summaryrefslogtreecommitdiff
path: root/spec/ruby/core/env/shared
AgeCommit message (Collapse)Author
2020-10-24Update to ruby/spec@4f59d86Benoit Daloze
2019-12-01[ruby/spec] Fix failures with LC_ALL=CNobuyoshi Nakada
https://github.com/ruby/spec/commit/51047687c0 https://github.com/ruby/spec/commit/2b87b467cc
2019-11-30Update to ruby/spec@4eec3dcBenoit Daloze
2019-10-26Update to ruby/spec@28a728bBenoit Daloze
2019-09-20Fix documentation for ENV.each to return ENVJeremy Evans
Also have spec check that it returns ENV. Mostly from burdettelamar@yahoo.com (Burdette Lamar). Fixes [Bug #16164]
2019-07-27Update to ruby/spec@875a09eBenoit Daloze
2019-06-27Update to ruby/spec@8d74d49Benoit Daloze
2019-06-21Alias ENV.merge! as ENV.updateKenichi Kamiya
[Feature #15947] Closes: https://github.com/ruby/ruby/pull/2246
2019-04-28Update to ruby/spec@7de852dBenoit Daloze
2019-01-20Update to ruby/spec@35a9fbaeregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-27Update to ruby/spec@a454137eregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-04Update to ruby/spec@c1b568beregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-27Update to ruby/spec@cbe855ceregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20Move spec/rubyspec to spec/ruby for consistencyeregon
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
0.2%;'/> -rw-r--r--README.ja (renamed from README.jp)70
-rw-r--r--ToDo117
-rw-r--r--array.c2279
-rw-r--r--bcc32/Makefile.sub585
-rw-r--r--bcc32/README.bcc32125
-rw-r--r--bcc32/configure.bat32
-rw-r--r--bcc32/mkexports.rb25
-rw-r--r--bcc32/setup.mak89
-rw-r--r--bignum.c1050
-rwxr-xr-xbin/erb139
-rw-r--r--bin/irb (renamed from sample/irb.rb)14
-rw-r--r--bin/rdoc67
-rwxr-xr-xbin/ri49
-rwxr-xr-xbin/testrb5
-rw-r--r--class.c646
-rw-r--r--compar.c166
-rw-r--r--config.guess1161
-rw-r--r--config.sub611
-rw-r--r--configure.in1053
-rw-r--r--cygwin/GNUmakefile.in58
-rw-r--r--defines.h227
-rw-r--r--dir.c1068
-rw-r--r--djgpp/GNUmakefile.in2
-rw-r--r--djgpp/README.djgpp2
-rw-r--r--djgpp/config.hin72
-rw-r--r--djgpp/config.sed184
-rw-r--r--djgpp/configure.bat1
-rw-r--r--dln.c309
-rw-r--r--dln.h21
-rw-r--r--doc/ChangeLog-1.8.024345
-rw-r--r--doc/NEWS837
-rw-r--r--doc/forwardable.rd84
-rw-r--r--doc/forwardable.rd.ja81
-rw-r--r--doc/irb/irb-tools.rd.ja185
-rw-r--r--doc/irb/irb.rd392
-rw-r--r--doc/irb/irb.rd.ja411
-rw-r--r--doc/shell.rd348
-rw-r--r--doc/shell.rd.ja336
-rw-r--r--enum.c714
-rw-r--r--env.h10
-rw-r--r--error.c971
-rw-r--r--eval.c7885
-rw-r--r--ext/.cvsignore3
-rw-r--r--ext/.document5
-rw-r--r--ext/Setup28
-rw-r--r--ext/Setup.atheos33
-rw-r--r--ext/Setup.dj32
-rw-r--r--ext/Setup.emx19
-rw-r--r--ext/Setup.nt24
-rw-r--r--ext/Setup.x6831
-rw-r--r--ext/Win32API/.cvsignore3
-rw-r--r--ext/Win32API/MANIFEST7
-rw-r--r--ext/Win32API/Win32API.c223
-rw-r--r--ext/Win32API/extconf.rb8
-rw-r--r--ext/Win32API/lib/win32/registry.rb831
-rw-r--r--ext/Win32API/lib/win32/resolv.rb366
-rw-r--r--ext/aix_mksym.rb33
-rw-r--r--ext/bigdecimal/.cvsignore3
-rw-r--r--ext/bigdecimal/README60
-rw-r--r--ext/bigdecimal/bigdecimal.c4057
-rw-r--r--ext/bigdecimal/bigdecimal.def2
-rw-r--r--ext/bigdecimal/bigdecimal.h216
-rw-r--r--ext/bigdecimal/bigdecimal_en.html797
-rw-r--r--ext/bigdecimal/bigdecimal_ja.html798
-rw-r--r--ext/bigdecimal/depend1
-rw-r--r--ext/bigdecimal/extconf.rb2
-rw-r--r--ext/bigdecimal/lib/bigdecimal/jacobian.rb63
-rw-r--r--ext/bigdecimal/lib/bigdecimal/ludcmp.rb77
-rw-r--r--ext/bigdecimal/lib/bigdecimal/math.rb196
-rw-r--r--ext/bigdecimal/lib/bigdecimal/newton.rb75
-rw-r--r--ext/bigdecimal/lib/bigdecimal/nlsolve.rb38
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb68
-rw-r--r--ext/bigdecimal/sample/linear.rb71
-rw-r--r--ext/bigdecimal/sample/nlsolve.rb38
-rw-r--r--ext/bigdecimal/sample/pi.rb20
-rw-r--r--ext/configsub.rb32
-rw-r--r--ext/curses/.cvsignore2
-rw-r--r--ext/curses/MANIFEST7
-rw-r--r--ext/curses/curses.c1335
-rw-r--r--ext/curses/extconf.rb22
-rw-r--r--ext/curses/hello.rb2
-rw-r--r--ext/curses/mouse.rb53
-rw-r--r--ext/curses/view2.rb115
-rw-r--r--ext/dbm/.cvsignore2
-rw-r--r--ext/dbm/MANIFEST4
-rw-r--r--ext/dbm/dbm.c343
-rw-r--r--ext/dbm/extconf.rb58
-rw-r--r--ext/dbm/testdbm.rb593
-rw-r--r--ext/digest/.cvsignore3
-rw-r--r--ext/digest/defs.h37
-rw-r--r--ext/digest/depend2
-rw-r--r--ext/digest/digest.c316
-rw-r--r--ext/digest/digest.h32
-rw-r--r--ext/digest/digest.txt113
-rw-r--r--ext/digest/digest.txt.ja111
-rw-r--r--ext/digest/extconf.rb6
-rw-r--r--ext/digest/lib/md5.rb14
-rw-r--r--ext/digest/lib/sha1.rb14
-rw-r--r--ext/digest/md5/.cvsignore3
-rw-r--r--ext/digest/md5/depend6
-rw-r--r--ext/digest/md5/extconf.rb26
-rw-r--r--ext/digest/md5/md5.c432
-rw-r--r--ext/digest/md5/md5.h83
-rw-r--r--ext/digest/md5/md5init.c35
-rw-r--r--ext/digest/md5/md5ossl.c30
-rw-r--r--ext/digest/md5/md5ossl.h11
-rw-r--r--ext/digest/rmd160/.cvsignore3
-rw-r--r--ext/digest/rmd160/depend8
-rw-r--r--ext/digest/rmd160/extconf.rb25
-rw-r--r--ext/digest/rmd160/rmd160.c464
-rw-r--r--ext/digest/rmd160/rmd160.h68
-rw-r--r--ext/digest/rmd160/rmd160hl.c96
-rw-r--r--ext/digest/rmd160/rmd160init.c38
-rw-r--r--ext/digest/rmd160/rmd160ossl.c45
-rw-r--r--ext/digest/rmd160/rmd160ossl.h20
-rw-r--r--ext/digest/sha1/.cvsignore3
-rw-r--r--ext/digest/sha1/depend8
-rw-r--r--ext/digest/sha1/extconf.rb25
-rw-r--r--ext/digest/sha1/sha1.c283
-rw-r--r--ext/digest/sha1/sha1.h50
-rw-r--r--ext/digest/sha1/sha1hl.c102
-rw-r--r--ext/digest/sha1/sha1init.c38
-rw-r--r--ext/digest/sha1/sha1ossl.c45
-rw-r--r--ext/digest/sha1/sha1ossl.h16
-rw-r--r--ext/digest/sha2/.cvsignore3
-rw-r--r--ext/digest/sha2/depend7
-rw-r--r--ext/digest/sha2/extconf.rb28
-rw-r--r--ext/digest/sha2/sha2.c937
-rw-r--r--ext/digest/sha2/sha2.h133
-rw-r--r--ext/digest/sha2/sha2hl.c252
-rw-r--r--ext/digest/sha2/sha2init.c47
-rw-r--r--ext/digest/test.sh33
-rw-r--r--ext/dl/.cvsignore8
-rw-r--r--ext/dl/depend46
-rw-r--r--ext/dl/dl.c714
-rw-r--r--ext/dl/dl.def59
-rw-r--r--ext/dl/dl.h313
-rw-r--r--ext/dl/doc/dl.txt266
-rw-r--r--ext/dl/extconf.rb193
-rw-r--r--ext/dl/h2rb500
-rw-r--r--ext/dl/handle.c215
-rw-r--r--ext/dl/install.rb49
-rw-r--r--ext/dl/lib/dl/import.rb215
-rw-r--r--ext/dl/lib/dl/struct.rb146
-rw-r--r--ext/dl/lib/dl/types.rb180
-rw-r--r--ext/dl/lib/dl/win32.rb25
-rw-r--r--ext/dl/mkcall.rb62
-rw-r--r--ext/dl/mkcallback.rb53
-rw-r--r--ext/dl/mkcbtable.rb18
-rw-r--r--ext/dl/ptr.c1065
-rw-r--r--ext/dl/sample/c++sample.C35
-rw-r--r--ext/dl/sample/c++sample.rb60
-rw-r--r--ext/dl/sample/drives.rb70
-rw-r--r--ext/dl/sample/getch.rb5
-rw-r--r--ext/dl/sample/libc.rb69
-rw-r--r--ext/dl/sample/msgbox.rb19
-rw-r--r--ext/dl/sample/msgbox2.rb18
-rw-r--r--ext/dl/sample/stream.rb87
-rw-r--r--ext/dl/sym.c990
-rw-r--r--ext/dl/test/libtest.def28
-rw-r--r--ext/dl/test/test.c247
-rw-r--r--ext/dl/test/test.rb295
-rw-r--r--ext/dl/type.rb115
-rw-r--r--ext/enumerator/.cvsignore (renamed from ext/md5/.cvsignore)1
-rw-r--r--ext/enumerator/enumerator.c195
-rw-r--r--ext/enumerator/enumerator.txt102
-rw-r--r--ext/enumerator/extconf.rb2
-rw-r--r--ext/etc/.cvsignore2
-rw-r--r--ext/etc/MANIFEST6
-rw-r--r--ext/etc/etc.c226
-rw-r--r--ext/etc/etc.txt2
-rw-r--r--ext/etc/etc.txt.ja (renamed from ext/etc/etc.txt.jp)2
-rw-r--r--ext/etc/extconf.rb31
-rw-r--r--ext/extmk.rb312
-rw-r--r--ext/extmk.rb.in778
-rw-r--r--ext/fcntl/.cvsignore2
-rw-r--r--ext/fcntl/MANIFEST3
-rw-r--r--ext/fcntl/extconf.rb2
-rw-r--r--ext/fcntl/fcntl.c7
-rw-r--r--ext/gdbm/.cvsignore2
-rw-r--r--ext/gdbm/MANIFEST5
-rw-r--r--ext/gdbm/gdbm.c751
-rw-r--r--ext/gdbm/testgdbm.rb663
-rw-r--r--ext/iconv/.cvsignore5
-rw-r--r--ext/iconv/charset_alias.rb52
-rw-r--r--ext/iconv/depend2
-rw-r--r--ext/iconv/extconf.rb49
-rw-r--r--ext/iconv/iconv.c885
-rw-r--r--ext/io/wait/.cvsignore2
-rw-r--r--ext/io/wait/extconf.rb12
-rw-r--r--ext/io/wait/lib/nonblock.rb23
-rw-r--r--ext/io/wait/wait.c106
-rw-r--r--ext/md5/MANIFEST8
-rw-r--r--ext/md5/depend2
-rw-r--r--ext/md5/extconf.rb3
-rw-r--r--ext/md5/md5.h86
-rw-r--r--ext/md5/md5.txt49
-rw-r--r--ext/md5/md5.txt.jp49
-rw-r--r--ext/md5/md5c.c337
-rw-r--r--ext/md5/md5init.c114
-rw-r--r--ext/nkf/.cvsignore2
-rw-r--r--ext/nkf/MANIFEST7
-rw-r--r--ext/nkf/depend2
-rw-r--r--ext/nkf/lib/kconv.rb197
-rw-r--r--ext/nkf/nkf-utf8/config.h52
-rw-r--r--ext/nkf/nkf-utf8/nkf.c4060
-rw-r--r--ext/nkf/nkf-utf8/utf8tbl.c5313
-rw-r--r--ext/nkf/nkf.c209
-rw-r--r--ext/nkf/nkf1.7/nkf.c1900
-rw-r--r--ext/nkf/test.rb538
-rw-r--r--ext/openssl/.cvsignore4
-rw-r--r--ext/openssl/extconf.rb145
-rw-r--r--ext/openssl/lib/net/ftptls.rb43
-rw-r--r--ext/openssl/lib/net/https.rb188
-rw-r--r--ext/openssl/lib/net/protocols.rb56
-rw-r--r--ext/openssl/lib/net/telnets.rb250
-rw-r--r--ext/openssl/lib/openssl.rb24
-rw-r--r--ext/openssl/lib/openssl/bn.rb35
-rw-r--r--ext/openssl/lib/openssl/buffering.rb200
-rw-r--r--ext/openssl/lib/openssl/cipher.rb52
-rw-r--r--ext/openssl/lib/openssl/digest.rb44
-rw-r--r--ext/openssl/lib/openssl/ssl.rb93
-rw-r--r--ext/openssl/lib/openssl/x509.rb71
-rw-r--r--ext/openssl/openssl_missing.c338
-rw-r--r--ext/openssl/openssl_missing.h126
-rw-r--r--ext/openssl/ossl.c449
-rw-r--r--ext/openssl/ossl.h217
-rw-r--r--ext/openssl/ossl_asn1.c1156
-rw-r--r--ext/openssl/ossl_asn1.h54
-rw-r--r--ext/openssl/ossl_bio.c70
-rw-r--r--ext/openssl/ossl_bio.h21
-rw-r--r--ext/openssl/ossl_bn.c719
-rw-r--r--ext/openssl/ossl_bn.h22
-rw-r--r--ext/openssl/ossl_cipher.c377
-rw-r--r--ext/openssl/ossl_cipher.h23
-rw-r--r--ext/openssl/ossl_config.c455
-rw-r--r--ext/openssl/ossl_config.h22
-rw-r--r--ext/openssl/ossl_digest.c294
-rw-r--r--ext/openssl/ossl_digest.h23
-rw-r--r--ext/openssl/ossl_engine.c329
-rw-r--r--ext/openssl/ossl_engine.h20
-rw-r--r--ext/openssl/ossl_hmac.c220
-rw-r--r--ext/openssl/ossl_hmac.h19
-rw-r--r--ext/openssl/ossl_ns_spki.c230
-rw-r--r--ext/openssl/ossl_ns_spki.h21
-rw-r--r--ext/openssl/ossl_ocsp.c765
-rw-r--r--ext/openssl/ossl_ocsp.h24
-rw-r--r--ext/openssl/ossl_pkcs12.c154
-rw-r--r--ext/openssl/ossl_pkcs12.h16
-rw-r--r--ext/openssl/ossl_pkcs7.c858
-rw-r--r--ext/openssl/ossl_pkcs7.h22
-rw-r--r--ext/openssl/ossl_pkey.c221
-rw-r--r--ext/openssl/ossl_pkey.h113
-rw-r--r--ext/openssl/ossl_pkey_dh.c395
-rw-r--r--ext/openssl/ossl_pkey_dsa.c423
-rw-r--r--ext/openssl/ossl_pkey_rsa.c503
-rw-r--r--ext/openssl/ossl_rand.c130
-rw-r--r--ext/openssl/ossl_rand.h20
-rw-r--r--ext/openssl/ossl_ssl.c793
-rw-r--r--ext/openssl/ossl_ssl.h21
-rw-r--r--ext/openssl/ossl_version.h16
-rw-r--r--ext/openssl/ossl_x509.c104
-rw-r--r--ext/openssl/ossl_x509.h114
-rw-r--r--ext/openssl/ossl_x509attr.c249
-rw-r--r--ext/openssl/ossl_x509cert.c672
-rw-r--r--ext/openssl/ossl_x509crl.c537
-rw-r--r--ext/openssl/ossl_x509ext.c439
-rw-r--r--ext/openssl/ossl_x509name.c311
-rw-r--r--ext/openssl/ossl_x509req.c466
-rw-r--r--ext/openssl/ossl_x509revoked.c229
-rw-r--r--ext/openssl/ossl_x509store.c559
-rw-r--r--ext/openssl/ruby_missing.h18
-rw-r--r--ext/pty/.cvsignore2
-rw-r--r--ext/pty/MANIFEST12
-rw-r--r--ext/pty/README40
-rw-r--r--ext/pty/README.expect.ja (renamed from ext/pty/README.expect.jp)0
-rw-r--r--ext/pty/README.ja (renamed from ext/pty/README.jp)0
-rw-r--r--ext/pty/expect_sample.rb15
-rw-r--r--ext/pty/extconf.rb7
-rw-r--r--ext/pty/lib/expect.rb6
-rw-r--r--ext/pty/pty.c298
-rw-r--r--ext/pty/script.rb3
-rw-r--r--ext/pty/shl.rb8
-rw-r--r--ext/racc/cparse/.cvsignore3
-rw-r--r--ext/racc/cparse/cparse.c824
-rw-r--r--ext/racc/cparse/depend1
-rw-r--r--ext/racc/cparse/extconf.rb4
-rw-r--r--ext/readline/.cvsignore2
-rw-r--r--ext/readline/MANIFEST5
-rw-r--r--ext/readline/README57
-rw-r--r--ext/readline/README.ja63
-rw-r--r--ext/readline/extconf.rb16
-rw-r--r--ext/readline/readline.c401
-rw-r--r--ext/sdbm/.cvsignore2
-rw-r--r--ext/sdbm/MANIFEST6
-rw-r--r--ext/sdbm/_sdbm.c2
-rw-r--r--ext/sdbm/init.c297
-rw-r--r--ext/sdbm/testsdbm.rb556
-rw-r--r--ext/socket/.cvsignore2
-rw-r--r--ext/socket/MANIFEST8
-rw-r--r--ext/socket/addrinfo.h7
-rw-r--r--ext/socket/extconf.rb137
-rw-r--r--ext/socket/getaddrinfo.c32
-rw-r--r--ext/socket/getnameinfo.c21
-rw-r--r--ext/socket/socket.c1747
-rw-r--r--ext/stringio/.cvsignore3
-rw-r--r--ext/stringio/README19
-rw-r--r--ext/stringio/depend2
-rw-r--r--ext/stringio/extconf.rb2
-rw-r--r--ext/stringio/stringio.c1017
-rw-r--r--ext/strscan/.cvsignore3
-rw-r--r--ext/strscan/depend1
-rw-r--r--ext/strscan/extconf.rb2
-rw-r--r--ext/strscan/strscan.c1346
-rw-r--r--ext/syck/.cvsignore3
-rw-r--r--ext/syck/bytecode.c1171
-rw-r--r--ext/syck/depend12
-rw-r--r--ext/syck/emitter.c444
-rw-r--r--ext/syck/extconf.rb5
-rw-r--r--ext/syck/gram.c1796
-rw-r--r--ext/syck/gram.h81
-rw-r--r--ext/syck/handler.c156
-rw-r--r--ext/syck/implicit.c2965
-rw-r--r--ext/syck/node.c337
-rw-r--r--ext/syck/rubyext.c1581
-rw-r--r--ext/syck/syck.c506
-rw-r--r--ext/syck/syck.h409
-rw-r--r--ext/syck/token.c2636
-rw-r--r--ext/syck/yaml2byte.c251
-rw-r--r--ext/syck/yamlbyte.h170
-rw-r--r--ext/syslog/.cvsignore3
-rw-r--r--ext/syslog/depend2
-rw-r--r--ext/syslog/extconf.rb10
-rw-r--r--ext/syslog/syslog.c394
-rw-r--r--ext/syslog/syslog.txt121
-rw-r--r--ext/syslog/test.rb164
-rw-r--r--ext/tcltklib/.cvsignore2
-rw-r--r--ext/tcltklib/MANIFEST16
-rw-r--r--ext/tcltklib/MANUAL.eng420
-rw-r--r--ext/tcltklib/MANUAL.euc409
-rw-r--r--ext/tcltklib/README.1st55
-rw-r--r--ext/tcltklib/README.ActiveTcl49
-rw-r--r--ext/tcltklib/README.euc26
-rw-r--r--ext/tcltklib/demo/lines1.rb26
-rw-r--r--ext/tcltklib/demo/lines2.rb26
-rw-r--r--ext/tcltklib/demo/lines3.rb54
-rw-r--r--ext/tcltklib/demo/lines4.rb54
-rw-r--r--ext/tcltklib/demo/safeTk.rb22
-rw-r--r--ext/tcltklib/extconf.rb247
-rw-r--r--ext/tcltklib/lib/tcltk.rb36
-rw-r--r--ext/tcltklib/sample/sample1.rb6
-rw-r--r--ext/tcltklib/sample/sample2.rb504
-rw-r--r--ext/tcltklib/stubs.c70
-rw-r--r--ext/tcltklib/tcltklib.c6282
-rw-r--r--ext/tk/.cvsignore2
-rw-r--r--ext/tk/ChangeLog.tkextlib87
-rw-r--r--ext/tk/MANIFEST25
-rw-r--r--ext/tk/README.1st23
-rw-r--r--ext/tk/README.fork34
-rw-r--r--ext/tk/extconf.rb2
-rw-r--r--ext/tk/lib/README30
-rw-r--r--ext/tk/lib/multi-tk.rb2381
-rw-r--r--ext/tk/lib/remote-tk.rb468
-rw-r--r--ext/tk/lib/tk.rb5590
-rw-r--r--ext/tk/lib/tk/after.rb6
-rw-r--r--ext/tk/lib/tk/autoload.rb192
-rw-r--r--ext/tk/lib/tk/bgerror.rb29
-rw-r--r--ext/tk/lib/tk/bindtag.rb79
-rw-r--r--ext/tk/lib/tk/button.rb27
-rw-r--r--ext/tk/lib/tk/canvas.rb701
-rw-r--r--ext/tk/lib/tk/canvastag.rb351
-rw-r--r--ext/tk/lib/tk/checkbutton.rb25
-rw-r--r--ext/tk/lib/tk/clipboard.rb75
-rw-r--r--ext/tk/lib/tk/clock.rb57
-rw-r--r--ext/tk/lib/tk/composite.rb293
-rw-r--r--ext/tk/lib/tk/console.rb29
-rw-r--r--ext/tk/lib/tk/dialog.rb293
-rw-r--r--ext/tk/lib/tk/encodedstr.rb107
-rw-r--r--ext/tk/lib/tk/entry.rb110
-rw-r--r--ext/tk/lib/tk/event.rb180
-rw-r--r--ext/tk/lib/tk/font.rb1464
-rw-r--r--ext/tk/lib/tk/frame.rb123
-rw-r--r--ext/tk/lib/tk/grid.rb211
-rw-r--r--ext/tk/lib/tk/image.rb186
-rw-r--r--ext/tk/lib/tk/itemconfig.rb794
-rw-r--r--ext/tk/lib/tk/itemfont.rb300
-rw-r--r--ext/tk/lib/tk/kinput.rb71
-rw-r--r--ext/tk/lib/tk/label.rb22
-rw-r--r--ext/tk/lib/tk/labelframe.rb20
-rw-r--r--ext/tk/lib/tk/listbox.rb273
-rw-r--r--ext/tk/lib/tk/macpkg.rb68
-rw-r--r--ext/tk/lib/tk/menu.rb488
-rw-r--r--ext/tk/lib/tk/menubar.rb131
-rw-r--r--ext/tk/lib/tk/menuspec.rb265
-rw-r--r--ext/tk/lib/tk/message.rb19
-rw-r--r--ext/tk/lib/tk/mngfocus.rb33
-rw-r--r--ext/tk/lib/tk/msgcat.rb286
-rw-r--r--ext/tk/lib/tk/namespace.rb294
-rw-r--r--ext/tk/lib/tk/optiondb.rb370
-rw-r--r--ext/tk/lib/tk/optionobj.rb212
-rw-r--r--ext/tk/lib/tk/pack.rb90
-rw-r--r--ext/tk/lib/tk/package.rb139
-rw-r--r--ext/tk/lib/tk/palette.rb54
-rw-r--r--ext/tk/lib/tk/panedwindow.rb204
-rw-r--r--ext/tk/lib/tk/place.rb128
-rw-r--r--ext/tk/lib/tk/radiobutton.rb32
-rw-r--r--ext/tk/lib/tk/root.rb86
-rw-r--r--ext/tk/lib/tk/scale.rb81
-rw-r--r--ext/tk/lib/tk/scrollable.rb79
-rw-r--r--ext/tk/lib/tk/scrollbar.rb124
-rw-r--r--ext/tk/lib/tk/scrollbox.rb36
-rw-r--r--ext/tk/lib/tk/selection.rb86
-rw-r--r--ext/tk/lib/tk/spinbox.rb39
-rw-r--r--ext/tk/lib/tk/tagfont.rb43
-rw-r--r--ext/tk/lib/tk/text.rb1285
-rw-r--r--ext/tk/lib/tk/textimage.rb72
-rw-r--r--ext/tk/lib/tk/textmark.rb135
-rw-r--r--ext/tk/lib/tk/texttag.rb253
-rw-r--r--ext/tk/lib/tk/textwindow.rb137
-rw-r--r--ext/tk/lib/tk/timer.rb490
-rw-r--r--ext/tk/lib/tk/toplevel.rb232
-rw-r--r--ext/tk/lib/tk/txtwin_abst.rb39
-rw-r--r--ext/tk/lib/tk/validation.rb373
-rw-r--r--ext/tk/lib/tk/variable.rb1016
-rw-r--r--ext/tk/lib/tk/virtevent.rb90
-rw-r--r--ext/tk/lib/tk/winfo.rb387
-rw-r--r--ext/tk/lib/tk/winpkg.rb138
-rw-r--r--ext/tk/lib/tk/wm.rb280
-rw-r--r--ext/tk/lib/tk/xim.rb122
-rw-r--r--ext/tk/lib/tkafter.rb316
-rw-r--r--ext/tk/lib/tkbgerror.rb17
-rw-r--r--ext/tk/lib/tkcanvas.rb943
-rw-r--r--ext/tk/lib/tkclass.rb15
-rw-r--r--ext/tk/lib/tkconsole.rb4
-rw-r--r--ext/tk/lib/tkdialog.rb141
-rw-r--r--ext/tk/lib/tkentry.rb215
-rw-r--r--ext/tk/lib/tkextlib/ICONS.rb13
-rw-r--r--ext/tk/lib/tkextlib/ICONS/icons.rb108
-rw-r--r--ext/tk/lib/tkextlib/ICONS/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/SUPPORT_STATUS173
-rw-r--r--ext/tk/lib/tkextlib/bwidget.rb146
-rw-r--r--ext/tk/lib/tkextlib/bwidget/arrowbutton.rb21
-rw-r--r--ext/tk/lib/tkextlib/bwidget/bitmap.rb21
-rw-r--r--ext/tk/lib/tkextlib/bwidget/button.rb21
-rw-r--r--ext/tk/lib/tkextlib/bwidget/buttonbox.rb73
-rw-r--r--ext/tk/lib/tkextlib/bwidget/combobox.rb45
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dialog.rb147
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dragsite.rb31
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dropsite.rb39
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dynamichelp.rb51
-rw-r--r--ext/tk/lib/tkextlib/bwidget/entry.rb28
-rw-r--r--ext/tk/lib/tkextlib/bwidget/label.rb26
-rw-r--r--ext/tk/lib/tkextlib/bwidget/labelentry.rb45
-rw-r--r--ext/tk/lib/tkextlib/bwidget/labelframe.rb30
-rw-r--r--ext/tk/lib/tkextlib/bwidget/listbox.rb290
-rw-r--r--ext/tk/lib/tkextlib/bwidget/mainframe.rb73
-rw-r--r--ext/tk/lib/tkextlib/bwidget/messagedlg.rb167
-rw-r--r--ext/tk/lib/tkextlib/bwidget/notebook.rb116
-rw-r--r--ext/tk/lib/tkextlib/bwidget/pagesmanager.rb61
-rw-r--r--ext/tk/lib/tkextlib/bwidget/panedwindow.rb31
-rw-r--r--ext/tk/lib/tkextlib/bwidget/passwddlg.rb27
-rw-r--r--ext/tk/lib/tkextlib/bwidget/progressbar.rb20
-rw-r--r--ext/tk/lib/tkextlib/bwidget/progressdlg.rb54
-rw-r--r--ext/tk/lib/tkextlib/bwidget/scrollableframe.rb34
-rw-r--r--ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb32
-rw-r--r--ext/tk/lib/tkextlib/bwidget/scrollview.rb20
-rw-r--r--ext/tk/lib/tkextlib/bwidget/selectcolor.rb45
-rw-r--r--ext/tk/lib/tkextlib/bwidget/selectfont.rb79
-rw-r--r--ext/tk/lib/tkextlib/bwidget/separator.rb20
-rw-r--r--ext/tk/lib/tkextlib/bwidget/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/spinbox.rb58
-rw-r--r--ext/tk/lib/tkextlib/bwidget/titleframe.rb27
-rw-r--r--ext/tk/lib/tkextlib/bwidget/tree.rb374
-rw-r--r--ext/tk/lib/tkextlib/bwidget/widget.rb113
-rw-r--r--ext/tk/lib/tkextlib/itcl.rb13
-rw-r--r--ext/tk/lib/tkextlib/itcl/incr_tcl.rb167
-rw-r--r--ext/tk/lib/tkextlib/itcl/setup.rb13
-rw-r--r--ext/tk/lib/tkextlib/itk.rb13
-rw-r--r--ext/tk/lib/tkextlib/itk/incr_tk.rb383
-rw-r--r--ext/tk/lib/tkextlib/itk/setup.rb13
-rw-r--r--ext/tk/lib/tkextlib/iwidgets.rb89
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/buttonbox.rb114
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/calendar.rb88
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb43
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb38
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/checkbox.rb111
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/combobox.rb99
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/dateentry.rb20
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/datefield.rb43
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/dialog.rb20
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/dialogshell.rb114
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb45
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/entryfield.rb161
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/extbutton.rb30
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb33
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb33
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/feedback.rb30
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb33
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb33
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/finddialog.rb29
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/hierarchy.rb294
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb40
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/labeledframe.rb24
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb30
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/mainwindow.rb52
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/menubar.rb190
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/messagebox.rb81
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/messagedialog.rb20
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/notebook.rb163
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/optionmenu.rb87
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/panedwindow.rb127
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/promptdialog.rb131
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/pushbutton.rb30
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/radiobox.rb111
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scopedobject.rb24
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb315
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb59
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb43
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb190
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb518
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb20
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectionbox.rb92
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb92
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/shell.rb38
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spindate.rb38
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spinint.rb20
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spinner.rb150
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spintime.rb38
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb154
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabset.rb89
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/timeentry.rb20
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/timefield.rb43
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/toolbar.rb87
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/watch.rb45
-rwxr-xr-xext/tk/lib/tkextlib/pkg_checker.rb184
-rw-r--r--ext/tk/lib/tkextlib/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tcllib.rb69
-rw-r--r--ext/tk/lib/tkextlib/tcllib/README135
-rw-r--r--ext/tk/lib/tkextlib/tcllib/autoscroll.rb143
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ctext.rb143
-rw-r--r--ext/tk/lib/tkextlib/tcllib/cursor.rb90
-rw-r--r--ext/tk/lib/tkextlib/tcllib/datefield.rb52
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ico.rb109
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ip_entry.rb55
-rw-r--r--ext/tk/lib/tkextlib/tcllib/plotchart.rb708
-rw-r--r--ext/tk/lib/tkextlib/tcllib/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tcllib/style.rb55
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tkpiechart.rb287
-rw-r--r--ext/tk/lib/tkextlib/tclx.rb13
-rw-r--r--ext/tk/lib/tkextlib/tclx/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tclx/tclx.rb59
-rw-r--r--ext/tk/lib/tkextlib/tile.rb69
-rw-r--r--ext/tk/lib/tkextlib/tile/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tile/style.rb70
-rw-r--r--ext/tk/lib/tkextlib/tile/tbutton.rb30
-rw-r--r--ext/tk/lib/tkextlib/tile/tcheckbutton.rb31
-rw-r--r--ext/tk/lib/tkextlib/tile/tlabel.rb30
-rw-r--r--ext/tk/lib/tkextlib/tile/tmenubutton.rb30
-rw-r--r--ext/tk/lib/tkextlib/tile/tnotebook.rb92
-rw-r--r--ext/tk/lib/tkextlib/tile/tradiobutton.rb31
-rw-r--r--ext/tk/lib/tkextlib/tkDND.rb18
-rw-r--r--ext/tk/lib/tkextlib/tkDND/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tkDND/shape.rb117
-rw-r--r--ext/tk/lib/tkextlib/tkDND/tkdnd.rb124
-rw-r--r--ext/tk/lib/tkextlib/tkHTML.rb13
-rw-r--r--ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb433
-rw-r--r--ext/tk/lib/tkextlib/tkHTML/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tkimg.rb31
-rw-r--r--ext/tk/lib/tkextlib/tkimg/README26
-rw-r--r--ext/tk/lib/tkextlib/tkimg/bmp.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/gif.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/ico.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/jpeg.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/pcx.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/pixmap.rb39
-rw-r--r--ext/tk/lib/tkextlib/tkimg/png.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/ppm.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/ps.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tkimg/sgi.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/sun.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/tga.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/tiff.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/window.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/xbm.rb28
-rw-r--r--ext/tk/lib/tkextlib/tkimg/xpm.rb28
-rw-r--r--ext/tk/lib/tkextlib/tktable.rb14
-rw-r--r--ext/tk/lib/tkextlib/tktable/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tktable/tktable.rb796
-rw-r--r--ext/tk/lib/tkextlib/tktrans.rb14
-rw-r--r--ext/tk/lib/tkextlib/tktrans/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/tktrans/tktrans.rb59
-rw-r--r--ext/tk/lib/tkextlib/treectrl.rb13
-rw-r--r--ext/tk/lib/tkextlib/treectrl/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/treectrl/tktreectrl.rb923
-rw-r--r--ext/tk/lib/tkextlib/vu.rb43
-rw-r--r--ext/tk/lib/tkextlib/vu/bargraph.rb51
-rw-r--r--ext/tk/lib/tkextlib/vu/charts.rb47
-rw-r--r--ext/tk/lib/tkextlib/vu/dial.rb102
-rw-r--r--ext/tk/lib/tkextlib/vu/pie.rb235
-rw-r--r--ext/tk/lib/tkextlib/vu/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/vu/spinbox.rb22
-rw-r--r--ext/tk/lib/tkextlib/winico.rb14
-rw-r--r--ext/tk/lib/tkextlib/winico/setup.rb8
-rw-r--r--ext/tk/lib/tkextlib/winico/winico.rb181
-rw-r--r--ext/tk/lib/tkfont.rb1026
-rw-r--r--ext/tk/lib/tkmacpkg.rb4
-rw-r--r--ext/tk/lib/tkmenubar.rb137
-rw-r--r--ext/tk/lib/tkmngfocus.rb27
-rw-r--r--ext/tk/lib/tkpalette.rb48
-rw-r--r--ext/tk/lib/tkscrollbox.rb31
-rw-r--r--ext/tk/lib/tktext.rb1087
-rw-r--r--ext/tk/lib/tkvirtevent.rb81
-rw-r--r--ext/tk/lib/tkwinpkg.rb4
-rw-r--r--ext/tk/sample/binding_sample.rb87
-rw-r--r--ext/tk/sample/bindtag_sample.rb127
-rw-r--r--ext/tk/sample/binstr_usage.rb39
-rw-r--r--ext/tk/sample/btn_with_frame.rb20
-rw-r--r--ext/tk/sample/cmd_res_test.rb17
-rw-r--r--ext/tk/sample/cmd_resource5
-rw-r--r--ext/tk/sample/demos-en/ChangeLog64
-rw-r--r--ext/tk/sample/demos-en/ChangeLog.prev9
-rw-r--r--ext/tk/sample/demos-en/README138
-rw-r--r--ext/tk/sample/demos-en/README.1st18
-rw-r--r--ext/tk/sample/demos-en/README.tkencoding29
-rw-r--r--ext/tk/sample/demos-en/arrow.rb239
-rw-r--r--ext/tk/sample/demos-en/bind.rb110
-rw-r--r--ext/tk/sample/demos-en/bitmap.rb73
-rw-r--r--ext/tk/sample/demos-en/browse163
-rw-r--r--ext/tk/sample/demos-en/browse282
-rw-r--r--ext/tk/sample/demos-en/button.rb84
-rw-r--r--ext/tk/sample/demos-en/check.rb70
-rw-r--r--ext/tk/sample/demos-en/check2.rb107
-rw-r--r--ext/tk/sample/demos-en/clrpick.rb77
-rw-r--r--ext/tk/sample/demos-en/colors.rb148
-rw-r--r--ext/tk/sample/demos-en/cscroll.rb134
-rw-r--r--ext/tk/sample/demos-en/ctext.rb186
-rw-r--r--ext/tk/sample/demos-en/dialog1.rb38
-rw-r--r--ext/tk/sample/demos-en/dialog2.rb41
-rw-r--r--ext/tk/sample/demos-en/doc.org/README7
-rw-r--r--ext/tk/sample/demos-en/doc.org/README.JP14
-rw-r--r--ext/tk/sample/demos-en/doc.org/README.tk8046
-rw-r--r--ext/tk/sample/demos-en/doc.org/license.terms39
-rw-r--r--ext/tk/sample/demos-en/doc.org/license.terms.tk8039
-rw-r--r--ext/tk/sample/demos-en/entry1.rb56
-rw-r--r--ext/tk/sample/demos-en/entry2.rb91
-rw-r--r--ext/tk/sample/demos-en/entry3.rb200
-rw-r--r--ext/tk/sample/demos-en/filebox.rb97
-rw-r--r--ext/tk/sample/demos-en/floor.rb1721
-rw-r--r--ext/tk/sample/demos-en/floor2.rb1720
-rw-r--r--ext/tk/sample/demos-en/form.rb62
-rw-r--r--ext/tk/sample/demos-en/hello14
-rw-r--r--ext/tk/sample/demos-en/hscale.rb74
-rw-r--r--ext/tk/sample/demos-en/icon.rb99
-rw-r--r--ext/tk/sample/demos-en/image1.rb60
-rw-r--r--ext/tk/sample/demos-en/image2.rb105
-rw-r--r--ext/tk/sample/demos-en/image3.rb121
-rw-r--r--ext/tk/sample/demos-en/items.rb374
-rw-r--r--ext/tk/sample/demos-en/ixset333
-rw-r--r--ext/tk/sample/demos-en/ixset2367
-rw-r--r--ext/tk/sample/demos-en/label.rb69
-rw-r--r--ext/tk/sample/demos-en/labelframe.rb93
-rw-r--r--ext/tk/sample/demos-en/menu.rb186
-rw-r--r--ext/tk/sample/demos-en/menu84.rb213
-rw-r--r--ext/tk/sample/demos-en/menubu.rb235
-rw-r--r--ext/tk/sample/demos-en/msgbox.rb88
-rw-r--r--ext/tk/sample/demos-en/paned1.rb45
-rw-r--r--ext/tk/sample/demos-en/paned2.rb92
-rw-r--r--ext/tk/sample/demos-en/patch_1.1c193
-rw-r--r--ext/tk/sample/demos-en/plot.rb122
-rw-r--r--ext/tk/sample/demos-en/puzzle.rb120
-rw-r--r--ext/tk/sample/demos-en/radio.rb84
-rw-r--r--ext/tk/sample/demos-en/radio2.rb106
-rw-r--r--ext/tk/sample/demos-en/radio3.rb114
-rw-r--r--ext/tk/sample/demos-en/rmt268
-rw-r--r--ext/tk/sample/demos-en/rolodex320
-rw-r--r--ext/tk/sample/demos-en/rolodex-j323
-rw-r--r--ext/tk/sample/demos-en/ruler.rb203
-rw-r--r--ext/tk/sample/demos-en/sayings.rb104
-rw-r--r--ext/tk/sample/demos-en/search.rb180
-rw-r--r--ext/tk/sample/demos-en/spin.rb63
-rw-r--r--ext/tk/sample/demos-en/square81
-rw-r--r--ext/tk/sample/demos-en/states.rb78
-rw-r--r--ext/tk/sample/demos-en/style.rb211
-rw-r--r--ext/tk/sample/demos-en/tcolor521
-rw-r--r--ext/tk/sample/demos-en/tcolor.bak513
-rw-r--r--ext/tk/sample/demos-en/text.rb126
-rw-r--r--ext/tk/sample/demos-en/timer136
-rw-r--r--ext/tk/sample/demos-en/tkencoding.rb42
-rw-r--r--ext/tk/sample/demos-en/twind.rb285
-rw-r--r--ext/tk/sample/demos-en/twind2.rb382
-rw-r--r--ext/tk/sample/demos-en/unicodeout.rb112
-rw-r--r--ext/tk/sample/demos-en/vscale.rb78
-rw-r--r--ext/tk/sample/demos-en/widget822
-rw-r--r--ext/tk/sample/demos-jp/README54
-rw-r--r--ext/tk/sample/demos-jp/README.1st20
-rw-r--r--ext/tk/sample/demos-jp/arrow.rb236
-rw-r--r--ext/tk/sample/demos-jp/bind.rb107
-rw-r--r--ext/tk/sample/demos-jp/bitmap.rb71
-rw-r--r--ext/tk/sample/demos-jp/browse163
-rw-r--r--ext/tk/sample/demos-jp/browse282
-rw-r--r--ext/tk/sample/demos-jp/button.rb81
-rw-r--r--ext/tk/sample/demos-jp/check.rb67
-rw-r--r--ext/tk/sample/demos-jp/check2.rb107
-rw-r--r--ext/tk/sample/demos-jp/clrpick.rb75
-rw-r--r--ext/tk/sample/demos-jp/colors.rb144
-rw-r--r--ext/tk/sample/demos-jp/cscroll.rb131
-rw-r--r--ext/tk/sample/demos-jp/ctext.rb182
-rw-r--r--ext/tk/sample/demos-jp/dialog1.rb38
-rw-r--r--ext/tk/sample/demos-jp/dialog2.rb42
-rw-r--r--ext/tk/sample/demos-jp/doc.org/README7
-rw-r--r--ext/tk/sample/demos-jp/doc.org/README.JP14
-rw-r--r--ext/tk/sample/demos-jp/doc.org/README.tk8046
-rw-r--r--ext/tk/sample/demos-jp/doc.org/license.terms39
-rw-r--r--ext/tk/sample/demos-jp/doc.org/license.terms.tk8039
-rw-r--r--ext/tk/sample/demos-jp/entry1.rb57
-rw-r--r--ext/tk/sample/demos-jp/entry2.rb88
-rw-r--r--ext/tk/sample/demos-jp/entry3.rb204
-rw-r--r--ext/tk/sample/demos-jp/filebox.rb96
-rw-r--r--ext/tk/sample/demos-jp/floor.rb1718
-rw-r--r--ext/tk/sample/demos-jp/floor2.rb1716
-rw-r--r--ext/tk/sample/demos-jp/form.rb63
-rw-r--r--ext/tk/sample/demos-jp/hello9
-rw-r--r--ext/tk/sample/demos-jp/hscale.rb77
-rw-r--r--ext/tk/sample/demos-jp/icon.rb96
-rw-r--r--ext/tk/sample/demos-jp/image1.rb58
-rw-r--r--ext/tk/sample/demos-jp/image2.rb102
-rw-r--r--ext/tk/sample/demos-jp/image3.rb122
-rw-r--r--ext/tk/sample/demos-jp/items.rb371
-rw-r--r--ext/tk/sample/demos-jp/ixset333
-rw-r--r--ext/tk/sample/demos-jp/ixset2368
-rw-r--r--ext/tk/sample/demos-jp/label.rb65
-rw-r--r--ext/tk/sample/demos-jp/labelframe.rb98
-rw-r--r--ext/tk/sample/demos-jp/menu.rb188
-rw-r--r--ext/tk/sample/demos-jp/menu84.rb210
-rw-r--r--ext/tk/sample/demos-jp/menu8x.rb222
-rw-r--r--ext/tk/sample/demos-jp/menubu.rb235
-rw-r--r--ext/tk/sample/demos-jp/msgbox.rb86
-rw-r--r--ext/tk/sample/demos-jp/paned1.rb48
-rw-r--r--ext/tk/sample/demos-jp/paned2.rb96
-rw-r--r--ext/tk/sample/demos-jp/plot.rb119
-rw-r--r--ext/tk/sample/demos-jp/puzzle.rb116
-rw-r--r--ext/tk/sample/demos-jp/radio.rb81
-rw-r--r--ext/tk/sample/demos-jp/radio2.rb107
-rw-r--r--ext/tk/sample/demos-jp/radio3.rb114
-rw-r--r--ext/tk/sample/demos-jp/rmt268
-rw-r--r--ext/tk/sample/demos-jp/rolodex320
-rw-r--r--ext/tk/sample/demos-jp/rolodex-j299
-rw-r--r--ext/tk/sample/demos-jp/ruler.rb200
-rw-r--r--ext/tk/sample/demos-jp/sayings.rb100
-rw-r--r--ext/tk/sample/demos-jp/search.rb176
-rw-r--r--ext/tk/sample/demos-jp/spin.rb67
-rw-r--r--ext/tk/sample/demos-jp/square81
-rw-r--r--ext/tk/sample/demos-jp/states.rb71
-rw-r--r--ext/tk/sample/demos-jp/style.rb248
-rw-r--r--ext/tk/sample/demos-jp/tcolor528
-rw-r--r--ext/tk/sample/demos-jp/text.rb117
-rw-r--r--ext/tk/sample/demos-jp/timer136
-rw-r--r--ext/tk/sample/demos-jp/twind.rb285
-rw-r--r--ext/tk/sample/demos-jp/twind2.rb381
-rw-r--r--ext/tk/sample/demos-jp/unicodeout.rb115
-rw-r--r--ext/tk/sample/demos-jp/vscale.rb78
-rw-r--r--ext/tk/sample/demos-jp/widget848
-rw-r--r--ext/tk/sample/encstr_usage.rb29
-rw-r--r--ext/tk/sample/images/earth.gifbin0 -> 51712 bytes-rw-r--r--ext/tk/sample/images/earthris.gifbin0 -> 6343 bytes-rw-r--r--ext/tk/sample/images/face.xbm173
-rw-r--r--ext/tk/sample/images/flagdown.xbm27
-rw-r--r--ext/tk/sample/images/flagup.xbm27
-rw-r--r--ext/tk/sample/images/gray25.xbm6
-rw-r--r--ext/tk/sample/images/grey.256
-rw-r--r--ext/tk/sample/images/grey.56
-rw-r--r--ext/tk/sample/images/letters.xbm27
-rw-r--r--ext/tk/sample/images/noletter.xbm27
-rw-r--r--ext/tk/sample/images/pattern.xbm6
-rw-r--r--ext/tk/sample/images/tcllogo.gifbin0 -> 2341 bytes-rw-r--r--ext/tk/sample/images/teapot.ppm56
-rw-r--r--ext/tk/sample/iso2022-kr.txt2
-rw-r--r--ext/tk/sample/menubar1.rb51
-rw-r--r--ext/tk/sample/menubar2.rb56
-rw-r--r--ext/tk/sample/msgs_rb/README3
-rw-r--r--ext/tk/sample/msgs_rb/cs.msg84
-rw-r--r--ext/tk/sample/msgs_rb/de.msg88
-rw-r--r--ext/tk/sample/msgs_rb/el.msg98
-rw-r--r--ext/tk/sample/msgs_rb/en.msg83
-rw-r--r--ext/tk/sample/msgs_rb/en_gb.msg7
-rw-r--r--ext/tk/sample/msgs_rb/eo.msg87
-rw-r--r--ext/tk/sample/msgs_rb/es.msg84
-rw-r--r--ext/tk/sample/msgs_rb/fr.msg84
-rw-r--r--ext/tk/sample/msgs_rb/it.msg84
-rw-r--r--ext/tk/sample/msgs_rb/ja.msg13
-rw-r--r--ext/tk/sample/msgs_rb/nl.msg123
-rw-r--r--ext/tk/sample/msgs_rb/pl.msg87
-rw-r--r--ext/tk/sample/msgs_rb/ru.msg87
-rw-r--r--ext/tk/sample/msgs_rb2/README5
-rw-r--r--ext/tk/sample/msgs_rb2/de.msg88
-rw-r--r--ext/tk/sample/msgs_rb2/ja.msg85
-rw-r--r--ext/tk/sample/msgs_tk/README4
-rw-r--r--ext/tk/sample/msgs_tk/cs.msg84
-rw-r--r--ext/tk/sample/msgs_tk/de.msg88
-rw-r--r--ext/tk/sample/msgs_tk/el.msg103
-rw-r--r--ext/tk/sample/msgs_tk/en.msg83
-rw-r--r--ext/tk/sample/msgs_tk/en_gb.msg7
-rw-r--r--ext/tk/sample/msgs_tk/eo.msg87
-rw-r--r--ext/tk/sample/msgs_tk/es.msg84
-rw-r--r--ext/tk/sample/msgs_tk/fr.msg84
-rw-r--r--ext/tk/sample/msgs_tk/it.msg84
-rw-r--r--ext/tk/sample/msgs_tk/ja.msg13
-rw-r--r--ext/tk/sample/msgs_tk/license.terms39
-rw-r--r--ext/tk/sample/msgs_tk/nl.msg123
-rw-r--r--ext/tk/sample/msgs_tk/pl.msg87
-rw-r--r--ext/tk/sample/msgs_tk/ru.msg87
-rw-r--r--ext/tk/sample/multi-ip_sample.rb102
-rw-r--r--ext/tk/sample/multi-ip_sample2.rb29
-rw-r--r--ext/tk/sample/optobj_sample.rb67
-rw-r--r--ext/tk/sample/propagate.rb30
-rw-r--r--ext/tk/sample/remote-ip_sample.rb33
-rw-r--r--ext/tk/sample/remote-ip_sample2.rb56
-rw-r--r--ext/tk/sample/resource.en13
-rw-r--r--ext/tk/sample/resource.ja13
-rw-r--r--ext/tk/sample/safe-tk.rb115
-rw-r--r--ext/tk/sample/tkalignbox.rb225
-rw-r--r--ext/tk/sample/tkballoonhelp.rb99
-rw-r--r--ext/tk/sample/tkbiff.rb38
-rw-r--r--ext/tk/sample/tkbrowse.rb10
-rw-r--r--ext/tk/sample/tkcombobox.rb426
-rw-r--r--ext/tk/sample/tkdialog.rb3
-rw-r--r--ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt61
-rw-r--r--ext/tk/sample/tkextlib/ICONS/tkIcons195
-rw-r--r--ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde658
-rw-r--r--ext/tk/sample/tkextlib/ICONS/tkIcons.kde195
-rw-r--r--ext/tk/sample/tkextlib/ICONS/viewIcons.rb329
-rw-r--r--ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt53
-rw-r--r--ext/tk/sample/tkextlib/bwidget/basic.rb198
-rw-r--r--ext/tk/sample/tkextlib/bwidget/bwidget.xbm46
-rw-r--r--ext/tk/sample/tkextlib/bwidget/demo.rb243
-rw-r--r--ext/tk/sample/tkextlib/bwidget/dnd.rb46
-rw-r--r--ext/tk/sample/tkextlib/bwidget/manager.rb150
-rw-r--r--ext/tk/sample/tkextlib/bwidget/select.rb82
-rw-r--r--ext/tk/sample/tkextlib/bwidget/tmpldlg.rb221
-rw-r--r--ext/tk/sample/tkextlib/bwidget/tree.rb289
-rw-r--r--ext/tk/sample/tkextlib/bwidget/x1.xbm2258
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt42
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gifbin0 -> 279 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gifbin0 -> 249 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gifbin0 -> 269 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gifbin0 -> 179 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gifbin0 -> 396 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gifbin0 -> 386 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gifbin0 -> 591 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gifbin0 -> 183 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gifbin0 -> 212 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gifbin0 -> 258 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gifbin0 -> 376 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gifbin0 -> 141 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gifbin0 -> 263 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gifbin0 -> 174 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gifbin0 -> 270 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gifbin0 -> 124 bytes-rw-r--r--ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb22
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb10
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb12
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb32
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb7
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb20
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb16
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb39
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb40
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb40
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb20
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb29
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb10
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb28
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb15
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb25
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb13
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb64
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb124
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb44
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb19
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb19
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb44
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb30
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb30
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb14
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb22
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb22
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb17
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb9
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb13
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb13
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb18
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb15
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb22
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb11
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb19
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb12
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/shell.rb17
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb7
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb10
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb33
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb7
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb26
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb30
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb34
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb7
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb8
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb152
-rw-r--r--ext/tk/sample/tkextlib/iwidgets/sample/watch.rb18
-rw-r--r--ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt46
-rw-r--r--ext/tk/sample/tkextlib/tcllib/datefield.rb29
-rw-r--r--ext/tk/sample/tkextlib/tcllib/plotdemos1.rb158
-rw-r--r--ext/tk/sample/tkextlib/tcllib/plotdemos2.rb71
-rw-r--r--ext/tk/sample/tkextlib/tcllib/plotdemos3.rb83
-rw-r--r--ext/tk/sample/tkextlib/tcllib/xyplot.rb17
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt12
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/README12
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/hv.rb306
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image1bin0 -> 8995 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image10bin0 -> 3095 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image11bin0 -> 1425 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image12bin0 -> 2468 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image13bin0 -> 4073 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image14bin0 -> 53 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image2bin0 -> 42 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image3bin0 -> 3473 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image4bin0 -> 1988 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image5bin0 -> 973 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image6bin0 -> 2184 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image7bin0 -> 2022 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image8bin0 -> 1186 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/image9bin0 -> 139 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page1/index.html115
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image1bin0 -> 1966 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image10bin0 -> 255 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image11bin0 -> 590 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image12bin0 -> 254 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image13bin0 -> 493 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image14bin0 -> 195 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image15bin0 -> 68 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image16bin0 -> 157 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image17bin0 -> 81 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image18bin0 -> 545 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image19bin0 -> 53 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image2bin0 -> 49 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image20bin0 -> 533 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image21bin0 -> 564 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image22bin0 -> 81 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image23bin0 -> 539 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image24bin0 -> 151 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image25bin0 -> 453 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image26bin0 -> 520 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image27bin0 -> 565 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image28bin0 -> 416 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image29bin0 -> 121 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image3bin0 -> 10835 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image30bin0 -> 663 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image31bin0 -> 78 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image32bin0 -> 556 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image33bin0 -> 598 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image34bin0 -> 496 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image35bin0 -> 724 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image36bin0 -> 404 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image37bin0 -> 124 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image38bin0 -> 8330 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image39bin0 -> 369 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image4bin0 -> 268 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image5bin0 -> 492 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image6bin0 -> 246 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image7bin0 -> 551 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image8bin0 -> 497 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/image9bin0 -> 492 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page2/index.html433
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image1bin0 -> 113 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image10bin0 -> 5088 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image11bin0 -> 4485 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image12bin0 -> 3579 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image13bin0 -> 5119 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image14bin0 -> 3603 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image2bin0 -> 74 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image3bin0 -> 681 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image4bin0 -> 3056 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image5bin0 -> 2297 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image6bin0 -> 79 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image7bin0 -> 1613 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image8bin0 -> 864 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/image9bin0 -> 2379 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page3/index.html2787
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image1bin0 -> 42 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image2bin0 -> 14343 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image3bin0 -> 17750 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image4bin0 -> 61 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image5bin0 -> 201 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image6bin0 -> 214 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image7bin0 -> 149 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image8bin0 -> 203 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/image9bin0 -> 1504 bytes-rw-r--r--ext/tk/sample/tkextlib/tkHTML/page4/index.html768
-rw-r--r--ext/tk/sample/tkextlib/tkHTML/ss.rb404
-rw-r--r--ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt52
-rw-r--r--ext/tk/sample/tkextlib/tktable/basic.rb60
-rw-r--r--ext/tk/sample/tkextlib/tktable/buttons.rb76
-rw-r--r--ext/tk/sample/tkextlib/tktable/command.rb89
-rw-r--r--ext/tk/sample/tkextlib/tktable/debug.rb101
-rw-r--r--ext/tk/sample/tkextlib/tktable/dynarows.rb99
-rw-r--r--ext/tk/sample/tkextlib/tktable/maxsize.rb67
-rw-r--r--ext/tk/sample/tkextlib/tktable/spreadsheet.rb137
-rwxr-xr-xext/tk/sample/tkextlib/tktable/tcllogo.gifbin0 -> 2341 bytes-rw-r--r--ext/tk/sample/tkextlib/tktable/valid.rb88
-rw-r--r--ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt51
-rw-r--r--ext/tk/sample/tkextlib/vu/README.txt50
-rw-r--r--ext/tk/sample/tkextlib/vu/canvItems.rb90
-rw-r--r--ext/tk/sample/tkextlib/vu/canvSticker.rb82
-rw-r--r--ext/tk/sample/tkextlib/vu/canvSticker2.rb99
-rw-r--r--ext/tk/sample/tkextlib/vu/dial.rb113
-rw-r--r--ext/tk/sample/tkextlib/vu/m128_000.xbm174
-rw-r--r--ext/tk/sample/tkextlib/vu/oscilloscope.rb68
-rw-r--r--ext/tk/sample/tkextlib/vu/pie.rb56
-rw-r--r--ext/tk/sample/tkextlib/vu/vu.rb67
-rw-r--r--ext/tk/sample/tkfrom.rb32
-rw-r--r--ext/tk/sample/tkhello.rb8
-rw-r--r--ext/tk/sample/tkline.rb6
-rw-r--r--ext/tk/sample/tkmenubutton.rb135
-rw-r--r--ext/tk/sample/tkmsgcat-load_rb.rb102
-rw-r--r--ext/tk/sample/tkmsgcat-load_rb2.rb102
-rw-r--r--ext/tk/sample/tkmsgcat-load_tk.rb118
-rw-r--r--ext/tk/sample/tkmulticolumnlist.rb743
-rw-r--r--ext/tk/sample/tkmultilistbox.rb654
-rw-r--r--ext/tk/sample/tkmultilistframe.rb940
-rw-r--r--ext/tk/sample/tkoptdb-safeTk.rb73
-rw-r--r--ext/tk/sample/tkoptdb.rb106
-rw-r--r--ext/tk/sample/tktextframe.rb162
-rw-r--r--ext/tk/sample/tktimer.rb2
-rw-r--r--ext/tk/sample/tktimer2.rb47
-rw-r--r--ext/tk/sample/tktimer3.rb59
-rw-r--r--ext/tk/sample/tktree.rb103
-rw-r--r--ext/tk/sample/tktree.tcl305
-rw-r--r--ext/tk/tkutil.c1329
-rw-r--r--ext/win32ole/.cvsignore3
-rw-r--r--ext/win32ole/depend1
-rw-r--r--ext/win32ole/doc/win32ole.rd294
-rw-r--r--ext/win32ole/extconf.rb27
-rw-r--r--ext/win32ole/lib/win32ole/property.rb16
-rw-r--r--ext/win32ole/sample/excel1.rb22
-rw-r--r--ext/win32ole/sample/excel2.rb30
-rw-r--r--ext/win32ole/sample/excel3.rb13
-rw-r--r--ext/win32ole/sample/ie.rb11
-rw-r--r--ext/win32ole/sample/ieconst.rb32
-rw-r--r--ext/win32ole/sample/ienavi.rb40
-rw-r--r--ext/win32ole/sample/oledirs.rb23
-rw-r--r--ext/win32ole/sample/olegen.rb348
-rw-r--r--ext/win32ole/sample/xml.rb7306
-rw-r--r--ext/win32ole/tests/oleserver.rb10
-rw-r--r--ext/win32ole/tests/testOLEEVENT.rb33
-rw-r--r--ext/win32ole/tests/testOLEMETHOD.rb87
-rw-r--r--ext/win32ole/tests/testOLEPARAM.rb74
-rw-r--r--ext/win32ole/tests/testOLETYPE.rb96
-rw-r--r--ext/win32ole/tests/testOLEVARIABLE.rb49
-rw-r--r--ext/win32ole/tests/testVARIANT.rb32
-rw-r--r--ext/win32ole/tests/testWIN32OLE.rb312
-rw-r--r--ext/win32ole/tests/testall.rb11
-rw-r--r--ext/win32ole/win32ole.c5565
-rw-r--r--ext/zlib/.cvsignore3
-rw-r--r--ext/zlib/doc/zlib.rd911
-rw-r--r--ext/zlib/extconf.rb66
-rw-r--r--ext/zlib/zlib.c3510
-rw-r--r--file.c2672
-rw-r--r--gc.c1201
-rw-r--r--hash.c1595
-rw-r--r--inits.c6
-rw-r--r--instruby.rb261
-rw-r--r--intern.h248
-rw-r--r--io.c3594
-rw-r--r--keywords80
-rw-r--r--lex.c88
-rw-r--r--lib/.document33
-rw-r--r--lib/English.rb133
-rw-r--r--lib/README92
-rw-r--r--lib/abbrev.rb103
-rw-r--r--lib/base64.rb150
-rw-r--r--lib/benchmark.rb569
-rw-r--r--lib/cgi-lib.rb6
-rw-r--r--lib/cgi.rb2127
-rw-r--r--lib/cgi/.document2
-rw-r--r--lib/cgi/session.rb370
-rw-r--r--lib/cgi/session/pstore.rb117
-rw-r--r--lib/complex.rb471
-rw-r--r--lib/csv.rb992
-rw-r--r--lib/date.rb1393
-rw-r--r--lib/date/format.rb563
-rw-r--r--lib/debug.rb1430
-rw-r--r--lib/delegate.rb111
-rw-r--r--lib/drb.rb2
-rw-r--r--lib/drb/acl.rb144
-rw-r--r--lib/drb/drb.rb1622
-rw-r--r--lib/drb/eq.rb16
-rw-r--r--lib/drb/extserv.rb67
-rw-r--r--lib/drb/extservm.rb94
-rw-r--r--lib/drb/gw.rb60
-rw-r--r--lib/drb/invokemethod.rb36
-rw-r--r--lib/drb/observer.rb22
-rw-r--r--lib/drb/ssl.rb185
-rw-r--r--lib/drb/timeridconv.rb91
-rw-r--r--lib/drb/unix.rb107
-rw-r--r--lib/e2mmap.rb5
-rw-r--r--lib/erb.rb473
-rw-r--r--lib/fileutils.rb1007
-rw-r--r--lib/final.rb4
-rw-r--r--lib/finalize.rb253
-rw-r--r--lib/find.rb58
-rw-r--r--lib/forwardable.rb94
-rw-r--r--lib/ftools.rb182
-rw-r--r--lib/ftplib.rb14
-rw-r--r--lib/generator.rb380
-rw-r--r--lib/getoptlong.rb36
-rw-r--r--lib/getopts.rb155
-rw-r--r--lib/gserver.rb249
-rw-r--r--lib/importenv.rb1
-rw-r--r--lib/ipaddr.rb762
-rw-r--r--lib/irb.rb340
-rw-r--r--lib/irb/cmd/chws.rb33
-rw-r--r--lib/irb/cmd/fork.rb25
-rw-r--r--lib/irb/cmd/load.rb67
-rw-r--r--lib/irb/cmd/nop.rb39
-rw-r--r--lib/irb/cmd/pushws.rb39
-rw-r--r--lib/irb/cmd/subirb.rb43
-rw-r--r--lib/irb/completion.rb163
-rw-r--r--lib/irb/context.rb234
-rw-r--r--lib/irb/ext/change-ws.rb62
-rw-r--r--lib/irb/ext/history.rb110
-rw-r--r--lib/irb/ext/loader.rb106
-rw-r--r--lib/irb/ext/math-mode.rb37
-rw-r--r--lib/irb/ext/multi-irb.rb (renamed from lib/irb/multi-irb.rb)91
-rw-r--r--lib/irb/ext/tracer.rb61
-rw-r--r--lib/irb/ext/use-loader.rb65
-rw-r--r--lib/irb/ext/workspaces.rb56
-rw-r--r--lib/irb/extend-command.rb215
-rw-r--r--lib/irb/frame.rb2
-rw-r--r--lib/irb/help.rb33
-rw-r--r--lib/irb/init.rb225
-rw-r--r--lib/irb/input-method.rb18
-rw-r--r--lib/irb/lc/error.rb30
-rw-r--r--lib/irb/lc/help-message35
-rw-r--r--lib/irb/lc/ja/error.rb29
-rw-r--r--lib/irb/lc/ja/help-message36
-rw-r--r--lib/irb/loader.rb118
-rw-r--r--lib/irb/locale.rb186
-rw-r--r--lib/irb/main.rb867
-rw-r--r--lib/irb/ruby-lex.rb285
-rw-r--r--lib/irb/ruby-token.rb17
-rw-r--r--lib/irb/slex.rb41
-rw-r--r--lib/irb/version.rb10
-rw-r--r--lib/irb/workspace-binding-2.rb15
-rw-r--r--lib/irb/workspace-binding.rb77
-rw-r--r--lib/irb/workspace.rb107
-rw-r--r--lib/irb/ws-for-case-2.rb15
-rw-r--r--lib/irb/xmp.rb12
-rw-r--r--lib/jcode.rb54
-rw-r--r--lib/logger.rb728
-rw-r--r--lib/mailread.rb2
-rw-r--r--lib/mathn.rb41
-rw-r--r--lib/matrix.rb996
-rw-r--r--lib/mkmf.rb1326
-rw-r--r--lib/monitor.rb248
-rw-r--r--lib/mutex_m.rb53
-rw-r--r--lib/net/ftp.rb444
-rw-r--r--lib/net/http.rb2176
-rw-r--r--lib/net/imap.rb4545
-rw-r--r--lib/net/pop.rb1078
-rw-r--r--lib/net/protocol.rb973
-rw-r--r--lib/net/smtp.rb803
-rw-r--r--lib/net/telnet.rb720
-rw-r--r--lib/observer.rb154
-rw-r--r--lib/open-uri.rb610
-rw-r--r--lib/open3.rb11
-rw-r--r--lib/optparse.rb1796
-rw-r--r--lib/optparse/date.rb17
-rw-r--r--lib/optparse/shellwords.rb6
-rw-r--r--lib/optparse/time.rb10
-rw-r--r--lib/optparse/uri.rb6
-rw-r--r--lib/optparse/version.rb68
-rw-r--r--lib/ostruct.rb111
-rw-r--r--lib/parsearg.rb2
-rw-r--r--lib/parsedate.rb180
-rw-r--r--lib/pathname.rb1197
-rw-r--r--lib/ping.rb4
-rw-r--r--lib/pp.rb652
-rw-r--r--lib/prettyprint.rb914
-rw-r--r--lib/profile.rb59
-rw-r--r--lib/profiler.rb59
-rw-r--r--lib/pstore.rb127
-rw-r--r--lib/racc/parser.rb456
-rw-r--r--lib/rational.rb102
-rw-r--r--lib/rdoc/README475
-rw-r--r--lib/rdoc/code_objects.rb706
-rw-r--r--lib/rdoc/diagram.rb333
-rw-r--r--lib/rdoc/dot/dot.rb255
-rw-r--r--lib/rdoc/generators/chm_generator.rb112
-rw-r--r--lib/rdoc/generators/html_generator.rb1442
-rw-r--r--lib/rdoc/generators/ri_generator.rb268
-rw-r--r--lib/rdoc/generators/template/chm/chm.rb87
-rw-r--r--lib/rdoc/generators/template/html/hefss.rb418
-rw-r--r--lib/rdoc/generators/template/html/html.rb647
-rw-r--r--lib/rdoc/generators/template/html/kilmer.rb421
-rw-r--r--lib/rdoc/generators/template/html/old_html.rb728
-rw-r--r--lib/rdoc/generators/template/html/one_page_html.rb122
-rw-r--r--lib/rdoc/generators/template/xml/rdf.rb112
-rw-r--r--lib/rdoc/generators/template/xml/xml.rb112
-rw-r--r--lib/rdoc/generators/xml_generator.rb130
-rw-r--r--lib/rdoc/markup/sample/rdoc2latex.rb16
-rw-r--r--lib/rdoc/markup/sample/sample.rb42
-rw-r--r--lib/rdoc/markup/simple_markup.rb477
-rw-r--r--lib/rdoc/markup/simple_markup/fragments.rb328
-rw-r--r--lib/rdoc/markup/simple_markup/inline.rb338
-rw-r--r--lib/rdoc/markup/simple_markup/lines.rb151
-rw-r--r--lib/rdoc/markup/simple_markup/preprocess.rb70
-rw-r--r--lib/rdoc/markup/simple_markup/to_flow.rb188
-rw-r--r--lib/rdoc/markup/simple_markup/to_html.rb289
-rw-r--r--lib/rdoc/markup/simple_markup/to_latex.rb333
-rw-r--r--lib/rdoc/markup/test/AllTests.rb2
-rw-r--r--lib/rdoc/markup/test/TestInline.rb154
-rw-r--r--lib/rdoc/markup/test/TestParse.rb503
-rw-r--r--lib/rdoc/options.rb575
-rw-r--r--lib/rdoc/parsers/parse_c.rb523
-rw-r--r--lib/rdoc/parsers/parse_f95.rb119
-rw-r--r--lib/rdoc/parsers/parse_rb.rb2594
-rw-r--r--lib/rdoc/parsers/parse_simple.rb37
-rw-r--r--lib/rdoc/parsers/parserfactory.rb99
-rw-r--r--lib/rdoc/rdoc.rb282
-rw-r--r--lib/rdoc/ri/ri_cache.rb187
-rw-r--r--lib/rdoc/ri/ri_descriptions.rb152
-rw-r--r--lib/rdoc/ri/ri_display.rb273
-rw-r--r--lib/rdoc/ri/ri_driver.rb145
-rw-r--r--lib/rdoc/ri/ri_formatter.rb651
-rw-r--r--lib/rdoc/ri/ri_options.rb257
-rw-r--r--lib/rdoc/ri/ri_paths.rb51
-rw-r--r--lib/rdoc/ri/ri_reader.rb100
-rw-r--r--lib/rdoc/ri/ri_util.rb75
-rw-r--r--lib/rdoc/ri/ri_writer.rb62
-rw-r--r--lib/rdoc/template.rb234
-rw-r--r--lib/rdoc/tokenstream.rb25
-rw-r--r--lib/rdoc/usage.rb203
-rw-r--r--lib/resolv-replace.rb62
-rw-r--r--lib/resolv.rb1767
-rw-r--r--lib/rexml/attlistdecl.rb62
-rw-r--r--lib/rexml/attribute.rb163
-rw-r--r--lib/rexml/cdata.rb68
-rw-r--r--lib/rexml/child.rb96
-rw-r--r--lib/rexml/comment.rb86
-rw-r--r--lib/rexml/doctype.rb213
-rw-r--r--lib/rexml/document.rb179
-rw-r--r--lib/rexml/dtd/attlistdecl.rb10
-rw-r--r--lib/rexml/dtd/dtd.rb51
-rw-r--r--lib/rexml/dtd/elementdecl.rb17
-rw-r--r--lib/rexml/dtd/entitydecl.rb56
-rw-r--r--lib/rexml/dtd/notationdecl.rb39
-rw-r--r--lib/rexml/element.rb1205
-rw-r--r--lib/rexml/encoding.rb56
-rw-r--r--lib/rexml/encodings/CP-1252.rb98
-rw-r--r--lib/rexml/encodings/EUC-JP.rb37
-rw-r--r--lib/rexml/encodings/ICONV.rb16
-rw-r--r--lib/rexml/encodings/ISO-8859-1.rb25
-rw-r--r--lib/rexml/encodings/ISO-8859-15.rb69
-rw-r--r--lib/rexml/encodings/SHIFT-JIS.rb37
-rw-r--r--lib/rexml/encodings/SHIFT_JIS.rb1
-rw-r--r--lib/rexml/encodings/UNILE.rb29
-rw-r--r--lib/rexml/encodings/US-ASCII.rb25
-rw-r--r--lib/rexml/encodings/UTF-16.rb29
-rw-r--r--lib/rexml/encodings/UTF-8.rb13
-rw-r--r--lib/rexml/entity.rb159
-rw-r--r--lib/rexml/functions.rb372
-rw-r--r--lib/rexml/instruction.rb62
-rw-r--r--lib/rexml/light/node.rb196
-rw-r--r--lib/rexml/namespace.rb47
-rw-r--r--lib/rexml/node.rb40
-rw-r--r--lib/rexml/output.rb24
-rw-r--r--lib/rexml/parent.rb165
-rw-r--r--lib/rexml/parseexception.rb51
-rw-r--r--lib/rexml/parsers/baseparser.rb451
-rw-r--r--lib/rexml/parsers/lightparser.rb60
-rw-r--r--lib/rexml/parsers/pullparser.rb149
-rw-r--r--lib/rexml/parsers/sax2parser.rb213
-rw-r--r--lib/rexml/parsers/streamparser.rb43
-rw-r--r--lib/rexml/parsers/treeparser.rb90
-rw-r--r--lib/rexml/parsers/ultralightparser.rb56
-rw-r--r--lib/rexml/parsers/xpathparser.rb691
-rw-r--r--lib/rexml/quickpath.rb266
-rw-r--r--lib/rexml/rexml.rb26
-rw-r--r--lib/rexml/sax2listener.rb94
-rw-r--r--lib/rexml/source.rb218
-rw-r--r--lib/rexml/streamlistener.rb89
-rw-r--r--lib/rexml/text.rb336
-rw-r--r--lib/rexml/validation/relaxng.rb559
-rw-r--r--lib/rexml/validation/validation.rb152
-rw-r--r--lib/rexml/validation/validationexception.rb9
-rw-r--r--lib/rexml/xmldecl.rb105
-rw-r--r--lib/rexml/xmltokens.rb18
-rw-r--r--lib/rexml/xpath.rb62
-rw-r--r--lib/rexml/xpath_parser.rb558
-rw-r--r--lib/rinda/rinda.rb184
-rw-r--r--lib/rinda/ring.rb164
-rw-r--r--lib/rinda/tuplespace.rb428
-rw-r--r--lib/rss/0.9.rb530
-rw-r--r--lib/rss/1.0.rb653
-rw-r--r--lib/rss/2.0.rb150
-rw-r--r--lib/rss/content.rb52
-rw-r--r--lib/rss/converter.rb155
-rw-r--r--lib/rss/dublincore.rb64
-rw-r--r--lib/rss/maker.rb33
-rw-r--r--lib/rss/maker/0.9.rb160
-rw-r--r--lib/rss/maker/1.0.rb184
-rw-r--r--lib/rss/maker/2.0.rb129
-rw-r--r--lib/rss/maker/base.rb430
-rw-r--r--lib/rss/maker/content.rb29
-rw-r--r--lib/rss/maker/dublincore.rb47
-rw-r--r--lib/rss/maker/syndication.rb27
-rw-r--r--lib/rss/maker/trackback.rb30
-rw-r--r--lib/rss/parser.rb396
-rw-r--r--lib/rss/rexmlparser.rb47
-rw-r--r--lib/rss/rss.rb680
-rw-r--r--lib/rss/syndication.rb85
-rw-r--r--lib/rss/taxonomy.rb32
-rw-r--r--lib/rss/trackback.rb306
-rw-r--r--lib/rss/utils.rb17
-rw-r--r--lib/rss/xml-stylesheet.rb94
-rw-r--r--lib/rss/xmlparser.rb91
-rw-r--r--lib/rss/xmlscanner.rb102
-rw-r--r--lib/rubyunit.rb6
-rw-r--r--lib/runit/assert.rb73
-rw-r--r--lib/runit/cui/testrunner.rb51
-rw-r--r--lib/runit/error.rb9
-rw-r--r--lib/runit/testcase.rb45
-rw-r--r--lib/runit/testresult.rb44
-rw-r--r--lib/runit/testsuite.rb26
-rw-r--r--lib/runit/topublic.rb8
-rw-r--r--lib/scanf.rb702
-rw-r--r--lib/set.rb1208
-rw-r--r--lib/shell.rb269
-rw-r--r--lib/shell/builtin-command.rb154
-rw-r--r--lib/shell/command-processor.rb592
-rw-r--r--lib/shell/error.rb26
-rw-r--r--lib/shell/filter.rb110
-rw-r--r--lib/shell/process-controller.rb258
-rw-r--r--lib/shell/system-command.rb168
-rw-r--r--lib/shell/version.rb16
-rw-r--r--lib/shellwords.rb61
-rw-r--r--lib/singleton.rb377
-rw-r--r--lib/soap/attachment.rb107
-rw-r--r--lib/soap/baseData.rb815
-rw-r--r--lib/soap/element.rb251
-rw-r--r--lib/soap/encodingstyle/aspDotNetHandler.rb220
-rw-r--r--lib/soap/encodingstyle/handler.rb100
-rw-r--r--lib/soap/encodingstyle/literalHandler.rb227
-rw-r--r--lib/soap/encodingstyle/soapHandler.rb589
-rw-r--r--lib/soap/generator.rb210
-rw-r--r--lib/soap/header/handler.rb57
-rw-r--r--lib/soap/header/handlerset.rb58
-rw-r--r--lib/soap/header/simplehandler.rb44
-rw-r--r--lib/soap/mapping.rb10
-rw-r--r--lib/soap/mapping/factory.rb388
-rw-r--r--lib/soap/mapping/mapping.rb218
-rw-r--r--lib/soap/mapping/registry.rb479
-rw-r--r--lib/soap/mapping/rubytypeFactory.rb452
-rw-r--r--lib/soap/mapping/typeMap.rb41
-rw-r--r--lib/soap/mapping/wsdlRegistry.rb155
-rw-r--r--lib/soap/marshal.rb58
-rw-r--r--lib/soap/mimemessage.rb238
-rw-r--r--lib/soap/netHttpClient.rb174
-rw-r--r--lib/soap/parser.rb252
-rw-r--r--lib/soap/processor.rb66
-rw-r--r--lib/soap/property.rb328
-rw-r--r--lib/soap/rpc/cgistub.rb206
-rw-r--r--lib/soap/rpc/driver.rb300
-rw-r--r--lib/soap/rpc/element.rb270
-rw-r--r--lib/soap/rpc/httpserver.rb105
-rw-r--r--lib/soap/rpc/proxy.rb171
-rw-r--r--lib/soap/rpc/router.rb235
-rw-r--r--lib/soap/rpc/rpc.rb25
-rw-r--r--lib/soap/rpc/soaplet.rb200
-rw-r--r--lib/soap/rpc/standaloneServer.rb43
-rw-r--r--lib/soap/soap.rb115
-rw-r--r--lib/soap/streamHandler.rb267
-rw-r--r--lib/soap/wsdlDriver.rb598
-rw-r--r--lib/sync.rb68
-rw-r--r--lib/telnet.rb9
-rw-r--r--lib/tempfile.rb207
-rw-r--r--lib/test/unit.rb283
-rw-r--r--lib/test/unit/assertionfailederror.rb12
-rw-r--r--lib/test/unit/assertions.rb472
-rw-r--r--lib/test/unit/autorunner.rb189
-rw-r--r--lib/test/unit/collector.rb43
-rw-r--r--lib/test/unit/collector/dir.rb86
-rw-r--r--lib/test/unit/collector/objectspace.rb34
-rw-r--r--lib/test/unit/error.rb54
-rw-r--r--lib/test/unit/failure.rb49
-rw-r--r--lib/test/unit/testcase.rb150
-rw-r--r--lib/test/unit/testresult.rb79
-rw-r--r--lib/test/unit/testsuite.rb74
-rw-r--r--lib/test/unit/ui/console/testrunner.rb125
-rw-r--r--lib/test/unit/ui/fox/testrunner.rb266
-rw-r--r--lib/test/unit/ui/gtk/testrunner.rb414
-rw-r--r--lib/test/unit/ui/gtk2/testrunner.rb463
-rw-r--r--lib/test/unit/ui/testrunnermediator.rb66
-rw-r--r--lib/test/unit/ui/testrunnerutilities.rb44
-rw-r--r--lib/test/unit/ui/tk/testrunner.rb258
-rw-r--r--lib/test/unit/util/backtracefilter.rb40
-rw-r--r--lib/test/unit/util/observable.rb88
-rw-r--r--lib/test/unit/util/procwrapper.rb46
-rw-r--r--lib/thread.rb226
-rw-r--r--lib/thwait.rb81
-rw-r--r--lib/time.rb617
-rw-r--r--lib/timeout.rb62
-rw-r--r--lib/tmpdir.rb42
-rw-r--r--lib/tracer.rb29
-rw-r--r--lib/tsort.rb289
-rw-r--r--lib/un.rb227
-rw-r--r--lib/uri.rb28
-rw-r--r--lib/uri/common.rb607
-rw-r--r--lib/uri/ftp.rb148
-rw-r--r--lib/uri/generic.rb1125
-rw-r--r--lib/uri/http.rb65
-rw-r--r--lib/uri/https.rb16
-rw-r--r--lib/uri/ldap.rb190
-rw-r--r--lib/uri/mailto.rb239
-rw-r--r--lib/weakref.rb38
-rw-r--r--lib/webrick.rb29
-rw-r--r--lib/webrick/accesslog.rb64
-rw-r--r--lib/webrick/cgi.rb249
-rw-r--r--lib/webrick/compat.rb15
-rw-r--r--lib/webrick/config.rb98
-rw-r--r--lib/webrick/cookie.rb80
-rw-r--r--lib/webrick/htmlutils.rb25
-rw-r--r--lib/webrick/httpauth.rb46
-rw-r--r--lib/webrick/httpauth/authenticator.rb79
-rw-r--r--lib/webrick/httpauth/basicauth.rb66
-rw-r--r--lib/webrick/httpauth/digestauth.rb348
-rw-r--r--lib/webrick/httpauth/htdigest.rb91
-rw-r--r--lib/webrick/httpauth/htgroup.rb61
-rw-r--r--lib/webrick/httpauth/htpasswd.rb75
-rw-r--r--lib/webrick/httpauth/userdb.rb29
-rw-r--r--lib/webrick/httpproxy.rb240
-rw-r--r--lib/webrick/httprequest.rb359
-rw-r--r--lib/webrick/httpresponse.rb327
-rw-r--r--lib/webrick/https.rb63
-rw-r--r--lib/webrick/httpserver.rb203
-rw-r--r--lib/webrick/httpservlet.rb22
-rw-r--r--lib/webrick/httpservlet/abstract.rb71
-rw-r--r--lib/webrick/httpservlet/cgi_runner.rb45
-rw-r--r--lib/webrick/httpservlet/cgihandler.rb98
-rw-r--r--lib/webrick/httpservlet/erbhandler.rb54
-rw-r--r--lib/webrick/httpservlet/filehandler.rb387
-rw-r--r--lib/webrick/httpservlet/prochandler.rb33
-rw-r--r--lib/webrick/httpstatus.rb126
-rw-r--r--lib/webrick/httputils.rb391
-rw-r--r--lib/webrick/httpversion.rb49
-rw-r--r--lib/webrick/log.rb88
-rw-r--r--lib/webrick/server.rb180
-rw-r--r--lib/webrick/ssl.rb126
-rw-r--r--lib/webrick/utils.rb88
-rw-r--r--lib/webrick/version.rb13
-rw-r--r--lib/wsdl/binding.rb65
-rw-r--r--lib/wsdl/data.rb64
-rw-r--r--lib/wsdl/definitions.rb240
-rw-r--r--lib/wsdl/documentation.rb32
-rw-r--r--lib/wsdl/import.rb70
-rw-r--r--lib/wsdl/importer.rb73
-rw-r--r--lib/wsdl/info.rb33
-rw-r--r--lib/wsdl/message.rb54
-rw-r--r--lib/wsdl/operation.rb129
-rw-r--r--lib/wsdl/operationBinding.rb80
-rw-r--r--lib/wsdl/param.rb74
-rw-r--r--lib/wsdl/parser.rb160
-rw-r--r--lib/wsdl/part.rb52
-rw-r--r--lib/wsdl/port.rb84
-rw-r--r--lib/wsdl/portType.rb72
-rw-r--r--lib/wsdl/service.rb61
-rw-r--r--lib/wsdl/soap/address.rb40
-rw-r--r--lib/wsdl/soap/binding.rb48
-rw-r--r--lib/wsdl/soap/body.rb52
-rw-r--r--lib/wsdl/soap/cgiStubCreator.rb73
-rw-r--r--lib/wsdl/soap/classDefCreator.rb112
-rw-r--r--lib/wsdl/soap/classDefCreatorSupport.rb106
-rw-r--r--lib/wsdl/soap/clientSkeltonCreator.rb78
-rw-r--r--lib/wsdl/soap/complexType.rb107
-rw-r--r--lib/wsdl/soap/data.rb41
-rw-r--r--lib/wsdl/soap/definitions.rb152
-rw-r--r--lib/wsdl/soap/driverCreator.rb84
-rw-r--r--lib/wsdl/soap/fault.rb52
-rw-r--r--lib/wsdl/soap/header.rb79
-rw-r--r--lib/wsdl/soap/headerfault.rb56
-rw-r--r--lib/wsdl/soap/mappingRegistryCreator.rb90
-rw-r--r--lib/wsdl/soap/methodDefCreator.rb148
-rw-r--r--lib/wsdl/soap/operation.rb123
-rw-r--r--lib/wsdl/soap/servantSkeltonCreator.rb65
-rw-r--r--lib/wsdl/soap/standaloneServerStubCreator.rb79
-rw-r--r--lib/wsdl/types.rb43
-rw-r--r--lib/wsdl/wsdl.rb23
-rw-r--r--lib/wsdl/xmlSchema/all.rb65
-rw-r--r--lib/wsdl/xmlSchema/any.rb56
-rw-r--r--lib/wsdl/xmlSchema/attribute.rb74
-rw-r--r--lib/wsdl/xmlSchema/choice.rb65
-rw-r--r--lib/wsdl/xmlSchema/complexContent.rb83
-rw-r--r--lib/wsdl/xmlSchema/complexType.rb133
-rw-r--r--lib/wsdl/xmlSchema/content.rb96
-rw-r--r--lib/wsdl/xmlSchema/data.rb68
-rw-r--r--lib/wsdl/xmlSchema/element.rb104
-rw-r--r--lib/wsdl/xmlSchema/enumeration.rb36
-rw-r--r--lib/wsdl/xmlSchema/import.rb44
-rw-r--r--lib/wsdl/xmlSchema/parser.rb162
-rw-r--r--lib/wsdl/xmlSchema/schema.rb106
-rw-r--r--lib/wsdl/xmlSchema/sequence.rb65
-rw-r--r--lib/wsdl/xmlSchema/simpleRestriction.rb48
-rw-r--r--lib/wsdl/xmlSchema/simpleType.rb81
-rw-r--r--lib/wsdl/xmlSchema/unique.rb34
-rw-r--r--lib/xmlrpc/README.txt31
-rw-r--r--lib/xmlrpc/base64.rb81
-rw-r--r--lib/xmlrpc/client.rb605
-rw-r--r--lib/xmlrpc/config.rb40
-rw-r--r--lib/xmlrpc/create.rb280
-rw-r--r--lib/xmlrpc/datetime.rb138
-rw-r--r--lib/xmlrpc/httpserver.rb178
-rw-r--r--lib/xmlrpc/marshal.rb76
-rw-r--r--lib/xmlrpc/parser.rb808
-rw-r--r--lib/xmlrpc/server.rb833
-rw-r--r--lib/xmlrpc/utils.rb172
-rw-r--r--lib/xsd/charset.rb167
-rw-r--r--lib/xsd/codegen.rb12
-rw-r--r--lib/xsd/codegen/classdef.rb203
-rw-r--r--lib/xsd/codegen/commentdef.rb34
-rw-r--r--lib/xsd/codegen/gensupport.rb112
-rw-r--r--lib/xsd/codegen/methoddef.rb63
-rw-r--r--lib/xsd/codegen/moduledef.rb191
-rw-r--r--lib/xsd/datatypes.rb1116
-rw-r--r--lib/xsd/datatypes1999.rb20
-rw-r--r--lib/xsd/iconvcharset.rb33
-rw-r--r--lib/xsd/namedelements.rb79
-rw-r--r--lib/xsd/ns.rb130
-rw-r--r--lib/xsd/qname.rb71
-rw-r--r--lib/xsd/xmlparser.rb61
-rw-r--r--lib/xsd/xmlparser/parser.rb96
-rw-r--r--lib/xsd/xmlparser/rexmlparser.rb54
-rw-r--r--lib/xsd/xmlparser/xmlparser.rb50
-rw-r--r--lib/xsd/xmlparser/xmlscanner.rb147
-rw-r--r--lib/yaml.rb413
-rw-r--r--lib/yaml/baseemitter.rb247
-rw-r--r--lib/yaml/basenode.rb216
-rw-r--r--lib/yaml/constants.rb45
-rw-r--r--lib/yaml/dbm.rb111
-rw-r--r--lib/yaml/emitter.rb107
-rw-r--r--lib/yaml/encoding.rb33
-rw-r--r--lib/yaml/error.rb33
-rw-r--r--lib/yaml/loader.rb14
-rw-r--r--lib/yaml/rubytypes.rb625
-rw-r--r--lib/yaml/store.rb29
-rw-r--r--lib/yaml/stream.rb44
-rw-r--r--lib/yaml/stringio.rb83
-rw-r--r--lib/yaml/syck.rb27
-rw-r--r--lib/yaml/types.rb196
-rw-r--r--lib/yaml/yamlnode.rb54
-rw-r--r--lib/yaml/ypath.rb52
-rw-r--r--main.c10
-rw-r--r--marshal.c987
-rw-r--r--math.c402
-rwxr-xr-xmdoc2man.rb465
-rw-r--r--misc/inf-ruby.el98
-rw-r--r--misc/ruby-mode.el1194
-rw-r--r--missing.h139
-rw-r--r--missing/acosh.c88
-rw-r--r--missing/alloca.c9
-rw-r--r--missing/dir.h66
-rw-r--r--missing/erf.c91
-rw-r--r--missing/fileblocks.c1
-rw-r--r--missing/finite.c2
-rw-r--r--missing/flock.c2
-rw-r--r--missing/hypot.c17
-rw-r--r--missing/isinf.c30
-rw-r--r--missing/isnan.c24
-rw-r--r--missing/memcmp.c5
-rw-r--r--missing/memmove.c38
-rw-r--r--missing/os2.c2
-rw-r--r--missing/strcasecmp.c6
-rw-r--r--missing/strchr.c57
-rw-r--r--missing/strerror.c8
-rw-r--r--missing/strftime.c47
-rw-r--r--missing/strncasecmp.c5
-rw-r--r--missing/strstr.c83
-rw-r--r--missing/strtol.c89
-rw-r--r--missing/vsnprintf.c9
-rw-r--r--missing/x68.c4
-rw-r--r--mkconfig.rb107
-rw-r--r--node.h222
-rw-r--r--numeric.c1849
-rw-r--r--object.c2095
-rw-r--r--pack.c1027
-rw-r--r--parse.y3816
-rw-r--r--prec.c70
-rw-r--r--process.c2935
-rw-r--r--random.c284
-rw-r--r--range.c603
-rw-r--r--re.c1385
-rw-r--r--re.h12
-rw-r--r--regex.c883
-rw-r--r--regex.h21
-rw-r--r--ruby.1569
-rw-r--r--ruby.c306
-rw-r--r--ruby.h414
-rw-r--r--rubyio.h22
-rw-r--r--rubysig.h75
-rw-r--r--rubytest.rb6
-rw-r--r--sample/README5
-rw-r--r--sample/biorhythm.rb29
-rw-r--r--sample/cal.rb231
-rw-r--r--sample/clnt.rb12
-rw-r--r--sample/dir.rb6
-rw-r--r--sample/drb/README.rd56
-rw-r--r--sample/drb/README.rd.ja59
-rw-r--r--sample/drb/darray.rb12
-rw-r--r--sample/drb/darrayc.rb59
-rw-r--r--sample/drb/dbiff.rb51
-rw-r--r--sample/drb/dcdbiff.rb43
-rw-r--r--sample/drb/dchatc.rb41
-rw-r--r--sample/drb/dchats.rb70
-rw-r--r--sample/drb/dhasen.rb42
-rw-r--r--sample/drb/dhasenc.rb13
-rw-r--r--sample/drb/dlogc.rb16
-rw-r--r--sample/drb/dlogd.rb39
-rw-r--r--sample/drb/dqin.rb13
-rw-r--r--sample/drb/dqlib.rb14
-rw-r--r--sample/drb/dqout.rb14
-rw-r--r--sample/drb/dqueue.rb12
-rw-r--r--sample/drb/drbc.rb45
-rw-r--r--sample/drb/drbch.rb48
-rw-r--r--sample/drb/drbm.rb60
-rw-r--r--sample/drb/drbmc.rb22
-rw-r--r--sample/drb/drbs-acl.rb51
-rw-r--r--sample/drb/drbs.rb64
-rw-r--r--sample/drb/drbssl_c.rb19
-rw-r--r--sample/drb/drbssl_s.rb31
-rw-r--r--sample/drb/extserv_test.rb80
-rw-r--r--sample/drb/gw_ct.rb29
-rw-r--r--sample/drb/gw_cu.rb28
-rw-r--r--sample/drb/gw_s.rb10
-rw-r--r--sample/drb/holderc.rb22
-rw-r--r--sample/drb/holders.rb63
-rw-r--r--sample/drb/http0.rb77
-rw-r--r--sample/drb/http0serv.rb119
-rw-r--r--sample/drb/name.rb117
-rw-r--r--sample/drb/namec.rb36
-rw-r--r--sample/drb/old_tuplespace.rb214
-rw-r--r--sample/drb/rinda_ts.rb7
-rw-r--r--sample/drb/rindac.rb17
-rw-r--r--sample/drb/rindas.rb18
-rw-r--r--sample/drb/ring_echo.rb30
-rw-r--r--sample/drb/ring_inspect.rb30
-rw-r--r--sample/drb/ring_place.rb25
-rw-r--r--sample/drb/simpletuple.rb91
-rw-r--r--sample/drb/speedc.rb21
-rw-r--r--sample/drb/speeds.rb31
-rw-r--r--sample/dualstack-fetch.rb48
-rw-r--r--sample/dualstack-httpd.rb55
-rw-r--r--sample/eval.rb15
-rw-r--r--sample/exyacc.rb8
-rw-r--r--sample/fact.rb5
-rw-r--r--sample/fullpath.rb14
-rw-r--r--sample/goodfriday.rb8
-rw-r--r--sample/io.rb44
-rw-r--r--sample/logger/app.rb46
-rw-r--r--sample/logger/log.rb27
-rw-r--r--sample/logger/shifting.rb26
-rw-r--r--sample/mkproto.rb8
-rw-r--r--sample/occur.rb2
-rw-r--r--sample/occur2.rb4
-rw-r--r--sample/openssl/c_rehash.rb174
-rw-r--r--sample/openssl/cert2text.rb23
-rw-r--r--sample/openssl/cert_store_view.rb911
-rw-r--r--sample/openssl/certstore.rb161
-rw-r--r--sample/openssl/cipher.rb29
-rw-r--r--sample/openssl/crlstore.rb122
-rw-r--r--sample/openssl/echo_cli.rb37
-rw-r--r--sample/openssl/echo_svr.rb62
-rw-r--r--sample/openssl/gen_csr.rb50
-rw-r--r--sample/openssl/smime_read.rb23
-rw-r--r--sample/openssl/smime_write.rb23
-rw-r--r--sample/openssl/wget.rb33
-rw-r--r--sample/optparse/opttest.rb85
-rw-r--r--sample/pi.rb2
-rw-r--r--sample/rbc.rb1015
-rw-r--r--sample/rcs.rb20
-rw-r--r--sample/rename.rb297
-rw-r--r--sample/rss/list_description.rb84
-rw-r--r--sample/rss/rss_recent.rb83
-rw-r--r--sample/rss/tdiary_plugin/rss-recent.rb213
-rw-r--r--sample/sieve.rb2
-rw-r--r--sample/soap/authheader/authmgr.rb41
-rw-r--r--sample/soap/authheader/client.rb40
-rw-r--r--sample/soap/authheader/client2.rb39
-rw-r--r--sample/soap/authheader/server.rb72
-rw-r--r--sample/soap/authheader/server2.rb77
-rw-r--r--sample/soap/babelfish.rb16
-rw-r--r--sample/soap/calc/calc.rb17
-rw-r--r--sample/soap/calc/calc2.rb29
-rw-r--r--sample/soap/calc/client.rb26
-rw-r--r--sample/soap/calc/client2.rb29
-rw-r--r--sample/soap/calc/httpd.rb20
-rw-r--r--sample/soap/calc/samplehttpd.conf2
-rw-r--r--sample/soap/calc/server.cgi15
-rw-r--r--sample/soap/calc/server.rb17
-rw-r--r--sample/soap/calc/server2.rb20
-rw-r--r--sample/soap/digraph.rb43
-rw-r--r--sample/soap/exchange/client.rb19
-rw-r--r--sample/soap/exchange/exchange.rb17
-rw-r--r--sample/soap/exchange/httpd.rb20
-rw-r--r--sample/soap/exchange/samplehttpd.conf2
-rw-r--r--sample/soap/exchange/server.cgi14
-rw-r--r--sample/soap/exchange/server.rb16
-rw-r--r--sample/soap/helloworld/hw_c.rb6
-rw-r--r--sample/soap/helloworld/hw_s.rb17
-rw-r--r--sample/soap/icd/IICD.rb17
-rw-r--r--sample/soap/icd/icd.rb46
-rw-r--r--sample/soap/raa/iRAA.rb154
-rw-r--r--sample/soap/raa/soap4r.rb30
-rw-r--r--sample/soap/raa2.4/raa.rb332
-rw-r--r--sample/soap/raa2.4/raaDriver.rb255
-rw-r--r--sample/soap/raa2.4/raaServiceClient.rb354
-rw-r--r--sample/soap/raa2.4/sample.rb115
-rw-r--r--sample/soap/sampleStruct/client.rb16
-rw-r--r--sample/soap/sampleStruct/httpd.rb20
-rw-r--r--sample/soap/sampleStruct/iSampleStruct.rb22
-rw-r--r--sample/soap/sampleStruct/sampleStruct.rb13
-rw-r--r--sample/soap/sampleStruct/samplehttpd.conf2
-rw-r--r--sample/soap/sampleStruct/server.cgi14
-rw-r--r--sample/soap/sampleStruct/server.rb20
-rw-r--r--sample/soap/ssl/files/README1
-rw-r--r--sample/soap/ssl/files/ca.cert23
-rw-r--r--sample/soap/ssl/files/client.cert19
-rw-r--r--sample/soap/ssl/files/client.key15
-rw-r--r--sample/soap/ssl/files/server.cert19
-rw-r--r--sample/soap/ssl/files/server.key15
-rw-r--r--sample/soap/ssl/files/sslclient.properties5
-rw-r--r--sample/soap/ssl/files/sslclient_require_noserverauth.properties2
-rw-r--r--sample/soap/ssl/files/sslclient_with_clientauth.properties9
-rw-r--r--sample/soap/ssl/files/subca.cert21
-rw-r--r--sample/soap/ssl/sslclient.rb12
-rw-r--r--sample/soap/ssl/sslclient_require_noserverauth.rb12
-rw-r--r--sample/soap/ssl/sslclient_with_clientauth.rb12
-rw-r--r--sample/soap/ssl/sslserver.rb49
-rw-r--r--sample/soap/ssl/sslserver_noauth.rb45
-rw-r--r--sample/soap/ssl/sslserver_require_clientauth.rb50
-rw-r--r--sample/soap/swa/client.rb13
-rw-r--r--sample/soap/swa/server.rb23
-rw-r--r--sample/soap/whois.rb14
-rw-r--r--sample/svr.rb4
-rw-r--r--sample/test.rb1034
-rw-r--r--sample/testunit/adder.rb13
-rw-r--r--sample/testunit/subtracter.rb12
-rw-r--r--sample/testunit/tc_adder.rb18
-rw-r--r--sample/testunit/tc_subtracter.rb18
-rw-r--r--sample/testunit/ts_examples.rb7
-rw-r--r--sample/time.rb2
-rw-r--r--sample/trojan.rb2
-rw-r--r--sample/tsvr.rb6
-rw-r--r--sample/uumerge.rb12
-rw-r--r--sample/webrick/demo-app.rb66
-rw-r--r--sample/webrick/demo-multipart.cgi12
-rw-r--r--sample/webrick/demo-servlet.rb6
-rw-r--r--sample/webrick/demo-urlencoded.cgi12
-rw-r--r--sample/webrick/hello.cgi11
-rw-r--r--sample/webrick/hello.rb8
-rw-r--r--sample/webrick/httpd.rb23
-rw-r--r--sample/webrick/httpsd.rb33
-rw-r--r--sample/wsdl/amazon/AmazonSearch.rb3057
-rw-r--r--sample/wsdl/amazon/AmazonSearchDriver.rb536
-rw-r--r--sample/wsdl/amazon/sampleClient.rb37
-rw-r--r--sample/wsdl/amazon/wsdlDriver.rb52
-rw-r--r--sample/wsdl/googleSearch/GoogleSearch.rb258
-rw-r--r--sample/wsdl/googleSearch/GoogleSearchDriver.rb101
-rw-r--r--sample/wsdl/googleSearch/README6
-rw-r--r--sample/wsdl/googleSearch/httpd.rb20
-rw-r--r--sample/wsdl/googleSearch/sampleClient.rb56
-rw-r--r--sample/wsdl/googleSearch/samplehttpd.conf2
-rw-r--r--sample/wsdl/googleSearch/sjissearch.sh3
-rw-r--r--sample/wsdl/googleSearch/wsdlDriver.rb23
-rw-r--r--sample/wsdl/raa/raa.wsdl264
-rw-r--r--sample/wsdl/raa/soap4r.rb31
-rw-r--r--sample/wsdl/raa2.4/raa.rb332
-rw-r--r--sample/wsdl/raa2.4/wsdlDriver.rb117
-rw-r--r--signal.c465
-rw-r--r--sprintf.c539
-rw-r--r--st.c175
-rw-r--r--st.h36
-rw-r--r--string.c3089
-rw-r--r--struct.c603
-rw-r--r--test/csv/test_csv.rb1753
-rw-r--r--test/dbm/test_dbm.rb54
-rw-r--r--test/digest/test_digest.rb97
-rw-r--r--test/drb/drbtest.rb303
-rw-r--r--test/drb/test_acl.rb195
-rw-r--r--test/drb/test_drb.rb286
-rw-r--r--test/drb/test_drbssl.rb74
-rw-r--r--test/drb/test_drbunix.rb57
-rw-r--r--test/drb/ut_array.rb15
-rw-r--r--test/drb/ut_array_drbssl.rb24
-rw-r--r--test/drb/ut_array_drbunix.rb15
-rw-r--r--test/drb/ut_drb.rb143
-rw-r--r--test/drb/ut_drb_drbssl.rb25
-rw-r--r--test/drb/ut_drb_drbunix.rb16
-rw-r--r--test/drb/ut_eval.rb23
-rw-r--r--test/drb/ut_large.rb38
-rw-r--r--test/drb/ut_port.rb14
-rw-r--r--test/drb/ut_safe1.rb16
-rw-r--r--test/drb/ut_timerholder.rb49
-rw-r--r--test/erb/test_erb.rb40
-rw-r--r--test/fileutils/fileasserts.rb51
-rw-r--r--test/fileutils/test_fileutils.rb642
-rw-r--r--test/fileutils/test_nowrite.rb89
-rw-r--r--test/gdbm/test_gdbm.rb52
-rw-r--r--test/logger/test_logger.rb276
-rw-r--r--test/monitor/test_monitor.rb161
-rw-r--r--test/openssl/ssl_server.rb71
-rw-r--r--test/openssl/test_cipher.rb62
-rw-r--r--test/openssl/test_digest.rb65
-rw-r--r--test/openssl/test_hmac.rb34
-rw-r--r--test/openssl/test_ssl.rb195
-rw-r--r--test/openssl/test_x509cert.rb175
-rw-r--r--test/openssl/test_x509crl.rb218
-rw-r--r--test/openssl/test_x509name.rb180
-rw-r--r--test/openssl/test_x509req.rb140
-rw-r--r--test/openssl/test_x509store.rb143
-rw-r--r--test/openssl/utils.rb135
-rw-r--r--test/optparse/test_noarg.rb57
-rw-r--r--test/optparse/test_optarg.rb44
-rw-r--r--test/optparse/test_optparse.rb46
-rw-r--r--test/optparse/test_placearg.rb45
-rw-r--r--test/optparse/test_reqarg.rb63
-rw-r--r--test/ostruct/test_ostruct.rb23
-rw-r--r--test/rinda/test_rinda.rb403
-rw-r--r--test/rss/rss-assertions.rb162
-rw-r--r--test/rss/rss-testcase.rb240
-rw-r--r--test/rss/test_1.0.rb268
-rw-r--r--test/rss/test_accessor.rb24
-rw-r--r--test/rss/test_content.rb95
-rw-r--r--test/rss/test_dublincore.rb124
-rw-r--r--test/rss/test_maker_0.9.rb397
-rw-r--r--test/rss/test_maker_1.0.rb363
-rw-r--r--test/rss/test_maker_2.0.rb622
-rw-r--r--test/rss/test_maker_content.rb34
-rw-r--r--test/rss/test_maker_dc.rb71
-rw-r--r--test/rss/test_maker_sy.rb43
-rw-r--r--test/rss/test_maker_trackback.rb35
-rw-r--r--test/rss/test_maker_xml-stylesheet.rb75
-rw-r--r--test/rss/test_parser.rb611
-rw-r--r--test/rss/test_syndication.rb123
-rw-r--r--test/rss/test_trackback.rb135
-rw-r--r--test/rss/test_xml-stylesheet.rb108
-rw-r--r--test/ruby/beginmainend.rb85
-rw-r--r--test/ruby/endblockwarn.rb12
-rw-r--r--test/ruby/envutil.rb21
-rw-r--r--test/ruby/marshaltestlib.rb494
-rw-r--r--test/ruby/test_alias.rb40
-rw-r--r--test/ruby/test_array.rb101
-rw-r--r--test/ruby/test_assignment.rb467
-rw-r--r--test/ruby/test_beginendblock.rb57
-rw-r--r--test/ruby/test_bignum.rb87
-rw-r--r--test/ruby/test_call.rb19
-rw-r--r--test/ruby/test_case.rb49
-rw-r--r--test/ruby/test_clone.rb28
-rw-r--r--test/ruby/test_condition.rb16
-rw-r--r--test/ruby/test_const.rb33
-rw-r--r--test/ruby/test_defined.rb43
-rw-r--r--test/ruby/test_env.rb84
-rw-r--r--test/ruby/test_eval.rb157
-rw-r--r--test/ruby/test_exception.rb187
-rw-r--r--test/ruby/test_file.rb70
-rw-r--r--test/ruby/test_float.rb89
-rw-r--r--test/ruby/test_gc.rb30
-rw-r--r--test/ruby/test_hash.rb74
-rw-r--r--test/ruby/test_ifunless.rb14
-rw-r--r--test/ruby/test_io.rb11
-rw-r--r--test/ruby/test_iterator.rb451
-rw-r--r--test/ruby/test_marshal.rb48
-rw-r--r--test/ruby/test_math.rb12
-rw-r--r--test/ruby/test_pack.rb19
-rw-r--r--test/ruby/test_path.rb46
-rw-r--r--test/ruby/test_pipe.rb18
-rw-r--r--test/ruby/test_proc.rb89
-rw-r--r--test/ruby/test_range.rb11
-rw-r--r--test/ruby/test_signal.rb25
-rw-r--r--test/ruby/test_string.rb19
-rw-r--r--test/ruby/test_stringchar.rb116
-rw-r--r--test/ruby/test_struct.rb24
-rw-r--r--test/ruby/test_system.rb64
-rw-r--r--test/ruby/test_time.rb74
-rw-r--r--test/ruby/test_trace.rb21
-rw-r--r--test/ruby/test_variable.rb53
-rw-r--r--test/ruby/test_whileuntil.rb77
-rw-r--r--test/ruby/ut_eof.rb115
-rw-r--r--test/runner.rb7
-rw-r--r--test/soap/calc/calc.rb17
-rw-r--r--test/soap/calc/calc2.rb29
-rw-r--r--test/soap/calc/server.cgi13
-rw-r--r--test/soap/calc/server.rb17
-rw-r--r--test/soap/calc/server2.rb20
-rw-r--r--test/soap/calc/test_calc.rb56
-rw-r--r--test/soap/calc/test_calc2.rb60
-rw-r--r--test/soap/calc/test_calc_cgi.rb76
-rw-r--r--test/soap/header/server.cgi119
-rw-r--r--test/soap/header/test_authheader.rb247
-rw-r--r--test/soap/header/test_authheader_cgi.rb128
-rw-r--r--test/soap/helloworld/hw_s.rb16
-rw-r--r--test/soap/helloworld/test_helloworld.rb47
-rw-r--r--test/soap/marshal/test_digraph.rb56
-rw-r--r--test/soap/marshal/test_marshal.rb26
-rw-r--r--test/soap/marshal/test_struct.rb47
-rw-r--r--test/soap/ssl/README1
-rw-r--r--test/soap/ssl/ca.cert23
-rw-r--r--test/soap/ssl/client.cert19
-rw-r--r--test/soap/ssl/client.key15
-rw-r--r--test/soap/ssl/server.cert19
-rw-r--r--test/soap/ssl/server.key15
-rw-r--r--test/soap/ssl/sslsvr.rb56
-rw-r--r--test/soap/ssl/subca.cert21
-rw-r--r--test/soap/ssl/test_ssl.rb212
-rw-r--r--test/soap/struct/test_struct.rb83
-rw-r--r--test/soap/swa/test_file.rb77
-rw-r--r--test/soap/test_basetype.rb964
-rw-r--r--test/soap/test_property.rb422
-rw-r--r--test/soap/test_soapelement.rb121
-rw-r--r--test/soap/test_streamhandler.rb197
-rw-r--r--test/soap/wsdlDriver/README.txt2
-rw-r--r--test/soap/wsdlDriver/echo_version.rb20
-rw-r--r--test/soap/wsdlDriver/simpletype.wsdl63
-rw-r--r--test/soap/wsdlDriver/test_simpletype.rb92
-rw-r--r--test/stringio/test_stringio.rb33
-rw-r--r--test/strscan/test_stringscanner.rb487
-rw-r--r--test/testunit/collector/test_dir.rb389
-rw-r--r--test/testunit/collector/test_objectspace.rb98
-rw-r--r--test/testunit/runit/test_assert.rb402
-rw-r--r--test/testunit/runit/test_testcase.rb91
-rw-r--r--test/testunit/runit/test_testresult.rb144
-rw-r--r--test/testunit/runit/test_testsuite.rb49
-rw-r--r--test/testunit/test_assertions.rb528
-rw-r--r--test/testunit/test_error.rb26
-rw-r--r--test/testunit/test_failure.rb33
-rw-r--r--test/testunit/test_testcase.rb275
-rw-r--r--test/testunit/test_testresult.rb104
-rw-r--r--test/testunit/test_testsuite.rb129
-rw-r--r--test/testunit/util/test_backtracefilter.rb41
-rw-r--r--test/testunit/util/test_observable.rb102
-rw-r--r--test/testunit/util/test_procwrapper.rb36
-rw-r--r--test/uri/test_common.rb56
-rw-r--r--test/uri/test_ftp.rb42
-rw-r--r--test/uri/test_generic.rb683
-rw-r--r--test/uri/test_http.rb63
-rw-r--r--test/uri/test_ldap.rb100
-rw-r--r--test/uri/test_mailto.rb122
-rw-r--r--test/wsdl/axisArray/axisArray.wsdl60
-rw-r--r--test/wsdl/axisArray/itemList.rb27
-rw-r--r--test/wsdl/axisArray/test_axisarray.rb69
-rw-r--r--test/wsdl/datetime/DatetimeService.rb38
-rw-r--r--test/wsdl/datetime/datetime.rb0
-rw-r--r--test/wsdl/datetime/datetime.wsdl45
-rw-r--r--test/wsdl/datetime/datetimeServant.rb21
-rw-r--r--test/wsdl/datetime/test_datetime.rb88
-rw-r--r--test/wsdl/emptycomplextype.wsdl31
-rw-r--r--test/wsdl/map/map.wsdl66
-rw-r--r--test/wsdl/map/map.xml43
-rw-r--r--test/wsdl/map/test_map.rb37
-rw-r--r--test/wsdl/multiplefault.wsdl68
-rw-r--r--test/wsdl/raa/RAA.rb243
-rw-r--r--test/wsdl/raa/RAAServant.rb99
-rw-r--r--test/wsdl/raa/RAAService.rb101
-rw-r--r--test/wsdl/raa/README.txt8
-rw-r--r--test/wsdl/raa/raa.wsdl264
-rw-r--r--test/wsdl/raa/test_raa.rb78
-rw-r--r--test/wsdl/simpletype/simpletype.wsdl67
-rw-r--r--test/wsdl/simpletype/test_simpletype.rb81
-rw-r--r--test/wsdl/soap/soapbodyparts.wsdl103
-rw-r--r--test/wsdl/soap/test_soapbodyparts.rb86
-rw-r--r--test/wsdl/test_emptycomplextype.rb21
-rw-r--r--test/wsdl/test_fault.rb51
-rw-r--r--test/wsdl/test_multiplefault.rb39
-rw-r--r--test/xsd/noencoding.xml4
-rw-r--r--test/xsd/test_noencoding.rb32
-rw-r--r--test/xsd/test_xmlschemaparser.rb22
-rw-r--r--test/xsd/test_xsd.rb1011
-rw-r--r--test/xsd/xmlschema.xml12
-rw-r--r--test/yaml/test_yaml.rb1246
-rw-r--r--test/zlib/test_zlib.rb57
-rw-r--r--time.c1607
-rw-r--r--util.c739
-rw-r--r--util.h29
-rw-r--r--variable.c1264
-rw-r--r--version.c14
-rw-r--r--version.h19
-rw-r--r--vms/config.h_in61
-rw-r--r--vms/vms.h6
-rw-r--r--win32/Makefile.sub680
-rw-r--r--win32/README.win3215
-rw-r--r--win32/config.h.in59
-rw-r--r--win32/config.status.in66
-rwxr-xr-xwin32/configure.bat21
-rw-r--r--win32/dir.h35
-rw-r--r--win32/mkexports.rb8
-rw-r--r--win32/resource.rb15
-rw-r--r--win32/setup.mak94
-rw-r--r--win32/win32.c2891
-rw-r--r--win32/win32.h469
-rw-r--r--wince/Makefile.sub718
-rw-r--r--wince/README.wince121
-rw-r--r--wince/assert.c11
-rw-r--r--wince/assert.h6
-rw-r--r--wince/configure.bat59
-rw-r--r--wince/direct.c54
-rw-r--r--wince/direct.h22
-rw-r--r--wince/errno.c11
-rw-r--r--wince/errno.h55
-rw-r--r--wince/fcntl.h42
-rw-r--r--wince/io.h76
-rw-r--r--wince/io_wce.c230
-rw-r--r--wince/mkconfig_wce.rb7
-rw-r--r--wince/mkexports.rb35
-rw-r--r--wince/process.h46
-rw-r--r--wince/process_wce.c47
-rw-r--r--wince/resource.rb96
-rw-r--r--wince/setup.mak233
-rw-r--r--wince/signal.h71
-rw-r--r--wince/signal_wce.c26
-rw-r--r--wince/stddef.h5
-rw-r--r--wince/stdio.c36
-rw-r--r--wince/stdlib.c57
-rw-r--r--wince/string_wce.c89
-rw-r--r--wince/sys/stat.c102
-rw-r--r--wince/sys/stat.h68
-rw-r--r--wince/sys/timeb.c25
-rw-r--r--wince/sys/timeb.h26
-rw-r--r--wince/sys/types.h67
-rw-r--r--wince/sys/utime.c44
-rw-r--r--wince/sys/utime.h27
-rw-r--r--wince/time.h63
-rw-r--r--wince/time_wce.c301
-rw-r--r--wince/varargs.h34
-rw-r--r--wince/wince.c583
-rw-r--r--wince/wince.h191
-rw-r--r--wince/wincemain.c19
-rw-r--r--wince/wincon.h7
-rw-r--r--wince/winsock2.c338
2073 files changed, 400648 insertions, 47063 deletions
diff --git a/.cvsignore b/.cvsignore
index 35fff17b58..52a5620133 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -3,18 +3,52 @@
*.rej
*.sav
*~
-.cvsignore
+.ccmalloc
+.ppack
+COPYING.LIB
+ChangeLog.pre-alpha
+ChangeLog.pre1_1
Makefile
README.fat-patch
+README.v6
+README.atheos
archive
+autom4te*.cache
+automake
+beos
config.cache
config.h
+config.h.in
config.log
config.status
configure
+foo.rb
+libruby.so.*
miniruby
+miniruby.elhash
+miniruby.elhash2
+miniruby.orig2
+miniruby.plhash
+miniruby.plhash2
+modex.rb
+newdate.rb
newver.rb
parse.c
+parse.y.try
+pitest.rb
ppack
+preview
rbconfig.rb
+rename2.h
+repack
+riscos
+rubicon
ruby
+ruby-man.rd.gz
+rubyunit
+st.c.power
+this that
+tmp
+web
+y.output
+y.tab.c
diff --git a/.document b/.document
new file mode 100644
index 0000000000..230c50e387
--- /dev/null
+++ b/.document
@@ -0,0 +1,16 @@
+# This file determines which files in the
+# Ruby hierarchy will be processed by the RDoc
+# tool when it is given the top-level directory
+# as an argument
+
+# Process all the C source files
+*.c
+
+# the lib/ directory (which has its own .document file)
+
+lib
+
+
+# and some of the ext/ directory (which has its own .document file)
+
+ext
diff --git a/COPYING b/COPYING
index eeb586b392..870a5f22d6 100644
--- a/COPYING
+++ b/COPYING
@@ -1,340 +1,56 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
+You can redistribute it and/or modify it under either the terms of the GPL
+(see the file GPL), or the conditions below:
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
- Preamble
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
+ b) use the modified software only within your corporation or
+ organization.
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
+ d) make other distribution arrangements with the author.
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
+ 3. You may distribute the software in object code or binary form,
+ provided that you do at least ONE of the following:
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
+ a) distribute the binaries and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
+ b) accompany the distribution with the machine-readable source of
+ the software.
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
+ d) make other distribution arrangements with the author.
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
+ 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 these terms.
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
+ For the list of those files and their copying conditions, see the
+ file LEGAL.
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
diff --git a/COPYING.ja b/COPYING.ja
new file mode 100644
index 0000000000..933cc7cb9a
--- /dev/null
+++ b/COPYING.ja
@@ -0,0 +1,51 @@
+$BK\%W%m%0%i%`$O%U%j!<%=%U%H%&%'%"$G$9!%(BGPL(the GNU General
+Public License)$B$^$?$O0J2<$K<($9>r7o$GK\%W%m%0%i%`$r:FG[I[$G(B
+$B$-$^$9!%(BGPL$B$K$D$$$F$O(BGPL$B%U%!%$%k$r;2>H$7$F2<$5$$!%(B
+
+ 1. $BJ#@=$O@)8B$J$/<+M3$G$9!%(B
+
+ 2. $B0J2<$N>r7o$N$$$:$l$+$rK~$?$9;~$KK\%W%m%0%i%`$N%=!<%9$r(B
+ $B<+M3$KJQ99$G$-$^$9!%(B
+
+ (a) $B%M%C%H%K%e!<%:$K%]%9%H$7$?$j!$:n<T$KJQ99$rAwIU$9$k(B
+ $B$J$I$NJ}K!$G!$JQ99$r8x3+$9$k!%(B
+
+ (b) $BJQ99$7$?K\%W%m%0%i%`$r<+J,$N=jB0$9$kAH?%FbIt$@$1$G(B
+ $B;H$&!%(B
+
+ (c) $BJQ99E@$rL@<($7$?$&$(!$%=%U%H%&%'%"$NL>A0$rJQ99$9$k!%(B
+ $B$=$N%=%U%H%&%'%"$rG[I[$9$k;~$K$OJQ99A0$NK\%W%m%0%i(B
+ $B%`$bF1;~$KG[I[$9$k!%$^$?$OJQ99A0$NK\%W%m%0%i%`$N%=!<(B
+ $B%9$NF~<jK!$rL@<($9$k!%(B
+
+ (d) $B$=$NB>$NJQ99>r7o$r:n<T$H9g0U$9$k!%(B
+
+ 3. $B0J2<$N>r7o$N$$$:$l$+$rK~$?$9;~$KK\%W%m%0%i%`$r%3%s%Q%$(B
+ $B%k$7$?%*%V%8%'%/%H%3!<%I$d<B9T7A<0$G$bG[I[$G$-$^$9!%(B
+
+ (a) $B%P%$%J%j$r<u$1<h$C$??M$,%=!<%9$rF~<j$G$-$k$h$&$K!$(B
+ $B%=!<%9$NF~<jK!$rL@<($9$k!%(B
+
+ (b) $B5!3#2DFI$J%=!<%9%3!<%I$rE:IU$9$k!%(B
+
+ (c) $BJQ99$r9T$C$?%P%$%J%j$OL>A0$rJQ99$7$?$&$(!$%*%j%8%J(B
+ $B%k$N%=!<%9%3!<%I$NF~<jK!$rL@<($9$k!%(B
+
+ (d) $B$=$NB>$NG[I[>r7o$r:n<T$H9g0U$9$k!%(B
+
+ 4. $BB>$N%W%m%0%i%`$X$N0zMQ$O$$$+$J$kL\E*$G$"$l<+M3$G$9!%$?(B
+ $B$@$7!$K\%W%m%0%i%`$K4^$^$l$kB>$N:n<T$K$h$k%3!<%I$O!$$=(B
+ $B$l$>$l$N:n<T$N0U8~$K$h$k@)8B$,2C$($i$l$k>l9g$,$"$j$^$9!%(B
+
+ $B$=$l$i%U%!%$%k$N0lMw$H$=$l$>$l$NG[I[>r7o$J$I$KIU$$$F$O(B
+ LEGAL$B%U%!%$%k$r;2>H$7$F$/$@$5$$!%(B
+
+ 5. $BK\%W%m%0%i%`$X$NF~NO$H$J$k%9%/%j%W%H$*$h$S!$K\%W%m%0%i(B
+ $B%`$+$i$N=PNO$N8"Mx$OK\%W%m%0%i%`$N:n<T$G$O$J$/!$$=$l$>(B
+ $B$l$NF~=PNO$r@8@.$7$??M$KB0$7$^$9!%$^$?!$K\%W%m%0%i%`$K(B
+ $BAH$_9~$^$l$k$?$a$N3HD%%i%$%V%i%j$K$D$$$F$bF1MM$G$9!%(B
+
+ 6. $BK\%W%m%0%i%`$OL5J]>Z$G$9!%:n<T$OK\%W%m%0%i%`$r%5%]!<%H(B
+ $B$9$k0U;V$O$"$j$^$9$,!$%W%m%0%i%`<+?H$N%P%0$"$k$$$OK\%W(B
+ $B%m%0%i%`$N<B9T$J$I$+$iH/@8$9$k$$$+$J$kB;32$KBP$7$F$b@U(B
+ $BG$$r;}$A$^$;$s!%(B
diff --git a/ChangeLog b/ChangeLog
index ee862e9723..027f0c2a6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10127 +1,8912 @@
-Wed Apr 18 00:24:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Nov 6 00:46:27 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_compile_pattern): char class at either edge of range
- should be invalid.
+ * string.c (rb_str_locktmp): check STR_TMPLOCK flag before
+ locking. [ruby-dev:24727]
-Tue Apr 17 16:54:39 2001 K.Kosako <kosako@sofnec.co.jp>
+Fri Nov 5 18:12:42 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * eval.c (safe_getter): should use INT2NUM().
+ * ext/tk/lib/tk/scrollable.rb: divide Scrollable module into
+ X_Scrollable and Y_Scrollable
-Tue Apr 17 15:12:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tk/entry.rb: include X_Scrollable instead of Scrollable
- * bignum.c (rb_big2long): 2**31 cannot fit in 31 bit long.
+ * ext/tk/lib/tk/autoload.rb: define autoload for X_Scrollable and
+ Y_Scrollable
-Sat Apr 14 22:46:43 2001 Guy Decoux <decoux@moulon.inra.fr>
+Fri Nov 5 16:05:32 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * regex.c (calculate_must_string): wrong length calculation.
+ * ext/tk/lib/tk.rb: TkComm._at() supprts both of "@x,y" and "@x"
-Sat Apr 14 13:33:32 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+Fri Nov 5 13:22:58 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * win32/config.status.in: no longer use missing/alloca.c.
+ * ext/tk/lib/tk/text.rb: sorry. bug fix again.
- * win32/Makefile.sub: ditto.
-
-Fri Apr 13 12:40:48 2001 K.Kosako <kosako@sofnec.co.jp>
-
- * eval.c (rb_thread_start_0): fixed memory leak.
-
-Fri Apr 13 16:41:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (none): should clear cmdarg_stack too.
-
-Fri Apr 13 06:19:29 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
-
- * io.c (rb_fopen): use setvbuf() to avoid recursive malloc() on
- some platforms.
-
-Wed Apr 11 23:36:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * file.c (rb_stat_dev): device functions should honor stat field
- types (except long long such as dev_t).
-
-Wed Apr 11 18:07:53 2001 K.Kosako <kosako@sofnec.co.jp>
-
- * eval.c (rb_mod_nesting): should not push nil for nesting array.
-
- * eval.c (rb_mod_s_constants): should not search array by
- rb_mod_const_at() for nil (happens for singleton class).
-
-Wed Apr 11 13:29:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (rb_singleton_class_attached): should modify iv_tbl by
- itself, no longer use rb_iv_set() to avoid freeze check error.
-
- * variable.c (rb_const_get): error message "uninitialized constant
- Foo at Bar::Baz" instead of "uninitialized constantBar::Baz::Foo".
-
-Tue Apr 10 02:24:40 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * io.c (opt_i_set): should strdup() inplace_edit string.
-
-Mon Apr 9 23:29:54 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (exec_under): need to push cref too.
-
-Mon Apr 9 12:05:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * file.c (Init_File): should redifine "new" class method.
-
-Mon Apr 9 11:56:52 2001 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb: fix typo.
-
-Thu Apr 5 22:40:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * variable.c (rb_const_get): no recursion to show full class path
- for modules.
-
- * eval.c (rb_set_safe_level): should set safe level in curr_thread
- as well.
-
- * eval.c (safe_setter): ditto.
-
-Thu Apr 5 13:46:06 2001 K.Kosako <kosako@sofnec.co.jp>
-
- * object.c (rb_obj_is_instance_of): nil belongs to false, not true.
-
-Thu Apr 5 02:19:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (make_time_t): proper (I hope) daylight saving time
- handling for both US and Europe. I HATE SUMMER TIME!
-
- * eval.c (rb_thread_wait_for): non blocked signal interrupt should
- stop the interval.
-
-Wed Apr 4 03:47:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (rb_mod_clone): should copy method bodies too.
-
- * bignum.c (bigdivrem): should trim trailing zero bdigits of
- remainder, even if dd == 0.
-
-Tue Apr 3 15:29:10 2001 Akinori MUSHA <knu@iDaemons.org>
-
- * Makefile.in: Introduce MAINLIBS.
-
- * configure.in: Link libc_r against the ruby executable on
- FreeBSD, which is the first attempt to work around a certain
- problem regarding pthread on FreeBSD. It should make ruby/libruby
- happy when it loads an extention to a library compiled and linked
- with -pthread. Note, however, that libruby is _not_ linked with
- libc_r so as not to mess up pthread unfriendly stuff including
- apache+mod_ruby and vim6+ruby_interp.
-
-Tue Apr 3 09:56:20 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ext/extmk.rb.in (create_makefile): create def file only if
- it does not yet exist.
-
- * lib/mkmf.rb: ditto.
-
-Tue Apr 3 00:05:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * time.c (make_time_t): remove HAVE_TM_ZONE code since it
- sometimes reports wrong time.
-
- * time.c (make_time_t): remove unnecessary range check for
- platforms where negative time_t is available.
-
-Mon Apr 2 14:25:49 2001 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/monitor.rb (wait): ensure reentrance.
-
- * lib/monitor.rb (wait): fix timeout support.
-
-Mon Apr 2 12:44:53 2001 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb: backport from ruby-1.7.
-
-Mon Apr 2 01:16:24 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * win32/win32.c: use ruby's opendir on mingw32.
-
- * missing/dir.h, dir.c, Makefile: ditto.
-
-Sun Apr 1 23:26:14 2001 TOYOFUKU Chikanobu <toyofuku@juice.or.jp>
-
- * numeric.c (flodivmod): a bug in no fmod case.
-
-Sun Apr 1 18:36:14 2001 Koji Arai <JCA02266@nifty.ne.jp>
-
- * process.c (pst_wifsignaled): should apply WIFSIGNALED for status
- (int), not st (VALUE).
-
-Sat Mar 31 03:24:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (rb_include_module): module inclusion should be check
- taints.
-
-Fri Mar 30 12:51:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (rb_include_module): freeze check at first.
-
-Thu Mar 29 17:05:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_attr): sprintf() and rb_intern() moved into
- conditional body.
-
-Wed Mar 28 23:43:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * ext/extmk.rb.in, lib/mkmf.rb: add C++ rules in addition to C
- rules for the mswin32 platforms.
-
-Wed Mar 28 19:29:21 2001 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/extmk.rb.in, lib/mkmf.rb: move C++ rules to the right place.
-
-Wed Mar 28 17:39:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_str2cstr): warn if string contains \0 and length
- value is ignored.
-
-Wed Mar 28 15:00:31 2001 K.Kosako <kosako@sofnec.co.jp>
-
- * class.c (rb_singleton_class_clone): should copy class constant
- table as well.
-
-Wed Mar 28 15:03:23 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (rb_include_module): sometimes cache was mistakenly left
- uncleared - based on the patch by K.Kosako.
-
-Wed Mar 28 09:52:33 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * win32/Makefile.sub: disable global optimization.
-
-Tue Mar 27 15:00:54 2001 K.Kosako <kosako@sofnec.co.jp>
-
- * eval.c (rb_mod_define_method): should have clear method cache.
-
- * eval.c (rb_mod_define_method): should have raised exception for
- type error.
-
-Tue Mar 27 14:48:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h: changed "extern INLINE" to "static inline".
-
-Mon Mar 26 23:19:33 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * time.c (rb_strftime): check whether strftime returns empty string.
-
-Mon Mar 26 18:14:47 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (rb_glob_helper): part of 1.7 globber backported to proper
- following of symlinks.
-
-Mon Mar 26 17:21:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c: remove TMP_PROTECT_END to prevent C_ALLOCA crash.
-
-Mon Mar 26 14:04:41 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ext/Win32API/Win32API.c: remove Init_win32api().
-
-Sat Mar 24 23:44:50 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (ev_const_defined): should ignore toplevel cbase (Object).
-
- * eval.c (ev_const_get): ditto.
-
-Fri Mar 23 12:18:44 2001 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
-
- * ext/curses/curses.c: curses on Mac OS X public beta does not
- have _maxx etc.
-
-Fri Mar 23 10:50:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (w_object): should truncate trailing zero short for
- bignums.
-
-Thu Mar 22 22:15:45 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ext/Win32API/extconf.rb: add -fno-omit-frame-pointer.
-
-Thu Mar 22 17:43:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.h: better inline function support.
-
- * configure.in (NO_C_INLINE): check if inline is available for the
- C compiler.
-
-Wed Mar 21 23:07:45 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * win32/win32.c (win32_stat): WinNT/2k "//host/share" support.
-
-Wed Mar 21 01:26:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (id2ref): sometimes confused symbol and reference.
-
-Tue Mar 20 23:09:33 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * win32/win32.c (win32_stat): UNC support.
-
- * dir.c (extract_path): fix "./*" problem.
-
-Mon Mar 19 19:14:47 2001 Guy Decoux <decoux@moulon.inra.fr>
-
- * marshal.c (shortlen): shortlen should return number of bytes
- written.
-
-Mon Mar 19 18:56:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * stable version 1.6.3 released.
-
-Mon Mar 19 16:52:23 2001 K.Kosako <kosako@sofnec.co.jp>
-
- * eval.c (ev_const_defined): need not to check if cbase->nd_class
- is rb_cObject.
-
- * eval.c (ev_const_get): ditto.
-
-Mon Mar 19 16:27:32 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (THREAD_ALLOC): flags should be initialized.
-
- * signal.c (rb_f_kill): should use FIX2INT, not FIX2UINT.
-
-Mon Mar 19 11:03:10 2001 Koji Arai <JCA02266@nifty.ne.jp>
-
- * marshal.c (r_object): len calculation patch was wrong for
- machines SIZEOF_BDIGITS == SIZEOF_SHORT.
-
- * gc.c: alloca prototype reorganized for C_ALLOCA machine.
-
-Sun Mar 18 08:58:18 2001 Wakou Aoyama <wakou@fsinet.or.jp>
-
- * lib/net/cgi.rb: // === '' --> //.match('')
-
- * lib/net/cgi.rb: cgi#header(): improvement for mod_ruby.
-
- * lib/net/cgi.rb: cgi#rfc1123date(): improvement.
- thanks to TADA Tadashi <sho@spc.gr.jp>.
-
- * lib/net/cgi.rb: cgi#rfc1123date(): document bug fix.
- thanks to Kazuhiro NISHIYAMA <zn@mbf.nifty.com>.
-
- * lib/net/cgi.rb: cgi#header(): bug fix.
- thanks to IWATSUKI Hiroyuki <don@na.rim.or.jp>.
-
-Fri Mar 16 17:21:25 2001 Akinori MUSHA <knu@iDaemons.org>
-
- * configure.in: Set SOLIBS properly for all ELF and
- FreeBSD/NetBSD/OpenBSD a.out platforms so that the shlib
- dependencies are recorded in the libruby shlib.
-
-Wed Mar 14 16:41:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_thread_schedule): raise FATAL just once to
- THREAD_TO_KILL.
-
-Wed Mar 14 10:41:34 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_yield_0): 0 (= Qfalse) is a valid value, so that
- default self should be checked by klass == 0.
-
- * bignum.c (rb_cstr2inum): should disallow '++1', '+-1', etc.
-
-Tue Mar 13 17:51:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (ev_const_defined): add new parameter self for special
- const fallback.
-
- * eval.c (ev_const_get): ditto.
-
-Tue Mar 13 16:39:45 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * dir.c (rb_glob_helper): fix drive letter handling on DOSISH.
-
-Tue Mar 13 15:01:12 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/http.rb: add HTTPRequest#basic_auth.
-
- * lib/net/smtp.rb: raise if only account or password is given.
-
- * lib/net/protocol.rb: WriteAdapter#<< returns self.
-
-Tue Mar 13 14:41:16 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (argf_seek): wrong calling sequence of rb_io_seek().
-
-Mon Mar 12 18:59:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/mkmf.rb (create_makefile): save/restore $libs and $LIBPATH.
-
-Sun Mar 11 00:55:31 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/mkmf.rb (install_rb): fix handling of destination path.
-
-Sat Mar 10 02:34:18 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * math.c (math_log, math_log10): use nan() instead of 0.0/0.0 on Cygwin.
-
-Thu Mar 8 17:43:59 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb: one write(2) per one line.
-
-Wed Mar 7 14:26:11 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * math.c (math_log, math_log10): should return NaN if x < 0.0
- on Cygwin.
-
-Thu Mar 7 10:31:26 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * parse.y (stmt): while/until modifier must work for empty body.
-
-Tue Mar 6 22:53:58 2001 Kazuhiro Yoshida <moriq.kazuhiro@nifty.ne.jp>
-
- * ruby.c (ruby_set_argv): clear ARGV contents before adding args.
-
-Tue Mar 6 10:50:29 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (primary): rescue and ensure clauses should be allowed
- to appear in singleton method body.
-
-Mon Mar 5 17:25:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_eq): compare Procs using blocktag equality.
-
- * eval.c (proc_to_s): stringify according to block tag address.
-
-Mon Mar 5 17:19:56 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * win32/win32.c (gettimeofday): use GetLocalTime() instead of ftime()
- for high-resolution timing.
-
-Sun Mar 4 20:45:20 2001 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/extmk.rb.in, lib/mkmf.rb: add C++ rules in addition to C
- rules.
-
-Sun Mar 4 17:01:09 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * string.c (trnext): support backslash escape in String#tr.
-
-Wed Feb 28 11:02:41 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_delete_bang): delete! should take at least 1
- argument.
-
-Tue Feb 27 16:38:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (ev_const_get): retrieve Object's caonstat if no current
- class is available (e.g. defining singleton class for Fixnums).
-
- * eval.c (ev_const_defined): check Object's constant if no current
- class is available (e.g. defining singleton class for Fixnums).
-
- * eval.c (proc_call): ignore block to `call' always, despite of
- being orphan or not.
-
-Wed Feb 27 10:16:32 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * eval.c (rb_yield_0): should check based on rb_block_given_p()
- and rb_f_block_given_p().
-
-Mon Feb 26 16:20:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ruby.c (proc_options): call ruby_show_version() just once.
-
-Mon Feb 26 00:04:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (proc_call): should not modify ruby_block->frame.iter
- based on ruby_frame->iter altered by PUSH_ITER().
-
-Mon Feb 26 05:27:52 2001 Wakou Aoyama <wakou@fsinet.or.jp>
-
- * lib/net/telnet.rb: #telnetmode(), #binmode(): bug fix.
- thanks to nobu.nakada@nifty.ne.jp.
-
-Mon Feb 26 04:55:50 2001 Wakou Aoyama <wakou@fsinet.or.jp>
-
- * lib/cgi.rb: CGI#form(): bug fix.
- thanks to MoonWolf <moonwolf@moonwolf.com>.
-
- * lib/cgi.rb: CGI#rfc1123_date(): improvement.
- thanks to Tomoyasu Akita <genzo-@dm4lab.to>.
-
- * lib/cgi.rb: CGI#header(): improvement for mod_ruby.
- thanks to Shugo Maeda <shugo@ruby-lang.org>.
-
-Sun Feb 25 02:45:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * file.c (rb_file_s_rename): avoid Cygwin's bug.
-
-Sat Feb 24 23:32:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_thread_fd_close): should save current context before
- raising exception.
-
-Sat Feb 24 22:14:00 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * win32/win32.c (myrename): fix error handling.
-
-Sat Feb 24 15:43:31 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb: use net 1.2 for also ruby 1.6 branch.
-
- * lib/net/smtp.rb: ditto.
-
- * lib/net/pop.rb: ditto.
-
- * lib/net/http.rb: ditto.
-
-Fri Feb 23 16:36:09 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/http.rb: always close connection if body is not exist.
-
-Fri Feb 23 13:27:05 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/http.rb: keep-alive detection was incomplete.
-
-Fri Feb 23 08:24:53 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb: clear read buffer after reopen.
-
- * lib/net/http.rb: update RD document.
-
-Tue Feb 20 16:37:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (rb_big2long): should not raise RangeError for Bignum
- LONG_MIN value.
-
-Mon Feb 19 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_substr): "a"[1,2] should return ""; need
- rubicon upgrade.
-
-Mon Feb 19 01:55:43 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (secure_visibility): visibility check for untainted modules.
-
-Mon Feb 19 00:29:29 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * signal.c (sigpipe): sighandler which does nothing.
-
- * signal.c (trap): set sigpipe function for SIGPIPE.
-
- * signal.c (Init_signal): default SIGPIPE handler should be
- sigpipe function.
-
-Sun Feb 18 15:42:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ext/curses/extconf.rb: add dir_config.
-
- * missing/flock.c: use fcntl(2) instead of lockf(2).
-
-Sun Feb 18 13:02:03 2001 Yasushi Shoji <yashi@yashi.com>
-
- * array.c (rb_ary_subseq): wrong boundary check.
-
-Fri Feb 16 01:44:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (set_outfile): f should be the FILE* from the assigning value.
-
-Thu Feb 15 11:33:49 2001 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/cgi/session.rb (close): fixed reversed condition.
-
-Wed Feb 14 17:28:24 2001 Shugo Maeda <shugo@ruby-lang.org>
-
- * lib/net/imap.rb: supports unknown resp_text_code.
-
-Wed Feb 14 00:44:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * dir.c (dir_s_glob): call rb_yield directly (via push_pattern) if
- block is given to the method.
-
- * dir.c (push_pattern): do not call rb_ary_push; yield directly.
-
-Tue Feb 13 23:05:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * dir.c (lstat): should use rb_sys_stat if lstat(2) is not
- available.
-
-Tue Feb 13 17:00:18 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/http.rb: supports HTTP 1.0 server.
-
-Tue Feb 13 01:13:43 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (primary): preserve and clear in_single and in_def using
- stack to prevent nested method errors in singleton class bodies.
-
-Sun Feb 11 16:00:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * eval.c (stack_length): use __builtin_frame_address() only if
- GCC and i386 CPU.
-
- * gc.c (rb_gc, Init_stack): ditto.
-
- * configure.in: add ac_cv_func_getpgrp_void=yes on DJGPP.
-
-Sat Feb 10 23:43:49 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * hash.c (rb_any_hash): dumped core on machines sizeof(int) != sizeof(long).
-
-Sat Feb 10 23:07:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * regex.c (PREV_IS_A_LETTER): should not treat c>0x7f as a word
- character if -Kn.
-
-Sat Feb 10 00:06:28 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * win32/win32.c (win32_stat): replace stat for enable when pathname
- ends with '/' or '\' for mswin32 on Win9X / Win2k.
-
- * win32/win32.h: ditto.
-
- * ruby.h: ditto.
-
- * dir.c (rb_glob_helper): ditto.
-
- * file.c (rb_stat, rb_file_s_stat, eaccess, check3rdbyte): ditto.
-
-Fri Feb 9 22:54:57 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * ruby.c (ruby_init_loadpath): convert '\\' to '/'
- before finding executable file path.
-
-Fri Feb 9 17:41:53 2001 Triet H. Lai <thlai@mail.usyd.edu.au>
-
- * dir.c (rb_glob_helper): do not follow symbolic links.
-
-Fri Feb 8 23:53:08 2001 Usaku Nakamura <usa@osb.att.ne.jp>
-
- * win32/config.h.in (inline): add inline definition.
-
-Thu Feb 8 21:27:24 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * lib/mkmf.rb (install_rb): fix handling of relative path.
-
- * lib/mkmf.rb (create_makefile): add srcdir.
-
-Wed Feb 7 16:05:22 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * parse.y (parse_quotedwords): %w should allow parenthesis escape.
-
-Wed Feb 7 00:57:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (parse_qstring): %q should allow terminator escape.
-
-Wed Feb 7 00:57:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_equal): all option flags should be same to be equal.
+Fri Nov 5 13:17:54 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Feb 6 21:01:29 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/tk/lib/tk/text.rb: bug fix
- * lib/net/protocol.rb: ignore EOFError on only specified case.
+Fri Nov 5 08:52:48 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/http.rb: take HTTP 1.0 server into account.
+ * gc.c (gc_mark): stricter GC stack check.
-Mon Feb 5 00:39:06 2001 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+Fri Nov 5 08:34:43 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * dir.c: use ISXXX() instead of isxxx().
+ * string.c (str_gsub): should have removed rb_str_unlocktmp(str).
+ [ruby-dev:24708]
- * dln.c (aix_loaderror): ditto.
+Thu Nov 4 21:25:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * file.c (rb_file_s_expand_path): ditto.
+ * string.c (str_gsub): string modify check no longer based on
+ tmplock. [ruby-dev:24706]
- * string.c (rb_str_upcase_bang): ditto.
+Thu Nov 4 19:27:46 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * win32/win32.c (do_spawn): ditto.
+ * io.c (rb_f_open): fix typo.
- * win32/win32.c (NtMakeCmdVector): ditto.
+Thu Nov 4 15:02:14 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * win32/win32.c (opendir): ditto.
+ * ext/tk/lib/tk/variable.rb: forget to initialize instance_variables
+ of TkVarAccess objects
-Fri Feb 3 00:48:50 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+Thu Nov 4 09:11:35 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * win32/win32.c (isInternalCmd): ignore case for shell's internal
- command. (marge from HEAD)
+ * gc.c (gc_mark): enable GC stack checking.
-Fri Feb 2 16:14:51 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Nov 4 03:11:33 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (POP_VARS): propagate DVAR_DONT_RECYCLE, if
- SCOPE_DONT_RECYCLE of ruby_scope is set.
+ * string.c (str_gsub): lock strings temporarily. [ruby-dev:24687]
-Wed Jan 31 22:27:29 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+ * ext/socket/socket.c (s_recvfrom): tmplock input buffer.
+ [ruby-dev:24705]
- * configure.in: gcc-2.95.2-7(cygwin) support.
- add -mwin32 if available.
+Wed Nov 3 22:32:12 2004 NARUSE, Yui <naruse@ruby-lang.org>
- * cygwin/GNUmakefile: ditto.
+ * process.c: On NetBSD don't use setruid() and setrgid().
-Mon Jan 29 17:36:19 2001 TOYOFUKU Chikanobu <toyofuku@juice.or.jp>
+Wed Nov 3 22:24:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (rb_eval): nd_iter evaluation should be wrapped by
- BEGIN_CALLARGS and END_CALLARGS.
+ * lib/webrick/httpauth/digestauth.rb: use Base64.encode64 to
+ avoid warnings.
-Mon Jan 29 01:40:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Nov 3 17:19:59 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_independent): should not clear str->orig here.
- it's too early.
+ * array.c (rb_ary_uniq_bang): do not push frozen string from hash
+ table. [ruby-dev:24695]
-Wed Jan 24 01:45:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (rb_ary_and): ditto.
- * eval.c (POP_BLOCK_TAG): call rb_gc_force_recycle() if block has
- not been objectified.
+ * array.c (rb_ary_or): ditto.
- * eval.c (rb_callcc): should nail down block->tag history to avoid
- rb_gc_force_recycle().
+Wed Nov 3 17:13:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Jan 23 18:51:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * io.c (pipe_open): fix compile error
- * gc.c (rb_gc_call_finalizer_at_exit): should finalize objects in
- deferred_final_list too.
+Wed Nov 3 16:58:07 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Jan 23 16:10:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tk.rb: support to use different Tcl commands between
+ configure and configinfo
- * gc.c (os_live_obj): do not list terminated object.
+ * ext/tk/lib/font.rb: ditto.
- * gc.c (os_obj_of): ditto.
+ * ext/tk/lib/itemconfig.rb: support to use different Tcl commands
+ between item_configure and item_configinfo
- * gc.c (rb_gc_mark): support new T_BLKTAG tag.
+ * ext/tk/lib/itemfont.rb: ditto.
- * gc.c (obj_free): ditto.
+ * ext/tk/extconf.rb: install SUPPORT_STATUS
- * eval.c (new_blktag): creation of new block tag, which holds
- destination of global jump and orphan status.
+ * ext/tk/lib/tkextlib: some bug fixes (see ext/tk/ChangeLog.tkextlib)
- * eval.c (block_pass): break from orphan Proc object will raise a
- LocalJumpError exception.
+Wed Nov 3 16:30:41 2004 NARUSE, Yui <naruse@ruby-lang.org>
-Mon Jan 22 16:33:16 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+ * ext/nkf: follow nkf 2.0.4
- * mkconfig.rb: autoconf 2.49 support.
+Wed Nov 3 15:53:34 2004 Kouhei Sutou <kou@cozmixng.org>
-Sat Jan 20 03:54:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * test/rss/test_maker_*.rb: added tests for RSS Maker.
- * parse.y (yylex): fixed serious syntax misbehavior. do's
- preceding was too high. a block in `foo bar do .. end' should
- be passed to `foo', not `bar'.
-
- * parse.y (block_call): syntax restructure.
-
-Fri Jan 19 04:04:31 2001 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/irb/ruby-lex.rb: Merge from HEAD: rev.1.4
-
-Wed Jan 17 13:28:26 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * configure.in: remove DEFS definition.
-
- * mkconfig.rb: ditto.
-
- * win32/config.status.in: ditto.
-
-Tue Jan 16 16:59:14 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb: ignore EOFError for read
-
-Sun Jan 14 21:49:28 2001 Koji Arai <JCA02266@nifty.ne.jp>
-
- * sprintf.c (rb_f_sprintf): simple typo. binary base should be 2,
- not '2'.
-
-Sun Jan 14 02:49:57 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb (adding): too few "yield" in case of arg is
- not String/File.
-
-Sat Jan 13 19:18:18 2001 WATANABE Hirofumi <eban@ruby-lang.org>
-
- * re.c (rb_reg_desc): separate RE_OPTION_MULTILINE
-
- * re.c (rb_reg_options): add RE_OPTION_{POSIXLINE,RE_OPTION_MULTILINE,
- RE_OPTION_EXTENDED}
-
-Thu Jan 11 06:45:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_mod_dup): should propagate FL_SINGLETON.
-
- * object.c (inspect_obj): handles the case of no instance variable.
-
-Wed Jan 10 01:50:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_reverse_bang): forgot to call rb_str_modify().
-
-Tue Jan 9 17:41:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_obj_taint): check frozen status before modifying
- taint status.
-
- * object.c (rb_obj_untaint): ditto.
-
-Mon Jan 8 21:35:10 2001 Guy Decoux <decoux@moulon.inra.fr>
-
- * file.c (path_check_1): should restore modified path.
-
-Mon Jan 8 21:24:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * bignum.c (bigdivrem): t2 might be too big for signed long; do
- not use rb_int2big(), but rb_uint2big().
-
-Mon Jan 8 03:09:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * error.c (rb_load_fail): new func to report LoadError.
-
- * ruby.c (load_file): use rb_load_fail.
-
-Sat Jan 6 00:55:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * pack.c (pack_pack): template "m2" or "u2" caused inifinite loop.
-
-Fri Jan 5 01:02:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (ruby_finalize): should enclosed by PUSH_TAG/POP_TAG.
-
-Sun Dec 31 01:39:16 2000 Guy Decoux <decoux@moulon.inra.fr>
-
- * eval.c (rb_mod_define_method): wrong comparison for blocks.
-
-Sat Dec 30 19:28:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (id2ref): should handle Symbol too.
-
- * gc.c (id2ref): should print original ptr value
-
-Sat Dec 30 03:14:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_iterate): NODE_CFUNC does not protect its data
- (nd_tval), so create new node NODE_IFUNC for iteration C
- function.
-
- * eval.c (rb_yield_0): use NODE_IFUNC.
-
- * gc.c (rb_gc_mark): support NODE_IFUNC.
-
-Fri Dec 29 11:41:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (mem_error): prohibit recursive mem_error().
- (ruby-bugs-ja:PR#36)
-
-Fri Dec 29 11:05:41 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_thread_fd_writable): should not switch context if
- rb_thread_critical is set.
-
- * eval.c (rb_thread_wait_fd): ditto.
-
- * eval.c (rb_thread_wait_for): ditto.
-
- * eval.c (rb_thread_select): ditto.
-
- * eval.c (rb_thread_join): join during critical section causes
- deadlock.
-
-Tue Dec 26 18:46:41 2000 NAKAMURA Hiroshi <nakahiro@sarion.co.jp>
-
- * lib/debug.rb: Avoid thread deadlock in debugging stopped thread.
-
- * lib/debug.rb: Uncleared 'finish' state.
-
-Tue Dec 26 16:53:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (rb_yield_0): remove dvar node by rb_gc_force_recycle()
- more eagerly.
-
- * eval.c (rb_f_binding): recycling should be stopped for outer
- scope too.
-
- * eval.c (proc_new): ditto.
-
-Tue Dec 26 15:45:35 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_inspect): should treat multibyte chracters
- properly.
-
-Mon Dec 25 17:49:08 2000 K.Kosako <kosako@sofnec.co.jp>
-
- * string.c (rb_str_replace_m): unexpected string share happens if
- replace is done for associated (STR_NO_ORIG) string.
-
-Tue Dec 26 15:01:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_f_p): should not call rb_io_flush() if rb_defout is not
- a IO (T_FILE).
-
-Mon Dec 25 15:52:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * stable version 1.6.2 released.
+ * lib/rss/maker.rb: added RSS Maker.
+
+ * lib/rss/maker/*.rb: ditto.
-Mon Dec 25 05:11:04 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+Tue Nov 2 16:35:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/cgi.rb: version 2.1.2 (some bug fixes).
+ * ext/enumerator/enumerator.c (each_cons_i): pass copy of an
+ internal consequent array. [ruby-talk:118691]
- * lib/cgi.rb: Regexp::last_match[1] --> $1
+Tue Nov 2 16:05:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/telnet.rb: ditto.
+ * process.c (rb_f_fork): need to flush stdout and stderr before
+ fork(2). [ruby-talk:117715]
-Mon Dec 25 04:43:02 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Tue Nov 2 01:20:09 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/http.rb: does not send HEAD on closing socket.
+ * eval.c (proc_invoke): nail down dyna_var node when Proc object
+ or continuation is created. [ruby-dev:24671]
-Mon Dec 25 00:44:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Nov 1 13:59:28 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * hash.c (rb_any_cmp): should use rb_str_cmp() if TYPE == T_STRING
- and CLASS_OF == rb_cString.
+ * ext/extmk.rb (MANIFEST): do not use anymore, use extconf.rb instead.
- * string.c (rb_str_new4): should copy class of original too.
+ * ext/enumerator/extconf.rb, ext/fcntl/extconf.rb,
+ ext/stringio/extconf.rb: added.
-Mon Dec 25 00:04:54 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * MANIFEST, ext/**/MANIFEST: removed.
- * eval.c (rb_thread_schedule): initial value of `max' changed to -1.
+ * README.EXT, README.EXT.ja: remove MANIFEST stuff.
-Mon Dec 25 00:16:14 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Nov 1 01:14:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (rb_str_replace_m): copy-on-write replace.
+ * io.c (rb_f_open): create copy of popen specifier. [ruby-dev:24656]
- * parse.y (yylex): should handle => after identifier as well as ==
- and =~.
+Mon Nov 1 00:36:48 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Sat Dec 23 23:55:57 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * main.c (_stklen): move to gc.c.
- * bignum.c (rb_cstr2inum): Integer("") should not return 0.
+Sun Oct 31 00:22:28 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Dec 23 11:55:57 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * string.c (rb_str_locktmp): lock string temporarily.
- * array.c (rb_ary_and): Array#& should preverve original order.
+ * string.c (str_independent): add tmplock check.
-Sat Dec 23 03:44:16 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * io.c (io_write): lock output string temporarily.
+ [ruby-dev:24649]
- * lib/net/protocol.rb: set @closed false in Socket#reopen.
+ * io.c (io_write): use rb_str_locktmp().
- * lib/net/pop.rb: add POP3.foreach, delete_all.
+ * io.c (read_all): ditto.
- * lib/net/pop.rb: add POP3#delete_all.
+Sat Oct 30 06:53:24 2004 Peter Vanbroekhoven <peter.vanbroekhoven@cs.kuleuven.ac.be>
- * lib/net/http.rb: add HTTP.version_1_1, version_1_2
+ * eval.c (rb_eval): NODE_XSTR should pass copy of literal string.
- * lib/net/http.rb: refactoring.
+Sat Oct 30 00:19:40 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Dec 22 23:11:12 2000 Ueno Katsuhiro <unnie@blue.sky.or.jp>
+ * enum.c (enum_sort_by): protect continuation jump in.
+ [ruby-dev:24642]
- * eval.c (rb_feature_p): ext might be null.
+Fri Oct 29 21:27:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Dec 22 17:04:12 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * io.c (rb_io_check_initialized): new function to check uninitialized
+ object. [ruby-talk:118234]
- * win32/win32.c (myselect): avoid busy loop by adjusting fd_count.
+ * file.c (rb_file_path), io.c (rb_io_closed): check if initialized.
-Fri Dec 22 15:07:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Oct 29 10:00:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bignum.c (rb_cstr2inum): prefix like '0x' had removed too much.
+ * eval.c (rb_thread_start_0): forget to free some memory chunks.
+ [ruby-core:03611]
-Thu Dec 21 13:01:46 2000 Tanaka Akira <akr@m17n.org>
+ * eval.c (ruby_cleanup): ruby_finalize_1 may cause exception,
+ should be wrapped by PUSH_TAG/POP_TAG(). [ruby-dev:24627]
- * lib/net/ftp.rb (makeport): don't use TCPsocket.getaddress.
+Thu Oct 28 23:32:54 2004 akira yamada <akira@ruby-lang.org>
-Wed Dec 20 12:00:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/zlib/zlib.c (zstream_detach_input): resets klass of z->input if
+ z->input isn't nil.
- * bignum.c (rb_big_lshift): should cast up to BDIGIT_DBL.
+Thu Oct 28 23:19:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (yylex): disallow trailing '_' for numeric litrals.
+ * ext/extmk.rb: prefer relative path. [ruby-talk:93037]
- * bignum.c (rb_cstr2inum): allow `_' within converting string.
+Wed Oct 27 18:49:11 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (specific_eval): should take no argument if block is
- supplied.
+ * gc.c: prototype; rb_io_fptr_finalize() doesn't return any value
+ at this version.
-Tue Dec 19 13:44:50 2000 K.Kosako <kosako@sofnec.co.jp>
+Wed Oct 27 17:27:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_f_p): should flush rb_defout, not stdout.
+ * gc.c (gc_sweep): recover ruby_in_compile variable.
-Tue Dec 19 00:57:10 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Oct 27 09:17:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * time.c (time_minus): usec might overflow. (ruby-bugs-ja:PR#35)
+ * string.c (str_gsub): use a string object for exception safeness.
+ [ruby-dev:24601]
- * eval.c (rb_obj_extend): Object#extend should take at least one
- argument.
+Tue Oct 26 23:52:32 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (mrhs_basic): should check value_expr($3), not $1.
+ * io.c (rb_io_getline): rs modification check should not interfere in the loop.
-Mon Dec 18 23:18:39 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+Tue Oct 26 23:30:39 2004 Dave Thomas <dave@pragprog.com>
- * util.c (mblen, __crt0_glob_function): add for multibyte
- on DJGPP 2.03.
+ * lib/rdoc/code_objects.rb (RDoc::Context::add_class_or_module):
+ Restore correct :nopdoc: behavior with nested classes and modules.
-Mon Dec 18 18:10:30 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Oct 26 18:21:29 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * time.c (time_plus): usec might underflow (ruby-bugs-ja:#PR33).
+ * string.c (RESIZE_CAPA): check string attribute before modifying
+ capacity member of string structure. [ruby-dev:24594]
-Mon Dec 18 08:11:20 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Oct 26 11:33:26 2004 David G. Andersen <dga@lcs.mit.edu>
- * hash.c (rb_hash_set_default): should call rb_hash_modify().
+ * ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
+ performance. [ruby-talk:117701]
-Sat Dec 16 02:58:26 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Tue Oct 26 10:56:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_eval): should clear ruby_errinfo on retry.
+ * sprintf.c (rb_f_sprintf): raise ArgumentError for extra
+ arguments, unless (digit)$ style used.
- * eval.c (rb_rescue2): ditto.
+Tue Oct 26 11:33:26 2004 David G. Andersen <dga@lcs.mit.edu>
-Thu Dec 14 13:06:18 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
+ performance. [ruby-talk:117701]
- * class.c (rb_include_module): prohibit fronzen class/module.
+Tue Oct 26 10:56:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_frozen_class_p): make external.
+ * sprintf.c (rb_f_sprintf): raise ArgumentError for extra
+ arguments, unless (digit)$ style used.
- * intern.h (rb_frozen_class_p): prototyped.
+Mon Oct 25 18:35:39 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * intern.h (rb_undef): prototyped not but rb_undef_method()
- which is also in ruby.h.
+ * win32/win32.c (isUNCRoot): should check NUL after '.'.
+ [ruby-dev:24590]
-Thu Dec 14 09:20:26 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+ * win32/win32.c (isUNCRoot): fixed buffer overrun.
- * lib/cgi.rb: support -T1 on ruby 1.6.2
+Mon Oct 25 08:03:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/cgi.rb: $1 --> Regexp::last_match[1]
+ * eval.c (get_backtrace): ignore illegal backtrace. [ruby-dev:24587]
- * lib/net/telnet.rb: ditto.
+Sun Oct 24 00:41:09 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Dec 13 23:27:06 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (rb_load, search_required, rb_require_safe, rb_require): use
+ frozen shared string to avoid outside modification. [ruby-dev:24580]
- * eval.c (rb_eval): handles case statement without expr, which
- looks for any TRUE (non nil, non false) when expression.
+Sat Oct 23 22:18:32 2004 Guy Decoux <ts@moulon.inra.fr>
- * parse.y (primary): case expression should not be compstmt, but
- mere expr.
+ * eval.c (frame_free): Guy Decoux solved the leak problem.
+ Thanks. [ruby-core:03549]
- * parse.y (primary): case without following expression is now
- separated rule.
+Sat Oct 23 00:20:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Dec 13 12:41:27 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * ext/zlib/zlib.c (zstream_append_input): clear klass for z->input
+ to avoid potential vulnerability.
- * ruby.c (proc_options): accept "--^M" for DOS line endings.
+ * ext/zlib/zlib.c (zstream_run): always use zstream_append_input()
+ to avoid SEGV. [ruby-dev:24568]
-Tue Dec 12 15:45:42 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Oct 22 12:02:28 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (newline_node): cancel newline unification.
+ * eval.c (rb_alias): was warning for wrong condition.
+ [ruby-dev:24565]
-Mon Dec 11 23:01:57 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Oct 22 10:36:37 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * parse.y (yylex): supports cases `?' precedes EOF and newline.
+ * lib/webrick/httprequest.rb (WEBrick::HTTPRequest#meta_vars):
+ should check if path_info is not nil.
-Mon Dec 11 12:11:25 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Oct 22 00:22:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (call_end_proc): some frame members were left
- uninitialized.
+ * ext/zlib/zlib.c (zstream_shift_buffer): should restore class
+ field of a buffer. [ruby-dev:24562]
-Mon Dec 11 01:14:58 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Oct 22 00:20:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_fptr_finalize): do not fclose stdin, stdout and
- stderr at exit.
+ * string.c (rb_str_include): should not treat char as negative value.
+ [ruby-dev:24558]
-Sat Dec 9 17:34:48 2000 Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
+Thu Oct 21 19:06:15 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * time.c (time_cmp): should check with kind_of?, not instance_of?
+ * lib/webrick/httpresponse.rb (WEBrick::HTTPResponse#send_body_io):
+ ensure to close @body. (http://bugs.debian.org/277520)
- * time.c (time_eql): ditto.
+Thu Oct 21 00:36:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * time.c (time_minus): ditto.
+ * eval.c (rb_alias): should warn on method discarding.
+ [ruby-dev:24546]
-Fri Dec 8 17:23:25 2000 Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
+ * ext/zlib/zlib.c (zstream_expand_buffer_into): hide internal
+ string buffer by clearing klass. [ruby-dev:24548]
- * sprintf.c (rb_f_sprintf): proper string precision treat.
+Wed Oct 20 19:45:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Dec 8 10:44:05 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * string.c (str_gsub): reentrant check. [ruby-dev:24432]
- * variable.c (rb_mod_remove_cvar): Module#remove_class_variable
- added.
+ * backport all SEGV bug fixes from CVS HEAD. [ruby-dev:24536]
-Thu Dec 7 17:35:51 2000 Shugo Maeda <shugo@ruby-lang.org>
+Wed Oct 20 04:17:55 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (stack_length): don't use __builtin_frame_address() on alpha.
+ * ext/dbm/dbm.c (fdbm_delete_if): should check if deleting element
+ is a string. [ruby-dev:24490]
-Wed Dec 6 18:07:13 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * ext/sdbm/init.c (fsdbm_delete_if): ditto.
- * djgpp/config.sed, win32/Makefile.sub: typo.
+Wed Oct 20 01:37:18 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_mod_define_method): avoid VC4.0 warnings.
+ * array.c (rb_ary_times): Array#* should return an instance of
+ the class of right operand. [ruby-dev:24526]
-Wed Dec 6 13:38:08 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/zlib/zlib.c (zstream_detach_buffer): should not expose
+ class-less object to Ruby world. [ruby-dev:24530]
- * array.c (rb_ary_and): tuning, make hash from shorter operand.
+ * eval.c (proc_dup): provide Proc#dup as well. [ruby-talk:116915]
-Wed Dec 6 01:28:50 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+ * eval.c (ruby_exec): stack marking position may be higher than
+ expected. thanks to Guy Decoux. [ruby-core:03527]
- * gc.c (rb_gc): __builtin_frame_address() should not be used on
- MacOS X.
+Tue Oct 19 22:43:12 2004 Dave Thomas <dave@pragprog.com>
- * gc.c (Init_stack): ditto.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_attr): If
+ we come across 'attr' in a context where it isn't
+ followed by a symbol, just issue a warning.
-Mon Dec 4 13:44:01 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+Tue Oct 19 20:41:37 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * lib/jcode.rb: consider multibyte. not /n.
+ * ext/win32ole.c(ole_invoke): retrieve the result value when
+ retrying the IDispatch::invoke.
-Mon Dec 4 09:49:36 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Oct 19 17:24:11 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (rb_str_inspect): output whole string contents. no more `...'
+ * io.c (read_all): block string buffer modification during
+ rb_io_fread() by freezing it temporarily. [ruby-dev:24479]
- * string.c (rb_str_dump): should propagate taintness.
+ * dir.c (rb_push_glob): block call at once the end of method.
+ [ruby-dev:24487]
- * hash.c (env_inspect): hash like human readable output.
+ * ext/enumerator/enumerator.c (enum_each_slice): remove
+ rb_gc_force_recycle() to prevent potential SEGV.
+ [ruby-dev:24499]
- * variable.c (rb_ivar_get): prohibiting instance variable access
- is too much restriction.
+ * ext/zlib/zlib.c (zstream_expand_buffer): hide internal string
+ buffer by clearing klass. [ruby-dev:24510]
- * class.c (method_list): retrieving information should not be
- restricted where $SAFE=4.
+Tue Oct 19 16:12:18 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * class.c (rb_obj_singleton_methods): ditto.
+ * ext/tk/tkutil.c: backport from CVS HEAD
- * eval.c (rb_thread_priority): ditto.
+Tue Oct 19 08:54:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_thread_local_aref): ditto.
+ * intern.h, object.c (rb_class_inherited_p): export.
- * variable.c (rb_obj_instance_variables): ditto.
+Tue Oct 19 08:46:57 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * variable.c (rb_mod_const_at): ditto.
+ * string.c (rb_str_upto): method result must be checked. [ruby-dev:24504]
- * variable.c (rb_mod_class_variables): ditto.
+ * eval.c (error_print): ditto. [ruby-dev:24519]
- * eval.c (rb_exec_end_proc): end_proc should be preserved.
+Mon Oct 18 23:37:05 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 2 22:32:43 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * marshal.c (r_object0): check inheritance by the internal function.
+ [ruby-dev:24515]
- * eval.c (rb_yield_0): || should accept exactly zero argument.
+Mon Oct 18 15:58:01 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * parse.y (stmt): multiple right hand side for single assignment
- (e.g. a = 1,2) is allowed.
+ * range.c (range_step, range_each): need cast.
-Wed Nov 29 07:55:29 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Oct 18 07:26:21 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * marshal.c (w_long): dumping long should be smaller than 32bit max.
+ * file.c (rb_file_truncate): discard read buffer before truncation.
+ [ruby-dev:24197]
- * marshal.c (w_long): shorter long format for small integers(-123..122).
+Mon Oct 18 02:11:21 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * marshal.c (r_long): ditto.
+ * lib/webrick/config.rb (WEBrick::Config::General): add default values:
+ - WEBrick::Config[:DoNotReverseLookup]
+ - WEBrick::Config[:RequestCallback] (it used as an alias of
+ :RequestHandler in WEBrick::HTTPServer#run)
+ - WEBrick::Config::FileHandler[:AcceptableLanguages]
-Tue Nov 28 18:10:51 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/webrick/httpservlet/filehandler.rb
+ (WEBrick::HTTPServlet::FileHandler#set_filename): search files
+ having suffix of language-name which Accept-Language header field
+ includes if :AcceptableLanguages options is present.
- * eval.c (rb_mod_define_method): quick hack to implement
- on-the-fly method definition. experimental.
+ * lib/webrick/httpservlet/filehandler.rb
+ (WEBrick::HTTPServlet::FileHandler#get_servlet): new method to
+ search servlet correspond to the suffix of filename.
-Mon Nov 27 17:00:35 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/webrick/httprequest.rb: add attributes access methods: accept,
+ accept_charset, accept_encoding, accept_language, content_length
+ and content_type.
- * eval.c (rb_eval): should not redefine builtin classes/modules
- from within wrapped load.
+ * lib/webrick/httpresponse.rb: add attribute access methods:
+ content_length, content_length=, content_type and content_type=.
-Mon Nov 27 08:57:33 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.mime_types):
+ use the second suffix to detect media type. (the first suffix
+ may be a language name.)
- * eval.c (call_end_proc): should be isolated from outer block.
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_qvalues):
+ add method to parse Accept header field. it returns an Array of
+ values sorted by the qvalues.
-Mon Nov 27 00:10:08 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Oct 18 02:04:11 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * io.c (rb_io_ctl): call ioctl/fcntl for fptr->f2 too.
+ * lib/webrick/httpserver.rb (WEBrick::HTTPServer#virtual_host): new
+ method to register virtual hosting servers.
- * process.c (rb_f_fork): call rb_thread_atfork() after creating
- child process.
+ * lib/webrick/server.rb (WEBrick::GenericServer#accept): call
+ do_not_reverse_lookup for each socket if :DoNotReverseLookup
+ is set. [ruby-core:02357]
- * eval.c (rb_thread_atfork): kill all other threads immediately,
- then turn the current thread into the main thread.
+Sun Oct 17 23:03:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Nov 25 23:12:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tk/timer.rb: TkTimer#start and restart accept a block
- * eval.c (ruby_run): move calling point of rb_trap_exit after
- cleaning up threads.
+Sun Oct 17 13:05:04 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * eval.c (ruby_finalize): new function to call EXIT trap, END
- procs and GC finalizers.
+ * ext/win32ole/win32ole.c (fole_func_methods): correct argument mismatch.
+ * ext/win32ole/win32ole.c (fole_get_methods): ditto.
+ * ext/win32ole/win32ole.c (fole_put_methods): ditto.
+ * ext/win32ole/tests/testWIN32OLE.rb: add test for WIN32OLE#ole_func_methods
+ WIN32OLE#ole_get_methods, WIN32OLE#ole_put_methods
- * eval.c (rb_exec_end_proc): prevent recursion.
+Sat Oct 16 14:45:28 2004 Kouhei Sutou <kou@cozmixng.org>
- * gc.c (rb_gc_call_finalizer_at_exit): ditto.
+ * lib/rss/0.9.rb (RSS::Rss#to_s): removed garbage.
- * signal.c (rb_trap_exit): ditto. made static.
+Sat Oct 16 13:42:49 2004 Kouhei Sutou <kou@cozmixng.org>
- * process.c (rb_f_fork): should swallow all exceptions from block
- execution.
+ * lib/rss/: untabified.
+ * test/rss/: untabified.
+ * lib/rss/0.9.rb (RSS::Rss#to_s): inent -> indent.
- * process.c (fork_rescue): should call ruby_finalize().
+Sat Oct 16 13:34:56 2004 Kouhei Sutou <kou@cozmixng.org>
- * parse.y (yycompile): rb_gc() removed. I don't remember why I put
- this here. test code?
+ * lib/rss: supported prety print.
+ * test/rss/test_1.0.rb: added test for calculating default indent size.
-Fri Nov 24 22:03:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Oct 15 18:04:35 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * range.c (EXCL): exclusive infomation is now stored in an
- instance variable. this enables proper marshal dump.
+ * ext/tk/lib/tk/timer.rb: TkTimer.new(interval, loop){ ... } is
+ acceptable. Add TkTimer.start ( == new + start ).
- * process.c (proc_waitpid): should clear rb_last_status ($?) if
- no pid was given by waitpid(2).
+Fri Oct 15 12:43:09 2004 Tanaka Akira <akr@m17n.org>
-Thu Nov 23 01:35:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * eval.c (Init_stack): make prototype declaration consistent with
+ the definition in gc.c.
- * process.c (proc_waitpid2): returns nil if no pid found.
+Thu Oct 14 14:34:01 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Wed Nov 22 23:45:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * io.c (MODE_BINMODE, MODE_BINARY): fixed reversed condition.
- * range.c (range_eq): new method. Compares start and end of range
- respectively.
+Thu Oct 14 13:33:59 2004 Kouhei Sutou <kou@cozmixng.org>
-Wed Nov 22 11:01:32 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/rss.rb: added link to Tutorial.
- * variable.c (rb_mod_class_variables): should honor singleton
- class variable rule defined yesterday.
+Mon Oct 11 13:48:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Nov 21 23:24:14 2000 Mitsuteru S Nakao <nakao@kuicr.kyoto-u.ac.jp>
+ * ext/tk/lib/tk/*: untabify
- * numeric.c (flodivmod): missing second operand (typo).
+Sun Oct 10 12:32:08 2004 Dave Thomas <dave@pragprog.com>
-Tue Nov 21 03:39:41 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::parse_require): Allow 'require'
+ to be used as a variable name
- * marshal.c (marshal_load): marshal format compatibility check
- revised. greater minor revision is UPWARD compatibile;
- downward compatibility is not assured.
+Sat Oct 9 21:23:37 2004 Kouhei Sutou <kou@cozmixng.org>
- * eval.c (is_defined): clarify class variable behavior for
- singleton classes. class variables within singleton class
- should be treated like within singleton method.
+ * lib/rss/converter.rb: changed to try to use Iconv for default
+ conversion.
-Mon Nov 20 13:45:21 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rss/rss.rb: 0.0.9 -> 0.1.0.
- * eval.c (rb_eval): set ruby_sourceline before evaluating
- exceptions.
+Sat Oct 9 19:50:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * gc.c (gc_sweep): defer finalization in GC during compilation or
- interrupt prohibit section.
+ * io.c (rb_io_getline): should not treat char as negative value.
+ [ruby-dev:24460]
- * gc.c (gc_sweep): mark all nodes before sweeping if GC happened
- during compilation.
+Fri Oct 8 09:49:32 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_eval): should treat class variables specially in a
- method defined in the singleton class.
+ * pack.c (pack_pack): pointer modification check before each
+ iteration. [ruby-dev:24445]
-Mon Nov 20 10:20:21 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+Fri Oct 8 01:13:05 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * dir.c, win32/win32.c, ruby.h: add rb_iglob().
+ * ext/tk/lib/tk/optiondb.rb: make it more secure
-Mon Nov 20 00:18:16 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Oct 7 23:47:57 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * array.c (rb_ary_subseq): should return nil for outbound start
- index.
+ * ext/tk/lib/tk/scrollbar.rb: When 'set' operation, a scrollbar
+ cannot propagate view port information from the source widget
+ (that calls 'set') to other assigned widgets.
- * marshal.c (marshal_load): show format versions explicitly when
- format version mismatch happens.
+Thu Oct 7 17:36:25 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sun Nov 19 06:13:24 2000 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+ * ext/tk/lib/tk.rb: When CHILDKILLED and so on, Tk.errorCode returns
+ a Fixnum for 2nd element (it's pid) of the return value.
- * marshal.c: use long for string/array length.
+Thu Oct 7 12:55:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * pack.c (swaps): use bit-or(|) instead of plus(+).
+ * io.c (io_read): should freeze buffer before thread context
+ switch. [ruby-dev:24442]
- * pack.c (swapl): ditto.
+ * pack.c (pack_unpack): string conversion should at the top of the
+Mon Oct 18 00:42:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Nov 18 15:18:16 2000 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+ * ext/socket/socket.c (sock_s_getservbyaname): protocol string
+ might be altered. [ruby-dev:24503]
- * array.c (rb_ary_replace): array size should be in long.
+ * string.c (rb_str_upto): check if return value from succ is a
+ string. [ruby-dev:24504]
- * array.c (rb_ary_concat): ditto.
+ method. [ruby-dev:24439]
- * array.c (rb_ary_hash): ditto.
+ * io.c (io_read): buffer should be frozen only after the length
+ check. [ruby-dev:24440]
-Sat Nov 18 14:07:20 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Thu Oct 7 02:56:43 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/http.rb: Socket#readline() reads until "\n", not "\r\n"
+ * ext/stringio/stringio.c: use FMODE_APPEND.
-Fri Nov 17 14:55:18 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+Thu Oct 7 01:05:33 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * string.c (rb_str_succ): output should be NUL terminated.
+ * ext/tk/lib/tk.rb: add Tk.errorInfo and Tk.errorCode
-Fri Nov 17 02:54:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Oct 7 00:08:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_io_close): need not to flush before closing.
+ * io.c (rb_io_s_sysopen): preserve path in the buffer allocated by
+ ALLOCA_N() to prevent modification. [ruby-dev:24438]
- * eval.c (rb_thread_join): should preserve last thread status when
- THREAD_TO_KILL.
+Wed Oct 6 09:21:00 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_thread_stop): ditto.
+ * io.c (rb_io_mode_flags): preserve append mode flag.
+ [ruby-dev:24436]
- * io.c (io_fflush): wrap fflush by TRAP_BEG, TRAP_END.
+ * io.c (rb_io_modenum_mode): do not use external output buffer.
- * eval.c (rb_eval): method defined within singleton class
- definition should behave like singleton method about class
- variables.
+ * string.c (rb_str_justify): differ pointer retrieval to prevent
+ padding string modification. [ruby-dev:24434]
- * eval.c (is_defined): ditto.
+ * range.c (range_each_func): allow func to terminate loop by
+ returning RANGE_EACH_BREAK.
-Thu Nov 16 23:06:07 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * range.c (member_i): use RANGE_EACH_BREAK. [ruby-talk:114959]
- * lib/net/http.rb: can call {old,new}_implementation any times.
+Mon Oct 4 14:04:14 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/http.rb: HTTP#connecting, receive ->
- common_oper, connecting.
+ * io.c (rb_file_open_internal, rb_io_reopen): fname might be altered
+ while GC. [ruby-dev:24408]
- * lib/net/http.rb: output warning if u_header includes
- duplicated header.
+Mon Oct 4 12:53:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/net/http.rb: not check Connection:/Proxy-Connection;
- always read until eof.
+ * ext/tk/lib/tk/optiondb.rb: support definition of command
+ resources on widgets
- * lib/net/protocol.rb: detects and catches "break" from block.
+ * ext/tk/lib/tk/image.rb: bug fix
-Thu Nov 16 16:32:45 2000 Masahiro Tanaka <masa@stars.gsfc.nasa.gov>
+Sun Oct 3 21:20:03 2004 Shugo Maeda <shugo@ruby-lang.org>
- * bignum.c (bigdivrem): should have incremented ny first.
+ * lib/net/imap.rb (TEXT_REGEXP): allow 8-bit characters for the german
+ version of Microsoft Exchange Server. (backported from HEAD)
-Thu Nov 16 14:58:00 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * lib/net/imap.rb (RTEXT_REGEXP): ditto.
- * ext/socket/socket.c (sock_new): duplicates file descriptor
- with myfddup() on mswin32/mingw32.
+ * lib/net/imap.rb (CTEXT_REGEXP): ditto.
- * win32/win32.h: uses system original fdopen().
+Sat Oct 2 20:34:22 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/win32.c (myfddup): newly added instead of myfdopen().
+ * node.h (NEW_DVAR): extra semicolon.
- * win32/win32.c (mybind, myconnect, mygetsockname, mygetsockopt,
- mylisten, mysetsockopt): now accept file descriptor only, not
- SOCKET.
+Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * win32/win32.c (myaccept, mysocket): return file descriptor,
- instead of SOCKET.
+ * marshal.c (r_byte): retrieve pointer from string value for each
+ time. [ruby-dev:24404]
-Thu Nov 16 10:23:24 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * marshal.c (r_bytes0): ditto.
- * eval.c (massign): too strict check for nameless rest argument.
+ * enum.c (sort_by_i): re-entrance check added. [ruby-dev:24399]
- * eval.c (method_arity): mere * should return -1.
+ * io.c (io_read): should freeze all reading buffer.
+ [ruby-dev:24400]
- * eval.c (intersect_fds): should check all FDs in the fd_set.
+ * string.c (rb_str_sum): should use bignums when bits is greater
+ than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395]
-Wed Nov 15 19:33:20 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * eval.c (specific_eval): defer pointer retrieval to prevent
+ unsafe sourcefile string modification. [ruby-dev:24382]
- * eval.c (rb_attr): should clear method cache before calling hook.
+ * eval.c (specific_eval): defer pointer retrieval to prevent
+ unsafe sourcefile string modification. [ruby-dev:24382]
- * eval.c (rb_eval): ditto.
+ * string.c (rb_str_sum): wrong cast caused wrong result.
+ [ruby-dev:24385]
- * eval.c (rb_mod_modfunc): ditto.
+ * enum.c (enum_sort_by): hide temporary array from
+ ObjectSpace.each_object. [ruby-dev:24386]
-Mon Nov 13 22:44:52 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * string.c (rb_str_sum): check was done with false pointer.
+ [ruby-dev:24383]
- * error.c (rb_bug): print version to stderr.
+ * string.c (rb_str_sum): string may be altered. [ruby-dev:24381]
+Mon Oct 11 17:51:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Nov 13 19:02:08 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * io.c (rb_io_popen): get mode string via rb_io_flags_mode() to
+ avoid mode string modification. [ruby-dev:24454]
- * win32/win32.c, io.c, process.c: the exit status of program must be
- multiplied 256 on mswin32 and msdosdjgpp(system(), ``).
+ * io.c (rb_io_getline_fast): should take delim as unsigned char to
+ distinguish EOF and '\377'. [ruby-dev:24460]
-Sat Nov 11 22:57:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * io.c (rb_io_getline): add check for RS modification.
+ [ruby-dev:24461]
- * parse.y (arg): uniformed treatment of -a**b, where a is a
- number literal; hacky but behavior appears more consistent.
+ * enum.c (enum_sort_by): use qsort() directly instead using
+ rb_iterate(). [ruby-dev:24462]
- * parse.y (newline_node): reduce newline node (one per line).
+ * enum.c (enum_each_with_index): remove rb_gc_force_recycle() to
+ prevent access to recycled object (via continuation for
+ example). [ruby-dev:24463]
- * random.c (rb_f_srand): should be prohibited in safe level
- greater than 4.
-Sat Nov 11 22:37:36 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+Fri Oct 1 11:40:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * rubysig.h: do not use rb_trap_immediate on win32.
+ * eval.c (rb_f_eval): defer pointer retrieval to prevent unsafe
+ sourcefile string modification. [ruby-dev:24373]
- * rubysig.h: new macros, ATOMIC_TEST, ATOMIC_SET, ATOMIC_INC,
- ATOMIC_DEC, RUBY_CRITICAL and new definition of TRAP_BEG,
- TRAP_END.
+ * io.c (io_read): block string buffer modification during
+ rb_io_fread() by freezing it temporarily. [ruby-dev:24366]
- * gc.c (ruby_xmalloc): should wrap malloc() by RUBY_CRITICAL.
+ * io.c (rb_io_s_popen): mode argument may be altered.
+ [ruby-dev:24375]
- * signal.c (sighandle): better win32 sig handling.
+ * file.c (rb_file_s_basename): ext argument may be altered.
+ [ruby-dev:24377]
- * win32/win32.c (flock): better implementation.
+ * enum.c (enum_sort_by): use NODE instead of 2 element arrays.
+ [ruby-dev:24378]
- * win32/win32.c (myselect): ditto.
+ * string.c (rb_str_chomp_bang): StringValue() may change the
+ receiver. [ruby-dev:24371]
- * win32/win32.c (myaccept): ditto.
+Fri Oct 1 11:25:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * win32/win32.c (waitpid): ditto.
+ * ext/tk/lib/tk/grid.rb: revive TkGrid.grid
- * win32/win32.c (myrename): ditto.
+ * ext/tk/lib/tk/pack.rb: revive TkPack.pack
- * win32/win32.c (wait_events): support function for win32 signal
- handling.
+ * ext/tk/lib/tk/place.rb: revive TkPlace.place
-Sat Nov 11 08:34:18 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Thu Sep 30 00:50:44 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.31.
+Sat Oct 9 00:25:39 2004 Tanaka Akira <akr@m17n.org>
- * lib/net/http.rb: initializes header in HTTP, not HTTPCommand.
+ * io.c (rb_io_fread): rb_thread_wait_fd() was lost.
+ [ruby-dev:24457]
- * lib/net/protocol.rb, http.rb: rewrites proxy code.
+ * ext/tcltklib/tcltklib.c (ip_init): bug fix
-Fri Nov 10 16:15:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/tkutil.c (get_eval_string_core): accept a Regexp object
- * numeric.c (rb_num2long): use to_int, not to_i.
+ * ext/tk/lib/multi-tk.rb: fix bug on 'exit' operation
- * error.c: T_SYMBOL was misplaced by T_UNDEF.
+ * ext/tk/lib/tk/text.rb: 'tksearch' accepts a Regexp object as a
+ matting pattern argument
- * parse.y (yylex): eval("^") caused infinite loop.
+Wed Sep 29 10:58:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Nov 9 14:22:13 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * enum.c (sort_by_i): internally used object must not be changed
+ outside. [ruby-dev:24368]
- * io.c (rb_io_taint_check): should check IO taintness; no
- operation for untainted IO should be allowed in the sandbox.
+Mon Sep 27 13:46:45 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * rubyio.h (GetOpenFile): check IO taintness inside using
- rb_io_taint_check().
+ * intern.h, struct.c (rb_struct_s_members, rb_struct_members): public
+ accessors. [ruby-dev:24342]
-Wed Nov 8 03:08:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * marshal.c (w_object, r_object0): use accessors.
- * io.c (io_fflush): ensure fflush(3) would not block by calling
- rb_thread_fd_writable().
+Mon Sep 27 09:14:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Nov 7 20:29:56 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/socket/socket.c (s_accept): don't retry for EWOULDBLOCK.
+ [ruby-talk:113807]
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.30.
+Fri Sep 24 16:09:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/protocol.rb, smtp.rb: Command#critical_ok -> error_ok
+ * eval.c (proc_invoke): propagate DVAR_DONT_RECYCLE on termination
+ to avoid double call to rb_gc_force_recycle(). [ruby-dev:24311]
- * lib/net/http.rb: reads header when also "100 Continue".
+Fri Sep 24 08:29:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Nov 7 04:32:19 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (rb_ary_subseq): original object might be modified after
+ sharing data creation. [ruby-dev:24327]
- * bignum.c (bigdivrem): use bit shift to make y's MSB set.
+ * array.c (rb_ary_replace): ditto.
-Mon Nov 6 1:22:49 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (ary_make_shared): freeze shared array. [ruby-dev:24325]
- * error.c (warn_print): do not use err_append(), to ensure output
- to stderr.
+ * struct.c (struct_members): always check struct size and size of
+ members list in the class. [ruby-dev:24320]
- * error.c (rb_warn): use warn_print() instead of err_print().
+Thu Sep 23 09:29:14 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * error.c (rb_warning): ditto.
+ * string.c (rb_str_sub_bang): check if string is not modified
+ during iteration. [ruby-dev:24315]
- * error.c (rb_bug): ditto.
+ * hash.c (rb_hash_rehash): replace st_foreach() by its deep
+ checking counterpart. [ruby-dev:24310]
- * eval.c (rb_load): re-raise exceptions during load.
+Wed Sep 22 13:38:12 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * time.c (make_time_t): remove useless adjust
+ * hash.c (rb_hash_rehash): add iteration check. [ruby-dev:24301]
-Thu Nov 2 18:01:16 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * st.c (st_foreach): add deep check.
- * random.c (rb_f_rand): half-baked float support fixed. This fix
- was originally proposed by K.Kosako <kosako@sofnec.co.jp>.
+Wed Sep 22 13:06:14 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Tue Oct 31 17:27:17 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * win32/win32.c (rb_w32_call_handler): workaround for Ctrl-C.
+ merge from HEAD.
- * bignum.c: change digit size to `long|int' if long long is
- available.
+Wed Sep 22 00:11:12 2004 Dave Thomas <dave@pragprog.com>
- * marshal.c (w_object): support `long|int' digits.
+ * process.c: Add documentation for fork()
- * marshal.c (r_object): ditto.
+Wed Sep 22 09:04:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Oct 28 23:54:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (rb_ary_collect_bang): element size might change during
+ comparison. [ruby-dev:24300]
- * parse.y (yylex): allow =end at the end of file (without a
- newline at the end).
+ * array.c (rb_ary_reject_bang): ditto. [ruby-dev:24300]
-Fri Oct 27 10:00:27 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (rb_ary_eql): ditto. [ruby-dev:24300]
- * bignum.c (rb_cstr2inum): should ignore trailing white spaces.
+Tue Sep 21 18:29:49 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bignum.c (rb_str2inum): string may not have sentinel NUL.
+ * array.c (rb_ary_equal): merge miss.
-Fri Oct 27 02:37:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (rb_ary_uniq_bang): element size might change during
+ comparison. [ruby-dev:24298]
- * bignum.c (rb_cstr2inum): wrongly assigned base to c before
- badcheck check.
+Mon Sep 20 00:24:19 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Oct 26 02:42:50 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * enum.c (enum_sort_by): do not use qsort directly. use
+ rb_ary_sort_bang() instead. [ruby-dev:24291]
- * lib/net/protocol.rb: Command#critical_ok
+ * enum.c (enum_sort_by): pedantic type check added.
+ [ruby-dev:24291]
- * lib/net/smtp.rb: clear critical flag before go to SMTP
+ * hash.c (rb_hash_foreach_iter): check iter_lev after each
+ iteration. [ruby-dev:24289]
-Wed Oct 25 12:30:19 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * array.c (rb_ary_and): element size might change during
+ comparison. [ruby-dev:24290]
- * array.c (rb_ary_concat): replacing array might be the receiver
- itself. do not call rb_ary_push_m.
+ * array.c (rb_ary_or): ditto. [ruby-dev:24292]
- * array.c (rb_ary_replace): replacing array might be the receiver
- itself. use memmove.
+ * array.c (rb_ary_equal): wrong fix. [ruby-dev:24286]
-Fri Oct 20 07:56:23 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sat Sep 18 15:02:22 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_eval): ARGSPUSH should not modify args array.
+ * array.c (rb_ary_equal): element size might change during
+ comparison. [ruby-dev:24254]
-Thu Oct 19 14:58:17 2000 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * array.c (rb_ary_diff): ditto. [ruby-dev:24274]
- * pack.c (NUM2U32): should use NUM2ULONG().
+ * array.c (rb_ary_select): ditto. [ruby-dev:24278]
-Tue Oct 17 17:30:34 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * array.c (rb_ary_delete): ditto. [ruby-dev:24283]
- * eval.c (error_print): ruby_sourcefile may be NULL.
+ * array.c (rb_ary_rindex): ditto. [ruby-dev:24275]
-Tue Oct 17 16:36:28 2000 Wes Nakamura <wknaka@pobox.com>
+ * array.c (rb_ary_initialize): element size might change during
+ initializing block. [ruby-dev:24284]
- * pack.c (NATINT_U32): wrong use of sizeof.
+Sat Sep 18 14:10:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Oct 17 12:48:20 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * dir.c (dir_s_chdir): avoid memory leak and unnecessary chdir to
+ the original directory when exception has caused in changing
+ direcotry or within block. thanks to Johan Holmberg
+ <holmberg@iar.se> [ruby-core:03446]
- * eval.c (rb_abort): nil check against ruby_errinfo.
+Fri Sep 17 20:20:27 2004 Minero Aoki <aamine@loveruby.net>
- * eval.c (rb_thread_schedule): use FOREACH_THREAD_FROM instead of
- FOREACH_THREAD, since curr_thread may be removed from thread ring.
+ * lib/fileutils.rb (mkdir_p): backport from CVS HEAD 1.45. [ruby-core:03420]
- * eval.c (THREAD_ALLOC): errinfo should be Qnil.
+Fri Sep 17 17:11:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_callcc): th->prev,th->next are now already
- initialized in THREAD_ALLOC.
+ * array.c (rb_ary_delete): element comparison might change array
+ size. [ruby-dev:24273]
-Mon Oct 16 15:37:33 2000 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+ * file.c (rb_file_truncate): clear stdio buffer before truncating
+ the file. [ruby-dev:24191]
- * eval.c (rb_thread_inspect): tag size was shorter than required.
+ * ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF
+ which might return singleton class. [ruby-dev:24202]
- * object.c (rb_obj_inspect): ditto.
+Fri Sep 17 16:07:09 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon Oct 16 14:25:18 2000 Shugo Maeda <shugo@ruby-lang.org>
+ * ext/tk/lib/multi-tk.rb: improve exit operation
- * object.c (sym_inspect): used `name' before initialization.
+Fri Sep 17 15:01:57 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon Oct 16 14:06:00 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tcltklib/tcltklib.c: fix SEGV when (thread_)vwait or
+ (thread_)tkwait
- * pack.c (pack_pack): use NATINT_U32 for 'l', 'L', and 'N'.
+ * ext/tk/lib/tk.rb: add alias wait_window to wait_destroy
- * pack.c (I32,U32): 32 bit sized integer.
+ * ext/tk/lib/multi-tk.rb: support calling 'mainloop' on slave
+ interpreters (however, the 'real' eventloop must be run on the
+ Default Master IP)
- * pack.c (OFF16,OFF32B): big endian offset for network byteorder.
+ * ext/tk/lib/remote-tk.rb: follow the changes of ext/tk/lib/multi-tk.rb
-Mon Oct 16 06:39:32 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/tk/sample/remote-ip_sample2.rb: ditto
- * lib/net/http.rb: hex-alpha is not [a-h] but [a-f].
+ * ext/tk/sample/tkoptdb-safeTk.rb: ditto
-Mon Oct 16 01:02:02 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Sep 16 18:12:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (rb_thread_start_0): should not abort on exception if
- $SAFE >= 4.
+ * lib/webrick/cgi.rb (WEBrick::CGI#start): should set REMOTE_USER
+ to request.user attribute.
- * parse.y (sym): symbols for class variable names.
+ * lib/webrick/httpservlet/filehandler.rb
+ (WEBrick::HTTPServlet::FileHandler#initialize): should expand
+ the pathname of document root directory.
-Sun Oct 15 01:49:18 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Sep 16 15:49:28 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * file.c (rb_file_flock): should accept interrupt.
+ * string.c (rb_str_intern): protect string argument from GC.
+ [ruby-core:03411]
- * process.c (rb_waitpid): ditto.
+Wed Sep 15 20:22:23 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * process.c (rb_waitpid): ditto.
+ * ext/tk/sample/tkoptdb-safeTk.rb: fix a bug depend on the changes
+ of MultiTkIp
- * process.c (proc_wait): ditto.
+Tue Sep 14 23:54:11 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * process.c (proc_waitpid2): wrong recursion.
+ * ext/tk/lib/multi-tk.rb: MultiTkIp#eval_string was en-bugged by
+ the previous changes.
-Sat Oct 14 03:32:13 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Sep 14 23:45:44 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (rb_thread_alloc): should not link a new thread in the
- live thread ring before initialization.
+ * lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::TextFormatter.for):
+ Add Eric Hodel's simpleformatter.
-Fri Oct 13 17:08:09 2000 Shugo Maeda <shugo@ruby-lang.org>
+Tue Sep 14 16:59:37 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/net/imap.rb: new file.
+ * ext/tcltklib/tcltklib.c: fix SEGV
-Thu Oct 12 18:56:28 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/tk/lib/multi-tk.rb: improve safe-level handling of argument proc
- * lib/net/pop.rb: POP3#reset
+ * ext/tk/sample/multi-ip_sample.rb: rename of old 'safe-tk.rb'
- * lib/net/http.rb: a code for "Switch Protocol" was wrongly 100.
+ * ext/tk/sample/safe-tk.rb: new sample script
-Thu Oct 12 01:23:38 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+Tue Sep 14 00:15:15 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * lib/cgi.rb: bug fix: CGI::html(): PRETTY option didn't work.
+ * ext/zlib/zlib.c: backported from HEAD.
-Thu Oct 12 00:03:02 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Sep 13 19:16:33 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * object.c (sym_inspect): should adjust string length.
+ * eval.c (blk_copy_prev): need frame_dup(). [ruby-dev:24103]
- * struct.c (rb_struct_to_s): ditto.
+Mon Sep 13 16:23:27 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * struct.c (rb_struct_inspect): ditto.
+ * ext/tk/lib/multi-tk.rb: MultiTkIp.new_master and new_slave accept
+ safe-level value argument
-Wed Oct 11 22:15:47 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Mon Sep 13 10:20:45 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (rb_thread_inspect): should adjust string length.
+ * object.c (nil_inspect): fix typo.
- * object.c (rb_any_to_s): ditto.
+Mon Sep 13 01:03:02 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * object.c (rb_obj_inspect): ditto.
+ * ext/tcltklib/tcltklib.c: improve control of preserv/release tcltkip
-Wed Oct 11 18:13:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tcltklib/tcltklib.c: store original 'exit' command
- * eval.c (rb_thread_start_0): should check insecure exit.
+ * ext/tk/tkutil.c: fix(?) SEGV
-Wed Oct 11 14:29:51 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Sun Sep 12 23:46:23 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * lib/net/protocol.rb: 2nd arg for ProtocolError#initialize is
- optional.
+ * util.c (ruby_strdup): remove unnecessary code. (xmalloc never
+ returns NULL.)
- * lib/net/http.rb: code refining.
+ * util.c (ruby_getcwd): fix memory leak on failure.
-Wed Oct 11 11:13:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Sep 12 02:41:58 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * parse.y (primary): setter method (e.g. foo=) should always be
- public.
+ * ext/tcltklib/tcltklib.c: add TclTkIp#allow_ruby_exit? and
+ allow_ruby_exit=
- * eval.c (rb_thread_raise): should not raise SecurityError if
- exception raised by the interpreter.
- * eval.c (rb_thread_cleanup): skip all THREAD_KILLED threads
- before FOREACH_THREAD.
+ * ext/tk/lib/multi-tk.rb: ditto.
-Tue Oct 10 16:11:54 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * ext/tk/lib/remote-tk.rb: ditto.
- * dln.c (dln_load): remove unused code for cygwin.
+ * ext/tcltklib/MANUAL.euc: ditto.
-Tue Oct 10 09:49:23 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tcltklib/MANUAL.eng: ditto.
- * file.c (Init_File): FileTest.size should return 0 (not nil) for
- empty files.
+ * ext/tcltklib/tcltklib.c: fix some reasons of SEGV
-Sun Oct 8 13:20:26 2000 Guy Decoux <decoux@moulon.inra.fr>
+ * ext/tk/tkutil.c: ditto.
- * eval.c (POP_SCOPE): not just set SCOPE_DONT_RECYCLE, but do
- scope_dup().
+ * ext/tk/lib/multi-tk.rb: ditto.
-Sat Oct 7 15:10:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tk/timer.rb: ditto.
- * string.c (rb_str_reverse_bang): unnecessary ALLOCA_N() was
- removed.
+Sat Sep 11 16:09:46 2004 Dave Thomas <dave@pragprog.com>
-Fri Oct 6 14:50:24 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * lib/rdoc/parsers/parse_rb.rb: Fix up cross-file class merging.
- * ext/extmk.rb.in, lib/mkmf.rb: remove "DESTDIR =".
+Fri Sep 10 20:20:53 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * Makefile.in, win32/Makefile.sub, ruby.1: renamed -X to -C.
+ * ext/tcltklib/tcltklib.c (lib_merge_tklist): fix suspicious
+ pointer conversion.
-Fri Oct 6 12:50:52 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Sep 10 02:43:54 2004 Dave Thomas <dave@pragprog.com>
- * array.c (rb_ary_plus): use to_ary(), not Check_Type().
+ * lib/rdoc/generators/template/kilmer.rb: James Buck's
+ patch for call-seq.
- * array.c (rb_ary_concat): ditto.
+Thu Sep 9 13:58:56 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * gc.c (rb_gc): use __builtin_frame_address() for gcc.
+ * ext/tcltklib/tcltklib.c (ip_init): change flag value for setting
+ 'argv' and 'argv0' variable
- * eval.c (stack_length): ditto.
+ * ext/tk/lib/remote-tk.rb: follow changes of multi-tk.rb
- * parse.y (assign_in_cond): stop warning till some better warning
- condition will be found.
+Thu Sep 9 11:46:18 2004 Dave Thomas <dave@pragprog.com>
-Thu Oct 5 18:02:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_classes): Allow
+ spaces aroun parameter to define_method_under (James Buck)
- * object.c (rb_obj_dup): should have propagated taint flag.
- (ruby-bugs:#PR64,65)
+Wed Sep 8 18:44:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Oct 4 00:26:11 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/stringio/stringio.c (strio_write): zero fill a gap if exsts.
+ [ruby-dev:24190]
- * eval.c (proc_arity): proc{|a|}'s arity should be -1.
+Wed Sep 8 15:19:49 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon Oct 2 05:28:58 2000 akira yamada <akira@ruby-lang.org>
+ * ext/tcltklib/tcltklib.c (ip_init): cannot create a IP at level 4
- * string.c (trnext): minus at the end of pattern.
+ * ext/tk/lib/multi-tk.rb: improve 'exit' operation, security check,
+ and error treatment
-Sun Oct 1 00:43:34 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * ext/tk/lib/multi-tk.rb: allow a trusted slave IP to create slave IPs
- * configure.in: exp-name was wrong on cygwin and mingw32.
+ * ext/tk/lib/tk/listbox.rb: add TkListbox#value, value=, clear, and
+ erase
-Thu Sep 28 14:57:09 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tk/text.rb: add TkText#clear and erase
- * regex.c (re_compile_pattern): should try must_string calculation
- every time.
+Mon Sep 6 11:08:50 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Tue Sep 19 23:47:44 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+ * ext/tk/lib/tk/menu.rb(TkOptionMenubutton#insert): call correct method
- * configure.in, config.guess, config.sub: MacOS X support.
+Mon Sep 6 11:00:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Sep 27 18:40:05 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * dir.c (dir_s_chdir): the patch to shut up false warning when
+ exception occurred within a block. a patch was given from Johan
+ Holmberg <holmberg@iar.se>. [ruby-core:03292]
- * stable version 1.6.1 released.
+Mon Sep 6 07:51:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Sep 27 16:13:05 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+ * eval.c (cvar_cbase): singletons should refer outer cvar scope.
+ [ruby-dev:24223]
- * mkconfig.rb: variables should be expanded only if /\$\{?\w+\}?/.
+ * eval.c (rb_load): should preserve previous ruby_wrapper value.
+ [ruby-dev:24226]
-Tue Sep 26 18:09:51 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+Sat Sep 4 01:14:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c: include <math.h>
+ * eval.c (cvar_cbase): class variables cause SEGV in
+ instance_eval() for fixnums and symbols. [ruby-dev:24213]
-Tue Sep 26 15:59:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Sep 3 17:47:58 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * object.c (rb_mod_dup): metaclasses of class/module should not be
- cleared by rb_obj_dup.
+ * struct.c (make_struct): remove redefining constant when
+ conflict. [ruby-dev:24210]
-Tue Sep 26 02:44:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Sep 3 11:31:44 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * gc.c (GC_MALLOC_LIMIT): size extended.
+ * ext/tk/lib/tk.rb: Tk.after makes TkCore::INTERP.tk_cmd_tbl grow
+ [ruby-dev:24207]
- * regex.c (DOUBLE_STACK): use machine's stack region for regex
- stack if its size is small enough.
+Fri Sep 3 02:12:48 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon Sep 25 18:13:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tcltklib/tcltklib.c: fix typo [ruby-talk:111266]
- * regex.c: include <defines.h>.
+ * ext/tk/lib/tk/text.rb: fix typo
- * eval.c (rb_add_method): cache mismatch by method
- definition. need to clear_cache_by_id every time.
+ * ext/tk/lib/multi-tk.rb: improve safe-level treatment on slave IPs
-Mon Sep 25 13:31:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Fri Sep 3 01:54:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/win32.c (NtCmdGlob): substitute '\\' with '/'.
+ * ext/extmk.rb: already built-in libraries satisfy dependencies.
+ [ruby-dev:24028]
-Mon Sep 25 00:35:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Thu Sep 2 11:36:20 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * defines.h: #undef HAVE_SETITIMER on cygwin.
+ * eval.c (rb_obj_instance_eval): backported from HEAD.
-Sun Sep 24 03:01:53 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Wed Sep 1 21:18:25 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * lib/net/protocol.rb, http.rb: typo.
+ * ext/tk/lib/tk/spinbox.rb: fix typo
-Sat Sep 23 07:33:20 2000 Aleksi Niemela <aleksi.niemela@cinnober.com>
+Tue Aug 31 18:24:04 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * regex.c (re_compile_pattern): nicer regexp error messages for
- invalid patterns.
+ * ext/tk/tkutil.c (cbsubst_init): fix memory leak
-Sat Sep 23 03:06:25 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/tkutil.c (cbsubst_get_all_subst_keys): fix SEGV
- * variable.c (rb_autoload_load): should not require already
- provided features.
+Tue Aug 31 16:04:22 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Fri Sep 22 15:46:21 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/tcltklib/tcltklib.c (ip_delete): when a tcltkip is deleted,
+ destroy its root widget
- * lib/net/http.rb: too early parameter expansion in string.
+Tue Aug 31 12:30:36 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Fri Sep 22 13:58:51 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * ext/tcltklib/tcltklib.c (del_root): fix SEGV
- * ext/extmk.rb.in: don't use default $:
+Mon Aug 30 23:11:06 2004 Dave Thomas <dave@pragprog.com>
-Fri Sep 22 13:42:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/rdoc/ri/ri_driver.rb (and others): ri now merges documentation
+ if it finds the same class in multiple places.
- * regex.c (PUSH_FAILURE_COUNT): avoid casting warning on alpha.
+Mon Aug 30 22:40:30 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * regex.c (PUSH_FAILURE_POINT): ditto.
+ * ext/tk/lib/multi-tk.rb: 'restart' method accepts arguments
-Fri Sep 22 10:16:21 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Mon Aug 30 21:50:14 2004 Dave Thomas <dave@pragprog.com>
- * win32/config.h.in: add HAVE_TELLDIR, HAVE_SEEKDIR
+ * object.c: Add RDoc for Module.included.
-Thu Sep 21 19:04:34 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Mon Aug 30 15:10:46 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/extmk.rb, lib/mkmf.rb (install_rb): check whether libdir is
- directory or not.
+ * configure.in (GNU/k*BSD): fixed FTBFS on GNU/k*BSD. [ruby-dev:24051]
-Thu Sep 21 17:23:05 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Mon Aug 30 11:29:35 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * file.c (rb_file_s_symlink): use HAVE_SYMLINK.
+ * win32/win32.c (CreateChild): strip trailing spaces. [ruby-dev:24143]
+ merge from HEAD.
- * file.c (rb_file_s_readlink): use HAVE_READLINK.
+Sun Aug 29 14:08:56 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * dir.c (dir_tell): use HAVE_TELLDIR.
+ * ext/tcltklib/tcltklib.c: compile error on bcc32 [ruby-dev:24081]
- * dir.c (dir_seek): use HAVE_SEEKDIR.
+ * ext/tk/lib/multi-tk.rb: MultiTkIp#eval_string does not work
- * configure.in (AC_CHECK_FUNCS): lstat, symlink, readlink,
- telldir, seekdir checks added.
+Sat Aug 28 23:04:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * file.c (lstat): should use stat(2) if lstat(2) is not
- available.
+ * bignum.c (rb_big_and): protect parameters from GC.
+ [ruby-talk:110664]
-Thu Sep 21 15:59:23 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Thu Aug 26 04:38:29 2004 Dave Thomas <dave@pragprog.com>
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.29.
+ * eval.c (return_jump): Minor typo in error message. Now reads
+ "return can't jump across threads".
- * lib/net/http.rb: HTTPReadAdapter -> HTTPResponseReceiver
+Tue Aug 24 17:30:00 2004 Shugo Maeda <shugo@ruby-lang.org>
- * lib/net/http.rb (connecting): response is got in receive()
+ * lib/cgi/session.rb (CGI::Session::FileStore#initialize): do not
+ use a session id as a filename. (backported from HEAD)
-Thu Sep 21 15:49:07 2000 Wayne Scott <wscott@ichips.intel.com>
+ * lib/cgi/session/pstore.rb (CGI::Session::PStore#initialize): ditto.
- * lib/find.rb (find): should not follow symbolic links;
- tuned performance too.
+ * lib/cgi/session/pstore.rb (CGI::Session::PStore#initialize): use
+ Dir::tmpdir. (backported from HEAD)
-Wed Sep 20 23:21:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Aug 24 14:40:16 2004 Shugo Maeda <shugo@ruby-lang.org>
- * ruby.c (load_file): two Ctrl-D was required to stop ruby at the
- beginning of stdin script read.
+ * lib/cgi/session.rb (CGI::Session::FileStore#initialize): untaint
+ session id after check. (backported from HEAD)
-Wed Sep 20 14:01:45 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Aug 24 09:09:01 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (rb_provided): detect infinite load loop.
+ * ext/openssl/ossl_x509attr.c (ossl_x509attr_initialize): d2i
+ functions may replace the pointer indicated by the first argument.
- * eval.c (rb_provided): too weak filename comparison.
+ * ext/openssl/ossl_x509ext.c (ossl_x509ext_initialize): ditto.
- * eval.c (rb_thread_alloc): avoid recycling still referenced
- dvar structures.
+ * ext/openssl/ossl_x509name.c (ossl_x509name_initialize): ditto.
- * eval.c (rb_callcc): ditto.
+Mon Aug 23 14:04:51 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (THREAD_ALLOC): fiil dyna_vars field by ruby_dyna_vars.
+ * ext/openssl/ossl_ssl.c (ossl_ssl_read):
+ - should return an empty string if specified length to read is 0.
+ - should check for pending data and wait for fd before reading.
+ - call underlying IO's sysread if SSL session is not started.
+ [ruby-dev:24072], [ruby-dev:24075]
-Tue Sep 19 17:47:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/openssl/ossl_ssl.c (ossl_ssl_write):
+ - call underlying IO's syswrite if SSL session is not started.
- * stable version 1.6.0 released.
+ * ext/openssl/ossl_ssl.c (ossl_ssl_pending): new method
+ OpenSSL::SSL#pending.
-Tue Sep 19 16:24:52 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/openssl/lib/openssl/buffering.rb: should not use select.
- * marshal.c (Init_marshal): provide marshal.so no more.
+Mon Aug 23 12:40:56 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Tue Sep 19 14:01:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/resolv.rb (Config.default_config_hash): when multiple domains
+ are set, Win32::Resolv.get_resolv_info returns Array.
- * configure.in, win32/setup.mak: include version number
- in RUBY_SO_NAME.
+Sun Aug 22 01:15:31 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Tue Sep 19 13:07:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/webrick/httpproxy.rb (WEBrick::HTTPProxyServer#proxy_connect):
+ should call :ProxyContentHandler before finishing CONNECT.
- * parse.y (yylex): was confusing $~ and $_.
+Sat Aug 21 06:41:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Sep 19 13:06:53 2000 GOTOU YUUZOU <gotoyuzo@notwork.org>
+ * ext/tcltklib/extconf.rb (find_tcl, find_tk): find stub library.
- * signal.c (rb_f_kill): signum may be a negative number, should be
- treated by signed number.
+ * lib/mkmf.rb (arg_config, with_config): deal with '-' and '_'
+ uniformly. [ruby-dev:24118]
-Tue Sep 19 01:14:56 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Aug 19 16:29:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * eval.c (rb_provide): better feature handling.
+ * ext/tk/lib/tk.rb: Fail to treat a hash value of 'font' option.
- * eval.c (rb_f_require): loading ruby library may be partial
- state. checks in rb_thread_loading is integrated.
+ * ext/tk/lib/tk.rb: bindinfo cannot return '%' substiturion infomation.
- * eval.c (rb_provided): better thread awareness.
+ * ext/tk/lib/menu.rb: typo bug.
- * lib/irb/frame.rb: 6 (not 5) parameters for trace_func proc.
+Thu Aug 19 15:15:24 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (error_print): should print error position even if
- get_backtrace() failed.
+ * dir.c (free_dir): fix memory leak. reported by yamamoto
+ madoka.
-Sat Sep 16 03:29:59 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Aug 20 11:00:00 2004 Akiyoshi, Masamichi <masamichi.akiyoshi@hp.com>
- * eval.c (rb_f_require): rb_provided() was called too early; does
- not work well with threads.
+ * dln.c (dln_load): Modify to call lib$find_image_symbol for VMS.
+ * io.c (rb_io_fwrite): Use fputc() for VMS non-stream file.
- * parse.y (ensure): should distinguish empty ensure and non
- existing ensure.
+Thu Aug 19 06:07:45 2004 why the lucky stiff <why@ruby-lang.org>
- * file.c (Init_File): extending File by class of FileTest was
- serious mistake.
+ * ext/syck/token.c: re2c no longer compiled with bit vectors. caused
+ problems for non-ascii characters. [ruby-core:03280]
+ * ext/syck/implicit.c: ditto.
+ * ext/syck/bytecode.c: ditto.
-Thu Sep 14 02:46:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/yaml/baseemitter.rb: folding now handles double-quoted strings,
+ fixed problem with extra line feeds at end of folding, whitespace
+ opening scalar blocks.
- * eval.c (rb_thread_yield): array strip should be done in this
- function.
+ * lib/yaml/rubytypes.rb: subtelties in handling strings with
+ non-printable characters and odd whitespace patterns.
-Wed Sep 13 17:01:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Aug 18 23:41:33 2004 Minero Aoki <aamine@loveruby.net>
- * bignum.c (rb_big_eq): incomplete value comparison of bignums.
+ * lib/net/protocol.rb (rbuf_fill): OpenSSL::SSL::SSLSocket has its own
+ buffer, select(2) might not work. [ruby-dev:24072]
-Wed Sep 13 06:39:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Aug 18 17:10:12 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * variable.c (rb_mod_class_variables): Module#class_variables added.
+ * ext/tcltklib/stubs.c (ruby_tcltk_stubs): need to call
+ Tcl_FindExecutable() for Tcl/Tk 8.4.
-Wed Sep 13 06:09:26 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+Wed Aug 18 12:52:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/cgi.rb: bug fix: CGI::header(): output status header.
+ * eval.c (rb_obj_instance_eval): evaluates under special singleton
+ classes as for special constants.
-Wed Sep 13 01:09:12 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Aug 17 17:20:59 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (yylex): allow global variables like '$__a'.
+ * io.c (rb_io_reopen): should clear allocated OpenFile. pointed
+ out by Guy Decoux. [ruby-core:03288]
-Tue Sep 12 22:28:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Tue Aug 17 01:36:32 2004 Dave Thomas <dave@pragprog.com>
- * ext/socket/extconf.rb: avoid using terrible <netinet/tcp.h>
- on cygwin 1.1.5.
+ * lib/rdoc/usage.rb: Remove extra indent. Tidy 'ri' option
+ parsing so RDoc::usage plays better with OptionParser.
-Tue Sep 12 16:01:58 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Sat Aug 14 13:09:10 2004 Minero Aoki <aamine@loveruby.net>
- * array.c (rb_ary_unshift_m): typo.
+ * lib/fileutils.rb: backport from CVS HEAD (rev1.44).
-Tue Sep 12 15:37:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/fileutils.rb: cp_r should copy symlink itself, except cp_r
+ root.
- * eval.c (rb_yield_0): stripped array too much, should remove just
- for proc_call().
+ * lib/fileutils.rb: new option mv :force.
-Tue Sep 12 07:05:24 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+ * lib/fileutils.rb: new module FileUtils::DryRun.
- * lib/cgi.rb: version 2.0.0: require ruby1.5.4 or later.
+Sat Aug 14 02:48:16 2004 Dave Thomas <dave@pragprog.com>
- * lib/net/telnet.rb: version 1.6.0
+ * lib/rdoc/usage.rb: Added. Allows command line programs
+ to report usage using their initial RDoc comment.
-Tue Sep 12 03:26:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Aug 13 13:23:17 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (massign): use to_ary to get an array if available.
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_range_header):
+ fix regex for range-spec.
- * object.c (rb_Array): ditto.
+ * lib/webrick/httpservlet/filehandler.rb
+ (WEBrick::HTTPServlet::DefaultFileHandler#make_partial_content):
+ multipart/byteranges response was broken.
-Mon Sep 11 14:24:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/webrick/httpservlet/erbhandler.rb
+ (WEBrick::HTTPServlet::ERBHandler#do_GET): should select media type
+ by suffix of script filename.
- * hash.c (ruby_setenv): should not free the element of
- origenvironment.
+ * lib/xmlrpc/server.rb: refine example code.
- * parse.y (command_call): kYIELD moved to this rule to allow
- 'a = yield b'. (ruby-bugs-ja:#PR15)
+Wed Aug 11 17:17:50 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Mon Sep 11 01:27:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * configure.in (RPATHFLAG): stop setting RPATHFLAG on Interix.
- * eval.c (rb_yield_0): proc#call([]) should pass single value to
- the block.
+Sun Aug 8 00:43:31 2004 why the lucky stiff <why@ruby-lang.org>
- * eval.c (callargs): reduce array allocation.
+ * lib/implicit.c: added sexagecimal float#base60.
- * eval.c (massign): precise check for argument number.
+ * ext/syck/rubyext.c (yaml_org_handler): ditto.
-Fri Sep 8 10:05:17 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/token.c: indentation absolutely ignored when processing flow
+ collections. plain scalars are trimmed if indentation follows in
+ an ambiguous flow collection.
- * gc.c (STR_NO_ORIG): should be FL_USER2.
+Sat Aug 7 00:50:01 2004 Tanaka Akira <akr@m17n.org>
-Thu Sep 7 14:17:51 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/zlib/zlib.c: Zlib::GzipReader#read(0) returns "" instead of nil.
- * string.c (rb_str_cat): should work even for concatenating same
- string.
-
-Wed Sep 6 17:06:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Tue Aug 3 13:49:20 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * variable.c (rb_cvar_declare): should check superclass's class
- variable first.
+ * ext/tk/lib/tk/namespace.rb: bug fix
-Wed Sep 6 10:42:02 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/lib/tkextlib/treectrl/tktreectrl.rb: add Tk::TreeCtrl.loupe
- * misc/ruby-mode.el (ruby-calculate-indent): shift continuing line
- if previous line ends with modifier keyword.
+Mon Aug 2 18:04:21 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * misc/ruby-mode.el (ruby-parse-region): should not give up if
- modifiers are at the end of line.
+ * ext/tk/lib/tk/msgcat.rb (set_translation): bug fix (fail to set
+ trans_str to the same as src_str when trans_str is not given.)
- * misc/ruby-mode.el (ruby-expr-beg): indented wrongly if modified
- statement was size 1.
+Mon Aug 2 11:53:06 2004 Dave Thomas <dave@pragprog.com>
-Wed Sep 6 10:41:19 2000 Kenichi Komiya <kom@mail1.accsnet.ne.jp>
+ * lib/rdoc/code_objects.rb (RDoc::Context::find_symbol): Fix infinite recursion
+ looking up some top level symbols (batsman)
- * misc/ruby-mode.el (ruby-parse-region): modifier was not handled
- well on emacs19.
+Mon Aug 2 11:48:29 2004 Dave Thomas <dave@pragprog.com>
-Tue Sep 5 17:10:12 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_methods): Allow '.'s in
+ variable names to support SWIG generated files (Hans Fugal)
- * time.c (time_to_s): fixed zone string UTC for utc time object.
+Sat Jul 31 17:40:16 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Sep 5 00:26:06 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * misc/ruby-mode.el (ruby-expr-beg, ruby-parse-partial,
+ ruby-calculate-indent, ruby-move-to-block, ruby-forward-sexp,
+ ruby-backward-sexp): keywords must match word-wise.
- * regex.c (re_search): range worked wrongly on bm_search().
+Sat Jul 31 05:47:37 2004 why the lucky stiff <why@ruby-lang.org>
-Mon Sep 4 13:40:40 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/yaml.rb (YAML::load_file, YAML::parse_file): added.
- * configure.in: renamed libruby.a to libruby.{cygwin,mingw32}.a
- on cygwin and mingw32.
+ * lib/yaml/rubytypes.rb: exceptions were using an older
+ YAML.object_maker. [ruby-core:03080]
-Sun Sep 3 23:44:04 2000 Noriaki Harada <tenmei@maoh.office.ne.jp>
+ * ext/syck/token.c (sycklex_yaml_utf8): using newline_len to
+ handline CR-LFs. "\000" was showing up on folded blocks which
+ stopped at EOF.
- * io.c (NO_SAFE_RENAME): for BeOS too.
+ * ext/syck/token.c: re2c compiled with bit vectors now.
+ * ext/syck/implicit.c: ditto.
+ * ext/syck/bytecode.c: ditto.
-Sun Sep 3 11:31:53 2000 Takaaki Tateishi <ttate@jaist.ac.jp>
+Fri Jul 30 16:10:54 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * parse.y (rescue): no assignment was done if rescue body was
- empty.
+ * ext/tcltklib/tcltklib.c (lib_fromUTF8_core): raise ArgumentError when
+ the unknown encoding name is given.
-Sat Sep 2 10:52:21 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (call_args,aref_args): block_call can be the last
- argument.
+ * ext/tcltklib/tcltklib.c (lib_toUTF8_core): ditto.
- * parse.y (COND_PUSH,COND_POP): maintain condition stack to allow
- kDO2 in parentheses in while/until/for conditions.
+ * ext/tk/lib/tk.rb (Tk::Encoding.encoding_convertfrom): bug fix.
- * parse.y (yylex): generate kDO2 for EXPR_ARG outside of
- while/until/for condition.
+ * ext/tk/lib/tk.rb (Tk::Encoding.encoding_convertto): ditto.
-Fri Sep 1 10:36:29 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Jul 28 18:59:17 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (aref_args,opt_call_args): add block_call to allow a
- method without parentheses and with block as a last argument.
+ * lib/cgi.rb (CGI::initialize): remove at_exit code for CGI_PARAMS
+ and CGI_COOKIES. they will no longer be used.
- * hash.c (rb_hash_sort): should not return nil.
+Wed Jul 28 01:04:44 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * re.c (match_aref): should use rb_reg_nth_match().
+ * gc.c (run_final): wrong order of data. [ruby-dev:23984]
- * eval.c (POP_SCOPE): recycled scopes too much
+Tue Jul 27 07:05:04 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (Init_eval): extend room for stack allowance.
-
- * eval.c (POP_SCOPE): frees scope too much.
-
-Thu Aug 31 14:28:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * gc.c (rb_gc_mark): T_SCOPE condition must be more precise.
-
- * eval.c (scope_dup): should not make all duped scope orphan.
-
-Thu Aug 31 10:11:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (stmt): allow stmt_rhs to be right hand side of multiple
+ * eval.c (rb_eval): copy on write for argument local variable
assignment.
- * time.c (rb_time_timeval): type error should not mention the word
- 'interval'.
-
-Wed Aug 30 23:21:20 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * numeric.c (rb_num2long): use rb_Integer() instead of independent
- convert routine.
+ * eval.c (assign): ditto.
- * eval.c (rb_rescue2): now takes arbitrary number of exception types.
+ * eval.c (rb_call0): update ruby_frame->argv with the default
+ value used for the optional arguments.
- * object.c (rb_convert_type): use rb_rescue2 now to handle NameError.
+ * object.c (Init_Object): "===" calls rb_obj_equal() directly.
+ [ruby-list:39937]
- * object.c (rb_convert_type): better error message.
+Mon Jul 26 11:22:55 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Wed Aug 30 17:09:14 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/webrick/httputils.rb (WEBrick::HTTPUtils.escape): should
+ escape space.
- * ext/Win32API/Win32API.c (Win32API_initialize): AlphaNT support.
+Sun Jul 25 11:05:21 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Wed Aug 30 14:19:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * win32/win32.{h,c} (rb_w32_{f,fd,fs}open): workaround for bcc32's
+ {f,fd,fs}open bug. set errno EMFILE and EBADF. [ruby-dev:23963]
- * parse.y (node_assign): should support NODE_CVASGN2 too.
+Sat Jul 24 13:32:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Aug 30 11:31:47 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * range.c (rb_range_beg_len): returns Qnil only when "beg" points
+ outside of a range. No boundary check for "end".
- * ext/Win32API/Win32API.c (Win32API_initialize): add the
- arguments checking.
+Fri Jul 23 16:40:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/Win32API/Win32API.c (Win32API_initialize): add taint
- checking. allow String object in the third argument.
+ * gc.c (define_final): should not disclose NODE* to Ruby world.
+ [ruby-dev:23957]
-Wed Aug 30 10:29:40 2000 Masahiro Tomita <tommy@tmtm.org>
+Fri Jul 23 09:03:16 2004 Shugo Maeda <shugo@ruby-lang.org>
- * io.c (rb_f_p): flush output buffer.
+ * lib/net/imap.rb (disconnected?): new method. (backported from HEAD)
-Tue Aug 29 16:29:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jul 22 16:41:54 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (assignable): remove NODE_CVASGN3.
+ * lib/cgi/session.rb (CGI::Session::FileStore#update): sets the
+ permission of the session data file to 0600.
- * parse.y (gettable): remove NODE_CVAR3.
+ * lib/cgi/session/pstore.rb (CGI::Session::Pstore#initialize):
+ ditto.
-Tue Aug 29 02:02:14 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Thu Jul 22 00:02:21 2004 Masahiro Kitajima <katonbo@katontech.com>
- * lib/mkmf.rb (create_makefile): handles create_makefile("a/b").
+ * process.c (rb_f_system): not need to call last_status_set() any
+ longer on _WIN32.
- * ext/extmk.rb.in (create_makefile): ditto
+Tue Jul 20 09:15:17 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Mon Aug 28 18:43:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * test/fileutils/test_fileutils.rb: File.link raises EINVAL on BeOS.
- * eval.c (is_defined): now handles class variables.
+Mon Jul 19 01:15:07 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (rb_eval): class variable behavior revisited.
+ * lib/webrick/httpservlet/cgihandler.rb
+ (WEBrick::HTTPServlet::CGIhandler#do_GET): set SystemRoot environment
+ variable to CGI process on Windows native platforms. [ruby-dev:23936]
- * parse.y (assignable): ditto.
+ * lib/webrick/httpservlet/cgihandler.rb
+ (WEBrick::HTTPServlet::CGIhandler#do_GET): use $?.exitstatus and
+ refine log message.
- * parse.y (gettable): ditto.
+Sun Jul 18 16:14:29 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * regex.c (PUSH_FAILURE_COUNT): push/pop interval count on failure
- stack. this fix is inspired by the Emacs21 patch from Stefan
- Monnier <monnier@cs.yale.edu>.
+ * ext/tk/lib/tk/msgcat.rb (TkMsgCatalog.callback): bug fix
+ ( wrong number of argument )
-Fri Aug 25 15:24:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jul 18 08:13:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * variable.c (rb_cvar_get): should not follow __attached__.
+ * sprintf.c (rb_f_sprintf): remove extra sign digit.
- * variable.c (rb_cvar_set): ditto.
+Sun Jul 18 03:21:42 2004 Akinori MUSHA <knu@iDaemons.org>
- * variable.c (rb_cvar_declare): ditto.
+ * dir.c (range): use NULL instead of 0.
- * variable.c (mod_av_set): second class variable assignment at the
- toplevel should not give warning.
+ * dir.c (range): get rid of a gcc 3.4 warning.
-Fri Aug 25 01:18:36 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Sun Jul 18 03:12:11 2004 Shugo Maeda <shugo@ruby-lang.org>
- * io.c (next_argv): prepare path for open file.
+ * lib/net/imap.rb (receive_responses): return if a LOGOUT response
+ received. (backported from HEAD)
+ * lib/net/imap.rb (send_string_data): wait command continuation
+ requests before sending octet data of literals. (backported from HEAD)
- * string.c (rb_str_setter): moved from io.c.
+Sat Jul 17 23:54:59 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * io.c (next_argv): filename should be "-" for refreshed ARGF.
+ * ext/tk/lib/tk/variable.rb: TkVariable#ref returns a TkVariable object
-Thu Aug 24 15:27:39 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Sat Jul 17 22:04:44 2004 akira yamada <akira@ruby-lang.org>
- * ext/socket/socketport.h: use `extern int h_errno' if needed.
+ * lib/uri/ldap.rb: method hierarchical? should be in URI::LDAP.
-Sat Aug 19 01:34:02 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Sat Jul 17 18:29:07 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/sdbm/_sdbm.c (sdbm_prep): flags should be or-ed by O_BINARY on
- Win32 too.
+ * parse.y (stmt): not to show same error messages twice.
- * ext/sdbm/_sdbm.c (makroom): fill hole with 0 on Win32 too.
+Sat Jul 17 13:13:32 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Aug 18 13:23:59 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/irb/ruby-lex.rb (RubyLex::identify_string): %s string do not
+ process expression interpolation. [ruby-talk:106691]
- * eval.c (rb_eval): should preserve and clear $! value before
- compilation.
+Sat Jul 17 05:26:27 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (eval): ditto.
+ * lib/rdoc/diagram.rb: Incorporate Micheal Neuman's
+ client-side imagemao patch
-Fri Aug 18 11:06:19 2000 Shugo Maeda <shugo@ruby-lang.org>
+Sat Jul 17 01:57:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/socket/socket.c (s_accept): start GC on EMFILE/ENFILE.
+ * eval.c (THREAD_ALLOC): th->thread should be initialized to NULL.
+ [ruby-talk:106657] The solution was found by Guy Decoux.
-Thu Aug 17 16:04:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Fri Jul 16 22:30:28 2004 Michael Neumann <mneumann@ntecs.de>
- * eval.c (is_defined): should clear ruby_errinfo.
+ * file.c (rb_stat_dev_major): new methods File::Stat#dev_major and
+ #dev_minor. [ruby-core:03195]
-Thu Aug 17 04:26:31 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Fri Jul 16 15:23:53 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.27.
+ * eval.c (return_jump, break_jump): raise unexpceted local jump
+ exception directly. [ruby-dev:23740]
- * lib/net/protocol.rb: writing methods returns written byte size.
+ * lib/base64.rb (Deprecated): super in bound method calls original
+ name method in stable version. [ruby-dev:23916]
- * lib/net/smtp.rb: send_mail accepts many destinations.
+Fri Jul 16 11:31:49 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Wed Aug 16 00:43:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/test/unit/ui/{fox,gtk,gtk2}/testrunner.rb: remove
+ garbage (patch from akira yamada) [ruby-dev:23911]
- * time.c (time_s_times): use CLK_TCK for HZ if it's defined.
+Fri Jul 16 11:20:00 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Tue Aug 15 17:30:59 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * sprintf.c (rb_f_sprintf): fix output of NaN, Inf and -Inf with
+ "%f" or etc on MSVCRT platforms. (backported from HEAD)
- * eval.c (frame_dup): should set flag FRAME_MALLOC after
- argv allocation.
+Fri Jul 16 11:17:38 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (blk_free): should not free argv if GC was called before
- frame_dup.
+ * error.c (exit_initialize): use EXIT_SUCCESS instead of 0.
+ [ruby-dev:23913]
-Tue Aug 15 16:08:40 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * error.c (exit_success_p): new method SystemExit#success?.
+ [ruby-dev:23912]
- * configure.in: add ac_cv_func_times=yes for mingw32.
+ * error.c (syserr_initialize): initialization for subclasses.
+ [ruby-dev:23912]
- * win32/win32.c (mytimes): typo.
+Thu Jul 15 23:53:38 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Aug 15 01:45:28 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * lib/optparse.rb (OptionParser#warn, OptionParser#abort): Exception
+ no longer has to_str method.
- * io.c (argf_eof): should return true at the end of ARGF without
- checking stdout if arguments are given.
+Thu Jul 15 22:59:48 2004 Shugo Maeda <shugo@ruby-lang.org>
-Mon Aug 14 10:34:32 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/readline/extconf.rb: added dir_config for curses, ncurses,
+ termcap. (backported from HEAD)
- * eval.c (rb_thread_status): status should return false for normal
- termination, nil for termination by exception.
+Thu Jul 15 20:29:15 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Fri Aug 11 15:43:46 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * class.c, error.c, eval.c, intern.h, object.c, variable.c:
+ do not set path if it is a singleton class. [ruby-dev:22588]
+ (backport from 1.9)
- * eval.c (rb_undef): give warning for undefining __id__, __send__.
+Thu Jul 15 10:15:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Thu Aug 10 08:05:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/, ext/tcltklib/: bug fix
- * eval.c (rb_callcc): returned current thread instead of
- continuation wrongly.
+ * ext/tk/lib/tk.rb: better operation for SIGINT when processing
+ callbacks.
+ * ext/tk/lib/tk/msgcat.rb: ditto.
+ * ext/tk/lib/tk/variable.rb: ditto.
+ * ext/tk/lib/tk/timer.rb: ditto.
-Thu Aug 10 05:40:28 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * ext/tk/lib/tk/validation.rb: add Tk::ValidateConfigure.__def_validcmd
+ to define validatecommand methods easier
- * ext/extmk.rb.in: $CPPFLAGS should be initialized.
+ * ext/tk/lib/tk.rb (_genobj_for_tkwidget): support autoload Tk ext
+ classes
- * ext/tcltklib/depend: add stubs.o.
+ * ext/tk/lib/tk/canvas.rb and so on: remove the parent widget type
+ check for items (e.g. canvas items; depends on the class) to
+ avoid some troubles on Tk extension widget class definition.
- * ext/tcltklib/extconf.rb: use $CPPFLAGS instead of $CFLAGS.
+ * ext/tk/lib/tkextlib/: add Iwidget and TkTable extension support
-Wed Aug 9 16:31:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * ext/tk/sample/tkextlib/: add samples of Iwidget and TkTable
- * eval.c (rb_callcc): thread status for continuations must be
- THREAD_KILLED, otherwise thread_free() breaks other threads.
-Wed Aug 9 13:24:25 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Wed Jul 14 18:08:37 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * win32/win32.[ch]: emulate rename(2).
+ * ext/openssl/ossl_asn1.c (ossl_asn1cons_to_der): fix type of
+ argument. [ruby-dev:23891]
-Tue Aug 8 14:01:46 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * test/openssl/test_x509store.rb: prune tests for CRL checking
+ unless X509::V_FLAG_CRL_CHECK is defined.
- * ext/tcltklib/tcltklib.c: support --enable-tcltk_stubs
+Wed Jul 14 12:29:07 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/tcltklib/extconf.rb: ditto.
+ * util.c (ruby_strtod): should not convert string in the form of
+ "-I.FE-X" which both "I" and "F" are ommitted. [ruby-dev:23883]
- * ext/tcltklib/stubs.c: created. examine candidate shared libraries.
+ * test/ruby/test_float.rb (test_strtod): add test for bug fix.
-Mon Aug 7 13:59:12 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Jul 14 01:18:45 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ruby.h (CLONESETUP): should copy flags before any potential
- object allocation.
+ * array.c: rdoc patch - unified margin.
- * regex.c (re_match): check for stack depth was needed.
+Wed Jul 14 00:31:15 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Sat Aug 5 16:43:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * array.c: rdoc patch. merged patch from Johan Holmberg
+ <holmberg@iar.se> [ruby-core:3170]
- * djgpp/*: convert DOS line endings to UNIX style.
+Tue Jul 13 19:39:12 2004 akira yamada <akira@ruby-lang.org>
- * djgpp/config.status: rename to config.sed for SFN.
+ * lib/uri/generic.rb (URI::Generic#merge_path):
+ "URI('http://www.example.com/foo/..') + './'" should return
+ "URI('http://www.example.com/')". [ruby-list:39838]
+ "URI('http://www.example.com/') + './foo/bar/..'" should return
+ "URI('http://www.example.com/foo/')". [ruby-list:39844]
- * lib/ftools.rb (compare, safe_unlink, chmod): avoid warnings.
+ * test/uri/test_generic.rb (TestGeneric#test_merge): added tests.
- * lib/ftools.rb (move): typo. not `tpath', but `to'.
+Tue Jul 13 15:51:45 2004 Akinori MUSHA <knu@iDaemons.org>
-Fri Aug 4 23:26:48 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (init_mkmf): Do not add $(libdir) to $LIBPATH in
+ extmk mode.
- * eval.c (proc_call): gives warning if a block is supplied.
+ * lib/mkmf.rb (dir_config): Prepend a new library path instead of
+ appending so it is tried first.
- * eval.c (rb_eval): no warning for discarding if an alias for the
- method is already made.
+Tue Jul 13 00:50:48 2004 Dave Thomas <dave@pragprog.com>
-Fri Aug 4 16:32:29 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/parsers/parse_rb.rb: Support call-seq: for Ruby files.
- * array.c (rb_ary_reject_bang): returns nil if no element removed.
+Mon Jul 12 21:20:36 2004 Dave Thomas <dave@pragprog.com>
- * hash.c (rb_hash_reject_bang): returns nil if no element removed.
+ * html_generator.rb: Support hyperlinks of the form {any text}[xxx]
+ as well as stuff[xxx]
-Thu Aug 3 19:44:26 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Jul 10 09:30:24 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * eval.c (rb_thread_fd_writable): should return integer value.
+ * test/soap/marshal/test_struct.rb: use qualified build-tin class name
+ (::Struct) to avoid name crash.
- * array.c (rb_ary_assoc): search array element whose length is
- longer than 0 (not 1).
+Sat Jul 10 04:21:56 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Wed Aug 2 18:27:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tk.rb: better operation for SIGINT when processing
+ callbacks.
+ * ext/tk/lib/tk/msgcat.rb: ditto.
+ * ext/tk/lib/tk/variable.rb: ditto.
+ * ext/tk/lib/tk/timer.rb: ditto.
- * eval.c (rb_thread_wait_fd): prohibit thread context switch
- during compilation.
+ * ext/tk/lib/tk/validation.rb (__def_validcmd): add a module
+ function of Tk::ValidateConfigure to define validatecommand
+ methods easier
- * eval.c (rb_cont_call): prohibit Continuation#call across threads.
+Fri Jul 9 22:36:36 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Wed Aug 2 08:22:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * array.c, enum.c, pack.c: rdoc patch from Johan Holmberg
+ <holmberg@iar.se> [ruby-core:3132] [ruby-core:3136]
- * gc.c (rb_gc): clear malloc_memories to zero, to avoid potential
- super frequent GC invocation. (ruby-bugs:#PR48)
+ * numeric.c: rdoc patch.
- * gc.c (rb_gc): only add_heap() if GC trigger condition is
- satisfied.
+Fri Jul 9 19:26:39 2004 Tanaka Akira <akr@m17n.org>
-Tue Aug 1 16:41:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/open-uri.rb (URI::HTTPS#proxy_open): raise ArgumentError to
+ notice https is not supported.
- * ruby.c (proc_options): global load path setting moved from
- ruby_prog_init().
+Fri Jul 9 14:28:54 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ruby.c (incpush): renamed. push path entry at the END of the
- load path array. This makes -I directories sorted in order in
- the arguments.
+ * eval.c (rb_thread_raise): accept third argument as well as
+ Kernel#raise, and evaluate the arguments to create an exception in
+ the caller's context. [ruby-talk:105507]
-Sat Jul 29 23:42:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Jul 9 01:47:08 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * dir.c (dir_each): should check whether dir is closed during the
- block execution. (ruby-bugs:#PR47)
+ * ext/tk/lib : bug fix
+ * ext/tk/lib/tkextlib/itcl : add [incr Tcl] support
+ * ext/tk/lib/tkextlib/itk : add [incr Tk] support
+ * ext/tk/lib/tkextlib/iwidgets : midway point of [incr Widgets] support
+ * ext/tk/sample/tkextlib/iwidgets : very simple examples of
+ [incr Widgets]
-Sat Jul 29 21:57:30 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Thu Jul 8 22:52:19 2004 Kouhei Sutou <kou@cozmixng.org>
- * ruby.c (rubylib_mangle): provide another buffer for the result.
+ * lib/rss/{rss,parser,0.9,1.0,2.0}.rb: supported RSS 0.9x/2.0
+ validation and validation which disregard order of elements.
+ * test/rss/test_parser.rb: added tests for RSS 0.9x/2.0
+ validation.
+ * test/rss/{test_trackback,rss-testcase}.rb: fixed no good method
+ name.
-Wed Jul 26 10:09:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Thu Jul 8 00:05:23 2004 akira yamada <akira@ruby-lang.org>
- * configure.in: set SOLIBS to LIBS on Cygwin.
+ * lib/tempfile.rb (Tempfile::initialize): got out code of
+ generating tmpname. [ruby-dev:23832][ruby-dev:23837]
- * configure.in: LIBRUBY_SO='$(RUBY_INSTALL_NAME)'.$target_os.dll
- on cygwin and mingw32. ruby-cygwin.dll is bad. why?
+Wed Jul 7 15:53:14 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Wed Jul 26 10:04:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (rb_str_match): raise TypeError when both arguments are
+ strings. [ruby-dev:22869] (backported from HEAD)
- * gc.c (gc_sweep): avoid full scan during compilation.
+ * string.c (rb_str_match2): removed.
- * gc.c (rb_gc): add heap during no gc period (including
- compilation).
+ * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub,
+ wince/Makefile.sub (string.c): now not depend on version.h.
-Tue Jul 25 19:03:04 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Wed Jul 7 00:48:34 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * cygwin/GNUmakefile: use puts instead of print, because
- Cygwin DLL's behavior is changed(or bug?).
+ * ext/tk/lib/tkextlib/tktrans.rb,
+ ext/tk/lib/tkextlib/treectrl.rb: fix syntax errors.
- * configure.in: LIBRUBY_SO='$(RUBY_INSTALL_NAME)'-$target_os.dll
- on cygwin and mingw32.
+Tue Jul 6 18:38:45 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib : improve framework of developping Tcl/Tk extension
+ wrappers
+
+Mon Jul 5 23:56:42 2004 Kouhei Sutou <kou@cozmixng.org>
+
+ * lib/rss/{trackback,syndication,dublincore,content}.rb: worked
+ with ruby 1.6 again.
+
+ * test/rss/rss-assertions.rb: ditto.
+
+Mon Jul 5 22:54:39 2004 Tanaka Akira <akr@m17n.org>
+
+ * lib/uri/common.rb (Kernel#URI): new global method for parsing URIs.
+
+Mon Jul 5 09:02:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (rb_thread_yield, rb_f_catch): 4th argument to rb_yield_0()
+ is a set of bit flags. [ruby-dev:23859]
+
+Mon Jul 5 01:27:32 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * lib/drb/drb.rb(DRbConn self.open): If socket pool is full, close
+ the socket whose last-access-time is oldest. (and add new one)
+ [ruby-dev:23860]
+
+Sun Jul 4 12:24:50 2004 Kouhei Sutou <kou@cozmixng.org>
+
+ * lib/rss/rss.rb: added copyright header.
+
+Sun Jul 4 00:24:40 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * added files
+ * lib/soap/attachment.rb
+ * lib/soap/header
+ * lib/soap/mimemessage.rb
+ * lib/soap/rpc/httpserver.rb
+ * lib/wsdl/soap/cgiStubCreator.rb
+ * lib/wsdl/soap/classDefCreator.rb
+ * lib/wsdl/soap/classDefCreatorSupport.rb
+ * lib/wsdl/soap/clientSkeltonCreator.rb
+ * lib/wsdl/soap/driverCreator.rb
+ * lib/wsdl/soap/mappingRegistryCreator.rb
+ * lib/wsdl/soap/methodDefCreator.rb
+ * lib/wsdl/soap/servantSkeltonCreator.rb
+ * lib/wsdl/soap/standaloneServerStubCreator.rb
+ * lib/wsdl/xmlSchema/enumeration.rb
+ * lib/wsdl/xmlSchema/simpleRestriction.rb
+ * lib/wsdl/xmlSchema/simpleType.rb
+ * lib/xsd/codegen
+ * lib/xsd/codegen.rb
+ * sample/soap/authheader
+ * sample/soap/raa2.4
+ * sample/soap/ssl
+ * sample/soap/swa
+ * sample/soap/whois.rb
+ * sample/soap/calc/samplehttpd.conf
+ * sample/soap/exchange/samplehttpd.conf
+ * sample/soap/sampleStruct/samplehttpd.conf
+ * sample/wsdl/raa2.4
+ * sample/wsdl/googleSearch/samplehttpd.conf
+ * test/openssl/_test_ssl.rb
+ * test/soap/header
+ * test/soap/ssl
+ * test/soap/struct
+ * test/soap/swa
+ * test/soap/wsdlDriver
+ * test/wsdl/multiplefault.wsdl
+ * test/wsdl/simpletype
+ * test/wsdl/test_multiplefault.rb
+
+ * modified files
+ * lib/soap/baseData.rb
+ * lib/soap/element.rb
+ * lib/soap/generator.rb
+ * lib/soap/marshal.rb
+ * lib/soap/netHttpClient.rb
+ * lib/soap/parser.rb
+ * lib/soap/processor.rb
+ * lib/soap/property.rb
+ * lib/soap/soap.rb
+ * lib/soap/streamHandler.rb
+ * lib/soap/wsdlDriver.rb
+ * lib/soap/encodingstyle/handler.rb
+ * lib/soap/encodingstyle/literalHandler.rb
+ * lib/soap/encodingstyle/soapHandler.rb
+ * lib/soap/mapping/factory.rb
+ * lib/soap/mapping/mapping.rb
+ * lib/soap/mapping/registry.rb
+ * lib/soap/mapping/rubytypeFactory.rb
+ * lib/soap/mapping/wsdlRegistry.rb
+ * lib/soap/rpc/cgistub.rb
+ * lib/soap/rpc/driver.rb
+ * lib/soap/rpc/element.rb
+ * lib/soap/rpc/proxy.rb
+ * lib/soap/rpc/router.rb
+ * lib/soap/rpc/soaplet.rb
+ * lib/soap/rpc/standaloneServer.rb
+ * lib/wsdl/data.rb
+ * lib/wsdl/definitions.rb
+ * lib/wsdl/operation.rb
+ * lib/wsdl/parser.rb
+ * lib/wsdl/soap/definitions.rb
+ * lib/wsdl/xmlSchema/complexContent.rb
+ * lib/wsdl/xmlSchema/complexType.rb
+ * lib/wsdl/xmlSchema/data.rb
+ * lib/wsdl/xmlSchema/parser.rb
+ * lib/wsdl/xmlSchema/schema.rb
+ * lib/xsd/datatypes.rb
+ * lib/xsd/qname.rb
+ * sample/soap/calc/httpd.rb
+ * sample/soap/exchange/httpd.rb
+ * sample/soap/sampleStruct/httpd.rb
+ * sample/soap/sampleStruct/server.rb
+ * sample/wsdl/amazon/AmazonSearch.rb
+ * sample/wsdl/amazon/AmazonSearchDriver.rb
+ * sample/wsdl/googleSearch/httpd.rb
+ * test/soap/test_basetype.rb
+ * test/soap/test_property.rb
+ * test/soap/test_streamhandler.rb
+ * test/soap/calc/test_calc.rb
+ * test/soap/calc/test_calc2.rb
+ * test/soap/calc/test_calc_cgi.rb
+ * test/soap/helloworld/test_helloworld.rb
+ * test/wsdl/test_emptycomplextype.rb
+ * test/wsdl/axisArray/test_axisarray.rb
+ * test/wsdl/datetime/test_datetime.rb
+ * test/wsdl/raa/test_raa.rb
+ * test/xsd/test_xmlschemaparser.rb
+ * test/xsd/test_xsd.rb
+
+ * summary
+ * add SOAP Header mustUnderstand support.
+
+ * add HTTP client SSL configuration and Cookies support (works
+ completely with http-access2).
+
+ * add header handler for handling sending/receiving SOAP Header.
+
+ * map Ruby's anonymous Struct to common SOAP Struct in SOAP Object
+ Model. it caused error.
+
+ * add WSDL simpleType support to restrict lexical value space.
+
+ * add SOAP with Attachment support.
+
+Sat Jul 3 17:19:44 2004 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/tk/lib/tkextlib/tkDND.rb: fix syntax error.
+
+Thu Jul 1 23:15:29 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/pstore.rb (transaction): safer backup scheme. [ruby-list:39102]
+
+ * lib/pstore.rb (commit_new): use FileUtils.copy_stream for Cygwin.
+ [ruby-dev:23157]
+
+ * lib/pstore.rb (transaction): allow overriding dump and load.
+ [ruby-dev:23567]
+
+ * lib/pstore.rb (PStore#transaction): get rid of opening in write mode
+ when read only transaction. [ruby-dev:23842]
+
+ * lib/yaml/store.rb: follow lib/pstore.rb's change.
- * cygwin/GNUmakefile: ditto.
+Thu Jul 1 18:36:08 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * Makefile.in: $(SOLIBS) should be put after dmyext.@OBJEXT@.
+ * ext/tk/lib/tcltklib : bug fix
- * instruby.rb: install $(LIBRUBY) to libdir
- if $(LIBRUBY) != $(LIBRUBY_A_).
+ * ext/tk/lib/tk : bug fix and add Tcl/Tk extension support libraries
-Tue Jul 25 15:16:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Jul 1 11:59:45 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * io.c (rb_p): redirect to $defout.
+ * ext/openssl/extconf.rb: check for EVP_CIPHER_CTX_copy, ENGINE_add,
+ EVP_CIPHER_CTX_set_padding, EVP_CipherFinal_ex, EVP_CipherInit_ex,
+ EVP_DigestFinal_ex and EVP_DigestInit_ex.
-Mon Jul 24 18:52:55 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * ext/openssl/openssl_missing.c (EVP_CIPHER_CTX_copy): new function.
- * win32/win32.c (win32_getenv): should remove `static'.
+ * ext/openssl/openssl_missing.h (EVP_DigestInit_ex, EVP_DigestFinal_ex,
+ EVP_CipherInit_ex, EVP_CipherFinal_ex, HMAC_Init_ex): new macro for
+ OpenSSL 0.9.6.
- * ruby.c (rubylib_mangle): support "/hoge;/foo"
+ * ext/openssl/ossl_cipher.c (ossl_cipher_encrypt, ossl_cipher_decrypt):
+ re-implemnt (the arguments for this method is ).
-Mon Jul 24 10:28:55 2000 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+ * ext/openssl/ossl_cipher.c (ossl_cipher_pkcs5_keyivgen): new method
+ OpenSSL::Cipher::Cipher#pkcs5_keyivgen. it calls EVP_BytesToKey().
- * string.c (rb_str_count): raise exception if no argument is
- given.
+ * ext/openssl/ossl_cipher.c (ossl_cipher_alloc, ossl_cipher_initialize,
+ ossl_cipher_copy, ossl_cipher_reset ossl_cipher_final,
+ ossl_cipher_set_key, ossl_cipher_set_iv): replace all EVP_CipherInit
+ and EVP_CipherFinal into EVP_CipherInit_ex and EVP_CipherFinal_ex.
+ and EVP_CIPHER_CTX_init should only be called once.
-Sun Jul 23 12:55:04 2000 Dave Thomas <Dave@Thomases.com>
+ * ext/openssl/ossl_cipher.c (ossl_cipher_set_key_length): new method
+ OpenSSL::Cipher::Cipher#key_len=.
- * string.c (rb_str_rindex): Support negative end position.
+ * ext/openssl/ossl_cipher.c (ossl_cipher_init_deprecated): new
+ finction; print warning for Cipher#<<.
-Fri Jul 21 17:35:01 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_digest.c: replace all EVP_DigestInit and
+ EVP_DigestFinal into EVP_DigestInit_ex and EVP_DigestFinal_ex.
+ and EVP_MD_CTX_init should only be called once.
- * parse.y (aref_args): command_call now be permitted as
- aref_args.
+ * ext/openssl/ossl_digest.c (digest_final): should call
+ EVP_MD_CTX_cleanup to avoid memory leak.
- * process.c (proc_getpriority): getpriority(2) may return valid
- negative number. use errno to detect error.
+ * ext/openssl/ossl_hmac.c (ossl_hmac_initialize): repalce HMAC_init
+ into HMAC_init_ex. and HMAC_CTX_init is moved to ossl_hmac_alloc.
- * marshal.c (dump_ensure): dumped string should be tainted if
- any among target objects is tainted.
+ * ext/openssl/ossl_hmac.c (hmac_final): should call
+ HMAC_CTX_cleanup to avoid memory leak.
- * marshal.c (r_regist): restored object should be tainted if and
- only if the source is a file or a tainted string.
+ * test/openssl/test_cipher.rb, test/openssl/test_digest.rb,
+ test/openssl/test_hmac.rb: new file.
-Wed Jul 19 15:14:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Jul 1 04:08:30 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * bignum.c (bigdivrem): should use rb_int2big(), not rb_uint2big().
+ * ext/openssl/ossl_asn1.c (ossl_i2d_ASN1_TYPE, ossl_ASN1_TYPE_free):
+ workaround for the versions earlier than OpenSSL-0.9.7.
-Tue Jul 18 14:58:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Jul 1 03:33:55 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (ruby_options): should treat SystemExit etc. properly.
+ * ext/openssl/ossl_pkey_dh.c (ossl_dh_initialize): should create
+ empty pkey object if no argument is passed. [ruby-talk:103328]
- * parse.y (yycompile): should check compile_for_eval, not
- ruby_in_eval.
+ * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_initialize): ditto.
-Mon Jul 17 04:29:50 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_initialize): ditto.
- * lib/mkmf.rb: converts extension of $objs into $OBJEXT.
+ * ext/openssl/ossl_pkey_dh.c: add new methods: OpenSSL::PKey::DH#p,
+ OpenSSL::PKey::DH#p=, OpenSSL::PKey::DH#g, OpenSSL::PKey::DH#g=,
+ OpenSSL::PKey::DH#pub_key, OpenSSL::PKey::DH#pub_key=,
+ OpenSSL::PKey::DH#priv_key and OpenSSL::PKey::DH#priv_key=.
-Sun Jul 16 03:02:34 2000 Dave Thomas <dave@thomases.com>
+ * ext/openssl/ossl_pkey_dsa.c: add new methods: OpenSSL::PKey::DSA#p,
+ OpenSSL::PKey::DSA#p=, OpenSSL::PKey::DSA#q, OpenSSL::PKey::DSA#q=,
+ OpenSSL::PKey::DSA#g, OpenSSL::PKey::DSA#g=,
+ OpenSSL::PKey::DSA#pub_key, OpenSSL::PKey::DSA#pub_key=,
+ OpenSSL::PKey::DSA#priv_key and OpenSSL::PKey::DSA#priv_key=.
- * lib/weakref.rb: Change to use new ObjectSpace calls.
+Thu Jul 1 03:16:09 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Sat Jul 15 21:59:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_ssl.c (ossl_ssl_read): take optional second argument
+ to specify a string to be written.
- * eval.c (rb_eval): should not redefine __id__ nor __send__.
+ * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#read):
+ take optional second argument to specify a string to be written.
- * gc.c (define_final): integrate final.rb features into the
- interpreter. define_finalizer and undefine_finalizer was
- added to ObjectSpace. plus, add_finalizer, remove_finalizer,
- and call_finalizer are deprecated now.
+ * ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#gets):
+ refine regexp for end-of-line.
-Sat Jul 15 01:32:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/opnessl/lib/openssl/ssl.rb
+ (OpenSSL::SSL::SocketForwarder#listen): fix typo.
- * eval.c (rb_mod_method): implements unbound method.
+Wed Jun 30 11:38:51 2004 Mikael Brockman <phubuh@phubuh.org>
- * eval.c (Init_eval): should prohibit `module_function' for class
- Class.
+ * parse.y (primary): should not be NULL. [ruby-core:03098]
-Fri Jul 14 17:19:59 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Wed Jun 30 02:53:24 2004 why the lucky stiff <why@ruby-lang.org>
- * cygwin/GNUmakefile.in: use miniruby instead of sed.
+ * ext/syck/rubyext.c (syck_emitter_new): set buffer after
+ Data_Wrap_Struct to avoid possible GC. [ruby-talk:104835]
-Fri Jul 14 12:49:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Jun 29 10:31:19 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (argf_eof): need to check stdin, when next_p == -1.
+ * eval.c (rb_eval_cmd, rb_thread_trap_eval): restore safe level.
- * io.c (read_all): use io_fread() instead of fread(3).
+ * gc.c (define_final, run_final): preserve and restore safe level for
+ finalizers. [ruby-core:03058]
- * io.c (io_reopen): should clearerr FILE if fd < 3.
+ * signal.c (signal_exec, rb_trap_exit, trap): preserve and restore
+ safe level for signal handlers. [ruby-dev:23829]
- * re.c (rb_reg_match_m): the result is exported, so it should be
- declared as busy.
+Mon Jun 28 14:57:56 2004 Jeff Mitchell <quixoticsycophant@yahoo.com>
- * eval.c (rb_eval): should preserve errinfo even if return, break,
- etc. is called in rescue clause.
+ * configure.in, lib/mkmf.rb (LIBPATHFLAG): use double quotes due to
+ DOSISH compilers. [ruby-core:03107]
- * instruby.rb: install irb too.
+Mon Jun 28 00:30:19 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Wed Jul 12 15:32:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * sample/drb/*.rb: using 'DRb.thread.join' instead of 'gets'
- * variable.c (rb_const_get): constants for builtin classes must
- have higher priority than constants from included modules at
- Object class.
+Sun Jun 27 22:39:51 2004 Kouhei Sutou <kou@cozmixng.org>
- * bignum.c (bigdivrem): small embarrassing typo.
+ * sample/rss/tdiary_plugin/rss-recent.rb: supported Hiki.
-Wed Jul 12 15:06:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Jun 27 12:19:46 2004 Kouhei Sutou <kou@cozmixng.org>
- * eval.c (rb_eval): use rb_const_get_at().
+ * {lib,sample,test}/rss: added RSS Parser. [ruby-dev:23780]
- * variable.c (top_const_get): retrieve toplevel constants only,
- not ones of Object (and its included modules) in general.
+Sat Jun 26 11:07:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jul 12 15:04:11 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * configure.in (aix): -b must come at the start of the command line,
+ and -e must not appear while testing libraries. [ruby-talk:104501]
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.26.
+ * lib/mkmf.rb (dir_config): quote directory names if necessary.
+ [ruby-talk:104505]
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb:
- add module Net::NetPrivate and its inner classes
- {Read,Write}Adapter, Command, Socket,
- SMTPCommand, POP3Command, APOPCommand, HTTPCommand
+Fri Jun 25 15:33:19 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jul 12 13:10:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/iconv/extconf.rb: check stricter. [ruby-talk:104501]
- * bignum.c (bigdivrem): defer bignorm().
+ * ext/iconv/extconf.rb: include iconv.h for libiconv. [ruby-dev:22715]
- * bignum.c (bignorm): accepts accidental fixnums.
+Fri Jun 25 08:31:29 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Jul 11 16:54:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_thread_atfork): remove "fork terminates thread"
+ warning. [ruby-dev:23768]
- * parse.y (yylex): `@<digit>' is no longer a valid instance
- variable name.
+ * object.c (rb_obj_clone): backport FL_FINALIZE patch from 1.9.
+ [ruby-core:02786][ruby-core:03067]
-Tue Jul 11 01:51:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/socket.c (sock_sockaddr): Socket#gethostbyname()
+ should give us packed address, not struct sockaddr.
+ [ruby-core:03053]
- * bignum.c (rb_big_divmod): should not use Integer(float) for
- the right operand.
+Fri Jun 25 02:04:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * bignum.c (rb_big_remainder): ditto.
+ * {bcc32,win32,wince}/setup.mak: remove RUBY_EXTERN lines when
+ including version.h. [ruby-talk:104456] (backported from HEAD)
- * bignum.c (rb_big_modulo): ditto.
+Thu Jun 24 14:23:29 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Jul 10 15:27:16 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * io.c (rb_io_fread): return already read data when system call is
+ interrupted. [ruby-talk:97206]
- * io.c (pipe_finalize): should set rb_last_status when pclose().
+Thu Jun 24 01:32:43 2004 Shugo Maeda <shugo@ruby-lang.org>
-Mon Jul 10 09:07:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * version.h: added declarations of ruby_version,
+ ruby_release_date, ruby_platform.
+ (backported from HEAD)
- * error.c (rb_bug): print version number and such too.
+Wed Jun 23 22:23:37 2004 Dave Thomas <dave@pragprog.com>
-Sat Jul 8 23:08:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/socket.c (sock_s_gethostbyaddr): Work around problem
+ with OS X not returning 'from' parameter to recvfrom for
+ connection-oriented sockets.
- * eval.c (rb_thread_start_0): should copy previous scopes to
- prevent rb_gc_force_recycle().
+Wed Jun 23 01:45:27 2004 Dave Thomas <dave@pragprog.com>
-Fri Jul 7 23:36:36 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/rdoc/parsers/parse_rb.rb (RubyLex::identify_quotation):
+ Fix problem with the 'r' being dropped from %r{xxx}
- * ext/socket/addrinfo.h: move IN_EXPERIMENTAL and IN_LOOPBACKNET
- definitions to ext/socket/sockport.h.
+Wed Jun 23 00:20:20 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * ext/socket/extconf.rb: add getservbyport() and arpa/inet.h check.
+ * ext/win32ole/win32ole.c (ole_hresult2msg): remove trailing
+ CRs and LFs. (doesn't depend on CR+LF) [ruby-dev:23749]
- * ext/socket/getaddrinfo.c (getaddrinfo): SOCK_RAW may not be
- defined (ex. BeOS, Palm OS 2.x or before).
+Wed Jun 23 00:00:25 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/socket/getnameinfo.c (getnameinfo): getservbyport() may not
- exist (ex. BeOS, Palm OS).
+ * io.c (rb_io_initialize): should check fcntl result. [ruby-dev:23742]
- * ext/socket/sockport.h: add IN_EXPERIMENTAL, IN_CLASSA_NSHIFT,
- IN_LOOPBACKNET, AF_UNSPEC, PF_UNSPEC and PF_INET.
+Tue Jun 22 21:11:36 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
-Fri Jul 7 03:30:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/win32ole/win32ole.c (OLE_FREE): should not call CoFreeUnuse-
+ dLibraries().
- * parse.y (aref_args): should allow Hash[:a=>2] etc.
+ * ext/win32ole/win32ole.c (ole_event_free): ditto.
- * numeric.c (fix_aref): convert index by NUM2INT, not FIX2INT.
- (ruby-bugs:#PR37)
+ * ext/win32ole/win32ole.c (ole_hresult2msg): truncate error message
+ before CR.
- * time.c (time_localtime): should prohibit for frozen time.
+Tue Jun 22 16:47:42 2004 Shugo Maeda <shugo@ruby-lang.org>
- * time.c (time_gmtime): ditto.
+ * lib/net/ftp.rb (MDTM_REGEXP): fix for demon's ftp server.
+ Thanks, Rutger Nijlunsing.
-Thu Jul 6 19:12:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Jun 21 10:19:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * io.c (rb_file_s_open): should not terminate fptr; just clear it.
+ * win32/win32.c (rb_w32_opendir): use FindFirstFile()/FindNextFile()/
+ FindClose() instead of _findfirst()/_findnext()/_findclose().
+ merge from HEAD.
- * ruby.c (proc_options): should not call require_libraries()
- twice.
+Sat Jun 19 13:24:15 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ruby.c (require_libraries): clear req_list_head.next after
- execution.
+ * eval.c (method_call): allow changing $SAFE. [ruby-dev:23713]
-Thu Jul 6 13:51:57 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+Fri Jun 18 23:12:22 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * object.c (rb_to_id): name may not be symbol nor fixnum.
+ * eval.c (proc_save_safe_level, rb_set_safe_level, safe_setter): limit
+ safe level.
- * struct.c (rb_struct_s_def): name may be nil.
+Wed Jun 16 23:05:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Jul 6 02:09:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * object.c (rb_mod_freeze): prepare string representation before
+ freezing. [ruby-talk:103646]
- * bignum.c (bigdivrem): new function to return remainder.
+Wed Jun 16 16:04:40 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * numeric.c (fixdivmod): now returns modulo, not remainder.
+ * object.c (rb_mod_le): singleton class inherits Class rather than its
+ object's class. [ruby-dev:23690]
- * numeric.c (flodivmod): ditto.
+Wed Jun 16 16:01:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * bignum.c (bigdivmod): ditto.
+ * gc.c (stack_grow_direction): memoize the direction.
- * numeric.c (num_modulo): new method; alias to '%'.
+ * gc.c (Init_stack): should always move to end of VALUE.
-Thu Jul 6 00:51:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Tue Jun 15 12:10:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * win32/win32.c (NtCmdGlob): patterns should be separated and
- NUL terminated.
+ * ext/tk/lib/tk.rb: bug fix (TkWindow#grab)
-Wed Jul 5 22:27:56 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Mon Jun 14 18:23:27 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * cygwin/GNUmakefile: use ruby.def to make rubycw.dll.
+ * ext/tk/lib/remote-tk.rb: bug fix
- * ext/extmk.rb.in: create target.def.
+Sun Jun 13 00:23:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * lib/mkmf.rb: ditto.
+ * ext/tcltklib/extconf.rb: [EXPERIMENTAL] MacOS X (darwin) support
-Wed Jul 5 09:47:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tcltklib/tcltklib.c: fix thread trouble on callback proc, and
+ eliminate warning about instance variable access
- * time.c (time_arg): Time::local, Time::gm now take 7th optional
- argument for usec.
+ * ext/tk/lib/tk/menubar.rb: improve supported menu_spec
- * numeric.c (num_ceil, etc): default ceil, floor, round, truncate
- implementation for Numeric, using `to_f'.
+ * ext/tk/lib/tk/menuspec.rb: [add] menu_spec support library
- * io.c (rb_io_reopen): clear fptr->path after free() to prevent
- potential GC crash.
+ * ext/tk/lib/tk/root.rb: add menu_spec support
- * io.c (rb_file_s_open): terminate fptr unless null.
+ * ext/tk/lib/tk/text.rb: bug fix
- * io.c (rb_file_initialize): ditto.
+ * ext/tk/lib/tk/toplevel.rb: add menu_spec support
- * lib/tempfile.rb: specify FILE::CREAT|File::EXCL to open for
- better security.
+ * ext/tk/sample/menubar?.rb: [add] sample of menu_spec usage
- * numeric.c (flo_truncate): new method.
+Sat Jun 12 11:15:53 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Wed Jul 5 01:02:53 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * configure.in (target_os): strip -gnu suffix on Linux.
- * ext/extmk.rb.in: join ' ' -> join(' ').
+Fri Jun 11 17:08:21 2004 Akinori MUSHA <knu@iDaemons.org>
- * lib/mkmf.rb: ditto.
+ * config.guess: Restore a wrongly removed hyphen.
-Tue Jul 4 13:51:29 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Jun 11 14:30:08 2004 Akinori MUSHA <knu@iDaemons.org>
- * ext/dbm/dbm.c: add methods added to Hash in 1.5.x.
+ * config.guess: Attempt to avoid system name change on
+ Darwin platforms also.
- * ext/gdbm/gdbm.c: ditto.
+Fri Jun 11 14:22:45 2004 Akinori MUSHA <knu@iDaemons.org>
- * ext/sdbm/init.c: ditto.
+ * config.guess, config.sub: Attempt to avoid system name change on
+ Linux platforms. We have been using "linux" instead of
+ "linux-gnu" on this branch.
- * eval.c (proc_call): args may be Qundef (means no argument), do
- not call TYPE() for args.
+Thu Jun 10 19:19:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Jul 4 13:20:56 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * ext/sdbm/init.c (fsdbm_store): sdbm should use StringValue().
+ [ruby-talk:103062]
- * ext/extmk.rb.in: make command line must be single-quoted.
- $(RUBY_INSTALL_NAME) is command substitution in the POSIX sh.
+Wed Jun 9 18:04:14 2004 akira yamada <akira@ruby-lang.org>
-Tue Jul 4 13:16:02 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/uri/generic.rb (URI::Generic::merge,
+ URI::Generic::route_from): accepts non-hierarchical URI.
+ [ruby-dev:23631]
- * util.c (rb_type): should add T_UNDEF.
+ * test/uri/test_generic.rb (TestGeneric::test_route,
+ TestGeneric::test_merge): added tests for above changes.
-Tue Jul 4 09:30:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Jun 9 17:39:37 2004 Akinori MUSHA <knu@iDaemons.org>
- * parse.y (here_document): supports EOF right after terminator.
+ * config.guess, config.sub: Update to a more recent version as of
+ 2004-01-20.
- * random.c (rb_f_rand): argument is now optional (rand(max=0)).
+ * configure.in: Add support for DragonFly BSD.
-Tue Jul 4 01:50:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Wed Jun 2 20:16:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/ruby.def: remove ruby_mktemp.
+ * string.c (str_new4): should share shared instance if it already
+ exists. [ruby-dev:23665]
-Tue Jul 4 01:27:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Jun 2 12:41:53 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_rescue2): new function to rescue arbitrary exception.
+ * io.c (rb_io_gets_m): set lastline ($_) even when read line is
+ nil. [ruby-dev:23663]
- * numeric.c (do_coerce): should catch NameError explicitly.
+Fri May 28 11:20:31 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Jul 4 00:15:23 2000 Dave Thomas <Dave@thomases.com>
+ * eval.c (rb_eval): bad influence on frame node.
- * numeric.c (Init_Numeric): forgot to register Numeric#remainder.
+ * eval.c (eval): reverted wrongly removed condition. [ruby-dev:23638]
-Mon Jul 3 23:46:56 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Thu May 27 23:15:18 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * win32/win32.c (myselect, myaccept): disable interrupt while
- executing accept() or select() to avoid Ctrl-C causes
- "unknown software exception (0xc0000029)".
+ * lib/logger.rb: leading 0 padding of timestamp usec part.
-Mon Jul 3 18:35:41 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/csv.rb (CSV.parse): [CAUTION] behavior changed. in the past,
+ CSV.parse accepts a filename to be read-opened (it was just a
+ shortcut of CSV.open(filename, 'r')). now CSV.parse accepts a
+ string or a stream to be parsed e.g.
+ CSV.parse("1,2\n3,r") #=> [['1', '2'], ['3', '4']]
- * lib/mkmf.rb: use null device if it exists for cross-compiling.
+ * lib/csv.rb: CSV::Row and CSV::Cell are deprecated. these classes
+ are removed in the future. in the new csv.rb, row is represented
+ as just an Array. since CSV::Row was a subclass of Array, it won't
+ hurt almost all programs except one which depended CSV::Row#match.
+ and a cell is represented as just a String or nil(NULL). this
+ change will cause widespread destruction.
-Mon Jul 3 18:19:51 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ CSV.open("foo.csv", "r") do |row|
+ row.each do |cell|
+ if cell.is_null # using Cell#is_null
+ p "(NULL)"
+ else
+ p cell.data # using Cell#data
+ end
+ end
+ end
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.26.
+ must be just;
- * lib/net/protocol.rb (finish): do nothing unless active.
+ CSV.open("foo.csv", "r") do |row|
+ row.each do |cell|
+ if cell.nil?
+ p "(NULL)"
+ else
+ p cell
+ end
+ end
+ end
- * lib/net/http.rb: HTTP#{get,post}2 again (for new impl).
+ * lib/csv.rb: [CAUTION] record separator(CR, LF, CR+LF) behavior
+ change. CSV.open, CSV.parse, and CSV,generate now do not force
+ opened file binmode. formerly it set binmode explicitly.
-Mon Jul 3 16:47:22 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ with CSV.open, binmode of opened file depends the given mode
+ parameter "r", "w", "rb", and "wb". CSV.parse and CSV.generate open
+ file with "r" and "w".
- * cygwin/GNUmakefile: librubys.a -> lib$(RUBY_INSTALL_NAME)s.a
+ setting mode properly is user's responsibility now.
- * configure.in: use AC_CANONICAL_{HOST,TARGET,BUILD}.
+ * lib/csv.rb: accepts String as a fs (field separator/column separator)
+ and rs (record separator/row separator)
-Mon Jul 3 13:15:02 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/csv.rb (CSV.read, CSV.readlines): added. works as IO.read and
+ IO.readlines in CSV format.
- * numeric.c (fix_divmod): x * d + m = y where d, m = x.divmod(y).
+ * lib/csv.rb: added CSV.foreach(path, rs = nil, &block). CSV.foreach
+ now does not handle "| cmd" as a path different from IO.foreach.
+ needed?
- * bignum.c (rb_big_divmod): ditto.
+ * test/csv/test_csv.rb: updated.
- * numeric.c (fixdivmod): does not depend C's undefined %
- behavior. adopt to fmod(3m) behavior.
+ * test/ruby/test_float.rb: added test_strtod to test Float("0").
- * numeric.c (flo_mod): modulo now reserves fmod(3m) behavior.
+Thu May 27 21:37:50 2004 Tanaka Akira <akr@m17n.org>
- * numeric.c (num_remainder): 'deprecated' warning.
+ * lib/pathname.rb (Pathname#initialize): refine pathname initialization
+ by pathname.
-Mon Jul 3 10:27:28 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Thu May 27 20:22:05 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * configure.in: use AC_CANONICAL_SYSTEM.
+ * io.c (rb_io_fwrite): check all case errno != 0 [ruby-dev:23648]
-Sun Jul 2 21:17:37 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Thu May 27 14:53:13 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * configure.in: support without --enable-shared for cygwin/mingw32.
+ * io.c (rb_io_fwrite): workaround for bcc32's fwrite bug.
+ add errno checking. [ruby-dev:23627]
- * cygwin/GNUmakefile: ditto.
+Wed May 26 14:19:42 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/extmk.rb.in: use null device if it exists for cross-compiling.
+ * eval.c (rb_eval, eval): make line number consistent on eval with
+ Proc. [ruby-talk:101253]
- * lib/mkmf.rb: ditto.
+Wed May 26 13:59:17 2004 Dave Thomas <dave@pragprog.com>
- * util.c (ruby_mktemp): remove unused ruby_mktemp().
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::skip_for_variable): Allow for
+ 'do' after for statement
-Sun Jul 2 14:18:04 2000 Koji Arai <JCA02266@nifty.ne.jp>
+Wed May 26 13:56:03 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (TMP_PROTECT_END): tmp__protect_tmp may be NULL.
+ * lib/rdoc/generators/html_generator.rb (Generators::MarkUp::style_url): Fix
+ relative path to code CSS file
-Sun Jul 2 03:37:50 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Wed May 26 13:14:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.25.
+ * io.c (rb_io_init_copy): copy also positions. [ruby-talk:100910]
- * lib/net/protocol.rb (each_crlf_line): beg = 0 is needed in adding{}
+Wed May 26 00:00:00 2004 why the lucky stiff <why@ruby-lang.org>
- * lib/net/smtp.rb: allow String for to_addr of SMTP#sendmail
+ * ext/syck/syck.c (syck_new_parser): clear parser on init.
+ thanks, ts. [ruby-core:02931]
-Sat Jul 1 15:22:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/token.c (sycklex_yaml_utf8): buffer underflow.
+ thanks, ts. [ruby-core:02929]
- * numeric.c (fix_rshift): should handle shift value more than
- sizeof(long).
+ * lib/yaml/baseemitter.rb (indent_text): simpler flow block code.
-Sat Jul 1 15:22:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/yaml.rb: added rdoc to beginning of lib.
- * eval.c (rb_eval): the value from RTEST() is not valid Ruby
- object. result should be either true or false.
+Mon May 24 10:46:26 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
-Sat Jul 1 09:30:06 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/rdoc/generators/template/html/html.rb: SYSTEM identifiers
+ must be absolute URIs
- * re.c (rb_reg_initialize): was freeing invalid pointer.
+Sat May 22 12:00:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Jul 1 03:25:56 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * MANIFEST: add new encodings in rexml.
- * parse.y (call_args): command_call can be the last argument of
- call_args. It had to be the only argument.
+ * ext/tk/MANIFEST: add recent files.
- * re.c (rb_reg_s_quote): should not dump core even for unsane mbc
- string.
-
-Fri Jun 30 01:36:20 2000 Aleksi Niemela <aleksi.niemela@cinnober.com>
-
- * parse.y (f_norm_arg): better, nicer error message.
-
-Thu Jun 29 07:45:33 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * ext/socket/socket.c (udp_send): destination may be packed
- struct sockaddr.
-
- * object.c (rb_Integer): Integer(nil) should be invalid, on the
- other hand, nil.to_i is OK.
-
-Wed Jun 28 17:26:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * ext/socket/socket.c (ip_recvfrom): udp_recvfrom and tcp_recvfrom
- is merged and moved to IPSocket#recvfrom.
-
- * ext/socket/socket.c (sock_s_getaddrinfo): family can be a
- strings such as "AF_INET" etc.
+Sat May 22 05:37:11 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ruby.c (require_libraries): . and RUBYLIB added to $load_path
- just before -r procedure.
+ * ext/tk/lib/remote-tk.rb: (NEW library) controll Tk interpreters
+ on the other processes by Tcl/Tk's 'send' command
- * ruby.c (proc_options): -e, - did not exec -r.
+Fri May 21 09:22:05 2004 Dave Thomas <dave@pragprog.com>
-Wed Jun 28 14:52:28 2000 Koga Youichirou <y-koga@mms.mt.nec.co.jp>
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method_parameters):
+ Add ()'s around parameters that don't have them
- * config.sub: NetBSD/hpcmips support.
+Thu May 20 17:02:03 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jun 28 10:11:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (check_sizeof): define result size. [ruby-core:02911]
- * gc.c: gc trigger threshold changed; GC_NEWOBJ_LIMIT removed,
- FREE_MIN is increased to 4096.
+ * lib/mkmf.rb (create_header): macro name should not include equal
+ sign.
-Tue Jun 27 22:39:28 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Thu May 20 15:59:50 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.24.
+ * ext/socket/socket.c: fix SEGV. [ruby-dev:23550]
- * lib/net/protocol.rb: modified each_crlf_line again.
+Thu May 20 14:35:52 2004 Tanaka Akira <akr@m17n.org>
- * lib/net/protocol.rb: do_write_beg,do_write_end -> writing{}
- do_write_do -> do_write
+ * ext/socket/socket.c: check SCM_RIGHTS macro addition to
+ the msg_control field to test existence of file descriptor passing
+ by msg_control.
- * lib/net/http.rb: can make proxy connection by passing
- addresses to HTTP.new, start.
+Thu May 20 12:38:06 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/http.rb: HTTP.new_implementation, old_implementation:
- can use 1.2 implementation of head, get, post, put.
- (see document)
+ * numeric.c (flo_eq): always check if operands are NaN.
+ [ruby-list:39685]
-Tue Jun 27 12:05:10 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Thu May 20 12:34:39 2004 Dave Thomas <dave@pragprog.com>
- * win32.c (myfdclr): new function.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_visibility):
+ At Ryan Davis' suggestion, honor visibility modifers if guarded by a
+ statement modifier
- * win32.h: add FD_CLR.
+Thu May 20 12:22:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Jun 26 23:41:41 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/mkmf.rb (have_type): do not check pointer to incomplete type,
+ which always get compiled. [ruby-list:39683]
- * ruby.h: add cast for ANSI style.
+Wed May 19 11:09:00 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * gc.c (rb_data_object_alloc): use RUBY_DATA_FUNC.
+ * ext/tk/lib/tk.rb: change permition of TkObject#tk_send from
+ private to public
-Mon Jun 26 22:20:03 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Tue May 18 14:00:46 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * win32/win32.c (is_socket, extract_file_fd): New function.
+ * node.h (NEW_DSTR): adjust list length.
- * win32/win32.c (myfdopen): use is_socket().
+ * parse.y (literal_concat): ditto.
- * win32/win32.c (myselect): return non socket files immediately
- if file and socket handles are mixed.
+Mon May 17 16:14:25 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Mon Jun 26 16:21:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * numeric.c (flo_to_s): it's preferable that "p 0.0" outputs "0.0"
+ instead of "0.0e+00". [ruby-dev:23480]
- * eval.c (rb_thread_schedule): wait_for cleared too early.
+ * numeric.c (flo_to_s): it's preferable that "p 0.00000000000000000001"
+ outputs "1.0e-20" instead of "9.999999999999999e-21". (the precision
+ is considered, but there is assumption DBL_DIG == 15 in current
+ implementation)
-Mon Jun 26 09:15:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon May 17 10:13:33 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * pack.c: remove obsolete 'F', 'D' specifiers.
+ * ext/socket/socket.c (setup_domain_and_type): honor duck typing.
+ [ruby-dev:23522]
-Sun Jun 25 00:55:03 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * ext/socket/socket.c (sock_s_getnameinfo): ditto.
- * ext/socket/socket.c (sock_s_getnameinfo): `res' would not
- be assigned if TYPE(sa) == T_STRING.
+Mon May 17 01:15:23 2004 why the lucky stiff <why@ruby-lang.org>
-Sat Jun 24 14:36:29 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/yaml.rb: removed fallback to pure Ruby parser.
- * config*.dj, configure.bat, top.sed: move to djgpp/.
+ * lib/yaml/baseemitter.rb (indent_text): was forcing a mod value
+ of zero at times, which kept some blocks from getting indentation.
-Sat Jun 24 02:34:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/yaml/baseemitter.rb (node_text): rewriting folded scalars.
- * ruby.c (load_file): call require_libraries() here to let
- debug.rb work properly.
+ * ext/syck/syck.h: reports style of scalars now, be they plain, block
+ single-, or double-quoted.
-Fri Jun 23 22:34:51 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * ext/syck/syck.c: ditto.
- * bignum.c (rb_big_lshift): reorder xds assignment to avoid
- reusing `x' as `len' by VC++ 6.0 SP3 compiler with -Ox switch.
+ * ext/syck/gram.c: ditto.
-Fri Jun 23 01:11:27 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/node.c: ditto.
- * string.c (rb_str_substr): should return empty string (""),
- if beg == str.size and len == zero, mostly for convenience and
- backward compatibility.
+ * ext/syck/token.c: ditto.
- * parse.y (new_super): should tweak block_pass node for super too.
+ * ext/syck/rubyext.c (yaml_org_handler): symbols loaded only
+ if scalar style is plain.
- * string.c (rb_str_split_m): last split element should not be nil,
- but "" when limit is specified.
+ * ext/syck/rubyext.c (yaml_org_handler): some empty strings were
+ loaded as symbols.
-Thu Jun 22 17:27:46 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/yaml/test_yaml.rb (test_perl_regexp): updated test to
+ match new regexp serialization.
- * string.c (rb_str_substr): str[n,m] now returns nil when n equals
- to str.size.
+Mon May 17 00:03:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Thu Jun 22 13:49:02 2000 Uechi Yasumasa <uechi@ryucom.ne.jp>
+ * lib/drb/drb.rb: Cosmetic documentation changes.
- * lib/net/ftp.rb: support resuming.
+Sun May 16 22:36:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Thu Jun 22 13:37:19 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/test/unit.rb: Removed :nodoc: directive (it prevented effective
+ RDoc operation), and added file-level comment.
- * eval.c (rb_thread_sleep_forever): merge pause() macro.
+Sun May 16 20:55:49 2004 Tanaka Akira <akr@m17n.org>
-Wed Jun 21 08:49:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/dbm/dbm.c (fdbm_initialize): accept optional 3rd argument to
+ specify an open flag.
+ (Init_dbm): define open flags: DBM::READER, DBM::WRITER, DBM::WRCREAT
+ and DBM::NEWDB.
- * eval.c (rb_eval): should not raise exception just by defining
- singleton class.
+Sun May 16 13:10:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Wed Jun 21 01:18:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/**/*.rb: Removed :nodoc: directives (many were
+ generating warnings, many were on private methods).
- * ruby.h: two macros RUBY_DATA_FUNC and RUBY_METHOD_FUNC are added
- to make writing C++ extensions easier.
+Sat May 15 01:41:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * array.c (rb_ary_dup): internal classes should not be shared by dup.
+ * eval.c (eval): forgot to restore $SAFE value before evaluating
+ compiled node. [ruby-core:02872]
- * hash.c (rb_hash_dup): ditto.
+Sat May 15 01:33:12 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * object.c (rb_obj_dup): ditto.
+ * range.c (range_each_func): terminates loop if generating value
+ is same to @end. [ruby-talk:100269]
- * string.c (rb_str_dup): ditto.
+Fri May 14 22:08:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * error.c (Init_Exception): renamed NotImplementError to
- NotImplementedError.
+ * string.c (rb_str_new4): should not reuse frozen shared string if
+ the original is not an instance of String. [ruby-talk:100193]
-Tue Jun 20 16:22:38 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri May 14 18:39:25 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * time.c (make_time_t): bug in DST boundary.
+ * ext/tk/lib/tk/canvas.rb: improve coords support for canvas items.
+ Now, supports all of the followings.
+ TkcLine.new(c, 0, 0, 100, 100, :fill=>'red')
+ TkcLine.new(c, [0, 0, 100, 100], :fill=>'red')
+ TkcLine.new(c, [0, 0], [100, 100], :fill=>'red')
+ TkcLine.new(c, [[0, 0], [100, 100]], :fill=>'red')
+ TkcLine.new(c, :coords=>[0, 0, 100, 100], :fill=>'red')
+ TkcLine.new(c, :coords=>[[0, 0], [100, 100]], :fill=>'red')
-Tue Jun 20 10:54:19 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Fri May 14 12:11:43 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * configure.in: add eval sitedir.
+ * util.c (ruby_strtod): strtod("0", &end); => end should point '\0'.
+ [ruby-dev:23498]
-Tue Jun 20 06:14:43 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+Thu May 13 15:47:30 2004 akira yamada <akira@ruby-lang.org>
- * lib/cgi.rb: change: version syntax. old: x.yz, now: x.y.z
+ * lib/net/telnet.rb (Net::Telnet::login): "options" can specify
+ regexps for login prompt and/or password prompt.
- * lib/net/telnet.rb: ditto.
+Thu May 13 14:23:45 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Tue Jun 20 00:37:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * hash.c (delete_if_i): use st_delete_safe() (via
+ rb_hash_delete()) instead of returning ST_DELETE.
+ backport from HEAD. [ruby-dev:23487]
- * re.c (rb_reg_kcode_m): Regexp#kcode returns nil for code unfixed
- regexp object.
+Thu May 13 13:01:30 2004 akira yamada <akira@ruby-lang.org>
- * bignum.c (bigdivmod): bignum zero check was wrong.
+ * lib/uri/mailto.rb (URI::MailTo::to_s): should include fragment.
-Mon Jun 19 10:48:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu May 13 11:04:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * variable.c (rb_cvar_set): forgot to add security check for class
- variable assignment.
+ * pack.c (pack_pack): always add with null for 'Z'.
-Sun Jun 18 22:49:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * pack.c (pack_unpack): terminated by null for 'Z'. [ruby-talk:98281]
- * configure.in: single quoted sitedir.
+Wed May 12 19:59:43 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * mkconfig.rb: add DESTDIR for cross-compiling.
+ * lib/mkmf.rb (have_type, check_sizeof): replace unusable characters.
+ [ruby-talk:99788]
- * lib/mkmf.rb: add DESTDIR.
+Wed May 12 17:41:42 2004 Tanaka Akira <akr@m17n.org>
- * ruby.c (load_file): force binmode if fname includes ".exe"
- on DOSISH.
+ * lib/resolv.rb (Resolv::DNS::Config): make it configurable without
+ external file such as /etc/resolv.conf.
-Sat Jun 17 23:22:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed May 12 14:37:27 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * sprintf.c (rb_f_sprintf): should ignore negative precision given
- by <%.*>.
+ * ext/openssl/ossl_x509name.c: attribute value of DC (short name of
+ domainComponent) should be IA5String.
- * sprintf.c (rb_f_sprintf): should allow zero precision.
+Wed May 12 13:20:19 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Jun 17 03:13:29 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tk/composite.rb: improve configure methods (based on
+ the proposal of [ruby-talk:99671]).
- * time.c (time_localtime): avoid unnecessary call of localtime.
+Wed May 12 11:51:08 2004 Dave Thomas <dave@pragprog.com>
- * time.c (time_gmtime): avoid unnecessary call of gmtime.
+ * class.c (rb_obj_singleton_methods): fix rdoc
- * process.c (proc_wait2): new method.
+Mon May 10 21:44:42 2004 Dave Thomas <dave@pragprog.com>
- * process.c (proc_waitpid): second argument made optional.
+ * lib/rdoc/generators/html_generator.rb: Change scheme for
+ looking up symbols in HTML generator.
- * process.c (proc_waitpid2): new method.
+Mon May 10 16:45:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Jun 17 00:05:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (eval): warning during eval should not cause deadlock.
+ [ruby-talk:98651]
- * re.c (rb_reg_clone): should initialize member fields.
+ * eval.c (rb_eval): raise TypeError exception for superclass
+ mismatch. [ruby-list:39567]
-Fri Jun 16 22:49:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon May 10 12:11:37 2004 Dave Thomas <dave@pragprog.com>
- * io.c (rb_io_rewind): set lineno to zero.
+ * lib/rdoc/generators/html_generator.rb: Hack to search parents
+ for unqualified constant names.
-Fri Jun 16 22:47:47 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Mon May 10 12:11:37 2004 Dave Thomas <dave@pragprog.com>
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.23.
+ * lib/rdoc/generators/html_generator.rb: Hack to search parents
+ for unqualified constant names.
- * lib/net/protocol.rb: too many CRLF in last line.
+Sun May 9 22:37:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Fri Jun 16 21:23:59 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/net/ftp.rb: improved documentation
+ * lib/net/imap.rb: ditto
+ * lib/net/pop.rb: ditto
+ * lib/net/smtp.rb: ditto
+ * lib/net/telnet.rb: ditto
- * configure.in: add pause(2) checking.
+Fri May 7 21:50:21 2004 Dave Thomas <dave@pragprog.com>
- * eval.c: define pause() if missing.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::parse_include): Allow
+ multiple arguments to 'include'
-Fri Jun 16 18:41:58 2000 Koji Arai <JCA02266@nifty.ne.jp>
+Fri May 7 21:31:56 2004 Minero Aoki <aamine@loveruby.net>
- * process.c (proc_setsid): BSD-style setpgrp() don't return
- process group ID, but 0 or -1.
+ * lib/fileutils.rb (fu_list): Array() breaks pathes including "\n".
+ [ruby-core:02843]
-Fri Jun 16 16:23:35 2000 Koji Arai <JCA02266@nifty.ne.jp>
+Fri May 7 11:25:53 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * file.c (rb_stat_inspect): gives detailed information;
- compatibility with ruby-1.4.x.
+ * util.c (ruby_strtod): "0.0000000000000000001" should be converted
+ to 1.0e-19 instead of 0.0. (leading zeros aren't significant digits)
+ [ruby-talk:99318] [ruby-dev:23465]
-Fri Jun 16 05:18:45 2000 Yasuhiro Fukuma <yasuf@bsdclub.org>
+Fri May 7 10:00:05 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * configure.in: FreeBSD: do not link dummy libxpg4 which was
- merged into libc.
+ * ext/tk/tkutil.c (get_eval_string_core): bug fix. [ruby-dev:23466]
-Fri Jun 16 03:17:36 2000 Satoshi Nojo <nojo@t-samukawa.or.jp>
+Thu May 6 22:13:17 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * ext/dbm/dbm.c (fdbm_length): use GetDBM. empty?, [] too.
+ * ext/socket/socket.c (ippaddr): use NUMERICHOST if can not resolve
+ hostname.
- * ext/gdbm/gdbm.c (fgdbm_length): ditto.
+Thu May 6 14:22:29 2004 why the lucky stiff <why@ruby-lang.org>
- * ext/sdbm/init.c (fsdbm_length): ditto.
+ * lib/yaml/rubytypes.rb (to_yaml): added instance variable handling
+ for Ranges, Strings, Structs, Regexps.
-Fri Jun 16 01:57:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/yaml/rubytypes.rb (to_yaml_fold): new method for setting a
+ String's flow style.
- * eval.c (rb_thread_sleep_forever): pause(2) instead of sleep(3).
+ * lib/yaml.rb (YAML::object_maker): now uses Object.allocate.
-Thu Jun 15 10:46:36 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/gram.c: fixed transfer methods on structs, broke it
+ last commit.
- * string.c (rb_str_sub_bang): should probagate taintness from
- replacement string.
+Thu May 6 11:40:28 2004 Shugo Maeda <shugo@ruby-lang.org>
-Wed Jun 14 17:01:41 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/net/imap.rb (string): accept NIL.
- * rubytest.rb: add CONFIG['EXEEXT'] to the executable file name.
+ * lib/net/imap.rb (body_type_basic): allow body-fields omissions.
-Wed Jun 14 14:50:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu May 6 01:59:04 2004 Dave Thomas <dave@pragprog.com>
- * string.c (rb_f_sub): assign to $_ only if modification happens.
+ * lib/rdoc/generators/html_generator.rb (Generators::HtmlMethod::params):
+ Don't include the &block parameter if we have explicit
+ yield parameters.
- * string.c (rb_f_gsub): ditto.
+Wed May 5 03:40:29 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * string.c (rb_f_chop): ditto.
+ * lib/rinda/ring.rb: use recv instead of recvfrom.
- * string.c (rb_f_chomp): ditto.
+Tue May 4 23:52:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * io.c (io_reopen): preserve file position by ftell/fseek, if io
- is a seekable.
+ * lib/gserver.rb: documented
- * eval.c (method_arity): wrong arity number for the methods with
- optional arguments.
+Tue May 4 23:46:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * time.c (make_time_t): opposite timezone shift (should be negative).
+ * lib/xmlrpc/README.txt: introduced for documentation purposes
-Wed Jun 14 14:07:38 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Mon May 3 09:47:24 2004 Dave Thomas <dave@pragprog.com>
- * io.c: typo(ig/if).
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method_or_yield_parameters):
+ Fix parsing bug if yield called within 1 line block
- * re.c: typo(re/reg). add rb_reg_check().
+Sun May 2 01:04:38 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * time.c: remove unneeded declare(daylight, timezone).
+ * ext/tcltklib, ext/tk: renewal Ruby/Tk
- * configure.in: add include <time.h> when daylight checking.
+Fri Apr 30 20:08:41 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Wed Jun 14 11:36:52 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * time.c (SIZEOF_TIME_T): support SIZEOF_TIME_T == SIZEOF_INT.
- * marshal.c (r_object): modified for symbols.
+Tue Apr 27 13:12:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * marshal.c (w_object): ditto.
+ * eval.c (rb_eval): too many line trace call. (ruby-bugs PR#1320)
-Wed Jun 14 10:04:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Apr 27 08:41:28 2004 why the lucky stiff <why@ruby-lang.org>
- * re.c (rb_memcmp): should compare according to ruby_ignorecase.
+ * lib/yaml/rubytypes.rb: passing Range tests.
- * string.c (rb_str_cmp): use rb_memcmp.
+ * ext/syck/syck.h: version 0.44.
- * string.c (rb_str_index): ditto.
+ * ext/syck/gram.c: transfers no longer open an indentation.
+ fixed transfers which precede blocks.
- * string.c (rb_str_rindex): ditto.
+ * ext/syck/token.c: ditto.
- * string.c (rb_str_each_line): ditto.
+ * ext/syck/syck.c: fixed segfault if an anchor has been released already.
-Wed Jun 14 04:58:53 2000 Dave Thomas <dave@thomases.com>
+ * ext/syck/node.c (syck_free_members): organized order of free'd nodes.
- * io.c (rb_io_set_lineno): should have returned VALUE, not
- integer.
+ * ext/syck/rubyext.c (syck_emitter_write_m): test for proper string with
+ StringValue.
-Wed Jun 14 09:29:42 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Apr 26 23:56:54 2004 Daniel Kelley <news-1082945587@dkelley.gmp.san-jose.ca.us>
- * string.c (rb_str_dup): dup should always propagate taintness.
+ * README.EXT, README.EXT.ja: fixed wrong function signature.
+ [ruby-talk:98349]
-Wed Jun 14 00:50:14 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+Mon Apr 26 21:40:09 2004 Dave Thomas <dave@pragprog.com>
- * lib/cgi.rb: read_multipart(): if no content body then raise EOFError.
+ * lib/rdoc/code_objects.rb (RDoc::Context::add_alias): Only alias
+ to instance methods.
-Tue Jun 13 11:46:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Apr 24 10:38:31 2004 Dave Thomas <dave@pragprog.com>
- * process.c (proc_setsid): try implement it using setpgrp() and
- ioctl(fd, TIOCNOTTY, NULL).
+ * lib/rdoc/markup/simple_markup.rb (SM::SimpleMarkup::group_lines):
+ Fix bug where consecutive headings are merged.
- * re.c (rb_reg_prepare_re): magic variable $= should affect regex
- pattern match.
+Fri Apr 23 23:26:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * time.c (make_time_t): use tm.tm_gmtoff if possible.
+ * lib/mkmf.rb: $hdrdir should not contain macros for backward
+ compatibilitiy. [bruby-dev:28]
- * time.c (time_zone): use tm.tm_zone if available.
+ * version.c (ruby_show_copyright): obtain copyright year from
+ RUBY_RELEASE_YEAR.
-Tue Jun 13 01:50:57 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * win32/resource.rb: ditto.
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.22.
+ * win32/resource.rb: default rubyw icon to ruby.ico, and let DLL also
+ include them.
- * lib/net/http.rb: HTTPResponse#body returns body.
+ * win32/resource.rb: include winver.h for older WindowsCE.
-Mon Jun 12 23:41:54 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Fri Apr 23 16:38:46 2004 Tanaka Akira <akr@m17n.org>
- * configure.in (daylight): avoid GCC optimization.
+ * lib/pathname.rb: sync taint/freeze flag between
+ a pathname object and its internal string object.
-Mon Jun 12 19:02:27 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+Fri Apr 23 14:52:08 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * configure.in: cygwin has strange timezone.
+ * parse.y (stmt, arg, aref_args): should not make sole splat into
+ array, in aref_args other than aref with op_asgn.
- * time.c (time_zone): use tzname and daylight.
+Fri Apr 23 14:14:38 2004 Tanaka Akira <akr@m17n.org>
-Sat Jun 10 23:10:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/resolv.rb: don't use Regexp#source to embed regexps.
+ [ruby-dev:23432]
- * io.c (rb_io_seek): whence is optional, default is SEEK_SET.
+Thu Apr 22 04:15:36 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Jun 9 17:00:29 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * parse.y (aref_args): should pass expanded list. [ruby-core:02793]
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.21.
+Thu Apr 22 01:12:57 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/http.rb: exception is raised with response object.
-
-Fri Jun 9 15:11:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * time.c (make_time_t): supports daylight saving time.
-
- * eval.c (rb_thread_safe_level): should retrieve current $SAFE
- value if a thread is the current thread.
-
-Thu Jun 8 14:25:45 2000 Hiroshi Igarashi <iga@ruby-lang.org>
-
- * lib/mkmf.rb: add target `distclean' in Makefile for extlib.
- target `clean' doesn't remove Makefile.
-
-Thu Jun 8 13:34:03 2000 Dave Thomas <dave@thomases.com>
-
- * numeric.c: add nan?, infinite?, and finite? to Float
-
-Thu Jun 8 00:31:04 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * numeric.c (flo_to_s): tweak output string based to preserve
+ decimal point and to remove trailing zeros. [ruby-talk:97891]
- * regex.h: export re_mbctab properly on cygwin.
+ * string.c (rb_str_index_m): use unsigned comparison for T_FIXNUM
+ search. [ruby-talk:97342]
- * dln.c: use dlopen instead of LoadLibrary on cygwin.
+Wed Apr 21 22:57:27 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Thu Jun 8 13:41:34 2000 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * lib/rinda/rinda.rb, test/rinda/test_rinda.rb: check Hash tuple size.
- * file.c (rb_file_s_basename): might dump core.
+Wed Apr 21 20:05:00 2004 Tanaka Akira <akr@m17n.org>
-Tue Jun 6 03:29:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/open-uri.rb (URI::HTTP#proxy_open): set Host: field explicitly.
+ [ruby-list:39542]
- * dir.c (dir_foreach): now returns nil for consistency.
+Mon Apr 19 18:11:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * bignum.c (bigdivmod): modulo by small numbers was wrong.
+ * hash.c (rb_hash_equal): returns true if two hashes have same set
+ of key-value set. [ruby-talk:97559]
-Mon Jun 5 00:18:08 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * hash.c (rb_hash_eql): returns true if two hashes are equal and
+ have same default values.
- * bignum.c: avoid conflict with USHORT on mingw32.
+Mon Apr 19 08:19:58 2004 Doug Kearns <djkea2@mugca.its.monash.edu.au>
-Mon Jun 5 00:13:35 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * dln.c, io.c, lib/benchmark.rb, lib/cgi.rb, lib/csv.rb, lib/date.rb,
+ lib/ftools.rb, lib/getoptlong.rb, lib/logger.rb, lib/matrix.rb,
+ lib/monitor.rb, lib/set.rb, lib/thwait.rb, lib/timeout.rb,
+ lib/yaml.rb, lib/drb/drb.rb, lib/irb/workspace.rb, lib/net/ftp.rb,
+ lib/net/http.rb, lib/net/imap.rb, lib/net/telnet.rb,
+ lib/racc/parser.rb, lib/rinda/rinda.rb, lib/rinda/tuplespace.rb,
+ lib/shell/command-processor.rb, lib/soap/rpc/soaplet.rb,
+ lib/test/unit/testcase.rb, lib/test/unit/testsuite.rb: typo fix.
- * eval.c (rb_thread_schedule): =/== typo.
+Mon Apr 19 08:14:18 2004 Dave Thomas <dave@pragprog.com>
-Sun Jun 4 03:17:36 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_body): Allow for
+ #ifdef HAVE_PROTOTYPES
- * lib/cgi.rb: improve: CGI::pretty()
+Fri Apr 16 22:33:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Sun Jun 4 02:01:10 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * ext/iconv/iconv.c: nearly finished RDoc comments.
- * lib/mkmf.rb: do not need to add -L$(topdir) in --enable-shared case.
+Fri Apr 16 17:04:07 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Jun 3 13:50:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (rb_str_equal): always returns true or false, never
+ returns nil. [ruby-dev:23404]
- * parse.y (rb_id2name): should support constant attrset
- identifiers.
+Fri Apr 16 08:27:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * bignum.c (rb_big_eq): Bignum#== should not raise exception.
+ * ext/extmk.rb: skip linking when libraries to be preloaded not
+ compiled. [ruby-list:39561]
-Fri Jun 2 11:24:48 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_popen): open with a block returns the value from the
- block. old behavior was back.
-
-Fri Jun 2 00:42:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
-
- * eval.c (rb_thread_cleanup): should clear priority for thread
- termination.
-
-Thu Jun 01 22:39:41 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.20.
-
- * lib/net/http.rb: wrongly closed the socket twice
- when no Content-Length: was given.
-
-Thu Jun 1 00:59:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_yield_0): convert Qundef to [].
-
-Wed May 31 20:45:59 2000 Dave Thomas <Dave@Thomases.com>
-
- * string.c (rb_str_slice_bang): wrong argument number.
-
-Wed May 31 12:37:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_exec_end_proc): print error message from END procs.
-
-Wed May 31 04:06:41 2000 Wakou Aoyama <wakou@fsinet.or.jp>
-
- * lib/cgi.rb: change: CGI#out() if "HEAD" == REQUEST_METHOD then
- output only HTTP header.
-
-Wed May 31 01:54:21 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_thread_schedule): set main_thread->status to
- THREAD_TO_KILL, before raising deadlock error.
-
- * eval.c (rb_thread_deadlock): if curr_thread == main_thread, do
- not call rb_thread_restore_context()
-
-Tue May 30 23:33:41 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * lib/mkmf.rb (create_makefile): add $(TARGET).ilk and *.pdb
- to cleanup files for mswin32.
-
-Mon May 29 10:41:10 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * file.c (rb_file_s_basename): should propagate taintness.
-
-Sun May 28 21:37:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * eval.c: bug fix: DLEXT2.
-
-Sun May 28 19:21:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * win32/win32.c: use ruby's glob.
-
- * dir.c: "glob" exported and renamed to "rb_glob".
-
- * ruby.h: ditto.
-
- * main.c: turn off command line mingw32's globbing.
-
-Wed May 25 22:25:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * ext/extmk.rb.in: use "ftools" instead of "rm -f".
-
- * lib/mkmf.rb: ditto.
-
-Thu May 25 22:01:32 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * defines.h: mswin32: remove obsolete USHORT definition.
-
- * re.h: mswin32: use EXTERN instead of extern.
-
- * regex.h: mswin32: export re_mbctab properly.
-
- * win32/ruby.def: add ruby_ignorecase and regex.c's exports.
-
-Thu May 25 21:28:44 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * re.c (rb_reg_expr_str): escape un-printable character.
-
-Thu May 25 01:35:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (tokadd_escape): forgot to add `\x' to hexadecimal
- escape sequences.
-
- * object.c (rb_obj_dup): dup for normal object (T_OBJECT) copies
- instance variables only.
-
-Wed May 24 23:49:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * object.c (rb_mod_initialize): should provide initialize.
-
-Wed May 24 23:17:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * win32/Makefile: remove unnecessary mv and rm command call.
-
-Wed May 24 21:01:04 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * ext/pty/pty.c: use "" instead of <> to include ruby.h and rubyio.h
- for BeOS (PowerPC).
-
- * file.c (rb_find_file): should check dln_find_file() result.
-
- * win32/ruby.def: add rb_block_given_p.
-
-Wed May 24 16:32:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_popen): popen does not take 3rd argument anymore.
-
- * re.c (rb_reg_desc): re may be zero, check before dereferencing.
-
-Wed May 24 16:03:06 2000 Wakou Aoyama <wakou@fsinet.or.jp>
-
- * lib/cgi.rb: bug fix: CGI::escape(), CGI::Cookie::new()
-
- * lib/net/telnet.rb: improve: binmode(), telnetmode() interface
-
-Wed May 24 13:12:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * misc/ruby-mode.el (ruby-parse-region): support `while .. do'
- etc. But corresponding keywords must be at the beginning of
- line.
-
-Tue May 23 23:50:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * re.c (rb_reg_initialize_m): wrong kcode value.
-
- * re.c (rb_reg_s_new): forgot to initialize re->ptr.
-
-Tue May 23 08:36:24 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * regex.c (re_compile_pattern): forgot to restore old option
- status by (?ix-ix).
-
- * regex.c (re_compile_fastmap): anychar may match newline if
- RE_OPTION_MULTILINE or RE_OPTION_POSIXLINE is set.
-
-Mon May 22 22:45:06 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.19.
-
- * lib/net/http.rb: do not use Regexp "p" option.
-
-Mon May 22 21:56:43 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * struct.c (rb_struct_getmember): should use ID2SYM, not INT2NUM.
-
-Mon May 22 15:07:37 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * file.c (rb_find_file): should check if the file really exists.
-
-Mon May 22 09:08:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_popen): _exit(0) after processing block under the
- child process.
-
- * io.c (rb_io_popen): flush stdout/stderr before subprocess
- termination.
-
- * eval.c (rb_check_safe_str): insert rb_secure(4); operation
- requires untainted string should be prohibited in level 4.
-
-Sun May 21 21:17:00 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * configure.in: add Setup.dj for djgpp cross-compiling.
-
- * Setup.dj: add readline.
-
- * instruby.rb: copy win32/win32.h to archlibdir on mingw32.
-
-Sun May 21 20:58:08 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * pack.c: fix OFF16 and OFF32 definitions for Alpha and IRIX64.
-
-Sun May 21 17:31:37 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * instruby.rb: support "make install" for cross-compiling.
-
- * ext/extmk.rb.in: ditto.
-
-Sun May 21 14:22:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * Makefile.in: rename prep.rb to fake.rb.
-
- * configure.in: ditto.
-
-Sat May 20 23:29:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * dir.c (dir_s_new): does not take block; "open" does.
-
- * io.c (rb_io_s_new): ditto.
-
-Fri May 19 07:44:26 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * dir.c (dir_s_open): Dir#open does not returns closed Dir if a
- block is given to the method.
-
- * re.c (rb_reg_initialize_m): Regexp::new calls initialize now.
-
- * string.c (Init_String): String#delete_at removed.
-
- * string.c (rb_str_aset_m): should have checked argc != 2.
-
- * eval.c (rb_thread_schedule): select(2) was called too many.
-
- * regex.c (re_compile_pattern): a bug in (?m) support. Pointed
- out by Dave Thomas <Dave@thomases.com>.
-
-Thu May 18 23:55:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * dln.c (search_undef): st_lookup()'s 3rd parameter should be
- a pointer of the variable which has the same size and alignment
- as `char *'.
-
- * marshal.c (w_symbol, w_object): ditto.
-
- * parse.y (rb_intern): ditto.
-
-Thu May 18 18:00:35 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.18.
-
- * lib/net/protocol.rb: Net::Version was removed.
-
- * lib/net/smtp.rb: use Socket.gethostname to get local host name.
-
-Thu May 18 13:34:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * ext/socket/socket.c (ruby_connect): should not have replaced
- thread_write_select() by rb_thread_fd_writable().
-
-Thu May 18 09:01:25 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * configure.in, ext/extmk.rb.in, lib/mkmf.rb: remove BeOS R3 support.
- Make a shared library (libruby.so) only if the --enable-shared
- option is specified.
-
- * instruby.rb: no longer use libruby.so.LIB and import.h.
-
- * io.c: fix READ_DATA_PENDING definition for BeOS (PowerPC).
-
-Wed May 17 14:14:23 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * re.c (rb_reg_new_1): use /m instead of /p.
-
-Wed May 17 02:22:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_thread_polling): wait 0.06 second to let other
- processes run.
-
- * process.c (rb_waitpid): avoid busy wait using rb_thread_polling.
-
- * file.c (rb_thread_flock): ditto.
-
- * parse.y (expr): avoid calling value_expr() twice.
-
-Wed May 17 00:45:57 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * io.c (rb_io_binmode): should check PLATFORMs, not O_BINARY, sigh...
-
-Wed May 17 00:40:15 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * win32/config.h: add DLEXT2, now DLEXT on mswin32 is "so".
-
- * win32/config.status: ditto.
-
- * win32/ruby.def: add symbol "rb_big_divmod".
-
-Tue May 16 19:45:32 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * intern.h: use EXTERN instead of extern.
-
- * win32/ruby.def: add rb_defout, rb_stdout, ruby_errinfo,
- ruby_sourceline, ruby_sourcefile to work with eruby
- reported by Hiroshi Saito <HiroshiSaito@pob.org>.
- Export both ruby_xmalloc and xmalloc etc.
-
-Tue May 16 17:00:05 2000 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
-
- * eval.c (rb_thread_select): should check whether fds are null.
-
-Tue May 16 11:51:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (pipe_open): synchronize subprocess stdout/stderr.
-
-Mon May 15 15:38:09 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * ruby.h: exported symbols should be for xmalloc etc. are now
- prefixed by 'ruby_', e.g. ruby_xmalloc().
-
- * eval.c (rb_thread_select): remove busy wait for select.
-
- * dir.c (glob): trailing path may be null, e.g. glob("**").
-
-Mon May 15 14:48:41 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * io.c (rb_io_pid): new method; returns nil if no process attached
- to the IO.
-
-Mon May 15 01:18:20 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_s_popen): _exit after Proc execution.
-
-Sun May 14 18:05:59 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * Makefile.in: missing/nt.c -> win32/win32.c
-
- * configure.in: bug fix; static linking on mingw32.
-
- * cygwin/GNUmakefile.in: remove VPATH.
-
- * ext/extmk.rb.in: Makefile set binmode with mingw32 on cygwin32.
-
- * lib/mkmf.rb: ditto.
-
- * win32/config.h: undef HAVE_SYS_FILE_H.
-
-Sun May 14 02:02:48 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * lib/irb/ruby-lex.rb: '/' should be escaped in character class.
-
-Sun May 14 00:54:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * configure.in, ...: support mingw32.
-
- * defines.h: ditto. undef EXTERN for tcl/tk on cygwin.
-
- * ext/*/extconf.rb: replace PLATFORM with RUBY_PLATFORM.
-
- * ext/socket/sockport.h: define IN_MULTICAST for missing IN_MULTICAST.
-
- * ext/tcltklib/tcltklib.c: remove declaration of rb_argv0.
-
- * file.c: should check S_IXGRP, S_ISGID, not NT.
-
- * io.c (rb_io_binmode): should check _IOBIN, O_BINARY, not PLATFORMs.
-
-Sat May 13 14:21:15 2000 Koji Arai <JCA02266@nifty.ne.jp>
-
- * io.c (rb_io_s_popen): should check whether a block is given.
-
-Fri May 12 17:33:44 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * regex.c (re_compile_pattern): charset_not should not exclude
- newline from matching set.
-
-Thu May 11 22:51:05 2000 Ryunosuke Ohshima <ryu@jaist.ac.jp>
-
- * pack.c (pack_pack): Bignum support.
-
- * pack.c (pack_unpack): ditto.
+Thu Apr 15 23:21:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu May 11 21:19:29 2000 Hiroshi Igarashi <iga@ruby-lang.org>
+ * process.c (pst_success_p): new method Process::Status#success?.
+ [ruby-dev:23385]
- * intern.h: add missing declarations of ruby API functions.
+Thu Apr 15 17:12:13 2004 Tanaka Akira <akr@m17n.org>
- * ruby.h: fix function name in declarations.
+ * ext/gdbm/gdbm.c (Init_gdbm): define GDBM::READER, GDBM::WRITER,
+ GDBM::WRCREAT and GDBM::NEWDB.
+ (fgdbm_initialize): use specified read/write flag.
-Thu May 11 22:29:25 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Wed Apr 14 11:29:56 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/md5/depend: add $(topdir)/config.h dependency to md5c.o.
+ * numeric.c (flo_eq): workaround for bcc32's bug.
+ (ruby-bugs-ja:PR#594)
- * ext/md5/extconf.rb: new file to add -DHAVE_CONFIG_H flag for Alpha.
+Wed Apr 14 13:06:35 2004 Doug Kearns <djkea2@mugca.its.monash.edu.au>
-Thu May 11 10:55:52 2000 Ryunosuke Ohshima <ryu@jaist.ac.jp>
+ * array.c, enum.c, eval.c, file.c, io.c, numeric.c, object.c, prec.c,
+ process.c, re.c, string.c: typos in RDoc comments. [ruby-core:02783]
- * pack.c (pack_pack): packing BER compressed integer by `w'.
+Wed Apr 14 11:06:38 2004 Dave Thomas <dave@pragprog.com>
- * pack.c (pack_unpack): unpacking BER.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::scan): Changed
+ behavior of :enddoc: -- it now unconditionally terminates
+ processing of the current file.
-Thu May 11 00:37:55 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Apr 14 11:03:22 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * parse.y (parse_regx): remove in_brack.
+ * defines.h: include <net/socket.h> to get fd_set definition in BeOS.
-Wed May 10 12:51:18 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Apr 13 23:06:30 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * ruby.c (proc_options): move adding RUBYLIB and "." to the load
- path after #! line parsing.
+ * lib/rinda/rinda.rb: change pattern matching.
+ a === b -> a == b || a === b. [druby-ja:98]
- * parse.y (parse_regx): should parse backslash escape like `\c['
- here to avoid causing `unterminated regexp' error.
+ * test/rinda/test_rinda.rb: ditto.
-Wed May 10 00:19:53 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Tue Apr 13 19:54:29 2004 Minero Aoki <aamine@loveruby.net>
- * MANIFEST, beos/GNUmakefile.in, configure.in: no longer need
- beos/GNUmakefile.in to support BeOS R4.5.2 (Intel) as a result
- of eban's Makefile.in change.
+ * lib/net/http.rb: should not overwrite HTTP request header.
+ [ruby-list:39543]
- * io.c: NOFILE is already defined on BeOS R4.5 (Intel) or later.
+Tue Apr 13 01:30:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * lib/matrix.rb: remove debug print.
+ * ext/iconv/iconv.c: RDoc documentation (from RD; nearly finished).
+ * ext/iconv/charset_alias.rb: Prevent from RDoc'ing.
- * regex.c: don't use nested comment.
+Mon Apr 12 19:11:29 2004 Eric Hodel <drbrain@segment7.net>
-Tue May 9 17:08:43 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * gc.c (rb_gc_copy_finalizer): typo. [ruby-core:02774]
- * eval.c (massign): no longer convert nil into empty array.
+Mon Apr 12 18:52:32 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * io.c (rb_io_s_popen): optional 3rd argument to give proc, which
- will be executed in spawned child process.
+ * ext/openssl/ossl_x509name.c (ossl_x509name_init_i): should return
+ a value.
-Mon May 8 23:47:39 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Mon Apr 12 10:43:47 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * eval.c (rb_callcc): prev & next should be initialized to zero.
+ * dir.c (rb_glob2, rb_glob, rb_globi, push_globs, push_braces,
+ rb_push_glob): fix memory leak. (leaked when block was interrupted)
-Mon May 8 23:17:36 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Apr 12 10:27:37 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * dln.c (dln_init): remove possible buffer overrun. This is
- suggested by Aleksi Niemela <aleksi.niemela@cinnober.com>.
+ * bcc32/Makefile.sub: backport SIZEOF_TIME_T definition from 1.9.
- * dln.c (init_funcname): ditto.
-
-Sat May 6 23:35:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (lhs): should allow `obj.Attr = 5' type expression.
-
-Sat May 6 15:46:08 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * ext/socket/extconf.rb: add a new configure option to force use
- of the WIDE Project's getaddrinfo(): --enbale-wide-getaddrinfo.
-
-Fri May 5 21:19:22 2000 MOROHOSHI Akihiko <moro@remus.dti.ne.jp>
-
- * parse.y (yylex): allow '$1foo' and such.
-
-Fri May 5 17:57:24 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.17.
-
- * lib/net/http.rb: write also port number in Host: field.
-
- * lib/net/http.rb: see Proxy-Connection: to decide socket connection.
-
-Fri May 5 03:25:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * regex.c (re_compile_fastmap): charset_not for multibyte
- characters excluded too many characters.
-
-Tue May 2 13:23:43 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_thread_schedule): little bit more impartial context
- switching.
-
-Tue May 2 09:50:03 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * configure.in: add DLDLIBS to set platform specific library
- for extensions.
-
- * ext/extmk.rb.in: use @DLDLIBS@ instead of RUBY_PLATFORM choice.
-
- * lib/mkmf.rb: use CONFIG["DLDLIBS"] instead of RUBY_PLATFORM choice.
-
- * config_s.dj: add @DLDLIBS@.
-
- * win32/config.status: ditto.
-
- * win32/ruby.def: regular maintenance.
-
-Mon May 1 23:42:44 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * configure.in, eval.c: add DLEXT2. now DLEXT on Cygwin is "so".
-
- * defines.h: use dllimport, dllexport for Cygwin 1.1.x.
-
- * ruby.h: ditto.
-
- * cygwin/GNUmakefile.in: ditto.
-
- * ext/Win32API/Win32API.c: directly "call" in asm statement for
- gcc 2.95.x or newer.
-
-Sat Apr 29 04:58:12 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * array.c (rb_ary_unshift_m): performance improvement.
-
-Fri Apr 28 00:19:22 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * array.c (rb_ary_unshift_m): takes items to push.
-
-Wed Apr 26 15:23:02 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (rb_str_succ): insert carrying character just before
- the leftmost alpha numeric character.
-
- * string.c (rb_str_succ): proper behavior for "".succ and "\377".succ.
-
- * string.c (rb_str_succ): use realloc and memmove.
-
-Tue Apr 25 18:28:45 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.16.
-
- * lib/net/smtp.rb: add SMTP AUTH
-
-Tue Apr 25 14:30:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_gets_internal): shortcut when rs == rb_default_rs.
-
-Sat Apr 22 23:14:41 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
-
- * configure.in: MacOS X support.
-
-Sat Apr 22 16:37:10 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.15.
-
- * lib/net/http.rb: closing socket by watching both
- user header and server response
-
-Fri Apr 21 21:44:34 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * io.c (rb_io_s_pipe): should set FMODE_SYNC.
-
-Thu Apr 20 16:59:22 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * eval.c (massign): `*lvalue = false' should assign `[false]' to
- lvalue.
-
-Wed Apr 19 08:35:08 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * class.c (rb_singleton_class): generate singleton class for
- special constants: nil, true, false.
-
-Wed Apr 19 02:09:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * class.c (rb_singleton_class): singleton method for nil, true,
- false is possible now.
-
- * eval.c (rb_eval): ditto.
-
-Tue Apr 18 18:54:25 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.14.
-
- * lib/net/http.rb: new method HTTP#head2.
-
- * lib/net/http.rb: get2/post2 does not raise exceptions.
-
-Mon Apr 17 15:16:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_close): to detect some exceptional status, writable
- IO should be flushed before close;
-
-Sat Apr 15 18:29:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * array.c (rb_ary_collect_bang): Array#filter renamed.
-
-Fri Apr 14 19:47:11 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.13.
-
- * lib/net/pop.rb: accept illegal timestamp
-
- * lib/net/http.rb: when body was chunked, does not set Content-Length:
-
-Tue Apr 11 21:14:42 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * config_s.dj: add @sitedir@.
- * configure.in: add --with-sitedir=DIR option.
- * instruby.rb: use CONFIG["sitedir"].
- * lib/mkmf.rb: support 'make site-install'.
- * win32/config.status: add @sitedir@.
-
-Tue Apr 11 16:25:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * bignum.c (rb_big_2comp): unnecessary lvalue cast removed.
-
-Tue Apr 11 02:25:53 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * hash.c (env_fetch): new method.
-
- * marshal.c (marshal_dump): accepts depth = nil for unlimited depth.
-
-Sun Apr 9 20:49:19 2000 Dave Thomas <Dave@Thomases.com>
-
- * parse.y (str_extend): Allow class variables to be expanded.
-
-Fri Apr 7 02:03:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * error.c (rb_sys_fail): escape non-printable characters.
-
-Thu Apr 6 20:10:47 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * ext/extmk.rb.in (create_makefile): BeOS --program-suffix support.
- * lib/mkmf.rb (create_makefile): ditto.
-
-Thu Apr 6 09:55:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * error.c (rb_sys_fail): need rb_exc_new2() call on BeOS.
-
-Mon Apr 3 17:22:27 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_reopen): support tempfile.
-
- * eval.c (catch_i): should supply argument.
-
-Sat Apr 1 22:50:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * marshal.c (r_object): wrong symbol restoration.
-
-Sat Apr 1 21:30:53 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * io.c(rb_io_printf, rb_f_printf): should use rb_io_write.
-
-Sat Apr 1 00:16:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * gc.c (rb_gc_call_finalizer_at_exit): should be clear flags
- before calling finalizers.
-
- * eval.c (specific_eval): can be called without SecurityError, if
- $SAFE >= 4.
-
- * object.c (sym_inspect): inspect gives ":sym", to_s gives "sym".
-
-Fri Mar 31 22:07:04 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.12.
-
- * lib/net/protocol.rb: update Net::Protocol::Proxy#connect
-
- * lib/net/protocol.rb: ReplyCode is not a class
-
- * lib/net/http.rb: header value format was change:
- values do not include header name
-
- * lib/net/http.rb: header is not a Hash, but HTTPResponse
-
-Thu Mar 30 12:19:44 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * enum.c (enum_find): rb_eval_cmd() should be called with array.
-
-Tue Mar 28 13:57:05 2000 Clemens Hintze <c.hintze@gmx.net>
-
- * ext/dbm/dbm.c (fdbm_invert): should return new hash.
-
- * ext/gdbm/gdbm.c (fgdbm_invert): ditto.
-
-Tue Mar 28 00:58:03 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.11.
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: does not
- dispatch any commands while dispatching command.
-
- * lib/net/protocol.rb: failed to get error class of
- inherited ReplyCode
-
- * lib/net/http.rb: change feature of "get2", "post2"
-
-Mon Mar 27 01:34:58 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.10.
-
- * lib/net/http.rb: return value of 'head' was wrong.
-
-Sun Mar 26 17:47:35 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.9.
-
- * lib/net/smtp.rb: SMTP#do_ready wrongly took no arguments
-
-Sat Mar 25 23:21:10 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * marshal.c (w_object): symbols should be converted to ID before
- dumping out.
-
-Sun Mar 25 16:52:48 2001 Koji Arai <JCA02266@nifty.ne.jp>
-
- * file.c (rb_file_flock): do not trap EINTR.
-
- * missing/flock.c (flock): returns the value from lockf(2)
- directly.
-
-Fri Mar 24 18:26:51 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * file.c (test_check): should have checked exact number of arguments.
-
-Fri Mar 24 21:02:11 2000 Koji Arai <JCA02266@nifty.ne.jp>
-
- * signal.c (trap): should treat some symbols as the signal.
-
-Fri Mar 24 06:58:03 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.8.
-
- * lib/net/http.rb: post, get2, post2, get_body
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: separate
- Command/Socket documentation.
-
-Thu Mar 23 02:26:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_fptr_finalize): fptr may be null.
-
- * io.c (rb_io_s_new): now calls `initialize'.
-
- * io.c (rb_io_initialize): actual open done in this method.
-
- * io.c (rb_file_initialize): ditto.
-
- * eval.c (rb_eval): class variables in singleton class definition
- is now handled properly (I hope).
-
-Wed Mar 22 21:49:36 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * st.c (st_delete_safe): skip already deleted entry.
-
- * hash.c (rb_hash_delete): modify brace miss.
-
-Wed Mar 22 08:53:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (exec_under): do not push cbase if ruby_cbase == under.
-
- * node.h (NEW_CREF0): preserve cbase nesting.
-
-Tue Mar 21 12:57:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * object.c (rb_class_s_new): Class::new should call `inherited'.
-
-Sat Mar 18 12:36:09 2000 Nobuyoshi Nakada <nobu.nokada@softhome.net>
-
- * eval.c (rb_backtrace, make_backtrace): removed unused variable
- `lev'.
-
- * eval.c (rb_attr): calls `method_added' at attribute definition.
-
- * eval.c (rb_mod_modfunc): calls `singleton_method_added' while
- `module_function'.
-
- * eval.c (rb_eval): parameter to `method_added' and
- `singleton_method_added' is Symbol.
-
- * eval.c (Init_eval): caches IDs for `method_added' and
- `singleton_method_added'.
-
-Sat Mar 18 11:25:10 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (rescue): allows `rescue Error in foo'. experimental.
- which is better this or preparing alias `exception' for `$!'?
-
-Fri Mar 17 15:02:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * variable.c (rb_autoload_id): defining new autoload should be
- prohibited for $SAFE > 4.
-
- * variable.c (rb_autoload_load): autoload should be possible for
- $SAFE > 4.
-
- * eval.c (call_trace_func): should handle T_ICLASS properly.
-
-Fri Mar 17 14:34:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (str_gsub): forgot to initialize str->orig.
-
-Fri Mar 17 01:24:59 2000 Dave Thomas <Dave@thomases.com>
-
- * string.c (rb_str_clone): forgot to copy str->orig if STR_NO_ORIG
- is set by Array#pack.
-
-Wed Mar 15 21:25:04 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * array.c (rb_ary_join): 'result' is always duplicated
- before concat string.
-
-Wed Mar 15 17:26:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * hash.c (rb_hash_s_create): unexpected recursive call removed.
- this bug was found by Satoshi Nojo <nojo@t-samukawa.or.jp>.
-
-Wed Mar 15 13:12:39 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (Init_Thread): Thread.join removed finally.
-
- * string.c (rb_str_chomp_bang): forgot to call rb_str_modify().
-
-Mon Mar 13 16:12:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (block_pass): distinguish real orphan block and still
- on-stack block passed by block argument.
-
-Mon Mar 13 00:20:25 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (f_norm_arg): proper error message when constant comes
- in formal argument list. this message is suggested by Muvaw
- Pnazte <bugathlon@yahoo.com>.
-
- * eval.c (rb_f_raise): proper error message when the first
- argument is not an exception class/object.
-
- * string.c (rb_str_dup): dup now postpone buffer copy as long as
- possible. performance improved by lazy copying.
-
-Sun Mar 12 13:58:52 2000 Koji Arai <JCA02266@nifty.ne.jp>
-
- * signal.c (rb_f_kill): should treat some symbols as the signal.
-
-Sat Mar 11 22:03:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (rb_str_gsub): performance tune by avoiding buffer copy.
-
- * eval.c (rb_f_missing): check if argv[0] is ID.
-
-Sat Mar 11 15:49:41 2000 Tadayoshi Funaba <tadf@kt.rim.or.jp>
-
- * struct.c (rb_struct_aref): struct aref by symbol.
-
-Sat Mar 11 05:07:11 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * process.c (proc_setpriority): should return 0, not nil.
-
- * process.c (proc_setpgid): ditto.
-
-Fri Mar 10 18:14:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * file.c (path_check_1): confusing buf and path. this bug found
- by <decoux@moulon.inra.fr>.
-
-Fri Mar 10 09:37:49 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * MANIFEST: add beos/GNUmakefile.in.
- * configure.in: support BeOS R4.5.2 (Intel).
- * beos/GNUmakefile.in: new file to support BeOS R4.5.2 (Intel).
-
-Thu Mar 9 11:13:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * regex.c (re_compile_fastmap): fixed embarrassing brace bug.
-
-Thu Mar 9 01:36:32 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * missing/flock.c: emulate missing flock() with fcntl().
-
-Thu Mar 9 00:29:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * object.c (sym_to_s): returns ":sym".
-
- * object.c (sym_id2name): separated from to_s; returns "sym".
-
-Wed Mar 8 19:16:19 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.7.
-
- * lib/net/http.rb (connecting): returns header
-
-Wed Mar 8 02:08:43 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y: escape expansion too early.
-
- * string.c (rb_f_scan): Kernel#scan added.
-
- * regex.c (re_compile_pattern): support \cX et al.
-
-Tue Mar 7 01:44:27 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (set_stdin): simplified procedure, allows $stdin = DATA;
- experimental.
-
- * io.c (set_outfile): ditto.
-
- * re.c (Init_Regexp): new method Regexp#last_match added; it's an
- alternative for $~.
-
- * configure.in (DEFAULT_KCODE): KCODE_NONE should be the default.
-
- * dir.c (dir_s_rmdir): should return 0 on success.
-
- * signal.c: remove CWGUSI support.
-
-Mon Mar 6 12:28:37 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * marshal.c (w_symbol): support symbol object.
-
- * util.c: make symbol as separated class.
-
- * error.c (Init_Exception): new exception RangeError.
-
- * ext/socket/socket.c (ip_addrsetup): should check length of hostname.
-
- * ext/socket/socket.c (ip_addrsetup): check newline at the end of
- hostname. These fixes suggested by Muvaw Pnazte <bugathlon@yahoo.com>.
-
-Sun Mar 5 20:35:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * ext/Win32API/Win32API.c (Win32API_initialize): should call
- LoadLibrary() everytime and should assign the hdll to Win32API
- object(protect the hdll from GC).
-
-Sun Mar 5 18:49:06 2000 Nakada.Nobuyoshi <nobu.nokada@softhome.net>
-
- * misc/ruby-mode.el (ruby-parse-region): not treat method `begin'
- and `end' as reserved words.
-
- * misc/ruby-mode.el (ruby-font-lock-docs): ignore after `=begin'
- and `=end'.
-
- * misc/ruby-mode.el (ruby-font-lock-keywords, hilit-set-mode-patterns):
- added `yield' to keywords.
-
- * misc/ruby-mode.el (ruby-font-lock-keywords, hilit-set-mode-patterns):
- matches keywords at end of buffer.
-
-Sun Mar 5 18:08:53 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.6.
-
- * lib/net/http.rb: allow to omit 'start'
-
-Tue Feb 29 01:08:26 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * range.c (range_initialize): initialization done in `initialize';
- `initialize' should not be called more than once.
-
- * object.c (Init_Object): default `initialize' should take zero
- argument.
-
- * time.c (time_s_new): call `initialize' in Time::new.
-
-Sat Feb 26 22:39:31 2000 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
-
- * string.c (rb_str_times): fix String#* with huge string.
-
-Sat Feb 26 00:14:59 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * dir.c (dir_s_new): call `initialize' in Dir::new.
-
-Fri Feb 25 23:01:49 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * ruby.h: export ruby_safe_level by EXTERN for mswin32.
- * win32/ruby.def: regular maintenance.
-
-Fri Feb 25 22:12:46 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_reopen): IO#reopen should accept path as well.
-
- * string.c (rb_str_s_new): call `initialize' in String::new.
-
- * hash.c (rb_hash_s_new): call `initialize' in Hash::new.
-
- * array.c (rb_ary_s_new): call `initialize' in Array::new.
-
-Fri Feb 25 12:50:20 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_thread_start_timer): interval changed to 10ms from 50ms.
-
-Fri Feb 25 06:42:26 2000 GOTOU YUUZOU <gotoyuzo@notwork.org>
-
- * ext/socket/socket.c (ip_addrsetup): hostp should remain NULL if
- host is nil.
-
-Thu Feb 24 16:53:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_thread_schedule): priority check for sleep expired
- threads needed.
-
-Wed Feb 23 14:22:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * array.c (rb_ary_join): forgot to initialize a local variable
- `taint'.
-
-Tue Feb 22 07:40:55 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * re.c (Init_Regexp): renamed to MatchData, old name MatchingData
- remain as alias.
-
-Tue Feb 22 00:20:21 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.5.
-
- * lib/net/session.rb: rename to protocol.rb
-
- * lib/net/protocol.rb: ProtocolSocket -> Net::Socket
-
- * lib/net/protocol.rb: Net::Socket#write, write_pendstr
- can take block
-
- * lib/net/smtp.rb: new methods SMTP#ready SMTPCommand#write_mail
-
- * lib/net/pop.rb: POPMail#pop can take block
-
-Sat Feb 19 23:58:51 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * regex.c (re_match): pop_loop should not pop at forward jump.
-
-Fri Feb 18 17:15:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (method_clone): method objects are now clonable.
-
-Fri Feb 18 00:27:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * variable.c (rb_shared_variable_declare): shared variable (aka
- class/module variable) introduced. prefix `@@'. experimental.
-
- * class.c (rb_scan_args): new format char '&'.
-
-Thu Feb 17 19:09:05 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * win32/win32.c (mypopen): don't close handle if it is not assigned.
- * win32/win32.c (my_open_osfhandle): support O_NOINHERIT flag.
- * win32/win32.c (win32_getcwd): rename getcwd to win32_getcwd
- in order to avoid using the C/C++ runtime DLL's getcwd.
- Use CharNext() to process directory name.
- * win32/win32.h: map getcwd to win32_getcwd.
-
-Wed Feb 16 00:32:49 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (method_arity): nd_rest is -1 for no rest argument.
-
- * process.c (proc_waitpid): returns nil when waitpid(2) returns 0.
-
-Tue Feb 15 01:47:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * process.c (rb_f_waitpid): pid_t should be signed.
-
-Mon Feb 14 13:59:01 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (yylex): yylex yields wrong tokens for `:foo=~expr'.
-
- * ruby.c (load_file): exit if reading file is empty.
-
-Mon Feb 14 03:34:52 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (yylex): `foo.bar=1' should be <foo><.><bar><=><1>,
- not <foo><.><bar=><1>.
-
- * eval.c (rb_thread_restore_context): process according to
- RESTORE_* is moved after longjmp().
-
- * eval.c (thread_switch): new function to process RESTORE_*.
-
-Sun Feb 13 16:19:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * ruby.c (require_libraries): don't access freed memory.
-
- * ruby.c (add_modules): ditto.
-
-Fri Feb 11 12:06:22 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (parse_quotedwords): %w() need to split not only by mere
- spaces, but by all whitespaces.
-
-Thu Feb 10 02:12:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (rb_str_index_m): did not support negative offset.
-
-Wed Feb 9 21:54:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * ext/socket/getaddrinfo.c: gcc --traditional support.
- Rearrange headers to work AC_C_CONST.
- * ext/socket/getnameinfo.c: ditto.
- * ext/socket/socket.c: mswin32: use double instead of long long.
-
-Wed Feb 9 16:30:41 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * numeric.c (num_coerce): should return [y, x].
-
-Wed Feb 9 11:07:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * ruby.c (ruby_prog_init): loadpath structure changed.
-
-Tue Feb 8 02:07:33 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * regex.c (re_search): optimize for \G at top.
-
- * regex.c (re_compile_pattern): \G introduced.
-
- * regex.c (re_match): ditto.
-
- * string.c (str_sub_bang): old behavior restored: bang method
- returns nil if string not changed.
-
- * regex.c (re_compile_pattern): support independent subexpression
- `(?>pattern)'.
-
- * regex.c (re_match): ditto.
-
-Mon Feb 7 15:51:08 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * regex.c (re_match): now understands interrupts under Ruby.
-
-Mon Feb 7 07:51:52 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * array.c (rb_ary_uniq_bang): always return an Array.
-
- * array.c (rb_ary_compact_bang): ditto.
-
- * array.c (rb_ary_flatten_bang): ditto.
-
- * hash.c (rb_hash_reject): returns a Hash, not an Array.
-
- * hash.c (env_reject): ditto.
-
-Fri Feb 4 10:20:25 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (scan_once): scan now leaves information about the last
- successful pattern match in $&.
-
- * io.c (rb_io_close): should not check closed IO.
-
-Fri Feb 4 05:44:01 2000 Kentaro Inagaki <inagaki@tg.rim.or.jp>
-
- * ext/socket/socket.c (s_recv): TRAP_BEG after retry entry.
-
-Wed Feb 2 22:33:45 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * eval.c (rb_thread_start): receives argument from outside, like
- `Thread::start(1,2,3){|a,b,c| ... }'.
-
-Wed Feb 2 22:14:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * re.c (rb_reg_regsub): should check regs->num_regs.
-
- * re.c (rb_reg_search): remove matchcache, use static struct
- re_register instead.
-
- * re.c (match_getter): avoid cloning match data.
-
-Wed Feb 2 17:12:15 2000 Dave Thomas <Dave@Thomases.com>
-
- * samples/eval.rb: Rescue new ScriptError exception
-
-Wed Feb 2 02:06:07 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (str_gsub_bang): gsub! now leaves information about the
- last successful pattern match in $&.
-
-Mon Jan 31 15:24:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (str_sub_bang): bang method returns string always.
- experimental.
-
-Sun Jan 30 17:58:09 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * eval.c: arrange to use setitimer(2) for BOW, DJGPP
-
- * defines.h: ditto. use random(3) on cygwin b20.1.
-
-Sun Jan 30 17:20:16 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * eval.c: use getrlimit(2) on DJGPP.
-
-Thu Jan 27 01:27:10 2000 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
-
- * dir.c (glob): glob pattern "/*" did not match.
-
-Wed Jan 26 22:30:47 2000 Shigeo Kobayashi <shigeo@tinyforest.gr.jp>
-
- * numeric.c (flo_modulo): wrong result for negative modulo.
-
-Wed Jan 26 02:01:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * file.c (test_c): should use S_ISCHR.
-
- * file.c (rb_stat_c): ditto.
-
- * string.c (rb_str_each_line): should propagate tainting.
-
-Tue Jan 25 04:01:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * object.c (rb_obj_freeze): all objects made freezable.
-
-Tue Jan 25 00:37:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * configure.in: use AC_CHECK_TOOL for cross compiling.
-
-Mon Jan 24 19:01:54 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * array.c (rb_protect_inspect): should be checked by id of
- objects; not by object themselves.
-
-Mon Jan 24 18:48:08 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * eval.c (rb_eval): too many warnings; warned on every method
- overriding. should be on method discarding.
-
-Mon Jan 24 02:56:44 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (yylex): -2.abs should be `(-2).abs' to accomplish the
- principle of less surprise. `+2' too.
-
- * eval.c (rb_eval): when defining class is already there, and
- superclass differ, throw away the old class.
-
- * variable.c (rb_const_set): gives warning again on constant
- redefinition.
-
- * error.c (Init_Exception): SyntaxError, NameError, LoadError and
- NotImplementError are subclasses of ScriptError<Exception, not
- StandardError. experimental.
-
-Sat Jan 22 00:00:41 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (parse_quotedwords): no longer use `String#split'.
- and enable space escape within quoted word list.
- e.g. %w(a\ b\ c abc) => ["a b c", "abc"].
-
- * string.c (rb_str_slice_bang): new method `slice!'.
-
-Fri Jan 21 21:56:08 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.4.
-
- * lib/net/http.rb: can receive messages which have
- no Content-Length:.
-
-Fri Jan 21 16:15:59 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (thgroup_s_new): new class ThreadGroup.
-
-Tue Jan 18 12:24:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * struct.c (Init_Struct): remove Struct's own hash and eql?.
-
-Sat Jan 15 22:21:08 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
-
- * eval.c (search_method): argument klass may be 0.
-
-Sat Jan 15 15:03:46 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * enum.c (enum_index): remove this method.
-
- * enum.c: remove use of pointers to local variables. find,
- find_all, min, max, index, member?, each_with_index,
-
- * eval.c (massign): multiple assignment does not use to_a anymore.
- experimental.
-
-Fri Jan 14 12:22:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (rb_str_replace): use memmove instead of memcpy for
- overwrapping strings (e.g. a[1] = a).
-
-Thu Jan 13 11:12:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (arg_add): use new node, ARGSPUSH.
-
-Mon Jan 10 18:32:28 2000 Koji Arai <JCA02266@nifty.ne.jp>
-
- * marshal.c (w_object): forgot an argument to call w_ivar().
-
-Sun Jan 9 18:13:51 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
-
- * random.c: first was not defined unless HAVE_RANDOM.
-
-Sat Jan 8 19:02:49 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * io.c (rb_io_sysread): raise IOError for buffered IO.
-
- * ext/socket/socket.c (s_recv): ditto.
-
-Fri Jan 7 00:59:29 2000 Masahiro Tomita <tommy@tmtm.org>
-
- * io.c (io_fread): TRAP_BEG/TRAP_END added around getc().
-
-Thu Jan 6 00:39:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * random.c (rb_f_rand): should be initialized unless srand is
- called before.
-
-Wed Jan 5 16:59:34 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
- * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.3.
-
- * lib/net/session.rb: Session -> Protocol, ...
-
- * lib/net/http.rb: HTTPCommand implementation was changed.
-
-Wed Jan 5 02:14:46 2000 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
-
- * parse.y: Fix SEGV on empty parens with UMINUS or UPLUS.
-
-Tue Jan 4 22:25:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (stmt): `() while cond' dumped core.
-
-Tue Jan 4 06:04:14 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * configure.in: modify for cross-compiling.
- use target_* instead of host_*.
- use AC_CANONICAL_TARGET.
-
- * Makefile.in: ditto.
-
- * cygwin/GNUmakefile.in: ditto.
-
-Sat Jan 1 13:26:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_yield_0): force_recycle ruby_dyna_vars to gain
- performance.
-
- * array.c (rb_ary_delete_at_m): takes same argument pattern with
- rb_ary_aref.
-
-Sat Jan 1 10:12:26 2000 Nobuyoshi Nakada <nobu.nokada@softhome.net>
-
- * ruby.h,util.c (rb_special_const_p): peep hole optimization.
-
- * ruby.h,util.c (rb_test_false_or_nil): removed.
-
- * ruby.h (RTEST, SPECIAL_CONST_P): peep hole optimization.
-
- * ruby.h (FL_ABLE, FL_SET, FL_UNSET, FL_REVERSE): made expressions
- not statements.
-
- * ruby.h (OBJ_INFECT): newly added macro which copies taint from
- `s' to `x'.
-
-Sat Jan 1 02:04:18 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_thread_safe_level): new method.
-
- * eval.c (rb_yield_0): recycle dyna_var_map to reduce object
- allocation.
-
-Fri Dec 31 00:52:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c: thread independent trace_func not needed.
-
-Thu Dec 30 14:47:31 1999 akira yamada <akira@ruby-lang.org>
-
- * configure.in: specifies -soname in LIBRUBY_DLDFLAGS on linux
- platforms.
-
-Thu Dec 30 10:51:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * array.c,io.c,hash,c,re.c,string.c: `_m' suffix instead of
- `_method' for wrapper functions to implement method,
- e.g. `rb_str_join_m()'.
-
-Thu Dec 30 02:08:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * bignum.c (rb_cstr2inum): non-numeric format check added.
- currently it works only with base == 0 (i.e. Integer()).
-
- * bignum.c (rb_str2inum): now takes VALUE to 1st argument. null
- byte check added.
+ * win32/Makefile.sub: ditto.
- * array.c (rb_ary_replace): unless replacement is an array,
- replacement shall be converted to array by `[replacement]', not
- by `replacement.to_a'.
+ * wince/Makefile.sub: ditto.
- * array.c (rb_ary_plus): right operand must be an array.
+Sun Apr 11 19:12:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (rb_ary_concat): argument must be an array.
+ * ruby.c (require_libraries): restore source file/line after
+ statically linked extensions initialized. [ruby-dev:23357]
-Mon Dec 27 12:35:47 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Sun Apr 11 10:47:04 2004 Dave Thomas <dave@pragprog.com>
- * ext/socket/socket.c (sock_finalize): mswin32: fix socket handle leak.
+ * lib/rdoc/code_objects.rb (RDoc::TopLevel::add_class_or_module): Toplevel
+ classes and modules are a special case too... (handle extending existing
+ classes with or without :enddoc:)
- * win32/win32.c (myfdclose): ditto.
+Sat Apr 10 23:51:13 2004 Dave Thomas <dave@pragprog.com>
-Sun Dec 26 23:15:13 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/rdoc/code_objects.rb (RDoc::Context::add_to): Implementation of :enddoc:
+ made one too many assumptions...
- * win32/win32.c (mypopen): raise catchable error instead of rb_fatal.
- * win32/win32.c (mypclose): fix process handle leak.
+Sat Apr 10 00:00:19 2004 Dave Thomas <dave@pragprog.com>
-Sun Dec 26 16:17:11 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/rdoc/markup/simple_markup/inline.rb: Fix problem
+ with \_cat_<b>dog</b>
- * ext/Win32API/Win32API.c (Win32API_initialize): use UINT2NUM
- instead of INT2NUM to set __dll__ and __proc__.
+Wed Apr 7 00:19:50 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Sat Dec 25 00:08:59 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+ * lib/rinda/rinda.rb: fix hash tuple bug.
- * ext/Win32API/Win32API.c (Win32API_Call): remove 'dword ptr'
- from _asm.
+ * lib/rinda/tuplespace.rb: ditto.
-Fri Dec 24 10:26:47 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
+ * test/rinda/test_rinda.rb
- * win32/win32.h: use "C++" linkage.
+Tue Apr 6 18:24:18 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Dec 24 02:00:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * io.c (rb_io_reopen): should use rb_io_check_io().
- * eval.c (THREAD_ALLOC): should initialize th->trace.
+Tue Apr 6 16:46:09 2004 Tanaka Akira <akr@m17n.org>
-Fri Dec 24 00:43:39 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+ * configure.in: check the size of time_t.
- * io.c (pipe_open): check for `fptr->f == NULL'.
- * win32/win32.c (mypopen): STDERR does not work during ` function.
+ * time.c (time_add): new function.
+ (time_plus): use time_add.
+ (time_minus): use time_add.
-Wed Dec 22 22:50:40 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Tue Apr 6 13:21:30 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.2.
+ * ext/socket/socket.c (make_hostent): must return value.
- * lib/net/http.rb: HTTP support is enhanced a little
+Tue Apr 6 00:05:30 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/net/http.rb: support proxy
+ * lib/rinda/rinda.rb: add require 'drb/drb'
-Tue Dec 21 17:21:28 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
+Mon Apr 5 08:18:23 2004 Dave Thomas <dave@pragprog.com>
- * ext/socket/socket.c (sock_finalize): mswin32: fix FILE* leak.
+ * lib/rdoc/rdoc.rb: Remove leading ./ from file names so that cross
+ references work properly.
-Tue Dec 21 05:33:56 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Sun Apr 4 20:33:42 2004 Minero Aoki <aamine@loveruby.net>
- * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.1.
+ * eval.c (Init_load): make $LOADED_FEATURES built-in.
+ [ruby-dev:23299]
- * lib/net/http.rb: support HTTP chunk
+ * ruby.c (ruby_prog_init): make $PROGRAM_NAME built-in.
-Mon Dec 20 19:08:12 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * lib/English.rb: remove $LOADED_FEATURES and $PROGRAM_NAME.
- * file.c (rb_file_s_expand_path): handle dir separator correctly.
+Sun Apr 4 14:01:20 2004 Dave Thomas <dave@pragprog.com>
-Sun Dec 19 22:56:31 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+ * lib/rdoc/options.rb (Options::parse): Allow multiple -x options to RDoc.
+ Fix bug where files weren't being excluded properly
- * lib/find.rb: support dosish root directory.
- * win32/Makefile: ditto.
- * win32/config.status: ditto.
- * win32/win32.c (opendir): ditto.
- * win32/win32.c (opendir): use CharPrev() to get last character
- of the directory name.
+Sat Apr 3 17:11:05 2004 why the lucky stiff <why@ruby-lang.org>
-Sat Dec 18 03:00:01 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/syck.h: version 0.43.
- * file.c (path_check_1): check should be done by absolute path.
+ * ext/syck/lib/gram.c: allow root-level inline collections.
+ [ruby-talk:94922]
- * marshal.c (r_ivar): should restore generic_ivar too.
+ * lib/yaml/rubytypes.rb (Symbol#to_yaml): emit symbols as implicits.
+ [ruby-talk:94930]
- * marshal.c (w_ivar): should dump generic_ivar too.
+ * ext/syck/bytecode.c: turn off default implicit typing.
-Fri Dec 17 22:46:46 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/syck/implicit.c: detect base60 integers.
- * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.0.
+ * ext/syck/rubyext.c: handle base60, as well as hex and octal
+ with commas. implicit typing of ruby symbols.
- * lib/net/http.rb: test release
+Fri Apr 2 17:27:17 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/session.rb: support class swapping
+ * eval.c (top_include): include in the wrapped load is done for
+ the wrapper, not for a singleton class for wrapped main.
+ [ruby-dev:23305]
- * lib/net/session.rb: Socket#flush_rbuf
+Fri Apr 2 15:13:44 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * lib/net/session.rb: doquote -> Net.quote
+ * bignum.c (rb_big_eq): use temporary double variable to save the
+ result (internal float register may be bigger than 64 bits, for
+ example, 80 bits on x86). [ruby-dev:23311]
-Fri Dec 17 19:27:43 1999 IWAMURO Motonori <iwa@mmp.fujitsu.co.jp>
+Fri Apr 2 14:35:26 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_load): should initialize ruby_frame->last_class.
+ * eval.c (block_pass): should generate unique identifier of the
+ pushing block. [ruby-talk:96363]
-Wed Dec 15 01:35:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Apr 2 07:31:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ruby.c (proc_options): option to change directory changed to
- `-C' like tar.
+ * ext/socket/socket.c (make_hostent): fix memory leak, based on
+ the patch from HORIKAWA Hisashi <vzw00011@nifty.ne.jp>.
- * ruby.c (proc_options): argv boundary check for `-X'.
+Thu Apr 1 22:55:33 2004 Dave Thomas <dave@pragprog.com>
-Mon Dec 13 15:15:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/parsers/parse_rb.rb: Allow rdoc comments in
+ =begin rdoc/=end
- * regex.c (re_adjust_startpos): separate startpos adjustment
- because of major performance drawback.
+ * lib/rdoc/parsers/parse_rb.rb: Fix problem with comment in
+ top-level method being taken as file comment.
- * class.c (rb_singleton_class): tainted status of the singleton
- class must be synchronized with the object.
+Thu Apr 1 22:55:04 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (rb_thread_schedule): implement thread priority.
+ * lib/rdoc/ri/ri_options.rb: Fix undefined variable warning.
-Sat Dec 11 03:34:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Apr 1 19:58:37 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * gc.c (mark_hashentry): key should be VALUE, not ID.
+ * lib/soap/mapping/{factory.rb,registry.rb}: fixed illegal mapped URI
+ object with soap/marshal.
+ added URIFactory class for URI mapping. BasetypeFactory checks
+ instance_variables when original mapping is not allowed (ivar must
+ be empty). Instance of URI have instance_variables but it must be
+ llowed whenever original mapping is allowed or not.
- * io.c (argf_eof): should check next_p too.
+ * lib/xsd/datatypes.rb: check the smallest positive non-zero
+ single-precision float exactly instead of packing with "f".
+ [ruby-talk:88822]
-Thu Dec 9 18:09:13 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/soap/mapping/rubytypeFactory.rb: should not dump singleton class.
+ [ruby-dev:22588]
+ c = class << Object.new; class C; self; end; end; SOAPMarshal.dump(c)
- * error.c (exc_set_backtrace): forgot to declare a VALUE argument.
+Wed Mar 31 19:06:23 2004 Tanaka Akira <akr@m17n.org>
-Thu Dec 9 14:19:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * time.c (year_leap_p): new function.
+ (timegm_noleapsecond): ditto.
+ (search_time_t): use timegm_noleapsecond instead of
+ mktime for first guess.
- * object.c (rb_obj_taint): explicit tainting must be prohibited at
- level 4 to prevent polluting trusted object by untrusted code.
+Wed Mar 31 12:04:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * file.c: file operations (stat, lstat, chmod, chown, umask,
- truncate, flock) are prohibited in level 2 (was level 4).
+ * lib/delegate.rb (DelegateClass): define internal methods of the
+ result class, but not metaclass of the caller. [ruby-talk:96156]
-Wed Dec 8 11:48:23 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * intern.h: provide proper prototypes. [ruby-core:02724]
- * eval.c (rb_f_require): prohibiting require() in the secure mode
- cause serious autoloading error.
+ * ruby.h: missing.h is now prerequisite to intern.h.
- * variable.c (rb_obj_instance_variables): don't need to prohibit
- to get list of instance variable names of untainted objects.
+Tue Mar 30 20:25:34 2004 Tanaka Akira <akr@m17n.org>
- * variable.c (rb_ivar_get): don't need to prohibit to get instance
- variables of untainted objects.
+ * time.c (search_time_t): limit guess range by mktime if it is
+ available. [ruby-dev:23274]
- * variable.c (rb_mod_remove_const): should prohibit constant
- removals too.
+Sun Mar 28 14:16:59 2004 Minero Aoki <aamine@loveruby.net>
-Wed Dec 8 09:23:01 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/net/pop.rb (auth): failed when account/password include "%".
+ [ruby-talk:95933]
- * eval.c (rb_eval): should try autoloading before defining
- class/module at the toplevel.
+Sat Mar 27 21:40:41 2004 Tanaka Akira <akr@m17n.org>
-Tue Dec 7 22:15:30 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/open-uri.rb: permit extra semicolon in content-type field.
- * configure.in: Modified rb_cv_rshift_sign detect routine and
- more simple/fast RSHIFT() for hpux-10.x.
+Sat Mar 27 10:40:48 2004 Tanaka Akira <akr@m17n.org>
-Tue Dec 7 11:16:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * (lib/pp.rb, lib/prettyprint.rb): define seplist in PP::PPMethods
+ instead of PrettyPrint.
- * eval.c (Init_eval): calculate stack limit from rlimit where
- getrlimit(2) is available.
+Thu Mar 25 23:28:52 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Dec 7 09:57:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * time.c (time_overflow_p): backport 1.9 usec overflow function.
+ (ruby-bugs PR#1307)
- * file.c (rb_file_ftype): should have removed mode_t.
+Thu Mar 25 23:15:24 2004 Dave Thomas <dave@pragprog.com>
-Mon Dec 6 15:55:30 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/rdoc/ri/ri_options.rb (RI::Options::show_version):
+ Add --version option
- * numeric.c (fix_rshift): Fix -1 >> 32 returned 0 (should be -1).
+Thu Mar 25 04:16:18 2004 Dave Thomas <dave@pragprog.com>
- * numeric.c (fix_rshift): Fix 1 >> -1 returned 0 (should be 2).
+ * lib/rdoc/ri/ri_options.rb (RI::Options): Add the --list-names option,
+ which dumps our all known names
-Mon Dec 6 11:47:23 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Mar 25 03:57:47 2004 Dave Thomas <dave@pragprog.com>
- * sprintf.c (rb_f_sprintf): formatted string must be tainted if
- any of parameters is a tainted string.
+ * lib/rdoc/ri/ri_util.rb (NameDescriptor::initialize): No longer
+ allow nested classes to be designated using "."--you must
+ now use "::"
- * file.c (rb_file_s_expand_path): expanded file path need not to
- be tainted always.
+Thu Mar 25 02:00:18 2004 Dave Thomas <dave@pragprog.com>
-Sun Dec 5 20:25:29 1999 Katsuhiro Ueno <unnie@blue.sky.or.jp>
+ * lib/rdoc/generators/template/html/one_page_html.rb (Page):
+ Fix to work with C modules.
- * eval.c (Init_Proc): simple typo.
+Wed Mar 24 21:17:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * gc.c (add_heap): sizeof(RVALUE*), not sizeof(RVALUE).
+ * lib/uri.rb: Documented (thanks Dmitry V. Sabanin).
+ * lib/uri/common.rb: Ditto.
+ * lib/uri/ftp.rb: Ditto.
+ * lib/uri/generic.rb: Ditto.
+ * lib/uri/http.rb: Ditto.
+ * lib/uri/https.rb: Ditto.
+ * lib/uri/ldap.rb: Ditto.
+ * lib/uri/mailto.rb: Ditto.
+ (All backported from 1.9)
-Sat Dec 4 01:40:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Mar 24 18:48:26 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_search): adjust startpos for multibyte match unless
- the first pattern is forced byte match.
+ * lib/mkmf.rb ($ruby, $topdir, $hdrdir): should not be affected by
+ DESTDIR after installed.
- * bignum.c (rb_big_rand): should not use rand/random where drand48
- may be available. RANDOM_NUMBER should be provided from outside.
+ * lib/mkmf.rb (RUBY): / is not recognized as path separator on
+ nmake/bmake. [ruby-list:39388]
-Fri Dec 3 09:54:59 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (init_mkmf): $INCFLAGS also should be lazy-evaluated.
- * ruby.c (moreswitches): there may be trailing garbage at #!
- line.
+Wed Mar 24 12:32:56 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (rb_f_require): should check require 'feature.o' too.
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::handle_class_module):
+ Don't document methods if we don't know for sure the
+ class or module.
-Thu Dec 2 11:58:15 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_class):
+ Don't store documentation for singleton classes if we
+ don't know the real class.
- * eval.c (rb_thread_loading): should maintain loading_tbl.
+Wed Mar 24 11:11:26 2004 Dave Thomas <dave@pragprog.com>
-Thu Dec 2 10:21:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/generators/html_generator.rb (Generators::HTMLGenerator::load_html_template):
+ Allow non-RDoc templates by putting a slash in the template name
- * eval.c (rb_thread_loading_done): wrong parameter to st_delete().
+Mon Mar 22 16:19:57 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Wed Dec 1 11:24:06 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * ruby.1: add -width option to .Bl for old groff.
- * ruby.c (process_sflag): process -s properly (should not force `--').
+Sun Mar 21 21:11:16 2004 Keiju Ishitsuka <keiju@ishitsuka.com>
-Wed Dec 1 09:47:33 1999 Kazunori NISHI <kazunori@swlab.csce.kyushu-u.ac.jp>
+ * lib/shell/*: bug fix for Shell#system(command_line_string).
- * string.c (rb_str_split_method): should increment end too.
+Sat Mar 20 20:57:10 2004 David Black <dblack@wobblini.net>
-Tue Nov 30 18:00:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/scanf.rb: Backported 1.9 branch
+ modifications/corrections to 1.8 branch
- * marshal.c: MARSHAL_MINOR incremented; format version is 4.2.
+Sat Mar 20 23:51:03 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * marshal.c (w_object): distinguish class and module.
+ * eval.c (rb_require_safe): preserve old ruby_errinfo.
+ [ruby-talk:95409]
- * marshal.c (w_object): save hash's default value.
+ * eval.c (rb_f_raise): should not clear backtrace information if
+ exception object already have one.
- * marshal.c (r_object): restore hash's default value.
+Sat Mar 20 15:25:36 2004 Dave Thomas <dave@pragprog.com>
-Tue Nov 30 01:46:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/generators/template/html/html.rb (RDoc::Page): Force
+ page background to white.
- * re.c (rb_reg_source): generated source string must be tainted if
- regex is tainted.
+Sat Mar 20 09:52:33 2004 Tadayoshi Funaba <tadf@dotrb.org>
- * file.c (rb_file_s_basename): basename should not be tainted
- unless the original path is tainted.
+ * lib/date.rb, lib/date/format.rb: _parse() now accepts fractional
+ part of second minute that follows a comma or a full stop.
- * file.c (rb_file_s_dirname): ditto.
+Fri Mar 19 01:55:57 2004 Mauricio Fernandez <batsman.geo@yahoo.com>
-Mon Nov 29 20:42:13 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * io.c (rb_io_sync): need not to check writable. [ruby-core:02674]
- * file.c (stat_new): Struct::Stat -> File::Stat; Stat is no longer
- a Struct.
+Thu Mar 18 21:44:38 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Mon Nov 29 15:28:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/drb/drb.rb: backport drb.rb 1.16.
- * variable.c (rb_path2class): evaluated value from path should be
- module or class.
+Thu Mar 18 16:22:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Nov 26 18:12:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (proc_eq): avoid false positive by using scope and
+ dyna_vars. no longer use frame.uniq.
- * eval.c (rb_exec_end_proc): should remove only end_procs defined
- within load wrapper.
+Wed Mar 17 14:44:43 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * eval.c (rb_load): save and restore ruby_wrapper around loading.
+ * dir.c (range): fix possible "\0" overrun. (in case of "\0-")
- * eval.c (rb_mark_end_proc): mark end procs registered by END{} or
- at_exit{}.
+Mon Mar 15 07:39:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_set_end_proc): should not call rb_global_variable()
- on heap address; it crashed mod_ruby.
+ * eval.c (rb_yield_0): should not re-submit TAG_BREAK if this
+ yield is not break destination. [ruby-dev:23197]
-Mon Nov 22 14:07:24 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Sat Mar 13 14:28:16 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * ruby.c (proc_options): variable e_script should be visited by
- garbage collector.
+ * test/drb/test_drbssl.rb: rescue LoadError. (Barkport from main
+ trunk)
-Sat Nov 20 10:10:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/drb/test_drbunix.rb: ditto.
- * hash.c (inspect_i): value may be nil, check revised.
+Wed Mar 10 22:28:09 2004 Minero Aoki <aamine@loveruby.net>
-Fri Nov 19 18:06:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/fileutils.rb (remove_dir): should handle symlink correctly.
+ This patch is contributed by Christian Loew. [ruby-talk:94635]
+ (Backport from main trunk)
- * dir.c (glob): recursive wildcard match by `**' ala zsh.
+Wed Mar 10 16:28:42 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Nov 19 11:44:26 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * eval.c (return_jump): set return value to the return
+ destination. separated from localjump_destination().
- * variable.c: was returning void value.
+ * eval.c (break_jump): break innermost loop (or thread or proc).
-Fri Nov 19 03:57:22 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * eval.c (rb_yield_0): set exit_value for block break.
- * file.c: add methods Stat struct class to reduce stat(2).
+Wed Mar 10 15:58:43 2004 Ryan Davis <ryand@zenspider.com>
-Thu Nov 18 16:18:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (eval): Only print backtrace if generating the backtrace
+ doesn't generate an exception. [ruby-core:02621]
- * lib/pstore.rb: mutual lock by flock(2).
+Tue Mar 9 13:04:26 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Nov 18 11:44:13 1999 Masahiro Tomita <tommy@tmtm.org>
+ * io.c (rb_io_ungetc): raise IOError instead of calling
+ rb_sys_fail(). [ruby-talk:23181]
- * io.c (read_all): should check bytes too.
+Mon Mar 8 19:32:28 2004 akira yamada <akira@ruby-lang.org>
-Wed Nov 17 02:40:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/uri/common.rb (URI::REGEXP::PATTERN::HOSTPORT): (?:#{PORT})
+ -> (?::#{PORT}). [ruby-dev:23170]
- * io.c (Init_IO): $defout (alias of $>) added.
+Mon Mar 8 15:31:41 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Tue Nov 16 09:47:14 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * dir.c (range): treat incomplete '[' as ordinary character (like
+ has_magic does).
- * lib/pstore.rb: add mutual lock using symlink.
+ * dir.c (range): Cancel above change. More discussion is needed.
-Mon Nov 15 16:50:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Mar 7 22:37:46 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * enum.c (enum_grep): non matching grep returns an empty array, no
- longer returns nil.
+ * test/drb/ut_drb.rb: use 'druby://localhost:0'. [ruby-dev:23078]
- * enum.c (enum_grep): grep with block returns collection of
- evaluated values of block over matched elements.
+ * test/drb/ut_eval.rb: ditto.
-Mon Nov 15 04:50:33 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * test/drb/ut_large.rb: ditto.
- * re.c (rb_reg_source): should not call rb_reg_expr_str()
- everytime.
+ * test/drb/ut_safe1.rb: ditto.
-Sat Nov 13 07:34:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/drb/ut_drb_drbssl.rb: use 'drbssl://localhost:0'.
- * variable.c (rb_mod_constants): traverse superclasses to collect
- constants.
+Sun Mar 7 16:22:26 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (assign): modified for shared variables.
+ * Makefile.in (lex.c): use $? instead of $<.
- * eval.c (rb_eval): search nested scope, then superclasses to
- assign shared variables within methods.
+Fri Mar 5 00:54:14 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (rb_eval): remove warnings from constants modification,
- because they are no longer constants.
+ * lib/test/unit.rb: MOve RDoc documentation so that you can
+ now say 'ri Test::Unit'
- * parse.y (node_assign): modified for shared variables.
+Tue Mar 2 12:32:59 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * parse.y (assignable): allow constant assignment in methods;
- constants should be called `shared variable'.
+ * win32/Makefile.sub, wince/Makefile.sub (config.h): shouldn't check
+ defined? NORETURN. [ruby-dev:23100]
-Fri Nov 12 23:52:19 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Mon Mar 1 12:24:10 2004 Dave Thomas <dave@pragprog.com>
- * process.c (rb_f_system): argument check for NT, __EMX__, DJGPP.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_alias):
+ Allow aliases to have parentheses
-Wed Nov 10 21:54:11 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+Sun Feb 29 23:14:53 2004 Dave Thomas <dave@pragprog.com>
- * hash.c (rb_any_cmp): Fixed return without value.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_class):
+ Handle :nodoc: on singleton classes.
-Wed Nov 10 17:57:06 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Feb 28 10:58:49 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * sprintf.c: incorporate <yasuf@big.or.jp>'s sprintf patch at
- [ruby-dev:7754].
+ * MANIFEST: add test_erb.rb
-Wed Nov 10 08:28:53 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/erb.rb, test/erb/test_erb.rb: don't forget filename,
+ if both filename and safe_level given. [ruby-dev:23050]
- * eval.c (rb_call0): supply class parameter for each invocation.
+Fri Feb 27 01:00:09 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Tue Nov 9 13:21:04 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/drb/drb.rb, test/drb/drbtest.rb: require drb/eq.rb by default
- * configure.in: AC_MINIX move to before AC_EXEEXT and AC_OBJEXT.
+Wed Feb 25 21:16:25 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Nov 8 19:52:29 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * instruby.rb (with_destdir): should return the given argument if no
+ DESTDIR is given.
- * configure.in: Renamed AC_CHAR_UNSIGNED to AC_C_CHAR_UNSIGNED.
+ * instruby.rb: use path name expansion of cmd.exe.
- * configure.in: Added default to AC_CHECK_SIZEOF().
+Wed Feb 25 09:35:22 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Mon Nov 8 14:28:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * error.c (NameError::Message): new class for lazy evaluation of
+ message to ensure replaced before marshalling. merge from HEAD.
+ (ruby-bugs-ja:PR#588)
- * parse.y (stmt): rescue modifier added to the syntax.
+ * eval.c (rb_method_missing): use NameError::Message. merge from
+ HEAD. (ruby-bugs-ja:PR#588)
- * keywords: kRESCUE_MOD added.
+Tue Feb 24 18:59:37 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * eval.c (rb_f_eval): fake outer scope when eval() called without
- bindings.
+ * dir.c (glob_helper): '**/' should not match leading period
+ unless File::FNM_DOTMATCH is set. (like '*/') [ruby-dev:23014]
- * eval.c (rb_f_binding): should copy last_class in the outer frame too.
+Tue Feb 24 13:22:21 2004 Dave Thomas <dave@pragprog.com>
-Sun Nov 7 18:31:04 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+ * lib/rdoc/rdoc.rb (RDoc::RDoc::normalized_file_list): Attempt to get better
+ heuristics on which files to include and exclude. Now only include
+ non-standard files if they are explicitly named in ARGV.
- * eval.c (is_defined): last_class may be 0.
+Tue Feb 24 07:23:30 2004 Dave Thomas <dave@pragprog.com>
-Sat Nov 6 19:26:55 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/rdoc/generators/html_generator.rb: Deal with :stopdoc: when
+ choosing a default main page to display (ie. don't select a page
+ if we don't have documentation for it).
- * Makefile.in: Added depend entry make parse.@OBJEXT@ from parse.c
- for UCB make
+Tue Feb 24 06:40:14 2004 Dave Thomas <dave@pragprog.com>
-Thu Nov 4 17:41:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/parsers/parse_rb.rb (RubyLex::identify_identifier): Handle
+ class variables in code listings
- * regex.c (re_compile_pattern): \< (wordbeg), \> (wordend) disabled.
+Tue Feb 24 06:40:14 2004 Dave Thomas <dave@pragprog.com>
-Wed Nov 3 08:52:57 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+ * lib/rdoc/parsers/parse_rb.rb (RubyLex::identify_identifier): Handle
+ class variables in code listings
- * io.c (Init_IO): forgot to use INT2FIX() around SEEK_SET, etc.
+Tue Feb 24 06:32:27 2004 Dave Thomas <dave@pragprog.com>
-Wed Nov 3 00:25:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_aliases): Handle
+ aliases in C files.
- * string.c (rb_str_split_method): use mbclen2() to handle kcode
- option of regexp objects.
+Tue Feb 24 06:16:22 2004 Dave Thomas <dave@pragprog.com>
-Mon Nov 1 14:22:15 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/rdoc/rdoc.rb (RDoc::RDoc::document): Now create op dir _before_
+ parsing files.
- * eval.c (rb_eval): reduce recursive calls to rb_eval()
- case of ||= and &&= .
+Tue Feb 24 06:08:47 2004 Dave Thomas <dave@pragprog.com>
-Sun Oct 31 13:12:42 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_constant):
+ Start collecting text of constant values earlier: was missing
+ values in output if there was no space after '='
- * regex.c (re_compile_pattern): wrong [\W] match.
+Tue Feb 24 06:08:25 2004 Dave Thomas <dave@pragprog.com>
-Fri Oct 29 16:57:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/generators/html_generator.rb: Escape contant values.
- * ext/nkf/lib/kconv.rb: new String methods (kconv, tojis, toeuc,
- tosjis).
+Tue Feb 24 03:45:06 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * time.c (time_s_at): now accepts optional second argument to
- specify micro second.
+ * ext/openssl/ossl_config.c (ossl_config_each): add new method
+ OpenSSL::Config#each. it iterates with section name, field name
+ and value.
-Thu Oct 28 13:35:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_config.c (Init_ossl_config): include Enumerable.
- * string.c (rb_str_split_method): should be mbchar aware with
- single char separators.
+Mon Feb 23 09:16:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Oct 27 12:57:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * instruby.rb (DOSISH): embedded path in batch files should not be
+ prefixed by DESTDIR. [ruby-core:02186]
- * random.c (rb_f_srand): random seed should be unsigned.
+Sun Feb 22 09:54:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Tue Oct 26 23:58:15 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * re.c: corrected documentation format (again)
- * array.c (rb_ary_collect): collect for better performance.
+Sun Feb 22 09:43:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Tue Oct 26 19:20:54 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * re.c: corrected documentation format (rb_reg_initialize_m)
- * marshal.c (r_object): should register class/module objects.
+Sat Feb 21 22:36:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Sat Oct 23 15:59:39 1999 Takaaki Tateishi <ttate@jaist.ac.jp>
+ * ext/zlib/zlib.c: documented, but needs more effort.
- * process.c (rb_f_system): should require at least one argument.
+Sat Feb 21 11:12:15 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Oct 23 12:42:44 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * missing/os2.c, missing/x68.c: typo fix. pointed out by greentea.
- * enum.c (enum_collect): collect without block will collect
- elements in enumerable.
+Fri Feb 20 18:59:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Oct 21 16:14:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/irb/init.rb (IRB::IRB.parse_opts): add -I option to
+ irb. [ruby-dev:39243]
- * ruby.c (moreswitches): function to process string option;
- the name is stolen from perl (not implementation).
+Thu Feb 19 23:24:16 2004 Dave Thomas <dave@pragprog.com>
- * ruby.c (proc_options): use RUBYOPT environment variable to
- retrieve the default options.
+ * lib/rdoc/generators/html_generator.rb (Generators::HtmlClass::build_attribute_list):
+ Support visibility modifiers for attributes
- * dir.c (fnmatch): use eban's fnmatch; do not depend on system's
- fnmatch (which may have portability problem) anymore.
+Thu Feb 19 23:24:16 2004 Dave Thomas <dave@pragprog.com>
-Wed Oct 20 15:14:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/generators/html_generator.rb (Generators::HtmlClass::build_attribute_list):
+ Support visibility modifiers for attributes
- * marshal.c (marshal_load): should protect the generated object
- table (arg->data) from GC.
+Thu Feb 19 22:39:04 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-Mon Oct 18 16:15:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/rinda/test_rinda.rb: DRb.start_service only once in testsuites.
+ DRb.start_service could handle this.
- * ext/nkf/nkf.c (rb_nkf_kconv): output should be NUL terminated.
+Thu Feb 19 22:19:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Mon Oct 18 09:03:01 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * lib/ostruct.rb: documented
- * lib/net/session.rb, smtp.rb, pop.rb: 1.0.3
+Thu Feb 19 21:28:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * lib/net/pop.rb: new methods POP3Command#uidl, POPMail#uidl.
+ * ext/strscan/strscan.c: improved documentation
-Sun Oct 17 03:35:33 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+Thu Feb 19 03:10:52 2004 Minero Aoki <aamine@loveruby.net>
- * array.c (rb_ary_pop): forgot some freeze checks.
+ * ext/strscan/strscan.c: synchronized with main trunk (rev 1.11).
-Sat Oct 16 12:57:53 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+Thu Feb 19 02:30:34 2004 Minero Aoki <aamine@loveruby.net>
- * array.c (rb_ary_sort): always returns the copied array.
+ * ext/strscan/strscan.c: documentation checked.
-Fri Oct 15 22:50:41 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+Thu Feb 19 00:11:05 2004 Dave Thomas <dave@pragprog.com>
- * error.c (sys_nerr): on CYGWIN, it is _sys_nerr.
+ * lib/rdoc/markup/simple_markup/preprocess.rb (SM::PreProcess::handle):
+ Strip extraneous space from filenames in :include:
-Fri Oct 15 01:32:31 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+Wed Feb 18 22:52:00 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * io.c (rb_io_ctl) :need to use NUM2ULONG, not NUM2INT.
+ * lib/drb/unix.rb: remove O_NONBLOCK, thanks \ay
- * ext/Win32API/Win32API.c (Win32API_Call): need to use NUM2ULONG,
- not NUM2INT.
+Wed Feb 18 22:47:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
-Fri Oct 15 00:22:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/strscan/strscan.c: documented
- * re.c (Init_Regexp): super class of the MatchingData, which was
- Data, to be Object.
+Wed Feb 18 22:03:11 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * eval.c (ruby_run): evaluate required libraries before load &
- compiling the script.
+ * test/*: should not depend on $KCODE.
- * parse.y (lex_getline): retrieve a line from the stream, saving
- lines in the table in debug mode.
+Wed Feb 18 17:18:01 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (call_trace_func): treat the case ruby_sourcefile is null.
+ * ext/win32ole/win32ole.c: need to include <olectl.h> on Cygwin.
-Thu Oct 14 02:00:10 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Feb 18 10:40:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (string): compile time string concatenation.
+ * sprintf.c (rb_f_sprintf): do not prepend dots for negative
+ numbers if FZERO is specified. [ruby-dev:39218]
-Wed Oct 13 07:28:09 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Tue Feb 17 23:40:34 2004 Guy Decoux <ts@moulon.inra.fr>
- * lib/net/session.rb, smtp.rb, pop.rb: 1.0.2
+ * sprintf.c (rb_f_sprintf): preserve original val for
+ format_integer. [ruby-talk:92975]
- * lib/net/session.rb: new method Session#set_pipe.
+Tue Feb 17 23:28:45 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * lib/net/session.rb, smtp.rb, pop.rb: add RD documentation.
+ * test/ruby/marshaltestlib.rb: common marshal testcase added.
-Wed Oct 13 02:17:05 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * test/ruby/test_marshal.rb: use above testsuite.
- * array.c (rb_ary_plus): remove recursion.
+ * test/soap/marshal/test_marshal.rb: ditto.
- * array.c (rb_ary_sort_bang): detect modify attempt.
+ * test/soap/marshal/cmarshal.rb: removed (not used).
-Wed Oct 13 02:17:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Feb 17 10:51:23 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (block_pass): should copy block to prevent modifications.
- tag in the structure should be updated from latest prot_tag.
+ * ext/syck/rubyext.c (syck_emitter_end_object): takes only one arg.
- * eval.c (proc_s_new): tag in struct BLOCK should not point into
- unused stack.
+Tue Feb 17 01:35:28 2004 Tanaka Akira <akr@m17n.org>
- * dir.c (dir_s_glob): iterate over generated matching filenames if
- the block is given to the method.
+ * eval.c (rb_eval): care that another thread replace NODE_DREGX_ONCE
+ to NODE_LIT. [ruby-dev:22920]
- * array.c (rb_ary_at): new methods; at, first, last.
+Tue Feb 17 01:24:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * hash.c (rb_hash_fetch): raises exception unless the default
- value is supplied.
+ * bcc32/Makefile.sub, win32/Makefile.sub (config.h): define
+ STACK_GROW_DIRECTION. [ruby-dev:22910]
- * hash.c (rb_hash_s_create): need not remove nil from value.
+ * bcc32/Makefile.sub (config.h): add newer checks.
- * hash.c (rb_hash_aset): setting value to nil does not remove key
- anymore.
+ * wince/Makefile.sub (config.h): define NEED_IO_SEEK_BETWEEN_RW.
-Tue Oct 12 22:29:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Feb 17 00:38:10 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * io.c (io_read): length may be 0 or negative.
+ * lib/rinda/tuplespace.rb: TupleSpace#initialize, stop doubling timeout
-Tue Oct 12 13:26:27 1999 Jun-ichiro itojun Hagino <itojun@itojun.org>
+Tue Feb 17 00:18:03 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * signal.c (posix_signal): RETSIGTYPE may be void.
+ * test/rinda/test_rinda.rb: import test_rinda.rb
-Tue Oct 12 03:28:03 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+Tue Feb 17 00:14:30 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * array.c (rb_ary_delete_at): allows negative position.
+ * bcc32/Makefile.sub: avoid warning "Redefinition of macro
+ 'HAVE_GETLOGIN'".
-Mon Oct 11 17:42:25 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * vms/config.h_in: ditto.
- * parse.y (rb_intern): should generate distinct ID_ATTRSET symbols
- for the name with multiple `='s at the end.
+Mon Feb 16 23:28:14 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * Makefile.in (CPPFLAGS): separate cpp flags from CFLAGS.
+ * lib/csv.rb: document reduction. [ruby-core:02429]
-Mon Oct 11 07:27:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Feb 16 22:08:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * eval.c (rb_eval): should not execute the `else' clause on the
- case the exceptions are handled by the `rescue' clause.
+ * lib/generator.rb: corrected doc format
+ * lib/rinda/rinda.rb: added documentation (from Hugh Sasse)
+ * lib/rinda/tuplespace.rb: ditto
- * signal.c (Init_signal): ignore SIGPIPE by default.
+Mon Feb 16 20:41:32 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Wed Oct 6 17:13:19 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+ * bcc32/Makefile.sub: show more warnings. (refering to mingw)
- * ruby.c (addpath): rubylib_mangled_path() modified.
+ * bcc32/setup.mak: ditto.
-Mon Oct 4 12:42:32 1999 Kazuhiko Izawa <izawa@erec.che.tohoku.ac.jp>
+Mon Feb 16 13:39:44 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
- * pack.c (pack_unpack): % in printf format should be %%.
+ * dir.c (rb_glob, rb_globi): add const.
-Mon Oct 4 10:01:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ruby.h: ditto.
- * variable.c (rb_obj_instance_variables): should always return
- array for all object can have instance variables now.
+Mon Feb 16 02:16:33 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Mon Oct 4 00:08:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * bcc32/Makefile.sub: should warn suspicious pointer conversion.
- * pack.c (OFF16): need to adjust pointer address to pack/unpack on
- 64bit machines.
+ * bcc32/setup.mak: ditto.
-Sun Oct 03 03:05:59 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+Sun Feb 15 19:06:42 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * time.c (time_arg): mktime y2k problem.
+ * lib/rinda/tuplespace.rb: TupleSpace#read(tpl, 0), raise
+ RequestExpiredError if not found.
-Sun Sep 26 16:54:45 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+Sun Feb 15 15:56:46 2004 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * parse.y (here_document): `\r' handling for here documents.
+ * ext/win32ole/win32ole.c: add IDispatch wrapper in val2variant.
+ Thanks, arton.
-Wed Sep 22 09:20:11 1999 Masahiro Tomita <tommy@tmtm.org>
+Sun Feb 15 01:46:05 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/socket/socket.c: SOCKS5 support.
+ * lib/mkmf.rb: absolute path of ruby is assigned to $(RUBY).
+ [ruby-dev:22870]
-Wed Sep 22 07:33:23 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+Sat Feb 14 11:29:41 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/net/session.rb, smtp.rb, pop.rb: 1.0.1
+ * sample/drb/*: import lib/drb/sample
- * lib/net/pop.rb: APOP did not work.
+Sat Feb 14 11:08:23 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * lib/net/pop.rb: modify the way to make APOP challenge.
+ * lib/drb/drb.rb: add pretty_print, thanks gotoken.
-Wed Sep 22 00:35:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Feb 13 12:35:08 2004 Minero Aoki <aamine@loveruby.net>
- * string.c (rb_str_include): should return boolean value.
+ * test/fileutils/test_fileutils.rb: File.link may raise EINVAL and
+ EACCES on Windows.
- * regex.c (re_compile_fastmap): wrong comparison with mbc.
+Thu Feb 12 21:45:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * eval.c (specific_eval): default sourcefile name should be
- "(eval)" for module_eval etc.
+ * lib/ftools.rb: documented
-Wed Sep 22 00:06:07 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Thu Feb 12 21:25:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * win32/Makefile: update rules.
+ * lib/base64.rb: backported from HEAD (modularised and documented)
- * io.c (io_fread): should not assign in char, it maybe -1.
+Thu Feb 12 20:31:48 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Sep 21 23:57:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (create_tmpsrc): cpp32 of Borland C++ ignores #error
+ directives in DOS line-ending files at all.
- * eval.c (call_trace_func): should not propagate retval in
- trace_func.
+Thu Feb 12 02:23:56 2004 Tanaka Akira <akr@m17n.org>
-Mon Sep 20 21:35:39 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/pathname.rb: use assert_raise instead of assert_raises.
- * win32/win32.c (myselect): assume non socket files are always
- readable/writable.
+ * lib/pp.rb: ditto.
-Mon Sep 20 01:08:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/time.rb: ditto.
- * io.c (io_fread): should not block other threads.
+ * lib/tsort.rb: ditto.
+ use TSortHash and TSortArray instead of Hash and Array in test.
- * io.c (rb_io_synchronized): renamed from rb_io_unbuffered(); do
- not call setbuf(NULL) anymore.
+Wed Feb 11 20:01:12 2004 akira yamada <akira@ruby-lang.org>
-Sat Sep 18 13:45:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/test_file.rb (TestFile::test_fnmatch): added tests for
+ File.fnmatch. [ruby-dev:22815][ruby-dev:22819]
- * stable version 1.4.2 released.
+ * test/ruby/test_proc.rb (TestProc::test_eq): added a
+ test. [ruby-dev:22599]
-Fri Sep 17 23:24:17 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * test/ruby/test_proc.rb (TestProc::test_eq): added tests for
+ Proc#==. [ruby-dev:22592], [ruby-dev:22601]
- * eval.c (rb_f_missing): dumped core if no argument given.
+Tue Feb 10 16:43:56 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Sep 17 23:21:06 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * eval.c (umethod_bind): purge unused check. [ruby-dev:22850]
- * win32/win32.c (myselect): translate WSAEINTR, WSAENOTSOCK into
- UNIX errno constants.
+Mon Feb 9 17:16:00 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Fri Sep 17 00:52:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/parsers/parse_c.rb: escape '{' and '}' to avoid warnings.
- * parse.y (arg): assignable() may return 0.
+Mon Feb 9 13:00:55 2004 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
-Thu Sep 16 20:46:23 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * dir.c (fnmatch): File.fnmatch('*?', 'a') should return true.
+ [ruby-dev:22815]
- * eval.c (rb_eval): was doubly evaluating the return expression.
+ * dir.c (fnmatch): File.fnmatch('\[1\]' , '[1]') should return true.
+ [ruby-dev:22819]
-Thu Sep 16 18:40:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Feb 8 16:46:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * stable version 1.4.1 released.
+ * lib/pp.rb (PP::PPMethods::object_address_group): suppress negative
+ sign for higher heap areas.
-Thu Sep 16 11:33:22 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Fri Feb 6 22:48:16 2004 Dave Thomas <dave@pragprog.com>
- * string.c (rb_str_match): should return nil.
+ * lib/rdoc/generators/html_generator.rb (gen_url): Support
+ https in RDoc hyperlinks
-Wed Sep 15 22:46:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Feb 6 22:41:22 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * re.c (rb_reg_s_quote): should quote `-' too.
+ * lib/pp.rb (PPInspectTest#test_to_s_with_iv): rollback the previous
+ commit. [ruby-dev:22813]
-Tue Sep 14 15:23:22 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+Fri Feb 6 22:22:50 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * parse.y (yylex): no need to ignore `\r' here.
+ * lib/pp.rb (PPInspectTest#test_to_s_with_iv): remove instance
+ variable which is defined in the test.
- * parse.y (nextc): strip `\r' from text.
+Fri Feb 6 00:48:37 2004 Tanaka Akira <akr@m17n.org>
- * parse.y (nextc): support `__END__\r\n' type terminator.
+ * lib/prettyprint.rb (PrettyPrint#first?): obsoleted.
-Mon Sep 13 10:49:19 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Thu Feb 5 23:56:55 2004 Tanaka Akira <akr@m17n.org>
- * eval.c (rb_eval): needless RTEST(ruby_verbose) removed.
+ * lib/prettyprint.rb (PrettyPrint#seplist): added.
-Mon Sep 13 09:10:11 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * lib/pp.rb (PPMethods#pp_object): use seplist.
+ (PPMethods#pp_hash): ditto.
+ (Array#pretty_print): ditto.
+ (Struct#pretty_print): ditto.
+ (MatchData#pretty_print): ditto.
- * lib/net/session.rb, smtp.rb, pop.rb: 1.0.0
+ * lib/set.rb (Set#pretty_print): use seplist.
-Wed Sep 8 11:37:38 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+Wed Feb 4 02:12:06 2004 Tanaka Akira <akr@m17n.org>
- * time.c (make_time_t): bit more strict comparison.
+ * file.c (test_l): fix wrong method name in document.
+ (test_S): ditto.
+ (test_b): ditto.
+ (test_c): ditto.
+ (test_suid): ditto.
+ (test_sgid): ditto.
+ (test_sticky): ditto.
-Tue Sep 7 00:50:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Feb 3 08:04:57 2004 Tanaka Akira <akr@m17n.org>
- * range.c (range_each): use rb_str_upto() for strings.
+ * lib/pp.rb (Struct#pretty_print_cycle): follow 1.8 style.
- * string.c (rb_str_upto): set upper limit by comparing curr <= end.
+Mon Feb 2 19:33:49 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * range.c (range_each): should check equality to handle magic
- increment.
+ * configure.in: backport from 1.9 for Interix.
-Mon Sep 6 22:43:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * dln.c (dln_load): ditto.
- * eval.c (rb_eval): break/next/redo available within -n/-p loop.
+Mon Feb 2 13:31:51 2004 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Sep 3 11:14:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/net/http.rb (canonical_each): fix merge miss.
- * compar.c (cmp_equal): should not raise exception; protect by
- rb_rescue().
+Mon Feb 2 01:54:00 2004 Tanaka Akira <akr@m17n.org>
-Thu Sep 2 05:23:05 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * lib/pp.rb (Struct#pretty_print): make it 1.8 style.
+ (Numeric#pretty_print, FalseClass#pretty_print)
+ (TrueClass#pretty_print, Module#pretty_print): fix pp for objects
+ with instance variables. [ruby-talk:91157]
- * file.c (rb_file_s_expand_path): use dirsep, instead of character
- literal '/'.
+ * lib/open-uri.rb (URI::Generic#find_proxy): return nil on loopback
+ address.
- * file.c (rb_file_s_expand_path): reduce multiple dirsep at the top.
+ * lib/resolv-replace.rb (BasicSocket#send): don't replace because
+ it has no hostname argument.
+ (IPSocket.getaddress): raise SocketError instead of
+ Resolv::ResolvError for errors.
+ (TCPSocket#initialize, UDPSocket#bind, UDPSocket#connect)
+ (SOCKSSocket#initialize): use IPSocket.getaddress instead of
+ Resolv.getaddress.
+ (UDPSocket#send): recognize 3 arguments form. try all addresses on
+ 4 arguments form.
-Wed Sep 1 00:28:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Feb 1 18:17:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * eval.c (rb_call): call rb_undefined() if a method appears not to
- be exist explicitly from cache.
+ * lib/net/http.rb: merged coding style changes from HEAD.
- * eval.c (rb_method_boundp): check method cache before calling
- rb_get_method_body().
+Sun Feb 1 16:15:00 2004 Gavin Sinclair <gsinclair@soyabean.com.au>
- * eval.c (rb_get_method_body): store method non-existence
- information in the cache.
+ * lib/test/unit.rb: rearranged documentation for RDoc's sake.
+ * lib/matrix.rb: improved documentation.
+ * lib/net/http.rb: slight documentation formatting improvement.
- * random.c (rb_f_srand): use getpid(2) to generate seed.
+Sun Feb 1 05:30:06 2004 Tanaka Akira <akr@m17n.org>
- * regex.c (re_match): do not apply partial mbc match for
- charset_not.
+ * lib/open-uri.rb (URI::Generic#find_proxy): warn HTTP_PROXY.
+ raise an errror on non-http proxy URI.
+ (OpenURI::Buffer#<<): make a tempfile binmode. [ruby-talk:90793]
- * regex.c (re_compile_pattern): put extended literal prefix (0xff)
- only before numeric literals, not before all >0x80 char.
+Sat Jan 31 09:20:32 2004 NAKAMURA, Hiroshi <nakahiro@sairon.co.jp>
- * regex.c (re_compile_pattern): put numeric literal in extended
- charset region, not normal charset bits.
+ * sample/openssl/gen_csr.rb: wrong usage string.
- * regex.c (re_compile_fastmap): calculate fastmap for charset and
- charset_not to treat numeric literal (e.g. \246) specially.
+Sat Jan 31 01:00:32 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-Fri Aug 28 17:32:55 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+ * lib/soap/wsdlDriver.rb, lib/wsdl/soap/operation.rb: add support of
+ "parts" attribute of soap:body element in WSDL.
- * eval.c (rb_eval): should set return value (nil) explicitly if a
- value is omitted for return statement.
+ * lib/wsdl/xmlSchema/schema.rb: friendly warning message for
+ simpleType element which is not supported for now.
-Thu Aug 26 15:06:11 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+ * lib/soap/mapping/factory.rb: deleted unused methods.
- * gc.c (rb_gc): local variables may be placed beyond stack_end, so
- use an address from alloca(1) on non C_ALLOCA platforms.
+ * lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type
+ string <-> Ruby class name matching.
-Thu Aug 26 01:24:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/wsdl/soap/{soapbodyparts.wsdl,test_soapbodyparts.wsdl}: new
+ files.
- * sprintf.c (rb_f_sprintf): "%%" is legal, but "%3.14%" is not.
+Thu Jan 29 23:56:00 2004 WATANABE Hirofumi <eban@ruby-lang.org>
-Mon Aug 23 00:00:54 1999 Tsukada Takuya <tsukada@fminn.nagano.nagano.jp>
+ * util.c (mblen): fix overrun. [ruby-dev:22672]
- * regex.c (re_compile_fastmap): wrong macro caused memory leak.
+Thu Jan 29 22:41:53 2004 Dave Thomas <dave@pragprog.com>
-Sat Aug 21 11:30:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/generators/html_generator.rb: Allow 'link:' in Tidylinks.
+ THis means you can write "see f1[link:files/f1_rb.html]".
- * eval.c (ADJ): should not adjust addresses to data on heap.
+Thu Jan 29 15:33:23 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Aug 20 20:50:58 1999 Kenji Nagasawa <kenn@hma.att.ne.jp>
+ * ext/openssl/ossl_x509hame.c (ossl_x509name_initialize): change
+ second argument. it expected to be a Hash not an Integer.
- * defines.h (PATH_SEP): path separator is ";" for OS/2.
+ * ext/openssl/ossl_x509name.c (ossl_x509name_add_entry): add new
+ function for OpenSSL::X509::Name#add_entry.
-Thu Aug 19 10:50:43 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * ext/openssl/ossl_x509name.c (ossl_x509name_to_a): append ASN.1
+ tag number to each element of return value.
- * gc.c (rb_gc): add volatile to avoid GCC optimize bug(?).
+ * ext/openssl/ossl_x509name.c (Init_ossl_x509name): add constants
+ OpenSSL::X509::Name::DEFAULT_OBJECT_TYPE and OBJECT_TYPE_TEMPLATE.
-Wed Aug 18 23:48:10 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/lib/openssl/x509.rb (OpenSSL::X509::Name#initialize):
+ second argument takes OBJECT_TYPE_TEMPLATE by default.
- * due to disk trouble, some change records were lost. several
- modification made to eval.c, gc.c, io.c, pack.c,
- ext/extmk.rb.in, and lib/mkmf.rb.
+ * sample/openssl/gen_csr.rb: use OpenSSL::X509::Name.parse.
-Fri Aug 13 15:41:39 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Jan 28 04:29:41 2004 Eric Schwartz <emschwar@fc.hp.com>
- * stable version 1.4.0 released.
+ * lib/cgi/session.rb: use LOCK_SH to read, and a few other
+ improvements. [ruby-core:02328]
-Fri Aug 13 03:16:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Jan 27 11:09:29 2004 FUKUMOTO Atsushi <fukumoto@nospam.imasy.or.jp>
- * io.c (argf_forward): since $stdout may be non-IO, ARGF.file is
- not guaranteed to be IO. check and forwarding added to every ARGF
- method.
+ * ext/socket/socket.c (s_recvfrom): sending length should be an
+ invariant while retrying on EAGAIN. [ruby-talk:89962]
- * io.c (set_outfile): $stdout/$stderr may not be IO now.
+Tue Jan 27 10:35:18 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * io.c (set_stdin): $stdin may not be IO now.
+ * ext/win32ole/win32ole.c (set_argv): fix condition.
- * range.c (rb_range_beg_len): round `end' to length as documented.
+Tue Jan 27 02:26:31 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * io.c (Init_IO): preserve original stdin/stdout/stderr.
+ * lib/webrick/httputils.rb (WEBrick:HTTPUtils::parse_header):
+ refine regex for header-name.
-Thu Aug 12 13:44:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Jan 27 00:30:11 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (Init_load): require receives 1 argument.
+ * win32/Makefile.sub: rollback.
- * eval.c (frame_dup): should clear tmp to avoid dangling
- references.
+Mon Jan 26 22:53:04 2004 Dave Thomas <dave@pragprog.com>
-Wed Aug 11 13:33:13 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * io.c: Remove documentation references to $defout.
- * eval.c (rb_eval): no automatic aggregate initialization.
+Mon Jan 26 15:11:47 2004 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (module_setup): ditto.
+ * sample/exyacc.rb: escape '}' to avoid warning.
-Wed Aug 11 18:18:41 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+Mon Jan 26 14:41:46 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (yield_under_i): automatic aggregate initialization is an
- ANSI feature.
+ * lib/delegate.rb (Delegator::initialize): preserve
+ singleton_method_added method [ruby-dev:22685]
-Wed Aug 11 10:10:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/delegate.rb (Delegator::initialize): use Kernel::raise
+ instead of mere raise. [ruby-dev:22681]
- * parse.y (yylex): parse `[].length==0' as `([].length)==0', not
- `([].length=)=0'
+Mon Jan 26 12:47:17 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * parse.y (yylex): parse `[].length!=0' as `([].length)!=0', not
- `([].length!)=0'
+ * ext/tcltklib/tcltklib.c: define CONST84 when TCL_MAJOR_VERSION == 7
- * parse.y (peek): peek-in lexical buffer.
+Mon Jan 26 11:35:23 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Aug 11 00:34:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/extmk.rb: Makefiles should depend on also rbconfig.rb.
+ (ruby-bugs:PR#1256)
- * regex.c (re_match): bug on backward jump adjustment concerning
- stop_paren.
+ * ext/win32ole/win32ole.c (set_argv): set real arguments to
+ WIN32OLE::ARGV. [ruby-list:39073]
-Tue Aug 10 14:54:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Jan 22 22:54:53 2004 Shugo Maeda <shugo@ruby-lang.org>
- * ext/nkf/nkf.c (rb_nkf_guess): binary detection was wrong.
+ * lib/net/imap.rb (BEG_REGEXP): allow 8-bit characters in quoted
+ strings for Novell GroupWise Internet Agent.
+ * lib/net/imap.rb (DATA_REGEXP): ditto.
-Tue Aug 10 00:07:36 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Jan 22 16:21:33 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_clone): should use CLONESETUP().
+ * parse.y (string_content): reset lexical states at the beginning of
+ string contents. [ruby-list:39061]
-Mon Aug 9 23:57:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Jan 21 21:55:51 2004 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * ruby.h (CLONESETUP): should have copied generic instance
- variables too.
+ * lib/drb/drb.rb: remove O_NONBLOCK, thanks \ay
+ * lib/drb/extserv.rb: typo
-Mon Aug 9 10:46:54 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Wed Jan 21 17:57:56 2004 Shugo Maeda <shugo@ruby-lang.org>
- * ext/socket/extconf.rb: add check for <arpa/nameser.h> and
- <resolv.h>.
+ * lib/net/imap.rb (envelope): allow NIL.
+ * lib/net/imap.rb (body): ditto.
+ * lib/net/imap.rb (number): ditto.
+ * lib/net/imap.rb (ensure_nz_number): show a detailed error
+ message.
-Sat Aug 7 13:19:06 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+Wed Jan 21 16:44:20 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * numeric.c (flo_cmp): comparing NaN should not return value.
- raises FloatDomainError.
+ * lib/mkmf.rb (merge_libs): squeeze successive same libraries.
+ [ruby-dev:22652]
-Sat Aug 7 03:09:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Jan 21 16:01:37 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (blk_free): free copied frames too.
+ * ext/digest/rmd160/extconf.rb: have_library appends found library.
- * eval.c (frame_dup): should copy previous frames from stack to
- heap to preserve frame information.
+Wed Jan 21 11:36:00 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Aug 6 15:01:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * parse.y (block_append): update nd_end for "real" head node.
+ [ruby-list:39058]
- * version 1.3.7 - version 1.4 beta
+Tue Jan 20 14:48:13 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/socket/socket.c (s_recv): UDPsocket#recvfrom now returns
- IPsocket#addr information.
+ * ext/openssl/extconf.rb: should check <openssl/conf_api.h> instead
+ of OPENSSL_VERSION_NUMBER. [ruby-list:39056]
- * array.c (rb_ary_subary): ary[-3,3] should not return nil.
+Tue Jan 20 14:43:17 2004 Dave Thomas <dave@pragprog.com>
-Thu Aug 5 10:58:01 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/base64.rb: Add RDoc
- * eval.c (thread_mark): protect old ruby_frame from GC during it
- replaced by eval().
+Tue Jan 20 14:25:51 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (eval): do not modify frame.prev; binding should preserve
- information about calling() too.
+ * lib/abbrev.rb: Add RDoc
- * eval.c (rb_yield_0): no arity check for mere yield; but only for
- Proc#call.
+Tue Jan 20 13:22:39 2004 Dave Thomas <dave@pragprog.com>
-Tue Aug 3 22:07:13 1999 Kazuhiro HIWADA <hiwada@kuee.kyoto-u.ac.jp>
+ * lib/rdoc/generators/html_generator.rb: Document aliases at
+ top-most level.
- * object.c (rb_mod_clone): should check if iv_tbl, m_tbl are
- initialized.
+ * lib/English.rb: Document English.rb.
-Tue Aug 3 19:03:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Jan 20 02:49:22 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * hash.c (rb_any_cmp): use rb_with_disable_interrupt() to ensure
- clearance of rb_prohibit_interrupt even on failure.
+ * ext/openssl/extconf.rb: add check for OpenSSL version.
+ [ruby-list:39054]
- * eval.c (rb_with_disable_interrupt): new function added.
+Tue Jan 20 02:38:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Jul 31 23:23:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * marshal.c (w_class): should not dump singleton class.
+ [ruby-dev:22631]
- * eval.c (rb_thread_create_0): set THREAD_RAISED flag on thread
- termination by exception.
+Tue Jan 20 01:31:36 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (rb_thread_join): `$!' may not be nil for the threads
- created in rescue clause.
+ * io.c (lineno): typo fix(FIX2INT -> INT2FIX).
- * eval.c (rb_thread_status): ditto.
+Mon Jan 19 21:53:38 2004 akira yamada <akira@ruby-lang.org>
- * eval.c (rb_thread_join): should re-raise exception for already
- dead threads too.
+ * io.c, re.c, string.c, time.c: fixed up positions of RDocs.
-Fri Jul 30 17:56:54 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+Mon Jan 19 07:09:20 2004 Tadayoshi Funaba <tadf@dotrb.org>
- * object.c (rb_mod_ge): wrong comparison.
+ * lib/date.rb: zone was wrong when it was behind UTC.
+ Thanks Mark J. Reed.
-Fri Jul 30 12:15:44 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/date/format.rb: %z is now always replaced by four digits
+ with a leading plus or minus sign.
- * ext/tcltklib/extconf.rb: win32 support.
+ * sample/cal.rb: added a class, anyway.
- * lib/mkmf.rb: use append_library().
+Sun Jan 18 20:47:35 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/extmk.rb.in: ditto.
+ * ruby.c: use translate_char() on Cygwin.
-Fri Jul 30 02:11:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Jan 18 02:33:26 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * array.c (rb_ary_delete): should return nil for deleting non
- existing item.
+ * defines.h (_WIN32): undef _WIN32 on Cygwin before defining DOSISH.
- * io.c (rb_io_close): call rb_sys_wait() on explicit close.
+Sun Jan 18 00:23:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_io_fptr_close): do not call rb_sys_wait() on finalize.
+ * marshal.c (class2path): check anonymous class/module before
+ checking referable, and allow singleton classes.
- * eval.c (yield_under_i): cbase context should be maintained for
- Module#module_eval(). suggested by <inaba@st.rim.or.jp>.
+Fri Jan 16 14:33:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jul 28 01:18:28 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * marshal.c (class2path): get class path and check referable.
+ [ruby-dev:22588]
- * Makefile.in: add -I$(hdrdir)/lib to install using ftools.
+Fri Jan 16 09:52:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * util.c: use HAVE_FCNTL_H, not HAVE_FCNTL
+ * eval.c (proc_eq): Proc with empty body may not be equal.
+ [ruby-dev:22590]
-Wed Jul 28 18:24:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Jan 15 13:03:10 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * version 1.3.6 - version 1.4 alpha
+ * io.c (argf_read): do not append EOF. (ruby-bugs-ja:PR#585)
-Tue Jul 27 09:38:08 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * io.c (rb_io_fwrite): ad-hockery hack to get rid of HP-UX stdio
+ weird behavior. [ruby-dev:22424]
- * eval.c (rb_eval): reduce recursive rb_eval() calls by
- NODE_BLOCKs.
+Wed Jan 14 13:31:06 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Jul 27 01:20:40 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/iconv/extconf.rb: wrapper iconv.rb is dependent on platform.
- * file.c (rb_file_s_expand_path): drive letter patch.
+Tue Jan 13 18:54:28 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-Mon Jul 26 02:36:31 1999 Shugo Maeda <shugo@netlab.co.jp>
+ * lib/logger.rb(Logger#msg2str): no special treatment for the object
+ which responds to :to_str. commited at 2004-01-11T21:46:27 by
+ gsinclair.
- * eval.c (rb_load): should clear ruby_nerr.
+ * lib/logger.rb(LogDevice#initialize): remove type checking if the
+ given object is a String. Kernel.open handles it correctly.
+ commited at 2004-01-11T21:46:27 by gsinclair.
- * eval.c (rb_thread_join): oldbt should not be empty to unshift.
+ * test/logger/test_logger.rb: follow above change (ArgumentError ->
+ TypeError.) follow above commit.
-Sun Jul 25 12:09:16 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Tue Jan 13 14:27:13 2004 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
- * dir.c (push_braces): should treat nested braces.
+ * lib/test/unit/ui/testrunnerutilities.rb (TestRunnerUtilities):
+ moved run method which allows output level. [ruby-dev:22554]
-Fri Jul 23 02:49:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Jan 13 04:29:52 2004 Dave Thomas <dave@pragprog.com>
- * hash.c (rb_hash_clear): dummy argument added; suggested by
- <eguchi@shizuokanet.ne.jp>. thanks.
+ * lib/rdoc/ri/ri_driver.rb (RiDriver::report_method_stuff):
+ Show fully-qualified class names in class list.
-Thu Jul 22 19:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Jan 13 01:04:37 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (rb_thread_join): get_backtrace() may return Qnil.
- typecheck added.
+ * lib/rdoc/ri/ri_paths.rb (RI::Paths): First attempt at
+ incorporating DESTDIR in the rdoc installation.
-Tue Jul 20 14:36:43 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Mon Jan 12 23:27:19 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * range.c (range_each): do not treat String specially (for future
- override).
+ * parse.y (primary): fix position after FCALL. [ruby-dev:22574]
-Tue Jul 20 02:28:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Jan 12 12:07:22 2004 Dave Thomas <dave@pragprog.com>
- * io.c (rb_gets): $_ should be nil, when get returns nil.
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_methods):
+ Someone changed the "// in eval.c" comments to "/*...*/" style,
+ so the parsing of the source file name broke.
- * io.c (rb_f_gets): ditto.
+ * object.c: Remove spurious space in TrueClass documentation.
-Mon Jul 19 17:13:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_body): Fix
+ bad regexp: if the code before a documented method contained
+ a comment that wasn't terminated by whitespace, that comment
+ and all intervening code was included in the following
+ method's documentation.
- * regex.c (re_compile_fastmap): should continue fastmap compile
- for anychar_repeat, for it's repeat anyway.
+ * lib/rdoc/ri/ri_formatter.rb (RI::HtmlFormatter::break_to_newline):
+ HTML formats need explicit line breaks.
-Mon Jul 26 13:33:45 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Mon Jan 12 11:46:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/jcode.rb: replaced by faster code.
+ * configure.in (LIBPATHFLAG, RPATHFLAG): enclose paths with single
+ quotes. [ruby-dev:22564]
-Mon Jul 19 01:57:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (libpathflag): do not enclose with quotes always.
- * lib/mkmf.rb: no longer use install program.
+ * {bcc32,win32,wince}/Makefile.sub (LIBPATHFLAG): quoted.
- * ext/extmk.rb.in: use miniruby to install programs.
+Mon Jan 12 02:24:07 2004 Dave Thomas <dave@pragprog.com>
-Sat Jul 17 00:06:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/ri/ri_formatter.rb (RI::HtmlFormatter): Add HTML
+ generation support to ri (Elliot Hughes)
- * ext/socket/socket.c (ipaddr): don't do reverse lookup if
- attribute do_not_reverse_lookup is set for socket classes.
- Experimental. Note this is a global attribute.
+Mon Jan 12 02:24:07 2004 Dave Thomas <dave@pragprog.com>
-Fri Jul 16 22:18:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rdoc/ri/ri_formatter.rb (RI::HtmlFormatter): Add HTML
+ generation support to ri (Elliot Hughes)
- * io.c (rb_io_eof): use feof() to check EOF already met.
+Sun Jan 11 02:07:47 2004 Dave Thomas <dave@pragprog.com>
- * io.c (read_all): should return nil at EOF.
+ * lib/rdoc/ri/ri_options.rb (RI::Options::OptionList::OptionList):
+ Also accept command line options via the 'RI' environment variable.
-Fri Jul 16 13:39:42 1999 Wakou Aoyama <wakou@fsinet.or.jp>
+Sun Jan 11 02:07:47 2004 Dave Thomas <dave@pragprog.com>
- * lib/telnet.rb: version 0.231.
+ * lib/rdoc/ri/ri_options.rb (RI::Options::OptionList::OptionList):
+ Also accept command line options via the 'RI' environment variable.
-Fri Jul 16 10:58:22 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+Sat Jan 10 21:27:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_match): debug print removed.
+ * eval.c (eval): need to add message delimiter. [ruby-dev:22561]
-Fri Jul 16 09:58:15 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Sat Jan 10 01:54:50 2004 Eric Sunshine <sunshine@sunshineco.com>
- * many files: clean up unused variables found by gcc -Wall.
+ * defines.h (__NeXT__): Ensure that all standard S_IRUSR, S_IWGRP,
+ S_IRWXO, etc. macros are defined since future code might require
+ them (even though present code only requires a subset).
- * lib/mkmf.rb: better cygwin support etc.
+ * defines.h (__NeXT__): Bug fix: WORDS_BIGENDIAN was not being set
+ correctly on Rhapsody when -arch compiler flag was used (via
+ configure's --enable-fat-binary option).
- * ext/extmk.rb.in: ditto.
+Fri Jan 9 10:05:14 2004 Siena. <siena@faculty.chiba-u.jp>
- * instruby.rb: ditto.
+ * lib/mkmf.rb (libpathflag): use single quotes. [ruby-dev:22440]
-Fri Jul 16 01:37:50 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Thu Jan 8 23:49:21 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * string.c (rb_str_squeeze_bang): the type of local variable `c'
- should be int, not char.
+ * configure.in (RDOCTARGET): new macro. if you want to install
+ rdoc documentation, you need to run configure with
+ --enable-install-doc.
- * string.c (rb_str_reverse): should always return copy.
+Thu Jan 8 21:29:43 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Thu Jul 15 23:25:57 1999 NAKAMURA Hiroshi <nakahiro@sarion.co.jp>
+ * ext/openssl/ossl_pkey.c (ossl_pkey_to_der): removed; it returns
+ public key only.
- * lib/debug.rb: better display & frame treatment.
+ * ext/openssl/ossl_pkey_dh.c (ossl_dh_to_der): new function for
+ OpenSSL::PKey::DH#to_der.
-Thu Jul 15 21:16:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_pkey_dsa.c (ossl_dsa_to_der): new function for
+ OpenSSL::PKey::DSA#to_der.
- * array.c (rb_ary_each): returns self for normal termination;
- returns nil for break.
+ * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_to_der): new function for
+ OpenSSL::PKey::RSA#to_der.
- * string.c: non bang methods (e.g. String#sub) should always
- return copy of the receiver.
+Thu Jan 8 16:51:04 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
-Thu Jul 15 21:09:15 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+ * test/wsdl/datetime/test_datetime.rb: fixed a stupid testcase which
+ dumps "E" at month-end.
- * eval.c (find_file): do not add empty string to the path.
+Thu Jan 8 11:20:01 2004 WATANABE Hirofumi <eban@ruby-lang.org>
- * configure.in (with-search-path): should not add empty string if
- the option is not supplied.
+ * eval.c, object.c, process.c, re.c: don't use C++ style comments.
-Thu Jul 15 17:49:08 1999 Ryo HAYASAKA <hayasaka@univ21.u-aizu.ac.jp>
+Thu Jan 8 04:36:21 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/tcltklib/tcltklib.c: move `#include "ruby.h"' forward.
+ * lib/webrick/cgi.rb (WEBrick::CGI#initialize): should create
+ @config[:Logger] if it was not given.
-Thu Jul 15 16:54:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * sample/webrick/*: new files.
- * version 1.3.5 - version 1.4 alpha
+ * MANIFEST: add sample/webrick/*
-Wed Jul 14 23:45:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Wed Jan 7 13:00:18 2004 Dave Thomas <dave@pragprog.com>
- * eval.c (ruby_init): initialize for the first time only.
+ * lib/rdoc/ri/ri_driver.rb: Fix problem where ri was
+ being too eager to find matches of ambiguous method
+ names (such as "ri Thread.join" would return both
+ Thread.join and ThreadsWait.join)
-Tue Jul 13 00:15:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Jan 7 12:35:41 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
- * hash.c (rb_hash_index): re-defined; method to retrieve a key
- from the value.
+ * lib/debug.rb: revert command parse regexps. [ruby-list:39014] by
+ Shirai,Kaoru.
- * hash.c (Init_Hash): member? should be re-defined for Hash.
+Wed Jan 7 08:21:04 2004 Dave Thomas <dave@pragprog.com>
-Tue Jul 12 13:54:51 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/rdoc/parsers/parserfactory.rb: Check for shebang
+ line in files that would otherwise be treated as
+ plain text.
- * io.c (rb_file_sysopen): wrong number of argument.
+Tue Jan 6 22:13:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Jul 12 11:52:35 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_mod_modfunc): should break if m has no super class.
+ [ruby-dev:22498]
- * eval.c (rb_f_missing): class name included in message.
+Tue Jan 6 21:55:02 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (print_undef): better error message.
+ * io.c (fptr_finalize): should save errno just after failure.
+ [ruby-dev:22492]
-Sun Jul 11 05:36:17 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+Tue Jan 6 14:53:14 2004 Dave Thomas <dave@pragprog.com>
- * lib/debug.rb: patch to show proper position.
+ * bin/ri: split out the display side, making it pluggable. Added
+ new ri_driver and ri_display files in lib/rdoc/ri.
-Fri Jul 9 23:56:14 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+Tue Jan 6 06:37:53 2004 Dave Thomas <dave@pragprog.com>
- * dln.c (dln_find_1): path conv. moved to conv_to_posix_path.
+ * bin/rdoc: Add --ri-system switch
- * dln.c (conv_to_posix_path): path conv. should be done.
+ * lib/.document: Update with list of files that seem to have
+ documentation
-Fri Jul 9 10:26:47 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * lib/test/unit.rb: Reorder comment to make it RDoc friendly.
- * random.c (RANDOM_NUMBER): should place parentheses.
+ * Makefile.in: add install-nodoc target, and make it
+ generate RDoc on default install.
-Fri Jul 8 11:00:51 1999 Shugo Maeda <shugo@netlab.co.jp>
+ * lib/rdoc/ri/ri_options.rb (RI::Options::parse): Add
+ --doc-dir option to ri.
- * numeric.c (fix_div): division may be out of fixnum range.
+Tue Jan 6 00:04:40 2004 Dave Thomas <dave@pragprog.com>
- * bignum.c (bigdivmod): proper sign calculation to result.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method_or_yield_parameters):
+ fix parsing if there are braces in a method parameter list
-Wed Jul 7 18:27:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Jan 2 14:54:11 2004 Dave Thomas <dave@pragprog.com>
- * st.c (st_delete_safe): was modifying wrong slot.
+ * bin/ri: Add new --classes option, and arrange for
+ help messages to be paged too.
-Mon Jul 5 13:17:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * bin/rdoc: Add statistics.
- * gc.c (rb_gc_call_finalizer_at_exit): close all files at exit.
+ * process.c: (MG) Added Process documentation
-Fri Jul 2 18:00:21 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * lib/rdoc/ri/ri_formatter.rb (RI::AttributeFormatter::wrap):
+ Fix problem with labels not displaying in RI labeled
+ lists using BS and ANSI modes.
- * lib/Mail/README: Mail-0.3.0 added to the distribution.
+Fri Jan 2 01:50:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Jul 2 01:45:32 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * io.c (argf_eof): ARGF.eof? should not have any side effect.
+ [ruby-dev:22469]
- * regex.c (re_compile_fastmap): avoid allocation of register
- variables for each invocation of re_match(). Suggested by
- Zasukhin Ruslan <ruslan@paradigmasoft.com>. Thanks.
+Wed Dec 31 17:25:17 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Jun 29 20:39:24 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * io.c (argf_each_byte): should return self. [ruby-dev:22465]
- * ext/tk/lib/tk.rb (TkVariable): bug fix; should value type check
- be added?
+Wed Dec 31 11:20:34 2003 Dave Thomas <dave@pragprog.com>
- * string.c (rb_str_each_line): a bug in paragraph mode.
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::do_methods): Make
+ file referenced in "// in sss.c" relative to current file.
- * ruby.c (load_file): shifted too much to skip #!.
+Wed Dec 31 11:17:37 2003 Dave Thomas <dave@pragprog.com>
-Tue Jun 29 06:50:21 1999 Wakou Aoyama <wakou@fsinet.or.jp>
+ * lib/rdoc/generators/html_generator.rb: Fix problem when
+ a public method was aliased, but the alias is then
+ made private, and hence doesn't appear in RDoc output.
- * lib/CGI.rb: 0.30 - cleanup release, incompatible.
+Wed Dec 31 01:33:05 2003 Dave Thomas <dave@pragprog.com>
- * lib/telnet.rb: 0.22 - timeout added.
+ * array.c, error.c, eval.c, io.c, prec.c, range.c, re.c,
+ string.c, time.c: Add RDoc for Kernel functions, and tidy.
-Tue Jun 29 10:49:25 1999 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+Tue Dec 30 19:39:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * configure.in: better Rhapsody support.
+ * io.c (rb_f_readline): should raise EOFError at the end of
+ files. [ruby-dev:22458]
- * lib/mkmf.rb: Rhapsody/NEXTSTEP support.
+ * io.c (argf_read): should concatenate input files when length
+ argument is nil. [ruby-dev:22450]
-Tue Jun 29 01:42:13 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * io.c (argf_read): should update supplied string buffer (2nd
+ argument) even when IO#read is called multiple times.
- * ext/pty/pty.c (chld_changed): should use POSIX.1 style wait.
+ * io.c: should initialize lineno by zero. [ruby-dev:22460]
-Mon Jun 28 21:07:36 1999 KIMURA Koichi <kbk@kt.rim.or.jp>
+Tue Dec 30 12:30:30 2003 Dave Thomas <dave@pragprog.com>
- * ext/extmk.rb.nt: wrong result for have_library().
+ * lib/rdoc/code_objects.rb (RDoc::Context::find_symbol): If a
+ class and a method have the same name, finding Xxx.abc was trying
+ to find 'abc' in method 'Xxx', not class 'Xxx'.
-Mon Jun 28 15:24:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
- * missing/isinf.c: OSF/1 raises SIGFPE on one()/zero().
+Tue Dec 30 08:32:32 2003 Dave Thomas <dave@pragprog.com>
- * regex.c (re_search): should search til EOS, for patterns may
- match beyond the end of range.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method):
+ Handle undoing nesting of yield parameters correctly for:
-Mon Jun 28 12:49:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ def each_entry(&b) Dir.foreach(@path) {|f| yield P.new(f) } end
- * io.c (rb_f_select): should not accept Time objects as an
- argument for it is time interval.
- * process.c (rb_f_sleep): ditto.
+Tue Dec 30 08:32:32 2003 Dave Thomas <dave@pragprog.com>
- * file.c (test_s): should return nil for false condition.
+ * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_method):
+ Handle undoing nesting of yield parameters correctly for:
-Mon Jun 28 12:23:52 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ def each_entry(&block) Dir.foreach(@path) {|f| yield Pathname.new(f) } end
- * bignum.c (rb_dbl2big): typo.
+Mon Dec 29 12:51:02 2003 Dave Thomas <dave@pragprog.com>
- * file.c (rb_f_test): ditto.
+ * eval.c: Add RDoc for Kernel global functions.
- * string.c (rb_str_crypt): wrong message.
+Mon Dec 29 11:00:16 2003 Dave Thomas <dave@pragprog.com>
-Sun Jun 27 19:50:11 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * array.c: Tidy up RDoc loose ends.
- * eval.c (rb_f_exit): should have treat signed integer status, not
- VALUE.
+Mon Dec 29 05:05:51 2003 Dave Thomas <dave@pragprog.com>
- * process.c (rb_f_exit_bang): should work like exit().
+ * struct.c, random: Add RDoc comments
-Sun Jun 27 16:21:32 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+Mon Dec 29 02:20:54 2003 Dave Thomas <dave@pragprog.com>
- * string.c (rb_str_rindex): wrong position to search.
+ * eval.c: Add RDoc for class Proc, Method, UnboundMethod
-Sat Jun 26 04:05:30 1999 Takaaki Tateishi <ttate@jaist.ac.jp>
+Mon Dec 29 00:41:44 2003 Dave Thomas <dave@pragprog.com>
- * configure.in (configure_args): --with-search-path to specify
- additional ruby search path.
+ * math.c: Add RDoc comments
- * ruby.c (ruby_prog_init): additional search path.
+Sun Dec 28 20:19:11 2003 Tanaka Akira <akr@m17n.org>
-Fri Jun 25 13:09:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/stringio/stringio.c (strio_sysread): StringIO.new.sysread didn't
+ raise EOFError.
- * pack.c (pack_unpack): needed to initialize natint.
+ * ext/zlib/zlib.c (gzreader_gets): don't increment lineno when
+ gzfile_read_all returns "".
- * regex.c (re_compile_pattern): add start_paren to avoid too much
- finalization on maybe_finalize_jump.
+Sun Dec 28 15:25:08 2003 Dave Thomas <dave@pragprog.com>
-Fri Jun 25 13:07:20 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
+ * class.c,object.c,parse.y,sprintf.c,variable.c: Document classes
+ Object, Module, etc...
- * missing/isinf.c: include "config.h" added.
+Sun Dec 28 11:55:29 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Fri Jun 25 07:25:05 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * test/csv/test_csv.rb: generate bom.csv and mac.csv files on the fly.
+ [ruby-talk:88852]
- * lib/mkmf.rb: initialize $(topdir).
+ * test/csv/{bom.csv,mac.csv}: removed.
- * ext/extmk.rb.in (install_rb): install lib/*.rb properly.
+Sun Dec 28 08:56:51 2003 Dave Thomas <dave@pragprog.com>
- * configure.in (linux): specifies -rpath on --enable-shared.
+ * eval.c: Thead[Group] RDoc (thanks to MG)
- * configure.in (aix): ruby.imp must reside in $(topdir).
+Sun Dec 28 03:50:05 2003 Dave Thomas <dave@pragprog.com>
-Thu Jun 24 19:11:29 1999 Yoshida Masato <yoshidam@yoshidam.net>
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_override_comment):
+ Escape method names used in regexp
- * parse.y (rb_str_extend): multi-byte identifier in expression
- interpolation in strings.
+Sun Dec 28 01:46:02 2003 Dave Thomas <dave@pragprog.com>
- * parse.y (yylex): support multi-byte char identifiers.
+ * lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::display_flow_item):
+ Add support for rules in 'ri' output.
-Thu Jun 24 15:27:13 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Dec 28 01:35:35 2003 Dave Thomas <dave@pragprog.com>
- * parse.y (f_arg): check duplicate argument names.
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_body):
+ Sometimes the Ruby source aliases two otherwise
+ unrelated methods (for example Kernel#object_id and
+ Kernel#hash are both the same C function). Provide a
+ facility to allow the methods to be documented
+ separately.
- * gc.c (rb_gc_mark): marking wrong member for NODE_ARGS.
+Sun Dec 28 01:05:31 2003 Dave Thomas <dave@pragprog.com>
- * string.c (rb_str_rindex): POSITION specifies start point, not
- end point.
+ * marshal.c, signal.c: RDoc collemts added by Elliott Hughes
-Thu Jun 24 13:00:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Dec 28 00:48:47 2003 Dave Thomas <dave@pragprog.com>
- * regex.c (print_mbc): wrong boundary.
+ * lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser::find_class_comment):
+ Some source files use lower case class or module names
+ when naming the Init_XXX function in C.
- * pack.c (uv_to_utf8): raises ArgError for too big value.
+Sat Dec 27 23:41:46 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Thu Jun 24 11:02:51 1999 Yoshida Masato <yoshidam@yoshidam.net>
+ * configure.in: fix "test: too many arguments" error.
- * pack.c (uv_to_utf8): mask needed.
+Sat Dec 27 15:32:19 2003 Dave Thomas <dave@wireless_3.local.thomases.com>
-Wed Jun 23 21:03:56 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * time.c: RDoc comments added
- * ruby.h (struct RFile): remove iv_tbl from struct. instance
- variables are handled as generic ivs.
+Sat Dec 27 15:07:57 2003 Dave Thomas <dave@pragprog.com>
-Wed Jun 23 22:06:26 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * object.c: Add RDoc comments for Symbol class.
- * pack.c (utf8_to_uv): pack to 7 bytes sequence.
+Sat Dec 27 14:42:30 2003 Dave Thomas <dave@pragprog.com>
- * pack.c (uv_to_utf8): wrong boundary.
+ * numeric.c: Add RDoc comments.
- * pack.c (pack_unpack): should treat as unsigned long.
+Sat Dec 27 00:44:00 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Jun 23 15:10:11 1999 Inaba Hiroto <inaba@sdd.tokyo-sc.toshiba.co.jp>
+ * io.c (next_argv): warn always for stdin on inplace edit mode.
- * parse.y (parse_string): failed to parse nested braces.
+ * io.c (read_all): need to check string value.
- * parse.y (parse_regx): nested braces within #{} available.
+ * io.c (argf_read): allow ARGF.read(nil). [ruby-dev:22433]
-Wed Jun 23 11:18:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Dec 26 23:02:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (slow_search): wrong shift width for mbcs.
+ * io.c (rb_f_backquote): need not to check nil result.
+ [ruby-core:02078]
- * eval.c (rb_thread_save_context): should not clear th->locals.
+ * io.c (rb_io_getline): should return nil when read_all gives
+ empty string, even when nil rs is specified. [ruby-core:02077]
-Wed Jun 23 02:06:14 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Dec 26 18:50:59 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (yylex): UMINUS binds too tight with digits. changed so
- that -2**2 => -4.
+ * configure.in: check if getcontext and setcontext are available.
- * parse.y (close_paren): `do' for expr termination now works it
- used to be.
+ * eval.c: use presence of getcontext/setcontext.
-Wed Jun 22 18:26:42 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Fri Dec 26 16:40:53 2003 Tanaka Akira <akr@m17n.org>
- * pack.c (pack_pack): should initialize local variable `j'.
+ * lib/pathname.rb (PathnameTest#test_plus): add 2 assertions.
-Wed Jun 22 15:24:59 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Fri Dec 26 09:26:58 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (here_document): a bug for multiline heredoc.
+ * pack.c (pack_pack): add sign check for 'i', and 'l'.
+ [ruby-dev:22427]
-Tue Jun 22 15:06:36 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * bignum.c (rb_quad_pack): add range check for 'quad int'.
- * ext/socket/socket.c (ruby_socket): forgot to return fd
- explicitly.
+Thu Dec 25 22:39:59 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Tue Jun 22 13:34:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (rb_str_update): don't return any value.
- * rubyio.h (MakeOpenFile): should initialize member `iv_tbl'.
+Thu Dec 25 15:30:17 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Jun 22 10:35:51 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * string.c (rb_str_update): call rb_str_modify().
- * io.c (rb_io_gets_internal): getc(3) may not set errno on
- interrupt.
+Thu Dec 25 05:08:09 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Jun 21 22:39:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (search_required): search actual file name once when no
+ extension specified.
- * eval.c (call_required_libraries): ruby_sourceline should be
- cleared before loading libraries.
+Thu Dec 25 04:00:44 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (set_stdin): do not use reopen(), so that we don't need to
- dup original stdin before assigning $stdin.
+ * stable version 1.8.1 released.
-Mon Jun 21 18:04:27 1999 Ryo HAYASAKA <hayasaka@univ21.u-aizu.ac.jp>
+Thu Dec 25 00:17:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/dbm/dbm.c: include <cdefs.h> for solaris 2.6.
+ * configure.in: check for nanosleep, -lrt if required.
+ [ruby-core:02059]
-Mon Jun 21 15:59:47 1999 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+ * eval.c (thread_timer): use select(2) if nanosleep(2) is not
+ available.
- * ext/socket/socket.c (ip_addrsetup): forgot to put `else'.
+ * eval.c: check __stub_getcontext for glibc on some platforms.
+ [ruby-list:38984]
-Mon Jun 21 15:38:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 24 23:48:04 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * io.c (fptr_finalize): remove rb_syswait() invocation to avoid
- wait4(2) within GC. rb_syswait() moved to rb_io_fptr_close().
+ * test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb
+ test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0"
+ to express -0.0. [ruby-talk:88786]
-Mon Jun 21 12:05:59 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+Wed Dec 24 23:29:30 2003 Tanaka Akira <akr@m17n.org>
- * dir.c (dir_s_glob): remove MAXPATHLEN restriction.
+ * lib/tsort.rb (test_orphaned_break): removed.
- * ext/md5/md5init.c (md5_hexdigest): should have used "%02x".
+Wed Dec 24 20:53:06 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sun Jun 20 19:50:38 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * ext/tk/sample/tkmulticolumnlist.rb: new sample
- * string.c (rb_str_each_line): should have checked string
- boundary.
+ * ext/tk/sample/tkmultilistframe.rb: bug fix
-Sat Jun 19 22:24:12 1999 Kenji Nagasawa <kenn@hma.att.ne.jp>
+Wed Dec 24 20:37:37 2003 Eric Sunshine <sunshine@sunshineco.com>
- * OS/2 patch improved.
+ * configure.in (LDSHARED): Fixed typographical error in assignment of
+ LDSHARED for Rhapsody which caused linking of extension modules to
+ fail.
-Fri Jun 18 08:30:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 24 17:51:18 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * marshal.c (r_byte): add data length check.
+ * file.c (rb_thread_flock): enable thread support again.
- * ext/tcltklib/tcltklib.c (_timer_for_tcl): was doing busy-wait.
+Wed Dec 24 16:46:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Jun 15 10:01:21 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * eval.c (catch_timer): do not call rb_thread_schedule() inside to
+ avoid pthread_mutex_lock() deadlock. interrupts to system calls
+ are detected by TRAP_END via EINTR error.
- * configure.in: remove trailing slash from interpreter embedded
- shared library path.
+ * eval.c (thread_timer): do not post signal unless it is
+ absolutely necessary.
- * configure.in (INSTALL_DLLIB): install shared lib with 0555.
+ * rubysig.h (TRAP_END): add CHECK_INTS to switch thread.
- * instruby.rb: changed mode for shared library into 0555.
+ * regex.c (re_compile_pattern): check if nextp is smaller than
+ pend. [ruby-dev:22372]
-Fri Jun 11 23:27:00 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * eval.c (umethod_bind): remove method overridden check.
+ [ruby-dev:22366]
- * ext/etc/etc.c (etc_passwd): should return nil, not exception for
- call after last passwd entry.
+Wed Dec 24 16:13:05 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Jun 11 15:21:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_ssl.c (ossl_ssl_read): should check for error
+ status by SSL_get_error().
- * gc.c (rb_gc_mark_locations): add safety margin 1.
+ * ext/openssl/ossl_ssl.c (ossl_ssl_write): ditto.
- * eval.c (ruby_run): should protect toplevel node tree.
+Wed Dec 24 14:23:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/etc/etc.c (etc_group): dumps core if there's no more group.
+ * ext/stringio/stringio.c (strio_read): clear the buffer argument
+ when returning nil. [ruby-dev:22363]
-Fri Jun 11 01:50:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/ut_eof.rb (TestEOF::test_eof_0, TestEOF::test_eof_1):
+ add buffer argument tests.
- * eval.c (ruby_run): Init_stack() was called too late; local
- variables happened to be higher (or lower) than stack_start.
+Wed Dec 24 14:07:55 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Jun 10 16:41:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/assertions.rb: Modules are allowed to rescue.
- * io.c: do not call `initialize' for IO objects. So with Array,
- Hash, Range, and Time objects.
-
- * ext/curses/curses.c (curses_getch): made thread aware using
- rb_read_check().
+ * lib/test/unit/autorunner.rb: show output_level in order.
- * ext/curses/curses.c (window_getch): ditto.
+ * lib/test/unit/collector/dir.rb: get rid of successive same
+ directories in load path.
- * ext/curses/curses.c (curses_getstr): made (partially) thread
- aware using rb_read_check().
+ * test/testunit/test_assertions.rb (test_assert_nothing_raised,
+ test_assert_raise): test for modules.
- * ext/curses/curses.c (window_getstr): ditto.
+Wed Dec 24 13:43:34 2003 Shugo Maeda <shugo@ruby-lang.org>
- * io.c (rb_read_check): new function to help making something
- (like extension libraries) thread aware.
+ * lib/net/imap.rb (authenticate): remove "\n" from base64 encoded
+ strings.
- * eval.c (is_defined): `defined? super' should be true even for
- private superclass methods.
+Wed Dec 24 11:26:41 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Jun 10 13:42:10 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * test/fileutils/test_fileutils.rb: should not create any
+ files or directories in current directory. [ruby-talk:88724]
- * pack.c (pack_pack): template `Z' should be allowed.
+Wed Dec 24 10:29:53 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jun 9 13:26:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/stringio/stringio.c (strio_read): never return nil at
+ unlimited read. [ruby-dev:22334]
- * eval.c (rb_thread_loading): modified to avoid nested race
- condition of require().
+ * ext/stringio/stringio.c (strio_read): support second
+ argument. [ruby-dev:22350]
- * ext/tcltklib/tcltklib.c (ip_invoke): queue invocation on non
- main threads.
+Wed Dec 24 09:38:49 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/tcltklib/tcltklib.c (lib_mainloop): flush invocation
- queues periodically.
+ * parse.y (arg): should return 0 after error. [ruby-dev:22360]
- * version.c (ruby_show_version): now print the message to stdout.
+Wed Dec 24 00:56:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * version.c (ruby_show_copyright): ditto.
+ * io.c (read_all): do not return nil at the end of file.
+ [ruby-dev:22334]
-Tue Jun 8 00:00:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * io.c (argf_read): do not depend on nil at eof behavior of
+ IO#read().
- * pack.c (pack_unpack): append sentinel (NUL) to the string.
+ * eval.c (rb_thread_join): dup exception before re-raising it.
- * ext/md5/md5init.c (md5_hexdigest): new method to obtain
- printable hash string.
+ * io.c (rb_io_eof): call clearerr() to prevent side effect. this
+ patch is supplied by Masahiro Sakai <sakai@tom.sfc.keio.ac.jp>.
+ [ruby-dev:22234]
- * ext/md5/md5init.c (md5_update): should return self.
+ * pack.c (OFF16): get offset for big endian machines.
- * pack.c (pack_pack): undocumented template 'U' for UTF8.
+ * pack.c (pack_pack): use OFF16 instead of OFF16B.
+ [ruby-dev:22344]
* pack.c (pack_unpack): ditto.
- * marshal.c (r_byte): should replace getc() with rb_getc().
-
- * io.c (rb_getc): getc() replacement uses READ_DATA_PENDING() and
- rb_thread_wait_fd().
-
-Mon Jun 7 23:23:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * object.c (rb_mod_clone): should call CLOSESETUP().
-
- * eval.c (bind_clone): should call CLONESETUP() for new clone.
-
-Sat Jun 5 10:32:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (rb_str_oct): binary (e.g. 0b10111) support.
-
- * variable.c (rb_const_set): raise warning, not exception.
-
- * parse.y (yycompile): initialize parser internal variables.
+Tue Dec 23 22:47:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (close_paren): set lex_state to EXPR_PAREN after closing
- parenthesis.
+ * io.c (rb_io_check_readable): set FMODE_RBUF always, even if
+ NEED_IO_SEEK_BETWEEN_RW is not defined. [ruby-dev:22340]
- * parse.y (yylex): returns kDO for `do' right after method_call.
+ * io.c (rb_io_check_writable): clear FMODE_RBUF before writing
+ something.
-Thu Jun 3 11:05:30 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Tue Dec 23 22:25:00 2003 Gavin Sinclair <gsinclair@soyabean.com.au>
- * regex.c (read_backslash): should decode \b within class.
+ * lib/optparse.rb: incomplete RDoc documentation added in place of
+ existing RD comments. Tabs converted to spaces.
-Thu Jun 3 01:06:18 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+Tue Dec 23 19:44:47 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * dln.c (dln_load): AIX improvement (aix_findmain removed).
+ * test/soap/test_streamhandler.rb (test_basic_auth): removed.
+ soap4r + basic_auth is not officially supported in ruby/1.8.1 even
+ though soap4r + basic_auth + http-access2 should run fine.
-Wed Jun 2 00:41:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Dec 23 19:42:59 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * pack.c (pack_unpack): new undocumented template Z which strips
- stuff after first null.
+ * io.c (rb_io_ungetc): raise an exception at unread stream to
+ avoid unspecified behavior. [ruby-dev:22330]
- * pack.c (pack_pack): should preserve specified length of the
- resulting string.
+ * test/ruby/test_system.rb (test_syntax): glob relatively from
+ __FILE__.
-Tue Jun 1 15:29:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Dec 23 18:09:40 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/socket/socket.c (ruby_socket): retry after GC, if socket(2)
- failed on EMFILE or ENFILE.
+ * pack.c (pack_pack): remove unnecessary negative value check.
+ [ruby-dev:22329]
- * ext/socket/socket.c (sock_s_socketpair): ditto.
+Tue Dec 23 17:26:55 2003 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
- * eval.c (module_setup): need to add PUSH_VAR/POP_VAR to clear
- dyna vars link list.
+ * bcc32/Makefile.sub (config.h): bcc has finite(). [ruby-list:38940]
- * version.h (RUBY_RELEASE_CODE): integer macro constant for source
- version detection.
+Tue Dec 23 16:08:16 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Sun May 30 22:19:12 1999 Kenji Nagasawa <kenn@tcp-ip.or.jp>
+ * lib/rexml/encodings/US-ASCII.rb: typo. [ruby-talk:88650]
- * ext/socket/socket.c: emx/gcc 0.9d now fixes things about
- AF_UNIX.
+ * test/ruby/test_system.rb: num of asserts depended on running dir.
- * process.c: OS/2 EMX kludge.
+ * test/xsd/test_noencoding.rb: rexml + without iconv/uconv cannot
+ handle euc-jp. install iconv, uconv or xmlscan.
- * Makefile.in (strncasecmp.o): added dependency.
+Tue Dec 23 14:13:51 2003 akira yamada <akira@ruby-lang.org>
-Mon May 31 16:06:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/uri/generic.rb (URI::Generic::check_userinfo,
+ URI::Generic::check_user, URI::Generic::check_password): tests
+ conflicts/depends with other components closely.
- * version 1.3.4 - preliminary release for 1.4
+ * test/uri/test_generic.rb (TestGeneric::test_set_component):
+ added tets.
-Mon May 31 15:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Dec 23 11:08:34 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * io.c (rb_io_fptr_close): close on IO which main_thread is
- waiting cause serious exception, that vanishes the actual fd
- closing. Invocation of rb_thread_fd_close() is deferred
- a little.
+ * test/xsd/test_noencoding.rb: rescue Errno::EINVAL and do not test.
+ "euc-jp" might not be in supported encoding name list.
+ [ruby-talk:88650]
-Sat May 29 18:27:13 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Tue Dec 23 06:10:31 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * regex.c (re_match): stack boundary check needed.
+ * lib/webrick/cgi.rb (CGI): add support for mod_ruby.
-Sat May 29 12:27:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/webrick/cgi.rb (CGI::Socket): add check for existence of
+ OpenSSL module in all HTTPS related methods.
- * ext/tcltklib/tcltklib.c (ip_invoke): proper ref count management
- to avoid leak. I HATE REF COUNTING!!
+ * lib/webrick/cgi.rb (CGI::Socket#cipher): should create similar
+ value to OpenSSL::SSLSocket#cipher.
- * eval.c (ruby_run): moved ruby_require_libraries() to handle `-r'
- from ruby_options() to avoid stack corruption for threads
- created in libraries.
+ * lib/webrick/httpresponse.rb (HTTPResponse#setup_header): should
+ set "connection: close" if @keep_alive is false.
-Sat May 29 02:22:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/webrick/https.rb (HTTPrequest#meta_vars): add supprt for
+ SSL_PROTOCOL, SSL_CIPHER_USEKEYSIZE and SSL_CIPHER_ALGKEYSIZE.
- * eval.c (rb_yield_0): when `for' appeared in blocks, it
- introduced new scope for local variables.
+Mon Dec 22 23:00:05 2003 akira yamada <akira@ruby-lang.org>
-Fri May 28 17:16:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/uri/generic.rb (URI::Generic::check_opaque): fixed typo.
- * string.c (rb_str_squeeze_bang): squeeze AND of the arguments.
- UNDOCUMENTED.
+Mon Dec 22 21:59:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_count): new UNDOCUMENTED method.
+ * ext/iconv/iconv.c (map_charset): always ensure code is a String.
- * string.c (rb_str_delete_bang): delete AND of the arg ranges.
- UNDOCUMENTED FEATURE for 1.3.x.
+Mon Dec 22 21:15:29 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/socket/socket.c (setipaddr): re-wrote using ip_addrsetup().
+ * class.c (rb_mod_init_copy): always copy singleton class.
+ [ruby-dev:22325]
- * ext/socket/socket.c (ip_addrsetup): decode symbolic address
- <broadcast>.
+Mon Dec 22 20:44:36 2003 akira yamada <akira@ruby-lang.org>
-Thu May 27 12:27:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/uri/generic.rb (URI::Generic#route_from): accepts urls which
+ has no host-part.
- * string.c (tr_trans): should handle NUL (\0) within strings.
+ * test/uri/test_generic.rb (TestGeneric::test_route): added a test.
-Tue May 25 16:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Dec 22 20:38:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_f_syscall): syscall may return values other than zero
- on success.
+ * lib/cgi.rb: reduce eval.
- * regex.c (re_match): handle empty loop properly (hopefully).
+ * lib/cgi.rb (CGI::QueryExtension::read_multipart): alias path to
+ local_path. [ruby-list:38883]
- * regex.c (re_match): remove empty group check, because it does
- not help non-grouping parentheses (?:..).
+Mon Dec 22 20:09:31 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * regex.c (re_compile_fastmap): treating try_next, finalize_push
- wrong way.
+ * test/soap/test_property.rb: remove duplicated test method.
- * regex.c: remove some obsolete functions such as
- group_match_null_string_p().
+Mon Dec 22 18:22:04 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Mon May 24 14:47:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * bcc32/Makefile.sub, win32/Makefile.sub (config.h): remove
+ HAVE_ISINF definition to follow previous commits of missing.h
+ and win32/win32.h.
- * regex.c (read_backslash): read backslash by regex.
+Mon Dec 22 17:23:42 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun May 23 19:44:58 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * configure.in (ac_cv_func_setitimer): moved from defines.h
- * ext/pty/pty.c (getDevice): portability patch.
+ * defines.h, rubysig.h, signal.c: removed macro handling which
+ should be done in configure.
-Fri May 21 23:01:26 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * configure.in (intrinsics.h): check if present.
- * ext/socket/getaddrinfo.c (GET_AI): should set error code.
+ * ruby.h: include intrinsics.h if available.
-Thu May 20 03:43:44 1999 Jun-ichiro itojun Hagino <itojun@itojun.org>
+ * bignum.c, marshal.c: include ieeefp.h if available.
- * ext/socket/socket.c: you should use sockaddr_storage to handle
- IPv6 addresses.
+ * missing.h (isinf): define as a macro if finite() and isnan()
+ are available. [ruby-core:02032]
- * ext/socket/getaddrinfo.c (getaddrinfo): prevent retrieving
- AF_INET6 address if hints.ai_flags == AI_PASSIVE.
+Mon Dec 22 17:07:31 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Wed May 19 12:27:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * configure.in (mingw): set isnan, finite and isinf to yes.
- * eval.c (exec_end_proc): should protect exceptions.
+Mon Dec 22 13:40:19 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * gc.c (run_final): ditto.
+ * lib/soap/property.rb: passing block by reference.
- * parse.y (f_rest_arg): allow just * for rest arg.
+Mon Dec 22 00:32:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (mlhs_basic): allow * without formal argument.
+ * eval.c (rb_with_disable_interrupt): use ENABLE_INTS instead of
+ ALLOW_INTS which may switch context. [ruby-dev:22319]
- * regex.c (re_match): the variable `part' should be initialized.
+ * ext/syck/emitter.c (syck_emitter_write): str bigger than
+ e->bufsize causes buffer overflow. [ruby-dev:22307]
-Tue May 18 15:25:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Dec 21 17:29:00 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_search): a bug in range adjustment.
+ * class.c (rb_check_inheritable): new function. [ruby-dev:22316]
-Tue May 18 11:35:59 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * intern.h: add prototype.
- * dln.c (conv_to_posix_path): path_len argument added.
+ * eval.c (superclass): use rb_check_inheritable().
-Mon May 17 12:26:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * object.c (rb_class_initialize): check argument validity.
- * numeric.c (fix_rev): should treat Fixnum as signed long.
+Sun Dec 21 16:25:10 2003 Tanaka Akira <akr@m17n.org>
- * eval.c (massign): add strict number check for yield (and call).
+ * lib/pathname.rb (Pathname#+): re-implemented to resolve ".." in
+ beginning of the argument.
+ (Pathname#join): concatenate from the last argument.
+ (Pathname#parent): just use Pathname#+.
- * eval.c (proc_arity): new method to return number of arguments.
+Sun Dec 21 00:12:37 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * eval.c (method_arity): new method to return number of arguments.
+ * ext/tk/lib/tk.rb: add new methods (TkScrollbar#assign, assign_list)
- * parse.y (read_escape): char may be unsigned.
+ * ext/tk/sample/tkmultilistframe.rb: use TkScrollbar#assign method
- * string.c (rb_str_succ): ditto.
+Sat Dec 20 21:59:03 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * string.c (tr_trans): ditto.
+ * lib/webrick/httprequest.rb (HTTPRequest#meta_vars): refine regexp.
- * object.c (Init_Object): methods `&', `|', `^' are added to nil.
+ * lib/webrick/cgi.rb (CGI#start): NPH scripts return status line
+ instead of Status: header field.
- * range.c (rb_range_beg_len): it should be OK for [0..-len-1].
+ * lib/webrick/cgi.rb (CGI::Socket): refine some coditions.
- * regex.c (re_search): search for byte literal within mbcs.
+Sat Dec 20 16:07:14 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (is_in_list): parsh
+ * lib/optparse.rb (OptionParser::Completion::complete): wrong
+ Regexp for word boundary. pointed out by Gavin Sinclair.
- * regex.c (re_compile_fastmap): should have not alter the loop
- variable `j' if TRASLATE_P().
+ * lib/optparse.rb (OptionParser::make_switch): [no-] prefix was
+ missing.
- * regex.c (re_compile_pattern): escaped characters should be read
- by PATFETCH_RAW(c).
+Sat Dec 20 11:40:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat May 15 11:23:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/yaml.rb (YAML::YAML): adjust Marshal version.
- * regex.c (re_match): endline2 (\Z) should not match at the point
- between a newline and end-of-line, like endline ($).
+Sat Dec 20 03:56:02 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * class.c (include_class_new): should initialize iv_tbl to share
- between module and iclass.
+ * eval.c (rb_with_disable_interrupt): prohibit thread context
+ switch during proc execution. [ruby-dev:21899]
-Fri May 14 08:50:27 1999 Akira Endo <akendo@t3.rim.or.jp>
+Sat Dec 20 02:41:02 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * regex.c (re_compile_fastmap): it should be k != 0 to skip.
+ * lib/webrick/cgi.rb: add file. (yet another CGI library)
-Fri May 14 12:46:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * MANIFEST: add lib/webrick/cgi.rb.
- * time.c (time_load): a bug in old marshal format support.
+Sat Dec 20 02:18:31 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * instruby.rb: make site_ruby directory.
+ * misc/ruby-mode.el (ruby-calculate-indent): proper indentation
+ inside of parentheses. [ruby-dev:22308]
-Fri May 14 10:18:02 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+Fri Dec 19 21:24:22 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * regex.c (re_match): a bug in inline `.*' etc.
+ * lib/webrick/httprequest.rb (HTTPRequest#meta_vars): should not set
+ HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH.
-Fri May 14 09:58:46 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+ * lib/webrick/https.rb (HTTPRequest#parse): should check presence
+ of cert() method to detect SSLSocket.
- * ruby.c (addpath): should have specified string length.
+Fri Dec 19 22:56:46 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Thu May 13 10:40:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/property.rb (SOAP::Property#load): new method for loading
+ property value into existing property tree.
- * eval.c (rb_eval_string_wrap): new function.
+ * test/soap/test_property.rb: add test.
- * regex.c (re_compile_pattern): POSIX line match should alter
- behavior for `^' and `$' to begbuf and endbuf2 respectively.
+Fri Dec 19 19:21:49 2003 akira yamada <akira@ruby-lang.org>
- * ext/pty/pty.c: un-ANSI-fy function arguments.
+ * lib/runit/cui/testrunner.rb (RUNIT::CUI::TestRunner::run):
+ should use Test::Unit::UI::{PROGRESS_ONLY,VERBOSE}.
-Wed May 12 14:19:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Dec 19 17:36:49 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * struct.c (iv_get): in case of inheritance of generated struct
- class, __member__ and __size__ should also be inherited.
- Thanks for Pros Yeboah <yeboah@tu-harburg.de>.
+ * ext/tk/sample/tkmultilistbox.rb: bug fix
- * io.c (rb_f_gets_internal): should check number of arguments
- before checking rb_rs == rb_default_rs. Thanks for Koji Arai
- <JCA02266@nifty.ne.jp>.
+ * ext/tk/sample/tkmultilistframe.rb: new sample script
-Tue May 11 08:29:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Dec 19 03:44:27 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * regex.c (re_compile_pattern): .?, .+ did not work.
+ * lib/webrick/httputils.rb (parse_form_data): should return an
+ empty Hash if the body is empty.
-Mon May 10 00:59:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Dec 18 21:47:35 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/jcode.rb: forgot to squeeze on reverse (complement) case.
+ * lib/mkmf.rb (create_makefile): should remove deffile if it's
+ made by miniruby. based on nobu's patch.
- * string.c (tr_squeeze): should not set modify flag to be honest,
- if the string is not modified.
+Thu Dec 18 21:44:21 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * signal.c (Init_signal): SIGTERM should not be handled.
+ * eval.c (stack_extend): ignore inline optimization on VC7.
- * regex.c (re_match): seeking for longest match is now optional,
- which can be set using RE_OPTION_POSIXMATCH. This satisfies
- POSIX longest match as much as Emacs's posix-* functions, which
- are known to be incomplete.
+ * win32/Makefile.sub (OS, RT): can override.
-Sun May 9 13:04:01 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * win32/Makefile.sub (LDFLAGS): ditto. shouldn't use pdb:none
+ option. based on Tietew's patch [ruby-dev:22289]
- * ext/socket/socket.c (sock_s_getaddrinfo): conversion from
- Fixnums to C integers needed.
+Thu Dec 18 16:38:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun May 9 11:51:43 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * dir.c (fnmatch): unlike find_dirsep(), rb_path_next() never
+ return NULL.
- * range.c (range_eqq): reverse condition.
+Thu Dec 18 15:27:59 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * range.c (range_s_new): default should be end inclusive.
+ * lib/ipaddr.rb (IPSocket::getaddress): merge usa's patch.
+ [ruby-dev:21678]
-Sat May 8 03:27:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 17 15:15:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/socket/socket.c (thread_connect): replace nasty
- rb_thread_fd_writable() with rb_thread_select().
+ * lib/cgi.rb (CGI::QueryExtension::Value::[]): should work like
+ String#[] if more than one arguments are specified.
-Fri May 7 20:49:00 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * lib/delegate.rb: avoid using common instance name as "@obj".
- * ext/socket/getaddrinfo.c (inet_pton): wrong parameter to
- inet_aton().
+ * lib/cgi.rb (CGI::QueryExtension::Value): Value is no longer
+ subclass of String, but DelegateClass(String).
- * ext/socket/addrinfo.h (__P): silly cut and paste typo.
+ * ext/curses/extconf.rb: restore function check for init_color.
+ [ruby-list:38905]
-Fri May 7 17:03:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * Makefile.in: need to specify $(MAINLIBS) for the miniruby
+ generation rule.
- * dir.c (glob): removed GPL'ed glob.c completely.
+ * configure.in: better FreeBSD -lc_r support.
-Fri May 7 08:17:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 17 00:16:14 2003 Minero Aoki <aamine@loveruby.net>
- * ext/sdbm/extconf.rb: sdbm extension added to the distribution.
+ * ext/strscan/strscan.c: new method
+ StringScanner#beginning_of_line? (alias #bol?)
-Fri May 7 01:42:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/strscan/strscan.c: new method StringScanner#concat and #<<.
- * ext/socket/socket.c (tcp_s_gethostbyname): avoid using struct
- sockaddr_storage.
+ * ext/strscan/strscan.c: StringScanner#new(str) does not duplicate
+ nor freeze STR (allow destructive modification).
-Thu May 6 13:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/strscan/test_stringscanner.rb: test new methods above.
- * array.c (rb_ary_indexes): should not use rb_ary_concat().
+ * test/strscan/test_stringscanner.rb: test destructive string
+ modification.
-Thu May 4 12:34:18 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Tue Dec 16 21:20:47 2003 Tanaka Akira <akr@m17n.org>
- * parse.y (parse_string): there should be newline escape by
- backslashes in strings.
+ * lib/pp.rb: don't use local variable `pp'.
- * parse.y (parse_qstring): ditto.
+ * lib/prettyprint.rb: ditto.
-Mon May 3 04:37:20 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Tue Dec 16 13:20:43 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tcltklib/extconf.rb: better search for libX11.
+ * ext/tk/lib/tk.rb: condition bug of if statement on
+ {pack,grid}_propagate methods
- * range.c (range_s_new): embarrassing =/== typo.
+Tue Dec 16 03:17:29 2003 why the lucky stiff <why@ruby-lang.org>
- * re.c (Init_Regexp): failed to set default kcode.
+ * lib/yaml/rubytypes.rb: comments in strings. [ruby-talk:88012]
-Mon May 3 02:39:55 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * test/yaml/test_yaml.rb: add test.
- * ext/socket/socket.c (open_inet): typo (res and res0).
+Tue Dec 16 01:14:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue May 4 02:07:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (catch_timer): check rb_thread_crtical in main native
+ thread.
- * mkconfig.rb: leave undefined $(VARIABLE) unexpanded in the
- Config::CONFIG hash table.
+ * eval.c (thread_timer): just sends signals periodically, to
+ prevent main native thread from receiving them in critical
+ section. [ruby-core:01959]
-Mon May 3 09:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Dec 15 13:32:22 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_compile_pattern): expand exactn{n} at compile time.
- handles stop_paren specially.
+ * dir.c (check_dirname): check string safety and remove extraneous
+ trailing directory separators. [ruby-dev:22279]
- * regex.c (re_compile_pattern): expand x{n} at compile time.
+ * file.c: renamed and externalized rb_path_next,
+ rb_path_skip_prefix, rb_path_last_separator, rb_path_end.
- * regex.c (re_search): posix line match should be checked.
+ * intern.h: prototypes for rb_path_next, rb_path_skip_prefix,
+ rb_path_last_separator, rb_path_end.
- * regex.c (re_search): a bug in anchor condition.
+Mon Dec 15 09:27:46 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Apr 30 18:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_pkcs12.c (ossl_pkcs12_initialize): first argument
+ of rb_protect should take an argument of VALUE.
- * version 1.3.3
+Sun Dec 14 18:46:48 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * string.c (rb_str_rindex): position should be END point, not
- START point.
+ * ext/socket/socket.c (Init_socket): IPv6 is not supported although
+ AF_INET6 is defined on MinGW.
- * re.c (rb_reg_search): pos means end point on reverse now.
+ * lib/ipaddr.rb (AF_INET6): workaround in the environment which does
+ not support IPv6.
- * array.c (rb_ary_s_create): should clear ary->ptr to avoid
- potential gc crash.
+Sat Dec 13 18:55:16 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Apr 30 15:24:58 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/iconv/charset_alias.rb: preserve original order.
- * ext/socket/addrinfo.h: compatibility hack for ipv4.
+ * ext/iconv/extconf.rb: remove wrapper file at clean.
- * ext/socket/socket.c: itojun's ipv6 patches applied.
+Sat Dec 13 18:09:42 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/socket/extconf.rb: detect ipv6 features based on itojun's
- ipv6 patches.
+ * eval.c (thread_timer): use timer by sub-thread and nanosleep.
+ [ruby-talk:87519]
- * ext/extmk.rb.in (enable_config): can handle --enable-xxx now.
+ * gc.c (Init_stack): no stack adjustment for THREAD_SAFE.
- * lib/mkmf.rb (enable_config): ditto.
+Sat Dec 13 17:17:59 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Apr 30 05:22:23 1999 Shugo Maeda <shugo@netlab.co.jp>
+ * eval.c (proc_alloc): cache the created object at first time.
+ [ruby-talk:61288], [ruby-dev:22240]
- * string.c (rb_str_aset): last index should not append.
+Sat Dec 13 09:01:23 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Apr 29 18:55:31 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+ * configure.in: check ucontext.h.
- * dln.c (conv_to_posix_path): remove const from args.
+ * eval.c: use getcontext/setcontext() instead of setjmp/longjmp()
+ on ia64 or with native thread enabled. [ruby-core:01932]
- * ruby.c (rubylib_mangle): remove Fatal(), the obsolete function.
+Sat Dec 13 03:09:14 2003 why the lucky stiff <why@ruby-lang.org>
-Tue Apr 27 14:11:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/yaml/rubytypes.rb: anonymous struct fix. [ruby-core:01946]
- * parse.y (fname): lazy workaround for keywords did not work well.
+ * test/yaml/test_yaml.rb: add test.
- * ext/extmk.rb.in: `--with-xxx=yyy' argument configuration.
-
- * lib/mkmf.rb: ditto.
-
- * misc/ruby-mode.el: forgot to handle $`.
-
- * ext/extmk.rb.in: better AIX link support proposed by
- <komatsu@sarion.co.jp>.
-
-Mon Apr 26 16:46:59 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * ext/extmk.rb.in: AIX shared library support modified.
-
- * ext/aix_mksym.rb: ditto.
-
- * configure.in: ditto.
+Fri Dec 12 22:36:44 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * sprintf.c (rb_f_sprintf): should allocate proper sized buffer
- for float numbers.
+ * lib/csv.rb: add Cell#to_str and Cell#to_s for /.../ =~ aCell,
+ "#{aCell}" and so on.
-Sat Apr 24 00:00:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/csv/test_csv.rb: add tests.
- * parse.y (operation): syntax like `a.[]=(1,2)' is allowed.
+Fri Dec 12 19:33:06 2003 Minero Aoki <aamine@loveruby.net>
-Fri Apr 23 23:54:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/fileutils.rb (mkdir): remove trailing `/' from pathes.
- * io.c (argf_binmode): binmode method added to ARGF.
+ * lib/fileutils.rb (rmdir): ditto. [ruby-dev:22238]
-Fri Apr 23 13:55:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/fileutils.rb (rmdir_r): ditto.
- * string.c (rb_f_chomp): should assign the result to $_. or maybe
- sub/gsub/chop/chomp should NOT assign $_ altogether.
+ * lib/fileutils.rb (fu_copy_dir): check if it is a directory after
+ mkdir(2).
-Thu Apr 22 16:50:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Dec 12 06:06:09 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_callcc): call scope_dup() for all scopes in
- the interpreter stack.
+ * eval.c (proc_invoke): fix class name in warning message for
+ define_method. [ruby-dev:22235]
-Tue Apr 20 11:24:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Dec 11 21:24:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * string.c (rb_str_dump): `#' should be escaped.
+ * ext/openssl/ossl_pkcs12.[ch]: new files. add OpenSSL::PKCS12.
-Tue Apr 20 02:32:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl.[ch]: ditto.
- * parse.y (parse_regx): option /p for posix match added.
+ * ext/openssl/MANIFEST: add ossl_pkcs12.[ch].
- * re.c (rb_reg_desc): did not print options properly.
+Thu Dec 11 20:54:28 2003 Minero Aoki <aamine@loveruby.net>
- * io.c (rb_file_s_open): initialize was called twice.
+ * lib/fileutils.rb (mkdir_p): remove trailing `/' befere mkdir(2).
+ mkdir("nonexistdir/") does not work on NetBSD/Alpha 1.6.1.
-Mon Apr 19 18:56:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/fileutils.rb (fu_list): call to_str for all arguments.
- * configure.in (DEFAULT_KCODE): can specify default code for
- $KCODE by --with-default-kcode=(euc|sjis|utf8|none).
+Thu Dec 11 20:07:01 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * regex.c (IS_A_LETTER): a byte sequence shorter than mbc should
- not match with \w etc.
+ * lib/ftools.rb (makedirs): sync with fileutils.
-Mon Apr 19 13:49:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Dec 11 19:53:03 2003 Minero Aoki <aamine@loveruby.net>
- * eval.c (eval): should restore ruby_dyna_vars.
+ * lib/fileutils.rb (mkdir_p): catch all SystemCallErrors.
+ (mkdir("C:\") causes EACCESS on Windows 2000/NTFS)
-Fri Apr 16 21:40:43 1999 Nobuyoshi Nakada <gea02117@nifty.ne.jp>
+Thu Dec 11 19:08:02 2003 Minero Aoki <aamine@loveruby.net>
- * io.c (f_backquote): pipe_open may return nil.
+ * lib/fileutils.rb (mkdir_p): check if it is a directory after
+ mkdir(2) instead of before mkdir(2), to avoid race condition.
+ [ruby-talk:87730]
+ Refer: mkinstalldirs sh script, GNU mkdir(1) (coreutils 5.0)
- * io.c (f_open): rb_io_open may return nil.
+Thu Dec 11 18:49:30 2003 Minero Aoki <aamine@loveruby.net>
- * io.c (io_s_foreach): ditto.
+ * lib/fileutils.rb: def m( arg ) -> def m(arg).
- * io.c (io_s_readlines): ditto.
+Thu Dec 11 11:39:43 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (io_defset): wrong message.
+ * configure.in (ieeefp.h), numeric.c: needed for finite() on
+ Solaris. [ruby-core:01921]
-Fri Apr 16 15:09:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * file.c (rb_stat_inspect): adjust format specifier.
- * bignum.c (rb_str2inum): strtoul() returns long, not int.
+ * parse.c (arg_prepend): nodetype() is for debug use.
- * eval.c (rb_load): size of VALUE and ID may be different.
+ * ruby.h (ISASCII, etc): cast to int to get rid of warning.
- * util.c (mmprepare): int is too small to cast from pointers.
+ * ruby.h (alloca.h): include even in GCC. [ruby-core:01925]
- * config.guess: avoid 'linux-gnu' for alpha-unknown-linux.
+ * ext/bigdecimal/bigdecimal.c (GetVpValue): adjust format
+ specifier.
-Thu Apr 15 23:46:20 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_prec, BigDecimal_coerce,
+ BigDecimal_divmod): use rb_assoc_new() to suppress memory usage.
- * ruby.c (rubylib_mangle): mangle path by RUBYLIB_PREFIX.
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_split): ditto.
-Wed Apr 14 23:52:51 1999 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+ * ext/dl/sym.c (rb_dlsym_guardcall): guard itself should be
+ volatile.
- * node.h (NODE_LMASK): should be long to avoid overflow.
+ * ext/iconv/iconv.c (iconv_convert): ensure actual parameter with
+ format specifier.
-Wed Apr 14 13:14:35 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+ * ext/pty/pty.c (MasterDevice, SlaveDevice, deviceNo): do not
+ define unless used.
- * dln.c: AIX dynamic link.
+ * ext/pty/pty.c (getDevice): get rid of warning.
- * ext/aix_ld.rb: ditto.
+ * ext/socket/socket.c (port_str, sock_s_getaddrinfo,
+ sock_s_getnameinfo): FIX2INT() now returns long.
-Wed Apr 14 12:19:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/socket.c (init_inetsock_internal): uninitialized
+ variable.
- * lib/thread.rb: Queue#{enq,deq} added.
+ * ext/syck/rubyext.c (syck_parser_assign_io): add prototype.
-Tue Apr 13 17:43:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/rubyext.c (rb_syck_mktime, yaml_org_handler): use
+ ISDIGIT() instead of isdigit() to avoid warnings and for
+ platforms which don't support non-ascii charater.
- * hash.c (rb_hash_s_create): Hash::[] acts more like casting.
+Wed Dec 10 19:28:56 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Apr 13 00:33:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/stringio/stringio.c (strio_read): set EOF flag at short read.
+ [ruby-dev:22223], [ruby-dev:22224]
- * io.c (rb_io_stdio_set): warning for assignment to the variables
- $std{in,out,err}.
+Wed Dec 10 18:07:25 2003 Minero Aoki <aamine@loveruby.net>
-Mon Apr 12 23:12:32 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/erb.rb: new method ERB#filename(=). [ruby-dev:22208]
- * io.c (rb_io_reopen): check for reopening same IO.
+Wed Dec 10 17:54:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Apr 9 17:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/stringio/stringio.c (strio_read): do not set EOF flag when
+ requested length is zero. [ruby-dev:22214]
- * parse.y (rb_compile_string): bug for nested eval().
+Wed Dec 10 17:17:18 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_match): should pop non-greedy stack items on
- failure, after best_regs are fixed.
+ * io.c (read_all): should return given string even if data read is
+ empty. [ruby-dev:22207]
-Thu Apr 8 17:30:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 10 17:16:06 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * pack.c (PACK_LENGTH_ADJUST): need to adjust for `*' length.
+ * ext/stringio/stringio.c (strio_read): adjust behavior at reading
+ beyond EOF to IO. [ruby-dev:22205]
-Tue Apr 6 23:28:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/ut_eof.rb (TestEOF::Seek): test behaviors at reading
+ beyond EOF.
- * parse.y (void_check): add void context checks.
+ * test/ruby/test_file.rb, test/stringio/test_stringio.rb: include
+ TestEOF::Seek test case.
-Mon Apr 5 12:23:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 10 15:01:19 2003 Shugo Maeda <shugo@ruby-lang.org>
- * time.c (time_s_at): should copy gmt-mode.
+ * test/monitor/test_monitor.rb (test_cond): use Queue#deq
+ instead of sleep.
- * eval.c (eval_node): preserve ruby_eval_tree.
+Wed Dec 10 14:45:39 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Fri Apr 2 14:00:34 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+ * ext/pty/pty.c (HAVE_SYS_IOCTL_H): need to include <sys/ioctl.h>
+ for TIOCSCTTY on *BSD. based on gotoyuzo's patch.
+ (ruby-bugs:PR#1211)
- * lib/debug.rb: wrong command interpreting.
+ * ext/pty/pty.c (establishShell): should close descriptors if fork
+ failed.
-Fri Apr 2 11:46:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 10 12:53:05 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * version 1.3.2
+ * win32/win32.h: define execv() using do_aspawn().
-Fri Apr 2 10:40:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * process.c (proc_exec_v): remove #ifdef's which stopped needing.
- * io.c (rb_io_s_pipe): forgot to define IO::pipe.
-
-Thu Apr 1 14:40:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (assign): modified for rhs change.
-
- * parse.y (stmt): unparenthesisized method calls can be right hand
- side expression of the assignment.
-
-Sat Mar 27 22:42:47 1999 Koji Arai <JCA02266@nifty.ne.jp>
-
- * ext/nkf/nkf.c (rb_nkf_kconv): check size output_ctr before
- decrement.
-
-Thu Mar 25 09:11:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * time.c (time_s_at): preserve gmt-mode for result.
-
- * parse.y (rb_compile_string): do not use cur_mid, use
- compile_for_eval instead.
-
- * st.c (PTR_NOT_EQUAL): wrong logical condition.
-
-Wed Mar 24 13:06:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (yycompile): should clear cur_mid after compilation.
-
- * io.c (next_argv): need to check type for ARGV.shift.
-
- * eval.c (blk_copy_prev): need to preserve outer scope as well as
- outer frames.
-
- * parse.y (rb_compile_string): return can appear within eval().
-
-Tue Mar 23 10:15:07 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
-
- * configure.in: AC_C_CONST check added.
-
-Tue Mar 23 02:07:35 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * time.c (time_plus): preserve gmt-mode for result.
-
-Mon Mar 22 01:32:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_eval): adjust line numbers before expression
- interpolation within strings.
-
- * eval.c (rb_eval): defined? returns nil for false condition.
-
- * numeric.c (num_nonzero_p): returns nil for false condition.
-
-Sat Mar 20 13:07:43 1999 Keiju Ishitsuka <keiju@rational.com>
-
- * lib/weakref.rb: avoid leak for two weakrefs for one object.
-
-Fri Mar 19 11:26:45 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
-
- * eval.c (ruby_run): needed to eval END{} on exit.
-
- * eval.c (rb_exit): ditto.
-
-Fri Mar 19 02:17:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * signal.c (Init_signal): handles terminating signals HUP, TERM,
- QUIT, PIPE, etc.
-
-Thu Mar 18 15:47:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * bignum.c (rb_big_and): bug in sign calculation.
-
- * bignum.c (rb_big_or): ditto.
+Tue Dec 9 23:32:23 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * io.c (rb_f_select): forgot to use to_io to retrieve IO, after
- calling select(2).
+ * ext/tk/lib/tk.rb, ext/tk/lib/tkcanvas.rb, ext/tk/lib/tkdialog.rb,
+ ext/tk/lib/tkentry.rb, ext/tk/lib/tkscrollbox.rb, ext/tk/lib/tktext.rb,
+ ext/tk/sample/tkalignbox.rb, ext/tk/sample/tkcombobox.rb,
+ ext/tk/sample/tkmultilistbox.rb, ext/tk/sample/tkoptdb.rb, ext/tk/sample/tktextframe.rb,
+ ext/tk/sample/demos-en/dialog1.rb, ext/tk/sample/demos-en/dialog2.rb,
+ ext/tk/sample/demos-jp/dialog1.rb, ext/tk/sample/demos-jp/dialog2.rb:
+ overrided instance methods, which are private methods on the super
+ class, are changed to 'private'
-Tue Mar 16 19:54:31 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Tue Dec 9 19:53:02 2003 akira yamada <akira@ruby-lang.org>
- * ext/extmk.rb.in: static linking cause infinite make loop.
+ * lib/uri/generic.rb (URI::Generic#route_from0): make case insensitive
+ for host-part.
-Tue Mar 16 18:50:04 1999 Yoshida Masato <yoshidam@yoshidam.net>
+ * test/uri/test_generic.rb (test_route): added tests for the above
+ change.
- * ext/socket/socket.c (tcp_s_gethostbyname): typo, not NUM2INT(),
- but INT2NUM().
+Tue Dec 9 14:10:48 2003 Tanaka Akira <akr@m17n.org>
- * ext/socket/socket.c (mkhostent): ditto.
+ * io.c (rb_io_check_readable): don't call io_seek if EOF flag is set,
+ to avoid clearing EOF flag.
+ (rb_io_check_writable): ditto.
-Tue Mar 16 12:31:44 1999 Ryo HAYASAKA <hayasaka@cheer.u-aizu.ac.jp>
+Tue Dec 9 02:53:55 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * file.c (utime_internal): suppress warning by const.
+ * ext/tk/sample/tkalignbox.rb: new sample script
- * time.c (time_gmtime): ditto.
+Tue Dec 9 00:45:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Tue Mar 16 10:23:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/assertions.rb: renamed #assert_raises to #assert_raise
+ and made the former call the latter. [ruby-core:01890]
- * time.c (time_clone): Time object can be cloned.
+ * test/testunit/test_assertions.rb: ditto.
-Tue Mar 16 03:13:10 1999 Koji Arai <JCA02266@nifty.ne.jp>
+Tue Dec 9 00:07:35 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * ruby.c (load_file): argv[argc] should be NULL.
+ * lib/soap/rpc/standaloneServer.rb: add 'shutdown' and 'status'
+ methods as delegates to WEBrick.
-Mon Mar 15 22:12:08 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * test/soap/calc/{test_calc.rb,test_calc2.rb},
+ test/soap/helloworld/test_helloworld.rb,
+ test/wsdl/datetime/test_datetime.rb, test/wsdl/raa/test_raa.rb:
+ follow the change.
- * sprintf.c (rb_f_sprintf): typo in arg_num check at exit.
+Mon Dec 8 22:48:03 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Mar 15 16:42:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/autorunner.rb: remove dependency to a particular
+ runner. [ruby-core:01901], [ruby-list:38869]
- * array.c (rb_ary_dup): dup2 should copy class too.
+ * lib/test/unit/ui/testrunnerutilities.rb: moved output level
+ constants from Console.
-Mon Mar 15 15:12:53 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+ * lib/test/unit/ui/console/testrunner.rb: ditto.
- * lib/mkmf.rb: install program relative path check.
+ * lib/test/unit/ui/{fox,gtk,gtk2,tk}/testrunner.rb (initialize):
+ accept output_level.
-Mon Mar 15 14:05:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Dec 8 15:03:30 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (rb_reg_s_new): 2nd argument is now option.
- Regexp::EXTENDED can be specified.
+ * ext/syck/syck.c (syck_io_str_read): get rid of buffer overflow.
-Fri Mar 12 10:47:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Dec 8 13:02:11 2003 Minero Aoki <aamine@loveruby.net>
- * string.c (rb_str_index): str.index("") should always match at
- offset point.
+ * lib/uri/common.rb: new method URI.regexp. [ruby-dev:22121]
- * string.c (rb_str_upto): can specify end point exclusion.
+ * test/uri/test_common.rb: add test for URI.regexp.
- * string.c (rb_str_index): negative offset.
+Mon Dec 8 12:44:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_match): begline should not match at the point
- between a newline and end-of-string. endline neither.
+ * pack.c: define swap16 and swap32 only if they are not
+ defined. OpenBSD defines these macros. [ruby-dev:22181]
- * regex.c (re_compile_pattern): context_indep_anchors .
+Sun Dec 7 20:54:17 2003 Tanaka Akira <akr@m17n.org>
- * parse.y (parse_regx): need not to push backslashes before
- escaped characters.
+ * ext/iconv/iconv.c (map_charset): make case sensitive.
+ ext/iconv/charset_alias.rb (charset_alias): don't ignore
+ config.charset's information. sort aliases.
- * eval.c (rb_thread_join): re-raises exception within target.
+Sat Dec 6 22:58:03 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Mar 12 01:09:36 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * ext/openssl/ossl_ssl.c (ossl_start_ssl): new function to wrap
+ SSL_connect and SSL_accept; if SSL_connect (or SSL_accept) returned
+ but not finished the handshake process, we should retry it.
- * ext/readline/readline.c (readline_s_vi_editing_mode): wrong
- number of arguments.
+ * ext/openssl/ossl_ssl.c (ossl_ssl_connect): call ossl_start_ssl.
-Fri Mar 12 02:12:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_ssl.c (ossl_ssl_accept): ditto.
- * pack.c (PACK_ITEM_ADJUST): "a".unpack("C3") => [97, nil, nil]
+ * ext/openssl/ossl_ssl.c (ossl_ssl_read): allow signal traps.
-Thu Mar 11 18:23:50 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+Sat Dec 6 21:45:10 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/socket/socket.c (Init_socket): UDPsocket was omitted.
+ * io.c (flush_before_seek): flush before seek on any platform.
-Thu Mar 11 16:43:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * pack.c (PACK_LENGTH_ADJUST): push fixed number of items per
- template to result array.
-
- * pack.c (pack_unpack): I/N/C etc. push nil in the array for "".
-
-Tue Mar 9 00:19:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * hash.c (ruby_unsetenv): use ruby_setenv(name, 0).
-
- * hash.c (env_delete): ditto.
-
- * string.c (rb_str_upto): do not check `beg<end' to generate
- strings for the pattern like "a".upto("#a").
-
- * range.c (range_each): treat strings as special case.
-
- * range.c (range_each): no longer use upto for generic cases.
-
-Sun Mar 7 14:21:32 1999 IKARASHI Akira <ikarashi@itlb.te.noda.sut.ac.jp>
-
- * string.c (rb_str_index): wrong end point calculation.
-
-Sat Mar 6 02:19:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * re.c (match_index): MatchingData#index(n) added.
-
- * array.c (rb_ary_subseq): ary[n..-1] returns an sub-array unless
- n is too small negative index.
-
- * re.c (rb_reg_match_method): Regexp#match(str) added.
-
- * array.c (rb_ary_indexes): understands ranges as indexes.
-
- * re.c (match_size): MatchingData#size added.
-
-Fri Mar 5 01:04:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * array.c (rb_ary_fill): modified for range.
-
- * array.c (rb_ary_aset): a[n..m] revisited.
-
-Thu Mar 4 14:23:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (rb_str_subseq): a[n..m] revisited.
-
- * parse.y (method_call): allow Const::method{}.
-
- * array.c (rb_ary_replace_method): should replace original array.
-
-Thu Mar 4 02:30:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * configure.in: remove --disable-thread, thread feature is no
- longer optional.
-
-Thu Mar 4 00:32:17 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
-
- * parse.y (read_escape): wrong arguments for scan_oct,scan_hex.
-
-Wed Mar 3 11:51:53 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * ext/socket/socket.c (Init_socket): rename class names as
- TCPsocket -> TCPSocket etc.
-
-Tue Mar 2 19:46:42 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
-
- * configure.in (LDSHARED): use gcc -Wl,-G for solaris with gcc.
-
-Tue Mar 2 17:04:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * parse.y (yylex): backslashes do not concatenate comment lines
- anymore.
-
-Mon Mar 1 14:05:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * eval.c (rb_call0): adjust argv for optional arguments. super
- without arguments emit superclass method with the value from
- optional arguments. enabled as experiment.
-
-Sun Feb 28 14:04:07 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
-
- * parse.y (nextc): backslash at the eof cause infinite loop
-
-Sun Feb 28 11:01:26 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
-
- * time.c (make_time_t): month range check added.
-
-Sat Feb 27 02:36:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * re.c (Init_Regexp): add escape as alias of quote.
-
- * re.c (rb_reg_s_quote): char-code can be specified now.
-
-Fri Feb 26 18:45:36 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
-
- * eval.c (error_print): bug for error message with newlines.
-
-Fri Feb 26 12:00:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * time.c (make_time_t): future check modified to allow 1969-12-31
- at certain timezone.
-
- * time.c (time_arg): year >= 1000 should be past.
-
- * version.c (Init_version): constant RELEASE_DATE added.
-
-Fri Feb 26 01:08:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * string.c (rb_str_substr): returns nil for out-of-range access.
+ * configure.in: ditto.
- * array.c (rb_ary_subseq): returns nil for out-of-range access.
+Sat Dec 6 17:23:00 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * array.c (rb_ary_store): negative index message has changed.
+ * lib/soap/soap.rb(SOAP::Env.getenv): allow upcase environment variable
+ as well as downcase one.
- * string.c (rb_str_aset): reallocation needed.
+ * lib/soap/netHttpClient.rb(SOAP::NetHttpClient#proxy=): check URI.
- * string.c (rb_str_aset): allow char append to the string.
+Fri Dec 5 23:22:30 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Feb 25 23:30:17 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * lib/test/unit/assertions.rb (Test::Unit::Assertions::assert_raises,
+ Test::Unit::Assertions::assert_nothing_raised): use the last
+ argument as message unless class object.
- * time.c (time_load): tm_year should be packed in 17 bits, not 18.
+ * test/testunit/test_assertions.rb (test_assert_raises): test for
+ multiple exception list. [ruby-core:01891]
-Thu Feb 25 12:50:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/testunit/test_assertions.rb (test_assert_nothing_raised): test
+ for non-exception classes.
- * missing/dup2.c: replaced by public domain version.
+Fri Dec 5 22:23:04 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * time.c (make_time_t): add `future check' in loops.
+ * lib/soap/netHttpClient.rb: proxy support did not work. fixed.
- * object.c (rb_num2dbl): forbid implicit conversion from nil, or
- strings. thus `Time.now + str' should raise error.
+ * lib/soap/property.rb: add class methods for loading property from
+ stream/file/propertyfile. propertyfile is a file which is located at
+ somedir in $:.
- * object.c (rb_Float): convert nil into 0.0.
+ * lib/soap/soap.rb, lib/soap/wsdlDriver.rb, lib/soap/rpc/driver.rb,
+ lib/wsdl/importer.rb: load property from propertyfile 'soap/property'
+ e.g. /usr/local/lib/ruby/site_ruby/1.8/soap/property.
- * object.c (rb_Integer): conversion method improved.
+ * test/soap/test_property.rb, test/soap/test_streamhandler.rb: new file.
-Thu Feb 25 03:27:50 1999 Shugo Maeda <shugo@netlab.co.jp>
+Fri Dec 5 17:26:23 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_call): should handle T_ICLASS properly.
+ * eval.c (rb_exec_end_proc): maintain tmp_end_procs.
+ [ruby-dev:22154]
-Thu Feb 25 00:04:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Dec 5 13:36:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * error.c (Init_Exception): global function Exception() removed.
+ * eval.c (rb_exec_end_proc): should not clear end_procs and
+ ephemeral_end_procs before execution. [ruby-dev:22144]
- * variable.c (rb_class2name): returns "nil"/"true"/"false" for them.
+ * eval.c (rb_obj_extend): call Module#extended hook after
+ extended_object. [ruby-list:38866]
- * time.c (time_dump): time marshaling format compressed size from
- 11 bytes to 8 bytes. thanx to tadf@kt.rim.or.jp.
+ * object.c (Init_Object): Module#extended defined.
- * eval.c (rb_obj_call_init): should specify arguments explicitly.
+Fri Dec 5 13:17:30 2003 Tanaka Akira <akr@m17n.org>
-Wed Feb 24 15:43:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/test_pipe.rb: use IO.pipe instead of IO.popen.
- * parse.y (yylex): comment concatenation requires preceding space
- before backslash at the end of line.
+Fri Dec 5 11:54:45 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (rb_f_pipe): global pipe is obsolete now.
+ * ext/stringio/stringio.c (strio_read): follow IO#read.
- * object.c (Init_Object): remove true.to_i, false.to_i.
+ * test/ruby/ut_eof.rb, test/ruby/test_file.rb, test/ruby/test_pipe.rb,
+ test/stringio/test_stringio.rb: add EOF test.
-Tue Feb 23 14:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Dec 5 02:49:35 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (yylex): warn if identifier! immediately followed by `='.
+ * lib/test/unit/assertions.rb (Test::Unit::Assertions::assert_raises):
+ allow multiple exception list. [ruby-core:01884]
-Tue Feb 23 12:32:41 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * lib/test/unit/assertions.rb (Test::Unit::Assertions::assert_nothing_raised):
+ check whether arguments are subclass of Exception.
- * eval.c (rb_load): tilde expansion moved to find_file.
+Thu Dec 4 23:54:00 2003 Rick Ohnemus <rick.ohnemus@systemware.com>
- * eval.c (find_file): tilde expansion added.
+ * dln.c (aix_loaderror): should not use member named 'errno' which
+ might be a macro (e.g. on AIX).
-Tue Feb 23 10:50:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Dec 4 23:32:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (require_method): require can handle multiple fnames.
+ * io.c (read_all): do not depend on lseek position.
+ [ruby-dev:22026]
- * hash.c (rb_hash_foreach_iter): hash key may be nil.
+Thu Dec 4 22:37:26 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Feb 22 17:44:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_eval): preserve $! value when retry happens in the
+ rescue clause. [ruby-talk:86697]
- * regex.c (re_match): should not pop failure point on success for
- non-greedy matches.
+Thu Dec 4 21:50:07 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (Init_IO): remove global_functions getc, readchar, ungetc,
- seek, tell, rewind.
+ * lib/drb/drb.rb (DRb::DRbMessage::send_request, send_reply):
+ should rescue errors and re-raise DRbConnError on write too.
+ [ruby-dev:22132]
-Sat Feb 20 22:54:26 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Dec 4 16:41:17 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * numeric.c (rb_num2long): no implicit conversion from boolean.
+ * parse.y (exc_list): allow expanding list. [ruby-dev:22134]
-Sat Feb 20 09:58:42 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+Thu Dec 4 14:09:24 2003 Minero Aoki <aamine@loveruby.net>
- * numeric.c (flo_to_s): portable Infinity and NaN support.
+ * test/fileutils/test_fileutils.rb (test_cp): test if the error is
+ kind of SystemCallError. It is needless details that which errno
+ is set on each systems.
-Sat Feb 20 07:13:31 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+Thu Dec 4 13:24:13 2003 Shugo Maeda <shugo@ruby-lang.org>
- * io.c (rb_file_sysopen): forgot to initialize a local variable.
+ * lib/monitor.rb: use Object#__send__ instead of Object#send.
-Fri Feb 19 23:05:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Dec 4 13:17:45 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * string.c (rb_str_subseq): range check changed.
+ * lib/soap/streamHandler.rb: support latest released version of
+ http-access2.
- * marshal.c: increment MARSHAL_MINOR for Time format change.
+Thu Dec 4 13:04:44 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * time.c (time_old_load): support old marshal format.
+ * lib/soap/soap.rb: add SOAP::Env module for environment repository
+ such as HTTP_PROXY.
- * time.c (time_load): changed for new format Y/M/D/h/m/s/usec.
+ * lib/soap/property.rb: property implementation.
- * time.c (time_dump): marshal dump format has changed.
+ * lib/soap/streamHandler.rb, lib/soap/wsdlDriver.rb,
+ lib/soap/rpc/driver.rb: use soap/property.rb.
-Fri Feb 19 00:25:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/wsdl/importer.rb, lib/soap/wsdlDriver.rb, lib/soap/rpc/driver.rb:
+ use SOAP::Env.
- * time.c (time_arg): should reject "sep\0" and such.
+ * lib/soap/netHttpClient.rb: add basic_auth, ssl_config, and cookie
+ management interface, but ignored for now.
- * time.c (time_plus): Time#+ should not receive Time object
- operand.
+ * lib/xsd/charset.rb: add XSD::Charset.encoding= interface to set
+ wiredump charset explicitly. it was fixed to 'utf-8' when iconv or
+ uconv module was found.
- * string.c (rb_str_substr): negative length raises exception now.
+Thu Dec 4 10:43:58 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * array.c (beg_len): if end == -1, it points end of the array.
+ * ext/dl/sym.c (rb_dlsym_guardcall): __declspec(noinline) is VC7
+ feature.
- * array.c (rb_ary_subseq): negative length raises exception now.
+Thu Dec 4 10:27:12 2003 Minero Aoki <aamine@loveruby.net>
-Thu Feb 18 20:57:04 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * lib/net/http.rb: update hyperlink to the Japanese document.
- * time.c (rb_strftime): strftime() may return 0 on success too.
+Thu Dec 4 09:12:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * time.c (time_strftime): `\0' within format string should not be
- omitted in the result.
+ * ext/openssl/ossl_asn1.c (asn1time_to_time): should check that
+ the underlying value of ASN1_TIME isn't NULL. [ruby-core:01881]
- * time.c (rb_strftime): zero length format.
+Thu Dec 4 08:29:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * time.c (time_to_a): yday start with 1 now.
+ * lib/webrick/server.rb (GenericServer#start): should rescue
+ Exception to avoid unexpected aborting. [ruby-core:01853]
- * time.c (time_zone): support for long timezone name.
+ * lib/webrick/server.rb (GenericServer#start_thread): should check
+ that peeraddr isn't nil before printing.
- * time.c (time_yday): yday start with 1 now.
+ * lib/webrick/httpresponse.rb (HTTPResponse#start_thread): should
+ rescue Exception to avoid unexpected aborting of thread.
- * time.c (time_minus): minus calculation was wrong.
+Thu Dec 4 03:48:59 2003 Tanaka Akira <akr@m17n.org>
- * time.c (time_minus): sec, usec should be at least `long', maybe
- they should be `time_t'.
+ * lib/pathname.rb (Pathname#link, Pathname#symlink): obsoleted.
+ (Pathname#make_link, Pathname#make_symlink): new method.
- * time.c (time_plus): addition with float was wrong.
+Thu Dec 4 01:45:24 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * time.c (time_to_s): support for long timezone name.
+ * io.c (argf_read): should not terminate on empty string; wait
+ until real EOF. [ruby-dev:21969]
- * time.c (time_gm_or_local): too far future check moved.
+ * io.c (argf_read): should adjust length to read, when length is
+ specified and read spans command line argument files.
- * time.c (time_arg): treat 2 digit year as 69-99 => 1969-1999,
- 00-68 => 2000-2068
+Wed Dec 3 19:38:36 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Thu Feb 18 03:56:47 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/drb/drb.rb: correct fcntl parameter. [ruby-dev:22120]
- * missing/fnmatch.c: moved to missing directory.
+Wed Dec 3 13:49:07 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Wed Feb 17 16:22:26 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tk.rb: 'format'==>'Kernel.format' (avoid override trouble)
- * struct.c (rb_struct_alloc): actual initialization now be done in
- `initialize'.
+ * ext/tk/lib/tkafter.rb: ditto.
-Wed Feb 17 09:47:15 1999 okabe katsuyuki <hgc02147@nifty.ne.jp>
+ * ext/tk/lib/tkcanvas.rb: ditto.
- * regex.c (re_search): use mbclen() instead of ismbchar().
+ * ext/tk/lib/tkdialog.rb: ditto.
- * re.c (rb_reg_s_quote): should handle mbchars properly.
+ * ext/tk/lib/tktext.rb: ditto.
-Wed Feb 17 01:25:26 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Dec 3 13:28:13 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (yylex): stop comment concatenation by backslash follows
- after >= 0x80 char. may cause problem with Latin chars.
+ * Makefile.in (lex.c): try gperf first, and copy from the source
+ directory if failed. [ruby-dev:22123]
- * eval.c (error_print): exception in rb_obj_as_string() caused
- SEGV. protect it by PUSH_TAG/POP_TAG.
+ * ext/extmk.rb (MTIMES): let makefiles depend to mkmf.rb.
- * error.c (exc_exception): `Exception#exception' should return self.
+ * lib/mkmf.rb (configuration): DLDFLAGS was duplicated.
-Wed Feb 17 01:12:22 1999 Hirotaka Ichikawa <hirotaka.ichikawa@tosmec.toshiba.co.jp>
+Tue Dec 2 23:18:12 2003 Minero Aoki <aamine@loveruby.net>
- * configure.in: BeOS patch.
+ * lib/net/http.rb: wrote the warning about HTTP_PROXY environment
+ variable.
-Tue Feb 16 14:25:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Dec 2 21:31:42 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_compile_pattern): should reallocate mbc space for
- character class unless current_mbctype is ASCII.
+ * bin/testrb: new test runner. [ruby-core:01845]
-Mon Feb 15 15:48:30 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner.run,
+ Test::Unit::AutoRunner#process_args): take test list to run and
+ options.
- * configure.in: specify `-Wl,-E' only for GNU ld.
+ * lib/test/unit/autorunner.rb (Test::Unit::AutoRunner::RUNNERS,
+ Test::Unit::AutoRunner#run): should not exit inside a library,
+ just return the result instead.
-Mon Feb 15 11:43:22 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+ * lib/test/unit.rb: ditto.
- * array.c (rb_inspecting_p): should return Qfalse.
+ * test/runner.rb: exit with the test result.
-Sun Feb 14 22:36:40 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+Tue Dec 2 20:18:48 2003 Eric Sunshine <sunshine@sunshineco.com>
- * sprintf.c (rb_f_sprintf): `%G' was omitted.
+ * configure.in (AC_PROG_YACC): AC_DEFINE(OLD_YACC) if Yacc is found
+ instead of Bison or byacc.
-Sun Feb 14 12:47:48 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * parse.y: If OLD_YACC is defined, ensure that YYMAXDEPTH is at least
+ 10000 (Bison's default) since some old versions of Yacc define it as
+ low as 150 by default, which is too low for Ruby to parse some files,
+ such as date/format.rb. Among other issues, the parse problem causes
+ "make test" to fail.
- * numeric.c (Init_Numeric): allow divide by zero on FreeBSD.
+Tue Dec 2 20:03:20 2003 Minero Aoki <aamine@loveruby.net>
- * numeric.c (Init_Numeric): FloatDomainError added.
+ * test/fileutils/test_fileutils.rb: check if Pathnames are usable
+ for arguments.
- * configure.in (AC_REPLACE_FUNCS): add checks for functions
- isinf, isnan, and finite.
+Tue Dec 2 04:22:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Sat Feb 13 01:24:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/assertions.rb: fixed #assert_no_match message.
- * eval.c (rb_thread_create_0): should protect th->thread.
+ * test/testunit/test_assertions.rb: ditto.
-Fri Feb 12 16:16:47 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+Tue Dec 2 00:43:00 2003 why the lucky stiff <why@ruby-lang.org>
- * string.c (rb_str_inspect): wrong mbc position.
+ * ext/syck/syck.c: string buffering bug. decrementing by full
+ max_size now. [ruby-core:01834]
-Fri Feb 12 16:21:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Dec 1 21:33:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_thread_fd_close):
+ * numeric.c (num_sadded): prohibit singleton method definition for
+ Numerics. fill yet another gap between Fixnum and Bignum.
- * io.c (rb_io_fptr_close): tell scheduler that fd is closed.
+Mon Dec 1 17:33:47 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_io_reopen): ditto.
+ * pack.c (htov16): converts endian using swap16. htov32(), hton16,
+ hton32 as well. [ruby-talk:85377]
- * io.c (READ_CHECK): check if closed after thread context switch.
+ * pack.c (swap16): swap 2 bytes no matter how big short is on the
+ platform. swap32() is also prepared.
- * ext/socket/socket.c (bsock_close_read): do not check
- the return value from shutdown(2).
+ * numeric.c (rb_num2int): returns long to preserve information.
+ rb_fix2int(), rb_num2uint(), rb_fix2uint() as well.
+ [ruby-talk:85377]
- * ext/socket/socket.c (bsock_close_write): ditto.
+ * numeric.c (rb_num2uint): should not check for value range if the
+ source value is negative.
- * ext/socket/socket.c (sock_new): need to dup(fd) for close_read
- and close_write.
+Mon Dec 1 17:14:34 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (here_document): handle newlines within #{}.
+ * sample/optparse/opttest.rb: added.
- * regex.h: should replace symbols for ruby.
+Mon Dec 1 16:10:52 2003 Dave Thomas <dave@pragprog.com>
-Fri Feb 12 00:46:28 1999 Shugo Maeda <shugo@netlab.co.jp>
+ * lib/rdoc/rdoc.rb: (etc) initial merge into main tree.
- * marshal.c (r_object): should update the method name in message.
+Mon Dec 1 14:17:49 2003 Minero Aoki <aamine@loveruby.net>
- * marshal.c (w_object): limit should be converted into Fixnum.
+ * lib/fileutils.rb (fu_each_src_dest0): call #to_str to allow
+ Pathname for arguments. [ruby-core:01795]
-Wed Feb 10 15:20:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/fileutils/test_fileutils.rb: does much strict test on
+ "same" files detecting.
- * regex.c (re_match): empty pattern should not cause infinite
- pattern match loop.
+Mon Dec 1 09:28:14 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * regex.c (re_compile_pattern): RE_OPTIMIZE_ANCHOR for /.*/, not
- for /(.|\n)/.
+ * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub
+ (XCFLAGS): re-export $(XCFLAGS).
- * numeric.c (fix_pow): `fixnum**nil' should raise TypeError.
+ * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub
+ (ARCH_FLAG): export $(ARCH_FLAG) (perhaps empty value).
- * bignum.c (rb_big_pow): need to normalize results.
+Mon Dec 1 01:03:27 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Wed Feb 10 01:42:41 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/mkmf.rb (TRY_LINK, link_command): added support for DLDFLAGS
+ and ARCH_FLAG. [ruby-dev:22085]
- * numeric.c (fix_pow): `(5**1).type' should be Integer.
+Sun Nov 30 20:18:07 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Tue Feb 9 01:22:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * configure.in: keep ARCH_FLAG separate. export ARCH_FLAG.
+ [ruby-core:01819]
- * parse.y (yylex): do not ignore newlines in mbchars.
+ * Makefile.in: add ARCH_FLAG to CFLAGS.
- * io.c (rb_file_s_open): mode can be specified by flags like
- open(2), e.g. File::open(path, File::CREAT|File::WRONLY).
+ * Makefile.in: add @CPPFLAGS@ to CPPFLAGS.
- * io.c (rb_f_open): bit-wise mode flags for pipes
+ * lib/mkmf.rb (link_command, cc_command): use ARCH_FLAG.
- * io.c (Init_IO): bit flags for open.
+ * lib/mkmf.rb (configuration): add ARCH_FLAG to DLDFLAGS.
-Sat Feb 6 22:56:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * Makefile.in: add ARCH_FLAG to DLDFLAGS.
- * string.c (rb_str_sub_bang): should not overwrite match data by
- regexp match within the block.
+ * configure.in: should put getcwd in AC_CHECK_FUNCS, not
+ AC_REPLACE_FUNCS. [ruby-core:01826]
- * string.c (rb_str_gsub_bang): ditto.
+Sun Nov 30 18:22:48 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Sat Feb 6 03:06:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * configure.in: do not override CCDLDFLAGS, LDFLAGS, XLDFLAGS,
+ DLDFLAGS and LDSHARED.
- * re.c (match_getter): accessing $~ without matching caused SEGV.
+ * configure.in: XCFLAGS for compiling ruby itself. ARCH_FLAG is
+ reflected in CFLAGS.
-Fri Feb 5 22:11:08 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/mkmf.rb: ditto. do not import XCFLAGS from config.status.
- * parse.y (yylex): binary literal support, like 0b01001.
+Sun Nov 30 17:37:36 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * parse.y (yylex): octal numbers can contain `_'s.
+ * ext/tk/lib/tk.rb: bug fix [ruby-talk:86746]
- * parse.y (yylex): warns if non-octal number follows immediately
- after octal literal.
+Sun Nov 30 13:02:00 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * parse.y (yylex): now need at least one digit after prefix such
- as 0x, or 0b.
+ * lib/soap/encodingstyle/soapHandler.rb: refactoring - Simplifying
+ Conditional Expressions.
- * bignum.c (rb_str2inum): recognize binary numbers like 0b0101.
+ * lib/wsdl/soap/definitions.rb: refactoring - Move Method.
-Fri Feb 5 03:26:56 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+ * test/xsd/{test_noencoding.rb,noencoding.xml}: new files. test for
+ encoding unspecified XML file parsing.
- * ruby.c (proc_options): -e without program prints error.
+ * test/wsdl/{test_fault.rb,map,datetime}: new files. test of
+ SOAPFault, dateTime and Apache's Map.
-Fri Feb 5 00:01:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 30 09:35:14 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (terms): needed to clear heredoc_end.
+ * string.c (rb_str_update): get rid of SEGV at just allocated String.
+ [ruby-core:01812]
- * numeric.c (flo_div): allow float division by zero.
+Fri Nov 28 23:19:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Feb 4 11:56:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * gc.c (gc_mark): explicitly check mark recursion levels, instead
+ of unreliable stack length.
- * missing/strtod.c: for compatibility.
+Fri Nov 28 22:49:56 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * configure.in (strtod): add strtod compatible check.
+ * lib/rinda/rinda.rb: fix TupleSpaceProxy#read, read_all.
- * numeric.c (rb_num2long): missing/vsnprintf.c does not support
- floating points.
+Fri Nov 28 21:44:40 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * numeric.c (flo_to_s): ditto.
+ * test/fileutils/test_fileutils.rb (test_ln_s): should be a file, not
+ a directory for FreeBSD.
-Wed Feb 3 23:02:12 1999 Yoshida Masato <yoshidam@yoshidam.net>
+Fri Nov 28 19:37:56 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_compile_pattern): use ismbchar() to get next char.
+ * hash.c (env_has_value, env_index): must match exactly.
- * regex.c (re_search): wrong mbchar shift.
+ * test/ruby/test_env.rb (test_has_value, test_index): condition for
+ aboves.
- * re.c (rb_reg_search): needed to reset $KCODE after match.
+Fri Nov 28 17:59:20 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * regex.c (re_compile_fastmap): mbchars should match with \w.
+ * test/ruby/test_env.rb: add tests for ENV.
-Wed Feb 3 22:35:12 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+Fri Nov 28 17:47:46 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * parse.y (yylex): too big float raise warning, not error.
+ * lib/drb/drb.rb (DRbMessage#load): rescue Errno::* and raise
+ DRbConnError.
-Tue Feb 2 23:41:42 1999 Yoshida Masato <yoshidam@yoshidam.net>
+Fri Nov 28 15:41:15 2003 Tanaka Akira <akr@m17n.org>
- * regex.c (re_match): wrong boundary.
+ * lib/pathname.rb (Pathname#realpath): obsolete the force_absolute
+ argument.
- * regex.c (IS_A_LETTER): re_mbctab[c] may not be 1 for mbc.
+Fri Nov 28 14:41:52 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * regex.c (re_search): mbchar support for shifting ranges.
+ * lib/soap/streamHandler.rb: drop unused http parameters.
- * regex.c (MBC2WC): wrong conversion.
+ * lib/soap/encodingstyle/soapHandler.rb, lib/soap/mapping/factory.rb,
+ lib/soap/mapping/mapping.rb, lib/soap/mapping/registry.rb,
+ lib/wsdl/soap/complexType.rb: ApacheSOAP's map support was broken
+ under WSDL dynanic client environment. fixed.
-Wed Feb 3 15:03:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/wsdl/raa/*: add tests.
- * parse.y (parse_regx): need to escape parens if terminators are
- not any kind of parenthesis.
+ * lib/xsd/datatypes.rb: dateTime precision bug fix (at least, I hope.)
+ bug of soap4r. XSDDateTimeImple.to_time passed a Float to
+ Time.local/Time.gm as an usec, and NUM2LONG(rb_num2long for Float)
+ causes rounding error.
- * parse.y (parse_qstring): ditto.
+ * test/soap/test_basetype.rb, test/xsd/test_xsd.rb: add tests.
- * parse.y (parse_string): ditto.
+Fri Nov 28 04:15:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Feb 2 17:11:26 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * eval.c (method_arity): used wrong Proc object. [ruby-talk:86504]
- * string.c (rb_str_gsub_bang): too small realloc condition.
+Fri Nov 28 00:47:29 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Feb 1 10:01:17 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * eval.c (rb_f_exit), process.c (rb_f_exit_bang): treat true as
+ success, false as failure. [ruby-dev:22067]
- * parse.y (yylex): range check for the float literal.
+ * eval.c (rb_f_abort, rb_thread_switch), process.c (rb_f_system): use
+ ANSI macro instead of hard coded value.
-Sat Jan 30 18:34:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_f_exit), process.c (rb_f_exit_bang): use VALUEs not but
+ TYPEs.
- * ruby.c (usage): -h option to show brief command description.
+Thu Nov 27 22:05:48 2003 Akinori MUSHA <knu@iDaemons.org>
-Sat Jan 30 08:45:16 1999 IKARASHI Akira <ikarashi@itlb.te.noda.sut.ac.jp>
+ * eval.c, gc.c: FreeBSD/ia64 currently does not have a way for a
+ process to get the base address for the RSE backing store, so
+ hardcode it for the moment.
+ [submitted by: Marcel Moolenaar <marcel@FreeBSD.org>]
- * lib/cgi-lib.rb: cookie support added.
+Thu Nov 27 17:36:42 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Jan 30 13:38:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tkafter.rb: bug fix on TkTimer#cancel_on_exception=(mode).
+ TkTimer#wait recieves the exception of the callback.
+ The exception is kept on @return_value.
- * regex.c (re_compile_pattern): mbchars should match with \w
- within character class. Was matching with \W.
+Thu Nov 27 16:58:48 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * regex.c (re_match): \w should match with multi byte characters,
- not its first byte.
+ * win32/win32.c (rb_w32_stat): remove _fullpath() for NUL: device.
-Sat Jan 30 10:06:41 1999 Yoshida Masato <yoshidam@yoshidam.net>
+Wed Nov 26 15:38:47 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * re.c (rb_reg_s_new): UTF-8 flag handle (/u, /U).
+ * test/fileutils/test_fileutils.rb (test_ln_s): should take the
+ existing symbolic link for OpenBSD.
- * re.c (rb_kcode): $KCODE handle for UTF-8.
+Wed Nov 26 04:48:42 2003 why the lucky stiff <why@ruby-lang.org>
-Sat Jan 30 01:51:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/token.c: removed YYTOKTMP references which
+ were causing buffer overflows on large block scalars,
+ comments, quoted scalars and plain scalars.
- * array.c (rb_ary_delete_if): RTEST() missing.
+ * ext/syck/rubyext.c: dynamic changing of buffer size.
- * hash.c (delete_if_i): ditto.
+ * ext/syck/syck.h: default buffer size of 4k.
- * enum.c (Init_Enumerable): select (=find_all), detect (=find)
- added as aliases.
+Wed Nov 26 00:55:30 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Jan 29 21:32:19 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * lib/webrick/httpresponse.rb: add HTTPResponse#keep_alive=.
- * hash.c (rb_f_setenv): SEGV caused by small typo.
+ * lib/webrick/httpserver.rb (HTTPServer#run): should pass the
+ request's keep_alive flag to the response.
-Fri Jan 29 00:15:58 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Nov 25 21:41:35 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * lib/parsedate.rb (parsedate): support date format like
- 23-Feb-93, which is required by HTTP/1.1.
+ * defines.h (ENV_IGNORECASE): should define when DOSISH without
+ human68k. [ruby-dev:22047]
- * variable.c (find_class_path): avoid calling rb_iv_set().
+ * hash.c (env_has_value, env_index): don't ignore case of value.
+ [ruby-dev:22048]
- * eval.c (backtrace): do not need to modify $SAFE internally.
+Tue Nov 25 21:39:37 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * variable.c (classname): inline __classid__ access.
+ * file.c (path_check_1): honor sticky bits always.
+ [ruby-talk:86273]
- * eval.c (THREAD_ALLOC): needed to initialize wrapper.
+Tue Nov 25 20:02:14 2003 Minero Aoki <aamine@loveruby.net>
- * lib/ftools.rb (makedirs): allows slash at the end of the path.
+ * test/fileutils/test_fileutils.rb: do test in more deep
+ directory.
- * numeric.c (rb_fix_induced_from): ensure result to be Fixnum.
+ * test/fileutils/test_nowrite.rb: ditto.
-Thu Jan 28 17:31:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Nov 25 19:04:23 2003 Tanaka Akira <akr@m17n.org>
- * numeric.c (flo_to_s): float format changed to "%16.10g".
+ * lib/open-uri.rb (URI::Generic#find_proxy): ENV case sensitivity test
+ refined.
-Thu Jan 28 02:13:11 1999 Yoshinori Toki <toki@freedom.ne.jp>
+Tue Nov 25 18:13:30 2003 Minero Aoki <aamine@loveruby.net>
- * array.c (rb_ary_store): expand allocated buffer by 3/2.
+ * test/fileutils/test_fileutils.rb: chdir Dir.tmpdir before each
+ test. [ruby-dev:22045]
-Wed Jan 27 17:50:02 1999 Kazuhiro HIWADA <hiwada@kuee.kyoto-u.ac.jp>
+ * test/fileutils/test_nowrite.rb: ditto.
- * bignum.c (dbl2big): raised error if double is too big to cast
- into long. check added.
+Tue Nov 25 17:52:11 2003 Tanaka Akira <akr@m17n.org>
-Wed Jan 27 03:16:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/open-uri.rb (URI::Generic#find_proxy): use http_proxy under CGI
+ if the environment variable is case sensitive.
- * variable.c (rb_mod_const_at): can't list constants of the
- untainted objects in safe mode.
+Tue Nov 25 16:41:33 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * class.c (method_list): can't list methods of untainted objects
- in safe mode.
+ * test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb:
+ removed. this test requires extra libraries in soap4r/1.5.*.
-Tue Jan 26 02:40:41 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+Tue Nov 25 16:24:42 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * prec.c: Precision support for numbers.
+ * lib/soap/**/*.rb, lib/wsdl/**/*.rb, lib/xsd/**/*.rb: changed license;
+ GPL2 -> Ruby's.
-Thu Jan 21 19:08:14 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/rpc/driver.rb, lib/soap/wsdlDriver.rb,
+ lib/soap/streamHandler.rb: add interface to streamhandler.
- * eval.c (rb_f_raise): calls `exception' method, not `new'.
+ * lib/soap/marshal.rb: raise error if parse fails.
- * error.c (exc_exception): renamed from `new'.
+ * lib/soap/netHttpClient.rb: add https support. Patched by
+ Oliver M. Bolzer.
-Wed Jan 20 03:39:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/netHttpClient.rb: dump HTTP response message body by itself.
- * parse.y (yycompile): rb_in_compile renamed to ruby_in_compile.
+ * lib/soap/rpc/driver.rb, lib/soap/rpc/proxy.rb,
+ lib/soap/wsdlDriver.rb: add driver#mandatorycharset interface to foce
+ using charset for parsing response from buggy server.
- * ruby.c (load_file): define DATA if __END__ appeared in script.
+ * lib/soap/encodingstyle/soapHandler.rb: support Apache Axis's half
+ typed multi-ref array.
-Tue Jan 19 14:57:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/mapping/factory.rb, lib/soap/mapping/registry.rb: map
+ SOAPStruct which has multi-accessors which name are the same, to an
+ array.
- * parse.y (here_document): need to protect lex_lastline.
+ * lib/soap/rpc/element.rb: fixed illegal parameter order.
- * parse.y (yylex): disable %//, %'', %``.
+ * lib/soap/rpc/element.rb: element name of response message could have
+ the name other than 'return'.
-Tue Jan 19 05:01:16 1999 Koji Arai <JCA02266@nifty.ne.jp>
+ * lib/wsdl/operation.rb, lib/wsdl/operationBinding.rb,
+ lib/wsdl/soap/classDefCreator.rb, lib/wsdl/soap/methodDefCreator.rb,
+ lib/wsdl/soap/methodDefCreatorSupport.rb: WSDL/1.1 allows plural
+ fault definition in a operation. [ruby-talk:84948]
- * array.c (beg_len): round range value too much.
+ * test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb: add
+ test for above fix.
-Mon Jan 18 13:02:27 1999 Kuroda Jun <jkuro@dwe.co.jp>
+ * lib/wsdl/soap/complexType.rb: support WSDL array definition with
+ maxOccures="unbound".
- * hash.c (env_keys): strchr() may return NULL.
+ * lib/xsd/charset.rb: use cp932 under emx. Patched by
+ Siena. / SHINAGAWA, Norihide in [ruby-dev:21972]
-Mon Jan 18 17:51:47 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/xsd/xmlparser/parser.rb: set @charset nil by default. Nil means
+ 'follow encoding declaration in XML'.
- * instruby.rb (wdir): install libruby.a in archdir.
+ * sample/soap/digraph.rb, sample/wsdl/amazon/wsdlDriver.rb,
+ sample/wsdl/googleSearch/sampleClient.rb,
+ sample/wsdl/googleSearch/wsdlDriver.rb,
+ test/wsdl/test_emptycomplextype.rb,
+ test/wsdl/marshal/test_wsdlmarshal.rb,
+ test/xsd/test_xmlschemaparser.rb: use File.open(...) { |f| f.read }
+ instead of File.open(...).read. [ruby-dev:21964]
- * lib/ftools.rb (install): removes file before installing.
+ * test/wsdl/emptycomplextype.wsdl, test/wsdl/test_emptycomplextype.rb:
+ simplify the test case.
-Mon Jan 18 16:55:31 1999 MAEDA shugo <shugo@aianet.ne.jp>
+ * test/wsdl/axisArray/*: add tests for axis's array encoding.
- * eval.c (rb_callcc): experimental continuation support.
+Tue Nov 25 16:15:29 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Sun Jan 17 19:45:37 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ruby.h: don't treat Cygwin as Windows.
- * pack.c (pack_pack): nil packing caused SEGV.
+Tue Nov 25 15:18:28 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Jan 16 13:18:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * configure.in: change default value of --enable-pthread (default: no)
- * string.c (rb_str_concat): character (fixnum) can be append to
- strings
+Tue Nov 25 07:31:16 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (rb_ary_unshift): unshift returns array.
+ * parse.y (primary): allow newlines just before right argument
+ parenthesis. (ruby-bugs:PR#1221)
-Sat Jan 16 01:39:19 1999 Yoshida Masato <yoshidam@tau.bekkoame.ne.jp>
+Mon Nov 24 23:32:06 2003 Tanaka Akira <akr@m17n.org>
- * string.c (rb_str_split_method): UTF-8 support.
+ * lib/open-uri.rb (OpenURI.open_loop, URI::HTTP#proxy_open): use
+ catch/throw for redirection instead of exception.
+ (OpenURI.open_loop, OpenURI.redirectable?): restrict redirection.
- * regex.c: UTF-8 support.
+Mon Nov 24 19:59:48 2003 Tanaka Akira <akr@m17n.org>
-Thu Jan 14 00:42:55 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/open-uri.rb (URI::Generic#find_proxy): use CGI_HTTP_PROXY
+ instead of HTTP_PROXY in the CGI environment.
- * string.c (rb_str_gsub_bang): forget to add offset for null match.
+Mon Nov 24 19:32:55 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (rb_thread_local_aset): can't modify in tainted mode.
+ * ext/etc/extconf.rb: check for pw_passwd in struct passwd and
+ gr_passwd in struct group for DJGPP.
- * hash.c (env_each_key): avoid generating temporary array.
+ * ext/etc/etc.c: ditto.
-Wed Jan 13 23:58:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/Setup.dj: support for curses, etc, zlib.
- * hash.c (rb_f_setenv): name and value can be tainted.
+Mon Nov 24 17:00:00 2003 Tanaka Akira <akr@m17n.org>
-Wed Jan 6 02:42:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/open-uri.rb: validate option names.
+ :content_length_proc and :progress_proc option implemented.
- * bignum.c (Init_Bignum): forgot to define Bignum#===.
+Mon Nov 24 14:53:10 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * gc.c (gc_sweep): if add_heap() is called during GC, objects on
- allocated heap page(s) are not marked, should not be recycled.
+ * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub
+ (XCFLAGS): output empty value instead of `-DRUBY_EXPORT'.
- * gc.c (gc_sweep): should refer latest freelist.
+Sat Nov 22 23:09:45 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * gc.c (id2ref): modified to support performance patch.
+ * configure.in: set enable_pthread to no on MinGW.
- * object.c (rb_obj_id): performance patch (no bignum for id).
+Sat Nov 22 22:56:20 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Jan 5 01:56:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * configure.in: add --enable-pthread option (default: yes)
- * config.guess: merge up-to-date from autoconf 2.12.
+Sat Nov 22 22:48:46 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * array.c (rb_ary_join): avoid calling rb_protect_inspect() till
- it is really needed.
+ * ext/tk/lib/tk.rb: add Tk.grab_release and fix bug of TkComposite
- * object.c (rb_obj_inspect): show detailed information for the
- instance variables (infinite loop can avoid now).
+ * ext/tk/lib/tkafter.rb: bug fix of TkAfter#start
- * struct.c (rb_struct_inspect): avoid infinite loop.
+ * ext/tk/sample/tkcombobox.rb: new sample script
-Sun Jan 3 01:37:58 1999 Takao KAWAMURA <kawamura@ike.tottori-u.ac.jp>
+ * ext/tcltklib/tcltklib.c: add native thread check
- * misc/ruby-mode.el (ruby-end-of-defun): moved too much.
+Sat Nov 22 18:49:47 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * misc/ruby-mode.el (ruby-mode-variables): set paragraph-separator
- for the mode.
+ * ext/curses/curses.c (window_nodelay): nodelay() of NetBSD's
+ libcruses returns no value, just like keypad().
- * misc/ruby-mode.el: proper font-lock for `def' and `nil' etc.
+Sat Nov 22 17:36:36 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Sat Jan 2 17:09:06 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub
+ (HAVE_GETCWD): output to config.h.
- * eval.c (rb_jump_tag): new api to invoke JUMP_TAG. tag values
- can obtained from rb_eval_string_protect()/rb_load_protect().
+ * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub
+ (XCFLAGS): output to config.status.
- * eval.c (rb_rescue): now catches all exceptions but SystemExit.
+Sat Nov 22 13:10:10 2003 Minero Aoki <aamine@loveruby.net>
- * eval.c (rb_eval_string_protect): eval string with protection.
+ * lib/fileutils.rb (have_st_ino?): djgpp has valid st_ino.
- * eval.c (rb_load_protect): load file with protection.
+Sat Nov 22 11:28:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_io_puts): avoid infinite loop for cyclic arrays.
+ * gc.c (Init_stack): stack region is far smaller than usual if
+ pthread is used.
- * eval.c (rb_thread_local_aref): thread local hash tables.
+Sat Nov 22 07:30:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * object.c (rb_equal): check exact equal before calling `=='.
+ * lib/test/unit/util/backtracefilter.rb: fixed a bug that occurred
+ when an exception had no backtrace.
-Thu Dec 31 22:28:53 1998 MAEDA shugo <shugo@aianet.ne.jp>
+ * test/testunit/util/test_backtracefilter.rb: ditto.
- * eval.c (rb_f_require): feature names should be provided with
- DLEXT extension.
+Fri Nov 21 16:44:18 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * marshal.c (Init_marshal): need to provide `marshal.so'.
+ * ext/tk/lib/tkentry.rb: fix the encoding trouble of percent
+ substitutions on validatecommand option of TkEntry widget
-Wed Dec 30 02:29:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tk.rb: fix bug on {pack|grid}_propagate() method
- * variable.c (classname): do not call rb_ivar_set().
+Fri Nov 21 16:12:11 2003 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (ruby_run): finalizers were called too early.
+ * ruby.1: Fix markups and grammar.
-Fri Dec 25 12:19:30 1998 Fukuda Masaki <fukuda@wni.co.jp>
+Fri Nov 21 14:49:42 2003 Minero Aoki <aamine@loveruby.net>
- * gc.c (rb_gc_mark): should not return on FL_EXIVAR.
+ * ruby.1: wrote about ruby related environment variables.
-Fri Dec 25 11:56:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Nov 21 12:28:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * gc.c (gc_mark): proper scanning for temporary region.
+ * marshal.c (w_extended): singleton methods should not be checked
+ when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
- * eval.c (TMP_ALLOC): protection for C_ALLOCA was broken.
+Fri Nov 21 01:40:00 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Thu Dec 24 18:26:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * configure.in: check <pthread.h>
- * development version 1.3 released.
+ * ruby.h: include pthread.h if existence.
+ define is_ruby_native() macro when not HAVE_NATIVETHREAD
-Thu Dec 24 00:17:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c: undef is_ruby_native() function when not HAVE_NATIVETHREAD
- * eval.c (rb_load): top self should be set properly.
+Fri Nov 21 00:43:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * variable.c (classname): check __classpath__ if it is defined.
+ * lib/test/unit/assertions.rb: use #__send__ instead of #send.
- * variable.c (classname): invalid warning at -v with static linked
- ruby interpreter.
+ * lib/test/unit/testcase.rb: ditto.
- * eval.c (is_defined): modified for expr::Const support.
+Thu Nov 20 19:19:22 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (rb_eval): invoke method expr::Const if expr is not class
- nor module.
+ * configure.in: don't find the Cygwin's pthread library on MinGW.
- * parse.y (primary): enable expr::identifier as method
- invocation.
+Thu Nov 20 19:15:50 2003 Minero Aoki <aamine@loveruby.net>
-Wed Dec 23 03:04:36 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/fileutils.rb (have_st_ino?): emx (OS/2 with EMX) does not
+ have st_ino (always 0). [ruby-dev:21972]
- * regex.c (re_match): avoid too many loop pops for (?:..).
+ * lib/fileutils.rb (rename_cannot_overwrite_file?): emx does not
+ allow overwriting files by rename(2).
-Tue Dec 22 18:01:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/fileutils/test_fileutils.rb: windows? ->
+ have_drive_letter?, have_file_perm?
- * experimental version 1.1d1 released.
+Thu Nov 20 17:50:58 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Mon Dec 21 01:33:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/sample/tkballoonhelp.rb: new sample script
- * eval.c (TMP_PROTECT): add volatile to ensure GC protection.
+ * ext/tk/sample/tkmultilistbox.rb: ditto
- * string.c (rb_str_gsub_bang): calculate buffer size properly.
+ * ext/tk/sample/tktextframe.rb: ditto
- * parse.y (lex_get_str): needed to return Qnil at EOS.
+Thu Nov 20 13:37:34 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * eval.c (find_file): check policy modified, raise exception
- immediately for tainted load_path.
+ * ruby.h: define is_ruby_native_thread() for no native thread
+ environment
- * hash.c (rb_f_setenv): do not depend on setenv() nor putenv().
+ * eval.c: ditto
-Thu Dec 17 06:29:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Nov 20 12:42:47 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tk/tkutil.c (tk_s_new): use rb_obj_instance_eval(), instead
- of rb_yield_0().
+ * configure.in: always check existence of the pthread library
- * eval.c (rb_f_require): forgot to call find_file in some cases.
+ * ruby.h: define macros for ruby's native thread check
- * eval.c (rb_f_require): `require "feature.so"' to load dynamic
- libraries. old `require "feature.o"' is still OK.
+ * eval.c: add ruby's native thread check
- * eval.c (rb_eval): yield without value dumped core.
+ * gc.c: ditto
-Wed Dec 16 16:28:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Nov 19 14:45:18 2003 Minero Aoki <aamine@loveruby.net>
- * experimental version 1.1d0 (pre1.2) released.
+ * lib/net/http.rb (to_ary): print more friendly warning message.
-Wed Dec 16 10:43:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Nov 19 14:32:08 2003 Minero Aoki <aamine@loveruby.net>
- * regex.c (re_search): bound check before calling re_match().
+ * lib/fileutils.rb (fu_same?): add djgpp and wince.
-Tue Dec 15 13:59:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/fileutils.rb (cannot_overwrite_file?): add wince.
- * error.c (exc_to_s): returns class name for unset mesg.
+Wed Nov 19 11:04:47 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * error.c (exc_initialize): do not initialize @mesg by "".
+ * lib/fileutils.rb (cannot_overwrite_file?, have_st_ino?): bccwin32
+ is same as mswin32.
- * parse.y (nextc): __END__ should handle CR+LF newlines.
+Wed Nov 19 07:54:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Wed Dec 9 13:37:12 1998 MAEDA shugo <shugo@aianet.ne.jp>
+ * lib/test/unit.rb: do not run tests if $! is set.
- * pack.c (encodes): use buffering for B-encoding.
+ * lib/test/unit/assertionfailederror.rb: extend StandardError instead
+ Exception (irb catches the former but not the latter).
- * pack.c (pack_pack): Q-encoding by 'M'.
+Tue Nov 18 23:31:36 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Tue Dec 8 14:10:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * missing/memmove.c (memmove): take void *, not char *.
- * variable.c (generic_ivar_get): any object can have instance
- variables now. great improvement.
+ * missing.h (memmove): ditto.
- * variable.c (rb_name_class): do not set __classpath__ by default,
- use __classid__ instead.
+ * missing.h (strchr, strrchr): return char *, not int.
-Mon Dec 7 22:08:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Nov 18 22:20:10 2003 Minero Aoki <aamine@loveruby.net>
- * ruby.h (struct RFile): IO objects can have instance variables now.
+ * lib/fileutils.rb (fu_same?): temporal fix for windows.
- * parse.y (primary): allows `def obj::foo; .. end'.
+Tue Nov 18 19:05:04 2003 Minero Aoki <aamine@loveruby.net>
-Mon Dec 7 18:24:50 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * lib/fileutils.rb (fu_same?): check by inode instead of path
+ name, to detect two hard links pointing to the same content.
- * ruby.c (set_arg0): $0 support for HP-UX.
+ * test/fileutils.rb: did not create correctly looped symlinks.
-Mon Dec 7 01:30:28 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Tue Nov 18 18:23:05 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * dln.c (dln_strerror): better error messages on win32.
+ * ext/stringio/stringio.c (strio_read): behave as IO at empty string.
+ [ruby-dev:21939], [ruby-dev:21941]
-Sat Dec 5 23:27:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/stringio/stringio.c (strio_getc, strio_getline): set EOF flag.
- * parse.y (here_document): indentable here-doc delimiter by
- `<<-'. Proposed by Clemens <c.hintze@gmx.net>. Thanks.
+ * ext/stringio/stringio.c (strio_rewind, strio_seek, strio_ungetc):
+ clear EOF flag.
-Thu Dec 3 16:50:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/stringio/test_stringio.rb: imported from [ruby-dev:21941].
- * ext/extmk.rb.in (realclean): trouble on install.
+Tue Nov 18 14:06:35 2003 Minero Aoki <aamine@loveruby.net>
-Sun Nov 29 22:25:39 1998 Takaaki Tateishi <ttate@jaist.ac.jp>
+ * lib/fileutils.rb (fu_each_src_dest): raise if src==dest.
+ [ruby-talk:85344] [ruby-core:01699]
- * process.c (f_exec): check number of argument.
+ * lib/fileutils.rb: use Object#is_a? instead of Class#=== to allow
+ e.g. remote objects for receivers.
-Thu Nov 26 17:27:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/fileutils.rb: FileTest -> File.
- * version 1.1c9 released.
+ * lib/fileutils.rb: put parentheses for arguments of File.xxxx?
-Wed Nov 25 13:07:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/fileutils/test_fileutils.rb (test_cp): test "cp a a".
- * string.c (rb_str_dup): do not copy additional data (STR_NO_ORIG).
+ * test/fileutils/test_fileutils.rb (test_mv): test "mv a a".
- * parse.y (yycompile): reduce known memory leak (hard to remove).
+ * test/fileutils/test_fileutils.rb (test_ln): test "ln a a".
-Wed Nov 25 03:41:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/fileutils/test_fileutils.rb (test_ln_s): test "ln_s a a".
- * st.c (st_init_table_with_size): round size up to prime number.
+ * test/fileutils/test_fileutils.rb (test_install): test "install a a".
-Sat Nov 21 23:27:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/fileutils/fileasserts.rb: new method assert_symlink.
- * hash.c (rb_hash_aset): reduce copying key strings.
+ * test/fileutils/fileasserts.rb: assert_is_directory -> assert_directory.
- * gc.c (looks_pointerp): declare as inline function if possible.
+Mon Nov 17 19:38:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * st.c (PTR_NOT_EQUAL): compare hash values first before calling
- comparing function.
+ * file.c (getcwdofdrv): avoid using getcwd() directly, use
+ my_getcwd() instead.
- * st.c (ADD_DIRECT): save hash value in entries to reduce hash
- calculation.
+ * merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
+ <sunshine@sunshineco.com>. [ruby-core:01596]
- * string.c (rb_str_gsub_bang): avoid rb_scan_args() to speed-up.
+Mon Nov 17 10:50:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_sub_bang): ditto.
+ * lib/optparse.rb (OptionParser::Completion::complete): allow least
+ common completion for three or more candidates.
-Sat Nov 21 18:44:06 1998 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+Mon Nov 17 09:41:38 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * time.c (time_s_now): had memory leak.
+ * lib/test/unit/ui/tk/testrunner.rb,
+ lib/test/unit/ui/gtk/testrunner.rb:
+ run GUI main loop in sub thread.
- * ext/md5/md5init.c (md5_new): had memory leak.
+ * lib/test/unit/ui/gtk2/testrunner.rb: imported from rough.
- * ext/md5/md5init.c (md5_clone): ditto.
+ * lib/test/unit/autorunner.rb (keyword_display): sort keywords.
-Fri Nov 20 23:23:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 16 18:10:57 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/delegate.rb: do not propagate hash and eql?.
+ * eval.c (rb_eval): iterator should return value from next inside
+ begin/rescue/end. (ruby-bugs:PR#1218)
-Thu Nov 19 01:40:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 16 13:26:07 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * sample/ruby-mode.el (ruby-expr-beg): failed to find reserved
- word boundary.
+ * marshal.c (w_object): LINK check earlier than anything else,
+ i.e. do not dump TYPE_IVAR for already dumped objects.
+ (ruby-bugs:PR#1220)
- * eval.c (rb_eval): avoid calling `concat' method. calls
- rb_ary_concat() directly for efficiency.
+ * eval.c (rb_eval): call "inherited" only when a new class is
+ generated; not on reopening.
- * eval.c (rb_eval): actual rest arguments extended arrays too much.
+ * eval.c (eval): prepend error position in evaluating string to
+ "mesg" attribute string only when it's available and is a
+ string.
-Wed Nov 18 14:30:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 16 12:16:10 2003 Minero Aoki <aamine@loveruby.net>
- * class.c (rb_define_global_function): global functions now be
- module function of the Kernel.
+ * lib/net/protocol.rb: logging response body. [experimental]
+ [ruby-list:38800]
-Wed Nov 18 10:48:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 16 10:49:38 2003 Gavin Sinclair <gsinclair@soyabean.com.au>
- * io.c (read_all): SEGV on large files.
+ * lib/thread.rb (Thread.exclusive): wrap method definition in
+ class Thread to enable rdoc to process.
-Tue Nov 17 18:11:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 16 09:45:23 2003 Minero Aoki <aamine@loveruby.net>
- * version 1.1c8 released.
+ * lib/net/http.rb (set_debug_output): warn if method is called
+ after #start. [ruby-dev:38798]
-Tue Nov 17 16:58:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 16 04:41:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (arg): assignment to attribute name start with capital
- should be allowed.
+ * eval.c (eval): do not re-raise exception to avoid unnecessary
+ exception copying, instead modify exception and internal
+ information to adjust eval().
- * eval.c (thread_alloc): needed to mark terminated threads too.
+ * eval.c (backtrace): can return the current frame information
+ only if lev < -1.
-Tue Nov 17 12:33:48 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+Sat Nov 15 22:16:42 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ext/extmk.rb.in (create_makefile): Set `libdir' to `@libdir@',
- Set `pkglibdir' to `$libdir/$(RUBY_INSTALL_NAME)'.
+ * /ext/openssl/ossl_x509ext.c (ossl_x509extfactory_create_ext):
+ refine error message.
-Tue Nov 17 10:30:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Nov 15 10:05:40 2003 Tanaka Akira <akr@m17n.org>
- * sprintf.c (f_sprintf): %l%%c -> %%l%c
+ * lib/open-uri.rb (OpenURI.open_loop, OpenURI::HTTP#proxy_open):
+ refactored to support options.
+ (Buffer): maintain size by this class.
-Tue Nov 17 01:08:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Nov 15 07:40:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (ret_args): distinguish `a' and `*a' for the arguments
- of yield and return.
+ * eval.c (rb_method_node): new API to retrieve method body.
- * eval.c (rb_eval): flip3 should work like sed.
+Fri Nov 14 13:21:30 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * eval.c (rb_eval): flip{2,3} now have independent state for each
- scope to work fine with thread.
+ * ext/tcltklib/tcltklib.c: fix (en-bugged at 2003/11/07)
-Mon Nov 16 23:26:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tkdialog.rb: TkDialog.new accepts a parent widget
+ argument [ruby-talk:85066]
- * parse.y (primary): exec else clause if no exception raised.
+Thu Nov 13 20:53:35 2003 Tanaka Akira <akr@m17n.org>
-Sun Nov 15 15:44:07 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * lib/open-uri.rb (Kernel[#.]open): hard coded URI schemes removed.
+ [ruby-ext:02251]
- * ext/extmk.rb.in (install): bug in target.
+Thu Nov 13 19:17:00 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Sat Nov 14 11:02:05 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+ * lib/test/unit/ui/tk/testrunner.rb: use grid and panedwindow
+ (if available)
- * Makefile.in (install): Give the argument `$(DESTDIR)' to
- `instruby.rb'.
- * instruby.rb: Recognize ARG[0] as `destdir'.
- * instruby.rb: Give the argument `destdir' to `extmk.rb'.
- * ext/extmk.rb.in: Recognize ARG[1] as `$destdir'.
+Thu Nov 13 17:56:41 2003 Tanaka Akira <akr@m17n.org>
- * instruby.rb: Create the installation directories (bindir, libdir,
- archdir, pkglibdir, archdir, and mandir) under `destdir', and
- install all files under there.
- * ext/extmk.rb.in: Likewise.
-
-Sat Nov 14 10:56:55 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+ * lib/open-uri.rb (OpenURI.open_uri): use File::RDONLY.
+ reported by Take_tk <ggb03124@nifty.ne.jp>.
+ [ruby-ext:02245]
- * instruby.rb: Add the variable `pkglibdir'.
- * instruby.rb: Set the variable `libdir' to `$(libdir)', not
- `$(libdir)/$(ruby_install_name)'. `libruby.so' and `libruby.so.LIB'
- are installed at `libdir'.
- * instruby.rb: Set the variable `archdir' to `$(pkglibdir)/$(arch)'.
+Thu Nov 13 16:45:53 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Nov 13 19:43:29 1998 KIMURA Koichi <kbk@kt.rim.or.jp>
+ * ext/openssl/ossl_x509req.c (ossl_x509req_to_der): add function for
+ X509::Request#to_der.
- * missing/nt.c (SafeFree): wrong free offset.
+Thu Nov 13 11:31:14 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Nov 12 20:11:53 1998 Koji Arai <JCA02266@nifty.ne.jp>
+ * lib/optparse.rb (OptionParser::Completion#complete): prior shorter
+ name to containing longer name.
- * sample/ruby-mode.el: wrong highlight.
+Thu Nov 13 06:08:54 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * parse.y (parse_regx): newline in regexp was ignored.
+ * ext/tk/lib/tk.rb: stop freezing some classes
-Wed Nov 11 10:54:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/multi-tk.rb: ditto.
- * parse.y (here_document): <<'FOO' should not escape anything.
+Wed Nov 12 17:32:49 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (here_document): bare << here-doc available, even though
- it's deprecated.
+ * lib/test/unit/assertions.rb (assert_throws, assert_nothing_thrown):
+ uncaught throw in sub thread raises ThreadError.
- * file.c (rb_file_s_readlink): return value should be tainted.
+ * lib/test/unit/ui/tk/testrunner.rb (setup_ui): "expand" is not
+ necessary.
- * ext/etc/etc.c (setup_passwd): information (eg. GCOS name) should
- be tainted (modified at Perl Conference).
+Wed Nov 12 14:09:43 2003 Shugo Maeda <shugo@ruby-lang.org>
-Tue Nov 10 00:22:11 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * test/monitor/test_monitor.rb: fix the timing problem by Queue.
- * configure.in: elf support for FreeBSD 3.x
+Wed Nov 12 12:59:44 2003 Shugo Maeda <shugo@ruby-lang.org>
-Tue Nov 10 00:05:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/monitor/test_monitor.rb: added.
- * parse.y (yylex): here document available in eval.
+Wed Nov 12 10:14:28 2003 Shugo Maeda <shugo@ruby-lang.org>
-Mon Nov 9 17:55:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/monitor.rb: refactored. Thanks, Gennady Bystritsky.
- * version 1.1c7 released.
+Wed Nov 12 06:11:39 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Nov 6 19:25:27 1998 Takao KAWAMURA <kawamura@ike.tottori-u.ac.jp>
+ * ext/openssl/ossl.c (ossl_x509_sk2ary, ossl_x509crl_sk2ary):
+ add functions to convert STACK into Array.
- * sample/ruby-mode.el: font-lock patch.
+ * ext/openssl/ossl.h: add prototypes.
-Thu Nov 5 15:42:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_pkcs7.c (ossl_pkcs7_set_certificates,
+ ossl_pkcs7_get_certificates, ossl_pkcs7_get_crls,
+ ossl_pkcs7_set_crls): add functions for PKCS7#certificates=
+ PKCS7#certificates, PKCS7#crls= and PKCS7#crls.
- * sample/README, lib/README: simple description for each file.
+Wed Nov 12 00:47:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Wed Nov 4 18:14:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/ui/testrunnermediator.rb: should require 'test/unit'.
- * eval.c (assign): attribute assignment should be called as public.
+Tue Nov 11 23:54:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Tue Nov 3 23:36:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/ui/gtk/testrunner.rb: added a rescue clause to handle
+ the case when the requested font is not available.
- * string.c (rb_str_dump): dumps core for negative char value.
+Tue Nov 11 22:44:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_compile_pattern): out of boundary access for empty
- regexp.
+ * io.c (appendline): file may not end with newline. a bug if
+ READ_DATA_PENDING_PTR is defined. [ruby-talk:84925]
-Mon Nov 2 22:54:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Nov 11 10:42:41 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * string.c (rb_str_aset): `str[str]' replaces first match.
+ * ext/tk/lib/tk.rb: raise an exception when creating TkWindow
+ object, because TkWindow class is an abstract class.
-Mon Nov 2 18:24:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Nov 11 03:30:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (thread_create): was accessing modified status.
+ * lib/ext/openssl/ossl_conf.c (ossl_config_get_value): return nil
+ if the specified value doesn't exist.
-Sun Nov 1 01:18:52 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * lib/ext/openssl/ossl_conf.c (ossl_config_get_section): return
+ a empty hash if the specified section doesn't exist.
- * gc.c (xrealloc): size 0 needs round up to 1.
+Mon Nov 10 11:40:29 2003 Shugo Maeda <shugo@ruby-lang.org>
-Sat Oct 31 23:18:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/monitor.rb (wait): return true on signal/broadcastfalse and
+ false on timeout. Thanks Gennady Bystritsky.
- * string.c (rb_str_split_method): negative LIMIT means number of
- split fields are unlimited, as in perl.
+Mon Nov 10 00:07:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (rb_str_split_method): if LIMIT is unspecified,
- trailing null fields are stripped.
+ * parse.y (primary): primary_value may be 0 when syntax error.
+ [ruby-talk:84893]
-Sat Oct 31 04:16:14 1998 Inaba Hiroto <inaba@st.rim.or.jp>
+Sun Nov 9 02:05:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * string.c (str_aref): regexp index SEGVed.
+ * lib/test/unit/assertions.rb: un-deprecated #assert_not_nil to
+ maintain symmetry with #assert_nil. Also added better output for
+ #assert_kind_of.
-Fri Oct 30 14:33:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/testunit/tc_assertions.rb: ditto.
- * re.c (reg_match): returns nil for unmatch.
+Sat Nov 8 18:50:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * dir.c (dir_entries): new method.
+ * test/wsdl/raa/*: add new testcase for WSDL loading, parsing and
+ reading.
- * eval.c (block_pass): do not push block, substitute it.
+ * test/soap/marshal/*: backport from soap4r/1.5.1. all differences are
+ for ruby/1.6.
-Fri Oct 30 01:28:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/*: backport from soap4r/1.5.1. all differences are for
+ ruby/1.6.
- * range.c (range_check): avoid <=> check for Fixnums.
+ * lib/wsdl/data.rb, lib/wsdl/xmlSchema/data.rb: move definition of
+ ArrayTypeAttrName from ::WSDL::XMLSchema::* to ::WSDL::*.
+ [ruby-talk:84813]
- * array.c (rb_ary_aset): accept negative index.
+ * lib/wsdl/soap/definitions.rb: element name typo in custom exception
+ struct definition which is needed for wsdlDriver; camelCase ->
+ underscore_name.
-Wed Oct 28 22:00:54 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Nov 8 13:49:50 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * regex.c (re_match): access out of boundary fixed.
+ * configure.in: improvement of pthread check
-Wed Oct 28 11:37:42 1998 TAMITO <tommy@valley.ne.jp>
+Sat Nov 8 13:28:46 2003 Takaaki Tateishi <ttate@ttsky.net>
+ * ext/dl/sym.c: Add DL.win32_last_error and DL.last_error.
+ Thanks, Kaoru Shirai.
- * io.c (f_select): fd number comparison bug.
+Sat Nov 8 06:19:38 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
-Tue Oct 27 23:07:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tcltklib/tcltklib.c: To fix 'pthread-enabled Tcl/Tk' problem,
+ TclTkIp#_eval calls Tcl_Eval() on the mainloop thread only
+ (queueing a handler to the EventQueue).
- * sample/ruby-mode.el (ruby-parse-region): forgot to support %w()
- style array literal.
+ * ext/tcltklib/README.1st: edit the description of '--with-pthread-ext'
- * eval.c (rb_eval): unused block raises warning.
+Fri Nov 7 23:23:04 2003 Tanaka Akira <akr@m17n.org>
-Mon Oct 26 09:37:53 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/pathname.rb (Pathname#+): if self or the argument is `.', return
+ another.
+ (Pathname#parent): if self is `.', return `..'.
+ (Pathname#children): if self is `.', don't prepend self for a
+ pathname in a result.
+ (Pathname#join): re-implemented using Pathname#+.
+ (Pathname#find): if self is `.', remove `./' prefix of yielding
+ pathname.
- * eval.c (dvar_asgn_push): dvar pushed too many times if
- variable-in-block first appear in loops.
+Fri Nov 7 10:23:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun Oct 25 22:59:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/socket.c (make_hostent): get rid of SEGV on aliases
+ lookup failure. (ruby-bugs:PR#1215)
- * regex.c (set_list_bits): was using wrong offset.
+Fri Nov 7 04:08:05 2003 UENO Katsuhiro <katsu@blue.sky.or.jp>
-Thu Oct 22 00:07:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/zlib/zlib.c (Init_zlib): define Zlib::GzipReader#each_line as
+ an alias of Zlib::GzipReader#each.
- * eval.c (rb_obj_method): method retrieved from tainted object
- should be tainted too.
+Fri Nov 7 01:03:16 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (method_call): safe_level should be restored during
- Method#call.
+ * eval.c (rb_load): save and restore rb_prohibit_interrupt.
+ [ruby-dev:21857]
-Wed Oct 21 14:21:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Nov 6 18:05:07 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (Init_IO): new constants IO::SEEK_{SET,CUR,END}.
+ * io.c (rb_io_inspect): show the path also at a closed file.
+ [ruby-dev:21851]
- * io.c (rb_f_ungetc): ungetc pushes a char back into STDIN.
+Thu Nov 6 11:42:07 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Oct 19 11:50:00 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+ * ext/stringio/stringio.c (strio_set_string, strio_reopen): check
+ tainted.
- * ext/extmk.rb: Load '@top_srcdir@/lib/find.rb', not
- '../lib/find.rb'.
- * ext/extmk.rb: Distinguish between `top_srcdir' and `topdir'.
- * Makefile.in (CFLAGS): Add `-I.'.
- * Makefile.in (lex.c): Give `@srcdir@/keywords' to gperf, not
- `keywords'.
- * instruby.rb: Use `CONFIG["bindir"]', instead of `prefix + "/bin"'.
- * instruby.rb: Use `CONFIG["libdir"]', instead of `prefix + "/lib"'.
- * instruby.rb Use `CONFIG["mandir"]', instead of `prefix + "/man"'.
- * instruby.rb (wdir): Add the variable to preserve the current
- working directory.
- * instruby.rb: Chdir to wdir before install `config.h' and
- `rbconfig.rb'.
+ * ext/stringio/stringio.c (strio_copy, strio_ungetc, strio_write,
+ strio_putc): add infection.
-Mon Oct 19 10:07:01 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+ * ext/stringio/stringio.c (strio_path): just nil. [ruby-dev:21846]
- * eval.c (rb_eval): reduce recursive calls to rb_eval().
+ * ruby.c (proc_options): reserve searched script path in the
+ source file name table. [ruby-list:38765]
-Fri Oct 16 15:31:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/optparse.rb (OptionParser::Completion#complete): default not to
+ ignore case on completion. [ruby-talk:84726]
- * time.c (time_new_internal): timeval must be positive.
+ * win32/win32.c (make_cmdvector): process backslashes even if a quote
+ is not enclosed.
-Thu Oct 15 13:54:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Nov 5 23:49:45 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * parse.y (arg): local variables can be accessed within right side
- expression in assignment, notably in blocks.
+ * sample/openssl/gen_csr.rb: there (at least) is a CA which does not
+ accept DN in UTF8STRING format. it's a sample.
-Wed Oct 14 00:18:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Nov 5 22:55:16 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * array.c (Init_Array): Array#=== is now for equal check, not
- inclusion check.
+ * configure.in, eval.c, signal.c: : add '--with-pthread-ext'
+ option to fix the pthread trouble on 'tcltklib'
- * parse.y (when_args): `when a, *b' style new syntax for array
- expansion in `case'.
+ * ext/tcltklib/README.1st: add the description of '--with-pthread-ext'
-Tue Oct 13 14:30:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tktext.rb : add TkText#text_copy, text_cut, text_paste
+ to support Tcl/Tk8.4's tk_textCopy, tk_textCut, tk_textPaste
- * object.c (rb_obj_untaint): taint marks can be unset.
+ * ext/tk/lib/tk.rb : add TkMenu#set_focus support Tcl/Tk's
+ tk_menuSetFocus
- * eval.c (rb_eval): taint propagation for embedded strings.
+Wed Nov 5 17:33:45 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Oct 12 13:27:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_load): allow interrupt during loaded program
+ evaluation. [ruby-dev:21834]
- * eval.c (rb_call0): check stack depth more frequently.
+ * hash.c (rb_hash_fetch): always warn if default argument and a
+ block are supplied at the same time. [ruby-dev:21842]
-Mon Oct 12 08:08:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * hash.c (env_fetch): ditto.
- * io.c (rb_p): can print even in secure mode.
+ * array.c (rb_ary_fetch): ditto.
-Sun Oct 11 22:50:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Nov 5 19:08:47 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * variable.c (rb_const_set): taint check for modification.
+ * lib/optparse.rb (OptionParser::Switch::PlacedArgument::parse):
+ do not remove next argument if empty value is placed.
- * variable.c (rb_ivar_set): taint check for modification.
+ * test/optparse: added.
- * string.c (rb_str_modify): taint check for modification.
+Wed Nov 5 17:05:18 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * hash.c (rb_hash_modify): taint check for modification.
+ * lib/test/unit/ui/gtk/testrunner.rb: typo.
- * array.c (rb_ary_modify): taint check for modification.
+Wed Nov 5 11:13:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * ruby.h (FL_TAINT): taint for all objects, not only strings.
+ * string.c: add #include "version.h". this file still depends on it.
-Fri Oct 9 17:01:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub,
+ wince/Makefile.sub: add version.h dependency to string.c.
- * io.c (read_all): read() returns "" at immediate EOF.
+Wed Nov 5 09:14:23 2003 Shugo Maeda <shugo@ruby-lang.org>
- * io.c (io_read): read(nil) read all until EOF.
+ * lib/monitor.rb: revert to the previous revision.
-Thu Oct 8 13:32:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Nov 5 08:39:51 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * time.c (time_dump): marshal can dump Time object now.
+ * lib/webrick/https.rb (HTTPRequest#parse): set @client_cert_chain.
- * marshal.c (Init_marshal): rename marshal methods `_dump_to' to
- `_dump', `_load_from' to `_load'.
+ * lib/webrick/https.rb (HTTPRequest#meta_vars): create
+ SSL_CLIENT_CERT_CHAIN_n from @client_cert_chain.
- * parse.y (rb_intern): "+=".intern generates proper symbol.
+ * ext/openssl/ossl_ssl.c (ossl_ssl_get_peer_cert_chain): return nil
+ if no cert-chain was given.
-Mon Oct 5 18:31:53 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Nov 4 23:44:48 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * version 1.1c6 released.
+ * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub:
+ remove needless version.h dependency.
-Fri Oct 2 14:22:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Nov 4 23:38:43 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * regex.c (re_search): `/\s*(--)$/ =~ "- --"' did not match,
- because of wrong optimize condition.
+ * class.c, hash.c, string.c: remove #include "version.h".
-Mon Oct 1 01:55:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * Makefile.in: remove needless version.h dependency.
- * parse.y (rb_intern): should not raise exceptions.
+Tue Nov 4 06:54:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (yylex): symbol like `:foo?=' should not be allowed.
+ * io.c (read_all): fptr->f may be NULL, if IO is closed in the
+ signal handler.
- * ext/extmk.rb.in: makes *.a for static link modules.
+ * io.c (io_read): ditto.
-Wed Sep 30 14:13:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (get_pat): remove 1.8.0 warning code.
- * eval.c (rb_thread_start): supports making a subclass of the
- Thread class.
+ * string.c (rb_str_match): extend warning until 1.8.2.
-Tue Sep 29 17:46:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (rb_str_match2): ditto.
- * eval.c (rb_thread_join): join is now an instance method.
+ * class.c (class_instance_method_list): remove 1.8.0 warnings.
+ method_list now recurs. [ruby-dev:21816]
-Fri Sep 25 12:01:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * class.c (rb_obj_singleton_methods): ditto.
- * parse.y (yylex): `@foo!' should be an error.
+ * array.c (rb_ary_select): remove select with block.
+ [ruby-dev:21824]
-Thu Sep 24 14:55:06 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * hash.c (rb_hash_select): ditto.
- * ext/etc/etc.c (Init_etc): wrong field definition.
+ * hash.c (env_select): ditto.
-Thu Sep 17 17:09:05 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * re.c (match_select): ditto.
- * io.c (io_reopen): was creating FILE* for wrong fd.
+ * struct.c (rb_struct_select): ditto.
-Tue Sep 15 05:28:11 1998 Koji Arai <JCA02266@nifty.ne.jp>
+Mon Nov 3 22:53:21 2003 Minero Aoki <aamine@loveruby.net>
- * regex.c (re_compile_pattern): forgot to fixup for the pattern
- like (?=(A)|(B)).
+ * lib/racc/parser.rb: synchronize with Racc 1.4.4.
-Tue Sep 15 01:06:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/racc/cparse/cparse.c: ditto.
- * io.c (rb_io_gets_internal): do not set $_ by default, only
- gets/readline set the variable.
+ * ext/racc/cparse/cparse.c (parse_main): should abort when
+ the length of LR state stack <=1, not ==0.
- * eval.c (rb_f_load): load toplevel class is set to anonymous
- module if safe_level >= 5, to encapsulate modification.
+Mon Nov 3 08:50:47 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_f_load): set frame properly.
+ * process.c (check_uid_switch): remove duplicated error messages.
- * string.c (rb_str_each_line): do not set $_.
+ * process.c (check_gid_switch): ditto.
-Mon Sep 14 14:42:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Nov 2 02:28:33 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * regex.c (re_match): beginning and end of the string, do not
- automatically match `\b'.
+ * lib/webrick/ssl.rb: new option :SSLExtraChainCert.
- * string.c (scan_once): consume at least on character.
+Sun Nov 2 01:02:04 2003 Akinori MUSHA <knu@iDaemons.org>
- * regex.c (re_search): wrong behavior for negative range.
+ * string.c (rb_str_hash): Update the HASH_PERL alternative hash
+ algorithm in sync with Perl 5.8.
-Sat Sep 12 21:21:26 1998 Koji Arai <JCA02266@nifty.ne.jp>
+ * st.c (strhash): Ditto.
- * regex.c (re_search): range value should be maintained.
+Sat Nov 1 18:21:09 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Thu Sep 10 10:55:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_ssl.c (ossl_ssl_peer_cert_chain): add new method
+ SSLSocket#peer_cert_chain.
- * parse.y (backref_error): yyerror does not understand formats.
+ * ext/openssl/ossl_x509req.c (GetX509ReqPtr): new function
+ which returns underlying X509_REQ.
-Tue Sep 8 18:05:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_x509ext.c (ossl_x509extfactory_set_issuer_cert,
+ ossl_x509extfactory_set_subject_cert, ossl_x509extfactory_set_crl,
+ ossl_x509extfactory_set_subject_req, ossl_x509extfactory_set_config):
+ use underlying C struct without duplication not to leak momory.
- * version 1.1c5 released.
+Sat Nov 1 01:49:03 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Tue Sep 8 10:03:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/mapping/factory.rb: mark marshalled basetype objects when
+ @allow_original_mapping is true. multi-referencing basetype node is
+ prohibited in SOAP/1.1 encoding but soap4r's original ruby object
+ mapping requires basetype to be marked to detect self referencing
+ loop. e.g. o = 1; o.instance_eval { @iv = o } soap4r's original
+ mapping is only used through soap/marshal API.
- * string.c (str_each_line): wrong line splitting with newline at
- top of the string.
+ * test/soap/marshal/test_marshal.rb: add tests for self referencing
+ immutable objects.
- * string.c: non bang methods return copied string.
+ * test/soap/calc/test_calc_cgi.rb: fix test name.
- * eval.c (f_END): needed to initialize frame->argc;
+Fri Oct 31 22:26:29 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
-Fri Sep 4 11:27:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * wince/string_wce.c (strrchr): should decrement pointer.
- * bignum.c (bigadd): proper sign combination.
+ * wince/Makefile.sub: correct a range of isdigit().
- * regex.c (re_search): wrong return value for \A.
+Fri Oct 31 12:55:24 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Thu Sep 3 14:08:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * configure.in, lib/mkmf.rb: add RPATHFLAG for NetBSD.
+ [ruby-dev:21791]
- * version 1.1c4 released.
+ * bcc32/Makefile.sub, win32/Makefile.sub, win32/Makefile.sub: ditto.
-Tue Sep 1 10:47:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Oct 31 01:38:14 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * regex.c (slow_search): do not compare llen and blen. llen may
- be longer than blen, if little contains 0xff.
+ * wince/Makefile.sub, win32/Makefile.sub (.y.c): allow white spaces
+ at the beginning of line to remove by sed. (ruby-bugs-ja:PR#580)
- * regex.c (mbctab_euc): set 0x8e as multibyte character.
+Fri Oct 31 01:02:24 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_inspect): mask character for octal output.
+ * compar.c (cmp_equal): protect exceptions from <=> comparison
+ again. returns nil if any exception or error happened during
+ comparison.
-Mon Aug 31 15:32:41 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (search_required): should update *featurep when DLEXT2 is
+ defined. (ruby-bugs-ja:PR#581)
- * regex.c (re_search): use calculated offset if exactn is the
- first opcode in the compiled regexp.
+Thu Oct 30 23:41:04 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * regex.c (bm_search): use Boyer-Moore search for simple search.
+ * lib/drb/drb.rb: add DRbArray
- * regex.c (must_instr): wrong length check if pattern includes
- byte escape by 0xff.
+ * lib/drb/invokemethod.rb: fix Hash#each problem. [ruby-dev:21773]
- * regex.c (re_compile_pattern): need not to check current_mbctype.
+ * lib/drb/unix.rb: add LoadError. [ruby-dev:21743]
-Sat Aug 29 16:31:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 30 23:19:11 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (rb_check_safe_str): avoid calling rb_id2name() in normal
- cases to speed-up.
+ * lib/soap/generator.rb: better XML pretty printing.
- * eval.c (thread_raise): do not save context of terminated thread.
+ * lib/soap/encodingstyle/soapHandler.rb: remove unnecessary namespace
+ assignment in the element which has "encodingStyle" attribute, and
+ add necessary namespace assignment for "arrayType" attribute.
- * regex.c (re_compile_pattern): mask \nnn over 256.
+ * test/soap/calc/test_calc_cgi.rb: take over $DEBUG to ruby process
+ through CGI.
-Sat Aug 29 02:09:46 1998 Koji Arai <JCA02266@nifty.ne.jp>
+Thu Oct 30 22:59:39 2003 why the lucky stiff <why@ruby-lang.org>
- * sprintf.c (f_sprintf): wrong buffer size check.
+ * ext/syck/yaml2byte.c: HASH const too long. Thanks, matz.
-Fri Aug 28 01:57:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 30 19:13:53 2003 Akinori MUSHA <knu@iDaemons.org>
- * regex.c (re_compile_pattern): accepts (?ix-ix) and (?ix-ix:...).
+ * ext/syck/MANIFEST: Add yamlbyte.h.
-Fri Aug 28 12:25:33 1998 Hiroshi Igarashi <igarashi@ueda.info.waseda.ac.jp>
+Thu Oct 30 14:25:31 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ruby.c (ruby_require_modules): load modules in appearing order.
+ * io.c (READ_DATA_BUFFERED): new macro to detect whether stdio
+ buffer filled.
-Fri Aug 28 01:57:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * io.c (rb_io_fptr_cleanup): move path deallocation to
+ rb_io_fptr_finalize (finalizer called by GC).
- * regex.c (re_compile_pattern): accepts (?ix-ix) and (?ix-ix:...).
+Thu Oct 30 13:23:39 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Aug 27 12:54:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * parse.y (logop): left may be NULL. [ruby-talk:84539]
- * version 1.1c3 released.
+ * eval.c (rb_eval): NODE_CASE nd_head may be NULL.
-Wed Aug 26 14:40:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 30 10:14:51 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (rb_eval): check whether ruby_class is properly set,
- before accessing it.
+ * lib/test/unit/autorunner.rb: make fox runner work.
- * eval.c (rb_obj_instance_eval): ruby_class should be Qnil for
- special objects like Fixnums.
+Thu Oct 30 09:32:26 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * ext/tkutil/tkutil.c (Init_tkutil): removes calls to
- rb_yield_0(). used instance_eval() instead in the tk.rb.
+ * process.c (rb_f_system): fixed lack of security check before
+ calling do_spawn() on win32. [ruby-talk:84555]
-Wed Aug 26 11:47:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 30 02:46:35 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_match): pop non-greedy stack elements on success.
+ * eval.c (proc_invoke): single array value to normal Proc#call
+ (i.e. not via lambda call), should be treated just like yield.
+ [ruby-dev:21726]
-Wed Aug 26 09:25:35 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Thu Oct 30 02:25:48 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ruby.h: add #define environ for cygwin32.
+ * ext/openssl/lib/openssl/buffering.rb (Buffering#initialize):
+ add new method to inherit @sync from @io.sync.
-Tue Aug 25 08:57:41 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/lib/net/protocols.rb (SSLIO#ssl_connect): no need to
+ set sync flag explicitly.
- * array.c (rb_ary_sort_bang): temporarily freeze sorting array.
+ * ext/openssl/ossl_ssl.c (ossl_sslctx_initialize): call super.
-Mon Aug 24 18:46:44 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/openssl/ossl_ssl.c (ossl_sslctx_setup): set extra chain
+ certificates in @extra_chain_cert.
- * dln.c (dln_find_1): path check was too strict.
+Wed Oct 29 22:02:04 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Mon Aug 24 15:28:11 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * test/drb/drbtest.rb: use rbconfig.rb to make the path of ruby
+ interpreter to exec, instead of test/ruby/envutil.rb,
- * parse.y (f_arglist): opt_nl added after f_args.
+Wed Oct 29 19:58:59 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Fri Aug 21 01:06:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tcltklib/tcltklib.c (CONST84): define CONST84 when it is not
+ defined and TCL_MAJOR_VERSION >= 8.
- * ext/socket/socket.c: grand renaming on socket.c.
+ * ext/tcltklib/tcltklib.c (VwaitVarProc, WaitVariableProc,
+ rb_threadVwaitProc): use CONST84 instead of CONST.
- * ext/socket/socket.c (inet_aton): supply inet_aton for those
- systems that do not have it.
+ * ext/tcltklib/tcltklib.c (ip_rbTkWaitCommand,
+ ip_rb_threadTkWaitCommand): use CONST84 always.
- * ext/socket/socket.c (setipaddr): use inet_aton instead of
- inet_addr.
+Wed Oct 29 17:27:05 2003 Tanaka Akira <akr@m17n.org>
- * ext/socket/socket.c (tcp_s_gethostbyname): new method: works
- like Socket.gethostbyname but returning array contains ip-addrs
- as octet decimal string format like "127.0.0.1".
+ * re.c (rb_reg_s_union, Init_Regexp): new method `Regexp.union'.
- * ext/socket/socket.c (mkhostent): return format changed to
- [host, aliases, type, ipaddr..] as documented.
+ * lib/pathname.rb (realpath): examine Dir.pwd because it may have
+ symlinks.
-Wed Aug 19 00:31:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 29 17:16:31 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (io_ctl): forgot to place TRAP_END at right position.
+ * eval.c (rb_longjmp): must not disturb original jump.
+ [ruby-dev:21733]
-Fri Aug 14 11:01:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 29 15:28:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (call_trace_func): save __FILE__, __LINE__ before
- executing trace_func, since trace function should not corrupt
- line number information.
+ * eval.c (Init_Proc): taint preallocated exception object
+ sysstack_error. [ruby-talk:84534]
-Thu Aug 13 15:09:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 29 11:27:39 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * array.c (ary_s_new): was marking unallocated region on GC.
+ * parse.y (ret_args): node may be NULL. [ruby-talk:84530]
-Tue Aug 11 11:57:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Oct 28 15:20:12 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * version 1.1c2 released.
+ * ext/tcltklib/tcltklib.c (VwaitVarProc, ip_rbVwaitObjCmd,
+ WaitVariableProc, WaitVisibilityProc, WaitWindowProc,
+ ip_rbTkWaitObjCmd, ip_rbTkWaitCommand, rb_threadVwaitProc,
+ rb_threadWaitVisibilityProc, rb_threadWaitWindowProc,
+ ip_rb_threadVwaitObjCmd, ip_rb_threadTkWaitObjCmd): prototype;
+ avoid VC++ warnings.
-Mon Aug 10 14:05:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Oct 27 19:19:55 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * process.c (f_system): removed fflush(stdin).
+ * eval.c (rb_longjmp): ignore reentering error while warning.
+ [ruby-dev:21730]
-Fri Aug 7 17:44:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Oct 27 00:23:50 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * error.c (err_snprintf): replace sprintf for fixed sized buffer,
- with snprintf to avoid buffer over-run. For systems which does
- dot provide snprintf, missing/snprintf.c added.
+ * ext/tcltklib/tcltklib.c (ip_ruby): bug fix on Win : hang-up when
+ calling 'exit' in the Tk callback procedure. [ruby-list:38656]
-Wed Aug 5 00:47:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Oct 25 09:18:04 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * re.c (rb_reg_search): recycle match object.
+ * eval.c (rb_method_missing): protect exception from within
+ "inspect". (ruby-bugs:PR#1204)
-Mon Aug 3 09:17:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Oct 24 23:26:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (rb_str_gsub_bang): do not allocate temporary string.
+ * hash.c (rb_hash_each): Hash#each should yield single value.
+ [ruby-talk:84420]
- * string.c (rb_str_sub_bang): use inline replace.
+ * hash.c (env_each): ditto for ENV.each.
-Wed Jul 29 00:36:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 23 20:25:32 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * hash.c (hash_s_new): the default value can be specified.
+ * lib/webrick/server.rb (GenericServer#start): should rescue
+ IOError from IO::accept. [ruby-dev:21692]
- * hash.c (hash_default): method to set the default value.
+Thu Oct 23 17:59:36 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * hash.c (hash_aref): now returns the default value.
+ * eval.c (ruby_cleanup): initialize stack bottom for embedding.
+ [ruby-dev:21686]
-Tue Jul 28 13:03:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/dl/extconf.rb: move list of files to clean from DEPEND file,
+ to get rid of macro redefinitions.
- * array.c (ary_s_new): argument to specify initial value is added.
+Thu Oct 23 13:44:00 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (ary_s_new): specifies size, not capacity.
+ * parse.y: integrate operations for stack_type. [ruby-dev:21681]
-Mon Jul 27 12:39:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 23 00:41:45 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * string.c (str_replace): zero fill for expansion gap.
+ * test/soap/calc/*, test/soap/helloworld/*: set logging threshold
+ to ERROR.
- * regex.c (mbctab_euc): set flags on for 0xA1-0xFE. suggested by
- <inaba@st.rim.or.jp>.
+Wed Oct 22 12:53:31 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (str_inspect): consider current_mbctype.
+ * lib/test/unit/collector/dir.rb (Test::Unit::Collector::Dir#collect_file):
+ ignore tests which raised LoadError.
-Sun Jul 26 15:37:11 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * test/drb/drbtest.rb, test/ruby/test_beginendblock.rb,
+ test/ruby/test_system.rb: avoid requiring same file twice.
- * array.c (ary_s_new): Array.new(1<<30) dumps core.
+ * test/drb/test_drbssl.rb, test/drb/test_drbunix.rb: should not use
+ ARGV unless invoked directly. do not create test cases unless
+ required libraries are available.
-Fri Jul 24 13:40:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 22 02:31:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * version 1.1c1 released.
+ * eval.c (ruby_cleanup): should not ignore exit_value in END
+ execution. [ruby-dev:21670]
-Fri Jul 24 02:10:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Oct 21 23:16:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * marshal.c (r_bytes2): allocated buffer size was too short.
+ * eval.c (ruby_cleanup): call finalizers and exit procs before
+ terminating threads.
- * marshal.c (w_object): saves all options, not only casefold flag.
+ * eval.c (ruby_cleanup): preserve ruby_errinfo before ruby_finalize_0().
- * re.c (reg_clone): now copies options properly.
+Tue Oct 21 15:57:11 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (reg_get_kcode): code number was wrong.
+ * lib/test/unit/collector/dir.rb (Test::Unit::Collector::Dir#collect_file):
+ prepend the directory of target file to the load path.
-Thu Jul 23 13:11:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Oct 21 15:08:53 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (rb_attr): argument should be symbol or string.
+ * win32/win32.c (do_spawn, do_aspawn): should wait child process even
+ if callded with P_OVERLAY.
-Wed Jul 22 11:59:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * win32/win32.c (do_spawn, do_aspawn): should return child's exit
+ status to parent.
- * regex.c (calculate_must_string): wrong offset added.
+Tue Oct 21 00:35:02 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Wed Jul 22 11:59:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/soap/calc/*, test/soap/helloworld/*: catch the exception from
+ test server thread and recover.
- * st.c (rehash): still had a GC problem. fixed.
+Tue Oct 21 00:22:57 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-Tue Jul 21 13:19:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/drb/*: import drb/runit.
- * eval.c (gc_mark_threads): crashed on GC before thread allocation.
+Mon Oct 20 23:55:47 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * st.c (rehash): GC during rehash caused SEGV.
+ * eval.c (rb_eval): set current node after arguments evaluation.
+ [ruby-dev:21632]
-Tue Jul 21 01:25:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_yield_0): set current node and keep it at local jump.
- * sprintf.c (f_sprintf): integer formatter totally re-written.
+Mon Oct 20 22:01:18 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * sprintf.c (remove_sign_bits): support uppercase hexadecimal.
+ * eval.c (rb_thread_cleanup): keep thread group for main thread.
+ [ruby-dev:21644]
-Sat Jul 18 00:14:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Oct 20 18:28:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * sprintf.c (f_sprintf): proper sign position for %X and %O.
+ * eval.c (rb_catch): backout.
-Fri Jul 17 14:10:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Oct 20 17:31:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * version 1.1c0 released.
+ * eval.c (PUSH_FRAME): generate unique number to be TAG_JUMP()
+ destination.
-Fri Jul 17 08:01:49 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * eval.c (localjump_destination): use unique number in ruby_frame
+ for localjump destination.
- * process.c (f_exec): Check_SafeStr() added.
+Mon Oct 20 11:31:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * process.c (f_system): Check_SafeStr() moved before fork().
+ * test/ruby/test_signal.rb (test_signal): restore old trap.
-Thu Jul 16 22:58:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Oct 20 11:00:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (scan_once): substrings to the block should not be
- tainted. use reg_nth_match(), not str_substr().
+ * gc.c (gc_sweep): loosen page free condition to avoid add_heap()
+ race condition. [ruby-dev:21633]
- * string.c (str_substr): needed to transfer taint.
+ * gc.c (gc_sweep): do not update malloc_limit when malloc_increase
+ is smaller than malloc_limit.
-Thu Jul 16 16:15:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Oct 20 09:45:12 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * gc.c (xmalloc): object allocation count added to GC trigger.
+ * lib/debug.rb (debug_command): remove debug print.
- * eval.c (thread_save_context): avoid marking uninitialized stack
- in thread_mark. GC may be triggered by REALLOC_N().
+Wed Oct 20 00:25:41 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jul 15 15:11:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (search_required): required name must not be changed before
+ loading. [ruby-dev:24492]
- * experimental release 1.1b9_31.
+Sun Oct 19 13:12:30 2003 Tanaka Akira <akr@m17n.org>
-Wed Jul 15 15:05:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/pathname.rb (foreachline, dir_foreach): add obsolete warning.
- * eval.c (thread_create): exit() and abort() in threads now
- forwarded to main_thread.
+Sun Oct 19 00:14:22 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Tue Jul 14 14:03:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/soap/calc/*, test/soap/helloworkd/*: changed port# of test
+ server. (17171)
- * variable.c (obj_instance_variables): list names that is not
- instance variables.
+Sat Oct 18 23:01:32 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * gc.c (GC_MALLOC_LIMIT): choose smaller limit value.
+ * missing/acosh.c (DBL_MANT_DIG): typo fix(ifdef -> ifndef).
-Mon Jul 13 12:39:38 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Oct 18 05:48:59 2003 why the lucky stiff <why@ruby-lang.org>
- * object.c (str2cstr): should not return NULL.
+ * ext/syck/rubyext.c: YAML::Syck::compile method.
-Fri Jul 10 11:51:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/syck.c: Buffer edge bug.
- * parse.y (gettable): needed to add dyna_in_block() check.
+ * ext/syck/yaml2byte.c: YAML to bytecode converter.
-Thu Jul 9 17:38:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/yamlbyte.h: Ditto.
- * experimental release 1.1b9_30.
+ * ext/syck/bytecode.c: Bytecode parser fixes to empty collections
+ and empty strings.
-Thu Jul 9 16:01:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/token.c: Ditto.
- * sprintf.c (fmt_setup): format specifier for long needed.
+Fri Oct 17 23:07:38 2003 Akinori MUSHA <knu@iDaemons.org>
- * sprintf.c (f_sprintf): ditto.
+ * ext/enumerator/enumerator.c, ext/enumerator/enumerator.txt:
+ Provide Kernel#to_enum as an alias for Kernel#enum_for. Maybe
+ this is a better name.
- * numeric.c (fix2str): ditto.
+Fri Oct 17 23:00:30 2003 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (thread_create): no more ITIMER_REAL.
+ * lib/generator.rb: Add rdoc documentation.
- * eval.c (thread_create): thread finalization needed before
- aborting thread if thread_abort is set.
+Fri Oct 17 22:16:42 2003 Akinori MUSHA <knu@iDaemons.org>
-Wed Jul 8 18:17:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/set.rb: Reword and fix Overview.
- * bignum.c (big_pow): abandon power by bignum (too big).
+ * lib/set.rb: It is not necessary to require
+ 'test/unit/ui/console/testrunner'.
-Tue Jul 7 13:58:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Oct 17 11:15:22 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (rb_catch): add C level catch/throw feature.
+ * test/ruby/test_range.rb: added.
-Mon Jul 6 15:18:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * MANIFEST: add test/ruby/test_range.rb.
- * parse.y (arg): proper return values for `||=' and `&&='.
+Fri Oct 17 03:21:23 2003 William Sobel <will.sobel@barra.com>
-Fri Jul 3 16:05:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/socket.c (make_hostent): h_aliases may be NULL.
+ (ruby-bugs:PR#1195)
- * experimental release 1.1b9_29.
+ * ext/socket/socket.c (sock_s_gethostbyaddr): ditto.
-Fri Jul 3 11:20:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Oct 17 00:12:41 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * marshal.c (r_byte): byte should not extend sign bit.
+ * ext/tk/lib/tk.rb: (bug fix) instance variable @frame was used
+ without initializing on TkComposite module.
- * numeric.c (fix_mul): use FIX2LONG() instead of FIX2INT() for
- 64bit architectures.
+Thu Oct 16 23:51:04 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * marshal.c (r_bytes): remove weird casting between pointer and int.
+ * ext/tk/lib/tk.rb: If $DEBUG == true and some exception is caused
+ in a callback operation, Ruby/Tk shows a (verbose) backtrace
+ information on the callback process.
- * process.c (proc_setsid): new method Process#setsid().
+Thu Oct 16 17:09:19 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Jul 2 12:49:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/debug.rb (DEBUGGER__::Context::debug_command): do not call
+ debug_silent_eval() when $1 is not set. (ruby-bugs:PR#1194)
- * marshal.c (w_object): remove `write_bignum' label for 64bit
- architectures.
+Thu Oct 16 16:54:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * marshal.c (r_bytes): needs int, not long.
+ * string.c (rb_str_upto): ("a"..."a").to_a should return [].
+ [ruby-core:01634]
-Wed Jul 1 14:21:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 16 16:40:51 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * numeric.c (flo_plus): should not allow addition with strings.
+ * ext/tk/lib/tk.rb:
+ Add Tk::EncodedString and Tk::UTF8_String class to support
+ characters using the \uXXXX escape to the UNICODE string.
-Wed Jul 1 13:09:01 1998 Keiju ISHITSUKA <keiju@rational.com>
+ * ext/tk/sample/{demos-en,demos-jp}/unicodeout.rb
+ new demo-scripts (samples of Tk::UTF8_String)
- * numeric.c (num_uminus): wrong coerce direction.
+ * ext/tk/sample/{demos-en,demos-jp}/widget
+ add entries for 'unicodeout.rb'
-Tue Jun 30 10:13:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 16 08:38:06 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (f_p): accepts arbitrary number of arguments.
+ * test/digest/test_digest.rb (test_eq): show failed class.
- * eval.c (rb_yield_0): there's some case that iterator_p() returns
- true even if the_block was not set. check added.
+ * test/ruby/test_iterator.rb (test_break, test_return_trace_func):
+ test localjump destination.
-Tue Jun 30 01:05:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 15 20:22:31 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (BEGIN_CALLARGS): adjust the_block before evaluating the
- receiver's value and the arguments.
+ * lib/soap/netHttpClient.rb: use URI::HTTP#request_uri instead of
+ instance_eval('path_query'). [ruby-list:38575]
-Fri Jun 26 18:02:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 15 17:24:45 2003 URABE Shyouhei <root@mput.dip.jp>
- * experimental release 1.1b9_28.
+ * lib/cgi.rb (CGI::Cookie): tiny typo fix.
-Fri Jun 26 11:01:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Wed Oct 15 15:00:54 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (str_aset_method): needed to convert to string.
+ * eval.c (ruby_run): just return FAILURE instead of parse error
+ count. [ruby-list:38569]
-Thu Jun 25 02:05:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 15 13:17:02 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * regex.c (re_search): optimize for `.*' at beginning of the
- pattern.
+ * ext/digest/digest.c (rb_digest_base_alloc): need to initialize
+ buffer. [ruby-dev:21622]
- * regex.c (re_search): optimize for character class repeat at
- beginning of the pattern.
+Wed Oct 15 11:23:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_compile_pattern): detect optimization potential for
- the compiled patterns.
+ * marshal.c (w_object): dump extended modules as well.
-Thu Jun 25 00:02:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * marshal.c (r_object0): TYPE_USRMARSHAL should restore extended
+ modules before invoking marshal_load. these two fixes are done
+ by Masatoshi Seki <m_seki@mva.biglobe.ne.jp>.
- * re.c (reg_s_new): flag value was wrong.
+Wed Oct 15 09:30:34 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Wed Jun 24 23:45:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/enumerator/enumerator.c (enumerator_each): avoid VC++ warning.
- * regex.c (re_search): wrong anchor handling for reverse search.
+ * ext/syck/syck.h: include stdio.h for definition of FILE.
-Wed Jun 24 02:18:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 15 08:09:07 2003 why the lucky stiff <why@ruby-lang.org>
- * parse.y (mlhs): `((a,b)),c = [[1,2]],3' assigns a=1,b=2,c=3.
+ * ext/syck/bytecode.c: Checkin of YAML bytecode support.
-Tue Jun 23 11:46:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/gram.c: Ditto.
- * parse.y (yylex): `&&=' and `||=' added.
+ * ext/syck/syck.c: Ditto.
-Sat Jun 20 02:53:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/token.c: Ditto.
- * parse.y (assignable): nesting local variables should have higher
- priority than normal local variables for assignment too.
+ * ext/syck/handler.c: Ditto.
-Fri Jun 19 18:28:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/handler.c: Now using 'tag' rather than 'taguri' in type URIs.
- * experimental release 1.1b9_27.
+ * ext/syck/rubyext.c: Ditto (on both counts).
-Fri Jun 19 14:34:49 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 15 05:05:53 2003 Akinori MUSHA <knu@iDaemons.org>
- * eval.c (assign): support hack for nested multiple assignment.
+ * lib/generator.rb: A new library which converts an internal
+ iterator to an external iterator.
- * parse.y (mlhs): nested multiple assignment.
+ * lib/abbrev.rb: A new library which creates an abbreviation table
+ from a list.
- * eval.c (rb_eval): in-block variables now honors static scope.
+Wed Oct 15 04:31:51 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * configure.in: RSHIFT check moved to configure.
+ * ext/tk/sample/demos-en/entry3.rb, ext/tk/sample/demos-jp/entry3.rb :
+ new demo-scripts
-Thu Jun 18 16:46:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/sample/demos-en/widget, ext/tk/sample/demos-jp/widget :
+ add entries for 'entry3.rb'
- * experimental release 1.1b9_26.
+Wed Oct 15 04:31:47 2003 Akinori MUSHA <knu@iDaemons.org>
-Thu Jun 18 13:37:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/digest/test_digest.rb: Moved from ext/digest/test.rb.
- * file.c (file_s_ftype): uses lstat(2) instead of stat(2).
+Wed Oct 15 03:53:20 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * dir.c (dir_s_glob): there can be buffer overrun, check added.
+ * ext/tk/lib/tk.rb: fixed trouble on auto-load Tcl commands (enbug
+ on the last commit).
- * eval.c (f_binding): handles in-block variables declared after
- binding's generation.
+Wed Oct 15 00:25:00 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * numeric.c (flo_floor): floor, ceil, round added to Float.
+ * parse.y (yylex): argument parentheses preceded by spaces should
+ be warned; not error. [ruby-talk:84103]
-Wed Jun 17 11:20:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Oct 15 00:20:15 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * parse.y (gettable): nesting local variables should have higher
- priority than normal local variables.
+ * ext/tcltklib/tcltklib.c: replace Tcl/Tk's vwait and tkwait to
+ switch on threads smoothly and avoid seg-fault.
-Tue Jun 16 12:30:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tcltklib/tcltklib.c: add TclTkIp._thread_vwait and
+ _thread_tkwait for waiting on a thread. (Because Tcl/Tk's vwait
+ and tkwait command wait on an eventloop.)
- * bignum.c (str2inum): handles `+ddd'.
+ * ext/tk/lib/multi-tk.rb: support TclTkIp._thread_vwait and
+ _thread_tkwait.
- * struct.c (make_struct): name parameter can be nil for unnamed
- structures.
+ * ext/tk/lib/tk.rb: now, TkVariable#wait has 2 arguments.
+ If 1st argument is true, waits on a thread. If false, waits on
+ an eventloop. If 2nd argument is true, checks existence of
+ rootwidgets. If false, doesn't. Default is wait(true, false).
-Mon Jun 15 16:30:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tk.rb: add TkVariable#tkwait(arg) which is equal to
+ TkVariable#wait(arg, true). wait_visibility and wait_destroy
+ have an argument for waiting on a thread or an eventloop.
- * object.c (class_s_inherited): prohibiting to make subclass of
- class Class.
+ * ext/tk/lib/tk.rb: improve of accessing Tcl/Tk's special variables.
- * object.c (module_s_new): support for making subclass of Module.
+ * ext/tk/lib/tkafter.rb: support 'wait on a thread' and 'wait on
+ an eventloop'.
- * parse.y (yycompile): clear eval_tree before compiling.
+Wed Oct 15 00:10:24 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Fri Jun 12 17:58:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/baseData.rb: Introduce SOAPType as the common ancestor of
+ SOAPBasetype and SOAPCompoundtype.
- * eval.c (eval): write back the_dyna_var into the block.
+ * lib/soap/generator.rb, lib/soap/element.rb, lib/soap/encodingstyle/*:
+ Encoding methods signature change. Pass SOAPGenerator as a parameter.
-Thu Jun 11 18:19:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/mapping/*, test/soap/marshal/test_marshal.rb: Refactoring
+ for better marshalling/unmarshalling support. Now I think SOAP
+ marshaller supports all kind of object graph which is supported by
+ Ruby's original marshaller. Of course there could be bugs as always.
+ Find it. :-)
- * experimental release 1.1b9_25.
+ * lib/soap/rpc/standaloneServer.rb: Set severity threshould to INFO.
+ DEBUG is too noisy.
- * eval.c (dvar_add_compiling): register dyna_var at compile time.
+ * lib/xsd/datatypes.rb: DateTime#of is obsoleted. Use DateTime#offset.
- * regex.c (re_compile_pattern): RE_DUP_MAX iteration is too big.
+ * test/wsdl/emptycomplextype.wsdl, test/xsd/xmlschema.xml: Avoid
+ useless warning.
-Wed Jun 10 15:12:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Oct 14 19:09:35 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (io_eof): do not block other threads.
+ * eval.c (ruby_finalize_0): return the given exit status unless
+ SystemExit got raised.
- * signal.c (trap): reserve SIGALRM for thread.
+Tue Oct 14 11:53:49 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (thread_create): use ITIMER_REAL also to avoid system
- call blocking.
+ * intern.h (ruby_stop): never return.
- * io.c (f_syscall): add TRAP_BEG, TRAP_END around system calls.
+ * ruby.h (ruby_run): ditto.
- * io.c (io_ctl): add TRAP_BEG, TRAP_END around system calls.
+Tue Oct 14 04:43:55 2003 Tanaka Akira <akr@m17n.org>
- * enum.c (enum_collect): did not collect false values.
+ * lib/pathname.rb (realpath): make ELOOP check bit more robust.
+ (children): prepend self by default.
+ (chroot): obsoleted.
- * array.c (ary_new2): forgot to initialize capa field.
+Tue Oct 14 02:29:31 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Jun 9 18:36:15 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * eval.c (rb_require_safe): segfault after loading .so.
- * string.c (str_split_method): split dumped core for "\xff".
+Tue Oct 14 02:05:23 2003 Akinori MUSHA <knu@iDaemons.org>
-Tue Jun 9 16:22:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/Setup*, ext/enumerator/*: Add ext/enumerator, a helper
+ module for the Enumerable interface.
- * experimental release 1.1b9_24.
+Mon Oct 13 23:55:59 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Tue Jun 9 16:04:07 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * test/ruby/envutil.rb: use Config::CONFIG["ruby_install_name"],
+ not "ruby".
- * ext/kconv/kconv.c (kconv_guess): more precise decision for EUC,
- using jless algorithm (3 sequential EUC hiragana characters).
+Mon Oct 13 23:57:29 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Jun 9 15:12:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_feature_p): match by classified suffix.
- * ext/kconv/kconv.c (kconv_guess): wrong guess for EUC as SJIS in
- some cases (0xe0 - 0xef).
+ * eval.c (rb_require_safe): require library in the specified safe
+ level.
- * gc.c (xmalloc): insert size check for big (negative in signed)
- allocation size.
+ * variable.c (rb_autoload, rb_autoload_load): restore safe level
+ when autoload was called. [ruby-dev:21338]
-Tue Jun 9 02:54:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * intern.h: prototypes; rb_require_safe.
- * lib/parsedate.rb: wday moved to the last in the return values.
+ * test/runner.rb: accept non-option arguments.
-Mon Jun 8 10:40:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Oct 13 20:49:51 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_split_method): split dumped core for "\0".
+ * string.c (str_new4): should not preserve FL_TAINT status in the
+ internal shared string. [ruby-dev:21601]
-Sat Jun 6 22:50:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (rb_str_new4): ditto.
- * regex.c (calculate_must_string): wrong condition for
- {start,stop}_nowidth.
+ * eval.c: use EXIT_SUCCESS and EXIT_FAILURE for exit values.
- * regex.c (re_match): various features imported from GNU regex.c
- 0.12, such as nested grouping, avoiding infinite loop with empty
- match, etc.
+ * process.c: ditto. [ruby-list:38521]
- * regex.c (register_info_type): now use union.
+Mon Oct 13 19:51:02 2003 Koji Arai <jca02266@nifty.ne.jp>
- * regex.c (re_search): more precise anchor(^) check.
+ * lib/debug.rb (debug_command): should enter emacs mode when
+ assigned any value to the environment variable "EMACS".
+ On Meadow, (getenv "EMACS") is "meadow".
-Wed Jun 3 18:07:54 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Oct 12 14:45:03 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * re.c (reg_raise): check rb_in_compile, not rb_in_eval.
+ * ext/win32ole/extconf.rb: check "windows.h", not "windows".
+ [ruby-talk:84051]
-Mon Jun 1 05:26:06 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+Sat Oct 11 20:41:03 2003 Corinna Vinschen <corinna@vinschen.de>
- * string.c (trnext): casting to signed char* needed.
+ * file.c (eaccess): Use access(2) on Cygwin.
-Tue Jun 2 16:00:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Oct 11 17:09:21 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * ext/socket/socket.c (udp_addrsetup): error check enhanced.
+ * lib/rexml/quickpath.rb (REXML::QuickPath::match):
+ escape '[' to avoid warning.
- * ext/socket/socket.c (sock_s_getservbyaname): use strtoul(), if
- possible.
+Sat Oct 11 16:08:41 2003 Tanaka Akira <akr@m17n.org>
-Sat May 30 07:10:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/pathname.rb (realpath): check existence of the file.
- * re.c (reg_prepare_re): no more needless regular expression
- recompile on casefold conditions.
+ * lib/pathname.rb (realpath): re-implemented.
+ (realpath_root?, realpath_rec): removed
-Thu May 28 18:02:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Oct 11 10:19:39 2003 Shugo Maeda <shugo@ruby-lang.org>
- * object.c (nil_plus): no more `+' method for nil.
+ * lib/monitor.rb: handle exceptions correctly. Thanks, Gennady
+ Bystritsky.
-Wed May 27 17:33:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Oct 10 07:50:54 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * hash.c (hash_fetch): new method.
+ * eval.c (is_defined): inheritance line adjustment as like as
+ rb_call_super().
- * regex.c (re_search): check whether translate table is set.
+Fri Oct 10 01:19:00 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Tue May 26 11:39:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_x509name.c (ossl_x509name_initialize): add
+ optional argument to specify the DirectoryString type
+ (ASN1::UTF8STRING by default). RFC3280 deprecates PrintableString
+ for DirectoryString, and strongly requires to use UTF8String for
+ all certificates issued after December, 31 2003.
- * experimental release 1.1b9_23.
+ * ext/openssl/lib/openssl/x509.rb (X509::Name::parse): ditto.
- * parse.y (yylex): no UPLUS/UMINUS for 1st argument if
- parenthesises are omitted.
+Thu Oct 9 23:50:21 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue May 26 01:09:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_thread_start_0): prevent thread from GC.
+ [ruby-dev:21572]
- * regex.c (re_compile_pattern): (?XI) for turns off the
- corresponding option.
+Thu Oct 9 19:11:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon May 25 12:38:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_thread_start_0): non-volatile should be restored from
+ volatile.
- * regex.c (re_compile_pattern): inline i option (?i).
+Thu Oct 9 17:43:36 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_compile_pattern): inline x option (?x).
+ * eval.c (proc_save_safe_level, proc_get_safe_level,
+ proc_set_safe_level): save/restore safe level 1..4.
- * regex.c (re_compile_pattern): x option for regexp.
+Thu Oct 9 16:33:23 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * dir.c (dir_s_open): returns block's evaluated value.
+ * marshal.c (r_object0): remove unnecessary iv restoration for
+ USRMARSHAL. [ruby-dev:21582]
- * io.c (f_open): returns block's evaluated value.
+ * marshal.c (w_object): dump generic instance variables from
+ a string from '_dump'.
- * ext/curses/curses.c (curses_addstr): nil argument caused SEGV.
+ * variable.c (rb_generic_ivar_table): return 0 if obj's FL_EXIVAR
+ is not set.
-Fri May 22 11:52:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * time.c (time_dump): copy instance variables to dumped string, to
+ be included in the marshaled data.
- * regex.c (re_compile_pattern): push mark on (?:), so that
- laststart check for {a,b} can be done.
+ * bignum.c (rb_big2ulong): add range check to ensure round trip.
-Thu May 21 17:31:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 9 15:45:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_match): wrong match (too non-greedy) for `{a,b}?'.
+ * pack.c (uv_to_utf8): change message to "out of range", since
+ negative values are not "too big". [ruby-dev:21567]
- * io.c (io_lineno): new method IO#lineno, IO#lineno=.
+Thu Oct 9 14:05:38 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed May 20 06:04:43 1998 MAEDA shugo <shugo@aianet.ne.jp>
+ * eval.c (rb_set_end_proc, rb_exec_end_proc): restore safe level.
+ [ruby-dev:21557]
- * BeOS patch.
+Thu Oct 9 10:51:04 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed May 20 16:32:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_yield_0): no error if block is empty.
- * bignum.c (BIGDN): use RSHIFT(), instead of mere `>>'.
+Thu Oct 9 06:43:33 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue May 19 16:36:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (localjump_error): id should be ID.
- * experimental release 1.1b9_22.
+ * eval.c (rb_eval): nd_rval is set in copy_node_scope().
-Tue May 19 16:31:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_yield_0): unused variable.
- * parse.y (assignable): specification changed for in-block
- variable definition.
+ * eval.c (rb_yield_0): nothing to do for empty node.
- * eval.c (dyna_var_asgn): error in in-block variables' compile
- time definition.
+ * eval.c (call_end_proc, proc_invoke): adjust backtrace in END.
+ [ruby-dev:21551]
- * parse.y (str_extend): wrong nesting detection.
+ * eval.c (rb_thread_start_0): set the value by break as the result.
+ [ruby-dev:21552]
-Tue May 19 09:47:55 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * eval.c (rb_thread_start_0, rb_thread_raise, rb_callcc): save
+ variables across THREAD_SAVE_CONTEXT.
- * numeric.c (num2int): re-defined (extensions may use this).
+Thu Oct 9 12:05:46 2003 Eric Sunshine <sunshine@sunshineco.com>
-Mon May 18 16:40:50 1998 MAEDA shugo <shugo@aianet.ne.jp>
+ * configure.in: revived NextStep, OpenStep, and Rhapsody ports which
+ had become unbuildable; enhanced --enable-fat-binary option so that
+ it accepts a list of desired architectures (rather than assuming a
+ fixed list), or defaults to a platform-appropriate list if user does
+ not provide an explicit list; made the default list of architectures
+ for MAB (fat binary) more comprehensive; now uses -fno-common even
+ when building the interpreter (in addition to using it for
+ extensions), thus allowing the interpreter to be embedded into a
+ plugin module of an external project (in addition to allowing
+ embedding directly into an application); added checks for
+ <netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
+ ensures that -I/usr/local/include is employed when extensions'
+ extconf.rb scripts invoke have_header() since extension checks on
+ NextStep and OpenStep will fail without it if the desired resource
+ resides in the /usr/local tree; fixed formatting of --help message.
- * error.c (get_syserr): BeOS support.
+ * Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
+ invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
+ (see configure's --enable-fat-binary option); added rule for new
+ missing/getcwd.c.
- * configure.in: modified for BeOS.
+ * defines.h: fixed endian handling during MAB build (see configure's
+ --enable-fat-binary option) to ensure that all portions of the
+ project see the correct WORDS_BIGENDIAN value (some extension modules
+ were getting the wrong endian setting); added missing constants
+ GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
+ and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
+ define in NeXT section.
- * string.c (str_dump): do not call isascii().
+ * dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
+ NextStep since, on some installations, this value always resolves
+ uselessly to zero.
- * sprintf.c (remove_sign_bits): forgot to initialize end pointer.
+ * dln.c: added error reporting to NextStep extension loader since the
+ previous behavior of failing silently was not useful; now ensures
+ that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
+ for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
+ on Rhapsody since this header lacks multiple-include protection,
+ which resulted in "redefinition" compilation errors.
- * glob.c: #include <alloca.h> added.
+ * main.c: also create hard reference to objc_msgSend() on NeXT
+ platforms (in addition to Apple platforms).
-Mon May 18 14:52:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
-
- * experimental release 1.1b9_21.
+ * lib/mkmf.rb: now exports XCFLAGS from configure script to extension
+ makefiles so that extensions can be built MAB (see configure's
+ --enable-fat-binary option); also utilize XCFLAGS in cc_command()
+ (but not cpp_command() because MAB flags are incompatible with
+ direct invocation of `cpp').
-Mon May 18 03:27:57 1998 MAEDA shugo <shugo@aianet.ne.jp>
+ * ext/curses/extconf.rb: now additionally checks for presence of these
+ curses functions which are not present on NextStep or Openstep:
+ bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
+ setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
+ wscrl(), wsetscrreg()
- * file.c (file_s_expand_path): optional second argument
- `default_directory' added.
+ * ext/curses/curses.c: added appropriate #ifdef's for additional set of
+ curses functions now checked by extconf.rb; fixed curses_bkgd() and
+ window_bkgd() to correctly return boolean result rather than numeric
+ result; fixed window_getbkgd() to correctly signal an error by
+ returning nil rather than -1.
-Sat May 16 22:06:52 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/etc/etc.c: setup_passwd() and setup_group() now check for null
+ pointers before invoking rb_tainted_str_new2() upon fields extracted
+ from `struct passwd' and `struct group' since null pointers in some
+ fields are common on NextStep/OpenStep (especially so for the
+ `pw_comment' field) and rb_tainted_str_new2() throws an exception
+ when it receives a null pointer.
- * error.c (RAISE_ERROR): wrong error message
+ * ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
+ platforms such as NextStep and OpenStep which lack strdup().
-Fri May 15 14:43:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
+ gethostbyaddr(), and gethostbyname() from (const char*) to non-const
+ (char*) for older platforms such as NextStep and OpenStep.
- * experimental release 1.1b9_20.
+ * ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
+ platforms such as NextStep and OpenStep which lack strdup(); include
+ <netinet/in_systm.h> if present for NextStep and OpenStep; cast first
+ argument of gethostbyaddr() and getservbyname() from (const char*) to
+ non-const (char*) for older platforms.
-Thu May 14 14:44:21 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
+ platforms such as NextStep and OpenStep which lack strdup().
- * sun4 cc patches for intern.h and regex.h.
+Wed Oct 8 22:19:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Thu May 14 14:03:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit.rb: removed installation instructions.
- * random.c (RANDOM_MAX): guessing proper maximum value for random
- numbers.
+ * lib/test/unit/ui/testrunnermediator.rb: moved the run flag to a more
+ central location.
- * random.c (f_rand): use drand48 if possible.
+ * lib/test/unit.rb: ditto.
-Wed May 13 19:05:20 1998 MAEDA shugo <shugo@aianet.ne.jp>
+ * lib/test/unit.rb: extracted the running code in to AutoRunner.
- * BeOS patches for io.c, error.c and config.guess.
+ * lib/test/unit/autorunner.rb: added.
-Wed May 13 14:56:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/collector/objectspace.rb: extracted common test
+ collection functionality in to a module.
- * experimental release 1.1b9_19.
+ * lib/test/unit/collector.rb: ditto; added.
- * most of the Mac and BeOS patches merged, except path separators.
+ * test/testunit/collector/test_objectspace.rb: ditto.
- * error.c (err_append): generated SyntaxError was String.
+ * lib/test/unit/collector/dir.rb: added. Supports collecting tests out
+ of a directory structure.
- * ruby.h: xxx2INT, xxx2UINT checks values as int, not long.
+ * test/testunit/collector/test_dir.rb: added.
- * ruby.h: remove typedef's. INT, UINT, UCHAR, USHORT.
+ * test/runner.rb: simplified to use the new capabilities.
-Tue May 12 17:38:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Oct 7 15:23:09 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * experimental release 1.1b9_18.
+ * test/ruby/test_beginendblock.rb: add tests for nested BEGIN/END.
-Tue May 12 11:38:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/beginmainend.rb: add tests for nested BEGIN/END.
- * error.c (syserr_errno): returns errno of the SystemCallError.
+ * test/ruby/endblockwarn.rb: new file added to test of END-in-method
+ warning.
- * error.c (rb_sys_fail): saves errno in the Exception.
+Tue Oct 7 12:23:47 2003 Tanaka Akira <akr@m17n.org>
- * error.c (set_syserr): no need to protect syserr_list.
+ * ext/fcntl/fcntl.c (Init_fcntl): define Fcntl::O_ACCMODE.
- * error.c (rb_sys_fail): no more bufsize limit.
+ * ext/socket/extconf.rb: useless assignment removed.
- * error.c (set_syserr): integer value of errno can be accessed by
- Errno::EXXX::Errno.
+Tue Oct 7 09:13:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sun May 10 03:10:33 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+ * test/ruby/test_beginendblock.rb (test_endinmethod): END{} is now
+ allowed in eval.
- * io.c (io_tell etc.): moved from File class to IO class.
+Tue Oct 7 04:15:25 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri May 8 12:26:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * parse.y (stmt): should not expand mrhs if lhs is solely starred.
- * pack.c (pack_unpack): should be unsigned int (was signed int).
+Tue Oct 7 02:57:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu May 7 16:34:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * parse.y (stmt): rhs of multiple assignment should not be
+ expanded using "to_a". [ruby-dev:21527]
- * pack.c (pack_pack): `V', `N' uses newly created NUM2UINT().
+Tue Oct 7 01:42:34 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ruby.h (NUM2UINT): new macro.
+ * ext/openssl/ossl_asn1.c (ossl_asn1_get_asn1type): use appropriate
+ free function for ASN1_OBJECT.
- * bignum.c (big2uint): try to convert bignum into UINT.
+ * ext/openssl/ossl_asn1.c (ossl_asn1obj_get_sn): add new function for
+ ASN1::ObjectId#sn; it returns short name text representation of OID.
- * re.c (reg_match): needed to return false for match with nil.
+ * ext/openssl/ossl_asn1.c (ossl_asn1obj_get_ln): add new function for
+ ASN1::ObjectId#ln; it returns long name text representation of OID.
- * gc.c (obj_free): wrong condition to free string.
+ * ext/openssl/ossl_asn1.c (ossl_asn1obj_get_oid): add new function for
+ ASN1::ObjectId#oid; it returns numerical representation of OID.
-Wed May 6 21:08:08 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Mon Oct 6 22:59:46 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * ruby.c (ruby_process_options): modified for DJGPP.
+ * lib/csv.rb (IOReader, BasicWriter): call binmode when a given IO
+ respond_to?(:binmode). record separator was wrong when you gave
+ text mode IO to Reader.parse and Writer.generate.
-Wed May 6 15:48:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/csv/test_csv.rb: add tests for above change.
- * experimental release 1.1b9_17.
+Sun Oct 5 23:27:09 2003 Tanaka Akira <akr@m17n.org>
-Wed May 6 01:37:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/extconf.rb: check recvmsg even if sendmsg is exists.
- * eval.c: remove global variable `errat'.
+ * ext/socket/socket.c (thread_read_select): restored.
- * eval.c (rb_longjmp): embed error position information in the
- exception object.
+Mon Oct 6 16:23:38 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat May 2 12:20:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * marshal.c (w_object): wrong method name in the message.
- * re.c (reg_search): supports reverse search.
+Mon Oct 6 16:02:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_index_method): does update $~ etc.
+ * parse.y (stmt): END in method should cause warning.
+ [ruby-dev:21519]
- * eval.c (f_load): needed to clear the_dyna_vars.
+Mon Oct 6 15:17:23 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (dyna_var_asgn): do not push dyna_var, which is id == 0.
+ * test/ruby/test_iterator.rb (test_block_argument_without_paren):
+ added. (follows sample/test.rb)
- * error.c (Init_Exception): NotImplementError is no longer
- StandardError, which is not handled by default rescue.
+Mon Oct 6 11:57:06 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Fri May 1 00:35:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/test_beginendblock.rb, test/ruby/beginmainend.rb: added
+ test for eval-ed BEGIN END order.
- * ruby.c (proc_options): `-d' turns on verbose flag too.
+Mon Oct 6 09:19:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * error.c (exception): last argument may be the superclass of the
- defining exception(s).
+ * marshal.c (w_object): should pass "weak" value to next level.
+ [ruby-dev:21496]
- * io.c (Init_IO): EOFError is now subclass of the IOError.
+ * eval.c (proc_alloc): should not use cached object if klass is
+ different. [ruby-talk:83685]
- * io.c (Init_IO): forgot to define IOError.
+Sun Oct 5 23:27:09 2003 Tanaka Akira <akr@m17n.org>
- * error.c (Init_Exception): old Exception class renamed to
- StandardError. Exception now replaces old GlobalExit.
+ * lib/pathname.rb: version information is added in document.
- * error.c (Init_Exception): Exception is now the root of the
- Global Exits. There's no longer GlobalExit class.
+Sun Oct 5 23:07:03 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * util.c (ruby_mktemp): check TMP, TMPDIR first.
+ * eval.c (rb_f_END): block should be given. [ruby-dev:21497]
-Thu Apr 30 01:08:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Oct 5 22:51:23 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * lib/tk.rb: call 'unknown', if proc not defined.
+ * lib/ext/openssl/extconf.rb: add check for some engine functions
+ unavailable in OpenSSL-0.9.6.
- * eval.c (handle_rescue): default rescue handles `Exceptional' not
- only the instance of the `Exception's.
+ * lib/ext/openssl/ossl_engine.c: ditto.
- * eval.c (f_raise): exception can be any object.
+Sun Oct 5 17:56:30 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * time.c (time_gm_or_local): call time_gmtime or time_localtime.
+ * eval.c (rb_eval): fix evaluation order. [ruby-list:38431]
- * eval.c (f_raise): raises TypeError if the class which is not a
- subclass of String is specified (checked in exc_new()).
+Sun Oct 5 15:05:06 2003 akira yamada <akira@ruby-lang.org>
- * error.c (exc_new): need to check whether invalid class (not a
- subclass of String) is specified.
+ * test/uri/*: translated RUNIT to Test::Unit.
-Wed Apr 29 21:05:44 1998 WATANABE Hirofumi <eban@os.rim.or.jp>
+Sun Oct 5 14:37:39 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * ruby.c (proc_options): option '-e' via tempfile.
+ * lib/xsd/datatypes.rb: Rational -> Decimal string bug fix.
-Tue Apr 28 15:27:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/soap/marshal/test_marshal.rb: ditto.
- * experimental release 1.1b9_16.
+ * test/soap/calc/test_calc_cgi.rb: add Config::CONFIG["EXEEXT"] to
+ RUBYBIN.
-Tue Apr 28 00:07:38 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Oct 5 13:47:22 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (obj_is_proc): type check predicate.
+ * test/ruby/test_beginendblock.rb, test/ruby/beginmainend.rb: add tests
+ about scope, order and allowed syntax.
- * eval.c (obj_is_block): ditto.
+Sun Oct 5 11:54:29 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Mon Apr 27 16:59:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/envutil.rb: added. split "rubybin" from test_system.rb.
- * ext/gtk/gtk.c (Init_gtk): use timeout, not idle to avoid
- consuming CPU too much.
+ * test/ruby/test_system.rb: use envutil.rb
- * lib/tk.rb: use tcltklib#_invoke instead of `_eval'.
+ * test/ruby/test_beginendblock.rb: added.
-Mon Apr 27 16:59:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/beginmainend.rb: added. used in test_beginendblock.rb.
- * array.c (ary_sort): use dup, not clone.
+Sun Oct 5 11:23:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Mon Apr 27 13:46:27 1998 Tadahiro Maebashi <maebashi@iij.ad.jp>
+ * test/testunit/runit/test_testresult.rb: removed some unnecessary
+ cruft.
- * ext/tcltklib/tcltklib.c (ip_invoke): invoke tcl command
- directly. need not worry about escaping tcl characters.
+Sun Oct 5 11:14:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Mon Apr 27 12:04:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rubyunit.rb: aliasing TestCase into the top level is
+ problematic.
- * random.c (f_rand): do not call srand() implicitly.
+ * lib/runit/assert.rb: fixed a couple of bugs caused by recent
+ refactoring in Test::Unit.
-Fri Apr 24 14:35:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/testunit/runit/*: added.
- * experimental release 1.1b9_15.
+Sun Oct 5 10:55:29 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * parse.y (assignable): dyna_var_asgn actually defines nested
- local variables in outer context.
+ * lib/open-uri.rb (URI::Generic#find_proxy): no_proxy support did not
+ work. [ruby-dev:21484]
- * random.c (f_rand): call srand(), if it has not called yet.
+Sun Oct 5 09:52:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * random.c (f_srand): use tv_usec as the default seed.
+ * lib/test/unit/assertions.rb: will use pp for output if available.
+ Can be disabled by setting Assertions.use_pp = false.
- * eval.c (rb_eval): values of nested local variables should be
- independent.
+ * test/testunit/test_assertions.rb: made a small change to exception
+ formatting.
- * eval.c (rb_yield_0): local variables wrong nested conditions.
+Sun Oct 5 07:42:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Wed Apr 22 23:27:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/assertions.rb: made small improvements to assertion
+ messages. Deprecated Assertions#assert_not_nil; use #assert instead.
- * io.c (select_get_io): get IO object by `to_io'.
+ * test/testunit/test_assertions.rb: ditto.
- * io.c (io_to_io): method to retrieve IO object, from delegating
- object for example.
+ * test/testunit/util/test_procwrapper.rb: use #assert instead of
+ #assert_not_nil.
-Wed Apr 22 16:52:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sun Oct 5 04:10:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * experimental release 1.1b9_14.
+ * lib/test/unit/assertions.rb: refactored message building.
- * string.c (str_modify): check for embedded pointer reference.
+Sun Oct 5 03:40:22 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * gc.c (obj_free): ditto.
+ * ext/openssl/ossl_asn1.h: global symbols should be declared
+ as external.
- * pack.c (pack_pack): p/P template to embed pointers.
+Sun Oct 5 03:03:20 2003 akira yamada <akira@ruby-lang.org>
-Wed Apr 22 00:07:10 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * test/ruby/test_exception.rb (test_else): added.
- * array.c (ary_rindex): embarrassing typo.
+Sun Oct 5 02:12:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Tue Apr 21 12:31:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/assertions.rb: changed assertion messages to rely more
+ heavily on #inspect. Added backtrace filtering for exceptions in
+ assertion messages.
- * experimental release 1.1b9_13.
+ * test/testunit/test_assertions.rb: ditto.
- * configure.in (RUBY_LIB): supports --program-{prefix,suffix}.
+Sun Oct 5 02:12:00 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
- * array.c (ary_rindex): new method.
+ * lib/drb/acl.rb, lib/drb/ssl.rb: added.
- * io.c (io_binmode): should return self.
+ * lib/drb/drb.rb: exit from a thread using 'break'.
-Tue Apr 21 08:23:04 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+Sat Oct 4 21:49:14 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * parse.y (here_document): calling parse_string with wrong
- arguments.
+ * gc.c (Init_stack): the type of space is changed to unsigned int
+ from double. [ruby-dev:21483]
- * struct.c (struct_aset): problem member assignment with name.
+Sat Oct 4 17:52:59 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Mon Apr 20 14:47:49 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/netHttpClient.rb: follow http-access2. hosts which matches
+ ENV['no_proxy'] or ENV['NO_PROXY'] are not proxyed.
+ - [,:] separated. ("ruby-lang.org:rubyist.net")
+ - no regexp. (give "ruby-lang.org", not "*.ruby-lang.org")
+ - if you want specify host by IP address, give full address.
+ ("192.168.1.1, 192.168.1.2")
- * experimental release 1.1b9_12.
+ * lib/soap/rpc/cgistub.rb: return "Status: XXX MMM" line.
- * time.c (time_arg): args may be string (support for reduced
- implicit type conversion).
+ * test/runner.rb: give testsuite name.
- * lib/base64.rb: changed to use pack/unpack with `m' template.
+Sat Oct 4 15:16:02 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Apr 20 06:23:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * marshal.c (w_object): instance variable dump do not cause error
+ for objects that cannot be dumped, if they traversed from
+ marshal_dump. they are just ignored.
- * variable.c (mod_remove_const): new method.
+ * gc.c (Init_stack): cast "space" (doble value) into unsigned
+ int. should run on PowerPC.
-Sat Apr 18 03:53:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_eval): should not execute else part if any exception
+ is caught. [ruby-dev:21482]
- * hash.c (hash_each_with_index): removed. use Enumerable's
- each_with_index instead.
+ * parse.y (f_args): should allow unparenthesized block argument.
- * class.c (rb_include_module): check for super modules, since
- module's included modules may be changed.
+ * parse.y (f_rest_arg): should allow unparenthesized rest
+ argument.
-Fri Apr 17 21:50:47 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Sat Oct 4 14:59:51 2003 Tanaka Akira <akr@m17n.org>
- * marshal.c (r_long): r_byte() may return signed byte.
+ * lib/pathname.rb (initialize): raise ArgumentError if argument has
+ '\0' character.
+ (relative_path_from): new method.
+ (each_entry): new method for replacement of dir_foreach.
+ (foreach, foreachline, dir_foreach, chdir): obsoleted.
-Fri Apr 17 11:58:30 1998 NAGAI Hidetoshi <nagai@dumbo.ai.kyutech.ac.jp>
+Sat Oct 4 12:58:48 2003 akira yamada <akira@ruby-lang.org>
- * ext/tcltklib/tcltklib.c (lib_mainloop): thread and interrupt check.
+ * test/uri/* (6 files): added.
-Fri Apr 17 11:06:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Oct 4 12:44:45 2003 akira yamada <akira@ruby-lang.org>
- * eval.c (find_file): try to fopen() to check whether file exists.
+ * lib/uri/ftp.rb, lib/uri/mailto.rb: renamed to #to_s from #to_str.
- * ruby.c (load_file): ditto.
+Sat Oct 4 07:33:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * struct.c (struct_aset): struct member can be set by member name.
+ * lib/test/unit/testsuite.rb: changed #<< to return self, and added
+ #delete.
-Fri Apr 17 00:47:19 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * test/testunit/test_testsuite.rb: ditto. Also slightly refactored
+ #test_size.
- * ext/extmk.rb.in: added m68k-human support
+ * lib/test/unit/collector/objectspace.rb: collector now preserves the
+ hierarchy of suites.
- * file.c (LOCK_SH): defines moved.
+ * test/testunit/collector/test_objectspace.rb: ditto.
- * array.c (ary_flatten_bang): simplified loop.
+Sat Oct 4 04:48:49 2003 why the lucky stiff <why@ruby-lang.org>
-Thu Apr 16 16:52:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/rubyext.c: default keys handled.
- * experimental release 1.1b9_11.
+ * ext/syck/syck.h: lowered default buffer size to 16k for increased
+ performance.
- * lib/tk.rb: thread support (experimental - maybe slow).
+ * test/yaml: checkin of basic unit tests.
- * eval.c (rb_longjmp): trace event on exception in raising
- context, just before raising exception.
+Sat Oct 4 04:24:19 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * struct.c (struct_s_members): forgot to check singletons.
+ * ext/openssl/extconf.rb: add check for X509V3_set_nconf.
- * struct.c (struct_aref): members can be accessed by names too.
+ * ext/openssl/ossl_x509ext.c (ossl_x509extfactory_set_config):
+ cannot implement if X509V3_set_nconf doesn't exist.
- * array.c (ary_flatten): new method.
+Sat Oct 4 02:12:44 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (rb_longjmp): prints exception information with `-d'.
+ * lib/xsd/datatypes.rb: dump sign by itself. under the problematic
+ platform, sprintf("%+.10g", -0.0) => +0. sigh.
- * object.c (any_to_s): remove class name restriction.
+ * sample/wsdl/amazon/*: update schema ver2 to ver3.
-Thu Apr 16 01:38:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Oct 4 01:33:46 2003 Tanaka Akira <akr@m17n.org>
- * file.c (thread_flock): do not block other threads.
+ * lib/pathname.rb (initialize): duplicate and freeze argument.
+ (to_s): return duplicated string.
+ (children): new method.
+ (each_line): new alias to foreachline.
- * eval.c (thread_trap_eval): signals are now delivered to the
- current thread again. In case that the current thread is dead,
- signals are forwarded to the main thread.
+Fri Oct 3 16:13:19 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * string.c (str_new4): need not to duplicate frozen strings.
+ * ext/openssl/ossl_asn1.c: add DER encoder and decoder.
-Wed Apr 15 08:33:47 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * ext/openssl/ossl_asn1.h: add OpenSSL::ASN1 module.
- * struct.c (struct_inspect): remove restriction for struct names.
+ * ext/openssl/ossl.c (Init_openssl): call Init_ossl_asn1.
-Wed Apr 15 02:55:02 1998 Kazuya 'Sharl' Masuda <sharl@www.ufo.co.jp>
+ * ext/openssl/extconf.rb: check if X509_ATTRIBUTE has field "single".
- * x68 patches to config.sub, ext/extmk.rb.in
+ * ext/openssl/ossl_x509attr.c (ossl_x509attr_set_value): accept
+ DER encoded data argument.
-Wed Apr 15 01:22:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_x509attr.c (ossl_x509attr_get_value): return
+ DER encoded data in OpenSSL::ASN1 types.
- * string.c (str_dup_frozen): do not duplicate frozen strings.
+Fri Oct 3 13:02:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * parse.y (yylex): allow nested parenthesises.
+ * lib/test/unit.rb: refactored to use optparse.
- * io.c (obj_displayln): prints newline after `display'ing the
- receiver.
+ * lib/test/unit.rb: added support for selecting the output
+ level from the command-line.
- * io.c (io_puts): avoid generating "\n" each time. use RS_default
- instead.
+ * lib/test/unit.rb: added a command-line switch to stop processing
+ the command-line, allowing arguments to be passed to tests.
- * io.c (f_p): ditto.
+ * lib/test/unit.rb: changed the method for specifying a runner or a
+ filter from the command-line.
-Tue Apr 14 22:18:17 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * lib/test/unit/collector/objectspace.rb: fixed a bug causing all
+ tests to be excluded when the filter was set to an empty array.
- * struct.c (struct_aref): should not subtract negative index.
+ * test/testunit/collector/test_objectspace.rb: ditto.
-Tue Apr 14 11:34:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Oct 3 08:14:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * experimental release 1.1b9_10.
+ * lib/irb/ruby-lex.rb (RubyLex::identify_identifier): support
+ 'class ::Foo' syntax. [ruby-talk:83514]
- * parse.y: token names prefixed by `t'.
+Fri Oct 3 08:01:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * struct.c (struct_s_def): supports subclassing of Struct.
+ * lib/test/unit/assertions.rb: added a default message for #assert,
+ #assert_block, and #flunk.
- * io.c (io_s_new): supports subclassing of IO.
+ * test/testunit/test_assertions.rb: ditto.
-Mon Apr 13 11:07:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/failure.rb: failures now show a better trace of where
+ they occurred.
- * eval.c (f_binding): need to restore method name.
+ * test/testunit/test_failure.rb: ditto (added).
- * eval.c (rb_call0): raises SystemStackError, not Fatal.
+ * lib/test/unit/testcase.rb: ditto.
- * io.c (obj_display): same as `print self'.
+ * test/testunit/test_testcase.rb: ditto.
- * io.c (f_p): can now be called in the method form.
+ * lib/test/unit/util/backtracefilter.rb: added.
- * re.c (reg_regsub): needed to be mbchar aware.
+ * test/testunit/util/test_backtracefilter.rb: added.
-Mon Apr 13 13:18:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/error.rb: changed to use BacktraceFilter and improved
+ output.
- * eval.c (thread_trap_eval): all signals delivered to main_thread.
+ * test/testunit/test_error.rb: ditto.
-Mon Apr 13 12:47:03 1998 TAKAHASHI Masayoshi <maki@inac.co.jp>
+Thu Oct 2 20:33:49 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (kcode_set_option): did not set SJIS on SJIS condition.
+ * ext/iconv/iconv.c (iconv_failure_initialize): conform with
+ orthodox initialization method.
-Sun Apr 12 22:14:07 1998 Kazunori NISHI <kazunori@swlab.csce.kyushu-u.ac.jp>
+ * ext/iconv/iconv.c (iconv_fail): initialize exception instance
+ from the class, and do not share instance variables with the
+ others. [ruby-dev:21470]
- * array.c (ary_uniq_bang): should be `==', not `='. embarrassing.
+Thu Oct 2 18:20:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Apr 11 02:13:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * time.c (Init_Time): define initialize. [ruby-dev:21469]
- * array.c (ary_subseq): SEGVed for `[][1,1]'.
+Thu Oct 2 17:39:38 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Apr 10 21:29:06 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * ext/openssl/ossl_engine.c: add a new module OpenSSL::Engine.
+ it supports OpenSSL hardware cryptographic engine interface.
- * array.c (ary_subseq): add check for beg larger than array length.
+ * ext/openssl/ossl_engine.h: ditto.
-Wed Apr 8 17:24:11 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+ * ext/openssl/MANIFEST: add ossl_engine.c and ossl_engine.h.
- * dir.c (dir_s_open): can be called with block (like IO#open).
+ * ext/openssl/extconf.rb: add check for openssl/engine.h.
- * dir.c (dir_s_chdir): print directory path on error.
+ * ext/openssl/ossl.c: call Init_ossl_engine().
- * dir.c (dir_s_chroot): ditto
+ * ext/openssl/ossl.h: include openssl/engine.h.
- * dir.c (Init_Dir): needed to override `new'.
+ * ext/openssl/ossl_pkey_{rsa,dsa,dh}.c: check if underlying
+ EVP_PKEY referes engine.
-Thu Apr 9 18:24:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 2 17:22:37 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * experimental release 1.1b9_09.
+ * time.c (time_load): restore instance variables (if any) before
+ loading from marshaled data.
- * string.c (str_cmp): do not depend on sentinel at the end of the
- strings.
+Thu Oct 2 14:19:15 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (str_chomp_bang): forgot to set the sentinel.
+ * ext/iconv/iconv.c (iconv_fail): now yield erred substring, and
+ set error object to $!.
-Wed Apr 8 00:59:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/iconv/iconv.c (iconv_convert): error handler block should
+ return appended part and the rest. if rest is nil, the
+ conversion stops.
- * bignum.c (big2int): converted int may be too big to fit in
- signed int.
+Thu Oct 2 12:00:18 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (arg): `foo += 1' should not cause an error.
+ * variable.c (rb_const_defined_0): look up constants in Object as
+ well. [ruby-dev:21458]
- * variable.c (rb_const_defined): returned false even if the
- constant is defined at the top level.
+ * test/ruby/test_defined.rb (TestDefined::test_defined): test for
+ constants.
- * eval.c (f_local_variables): dyna_var->id may be null. should
- have checked before calling str_new2().
+Thu Oct 2 11:17:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Tue Apr 7 01:15:15 1998 Kaneko Naoshi <wbs01621@mail.wbs.or.jp>
+ * lib/test/unit/assertions.rb: should not capture an
+ AssertionFailedError unless explicitly requested.
- * re.c (reg_regsub): need to check string boundary.
+ * test/testunit/test_assertions.rb: ditto.
-Tue Apr 7 19:19:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/testunit/collector/test_objectspace.rb: fixed a test failure
+ caused by methods being returned in different orders on different
+ platforms by moving test sorting from TestSuite into the locations
+ where suites are constructed. [ruby-talk:83156]
- * string.c (str_cmp): returns either 1, 0, -1.
+ * lib/test/unit/testcase.rb: ditto.
- * array.c (ary_cmp): should check array length, too
+ * lib/test/unit/testsuite.rb: ditto.
-Tue Apr 7 18:50:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/collector/objectspace.rb: ditto.
- * experimental release 1.1b9_08.
+Thu Oct 2 03:25:01 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Tue Apr 7 18:31:27 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * eval.c (rb_thread_raise): prototype; avoid VC++ warning.
- * instruby.rb (mandir): dll installation for cygwin32
+Thu Oct 2 01:37:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Apr 7 01:16:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * time.c (time_mdump): new marshal dumper. _dump is still
+ available for compatibility.
- * config.sub (maybe_os): TOWNS support?
+ * time.c (time_mload): new marshal loader.
- * config.guess: too strict check for libc versions on linuxes.
+ * marshal.c (w_object): preserve instance variables for objects
+ with marshal_dump.
- * experimental release 1.1b9_07.
+ * marshal.c (r_object0): restore instance variables before calling
+ marshal_load.
- * array.c (ary_cmp): compare each element using `<=>'.
+ * error.c (rb_warn_m): always return nil.
- * hash.c (hash_each_with_index): yields [value, key] pair.
+Thu Oct 2 01:32:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * class.c (class_protected_instance_methods): list protected
- method names.
+ * eval.c (rb_f_block_given_p): real required condition is
+ ruby_frame->prev->iter == ITER_CUR.
- * class.c (ins_methods_i): exclude protected methods.
+ * eval.c (rb_block_given_p): ditto.
- * eval.c (PUSH_BLOCK): dynamic variables can be accessed from
- eval() with bindings.
+ * eval.c (block_pass): update ruby_frame->iter only when previous
+ value is ITER_NOT.
-Mon Apr 6 14:49:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Oct 2 01:02:35 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (thread_yield): must return evaluated value.
+ * variable.c (rb_const_defined_at): should exclude constants from
+ Object when TYPE(klass) == T_MODULE *and* exclude is on.
+ [ruby-dev:21458]
-Fri Apr 3 13:07:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * variable.c (rb_const_get_0): do not lookup constants from Object
+ when TYPE(klass) == T_MODULE *and* exclude is on.
- * eval.c (thread_schedule): context switch bypassed on wrong
- conditions.
+Thu Oct 2 00:21:11 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * variable.c (rb_name_class): set classname by id before String
- class is initialized (1.0 behavior restored).
+ * test/logger/test_logger.rb: unlinking file before close causes
+ problem under win32 box.
-Fri Apr 3 11:25:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/xsd/datatypes.rb(XSDFloat, XSDDouble): add +/- sign explicitly
+ when stringified and embedded into XML instance. Ruby's sprintf may
+ format -0.0 as "0.0" (no minus sign) depending on underlying C
+ sprintf implementation.
- * numeric.c (num2int): no implicit conversion from string.
+ * test/xsd/test_xsd.rb, test/soap/test_basetype.rb: follow above change.
- * numeric.c (num2int): check whether `to_i' returns an Integer.
+ * test/soap/calc/*: give httpd config param "CGIInterpreter".
+ "/usr/bin/env ruby" thing does not work under non-Unix boxes.
- * numeric.c (num_zero_p): new method.
+Sat Oct 2 00:42:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
- * numeric.c (num_nonzero_p): new method. returns the receiver if
- it's not zero.
+ * marshal.c (r_byte): retrieve pointer from string value for each
+ time. [ruby-dev:24404]
- * eval.c (obj_instance_eval): the_class should be the object's
- singleton class.
+ * marshal.c (r_bytes0): ditto.
- * error.c (exc_s_new): message is converted into a string.
+ * enum.c (sort_by_i): re-entrance check added. [ruby-dev:24399]
-Thu Apr 2 18:31:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * io.c (io_read): should freeze all reading buffer.
+ [ruby-dev:24400]
- * eval.c (obj_call_init): every object call `initialize'.
+ * string.c (rb_str_sum): should use bignums when bits is greater
+ than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395]
-Wed Apr 1 08:51:53 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * eval.c (specific_eval): defer pointer retrieval to prevent
+ unsafe sourcefile string modification. [ruby-dev:24382]
- * parse.y (stmt): UNTIL_MOD should be for stmt, not only for expr.
+ * string.c (rb_str_sum): wrong cast caused wrong result.
+ [ruby-dev:24385]
-Wed Apr 1 01:20:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * enum.c (enum_sort_by): hide temporary array from
+ ObjectSpace.each_object. [ruby-dev:24386]
- * object.c (true_and): boolean operators &, | and ^.
+ * string.c (rb_str_sum): check was done with false pointer.
+ [ruby-dev:24383]
-Tue Mar 31 13:23:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (rb_str_sum): string may be altered. [ruby-dev:24381]
- * array.c (ary_compact_bang): returns nil, if it does not modify
- the array like String's bang methods.
+Thu Oct 2 00:25:21 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (ary_uniq_bang): new method to remove duplicate items.
+ * signal.c (ruby_signal_name): adjust to the prototype.
- * eval.c (bind_s_new): new method.
+ * process.c (pst_inspect): ditto.
- * numeric.c (num2int): raise exception if Fixnums too big to
- convert into `int' in case that sizeof(int) < sizeof(INT).
+ * ext/etc/etc.c (etc_getgrent, Init_etc): typo.
- * string.c (str_center): SEGV on negative width.
+Wed Oct 1 20:49:41 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (eval): forgot to set sourcefile.
+ * gc.c (heaps): manage slots and limits together. [ruby-dev:21453]
-Mon Mar 30 11:12:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * gc.c (add_heap): should not clear heaps slot even if realloc()
+ failed.
- * file.c (f_test): raises exception for unknown command.
+Wed Oct 1 20:36:49 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (Init_eval): `class_eval': alias to the module_eval.
+ * MANIFEST: add wince/mkconfig_wce.rb.
-Mon Mar 30 18:50:42 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+Wed Oct 1 17:22:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_capitalize_bang): did not check string modification.
+ * ext/etc/etc.c: add new functions: setpwent, getpwent, endpwent,
+ setgrent, getgrent, endgrent.
- * string.c (str_delete_bang): wrong conversion.
+ * ext/socket/socket.c (sock_s_gethostbyname): do not reverse lookup.
- * string.c (str_intern): typo in error message.
+Wed Oct 1 17:01:30 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Mar 30 01:44:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_load): Object scope had priority over required file
+ scope. [ruby-dev:21415]
- * eval.c (obj_instance_eval): accepts block as evaluation body.
- No compilation needed each time.
+Wed Oct 01 14:09:53 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
- * eval.c (mod_module_eval): ditto
+ * wince/mkconfig_wce.rb: sorry, forget to commit.
- * file.c (file_s_umask): umask did not return old values, if no
- argument given.
+Wed Oct 01 10:08:42 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
-Sun Mar 29 00:54:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * wince/setup.mak: add sigmarionIII SDK support.
- * eval.c (f_throw): nil returned always.
+ * wince/Makefile.sub: ditto.
-Sat Mar 28 20:40:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * wince/mkexports.rb: fix linker error in SH4.
- * experimental release 1.1b9_06.
+ * wince/mkconfig_wce.rb: camouflage RUBY_PLATFORM for compiling ext.
-Sat Mar 28 16:07:11 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Wed Oct 01 08:02:52 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
- * io.c (io_closed): should not cause exception for closed IO.
+ * wince/time_wce.c (time): add zero check.
- * string.c (str_tr): returned nil for success.
+Tue Sep 30 16:11:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Sat Mar 28 00:47:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * Makefile.in: copy lex.c from $(srcdir) if it's not the current
+ directory. [ruby-dev:21437]
- * eval.c (f_local_variables): new method to return an array of
- local variable names.
+Tue Sep 30 11:29:23 2003 Tanaka Akira <akr@m17n.org>
- * variable.c (obj_instance_variables): now returns an array of
- variable names, as described in the reference.
+ * process.c (pst_inspect): describe stopped process "stopped".
- * eval.c (rb_attr): honors default method visibility of the
- current scope.
+Tue Sep 30 09:31:56 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Mar 27 13:49:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/runner.rb: glob for directories.
- * experimental release 1.1b9_05.
+Tue Sep 30 09:11:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ruby.c (ruby_prog_init): `site_ruby' added to load_path.
+ * eval.c (rb_eval): while/until should not capture break unless
+ they are destination of the break.
- * ruby.c (ruby_prog_init): load-path order changed. Paths in
- the RUBYLIB environment variable comes first in non-tainted
- mode.
+Tue Sep 30 03:12:02 2003 Minero Aoki <aamine@loveruby.net>
-Thu Mar 26 11:51:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/net/http.rb (finish): revert to 1.93.
- * eval.c (rb_call): new feature: `protected' methods.
+ * lib/net/pop.rb (finish): revert to 1.60.
- * string.c (str_dump): new method.
+ * lib/net/smtp.rb (finish): revert to 1.67.
- * eval.c (block_pass): block argument can be nil, which means no
- block is supplied for the method.
+ * lib/net/http.rb (do_start): ensure to close socket if failed to
+ start session.
-Wed Mar 25 21:20:13 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * lib/net/pop.rb (do_start): ditto.
- * string.c (str_reverse_bang): string copied to wrong place.
+ * lib/net/smtp.rb (do_start): ditto.
-Wed Mar 25 08:12:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/net/smtp.rb: SMTP#started? wrongly returned false always.
- * numeric.c (flo_modulo): caused SEGV if left operand is not a
- float value.
+Tue Sep 30 02:54:49 2003 Minero Aoki <aamine@loveruby.net>
- * eval.c (f_eval): optional third and fourth argument to specify
- file-name and line-number.
+ * test/ruby/test_iterator.rb: new test
+ test_break__nested_loop[123].
- * eval.c (eval): file-name and line-number set properly.
+Mon Sep 29 23:39:13 2003 Minero Aoki <aamine@loveruby.net>
- * parse.y (assign_in_cond): literal assignment is now warning, not
- compile error.
+ * lib/net/http.rb (finish): does not raise IOError even if
+ !started?, to allow closing socket which was opened before
+ session started.
- * error.c (Warn): Warn() always print message, OTOH Waring()
- prints when verbose flag is set.
+ * lib/net/pop.rb (finish): ditto.
-Tue Mar 24 12:50:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/net/smtp.rb (finish): ditto.
- * ruby.c (ruby_prog_init): `.' should come last in the load-path.
+Mon Sep 29 19:06:51 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (Init_eval): `__send__', alias for `send'.
+ * ext/win32ole/extconf.rb: add windows.h checking.
+ (ruby-bugs:PR#1185)
-Mon Mar 23 12:44:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Sep 29 16:18:30 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * string.c (str_chomp_bang): now takes `rs' as an argument.
+ * lib/logger.rb: check if the given logdevice object respond_to :write
+ and :close, not is_a? IO. duck duck.
- * eval.c (thread_free): main_thread should not be freed.
+ * test/logger/test_logger.rb: self IO.pipe reading/writing may be
+ locked by the flood. use tempfile.
-Fri Mar 20 16:40:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/wsdl/xmlSchema/data.rb: wrong constant reference.
- * string.c (str_chomp_bang): chomp! (and other ! methods) returns
- nil if it does not modify the string.
+Mon Sep 29 16:11:23 2003 Minero Aoki <aamine@loveruby.net>
- * string.c (str_sub_iter_s): should check last pattern since it
- may be matched to null.
+ * test/fileutils/test_fileutils.rb: clean up temporary symlink.
+ Patched by NaHi. [ruby-dev:21420]
-Thu Mar 19 13:48:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Sep 29 11:16:55 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * experimental release 1.1b9_04.
+ * eval.c (rb_thread_atfork): wrong format specifier.
+ [ruby-dev:21428]
- * parse.y (yylex): `10e0.9' should cause syntax error.
+ * process.c (pst_inspect): better description.
-Wed Mar 18 17:46:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Mon Sep 29 02:31:44 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * ruby.c (load_file): new file object constant DATA. Only
- available for the script from the file.
+ * lib/webrick/utils.rb (Utils::su): use setgid and setuid to
+ set real and effective IDs. and setup group access list by
+ initgroups.
- * regex.c (re_match): forwarding failure point popped too much.
+Sun Sep 28 11:14:19 2003 Koji Arai <jca02266@nifty.ne.jp>
-Tue Mar 17 18:23:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/digest/digest.c (Init_digest): `copy_object' was deprecated.
+ `initialize_copy' should be defined.
- * math.c (math_frexp): newly added.
+ * ext/stringio/stringio.c (Init_stringio): ditto.
- * math.c (math_ldexp): ditto.
+Sat Sep 27 18:25:13 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * bignum.c (bigdivmod): calculates modulo.
+ * lib/xsd/charset.rb: XSD::Charset.is_ces did return always true under
+ $KCODE = "NONE" environment. check added.
- * numeric.c (fix_remainder): returns reminder, formerly introduced
- as modulo.
+ * test/xsd/test_xsd.rb: add tests for above fix.
- * numeric.c (fix_modulo): calculates proper `modulo'.
+Sat Sep 27 15:58:50 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * bignum.c (bigdivmod): wrong sign for reminder.
+ * lib/soap/rpc/cgistub.rb: make logging severity threshold higher.
-Mon Mar 16 17:07:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/soap/rpc/standaloneServer.rb: defer WEBrick server start to give
+ a chance to reset logging severity threshold.
- * experimental release 1.1b9_03.
+ * test/soap/calc/test_*, test/soap/helloworld/test_helloworld.rb: run
+ silent.
-Mon Mar 16 16:33:53 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Sat Sep 27 09:44:18 2003 Minero Aoki <aamine@loveruby.net>
- * io.c (pipe_finalize): needed to add pipe_finalize to pipes on
- cygwin32.
+ * test/fileutils/test_fileutils.rb: clear all errors on Windows.
+ [ruby-dev:21417]
-Mon Mar 16 14:11:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/fileutils/test_nowrite.rb: ditto.
- * class.c (ins_methods_i): needed to consider NOEX_UNDEF.
+Mon Sep 27 09:14:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Mar 16 13:23:53 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * array.c (rb_ary_delete): comparison may change the capacity.
+ [ruby-dev:24348]
- * io.c (io_check_closed): check for `fptr->f2 == NULL'.
+ * array.c (rb_ary_fill): fill should honor length argument.
+ [ruby-dev:24346]
- * io.c (io_fptr_close): ditto.
+ * array.c (rb_ary_replace): should not use ptr from shared array.
+ [ruby-dev:24345]
-Mon Mar 16 11:49:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/socket.c (s_accept): don't retry for EWOULDBLOCK.
+ [ruby-talk:113807]
- * io.c (pipe_atexit): free()ing referencing pipe_list.
+Sat Sep 27 04:57:07 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * range.c (range_length): returns zero, if the first is greater
- than the last.
+ * test/ruby/test_file.rb: new file. only asserts unlink-before-close
+ behaviour now.
- * signal.c (trap_restore_mask): restore signal mask before raising
- exceptions and throws.
+ * test/soap/marshal/test_digraph.rb: should close before unlink.
+ unlink-before-close pattern is not needed here.
-Fri Mar 13 13:49:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Sep 27 03:32:37 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * experimental release 1.1b9_02.
+ * test/soap/*, test/wsdl/*, test/xsd/*: move TestCase classes into
+ each module namespace. TestMarshal in
+ test/soap/marshal/test_marshal.rb crashed with
+ test/ruby/test_marshal.rb.
- * object.c (mod_clone): need to dups constants and instance
- variables.
+Sat Sep 27 01:30:59 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (rb_eval): forgot to initialize body for NODE_DEFS.
+ * ext/socket/socket.c (ruby_connect): on win32, type of the 4th
+ argument of getsockopt is char *.
- * eval.c (rb_eval): retrieve self from calling frame, since self
- changes sometimes.
+Fri Sep 26 18:35:40 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * env.h (FRAME): need to save self in the calling frame.
+ * lib/resolv-replace.rb: 1.8 compliance. [ruby-talk:82946]
- * io.c (f_gets_method): rs should be initialized by RS.
+Fri Sep 26 17:39:27 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Thu Mar 12 15:33:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/test_marshal.rb: add test for ruby's objects.
- * experimental release 1.1b9_01.
+Fri Sep 26 09:52:44 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * range.c (range_s_new): check values by `first <= last'.
+ * defines.h (flush_register_windows): use volatile only for gcc on
+ Solaris. [ruby-dev:21403]
- * parse.y (lastline_set): fixed offset for $_ and $~ in the local
- variable space.
+ * lib/mkmf.rb (xsystem): use system directly to honor shell meta
+ charaters.
-Wed Mar 11 02:14:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Sep 26 00:10:13 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * io.c (io_gets): handle normal case specially for speed.
+ * lib/README: updated.
- * eval.c (rb_disable_super): function to disable superclass's
- method explicitly.
+Thu Sep 25 17:48:10 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * eval.c (rb_eval): inherits previous method definition's
- NOEX_UNDEF-ness, if exists.
+ * ext/openssl/ossl.c (ossl_buf2str): fix type of 1st argument for
+ rb_protect.
- * class.c (rb_define_method): disables superclass's overriding
- method by default.
+ * ext/openssl/ossl_hmac.c (ossl_hmac_digest): should return meaningful
+ value.
-Wed Mar 11 01:40:48 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+Thu Sep 25 09:00:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * numeric.c (flo_gt,etc.): do not depend on `<=>', to handle NaN.
+ * lib/ostruct.rb: Added OpenStruct#==.
-Tue Mar 10 00:03:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ostruct/test_ostruct.rb: Added.
- * ruby.c (load_file): understands multiple options in #! line.
+Thu Sep 25 07:55:26 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_compile_pattern): support for [:alpha:] etc.
+ * ext/win32ole/win32ole.c, ext/openssl/ossl_pkey_dsa.c,
+ ext/openssl/ossl_pkey_rsa.c, ext/bigdecimal/bigdecimal.h: must
+ not use C++ or C99 style comment yet. (ruby-bugs:PR#1184)
-Mon Mar 9 16:53:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Sep 25 00:23:22 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * io.h (GetOpenFile): embed io_check_closed in GetOpenFile.
+ * MANIFEST: add SOAP4R.
- * sprintf.c (f_sprintf): zero padding failed for negative
- integers.
+Thu Sep 25 00:13:15 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * sprintf.c (remove_sign_bits): failed to remove some bits.
+ * lib/soap/* (29 files): SOAP4R added.
-Sat Mar 7 21:51:46 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+ * lib/wsdl/* (42 files): WSDL4R added.
- * class.c (ins_methods_i): body may be NULL for some case.
+ * lib/xsd/* (12 files): XSD4R added.
-Fri Mar 6 17:23:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/soap/* (16 files): added.
- * regex.c (mbcinit): table driven mbchar detection.
+ * test/wsdl/* (2 files): added.
- * object.c (obj_alloc): check for allocating instance for the
- primitive classes (mostly perfect).
+ * test/xsd/* (3 files): added.
- * ext/curses/curses.c (curses_finalize): restore original state at
- interpreter termination.
+ * sample/soap/* (27 files): added.
- * ext/curses/curses.c (curses_addstr): forgot to check argument
- type (caused SEGV). now uses STR2CSTR() macro.
+ * sample/wsdl/* (13 files): added.
-Thu Mar 5 13:47:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Sep 24 02:08:11 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (block_pass): accepts method object as block args.
+ * lib/webrick/httpservlet/cgihandler.rb: conform to mswin32.
+ [ruby-talk:82735], [ruby-talk:82748], [ruby-talk:82818]
- * eval.c (f_missing): use any_to_s() for stringify.
+Tue Sep 23 23:10:16 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Wed Mar 4 01:39:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/logger.rb: add Logger#<<(msg) for writing msg without any
+ formatting.
- * parse.y (block_arg): new syntax - block argument in the
- calling arglist.
+ * test/logger/test_logger.rb: ditto.
- * eval.c (rb_call): no module search. simplified a lot.
+Tue Sep 23 20:47:51 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_eval): block arg support.
+ * error.c (rb_warn_m): should not warn if -W0 is specified.
+ [ruby-talk:82675]
- * parse.y (f_block_arg): new syntax - block argument in the
- formal arglist.
+Mon Sep 22 21:28:57 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Tue Mar 3 14:20:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * MANIFEST: updated.
- * eval.c (obj_method): returns bound method object.
+Mon Sep 22 19:22:26 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (rb_call): argument check for empty methods.
+ * configure.in (AC_CHECK_FUNCS): add setuid and setgid.
- * ruby.h (NUM2CHR): new macro, originally from curses module.
+Mon Sep 22 12:34:55 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Mar 3 13:03:35 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+ * util.c (ruby_strtod): skip preceding zeros before counting
+ digits in the mantissa. (ruby-bugs:PR#1181)
- * io.c (io_putc): new method.
+Sun Sep 21 04:12:36 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Tue Mar 3 11:21:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_ocsp.c (ossl_ocspreq_initialize): the argument
+ should be a String.
- * string.c (str_inspect): more strict charcode detection.
+ * ext/openssl/ossl_ocsp.c (ossl_ocspres_initialize): ditt.
- * eval.c (thread_stop): stopping only thread raises ThreadError
- exception.
+ * ext/openssl/ossl_x509attr.c (ossl_x509attr_initialize): ditto.
-Tue Mar 3 08:04:56 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+ * ext/openssl/ossl_x509ext.c (ossl_x509ext_initialize): ditto.
- * struct.c (struct_alloc): incomplete struct initialization made
- GC to access unallocated addresses.
+ * ext/openssl/ossl_x509ext.c (ossl_x509ext_set_value): ditto.
-Mon Mar 2 16:28:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Sep 20 11:49:05 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (thread_stop_method): remove Thread#stop.
+ * lib/logger.rb: typo fixed.
-Fri Feb 27 18:16:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/logger/test_logger.rb: new file.
- * version 1.1b9 released.
+Fri Sep 19 11:39:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
-Fri Feb 27 09:36:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/testunit/*: Added.
- * hash.c (hash_delete_nil): needed to compare value to nil, since
- nil is the valid key for hashes.
+ * lib/test/unit.rb: Documentation update.
- * hash.c (hash_foreach_iter): rehashing causes IndexError.
+ * lib/test/unit/ui/console/testrunner.rb (TestRunner#initialize):
+ Ditto.
- * hash.c (hash_foreach_iter): rehash check by pointer comparison.
+ * lib/test/unit.rb: Factored out an ObjectSpace collector.
-Thu Feb 26 17:22:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/test/unit/collector/objectspace.rb: Ditto.
- * parse.y (fname): convert reswords into symbols.
+ * sample/testunit/*: Added.
- * parse.y (reswords): reserved words are now embedded in the
- syntax (sigh).
+Fri Sep 19 01:00:48 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * parse.y: now reserved words can be method names safely.
+ * lib/webrick/log.rb (BasicLog#log): get rid of as ineffectual
+ condition.
-Wed Feb 25 15:50:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/webrick/log.rb (BasicLog#format): add "\n" to message.
- * eval.c (mod_module_eval): clear the_scope's PRIVATE flag before
- calling eval().
+Thu Sep 18 22:43:20 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * gc.c (gc_call_finalizer_at_exit): run finalizers before any data
- object being freed.
+ * eval.c (proc_invoke): should push PROT_PCALL tag for orphans.
- * eval.c (rb_eval): needed to keep prot_tag->retval before
- evaluating the ensure clause.
+ * eval.c (proc_invoke): should update "result" for orphans.
-Tue Feb 24 11:16:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Sep 18 20:33:03 2003 Tietew <tietew-ml-ruby-list@tietew.net>
- * parse.y (yylex): reserved words can be appear as method names at
- right after 'def' and `.'(dot), like foo.next.
+ * parse.y (str_xquote): do not prepend escapes in
+ backqoute literals. [ruby-list:38409]
- * eval.c (return_check): checks for return out of thread (formerly
- done in return_value).
+Thu Sep 18 20:30:17 2003 Tanaka Akira <akr@m17n.org>
- * eval.c (POP_TAG): copy retval to outer level.
+ * lib/pathname.rb: update document.
- * eval.c (return_value): just set retval, no check, no unwinding.
+Thu Sep 18 15:27:05 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * parse.y (nextc): line continuation by backslash at end of line.
+ * lib/logger.rb: new file. Logger, formerly called devel-logger or
+ Devel::Logger.
- * regex.c (re_compile_pattern): forgot to clear pending_exact on
- closing parentheses.
+ * sample/logger/*: new file. samples of logger.rb.
- * parse.y (assignable): should not assign dyna_var to true, if it
- is already defined.
+Wed Sep 17 23:41:45 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Feb 23 14:35:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (localjump_destination): should not raise ThreadError
+ exception for "break". [ruby-dev:21348]
- * object.c (obj_is_kind_of): no longer accepts true/false/nil.
+ * eval.c (proc_invoke): use result instead of prot_tag->retval.
+ retval is no longer propagated to the ancestors.
- * object.c ({true,false,nil}_to_i): can be converted into integers.
+Wed Sep 17 20:34:00 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Feb 23 12:11:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * parse.y (tokadd_string, parse_string, yylex): escaped terminator
+ is now interpreted as is. [ruby-talk:82206]
- * re.c (reg_s_quote): needed to be mbchar aware.
+Wed Sep 17 18:52:36 2003 Minero Aoki <aamine@loveruby.net>
- * eval.c (proc_s_new): wrong iter mark.
+ * test/fileutils/fileassertions.rb: new file.
-Sat Feb 21 22:59:30 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+ * test/fileutils/test_fileutils.rb: new file.
- * io.c (f_syscall): no argument check.
+ * test/fileutils/test_nowrite.rb: new file.
-Fri Feb 20 10:17:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Sep 17 18:51:02 2003 Minero Aoki <aamine@loveruby.net>
- * version 1.1b8 released.
+ * test/strscan/test_stringscanner.rb: require test/unit.
- * ext/kconv/kconv.c (kconv_kconv): default output code now be
- determined according to the value of $KCODE.
+Wed Sep 17 18:35:34 2003 Minero Aoki <aamine@loveruby.net>
- * re.c (rb_get_kcode): can retrieve $KCODE from C code.
+ * test/strscan/test_stringscanner.rb: new file.
- * parse.y (stmt): if/unless modifiers returns nil, if condition is
- not established.
+Wed Sep 17 18:03:30 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Thu Feb 19 11:06:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl: all files are reviewed to simplify and avoid memory leak.
- * ext/kconv/kconv.c (kconv_kconv): charcode can be specified by
- code name (JIS, SJIS, EUC like value of $KCODE).
+ * ext/openssl/extconf.rb: add check for assert.h.
- * regex.c (re_compile_pattern): forgot to fixup_jump for (?:..).
+ * ext/openssl/ossl.c (ossl_buf2str): new function to convert
+ C buffer to String and free buffer.
- * regex.c (re_compile_pattern): needed to clear pending_exact on
- non-registering grouping (?:...).
+ * ext/openssl/ossl.c (ossl_x509_ary2sk): new function to convert
+ Array of OpenSSL::X509 to STACK_OF(X509) with exception safe.
-Wed Feb 18 19:54:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl.c (ossl_to_der, ossl_to_der_if_possible): new
+ functions to convert object to DER string.
- * parse.y (here_document): needed to set lex_state to EXPR_END.
+ * ext/openssl/ossl.h: ditto.
-Wed Feb 18 18:45:10 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/openssl/ossl_bio.c (ossl_membio2str): new function to convert
+ BIO to String object and free BIO.
- * patches for cygwin32 applied.
+ * ext/openssl/ossl_bio.h: ditto.
-Wed Feb 18 00:41:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_pkcs7.c (ossl_pkcs7_to_der): add for "to_der".
- * string.c (str_sub_s): needed to be mbchar aware to increment one
- character.
+ * ext/openssl/ossl_x509name.c (ossl_x509name_to_der): ditto.
- * regex.c (re_match): \Z matches newline just before the end of
- the string.
+ * ext/openssl/ossl_x509ext.c (ossl_x509ext_to_der): ditto.
-Tue Feb 17 00:04:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_x509ext.c (create_ext_from_array): removed
+ and reimplement in openssl/x509.rb.
- * time.c (time_arg): Time.gm and Time.local now understands
- Time#to_a format.
+ * ext/openssl/ossl_x509attr.c: reimplemented and disable some
+ method temporarily. this class doesn't work fine without ASN.1
+ data support;-) I'll rewrite in near future.
- * string.c (str_sub_s): replace happened twice for null pattern.
+ * ext/openssl/lib/openssl/x509.c (X509::Attribute): get rid off
+ unused code.
- * regex.c (re_search): null pattern should not match after newline
- at the end of string.
+ * ext/openssl/lib/openssl/x509.c (X509::ExtensionFactory): refine all.
- * time.c (time_isdst): now returns boolean value.
+Tue Sep 16 22:25:06 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * error.c (rb_check_type): treat special constants in messages.
+ * test/csv/test_csv.rb: add negative tests of row_sep.
- * parse.y (yylex): new form `::Const' to see toplevel constants.
+Tue Sep 16 18:02:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (cond): SEGV on `if ()'.
+ * regex.c (re_compile_pattern): should not translate character
+ class range edge. [ruby-list:38393]
- * gc.c (obj_free): some data needed explicit free().
+Tue Sep 16 16:47:56 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Mon Feb 16 23:55:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * MANIFEST: add test/csv/mac.csv.
- * eval.c (blk_free): release duplicated block informations.
+ * win32/Makefile.sub, bcc32/Makefile.sub (test): add phony NUL target.
- * eval.c (blk_copy_prev): duplicate outer block information into
- the heap, when proc/binding created.
+Mon Sep 15 19:02:52 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Mon Feb 16 14:38:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/csv.rb: add extra pamameter to specify row(record) separater
+ character. To parse Mac's CR separated CSV, do like this.
+ CSV.open("mac.csv", "r", ?,, ?\r) { |row| p row.to_a }
+ The 3rd parameter in this example ?, is for column separater and the
+ 4th ?\r is for row separater. Row separater is nil by default. Nil
+ separater means "\r\n" or "\n".
- * time.c (time_mon): now 1 for January and so on.
+ * test/csv/test_csv.rb: add tests for above feature.
- * time.c (time_year): year in 19xx (no + 1900 needed anymore).
+ * test/csv/mac.csv: added. Sample CR separated CSV file.
-Mon Feb 16 13:28:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Sep 12 22:41:48 2003 Michal Rokos <m.rokos@sh.cvut.cz>
- * regex.c (re_compile_pattern): need to fetch mbchar's second byte
- without translation.
+ * ext/openssl/ossl.c: move ASN.1 stuff to ossl_asn1.[ch]
-Mon Feb 16 12:29:27 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+ * ext/openssl/ossl.c: move BIO stuff to ossl_bio.[ch]
- * eval.c (f_pass_block): pass iterator block to other method.
+ * ext/openssl/ossl_asn1.[ch]: new files
-Fri Feb 13 08:16:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_bio.[ch]: new files
- * parse.y (parse_regx): handle \s before read_escape().
+Fri Sep 12 12:30:41 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (read_escape): `\s' in strings as space.
+ * intern.h (rb_disable_super, rb_enable_super): replace with dummy
+ expressions instead of prototypes. the functions remain yet for
+ binary compatibility. [ruby-talk:81758]
-Tue Feb 10 17:29:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Sep 12 12:09:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * version 1.1b7 released.
+ * bignum.c (rb_big_and): convert argument using 'to_int'.
- * string.c (str_aset): string insertion by `str[n] = str2'.
+ * bignum.c (rb_big_or): ditto.
- * string.c (str_oct): does recognize `0x'.
+ * bignum.c (rb_big_xor): ditto.
- * sprintf.c (f_sprintf): use base 10 for conversion from string to
- integer.
+Fri Sep 12 07:06:14 2003 David Black <dblack@superlink.net>
-Mon Feb 9 14:51:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/scanf.rb: Took out useless @matched_item variable; some small
+ refactoring.
- * numeric.c (do_coerce): proper error message.
+Thu Sep 11 08:43:44 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_sum): bug - masked by wrong value. (sigh..)
+ * eval.c (rb_f_require): allow "require" on $SAFE>0, if feature
+ name is not tainted.
-Sat Feb 7 15:11:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/rexml/parsers/baseparser.rb (REXML::Parsers::BaseParser::stream):
+ Supports StringIO.
- * string.c (str_empty): new method
+Wed Sep 10 22:47:30 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Fri Feb 6 01:42:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl.h: add a workaround for win32 platform.
+ libeay32.dll doesn't export functions defined in conf_api.h.
- * time.c (time_asctime): use asctime(3), not strftime(3).
+ * ext/openssl/ossl_config.c (ossl_config_initialize): ditto.
-Thu Feb 5 18:58:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_config.c (ossl_config_add_value): ditto.
- * io.c (io_fptr_close): do not free path on close().
+ * ext/openssl/ossl_config.c (set_conf_section_i): should check
+ if the argument is Array.
- * array.c (ary_filter): new method.
+Wed Sep 10 22:41:54 2003 Tietew <tietew@tietew.net>
- * enum.c (enum_each_with_index): new method.
+ * eval.c (win32_get_exception_list): avoid VC7 warning.
+ [ruby-win32:577]
-Thu Feb 5 14:10:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Sep 9 10:39:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (primary): singleton class def can be appeared inside
- method bodies.
+ * eval.c (struct tag): dst should be VALUE.
- * hash.c (hash_replace): replace content.
+Tue Sep 9 10:39:51 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * string.c (str_replace_method): replace content.
+ * eval.c (localjump_destination): stop at the scope where the current
+ block was created. [ruby-dev:21353]
- * array.c (ary_replace_method): replace elements.
+Tue Sep 9 05:17:04 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * string.c (str_succ_bang): String#succ!
+ * ext/openssl/ossl_config.rb: avoid compile error in OpenSSL-0.9.6.
-Thu Feb 5 18:20:30 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Tue Sep 9 02:41:35 2003 Michal Rokos <m.rokos@sh.cvut.cz>
- * string.c (str_upcase_bang): multi byte character support.
+ * ext/openssl/ossl_config.c: Refine compatibility.
-Wed Feb 4 13:55:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Sep 9 01:50:45 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * array.c (ary_reverse): SEGV on empty array reverse.
+ * lib/webrick/httpserver.rb (HTTPServer#access_log): add "\n" to
+ the message.
-Tue Feb 3 12:24:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/webrick/log.rb (BasicLog#log): add "\n" only if needed.
- * re.c (match_to_a): non matching element should be nil.
+Mon Sep 8 22:15:33 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ruby.c (ruby_load_script): load script after all initialization.
+ * ext/tk/lib/multi-tk.rb: modify security check at creating
+ a new interpreter
- * bignum.c (str2inum): need to interpret prefix `0' of `0x'.
+Mon Sep 8 20:00:12 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Feb 3 10:00:18 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * lib/optparse.rb, lib/optparse/version.rb: search also all
+ capital versions.
- * numeric.c (fix_rshift): use `sizeof(INT)*8' instead of 32.
+Mon Sep 8 19:26:33 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Mon Feb 2 14:09:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl.h: include openssl/conf.h and openssl/conf_api.h.
- * ruby.c (set_arg0): grab environment region too.
+ * ext/openssl/ossl_config.c: refine all with backward compatibility.
-Thu Jan 29 18:36:25 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/openssl/ossl_config.h: export GetConfigPtr() and DupConfigPtr().
- * process.c (rb_proc_exec): check `sh' to be exist.
+ * ext/openssl/ossl_x509.c: added new constants under X509 module.
+ DEFAULT_CERT_AREA, DEFAULT_CERT_DIR, DEFAULT_CERT_FILE,
+ DEFAULT_CERT_DIR_ENV, DEFAULT_CERT_FILE_ENV and DEFAULT_PRIVATE_DIR.
-Thu Jan 29 18:18:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_x509ext.c (ossl_x509extfactory_free): don't free
+ the members of the struct. it's left to GC.
- * io.c (io_stdio_set): assignment to $stdin or $stdout does
- reopen() as well as $stderr.
+ * ext/openssl/ossl_x509ext.c (ossl_x509_set_config): add for config=.
-Thu Jan 29 14:18:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_x509ext.c (Xossl_x509extfactory_initialize):
+ add attr readers: issuer_certificate, subject_certificate,
+ subject_request, crl and config.
- * class.c (mod_ancestors): should not include singleton classes.
+Mon Sep 8 18:26:41 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * object.c (obj_type): should not return internal class.
+ * lib/webrick/accesslog.rb (AccessLog::setup_params): use req.port
+ instead of config[:Port] or req.request_uri.port.
- * io.c (io_reopen): unwillingly closes stdio streams.
+ * lib/webrick/httprequest.rb (HTTPRequest#meta_vars): ditto.
-Thu Jan 29 11:50:35 1998 Toshihiko SHIMOKAWA <toshi@csce.kyushu-u.ac.jp>
+ * lib/webrick/httpservlet/filehandler.rb (FileHandler#dir_list): ditto.
- * ext/socket/socket.c (udp_addrsetup): forgot to use htons().
+ * lib/webrick/config.rb: :Listen option never be used.
-Tue Jan 27 23:15:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/webrick/server.rb (GenericServer#initialize): don't use :Listen
+ option and add warning message.
- * keywords: __FILE__, __LINE__ are available again.
+ * lib/webrick/log.rb (BasicLog#<<): shortcut of log(INFO, ...).
-Fri Jan 23 14:19:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/webrick/httpserver.rb (HTTPServer#accesslog): use << for logging.
- * version 1.1b6 released.
+Sun Sep 7 16:08:28 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * object.c (mod_to_s): need to duplicate classpath.
+ * ext/tcltklib/tcltklib.c (lib_mainloop_core): fixed signal-trap bug
- * error.c (exc_inspect): need to duplicate classpath.
+ * ext/tk/lib/*.rb : Ruby/Tk works at $SAFE == 4
-Thu Jan 22 00:37:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Sep 6 02:26:34 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * ruby.h (STR2CSTR): new macro to retrieve char*.
+ * test/ruby/test_*.rb: assert_same, assert_match, and so on.
- * class.c (rb_define_method): `initialize' should always be
- private, even if it defined by C extensions.
+Sat Sep 6 18:45:46 2003 Mauricio Fernandez <batsman.geo@yahoo.com>
- * eval.c (rb_eval): `initialize' should always be private.
+ * parse.y (assignable): call rb_compile_error(), not rb_bug().
+ [ruby-core:01523]
-Thu Jan 22 16:21:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Sep 6 17:40:41 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * eval.c (rb_eval): some singleton class def cause SEGV.
+ * ext/openssl/ruby_missing.c: rid of unnecessary backward
+ compatibility stuff. and remove DEFINE_ALLOC_WRAPPER from
+ all sources.
- * eval.c (TMP_ALLOC): replace ALLOCA_N, where thread context
- switch may happen.
+ * ext/openssl/ossl_x509ext.c (X509::Extension.new): new method.
-Wed Jan 21 01:43:42 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_x509ext.c (X509::Extension#oid=): new method.
- * eval.c (PUSH_FRAME): do not use ALLOCA_N(). crash on some
- platforms that use missing/alloca.c.
+ * ext/openssl/ossl_x509ext.c (X509::Extension#value=): new method.
- * regex.c (re_compile_pattern): too many pops for non register
- subexpr.
+ * ext/openssl/ossl_x509ext.c (X509::Extension#critical=): new method.
- * parse.y (yylex): open parentheses after identifiers are argument
- list, even if whitespaces have seen.
+Sat Sep 6 01:23:22 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Tue Jan 20 15:19:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * win32/win32.c (CreateChild): need to quote cmd if RUBYSHELL is set.
- * parse.y (terms): quoted word list by %w(a b c).
+ * win32/win32.c (CreateChild): fix condition about whether to call
+ shell or not.
- * ext/tcltklib/extconf.rb: more accurate check for tcl/tk libs.
+Sat Sep 6 00:36:20 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
- * file.c (rb_stat): most of the FileTest methods (and function
- `test') accept File objects as the argument.
+ * Makefile.in (test): phony target.
-Tue Jan 19 18:19:24 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * lib/mkmf.rb (have_library, find_library): configure by library
+ name.
- * ext/extmk.rb.in (install): there should be no newline after install:
+ * lib/optparse.rb (OptionParser#order, #permute, #parse): allow an
+ array as argument.
- * re.c (MIN): renamed from min(). there's a local variable named
- min in the file, so that some cpp will raise an error.
+ * test/ruby/test_*.rb: moved invariants to left side in
+ assert_equal, and use assert_nil, assert_raises and so on.
-Mon Jan 19 16:30:05 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * win32/win32.c (isInternalCmd): distinguish command.com and
+ cmd.exe.
- * version 1.1b5 released.
+ * win32/win32.c (make_cmdvector): a character just after wildcard
+ was ignored. [ruby-core:01518]
- * process.c (rb_syswait): no exception raised.
+Fri Sep 5 20:27:08 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
-Fri Jan 16 00:43:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/test_*.rb: replace 'assert(a == b)' with assert_equal(a, b)'
- * ruby.h (CLONESETUP): copies its singleton classes too.
+Fri Sep 5 18:00:51 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * class.c (singleton_class_attached): saves binded object in the
- singleton classes.
+ * ext/openssl/lib/openssl/x509.rb: new method X509::Name::parse.
- * eval.c (rb_eval): calls singleton_method_added even in the
- singleton class clauses.
+ * ext/openssl/ossl_digest.c: add ossl_digest_new().
-Fri Jan 15 23:22:43 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/openssl/ossl_digest.h: ditto.
- * ruby.c (proc_options): -S does not recognize PATH.
+ * ext/openssl/ossl_cipher.c: add ossl_cipher_new().
-Thu Jan 15 02:03:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_cipher.h: ditto.
- * eval.c (rb_clear_cache_by_id): clear only affected cache
- entries.
+Fri Sep 5 15:32:04 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Jan 14 02:14:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * misc/ruby-mode.el (ruby-font-lock-maybe-here-docs): should not
+ search delimiter forward if found in backward.
- * ext/socket/socket.c: new UDP/IP socket classes.
+Fri Sep 5 13:32:48 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Jan 13 10:00:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/runner.rb: arguments should be keys.
- * string.c (str_cmp): ignorecase($=) works wrong.
+Fri Sep 5 12:09:55 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Fri Jan 9 13:19:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/ruby/test_system.rb (test_system): check existence of ruby
+ interpreter.
- * version 1.1b4 released.
+Fri Sep 5 11:32:17 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (f_missing): class name omitted from the error message.
+ * lib/optparse.rb (--version): fix assignment/reference order.
- * error.c (exc_inspect): description changed.
+ * lib/optparse.rb (OptionParser#help): new; OptionParser#to_s may
+ be deprecated in future.
- * string.c (Init_String): GlobalExit's superclass did not filled,
- since GlobalExit created earlier than String.
+ * lib/optparse/version.rb (OptionParser#show_version): hide Object.
-Thu Jan 8 12:10:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/runner.rb: fix optparse usage.
- * parse.y (aryset): expr in the brackets can be null.
+ * test/runner.rb: glob all testsuits if no tests given.
-Wed Jan 7 21:13:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Sep 5 10:42:58 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * io.c (io_reopen): keep stderr unclosed.
+ * test/runner.rb: added. gets testcases from command line and runs it.
- * io.c (io_errset): keep stderr unclosed.
+ * test/ruby/test_gc.rb: remove useless part which was for dumping test
+ result.
-Tue Jan 6 00:27:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Sep 5 09:28:59 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * parse.y: syntax modified for `while expr do .. end' etc.
+ * test/ruby/test_gc.rb: added. splitter.rb which I made to split
+ sample/test.rb into test/ruby/test_* kindly removed GC test (the
+ last section in the original test) to reduce things to be worried.
- * process.c (f_exec,f_system): can supply arbitrary name for the
- new process.
+Fri Sep 5 03:00:04 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Jan 5 16:59:13 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * test/ruby/test_iterator.rb (test_block_in_arg): add no block
+ given tests.
- * file.c (file_s_basename): removes any extension by ".*".
+ * test/ruby/test_iterator.rb (test_ljump): uncomment LocalJumpError
+ test.
-Sun Jan 4 19:36:22 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Fri Sep 5 01:10:11 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * parse.y (yylex): needed to update lex_p (reading point).
+ * test/ruby: tests for ruby itself.
-Sat Jan 3 19:14:14 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * test/ruby/test_*.rb: split sample/test.rb into 28 test/unit testcases.
+ some tests could not be translates... search '!!' mark to see it.
- * class.c,object.c: duplicate defines mKernel and cFinxnum.
+ * test/csv/test_csv.rb: should require 'csv', not '../lib/csv'. test
+ runner should set load path correctly.
-Fri Jan 2 20:38:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Sep 5 01:03:59 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * ext/curses/curses.c (NUM2CHAR): uses the first character for
- string arguments.
+ * test/csv/test_csv.rb: close opened files for CSV::IOBuf explicitly.
+ opened file cannot be removed under win32 box.
- * array.c (ary_fill): did not extend array for ranges.
+Thu Sep 4 23:59:40 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (beg_len): did not return end pos bigger than size.
+ * parse.y (tokadd_string): newlines have no special meanings in
+ %w/%W, otherwise they are ignored only when interpolation is
+ enabled. [ruby-dev:21325]
-Fri Jan 2 02:09:16 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Thu Sep 4 19:38:25 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * dir.c (dir_s_chdir): bug in nil check.
+ * ext/io/wait/.cvsignore: added.
- * array.c (ary_fill): bug in nil check.
+ * ext/openssl/.cvsignore: added.
-Tue Dec 30 11:46:23 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Sep 4 19:28:24 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * hash.c (env_path_tainted): checks directories in PATH
- environment variable are not world writable.
+ * sample/openssl: added. Sample of standard distribution library
+ should be locate in sample/{module_name}/*.
- * ruby.c (load_file): invoke specified interpreter if the #! line
- does not contain the word `ruby'.
+ * ext/openssl/sample/*: removed. move to sample/openssl/*.
-Fri Dec 26 03:26:41 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Sep 4 18:02:15 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * string.c (uscore_get): type information included in the error
- message.
+ * test/csv/test_csv.rb: use remove_const to reduce warnings. use
+ Dir.tmpdir to locate working files.
- * variable.c (f_untrace_var): does not free trace-data within
- trace procedure.
+Thu Sep 4 17:41:31 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Dec 25 02:50:29 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * misc/ruby-mode.el (ruby-here-doc-beg-re): underscore also is
+ valid delimiter.
- * version 1.1b3 released.
+ * misc/ruby-mode.el (ruby-here-doc-end-match): must quote
+ arbitrary string to use as regexp.
- * ruby.h: inlining some functions on gcc 2.x
+ * misc/ruby-mode.el (ruby-font-lock-maybe-here-docs): must not
+ call `ruby-here-doc-end-match' unless `ruby-here-doc-beg-re'
+ matched.
-Tue Dec 23 02:47:33 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Sep 4 15:40:07 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * eval.c (rb_eval): public/private information kept in the current
- scope, to remove undesired state from the class/module.
+ * test/csv/test_csv.rb: run on test/unit original layer.
- * time.c (time_strftime): remove hidden limit of 100 bytes of
- result string, using malloc'ed buffer.
+Thu Sep 4 12:54:50 2003 why the lucky stiff <why@ruby-lang.org>
- * hash.c (hash_update): merges the contents of another hash,
- overriding existing keys.
+ * ext/syck/token.c: headerless documents with root-level spacing now
+ honored.
- * regex.c (must_instr): totally re-written.
+Thu Sep 4 00:06:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (read_all): try to allocate proper sized buffer using
- fstat(2) for speedup.
+ * eval.c (mark_frame_adj): need to adjust argv pointer if using
+ system's alloca. [ruby-core:01503]
-Sat Dec 20 00:27:28 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Sep 3 21:33:20 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
- * regex.c (must_instr): need to skip 2 bytes for mbchars.
+ * test: add test directory. Test::Unit aware testcases and needed
+ files should be located in this directory. dir/file name convention;
+ test/{module_name}/test_{testcase_name}.rb
+ test/{module_name}/{needed_files}
+ someday, someone will write testrunner which searches test_*.rb and
+ run testcases automatically.
-Fri Dec 19 01:18:29 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * test/csv/*: add testcase for lib/csv.rb.
- * version 1.1b2 released.
+Wed Sep 3 01:37:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (check_errat): check and convert (if necessary) traceback
- information before assigning to the variable $@.
+ * io.c (rb_f_gets): should call next_argv() before type check
+ current_file. [ruby-list:38336]
- * eval.c (f_raise): optional third argument to specify traceback
- information.
+Tue Sep 2 20:37:15 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * io.c (f_open): prevent infinite recursive call.
+ * ext/openssl/lib/net/protocols.rb (SSLIO#ssl_connect): warning
+ for skipping server verification.
-Thu Dec 18 19:33:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Sep 2 23:36:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * string.c (str_rindex): now accepts regexp as index.
+ * eval.c (proc_invoke): should retrieve retval when pcall is true.
-Thu Dec 18 18:42:50 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Tue Sep 2 14:09:20 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ext/socket/extconf.rb: modified to detect win32 socket lib.
+ * ext/socket/extconf.rb: check s6_addr8 in in6_addr (Tru64 UNIX).
+ the patch is submitted by nmu <nmu@users.sourceforge.jp>.
-Thu Dec 18 00:25:03 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/socket/getaddrinfo.c (getaddrinfo): should use in6_addr8 on
+ some platforms.
- * re.c (reg_equal): checks for source and casefold and kcode matching.
+ * ext/socket/getnameinfo.c (getnameinfo): ditto.
- * marshal.c: became built-in module.
+Tue Sep 2 14:02:19 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/marshal/marshal.c (r_object): displays struct name for
- non-compatible struct.
+ * ext/tcltklib/tcltklib.c (ip_invoke): fixed bug on passing a exception
- * string.c (str_index_method): now searches character (fixnum) in
- the string.
+ * ext/tk/lib/{tk.rb, tkcanvas.rb, tkfont.rb, tktext.rb} :
+ bug fix and improvement of font control
- * string.c (str_include): redefine `include?'.
+Tue Sep 2 09:51:36 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * regex.c (re_match): start_nowidth saves current stack position
- to stop_nowidth.
+ * eval.c (rb_eval): should not handle exceptions within rescue
+ argument. [ruby-talk:80804]
- * regex.c (re_compile_pattern): add space to stop_nowidth to save
- runtime stack position.
+Tue Sep 2 00:44:37 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Tue Dec 16 14:57:43 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * re.c (rb_memsearch): fix overrun. [ruby-talk:80759]
- * string.c (scan_once): wrong exception for regexp that match with
- null string (use substr instead of subseq).
+Tue Sep 2 00:41:27 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Sat Dec 13 00:13:32 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/iconv/iconv.c (map_charset): use lower case keys.
- * parse.y (expr): remove bare assocs from expr rule.
+ * ext/iconv/iconv.c (iconv_fail): just yield error and return the
+ result if a block is given.
- * rbconfig.rb: renamed from config.rb (it was too generic name).
+ * ext/iconv/iconv.c (iconv_convert): yield error and append the
+ result if a block is given.
-Fri Dec 12 00:50:25 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/iconv/charset_alias.rb (charset_alias): optional third
+ argument.
- * parse.y (expr): warns if BEGIN or END appear in the method
- bodies.
+ * ext/iconv/charset_alias.rb (charset_alias): use CP932 instead of
+ SHIFT_JIS on cygwin.
- * string.c (str_match): calls y =~ x if y is neither String nor
- Regexp so that eregex.rb works.
+Mon Sep 1 18:34:25 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (f_at_exit): to register end proc.
+ * eval.c (rb_eval): make tail recursion in ELSE clause of
+ RESCUE a jump.
- * class.c (rb_define_module_function): define 'function' method
- for the Module, not private method.
+Mon Sep 1 18:00:02 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * class.c (rb_define_function): function to define `function' method.
+ * parse.y (aref_args): forgot to call NEW_SPLAT(). reported by
+ Dave Butcher.
- * eval.c (rb_eval): inherit visibility from superclass's method
- except when it is set to `function'
+ * eval.c (Init_Thread): protect thgroup_default. suggested by Guy
+ Decoux in [ruby-talk:80623]
- * eval.c (rb_eval): new visibility status `function'.
+Mon Sep 1 16:59:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (yycompile): do not clear eval_tree. thus enable multiple
- command line script by option `-e'.
+ * eval.c (rb_thread_switch): add RESTORE_EXIT; exit by another
+ thread termination.
- * eval.c (rb_eval): END execute just once.
+ * eval.c (rb_thread_start_0): should not error_print() within
+ terminated thread, because $stderr used by it might be
+ overriden now. [ruby-dev:21280]
- * parse.y (expr): BEGIN/END built in the syntax.
+Sun Aug 31 22:46:55 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Thu Dec 11 13:14:35 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (TAG_DST()): take no argument.
- * object.c (mod_le): Module (or Class) comparison.
+ * process.c (p_gid_sw_ensure): return VALUE.
- * eval.c (rb_remove_method): raises NameError if named method does
- not exist.
+Sun Aug 31 22:27:10 2003 Hidetoshi NAGAI <nagai@dumbo.ai.kyutech.ac.jp>
- * ext/curses/curses.c: remove CHECK macro for BSD curses.
-
-Thu Dec 11 12:44:01 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * process.c (p_gid_sw_ensure): lack of function type
- * pack.c: sun4 cc patch
+Sun Aug 31 12:25:06 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
-Wed Dec 10 15:21:36 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/optparse.rb: --version takes an optional argument; "all" or
+ a list of package names.
- * ext/marshal/marshal.c (marshal_load): can supply evolution proc
- object as optional second argument.
+Sun Aug 31 10:17:02 2003 Tadayoshi Funaba <tadf@dotrb.org>
- * re.c (reg_source): get source string of the regular expression.
+ * lib/date/format.rb: yyyy/mm is not an acceptable format.
-Tue Dec 9 10:05:17 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/time.rb: follow above.
- * version 1.1b1 released.
+Sat Aug 30 14:25:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y (tokadd): token buffer overrun.
+ * eval.c (rb_iter_break): should not call TAG_JUMP directly.
- * ruby.c (ruby_prog_init): forgot to protect rb_argv0 from gc.
+Sat Aug 30 03:58:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (ruby_run): call finalizers at process termination.
+ * eval.c (struct BLOCK): remove BLOCKTAG, use scope instead.
- * gc.c (gc_call_finalizer_at_exit): call free proc for every Data
- Wrapper, and finalizer for specified objects at termination.
+ * eval.c (POP_TAG): no longer propagate retval. retval is now set
+ directly by localjump_destination().
- * version.c (show_version): version format changed.
+ * eval.c (localjump_destination): new function to cast
+ return/break local jump.
- * regex.c (re_match): wrong match with non-greedy if they appear
- more than once in regular expressions.
+ * eval.c (rb_yield_0): stop TAG_RETURN/TAG_BREAK escaping.
- * sample/ruby-mode.el (ruby-expr-beg): forgot to handle modifiers.
+Fri Aug 29 22:35:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
-Mon Dec 8 19:00:15 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * bigdecimal.c *.html: The 2nd arg. for add,sub,mult, and div is 0,
+ then result will be the same as +,-,*,/ respectively.
- * io.c (io_puts): just put a newline if no argument given.
+Fri Aug 29 17:30:15 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
- * ext/tcltklib/tcltklib.c (lib_mainloop): thread-aware tk handle
- when $tk_thread_safe is set.
+ * process.c: bug fix
- * ext/tcltklib/tcltklib.c (lib_mainloop): use Tcl_DoOneEvent()
- instead of Tk_MainLoop().
+ * process.c: add rb_secure(2) to methods of Process::{UID,GID,Sys}
-Mon Dec 6 07:11:16 1997 MAEDA shugo <shugo@po.aianet.ne.jp>
+ * process.c: deny handling IDs during evaluating the block given to
+ the Process::{UID,GID}.switch method
- * io.c (io_puts): core dumped without any argument.
+ * ext/tcltklib/tcltklib.c : some methods have no effect if on slave-IP
-Fri Dec 5 18:17:17 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tcltklib/tcltklib.c : can create a interpreter without Tk
- * eval.c (mod_remove_method): remove (not undef) a method from the
- class/module.
+ * ext/tcltklib/tcltklib.c : bug fix on handling exceptions
- * variable.c (obj_remove_instance_variable): method to remove
- instance variables.
+ * ext/tcltklib/MANUAL.euc : modify
-Thu Dec 4 13:50:29 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tk.rb : freeze some core modules
- * version 1.1b0 released.
+ * ext/tk/lib/multi-tk.rb : more secure
- * string.c (str_aref): called str_index for regexp.
+ * ext/tk/lib/tk.rb: TkVariable.new(array) --> treat the array as the
+ Tk's list
-Mon Dec 1 15:24:41 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tk.rb: improve accessibility of TkVariable object
- * compar.c (cmp_between): wrong comparison made.
+ * ext/tk/lib/tk.rb, ext/tk/lib/tkfont.rb, ext/tk/lib/tkcanvas.rb,
+ ext/tk/lib/tktext.rb : fix bug of font handling
-Wed Nov 26 18:18:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/tk/lib/tkfont.rb TkFont.new() accepts compound fonts
- * lib/mkmf.rb: generate Makefile for extension modules out of ruby
- source tree. use like `ruby -r mkmf extconf.rb'.
+Thu Aug 28 22:07:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * numeric.c (fix2str): enlarge buffer to prevent overflow on some
- machines.
+ * variable.c (rb_autoload_load): call const_missing if autoloading
+ constant is not defined to allow hook.
- * parse.y (here_document): wrong line number generated after here-doc.
+ * eval.c (rb_eval): use rb_const_get_from() instead of
+ rb_const_get_at().
-Fri Nov 21 13:17:12 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (is_defined): forgot to check NODE_COLON3.
- * parse.y (yylex): skip multibyte characters in comments.
+Thu Aug 28 17:30:24 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Nov 19 17:19:20 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * variable.c (rb_const_get_0): should check constants defined in
+ included modules, if klass is Object. [ruby-talk:79302]
- * object.c (nil_to_a): nil.to_a => [].
+ * numeric.c (check_uint): check should be done using UINT_MAX, not
+ INT_MAX. this fix is submitted by Lyle Johnson
+ <lyle@knology.net> in [ruby-core:01486]
- * parse.y (call_args): wrong node generation.
+Thu Aug 28 05:02:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Tue Nov 18 10:13:08 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * parse.y (singleton): typo fixed (ruby-bugs-ja:PR#562)
- * array.c (Init_Array): Array#=== works as Array#include?
+Thu Aug 28 02:37:45 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_compile_pattern): insert initialize code for jump_n,
- before entering loops.
+ * eval.c (rb_eval): *a = [1,2] now assigns [[1,2]] to a.
+ consistent with *a = [1], which set [[1]] to a.
- * re.c (reg_search): does not save registers unless $& etc appear
- in the script.
+ * node.h: merge NODE_RESTARY to NODE_SPLAT.
-Mon Nov 17 13:01:43 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * parse.y: rules simplified a bit by removing NODE_RESTARY.
- * eval.c (is_defined): add defined? check for receivers and
- arguments for calls.
+ * sample/test.rb: updated for new assignment behavior.
- * re.c (reg_search): cache last match object.
+Wed Aug 27 22:33:24 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * re.c (match_aref): $[0] etc. are available.
+ * error.c (rb_bug): should not use other methods; this function is
+ not for ordinary use. [ruby-dev:21259]
-Sat Nov 15 00:11:36 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Wed Aug 27 15:07:57 2003 Minero Aoki <aamine@loveruby.net>
- * io.c (io_s_popen): "rb" detection
+ * lib/net/smtp.rb (check_response): AUTH CRAM-MD5 returns 334
+ response. [ruby-list:38279]
-Fri Nov 14 18:28:40 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Aug 27 05:10:15 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * string.c (scan_once): returns whole match if the pattern does
- not contain any parentheses.
+ * win32/win32.c (map_errno): support winsock error.
-Thu Nov 13 14:39:06 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * win32/win32.c (pipe_exec, CreateChild, poll_child_status, waitpid,
+ kill, link, rb_w32_rename, unixtime_to_filetime, rb_w32_utime):
+ pass errno to map_errno().
- * string.c (str_sub): returns copy of the receiver string, even if
- any substitution occurred.
+ * win32/win32.c (rb_w32_select, rb_w32_accept, rb_w32_bind,
+ rb_w32_connect, rb_w32_getpeername, rb_w32_getsockname,
+ rb_w32_getsockopt, rb_w32_ioctlsocket, rb_w32_listen, rb_w32_recv,
+ rb_w32_recvfrom, rb_w32_send, rb_w32_sendto, rb_w32_setsockopt,
+ rb_w32_shutdown, rb_w32_socket, rb_w32_gethostbyaddr,
+ rb_w32_gethostbyname, rb_w32_gethostname, rb_w32_getprotobyname,
+ rb_w32_getprotobynumber, rb_w32_getservbyname, rb_w32_getservbyport,
+ rb_w32_fclose, rb_w32_close): use map_errno().
- * regex.c (re_compile_pattern): no-width match by (?=..), (?!..).
+ * win32/win32.h: add winsock errors.
-Wed Nov 12 13:44:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Aug 26 23:53:23 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * time.c: remove coerce from Time class.
+ * lib/ostruct.rb (OpenStruct::method_missing): prohibit modifying
+ frozen OpenStruct. [ruby-talk:80214]
- * regex.c (re_match): non-greedy match by ??, *? +?, {n,m}?.
+Tue Aug 26 20:03:50 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Nov 10 11:24:51 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (create_tmpsrc): add the hook for source.
+ [ruby-list:38122]
- * regex.c (re_compile_pattern): non-registering parens (?:..).
+Tue Aug 26 15:59:53 2003 why the lucky stiff <why@ruby-lang.org>
- * regex.c (re_compile_pattern): new meta character \< (wordbeg)
- and \> (wordend).
+ * implicit.c (syck_type_id_to_taguri): corrected detection of
+ x-private types.
- * regex.c (re_compile_pattern): embedded comment for regular
- expression by (?#...).
+Sun Aug 24 01:02:48 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Fri Nov 7 16:58:24 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * file.c (file_expand_path): performance improvement.
+ [ruby-talk:79748]
- * regex.c (re_compile_pattern): perl5 regxp \A and \Z available.
+Sat Aug 23 23:41:16 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * regex.c (re_compile_pattern): can expand compile stack dynamically.
+ * file.c (rb_file_s_expand_path): avoid calling rb_scan_args() for
+ apparent cases. [ruby-talk:79748]
- * regex.c (PUSH_FAILURE_POINT): wrong compare condition.
+Sat Aug 23 18:56:53 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Wed Nov 2 16:00:00 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/nkf/nkf.c (rb_nkf_putchar): should use rb_str_resize() to just
+ resize a string, rb_str_cat() disallows NULL. [ruby-dev:21237]
- * string.c (str_sub_s): "".sub! "", "" => "\000"
+Sat Aug 23 16:48:41 2003 Keiju Ishitsuka <keiju@ishitsuka.com>
-Fri Oct 31 15:52:10 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/irb/ruby-lex.rb: bug fix for "foo" !~ /bar/. [ruby-talk:79942]
- * parse.y (assoc): keyword assoc like {fg->"black"}.
+Sat Aug 23 15:59:58 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Oct 30 17:33:38 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_eval, rb_iterate, block_pass): reduce PUSH/POP_TAG and
+ EXEC_TAG() for retry. [ruby-dev:21216]
- * io.c (io_println): print with newline, which is not affected by
- the values of $/ and $\.
+Sat Aug 23 02:32:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Oct 30 16:54:01 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * eval.c (rb_yield_splat): should check if "values" is array.
- * string.c (str_chop_bang): "".chop caused SEGV.
+ * enum.c (each_with_index_i): typo.
- * string.c (str_chomp_bang): method to chop out last newline.
+Fri Aug 22 17:07:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Mon Oct 27 13:49:13 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * enum.c (inject_i): use rb_yield_values.
- * ext/extmk.rb.in: library may have pathname contains `.'
+ * enum.c (each_with_index_i): ditto.
- * eval.c (rb_rescue): should not protect SystemError.
+ * eval.c (rb_yield_splat): new function to call "yield *values".
-Fri Oct 24 10:58:53 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * string.c (rb_str_scan): use rb_yield_splat().
- * io.c (io_s_with_open_stream): ensures to close stream.
+Fri Aug 22 06:13:22 2003 why the lucky stiff <why@ruby-lang.org>
-Thu Oct 23 11:17:44 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/rubyext.c: refactoring of the transfer method
+ dispatch. added yaml_org_handler for faster dispatch of
+ transfers to base types.
- * io.c (io_errset): value of $stderr can be changed (to any IO
- object).
+ * lib/yaml/rubytypes.rb: removed handling of builtins from
+ Ruby library.
- * io.c (next_argv): $< can be anything that responds to `write'.
+ * ext/syck/token.c: quoted and block scalars are now implicit !str
- * file.c (file_s_with_open_file): ensures to close file.
+ * ext/syck/implicit.c: empty string detected as !null.
- * error.c (exception): create error under the current class/module.
+Fri Aug 22 01:00:31 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * range.c (range_eqq): fixnum check for last needed too.
+ * eval.c (block_pass): improve passing current block.
-Wed Oct 22 12:52:30 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Aug 22 00:13:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
- * ext/socket/socket.c: Socket::Constants added.
+ * ext/bigdecimal/bigdecimal.c: Int. overflow bug in multiplication
+ fixed, and VpNmlz() speed up.
- * file.c: File::Constants added for inclusion.
+Wed Aug 20 16:44:49 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * array.c (ary_join): call ary_join() recursively for the 1st
- array element.
+ * ext/socket/socket.c (ruby_connect): many systems seem to have
+ a problem in select() after EINPROGRESS. [ruby-list:38080]
-Mon Oct 20 12:18:29 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Wed Aug 20 01:31:17 2003 why the lucky stiff <why@ruby-lang.org>
- * ruby.c (load_file): wrong condition for #! check with -x.
+ * ext/syck/syck.h: Parser definition problems on HP-UX.
+ [ruby-talk:79389]
- * file.c (file_s_dirname): did return "" for "/a".
+ * ext/syck/handler.c (syck_hdlr_get_anchor): Memory leak.
-Fri Oct 17 14:29:09 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/syck/syck.s (syck_io_file_read): Bad arguments to fread.
- * ruby.c: now works on alpha-linux.
+ * ext/syck/rubyext.c: Tainting issues.
- * bignum.c (bigadd): some undefined side effect order assumed.
+Tue Aug 19 23:20:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
-Wed Oct 15 17:49:24 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/bigdecimal/bigdecimal.c .h .html: to_s("+") implemented.
- * intern.h: function prototypes added.
+ * ext/bigdecimal/lib/bigdecimal/math.rb: E implemented.
-Mon Oct 13 16:54:18 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Aug 19 07:47:09 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * class.c (rb_define_class_id): call superclass's `inherited'
- method when making subclasses.
+ * lib/webrick/ssl.rb: new file; SSL/TLS enhancement for GenericServer.
- * parse.y (nextc): clear lex_lastline at the end of file.
+ * lib/webrick/https.rb: SSLSocket handling is moved to webrick/ssl.rb.
- * object.c (Init_Object): need to undef Class#append_features.
+ * lib/webrick/compat.rb (File::fnmatch): remove old migration code.
- * eval.c (rb_eval): no warning on extending classes or modules.
+ * lib/webrick/httpserver.rb (HTTPServer#run): ditto.
-Thu Oct 9 11:17:50 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/webrick/server.rb (GenericServer#listen): the body of this
+ method is pull out as Utils::create_lisnteners.
- * eval.c (error_print): the exception name follows after the error
- message.
+ * lib/webrick/utils.rb (Utils::create_lisnteners): new method.
- * eval.c (compile_error): error message slightly changed.
+ * lib/webrick/server.rb (GenericServer#start): should rescue
+ unknown errors. and refine comments.
- * parse.y (nextc): script parsing will be terminated by __END__ at
- beginning of line.
+ * ext/openssl/lib/openssl/ssl.rb (SSLServer#accept): should close
+ socket if SSLSocket raises error.
- * eval.c (compile_error): `__END__' is no longer a keyword.
+Tue Aug 19 11:19:33 2003 Shugo Maeda <shugo@ruby-lang.org>
- * parse.y (nextc): protect lastline read from script stream.
+ * io.c (next_argv): should not call GetOpenFile() if rb_stdout is
+ not a IO (T_FILE).
-Tue Oct 7 14:06:06 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Aug 19 07:47:09 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * version 1.1 alpha9 released.
+ * ext/openssl/ossl_ssl.c: sync_close is moved to SSLSocket as
+ a builtin.
- * eval.c (mod_append_features): renamed from extend_class.
+ * ext/openssl/lib/openssl/buffering.rb (Buffering#close): ditto.
- * eval.c (rb_eval): defining method calls `method_added'.
+ * ext/openssl/lib/openssl/buffering.rb (Buffering#puts): should
+ add a return to the tails of each line.
- * eval.c (ruby_options): exception while processing options must
- terminate the interpreter.
+ * ext/openssl/lib/openssl/ssl.rb: new class OpenSSL::SSL::SSLServer.
- * error.c (Init_Exception): wrong method configuration. `new'
- should have been a singleton method.
+ * ext/openssl/lib/net/protocols.rb (SSLIO#ssl_connect): use sync_close.
-Mon Oct 6 18:55:38 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/sample/echo_svr.rb: use SSLServer.
- * ext/kconv/kconv.c (kconv_guess): code to guess character code
- from string.
+ * ext/openssl/sample/echo_cli.rb: add example of SSLSocket#sync_close.
-Mon Oct 6 18:38:17 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Tue Aug 19 01:24:34 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * pack.c: now encode/decode base64 by `m' template.
+ * ext/curses/curses.c (_XOPEN_SOURCE_EXTENDED): Mac OS X standard
+ headers are inconsistent at this macro. [ruby-core:01432]
-Fri Oct 3 10:51:10 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/curses/extconf.rb: check if _XOPEN_SOURCE_EXTENDED breaks.
- * MANIFEST: needed to include lex.c in the distribution.
+ * ext/tcltklib/stubs.c: Status macro in X11/Xthreads.h bothers
+ winspool.h
- * eval.c (ruby_options): f_require() called too early.
+ * instruby.rb: make list at first instead of iterator.
+ [ruby-talk:79347]
- * eval.c (rb_provide): module extensions should always be `.o'.
+Mon Aug 18 11:23:11 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Thu Oct 2 11:38:31 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * dir.c (glob_helper): preserve raw order for **.
- * version 1.1 alpha8 released.
+Sun Aug 17 23:39:55 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/marshal/marshal.c (r_object): remove temporal regist for
- structs. (caused problem if structs form cycles.)
+ * ext/openssl/extconf.rb (HAVE_VA_ARGS_MACRO): need to compile.
- * parse.y (match_gen): static binding for match(=~) calls
- with regexp literals.
+Sun Aug 17 17:10:03 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Wed Oct 1 15:26:55 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/lib/openssl/ssl.rb (SSLSocket#sync_close=): add a
+ method to specify if the underlying IO will be closed in
+ SSLSocket#close.
- * eval.c: protect retval in struct tag from GC for C_ALLOCA.
+ * ext/openssl/lib/openssl/buffering.rb: add forwarders to
+ setsockopt, getsockopt and fcntl.
- * eval.c: no more pointer value from setjmp/longjmp.
+ * ext/openssl/lib/net/protocols.rb: enable sync for SSLSocket.
-Wed Oct 1 14:01:49 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Sun Aug 17 11:32:04 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * ext/marshal/marshal.c (w_byte): argument must be char.
+ * ext/extmk.rb (extmake): should not force to remake Makefile when
+ installation and so on.
-Wed Oct 1 10:30:22 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Sat Aug 16 23:58:18 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * variable.c (mod_const_at): global constants now belongs to the
- class Object.
+ * marshal.c (w_symbol, w_object): get rid of warnings.
- * object.c (Init_Object): new global constant NIL.
+ * re.c (rb_memsearch): ditto.
- * ext/marshal/marshal.c (marshal_dump): try to set binmode.
+ * time.c (time_dump): ditto.
- * ext/marshal/marshal.c (r_object): forgot to re-regist structs in
- the object table.
+ * ext/extmk.rb (extmake): not continue making when extconf.rb
+ failed.
- * eval.c (ruby_options): call Init_ext() before any require()
- calls by `-r'.
+ * ext/openssl/extconf.rb: check __VA_ARGS__ macro more precisely.
-Fri Sep 30 14:29:22 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/openssl/ossl.h: remove version.h dependency.
- * ext/marshal/marshal.c (w_object): marshal dumped core.
+ * ext/openssl/ruby_missing.h: ditto.
-Tue Sep 30 10:27:39 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (pkg_config): use --libs output except with
+ only-L for other options. [ruby-list:38099]
- * sample/test.rb: bignum test suits added.
+ * lib/mkmf.rb (create_makefile): separate rule for static
+ library from shared object.
- * eval.c (rb_eval): new pseudo variable `true' and `false'.
+ * win32/Makefile.sub, bcc32/Makefile.sub, wince/Makefile.sub:
+ define exec_prefix and libdir.
- * parse.y: new keywords `true' and `false' added.
+Fri Aug 15 23:15:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
-Mon Sep 29 13:37:58 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/bigdecimal/bigdecimal.c .h: Bug in combination of limit & div
+ method fixed.
- * ruby.c (forbid_setid): forbid some options in suid mode.
+ * ext/bigdecimal/lib/bigdecimal/math.rb: atan() & sqrt() added.
- * ruby.h (NUM2DBL): new macro to convert into doubles.
+Fri Aug 15 12:01:43 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
-Mon Sep 27 09:53:48 1997 EGUCHI Osamu <eguchi@shizuokanet.or.jp>
+ * configure.in (HUGE_ST_INO): check whether struct stat.st_ino
+ is larger than long. [ruby-dev:21194]
+ http://www.geocities.co.jp/SiliconValley-PaloAlto/1409/ruby/beos.html
- * bignum.c: modified for speeding.
+ * error.c (syserr_eqq): errno might exceed Fixnum limit.
-Fri Sep 26 18:27:59 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * error.c (Init_Exception): moved base initialization from
+ init_syserr().
- * sample/from.rb: some extensions.
+ * inits.c (rb_call_inits): postpone initializing errnos until
+ Bignum is available.
-Mon Sep 29 13:15:56 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Fri Aug 15 12:01:43 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * parse.y (lhs): no more syntax error on `obj.CONSTANT = value'.
+ * ext/curses/curses.c (_XOPEN_SOURCE_EXTENDED): needed to let
+ keyname() and so on be declared.
-Fri Sep 26 14:41:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/curses/curses.c (curses_resizeterm, window_resize):
+ arguments conflicted with macros in term.h.
- * eval.c (ruby_run): deferred calling Init_ext() just before eval_node.
+ * ext/curses/curses.c (Curses module methods): ensure
+ initialized. [ruby-dev:21191]
-Fri Sep 26 13:27:24 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Fri Aug 15 02:08:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (io_isatty): forgot to return TRUE value.
+ * gc.c (id2ref): recycle check should be done by klass == 0.
+ [ruby-core:01408]
-Fri Sep 25 11:10:58 1997 EGUCHI Osamu <eguchi@shizuokanet.or.jp>
+Fri Aug 15 01:34:23 2003 Michal Rokos <m.rokos@sh.cvut.cz>
- * eval.c: use _setjmp/_longjmp instead of setjmp/longjmp on some
- platforms.
+ * ext/openssl/ossl_pkey.c: move generate_cb here
-Wed Sep 24 17:43:13 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/ossl_pkey_{dh|dsa|rsa}.c: adapt to this cb
- * string.c (Init_String): String#taint and String#taint? added.
+ * ext/openssl/openssl_missing.[ch]: add (0.9.6x, x<j) missing BN funcs
- * class.c (mod_ancestors): ancestors include the class itself.
+ * ext/openssl/ossl_bn.c: use supplied funcs from openssl_missing.c
-Wed Sep 24 00:57:00 1997 Katsuyuki Okabe <HGC02147@niftyserve.or.jp>
+Fri Aug 15 00:38:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
- * X68000 patch.
+ * ext/bigdecimal/bigdecimal.c: Bug in div method fixed.
-Tue Sep 23 20:42:30 1997 EGUCHI Osamu <eguchi@shizuokanet.or.jp>
+ * ext/bigdecimal/lib/bigdecimal/math.rb: Newly added.
- * parse.y (node_newnode): SEGV on null node setup.
+ * ext/bigdecimal/sample/pi.rb: Changed so as to use math.rb.
-Mon Sep 22 11:22:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Aug 14 21:19:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * ruby.c (ruby_prog_init): wrong safe condition check.
+ * eval.c (Init_Thread): Continuation#[] added. [ruby-talk:79028]
-Sun Sep 21 14:46:02 1997 MAEDA shugo <shugo@po.aianet.ne.jp>
+Thu Aug 14 20:03:34 2003 Masaki Suketa <masaki.suketa@nifty.ne.jp>
- * error.c (exc_inspect): garbage added to classpath.
+ * ext/win32ole/win32ole.c (OLE_FREE): should not call
+ ole_message_loop.
-Fri Sep 19 11:49:23 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/win32ole/win32ole.c (ole_event_free): ditto.
- * parse.y (newtok): forgot to adjust buffer size when shrinking
- the token buffer.
+ * ext/win32ole/win32ole.c (ole_initialize): stop calling
+ OleUninitialize at exit.
- * enum.c (enum_find): rb_eval_cmd() does not return value.
+Thu Aug 14 11:27:37 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * io.c (pipe_open): close fds on pipe exec. fcntl(fd, F_SETFD, 1)
- no longer used.
+ * gc.c (rb_data_object_alloc): check type of 1st argument.
+ [ruby-dev:21192]
-Tue Sep 16 17:54:25 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Aug 14 00:21:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * file.c (f_test): problem if wrong command specified.
+ * parse.y (mlhs_node): should allow "::Foo" (colon3) as lhs.
- * ruby.c (ruby_prog_init): close stdaux and stdprn for MSDOS.
+ * parse.y (lhs): ditto.
- * ruby.c (ruby_prog_init): should not add path from environment
- variable, if ruby is running under setuid.
+ * parse.y (yylex): should return tCOLON3 right after kCLASS.
+ [ruby-talk:78918]
- * process.c (init_ids): check suid check for setuid/seteuid etc.
+ * error.c (exc_initialize): was converting argument to string too
+ eagerly. Only check was needed. [ruby-talk:78958]
-Mon Sep 15 00:42:04 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+Wed Aug 13 23:31:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
- * regex.c (re_compile_pattern): \w{3} and \W{3} did not work.
+ * ext/bigdecimal/bigdecimal.c .h .html: Ambiguity of
+ BigDecimal::limit removed.
-Thu Sep 11 10:31:48 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Wed Aug 13 19:21:34 2003 Christian Neukirchen <chneukirchen@yahoo.de>
- * version 1.1 alpha7 released.
+ * lib/webrick/https.rb (HTTPServer#run): should set syncing-mode
+ to SSLSocket. [ruby-talk:78919]
- * ext/socket/socket.c (sock_new): no setbuf() for NT.
+Wed Aug 13 18:13:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * io.c (rb_fopen,rb_fdopen): set close-on-exec for every fd.
+ * eval.c (POP_BLOCK): turn on BLOCK_LEFT flag when leaving block.
-Wed Sep 10 15:55:31 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (proc_invoke): unpack return/break destination when block
+ is already left.
- * ext/marshal/marshal.c (r_bytes0): extra big length check.
+Wed Aug 13 15:58:31 2003 WATANABE Hirofumi <eban@ruby-lang.org>
-Tue Sep 9 16:27:14 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * object.c (rb_class_s_alloc): add function prototype to avoid VC++
+ warning.
- * io.c (pipe_fptr_atexit): clean up popen()'ed fptr.
+Wed Aug 13 13:50:59 2003 NAKAMURA Usaku <usa@ruby-lang.org>
- * error.c (set_syserr): some system has error code that is bigger
- than sys_nerr. grrr.
+ * ext/Win32API/Win32API.c (Win32API_initialize): should pass some
+ class to first argument of Data_Wrap_Struct(). (ruby-bugs:PR#1109)
-Mon Sep 8 18:33:33 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Aug 12 16:55:11 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * io.c (io_s_new): dereferenced nil for optional mode.
+ * Makefile.in: static link libraries to LIBRUBY_SO with static linked
+ ext. [ruby-dev:21157]
-Fri Sep 5 10:26:03 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/extmk.rb (extmake): sort extension library initialization order.
- * class.c (class_instance_methods): do not include methods which
- are changed to private in subclasses.
+ * ext/extmk.rb (extmake): compact $extlibs.
-Thu Sep 4 12:38:53 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Aug 12 02:48:56 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * variable.c (f_global_variables): list name of the global
- variables.
+ * eval.c (THREAD_SAVE_CONTEXT): should explicitly turn off the
+ flag before calling getcontext(2).
- * object.c (obj_id): returns unique integer.
+ * eval.c (struct thread): add member to save backing store on
+ IA64. (ruby-bugs PR1086)
-Wed Sep 3 14:05:16 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (thread_mark): mark IA64 backing store region.
- * version 1.1 alpha6 released.
+ * eval.c (thread_free): free saved IA64 backing store.
- * eval.c (mod_s_constants): context sensitive constant list.
+ * eval.c (rb_thread_save_context): save IA64 backing store as well.
- * variable.c (mod_constants): no more `all' option.
+ * eval.c (rb_thread_restore_context): restore IA64 backing store.
- * variable.c (mod_const_of): the values for autoload classes are
- their name strings.
+ * eval.c (THREAD_ALLOC): initialize IA64 members.
- * class.c (class_instance_methods): no special treatment for
- singleton classes.
+Mon Aug 11 22:31:50 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+ * lib/debug.rb(debug_command): inspection command should inspect
+ resulting value even if it's nil. [ruby-dev:21180] by OMAE, jun
+ <jun66j5@ybb.ne.jp>.
- * object.c (obj_singleton_methods): returns list of singleton
- method names.
+ * lib/debug.rb(debug_command): incomplete regexp.
- * parse.y (yylex): no here document after `class' keyword.
+Mon Aug 11 17:33:07 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (f_load): expand path if fname begins with `~'.
+ * eval.c (rb_call_super): do not use rb_block_given_p() for
+ check. [ruby-talk:78656]
-Tue Sep 2 13:19:48 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (BEGIN_CALLARGS): push ITER_NOT only when ITER_PRE.
- * class.c (ins_methods_i): do not list undef'ed methods.
+Sun Aug 10 10:43:05 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
-Mon Sep 1 13:42:48 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/openssl/lib/openssl/buffering.rb: increase BLOCK_SIZE
+ from 1k to 16k bytes. [ruby-talk:78603]
- * version 1.1 alpha5 released.
+ * ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc): enable
+ partial write to allow interruption in SSLSocket#write.
- * object.c (mod_attr_reader): create methods to define attribute
- reader/write/accessor.
+Sun Aug 10 00:34:16 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * class.c (rb_define_attr): always defines accessors.
+ * cygwin/GNUmakefile: remove unnecessary '--drive-name=$(CC)'
+ for ccache.
- * eval.c (rb_call): alias occurred in the module body caused SEGV.
+Sat Aug 9 10:36:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * parse.y: did not generate here document strings properly.
+ * marshal.c (w_object): do not dump generic instance variable when
+ marshal_dump is defined.
-Mon Sep 1 11:43:57 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
-
- * parse.y (yylex): heredoc dropped an extra character.
+Sat Aug 9 00:35:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
-Fri Aug 29 11:10:21 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/bigdecimal.c: F style output(like 1234.56789) implemented
+ to to_s method.
+ * ext/bigdecimal_??.html: F style output(like 1234.56789)
+ implemented to to_s method.
- * class.c (class_instance_methods): same method names should not
- appear more than once.
+Fri Aug 8 12:33:17 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * parse.y (yylex): spaces can follow =begin/=end.
+ * bcc32/Makefile.sub: rubyw.exe should be a Windows GUI program.
+ add the -aa option to WLDFLAGS.
- * variable.c (find_class_path): look for class_tbl also for
- unnamed fundamental classes, such as Object, String, etc.
+Fri Aug 8 11:29:26 2003 Koji Arai <jca02266@nifty.ne.jp>
- * variable.c (rb_name_class): can't name class before String class
- is initialized.
+ * marshal.c (w_object): should set `c_arg' at first.
- * inits.c (rb_call_inits): unrecognized dependency from GC to
- Array.
+Fri Aug 8 03:22:28 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
- * variable.c (find_class_path): could not find class if Object's
- iv_tbl is NULL.
+ * lib/webrick/httputils.rb (FormData#list): should not take
+ a side effect for the receiver.
-Thu Aug 28 13:12:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Aug 7 14:40:37 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * version 1.1 alpha4 released.
+ * cygwin/GNUmakefile: better --disbale-shared option support.
- * variable.c (mod_constants): wrong condition for singleton
- class.
+ * cygwin/GNUmakefile: add forwarding DLL target for cygwin.
- * parse.y (yylex): revised `=begin' skip code.
+Thu Aug 7 14:21:05 2003 Corinna Vinschen <vinschen@redhat.com>
- * parse.y (here_document): forgot to free(eos).
+ * configure.in: Fix Cygwin specific naming of libraries to
+ be net distribution compliant. (ruby-bugs:PR#1077)
+ cygwin-ruby18.dll -> cygruby18.dll
- * parse.y (yylex): spaces after `<<' prohibited for here
- documents to avoid confusing with operator `<<'.
+Thu Aug 7 12:51:38 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (is_defined): separated from rb_eval().
+ * eval.c (rb_f_at_exit): should not be called without a block.
+ block_given check added.
-Wed Aug 27 11:32:42 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Thu Aug 7 06:46:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * version 1.1 alpha3 released.
+ * eval.c (rb_call0): forgot to pop ruby_class.
- * variable.c (mod_name): returns name of the class/module.
+ * eval.c (rb_call0): update ruby_class as well as ruby_cref.
+ (ruby-bugs-ja:PR#540)
- * parse.y (here_document): finally here document available now.
+Thu Aug 7 04:52:50 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * variable.c (fc_i): some classes/modules does not have iv_tbl.
+ * eval.c (rb_yield_0): remove ruby_frame->cbase and unify to
+ ruby_cref. [ruby-talk:78141]
- * variable.c (find_class_path): avoid infinite loop.
+Thu Aug 7 04:19:15 2003 Akinori MUSHA <knu@iDaemons.org>
-Tue Aug 26 13:43:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * gc.c: FreeBSD/ia64's mcontext_t is a bit different from that of
+ Linux/ia64. This makes gc.c compile but miniruby coredumps for
+ the moment.
- * eval.c (rb_eval): undef'ing non-existing method will raise
- NameError exception.
+Thu Aug 7 00:15:00 2003 Shigeo Kobayashi <shigek@ruby-lang.org>
- * object.c (class_s_new): needed to create metaclass too.
+ * ext/bigdecimal.c: Comparison results adjusted to Float's.
+ * ext/bigdecimal.c: Use rb_num_coerce_????(x,y) instead of own.
- * eval.c (error_print): no class name print for anonymous class.
+Wed Aug 6 22:58:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
- * eval.c (rb_longjmp): proper exception raised if raise() called
- without arguments, with $! or $@ set.
+ * lib/test/unit/testcase.rb: Added equality checking.
+ * lib/test/unit/testsuite.rb: Added equality checking.
+ * lib/test/unit/assertions.rb: Fixed a warning.
- * object.c (Init_Object): superclass()'s method argument setting
- was wrong again.
+Wed Aug 6 17:28:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * class.c (mod_ancestors): list superclasses and included modules
- in priority order.
+ * ext/extmk.rb (extmake): pass LIBPATH to make ruby. [ruby-dev:21137]
-Mon Aug 25 11:53:11 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/extmk.rb (extmake): set library name as source file name in
+ Init_ext(). [ruby-dev:21137]
- * version 1.1 alpha2 released.
+ * lib/mkmf.rb (Logging::postpone): postpone logging messages after
+ heading message as the result of the block.
- * sample/ruby-mode.el (ruby-parse-region): auto-indent now
- supports "\\" in the strings.
+ * lib/mkmf.rb (macro_defined?): append newline to src unless ended
+ with it.
- * struct.c (struct_getmember): new API to get member value from C
- language side.
+ * lib/mkmf.rb (have_library): treat nil function name as "main".
+ (ruby-bugs:PR#1083)
-Sat Aug 23 21:39:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/mkmf.rb (pkg_config): should append additional libraries to
+ $libs but not $LIBS. [ruby-dev:21137]
- * parse.y (assignable): remove unnecessary local variable
- initialize by nil.
+ * ext/io/wait/extconf.rb: check DOSISH macro instead of platform.
-Fri Aug 22 14:26:40 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * ext/digest/sha1/extconf.rb: have_library already appends library
+ name.
- * eval.c (error_print): modified exception print format.
+Wed Aug 6 17:23:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Thu Aug 21 16:10:58 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c: initialize /* OK */ variables by Qnil to stop warnings.
- * sample/ruby-mode.el (ruby-calculate-indent): wrong indent level
- calculated with keyword operators.
+Wed Aug 6 04:58:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
-Thu Aug 21 11:36:58 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * ext/Setup*: add io/wait and openssl.
- * parse.y (arg): ary[0] += 1 cause SEGV
+Wed Aug 6 01:13:38 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Aug 20 17:28:50 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * eval.c (rb_f_autoload): use ruby_cbase instead of ruby_class.
- * ruby.c (ruby_process_options): require() all modules after
- processing all options
+ * eval.c (rb_f_autoload_p): ditto.
- * process.c (rb_proc_exec): more security checks added.
+ * class.c (rb_mod_init_copy): no longer implements independent
+ clone and dup methods. override "initialize_copy" instead.
+ [ruby-core:01352]
- * process.c (rb_proc_exec): insecure path on exec.
+ * object.c (rb_class_s_alloc): define Class allocation function.
+ this makes Classes to follow clone framework that uses
+ initialize_copy.
- * hash.c (f_getenv): PATH modification security check.
+ * object.c (rb_class_initialize): separate instantiation and
+ initialization.
-Tue Aug 19 00:15:38 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * object.c (rb_obj_alloc): prohibit instantiation from
+ uninitialized class.
- * version 1.1 alpha1 released.
+ * object.c (rb_class_superclass): check uninitialized class.
- * eval.c (mod_eval): work as normal eval() if second binding
- argument given.
+ * array.c (rb_ary_fill): wrong index processing with block. this
+ fix was done by Koji Arai <JCA02266@nifty.ne.jp> [ruby-list:38029]
- * eval.c (rb_call): did not raise ArgumentError if too many
- arguments more than optional arguments (without rest arg).
+ * marshal.c (w_object): should preserve generic ivar for nil,
+ true, false, symbols, and fixnums.
- * eval.c (rb_eval): did not work well for op_asgn2 (attribute
- self assignment).
+ * marshal.c (w_uclass): base_klass check should be done after
+ rb_class_real().
- * eval.c (Init_Thread): returns main thread.
+Wed Aug 6 01:18:50 2003 Minero Aoki <aamine@loveruby.net>
-Mon Aug 18 09:25:56 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/net/http.rb: update document.
- * object.c (inspect_i): did not display T_DATA instance variables.
+ * lib/net/pop.rb: ditto.
- * parse.y: provides more accurate line number information.
+ * lib/net/protocol.rb: ditto.
- * eval.c (thread_value): include value's backtrace information in
- the variable `$@'.
+Wed Aug 6 00:48:37 2003 Koji Arai <jca02266@nifty.ne.jp>
- * eval.c (f_abort): print backtrace and exit.
+ * marshal.c (w_object): should recommend marshal_dump rather than
+ _dump_data.
-Sat Aug 16 00:17:44 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+Tue Aug 5 17:58:57 2003 WATANABE Hirofumi <eban@ruby-lang.org>
- * eval.c (class_new_instance): do not make instance from virtual
- classes.
+ * lib/fileutils.rb (install): should preserve timestamp only.
- * object.c (class_s_new): do not make subclass of singleton class.
+Tue Aug 5 17:31:59 2003 Ian Macdonald <ian@caliban.org>
-Fri Aug 15 15:49:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * lib/shell/command-processor.rb (Shell::CommandProcessor::rmdir):
+ simple typo.
- * eval.c (call_trace_func): block context switch in the trace
- function.
+Tue Aug 5 15:47:34 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * eval.c (rb_eval): clear method cache at class extension.
+ * eval.c (rb_load): should preserve current source file/line.
- * object.c (obj_type): returns object's class even if it defines
- singleton methods.
+Tue Aug 5 10:04:42 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Fri Aug 15 19:40:43 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+ * string.c (str_new4): ptr may refer null_str.
- * ext/socket/socket.c (Init_socket): small typo caused SEGV.
+Mon Aug 4 17:25:18 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-Wed Aug 13 17:51:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+ * stable version 1.8.0 released.
- * version 1.1 alpha0 released.
+For the changes before 1.8.0, see doc/ChangeLog-1.8.0
+Local variables:
+add-log-time-format: (lambda ()
+ (let* ((time (current-time))
+ (diff (+ (cadr time) 32400))
+ (lo (% diff 65536))
+ (hi (+ (car time) (/ diff 65536))))
+ (format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t)))
+indent-tabs-mode: t
+tab-width: 8
+end:
diff --git a/GPL b/GPL
new file mode 100644
index 0000000000..5b6e7c66c2
--- /dev/null
+++ b/GPL
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/LEGAL b/LEGAL
new file mode 100644
index 0000000000..dce7c1acbf
--- /dev/null
+++ b/LEGAL
@@ -0,0 +1,371 @@
+LEGAL NOTICE INFORMATION
+------------------------
+
+All the files in this distribution are covered under either the Ruby's
+license (see the file COPYING) or public-domain except some files
+mentioned below.
+
+regex.[ch]:
+
+ These files are under LGPL. Treat them as LGPL says. (See the file
+ LGPL for details)
+
+ Extended regular expression matching and search library.
+ Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+
+ 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 LGPL. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto)
+ Last change: May 21, 1993 by t^2
+ removed gapped buffer support, multiple syntax support by matz <matz@nts.co.jp>
+ Perl5 extension added by matz <matz@caelum.co.jp>
+ UTF-8 extension added Jan 16 1999 by Yoshida Masato <yoshidam@tau.bekkoame.ne.jp>
+
+configure:
+
+ This file is free software.
+
+ Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+
+ This configure script is free software; the Free Software Foundation
+ gives unlimited permission to copy, distribute and modify it.
+
+config.guess:
+config.sub:
+parse.c:
+
+ As long as you distribute these files with the file configure, they
+ are covered under the Ruby's license.
+
+ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+ Free Software Foundation, Inc.
+
+ This file is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception to the GNU General Public License, if you
+ distribute this file as part of a program that contains a
+ configuration script generated by Autoconf, you may include it under
+ the same distribution terms that you use for the rest of that program.
+
+util.c (partly):
+win32/win32.[ch]:
+
+ You can apply the Artistic License to these files. (or GPL,
+ alternatively)
+
+ Copyright (c) 1993, Intergraph Corporation
+
+ You may distribute under the terms of either the GNU General Public
+ License or the Artistic License, as specified in the perl README file.
+
+random.c
+
+ This file is under the new-style BSD license.
+
+ A C-program for MT19937, with initialization improved 2002/2/10.
+ Coded by Takuji Nishimura and Makoto Matsumoto.
+ This is a faster version by taking Shawn Cokus's optimization,
+ Matthe Bellew's simplification, Isaku Wada's real version.
+
+ Before using, initialize the state by using init_genrand(seed)
+ or init_by_array(init_key, key_length).
+
+ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+ Any feedback is very welcome.
+ http://www.math.keio.ac.jp/matumoto/emt.html
+ email: matumoto@math.keio.ac.jp
+
+st.[ch]:
+x68/*:
+missing/alloca.c:
+missing/dup2.c:
+missing/erf.c:
+missing/finite.c:
+missing/hypot.c:
+missing/isinf.c:
+missing/isnan.c:
+missing/memcmp.c:
+missing/memmove.c:
+missing/mkdir.c:
+missing/strcasecmp.c:
+missing/strchr.c:
+missing/streror.c:
+missing/strftime.c:
+missing/strncasecmp.c:
+missing/strstr.c:
+missing/strtol.c:
+ext/digest/sha1/sha1.[ch]:
+
+ These files are all under public domain.
+
+missing/strtod.c:
+
+ This file will not be used on most platforms depending on how the
+ configure script results. In any case you must not receive any fee
+ with the file itself.
+
+ Copyright (c) 1988-1993 The Regents of the University of California.
+ Copyright (c) 1994 Sun Microsystems, Inc.
+
+ Permission to use, copy, modify, and distribute this
+ software and its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright
+ notice appear in all copies. The University of California
+ makes no representations about the suitability of this
+ software for any purpose. It is provided "as is" without
+ express or implied warranty.
+
+missing/strtoul.c:
+
+ This file will not be used on most platforms depending on how the
+ configure script results. In any case you must not receive any fee
+ with the file itself.
+
+ Copyright 1988 Regents of the University of California
+
+ Permission to use, copy, modify, and distribute this
+ software and its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright
+ notice appear in all copies. The University of California
+ makes no representations about the suitability of this
+ software for any purpose. It is provided "as is" without
+ express or implied warranty.
+
+missing/vsnprintf.c:
+
+ This file is under the old-style BSD license. Note that the
+ paragraph 3 below is now null and void.
+
+ Copyright (c) 1990, 1993
+ The Regents of the University of California. All rights reserved.
+
+ This code is derived from software contributed to Berkeley by
+ Chris Torek.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. All advertising materials mentioning features or use of this software
+ must display the following acknowledgement:
+ This product includes software developed by the University of
+ California, Berkeley and its contributors.
+ 4. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ IMPORTANT NOTE:
+ --------------
+ From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
+ paragraph 3 above is now null and void.
+
+ext/digest/md5/md5.[ch]:
+
+ These files are under the following license. Ruby uses modified
+ versions of them.
+
+ Copyright (C) 1999, 2000 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ext/digest/rmd160/rmd160.[ch]:
+
+ These files have the following copyright information, and by the
+ author we are allowed to use it under the new-style BSD license.
+
+ AUTHOR: Antoon Bosselaers, ESAT-COSIC
+ (Arranged for libc by Todd C. Miller)
+ DATE: 1 March 1996
+
+ Copyright (c) Katholieke Universiteit Leuven
+ 1996, All Rights Reserved
+
+ext/digest/rmd160/rmd160hl.c:
+ext/digest/sha1/sha1hl.c:
+
+ These files are under the beer-ware license.
+
+ "THE BEER-WARE LICENSE" (Revision 42):
+ <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
+ can do whatever you want with this stuff. If we meet some day, and you think
+ this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+
+ext/digest/sha2/sha2.[ch]:
+ext/digest/sha2/sha2hl.c:
+
+ These files are under the new-style BSD license.
+
+ Copyright 2000 Aaron D. Gifford. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holder nor the names of contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ext/nkf/nkf1.7/nkf.c:
+
+ This file is under the following license. So to speak, it is
+ copyrighted semi-public-domain software.
+
+ Copyright (C) 1987, Fujitsu LTD. (Itaru ICHIKAWA)
+ 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.
+
+ext/socket/addrinfo.h:
+ext/socket/getaddrinfo.c:
+ext/socket/getnameinfo.c:
+
+ These files are under the new-style BSD license.
+
+ Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the project nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ext/win32ole/win32ole.c:
+
+ You can apply the Artistic License to this file. (or GPL,
+ alternatively)
+
+ (c) 1995 Microsoft Corporation. All rights reserved.
+ Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
+
+ Other modifications Copyright (c) 1997, 1998 by Gurusamy Sarathy
+ <gsar@umich.edu> and Jan Dubois <jan.dubois@ibm.net>
+
+ You may distribute under the terms of either the GNU General Public
+ License or the Artistic License, as specified in the README file
+ of the Perl distribution.
diff --git a/LGPL b/LGPL
new file mode 100644
index 0000000000..b1e3f5a263
--- /dev/null
+++ b/LGPL
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index 17e8924bb7..0000000000
--- a/MANIFEST
+++ /dev/null
@@ -1,251 +0,0 @@
-COPYING
-COPYING.LIB
-ChangeLog
-MANIFEST
-Makefile.in
-README
-README.jp
-README.EXT
-README.EXT.jp
-ToDo
-array.c
-bignum.c
-class.c
-compar.c
-configure
-configure.in
-config.guess
-config.sub
-defines.h
-dir.c
-dln.c
-dln.h
-dmyext.c
-enum.c
-env.h
-error.c
-eval.c
-file.c
-gc.c
-hash.c
-inits.c
-install-sh
-instruby.rb
-intern.h
-io.c
-keywords
-lex.c
-main.c
-marshal.c
-math.c
-mkconfig.rb
-node.h
-numeric.c
-object.c
-pack.c
-parse.c
-parse.y
-prec.c
-process.c
-random.c
-range.c
-re.c
-re.h
-regex.c
-regex.h
-ruby.1
-ruby.c
-ruby.h
-rubyio.h
-rubysig.h
-rubytest.rb
-signal.c
-sprintf.c
-st.c
-st.h
-string.c
-struct.c
-time.c
-util.h
-util.c
-variable.c
-version.c
-version.h
-djgpp/README.djgpp
-djgpp/config.hin
-djgpp/config.sed
-djgpp/configure.bat
-djgpp/mkver.sed
-cygwin/GNUmakefile.in
-ext/Setup
-ext/Setup.dj
-ext/Setup.emx
-ext/Setup.x68
-ext/aix_mksym.rb
-ext/configsub.rb
-ext/extmk.rb.in
-lib/English.rb
-lib/Env.rb
-lib/README
-lib/base64.rb
-lib/cgi.rb
-lib/cgi/session.rb
-lib/cgi-lib.rb
-lib/complex.rb
-lib/date.rb
-lib/date2.rb
-lib/debug.rb
-lib/delegate.rb
-lib/e2mmap.rb
-lib/eregex.rb
-lib/find.rb
-lib/final.rb
-lib/finalize.rb
-lib/ftplib.rb
-lib/ftools.rb
-lib/getopts.rb
-lib/getoptlong.rb
-lib/importenv.rb
-lib/irb/completion.rb
-lib/irb/frame.rb
-lib/irb/input-method.rb
-lib/irb/irb.rb
-lib/irb/loader.rb
-lib/irb/main.rb
-lib/irb/multi-irb.rb
-lib/irb/ruby-lex.rb
-lib/irb/ruby-token.rb
-lib/irb/slex.rb
-lib/irb/version.rb
-lib/irb/workspace-binding-2.rb
-lib/irb/workspace-binding.rb
-lib/irb/xmp.rb
-lib/jcode.rb
-lib/mailread.rb
-lib/mathn.rb
-lib/matrix.rb
-lib/mkmf.rb
-lib/monitor.rb
-lib/mutex_m.rb
-lib/net/ftp.rb
-lib/net/http.rb
-lib/net/imap.rb
-lib/net/pop.rb
-lib/net/protocol.rb
-lib/net/smtp.rb
-lib/net/telnet.rb
-lib/observer.rb
-lib/open3.rb
-lib/ostruct.rb
-lib/parsearg.rb
-lib/parsedate.rb
-lib/ping.rb
-lib/profile.rb
-lib/pstore.rb
-lib/rational.rb
-lib/readbytes.rb
-lib/shellwords.rb
-lib/singleton.rb
-lib/sync.rb
-lib/telnet.rb
-lib/tempfile.rb
-lib/thread.rb
-lib/thwait.rb
-lib/timeout.rb
-lib/tracer.rb
-lib/weakref.rb
-misc/README
-misc/inf-ruby.el
-misc/ruby-mode.el
-misc/rubydb2x.el
-misc/rubydb3x.el
-missing/alloca.c
-missing/crypt.c
-missing/dir.h
-missing/dup2.c
-missing/file.h
-missing/finite.c
-missing/flock.c
-missing/isinf.c
-missing/isnan.c
-missing/memcmp.c
-missing/memmove.c
-missing/mkdir.c
-missing/os2.c
-missing/strcasecmp.c
-missing/strncasecmp.c
-missing/strchr.c
-missing/strdup.c
-missing/strerror.c
-missing/strftime.c
-missing/strstr.c
-missing/strtod.c
-missing/strtol.c
-missing/strtoul.c
-missing/vsnprintf.c
-missing/x68.c
-sample/README
-sample/biorhythm.rb
-sample/cal.rb
-sample/cbreak.rb
-sample/clnt.rb
-sample/dbmtest.rb
-sample/dir.rb
-sample/dualstack-fetch.rb
-sample/dualstack-httpd.rb
-sample/eval.rb
-sample/export.rb
-sample/exyacc.rb
-sample/fact.rb
-sample/fib.awk
-sample/fib.pl
-sample/fib.py
-sample/fib.rb
-sample/fib.scm
-sample/freq.rb
-sample/from.rb
-sample/fullpath.rb
-sample/getopts.test
-sample/goodfriday.rb
-sample/irb.rb
-sample/less.rb
-sample/list.rb
-sample/list2.rb
-sample/list3.rb
-sample/mine.rb
-sample/mkproto.rb
-sample/mpart.rb
-sample/mrshtest.rb
-sample/observ.rb
-sample/occur.pl
-sample/occur.rb
-sample/occur2.rb
-sample/philos.rb
-sample/pi.rb
-sample/rename.rb
-sample/rcs.awk
-sample/rcs.dat
-sample/rcs.rb
-sample/regx.rb
-sample/sieve.rb
-sample/svr.rb
-sample/test.rb
-sample/time.rb
-sample/trojan.rb
-sample/tsvr.rb
-sample/uumerge.rb
-win32/Makefile.sub
-win32/README.win32
-win32/config.h.in
-win32/config.status.in
-win32/configure.bat
-win32/mkexports.rb
-win32/resource.rb
-win32/setup.mak
-win32/win32.c
-win32/win32.h
-win32/winmain.c
-x68/fconvert.c
-x68/select.c
-x68/_dtos18.c
-x68/_round.c
diff --git a/Makefile.in b/Makefile.in
index 420bd3985b..663ba43111 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -12,15 +12,25 @@ AUTOCONF = autoconf
@SET_MAKE@
prefix = @prefix@
-CFLAGS = @CFLAGS@
-CPPFLAGS = -I. -I$(srcdir) -I@includedir@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+sbindir = @sbindir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+arch = @arch@
+sitearch = @sitearch@
+sitedir = @sitedir@
+
+CFLAGS = @CFLAGS@ @XCFLAGS@ @ARCH_FLAG@
+CPPFLAGS = -I. -I$(srcdir) @CPPFLAGS@
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
-XLDFLAGS = @XLDFLAGS@
+EXTLDFLAGS =
+XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
EXTLIBS =
LIBS = @LIBS@ $(EXTLIBS)
MISSING = @LIBOBJS@ @ALLOCA@
LDSHARED = @LIBRUBY_LDSHARED@
-DLDFLAGS = @LIBRUBY_DLDFLAGS@
+DLDFLAGS = @LIBRUBY_DLDFLAGS@ $(EXTLDFLAGS) @ARCH_FLAG@
SOLIBS = @SOLIBS@
MAINLIBS = @MAINLIBS@
@@ -28,6 +38,8 @@ RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
RUBY_SO_NAME=@RUBY_SO_NAME@
EXEEXT = @EXEEXT@
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
+RUBY = $(RUBY_INSTALL_NAME)
+MINIRUBY = @MINIRUBY@
#### End of system configuration section. ####
@@ -40,8 +52,16 @@ LIBRUBY_SO = @LIBRUBY_SO@
LIBRUBY_ALIASES= @LIBRUBY_ALIASES@
LIBRUBY = @LIBRUBY@
LIBRUBYARG = @LIBRUBYARG@
+LIBRUBYARG_STATIC = @LIBRUBYARG_STATIC@
+LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@
+
+PREP = @PREP@ @ARCHFILE@
+SETUP =
+EXTSTATIC = @EXTSTATIC@
EXTOBJS =
+DLDOBJS = $(DMYEXT)
+DMYEXT = dmyext.@OBJEXT@
MAINOBJ = main.@OBJEXT@
@@ -83,65 +103,123 @@ OBJS = array.@OBJEXT@ \
version.@OBJEXT@ \
$(MISSING)
-all: miniruby$(EXEEXT) @PREP@ rbconfig.rb $(LIBRUBY)
- @@MINIRUBY@ -Cext extmk.rb @EXTSTATIC@
+MANTYPE = @MANTYPE@
+
+SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
+ --make="$(MAKE)" \
+ --mflags="$(MFLAGS)" \
+ --make-flags="$(MAKEFLAGS)"
+
+all: @MAKEFILES@ miniruby$(EXEEXT) rbconfig.rb $(LIBRUBY)
+ @$(MINIRUBY) $(srcdir)/ext/extmk.rb --extstatic="$(EXTSTATIC)" $(SCRIPT_ARGS)
-miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) dmyext.@OBJEXT@
+miniruby$(EXEEXT): config.status $(LIBRUBY_A) $(MAINOBJ) $(DMYEXT)
@rm -f $@
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) dmyext.@OBJEXT@ $(LIBRUBY_A) $(LIBS) -o $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINLIBS) $(MAINOBJ) $(DMYEXT) $(LIBRUBY_A) $(LIBS) -o $@
-$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS)
+$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) $(SETUP) miniruby$(EXEEXT)
@rm -f $@
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
-$(LIBRUBY_A): $(OBJS) dmyext.@OBJEXT@
- @AR@ rcu $@ $(OBJS) dmyext.@OBJEXT@
+# We must `rm' the library each time this rule is invoked because "updating" a
+# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
+# supported.
+$(LIBRUBY_A): $(OBJS) $(DMYEXT)
+ @rm -f $@
+ @AR@ rcu $@ $(OBJS) $(DMYEXT)
@-@RANLIB@ $@ 2> /dev/null || true
-$(LIBRUBY_SO): $(OBJS) dmyext.@OBJEXT@
- $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.@OBJEXT@ $(SOLIBS) -o $@
- @-@MINIRUBY@ -e 'ARGV.each{|link| File.delete link if File.exist? link; \
+$(LIBRUBY_SO): $(OBJS) $(DLDOBJS) miniruby$(EXEEXT) $(PREP)
+ $(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) -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@ $(srcdir)/instruby.rb $(DESTDIR)
+ruby.imp: $(LIBRUBY_A)
+ @@NM@ -Pgp $(LIBRUBY_A) | awk 'BEGIN{print "#!"}; $$2~/^[BD]$$/{print $$1}' | sort -u -o $@
+# $(MINIRUBY) $< $@
+
+install: install-nodoc @RDOCTARGET@
+
+install-nodoc: rbconfig.rb
+ $(MINIRUBY) $(srcdir)/instruby.rb $(SCRIPT_ARGS) --mantype="$(MANTYPE)"
+ $(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) install
-clean:; @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) $(MAINOBJ) rbconfig.rb
+what-where no-install: rbconfig.rb
+ $(MINIRUBY) $(srcdir)/instruby.rb -n $(SCRIPT_ARGS) --mantype="$(MANTYPE)"
+ $(MINIRUBY) $(srcdir)/ext/extmk.rb -n $(SCRIPT_ARGS) install
+
+install-doc:
+ @echo Generating RDoc documentation
+ $(bindir)/$(PROGRAM) $(srcdir)/bin/rdoc --all --ri-system $(srcdir)
+
+clean-ext:
+ @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) clean 2> /dev/null || true
+
+clean-local:
+ @rm -f $(OBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES)
@rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@
- @-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true
@rm -f $(PROGRAM) miniruby$(EXEEXT)
-distclean: clean
- @rm -f Makefile ext/extmk.rb config.h
+clean: clean-ext clean-local
+
+distclean-ext:
+ @-$(MINIRUBY) $(srcdir)/ext/extmk.rb $(SCRIPT_ARGS) distclean 2> /dev/null || true
+
+distclean-local: clean-local
+ @rm -f @MAKEFILES@ config.h rbconfig.rb
@rm -f ext/config.cache config.cache config.log config.status
@rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp
-realclean: distclean
+distclean: distclean-ext distclean-local
+
+realclean: distclean
@rm -f parse.c
@rm -f lex.c
-test: miniruby$(EXEEXT)
+test: miniruby$(EXEEXT) rbconfig.rb $(PROGRAM) PHONY
@./miniruby$(EXEEXT) $(srcdir)/rubytest.rb
-rbconfig.rb: miniruby$(EXEEXT)
- @@MINIRUBY@ $(srcdir)/mkconfig.rb rbconfig.rb
+rbconfig.rb: miniruby$(EXEEXT) $(srcdir)/mkconfig.rb config.status $(PREP)
+ @$(MINIRUBY) $(srcdir)/mkconfig.rb rbconfig.rb
-fake.rb: miniruby$(EXEEXT)
+fake.rb: miniruby$(EXEEXT) Makefile
@echo ' \
class Object; \
+ CROSS_COMPILING = RUBY_PLATFORM; \
remove_const :RUBY_PLATFORM; \
+ remove_const :RUBY_VERSION; \
RUBY_PLATFORM = "@arch@"; \
- if defined? PLATFORM; \
- remove_const :PLATFORM; \
- PLATFORM = "@arch@"; \
+ RUBY_VERSION = "@MAJOR@.@MINOR@.@TEENY@"; \
+ end; \
+ if RUBY_PLATFORM =~ /mswin|bccwin|mingw/; \
+ class File; \
+ remove_const :ALT_SEPARATOR; \
+ ALT_SEPARATOR = "\\"; \
end; \
- CROSS_COMPILING = true; \
- end \
+ end; \
' > $@
+Makefile: $(srcdir)/Makefile.in
+
+.PRECIOUS: @MAKEFILES@
+
+.PHONY: test install install-nodoc install-doc
+
+PHONY:
+
+@MAKEFILES@: config.status
+ MAKE=$(MAKE) $(SHELL) ./config.status
+ @{ \
+ echo "all:; -@rm -f conftest.mk"; \
+ echo "conftest.mk: .force; @echo AUTO_REMAKE"; \
+ echo ".force:"; \
+ } > conftest.mk || exit 1; \
+ $(MAKE) -f conftest.mk | grep '^AUTO_REMAKE$$' >/dev/null 2>&1 || \
+ { echo "Makefile updated, restart."; exit 1; }
+
config.status: $(srcdir)/configure
- $(SHELL) ./config.status --recheck
+ MINIRUBY="$(MINIRUBY)" $(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in
cd $(srcdir) && $(AUTOCONF)
@@ -150,13 +228,20 @@ $(srcdir)/configure: $(srcdir)/configure.in
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
lex.c: keywords
- gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $(srcdir)/keywords > lex.c
+ @-rm -f $@
+ gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? > $@ || \
+ cp "$(srcdir)/$@" .
-parse.c: parse.y
+.y.c:
$(YACC) $<
- mv -f y.tab.c parse.c
+ sed '/^#/s|y\.tab\.c|$@|' y.tab.c > $@
+ rm -f y.tab.c
+
+ext/extinit.@OBJEXT@: ext/extinit.c $(SETUP)
+ $(CC) $(CFLAGS) $(CPPFLAGS) @OUTFLAG@$@ -c ext/extinit.c
-parse.@OBJEXT@: parse.c
+acosh.@OBJEXT@: $(srcdir)/missing/acosh.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/acosh.c
alloca.@OBJEXT@: $(srcdir)/missing/alloca.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/alloca.c
@@ -167,6 +252,9 @@ crypt.@OBJEXT@: $(srcdir)/missing/crypt.c
dup2.@OBJEXT@: $(srcdir)/missing/dup2.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/dup2.c
+fileblocks.@OBJEXT@: $(srcdir)/missing/fileblocks.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/fileblocks.c
+
finite.@OBJEXT@: $(srcdir)/missing/finite.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/finite.c
@@ -212,9 +300,6 @@ strftime.@OBJEXT@: $(srcdir)/missing/strftime.c
strstr.@OBJEXT@: $(srcdir)/missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strstr.c
-strtod.@OBJEXT@: $(srcdir)/missing/strtod.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtod.c
-
strtol.@OBJEXT@: $(srcdir)/missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/strtol.c
@@ -231,47 +316,65 @@ dl_os2.@OBJEXT@: $(srcdir)/missing/dl_os2.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/missing/dl_os2.c
win32.@OBJEXT@: $(srcdir)/win32/win32.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -I$(srcdir)/missing -c $(srcdir)/win32/win32.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -I$(srcdir)/win32 -c $(srcdir)/win32/win32.c
# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
###
-parse.@OBJEXT@: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
-###
-array.@OBJEXT@: array.c ruby.h config.h defines.h intern.h util.h st.h
-bignum.@OBJEXT@: bignum.c ruby.h config.h defines.h intern.h
-class.@OBJEXT@: class.c ruby.h config.h defines.h intern.h rubysig.h node.h st.h
-compar.@OBJEXT@: compar.c ruby.h config.h defines.h intern.h
-dir.@OBJEXT@: dir.c ruby.h config.h defines.h intern.h
-dln.@OBJEXT@: dln.c config.h defines.h dln.h
+array.@OBJEXT@: array.c ruby.h config.h defines.h intern.h missing.h \
+ util.h st.h
+bignum.@OBJEXT@: bignum.c ruby.h config.h defines.h intern.h missing.h
+class.@OBJEXT@: class.c ruby.h config.h defines.h intern.h missing.h \
+ rubysig.h node.h st.h
+compar.@OBJEXT@: compar.c ruby.h config.h defines.h intern.h missing.h
+dir.@OBJEXT@: dir.c ruby.h config.h defines.h intern.h missing.h util.h
+dln.@OBJEXT@: dln.c ruby.h config.h defines.h intern.h missing.h dln.h
dmyext.@OBJEXT@: dmyext.c
-enum.@OBJEXT@: enum.c ruby.h config.h defines.h intern.h node.h
-error.@OBJEXT@: error.c ruby.h config.h defines.h intern.h env.h version.h
-eval.@OBJEXT@: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h
-file.@OBJEXT@: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h dln.h
-gc.@OBJEXT@: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
-hash.@OBJEXT@: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.h
-inits.@OBJEXT@: inits.c ruby.h config.h defines.h intern.h
-io.@OBJEXT@: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h env.h util.h
-main.@OBJEXT@: main.c ruby.h config.h defines.h intern.h
-marshal.@OBJEXT@: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
-prec.@OBJEXT@: prec.c ruby.h config.h defines.h intern.h
-math.@OBJEXT@: math.c ruby.h config.h defines.h intern.h
-numeric.@OBJEXT@: numeric.c ruby.h config.h defines.h intern.h
-object.@OBJEXT@: object.c ruby.h config.h defines.h intern.h st.h
-pack.@OBJEXT@: pack.c ruby.h config.h defines.h intern.h
-process.@OBJEXT@: process.c ruby.h config.h defines.h intern.h rubysig.h st.h
-random.@OBJEXT@: random.c ruby.h config.h defines.h intern.h
-range.@OBJEXT@: range.c ruby.h config.h defines.h intern.h
-re.@OBJEXT@: re.c ruby.h config.h defines.h intern.h re.h regex.h
+enum.@OBJEXT@: enum.c ruby.h config.h defines.h intern.h missing.h node.h \
+ util.h
+error.@OBJEXT@: error.c ruby.h config.h defines.h intern.h missing.h \
+ env.h st.h
+eval.@OBJEXT@: eval.c ruby.h config.h defines.h intern.h missing.h node.h \
+ env.h util.h rubysig.h st.h dln.h
+file.@OBJEXT@: file.c ruby.h config.h defines.h intern.h missing.h \
+ rubyio.h rubysig.h util.h dln.h
+gc.@OBJEXT@: gc.c ruby.h config.h defines.h intern.h missing.h rubysig.h \
+ st.h node.h env.h re.h regex.h
+hash.@OBJEXT@: hash.c ruby.h config.h defines.h intern.h missing.h st.h \
+ util.h rubysig.h
+inits.@OBJEXT@: inits.c ruby.h config.h defines.h intern.h missing.h
+io.@OBJEXT@: io.c ruby.h config.h defines.h intern.h missing.h rubyio.h \
+ rubysig.h env.h util.h
+main.@OBJEXT@: main.c ruby.h config.h defines.h intern.h missing.h
+marshal.@OBJEXT@: marshal.c ruby.h config.h defines.h intern.h missing.h \
+ rubyio.h st.h util.h
+math.@OBJEXT@: math.c ruby.h config.h defines.h intern.h missing.h
+numeric.@OBJEXT@: numeric.c ruby.h config.h defines.h intern.h missing.h
+object.@OBJEXT@: object.c ruby.h config.h defines.h intern.h missing.h \
+ st.h util.h
+pack.@OBJEXT@: pack.c ruby.h config.h defines.h intern.h missing.h
+parse.@OBJEXT@: parse.c ruby.h config.h defines.h intern.h missing.h \
+ env.h node.h st.h regex.h util.h lex.c
+prec.@OBJEXT@: prec.c ruby.h config.h defines.h intern.h missing.h
+process.@OBJEXT@: process.c ruby.h config.h defines.h intern.h missing.h \
+ rubysig.h st.h
+random.@OBJEXT@: random.c ruby.h config.h defines.h intern.h missing.h
+range.@OBJEXT@: range.c ruby.h config.h defines.h intern.h missing.h
+re.@OBJEXT@: re.c ruby.h config.h defines.h intern.h missing.h re.h \
+ regex.h
regex.@OBJEXT@: regex.c config.h regex.h
-ruby.@OBJEXT@: ruby.c ruby.h config.h defines.h intern.h dln.h node.h util.h
-signal.@OBJEXT@: signal.c ruby.h config.h defines.h intern.h rubysig.h
-sprintf.@OBJEXT@: sprintf.c ruby.h config.h defines.h intern.h
+ruby.@OBJEXT@: ruby.c ruby.h config.h defines.h intern.h missing.h dln.h \
+ node.h util.h
+signal.@OBJEXT@: signal.c ruby.h config.h defines.h intern.h missing.h \
+ rubysig.h
+sprintf.@OBJEXT@: sprintf.c ruby.h config.h defines.h intern.h missing.h
st.@OBJEXT@: st.c config.h st.h
-string.@OBJEXT@: string.c ruby.h config.h defines.h intern.h re.h regex.h
-struct.@OBJEXT@: struct.c ruby.h config.h defines.h intern.h
-time.@OBJEXT@: time.c ruby.h config.h defines.h intern.h
-util.@OBJEXT@: util.c ruby.h config.h defines.h intern.h util.h
-variable.@OBJEXT@: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h
-version.@OBJEXT@: version.c ruby.h config.h defines.h intern.h version.h
+string.@OBJEXT@: string.c ruby.h config.h defines.h intern.h missing.h \
+ re.h regex.h
+struct.@OBJEXT@: struct.c ruby.h config.h defines.h intern.h missing.h
+time.@OBJEXT@: time.c ruby.h config.h defines.h intern.h missing.h
+util.@OBJEXT@: util.c ruby.h config.h defines.h intern.h missing.h util.h
+variable.@OBJEXT@: variable.c ruby.h config.h defines.h intern.h \
+ missing.h env.h node.h st.h util.h
+version.@OBJEXT@: version.c ruby.h config.h defines.h intern.h missing.h \
+ version.h
diff --git a/README b/README
index 83a88e1359..bde22dff78 100644
--- a/README
+++ b/README
@@ -5,6 +5,7 @@ easy object-oriented programming. It has many features to
process text files and to do system management tasks (as in
Perl). It is simple, straight-forward, and extensible.
+
* Features of Ruby
+ Simple Syntax
@@ -18,18 +19,27 @@ Perl). It is simple, straight-forward, and extensible.
+ Highly Portable(works on many UNIX machines, and on DOS,
Windows, Mac, BeOS etc.)
+
* How to get Ruby
The Ruby distribution can be found on:
- ftp://ftp.netlab.co.jp/pub/lang/ruby/
+ ftp://ftp.ruby-lang.org/pub/ruby/
You can get it by anonymous CVS. How to check out is:
- $ cvs -d :pserver:anonymous@cvs.ruby-lang.org:/home/cvs login
+ $ cvs -d :pserver:anonymous@cvs.ruby-lang.org:/src login
(Logging in to anonymous@cvs.ruby-lang.org)
- CVS password: guest
- $ cvs -d :pserver:anonymous@cvs.ruby-lang.org:/home/cvs checkout ruby
+ CVS password: anonymous
+ $ cvs -z4 -d :pserver:anonymous@cvs.ruby-lang.org:/src checkout ruby
+
+
+* Ruby home-page
+
+The URL of the Ruby home-page is:
+
+ http://www.ruby-lang.org/
+
* Mailing list
@@ -42,6 +52,7 @@ e.g.
in the mail body (not subject) to the address <ruby-talk-ctl@ruby-lang.org>.
+
* How to compile and install
This is what you need to do to compile and install Ruby:
@@ -75,78 +86,18 @@ This is what you need to do to compile and install Ruby:
If you fail to compile ruby, please send the detailed error report with
the error log and machine/OS type, to help others.
-* Copying
-
-Ruby is copyrighted free software by Yukihiro Matsumoto <matz@zetabits.com>.
-You can redistribute it and/or modify it under either the terms of the GPL
-(see COPYING file), or the conditions below:
-
- 1. You may make and give away verbatim copies of the source form of the
- software without restriction, provided that you duplicate all of the
- original copyright notices and associated disclaimers.
-
- 2. You may modify your copy of the software in any way, provided that
- you do at least ONE of the following:
-
- a) place your modifications in the Public Domain or otherwise
- make them Freely Available, such as by posting said
- modifications to Usenet or an equivalent medium, or by allowing
- the author to include your modifications in the software.
- b) use the modified software only within your corporation or
- organization.
-
- c) rename any non-standard executables so the names do not conflict
- with standard executables, which must also be provided.
-
- d) make other distribution arrangements with the author.
-
- 3. You may distribute the software in object code or executable
- form, provided that you do at least ONE of the following:
-
- a) distribute the executables and library files of the software,
- together with instructions (in the manual page or equivalent)
- on where to get the original distribution.
-
- b) accompany the distribution with the machine-readable source of
- the software.
-
- c) give non-standard executables non-standard names, with
- instructions on where to get the original software distribution.
-
- d) make other distribution arrangements with the author.
-
- 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], 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
- copyright of the software, but belong to whomever generated them,
- and may be sold commercially, and may be aggregated with this
- software.
-
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE.
-
-* Ruby home-page
+* Copying
-The URL of the Ruby home-page is:
+See the file COPYING.
- http://www.ruby-lang.org/
* The Author
Feel free to send comments and bug reports to the author. Here is the
author's latest mail address:
- matz@zetabits.com
+ matz@netlab.jp
-------------------------------------------------------
created at: Thu Aug 3 11:57:36 JST 1995
diff --git a/README.EXT b/README.EXT
index 5079adb558..d832d1e0af 100644
--- a/README.EXT
+++ b/README.EXT
@@ -5,23 +5,23 @@ This document explains how to make extension libraries for Ruby.
1. Basic knowledge
In C, variables have types and data do not have types. In contrast,
-Ruby variables do not have static type and data themselves have
-types. So, data need to be converted across the languages.
+Ruby variables do not have a static type, and data themselves have
+types, so data will need to be converted between the languages.
-Data in Ruby represented C type `VALUE'. Each VALUE data have its
-data-type.
+Data in Ruby are represented by C type `VALUE'. Each VALUE data has
+its data-type.
-To retrieve an C data from the VALUE, you need to:
+To retrieve C data from a VALUE, you need to:
- (1) Identify VALUE's data type
- (2) Convert VALUE into C data
+ (1) Identify the VALUE's data type
+ (2) Convert the VALUE into C data
-Converting to wrong data type may cause serious problems.
+Converting to the wrong data type may cause serious problems.
1.1 Data-types
-Ruby interpreter has data-types as below:
+The Ruby interpreter has the following data types:
T_NIL nil
T_OBJECT ordinary object
@@ -35,12 +35,13 @@ Ruby interpreter has data-types as below:
T_HASH associative array
T_STRUCT (Ruby) structure
T_BIGNUM multi precision integer
+ T_FILE IO
T_TRUE true
T_FALSE false
T_DATA data
T_SYMBOL symbol
-Otherwise, there are several other types used internally:
+In addition, there are several other types used internally:
T_ICLASS
T_MATCH
@@ -53,9 +54,9 @@ Most of the types are represented by C structures.
1.2 Check Data Type of the VALUE
-The macro TYPE() defined in ruby.h shows data-type of the VALUE.
+The macro TYPE() defined in ruby.h shows the data type of the VALUE.
TYPE() returns the constant number T_XXXX described above. To handle
-data-types, the code will be like:
+data types, your code will look something like this:
switch (TYPE(obj)) {
case T_FIXNUM:
@@ -73,13 +74,13 @@ data-types, the code will be like:
break;
}
-There is the data-type check function.
+There is the data-type check function
void Check_Type(VALUE value, int type)
-It raises an exception, if the VALUE does not have the type specified.
+which raises an exception if the VALUE does not have the type specified.
-There are faster check-macros for fixnums and nil.
+There are also faster check macros for fixnums and nil.
FIXNUM_P(obj)
NIL_P(obj)
@@ -89,29 +90,43 @@ There are faster check-macros for fixnums and nil.
The data for type T_NIL, T_FALSE, T_TRUE are nil, true, false
respectively. They are singletons for the data type.
-The T_FIXNUM data is the 31bit length fixed integer (63bit length on
-some machines), which can be convert to the C integer by using
-FIX2INT() macro. There also be NUM2INT() which converts any Ruby
-numbers into C integer. The NUM2INT() macro includes type check, so
-the exception will be raised if conversion failed.
+The T_FIXNUM data is a 31bit length fixed integer (63bit length on
+some machines), which can be convert to a C integer by using the
+FIX2INT() macro. There is also NUM2INT() which converts any Ruby
+numbers into C integers. The NUM2INT() macro includes a type check, so
+an exception will be raised if the conversion failed. NUM2DBL() can
+be used to retrieve the double float value in same way.
+
+To get char* from a VALUE, version 1.7 recommend to use new macros
+StringValue() and StringValuePtr(). StringValue(var) replaces var's
+value to the result of "var.to_str()". StringValuePtr(var) does same
+replacement and returns char* representation of var. These macros
+will skip the replacement if var is a String. Notice that the macros
+requires to take only lvalue as their argument, to change the value
+of var in the replacement.
+
+In version 1.6 or earlier, STR2CSTR() was used to do same thing
+but now it is obsoleted in version 1.7 because of STR2CSTR() has
+a risk of dangling pointer problem in to_str() impliclit conversion.
Other data types have corresponding C structures, e.g. struct RArray
-for T_ARRAY etc. VALUE of the type which has corresponding structure
+for T_ARRAY etc. The VALUE of the type which has corresponding structure
can be cast to retrieve the pointer to the struct. The casting macro
-RXXXX for each data type like RARRAY(obj). see "ruby.h".
+will be of the form RXXXX for each data type; for instance, RARRAY(obj).
+See "ruby.h".
-For example, `RSTRING(size)->len' is the way to get the size of the
+For example, `RSTRING(str)->len' is the way to get the size of the
Ruby String object. The allocated region can be accessed by
-`RSTRING(str)->ptr'. For arrays, `RARRAY(ary)->len' and
+`RSTRING(str)->ptr'. For arrays, use `RARRAY(ary)->len' and
`RARRAY(ary)->ptr' respectively.
Notice: Do not change the value of the structure directly, unless you
-are responsible about the result. It will be the cause of interesting
+are responsible for the result. This ends up being the cause of interesting
bugs.
1.4 Convert C data into VALUE
-To convert C data to the values of Ruby:
+To convert C data to Ruby values:
* FIXNUM
@@ -121,25 +136,25 @@ To convert C data to the values of Ruby:
cast to VALUE.
-You can determine whether VALUE is pointer or not, by checking LSB.
+You can determine whether a VALUE is pointer or not by checking its LSB.
-Notice Ruby does not allow arbitrary pointer value to be VALUE. They
-should be pointers to the structures which Ruby knows. The known
+Notice Ruby does not allow arbitrary pointer values to be a VALUE. They
+should be pointers to the structures which Ruby knows about. The known
structures are defined in <ruby.h>.
-To convert C numbers to Ruby value, use these macros.
+To convert C numbers to Ruby values, use these macros.
INT2FIX() for integers within 31bits.
INT2NUM() for arbitrary sized integer.
-INT2NUM() converts integers into Bignums, if it is out of FIXNUM
-range, but bit slower.
+INT2NUM() converts an integer into a Bignum if it is out of the FIXNUM
+range, but is a bit slower.
-1.5 Manipulate Ruby data
+1.5 Manipulating Ruby data
-As I already told, it is not recommended to modify object's internal
-structure. To manipulate objects, use functions supplied by Ruby
-interpreter. Useful functions are listed below (not all):
+As I already mentioned, it is not recommended to modify an object's internal
+structure. To manipulate objects, use the functions supplied by the Ruby
+interpreter. Some (not all) of the useful functions are listed below:
String functions
@@ -149,40 +164,40 @@ interpreter. Useful functions are listed below (not all):
rb_str_new2(const char *ptr)
- Creates a new Ruby string from C string. This is equivalent to
+ Creates a new Ruby string from a C string. This is equivalent to
rb_str_new(ptr, strlen(ptr)).
rb_tainted_str_new(const char *ptr, long len)
Creates a new tainted Ruby string. Strings from external data
- should be tainted.
+ sources should be tainted.
rb_tainted_str_new2(const char *ptr)
- Creates a new tainted Ruby string from C string.
+ Creates a new tainted Ruby string from a C string.
rb_str_cat(VALUE str, const char *ptr, long len)
- Appends len bytes data from ptr to the Ruby string.
+ Appends len bytes of data from ptr to the Ruby string.
Array functions
rb_ary_new()
- Creates an array with no element.
+ Creates an array with no elements.
rb_ary_new2(long len)
- Creates an array with no element, with allocating internal buffer
+ Creates an array with no elements, allocating internal buffer
for len elements.
rb_ary_new3(long n, ...)
- Creates an n-elements array from arguments.
+ Creates an n-element array from the arguments.
rb_ary_new4(long n, VALUE *elts)
- Creates an n-elements array from C array.
+ Creates an n-element array from a C array.
rb_ary_push(VALUE ary, VALUE val)
rb_ary_pop(VALUE ary)
@@ -192,12 +207,12 @@ interpreter. Useful functions are listed below (not all):
Array operations. The first argument to each functions must be an
array. They may dump core if other types given.
-2. Extend Ruby with C
+2. Extending Ruby with C
-2.1 Add new features to Ruby
+2.1 Addding new features to Ruby
You can add new features (classes, methods, etc.) to the Ruby
-interpreter. Ruby provides the API to define things below:
+interpreter. Ruby provides APIs for defining the following things:
* Classes, Modules
* Methods, Singleton Methods
@@ -205,22 +220,22 @@ interpreter. Ruby provides the API to define things below:
2.1.1 Class/module definition
-To define class or module, use functions below:
+To define a class or module, use the functions below:
VALUE rb_define_class(const char *name, VALUE super)
VALUE rb_define_module(const char *name)
These functions return the newly created class or module. You may
-want to save this reference into the variable to use later.
+want to save this reference into a variable to use later.
-To define nested class or module, use functions below:
+To define nested classes or modules, use the functions below:
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
VALUE rb_define_module_under(VALUE outer, const char *name)
2.1.2 Method/singleton method definition
-To define methods or singleton methods, use functions below:
+To define methods or singleton methods, use these functions:
void rb_define_method(VALUE klass, const char *name,
VALUE (*func)(), int argc)
@@ -231,17 +246,17 @@ To define methods or singleton methods, use functions below:
The `argc' represents the number of the arguments to the C function,
which must be less than 17. But I believe you don't need that much. :-)
-If `argc' is negative, it specifies calling sequence, not number of
+If `argc' is negative, it specifies the calling sequence, not number of
the arguments.
-If argc is -1, the function will be called like:
+If argc is -1, the function will be called as:
VALUE func(int argc, VALUE *argv, VALUE obj)
where argc is the actual number of arguments, argv is the C array of
the arguments, and obj is the receiver.
-if argc is -2, the arguments are passed in Ruby array. The function
+If argc is -2, the arguments are passed in a Ruby array. The function
will be called like:
VALUE func(VALUE obj, VALUE args)
@@ -249,14 +264,14 @@ will be called like:
where obj is the receiver, and args is the Ruby array containing
actual arguments.
-There're two more functions to define method. One is to define
-private method:
+There are two more functions to define methods. One is to define
+private methods:
void rb_define_private_method(VALUE klass, const char *name,
VALUE (*func)(), int argc)
-The other is to define module function, which is private AND singleton
-method of the module. For example, sqrt is the module function
+The other is to define module functions, which are private AND singleton
+methods of the module. For example, sqrt is the module function
defined in Math module. It can be call in the form like:
Math.sqrt(4)
@@ -266,13 +281,13 @@ or
include Math
sqrt(4)
-To define module function
+To define module functions, use:
void rb_define_module_function(VALUE module, const char *name,
VALUE (*func)(), int argc)
-Oh, in addition, function-like method, which is private method defined
-in Kernel module, can be defined using:
+Oh, in addition, function-like methods, which are private methods defined
+in the Kernel module, can be defined using:
void rb_define_global_function(const char *name, VALUE (*func)(), int argc)
@@ -287,33 +302,33 @@ We have 2 functions to define constants:
void rb_define_const(VALUE klass, const char *name, VALUE val)
void rb_define_global_const(const char *name, VALUE val)
-The former is to define constant under specified class/module. The
-latter is to define global constant.
+The former is to define a constant under specified class/module. The
+latter is to define a global constant.
2.2 Use Ruby features from C
There are several ways to invoke Ruby's features from C code.
-2.2.1 Evaluate Ruby Program in String
+2.2.1 Evaluate Ruby Programs in a String
-Easiest way to call Ruby's function from C program is to evaluate the
-string as Ruby program. This function will do the job.
+The easiest way to use Ruby's functionality from a C program is to
+evaluate the string as Ruby program. This function will do the job.
VALUE rb_eval_string(const char *str)
-Evaluation is done under current context, thus current local variables
+Evaluation is done under the current context, thus current local variables
of the innermost method (which is defined by Ruby) can be accessed.
2.2.2 ID or Symbol
You can invoke methods directly, without parsing the string. First I
-need to explain about symbols (which data type is ID). ID is the
+need to explain about symbols (whose data type is ID). ID is the
integer number to represent Ruby's identifiers such as variable names.
-It can be accessed from Ruby in the form like:
+It can be accessed from Ruby in the form:
:Identifier
-You can get the symbol value from string within C code, by using
+You can get the symbol value from a string within C code by using
rb_intern(const char *name)
@@ -323,13 +338,13 @@ To invoke methods directly, you can use the function below
VALUE rb_funcall(VALUE recv, ID mid, int argc, ...)
-This function invokes the method of the recv, which name is specified
-by the symbol mid.
+This function invokes a method on the recv, with the method name
+specified by the symbol mid.
2.2.4 Accessing the variables and constants
-You can access class variables, and instance variables using access
-functions. Also, global variables can be shared between both worlds.
+You can access class variables and instance variables using access
+functions. Also, global variables can be shared between both environments.
There's no way to access Ruby's local variables.
The functions to access/modify instance variables are below:
@@ -347,14 +362,14 @@ See 2.1.3 for defining new constant.
3. Information sharing between Ruby and C
-3.1 Ruby constant that C can be accessed from C
+3.1 Ruby constants that C can be accessed from C
-Following Ruby constants can be referred from C.
+The following Ruby constants can be referred from C.
Qtrue
Qfalse
-Boolean values. Qfalse is false in the C also (i.e. 0).
+Boolean values. Qfalse is false in C also (i.e. 0).
Qnil
@@ -362,16 +377,16 @@ Ruby nil in C scope.
3.2 Global variables shared between C and Ruby
-Information can be shared between two worlds, using shared global
+Information can be shared between the two environments using shared global
variables. To define them, you can use functions listed below:
void rb_define_variable(const char *name, VALUE *var)
-This function defines the variable which is shared by the both world.
-The value of the global variable pointed by `var', can be accessed
+This function defines the variable which is shared by both environments.
+The value of the global variable pointed to by `var' can be accessed
through Ruby's global variable named `name'.
-You can define read-only (from Ruby, of course) variable by the
+You can define read-only (from Ruby, of course) variables using the
function below.
void rb_define_readonly_variable(const char *name, VALUE *var)
@@ -389,17 +404,17 @@ works just like rb_define_variable().
void rb_define_virtual_variable(const char *name,
VALUE (*getter)(), void (*setter)())
-This function defines the Ruby global variable without corresponding C
+This function defines a Ruby global variable without a 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:
+The prototypes of the getter and setter functions are as follows:
(*getter)(ID id, void *data, struct global_entry* entry);
(*setter)(VALUE val, ID id, void *data, struct global_entry* entry);
3.3 Encapsulate C data into Ruby object
-To wrapping and objectify the C pointer as Ruby object (so called
+To wrap and objectify a C pointer as a Ruby object (so called
DATA), use Data_Wrap_Struct().
Data_Wrap_Struct(klass, mark, free, ptr)
@@ -407,8 +422,9 @@ DATA), use Data_Wrap_Struct().
Data_Wrap_Struct() returns a created DATA object. The klass 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.
+function to free the pointer allocation. If this is -1, the pointer
+will be just freed. The functions mark and free will be called from
+garbage collector.
You can allocate and wrap the structure in one step.
@@ -419,23 +435,23 @@ the structure, which is also allocated. This macro works like:
(sval = ALLOC(type), Data_Wrap_Struct(klass, mark, free, sval))
-Arguments, klass, mark, free, works like their counterpart of
-Data_Wrap_Struct(). The pointer to allocated structure will be
-assigned to sval, which should be the pointer to the type specified.
+Arguments klass, mark, and free work like their counterparts in
+Data_Wrap_Struct(). A pointer to the allocated structure will be
+assigned to sval, which should be a pointer of the type specified.
To retrieve the C pointer from the Data object, use the macro
Data_Get_Struct().
Data_Get_Struct(obj, type, sval)
-The pointer to the structure will be assigned to the variable sval.
+A pointer to the structure will be assigned to the variable sval.
-See example below for detail.
+See the example below for details.
4. Example - Creating dbm extension
-OK, here's the example to make extension library. This is the
-extension to access dbm. The full source is included in ext/
+OK, here's the example of making an extension library. This is the
+extension to access DBMs. The full source is included in the ext/
directory in the Ruby's source tree.
(1) make the directory
@@ -444,25 +460,17 @@ directory in the Ruby's source tree.
Make a directory for the extension library under ext directory.
-(2) create MANIFEST file
-
- % cd ext/dbm
- % touch MANIFEST
-
-There should be MANIFEST file in the directory for the extension
-library. Make empty file now.
-
-(3) design the library
+(2) design the library
You need to design the library features, before making it.
-(4) write C code.
+(3) write C code.
You need to write C code for your extension library. If your library
has only one source file, choosing ``LIBRARY.c'' as a file name is
-preferred. On the other hand, in case your library has plural source
+preferred. On the other hand, in case your library has multiple source
files, avoid choosing ``LIBRARY.c'' for a file name. It may conflict
-with intermediate file ``LIBRARY.o'' on some platforms.
+with an intermediate file ``LIBRARY.o'' on some platforms.
Ruby will execute the initializing function named ``Init_LIBRARY'' in
the library. For example, ``Init_dbm()'' will be executed when loading
@@ -487,10 +495,13 @@ Init_dbm()
rb_define_method(cDBM, "[]", fdbm_fetch, 1);
:
+ /* ID for a instance variable to store DBM data */
+ id_dbm = rb_intern("dbm");
}
--
-The dbm extension wrap dbm struct in C world using Data_Make_Struct.
+The dbm extension wraps the dbm struct in the C environment using
+Data_Make_Struct.
--
struct dbmdata {
@@ -502,10 +513,11 @@ struct dbmdata {
obj = Data_Make_Struct(klass, struct dbmdata, 0, free_dbm, dbmp);
--
-This code wraps dbmdata structure into Ruby object. We avoid wrapping
+This code wraps the dbmdata structure into a Ruby object. We avoid wrapping
DBM* directly, because we want to cache size information.
-To retrieve dbmdata structure from Ruby object, we define the macro below:
+To retrieve the dbmdata structure from a Ruby object, we define the
+following macro:
--
#define GetDBM(obj, dbmp) {\
@@ -514,11 +526,11 @@ To retrieve dbmdata structure from Ruby object, we define the macro below:
}
--
-This sort of complicated macro do the retrieving and close check for
+This sort of complicated macro does the retrieving and close checking for
the DBM.
-There are three kind of way to receiving method arguments. First, the
-methods with fixed number of arguments receives arguments like this:
+There are three kinds of way to receive method arguments. First,
+methods with a fixed number of arguments receive arguments like this:
--
static VALUE
@@ -532,7 +544,7 @@ fdbm_delete(obj, keystr)
The first argument of the C function is the self, the rest are the
arguments to the method.
-Second, the methods with arbitrary number of arguments receives
+Second, methods with an arbitrary number of arguments receive
arguments like this:
--
@@ -550,15 +562,15 @@ fdbm_s_open(argc, argv, klass)
}
--
-The first argument is the number of method arguments. the second
-argument is the C array of the method arguments. And the third
+The first argument is the number of method arguments, the second
+argument is the C array of the method arguments, and the third
argument is the receiver of the method.
You can use the function rb_scan_args() to check and retrieve the
-arguments. For example "11" means, the method requires at least one
+arguments. For example, "11" means that the method requires at least one
argument, and at most receives two arguments.
-The methods with arbitrary number of arguments can receives arguments
+Methods with an arbitrary number of arguments can receive arguments
by Ruby's array, like this:
--
@@ -575,86 +587,77 @@ which contains the arguments to the method.
** Notice
-GC should know about global variables which refers Ruby's objects, but
-not exported to the Ruby world. You need to protect them by
+GC should know about global variables which refer to Ruby's objects, but
+are not exported to the Ruby world. You need to protect them by
void rb_global_variable(VALUE *var)
-(5) prepare extconf.rb
+(4) prepare extconf.rb
-If there exists the file named extconf.rb, it will be executed to
-generate Makefile. If not, compilation scheme try to generate
-Makefile anyway.
+If the file named extconf.rb exists, it will be executed to generate
+Makefile. If not, the compilation scheme will try to generate Makefile
+anyway.
-The extconf.rb is the file to check compilation condition etc. You
+extconf.rb is the file for check compilation conditions etc. You
need to put
require 'mkmf'
-at the top of the file. You can use the functions below to check the
-condition.
+at the top of the file. You can use the functions below to check
+various conditions.
have_library(lib, func): check whether library containing function exists.
have_func(func, header): check whether function exists
have_header(header): check whether header file exists
create_makefile(target): generate Makefile
-The value of variables below will affect Makefile.
+The value of the variables below will affect the Makefile.
$CFLAGS: included in CFLAGS make variable (such as -I)
$LDFLAGS: included in LDFLAGS make variable (such as -L)
-If compilation condition is not fulfilled, you do not call
-``create_makefile''. Makefile will not generated, compilation will
+If a compilation condition is not fulfilled, you should not call
+``create_makefile''. The Makefile will not generated, compilation will
not be done.
-(6) prepare depend (optional)
+(5) prepare depend (optional)
If the file named depend exists, Makefile will include that file to
-check dependency. You can make this file by invoking
+check dependencies. You can make this file by invoking
% gcc -MM *.c > depend
It's no harm. Prepare it.
-(7) put file names into MANIFEST (optional)
-
- % find * -type f -print > MANIFEST
- % vi 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.
+(6) generate Makefile
-(8) generate Makefile
-
-Try generate Makefile by:
+Try generating the Makefile by:
ruby extconf.rb
-You don't need this step, if you put extension library under ext
+You don't need this step if you put the extension library under the ext
directory of the ruby source tree. In that case, compilation of the
interpreter will do this step for you.
-(9) make
+(7) make
Type
make
-to compile your extension. You don't need this step neither, if you
-put extension library under ext directory of the ruby source tree.
+to compile your extension. You don't need this step either if you have
+put extension library under the ext directory of the ruby source tree.
-(9) debug
+(8) debug
-You may need to rb_debug the extension. The extensions can be linked
-statically by adding directory name in the ext/Setup file, so that you
-can inspect the extension with the debugger.
+You may need to rb_debug the extension. Extensions can be linked
+statically by the adding directory name in the ext/Setup file so that
+you can inspect the extension with the debugger.
-(10) done, now you have the extension library
+(9) done, now you have the extension library
You can do anything you want with your library. The author of Ruby
-will not claim any restriction about your code depending Ruby API.
+will not claim any restrictions on your code depending on the Ruby API.
Feel free to use, modify, distribute or sell your program.
Appendix A. Ruby source files overview
@@ -715,7 +718,7 @@ Appendix B. Ruby extension API reference
VALUE
-The type for Ruby object. Actual structures are defined in ruby.h,
+The type for the Ruby object. Actual structures are defined in ruby.h,
such as struct RString, etc. To refer the values in structures, use
casting macros like RSTRING(obj).
@@ -737,10 +740,11 @@ const: false object
Data_Wrap_Struct(VALUE klass, void (*mark)(), void (*free)(), void *sval)
-Wrap C pointer into Ruby object. If object has references to other
-Ruby object, they should be marked by using mark function during GC
-process. Otherwise, mark should be 0. When this object is no longer
-referred by anywhere, the pointer will be discarded by free function.
+Wrap a C pointer into a Ruby object. If object has references to other
+Ruby objects, they should be marked by using the mark function during
+the GC process. Otherwise, mark should be 0. When this object is no
+longer referred by anywhere, the pointer will be discarded by free
+function.
Data_Make_Struct(klass, type, mark, free, sval)
@@ -752,40 +756,59 @@ sval, and returns the DATA encapsulating the pointer to memory region.
This macro retrieves the pointer value from DATA, and assigns it to
the variable sval.
+** Checking data types
+
+TYPE(value)
+FIXNUM_P(value)
+NIL_P(value)
+void Check_Type(VALUE value, int type)
+void Check_SafeStr(VALUE value)
+
+** Data type conversion
+
+FIX2INT(value)
+INT2FIX(i)
+NUM2INT(value)
+INT2NUM(i)
+NUM2DBL(value)
+rb_float_new(f)
+STR2CSTR(value)
+rb_str_new2(s)
+
** defining class/module
VALUE rb_define_class(const char *name, VALUE super)
-Defines new Ruby class as subclass of super.
+Defines a new Ruby class as a subclass of super.
VALUE rb_define_class_under(VALUE module, const char *name, VALUE super)
-Creates new Ruby class as subclass of super, under the module's
+Creates a new Ruby class as a subclass of super, under the module's
namespace.
VALUE rb_define_module(const char *name)
-Defines new Ruby module.
+Defines a new Ruby module.
- VALUE rb_define_module_under(VALUE module, const char *name, VALUE super)
+ VALUE rb_define_module_under(VALUE module, const char *name)
-Defines new Ruby module, under the module's namespace.
+Defines a new Ruby module under the module's namespace.
void rb_include_module(VALUE klass, VALUE module)
Includes module into class. If class already includes it, just
-ignore.
+ignored.
void rb_extend_object(VALUE object, VALUE module)
-Extend the object with module's attribute.
+Extend the object with the module's attributes.
** Defining Global Variables
void rb_define_variable(const char *name, VALUE *var)
Defines a global variable which is shared between C and Ruby. If name
-contains the character which is not allowed to be part of the symbol,
+contains a character which is not allowed to be part of the symbol,
it can't be seen from Ruby programs.
void rb_define_readonly_variable(const char *name, VALUE *var)
@@ -796,7 +819,7 @@ rb_define_variable(), except defined variable is read-only.
void rb_define_virtual_variable(const char *name,
VALUE (*getter)(), VALUE (*setter)())
-Defines a virtual variable, whose behavior is defined by pair of C
+Defines a virtual variable, whose behavior is defined by a pair of C
functions. The getter function is called when the variable is
referred. The setter function is called when the value is set to the
variable. The prototype for getter/setter functions are:
@@ -809,16 +832,16 @@ The getter function must return the value for the access.
void rb_define_hooked_variable(const char *name, VALUE *var,
VALUE (*getter)(), VALUE (*setter)())
-Defines hooked variable. It's virtual variable with C variable. The
-getter is called as
+Defines hooked variable. It's a virtual variable with a C variable.
+The getter is called as
VALUE getter(ID id, VALUE *var)
-returning new value. The setter is called as
+returning a new value. The setter is called as
void setter(VALUE val, ID id, VALUE *var)
-GC requires to mark the C global variables which hold Ruby values.
+GC requires C global variables which hold Ruby values to be marked.
void rb_global_variable(VALUE *var)
@@ -832,7 +855,7 @@ Defines a new constant under the class/module.
void rb_define_global_const(const char *name, VALUE val)
-Defines global constant. This is just work as
+Defines a global constant. This is just the same as
rb_define_const(cKernal, name, val)
@@ -842,8 +865,8 @@ Defines global constant. This is just work as
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
+3 arguments: argc, argv, and self. if argc is -2, the function will
+receive 2 arguments, self and args, where args is a Ruby array of
the method arguments.
rb_define_private_method(VALUE klass, const char *name, VALUE (*func)(), int argc)
@@ -860,26 +883,26 @@ Defines a singleton method. Arguments are same as rb_define_method().
Retrieve argument from argc, argv. The fmt is the format string for
the arguments, such as "12" for 1 non-optional argument, 2 optional
arguments. If `*' appears at the end of fmt, it means the rest of
-the arguments are assigned to corresponding variable, packed in
-array.
+the arguments are assigned to the corresponding variable, packed in
+an array.
** Invoking Ruby method
VALUE rb_funcall(VALUE recv, ID mid, int narg, ...)
-Invokes the method. To retrieve mid from method name, use rb_intern().
+Invokes a method. To retrieve mid from a method name, use rb_intern().
VALUE rb_funcall2(VALUE recv, ID mid, int argc, VALUE *argv)
-Invokes method, passing arguments by array of values.
+Invokes a method, passing arguments by an array of values.
VALUE rb_eval_string(const char *str)
-Compiles and executes the string as Ruby program.
+Compiles and executes the string as a Ruby program.
ID rb_intern(const char *name)
-Returns ID corresponding the name.
+Returns ID corresponding to the name.
char *rb_id2name(ID id)
@@ -918,7 +941,7 @@ Evaluates the block with value val.
VALUE rb_rescue(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2)
-Calls the function func1, with arg1 as the argument. If exception
+Calls the function func1, with arg1 as the argument. If an 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.
@@ -926,29 +949,32 @@ exception occurs, from func2 otherwise.
VALUE rb_ensure(VALUE (*func1)(), void *arg1, void (*func2)(), void *arg2)
Calls the function func1 with arg1 as the argument, then calls func2
-with arg2, whenever execution terminated. The return value from
+with arg2 if execution terminated. The return value from
rb_ensure() is that of func1.
** Exceptions and Errors
void rb_warn(const char *fmt, ...)
-Prints warning message according to the printf-like format.
+Prints a warning message according to a printf-like format.
void rb_warning(const char *fmt, ...)
-Prints warning message according to the printf-like format, if
+Prints a warning message according to a printf-like format, if
$VERBOSE is true.
+void rb_raise(rb_eRuntimeError, const char *fmt, ...)
+
+Raises RuntimeError. The fmt is a format string just like printf().
+
void rb_raise(VALUE exception, const char *fmt, ...)
-Raises an exception of class exception. The fmt is the format string
-just like printf().
+Raises a class exception. The fmt is a format string just like printf().
void rb_fatal(const char *fmt, ...)
-Raises fatal error, terminates the interpreter. No exception handling
-will be done for fatal error, but ensure blocks will be executed.
+Raises a fatal error, terminates the interpreter. No exception handling
+will be done for fatal errors, but ensure blocks will be executed.
void rb_bug(const char *fmt, ...)
@@ -958,7 +984,7 @@ exception handling nor ensure execution will be done.
** Initialize and Starts the Interpreter
-The embedding API are below (not needed for extension libraries):
+The embedding API functions are below (not needed for extension libraries):
void ruby_init()
@@ -976,30 +1002,49 @@ Starts execution of the interpreter.
Specifies the name of the script ($0).
-Appendix B. Functions Available in extconf.rb
+Appendix C. Functions Available in extconf.rb
These functions are available in extconf.rb:
have_library(lib, func)
-Checks whether library which contains specified function exists.
+Checks whether the library exists, containing the specified function.
Returns true if the library exists.
+ find_library(lib, func, path...)
+
+Checks whether a library which contains the specified function exists in
+path. Returns true if the library exists.
+
have_func(func, header)
Checks whether func exists with header. Returns true if the function
-exists. To check functions in the additional library, you need to
+exists. To check functions in an additional library, you need to
check that library first using have_library().
have_header(header)
-Checks for the header files. Returns true if the header file exists.
+Checks whether header exists. Returns true if the header file exists.
create_makefile(target)
Generates the Makefile for the extension library. If you don't invoke
this method, the compilation will not be done.
+ with_config(withval[, default=nil])
+
+Parses the command line options and returns the value specified by
+--with-<withval>.
+
+ dir_config(target[, default_dir])
+ dir_config(target[, default_include, default_lib])
+
+Parses the command line options and adds the directories specified by
+--with-<target>-dir, --with-<target>-include, and/or --with-<target>-lib
+to $CFLAGS and/or $LDFLAGS. --with-<target>-dir=/path is equivalent to
+--with-<target>-include=/path/include --with-<target>-lib=/path/lib.
+Returns an array of the added directories ([include_dir, lib_dir]).
+
/*
* Local variables:
* fill-column: 70
diff --git a/README.EXT.jp b/README.EXT.ja
index 0db954818e..7a4cb5df2a 100644
--- a/README.EXT.jp
+++ b/README.EXT.ja
@@ -1,4 +1,4 @@
-.\" README.EXT - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
+.\" README.EXT.ja - -*- Text -*- created at: Mon Aug 7 16:45:54 JST 1995
Ruby¤Î³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤Îºî¤êÊý¤òÀâÌÀ¤·¤Þ¤¹¡¥
@@ -104,10 +104,19 @@ FIXNUM¤ÈNIL¤Ë´Ø¤·¤Æ¤Ï¤è¤ê¹â®¤ÊȽÊÌ¥Þ¥¯¥í¤¬ÍѰդµ¤ì¤Æ¤¤¤Þ¤¹¡¥
¤¤¤Þ¤¹¡¥¤½¤ì¤«¤é¡¤FIXNUM¤Ë¸Â¤é¤ºRuby¤Î¥Ç¡¼¥¿¤òÀ°¿ô¤ËÊÑ´¹¤¹¤ë
¡ÖNUM2INT()¡×¤È¤¤¤¦¥Þ¥¯¥í¤¬¤¢¤ê¤Þ¤¹¡¥¤³¤Î¥Þ¥¯¥í¤Ï¥Ç¡¼¥¿¥¿¥¤
¥×¤Î¥Á¥§¥Ã¥¯Ìµ¤·¤Ç»È¤¨¤Þ¤¹(À°¿ô¤ËÊÑ´¹¤Ç¤­¤Ê¤¤¾ì¹ç¤Ë¤ÏÎã³°¤¬
-ȯÀ¸¤¹¤ë)¡¥
-
-ƱÍͤ˥Á¥§¥Ã¥¯Ìµ¤·¤Ç»È¤¨¤ëÊÑ´¹¥Þ¥¯¥í¤Ïdouble¤ò¼è¤ê½Ð¤¹
-¡ÖNUM2DBL()¡×¤Èchar*¤ò¼è¤ê½Ð¤¹¡ÖSTR2CSTR()¡×¤¬¤¢¤ê¤Þ¤¹¡¥
+ȯÀ¸¤¹¤ë)¡¥Æ±Íͤ˥Á¥§¥Ã¥¯Ìµ¤·¤Ç»È¤¨¤ëÊÑ´¹¥Þ¥¯¥í¤Ïdouble¤ò
+¼è¤ê½Ð¤¹¡ÖNUM2DBL()¡×¤¬¤¢¤ê¤Þ¤¹¡£
+
+char* ¤ò¼è¤ê½Ð¤¹¾ì¹ç¡¢version 1.6 °ÊÁ°¤Ç¤Ï¡ÖSTR2CSTR()¡×¤È
+¤¤¤¦¥Þ¥¯¥í¤ò»È¤Ã¤Æ¤¤¤Þ¤·¤¿¤¬¡¢¤³¤ì¤Ï to_str() ¤Ë¤è¤ë°ÅÌÛ¤Î
+·¿ÊÑ´¹·ë²Ì¤¬ GC ¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¤¿¤á¡¢version 1.7 °Ê¹ß¤Ç¤Ï
+obsolete ¤È¤Ê¤ê¡¢Âå¤ï¤ê¤Ë StringValue() ¤È StringValuePtr()
+¤ò»È¤¦»ö¤ò¿ä¾©¤·¤Æ¤¤¤Þ¤¹¡£StringValue(var) ¤Ï var ¤¬ String
+ ¤Ç¤¢¤ì¤Ð²¿¤â¤»¤º¡¢¤½¤¦¤Ç¤Ê¤±¤ì¤Ð var ¤ò var.to_str() ¤Î·ë²Ì¤Ë
+ÃÖ¤­´¹¤¨¤ë¥Þ¥¯¥í¡¢StringValuePtr(var) ¤ÏƱÍÍ¤Ë var ¤òÃÖ¤­´¹¤¨
+¤Æ¤«¤é var ¤Îʸ»úÎóɽ¸½¤ËÂФ¹¤ë char* ¤òÊÖ¤¹¥Þ¥¯¥í¤Ç¤¹¡£var ¤Î
+ÆâÍÆ¤òľÀÜÃÖ¤­´¹¤¨¤ë½èÍý¤¬Æþ¤ë¤Î¤Ç¡¢var ¤Ï lvalue ¤Ç¤¢¤ëɬÍפ¬
+¤¢¤ê¤Þ¤¹¡£
¤½¤ì°Ê³°¤Î¥Ç¡¼¥¿¥¿¥¤¥×¤ÏÂбþ¤¹¤ëC¤Î¹½Â¤ÂΤ¬¤¢¤ê¤Þ¤¹¡¥Âбþ¤¹
¤ë¹½Â¤ÂΤΤ¢¤ëVALUE¤Ï¤½¤Î¤Þ¤Þ¥­¥ã¥¹¥È(·¿ÊÑ´¹)¤¹¤ì¤Ð¹½Â¤ÂΤÎ
@@ -493,7 +502,8 @@ C¤Î¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤Ç¤¹¡¥mark¤Ï¤³¤Î¹½Â¤ÂΤ¬Ruby¤Î¥ª¥Ö¥¸¥§
# ¤½¤Î¤è¤¦¤Ê»²¾È¤Ï´«¤á¤é¤ì¤Þ¤»¤ó¡¥
free¤Ï¤³¤Î¹½Â¤ÂΤ¬¤â¤¦ÉÔÍפˤʤä¿»þ¤Ë¸Æ¤Ð¤ì¤ë´Ø¿ô¤Ç¤¹¡¥¤³¤Î
-´Ø¿ô¤¬¥¬¡¼¥Ù¡¼¥¸¥³¥ì¥¯¥¿¤«¤é¸Æ¤Ð¤ì¤Þ¤¹¡¥
+´Ø¿ô¤¬¥¬¡¼¥Ù¡¼¥¸¥³¥ì¥¯¥¿¤«¤é¸Æ¤Ð¤ì¤Þ¤¹¡¥¤³¤ì¤¬-1¤Î¾ì¹ç¤Ï¡¤Ã±
+½ã¤Ë³«Êü¤µ¤ì¤Þ¤¹¡¥
C¤Î¹½Â¤ÂΤγäÅö¤ÈData¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤òƱ»þ¤Ë¹Ô¤¦¥Þ¥¯¥í¤È
¤·¤Æ°Ê²¼¤Î¤â¤Î¤¬Ä󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡¥
@@ -532,28 +542,14 @@ Ruby 1.1¤«¤é¤ÏǤ°Õ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ç¥À¥¤¥Ê¥ß¥Ã¥¯¥é¥¤¥Ö¥é¥ê¤òºî
¥é¥¤¥Ö¥é¥êÍѤΥǥ£¥ì¥¯¥È¥ê¤òºî¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¥Ì¾Á°¤ÏŬÅö¤Ë
Áª¤ó¤Ç¹½¤¤¤Þ¤»¤ó¡¥
-(2) MANIFEST¥Õ¥¡¥¤¥ë¤òºî¤ë
-
- % cd ext/dbm
- % touch MANIFEST
-
-³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î²¼¤Ë¤ÏMANIFEST¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤¬
-ɬÍפʤΤǡ¤¤È¤ê¤¢¤¨¤º¶õ¤Î¥Õ¥¡¥¤¥ë¤òºî¤Ã¤Æ¤ª¤­¤Þ¤¹¡¥¸å¤Ç¤³¤Î
-¥Õ¥¡¥¤¥ë¤Ë¤ÏɬÍפʥե¡¥¤¥ë°ìÍ÷¤¬Æþ¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡¥
-
-MANIFEST¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤Ï¡¤ÀÅŪ¥ê¥ó¥¯¤Îmake¤Î»þ¤Ë¥Ç¥£¥ì¥¯¥È¥ê
-¤¬³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤ò´Þ¤ó¤Ç¤¤¤ë¤«¤É¤¦¤«È½Äꤹ¤ë¤¿¤á¤Ë»È¤ï¤ì¤ì¤Æ
-¤¤¤Þ¤¹¡¥¥À¥¤¥Ê¥ß¥Ã¥¯¥é¥¤¥Ö¥é¥ê¤òºî¤ë¾ì¹ç¤Ë¤Ïɬ¤º¤·¤âɬÍפǤÏ
-¤¢¤ê¤Þ¤»¤ó¡¥
-
-(3) À߷פ¹¤ë
+(2) À߷פ¹¤ë
¤Þ¤¢¡¤ÅöÁ³¤Ê¤ó¤Ç¤¹¤±¤É¡¤¤É¤¦¤¤¤¦µ¡Ç½¤ò¼Â¸½¤¹¤ë¤«¤É¤¦¤«¤Þ¤ºÀß
·×¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¥¤É¤ó¤Ê¥¯¥é¥¹¤ò¤Ä¤¯¤ë¤«¡¤¤½¤Î¥¯¥é¥¹¤Ë¤Ï
¤É¤ó¤Ê¥á¥½¥Ã¥É¤¬¤¢¤ë¤«¡¤¥¯¥é¥¹¤¬Ä󶡤¹¤ëÄê¿ô¤Ê¤É¤Ë¤Ä¤¤¤ÆÀß·×
¤·¤Þ¤¹¡¥
-(4) C¥³¡¼¥É¤ò½ñ¤¯
+(3) C¥³¡¼¥É¤ò½ñ¤¯
³ÈÄ¥¥é¥¤¥Ö¥é¥êËÜÂΤȤʤëC¸À¸ì¤Î¥½¡¼¥¹¤ò½ñ¤­¤Þ¤¹¡¥C¸À¸ì¤Î¥½¡¼
¥¹¤¬¤Ò¤È¤Ä¤Î»þ¤Ë¤Ï¡Ö¥é¥¤¥Ö¥é¥ê̾.c¡×¤òÁª¤Ö¤ÈÎɤ¤¤Ç¤·¤ç¤¦¡¥C
@@ -696,7 +692,7 @@ C¤ÎÂç°èÊÑ¿ô¤Ï°Ê²¼¤Î´Ø¿ô¤ò»È¤Ã¤ÆRuby¥¤¥ó¥¿¥×¥ê¥¿¤ËÊÑ¿ô¤Î¸ºß
void rb_global_variable(VALUE *var)
-(5) extconf.rb¤òÍѰդ¹¤ë
+(4) extconf.rb¤òÍѰդ¹¤ë
Makefile¤òºî¤ë¾ì¹ç¤Î¿÷·¿¤Ë¤Ê¤ëextconf.rb¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤òºî¤ê
¤Þ¤¹¡¥extconf.rb¤Ï¥é¥¤¥Ö¥é¥ê¤Î¥³¥ó¥Ñ¥¤¥ë¤ËɬÍפʾò·ï¤Î¥Á¥§¥Ã
@@ -721,7 +717,7 @@ Makefile¤òºî¤ë¾ì¹ç¤Î¿÷·¿¤Ë¤Ê¤ëextconf.rb¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤òºî¤ê
¥Ñ¥¤¥ë¤·¤Ê¤¤»þ¤Ë¤Ïcreate_makefile¤ò¸Æ¤Ð¤Ê¤±¤ì¤ÐMakefile¤ÏÀ¸
À®¤µ¤ì¤º¡¤¥³¥ó¥Ñ¥¤¥ë¤â¹Ô¤ï¤ì¤Þ¤»¤ó¡¥
-(6) depend¤òÍѰդ¹¤ë
+(5) depend¤òÍѰդ¹¤ë
¤â¤·¡¤¥Ç¥£¥ì¥¯¥È¥ê¤Ëdepend¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ì¤Ð¡¤
Makefile¤¬°Í¸´Ø·¸¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤ì¤Þ¤¹¡¥
@@ -730,18 +726,7 @@ Makefile¤¬°Í¸´Ø·¸¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤ì¤Þ¤¹¡¥
¤Ê¤É¤Çºî¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡¥¤¢¤Ã¤ÆÂ»¤Ï̵¤¤¤Ç¤·¤ç¤¦¡¥
-(7) MANIFEST¥Õ¥¡¥¤¥ë¤Ë¥Õ¥¡¥¤¥ë̾¤òÆþ¤ì¤ë
-
- % find * -type f -print > MANIFEST
- % vi MANIFEST
-
-*.o, *~¤Ê¤ÉÉÔɬÍפʥե¡¥¤¥ë°Ê³°¤ÏMANIFEST¤ËÄɲ䷤Ƥª¤­¤Þ¤¹¡¥
-make»þ¤Ë¤ÏMANIFEST¤ÎÆâÍÆ¤Ï»²¾È¤·¤Þ¤»¤ó¤Î¤Ç¡¤¶õ¤Î¤Þ¤Þ¤Ç¤âÌäÂê
-¤Ïµ¯¤­¤Þ¤»¤ó¤¬¡¤¥Ñ¥Ã¥±¡¼¥¸¥ó¥°¤Î»þ¤Ë»²¾È¤¹¤ë¤³¤È¤¬¤¢¤ë¤Î¤È¡¤
-ɬÍפʥե¡¥¤¥ë¤ò¶èÊ̤Ǥ­¤ë¤Î¤Ç¡¤ÍѰդ·¤Æ¤ª¤¤¤¿Êý¤¬Îɤ¤¤Ç¤·¤ç
-¤¦¡¥
-
-(8) Makefile¤òÀ¸À®¤¹¤ë
+(6) Makefile¤òÀ¸À®¤¹¤ë
Makefile¤ò¼ÂºÝ¤ËÀ¸À®¤¹¤ë¤¿¤á¤Ë¤Ï
@@ -757,7 +742,7 @@ Makefile¤ò¼ÂºÝ¤ËÀ¸À®¤¹¤ë¤¿¤á¤Ë¤Ï
¥Ç¥£¥ì¥¯¥È¥ê¤òext°Ê²¼¤ËÍѰդ·¤¿¾ì¹ç¤Ë¤ÏRubyÁ´ÂΤÎmake¤Î»þ¤Ë
¼«Æ°Åª¤ËMakefile¤¬À¸À®¤µ¤ì¤Þ¤¹¤Î¤Ç¡¤¤³¤Î¥¹¥Æ¥Ã¥×¤ÏÉÔÍפǤ¹¡¥
-(9) make¤¹¤ë
+(7) make¤¹¤ë
ưŪ¥ê¥ó¥¯¥é¥¤¥Ö¥é¥ê¤òÀ¸À®¤¹¤ë¾ì¹ç¤Ë¤Ï¤½¤Î¾ì¤Çmake¤·¤Æ¤¯¤À¤µ
¤¤¡¥É¬ÍפǤ¢¤ì¤Ð make install ¤Ç¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Þ¤¹¡¥
@@ -775,13 +760,13 @@ extconf.rb¤ò½ñ¤­´¹¤¨¤ë¤Ê¤É¤·¤ÆMakefile¤ÎºÆÀ¸À®¤¬É¬Íפʻþ¤Ï¤Þ
¤òºî¤ê¡¤¤½¤³¤Ë ³ÈÄ¥»Ò .rb ¤Î¥Õ¥¡¥¤¥ë¤òÃÖ¤¤¤Æ¤ª¤±¤ÐƱ»þ¤Ë¥¤¥ó
¥¹¥È¡¼¥ë¤µ¤ì¤Þ¤¹¡¥
-(10) ¥Ç¥Ð¥Ã¥°
+(8) ¥Ç¥Ð¥Ã¥°
¤Þ¤¢¡¤¥Ç¥Ð¥Ã¥°¤·¤Ê¤¤¤Èư¤«¤Ê¤¤¤Ç¤·¤ç¤¦¤Í¡¥ext/Setup¤Ë¥Ç¥£¥ì
¥¯¥È¥ê̾¤ò½ñ¤¯¤ÈÀÅŪ¤Ë¥ê¥ó¥¯¤¹¤ë¤Î¤Ç¥Ç¥Ð¥Ã¥¬¤¬»È¤¨¤ë¤è¤¦¤Ë¤Ê
¤ê¤Þ¤¹¡¥¤½¤Îʬ¥³¥ó¥Ñ¥¤¥ë¤¬ÃÙ¤¯¤Ê¤ê¤Þ¤¹¤±¤É¡¥
-(11) ¤Ç¤­¤¢¤¬¤ê
+(9) ¤Ç¤­¤¢¤¬¤ê
¸å¤Ï¤³¤Ã¤½¤ê»È¤¦¤Ê¤ê¡¤¹­¤¯¸ø³«¤¹¤ë¤Ê¤ê¡¤Çä¤ë¤Ê¤ê¡¤¤´¼«Í³¤Ë¤ª
»È¤¤¤¯¤À¤µ¤¤¡¥Ruby¤Îºî¼Ô¤Ï³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤Ë´Ø¤·¤Æ°ìÀڤθ¢Íø¤ò
@@ -924,7 +909,7 @@ VALUE rb_define_module(const char *name)
¿·¤·¤¤Ruby¥â¥¸¥å¡¼¥ë¤òÄêµÁ¤¹¤ë¡¥
-VALUE rb_define_module_under(VALUE module, const char *name, VALUE super)
+VALUE rb_define_module_under(VALUE module, const char *name)
¿·¤·¤¤Ruby¥â¥¸¥å¡¼¥ë¤òÄêµÁ¤·¡¤module¤ÎÄê¿ô¤È¤·¤ÆÄêµÁ¤¹¤ë¡¥
@@ -1133,7 +1118,7 @@ void ruby_script(char *name)
Ruby¤Î¥¹¥¯¥ê¥×¥È̾($0)¤òÀßÄꤹ¤ë¡¥
-Appendix B. extconf.rb¤Ç»È¤¨¤ë´Ø¿ô¤¿¤Á
+Appendix C. extconf.rb¤Ç»È¤¨¤ë´Ø¿ô¤¿¤Á
extconf.rb¤ÎÃæ¤Ç¤ÏÍøÍѲÄǽ¤Ê¥³¥ó¥Ñ¥¤¥ë¾ò·ï¥Á¥§¥Ã¥¯¤Î´Ø¿ô¤Ï°Ê
²¼¤ÎÄ̤ê¤Ç¤¢¤ë¡¥
@@ -1160,11 +1145,6 @@ have_header(header)
¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Î¸ºß¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡¥¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹
¤ë»þtrue¤òÊÖ¤¹¡¥
-find_header(header)
-
- ¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Î¸ºß¤ò -Ipath ¤òÄɲ䷤ʤ¬¤é¥Á¥§¥Ã¥¯¤¹¤ë¡¥
- ¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤¬¸«ÉÕ¤«¤Ã¤¿»þtrue¤òÊÖ¤¹¡¥
-
create_makefile(target)
³ÈÄ¥¥é¥¤¥Ö¥é¥êÍѤÎMakefile¤òÀ¸À®¤¹¤ë¡¥¤³¤Î´Ø¿ô¤ò¸Æ¤Ð¤Ê¤±¤ì
@@ -1173,13 +1153,17 @@ create_makefile(target)
with_config(withval[, default=nil])
- --with-<withval>¤Ç»ØÄꤵ¤ì¤¿¥ª¥×¥·¥ç¥óÃͤòÆÀ¤ë¡¥
+ ¥³¥Þ¥ó¥É¥é¥¤¥ó¾å¤Î--with-<withval>¤Ç»ØÄꤵ¤ì¤¿¥ª¥×¥·¥ç¥óÃͤòÆÀ¤ë¡¥
-dir_config(target)
+dir_config(target[, default_dir])
+dir_config(target[, default_include, default_lib])
- --with-<target>-dir, --with-<target>-include, --with-<target>-lib
- ¤Î¤¤¤º¤ì¤«¤Ç»ØÄꤵ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ò $CFLAGS ¤ä $LDFLAGS
- ¤ËÄɲ乤롥
+ ¥³¥Þ¥ó¥É¥é¥¤¥ó¾å¤Î--with-<target>-dir, --with-<target>-include,
+ --with-<target>-lib¤Î¤¤¤º¤ì¤«¤Ç»ØÄꤵ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ò
+ $CFLAGS ¤ä $LDFLAGS ¤ËÄɲ乤롥--with-<target>-dir=/path¤Ï
+ --with-<target>-include=/path/include --with-<target>-lib=/path/lib
+ ¤ÈÅù²Á¤Ç¤¢¤ë¡¥Äɲ䵤줿 include ¥Ç¥£¥ì¥¯¥È¥ê¤È lib ¥Ç¥£¥ì¥¯¥È¥ê¤Î
+ ÇÛÎó¤òÊÖ¤¹¡¥ ([include_dir, lib_dir])
/*
* Local variables:
diff --git a/README.jp b/README.ja
index 566fbcdac4..fc502dd440 100644
--- a/README.jp
+++ b/README.ja
@@ -30,14 +30,14 @@ Ruby¤Ï¥Æ¥­¥¹¥È½èÍý´Ø·¸¤ÎǽÎϤʤɤËÍ¥¤ì¡¤Perl¤ÈƱ¤¸¤¯¤é¤¤¶¯ÎÏ
°Ê²¼¤Î¾ì½ê¤Ë¤ª¤¤¤Æ¤¢¤ê¤Þ¤¹¡¥
- ftp://ftp.netlab.co.jp/pub/lang/ruby/
+ ftp://ftp.ruby-lang.org/pub/ruby/
** CVS¤Ç
- $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs login
- (Logging in to anonymous@cvs.netlab.co.jp)
- CVS password: guest
- $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs checkout ruby
+ $ cvs -d :pserver:anonymous@cvs.ruby-lang.org:/src login
+ (Logging in to anonymous@cvs.ruby-lang.org)
+ CVS password: anonymous
+ $ cvs -z4 -d :pserver:anonymous@cvs.ruby-lang.org:src checkout ruby
* ¥Û¡¼¥à¥Ú¡¼¥¸
@@ -53,7 +53,7 @@ Ruby¤Î¥Û¡¼¥à¥Ú¡¼¥¸¤ÎURL¤Ï
Ruby¤Î¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤¬¤¢¤ê¤Þ¤¹¡£»²²Ã´õ˾¤ÎÊý¤Ï
- ruby-list-ctl@netlab.co.jp
+ ruby-list-ctl@ruby-lang.org
¤Þ¤ÇËÜʸ¤Ë
@@ -65,11 +65,12 @@ Ruby³«È¯¼Ô¸þ¤±¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤â¤¢¤ê¤Þ¤¹¡£¤³¤Á¤é¤Ç¤Ïruby¤Î¥Ð
¥°¡¢¾­Íè¤Î»ÅÍͳÈÄ¥¤Ê¤É¼ÂÁõ¾å¤ÎÌäÂê¤Ë¤Ä¤¤¤ÆµÄÏÀ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
»²²Ã´õ˾¤ÎÊý¤Ï
- ruby-dev-ctl@netlab.co.jp
+ ruby-dev-ctl@ruby-lang.org
¤Þ¤Çruby-list¤ÈƱÍͤÎÊýË¡¤Ç¥á¡¼¥ë¤·¤Æ¤¯¤À¤µ¤¤¡£
Ruby³ÈÄ¥¥â¥¸¥å¡¼¥ë¤Ë¤Ä¤¤¤ÆÏ䷹礦ruby-ext¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤È
+¿ô³Ø´Ø·¸¤ÎÏÃÂê¤Ë¤Ä¤¤¤ÆÏ䷹礦ruby-math¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤È
±Ñ¸ì¤ÇÏ䷹礦ruby-talk¥á¡¼¥ê¥ó¥°¥ê¥¹¥È¤â¤¢¤ê¤Þ¤¹¡£»²²ÃÊýË¡
¤Ï¤É¤ì¤âƱ¤¸¤Ç¤¹¡£
@@ -139,63 +140,12 @@ UNIX¤Ç¤¢¤ì¤Ðconfigure¤¬¤Û¤È¤ó¤É¤Îº¹°Û¤òµÛ¼ý¤·¤Æ¤¯¤ì¤ë¤Ï¤º¤Ç
* ÇÛÉÛ¾ò·ï
-ËÜ¥×¥í¥°¥é¥à¤Ï¥Õ¥ê¡¼¥½¥Õ¥È¥¦¥§¥¢¤Ç¤¹¡¥GPL(the GNU General
-Public License)¤Þ¤¿¤Ï°Ê²¼¤Ë¼¨¤¹¾ò·ï¤ÇËÜ¥×¥í¥°¥é¥à¤òºÆÇÛÉÛ¤Ç
-¤­¤Þ¤¹¡¥GPL¤Ë¤Ä¤¤¤Æ¤ÏCOPYING¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡¥
+COPYING.ja¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
- 1. Ê£À½¤ÏÀ©¸Â¤Ê¤¯¼«Í³¤Ç¤¹¡¥
-
- 2. °Ê²¼¤Î¾ò·ï¤Î¤¤¤º¤ì¤«¤òËþ¤¿¤¹»þ¤ËËÜ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹¤ò
- ¼«Í³¤ËÊѹ¹¤Ç¤­¤Þ¤¹¡¥
-
- (a) ¥Í¥Ã¥È¥Ë¥å¡¼¥º¤Ë¥Ý¥¹¥È¤·¤¿¤ê¡¤ºî¼Ô¤ËÊѹ¹¤òÁ÷ÉÕ¤¹¤ë
- ¤Ê¤É¤ÎÊýË¡¤Ç¡¤Êѹ¹¤ò¸ø³«¤¹¤ë¡¥
-
- (b) Êѹ¹¤·¤¿ËÜ¥×¥í¥°¥é¥à¤ò¼«Ê¬¤Î½ê°¤¹¤ëÁÈ¿¥ÆâÉô¤À¤±¤Ç
- »È¤¦¡¥
-
- (c) Êѹ¹ÅÀ¤òÌÀ¼¨¤·¤¿¤¦¤¨¡¤¥½¥Õ¥È¥¦¥§¥¢¤Î̾Á°¤òÊѹ¹¤¹¤ë¡¥
- ¤½¤Î¥½¥Õ¥È¥¦¥§¥¢¤òÇÛÉÛ¤¹¤ë»þ¤Ë¤ÏÊѹ¹Á°¤ÎËÜ¥×¥í¥°¥é
- ¥à¤âƱ»þ¤ËÇÛÉÛ¤¹¤ë¡¥¤Þ¤¿¤ÏÊѹ¹Á°¤ÎËÜ¥×¥í¥°¥é¥à¤Î¥½¡¼
- ¥¹¤ÎÆþ¼êË¡¤òÌÀ¼¨¤¹¤ë¡¥
-
- (d) ¤½¤Î¾¤ÎÊѹ¹¾ò·ï¤òºî¼Ô¤È¹ç°Õ¤¹¤ë¡¥
-
- 3. °Ê²¼¤Î¾ò·ï¤Î¤¤¤º¤ì¤«¤òËþ¤¿¤¹»þ¤ËËÜ¥×¥í¥°¥é¥à¤ò¥³¥ó¥Ñ¥¤
- ¥ë¤·¤¿¥ª¥Ö¥¸¥§¥¯¥È¥³¡¼¥É¤ä¼Â¹Ô·Á¼°¤Ç¤âÇÛÉۤǤ­¤Þ¤¹¡¥
-
- (a) ¥Ð¥¤¥Ê¥ê¤ò¼õ¤±¼è¤Ã¤¿¿Í¤¬¥½¡¼¥¹¤òÆþ¼ê¤Ç¤­¤ë¤è¤¦¤Ë¡¤
- ¥½¡¼¥¹¤ÎÆþ¼êË¡¤òÌÀ¼¨¤¹¤ë¡¥
-
- (b) µ¡³£²ÄÆÉ¤Ê¥½¡¼¥¹¥³¡¼¥É¤òźÉÕ¤¹¤ë¡¥
-
- (c) Êѹ¹¤ò¹Ô¤Ã¤¿¥Ð¥¤¥Ê¥ê¤Ï̾Á°¤òÊѹ¹¤·¤¿¤¦¤¨¡¤¥ª¥ê¥¸¥Ê
- ¥ë¤Î¥½¡¼¥¹¥³¡¼¥É¤ÎÆþ¼êË¡¤òÌÀ¼¨¤¹¤ë¡¥
-
- (d) ¤½¤Î¾¤ÎÇÛÉÛ¾ò·ï¤òºî¼Ô¤È¹ç°Õ¤¹¤ë¡¥
-
- 4. ¾¤Î¥×¥í¥°¥é¥à¤Ø¤Î°úÍѤϤ¤¤«¤Ê¤ëÌÜŪ¤Ç¤¢¤ì¼«Í³¤Ç¤¹¡¥¤¿
- ¤À¤·¡¤ËÜ¥×¥í¥°¥é¥à¤Ë´Þ¤Þ¤ì¤ë¾¤Îºî¼Ô¤Ë¤è¤ë¥³¡¼¥É¤Ï¡¤¤½
- ¤ì¤¾¤ì¤Îºî¼Ô¤Î°Õ¸þ¤Ë¤è¤ëÀ©¸Â¤¬²Ã¤¨¤é¤ì¤ë¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¡¥
-
- ¶ñÂÎŪ¤Ë¤Ïgc.c(°ìÉô)¡¤util.c(°ìÉô)¡¤st.[ch]¡¤regex.[ch]
- ¤ª¤è¤Ó ./missing¥Ç¥£¥ì¥¯¥È¥ê²¼¤Î¥Õ¥¡¥¤¥ë·²¤¬³ºÅö¤·¤Þ¤¹¡¥
- ¤½¤ì¤¾¤ì¤ÎÇÛÉÛ¾ò·ï¤Ê¤É¤ËÉÕ¤¤¤Æ¤Ï³Æ¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¯
- ¤À¤µ¤¤¡¥
-
- 5. ËÜ¥×¥í¥°¥é¥à¤Ø¤ÎÆþÎϤȤʤ륹¥¯¥ê¥×¥È¤ª¤è¤Ó¡¤ËÜ¥×¥í¥°¥é
- ¥à¤«¤é¤Î½ÐÎϤθ¢Íø¤ÏËÜ¥×¥í¥°¥é¥à¤Îºî¼Ô¤Ç¤Ï¤Ê¤¯¡¤¤½¤ì¤¾
- ¤ì¤ÎÆþ½ÐÎϤòÀ¸À®¤·¤¿¿Í¤Ë°¤·¤Þ¤¹¡¥¤Þ¤¿¡¤ËÜ¥×¥í¥°¥é¥à¤Ë
- ÁȤ߹þ¤Þ¤ì¤ë¤¿¤á¤Î³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤Ë¤Ä¤¤¤Æ¤âƱÍͤǤ¹¡¥
-
- 6. ËÜ¥×¥í¥°¥é¥à¤Ï̵ÊݾڤǤ¹¡¥ºî¼Ô¤ÏËÜ¥×¥í¥°¥é¥à¤ò¥µ¥Ý¡¼¥È
- ¤¹¤ë°Õ»Ö¤Ï¤¢¤ê¤Þ¤¹¤¬¡¤¥×¥í¥°¥é¥à¼«¿È¤Î¥Ð¥°¤¢¤ë¤¤¤ÏËÜ¥×
- ¥í¥°¥é¥à¤Î¼Â¹Ô¤Ê¤É¤«¤éȯÀ¸¤¹¤ë¤¤¤«¤Ê¤ë»³²¤ËÂФ·¤Æ¤âÀÕ
- Ǥ¤ò»ý¤Á¤Þ¤»¤ó¡¥
* Ãø¼Ô
-¥³¥á¥ó¥È¡¤¥Ð¥°¥ì¥Ý¡¼¥È¤½¤Î¾¤Ï matz@zetabits.com ¤Þ¤Ç¡¥
+¥³¥á¥ó¥È¡¤¥Ð¥°¥ì¥Ý¡¼¥È¤½¤Î¾¤Ï matz@netlab.jp ¤Þ¤Ç¡¥
-------------------------------------------------------
created at: Thu Aug 3 11:57:36 JST 1995
Local variables:
diff --git a/ToDo b/ToDo
index 5f67a42b25..b55e399edf 100644
--- a/ToDo
+++ b/ToDo
@@ -1,12 +1,7 @@
Language Spec.
-- def foo; .. rescue .. end
-- compile time string concatenation, "hello" "world" => "helloworld"
-- rescue modifier; a rescue b => begin a rescue; b end
-- %w(a\ b\ c abc) => ["a b c", "abc"]
-- objectify symbols
-- class variable (prefix @@)
-- rescue RuntimeError => err
+- Class#allocate - basicNew
+- class Foo::Bar<Baz .. end, module Boo::Bar .. end
* operator !! for rescue. ???
* objectify characters
* ../... outside condition invokes operator method too.
@@ -17,27 +12,35 @@ Language Spec.
* multiple return values, yield values. maybe incompatible ???
* cascading method invocation ???
* def Class#method .. end ??
-* class Foo::Bar<Baz .. end, module Boo::Bar .. end
* def Foo::Bar::baz() .. end ??
* I18N (or M17N) script/string/regexp
* Fixnum 0 as false ????
-* discourage use of symbol variable (e.g. $/, etc.) in manual
+* discourage use of symbol variables (e.g. $/, etc.) in manual
* discourage use of Perlish features by giving warnings.
* non confusing in-block local variable (is it possible?)
+ remove scope by block
+ variables appears within block may have independent values.
* Regexp: make /o thread safe.
-* decide if begin with rescue or ensure make do..while loop.
+* decide whether begin with rescue or ensure make do..while loop.
* a +1 to be a+1, not a(+1).
+* unify == and eql? again
+* to_i returns nil if str contains no digit.
+* raise exception by `` error
+* jar like combined library package. -> RubyGems?
+* resumable Exception via Exception#resume.
+* method combination, e.g. before, after, around, etc.
+* .. or something like defadvice in Emacs.
+* property - for methods, or for objects in general.
+* "in" modifier, to annotate, or to encourage assertion.
+* selector namespace - something like generic-flet in CLOS, to help RubyBehavior
+* private instance variable (as in Python?) @_foo in class Foo => @_Foo_foo
+* warn/error "bare word" method, like "foo", you should type "foo()"
+* clarify evaluation order of operator argument (=~, .., ...)
+* :symbol => value hash in the form of {symbol: value, ...} ??
Hacking Interpreter
-- use eban's fnmatch
-- RUBYOPT environment variable
-- alias $defout $>
-- retrieve STACK_LEVEL_MAX from users' limit.
-- remove end_proc registered out of require only
-- all object made freezable
+- generational GC
* non-blocking open (e.g. for named pipe) for thread
* avoid blocking with gethostbyname/gethostbyaddr (use fork ???)
* objectify interpreters ???
@@ -46,45 +49,42 @@ Hacking Interpreter
* scrambled script, or script filter
* setuid ruby
* performance tune for in-block (dynamic) local variables.
-* generational GC
* give warnings to assign magic variables.
* export rb_io_{addstr,printf,puts,print}
* autoload should work with threads [ruby-talk:4589]
* remove stdio dependency from IOs.
* warn for inconsistent local variable usage (lv m and method m at the same time).
+* MicroRuby
+* Built-in Interactive Ruby.
+* Parser API
+* trap every method invocation, which can be enabled by e.g. trap_call :method.
+* unify Errno exceptions of same errno, or new exception comparison scheme.
+* 2.times{|i| if i==0 then a = 15 else puts eval("a") end} should print nil.
+* Thread#max_stack_size attribute (possible??)
Standard Libraries
-- hash[key] = nil does not remove entry; hashes may have nil as the value.
-- hash.fetch(key) raises exception if key is not found.
-- Array#{first,last,at}
-- Dir.glob(pat){|f|...}
-- sprintf/printf's $ to specify argument order
-- Dir.glob("**/*.c") ala zsh
-- Remove Enumerable#{size,length}
-- Array#slice, Array#slice!
-- String#slice, String#slice!
-- Marshal should handle generic instance variables.
-- debugger for thread programming
-- SyntaxError, NameError, LoadError and NotImplementedError are subclasses of
- ScriptError<Exception, not StandardError.
-- Thread::start gives arguments, not a thread object to the block
-- regexp: (?>..), \G
-- Struct::new([name,]member,...)
-- IO#reopen accepts path as well
-- Kernel#scan
-- call initialize for builtin classes too
-- performance tune for String's non-bang methods.
-- 'w' template for pack/unpack
-- alternative for interator? => block_given?
-- regex - /p (made obsolete), /m (new)
-- consistent /, %, divmod
-- unbound method object
-- integrate final.rb into the core.
-* Enumerable#sort_by for Schwartzian transformation
+- Module#define_method which takes a name and a body (block, proc or method).
+- Enume#inject
+- Array#fetch
+- IO::for_fd
+- Process::waitall [ruby-talk:4557]
+- Process::Status
+- File::lchown, File::lchmod; xxx - still need work for non existing platforms
+- move Time::times to Process.
+- Enumerable#sort_by for Schwartzian transformation
+- fork_and_kill_other_threads.
+- signal list (Signal::trap, Signal::list).
+- move NameError under StandardError.
+- Integer#to_s(base)
+- Hash::new{default}
+- hash etc. should handle self referenceing array/hash
+- Array#select(n1,n2...) works like Array#indexes(n1,n2...)
+- use Mersenne Twister RNG for random.
+- deprecate Array#indexes, and Array#indices.
+- remove dependency on MAXPATHLEN.
* String#scanf(?)
* Object#fmt(?)
-* Integer#{bin,oct,hex,heX}
* Time::strptime
* Integer[num], Float[num]; Fixnum[num]?
* method to retrieve non-number trailer for to_i/to_f.
@@ -93,37 +93,34 @@ Standard Libraries
* optional stepsize argument for succ()
* Ruby module -- Ruby::Version, Ruby::Interpreter
* introduce Boolean class; super of TrueClass, FalseClass
-* Process::waitall [ruby-talk:4557]
* synchronized method - synchronized{...}, synchronized :foo, :bar
-* move Time::times to Process.
-- Module#define_method which takes a name and a body (block, proc or method).
-* IO#for_fd in general
* Array#&, Array#| to allow duplication. ???
-- fork_and_kill_other_threads.
* way to specify immortal (fork endurance) thread;
* or raise ForkException to every thread but fork caller.
-* Array#fetch
+* new user-defined marshal scheme. _dump(dumper), _load(restorer)
+* library to load per-user profile seeking .ruby_profile or ruby.ini file.
+* warning framework (warn, warning for Ruby level)
+* marshal should not depend on sprintf (works bad with locale).
+* ternary arg pow: a.pow(b,c) == a**b%c
+* new caller(), e.g. call_stack; needs better name.
+* pointer share mechanism similar to one in String for Array.
+* require "1.6" etc. by /usr/lib/ruby/1.6/1.6.rb ;-)
+* save both "feature names" and "normalized path" in $"
+* implement Mutex_m (or MutexMixin) using Mutex.
Extension Libraries
-- FastCGI ruby
* ptk.rb pTk wrapper that is compatible to tk.rb
* Berkeley DB extension
* BitVector
+* thread-safe fcgi
Ruby Libraries
-- net/http.rb
-* add uri.rb
* urllib.rb, nttplib.rb, etc.
* format like perl's
Tools
-- extension library maker using SWIG
* freeze or undump to bundle everything
-
-Misc
-
-- publish Ruby books
-- publish Ruby books in English
+* bundle using zlib
diff --git a/array.c b/array.c
index 3349a81f8f..03647f81fd 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-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -17,6 +17,7 @@
#include "st.h"
VALUE rb_cArray;
+static ID id_cmp;
#define ARY_DEFAULT_SIZE 16
@@ -30,7 +31,7 @@ rb_mem_clear(mem, size)
}
}
-static void
+static inline void
memfill(mem, size, val)
register VALUE *mem;
register long size;
@@ -43,17 +44,33 @@ memfill(mem, size, val)
#define ARY_TMPLOCK FL_USER1
-static void
-rb_ary_modify(ary)
+static inline void
+rb_ary_modify_check(ary)
VALUE ary;
{
if (OBJ_FROZEN(ary)) rb_error_frozen("array");
if (FL_TEST(ary, ARY_TMPLOCK))
- rb_raise(rb_eTypeError, "can't modify array during sort");
+ rb_raise(rb_eRuntimeError, "can't modify array during iteration");
if (!OBJ_TAINTED(ary) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify array");
}
+static void
+rb_ary_modify(ary)
+ VALUE ary;
+{
+ VALUE *ptr;
+
+ rb_ary_modify_check(ary);
+ if (FL_TEST(ary, ELTS_SHARED)) {
+ ptr = ALLOC_N(VALUE, RARRAY(ary)->len);
+ FL_UNSET(ary, ELTS_SHARED);
+ RARRAY(ary)->aux.capa = RARRAY(ary)->len;
+ MEMCPY(ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
+ RARRAY(ary)->ptr = ptr;
+ }
+}
+
VALUE
rb_ary_freeze(ary)
VALUE ary;
@@ -61,38 +78,67 @@ rb_ary_freeze(ary)
return rb_obj_freeze(ary);
}
+/*
+ * call-seq:
+ * array.frozen? -> true or false
+ *
+ * Return <code>true</code> if this array is frozen (or temporarily frozen
+ * while being sorted).
+ */
+
static VALUE
rb_ary_frozen_p(ary)
VALUE ary;
{
- if (FL_TEST(ary, FL_FREEZE|ARY_TMPLOCK))
- return Qtrue;
+ if (OBJ_FROZEN(ary)) return Qtrue;
+ if (FL_TEST(ary, ARY_TMPLOCK)) return Qtrue;
return Qfalse;
}
-VALUE
-rb_ary_new2(len)
- long len;
+static VALUE ary_alloc _((VALUE));
+static VALUE
+ary_alloc(klass)
+ VALUE klass;
{
NEWOBJ(ary, struct RArray);
- OBJSETUP(ary, rb_cArray, T_ARRAY);
+ OBJSETUP(ary, klass, T_ARRAY);
+
+ ary->len = 0;
+ ary->ptr = 0;
+ ary->aux.capa = 0;
+
+ return (VALUE)ary;
+}
+
+static VALUE
+ary_new(klass, len)
+ VALUE klass;
+ long len;
+{
+ VALUE ary = ary_alloc(klass);
if (len < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
}
- if (len > 0 && len*sizeof(VALUE) <= 0) {
+ if (len > 0 && len * sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
- ary->len = 0;
- ary->capa = len;
- ary->ptr = 0;
if (len == 0) len++;
- ary->ptr = ALLOC_N(VALUE, len);
+ RARRAY(ary)->ptr = ALLOC_N(VALUE, len);
+ RARRAY(ary)->aux.capa = len;
- return (VALUE)ary;
+ return ary;
}
VALUE
+rb_ary_new2(len)
+ long len;
+{
+ return ary_new(rb_cArray, len);
+}
+
+
+VALUE
rb_ary_new()
{
return rb_ary_new2(ARY_DEFAULT_SIZE);
@@ -119,10 +165,7 @@ rb_ary_new3(n, va_alist)
VALUE ary;
long i;
- if (n < 0) {
- rb_raise(rb_eIndexError, "negative number of items(%d)", n);
- }
- ary = rb_ary_new2(n<ARY_DEFAULT_SIZE?ARY_DEFAULT_SIZE:n);
+ ary = rb_ary_new2(n);
va_init_list(ar, n);
for (i=0; i<n; i++) {
@@ -137,12 +180,12 @@ rb_ary_new3(n, va_alist)
VALUE
rb_ary_new4(n, elts)
long n;
- VALUE *elts;
+ const VALUE *elts;
{
VALUE ary;
ary = rb_ary_new2(n);
- if (elts) {
+ if (n > 0 && elts) {
MEMCPY(RARRAY(ary)->ptr, elts, VALUE, n);
}
RARRAY(ary)->len = n;
@@ -165,18 +208,59 @@ rb_assoc_new(car, cdr)
}
static VALUE
-rb_ary_s_new(argc, argv, klass)
- int argc;
- VALUE *argv;
- VALUE klass;
+to_ary(ary)
+ VALUE ary;
{
- VALUE ary = rb_ary_new();
- OBJSETUP(ary, klass, T_ARRAY);
- rb_obj_call_init(ary, argc, argv);
-
- return ary;
+ return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
}
+VALUE
+rb_check_array_type(ary)
+ VALUE ary;
+{
+ return rb_check_convert_type(ary, T_ARRAY, "Array", "to_ary");
+}
+
+static VALUE rb_ary_replace _((VALUE, VALUE));
+
+/*
+ * call-seq:
+ * Array.new(size=0, obj=nil)
+ * Array.new(array)
+ * Array.new(size) {|index| block }
+ *
+ * Returns a new array. In the first form, the new array is
+ * empty. In the second it is created with _size_ copies of _obj_
+ * (that is, _size_ references to the same
+ * _obj_). The third form creates a copy of the array
+ * passed as a parameter (the array is generated by calling
+ * to_ary on the parameter). In the last form, an array
+ * of the given size is created. Each element in this array is
+ * calculated by passing the element's index to the given block and
+ * storing the return value.
+ *
+ * Array.new
+ * Array.new(2)
+ * Array.new(5, "A")
+ *
+ * # only one copy of the object is created
+ * a = Array.new(2, Hash.new)
+ * a[0]['cat'] = 'feline'
+ * a
+ * a[1]['cat'] = 'Felix'
+ * a
+ *
+ * # here multiple copies are created
+ * a = Array.new(2) { Hash.new }
+ * a[0]['cat'] = 'feline'
+ * a
+ *
+ * squares = Array.new(5) {|i| i*i}
+ * squares
+ *
+ * copy = Array.new(squares)
+ */
+
static VALUE
rb_ary_initialize(argc, argv, ary)
int argc;
@@ -186,48 +270,80 @@ rb_ary_initialize(argc, argv, ary)
long len;
VALUE size, val;
+ rb_ary_modify(ary);
if (rb_scan_args(argc, argv, "02", &size, &val) == 0) {
+ RARRAY(ary)->len = 0;
+ if (rb_block_given_p()) {
+ rb_warning("given block not used");
+ }
return ary;
}
- rb_ary_modify(ary);
+ if (argc == 1 && !FIXNUM_P(size)) {
+ val = rb_check_array_type(size);
+ if (!NIL_P(val)) {
+ rb_ary_replace(ary, val);
+ return ary;
+ }
+ }
+
len = NUM2LONG(size);
if (len < 0) {
rb_raise(rb_eArgError, "negative array size");
}
- if (len > 0 && len*sizeof(VALUE) <= 0) {
+ if (len > 0 && len * (long)sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
- if (len > RARRAY(ary)->capa) {
- RARRAY(ary)->capa = len;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
+ if (len > RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
+ RARRAY(ary)->aux.capa = len;
+ }
+ if (rb_block_given_p()) {
+ long i;
+
+ if (argc == 2) {
+ rb_warn("block supersedes default value argument");
+ }
+ for (i=0; i<len; i++) {
+ rb_ary_store(ary, i, rb_yield(LONG2NUM(i)));
+ RARRAY(ary)->len = i + 1;
+ }
+ }
+ else {
+ memfill(RARRAY(ary)->ptr, len, val);
+ RARRAY(ary)->len = len;
}
- memfill(RARRAY(ary)->ptr, len, val);
- RARRAY(ary)->len = len;
return ary;
}
+
+/*
+* Returns a new array populated with the given objects.
+*
+* Array.[]( 1, 'a', /^A/ )
+* Array[ 1, 'a', /^A/ ]
+* [ 1, 'a', /^A/ ]
+*/
+
static VALUE
rb_ary_s_create(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
- NEWOBJ(ary, struct RArray);
- OBJSETUP(ary, klass, T_ARRAY);
+ VALUE ary = ary_alloc(klass);
- ary->len = ary->capa = 0;
- if (argc == 0) {
- ary->ptr = 0;
+ if (argc < 0) {
+ rb_raise(rb_eArgError, "negative number of arguments");
}
- else {
- ary->ptr = ALLOC_N(VALUE, argc);
- MEMCPY(ary->ptr, argv, VALUE, argc);
+ if (argc > 0) {
+ RARRAY(ary)->ptr = ALLOC_N(VALUE, argc);
+ MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
}
- ary->len = ary->capa = argc;
+ RARRAY(ary)->len = RARRAY(ary)->aux.capa = argc;
- return (VALUE)ary;
+ return ary;
}
void
@@ -240,22 +356,27 @@ rb_ary_store(ary, idx, val)
if (idx < 0) {
idx += RARRAY(ary)->len;
if (idx < 0) {
- rb_raise(rb_eIndexError, "index %d out of array",
- idx - RARRAY(ary)->len);
+ rb_raise(rb_eIndexError, "index %ld out of array",
+ idx - RARRAY(ary)->len);
}
}
- if (idx >= RARRAY(ary)->capa) {
- long capa_inc = RARRAY(ary)->capa / 2;
- if (capa_inc < ARY_DEFAULT_SIZE) {
- capa_inc = ARY_DEFAULT_SIZE;
+ if (idx >= RARRAY(ary)->aux.capa) {
+ long new_capa = RARRAY(ary)->aux.capa / 2;
+
+ if (new_capa < ARY_DEFAULT_SIZE) {
+ new_capa = ARY_DEFAULT_SIZE;
+ }
+ new_capa += idx;
+ if (new_capa * (long)sizeof(VALUE) <= new_capa) {
+ rb_raise(rb_eArgError, "index too big");
}
- RARRAY(ary)->capa = idx + capa_inc;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, new_capa);
+ RARRAY(ary)->aux.capa = new_capa;
}
if (idx > RARRAY(ary)->len) {
- rb_mem_clear(RARRAY(ary)->ptr+RARRAY(ary)->len,
- idx-RARRAY(ary)->len+1);
+ rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len,
+ idx-RARRAY(ary)->len + 1);
}
if (idx >= RARRAY(ary)->len) {
@@ -264,6 +385,19 @@ rb_ary_store(ary, idx, val)
RARRAY(ary)->ptr[idx] = val;
}
+/*
+ * call-seq:
+ * array << obj -> array
+ *
+ * Append---Pushes the given object on to the end of this array. This
+ * expression returns the array itself, so several appends
+ * may be chained together.
+ *
+ * [ 1, 2 ] << "c" << "d" << [ 3, 4 ]
+ * #=> [ 1, 2, "c", "d", [ 3, 4 ] ]
+ *
+ */
+
VALUE
rb_ary_push(ary, item)
VALUE ary;
@@ -273,61 +407,105 @@ rb_ary_push(ary, item)
return ary;
}
+/*
+ * call-seq:
+ * array.push(obj, ... ) -> array
+ *
+ * Append---Pushes the given object(s) on to the end of this array. This
+ * expression returns the array itself, so several appends
+ * may be chained together.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.push("d", "e", "f")
+ * #=> ["a", "b", "c", "d", "e", "f"]
+ */
+
static VALUE
rb_ary_push_m(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
- if (argc == 0) {
- rb_raise(rb_eArgError, "wrong # of arguments(at least 1)");
- }
- if (argc > 0) {
- long len = RARRAY(ary)->len;
-
- --argc;
- /* make rooms by copying the last item */
- rb_ary_store(ary, len + argc, argv[argc]);
-
- if (argc) { /* if any rest */
- MEMCPY(RARRAY(ary)->ptr + len, argv, VALUE, argc);
- }
+ while (argc--) {
+ rb_ary_push(ary, *argv++);
}
return ary;
}
+/*
+ * call-seq:
+ * array.pop -> obj or nil
+ *
+ * Removes the last element from <i>self</i> and returns it, or
+ * <code>nil</code> if the array is empty.
+ *
+ * a = [ "a", "m", "z" ]
+ * a.pop #=> "z"
+ * a #=> ["a", "m"]
+ */
+
VALUE
rb_ary_pop(ary)
VALUE ary;
{
- rb_ary_modify(ary);
+ rb_ary_modify_check(ary);
if (RARRAY(ary)->len == 0) return Qnil;
- if (RARRAY(ary)->len * 10 < RARRAY(ary)->capa && RARRAY(ary)->capa > ARY_DEFAULT_SIZE) {
- RARRAY(ary)->capa = RARRAY(ary)->len * 2;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
+ if (!FL_TEST(ary, ELTS_SHARED) &&
+ RARRAY(ary)->len * 2 < RARRAY(ary)->aux.capa &&
+ RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) {
+ RARRAY(ary)->aux.capa = RARRAY(ary)->len * 2;
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->aux.capa);
}
return RARRAY(ary)->ptr[--RARRAY(ary)->len];
}
+static VALUE
+ary_make_shared(ary)
+ VALUE ary;
+{
+ if (!FL_TEST(ary, ELTS_SHARED)) {
+ NEWOBJ(shared, struct RArray);
+ OBJSETUP(shared, rb_cArray, T_ARRAY);
+
+ shared->len = RARRAY(ary)->len;
+ shared->ptr = RARRAY(ary)->ptr;
+ shared->aux.capa = RARRAY(ary)->aux.capa;
+ RARRAY(ary)->aux.shared = (VALUE)shared;
+ FL_SET(ary, ELTS_SHARED);
+ OBJ_FREEZE(shared);
+ return (VALUE)shared;
+ }
+ else {
+ return RARRAY(ary)->aux.shared;
+ }
+}
+
+/*
+ * call-seq:
+ * array.shift -> obj or nil
+ *
+ * Returns the first element of <i>self</i> and removes it (shifting all
+ * other elements down by one). Returns <code>nil</code> if the array
+ * is empty.
+ *
+ * args = [ "-m", "-q", "filename" ]
+ * args.shift #=> "-m"
+ * args #=> ["-q", "filename"]
+ */
+
VALUE
rb_ary_shift(ary)
VALUE ary;
{
VALUE top;
- rb_ary_modify(ary);
+ rb_ary_modify_check(ary);
if (RARRAY(ary)->len == 0) return Qnil;
-
top = RARRAY(ary)->ptr[0];
+ ary_make_shared(ary);
+ RARRAY(ary)->ptr++; /* shift ptr */
RARRAY(ary)->len--;
- /* sliding items */
- MEMMOVE(RARRAY(ary)->ptr, RARRAY(ary)->ptr+1, VALUE, RARRAY(ary)->len);
- if (RARRAY(ary)->len * 10 < RARRAY(ary)->capa && RARRAY(ary)->capa > ARY_DEFAULT_SIZE) {
- RARRAY(ary)->capa = RARRAY(ary)->len * 2;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
- }
-
return top;
}
@@ -336,17 +514,17 @@ rb_ary_unshift(ary, item)
VALUE ary, item;
{
rb_ary_modify(ary);
- if (RARRAY(ary)->len >= RARRAY(ary)->capa) {
- long capa_inc = RARRAY(ary)->capa / 2;
+ if (RARRAY(ary)->len == RARRAY(ary)->aux.capa) {
+ long capa_inc = RARRAY(ary)->aux.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);
+ RARRAY(ary)->aux.capa += capa_inc;
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->aux.capa);
}
/* sliding items */
- MEMMOVE(RARRAY(ary)->ptr+1, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
+ MEMMOVE(RARRAY(ary)->ptr + 1, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
RARRAY(ary)->len++;
RARRAY(ary)->ptr[0] = item;
@@ -354,109 +532,185 @@ rb_ary_unshift(ary, item)
return ary;
}
+/*
+ * call-seq:
+ * array.unshift(obj, ...) -> array
+ *
+ * Prepends objects to the front of <i>array</i>.
+ * other elements up one.
+ *
+ * a = [ "b", "c", "d" ]
+ * a.unshift("a") #=> ["a", "b", "c", "d"]
+ * a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"]
+ */
+
static VALUE
rb_ary_unshift_m(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
- if (argc == 0) {
- rb_raise(rb_eArgError, "wrong # of arguments(at least 1)");
+ long len = RARRAY(ary)->len;
+
+ if (argc < 0) {
+ rb_raise(rb_eArgError, "negative number of arguments");
}
- if (argc > 0) {
- long len = RARRAY(ary)->len;
+ if (argc == 0) return ary;
- /* make rooms by setting the last item */
- rb_ary_store(ary, len + argc - 1, Qnil);
+ /* make rooms by setting the last item */
+ rb_ary_store(ary, len + argc - 1, Qnil);
- /* sliding items */
- MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len);
- MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
- }
+ /* sliding items */
+ MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len);
+ MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc);
+
return ary;
}
-VALUE
-rb_ary_entry(ary, offset)
+/* faster version - use this if you don't need to treat negative offset */
+static inline VALUE
+rb_ary_elt(ary, offset)
VALUE ary;
long offset;
{
if (RARRAY(ary)->len == 0) return Qnil;
-
- if (offset < 0) {
- offset = RARRAY(ary)->len + offset;
- }
if (offset < 0 || RARRAY(ary)->len <= offset) {
return Qnil;
}
-
return RARRAY(ary)->ptr[offset];
}
+VALUE
+rb_ary_entry(ary, offset)
+ VALUE ary;
+ long offset;
+{
+ if (offset < 0) {
+ offset += RARRAY(ary)->len;
+ }
+ return rb_ary_elt(ary, offset);
+}
+
static VALUE
rb_ary_subseq(ary, beg, len)
VALUE ary;
long beg, len;
{
- VALUE ary2;
+ VALUE klass, ary2, shared;
+ VALUE *ptr;
if (beg > RARRAY(ary)->len) return Qnil;
if (beg < 0 || len < 0) return Qnil;
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
+ if (len < 0)
+ len = 0;
}
- if (len < 0) {
- len = 0;
- }
- if (len == 0) return rb_ary_new2(0);
+ klass = rb_obj_class(ary);
+ if (len == 0) return ary_new(klass, 0);
- ary2 = rb_ary_new2(len);
- MEMCPY(RARRAY(ary2)->ptr, RARRAY(ary)->ptr+beg, VALUE, len);
+ shared = ary_make_shared(ary);
+ ptr = RARRAY(ary)->ptr;
+ ary2 = ary_alloc(klass);
+ RARRAY(ary2)->ptr = ptr + beg;
RARRAY(ary2)->len = len;
+ RARRAY(ary2)->aux.shared = shared;
+ FL_SET(ary2, ELTS_SHARED);
return ary2;
}
+/*
+ * call-seq:
+ * array[index] -> obj or nil
+ * array[start, length] -> an_array or nil
+ * array[range] -> an_array or nil
+ * array.slice(index) -> obj or nil
+ * array.slice(start, length) -> an_array or nil
+ * array.slice(range) -> an_array or nil
+ *
+ * Element Reference---Returns the element at _index_,
+ * or returns a subarray starting at _start_ and
+ * continuing for _length_ elements, or returns a subarray
+ * specified by _range_.
+ * Negative indices count backward from the end of the
+ * array (-1 is the last element). Returns nil if the index
+ * (or starting index) are out of range.
+ *
+ * a = [ "a", "b", "c", "d", "e" ]
+ * a[2] + a[0] + a[1] #=> "cab"
+ * a[6] #=> nil
+ * a[1, 2] #=> [ "b", "c" ]
+ * a[1..3] #=> [ "b", "c", "d" ]
+ * a[4..7] #=> [ "e" ]
+ * a[6..10] #=> nil
+ * a[-3, 3] #=> [ "c", "d", "e" ]
+ * # special cases
+ * a[5] #=> nil
+ * a[5, 1] #=> []
+ * a[5..10] #=> []
+ *
+ */
+
VALUE
rb_ary_aref(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
- VALUE arg1, arg2;
+ VALUE arg;
long beg, len;
- if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
- beg = NUM2LONG(arg1);
- len = NUM2LONG(arg2);
+ if (argc == 2) {
+ if (SYMBOL_P(argv[0])) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
+ }
+ beg = NUM2LONG(argv[0]);
+ len = NUM2LONG(argv[1]);
if (beg < 0) {
- beg = RARRAY(ary)->len + beg;
+ beg += RARRAY(ary)->len;
}
return rb_ary_subseq(ary, beg, len);
}
-
+ if (argc != 1) {
+ rb_scan_args(argc, argv, "11", 0, 0);
+ }
+ arg = argv[0];
/* special case - speeding up */
- if (FIXNUM_P(arg1)) {
- return rb_ary_entry(ary, FIX2LONG(arg1));
+ if (FIXNUM_P(arg)) {
+ return rb_ary_entry(ary, FIX2LONG(arg));
}
- else if (TYPE(arg1) == T_BIGNUM) {
- rb_raise(rb_eIndexError, "index too big");
+ if (SYMBOL_P(arg)) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
}
- else {
- /* check if idx is Range */
- switch (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 0)) {
- case Qfalse:
- break;
- case Qnil:
- return Qnil;
- default:
- return rb_ary_subseq(ary, beg, len);
- }
+ /* check if idx is Range */
+ switch (rb_range_beg_len(arg, &beg, &len, RARRAY(ary)->len, 0)) {
+ case Qfalse:
+ break;
+ case Qnil:
+ return Qnil;
+ default:
+ return rb_ary_subseq(ary, beg, len);
}
- return rb_ary_entry(ary, NUM2LONG(arg1));
+ return rb_ary_entry(ary, NUM2LONG(arg));
}
+/*
+ * call-seq:
+ * array.at(index) -> obj or nil
+ *
+ * Returns the element at _index_. A
+ * negative index counts from the end of _self_. Returns +nil+
+ * if the index is out of range. See also <code>Array#[]</code>.
+ * (<code>Array#at</code> is slightly faster than <code>Array#[]</code>,
+ * as it does not accept ranges and so on.)
+ *
+ * a = [ "a", "b", "c", "d", "e" ]
+ * a.at(0) #=> "a"
+ * a.at(-1) #=> "e"
+ */
+
static VALUE
rb_ary_at(ary, pos)
VALUE ary, pos;
@@ -464,22 +718,141 @@ rb_ary_at(ary, pos)
return rb_ary_entry(ary, NUM2LONG(pos));
}
+/*
+ * call-seq:
+ * array.first -> obj or nil
+ *
+ * Returns the first element of the array. If the array is empty,
+ * returns <code>nil</code>.
+ *
+ * a = [ "q", "r", "s", "t" ]
+ * a.first #=> "q"
+ */
+
static VALUE
-rb_ary_first(ary)
+rb_ary_first(argc, argv, ary)
+ int argc;
+ VALUE *argv;
VALUE ary;
{
- if (RARRAY(ary)->len == 0) return Qnil;
- return RARRAY(ary)->ptr[0];
+ if (argc == 0) {
+ if (RARRAY(ary)->len == 0) return Qnil;
+ return RARRAY(ary)->ptr[0];
+ }
+ else {
+ VALUE nv, result;
+ long n, i;
+
+ rb_scan_args(argc, argv, "01", &nv);
+ n = NUM2LONG(nv);
+ if (n > RARRAY(ary)->len) n = RARRAY(ary)->len;
+ result = rb_ary_new2(n);
+ for (i=0; i<n; i++) {
+ rb_ary_push(result, RARRAY(ary)->ptr[i]);
+ }
+ return result;
+ }
}
+/*
+ * call-seq:
+ * array.last -> obj or nil
+ * array.last(n) -> an_array
+ *
+ * Returns the last element(s) of <i>self</i>. If the array is empty,
+ * the first form returns <code>nil</code>.
+ *
+ * [ "w", "x", "y", "z" ].last #=> "z"
+ */
+
static VALUE
-rb_ary_last(ary)
+rb_ary_last(argc, argv, ary)
+ int argc;
+ VALUE *argv;
VALUE ary;
{
- if (RARRAY(ary)->len == 0) return Qnil;
- return RARRAY(ary)->ptr[RARRAY(ary)->len-1];
+ if (argc == 0) {
+ if (RARRAY(ary)->len == 0) return Qnil;
+ return RARRAY(ary)->ptr[RARRAY(ary)->len-1];
+ }
+ else {
+ VALUE nv, result;
+ long n, i;
+
+ rb_scan_args(argc, argv, "01", &nv);
+ n = NUM2LONG(nv);
+ if (n > RARRAY(ary)->len) n = RARRAY(ary)->len;
+ result = rb_ary_new2(n);
+ for (i=RARRAY(ary)->len-n; n--; i++) {
+ rb_ary_push(result, RARRAY(ary)->ptr[i]);
+ }
+ return result;
+ }
+}
+
+/*
+ * call-seq:
+ * array.fetch(index) -> obj
+ * array.fetch(index, default ) -> obj
+ * array.fetch(index) {|index| block } -> obj
+ *
+ * Tries to return the element at position <i>index</i>. If the index
+ * lies outside the array, the first form throws an
+ * <code>IndexError</code> exception, the second form returns
+ * <i>default</i>, and the third form returns the value of invoking
+ * the block, passing in the index. Negative values of <i>index</i>
+ * count from the end of the array.
+ *
+ * a = [ 11, 22, 33, 44 ]
+ * a.fetch(1) #=> 22
+ * a.fetch(-1) #=> 44
+ * a.fetch(4, 'cat') #=> "cat"
+ * a.fetch(4) { |i| i*i } #=> 16
+ */
+
+static VALUE
+rb_ary_fetch(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+{
+ VALUE pos, ifnone;
+ long block_given;
+ long idx;
+
+ rb_scan_args(argc, argv, "11", &pos, &ifnone);
+ block_given = rb_block_given_p();
+ if (block_given && argc == 2) {
+ rb_warn("block supersedes default value argument");
+ }
+ idx = NUM2LONG(pos);
+
+ if (idx < 0) {
+ idx += RARRAY(ary)->len;
+ }
+ if (idx < 0 || RARRAY(ary)->len <= idx) {
+ if (block_given) return rb_yield(pos);
+ if (argc == 1) {
+ rb_raise(rb_eIndexError, "index %ld out of array", idx);
+ }
+ return ifnone;
+ }
+ return RARRAY(ary)->ptr[idx];
}
+/*
+ * call-seq:
+ * array.index(obj) -> int or nil
+ *
+ * Returns the index of the first object in <i>self</i> such that is
+ * <code>==</code> to <i>obj</i>. Returns <code>nil</code> if
+ * no match is found.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.index("b") #=> 1
+ * a.index("z") #=> nil
+ */
+
static VALUE
rb_ary_index(ary, val)
VALUE ary;
@@ -489,11 +862,24 @@ rb_ary_index(ary, val)
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], val))
- return INT2NUM(i);
+ return LONG2NUM(i);
}
return Qnil;
}
+/*
+ * call-seq:
+ * array.rindex(obj) -> int or nil
+ *
+ * Returns the index of the last object in <i>array</i>
+ * <code>==</code> to <i>obj</i>. Returns <code>nil</code> if
+ * no match is found.
+ *
+ * a = [ "a", "b", "b", "b", "c" ]
+ * a.rindex("b") #=> 3
+ * a.rindex("z") #=> nil
+ */
+
static VALUE
rb_ary_rindex(ary, val)
VALUE ary;
@@ -502,12 +888,24 @@ rb_ary_rindex(ary, val)
long i = RARRAY(ary)->len;
while (i--) {
+ if (i > RARRAY(ary)->len) {
+ i = RARRAY(ary)->len;
+ continue;
+ }
if (rb_equal(RARRAY(ary)->ptr[i], val))
- return INT2NUM(i);
+ return LONG2NUM(i);
}
return Qnil;
}
+/*
+ * call-seq:
+ * array.indexes( i1, i2, ... iN ) -> an_array
+ * array.indices( i1, i2, ... iN ) -> an_array
+ *
+ * Deprecated; use <code>Array#select</code>.
+ */
+
static VALUE
rb_ary_indexes(argc, argv, ary)
int argc;
@@ -517,6 +915,7 @@ rb_ary_indexes(argc, argv, ary)
VALUE new_ary;
long i;
+ rb_warn("Array#%s is deprecated; use Array#values_at", rb_id2name(rb_frame_last_func()));
new_ary = rb_ary_new2(argc);
for (i=0; i<argc; i++) {
rb_ary_push(new_ary, rb_ary_aref(1, argv+i, ary));
@@ -525,42 +924,58 @@ rb_ary_indexes(argc, argv, ary)
return new_ary;
}
+VALUE
+rb_ary_to_ary(obj)
+ VALUE obj;
+{
+ if (TYPE(obj) == T_ARRAY) {
+ return obj;
+ }
+ if (rb_respond_to(obj, rb_intern("to_ary"))) {
+ return rb_convert_type(obj, T_ARRAY, "Array", "to_ary");
+ }
+ return rb_ary_new3(1, obj);
+}
+
static void
-rb_ary_replace(ary, beg, len, rpl)
- VALUE ary, rpl;
+rb_ary_update(ary, beg, len, rpl)
+ VALUE ary;
long beg, len;
+ VALUE rpl;
{
long rlen;
- if (len < 0) rb_raise(rb_eIndexError, "negative length %d", len);
+ if (len < 0) rb_raise(rb_eIndexError, "negative length (%ld)", len);
if (beg < 0) {
beg += RARRAY(ary)->len;
- }
- if (beg < 0) {
- beg -= RARRAY(ary)->len;
- rb_raise(rb_eIndexError, "index %d out of array", beg);
+ if (beg < 0) {
+ beg -= RARRAY(ary)->len;
+ rb_raise(rb_eIndexError, "index %ld out of array", beg);
+ }
}
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}
+ rb_ary_modify(ary);
if (NIL_P(rpl)) {
- rpl = rb_ary_new2(0);
+ rlen = 0;
}
- else if (TYPE(rpl) != T_ARRAY) {
- rpl = rb_ary_new3(1, rpl);
+ else {
+ rpl = rb_ary_to_ary(rpl);
+ rlen = RARRAY(rpl)->len;
}
- rlen = RARRAY(rpl)->len;
- rb_ary_modify(ary);
if (beg >= RARRAY(ary)->len) {
len = beg + rlen;
- if (len >= RARRAY(ary)->capa) {
- RARRAY(ary)->capa=len;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
+ if (len >= RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
+ RARRAY(ary)->aux.capa = len;
+ }
+ rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len, beg - RARRAY(ary)->len);
+ if (rlen > 0) {
+ MEMCPY(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
}
- rb_mem_clear(RARRAY(ary)->ptr+RARRAY(ary)->len, beg-RARRAY(ary)->len);
- MEMCPY(RARRAY(ary)->ptr+beg, RARRAY(rpl)->ptr, VALUE, rlen);
RARRAY(ary)->len = len;
}
else {
@@ -571,20 +986,50 @@ rb_ary_replace(ary, beg, len, rpl)
}
alen = RARRAY(ary)->len + rlen - len;
- if (alen >= RARRAY(ary)->capa) {
- RARRAY(ary)->capa=alen;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
+ if (alen >= RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, alen);
+ RARRAY(ary)->aux.capa = alen;
}
- if (len != RARRAY(rpl)->len) {
- MEMMOVE(RARRAY(ary)->ptr+beg+rlen, RARRAY(ary)->ptr+beg+len,
- VALUE, RARRAY(ary)->len-(beg+len));
+ if (len != rlen) {
+ MEMMOVE(RARRAY(ary)->ptr + beg + rlen, RARRAY(ary)->ptr + beg + len,
+ VALUE, RARRAY(ary)->len - (beg + len));
RARRAY(ary)->len = alen;
}
- MEMMOVE(RARRAY(ary)->ptr+beg, RARRAY(rpl)->ptr, VALUE, rlen);
+ if (rlen > 0) {
+ MEMMOVE(RARRAY(ary)->ptr + beg, RARRAY(rpl)->ptr, VALUE, rlen);
+ }
}
}
+/*
+ * call-seq:
+ * array[index] = obj -> obj
+ * array[start, length] = obj or an_array or nil -> obj or an_array or nil
+ * array[range] = obj or an_array or nil -> obj or an_array or nil
+ *
+ * Element Assignment---Sets the element at _index_,
+ * or replaces a subarray starting at _start_ and
+ * continuing for _length_ elements, or replaces a subarray
+ * specified by _range_. If indices are greater than
+ * the current capacity of the array, the array grows
+ * automatically. A negative indices will count backward
+ * from the end of the array. Inserts elements if _length_ is
+ * zero. If +nil+ is used in the second and third form,
+ * deletes elements from _self_. An +IndexError+ is raised if a
+ * negative index points past the beginning of the array. See also
+ * <code>Array#push</code>, and <code>Array#unshift</code>.
+ *
+ * a = Array.new
+ * a[4] = "4"; #=> [nil, nil, nil, nil, "4"]
+ * a[0, 3] = [ 'a', 'b', 'c' ] #=> ["a", "b", "c", nil, "4"]
+ * a[1..2] = [ 1, 2 ] #=> ["a", 1, 2, nil, "4"]
+ * a[0, 2] = "?" #=> ["?", 2, nil, "4"]
+ * a[0..2] = "A" #=> ["A", "4"]
+ * a[-1] = "Z" #=> ["A", "Z"]
+ * a[1..-1] = nil #=> ["A"]
+ */
+
static VALUE
rb_ary_aset(argc, argv, ary)
int argc;
@@ -594,31 +1039,88 @@ rb_ary_aset(argc, argv, ary)
long offset, beg, len;
if (argc == 3) {
- rb_ary_replace(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
+ if (SYMBOL_P(argv[0])) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
+ }
+ if (SYMBOL_P(argv[1])) {
+ rb_raise(rb_eTypeError, "Symbol as subarray length");
+ }
+ rb_ary_update(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
return argv[2];
}
if (argc != 2) {
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
}
if (FIXNUM_P(argv[0])) {
offset = FIX2LONG(argv[0]);
goto fixnum;
}
- else if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
+ if (SYMBOL_P(argv[0])) {
+ rb_raise(rb_eTypeError, "Symbol as array index");
+ }
+ if (rb_range_beg_len(argv[0], &beg, &len, RARRAY(ary)->len, 1)) {
/* check if idx is Range */
- rb_ary_replace(ary, beg, len, argv[1]);
+ rb_ary_update(ary, beg, len, argv[1]);
return argv[1];
}
- if (TYPE(argv[0]) == T_BIGNUM) {
- rb_raise(rb_eIndexError, "index too big");
- }
offset = NUM2LONG(argv[0]);
- fixnum:
+fixnum:
rb_ary_store(ary, offset, argv[1]);
return argv[1];
}
+/*
+ * call-seq:
+ * array.insert(index, obj...) -> array
+ *
+ * Inserts the given values before the element with the given index
+ * (which may be negative).
+ *
+ * a = %w{ a b c d }
+ * a.insert(2, 99) #=> ["a", "b", 99, "c", "d"]
+ * a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
+ */
+
+static VALUE
+rb_ary_insert(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+{
+ long pos;
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "wrong number of arguments (at least 1)");
+ }
+ pos = NUM2LONG(argv[0]);
+ if (pos == -1) {
+ pos = RARRAY(ary)->len;
+ }
+ else if (pos < 0) {
+ pos++;
+ }
+
+ if (argc == 1) return ary;
+ rb_ary_update(ary, pos, 0, rb_ary_new4(argc - 1, argv + 1));
+ return ary;
+}
+
+/*
+ * call-seq:
+ * array.each {|item| block } -> array
+ *
+ * Calls <i>block</i> once for each element in <i>self</i>, passing that
+ * element as a parameter.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.each {|x| print x, " -- " }
+ *
+ * produces:
+ *
+ * a -- b -- c --
+ */
+
VALUE
rb_ary_each(ary)
VALUE ary;
@@ -631,6 +1133,21 @@ rb_ary_each(ary)
return ary;
}
+/*
+ * call-seq:
+ * array.each_index {|index| block } -> array
+ *
+ * Same as <code>Array#each</code>, but passes the index of the element
+ * instead of the element itself.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.each_index {|x| print x, " -- " }
+ *
+ * produces:
+ *
+ * 0 -- 1 -- 2 --
+ */
+
static VALUE
rb_ary_each_index(ary)
VALUE ary;
@@ -638,11 +1155,26 @@ rb_ary_each_index(ary)
long i;
for (i=0; i<RARRAY(ary)->len; i++) {
- rb_yield(INT2NUM(i));
+ rb_yield(LONG2NUM(i));
}
return ary;
}
+/*
+ * call-seq:
+ * array.reverse_each {|item| block }
+ *
+ * Same as <code>Array#each</code>, but traverses <i>self</i> in reverse
+ * order.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.reverse_each {|x| print x, " " }
+ *
+ * produces:
+ *
+ * c b a
+ */
+
static VALUE
rb_ary_reverse_each(ary)
VALUE ary;
@@ -651,17 +1183,38 @@ rb_ary_reverse_each(ary)
while (len--) {
rb_yield(RARRAY(ary)->ptr[len]);
+ if (RARRAY(ary)->len < len) {
+ len = RARRAY(ary)->len;
+ }
}
return ary;
}
+/*
+ * call-seq:
+ * array.length -> int
+ *
+ * Returns the number of elements in <i>self</i>. May be zero.
+ *
+ * [ 1, 2, 3, 4, 5 ].length #=> 5
+ */
+
static VALUE
rb_ary_length(ary)
VALUE ary;
{
- return INT2NUM(RARRAY(ary)->len);
+ return LONG2NUM(RARRAY(ary)->len);
}
+/*
+ * call-seq:
+ * array.empty? -> true or false
+ *
+ * Returns <code>true</code> if <i>self</i> array contains no elements.
+ *
+ * [].empty? #=> true
+ */
+
static VALUE
rb_ary_empty_p(ary)
VALUE ary;
@@ -671,23 +1224,16 @@ rb_ary_empty_p(ary)
return Qfalse;
}
-static VALUE
-rb_ary_clone(ary)
+VALUE
+rb_ary_dup(ary)
VALUE ary;
{
- VALUE clone = rb_ary_new2(RARRAY(ary)->len);
-
- CLONESETUP(clone, ary);
- MEMCPY(RARRAY(clone)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
- RARRAY(clone)->len = RARRAY(ary)->len;
- return clone;
-}
+ VALUE dup = rb_ary_new2(RARRAY(ary)->len);
-static VALUE
-to_ary(ary)
- VALUE ary;
-{
- return rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
+ DUPSETUP(dup, ary);
+ MEMCPY(RARRAY(dup)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
+ RARRAY(dup)->len = RARRAY(ary)->len;
+ return dup;
}
extern VALUE rb_output_fs;
@@ -704,38 +1250,23 @@ VALUE
rb_ary_join(ary, sep)
VALUE ary, sep;
{
- long i;
- int taint = 0;
+ long len = 1, i;
+ int taint = Qfalse;
VALUE result, tmp;
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
- if (OBJ_TAINTED(ary)) taint = 1;
- if (OBJ_TAINTED(sep)) taint = 1;
-
- tmp = RARRAY(ary)->ptr[0];
- if (OBJ_TAINTED(tmp)) taint = 1;
- switch (TYPE(tmp)) {
- case T_STRING:
- result = rb_str_dup(tmp);
- break;
- case T_ARRAY:
- if (rb_inspecting_p(tmp)) {
- result = rb_str_new2("[...]");
- }
- else {
- VALUE args[2];
+ if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = Qtrue;
- args[0] = tmp;
- args[1] = sep;
- result = rb_protect_inspect(inspect_join, ary, (VALUE)args);
- }
- break;
- default:
- result = rb_str_dup(rb_obj_as_string(tmp));
- break;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ tmp = rb_check_string_type(RARRAY(ary)->ptr[i]);
+ len += NIL_P(tmp) ? 10 : RSTRING(tmp)->len;
}
-
- for (i=1; i<RARRAY(ary)->len; i++) {
+ if (!NIL_P(sep)) {
+ StringValue(sep);
+ len += RSTRING(sep)->len * (RARRAY(ary)->len - 1);
+ }
+ result = rb_str_buf_new(len);
+ for (i=0; i<RARRAY(ary)->len; i++) {
tmp = RARRAY(ary)->ptr[i];
switch (TYPE(tmp)) {
case T_STRING:
@@ -755,15 +1286,27 @@ rb_ary_join(ary, sep)
default:
tmp = rb_obj_as_string(tmp);
}
- if (!NIL_P(sep)) rb_str_append(result, sep);
- rb_str_append(result, tmp);
- if (OBJ_TAINTED(tmp)) taint = 1;
+ if (i > 0 && !NIL_P(sep))
+ rb_str_buf_append(result, sep);
+ rb_str_buf_append(result, tmp);
+ if (OBJ_TAINTED(tmp)) taint = Qtrue;
}
if (taint) OBJ_TAINT(result);
return result;
}
+/*
+ * call-seq:
+ * array.join(sep=$,) -> str
+ *
+ * Returns a string created by converting each element of the array to
+ * a string, separated by <i>sep</i>.
+ *
+ * [ "a", "b", "c" ].join #=> "abc"
+ * [ "a", "b", "c" ].join("-") #=> "a-b-c"
+ */
+
static VALUE
rb_ary_join_m(argc, argv, ary)
int argc;
@@ -774,19 +1317,27 @@ rb_ary_join_m(argc, argv, ary)
rb_scan_args(argc, argv, "01", &sep);
if (NIL_P(sep)) sep = rb_output_fs;
+
return rb_ary_join(ary, sep);
}
+/*
+ * call-seq:
+ * array.to_s -> string
+ *
+ * Returns _self_<code>.join</code>.
+ *
+ * [ "a", "e", "i", "o" ].to_s #=> "aeio"
+ *
+ */
+
VALUE
rb_ary_to_s(ary)
VALUE ary;
{
- VALUE str;
-
if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
- str = rb_ary_join(ary, rb_output_fs);
- if (NIL_P(str)) return rb_str_new(0, 0);
- return str;
+
+ return rb_ary_join(ary, rb_output_fs);
}
static ID inspect_key;
@@ -796,7 +1347,7 @@ struct inspect_arg {
VALUE arg1, arg2;
};
-VALUE
+static VALUE
inspect_call(arg)
struct inspect_arg *arg;
{
@@ -804,33 +1355,50 @@ inspect_call(arg)
}
static VALUE
+get_inspect_tbl(create)
+ int create;
+{
+ VALUE inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
+
+ if (NIL_P(inspect_tbl)) {
+ if (create) {
+ tbl_init:
+ inspect_tbl = rb_ary_new();
+ rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl);
+ }
+ }
+ else if (TYPE(inspect_tbl) != T_ARRAY) {
+ rb_warn("invalid inspect_tbl value");
+ if (create) goto tbl_init;
+ rb_thread_local_aset(rb_thread_current(), inspect_key, Qnil);
+ return Qnil;
+ }
+ return inspect_tbl;
+}
+
+static VALUE
inspect_ensure(obj)
VALUE obj;
{
VALUE inspect_tbl;
- inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
- rb_ary_pop(inspect_tbl);
+ inspect_tbl = get_inspect_tbl(Qfalse);
+ if (!NIL_P(inspect_tbl)) {
+ rb_ary_pop(inspect_tbl);
+ }
return 0;
}
VALUE
rb_protect_inspect(func, obj, arg)
- VALUE (*func)();
+ VALUE (*func)(ANYARGS);
VALUE obj, arg;
{
struct inspect_arg iarg;
VALUE inspect_tbl;
VALUE id;
- if (!inspect_key) {
- inspect_key = rb_intern("__inspect_key__");
- }
- inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
- if (NIL_P(inspect_tbl)) {
- inspect_tbl = rb_ary_new();
- rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl);
- }
+ inspect_tbl = get_inspect_tbl(Qtrue);
id = rb_obj_id(obj);
if (rb_ary_includes(inspect_tbl, id)) {
return (*func)(obj, arg);
@@ -849,8 +1417,7 @@ rb_inspecting_p(obj)
{
VALUE inspect_tbl;
- if (!inspect_key) return Qfalse;
- inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key);
+ inspect_tbl = get_inspect_tbl(Qfalse);
if (NIL_P(inspect_tbl)) return Qfalse;
return rb_ary_includes(inspect_tbl, rb_obj_id(obj));
}
@@ -860,23 +1427,28 @@ inspect_ary(ary)
VALUE ary;
{
int tainted = OBJ_TAINTED(ary);
- long i = 0;
+ long i;
VALUE s, str;
- str = rb_str_new2("[");
-
+ str = rb_str_buf_new2("[");
for (i=0; i<RARRAY(ary)->len; i++) {
s = rb_inspect(RARRAY(ary)->ptr[i]);
- tainted = OBJ_TAINTED(s);
- if (i > 0) rb_str_cat2(str, ", ");
- rb_str_append(str, s);
+ if (OBJ_TAINTED(s)) tainted = Qtrue;
+ if (i > 0) rb_str_buf_cat2(str, ", ");
+ rb_str_buf_append(str, s);
}
- rb_str_cat(str, "]", 1);
-
+ rb_str_buf_cat2(str, "]");
if (tainted) OBJ_TAINT(str);
return str;
}
+/*
+ * call-seq:
+ * array.inspect -> string
+ *
+ * Create a printable version of <i>array</i>.
+ */
+
static VALUE
rb_ary_inspect(ary)
VALUE ary;
@@ -886,10 +1458,37 @@ rb_ary_inspect(ary)
return rb_protect_inspect(inspect_ary, ary, 0);
}
+/*
+ * call-seq:
+ * array.to_a -> array
+ *
+ * Returns _self_. If called on a subclass of Array, converts
+ * the receiver to an Array object.
+ */
+
static VALUE
rb_ary_to_a(ary)
VALUE ary;
{
+ if (rb_obj_class(ary) != rb_cArray) {
+ VALUE dup = rb_ary_new2(RARRAY(ary)->len);
+ rb_ary_replace(dup, ary);
+ return dup;
+ }
+ return ary;
+}
+
+/*
+ * call-seq:
+ * array.to_ary -> array
+ *
+ * Returns _self_.
+ */
+
+static VALUE
+rb_ary_to_ary_m(ary)
+ VALUE ary;
+{
return ary;
}
@@ -900,69 +1499,118 @@ rb_ary_reverse(ary)
VALUE *p1, *p2;
VALUE tmp;
- if (RARRAY(ary)->len <= 1) return ary;
rb_ary_modify(ary);
-
- p1 = RARRAY(ary)->ptr;
- p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
-
- while (p1 < p2) {
- tmp = *p1;
- *p1++ = *p2;
- *p2-- = tmp;
+ if (RARRAY(ary)->len > 1) {
+ p1 = RARRAY(ary)->ptr;
+ p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
+
+ while (p1 < p2) {
+ tmp = *p1;
+ *p1++ = *p2;
+ *p2-- = tmp;
+ }
}
-
return ary;
}
+/*
+ * call-seq:
+ * array.reverse! -> array
+ *
+ * Reverses _self_ in place.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.reverse! #=> ["c", "b", "a"]
+ * a #=> ["c", "b", "a"]
+ */
+
static VALUE
rb_ary_reverse_bang(ary)
VALUE ary;
{
- if (RARRAY(ary)->len <= 1) return Qnil;
return rb_ary_reverse(ary);
}
+/*
+ * call-seq:
+ * array.reverse -> an_array
+ *
+ * Returns a new array containing <i>self</i>'s elements in reverse order.
+ *
+ * [ "a", "b", "c" ].reverse #=> ["c", "b", "a"]
+ * [ 1 ].reverse #=> [1]
+ */
+
static VALUE
rb_ary_reverse_m(ary)
VALUE ary;
{
- return rb_ary_reverse(rb_obj_dup(ary));
+ return rb_ary_reverse(rb_ary_dup(ary));
}
-static ID cmp;
+struct ary_sort_data {
+ VALUE ary;
+ VALUE *ptr;
+ long len;
+};
+
+static void
+ary_sort_check(data)
+ struct ary_sort_data *data;
+{
+ if (RARRAY(data->ary)->ptr != data->ptr || RARRAY(data->ary)->len != data->len) {
+ rb_raise(rb_eArgError, "array modified during sort");
+ }
+}
static int
-sort_1(a, b)
+sort_1(a, b, data)
VALUE *a, *b;
+ struct ary_sort_data *data;
{
- VALUE retval = rb_yield(rb_assoc_new(*a, *b));
- return NUM2INT(retval);
+ VALUE retval = rb_yield_values(2, *a, *b);
+ int n;
+
+ n = rb_cmpint(retval, *a, *b);
+ ary_sort_check(data);
+ return n;
}
static int
-sort_2(a, b)
- VALUE *a, *b;
+sort_2(ap, bp, data)
+ VALUE *ap, *bp;
+ struct ary_sort_data *data;
{
VALUE retval;
+ VALUE a = *ap, b = *bp;
+ int n;
- if (FIXNUM_P(*a)) {
- if (FIXNUM_P(*b)) return *a - *b;
+ if (FIXNUM_P(a) && FIXNUM_P(b)) {
+ if ((long)a > (long)b) return 1;
+ if ((long)a < (long)b) return -1;
+ return 0;
}
- else if (TYPE(*a) == T_STRING && TYPE(*b) == T_STRING) {
- return rb_str_cmp(*a, *b);
+ if (TYPE(a) == T_STRING && TYPE(b) == T_STRING) {
+ return rb_str_cmp(a, b);
}
- retval = rb_funcall(*a, cmp, 1, *b);
- return NUM2INT(retval);
+ retval = rb_funcall(a, id_cmp, 1, b);
+ n = rb_cmpint(retval, a, b);
+ ary_sort_check(data);
+
+ return n;
}
static VALUE
sort_internal(ary)
VALUE ary;
{
+ struct ary_sort_data data;
+
+ data.ary = ary;
+ data.ptr = RARRAY(ary)->ptr; data.len = RARRAY(ary)->len;
qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE),
- rb_block_given_p()?sort_1:sort_2);
+ rb_block_given_p()?sort_1:sort_2, &data);
return ary;
}
@@ -974,46 +1622,105 @@ sort_unlock(ary)
return ary;
}
+/*
+ * call-seq:
+ * array.sort! -> array
+ * array.sort! {| a,b | block } -> array
+ *
+ * Sorts _self_. Comparisons for
+ * the sort will be done using the <code><=></code> operator or using
+ * an optional code block. The block implements a comparison between
+ * <i>a</i> and <i>b</i>, returning -1, 0, or +1. See also
+ * <code>Enumerable#sort_by</code>.
+ *
+ * a = [ "d", "a", "e", "c", "b" ]
+ * a.sort #=> ["a", "b", "c", "d", "e"]
+ * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
+ */
+
VALUE
rb_ary_sort_bang(ary)
VALUE ary;
{
rb_ary_modify(ary);
- if (RARRAY(ary)->len <= 1) return Qnil;
-
- FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
- rb_ensure(sort_internal, ary, sort_unlock, ary);
+ if (RARRAY(ary)->len > 1) {
+ FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
+ rb_ensure(sort_internal, ary, sort_unlock, ary);
+ }
return ary;
}
+/*
+ * call-seq:
+ * array.sort -> an_array
+ * array.sort {| a,b | block } -> an_array
+ *
+ * Returns a new array created by sorting <i>self</i>. Comparisons for
+ * the sort will be done using the <code><=></code> operator or using
+ * an optional code block. The block implements a comparison between
+ * <i>a</i> and <i>b</i>, returning -1, 0, or +1. See also
+ * <code>Enumerable#sort_by</code>.
+ *
+ * a = [ "d", "a", "e", "c", "b" ]
+ * a.sort #=> ["a", "b", "c", "d", "e"]
+ * a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
+ */
+
VALUE
rb_ary_sort(ary)
VALUE ary;
{
- ary = rb_obj_dup(ary);
+ ary = rb_ary_dup(ary);
rb_ary_sort_bang(ary);
return ary;
}
+/*
+ * call-seq:
+ * array.collect {|item| block } -> an_array
+ * array.map {|item| block } -> an_array
+ *
+ * Invokes <i>block</i> once for each element of <i>self</i>. Creates a
+ * new array containing the values returned by the block.
+ * See also <code>Enumerable#collect</code>.
+ *
+ * a = [ "a", "b", "c", "d" ]
+ * a.collect {|x| x + "!" } #=> ["a!", "b!", "c!", "d!"]
+ * a #=> ["a", "b", "c", "d"]
+ */
+
static VALUE
rb_ary_collect(ary)
VALUE ary;
{
- long len, i;
+ long i;
VALUE collect;
if (!rb_block_given_p()) {
- return rb_obj_dup(ary);
+ return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
}
- len = RARRAY(ary)->len;
- collect = rb_ary_new2(len);
- for (i=0; i<len; i++) {
+ collect = rb_ary_new2(RARRAY(ary)->len);
+ for (i = 0; i < RARRAY(ary)->len; i++) {
rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr[i]));
}
return collect;
}
+/*
+ * call-seq:
+ * array.collect! {|item| block } -> array
+ * array.map! {|item| block } -> array
+ *
+ * Invokes the block once for each element of _self_, replacing the
+ * element with the value returned by _block_.
+ * See also <code>Enumerable#collect</code>.
+ *
+ * a = [ "a", "b", "c", "d" ]
+ * a.collect! {|x| x + "!" }
+ * a #=> [ "a!", "b!", "c!", "d!" ]
+ */
+
static VALUE
rb_ary_collect_bang(ary)
VALUE ary;
@@ -1022,19 +1729,119 @@ rb_ary_collect_bang(ary)
rb_ary_modify(ary);
for (i = 0; i < RARRAY(ary)->len; i++) {
- RARRAY(ary)->ptr[i] = rb_yield(RARRAY(ary)->ptr[i]);
+ rb_ary_store(ary, i, rb_yield(RARRAY(ary)->ptr[i]));
}
return ary;
}
+VALUE
+rb_values_at(obj, olen, argc, argv, func)
+ VALUE obj;
+ long olen;
+ int argc;
+ VALUE *argv;
+ VALUE (*func) _((VALUE,long));
+{
+ VALUE result = rb_ary_new2(argc);
+ long beg, len, i, j;
+
+ for (i=0; i<argc; i++) {
+ if (FIXNUM_P(argv[i])) {
+ rb_ary_push(result, (*func)(obj, FIX2LONG(argv[i])));
+ continue;
+ }
+ /* check if idx is Range */
+ switch (rb_range_beg_len(argv[i], &beg, &len, olen, 0)) {
+ case Qfalse:
+ break;
+ case Qnil:
+ continue;
+ default:
+ for (j=0; j<len; j++) {
+ rb_ary_push(result, (*func)(obj, j+beg));
+ }
+ continue;
+ }
+ rb_ary_push(result, (*func)(obj, NUM2LONG(argv[i])));
+ }
+ return result;
+}
+
+/*
+ * call-seq:
+ * array.values_at(selector,... ) -> an_array
+ *
+ * Returns an array containing the elements in
+ * _self_ corresponding to the given selector(s). The selectors
+ * may be either integer indices or ranges.
+ * See also <code>Array#select</code>.
+ *
+ * a = %w{ a b c d e f }
+ * a.values_at(1, 3, 5)
+ * a.values_at(1, 3, 5, 7)
+ * a.values_at(-1, -3, -5, -7)
+ * a.values_at(1..3, 2...5)
+ */
+
+static VALUE
+rb_ary_values_at(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+{
+ return rb_values_at(ary, RARRAY(ary)->len, argc, argv, rb_ary_entry);
+}
+
+/*
+ * call-seq:
+ * array.select {|item| block } -> an_array
+ *
+ * Invokes the block passing in successive elements from <i>array</i>,
+ * returning an array containing those elements for which the block
+ * returns a true value (equivalent to <code>Enumerable#select</code>).
+ *
+ * a = %w{ a b c d e f }
+ * a.select {|v| v =~ /[aeiou]/} #=> ["a", "e"]
+ */
+
static VALUE
-rb_ary_filter(ary)
+rb_ary_select(argc, argv, ary)
+ int argc;
+ VALUE *argv;
VALUE ary;
{
- rb_warn("Array#filter is deprecated; use Array#collect!");
- return rb_ary_collect_bang(ary);
+ VALUE result;
+ long i;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ result = rb_ary_new2(RARRAY(ary)->len);
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ if (RTEST(rb_yield(RARRAY(ary)->ptr[i]))) {
+ rb_ary_push(result, rb_ary_elt(ary, i));
+ }
+ }
+ return result;
}
+/*
+ * call-seq:
+ * array.delete(obj) -> obj or nil
+ * array.delete(obj) { block } -> obj or nil
+ *
+ * Deletes items from <i>self</i> that are equal to <i>obj</i>. If
+ * the item is not found, returns <code>nil</code>. If the optional
+ * code block is given, returns the result of <i>block</i> if the item
+ * is not found.
+ *
+ * a = [ "a", "b", "b", "b", "c" ]
+ * a.delete("b") #=> "b"
+ * a #=> ["a", "c"]
+ * a.delete("z") #=> nil
+ * a.delete("z") { "not found" } #=> "not found"
+ */
+
VALUE
rb_ary_delete(ary, item)
VALUE ary;
@@ -1044,9 +1851,11 @@ rb_ary_delete(ary, item)
rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
- if (rb_equal(RARRAY(ary)->ptr[i1], item)) continue;
+ VALUE e = RARRAY(ary)->ptr[i1];
+
+ if (rb_equal(e, item)) continue;
if (i1 != i2) {
- RARRAY(ary)->ptr[i2] = RARRAY(ary)->ptr[i1];
+ rb_ary_store(ary, i2, e);
}
i2++;
}
@@ -1056,8 +1865,14 @@ rb_ary_delete(ary, item)
}
return Qnil;
}
- else {
+
+ if (RARRAY(ary)->len > i2) {
RARRAY(ary)->len = i2;
+ if (i2 * 2 < RARRAY(ary)->aux.capa &&
+ RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2);
+ RARRAY(ary)->aux.capa = i2 * 2;
+ }
}
return item;
@@ -1069,12 +1884,14 @@ rb_ary_delete_at(ary, pos)
long pos;
{
long i, len = RARRAY(ary)->len;
- VALUE del = Qnil;
+ VALUE del;
rb_ary_modify(ary);
if (pos >= len) return Qnil;
- if (pos < 0) pos += len;
- if (pos < 0) return Qnil;
+ if (pos < 0) {
+ pos += len;
+ if (pos < 0) return Qnil;
+ }
del = RARRAY(ary)->ptr[pos];
for (i = pos + 1; i < len; i++, pos++) {
@@ -1085,13 +1902,52 @@ rb_ary_delete_at(ary, pos)
return del;
}
-VALUE
+/*
+ * call-seq:
+ * array.delete_at(index) -> obj or nil
+ *
+ * Deletes the element at the specified index, returning that element,
+ * or <code>nil</code> if the index is out of range. See also
+ * <code>Array#slice!</code>.
+ *
+ * a = %w( ant bat cat dog )
+ * a.delete_at(2) #=> "cat"
+ * a #=> ["ant", "bat", "dog"]
+ * a.delete_at(99) #=> nil
+ */
+
+static VALUE
rb_ary_delete_at_m(ary, pos)
VALUE ary, pos;
{
return rb_ary_delete_at(ary, NUM2LONG(pos));
}
+/*
+ * call-seq:
+ * array.slice!(index) -> obj or nil
+ * array.slice!(start, length) -> sub_array or nil
+ * array.slice!(range) -> sub_array or nil
+ *
+ * Deletes the element(s) given by an index (optionally with a length)
+ * or by a range. Returns the deleted object, subarray, or
+ * <code>nil</code> if the index is out of range. Equivalent to:
+ *
+ * def slice!(*args)
+ * result = self[*args]
+ * self[*args] = nil
+ * result
+ * end
+ *
+ * a = [ "a", "b", "c" ]
+ * a.slice!(1) #=> "b"
+ * a #=> ["a", "c"]
+ * a.slice!(-1) #=> "c"
+ * a #=> ["a"]
+ * a.slice!(100) #=> nil
+ * a #=> ["a"]
+ */
+
static VALUE
rb_ary_slice_bang(argc, argv, ary)
int argc;
@@ -1099,7 +1955,7 @@ rb_ary_slice_bang(argc, argv, ary)
VALUE ary;
{
VALUE arg1, arg2;
- long pos, len, i;
+ long pos, len;
rb_ary_modify(ary);
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
@@ -1110,7 +1966,7 @@ rb_ary_slice_bang(argc, argv, ary)
pos = RARRAY(ary)->len + pos;
}
arg2 = rb_ary_subseq(ary, pos, len);
- rb_ary_replace(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
+ rb_ary_update(ary, pos, len, Qnil); /* Qnil/rb_ary_new2(0) */
return arg2;
}
@@ -1118,22 +1974,19 @@ rb_ary_slice_bang(argc, argv, ary)
goto delete_pos_len;
}
- pos = NUM2LONG(arg1);
- len = RARRAY(ary)->len;
-
- if (pos >= len) return Qnil;
- if (pos < 0) pos += len;
- if (pos < 0) return Qnil;
-
- arg2 = RARRAY(ary)->ptr[pos];
- for (i = pos + 1; i < len; i++, pos++) {
- RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
- }
- RARRAY(ary)->len = pos;
-
- return arg2;
+ return rb_ary_delete_at(ary, NUM2LONG(arg1));
}
+/*
+ * call-seq:
+ * array.reject! {|item| block } -> array or nil
+ *
+ * Equivalent to <code>Array#delete_if</code>, deleting elements from
+ * _self_ for which the block evaluates to true, but returns
+ * <code>nil</code> if no changes were made. Also see
+ * <code>Enumerable#reject</code>.
+ */
+
static VALUE
rb_ary_reject_bang(ary)
VALUE ary;
@@ -1142,48 +1995,236 @@ rb_ary_reject_bang(ary)
rb_ary_modify(ary);
for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
- if (RTEST(rb_yield(RARRAY(ary)->ptr[i1]))) continue;
+ VALUE v = RARRAY(ary)->ptr[i1];
+ if (RTEST(rb_yield(v))) continue;
if (i1 != i2) {
- RARRAY(ary)->ptr[i2] = RARRAY(ary)->ptr[i1];
+ rb_ary_store(ary, i2, v);
}
i2++;
}
if (RARRAY(ary)->len == i2) return Qnil;
- RARRAY(ary)->len = i2;
+ if (i2 < RARRAY(ary)->len)
+ RARRAY(ary)->len = i2;
return ary;
}
+/*
+ * call-seq:
+ * array.reject {|item| block } -> an_array
+ *
+ * Returns a new array containing the items in _self_
+ * for which the block is not true.
+ */
+
static VALUE
-rb_ary_delete_if(ary)
+rb_ary_reject(ary)
VALUE ary;
{
+ ary = rb_ary_dup(ary);
rb_ary_reject_bang(ary);
return ary;
}
+/*
+ * call-seq:
+ * array.delete_if {|item| block } -> array
+ *
+ * Deletes every element of <i>self</i> for which <i>block</i> evaluates
+ * to <code>true</code>.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.delete_if {|x| x >= "b" } #=> ["a"]
+ */
+
static VALUE
-rb_ary_replace_m(ary, ary2)
- VALUE ary, ary2;
+rb_ary_delete_if(ary)
+ VALUE ary;
{
- ary2 = to_ary(ary2);
- rb_ary_replace(ary, 0, RARRAY(ary)->len, ary2);
+ rb_ary_reject_bang(ary);
return ary;
}
+/*
+ * call-seq:
+ * array.zip(arg, ...) -> an_array
+ * array.zip(arg, ...) {| arr | block } -> nil
+ *
+ * Converts any arguments to arrays, then merges elements of
+ * <i>self</i> with corresponding elements from each argument. This
+ * generates a sequence of <code>self.size</code> <em>n</em>-element
+ * arrays, where <em>n</em> is one more that the count of arguments. If
+ * the size of any argument is less than <code>enumObj.size</code>,
+ * <code>nil</code> values are supplied. If a block given, it is
+ * invoked for each output array, otherwise an array of arrays is
+ * returned.
+ *
+ * a = [ 4, 5, 6 ]
+ * b = [ 7, 8, 9 ]
+ *
+ * [1,2,3].zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
+ * [1,2].zip(a,b) #=> [[1, 4, 7], [2, 5, 8]]
+ * a.zip([1,2],[8]) #=> [[4,1,8], [5,2,nil], [6,nil,nil]]
+ */
+
+static VALUE
+rb_ary_zip(argc, argv, ary)
+ int argc;
+ VALUE *argv;
+ VALUE ary;
+{
+ int i, j;
+ long len;
+ VALUE result;
+
+ for (i=0; i<argc; i++) {
+ argv[i] = to_ary(argv[i]);
+ }
+ if (rb_block_given_p()) {
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ VALUE tmp = rb_ary_new2(argc+1);
+
+ rb_ary_push(tmp, rb_ary_elt(ary, i));
+ for (j=0; j<argc; j++) {
+ rb_ary_push(tmp, rb_ary_elt(argv[j], i));
+ }
+ rb_yield(tmp);
+ }
+ return Qnil;
+ }
+ len = RARRAY(ary)->len;
+ result = rb_ary_new2(len);
+ for (i=0; i<len; i++) {
+ VALUE tmp = rb_ary_new2(argc+1);
+
+ rb_ary_push(tmp, rb_ary_elt(ary, i));
+ for (j=0; j<argc; j++) {
+ rb_ary_push(tmp, rb_ary_elt(argv[j], i));
+ }
+ rb_ary_push(result, tmp);
+ }
+ return result;
+}
+
+/*
+ * call-seq:
+ * array.transpose -> an_array
+ *
+ * Assumes that <i>self</i> is an array of arrays and transposes the
+ * rows and columns.
+ *
+ * a = [[1,2], [3,4], [5,6]]
+ * a.transpose #=> [[1, 3, 5], [2, 4, 6]]
+ */
+
+static VALUE
+rb_ary_transpose(ary)
+ VALUE ary;
+{
+ long elen = -1, alen, i, j;
+ VALUE tmp, result = 0;
+
+ alen = RARRAY(ary)->len;
+ if (alen == 0) return rb_ary_dup(ary);
+ for (i=0; i<alen; i++) {
+ tmp = to_ary(rb_ary_elt(ary, i));
+ if (elen < 0) { /* first element */
+ elen = RARRAY(tmp)->len;
+ result = rb_ary_new2(elen);
+ for (j=0; j<elen; j++) {
+ rb_ary_store(result, j, rb_ary_new2(alen));
+ }
+ }
+ else if (elen != RARRAY(tmp)->len) {
+ rb_raise(rb_eIndexError, "element size differ (%d should be %d)",
+ RARRAY(tmp)->len, elen);
+ }
+ for (j=0; j<elen; j++) {
+ rb_ary_store(rb_ary_elt(result, j), i, rb_ary_elt(tmp, j));
+ }
+ }
+ return result;
+}
+
+/*
+ * call-seq:
+ * array.replace(other_array) -> array
+ *
+ * Replaces the contents of <i>self</i> with the contents of
+ * <i>other_array</i>, truncating or expanding if necessary.
+ *
+ * a = [ "a", "b", "c", "d", "e" ]
+ * a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"]
+ * a #=> ["x", "y", "z"]
+ */
+
+static VALUE
+rb_ary_replace(copy, orig)
+ VALUE copy, orig;
+{
+ VALUE shared;
+
+ rb_ary_modify(copy);
+ orig = to_ary(orig);
+ if (copy == orig) return copy;
+ shared = ary_make_shared(orig);
+ if (RARRAY(copy)->ptr && !FL_TEST(copy, ELTS_SHARED))
+ free(RARRAY(copy)->ptr);
+ RARRAY(copy)->ptr = RARRAY(orig)->ptr;
+ RARRAY(copy)->len = RARRAY(orig)->len;
+ RARRAY(copy)->aux.shared = shared;
+ FL_SET(copy, ELTS_SHARED);
+
+ return copy;
+}
+
+/*
+ * call-seq:
+ * array.clear -> array
+ *
+ * Removes all elements from _self_.
+ *
+ * a = [ "a", "b", "c", "d", "e" ]
+ * a.clear #=> [ ]
+ */
+
VALUE
rb_ary_clear(ary)
VALUE ary;
{
rb_ary_modify(ary);
RARRAY(ary)->len = 0;
- if (ARY_DEFAULT_SIZE*3 < RARRAY(ary)->capa) {
- RARRAY(ary)->capa = ARY_DEFAULT_SIZE * 2;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
+ if (ARY_DEFAULT_SIZE * 2 < RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, ARY_DEFAULT_SIZE * 2);
+ RARRAY(ary)->aux.capa = ARY_DEFAULT_SIZE * 2;
}
return ary;
}
+/*
+ * call-seq:
+ * array.fill(obj) -> array
+ * array.fill(obj, start [, length]) -> array
+ * array.fill(obj, range ) -> array
+ * array.fill {|index| block } -> array
+ * array.fill(start [, length] ) {|index| block } -> array
+ * array.fill(range) {|index| block } -> array
+ *
+ * The first three forms set the selected elements of <i>self</i> (which
+ * may be the entire array) to <i>obj</i>. A <i>start</i> of
+ * <code>nil</code> is equivalent to zero. A <i>length</i> of
+ * <code>nil</code> is equivalent to <i>self.length</i>. The last three
+ * forms fill the array with the value of the block. The block is
+ * passed the absolute index of each element to be filled.
+ *
+ * a = [ "a", "b", "c", "d" ]
+ * a.fill("x") #=> ["x", "x", "x", "x"]
+ * a.fill("z", 2, 2) #=> ["x", "x", "z", "z"]
+ * a.fill("y", 0..1) #=> ["y", "y", "z", "z"]
+ * a.fill {|i| i*i} #=> [0, 1, 4, 9]
+ * a.fill(-2) {|i| i*i*i} #=> [0, 1, 8, 27]
+ */
+
static VALUE
rb_ary_fill(argc, argv, ary)
int argc;
@@ -1193,12 +2234,20 @@ rb_ary_fill(argc, argv, ary)
VALUE item, arg1, arg2;
long beg, end, len;
VALUE *p, *pend;
+ int block_p = Qfalse;
- rb_scan_args(argc, argv, "12", &item, &arg1, &arg2);
+ if (rb_block_given_p()) {
+ block_p = Qtrue;
+ rb_scan_args(argc, argv, "02", &arg1, &arg2);
+ argc += 1; /* hackish */
+ }
+ else {
+ rb_scan_args(argc, argv, "12", &item, &arg1, &arg2);
+ }
switch (argc) {
case 1:
beg = 0;
- len = RARRAY(ary)->len - beg;
+ len = RARRAY(ary)->len;
break;
case 2:
if (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 1)) {
@@ -1206,187 +2255,314 @@ rb_ary_fill(argc, argv, ary)
}
/* fall through */
case 3:
- beg = NIL_P(arg1)?0:NUM2LONG(arg1);
+ beg = NIL_P(arg1) ? 0 : NUM2LONG(arg1);
if (beg < 0) {
beg = RARRAY(ary)->len + beg;
if (beg < 0) beg = 0;
}
- len = NIL_P(arg2)?RARRAY(ary)->len - beg:NUM2LONG(arg2);
+ len = NIL_P(arg2) ? RARRAY(ary)->len - beg : NUM2LONG(arg2);
break;
}
rb_ary_modify(ary);
end = beg + len;
if (end > RARRAY(ary)->len) {
- if (end >= RARRAY(ary)->capa) {
- RARRAY(ary)->capa=end;
- REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->capa);
+ if (end >= RARRAY(ary)->aux.capa) {
+ REALLOC_N(RARRAY(ary)->ptr, VALUE, end);
+ RARRAY(ary)->aux.capa = end;
}
if (beg > RARRAY(ary)->len) {
- rb_mem_clear(RARRAY(ary)->ptr+RARRAY(ary)->len,end-RARRAY(ary)->len);
+ rb_mem_clear(RARRAY(ary)->ptr + RARRAY(ary)->len, end - RARRAY(ary)->len);
}
RARRAY(ary)->len = end;
}
- p = RARRAY(ary)->ptr + beg; pend = p + len;
- while (p < pend) {
- *p++ = item;
+ if (block_p) {
+ VALUE v;
+ long i;
+
+ for (i=beg; i<end; i++) {
+ v = rb_yield(LONG2NUM(i));
+ if (i>=RARRAY(ary)->len) break;
+ RARRAY(ary)->ptr[i] = v;
+ }
+ }
+ else {
+ p = RARRAY(ary)->ptr + beg;
+ pend = p + len;
+ while (p < pend) {
+ *p++ = item;
+ }
}
return ary;
}
+/*
+ * call-seq:
+ * array + other_array -> an_array
+ *
+ * Concatenation---Returns a new array built by concatenating the
+ * two arrays together to produce a third array.
+ *
+ * [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ]
+ */
+
VALUE
rb_ary_plus(x, y)
VALUE x, y;
{
VALUE z;
+ long len;
y = to_ary(y);
- z = rb_ary_new2(RARRAY(x)->len + RARRAY(y)->len);
+ len = RARRAY(x)->len + RARRAY(y)->len;
+ z = rb_ary_new2(len);
MEMCPY(RARRAY(z)->ptr, RARRAY(x)->ptr, VALUE, RARRAY(x)->len);
- MEMCPY(RARRAY(z)->ptr+RARRAY(x)->len, RARRAY(y)->ptr, VALUE, RARRAY(y)->len);
- RARRAY(z)->len = RARRAY(x)->len + RARRAY(y)->len;
+ MEMCPY(RARRAY(z)->ptr + RARRAY(x)->len, RARRAY(y)->ptr, VALUE, RARRAY(y)->len);
+ RARRAY(z)->len = len;
return z;
}
+/*
+ * call-seq:
+ * array.concat(other_array) -> array
+ *
+ * Appends the elements in other_array to _self_.
+ *
+ * [ "a", "b" ].concat( ["c", "d"] ) #=> [ "a", "b", "c", "d" ]
+ */
+
+
VALUE
rb_ary_concat(x, y)
VALUE x, y;
{
- long xlen = RARRAY(x)->len;
- long ylen;
-
y = to_ary(y);
- ylen = RARRAY(y)->len;
- if (ylen > 0) {
- rb_ary_modify(x);
- if (xlen + ylen > RARRAY(x)->capa) {
- RARRAY(x)->capa = xlen + ylen;
- REALLOC_N(RARRAY(x)->ptr, VALUE, RARRAY(x)->capa);
- }
- MEMCPY(RARRAY(x)->ptr+xlen, RARRAY(y)->ptr, VALUE, ylen);
- RARRAY(x)->len = xlen + ylen;
+ if (RARRAY(y)->len > 0) {
+ rb_ary_update(x, RARRAY(x)->len, 0, y);
}
return x;
}
+
+/*
+ * call-seq:
+ * array * int -> an_array
+ * array * str -> a_string
+ *
+ * Repetition---With a String argument, equivalent to
+ * self.join(str). Otherwise, returns a new array
+ * built by concatenating the _int_ copies of _self_.
+ *
+ *
+ * [ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
+ * [ 1, 2, 3 ] * "," #=> "1,2,3"
+ *
+ */
+
static VALUE
rb_ary_times(ary, times)
- VALUE ary;
- VALUE times;
+ VALUE ary, times;
{
- VALUE ary2;
+ VALUE ary2, tmp;
long i, len;
- if (TYPE(times) == T_STRING) {
- return rb_ary_join(ary, times);
+ tmp = rb_check_string_type(times);
+ if (!NIL_P(tmp)) {
+ return rb_ary_join(ary, tmp);
}
len = NUM2LONG(times);
+ if (len == 0) return ary_new(rb_obj_class(ary), 0);
if (len < 0) {
rb_raise(rb_eArgError, "negative argument");
}
+ if (LONG_MAX/len < RARRAY(ary)->len) {
+ rb_raise(rb_eArgError, "argument too big");
+ }
len *= RARRAY(ary)->len;
- ary2 = rb_ary_new2(len);
+ ary2 = ary_new(rb_obj_class(ary), len);
RARRAY(ary2)->len = len;
for (i=0; i<len; i+=RARRAY(ary)->len) {
MEMCPY(RARRAY(ary2)->ptr+i, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
}
+ OBJ_INFECT(ary2, ary);
return ary2;
}
+/*
+ * call-seq:
+ * array.assoc(obj) -> an_array or nil
+ *
+ * Searches through an array whose elements are also arrays
+ * comparing _obj_ with the first element of each contained array
+ * using obj.==.
+ * Returns the first contained array that matches (that
+ * is, the first associated array),
+ * or +nil+ if no match is found.
+ * See also <code>Array#rassoc</code>.
+ *
+ * s1 = [ "colors", "red", "blue", "green" ]
+ * s2 = [ "letters", "a", "b", "c" ]
+ * s3 = "foo"
+ * a = [ s1, s2, s3 ]
+ * a.assoc("letters") #=> [ "letters", "a", "b", "c" ]
+ * a.assoc("foo") #=> nil
+ */
+
VALUE
rb_ary_assoc(ary, key)
- VALUE ary;
- VALUE key;
+ VALUE ary, key;
{
- VALUE *p, *pend;
+ long i;
+ VALUE v;
- p = RARRAY(ary)->ptr; pend = p + RARRAY(ary)->len;
- while (p < pend) {
- if (TYPE(*p) == T_ARRAY
- && RARRAY(*p)->len > 0
- && rb_equal(RARRAY(*p)->ptr[0], key))
- return *p;
- p++;
+ for (i = 0; i < RARRAY(ary)->len; ++i) {
+ v = RARRAY(ary)->ptr[i];
+ if (TYPE(v) == T_ARRAY &&
+ RARRAY(v)->len > 0 &&
+ rb_equal(RARRAY(v)->ptr[0], key))
+ return v;
}
return Qnil;
}
+/*
+ * call-seq:
+ * array.rassoc(key) -> an_array or nil
+ *
+ * Searches through the array whose elements are also arrays. Compares
+ * <em>key</em> with the second element of each contained array using
+ * <code>==</code>. Returns the first contained array that matches. See
+ * also <code>Array#assoc</code>.
+ *
+ * a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ]
+ * a.rassoc("two") #=> [2, "two"]
+ * a.rassoc("four") #=> nil
+ */
+
VALUE
rb_ary_rassoc(ary, value)
- VALUE ary;
- VALUE value;
+ VALUE ary, value;
{
- VALUE *p, *pend;
+ long i;
+ VALUE v;
- p = RARRAY(ary)->ptr; pend = p + RARRAY(ary)->len;
- while (p < pend) {
- if (TYPE(*p) == T_ARRAY
- && RARRAY(*p)->len > 1
- && rb_equal(RARRAY(*p)->ptr[1], value))
- return *p;
- p++;
+ for (i = 0; i < RARRAY(ary)->len; ++i) {
+ v = RARRAY(ary)->ptr[i];
+ if (TYPE(v) == T_ARRAY &&
+ RARRAY(v)->len > 1 &&
+ rb_equal(RARRAY(v)->ptr[1], value))
+ return v;
}
return Qnil;
}
+/*
+ * call-seq:
+ * array == other_array -> bool
+ *
+ * Equality---Two arrays are equal if they contain the same number
+ * of elements and if each element is equal to (according to
+ * Object.==) the corresponding element in the other array.
+ *
+ * [ "a", "c" ] == [ "a", "c", 7 ] #=> false
+ * [ "a", "c", 7 ] == [ "a", "c", 7 ] #=> true
+ * [ "a", "c", 7 ] == [ "a", "d", "f" ] #=> false
+ *
+ */
+
static VALUE
rb_ary_equal(ary1, ary2)
VALUE ary1, ary2;
{
long i;
- if (TYPE(ary2) != T_ARRAY) return Qfalse;
+ if (ary1 == ary2) return Qtrue;
+ if (TYPE(ary2) != T_ARRAY) {
+ if (!rb_respond_to(ary2, rb_intern("to_ary"))) {
+ return Qfalse;
+ }
+ return rb_equal(ary2, ary1);
+ }
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {
- if (!rb_equal(RARRAY(ary1)->ptr[i], RARRAY(ary2)->ptr[i]))
+ if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
}
return Qtrue;
}
+/*
+ * call-seq:
+ * array.eql?(other) -> true or false
+ *
+ * Returns <code>true</code> if _array_ and _other_ are the same object,
+ * or are both arrays with the same content.
+ */
+
static VALUE
rb_ary_eql(ary1, ary2)
VALUE ary1, ary2;
{
long i;
+ if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
- if (RARRAY(ary1)->len != RARRAY(ary2)->len)
- return Qfalse;
+ if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
for (i=0; i<RARRAY(ary1)->len; i++) {
- if (!rb_eql(RARRAY(ary1)->ptr[i], RARRAY(ary2)->ptr[i]))
+ if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
}
return Qtrue;
}
+/*
+ * call-seq:
+ * array.hash -> fixnum
+ *
+ * Compute a hash-code for this array. Two arrays with the same content
+ * will have the same hash code (and will compare using <code>eql?</code>).
+ */
+
static VALUE
rb_ary_hash(ary)
VALUE ary;
{
- long i;
+ long i, h;
VALUE n;
- long h;
h = RARRAY(ary)->len;
for (i=0; i<RARRAY(ary)->len; i++) {
- h = (h<<1) | (h<0 ? 1 : 0);
+ h = (h << 1) | (h<0 ? 1 : 0);
n = rb_hash(RARRAY(ary)->ptr[i]);
h ^= NUM2LONG(n);
}
- return INT2FIX(h);
+ return LONG2FIX(h);
}
+/*
+ * call-seq:
+ * array.include?(obj) -> true or false
+ *
+ * Returns <code>true</code> if the given object is present in
+ * <i>self</i> (that is, if any object <code>==</code> <i>anObject</i>),
+ * <code>false</code> otherwise.
+ *
+ * a = [ "a", "b", "c" ]
+ * a.include?("b") #=> true
+ * a.include?("z") #=> false
+ */
+
VALUE
rb_ary_includes(ary, item)
VALUE ary;
VALUE item;
{
long i;
+
for (i=0; i<RARRAY(ary)->len; i++) {
if (rb_equal(RARRAY(ary)->ptr[i], item)) {
return Qtrue;
@@ -1395,53 +2571,56 @@ rb_ary_includes(ary, item)
return Qfalse;
}
-static VALUE
-rb_ary_cmp(ary, ary2)
- VALUE ary;
- VALUE ary2;
+
+/*
+ * call-seq:
+ * array <=> other_array -> -1, 0, +1
+ *
+ * Comparison---Returns an integer (-1, 0,
+ * or +1) if this array is less than, equal to, or greater than
+ * other_array. Each object in each array is compared
+ * (using <=>). If any value isn't
+ * equal, then that inequality is the return value. If all the
+ * values found are equal, then the return is based on a
+ * comparison of the array lengths. Thus, two arrays are
+ * ``equal'' according to <code>Array#<=></code> if and only if they have
+ * the same length and the value of each element is equal to the
+ * value of the corresponding element in the other array.
+ *
+ * [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1
+ * [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1
+ *
+ */
+
+VALUE
+rb_ary_cmp(ary1, ary2)
+ VALUE ary1, ary2;
{
long i, len;
ary2 = to_ary(ary2);
- len = RARRAY(ary)->len;
+ len = RARRAY(ary1)->len;
if (len > RARRAY(ary2)->len) {
len = RARRAY(ary2)->len;
}
for (i=0; i<len; i++) {
- VALUE v = rb_funcall(RARRAY(ary)->ptr[i],cmp,1,RARRAY(ary2)->ptr[i]);
+ VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
if (v != INT2FIX(0)) {
return v;
}
}
- len = RARRAY(ary)->len - RARRAY(ary2)->len;
+ len = RARRAY(ary1)->len - RARRAY(ary2)->len;
if (len == 0) return INT2FIX(0);
if (len > 0) return INT2FIX(1);
return INT2FIX(-1);
}
static VALUE
-rb_ary_diff(ary1, ary2)
- VALUE ary1, ary2;
-{
- VALUE ary3;
- long i;
-
- ary2 = to_ary(ary2);
- ary3 = rb_ary_new();
- for (i=0; i<RARRAY(ary1)->len; i++) {
- if (rb_ary_includes(ary2, RARRAY(ary1)->ptr[i])) continue;
- if (rb_ary_includes(ary3, RARRAY(ary1)->ptr[i])) continue;
- rb_ary_push(ary3, RARRAY(ary1)->ptr[i]);
- }
- return ary3;
-}
-
-static VALUE
ary_make_hash(ary1, ary2)
VALUE ary1, ary2;
{
VALUE hash = rb_hash_new();
- int i, n;
+ long i;
for (i=0; i<RARRAY(ary1)->len; i++) {
rb_hash_aset(hash, RARRAY(ary1)->ptr[i], Qtrue);
@@ -1454,20 +2633,61 @@ ary_make_hash(ary1, ary2)
return hash;
}
+/*
+ * call-seq:
+ * array - other_array -> an_array
+ *
+ * Array Difference---Returns a new array that is a copy of
+ * the original array, removing any items that also appear in
+ * other_array. (If you need set-like behavior, see the
+ * library class Set.)
+ *
+ * [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ]
+ */
+
+static VALUE
+rb_ary_diff(ary1, ary2)
+ VALUE ary1, ary2;
+{
+ VALUE ary3, hash;
+ long i;
+
+ hash = ary_make_hash(to_ary(ary2), 0);
+ ary3 = rb_ary_new();
+
+ for (i=0; i<RARRAY(ary1)->len; i++) {
+ if (st_lookup(RHASH(hash)->tbl, RARRAY(ary1)->ptr[i], 0)) continue;
+ rb_ary_push(ary3, rb_ary_elt(ary1, i));
+ }
+ return ary3;
+}
+
+/*
+ * call-seq:
+ * array & other_array
+ *
+ * Set Intersection---Returns a new array
+ * containing elements common to the two arrays, with no duplicates.
+ *
+ * [ 1, 1, 3, 5 ] & [ 1, 2, 3 ] #=> [ 1, 3 ]
+ */
+
+
static VALUE
rb_ary_and(ary1, ary2)
VALUE ary1, ary2;
{
- VALUE hash;
- VALUE ary3 = rb_ary_new();
+ VALUE hash, ary3, v, vv;
long i;
ary2 = to_ary(ary2);
+ ary3 = rb_ary_new2(RARRAY(ary1)->len < RARRAY(ary2)->len ?
+ RARRAY(ary1)->len : RARRAY(ary2)->len);
hash = ary_make_hash(ary2, 0);
for (i=0; i<RARRAY(ary1)->len; i++) {
- VALUE v = RARRAY(ary1)->ptr[i];
- if (st_delete(RHASH(hash)->tbl, &v, 0)) {
+ v = vv = rb_ary_elt(ary1, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
@@ -1475,68 +2695,113 @@ rb_ary_and(ary1, ary2)
return ary3;
}
+/*
+ * call-seq:
+ * array | other_array -> an_array
+ *
+ * Set Union---Returns a new array by joining this array with
+ * other_array, removing duplicates.
+ *
+ * [ "a", "b", "c" ] | [ "c", "d", "a" ]
+ * #=> [ "a", "b", "c", "d" ]
+ */
+
static VALUE
rb_ary_or(ary1, ary2)
VALUE ary1, ary2;
{
- VALUE hash;
- VALUE ary3 = rb_ary_new();
- VALUE v;
+ VALUE hash, ary3;
+ VALUE v, vv;
long i;
ary2 = to_ary(ary2);
+ ary3 = rb_ary_new2(RARRAY(ary1)->len+RARRAY(ary2)->len);
hash = ary_make_hash(ary1, ary2);
for (i=0; i<RARRAY(ary1)->len; i++) {
- v = RARRAY(ary1)->ptr[i];
- if (st_delete(RHASH(hash)->tbl, &v, 0)) {
+ v = vv = rb_ary_elt(ary1, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
for (i=0; i<RARRAY(ary2)->len; i++) {
- v = RARRAY(ary2)->ptr[i];
- if (st_delete(RHASH(hash)->tbl, &v, 0)) {
+ v = vv = rb_ary_elt(ary2, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
rb_ary_push(ary3, v);
}
}
-
return ary3;
}
+/*
+ * call-seq:
+ * array.uniq! -> array or nil
+ *
+ * Removes duplicate elements from _self_.
+ * Returns <code>nil</code> if no changes are made (that is, no
+ * duplicates are found).
+ *
+ * a = [ "a", "a", "b", "b", "c" ]
+ * a.uniq! #=> ["a", "b", "c"]
+ * b = [ "a", "b", "c" ]
+ * b.uniq! #=> nil
+ */
+
static VALUE
rb_ary_uniq_bang(ary)
VALUE ary;
{
- VALUE hash = ary_make_hash(ary, 0);
- VALUE *p, *q, *end;
+ VALUE hash, v, vv;
+ long i, j;
+
+ rb_ary_modify(ary);
+
+ hash = ary_make_hash(ary, 0);
if (RARRAY(ary)->len == RHASH(hash)->tbl->num_entries) {
return Qnil;
}
-
- rb_ary_modify(ary);
- p = q = RARRAY(ary)->ptr;
- end = p + RARRAY(ary)->len;
- while (p < end) {
- VALUE v = *p++;
- if (st_delete(RHASH(hash)->tbl, &v, 0)) {
- *q++ = v;
+ for (i=j=0; i<RARRAY(ary)->len; i++) {
+ v = vv = rb_ary_elt(ary, i);
+ if (st_delete(RHASH(hash)->tbl, (st_data_t*)&vv, 0)) {
+ rb_ary_store(ary, j++, v);
}
}
- RARRAY(ary)->len = (q - RARRAY(ary)->ptr);
+ RARRAY(ary)->len = j;
return ary;
}
+/*
+ * call-seq:
+ * array.uniq -> an_array
+ *
+ * Returns a new array by removing duplicate values in <i>self</i>.
+ *
+ * a = [ "a", "a", "b", "b", "c" ]
+ * a.uniq #=> ["a", "b", "c"]
+ */
+
static VALUE
rb_ary_uniq(ary)
VALUE ary;
{
- ary = rb_obj_dup(ary);
+ ary = rb_ary_dup(ary);
rb_ary_uniq_bang(ary);
return ary;
}
+/*
+ * call-seq:
+ * array.compact! -> array or nil
+ *
+ * Removes +nil+ elements from array.
+ * Returns +nil+ if no changes were made.
+ *
+ * [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ]
+ * [ "a", "b", "c" ].compact! #=> nil
+ */
+
static VALUE
rb_ary_compact_bang(ary)
VALUE ary;
@@ -1546,6 +2811,7 @@ rb_ary_compact_bang(ary)
rb_ary_modify(ary);
p = t = RARRAY(ary)->ptr;
end = p + RARRAY(ary)->len;
+
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
@@ -1553,21 +2819,41 @@ rb_ary_compact_bang(ary)
if (RARRAY(ary)->len == (p - RARRAY(ary)->ptr)) {
return Qnil;
}
- RARRAY(ary)->len = RARRAY(ary)->capa = (p - RARRAY(ary)->ptr);
+ RARRAY(ary)->len = RARRAY(ary)->aux.capa = (p - RARRAY(ary)->ptr);
REALLOC_N(RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
return ary;
}
+/*
+ * call-seq:
+ * array.compact -> an_array
+ *
+ * Returns a copy of _self_ with all +nil+ elements removed.
+ *
+ * [ "a", nil, "b", nil, "c", nil ].compact
+ * #=> [ "a", "b", "c" ]
+ */
+
static VALUE
rb_ary_compact(ary)
VALUE ary;
{
- ary = rb_obj_dup(ary);
+ ary = rb_ary_dup(ary);
rb_ary_compact_bang(ary);
return ary;
}
+/*
+ * call-seq:
+ * array.nitems -> int
+ *
+ * Returns the number of non-<code>nil</code> elements in _self_.
+ * May be zero.
+ *
+ * [ 1, nil, 3, nil, 5 ].nitems #=> 3
+ */
+
static VALUE
rb_ary_nitems(ary)
VALUE ary;
@@ -1577,87 +2863,151 @@ rb_ary_nitems(ary)
p = RARRAY(ary)->ptr;
pend = p + RARRAY(ary)->len;
+
while (p < pend) {
if (!NIL_P(*p)) n++;
p++;
}
- return INT2NUM(n);
+ return LONG2NUM(n);
}
+static long
+flatten(ary, idx, ary2, memo)
+ VALUE ary;
+ long idx;
+ VALUE ary2, memo;
+{
+ VALUE id;
+ long i = idx;
+ long n, lim = idx + RARRAY(ary2)->len;
+
+ id = rb_obj_id(ary2);
+ if (rb_ary_includes(memo, id)) {
+ rb_raise(rb_eArgError, "tried to flatten recursive array");
+ }
+ rb_ary_push(memo, id);
+ rb_ary_update(ary, idx, 1, ary2);
+ while (i < lim) {
+ VALUE tmp;
+
+ tmp = rb_check_array_type(rb_ary_elt(ary, i));
+ if (!NIL_P(tmp)) {
+ n = flatten(ary, i, tmp, memo);
+ i += n; lim += n;
+ }
+ i++;
+ }
+ rb_ary_pop(memo);
+
+ return lim - idx - 1; /* returns number of increased items */
+}
+
+/*
+ * call-seq:
+ * array.flatten! -> array or nil
+ *
+ * Flattens _self_ in place.
+ * Returns <code>nil</code> if no modifications were made (i.e.,
+ * <i>array</i> contains no subarrays.)
+ *
+ * a = [ 1, 2, [3, [4, 5] ] ]
+ * a.flatten! #=> [1, 2, 3, 4, 5]
+ * a.flatten! #=> nil
+ * a #=> [1, 2, 3, 4, 5]
+ */
+
static VALUE
rb_ary_flatten_bang(ary)
VALUE ary;
{
- long i;
+ long i = 0;
int mod = 0;
- VALUE flattening = Qnil;
+ VALUE memo = Qnil;
rb_ary_modify(ary);
- for (i=0; i<RARRAY(ary)->len; i++) {
+ while (i<RARRAY(ary)->len) {
VALUE ary2 = RARRAY(ary)->ptr[i];
- if (TYPE(ary2) == T_ARRAY) {
- if (ary == ary2) {
- ary2 = Qnil;
- } else {
- VALUE id;
-
- if (NIL_P(flattening)) {
- flattening = rb_ary_new();
- }
- id = rb_obj_id(ary2);
- if (rb_ary_includes(flattening, id)) {
- rb_raise(rb_eArgError, "tried to flatten recursive array");
- }
- rb_ary_push(flattening, id);
+ VALUE tmp;
+
+ tmp = rb_check_array_type(ary2);
+ if (!NIL_P(tmp)) {
+ if (NIL_P(memo)) {
+ memo = rb_ary_new();
}
- rb_ary_replace(ary, i--, 1, ary2);
+ i += flatten(ary, i, tmp, memo);
mod = 1;
}
+ i++;
}
if (mod == 0) return Qnil;
return ary;
}
+/*
+ * call-seq:
+ * array.flatten -> an_array
+ *
+ * Returns a new array that is a one-dimensional flattening of this
+ * array (recursively). That is, for every element that is an array,
+ * extract its elements into the new array.
+ *
+ * s = [ 1, 2, 3 ] #=> [1, 2, 3]
+ * t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
+ * a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
+ * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10
+ */
+
static VALUE
rb_ary_flatten(ary)
VALUE ary;
{
- ary = rb_obj_dup(ary);
+ ary = rb_ary_dup(ary);
rb_ary_flatten_bang(ary);
return ary;
}
+
+/* Arrays are ordered, integer-indexed collections of any object.
+ * Array indexing starts at 0, as in C or Java. A negative index is
+ * assumed to be relative to the end of the array---that is, an index of -1
+ * indicates the last element of the array, -2 is the next to last
+ * element in the array, and so on.
+ */
+
void
Init_Array()
{
rb_cArray = rb_define_class("Array", rb_cObject);
rb_include_module(rb_cArray, rb_mEnumerable);
- rb_define_singleton_method(rb_cArray, "new", rb_ary_s_new, -1);
+ rb_define_alloc_func(rb_cArray, ary_alloc);
rb_define_singleton_method(rb_cArray, "[]", rb_ary_s_create, -1);
rb_define_method(rb_cArray, "initialize", rb_ary_initialize, -1);
+ rb_define_method(rb_cArray, "initialize_copy", rb_ary_replace, 1);
+
rb_define_method(rb_cArray, "to_s", rb_ary_to_s, 0);
rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0);
rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0);
- rb_define_method(rb_cArray, "to_ary", rb_ary_to_a, 0);
+ rb_define_method(rb_cArray, "to_ary", rb_ary_to_ary_m, 0);
rb_define_method(rb_cArray, "frozen?", rb_ary_frozen_p, 0);
rb_define_method(rb_cArray, "==", rb_ary_equal, 1);
rb_define_method(rb_cArray, "eql?", rb_ary_eql, 1);
rb_define_method(rb_cArray, "hash", rb_ary_hash, 0);
- rb_define_method(rb_cArray, "===", rb_ary_equal, 1);
rb_define_method(rb_cArray, "[]", rb_ary_aref, -1);
rb_define_method(rb_cArray, "[]=", rb_ary_aset, -1);
rb_define_method(rb_cArray, "at", rb_ary_at, 1);
- rb_define_method(rb_cArray, "first", rb_ary_first, 0);
- rb_define_method(rb_cArray, "last", rb_ary_last, 0);
+ rb_define_method(rb_cArray, "fetch", rb_ary_fetch, -1);
+ rb_define_method(rb_cArray, "first", rb_ary_first, -1);
+ rb_define_method(rb_cArray, "last", rb_ary_last, -1);
rb_define_method(rb_cArray, "concat", rb_ary_concat, 1);
rb_define_method(rb_cArray, "<<", rb_ary_push, 1);
rb_define_method(rb_cArray, "push", rb_ary_push_m, -1);
rb_define_method(rb_cArray, "pop", rb_ary_pop, 0);
rb_define_method(rb_cArray, "shift", rb_ary_shift, 0);
rb_define_method(rb_cArray, "unshift", rb_ary_unshift_m, -1);
+ rb_define_method(rb_cArray, "insert", rb_ary_insert, -1);
rb_define_method(rb_cArray, "each", rb_ary_each, 0);
rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0);
rb_define_method(rb_cArray, "reverse_each", rb_ary_reverse_each, 0);
@@ -1668,7 +3018,6 @@ Init_Array()
rb_define_method(rb_cArray, "rindex", rb_ary_rindex, 1);
rb_define_method(rb_cArray, "indexes", rb_ary_indexes, -1);
rb_define_method(rb_cArray, "indices", rb_ary_indexes, -1);
- rb_define_method(rb_cArray, "clone", rb_ary_clone, 0);
rb_define_method(rb_cArray, "join", rb_ary_join_m, -1);
rb_define_method(rb_cArray, "reverse", rb_ary_reverse_m, 0);
rb_define_method(rb_cArray, "reverse!", rb_ary_reverse_bang, 0);
@@ -1676,13 +3025,18 @@ Init_Array()
rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0);
rb_define_method(rb_cArray, "collect", rb_ary_collect, 0);
rb_define_method(rb_cArray, "collect!", rb_ary_collect_bang, 0);
+ rb_define_method(rb_cArray, "map", rb_ary_collect, 0);
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
- rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
+ rb_define_method(rb_cArray, "select", rb_ary_select, -1);
+ rb_define_method(rb_cArray, "values_at", rb_ary_values_at, -1);
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at_m, 1);
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);
+ rb_define_method(rb_cArray, "reject", rb_ary_reject, 0);
rb_define_method(rb_cArray, "reject!", rb_ary_reject_bang, 0);
- rb_define_method(rb_cArray, "replace", rb_ary_replace_m, 1);
+ rb_define_method(rb_cArray, "zip", rb_ary_zip, -1);
+ rb_define_method(rb_cArray, "transpose", rb_ary_transpose, 0);
+ rb_define_method(rb_cArray, "replace", rb_ary_replace, 1);
rb_define_method(rb_cArray, "clear", rb_ary_clear, 0);
rb_define_method(rb_cArray, "fill", rb_ary_fill, -1);
rb_define_method(rb_cArray, "include?", rb_ary_includes, 1);
@@ -1709,5 +3063,6 @@ Init_Array()
rb_define_method(rb_cArray, "flatten!", rb_ary_flatten_bang, 0);
rb_define_method(rb_cArray, "nitems", rb_ary_nitems, 0);
- cmp = rb_intern("<=>");
+ id_cmp = rb_intern("<=>");
+ inspect_key = rb_intern("__inspect_key__");
}
diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub
new file mode 100644
index 0000000000..0c4c6bb126
--- /dev/null
+++ b/bcc32/Makefile.sub
@@ -0,0 +1,585 @@
+# -*- makefile -*-
+
+SHELL = $(COMSPEC)
+
+#### Start of system configuration section. ####
+OS = bccwin32
+RT = $(OS)
+
+## variables may be overridden by $(compile_dir)/Makefile
+!ifndef srcdir
+srcdir = ..
+!endif
+!ifndef RUBY_INSTALL_NAME
+RUBY_INSTALL_NAME = ruby
+!endif
+!ifndef RUBYW_INSTALL_NAME
+RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME:ruby=rubyw)
+!elif "$(RUBYW_INSTALL_NAME)" == "$(RUBY_INSTALL_NAME)"
+RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME:ruby=rubyw)
+!endif
+!if "$(RUBYW_INSTALL_NAME)" == "$(RUBY_INSTALL_NAME)"
+RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME)w
+!endif
+!ifndef RUBY_SO_NAME
+RUBY_SO_NAME = $(RT)-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)
+!endif
+!ifndef icondirs
+!ifdef ICONDIRS
+icondirs=$(ICONDIRS)
+!endif
+!endif
+!ifdef icondirs
+icondirs=$(icondirs:\=/)
+iconinc=-I$(icondirs: = -I)
+!endif
+###############
+
+VPATH = $(srcdir):$(srcdir)/missing
+.SUFFIXES: .y
+
+!ifndef CC
+CC = bcc32
+!endif
+!ifndef CPP
+CPP = cpp32
+!endif
+!ifndef RC
+RC = brcc32
+!endif
+!ifndef YACC
+YACC = byacc
+!endif
+!ifndef AR
+AR = tlib
+!endif
+
+PURIFY =
+AUTOCONF = autoconf
+
+!if !defined(PROCESSOR_ARCHITECTURE)
+PROCESSOR_ARCHITECTURE = x86
+!endif
+MACHINE = $(PROCESSOR_ARCHITECTURE)
+!if "$(PROCESSOR_ARCHITECTURE)" == "x86"
+!ifndef PROCESSOR_LEVEL
+PROCESSOR_LEVEL = 5
+!endif
+!if 6 < $(PROCESSOR_LEVEL)
+PROCESSOR_LEVEL = 6
+!endif
+PROCESSOR_FLAG = -$(PROCESSOR_LEVEL)
+CPU = i$(PROCESSOR_LEVEL)86
+ARCH = i386
+!else
+CPU = $(PROCESSOR_ARCHITECTURE)
+ARCH = $(PROCESSOR_ARCHITECTURE)
+!endif
+!ifndef DEBUGFLAGS
+DEBUGFLAGS =
+!endif
+!ifndef OPTFLAGS
+OPTFLAGS = -O
+!endif
+
+!ifndef prefix
+prefix = /usr
+!endif
+!ifndef exec_prefix
+exec_prefix = $(prefix)
+!endif
+!ifndef libdir
+libdir = $(exec_prefix)/lib
+!endif
+!ifndef DESTDIR
+DESTDIR = $(prefix)
+!endif
+!ifndef CFLAGS
+CFLAGS = -q $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) -w- -wsus -wcpt -wdup -wext -wrng -wrpt -wzdi
+!endif
+!ifndef CPPFLAGS
+CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)missing
+!endif
+!ifndef LDFLAGS
+LDFLAGS = -S:$(STACK)
+!endif
+!ifndef RFLAGS
+RFLAGS = $(iconinc)
+!endif
+!ifndef EXTLIBS
+EXTLIBS =
+!endif
+LIBS = cw32.lib import32.lib ws2_32.lib $(EXTLIBS)
+MISSING = acosh.obj crypt.obj erf.obj win32.obj
+
+!ifndef STACK
+STACK = 0x2000000
+!endif
+
+XCFLAGS = -DRUBY_EXPORT
+
+ARFLAGS = /a
+LD = ilink32 -q -Gn
+LDSHARED = $(LD)
+XLDFLAGS = -Tpe c0x32.obj
+WLDFLAGS = -aa -Tpe c0w32.obj
+DLDFLAGS = -Tpd c0d32.obj
+LIBRUBY_LDSHARED = $(LDSHARED)
+LIBRUBY_DLDFLAGS = -Gi $(DLDFLAGS) $(EXTLDFLAGS)
+LDOBJECTS = $(MAINOBJ)
+
+SOLIBS =
+
+EXEEXT = .exe
+PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
+WPROGRAM=$(RUBYW_INSTALL_NAME)$(EXEEXT)
+RUBYDEF = $(RUBY_SO_NAME).def
+MINIRUBY = .\miniruby$(EXEEXT)
+
+ORGLIBPATH = $(LIB)
+
+#### End of system configuration section. ####
+
+LIBRUBY_A = $(RUBY_SO_NAME)-static.lib
+LIBRUBY_SO = $(RUBY_SO_NAME).dll
+LIBRUBY = $(RUBY_SO_NAME).lib
+LIBRUBYARG = $(LIBRUBY)
+
+!ifndef EXTOBJS
+EXTOBJS = dmyext.obj
+!endif
+
+MAINOBJ = main.obj
+WINMAINOBJ = winmain.obj
+
+OBJS = array.obj \
+ bignum.obj \
+ class.obj \
+ compar.obj \
+ dir.obj \
+ dln.obj \
+ enum.obj \
+ error.obj \
+ eval.obj \
+ file.obj \
+ gc.obj \
+ hash.obj \
+ inits.obj \
+ io.obj \
+ marshal.obj \
+ math.obj \
+ numeric.obj \
+ object.obj \
+ pack.obj \
+ parse.obj \
+ prec.obj \
+ process.obj \
+ random.obj \
+ range.obj \
+ re.obj \
+ regex.obj \
+ ruby.obj \
+ signal.obj \
+ sprintf.obj \
+ st.obj \
+ string.obj \
+ struct.obj \
+ time.obj \
+ util.obj \
+ variable.obj \
+ version.obj \
+ $(MISSING)
+
+SCRIPT_ARGS = "--dest-dir=$(DESTDIR)" \
+ "--make=$(MAKE)" \
+ "--mflags=$(MFLAGS)" \
+ "--make-flags=$(MAKEFLAGS)"
+
+all: miniruby$(EXEEXT) rbconfig.rb \
+ $(LIBRUBY) $(MISCLIBS)
+ .\miniruby$(EXEEXT) $(srcdir)ext/extmk.rb --extstatic=$(EXTSTATIC) $(SCRIPT_ARGS)
+
+ruby: $(PROGRAM)
+rubyw: $(WPROGRAM)
+lib: $(LIBRUBY)
+dll: $(LIBRUBY_SO)
+
+config: config.h config.status
+
+config.h:
+ @echo Creating $(@:.\=)
+ @type > $@ &&|
+\#define HAVE_SYS_TYPES_H 1
+\#define HAVE_SYS_STAT_H 1
+\#define HAVE_STDLIB_H 1
+\#define HAVE_STRING_H 1
+\#define HAVE_MEMORY_H 1
+\#define HAVE_OFF_T 1
+\#define SIZEOF_INT 4
+\#define SIZEOF_SHORT 2
+\#define SIZEOF_LONG 4
+\#define SIZEOF_LONG_LONG 0
+\#define SIZEOF___INT64 8
+\#define SIZEOF_OFF_T 4
+\#define SIZEOF_VOIDP 4
+\#define SIZEOF_FLOAT 4
+\#define SIZEOF_DOUBLE 8
+\#define SIZEOF_TIME_T 4
+\#define HAVE_PROTOTYPES 1
+\#define TOKEN_PASTE(x,y) x\#\#y
+\#define HAVE_STDARG_PROTOTYPES 1
+\#define NORETURN(x) x
+\#define HAVE_DECL_SYS_NERR 1
+\#define HAVE_LIMITS_H 1
+\#define HAVE_FCNTL_H 1
+\#define HAVE_UTIME_H 1
+\#define HAVE_FLOAT_H 1
+\#define HAVE_STRUCT_STAT_ST_RDEV 1
+\#define HAVE_ST_RDEV 1
+\#define GETGROUPS_T int
+\#define RETSIGTYPE void
+\#define HAVE_ALLOCA 1
+\#define HAVE_DUP2 1
+\#define HAVE_MEMMOVE 1
+\#define HAVE_MKDIR 1
+\#define HAVE_STRCASECMP 1
+\#define HAVE_STRNCASECMP 1
+\#define HAVE_STRERROR 1
+\#define HAVE_STRFTIME 1
+\#define HAVE_STRCHR 1
+\#define HAVE_STRSTR 1
+\#define HAVE_STRTOD 1
+\#define HAVE_STRTOL 1
+\#define HAVE_STRTOUL 1
+\#define HAVE_ISNAN 1
+\#define HAVE_FINITE 1
+\#define HAVE_FMOD 1
+\#define HAVE_WAITPID 1
+\#define HAVE_FSYNC 1
+\#define HAVE_GETCWD 1
+\#define HAVE_CHSIZE 1
+\#define HAVE_TIMES 1
+\#define HAVE_LINK 1
+\#define HAVE_TELLDIR 1
+\#define HAVE_SEEKDIR 1
+\#define HAVE_COSH 1
+\#define HAVE_SINH 1
+\#define HAVE_TANH 1
+\#define RSHIFT(x,y) ((x)>>(int)y)
+\#define FILE_COUNT level
+\#define FILE_READPTR curp
+\#define inline __inline
+\#define NEED_IO_SEEK_BETWEEN_RW 1
+\#define STACK_GROW_DIRECTION -1
+\#define DEFAULT_KCODE KCODE_NONE
+\#define DLEXT ".so"
+\#define DLEXT2 ".dll"
+\#define RUBY_LIB "/lib/ruby/$(MAJOR).$(MINOR)"
+\#define RUBY_SITE_LIB "/lib/ruby/site_ruby"
+\#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)"
+\#define RUBY_PLATFORM "$(ARCH)-$(OS)"
+\#define RUBY_ARCHLIB "/lib/ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(OS)"
+\#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(OS)"
+|
+
+config.status: Makefile $(srcdir)bcc32/Makefile.sub
+ @echo Creating $@
+ @type > $@ &&|
+# Generated automatically by Makefile.sub.
+s,@SHELL@,$$(COMSPEC),;t t
+s,@CFLAGS@,$(CFLAGS),;t t
+s,@CPPFLAGS@,$(CPPFLAGS),;t t
+s,@CXXFLAGS@,$(CXXFLAGS),;t t
+s,@FFLAGS@,$(FFLAGS),;t t
+s,@LDFLAGS@,,;t t
+s,@LIBS@,$(LIBS),;t t
+s,@exec_prefix@,$${prefix},;t t
+s,@prefix@,,;t t
+s,@program_transform_name@,s,,,,;t t
+s,@bindir@,$${exec_prefix}/bin,;t t
+s,@sbindir@,$${exec_prefix}/sbin,;t t
+s,@libexecdir@,$${exec_prefix}/libexec,;t t
+s,@datadir@,$${prefix}/share,;t t
+s,@sysconfdir@,$${prefix}/etc,;t t
+s,@sharedstatedir@,/etc,;t t
+s,@localstatedir@,/var,;t t
+s,@libdir@,$${exec_prefix}/lib,;t t
+s,@includedir@,$${prefix}/include,;t t
+s,@oldincludedir@,/usr/include,;t t
+s,@infodir@,$${prefix}/info,;t t
+s,@mandir@,$${prefix}/man,;t t
+s,@build@,$(CPU)-pc-$(OS),;t t
+s,@build_alias@,$(CPU)-$(OS),;t t
+s,@build_cpu@,$(CPU),;t t
+s,@build_vendor@,pc,;t t
+s,@build_os@,$(OS),;t t
+s,@host@,$(CPU)-pc-$(OS),;t t
+s,@host_alias@,$(CPU)-$(OS),;t t
+s,@host_cpu@,$(CPU),;t t
+s,@host_vendor@,pc,;t t
+s,@host_os@,$(OS),;t t
+s,@target@,$(ARCH)-pc-$(OS),;t t
+s,@target_alias@,$(ARCH)-$(OS),;t t
+s,@target_cpu@,$(ARCH),;t t
+s,@target_vendor@,pc,;t t
+s,@target_os@,$(OS),;t t
+s,@CC@,$(CC),;t t
+s,@CPP@,cpp32,;t t
+s,@YACC@,$(YACC),;t t
+s,@RANLIB@,,;t t
+s,@AR@,$(AR),;t t
+s,@ARFLAGS@,$(ARFLAGS) ,;t t
+s,@LN_S@,$(LN_S),;t t
+s,@SET_MAKE@,$(SET_MAKE),;t t
+s,@LIBOBJS@, acosh.obj crypt.obj erf.obj win32.obj,;t t
+s,@ALLOCA@,$(ALLOCA),;t t
+s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t
+s,@EXEEXT@,.exe,;t t
+s,@OBJEXT@,obj,;t t
+s,@XCFLAGS@,$(XCFLAGS),;t t
+s,@XLDFLAGS@,$(XLDFLAGS),;t t
+s,@DLDFLAGS@,$(DLDFLAGS),;t t
+s,@ARCH_FLAG@,$(ARCH_FLAG),;t t
+s,@STATIC@,$(STATIC),;t t
+s,@CCDLFLAGS@,,;t t
+s,@LDSHARED@,$(LDSHARED),;t t
+s,@DLEXT@,so,;t t
+s,@DLEXT2@,dll,;t t
+s,@LIBEXT@,lib,;t t
+s,@STRIP@,$(STRIP),;t t
+s,@EXTSTATIC@,$(EXTSTATIC),;t t
+s,@setup@,Setup,;t t
+s,@MINIRUBY@,$(MINIRUBY),;t t
+s,@LIBRUBY_LDSHARED@,$$(LDSHARED),;t t
+s,@LIBRUBY_DLDFLAGS@,-Gi $$(DLDFLAGS),;t t
+s,@RUBY_INSTALL_NAME@,$(RUBY_INSTALL_NAME),;t t
+s,@rubyw_install_name@,$(RUBYW_INSTALL_NAME),;t t
+s,@RUBYW_INSTALL_NAME@,$(RUBYW_INSTALL_NAME),;t t
+s,@RUBY_SO_NAME@,$(RUBY_SO_NAME),;t t
+s,@LIBRUBY_A@,$$(RUBY_SO_NAME)-static.lib,;t t
+s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t
+s,@LIBRUBY_ALIASES@,$(LIBRUBY_ALIASES),;t t
+s,@LIBRUBY@,$$(RUBY_SO_NAME).lib,;t t
+s,@LIBRUBYARG@,$$(LIBRUBYARG_SHARED),;t t
+s,@LIBRUBYARG_STATIC@,$$(LIBRUBY_A),;t t
+s,@LIBRUBYARG_SHARED@,$$(LIBRUBY),;t t
+s,@SOLIBS@,$(SOLIBS),;t t
+s,@DLDLIBS@,$(DLDLIBS),;t t
+s,@ENABLE_SHARED@,yes,;t t
+s,@OUTFLAG@,-o,;t t
+s,@CPPOUTFILE@,,;t t
+s,@LIBPATHFLAG@, -L"%s",;t t
+s,@RPATHFLAG@,,;t t
+s,@LIBARG@,%s.lib,;t t
+s,@LINK_SO@,$$(LDSHARED) $$(DLDFLAGS) $$(LIBPATH) $$(OBJS), $$(@:/=\), nul, $$(LIBS) $$(LOCAL_LIBS), $$(DEFFILE), $$(RESFILE),;t t
+s,@COMPILE_C@,$$(CC) $$(CFLAGS) $$(CPPFLAGS) -c $$(<:/=\),;t t
+s,@COMPILE_CXX@,$$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) -P -c $$(<:/=\),;t t
+s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: .%s.%s:,;t t
+s,@COMMON_LIBS@,m,;t t
+s,@COMMON_MACROS@,WIN32_LEAN_AND_MEAN;t t
+s,@COMMON_HEADERS@,winsock2.h windows.h,;t t
+s,@TRY_LINK@,$$(CC) -oconftest $$(INCFLAGS) -I$$(hdrdir) $$(CPPFLAGS) $$(CFLAGS) $$(LIBPATH) $$(LDFLAGS) $$(src) $$(LOCAL_LIBS) $$(LIBS),;t t
+s,@EXPORT_PREFIX@,_,;t t
+s,@arch@,$(ARCH)-$(OS),;t t
+s,@sitearch@,$(ARCH)-$(OS),;t t
+s,@sitedir@,$${prefix}/lib/ruby/site_ruby,;t t
+s,@configure_args@,--enable-shared $(configure_args),;t t
+s,@configure_input@,$$configure_input,;t t
+s,@srcdir@,$(srcdir),;t t
+s,@top_srcdir@,$(srcdir),;t t
+|
+
+miniruby$(EXEEXT): $(LIBRUBY_A) $(MAINOBJ) dmyext.obj
+ @echo $(LIBS)
+ $(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) dmyext.obj,$@,nul,$(LIBRUBY_A) $(LIBS)
+
+$(PROGRAM): $(MAINOBJ) $(LIBRUBY_SO) $(RUBY_INSTALL_NAME).res
+ $(LD) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ),$@,nul,$(LIBRUBYARG) $(LIBS),,$(RUBY_INSTALL_NAME).res
+
+$(WPROGRAM): $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_SO) $(RUBYW_INSTALL_NAME).res
+ $(LD) $(LDFLAGS) $(WLDFLAGS) $(MAINOBJ) $(WINMAINOBJ),$@,nul,$(LIBRUBYARG) $(LIBS),,$(RUBYW_INSTALL_NAME).res
+
+$(LIBRUBY_A): $(OBJS) dmyext.obj
+ @-if exist $@ del $@
+ $(AR) $(ARFLAGS) "$@" $(OBJS) dmyext.obj
+
+# $(LIBRUBY): $(LIBRUBY_SO)
+# implib $@ $(LIBRUBY_SO)
+
+$(LIBRUBY_SO) $(LIBRUBY): $(LIBRUBY_A) $(EXTOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res
+ @echo $(EXTOBJS)
+ $(LIBRUBY_LDSHARED) $(LIBRUBY_DLDFLAGS) $(EXTOBJS:/=\),$(LIBRUBY_SO),nul,$(LIBRUBY_A) $(LIBS),$(RUBYDEF),$(RUBY_SO_NAME).res
+
+$(RUBYDEF): $(LIBRUBY_A) miniruby$(EXEEXT)
+ $(MINIRUBY) $(srcdir)bcc32/mkexports.rb -output=$@ $(LIBRUBY_A)
+
+install: rbconfig.rb
+ $(MINIRUBY) $(srcdir)instruby.rb $(SCRIPT_ARGS)
+ $(MINIRUBY) $(srcdir)ext/extmk.rb $(SCRIPT_ARGS) install
+
+what-where no-install: rbconfig.rb
+ $(MINIRUBY) $(srcdir)instruby.rb -n $(SCRIPT_ARGS)
+ $(MINIRUBY) $(srcdir)ext/extmk.rb -n $(SCRIPT_ARGS) install
+
+clean: clean-ext clean-local
+
+clean-local:
+ @if exist $(LIBRUBY_A) del $(LIBRUBY_A)
+ @if exist $(MAINOBJ) del $(MAINOBJ)
+ @if exist rbconfig.rb del rbconfig.rb
+ @if exist ext\extinit.c del ext\extinit.c
+ @if exist ext\extinit.obj del ext\extinit.obj
+ @if exist ext\vc*.pdb del ext\vc*.pdb
+ @if exist *.obj del *.obj
+ @if exist *.res del *.res
+ @if exist *.tds del *.tds
+ @if exist *.il? del *.il?
+
+clean-ext:
+ @-$(MINIRUBY) $(srcdir)ext/extmk.rb $(SCRIPT_ARGS) clean
+
+distclean: distclean-ext distclean-local
+
+distclean-local: clean-local
+ @if exist Makefile del Makefile
+ @if exist config.h del config.h
+ @if exist ext\config.cache del ext\config.cache
+ @if exist config.cache del config.cache
+ @if exist config.log del config.log
+ @if exist config.status del config.status
+ @if exist *~ del *~
+ @if exist *.bak del *.bak
+ @if exist *.stackdump del *.stackdump
+ @if exist *.core del *.core
+ @if exist gmon.out del gmon.out
+ @if exist y.tab.c del y.tab.c
+ @if exist y.output del y.output
+ @if exist *.map del *.map
+ @if exist *.pdb del *.pdb
+ @if exist *.ilk del *.ilk
+ @if exist *.exp del *.exp
+ @if exist $(RUBYDEF) del $(RUBYDEF)
+ @if exist $(RUBY_INSTALL_NAME).rc del $(RUBY_INSTALL_NAME).rc
+ @if exist $(RUBYW_INSTALL_NAME).rc del $(RUBYW_INSTALL_NAME).rc
+ @if exist $(RUBY_SO_NAME).rc del $(RUBY_SO_NAME).rc
+ @if exist $(PROGRAM) del $(PROGRAM)
+ @if exist $(WPROGRAM) del $(WPROGRAM)
+ @if exist $(LIBRUBY_SO) del $(LIBRUBY_SO)
+ @if exist $(LIBRUBY) del $(LIBRUBY)
+ @if exist ext\nul if not exist ext\* rmdir ext
+ @if exist miniruby$(EXEEXT) del miniruby$(EXEEXT)
+
+distclean-ext:
+ @-$(MINIRUBY) $(srcdir)ext/extmk.rb $(SCRIPT_ARGS) distclean
+
+realclean: distclean
+ @if exist parse.c del parse.c
+ @if exist lex.c del lex.c
+
+test: miniruby$(EXEEXT) NUL
+ @$(MINIRUBY) $(srcdir)rubytest.rb
+
+rbconfig.rb: miniruby$(EXEEXT) config.status
+ @$(MINIRUBY) $(srcdir)mkconfig.rb -srcdir=$(srcdir) \
+ -install_name=$(RUBY_INSTALL_NAME) \
+ -so_name=$(RUBY_SO_NAME) rbconfig.rb
+
+$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: rbconfig.rb
+ @$(MINIRUBY) $(srcdir)win32/resource.rb \
+ -ruby_name=$(RUBY_INSTALL_NAME) \
+ -rubyw_name=$(RUBYW_INSTALL_NAME) \
+ -so_name=$(RUBY_SO_NAME) \
+ . $(icondirs) $(srcdir)win32
+
+#config.status: $(srcdir)configure
+# $(SHELL) .config.status --recheck
+
+.path.c = .;$(srcdir);$(srcdir)win32;$(srcdir)missing
+.path.h = .;$(srcdir);$(srcdir)win32;$(srcdir)missing
+.path.y = $(srcdir)
+
+.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) -I. $(CPPFLAGS) -c $(<:/=\)
+
+.rc.res:
+ $(RC) $(RFLAGS) -I. -I$(<D). $(iconinc) -I$(srcdir)win32 $(RFLAGS) -fo$@ $(<:/=\)
+
+.y.c:
+ $(YACC) $(YFLAGS) $(<:\=/)
+ sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $(@F)
+ @del y.tab.c
+
+parse.c: parse.y
+
+ext/extinit.obj: ext/extinit.c $(SETUP)
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -o$@ -c ext/extinit.c
+
+acosh.obj: acosh.c win32.h
+alloca.obj: alloca.c win32.h
+crypt.obj: crypt.c win32.h
+dup2.obj: dup2.c win32.h
+erf.obj: erf.c win32.h
+finite.obj: finite.c win32.h
+flock.obj: flock.c win32.h
+memcmp.obj: memcmp.c win32.h
+memmove.obj: memmove.c win32.h
+mkdir.obj: mkdir.c win32.h
+vsnprintf.obj: vsnprintf.c win32.h
+strcasecmp.obj: strcasecmp.c win32.h
+strncasecmp.obj: strncasecmp.c win32.h
+strchr.obj: strchr.c win32.h
+strdup.obj: strdup.c win32.h
+strerror.obj: strerror.c win32.h
+strftime.obj: strftime.c win32.h
+strstr.obj: strstr.c win32.h
+strtod.obj: strtod.c win32.h
+strtol.obj: strtol.c win32.h
+strtoul.obj: strtoul.c win32.h
+nt.obj: nt.c win32.h
+x68.obj: x68.c win32.h
+os2.obj: os2.c win32.h
+dl_os2.obj: dl_os2.c win32.h
+
+# when I use -I., there is confliction at "OpenFile"
+# so, set . into environment varible "include"
+win32.obj: win32.c win32.h
+
+###
+array.obj: array.c ruby.h config.h defines.h intern.h missing.h util.h st.h win32.h
+bignum.obj: bignum.c ruby.h config.h defines.h intern.h missing.h win32.h
+class.obj: class.c ruby.h config.h defines.h intern.h missing.h rubysig.h node.h st.h win32.h
+compar.obj: compar.c ruby.h config.h defines.h intern.h missing.h win32.h
+dir.obj: dir.c ruby.h config.h defines.h intern.h missing.h util.h win32.h
+dln.obj: dln.c ruby.h config.h defines.h intern.h missing.h dln.h win32.h
+dmyext.obj: dmyext.c
+enum.obj: enum.c ruby.h config.h defines.h intern.h missing.h node.h util.h win32.h
+error.obj: error.c ruby.h config.h defines.h intern.h missing.h env.h st.h win32.h
+eval.obj: eval.c ruby.h config.h defines.h intern.h missing.h node.h env.h util.h rubysig.h st.h dln.h win32.h
+file.obj: file.c ruby.h config.h defines.h intern.h missing.h rubyio.h rubysig.h util.h dln.h win32.h
+gc.obj: gc.c ruby.h config.h defines.h intern.h missing.h rubysig.h st.h node.h env.h re.h regex.h win32.h
+hash.obj: hash.c ruby.h config.h defines.h intern.h missing.h st.h util.h rubysig.h win32.h
+inits.obj: inits.c ruby.h config.h defines.h intern.h missing.h win32.h
+io.obj: io.c ruby.h config.h defines.h intern.h missing.h rubyio.h rubysig.h env.h util.h win32.h
+main.obj: main.c ruby.h config.h defines.h intern.h missing.h win32.h
+marshal.obj: marshal.c ruby.h config.h defines.h intern.h missing.h rubyio.h st.h util.h win32.h
+math.obj: math.c ruby.h config.h defines.h intern.h missing.h win32.h
+numeric.obj: numeric.c ruby.h config.h defines.h intern.h missing.h win32.h
+object.obj: object.c ruby.h config.h defines.h intern.h missing.h st.h util.h win32.h
+pack.obj: pack.c ruby.h config.h defines.h intern.h missing.h win32.h
+parse.obj: parse.c ruby.h config.h defines.h intern.h missing.h env.h node.h st.h regex.h util.h lex.c win32.h
+prec.obj: prec.c ruby.h config.h defines.h intern.h missing.h win32.h
+process.obj: process.c ruby.h config.h defines.h intern.h missing.h rubysig.h st.h win32.h
+random.obj: random.c ruby.h config.h defines.h intern.h missing.h win32.h
+range.obj: range.c ruby.h config.h defines.h intern.h missing.h win32.h
+re.obj: re.c ruby.h config.h defines.h intern.h missing.h re.h regex.h win32.h
+regex.obj: regex.c config.h regex.h win32.h
+ruby.obj: ruby.c ruby.h config.h defines.h intern.h missing.h dln.h node.h util.h win32.h
+signal.obj: signal.c ruby.h config.h defines.h intern.h missing.h rubysig.h win32.h
+sprintf.obj: sprintf.c ruby.h config.h defines.h intern.h missing.h win32.h
+st.obj: st.c config.h st.h
+string.obj: string.c ruby.h config.h defines.h intern.h missing.h re.h regex.h win32.h
+struct.obj: struct.c ruby.h config.h defines.h intern.h missing.h win32.h
+time.obj: time.c ruby.h config.h defines.h intern.h missing.h win32.h
+util.obj: util.c ruby.h config.h defines.h intern.h missing.h util.h win32.h
+variable.obj: variable.c ruby.h config.h defines.h intern.h missing.h env.h node.h st.h util.h win32.h
+version.obj: version.c ruby.h config.h defines.h intern.h missing.h version.h win32.h
diff --git a/bcc32/README.bcc32 b/bcc32/README.bcc32
new file mode 100644
index 0000000000..a699d34a4e
--- /dev/null
+++ b/bcc32/README.bcc32
@@ -0,0 +1,125 @@
+=begin
+
+= How to build ruby using Borland C++
+
+== Requirement
+
+(1) Borland C++ 5.0 or later.
+
+(2) If you want to run `((%make clean%))' or `((%make distclean%))'
+ properly, you must install UNIX compatible `((%rm%))' command on
+ your ((|PATH|)).
+
+(3) Please set environment variable (({INCLUDE})), (({LIB})), (({PATH}))
+ to run required commands properly from the command line.
+
+ Note: building ruby requires following commands.
+ * make
+ * bcc
+ * tlib
+ * ilink
+
+== How to compile and install
+
+(1) Execute bcc32\configure.bat on your build directory.
+ ex. c:\ruby-1.6.7>bcc32\configure.bat
+
+(2) Change ((|RUBY_INSTALL_NAME|)) and ((|RUBY_SO_NAME|)) in (({Makefile}))
+ if you want to change the name of the executable files.
+ And add ((|RUBYW_INSTALL_NAME|)) to change the name of the
+ executable without console window if also you want.
+
+(3) Run `((%make%))'
+
+(4) Run `((%make test%))'
+
+(5) Run `((%make DESTDIR=<install_directory> install%))'
+
+ This command will create following directories and install files onto them.
+ * <install_directory>\bin
+ * <install_directory>\lib
+ * <install_directory>\lib\ruby
+ * <install_directory>\lib\ruby\<MAJOR>.<MINOR>
+ * <install_directory>\lib\ruby\<MAJOR>.<MINOR>\<PLATFORM>
+ * <install_directory>\lib\ruby\site_ruby
+ * <install_directory>\lib\ruby\site_ruby\<MAJOR>.<MINOR>
+ * <install_directory>\lib\ruby\site_ruby\<MAJOR>.<MINOR>\<PLATFORM>
+ * <install_directory>\man\man1
+ If Ruby's version is `x.y.z', the ((|<MAJOR>|)) is `x' and the ((|<MINOR>|)) is `y'.
+ The ((|<PLATFORM>|)) is usually `(({i586-bccwin32}))'.
+
+== Icons
+
+Any icon files(*.ico) in the build directory, directories specified with
+((|icondirs|)) make variable and (({win32})) directory under the ruby
+source directory will be included in DLL or executable files, according
+to their base names.
+ $(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe
+ $(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe
+ the others --> $(RUBY_SO_NAME).dll
+
+Although no icons are distributed with the ruby source or in the official
+site, you can use anything you like. For example, followings are written
+in Japanese, but you can download at least.
+
+* ((<URL:http://member.nifty.ne.jp/ueivu/rubyico.html>)) or
+ ((<zipped icons|URL:http://member.nifty.ne.jp/ueivu/Ruby_ico.zip>))
+* ((<URL:http://homepage1.nifty.com/a_nakata/ruby/>)) or
+ ((<icon itself|URL:http://homepage1.nifty.com/a_nakata/ruby/RubyIcon.ico>))
+
+== Build examples
+
+* Build on the ruby source directory.
+
+ ex.)
+ ruby source directory: C:\ruby
+ build directory: C:\ruby
+ install directory: C:\usr\local
+
+ C:
+ cd \ruby
+ bcc32\configure
+ make
+ make test
+ make DESTDIR=/usr/local install
+
+* Build on the relative directory from the ruby source directory and CPU type
+ i386.
+
+ ex.)
+ ruby source directory: C:\ruby
+ build directory: C:\ruby\bccwin32
+ install directory: C:\usr\local
+ CPU i386
+
+ C:
+ cd \ruby
+ mkdir bccwin32
+ cd bccwin32
+ ..\bcc32\configure target i386-bccwin32
+ make
+ make test
+ make DESTDIR=/usr/local install
+
+* Build on the different drive.
+
+ ex.)
+ ruby source directory: C:\src\ruby
+ build directory: D:\build\ruby
+ install directory: C:\usr\local
+
+ D:
+ cd D:\build\ruby
+ C:\src\ruby\bcc32\configure
+ make
+ make test
+ make DESTDIR=C:/usr/local install
+
+== Bugs
+
+You can ((*NOT*)) use a path name contains any white space characters as
+the ruby source directory, this restriction comes from the behavior of
+(({!INCLUDE})) directives of (({MAKE})).
+((- you may call it a bug. -))
+
+=end
diff --git a/bcc32/configure.bat b/bcc32/configure.bat
new file mode 100644
index 0000000000..449b6e25b5
--- /dev/null
+++ b/bcc32/configure.bat
@@ -0,0 +1,32 @@
+@echo off
+::: Don't set environment variable in batch file other than autoexec.bat
+::: to avoid "Out of environment space" problem on Windows 95/98.
+::: set TMPMAKE=~tmp~.mak
+
+echo> ~tmp~.mak ####
+echo>> ~tmp~.mak conf = %0
+echo>> ~tmp~.mak $(conf:\=/): nul
+echo>> ~tmp~.mak @del ~tmp~.mak
+echo>> ~tmp~.mak @-$(MAKE) -l$(MAKEFLAGS) -f $(@D)setup.mak \
+echo>> ~tmp~.mak bcc32dir="$(@D)" \
+:loop
+if "%1" == "" goto :end
+if "%1" == "--srcdir" goto :srcdir
+if "%1" == "srcdir" goto :srcdir
+if "%1" == "--target" goto :target
+if "%1" == "target" goto :target
+ echo>> ~tmp~.mak "%1"
+ shift
+goto :loop
+:srcdir
+ echo>> ~tmp~.mak "srcdir=%2"
+ shift
+ shift
+goto :loop
+:target
+ echo>> ~tmp~.mak %2
+ shift
+ shift
+goto :loop
+:end
+make -s -f ~tmp~.mak
diff --git a/bcc32/mkexports.rb b/bcc32/mkexports.rb
new file mode 100644
index 0000000000..e34b441e2f
--- /dev/null
+++ b/bcc32/mkexports.rb
@@ -0,0 +1,25 @@
+#!./miniruby -s
+
+SYM = {}
+STDIN.reopen(open("nul"))
+ARGV.each do |obj|
+ IO.foreach("|tdump -q -oiPUBDEF -oiPUBD32 #{obj.tr('/', '\\')}") do |l|
+ next unless /(?:PUBDEF|PUBD32)/ =~ l
+ SYM[$1] = true if /'(.*?)'/ =~ l
+ end
+end
+
+exports = []
+if $name
+ exports << "Name " + $name
+elsif $library
+ exports << "Library " + $library
+end
+exports << "Description " + $description.dump if $description
+exports << "EXPORTS" << SYM.keys.sort
+
+if $output
+ open($output, 'w') {|f| f.puts exports.join("\n")}
+else
+ puts exports.join("\n")
+end
diff --git a/bcc32/setup.mak b/bcc32/setup.mak
new file mode 100644
index 0000000000..3b37b92fa8
--- /dev/null
+++ b/bcc32/setup.mak
@@ -0,0 +1,89 @@
+# -*- makefile -*-
+
+!if "$(srcdir)" != ""
+bcc32dir = $(srcdir)bcc32/
+!elseif "$(bcc32dir)" == "bcc32/"
+srcdir = ./
+!elseif "$(bcc32dir:/bcc32/=)/bcc32/" == "$(bcc32dir)"
+srcdir = $(bcc32dir:/bcc32/=/)
+!else
+srcdir = $(bcc32dir)../
+!endif
+
+OS = bccwin32
+RT = $(OS)
+INCLUDE = !include
+APPEND = echo>>$(MAKEFILE)
+!ifdef MAKEFILE
+MAKE = $(MAKE) -f $(MAKEFILE)
+!else
+MAKEFILE = Makefile
+!endif
+
+all: Makefile
+Makefile: -prologue- -generic- -epilogue-
+i386-$(OS): -prologue- -i386- -epilogue-
+i486-$(OS): -prologue- -i486- -epilogue-
+i586-$(OS): -prologue- -i586- -epilogue-
+i686-$(OS): -prologue- -i686- -epilogue-
+alpha-$(OS): -prologue- -alpha- -epilogue-
+
+-prologue-: nul
+ @echo Creating $(MAKEFILE)
+ @type > $(MAKEFILE) &&|
+\#\#\# Makefile for ruby $(OS) \#\#\#
+srcdir = $(srcdir:\=/)
+|
+ @cpp32 -I$(srcdir) -DRUBY_EXTERN="//" -P- -o$(MAKEFILE) > nul &&|
+\#include "version.h"
+MAJOR = RUBY_VERSION_MAJOR
+MINOR = RUBY_VERSION_MINOR
+TEENY = RUBY_VERSION_TEENY
+|
+ @type $(MAKEFILE).i >> $(MAKEFILE)
+ @del $(MAKEFILE).i
+
+-generic-: nul
+!if defined(PROCESSOR_ARCHITECTURE) || defined(PROCESSOR_LEVEL)
+ @type >> $(MAKEFILE) &&|
+!if defined(PROCESSOR_ARCHITECTURE)
+PROCESSOR_ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
+!endif
+!if defined(PROCESSOR_LEVEL)
+PROCESSOR_LEVEL = $(PROCESSOR_LEVEL)
+!endif
+
+|
+!endif
+
+-alpha-: nul
+ @$(APPEND) PROCESSOR_ARCHITECTURE = alpha
+-ix86-: nul
+ @$(APPEND) PROCESSOR_ARCHITECTURE = x86
+
+-i386-: -ix86-
+ @$(APPEND) PROCESSOR_LEVEL = 3
+-i486-: -ix86-
+ @$(APPEND) PROCESSOR_LEVEL = 4
+-i586-: -ix86-
+ @$(APPEND) PROCESSOR_LEVEL = 5
+-i686-: -ix86-
+ @$(APPEND) PROCESSOR_LEVEL = 6
+
+-epilogue-: nul
+ @type >> $(MAKEFILE) &&|
+
+\# OS = $(OS)
+\# RT = $(RT)
+\# RUBY_INSTALL_NAME = ruby
+\# RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)$$(MAJOR)$$(MINOR)
+\# prefix = /usr
+\# CFLAGS = -q $$(DEBUGFLAGS) $$(OPTFLAGS) $$(PROCESSOR_FLAG) -w- -wsus -wcpt -wdup -wext -wrng -wrpt -wzdi
+\# CPPFLAGS = -I. -I$$(srcdir) -I$$(srcdir)missing -DLIBRUBY_SO=\"$$(LIBRUBY_SO)\"
+\# STACK = 0x2000000
+\# LDFLAGS = -S:$$(STACK)
+\# RFLAGS = $$(iconinc)
+\# EXTLIBS = cw32.lib import32.lib user32.lib kernel32.lib
+$(INCLUDE) $$(srcdir)bcc32/Makefile.sub
+|
+ @echo type "`$(MAKE)'" to make ruby for $(OS).
diff --git a/bignum.c b/bignum.c
index 708d74c155..06228416bf 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6,13 +6,17 @@
$Date$
created at: Fri Jun 10 00:48:55 JST 1994
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
#include "ruby.h"
+
#include <math.h>
#include <ctype.h>
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
VALUE rb_cBignum;
@@ -20,27 +24,19 @@ VALUE rb_cBignum;
#define USHORT _USHORT
#endif
-#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
-typedef unsigned int BDIGIT;
-typedef unsigned long long BDIGIT_DBL;
-typedef long long BDIGIT_DBL_SIGNED;
-#elif SIZEOF_INT*2 <= SIZEOF___INT64
-typedef unsigned int BDIGIT;
-typedef unsigned __int64 BDIGIT_DBL;
-typedef __int64 BDIGIT_DBL_SIGNED;
-#else
-typedef unsigned short BDIGIT;
-typedef unsigned long BDIGIT_DBL;
-typedef long BDIGIT_DBL_SIGNED;
-#endif
-
#define BDIGITS(x) ((BDIGIT*)RBIGNUM(x)->digits)
-#define BITSPERDIG (sizeof(BDIGIT)*CHAR_BIT)
+#define BITSPERDIG (SIZEOF_BDIGITS*CHAR_BIT)
#define BIGRAD ((BDIGIT_DBL)1 << BITSPERDIG)
-#define DIGSPERLONG ((unsigned int)(sizeof(long)/sizeof(BDIGIT)))
+#define DIGSPERLONG ((unsigned int)(SIZEOF_LONG/SIZEOF_BDIGITS))
+#if HAVE_LONG_LONG
+# define DIGSPERLL ((unsigned int)(SIZEOF_LONG_LONG/SIZEOF_BDIGITS))
+#endif
#define BIGUP(x) ((BDIGIT_DBL)(x) << BITSPERDIG)
#define BIGDN(x) RSHIFT(x,BITSPERDIG)
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
+#define BDIGMAX ((BDIGIT)-1)
+
+#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0))
static VALUE
bignew_1(klass, len, sign)
@@ -69,9 +65,10 @@ rb_big_clone(x)
return z;
}
-void
-rb_big_2comp(x) /* get 2's complement */
+static void
+get2comp(x, carry) /* get 2's complement */
VALUE x;
+ int carry;
{
long i = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(x);
@@ -84,16 +81,21 @@ rb_big_2comp(x) /* get 2's complement */
ds[i++] = BIGLO(num);
num = BIGDN(num);
} while (i < RBIGNUM(x)->len);
- if (ds[0] == 1 || ds[0] == 0) {
- for (i=1; i<RBIGNUM(x)->len; i++) {
- if (ds[i] != 0) return;
- }
- REALLOC_N(RBIGNUM(x)->digits, BDIGIT, RBIGNUM(x)->len++);
+ if (!carry) return;
+ if ((ds[RBIGNUM(x)->len-1] & (1<<(BITSPERDIG-1))) == 0) {
+ REALLOC_N(RBIGNUM(x)->digits, BDIGIT, ++RBIGNUM(x)->len);
ds = BDIGITS(x);
- ds[RBIGNUM(x)->len-1] = 1;
+ ds[RBIGNUM(x)->len-1] = ~0;
}
}
+void
+rb_big_2comp(x) /* get 2's complement */
+ VALUE x;
+{
+ get2comp(x, Qtrue);
+}
+
static VALUE
bignorm(x)
VALUE x;
@@ -105,16 +107,16 @@ bignorm(x)
while (len-- && !ds[len]) ;
RBIGNUM(x)->len = ++len;
- if (len*sizeof(BDIGIT) <= sizeof(VALUE)) {
+ if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
long num = 0;
while (len--) {
num = BIGUP(num) + ds[len];
}
if (num >= 0) {
if (RBIGNUM(x)->sign) {
- if (POSFIXABLE(num)) return INT2FIX(num);
+ if (POSFIXABLE(num)) return LONG2FIX(num);
}
- else if (NEGFIXABLE(-(long)num)) return INT2FIX(-(long)num);
+ else if (NEGFIXABLE(-(long)num)) return LONG2FIX(-(long)num);
}
}
}
@@ -137,7 +139,6 @@ rb_uint2big(n)
BDIGIT *digits;
VALUE big;
- i = 0;
big = bignew(DIGSPERLONG, 1);
digits = BDIGITS(big);
while (i < DIGSPERLONG) {
@@ -146,7 +147,7 @@ rb_uint2big(n)
}
i = DIGSPERLONG;
- while (i-- && !digits[i]) ;
+ while (--i && !digits[i]) ;
RBIGNUM(big)->len = i+1;
return big;
}
@@ -173,7 +174,7 @@ VALUE
rb_uint2inum(n)
unsigned long n;
{
- if (POSFIXABLE(n)) return INT2FIX(n);
+ if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_uint2big(n);
}
@@ -181,26 +182,163 @@ VALUE
rb_int2inum(n)
long n;
{
- if (FIXABLE(n)) return INT2FIX(n);
+ if (FIXABLE(n)) return LONG2FIX(n);
return rb_int2big(n);
}
+#ifdef HAVE_LONG_LONG
+
+void
+rb_quad_pack(buf, val)
+ char *buf;
+ VALUE val;
+{
+ LONG_LONG q;
+
+ val = rb_to_int(val);
+ if (FIXNUM_P(val)) {
+ q = FIX2LONG(val);
+ }
+ else {
+ long len = RBIGNUM(val)->len;
+ BDIGIT *ds;
+
+ if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS)
+ rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
+ ds = BDIGITS(val);
+ q = 0;
+ while (len--) {
+ q = BIGUP(q);
+ q += ds[len];
+ }
+ if (!RBIGNUM(val)->sign) q = -q;
+ }
+ memcpy(buf, (char*)&q, SIZEOF_LONG_LONG);
+}
+
VALUE
-rb_cstr2inum(str, base)
+rb_quad_unpack(buf, sign)
+ const char *buf;
+ int sign;
+{
+ unsigned LONG_LONG q;
+ long neg = 0;
+ long i;
+ BDIGIT *digits;
+ VALUE big;
+
+ memcpy(&q, buf, SIZEOF_LONG_LONG);
+ if (sign) {
+ if (FIXABLE((LONG_LONG)q)) return LONG2FIX((LONG_LONG)q);
+ if ((LONG_LONG)q < 0) {
+ q = -(LONG_LONG)q;
+ neg = 1;
+ }
+ }
+ else {
+ if (POSFIXABLE(q)) return LONG2FIX(q);
+ }
+
+ i = 0;
+ big = bignew(DIGSPERLL, 1);
+ digits = BDIGITS(big);
+ while (i < DIGSPERLL) {
+ digits[i++] = BIGLO(q);
+ q = BIGDN(q);
+ }
+
+ i = DIGSPERLL;
+ while (i-- && !digits[i]) ;
+ RBIGNUM(big)->len = i+1;
+
+ if (neg) {
+ RBIGNUM(big)->sign = 0;
+ }
+ return bignorm(big);
+}
+
+#else
+
+#define QUAD_SIZE 8
+
+void
+rb_quad_pack(buf, val)
+ char *buf;
+ VALUE val;
+{
+ long len;
+
+ memset(buf, 0, QUAD_SIZE);
+ val = rb_to_int(val);
+ if (FIXNUM_P(val)) {
+ val = rb_int2big(FIX2LONG(val));
+ }
+ len = RBIGNUM(val)->len * SIZEOF_BDIGITS;
+ if (len > QUAD_SIZE) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
+ }
+ memcpy(buf, (char*)BDIGITS(val), len);
+ if (!RBIGNUM(val)->sign) {
+ len = QUAD_SIZE;
+ while (len--) {
+ *buf = ~*buf;
+ buf++;
+ }
+ }
+}
+
+#define BNEG(b) (RSHIFT(((BDIGIT*)b)[QUAD_SIZE/SIZEOF_BDIGITS-1],BITSPERDIG-1) != 0)
+
+VALUE
+rb_quad_unpack(buf, sign)
+ const char *buf;
+ int sign;
+{
+ VALUE big = bignew(QUAD_SIZE/SIZEOF_BDIGITS, 1);
+
+ memcpy((char*)BDIGITS(big), buf, QUAD_SIZE);
+ if (sign && BNEG(buf)) {
+ long len = QUAD_SIZE;
+ char *tmp = (char*)BDIGITS(big);
+
+ RBIGNUM(big)->sign = 0;
+ while (len--) {
+ *tmp = ~*tmp;
+ tmp++;
+ }
+ }
+
+ return bignorm(big);
+}
+
+#endif
+
+VALUE
+rb_cstr_to_inum(str, base, badcheck)
const char *str;
int base;
+ int badcheck;
{
const char *s = str;
char *end;
- int badcheck = (base==0)?1:0;
- char sign = 1, c;
+ char sign = 1, nondigit = 0;
+ int c;
BDIGIT_DBL num;
long len, blen = 1;
long i;
VALUE z;
BDIGIT *zds;
- while (*str && ISSPACE(*str)) str++;
+ if (!str) {
+ if (badcheck) goto bad;
+ return INT2FIX(0);
+ }
+ if (badcheck) {
+ while (ISSPACE(*str)) str++;
+ }
+ else {
+ while (ISSPACE(*str) || *str == '_') str++;
+ }
if (str[0] == '+') {
str++;
@@ -213,39 +351,79 @@ rb_cstr2inum(str, base)
if (badcheck) goto bad;
return INT2FIX(0);
}
- if (base == 0) {
+ if (base <= 0) {
if (str[0] == '0') {
- if (str[1] == 'x' || str[1] == 'X') {
+ switch (str[1]) {
+ case 'x': case 'X':
base = 16;
- }
- else if (str[1] == 'b' || str[1] == 'B') {
+ break;
+ case 'b': case 'B':
base = 2;
- }
- else {
+ break;
+ case 'o': case 'O':
+ base = 8;
+ break;
+ case 'd': case 'D':
+ base = 10;
+ break;
+ default:
base = 8;
}
}
+ else if (base < -1) {
+ base = -base;
+ }
else {
base = 10;
}
}
- if (base == 8) {
- while (*str == '0') str++;
- if (!*str) return INT2FIX(0);
- while (*str == '_') str++;
- len = 3*strlen(str)*sizeof(char);
- }
- else { /* base == 10, 2 or 16 */
- if (base == 16 && str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) {
+ switch (base) {
+ case 2:
+ len = 1;
+ if (str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) {
str += 2;
}
- if (base == 2 && str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) {
+ break;
+ case 3:
+ len = 2;
+ break;
+ case 8:
+ if (str[0] == '0' && (str[1] == 'o'||str[1] == 'O')) {
+ str += 2;
+ }
+ case 4: case 5: case 6: case 7:
+ len = 3;
+ break;
+ case 10:
+ if (str[0] == '0' && (str[1] == 'd'||str[1] == 'D')) {
+ str += 2;
+ }
+ case 9: case 11: case 12: case 13: case 14: case 15:
+ len = 4;
+ break;
+ case 16:
+ len = 4;
+ if (str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) {
str += 2;
}
- while (*str && *str == '0') str++;
- if (!*str) str--;
- len = 4*strlen(str)*sizeof(char);
+ break;
+ default:
+ if (base < 2 || 36 < base) {
+ rb_raise(rb_eArgError, "illegal radix %d", base);
+ }
+ if (base <= 32) {
+ len = 5;
+ }
+ else {
+ len = 6;
+ }
+ break;
+ }
+ if (*str == '0') { /* squeeze preceeding 0s */
+ while (*++str == '0');
+ --str;
}
+ len *= strlen(str)*sizeof(char);
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
unsigned long val = strtoul((char*)str, &end, base);
@@ -254,23 +432,20 @@ rb_cstr2inum(str, base)
if (badcheck) {
if (end == str) goto bad; /* no number */
while (*end && ISSPACE(*end)) end++;
- if (*end) { /* trailing garbage */
- bad:
- rb_raise(rb_eArgError, "invalid value for Integer: \"%s\"", s);
- }
+ if (*end) goto bad; /* trailing garbage */
}
if (POSFIXABLE(val)) {
- if (sign) return INT2FIX(val);
+ if (sign) return LONG2FIX(val);
else {
long result = -(long)val;
- return INT2FIX(result);
+ return LONG2FIX(result);
}
}
else {
VALUE big = rb_uint2big(val);
RBIGNUM(big)->sign = sign;
- return big;
+ return bignorm(big);
}
}
bigparse:
@@ -281,33 +456,30 @@ rb_cstr2inum(str, base)
zds = BDIGITS(z);
for (i=len;i--;) zds[i]=0;
while (c = *str++) {
- switch (c) {
- case '8': case '9':
- if (base == 8) {
- c = base;
- break;
+ if (c == '_') {
+ if (badcheck) {
+ if (nondigit) goto bad;
+ nondigit = c;
}
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7':
- c = c - '0';
- break;
- case 'a': case 'b': case 'c':
- case 'd': case 'e': case 'f':
- if (base != 16) c = base;
- else c = c - 'a' + 10;
- break;
- case 'A': case 'B': case 'C':
- case 'D': case 'E': case 'F':
- if (base != 16) c = base;
- else c = c - 'A' + 10;
- break;
- case '_':
continue;
- default:
- c = base;
+ }
+ else if (!ISASCII(c)) {
+ break;
+ }
+ else if (isdigit(c)) {
+ c -= '0';
+ }
+ else if (islower(c)) {
+ c -= 'a' - 10;
+ }
+ else if (isupper(c)) {
+ c -= 'A' - 10;
+ }
+ else {
break;
}
if (c >= base) break;
+ nondigit = 0;
i = 0;
num = c;
for (;;) {
@@ -326,44 +498,128 @@ rb_cstr2inum(str, base)
if (badcheck) {
str--;
if (s+1 < str && str[-1] == '_') goto bad;
- if (ISSPACE(c)) {
- while (*str && ISSPACE(*str)) str++;
+ while (*str && ISSPACE(*str)) str++;
+ if (*str) {
+ bad:
+ rb_invalid_str(s, "Integer");
}
- if (*str) goto bad;
}
return bignorm(z);
}
VALUE
-rb_str2inum(str, base)
+rb_str_to_inum(str, base, badcheck)
VALUE str;
int base;
+ int badcheck;
{
char *s;
- int len;
+ long len;
+
+ StringValue(str);
+ if (badcheck) {
+ s = StringValueCStr(str);
+ }
+ else {
+ s = RSTRING(str)->ptr;
+ }
+ if (s) {
+ len = RSTRING(str)->len;
+ if (s[len]) { /* no sentinel somehow */
+ char *p = ALLOCA_N(char, len+1);
+
+ MEMCPY(p, s, char, len);
+ p[len] = '\0';
+ s = p;
+ }
+ }
+ return rb_cstr_to_inum(s, base, badcheck);
+}
+
+#if HAVE_LONG_LONG
+
+VALUE
+rb_ull2big(n)
+ unsigned LONG_LONG n;
+{
+ BDIGIT_DBL num = n;
+ long i = 0;
+ BDIGIT *digits;
+ VALUE big;
+
+ big = bignew(DIGSPERLL, 1);
+ digits = BDIGITS(big);
+ while (i < DIGSPERLL) {
+ digits[i++] = BIGLO(num);
+ num = BIGDN(num);
+ }
+
+ i = DIGSPERLL;
+ while (i-- && !digits[i]) ;
+ RBIGNUM(big)->len = i+1;
+ return big;
+}
- s = rb_str2cstr(str, &len);
- if (s[len]) { /* no sentinel somehow */
- char *p = ALLOCA_N(char, len+1);
+VALUE
+rb_ll2big(n)
+ LONG_LONG n;
+{
+ long neg = 0;
+ VALUE big;
- MEMCPY(p, s, char, len);
- p[len] = '\0';
- s = p;
+ if (n < 0) {
+ n = -n;
+ neg = 1;
}
- if (len != strlen(s)) {
- rb_raise(rb_eArgError, "string for Integer contains null byte");
+ big = rb_ull2big(n);
+ if (neg) {
+ RBIGNUM(big)->sign = 0;
}
- return rb_cstr2inum(s, base);
+ return big;
+}
+
+VALUE
+rb_ull2inum(n)
+ unsigned LONG_LONG n;
+{
+ if (POSFIXABLE(n)) return LONG2FIX(n);
+ return rb_ull2big(n);
+}
+
+VALUE
+rb_ll2inum(n)
+ LONG_LONG n;
+{
+ if (FIXABLE(n)) return LONG2FIX(n);
+ return rb_ll2big(n);
+}
+
+#endif /* HAVE_LONG_LONG */
+
+VALUE
+rb_cstr2inum(str, base)
+ const char *str;
+ int base;
+{
+ return rb_cstr_to_inum(str, base, base==0);
+}
+
+VALUE
+rb_str2inum(str, base)
+ VALUE str;
+ int base;
+{
+ return rb_str_to_inum(str, base, base==0);
}
-static char hexmap[] = "0123456789abcdef";
+const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
VALUE
rb_big2str(x, base)
VALUE x;
int base;
{
- VALUE t;
+ volatile VALUE t;
BDIGIT *ds;
long i, j, hbase;
VALUE ss;
@@ -373,28 +629,42 @@ rb_big2str(x, base)
return rb_fix2str(x, base);
}
i = RBIGNUM(x)->len;
- if (i == 0) return rb_str_new2("0");
- if (base == 10) {
- j = (sizeof(BDIGIT)/sizeof(char)*CHAR_BIT*i*241L)/800+2;
- hbase = 10000;
- }
- else if (base == 16) {
- j = (sizeof(BDIGIT)/sizeof(char)*CHAR_BIT*i)/4+2;
- hbase = 0x10000;
- }
- else if (base == 8) {
- j = (sizeof(BDIGIT)/sizeof(char)*CHAR_BIT*i)+2;
- hbase = 010000;
- }
- else if (base == 2) {
- j = (sizeof(BDIGIT)*CHAR_BIT*i)+2;
- hbase = 020;
- }
- else {
- j = 0;
- hbase = 0;
- rb_raise(rb_eArgError, "bignum cannot treat base %d", base);
+ if (BIGZEROP(x)) {
+ return rb_str_new2("0");
+ }
+ j = SIZEOF_BDIGITS*CHAR_BIT*i;
+ switch (base) {
+ case 2: break;
+ case 3:
+ j = j * 647L / 1024;
+ break;
+ case 4: case 5: case 6: case 7:
+ j /= 2;
+ break;
+ case 8: case 9:
+ j /= 3;
+ break;
+ case 10: case 11: case 12: case 13: case 14: case 15:
+ j = j * 241L / 800;
+ break;
+ case 16: case 17: case 18: case 19: case 20: case 21:
+ case 22: case 23: case 24: case 25: case 26: case 27:
+ case 28: case 29: case 30: case 31:
+ j /= 4;
+ break;
+ case 32: case 33: case 34: case 35: case 36:
+ j /= 5;
+ break;
+ default:
+ rb_raise(rb_eArgError, "illegal radix %d", base);
+ break;
}
+ j += 2;
+
+ hbase = base * base;
+#if SIZEOF_BDIGITS > 2
+ hbase *= hbase;
+#endif
t = rb_big_clone(x);
ds = BDIGITS(t);
@@ -412,10 +682,10 @@ rb_big2str(x, base)
num %= hbase;
}
if (ds[i-1] == 0) i--;
- k = 4;
+ k = SIZEOF_BDIGITS;
while (k--) {
c = (char)(num % base);
- s[--j] = hexmap[(int)c];
+ s[--j] = ruby_digitmap[(int)c];
num /= base;
if (i == 0 && num == 0) break;
}
@@ -428,11 +698,33 @@ rb_big2str(x, base)
return ss;
}
+/*
+ * call-seq:
+ * big.to_s(base=10) => string
+ *
+ * Returns a string containing the representation of <i>big</i> radix
+ * <i>base</i> (2 through 36).
+ *
+ * 12345654321.to_s #=> "12345654321"
+ * 12345654321.to_s(2) #=> "1011011111110110111011110000110001"
+ * 12345654321.to_s(8) #=> "133766736061"
+ * 12345654321.to_s(16) #=> "2dfdbbc31"
+ * 78546939656932.to_s(36) #=> "rubyrules"
+ */
+
static VALUE
-rb_big_to_s(x)
+rb_big_to_s(argc, argv, x)
+ int argc;
+ VALUE *argv;
VALUE x;
{
- return rb_big2str(x, 10);
+ VALUE b;
+ int base;
+
+ rb_scan_args(argc, argv, "01", &b);
+ if (argc == 0) base = 10;
+ else base = NUM2INT(b);
+ return rb_big2str(x, base);
}
static unsigned long
@@ -444,7 +736,7 @@ big2ulong(x, type)
BDIGIT_DBL num;
BDIGIT *ds;
- if (len > sizeof(long)/sizeof(BDIGIT))
+ if (len > SIZEOF_LONG/SIZEOF_BDIGITS)
rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
ds = BDIGITS(x);
num = 0;
@@ -461,7 +753,12 @@ rb_big2ulong(x)
{
unsigned long num = big2ulong(x, "unsigned long");
- if (!RBIGNUM(x)->sign) return -num;
+ if (!RBIGNUM(x)->sign) {
+ if ((long)num < 0) {
+ rb_raise(rb_eRangeError, "bignum out of range of unsigned long");
+ }
+ return -num;
+ }
return num;
}
@@ -469,15 +766,63 @@ long
rb_big2long(x)
VALUE x;
{
- unsigned long num = big2ulong(x, "int");
+ unsigned long num = big2ulong(x, "long");
if ((long)num < 0 && (RBIGNUM(x)->sign || (long)num != LONG_MIN)) {
- rb_raise(rb_eRangeError, "bignum too big to convert into `int'");
+ rb_raise(rb_eRangeError, "bignum too big to convert into `long'");
}
if (!RBIGNUM(x)->sign) return -(long)num;
return num;
}
+#if HAVE_LONG_LONG
+
+static unsigned LONG_LONG
+big2ull(x, type)
+ VALUE x;
+ char *type;
+{
+ long len = RBIGNUM(x)->len;
+ BDIGIT_DBL num;
+ BDIGIT *ds;
+
+ if (len > SIZEOF_LONG_LONG/SIZEOF_BDIGITS)
+ rb_raise(rb_eRangeError, "bignum too big to convert into `%s'", type);
+ ds = BDIGITS(x);
+ num = 0;
+ while (len--) {
+ num = BIGUP(num);
+ num += ds[len];
+ }
+ return num;
+}
+
+unsigned LONG_LONG
+rb_big2ull(x)
+ VALUE x;
+{
+ unsigned LONG_LONG num = big2ull(x, "unsigned long long");
+
+ if (!RBIGNUM(x)->sign) return -num;
+ return num;
+}
+
+LONG_LONG
+rb_big2ll(x)
+ VALUE x;
+{
+ unsigned LONG_LONG num = big2ull(x, "long long");
+
+ if ((LONG_LONG)num < 0 && (RBIGNUM(x)->sign
+ || (LONG_LONG)num != LLONG_MIN)) {
+ rb_raise(rb_eRangeError, "bignum too big to convert into `long long'");
+ }
+ if (!RBIGNUM(x)->sign) return -(LONG_LONG)num;
+ return num;
+}
+
+#endif /* HAVE_LONG_LONG */
+
static VALUE
dbl2big(d)
double d;
@@ -529,10 +874,23 @@ rb_big2dbl(x)
while (i--) {
d = ds[i] + BIGRAD*d;
}
+ if (isinf(d)) {
+ rb_warn("Bignum out of Float range");
+ d = HUGE_VAL;
+ }
if (!RBIGNUM(x)->sign) d = -d;
return d;
}
+/*
+ * call-seq:
+ * big.to_f -> float
+ *
+ * Converts <i>big</i> to a <code>Float</code>. If <i>big</i> doesn't
+ * fit in a <code>Float</code>, the result is infinity.
+ *
+ */
+
static VALUE
rb_big_to_f(x)
VALUE x;
@@ -540,6 +898,16 @@ rb_big_to_f(x)
return rb_float_new(rb_big2dbl(x));
}
+/*
+ * call-seq:
+ * big <=> numeric => -1, 0, +1
+ *
+ * Comparison---Returns -1, 0, or +1 depending on whether <i>big</i> is
+ * less than, equal to, or greater than <i>numeric</i>. This is the
+ * basis for the tests in <code>Comparable</code>.
+ *
+ */
+
static VALUE
rb_big_cmp(x, y)
VALUE x, y;
@@ -555,11 +923,10 @@ rb_big_cmp(x, y)
break;
case T_FLOAT:
- y = dbl2big(RFLOAT(y)->value);
- break;
+ return rb_dbl_cmp(rb_big2dbl(x), RFLOAT(y)->value);
default:
- return rb_num_coerce_bin(x, y);
+ return rb_num_coerce_cmp(x, y);
}
if (RBIGNUM(x)->sign > RBIGNUM(y)->sign) return INT2FIX(1);
@@ -576,6 +943,17 @@ rb_big_cmp(x, y)
(RBIGNUM(x)->sign ? INT2FIX(-1) : INT2FIX(1));
}
+/*
+ * call-seq:
+ * big == obj => true or false
+ *
+ * Returns <code>true</code> only if <i>obj</i> has the same value
+ * as <i>big</i>. Contrast this with <code>Bignum#eql?</code>, which
+ * requires <i>obj</i> to be a <code>Bignum</code>.
+ *
+ * 68719476736 == 68719476736.0 #=> true
+ */
+
static VALUE
rb_big_eq(x, y)
VALUE x, y;
@@ -587,10 +965,16 @@ rb_big_eq(x, y)
case T_BIGNUM:
break;
case T_FLOAT:
- y = dbl2big(RFLOAT(y)->value);
- break;
+ {
+ volatile double a, b;
+
+ a = RFLOAT(y)->value;
+ b = rb_big2dbl(x);
+ if (isnan(a) || isnan(b)) return Qfalse;
+ return (a == b)?Qtrue:Qfalse;
+ }
default:
- return Qfalse;
+ return rb_equal(y, x);
}
if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
if (RBIGNUM(x)->len != RBIGNUM(y)->len) return Qfalse;
@@ -598,6 +982,35 @@ rb_big_eq(x, y)
return Qtrue;
}
+/*
+ * call-seq:
+ * big.eql?(obj) => true or false
+ *
+ * Returns <code>true</code> only if <i>obj</i> is a
+ * <code>Bignum</code> with the same value as <i>big</i>. Contrast this
+ * with <code>Bignum#==</code>, which performs type conversions.
+ *
+ * 68719476736.eql?(68719476736.0) #=> false
+ */
+
+static VALUE
+rb_big_eql(x, y)
+ VALUE x, y;
+{
+ if (TYPE(y) != T_BIGNUM) return Qfalse;
+ if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
+ if (RBIGNUM(x)->len != RBIGNUM(y)->len) return Qfalse;
+ if (MEMCMP(BDIGITS(x),BDIGITS(y),BDIGIT,RBIGNUM(y)->len) != 0) return Qfalse;
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * -big => other_big
+ *
+ * Unary minus (returns a new Bignum whose value is 0-big)
+ */
+
static VALUE
rb_big_uminus(x)
VALUE x;
@@ -609,6 +1022,18 @@ rb_big_uminus(x)
return bignorm(z);
}
+/*
+ * call-seq:
+ * ~big => integer
+ *
+ * Inverts the bits in big. As Bignums are conceptually infinite
+ * length, the result acts as if it had an infinite number of one
+ * bits to the left. In hex representations, this is displayed
+ * as two periods to the left of the digits.
+ *
+ * sprintf("%X", ~0x1122334455) #=> "..FEEDDCCBBAA"
+ */
+
static VALUE
rb_big_neg(x)
VALUE x;
@@ -617,9 +1042,9 @@ rb_big_neg(x)
long i = RBIGNUM(x)->len;
BDIGIT *ds = BDIGITS(z);
- if (!RBIGNUM(x)->sign) rb_big_2comp(z);
+ if (!RBIGNUM(x)->sign) get2comp(z, Qtrue);
while (i--) ds[i] = ~ds[i];
- if (RBIGNUM(x)->sign) rb_big_2comp(z);
+ if (RBIGNUM(x)->sign) get2comp(z, Qfalse);
RBIGNUM(z)->sign = !RBIGNUM(z)->sign;
return bignorm(z);
@@ -632,9 +1057,8 @@ bigsub(x, y)
VALUE z = 0;
BDIGIT *zds;
BDIGIT_DBL_SIGNED num;
- long i;
-
- i = RBIGNUM(x)->len;
+ long i = RBIGNUM(x)->len;
+
/* if x is larger than y, swap */
if (RBIGNUM(x)->len < RBIGNUM(y)->len) {
z = x; x = y; y = z; /* swap x y */
@@ -718,6 +1142,13 @@ bigadd(x, y, sign)
return z;
}
+/*
+ * call-seq:
+ * big + other => Numeric
+ *
+ * Adds big and other, returning the result.
+ */
+
VALUE
rb_big_plus(x, y)
VALUE x, y;
@@ -737,6 +1168,13 @@ rb_big_plus(x, y)
}
}
+/*
+ * call-seq:
+ * big - other => Numeric
+ *
+ * Subtracts other from big, returning the result.
+ */
+
VALUE
rb_big_minus(x, y)
VALUE x, y;
@@ -756,6 +1194,13 @@ rb_big_minus(x, y)
}
}
+/*
+ * call-seq:
+ * big * other => Numeric
+ *
+ * Multiplies big and other, returning the result.
+ */
+
VALUE
rb_big_mul(x, y)
VALUE x, y;
@@ -816,9 +1261,9 @@ bigdivrem(x, y, divp, modp)
BDIGIT_DBL_SIGNED num;
BDIGIT dd, q;
+ if (BIGZEROP(y)) rb_num_zerodiv();
yds = BDIGITS(y);
- if (ny == 0 && yds[0] == 0) rb_num_zerodiv();
- if (nx < ny || nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1]) {
+ if (nx < ny || (nx == ny && BDIGITS(x)[nx - 1] < BDIGITS(y)[ny - 1])) {
if (divp) *divp = rb_int2big(0);
if (modp) *modp = x;
return;
@@ -915,10 +1360,10 @@ bigdivrem(x, y, divp, modp)
for (i = 0;i < j;i++) zds[i] = zds[i+ny];
RBIGNUM(*divp)->len = i;
}
- if (modp) { /* just normalize remainder */
+ if (modp) { /* normalize remainder */
*modp = rb_big_clone(z);
zds = BDIGITS(*modp);
- while (0 < ny && !zds[ny-1]) ny--;
+ while (--ny && !zds[ny]); ++ny;
if (dd) {
t2 = 0; i = ny;
while(i--) {
@@ -941,7 +1386,7 @@ bigdivmod(x, y, divp, modp)
VALUE mod;
bigdivrem(x, y, divp, &mod);
- if (RBIGNUM(x)->sign != RBIGNUM(y)->sign && RBIGNUM(mod)->len > 0) {
+ if (RBIGNUM(x)->sign != RBIGNUM(y)->sign && !BIGZEROP(mod)) {
if (divp) *divp = bigadd(*divp, rb_int2big(1), 0);
if (modp) *modp = bigadd(mod, y, 1);
}
@@ -951,6 +1396,14 @@ bigdivmod(x, y, divp, modp)
}
}
+/*
+ * call-seq:
+ * big / other => Numeric
+ * big.div(other) => Numeric
+ *
+ * Divides big by other, returning the result.
+ */
+
static VALUE
rb_big_div(x, y)
VALUE x, y;
@@ -976,6 +1429,14 @@ rb_big_div(x, y)
return bignorm(z);
}
+/*
+ * call-seq:
+ * big % other => Numeric
+ * big.modulo(other) => Numeric
+ *
+ * Returns big modulo other. See Numeric.divmod for more
+ * information.
+ */
static VALUE
rb_big_modulo(x, y)
@@ -999,6 +1460,15 @@ rb_big_modulo(x, y)
return bignorm(z);
}
+/*
+ * call-seq:
+ * big.remainder(numeric) => number
+ *
+ * Returns the remainder after dividing <i>big</i> by <i>numeric</i>.
+ *
+ * -1234567890987654321.remainder(13731) #=> -6966
+ * -1234567890987654321.remainder(13731.24) #=> -9906.22531493148
+ */
static VALUE
rb_big_remainder(x, y)
VALUE x, y;
@@ -1021,6 +1491,13 @@ rb_big_remainder(x, y)
return bignorm(z);
}
+/*
+ * call-seq:
+ * big.divmod(numeric) => array
+ *
+ * See <code>Numeric#divmod</code>.
+ *
+ */
VALUE
rb_big_divmod(x, y)
VALUE x, y;
@@ -1043,6 +1520,57 @@ rb_big_divmod(x, y)
return rb_assoc_new(bignorm(div), bignorm(mod));
}
+/*
+ * call-seq:
+ * big.quo(numeric) -> float
+ *
+ * Returns the floating point result of dividing <i>big</i> by
+ * <i>numeric</i>.
+ *
+ * -1234567890987654321.quo(13731) #=> -89910996357705.5
+ * -1234567890987654321.quo(13731.24) #=> -89909424858035.7
+ *
+ */
+
+static VALUE
+rb_big_quo(x, y)
+ VALUE x, y;
+{
+ double dx = rb_big2dbl(x);
+ double dy;
+
+ switch (TYPE(y)) {
+ case T_FIXNUM:
+ dy = (double)FIX2LONG(y);
+ break;
+
+ case T_BIGNUM:
+ dy = rb_big2dbl(y);
+ break;
+
+ case T_FLOAT:
+ dy = RFLOAT(y)->value;
+ break;
+
+ default:
+ return rb_num_coerce_bin(x, y);
+ }
+ return rb_float_new(dx / dy);
+}
+
+/*
+ * call-seq:
+ * big ** exponent #=> numeric
+ *
+ * Raises _big_ to the _exponent_ power (which may be an integer, float,
+ * or anything that will coerce to a number). The result may be
+ * a Fixnum, Bignum, or Float
+ *
+ * 123456789 ** 2 #=> 15241578750190521
+ * 123456789 ** 1.2 #=> 5126464716.09932
+ * 123456789 ** -2 #=> 6.5610001194102e-17
+ */
+
VALUE
rb_big_pow(x, y)
VALUE x, y;
@@ -1062,22 +1590,20 @@ rb_big_pow(x, y)
break;
case T_FIXNUM:
- yy = NUM2LONG(y);
+ yy = FIX2LONG(y);
if (yy > 0) {
- VALUE z;
+ VALUE z = x;
- z = x;
for (;;) {
- yy = yy - 1;
+ yy -= 1;
if (yy == 0) break;
while (yy % 2 == 0) {
- yy = yy / 2;
+ yy /= 2;
x = rb_big_mul(x, x);
}
z = rb_big_mul(z, x);
}
- if (!FIXNUM_P(z)) z = bignorm(z);
- return z;
+ return bignorm(z);
}
d = (double)yy;
break;
@@ -1088,29 +1614,34 @@ rb_big_pow(x, y)
return rb_float_new(pow(rb_big2dbl(x), d));
}
+/*
+ * call-seq:
+ * big & numeric => integer
+ *
+ * Performs bitwise +and+ between _big_ and _numeric_.
+ */
+
VALUE
-rb_big_and(x, y)
- VALUE x, y;
+rb_big_and(xx, yy)
+ VALUE xx, yy;
{
- VALUE z;
+ volatile VALUE x, y, z;
BDIGIT *ds1, *ds2, *zds;
long i, l1, l2;
char sign;
+ x = xx;
+ y = rb_to_int(yy);
if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
}
- else {
- Check_Type(y, T_BIGNUM);
- }
-
if (!RBIGNUM(y)->sign) {
y = rb_big_clone(y);
- rb_big_2comp(y);
+ get2comp(y, Qtrue);
}
if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x);
- rb_big_2comp(x);
+ get2comp(x, Qtrue);
}
if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
l1 = RBIGNUM(y)->len;
@@ -1135,33 +1666,39 @@ rb_big_and(x, y)
for (; i<l2; i++) {
zds[i] = sign?0:ds2[i];
}
- if (!RBIGNUM(z)->sign) rb_big_2comp(z);
+ if (!RBIGNUM(z)->sign) get2comp(z, Qfalse);
return bignorm(z);
}
+/*
+ * call-seq:
+ * big | numeric => integer
+ *
+ * Performs bitwise +or+ between _big_ and _numeric_.
+ */
+
VALUE
-rb_big_or(x, y)
- VALUE x, y;
+rb_big_or(xx, yy)
+ VALUE xx, yy;
{
- VALUE z;
+ volatile VALUE x, y, z;
BDIGIT *ds1, *ds2, *zds;
long i, l1, l2;
char sign;
+ x = xx;
+ y = rb_to_int(yy);
if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
}
- else {
- Check_Type(y, T_BIGNUM);
- }
if (!RBIGNUM(y)->sign) {
y = rb_big_clone(y);
- rb_big_2comp(y);
+ get2comp(y, Qtrue);
}
if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x);
- rb_big_2comp(x);
+ get2comp(x, Qtrue);
}
if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
l1 = RBIGNUM(y)->len;
@@ -1186,34 +1723,41 @@ rb_big_or(x, y)
for (; i<l2; i++) {
zds[i] = sign?ds2[i]:(BIGRAD-1);
}
- if (!RBIGNUM(z)->sign) rb_big_2comp(z);
+ if (!RBIGNUM(z)->sign) get2comp(z, Qfalse);
return bignorm(z);
}
+/*
+ * call-seq:
+ * big ^ numeric => integer
+ *
+ * Performs bitwise +exclusive or+ between _big_ and _numeric_.
+ */
+
VALUE
-rb_big_xor(x, y)
- VALUE x, y;
+rb_big_xor(xx, yy)
+ VALUE xx, yy;
{
+ volatile VALUE x, y;
VALUE z;
BDIGIT *ds1, *ds2, *zds;
long i, l1, l2;
char sign;
+ x = xx;
+ y = rb_to_int(yy);
if (FIXNUM_P(y)) {
y = rb_int2big(FIX2LONG(y));
}
- else {
- Check_Type(y, T_BIGNUM);
- }
if (!RBIGNUM(y)->sign) {
y = rb_big_clone(y);
- rb_big_2comp(y);
+ get2comp(y, Qtrue);
}
if (!RBIGNUM(x)->sign) {
x = rb_big_clone(x);
- rb_big_2comp(x);
+ get2comp(x, Qtrue);
}
if (RBIGNUM(x)->len > RBIGNUM(y)->len) {
l1 = RBIGNUM(y)->len;
@@ -1240,13 +1784,20 @@ rb_big_xor(x, y)
for (; i<l2; i++) {
zds[i] = sign?ds2[i]:~ds2[i];
}
- if (!RBIGNUM(z)->sign) rb_big_2comp(z);
+ if (!RBIGNUM(z)->sign) get2comp(z, Qfalse);
return bignorm(z);
}
static VALUE rb_big_rshift _((VALUE,VALUE));
+/*
+ * call-seq:
+ * big << numeric => integer
+ *
+ * Shifts big left _numeric_ positions (right if _numeric_ is negative).
+ */
+
VALUE
rb_big_lshift(x, y)
VALUE x, y;
@@ -1276,46 +1827,88 @@ rb_big_lshift(x, y)
return bignorm(z);
}
+/*
+ * call-seq:
+ * big >> numeric => integer
+ *
+ * Shifts big right _numeric_ positions (left if _numeric_ is negative).
+ */
+
static VALUE
rb_big_rshift(x, y)
VALUE x, y;
{
BDIGIT *xds, *zds;
int shift = NUM2INT(y);
- int s1 = shift/BITSPERDIG;
- int s2 = shift%BITSPERDIG;
+ long s1 = shift/BITSPERDIG;
+ long s2 = shift%BITSPERDIG;
VALUE z;
BDIGIT_DBL num = 0;
- long i = RBIGNUM(x)->len;
- long j;
+ long i, j;
if (shift < 0) return rb_big_lshift(x, INT2FIX(-shift));
+
if (s1 > RBIGNUM(x)->len) {
if (RBIGNUM(x)->sign)
return INT2FIX(0);
else
return INT2FIX(-1);
}
+ if (!RBIGNUM(x)->sign) {
+ x = rb_big_clone(x);
+ get2comp(x, Qtrue);
+ }
xds = BDIGITS(x);
i = RBIGNUM(x)->len; j = i - s1;
z = bignew(j, RBIGNUM(x)->sign);
+ if (!RBIGNUM(x)->sign) {
+ num = ((BDIGIT_DBL)~0) << BITSPERDIG;
+ }
zds = BDIGITS(z);
while (i--, j--) {
num = (num | xds[i]) >> s2;
zds[j] = BIGLO(num);
num = BIGUP(xds[i]);
}
+ if (!RBIGNUM(x)->sign) {
+ get2comp(z, Qfalse);
+ }
return bignorm(z);
}
+/*
+ * call-seq:
+ * big[n] -> 0, 1
+ *
+ * Bit Reference---Returns the <em>n</em>th bit in the (assumed) binary
+ * representation of <i>big</i>, where <i>big</i>[0] is the least
+ * significant bit.
+ *
+ * a = 9**15
+ * 50.downto(0) do |n|
+ * print a[n]
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * 000101110110100000111000011110010100111100010111001
+ *
+ */
+
static VALUE
rb_big_aref(x, y)
VALUE x, y;
{
BDIGIT *xds;
- int shift = NUM2INT(y);
- int s1, s2;
+ int shift;
+ long s1, s2;
+ if (TYPE(y) == T_BIGNUM) {
+ if (!RBIGNUM(y)->sign || RBIGNUM(x)->sign)
+ return INT2FIX(0);
+ return INT2FIX(1);
+ }
+ shift = NUM2INT(y);
if (shift < 0) return INT2FIX(0);
s1 = shift/BITSPERDIG;
s2 = shift%BITSPERDIG;
@@ -1323,7 +1916,7 @@ rb_big_aref(x, y)
if (!RBIGNUM(x)->sign) {
if (s1 >= RBIGNUM(x)->len) return INT2FIX(1);
x = rb_big_clone(x);
- rb_big_2comp(x);
+ get2comp(x, Qtrue);
}
else {
if (s1 >= RBIGNUM(x)->len) return INT2FIX(0);
@@ -1334,6 +1927,13 @@ rb_big_aref(x, y)
return INT2FIX(0);
}
+/*
+ * call-seq:
+ * big.hash => fixnum
+ *
+ * Compute a hash based on the value of _big_.
+ */
+
static VALUE
rb_big_hash(x)
VALUE x;
@@ -1345,9 +1945,13 @@ rb_big_hash(x)
for (i=0; i<len; i++) {
key ^= *digits++;
}
- return INT2FIX(key);
+ return LONG2FIX(key);
}
+/*
+ * MISSING: documentation
+ */
+
static VALUE
rb_big_coerce(x, y)
VALUE x, y;
@@ -1357,12 +1961,21 @@ rb_big_coerce(x, y)
}
else {
rb_raise(rb_eTypeError, "Can't coerce %s to Bignum",
- rb_class2name(CLASS_OF(y)));
+ rb_obj_classname(y));
}
/* not reached */
return Qnil;
}
+/*
+ * call-seq:
+ * big.abs -> aBignum
+ *
+ * Returns the absolute value of <i>big</i>.
+ *
+ * -1234567890987654321.abs #=> 1234567890987654321
+ */
+
static VALUE
rb_big_abs(x)
VALUE x;
@@ -1374,49 +1987,68 @@ rb_big_abs(x)
return x;
}
-/* !!!warnig!!!!
- this is not really a random number!!
-*/
-
VALUE
-rb_big_rand(max, rand)
+rb_big_rand(max, rand_buf)
VALUE max;
- double rand;
+ double *rand_buf;
{
VALUE v;
- long len;
+ long len = RBIGNUM(max)->len;
- len = RBIGNUM(max)->len;
+ if (BIGZEROP(max)) {
+ return rb_float_new(rand_buf[0]);
+ }
v = bignew(len,1);
while (len--) {
- BDIGITS(v)[len] = ((BDIGIT)~0) * rand;
+ BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len];
}
return rb_big_modulo((VALUE)v, max);
}
+/*
+ * call-seq:
+ * big.size -> integer
+ *
+ * Returns the number of bytes in the machine representation of
+ * <i>big</i>.
+ *
+ * (256**10 - 1).size #=> 12
+ * (256**20 - 1).size #=> 20
+ * (256**40 - 1).size #=> 40
+ */
+
static VALUE
rb_big_size(big)
VALUE big;
{
- return INT2FIX(RBIGNUM(big)->len*sizeof(BDIGIT));
+ return LONG2FIX(RBIGNUM(big)->len*SIZEOF_BDIGITS);
}
-static VALUE
-rb_big_zero_p(big)
- VALUE big;
-{
- return Qfalse;
-}
+/*
+ * Bignum objects hold integers outside the range of
+ * Fixnum. Bignum objects are created
+ * automatically when integer calculations would otherwise overflow a
+ * Fixnum. When a calculation involving
+ * Bignum objects returns a result that will fit in a
+ * Fixnum, the result is automatically converted.
+ *
+ * For the purposes of the bitwise operations and <code>[]</code>, a
+ * Bignum is treated as if it were an infinite-length
+ * bitstring with 2's complement representation.
+ *
+ * While Fixnum values are immediate, Bignum
+ * objects are not---assignment and parameter passing work with
+ * references to objects, not the objects themselves.
+ *
+ */
void
Init_Bignum()
{
rb_cBignum = rb_define_class("Bignum", rb_cInteger);
- rb_undef_method(CLASS_OF(rb_cBignum), "new");
-
- rb_define_method(rb_cBignum, "to_s", rb_big_to_s, 0);
+ rb_define_method(rb_cBignum, "to_s", rb_big_to_s, -1);
rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
rb_define_method(rb_cBignum, "-@", rb_big_uminus, 0);
rb_define_method(rb_cBignum, "+", rb_big_plus, 1);
@@ -1424,9 +2056,11 @@ Init_Bignum()
rb_define_method(rb_cBignum, "*", rb_big_mul, 1);
rb_define_method(rb_cBignum, "/", rb_big_div, 1);
rb_define_method(rb_cBignum, "%", rb_big_modulo, 1);
+ rb_define_method(rb_cBignum, "div", rb_big_div, 1);
rb_define_method(rb_cBignum, "divmod", rb_big_divmod, 1);
rb_define_method(rb_cBignum, "modulo", rb_big_modulo, 1);
rb_define_method(rb_cBignum, "remainder", rb_big_remainder, 1);
+ rb_define_method(rb_cBignum, "quo", rb_big_quo, 1);
rb_define_method(rb_cBignum, "**", rb_big_pow, 1);
rb_define_method(rb_cBignum, "&", rb_big_and, 1);
rb_define_method(rb_cBignum, "|", rb_big_or, 1);
@@ -1438,11 +2072,9 @@ Init_Bignum()
rb_define_method(rb_cBignum, "<=>", rb_big_cmp, 1);
rb_define_method(rb_cBignum, "==", rb_big_eq, 1);
- rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
- rb_define_method(rb_cBignum, "eql?", rb_big_eq, 1);
+ rb_define_method(rb_cBignum, "eql?", rb_big_eql, 1);
rb_define_method(rb_cBignum, "hash", rb_big_hash, 0);
rb_define_method(rb_cBignum, "to_f", rb_big_to_f, 0);
rb_define_method(rb_cBignum, "abs", rb_big_abs, 0);
rb_define_method(rb_cBignum, "size", rb_big_size, 0);
- rb_define_method(rb_cBignum, "zero?", rb_big_zero_p, 0);
}
diff --git a/bin/erb b/bin/erb
new file mode 100755
index 0000000000..2459d2562e
--- /dev/null
+++ b/bin/erb
@@ -0,0 +1,139 @@
+#!/usr/bin/env ruby
+# Tiny eRuby --- ERB2
+# Copyright (c) 1999-2000,2002 Masatoshi SEKI
+# You can redistribute it and/or modify it under the same terms as Ruby.
+
+require 'erb'
+
+class ERB
+ module Main
+ def ARGV.switch
+ return nil if self.empty?
+ arg = self.shift
+ return nil if arg == '--'
+ if arg =~ /^-(.)(.*)/
+ return arg if $1 == '-'
+ raise 'unknown switch "-"' if $2.index('-')
+ self.unshift "-#{$2}" if $2.size > 0
+ "-#{$1}"
+ else
+ self.unshift arg
+ nil
+ end
+ end
+
+ def ARGV.req_arg
+ self.shift || raise('missing argument')
+ end
+
+ def trim_mode_opt(trim_mode, disable_percent)
+ return trim_mode if disable_percent
+ case trim_mode
+ when 0
+ return '%'
+ when 1
+ return '%>'
+ when 2
+ return '%<>'
+ when '-'
+ return '%-'
+ end
+ end
+ module_function :trim_mode_opt
+
+ def run(factory=ERB)
+ trim_mode = 0
+ disable_percent = false
+ begin
+ while switch = ARGV.switch
+ case switch
+ when '-x' # ruby source
+ output = true
+ when '-n' # line number
+ number = true
+ when '-v' # verbose
+ $VERBOSE = true
+ when '--version' # version
+ STDERR.puts factory.version
+ exit
+ when '-d', '--debug' # debug
+ $DEBUG = true
+ when '-r' # require
+ require ARGV.req_arg
+ when '-S' # sacurity level
+ arg = ARGV.req_arg
+ raise "invalid safe_level #{arg.dump}" unless arg =~ /^[0-4]$/
+ safe_level = arg.to_i
+ when '-T' # trim mode
+ arg = ARGV.req_arg
+ if arg == '-'
+ trim_mode = arg
+ next
+ end
+ raise "invalid trim mode #{arg.dump}" unless arg =~ /^[0-2]$/
+ trim_mode = arg.to_i
+ when '-K' # KCODE
+ arg = ARGV.req_arg
+ case arg.downcase
+ when 'e', '-e', 'euc'
+ $KCODE = 'EUC'
+ when 's', '-s', 'sjis'
+ $KCODE = 'SJIS'
+ when 'u', '-u', 'utf8'
+ $KCODE = 'UTF8'
+ when 'n', '-n', 'none'
+ $KCODE = 'NONE'
+ else
+ raise "invalid KCODE #{arg.dump}"
+ end
+ when '-P'
+ disable_percent = true
+ when '--help'
+ raise "print this help"
+ else
+ raise "unknown switch #{switch.dump}"
+ end
+ end
+ rescue # usage
+ STDERR.puts $!.to_s
+ STDERR.puts File.basename($0) +
+ " [switches] [inputfile]"
+ STDERR.puts <<EOU
+ -x print ruby script
+ -n print ruby script with line number
+ -v enable verbose mode
+ -d set $DBEUG to true
+ -r [library] load a library
+ -K [kcode] specify KANJI code-set
+ -S [safe_level] set $SAFE (0..4)
+ -T [trim_mode] specify trim_mode (0..2, -)
+ -P disregard the lin which starts in "%"
+EOU
+ exit 1
+ end
+
+ src = $<.read
+ exit 2 unless src
+ trim = trim_mode_opt(trim_mode, disable_percent)
+ erb = factory.new(src.untaint, safe_level, trim)
+ if output
+ if number
+ l = 1
+ for line in erb.src
+ puts "%3d %s"%[l, line]
+ l += 1
+ end
+ else
+ puts erb.src
+ end
+ else
+ erb.run(TOPLEVEL_BINDING.taint)
+ end
+ end
+ module_function :run
+ end
+end
+
+if __FILE__ == $0
+ ERB::Main.run
+end
diff --git a/sample/irb.rb b/bin/irb
index 6746c59d42..309da52161 100644
--- a/sample/irb.rb
+++ b/bin/irb
@@ -1,19 +1,13 @@
#!/usr/bin/env ruby
#
# irb.rb - intaractive ruby
-# $Release Version: 0.6 $
+# $Release Version: 0.7.3 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
-#
-# --
-# Usage:
-#
-# irb.rb [options] file_name opts
-#
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
-require "irb/main"
+require "irb"
if __FILE__ == $0
IRB.start(__FILE__)
@@ -22,6 +16,6 @@ else
if /^-e$/ =~ $0
IRB.start(__FILE__)
else
- IRB.initialize(__FILE__)
+ IRB.setup(__FILE__)
end
end
diff --git a/bin/rdoc b/bin/rdoc
new file mode 100644
index 0000000000..fe619137fd
--- /dev/null
+++ b/bin/rdoc
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+#
+# RDoc: Documentation tool for source code
+# (see lib/rdoc/rdoc.rb for more information)
+#
+# Copyright (c) 2003 Dave Thomas
+# Released under the same terms as Ruby
+#
+# $Revision$
+
+## Transitional Hack ####
+#
+# RDoc was initially distributed independently, and installed
+# itself into <prefix>/lib/ruby/site_ruby/<ver>/rdoc...
+#
+# Now that RDoc is part of the distribution, it's installed into
+# <prefix>/lib/ruby/<ver>, which unfortunately appears later in the
+# search path. This means that if you have previously installed RDoc,
+# and then install from ruby-lang, you'll pick up the old one by
+# default. This hack checks for the condition, and readjusts the
+# search path if necessary.
+
+def adjust_for_existing_rdoc(path)
+
+ $stderr.puts %{
+ It seems as if you have a previously-installed RDoc in
+ the directory #{path}.
+
+ Because this is now out-of-date, you might want to consider
+ removing the directories:
+
+ #{File.join(path, "rdoc")}
+
+ and
+
+ #{File.join(path, "markup")}
+
+ }
+
+ # Move all the site_ruby directories to the end
+ p $:
+ $:.replace($:.partition {|path| /site_ruby/ !~ path}.flatten)
+ p $:
+end
+
+$:.each do |path|
+ if /site_ruby/ =~ path
+ rdoc_path = File.join(path, 'rdoc', 'rdoc.rb')
+ if File.exists?(rdoc_path)
+ adjust_for_existing_rdoc(path)
+ break
+ end
+ end
+end
+
+## End of Transitional Hack ##
+
+
+require 'rdoc/rdoc'
+
+begin
+ r = RDoc::RDoc.new
+ r.document(ARGV)
+rescue RDoc::RDocError => e
+ $stderr.puts e.message
+ exit(1)
+end
diff --git a/bin/ri b/bin/ri
new file mode 100755
index 0000000000..fb3e00eda3
--- /dev/null
+++ b/bin/ri
@@ -0,0 +1,49 @@
+#!/usr/bin/env ruby
+# usage:
+#
+# ri name...
+#
+# where name can be
+#
+# Class | Class::method | Class#method | Class.method | method
+#
+# All names may be abbreviated to their minimum unbiguous form. If a name
+# _is_ ambiguous, all valid options will be listed.
+#
+# The form '.' method matches either class or instance methods, while
+# #method matches only instance and ::method matches only class methods.
+#
+#
+# == Installing Documentation
+#
+# 'ri' uses a database of documentation built by the RDoc utility.
+#
+# So, how do you install this documentation on your system?
+# It depends on how you installed Ruby.
+#
+# <em>If you installed Ruby from source files</em> (that is, if it some point
+# you typed 'make' during the process :), you can install the RDoc
+# documentation yourself. Just go back to the place where you have
+# your Ruby source and type
+#
+# make install-doc
+#
+# You'll probably need to do this as a superuser, as the documentation
+# is installed in the Ruby target tree (normally somewhere under
+# <tt>/usr/local</tt>.
+#
+# <em>If you installed Ruby from a binary distribution</em> (perhaps
+# using a one-click installer, or using some other packaging system),
+# then the team that produced the package probably forgot to package
+# the documentation as well. Contact them, and see if they can add
+# it to the next release.
+#
+
+
+require 'rdoc/ri/ri_driver'
+
+######################################################################
+
+ri = RiDriver.new
+ri.process_args
+
diff --git a/bin/testrb b/bin/testrb
new file mode 100755
index 0000000000..ff49cb5466
--- /dev/null
+++ b/bin/testrb
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+require 'test/unit'
+(r = Test::Unit::AutoRunner.new(true)).process_args(ARGV) or
+ abort r.options.banner + " tests..."
+exit r.run
diff --git a/class.c b/class.c
index b5caf3082a..8addef7612 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-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
@@ -19,7 +19,7 @@
extern st_table *rb_class_tbl;
VALUE
-rb_class_new(super)
+rb_class_boot(super)
VALUE super;
{
NEWOBJ(klass, struct RClass);
@@ -30,70 +30,90 @@ rb_class_new(super)
klass->m_tbl = 0; /* safe GC */
klass->m_tbl = st_init_numtable();
+ OBJ_INFECT(klass, super);
return (VALUE)klass;
}
+VALUE
+rb_class_new(super)
+ VALUE super;
+{
+ Check_Type(super, T_CLASS);
+ if (super == rb_cClass) {
+ rb_raise(rb_eTypeError, "can't make subclass of Class");
+ }
+ if (FL_TEST(super, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't make subclass of virtual class");
+ }
+ return rb_class_boot(super);
+}
+
static int
clone_method(mid, body, tbl)
ID mid;
NODE *body;
st_table *tbl;
{
- st_insert(tbl, mid, NEW_METHOD(body->nd_body, body->nd_noex));
+ st_insert(tbl, mid, (st_data_t)NEW_METHOD(body->nd_body, body->nd_noex));
return ST_CONTINUE;
}
VALUE
-rb_mod_clone(module)
- VALUE module;
+rb_mod_init_copy(clone, orig)
+ VALUE clone, orig;
{
- NEWOBJ(clone, struct RClass);
- CLONESETUP(clone, module);
-
- clone->super = RCLASS(module)->super;
- if (RCLASS(module)->iv_tbl) {
- clone->iv_tbl = st_copy(RCLASS(module)->iv_tbl);
+ rb_obj_init_copy(clone, orig);
+ if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
+ RBASIC(clone)->klass = rb_singleton_class_clone(orig);
}
- if (RCLASS(module)->m_tbl) {
- clone->m_tbl = st_init_numtable();
- st_foreach(RCLASS(module)->m_tbl, clone_method, clone->m_tbl);
+ RCLASS(clone)->super = RCLASS(orig)->super;
+ if (RCLASS(orig)->iv_tbl) {
+ ID id;
+
+ RCLASS(clone)->iv_tbl = st_copy(RCLASS(orig)->iv_tbl);
+ id = rb_intern("__classpath__");
+ st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
+ id = rb_intern("__classid__");
+ st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
+ }
+ if (RCLASS(orig)->m_tbl) {
+ RCLASS(clone)->m_tbl = st_init_numtable();
+ st_foreach(RCLASS(orig)->m_tbl, clone_method,
+ (st_data_t)RCLASS(clone)->m_tbl);
}
- return (VALUE)clone;
+ return clone;
}
VALUE
-rb_mod_dup(mod)
- VALUE mod;
+rb_class_init_copy(clone, orig)
+ VALUE clone, orig;
{
- VALUE dup = rb_mod_clone(mod);
- OBJSETUP(dup, RBASIC(mod)->klass, BUILTIN_TYPE(mod));
- if (FL_TEST(mod, FL_SINGLETON)) {
- FL_SET(dup, FL_SINGLETON);
+ if (RCLASS(clone)->super != 0) {
+ rb_raise(rb_eTypeError, "already initialized class");
}
- return dup;
+ return rb_mod_init_copy(clone, orig);
}
VALUE
-rb_singleton_class_new(super)
- VALUE super;
+rb_singleton_class_clone(obj)
+ VALUE obj;
{
- VALUE klass = rb_class_new(super);
+ VALUE klass = RBASIC(obj)->klass;
- FL_SET(klass, FL_SINGLETON);
- return klass;
-}
-
-VALUE
-rb_singleton_class_clone(klass)
- VALUE klass;
-{
if (!FL_TEST(klass, FL_SINGLETON))
return klass;
else {
/* copy singleton(unnamed) class */
NEWOBJ(clone, struct RClass);
- CLONESETUP(clone, klass);
+ OBJSETUP(clone, 0, RBASIC(klass)->flags);
+
+ if (BUILTIN_TYPE(obj) == T_CLASS) {
+ RBASIC(clone)->klass = (VALUE)clone;
+ }
+ else {
+ RBASIC(clone)->klass = rb_singleton_class_clone(klass);
+ }
clone->super = RCLASS(klass)->super;
clone->iv_tbl = 0;
@@ -102,7 +122,9 @@ rb_singleton_class_clone(klass)
clone->iv_tbl = st_copy(RCLASS(klass)->iv_tbl);
}
clone->m_tbl = st_init_numtable();
- st_foreach(RCLASS(klass)->m_tbl, clone_method, clone->m_tbl);
+ st_foreach(RCLASS(klass)->m_tbl, clone_method,
+ (st_data_t)clone->m_tbl);
+ rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
FL_SET(clone, FL_SINGLETON);
return (VALUE)clone;
}
@@ -121,6 +143,30 @@ rb_singleton_class_attached(klass, obj)
}
VALUE
+rb_make_metaclass(obj, super)
+ VALUE obj, super;
+{
+ VALUE klass = rb_class_boot(super);
+ FL_SET(klass, FL_SINGLETON);
+ RBASIC(obj)->klass = klass;
+ rb_singleton_class_attached(klass, obj);
+ if (BUILTIN_TYPE(obj) == T_CLASS && FL_TEST(obj, FL_SINGLETON)) {
+ RBASIC(klass)->klass = klass;
+ RCLASS(klass)->super = RBASIC(rb_class_real(RCLASS(obj)->super))->klass;
+ }
+ else {
+ VALUE metasuper = RBASIC(rb_class_real(super))->klass;
+
+ /* metaclass of a superclass may be NULL at boot time */
+ if (metasuper) {
+ RBASIC(klass)->klass = metasuper;
+ }
+ }
+
+ return klass;
+}
+
+VALUE
rb_define_class_id(id, super)
ID id;
VALUE super;
@@ -129,15 +175,32 @@ rb_define_class_id(id, super)
if (!super) super = rb_cObject;
klass = rb_class_new(super);
- rb_name_class(klass, id);
- /* make metaclass */
- RBASIC(klass)->klass = rb_singleton_class_new(RBASIC(super)->klass);
- rb_singleton_class_attached(RBASIC(klass)->klass, klass);
- rb_funcall(super, rb_intern("inherited"), 1, klass);
+ rb_make_metaclass(klass, RBASIC(super)->klass);
return klass;
}
+void
+rb_check_inheritable(super)
+ VALUE super;
+{
+ if (TYPE(super) != T_CLASS) {
+ rb_raise(rb_eTypeError, "superclass must be a Class (%s given)",
+ rb_obj_classname(super));
+ }
+ if (RBASIC(super)->flags & FL_SINGLETON) {
+ rb_raise(rb_eTypeError, "can't make subclass of virtual class");
+ }
+}
+
+VALUE
+rb_class_inherited(super, klass)
+ VALUE super, klass;
+{
+ if (!super) super = rb_cObject;
+ return rb_funcall(super, rb_intern("inherited"), 1, klass);
+}
+
VALUE
rb_define_class(name, super)
const char *name;
@@ -147,9 +210,24 @@ rb_define_class(name, super)
ID id;
id = rb_intern(name);
+ if (rb_const_defined(rb_cObject, id)) {
+ klass = rb_const_get(rb_cObject, id);
+ if (TYPE(klass) != T_CLASS) {
+ rb_raise(rb_eTypeError, "%s is not a class", name);
+ }
+ if (rb_class_real(RCLASS(klass)->super) != super) {
+ rb_name_error(id, "%s is already defined", name);
+ }
+ return klass;
+ }
+ if (!super) {
+ rb_warn("no super class for `%s', Object assumed", name);
+ }
klass = rb_define_class_id(id, super);
-
st_add_direct(rb_class_tbl, id, klass);
+ rb_name_class(klass, id);
+ rb_const_set(rb_cObject, id, klass);
+ rb_class_inherited(super, klass);
return klass;
}
@@ -164,9 +242,24 @@ rb_define_class_under(outer, name, super)
ID id;
id = rb_intern(name);
+ if (rb_const_defined_at(outer, id)) {
+ klass = rb_const_get_at(outer, id);
+ if (TYPE(klass) != T_CLASS) {
+ rb_raise(rb_eTypeError, "%s is not a class", name);
+ }
+ if (rb_class_real(RCLASS(klass)->super) != super) {
+ rb_name_error(id, "%s is already defined", name);
+ }
+ return klass;
+ }
+ if (!super) {
+ rb_warn("no super class for `%s::%s', Object assumed",
+ rb_class2name(outer), name);
+ }
klass = rb_define_class_id(id, super);
- rb_const_set(outer, id, klass);
rb_set_class_path(klass, outer, name);
+ rb_const_set(outer, id, klass);
+ rb_class_inherited(super, klass);
return klass;
}
@@ -205,8 +298,15 @@ rb_define_module(name)
ID id;
id = rb_intern(name);
+ if (rb_const_defined(rb_cObject, id)) {
+ module = rb_const_get(rb_cObject, id);
+ if (TYPE(module) == T_MODULE)
+ return module;
+ rb_raise(rb_eTypeError, "%s is not a module", rb_obj_classname(module));
+ }
module = rb_define_module_id(id);
st_add_direct(rb_class_tbl, id, module);
+ rb_const_set(rb_cObject, id, module);
return module;
}
@@ -220,6 +320,13 @@ rb_define_module_under(outer, name)
ID id;
id = rb_intern(name);
+ if (rb_const_defined_at(outer, id)) {
+ module = rb_const_get_at(outer, id);
+ if (TYPE(module) == T_MODULE)
+ return module;
+ rb_raise(rb_eTypeError, "%s::%s is not a module",
+ rb_class2name(outer), rb_obj_classname(module));
+ }
module = rb_define_module_id(id);
rb_const_set(outer, id, module);
rb_set_class_path(module, outer, name);
@@ -234,6 +341,9 @@ include_class_new(module, super)
NEWOBJ(klass, struct RClass);
OBJSETUP(klass, rb_cClass, T_ICLASS);
+ if (BUILTIN_TYPE(module) == T_ICLASS) {
+ module = RBASIC(module)->klass;
+ }
if (!RCLASS(module)->iv_tbl) {
RCLASS(module)->iv_tbl = st_init_numtable();
}
@@ -246,6 +356,8 @@ include_class_new(module, super)
else {
RBASIC(klass)->klass = module;
}
+ OBJ_INFECT(klass, module);
+ OBJ_INFECT(klass, super);
return (VALUE)klass;
}
@@ -254,45 +366,69 @@ void
rb_include_module(klass, module)
VALUE klass, module;
{
- VALUE p;
+ VALUE p, c;
int changed = 0;
rb_frozen_class_p(klass);
if (!OBJ_TAINTED(klass)) {
rb_secure(4);
}
+
if (NIL_P(module)) return;
if (klass == module) return;
- switch (TYPE(module)) {
- case T_MODULE:
- case T_CLASS:
- case T_ICLASS:
- break;
- default:
+ if (TYPE(module) != T_MODULE) {
Check_Type(module, T_MODULE);
}
+ OBJ_INFECT(klass, module);
+ c = klass;
while (module) {
+ int superclass_seen = Qfalse;
+
+ if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl)
+ rb_raise(rb_eArgError, "cyclic include detected");
/* ignore if the module included already in superclasses */
for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) {
- if (BUILTIN_TYPE(p) == T_ICLASS &&
- RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
- if (RCLASS(module)->super) {
- rb_include_module(p, RCLASS(module)->super);
+ switch (BUILTIN_TYPE(p)) {
+ case T_ICLASS:
+ if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
+ if (!superclass_seen) {
+ c = p; /* move insertion point */
+ }
+ goto skip;
}
- if (changed) rb_clear_cache();
- return;
+ break;
+ case T_CLASS:
+ superclass_seen = Qtrue;
+ break;
}
}
- RCLASS(klass)->super = include_class_new(module, RCLASS(klass)->super);
- klass = RCLASS(klass)->super;
- module = RCLASS(module)->super;
+ c = RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
changed = 1;
+ skip:
+ module = RCLASS(module)->super;
}
if (changed) rb_clear_cache();
}
+/*
+ * call-seq:
+ * mod.included_modules -> array
+ *
+ * Returns the list of modules included in <i>mod</i>.
+ *
+ * module Mixin
+ * end
+ *
+ * module Outer
+ * include Mixin
+ * end
+ *
+ * Mixin.included_modules #=> []
+ * Outer.included_modules #=> [Mixin]
+ */
+
VALUE
rb_mod_included_modules(mod)
VALUE mod;
@@ -308,13 +444,63 @@ rb_mod_included_modules(mod)
return ary;
}
+/*
+ * call-seq:
+ * mod.include?(module) => true or false
+ *
+ * Returns <code>true</code> if <i>module</i> is included in
+ * <i>mod</i> or one of <i>mod</i>'s ancestors.
+ *
+ * module A
+ * end
+ * class B
+ * include A
+ * end
+ * class C < B
+ * end
+ * B.include?(A) #=> true
+ * C.include?(A) #=> true
+ * A.include?(A) #=> false
+ */
+
VALUE
-rb_mod_ancestors(mod)
+rb_mod_include_p(mod, mod2)
VALUE mod;
+ VALUE mod2;
{
- VALUE ary = rb_ary_new();
VALUE p;
+ Check_Type(mod2, T_MODULE);
+ for (p = RCLASS(mod)->super; p; p = RCLASS(p)->super) {
+ if (BUILTIN_TYPE(p) == T_ICLASS) {
+ if (RBASIC(p)->klass == mod2) return Qtrue;
+ }
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * mod.ancestors -> array
+ *
+ * Returns a list of modules included in <i>mod</i> (including
+ * <i>mod</i> itself).
+ *
+ * module Mod
+ * include Math
+ * include Comparable
+ * end
+ *
+ * Mod.ancestors #=> [Mod, Comparable, Math]
+ * Math.ancestors #=> [Math]
+ */
+
+VALUE
+rb_mod_ancestors(mod)
+ VALUE mod;
+{
+ VALUE p, ary = rb_ary_new();
+
for (p = mod; p; p = RCLASS(p)->super) {
if (FL_TEST(p, FL_SINGLETON))
continue;
@@ -328,163 +514,278 @@ rb_mod_ancestors(mod)
return ary;
}
+#define VISI(x) ((x)&NOEX_MASK)
+#define VISI_CHECK(x,f) (VISI(x) == (f))
+
static int
-ins_methods_i(key, body, ary)
- ID key;
- NODE *body;
+ins_methods_push(name, type, ary, visi)
+ ID name;
+ long type;
VALUE ary;
+ long visi;
{
- if ((body->nd_noex&(NOEX_PRIVATE|NOEX_PROTECTED)) == 0) {
- VALUE name = rb_str_new2(rb_id2name(key));
-
- if (!rb_ary_includes(ary, name)) {
- if (!body->nd_body) {
- rb_ary_push(ary, Qnil);
- }
- rb_ary_push(ary, name);
- }
+ if (type == -1) return ST_CONTINUE;
+ switch (visi) {
+ case NOEX_PRIVATE:
+ case NOEX_PROTECTED:
+ case NOEX_PUBLIC:
+ visi = (type == visi);
+ break;
+ default:
+ visi = (type != NOEX_PRIVATE);
+ break;
}
- else if (body->nd_body && nd_type(body->nd_body) == NODE_ZSUPER) {
- rb_ary_push(ary, Qnil);
- rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
+ if (visi) {
+ rb_ary_push(ary, rb_str_new2(rb_id2name(name)));
}
return ST_CONTINUE;
}
static int
-ins_methods_prot_i(key, body, ary)
- ID key;
- NODE *body;
+ins_methods_i(name, type, ary)
+ ID name;
+ long type;
VALUE ary;
{
- if (!body->nd_body) {
- rb_ary_push(ary, Qnil);
- rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
- }
- else if (body->nd_noex & NOEX_PROTECTED) {
- VALUE name = rb_str_new2(rb_id2name(key));
+ return ins_methods_push(name, type, ary, -1); /* everything but private */
+}
- if (!rb_ary_includes(ary, name)) {
- rb_ary_push(ary, name);
- }
- }
- else if (nd_type(body->nd_body) == NODE_ZSUPER) {
- rb_ary_push(ary, Qnil);
- rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
- }
- return ST_CONTINUE;
+static int
+ins_methods_prot_i(name, type, ary)
+ ID name;
+ long type;
+ VALUE ary;
+{
+ return ins_methods_push(name, type, ary, NOEX_PROTECTED);
}
static int
-ins_methods_priv_i(key, body, ary)
+ins_methods_priv_i(name, type, ary)
+ ID name;
+ long type;
+ VALUE ary;
+{
+ return ins_methods_push(name, type, ary, NOEX_PRIVATE);
+}
+
+static int
+ins_methods_pub_i(name, type, ary)
+ ID name;
+ long type;
+ VALUE ary;
+{
+ return ins_methods_push(name, type, ary, NOEX_PUBLIC);
+}
+
+static int
+method_entry(key, body, list)
ID key;
NODE *body;
- VALUE ary;
+ st_table *list;
{
- if (!body->nd_body) {
- rb_ary_push(ary, Qnil);
- rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
- }
- else if (body->nd_noex & NOEX_PRIVATE) {
- VALUE name = rb_str_new2(rb_id2name(key));
+ long type;
- if (!rb_ary_includes(ary, name)) {
- rb_ary_push(ary, name);
- }
- }
- else if (nd_type(body->nd_body) == NODE_ZSUPER) {
- rb_ary_push(ary, Qnil);
- rb_ary_push(ary, rb_str_new2(rb_id2name(key)));
+ if (key == ID_ALLOCATOR) return ST_CONTINUE;
+ if (!st_lookup(list, key, 0)) {
+ if (!body->nd_body) type = -1; /* none */
+ else type = VISI(body->nd_noex);
+ st_add_direct(list, key, type);
}
return ST_CONTINUE;
}
static VALUE
-method_list(mod, option, func)
+class_instance_method_list(argc, argv, mod, func)
+ int argc;
+ VALUE *argv;
VALUE mod;
- int option;
- int (*func)();
+ int (*func) _((ID, long, VALUE));
{
VALUE ary;
- VALUE klass;
- VALUE *p, *q, *pend;
+ int recur;
+ st_table *list;
- ary = rb_ary_new();
- for (klass = mod; klass; klass = RCLASS(klass)->super) {
- st_foreach(RCLASS(klass)->m_tbl, func, ary);
- if (!option) break;
- }
- p = q = RARRAY(ary)->ptr; pend = p + RARRAY(ary)->len;
- while (p < pend) {
- if (*p == Qnil) {
- p+=2;
- continue;
- }
- *q++ = *p++;
+ if (argc == 0) {
+ recur = Qtrue;
}
- RARRAY(ary)->len = q - RARRAY(ary)->ptr;
+ else {
+ VALUE r;
+ rb_scan_args(argc, argv, "01", &r);
+ recur = RTEST(r);
+ }
+
+ list = st_init_numtable();
+ for (; mod; mod = RCLASS(mod)->super) {
+ st_foreach(RCLASS(mod)->m_tbl, method_entry, (st_data_t)list);
+ if (BUILTIN_TYPE(mod) == T_ICLASS) continue;
+ if (FL_TEST(mod, FL_SINGLETON)) continue;
+ if (!recur) break;
+ }
+ ary = rb_ary_new();
+ st_foreach(list, func, ary);
+ st_free_table(list);
+
return ary;
}
+/*
+ * call-seq:
+ * mod.instance_methods(include_super=true) => array
+ *
+ * Returns an array containing the names of public instance methods in
+ * the receiver. For a module, these are the public methods; for a
+ * class, they are the instance (not singleton) methods. With no
+ * argument, or with an argument that is <code>false</code>, the
+ * instance methods in <i>mod</i> are returned, otherwise the methods
+ * in <i>mod</i> and <i>mod</i>'s superclasses are returned.
+ *
+ * module A
+ * def method1() end
+ * end
+ * class B
+ * def method2() end
+ * end
+ * class C < B
+ * def method3() end
+ * end
+ *
+ * A.instance_methods #=> ["method1"]
+ * B.instance_methods(false) #=> ["method2"]
+ * C.instance_methods(false) #=> ["method3"]
+ * C.instance_methods(true).length #=> 43
+ */
+
VALUE
rb_class_instance_methods(argc, argv, mod)
int argc;
VALUE *argv;
VALUE mod;
{
- VALUE option;
-
- rb_scan_args(argc, argv, "01", &option);
- return method_list(mod, RTEST(option), ins_methods_i);
+ return class_instance_method_list(argc, argv, mod, ins_methods_i);
}
+/*
+ * call-seq:
+ * mod.protected_instance_methods(include_super=true) => array
+ *
+ * Returns a list of the protected instance methods defined in
+ * <i>mod</i>. If the optional parameter is not <code>false</code>, the
+ * methods of any ancestors are included.
+ */
+
VALUE
rb_class_protected_instance_methods(argc, argv, mod)
int argc;
VALUE *argv;
VALUE mod;
{
- VALUE option;
-
- rb_scan_args(argc, argv, "01", &option);
- return method_list(mod, RTEST(option), ins_methods_prot_i);
+ return class_instance_method_list(argc, argv, mod, ins_methods_prot_i);
}
+/*
+ * call-seq:
+ * mod.private_instance_methods(include_super=true) => array
+ *
+ * Returns a list of the private instance methods defined in
+ * <i>mod</i>. If the optional parameter is not <code>false</code>, the
+ * methods of any ancestors are included.
+ *
+ * module Mod
+ * def method1() end
+ * private :method1
+ * def method2() end
+ * end
+ * Mod.instance_methods #=> ["method2"]
+ * Mod.private_instance_methods #=> ["method1"]
+ */
+
VALUE
rb_class_private_instance_methods(argc, argv, mod)
int argc;
VALUE *argv;
VALUE mod;
{
- VALUE option;
+ return class_instance_method_list(argc, argv, mod, ins_methods_priv_i);
+}
+
+/*
+ * call-seq:
+ * mod.public_instance_methods(include_super=true) => array
+ *
+ * Returns a list of the public instance methods defined in <i>mod</i>.
+ * If the optional parameter is not <code>false</code>, the methods of
+ * any ancestors are included.
+ */
- rb_scan_args(argc, argv, "01", &option);
- return method_list(mod, RTEST(option), ins_methods_priv_i);
+VALUE
+rb_class_public_instance_methods(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
+{
+ return class_instance_method_list(argc, argv, mod, ins_methods_pub_i);
}
+/*
+ * call-seq:
+ * obj.singleton_methods(all=true) => array
+ *
+ * Returns an array of the names of singleton methods for <i>obj</i>.
+ * If the optional <i>all</i> parameter is true, the list will include
+ * methods in modules included in <i>obj</i>.
+ *
+ * module Other
+ * def three() end
+ * end
+ *
+ * class Single
+ * def Single.four() end
+ * end
+ *
+ * a = Single.new
+ *
+ * def a.one()
+ * end
+ *
+ * class << a
+ * include Other
+ * def two()
+ * end
+ * end
+ *
+ * Single.singleton_methods #=> ["four"]
+ * a.singleton_methods(false) #=> ["two", "one"]
+ * a.singleton_methods #=> ["two", "one", "three"]
+ */
+
VALUE
-rb_obj_singleton_methods(obj)
+rb_obj_singleton_methods(argc, argv, obj)
+ int argc;
+ VALUE *argv;
VALUE obj;
{
- VALUE ary;
- VALUE klass;
- VALUE *p, *q, *pend;
+ VALUE recur, ary, klass;
+ st_table *list;
- ary = rb_ary_new();
+ rb_scan_args(argc, argv, "01", &recur);
+ if (argc == 0) {
+ recur = Qtrue;
+ }
klass = CLASS_OF(obj);
- while (klass && FL_TEST(klass, FL_SINGLETON)) {
- st_foreach(RCLASS(klass)->m_tbl, ins_methods_i, ary);
+ list = st_init_numtable();
+ if (klass && FL_TEST(klass, FL_SINGLETON)) {
+ st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
klass = RCLASS(klass)->super;
}
- p = q = RARRAY(ary)->ptr; pend = p + RARRAY(ary)->len;
- while (p < pend) {
- if (*p == Qnil) {
- p+=2;
- continue;
+ if (RTEST(recur)) {
+ while (klass && (FL_TEST(klass, FL_SINGLETON) || TYPE(klass) == T_ICLASS)) {
+ st_foreach(RCLASS(klass)->m_tbl, method_entry, (st_data_t)list);
+ klass = RCLASS(klass)->super;
}
- *q++ = *p++;
}
- RARRAY(ary)->len = q - RARRAY(ary)->ptr;
+ ary = rb_ary_new();
+ st_foreach(list, ins_methods_i, ary);
+ st_free_table(list);
return ary;
}
@@ -496,7 +797,7 @@ rb_define_method_id(klass, name, func, argc)
VALUE (*func)();
int argc;
{
- rb_add_method(klass, name, NEW_CFUNC(func,argc), NOEX_PUBLIC|NOEX_CFUNC);
+ rb_add_method(klass, name, NEW_CFUNC(func,argc), NOEX_PUBLIC);
}
void
@@ -507,10 +808,10 @@ rb_define_method(klass, name, func, argc)
int argc;
{
ID id = rb_intern(name);
+ int ex = NOEX_PUBLIC;
+
- rb_add_method(klass, id, NEW_CFUNC(func, argc),
- ((name[0] == 'i' && id == rb_intern("initialize"))?
- NOEX_PRIVATE:NOEX_PUBLIC)|NOEX_CFUNC);
+ rb_add_method(klass, id, NEW_CFUNC(func, argc), ex);
}
void
@@ -520,8 +821,7 @@ rb_define_protected_method(klass, name, func, argc)
VALUE (*func)();
int argc;
{
- rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc),
- NOEX_PROTECTED|NOEX_CFUNC);
+ rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PROTECTED);
}
void
@@ -531,8 +831,7 @@ rb_define_private_method(klass, name, func, argc)
VALUE (*func)();
int argc;
{
- rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc),
- NOEX_PRIVATE|NOEX_CFUNC);
+ rb_add_method(klass, rb_intern(name), NEW_CFUNC(func, argc), NOEX_PRIVATE);
}
void
@@ -543,13 +842,11 @@ rb_undef_method(klass, name)
rb_add_method(klass, rb_intern(name), 0, NOEX_UNDEF);
}
-#define SPECIAL_SINGLETON(x,c) if (obj == (x)) {\
- if (!FL_TEST(c, FL_SINGLETON)) {\
- c = rb_singleton_class_new(c);\
- rb_singleton_class_attached(c,obj);\
+#define SPECIAL_SINGLETON(x,c) do {\
+ if (obj == (x)) {\
+ return c;\
}\
- return c;\
-}
+} while (0)
VALUE
rb_singleton_class(obj)
@@ -564,17 +861,16 @@ rb_singleton_class(obj)
SPECIAL_SINGLETON(Qnil, rb_cNilClass);
SPECIAL_SINGLETON(Qfalse, rb_cFalseClass);
SPECIAL_SINGLETON(Qtrue, rb_cTrueClass);
- rb_bug("unknown immediate %d", obj);
+ rb_bug("unknown immediate %ld", obj);
}
DEFER_INTS;
- if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON)) {
+ if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) &&
+ rb_iv_get(RBASIC(obj)->klass, "__attached__") == obj) {
klass = RBASIC(obj)->klass;
}
else {
- klass = rb_singleton_class_new(RBASIC(obj)->klass);
- RBASIC(obj)->klass = klass;
- rb_singleton_class_attached(klass, obj);
+ klass = rb_make_metaclass(obj, RBASIC(obj)->klass);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(klass);
@@ -645,11 +941,11 @@ rb_define_attr(klass, name, read, write)
int
#ifdef HAVE_STDARG_PROTOTYPES
-rb_scan_args(int argc, VALUE *argv, const char *fmt, ...)
+rb_scan_args(int argc, const VALUE *argv, const char *fmt, ...)
#else
rb_scan_args(argc, argv, fmt, va_alist)
int argc;
- VALUE *argv;
+ const VALUE *argv;
const char *fmt;
va_dcl
#endif
@@ -666,7 +962,7 @@ 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 number of arguments (%d for %d)", argc, n);
for (i=0; i<n; i++) {
var = va_arg(vargs, VALUE*);
if (var) *var = argv[i];
@@ -707,7 +1003,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
if (*p == '&') {
var = va_arg(vargs, VALUE*);
if (rb_block_given_p()) {
- *var = rb_f_lambda();
+ *var = rb_block_proc();
}
else {
*var = Qnil;
@@ -721,7 +1017,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
}
if (argc > i) {
- rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, i);
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, i);
}
return argc;
diff --git a/compar.c b/compar.c
index 3cebc30a80..1488b2c65d 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-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
@@ -16,23 +16,68 @@ VALUE rb_mComparable;
static ID cmp;
+int
+rb_cmpint(val, a, b)
+ VALUE val, a, b;
+{
+ if (NIL_P(val)) {
+ rb_cmperr(a, b);
+ }
+ if (FIXNUM_P(val)) return FIX2INT(val);
+ if (TYPE(val) == T_BIGNUM) {
+ if (RBIGNUM(val)->sign) return 1;
+ return -1;
+ }
+ if (RTEST(rb_funcall(val, '>', 1, INT2FIX(0)))) return 1;
+ if (RTEST(rb_funcall(val, '<', 1, INT2FIX(0)))) return -1;
+ return 0;
+}
+
+void
+rb_cmperr(x, y)
+ VALUE x, y;
+{
+ const char *classname;
+
+ if (SPECIAL_CONST_P(y)) {
+ y = rb_inspect(y);
+ classname = StringValuePtr(y);
+ }
+ else {
+ classname = rb_obj_classname(y);
+ }
+ rb_raise(rb_eArgError, "comparison of %s with %s failed",
+ rb_obj_classname(x), classname);
+}
+
+#define cmperr() (rb_cmperr(x, y), Qnil)
+
static VALUE
cmp_eq(a)
VALUE *a;
{
VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
- int t = NUM2INT(c);
- if (t == 0) return Qtrue;
+ if (NIL_P(c)) return Qnil;
+ if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;
return Qfalse;
}
static VALUE
cmp_failed()
{
- return Qfalse;
+ return Qnil;
}
+/*
+ * call-seq:
+ * obj == other => true or false
+ *
+ * Compares two objects based on the receiver's <code><=></code>
+ * method, returning true if it returns 0. Also returns true if
+ * _obj_ and _other_ are the same object.
+ */
+
static VALUE
cmp_equal(x, y)
VALUE x, y;
@@ -42,68 +87,147 @@ cmp_equal(x, y)
if (x == y) return Qtrue;
a[0] = x; a[1] = y;
- return rb_rescue2(cmp_eq, (VALUE)a, cmp_failed, 0,
- rb_eStandardError, rb_eNameError, 0);
+ return rb_rescue(cmp_eq, (VALUE)a, cmp_failed, 0);
}
+/*
+ * call-seq:
+ * obj > other => true or false
+ *
+ * Compares two objects based on the receiver's <code><=></code>
+ * method, returning true if it returns 1.
+ */
+
static VALUE
cmp_gt(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t > 0) return Qtrue;
+ if (NIL_P(c)) return cmperr();
+ if (rb_cmpint(c, x, y) > 0) return Qtrue;
return Qfalse;
}
+/*
+ * call-seq:
+ * obj >= other => true or false
+ *
+ * Compares two objects based on the receiver's <code><=></code>
+ * method, returning true if it returns 0 or 1.
+ */
+
static VALUE
cmp_ge(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t >= 0) return Qtrue;
+ if (NIL_P(c)) return cmperr();
+ if (rb_cmpint(c, x, y) >= 0) return Qtrue;
return Qfalse;
}
+/*
+ * call-seq:
+ * obj < other => true or false
+ *
+ * Compares two objects based on the receiver's <code><=></code>
+ * method, returning true if it returns -1.
+ */
+
static VALUE
cmp_lt(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t < 0) return Qtrue;
+ if (NIL_P(c)) return cmperr();
+ if (rb_cmpint(c, x, y) < 0) return Qtrue;
return Qfalse;
}
+
+/*
+ * call-seq:
+ * obj <= other => true or false
+ *
+ * Compares two objects based on the receiver's <code><=></code>
+ * method, returning true if it returns -1 or 0.
+ */
+
static VALUE
cmp_le(x, y)
VALUE x, y;
{
VALUE c = rb_funcall(x, cmp, 1, y);
- int t = NUM2INT(c);
- if (t <= 0) return Qtrue;
+ if (NIL_P(c)) return cmperr();
+ if (rb_cmpint(c, x, y) <= 0) return Qtrue;
return Qfalse;
}
+/*
+ * call-seq:
+ * obj.between?(min, max) => true or false
+ *
+ * Returns <code>false</code> if <i>obj</i> <code><=></code>
+ * <i>min</i> is less than zero or if <i>anObject</i> <code><=></code>
+ * <i>max</i> is greater than zero, <code>true</code> otherwise.
+ *
+ * 3.between?(1, 5) #=> true
+ * 6.between?(1, 5) #=> false
+ * 'cat'.between?('ant', 'dog') #=> true
+ * 'gnu'.between?('ant', 'dog') #=> false
+ *
+ */
+
static VALUE
cmp_between(x, min, max)
VALUE x, min, max;
{
- VALUE c = rb_funcall(x, cmp, 1, min);
- long t = NUM2LONG(c);
- if (t < 0) return Qfalse;
-
- c = rb_funcall(x, cmp, 1, max);
- t = NUM2LONG(c);
- if (t > 0) return Qfalse;
+ if (RTEST(cmp_lt(x, min))) return Qfalse;
+ if (RTEST(cmp_gt(x, max))) return Qfalse;
return Qtrue;
}
+/*
+ * The <code>Comparable</code> mixin is used by classes whose objects
+ * may be ordered. The class must define the <code><=></code> operator,
+ * which compares the receiver against another object, returning -1, 0,
+ * or +1 depending on whether the receiver is less than, equal to, or
+ * greater than the other object. <code>Comparable</code> uses
+ * <code><=></code> to implement the conventional comparison operators
+ * (<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,
+ * and <code>></code>) and the method <code>between?</code>.
+ *
+ * class SizeMatters
+ * include Comparable
+ * attr :str
+ * def <=>(anOther)
+ * str.size <=> anOther.str.size
+ * end
+ * def initialize(str)
+ * @str = str
+ * end
+ * def inspect
+ * @str
+ * end
+ * end
+ *
+ * s1 = SizeMatters.new("Z")
+ * s2 = SizeMatters.new("YY")
+ * s3 = SizeMatters.new("XXX")
+ * s4 = SizeMatters.new("WWWW")
+ * s5 = SizeMatters.new("VVVVV")
+ *
+ * s1 < s2 #=> true
+ * s4.between?(s1, s3) #=> false
+ * s4.between?(s3, s5) #=> true
+ * [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV]
+ *
+ */
+
void
Init_Comparable()
{
diff --git a/config.guess b/config.guess
index c55635bd7b..dd1688b7b5 100644
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
-# Free Software Foundation, Inc.
-#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2004-06-11'
+
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -22,113 +24,291 @@
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
-# Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
-# Please send patches to the Autoconf mailing list <autoconf@gnu.org>.
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
-# don't specify an explicit system type (host/target name).
-#
-# Only a few systems have been added to this list; please add others
-# (but try to keep the structure clean).
-#
+# don't specify an explicit build system type.
-# Use $HOST_CC if defined. $CC may point to a cross-compiler
-if test x"$CC_FOR_BUILD" = x; then
- if test x"$HOST_CC" != x; then
- CC_FOR_BUILD="$HOST_CC"
- else
- if test x"$CC" != x; then
- CC_FOR_BUILD="$CC"
- else
- CC_FOR_BUILD=cc
- fi
- fi
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
fi
-# Modified for Human68k by K.Okabe 1997.07.09
-# Last change: 1997.07.09
+trap 'exit 1' 1 2 15
-case "$KSH_VERSION" in
-*X6*)
- echo m68k-sharp-human
- exit 0 ;;
-*)
- ;;
-esac
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 8/24/94.)
+# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-dummy=dummy-$$
-trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
-
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- *:OS/2:*:*)
- echo "i386-pc-os2_emx"
- exit 0;;
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
+ amd64:OpenBSD:*:*)
+ echo x86_64-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ cats:OpenBSD:*:*)
+ echo arm-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ luna88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvmeppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mipseb-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:MirBSD:*:*)
+ echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit 0 ;;
alpha:OSF1:*:*)
- if test $UNAME_RELEASE = "V4.0"; then
+ case $UNAME_RELEASE in
+ *4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- fi
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- cat <<EOF >$dummy.s
- .globl main
- .ent main
-main:
- .frame \$30,0,\$26,0
- .prologue 0
- .long 0x47e03d80 # implver $0
- lda \$2,259
- .long 0x47e20c21 # amask $2,$1
- srl \$1,8,\$2
- sll \$2,2,\$2
- sll \$0,3,\$0
- addl \$1,\$0,\$0
- addl \$2,\$0,\$0
- ret \$31,(\$26),1
- .end main
-EOF
- $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
- if test "$?" = 0 ; then
- ./$dummy
- case "$?" in
- 7)
- UNAME_MACHINE="alpha"
- ;;
- 15)
- UNAME_MACHINE="alphaev5"
- ;;
- 14)
- UNAME_MACHINE="alphaev56"
- ;;
- 10)
- UNAME_MACHINE="alphapca56"
- ;;
- 16)
- UNAME_MACHINE="alphaev6"
- ;;
- esac
- fi
- rm -f $dummy.s $dummy
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha*:OpenVMS:*:*)
+ echo alpha-hp-vms
exit 0 ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
@@ -140,42 +320,24 @@ EOF
echo alpha-dec-winnt3.5
exit 0 ;;
Amiga*:UNIX_System_V:4.0:*)
- echo m68k-cbm-sysv4
+ echo m68k-unknown-sysv4
exit 0;;
- amiga:NetBSD:*:*)
- echo m68k-cbm-netbsd${UNAME_RELEASE}
- exit 0 ;;
- amiga:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit 0 ;;
- arc64:OpenBSD:*:*)
- echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
exit 0 ;;
- arc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- hkmips:OpenBSD:*:*)
- echo mips-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- pmax:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- sgi:OpenBSD:*:*)
- echo mips-unknown-openbsd${UNAME_RELEASE}
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
exit 0 ;;
- wgrisc:OpenBSD:*:*)
- echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
- arm32:NetBSD:*:*)
- echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- exit 0 ;;
- SR2?01:HI-UX/MPP:*:*)
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
@@ -189,6 +351,13 @@ EOF
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit 0 ;;
+ DRS?6000:UNIX_SV:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7 && exit 0 ;;
+ esac ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -217,7 +386,7 @@ EOF
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
@@ -231,15 +400,9 @@ EOF
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
- atari*:NetBSD:*:*)
- echo m68k-atari-netbsd${UNAME_RELEASE}
- exit 0 ;;
- atari*:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
+ # "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
@@ -263,30 +426,12 @@ EOF
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;;
- sun3*:NetBSD:*:*)
- echo m68k-sun-netbsd${UNAME_RELEASE}
- exit 0 ;;
- sun3*:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:NetBSD:*:*)
- echo m68k-apple-netbsd${UNAME_RELEASE}
- exit 0 ;;
- mac68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme68k:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
- exit 0 ;;
- mvme88k:OpenBSD:*:*)
- echo m88k-unknown-openbsd${UNAME_RELEASE}
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
- macppc:NetBSD:*:*)
- echo powerpc-apple-netbsd${UNAME_RELEASE}
- exit 0 ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit 0 ;;
@@ -300,8 +445,10 @@ EOF
echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
@@ -320,12 +467,20 @@ EOF
exit (-1);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy \
- && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
- && rm $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ $CC_FOR_BUILD -o $dummy $dummy.c \
+ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && exit 0
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit 0 ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
@@ -341,15 +496,18 @@ EOF
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
- -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
echo m88k-dg-dgux${UNAME_RELEASE}
- else
+ else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
fi
- else echo i586-dg-dgux${UNAME_RELEASE}
- fi
exit 0 ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
@@ -370,11 +528,20 @@ EOF
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i?86:AIX:*:*)
+ i*86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <sys/systemcfg.h>
@@ -386,8 +553,7 @@ EOF
exit(0);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
@@ -395,9 +561,9 @@ EOF
echo rs6000-ibm-aix3.2
fi
exit 0 ;;
- *:AIX:*:4)
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
- if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
@@ -405,7 +571,7 @@ EOF
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
- IBM_REV=4.${UNAME_RELEASE}
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit 0 ;;
@@ -415,7 +581,7 @@ EOF
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit 0 ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit 0 ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
@@ -431,11 +597,30 @@ EOF
echo m68k-hp-bsd4.4
exit 0 ;;
9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
- sed 's/^ //' << EOF >$dummy.c
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
@@ -466,13 +651,29 @@ EOF
exit (0);
}
EOF
- ($CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
- rm -f $dummy.c $dummy
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
esac
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ # avoid double evaluation of $set_cc_for_build
+ test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit 0 ;;
3050*:HI-UX:*:*)
+ eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <unistd.h>
int
@@ -498,8 +699,7 @@ EOF
exit (0);
}
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
+ $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -508,7 +708,7 @@ EOF
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit 0 ;;
- *9??*:MPE/iX:*:*)
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit 0 ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
@@ -517,7 +717,7 @@ EOF
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
- i?86:OSF1:*:*)
+ i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
@@ -527,9 +727,6 @@ EOF
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
- hppa*:OpenBSD:*:*)
- echo hppa-unknown-openbsd
- exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
@@ -548,41 +745,39 @@ EOF
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit 0 ;;
- CRAY*X-MP:*:*:*)
- echo xmp-cray-unicos
- exit 0 ;;
CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE}
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE}
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3E:*:*:*)
- echo t3e-cray-unicosmk${UNAME_RELEASE}
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
- CRAY-2:*:*:*)
- echo cray2-cray-unicos
- exit 0 ;;
- F300:UNIX_System_V:*:*)
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ *:UNICOS/mp:*:*)
+ echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
- F301:UNIX_System_V:*:*)
- echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
- exit 0 ;;
- hp3[0-9][05]:NetBSD:*:*)
- echo m68k-hp-netbsd${UNAME_RELEASE}
- exit 0 ;;
- hp300:OpenBSD:*:*)
- echo m68k-unknown-openbsd${UNAME_RELEASE}
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
- i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
sparc*:BSD/OS:*:*)
@@ -592,22 +787,21 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
- if test -x /usr/bin/objformat; then
- if test "elf" = "`/usr/bin/objformat`"; then
- echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
- exit 0
- fi
- fi
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit 0 ;;
- *:NetBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- exit 0 ;;
- *:OpenBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- exit 0 ;;
- *:*:*BOW*:*)
- echo i386-pc-bow
+ # Determine whether the default compiler uses glibc.
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #if __GLIBC__ >= 2
+ LIBC=gnu
+ #else
+ LIBC=
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ # GNU/KFreeBSD systems have a "k" prefix to indicate we are using
+ # FreeBSD's kernel, but not the complete OS.
+ case ${LIBC} in gnu) kernel_only='k' ;; esac
+ echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -615,11 +809,20 @@ EOF
i*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit 0 ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit 0 ;;
+ x86:Interix*:[34]*)
+ echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+ exit 0 ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit 0 ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
- echo i386-pc-interix
+ echo i586-pc-interix
exit 0 ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
@@ -631,180 +834,178 @@ EOF
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
+ # the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
- *:Linux:*:*)
- # uname on the ARM produces all sorts of strangeness, and we need to
- # filter it out.
- case "$UNAME_MACHINE" in
- armv*) UNAME_MACHINE=$UNAME_MACHINE ;;
- arm* | sa110*) UNAME_MACHINE="arm" ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit 0 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit 0 ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit 0 ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+ ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit 0 ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit 0 ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit 0 ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
esac
-
+ exit 0 ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit 0 ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit 0 ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit 0 ;;
+ i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
- ld_help_string=`cd /; ld --help 2>&1`
- ld_supported_emulations=`echo $ld_help_string \
- | sed -ne '/supported emulations:/!d
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
- s/.*supported emulations: *//
+ s/.*supported targets: *//
s/ .*//
p'`
- case "$ld_supported_emulations" in
- i?86linux) echo "${UNAME_MACHINE}-pc-linux-aout" ; exit 0 ;;
- i?86coff) echo "${UNAME_MACHINE}-pc-linux-coff" ; exit 0 ;;
- sparclinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;;
- armlinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;;
- m68klinux) echo "${UNAME_MACHINE}-unknown-linux-aout" ; exit 0 ;;
- elf32ppc)
- # Determine Lib Version
- cat >$dummy.c <<EOF
-#include <features.h>
-#if defined(__GLIBC__)
-extern char __libc_version[];
-extern char __libc_release[];
-#endif
-main(argc, argv)
- int argc;
- char *argv[];
-{
-#if defined(__GLIBC__)
- printf("%s %s\n", __libc_version, __libc_release);
-#else
- printf("unkown\n");
-#endif
- return 0;
-}
-EOF
- LIBC=""
- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
- if test "$?" = 0 ; then
- ./$dummy | grep 1\.99 > /dev/null
- if test "$?" = 0 ; then
- LIBC="-libc1"
- fi
- fi
- rm -f $dummy.c $dummy
- echo powerpc-unknown-linux${LIBC} ; exit 0 ;;
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0 ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0 ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit 0 ;;
esac
-
- if test "${UNAME_MACHINE}" = "alpha" ; then
- sed 's/^ //' <<EOF >$dummy.s
- .globl main
- .ent main
- main:
- .frame \$30,0,\$26,0
- .prologue 0
- .long 0x47e03d80 # implver $0
- lda \$2,259
- .long 0x47e20c21 # amask $2,$1
- srl \$1,8,\$2
- sll \$2,2,\$2
- sll \$0,3,\$0
- addl \$1,\$0,\$0
- addl \$2,\$0,\$0
- ret \$31,(\$26),1
- .end main
-EOF
- LIBC=""
- $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
- if test "$?" = 0 ; then
- ./$dummy
- case "$?" in
- 7)
- UNAME_MACHINE="alpha"
- ;;
- 15)
- UNAME_MACHINE="alphaev5"
- ;;
- 14)
- UNAME_MACHINE="alphaev56"
- ;;
- 10)
- UNAME_MACHINE="alphapca56"
- ;;
- 16)
- UNAME_MACHINE="alphaev6"
- ;;
- esac
-
- objdump --private-headers $dummy | \
- grep ld.so.1 > /dev/null
- if test "$?" = 0 ; then
- LIBC="-libc1"
- fi
- fi
- rm -f $dummy.s $dummy
- echo ${UNAME_MACHINE}-unknown-linux${LIBC} ; exit 0
- elif test "${UNAME_MACHINE}" = "mips" ; then
- cat >$dummy.c <<EOF
-#ifdef __cplusplus
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __MIPSEB__
- printf ("%s-unknown-linux\n", argv[1]);
-#endif
-#ifdef __MIPSEL__
- printf ("%sel-unknown-linux\n", argv[1]);
-#endif
- return 0;
-}
-EOF
- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
- else
- # Either a pre-BFD a.out linker (linux-oldld)
- # or one that does not give us useful --help.
- # GCC wants to distinguish between linux-oldld and linux-aout.
- # If ld does not provide *any* "supported emulations:"
- # that means it is oldld.
- echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
- test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-oldld" && exit 0
-
- case "${UNAME_MACHINE}" in
- i?86)
- VENDOR=pc;
- ;;
- *)
- VENDOR=unknown;
- ;;
- esac
- # Determine whether the default compiler is a.out or elf
- cat >$dummy.c <<EOF
-#include <features.h>
-#ifdef __cplusplus
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __ELF__
-# ifdef __GLIBC__
-# if __GLIBC__ >= 2
- printf ("%s-${VENDOR}-linux\n", argv[1]);
-# else
- printf ("%s-${VENDOR}-linux-libc1\n", argv[1]);
-# endif
-# else
- printf ("%s-${VENDOR}-linux-libc1\n", argv[1]);
-# endif
-#else
- printf ("%s-${VENDOR}-linux-aout\n", argv[1]);
-#endif
- return 0;
-}
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #ifdef __INTEL_COMPILER
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
EOF
- $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
- rm -f $dummy.c $dummy
- fi ;;
-# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
-# are messed up and put the nodename in both sysname and nodename.
- i?86:DYNIX/ptx:4*:*)
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
+ test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
echo i386-sequent-sysv4
exit 0 ;;
- i?86:UNIX_SV:4.2MP:2.*)
+ i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
@@ -812,47 +1013,62 @@ EOF
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
- i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit 0 ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit 0 ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit 0 ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit 0 ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit 0 ;;
- i?86:*:5:7*)
- UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
- (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586
- (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686
- (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE}
+ i*86:*:5:[78]*)
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
exit 0 ;;
- i?86:*:3.2:*)
+ i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
- (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
- (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
- (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
- i?86:UnixWare:*:*)
- if /bin/uname -X 2>/dev/null >/dev/null ; then
- (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
- && UNAME_MACHINE=i586
- fi
- echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION}
- exit 0 ;;
pc:*:*:*)
+ # Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
@@ -874,9 +1090,15 @@ EOF
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
- M68*:*:R3V[567]*:*)
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit 0 ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit 0 ;;
+ M68*:*:R3V[5678]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
- 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -887,21 +1109,21 @@ EOF
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
- m68*:LynxOS:2.*:*)
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
- i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
- rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+ rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
@@ -919,8 +1141,8 @@ EOF
echo ns32k-sni-sysv
fi
exit 0 ;;
- PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit 0 ;;
*:UNIX_System_V:4*:FTX*)
@@ -932,22 +1154,23 @@ EOF
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit 0 ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
- news*:NEWS-OS:*:6*)
+ news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit 0 ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
- echo mips-nec-sysv`echo ${UNAME_RELEASE} | sed -n 's/\([.0-9]*\).*/\1/p'`
+ echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- DS/90*:*:*:V20*)
- echo sparc-fujitsu-uxpds
- exit 0 ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit 0 ;;
@@ -963,6 +1186,9 @@ EOF
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit 0 ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
@@ -970,13 +1196,76 @@ EOF
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:Darwin:*:*)
- echo `uname -p`-apple-darwin${UNAME_RELEASE}
+ case `uname -p` in
+ *86) UNAME_PROCESSOR=i686 ;;
+ powerpc) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit 0 ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit 0 ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit 0 ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit 0 ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit 0 ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit 0 ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit 0 ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit 0 ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit 0 ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+eval $set_cc_for_build
cat >$dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
@@ -1063,11 +1352,24 @@ main ()
#endif
#if defined (vax)
-#if !defined (ultrix)
- printf ("vax-dec-bsd\n"); exit (0);
-#else
- printf ("vax-dec-ultrix\n"); exit (0);
-#endif
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
#endif
#if defined (alliant) && defined (i860)
@@ -1078,8 +1380,7 @@ main ()
}
EOF
-$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
-rm -f $dummy.c $dummy
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
# Apollos put the system type in the environment.
@@ -1111,6 +1412,48 @@ then
esac
fi
-#echo '(Unable to guess system type)' 1>&2
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.sub b/config.sub
index 1000343616..506d3ab77f 100644
--- a/config.sub
+++ b/config.sub
@@ -1,6 +1,10 @@
#! /bin/sh
-# Configuration validation subroutine script, version 1.1.
-# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc.
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2004-06-11'
+
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
@@ -25,6 +29,9 @@
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
@@ -45,30 +52,74 @@
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
-if [ x$1 = x ]
-then
- echo Configuration name missing. 1>&2
- echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
- echo "or $0 ALIAS" 1>&2
- echo where ALIAS is a recognized configuration type. 1>&2
- exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
-# First pass through any local machine types.
-case $1 in
- *local*)
- echo $1
- exit 0
- ;;
- *)
- ;;
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- linux*)
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
+ kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -94,7 +145,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple)
+ -apple | -axis)
os=
basic_machine=$1
;;
@@ -105,9 +156,17 @@ case $os in
-scout)
;;
-wrs)
- os=vxworks
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
basic_machine=$1
;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
-hiux*)
os=-hiuxwe2
;;
@@ -156,61 +215,137 @@ case $os in
-psos*)
os=-psos
;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# 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 | hppa2.0w | hppa2.0n \
- | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
- | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
- | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
- | mips64orion | mips64orionel | mipstx39 | mipstx39el \
- | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
- | mips64vr5000 | miprs64vr5000el \
- | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
- | thumb | d10v)
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32r | m68000 | m68k | m88k | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | msp430 \
+ | ns16k | ns32k \
+ | openrisc | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+ | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xscale | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
+ os=-none
;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65)
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
- i[34567]86)
+ i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
- i[3456]86-TOWNS*)
- basic_machine=`echo $basic_machine | sed -e 's/-TOWNS.*/-TOWNS/'`
- ;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
- | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
- | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
- | xmp-* | ymp-* \
- | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
- | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
- | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
- | clipper-* | orion-* \
- | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
- | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
- | mipstx39-* | mipstx39el-* \
- | f301-* | armv*-* | t3e-* \
- | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
- | thumb-* | v850-* | d30v-* | tic30-* | c30-* )
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* \
+ | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32r-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | msp430-* \
+ | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+ | xtensa-* \
+ | ymp-* \
+ | z8k-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -242,19 +377,25 @@ case $basic_machine in
basic_machine=a29k-none
os=-bsd
;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
- basic_machine=m68k-cbm
+ basic_machine=m68k-unknown
;;
amigaos | amigados)
- basic_machine=m68k-cbm
+ basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
- basic_machine=m68k-cbm
+ basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
@@ -273,6 +414,10 @@ case $basic_machine in
basic_machine=ns32k-sequent
os=-dynix
;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
convex-c1)
basic_machine=c1-convex
os=-bsd
@@ -293,27 +438,30 @@ case $basic_machine in
basic_machine=c38-convex
os=-bsd
;;
- cray | ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- cray2)
- basic_machine=cray2-cray
- os=-unicos
- ;;
- [ctj]90-cray)
- basic_machine=c90-cray
+ cray | j90)
+ basic_machine=j90-cray
os=-unicos
;;
crds | unos)
basic_machine=m68k-crds
;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
@@ -355,6 +503,10 @@ case $basic_machine in
basic_machine=tron-gmicro
os=-sysv
;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
@@ -428,22 +580,21 @@ case $basic_machine in
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
- os=-mvs
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[34567]86v32)
+ i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
- i[34567]86v4*)
+ i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
- i[34567]86v)
+ i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
- i[34567]86sol2)
+ i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
@@ -455,14 +606,6 @@ case $basic_machine in
basic_machine=i386-unknown
os=-vsta
;;
- i386-go32 | go32)
- basic_machine=i386-unknown
- os=-go32
- ;;
- i386-mingw32 | mingw32)
- basic_machine=i386-unknown
- os=-mingw32
- ;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
@@ -488,35 +631,43 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
miniframe)
basic_machine=m68000-convergent
;;
- *mint | *MiNT)
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
- mipsel*-linux*)
- basic_machine=mipsel-unknown
- os=-linux
- ;;
- mips*-linux*)
- basic_machine=mips-unknown
- os=-linux
- ;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
msdos)
- basic_machine=i386-unknown
+ basic_machine=i386-pc
os=-msdos
;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
@@ -525,12 +676,8 @@ case $basic_machine in
basic_machine=i386-unknown
os=-netbsd
;;
- hpcmips*-*)
- basic_machine=hpcmips-unknown
- os=-netbsd
- ;;
netwinder)
- basic_machine=armv4l-corel
+ basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
@@ -578,13 +725,32 @@ case $basic_machine in
basic_machine=i960-intel
os=-mon960
;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
np1)
basic_machine=np1-gould
;;
+ nv1)
+ basic_machine=nv1-cray
+ os=-unicosmp
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
+ or32 | or32-*)
+ basic_machine=or32-unknown
+ os=-coff
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
@@ -607,45 +773,65 @@ case $basic_machine in
pbb)
basic_machine=m68k-tti
;;
- pc532 | pc532-*)
+ pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
- pentium | p5 | k5 | k6 | nexen)
+ pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
- pentiumpro | p6 | 6x86)
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc
;;
- pentiumii | pentium2)
+ pentium4)
basic_machine=i786-pc
;;
- pentium-* | p5-* | k5-* | k6-* | nexen-*)
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- pentiumpro-* | p6-* | 6x86-*)
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- pentiumii-* | pentium2-*)
+ pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
- power) basic_machine=rs6000-ibm
+ power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
- ;;
+ ;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
- ;;
+ ;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
ps2)
basic_machine=i386-ibm
;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@@ -656,10 +842,26 @@ case $basic_machine in
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
sequent)
basic_machine=i386-sequent
;;
@@ -667,7 +869,10 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
- sparclite-wrs)
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
@@ -725,23 +930,51 @@ case $basic_machine in
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
- basic_machine=t3e-cray
+ basic_machine=alphaev5-cray
os=-unicos
;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
tower | tower-32)
basic_machine=m68k-ncr
;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
udi29k)
basic_machine=a29k-amd
os=-udi
@@ -763,8 +996,8 @@ case $basic_machine in
os=-vms
;;
vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
+ basic_machine=f301-fujitsu
+ ;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
@@ -785,13 +1018,13 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
- xmp)
- basic_machine=xmp-cray
- os=-unicos
- ;;
- xps | xps100)
+ xps | xps100)
basic_machine=xps100-honeywell
;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
@@ -812,13 +1045,6 @@ case $basic_machine in
op60c)
basic_machine=hppa1.1-oki
;;
- mips)
- if [ x$os = x-linux ]; then
- basic_machine=mips-unknown
- else
- basic_machine=mips-mips
- fi
- ;;
romp)
basic_machine=romp-ibm
;;
@@ -828,16 +1054,26 @@ case $basic_machine in
vax)
basic_machine=vax-dec
;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
- sparc | sparcv9)
+ sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
- cydra)
+ cydra)
basic_machine=cydra-cydrome
;;
orion)
@@ -852,9 +1088,8 @@ case $basic_machine in
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
- c4x*)
- basic_machine=c4x-none
- os=-coff
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
@@ -908,29 +1143,63 @@ case $os in
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -rhapsody* | -openstep* | -oskit* \
- | -darwin*)
+ | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
- | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=-linux
+ ;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
-osfrose*)
os=-osfrose
;;
@@ -946,14 +1215,26 @@ case $os in
-acis*)
os=-aos
;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
-ns2 )
- os=-nextstep2
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
@@ -962,6 +1243,9 @@ case $os in
-sinix*)
os=-sysv4
;;
+ -tpf*)
+ os=-tpf
+ ;;
-triton*)
os=-sysv3
;;
@@ -989,16 +1273,14 @@ case $os in
-xenix)
os=-xenix
;;
- -mint* | -MiNT*)
- os=-mint
- ;;
- -uxpds)
- os=-uxpds
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
;;
- -human)
+ -aros*)
+ os=-aros
;;
- -beos)
- os=-beos
+ -kaos*)
+ os=-kaos
;;
-none)
;;
@@ -1025,13 +1307,20 @@ case $basic_machine in
*-acorn)
os=-riscix1.2
;;
- arm*-corel)
+ arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
- pdp11-*)
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
os=-none
;;
*-dec | vax-*)
@@ -1058,6 +1347,9 @@ case $basic_machine in
mips*-*)
os=-elf
;;
+ or32-*)
+ os=-coff
+ ;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
@@ -1121,25 +1413,25 @@ case $basic_machine in
*-next)
os=-nextstep3
;;
- *-gould)
+ *-gould)
os=-sysv
;;
- *-highlevel)
+ *-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
- *-sgi)
+ *-sgi)
os=-irix
;;
- *-siemens)
+ *-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
- f301-fujitsu)
+ f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
@@ -1199,13 +1491,19 @@ case $basic_machine in
-genix*)
vendor=ns
;;
- -mvs*)
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
- -vxsim* | -vxworks*)
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
@@ -1217,12 +1515,23 @@ case $basic_machine in
-mpw* | -macos*)
vendor=apple
;;
- -*mint | -*MiNT)
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
+ -vos*)
+ vendor=stratus
+ ;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure.in b/configure.in
index 094098861d..641954adfe 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,48 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(ruby.h)
+AC_INIT()
+
+AC_PREREQ(2.50)
+
+AC_DEFUN(RUBY_MINGW32,
+[case "$host_os" in
+cygwin*)
+AC_CACHE_CHECK(for mingw32 environment, rb_cv_mingw32,
+[AC_TRY_CPP([
+#ifndef __MINGW32__
+# error
+#endif
+], rb_cv_mingw32=yes,rb_cv_mingw32=no)
+rm -f conftest*])
+test "$rb_cv_mingw32" = yes && target_os="mingw32"
+ ;;
+esac])
+
+AC_DEFUN(RUBY_CPPOUTFILE,
+[AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
+[cppflags=$CPPFLAGS
+CPPFLAGS='-o conftest.i'
+AC_TRY_CPP([], rb_cv_cppoutfile=yes, rb_cv_cppoutfile=no)
+CPPFLAGS=$cppflags
+rm -f conftest*])
+if test "$rb_cv_cppoutfile" = yes; then
+ CPPOUTFILE='-o conftest.i'
+elif test "$rb_cv_cppoutfile" = no; then
+ CPPOUTFILE='> conftest.i'
+elif test -n "$rb_cv_cppoutfile"; then
+ CPPOUTFILE="$rb_cv_cppoutfile"
+fi
+AC_SUBST(CPPOUTFILE)])
+
+AC_DEFUN(RUBY_PROG_GNU_LD,
+[AC_CACHE_CHECK(whether the linker is GNU ld, rb_cv_prog_gnu_ld,
+[if `$CC $CFLAGS $CPPFLAGS $LDFLAGS --print-prog-name=ld 2>&1` -v 2>&1 | grep "GNU ld" > /dev/null; then
+ rb_cv_prog_gnu_ld=yes
+else
+ rb_cv_prog_gnu_ld=no
+fi
+])
+GNU_LD=$rb_cv_prog_gnu_ld
+AC_SUBST(GNU_LD)])
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]*"'`
@@ -9,70 +52,92 @@ AC_SUBST(MAJOR)
AC_SUBST(MINOR)
AC_SUBST(TEENY)
dnl checks for alternative programs
-AC_ARG_WITH(gcc, [--without-gcc never use gcc], [
+AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
case $withval in
- no) CC=cc
- without_gcc=yes;;
- yes) CC=gcc
- without_gcc=no;;
+ no) : ${CC=cc}
+ ;;
+ yes) : ${CC=gcc}
+ ;;
*) CC=$withval
- without_gcc=$withval;;
- esac], [without_gcc=no])
+ ;;
+ esac])
dnl If the user switches compilers, we can't believe the cache
if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
then
- AC_ERROR(cached CC is different -- throw away $cache_file
+ AC_MSG_ERROR(cached CC is different -- throw away $cache_file
(it is also a good idea to do 'make clean' before compiling))
fi
-AC_CANONICAL_HOST
+if test "$program_prefix" = NONE; then
+ program_prefix=
+fi
AC_CANONICAL_TARGET
-AC_CANONICAL_BUILD
+target_os=`echo $target_os | sed 's/linux-gnu$/linux/;s/linux-gnu/linux-/'`
dnl checks for fat-binary
-fat_binary=no
AC_ARG_ENABLE(fat-binary,
- [--enable-fat-binary build a NeXT/Apple Multi Architecture Binary. ],
- [fat_binary=$enableval])
- if test "$fat_binary" = yes ; then
+ [ --enable-fat-binary=ARCHS
+ build an Apple/NeXT Multi Architecture Binary (MAB);
+ ARCHS is a comma-delimited list of architectures for
+ which to build; if ARCHS is omitted, then the package
+ will be built for all architectures supported by the
+ platform ("ppc" for MacOS/X and Darwin; "ppc,i386"
+ for Rhapsody; "m68k,i386,sparc" for OpenStep;
+ "m68k,i386,sparc,hppa" for NextStep); if this option
+ is disabled or omitted entirely, then the package
+ will be built only for the target platform],
+ [fat_binary=$enableval], [fat_binary=no])
+if test "$fat_binary" != no; then
+
+ AC_MSG_CHECKING([target architectures])
+
+ # Respect TARGET_ARCHS setting from environment if available.
+ if test -z "$TARGET_ARCHS"; then
+ # Respect ARCH given to --enable-fat-binary if present.
+ if test "$fat_binary" != yes; then
+ TARGET_ARCHS=`echo "$fat_binary" | tr ',' ' '`
+ else
+ # Choose a default set of architectures based upon platform.
+ case "$target_os" in
+ darwin*)
+ TARGET_ARCHS="ppc"
+ ;;
+ rhapsody*)
+ TARGET_ARCHS="ppc i386"
+ ;;
+ openstep*)
+ TARGET_ARCHS="m68k i386 sparc"
+ ;;
+ nextstep*)
+ TARGET_ARCHS="m68k i386 sparc hppa"
+ ;;
+ *)
+ TARGET_ARCHS=`arch`
+ esac
+ fi
+ fi
- AC_MSG_CHECKING(target architecture)
+ AC_MSG_RESULT([$TARGET_ARCHS])
- case "$target_os" in
- rhapsody*)
- echo -n "MacOS X Server: "
- if test "$TARGET_ARCHS" = "" ; then
- TARGET_ARCHS="ppc i386"
- fi
- ;;
- nextstep*|openstep*)
- echo -n "NeXTSTEP/OPENSTEP: "
- if test "$TARGET_ARCHS" = "" ; then
- if test `/usr/bin/arch` = "m68k" ; then
- TARGET_ARCHS="m68k i486"
- else # Black and Native one
- TARGET_ARCHS="m68k `/usr/bin/arch`"
- fi
- fi
- # to ensure AC_HEADER_SYS_WAIT works
- AC_DEFINE(_POSIX_SOURCE)
- ;;
- macos*|darwin*)
- echo -n "MacOS X (Darwin): "
- if test "$TARGET_ARCHS" = "" ; then
- TARGET_ARCHS="ppc i386"
- fi
- ;;
- esac
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
+ ARCH_FLAG=
for archs in $TARGET_ARCHS
do
- ARCH_FLAG="$ARCH_FLAG -arch $archs "
- echo -n " $archs"
+ ARCH_FLAG="$ARCH_FLAG -arch $archs"
done
AC_DEFINE(NEXT_FAT_BINARY)
- echo "."
-fi
+fi
+
+case $target_cpu in
+ i?86) frame_address=yes;;
+ *) frame_address=no;;
+esac
+AC_ARG_ENABLE(frame-address,
+ [ --enable-frame-address use GCC __builtin_frame_address(). ],
+ [frame_address=$enableval])
+if test $frame_address = yes; then
+ AC_DEFINE(USE_BUILTIN_FRAME_ADDRESS)
+fi
AC_ARG_PROGRAM
@@ -84,26 +149,41 @@ fi
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
+RUBY_PROG_GNU_LD
+RUBY_CPPOUTFILE
+
+: ${OUTFLAG='-o '}
+AC_SUBST(OUTFLAG)
+
+RUBY_MINGW32
+
AC_PROG_YACC
+if test "$YACC" = "yacc"; then
+ AC_DEFINE([OLD_YACC])
+fi
+
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_CHECK_TOOL(AR, ar)
-AC_CHECK_PROGS(AR, ar aal, ar)
+if test -z "$AR"; then
+ AC_CHECK_PROGS(AR, aal, ar)
+fi
case "$target_os" in
cygwin*|mingw*)
AC_CHECK_TOOL(NM, nm)
- AC_CHECK_TOOL(DLLWRAP, dllwrap)
- AC_CHECK_TOOL(AS, as)
- AC_CHECK_TOOL(DLLTOOL, dlltool)
AC_CHECK_TOOL(WINDRES, windres)
- echo 'main(){}' > conftest.c
- if $CC -mwin32 -c conftest.c 2> /dev/null; then
- MWIN32=-mwin32
- CFLAGS="$CFLAGS $MWIN32"
- fi
+ AC_CHECK_TOOL(DLLWRAP, dllwrap)
+ target_cpu=`echo $target_cpu | sed s/i.86/i386/`
+ : ${enable_shared=yes}
+ ;;
+aix*)
+ AC_CHECK_TOOL(NM, nm, /usr/ccs/bin/nm, /usr/ccs/bin:$PATH)
+ ;;
+hiuxmpp*)
+ # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
+ AC_DEFINE(__HIUX_MPP__)
;;
esac
-AC_SUBST(MWIN32)
AC_PROG_LN_S
AC_PROG_MAKE_SET
@@ -112,17 +192,21 @@ AC_PROG_MAKE_SET
AC_AIX
AC_MINIX
-AC_EXEEXT
-AC_OBJEXT
+dnl check for large file stuff
+AC_SYS_LARGEFILE
+
+AC_CHECK_TYPES([long long, off_t])
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(long long, 0)
AC_CHECK_SIZEOF(__int64, 0)
+AC_CHECK_SIZEOF(off_t, 0)
AC_CHECK_SIZEOF(void*, 4)
AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)
+AC_CHECK_SIZEOF(time_t, 0)
AC_CACHE_CHECK(for prototypes, rb_cv_have_prototypes,
[AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
@@ -161,21 +245,32 @@ if test "$rb_cv_stdarg" = yes; then
AC_DEFINE(HAVE_STDARG_PROTOTYPES)
fi
-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)])
-if test "$rb_cv_have_attr_noreturn" = yes; then
- AC_DEFINE(HAVE_ATTR_NORETURN)
-fi
-
-dnl wheather link libc_r or not
+AC_CACHE_CHECK([for noreturn], rb_cv_noreturn,
+[rb_cv_noreturn=no
+for mac in "x __attribute__ ((noreturn))" "__declspec(noreturn) x" x; do
+ AC_TRY_COMPILE(
+ [#define NORETURN(x) $mac
+NORETURN(void exit(int x));],
+ [],
+ [rb_cv_noreturn="$mac"; break])
+done])
+AC_DEFINE_UNQUOTED([NORETURN(x)], $rb_cv_noreturn)
+
+dnl Check whether we need to define sys_nerr locally
+AC_CHECK_DECLS([sys_nerr], [], [], [$ac_includes_default
+#include <errno.h>])
+
+dnl whether link libc_r or not
AC_ARG_WITH(libc_r,
- [--with-libc_r link libc_r if possible (FreeBSD only)], [
+ [ --with-libc_r link libc_r if possible (FreeBSD only)], [
case $withval in
yes) with_libc_r=yes;;
*) with_libc_r=no;;
- esac], [with_libc_r=yes])
+ esac], [with_libc_r=no])
+
+AC_ARG_ENABLE(pthread,
+ [ --enable-pthread use pthread library.],
+ [enable_pthread=$enableval], [enable_pthread=no])
dnl Checks for libraries.
case "$target_os" in
@@ -183,10 +278,18 @@ nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
darwin*) LIBS="-lobjc $LIBS";;
-human*) ac_cv_func_getpgrp_void=yes;;
+hpux*) LIBS="-lm $LIBS"
+ ac_cv_c_inline=no;;
+human*) ac_cv_func_getpgrp_void=yes
+ ac_cv_func_setitimer=no
+ ;;
beos*) ;;
-cygwin*) rb_cv_have_daylight=no;;
-mingw*) LIBS="-lwsock32 -lmsvcrt $LIBS"
+cygwin*) rb_cv_have_daylight=no
+ ac_cv_var_tzname=no
+ ac_cv_func__setjmp=no
+ ac_cv_func_setitimer=no
+ ;;
+mingw*) LIBS="-lwsock32 $LIBS"
ac_cv_header_a_out_h=no
ac_cv_header_pwd_h=no
ac_cv_header_utime_h=no
@@ -195,11 +298,24 @@ mingw*) LIBS="-lwsock32 -lmsvcrt $LIBS"
ac_cv_header_sys_resource_h=no
ac_cv_header_sys_select_h=no
ac_cv_header_sys_times_h=no
- ac_cv_func_times=yes;;
-os2_emx*) LIBS="-lm $LIBS"
+ ac_cv_func_times=yes
+ ac_cv_func_waitpid=yes
+ ac_cv_func_fsync=yes
+ ac_cv_func_vsnprintf=yes
+ ac_cv_func_seekdir=yes
+ ac_cv_func_telldir=yes
+ ac_cv_func_isinf=yes
+ ac_cv_func_isnan=yes
+ ac_cv_func_finite=yes
+ ac_cv_lib_crypt_crypt=no
+ enable_pthread=no
+ ;;
+os2-emx*) LIBS="-lm $LIBS"
ac_cv_lib_dir_opendir=no;;
msdosdjgpp*) LIBS="-lm $LIBS"
- ac_cv_func_getpgrp_void=yes;;
+ ac_cv_func_getpgrp_void=yes
+ ac_cv_func_setitimer=no
+ ;;
freebsd*) LIBS="-lm $LIBS"
AC_CACHE_CHECK([whether -lxpg4 has to be linked],
rb_cv_lib_xpg4_needed,
@@ -229,51 +345,80 @@ freebsd*) LIBS="-lm $LIBS"
rb_cv_supplementary_lib_c_r=yes,
rb_cv_supplementary_lib_c_r=yes)])
if test "$rb_cv_supplementary_lib_c_r" = yes; then
- MAINLIBS="-lc_r $MAINLIBS"
- else
- MAINLIBS="-pthread $MAINLIBS"
- CFLAGS="-D_THREAD_SAFE $CFLAGS"
+ MAINLIBS="-lc_r $MAINLIBS"
fi
fi
;;
+dragonfly*) LIBS="-lm $LIBS"
+ ;;
+bow) ac_cv_func_setitimer=no
+ ;;
+superux*) ac_cv_func_setitimer=no
+ ;;
*) LIBS="-lm $LIBS";;
esac
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
+case "$target_cpu" in
+alpha*) case "$target_os"::"$GCC" in
+ *::yes) CFLAGS="-mieee $CFLAGS" ;; # gcc
+ osf*) CFLAGS="-ieee $CFLAGS" ;; # ccc
+ esac ;;
+esac
+
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
- syscall.h pwd.h a.out.h utime.h memory.h direct.h sys/resource.h)
+ syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \
+ sys/mkdev.h sys/utime.h netinet/in_systm.h float.h ieeefp.h pthread.h \
+ ucontext.h intrinsics.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T
AC_TYPE_SIZE_T
AC_STRUCT_ST_BLKSIZE
-save_LIBOJBS="$LIBOBJS"
AC_STRUCT_ST_BLOCKS
-LIBOBJS="$save_LIBOBJS"
AC_STRUCT_ST_RDEV
dnl Checks for library functions.
AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
AC_FUNC_ALLOCA
-AC_FUNC_VFORK
AC_FUNC_MEMCMP
+AC_FUNC_FSEEKO
+AC_CHECK_FUNCS(ftello)
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
- isinf isnan finite)
-AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
+ isnan finite isinf hypot acosh erf)
+AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync getcwd\
truncate chsize times utimes fcntl lockf lstat symlink readlink\
- setitimer setruid seteuid setreuid setrgid setegid setregid pause\
- getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\
- dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod)
+ setitimer setruid seteuid setreuid setresuid setproctitle\
+ setrgid setegid setregid setresgid issetugid pause lchown lchmod\
+ getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
+ getpriority getrlimit dlopen sigprocmask sigaction _setjmp\
+ setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\
+ setuid setgid)
+AC_ARG_ENABLE(setreuid,
+ [ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
+ [use_setreuid=$enableval])
+if test "$use_setreuid" = yes; then
+ AC_DEFINE(USE_SETREUID)
+ AC_DEFINE(USE_SETREGID)
+fi
AC_STRUCT_TIMEZONE
+AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
+ [AC_TRY_COMPILE([#include <time.h>],
+ [struct tm t; t.tm_gmtoff = 3600;],
+ [rb_cv_member_struct_tm_tm_gmtoff=yes],
+ [rb_cv_member_struct_tm_tm_gmtoff=no])])
+if test "$rb_cv_member_struct_tm_tm_gmtoff" = yes; then
+ AC_DEFINE(HAVE_STRUCT_TM_TM_GMTOFF)
+fi
AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
[AC_TRY_LINK([#include <time.h>
int i;],
@@ -283,6 +428,43 @@ AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
if test "$rb_cv_have_daylight" = yes; then
AC_DEFINE(HAVE_DAYLIGHT)
fi
+AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
+ [AC_TRY_RUN([
+#include <time.h>
+
+void
+check(tm, y, m, d, h, s)
+ struct tm *tm;
+ int y, m, d, h, s;
+{
+ if (!tm ||
+ tm->tm_year != y ||
+ tm->tm_mon != m-1 ||
+ tm->tm_mday != d ||
+ tm->tm_hour != h ||
+ tm->tm_sec != s) {
+ exit(1);
+ }
+}
+
+int
+main()
+{
+ time_t t = -1;
+ struct tm *tm;
+
+ check(gmtime(&t), 69, 12, 31, 23, 59);
+ t = ~(time_t)0 << 31;
+ check(gmtime(&t), 1, 12, 13, 20, 52);
+ return 0;
+}
+],
+ rb_cv_negative_time_t=yes,
+ rb_cv_negative_time_t=no,
+ rb_cv_negative_time_t=yes)])
+if test "$rb_cv_negative_time_t" = yes; then
+ AC_DEFINE(NEGATIVE_TIME_T)
+fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL)
@@ -318,40 +500,11 @@ fi
AC_FUNC_GETPGRP
AC_FUNC_SETPGRP
-AC_CACHE_CHECK(for working strtod, rb_cv_func_strtod,
-[AC_TRY_RUN([
-double strtod ();
-int
-main()
-{
- {
- /* Some versions of Linux strtod mis-parse strings with leading '+'. */
- char *string = " +69";
- char *term;
- double value;
- value = strtod(string, &term);
- if (value != 69 || term != (string + 4))
- exit(1);
- }
-
- {
- /* Under Solaris 2.4, strtod returns the wrong value for the
- terminating character under some conditions. */
- char *string = "NaN";
- char *term;
- strtod(string, &term);
- if (term != string && *(term - 1) == 0)
- exit(1);
- }
- exit(0);
-}
-], rb_cv_func_strtod=yes, rb_cv_func_strtod=no, rb_cv_func_strtod=no)])
-test $rb_cv_func_strtod = no && LIBOBJS="$LIBOBJS strtod.o"
-
AC_C_BIGENDIAN
AC_C_CONST
AC_C_CHAR_UNSIGNED
AC_C_INLINE
+AC_C_VOLATILE
AC_CACHE_CHECK(whether right shift preserve sign bit, rb_cv_rshift_sign,
[AC_TRY_RUN([
@@ -372,29 +525,21 @@ else
AC_DEFINE(RSHIFT(x,y), (((x)<0) ? ~((~(x))>>y) : (x)>>y))
fi
-AC_MSG_CHECKING(count field in FILE structures)
+AC_MSG_CHECKING(read 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", )
-if test "$rb_cv_fcnt" = ""; then
- AC_TRY_COMPILE([#include <stdio.h>],
- [FILE *f = stdin; f->__cnt = 0;], rb_cv_fcnt="__cnt", )
-fi
-if test "$rb_cv_fcnt" = ""; then
- AC_TRY_COMPILE([#include <stdio.h>],
- [FILE *f = stdin; f->_r = 0;], rb_cv_fcnt="_r", )
-fi
-if test "$rb_cv_fcnt" = ""; then
- AC_TRY_COMPILE([#include <stdio.h>],
- [FILE *f = stdin; f->readCount = 0;],
- rb_cv_fcnt="readCount", )
-fi
-dnl for emx0.9c
-if test "$rb_cv_fcnt" = ""; then
- AC_TRY_COMPILE([#include <stdio.h>],
- [FILE *f = stdin; f->_rcount = 0;],
- rb_cv_fcnt="_rcount", rb_cv_fcnt="not found")
-fi])
+[for fcnt in dnl
+ _cnt dnl
+ __cnt dnl
+ _r dnl
+ readCount dnl
+ _rcount dnl for emx0.9c
+; do
+ AC_TRY_COMPILE([#include <stdio.h>
+],
+ [FILE *f = stdin; f->$fcnt = 0;],
+ rb_cv_fcnt="$fcnt"; break,
+ rb_cv_fcnt="not found")
+done])
if test "$rb_cv_fcnt" = "not found"; then
AC_MSG_RESULT([not found(OK if using GNU libc)])
else
@@ -402,11 +547,191 @@ else
AC_DEFINE_UNQUOTED(FILE_COUNT, $rb_cv_fcnt)
fi
+AC_MSG_CHECKING(read buffer ptr field in FILE structures)
+AC_CACHE_VAL(rb_cv_frptr,
+[for frptr in dnl
+ _IO_read_ptr dnl
+ _ptr dnl
+ __ptr dnl
+ bufpos dnl
+ _p dnl
+; do
+ AC_TRY_COMPILE([#include <stdio.h>
+],
+ [FILE *f = stdin; char buf[256]; f->$frptr = buf;],
+ rb_cv_frptr="$frptr"; break,
+ rb_cv_frptr="not found")
+done])
+if test "$rb_cv_frptr" = "not found"; then
+ AC_MSG_RESULT([not found])
+else
+ AC_MSG_RESULT($rb_cv_frptr)
+ AC_DEFINE_UNQUOTED(FILE_READPTR, $rb_cv_frptr)
+
+ if test "$rb_cv_fcnt" = "not found"; then
+ AC_MSG_CHECKING(read buffer end field in FILE structures)
+ AC_CACHE_VAL(rb_cv_frend,
+ [for frend in dnl
+ _IO_read_end dnl
+ bufread dnl
+ ; do
+ AC_TRY_COMPILE([#include <stdio.h>
+ ],
+ [FILE *f = stdin; char buf[256]; f->$frend = buf;],
+ rb_cv_frend="$frend"; break,
+ rb_cv_frend="not found")
+ done])
+ if test "$rb_cv_frend" = "not found"; then
+ AC_MSG_RESULT([not found])
+ else
+ AC_MSG_RESULT($rb_cv_frend)
+ AC_DEFINE_UNQUOTED(FILE_READEND, $rb_cv_frend)
+ fi
+ fi
+fi
+
+AC_DEFUN(RUBY_CHECK_IO_NEED,
+[AC_CACHE_CHECK(whether need to [$1], [$2],
+ [AC_TRY_RUN([
+#include <stdio.h>
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
+#define before_seek(f) ]ifelse(index($2,flush_before_seek),-1,[fflush(f)],[(f,0)])[
+#define reset_rw(f) ]ifelse(index($2,seek_between_rw),-1,[do_seek(f,SEEK_CUR)],[(f,0)])[
+#define do_seek(f, w) (before_seek(f), fseek(f,0,w))
+
+char *fn = "conftest.dat";
+char *wombat = "wombat\n";
+char *koara = "koara\n";
+char *kangaroo = "kangaroo\n";
+
+int main()
+{
+ char buf[BUFSIZ];
+ FILE *f;
+ int r = 1;
+
+ if (!(f = fopen(fn, "w+"))) return 1;
+ fputs(wombat, f);
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ reset_rw(f);
+ fputs(koara, f);
+ fputs(kangaroo, f);
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, koara)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ reset_rw(f);
+ fputc('X', f);
+ reset_rw(f);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, koara+1)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
+ do_seek(f, SEEK_SET);
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, wombat)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || buf[0] != 'X' || strcmp(buf+1, koara+1)) goto fail;
+ if (!fgets(buf, BUFSIZ, f) || strcmp(buf, kangaroo)) goto fail;
+ r = 0;
+ fail:
+ fclose(f);
+ unlink(fn);
+ return r;
+}
+], [$2]=no, [$2]=yes, [$2]=[$3])])])
+RUBY_CHECK_IO_NEED(seek between R/W, rb_cv_need_io_seek_between_rw, yes)
+if test "$rb_cv_need_io_seek_between_rw" = yes; then
+ AC_DEFINE(NEED_IO_SEEK_BETWEEN_RW, 1)
+fi
+dnl RUBY_CHECK_IO_NEED(flush before seek, rb_cv_need_io_flush_before_seek, no)
+dnl if test "$rb_cv_need_io_flush_before_seek" = yes; then
+dnl AC_DEFINE(NEED_IO_FLUSH_BEFORE_SEEK, 1)
+dnl fi
+
+AC_CACHE_CHECK([whether st_ino is huge], rb_cv_huge_st_ino,
+[AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([
+#include <sys/stat.h>
+struct stat test_stat;
+], [sizeof(test_stat.st_ino)>sizeof(long)])],
+rb_cv_huge_st_ino=yes,
+rb_cv_huge_st_ino=no)
+])
+if test $rb_cv_huge_st_ino = yes; then
+ AC_DEFINE(HUGE_ST_INO)
+fi
+
+case "$target_cpu" in
+m68*|i?86|ia64|sparc*|alpha*) rb_cv_stack_grow_dir=-1;;
+hppa*) rb_cv_stack_grow_dir=+1;;
+esac
+AC_CACHE_CHECK(stack growing direction, rb_cv_stack_grow_dir,
+ [AC_TRY_RUN([
+/* recurse to get rid of inlining */
+static int
+stack_growup_p(addr, n)
+ volatile int *addr, n;
+{
+ volatile int end;
+ if (n > 0)
+ return *addr = stack_growup_p(addr, n - 1);
+ else
+ return (&end > addr);
+}
+int main()
+{
+ int x;
+ return stack_growup_p(&x, 10);
+}
+], rb_cv_stack_grow_dir=-1, rb_cv_stack_grow_dir=+1, rb_cv_stack_grow_dir=0)])
+AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
+
+if test x"$enable_pthread" = xyes; then
+ for pthread_lib in pthread pthreads c c_r; do
+ AC_CHECK_LIB($pthread_lib, pthread_kill,
+ rb_with_pthread=yes, rb_with_pthread=no)
+ if test "$rb_with_pthread" = "yes"; then break; fi
+ done
+ if test x"$rb_with_pthread" = xyes; then
+ AC_DEFINE(_REENTRANT)
+ AC_DEFINE(_THREAD_SAFE)
+ AC_DEFINE(HAVE_LIBPTHREAD)
+ case $pthread_lib in
+ c)
+ ;;
+ c_r)
+ MAINLIBS="-pthread $MAINLIBS"
+ ;;
+ *)
+ LIBS="-l$pthread_lib $LIBS"
+ ;;
+ esac
+ else
+ AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled")
+ fi
+ AC_CHECK_FUNCS(nanosleep)
+ if test x"$ac_cv_func_nanosleep" = xno; then
+ AC_CHECK_LIB(rt, nanosleep)
+ if test x"$ac_cv_lib_rt_nanosleep" = xyes; then
+ AC_DEFINE(HAVE_NANOSLEEP)
+ fi
+ fi
+fi
+if test x"$ac_cv_header_ucontext_h" = xyes; then
+ if test x"$target_cpu" = xia64 -o x"$rb_with_pthread" = xyes; then
+ AC_CHECK_FUNCS(getcontext setcontext)
+ fi
+fi
+
dnl default value for $KANJI
DEFAULT_KCODE="KCODE_NONE"
AC_ARG_WITH(default-kcode,
- [--with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)],
+ [ --with-default-kcode=CODE specify default value for \$KCODE (utf8|euc|sjis|none)],
[case $withval in
utf8) DEFAULT_KCODE="KCODE_UTF8";;
euc) DEFAULT_KCODE="KCODE_EUC";;
@@ -418,14 +743,12 @@ AC_DEFINE_UNQUOTED(DEFAULT_KCODE, $DEFAULT_KCODE)
dnl wheather use dln_a_out or not
AC_ARG_WITH(dln-a-out,
- [--with-dln-a-out use dln_a_out if possible], [
+ [ --with-dln-a-out use dln_a_out if possible], [
case $withval in
yes) with_dln_a_out=yes;;
*) with_dln_a_out=no;;
esac], [with_dln_a_out=no])
-AC_SUBST(XLDFLAGS)dnl
-
AC_CACHE_CHECK(whether ELF binaries are produced, rb_cv_binary_elf,
[AC_TRY_RUN([
/* Test for whether ELF binaries are produced */
@@ -453,14 +776,13 @@ if test "$rb_cv_binary_elf" = yes; then
fi
case "$target_os" in
- linux*)
- if test "$rb_cv_binary_elf" = no; then
- with_dln_a_out=yes
- target_os=${target_os}-a_out
- else
- LDFLAGS="-rdynamic"
- fi;;
-netbsd*)
+linux* | gnu* | k*bsd*-gnu)
+ if test "$rb_cv_binary_elf" = no; then
+ with_dln_a_out=yes
+ else
+ LDFLAGS="$LDFLAGS -rdynamic"
+ fi;;
+netbsd*|openbsd*)
if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
then
netbsd_elf=yes
@@ -469,138 +791,164 @@ netbsd*)
fi
;;
esac
+LIBEXT=a
AC_SUBST(DLDFLAGS)dnl
+AC_SUBST(ARCH_FLAG)dnl
AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl
AC_SUBST(LDSHARED)dnl
AC_SUBST(DLEXT)dnl
AC_SUBST(DLEXT2)dnl
+AC_SUBST(LIBEXT)dnl
STATIC=
+: ${LIBPATHFLAG=' -L"%s"'}
+: ${PATHFLAG=''}
if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=unknown
AC_MSG_CHECKING(whether OS depend dynamic link works)
if test "$GCC" = yes; then
case "$target_os" in
- nextstep*) ;;
- openstep*) ;;
- rhapsody*) ;;
- darwin*) ;;
- human*) ;;
- bsdi*) ;;
- beos*) ;;
- cygwin*) ;;
- mingw*) ;;
- netbsd*) CCDLFLAGS=-fpic
- case "$target_cpu" in
- mips*) CCDLFLAGS=-fPIC ;;
- sparc) CCDLFLAGS=-fPIC ;;
- *) ;;
- esac ;;
- *) CCDLFLAGS=-fPIC;;
+ nextstep*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
+ openstep*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
+ rhapsody*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
+ darwin*) CCDLFLAGS="$CCDLFLAGS -fno-common";;
+ human*|bsdi*|beos*|cygwin*|mingw*|aix*|interix*) ;;
+ *) CCDLFLAGS="$CCDLFLAGS -fPIC";;
esac
else
case "$target_os" in
- hpux*) CCDLFLAGS='+z';;
- solaris*|irix*) CCDLFLAGS='-KPIC' ;;
- sunos*) CCDLFLAGS='-PIC' ;;
- esix*|uxpds*) CCDLFLAGS='-KPIC' ;;
- *) CCDLFLAGS='' ;;
+ hpux*) CCDLFLAGS="$CCDLFLAGS +Z";;
+ solaris*|irix*) CCDLFLAGS="$CCDLFLAGS -KPIC" ;;
+ sunos*) CCDLFLAGS="$CCDLFLAGS -PIC" ;;
+ esix*|uxpds*) CCDLFLAGS="$CCDLFLAGS -KPIC" ;;
+ *) : ${CCDLFLAGS=""} ;;
esac
fi
case "$target_os" in
- hpux*) DLDFLAGS="-E"
- LDSHARED='ld -b'
- LDFLAGS="-Wl,-E"
+ hpux*) DLDFLAGS="$DLDFLAGS -E"
+ : ${LDSHARED='ld -b'}
+ XLDFLAGS="$XLDFLAGS -Wl,-E"
rb_cv_dlopen=yes;;
solaris*) if test "$GCC" = yes; then
- LDSHARED='$(CC) -Wl,-G'
- `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
+ : ${LDSHARED='$(CC) -Wl,-G'}
+ if test "$rb_cv_prog_gnu_ld" = yes; then
+ LDFLAGS="$LDFLAGS -Wl,-E"
+ LDSHARED="$LDSHARED -shared"
+ fi
else
- LDSHARED='ld -G'
+ : ${LDSHARED='ld -G'}
fi
rb_cv_dlopen=yes;;
- sunos*) LDSHARED='ld -assert nodefinitions'
+ sunos*) : ${LDSHARED='ld -assert nodefinitions'}
rb_cv_dlopen=yes;;
- irix*) LDSHARED='ld -shared'
+ irix*) : ${LDSHARED='ld -shared'}
rb_cv_dlopen=yes;;
- sysv4*) LDSHARED='ld -G'
+ sysv4*) : ${LDSHARED='ld -G'}
rb_cv_dlopen=yes;;
- esix*|uxpds*) LDSHARED="ld -G"
+ nto-qnx*) : ${LDSHARED="qcc -shared"}
+ rb_cv_dlopen=yes ;;
+ esix*|uxpds*) : ${LDSHARED="ld -G"}
+ rb_cv_dlopen=yes ;;
+ osf*) : ${LDSHARED="ld -shared -expect_unresolved \"*\""}
rb_cv_dlopen=yes ;;
- osf*) LDSHARED="$CC -shared"
+ linux* | gnu* | k*bsd*-gnu)
+ : ${LDSHARED="$CC -shared"}
rb_cv_dlopen=yes ;;
- linux*) LDSHARED="$CC -shared"
+ interix*) : ${LDSHARED="$CC -shared"}
+ XLDFLAGS="$XLDFLAGS -Wl,-E"
+ LIBPATHFLAG=" -L'%1\$-s'"
rb_cv_dlopen=yes ;;
- freebsd*) LDSHARED="$CC -shared"
+ freebsd*|dragonfly*) : ${LDSHARED="$CC -shared"}
if test "$rb_cv_binary_elf" = yes; then
- LDFLAGS="-rdynamic"
- DLDFLAGS='-Wl,-soname,$(.TARGET)'
+ LDFLAGS="$LDFLAGS -rdynamic"
+ DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)'
else
- test "$GCC" = yes && `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null || LDSHARED="ld -Bshareable"
+ test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED="ld -Bshareable"
fi
rb_cv_dlopen=yes ;;
- netbsd*) LDSHARED="ld -shared"
+ netbsd*) : ${LDSHARED='${CC} -shared'}
if test "$rb_cv_binary_elf" = yes; then
- LDFLAGS="-export-dynamic"
+ LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
+ LIBPATHFLAG=" -L'%1\$-s'"
+ RPATHFLAG=" -Wl,-R'%1\$-s'"
fi
rb_cv_dlopen=yes ;;
- openbsd*) LDSHARED="ld -Bforcearchive -Bshareable"
+ openbsd*) : ${LDSHARED="\$(CC) -shared ${CCDLFLAGS}"}
+ if test "$rb_cv_binary_elf" = yes; then
+ LDFLAGS="$LDFLAGS -Wl,-E"
+ fi
rb_cv_dlopen=yes ;;
bsdi3*) case "$CC" in
- *shlicc*) LDSHARED="$CC -r"
+ *shlicc*) : ${LDSHARED="$CC -r"}
rb_cv_dlopen=yes ;;
esac ;;
- bsdi*) LDSHARED="ld -shared"
- LDFLAGS='-rdynamic -Wl,-rpath,$(prefix)/lib/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0'
+ bsdi*) : ${LDSHARED="ld -shared"}
+ LDFLAGS="$LDFLAGS "'-rdynamic -Wl,-rpath,$(libdir)/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0'
rb_cv_dlopen=yes ;;
- nextstep*) LDSHARED='cc -r -nostdlib'
- LDFLAGS="-u libsys_s"
- DLDFLAGS="$ARCH_FLAG"
+ nextstep*) : ${LDSHARED='cc -r -nostdlib'}
+ LDFLAGS="$LDFLAGS -u libsys_s"
rb_cv_dlopen=yes ;;
- openstep*) LDSHARED='cc -dynamic -bundle -undefined suppress'
- LDFLAGS=""
- DLDFLAGS="$ARCH_FLAG"
+ openstep*) : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
+ : ${LDFLAGS=""}
rb_cv_dlopen=yes ;;
- rhapsody*) LDSHARED='cc -dynamic -bundle -undefined suppress'
- LDFLAGS=""
- DLDFLAGS="$ARCH_FLAG"
+ rhapsody*) : ${LDSHARED='cc -dynamic -bundle -undefined suppress'}
+ : ${LDFLAGS=""}
rb_cv_dlopen=yes ;;
- darwin*) LDSHARED='cc -dynamic -bundle -undefined suppress'
- LDFLAGS=""
- DLDFLAGS="$ARCH_FLAG"
+ darwin*) : ${LDSHARED='cc -dynamic -bundle -undefined suppress -flat_namespace'}
+ : ${LDFLAGS=""}
rb_cv_dlopen=yes ;;
- aix*) LDSHARED='/usr/ccs/bin/ld'
- XLDFLAGS='-Wl,-bE:ruby.imp'
- DLDFLAGS='-brtl -eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
- LDFLAGS="-brtl"
+ aix*) : ${LDSHARED='/usr/ccs/bin/ld'}
+ XLDFLAGS="$XLDFLAGS -Wl,-bE:ruby.imp"
+ DLDFLAGS='-brtl -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 '"$DLDFLAGS"
+ ARCH_FLAGS='-eInit_$(TARGET)'
+ : LDFLAGS="-brtl $LDFLAGS"
+ : ${ARCHFILE="ruby.imp"}
+ TRY_LINK='$(CC) $(DLDFLAGS) -oconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) $(CFLAGS)'
+ TRY_LINK="$TRY_LINK"' $(src) $(LIBPATH) $(LOCAL_LIBS) $(LIBS)'
rb_cv_dlopen=yes ;;
- human*) DLDFLAGS=''
- LDSHARED=''
- LDFLAGS=''
+ human*) : ${DLDFLAGS=''}
+ : ${LDSHARED=''}
+ : ${LDFLAGS=''}
+ : ${LINK_SO='ar cru $@ $(OBJS)'}
rb_cv_dlopen=yes ;;
beos*) case "$target_cpu" in
powerpc*)
- LDSHARED="ld -xms"
- DLDFLAGS='-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
+ : ${LDSHARED="ld -xms"}
+ DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
;;
i586*)
- LDSHARED="ld -shared"
- DLDFLAGS="-L/boot/develop/lib/x86 -lbe -lroot"
+ : ${LDSHARED="ld -shared"}
+ DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -lbe -lroot"
;;
esac
rb_cv_dlopen=yes ;;
- cygwin*|mingw*) : ${LDSHARED="${DLLWRAP} --target=${target_os} --as=${AS} --dlltool-name=${DLLTOOL} --driver-name=${CC} --export-all -s"}
+ nto-qnx*) DLDFLAGS="$DLDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
+ : ${LDSHARED='ld -Bshareable -x'}
+ LDFLAGS="$LDFLAGS -L/lib -L/usr/lib -L/usr/local/lib"
+ rb_cv_dlopen=yes;;
+ cygwin*|mingw*) : ${LDSHARED="${CC} -shared -s"}
+ XLDFLAGS="$XLDFLAGS -Wl,--stack,0x02000000"
+ DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-import,--export-all"
+ rb_cv_dlopen=yes ;;
+ hiuxmpp) : ${LDSHARED='ld -r'} ;;
+ atheos*) : ${LDSHARED="$CC -shared"}
rb_cv_dlopen=yes ;;
- *) LDSHARED='ld' ;;
+ os2-emx*) LDFLAGS="$LDFLAGS -Zbsd-signals"
+ ;;
+ *) : ${LDSHARED='ld'} ;;
esac
AC_MSG_RESULT($rb_cv_dlopen)
fi
+AC_SUBST(LINK_SO)
+AC_SUBST(LIBPATHFLAG)
+AC_SUBST(RPATHFLAG)
+AC_SUBST(TRY_LINK)
dln_a_out_works=no
if test "$ac_cv_header_a_out_h" = yes; then
@@ -642,7 +990,7 @@ else
AC_DEFINE(DLEXT, ".bundle");;
darwin*) DLEXT=bundle
AC_DEFINE(DLEXT, ".bundle");;
- os2_emx*) DLEXT=dll
+ os2-emx*) DLEXT=dll
AC_DEFINE(DLEXT, ".dll");;
cygwin*|mingw*) DLEXT=so
AC_DEFINE(DLEXT, ".so")
@@ -661,7 +1009,7 @@ else
fi
case "$target_os" in
- linux*)
+ linux* | gnu* | k*bsd*-gnu)
STRIP='strip -S -x';;
nextstep*)
STRIP='strip -A -n';;
@@ -676,7 +1024,7 @@ esac
EXTSTATIC=
AC_SUBST(EXTSTATIC)dnl
AC_ARG_WITH(static-linked-ext,
- [--with-static-linked-ext link external modules statically],
+ [ --with-static-linked-ext link external modules statically],
[case $withval in
yes) STATIC=
EXTSTATIC=static;;
@@ -725,15 +1073,16 @@ rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no
if test "$rb_cv_missing_fconvert" = yes; then
AC_DEFINE(MISSING_FCONVERT)
fi
- LIBOBJS="$LIBOBJS x68.o"
- CFLAGS="$CFLAGS -fansi-only -cc1-stack=262144 -cpp-stack=2694144"
+ AC_LIBOBJ([x68.o])
+ CFLAGS="$CFLAGS -fansi-only"
+ XCFLAGS="$XCFLAGS -cc1-stack=262144 -cpp-stack=2694144"
EXEEXT=.x
OBJEXT=o
setup=Setup.x68
;;
dnl OS/2 environment w/ Autoconf 2.1x for EMX
- os2_emx)
- LIBOBJS="$LIBOBJS os2.$OBJEXT"
+ os2-emx)
+ AC_LIBOBJ([os2])
setup=Setup.emx
;;
*djgpp*)
@@ -750,12 +1099,12 @@ if test "$prefix" = NONE; then
prefix=$ac_default_prefix
fi
-if test "$fat_binary" = yes ; then
- CFLAGS="$CFLAGS $ARCH_FLAG"
-fi
+#if test "$fat_binary" != no ; then
+# CFLAGS="$CFLAGS $ARCH_FLAG"
+#fi
if test x"$cross_compiling" = xyes; then
- MINIRUBY="ruby -I`pwd` -rfake"
+ test x"$MINIRUBY" = x && MINIRUBY="${RUBY-ruby} -I`pwd` -rfake"
PREP=fake.rb
else
MINIRUBY='./miniruby$(EXEEXT)'
@@ -765,32 +1114,35 @@ AC_SUBST(MINIRUBY)
AC_SUBST(PREP)
FIRSTMAKEFILE=""
-LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a'
+LIBRUBY_A='lib$(RUBY_SO_NAME)-static.a'
LIBRUBY='$(LIBRUBY_A)'
-LIBRUBYARG='$(LIBRUBY_A)'
+LIBRUBYARG_STATIC='-l$(RUBY_SO_NAME)-static'
+LIBRUBYARG='$(LIBRUBYARG_STATIC)'
SOLIBS=
case "$target_os" in
- cygwin*|mingw*|beos*|openstep*|nextstep*|rhapsody*|darwin*|os2_emx*)
- DLDLIBS=""
+ cygwin*|mingw*|beos*|openstep*|nextstep*|rhapsody*|darwin*|os2-emx*)
+ : ${DLDLIBS=""}
;;
*)
- DLDLIBS="-lc"
+ DLDLIBS="$DLDLIBS -lc"
;;
esac
+RUBY_SO_NAME='$(RUBY_INSTALL_NAME)'
LIBRUBY_LDSHARED=$LDSHARED
LIBRUBY_DLDFLAGS=$DLDFLAGS
-LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
-LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so'
+LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY)'
+LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so'
ENABLE_SHARED=no
-AC_ARG_ENABLE(enable-shared,
- [--enable-shared build a shared library for Ruby. ],
+AC_ARG_ENABLE(shared,
+ [ --enable-shared build a shared library for Ruby. ],
[enable_shared=$enableval])
if test "$enable_shared" = 'yes'; then
LIBRUBY='$(LIBRUBY_SO)'
- LIBRUBYARG='-L. -l$(RUBY_INSTALL_NAME)'
+ LIBRUBYARG_SHARED='-l$(RUBY_SO_NAME)'
+ LIBRUBYARG='$(LIBRUBYARG_SHARED)'
CFLAGS="$CFLAGS $CCDLFLAGS"
ENABLE_SHARED=yes
if test "$rb_cv_binary_elf" = yes; then
@@ -798,15 +1150,15 @@ if test "$enable_shared" = 'yes'; then
fi
case "$target_os" in
sunos4*)
- LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
+ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
;;
- linux*)
- LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)'
- LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so'
+ linux* | gnu* | k*bsd*-gnu)
+ LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
+ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
;;
- freebsd*)
+ freebsd*|dragonfly*)
SOLIBS='$(LIBS)'
- LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)'
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
if test "$rb_cv_binary_elf" != "yes" ; then
LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
LIBRUBY_ALIASES=''
@@ -814,23 +1166,26 @@ if test "$enable_shared" = 'yes'; then
;;
netbsd*)
SOLIBS='$(LIBS)'
- LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)'
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR).$(TEENY)'
+ LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)'
+ LIBRUBYARG_SHARED='-Wl,-R -Wl,${libdir} -L${libdir} -L. -l$(RUBY_SO_NAME)'
if test "$rb_cv_binary_elf" = yes; then # ELF platforms
- LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR) lib$(RUBY_INSTALL_NAME).so'
- else
- LIBRUBY_ALIASES= # a.out platforms
+ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_SO_NAME).so'
+ else # a.out platforms
+ LIBRUBY_ALIASES=""
fi
;;
openbsd*)
SOLIBS='$(LIBS)'
- ;;
+ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
+ ;;
solaris*)
- XLDFLAGS='-R${prefix}/lib'
+ XLDFLAGS="$XLDFLAGS "'-R${libdir}'
;;
hpux*)
- XLDFLAGS='-Wl,+s,+b,$(prefix)/lib'
- LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
- LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl'
+ XLDFLAGS="$XLDFLAGS "'-Wl,+s,+b,$(libdir)'
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)'
+ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl'
;;
aix*)
if test "$GCC" = yes; then
@@ -840,7 +1195,7 @@ if test "$enable_shared" = 'yes'; then
LIBRUBY_LDSHARED='/usr/ccs/bin/ld'
LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry'
fi
- LIBRUBYARG='-L${prefix}/lib -Wl,lib$(RUBY_INSTALL_NAME).so'
+ LIBRUBYARG_SHARED='-L${libdir} -Wl,lib$(RUBY_SO_NAME).so'
SOLIBS='-lm -lc'
;;
beos*)
@@ -850,31 +1205,65 @@ if test "$enable_shared" = 'yes'; then
;;
esac
;;
+ darwin*)
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib'
+ LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace'
+ LIBRUBY_DLDFLAGS='-install_name $(libdir)/lib$(RUBY_SO_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)'
+ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib'
+ ;;
+ atheos*)
+ LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)'
+ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so'
+ ;;
+ interix*)
+ LIBRUBYARG_SHARED='-L${libdir} -L. -l$(RUBY_SO_NAME)'
+ ;;
*)
;;
esac
fi
+XLDFLAGS="$XLDFLAGS -L."
+AC_SUBST(ARCHFILE)
+
+dnl build rdoc index if requested
+RDOCTARGET=""
+AC_ARG_ENABLE(install-doc,
+ [ --enable-install-doc build and install rdoc indexes during install ],
+ [install_doc=$enableval], [install_doc=no])
+if test "$install_doc" != no; then
+ RDOCTARGET="install-doc"
+fi
+AC_SUBST(RDOCTARGET)
case "$target_os" in
- nextstep*)
+ netbsd*)
CFLAGS="$CFLAGS -pipe"
;;
- openstep*)
- CFLAGS="$CFLAGS -pipe"
+ nextstep*|openstep*)
+ # The -fno-common is needed if we wish to embed the Ruby interpreter
+ # into a plugin module of some project (as opposed to embedding it
+ # within the project's application). The -I/usr/local/include is
+ # needed because CPP as discovered by configure (cc -E -traditional)
+ # fails to consult /usr/local/include by default. This causes
+ # mkmf.rb's have_header() to fail if the desired resource happens to be
+ # installed in the /usr/local tree.
+ CFLAGS="$CFLAGS -pipe -fno-common"
+ CPPFLAGS="$CPPFLAGS -I/usr/local/include"
;;
rhapsody*)
- CFLAGS="$CFLAGS -pipe -no-precomp"
+ CFLAGS="$CFLAGS -pipe -no-precomp -fno-common"
;;
darwin*)
- CFLAGS="$CFLAGS -pipe -no-precomp"
+ CFLAGS="$CFLAGS -pipe -fno-common"
;;
- os2_emx)
- CFLAGS="$CFLAGS -DOS2"
+ os2-emx)
+ CFLAGS="$CFLAGS -DOS2 -Zmts"
+ LIBRUBY_A=`echo $LIBRUBY_A | sed 's/^lib//'`
+ LIBRUBY_SO=`echo $LIBRUBY_SO | sed 's/^lib//'`
+ LIBRUBY_ALIASES=`for i in $LIBRUBY_ALIASES; do echo "$i"; done | sed 's/^lib//'`
;;
osf*)
- if test "$without_gcc" = "no" ; then
- CFLAGS="$CFLAGS -ansi"
- else
+ if test "$GCC" != "yes" ; then
# compile something small: taint.c is fine for this.
# the main point is the '-v' flag of 'cc'.
case "`cc -v -I. -c main.c -o /tmp/main.o 2>&1`" in
@@ -897,47 +1286,80 @@ case "$target_os" in
esac
;;
cygwin*|mingw*)
- RUBY_SO_NAME=$target_os-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
- if test x"$enable_shared" = xyes; then
- LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
- LIBRUBY_DLDFLAGS='--dllname=$@ --output-lib=$(LIBRUBY) --add-stdcall-alias --def=$(RUBYDEF)'
- else
- LIBRUBY_SO=dummy
- LIBRUBY_DLDFLAGS='--output-exp=$(RUBY_INSTALL_NAME).exp --dllname=$(RUBY_INSTALL_NAME)$(EXEEXT) --output-lib=$(LIBRUBY) --add-stdcall-alias --def=$(RUBYDEF)'
- fi
- LIBRUBY_ALIASES=''
- LIBRUBY_A='lib$(RUBY_INSTALL_NAME)s.a'
- LIBRUBY='lib$(RUBY_SO_NAME).a'
- LIBRUBYARG='-L. -l$(RUBY_SO_NAME)'
- FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
- SOLIBS='$(LIBS)'
case "$target_os" in
cygwin*)
- LIBOBJS="$LIBOBJS strftime.o"
- CCDLFLAGS=-DUSEIMPORTLIB ;;
+ if test x"$enable_shared" = xyes; then
+ LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}.dll
+ LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
+ fi
+ AC_LIBOBJ([strftime])
+ ;;
mingw*)
- LIBOBJS="$LIBOBJS win32.o"
- CFLAGS="-DNT -D__MSVCRT__ $CFLAGS"
- CCDLFLAGS=-DIMPORT ;;
+ RUBY_SO_NAME=msvcrt-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
+ if test x"$enable_shared" = xyes; then
+ LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
+ LIBRUBY='lib$(LIBRUBY_SO).a'
+ fi
+ AC_LIBOBJ([win32])
+ COMMON_LIBS=m
+ COMMON_MACROS="WIN32_LEAN_AND_MEAN="
+ COMMON_HEADERS="windows.h winsock.h"
+ ;;
+ esac
+ XCFLAGS="$XCFLAGS"
+ LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
+ LIBRUBY_ALIASES=''
+ FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in
+ SOLIBS='$(LIBS)'
+ if test x"$enable_shared" = xno; then
+ LIBRUBY_SO=dummy
+ LIBRUBY='lib$(RUBY_SO_NAME).a'
+ LIBRUBYARG='-l$(RUBY_SO_NAME)'
+ fi
+ ;;
+ hpux*)
+ case "$YACC" in
+ *yacc*)
+ XCFLAGS="$XCFLAGS -DYYMAXDEPTH=300"
+ YACC="$YACC -Nl40000 -Nm40000"
+ ;;
esac
;;
*)
- ;;
+ ;;
+esac
+
+case "$build_os" in
+ *msdosdjgpp*) FIRSTMAKEFILE=GNUmakefile:djgpp/GNUmakefile.in;;
esac
+AC_SUBST(XCFLAGS)dnl
+AC_SUBST(XLDFLAGS)dnl
AC_SUBST(LIBRUBY_LDSHARED)
AC_SUBST(LIBRUBY_DLDFLAGS)
AC_SUBST(RUBY_INSTALL_NAME)
+AC_SUBST(rubyw_install_name)
+AC_SUBST(RUBYW_INSTALL_NAME)
AC_SUBST(RUBY_SO_NAME)
AC_SUBST(LIBRUBY_A)
AC_SUBST(LIBRUBY_SO)
AC_SUBST(LIBRUBY_ALIASES)
AC_SUBST(LIBRUBY)
AC_SUBST(LIBRUBYARG)
+AC_SUBST(LIBRUBYARG_STATIC)
+AC_SUBST(LIBRUBYARG_SHARED)
AC_SUBST(SOLIBS)
AC_SUBST(DLDLIBS)
AC_SUBST(ENABLE_SHARED)
AC_SUBST(MAINLIBS)
+AC_SUBST(COMMON_LIBS)
+AC_SUBST(COMMON_MACROS)
+AC_SUBST(COMMON_HEADERS)
+AC_SUBST(EXPORT_PREFIX)
+
+MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`"
+MAKEFILES="`echo $MAKEFILES`"
+AC_SUBST(MAKEFILES)
ri_prefix=
test "$program_prefix" != NONE &&
@@ -949,7 +1371,13 @@ test "$program_suffix" != NONE &&
RUBY_INSTALL_NAME="${ri_prefix}ruby${ri_suffix}"
case "$target_os" in
- cygwin*|mingw*|*djgpp*|os2_emx*)
+ cygwin*|mingw*)
+ RUBYW_INSTALL_NAME="${ri_prefix}rubyw${ri_suffix}"
+ rubyw_install_name="$RUBYW_INSTALL_NAME"
+ ;;
+esac
+case "$target_os" in
+ cygwin*|mingw*|*djgpp*|os2-emx*)
RUBY_LIB_PREFIX="/lib/ruby"
;;
*)
@@ -959,12 +1387,12 @@ esac
RUBY_LIB_PATH="${RUBY_LIB_PREFIX}/${MAJOR}.${MINOR}"
AC_ARG_WITH(sitedir,
- [--with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
+ [ --with-sitedir=DIR site libraries in DIR [PREFIX/lib/ruby/site_ruby]],
[sitedir=$withval],
[sitedir='${prefix}/lib/ruby/site_ruby'])
SITE_DIR="`eval \"echo ${sitedir}\"`"
case "$target_os" in
- cygwin*|mingw*|*djgpp*|os2_emx*)
+ cygwin*|mingw*|*djgpp*|os2-emx*)
RUBY_SITE_LIB_PATH="`expr "$SITE_DIR" : "$prefix\(/.*\)"`" ||
RUBY_SITE_LIB_PATH="$SITE_DIR";;
*)
@@ -977,12 +1405,13 @@ AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${RUBY_SITE_LIB_PATH}")
AC_DEFINE_UNQUOTED(RUBY_SITE_LIB2, "${RUBY_SITE_LIB_PATH2}")
AC_SUBST(arch)dnl
+AC_SUBST(sitearch)dnl
AC_SUBST(sitedir)dnl
configure_args=$ac_configure_args
AC_SUBST(configure_args)dnl
-if test "$fat_binary" = yes ; then
+if test "$fat_binary" != no ; then
arch="fat-${target_os}"
AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB,
@@ -996,18 +1425,50 @@ else
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}")
fi
+case "$target_os" in
+ mingw*) sitearch="i386-msvcrt" ;;
+ *) sitearch="${arch}" ;;
+esac
+
AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}")
-AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${arch}")
+AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${sitearch}")
AC_ARG_WITH(search-path,
- [--with-search-path=DIR specify the additional search path],
+ [ --with-search-path=DIR specify the additional search path],
[search_path=$withval])
if test "$search_path" != ""; then
AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path")
fi
-echo "creating config.h"
-tr -d '\015' < confdefs.h > config.h
+AC_ARG_WITH(mantype,
+ [ --with-mantype=TYPE specify man page type; TYPE is one of man and doc],
+ [
+ case "$withval" in
+ man|doc)
+ MANTYPE=$withval
+ ;;
+ *)
+ AC_MSG_ERROR(invalid man type: $withval)
+ ;;
+ esac
+ ])
+if test -z "$MANTYPE"; then
+ AC_PATH_PROGS(NROFF, nroff awf, /bin/false, "/usr/bin:/usr/ucb")
+ if ${NROFF} -mdoc ${srcdir}/ruby.1 >/dev/null 2>&1; then
+ MANTYPE=doc
+ else
+ MANTYPE=man
+ fi
+fi
+AC_SUBST(MANTYPE)
+
+if test -f config.h && tr -d '\015' < confdefs.h | cmp -s config.h -; then
+ echo "config.h unchanged"
+else
+ echo "creating config.h"
+ tr -d '\015' < confdefs.h > config.h
+fi
: > confdefs.h
-AC_OUTPUT($FIRSTMAKEFILE Makefile ext/extmk.rb)
+AC_CONFIG_FILES([$FIRSTMAKEFILE Makefile])
+AC_OUTPUT
diff --git a/cygwin/GNUmakefile.in b/cygwin/GNUmakefile.in
index 0e89d15dec..da9efaab47 100644
--- a/cygwin/GNUmakefile.in
+++ b/cygwin/GNUmakefile.in
@@ -2,31 +2,39 @@ include Makefile
ENABLE_SHARED=@ENABLE_SHARED@
-ifneq (,$(findstring no, $(ENABLE_SHARED)))
- EXTOBJS = $(RUBY_INSTALL_NAME).exp
+ifeq (@target_os@,cygwin)
+ DLL_BASE_NAME := $(subst .dll,,$(LIBRUBY_SO))
+else
+ DLL_BASE_NAME := $(RUBY_SO_NAME)
+endif
+
+ifneq ($(ENABLE_SHARED),yes)
+ RUBY_EXP = $(RUBY_INSTALL_NAME).exp
+ EXTOBJS = $(RUBY_EXP)
LIBRUBYARG = $(LIBRUBY_A)
+ LIBRUBY_SO =
endif
-ifneq (,$(findstring ruby, $(RUBY_INSTALL_NAME)))
- RUBYW_INSTALL_NAME = $(subst ruby,rubyw,$(RUBY_INSTALL_NAME))
-else
+ifeq ($(RUBY_INSTALL_NAME),ruby)
RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME)w
+else
+ RUBYW_INSTALL_NAME = $(subst ruby,rubyw,$(RUBY_INSTALL_NAME))
endif
+
WPROGRAM = $(RUBYW_INSTALL_NAME)$(EXEEXT)
-RUBYDEF = $(RUBY_INSTALL_NAME).def
-SOLIBS := $(LIBRUBY_SO).res.@OBJEXT@ $(SOLIBS)
+SOLIBS := $(DLL_BASE_NAME).res.@OBJEXT@ $(SOLIBS)
EXTOBJS += $(@:$(EXEEXT)=.res.@OBJEXT@)
-$(LIBRUBY_SO): $(RUBYDEF) $(LIBRUBY_SO).res.@OBJEXT@
-$(LIBRUBY): $(LIBRUBY_SO)
+$(LIBRUBY): $(RUBY_EXP) $(LIBRUBY_SO)
+$(RUBY_EXP) $(LIBRUBY_SO): $(DLL_BASE_NAME).res.@OBJEXT@
%.res.@OBJEXT@: %.rc
- @WINDRES@ --preprocessor '$(CC) -E -xc-header -DRC_INVOKE @MWIN32@' --include-dir . --include-dir $(<D) --include-dir $(srcdir)/win32 $< $@
+ @WINDRES@ --include-dir . --include-dir $(<D) --include-dir $(srcdir)/win32 $< $@
-$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(LIBRUBY_SO).rc: rbconfig.rb
- @@MINIRUBY@ $(srcdir)/win32/resource.rb \
+$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(DLL_BASE_NAME).rc: rbconfig.rb
+ @$(MINIRUBY) $(srcdir)/win32/resource.rb \
-ruby_name=$(RUBY_INSTALL_NAME) -rubyw_name=$(RUBYW_INSTALL_NAME) \
- -so_name=$(LIBRUBY_SO) \
+ -so_name=$(DLL_BASE_NAME) \
. $(icondirs) $(srcdir)/win32
$(PROGRAM): $(RUBY_INSTALL_NAME).res.@OBJEXT@
@@ -35,7 +43,23 @@ $(WPROGRAM): $(RUBYW_INSTALL_NAME).res.@OBJEXT@
$(PURIFY) $(CC) -mwindows -e _mainCRTStartup $(LDFLAGS) $(XLDFLAGS) \
$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@
-$(RUBYDEF): $(LIBRUBY_A)
- echo EXPORTS > $(RUBYDEF)
- @NM@ --extern-only --defined-only $(LIBRUBY_A) | \
- @MINIRUBY@ -ne 'puts $$1 if / [CDT] _(.*)$$/' >> $(RUBYDEF)
+$(RUBY_EXP): $(LIBRUBY_A)
+ @DLLWRAP@ --target=@target_os@ --driver-name=$(CC) \
+ --output-exp=$(RUBY_EXP) \
+ --export-all $(LIBRUBY_A) $(LIBS) -o $(PROGRAM)
+ $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)
+ @rm -f $(PROGRAM)
+
+GNUmakefile: $(srcdir)/cygwin/GNUmakefile.in
+
+ifeq (@target_os@,mingw32)
+$(OBJS) $(MAINOBJ): win32/win32.h
+endif
+
+ifeq (@target_os@,cygwin)
+cygwin-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR).dll: $(LIBRUBY_A)
+ @NM@ --extern --defined $(LIBRUBY_A) | \
+ $(MINIRUBY) -ne 'BEGIN{puts "EXPORTS"}; puts $$1+"=cyg$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)."+$$1 if / [CDT] _(.*)$$/' >rubydll.def
+ @DLLWRAP@ -s --def=rubydll.def -o $@
+ @rm -f rubydll.def
+endif
diff --git a/defines.h b/defines.h
index fefddee23b..77f3f40a55 100644
--- a/defines.h
+++ b/defines.h
@@ -12,54 +12,224 @@
#define RUBY
+#ifdef __cplusplus
+# ifndef HAVE_PROTOTYPES
+# define HAVE_PROTOTYPES 1
+# endif
+# ifndef HAVE_STDARG_PROTOTYPES
+# define HAVE_STDARG_PROTOTYPES 1
+# endif
+#endif
+
+#undef _
+#ifdef HAVE_PROTOTYPES
+# define _(args) args
+#else
+# define _(args) ()
+#endif
+
+#undef __
+#ifdef HAVE_STDARG_PROTOTYPES
+# define __(args) args
+#else
+# define __(args) ()
+#endif
+
+#ifdef __cplusplus
+#define ANYARGS ...
+#else
+#define ANYARGS
+#endif
+
+#define xmalloc ruby_xmalloc
+#define xcalloc ruby_xcalloc
+#define xrealloc ruby_xrealloc
+#define xfree ruby_xfree
+
+void *xmalloc _((long));
+void *xcalloc _((long,long));
+void *xrealloc _((void*,long));
+void xfree _((void*));
+
+#if SIZEOF_LONG_LONG > 0
+# define LONG_LONG long long
+#elif SIZEOF___INT64 > 0
+# define HAVE_LONG_LONG 1
+# define LONG_LONG __int64
+# undef SIZEOF_LONG_LONG
+# define SIZEOF_LONG_LONG SIZEOF___INT64
+#endif
+
+#if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
+# define BDIGIT unsigned int
+# define SIZEOF_BDIGITS SIZEOF_INT
+# define BDIGIT_DBL unsigned LONG_LONG
+# define BDIGIT_DBL_SIGNED LONG_LONG
+#elif SIZEOF_INT*2 <= SIZEOF_LONG
+# define BDIGIT unsigned int
+# define SIZEOF_BDIGITS SIZEOF_INT
+# define BDIGIT_DBL unsigned long
+# define BDIGIT_DBL_SIGNED long
+#elif SIZEOF_SHORT*2 <= SIZEOF_LONG
+# define BDIGIT unsigned short
+# define SIZEOF_BDIGITS SIZEOF_SHORT
+# define BDIGIT_DBL unsigned long
+# define BDIGIT_DBL_SIGNED long
+#else
+# define BDIGIT unsigned short
+# define SIZEOF_BDIGITS (SIZEOF_LONG/2)
+# define BDIGIT_DBL unsigned long
+# define BDIGIT_DBL_SIGNED long
+#endif
+
+#ifdef __CYGWIN__
+#undef _WIN32
+#endif
+
+#if defined(MSDOS) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__)
+#define DOSISH 1
+#ifndef _WIN32_WCE
+# define DOSISH_DRIVE_LETTER
+#endif
+#endif
+
/* define RUBY_USE_EUC/SJIS for default kanji-code */
#ifndef DEFAULT_KCODE
-#if defined(MSDOS) || defined(__CYGWIN__) || defined(__human68k__) || defined(__MACOS__) || defined(__EMX__) || defined(OS2) || defined(NT)
+#if defined(DOSISH) || defined(__CYGWIN__) || defined(__MACOS__) || defined(OS2)
#define DEFAULT_KCODE KCODE_SJIS
#else
#define DEFAULT_KCODE KCODE_EUC
#endif
#endif
-#ifdef NeXT
-#define DYNAMIC_ENDIAN /* determine endian at runtime */
+#ifdef __NeXT__
+/* NextStep, OpenStep, Rhapsody */
+#ifndef S_IRUSR
+#define S_IRUSR 0000400 /* read permission, owner */
+#endif
+#ifndef S_IRGRP
+#define S_IRGRP 0000040 /* read permission, group */
+#endif
+#ifndef S_IROTH
+#define S_IROTH 0000004 /* read permission, other */
+#endif
+#ifndef S_IWUSR
+#define S_IWUSR 0000200 /* write permission, owner */
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP 0000020 /* write permission, group */
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH 0000002 /* write permission, other */
+#endif
+#ifndef S_IXUSR
+#define S_IXUSR 0000100 /* execute/search permission, owner */
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP 0000010 /* execute/search permission, group */
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH 0000001 /* execute/search permission, other */
+#endif
+#ifndef S_IRWXU
+#define S_IRWXU 0000700 /* read, write, execute permissions, owner */
+#endif
+#ifndef S_IRWXG
+#define S_IRWXG 0000070 /* read, write, execute permissions, group */
+#endif
+#ifndef S_IRWXO
+#define S_IRWXO 0000007 /* read, write, execute permissions, other */
+#endif
+#ifndef S_ISBLK
+#define S_ISBLK(mode) (((mode) & (0170000)) == (0060000))
+#endif
+#ifndef S_ISCHR
+#define S_ISCHR(mode) (((mode) & (0170000)) == (0020000))
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode) & (0170000)) == (0040000))
+#endif
+#ifndef S_ISFIFO
+#define S_ISFIFO(mode) (((mode) & (0170000)) == (0010000))
+#endif
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & (0170000)) == (0100000))
+#endif
+/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may
+ result in a different endian. Instead trust __BIG_ENDIAN__ and
+ __LITTLE_ENDIAN__ which are set correctly by -arch. */
+#undef WORDS_BIGENDIAN
+#ifdef __BIG_ENDIAN__
+#define WORDS_BIGENDIAN
+#endif
#ifndef __APPLE__
-#define S_IXUSR _S_IXUSR /* execute/search permission, owner */
+/* NextStep, OpenStep (but not Rhapsody) */
+#ifndef GETPGRP_VOID
+#define GETPGRP_VOID 1
#endif
-#define S_IXGRP 0000010 /* execute/search permission, group */
-#define S_IXOTH 0000001 /* execute/search permission, other */
-
-#define HAVE_SYS_WAIT_H /* configure fails to find this */
+#ifndef WNOHANG
+#define WNOHANG 01
+#endif
+#ifndef WUNTRACED
+#define WUNTRACED 02
+#endif
+#ifndef X_OK
+#define X_OK 1
+#endif
+typedef int pid_t;
+#endif /* __APPLE__ */
#endif /* NeXT */
-#ifdef NT
+#ifdef _WIN32
#include "win32/win32.h"
#endif
-#if defined __CYGWIN__
-# undef EXTERN
-# if defined USEIMPORTLIB
-# define EXTERN extern __declspec(dllimport)
-# else
-# define EXTERN extern __declspec(dllexport)
+#if defined(__VMS)
+#include "vms/vms.h"
+#endif
+
+#if defined(__BEOS__)
+#include <net/socket.h> /* intern.h needs fd_set definition */
+#endif
+
+#undef RUBY_EXTERN
+#if defined _WIN32 && !defined __GNUC__
+# ifndef RUBY_EXPORT
+# define RUBY_EXTERN extern __declspec(dllimport)
# endif
#endif
-#ifndef EXTERN
-#define EXTERN extern
+#ifndef RUBY_EXTERN
+#define RUBY_EXTERN extern
#endif
-#ifdef sparc
-#define FLUSH_REGISTER_WINDOWS asm("ta 3")
-#else
-#define FLUSH_REGISTER_WINDOWS /* empty */
+#ifndef EXTERN
+#define EXTERN RUBY_EXTERN /* deprecated */
#endif
-#if defined(MSDOS) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__)
-#define DOSISH 1
+#if defined(sparc) || defined(__sparc__)
+static inline void
+flush_register_windows(void)
+{
+ asm
+#ifdef __GNUC__
+ volatile
+#endif
+# if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
+ ("flushw")
+# elif defined(linux) || defined(__linux__)
+ ("ta 0x83")
+# else /* Solaris, OpenBSD, NetBSD, etc. */
+ ("ta 0x03")
+# endif /* trap always to flush register windows if we are on a Sparc system */
+ ;
+}
+# define FLUSH_REGISTER_WINDOWS flush_register_windows()
+#else
+# define FLUSH_REGISTER_WINDOWS ((void)0)
#endif
-#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(OS2)
+#if defined(DOSISH)
#define PATH_SEP ";"
#elif defined(riscos)
#define PATH_SEP ","
@@ -69,12 +239,13 @@
#define PATH_SEP_CHAR PATH_SEP[0]
#if defined(__human68k__)
-#undef HAVE_RANDOM
-#undef HAVE_SETITIMER
+#define PATH_ENV "path"
+#else
+#define PATH_ENV "PATH"
#endif
-#if defined(DJGPP) || defined(__BOW__) || defined __CYGWIN__
-#undef HAVE_SETITIMER
+#if defined(DOSISH) && !defined(__human68k__) && !defined(__EMX__)
+#define ENV_IGNORECASE
#endif
#ifndef RUBY_PLATFORM
diff --git a/dir.c b/dir.c
index 224965186d..2de990ad8a 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-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -17,24 +17,24 @@
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#else
-# define MAXPATHLEN 1024
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if defined HAVE_DIRENT_H && !defined NT
+#if defined HAVE_DIRENT_H && !defined _WIN32
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
-#elif defined HAVE_DIRECT_H && !defined NT
+#elif defined HAVE_DIRECT_H && !defined _WIN32
# include <direct.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
+# if !defined __NeXT__
+# define NAMLEN(dirent) (dirent)->d_namlen
+# else
+# /* On some versions of NextStep, d_namlen is always zero, so avoid it. */
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+# endif
# if HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
@@ -44,8 +44,8 @@
# if HAVE_NDIR_H
# include <ndir.h>
# endif
-# if defined(NT)
-# include "missing/dir.h"
+# ifdef _WIN32
+# include "win32/dir.h"
# endif
#endif
@@ -61,46 +61,44 @@ char *strchr _((char*,char));
#include <ctype.h>
+#include "util.h"
+
#ifndef HAVE_LSTAT
-#define lstat rb_sys_stat
+#define lstat(path,st) stat(path,st)
#endif
#define FNM_NOESCAPE 0x01
#define FNM_PATHNAME 0x02
-#define FNM_PERIOD 0x04
-#define FNM_NOCASE 0x08
+#define FNM_DOTMATCH 0x04
+#define FNM_CASEFOLD 0x08
#define FNM_NOMATCH 1
#define FNM_ERROR 2
#define downcase(c) (nocase && ISUPPER(c) ? tolower(c) : (c))
+#ifndef CharNext /* defined as CharNext[AW] on Windows. */
+# if defined(DJGPP)
+# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
+# else
+# define CharNext(p) ((p) + 1)
+# endif
+#endif
+
#if defined DOSISH
#define isdirsep(c) ((c) == '/' || (c) == '\\')
-static char *
-find_dirsep(s)
- char *s;
-{
- while (*s) {
- if (isdirsep(*s))
- return s;
- s++;
- }
- return 0;
-}
#else
#define isdirsep(c) ((c) == '/')
-#define find_dirsep(s) strchr(s, '/')
#endif
static char *
range(pat, test, flags)
- char *pat;
- char test;
+ const char *pat;
+ int test;
int flags;
{
int not, ok = 0;
- int nocase = flags & FNM_NOCASE;
+ int nocase = flags & FNM_CASEFOLD;
int escape = !(flags & FNM_NOESCAPE);
not = *pat == '!' || *pat == '^';
@@ -109,47 +107,48 @@ range(pat, test, flags)
test = downcase(test);
- while (*pat) {
+ while (*pat != ']') {
int cstart, cend;
+ if (escape && *pat == '\\')
+ pat++;
cstart = cend = *pat++;
- if (cstart == ']')
- return ok == not ? 0 : pat;
- else if (escape && cstart == '\\')
- cstart = cend = *pat++;
+ if (!cstart)
+ return NULL;
if (*pat == '-' && pat[1] != ']') {
- if (escape && pat[1] == '\\')
+ pat++;
+ if (escape && *pat == '\\')
pat++;
- cend = pat[1];
+ cend = *pat++;
if (!cend)
- return 0;
- pat += 2;
+ return NULL;
}
if (downcase(cstart) <= test && test <= downcase(cend))
ok = 1;
}
- return 0;
+ return ok == not ? NULL : (char *)pat + 1;
}
+#define ISDIRSEP(c) (pathname && isdirsep(c))
#define PERIOD(s) (period && *(s) == '.' && \
- ((s) == string || pathname && isdirsep(*(s))))
+ ((s) == string || ISDIRSEP((s)[-1])))
static int
fnmatch(pat, string, flags)
- char *pat;
- char *string;
+ const char *pat;
+ const char *string;
int flags;
{
int c;
int test;
- char *s = string;
+ const char *s = string;
int escape = !(flags & FNM_NOESCAPE);
int pathname = flags & FNM_PATHNAME;
- int period = flags & FNM_PERIOD;
- int nocase = flags & FNM_NOCASE;
+ int period = !(flags & FNM_DOTMATCH);
+ int nocase = flags & FNM_CASEFOLD;
while (c = *pat++) {
switch (c) {
case '?':
- if (!*s || pathname && isdirsep(*s) || PERIOD(s))
+ if (!*s || ISDIRSEP(*s) || PERIOD(s))
return FNM_NOMATCH;
s++;
break;
@@ -161,15 +160,17 @@ fnmatch(pat, string, flags)
return FNM_NOMATCH;
if (!c) {
- if (pathname && find_dirsep(s))
+ if (pathname && *rb_path_next(s))
return FNM_NOMATCH;
else
return 0;
}
- else if (pathname && isdirsep(c)) {
- s = find_dirsep(s);
- if (s)
+ else if (ISDIRSEP(c)) {
+ s = rb_path_next(s);
+ if (*s) {
+ s++;
break;
+ }
return FNM_NOMATCH;
}
@@ -177,20 +178,20 @@ fnmatch(pat, string, flags)
test = downcase(test);
pat--;
while (*s) {
- if ((c == '[' || downcase(*s) == test) &&
- !fnmatch(pat, s, flags & ~FNM_PERIOD))
+ if ((c == '?' || c == '[' || downcase(*s) == test) &&
+ !fnmatch(pat, s, flags | FNM_DOTMATCH))
return 0;
- else if (pathname && isdirsep(*s))
+ else if (ISDIRSEP(*s))
break;
s++;
}
return FNM_NOMATCH;
-
+
case '[':
- if (!*s || pathname && isdirsep(*s) || PERIOD(s))
+ if (!*s || ISDIRSEP(*s) || PERIOD(s))
return FNM_NOMATCH;
pat = range(pat, *s, flags);
- if (!pat)
+ if (pat == NULL)
return FNM_NOMATCH;
s++;
break;
@@ -198,7 +199,7 @@ fnmatch(pat, string, flags)
case '\\':
if (escape
#if defined DOSISH
- && *pat && strchr("*?[\\", *pat)
+ && *pat && strchr("*?[]\\", *pat)
#endif
) {
c = *pat;
@@ -211,7 +212,7 @@ fnmatch(pat, string, flags)
default:
#if defined DOSISH
- if (pathname && isdirsep(c) && isdirsep(*s))
+ if (ISDIRSEP(c) && isdirsep(*s))
;
else
#endif
@@ -226,62 +227,92 @@ fnmatch(pat, string, flags)
VALUE rb_cDir;
+struct dir_data {
+ DIR *dir;
+ char *path;
+};
+
static void
free_dir(dir)
- DIR *dir;
+ struct dir_data *dir;
{
- if (dir) closedir(dir);
+ if (dir) {
+ if (dir->dir) closedir(dir->dir);
+ if (dir->path) free(dir->path);
+ }
+ free(dir);
}
static VALUE dir_close _((VALUE));
+static VALUE dir_s_alloc _((VALUE));
static VALUE
-dir_s_new(argc, argv, klass)
- int argc;
- VALUE *argv;
+dir_s_alloc(klass)
VALUE klass;
{
- VALUE obj = Data_Wrap_Struct(klass, 0, free_dir, 0);
+ struct dir_data *dirp;
+ VALUE obj = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dirp);
- rb_obj_call_init(obj, argc, argv);
+ dirp->dir = NULL;
+ dirp->path = NULL;
return obj;
}
+/*
+ * call-seq:
+ * Dir.new( string ) -> aDir
+ *
+ * Returns a new directory object for the named directory.
+ */
static VALUE
dir_initialize(dir, dirname)
VALUE dir, dirname;
{
- DIR *dirp;
-
- Check_SafeStr(dirname);
- if (DATA_PTR(dir)) closedir(DATA_PTR(dir));
- DATA_PTR(dir) = NULL;
- dirp = opendir(RSTRING(dirname)->ptr);
- if (dirp == NULL) {
+ struct dir_data *dp;
+
+ SafeStringValue(dirname);
+ Data_Get_Struct(dir, struct dir_data, dp);
+ if (dp->dir) closedir(dp->dir);
+ if (dp->path) free(dp->path);
+ dp->dir = NULL;
+ dp->path = NULL;
+ dp->dir = opendir(RSTRING(dirname)->ptr);
+ if (dp->dir == NULL) {
if (errno == EMFILE || errno == ENFILE) {
rb_gc();
- dirp = opendir(RSTRING(dirname)->ptr);
+ dp->dir = opendir(RSTRING(dirname)->ptr);
}
- if (dirp == NULL) {
+ if (dp->dir == NULL) {
rb_sys_fail(RSTRING(dirname)->ptr);
}
}
- DATA_PTR(dir) = dirp;
+ dp->path = strdup(RSTRING(dirname)->ptr);
return dir;
}
+/*
+ * call-seq:
+ * Dir.open( string ) => aDir
+ * Dir.open( string ) {| aDir | block } => anObject
+ *
+ * With no block, <code>open</code> is a synonym for
+ * <code>Dir::new</code>. If a block is present, it is passed
+ * <i>aDir</i> as a parameter. The directory is closed at the end of
+ * the block, and <code>Dir::open</code> returns the value of the
+ * block.
+ */
static VALUE
dir_s_open(klass, dirname)
VALUE klass, dirname;
{
- VALUE dir = Data_Wrap_Struct(klass, 0, free_dir, 0);
+ struct dir_data *dp;
+ VALUE dir = Data_Make_Struct(klass, struct dir_data, 0, free_dir, dp);
dir_initialize(dir, dirname);
if (rb_block_given_p()) {
- rb_ensure(rb_yield, dir, dir_close, dir);
- return Qnil;
+ return rb_ensure(rb_yield, dir, dir_close, dir);
}
return dir;
@@ -293,23 +324,56 @@ dir_closed()
rb_raise(rb_eIOError, "closed directory");
}
-#define GetDIR(obj, dirp) {\
- Data_Get_Struct(obj, DIR, dirp);\
- if (dirp == NULL) dir_closed();\
+#define GetDIR(obj, dirp) do {\
+ Data_Get_Struct(obj, struct dir_data, dirp);\
+ if (dirp->dir == NULL) dir_closed();\
+} while (0)
+
+/*
+ * call-seq:
+ * dir.path => string or nil
+ *
+ * Returns the path parameter passed to <em>dir</em>'s constructor.
+ *
+ * d = Dir.new("..")
+ * d.path #=> ".."
+ */
+static VALUE
+dir_path(dir)
+ VALUE dir;
+{
+ struct dir_data *dirp;
+
+ GetDIR(dir, dirp);
+ if (!dirp->path) return Qnil;
+ return rb_str_new2(dirp->path);
}
+/*
+ * call-seq:
+ * dir.read => string or nil
+ *
+ * Reads the next entry from <em>dir</em> and returns it as a string.
+ * Returns <code>nil</code> at the end of the stream.
+ *
+ * d = Dir.new("testdir")
+ * d.read #=> "."
+ * d.read #=> ".."
+ * d.read #=> "config.h"
+ */
static VALUE
dir_read(dir)
VALUE dir;
{
- DIR *dirp;
+ struct dir_data *dirp;
struct dirent *dp;
GetDIR(dir, dirp);
errno = 0;
- dp = readdir(dirp);
- if (dp)
+ dp = readdir(dirp->dir);
+ if (dp) {
return rb_tainted_str_new(dp->d_name, NAMLEN(dp));
+ }
else if (errno == 0) { /* end of stream */
return Qnil;
}
@@ -319,127 +383,339 @@ dir_read(dir)
return Qnil; /* not reached */
}
+/*
+ * call-seq:
+ * dir.each { |filename| block } => dir
+ *
+ * Calls the block once for each entry in this directory, passing the
+ * filename of each entry as a parameter to the block.
+ *
+ * d = Dir.new("testdir")
+ * d.each {|x| puts "Got #{x}" }
+ *
+ * <em>produces:</em>
+ *
+ * Got .
+ * Got ..
+ * Got config.h
+ * Got main.rb
+ */
static VALUE
dir_each(dir)
VALUE dir;
{
- DIR *dirp;
+ struct dir_data *dirp;
struct dirent *dp;
GetDIR(dir, dirp);
- for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
+ for (dp = readdir(dirp->dir); dp != NULL; dp = readdir(dirp->dir)) {
rb_yield(rb_tainted_str_new(dp->d_name, NAMLEN(dp)));
- if (DATA_PTR(dir) == NULL) dir_closed();
+ if (dirp->dir == NULL) dir_closed();
}
return dir;
}
+/*
+ * call-seq:
+ * dir.pos => integer
+ * dir.tell => integer
+ *
+ * Returns the current position in <em>dir</em>. See also
+ * <code>Dir#seek</code>.
+ *
+ * d = Dir.new("testdir")
+ * d.tell #=> 0
+ * d.read #=> "."
+ * d.tell #=> 12
+ */
static VALUE
dir_tell(dir)
VALUE dir;
{
#ifdef HAVE_TELLDIR
- DIR *dirp;
+ struct dir_data *dirp;
long pos;
GetDIR(dir, dirp);
- pos = telldir(dirp);
+ pos = telldir(dirp->dir);
return rb_int2inum(pos);
#else
rb_notimplement();
#endif
}
+/*
+ * call-seq:
+ * dir.seek( integer ) => dir
+ *
+ * Seeks to a particular location in <em>dir</em>. <i>integer</i>
+ * must be a value returned by <code>Dir#tell</code>.
+ *
+ * d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
+ * d.read #=> "."
+ * i = d.tell #=> 12
+ * d.read #=> ".."
+ * d.seek(i) #=> #<Dir:0x401b3c40>
+ * d.read #=> ".."
+ */
static VALUE
dir_seek(dir, pos)
VALUE dir, pos;
{
- DIR *dirp;
+ struct dir_data *dirp;
#ifdef HAVE_SEEKDIR
GetDIR(dir, dirp);
- seekdir(dirp, NUM2INT(pos));
+ seekdir(dirp->dir, NUM2INT(pos));
return dir;
#else
rb_notimplement();
#endif
}
+/*
+ * call-seq:
+ * dir.pos( integer ) => integer
+ *
+ * Synonym for <code>Dir#seek</code>, but returns the position
+ * parameter.
+ *
+ * d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
+ * d.read #=> "."
+ * i = d.pos #=> 12
+ * d.read #=> ".."
+ * d.pos = i #=> 12
+ * d.read #=> ".."
+ */
+static VALUE
+dir_set_pos(dir, pos)
+ VALUE dir, pos;
+{
+ dir_seek(dir, pos);
+ return pos;
+}
+
+/*
+ * call-seq:
+ * dir.rewind => dir
+ *
+ * Repositions <em>dir</em> to the first entry.
+ *
+ * d = Dir.new("testdir")
+ * d.read #=> "."
+ * d.rewind #=> #<Dir:0x401b3fb0>
+ * d.read #=> "."
+ */
static VALUE
dir_rewind(dir)
VALUE dir;
{
- DIR *dirp;
+ struct dir_data *dirp;
GetDIR(dir, dirp);
- rewinddir(dirp);
+ rewinddir(dirp->dir);
return dir;
}
+/*
+ * call-seq:
+ * dir.close => nil
+ *
+ * Closes the directory stream. Any further attempts to access
+ * <em>dir</em> will raise an <code>IOError</code>.
+ *
+ * d = Dir.new("testdir")
+ * d.close #=> nil
+ */
static VALUE
dir_close(dir)
VALUE dir;
{
- DIR *dirp;
+ struct dir_data *dirp;
- Data_Get_Struct(dir, DIR, dirp);
- if (dirp == NULL) dir_closed();
- closedir(dirp);
- DATA_PTR(dir) = NULL;
+ GetDIR(dir, dirp);
+ closedir(dirp->dir);
+ dirp->dir = NULL;
return Qnil;
}
+static void
+dir_chdir(path)
+ VALUE path;
+{
+ if (chdir(RSTRING(path)->ptr) < 0)
+ rb_sys_fail(RSTRING(path)->ptr);
+}
+
+static int chdir_blocking = 0;
+static VALUE chdir_thread = Qnil;
+
+struct chdir_data {
+ VALUE old_path, new_path;
+ int done;
+};
+
+static VALUE
+chdir_yield(args)
+ struct chdir_data *args;
+{
+ dir_chdir(args->new_path);
+ args->done = Qtrue;
+ chdir_blocking++;
+ if (chdir_thread == Qnil)
+ chdir_thread = rb_thread_current();
+ return rb_yield(args->new_path);
+}
+
+static VALUE
+chdir_restore(args)
+ struct chdir_data *args;
+{
+ if (args->done) {
+ chdir_blocking--;
+ if (chdir_blocking == 0)
+ chdir_thread = Qnil;
+ dir_chdir(args->old_path);
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * Dir.chdir( [ string] ) => 0
+ * Dir.chdir( [ string] ) {| path | block } => anObject
+ *
+ * Changes the current working directory of the process to the given
+ * string. When called without an argument, changes the directory to
+ * the value of the environment variable <code>HOME</code>, or
+ * <code>LOGDIR</code>. <code>SystemCallError</code> (probably
+ * <code>Errno::ENOENT</code>) if the target directory does not exist.
+ *
+ * If a block is given, it is passed the name of the new current
+ * directory, and the block is executed with that as the current
+ * directory. The original working directory is restored when the block
+ * exits. The return value of <code>chdir</code> is the value of the
+ * block. <code>chdir</code> blocks can be nested, but in a
+ * multi-threaded program an error will be raised if a thread attempts
+ * to open a <code>chdir</code> block while another thread has one
+ * open.
+ *
+ * Dir.chdir("/var/spool/mail")
+ * puts Dir.pwd
+ * Dir.chdir("/tmp") do
+ * puts Dir.pwd
+ * Dir.chdir("/usr") do
+ * puts Dir.pwd
+ * end
+ * puts Dir.pwd
+ * end
+ * puts Dir.pwd
+ *
+ * <em>produces:</em>
+ *
+ * /var/spool/mail
+ * /tmp
+ * /usr
+ * /tmp
+ * /var/spool/mail
+ */
static VALUE
dir_s_chdir(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
- VALUE path;
- char *dist = "";
+ VALUE path = Qnil;
rb_secure(2);
if (rb_scan_args(argc, argv, "01", &path) == 1) {
- Check_SafeStr(path);
- dist = RSTRING(path)->ptr;
+ SafeStringValue(path);
}
else {
- dist = getenv("HOME");
+ const char *dist = getenv("HOME");
if (!dist) {
dist = getenv("LOGDIR");
+ if (!dist) rb_raise(rb_eArgError, "HOME/LOGDIR not set");
}
+ path = rb_str_new2(dist);
}
- if (chdir(dist) < 0)
- rb_sys_fail(dist);
+ if (chdir_blocking > 0) {
+ if (!rb_block_given_p() || rb_thread_current() != chdir_thread)
+ rb_warn("conflicting chdir during another chdir block");
+ }
+
+ if (rb_block_given_p()) {
+ struct chdir_data args;
+ char *cwd = my_getcwd();
+
+ args.old_path = rb_tainted_str_new2(cwd); free(cwd);
+ args.new_path = path;
+ args.done = Qfalse;
+ return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);
+ }
+ dir_chdir(path);
return INT2FIX(0);
}
+/*
+ * call-seq:
+ * Dir.getwd => string
+ * Dir.pwd => string
+ *
+ * Returns the path to the current working directory of this process as
+ * a string.
+ *
+ * Dir.chdir("/tmp") #=> 0
+ * Dir.getwd #=> "/tmp"
+ */
static VALUE
dir_s_getwd(dir)
VALUE dir;
{
- char path[MAXPATHLEN];
+ char *path;
+ VALUE cwd;
-#ifdef HAVE_GETCWD
- if (getcwd(path, sizeof(path)) == 0) rb_sys_fail(path);
-#else
- extern char *getwd();
- if (getwd(path) == 0) rb_sys_fail(path);
-#endif
+ rb_secure(4);
+ path = my_getcwd();
+ cwd = rb_tainted_str_new2(path);
- return rb_tainted_str_new2(path);
+ free(path);
+ return cwd;
+}
+
+static void check_dirname _((volatile VALUE *));
+static void
+check_dirname(dir)
+ volatile VALUE *dir;
+{
+ char *path, *pend;
+
+ SafeStringValue(*dir);
+ rb_secure(2);
+ path = RSTRING(*dir)->ptr;
+ if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) {
+ *dir = rb_str_new(path, pend - path);
+ }
}
+/*
+ * call-seq:
+ * Dir.chroot( string ) => 0
+ *
+ * Changes this process's idea of the file system root. Only a
+ * privileged process may make this call. Not available on all
+ * platforms. On Unix systems, see <code>chroot(2)</code> for more
+ * information.
+ */
static VALUE
dir_s_chroot(dir, path)
VALUE dir, path;
{
#if defined(HAVE_CHROOT) && !defined(__CHECKER__)
- rb_secure(2);
- Check_SafeStr(path);
+ check_dirname(&path);
if (chroot(RSTRING(path)->ptr) == -1)
rb_sys_fail(RSTRING(path)->ptr);
@@ -451,6 +727,19 @@ dir_s_chroot(dir, path)
#endif
}
+/*
+ * call-seq:
+ * Dir.mkdir( string [, integer] ) => 0
+ *
+ * Makes a new directory named by <i>string</i>, with permissions
+ * specified by the optional parameter <i>anInteger</i>. The
+ * permissions may be modified by the value of
+ * <code>File::umask</code>, and are ignored on NT. Raises a
+ * <code>SystemCallError</code> if the directory cannot be created. See
+ * also the discussion of permissions in the class documentation for
+ * <code>File</code>.
+ *
+ */
static VALUE
dir_s_mkdir(argc, argv, obj)
int argc;
@@ -467,9 +756,8 @@ dir_s_mkdir(argc, argv, obj)
mode = 0777;
}
- Check_SafeStr(path);
- rb_secure(2);
-#if !defined(NT)
+ check_dirname(&path);
+#ifndef _WIN32
if (mkdir(RSTRING(path)->ptr, mode) == -1)
rb_sys_fail(RSTRING(path)->ptr);
#else
@@ -480,12 +768,20 @@ dir_s_mkdir(argc, argv, obj)
return INT2FIX(0);
}
+/*
+ * call-seq:
+ * Dir.delete( string ) => 0
+ * Dir.rmdir( string ) => 0
+ * Dir.unlink( string ) => 0
+ *
+ * Deletes the named directory. Raises a subclass of
+ * <code>SystemCallError</code> if the directory isn't empty.
+ */
static VALUE
dir_s_rmdir(obj, dir)
VALUE obj, dir;
{
- Check_SafeStr(dir);
- rb_secure(2);
+ check_dirname(&dir);
if (rmdir(RSTRING(dir)->ptr) < 0)
rb_sys_fail(RSTRING(dir)->ptr);
@@ -494,12 +790,14 @@ dir_s_rmdir(obj, dir)
/* Return nonzero if S has any special globbing chars in it. */
static int
-has_magic(s, send)
- char *s, *send;
+has_magic(s, send, flags)
+ const char *s, *send;
+ int flags;
{
- register char *p = s;
+ register const char *p = s;
register char c;
int open = 0;
+ int escape = !(flags & FNM_NOESCAPE);
while ((c = *p++) != '\0') {
switch (c) {
@@ -507,8 +805,8 @@ has_magic(s, send)
case '*':
return Qtrue;
- case '[': /* Only accept an open brace if there is a close */
- open++; /* brace to match it. Bracket expressions must be */
+ case '[': /* Only accept an open brace if there is a close */
+ open++; /* brace to match it. Bracket expressions must be */
continue; /* complete, according to Posix.2 */
case ']':
if (open)
@@ -516,7 +814,7 @@ has_magic(s, send)
continue;
case '\\':
- if (*p++ == '\0')
+ if (escape && *p++ == '\0')
return Qfalse;
}
@@ -527,7 +825,7 @@ has_magic(s, send)
static char*
extract_path(p, pend)
- char *p, *pend;
+ const char *p, *pend;
{
char *alloc;
int len;
@@ -536,7 +834,7 @@ extract_path(p, pend)
alloc = ALLOC_N(char, len+1);
memcpy(alloc, p, len);
if (len > 1 && pend[-1] == '/'
-#if defined DOSISH
+#if defined DOSISH_DRIVE_LETTER
&& pend[-2] != ':'
#endif
) {
@@ -551,9 +849,9 @@ extract_path(p, pend)
static char*
extract_elem(path)
- char *path;
+ const char *path;
{
- char *pend;
+ const char *pend;
pend = strchr(path, '/');
if (!pend) pend = path + strlen(path);
@@ -561,32 +859,95 @@ extract_elem(path)
return extract_path(path, pend);
}
+static void
+remove_backslashes(p)
+ char *p;
+{
+ char *pend = p + strlen(p);
+ char *t = p;
+
+ while (p < pend) {
+ if (*p == '\\') {
+ if (++p == pend) break;
+ }
+ *t++ = *p++;
+ }
+ *t = '\0';
+}
+
#ifndef S_ISDIR
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif
-void
-rb_glob_helper(path, flag, func, arg)
+struct glob_args {
+ void (*func) _((const char*, VALUE));
+ const char *c;
+ VALUE v;
+};
+
+static VALUE glob_func_caller _((VALUE));
+
+static VALUE
+glob_func_caller(val)
+ VALUE val;
+{
+ struct glob_args *args = (struct glob_args *)val;
+ (*args->func)(args->c, args->v);
+ return Qnil;
+}
+
+static int
+glob_call_func(func, path, arg)
+ void (*func) _((const char*, VALUE));
+ const char *path;
+ VALUE arg;
+{
+ int status;
+ struct glob_args args;
+
+ args.func = func;
+ args.c = path;
+ args.v = arg;
+
+ rb_protect(glob_func_caller, (VALUE)&args, &status);
+ return status;
+}
+
+static int
+glob_helper(path, sub, flags, func, arg)
char *path;
- int flag;
- void (*func)();
+ char *sub;
+ int flags;
+ void (*func) _((const char*, VALUE));
VALUE arg;
{
struct stat st;
char *p, *m;
+ int status = 0;
- if (!has_magic(path, 0)) {
- if (rb_sys_stat(path, &st) == 0) {
- (*func)(path, arg);
+ p = sub ? sub : path;
+ if (!has_magic(p, 0, flags)) {
+#if defined DOSISH
+ remove_backslashes(path);
+#else
+ if (!(flags & FNM_NOESCAPE)) remove_backslashes(p);
+#endif
+ if (lstat(path, &st) == 0) {
+ status = glob_call_func(func, path, arg);
+ if (status) return status;
+ }
+ else if (errno != ENOENT) {
+ /* In case stat error is other than ENOENT and
+ we may want to know what is wrong. */
+ rb_sys_warning(path);
}
- return;
+ return 0;
}
- p = path;
- while (p) {
+ while (p && !status) {
if (*p == '/') p++;
m = strchr(p, '/');
- if (has_magic(p, m)) {
+ if (has_magic(p, m, flags)) {
char *dir, *base, *magic, *buf;
DIR *dirp;
struct dirent *dp;
@@ -595,148 +956,192 @@ rb_glob_helper(path, flag, func, arg)
struct d_link {
char *path;
struct d_link *next;
- } *tmp, *link = 0;
+ } *tmp, *link, **tail = &link;
base = extract_path(path, p);
if (path == p) dir = ".";
else dir = base;
magic = extract_elem(p);
- if (m && strcmp(magic, "**") == 0) {
- recursive = 1;
- buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
- sprintf(buf, "%s%s%s", base, (*base)?"":".", m);
- rb_glob_helper(buf, flag, func, arg);
- free(buf);
- }
- if (rb_sys_stat(dir, &st) < 0) {
+ if (stat(dir, &st) < 0) {
+ if (errno != ENOENT) rb_sys_warning(dir);
free(base);
+ free(magic);
break;
}
if (S_ISDIR(st.st_mode)) {
- dirp = opendir(dir);
- if (dirp == NULL) {
- free(base);
- break;
- }
+ if (m && strcmp(magic, "**") == 0) {
+ int n = strlen(base);
+ recursive = 1;
+ buf = ALLOC_N(char, n+strlen(m)+3);
+ sprintf(buf, "%s%s", base, *base ? m : m+1);
+ status = glob_helper(buf, buf+n, flags, func, arg);
+ free(buf);
+ if (status) goto finalize;
+ }
+ dirp = opendir(dir);
+ if (dirp == NULL) {
+ rb_sys_warning(dir);
+ free(base);
+ free(magic);
+ break;
+ }
}
else {
- free(base);
- break;
+ free(base);
+ free(magic);
+ break;
}
-
-#if defined DOSISH
+
+#if defined DOSISH_DRIVE_LETTER
#define BASE (*base && !((isdirsep(*base) && !base[1]) || (base[1] == ':' && isdirsep(base[2]) && !base[3])))
#else
-#define BASE (*base && !(*base == '/' && !base[1]))
+#define BASE (*base && !(isdirsep(*base) && !base[1]))
#endif
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if (recursive) {
if (strcmp(".", dp->d_name) == 0 || strcmp("..", dp->d_name) == 0)
continue;
+ if (fnmatch("*", dp->d_name, flags) != 0)
+ continue;
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
- sprintf(buf, "%s%s%s/**%s", base, (BASE)?"/":"", dp->d_name, m);
- sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name);
+ sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
if (lstat(buf, &st) < 0) {
+ if (errno != ENOENT) rb_sys_warning(buf);
+ free(buf);
continue;
}
if (S_ISDIR(st.st_mode)) {
- strcat(buf, "/**");
- strcat(buf, m);
- rb_glob_helper(buf, flag, func, arg);
+ char *t = buf+strlen(buf);
+ strcpy(t, "/**");
+ strcpy(t+3, m);
+ status = glob_helper(buf, t, flags, func, arg);
+ free(buf);
+ if (status) break;
+ continue;
}
free(buf);
continue;
}
- if (fnmatch(magic, dp->d_name, flag) == 0) {
+ if (fnmatch(magic, dp->d_name, flags) == 0) {
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2);
- sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name);
+ sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
if (!m) {
- (*func)(buf, arg);
+ status = glob_call_func(func, buf, arg);
free(buf);
+ if (status) break;
continue;
}
tmp = ALLOC(struct d_link);
tmp->path = buf;
- tmp->next = link;
- link = tmp;
+ *tail = tmp;
+ tail = &tmp->next;
}
}
closedir(dirp);
+ finalize:
+ *tail = 0;
free(base);
free(magic);
- while (link) {
- stat(link->path, &st); /* should success */
- if (S_ISDIR(st.st_mode)) {
- int len = strlen(link->path);
- int mlen = strlen(m);
- char *t = ALLOC_N(char, len+mlen+1);
-
- sprintf(t, "%s%s", link->path, m);
- rb_glob_helper(t, flag, func, arg);
- free(t);
+ if (link) {
+ while (link) {
+ if (status == 0) {
+ if (stat(link->path, &st) == 0) {
+ if (S_ISDIR(st.st_mode)) {
+ int len = strlen(link->path);
+ int mlen = strlen(m);
+ char *t = ALLOC_N(char, len+mlen+1);
+
+ sprintf(t, "%s%s", link->path, m);
+ status = glob_helper(t, t+len, flags, func, arg);
+ free(t);
+ }
+ }
+ else {
+ rb_sys_warning(link->path);
+ }
+ }
+ tmp = link;
+ link = link->next;
+ free(tmp->path);
+ free(tmp);
}
- tmp = link;
- link = link->next;
- free(tmp->path);
- free(tmp);
+ break;
}
}
p = m;
}
+ return status;
+}
+
+static int
+rb_glob2(path, flags, func, arg)
+ const char *path;
+ int flags;
+ void (*func) _((const char*, VALUE));
+ VALUE arg;
+{
+ char *buf;
+ int status;
+
+ buf = ALLOC_N(char, strlen(path)+1);
+ strcpy(buf, path);
+ status = glob_helper(buf, 0, flags, func, arg);
+ free(buf);
+ return status;
}
void
rb_glob(path, func, arg)
- char *path;
- void (*func)();
+ const char *path;
+ void (*func) _((const char*, VALUE));
VALUE arg;
{
- rb_glob_helper(path, FNM_PERIOD|FNM_PATHNAME, func, arg);
+ int status = rb_glob2(path, 0, func, arg);
+
+ if (status) rb_jump_tag(status);
}
void
-rb_iglob(path, func, arg)
- char *path;
- void (*func)();
+rb_globi(path, func, arg)
+ const char *path;
+ void (*func) _((const char*, VALUE));
VALUE arg;
{
- rb_glob_helper(path, FNM_PERIOD|FNM_PATHNAME|FNM_NOCASE, func, arg);
+ int status = rb_glob2(path, FNM_CASEFOLD, func, arg);
+
+ if (status) rb_jump_tag(status);
}
static void
push_pattern(path, ary)
- char *path;
+ const char *path;
VALUE ary;
{
- VALUE str = rb_tainted_str_new2(path);
-
- if (ary) {
- rb_ary_push(ary, str);
- }
- else {
- rb_yield(str);
- }
+ rb_ary_push(ary, rb_tainted_str_new2(path));
}
-static void
-push_globs(ary, s)
+static int
+push_globs(ary, s, flags)
VALUE ary;
- char *s;
+ const char *s;
+ int flags;
{
- rb_glob(s, push_pattern, ary);
+ return rb_glob2(s, flags, push_pattern, ary);
}
-static void
-push_braces(ary, s)
+static int
+push_braces(ary, s, flags)
VALUE ary;
- char *s;
+ const char *s;
+ int flags;
{
- char buffer[MAXPATHLEN], *buf = buffer;
- char *p, *t, *b;
- char *lbrace, *rbrace;
+ char *buf, *b;
+ const char *p, *t;
+ const char *lbrace, *rbrace;
int nest = 0;
+ int status = 0;
p = s;
lbrace = rbrace = 0;
@@ -756,10 +1161,9 @@ push_braces(ary, s)
p++;
}
- if (lbrace) {
+ if (lbrace && rbrace) {
int len = strlen(s);
- if (len >= MAXPATHLEN)
- buf = xmalloc(len + 1);
+ buf = xmalloc(len + 1);
memcpy(buf, s, lbrace-s);
b = buf + (lbrace-s);
p = lbrace;
@@ -771,61 +1175,145 @@ push_braces(ary, s)
}
memcpy(b, t, p-t);
strcpy(b+(p-t), rbrace+1);
- push_braces(ary, buf);
+ status = push_braces(ary, buf, flags);
+ if (status) break;
}
- if (buf != buffer)
- free(buf);
+ free(buf);
}
else {
- push_globs(ary, s);
+ status = push_globs(ary, s, flags);
}
+
+ return status;
}
-#define isdelim(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\0')
+#define isdelim(c) ((c)=='\0')
static VALUE
-dir_s_glob(dir, str)
- VALUE dir, str;
+rb_push_glob(str, flags)
+ VALUE str;
+ int flags;
{
- char *p, *pend;
- char buffer[MAXPATHLEN], *buf = buffer;
+ const char *p, *pend;
+ char *buf;
char *t;
- int nest;
- VALUE ary = 0;
+ int nest, maxnest;
+ int status = 0;
+ int noescape = flags & FNM_NOESCAPE;
+ VALUE ary;
- Check_SafeStr(str);
- if (!rb_block_given_p()) {
- ary = rb_ary_new();
- }
- if (RSTRING(str)->len >= MAXPATHLEN)
- buf = xmalloc(RSTRING(str)->len + 1);
+ ary = rb_ary_new();
+ SafeStringValue(str);
+ buf = xmalloc(RSTRING(str)->len + 1);
p = RSTRING(str)->ptr;
pend = p + RSTRING(str)->len;
while (p < pend) {
t = buf;
- nest = 0;
+ nest = maxnest = 0;
while (p < pend && isdelim(*p)) p++;
while (p < pend && !isdelim(*p)) {
- if (*p == '{') nest+=2;
- if (*p == '}') nest+=3;
+ if (*p == '{') nest++, maxnest++;
+ if (*p == '}') nest--;
+ if (!noescape && *p == '\\') {
+ *t++ = *p++;
+ if (p == pend) break;
+ }
*t++ = *p++;
}
*t = '\0';
- if (nest == 0) {
- push_globs(ary, buf);
+ if (maxnest == 0) {
+ status = push_globs(ary, buf, flags);
+ if (status) break;
}
- else if (nest % 5 == 0) {
- push_braces(ary, buf);
+ else if (nest == 0) {
+ status = push_braces(ary, buf, flags);
+ if (status) break;
}
/* else unmatched braces */
}
- if (buf != buffer)
- free(buf);
+ free(buf);
+
+ if (status) rb_jump_tag(status);
+
+ if (rb_block_given_p()) {
+ rb_ary_each(ary);
+ return Qnil;
+ }
return ary;
}
+/*
+ * call-seq:
+ * Dir[ string ] => array
+ *
+ * Equivalent to calling
+ * <em>dir</em>.<code>glob(</code><i>string,</i><code>0)</code>.
+ *
+ */
+static VALUE
+dir_s_aref(obj, str)
+ VALUE obj, str;
+{
+ return rb_push_glob(str, 0);
+}
+
+/*
+ * call-seq:
+ * Dir.glob( string, [flags] ) => array
+ * Dir.glob( string, [flags] ) {| filename | block } => false
+ *
+ * Returns the filenames found by expanding the pattern given in
+ * <i>string</i>, either as an <i>array</i> or as parameters to the
+ * block. Note that this pattern is not a regexp (it's closer to a
+ * shell glob). See <code>File::fnmatch</code> for
+ * details of file name matching and the meaning of the <i>flags</i>
+ * parameter.
+ *
+ * Dir["config.?"] #=> ["config.h"]
+ * Dir.glob("config.?") #=> ["config.h"]
+ * Dir.glob("*.[a-z][a-z]") #=> ["main.rb"]
+ * Dir.glob("*.[^r]*") #=> ["config.h"]
+ * Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
+ * Dir.glob("*") #=> ["config.h", "main.rb"]
+ * Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
+ *
+ */
+static VALUE
+dir_s_glob(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE str, rflags;
+ int flags;
+
+ if (rb_scan_args(argc, argv, "11", &str, &rflags) == 2)
+ flags = NUM2INT(rflags);
+ else
+ flags = 0;
+
+ return rb_push_glob(str, flags);
+}
+
+/*
+ * call-seq:
+ * Dir.foreach( dirname ) {| filename | block } => nil
+ *
+ * Calls the block once for each entry in the named directory, passing
+ * the filename of each entry as a parameter to the block.
+ *
+ * Dir.foreach("testdir") {|x| puts "Got #{x}" }
+ *
+ * <em>produces:</em>
+ *
+ * Got .
+ * Got ..
+ * Got config.h
+ * Got main.rb
+ *
+ */
static VALUE
dir_foreach(io, dirname)
VALUE io, dirname;
@@ -837,6 +1325,17 @@ dir_foreach(io, dirname)
return Qnil;
}
+/*
+ * call-seq:
+ * Dir.entries( dirname ) => array
+ *
+ * Returns an array containing all of the filenames in the given
+ * directory. Will raise a <code>SystemCallError</code> if the named
+ * directory doesn't exist.
+ *
+ * Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"]
+ *
+ */
static VALUE
dir_entries(io, dirname)
VALUE io, dirname;
@@ -847,6 +1346,80 @@ dir_entries(io, dirname)
return rb_ensure(rb_Array, dir, dir_close, dir);
}
+/*
+ * call-seq:
+ * File.fnmatch( pattern, path, [flags] ) => (true or false)
+ * File.fnmatch?( pattern, path, [flags] ) => (true or false)
+ *
+ * Returns true if <i>path</i> matches against <i>pattern</i> The
+ * pattern is not a regular expression; instead it follows rules
+ * similar to shell filename globbing. It may contain the following
+ * metacharacters:
+ *
+ * <i>flags</i> is a bitwise OR of the <code>FNM_xxx</code> parameters.
+ * The same glob pattern and flags are used by <code>Dir::glob</code>.
+ *
+ * File.fnmatch('cat', 'cat') #=> true
+ * File.fnmatch('cat', 'category') #=> false
+ * File.fnmatch('c{at,ub}s', 'cats') #=> false
+ * File.fnmatch('c{at,ub}s', 'cubs') #=> false
+ * File.fnmatch('c{at,ub}s', 'cat') #=> false
+ *
+ * File.fnmatch('c?t', 'cat') #=> true
+ * File.fnmatch('c\?t', 'cat') #=> false
+ * File.fnmatch('c??t', 'cat') #=> false
+ * File.fnmatch('c*', 'cats') #=> true
+ * File.fnmatch('c/ * FIXME * /t', 'c/a/b/c/t') #=> true
+ * File.fnmatch('c*t', 'cat') #=> true
+ * File.fnmatch('c\at', 'cat') #=> true
+ * File.fnmatch('c\at', 'cat', File::FNM_NOESCAPE) #=> false
+ * File.fnmatch('a?b', 'a/b') #=> true
+ * File.fnmatch('a?b', 'a/b', File::FNM_PATHNAME) #=> false
+ *
+ * File.fnmatch('*', '.profile') #=> false
+ * File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true
+ * File.fnmatch('*', 'dave/.profile') #=> true
+ * File.fnmatch('*', 'dave/.profile', File::FNM_DOTMATCH) #=> true
+ * File.fnmatch('*', 'dave/.profile', File::FNM_PATHNAME) #=> false
+ * File.fnmatch('* / FIXME *', 'dave/.profile', File::FNM_PATHNAME) #=> false
+ * STRICT = File::FNM_PATHNAME | File::FNM_DOTMATCH
+ * File.fnmatch('* / FIXME *', 'dave/.profile', STRICT) #=> true
+ */
+static VALUE
+file_s_fnmatch(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE pattern, path;
+ VALUE rflags;
+ int flags;
+
+ if (rb_scan_args(argc, argv, "21", &pattern, &path, &rflags) == 3)
+ flags = NUM2INT(rflags);
+ else
+ flags = 0;
+
+ StringValue(pattern);
+ StringValue(path);
+
+ if (fnmatch(RSTRING(pattern)->ptr, RSTRING(path)->ptr, flags) == 0)
+ return Qtrue;
+
+ return Qfalse;
+}
+
+/*
+ * Objects of class <code>Dir</code> are directory streams representing
+ * directories in the underlying file system. They provide a variety of
+ * ways to list directories and their contents. See also
+ * <code>File</code>.
+ *
+ * The directory used in these examples contains the two regular files
+ * (<code>config.h</code> and <code>main.rb</code>), the parent
+ * directory (<code>..</code>), and the directory itself
+ * (<code>.</code>).
+ */
void
Init_Dir()
{
@@ -854,19 +1427,20 @@ Init_Dir()
rb_include_module(rb_cDir, rb_mEnumerable);
- rb_define_singleton_method(rb_cDir, "new", dir_s_new, -1);
+ rb_define_alloc_func(rb_cDir, dir_s_alloc);
rb_define_singleton_method(rb_cDir, "open", dir_s_open, 1);
rb_define_singleton_method(rb_cDir, "foreach", dir_foreach, 1);
rb_define_singleton_method(rb_cDir, "entries", dir_entries, 1);
rb_define_method(rb_cDir,"initialize", dir_initialize, 1);
+ rb_define_method(rb_cDir,"path", dir_path, 0);
rb_define_method(rb_cDir,"read", dir_read, 0);
rb_define_method(rb_cDir,"each", dir_each, 0);
rb_define_method(rb_cDir,"rewind", dir_rewind, 0);
rb_define_method(rb_cDir,"tell", dir_tell, 0);
rb_define_method(rb_cDir,"seek", dir_seek, 1);
rb_define_method(rb_cDir,"pos", dir_tell, 0);
- rb_define_method(rb_cDir,"pos=", dir_seek, 1);
+ rb_define_method(rb_cDir,"pos=", dir_set_pos, 1);
rb_define_method(rb_cDir,"close", dir_close, 0);
rb_define_singleton_method(rb_cDir,"chdir", dir_s_chdir, -1);
@@ -878,6 +1452,14 @@ Init_Dir()
rb_define_singleton_method(rb_cDir,"delete", dir_s_rmdir, 1);
rb_define_singleton_method(rb_cDir,"unlink", dir_s_rmdir, 1);
- rb_define_singleton_method(rb_cDir,"glob", dir_s_glob, 1);
- rb_define_singleton_method(rb_cDir,"[]", dir_s_glob, 1);
+ rb_define_singleton_method(rb_cDir,"glob", dir_s_glob, -1);
+ rb_define_singleton_method(rb_cDir,"[]", dir_s_aref, 1);
+
+ rb_define_singleton_method(rb_cFile,"fnmatch", file_s_fnmatch, -1);
+ rb_define_singleton_method(rb_cFile,"fnmatch?", file_s_fnmatch, -1);
+
+ rb_file_const("FNM_NOESCAPE", INT2FIX(FNM_NOESCAPE));
+ rb_file_const("FNM_PATHNAME", INT2FIX(FNM_PATHNAME));
+ rb_file_const("FNM_DOTMATCH", INT2FIX(FNM_DOTMATCH));
+ rb_file_const("FNM_CASEFOLD", INT2FIX(FNM_CASEFOLD));
}
diff --git a/djgpp/GNUmakefile.in b/djgpp/GNUmakefile.in
new file mode 100644
index 0000000000..0a7e1fb131
--- /dev/null
+++ b/djgpp/GNUmakefile.in
@@ -0,0 +1,2 @@
+include Makefile
+VPATH = $(srcdir) $(srcdir)/missing
diff --git a/djgpp/README.djgpp b/djgpp/README.djgpp
index d81259ccac..f1f413a478 100644
--- a/djgpp/README.djgpp
+++ b/djgpp/README.djgpp
@@ -3,7 +3,7 @@
This is what you need to do to compile and install Ruby:
1. Run configure.bat, which will generate config.h and Makefile
- and ext/extmk.rb(GNU sed required).
+ (GNU sed required).
Message like this is normal:
sed.exe: can't read 123456789: No such file or directory (ENOENT)
diff --git a/djgpp/config.hin b/djgpp/config.hin
index 973a0db93d..8ee427c92f 100644
--- a/djgpp/config.hin
+++ b/djgpp/config.hin
@@ -1,69 +1,111 @@
-#define USE_THREAD 1
+
+#define PACKAGE_NAME ""
+#define PACKAGE_TARNAME ""
+#define PACKAGE_VERSION ""
+#define PACKAGE_STRING ""
+#define PACKAGE_BUGREPORT ""
+#define USE_BUILTIN_FRAME_ADDRESS 1
+#define STDC_HEADERS 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_LONG_LONG 1
+#define HAVE_OFF_T 1
#define SIZEOF_INT 4
#define SIZEOF_SHORT 2
#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF___INT64 0
+#define SIZEOF_OFF_T 4
#define SIZEOF_VOIDP 4
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define HAVE_PROTOTYPES 1
#define TOKEN_PASTE(x,y) x##y
#define HAVE_STDARG_PROTOTYPES 1
-#define HAVE_ATTR_NORETURN 1
+#define NORETURN(x) x __attribute__ ((noreturn))
+#define HAVE_DECL_SYS_NERR 1
#define HAVE_DIRENT_H 1
#define STDC_HEADERS 1
+#define HAVE_SYS_WAIT_H 1
#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
#define HAVE_UNISTD_H 1
#define HAVE_LIMITS_H 1
#define HAVE_SYS_FILE_H 1
#define HAVE_SYS_IOCTL_H 1
-#define HAVE_PWD_H 1
+#define HAVE_FCNTL_H 1
+#define HAVE_SYS_FCNTL_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_PWD_H 1
#define HAVE_UTIME_H 1
#define HAVE_MEMORY_H 1
#define HAVE_DIRECT_H 1
+#define HAVE_SYS_RESOURCE_H 1
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
#define HAVE_ST_BLKSIZE 1
+#define HAVE_STRUCT_STAT_ST_RDEV 1
#define HAVE_ST_RDEV 1
#define GETGROUPS_T gid_t
#define RETSIGTYPE void
#define HAVE_ALLOCA 1
-#define vfork fork
#define HAVE_DUP2 1
-#define HAVE_SETENV 1
#define HAVE_MEMMOVE 1
#define HAVE_MKDIR 1
#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
#define HAVE_STRERROR 1
#define HAVE_STRFTIME 1
#define HAVE_STRCHR 1
#define HAVE_STRSTR 1
#define HAVE_STRTOUL 1
-#define HAVE_STRDUP 1
#define HAVE_ISINF 1
#define HAVE_ISNAN 1
#define HAVE_FINITE 1
+#define HAVE_HYPOT 1
+#define HAVE_ACOSH 1
#define HAVE_FMOD 1
-#define HAVE_RANDOM 1
#define HAVE_WAITPID 1
-#define HAVE_GETCWD 1
+#define HAVE_FSYNC 1
#define HAVE_TRUNCATE 1
#define HAVE_CHSIZE 1
#define HAVE_TIMES 1
#define HAVE_UTIMES 1
-#define HAVE_FCNTL_H 1
-/*#define HAVE_SETITIMER 1*/
+#define HAVE_FCNTL 1
+#define HAVE_SYMLINK 1
+#define HAVE_SETITIMER 1
+#define HAVE_PAUSE 1
+#define HAVE_GETPGRP 1
+#define HAVE_SETPGID 1
#define HAVE_GETGROUPS 1
+#define HAVE_GETRLIMIT 1
#define HAVE_SIGPROCMASK 1
#define HAVE_SIGACTION 1
#define HAVE_SETSID 1
+#define HAVE_TELLDIR 1
+#define HAVE_SEEKDIR 1
+#define HAVE_MKTIME 1
+#define HAVE_COSH 1
+#define HAVE_SINH 1
+#define HAVE_TANH 1
+#define HAVE_STRUCT_TM_TM_ZONE 1
+#define HAVE_TM_ZONE 1
+#define HAVE_STRUCT_TM_TM_GMTOFF 1
#define POSIX_SIGNAL 1
-#define BSD_SETPGRP setpgrp
-#define RSHIFT(x,y) ((x)>>y)
+#define GETPGRP_VOID 1
+#define SETPGRP_VOID 1
+#define RSHIFT(x,y) ((x)>>(int)y)
#define FILE_COUNT _cnt
-#define DLEXT ".o"
+#define FILE_READPTR _ptr
+#define NEED_IO_FLUSH_BETWEEN_RW 1
+#define DEFAULT_KCODE KCODE_NONE
+#define DLEXT ".so"
#define RUBY_LIB "/lib/ruby/@MAJOR@.@MINOR@"
#define RUBY_SITE_LIB "/lib/ruby/site_ruby"
#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/@MAJOR@.@MINOR@"
diff --git a/djgpp/config.sed b/djgpp/config.sed
index 0713759f16..1805789520 100644
--- a/djgpp/config.sed
+++ b/djgpp/config.sed
@@ -1,70 +1,5 @@
/^SHELL/s,/bin/sh,$(COMSPEC),
-s%@srcdir@%.%g
-s%@top_srcdir@%..%
-s%@CFLAGS@%-O2%g
-s%@CPPFLAGS@%%g
-s%@CXXFLAGS@%%g
-s%@LDFLAGS@%%g
-s%@LIBS@%-lm %g
-s%@exec_prefix@%${prefix}%g
-s%@prefix@%/usr/local%g
-s%@program_transform_name@%s,x,x,%g
-s%@bindir@%${exec_prefix}/bin%g
-s%@sbindir@%${exec_prefix}/sbin%g
-s%@libexecdir@%${exec_prefix}/libexec%g
-s%@datadir@%${prefix}/share%g
-s%@sysconfdir@%${prefix}/etc%g
-s%@sharedstatedir@%${prefix}/com%g
-s%@localstatedir@%${prefix}/var%g
-s%@libdir@%${exec_prefix}/lib%g
-s%@includedir@%${prefix}/include%g
-s%@oldincludedir@%/usr/include%g
-s%@infodir@%${prefix}/info%g
-s%@mandir@%${prefix}/man%g
-s%@host@%i386-pc-msdosdjgpp%g
-s%@host_alias@%i386-msdosdjgpp%g
-s%@host_cpu@%i386%g
-s%@host_vendor@%pc%g
-s%@host_os@%msdosdjgpp%g
-s%@CC@%gcc%g
-s%@CPP@%gcc -E%g
-s%@YACC@%bison -y%g
-s%@RANLIB@%ranlib%g
-s%@AR@%ar%g
-s%@INSTALL_PROGRAM@%${INSTALL}%g
-s%@INSTALL_DATA@%${INSTALL} -m 644%g
-s%@SET_MAKE@%%g
-s%@LIBOBJS@% crypt.o flock.o vsnprintf.o%g
-s%@ALLOCA@%%g
-s%@DEFAULT_KCODE@%%g
-s%@EXEEXT@%.exe%g
-s%@OBJEXT@%o%g
-s%@XLDFLAGS@%%g
-s%@DLDFLAGS@%%g
-s%@STATIC@%%g
-s%@CCDLFLAGS@%%g
-s%@LDSHARED@%ld%g
-s%@DLEXT@%o%g
-s%@STRIP@%strip%g
-s%@EXTSTATIC@%%g
-s%@binsuffix@%.exe%g
-s%@setup@%Setup.dj%g
-s%@LIBRUBY@%libruby.a%g
-s%@LIBRUBY_A@%libruby.a%g
-s%@LIBRUBYARG@%libruby.a%g
-s%@LIBRUBY_SO@%%g
-s%@SOLIBS@%%g
-s%@arch@%i386-msdosdjgpp%g
;s%/bin/rm%rm%
-s%@DLDLIBS@%-lc%g
-s%@PREP@%%
-s%@RUBY_INSTALL_NAME@%ruby%g
-s%@RUBY_SO_NAME@%%g
-s%@arch@%i386-msdosdjgpp%g
-s%@sitedir@%${prefix}/lib/ruby/site_ruby%g
-s%@configure_args@%%g
-s%@MINIRUBY@%./miniruby%
-s%@archlib@%/lib/ruby/i386-msdosdjgpp%
;s%|| true%%
;/\/dev\/null/ {
;s,/dev/null 2>&1, nul,
@@ -73,8 +8,121 @@ s%@archlib@%/lib/ruby/i386-msdosdjgpp%
;/^config.status/ {
; N;N;N;N;N;d
;}
-;s%mv -f y\.tab\.c%if exist parse.c del parse.c\
- ren y_tab.c%
-;s%y\.tab\.c%y_tab.c%
+:t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@srcdir@,.,g;t t
+s,@top_srcdir@,..,;t t
+s,@PATH_SEPARATOR@,:,;t t
+s,@PACKAGE_NAME@,,;t t
+s,@PACKAGE_TARNAME@,,;t t
+s,@PACKAGE_VERSION@,,;t t
+s,@PACKAGE_STRING@,,;t t
+s,@PACKAGE_BUGREPORT@,,;t t
+s,@exec_prefix@,${prefix},;t t
+s,@prefix@,/dev/env/DJDIR,;t t
+s%@program_transform_name@%s,^,,%;t t
+s,@bindir@,${exec_prefix}/bin,;t t
+s,@sbindir@,${exec_prefix}/sbin,;t t
+s,@libexecdir@,${exec_prefix}/libexec,;t t
+s,@datadir@,${prefix}/share,;t t
+s,@sysconfdir@,${prefix}/etc,;t t
+s,@sharedstatedir@,${prefix}/com,;t t
+s,@localstatedir@,${prefix}/var,;t t
+s,@libdir@,${exec_prefix}/lib,;t t
+s,@includedir@,${prefix}/include,;t t
+s,@oldincludedir@,/usr/include,;t t
+s,@infodir@,${prefix}/info,;t t
+s,@mandir@,${prefix}/man,;t t
+s,@build_alias@,i586-pc-msdosdjgpp,;t t
+s,@host_alias@,i586-pc-msdosdjgpp,;t t
+s,@target_alias@,i386-msdosdjgpp,;t t
+s,@DEFS@,,;t t
+s,@ECHO_C@,,;t t
+s,@ECHO_N@,-n,;t t
+s,@ECHO_T@,,;t t
+s,@LIBS@,-lm ,;t t
+s,@MAJOR@,1,;t t
+s,@MINOR@,7,;t t
+s,@TEENY@,3,;t t
+s,@build@,i586-pc-msdosdjgpp,;t t
+s,@build_cpu@,i586,;t t
+s,@build_vendor@,pc,;t t
+s,@build_os@,msdosdjgpp,;t t
+s,@host@,i586-pc-msdosdjgpp,;t t
+s,@host_cpu@,i586,;t t
+s,@host_vendor@,pc,;t t
+s,@host_os@,msdosdjgpp,;t t
+s,@target@,i386-pc-msdosdjgpp,;t t
+s,@target_cpu@,i386,;t t
+s,@target_vendor@,pc,;t t
+s,@target_os@,msdosdjgpp,;t t
+s,@CC@,gcc,;t t
+s,@ac_ct_CC@,,;t t
+s,@CFLAGS@,-Os,;t t
+s,@LDFLAGS@,,;t t
+s,@CPPFLAGS@,,;t t
+s,@EXEEXT@,.exe,;t t
+s,@OBJEXT@,o,;t t
+s,@CPP@,gcc -E,;t t
+s,@EGREP@,grep -E,;t t
+s,@GNU_LD@,yes,;t t
+s,@CPPOUTFILE@,-o conftest.i,;t t
+s,@OUTFLAG@,-o ,;t t
+s,@YACC@,bison -y,;t t
+s,@RANLIB@,ranlib,;t t
+s,@ac_ct_RANLIB@,,;t t
+s,@AR@,ar,;t t
+s,@ac_ct_AR@,,;t t
+s,@NM@,,;t t
+s,@ac_ct_NM@,,;t t
+s,@WINDRES@,,;t t
+s,@ac_ct_WINDRES@,,;t t
+s,@DLLWRAP@,,;t t
+s,@ac_ct_DLLWRAP@,,;t t
+s,@LN_S@,ln -s,;t t
+s,@SET_MAKE@,,;t t
+s,@LIBOBJS@,crypt.o flock.o vsnprintf.o,;t t
+s,@ALLOCA@,,;t t
+s,@XCFLAGS@,,;t t
+s,@XLDFLAGS@, -L.,;t t
+s,@DLDFLAGS@,,;t t
+s,@STATIC@,,;t t
+s,@CCDLFLAGS@,,;t t
+s,@LDSHARED@,ld,;t t
+s,@DLEXT@,so,;t t
+s,@DLEXT2@,,;t t
+s,@LIBEXT@,a,;t t
+s,@LINK_SO@,,;t t
+s,@LIBPATHFLAG@, -L%s,;t t
+s,@STRIP@,strip,;t t
+s,@EXTSTATIC@,,;t t
+s,@setup@,Setup.dj,;t t
+s,@MINIRUBY@,./miniruby,;t t
+s,@PREP@,,;t t
+s,@ARCHFILE@,,;t t
+s,@LIBRUBY_LDSHARED@,ld,;t t
+s,@LIBRUBY_DLDFLAGS@,,;t t
+s,@RUBY_INSTALL_NAME@,ruby,;t t
+s,@rubyw_install_name@,,;t t
+s,@RUBYW_INSTALL_NAME@,,;t t
+s,@RUBY_SO_NAME@,$(RUBY_INSTALL_NAME),;t t
+s,@LIBRUBY_A@,lib$(RUBY_INSTALL_NAME).a,;t t
+s,@LIBRUBY_SO@,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY),;t t
+s,@LIBRUBY_ALIASES@,lib$(RUBY_SO_NAME).so,;t t
+s,@LIBRUBY@,$(LIBRUBY_A),;t t
+s,@LIBRUBYARG@,-l$(RUBY_INSTALL_NAME),;t t
+s,@SOLIBS@,,;t t
+s,@DLDLIBS@,-lc,;t t
+s,@ENABLE_SHARED@,no,;t t
+s,@MAINLIBS@,,;t t
+s,@COMMON_LIBS@,,;t t
+s,@COMMON_MACROS@,,;t t
+s,@COMMON_HEADERS@,,;t t
+s,@EXPORT_PREFIX@,,;t t
+s,@MAKEFILES@,Makefile,;t t
+s,@arch@,i386-msdosdjgpp,;t t
+s,@sitearch@,i386-msdosdjgpp,;t t
+s,@sitedir@,${prefix}/lib/ruby/site_ruby,;t t
+s,@configure_args@,,;t t
/^,THIS_IS_DUMMY_PATTERN_/i\
ac_given_srcdir=.
diff --git a/djgpp/configure.bat b/djgpp/configure.bat
index dbb4a08528..e6a5d79d4a 100644
--- a/djgpp/configure.bat
+++ b/djgpp/configure.bat
@@ -5,7 +5,6 @@ if exist djgpp\version.sed goto exist
:exist
set _conv_=-f djgpp\config.sed -f djgpp\version.sed
sed %_conv_% < Makefile.in > Makefile
-sed %_conv_% < ext\extmk.rb.in > ext\extmk.rb
sed %_conv_% < djgpp\config.hin > config.h
echo LFN check > 12345678
sed -n /LFN/d 123456789 > nul
diff --git a/dln.c b/dln.c
index ae3cbf2fb3..8f0b2a0409 100644
--- a/dln.c
+++ b/dln.c
@@ -6,28 +6,32 @@
$Date$
created at: Tue Jan 18 17:05:06 JST 1994
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
-#include "config.h"
-#include "defines.h"
+#include "ruby.h"
#include "dln.h"
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
#ifdef __CHECKER__
#undef HAVE_DLOPEN
#undef USE_DLN_A_OUT
#undef USE_DLN_DLOPEN
#endif
+#ifdef USE_DLN_A_OUT
char *dln_argv0;
-void rb_loaderror();
+#endif
#ifdef _AIX
#pragma alloca
#endif
-#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
+#if defined(HAVE_ALLOCA_H)
#include <alloca.h>
#endif
@@ -44,15 +48,20 @@ void *xrealloc();
#endif
#include <stdio.h>
-#ifdef NT
+#if defined(_WIN32) || defined(__VMS)
#include "missing/file.h"
#endif
#include <sys/types.h>
#include <sys/stat.h>
+#ifndef S_ISDIR
+# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#endif
+
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
-#else
+#endif
+#ifndef MAXPATHLEN
# define MAXPATHLEN 1024
#endif
@@ -60,10 +69,15 @@ void *xrealloc();
# include <unistd.h>
#endif
-#ifndef NT
+#ifndef _WIN32
char *getenv();
#endif
+#if defined(__VMS)
+#pragma builtins
+#include <dlfcn.h>
+#endif
+
#ifdef __MACOS__
# include <TextUtils.h>
# include <CodeFragments.h>
@@ -77,42 +91,59 @@ char *getenv();
int eaccess();
-#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX)
+#if defined(HAVE_DLOPEN) && !defined(USE_DLN_A_OUT) && !defined(_AIX) && !defined(__APPLE__) && !defined(_UNICOSMP)
/* dynamic load with dlopen() */
# define USE_DLN_DLOPEN
#endif
#ifndef FUNCNAME_PATTERN
-# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
-# define FUNCNAME_PATTERN "_Init_%.200s"
+# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && !defined(__ELF__)) || (defined(__OpenBSD__) && !defined(__ELF__)) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
+# define FUNCNAME_PATTERN "_Init_%s"
# else
-# define FUNCNAME_PATTERN "Init_%.200s"
+# define FUNCNAME_PATTERN "Init_%s"
# endif
#endif
-static void
-init_funcname(buf, file)
- char *buf;
- char *file;
+static int
+init_funcname_len(buf, file)
+ char **buf;
+ const char *file;
{
- char *p, *slash;
+ char *p;
+ const char *slash;
+ int len;
/* Load the file as an object one */
- for (p = file, slash = p-1; *p; p++) /* Find position of last '/' */
+ for (slash = file-1; *file; file++) /* Find position of last '/' */
#ifdef __MACOS__
- if (*p == ':') slash = p;
+ if (*file == ':') slash = file;
#else
- if (*p == '/') slash = p;
+ if (*file == '/') slash = file;
#endif
- snprintf(buf, MAXPATHLEN, FUNCNAME_PATTERN, slash + 1);
- for (p = buf; *p; p++) { /* Delete suffix if it exists */
+ len = strlen(FUNCNAME_PATTERN) + strlen(slash + 1);
+ *buf = xmalloc(len);
+ snprintf(*buf, len, FUNCNAME_PATTERN, slash + 1);
+ for (p = *buf; *p; p++) { /* Delete suffix if it exists */
if (*p == '.') {
*p = '\0'; break;
}
}
+ return p - *buf;
}
+#define init_funcname(buf, file) do {\
+ int len = init_funcname_len(buf, file);\
+ char *tmp = ALLOCA_N(char, len+1);\
+ if (!tmp) {\
+ free(*buf);\
+ rb_memerror();\
+ }\
+ strcpy(tmp, *buf);\
+ free(*buf);\
+ *buf = tmp;\
+} while (0)
+
#ifdef USE_DLN_A_OUT
#ifndef LIBC_NAME
@@ -618,7 +649,6 @@ load_1(fd, disp, need_init)
struct nlist *sym;
struct nlist *end;
int init_p = 0;
- char buf[MAXPATHLEN];
if (load_header(fd, &hdr, disp) == -1) return -1;
if (INVALID_OBJECT(hdr)) {
@@ -627,8 +657,12 @@ load_1(fd, disp, need_init)
}
reloc = load_reloc(fd, &hdr, disp);
if (reloc == NULL) return -1;
+
syms = load_sym(fd, &hdr, disp);
- if (syms == NULL) return -1;
+ if (syms == NULL) {
+ free(reloc);
+ return -1;
+ }
sym = syms;
end = syms + (hdr.a_syms / sizeof(struct nlist));
@@ -641,7 +675,7 @@ load_1(fd, disp, need_init)
char *key = sym->n_un.n_name;
if (st_lookup(sym_tbl, sym[1].n_un.n_name, &old_sym)) {
- if (st_delete(undef_tbl, &key, NULL)) {
+ if (st_delete(undef_tbl, (st_data_t*)&key, NULL)) {
unlink_undef(key, old_sym->n_value);
free(key);
}
@@ -654,7 +688,7 @@ load_1(fd, disp, need_init)
st_foreach(reloc_tbl, reloc_repl, &data);
st_insert(undef_tbl, strdup(sym[1].n_un.n_name), NULL);
- if (st_delete(undef_tbl, &key, NULL)) {
+ if (st_delete(undef_tbl, (st_data_t*)&key, NULL)) {
free(key);
}
}
@@ -722,7 +756,7 @@ load_1(fd, disp, need_init)
}
key = sym->n_un.n_name;
- if (st_delete(undef_tbl, &key, NULL) != 0) {
+ if (st_delete(undef_tbl, (st_data_t*)&key, NULL) != 0) {
unlink_undef(key, sym->n_value);
free(key);
}
@@ -831,12 +865,13 @@ load_1(fd, disp, need_init)
if (need_init) {
int len;
char **libs_to_be_linked = 0;
+ char *buf;
if (undef_tbl->num_entries > 0) {
if (load_lib(libc) == -1) goto err_exit;
}
- init_funcname(buf, need_init);
+ init_funcname(&buf, need_init);
len = strlen(buf);
for (sym = syms; sym<end; sym++) {
@@ -1104,17 +1139,29 @@ dln_sym(name)
#include <mach-o/rld.h>
#else
#include <mach-o/dyld.h>
+#ifndef NSLINKMODULE_OPTION_BINDNOW
+#define NSLINKMODULE_OPTION_BINDNOW 1
#endif
#endif
+#else
#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif
-
+#endif
#if defined _WIN32 && !defined __CYGWIN__
#include <windows.h>
#endif
+#ifdef _WIN32_WCE
+#undef FormatMessage
+#define FormatMessage FormatMessageA
+#undef LoadLibrary
+#define LoadLibrary LoadLibraryA
+#undef GetProcAddress
+#define GetProcAddress GetProcAddressA
+#endif
+
static const char *
dln_strerror()
{
@@ -1125,7 +1172,7 @@ dln_strerror()
case DLN_ECONFL:
return "Symbol name conflict";
case DLN_ENOINIT:
- return "No inititalizer given";
+ return "No initializer given";
case DLN_EUNDEF:
return "Unresolved symbols";
case DLN_ENOTLIB:
@@ -1149,7 +1196,7 @@ dln_strerror()
char *p = message;
p += sprintf(message, "%d: ", error);
FormatMessage(
- FORMAT_MESSAGE_FROM_SYSTEM,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
@@ -1174,7 +1221,7 @@ aix_loaderror(const char *pathname)
int i,j;
struct errtab {
- int errno;
+ int errnum;
char *errstr;
} load_errtab[] = {
{L_ERROR_TOOMANY, "too many errors, rest skipped."},
@@ -1186,7 +1233,7 @@ aix_loaderror(const char *pathname)
{L_ERROR_MEMBER,
"file not an archive or does not contain requested member:"},
{L_ERROR_TYPE, "symbol table mismatch:"},
- {L_ERROR_ALIGN, "text allignment in file is wrong."},
+ {L_ERROR_ALIGN, "text alignment in file is wrong."},
{L_ERROR_SYSTEM, "System error:"},
{L_ERROR_ERRNO, NULL}
};
@@ -1194,17 +1241,17 @@ aix_loaderror(const char *pathname)
#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
- snprintf(errbuf, 1024, "load failed - %.200s ", pathname);
+ snprintf(errbuf, 1024, "load failed - %s ", pathname);
if (!loadquery(1, &message[0], sizeof(message)))
ERRBUF_APPEND(strerror(errno));
for(i = 0; message[i] && *message[i]; i++) {
int nerr = atoi(message[i]);
for (j=0; j<LOAD_ERRTAB_LEN; j++) {
- if (nerr == load_errtab[i].errno && load_errtab[i].errstr)
+ if (nerr == load_errtab[i].errnum && load_errtab[i].errstr)
ERRBUF_APPEND(load_errtab[i].errstr);
}
- while (ISDIGIT(*message[i])) message[i]++;
+ while (isdigit(*message[i])) message[i]++;
ERRBUF_APPEND(message[i]);
ERRBUF_APPEND("\n");
}
@@ -1214,46 +1261,66 @@ aix_loaderror(const char *pathname)
}
#endif
+#if defined(__VMS)
+#include <starlet.h>
+#include <rms.h>
+#include <stsdef.h>
+#include <unixlib.h>
+#include <descrip.h>
+#include <lib$routines.h>
+
+static char *vms_filespec;
+static int vms_fileact(char *filespec, int type);
+static long vms_fisexh(long *sigarr, long *mecarr);
+#endif
+
void*
dln_load(file)
const char *file;
{
+#if !defined(_AIX) && !defined(NeXT)
+ const char *error = 0;
+#define DLN_ERROR() (error = dln_strerror(), strcpy(ALLOCA_N(char, strlen(error) + 1), error))
+#endif
+
#if defined _WIN32 && !defined __CYGWIN__
HINSTANCE handle;
char winfile[MAXPATHLEN];
void (*init_fct)();
- char buf[MAXPATHLEN];
+ char *buf;
if (strlen(file) >= MAXPATHLEN) rb_loaderror("filename too long");
/* Load the file as an object one */
- init_funcname(buf, file);
+ init_funcname(&buf, file);
strcpy(winfile, file);
/* Load file */
- if ((handle =
- LoadLibraryExA(winfile, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) == NULL) {
+ if ((handle = LoadLibrary(winfile)) == NULL) {
+ error = dln_strerror();
goto failed;
}
if ((init_fct = (void(*)())GetProcAddress(handle, buf)) == NULL) {
rb_loaderror("%s - %s\n%s", dln_strerror(), buf, file);
}
+
/* Call the init code */
(*init_fct)();
return handle;
#else
#ifdef USE_DLN_A_OUT
if (load(file) == -1) {
+ error = dln_strerror();
goto failed;
}
return 0;
#else
- char buf[MAXPATHLEN];
+ char *buf;
/* Load the file as an object one */
- init_funcname(buf, file);
+ init_funcname(&buf, file);
#ifdef USE_DLN_DLOPEN
#define DLN_DEFINED
@@ -1264,21 +1331,28 @@ dln_load(file)
#ifndef RTLD_LAZY
# define RTLD_LAZY 1
#endif
+#ifdef __INTERIX
+# undef RTLD_GLOBAL
+#endif
#ifndef RTLD_GLOBAL
# define RTLD_GLOBAL 0
#endif
/* Load file */
if ((handle = (void*)dlopen(file, RTLD_LAZY|RTLD_GLOBAL)) == NULL) {
+ error = dln_strerror();
goto failed;
}
- if ((init_fct = (void(*)())dlsym(handle, buf)) == NULL) {
+ init_fct = (void(*)())dlsym(handle, buf);
+ if (init_fct == NULL) {
+ error = DLN_ERROR();
dlclose(handle);
goto failed;
}
/* Call the init code */
(*init_fct)();
+
return handle;
}
#endif /* USE_DLN_DLOPEN */
@@ -1334,31 +1408,41 @@ dln_load(file)
Special Thanks...
Yu tomoak-i@is.aist-nara.ac.jp,
Mi hisho@tasihara.nest.or.jp,
+ sunshine@sunshineco.com,
and... Miss ARAI Akino(^^;)
----------------------------------------------------*/
#if defined(NeXT) && (NS_TARGET_MAJOR < 4)/* NeXTSTEP rld functions */
{
+ NXStream* s;
unsigned long init_address;
char *object_files[2] = {NULL, NULL};
void (*init_fct)();
- object_files[0] = file;
+ object_files[0] = (char*)file;
+ s = NXOpenFile(2,NX_WRITEONLY);
+
/* Load object file, if return value ==0 , load failed*/
- if(rld_load(NULL, NULL, object_files, NULL) == 0) {
+ if(rld_load(s, NULL, object_files, NULL) == 0) {
+ NXFlush(s);
+ NXClose(s);
rb_loaderror("Failed to load %.200s", file);
}
/* lookup the initial function */
- if(rld_lookup(NULL, buf, &init_address) == 0) {
+ if(rld_lookup(s, buf, &init_address) == 0) {
+ NXFlush(s);
+ NXClose(s);
rb_loaderror("Failed to lookup Init function %.200s", file);
}
- /* Cannot call *init_address directory, so copy this value to
- funtion pointer */
+ NXFlush(s);
+ NXClose(s);
+ /* Cannot call *init_address directory, so copy this value to
+ funtion pointer */
init_fct = (void(*)())init_address;
(*init_fct)();
return (void*)init_address;
@@ -1368,7 +1452,7 @@ dln_load(file)
int dyld_result;
NSObjectFileImage obj_file; /* handle, but not use it */
/* "file" is module file name .
- "buf" is initial function name with "_" . */
+ "buf" is pointer to initial function name with "_" . */
void (*init_fct)();
@@ -1379,15 +1463,12 @@ dln_load(file)
rb_loaderror("Failed to load %.200s", file);
}
- NSLinkModule(obj_file, file, TRUE);
+ NSLinkModule(obj_file, file, NSLINKMODULE_OPTION_BINDNOW);
/* lookup the initial function */
- /*NSIsSymbolNameDefined require function name without "_" */
- if(NSIsSymbolNameDefined(buf + 1)) {
+ if(!NSIsSymbolNameDefined(buf)) {
rb_loaderror("Failed to lookup Init function %.200s",file);
- }
-
- /* NSLookupAndBindSymbol require function name with "_" !! */
+ }
init_fct = NSAddressOfSymbol(NSLookupAndBindSymbol(buf));
(*init_fct)();
@@ -1484,23 +1565,75 @@ dln_load(file)
if (err) {
rb_loaderror("Unresolved symbols - %s" , file);
}
-
init_fct = (void (*)())symAddr;
(*init_fct)();
return (void*)init_fct;
}
#endif /* __MACOS__ */
+#if defined(__VMS)
+#define DLN_DEFINED
+ {
+ long status;
+ void (*init_fct)();
+ char *fname, *p1, *p2;
+
+ $DESCRIPTOR(fname_d, "");
+ $DESCRIPTOR(image_d, "");
+ $DESCRIPTOR(buf_d, "");
+
+ decc$to_vms(file, vms_fileact, 0, 0);
+
+ fname = (char *)__alloca(strlen(file)+1);
+ strcpy(fname,file);
+ if (p1 = strrchr(fname,'/'))
+ fname = p1 + 1;
+ if (p2 = strrchr(fname,'.'))
+ *p2 = '\0';
+
+ fname_d.dsc$w_length = strlen(fname);
+ fname_d.dsc$a_pointer = fname;
+ image_d.dsc$w_length = strlen(vms_filespec);
+ image_d.dsc$a_pointer = vms_filespec;
+ buf_d.dsc$w_length = strlen(buf);
+ buf_d.dsc$a_pointer = buf;
+
+ lib$establish(vms_fisexh);
+
+ status = lib$find_image_symbol (
+ &fname_d,
+ &buf_d,
+ &init_fct,
+ &image_d);
+
+ lib$establish(0);
+
+ if (status == RMS$_FNF) {
+ error = dln_strerror();
+ goto failed;
+ } else if (!$VMS_STATUS_SUCCESS(status)) {
+ error = DLN_ERROR();
+ goto failed;
+ }
+
+ /* Call the init code */
+ (*init_fct)();
+
+ return 1;
+ }
+#endif /* __VMS */
+
#ifndef DLN_DEFINED
- rb_notimplement("dynamic link not supported");
+ rb_notimplement();
#endif
#endif /* USE_DLN_A_OUT */
#endif
#if !defined(_AIX) && !defined(NeXT)
failed:
- rb_loaderror("%s - %s", dln_strerror(), file);
+ rb_loaderror("%s - %s", error, file);
#endif
+ return 0; /* dummy return */
}
static char *dln_find_1();
@@ -1511,15 +1644,11 @@ dln_find_exe(fname, path)
const char *path;
{
if (!path) {
-#if defined(__human68k__)
- path = getenv("path");
-#else
- path = getenv("PATH");
-#endif
+ path = getenv(PATH_ENV);
}
if (!path) {
-#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__MACOS__)
+#if defined(MSDOS) || defined(_WIN32) || defined(__human68k__) || defined(__MACOS__)
path = "/usr/local/bin;/usr/ucb;/usr/bin;/bin;.";
#else
path = "/usr/local/bin:/usr/ucb:/usr/bin:/bin:.";
@@ -1581,19 +1710,21 @@ dln_find_1(fname, path, exe_flag)
register char *dp;
register char *ep;
register char *bp;
-#ifndef __MACOS__
struct stat st;
-#else
+#ifdef __MACOS__
const char* mac_fullpath;
#endif
+ if (!fname) return fname;
if (fname[0] == '/') return fname;
if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
return fname;
if (exe_flag && strchr(fname, '/')) return fname;
-#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
+#ifdef DOSISH
if (fname[0] == '\\') return fname;
+# ifdef DOSISH_DRIVE_LETTER
if (strlen(fname) > 2 && fname[1] == ':') return fname;
+# endif
if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
return fname;
if (exe_flag && strchr(fname, '\\')) return fname;
@@ -1623,7 +1754,7 @@ dln_find_1(fname, path, exe_flag)
*/
if (*dp == '~' && (l == 1 ||
-#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
+#if defined(DOSISH)
dp[1] == '\\' ||
#endif
dp[1] == '/')) {
@@ -1660,7 +1791,7 @@ dln_find_1(fname, path, exe_flag)
*bp = '\0';
fprintf(stderr, "\tDirectory \"%s\"\n", fbuf);
fprintf(stderr, "\tFile \"%s\"\n", fname);
- continue;
+ goto next;
}
memcpy(bp, fname, i + 1);
@@ -1668,16 +1799,20 @@ dln_find_1(fname, path, exe_flag)
if (stat(fbuf, &st) == 0) {
if (exe_flag == 0) return fbuf;
/* looking for executable */
- if (eaccess(fbuf, X_OK) == 0) return fbuf;
+ if (!S_ISDIR(st.st_mode) && 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;
+ if (stat(mac_fullpath, &st) == 0) {
+ if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0)
+ return mac_fullpath;
+ }
}
#endif
-#if defined(MSDOS) || defined(NT) || defined(__human68k__) || defined(__EMX__)
+#if defined(DOSISH)
if (exe_flag) {
static const char *extension[] = {
#if defined(MSDOS)
@@ -1685,9 +1820,9 @@ dln_find_1(fname, path, exe_flag)
#if defined(DJGPP)
".btm", ".sh", ".ksh", ".pl", ".sed",
#endif
-#elif defined(__EMX__) || defined(NT)
+#elif defined(__EMX__) || defined(_WIN32)
".exe", ".com", ".cmd", ".bat",
-/* end of __EMX__ or NT*/
+/* end of __EMX__ or _WIN32 */
#else
".r", ".R", ".x", ".X", ".bat", ".BAT",
/* __human68k__ */
@@ -1710,10 +1845,13 @@ dln_find_1(fname, path, exe_flag)
#else
if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf))
return mac_fullpath;
+
#endif
}
}
-#endif /* MSDOS or NT or __human68k__ or __EMX__ */
+#endif /* MSDOS or _WIN32 or __human68k__ or __EMX__ */
+
+ next:
/* if not, and no other alternatives, life is bleak */
if (*ep == '\0') {
return NULL;
@@ -1722,3 +1860,24 @@ dln_find_1(fname, path, exe_flag)
/* otherwise try the next component in the search path */
}
}
+
+#if defined(__VMS)
+
+/* action routine for decc$to_vms */
+static int vms_fileact(char *filespec, int type)
+{
+ if (vms_filespec)
+ free(vms_filespec);
+ vms_filespec = malloc(strlen(filespec)+1);
+ strcpy(vms_filespec, filespec);
+ return 1;
+}
+
+/* exception handler for LIB$FIND_IMAGE_SYMBOL */
+static long vms_fisexh(long *sigarr, long *mecarr)
+{
+ sys$unwind(1, 0);
+ return 1;
+}
+
+#endif /* __VMS */
diff --git a/dln.h b/dln.h
index c29d3bd8e9..182cf9f9f4 100644
--- a/dln.h
+++ b/dln.h
@@ -6,20 +6,27 @@
$Date$
created at: Wed Jan 19 16:53:09 JST 1994
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
#ifndef DLN_H
#define DLN_H
-#ifndef _
-#ifndef __STDC__
-# define _(args) ()
-# define const
-#else
-# define _(args) args
+#ifdef __cplusplus
+# ifndef HAVE_PROTOTYPES
+# define HAVE_PROTOTYPES 1
+# endif
+# ifndef HAVE_STDARG_PROTOTYPES
+# define HAVE_STDARG_PROTOTYPES 1
+# endif
#endif
+
+#undef _
+#ifdef HAVE_PROTOTYPES
+# define _(args) args
+#else
+# define _(args) ()
#endif
char *dln_find_exe _((const char*,const char*));
diff --git a/doc/ChangeLog-1.8.0 b/doc/ChangeLog-1.8.0
new file mode 100644
index 0000000000..d168a50f80
--- /dev/null
+++ b/doc/ChangeLog-1.8.0
@@ -0,0 +1,24345 @@
+Mon Aug 4 17:21:19 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (class_instance_method_list): methods defined in
+ singleton class and extended modules should be included.
+ [ruby-dev:21119]
+
+Mon Aug 4 13:05:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (method_proc): should specify YIELD_FUNC_SVALUE.
+ [ruby-dev:21107]
+
+ * marshal.c (w_object): should not call w_extended for USRMARSHAL
+ dump. [ruby-dev:21106]
+
+Mon Aug 4 10:42:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
+
+ * lib/test/unit/ui/console/testrunner.rb: Flushed io in the
+ Console::TestRunner so that it will output immediately.
+
+Mon Aug 4 10:27:22 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * util.h: remove unnecessary parentheses. [ruby-dev:20879]
+
+Mon Aug 4 10:00:47 2003 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb (receive_responses): raise exception to
+ client_thread. Thanks to William Webber.
+
+Mon Aug 4 09:22:53 2003 William Webber <wew@williamwebber.com>
+
+ * lib/net/imap.rb: convert RD to RDoc.
+
+Mon Aug 4 02:34:05 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (rb_w32_utime): never use utime() of C runtime.
+ [ruby-talk:77782]
+
+Sun Aug 3 23:56:50 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (rb_call_super): should propagate previous block for
+ super call. [ruby-talk:77884]
+
+Sun Aug 3 22:07:47 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkentry.rb: support 'validatecommand' option of
+ TkEntry/TkSpinbox widget
+
+ * ext/tk/sample/{demos-en,demos-jp}/spin.rb: add
+
+Sun Aug 3 19:25:28 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (call_trace_func): clear exception flag temporarily.
+ [ruby-dev:21090]
+
+Sun Aug 3 18:03:44 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * regex.h (re_mbctab): should refer to RUBY_EXPORT. [ruby-ext:02199]
+
+ * lib/un.h (help): new. % ruby -run -e help cp
+
+Sun Aug 3 08:53:06 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/sample/{demos-en,demos-jp}/image3.rb: add
+
+ * ext/tk/lib/tkcanvas.rb: bug fix on Tk object ID management
+
+ * ext/tk/lib/tktext.rb: ditto
+
+Sun Aug 3 02:55:52 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * process.c: modify macro to detect 'MacOS X' [ruby-talk:77849]
+
+ * ext/tcltklib/lib/tcltk.rb: bug fix ( NOT MAINTAINED : only
+ for running 'line2.rb' demo. )
+
+Sun Aug 3 02:45:06 2003 Koji Arai <jca02266@nifty.ne.jp>
+
+ * numeric.c (flo_to_s): get rid of buffer overflow.
+
+Sat Aug 2 23:51:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (appendline): clearerr(3) before raising exception, since
+ exception may be captured by rescue. [ruby-talk:77794]
+
+Sat Aug 2 09:58:13 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: bug fix --- TkGrid failed to treat
+ RELATIVE PLACEMENT
+
+ * ext/tk/sample/demos-en/, demos-jp/: add or modify some
+ widget demo scripts
+
+Sat Aug 2 20:59:38 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick/https.rb: change an option name.
+ :SSLCertStore -> :SSLCertificateStore.
+
+Sat Aug 2 19:18:40 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: respond_to? needs 2nd argument.
+ Thanks Jim Bob. [ruby-talk:77796]
+
+Sat Aug 2 15:11:54 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb (--no-undefined): annoying option removed.
+
+Sat Aug 2 14:53:55 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/mkmf.rb (pkg_config): get configuration by pkg-config. [new]
+
+ * ext/openssl/extconf.rb: use pkg_config.
+
+Sat Aug 2 13:45:17 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c: add "#pragma weak" for __libc_ia64_register_backing_store_base.
+ [ruby-dev:21072]
+
+Sat Aug 2 14:02:39 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * variable.c (classname): find regular class name if not set.
+ [ruby-dev:20496]
+
+Sat Aug 2 09:58:13 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: bug fix --- forgot to entry a widget class
+ name of 'labelframe' widget
+
+ * ext/tk/sample/{demos-en,demos-jp}/{labelframe.rb,paned1.rb,
+ paned2.rb,spin.rb}: add demo-scripts to the JP/EN widget demos
+
+Sat Aug 2 05:04:30 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkentry.rb: bug fix of TkEntry#delete
+
+ * ext/tk/samples/: bug fix of some widget demos
+
+ * ext/tk/lib/tk.rb: support <TkVariable object> == <Symbol>
+
+ * ext/tk/lib/*.rb: freeze some object for security reason
+
+Sat Aug 2 03:30:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_obj_singleton_methods): should not go up to
+ ancestors unless the recursive flag is set. [ruby-list:38007]
+
+ * eval.c (rb_yield_0): expand [] to nil if avalue is set.
+ [ruby-dev:21058]
+
+ * hash.c (env_each_key): use env_keys to avoid environment modify
+ on the fly.
+
+ * hash.c (env_each_value): use env_values for safety.
+
+ * hash.c (env_each): allocate environment array first.
+
+Fri Aug 2 03:20:00 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * lib/yaml/store.rb (YAML::Store#initialize): filename is first
+ argument. Thanks Kent Dahl.
+
+Sat Aug 2 00:49:31 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: refine document.
+
+Fri Aug 1 23:57:45 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * gc.c (rb_gc_mark_locations): no need to swap arguments.
+
+ * gc.c (STACK_LENGTH): insufficient for growing up stack
+ architectures.
+
+ * gc.c (rb_gc, Init_stack) ditto.
+
+Fri Aug 1 23:33:36 2003 Masatoshi Seki <mas@snow.local.>
+
+ * rubytest.rb: set dldpath on darwin.
+
+Fri Aug 1 23:07:38 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: convert RD to RDoc. Thanks William Webber.
+ [ruby-doc:456]
+
+Fri Aug 1 19:48:56 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/syck/rubyext.c (syck_emitter_write_m): forgot to declare
+ "self", making it default to "int".
+
+ * ext/syck/rubyext.c (syck_emitter_simple_write): ditto.
+
+ * gc.c (rb_gc): should mark backing store region on IA64.
+
+Fri Aug 1 18:51:10 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * process.c: bug fix --- preprocessor errors occur on OpenBSD-current
+
+Fri Aug 1 17:13:23 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/openssl/extconf.rb: should replace literally.
+
+Fri Aug 1 16:22:57 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (rb_io_check_readable, rb_io_check_writable): ensure not
+ closed at first.
+
+ * io.c (rb_io_getline): check readable always. (ruby-bugs:PR#1069)
+
+ * io.c (rb_io_each_byte): ditto.
+
+Fri Aug 1 16:02:46 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (READ_DATA_PENDING_PTR): cast to get rid of warnings.
+
+ * ext/socket/socket.c (unix_send_io, unix_recv_io): ditto.
+
+Fri Aug 1 15:53:24 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (isInternalCmd): shouldn't return if find end of str.
+ [ruby-talk:77678]
+
+Fri Aug 1 13:45:14 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (rb_call_super): propagate previous block if a block is
+ given. [ruby-talk:77577]
+
+Fri Aug 1 09:54:38 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_fill): array length may be changed during the
+ block execution. [ruby-talk:77579]
+
+ * array.c (rb_ary_zip): ditto.
+
+ * array.c (rb_ary_fill): ditto.
+
+ * hash.c (env_reject_bang): length may be changed during the block
+ execution.
+
+ * hash.c (env_clear): ditto.
+
+Fri Aug 1 04:58:55 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: bug fix --- forget to eval given block to
+ TkRoot.new method
+
+ * ext/tk/sample/tkoptdb-safeTk.rb: new sample script
+
+Fri Aug 1 00:52:58 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (Init_stack): IA64 requires STACK_LEVEL_MAX to be less than
+ magic number when optimizer turned on, regardless of rlimit
+ values.
+
+Thu Jul 31 23:44:00 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/erb.rb: import erb-2.0.4b4.
+
+Thu Jul 31 23:04:45 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/sample/resource.en, ext/tk/sample/resource.jp:
+ wrong resource file format
+
+ * ext/tk/lib/tk.rb: add Tk::Encoding.{encoding_convertfrom,
+ encoding_convertto}
+
+ * ext/tk/lib/tk.rb: add TkOptionDB.read_with_encoding to read
+ non-utf8 resource file
+
+Thu Jul 31 23:02:47 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/etc/etc.c: revert getenv()'s prototype. use it only when _WIN32
+ is not defined.
+
+Thu Jul 31 20:52:40 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: (IMPORTANT BUG FIX) scan of event keywords
+ doesn't work on recent versions of Tck/Tk
+
+ * ext/tk/lib/tk.rb: initialize error of instance variable on
+ TkComposite
+
+ * ext/tk/lib/multi-tk.rb: initialize error on encoding-system on
+ MultiTkIp
+
+ * ext/tk/lib/tk.rb: trouble on destroying widgets
+
+ * ext/tk/sample/demos-en/, demos-jp/: add JP and EN version of
+ Ruby/Tk widget demos
+
+Thu Jul 31 15:25:12 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * array.c (rb_ary_collect): must get length of array for each
+ iteration. reported on [ruby-talk:77500], and fixed by
+ K.Sasada <ko1@namikilab.tuat.ac.jp> on [ruby-talk:77504]
+
+Thu Jul 31 14:11:54 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/extconf.rb: move gmake specific features
+ into GNUmakefile.
+
+Thu Jul 31 12:36:11 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * bin/erb, lib/erb.rb: add explicit trim mode.
+
+Thu Jul 31 04:59:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (rb_num_coerce_relop): export function.
+
+Thu Jul 31 08:18:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
+
+ * lib/test/unit.rb: A useful return code is now set if tests fail when
+ running automatically using the Console::TestRunner.
+
+Thu Jul 31 07:59:18 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: wrap the command-proc of TkScale --- pass
+ the numeric object to the proc
+
+ * ext/tk/lib/tk.rb: better support for widgets created on
+ Tk interpreter (without Ruby)
+
+ * ext/tk/lib/multi-tk.rb: a little more stable on Multiple Tk
+ interpreters running
+
+Thu Jul 31 00:17:19 2003 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/ftp.rb (return_code): obsolete.
+
+ * lib/net/ftp.rb (last_response_code): new method. lastresp is now
+ alias to last_response_code.
+
+ * lib/net/ftp.rb (last_response): new method.
+
+Wed Jul 30 23:55:44 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): check has been dropped. "_dump must return
+ string." [ruby-dev:21024]
+
+Wed Jul 30 22:35:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (dir_config): allow multiple directories separated
+ by File::PATH_SEPARATOR.
+
+ * lib/mkmf.rb (create_makefile): DLDFLAGS include $LDFLAGS again.
+ [ruby-talk:76894]
+
+ * lib/mkmf.rb (init_mkmf): not default $LDFLAGS to LDFLAGS for
+ ruby itself, but default $DLDFLAGS to DLDFLAGS.
+
+Wed Jul 30 16:17:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): marshal_dump should not take any
+ argument.
+
+Wed Jul 30 15:54:04 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl_ssl.c (ossl_sslctx_initialize): should initialize
+ instance variables. [ruby-talk:77362]
+
+Wed Jul 30 15:39:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.c (proc_options): -F set compiled regular expression to $;.
+ [ruby-talk:77381]
+
+ * string.c (Init_String): no setter type check for $;
+
+Wed Jul 30 15:10:02 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * error.c (rb_raise): snprintf() termination moved to
+ win32/win32.c.
+
+ * win32/win32.c (valid_filename, str_grow): unused.
+
+ * win32/win32.c (NTLoginName, ChildRecord): make static.
+
+ * win32/win32.c (CreateChild): argument check.
+
+ * win32/win32.c (kill): should not call CloseHandle() when
+ OpenProcess() failed.
+
+ * win32/win32.c (rb_w32_vsnprintf, rb_w32_snprintf): ensure buffer
+ terminated. [ruby-talk:69672]
+
+Wed Jul 30 10:54:10 2003 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/ftp.rb (get): fix wrong argument name. Thanks to William
+ Webber.
+
+Wed Jul 30 10:31:37 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/iconv/iconv.c (iconv_convert): append unchanged portion
+ after overflow. [ruby-dev:21006]
+
+ * ext/iconv/extconf.rb: check if iconv() 2nd argument is const.
+
+Wed Jul 30 09:31:55 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (os2-emx): renamed from os2_emx, add flags to
+ CFLAGS and LDFLAGS, and remove lib prefix. [ruby-dev:20993]
+
+ * file.c (rb_file_s_rename): retry with removing new file on
+ DOSISH. [ruby-dev:21007]
+
+ * ext/socket/extconf.rb (sendmsg, recvmsg): check functions.
+
+ * ext/socket/socket.c (unix_send_io, unix_recv_io): raise
+ NotImplementedError unless system calls are available.
+
+ * ext/socket/socket.c (sock_initialize): rename from sock_init()
+ to get rid of conflict with OS/2 socket library.
+
+Wed Jul 30 07:23:14 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkentry.rb: fix lack of methods for TkEntry
+
+ * ext/tk/lib/multi-tk.rb, ext/tk/lib/tk.rb,
+ ext/tk/lib/tkdialog.rb, ext/tk/lib/tkentry.rb,
+ ext/tk/sample/safe-tk.rb, ext/tk/sample/tktimer2.rb: bug fix
+
+ * ext/tk/lib/multi-tk.rb: MultiTkIp.new_* accept a block to
+ eval under the new interpreter
+
+Wed Jul 30 04:36:30 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c,
+ ext/tk/lib/tk.rb, ext/tk/lib/tkafter.rb: additional check of
+ Tk interpreters' status for a little more safety
+
+Wed Jul 30 02:37:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): if object responds to 'marshal_dump',
+ Marshal.dump uses it to dump object. unlike '_dump',
+ marshal_dump returns any kind of object.
+
+ * marshal.c (r_object0): restore instance by calling
+ 'marshal_load' method. unlike '_load', it's an instance
+ method, to handle cyclic reference.
+
+ * marshal.c (marshal_load): all objects read from file should be
+ tainted. [ruby-core:01325]
+
+Wed Jul 30 01:47:51 2003 Hugh Sasse <hgs@dmu.ac.uk>
+
+ * lib/timeout.rb (Timeout::timeout): execute immediately if sec is
+ zero.
+
+Wed Jul 30 01:36:18 2003 Aron Griffis <ruby-talk@griffis1.net>
+
+ * ext/socket/socket.c (socks_init): typo fixed. [ruby-talk:77232]
+
+Wed Jul 30 00:48:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/extconf.rb: the default value for --enable-socks is
+ taken from ENV["SOCKS_SERVER"]. [ruby-talk:77232]
+
+ * ruby.c (proc_options): add -W option. -W0 to shut up all warning
+ messages. [ruby-talk:77227]
+
+ * error.c (rb_warn): no message will be printed if the value of
+ $VERBOSE is "nil", i.e. perfect silence.
+
+ * ruby.c (verbose_setter): $VERBOSE value is either true, false,
+ or nil.
+
+ * io.c (Init_IO): no "read" check for $stdin. in addition some
+ function names has been changed.
+
+Tue Jul 29 23:10:19 2003 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * regex.c (re_match_exec): incorrect multibyte match.
+
+Tue Jul 29 22:36:50 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb (send0): do taint check only when $SAFE > 0
+
+Tue Jul 29 19:20:34 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/fileutils.rb (install): support preserve timestamp.
+
+ * instruby.rb (install): use FileUtils::install preserve mode.
+
+ * lib/un.rb: new. % ruby -run -e cp -- -p foo bar
+
+ * lib/mkmf.rb: use un.rb instead of ftools.rb.
+
+ * MANIFEST: add lib/un.rb.
+
+ * ext/extmk.rb (INSTALL_PROG, INSTALL_DATA): modify verbose messages.
+
+Tue Jul 29 18:55:22 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: unify coding style.
+
+ * lib/net/http.rb: ditto.
+
+Tue Jul 29 17:27:59 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ruby.h (LLONG_MIN): fix typo.
+
+Tue Jul 29 16:38:44 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/net/smtp.rb (Net::SMTP::send0): add taint check.
+
+Tue Jul 29 15:41:02 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * instruby.rb (install): preserve the timestamp for Mac OS X ranlib
+ problem.
+
+Tue Jul 29 01:14:51 2003 Rick Ohnemus <rick_ohnemus@acm.org>
+
+ * ruby.h (LLONG_MIN): wrong value.
+
+Mon Jul 28 22:57:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_f_getc): $stdin may not be IO. [ruby-dev:20973]
+
+Tue Jul 29 16:20:36 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: bug fix and
+ change mainloop_abort_on_no_widget_cmd => mainloop_abort_on_exception
+ ( to avoid thread timing trouble on accessing destroyed widgets )
+
+ * ext/tk/lib/multi-tk.rb: change default mode of
+ mainloop_abort_on_exception on multi-tk.rb
+
+ * ext/tk/lib/multi-tk.rb: fix a bug of the procedure for
+ 'Delete' button on the safe-Tk frmae
+
+Tue Jul 29 12:22:28 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/token.c: prefixed many constants and definitions
+ with YAML_ to avoid name clash.
+
+ * ext/syck/gram.c: ditto.
+
+ * ext/syck/gram.h: ditto.
+
+Tue Jul 29 12:15:37 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/etc/etc.c: add real prototype to getenv().
+
+ * win32/win32.h: add arguments to definitions of functions if possible.
+
+Tue Jul 29 08:05:30 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb, ext/tk/lib/tkdialog.rb, ext/tk/lib/tktext.rb,
+ ext/tk/sample/tkbiff.rb, ext/tk/sample/tkdialog.rb,
+ ext/tk/sample/tkform.rb: bug fix ( tested with Ruby/Tk widget demo )
+
+Tue Jul 29 04:22:08 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/syck.h: Added 'syck' yacc prefixes.
+
+ * ext/syck/gram.c: ditto.
+
+ * ext/syck/token.c: ditto.
+
+ * ext/syck: Added ruby.h reference to source files.
+
+Tue Jul 29 03:53:28 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/lib/net/https.rb (use_ssl=): raise ProtocolError if
+ connection is set up already.
+
+Tue Jul 29 01:45:32 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: use RTEST()
+
+Tue Jul 29 01:24:32 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: bug fix
+
+ * ext/tk/lib/multi-tk.rb: bug fix and pack options are pssed
+ to the safeTk container
+
+ * ext/tk/sample/safe-tk.rb: add example for pack options of
+ safeTk container
+
+Mon Jul 28 23:23:08 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (Init_File): IO should include File::Const.
+ [ruby-dev:20964]
+
+Mon Jul 28 18:53:03 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/openssl/extconf.rb: check again after pkg-config for MinGW on
+ Cygwin.
+
+Mon Jul 28 15:32:04 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/stringio/stringio.c (strio_gets): only "gets" should set $_.
+
+ * ext/stringio/stringio.c (strio_getline): should not set $_ here.
+
+ * io.c (argf_to_s): argf.to_s returns "ARGF".
+
+ * io.c (set_defout_var, set_deferr_var): make $defout and $deferr
+ obsolete.
+
+ * io.c (set_input_var, set_output_var): allow $stdin, $stdout,
+ $stderr not to be instance of IO.
+
+ * io.c (rb_f_readline): forward method to current_file. gets,
+ readline, readlines, getc, readchar, tell, seek, pos=, rewind,
+ fileno, to_io, eof, each_line, each_byte, binmode, and closed?
+ as well.
+
+ * io.c (argf_forward): utility function to forward method to
+ current_file.
+
+Mon Jul 28 06:10:13 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: bug fix
+
+ * ext/lib/tk/multi-tk.rb: bug fix
+
+ * ext/lib/tk/multi-tk.rb: add methods depend on Tcl's 'interp' command
+
+ * ext/lib/tk/multi-tk.rb: suppot safe-level control of each interpreter
+
+Mon Jul 28 03:08:47 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: each() should return self.
+
+Mon Jul 28 01:35:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_chomp_bang): defer rb_str_modify() to actual
+ modify point. other methods, replace, tr, delete, squeeze,
+ lstrip, and rstrip as well.
+
+ * string.c (rb_str_rstrip_bang): remove trailing '\0' at the end
+ of string.
+
+ * string.c (rb_str_lstrip_bang): do not strip '\0' from the left.
+
+Sun Jul 27 21:16:30 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/openssl/extconf.rb: better support MinGW. add
+ dir_config("kerberos") and with_config("pkg-config").
+
+ * mkconfig.rb: initialize global variables to avoid warnings.
+
+Sun Jul 27 19:35:06 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: add some methods to support
+ multiple interpreters (low level)
+
+ * ext/tk/lib/multi-tk.rb: new library to support multiple Tk
+ interpreters (high level)
+
+ * ext/tcltklib/demo/safeTk.rb: new sample of safeTk interpreter
+
+ * ext/tk/sample/safe-tk.rb: new sample of multi-tk.rb
+
+ * ext/tk/lib/tk.rb: bug fix and add feature to supprt multi-tk
+
+ * ext/tk/lib/tkafter.rb: ditto
+
+Sun Jul 27 14:43:37 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+
+ * lib/debug.rb: fix breakpoint parameter parsing/checking.
+ (?:(file|class):)(line_number|method)
+
+Sun Jul 27 10:21:28 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/drb/unix.rb: add UNIXFileOwner, UNIXFileGroup.
+
+Sun Jul 27 03:10:43 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (io_reopen): avoid dup2() equal handles not to close itself and
+ to get rid of a msvcrt bug. [ruby-dev:20919]
+
+Sun Jul 27 00:37:16 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/tmpdir.rb: use GetWindowsDirectory, not GetSystemDirectory.
+ [ruby-talk:77073]
+
+Sat Jul 26 21:25:21 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * io.c (rb_fdopen): set errno if it's zero on win32 platforms.
+
+ * ext/openssl/ossl_ssl.c (TO_SOCKET): define special version when
+ _WIN32 is defined. this is ruby's problem, not OpenSSL.
+
+ * win32/win32.c: remove some old comments.
+
+Sat Jul 26 14:26:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/tk/lib/tk.rb (TkCore::chooseDirectory): back up wrongly
+ removed method.
+
+Sat Jul 26 14:14:12 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/stringio/stringio.c: includes Enumerable as well as IO.
+ [ruby-talk:77058]
+
+Sat Jul 26 07:00:53 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/erb.rb: fix % line.
+
+Sat Jul 26 05:31:09 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl.h: fix comment.
+
+ * ext/openssl/ossl.c (ossl_debug): should enable if no va-args
+ macro supplied.
+
+Sat Jul 26 04:04:36 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/extconf.rb: refine va-args macro detection.
+ [ruby-talk:76983]
+
+Sat Jul 26 01:33:51 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/openssl/ossl_ssl.c (ossl_ssl_setup): need to pass the real
+ socket to SSL_get_fd on native win32 platforms.
+
+Sat Jul 26 01:20:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_const_missing): "const_missing" should not
+ appear in the caller(); add call frame adjustment.
+
+ * eval.c (rb_method_missing): simplify call frame adjustment.
+
+Fri Jul 26 00:04:25 2003 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * ext/openssl/sample: add samples.
+ - cert2text.rb: dump certificate file as text.
+ - crlstore.rb: CRL store implementation. Fetch CRL via HTTP when
+ http-access2 is installed.
+ - certstore.rb: certificate store implementation.
+ - cert_store_view.rb: certificate store viewer with FXRuby. Uses
+ c_rehash.rb, crlstore.rb and certstore.rb.
+
+Fri Jul 25 16:43:03 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: add TclTkIp#create_slave,
+ TclTkIp#_make_safe and TclTkIp#safe?
+
+ * ext/tcltklib/MANUAL.euc: modify descriptions
+
+ * ext/tk/lib/tk.rb: bug fix [ruby-talk:76980] and modify to
+ support multi Tk IPs
+
+ * ext/tk/lib/tkafter.rb: modify to support multi Tk IPs
+
+Fri Jul 25 15:47:39 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/extconf.rb: add check for BN_rand_range() and
+ BN_pseudo_rand_range().
+
+ * ext/openssl/ossl_bn.c (ossl_bn_s_rand_range): should raise
+ NotImplementedError if BN_rand_range() wan not defined.
+
+ * ext/openssl/ossl_bn.c (ossl_bn_s_pseudo_rand_range): should raise
+ NotImplementedError if BN_pseudo_rand_range() wan not defined.
+
+ * ext/openssl/ossl_pkcs7.c (ossl_pkcs7_s_encrypt): avoid compiler
+ warning for OpenSSL-0.9.6.
+
+ * ext/openssl/ossl_pkcs7.c (ossl_pkcs7si_initialize): ditto.
+
+Fri Jul 25 14:34:55 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): was using
+ uninitialized size_t value. [ruby-talk:76946]
+
+Fri Jul 25 13:38:38 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * re.c (rb_reg_options_m): use rb_reg_options() to mask internal
+ flags.
+
+ * re.c (rb_reg_initialize_m): allow nil as third argument and
+ ignore, and mask code flags if the argument is given.
+ [ruby-dev:20885]
+
+ * re.c (rb_reg_options): get common flags directly.
+
+Fri Jul 25 03:52:21 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * lib/yaml/dbm.rb: replace indexes with values_at.
+
+Fri Jul 25 02:55:59 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/extconf.rb: add check for libsocket and libnsl.
+
+ * ext/openssl/extconf.rb: use pkg-config to build CFLAGS and LDFLAGS.
+
+Fri Jul 25 01:27:59 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/emitter.c (syck_emitter_flush): accepts count
+ of bytes to flush. anchor offsets now functional.
+
+ * ext/syck/syck.h (syck_emitter_flush): ditto.
+
+ * ext/syck/rubyext.c: ditto.
+
+ * ext/syck/token.c: URI escaping now supported.
+
+Thu Jul 24 16:41:31 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (have_type): check if a type is defined.
+
+ * lib/mkmf.rb (check_sizeof): check size of a type.
+
+ * ext/dbm/extconf.rb: check if type DBM is defined.
+ [ruby-talk:76693]
+
+Thu Jul 24 16:18:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ChangeLog (add-log-time-format): "%c" contains timezone on
+ XEmacs.
+
+Thu Jul 24 16:05:22 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (AC_C_VOLATILE): check if volatile works.
+
+ * defines.h (volatile): removed.
+
+ * eval.c (rb_thread_group): Thread#group. [new]
+
+Thu Jul 24 15:50:42 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/extconf.rb: add check for win32 OpenSSL libraries.
+
+ * ext/openssl/extconf.rb: add check for __VA_ARGS__.
+
+ * ext/openssl/ossl.h: avoid non C99 compiler errors.
+
+Thu Jul 24 13:32:56 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (thgroup_add): no warning for terminated threads.
+
+Thu Jul 24 13:09:26 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/pathname.rb: added.
+
+Thu Jul 24 11:21:10 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/io/wait/extconf.rb: removed unnecessary backward
+ compatibility stuff.
+
+Thu Jul 24 11:09:10 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/openssl/extconf.rb: revert use of dir_config.
+
+Thu Jul 24 09:58:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/Win32API/lib/win32/resolv.rb: added.
+
+ * lib/resolv.rb: support Win32 platforms. based on Tietew's work
+ [ruby-dev:15573].
+
+Thu Jul 24 04:05:46 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ssl.h: undef X509_NAME and PKCS7_SIGNER_INFO to
+ avoid name confliction on mswin32.
+
+ * ext/openssl/ssl.c (ossl_protect_obj2bio): avoid VC++ warnings
+ in function prototype.
+
+ * ext/openssl/ssl.c (ossl_protect_membio2str): ditto.
+
+ * ext/openssl/ssl.c (ossl_protect_x509_ary2sk): ditto.
+
+Thu Jul 24 03:44:04 2003 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * ext/openssl/extconf.rb: cut check for OpenSSL version
+
+Thu Jul 24 03:41:30 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/tcltklib/tcltklib.c (ip_init): need at least one statement after
+ label.
+
+Thu Jul 24 01:48:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi.rb (CGI::QueryExtension::[]): should return StringIO (or
+ Tempfile) for multipart/form.
+
+ * variable.c (rb_define_const): give warning for non constant
+ name. [ruby-core:01287]
+
+Thu Jul 24 01:51:08 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * lib/webrick: imported.
+
+ * MANIFEST: added webrick files.
+
+Thu Jul 24 01:32:04 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/tmpdir.rb (tmpdir): new method. remove TMPDIR.
+ use GetSystemWindowsDirectory(GetSystemDirectory), not GetTempPath.
+
+Thu Jul 24 01:08:43 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl: imported.
+
+Wed Jul 23 23:06:59 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * file.c (DOSISH): better Cygwin support.
+
+Wed Jul 23 19:13:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_split_m): the receiver may be empty string.
+
+Wed Jul 23 18:43:00 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/erb.rb: import erb-2.0.4b1.
+
+Wed Jul 23 18:21:52 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/io/wait: imported.
+
+Wed Jul 23 16:07:35 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * process.c: unify indentation
+
+ * configure.in: add --enable-setreuid option
+
+ * ext/tcltklib/tcltklib.c: TclTkIp.new accepts 'ip-name' and 'options'
+
+ * ext/tk/lib/tk.rb: support arguments of TclTkIp.new
+
+ * ext/tk/lib/tk*.rb: preparations for multi-Tk interpreter support
+
+Wed Jul 23 15:49:01 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_lstrip_bang): strip NUL along with white
+ spaces. [ruby-talk:76659]
+
+ * string.c (rb_str_rstrip_bang): ditto.
+
+Wed Jul 23 14:19:17 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (log_src, checking_for, create_header):
+ Logging.message is printf like format.
+
+Wed Jul 23 10:11:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/iconv/iconv.c (check_iconv): check if Iconv instance.
+
+ * ext/iconv/iconv.c (iconv_convert): stringify argument.
+
+Wed Jul 23 02:39:46 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * process.c: add a module for raw syscalls to control UID/GID
+
+ * process.c: add modules for portable UID/GID control
+
+Tue Jul 22 19:16:40 2003 Tanaka Akira <akr@m17n.org>
+
+ * ext/iconv/iconv.c (iconv_failure_initialize): limit
+ inspect message. [ruby-dev:20785]
+
+ * ext/iconv/iconv.c (rb_str_derive): share with original
+ string if possible. [ruby-dev:20785]
+
+Tue Jul 22 17:22:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_const_missing): new method. [ruby-core:00441]
+
+ * variable.c (rb_const_get_at): allow "const_missing" hook.
+
+ * variable.c (rb_const_get_0): ditto.
+
+ * eval.c (method_missing): rename from rb_undefined to clarify.
+
+ * eval.c (ruby_finalize_0): update exit status if any of END proc
+ raises SystemExit. [ruby-core:01256]
+
+ * signal.c (rb_trap_exit): wrap rb_eval_cmd
+
+ * eval.c (rb_exec_end_proc): reduce rb_protect().
+
+Tue Jul 22 17:15:57 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * MANIFEST (lib/cgi/session/pstore.rb, lib/yaml/baseemitter.rb):
+ added.
+
+Tue Jul 22 10:52:19 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/tmpdir.rb: remove charcters after "\000" and regularize path.
+
+Tue Jul 22 02:22:45 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_equal): should not use rb_equal().
+
+ * string.c (rb_str_equal): should return nil for non string
+ operand to conform comparable convention. [ruby-dev:20759]
+
+Tue Jul 22 00:19:19 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/tmpdir.rb: new library to get temporary directory path,
+ using GetTempPath on Win32 environment.
+
+ * lib/tempfile.rb: now uses tmpdir.rb.
+
+ * lib/cgi/session.rb, ib/drb/unix.rb: ditto.
+
+Mon Jul 21 01:53:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_string_value_cstr): check null byte in the string
+ before retrieving C ptr. accessed via macro StringValueCStr.
+
+ * file.c: use StringValueCStr to retrieve paths to system calls.
+
+ * file.c (sys_fail2): raise error for two operand system calls
+ such as rename, link, symlink. (ruby-bugs PR#1047)
+
+Sun Jul 20 11:03:25 2003 UENO Katsuhiro <katsu@blue.sky.or.jp>
+
+ * ext/zlib/zlib.c (gzfile_read_header): gz->z.input may be nil after
+ finishing reading a gzip header.
+
+Sat Jul 19 22:25:47 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_match2): add warning to "~string".
+ [ruby-list:37751]
+
+ * lib/net/ftp.rb (Net::FTP::open): takes block. suggested by Gavin
+ Sinclair in [ruby-core:01237].
+
+Sat Jul 19 19:03:24 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/stdlib.c: add bsearch().
+
+Sat Jul 19 12:34:45 2003 David Black <dblack@superlink.net>
+
+ * lib/scanf.rb: import.
+
+Sat Jul 19 11:27:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/xmlrpc: import.
+
+ * eval.c (thgroup_add): should return group for terminated thread
+ case.
+
+ * eval.c (thgroup_add): do not raise ThreadError on terminated
+ thread addition for compatibility. just warning.
+
+Sat Jul 19 04:50:56 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/iconv/charset_alias.rb, ext/iconv/extconf.rb: make wrapper
+ script which maps charset names. [ruby-dev:20625]
+
+ * ext/iconv/iconv.c (charset_map): charset name map.
+
+ * ext/iconv/iconv.c (iconv_dfree): no exception while
+ finalization.
+
+ * ext/iconv/iconv.c (iconv_s_conv): new method Iconv.conv.
+ [ruby-dev:20588]
+
+Sat Jul 19 03:09:18 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/Win32API/lib/win32/registry.rb (Win32::Registry::Error):
+ inherit StandardError instead of SystemCallError.
+
+Sat Jul 19 02:00:39 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_attr): extra calls of method_added. [ruby-talk:76361]
+
+Fri Jul 18 18:44:22 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (init_mkmf): clear $INSTALLFILES. [ruby-dev:20727]
+
+Fri Jul 18 17:34:39 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (rm_f): use FileUtils.
+
+ * lib/mkmf.rb (modified?): return mtime of the target if
+ it exists and newer than times.
+
+ * lib/mkmf.rb (install_files): add a current directory
+ file even if it does not exist yet.
+
+ * lib/mkmf.rb (configuration): do not add $LDFLAGS to
+ DLDFLAGS.
+
+ * ext/extmk.rb (extmake): check whether Makefile is newer
+ than depend and MANIFEST.
+
+Fri Jul 18 14:57:19 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (make_cmdvector): recognize quote within string.
+ based on Nobu's patch ([ruby-win32:450]). [ruby-talk:75853]
+
+Fri Jul 18 13:04:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_missing): VCALL is called only for LOCAL_ID. no
+ check required.
+
+ * parse.y (primary): primary:tFID generates NODE_FCALL.
+ [ruby-dev:20641]
+
+Thu Jul 17 18:50:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (match_captures): rename from "groups".
+
+Thu Jul 17 17:57:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_clear_cache_by_class): check both klass and origin.
+
+Thu Jul 17 13:46:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_init): set ruby_running to true after
+ initialization.
+
+Thu Jul 17 13:42:53 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/ftools.rb (File::makedirs): do not handle "//" as a directory.
+
+Thu Jul 17 06:40:28 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: recover and fix typo : Tk.chooseDirectory
+ (Tk8.4 feature)
+
+Wed Jul 16 16:23:58 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_proc_new): call svalue_to_avalue for yield argument.
+
+Wed Jul 16 00:31:00 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_disable_super, rb_enable_super): deprecate.
+
+ * eval.c (thgroup_s_alloc): re-implement group struct.
+
+ * eval.c (thgroup_add): add check for enclose and frozen status.
+
+Tue Jul 15 19:50:49 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_add_method, rb_alias): need to clear cache by
+ ID when method defined in parent class is cached for
+ grand child classes. [ruby-dev:20672]
+
+Tue Jul 15 14:38:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/matrix.rb: remove elements conversion to_f, to_i, to_r.
+
+ * lib/cgi/session/pstore.rb: add new file.
+
+Tue Jul 15 03:30:41 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c (syck_mark_emitter): forgot to rb_gc_mark the
+ outgoing IO object.
+
+Sun Jul 13 14:55:36 2003 Koji Arai <jca02266@nifty.ne.jp>
+
+ * process.c (proc_getgroups, proc_setmaxgroups): fix typo.
+
+Sat Jul 12 17:01:28 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * struct.c (struct_entry): add prototype to avoid VC++ warnings.
+
+Sat Jul 12 04:43:57 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/emitter.c: new emitter code.
+
+ * ext/syck/rubyext.c: Emitter class.
+
+ * lib/yaml.rb: Load Syck emitter, if available.
+
+ * lib/yaml/stream.rb: ditto.
+
+ * lib/yaml/baseemitter.rb: underlying class for all emitters.
+
+ * lib/yaml/rubytypes.rb: use BaseEmitter abstraction.
+
+ * lib/yaml/emitter.rb: ditto.
+
+Sat Jul 12 04:23:13 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_undef): need to clear cache for inherited class.
+ (rubicon/builtin/TestModulePrivate.rb:test_undef_method)
+
+Sat Jul 12 01:21:54 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (avalue_to_svalue): typo.
+
+ * eval.c (rb_load): rb_prohibit_interrupt must not underflow.
+
+ * parse.y (NODE_STRTERM, tokadd_string, parse_string): moved
+ string nest level from a static variable to NODE_STRTERM, to
+ preserve it from word to word in %W/%w.
+
+Fri Jul 11 22:37:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (aix): needs ruby.imp even with gcc.
+ (ruby-bugs:PR#1007)
+
+Fri Jul 11 18:37:37 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * instruby.rb: do not handle directories. [ruby-dev:20613]
+
+Fri Jul 11 16:09:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * util.c (ruby_strtod): exp should be less than MDMAXEXPT.
+
+Fri Jul 11 07:17:47 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: not create a Tcl/Tk interpreter if already
+ defined TkCore::INTERP
+
+ * ext/tk/lib/tk.rb: bugfix on TkWindow#configure
+
+Thu Jul 10 14:42:02 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * math.c (math_log): nan takes a dummy argument on Cygwin 1.5.0.
+
+Wed Jul 9 23:50:46 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * regex.c (mbctab_sjis): 0x80 is not shift jis first byte.
+ [ruby-dev:20516]
+
+Wed Jul 9 15:38:28 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * instruby.rb: do not install shared libraries as man pages.
+
+ * mkconfig.rb: support text-mount on Cygwin.
+
+Wed Jul 9 11:09:57 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * re.c (match_entry): add prototype to avoid VC++ warnings.
+
+Wed Jul 9 03:48:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_load): put rb_load_file() in a thread critical
+ section. [ruby-dev:20490]
+
+ * eval.c (compile): put rb_compile_string() in a thread critical
+ section.
+
+Tue Jul 8 02:35:41 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_const_get_0): should not warn if constant is not
+ defined. (ruby-bugs-ja PR#509)
+
+ * bignum.c (rb_big2dbl): give a warning on overflow.
+ (ruby-bugs-ja PR#510)
+
+ * util.c (ruby_strtod): change MDMAXEXPT from 511 to 308.
+
+ * pack.c (utf8_to_uv): long is sufficient. LONG_LONG is not
+ required.
+
+Tue Jul 8 01:43:16 2003 Koji Arai <jca02266@nifty.ne.jp>
+
+ * bignum.c (rb_big2str): support 32 bit (without `long long' type)
+ machines. (ruby-bugs-ja PR#512)
+
+Mon Jul 7 10:22:46 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/dbm/extconf.rb (gdbm_compat, qdbm): add check for gdbm_compat
+ and qdbm.
+
+Mon Jul 7 01:34:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call_super): k->super maybe NULL if klass is Kernel.
+ [ruby-dev:20519]
+
+ * gc.c (obj_free): clear method cache when freeing class/module.
+
+Sat Jul 5 23:32:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_remove_method): allow "remove_method" to accept
+ multiple arguments.
+
+Sat Jul 5 00:22:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * node.h (NEW_NODE): cast arguments to rb_node_newnode().
+
+Fri Jul 4 21:48:44 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/syck/rubyext.c, ext/syck/syck.c, ext/syck/syck.h,
+ ext/syck/token.c: C++ style comments are not allowed.
+ (ruby-bugs:PR#1008)
+
+Thu Jul 3 23:41:30 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/timeout.rb: add optional exception argument for compatibility
+ function.
+
+Thu Jul 3 14:22:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_values_at): extract common procedure from
+ rb_ary_values_at. follow DRY principle.
+
+ * re.c (match_values_at): values_at should understand ranges.
+
+ * struct.c (rb_struct_values_at): ditto.
+
+ * struct.c (inspect_struct): inspect format changed; add "struct "
+ at the top.
+
+ * sprintf.c (rb_f_sprintf): "%p" specifier for inspect output.
+ (RCR#69)
+
+ * eval.c (rb_mod_undef_method): allow "undef_method" to accept
+ multiple arguments. (RCR#146)
+
+ * lib/timeout.rb: put timeout in Timeout module. (RCR#121)
+ [ruby-talk:61028]
+
+ * re.c (match_groups): new method added. (RCR#139)
+
+ * variable.c (rb_mod_const_of): should exclude constant defined
+ in Object, unless retrieving constants of Object.
+
+Thu Jul 3 12:13:05 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (VPATH): convert from Windows form to Unix form on
+ MinGW. This fixes the build with GNU make 3.80-1 for Cygwin.
+
+Wed Jul 2 23:27:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_new4): do not allocate new string if original
+ is frozen or already have copy-on-write entry. [ruby-talk:74940]
+
+Wed Jul 2 13:22:39 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_shared_replace): clear flags before copy.
+
+ * string.c (rb_str_replace): ditto.
+
+ * eval.c (rb_yield_0): override visibility mode for module_eval
+ etc. (ruby-bugs-ja PR#505)
+
+Wed Jul 2 11:45:34 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: synchronize document with source code.
+
+ * lib/net/pop.rb: ditto.
+
+Wed Jul 2 11:39:50 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: unify SMTP and SMTPCommand.
+
+ * lib/net/smtp.rb: new exception class SMTPError.
+
+ * lib/net/smtp.rb: new exception class SMTPAuthenticationError.
+
+ * lib/net/smtp.rb: new exception class SMTPServerBusy.
+
+ * lib/net/smtp.rb: new exception class SMTPSyntaxError.
+
+ * lib/net/smtp.rb: new exception class SMTPFatalError.
+
+ * lib/net/smtp.rb: new exception class SMTPUnknownError.
+
+ * lib/net/smtp.rb: change critical section protect algorithm.
+
+ * lib/net/smtp.rb (SMTP#do_start): check authentication args
+ before all.
+
+ * lib/net/smtp.rb: new method send_message (alias send_mail).
+
+ * lib/net/smtp.rb: new method open_message_stream (alias ready).
+
+ * lib/net/pop.rb: POPBadResponse is a POPError.
+
+ * lib/net/pop.rb (POPMail#pop): ban ReadAdapter.
+
+ * lib/net/pop.rb (POPMail#top): ditto.
+
+ * lib/net/pop.rb (POP3Command): change critical section protect
+ algorithm.
+
+ * lib/net/pop.rb (POP3Command#auth): USER and PASS should be one
+ critical block.
+
+ * lib/net/pop.rb (POP3Command#retr): ban `dest' argument using
+ iterator.
+
+ * lib/net/pop.rb (POP3Command#top): ditto.
+
+ * lib/net/protocol.rb: #read_message_to -> #each_message_chunk
+
+ * lib/net/protocol.rb: #D -> #LOG
+
+ * lib/net/protocol.rb: #D_off -> #LOG_off
+
+ * lib/net/protocol.rb: #D_on -> #LOG_on
+
+Wed Jul 2 11:10:47 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: set old class aliases for backward
+ compatibility. [ruby-talk:74863]
+
+ * lib/net/protocol.rb: ditto.
+
+Wed Jul 2 01:32:40 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/net/pop.rb (Net::POP3#start): typofix.
+
+Tue Jul 1 22:08:19 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: TkWindow include TkWinfo
+
+ * ext/tk/lib/tk.rb: treat unknown widget classes as subclasses
+ of TkWindow
+
+Tue Jul 1 19:02:12 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * parse.y (rb_intern): should use mbclen instead of mblen.
+
+Tue Jul 1 10:36:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * class.c (rb_define_class, rb_define_module): also set constant under
+ Object. [ruby-dev:20445]
+
+ * object.c (boot_defclass): ditto.
+
+ * variable.c (rb_const_get_at, rb_const_get_0, rb_mod_const_at,
+ rb_const_defined, mod_av_set, rb_const_assign): toplevel constants
+ are now under Object, rb_class_tbl remains for GC.
+
+Mon Jun 30 17:53:06 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (mnew): ignore metaclasses have no influence, for rklass.
+ [ruby-talk:74706]
+
+Sun Jun 29 06:59:07 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/drb/drb.rb, lib/drb/invokemethod.rb: import drb-2.0.4
+ (use LocalJumpError#reason)
+
+Sat Jun 28 12:28:54 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (rb_cv_stack_grow_dir): check stack growing direction.
+
+ * eval.c (rb_thread_restore_context): prior configuration macro.
+
+ * gc.c (ruby_stack_length): always return the address of lower edge.
+
+ * gc.c (rb_gc_mark_locations): remove margin. [ruby-dev:20462]
+
+ * gc.c (rb_gc, Init_stack): prior configuration macro.
+
+ * gc.c (Init_stack): add safety margin.
+
+Fri Jun 27 14:41:22 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * string.c (rb_str_split_m): remove white spaces on the head of
+ the last element, when limit is specified. [ruby-talk:74506]
+
+Fri Jun 27 03:24:54 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (io_fflush): need to check if closed after thread switch.
+ [ruby-dev:20351]
+
+ * io.c (fptr_finalize): ditto.
+
+ * string.c (rb_str_rindex_m): fixed wrong fix. should move backward
+ first only when matching from the end.
+
+Thu Jun 26 21:34:49 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * class.c (class_instance_method_list): get rid of warning about
+ arguement type mismatch, and inline method_list().
+ [ruby-core:01198]
+
+Wed Jun 25 14:40:33 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: add and modify methods ---
+ TkWidget.database_class, TkWidget.database_classname,
+ TkWidget#database_class, TkWidget#database_classname
+
+ * ext/tk/lib/tk.rb: instances of a subclass of TkToplevel or
+ TkFrame are created with ":class=>subclass" option as default.
+
+ * ext/tk/sample/tkoptdb.rb: add a new part
+
+Wed Jun 25 12:52:58 2003 Matthew Dempsky <jivera@flame.org>
+
+ * class.c (rb_generic_class_instance_methods): merge argument
+ check (and warning) into one function; following DRY principle.
+ [ruby-core:01193]
+
+Wed Jun 25 05:49:10 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: add widget destroy hook binding to TkBindTag::ALL
+
+ * ext/tk/lib/tkcanvas.rb: Although requiring manual control of GC,
+ memory eating problem of TkCanvas Items is fixed.
+
+ * ext/tk/lib/tktext.rb: add some methods and bug fix
+
+Wed Jun 25 00:14:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (autoload_delete): should delete Qundef from iv_tbl.
+ (ruby-bugs-ja PR#504)
+
+Tue Jun 24 16:46:07 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: bug fix on TkToplevel, TkFrame,
+ TkPanedwindow, TkOptionDB
+
+ * ext/tk/lib/tk.rb: TkOptionDB --- make it more secure to use procs
+ defined on resourceDB
+
+ * ext/tk/sample/tkoptdb.rb, resource.ja, resource.en:
+ sample script how to use TkOptionDB.
+
+Tue Jun 24 14:22:41 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * lib/yaml/types.rb: replaced Kernel::Hash reference with Object::Hash
+ from [ruby-talk:74270]
+
+Tue Jun 24 17:59:30 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_yield_0): show yielded block position not only yielding
+ point. [ruby-dev:20441]
+
+Tue Jun 24 16:47:07 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb (HTTPHeader#proxy_basic_auth): missing `@'.
+ Thanks Douglas Koszerek. (ruby-bugs:PR975)
+
+Tue Jun 24 14:31:17 2003 Minero Aoki <aamine@loveruby.net>
+
+ * config.guess: have wrongly returned "alphaev56-unknown-linux-"
+ on Linux/Alpha. [ruby-dev:20434]
+
+Tue Jun 24 04:54:46 2003 Minero Aoki <aamine@loveruby.net>
+
+ * configure.in: always add -mieee for gcc/alpha. [ruby-dev:20429]
+
+Tue Jun 24 02:40:09 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * array.c (rb_ary_unshift_m): need to check number of arguments.
+ [ruby-talk:74189]
+
+Mon Jun 23 23:59:56 2003 Minero Aoki <aamine@loveruby.net>
+
+ * io.c (io_close): missing prototype. [ruby-dev:20422]
+
+ * ext/socket/socket.c (bsock_do_not_rev_lookup_set): ditto.
+
+ * ext/win32ole/win32ole.c (foletype_guid, foletype_progid): ditto.
+
+ * error.c (syserr_initialize): length argument of sprintf() is an
+ int.
+
+Mon Jun 23 23:28:14 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * MANIFEST: add wince files.
+
+ * ext/tk/MANIFEST: add sample/tkmenubutton.rb.
+
+Mon Jun 23 17:40:58 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * dir.c (find_dirsep): get rid of warnings.
+
+ * eval.c (error_print): temporary value might be disposed by GC.
+
+ * hash.c (env_has_value, env_index): should not increment NULL.
+
+ * io.c (io_read, rb_io_sysread): not read when length is 0.
+
+ * io.c (rb_io_reopen): ensure initialized IO.
+
+ * io.c (rb_io_init_copy): sychronize file pointer.
+
+ * io.c (rb_io_s_pipe): make exception proof.
+
+ * string.c (rb_str_rindex_m): Fixnum 0 matched end of string.
+
+Mon Jun 23 16:18:12 2003 Tanaka Akira <akr@m17n.org>
+
+ * io.c (rb_open_file): initialize flags.
+
+ * time.c (time_arg): initialize v[6] even when argc is 10 to
+ avoid valgrind error.
+
+Mon Jun 23 14:22:44 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: bug fix on TkRoot and TkToplevel
+
+Mon Jun 23 08:24:01 2003 Florian Frank <flori@nixe.ping.de>
+
+ * string.c (rb_str_upto): generate sequence according to "succ"
+ order. formerly check was done by dictionary order.
+ [ruby-talk:74138]
+
+Mon Jun 23 00:27:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_string_value): fill constant empty string along
+ with setting ELTS_SHARED if str->ptr is NULL. [ruby-core:01179]
+
+ * string.c (rb_string_value_ptr): ditto.
+
+ * string.c (rb_check_string_type): ditto.
+
+Sun Jun 22 23:42:20 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * string.c (str_gsub): move END(0) check before mbclen2().
+
+ * string.c (scan_once): reduce END(0) check.
+
+ * io.c (rb_io_initialize): accept fixnum mode.
+
+ * eval.c (error_print): replace strchr() by memchr(), einfo may
+ contain "\0".
+
+ * pack.c (pack_unpack): range check for "@" move; initialize check
+ for "m".
+
+ * error.c (syserr_initialize): avoid buffer overflow.
+
+ * file.c (rb_file_s_readlink): expand buffer until readlink
+ succeed.
+
+Sun Jun 22 16:17:02 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: TkRoot.new and TkToplevel.new accept Wm
+ commands as elements
+
+ * ext/tk/lib/tk.rb: TkMenu --- add some methods
+
+ * ext/tk/lib/tk.rb: TkOptionMenubutton --- bug fix
+
+ * ext/tk/sample/tkmenubutton.rb: sample of TkMenubutton and
+ TkOptionMenubutton
+
+Sat Jun 21 23:15:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_invoke): should not propagate distination tag if
+ tag is already handled in this level. (ruby-bugs-ja PR#501)
+
+ * object.c (str_to_id): check for empty string before intern.
+ [ruby-talk:74006]
+
+Sat Jun 21 13:56:09 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/Makefile.sub: undefine HAVE__SETJMP.
+
+ * wince/resource.rb: include winver.h in wince3.0.
+
+Sat Jun 21 12:55:17 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: TkRoot.new and TkToplevel.new accept Wm commands
+ as elements of a hash argument.
+
+ * ext/tk/sample/tktimer2.rb: add comments about the usage of a
+ TkTimer object.
+
+Sat Jun 21 08:47:22 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk*.rb: remove direct-accesses to TkComm::INTERP and
+ TkComm::INITIALIZE_TARGETS
+
+ * ext/tk/lib/tk*.rb: use TkINTERP_SETUP_SCRIPTS constant for setting
+ up the interpreter
+
+ * ext/tcltklib/tcltklib.c: support to create a safe interpreter
+ with safe-Tk
+
+Fri Jun 20 23:28:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_invoke): should not propagate TAG_BREAK and
+ TAG_RETURN from orphan Proc object. [ruby-core:01148]
+
+Fri Jun 20 15:04:28 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * defines.h (PATH_ENV): name of PATH environment. [new].
+
+ * defines.h (ENV_IGNORECASE): define for case insensitive platforms
+ to access environment variables.
+
+ * dln.c (dln_find_exe): use PATH_ENV instead of "PATH".
+
+ * hash.c (env_delete, rb_f_getenv, env_fetch, rb_env_path_tainted,
+ env_aset): ditto.
+
+ * ruby.c (proc_options): ditto.
+
+Fri Jun 20 14:52:46 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: Tk interpreter returns TAINTED strings.
+
+Fri Jun 20 03:09:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (new_yield): distinguish "yield 1,2" and "yield [1,2]".
+ [ruby-dev:20360]
+
+ * eval.c (rb_eval): support new_yield() change.
+
+ * variable.c (rb_const_get_0): warn for Foo::BAR when BAR is a
+ toplevel constant (i.e. a constant defined under Object).
+ [ruby-list:36935]
+
+ * parse.y (no_blockarg): separate no block argument check and
+ ret_args argument processing.
+
+Fri Jun 20 00:45:19 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+
+ * lib/csv.rb: import csv module.
+
+Thu Jun 19 22:51:41 2003 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
+
+ * lib/drb.rb, lib/drb/drb.rb, lib/drb/eq.rb,
+ lib/drb/extserv.rb, lib/drb/extservm.rb, lib/drb/gw.rb,
+ lib/drb/invokemethod.rb, lib/drb/observer.rb,
+ lib/drb/timeridconv.rb, lib/drb/unix.rb: import drb-2.0.4b3
+
+Thu Jun 19 16:14:43 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c (lib_do_one_event): change default
+ value of the argument
+
+ * ext/tcltklib/tcltklib.c (lib_do_one_event): returns true/false
+
+ * ext/tcltklib/tcltklib.c: add TclTkLib::EventFlag::NONE ( == 0 )
+
+ * ext/tcltklib/tcltklib.c: add set_no_event_wait() and
+ get_no_event_wait()
+
+ * ext/tcltklib/MANUAL.euc: modify
+
+ * ext/tcltklib/README.euc: ditto
+
+ * ext/tk/lib/tk.rb: change default value of TkCore.do_one_event
+ argument
+
+ * ext/tk/lib/tk.rb: add TkCore.set_no_event_wait(wait) and
+ TkCore.get_no_event_wait
+
+ * ext/tk/lib/tk.rb: add Tk.exit ( == destroy root widget )
+
+ * ext/tk/lib/tkafter.rb: rename TkAfter => TkTimer (TkAfter is
+ an alias name)
+
+ * ext/tk/lib/tkafter.rb: set_callback returns self
+
+ * ext/tk/lib/tkafter.rb: continue() raises an exception, if already
+ running or no procedure.
+
+ * ext/tk/lib/tkafter.rb: skip() raises an exception, if not running.
+
+ * ext/tk/sample/tktimer2.rb: new sample for TkTimer class.
+
+Thu Jun 19 16:13:54 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * rubytest.rb: add library path to include standard libraries.
+
+Thu Jun 19 13:13:10 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * hash.c (env_delete, rb_f_getenv, env_fetch): case insensitive to
+ access environment variables on DOSISH platforms.
+
+Thu Jun 19 00:51:47 2003 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * range.c (rb_range_beg_len): out_of_range check after adjusting
+ end point. [ruby-dev:20370]
+
+Wed Jun 18 23:59:11 2003 Guy Decoux <ts@moulon.inra.fr>
+
+ * parse.y (call_args): the first argument to arg_cancat() should
+ be NODE_LIST. [ruby-core:01151]
+
+Wed Jun 18 23:41:27 2003 Marc Cartright <marc@isri.unlv.edu>
+
+ * ext/zlib/zlib.c (zstream_run): In a particular situation,
+ deflate/inflate will return Z_BUF_ERROR, even though another call
+ is required by the zlib library.
+
+Wed Jun 18 19:46:21 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb: bug fix
+
+ * ext/tk/lib/tk.rb: rename 'no_create' option to 'without_creating'
+
+ * ext/tk/lib/tk.rb: add TkWindow#pack_in, TkWindow#grid_in,
+ TkWindow#place_in
+
+ * ext/tk/lib/tk.rb: add TkWindow#bind_class and TkWindow#database_class
+
+ * ext/tk/lib/tk.rb: add TkBindTag.new_by_name and TkDatabaseClass
+ for binding to database class
+
+ * ext/tk/lib/tk.rb: check varname whether already exsist or not.
+ (TkVarAccess.new)
+
+ * ext/tk/lib/tk.rb: TkTextWin#bbox returns an array of four numbers
+
+ * ext/tk/lib/tk.rb: autoload TkDialog2, TkWarning2
+
+ * ext/tk/lib/tk.rb: scan event callback arguments and convert
+ to proper type
+
+ * ext/tk/lib/tk.rb: TkBindTag.new accepts a block
+
+ * ext/tk/lib/tk.rb: If given taglist, TkWindow#bindtags(taglist)
+ returns taglist
+
+ * ext/tk/lib/tk.rb: add TkWindow#bindtags=(taglist)
+
+ * ext/tk/lib/tk.rb: Tk.focue and Tk.focus_lastfor return nil
+ if there is no target widget.
+
+ * ext/tk/lib/tk.rb: Tk::Wm.client returns the argument string
+ when setting name
+
+ * ext/tk/lib/tk.rb: TkGrid.columnconfiginfo and rowconfiginfo
+ given a slot return a number.
+
+ * ext/tk/lib/tk.rb: TkWindow.grid_columnconfiginfo and
+ grid_rowconfiginfo --- ditto
+
+ * ext/tk/lib/tk.rb: rename and define alias :: TkOption ==> TkOptionDB
+
+ * ext/tk/lib/tk.rb: define alias :: TkTimer ==> TkAfter
+
+ * ext/tk/lib/tk.rb: some instance methods change from public to private
+
+ * ext/tk/lib/tk.rb: some TkComm methods change to module functions
+
+ * ext/tk/lib/tk.rb: add support for -displayof option to some
+ TkWinfo methods
+
+ * ext/tk/lib/tk.rb: bind, bind_append and bind_remove ---
+ returns the target of event-binding
+
+ * ext/tk/lib/tk.rb: add Tk8.4 features
+
+ * ext/tk/lib/tk.rb: add TkPaneWindow
+
+ * ext/tk/lib/tkdialog.rb: bug fix
+
+ * ext/tk/lib/tkdialog.rb: some methods return self
+
+ * ext/tk/lib/tkdialog.rb: add TkTextMark#+(mod) and TkTextMark#-(mod)
+
+ * ext/tk/lib/tkdialog.rb: add some methods
+
+ * ext/tk/lib/tkcanvas.rb: bug fix and some methods return self
+
+ * ext/tk/lib/tkentry.rb: some methods return self
+
+ * ext/tk/lib/tkentry.rb: TkEntry#bbox returns an array of four numbers
+
+ * ext/tk/lib/tkentry.rb: scan validatecommand arguments and
+ convert to proper type
+
+ * ext/tk/lib/tkbgerror.rb: support to define a error handler by user
+
+ * ext/tcltklib/tcltklib.c: [ruby-talk:60759]
+
+Wed Jun 18 13:50:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should dispatch based on ID type.
+
+Wed Jun 18 12:53:42 2003 Minero Aoki <aamine@loveruby.net>
+
+ * eval.c (rb_yield_0): should restore scope_vmode during yield.
+ [ruby-dev:20361]
+
+Wed Jun 18 01:13:36 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c (rb_syck_load_handler): merge key implemented.
+
+ * ext/syck/rubyext.c (transfer_find_i): removed use of String#=~ in favor
+ of Regexp#match.
+
+ * lib/yaml.rb: YAML::try_implicit returns.
+
+ * lib/yaml/rubytypes.rb: Regexps added for type matching.
+
+ * lib/yaml/emitter.rb: fix String + nil error.
+
+Tue Jun 17 17:01:08 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/gram.c: added grammar for certain empty sequence entries.
+
+ * ext/syck/handler.c, ext/syck/syck.c, ext/syck/syck.h: track bad anchors.
+
+ * ext/syck/token.c: added pause token, tag possible circular references.
+
+ * lib/yaml/rubytypes.rb: parsing YMD time as Date instance.
+
+ * ext/syck/rubyext.c: ditto. DomainType, PrivateType, BadAlias classes.
+
+Tue Jun 17 21:28:27 2003 Ariff Abdullah <skywizard@time.net.my>
+
+ * win32/win32.c (rb_w32_opendir): need to set errno. [ruby-talk:73761]
+
+Mon Jun 16 19:01:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c: remove rb_cBlock.
+
+Mon Jun 16 18:06:33 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * numeric.c (rb_fix2uint): renamed from rb_fix2int on IA64.
+
+Mon Jun 16 17:02:57 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (proc_invoke): format the message for localjump_error().
+
+Mon Jun 16 16:23:56 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/dl/dl.c (rb_dl_callback): use rb_block_proc() instead of
+ rb_block_new().
+
+ * ext/win32ole/win32ole.c (ev_on_event): ditto.
+
+Mon Jun 16 16:06:47 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_alloc): re-unification of Block and Proc. Block
+ class is no longer available.
+
+Mon Jun 16 14:43:14 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * bcc32/Makefile.sub: undefine HAVE_GETGROUPS.
+
+Sat Jun 14 16:58:41 2003 Guy Decoux <ts@moulon.inra.fr>
+
+ * regex.c (calculate_must_string): should handle option_set
+ properly. [ruby-talk:73481]
+
+ * regex.c (re_compile_fastmap): a bug in flag manipulation.
+ [ruby-talk:73549]
+
+Sat Jun 14 17:59:59 2003 Guy Decoux <ts@moulon.inra.fr>
+
+ * eval.c (method_arity): should handle NODE_BMETHOD and
+ NODE_DMETHOD. [ruby-core:01138]
+
+Fri Jun 13 09:24:39 2003 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/ftp.rb (storebinary): seek correctly. Thanks, William Webber.
+
+ * lib/net/ftp.rb (putbinaryfile): rescue FTPPermError.
+
+Thu Jun 12 22:13:13 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb : add 'no_create' option to widget
+ initialize method.
+
+ * ext/tk/MANIFEST : forgot to commit when added tkmacpkg.rb
+ and tkwinpkg.rb
+
+ * ext/tk/lib/README : ditto.
+
+Thu Jun 12 21:14:11 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tk.rb : widget configure returns self (for method
+ call chain)
+
+ * ext/tk/lib/tkmacpkg.rb : Mac resource (not new but not
+ included until now)
+
+ * ext/tk/lib/tkwinpkg.rb : Win DDE and registry (not new but not
+ included until now)
+
+Tue Jun 10 14:26:30 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/token.c: preserve newlines prepended to a block.
+
+ * ext/syck/implicit.c (syck_match_implicit): added !merge and !default.
+
+ * lib/yaml/constants.rb: remove '\z' escape.
+
+ * lib/yaml/emitter.rb: ensure reset of @seq_map shortcut flag.
+
+ * lib/yaml/encoding.rb: remove Unicode translation methods.
+
+ * lib/yaml/rubytypes.rb: improved round-tripping of Strings.
+ [ruby-core:1134]
+
+Tue Jun 10 01:07:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/irb.rb (IRB::Irb::eval_input): warn and exit if $SAFE >=3
+ after input evaluation.
+
+ * lib/irb.rb (IRB::Irb::eval_input): untaint input string. now
+ irb works for levels 1 and 2.
+
+Mon Jun 9 19:02:33 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in: checks presence of grp.h and setgroups().
+
+ * process.c (proc_getgroups, proc_setgroups): raise
+ NotImplementedError unless available. [ruby-talk:73014]
+
+Mon Jun 9 18:09:11 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: fixed 100% CPU problem of Tk.mainloop
+
+Mon Jun 9 15:50:24 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: renewal Tk.mainloop
+
+Sun Jun 8 13:37:21 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/setup.mak: set SUBSYSTEM in each platform.
+
+ * wince/stdlib.c: fix mblen() bug.
+
+Sat Jun 7 22:22:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/syck/rubyext.c (syck_loader_transfer): should not use
+ rb_cProc directly, since type_proc may be Proc, Block, or
+ Method.
+
+ * parse.y (value_expr0): class and module statements should not be
+ warned for "void value expression". [ruby-talk:72989]
+
+Sat Jun 7 01:46:41 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (add_final): should determine type by respond_to?
+
+ * gc.c (define_final): ditto.
+
+ * io.c (rb_io_ctl): should not depend on respond_to?
+
+ * range.c (range_step): rb_check_string_type().
+
+Fri Jun 6 20:29:14 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (error_print): needs to be exception proof.
+
+ * eval.c (error_handle, rb_longjmp): bails out when exception
+ reentered. (ruby-bugs-ja:PR#487), [ruby-core:01119],
+ [ruby-core:01122]
+
+ * eval.c (Init_Proc): pre-allocates critical error objects.
+
+Fri Jun 6 20:29:14 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (cmd_brace_block, do_block, brace_block): initialize block
+ variables at the beginning of the block. [ruby-talk:72521]
+
+Fri Jun 6 18:49:11 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (proc_setgroups): new functions.
+
+Fri Jun 6 18:33:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (define_final): eliminate rb_f_lambda() call.
+
+ * class.c (rb_scan_args): ditto.
+
+ * signal.c (sig_trap): ditto.
+
+ * hash.c (rb_hash_initialize): ditto.
+
+ * variable.c (rb_f_trace_var): ditto.
+
+ * ext/dl/dl.c (rb_dl_callback): ditto.
+
+ * ext/win32ole/win32ole.c (ev_on_event): ditto.
+
+Fri Jun 6 16:10:01 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: define Net::HTTPResponse#to_ary for backward
+ compatibility. [ruby-talk:72927]
+
+ * lib/net/protocol.rb: add warning.
+
+Fri Jun 6 13:30:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_cleanup): $SAFE is turned off in the finalization.
+ Each END proc should preserve its own $SAFE level. [ruby-core:01119]
+
+ * marshal.c (marshal_load): remove unused variable "hash".
+ [ruby-core:01120]
+
+ * hash.c (env_str_new): freeze strings from ENV. [ruby-talk:72860]
+
+ * array.c (rb_ary_first): optional argument to retrieve first n
+ elements.
+
+ * array.c (rb_ary_last): optional argument to retrieve last n
+ elements.
+
+Thu Jun 5 21:31:55 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/stdlib.c: add mblen().
+
+Thu Jun 5 18:33:46 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/curses/curses.c (window_s_allocate,curses_finalize):
+ avoid VC++ warnings.
+
+Thu Jun 5 17:44:11 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c (syck_parser_mark): was a bit heavy on the GC.
+
+ * lib/yaml.rb (YAML::transfer): added.
+
+Thu Jun 5 16:11:50 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * bcc32/Makefile.sub, win32/Makefile.sub, wince/Makefile.sub
+ (MISSING): link with missing/erf.c.
+
+ * missing.h (erf, erfc): fix prototype.
+
+ * missing/erf.c: new. [ruby-list:37753]
+
+Thu Jun 5 15:09:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * math.c (math_erf,math_erfc): new function. [ruby-list:37753]
+
+Thu Jun 5 14:49:43 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c: using GC nodes caused segfault. [ruby-core:1071]
+
+Thu Jun 5 13:48:57 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/token.c: directives choked on a period.
+
+ * ext/syck/gram.y: anchors work above a collection. [ruby-core:1071]
+
+ * ext/syck/handler.c, ext/syck/syck.c: ensure a fresh strtable between
+ parser iterations.
+
+Wed Jun 4 12:06:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_finalize): no longer need to turn off $DEBUG in the
+ finalizer. (ruby-bugs-ja PR#473)
+
+Tue Jun 3 22:20:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call_super): should search superclass method based on
+ orig_func, not last_func.
+
+Tue Jun 3 09:59:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call_super): inheritance line adjustment moved from
+ rb_call(). [ruby-core:01113]
+
+ * eval.c (rb_eval): use rb_call_super() to follow DRY principle.
+
+Mon Jun 2 02:20:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (push_values_at): Array#values_at should work with
+ ranges too.
+
+ * range.c (rb_range_beg_len): length calculation was wrong.
+
+ * eval.c (rb_call): should set T_ICLASS in the frame->last_class.
+ [ruby-core:01110]
+
+Sun Jun 1 21:50:01 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: should not use def file, use ld with
+ --export-all-symbols option on Cygwin/MinGW.
+
+ * defines.h: ditto.
+
+ * cygwin/GNUmakefile.in: ditto.
+
+ * ext/digest/defs.h: avoid warnings on Cygwin.
+
+Sun Jun 01 13:33:49 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/string_wce.c: add strpbrk() for hpcpro support.
+
+ * wince/setup.mak: add hpcpro(CE2.11) & armv4t(CE.NET) support.
+
+ * wince/resource.rb: ditto.
+
+ * wince/Makefile.sub: ditto.
+
+Sun Jun 1 10:38:28 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * variable.c (rb_autoload_load): autoloaded constants under a module
+ belong to the module. [ruby-core:01094], [ruby-dev:20309]
+
+Sat May 31 04:36:54 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (rb_intern): should handle multibyte name.
+
+Fri May 30 23:18:01 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c (rb_syck_mktime): seconds calculated wrong.
+
+ * ext/syck/gram.c: flexibility to anchors and transfer methods on
+ collections.
+
+ * ext/syck/token.c: hex escapes.
+
+ * lib/yaml/basenode.rb: YamlNode references changed to YAML::BaseNode.
+
+Fri May 30 22:28:04 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * numeric.c (rb_num2uint, rb_fix2int): new function to convert
+ values over INT_MAX. [ruby-core:01099]
+
+ * ruby.h (NUM2UINT, FIX2INT): ditto.
+
+Fri May 30 15:01:05 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/token.c: preserve any indentation past an explicit
+ indentation.
+
+Fri May 30 14:55:44 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_Array): exclude Kernel#to_a instead of Object#to_a.
+ (ruby-bugs-ja:PR#483)
+
+ * lib/optparse.rb (OptionParser::Switch#parse_arg): not splat.
+
+ * lib/optparse.rb (OptionParser::Switch#conv_arg): splat if no
+ conversion supplied.
+
+ * lib/optparse.rb (OptionParser::Switch::PlacedArgument#parse):
+ override next switch after argument conversion.
+
+Fri May 30 14:41:34 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/handler.c, ext/syck/syck.h: removed syck_fold_format().
+
+ * ext/syck/gram.c: flexibility for aliases and anchors.
+
+ * ext/syck/token.c: folding now handled in the tokenizer.
+
+Fri May 30 06:21:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * variable.c (rb_autoload_load): should delete autoloaded
+ symbol itself before load. [ruby-core:01097]
+
+ * variable.c (rb_mod_remove_const): must not return Qundef.
+
+Thu May 29 14:59:10 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c (_CRTIMP): redefine _CRTIMP on MinGW.
+
+ * configure.in: remove '-D__USE_CRTIMP' from XCFLAGS on MinGW.
+
+ * win32/win32.c (NtMakeCmdVector): handle quotes only if not instring.
+
+Thu May 29 09:11:01 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (ev_const_defined, ev_const_get), variable.c
+ (rb_const_get_at, rb_const_get, rb_mod_remove_const): use Qundef
+ as autoload marker. [ruby-dev:18103], [ruby-dev:18184]
+
+ * eval.c (rb_mod_autoload, rb_mod_autoload_p): new method;
+ Module#autoload, Module#autoload?.
+
+ * variable.c (rb_autoload, rb_autoload_load, rb_autoload_p):
+ manage autoload constants per classes/modules.
+
+ * variable.c (rb_const_defined_at, rb_const_defined): return false
+ for autoloading constants.
+
+ * class.c (rb_define_class, rb_define_module), eval.c (rb_eval),
+ variable.c (rb_mod_const_at, rb_const_assign): removed autoload
+ stuff.
+
+ * intern.h: prototypes; rb_autoload, rb_autoload_load,
+ rb_autoload_p.
+
+ * lib/optparse.rb (OptionParser::Switch::PlacedArgument::parse):
+ do not treat unmatched argument as an option.
+
+Wed May 28 08:44:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_f_syscall): type dispatch should be based on
+ rb_check_string_type(), not FIXNUM_P(), because values may be a
+ bignum. [ruby-talk:72257]
+
+Tue May 27 20:33:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c, util.c: removed duplicated includes/defines.
+
+ * ext/socket/socket.c (sock_addrinfo): get rid of SEGV at NULL ptr
+ String. increase buffer size for 64bit platforms.
+
+Tue May 27 02:34:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call0): should pass the current klass value to
+ block_invoke, which may be called via "super". [ruby-core:01077]
+
+ * eval.c (block_invoke): now takes 4th argument "klass".
+
+ * eval.c (block_alloc): should propagate BLOCK_PROC to
+ ruby_block.
+
+Mon May 26 23:51:38 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (r_object0): should not use "yield" method, use "call"
+ instead. (ruby-bugs-ja PR#476)
+
+Mon May 26 21:39:46 2003 MoonWolf <moonwolf@moonwolf.com>
+
+ * lib/mkmf.rb, lib/optparse.rb, lib/tracer.rb: use Method#to_block
+ instead of deprecated Method#to_proc. (ruby-bugs-ja:PR#477)
+
+Mon May 26 21:21:20 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb (OptionParser::Switch::parse,
+ OptionParser::order): use {Block,Proc}#call instead of deprecated
+ #yield.
+
+Mon May 26 16:39:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (Init_Proc): Block/Proc separation. [huge change]
+
+ * eval.c (block_arity): returns exact arity number for Procs out
+ of methods. also gives 1 for {|a|..}.
+
+ * string.c (rb_str_match): revert use of String#index for
+ invocation like string =~ string.
+
+ * eval.c (rb_Array): move Object#to_a exclusion hack from
+ splat_value(). need to be in eval.c for a while.
+
+Sun May 25 23:48:21 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bignum.c (rb_quad_pack): should negate negative bignum.
+ (ruby-bugs-ja:PR#474)
+
+Sun May 25 03:27:25 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: support LOGIN authentication, based on
+ the patch by Kazuhiko Izawa. [ruby-talk:78981]
+
+Sat May 24 18:19:51 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/Makefile.sub: add eMbedded Visual C++ 4.0 support.
+
+ * wince/resource.rb: ditto.
+
+ * wince/setup.mak: ditto.
+
+ * wince/configure.bat: ditto.
+
+ * wince/mkexports.rb: delete japanese comments.
+
+Fri May 23 18:34:05 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_longjmp): get rid of reentering while debug warning.
+ (ruby-bugs-ja:PR473)
+
+Fri May 23 15:16:16 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * pack.c (pack_unpack): sign-extend if sizeof long is bigger than
+ 32. (ruby-bugs-ja:PR#472)
+
+Fri May 23 14:19:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_finalize): turn off ruby_debug flag before calling
+ at_exit procs and finalizers. (ruby-bugs-ja:PR473)
+
+ * ext/tcltklib/tcltklib.c (lib_mainloop_core): OK to block if
+ there's no other thread. (ruby-bugs:PR#861)
+
+Thu May 22 18:07:46 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/token.c: single- and double-quoted root-level fix.
+
+ * lib/yaml.rb (YAML::object_maker): can create object attributes (such as
+ found in Exception class)
+
+ * lib/yaml/rubytypes.rb: roundtripping of Exception and subclasses.
+
+Fri May 23 01:26:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_clone): defer copying freezing state after
+ calling initialize_copy(). [ruby-dev:20276]
+
+Thu May 22 17:12:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (run_final): use rb_thread_critical instead of DEFER_INTS.
+ [ruby-dev:20272]
+
+ * marshal.c: try to make ArgumentError and TypeError consistent.
+ [ruby-core:01068]
+
+Thu May 22 15:46:37 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_define_alloc_func): need not to disable
+ rb_call_super() for allocation functions. [ruby-core:1065]
+
+Thu May 22 06:21:33 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c (rb_syck_err_handler): raise ArgumentError on
+ malformed YAML.
+
+ * lib/yaml/rubytypes.rb: String#to_yaml was missing space indicators at
+ the end of a line.
+
+Thu May 22 05:43:24 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c (syck_parser_load): root-level false was returning
+ nil.
+
+ * ext/syck/token.c: root-level transfer method bug.
+
+ * ext/syck/gram.c: root-level empty gave a parse error.
+
+ * lib/yaml/rubytypes.rb: Symbol#to_yaml generating method call error.
+
+Thu May 22 02:46:38 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): splat NODE_RESTARY. [ruby-dev:20268]
+
+ * eval.c (rb_thread_fd_close): raise for writing threads.
+ [ruby-dev:20269]
+
+ * io.c (rb_io_close, io_reopen): ditto.
+
+ * io.c (io_reopen): keep stdio objects for stdin, stdout,
+ and stderr. [ruby-dev:19442]
+
+Thu May 22 01:11:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (strings, word_list): must create new instance always.
+ http://yowaken.dip.jp/tdiary/20030521.html#p02
+
+ * parse.y (yylex): slight optimization.
+
+Wed May 21 23:07:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (rb_sys_fail): should not specify errno explicitly.
+ [ruby-dev:20264]
+
+Wed May 21 20:51:47 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub,
+ wince/Makefile.sub: update dependencies.
+
+Wed May 21 17:44:16 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (syserr_initialize): prohibit specifying errno for
+ subclasses of SystemCallError. in addition, if initialize is
+ called for SystenCallError instance, its class be changed.
+ [ruby-dev:20257]
+
+ * gc.c (run_final): to protect thread context switch, finalizers
+ are wrapped in DEFER_INTS/ENABLE_INTS.
+
+Wed May 21 13:26:08 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb: get rid of warnings.
+
+Tue May 20 18:59:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_save_context): prohibit rb_gc_force_recycle()
+ on thread saved ruby_dyna_vars. [ruby-dev:20236]
+
+Tue May 20 17:39:15 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (init_copy): call initialize_copy at the end of copy
+ process.
+
+Tue May 20 17:15:55 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * error.c (syserr_initialize): use Errno constants as default
+ errno for subclasses. [ruby-dev:20241]
+
+Tue May 20 15:26:25 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * st.h: define ST_DATA_T_DEFINED for portability.
+
+ * ext/syck/syck.h: add typedef, st_data_t for Ruby 1.6.
+
+ * ext/syck/syck.c (syck_st_free_nodes): return int.
+
+ * ext/syck/syck.c (syck_add_sym): cast the data to st_data_t
+ to avoid error on bcc32.
+
+ * ext/syck/syck.c (syck_lookup_sym): ditto.
+
+ * ext/syck/syck.c (syck_free_parser): NULL is not integer.
+
+Tue May 20 13:29:04 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (kill): set errno after calling raise().
+
+Tue May 20 10:51:26 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_f_missing): create exception instance by ordinal
+ method. [ruby-dev:20033]
+
+ * error.c (rb_name_error, rb_sys_fail): ditto.
+
+ * error.c (exc_to_s, exit_status, name_err_name,
+ nometh_err_args, syserr_errno, syserr_eqq): access
+ attributes.
+
+ * error.c (name_err_initialize, nometh_err_initialize,
+ syserr_initialize): initialize attributes.
+
+Tue May 20 10:26:56 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): give warning for multiple values for a
+ block parameter.
+
+ * eval.c (rb_yield_values): a function to yield multiple values.
+
+ * array.c (sort_1): use rb_yield_values.
+
+ * enum.c (min_ii, max_ii): ditto.
+
+ * hash.c (rb_hash_update_block_i, delete_if_i, select_i,
+ each_pair_i, env_each, env_reject_bang, env_select,
+ env_update_i): ditto.
+
+ * struct.c (rb_struct_each_pair): ditto.
+
+ * eval.c (top_include): should include module in the current self,
+ not ruby_top_self. [ruby-dev:20198]
+
+ * eval.c (top_include): stop inclusion to ruby_wrapper; give
+ warning.
+
+Mon May 19 18:54:30 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/token.c, ext/syck/implicit.c: expanded character set to
+ allow UTF-8, other Ruby encodings.
+
+Mon May 19 16:47:00 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/syck.c, ext/syck/syck.h, ext/syck/token.c, ext/syck/gram.c:
+ count line numbers only if line pointer has increased.
+
+Tue May 20 00:45:40 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (push_braces): do not push_braces() unless rbrace is found.
+ (ruby-bugs-ja:PR#469)
+
+Tue May 20 00:09:41 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/pty/pty.c (pty_finalize_syswait): join (using Thread#value)
+ before detach pid. [ruby-talk:71519]
+
+Mon May 19 23:02:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (PUSH_FRAME): save outer ruby_block. [ruby-list:37677],
+ [ruby-dev:20202]
+
+ * eval.c (BEGIN_CALLARGS): restore outer block by using
+ ruby_block->outer.
+
+ * eval.c (block_pass): do not alter block->prev, but block->outer.
+
+ * array.c (get_inspect_tbl): warning on wrong condition.
+
+Mon May 19 16:13:57 2003 Minero Aoki <aamine@loveruby.net>
+
+ * class.c: add #include "version.h".
+
+ * hash.c: ditto.
+
+ * string.c: ditto.
+
+Mon May 19 15:33:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (localjump_xvalue): renamed exitstatus to exit_value
+ since it's not exit "status" after all.
+
+ * eval.c (localjump_error): add reason to LocalJumpError.
+
+ * compar.c (rb_cmpint): raise error via rb_cmperr(), if cmp value
+ is nil. now take new 2 arguments.
+
+ * time.c (time_cmp): 2003-05-16 fix was incomplete.
+ (ruby-bugs-ja:PR#458)
+
+Mon May 19 14:42:50 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_mod_cmp): stupid comparison fixed.
+
+ * io.c (Init_IO): ARGF.path added (alias to ARGF.filename).
+ [ruby-dev:20197]
+
+Mon May 19 13:58:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (init_copy): rename copy_object as initialize_copy,
+ since it works as copy constructor.
+
+ * eval.c (rb_add_method): initialize_copy should always be
+ private, like initialize.
+
+Mon May 19 13:51:50 2003 Minero Aoki <aamine@loveruby.net>
+
+ * re.c (rb_reg_quote): \n \r \f \v quoting was wrong.
+ [ruby-dev:20203]
+
+ * re.c (rb_reg_quote): rb_reg_quote(" ") should be "\\ ", not
+ "\\s".
+
+Mon May 19 08:08:51 2003 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb: use warn() instead of $stderr.puts().
+
+ * sample/cal.rb: ditto.
+
+Sat May 17 12:02:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (get_inspect_tbl): check whether inspect_tbl value is a
+ valid array. (ruby-bugs-ja PR#65)
+
+ * array.c (inspect_ensure,rb_protect_inspect,rb_inspecting_p):
+ use get_inspect_tbl().
+
+Sat May 17 11:50:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_abort): call exit(1) if exception is raised. This
+ patch was made by Nobuyoshi Nakada <nobu.nokada@softhome.net> on
+ 2002-05-30. (ruby-bugs-ja PR#236)
+
+ * signal.c: disable Ruby's interrupt handler at the beginning.
+ (ruby-bugs-ja PR#236)
+
+Sat May 17 02:17:42 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/rational.rb (Integer::denominator): fixed typo.
+ (ruby-bugs-ja:PR#466)
+
+Sat May 17 00:18:11 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/socket/socket.c (ruby_connect): connect() after EINPROGRESS
+ returns EINVAL on some platforms, need to check true error
+ status. [ruby-core:01037]
+
+Sat May 17 00:21:51 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_class_allocate_instance): singleton class check
+ moved to rb_obj_alloc(). (ruby-bugs-ja PR#345)
+
+Fri May 16 23:55:50 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_quote): should escape white space characters,
+ \t, \f, \n, \r. (ruby-bugs-ja PR#231)
+
+Fri May 16 12:40:40 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (block_pass): chain previous block to the pushing block.
+ [ruby-list:37677]
+
+ * time.c (time_cmp): does not compare with numbers for
+ interchangeability. (ruby-bugs-ja:PR#458)
+
+Thu May 15 21:55:54 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/gram.c: fixes to one-line documents and end of stream
+ documents.
+
+ * ext/syck/syck.c, ext/syck/syck.h: add root_on_error to parser
+ struct, specifying the symbol to be returned on a parse error.
+
+Thu May 15 18:44:31 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/open-uri.rb (OpenURI::Redirect#initialize): call super to
+ initialize mesg.
+
+ * lib/open-uri.rb (OpenURI::Meta#charset): call block to guess charset
+ if block is given and charset is not given.
+
+Thu May 15 16:55:16 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_mod_le): returns nil if two classes/modules are not
+ in class-superclass relationship.
+
+ * object.c (rb_mod_cmp): uses new rb_mod_le() behavior.
+
+Thu May 15 07:45:30 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/rubyext.c, ext/syck/implicit.c: timestamp repairs to
+ timezone and milliseconds.
+
+ * ext/syck/syck.c (syck_parser_reset_levels): duplicate string literal
+ to avoid warning.
+
+Thu May 15 13:26:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_class_instance_methods): default will be changed in
+ 1.8.1.
+
+ * io.c (set_stdio): better message.
+
+Thu May 15 13:18:11 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (set_stdio): $stdin, $stdout, $stderr now became read-only.
+
+ * variable.c (readonly_setter): message changed.
+
+Thu May 15 09:50:51 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/syck/syck.c (syck_parser_pop_level): add prototype.
+
+ * ext/syck/syck.c (syck_strndup): should return value.
+
+Thu May 15 09:32:25 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (kill): fix typo and add signal 0 support.
+
+Wed May 14 20:09:26 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/gram.c: sequence-in-map shortcut, transfer methods on
+ sequence-in-sequence, memory leak in mapping merge.
+
+ * ext/syck/syck.c: memory leak in domain anchoring.
+
+ * lib/yaml/rubytypes.rb, lib/yaml/types.rb: eliminated 1.6.x code.
+
+Wed May 14 19:56:43 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/syck/rubyext.c: add prototypes to avoid VC++ warnings.
+
+Wed May 14 12:23:46 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb (Net::HTTP#start): should check whether HTTP
+ session is opened before finishing. (ruby-bugs-ja:PR#463)
+
+Wed May 14 09:12:55 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: reduce warning. (ruby-bugs-ja:PR#462)
+
+Tue May 13 22:31:04 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * lib/yaml/rubytypes.rb, lib/yaml/types.rb: using Object#object_id
+ rather than deprecated Object#id.
+
+ * ext/syck/token.c: changed ASCII escapes to octal notation.
+
+ * ext/Setup*: added entries for static linking of Syck extension.
+
+Tue May 13 20:31:58 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: add '--Wl,--enable-auto-import' to DLDFLAGS
+ on Cygwin/MinGW.
+
+ * configure.in: add '-D__USE_CRTIMP' to XCFLAGS on MinGW.
+
+ * ext/syck/handler.c: add proper casts.
+
+ * ext/syck/syck.c: ditto.
+
+Tue May 13 17:58:08 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * configure.in, bcc32/Makefile.sub, win32/Makefile.sub: define
+ HAVE_FSYNC.
+
+ * win32/win32.h (fsync): define as _commit().
+
+Tue May 13 15:35:35 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_match_exec): \Z changed to be consistent with new $
+ (endbuf) behavior.
+
+Tue May 13 14:48:07 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (error_pos): use $deferr for output instead of stderr
+ directly.
+
+ * eval.c (error_print,error_handle,rb_longjmp,rb_thread_schedule):
+ ditto.
+
+Tue May 13 06:34:19 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * lib/yaml/rubytypes.rb: object and struct loading
+
+ * lib/yaml.rb: YAML::detect_implicit will discover typing for a Ruby
+ string
+
+ * ext/syck/: Fixed portable comments, misuse of NULL and methods without
+ return VALUEs.
+
+Mon May 12 18:08:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (Init_IO): new variable $deferr which is default output
+ port of error messages.
+
+ * io.c (rb_warn_m): new method "warn". [new]
+
+ * error.c (warn_print): use $deferr.
+
+ * error.c (rb_bug): ditto.
+
+ * error.c (err_append): ditto.
+
+Sun May 11 13:50:12 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb: refine to_s test.
+
+ * lib/pp.rb (PP::ObjectMixin#pretty_print): refine to_s handling.
+
+Sun May 11 06:32:13 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/implicit.c, ext/syck/rubyext.c: transfer methods applied to
+ native loading
+
+ * ext/syck/token.c: fix for transfer methods on same indentation as nested
+ mapping
+
+ * lib/yaml/rubytypes.rb: all type names in lowercase
+
+Sat May 10 19:55:18 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ext/syck/gram.c ext/syck/handler.c ext/syck/implicit.c
+ ext/syck/node.c ext/syck/rubyext.c ext/syck/syck.c
+ ext/syck/syck.h ext/syck/token.c: updated to Syck 0.27
+
+ * lib/yaml/loader.rb: new YAML::Loader class
+
+ * lib/yaml.rb: loading of type families leverages YAML::DefaultLoader
+
+Sat May 10 19:00:08 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/string.c: file removed.
+
+ * wince/stdlib.c: file added.
+
+Sat May 10 16:17:02 2003 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb (decode_utf7): new method.
+
+ * lib/net/imap.rb (encode_utf7): new method.
+
+Fri May 9 21:25:50 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>
+
+ * ruby/ext/syck, ruby/lib/yaml: Initial checkin of YAML substances.
+
+Fri May 9 16:38:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_reopen): It should be possible to reopen closed IO.
+ [ruby-talk:70941]
+
+ * io.c (rb_io_reopen): inherit original file mode unless specified.
+
+Thu May 8 18:44:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc): check odd alignment stack on m68k machines.
+
+Thu May 8 12:56:04 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * compar.c (rb_cmperr): raise comparison failure.
+
+ * intern.h: prototype; rb_cmperr
+
+ * numeric.c (flo_gt, flo_ge, flo_lt, flo_le, fix_gt, fix_ge,
+ fix_lt, fix_le): should fail unless the argument is comparable.
+ (ruby-bugs-ja:PR#456)
+
+ * numeric.c (int_upto, int_downto): should fail unless the
+ argument is comparable. (ruby-bugs-ja:PR#454)
+
+Wed May 7 13:30:11 2003 Masahiro TANAKA <masa@ir.isas.ac.jp>
+
+ * numeric.c (num_step): better error treatment of float values.
+
+Tue May 6 17:51:54 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/pop.rb: rename method: POP3#mail_size -> n_mails
+
+ * lib/net/pop.rb: rename method: POP3#bytes -> n_bytes
+
+Tue May 6 17:21:01 2003 Minero Aoki <aamine@loveruby.net>
+
+ * ext/bigdecimal/.cvsignore: new file.
+
+ * ext/zlib/.cvsignore: new file.
+
+Tue May 6 14:39:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_methods): list singleton methods if recur
+ argument is false; list all methods otherwise.
+
+Mon May 5 21:19:25 2003 Koji Arai <jca02266@nifty.ne.jp>
+
+ * ext/gdbm/gdbm.c (fgdbm_values_at): new method to replace
+ select(index..).
+
+ * ext/sdbm/init.c (fsdbm_values_at): ditto.
+
+ * ext/dbm/dbm.c (fdbm_values_at): ditto.
+
+ * ext/dbm/dbm.c (DBM::VERSION): defined.
+
+ * ext/gdbm/testgdbm.rb: replace select with values_at.
+
+ * ext/sdbm/testsdbm.rb: ditto.
+
+ * ext/dbm/testdbm.rb: ditto.
+
+ * ext/dbm/testdbm.rb (setup): DBM.open(path, 0400) cause EACCESS
+ on Berkeley DB[234].
+
+Mon May 5 22:57:07 2003 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * sample/cal.rb: use values_at instead of select.
+
+ * sample/biorhythm.rb: ditto.
+
+Mon May 5 18:59:45 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * sample/test.rb: substitute 'select' with 'values_at'.
+
+ * lib/date.rb: ditto.
+
+ * lib/parsedate.rb: ditto.
+
+Mon May 5 00:46:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_values_at): new method to replace select(index..).
+
+ * hash.c (rb_hash_values_at,env_values_at): ditto.
+
+ * re.c (match_values_at): ditto.
+
+ * struct.c (rb_struct_values_at): ditto.
+
+ * re.c (match_select): add iterator behavior.
+
+Sun May 4 19:08:53 2003 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date/format.rb: synchronized with date2 3.3.2.
+
+Sun May 4 15:21:18 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: ESMTP -> SMTP transition wrongly fails.
+
+Sun May 4 15:06:37 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/pop.rb: APOP did not work. [ruby-dev:20149]
+
+Sat May 3 21:14:29 2003 Johan Holmberg <holmberg@iar.se>
+
+ * ext/curses/curses.c, ext/digest/sha2/sha2.c, ext/iconv/iconv.c,
+ ext/racc/cparse/cparse.c: include "ruby.h" at the top to shut up
+ "_FILE_OFFSET_BITS redefined" warning on Solaris.
+
+Sat May 3 11:00:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_class_protected_instance_methods): now gives
+ warnings to show migration path. The default will be reversed
+ on Jan 2004.
+
+Sat May 3 00:58:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_methods): now accepts recurse parameter.
+
+ * lib/delegate.rb (Delegator::initialize): instance_methods
+ etc. now recurse by default. need to specify false.
+
+Sat May 3 00:22:00 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: reintroduce Protocol.protocol_param.
+
+ * lib/net/http.rb: ditto.
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/smtp.rb: ditto.
+
+Fri May 2 23:29:53 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: remove Protocol class.
+
+ * lib/net/smtp.rb (SMTP): ditto.
+
+ * lib/net/pop.rb (POP3): ditto.
+
+ * lib/net/http.rb (HTTP): ditto.
+
+ * lib/net/protocol.rb: remove Command class.
+
+ * lib/net/smtp.rb (SMTPCommand): ditto.
+
+ * lib/net/pop.rb (POP3Command): ditto.
+
+ * lib/net/pop.rb: remove APOPCommand class.
+
+ * lib/net/protocol.rb: remove Code class and its all subclasses.
+
+ * lib/net/protocol.rb: remove Response class and its all
+ subclasses.
+
+ * lib/net/pop.rb (POPMail): new method unique_id (alias uidl).
+
+Fri May 2 18:17:37 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * compar.c (cmp_gt): raises ArgumentError when "<=>" give nil.
+ inspired by discussion on comp.lang.python.
+
+Fri May 2 17:37:01 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi/session.rb (CGI::Session::initialize): updated to
+ support 2003-04-23 change in cgi.rb [ruby-core:1002]
+
+Fri May 2 17:21:02 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (method_list): classify methods based on nearest
+ visibility. [ruby-dev:20127]
+
+ * class.c (rb_class_instance_methods): recurse by default. other
+ method listing methods as well.
+
+Fri May 2 09:38:06 2003 Warren Brown <wkb@airmail.net>
+
+ * string.c (rb_str_ljust): now takes optional argument to specify
+ pad string. [ruby-talk:70482]
+
+ * string.c (rb_str_rjust): ditto.
+
+ * string.c (rb_str_center): ditto.
+
+ * string.c (rb_str_justify): utility function.
+
+Fri May 2 04:10:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_add_method): call singleton_method_added or
+ method_added for every method definition (after ruby_running).
+ [ruby-talk:70471]
+
+ * array.c (rb_ary_reverse_bang): Array#reverse! should not return
+ nil even for arrays sized less than 2.
+
+Thu May 1 23:18:01 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_eof): should not block after reading all argument
+ files. (ruby-bugs-ja PR#449)
+
+Fri May 2 15:10:41 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: use hashes to pass options.
+
+ * lib/fileutils.rb: new option mkdir(:mode), mkdir_p(:mode).
+
+ * instruby.rb: follow fileutils.rb feature change.
+
+Thu May 1 08:24:00 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_match_exec): $ _always_ matches at the end of string.
+
+Wed Apr 30 14:12:00 2003 wanowa.kimura@nifty.ne.jp (kimura wataru)
+
+ * net/imap.rb: support THREAD extension.
+
+Sun Apr 27 23:13:20 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * string.c (rb_str_to_i): disallow negative radix.
+ [ruby-dev:20087]
+
+Sat Apr 26 23:34:42 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (open_args): warning message changed to "don't put space
+ before argument parentheses".
+
+Sat Apr 26 14:25:00 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * wince/ : files removed.
+ (config, dll.mak, exe.mak, mswince-ruby17.def,
+ io.c, process.c, signal.c, string.c, time.c)
+
+ * wince/ : files added.
+ (assert.c, Makefile.sub, mkexports.rb, io_wce.c,
+ process_wce.c, signal_wce.c, string_wce.c,
+ time_wce.c)
+
+ * wince/configure.bat : like mswin32 style.
+
+ * wince/direct.c : remove "static" at _currentdir.
+
+ * wince/io.h : change definition.
+
+ * wince/stdio.c : _fdopen -> fdopen.
+
+ * wince/process.h : add _P_OVERLAY.
+
+ * wince/time.h : change definition.
+
+ * wince/wincemain.c : add wce_SetCurrentDir.
+
+ * wince/wince.c : add wce_SetCurrentDir and wce_fopen.
+ fix GetModuleFileNameA to return correct "lpFileName".
+
+ * wince/wince.h : remove #ifdef.
+
+ * wince/sys/utime.h, utime.c : rename _utime to utime.
+
+ * wince/sys/stat.c : expand relative directory in stat.
+
+Sat Apr 26 06:33:04 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_read): ARGF.read() should read all argument files.
+
+Fri Apr 25 18:46:00 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * gc.c: STACK_LEVEL_MAX=65535 on mswince.
+
+Fri Apr 25 18:40:07 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_read): read should not span two files. [ruby-dev:20073]
+
+Fri Apr 25 18:19:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (splat_value): split splat_value() and avalue_splat().
+
+ * io.c: there's no way to set non-IO value to current_file, thus
+ no need for argf_forward().
+
+Fri Apr 25 02:03:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_invoke): Proc#yield should pass through retry and
+ break like keyword yield. [ruby-talk:70034]
+
+ * eval.c (proc_invoke): orphan Proc now raises LocalJumpError for
+ break and retry again.
+
+ * eval.c (rb_eval): ARGSCAT should splat the argument.
+
+ * eval.c (splat_value): splat operation function.
+
+Thu Apr 24 23:37:02 2003 Dave Thomas <dave@thomases.com>
+
+ * lib/matrix.rb (Matrix#minor): Used Range#size, which no longer
+ exists.
+
+ * lib/complex.rb (new!): Complex.new had been made private, but
+ Kernel#Complex called it. Re-exposed as new!.
+
+ * lib/matrix.rb (Matrix.row_vector): Fix method name typo
+
+Thu Apr 24 19:40:02 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb: add -Wl,--no-undefined to LDSHARED only
+ if GNU ld is 2.11 or later.
+
+Wed Apr 23 14:05:40 2003 Dave Thomas <dave@pragprog.com>
+
+ * lib/ipaddr.rb (include?): Support non-IPAddr parameters.
+ [ruby-core:00980]
+
+Wed Apr 23 13:31:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/cgi.rb (CGI::QueryExtension::[]): always return Value
+ object.
+
+Wed Apr 23 08:39:27 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/zlib/extconf.rb: bccwin32 is win32 too.
+
+Tue Apr 22 20:58:00 2003 Takaaki Uematsu <uema2x@jcom.home.ne.jp>
+
+ * ruby.c: don't call VirtualQuery in ruby_init_loadpath()
+ on mswince.
+
+Tue Apr 22 19:08:53 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c (save_mantissa, load_mantissa): for interoperability
+ should count cut-down bit from topmost.
+
+Tue Apr 22 09:20:40 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg_ambiguous): hopefully better message.
+
+ * lib/cgi.rb (CGI::QueryExtension::initialize_query): to_ary
+ removed.
+
+Tue Apr 22 06:06:22 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/resolv.rb (Resolv::DNS::Resource#hash): use XOR to accumulate
+ hash value.
+
+ * lib/tsort.rb (TSort#each_strongly_connected_component): don't use
+ block argument.
+ (each_strongly_connected_component_from): ditto.
+
+Mon Apr 21 21:59:48 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c: one more digit for decimal point. [ruby-talk:69808]
+
+Mon Apr 21 21:25:59 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * numeric.c (flo_is_finite_p): use finite() if available.
+
+ * win32/win32.h (isinf, isnan): define as macro.
+ [ruby-win32:00533]
+
+ * bcc32/Makefile.sub, win32/Makefile.sub: no longer use
+ missing/isinf.c, missing/isnan.c.
+
+Mon Apr 21 18:36:28 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bignum.c (rb_cstr_to_inum): unnecessarily long buffer was used
+ for radix 9. [ruby-dev:20057]
+
+Mon Apr 21 17:44:34 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (block_append, value_expr0, assign_in_cond,
+ warn_unless_e_option, warning_unless_e_option, range_op,
+ cond0): adjust line number in warning.
+
+Mon Apr 21 00:47:42 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * sample/test.rb: avoid the MSVCRT *printf problem(float).
+ [ruby-dev:20037]
+
+Mon Apr 21 00:11:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c (w_float): append least mantissa bits to get rid
+ of roundoff problem. [ruby-talk:69518]
+
+ * marshal.c (r_object0): load least mantissa bits.
+
+Sun Apr 20 23:24:25 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c (NtInitialize): set the floating-point control word
+ on bcc32.
+
+ * win32/win32.h, bcc32/Makefile.sub: use missing/isinf.c, should not
+ use _finite() because it returns 0 if NaN.
+
+Sun Apr 20 03:09:30 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * parse.y (void_expr0): node might become NULL after calling
+ remove_begin().
+
+Sat Apr 19 21:55:10 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/Setup*: Add zlib and remove bogus and obsolete entries.
+
+Sat Apr 19 14:47:07 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc): use rb_gc_mark_maybe() to mark registered C
+ addresses. C variables may not hold valid reference to Ruby
+ objects. [ruby-core:00975]
+
+Sat Apr 19 00:56:13 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * struct.c (rb_struct_eql): should compare values with "eql?".
+
+Fri Apr 18 23:29:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_check): <=> returns nil for invalid values;
+ should check.
+
+Fri Apr 18 15:26:50 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * error.c (rb_raise): workaround for some implementations of
+ vsnprintf.
+
+Fri Apr 18 02:23:42 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): should not set RE_OPTIMIZE_ANCHOR,
+ if anychar_repeat is enclosed by parentheses.
+
+Fri Apr 18 01:49:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * util.c (ruby_strtod): improved conversion accuracy.
+
+Thu Apr 17 14:39:23 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/dbm/dbm.c (each_pair): add prototype to avoid VC++ warnings.
+
+ * ext/readline/readline.c (Init_readline): follow readline 4.2
+ prototype.
+
+Thu Apr 17 14:22:36 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (cond0): warn only range literals whose both side are
+ literals. [ruby-core:00964]
+
+Thu Apr 17 11:10:59 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/readline/readline.c: add the defined operator for bcc32.
+
+Wed Apr 16 00:14:06 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-special-char-p): should test at the
+ point if no argument. fixed by Michael Scholz
+ <scholz-micha@gmx.de>.
+
+Tue Apr 15 19:35:08 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: rm_r should raise Errno::ENOENT if file
+ does not exist ([ruby-core:958]). Thanks Johan Holmberg.
+
+Tue Apr 15 19:12:21 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * struct.c (rb_struct_hash): new methods Struct#hash, Struct#eql?.
+ (ruby-bugs:PR#758)
+
+Tue Apr 15 16:05:11 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * numeric.c (rb_fix2str): buffer was insufficient.
+ (ruby-bugs-ja:PR#431)
+
+Mon Apr 14 19:45:56 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (file_expand_path): root must follow buf when
+ reallocated. [ruby-talk:69339], [ruby-dev:20025]
+
+Mon Apr 14 03:22:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * rubyio.h (struct OpenFile): add noraise flag to finalizer.
+
+ * io.c (Init_IO): define $/, $-0, and $\ as string-only
+ variables.
+
+ * string.c (rb_str_split_m): does not generate empty string if
+ the receiver is empty.
+
+ * io.c (fptr_finalize): should raise error on EBADF for readable
+ IOs as well.
+
+Mon Apr 14 15:54:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bignum.c (rb_cstr_to_inum, rb_big2str): allow 2-36 as radix.
+
+ * numeric.c (rb_fix2str): ditto.
+
+ * string.c (rb_str_to_i): ditto.
+
+Sun Apr 13 03:20:31 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (try_func): remove COMMON_HEADERS at first for
+ performance.
+
+Sat Apr 12 20:59:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-beginning-of-arg): substitute
+ ruby-backward-arg.
+
+ * misc/ruby-mode.el (ruby-calculate-indent): fixed wrong
+ indentation in brace block and parentheses.
+
+ * misc/ruby-mode.el (ruby-forward-sexp, ruby-backward-sexp):
+ support special char literal, and negative arguments.
+
+Sat Apr 12 17:52:47 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_stat): use rb_check_convert_type() to retrieve IO.
+
+Fri Apr 11 19:00:14 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (rb_w32_stat): check arguments. [ruby-dev:20007]
+ [ruby-win32:535]
+
+Fri Apr 11 15:56:08 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * numeric.c (coerce_rescue): prevent inspected String from GC.
+
+ * numeric.c (flo_eq, rb_dbl_cmp, flo_gt, flo_ge, flo_lt, flo_le,
+ flo_eql): correct NaN comparison. (ruby-bugs:PR#744)
+
+ * sample/test.rb: NaN comparison test.
+
+Fri Apr 11 14:48:47 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_stat): dereference using StringValuePtr().
+
+ * file.c (rb_file_s_stat): use rb_stat(). [ruby-dev:20007]
+
+Fri Apr 11 10:51:08 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/benchmark.rb (Benchmark::bm): get rid of warning.
+ [ruby-talk:69124]
+
+Fri Apr 11 02:41:35 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (set_stdin): assigned value must respond to "read" and
+ "getc".
+
+ * io.c (set_outfile): assigned value must respond to "write".
+ (ruby-bugs-ja:PR#425)
+
+Thu Apr 10 21:12:19 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/pop.rb: Exception line was accidentaly removed.
+ [ruby-dev:19989]
+
+Thu Apr 10 18:42:13 2003 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * array.c (rb_ary_times): added some checks for request size.
+
+Thu Apr 10 03:22:38 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_name): always return empty string for
+ anonymous class/module. (ruby-bugs-ja PR#424)
+
+ * config.sub: stop forcing addition of -gnu to -linux.
+
+ * variable.c (classname): refactoring.
+
+ * variable.c (rb_class_path): __tmp__classpath__ handling moved
+ from classname().
+
+Thu Apr 10 01:52:24 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_obj_is_method): indefinite return value.
+
+Thu Apr 10 00:39:32 2003 Tanaka Akira <akr@m17n.org>
+
+ * regex.c (re_compile_pattern): /[\--\-]/ was warned. warn /]/.
+
+ * mkconfig.rb: escape `]' in regexp.
+
+Thu Apr 10 00:27:07 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * time.c (time_strftime): RSTRING(format)->ptr might become NULL.
+
+Wed Apr 9 23:54:50 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_obj_remove_instance_variable): better message.
+ [ruby-talk:68987]
+
+ * variable.c (rb_mod_remove_const): ditto.
+
+ * object.c (rb_obj_ivar_get): ditto.
+
+ * object.c (rb_obj_ivar_set): ditto.
+
+ * parse.y (yylex): ditto.
+
+Wed Apr 9 21:51:20 2003 Dave Thomas <Dave@Thomases.com>
+
+ * eval.c (rb_mod_define_method): Allow UnboundMethod as
+ parameter.
+
+Wed Apr 9 18:30:58 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (top_include): include module to wrapper module if
+ wrapper is present. experimental. [ruby-list:37539]
+
+Wed Apr 9 17:24:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc_mark_children): introduce this function again; this
+ is required when stack was very tight. [ruby-talk:68916]
+
+Wed Apr 9 15:49:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (bigdivmod): small typo.
+
+Wed Apr 9 15:35:04 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/readline/readline.c: include <unistd.h> only when
+ HAVE_UNISTD_H is defined.
+
+Wed Apr 9 14:05:00 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c (w_object): preserve extended module on struct.
+ (ruby-bugs-ja:PR#422)
+
+Wed Apr 9 03:43:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (BIGZEROP): macro to determine if x is a bignum zero.
+
+Tue Apr 8 11:49:31 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (Init_Proc): make Method and UnboundMethod independent.
+ They are like instance and its class. [ruby-core:00941]
+
+ * parse.y (yylex): disallow global variables like "$1ve".
+ [ruby-core:00945]
+
+ * marshal.c (marshal_dump): Marshal.dump(0, false) should cause an
+ error. (ruby-bugs-ja PR#421)
+
+ * regex.c (re_compile_pattern): warn if '-' is the edge of
+ character range.
+
+Mon Apr 7 15:49:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (sock_s_unpack_sockaddr_in): remove struct
+ size check. getnameinfo(3) can handle. [ruby-dev:19967]
+
+Mon Apr 7 01:33:31 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_read): do not call rb_sys_fail() when required data
+ length is zero. (ruby-bugs-ja PR#420)
+
+ * eval.c (umethod_proc): should raise TypeError, instead of
+ returning error causing Proc. Following the principle of "fail
+ early". [ruby-core:00927]
+
+Sun Apr 6 18:29:21 2003 UENO Katsuhiro <katsu@blue.sky.or.jp>
+
+ * ext/zlib/zlib.c: the return value of GzipReader#getc must be
+ unsigned.
+
+Sun Apr 6 00:35:37 2003 Tanaka Akira <akr@m17n.org>
+
+ * sample/exyacc.rb: use Regexp in gsub!.
+
+Sat Apr 5 23:41:28 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_pack): small but serious typo.
+
+Sat Apr 5 04:23:05 2003 Warren Brown <wkb@airmail.net>
+
+ * sprintf.c (rb_f_sprintf): was decrementing width even if there
+ is no sign character.
+
+Sat Apr 5 01:41:28 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (backtrace): skip internal allocator frame.
+ (ruby-bugs-ja PR#416)
+
+Fri Apr 4 10:53:22 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (assign): should prepare mrhs by svalue_to_mrhs().
+
+Wed Apr 2 15:11:23 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * README.EXT, README.EXT.ja (3.3): clarified -1 as free for
+ Data_Wrap_Struct(). [ruby-dev:19881]
+
+Mon Mar 31 11:11:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_missing): use "inspect" for T_OBJECT as well.
+
+Mon Mar 31 10:50:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (env_reject_bang): untaint key string.
+
+ * hash.c (env_delete_m): execute block only if deleting key does
+ not exist.
+
+Sat Mar 29 17:54:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_pack): do not call rb_str_buf_cat() with NULL ptr,
+ which causes SEGV; jump to grow instead. [ruby-dev:19944]
+
+Sat Mar 29 15:19:48 2003 Tanaka Akira <akr@m17n.org>
+
+ * instruby.rb, ext/extmk.rb, lib/benchmark.rb, lib/cgi.rb,
+ lib/debug.rb, lib/getoptlong.rb, lib/optparse.rb, lib/time.rb,
+ lib/date/format.rb, lib/irb/ruby-lex.rb lib/uri/common.rb: revert
+ escape for `-' in character class.
+
+Sat Mar 29 09:48:35 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (avalue_to_svalue): use rb_check_array_type() again.
+ Clarify how "to_ary" and "to_a" work. [ruby-talk:68155]
+
+ * eval.c (svalue_to_avalue): ditto.
+
+ * eval.c (svalue_to_mrhs): ditto.
+
+ * eval.c (rb_eval): unary splat to use to_a, but we need a hack to
+ exclude Object#to_a until it's removed.
+
+ * object.c (rb_Array): check obj.respond_to?("to_a"). Currently
+ all object respond_to "to_a", but Object#to_a will be removed.
+
+ * range.c (Init_Range): undefine to_ary.
+
+ * re.c (Init_Regexp): ditto.
+
+Sat Mar 29 09:47:52 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * MANIFEST (ext/aix_mksym.rb): remove obsolete file.
+
+Fri Mar 29 06:21:24 2003 UENO Katsuhiro <katsu@blue.sky.or.jp>
+
+ * ext/zlib: merge from rough.
+
+Fri Mar 28 19:33:39 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * variable.c (rb_class_path): hold temporary class path in a
+ instance variable to get rid of GC. [ruby-dev:19932]
+
+ * variable.c (classname): remove temporary class path when exact
+ name found.
+
+Fri Mar 28 18:29:23 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): do not warn if "-" is at the top
+ or last of character class.
+
+Thu Mar 27 12:10:15 2003 Tanaka Akira <akr@m17n.org>
+
+ * regex.c (re_compile_pattern): fix [:name:] handling.
+ /[\[:digit:]]/ was treated as /[[:digit:]]/.
+ /[[:-@]/ was treated as /[\[:\-@]/.
+ /[%-[:digit:]]/ was treated as /[%-\[:digit:]\]/.
+
+Thu Mar 27 03:26:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * string.c (rb_str_capitalize_bang): check length before upcase
+ first character. (ruby-bugs:PR#697)
+
+Wed Mar 26 20:25:10 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * dln.c (dln_find_1): break if path list end, even for too long
+ path names. (ruby-bugs-ja:PR#412)
+
+Wed Mar 26 13:19:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (avalue_splat): new function to do unary * (splat)
+ operator.
+
+ * eval.c (avalue_to_svalue,svalue_to_avalue,svalue_to_mrhs): do
+ not use implicit "to_ary" conversion.
+
+ * ext/curses/curses.c (GetWINDOW,GetMOUSE): add taint check.
+
+ * ext/curses/curses.c (curses_init_screen): ditto.
+
+ * ext/curses/curses.c (window_initialize): ditto.
+
+ * gc.c (os_each_obj): prohibit ObjectSpace#each_object in safe
+ mode ($SAFE >= 4).
+
+Tue Mar 25 23:26:02 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * signal.c (trap): return "DEFAULT" and "IGNORE" respectively for
+ previous sighandler SIG_DFL and SIG_IGN. [ruby-talk:67860]
+
+Tue Mar 25 12:24:15 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): call avalue_to_mrhs() to assign block
+ parameter |a|. [ruby-dev:19897]
+
+ * ruby.c (ruby_set_argv): freeze argument strings.
+
+Tue Mar 25 12:01:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_initialize): should check rb_secure(4).
+
+ * dir.c (dir_s_getwd): should check rb_secure(4).
+
+ * object.c (rb_obj_infect): function version of OBJ_INFECT().
+
+ * eval.c (rb_secure_update): new function to check object update.
+
+Tue Mar 25 10:18:05 2003 Minero Aoki <aamine@loveruby.net>
+
+ * ext/strscan/strscan.c: should infect also return values of
+ #inspect.
+
+ * ext/strscan/strscan.c: use snprintf() instead of sprintf().
+
+Mon Mar 24 16:55:04 2003 Takaaki Tateishi <ttate@ttsky.net>
+
+ * ext/dl/dl.c: added rb_secure(4). (Thanks to Minero Aoki)
+
+ * ext/dl/sym.c: ditto.
+
+ * ext/dl/ptr.c: ditto.
+
+Mon Mar 24 00:09:02 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (block_append): warn unused literal.
+
+Sun Mar 23 22:22:04 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/jcode.rb (tr!, delete!, szueeze!): add empty string checking.
+
+Sun Mar 23 19:54:53 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * gc.c (rb_gc_call_finalizer_at_exit): use free() if dfree is -1.
+
+Sat Mar 22 15:50:29 2003 Tanaka Akira <akr@m17n.org>
+
+ * time.c (make_time_t): try search_time_t if mktime/timegm is failed.
+
+Sat Mar 22 13:26:33 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/optparse.rb, lib/jcode.rb, ext/tk/lib/tk.rb: reorder character
+ class /[\]\[]/ to /[\[\]]/ for readability.
+
+Sat Mar 22 12:44:15 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/date/format.rb, lib/uri/common.rb: escape `[', `]', `-' in
+ character class in regexp to avoid warning.
+
+Sat Mar 22 07:39:32 2003 Ulf Betlehem <flu@iki.fi>
+
+ * io.c (rb_io_fread): may lose data on nonblocking read.
+
+Fri Mar 21 23:40:41 2003 Tanaka Akira <akr@m17n.org>
+
+ * regex.c (re_compile_pattern): fix previous change.
+
+ * instruby.rb, ext/extmk.rb, ext/tk/lib/tk.rb, lib/benchmark.rb,
+ lib/cgi.rb, lib/debug.rb, lib/getoptlong.rb, lib/jcode.rb,
+ lib/optparse.rb, lib/time.rb, lib/date/format.rb,
+ lib/irb/ruby-lex.rb: escape `[', `]', `-' in character class in
+ regexp to avoid warning.
+
+Fri Mar 21 23:23:45 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): give warning for unescaped square
+ brackets and minus in character class. [ruby-dev:19868]
+
+Fri Mar 21 18:12:20 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (bmcall): missing type.
+
+Fri Mar 21 01:29:35 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sprintf.c (rb_f_sprintf): copy sign bits only if value is
+ negative.
+
+ * missing.h: include <stdarg.h> or <varargs.h> if HAVE_VSNPRINTF
+ is not defined.
+
+Thu Mar 20 18:31:37 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb (OptionParser#order!): follow recent change
+ of proc argument.
+
+Thu Mar 20 16:12:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (flo_to_s): change format specifier to "%.15g" to
+ avoid unnecessary 9s (e.g. 99.59999999999999). (ruby-bugs-ja PR#406)
+
+Thu Mar 20 16:03:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (stmt, primary): get rid of SEGV at empty or invalid
+ condition. (ruby-bugs-ja:PR#410)
+
+ * parse.y (cond_negative): negate condition node when NODE_NOT.
+
+Thu Mar 20 10:45:29 2003 Tanaka Akira <akr@m17n.org>
+
+ * eval.c (bmcall): add volatile to avoid GC problem.
+
+Thu Mar 20 10:10:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (load_dyna): clear ruby_errinfo. (ruby-bugs-ja PR#409)
+
+Wed Mar 19 23:05:30 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+
+ * lib/tracer.rb (trace_func): save and recover Thread.critical state.
+ Fixed by Fukumoto Atsushi <fukumoto@imasy.or.jp> [ruby-dev:19830]
+
+Wed Mar 19 02:55:46 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (read_all): make str empty if given. (ruby-bugs-ja PR#408)
+
+ * io.c (io_read): ditto.
+
+ * io.c (rb_io_sysread): ditto.
+
+Tue Mar 18 18:24:03 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c: do not override min and max.
+
+Sun Mar 16 12:29:55 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb (object_address_group): use to_s instead of name
+ to get name of class.
+
+Fri Mar 14 08:53:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sprintf.c (remove_sign_bits): octal left most digit for negative
+ numbers may be '3'. (ruby-bugs-ja PR#407)
+
+ * sprintf.c (rb_f_sprintf): should prefix sign bits if bignum is
+ negative, using sign_bits().
+
+Wed Mar 12 16:48:19 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (prep_stdio): set binmode only if the file descriptor
+ is not connected to a terminal on Cygwin.
+
+Wed Mar 12 11:23:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (avalue_to_mrhs): split argument passing and assignment
+ conversion.
+
+ * eval.c (svalue_to_mrhs): ditto.
+
+ * eval.c (avalue_to_svalue): avalue_to_svalue([[1,2]]) should be
+ [[1,2]], not [1,2] to wrap-around.
+
+Tue Mar 11 21:00:59 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: Digest string wrongly included '\n' when user
+ name is too long (ruby-bugs-ja:PR#404).
+
+Tue Mar 11 20:07:01 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: speeding up by avoiding extra flush.
+ (suggested by Brian Candler <B.Candler@pobox.com> [ruby-talk:66516])
+
+Tue Mar 11 04:30:12 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (massign): remove unnecessary array unpacking; it should
+ be handled before massign() by svalue_to_mrhs().
+
+ * eval.c (svalue_to_mrhs): '*a = v' value conversion to avalue
+ (i.e. [1] => [[1]], [1,2] => [1,2]).
+
+ * eval.c (rb_eval): use svalue_to_mrhs.
+
+ * eval.c (rb_yield_0): ditto.
+
+ * eval.c (proc_invoke): break from "Proc#yield" is legal.
+
+Mon Mar 10 23:19:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_find_file): need world writable directory check for
+ relative paths too.
+
+Mon Mar 10 11:23:00 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_find_file): world writable directory check if
+ $SAFE >= 1 (was $SAFE >= 2).
+
+Mon Mar 10 01:59:47 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/pop.rb: do not dispatch LIST when a mailbox is empty.
+
+ * lib/net/pop.rb: merge the 'STAT' patch from Frank S.Fejes
+ <frank@oopdreams.com>, with modifications (listed below).
+
+ * lib/net/pop.rb: new method Net::POP#mail_size.
+
+ * lib/net/pop.rb: new method Net::POP#bytes.
+
+ * lib/net/pop.rb: new method Net::POPCommand#stat.
+
+Sun Mar 9 19:30:25 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/fileutils.rb (mkdir, mkdir_p): revert.
+
+ * instruby.rb (umask): umask 0022, not 0.
+
+Sun Mar 9 17:09:40 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/fileutils.rb (mkdir, mkdir_p): set mode to 0755.
+
+ * Makefile.in (fake.rb): set ALT_SEPARATOR to the default value.
+
+Sat Mar 8 11:30:59 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (massign): fix a bug not to expand in assignment to sole
+ lhs. [ruby-dev:19766]
+
+Fri Mar 7 21:57:25 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb (Kernel.pp): module function.
+ (MatchData#pretty_print): new method.
+
+Fri Mar 7 20:27:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/tcltklib/extconf.rb (find_tcl, find_tk): return true if
+ non-versioned found. [ruby-dev:19759]
+
+Fri Mar 7 15:05:35 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/dbm/extconf.rb: add QDBM support.
+
+Fri Mar 7 12:59:39 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (massign): deal with sole lhs, assign rest args from
+ converted array. [ruby-dev:19751]
+
+Fri Mar 7 03:31:36 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (dsym): :"symbol string" style should not contain `\0'.
+
+ * process.c (proc_detach): new method Process.detach(pid) which
+ create background watcher thread to issue waitpid. [new]
+
+ * process.c (rb_detach_process): utility function to detach
+ process from C code.
+
+ * ext/pty/pty.c (pty_finalize_syswait): terminate watcher thread,
+ and detach child process (by creating new idle waitpid watcher
+ thread).
+
+ * ext/pty/pty.c (pty_syswait): may lost signal stopped child.
+
+Fri Mar 7 00:30:33 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/Win32API/Win32API.c: no longer use inline-asms.
+
+ * ext/Win32API/extconf.rb: no need to add gcc options.
+
+Thu Mar 6 13:02:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (reswords): fix reswords list.
+
+Wed Mar 5 12:13:21 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: better YACC support on HP-UX.
+
+Wed Mar 5 05:55:20 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_cat): remove ptr NULL check and MEMZERO(). ptr
+ must be non NULL.
+
+Tue Mar 4 23:12:07 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in, bcc32/Makefile.sub, win32/Makefile.sub: define
+ RUBY_EXPORT to export symbols.
+
+ * defines.h: use RUBY_EXTERN instead of EXTERN.
+
+ * intern.h, re.h, ruby.h, rubysig.h: ditto.
+
+ * win32/win32.h: remove EXTERN definition.
+
+Tue Mar 4 17:54:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_aref): raise TypeError if index is a symbol.
+ [ruby-list:37217]
+
+ * array.c (rb_ary_aset): ditto.
+
+Tue Nov 13 14:39:11 2001 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * missing/strftime.c: HP-UX support.
+
+Tue Mar 4 15:08:08 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: better HP-UX support.
+
+ * missing/strftime.c: ditto.
+
+Tue Mar 4 10:11:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_popen): do not call rb_io_close() directly, call
+ "close" method instead. [ruby-dev:19717]
+
+ * io.c (rb_io_s_open): ditto.
+
+ * hash.c (rb_any_hash): remove DEFER_INTS. all do_hash() calls in
+ st.c are at the top of functions. No reentrant problem.
+
+Tue Mar 4 01:19:21 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/dl/MANIFEST: Exclude .cvsignore. [found by: eban]
+
+Tue Mar 4 01:17:08 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/Win32API/MANIFEST: Belatedly add lib/win32/registry.rb.
+ [found by: eban]
+
+Tue Mar 4 00:33:04 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * MANIFEST: Belatedly add Test::Unit files. D'oh!
+
+Sun Mar 2 09:51:47 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c (w_nbyte): should output always via rb_io_write().
+
+ * marshal.c (dump_ensure): ditto.
+
+ * marshal.c (marshal_dump): should call "binmode" method, if it
+ responds to.
+
+ * marshal.c (r_byte): should input always via "getc" method.
+
+ * marshal.c (r_bytes0): should input always via "read" method.
+
+ * marshal.c (marshal_load): need not to set up FILE* fp;
+
+Mon Mar 3 11:29:04 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): parse 'lhs = a rescue b' as 'lhs=(a rescue b)'.
+
+Mon Mar 3 02:53:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_fread): should not clearerr() if there's no filled
+ buffer (i.e. rb_io_fread() returning zero).
+
+Mon Mar 3 01:42:35 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-expr-beg): escaped char syntax.
+
+ * misc/ruby-mode.el (ruby-parse-partial): ditto.
+
+ * misc/ruby-mode.el (ruby-parse-partial): no deep indent for
+ block.
+
+ * misc/ruby-mode.el (ruby-backward-arg): skip arguments backward.
+
+ * misc/ruby-mode.el (ruby-calculate-indent): too deep indentation.
+
+Fri Feb 28 23:50:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (map_errno): map OS error to errno. [new]
+
+ * win32/win32.c (pipe_exec, CreateChild, poll_child_status, waitpid,
+ kill, link, rb_w32_rename, unixtime_to_filetime, rb_w32_utime): use
+ map_errno() instead of using GetLastError() directly.
+
+ * win32/win32.c (rb_w32_select, rb_w32_accept, rb_w32_bind,
+ rb_w32_connect, rb_w32_getpeername, rb_w32_getsockname,
+ rb_w32_getsockopt, rb_w32_ioctlsocket, rb_w32_listen, rb_w32_recv,
+ rb_w32_recvfrom, rb_w32_send, rb_w32_sendto, rb_w32_setsockopt,
+ rb_w32_shutdown, rb_w32_socket, rb_w32_gethostbyaddr,
+ rb_w32_gethostbyname, rb_w32_gethostname, rb_w32_getprotobyname,
+ rb_w32_getprotobynumber, rb_w32_getservbyname, rb_w32_getservbyport,
+ rb_w32_fclose, rb_w32_close): map winsock error to errno.
+
+Fri Feb 28 22:54:10 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (flock): supports larger files, and maps error
+ code.
+
+ * win32/win32.c (rb_w32_asynchronize): returns errno from child
+ thread.
+
+ * win32/win32.c (rb_w32_fclose, rb_w32_close): ensures unlocked.
+
+Wed Feb 26 17:38:16 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/open-uri.rb: replace Kernel.open as well.
+
+Tue Feb 25 23:03:08 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
+
+ * lib/debug.rb (DEBUGGER__::Context#debug_command): bp filename must
+ be the basename of it. [ruby-talk:65644]
+
+Mon Feb 24 17:49:35 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (yycompile): zero clear ruby_eval_tree_begin if
+ compilation failed.
+
+Mon Feb 24 08:06:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (str_new): need no MEMZERO().
+
+Sun Feb 23 17:57:06 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/fileutils (fu_stream_blksize): wrong logical condition.
+ (and -> or).
+
+Sat Feb 22 03:12:56 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (fix_gt): use rb_num_coerce_cmp() instead of
+ rb_num_coerce_bin.
+
+ * numeric.c (fix_ge, fix_lt, fix_le): ditto.
+
+ * numeric.c (flo_gt, flo_ge, flo_lt, flo_le): ditto.
+
+Sat Feb 22 02:45:20 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_create): may called from place higher than
+ rb_gc_stack_start.
+
+ * gc.c (Init_stack): update rb_gc_stack_start if it is lower (or
+ higher if stack grows down) than the previous value.
+
+Fri Feb 21 21:03:41 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: new method FileUtils#copy_stream.
+
+ * lib/fileutils.rb: new method FileUtils#compare_file.
+
+ * lib/fileutils.rb: new method FileUtils#compare_stream.
+
+ * lib/fileutils.rb: new method FileUtils#rmtree (alias of rm_rf).
+
+Fri Feb 21 17:19:27 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * eval.c (rb_f_require): do not need to abort if a DLEXT file
+ is not found.
+
+Fri Feb 21 13:39:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_cmp_m): should use LONG2NUM().
+
+Fri Feb 21 12:45:50 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_cmp_m): two small bugs fixed.
+
+Fri Feb 21 08:03:09 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc_mark): inline rb_gc_mark_children().
+
+ * gc.c (gc_sweep): new tactics to increase malloc_limit mildly.
+
+Fri Feb 21 05:16:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_cmp_m): return nil if str2 does not respond to
+ both "to_str" and "<=>".
+
+ * compar.c (cmp_gt): return nil if "<=>" returns nil (means
+ incomparable).
+
+ * compar.c (cmp_ge, cmp_lt, cmp_le): ditto.
+
+ * compar.c (cmp_between): use RTEST(), since cmp_lt and cmp_gt may
+ return nil.
+
+Thu Feb 20 19:05:51 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_start_0): main thread swapped by fork() may
+ terminate rb_thread_start_0() successfully. call ruby_stop(0);
+ this change was suggested by Rudi Cilibrasi
+ <cilibrar@drachma.ugcs.caltech.edu>.
+
+Thu Feb 20 18:44:51 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (file_expand_path): fix wrong behavior for root file.
+ expand_path("..", "//machine/share") => "//machine/share"
+ expand_path("..", "c:/a") => "c:/"
+ expand_path("..", "/a") => "/"
+
+Thu Feb 20 18:11:01 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (file_expand_path): should not upward beyond share name.
+
+Thu Feb 20 15:45:33 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * missing.h (strtoul): fix prototype of strtoul.
+
+Thu Feb 20 10:11:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (clhs): allow "Foo::Bar = x".
+
+Thu Feb 20 04:07:06 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (primary): "self[n]=x" can be legal even when "[]=" is
+ private. changes submitted in [ruby-talk:63982]
+
+ * parse.y (aryset): ditto.
+
+ * parse.y (attrset): "self.foo=x" can be legal even when "foo="
+ is private.
+
+ * eval.c (is_defined): private "[]=" and "foo=" support.
+
+ * eval.c (rb_eval, assign): ditto.
+
+Thu Feb 20 03:58:34 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): "foo=" should not always be public.
+
+Thu Feb 20 01:23:59 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_restore_context): inhibit interrupts in
+ critical section while context switching. [ruby-talk:64785]
+
+Wed Feb 19 18:27:42 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * node.h (nd_cpath): nested class/module declaration.
+ [EXPERIMENTAL]
+
+ * eval.c (rb_eval): ditto.
+
+ * gc.c (rb_gc_mark_children): ditto.
+
+ * parse.y (cpath): ditto.
+
+Tue Feb 18 21:39:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call0): should not report uninitialized warning by
+ attribute reader method.
+
+ * variable.c (rb_attr_get): new function to get instance variable
+ without uninitialized warning.
+
+ * io.c (argf_to_io): should prefetch argv.
+
+Tue Feb 18 00:13:50 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-comment-column): customize comment
+ column. [new]
+
+ * misc/ruby-mode.el (ruby-deep-indent-paren): deep indentation
+ parentheses. [new]
+
+ * misc/ruby-mode.el (ruby-expr-beg): fix for / after $?.
+
+ * misc/ruby-mode.el (ruby-parse-partial, ruby-calculate-indent):
+ deep indentation support.
+
+ * misc/ruby-mode.el (ruby-forward-sexp, ruby-backward-sexp):
+ move forward/backward across one balanced expression. [new]
+
+ * misc/ruby-mode.el (ruby-indent-exp): indent balanced
+ expression. [new]
+
+ * misc/ruby-mode.el (ruby-electric-brace): indent before
+ show matching parenthesis. (contributed by NABEYA Kenichi)
+
+Mon Feb 17 14:36:56 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (rb_w32_opendir, rb_w32_utime): need parens.
+
+Mon Feb 17 14:13:25 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (link): implement with CreateHardLink().
+
+ * win32/win32.c, win32/win32.h (rb_w32_utime): enable utime() to
+ directory if on NT. [new] (ruby-bugs-ja:PR#393)
+
+Mon Feb 17 13:28:51 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (file_expand_path): strip last slash when path is
+ root.
+
+Sun Feb 16 19:22:31 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (file_expand_path): buffer might be reallocated while
+ expanding default directory.
+
+ * file.c (file_expand_path): default directory was being
+ ignored if path was full path with no drive letter, under
+ DOSISH.
+
+Sun Feb 16 03:14:33 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (prep_stdio, Init_io): always set binmode on Cygwin.
+
+Sat Feb 15 01:01:45 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (file_expand_path): fix surplus path separators while
+ expanding at root directory. [ruby-dev:19572]
+
+Fri Feb 14 14:25:24 2003 akira yamada <akira@arika.org>
+
+ * lib/uri/generic.rb, lib/uri/ldap.rb, lib/uri/mailto.ldap: all foo=()
+ returns arguments passed by caller.
+
+ * lib/uri/generic.rb (Generic#to_str, Generic#to_s): removed to_str.
+ Suggested by Tanaka Akira <akr@m17n.org> at [ruby-dev:19475].
+
+ * lib/uri/generic.rb (Generic#==): should not generate an URI object
+ from argument. Suggested by Tanaka Akira <akr@m17n.org> at
+ [ruby-dev:19475].
+
+Thu Feb 13 11:54:50 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ruby.c (ruby_init_loadpath): ensures buffer terminated
+ before use strncpy().
+
+ * ruby.c (proc_options): avoid SEGV at -S with no arguments.
+ script argument is in effect only when -e is not given.
+ (ruby-bugs-ja:PR#391)
+
+Thu Feb 13 01:30:10 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_schedule): current thread may be dead when
+ deadlock. (ruby-bugs:PR#588)
+
+Thu Feb 13 00:28:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_step): step might be float 0 < x < 1.
+
+ * eval.c (rb_thread_schedule): pause if no runnable thread when
+ there's only one thread.
+
+Thu Feb 13 00:09:47 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (strrdirsep): ignore trailing directory separators.
+
+ * file.c (rb_file_s_expand_path): File.expand_path(".","/") should
+ return "/". (ruby-bugs-ja:PR#389)
+
+ * file.c (rb_file_s_basename): also ignore trailing directory
+ separators, in compliance with SUSv3. (ruby-bugs-ja:PR#390)
+
+ * file.c (rb_file_s_dirname, rb_file_s_extname): ditto.
+
+ * file.c (rb_file_s_dirname): append "." if drive only.
+
+ * file.c (rb_file_s_split): get rid of converting twice.
+
+Mon Feb 10 20:55:15 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb (parse_args): add '-n' to $mflags BEFORE "--".
+ do not add DESTDIR if already included in $mflags.
+
+Mon Feb 10 19:54:30 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb (FileUtils#uptodate?): use mtime for
+ comparison.
+
+Mon Feb 10 10:14:26 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_to_a): return value should be an Array if the
+ receiver is an instance of subclass of Array.
+
+ * string.c (rb_str_to_s): return value should be a String if the
+ receiver is an instance of subclass of String.
+
+Mon Feb 10 03:33:42 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (rb_file_sysopen): rb_file_sysopen_internal() needs four
+ arguments.
+
+Sun Feb 9 15:16:04 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * intern.h (HAVE_RB_DEFINE_ALLOC_FUNC, RB_CVAR_SET_4ARGS):
+ define to 1.
+
+ * ruby.h (NORETURN_STYLE_NEW): ditto.
+
+Sun Feb 9 12:28:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (init_mkmf): add libdir to LIBPATH unless cross
+ compiling.
+
+Sun Feb 9 08:34:45 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: 4xx raises Net::ProtoServerError, 5xx raises
+ Net::ProtoFatalError (for backward compatibility).
+
+Sun Feb 9 07:07:26 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: new method FileUtils.pwd (really).
+
+ * lib/fileutils.rb: FileUtils.pwd, cmp, identical?, uptodate? does
+ not accept any option.
+
+Sat Feb 8 18:35:30 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-forward-string): fixed void variable
+ error.
+
+Sat Feb 8 16:23:11 2003 NABEYA Kenichi <kenichi@nabeya.com>
+
+ * misc/ruby-mode.el (ruby-font-lock-keywords): method name can
+ be delimited by tab.
+
+Sat Feb 8 03:57:32 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/irb/workspace.rb, lib/irb/ext/math-mode.rb,
+ lib/irb/ext/multi-irb.rb, lib/irb/lc/error.rb,
+ lib/irb/lc/help-message, lib/irb/lc/ja/error.rb,
+ lib/shell/command-processor.rb, lib/shell/error.rb,
+ lib/shell/filter.rb: Fix typos and grammos. [approved by: keiju]
+
+Sat Feb 8 03:34:28 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * intern.h (HAVE_RB_DEFINE_ALLOC_FUNC): New boolean macro to make
+ it easier to write extensions that work with both ~1.6 and 1.8~.
+
+ * intern.h (RB_CVAR_SET_4ARGS): Ditto.
+
+ * ruby.h (NORETURN_STYLE_NEW): Ditto.
+
+Sat Feb 8 00:47:24 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call): calls method_missing when superclass method
+ does not exist.
+
+ * eval.c (rb_f_missing): now handles "no super" case.
+
+ * object.c (rb_obj_ivar_get): Object#instance_variable_get: new
+ method to get instance variable value without eval(). [new]
+
+ * object.c (rb_obj_ivar_set): Object#instance_variable_set: new
+ method to set instance variable value without eval(). [new]
+
+Fri Feb 7 15:35:21 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * intern.h, re.c (rb_memsearch): returns long.
+
+ * string.c (rb_str_index): should return offset position.
+
+Fri Feb 7 15:30:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (proc_invoke): should propagate self to super
+ methods. [ruby-dev:19510]
+
+Thu Feb 6 19:04:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_initialize_m): should not preset "kcode" unless
+ encoding is explicitly specified.
+
+Thu Feb 6 19:01:32 2003 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: new method FileUtils.pwd.
+
+ * lib/fileutils.rb: default label is ''.
+
+ * lib/fileutils.rb: using module_eval again, to avoid ruby's bug.
+
+ * lib/fileutils.rb: fix wrong examples in rdoc.
+
+Thu Feb 6 17:43:56 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/complex.rb (Complex#==): should not raise error by type
+ mismatch.
+
+ * lib/rational.rb (Rational#==): ditto.
+
+Thu Feb 6 11:44:40 2003 MoonWolf <moonwolf@moonwolf.com>
+
+ * re.c (rb_reg_initialize_m): 3rd argument was ignored.
+
+Thu Feb 6 01:09:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_count): return 0 for empty string (was
+ returning nil).
+
+Wed Feb 5 19:41:37 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/open-uri.rb: dispatch code restructured to make it openable
+ that has `open' method.
+
+ * lib/open-uri.rb: Location: field may has a relative URI.
+ pointed out by erik eriksson <ee@opera.com>.
+
+Wed Feb 5 17:11:02 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): no .<digit> float literal anymore.
+
+Tue Feb 4 16:11:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_equal): a == b is true when b is non T_ARRAY
+ object, if b has "to_ary" and b == a.
+
+ * hash.c (rb_hash_equal): a == b is true when b is non T_HASH
+ object, if b has "to_hash" and b == a.
+
+ * string.c (rb_str_equal): a == b is true when b is non T_STRING
+ object, if b has "to_str" and b == a.
+
+Mon Feb 3 23:46:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_getline): should not increment lineno at EOF.
+
+Mon Feb 3 16:49:19 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): default Object#=== now calls "=="
+ internally.
+
+ * re.c (rb_reg_initialize_m): should honor option status of
+ original regexp.
+
+ * array.c (rb_ary_equal): ary2 should be T_ARRAY (no to_ary
+ conversion).
+
+ * array.c (rb_ary_eql): ditto.
+
+ * string.c (rb_str_equal): str2 should be T_STRING (no to_str
+ conversion).
+
+Mon Feb 3 16:32:52 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * re.c (rb_memsearch): a little improvement.
+
+Mon Feb 3 13:18:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_memsearch): algorithm body of String#index.
+
+ * error.c (Init_Exception): "to_str" removed.
+
+ * eval.c (eval): should not rely on Exception#to_str
+
+ * eval.c (compile_error): ditto.
+
+ * error.c (err_append): ditto.
+
+Sat Feb 1 23:56:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_merge): Hash#merge, non destructive "update".
+ now there's also Hash#merge! which is an alias to "update".
+
+Fri Jan 31 14:16:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_index): search using Karp-Rabin algorithm.
+
+Fri Jan 31 12:45:11 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_obj_classname): new function.
+
+ * string.c (rb_str_dup): should preserve original's class (but not
+ hidden singleton class).
+
+ * string.c (rb_str_substr): ditto.
+
+ * parse.y: backout EXPR_CMDARG removal.
+
+Fri Jan 31 09:40:07 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb (OptionParser::List::accept): default
+ pattern must not be nil.
+
+ * lib/optparse.rb (OptionParser::make_switch): NoArgument doesn't
+ override other styles.
+
+Thu Jan 30 16:46:43 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb (OptionParser::Switch::PlacedArgument): added.
+ if the next argument doesn't start with '-', use it as the
+ value.
+
+ * lib/optparse.rb (OptionParser::make_switch): fixed a bug of
+ pattern.
+
+ * lib/optparse.rb (Array): no need to guard.
+
+Thu Jan 30 08:27:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (rb_file_s_expand_path): removed a sludge.
+
+Wed Jan 29 03:24:39 2003 Michal Rokos <michal@rokos.homeip.net>
+
+ * dir.c (glob_helper): memory leak fixed.
+
+Tue Jan 28 04:45:03 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * instruby.rb (parse_args), ext/extmk.rb (parse_args): Prepend a
+ hyphen to the first argument of MAKEFLAGS only if appropriate.
+ Remove wrong comments.
+
+Mon Jan 27 03:30:06 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * error.c (get_syserror): use snprintf() instead of sprintf(). pointed
+ out by knu.
+
+Mon Jan 27 02:06:38 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * error.c (get_syserror): some Windows' errno have 5 digits. pointed
+ out by znz.
+
+Sun Jan 26 19:23:10 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * instruby.rb ($mflags.set?): Check $make instead of $nmake, since
+ there is no such a variable.
+
+ * instruby.rb ($mflags.set?), ext/extmk.rb ($mflags.set?): Return
+ false if unmatched.
+
+Sun Jan 26 19:08:30 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/shellwords.rb: Embed rdoc style comments.
+
+ * lib/shellwords.rb (shellwords): Use String#lstrip!.
+
+ * lib/shellwords.rb (shellwords): Recognize an object that
+ responds to to_str() by using String.new().
+
+Sun Jan 26 17:53:04 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * instruby.rb (parse_args), ext/extmk.rb (parse_args): Detect -n
+ and emulate a dry run. Use 'make' in case no --make argument is
+ given.
+
+Sun Jan 26 07:18:42 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * instruby.rb: re-define individual methods verbosely rather than
+ including FileUtils::Verbose, in order to suppress messages from
+ FileUtils#cmp.
+
+ * instruby.rb (makedirs): make same directory only once even if
+ dryrun.
+
+ * lib/fileutils.rb (FileUtils::Verbose, FileUtils::NoWrite):
+ re-define methods with define_method instead of module_eval.
+
+Sun Jan 26 03:37:18 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * instruby.rb, ext/extmk.rb, Makefile.in, win32/Makefile.sub,
+ bcc32/Makefile.sub: Replace the complicated MFLAGS/MAKEFLAGS
+ parser with something plain and comprehensible. This fixes a
+ bug where make flags were wrongly reordered and the resulted
+ command line often did not make sense especially when BSD make
+ is used with extra arguments given. Tested with FreeBSD and
+ Linux by me and mswin32, bccwin32 and mingw by usa.
+
+Fri Jan 24 18:15:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y: tMINUS should have lower precedence than tPOW.
+
+Fri Jan 24 05:12:55 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-font-lock-syntactic-keywords): deal
+ with escaped $ and ? at the end of strings. [ruby-talk:62297]
+
+ * misc/ruby-mode.el (ruby-font-lock-keywords): added defined?.
+
+Thu Jan 23 17:25:04 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): do not warn discarding already undefined
+ method.
+
+ * lib/rational.rb: undef quo before replacing.
+
+Thu Jan 23 15:49:57 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (arg): missing arguments.
+
+Thu Jan 23 14:56:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/rational.rb: modified to support "quo".
+
+ * numeric.c (num_quo): should return most exact quotient value,
+ i.e. float by default, rational if available.
+
+ * numeric.c (num_div): "div" should return x.divmod(x)[0].
+
+Thu Jan 23 13:24:18 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_arg): was accessing garbage argv value.
+
+Thu Jan 23 06:37:01 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * instruby.rb: should not contain destdir in shebang line.
+
+Wed Jan 22 23:19:57 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (pipe_exec): remove unnecessary SetStdHandle().
+
+Wed Jan 22 20:20:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): syntaxify tPOW negative number hack.
+
+ * parse.y (negate_lit): new function to negate literal numeric
+ values in compile time.
+
+Wed Jan 22 15:36:54 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_match_exec): charset info may be stored in MBC
+ region when $KCODE != NONE.
+
+Wed Jan 22 14:22:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (set_syserr): should preserve duplicated error names.
+
+Tue Jan 21 20:29:31 2003 Michal Rokos <michal@rokos.homeip.net>
+
+ * mkmf.rb: make possible to add files to clean and distclean targets
+
+Tue Jan 21 18:05:25 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bcc32/Makefile.sub (LIBRUBY_A): link dmyext.
+
+Tue Jan 21 16:59:18 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * instruby.rb: use real interpreter pathname at shebang line.
+ [ruby-dev:19370]
+
+Tue Jan 21 16:22:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): put back old ** behavior for negative number
+ right operand.
+
+Tue Jan 21 14:46:12 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb: Use Test::Unit.
+
+ * lib/prettyprint.rb: Ditto
+
+ * lib/time.rb: Ditto
+
+ * lib/tsort.rb: Ditto
+
+Tue Jan 21 04:15:50 2003 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb: Use redefined `to_s' as well as `inspect'.
+ Useless `pretty_print' methods removed.
+ (PP::ObjectMixin#pretty_print_inspect): new method.
+
+Mon Jan 20 21:48:43 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * configure.in (MANTYPE): Detect if the system's nroff(1) groks
+ mdoc. Provide a new option --with-mantype={doc|man} in case the
+ check does not work as expected.
+
+ * Makefile.in (MANTYPE): Define MANTYPE and pass it to
+ instruby.rb.
+
+ * instruby.rb: Convert mdoc manpages to man for systems which
+ nroff(1) does not grok mdoc.
+
+Mon Jan 20 21:25:18 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/tempfile.rb (self.open): If a block is given, call it with
+ tempfile as an argument and automatically close the tempfile
+ when the block terminates.
+
+Mon Jan 20 21:02:50 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * mdoc2man.rb: Properly put nested braces, parentheses and angles.
+
+ * mdoc2man.rb: Add support for .An and .Aq/.Ao/.Ac.
+
+ * mdoc2man.rb: Add support for .Dl.
+
+ * mdoc2man.rb: Make .Pf macro actually work.
+
+ * mdoc2man.rb: Properly handle .Os.
+
+ * mdoc2man.rb: Correctly omit spaces around punctuation
+ characters.
+
+Mon Jan 20 19:43:41 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * mdoc2man.rb: Make this work as a library.
+
+Mon Jan 20 18:22:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_f_require): purge too many goto's.
+
+Mon Jan 20 17:50:05 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * mdoc2man.rb (parse_macro): Understand .Ux.
+
+Mon Jan 20 17:32:56 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * mdoc2man.rb: New file. A mdoc to man converter ported from
+ Perl.
+
+Mon Jan 20 15:40:15 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * ruby.1: Properly close .Bl with .El.
+
+Mon Jan 20 04:14:17 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (egrep_cpp): use inspect to show options.
+
+ * lib/mkmf.rb (dir_config): prior configured directories to
+ defaults.
+
+ * lib/mkmf.rb (dir_config): extract first word to determine
+ make command type.
+
+Mon Jan 20 02:15:53 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/aix_mksym.rb: no longer used.
+
+Mon Jan 20 00:17:16 2003 Matt Armstrong <matt@lickey.com>
+
+ * file.c (eaccess): under windows, make eaccess() just call
+ access(). [ruby-core:716], [ruby-bugs:PR#556]
+
+Sun Jan 19 23:08:18 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/shellwords.rb (shellwords): A backslash ('\') in single
+ quotes should not be regarded as meta character. This bug or
+ maybe feature was inherited from Perl's shellwords.pl.
+
+Sun Jan 19 14:01:12 2003 UENO Katsuhiro <unnie@blue.sky.or.jp>
+
+ * regex.c (is_in_list): should work well with UTF-8.
+
+ * regex.c (re_match_exec): ditto.
+
+Sat Jan 18 14:53:49 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bignum.c (rb_cstr_to_inum): should not erase all 0s, but
+ squeeze into one. [ruby-dev:19377]
+
+Fri Jan 17 03:33:42 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * sprintf.c (rb_f_sprintf): Fix a bug caused by an uninitialized
+ variable v, that a bignum unexpectedly gets converted into a
+ string with its higher figures all filled with ./f/7/1,
+ depending on the base. This bug seems to have been introduced
+ in rev.1.27.
+
+ * sprintf.c (rb_f_sprintf): Use switch instead of a sequence of
+ else-if's.
+
+Wed Jan 15 15:18:38 2003 moumar <moumar@netcourrier.com>
+
+ * configure.in (ARCHFILE): set even unless --enable-shared on
+ AIX. [ruby-talk:61466]
+
+ * marshal.c (math.h): should be included after ruby.h on AIX.
+ [ruby-talk:61366]
+
+Tue Jan 14 21:47:56 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_f_require): do not search adding .rb/.so suffixes if
+ the suffix specified. [ruby-dev:18702]
+ http://moonrock.jp/~don/d/200211.html#d08_t1
+
+Tue Jan 14 18:36:41 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_all): now works without block.
+
+ * enum.c (enum_any): ditto.
+
+Tue Jan 14 01:21:32 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (next_argv): not always set binmode.
+
+Mon Jan 13 20:45:19 2003 Guy Decoux <ts@moulon.inra.fr>
+
+ * parse.y (list_append): avoid O(n) search using node->nd_next->nd_end.
+
+ * parse.y (list_concat): ditto.
+
+ * eval.c (rb_eval): NODE_ARRY nd_end adoption.
+
+Mon Jan 13 02:22:11 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/dl/lib/dl/win32.rb: eliminate unnecessary "A" adding.
+
+Sun Jan 12 16:07:17 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (next_argv): inherit binmode from $defout.
+
+Sat Jan 11 22:50:47 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/dl/lib/dl/win32.rb: compatibility improvement.
+
+Sat Jan 11 01:44:16 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (RUBY_CHECK_IO_NEED): added more tests.
+
+ * io.c (rb_io_check_readable): seek after synchronized write.
+
+Fri Jan 10 01:23:45 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-font-lock-syntactic-keywords): syntax
+ classes are not allowed inside character classes.
+ [ruby-talk:60996]
+
+Thu Jan 9 23:28:01 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in: AC_MSG_FAILURE is a new macro in 2.54b or later.
+
+Thu Jan 9 17:05:24 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (RUBY_CHECK_IO_NEED): check whether fseek() and
+ fflush() are needed.
+
+ * io.c (flush_before_seek): flush write stream only.
+
+ * io.c (rb_io_check_readable): seek instead of flush if the last
+ operation was write.
+
+ * io.c (rb_io_check_writable): seek instead of flush if the last
+ operation was read.
+
+ * bcc32/Makefile.sub, win32/Makefile.sub: needs to seek between
+ R/W.
+
+Thu Jan 9 16:31:51 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should not discard nested NODE_BLOCK.
+
+Thu Jan 9 15:12:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (stmt): NODE_NOT elimination for if/unless/while/until node.
+
+ * parse.y (primary): ditto.
+
+Thu Jan 9 13:26:18 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * st.h, st.c: Back out the introduction of st_*_func_t. Some
+ compilers complain about function type mismatch.
+
+Thu Jan 9 02:10:44 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): reduce recursive rb_eval() call by using sort
+ of continuation passing style.
+
+Wed Jan 8 17:10:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/Win32API/lib/win32/registry.rb: added. [new]
+
+Wed Jan 8 15:54:05 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c: remove ruby_last_node and assignments seems to be
+ unnecessary
+
+ * intern.h: debug does not run if ID_ALLOCATOR is zero.
+
+Wed Jan 8 15:04:11 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_each): treat fixnums specially to boost.
+
+ * numeric.c (num_step): remove rb_scan_args() for small speedup.
+
+Tue Jan 7 17:56:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (svalue_to_avalue): should return converted array.
+
+Tue Jan 7 07:48:01 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_f_local_variables): skip $_, $~ and flip states in
+ dynamic variables. [ruby-core:00681]
+
+Tue Jan 7 02:46:29 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (env_clear): new Hash compatible method.
+
+ * hash.c (env_shift, env_invert, env_replace, env_update): ditto.
+
+Mon Jan 6 23:36:29 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * st.h, st.c: Introduce new conventional typedef's, st_data_t,
+ st_compare_func_t, st_hash_func_t and st_each_func_t.
+
+ * st.h, st.c: Do explicit function declarations and do not rely on
+ implicit declarations.
+
+ * class.c, eval.c, gc.c, hash.c, marshal.c, parse.y, variable.c:
+ Add proper casts to avoid warnings.
+
+Mon Jan 6 20:44:43 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * intern.h (rb_check_array_type): Declare rb_check_array_type().
+
+ * ext/digest/md5/md5ossl.c: Include stdio.h for sprintf() and
+ string.h for memcmp().
+
+ * ext/dl/ptr.c: Include ctype.h for isdigit().
+
+Mon Jan 6 18:43:17 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * file.c: improve DOSISH drive letter support.
+
+Mon Jan 6 18:31:45 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/fileutils.rb (ln): add ' -f' in the verbose message.
+
+ * lib/fileutils.rb (cp_r): add 'p' in the verbose message.
+
+Mon Jan 6 16:44:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_join): dispatch based on "to_str".
+
+ * array.c (rb_ary_times, rb_ary_equal): ditto.
+
+Mon Jan 6 13:26:35 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * process.c (proc_exec_v): follow to proc_spawn_v(). call do_aspawn()
+ on Win32.
+
+ * process.c (rb_proc_exec): call do_spawn() on Win32.
+
+ * win32/win32.c, win32/win32.h (do_spawn, do_aspawn): add mode flag.
+
+ * process.c (proc_spawn_v, rb_f_system): follow above change.
+
+Mon Jan 6 05:11:15 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/extmk.rb: make $0 normal variable.
+
+Mon Jan 6 02:32:46 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * struct.c (make_struct): needs meta class.
+
+Sun Jan 5 22:54:05 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/fileutils.rb (ln): `argv' is not a argument.
+
+Sun Jan 5 17:44:37 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/extmk.rb (extmake): set $0 temporarily while loading
+ extconf.rb.
+
+Sun Jan 5 14:46:46 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * instruby.rb: need paren in regexp(make -n install).
+
+ * ext/extmk.rb (sysquote): do not need to quote on mswin/bccwin/mingw.
+
+ * ext/extmk.rb ($mflags): uniq items and remove '-' and '--'.
+ move options to the lead.
+
+ * lib/fileutils.rb (install): model on the real install
+ command(message).
+
+Sun Jan 5 09:36:46 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ruby.c (ruby_init_loadpath): under Windows, get the module
+ path from an internal address instead of hard coded library
+ name.
+
+ * cygwin/GNUmakefile.in, bcc32/Makefile.sub,
+ win32/Makefile.sub (CPPFLAGS): removed LIBRUBY_SO macro.
+
+ * bcc32/Makefile.sub, win32/Makefile.sub (config.h): no longer
+ depends on makefiles.
+
+Sun Jan 5 04:17:05 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * gc.c (SET_STACK_END): Issue a FLUSH_REGISTER_WINDOWS here too.
+ This fixes make test on FreeBSD/sparc64.
+
+Sun Jan 5 03:43:47 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * defines.h (FLUSH_REGISTER_WINDOWS): Make the flushw call an
+ inline function so it can be used as an expression.
+
+ * eval.c (EXEC_TAG, THREAD_SAVE_CONTEXT): Consistently call
+ FLUSH_REGISTER_WINDOWS before calling setjmp(). (I suspect that
+ every setjmp() implementation should take care of register
+ windows, though)
+
+Sun Jan 5 03:12:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * file.c (utimbuf): use utimbuf instead of _utimbuf if defined _WIN32.
+
+ * win32/Makefile.sub (LIBS): use oldnames.lib.
+
+ * win32/win32.c (rb_w32_getcwd): follow above change.
+
+ * win32/win32.h: ditto.
+
+ * wince/direct.c, wince/direct.h (getcwd): ditto.
+
+ * wince/io.h: ditto.
+
+ * wince/string.c, wince/wince.h (stricmp, strnicmp): ditto.
+
+Sat Jan 4 15:18:50 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * process.c (rb_proc_exec): use same logic as DJGPP on win32 ports.
+
+ * process.c (rb_f_system): ditto.
+
+ * win32/win32.c, win32/win32.h (do_aspawn): [new]. for arrayed
+ arguments.
+
+ * win32/win32.c (CreateChild): add new argument for real filename of
+ executing process.
+
+ * win32/win32.c (NtHasRedirection, pipe_exec): follow above change.
+
+Sat Jan 4 14:29:52 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * configure.in: set rb_cv_need_io_flush_between_seek=yes.
+
+ * win32/Makefile.sub (config.h): define NEED_IO_FLUSH_BETWEE_SEEK.
+ (pointed out by moriq [ruby-dev:19299])
+
+Sat Jan 4 03:12:14 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (umethod_bind): exact class match is not required. relax
+ the restriction to subclasses.
+
+Sat Jan 4 01:33:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (rb_file_s_lchmod): get rid of gcc-3 -O3 warning.
+
+Fri Jan 3 22:26:07 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * process.c (rb_proc_times): need to initialize first.
+
+Fri Jan 3 01:10:17 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): call "inherited" before executing class body.
+
+ * class.c (rb_define_class): call "inherited" after defining the
+ constant.
+
+ * class.c (rb_define_class_under): ditto.
+
+Thu Jan 2 19:37:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (massign): expand first element if RHS is an array and
+ its size is 1, and LHS has concrete assignment target (i.e. LHS
+ has target(s) other than *var).
+
+ * eval.c (massign): avoid unnecessary avalue/svalue conversion.
+
+ * eval.c (rb_yield_0): ditto
+
+ * array.c (rb_ary_update): do not allocate unused array if rpl is
+ nil (i.e. merely removing elements).
+
+Thu Jan 2 13:55:08 2003 Mathieu Bouchard <matju@sympatico.ca>
+
+ * io.c (io_read): should resize supplied string if it's shorter
+ than expected.
+
+Thu Jan 2 11:01:20 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (bmcall): arguments should be an array.
+
+Wed Jan 1 18:18:45 2003 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: better DJGPP support. add GNUmakefile.
+
+ * djgpp/GNUmakefile: new.
+
+Wed Jan 1 04:16:18 2003 Akinori MUSHA <knu@iDaemons.org>
+
+ * node.h (struct RNode): Change argc from int to long. Otherwise
+ NEW_CFUNC() sets argc to a wrong value on platforms where
+ sizeof(int) != sizeof(long) and the byte order is big-endian.
+ This fixes breakage on FreeBSD/sparc64.
+
+Tue Dec 31 23:22:50 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (massign): removed awkward conversion between yvalue,
+ mvalue, etc.
+
+ * eval.c (rb_yield_0): new parameter added to tell whether val is
+ an array value or not.
+
+ * parse.y (yield_args): restructuring: new nodes: NODE_RESTARY2,
+ NODE_SVALUE; removed node: NODE_RESTARGS.
+
+Tue Dec 31 21:13:51 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * Makefile.in, {win32,bcc32}/Makefile.sub: add new target:
+ what-where, no-install.
+
+ * mkconfig.rb: add const: CROSS_COMPILING.
+
+ * ext/extmk.rb: no-install support. add MAKEDIRS macro.
+
+ * lib/mkmf.rb: add !ifdef .. !endif for Borland make.
+
+ * process.c: improve DJGPP support. system "ls", "-l".
+
+Tue Dec 31 20:16:37 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/socket/addrinfo.h (NI_MAXHOST): Define NI_MAXHOST and
+ NI_MAXSERV only if they are not defined yet. This fixes build
+ on such platforms as OpenBSD.
+
+Tue Dec 31 20:07:49 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/tcltklib/extconf.rb (find_tcl, find_tk): Look for both
+ lib{tcl,tk}M.N and lib{tcl,tk}MN on all platforms. *BSD have
+ Tcl/Tk libraries named this way.
+
+Tue Dec 31 19:48:21 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * configure.in: Improve OpenBSD support. [obtained from: OpenBSD
+ ports]
+
+ * dln.c (FUNCNAME_PATTERN): Ditto.
+
+Tue Dec 31 19:21:02 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * array.c (rb_ary_transpose): Properly declare ary as a VALUE.
+
+ * file.c (rb_file_s_chmod): Do not directly cast an int to void *
+ to avoid a warning.
+
+ * defines.h (FLUSH_REGISTER_WINDOWS): Add support for
+ FreeBSD/sparc64. miniruby still coredumps in a different place,
+ though.
+
+Tue Dec 31 07:47:15 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (parse_string): readjusted.
+
+ * parse.y (heredoc_identifier): readjusted.
+
+ * parse.y (here_document): make EOL codes of single-quoted
+ here-documents consistent.
+
+ * parse.y (yylex): reduced unnecessary conditionals.
+
+Tue Dec 31 04:49:51 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ruby.1: mdoc'ify.
+
+Tue Dec 31 01:30:29 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * parse.y (yylex): do not accept " __END__\n". ([ruby-dev:19245])
+
+Mon Dec 30 21:10:59 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * parse.y (yylex): use strncmp instead of strcmp.
+ accept "__END__\r\n". ([ruby-dev:19241])
+
+Mon Dec 30 20:32:14 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc_mark_frame): should mark frame->node.
+
+Mon Dec 30 19:10:30 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/extmk.rb: split --make argument contains options, assume
+ the first word of --make-flags is always options even unless
+ preceded by -, and ignore letter-case of options if nmake.
+
+ * instruby.rb: extract -n option also from --make and
+ --make-flags.
+
+ * bcc32/Makefile.sub, win32/Makefile.sub: not prepend - to
+ $(MFLAGS)
+
+Mon Dec 30 16:44:14 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * string.c (rb_str_substr): should share the shared string if
+ present, instead of the original string. (ruby-bugs:PR#528)
+
+Mon Dec 30 05:10:00 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/socket/socket.c (tcp_svr_init): local host to
+ init_inetsock() is VALUE but not pointer.
+
+ * ext/socket/socket.c (sock_s_unpack_sockaddr_in): get rid of
+ gcc-3 -O3 warning.
+
+Sun Dec 29 23:45:53 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * gc.c (gc_sweep): adjust GC trigger.
+
+ * dln.c (init_funcname_len): get rid of gcc-3 -O3 warning.
+
+ * eval.c (copy_node_scope): ditto.
+
+ * hash.c (rb_hash_foreach, delete_if_i, select_i, each_value_i,
+ each_key_i, each_pair_i, envix): ditto.
+
+ * range.c (range_each_func): ditto.
+
+ * file.c (rb_file_s_chmod): ditto.
+
+Sun Dec 29 15:30:37 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb (fu_parseargs): should not inherit ftools.rb's
+ misfeature.
+
+Sun Dec 29 05:08:13 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/fileutils.rb (cmp): return false if file size differs.
+
+Sat Dec 28 19:21:24 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * instruby.rb: remove junk args.
+
+ * lib/mkmf.rb (create_makefile): remove a trouble library
+ before making a shared library.
+
+ * win32/Makefile.sub: invoke instruby.rb with the --make-flags option.
+
+Sat Dec 28 03:09:58 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/cgi.rb (CGI#[]): improvement. thanks to Kazuhiro NISHIYAMA
+ <zn@mbf.nifty.com>
+
+Sat Dec 28 00:34:03 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * {win32,bcc32}/Makefile.sub: remove `=' from --make-flags options.
+ nmake quotes args if included `=' in args.
+
+ * instruby.rb: use getopts.rb.
+
+ * ext/dbm/extconf.rb (-DDBM_HDR): substitute ' with " to avoid
+ a error on Win32.
+
+ * ext/gdbm/gdbm.c: add prototypes to avoid VC++ warnings.
+
+Fri Dec 27 21:41:57 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bcc32/setup.mak, win32/setup.mak(-prologue-): move srcdir from
+ CPP input or UNC path will be removed as a comment.
+
+Fri Dec 27 17:55:00 2002 Takaaki Uematsu <mail@uema2.cjb.net>
+
+ * wince/config, wince/configure.bat: replace 1.7 with 1.8
+ in macros.
+
+Fri Dec 27 13:28:14 2002 Minero Aoki <aamine@loveruby.net>
+
+ * instruby.rb: fileutils.rb accepts only one argument.
+
+Fri Dec 27 13:23:29 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb (fu_parseargs): reject illegal options
+ correctly.
+
+ * lib/fileutils.rb (uptodate?): parameter declaration was wrong.
+
+ * lib/fileutils.rb: change coding styles.
+
+Fri Dec 27 09:25:22 2002 ABE Shigeru <shiger-a@nifty.com>
+
+ * process.c (rb_proc_times): avoid WindowsXP crash using volatile
+ variables.
+
+Fri Dec 27 02:56:58 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * instruby.rb: check only `-' option, and use fileutils instead of
+ ftools.
+
+Fri Dec 27 02:45:17 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/net/telnet.rb: Telnet#print not add "\n".
+
+ * lib/cgi.rb: cgi['key'] is equal cgi['key'][0]
+
+Thu Dec 26 22:33:18 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb (create_makefile): check only `-' option.
+
+ * configure.in: cleanups for MinGW. remove -D__NO_ISOCEXT in $CFLAGS.
+
+ * win32/win32.h: prototypes for isinf, isnan are not needed on MinGW.
+
+Thu Dec 26 19:22:00 2002 YOSHIDA Kazuhiro <moriq@moriq.com>
+
+ * win32/setup.mak (-prologue-): moved srcdir macro definition.
+ [ruby-win32:420].
+
+Wed Dec 25 18:26:44 2002 K.Kosako <kosako@sofnec.co.jp>
+
+ * regex.c (re_match): fixed wrong \G behavior. (ruby-bugs-ja:PR#377)
+
+Wed Dec 25 16:41:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_match_exec): fix odd \G behavior based on the patch
+ from Nobu.
+
+Wed Dec 25 11:05:11 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bcc32/setup.mak (-generic-): removed garbages.
+
+Wed Dec 25 10:36:20 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * bcc32/Makefile.sub, win32/Makefile.sub (RUBY_SO_NAME, config.h):
+ use $(MAJOR) and $(MINOR). based on Nobu's patch. [ruby-win32:413]
+
+ * bcc32/setup.mak, win32/setup.mak (-prologue-): define MAJOR, MINOR
+ and TEENY from version.h. based on Nobu's patch. [ruby-win32:413]
+
+ * win32/Makefile.sub (config.h): add HAVE_FLOAT_H.
+
+ * win32/Makefile.sub (parse.obj): depend on win32/win32.h.
+
+Tue Dec 24 23:49:16 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/irb/completion.rb: Use Object#class rather than Object#type.
+
+Tue Dec 24 23:37:40 2002 TADA Tadashi <sho@spc.gr.jp>
+
+ * lib/cgi.rb (Cookie::parse), lib/cgi-lib.rb (initialize): Do not
+ pass to split() a bare string longer than 2 characters as
+ separator.
+
+Tue Dec 24 19:19:24 2002 Tietew <tietew@tietew.net>
+
+ * numeric.c (DBL_MAX_10_EXP): fix typo. [ruby-dev:19175]
+
+Tue Dec 24 17:02:46 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_undefined): use NoMethodError instead of fatal.
+
+Tue Dec 24 02:12:45 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/README: Synchronize with reality.
+
+Tue Dec 24 02:05:51 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * MANIFEST, lib/README, lib/ipaddr.rb: Add ipaddr.rb from rough.
+
+Sun Dec 22 04:07:47 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/dbm/dbm.c (fdbm_alloc): allocator takes only one argument.
+
+Sun Dec 22 02:49:25 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * array.c (ary_alloc), dir.c (dir_s_alloc), eval.c (thgroup_s_alloc),
+ file.c (rb_stat_s_alloc), hash.c (hash_alloc), io.c (io_alloc),
+ object.c (rb_module_s_alloc, rb_class_allocate_instance),
+ re.c (match_alloc, rb_reg_s_alloc), string.c (str_alloc),
+ time.c (time_s_alloc), ext/digest/digest.c (rb_digest_base_alloc),
+ ext/tcltklib/tcltklib.c (ip_alloc),
+ ext/win32ole/win32ole.c (fole_s_allocate, fev_s_allocate)
+ : add prototype to get rid of VC++ warnings.
+
+ * ext/sdbm/init.c (fsdbm_alloc): allocator takes only one argument.
+
+Sun Dec 22 00:36:43 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (create_makefile): accept pure ruby libraries.
+
+Sat Dec 21 23:59:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (ins_methods_i): should not show ID_ALLOCATOR.
+
+ * class.c (ins_methods_prot_i): ditto.
+
+ * class.c (ins_methods_priv_i): ditto.
+
+ * class.c (ins_methods_pub_i): ditto.
+
+ * eval.c (call_trace_func): ditto.
+
+ * eval.c (rb_undefined): ditto.
+
+Sat Dec 21 07:27:24 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-parse-partial): keywords must not be
+ preceded by @ or $.
+
+Fri Dec 20 20:29:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
+ ext/dl/handle.c, ext/dl/ptr.c, ext/dl/sym.c, ext/gdbm/gdbm.c,
+ ext/iconv/iconv.c, ext/sdbm/init.c, ext/stringio/stringio.c,
+ ext/strscan/strscan.c, ext/tcltklib/tcltklib.c,
+ ext/win32ole/win32ole.c: use rb_define_alloc_func().
+
+Fri Dec 20 18:29:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (rb_io_fwrite): separated from io_write().
+
+ * marshal.c (w_byten): use rb_io_fwrite() to support non-blocking
+ IO, and added error check.
+
+ * rubyio.h: prototypes; rb_io_fwrite
+
+Fri Dec 20 17:40:59 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): should not remove Class#allocate.
+
+ * lib/profiler.rb: separate profiling functions, without
+ trace_func and at_exit setting.
+
+Fri Dec 20 16:20:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (do_block): split "do" block and tLBRACE_ARG block.
+
+ * parse.y (cmd_brace_block): new tLBRACE_ARG block rule
+
+ * parse.y (command): can take optional cmd_brace_block; use %prec
+ to resolve shift/reduce conflict. (ruby-bugs-ja PR#372)
+
+ * eval.c (ruby_finalize): trace_func should be cleared here (after
+ executing exit procs and finalizers).
+
+ * eval.c (rb_define_alloc_func): new allocation framework, based
+ on Nobu's work [ruby-dev:19116]. "allocate" method is no longer
+ used for object allocation.
+
+Fri Dec 20 05:06:49 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/README, lib/cgi/ftplib.rb, lib/telnet.rb: Delete ftplib.rb
+ and telnet.rb. It has been quite some time sinc they were
+ obsoleted and made to emit warnings.
+
+Fri Dec 20 04:58:22 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/tempfile.rb: Embed Rdoc style comments.
+
+ * lib/tempfile.rb: Add length as an alias for size.
+
+Fri Dec 20 03:57:32 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/tempfile.rb: Add Tempfile#close!() as a shorthand for
+ Tempfile#close(true).
+
+ * lib/tempfile.rb: Add Tempfile#{unlink,delete}().
+
+Fri Dec 20 03:53:01 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/README, lib/cgi/final.rb, lib/cgi/session.rb: Delete
+ final.rb, which was obsoleted long ago.
+
+Fri Dec 20 00:16:06 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * re.c (rb_reg_match_pre, rb_reg_match_post, match_to_a,
+ match_select): return instances of same class as the original
+ string. [ruby-dev:19119]
+
+Thu Dec 19 22:55:49 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * numeric.c (DBL_EPSILON): fix typo.
+
+Thu Dec 19 22:35:20 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (assign): avoid [BUG] at multiple attribute assignment.
+
+Thu Dec 19 01:00:09 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_step): use DBL_EPSILON.
+
+ * array.c (rb_check_array_type): new function: return an array
+ (convert if possible), or nil.
+
+ * string.c (rb_check_string_type): new function: return a string
+ (convert if possible), or nil.
+
+ * numeric.c (rb_dbl_cmp): returns nil if values are not
+ comparable.
+
+ * numeric.c (fix_cmp,flo_cmp): use rb_num_coerce_cmp()
+
+ * bignum.c (rb_big_cmp): ditto.
+
+ * numeric.c (rb_num_coerce_cmp): new coercing function for "<=>",
+ which does not raise TypeError.
+
+ * numeric.c (do_coerce): can be suppress exception now.
+
+ * object.c (rb_mod_cmp): should return nil for non class/module
+ objects.
+
+Thu Dec 19 04:21:10 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/open-uri.rb: add a missing ||. (found by: ruby -wc)
+
+Wed Dec 18 17:53:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_eqq): return false if the argument is not a
+ string. now returns boolean value.
+
+ * class.c (rb_include_module): argument should be T_MODULE, not
+ T_class, nor T_ICLASS.
+
+Wed Dec 18 03:52:55 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * string.c (rb_str_new4): handle tail shared string.
+ (ruby-bugs-ja:PR#370)
+
+ * string.c (rb_str_dup_frozen): ditto.
+
+Tue Dec 17 21:08:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * node.h (NODE_ATTRASGN): new node, assignment to attribute.
+ [ruby-core:00637].
+
+ * eval.c (is_defined, rb_eval): ditto.
+
+ * parse.y (attrset, node_assign): ditto.
+
+ * string.c (rb_str_substr): tail sharing. [ruby-core:00650]
+
+ * re.c (rb_reg_nth_match): ditto.
+
+Tue Dec 17 16:52:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (is_defined): "defined?" should return "assignment" for
+ attribute assignment (e.g. a.foo=b) and indexed assignment
+ (e.g. a[2] = 44).
+
+ * parse.y (aryset): use NODE_ATTRASGN.
+
+Tue Dec 17 04:03:45 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/open-uri.rb: new file.
+
+Tue Dec 17 00:28:19 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * file.c (utimbuf): need to define for VC++.
+
+Mon Dec 16 15:53:20 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (nextc): get rid of overrun. (pointed out by akr
+ [ruby-list:36773])
+
+Sun Dec 15 21:16:44 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (init_mkmf): add $(topdir) to $LIBPATH if $extmk.
+ remove adding $(archdir) to $LIBPATH.
+
+Sat Dec 15 12:15:00 2002 Takaaki Uematsu <mail@uema2.cjb.net>
+
+ * configure.in, defines.h, dir.c, dir.h, dln.c, error.c,
+ eval.c, file.c, hash.c, io.c, main.c, missing.c,
+ process.c, ruby.c, rubysig.h, signal.c, st.c, util.c, util.h,
+ bcc/Makefile.sub, win32/Makefile.sub, win32/win32.h,
+ ext/Win32API/Win32API.c, ext/socket/getaddrinfo.c,
+ ext/socket/getnameinfo.c, ext/socket/socket.c,
+ ext/tcltklib/stubs.c
+ : replace "NT" with "_WIN32", add DOSISH_DRIVE_LETTER
+ * wince/exe.mak : delete \r at the end of lines.
+ * wince/mswince-ruby17.def : delete rb_obj_become
+
+Sun Dec 15 11:43:26 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (dispose_string): dispose String object.
+
+ * parse.y (heredoc_restore, here_document): fix memory leak.
+
+Sat Dec 14 14:25:00 2002 Takaaki Uematsu <mail@uema2.cjb.net>
+
+ * wince/sys : add stat.c, stat.h, timeb.c, timeb.h,
+ types.h, utime.c, utime.h
+ * wince/dll.mak : object file name changed.
+ * wince/io.c : add empty dup2().
+ * wince/io.h : add dup2 definition.
+
+Sat Dec 14 01:51:29 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/dbm/extconf.rb (rb_check): support for GNU dbm 1.8.3.
+ (-with-dbm-type=gdbm_compat). link against -lgdbm_compat
+ and -lgdbm.
+
+Fri Dec 13 23:42:16 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/dbm/extconf.rb (db_check): check existence of the function
+ in the specified library before checking it in libc.
+
+Fri Dec 13 17:15:49 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (generic_ivar_get): should always warn uninitialized
+ instance variables.
+
+Fri Dec 13 12:33:22 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (expr): rescue clause was ignored.
+
+Thu Dec 12 18:19:14 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (RUBY_PROG_GNU_LD): add $CFLAGS, $CPPFLAGS, $LDFLAGS
+ to the option of $CC.
+
+ * configure.in: set LIBRUBYARG to '-l$(RUBY_SO_NAME)' if the
+ target os is cygwin and --disable-shared option is supplied.
+
+ * lib/mkmf.rb (init_mkmf): expand config["LIBRUBY"] and
+ config["LIBRUBY_A"]. don't link $LIBRUBYARG_STATIC if
+ --disable-shared option is supplied.
+
+ * configure.in (RUBY_CPPOUTFILE): should be a better message.
+
+ * ext/Win32API/extconf.rb: join with a space.
+
+Thu Dec 12 17:27:19 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_hash): define Regexp#hash to make regexps to be
+ hash keys.
+
+ * re.c (Init_Regexp): define Regexp#eql? (alias to Regexp#==).
+
+Thu Dec 12 16:26:31 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c (r_object0): singleton class instance can't be loaded.
+ (ruby-bugs-ja:PR#366)
+
+Wed Dec 11 23:35:43 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb (create_makefile): -no-undefined -> --no-undefined.
+
+Wed Dec 11 17:54:59 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_read): takes optional second argument to specify a
+ string to be written. the string should not be frozen.
+
+ * io.c (rb_io_sysread): ditto.
+
+Wed Dec 11 11:30:28 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/digest/digest.c (rb_digest_base_copy): renamed "become".
+
+ * ext/stringio/stringio.c (strio_copy): ditto.
+
+Wed Dec 11 00:45:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/getoptlong.rb (GetoptLong::Error): provide a common ancestor
+ for GetoptLong error classes (RCR#129).
+
+Tue Dec 10 17:42:39 2002 K.Kosako <kosako@sofnec.co.jp>
+
+ * re.c (rb_reg_copy_object): fixed memory leak.
+
+Tue Dec 10 17:30:35 2002 Tanaka Akira <akr@m17n.org>
+
+ * pack.c (utf8_limits): fix the limit of 4 bytes UTF-8 sequence.
+
+Tue Dec 10 12:01:15 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (mnew): original class of method defined in module should
+ be the module not intermediate class. [ruby-dev:19040]
+
+Tue Dec 10 01:16:52 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sprintf.c (rb_f_sprintf): preceding ".." for negative numbers
+ still left; removed.
+
+ * sprintf.c (rb_f_sprintf): should not prepend '0' if width > prec
+ for example "%5.3d".
+
+Sat Dec 7 18:14:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (Init_process): add Process.exit and Process.abort
+
+ * pack.c (utf8_to_uv): raise ArgumentError for malformed/redundant
+ UTF-8 sequences.
+
+Fri Dec 6 03:46:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (last_status_set): add pid attribute to Process::Status.
+
+Wed Dec 4 17:31:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (uv_to_utf8): limit maximum length of the encoded string
+ to 6 bytes, even when the platform supports 8 bytes long integers.
+
+ * pack.c (utf8_to_uv): do not decode sequences longer than 6 bytes.
+
+ * object.c (copy_object): use "copy_object" method, not "become".
+
+Wed Dec 4 16:37:11 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (copy_object): copy finalizers as well if any.
+
+ * gc.c (rb_gc_copy_finalizer): new function to copy finalizers.
+
+Tue Dec 3 01:13:41 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb (PP.singleline_pp): new method.
+
+Sun Dec 1 23:04:03 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb (OptionParser::new): same as OptionParser#on but
+ returns new OptionParser::switch.
+
+Sun Dec 1 22:43:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (rb_w32_stat): empty path is invalid, and return
+ ENOENT rather than EBADF in such case. [ruby-talk:57177]
+
+Fri Nov 29 18:01:48 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (utf8_to_uv): added checks for malformed or redundant
+ UTF-8 sequences.
+
+Thu Nov 28 12:08:30 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/mkmf.rb: Avoid the use of "clean::" in favor of "clean:" in
+ order not to let make(1) choke if there is another dependency on
+ the target added in a depend file.
+
+Thu Nov 28 02:40:42 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/mkmf.rb: Make sure to dig the destination directory before
+ installing a file there. Formerly "make install" could fail
+ depending on make(1)'s mood of the moment, especially when -jN
+ is given.
+
+Wed Nov 27 17:39:38 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/syslog/syslog.c: Cut redundancy.
+
+ * ext/syslog/syslog.c: Do not leak ident.
+
+Wed Nov 27 17:25:29 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/syslog/syslog.c, ext/syslog/test.rb: Syslog.close should
+ raise RuntimeError when not opened.
+
+ * ext/syslog/syslog.c, ext/syslog/test.rb:
+ Syslog.{ident,options,facility,mask} should all return nil when
+ not opened.
+
+ * ext/syslog/syslog.c, ext/syslog/test.rb: Change back the output
+ format of inspect().
+
+Wed Nov 27 16:25:43 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/test.rb: Switch from RUnit to Test::Unit.
+
+Wed Nov 27 16:14:12 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/syslog/syslog.c: Fix a problem where Syslog.ident was not
+ marked and could thus be GC'd.
+
+Wed Nov 27 16:11:53 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/syslog/test.rb: Switch from RUnit to Test::Unit.
+
+ * ext/syslog/test.rb: The output format of inspect() is slightly
+ altered.
+
+Wed Nov 27 06:43:26 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * error.c (exit_initialize): add SystemExit#initialize to set
+ instance variable status. (ruby-bugs-ja:PR#362)
+ Now accepts status as optional first argument.
+
+ * eval.c (error_handle): now SystemExit have status always.
+
+ * eval.c (system_exit): just instantiate SystemExit without raise.
+
+ * eval.c (rb_thread_start_0): initialize SystemExit properly.
+
+Tue Nov 26 10:17:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dln.c (init_funcname_len): remove MAXPATHLEN dependency.
+
+Mon Nov 25 19:55:38 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb (extmake): return true if not dynamic and not static.
+
+Mon Nov 25 01:08:40 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dln.c: revert and add the MAXPATHLEN definition on mswin32/mingw32.
+
+Sun Nov 24 20:36:53 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dln.c: move the MAXPATHLEN definition in front.
+
+Fri Nov 22 22:55:01 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sprintf.c (rb_f_sprintf): preceding ".." for negative
+ hexadecimal numbers should not appear if prec (e.g. %.4) is
+ specified.
+
+ * pack.c (NUM2I32): support platforms which does not have 32bit
+ integers (e.g. Cray).
+
+Fri Nov 22 19:20:36 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * instruby.rb: Install batch files on Windows. [Submitted by usa]
+
+Fri Nov 22 18:31:46 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_add_method): node may be NULL.
+
+Thu Nov 21 20:53:06 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: changes coding style.
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/protocol.rb: ditto.
+
+Thu Nov 21 20:17:08 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: changes coding style.
+
+Thu Nov 21 20:04:06 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: should not overwrite Host: header.
+ (This patch is contributed by sean@ruby-lang.org)
+
+Thu Nov 21 20:01:33 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: support Proxy-Authorization.
+ (This patch is contributed by Alexander Bokovoy)
+
+Thu Nov 21 11:03:39 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_find_file_ext): should not terminate searching with
+ empty path, just ignore.
+
+ * dir.c: remove <sys/parm.h> inclusion.
+
+Wed Nov 20 02:07:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * compar.c (cmp_eq,cmp_gt,cmp_ge,cmp_lt,cmp_le): check using
+ rb_cmpint().
+
+ * error.c (init_syserr): remove sys_nerr dependency.
+
+Wed Nov 20 01:52:21 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_cmp): added to satisfy Comparable assumption.
+
+ * eval.c (rb_add_method): "initialize" should be public if it is a
+ singleton method.
+
+Tue Nov 19 22:37:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_match): avoid dereferencing if size == 0.
+ (ruby-bugs-ja:PR#360)
+
+Tue Nov 19 20:40:39 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_cmp): should return nil if an operand is not a
+ number nor time. (ruby-bugs-ja:PR#359)
+
+ * file.c (rb_stat_cmp): should return nil if an operand is not
+ File::Stat.
+
+Tue Nov 19 14:35:09 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_zip): iterates over items in the receiver.
+ zipped with nil if argument arrays are shorter. if arrays are
+ longer, left items are ignored. now works with blocks.
+
+ * enum.c (zip_i): changed for new behavior.
+
+ * array.c (rb_ary_transpose): added. [new]
+
+Tue Nov 19 05:12:21 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * instruby.rb: Do not install various working files under bin/.
+
+Tue Nov 19 05:07:39 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * instruby.rb: not rewrite installed scripts when dry-run mode.
+
+ * lib/ostruct.rb (OpenStruct::initialize): should symbolize keys
+ instead of values.
+
+Tue Nov 19 02:24:10 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * instruby.rb: Rewrite installed scripts' shebang lines.
+
+ * instruby.rb: Use File.join() where appropriate.
+
+Tue Nov 19 01:53:35 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * bin/irb: Moved from sample/irb.rb.
+
+ * instruby.rb: Install script files under bin/ with ruby's program
+ prefix and suffix.
+
+Mon Nov 18 02:13:36 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/tempfile.rb: Make this library thread safe.
+
+ * lib/tempfile.rb: Do not pick a name which was once used and is
+ still scheduled for removal.
+
+ * lib/tempfile.rb: A lock file need not and must not be scheduled
+ for removal.
+
+ * lib/tempfile.rb: Compare Max_try with the number of mkdir
+ failures instead of the suffix counter.
+
+ * lib/tempfile.rb: Overall cleanup and add some important notices.
+
+Sun Nov 17 22:57:31 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (dsym): garbage returned. (ruby-bugs-ja:PR#358)
+
+Fri Nov 15 07:40:08 2002 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * observer.rb: raise NoMethodError instead of NameError.
+ [ruby-dev:18788]
+
+ * ostruct.rb: ditto. fix a bug in inspect which called String#+ with
+ Symbol. [ruby-dev:18788]
+
+ * profile.rb: illegal use of Array#sort!. replaced it with non-bang
+ method. [ruby-dev:18792]
+
+Thu Nov 14 22:40:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (LIBRUBY_A): append -static. [ruby-dev:18689]
+
+ * configure.in (LIBRUBYARG_STATIC, LIBRUBYARG_SHARED): linker
+ argument to link static/shared library respectively.
+
+ * Makefile.in (LIBRUBYARG_STATIC, LIBRUBYARG_SHARED): added.
+
+ * bcc32/Makefile.sub, win32/Makefile.sub: ditto.
+
+ * instruby.rb (LIBRUBY_A): install to libdir.
+
+ * lib/mkmf.rb (link_command): link static library of ruby, or
+ try_run fails unless LIBRUBY_SO is installed. [ruby-dev:18646]
+
+ * eval.c (call_trace_func): toplevel caller was missing.
+ [ruby-dev:18754]
+
+ * eval.c (proc_to_s): adjust created line number.
+
+ * parse.y (primary, do_block, brace_block): adjust line number of
+ block to beginning line, instead of the first statement inside
+ the block.
+
+Thu Nov 14 08:23:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * math.c (math_acos): check errno after operation. ditto for
+ asin, acosh, atanh, log, log10 and sqrt.
+
+ * eval.c (rb_add_method): initialize should always be private.
+
+ * parse.y (expr): add rescue modifier rule.
+
+ * parse.y (command_call): return, break and next with argument is
+ now part of this rule.
+
+Wed Nov 13 16:22:38 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (DLDFLAGS): removed -Wl,-no-undefined to
+ ext/extmk.rb, in order to allow references to symbols in other
+ extension libraries for mkmf.rb. [ruby-dev:18724]
+
+ * ext/extmk.rb (extmake): ditto.
+
+ * ext/extmk.rb (extmake): exit when make failed.
+
+Sun Nov 10 03:46:18 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: retire contain?() and add superset?(),
+ proper_superset?() subset?(), and proper_subset?().
+ [obtained from: Jason Voegele's set.rb]
+
+ * lib/set.rb: define several aliases: union() for |(),
+ difference() for -(), and intersection() for &().
+ [obtained from: Jason Voegele's set.rb]
+
+ * lib/set.rb: deal with a s/id/object_id/ leftover.
+
+Sat Nov 9 16:06:57 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/tcltklib/stubs.c: should include "util.h" for ruby_strdup.
+
+Sat Nov 9 11:39:45 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c: remove ENABLE_TRACE/DISABLE_TRACE to trace child nodes of
+ c-call. [ruby-dev:18699]
+
+Fri Nov 8 04:16:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): "a" in "a /5" should be considered as a local
+ variable. [experimental]
+
+Thu Nov 7 09:51:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_yield_0): should enable trace for non-cfunc nodes.
+ [ruby-dev:18645]
+
+ * eval.c (blk_orphan): a block created in a different thread is
+ orphan. [ruby-dev:17471]
+
+Wed Nov 6 16:57:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_define_method): do not set NOEX_CFUNC if klass is
+ really a module, whose methods must be safe for reciever's type.
+
+ * eval.c (rb_eval): nosuper should not be inherited unless the
+ overwritten method is an undef placeholder.
+
+Tue Nov 5 00:46:04 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb: Properly pass the given target to
+ make(1). [pointed out by eban]
+
+Mon Nov 4 20:03:53 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * instruby.rb, lib/mkmf.rb: use CONFIG["ENABLE_SHARED"] instead of
+ checking whether CONFIG["configure-args"] includes "--enable-shared".
+
+Mon Nov 4 16:49:14 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (primary): allow 'when'-less case statement; persuaded
+ by Sean Chittenden.
+
+Mon Nov 4 06:28:09 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * Makefile.in, ext/extmk.rb, bcc32/Makefile.sub,
+ win32/Makefile.sub: Introduce better command line syntax
+ (--make/--make-flags/--extstatic) to extmk.rb and instruby.rb.
+ Previously such command as 'make -j3 install' with pmake doesn't
+ fail. Formerly extmk.rb was receiving "make -j 3 -j 3" via the
+ command line arguments and just ended up recognizing the first
+ "3" as destdir. [with help of usa]
+
+Mon Nov 4 03:59:51 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/getopts.rb: Do not choke on characters that cannot be used
+ in a variable name. Replace them with `_'. Define a hash named
+ $OPT for convenience.
+
+Sat Nov 2 00:38:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): added Object#object_id, new name for
+ Object#id. [new]
+
+ * object.c (rb_obj_id_obsolete): give warning for Object#id.
+
+ * numeric.c (fix_intern): added Fixnum#to_sym. [new]
+
+ * object.c (sym_to_sym): rename from Symbol#intern
+
+Fri Nov 1 14:21:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_zip): added Enumerable#zip. [new]
+
+ * array.c (rb_ary_zip): added Array#zip.
+
+Thu Oct 31 20:10:18 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (init_syserr): remove sys_nerr dependency.
+
+Thu Oct 31 09:31:51 2002 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (rb_export_method): undef'ed method visibility should not
+ be changed.
+
+Wed Oct 30 17:00:47 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_public_method_defined, etc.): new methods:
+ public_method_defined?, private_method_defined?,
+ protected_method_defined?
+
+ * object.c (rb_obj_public_methods): new method
+ Object#public_methods.
+
+ * class.c (ins_methods_i): Object#methods should list both public
+ and protected methods.
+
+ * class.c (rb_class_public_instance_methods): new method
+ Module#public_instance_methods.
+
+Wed Oct 30 06:29:00 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * eval.c, file.c, gc.c, io.c, object.c, ruby.c, ruby.h, struct.c,
+ ext/socket/socket.c: differentiate long and int; use proper
+ printf type specifiers and do casts where appropriate.
+
+Wed Oct 30 04:07:33 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (error_print, rb_longjmp, rb_thread_schedule): flush
+ error message. [ruby-dev:18582]
+
+ * eval.c (ruby_cleanup): added. just clean up without exit.
+ [ruby-dev:18582]
+
+ * eval.c (ruby_exec): added. execute main evaluation tree without
+ exit. [ruby-dev:18582]
+
+ * intern.h: prototypes; ruby_cleanup, ruby_exec
+
+Tue Oct 29 02:00:08 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/extmk.rb (extmake): use dummy_makefile to create dummy
+ Makefile.
+
+ * lib/mkmf.rb (find_executable0): EXEEXT is optional.
+
+ * lib/mkmf.rb (dummy_makefile): make dummy Makefile content.
+
+ * lib/mkmf.rb (create_makefile): define EXTLIB replacing -l.
+
+ * lib/mkmf.rb ($bccwin): detect Borland make by help message.
+
+ * lib/mkmf.rb (CLEANINGS): common rules to clean.
+
+Mon Oct 28 01:27:17 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * djgpp/config.sed (@program_transform_name@): use `%', not `,'.
+
+Sun Oct 27 22:59:50 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * ext/extmk.rb(78) : The unnecessary error when installing by bccwin32
+ is controlled.
+
+ * lib/mkmf.rb(773) : Also in the case of bccwin32, the path was added.
+
+Sun Oct 27 17:07:25 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * djgpp/*: sync with the latest.
+
+ * ext/extmk.rb, lib/mkmf.rb: flush $stdout.
+
+ * io.c (READ_DATA_PENDING_COUNT, READ_DATA_PENDING_PTR):
+ undef these macros on DJGPP.
+
+Sat Oct 26 10:11:47 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * node.h (nd_type): cast the value to int.
+
+Sat Oct 26 04:27:35 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/dbm/dbm.c (fdbm_indexes, fdbm_select): add a missing
+ argument and prevent coredump when a nonexistent key is
+ specified.
+
+ * ext/sdbm/init.c (fsdbm_indexes, fsdbm_select): ditto.
+
+Sat Oct 26 03:28:43 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * eval.c, gc.c: use a common set of alloca() #ifdef's. This fixes
+ the build with Intel C Compiler for Linux.
+
+ * eval.c (rb_f_require): declare old_func with a real type, not
+ just type modifiers.
+
+Fri Oct 25 02:55:01 2002 Minero Aoki <aamine@loveruby.net>
+
+ * string.c (rb_str_split_m): RSTRING(str)->ptr might become NULL.
+ [ruby-dev:18581]
+
+Thu Oct 24 21:57:02 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (LIBPATHFLAG): avoid $ substitution.
+ [ruby-dev:18577]
+
+ * ext/extmk.rb (extmake): expand $srcdir.
+
+ * ext/win32ole/extconf.rb: should not override $CFLAGS, but
+ append.
+
+ * lib/mkmf.rb (config_string): use given config hash.
+
+ * bcc32/Makefile.sub (.rc.res): directory part may be empty in
+ Borland make.
+
+Thu Oct 24 03:38:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb (create_makefile): site-install target for backward
+ compatibility.
+
+ * lib/mkmf.rb (init_mkmf): libdir prior to topdir.
+
+ * configure.in (LIBPATHFLAG): should escape $. [ruby-dev:18572]
+
+ * mkconfig.rb: never substitute escaped $$.
+
+ * instruby.rb: not install LIBRUBY_SO unless enable-shared.
+ [ruby-dev:18569]
+
+Wed Oct 23 19:16:06 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): added NODE_DSYM, symbol literal with
+ interpolation.
+
+ * node.h: ditto.
+
+ * intern.h: prototypes; rb_is_junk_id, rb_str_dump, rb_str_intern
+
+ * object.c (sym_inspect): escape and quote for non-alphanumeric
+ symbols.
+
+ * parse.y (dsym, tokadd_string, yylex): extended symbol literals.
+
+ * parse.y (rb_is_junk_id): added.
+
+ * string.c (rb_str_dump, rb_str_intern) : make extern.
+
+ * lib/mkmf.rb (create_makefile): deffile should be removed by
+ distclean, not clean.
+
+Tue Oct 22 23:56:41 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (init_mkmf): add dir_config("opt").
+
+Tue Oct 22 19:44:03 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * bcc32/configure.bat : The command line when calling setup.mak is
+ corrected.
+
+ * bcc32/readme.bcc32 : It follows up about the option of configure.bat.
+
+Tue Oct 22 15:23:19 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * instruby.rb: add dryrun mode.
+
+ * ext/extmk.rb (extmake): add install: target to dummy Makefile.
+
+ * ext/extmk.rb (extmake): avoid Borland make's quirk behavior.
+
+ * lib/mkmf.rb (link_command): opt is not a makefile macro.
+
+ * bcc32/Makefile.sub ($(LIBRUBY_SO) $(LIBRUBY)): EXTOBJS were not
+ linked.
+
+ * bcc32/Makefile.sub (ext/extinit.obj): missing.
+
+ * bcc32/Makefile.sub (TRY_LINK): options have to place before any
+ non-option arguments.
+
+ * win32/Makefile.sub (TRY_LINK): need -link and -libpath options.
+
+ * bcc32/Makefile.sub, win32/Makefile.sub (RANLIB): logical
+ operator never work with command.com.
+
+Tue Oct 22 00:59:59 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (RUBY_CPPOUTFILE): fix cache file bug.
+
+ * lib/mkmf.rb (link_command): put 'opt' after conftest.c for
+ static linking.
+
+Mon Oct 21 22:53:02 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (XCFLAGS): CFLAGS to compile ruby itself.
+
+ * configure.in (LIBEXT): suffix for static libraries.
+
+ * configure.in (LIBPATHFLAG): switch template to specify library
+ path.
+
+ * configure.in (LINK_SO): command to link shared objects.
+
+ * configure.in (DEFFILE, ARCHFILE): miscellaneous system dependent
+ files.
+
+ * configure.in (EXPORT_PREFIX): prefix to exported symbols on
+ Windows.
+
+ * configure.in (COMMON_LIBS, COMMON_MACROS, COMMON_HEADERS):
+ libraries, macros and headers used in common.
+
+ * configure.in (RUBYW_INSTALL_NAME, rubyw_install_name): GUI mode
+ executable name.
+
+ * Makefile.in (CFLAGS): append XCFLAGS.
+
+ * Makefile.in (PREP): miscellaneous system dependent files.
+
+ * Makefile.in (ruby.imp, ext/extinit.o): moved from ext/extmk.rb.
+
+ * Makefile.in (fake.rb): CROSS_COMPILING keeps building platform.
+
+ * Makefile.in (MAKEFILES): depend on *.in and config.status.
+
+ * Makefile.in (parse.c): replace "y.tab.c" with actual name for
+ byacc.
+
+ * ext/extmk.rb, lib/mkmf.rb: integrated.
+
+ * ext/extmk.rb: propagate MFLAGS.
+
+ * ext/extmk.rb (extmake): make dummy Makefile to clean even if no
+ Makefile is made.
+
+ * lib/mkmf.rb (older): accept multiple file names and Time
+ objects.
+
+ * lib/mkmf.rb (xsystem): split and quote.
+
+ * lib/mkmf.rb (cpp_include): make include directives.
+
+ * lib/mkmf.rb (try_func): try whether specified function is
+ available.
+
+ * lib/mkmf.rb (install_files): default to site-install.
+
+ * lib/mkmf.rb (checking_for): added.
+
+ * lib/mkmf.rb (find_executable0): just find executable file with
+ no message.
+
+ * lib/mkmf.rb (create_header): output header file is variable.
+
+ * lib/mkmf.rb (create_makefile): separate sections.
+
+ * lib/mkmf.rb (init_mkmf): initialize global variables.
+
+ * win32/Makefile.sub, bcc32/Makefile.sub (CPP, AR): added.
+
+ * bcc32/Makefile.sub (ARCH): fixed to i386.
+
+ * win32/Makefile.sub, bcc32/Makefile.sub (miniruby): should not
+ link EXTOBJS.
+
+ * ext/dl/extconf.rb: use try_cpp to cross compile.
+
+ * ext/dl/extconf.rb: not modify files in source directory.
+
+Fri Oct 18 23:11:21 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (value_expr0): allow return/break/next/redo/retry in rhs
+ of logical operator. [ruby-dev:18534]
+
+ * parse.y (remove_begin): eliminate useless NODE_BEGIN.
+ [ruby-dev:18535]
+
+Fri Oct 18 01:02:44 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * hash.c, eval.c: Use (*_NSGetEnviron()) instead of environ on
+ Darwin for namespace cleanness. [ruby-core:00537]
+
+ * dln.c (dln_load): Fix Darwin support that has been disabled and
+ switch to using it on Darwin instead of the system dlopen().
+ [ruby-core:00541]
+
+Thu Oct 17 19:17:56 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c (w_byten): added; write n bytes from s to arg.
+
+ * marshal.c (dump): flush buffered data.
+
+ * marshal.c (marshal_dump, r_byte, r_bytes0, marshal_load): unify
+ marshaling I/O. [ruby-talk:53368]
+
+Thu Oct 17 12:58:24 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: stat.blksize might be 0/nil.
+
+ * lib/fileutils.rb: change coding style.
+
+Wed Oct 16 22:35:53 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * sprintf.c (rb_f_sprintf): disallow mixed usage of numbered and
+ unnumbered arguments. [ruby-dev:18531]
+ get rid of memory leak at exception. [ruby-core:00460]
+
+Wed Oct 16 13:36:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * variable.c (rb_global_entry): not add global entry until
+ initialized to avoid accessing it while GC. [ruby-dev:18514]
+
+ * variable.c (rb_alias_variable): ditto.
+
+Wed Oct 16 01:03:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_str_to_dbl): RString ptr might be NULL.
+
+ * object.c (rb_cstr_to_dbl): p pointer might be NULL.
+
+ * bignum.c (rb_str_to_inum): RString ptr might be NULL.
+
+ * bignum.c (rb_cstr_to_inum): str pointer might be NULL.
+
+Sat Oct 12 23:44:11 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (rb_w32_putc): wrong condition to fill or flush on
+ bccwin32. [ruby-win32:408]
+
+Fri Oct 11 15:58:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): rescue modifier is now an operator with
+ precedence right below assignments. i.e. "a = b rescue c" now
+ parsed as "a = (b rescue c)", not as "(a = b) rescue c". [new]
+ [experimental]
+
+Fri Oct 11 06:05:30 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (rb_w32_fclose, rb_w32_close): use closesocket()
+ for socket. [ruby-win32:382]
+
+ * win32/win32.c (StartSockets): set NtSocketsInitialized.
+
+ * win32/win32.h: prototypes; rb_w32_fclose, rb_w32_close
+
+Fri Oct 11 00:24:57 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * gc.c (ruby_xmalloc, ruby_xrealloc): restrict total allocation
+ size according to memories consumed by live objects.
+ [ruby-dev:18482]
+
+ * gc.c (gc_sweep): estimate how live objects consume memories.
+
+Thu Oct 10 17:26:12 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/tcltklib/stubs.c (ruby_tcltk_stubs): fix memory leak.
+ [ruby-dev:18478]
+
+Thu Oct 10 15:20:18 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/weakref.rb (WeakRef::@@final): use Hash#delete.
+
+ * lib/weakref.rb (WeakRef::__getobj__): examine if alive or not by
+ ID_REV_MAP to deal with recycled object. [ruby-dev:18472]
+
+ * lib/weakref.rb (WeakRef::weakref_alive?): ditto.
+
+Wed Oct 9 07:11:25 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * gc.c (gc_sweep): also adjust heaps_limits when free unused heap
+ page. [ruby-core:00526]
+
+ * io.c (io_fflush): condition to retry can occur.
+
+ * io.c (io_write): returned 0 wrongly if no error occurred.
+
+Tue Oct 8 14:19:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (io_write): must check returned value from fwrite() before
+ test with ferror(). (ruby-bugs-ja:PR#350)
+
+Tue Oct 8 10:55:23 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/prettyprint.rb (PrettyPrint.singleline_format): new method.
+
+Mon Oct 7 16:43:07 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (bigdivrem): bignum zero's len should not be 0.
+
+Mon Oct 7 15:36:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (bigdivmod): wrong condition check for Bignum zero.
+
+ * bignum.c (Init_Bignum): need to add Bignum#div.
+
+Sun Oct 6 00:49:15 2002 Minero Aoki <aamine@loveruby.net>
+
+ * eval.c (rb_load): should not pass blocks to the loaded file.
+ [ruby-dev:18458]
+
+Fri Oct 4 20:25:38 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_interrupt, rb_thread_signal_raise): no need to
+ save dead thread context. (same as [ruby-dev:18322])
+ (ruby-bugs-ja:PR#349)
+
+Fri Oct 4 13:05:58 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (RUBY_PROG_GNU_LD): check whether the linker is GNU ld.
+
+ * ext/extmk.rb (create_makefile): add -Wl,-no-undefined to $DLDFLAGS
+ on Linux if GNU ld is used and --enable-shared is specified.
+
+Fri Oct 4 02:21:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_rshift): num should be initialized by carry
+ bits if x is negative.
+
+ * bignum.c (bigdivmod): len for bignum zero is 1, not 0.
+
+Thu Oct 3 20:22:11 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bcc32/mkexports.rb: to work on cygwin via telnet.
+ [ruby-win32:358]
+
+ * ext/tcltklib/tcltklib.c (ip_invoke): requires command name
+ argument. [ruby-dev:18438]
+
+ * eval.c (ruby_init, ruby_options): Init_stack() with local
+ location. (ruby-bugs-ja:PR#277)
+
+ * eval.c (rb_call0): disable trace call. [ruby-dev:18074]
+
+ * eval.c (eval, rb_load): enable trace call. [ruby-dev:18074]
+
+ * eval.c (rb_f_require): set source file name for extension
+ libraries. [ruby-dev:18445]
+
+ * gc.c (Init_stack): prefer address of argument rather than local
+ variable to initialize rb_gc_stack_start.
+
+ * ruby.c (translate_char): translate a character in a string;
+ DOSISH only. [ruby-dev:18274]
+
+ * ruby.c (ruby_init_loadpath): added argv[0] handling under
+ Human68K. [ruby-dev:18274]
+
+ * ruby.c (proc_options): translate directory separator in $0 to
+ '/'. [ruby-dev:18274]
+
+Thu Oct 3 00:27:26 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/delegate.rb (Delegator::initialize): use Object#class
+ instead of deprecated Object#type.
+
+Wed Oct 2 23:32:48 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * configure.in (RUBY_CHECK_IO_NEED_FLUSH): check whether fflush()
+ is needed.
+
+ * io.c (flush_before_seek): flush before seek if buffered data
+ may remain.
+
+ * io.c (rb_io_check_readable): flush if the last operation was
+ write.
+
+ * io.c (rb_io_check_writable): flush if the last operation was
+ read.
+
+ * rubyio.h (FMODE_RBUF): added.
+
+Wed Oct 2 23:09:20 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (rb_io_wait_readable): handle retryable errors.
+
+ * io.c (rb_io_wait_writable): ditto.
+
+ * ext/socket/socket.c (bsock_send): ditto.
+
+ * ext/socket/socket.c (s_recvfrom): ditto.
+
+ * ext/socket/socket.c (s_accept): ditto.
+
+ * ext/socket/socket.c (udp_send): ditto.
+
+ * ext/socket/getaddrinfo.c (afdl): made private structures constant.
+
+ * rubyio.h: prototype; rb_io_wait_readable(), rb_io_wait_writable().
+
+Wed Oct 2 13:03:58 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: set ac_cv_func_setitimer to "no" on Cygwin.
+
+Wed Oct 2 10:59:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (gc_sweep): free unused heap page to reduce process size if
+ possible.
+
+ * object.c (rb_obj_type): deprecated Object#type; use Object#class.
+
+Tue Oct 1 23:48:32 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/socket/socket.c (init_sock): no need for special finalizer,
+ socket descriptor is no longer duplicated in 1.7.
+ [ruby-talk:50732]
+
+ * win32/win32.c, win32/win32.h (rb_w32_fddup, rb_w32_fdclose):
+ delete.
+
+Mon Sep 30 20:29:10 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (rb_io_inspect): not need to raise IOError for closed
+ stream. [ruby-talk:51871]
+
+Mon Sep 30 03:48:15 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_check): need no Fixnum check.
+
+Sun Sep 29 18:30:24 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (rb_w32_open_osfhandle): adjust
+ rb_w32_open_osfhandle() with _open_osfhandle().
+
+ * win32/win32.c (rb_w32_accept, rb_w32_socket): return -1 on
+ error.
+
+ * win32/win32.h: should use file descriptor instead of SOCKET.
+
+Sun Sep 29 06:33:03 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (is_socket, rb_w32_select, rb_w32_accept, rb_w32_bind,
+ rb_w32_connect, rb_w32_getpeername, rb_w32_getsockname,
+ rb_w32_getsockopt, rb_w32_ioctlsocket, rb_w32_listen, rb_w32_recv,
+ rb_w32_recvfrom, rb_w32_send, rb_w32_sendto, rb_w32_setsockopt,
+ rb_w32_shutdown, rb_w32_socket, rb_w32_gethostbyaddr,
+ rb_w32_gethostbyname, rb_w32_gethostname, rb_w32_getprotobyname,
+ rb_w32_getprotobynumber, rb_w32_getservbyname, rb_w32_getservbyport):
+ need to protect WSAGetLastError() by RUBY_CRITICAL. [ruby-talk:51778]
+
+Sat Sep 28 20:06:36 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * keywords: add braces around initializers.
+
+Sat Sep 28 13:19:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * hash.c (rb_hash_become): should check self-assignment after
+ conversion.
+
+Sat Sep 28 10:40:44 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_become): Hash#become should check added
+ self-assignment.
+
+ * class.c (rb_make_metaclass): metaclass of a superclass may be
+ NULL at boot time.
+
+Sat Sep 28 09:50:03 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * ext/extmk.rb: The condition judgment without necessity was deleted.
+
+Fri Sep 27 18:40:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_deadlock): more verbose message at deadlock.
+
+ * eval.c (rb_thread_schedule): ditto.
+
+ * eval.c (rb_thread_join): ditto.
+
+Fri Sep 27 13:24:35 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): Class#inherited should be called after the
+ execution of the class body.
+
+Fri Sep 27 02:41:53 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/sha1: Use OpenSSL's SHA1 engine if available. It is
+ much faster than what we have now (sha1.[ch]). Add a knob
+ (--with-bundled-sha1) to extconf.rb which makes it use the
+ bundled one anyway.
+
+Fri Sep 27 02:25:14 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/rmd160: Use OpenSSL's RMD160 engine if available. It
+ is much faster than what we have now (rmd160.[ch]). Add a knob
+ (--with-bundled-rmd160) to extconf.rb which makes it use the
+ bundled one anyway.
+
+Fri Sep 27 01:23:39 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/md5: Use OpenSSL's MD5 engine if available. It is
+ much faster than what we have now (md5.[ch]). Add a knob
+ (--with-bundled-md5) to extconf.rb which makes it use the
+ bundled one anyway.
+
+Thu Sep 26 22:44:21 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/digest.c (rb_digest_base_s_digest): Fix a double
+ free() bug mingled with allocation framework deployment.
+
+ * ext/digest/digest.c (rb_digest_base_s_hexdigest): Get rid of
+ redundant struct allocation.
+
+Thu Sep 26 09:52:52 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (primary): remove "return outside of method" check at
+ compile time.
+
+Wed Sep 25 23:51:29 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * dir.c (glob_helper): must not closedir() when exception raised
+ while globbing "**".
+
+ * marshal.c (w_uclass): unused variable.
+
+ * re.c (match_clone): unused.
+
+ * regex.c (re_compile_pattern): get rid of implicit promotion from
+ plain char to int.
+
+Wed Sep 25 17:46:46 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * lib/mkmf.rb (libpathflag): restore ENV['LIB'] when some error
+ occurred.
+
+Wed Sep 25 16:14:51 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_match): p1 may exceed pend limit.
+
+Mon Sep 23 23:22:43 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_call0): must not clear ruby_current_node, or
+ backtrace cannot be generated.
+
+ * intern.h (ruby_yyparse): rather than yyparse().
+
+ * parse.y (yylex): nextc() returns -1 at end of input, not 0.
+
+ * parse.y (newline_node): reduce duplicated newline node.
+
+ * parse.y (literal_concat): get rid of warning.
+
+ * parse.y (new_evstr): fixed junk code.
+
+Mon Sep 23 19:57:52 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (RUBY_MINGW32): new macro. check for the MinGW
+ compiler environment.
+
+ * lib/mkmf.rb: refactoring.
+
+Mon Sep 23 08:27:11 2002 Tanaka Akira <akr@m17n.org>
+
+ * io.c (appendline): forget to terminate with nul.
+
+Mon Sep 23 02:46:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_run): should set toplevel visibility again here.
+
+ * eval.c (rb_eval): should not rely on ruby_class == rb_cObject
+ check. Besides allow implicit publicity for attribute set
+ methods.
+
+ * parse.y (primary): need not to check class_nest, just set
+ whether method is an attrset or not.
+
+Sun Sep 22 21:49:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (call_trace_func): should not call trace function while
+ compilation.
+
+ * eval.c (rb_call0): also inside c-func.
+
+ * parse.y (yycompile): ditto.
+
+ * ruby.c (require_libraries): preserve source file/line for each
+ require.
+
+Sun Sep 22 17:08:11 2002 Tanaka Akira <akr@m17n.org>
+
+ * string.c (rb_str_each_line): p might be at the top of the
+ string.
+
+Sat Sep 21 23:28:28 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_make_metaclass): class of metaclass should be
+ metaclass of superclass, unless class itself is a metaclass;
+ class of metaclass of metaclass should point back to self.
+ eh, confusing, isn't it.
+
+ * class.c (rb_singleton_class): check if its class is singleton
+ AND attached to self.
+
+Sat Sep 21 22:23:41 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_raise): no need to save dead thread context.
+ [ruby-dev:18322]
+
+Fri Sep 20 23:02:01 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (block_append): eliminate unused literal nodes.
+
+ * parse.y (literal_concat): refined literal concatenation.
+
+Fri Sep 20 19:43:40 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: Merge rough/lib/set.rb rev.1.5-1.15.
+
+Wed Sep 18 12:41:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should define class/module under ruby_cbase.
+
+ * eval.c (rb_eval): should set class/module path based on
+ ruby_cbase, not ruby_class.
+
+ * eval.c (module_setup): use ruby_cbase instead of ruby_class.
+
+Tue Sep 17 21:06:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_die): put thread dead state.
+
+ * eval.c (rb_thread_atfork): free stack buffer at fork too.
+
+Tue Sep 17 01:13:31 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_nesting): load wrapping module should appear in
+ Module#nesting list. (ruby-bugs-ja:PR#328)
+
+ * eval.c (rb_thread_remove): free stack buffer on remove.
+
+Tue Sep 17 00:58:35 2002 Minero Aoki <aamine@loveruby.net>
+
+ * io.c: add parameter prototype.
+
+ * re.c: ditto.
+
+Sun Sep 15 21:14:22 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * win32/win32.c (rb_w32_opendir, rb_w32_stat): Corresponds to
+ the unjust path containing ".
+
+Sun Sep 15 19:48:55 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (OUTFLAG, CPPOUTFILE): moved from lib/mkmf.rb.
+ check whether ${CPP} accepts the -o option.
+
+ * win32/Makefile.sub (OUTFLAG, CPPOUTFILE): ditto.
+
+ * bcc32/Makefile.sub (OUTFLAG, CPPOUTFILE): ditto.
+
+ * djgpp/config.sed (OUTFLAG, CPPOUTFILE): ditto.
+
+ * lib/mkmf.rb (OUTFLAG, CPPOUTFILE): use CONFIG.
+ make easy to understand log.
+
+ * mkconfig.rb (val): should not strip.
+
+Sat Sep 14 20:13:42 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * error.c(rb_sys_fail): remove case EPIPE on bcc32 .
+
+Fri Sep 13 23:39:49 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * dir.c (glob_func_caller): add prototype to get rid of warning.
+
+Fri Sep 13 18:35:12 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): avoid uninitialized global/class variable
+ warnings at `||='. [ruby-dev:18278]
+
+ * parse.y (stmt, arg): ditto
+
+Fri Sep 13 13:28:04 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb ($INSTALLFILES): avoid warning when $VERBOSE mode.
+
+Thu Sep 12 23:20:10 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * bcc32/setup.mak : Control of a message.
+
+ * bcc32/makefile.sub : include resource.
+
+Thu Sep 12 18:10:03 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * dir.c (glob_helper): fixed freeing buffer. (ruby-bugs-ja:PR#332)
+
+ * dir.c (glob_helper): should pass matched path. (ruby-bugs-ja:PR#333)
+
+Thu Sep 12 00:09:32 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_trap_eval): preserve thread status and so on.
+ [ruby-talk:40337], [ruby-core:00019]
+
+Wed Sep 11 21:25:52 2002 Tanaka Akira <akr@m17n.org>
+
+ * pp.rb (ARGF.pretty_print): implemented.
+ (PP.pp): arguments reordered.
+
+Wed Sep 11 18:55:38 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (proc_to_s): refined format. [ruby-dev:18215]
+
+Wed Sep 11 17:47:17 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c, win32/win32.h (rb_w32_getpid): negate pid under Win9x.
+ [ruby-dev:18262]
+
+Wed Sep 11 12:58:57 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * string.c (get_pat): Add an extra argument "quote".
+
+ * string.c (rb_str_match_m): Do not bother to convert if a regexp
+ is given.
+
+Wed Sep 11 11:33:40 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * bcc32/Makefile.sub: remove unnecessary `.dll' from filename of
+ dll's resource file.
+
+ * cygwin/GNUmakefile.in: ditto. [ruby-dev:17103]
+
+ * win32/Makefile.sub: ditto. [ruby-dev:17103]
+
+ * win32/resource.rb: ditto. [ruby-dev:17103]
+
+Wed Sep 11 09:59:46 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (rb_io_wait_readable): added.
+
+ * io.c (rb_io_wait_writable): added.
+
+ * io.c (io_read_retryable): added.
+
+ * io.c (io_write): retry on EINTR, ERESTART and EWOULDBLOCK.
+ [ruby-dev:17855], [ruby-dev:17878], [ruby-core:00444]
+
+ * io.c (rb_io_fread): ditto.
+
+ * io.c (read_all): ditto.
+
+ * io.c (appendline): ditto.
+
+ * io.c (rb_io_each_byte): ditto.
+
+ * io.c (rb_io_getc): ditto.
+
+Wed Sep 11 09:29:24 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub (ext): make directory `ext' on compile dir.
+ [ruby-dev:18255]
+
+Wed Sep 11 00:41:10 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_mod_define_method): initialize orig_func too.
+ (ruby-bugs-ja:PR#330)
+
+Wed Sep 11 00:01:32 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (glob_helper): prevent memory leak using rb_protect().
+
+ * string.c (rb_str_associate): no need to check freeze flag.
+
+ * string.c (rb_str_resize): should honor STR_ASSOC flag on
+ resize.
+
+ * string.c (rb_str_resize): proper STR_ASSOC handling. pointed
+ out by Michal Rokos.
+
+ * string.c (rb_str_buf_cat): ditto.
+
+ * string.c (rb_str_cat): ditto.
+
+ * string.c (rb_str_buf_append): ditto.
+
+ * string.c (rb_str_append): ditto.
+
+Tue Sep 10 23:35:46 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (nextc): restore line number after here documents.
+ (ruby-bugs-ja:PR#331)
+
+ * parse.y (heredoc_restore): ditto.
+
+Tue Sep 10 18:26:52 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb, lib/mkmf.rb ($INCFLAGS): new var for -I$(topdir).
+
+ * lib/mkmf.rb: add #define WIN32_LEAN_AND_MEAN to improve compile
+ times.
+
+Tue Sep 10 17:16:14 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub (miniruby): shouldn't link $(EXTOBJS).
+ [ruby-dev:17059]
+
+ * win32/Makefile.sub ($(LIBRUBY_A), $(LIBRUBY)): avoid lib.exe's
+ warning. [ruby-dev:17059]
+
+ * win32/Makefile.sub: remove unnecessary rules. [ruby-dev:17059]
+
+ * win32/configure.bat, win32/setup.mak, win32/README.win32: enable to
+ pass some arguments to configure. [ruby-dev:17059]
+
+Mon Sep 9 23:43:33 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.h (S_I?USR): define only if not mingw32.
+
+Mon Sep 9 11:21:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/stringio/stringio.c (strio_set_string): reinitialize
+ properly.
+
+ * ext/stringio/stringio.c (strio_become): added self-assign check
+ and experimental auto-conversion to StringIO.
+
+ * ext/stringio/stringio.c (strio_reopen): added.
+
+
+Sun Sep 8 21:29:25 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * time.c (time_free): prototype; struct time_object -> void *.
+ avoid GCC warnings.
+
+ * lib/mkmf.rb, ext/extmk.rb ($LINK, $CPP): move to lib/mkmf.rb.
+
+Sun Sep 8 19:02:28 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * time.c: prototype; time_free() to avoid VC++ warnings.
+
+ * ext/tcltklib/tcltklib.c: prototype; invoke_queue_handler() to avoid
+ VC++ warning.
+
+ * win32/win32.c (rb_w32_stat): remove S_IWGRP and S_IWOTH bits from
+ st_mode.
+
+ * win32/win32.h (S_I*): define if not defined.
+
+Sun Sep 8 14:38:31 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: modify program_prefix only if specified
+ --program-prefix.
+
+ * configure.in: don't generate ext/extmk.rb.
+
+ * Makefile.in: execute directly $(srcdir)/ext/extmk.rb.
+ remove -Cext option, "Dir::chdir 'ext'" in ext/extmk.rb.
+
+ * {win32,bccwin32}/Makefile.sub: ditto.
+
+ * instruby.rb: ditto.
+
+ * ext/extmk.rb: renamed from ext/extmk.rb.in.
+
+ * lib/mkmf.rb (module Logging): create log files (mkmf.log)
+ in each extension module directories.
+
+ * ext/extmk.rb: ditto.
+
+ * lib/mkmf.rb (macro_defined?): new method.
+
+ * ext/.cvsignore: remove extmk.rb.
+
+ * ext/*/.cvsignore: add "*.def".
+
+ * lib/mkmf.rb (have_struct_member): moved from ext/socket/extconf.rb.
+
+ * ext/socket/extconf.rb: use macro_defined? instead of egrep_cpp.
+
+ * ext/etc/extconf.rb: use have_struct_member.
+
+ * ext/etc/etc.c: add prefix HAVE_ST_ to PW_ macros.
+
+Sun Sep 8 14:36:40 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * bcc32/configure.bat : Control of a message.
+ * bcc32/makefile.sub : @(sitearch) typo.
+ * ext/extmk.rb.in : [bccwin32] libdir is added to a library path.
+ * lib/mkmf.rb : ditto.
+
+Sat Sep 7 23:32:56 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/inf-ruby.el (inferior-ruby-error-regexp-alist): regexp
+ alist for error message from ruby.
+
+ * misc/inf-ruby.el (inferior-ruby-mode): fixed for Emacs.
+
+ * misc/inf-ruby.el (ruby-send-region): compilation-parse-errors
+ doesn't parse first line, so insert separators before each
+ evaluations.
+
+Sat Sep 7 19:46:57 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: Disallow Set.new(false). Add even more tests.
+ [Submitted by: "Christoph" <chr_news@gmx.net>]
+
+Sat Sep 7 19:23:56 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: Fix a bug in flatten()'s recursive set detection.
+ [Submitted by: "Christoph" <chr_news@gmx.net>] Some tests
+ against the bug are added.
+
+ * lib/set.rb: Resurrect the test suite by putting it after
+ __END__ and executing `eval DATA.read'.
+
+Sat Sep 7 08:41:39 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y (rb_gc_mark_parser): ruby_eval_tree is marked in eval.c.
+
+Fri Sep 6 20:01:38 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/mkmf.rb ($CC): command to compile C source.
+
+ * lib/mkmf.rb (logging): added.
+
+ * lib/mkmf.rb (try_compile): added.
+
+ * lib/mkmf.rb (egrep_cpp): use internal grep when pattern is
+ Regexp, otherwise use external egrep command but get rid of
+ pipe of command.com.
+
+ * lib/mkmf.rb (have_func): local variable should be volatile not
+ to be eliminated by optimization.
+
+ * lib/mkmf.rb (create_makefile): link with CONFIG["LIBS"].
+
+ * lib/mkmf.rb (create_makefile): emit .SUFFIXES:.
+
+Fri Sep 6 12:11:22 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y (rb_gc_mark_parser): should mark ALL global variables
+ defined in parse.y.
+
+Fri Sep 6 01:15:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (ruby_xmalloc): remove MALLOC_LIMIT to avoid frequent
+ garbage collection.
+
+Fri Sep 6 11:47:37 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y (rb_gc_mark_parser): should mark global variables
+ defined in parse.y.
+
+Fri Sep 6 10:34:32 2002 Minero Aoki <aamine@loveruby.net>
+
+ * io.c (rb_io_puts): RSTRING(line)->ptr might be NULL.
+
+Fri Sep 6 10:26:37 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y: should not put non-NODE-VALUEs in the semantic stack.
+
+Fri Sep 6 05:48:26 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (rb_path_check): nothing to check under DOSISH.
+ [ruby-list:35772]
+
+Fri Sep 6 05:03:50 2002 Minero Aoki <aamine@loveruby.net>
+
+ * gc.c (rb_gc): should mark parser.
+
+ * parse.y (rb_gc_mark_parser): new function.
+
+ * intern.h (rb_gc_mark_parser): added.
+
+Thu Sep 5 18:32:32 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_path2class): should not use rb_eval_string().
+
+Thu Sep 5 17:18:22 2002 Michal Rokos <michal@ruby-lang.org>
+
+ * dln.c: fix memory leak in dln_load (ruby-core:405) and
+ in load_1 (ruby-core:407)
+
+Thu Sep 5 15:43:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_extended): should allow marshaling of object which
+ is extended by named module.
+
+ * class.c (rb_make_metaclass): super may be T_ICLASS, need to skip.
+
+Thu Sep 5 13:09:22 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): overriding false constant with class/module
+ definition should be error. (PR#327)
+
+Thu Sep 5 01:24:26 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * extmk.rb (create_makefile): add macro MAKEDIRS, INSTALL_PROG,
+ INSTALL_DATA.
+
+ * extmk.rb (create_makefile): support for building to any directory.
+
+ * extmk.rb (xsystem): move to mkmf.rb.
+
+ * mkmf.rb (xsystem): support for extmk.rb
+
+ * mkmf.rb ($CPP): remove '-E' option. add CPPFLAGS.
+
+Wed Sep 4 16:15:17 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: ==(o) should be aware of all the Set variant
+ instances, not just those of its subclasses. [Submitted by:
+ "Christoph" <chr_news@gmx.net>]
+
+ * lib/set.rb: - Fix eql?(). [ditto]
+
+Wed Sep 4 15:23:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_make_metaclass): obj.meta.super.meta should be equal
+ to obj.meta.meta.super (ruby-bugs-ja:PR#324).
+
+Wed Sep 4 05:10:16 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * parse.y (yylex): the warning message "invalid
+ character syntax" was never issued (ruby-bugs-ja:PR#323).
+
+Wed Sep 4 01:08:45 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (r_bytes): do not use alloca (ruby-bugs:PR#382).
+
+Tue Sep 3 17:12:59 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * extmk.rb: require mkmf.rb. remove duplicate methods.
+ use Config::CONFIG["FOO"] instead of @FOO@.
+
+ * mkmf.rb: support for extmk.rb.
+
+Mon Sep 2 23:01:50 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * re.c (rb_reg_search): MatchData must be rb_cMatch.
+ (ruby-bugs-ja:PR#319)
+
+Mon Sep 2 21:21:46 2002 Minero Aoki <aamine@loveruby.net>
+
+ * gc.c (gc_sweep): does reclaim nodes in also compile time, if we
+ can.
+
+ * ruby.c (load_file): omit GC if we can.
+
+ * parse.y (ruby_parser_stack_on_heap): new function.
+
+ * intern.h (ruby_parser_stack_on_heap): added.
+
+Mon Sep 2 18:45:07 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_copy_generic_ivar): remove old generic instance
+ variable table if it exists.
+
+Sun Sep 1 15:54:33 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * config.guess: fixed for Linux/PPC.
+
+Sat Aug 31 09:38:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_make_metaclass): metaclass of a metaclass is a
+ metaclass itself.
+
+Fri Aug 30 22:45:16 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: Added.
+
+Fri Aug 30 20:58:54 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * ext/Win32API/Win32API.c (Win32API_Call): typo.
+
+Fri Aug 30 19:45:52 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * variable.c (rb_const_assign): st_delete() takes pointer to key.
+
+Fri Aug 30 19:40:28 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/Win32API/Win32API.c (Win32API_Call): RSTRING()->ptr may be
+ NULL.
+
+ * ext/nkf/nkf.c (rb_nkf_guess): ditto.
+
+ * ext/readline/readline.c (readline_s_set_completion_append_character):
+ ditto.
+
+ * ext/socket/socket.c (sock_s_getaddrinfo, sock_s_getnameinfo):
+ ditto.
+
+ * ext/tcltklib/tcltklib.c (ip_toUTF8, ip_fromUTF8): ditto.
+
+Fri Aug 30 01:32:17 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_singleton_class): superclass of a metaclass
+ should be a metaclass of superclass.
+
+ * range.c (range_eq): two instances must belong to a same class to
+ be equal.
+
+ * range.c (range_eql): ditto.
+
+ * io.c (rb_io_taint_check): frozen check added.
+
+ * file.c (rb_stat_become): frozen check added.
+
+ * object.c (rb_obj_become): ditto.
+
+ * re.c (rb_reg_become): ditto.
+
+ * struct.c (rb_struct_become): ditto.
+
+ * time.c (time_become): ditto.
+
+ * array.c (rb_ary_become): should call rb_ary_modify().
+
+ * hash.c (rb_hash_become): should call rb_hash_modify().
+
+ * compar.c (cmp_equal): should not use NUM2LONG(), since <=> may
+ return bignum.
+
+ * compar.c (cmp_gt, cmp_ge, cmp_lt, cmp_le, cmp_between): ditto.
+
+Thu Aug 29 23:34:42 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * bcc32/MakeFile.sub (sitearch): add.
+
+Thu Aug 29 13:36:42 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (read_all): should use off_t instead of long.
+
+Thu Aug 29 00:55:55 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * marshal.c (r_object): yield loaded objects, not intermediates.
+ (ruby-bugs-ja:PR#296)
+
+Thu Aug 29 00:06:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_become): should not free ptr if it's shared.
+
+ * eval.c (rb_alias): prohibit making an alias named "allocate" if
+ klass is a metaclass.
+
+Wed Aug 28 23:59:15 2002 Michal Rokos <michal@ruby-lang.org>
+
+ * signal.c: remove #ifdef SIGINT for struct signals.
+
+ * variable.c: get rid of fix length buffer in rb_class_path.
+
+Wed Aug 28 23:34:32 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (appendline): data was lost when raw mode.
+
+Wed Aug 28 22:57:34 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_string_value_ptr): StringValuePtr() should never
+ return NULL pointer.
+
+Wed Aug 28 19:12:46 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/stringio/stringio.c (strio_initialize): RSTRING(mode)->ptr
+ can be NULL.
+
+ * ext/stringio/stringio.c (strio_ungetc): fix buffer overflow.
+
+Wed Aug 28 18:19:55 2002 Michal Rokos <michal@ruby-lang.org>
+
+ * file.c: fix memory leak in rb_stat_init.
+
+Wed Aug 28 17:45:03 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/win32.c (kill): negate pid under Win9x.
+
+Wed Aug 28 16:36:40 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (ar): don't check ar twice.
+
+Wed Aug 28 15:00:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_delete_bang): should check if str->ptr is 0.
+
+ * string.c (rb_str_squeeze_bang): ditto.
+
+ * string.c (rb_str_count): ditto.
+
+ * string.c (rb_str_lstrip_bang): ditto.
+
+ * string.c (rb_str_rstrip_bang): ditto.
+
+ * string.c (rb_str_intern): ditto.
+
+Wed Aug 28 11:37:35 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.h: define SIGINT and SIGKILL if not defined.
+
+ * win32/win32.c: remove definition of SIGINT and SIGKILL.
+
+Tue Aug 27 19:50:27 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ruby.c (require_libraries): prevent ruby_sourcefile from GC.
+
+Tue Aug 27 15:03:35 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_find_file): $LOAD_PATH must not be empty.
+
+ * file.c (rb_find_file_ext): ditto.
+
+Tue Aug 27 02:35:21 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_eq): class check should be based on range.class,
+ instead of Range to work with Range.dup.
+
+ * range.c (range_eql): ditto.
+
+Mon Aug 26 18:17:56 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_mod_dup): need to preserve metaclass and flags.
+
+Mon Aug 26 10:44:18 2002 Tanaka Akira <akr@m17n.org>
+
+ * object.c (rb_cstr_to_dbl): had a buffer overrun.
+
+Sun Aug 25 20:10:32 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/cgi.rb (CGI#form): fix ruby-bugs-ja:PR#280, add default action.
+
+Sat Aug 24 15:32:16 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (call_trace_func): restore source file/line, as trace
+ function installed in required library with -r option can be
+ called while parsing. (ruby-bugs:PR#372)
+
+ * eval.c (module_setup): unused variable. [ruby-core:00358]
+
+Sat Aug 24 14:59:02 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_class): integrate singleton check into a function
+ to follow DRY principle.
+
+ * marshal.c (w_uclass): should check singleton method.
+
+ * object.c (rb_obj_dup): dmark and dfree functions must be match
+ for T_DATA type.
+
+ * object.c (rb_obj_dup): class of the duped object must be match
+ to the class of the original.
+
+Sat Aug 24 13:57:28 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/time.rb (Time.rfc2822, Time#rfc2822): preserve localtimeness.
+
+ * lib/pp.rb: pretty_print_cycled is renamed to pretty_print_cycle.
+
+Fri Aug 23 23:59:57 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (method_call): check receiver is defined.
+
+ * eval.c (umethod_call): removed.
+
+Fri Aug 23 23:39:17 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_quote): do not escape \t, \f, \r, \n, for they are
+ not regular expression metacharacters.
+
+ * time.c (time_s_alloc): use time_free instead of free (null check,
+ also serves for type mark).
+
+ * time.c (time_s_at): check dfree function too.
+
+Fri Aug 23 17:06:48 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: RUBY_SO_NAME is msvcrt-rubyXX on mswin32/mingw32.
+
+ * configure.in (sitearch): new var.
+
+ * mkconfig.rb, lib/mkmf.rb (sitearch): ditto.
+
+ * win32/Makefile.sub, win32/setup.mak (sitearch): ditto.
+
+ * instruby.rb: ditto.
+
+Wed Aug 21 16:53:00 2002 Michal Rokos <michal@ruby-lang.org>
+
+ * *.c: int, long types cleanup.
+
+ * parse.y: ditto.
+
+ * re.h, regex.h, ruby.h: ditto.
+
+Wed Aug 21 16:43:19 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_cleanup): should not modify the global
+ variable curr_thread.
+
+Wed Aug 21 16:14:26 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: set ac_cv_func__setjmp to "no" on Cygwin.
+
+ * configure.in: set ac_cv_func_crypt to "no" on MinGW.
+
+Tue Aug 20 21:47 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * io.c (rb_io_fread): remove case EPIPE on bcc32 .
+
+ * win32/win32.c (rb_w32_getc): clear EPIPE error on bcc32.
+
+Tue Aug 20 19:39:03 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * file.c (rb_file_s_expand_path): accept drive letter on Cygwin.
+
+ * file.c (is_absolute_path): ditto.
+
+Tue Aug 20 12:12:25 2002 Tietew <tietew@tietew.net>
+
+ * io.c (rb_io_putc): output via rb_io_write().
+
+Mon Aug 19 19:01:55 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/inf-ruby.el (inf-ruby-keys): ruby-send-definition
+ conflicted with ruby-insert-end.
+
+ * misc/inf-ruby.el (inferior-ruby-mode): compilation-minor-mode.
+
+ * misc/inf-ruby.el (ruby-send-region): send as here document to
+ adjust source file/line. [ruby-talk:47113], [ruby-dev:17965]
+
+ * misc/inf-ruby.el (ruby-send-terminator): added to make unique
+ terminator.
+
+Mon Aug 19 17:08:19 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_initialize_m): frozen check should be moved here
+ from rb_reg_initialize().
+
+Mon Aug 19 15:38:44 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (sort_2): comparison should be done as signed long.
+
+ * array.c (sort_2): should return int, not VALUE.
+
+Mon Aug 19 12:38:33 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_save_context, rb_thread_restore_context):
+ save/restore SEH chain on MS-Windows at thread switch.
+ [ruby-win32:273]
+
+ * eval.c (win32_get_exception_list, win32_set_exception_list):
+ added.
+
+Sat Aug 17 23:01:25 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (sort_2): *a - *b may overflow.
+
+Sat Aug 17 00:25:08 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (ary_new): len*sizeof(VALUE) may be a positive value.
+
+ * array.c (rb_ary_initialize): ditto.
+
+Fri Aug 16 15:58:16 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (NOFILE): define NOFILE as 64 if not defined.
+
+ * signal.c (sighandler_t): rename to sh_t on dietlibc.
+
+Fri Aug 16 15:37:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bignum.c (rb_cstr_to_inum): new decimal and octal string.
+
+Fri Aug 16 13:17:11 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_class_allocate_instance): move singleton class
+ check from rb_obj_alloc().
+
+Fri Aug 16 11:47:24 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (rb_io_fread): renamed from io_fread and made extern.
+
+ * marshal.c (r_bytes0): check if successfully read, use
+ rb_io_fread() instead of fread() to be preemptive.
+ (ruby-bugs-ja:PR#294, 295)
+
+ * rubyio.h (rb_io_fread): added.
+
+Fri Aug 16 07:57:26 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (compile_error): must not clear ruby_sourcefile here.
+ (ruby-bugs:PR#364).
+
+ * eval.c (rb_longjmp): set ruby_sourcefile before making
+ backtrace.
+
+Thu Aug 15 20:38:58 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (ruby_current_node) : added to set sourceline on demand.
+
+ * eval.c (error_pos, error_print, rb_longjmp, assign): set source
+ file/line.
+
+ * eval.c (rb_eval): store current node instead of file/line, and
+ preserve it at return.
+
+ * eval.c (module_setup): ditto.
+
+ * eval.c (struct thread): store node instead of file/line.
+
+ * eval.c (rb_thread_raise): ditto.
+
+ * intern.h (ruby_current_node): added.
+
+ * intern.h (ruby_set_current_source): added.
+
+ * parse.y (stmt, arg): not fix position of assignment.
+
+ * parse.y (node_assign): ditto.
+
+ * parse.y (yycompile): clear current node.
+
+Thu Aug 15 00:48:46 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_initialize): should not modify frozen Regexp.
+
+Tue Aug 13 18:33:18 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/tcltklib/tcltklib.c (ip_init): allocation framework.
+
+Tue Aug 13 15:32:14 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_replace): should copy ifnone.
+
+ * hash.c (rb_hash_dup): should preserve HASH_PROC_DEFAULT and
+ HASH_DELETED flags.
+
+ * hash.c (rb_hash_shift): shift from empty hash should not return
+ its default proc.
+
+ * hash.c (rb_hash_default_proc): new method. [new]
+
+Tue Aug 13 00:37:11 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_aref): no need for Bignum check.
+
+ * array.c (rb_ary_aset): explicit Bignum check removed.
+
+ * numeric.c (fix_aref): normalize bignum before bit-op.
+
+ * bignum.c (rb_big_rand): max may be Bignum zero.
+
+ * bignum.c (rb_cstr_to_inum): should normalize bignums, to avoid
+ returning fixable bignum value.
+
+ * bignum.c (rb_uint2big): there should be no zero sized bignum.
+
+Mon Aug 12 23:45:28 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/extmk.rb.in: extmake() that works properly for both tkutil
+ (tk/tkutil.so) and digest/sha1.
+
+Mon Aug 12 22:29:35 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ruby.c (set_arg0): Correct the position of #endif.
+
+Mon Aug 12 17:25:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_equal): should check HASH_PROC_DEFAULT too.
+
+Mon Aug 12 16:15:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * bignum.c (rb_big_cmp): raise for NaN. (ruby-bugs-ja:PR#284).
+
+Sun Aug 11 09:34:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): set line number from all nodes.
+
+ * eval.c (proc_to_s): show source file/line if available.
+
+ * marshal.c (r_object): register TYPE_BIGNUM regardless real type.
+
+Sat Aug 10 23:47:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_cmp): use dbl2big() for Floats, instead of
+ big2dbl().
+
+ * bignum.c (Init_Bignum): rb_big_zero_p() removed. There may be
+ Bignum zero.
+
+Fri Aug 9 13:31:40 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/Win32API/extconf.rb: check existence of <windows.h>.
+
+Thu Aug 8 09:37:02 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb (NilClass): must provide conversion block.
+
+ * lib/optparse.rb (String): ditto.
+
+Thu Aug 8 00:45:15 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call0): new argument added for original method name.
+ preserve original method name in frame->orig_func.
+
+ * eval.c (is_defined): use frame->orig_func, not last_func.
+
+ * eval.c (rb_eval): ditto.
+
+ * eval.c (method_call): supply data->oid also to rb_call0().
+
+ * object.c (rb_class_allocate_instance): call rb_obj_alloc() when
+ called from alias, thus invoke original "allocate".
+
+ * eval.c (remove_method): removing allocate from classes should
+ cause NameError.
+
+Wed Aug 7 22:12:54 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/optparse.rb (OptionParser::Completion::convert): returned
+ all values not first one.
+
+ * lib/optparse.rb (OptionParser::Switch::parse): return values as
+ is.
+
+ * lib/optparse.rb (OptionParser::order): ditto.
+
+ * lib/optparse/time.rb: prior time.rb.
+
+ * lib/optparse/uri.rb: require standard uri module. thanks to
+ Minero Aoki.
+
+Wed Aug 7 09:51:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_equal): should check default values.
+
+Wed Aug 7 08:44:32 2002 Minero Aoki <aamine@loveruby.net>
+
+ * ext/racc/cparse/cparse.c: reduce goto.
+
+Tue Aug 6 15:19:39 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * string.c (rb_str_rindex): must return -1 if unmatched.
+
+Mon Aug 5 22:41:18 2002 Minero Aoki <aamine@loveruby.net>
+
+ * MANIFEST: add lib/racc/parser.rb.
+
+ * ext/racc/cparse/cparse.c: code refine.
+
+ * ext/racc/cparse/MANIFEST: add depend.
+
+Sun Aug 4 22:30:50 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/curses/curses.c: follow allocation framework.
+
+Sat Aug 3 21:23:56 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): set constant in cbase scope.
+
+ * eval.c (assign): ditto.
+
+Fri Aug 2 09:12:32 2002 Minero Aoki <aamine@loveruby.net>
+
+ * ext/strscan/strscan.c: follow allocation framework.
+
+Fri Aug 2 01:21:52 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (s_recvfrom): update RSTRING len.
+
+Thu Aug 1 17:47:15 2002 Tachino Nobuhiro <tachino@jp.fujitsu.com>
+
+ * parse.y (tokadd_string): ignore backslashed spaces in %w.
+
+Thu Aug 1 14:14:15 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_find): do not use rb_eval_cmd(); should not accept
+ a string for if_none.
+
+Wed Jul 31 14:11:43 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_undef): undef should be done for klass, not ruby_class.
+
+Tue Jul 30 19:48:51 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-accurate-end-of-block): restrict search
+ region.
+
+ * misc/ruby-mode.el (ruby-parse-partial): reversed wrong patch.
+
+Tue Jul 30 17:21:13 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-accurate-end-of-block): incomplete block
+ caused infinite loop.
+
+ * misc/ruby-mode.el (ruby-parse-partial): returns nil unless
+ delimiters found.
+
+Tue Jul 30 15:24:07 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/tcltklib/stubs.c (ruby_tcltk_stubs): win32_getenv returns
+ the same address always, so allocate string by ruby_strdup.
+
+ * win32/win32.c: prototype; rb_w32_open_osfhandle().
+
+Tue Jul 30 09:11:07 2002 Minero Aoki <aamine@loveruby.net>
+
+ * eval.c (rb_thread_join_m): add parameter type declaration.
+
+Tue Jul 30 08:37:11 2002 Minero Aoki <aamine@loveruby.net>
+
+ * eval.c (localjump_error): add parameter type declaration.
+
+Mon Jul 29 16:00:54 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in: always use File.expand_path for $top_srcdir.
+
+Sat Jul 27 23:07:52 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_to_int): default to_int implementation for every
+ numeric class.
+
+Sat Jul 27 08:09:03 2002 Booker C. Bense <bbense@slac.stanford.edu>
+
+ * re.c (rb_reg_quote): initial part of the string was never copied
+ to the quoted string.
+
+Fri Jul 26 23:03:53 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): no need to convert to string twice.
+
+Fri Jul 26 18:32:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-expr-beg): wrong indent at modifiers
+ after ?.
+
+Fri Jul 26 16:01:16 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in (create_makefile): use Regexp in gsub.
+
+ * sample/mkproto.rb: ditto and fix bug.
+
+Fri Jul 26 14:31:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * random.c: replace with Mersenne Twister RNG.
+
+Fri Jul 26 12:14:48 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y (yylex): modify to accept a code like "m (a){...}".
+
+Thu Jul 25 09:05:02 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-delimiter): include here document.
+
+ * misc/ruby-mode.el (ruby-deep-arglist): skips spaces after
+ parenthesis when 'space.
+
+ * misc/ruby-mode.el (ruby-imenu-create-index): fix for nested
+ classes.
+
+ * misc/ruby-mode.el (ruby-accurate-end-of-block): added. scan a
+ block in the order.
+
+ * misc/ruby-mode.el (ruby-expr-beg): support for here document.
+
+ * misc/ruby-mode.el (ruby-parse-partial): splitted from
+ ruby-parse-region.
+
+ * misc/ruby-mode.el (ruby-move-to-block): skips RD style comments.
+
+Wed Jul 24 09:47:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (jump_tag_but_local_jump): preserve retval in
+ LocalJumpError exceptions.
+
+ * parse.y (command): no more check for "super outside of method".
+
+ * eval.c (rb_mod_define_method): should set last_class and
+ last_func in the block->frame.
+
+Mon Jul 22 17:23:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (error_handle): should handle TAG_THROW as well.
+
+Fri Jul 19 10:52:32 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): new decimal notation '0d4567'.
+
+Thu Jul 18 11:52:02 2002 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/ftp.rb (set_socket): new method.
+
+Thu Jul 18 06:51:24 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y (yylex): fix typo.
+
+Wed Jul 17 18:41:28 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): new octal notation '0o777'.
+
+Mon Jul 15 18:36:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (string_content): every string_content node should
+ return string only. use NODE_EVSTR to coercing.
+
+ * eval.c (rb_eval): NODE_EVSTR support.
+
+Mon Jul 15 10:35:35 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y (heredoc_identifier): fix typo.
+
+Sat Jul 13 09:30:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (literal_concat_string): wrong optimization.
+
+Sat Jul 13 01:25:38 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/resolv.rb (Resolv::DNS::open, close): new.
+
+ * lib/optparse.rb, lib/optparse: import.
+
+Fri Jul 12 06:34:05 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: rename HTTP.get_uri get_response.
+
+ * lib/net/http.rb: HTTP.get_print accepts URI objects.
+
+ * lib/net/http.rb: HTTP.get had not work with URI objects.
+
+Fri Jul 12 02:15:58 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * string.c (rb_str_match): fix for string match.
+
+Fri Jul 12 00:02:50 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/stringio/stringio.c (strio_gets_internal): fixed for record
+ separator longer than 1.
+
+Thu Jul 11 17:59:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_quote): avoid unnecessary string allocation.
+
+ * string.c (get_pat): quote metacharacters before compiling a
+ string into a regex.
+
+ * string.c (rb_str_split_m): special treatment of strings of size
+ 1, but AWK emulation. now uses get_pat().
+
+ * string.c (rb_str_match_m): quote metacharacters.
+
+ * string.c (rb_str_match2): ditto.
+
+Thu Jul 11 12:59:23 2002 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/resolv.rb: untaint strings read from /etc/hosts and
+ /etc/resolv.conf to prevent SecurityError when $SAFE==1.
+
+Thu Jul 11 09:00:43 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_slice_bang): if there's no corresponding
+ substring, slice! should return nil without exception.
+
+Tue Jul 9 20:03:55 2002 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * irb 0.9
+
+Sat Jul 6 07:35:02 2002 Jamie Herre <jfh@gettysgroup.com>
+
+ * array.c (rb_ary_insert): type fixed.
+
+Fri Jul 5 09:17:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_split_m): accept separator value nil as well.
+
+Fri Jul 5 08:59:15 2002 Michal Rokos <michal@ruby-lang.org>
+
+ * enum.c: Fix bug in enum_sort_by and some code indents
+
+Fri Jul 5 05:00:40 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/cgi.rb (CGI#initialize): improvement for mod_ruby.
+ thanks to Sean Chittenden <sean@ruby-lang.org>, Shugo Maeda
+ <shugo@modruby.net>
+
+Fri Jul 5 00:10:09 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_become): was leaking memory.
+
+Thu Jul 4 23:43:26 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y: remove useless function str_extend_p().
+
+Wed Jul 3 14:26:40 2002 Sean Chittenden <sean@ruby-lang.org>
+
+ * lib/net/ftp.rb (get): new method.
+
+ * lib/net/ftp.rb (putt): ditto.
+
+ * lib/net/ftp.rb (binary): ditto.
+
+ * lib/net/ftp.rb (binary=): ditto.
+
+Wed Jul 3 13:57:53 2002 Sean Chittenden <sean@ruby-lang.org>
+
+ * lib/net/ftp.rb (getbinaryfile): the second argument (localfile)
+ is now optional.
+
+ * lib/net/ftp.rb (gettextfile): ditto.
+
+Wed Jul 3 13:45:42 2002 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/ftp.rb: use &block and yield for speed.
+
+Wed Jul 3 02:32:31 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/cgi.rb (CGI#initialize): improvement for mod_ruby.
+
+Tue Jul 2 14:53:10 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_include_module): should not alter other
+ classes/modules by inclusion. by this fix, local order may not
+ be preserved for some cases.
+
+ * class.c (include_class_new): module may be T_ICLASS; retrieve
+ original module information.
+
+Tue Jul 2 14:13:11 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/cgi.rb (CGI#header): accept any type as value.
+
+Sun Jun 30 17:05:29 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (seekdir, telldir): add ac_cv_func_telldir=yes,
+ ac_cv_func_seekdir=yes for MinGW.
+
+Sat Jun 29 01:43:32 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * io.c (pipe_finalize, pipe_popen): two-way pipe support for win32.
+
+ * win32/win32.c (ChildRecord, FindFreeChildSlot): ditto.
+
+ * win32/win32.c, win32/win32.h (pipe_exec): new function for two-way
+ pipe support for win32.
+
+ * win32/win32.c, win32/win32.h (FindPipedChildSlot, rb_w32_popen,
+ rb_w32_pclose): removed functions for two-way pipe support for win32.
+
+Fri Jun 28 23:49:34 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * pack.c (pack_unpack): change names of local variables because their
+ names are overlapped.
+
+Fri Jun 28 17:54:07 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb: fix object address.
+
+Thu Jun 27 23:55:50 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/win32.c (rb_w32_stat): fix buffer overflow. (ruby-bugs:PR#329)
+
+Thu Jun 27 20:57:45 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/prettyprint.rb, lib/pp.rb: convenience methods added.
+
+Thu Jun 27 15:22:18 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/prettyprint.rb: re-implemented for incremental output to handle
+ huge data. API is changed a bit.
+
+ * lib/pp.rb: adapt new pretty printing API.
+
+Thu Jun 27 08:28:18 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (literal_concat_string): non-string last expression in
+ #{} was ignored when followed by literal.
+
+Thu Jun 27 03:42:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_expr_str): need to process backslashes properly.
+
+Wed Jun 26 17:33:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_any_to_a): declare Object#to_a to be obsolete.
+
+ * object.c (rb_Array): do not convert nil into [] automagically.
+
+Wed Jun 26 15:40:00 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (words, qwords): word list literal rules.
+
+ * parse.y (parse_string): ditto.
+
+ * parse.y (yylex): %W: word list literal with interpolation. [new]
+
+Tue Jun 25 18:53:34 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (string1, xstring, regexp): moved lex_strnest
+ initialization to string_contents/xstring_contents.
+
+Tue Jun 25 19:24:38 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * dln.c: remove definition rb_loaderror().
+
+Tue Jun 25 00:34:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_Integer): use "to_int" instead of
+ "to_i". [experimental]
+
+ * object.c (nil_to_f): new method.
+
+ * object.c (rb_Integer): Symbols and nil should cause error.
+
+ * object.c (rb_Float): nil should cause error.
+
+Tue Jun 25 00:21:00 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * dln.c: remark definition rb_loaderror().
+
+Tue Jun 25 00:14:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (string_dvar): allow back references in interpolation.
+
+Mon Jun 24 16:32:31 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_eval): NODE_EVSTR is no longer used.
+
+ * eval.c (eval): not enforce to make assigned variables dynamic.
+
+ * parse.y (string): split rules to strings/xstring/regexp to allow
+ arbitrary statements inside string interpolation.
+
+ * parse.y (here_document): splitted into three phases.
+
+ * parse.y (literall_append, literal_concat): added.
+ append/concatenate string literals.
+
+ * sample/test.rb (valid_syntax): adjust line number for BEGIN.
+
+ * lib/mkmf.rb (create_makefile): get rid of nested string.
+
+ * lib/mkmf.rb (install_rb): site-install didn't work properly.
+
+Sun Jun 23 00:19:10 2002 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb, sample/cal.rb, sample/goodfriday.rb:
+ updated to the new version (based on date2 3.3).
+
+Sat Jun 22 14:41:33 2002 Guy Decoux <ts@moulon.inra.fr>
+
+ * ext/socket/socket.c (sock_addrinfo): make all 3 versions of
+ getaddrinfo happy. [ruby-core:00184]
+
+Fri Jun 21 18:49:58 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): __END__ should not be effective within
+ string literals.
+
+Thu Jun 20 21:09:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/readline/readline.c (readline_readline): get rid of
+ libreadline's bug. (ruby-bugs-ja:PR#268)
+
+Thu Jun 20 17:10:27 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/ftool.rb (BUFSIZE): tuning, set buffer length to 8192.
+
+ * configure.in (__NO_ISOCEXT): add for mingw-runtime 2.0-2.
+
+ * configure.in (__MSVCRT__): removed because it is defined
+ in the GCC specs.
+
+Wed Jun 19 14:46:18 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb, lib/mkmf.rb (xsystem): open the log file if xsystem
+ is called.
+
+Wed Jun 19 01:01:13 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (here_document): should be aware of __END__ within here
+ documents.
+
+Wed Jun 19 00:50:50 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (yylex): ? followed by successive word characters is
+ ternary operator not numeric literal.
+
+ * parse.y (yylex): commands after break/next/rescue can take
+ arguments. (ruby-bugs-ja:PR#265)
+
+Tue Jun 18 19:20:16 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/mkexports.rb: remove unnecessary exports. (ruby-dev:17418)
+
+Tue Jun 18 12:50:17 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (yylex): should pushback proper char after '<<'.
+
+ * parse.y (range_op, cond0, cond): get rid of doubled warnings.
+
+ * parse.y (value_expr): reduce recursion level.
+
+ * parse.y (logop): ditto.
+
+Mon Jun 17 11:11:34 2002 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * string.c (rb_str_crypt): result need not be tainted always.
+
+Mon Jun 17 10:51:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * dln.c (dln_load): need to preserve dln_strerror() result,
+ calling other dl family can clear it.
+
+Sat Jun 15 22:56:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): obsolete '?<whitespace>'; use '?\s', '?\n',
+ etc, instead.
+
+Sat Jun 15 18:51:13 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * dir.c (glob_helper): Use lstat() instead of stat() so it catches
+ a dead symlink. Given a dead symlink named "a", Dir.glob("?")
+ did catch it but Dir.glob("a") somehow didn't.
+
+Sat Jun 15 01:59:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): no here document after a dot.
+
+ * parse.y (yylex): should have set lex_state after '`'.
+
+ * parse.y (yylex): should have set lex_state properly after
+ tOP_ASGN.
+
+Fri Jun 14 21:01:48 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * bcc32/mkexports.rb: insert sleep(1) for win9x.
+
+ * bcc32/configure.bat: change return code LF -> CRLF for win9x.
+
+ * win32/win32.c: fix rb_w32_open_osfhandle()
+
+Fri Jun 14 15:22:19 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (read_escape): deny zero-width hexadecimal character.
+ (ruby-bugs-ja:PR#260)
+
+ * parse.y (tokadd_escape): ditto.
+
+ * regex.c (re_compile_pattern): ditto.
+
+Fri Jun 14 00:49:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big2dbl): return canonical HUGE_VAL for infinity.
+
+Thu Jun 13 09:43:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (svalue_to_avalue): v may be Qundef. This fix was
+ suggested by Guy Decoux.
+
+Thu Jun 13 00:33:49 2002 takuma ozawa <metal@mine.ne.jp>
+
+ * hash.c (rb_hash_s_create): use rb_hash_aset() instead of calling
+ st_insert() directly, to dup&freeze string keys.
+
+Thu Jun 13 00:12:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): proper error message for "@@0".
+
+ * parse.y (yylex): paren to parse_string() must be zero for
+ unparenthesized strings.
+
+ * parse.y (str_extend): broken string when unterminated "#{".
+
+ * enum.c (enum_sort_by): had a bug in 1 element enumeration.
+
+Wed Jun 12 18:04:44 2002 akira yamada <akira@arika.org>
+
+ * uri/common.rb (REGEXP::PATTERN::X_ABS_URI): 'file:/foo' is valid.
+
+ * uri/generic.rb (Generic#xxx=): should return substituted value.
+ (ruby-dev:16728.)
+
+ * test/generic.rb (test_set_component): added tests for the above
+ change.
+
+Wed Jun 12 02:38:00 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (stmt): fix typo.
+
+Wed Jun 12 01:10:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): 'do' should return kDO_BLOCK on EXPR_ENDARG.
+
+ * parse.y (singleton): "def (()).a end" dumped core.
+
+ * parse.y (range_op): node may be null.
+
+ * parse.y (match_gen): ditto.
+
+Tue Jun 11 19:20:34 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (LIBRUBY): rename to lib$(LIBRUBY_SO).a on Cygwin/MinGW.
+
+ * configure.in, cygwin/GNUmakefile: use dllwrap when --disable-shared
+ is specified.
+
+Tue Jun 11 17:12:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): void value check for "..", "...", "!", and "not".
+
+ * parse.y (match_gen): void value check for "=~".
+
+ * parse.y (value_expr): check NODE_AND and NODE_OR recursively.
+
+ * parse.y (cond0): void value check added for conditionals.
+
+Tue Jun 11 13:18:47 2002 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/ftp.rb (noop): new method.
+
+ * lib/net/ftp.rb (site): ditto.
+
+Tue Jun 11 13:15:41 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * bcc32/Makefile.sub: set PROCESSOR_LEVEL to 6 if it's too big value.
+
+ * win32/Makefile.sub: ditto.
+
+Tue Jun 11 12:37:46 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * bcc32/configure.bat fix.
+
+Tue Jun 11 10:18:23 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
+
+ * new platform [bccwin32] merged.
+ - create new folder bcc32
+ - modify any files for bccwin32
+ error.c, file.c, hash.c, io.c, instruby.rb,
+ ext/extmk.rb.in,
+ lib/mkmf.rb, lib/ftools.rb,
+ ext/digest/defs.h,
+ ext/dl/depend, ext/dl/dl.c, ext/dl/sym.c, ext/dl/extconf.rb,
+ ext/socket/extconf.rb,
+ ext/pty/extconf.rb,
+ ext/tcltklib/extconf.rb
+ ext/Win32API/Win32API.c,
+ win32/dir.h, win32/win32.c, win32/win32.h, win32/resource.rb
+
+Mon Jun 10 19:02:19 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * numeric.c (fix_lshift): negative shift count means right shift.
+ (ruby-bugs-ja:PR#248)
+
+ * numeric.c (fix_rshift): return -1 when left side operand is
+ negative. (ruby-bugs-ja:PR#247)
+
+ * parse.y (yylex): `0_' should be an error. (ruby-bugs-ja:PR#249)
+
+Mon Jun 10 01:53:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): ruby_frame->last_func may be null, if it's
+ called outside of a method.
+
+ * parse.y (arg): use INT2NUM, not INT2FIX for tUMINUS.
+
+ * parse.y (arg): unnecessary negative tPOW treatment.
+
+ * parse.y (tokadd_escape): wrong backslash escapement.
+
+Sun Jun 9 17:40:41 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl: change the callback mechanism.
+
+Sat Jun 8 00:48:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (stmt,arg): too much void value check.
+
+ * parse.y (stmt,arg): need to check void value on rules which does
+ not use node_assign().
+
+Thu Jun 6 19:50:39 2002 KONISHI Hiromasa <H_Konishi@ruby-lang.org>
+
+ * sample/biorhythm.rb (getPosiiton,etc)
+ fix at changing Date module ( Date is changed Fixnum to Rational )
+
+Thu Jun 6 17:42:39 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (ipaddr): need not to taint hostnames.
+
+Thu Jun 6 12:04:30 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub (config.status): use sub! instead of []= because
+ []= causes exception.
+
+Thu Jun 6 11:42:15 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * lib/thread.rb (Queue::pop): get rid of race condition.
+
+Wed Jun 5 01:56:47 2002 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: Stop the running zombi-eventloop when
+ mainloop_watchdog is killed.
+
+Tue Jun 4 23:09:24 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_include): should be based on "<=>", whereas
+ member? still is based on "each".
+
+ * range.c (range_min,range_max): redefine methods based on "<=>".
+
+Tue Jun 4 18:28:37 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/extconf.rb: The IPv6 stack of Cygwin is still incomplete.
+
+ * ext/Win32API/extconf.rb: refactoring.
+
+Tue Jun 4 07:03:33 2002 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkfont.rb: Fix bugs on TkFont.init_widget_font for Tk8.x.
+
+ * ext/tk/lib/tkafter.rb: Add self to 1st argument of interval-
+ and loop-proc
+ TkAfter#current_interval returns an interval (sleep) time value
+ TkAfter#current_args returns an array of arguments
+ TkAfter#return_value returns a return value of last loop-proc
+
+ * ext/tk/lib/tk*.rb: Allow to use Symbols for parameters.
+
+ * ext/tk/lib/tkcanvas.rb: (TkcItem) Add 'coords' parameter to the
+ canvas item constructor (for new notation of constructor).
+
+ * ext/tcltklib/tcltklib.c: New 'mainloop' and 'mainloop_watchdog'.
+
+ * ext/tk/lib/tk.rb: (Tk.restart) Add 'app-name' paramater and
+ 'use' parameter.
+
+ * ext/tk/lib/tk.rb: Add new parameter 'widgetname' to the widget
+ constructor to support effective use of Resource Database.
+
+ * ext/tk/lib/tk.rb: TkOption::get always returns a tainted string.
+
+Tue Jun 4 00:45:50 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/socket/addrinfo.h: typo.
+
+ * ext/socket/getaddrinfo.c (gai_strerror): make literals const.
+
+ * ext/socket/socket.c (init_inetsock): ensures resources are
+ freed at exceptions.
+
+ * ext/socket/socket.c (init_unixsock): ditto.
+
+ * ext/socket/socket.c (udp_connect): ditto.
+
+Mon Jun 3 20:39:51 2002 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+
+ * ext/win32ole/extconf.rb : change PLATFORM with RUBY_PLATFORM.
+
+Mon Jun 3 07:07:07 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (here_document): check if identifier is terminated.
+ (ruby-bugs-ja:PR#239)
+
+ * parse.y (yylex): should pushback proper char after '**'.
+ (ruby-bugs-ja:PR#240)
+
+Mon Jun 3 05:56:17 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_aset): should raise error if an indexing string
+ is not found in the receiver.
+
+ * sprintf.c (rb_f_sprintf): "%d" should convert objects into
+ integers using Integer().
+
+Sat Jun 1 19:20:07 2002 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+
+ * ext/win32ole: merge from rough.
+
+Fri May 31 17:11:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/tempfile.rb (Tempfile::size): added.
+
+Thu May 30 12:52:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_step): iteration done using "+" if elements are
+ Numeric. Otherwise using "succ".
+
+ * range.c (range_each): iteration done using "succ". If the
+ elements does not respond to "succ", raise TypeError. As a
+ result, all Enumerable methods, e.g. collect, require elements
+ to respond to "succ".
+
+ * range.c (range_member): comparison done using "each", if
+ elements are non-Numeric or no-"succ" objects. Otherwise
+ compare using "<=>".
+
+ * range.c (Init_Range): remove "size" and "length".
+
+Thu May 30 09:16:36 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/cgi.rb: if StringIO is usable then use it.
+
+Wed May 29 18:55:47 2002 KONISHI Hiromasa <H_Konishi@ruby-lang.org>
+
+ * function renames my* and win32_* to rb_w32_* in win32/win32.c
+ fixed files win32/win32.c, win32/win32.h, win32/dir.h,
+ hash.c, rubysig.h, signal.c, ext/socket/socket.c
+
+Wed May 29 17:32:55 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * time.c (tmcmp, search_time_t): activate unless HAVE_TIMEGM.
+
+Wed May 29 13:45:15 2002 Wakou Aoyama <wakou@ruby-lang.org>
+
+ * lib/cgi.rb: not use const if GET, HEAD. check multipart form head.
+
+Tue May 28 17:56:02 2002 Sean Chittenden <sean@ruby-lang.org>
+
+ * parse.y: yyparse #defines moved from intern.h
+
+ * ruby.c (proc_options): access prefixed "ruby_yydebug".
+
+ * applied modifies to pacify some of gcc -Wall warnings.
+
+Tue May 28 14:07:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): no more ugly hack for "**", so that "-2**2" to be
+ parsed as "(-2)**2", whereas "- 2**2" or "-(2)**2" to be parsed
+ as "-(2**2)".
+
+ * parse.y (yylex): '-2' to be literal fixnum. [new]
+
+Tue May 28 12:13:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (scope_node): trick to keep the node has a scope.
+
+ * eval.c (rb_eval): NODE_EVSTR: write back local_tbl to the node.
+
+ * eval.c (rb_eval): NODE_SCOPE: hold the scope node in ruby_scope.
+
+ * eval.c (module_setup): ditto.
+
+ * eval.c (rb_call0): ditto.
+
+ * node.h (NEW_DASGN, NEW_DASGN_CURR): remove surplus semicolons.
+
+Fri May 24 09:06:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_arg): nil test against v[6] (usec).
+
+Thu May 23 16:39:21 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ruby.c (proc_options): option parsing problem.
+ (ruby-bugs-ja:PR#233)
+
+Thu May 23 09:13:56 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.c (proc_options): removed "-*-" support for #! line.
+
+ * io.c (rb_io_s_sysopen): new method to get a raw file
+ descriptor. [new]
+
+ * ext/socket/socket.c (tcp_sysaccept): new method to return an
+ accepted socket fd (integer). [new]
+
+ * ext/socket/socket.c (unix_sysaccept,sock_sysaccept): ditto.
+
+Wed May 22 21:26:47 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ruby.c (proc_options): -T consumes digits only.
+
+Wed May 22 20:18:31 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: need not link vsnprintf.o on MinGW.
+
+Wed May 22 18:34:23 2002 Minero Aoki <aamine@loveruby.net>
+
+ * parse.y (yylex): Here-document label ate '-'.
+
+Tue May 21 13:25:18 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-font-lock-keywords): symbols end with
+ '_'.
+
+Tue May 21 04:48:37 2002 Sean Chittenden <sean@chittenden.org>
+
+ * lib/cgi-lib.rb: Checking for constant MOD_RUBY instead of
+ environment variable. Remove a mod_ruby warning and use
+ Apache::request.headers_out[] instead.
+
+Tue May 21 01:16:46 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (bodystmt): ensure clause was executed on else clause
+ without rescue clause.
+
+Tue May 21 00:20:25 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl/ptr.c: rename PtrData::alloc to PtrData::malloc.
+
+ * ext/dl/lib/dl/struct.c: rename Struct#alloc to Struct#malloc.
+
+Mon May 20 14:29:14 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): should do exact match for Module#==.
+
+ * compar.c (cmp_eq): returns 'false' if <=> returns 'nil'.
+
+ * compar.c (cmp_gt,cmp_ge,cmp_lt,cmp_le,cmp_between): ditto.
+
+Mon May 20 13:28:52 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * io.c (rb_io_clone): writing stream was not copied properly.
+
+Sat May 18 21:38:11 2002 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb, lib/date/format.rb, lib/parsedate.rb:
+ updated to the new version (based on date2 3.2.1).
+
+Sat May 18 21:18:00 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub (config.h): add VC++4/5 support about noreturn
+ directive.
+
+Sat May 18 02:16:41 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_pack): should propagate taintedness.
+
+ * pack.c (pack_unpack): ditto.
+
+Fri May 17 16:16:19 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * sample/test.rb: use eval instead of './miniruby -c',
+ in order to check a syntax error.
+
+Thu May 16 14:46:34 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_select): cleanup conditional compilation.
+
+Wed May 15 06:13:35 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_schedule): need to preserve errno before
+ calling rb_trap_exec().
+
+ * regex.c (calculate_must_string): a bug in charset/charset_not
+ parsing.
+
+Tue May 14 18:17:44 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * win32/Makefile.sub: config.h inlined. and catch up with the
+ latest change.
+
+ * win32/config.h.in: no longer used.
+
+Tue May 14 14:49:05 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * gc.c (is_pointer_to_heap): avoid GCC 3.1 warnings.
+
+ * missing/strftime.c (timezone): it should take no argument on Cygwin.
+
+Tue May 14 03:07:35 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_clear_cache_by_class): new function.
+
+ * eval.c (set_method_visibility): should have clear cache for
+ updated visibility.
+
+Mon May 13 14:38:33 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * djgpp/config.hin, djgpp/config.sed: catch up with the latest change.
+
+Mon May 13 01:59:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (flo_to_s): default format precision to be "%.16g".
+
+ * util.c (ruby_strtod): use own strtod(3) implementation to avoid
+ locale hell. Due to this change "0xff".to_f no longer returns 255.0
+
+Sun May 12 03:01:08 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * missing.h: add for missing/*.c.
+
+ * ruby.h: add `#include "missing.h"'.
+
+ * Makefile.in: add the dependency of missing.h by gcc -MM.
+
+ * MANIFEST: add missing.h
+
+Sat May 11 23:24:52 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl: enable dl's stack emulation for constructing function call.
+
+Sat May 11 10:52:09 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * dir.c (glob_helper): remove escaping backslashes.
+
+Sat May 11 02:46:43 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (avalue_to_yvalue): new function to distinguish yvalue
+ (no-arg == Qundef) from svalue (no-arg == Qnil).
+
+ * eval.c (rb_yield_0): use avalue_to_yvalue().
+
+ * eval.c (assign): warn if val == Qundef where it means rhs is
+ void (e.g. yield without value or call without argument).
+
+Fri May 10 19:00:47 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * parse.y (here_document): preserve line number begins here
+ document.
+
+Fri May 10 01:55:44 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_thread_join): added an argument to limit time to wait
+ the thread.
+
+ * eval.c (rb_thread_join_m): new. and added optional argument.
+
+Wed May 8 23:48:40 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (value_expr): need not to warn for WHILE and UNTIL,
+ since they can have return value (via valued break).
+
+Tue May 7 17:13:40 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: forgot to add '-Wl,' to the gcc option on Cygwin/MinGW.
+
+Tue May 7 15:41:33 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/iconv/iconv.c (iconv_try): should initialize exceptions
+ properly. (ruby-bugs-ja:PR#232)
+
+Tue May 7 15:28:03 2002 Minero Aoki <aamine@loveruby.net>
+
+ * eval.c (rb_yield_0): The destination of the goto jump was wrong.
+
+Tue May 7 09:17:51 2002 Minero Aoki <aamine@loveruby.net>
+
+ * eval.c (superclass): undesirable "unexpected return" when the
+ superclass is not a Class.
+
+Sun May 5 06:53:45 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/mkmf.rb: exclude topdir from the system configuration
+ section and prevent it from being overridden.
+
+Fri May 3 20:19:00 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: add #include <errno.h> in AC_CHECK_DECLS().
+
+ * win32/config.h.in: define HAVE_DECL_SYS_NERR.
+
+Thu May 2 23:42:40 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_s_quote): # also should be quoted.
+
+Thu May 2 18:27:13 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: use 'do...end' instead of '{}' for
+ Borland make.
+
+Thu May 2 08:01:56 2002 Chris Thomas <kenshin@apple.com>
+
+ * error.c: use HAVE_DECL_SYS_NERR instead of platform names.
+
+Tue Apr 30 09:23:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_step): better iteration condition for float
+ values; suggested by Masahiro TANAKA <masa@ir.isas.ac.jp>.
+
+Tue Apr 30 05:59:42 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * range.c (range_step): step (for Range#step method) <= 0 makes no
+ sense, thus ArgError will be raised.
+
+ * range.c (range_each): Range#each method is special case for
+ Range#step(1)
+
+Mon Apr 29 18:46:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_find_file): load must be done from an absolute path if
+ $SAFE >= 4.
+
+Sun Apr 28 17:01:56 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c (insert): fix prototype for ANSI C.
+
+Fri Apr 26 13:47:15 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_partition): new method. [new]
+
+Fri Apr 26 13:41:00 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_s_quote): quote whitespaces for /x cases.
+
+Fri Apr 26 06:48:23 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl/ptr.c (cary2ary): missing break in switch statements.
+
+Fri Apr 26 09:35:47 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_proc_new): make Proc from C function. [new]
+
+ * intern.h (rb_proc_new): prototype.
+
+Wed Apr 24 14:56:46 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (proc_to_proc): return self. [new]
+
+ * eval.c (block_pass): no need to convert if block is Proc.
+
+Wed Apr 24 14:21:41 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: set size of the initial stack from
+ 2MB to 32MB on MinGW/Cygwin.
+
+Wed Apr 24 14:06:35 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_step): try to reduce residual on Float operations.
+
+Wed Apr 24 06:48:31 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * io.c (rb_io_mode_flags): both 'r+b' and 'rb+' should be allowed.
+
+ * io.c (rb_io_mode_modenum): ditto.
+
+Wed Apr 24 01:16:14 2002 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/stringio/stringio.c (strio_mark): must check if ptr is NULL
+ first. [ruby-talk:38873]
+
+ * lib/mkmf.rb (create_makefile): should print depend file when
+ make is other than nmake.
+
+Wed Apr 24 00:37:12 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/extmk.rb.in (create_makefile): use `{$(srcdir)}' directive instead
+ of `$(srcdir)/' when including depend file.
+
+ * lib/mkmf.rb (create_makefile): add `{$(srcdir)}' when including depend
+ file.
+
+Tue Apr 23 12:58:18 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_memerror): rename from mem_error, and exported.
+
+ * gc.c (Init_GC): pre-allocate NoMemoryError instance.
+
+ * object.c (convert_type): error message changed from "failed to
+ convert" to "cannot convert", since it does not try to convert
+ if an object does not respond to the converting method.
+
+Mon Apr 22 09:31:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (block_pass): convert Method to Proc using
+ rb_check_convert_type().
+
+ * object.c (rb_check_convert_type): always convert T_DATA
+
+ * eval.c (rb_thread_cleanup): should not terminate main_thread by
+ Fatal error.
+
+ * regex.c (is_in_list): need to not exclude NUL and NEWLINE.
+
+Sat Apr 20 00:19:13 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_expr_str): wrong backslash escapement.
+
+ * re.c (rb_reg_expr_str): do not escape embedded space
+ characters.
+
+Fri Apr 19 22:03:40 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub: add -DNT to $CFLAGS instead of $CPPFLAGS.
+
+ * win32/setup.mak: ditto.
+
+Fri Apr 19 17:24:22 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): T_DATA process patch from Joel VanderWerf
+ <vjoel@PATH.Berkeley.EDU>. This is temporary hack; it remains
+ undocumented, and it will be removed when marshaling is
+ re-designed.
+
+ * marshal.c (r_object): ditto.
+
+Fri Apr 19 17:10:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_step): Integer#step is moved to Numeric#step;
+ Fixnum#step is merged into this method.
+
+ * numeric.c (int_dotimes): Fixnum#times is merged.
+
+ * numeric.c (int_upto): Fixnum#upto is merged.
+
+ * numeric.c (int_downto): Fixnum#downto is merged.
+
+Fri Apr 19 16:22:55 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/extconf.rb: include <windows.h>, <winsock.h> on _WIN32.
+
+ * win32/win32.c: include <mswsock.h> on __MINGW32__.
+
+ * configure.in: cleanup for autoconf 2.5x.
+
+ * configure.in: use gcc -shared instead of dllwrap on Cygwin/MinGW.
+
+ * ext/extmk.rb, lib/mkmf.rb: get rid of "--def=".
+
+Fri Apr 19 14:57:44 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * re.c (rb_reg_to_s): remove redundant shy group.
+
+Fri Apr 19 01:08:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_cleanup): current thread may be THREAD_STOPPED,
+ for example when terminated from signal handler.
+
+Thu Apr 18 19:03:15 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): remove /p support.
+
+ * regex.h: ditto.
+
+ * parse.y (parse_regx): ditto.
+
+Thu Apr 18 17:01:43 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl/ptr.c (rb_dlptr_cast): removed.
+
+Thu Apr 18 17:01:43 2002 Tanaka Akira <akr@m17n.org>
+
+ * re.c (rb_reg_to_s): new function for Regexp#to_s.
+
+Wed Apr 17 23:55:34 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/Setup*, ext/bigfloat/*: Back out the import of BigFloat in
+ favor of its forthcoming successor, BigDecimal.
+
+Wed Apr 17 16:53:33 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_expr_str): should treat backslash specially in
+ escaping.
+
+Wed Apr 17 08:16:41 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * io.c: complete off_t handling; missing argument for
+ fptr_finalize(); polished rb_scan_args call.
+
+Wed Apr 17 00:01:59 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * dir.c: wrap multi-statement macro by do { } while (0)
+
+ * eval.c, numeric,c, sprintf.c, util.c: ditto.
+
+Tue Apr 16 08:59:50 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (assign): convert mrhs to mvalue.
+
+Mon Apr 15 18:12:57 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_eq): check `y == x' if y is neither Fixnum,
+ Bignum, nor Float.
+
+Mon Apr 15 09:27:31 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_unpack): should treat 'U' in character unit, not in
+ byte unit.
+
+ * error.c (exc_initialize): should clear backtrace information.
+
+Sat Apr 13 23:42:43 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_fptr_cleanup): should close IO created by IO.new(fd).
+
+ * rubyio.h: remove FMODE_FDOPEN
+
+Fri Apr 12 12:54:04 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * win32/Makefile.sub: use missing/acosh.c.
+
+ * win32/config.h.in: define HAVE_COSH, HAVE_SINH, and HAVE_TANH.
+
+Fri Apr 12 02:58:55 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * struct.c (rb_struct_select): fix typo.
+
+Fri Apr 12 00:34:17 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * MANIFEST (missing/acosh.c): added.
+
+ * Makefile.in (missing/acosh.c): ditto.
+
+ * Makefile.in (missing/fileblocks.c): ditto.
+
+ * configure.in (AC_REPLACE_FUNCS): check acosh() on behalf of
+ inverse hyperbolic functions, asinh() and atanh().
+
+ * missing/acosh.c: added for acosh(), asinh() and atanh().
+
+Thu Apr 11 20:01:44 2002 Masahiro Tomita <tommy@tmtm.org>
+
+ * io.c (io_write): check error if written data is less than
+ specified size to detect EPIPE.
+
+Thu Apr 11 19:10:37 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (remain_size): IO#read returns "" if file.size == 0.
+
+ * random.c (rand_init): add check for initstate(3).
+
+ * configure.in: ditto.
+
+Thu Apr 11 09:31:19 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl/ptr.c: raise() -> rb_raise(). (Thanks Tetsuya Watanabe)
+
+ * ext/dl/sym.c: ditto.
+
+Thu Apr 11 07:57:48 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * eval.c (assign): ruby_verbose should be surrounded by RTEST().
+
+ * object.c (rb_str2cstr): ditto.
+
+ * parse.y (void_expr): ditto.
+
+ * parse.y (void_stmts): ditto.
+
+ * variable.c (rb_ivar_get): ditto.
+
+ * variable.c (rb_cvar_set): ditto.
+
+ * variable.c (rb_cvar_get): ditto.
+
+Thu Apr 11 07:02:31 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl: Add dl.txt instead of README and README.html.
+
+Thu Apr 11 01:55:52 2002 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi/session.rb: support for multipart form.
+
+Wed Apr 10 18:42:23 2002 Tachino Nobuhiro <tachino@jp.fujitsu.com>
+
+ * dir.c (glob_helper): should have proceed link when link->path
+ was non existing symbolic link.
+
+Wed Apr 10 17:30:19 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_obj_remove_instance_variable): raise NameError if
+ specified instance variable is not defined.
+
+ * variable.c (generic_ivar_remove): modified to check ivar
+ existence.
+
+Wed Apr 10 14:16:45 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * misc/ruby-mode.el (ruby-font-lock-keywords): fontify symbols for
+ unary operators and aset.
+
+Tue Apr 9 13:40:31 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * lib/mkmf.rb (try_link0): need expand macro in command, sync with
+ ext/extmk.rb.in.
+
+ * lib/mkmf.rb (try_cpp): ditto.
+
+ * lib/mkmf.rb (egrep_cpp): ditto.
+
+Tue Apr 9 12:44:59 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/stringio/stringio.c (check_modifiable): performance
+ improvement. avoid calling rb_str_modify() twice.
+
+ * ext/stringio/stringio.c (strio_ungetc): ditto.
+
+ * ext/stringio/stringio.c (strio_putc): ditto.
+
+ * ext/stringio/stringio.c (strio_write): ditto, and use
+ rb_str_cat() as possible.
+
+Tue Apr 9 05:17:48 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * re.c (match_select): fix index references and make
+ MatchData#select actually work.
+
+Tue Apr 9 00:20:52 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_file_s_extname): new method based on the proposal
+ (and patch) from Mike Hall. [new]
+
+Mon Apr 8 04:50:51 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (error_handle): default to 1 unless status is set.
+
+ * eval.c (ruby_options): guard error_handle() with PROT_NONE.
+
+ * eval.c (ruby_stop): ditto.
+
+Mon Apr 8 01:22:24 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * math.c (math_acosh): added. [new]
+
+ * math.c (math_asinh): ditto.
+
+ * math.c (math_atanh): ditto.
+
+ * struct.c (rb_struct_each_pair): method added. [new]
+
+Sat Apr 6 02:04:49 2002 Guy Decoux <ts@moulon.inra.fr>
+
+ * class.c (rb_singleton_class): wrong condition; was creating
+ unnecessary singleton class.
+
+Sat Apr 6 01:09:41 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * sprintf.c (remove_sign_bits): simplifies the condition.
+
+ * bignum.c (get2comp): calculate proper carry over.
+
+Fri Apr 5 05:07:28 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl: Add dl/struct.rb.
+
+Thu Apr 4 14:08:52 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl/lib/dl/import.rb: Get rid of ineffective
+ encoding/decoding procedures.
+
+Thu Apr 4 01:08:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (int_step): step may be a float less than 1.
+
+Wed Apr 3 20:42:34 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl: Merge Nakada's patch.
+
+ * ext/dl/dl.h: define StringValuePtr for ruby-1.6.
+
+Wed Apr 3 15:37:24 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl: Add dl/types.rb.
+
+Wed Apr 3 01:54:10 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/extmk.rb.in (enable_config): follow lib/mkmf.rb.
+
+Tue Apr 2 19:59:13 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl: Merge from rough.
+
+Tue Apr 2 15:17:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * Makefile.in (CPPFLAGS): remove @includedir@.
+
+ * lib/mkmf.rb (create_makefile): ditto.
+
+ * ext/extmk.rb.in (create_makefile): ditto.
+
+Tue Apr 2 15:09:05 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/socket.c (sock_addrinfo): should clear addrinfo hints.
+
+Mon Apr 1 23:48:12 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * lib/mkmf.rb: install any files using $INSTALLFILES.
+ (see also [ruby-dev:16683])
+
+Mon Apr 1 17:25:50 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_fptr_cleanup): need flush even when io will not be
+ closed.
+
+ * io.c (rb_io_initialize): was calling wrong function
+ rb_io_mode_flags().
+
+Mon Apr 1 16:52:00 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/sdbm/init.c (each_pair): moved prototype before the
+ definition.
+
+ * ext/racc/cparse/cparse.c (call_scaniter): ditto.
+
+Mon Apr 1 15:11:40 2002 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * ext/racc/cparse/cparse.c: prototype; call_scaniter().
+
+ * ext/sdbm/init.c: prototype; each_pair().
+
+ * ext/tcltklib/tcltklib.c: prototypes; _timer_for_tcl() and ip_ruby(),
+ Nobu's patch at [ruby-dev:14483].
+
+Mon Apr 1 10:56:40 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (match_setter): it's OK to assign nil to $~.
+
+Mon Apr 1 03:55:46 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_fptr_cleanup): do not close IO created by for_fd().
+
+ * io.c (rb_io_initialize): mark IO created by for_fd
+
+ * ext/socket/socket.c (bsock_s_for_fd): ditto.
+
+Fri Mar 29 20:21:58 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * lib/mkmf.rb (create_makefile): default FLAGS to empty strings.
+
+Fri Mar 29 16:36:52 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * lib/mkmf.rb (arg_config): should use Shellwords::shellwords like
+ ext/extmk.rb.in.
+
+ * lib/mkmf.rb (enable_config): default had priority over command
+ line options and configure_args.
+
+ * lib/mkmf.rb: support autoconf 2.53 style variables from
+ environment.
+
+ * lib/mkmf.rb: add directory options.
+
+Fri Mar 29 15:49:29 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/README.win32: follow recent changes.
+
+Fri Mar 29 14:44:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_fflush): DRY patch from /Christoph applied.
+
+Thu Mar 28 18:58:13 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/Makefile.sub (config.status): reflect user defined $CC in
+ config.status.
+
+Thu Mar 28 18:03:51 2002 Minero Aoki <aamine@loveruby.net>
+
+ * ext/strscan/strscan.c: add taint check.
+
+ * ext/strscan/strscan.c: #getch/#get_byte should set regexp
+ registers.
+
+ * ext/strscan/strscan.c: remove useless #include directive.
+
+ * ext/strscan/strscan.c: refactor struct strscanner.
+
+Thu Mar 28 14:51:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (sock_addrinfo): should specify socktype
+ from outside.
+
+Wed Mar 27 17:04:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_binmode): should call next_argv() to initialize ARGF.
+
+ * io.c (argf_filename): ditto.
+
+ * io.c (argf_file): ditto.
+
+Wed Mar 27 14:47:32 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (READ_DATA_PENDING): configure.in has supported for uClibc,
+ so remove uClibc stuff.
+
+Wed Mar 27 13:14:43 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_sysseek): new method based on a patch from Aristarkh
+ A Zagorodnikov <xm@bolotov-team.ru>. [new]
+
+ * io.c (READ_DATA_PENDING): use !feof(fp) for default behavior.
+
+Tue Mar 26 20:28:50 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: HTTP.get accepts URI.
+
+ * lib/net/http.rb: new method HTTP.get_uri.
+
+ * lib/net/http.rb: add some HTTP 1.1 response codes.
+
+Tue Mar 26 20:25:28 2002 Minero Aoki <aamine@loveruby.net>
+
+ * doc/net/protocol.rd.ja, smtp.rd.ja, pop.rd.ja: removed.
+
+ * MANIFEST: remove doc/net/* entries.
+
+Tue Mar 26 18:45:15 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (FILE_READPTR): check bufread instead of bufend
+ for uClibc.
+
+ * ext/extmk.rb.in (arg_config): should use Shellwords::shellwords.
+
+Tue Mar 26 01:56:33 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (primary): while/until statement modifiers to "begin"
+ statement now work as "do .. while" even when begin statement
+ has "rescue" or "ensure" [new].
+
+ * parse.y (bodystmt): rescue/ensure is allowed at every bodies,
+ i.e. method bodies, begin bodies, class bodies[new], and module
+ bodies[new].
+
+Mon Mar 25 22:10:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (sock_addrinfo): should specify ai_socktype
+ for getaddrinfo hints.
+
+Mon Mar 25 17:18:48 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * dir.c (rb_push_glob): local variable 'maxnest' was
+ uninitialized.
+
+Mon Mar 25 16:53:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_abort): embed aborting message into exception
+ object [new].
+
+ * eval.c (terminate_process): utility function for exit and abort.
+
+Tue Mar 26 14:04:47 2002 okabe katsuyuki <HGC02147@nifty.ne.jp>
+
+ * win32/mkexports.rb: support VC++.NET.
+
+Tue Mar 26 14:00:17 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/bigfloat/bigfloat.c: Fix the initializer's function name
+ according to the new library name. (pointed out by nobu)
+
+Tue Mar 26 11:12:01 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/fileutils.rb: new file.
+
+Tue Mar 26 03:23:50 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb (pp): return nil like p.
+
+Tue Mar 26 01:48:01 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/bigfloat/extconf.rb: Downcase the library name. (BigFloat.so
+ -> bigfloat.so)
+
+ * ext/bigfloat/bigfloat.c (BigFloat_inspect): Alter the inspect
+ format not to look like an array. (pointed out by akr)
+
+ * ext/bigfloat/bigfloat.c (BigFloat_hash): Implement BigFloat#hash.
+
+ * ext/bigfloat/bigfloat.c (BigFloat_dump, BigFloat_load):
+ Support marshaling.
+
+Tue Mar 26 00:38:11 2002 Tanaka Akira <akr@m17n.org>
+
+ * configure.in (FILE_READPTR): check _p for 4.4BSD.
+
+Mon Mar 25 23:39:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * configure.in (FILE_READPTR): new. for IO#gets improvement.
+
+ * io.c (READ_DATA_PENDING_PTR): ditto.
+
+ * io.c (remain_size): separated from read_all().
+
+ * io.c (read_all): argument changed.
+
+ * io.c (appendline): new. get a line and append to string.
+
+ * io.c (swallow): new. swallow continuous line delimiters.
+
+ * io.c (rb_io_getline_fast): add delimiter argument.
+
+ * io.c (rb_io_getline): performance improvement.
+
+Mon Mar 25 19:30:25 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in (arg_config): get rid of single quotes
+ for autoconf 2.53.
+
+Mon Mar 25 17:49:41 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * regex.c (mbc_startpos_func): VC6 seems to be unable to
+ understand forward declaration for static variables.
+
+ * dir.c (rb_push_glob): local variable 'maxnest' was
+ uninitialized.
+
+Mon Mar 25 13:24:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (bsock_do_not_rev_lookup_set): should not be
+ allowed when $SAFE > 3.
+
+ * eval.c (rb_thread_ready): THREAD_TO_KILL threads should not turn
+ into THREAD_RUNNABLE on wakeup.
+
+ * eval.c (rb_thread_list): THREAD_TO_KILL threads should be in the
+ list.
+
+ * eval.c (thgroup_list): ditto; by moving gid clearance from
+ rb_thread_cleanup().
+
+Mon Mar 25 11:06:19 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * dln.c (dln_argv0): unused unless USE_DLN_A_OUT.
+
+ * regex.c (mbc_startpos_func): should be static.
+
+Sun Mar 24 12:19:09 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * dir.c (fnmatch): "*/bar" (with FNM_PATHNAME flag) does not
+ match "foo/bar".
+
+Sun Mar 24 00:46:05 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * util.c (push_element): avoid warning for djgpp.
+
+Sat Mar 23 01:50:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (read_all): files on /proc filesystem with zero stat size,
+ may have contents.
+
+Fri Mar 22 18:07:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): refactored.
+
+ * ext/socket/socket.c (sock_s_gethostbyname): ditto.
+
+Fri Mar 22 16:46:54 2002 Minero Aoki <aamine@loveruby.net>
+
+ * ext/extmk.rb.in: replace mkdir with mkpath to compile racc/cparse.
+
+Fri Mar 22 16:22:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * the VMS support patch submitted by Akiyoshi, Masamichi
+ <Masamichi.Akiyoshi@jp.compaq.com> is merged.
+
+Fri Mar 22 16:27:24 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/racc/parser.rb: new file.
+
+ * ext/racc/MANIFEST, cparse.c, depend, extconf.rb: new files.
+
+ * lib/README: add racc/parser.rb.
+
+ * ext/Setup*: add racc/cparse.
+
+Fri Mar 22 15:04:03 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (exec_under): changing ruby_class is OK, but should not
+ alter cbase.
+
+ * eval.c (yield_under_i): ditto.
+
+Fri Mar 22 15:44:38 2002 Minero Aoki <aamine@loveruby.net>
+
+ * ext/strscan/MANIFEST, strscan.c, depend, extconf.rb: new files.
+
+ * ext/Setup*: add strscan entry.
+
+Fri Mar 22 14:32:14 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: Protocol#start should return self.
+
+Fri Mar 22 14:14:21 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/resolv.rb: fix arguments to create exceptions.
+ Patch from matt@lickey.com. (ruby-bugs:PR#278)
+
+Fri Mar 22 13:51:11 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/bigfloat/.cvsignore, ext/bigfloat/MANIFEST: BigFloat 1.1.8
+ has been imported. Add .cvsignore and MANIFEST.
+
+Fri Mar 22 04:07:55 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * sprintf.c (rb_f_printf): discard meaningless prefix ".." for '%u'.
+
+Thu Mar 21 01:11:37 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/Makefile.sub (config.status): fix install path (prefix).
+
+Thu Mar 21 01:03:05 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/configsub.rb: latest autoconf style support.
+
+Wed Mar 20 22:16:25 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * mkconfig.rb: close duplicated $stdout before renaming rbconfig.rb.
+
+Wed Mar 20 21:54:17 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * win32/Makefile.sub: made variables configurable.
+
+ * win32/Makefile.sub (config.h): updates RUBY_PLATFORM from
+ Makefile.
+
+ * win32/Makefile.sub (config.status): ditto. and use recent
+ autoconf format.
+
+ * win32/Makefile.sub (clean): separate ext and local clean up.
+
+ * win32/Makefile.sub (distclean): ditto.
+
+ * win32/config.status.in: no longer used.
+
+Wed Mar 20 20:12:35 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * variable.c (rb_const_list): a temporary table must be freed.
+
+Wed Mar 20 19:44:09 2002 Tanaka Akira <akr@m17n.org>
+
+ * mkconfig.rb: don't touch rbconfig.rb if there is a trouble.
+
+Wed Mar 20 16:05:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (is_defined): should check receiver only once.
+
+ * eval.c (is_defined): should handle NODE_NEWLINE.
+
+Wed Mar 20 11:29:25 2002 Aristarkh A Zagorodnikov <xm@xml-objects.com>
+
+ * file.c (rb_file_s_expand_path): memory leak fixed.
+
+Wed Mar 20 00:36:43 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * util.c (ruby_getcwd): the content of buf is uncertain and must
+ not be printed when getcwd(buf, size) has failed.
+
+Mon Mar 18 22:19:52 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/stringio/stringio.c (check_modifiable): wrong declaration.
+
+Mon Mar 18 18:04:05 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/digest: add depend file.
+
+ * ext/digest/md5: ditto.
+
+ * ext/digest/rmd160: ditto.
+
+ * ext/digest/sha1: ditto.
+
+ * ext/digest/sha2: ditto.
+
+ * ext/iconv/MANIFEST: ditto.
+
+ * ext/stringio/MANIFEST: ditto.
+
+ * ext/syslog: ditto.
+
+Mon Mar 18 17:18:06 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_f_abort): should not bypass cleanup.
+
+ * ext/stringio/stringio.c (check_modifiable): void function.
+
+Mon Mar 18 12:52:01 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/iconv/extconf.rb: workaround for GNU libiconv.
+
+Mon Mar 18 10:55:03 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (parse_string): part of multi-byte sequence must not
+ match to paren.
+
+ * parse.y (parse_qstring): ditto.
+
+ * parse.y (parse_quotedwords): ditto.
+
+ * parse.y (str_extend): handle multi-byte characters.
+
+Mon Mar 18 10:31:20 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * enum.c (enum_find): catch a value before recycle.
+
+ * enum.c (enum_all): ditto.
+
+ * enum.c (enum_any): ditto.
+
+ * enum.c (enum_min): ditto.
+
+ * enum.c (enum_max): ditto.
+
+Sun Mar 17 20:08:04 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/iconv/depend: added.
+
+ * ext/stringio/depend: added.
+
+Sat Mar 16 22:43:53 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * missing/fileblocks.c: add for autoconf.
+
+Sat Mar 16 15:30:40 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_search): should clear last_match if pos is out of
+ string range.
+
+ * string.c (rb_str_index_m): ditto.
+
+ * string.c (rb_str_rindex): ditto.
+
+Sat Mar 16 09:04:58 2002 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * enum.c (enum_inject): use the first iterated element as the
+ initial value when omitted.
+
+ * enum.c (inject_i): ditto.
+
+ * enum.c (Init_Enumerable): Enumerable#inject now takes variable
+ count arguments.
+
+Fri Mar 15 19:47:31 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * win32/win32.c (StartSockets): remove duplicated lines.
+
+Fri Mar 15 17:44:08 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * bignum.c, intern.h (rb_ull2big, rb_ll2big, rb_ull2inum, rb_ll2inum,
+ big2ull, rb_big2ull, rb_big2ll): use LONG_LONG macro instead of
+ long long.
+
+ * numeric.c, intern.h, ruby.h (rb_num2ll, rb_num2ull): ditto.
+
+ * ruby.h: use _I64_MAX and _I64_MIN if they are defined (for VC++).
+
+Fri Mar 15 14:02:43 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/iconv/iconv.c: fixed document, Iconv#new is no longer an
+ iterator. thanks to Tanaka Akira <akr@m17n.org>.
+
+Thu Mar 14 22:17:45 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/iconv: imported.
+
+Thu Mar 14 16:42:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_define_class): should handle autoload.
+
+ * class.c (rb_define_module): ditto.
+
+Thu Mar 14 16:18:12 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: autoconf 2.53 support. use AC_LIBOBJ.
+
+Thu Mar 14 00:29:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_match): should clear $~ if operand is nil.
+
+ * re.c (rb_reg_match2): ditto.
+
+Thu Mar 14 12:32:59 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/stringio/stringio.c: fixed frozen string bug. ungetc no
+ longer raises on readonly stream unless modifies actually.
+
+Thu Mar 14 08:57:41 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * dir.c (rb_push_glob): avoid SEGV when a block given.
+
+Thu Mar 14 00:16:02 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * string.c (rb_str_subpat_set): must make str independent after
+ rb_reg_search() matched.
+
+Wed Mar 13 19:05:15 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * dir.c: FNM_PERIOD is obsoleted and FNM_DOTMATCH is introduced
+ instead, which has the opposite meaning of FNM_PERIOD.
+
+ * dir.c: Dir::glob now accepts optional FNM_* flags via the second
+ argument, whereas Dir::[] doesn't.
+
+Wed Mar 13 18:36:55 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/getopts.rb: single_options can be nil[*], and is not not
+ optional. ([*]Pointed out by gotoken)
+
+Wed Mar 13 17:23:46 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * configure: merge Jonathan Baker's large file support patch
+ [ruby-talk:35316], with read_all patch in [ruby-talk:35470].
+
+Wed Mar 13 04:06:48 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_abort): optional message argument that be printed
+ on termination.
+
+Tue Mar 12 17:12:06 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/resolv.rb: don't complete domains for absolute FQNs.
+
+Mon Mar 11 23:08:48 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/tsort.rb: new file.
+
+Mon Mar 11 21:03:37 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/stringio: new.
+
+Mon Mar 11 18:03:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): '\0111' should be '\011' plus '1',
+ since octal literals are formed by three digits at most.
+
+Mon Mar 11 14:44:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): module inclusion using extend() should
+ also be detected.
+
+ * eval.c (rb_eval_cmd): cbase should not be NULL; it should be
+ either ruby_wrapper or Object.
+
+Sun Mar 10 02:18:22 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * enum.c (enum_each_with_index): should return self.
+
+ * process.c (proc_setpgrp): should return value for non-void function.
+
+ * process.c (proc_getpgid): should raise exception if getpgid() return -1.
+
+ * string.c (rb_str_ljust): should return a duplicated string.
+
+ * string.c (rb_str_rjust): ditto.
+
+ * string.c (rb_str_center): ditto.
+
+Sat Mar 9 08:45:58 2002 Tanaka Akira <akr@m17n.org>
+
+ * ext/socket/extconf.rb (have_struct_member): don't print checked
+ result.
+
+Fri Mar 8 12:19:15 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/resolv.rb: use its own thread group for background threads.
+
+Fri Mar 8 02:21:32 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (cvar_cbase): utility function to find innermost non
+ singleton cbase.
+
+ * eval.c (is_defined): adopt new cvar behavior.
+
+ * eval.c (rb_eval): ditto.
+
+ * eval.c (assign): ditto.
+
+Thu Mar 7 20:08:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * gc.c (rb_source_filename): added. holds unique strings for file
+ names with GC space.
+
+ * gc.c (rb_gc_mark): mark source file name.
+
+ * gc.c (gc_sweep): ditto.
+
+ * gc.c (Init_GC): initialize source file name table.
+
+ * intern.h (rb_source_filename): added.
+
+ * eval.c (rb_eval_string): use rb_source_filename().
+
+ * parse.y (yycompile): ditto.
+
+ * ruby.c (proc_options): ditto.
+
+ * ruby.c (load_file): ditto.
+
+ * ruby.c (ruby_script): ditto.
+
+ * ruby.c (ruby_prog_init): ditto.
+
+Wed Mar 6 17:58:08 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dln.c (dln_load): use LoadLibrary instead of LoadLibraryEx.
+
+Wed Mar 6 16:50:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_mod_clone): should not call rb_obj_clone(), since
+ Module does not provide "allocate".
+
+ * class.c (rb_singleton_class): should create new singleton class
+ if obj is a class or module and attached object is different,
+ which means metaclass of singleton class is sought.
+
+ * time.c (time_s_alloc): now follows allocation framework.
+
+Tue Mar 5 05:56:29 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/getopts.rb: Rewrite to fix some bugs and complete features.
+ - Accept options with the colon in the first argument;
+ getopts("a:bcd:") is equivalent to getopts("bc", "a:", "d:").
+ - Do not discard the argument that caused an error.
+ - Do not discard '-', which commonly stands for stdin or stdout.
+ - Allow specifying a long option with a value using '='.
+ (command --long-option=value)
+ - Stop reading options when it meets a non-option argument.
+
+Mon Mar 4 13:19:18 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in (dir_config): Sync with mkmf.rb: Fix a bug where
+ --with-xx-{include,lib} is ignored when --with-xx-dir is
+ specified.
+
+Mon Mar 4 00:09:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should initialize outer class variables from
+ methods in singleton class definitions.
+
+ * eval.c (assign): ditto.
+
+Fri Mar 1 11:29:10 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/{addinfo.h,getaddrinfo.c} (gai_strerror): add const
+ qualifier only for uClibc.
+
+Fri Mar 1 11:22:51 2002 Amos Gouaux <amos+ruby@utdallas.edu>
+
+ * lib/net/imap.rb: added document.
+
+ * lib/net/imap.rb (getquotaroot): new method.
+
+ * lib/net/imap.rb (setacl): remove the rights if the rights
+ parameter is nil.
+
+ * lib/net/imap.rb (getacl): return an array of MailboxACLItem.
+
+Fri Mar 1 06:25:49 2002 Tanaka Akira <akr@m17n.org>
+
+ * ext/socket/extconf.rb (have_struct_member): new method.
+ check msg_control and msg_accrights in struct msghdr. check
+ sys/uio.h.
+
+ * ext/socket/socket.c: include sys/uio.h if available.
+ (thread_read_select): new function.
+ (unix_send_io): ditto.
+ (unix_recv_io): ditto.
+ (unix_s_socketpair): ditto.
+ (Init_socket): define UNIXSocket#send_io, UNIXSocket#recv_io,
+ UNIXSocket.socketpair and UNIXSocket.pair.
+
+ * dln.c (dln_load): fix typo.
+
+Wed Feb 27 16:30:50 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_include): load modules in argument order.
+
+ * st.c (st_init_table_with_size): num_bins should be prime numbers
+ (no decrement).
+
+ * st.c (rehash): ditto.
+
+Wed Feb 27 13:18:49 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * io.c (READ_DATA_PENDING): uClibc support.
+
+ * random.c (rand_init): ditto.
+
+ * ext/socket/{addinfo.h,getaddrinfo.c} (gai_strerror): ditto.
+
+Wed Feb 27 07:05:17 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/sha2/sha2.c: Merge from rough. Fix a couple of
+ off-by-one errors in Aaron Gifford's code.
+
+ Obtained from: KAME via FreeBSD
+ KAME PR: 393
+ FreeBSD PR: kern/34242
+
+Wed Feb 27 03:36:47 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * ext/dbm/dbm.c (fdbm_select): 1.7 behavior.
+
+ * ext/gdbm/gdbm.c (fgdbm_select): ditto.
+
+ * ext/sdbm/sdbm.c (fsdbm_select): ditto.
+
+ * ext/dbm/dbm.c (fdbm_delete): adopt Hash#delete behavior.
+
+ * ext/sdbm/sdbm.c (fsdbm_delete): ditto.
+
+ * ext/gdbm/gdbm.c: need not to dup key to the block.
+
+ * ext/sdbm/sdbm.c : replace RuntimeError with SDBMError.
+
+Tue Feb 26 21:34:07 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * bignum.c (rb_big_2comp): void function cannot return any value.
+
+Tue Feb 26 16:52:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_missing): NoMethod error messages for true, false,
+ nil must respond visibility like for other objects.
+
+Tue Feb 26 15:41:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): call trace_func for if/while conditions.
+
+ * marshal.c (r_object): separate r_regist from proc calling.
+
+Tue Feb 26 11:25:50 2002 akira yamada <akira@arika.org>
+
+ * lib/uri/generic.rb: merge0 should return [oth, oth] if oth is
+ absolute URI.
+
+ * lib/uri/generic.rb: registry part must not be allowed for any
+ schemes for the Internet. (RFC2396, section 3.2.2 and 3.2.1.)
+
+Mon Feb 25 21:22:41 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/syslog/syslog.c: Merge from rough. Use SafeStringValue().
+
+Mon Feb 25 21:12:08 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/syslog/syslog.c: Merge from rough. Turn Syslog into a
+ module keeping backward compatibility intact.
+
+Mon Feb 25 19:35:48 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * sample/test.rb (system): test with scripts under the source
+ directory.
+
+Mon Feb 25 15:14:01 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (method_inspect): should not dump core for unbound
+ singleton methods.
+
+ * object.c (rb_mod_to_s): better description.
+
+Mon Feb 25 13:32:13 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * lib/shell.rb (Shell::expand_path): relative to @cwd.
+
+Mon Feb 25 06:30:11 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * hash.c (env_select): should path the assoc list.
+
+Sun Feb 24 17:20:22 2002 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/*/*.h: Merge from rough.
+ - Avoid namespace pollution. (MD5_* -> rb_Digest_MD5_*, etc.)
+
+Sat Feb 23 21:12:13 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (rb_syswait): thread kludge; should be fixed to
+ support native thread.
+
+Fri Feb 22 21:20:53 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: set read_timeout dynamically.
+
+ * lib/net/http.rb: @@newimpl is always true in the main trunk.
+
+ * lib/net/http.rb: HTTP.port -> default_port
+
+ * lib/net/http.rb: HTTPResponse.read_response_status ->
+ read_status_line
+
+Fri Feb 22 19:56:15 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/config.status.in: set LIBRUBY_SO.
+
+Fri Feb 22 03:34:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (get2comp): need to specify to carry or not.
+
+ * io.c (rb_io_inspect): embed path info.
+
+Fri Feb 22 11:30:01 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/prettyprint.rb: FillGroup implemented.
+
+Thu Feb 21 21:40:18 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * ext/extmk.rb.in (create_makefile): remove unnecessary -L option from
+ LIBS macro.
+
+Thu Feb 21 02:49:12 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * pack.c (pack_pack): wrong # comment treatment.
+
+ * pack.c (pack_unpack): ditto.
+
+Wed Feb 20 15:15:03 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * intern.h: prototypes; rb_io_addstr(), rb_io_printf(),
+ rb_io_print(), rb_io_puts()
+
+ * io.c (rb_io_addstr): make extern.
+
+ * io.c (rb_io_printf): ditto.
+
+ * io.c (rb_io_print): ditto.
+
+ * io.c (rb_io_puts): ditto.
+
+Wed Feb 20 13:41:35 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * io.c (rb_io_close): return Qnil.
+
+Wed Feb 20 12:41:59 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_any_cmp): should handle Qundef in keys.
+
+ * eval.c (remove_method): should not remove a empty method to
+ implement "undef".
+
+ * eval.c (rb_eval): should allow singleton class def for
+ true/false/nil.
+
+Tue Feb 19 21:43:32 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: rename Protocol.port to default_port.
+
+ * lib/net/smtp.rb: ditto.
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/http.rb: ditto.
+
+ * lib/net/protocol.rb: rename BufferedSocket class to
+ InternetMessageIO.
+
+ * lib/net/smtp.rb: ditto.
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/http.rb: ditto.
+
+ * lib/net/protocol.rb: rename InternetMessageIO#write_pendstr to
+ write_message.
+
+ * lib/net/smtp.rb: ditto.
+
+ * lib/net/protocol.rb: new method
+ InternetMessageIO#through_message.
+
+ * lib/net/smtp.rb: ditto.
+
+ * lib/net/protocol.rb: rename InternetMessageIO#read_pendstr to
+ read_message_to.
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/protocol.rb: rename InternetMessageIO#read_pendlist to
+ each_list_item
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/protocol.rb: Now block size is 1024.
+
+ * lib/net/smtp.rb: new methods SMTP#esmtp? and #esmtp=.
+
+ * lib/net/http.rb: Using singleton method syntax instead of
+ singleton class clause, to avoid behavior change of class
+ variables in ruby 1.7.
+
+ * lib/net/http.rb: HTTPResponse class does not inherit from
+ Net::Response.
+
+ * lib/net/http.rb: divide HTTP#connecting into
+ {begin,end}_transport.
+
+ * lib/net/http.rb: unused class Accumulator removed.
+
+ * lib/net/http.rb: Net::HTTP reads response. not HTTPRequest.
+
+ * lib/net/http.rb: proxy related class-instance-variables are not
+ initialized correctly.
+
+Tue Feb 19 20:20:12 2002 Ed Sinjiashvili <edsin@swes.saren.ru>
+
+ * parse.y (str_extend): backslash escape was done wrong.
+
+Tue Feb 19 17:10:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (path_check_1): do not fail on world writable *parent*
+ directories too.
+
+Tue Feb 19 15:51:41 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (path_check_1): do not warn on world writable *parent*
+ directories.
+
+ * class.c (rb_include_module): should preserve ancestor order in
+ the included class/module.
+
+Tue Feb 19 14:45:32 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (path_check_1): should check directory sticky bits.
+
+ * process.c (security): need not to warn twice.
+
+ * marshal.c (r_object): complete restoration before calling
+ r_regist().
+
+Tue Feb 19 14:24:36 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): operators in the "op" rule should make
+ lex_state EXPR_ARG on EXPR_FNAME and EXPR_DOT.
+
+Tue Feb 19 13:38:10 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval_string_wrap): should hide the toplevel local
+ variable bindings by PUSH_SCOPE().
+
+Tue Feb 19 13:21:51 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * regex.c: fix prototypes of xmalloc(), xcalloc() and xrealloc().
+
+Tue Feb 19 13:16:08 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * io.c (rb_io_ungetc): don't fail pushed EOF back.
+
+Mon Feb 18 20:48:40 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * pack.c (pack_pack): avoid infinite loop at comment.
+
+ * pack.c (pack_unpack): ditto.
+
+Mon Feb 18 14:06:28 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * misc/ruby-mode.el (ruby-block-hanging-re): rescue block was too
+ indented.
+
+Mon Feb 18 13:56:44 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (expr_value, arg_value, primary_value): value_expr()
+ check in place.
+
+ * eval.c (block_pass): "&nil" should clear block given.
+
+Mon Feb 18 02:05:56 2002 Wolfgang Jahrling <wolfgang@pro-linux.de>
+
+ * dir.c (push_braces): remove MAXPATHLEN dependency.
+
+ * dir.c (dir_s_globd): ditto.
+
+ * dln.c (init_funcname): ditto.
+
+ * dln.c (load_1): ditto.
+
+ * dln.c (dln_load): ditto.
+
+ * configure.in: add GNU/Hurd switches.
+
+Fri Feb 15 17:44:26 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_pack): allows comment in template strings.
+
+ * pack.c (pack_unpack): ditto.
+
+Sun Feb 17 23:41:37 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * mkconfig.rb (Config::expand): expand ${} too.
+
+ * ext/extmk.rb.in (try_link0): expand command.
+
+ * ext/extmk.rb.in (try_cpp): ditto.
+
+ * ext/extmk.rb.in (extmake): default $LIBPATH to $libdir
+
+Sun Feb 17 21:39:24 2002 Tetsuya Watanabe <tetsuya.watanabe@nifty.com>
+
+ * ext/digest/md5/md5init.c (Init_md5): rb_cvar_declare() is
+ replaced by rb_cvar_set().
+
+ * ext/digest/rmd160/rmd160init.c (Init_rmd160): ditto.
+
+ * ext/digest/sha1/sha1init.c (Init_sha1): ditto.
+
+ * ext/digest/sha2/sha2init.c (Init_sha2): ditto.
+
+Sun Feb 17 18:10:09 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * class.c (rb_define_class): warn unless superclass is specified
+ explicitly.
+
+ * class.c (rb_define_class_under): ditto.
+
+Thu Feb 16 02:11:08 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * misc/ruby-mode.el (ruby-font-lock-keywords): fontify
+ instance/class/global variables start with '_'.
+
+Fri Feb 15 14:40:38 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): replace rb_cvar_declare() by rb_cvar_set().
+
+ * eval.c (assign): ditto.
+
+ * variable.c (rb_cvar_set): 4th argument (warn) added; define new
+ class variable if it's not defined yet.
+
+ * variable.c (rb_cvar_declare): removed.
+
+Fri Feb 15 13:36:58 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_rshift): should properly convert the negative
+ value to 2's compliment.
+
+Thu Feb 14 17:38:35 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y: avoid SEGV at OP_ASIGN to pseudo variable.
+
+Thu Feb 14 14:13:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * struct.c (Init_Struct): should undefine "allocate" for Struct
+ class (it's redefined in the subclasses).
+
+Wed Feb 13 17:58:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (stmt): local variable declaration order was changed
+ since 1.6
+
+ * parse.y (arg): ditto.
+
+ * pack.c (pack_pack): add templates 'q' and 'Q'.
+
+ * pack.c (pack_unpack): ditto.
+
+ * bignum.c (rb_quad_pack): new utility function.
+
+ * bignum.c (rb_quad_unpack): ditto.
+
+Tue Feb 12 01:21:34 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (assignable): should emit CVASGN within the method
+ body.
+
+Mon Feb 11 06:13:53 2002 Matt Armstrong <matt@lickey.com>
+
+ * dir.c (dir_s_glob): should not warn even if no match found.
+
+Mon Feb 11 04:25:54 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): clean up class variable behavior.
+
+ * eval.c (assign): ditto.
+
+ * eval.c (is_defined): ditto.
+
+ * variable.c (rb_mod_class_variables): need not to call rb_cvar_singleton().
+
+ * variable.c (rb_cvar_singleton): removed.
+
+Mon Feb 11 00:10:41 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * regex.c (re_compile_fastmap): skip begpos.
+
+Sun Feb 10 16:52:53 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ruby.c (load_file): avoid SEGV on '#' only input.
+
+Fri Feb 8 23:07:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): singleton check should be moved from yycompile
+ to here.
+
+ * eval.c (is_defined): check should be added here too.
+
+Fri Feb 8 05:31:48 2002 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: HTTP.Proxy should use self for proxy-class's
+ super class.
+
+ * lib/net/http.rb: initialize HTTP.proxy_port by HTTP.port.
+
+Fri Feb 8 01:27:33 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yycompile): should inherit "in_single" if eval happened
+ in a singleton method.
+
+ * eval.c (rb_eval): class variables from singleton methods defined
+ within singleton class statement should work like ones defined
+ by singleton def statements.
+
+Thu Feb 7 13:44:08 2002 akira yamada <akira@arika.org>
+
+ * uri/common.rb (URI::join): new method.
+
+ * uri/generic.rb (Generic#merge): URI.parse("http://a/")+"b" should
+ return "http://a/b" but it returned "http://a//b".
+
+ * uri/generic.rb (Generic#check_path): corrected error message,
+ @path -> v
+
+Thu Feb 7 00:18:43 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_write): flag when buffered write is done.
+
+ * io.c (fptr_finalize): do not raise error on EBADF if write
+ buffer is empty.
+
+Wed Feb 6 17:18:54 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * configure.in: keep old config.h unless changed.
+
+Wed Feb 6 13:28:53 2002 Amos Gouaux <amos+ruby@utdallas.edu>
+
+ * lib/net/imap.rb: OpenSSL support.
+
+ * lib/net/imap.rb (setquota): unset quota if the second argument
+ is nil.
+
+Wed Feb 6 13:05:11 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_readlines): avoid calling GetOpenFile() repeatedly.
+
+ * io.c (rb_io_each_line): ditto.
+
+ * io.c (argf_getline): ditto.
+
+ * process.c: should include <time.h> to get proper CLK_TCK.
+
+Wed Feb 6 02:10:30 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * io.c (fptr_finalize): ignore EBADF when f and f2 use same
+ descriptor.
+
+Tue Feb 5 16:17:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (fptr_finalize): should raise error when fclose fails.
+
+ * eval.c (method_inspect): proper output format to distinguish
+ methods and singleton methods.
+
+Mon Feb 4 22:44:58 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (rb_file_s_expand_path): should terminate.
+
+Mon Feb 4 15:38:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_class_real): should not follow ICLASS link
+
+ * variable.c (classname): should follow ICLASS link explicitly.
+
+ * eval.c (rb_call): ditto.
+
+Fri Feb 1 19:10:04 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * intern.h: prototypes for new functions; rb_cstr_to_inum(),
+ rb_str_to_inum(), rb_cstr_to_dbl(), rb_str_to_dbl()
+
+ * bignum.c (rb_cstr_to_inum): changed from rb_cstr2inum(), and
+ added argument badcheck to be consistent with parser. [new]
+
+ * bignum.c (rb_str_to_inum): ditto.
+
+ * bignum.c (rb_cstr2inum): wrapper of rb_cstr_to_inum() now.
+
+ * bignum.c (rb_str2inum): ditto.
+
+ * object.c (rb_cstr_to_dbl): float number parser. [new]
+
+ * object.c (rb_str_to_dbl): ditto.
+
+ * object.c (rb_Float): use rb_cstr_to_dbl() for strict check.
+
+ * object.c (rb_Integer): use rb_str_to_inum() for strict check.
+
+ * string.c (rb_str_to_f): use rb_str_to_dbl() with less check.
+
+ * string.c (rb_str_to_i): use rb_str_to_inum() with less check.
+
+ * string.c (rb_str_hex): ditto.
+
+ * string.c (rb_str_oct): ditto.
+
+ * sprintf.c (rb_f_sprintf): ditto.
+
+ * time.c (obj2long): ditto.
+
+ * parse.y (yylex): use rb_cstr_to_inum() for strict check.
+
+Fri Feb 1 17:46:39 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * regex.c (mbc_startpos): become macro.
+
+ * regex.c (euc_startpos): added for improvement.
+
+ * regex.c (sjis_startpos): ditto.
+
+ * regex.c (utf8_startpos): ditto.
+
+Fri Feb 1 00:03:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_stat_inspect): print dev, rdev in hexadecimal.
+
+Thu Jan 31 20:45:33 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * lib/mkmf.rb (dir_config): prior --with flag.
+
+ * lib/mkmf.rb (arg_config): avoid special variables for
+ font-lock-mode.
+
+Thu Jan 31 13:22:36 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb (File::Stat#pretty_print): print rdev_major and rdev_minor.
+
+Wed Jan 30 15:58:04 2002 K.Kosako <kosako@sofnec.co.jp>
+
+ * regex.c (re_adjust_startpos): fix for SJIS and UTF-8.
+
+ * regex.c (mbc_startpos): ditto.
+
+Wed Jan 30 13:37:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (rb_reg_search): should set regs.allocated.
+
+Wed Jan 30 02:25:38 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * regex.c (re_adjust_startpos): search start of multibyte
+ backward.
+
+ * regex.c (mbc_startpos): ditto.
+
+Tue Jan 29 17:59:20 2002 Tanaka Akira <akr@m17n.org>
+
+ * file.c: `major' and `minor' macro needs sys/mkdev.h on SunOS 5.x.
+
+ * configure.in: add check for `sys/mkdev.h'.
+
+ * lib/pp.rb: don't print a mode File::Stat as decimal number.
+
+Mon Jan 28 19:16:58 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * array.c (rb_ary_fill): shouldn't yield unless block given.
+
+Mon Jan 28 18:33:18 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (yylex): strict check for numbers.
+
+Mon Jan 28 18:01:01 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_stat_rdev_major): added. [new]
+
+ * file.c (rb_stat_rdev_minor): added. [new]
+
+ * file.c (rb_stat_inspect): print mode in octal.
+
+Mon Jan 28 13:29:41 2002 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (is_defined): defined?(Foo::Baz) should check constants
+ only, no methods.
+
+ * eval.c (is_defined): should not dump core on defined?(a::b)
+ where a is not a class nor a module.
+
+Mon Jan 28 02:50:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): remove dup and clone from TrueClass,
+ FalseClass, and NilClass.
+
+ * array.c (rb_ary_fill): Array#fill takes block to get the value to
+ fill.
+
+Sat Jan 26 20:05:18 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_to_i): to_i(0) auto-detects base radix.
+
+ * array.c (rb_ary_initialize): fill by the block evaluation value
+ if block is given.
+
+Fri Jan 25 17:48:43 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in (solaris): add '-shared' only for GNU ld.
+
+Fri Jan 25 17:16:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_include_module): detect cyclic module inclusion.
+
+Fri Jan 25 02:17:56 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_cleanup): need not to free thread stacks at
+ process termination.
+
+ * array.c (rb_ary_fetch): use the block to get the default value
+ if the block is given.
+
+ * eval.c (rb_thread_schedule): should check time only if BOTH
+ WAIT_SELECT and WAIT_TIME.
+
+Thu Jan 24 11:49:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (umethod_bind): should update rklass field.
+
+ * hash.c (rb_hash_update): if a block is given, yields [key,
+ value1, value2] to the block to resolve conflict.
+
+Thu Jan 24 05:42:01 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * string.c (rb_str_split_m): no need to consider KANJI
+ characters, if the length of separator is 1 (byte).
+
+Wed Jan 23 16:07:31 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (Init_Array): remove Array#filter.
+
+Wed Jan 23 13:27:44 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_yield_0): restore source file/line after yield.
+
+Wed Jan 23 02:00:14 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_mod_initialize): should accept zero argument.
+
+ * object.c (rb_mod_cmp): should raise ArgumentError if
+ inheritance/inclusion relation between two classes/modules is
+ not defined. [new]
+
+Tue Jan 22 17:45:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_fsync): new method. [new]
+
+Mon Jan 21 22:57:18 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * signal.c (ruby_signal): must define sighandler_t for every
+ occasion.
+
+Mon Jan 21 08:25:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_stop): should not trace error handler.
+
+ * signal.c (install_sighandler): do not install sighandler unless
+ the old value is SIG_DFL.
+
+ * io.c (io_write): should not raise exception on O_NONBLOCK io.
+
+ * dir.c (dir_set_pos): seek should return dir, pos= should not.
+
+Sat Jan 19 02:31:45 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): need not to clear method cache for NODE_CLASS,
+ NODE_SCLASS.
+
+ * gc.c (obj_free): need not to clear method cache on class/module
+ finalization.
+
+Fri Jan 18 23:38:03 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_fetch): index out of range raises exception
+ unless optional second argument is specified.
+
+Fri Jan 18 17:32:09 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_s_new): block check moved from initialize to this
+ method.
+
+ * io.c (rb_io_s_open): open should call initialize too. IO#for_fd
+ also calls initialize. [new]
+
+Fri Jan 18 10:26:33 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (rb_sys_fail): replace INT2FIX() by INT2NUM() since
+ errno value may not fit in Fixnum size on Hurd.
+
+ * error.c (set_syserr): ditto.
+
+Fri Jan 18 10:12:00 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * ext/socket/socket.c (tcp_svr_s_open): fix typo.
+
+Fri Jan 18 02:27:48 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (dir_s_glob): returns nil if block given.
+
+ * io.c (rb_io_each_byte): should return self.
+
+ * io.c (rb_io_close_m): close check added.
+
+ * dir.c (dir_seek): should return pos.
+
+Fri Jan 18 01:21:53 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (fixpos): orig may be (NODE*)1, which should not be
+ dereferenced.
+
+Thu Jan 17 16:21:42 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (block_pass): allow "retry" from within argument passed
+ block. [new]
+
+ * eval.c (localjump_error): should preserve exit status in the
+ exception object. [new]
+
+ * eval.c (proc_invoke): should raise exception for "break" if it's
+ yielding, not calling. [new]
+
+ * eval.c (block_pass): should NOT raise exception for "break". [new]
+
+ * eval.c (block_pass): should allow block argument relay even in
+ the tainted mode.
+
+Thu Jan 17 04:51:48 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c: support subclassing by proper "initialize"
+ calling convention. [new]
+
+Wed Jan 16 18:25:08 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * st.c: primes should be primes.
+
+Wed Jan 16 12:29:14 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/timeout.rb (timeout): new optional argument to specify an
+ exception class.
+
+ * lib/resolv.rb: use Resolv::ResolvTimeout for internal timeout to
+ avoid problem with timeout of application.
+
+Wed Jan 16 11:12:30 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * object.c (rb_Float): remove underscores between digits.
+
+ * bignum.c (rb_cstr2inum): reject prefix followed by spaces only.
+
+ * class.c (rb_class_inherited): should use Object when no super
+ class.
+
+Tue Jan 15 01:11:44 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (is_defined): method defined? check should honor
+ protected too.
+
+Mon Jan 14 13:06:02 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (block_pass): should not pass tainted block, if $SAFE > 0.
+
+Sun Jan 13 09:31:41 2002 Koji Arai <jca02266@nifty.ne.jp>
+
+ * variable.c (rb_mod_remove_cvar): should pass the char*.
+
+Fri Jan 11 05:06:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * class.c (rb_make_metaclass): [new]
+
+ * class.c (rb_define_class_id): use rb_make_metaclass(), don't
+ call Class#inherited hook.
+
+ * class.c (rb_class_inherited): [new]
+
+ * class.c (rb_define_class): call Class#inherited hook here.
+
+ * class.c (rb_define_class_under): ditto after class path is set.
+
+ * class.c (rb_singleton_class): use rb_make_metaclass().
+
+ * eval.c (rb_eval): same as rb_define_class_under().
+
+ * intern.h: prototypes of rb_make_metaclass() and
+ rb_class_inherited().
+
+ * object.c (rb_class_s_new): use rb_make_metaclass() and
+ rb_class_inherited().
+
+ * object.c (Init_Object): use rb_make_metaclass().
+
+ * struct.c (make_struct): use rb_class_inherited().
+
+Thu Jan 10 19:15:15 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_add_method): should clear cache by id always.
+
+ * eval.c (rb_disable_super): no longer need to clear cache before
+ rb_add_method().
+
+ * eval.c (rb_export_method): ditto.
+
+ * eval.c (rb_attr): ditto.
+
+ * eval.c (rb_undef): ditto.
+
+ * eval.c (rb_eval): ditto.
+
+ * eval.c (rb_mod_modfunc): ditto.
+
+ * eval.c (rb_mod_define_method): ditto.
+
+Thu Jan 10 11:42:47 2002 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/resource.rb: Modify copyright in resource script.
+
+Thu Jan 10 07:15:44 2002 takuma ozawa <metal@mine.ne.jp>
+
+ * re.c (match_select): should propagate taintness.
+
+Thu Jan 10 00:54:57 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_set_default): Hash#default= should return the
+ new value.
+
+Wed Jan 9 20:21:09 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * misc/ruby-mode.el (ruby-calculate-indent): indentation after
+ comment at beginning of buffer failed.
+
+ * misc/ruby-mode.el (font-lock-defaults): unless XEmacs, set
+ font-lock variables in ruby-mode-hook.
+
+Tue Jan 8 15:56:20 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_to_i): accepts optional base argument. [new]
+
+ * numeric.c (rb_fix2str): should not handle negative fixnum values
+ int32 via calling sprintf() directly.
+
+Tue Jan 8 15:54:02 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_add_method): clear replaced method from the cache.
+
+Mon Jan 7 12:38:47 2002 Tanaka Akira <akr@m17n.org>
+
+ * lib/time.rb (Time#xmlschema): new optional argument
+ fractional_seconds to specify a number of digits of
+ fractional part of the time.
+
+Sat Jan 5 13:18:11 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * range.c (range_member): beginning check was
+ wrong. [ruby-talk:30252]
+
+Sat Jan 5 03:07:34 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_new2): NULL pointer check added.
+
+Sat Jan 5 00:19:12 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (yycompile): strdup()'ed twice.
+
+Fri Jan 4 18:29:10 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+
+ * class.c (rb_define_module_under): should locate predefined
+ module using rb_const_defined_at().
+
+Fri Jan 4 17:23:49 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * misc/ruby-mode.el (ruby-forward-string): forward a string. [new]
+
+ * misc/ruby-mode.el (ruby-parse-region): handle nested parentheses
+ in a string and terminators in #{}.
+
+ * misc/ruby-mode.el (ruby-calculate-indent): ditto.
+
+Wed Jan 2 23:34:25 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (create_makefile): add -I. to CPPFLAGS.
+
+ * lib/mkmf.rb (create_makefile): srcdir support(.def and depend file).
+
+Wed Jan 2 11:51:56 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (rb_f_system): abandon vfork.
+
+ * io.c (pipe_open): ditto.
+
+Tue Jan 1 02:16:48 2002 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/curses/extconf.rb: add dir_config.
+
+ * Makefile.in (fake.rb): set RUBY_VERSION.
+
+Mon Dec 31 14:20:46 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (yycompile): always store copy of filename.
+
+ * parse.y (rb_compile_file): no longer need to strdup() here.
+
+Mon Dec 31 05:26:40 2001 Ferris McCormick <fmccor@inforead.com>
+
+ * defines.h: sparc linux needs different FLUSH_REGISTER_WINDOWS
+
+Mon Dec 31 04:27:28 2001 Minero Aoki <aamine@mx.edit.ne.jp>
+
+ * lib/net/protocol.rb: Protocol#start returns the return value of
+ block.
+
+ * lib/net/protocol.rb: set timeout limit by default.
+
+ * lib/net/protocol.rb: new methods WriteAdapter#write, puts,
+ print, printf.
+
+ * lib/net/http.rb: rename HTTP#get2 to request_get, post2 to
+ request_post ...
+
+ * lib/net/smtp.rb: should not resolve HELO domain automatically.
+
+Sun Dec 30 00:59:16 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb (have_library): accept -lm
+ unconditionally on mswin32/mingw32.
+
+Sat Dec 29 01:55:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_search): abandon stclass optimization.
+
+Fri Dec 28 14:39:05 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * array.c (rb_cmpint): fixed typo.
+
+Thu Dec 27 18:43:04 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * bignum.c (rb_cstr2inum): deny "0_".
+
+Thu Dec 27 01:54:02 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * bignum.c (rb_cstr2inum): allow "0\n" and so on.
+
+Wed Dec 26 19:24:21 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (rb_invalid_str): utility function to show inspect()'ed
+ string.
+
+ * bignum.c (rb_cstr2inum): prints invalid strings in inspect()'ed
+ format.
+
+ * object.c (rb_Float): ditto.
+
+Wed Dec 26 02:41:29 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_convert_type): no longer use rb_rescue().
+
+Tue Dec 25 18:32:16 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * re.c (rb_reg_search): initialize taint status of match object.
+
+Tue Dec 25 02:37:49 2001 Tanaka Akira <akr@m17n.org>
+
+ * lib/pp.rb, lib/prettyprint.rb: new files.
+
+Tue Dec 25 02:11:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_convert_type): check method response check before
+ invoking rb_rescue().
+
+ * object.c (rb_check_convert_type): ditto.
+
+Mon Dec 24 02:37:40 2001 Le Wang <lewang@bigfoot.com>
+
+ * misc/ruby-mode.el (ruby-font-lock-syntactic-keywords):
+ fix font-lock problem [ruby-talk:29296].
+
+Sat Dec 22 22:52:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_timeval): wrong cast to time_t.
+
+ * time.c (time_plus): ditto.
+
+Fri Dec 21 20:33:34 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * parse.y (str_extend): make up "#$;" handling.
+
+Fri Dec 21 16:18:17 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * dln.h, ruby.h, util.h: enable prototypes in C++.
+
+Fri Dec 21 15:12:41 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_plus): result should not be negative unless
+ NEGATIVE_TIME_T is defined.
+
+ * time.c (time_new_internal): should check tv_sec overflow too.
+
+ * time.c (time_timeval): should check time_t range when time is
+ initialized from float.
+
+ * time.c (time_plus): uses modf(3).
+
+Fri Dec 21 03:15:52 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_mod_define_method): must not convert Method to Proc.
+
+Fri Dec 21 01:17:57 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * lib/mkmf.rb (with_destdir): new.
+
+ * lib/mkmf.rb: prefix target directories with $(DESTDIR) all.
+
+ * lib/mkmf.rb: no need to mkdir $(libdir)
+
+Thu Dec 20 14:08:20 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: rename Net::Socket to Net::BufferedSocket
+
+Thu Dec 20 13:51:52 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * variable.c (rb_cvar_set): add frozen class/module check.
+
+ * variable.c (rb_cvar_declare): add frozen class/module check.
+
+Thu Dec 20 01:01:50 2001 takuma ozawa <metal@mine.ne.jp>
+
+ * re.c (match_to_a): should propagate taint.
+
+ * re.c (rb_reg_s_quote): ditto.
+
+Wed Dec 19 16:58:29 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * ext/readline/readline.c: new methods
+ Readline::basic_word_break_characters,
+ Readline::basic_word_break_characters=,
+ Readline::completer_word_break_characters,
+ Readline::completer_word_break_characters=,
+ Readline::basic_quote_characters,
+ Readline::basic_quote_characters=,
+ Readline::completer_quote_characters,
+ Readline::completer_quote_characters=,
+ Readline::filename_quote_characters,
+ Readline::filename_quote_characters=.
+
+Wed Dec 19 14:05:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_define_method): define_method should follow
+ default method visibility.
+
+ * eval.c (rb_attr): should warn if the default method visibility
+ is "module_function" (can be error).
+
+ * eval.c (rb_mod_define_method): should define class/module method
+ also if the visibility is "module_function".
+
+ * eval.c (rb_mod_define_method): should call hook method
+ "method_added", and "singleton_method_added".
+
+Wed Dec 19 11:42:13 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * string.c: use RESIZE_CAPA for capacity change.
+
+Wed Dec 19 03:08:40 2001 Tanaka Akira <akr@m17n.org>
+
+ * lib/time.rb: date.rb is not required anymore.
+
+ * lib/resolv.rb: fix document. refine IPv6 regex.
+
+Tue Dec 18 23:24:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (Init_socket): add listen method to
+ TCPServer and UNIXServer.
+
+Tue Dec 18 17:54:53 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * sample/test.rb: Hash#indexes -> Hash#select.
+
+Tue Dec 18 01:02:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_schedule): should not select a thread which is
+ not yet initialized.
+
+Mon Dec 17 18:53:49 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * string.c (rb_str_replace): swap arguments of OBJ_INFECT.
+
+Mon Dec 17 16:52:20 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * intern.h: add prototypes.
+ rb_gc_enable(), rb_gc_disable(), rb_gc_start(), rb_str_new5()
+ rb_str_buf_append(), rb_str_buf_cat(), rb_str_buf_cat2(),
+ rb_str_dup_frozen()
+
+ * ruby.h: added declaration.
+ rb_defout, rb_stdin, rb_stdout, rb_stderr, ruby_errinfo
+
+ * rubyio.h: changed double include guard macro to RUBYIO_H.
+
+ * array.c (inspect_call): make static.
+
+ * eval.c (dvar_asgn): ditto.
+
+ * io.c (rb_io_close_read): ditto.
+
+ * lex.c (rb_reserved_word): ditto.
+
+ * ruby.c: (req_list_head, req_list_last): ditto.
+
+ * ruby.c (require_libraries): ditto.
+
+Mon Dec 17 15:41:24 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_plus): wrong boundary check.
+
+ * time.c (time_minus): ditto.
+
+Mon Dec 17 15:19:32 2001 Tanaka Akira <akr@m17n.org>
+
+ * time.c: new method `gmtoff', `gmt_offset' and `utc_offset'.
+ (time_utc_offset): new function.
+ (Init_Time): bind above methods to `time_utc_offset'.
+
+ * time.c: 64bit time_t support.
+ (time_s_at): use NUM2LONG instead of NUM2INT for tv_sec.
+ (time_arg): initialize tm_isdst correctly.
+ use long to initialize tm_year.
+ (search_time_t): renamed from `make_time_t'.
+ (make_time_t): call `timegm' and `mktime' instead of `search_time_t'
+ if available.
+ (time_to_i): use LONG2NUM instead of INT2NUM.
+ (time_localtime): check localtime failure.
+ (time_gmtime): check gmtime failure.
+ (time_year): use LONG2NUM instead of INT2FIX.
+ (time_to_a): use long for tm_year.
+ (time_dump): check tm_year which is not representable with 17bit.
+ (time_load): initialize tm_isdst.
+
+ * configure.in: check existence of `mktime' and `timegm'.
+ check existence of tm_gmtoff field of struct tm.
+ fix negative time_t for 64bit time_t.
+
+ * missing/strftime.c: fix overflow by tm_year + 1900.
+
+ * lib/time.rb: use Time#utc_offset.
+
+Mon Dec 17 00:02:04 2001 Guy Decoux <ts@moulon.inra.fr>
+
+ * variable.c (find_class_path): should initialize iv_tbl if it's
+ NULL.
+
+Fri Dec 14 04:23:36 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/pop.rb: new method Net::POP3.APOP
+
+ * lib/net/http.rb: set default Content-Type to
+ x-www-form-urlencoded (causes warning)
+
+ * lib/net/protocol.rb: remove Net::NetPrivate module.
+
+ * lib/net/smtp.rb: ditto.
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/http.rb: ditto.
+
+Fri Dec 14 00:16:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_define_class): should return the existing class if
+ the class is already defined and its superclass is identical to
+ the specified superclass.
+
+ * class.c (rb_define_class_under): ditto.
+
+ * class.c (rb_define_module): should return the existing module if
+ the module is already defined.
+
+Thu Dec 13 09:52:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_new_internal): avoid loop to calculate negative
+ div, mod.
+
+ * time.c (time_cmp): should handle Bignums.
+
+Tue Dec 11 17:39:16 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * array.c (rb_ary_pop): should ELTS_SHARED flag check before
+ REALLOC.
+
+Tue Dec 11 12:45:28 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_match_m): should convert an argument into
+ regexp if it's a string.
+
+Tue Dec 11 03:40:23 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_select): Array#select(n,m,...) now works like
+ Array#indexes(n,m,..). [new, experimental]
+
+ * hash.c (rb_hash_select): ditto.
+
+ * hash.c (env_select): ditto.
+
+ * re.c (match_select): ditto.
+
+ * struct.c (rb_struct_select): ditto.
+
+Tue Dec 11 03:17:19 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * object.c (rb_class_real): follow included modules.
+
+Mon Dec 10 23:37:51 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * util.h: change prototype of ruby_qsort() to accord with its
+ definition.
+
+Mon Dec 10 20:30:01 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * gc.c (STR_ASSOC): use FL_USER3 instead of FL_USER2.
+
+Mon Dec 10 17:40:02 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * parse.y (str_extend): make up pushback call.
+
+Mon Dec 10 02:09:28 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_modify): should copy the internal buffer if the
+ modifying buffer is shared.
+
+ * array.c (ary_make_shared): make an internal buffer of an array
+ to be shared.
+
+ * array.c (rb_ary_shift): avoid sliding an internal buffer by
+ using shared buffer.
+
+ * array.c (rb_ary_subseq): avoid copying the buffer.
+
+Mon Dec 10 01:06:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (gettable): should freeze __FILE__ string.
+
+Sun Dec 9 18:06:26 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: calls on_connect before conn_command
+
+Sat Dec 8 23:27:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_puts): old behavior restored. rationale: a) if you
+ want to call to_s for arrays, you can just call print a, "\n".
+ b) to_s wastes memory if array (and sum of its contents) is
+ huge. c) now any object that has to_ary is treated as an array,
+ using rb_check_convert_type().
+
+Sat Dec 8 22:40:38 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_initialize): now accepts a block to calculate
+ the default value. [new]
+
+ * hash.c (rb_hash_aref): call "default" method to get the value
+ corresponding to the non existing key.
+
+ * hash.c (rb_hash_default): get the default value based on the
+ block given to 'new'. Now it takes an optional "key" argument.
+ "default" became the method to get the value for non existing
+ key. Users may override "default" method to change the hash
+ behavior.
+
+ * hash.c (rb_hash_set_default): clear the flag if a block is given
+ to 'new'
+
+Sat Dec 8 02:29:54 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (Init_Object): undef Data.allocate, left Data.new.
+
+Fri Dec 7 19:12:14 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/smtp.rb: SMTP.new requires at least one arg.
+
+ * lib/net/pop.rb: POP.new requires at least one arg.
+
+ * lib/net/pop.rb: uses "raise *Error.new" instead of simple raise.
+
+ * lib/net/http.rb: HTTP.new requires at least one arg.
+
+ * lib/net/http.rb: changes implicit start algorithm.
+
+Fri Dec 7 15:49:39 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * ext/extmk.rb.in: ignore adding -Wl,-R to DLDFLAGS when the directory
+ is $topdir.
+
+Fri Dec 7 13:58:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/curses/curses.c (window_scrollok): use RTEST().
+
+ * ext/curses/curses.c (window_idlok): ditto.
+
+ * ext/curses/curses.c (window_keypad): ditto.
+
+ * ext/curses/curses.c (window_idlok): idlok() may return void on
+ some platforms; so don't use return value.
+
+ * ext/curses/curses.c (window_scrollok): ditto for consistency.
+
+ * ext/curses/curses.c: replace FIX2INT() by typechecking NUM2INT().
+
+Fri Dec 7 09:51:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (str_extend): should not process immature #$x and
+ #@x interpolation, e.g #@#@ etc.
+
+Fri Dec 7 03:21:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_sort_by): sort_by does not have to be stable always.
+
+ * enum.c (enum_sort_by): call qsort directly to gain performance.
+
+Thu Dec 6 18:52:28 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * ext/extmk.rb.in: add -Wl,-R flags to DLDFLAGS on netbsdelf.
+
+ * lib/mkmf.rb: ditto.
+
+Thu Dec 6 09:15:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * util.c (ruby_qsort): ruby_qsort(qs6) is now native thread safe.
+
+ * error.c (rb_sys_fail): it must be a bug if it's called when
+ errno == 0.
+
+Wed Dec 5 23:36:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (WC2MBC1ST): should not pass through > 0x80 number in UTF-8.
+
+Wed Dec 5 20:05:18 2001 Florian Frank <flori@ping.de>
+
+ * ext/socket/socket.c (bsock_send): should raise EWOULDBLOCK
+ exception.
+
+ * ext/socket/socket.c (s_recvfrom): ditto.
+
+ * ext/socket/socket.c (s_accept): ditto.
+
+ * ext/socket/socket.c (udp_send): ditto.
+
+Tue Dec 4 17:43:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.h (DUPSETUP): new SETUP macro for duplication.
+
+ * time.c (time_dup): implement in Time class using DUPSETUP.
+
+ * time.c (time_getlocaltime): new method; probably requires
+ better name than getlocaltime. [new,experimental]
+
+ * time.c (time_getgmtime): ditto.
+
+ * array.c (rb_ary_dup): uses DUPSETUP.
+
+ * string.c (rb_str_dup): uses DUPSETUP. now properly copies
+ instance variables too.
+
+Tue Dec 4 03:49:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_fread): EAGAIN/EWOULDBLOCK should not terminate and
+ throw away the input.
+
+ * time.c (time_new_internal): underflow adjustment must not use
+ negative div/mod.
+
+ * time.c (time_cmp): should consider tv_usec on non Fixnum number
+ comparison.
+Sun Dec 9 23:00:54 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
+ * matrix.rb: Vector#* bug. reported from Massimiliano Mirra
+ <info@chromatic-harp.com>.
+
+Sun Dec 9 22:15:59 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * enum.c (enum_sort_by): should replace with last elements.
+
+Mon Dec 3 16:06:57 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/extconf.rb: remove -L/usr/local/lib.
+
+ * configure.in: add -Wl,-export-dynamic on NetBSD.
+
+Mon Dec 3 16:04:16 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * configure.in: not use X11BASE, since it's not always set.
+
+Mon Dec 3 13:53:49 2001 Tanaka Akira <akr@m17n.org>
+
+ * time.c (rb_strftime): buffer length condition was wrong.
+
+ * time.c (time_strftime): should backup buf to the original
+ buffer.
+
+Mon Dec 3 09:59:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_plus): must detect result overflow.
+
+ * time.c (time_minus): ditto.
+
+ * time.c (time_new_internal): round usec overflow and underflow
+ here.
+
+ * time.c (time_plus): move operand overflow/underflow check to
+ time_new_internal().
+
+ * time.c (time_minus): ditto.
+
+ * time.c (time_cmp): should consider tv_usec too.
+
+Mon Dec 3 03:32:22 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * configure.in: apply patch from NetBSD's pkgsrc (patch-aa).
+
+Sun Dec 2 22:01:52 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: use GCC, not without_gcc. remove without_gcc.
+
+ * ext/curses/extconf.rb: check for curses.h.
+
+ * ext/dbm/extconf.rb: check if $CFLAGS includes DBM_HDR.
+
+Sat Dec 1 12:13:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_gmtime): time_modify() should be called even if tm
+ struct is not calculated yet.
+
+Fri Nov 30 17:02:55 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: set target_cpu to i386 on cygwin and mingw32.
+
+ * configure.in: default --enable-shared to yes on cygwin and mingw32.
+
+Fri Nov 30 00:25:28 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * README.EXT: Appendix B is duplicated.
+
+ * README.EXT.ja: ditto.
+
+Thu Nov 29 00:28:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_equal): object with to_str must be treated as a
+ string.
+
+Wed Nov 28 18:46:28 2001 Ville Mattila <mulperi@iki.fi>
+
+ * eval.c (rb_thread_select): should subtract timeofday() from
+ limit, not reverse.
+
+Wed Nov 28 16:03:28 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * util.c (scan_hex): x is not a hexadecimal digit.
+
+Wed Nov 28 13:38:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_schedule): should treat the case that
+ select(2) returns 0, if a thread is under both WAIT_SELECT and
+ WAIT_TIME. Jakub Travnik <J.Travnik@sh.cvut.cz> actually fixed
+ this bug.
+
+Tue Nov 27 02:15:25 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_float): must distinguish -0.0 from 0.0.
+
+Mon Nov 26 20:57:24 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/Setup*, ext/syslog/*: import the "syslog" module from the
+ rough ruby project.
+
+Mon Nov 26 16:14:42 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * gc.c (gc_mark_all): tweak mark order for little bit better scan.
+
+ * gc.c (rb_gc_mark): ditto.
+
+ * gc.c (rb_gc): ditto.
+
+Mon Nov 26 16:54:59 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/win32.c (mypopen): fixed that mypclose() didn't really close
+ pipe.
+
+ * win32/win32.c (CreateChild): set STARTF_USESTDHANDLES flag only
+ when some handles are passed.
+
+Mon Nov 26 16:31:28 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (sort_by_i): slight performance boost.
+
+Sun Nov 25 21:02:18 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * parse.y (str_extend): change types of second and third arguments
+ from char to int.
+
+Thu Nov 22 20:15:28 2001 TAMURA Takashi <sheepman@tcn.zaq.ne.jp>
+
+ * gc.c (gc_mark_rest): should call gc_mark_children(), not gc_mark().
+
+ * gc.c (rb_gc_mark): may cause infinite loop.
+
+Thu Nov 22 00:28:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (str_extend): should check nesting parentheses in #{}.
+
+Wed Nov 21 12:22:52 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/cgi.rb: CGI#header: do not set Apache.request.status for
+ Location: if Apache.request.status is already set.
+
+Wed Nov 21 02:24:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (pst_wstopsig): returns nil unless WIFSTOPPED() is
+ non-zero.
+
+ * process.c (pst_wtermsig): returns nil unless WIFSIGNALED() is
+ non-zero.
+
+ * process.c (pst_wexitstatus): returns nil unless WIFEXITED() is
+ non-zero.
+
+Wed Nov 21 00:17:54 2001 Ville Mattila <mulperi@iki.fi>
+
+ * eval.c (rb_thread_select): tv_sec and tv_usec should not be
+ negative.
+
+ * signal.c (posix_signal): do not set SA_RESTART for SIGVTALRM.
+
+Tue Nov 20 21:09:22 2001 Guy Decoux <ts@moulon.inra.fr>
+
+ * parse.y (call_args2): block_arg may follow the first argument in
+ call_args2.
+
+Tue Nov 20 02:01:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (stack_check): should avoid stack length check during
+ raising SystemStackError exception.
+
+Tue Nov 20 01:07:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (str_extend): should not terminate string interpolation
+ with newlines in here-docs and newline terminated strings.
+
+Mon Nov 19 17:58:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_modfunc): should follow NODE_ZSUPER link; based
+ on Guy Decoux's patch in [ruby-talk:25478].
+
+Mon Nov 19 16:09:33 2001 Tanaka Akira <akr@m17n.org>
+
+ * string.c (rb_str_succ): there was buffer overrun.
+
+Mon Nov 19 14:14:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (str_extend): term can be any character.
+
+Mon Nov 19 04:58:42 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb (header): support for Apache. thanks to
+ Shugo Maeda <shugo@ruby-lang.org>.
+
+Sun Nov 18 19:37:55 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y: needless conditionals.
+
+ * parse.y (parse_regx): parse error at unterminated regex /#{.
+ (ruby-bugs-ja:PR#142)
+
+Sat Nov 17 12:37:39 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_unpack): should give length to utf8_to_uv().
+
+ * pack.c (utf8_to_uv): add length check.
+
+Sat Nov 17 01:41:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * massages: replace "wrong #" by "wrong number".
+
+ * marshal.c (w_float): output Infinity and NaN explicitly.
+
+ * marshal.c (r_object): support new explicit float format.
+
+ * eval.c (rb_thread_wait_for): select may cause ERESTART on
+ Solaris.
+
+ * eval.c (rb_thread_select): ditto.
+
+Thu Nov 15 15:29:39 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * array.c (rb_ary_join): non-nil separator must be converted to
+ String. and separators' total length was wrong.
+
+Thu Nov 15 03:37:17 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * hash.c (ruby_setenv): remove USE_WIN32_RTL_ENV block since it's
+ obsoleted.
+
+ * win32/win32.c, win32/win32.h: sort out #if 0 - #endif or others.
+
+Thu Nov 15 00:07:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_to_s): if rb_output_fs is nil, insert newlines
+ between array elements (use rb_default_rs as newline literal)
+ [experimental].
+
+Wed Nov 14 15:16:23 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * gc.c (init_mark_stack): no need to clear mark_stack.
+
+ * gc.c (gc_mark_all): need to handle finalizer mark.
+
+ * gc.c (gc_mark_rest): use MEMCPY instead of memcpy.
+
+ * gc.c (rb_gc_mark): earlier const check to avoid pusing special
+ constants into mark stack.
+
+Wed Nov 14 01:12:07 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/win32.c (waitpid): fix wait count.
+
+ * win32/win32.c (poll_child_status): rename from wait_child().
+
+Wed Nov 14 01:33:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (fix_to_s): 'to_s' now takes optional argument to
+ specify radix. [new]
+
+ * bignum.c (rb_big_to_s): ditto. [new]
+
+Tue Nov 13 19:50:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: do not override CC if set.
+
+Tue Nov 13 16:49:16 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/win32.c (mypopen): return error status instead of calling
+ rb_sys_fail().
+
+ * win32/win32.c (do_spawn): ditto.
+
+Tue Nov 13 14:39:11 2001 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * signal.c (sighandle): should not re-register sighandler if
+ POSIX_SIGNAL is defined.
+
+Tue Nov 13 12:55:59 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/win32.c (do_spawn): use CreateChild() instead of calling
+ CreateProcess() directly. Original patches comes from Patrick Cheng.
+
+ * win32/win32.c (mypopen): ditto.
+
+ * win32/win32.c (mypclose): use rb_syswait() instead of waiting in this
+ function.
+
+ * win32/win32.c (waitpid): use wait_child() instead of _cwait().
+
+ * win32/win32.c (CreateChild): added. [new]
+
+ * win32/win32.c (wait_child): added. [new]
+
+ * win32/win32.c (FindFirstChildSlot): added. [new]
+
+ * win32/win32.c (FindChildSlot): added. [new]
+
+ * win32/win32.c (FindPipedChildSlot): added. [new]
+
+ * win32/win32.c (CloseChildHandle): added. [new]
+
+ * win32/win32.c (FindFreeChildSlot): added. [new]
+
+Tue Nov 13 12:38:12 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * hash.c (envix): use GET_ENVIRON and FREE_ENVIRON to get environment
+ variables list.
+
+ * hash.c (env_keys): ditto.
+
+ * hash.c (env_each_key): ditto.
+
+ * hash.c (env_values): ditto.
+
+ * hash.c (env_keys): ditto.
+
+ * hash.c (env_each_value): ditto.
+
+ * hash.c (env_each): ditto.
+
+ * hash.c (env_inspect): ditto.
+
+ * hash.c (env_to_a): ditto.
+
+ * hash.c (env_size): ditto.
+
+ * hash.c (env_empty_p): ditto.
+
+ * hash.c (env_has_value): ditto.
+
+ * hash.c (env_index): ditto.
+
+ * hash.c (env_to_hash): ditto.
+
+ * win32/win32.c (win32_getenv): use static buffer.
+
+ * win32/win32.c, win32/win32.h (win32_get_environ): get environment
+ variables list. [new]
+
+ * win32/win32.c, win32/win32.h (win32_free_environ): free environment
+ variables list. [new]
+
+Mon Nov 12 16:48:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (error_print): errat array may be empty.
+
+Mon Nov 12 01:30:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval_cmd): should not upgrade safe level unless
+ explicitly specified by argument newly added.
+
+ * signal.c (sig_trap): should not allow tainted trap closure.
+
+ * variable.c (rb_f_trace_var): should not allow trace_var on safe
+ level higher than 3.
+
+ * variable.c (rb_f_trace_var): should not allow tainted trace
+ closure.
+
+Sun Nov 11 00:12:23 2001 TAMURA Takashi <sheepman@tcn.zaq.ne.jp>
+
+ * gc.c: do not use static stack until system stack overflows.
+
+Sat Nov 10 03:57:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (eval): should call Exception#exception instead of
+ calling rb_exc_new3() directly.
+
+ * error.c (exc_exception): set "mesg" directly to the clone. it
+ might be better to set mesg via some method for flexibility.
+
+Sat Nov 10 00:14:24 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (cvar_override_check): should print original module
+ name, if 'a' is T_ICLASS.
+
+ * parse.y (yylex): float '1_.0' should not be allowed.
+
+ * variable.c (var_getter): should care about var as Qfalse
+ (ruby-bugs#PR199).
+
+Fri Nov 9 13:50:06 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/config.status.in: make CFLAGS same as Makefile's one.
+
+Thu Nov 8 20:20:37 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_trap_eval): avoid annoying warning with signal.
+ [ruby-talk:23225]
+
+ * eval.c (rb_call0): adjust caller source file/line while
+ evaluating optional arguments.
+
+Thu Nov 8 18:41:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (cmpint): <=> or block for {min,max} may return bignum.
+
+ * array.c (sort_1): use rb_compint.
+
+ * array.c (sort_2): ditto.
+
+ * enum.c (min_ii): ditto.
+
+ * enum.c (min_ii): ditto.
+
+ * enum.c (max_i): ditto.
+
+ * enum.c (max_ii): ditto.
+
+Thu Nov 8 18:21:02 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (path_check_1): forgot to initialize 'p'.
+
+Thu Nov 8 14:52:15 2001 Tanaka Akira <akr@m17n.org>
+
+ * mkconfig.rb: use String#dump to generate Ruby string literal.
+
+Thu Nov 8 15:46:54 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_eql): should override 'eql?'
+
+ * array.c (rb_ary_hash): should override 'hash' too.
+
+Tue Nov 6 14:38:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (security): always give warning for insecure PATH.
+
+ * dir.c (my_getcwd): do not rely on MAXPATHLEN.
+
+ * file.c (rb_file_s_readlink): ditto.
+
+ * file.c (path_check_1): ditto.
+
+Tue Nov 6 14:17:14 2001 Amos Gouaux <amos+ruby@utdallas.edu>
+
+ * lib/net/imap.rb (getquota_response): use astring for mailbox
+ names.
+
+ * lib/net/imap.rb (getacl_response): ditto.
+
+Mon Nov 5 17:09:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): should not call rb_f_block_given_p().
+
+Sat Nov 3 23:33:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_chomp_bang): should terminate string by NUL.
+
+Sat Nov 3 22:28:51 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * matrix.rb (Matrix#column_vectors, Matrix#row_vectors): ditto bug.
+ this bug report and fix by tsutomu@nucba.ac.jp.
+
+ * forwardable.rb: change raise to Kernel::raise
+
+Sat Nov 3 10:11:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): better error message.
+
+Thu Nov 1 14:08:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_aref): idx may be a Bignum.
+
+ * numeric.c (fix_aref): negative index must return zero.
+
+Thu Nov 1 13:23:50 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (gc_mark_children): should NOT treat last element of
+ structs and arrays specially.
+
+Wed Oct 31 16:59:25 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (exec_under): should initialize ruby_frame->self;
+
+Wed Oct 31 15:09:28 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (POP_VARS): should not set DVAR_DONT_RECYCLE if _old
+ ruby_vars is already force_recycled.
+
+Wed Oct 31 10:28:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc): handles mark stack overflow.
+
+ * gc.c (PUSH_MARK): use static mark stack, no more recursion.
+
+Wed Oct 31 02:44:06 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: CGI::Cookie::parse(): Ignore duplicate keys caused by
+ Netscape bug.
+
+Tue Oct 30 18:21:51 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/mkexports.rb: follow the change of rb_io_puts().
+
+Tue Oct 30 14:04:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_chomp_bang): do smart chomp if $/ == '\n'. [new]
+
+ * io.c (rb_io_puts): don't treat Array specially.
+
+ * bignum.c (rb_big_cmp): should convert bignum to float.
+
+ * eval.c (rb_f_eval): can't modify untainted binding.
+
+Mon Oct 29 16:08:30 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): should preserve p0 value.
+
+Mon Oct 29 14:56:44 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * intern.h (rb_protect_inspect): follow the change of array.c.
+
+ * eval.c (rb_exec_end_proc): follow the change of rb_protect().
+
+ * eval.c (method_proc, umethod_proc, rb_catch): cast the first
+ parameter of rb_iterate() to avoid VC++ warning.
+
+ * range.c (range_step): ditto.
+
+ * ext/sdbm/init.c (fsdbm_update, fsdbm_replace): ditto.
+
+Mon Oct 29 07:57:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (str_extend): should allow interpolation of $-x.
+
+ * variable.c (rb_cvar_set): empty iv_tbl may cause infinite loop.
+
+ * variable.c (rb_cvar_get): ditto.
+
+ * variable.c (cvar_override_check): ditto.
+
+Sat Oct 27 23:01:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_eq): convert Bignum to Float, instead of
+ reverse.
+
+Fri Oct 26 06:19:29 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_localtime): getting tm should not be prohibited for
+ frozen time objects.
+
+ * time.c (time_gmtime): ditto.
+
+ * version.c (Init_version): freeze RUBY_VERSION,
+ RUBY_RELEASE_DATE, and RUBY_PLATFORM.
+
+ * file.c (Init_File): freeze File::SEPARATOR, ALT_SEPARATOR and
+ PATH_SEPARATOR.
+
+ * file.c (rb_stat_cmp): should check operand type before calling
+ get_stat().
+
+Thu Oct 25 10:28:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval_cmd): should not invoke "call" with a block on
+ any occasion.
+
+Wed Oct 24 03:25:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (fix_aref): idx may be a Bignum.
+
+Tue Oct 23 01:21:19 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (proc_invoke): fix self switching in Proc#call
+ (ruby-bugs-ja#PR108) and GC failure. use Qundef instead of 0
+ to direct not switching self.
+
+ * eval.c (call_trace_func): ditto.
+
+ * eval.c (call_end_proc): ditto.
+
+ * eval.c (proc_call): ditto.
+
+ * eval.c (proc_yield): ditto.
+
+Tue Oct 23 01:15:43 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * variable.c (rb_global_entry): reconstruct global variable
+ aliasing (sharing global_entry->var with other global_entry).
+
+ * variable.c (undef_getter): ditto.
+
+ * variable.c (undef_setter): ditto.
+
+ * variable.c (val_setter): ditto.
+
+ * variable.c (mark_global_entry): ditto.
+
+ * variable.c (rb_define_hooked_variable): ditto.
+
+ * variable.c (rb_f_trace_var): ditto.
+
+ * variable.c (remove_trace): ditto.
+
+ * variable.c (rb_f_untrace_var): ditto.
+
+ * variable.c (rb_gvar_get): ditto.
+
+ * variable.c (trace_en): ditto.
+
+ * variable.c (rb_gvar_set): ditto.
+
+ * variable.c (rb_gvar_defined): ditto.
+
+ * variable.c (rb_alias_variable): ditto.
+
+Mon Oct 22 18:53:55 2001 Masahiro Tanaka <masa@stars.gsfc.nasa.gov>
+
+ * numeric.c (num_remainder): a bug in Numeric#remainder.
+
+Mon Oct 22 15:21:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_exec_end_proc): END might be called within END
+ block.
+
+ * class.c (rb_mod_clone): should not copy class name, since clone
+ should remain anonymous.
+
+Fri Oct 19 23:40:37 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * variable.c (remove_trace): should not access already freed area.
+
+ * variable.c (rb_f_untrace_var): fix memory leak.
+
+Fri Oct 19 17:55:14 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * marshal.c (w_uclass): cloned class is not user
+ class. (ruby-bugs-ja#PR103)
+
+ * marshal.c (r_object): Struct subclass couldn't
+ load. (ruby-bugs-ja#PR104)
+
+Wed Oct 17 14:12:50 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * variable.c (alias_fixup): added. ad hoc support for ordinary
+ global variable aliasing. when original entry is set, make the
+ alias to refer directly as possible.
+
+ * variable.c (alias_getter, alias_setter): ditto.
+
+ * variable.c (rb_alias_variable): ditto. and no need to mark alias
+ variables.
+
+ * variable.c (rb_gvar_defined): refer the original entry of an alias.
+
+Tue Oct 16 23:29:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call0): self in a block given to define_method now be
+ switched to the receiver of the method.
+
+ * eval.c (proc_invoke): added new parameter to allow self
+ switching.
+
+Tue Oct 16 21:38:15 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_f_missing): check stack level with rb_stack_check().
+
+ * eval.c (rb_call0): ditto.
+
+ * eval.c, intern.h (rb_stack_check): added. [new]
+
+Tue Oct 16 13:18:47 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * object.c (rb_mod_initialize): optional block with
+ Module.new. [new] (from 2001-10-10)
+
+Tue Oct 16 00:07:06 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (yylex): disallow alpha-numeric and mbchar for
+ terminator of %string.
+
+Mon Oct 15 18:00:05 2001 Pit Capitain <pit@capitain.de>
+
+ * string.c (rb_str_index): wrong increment for non alphanumeric
+ string.
+
+Mon Oct 15 05:23:02 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * sprintf.c (rb_f_sprintf): support "%B".
+
+Wed Oct 10 03:11:47 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_stat_clone): should copy internal data too.
+
+ * numeric.c (num_clone): Numeric should not be copied by clone.
+
+ * object.c (rb_obj_clone): should check immediate values.
+
+ * parse.y (command): `yield' should take command_args.
+
+ * parse.y (parse_quotedwords): %w(...) is not a string.
+
+Tue Oct 9 18:40:35 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * process.c (Init_process): activate the case NT.
+
+Tue Oct 9 17:08:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (thread_status_name): separated from
+ rb_thread_inspect(). return string expression for thread status.
+
+ * eval.c (rb_thread_status, rb_thread_inspect): use
+ thread_status_name().
+
+ * eval.c (rb_thread_priority_set): return the priority not but
+ self.
+
+Sat Oct 6 23:07:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): NODE_MATCH3 was confusing left and right. sigh.
+
+Fri Oct 5 15:19:46 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_unique): should not dump anonymous class.
+
+Fri Oct 5 11:59:13 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (proc_s_new): revived.
+
+ * eval.c (Init_Proc): define Proc.new instead of Proc.allocate to
+ inhibit from creating uninitialized Proc.
+
+Thu Oct 4 14:11:03 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/socket.c (ruby_connect): EALREADY is the equivalent
+ for EINPROGRESS in ws2_32.lib.
+
+Wed Oct 3 20:11:06 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * re.c (rb_reg_s_alloc): avoid infinite recursion.
+
+Wed Oct 3 16:49:49 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/gdbm/gdbm.c (rb_gdbm_fetch): str is a VALUE now.
+
+Wed Oct 3 13:32:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (r_object): better allocation type check for
+ TYPE_UCLASS. usage of allocation framework is disabled for now.
+
+ * variable.c (rb_class_path): Module may have subclass.
+
+ * string.c (rb_str_update): should maintain original negative
+ offset.
+
+ * string.c (rb_str_subpat_set): ditto
+
+ * string.c (rb_str_aset): ditto.
+
+ * re.c (rb_reg_nth_match): should check negative nth.
+
+ * re.c (rb_reg_nth_defined): ditto.
+
+Tue Oct 2 19:12:47 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/ftools.rb (catname): allow trailing '/' for the destination.
+
+Tue Oct 2 18:31:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should override existing class.
+
+Tue Oct 2 17:08:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_alloc): general instance allocation framework.
+ use of NEWOBJ() is deprecated except within 'allocate' method.
+
+Tue Oct 2 08:04:52 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * marshal.c (r_object): TYPE_UCLASS check should be inversed.
+
+Mon Oct 1 19:18:54 2001 Tanaka Akira <akr@m17n.org>
+
+ * ext/socket/socket.c (unix_addr): getsockname(2) may result len = 0.
+
+ * ext/socket/socket.c (unix_peeraddr): getpeername(2) may result
+ len = 0.
+
+Mon Oct 1 09:59:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_subpat_set): support function for new argument
+ pattern String#[re,offset] = val. [new]
+
+Sat Sep 29 02:30:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (POP_BLOCK): rb_gc_force_recycle() was called too much.
+ Should not be called if SCOPE_DONT_RECYCLE is set.
+
+Wed Sep 26 22:21:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_aref_m): new argument pattern
+ String#[re,offset]. [new]
+
+Wed Sep 26 19:02:39 2001 Guy Decoux <ts@moulon.inra.fr>
+
+ * parse.y: allow 'primary[] = arg'
+
+Tue Sep 25 10:46:42 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/win32.c (isInternalCmd): check return value of NtMakeCmdVector
+ (Tietew <tietew@tietew.net>'s patch).
+
+Mon Sep 24 00:55:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_substr): should return an instance of
+ receiver's class.
+
+ * string.c (rb_str_succ): ditto.
+
+ * array.c (rb_ary_subseq): ditto.
+
+ * array.c (rb_ary_initialize): Array.new([1,2,3]) => [1,2,3]. [new]
+
+Sat Sep 22 22:16:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_reverse): should return an instance of
+ receiver's class.
+
+ * string.c (rb_str_times): ditto.
+
+ * array.c (rb_ary_times): ditto
+
+ * string.c (str_gsub): ditto.
+
+ * string.c (rb_str_ljust): ditto.
+
+ * string.c (rb_str_rjust): ditto.
+
+ * string.c (rb_str_center): ditto.
+
+Sat Sep 22 12:13:39 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (eval): retrieves file, line information from binding.
+
+Thu Sep 20 21:25:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (MATCH_DATA): access via rb_svar().
+
+Thu Sep 20 15:20:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c, intern.h (rb_svar): return reference to special variable
+ from local variable index. [new]
+
+ * eval.c (rb_eval): use rb_svar() for NODE_FLIP{2,3}.
+
+ * parse.y (rb_(backref|lastline)_(get|set)): access via rb_svar().
+
+ * eval.c (proc_invoke): push dynamic variables.
+
+ * eval.c (rb_thread_yield): push special variables as dynamic
+ variables($_, $~ and FLIP states).
+
+Thu Sep 20 15:20:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * intern.h, parse.y (rb_is_local_id): return true if the ID is
+ local symbol. [new]
+
+ * parse.y (internal_id): make new ID for internal use. [new]
+
+ * parse.y (cond0): allocate internal ID for NODE_FLIP{2,3}.
+
+ * eval.c (rb_f_local_variables): use rb_is_local_id() to select
+ visible local variables.
+
+Thu Sep 20 15:20:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_thread_start_0): SCOPE_SHARED is removed.
+
+ * eval.c, intern.h (rb_thread_scope_shared_p): removed. special
+ variables are no longer shared by threads.
+
+ * re.c (rb_reg_search): MATCHDATA is no longer shared by threads.
+
+Tue Sep 18 11:44:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_init): String.new() => "" [new]
+
+Tue Sep 11 20:53:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (dir_path): new method.
+
+ * dir.c (dir_initialize): wrap DIR into struct, along with path
+ information.
+
+Sat Sep 8 07:13:42 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/net/telnet.rb: waitfor(): improvement. thanks to
+ nobu.nakada@nifty.ne.jp
+
+Sat Sep 8 04:34:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_restore_context): save current value of
+ lastline and lastmatch in the thread struct for later restore.
+
+ * eval.c (rb_thread_save_context): restore lastline and lastmatch.
+
+Fri Sep 7 11:27:56 2001 akira yamada <akira@ruby-lang.org>
+
+ * numeric.c (flo_to_s): should handle negative float value.
+
+Fri Sep 7 09:44:44 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/net/telnet.rb: waitfor(): bug fix.
+
+Fri Sep 7 07:11:34 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: CGI#doctype(): bug fix (html4Fr).
+
+ * lib/net/telnet.rb, lib/cgi.rb: remove VERSION, RELEASE_DATE,
+ VERSION_CODE, RELEASE_CODE. please use REVISION.
+
+ * lib/cgi.rb: CGI#header(): bug fix.
+
+ * lib/net/telnet.rb, lib/cgi.rb: concat --> +=
+
+Thu Sep 6 17:38:18 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * dir.c (dir_s_chdir): raise if environment variable HOME/LOGDIR
+ not set.
+
+ * dir.c (glob_helper): avoid infinite loop on a file name with
+ wildcard characters. (ruby-bugs#PR177)
+
+Thu Sep 6 14:25:15 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/digest.c (rb_digest_base_s_hexdigest): remove a debug
+ print.
+
+Thu Sep 6 13:56:14 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/digest.c (rb_digest_base_s_digest,
+ rb_digest_base_s_hexdigest): ensure that a string is given.
+
+Thu Sep 6 13:28:51 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/jcode.rb (_regexp_quote): fix quote handling, again.
+
+Thu Sep 6 07:28:56 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (rb_find_file_ext): add const qualifiers to ext.
+
+ * intern.h (rb_find_file_ext): ditto.
+
+Thu Sep 6 07:16:14 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/socket/socket.c (Init_socket): remove duplicating constants.
+
+Thu Sep 6 03:15:24 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_include_module): should check whole ancestors to
+ avoid duplicate module inclusion.
+
+Wed Sep 5 20:02:27 2001 Shin'ya Adzumi <adzumi@denpa.org>
+
+ * string.c (trnext): should check backslash before updating "now"
+ position.
+
+Wed Sep 5 17:41:11 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/jcode.rb (_regexp_quote): fix quote handling.
+
+Tue Sep 4 01:03:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (Init_Regexp): to_s to be alias to inspect.
+
+Mon Sep 3 22:46:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): should support 'keyword='.
+
+Mon Sep 3 20:26:08 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * intern.h (rb_find_file_ext): changed from rb_find_file_noext().
+
+Mon Sep 3 15:12:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.c (proc_options): should not adjust argc/argv if -e option
+ is supplied.
+
+Mon Sep 3 14:11:17 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * error.c: unbreak the build on *BSD with gcc 3.0.1 by removing
+ the conflicting declaration of sys_nerr for *BSD.
+
+Sat Sep 1 18:50:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.c (proc_options): should not alter origargv[].
+
+ * ruby.c (set_arg0): long strings for $0 dumped core.
+
+Sat Sep 1 09:50:54 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ruby.c (set_arg0): prevent SEGV when val is longer than the
+ original arguments.
+
+ * ruby.c (ruby_process_options): initialize total length of
+ original arguments at first.
+
+Sat Sep 1 14:05:28 2001 Brian F. Feldman <green@FreeBSD.org>
+
+ * ruby.c (set_arg0): use setprogtitle() if it's available.
+
+Sat Sep 1 03:49:11 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_popen): accept integer flags as mode.
+
+Fri Aug 31 19:46:05 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (rb_find_file_ext): extension table can be supplied from
+ outside. renamed.
+
+ * eval.c (rb_f_require): replace rb_find_file_noext by
+ rb_find_file_ext.
+
+Fri Aug 31 19:26:55 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_provided): should also check feature without
+ extension.
+
+Fri Aug 31 13:06:33 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (flo_to_s): do not rely on decimal point to be '.'
+
+Wed Aug 29 02:18:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): ternary ? can be followed by newline.
+
+Tue Aug 28 00:40:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_require): should check static linked libraries
+ before raising exception.
+
+Fri Aug 24 15:17:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_equal): check identity equality first.
+
+ * string.c (rb_str_equal): ditto.
+
+ * struct.c (rb_struct_equal): ditto.
+
+Fri Aug 24 14:38:17 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * dln.c (dln_strerror): fix a bug that sometimes made null message on
+ win32 (Tietew <tietew@tietew.net>'s patch).
+
+ * win32/win32.c (mystrerror): ditto.
+
+Fri Aug 24 03:15:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (Init_Numeric): undef Integer::new.
+
+Fri Aug 24 00:46:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): NODE_WHILE should update result for each
+ conditional evaluation.
+
+ * eval.c (rb_eval): NODE_UNTIL should return last evaluated value
+ (or value given to break).
+
+Thu Aug 23 21:59:38 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * enum.c (sort_by_i): fix typo.
+
+Thu Aug 23 10:10:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (is_defined): should not dump core for "defined?(())".
+
+ * eval.c (umethod_bind): recv can be an instance of descender of
+ oklass if oklass is a Module.
+
+Wed Aug 22 23:20:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_equal): check identity equality first.
+
+Wed Aug 22 19:58:59 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (intersect_fds): counts intersecting fds.
+
+ * eval.c (rb_thread_schedule): only fds requested by
+ each thread count as select_value.
+
+Tue Aug 21 22:28:09 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (group_member): should check real gid only.
+
+ * file.c (eaccess): do not cache euid, since effective euid may be
+ changed via Process.euid=().
+
+ * file.c (eaccess): return -1 unless every specified access mode
+ is permitted.
+
+Tue Aug 21 16:09:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): while/until returns the value which is given
+ to break.
+
+ * parse.y (value_expr): using while/until/class/def as an
+ expression is now gives a warning, not an error.
+
+Tue Aug 21 11:56:02 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_eqq): should compare strings based on magical
+ increment (using String#upto), not dictionary order.
+
+Mon Aug 20 19:53:16 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/digest/sha2/extconf.rb: fix support for cross-compiling.
+
+ * mkconfig.rb: fix support for autoconf 2.52.
+
+Mon Aug 20 17:24:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_sort_by): new method for Schewartzian transformed
+ stable sort.
+
+Mon Aug 20 16:09:05 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (mod_av_set): detect constant overriding for built-in
+ classes/modules.
+
+Mon Aug 20 15:14:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (tokadd_escape): escaped backslashes too much.
+
+Mon Aug 20 13:24:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_step): 'iter' here should be an array.
+
+Mon Aug 20 12:43:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): should retrieve __member__ data from
+ non-singleton class.
+
+Sat Aug 18 23:11:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_cvar_get): class variable override check added.
+
+ * variable.c (rb_cvar_set): ditto
+
+ * variable.c (rb_cvar_declare): ditto.
+
+Fri Aug 17 12:13:48 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/protocol.rb: Protocol.new requires at least one arg.
+
+ * lib/net/smtp.rb: ditto.
+
+ * lib/net/pop.rb: ditto.
+
+ * lib/net/http.rb: ditto.
+
+Fri Aug 17 00:49:51 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (parse_regx): handle backslash escaping of delimiter here.
+
+Thu Aug 16 23:03:40 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * io.c: prevent recursive malloc calls on NEC UX/4800.
+
+ * ext/socket/socket.c: ditto.
+
+Thu Aug 16 13:54:04 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * ext/socket/socket.c (s_recvfrom): fix typo.
+
+Thu Aug 16 09:53:28 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * ext/socket/socket.c (s_recvfrom): avoid VC++6 warning.
+
+Thu Aug 16 03:50:33 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/win32.c (NtCmdGlob): avoid VC++ warning.
+
+ * lib/mkmf.rb: add -I$(srcdir) to CPPFLAGS.
+
+Wed Aug 15 04:59:15 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/*/extconf.rb: really fix so that they build from any
+ directory.
+
+Wed Aug 15 04:04:02 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/sha2/extconf.rb: fix so that they build from any
+ directory.
+
+Wed Aug 15 01:59:19 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/defs.h: Define NO_UINT64_T instead of emitting an
+ error to fail.
+
+ * ext/digest/sha2/extconf.rb: Do not exit on error, and utilize
+ NO_UINT64_T to detect if the system has a 64bit integer type.
+
+Tue Aug 14 21:14:07 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/sha2/extconf.rb: do not create Makefile when no 64bit
+ integer type is detected.
+
+Tue Aug 14 17:09:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_step): new method.
+
+Tue Aug 14 11:49:00 2001 TOYOFUKU Chikanobu <toyofuku@juice.or.jp>
+
+ * string.c (rb_str_cmp): remove needless conditional.
+
+Tue Aug 14 03:23:25 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * string.c (rb_str_lstrip_bang) `return Qnil' was missing.
+
+Mon Aug 13 14:16:46 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * bignum.c, marshal.c: Detypo: s/SIZEOF_ING/SIZEOF_INT/.
+
+Sun Aug 12 15:01:58 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * string.c (rb_str_cat): fix buffer overflow.
+
+ * string.c (rb_str_append): nothing to append actually when `str2'
+ is empty.
+
+Sat Aug 11 14:43:47 2001 Tanaka Akira <akr@m17n.org>
+
+ * array.c (rb_inspecting_p): initialize inspect_key if it is
+ not initialized yet.
+
+Fri Aug 10 22:14:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (cond0): operands of logical operators are not treated
+ as conditional expression anymore, but propagate conditional
+ status if used in conditionals.
+
+Tue Aug 7 09:10:32 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * win32/win32.h: fix problems with BC++ (ruby-bugs#PR161).
+
+Mon Aug 6 23:47:46 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * pack.c (pack_pack): associates p/P strings once at last
+ (reverted to 1.26).
+
+ * string.c (rb_str_associate): associates an Array at once, not
+ but a String. realloc's when str_buf.
+
+Mon Aug 6 17:01:33 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_gc_mark_threads): should mark ruby_cref.
+
+Mon Aug 6 14:31:37 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * numeric.c (num_divmod): fix typo.
+
+Mon Aug 6 03:29:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_lstrip_bang): new method.
+
+ * string.c (rb_str_rstrip_bang): new method.
+
+Mon Aug 6 00:35:03 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * struct.c (rb_struct_modify): should check frozen and taint
+ status.
+
+Sun Aug 5 19:28:39 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * string.c (rb_str_associate): should consider STR_ASSOC too.
+
+Sun Aug 5 07:46:18 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_undefined): do not recurse if method_missing is
+ undefined.
+
+Thu Aug 2 21:37:32 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (proc_waitpid): now all arguments are optional.
+
+ * process.c (Init_process): waitpid is now alias to wait.
+
+ * process.c (Init_process): waitpid2 is now alias to wait2.
+
+ * process.c (rb_waitpid): made public.
+
+ * ext/pty/pty.c (pty_getpty): avoid disturbing SIGCHLD using
+ thread and rb_waitpid.
+
+Thu Aug 2 11:23:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (proc_getpgrp): now takes no argument on all
+ platforms.
+
+ * process.c (proc_setpgrp): ditto.
+
+Thu Aug 2 01:29:42 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (strrdirsep): removed meaningless code.
+
+ * file.c (rb_file_s_expand_path): reverted to 1.66.
+
+Wed Aug 1 16:17:47 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/socket.c (sock_s_pack_sockaddr_in): added
+ Socket::pack_sockaddr_in(). [new]
+
+ * ext/socket/socket.c (sock_s_pack_sockaddr_un): added
+ Socket::pack_sockaddr_un(). [new]
+
+ * ext/socket/socket.c (sock_s_pack_sockaddr_in): added
+ Socket::unpack_sockaddr_in(). [new]
+
+ * ext/socket/socket.c (sock_s_pack_sockaddr_un): added
+ Socket::unpack_sockaddr_un(). [new]
+
+Wed Aug 1 15:42:16 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * eval.c (ruby_run): avoid VC++ warning.
+
+Tue Jul 31 17:30:53 2001 Usaku Nakamura <usa@ruby-lang.org>
+
+ * marshal.c (Init_marshal): fix typos.
+
+Tue Jul 31 15:16:39 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * process.c (last_status_set): nothing returned, should be void.
+
+ * ext/socket/socket.c (load_addr_info): ditto.
+
+Tue Jul 31 12:11:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (Init_marshal): new constant Marshal::MAJOR_VERSION
+ and Marshal::MINOR_VERSION.
+
+Tue Jul 31 07:18:04 2001 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * file.c (rb_file_s_expand_path): scans per path element not per
+ byte/character, including fix of [ruby-talk:18152] and
+ multi-byte pathname support.
+
+Tue Jul 31 11:52:10 2001 akira yamada <akira@ruby-lang.org>
+
+ * marshal.c (marshal_load): ruby_verbose test should be wrapped by
+ RTEST().
+
+Mon Jul 30 17:54:23 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_index): should return nil (not the default
+ value) if value is not in the hash.
+
+Mon Jul 30 12:55:47 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (num_div): new method added. alias to '/' which
+ should be preserved even if '/' is redefined (e.g. by
+ mathn). [new]
+
+Mon Jul 30 11:12:14 2001 Amos Gouaux <amos+ruby@utdallas.edu>
+
+ * lib/net/imap.rb: added new commands for managing folder quotas
+ and folder ACLs.
+
+Mon Jul 30 03:19:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_cstr2inum): "0 ff".hex should return 0, not 255.
+
+Fri Jul 27 22:29:41 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (rb_file_s_expand_path): fixed using CharNext().
+
+Fri Jul 27 18:07:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_provided): extension should be guessed using
+ rb_find_file_noext().
+
+ * eval.c (rb_f_require): should call rb_feature_p() after
+ extension completion.
+
+Fri Jul 27 16:25:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): add CHECK_INTS before next, redo, retry to
+ avoid potential uninterruptable infinite loop.
+
+Thu Jul 26 11:27:12 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * file.c (rb_find_file_noext, rb_find_file): fix tilde expansion
+ problem.
+
+Wed Jul 25 17:54:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_file_s_expand_path): use CharNext() to expand.
+
+Wed Jul 25 17:16:26 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * intern.h: add some missing function prototypes.
+
+Wed Jul 25 15:50:05 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * file.c (rb_file_s_expand_path): should not expand "." and ".."
+ not following dirsep.
+
+Wed Jul 25 12:15:32 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * file.c (rb_find_file_noext): should update f by expanded path.
+
+ * file.c (rb_find_file): ditto.
+
+Tue Jul 24 23:10:47 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (strrdirsep): multi-byte pathname and DOSish separator
+ support. originally comes from Patrick Cheng. [new]
+
+ * file.c (rb_file_s_basename, rb_file_s_dirname): use
+ strrdirsep(). comes from Patrick Cheng.
+
+ * file.c (is_absolute_path): restricted in DOSish absolute path
+ with drive letter, and UNC support. originally comes from
+ Patrick Cheng.
+
+ * file.c (getcwd): define macro using getwd() unless provided.
+
+Tue Jul 24 19:23:15 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: dig the target subdirectory for
+ lib/* files properly in case of create_makefile("dir/name").
+
+Mon Jul 23 00:26:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_provide_feature): should not tweak extension used for
+ loading.
+
+Sun Jul 22 21:16:43 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: introduce a couple of new make
+ variables: CLEANFILES and DISTCLEANFILES. They'd typically be
+ defined in a file "depend".
+
+Sat Jul 21 09:40:10 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * io.c (io_fread): use fread(3) if PENDING_COUNT is available.
+
+Fri Jul 20 22:55:01 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * gc.c (ruby_xrealloc): fix a dangling bug which led memory
+ reallocation to fail even though the second try after a GC
+ succeeds.
+
+Fri Jul 20 03:00:46 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * class.c (rb_mod_include_p): Module#include? added. [new]
+
+Fri Jul 20 01:05:50 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (ignorecase_setter): give warning on modifying $=.
+
+ * string.c (rb_str_casecmp): new method. [new]
+
+ * string.c (rb_str_eql): separated from rb_str_equal(), make it
+ always be case sensitive. [new]
+
+ * string.c (rb_str_hash): made it always be case sensitive.
+
+Thu Jul 19 13:03:15 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_f_require): should not include path in $" value
+
+ * file.c (rb_find_file): should return 0 explicitly on failure.
+
+Tue Jul 17 11:44:40 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * ruby.h: enable volatile directive with VC++.
+
+ * regex.c: ditto.
+
+Tue Jul 17 06:01:12 2001 Minero Aoki <aamine@loveruby.net>
+
+ * doc/net/smtp.rd.ja, pop.rd.ja, http.rd.ja: new files.
+
+ * MANIFEST: add doc/net/{http,pop,smtp}.rd.ja.
+
+Tue Jul 17 11:22:01 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (NUM_FAILURE_ITEMS): was confusing NUM_REG_ITEMS and
+ NUM_NONREG_ITEMS, which have happened to be same value.
+
+Tue Jul 17 11:08:34 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * ext/extmk.rb.in: modify RM macro because command.com/cmd.exe don't
+ recognize single quotation as quote character.
+
+ * lib/mkmf.rb: ditto.
+
+Tue Jul 17 01:38:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_class_new): subclass check moved to this function.
+
+ * class.c (rb_class_boot): check less version of rb_class_new().
+
+Man Jul 16 13:21:30 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * file.c (file_load_ok): fix typo.
+
+Mon Jul 16 12:58:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_invoke): should preserve iter status for embedded
+ frame in the block.
+
+Mon Jul 16 00:04:39 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_file_s_expand_path): may overrun buffer on stack.
+
+Sun Jul 15 01:38:28 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * string.c (rb_str_insert): forgot to call rb_str_modify().
+
+Sat Jul 14 12:26:30 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/digest/*/extconf.rb: fix so that they build from any
+ directory.
+
+Sat Jul 14 06:20:17 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/net/http.rb: HTTP#proxy? did not worked.
+
+Sat Jul 14 02:56:19 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in: support multi-level ext/ directories.
+ (e.g. you can have ext/foo, ext/foo/bar and ext/foo/baz)
+
+Sat Jul 14 02:55:02 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/.cvsignore: let cvs ignore extinit.c.
+
+Fri Jul 13 23:47:35 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_search): should consider reverse search.
+
+Fri Jul 13 22:26:09 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/mkmf.rb: use File::split to split a target into a prefix and
+ a module name. This also works around a just found bug of
+ String#rindex.
+
+ * ext/extmk.rb.in: ditto.
+
+Fri Jul 13 02:36:10 2001 Minero Aoki <aamine@loveruby.net>
+
+ * dir.c (dir_s_chdir): warn only when invoked from multiple
+ threads or block is not given.
+
+Thu Jul 12 15:11:48 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/socket.c (ruby_connect): workaround for the setup of
+ Cygwin socket(EALREADY).
+
+Mon Jul 9 16:49:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in: modify RM macro.
+
+ * lib/mkmf.rb: ditto.
+
+Sun Jul 8 20:52:02 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ruby.h: fix a wrong function name: rb_iglob() -> rb_globi().
+
+Sun Jul 8 16:04:35 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: rename HTTP#request_by_name to send_request.
+
+ * lib/net/protocol.rb (ProtoSocket#read): modify typo.
+
+Sat Jul 7 17:45:35 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_convert_type): should use rb_rescue(), not rb_rescue2().
+
+ * range.c (range_init): ditto.
+
+Fri Jul 6 18:01:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_dup): copies (actually does not free)
+ generic_ivar on dupif original owns them.
+
+Fri Jul 6 02:15:06 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/tempfile.rb: a tempfile must be created with mode 0600.
+
+Thu Jul 5 20:28:53 2001 Tietew <tietew@tietew.net>
+
+ * string.c (rb_str_each_line): should propagate taint mark.
+
+ * ext/nkf/nkf.c (rb_nkf_kconv): ditto.
+
+Fri Jul 6 14:54:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_require): revamp for simpler implementation.
+
+ * file.c (rb_find_file_noext): use String object, instead of
+ passing char* around.
+
+ * file.c (rb_find_file): ditto.
+
+Thu Jul 5 22:01:02 2001 Mitsuhiro Kondo <kondo@nik-prt.co.jp>
+
+ * dln.c (dln_load): should use NSLINKMODULE_OPTION_BINDNOW.
+
+Thu Jul 5 13:44:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.c (load_file): local variables 'c' remain uninitialized on
+ xflag.
+
+Thu Jul 5 10:00:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_match): prefetched escaped character too early.
+
+Wed Jul 4 08:58:30 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call0): add argument check for attr_readers.
+
+Wed Jul 4 04:22:44 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb (HTTP#request_by_name): arg order changes.
+
+Wed Jul 4 04:07:36 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb (HTTP#request_by_name): bug fix.
+
+ * lib/net/http.rb: does not write Connection: by default.
+
+ * lib/net/protocol.rb: "start" for started protocol is an error.
+
+ * lib/net/protocol.rb: "finish" for finished protocol is an error.
+
+Wed Jul 4 03:17:31 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/http.rb: new method HTTP#request_by_name (test)
+
+ * lib/net/http.rb: new class HTTPGenericRequest
+
+Tue Jul 3 23:58:29 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/mkmf.rb: distclean should remove mkmf.log as well.
+
+Tue Jul 3 18:35:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval_string_wrap): should push frame (and adjust
+ cbase) before wrapped eval.
+
+ * eval.c (rb_eval_cmd): ditto.
+
+ * eval.c (eval): should update ruby_class always after all.
+
+Tue Jul 3 14:56:27 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * eval.c (block_pass): do not change wrapper information.
+
+ * eval.c (rb_yield_0): preserve wrapper information.
+
+Tue Jul 3 08:59:50 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * error.c (rb_name_error): raise NameError instead of LoadError.
+
+Mon Jul 2 17:22:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (exc_exception): clone the receiver exception instead of
+ creating brand new exception object of the receiver.
+
+Mon Jul 2 09:53:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval_string_wrap): extend new ruby_top_self, not
+ original self.
+
+ * eval.c (rb_eval_cmd): respect ruby_wrapper if set.
+
+ * eval.c (eval): do not update ruby_class unless scope is not
+ provided.
+
+Sun Jul 1 10:51:15 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * eval.c (eval): preserve wrapper information.
+
+ * eval.c (proc_invoke): ditto.
+
+ * eval.c (block_pass): ditto.
+
+Sat Jun 30 02:55:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (void_expr): too much warnings for void context
+ (e.g. foo[1] that can be mere Proc call).
+
+Fri Jun 29 17:23:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (rb_name_error): new function to raise NameError with
+ name attribute set.
+
+ * eval.c (rb_f_missing): set name and args in the exception
+ object. [new]
+
+ * error.c (name_name): NameError#name - new method.
+
+ * error.c (nometh_args): NoMethodError#args - new method.
+
+Fri Jun 29 15:29:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lex.c (rb_reserved_word): lex_state after tRESCUE should be
+ EXPR_MID.
+
+Thu Jun 28 00:21:28 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * lib/matrix.rb: resolve 'ruby -w' warnings.
+
+ * lib/irb/locale.rb: resolve 'ruby -w' warnings.
+
+ * lib/irb/multi-irb.rb: resolve 'ruby -w' warnings.
+
+ * lib/irb/ruby-lex.rb: fix problem for "\\M-\\..." and "\\C-\\..."
+ and resolve 'ruby -w' warnings.
+
+ * lib/irb/ruby-token.rb: fix typo
+
+ * lib/shell/command-processor.rb: resolve 'ruby -w' warnings.
+
+Wed Jun 27 08:53:26 2001 Minero Aoki <aamine@loveruby.net>
+
+ * lib/net/pop.rb: new methods POP3.auth_only, POP3#auth_only
+
+ * lib/net/http.rb: HTTP.Proxy returns self if ADDRESS is nil.
+
+ * lib/net/protocol.rb: new method ProtocolError#response
+
+ * lib/net/protocol.rb,smtp.rb,pop.rb,http.rb: add document.
+
+Tue Jun 26 18:42:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (add_heap): allocation size of the heap unit is doubled for
+ each allocation.
+
+Mon Jun 25 09:54:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (isdelim): space, tab, and newline are no longer
+ delimiters for glob patterns.
+
+Sat Jun 23 22:28:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (svalue_to_avalue): new conversion scheme between single
+ value and array values.
+
+ * eval.c (avalue_to_svalue): ditto.
+
+ * eval.c (rb_eval): REXPAND now uses avalue_to_svalue(), return
+ and yield too.
+
+ * eval.c (rb_yield_0): use avalue_to_svalue().
+
+ * eval.c (proc_invoke): Proc#call gives avaules, whereas
+ Proc#yield gives mvalues.
+
+ * eval.c (bmcall): convert given value (svalue) to avalue.
+
+Sat Jun 23 18:28:52 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/readline/readline.c (readline_event): a non-void function
+ should return a value.
+
+Fri Jun 22 23:17:28 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/socket/socket.c (ruby_connect): workaround for the setup of
+ Cygwin socket.
+
+Fri Jun 22 23:11:17 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * lib/irb/locale.rb: fix for require "kconv" problem
+
+Fri Jun 22 18:08:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): no mvalue_to_svalue conversion here.
+
+ * eval.c (massign): takes svalue, convert it to mvalue inside.
+
+ * eval.c (rb_eval): parameters for yield/return are always
+ svalues now.
+
+ * eval.c (svalue_to_mvalue): more strict conversion.
+
+ * eval.c (mvalue_to_svalue): ditto.
+
+Fri Jun 22 17:12:23 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * st.c (new_size): prime hash size enabled.
+
+ * ext/socket/socket.c (Init_socket): SO_* constants added.
+
+Tue Jun 19 22:24:07 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * gc.c (rb_setjmp): avoid GCC 3.0 warnings.
+
+Tue Jun 19 18:19:30 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/readline/readline.c: add new methods:
+ Readline::completion_append_character and
+ Readline::completion_append_character=.
+
+Tue Jun 19 16:29:50 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (svalue_to_mvalue): new function to convert from svalue
+ to mvalue. [experimental]
+
+ * eval.c (mvalue_to_svalue): new function to convert from mvalue
+ to svalue.
+
+ * eval.c (rb_eval): use mvalue_to_svalue().
+
+ * eval.c (rb_yield_0): use mvalue_to_svalue().
+
+ * eval.c (proc_invoke): proper mvalue handling.
+
+Mon Jun 18 17:38:50 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_require): searches ".rb" and ".so" at the same
+ time. previous behavior (search ".rb", then ".so") has a
+ security risk (ruby-bugs#PR140).
+
+ * array.c (rb_ary_to_ary): new function to replace internal
+ rb_Array(), which never calls to_a, but to_ary (rb_Array() might
+ call both). [new]
+
+Mon Jun 18 00:43:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (PUSH_FAILURE_POINT): push option status again.
+
+ * regex.c (re_compile_pattern): avoid pushing unnecessary
+ option_set.
+
+Sat Jun 16 10:58:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_load): tainted string is OK if wrapped *and*
+ $SAFE >= 4.
+
+Thu Jun 14 16:27:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_start_0): should not nail down higher blocks
+ before preserving original context (i.e. should not alter
+ original context).
+
+Wed Jun 13 19:34:59 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * dir.c (Init_Dir): add a new method File::fnmatch? along with
+ File::Constants::FNM_*. While I am here, FNM_NOCASE is renamed
+ to FNM_CASEFOLD which is commonly used by *BSD and GNU libc.
+
+Wed Jun 13 09:33:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_yield): new method equivalent to Proc#call but no
+ check for number of arguments. [new]
+
+Tue Jun 12 14:21:28 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * lib/mkmf.rb: target_prefix is only for installation, not for
+ build.
+
+Tue Jun 12 00:41:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (method_eq): new method Method#==. [new]
+
+Mon Jun 11 14:29:41 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * confgure.in: add RUBY_CANONICAL_BUILD.
+
+Sun Jun 10 17:31:47 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * gc.c (STR_NO_ORIG): STR_NO_ORIG value was different between
+ string.c and gc.c
+
+Sat Jun 9 22:10:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should convert *non-array at the end of
+ arguments by using Array().
+
+Sat Jun 9 17:04:30 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * hash.c (ruby_setenv): readline library leaves their environment
+ strings uncopied. "free" check revised.
+
+Sat Jun 9 16:31:03 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * ext/extmk.rb.in: Use -F and -T for mswin32 because cl.exe doesn't
+ support -o officially and cl.exe considers that *.cc and *.cxx are
+ OBJs.
+
+ * lib/mkmf.rb: ditto.
+
+ * win32/Makefile.sub: Use del instead of rm.
+ All these changes are derived from Nobuyoshi Nakada's patch.
+ Thanks.
+
+Fri Jun 8 22:37:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (Init_stack): avoid __builtin_frame_address(2) to retrieve
+ stack bottom line.
+
+Fri Jun 8 18:14:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * st.c (numhash): should shuffle bits by dividing by prime number.
+
+Fri Jun 8 17:05:21 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): multiple assignment behavior fixed, which
+ results "*a = nil" makes "a == []" now.
+
+Fri Jun 8 15:25:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_require): should set SCOPE_PUBLIC before calling
+ dln_load().
+
+Thu Jun 7 17:28:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): exclude kDO_BLOCK too much by false condition.
+
+Wed Jun 6 23:02:36 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * lib/sync.rb: bug fix if obj.initialize has parameters when
+ obj.extend(Sync_m)
+
+ * lib/mutex_m.rb: modified bit
+
+Wed Jun 6 16:11:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_load): should check if tainted even when wrap is
+ specified.
+
+Wed Jun 6 14:34:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (mrhs_basic): "*arg" should always be expanded by REXPAND.
+
+ * regex.c (re_compile_pattern): too much optimization for the
+ cases like /(.|a)b/.
+
+Tue Jun 5 23:58:43 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (fc_i): removed vast string allocation.
+
+Tue Jun 5 16:45:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (Init_Exception): NameError went under StandardError,
+ and NoMethodError went under NameError.
+
+Tue Jun 5 16:40:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (rb_intern): non identifier symbols should be
+ categorized as ID_JUNK. [new]
+
+Tue Jun 5 16:15:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_const_at): use hash table as internal
+ data. [new]
+
+ * variable.c (rb_mod_const_of): ditto.
+
+ * variable.c (rb_const_list): new function to convert internal
+ data (hash table) to array of strings.
+
+ * eval.c (rb_mod_s_constants): data handling scheme has changed.
+
+Tue Jun 5 15:16:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_add_method): should not call rb_secure(), for
+ last_func may not be set.
+
+ * io.c (rb_io_ctl): ioctl should accept any integer within C long
+ range.
+
+Tue Jun 5 13:41:13 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/etc/extconf.rb: use egrep_cpp.
+
+Tue Jun 5 12:44:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (r_object): wrong type check for modules.
+
+ * marshal.c (w_object): should not dump anonymous classes/modules.
+
+Tue Jun 5 01:19:34 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_open_file): use rb_file_sysopen_internal() if the 3rd
+ argument (permission flags) is given. [new, should be backported?]
+
+ * io.c (rb_io_mode_binmode): mode string (e.g. "r+") to flags to
+ open(2).
+
+Mon Jun 4 23:55:54 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): NODE_REXPAND expand an array of 1 element as
+ the element itself. [new, should be backported?]
+
+ * parse.y (ret_args): should treat "*[a]" in rhs expression as
+ "a", not "[a]".
+
+Mon Jun 4 04:14:53 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/shellwords.rb: don't destroy argument.
+
+Sat Jun 2 23:23:05 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): should push option modifier at the
+ right place.
+
+Sat Jun 2 23:05:20 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/cgi/session.rb: don't use module_function for Class.
+
+Sat Jun 2 00:02:22 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * irb messages: fix typos.
+
+Fri Jun 1 17:26:24 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * hash.c (replace_i): ignore when key == Qundef.
+
+Fri Jun 1 16:50:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (call_args2): confusion with list_append() and
+ list_concat() was fixed.
+
+Fri Jun 1 15:01:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): fixed 'print CGI::bar() {}, "\n"' syntax
+ breakage, adding new lex_state status. sigh. [new]
+
+Fri Jun 1 11:21:04 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: use waitpid on mingw32.
+
+ * ext/dbm/extconf.rb: include <ndbm.h>, not <gdbm.h>.
+
+Thu May 31 18:34:57 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * file.c (rb_file_s_unlink): should not allow if $SAFE >= 2.
+
+Thu May 31 17:23:25 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (Init_Range): define "to_ary".
+
+Thu May 31 13:30:25 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * mkconfig.rb, ext/configsub.rb: VERSION -> RUBY_VERSION.
+
+Thu May 31 08:00:58 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * win32/dir.h: re-add.
+
+Thu May 31 01:25:59 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * configure.in: default --with-libc_r to `no' until the problem is
+ fixed. (FreeBSD only)
+
+Tue May 29 17:24:23 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * ruby.c (proc_options): unexpected SecurityError happens when -T4.
+
+Tue May 29 18:46:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): * \1 .. \9 should be
+ backreferences always.
+
+ * regex.c (re_match): backreferences corresponding to
+ unclosed/unmatched parentheses should fail always.
+
+Tue May 29 16:35:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_cat): use rb_str_buf_cat() if possible. [new]
+
+ * string.c (rb_str_append): ditto.
+
+ * string.c (rb_str_buf_cat): remove unnecessary check (type,
+ taint, modify) to gain performance.
+
+ * string.c (rb_str_buf_append): ditto.
+
+ * string.c (rb_str_buf_finish): removed.
+
+Tue May 29 02:05:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_buf_new): buffering string function. [new]
+
+ * string.c (rb_str_buf_append): ditto.
+
+ * string.c (rb_str_buf_cat): ditto.
+
+ * string.c (rb_str_buf_finish): ditto.
+
+Mon May 28 23:20:43 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: remove unnecessary AC_CANONICAL_BUILD
+
+ * defines.h: #define HAVE_SETITIMER on Cygwin(bug fixed).
+
+ * ruby.c: use relative path from LIBRUBY_SO.
+
+ * ruby.c: don't use -mwin32 option on Cygwin.
+
+ * cygwin/GNUmakefile.in: ditto.
+
+ * ext/sdbm/_sdbm: ditto.
+
+ * ext/tcltklib/extconf.rb: ditto.
+
+ * ext/tcltklib/stubs.c: ditto.
+
+Mon May 28 22:12:01 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/extconf.rb.in: make the priority of the make rule of .c
+ higher than .C .
+
+Mon May 28 13:22:19 2001 Tanaka Akira <akr@m17n.org>
+
+ * time.c (make_time_t): local time adjustment revised.
+
+Mon May 28 02:20:38 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * dir.c (glob_helper): teach has_magic() to handle flags and get
+ glob_helper to properly support FNM_NOESCAPE.
+
+ * dir.c (fnmatch): fix a bug when FNM_PATHNAME and FNM_PERIOD are
+ specified at the same time.
+
+Sat May 26 09:55:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y: accomplish extended syntax described in [ruby-talk:14525]
+ using tSPC token. [new, experimental]
+
+Sat May 26 07:05:45 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * MANIFEST: add win32/dir.h .
+
+Fri May 25 20:03:51 2001 Pascal Rigaux <pixel@mandrakesoft.com>
+
+ * dln.c (dln_find_1): should exclude directories in executable
+ file lookup.
+
+Fri May 25 18:00:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_obj_singleton_methods): list methods in extended
+ modules if optional argument is true. [new]
+
+Fri May 25 14:19:25 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * string.c (rb_str_replace): add taint status infection
+ (OBJ_INFECT()).
+
+ * string.c (rb_str_crypt): ditto.
+
+ * string.c (rb_str_ljust): ditto.
+
+ * string.c (rb_str_rjust): ditto.
+
+ * string.c (rb_str_center): ditto.
+
+Fri May 25 05:39:03 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/sha1/sha1-ruby.c (sha1_hexdigest): fix buffer overflow. The
+ buffer for a SHA-1 hexdigest needs to be 41 bytes in length.
+
+Fri May 25 01:47:39 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * MANIFEST: update the entries I forgot to add or remove.
+
+Fri May 25 00:57:25 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/sha1/sha1-ruby.c (sha1_new): separate initialize() from
+ new().
+
+ * ext/md5/md5init.c (md5i_new): ditto.
+
+Fri May 25 00:53:41 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/dbm/extconf.rb: fix support for *BSD and set $CFLAGS
+ properly.
+
+Thu May 24 16:10:33 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_member): check based on "<=>" comparison. [new]
+
+ * range.c (range_check): add "succ" check if first end is not a
+ numeric.
+
+ * range.c (range_eqq): comparison should based on "<=>".
+
+ * range.c (range_each): ditto.
+
+Thu May 24 16:08:21 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * mkconfig.rb: autoconf 2.50 support.
+
+Thu May 24 14:23:35 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): need argument adjustment for C defined
+ blocks too.
+
+Thu May 24 01:11:30 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/dbm/extconf.rb: header search added. [new]
+
+Wed May 23 02:58:21 2001 Tanaka Akira <akr@m17n.org>
+
+ * time.c (make_time_t): fix ad-hoc local time adjustment, using
+ binary tree search.
+
+Tue May 22 17:10:35 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * variable.c (rb_alias_variable): should not allow variable
+ aliasing if $SAFE >= 4.
+
+Tue May 22 02:37:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (expr): "break" and "next" to take optional expression,
+ which is used as a value for termination. [new, experimental]
+
+ * eval.c (rb_eval): "break" can give value to terminating method.
+
+ * eval.c (rb_eval): "break" and "next" to take optional expression.
+
+ * eval.c (rb_yield_0): "next" can give value to terminating "yield".
+
+ * eval.c (rb_iterate): "break" can give value to terminating method.
+
+ * eval.c (proc_call): ditto.
+
+Mon May 21 13:15:25 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big2str): t should be protected from GC.
+
+Sat May 19 09:29:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (rb_proc_times): need not to check return value from
+ times(2).
+
+Fri May 18 05:36:08 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in (xsystem): backout the previous fix which was
+ bogus.
+
+Fri May 18 05:19:55 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/mkmf.rb (xsystem): make a temporary fix to get $(...) macros
+ properly expanded on a command execution.
+
+ * ext/extmk.rb.in (xsystem): ditto.
+
+Fri May 18 03:45:55 2001 Brian F. Feldman <green@FreeBSD.org>
+
+ * lib/mkmf.rb: unbreak "make install". lib/* must be installed
+ under $rubylibdir, not under $libdir.
+
+Fri May 18 01:28:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (expr): break, next, redo, retry are moved from primary.
+
+Fri May 18 01:11:02 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * ext/sha1/sha1-ruby.c (sha1_new): get rid of an unneeded
+ rb_obj_call_init() call.
+
+Fri May 18 01:03:55 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * ext/sha1/sha1.txt, ext/sha1/sha1.txt.jp: fix typos.
+
+Thu May 17 19:17:11 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/shell.rb, lib/shell/process-controller.rb,
+ lib/shell/command-processor.rb: translate Japanese comments into
+ English.
+
+Thu May 17 19:07:14 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * doc/shell.rd.jp: RD'ify and make some fixes.
+
+ * doc/shell.rd: RD'ify, delete Japanese leftovers, make overall
+ English fixes, and sync with doc/shell.rd.jp.
+
+Thu May 17 17:35:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_call0): address of local_vars might change during eval.
+
+Thu May 17 07:27:09 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/md5/md5.txt.jp, ext/sha1/sha1.txt.jp:
+ s/SuperClass/Superclass/.
+
+Thu May 17 07:21:44 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/Setup.dj, ext/Setup.emx, ext/Setup.nt, ext/Setup.x68:
+ compile sha1 in as well as md5.
+
+ * ext/Setup: put sha1 in a comment.
+
+Thu May 17 07:16:38 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/sha1/sha1.txt.jp: add the Japanese version derived from
+ ext/md5/md5.txt.jp.
+
+ * ext/sha1/sha1.txt: revise the copyright info and reduce the
+ difference from ext/md5/md5.txt.
+
+ * ext/md5/md5.txt: reduce the difference from ext/sha1/sha1.txt.
+
+Thu May 17 07:11:35 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/sha1/extconf.rb, ext/sha1/sha1.c: use WORDS_BIGENDIAN to
+ detect the platform's endian.
+
+Thu May 17 06:31:30 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/md5/md5.txt: make wording fixes, and mention the newly added
+ method: "<<".
+
+ * ext/md5/md5.txt.jp: ditto.
+
+Wed May 16 18:05:52 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/md5/md5init.c: add an instance method "<<" as an alias for
+ "update". (inspired by Steve Coltrin's ruby-sha1)
+
+Tue May 15 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_and): should not push frozen key string.
+
+ * array.c (rb_ary_or): ditto.
+
+Tue May 15 02:18:23 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/thread.rb: rescue ThreadError in case the thread is dead
+ just before calling Thread#run.
+
+Mon May 14 13:50:22 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_schedule): should save context before raising
+ deadlock, saved context for current thread might be obsolete.
+
+ * time.c (make_time_t): non DST timezone shift supported (hopefully).
+
+ * time.c (make_time_t): strict range detection for negative time_t.
+
+Mon May 14 11:54:20 2001 Tanaka Akira <akr@m17n.org>
+
+ * signal.c: SIGINFO added.
+
+Mon May 14 08:57:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_ensure): should not SEGV when prot_tag is NULL.
+
+Sun May 13 23:51:14 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * win32/resource.rb: Modify copyright in resource script.
+
+Sun May 13 14:03:33 2001 Okada Jun <yun@be-in.org>
+
+ * lib/thread.rb: fix Queue#pop and SizedQueue#max= to avoid
+ deadlock.
+
+Sat May 12 15:43:55 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * win32/win32.c (kill): add support of signal 9 on mswin32/mingw32.
+
+Fri May 11 15:09:52 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ruby.h (rb_string_value): add volatile to avoid compiler warning.
+
+ * string.c (rb_string_value): ditto.
+
+Fri May 11 03:35:33 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * README.EXT: Document find_library(), with_config() and
+ dir_config().
+
+Fri May 11 03:34:20 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * README.EXT.jp: Remove the description of find_header() because
+ such a function does not actually exist.
+
+ * README.EXT.jp: Update the description of dir_config().
+
+Fri May 11 02:42:05 2001 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * README, README.jp: Fix CVS access and mailing lists info.
+
+Fri May 11 02:00:44 2001 Ryo HAYASAKA <ryoh@jaist.ac.jp>
+
+ * bignum.c (bigdivrem): access boundary bug.
+
+Thu May 10 02:40:47 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): prohibit dumping out singleton classes.
+
+ * object.c (rb_mod_to_s): distinguish singleton classes.
+
+ * variable.c (rb_class2name): it's ok to reveal NilClass,
+ TrueClass, FalseClass.
+
+Wed May 9 14:38:33 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (rb_yield_0): preserve and restore ruby_cref as well.
+
+Tue May 8 18:28:19 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
+
+ * lib/irb.rb lib/irb/multi-irb.rb lib/irb/ruby-lex.rb
+ lib/irb/version.rb resolve ctrl-c problem
+
+Tue May 8 17:12:43 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (is_defined): core dumped during instance_eval for
+ special constants.
+
+ * eval.c (rb_eval): ditto.
+
+Tue May 8 08:52:57 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * doc/forwardable.rd, doc/forwardable.rd.jp: Hit `=begin' and
+ `=end' in proper places so rd2 can format them without a problem.
+
+ * doc/irb/irb-tools.rd.jp, doc/irb/irb.rd, doc/irb/irb.rd.jp:
+ ditto.
+
+Tue May 8 08:38:53 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * doc/forwardable.rd, doc/forwardable.rd.jp, lib/forwardable.rb:
+ Import forwardable 1.1.
+
+Tue May 8 08:34:33 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * doc/irb/irb-tools.rd.jp, doc/irb/irb.rd.jp: Convert from JIS to
+ EUC.
+
+Tue May 8 03:46:39 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * sample/rbc.rb: Obsoleted by IRB.
+
+Mon May 7 15:58:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): "||=" should not warn for uninitialized instance
+ variables.
+
+ * eval.c (rb_eval): ditto.
+
+ * eval.c (eval): preserve and restore ruby_cref as well.
+
+Mon May 7 15:45:48 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/ftools.rb (syscopy): chmod destination file only if
+ it does not exist.
+
+Mon May 7 14:35:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_is_instance_of): takes only class/module as an
+ argument.
+
+Sun May 6 16:27:29 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * eval.c (is_defined): rb_reg_nth_defined() may return Qnil.
+
+Thu May 3 03:15:06 2001 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * configure.in: get --enable-shared to work on MacOS X.
+
+ * Makefile.in: make $(LIBRUBY_SO) depend on miniruby properly.
+ Now `make -jN' should work without a problem.
+
+Thu May 3 02:07:45 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * win32/config.h.in: add SIZEOF___INT64 definition.
+
+Wed May 2 20:39:35 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dir.c (rb_glob, rb_globi): remove unnecessary FNM_PATHNAME.
+
+Wed May 2 11:46:13 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (block_pass): should not downgrade safe level.
+
+Wed May 2 03:07:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/dbm/extconf.rb: allow specifying dbm-type explicitly.
+
+ * ext/dbm/extconf.rb: avoid gdbm if possible, because it leaks
+ memory, whereas gdbm.so doesn't. potential incompatibility.
+
+Wed May 2 02:02:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_insert): new method.
+
+Tue May 1 17:55:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): lex_state after RESCUE_MOD should be EXPR_BEG.
+
+Tue May 1 16:23:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_insert): new method.
+
+ * array.c (rb_ary_update): new utility function.
+
+Tue May 1 03:24:05 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/irb/completion.rb, lib/irb/frame.rb, lib/irb/xmp.rb,
+ doc/irb/irb-tools.rd.jp: Merge from irb-tools 0.7.1.
+
+Tue May 1 03:07:17 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * sample/irb.rb, lib/irb.rb, lib/irb/*, doc/irb/*: Merge from irb
+ 0.7.3.
+
+ * instruby.rb: Install help-message's too.
+
+ * lib/irb/main.rb: This file is not needed anymore.
+
+Fri Apr 27 09:27:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (set_outfile): should check if closed before assignment.
+
+Thu Apr 26 22:36:11 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: don't use tzname on Cygwin 1.3.1+.
+
+ * configure.in: add -mieee/-ieee to CFLAGS on OSF1/Alpha
+ to disable "DIVISION BY ZERO" exception.
+
+Thu Apr 26 22:30:43 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should preserve value of ruby_errinfo.
+
+Thu Apr 26 10:36:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_schedule): infinite sleep should not cause
+ dead lock.
+
+Wed Apr 25 16:40:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_flatten_bang): proper recursive detection.
+
+Wed Apr 25 15:36:15 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (yield_under): need not to prohibit at safe level 4.
+
+Wed Apr 25 15:22:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_pack): p/P packs nil into NULL.
+
+ * pack.c (pack_unpack): p/P unpacks NULL into nil.
+
+Tue Apr 24 15:35:32 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_pack): size check for P template.
+
+ * ruby.c (set_arg0): wrong predicate when new $0 value is bigger
+ than original space.
+
+Tue Apr 24 15:18:49 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: (dir_config) do not add the
+ specified include directory if already included in $CPPFLAGS.
+
+ * ext/extmk.rb.in, lib/mkmf.rb: (dir_config) return a more useful
+ value, [include_dir, lib_dir].
+
+Mon Apr 23 14:43:59 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (id2ref): should use NUM2ULONG()
+
+ * object.c (rb_mod_const_get): check whether name is a class
+ variable name.
+
+ * object.c (rb_mod_const_set): ditto.
+
+ * object.c (rb_mod_const_defined): ditto.
+
+Sat Apr 21 22:33:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_float): precision changed to "%.16g"
+
+Sat Apr 21 22:07:58 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * eval.c (rb_call0): wrong retry behavior.
+
+Fri Apr 20 19:12:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (fix_aref): a bug on long>int architecture.
+
+Fri Apr 20 14:57:15 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (rb_eval_string_wrap): should restore ruby_wrapper.
+
+Sun Apr 22 17:44:37 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: add -mieee to CFLAGS on Linux/Alpha
+ to disable "DIVISION BY ZERO" exception.
+
+ * configure.in: remove -ansi on OSF/1.
+
+Wed Apr 18 04:37:51 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: CGI::Cookie: no use PATH_INFO.
+
+Wed Apr 18 00:24:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): char class at either edge of range
+ should be invalid.
+
+Tue Apr 17 17:33:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (handle_rescue): use === to compare exception match.
+
+ * error.c (syserr_eqq): comparison between SytemCallErrors should
+ based on their error numbers.
+
+Tue Apr 17 16:54:39 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (safe_getter): should use INT2NUM().
+
+Tue Apr 17 15:12:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big2long): 2**31 cannot fit in 31 bit long.
+
+Sat Apr 14 22:46:43 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * regex.c (calculate_must_string): wrong length calculation.
+
+Sat Apr 14 13:37:32 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * win32/config.status.in: no longer use missing/alloca.c.
+
+ * win32/Makefile.sub: ditto.
+
+Fri Apr 13 12:40:48 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (rb_thread_start_0): fixed memory leak.
+
+Fri Apr 13 16:41:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (none): should clear cmdarg_stack too.
+
+Fri Apr 13 06:19:29 2001 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * io.c (rb_fopen): use setvbuf() to avoid recursive malloc() on
+ some platforms.
+
+Wed Apr 11 23:36:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_stat_dev): device functions should honor stat field
+ types (except long long such as dev_t).
+
+Wed Apr 11 18:07:53 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (rb_mod_nesting): should not push nil for nesting array.
+
+ * eval.c (rb_mod_s_constants): should not search array by
+ rb_mod_const_at() for nil (happens for singleton class).
+
+Wed Apr 11 13:29:26 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_singleton_class_attached): should modify iv_tbl by
+ itself, no longer use rb_iv_set() to avoid freeze check error.
+
+ * variable.c (rb_const_get): error message "uninitialized constant
+ Foo at Bar::Baz" instead of "uninitialized constantBar::Baz::Foo".
+
+Tue Apr 10 17:52:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_included): new hook called from rb_mod_include().
+
+Tue Apr 10 02:24:40 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * io.c (opt_i_set): should strdup() inplace_edit string.
+
+Mon Apr 9 23:29:54 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (exec_under): need to push cref too.
+
+Mon Apr 9 15:20:21 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_missing): raise NameError for "undefined local
+ variable or method".
+
+ * error.c (Init_Exception): new exception NoMethodError.
+ NameError moved under ScriptError again.
+
+ * eval.c (rb_f_missing): use NoMethodError instead of NameError.
+
+Mon Apr 9 12:05:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (Init_File): should redefine "new" class method.
+
+Mon Apr 9 11:56:52 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb: fix typo.
+
+Fri Apr 6 01:46:35 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (PUSH_CREF): sharing cref node was problematic. maintain
+ runtime cref list instead.
+
+ * eval.c (rb_eval): copy defn node before registering.
+
+ * eval.c (rb_load): clear ruby_cref before loading.
+
+Thu Apr 5 22:40:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_const_get): no recursion to show full class path
+ for modules.
+
+ * eval.c (rb_set_safe_level): should set safe level in curr_thread
+ as well.
+
+ * eval.c (safe_setter): ditto.
+
+Thu Apr 5 13:46:06 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * object.c (rb_obj_is_instance_of): nil belongs to false, not true.
+
+Thu Apr 5 02:19:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (make_time_t): proper (I hope) daylight saving time
+ handling for both US and Europe. I HATE DST!
+
+ * eval.c (rb_thread_wait_for): non blocked signal interrupt should
+ stop the interval.
+
+Wed Apr 4 03:47:03 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_eq): class check added.
+
+ * eval.c (proc_eq): typo fixed ("return" was omitted).
+
+ * error.c (Init_Exception): move NameError under StandardError.
+
+ * class.c (rb_mod_clone): should copy method bodies too.
+
+ * bignum.c (bigdivrem): should trim trailing zero bdigits of
+ remainder, even if dd == 0.
+
+ * file.c (check3rdbyte): safe string check moved here.
+
+Tue Apr 3 09:56:20 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in (create_makefile): create def file only if
+ it does not yet exist.
+
+ * lib/mkmf.rb: ditto.
+
+Tue Apr 3 00:05:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (make_time_t): remove HAVE_TM_ZONE code since it
+ sometimes reports wrong time.
+
+ * time.c (make_time_t): remove unnecessary range check for
+ platforms where negative time_t is available.
+
+Mon Apr 2 16:52:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (proc_waitall): should push Process::Status instead of
+ Fixnum status.
+
+ * process.c (waitall_each): should add all entries in pid_tbl.
+ these changes are inspired by Koji Arai. Thanks.
+
+ * process.c (proc_wait): should not iterate if pid_tbl is 0.
+
+ * process.c (proc_waitall): ditto.
+
+Mon Apr 2 14:25:49 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/monitor.rb (wait): ensure reentrance.
+
+ * lib/monitor.rb (wait): fix timeout support.
+
+Mon Apr 2 12:40:45 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb (media_subtype): return subtype.
+
+Mon Apr 2 12:01:15 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb (flag_list): capitalize flags.
+
+Mon Apr 2 01:32:38 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * Makefile.in: Introduce MAINLIBS.
+
+ * configure.in: Link libc_r against the ruby executable on
+ FreeBSD, which is the first attempt to work around a certain
+ problem regarding pthread on FreeBSD. It should make ruby/libruby
+ happy when it loads an extension to a library compiled and linked
+ with -pthread. Note, however, that libruby is _not_ linked with
+ libc_r so as not to mess up pthread unfriendly stuff including
+ apache+mod_ruby and vim6+ruby_interp.
+
+Mon Apr 2 01:16:24 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c: use ruby's opendir on mingw32.
+
+ * win32/dir.h, dir.c, Makefile: ditto.
+
+Sun Apr 1 23:26:14 2001 TOYOFUKU Chikanobu <toyofuku@juice.or.jp>
+
+ * numeric.c (flodivmod): a bug in no fmod case.
+
+Sun Apr 1 18:36:14 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * process.c (pst_wifsignaled): should apply WIFSIGNALED for status
+ (int), not st (VALUE).
+
+Sat Mar 31 04:47:55 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb: add document and example code.
+
+Sat Mar 31 03:24:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (Init_IO): value of $/ and $\ are no longer restricted to
+ strings. type checks are done on demand.
+
+ * class.c (rb_include_module): module inclusion should be check
+ taints.
+
+ * ruby.h (STR2CSTR): replace to StringType() and StringTypePtr().
+
+ * ruby.h (rb_str2cstr): ditto.
+
+Fri Mar 30 23:37:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_load): should not copy toplevel local variables. It
+ cause variable/method ambiguity. Thanks to L. Peter Deutsch.
+
+Fri Mar 30 22:56:56 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb: rename ContinueRequest to ContinuationRequest.
+
+Fri Mar 30 12:51:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_include_module): freeze check at first.
+
+Thu Mar 29 17:05:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_attr): sprintf() and rb_intern() moved into
+ conditional body.
+
+Wed Mar 28 23:43:00 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: add C++ rules in addition to C
+ rules for the mswin32 platforms.
+
+Wed Mar 28 19:29:21 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: move C++ rules to the right place.
+
+Wed Mar 28 17:39:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_str2cstr): warn if string contains \0 and length
+ value is ignored.
+
+Wed Mar 28 15:00:31 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * class.c (rb_singleton_class_clone): should copy class constant
+ table as well.
+
+Wed Mar 28 14:23:23 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_include_module): sometimes cache was mistakenly left
+ uncleared - based on the patch by K.Kosako.
+
+ * ruby.h: all Check_SafeStr()'s are replaced by SafeStr() to
+ ensure 'to_str' be always effective.
+
+Wed Mar 28 09:52:33 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/Makefile.sub: disable global optimization.
+
+Tue Mar 27 15:00:54 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (rb_mod_define_method): should have clear method cache.
+
+ * eval.c (rb_mod_define_method): should have raised exception for
+ type error.
+
+Tue Mar 27 14:48:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.h: changed "extern INLINE" to "static inline".
+
+Mon Mar 26 23:19:33 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * time.c (rb_strftime): check whether strftime returns empty string.
+
+Mon Mar 26 21:16:56 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb: supports response handlers and multiple commands.
+
+Mon Mar 26 17:21:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c: remove TMP_PROTECT_END to prevent C_ALLOCA crash.
+
+Mon Mar 26 14:04:41 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/Win32API/Win32API.c: remove Init_win32api().
+
+Sun Mar 25 16:52:48 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * file.c (rb_file_flock): do not trap EINTR.
+
+ * missing/flock.c (flock): returns the value from lockf(2)
+ directly.
+
+Sat Mar 24 23:44:50 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ev_const_defined): should ignore toplevel cbase (Object).
+
+ * eval.c (ev_const_get): ditto.
+
+Fri Mar 23 17:37:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/md5/md5.h: replace by independent md5 implementation
+ contributed by L. Peter Deutsch (thanks).
+
+ * ext/md5/md5init.c: adopted to Deutsch's md5 implementation.
+
+Fri Mar 23 17:26:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_unpack): string from P/p should be tainted.
+
+Fri Mar 23 12:18:44 2001 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * ext/curses/curses.c: curses on Mac OS X public beta does not
+ have _maxx etc.
+
+Fri Mar 23 10:50:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_object): should truncate trailing zero short for
+ bignums.
+
+Fri Mar 23 09:49:02 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (sym_intern): new method.
+
+Thu Mar 22 22:15:45 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/Win32API/extconf.rb: add -fno-omit-frame-pointer.
+
+Thu Mar 22 18:17:36 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_nesting): should not include Object at the
+ toplevel.
+
+Thu Mar 22 17:43:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.h: better inline function support.
+
+ * configure.in (NO_C_INLINE): check if inline is available for the
+ C compiler.
+
+Mon Mar 19 11:03:10 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * marshal.c (r_object): len calculation patch was wrong for
+ machines SIZEOF_BDIGITS == SIZEOF_SHORT.
+
+ * gc.c: alloca prototype reorganized for C_ALLOCA machine.
+
+Wed Mar 21 23:07:45 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c (win32_stat): WinNT/2k "//host/share" support.
+
+Wed Mar 21 08:05:35 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * win32/dir.h: replace missing/dir.h .
+
+ * win32/win32.h: ditto.
+
+ * win32/win32.c: ditto.
+
+Wed Mar 21 01:26:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (id2ref): sometimes confused symbol and reference.
+
+Tue Mar 20 23:09:33 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c (win32_stat): UNC support.
+
+ * dir.c (extract_path): fix "./*" problem.
+
+Tue Mar 20 15:10:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (glob_helper): breaks loop after calling recursive
+ glob_helper; all wild cards should be consumed; no need for
+ further match.
+
+ * dir.c (dir_s_glob): gives warning if no match found.
+
+Tue Mar 20 14:13:45 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * object.c (sym_inspect): did allocate extra byte space.
+
+Mon Mar 19 19:14:47 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * marshal.c (shortlen): shortlen should return number of bytes
+ written.
+
+Mon Mar 19 16:52:23 2001 K.Kosako <kosako@sofnec.co.jp>
+
+ * eval.c (ev_const_defined): need not to check if cbase->nd_class
+ is rb_cObject.
+
+ * eval.c (ev_const_get): ditto.
+
+Mon Mar 19 17:11:20 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_zone): return "UTC" for UTC time objects.
+
+Mon Mar 19 16:27:32 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (THREAD_ALLOC): flags should be initialized.
+
+ * signal.c (rb_f_kill): should use FIX2INT, not FIX2UINT.
+
+Mon Mar 19 10:55:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (glob_helper): replace lstat() by stat() to follow symlink
+ in the case like 'symlink/*'.
+
+ * dir.c (glob_helper): gave warning too much.
+
+Sun Mar 18 08:58:18 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: // === '' --> //.match('')
+
+ * lib/cgi.rb: cgi#header(): improvement for mod_ruby.
+
+ * lib/cgi.rb: cgi#rfc1123date(): improvement.
+ thanks to TADA Tadashi <sho@spc.gr.jp>.
+
+ * lib/cgi.rb: cgi#rfc1123date(): document bug fix.
+ thanks to Kazuhiro NISHIYAMA <zn@mbf.nifty.com>.
+
+ * lib/cgi.rb: cgi#header(): bug fix.
+ thanks to IWATSUKI Hiroyuki <don@na.rim.or.jp>.
+
+Sat Mar 17 11:11:24 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (glob_helper): * should follow symlink, whereas ** should
+ not follow.
+
+Thu Mar 15 01:28:02 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (dir_s_chdir): block form of Dir.chdir. (RCR#U016).
+
+Fri Mar 16 17:14:17 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * configure.in: Set SOLIBS properly for all ELF and
+ FreeBSD/NetBSD/OpenBSD a.out platforms so that the shlib
+ dependencies are recorded in the libruby shlib.
+
+Wed Mar 14 16:41:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_schedule): raise FATAL just once to
+ THREAD_TO_KILL.
+
+Wed Mar 14 10:41:34 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): 0 (= Qfalse) is a valid value, so that
+ default self should be checked by klass == 0.
+
+ * bignum.c (rb_cstr2inum): should disallow '++1', '+-1', etc.
+
+Tue Mar 13 17:51:09 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ev_const_defined): add new parameter self for special
+ const fallback.
+
+ * eval.c (ev_const_get): ditto.
+
+Tue Mar 13 16:39:45 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dir.c (rb_glob_helper): fix drive letter handling on DOSISH.
+
+Tue Mar 13 14:54:39 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: add HTTPRequest#basic_auth.
+
+ * lib/net/smtp.rb: raise if only account or password is given.
+
+ * lib/net/protocol.rb: WriteAdapter#<< returns self.
+
+Tue Mar 13 14:41:16 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_seek_m): wrong calling sequence of rb_io_seek().
+
+Tue Mar 13 09:14:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (cond0): no special treatment of string literal in
+ condition.
+
+Mon Mar 12 18:59:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (create_makefile): save/restore $libs and $LIBPATH.
+
+Sun Mar 11 18:13:34 2001 Masahiro Tanaka <masa@stars.gsfc.nasa.gov>
+
+ * math.c: add acos, asin, atan, conh, sinh, tanh and hypot to Math.
+
+ * configure.in: check hypot availability.
+
+ * missing/hypot.c: public domain rewrite of hypot.
+
+Sun Mar 11 13:21:04 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * parse.y (warn_unless_e_option): warning condition was wrong.
+
+ * parse.y (warning_unless_e_option): ditto.
+
+Sun Mar 11 00:55:31 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (install_rb): fix handling of destination path.
+
+Sat Mar 10 22:56:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_all): new method 'all?', which returns true if
+ block returns true for all elements.
+
+ * enum.c (enum_any): new method 'any?', which returns true if
+ block returns true for any of elements.
+
+Sat Mar 10 02:34:18 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * math.c (math_log, math_log10): use nan() instead of 0.0/0.0 on Cygwin.
+
+Fri Mar 9 09:56:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (marshal_load): do not give warning unless explicitly
+ set to verbose.
+
+Fri Mar 9 02:07:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_exit): give string value "exit" to SystemExit.
+
+ * ruby.c (proc_options): -v should not print version if
+ proc_options called via moreswitches().
+
+Thu Mar 8 17:45:19 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb: one write(2) per one line.
+
+Wed Mar 7 14:26:11 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * math.c (math_log, math_log10): should return NaN if x < 0.0
+ on Cygwin.
+
+Thu Mar 7 10:31:26 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (stmt): while/until modifier must work for empty body.
+
+Tue Mar 6 22:53:58 2001 Kazuhiro Yoshida <moriq.kazuhiro@nifty.ne.jp>
+
+ * ruby.c (ruby_set_argv): clear ARGV contents before adding args.
+
+Tue Mar 6 10:50:29 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (primary): rescue and ensure clauses should be allowed
+ to appear in singleton method body.
+
+Mon Mar 5 17:25:13 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_eq): compare Procs using blocktag equality.
+
+ * eval.c (proc_to_s): stringify according to block tag address.
+
+Mon Mar 5 17:19:56 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c (gettimeofday): use GetLocalTime() instead of ftime()
+ for high-resolution timing.
+
+Sun Mar 4 17:01:09 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * string.c (trnext): support backslash escape in String#tr.
+
+Sat Mar 3 16:15:16 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): push cbase if ruby_cbase != ruby_class, for
+ example in the case NODE_DEFN/NODE_DEFS are called within
+ module_eval.
+
+Wed Feb 28 11:02:41 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_delete_bang): delete! should take at least 1
+ argument.
+
+ * ruby.c (load_file): add rb_gc() after loading to avoid
+ extraordinary memory growth.
+
+Wed Feb 28 05:01:40 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * dir.c (rb_glob_helper): "./foo" should match "foo", not "./foo".
+
+Tue Feb 27 16:38:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ev_const_get): retrieve Object's constant if no current
+ class is available (e.g. defining singleton class for Fixnums).
+
+ * eval.c (ev_const_defined): check Object's constant if no current
+ class is available (e.g. defining singleton class for Fixnums).
+
+ * time.c (time_timeval): negative time interval should not be
+ allowed.
+
+ * eval.c (proc_call): ignore block to `call' always, despite of
+ being orphan or not.
+
+Wed Feb 27 10:16:32 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_yield_0): should check based on rb_block_given_p()
+ and rb_f_block_given_p().
+
+Tue Feb 27 04:13:45 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * configure.in (frame-address): --enable-frame-address to allow
+ __builtin_frame_address() to be used.
+
+ * eval.c (stack_length): use __builtin_frame_address() based on
+ the macro USE_BUILTIN_FRAME_ADDRESS.
+
+ * gc.c (rb_gc): ditto.
+
+ * gc.c (Init_stack): ditto.
+
+Mon Feb 26 16:20:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.c (proc_options): call ruby_show_version() just once.
+
+ * dir.c (dir_s_open): returns the value from a block (if given).
+
+Mon Feb 26 14:29:04 2001 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: add C++ rules in addition to C
+ rules.
+
+Mon Feb 26 00:04:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_call): should not modify ruby_block->frame.iter
+ based on ruby_frame->iter altered by PUSH_ITER().
+
+Mon Feb 26 05:27:52 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/net/telnet.rb: #telnetmode(), #binmode(): bug fix.
+ thanks to nobu.nakada@nifty.ne.jp.
+
+Mon Feb 26 04:55:50 2001 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: CGI#form(): bug fix.
+ thanks to MoonWolf <moonwolf@moonwolf.com>.
+
+ * lib/cgi.rb: CGI#rfc1123_date(): improvement.
+ thanks to Tomoyasu Akita <genzo-@dm4lab.to>.
+
+ * lib/cgi.rb: CGI#header(): improvement for mod_ruby.
+ thanks to Shugo Maeda <shugo@ruby-lang.org>.
+
+Sun Feb 25 02:45:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * file.c (rb_file_s_rename): avoid Cygwin's bug.
+
+Sat Feb 24 23:32:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_fd_close): should save current context before
+ raising exception.
+
+Sat Feb 24 22:14:00 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c (myrename): fix error handling.
+
+Sat Feb 24 13:58:48 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: always close connection on request without
+ body.
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: change copyright.
+
+Sat Feb 24 03:15:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (set_stdin): preserve original stdin.
+
+ * io.c (set_outfile): preserve original stdout/stderr.
+
+Fri Feb 23 08:28:58 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb: clear read buffer after reopen.
+
+ * lib/net/protocol.rb: refactoring.
+
+ * lib/net/http.rb: split module HTTPHeader from HTTPResponse.
+
+Tue Feb 20 23:45:35 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * process.c: add W* macro if not available.
+
+Tue Feb 20 16:37:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * configure.in: add check for negative time_t for gmtime(3).
+
+ * time.c (time_new_internal): no positive check if gmtime(3) can
+ handle negative time_t.
+
+ * time.c (time_timeval): ditto.
+
+ * bignum.c (rb_big2long): should not raise RangeError for Bignum
+ LONG_MIN value.
+
+Mon Feb 19 17:46:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_substr): "a"[1,2] should return ""; need
+ rubicon upgrade.
+
+Mon Feb 19 12:10:36 2001 Triet H. Lai <thlai@mail.usyd.edu.au>
+
+ * error.c (rb_sys_warning): new function to give warning with
+ strerror() message.
+
+ * dir.c (rb_glob_helper): better error handling, along with
+ performance tune.
+
+Mon Feb 19 01:55:43 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (secure_visibility): visibility check for untainted modules.
+
+Mon Feb 19 00:29:29 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * signal.c (sigpipe): sighandler which does nothing.
+
+ * signal.c (trap): set sigpipe function for SIGPIPE.
+
+ * signal.c (Init_signal): default SIGPIPE handler should be
+ sigpipe function.
+
+Sun Feb 18 15:42:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/curses/extconf.rb: add dir_config.
+
+ * missing/flock.c: use fcntl(2) instead of lockf(2).
+
+Sun Feb 18 05:46:03 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: Response#range_length was not debugged.
+
+Sun Feb 18 04:02:03 2001 Yasushi Shoji <yashi@yashi.com>
+
+ * array.c (rb_ary_subseq): wrong boundary check.
+
+Sun Feb 18 00:09:50 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * win32/win32.c: make file I/O faster on mswin32/mingw32.
+
+ * win32/win32.h: ditto.
+
+ * rubysig.h: ditto.
+
+Sat Feb 17 23:32:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (cond0): integer literal in condition should not be
+ compared to lineno ($.).
+
+Fri Feb 16 01:44:56 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (set_outfile): f should be the FILE* from the assigning value.
+
+ * ext/socket/socket.c (tcp_s_open): should not give default value
+ to local_host.
+
+ * time.c (time_s_times): move to Process::times.
+
+ * file.c (rb_file_s_lchmod): new method File::lchmod.
+
+ * file.c (rb_file_s_lchown): new method File::lchown.
+
+Thu Feb 15 11:33:49 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/cgi/session.rb (close): fixed reversed condition.
+
+Thu Feb 15 08:34:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (proc_waitall): new method based on a patch from Brian
+ Fundakowski Feldman <green@green.dyndns.org>.
+
+ * process.c (last_status_set): objectify $? value (Process::Status).
+
+Wed Feb 14 17:28:24 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb: supports unknown resp_text_code.
+
+Wed Feb 14 00:44:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (dir_s_glob): support backslash escape of metacharacters
+ and delimiters.
+
+ * dir.c (remove_backslases): remove backslashes from path before
+ calling stat(2).
+
+ * dir.c (dir_s_glob): call rb_yield directly (via push_pattern) if
+ block is given to the method.
+
+ * dir.c (push_pattern): do not call rb_ary_push; yield directly.
+
+ * eval.c (blk_copy_prev): reduced ALLOC_N too much.
+
+ * eval.c (frame_dup): ditto.
+
+Tue Feb 13 23:05:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dir.c (lstat): should use rb_sys_stat if lstat(2) is not
+ available.
+
+Tue Feb 13 08:43:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_ctl): do not call ioctl/fcntl for f2, if f and f2
+ have same fileno.
+
+Tue Feb 13 01:13:43 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_load): raise LocalJumpError if unexpected local jumps
+ appear during load.
+
+ * ext/socket/socket.c (bsock_close_read): don't call rb_thread_fd_close();
+ it's supposed to be called by io_io_close().
+
+ * ext/socket/socket.c (bsock_close_read): do not modify f and f2.
+
+ * ext/socket/socket.c (bsock_close_write): ditto.
+
+ * ext/socket/socket.c (sock_new): avoid dup(2) on sockets.
+
+ * parse.y (primary): preserve and clear in_single and in_def using
+ stack to prevent nested method errors in singleton class bodies.
+
+Sun Feb 11 16:00:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * eval.c (stack_length): use __builtin_frame_address() only if
+ GCC and i386 CPU.
+
+ * gc.c (rb_gc, Init_stack): ditto.
+
+ * configure.in: add ac_cv_func_getpgrp_void=yes on DJGPP.
+
+Sat Feb 10 23:43:49 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * hash.c (rb_any_hash): dumped core on machines sizeof(int) != sizeof(long).
+
+Sat Feb 10 23:07:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_s_for_fd): IO::for_fd(fd) - new method.
+
+ * regex.c (PREV_IS_A_LETTER): should not treat c>0x7f as a word
+ character if -Kn.
+
+Sat Feb 10 00:00:30 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * win32/win32.c (win32_stat): replace stat to enable when pathname
+ ends with '/' or '\' for mswin32 on Win9X / Win2k.
+
+ * win32/win32.h: ditto.
+
+ * ruby.h: ditto.
+
+ * dir.c (rb_glob_helper): ditto.
+
+ * file.c (rb_stat, rb_file_s_stat, eaccess, check3rdbyte): ditto.
+
+Fri Feb 9 22:54:57 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ruby.c (ruby_init_loadpath): convert '\\' to '/'
+ before finding executable file path.
+
+Fri Feb 9 17:41:53 2001 Triet H. Lai <thlai@mail.usyd.edu.au>
+
+ * dir.c (rb_glob_helper): do not follow symbolic links.
+
+Thu Feb 8 21:27:24 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/mkmf.rb (install_rb): fix handling of relative path.
+
+ * lib/mkmf.rb (create_makefile): add srcdir.
+
+Thu Feb 8 02:22:09 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: join HTTPReadResponse into HTTPResponse again.
+
+ * lib/net/http.rb: move http_version() from HTTPRequest to
+ HTTPResponse.
+
+ * lib/net/protocol.rb: refactoring.
+
+Wed Feb 7 16:27:27 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: split HTTPResponse into HTTPReadResponse
+ module.
+
+ * lib/net/protocol.rb: add Net::net_private.
+
+ * lib/net/protocol.rb: Socket#reopen takes arg, open_timeout.
+
+Wed Feb 7 16:05:22 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (parse_quotedwords): %w should allow parenthesis escape.
+
+Wed Feb 7 00:57:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (parse_qstring): %q should allow terminator escape.
+
+ * re.c (rb_reg_options): new method to give an option values.
+
+ * parse.y (cond0): disable special treating of integer literal in
+ conditional unless option -e is supplied. changes current
+ behavior. experimental.
+
+ * parse.y (cond0): give warning for string/integer literals and
+ dot operators in conditionals unless option -e is supplied.
+
+ * re.c (rb_reg_equal): all option flags should be same to be equal.
+
+Tue Feb 6 21:30:44 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: call on_connect() on re-opening socket.
+
+ * lib/net/pop.rb: also POP3 can use APOP auth.
+
+Tue Feb 6 20:19:10 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: add HTTP#request.
+
+ * lib/net/http.rb: take HTTP 1.0 server into account (incomplete).
+
+ * lib/net/protocol.rb: timeout for open/read.
+
+ * lib/net/protocol.rb: add Protocol#on_connect,on_disconnect.
+
+Mon Feb 5 23:15:46 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (Init_Exception): make Interrupt a subclass of
+ SignalException.
+
+Mon Feb 5 00:39:06 2001 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+
+ * dir.c: use ISXXX() instead of isxxx().
+
+ * dln.c (aix_loaderror): ditto.
+
+ * file.c (rb_file_s_expand_path): ditto.
+
+ * string.c (rb_str_upcase_bang): ditto.
+
+ * win32/win32.c (do_spawn): ditto.
+
+ * win32/win32.c (NtMakeCmdVector): ditto.
+
+ * win32/win32.c (opendir): ditto.
+
+Sat Feb 3 14:44:53 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * configure.in (AC_C_INLINE): check inline attribute.
+
+ * gc.c (is_pointer_to_heap): use inline rather than __inline__.
+
+ * pack.c (hex2num): ditto.
+
+ * ruby.h (rb_class_of, rb_type, rb_special_const_p): ditto.
+
+ * util.c (rb_class_of, rb_type, rb_special_const_p): defined in
+ ruby.h.
+
+Fri Feb 2 16:14:51 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_sort_bang): returns self, even if its length is
+ less than 2.
+
+ * eval.c (POP_VARS): propagate DVAR_DONT_RECYCLE, if
+ SCOPE_DONT_RECYCLE of ruby_scope is set.
+
+Wed Jan 31 22:27:29 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: gcc-2.95.2-7(Cygwin) support.
+ add -mwin32 if available.
+
+ * cygwin/GNUmakefile: ditto.
+
+Tue Jan 30 17:56:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_fetch): new method.
+
+Mon Jan 29 17:36:19 2001 TOYOFUKU Chikanobu <toyofuku@juice.or.jp>
+
+ * eval.c (rb_eval): nd_iter evaluation should be wrapped by
+ BEGIN_CALLARGS and END_CALLARGS.
+
+Mon Jan 29 14:25:39 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (block_pass): return from block jumps directory to
+ block invoker.
+
+Mon Jan 29 01:40:27 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (str_independent): should not clear str->orig here.
+ it's too early.
+
+Fri Jan 26 01:42:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y: clarify do ambiguity, bit more complex but natural
+ from my point of view.
+
+Wed Jan 24 14:58:08 2001 Akinori MUSHA <knu@ruby-lang.org>
+
+ * lib/cgi.rb: fix the problem that when running under mod_ruby
+ header() outputs only one Set-Cookie line.
+
+Wed Jan 24 01:45:49 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (POP_BLOCK_TAG): call rb_gc_force_recycle() if block has
+ not been objectified.
+
+ * eval.c (rb_callcc): should nail down block->tag history to avoid
+ rb_gc_force_recycle().
+
+Tue Jan 23 18:51:57 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc_call_finalizer_at_exit): should finalize objects in
+ deferred_final_list too.
+
+Tue Jan 23 16:10:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (os_live_obj): do not list terminated object.
+
+ * gc.c (os_obj_of): ditto.
+
+ * gc.c (rb_gc_mark): support new T_BLKTAG tag.
+
+ * gc.c (obj_free): ditto.
+
+ * eval.c (new_blktag): creation of new block tag, which holds
+ destination of global jump and orphan status.
+
+ * eval.c (block_pass): break from orphan Proc object will raise a
+ LocalJumpError exception.
+
+Mon Jan 22 16:33:16 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * mkconfig.rb: autoconf 2.49 support.
+
+Mon Jan 22 00:32:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (block_pass): behavior consistency with proc_call(). do
+ not propagate `break'.
+
+Sat Jan 20 03:54:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): fixed serious syntax misbehavior. do's
+ preceding was too high. a block in `foo bar do .. end' should
+ be passed to `foo', not `bar'.
+
+ * parse.y (block_call): syntax restructure.
+
+Thu Jan 18 04:28:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_s_read): new method to call IO#read from
+ pathname. In addition, it accepts third optional argument to
+ specify starting point.
+
+Wed Jan 17 13:28:26 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: remove DEFS definition.
+
+ * mkconfig.rb: ditto.
+
+ * win32/config.status.in: ditto.
+
+Tue Jan 16 17:00:50 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb: ignore EOFError for read.
+
+ * lib/net/http.rb: user specified header was not used.
+
+Mon Jan 15 16:00:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_unpack): should check associated pointer packed by
+ pack("P"). Thus pointers can be retrieved only from pointer
+ packed strings. restriction added.
+
+Sun Jan 14 21:49:28 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * sprintf.c (rb_f_sprintf): simple typo. binary base should be 2,
+ not '2'.
+
+ * re.c (rb_reg_s_last_match): should explicitly return nth match.
+
+Sun Jan 14 18:21:30 2001 Usaku Nakamura <usa@osb.att.ne.jp>
+
+ * win32/config.status.in: add some field.
+
+ * win32/win32.c (isInternalCmd): ignore case for shell's internal
+ command.
+
+ * win32/win32.c (do_spawn): recognize quoted command line.
+
+Sun Jan 14 04:10:27 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb (adding): too few "yield" in case of arg is
+ not String/File.
+
+ * lib/net/http.rb: add http request object.
+
+Sat Jan 13 19:39:30 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * re.c (rb_reg_desc): separate RE_OPTION_MULTILINE
+
+ * re.c (rb_reg_options): add RE_OPTION_{POSIXLINE,RE_OPTION_MULTILINE,
+ RE_OPTION_EXTENDED}
+
+Thu Jan 11 10:45:04 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.h, win32/config.h.in: move NORETURN from win32.h
+ to config.h.in.
+
+ * win32/config.h.in (inline): renamed from INLINE.
+
+ * djgpp/config.hin (INLINE): removed.
+
+Thu Jan 11 06:45:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_mod_dup): should propagate FL_SINGLETON.
+
+ * object.c (inspect_obj): handles the case of no instance variable.
+
+Wed Jan 10 16:15:08 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ruby.h: NORETURN macro is changed for VC++ 6.0.
+
+ * eval.c, intern.h: ditto.
+
+ * djgpp/config.hin, win32/win32.h: ditto.
+
+ * configure.in: ditto.
+
+Wed Jan 10 13:54:53 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * process.c (proc_setuid): use setresuid() if available.
+
+ * process.c (proc_setgid): use setresgid() if available.
+
+ * configure.in: ditto.
+
+Wed Jan 10 01:50:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * configure.in (AC_C_INLINE): check inline attribute.
+
+ * string.c (rb_str_reverse_bang): forgot to call rb_str_modify().
+
+Tue Jan 9 17:41:40 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_taint): check frozen status before modifying
+ taint status.
+
+ * object.c (rb_obj_untaint): ditto.
+
+Tue Jan 9 16:22:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_inject): new method.
+
+Tue Jan 9 02:16:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc_call_finalizer_at_exit): clear klass member of
+ terminating object.
+
+ * eval.c (rb_call): raise exception for terminated object.
+
+Mon Jan 8 21:24:37 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (bigdivrem): t2 might be too big for signed long; do
+ not use rb_int2big(), but rb_uint2big().
+
+Mon Jan 8 21:35:10 2001 Guy Decoux <decoux@moulon.inra.fr>
+
+ * file.c (path_check_1): should restore modified path.
+
+Mon Jan 8 03:09:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (rb_load_fail): new func to report LoadError.
+
+ * ruby.c (load_file): use rb_load_fail.
+
+Sat Jan 6 00:17:18 2001 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * pack.c (pack_pack): avoid infinite loop(pack 'm2').
+
+Fri Jan 5 01:02:17 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_finalize): should enclosed by PUSH_TAG/POP_TAG.
+
+ * gc.c (rb_gc_mark): link 2 of NODE_IFUNC should not be explicitly
+ marked. it may contain non object pointer.
+
+Tue Jan 2 00:20:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * re.c (reg_s_last_match): Regexp::last_match(nth) returns nth
+ substring of the match (alternative for $& and $<digit>).
+
+Sun Dec 31 01:39:16 2000 Guy Decoux <decoux@moulon.inra.fr>
+
+ * eval.c (rb_mod_define_method): wrong comparison for blocks.
+
+Sat Dec 30 19:28:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (id2ref): should handle Symbol too.
+
+ * gc.c (id2ref): should print original ptr value
+
+Sat Dec 30 03:14:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_iterate): NODE_CFUNC does not protect its data
+ (nd_tval), so create new node NODE_IFUNC for iteration C
+ function.
+
+ * eval.c (rb_yield_0): use NODE_IFUNC.
+
+ * gc.c (rb_gc_mark): support NODE_IFUNC.
+
+Fri Dec 29 11:41:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (mem_error): prohibit recursive mem_error().
+ (ruby-bugs-ja:PR#36)
+
+Fri Dec 29 11:05:41 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_fd_writable): should not switch context if
+ rb_thread_critical is set.
+
+ * eval.c (rb_thread_wait_fd): ditto.
+
+ * eval.c (rb_thread_wait_for): ditto.
+
+ * eval.c (rb_thread_select): ditto.
+
+ * eval.c (rb_thread_join): join during critical section causes
+ deadlock.
+
+Fri Dec 29 00:38:46 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * m17n.c: new file - core functions of M17N.
+
+Tue Dec 26 18:46:41 2000 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/debug.rb: Avoid thread deadlock in debugging stopped thread.
+
+ * lib/debug.rb: Uncleared 'finish' state.
+
+Tue Dec 26 16:53:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): remove dvar node by rb_gc_force_recycle()
+ more eagerly.
+
+ * eval.c (rb_f_binding): recycling should be stopped for outer
+ scope too.
+
+ * eval.c (proc_new): ditto.
+
+Tue Dec 26 15:45:35 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_inspect): should treat multibyte characters
+ properly.
+
+Mon Dec 25 17:49:08 2000 K.Kosako <kosako@sofnec.co.jp>
+
+ * string.c (rb_str_replace_m): unexpected string share happens if
+ replace is done for associated (STR_NO_ORIG) string.
+
+Tue Dec 26 15:01:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_f_p): should not call rb_io_flush() if rb_defout is not
+ a IO (T_FILE).
+
+Mon Dec 25 15:52:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * stable version 1.6.2 released.
+
+Mon Dec 25 05:11:04 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: version 2.1.2 (some bug fixes).
+
+ * lib/cgi.rb: Regexp::last_match[1] --> $1
+
+ * lib/net/telnet.rb: ditto.
+
+Mon Dec 25 04:43:02 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: does not send HEAD on closing socket.
+
+Mon Dec 25 00:44:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_any_cmp): should use rb_str_cmp() if TYPE == T_STRING
+ and CLASS_OF == rb_cString.
+
+ * string.c (rb_str_new4): should copy class of original too.
+
+Mon Dec 25 00:04:54 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_thread_schedule): initial value of `max' changed to -1.
+
+Mon Dec 25 00:16:14 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_replace_m): copy-on-write replace.
+
+ * parse.y (yylex): should handle => after identifier as well as ==
+ and =~.
+
+Sat Dec 23 23:55:57 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_cstr2inum): Integer("") should not return 0.
+
+Sat Dec 23 11:55:57 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_and): Array#& should preserve original order.
+
+Sat Dec 23 03:44:16 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb: set @closed false in Socket#reopen.
+
+ * lib/net/pop.rb: add POP3.foreach, delete_all.
+
+ * lib/net/pop.rb: add POP3#delete_all.
+
+ * lib/net/http.rb: add HTTP.version_1_1, version_1_2
+
+ * lib/net/http.rb: refactoring.
+
+Fri Dec 22 23:11:12 2000 Ueno Katsuhiro <unnie@blue.sky.or.jp>
+
+ * eval.c (rb_feature_p): ext might be null.
+
+Fri Dec 22 17:04:12 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * win32/win32.c (myselect): avoid busy loop by adjusting fd_count.
+
+Fri Dec 22 15:07:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_cstr2inum): prefix like '0x' had removed too much.
+
+Thu Dec 21 13:01:46 2000 Tanaka Akira <akr@m17n.org>
+
+ * lib/net/ftp.rb (makeport): don't use TCPsocket.getaddress.
+
+Wed Dec 20 12:00:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_lshift): should cast up to BDIGIT_DBL.
+
+ * parse.y (yylex): disallow trailing '_' for numeric literals.
+
+ * bignum.c (rb_cstr2inum): allow `_' within converting string.
+
+ * eval.c (specific_eval): should take no argument if block is
+ supplied.
+
+Tue Dec 19 13:44:50 2000 K.Kosako <kosako@sofnec.co.jp>
+
+ * io.c (rb_f_p): should flush rb_defout, not stdout.
+
+Tue Dec 19 00:57:10 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_minus): usec might overflow. (ruby-bugs-ja:PR#35)
+
+ * eval.c (rb_obj_extend): Object#extend should take at least one
+ argument.
+
+ * parse.y (mrhs_basic): should check value_expr($3), not $1.
+
+Mon Dec 18 23:18:39 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * util.c (mblen, __crt0_glob_function): add for multibyte
+ on DJGPP 2.03.
+
+Mon Dec 18 18:10:30 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_plus): usec might underflow (ruby-bugs-ja:#PR33).
+
+Mon Dec 18 08:11:20 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (rb_hash_set_default): should call rb_hash_modify().
+
+Sat Dec 16 02:58:26 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * eval.c (rb_eval): should clear ruby_errinfo on retry.
+
+ * eval.c (rb_rescue2): ditto.
+
+Thu Dec 14 13:06:18 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * class.c (rb_include_module): prohibit frozen class/module.
+
+ * eval.c (rb_frozen_class_p): make external.
+
+ * intern.h (rb_frozen_class_p): prototyped.
+
+ * intern.h (rb_undef): prototyped not but rb_undef_method()
+ which is also in ruby.h.
+
+Thu Dec 14 09:20:26 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: support -T1 on ruby 1.6.2
+
+ * lib/cgi.rb: $1 --> Regexp::last_match[1]
+
+ * lib/net/telnet.rb: ditto.
+
+Wed Dec 13 23:27:06 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): handles case statement without expr, which
+ looks for any TRUE (non nil, non false) when expression.
+
+ * parse.y (primary): case expression should not be compstmt, but
+ mere expr.
+
+ * parse.y (primary): case without following expression is now
+ separated rule.
+
+Wed Dec 13 12:41:27 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ruby.c (proc_options): accept "--^M" for DOS line endings.
+
+Tue Dec 12 15:45:42 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (newline_node): cancel newline unification.
+
+Mon Dec 11 23:01:57 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): supports cases `?' precedes EOF and newline.
+
+Mon Dec 11 12:11:25 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (call_end_proc): some frame members were left
+ uninitialized.
+
+Mon Dec 11 01:14:58 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_fptr_finalize): do not fclose stdin, stdout and
+ stderr at exit.
+
+Sat Dec 9 17:34:48 2000 Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
+
+ * time.c (time_cmp): should check with kind_of?, not instance_of?
+
+ * time.c (time_eql): ditto.
+
+ * time.c (time_minus): ditto.
+
+Fri Dec 8 17:23:25 2000 Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
+
+ * sprintf.c (rb_f_sprintf): proper string precision treat.
+
+Fri Dec 8 10:44:05 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_remove_cvar): Module#remove_class_variable
+ added.
+
+Thu Dec 7 17:35:51 2000 Shugo Maeda <shugo@ruby-lang.org>
+
+ * eval.c (stack_length): don't use __builtin_frame_address() on alpha.
+
+Wed Dec 6 18:07:13 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * djgpp/config.sed, win32/Makefile.sub: typo.
+
+ * eval.c (rb_mod_define_method): avoid VC4.0 warnings.
+
+Wed Dec 6 13:38:08 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_and): tuning, make hash from shorter operand.
+
+Wed Dec 6 01:28:50 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * gc.c (rb_gc): __builtin_frame_address() should not be used on
+ MacOS X.
+
+ * gc.c (Init_stack): ditto.
+
+Mon Dec 4 13:44:01 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * lib/jcode.rb: consider multibyte. not /n.
+
+Mon Dec 4 09:49:36 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_inspect): output whole string contents. no more `...'
+
+ * string.c (rb_str_dump): should propagate taintness.
+
+ * hash.c (env_inspect): hash like human readable output.
+
+ * variable.c (rb_ivar_get): prohibiting instance variable access
+ is too much restriction.
+
+ * class.c (method_list): retrieving information should not be
+ restricted where $SAFE=4.
+
+ * class.c (rb_obj_singleton_methods): ditto.
+
+ * eval.c (rb_thread_priority): ditto.
+
+ * eval.c (rb_thread_local_aref): ditto.
+
+ * variable.c (rb_obj_instance_variables): ditto.
+
+ * variable.c (rb_mod_const_at): ditto.
+
+ * variable.c (rb_mod_class_variables): ditto.
+
+ * eval.c (rb_exec_end_proc): end_proc should be preserved.
+
+Sat Dec 2 22:32:43 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): || should accept exactly zero argument.
+
+ * parse.y (stmt): multiple right hand side for single assignment
+ (e.g. a = 1,2) is allowed.
+
+Wed Nov 29 07:55:29 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (w_long): dumping long should be smaller than 32bit max.
+
+ * marshal.c (w_long): shorter long format for small integers(-123..122).
+
+ * marshal.c (r_long): ditto.
+
+Tue Nov 28 18:10:51 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_mod_define_method): quick hack to implement
+ on-the-fly method definition. experimental.
+
+Mon Nov 27 17:00:35 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should not redefine builtin classes/modules
+ from within wrapped load.
+
+Mon Nov 27 08:57:33 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (call_end_proc): should be isolated from outer block.
+
+Mon Nov 27 00:10:08 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_ctl): call ioctl/fcntl for fptr->f2 too.
+
+ * process.c (rb_f_fork): call rb_thread_atfork() after creating
+ child process.
+
+ * eval.c (rb_thread_atfork): kill all other threads immediately,
+ then turn the current thread into the main thread.
+
+Sat Nov 25 23:12:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (ruby_run): move calling point of rb_trap_exit after
+ cleaning up threads.
+
+ * eval.c (ruby_finalize): new function to call EXIT trap, END
+ procs and GC finalizers.
+
+ * eval.c (rb_exec_end_proc): prevent recursion.
+
+ * gc.c (rb_gc_call_finalizer_at_exit): ditto.
+
+ * signal.c (rb_trap_exit): ditto. made static.
+
+ * process.c (rb_f_fork): should swallow all exceptions from block
+ execution.
+
+ * process.c (fork_rescue): should call ruby_finalize().
+
+ * parse.y (yycompile): rb_gc() removed. I don't remember why I put
+ this here. test code?
+
+Fri Nov 24 22:03:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (EXCL): exclusive information is now stored in an
+ instance variable. this enables proper marshal dump.
+
+ * process.c (proc_waitpid): should clear rb_last_status ($?) if
+ no pid was given by waitpid(2).
+
+Thu Nov 23 01:35:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * process.c (proc_waitpid2): returns nil if no pid found.
+
+Wed Nov 22 23:45:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_eq): new method. Compares start and end of range
+ respectively.
+
+Wed Nov 22 11:01:32 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_class_variables): should honor singleton
+ class variable rule defined yesterday.
+
+Tue Nov 21 23:24:14 2000 Mitsuteru S Nakao <nakao@kuicr.kyoto-u.ac.jp>
+
+ * numeric.c (flodivmod): missing second operand (typo).
+
+Tue Nov 21 03:39:41 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (marshal_load): marshal format compatibility check
+ revised. greater minor revision is UPWARD compatible;
+ downward compatibility is not assured.
+
+ * eval.c (is_defined): clarify class variable behavior for
+ singleton classes. class variables within singleton class
+ should be treated like within singleton method.
+
+Mon Nov 20 13:45:21 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): set ruby_sourceline before evaluating
+ exceptions.
+
+ * gc.c (gc_sweep): defer finalization in GC during compilation or
+ interrupt prohibit section.
+
+ * gc.c (gc_sweep): mark all nodes before sweeping if GC happened
+ during compilation.
+
+ * eval.c (rb_eval): should treat class variables specially in a
+ method defined in the singleton class.
+
+Mon Nov 20 10:20:21 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dir.c, win32/win32.c, ruby.h: add rb_iglob().
+
+Mon Nov 20 00:18:16 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_subseq): should return nil for outbound start
+ index.
+
+ * marshal.c (marshal_load): show format versions explicitly when
+ format version mismatch happens.
+
+Sun Nov 19 06:13:24 2000 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * marshal.c: use long for string/array length.
+
+ * pack.c (swaps): use bit-or(|) instead of plus(+).
+
+ * pack.c (swapl): ditto.
+
+Sat Nov 18 15:18:16 2000 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * array.c (rb_ary_replace): array size should be in long.
+
+ * array.c (rb_ary_concat): ditto.
+
+ * array.c (rb_ary_hash): ditto.
+
+Sat Nov 18 14:07:20 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: Socket#readline() reads until "\n", not "\r\n"
+
+Fri Nov 17 14:55:18 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * string.c (rb_str_succ): output should be NUL terminated.
+
+Fri Nov 17 02:54:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_close): need not to flush before closing.
+
+ * eval.c (rb_thread_join): should preserve last thread status when
+ THREAD_TO_KILL.
+
+ * eval.c (rb_thread_stop): ditto.
+
+ * io.c (io_fflush): wrap fflush by TRAP_BEG, TRAP_END.
+
+ * eval.c (rb_eval): method defined within singleton class
+ definition should behave like singleton method about class
+ variables.
+
+ * eval.c (is_defined): ditto.
+
+Thu Nov 16 23:06:07 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: can call {old,new}_implementation any times.
+
+ * lib/net/http.rb: HTTP#connecting, receive ->
+ common_oper, connecting.
+
+ * lib/net/http.rb: output warning if u_header includes
+ duplicated header.
+
+ * lib/net/http.rb: not check Connection:/Proxy-Connection;
+ always read until eof.
+
+ * lib/net/protocol.rb: detects and catches "break" from block.
+
+Thu Nov 16 16:32:45 2000 Masahiro Tanaka <masa@stars.gsfc.nasa.gov>
+
+ * bignum.c (bigdivrem): should have incremented ny first.
+
+Thu Nov 16 14:58:00 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/socket/socket.c (sock_new): duplicates file descriptor
+ with myfddup() on mswin32/mingw32.
+
+ * win32/win32.h: uses system original fdopen().
+
+ * win32/win32.c (myfddup): newly added instead of myfdopen().
+
+ * win32/win32.c (mybind, myconnect, mygetsockname, mygetsockopt,
+ mylisten, mysetsockopt): now accept file descriptor only, not
+ SOCKET.
+
+ * win32/win32.c (myaccept, mysocket): return file descriptor,
+ instead of SOCKET.
+
+Thu Nov 16 10:23:24 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (massign): too strict check for nameless rest argument.
+
+ * eval.c (method_arity): mere * should return -1.
+
+ * eval.c (intersect_fds): should check all FDs in the fd_set.
+
+Wed Nov 15 19:33:20 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_attr): should clear method cache before calling hook.
+
+ * eval.c (rb_eval): ditto.
+
+ * eval.c (rb_mod_modfunc): ditto.
+
+Mon Nov 13 22:44:52 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (rb_bug): print version to stderr.
+
+Mon Nov 13 19:02:08 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * win32/win32.c, io.c, process.c: the exit status of program must be
+ multiplied 256 on mswin32 and msdosdjgpp(system(), ``).
+
+Sat Nov 11 22:57:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (arg): uniformed treatment of -a**b, where a is a
+ number literal; hacky but behavior appears more consistent.
+
+ * parse.y (newline_node): reduce newline node (one per line).
+
+ * random.c (rb_f_srand): should be prohibited in safe level
+ greater than 4.
+
+Sat Nov 11 22:37:36 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * rubysig.h: do not use rb_trap_immediate on win32.
+
+ * rubysig.h: new macros, ATOMIC_TEST, ATOMIC_SET, ATOMIC_INC,
+ ATOMIC_DEC, RUBY_CRITICAL and new definition of TRAP_BEG,
+ TRAP_END.
+
+ * gc.c (ruby_xmalloc): should wrap malloc() by RUBY_CRITICAL.
+
+ * signal.c (sighandle): better win32 sig handling.
+
+ * win32/win32.c (flock): better implementation.
+
+ * win32/win32.c (myselect): ditto.
+
+ * win32/win32.c (myaccept): ditto.
+
+ * win32/win32.c (waitpid): ditto.
+
+ * win32/win32.c (myrename): ditto.
+
+ * win32/win32.c (wait_events): support function for win32 signal
+ handling.
+
+Sat Nov 11 08:34:18 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.31.
+
+ * lib/net/http.rb: initializes header in HTTP, not HTTPCommand.
+
+ * lib/net/protocol.rb, http.rb: rewrites proxy code.
+
+Fri Nov 10 16:15:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (rb_num2long): use to_int, not to_i.
+
+ * error.c: T_SYMBOL was misplaced by T_UNDEF.
+
+ * parse.y (yylex): eval("^") caused infinite loop.
+
+Thu Nov 9 14:22:13 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_taint_check): should check IO taintness; no
+ operation for untainted IO should be allowed in the sandbox.
+
+ * rubyio.h (GetOpenFile): check IO taintness inside using
+ rb_io_taint_check().
+
+Wed Nov 8 03:08:53 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (io_fflush): ensure fflush(3) would not block by calling
+ rb_thread_fd_writable().
+
+Tue Nov 7 20:29:56 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.30.
+
+ * lib/net/protocol.rb, smtp.rb: Command#critical_ok -> error_ok
+
+ * lib/net/http.rb: reads header when also "100 Continue".
+
+Tue Nov 7 04:32:19 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (bigdivrem): use bit shift to make y's MSB set.
+
+Mon Nov 6 1:22:49 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (warn_print): do not use err_append(), to ensure output
+ to stderr.
+
+ * error.c (rb_warn): use warn_print() instead of err_print().
+
+ * error.c (rb_warning): ditto.
+
+ * error.c (rb_bug): ditto.
+
+ * eval.c (rb_load): re-raise exceptions during load.
+
+ * time.c (make_time_t): remove useless adjust
+
+Thu Nov 2 18:01:16 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * random.c (rb_f_rand): half-baked float support fixed. This fix
+ was originally proposed by K.Kosako <kosako@sofnec.co.jp>.
+
+Tue Oct 31 17:27:17 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c: change digit size to `long|int' if long long is
+ available.
+
+ * marshal.c (w_object): support `long|int' digits.
+
+ * marshal.c (r_object): ditto.
+
+Sat Oct 28 23:54:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): allow =end at the end of file (without a
+ newline at the end).
+
+Fri Oct 27 10:00:27 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_cstr2inum): should ignore trailing white spaces.
+
+ * bignum.c (rb_str2inum): string may not have sentinel NUL.
+
+Fri Oct 27 02:37:22 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_cstr2inum): wrongly assigned base to c before
+ badcheck check.
+
+Thu Oct 26 02:42:50 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb: Command#critical_ok
+
+ * lib/net/smtp.rb: clear critical flag before go to SMTP
+
+Wed Oct 25 12:30:19 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_concat): replacing array might be the receiver
+ itself. do not call rb_ary_push_m.
+
+ * array.c (rb_ary_replace): replacing array might be the receiver
+ itself. use memmove.
+
+Fri Oct 20 07:56:23 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): ARGSPUSH should not modify args array.
+
+Thu Oct 19 14:58:17 2000 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * pack.c (NUM2U32): should use NUM2ULONG().
+
+Tue Oct 17 17:30:34 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * eval.c (error_print): ruby_sourcefile may be NULL.
+
+Tue Oct 17 16:36:28 2000 Wes Nakamura <wknaka@pobox.com>
+
+ * pack.c (NATINT_U32): wrong use of sizeof.
+
+Tue Oct 17 12:48:20 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (rb_abort): nil check against ruby_errinfo.
+
+ * eval.c (rb_thread_schedule): use FOREACH_THREAD_FROM instead of
+ FOREACH_THREAD, since curr_thread may be removed from thread ring.
+
+ * eval.c (THREAD_ALLOC): errinfo should be Qnil.
+
+ * eval.c (rb_callcc): th->prev,th->next are now already
+ initialized in THREAD_ALLOC.
+
+Mon Oct 16 15:37:33 2000 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * eval.c (rb_thread_inspect): tag size was shorter than required.
+
+ * object.c (rb_obj_inspect): ditto.
+
+Mon Oct 16 14:25:18 2000 Shugo Maeda <shugo@ruby-lang.org>
+
+ * object.c (sym_inspect): used `name' before initialization.
+
+Mon Oct 16 14:06:00 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * pack.c (pack_pack): use NATINT_U32 for 'l', 'L', and 'N'.
+
+ * pack.c (I32,U32): 32 bit sized integer.
+
+ * pack.c (OFF16,OFF32B): big endian offset for network byteorder.
+
+Mon Oct 16 06:39:32 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: hex-alpha is not [a-h] but [a-f].
+
+Mon Oct 16 01:02:02 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_start_0): should not abort on exception if
+ $SAFE >= 4.
+
+ * parse.y (sym): symbols for class variable names.
+
+Sun Oct 15 01:49:18 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_file_flock): should accept interrupt.
+
+ * process.c (rb_waitpid): ditto.
+
+ * process.c (rb_waitpid): ditto.
+
+ * process.c (proc_wait): ditto.
+
+ * process.c (proc_waitpid2): wrong recursion.
+
+Sat Oct 14 03:32:13 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_alloc): should not link a new thread in the
+ live thread ring before initialization.
+
+Fri Oct 13 17:08:09 2000 Shugo Maeda <shugo@ruby-lang.org>
+
+ * lib/net/imap.rb: new file.
+
+Thu Oct 12 18:56:28 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/pop.rb: POP3#reset
+
+ * lib/net/http.rb: a code for "Switch Protocol" was wrongly 100.
+
+Thu Oct 12 01:23:38 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: bug fix: CGI::html(): PRETTY option didn't work.
+
+Thu Oct 12 00:03:02 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (sym_inspect): should adjust string length.
+
+ * struct.c (rb_struct_to_s): ditto.
+
+ * struct.c (rb_struct_inspect): ditto.
+
+Wed Oct 11 22:15:47 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (rb_thread_inspect): should adjust string length.
+
+ * object.c (rb_any_to_s): ditto.
+
+ * object.c (rb_obj_inspect): ditto.
+
+Wed Oct 11 18:13:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_start_0): should check insecure exit.
+
+Wed Oct 11 14:29:51 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb: 2nd arg for ProtocolError#initialize is
+ optional.
+
+ * lib/net/http.rb: code refining.
+
+Wed Oct 11 11:13:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (primary): setter method (e.g. foo=) should always be
+ public.
+
+ * eval.c (rb_thread_raise): should not raise SecurityError if
+ exception raised by the interpreter.
+
+ * eval.c (rb_thread_cleanup): skip all THREAD_KILLED threads
+ before FOREACH_THREAD.
+
+Tue Oct 10 16:11:54 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * dln.c (dln_load): remove unused code for Cygwin.
+
+Tue Oct 10 09:49:23 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (Init_File): FileTest.size should return 0 (not nil) for
+ empty files.
+
+Sun Oct 8 13:20:26 2000 Guy Decoux <decoux@moulon.inra.fr>
+
+ * eval.c (POP_SCOPE): not just set SCOPE_DONT_RECYCLE, but do
+ scope_dup().
+
+Sat Oct 7 15:10:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_reverse_bang): unnecessary ALLOCA_N() was
+ removed.
+
+Fri Oct 6 14:50:24 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * ext/extmk.rb.in, lib/mkmf.rb: remove "DESTDIR =".
+
+ * Makefile.in, win32/Makefile.sub, ruby.1: renamed -X to -C.
+
+Fri Oct 6 12:50:52 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_plus): use to_ary(), not Check_Type().
+
+ * array.c (rb_ary_concat): ditto.
+
+ * gc.c (rb_gc): use __builtin_frame_address() for gcc.
+
+ * eval.c (stack_length): ditto.
+
+ * parse.y (assign_in_cond): stop warning till some better warning
+ condition will be found.
+
+Thu Oct 5 18:02:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_obj_dup): should have propagated taint flag.
+ (ruby-bugs:#PR64,65)
+
+Wed Oct 4 00:26:11 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_arity): proc{|a|}'s arity should be -1.
+
+Mon Oct 2 05:28:58 2000 akira yamada <akira@ruby-lang.org>
+
+ * string.c (trnext): minus at the end of pattern.
+
+Sun Oct 1 00:43:34 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * configure.in: exp-name was wrong on cygwin and mingw32.
+
+Thu Sep 28 14:57:09 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): should try must_string calculation
+ every time.
+
+Tue Sep 19 23:47:44 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * configure.in, config.guess, config.sub: MacOS X support.
+
+Wed Sep 27 18:40:05 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * stable version 1.6.1 released.
+
+Wed Sep 27 16:13:05 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * mkconfig.rb: variables should be expanded only if /\$\{?\w+\}?/.
+
+Tue Sep 26 18:09:51 2000 WATANABE Hirofumi <eban@ruby-lang.org>
+
+ * string.c: include <math.h>
+
+Tue Sep 26 15:59:50 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * object.c (rb_mod_dup): metaclasses of class/module should not be
+ cleared by rb_obj_dup.
+
+Tue Sep 26 02:44:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (GC_MALLOC_LIMIT): size extended.
+
+ * regex.c (DOUBLE_STACK): use machine's stack region for regex
+ stack if its size is small enough.
+
+Mon Sep 25 18:13:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c: include <defines.h>.
+
+ * eval.c (rb_add_method): cache mismatch by method
+ definition. need to clear_cache_by_id every time.
+
+Mon Sep 25 13:31:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/win32.c (NtCmdGlob): substitute '\\' with '/'.
+
+Mon Sep 25 00:35:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * defines.h: #undef HAVE_SETITIMER on cygwin.
+
+Sun Sep 24 03:01:53 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, http.rb: typo.
+
+Sat Sep 23 07:33:20 2000 Aleksi Niemela <aleksi.niemela@cinnober.com>
+
+ * regex.c (re_compile_pattern): nicer regexp error messages for
+ invalid patterns.
+
+Sat Sep 23 03:06:25 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_autoload_load): should not require already
+ provided features.
+
+Fri Sep 22 15:46:21 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/http.rb: too early parameter expansion in string.
+
+Fri Sep 22 13:58:51 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/extmk.rb.in: don't use default $:
+
+Fri Sep 22 13:42:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * regex.c (PUSH_FAILURE_COUNT): avoid casting warning on alpha.
+
+ * regex.c (PUSH_FAILURE_POINT): ditto.
+
+Fri Sep 22 10:16:21 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/config.h.in: add HAVE_TELLDIR, HAVE_SEEKDIR
+
+Thu Sep 21 19:04:34 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/extmk.rb, lib/mkmf.rb (install_rb): check whether libdir is
+ directory or not.
+
+Thu Sep 21 17:23:05 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * file.c (rb_file_s_symlink): use HAVE_SYMLINK.
+
+ * file.c (rb_file_s_readlink): use HAVE_READLINK.
+
+ * dir.c (dir_tell): use HAVE_TELLDIR.
+
+ * dir.c (dir_seek): use HAVE_SEEKDIR.
+
+ * configure.in (AC_CHECK_FUNCS): lstat, symlink, readlink,
+ telldir, seekdir checks added.
+
+ * file.c (lstat): should use stat(2) if lstat(2) is not
+ available.
+
+Thu Sep 21 15:59:23 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.29.
+
+ * lib/net/http.rb: HTTPReadAdapter -> HTTPResponseReceiver
+
+ * lib/net/http.rb (connecting): response is got in receive()
+
+Thu Sep 21 15:49:07 2000 Wayne Scott <wscott@ichips.intel.com>
+
+ * lib/find.rb (find): should not follow symbolic links;
+ tuned performance too.
+
+Wed Sep 20 23:21:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.c (load_file): two Ctrl-D was required to stop ruby at the
+ beginning of stdin script read.
+
+Wed Sep 20 14:01:45 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_provided): detect infinite load loop.
+
+ * eval.c (rb_provided): too weak filename comparison.
+
+ * eval.c (rb_thread_alloc): avoid recycling still referenced
+ dvar structures.
+
+ * eval.c (rb_callcc): ditto.
+
+ * eval.c (THREAD_ALLOC): fill dyna_vars field by ruby_dyna_vars.
+
+Tue Sep 19 17:47:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * stable version 1.6.0 released.
+
+Tue Sep 19 16:24:52 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (Init_marshal): provide marshal.so no more.
+
+Tue Sep 19 14:01:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in, win32/setup.mak: include version number
+ in RUBY_SO_NAME.
+
+Tue Sep 19 13:07:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): was confusing $~ and $_.
+
+Tue Sep 19 13:06:53 2000 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * signal.c (rb_f_kill): signum may be a negative number, should be
+ treated by signed number.
+
+Tue Sep 19 01:14:56 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_provide): better feature handling.
+
+ * eval.c (rb_f_require): loading ruby library may be partial
+ state. checks in rb_thread_loading is integrated.
+
+ * eval.c (rb_provided): better thread awareness.
+
+ * lib/irb/frame.rb: 6 (not 5) parameters for trace_func proc.
+
+ * eval.c (error_print): should print error position even if
+ get_backtrace() failed.
+
+Sat Sep 16 03:29:59 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_f_require): rb_provided() was called too early; does
+ not work well with threads.
+
+ * parse.y (ensure): should distinguish empty ensure and non
+ existing ensure.
+
+ * file.c (Init_File): extending File by class of FileTest was
+ serious mistake.
+
+Thu Sep 14 02:46:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_yield): array strip should be done in this
+ function.
+
+Wed Sep 13 17:01:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_eq): incomplete value comparison of bignums.
+
+Wed Sep 13 06:39:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_class_variables): Module#class_variables added.
+
+Wed Sep 13 06:09:26 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: bug fix: CGI::header(): output status header.
+
+Wed Sep 13 01:09:12 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (yylex): allow global variables like '$__a'.
+
+Tue Sep 12 22:28:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/socket/extconf.rb: avoid using terrible <netinet/tcp.h>
+ on cygwin 1.1.5.
+
+Tue Sep 12 16:01:58 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * array.c (rb_ary_unshift_m): typo.
+
+Tue Sep 12 15:37:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): stripped array too much, should remove just
+ for proc_call().
+
+Tue Sep 12 07:05:24 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: version 2.0.0: require ruby1.5.4 or later.
+
+ * lib/net/telnet.rb: version 1.6.0
+
+Tue Sep 12 03:26:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (massign): use to_ary to get an array if available.
+
+ * object.c (rb_Array): ditto.
+
+Mon Sep 11 14:24:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * hash.c (ruby_setenv): should not free the element of
+ origenvironment.
+
+ * parse.y (command_call): kYIELD moved to this rule to allow
+ 'a = yield b'. (ruby-bugs-ja:#PR15)
+
+Mon Sep 11 01:27:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_yield_0): proc#call([]) should pass single value to
+ the block.
+
+ * eval.c (callargs): reduce array allocation.
+
+ * eval.c (massign): precise check for argument number.
+
+Fri Sep 8 10:05:17 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (STR_NO_ORIG): should be FL_USER2.
+
+Thu Sep 7 14:17:51 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_cat): should work even for concatenating same
+ string.
+
+Wed Sep 6 17:06:38 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_cvar_declare): should check superclass's class
+ variable first.
+
+Wed Sep 6 10:42:02 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * misc/ruby-mode.el (ruby-calculate-indent): shift continuing line
+ if previous line ends with modifier keyword.
+
+ * misc/ruby-mode.el (ruby-parse-region): should not give up if
+ modifiers are at the end of line.
+
+ * misc/ruby-mode.el (ruby-expr-beg): indented wrongly if modified
+ statement was size 1.
+
+Wed Sep 6 10:41:19 2000 Kenichi Komiya <kom@mail1.accsnet.ne.jp>
+
+ * misc/ruby-mode.el (ruby-parse-region): modifier was not handled
+ well on emacs19.
+
+Tue Sep 5 17:10:12 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_to_s): fixed zone string UTC for utc time object.
+
+Tue Sep 5 00:26:06 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_search): range worked wrongly on bm_search().
+
+Mon Sep 4 13:40:40 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: renamed libruby.a to libruby.{cygwin,mingw32}.a
+ on cygwin and mingw32.
+
+Sun Sep 3 23:44:04 2000 Noriaki Harada <tenmei@maoh.office.ne.jp>
+
+ * io.c (NO_SAFE_RENAME): for BeOS too.
+
+Sun Sep 3 11:31:53 2000 Takaaki Tateishi <ttate@jaist.ac.jp>
+
+ * parse.y (rescue): no assignment was done if rescue body was
+ empty.
+
+Sat Sep 2 10:52:21 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (call_args,aref_args): block_call can be the last
+ argument.
+
+ * parse.y (COND_PUSH,COND_POP): maintain condition stack to allow
+ kDO2 in parentheses in while/until/for conditions.
+
+ * parse.y (yylex): generate kDO2 for EXPR_ARG outside of
+ while/until/for condition.
+
+Fri Sep 1 10:36:29 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (aref_args,opt_call_args): add block_call to allow a
+ method without parentheses and with block as a last argument.
+
+ * hash.c (rb_hash_sort): should not return nil.
+
+ * re.c (match_aref): should use rb_reg_nth_match().
+
+ * eval.c (POP_SCOPE): recycled scopes too much
+
+ * eval.c (Init_eval): extend room for stack allowance.
+
+ * eval.c (POP_SCOPE): frees scope too much.
+
+Thu Aug 31 14:28:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (rb_gc_mark): T_SCOPE condition must be more precise.
+
+ * eval.c (scope_dup): should not make all duped scope orphan.
+
+Thu Aug 31 10:11:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (stmt): allow stmt_rhs to be right hand side of multiple
+ assignment.
+
+ * time.c (rb_time_timeval): type error should not mention the word
+ 'interval'.
+
+Wed Aug 30 23:21:20 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * numeric.c (rb_num2long): use rb_Integer() instead of independent
+ convert routine.
+
+ * eval.c (rb_rescue2): now takes arbitrary number of exception types.
+
+ * object.c (rb_convert_type): use rb_rescue2 now to handle NameError.
+
+ * object.c (rb_convert_type): better error message.
+
+Wed Aug 30 17:09:14 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/Win32API/Win32API.c (Win32API_initialize): AlphaNT support.
+
+Wed Aug 30 14:19:07 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (node_assign): should support NODE_CVASGN2 too.
+
+Wed Aug 30 11:31:47 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ext/Win32API/Win32API.c (Win32API_initialize): add the
+ arguments checking.
+
+ * ext/Win32API/Win32API.c (Win32API_initialize): add taint
+ checking. allow String object in the third argument.
+
+Wed Aug 30 10:29:40 2000 Masahiro Tomita <tommy@tmtm.org>
+
+ * io.c (rb_f_p): flush output buffer.
+
+Tue Aug 29 16:29:15 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (assignable): remove NODE_CVASGN3.
+
+ * parse.y (gettable): remove NODE_CVAR3.
+
+Tue Aug 29 02:02:14 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/mkmf.rb (create_makefile): handles create_makefile("a/b").
+
+ * ext/extmk.rb.in (create_makefile): ditto
+
+Mon Aug 28 18:43:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (is_defined): now handles class variables.
+
+ * eval.c (rb_eval): class variable behavior revisited.
+
+ * parse.y (assignable): ditto.
+
+ * parse.y (gettable): ditto.
+
+ * regex.c (PUSH_FAILURE_COUNT): push/pop interval count on failure
+ stack. this fix is inspired by the Emacs21 patch from Stefan
+ Monnier <monnier@cs.yale.edu>.
+
+Fri Aug 25 15:24:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_cvar_get): should not follow __attached__.
+
+ * variable.c (rb_cvar_set): ditto.
+
+ * variable.c (rb_cvar_declare): ditto.
+
+ * variable.c (mod_av_set): second class variable assignment at the
+ toplevel should not give warning.
+
+Fri Aug 25 01:18:36 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (next_argv): prepare path for open file.
+
+ * string.c (rb_str_setter): moved from io.c.
+
+ * io.c (next_argv): filename should be "-" for refreshed ARGF.
+
+Thu Aug 24 15:27:39 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/socket/socketport.h: use `extern int h_errno' if needed.
+
+Sat Aug 19 01:34:02 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/sdbm/_sdbm.c (sdbm_prep): flags should be or-ed by O_BINARY on
+ Win32 too.
+
+ * ext/sdbm/_sdbm.c (makroom): fill hole with 0 on Win32 too.
+
+Fri Aug 18 13:23:59 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval): should preserve and clear $! value before
+ compilation.
+
+ * eval.c (eval): ditto.
+
+Fri Aug 18 11:06:19 2000 Shugo Maeda <shugo@ruby-lang.org>
+
+ * ext/socket/socket.c (s_accept): start GC on EMFILE/ENFILE.
+
+Thu Aug 17 16:04:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (is_defined): should clear ruby_errinfo.
+
+Thu Aug 17 04:26:31 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.27.
+
+ * lib/net/protocol.rb: writing methods returns written byte size.
+
+ * lib/net/smtp.rb: send_mail accepts many destinations.
+
+Wed Aug 16 00:43:47 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_s_times): use CLK_TCK for HZ if it's defined.
+
+Tue Aug 15 17:30:59 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (frame_dup): should set flag FRAME_MALLOC after
+ argv allocation.
+
+ * eval.c (blk_free): should not free argv if GC was called before
+ frame_dup.
+
+Tue Aug 15 16:08:40 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: add ac_cv_func_times=yes for mingw32.
+
+ * win32/win32.c (mytimes): typo.
+
+Tue Aug 15 01:45:28 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_eof): should return true at the end of ARGF without
+ checking stdout if arguments are given.
+
+Mon Aug 14 10:34:32 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_status): status should return false for normal
+ termination, nil for termination by exception.
+
+Fri Aug 11 15:43:46 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_undef): give warning for undefining __id__, __send__.
+
+Thu Aug 10 08:05:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_callcc): returned current thread instead of
+ continuation wrongly.
+
+Thu Aug 10 05:40:28 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/extmk.rb.in: $CPPFLAGS should be initialized.
+
+ * ext/tcltklib/depend: add stubs.o.
+
+ * ext/tcltklib/extconf.rb: use $CPPFLAGS instead of $CFLAGS.
+
+Wed Aug 9 16:31:48 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_callcc): thread status for continuations must be
+ THREAD_KILLED, otherwise thread_free() breaks other threads.
+
+Wed Aug 9 13:24:25 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/win32.[ch]: emulate rename(2).
+
+Tue Aug 8 14:01:46 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/tcltklib/tcltklib.c: support --enable-tcltk_stubs
+
+ * ext/tcltklib/extconf.rb: ditto.
+
+ * ext/tcltklib/stubs.c: created. examine candidate shared libraries.
+
+Mon Aug 7 13:59:12 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ruby.h (CLONESETUP): should copy flags before any potential
+ object allocation.
+
+ * regex.c (re_match): check for stack depth was needed.
+
+Sat Aug 5 16:43:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * djgpp/*: convert DOS line endings to UNIX style.
+
+ * djgpp/config.status: rename to config.sed for SFN.
+
+ * lib/ftools.rb (compare, safe_unlink, chmod): avoid warnings.
+
+ * lib/ftools.rb (move): typo. not `tpath', but `to'.
+
+Fri Aug 4 23:26:48 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (proc_call): gives warning if a block is supplied.
+
+ * eval.c (rb_eval): no warning for discarding if an alias for the
+ method is already made.
+
+Fri Aug 4 16:32:29 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_reject_bang): returns nil if no element removed.
+
+ * hash.c (rb_hash_reject_bang): returns nil if no element removed.
+
+Thu Aug 3 19:44:26 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_fd_writable): should return integer value.
+
+ * array.c (rb_ary_assoc): search array element whose length is
+ longer than 0 (not 1).
+
+Wed Aug 2 18:27:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_wait_fd): prohibit thread context switch
+ during compilation.
+
+ * eval.c (rb_cont_call): prohibit Continuation#call across threads.
+
+Wed Aug 2 08:22:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (rb_gc): clear malloc_memories to zero, to avoid potential
+ super frequent GC invocation. (ruby-bugs:#PR48)
+
+ * gc.c (rb_gc): only add_heap() if GC trigger condition is
+ satisfied.
+
+Tue Aug 1 16:41:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (proc_options): global load path setting moved from
+ ruby_prog_init().
+
+ * ruby.c (incpush): renamed. push path entry at the END of the
+ load path array. This makes -I directories sorted in order in
+ the arguments.
+
+Sat Jul 29 23:42:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (dir_each): should check whether dir is closed during the
+ block execution. (ruby-bugs:#PR47)
+
+Sat Jul 29 21:57:30 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ruby.c (rubylib_mangle): provide another buffer for the result.
+
+Wed Jul 26 10:09:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: set SOLIBS to LIBS on Cygwin.
+
+ * configure.in: LIBRUBY_SO='$(RUBY_INSTALL_NAME)'.$target_os.dll
+ on cygwin and mingw32. ruby-cygwin.dll is bad. why?
+
+Wed Jul 26 10:04:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (gc_sweep): avoid full scan during compilation.
+
+ * gc.c (rb_gc): add heap during no gc period (including
+ compilation).
+
+Tue Jul 25 19:03:04 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * cygwin/GNUmakefile: use puts instead of print, because
+ Cygwin DLL's behavior is changed(or bug?).
+
+ * configure.in: LIBRUBY_SO='$(RUBY_INSTALL_NAME)'-$target_os.dll
+ on cygwin and mingw32.
+
+ * cygwin/GNUmakefile: ditto.
+
+ * Makefile.in: $(SOLIBS) should be put after dmyext.@OBJEXT@.
+
+ * instruby.rb: install $(LIBRUBY) to libdir
+ if $(LIBRUBY) != $(LIBRUBY_A_).
+
+Tue Jul 25 15:16:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_p): redirect to $defout.
+
+Mon Jul 24 18:52:55 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/win32.c (win32_getenv): should remove `static'.
+
+ * ruby.c (rubylib_mangle): support "/hoge;/foo"
+
+Mon Jul 24 10:28:55 2000 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+
+ * string.c (rb_str_count): raise exception if no argument is
+ given.
+
+Sun Jul 23 12:55:04 2000 Dave Thomas <Dave@Thomases.com>
+
+ * string.c (rb_str_rindex): Support negative end position.
+
+Fri Jul 21 17:35:01 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (aref_args): command_call now be permitted as
+ aref_args.
+
+ * process.c (proc_getpriority): getpriority(2) may return valid
+ negative number. use errno to detect error.
+
+ * marshal.c (dump_ensure): dumped string should be tainted if
+ any among target objects is tainted.
+
+ * marshal.c (r_regist): restored object should be tainted if and
+ only if the source is a file or a tainted string.
+
+Wed Jul 19 15:14:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (bigdivrem): should use rb_int2big(), not rb_uint2big().
+
+Tue Jul 18 14:58:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (ruby_options): should treat SystemExit etc. properly.
+
+ * parse.y (yycompile): should check compile_for_eval, not
+ ruby_in_eval.
+
+Mon Jul 17 04:29:50 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/mkmf.rb: converts extension of $objs into $OBJEXT.
+
+Sun Jul 16 03:02:34 2000 Dave Thomas <dave@thomases.com>
+
+ * lib/weakref.rb: Change to use new ObjectSpace calls.
+
+Sat Jul 15 21:59:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): should not redefine __id__ nor __send__.
+
+ * gc.c (define_final): integrate final.rb features into the
+ interpreter. define_finalizer and undefine_finalizer was
+ added to ObjectSpace. plus, add_finalizer, remove_finalizer,
+ and call_finalizer are deprecated now.
+
+Sat Jul 15 01:32:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_mod_method): implements unbound method.
+
+ * eval.c (Init_eval): should prohibit `module_function' for class
+ Class.
+
+Fri Jul 14 17:19:59 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * cygwin/GNUmakefile.in: use miniruby instead of sed.
+
+Fri Jul 14 12:49:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (argf_eof): need to check stdin, when next_p == -1.
+
+ * io.c (read_all): use io_fread() instead of fread(3).
+
+ * io.c (io_reopen): should clearerr FILE if fd < 3.
+
+ * re.c (rb_reg_match_m): the result is exported, so it should be
+ declared as busy.
+
+ * eval.c (rb_eval): should preserve errinfo even if return, break,
+ etc. is called in rescue clause.
+
+ * instruby.rb: install irb too.
+
+Wed Jul 12 15:32:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_const_get): constants for builtin classes must
+ have higher priority than constants from included modules at
+ Object class.
+
+ * bignum.c (bigdivrem): small embarrassing typo.
+
+Wed Jul 12 15:06:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): use rb_const_get_at().
+
+ * variable.c (top_const_get): retrieve toplevel constants only,
+ not ones of Object (and its included modules) in general.
+
+Wed Jul 12 15:04:11 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.26.
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb:
+ add module Net::NetPrivate and its inner classes
+ {Read,Write}Adapter, Command, Socket,
+ SMTPCommand, POP3Command, APOPCommand, HTTPCommand
+
+Wed Jul 12 13:10:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (bigdivrem): defer bignorm().
+
+ * bignum.c (bignorm): accepts accidental fixnums.
+
+Tue Jul 11 16:54:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): `@<digit>' is no longer a valid instance
+ variable name.
+
+Tue Jul 11 01:51:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (rb_big_divmod): should not use Integer(float) for
+ the right operand.
+
+ * bignum.c (rb_big_remainder): ditto.
+
+ * bignum.c (rb_big_modulo): ditto.
+
+Mon Jul 10 15:27:16 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * io.c (pipe_finalize): should set rb_last_status when pclose().
+
+Mon Jul 10 09:07:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (rb_bug): print version number and such too.
+
+Sat Jul 8 23:08:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_start_0): should copy previous scopes to
+ prevent rb_gc_force_recycle().
+
+Fri Jul 7 23:36:36 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/addrinfo.h: move IN_EXPERIMENTAL and IN_LOOPBACKNET
+ definitions to ext/socket/sockport.h.
+
+ * ext/socket/extconf.rb: add getservbyport() and arpa/inet.h check.
+
+ * ext/socket/getaddrinfo.c (getaddrinfo): SOCK_RAW may not be
+ defined (ex. BeOS, Palm OS 2.x or before).
+
+ * ext/socket/getnameinfo.c (getnameinfo): getservbyport() may not
+ exist (ex. BeOS, Palm OS).
+
+ * ext/socket/sockport.h: add IN_EXPERIMENTAL, IN_CLASSA_NSHIFT,
+ IN_LOOPBACKNET, AF_UNSPEC, PF_UNSPEC and PF_INET.
+
+Fri Jul 7 03:30:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (aref_args): should allow Hash[:a=>2] etc.
+
+ * numeric.c (fix_aref): convert index by NUM2INT, not FIX2INT.
+ (ruby-bugs:#PR37)
+
+ * time.c (time_localtime): should prohibit for frozen time.
+
+ * time.c (time_gmtime): ditto.
+
+Thu Jul 6 19:12:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_file_s_open): should not terminate fptr; just clear it.
+
+ * ruby.c (proc_options): should not call require_libraries()
+ twice.
+
+ * ruby.c (require_libraries): clear req_list_head.next after
+ execution.
+
+Thu Jul 6 13:51:57 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * object.c (rb_to_id): name may not be symbol nor fixnum.
+
+ * struct.c (rb_struct_s_def): name may be nil.
+
+Thu Jul 6 02:09:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (bigdivrem): new function to return remainder.
+
+ * numeric.c (fixdivmod): now returns modulo, not remainder.
+
+ * numeric.c (flodivmod): ditto.
+
+ * bignum.c (bigdivmod): ditto.
+
+ * numeric.c (num_modulo): new method; alias to '%'.
+
+Thu Jul 6 00:51:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/win32.c (NtCmdGlob): patterns should be separated and
+ NUL terminated.
+
+Wed Jul 5 22:27:56 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * cygwin/GNUmakefile: use ruby.def to make rubycw.dll.
+
+ * ext/extmk.rb.in: create target.def.
+
+ * lib/mkmf.rb: ditto.
+
+Wed Jul 5 09:47:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_arg): Time::local, Time::gm now take 7th optional
+ argument for usec.
+
+ * numeric.c (num_ceil, etc): default ceil, floor, round, truncate
+ implementation for Numeric, using `to_f'.
+
+ * io.c (rb_io_reopen): clear fptr->path after free() to prevent
+ potential GC crash.
+
+ * io.c (rb_file_s_open): terminate fptr unless null.
+
+ * io.c (rb_file_initialize): ditto.
+
+ * lib/tempfile.rb: specify FILE::CREAT|File::EXCL to open for
+ better security.
+
+ * numeric.c (flo_truncate): new method.
+
+Wed Jul 5 01:02:53 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/extmk.rb.in: join ' ' -> join(' ').
+
+ * lib/mkmf.rb: ditto.
+
+Tue Jul 4 13:51:29 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/dbm/dbm.c: add methods added to Hash in 1.5.x.
+
+ * ext/gdbm/gdbm.c: ditto.
+
+ * ext/sdbm/init.c: ditto.
+
+ * eval.c (proc_call): args may be Qundef (means no argument), do
+ not call TYPE() for args.
+
+Tue Jul 4 13:20:56 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/extmk.rb.in: make command line must be single-quoted.
+ $(RUBY_INSTALL_NAME) is command substitution in the POSIX sh.
+
+Tue Jul 4 13:16:02 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * util.c (rb_type): should add T_UNDEF.
+
+Tue Jul 4 09:30:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): supports EOF right after terminator.
+
+ * random.c (rb_f_rand): argument is now optional (rand(max=0)).
+
+Tue Jul 4 01:50:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/ruby.def: remove ruby_mktemp.
+
+Tue Jul 4 01:27:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_rescue2): new function to rescue arbitrary exception.
+
+ * numeric.c (do_coerce): should catch NameError explicitly.
+
+Tue Jul 4 00:15:23 2000 Dave Thomas <Dave@thomases.com>
+
+ * numeric.c (Init_Numeric): forgot to register Numeric#remainder.
+
+Mon Jul 3 23:46:56 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/win32.c (myselect, myaccept): disable interrupt while
+ executing accept() or select() to avoid Ctrl-C causes
+ "unknown software exception (0xc0000029)".
+
+Mon Jul 3 18:35:41 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * lib/mkmf.rb: use null device if it exists for cross-compiling.
+
+Mon Jul 3 18:19:51 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.26.
+
+ * lib/net/protocol.rb (finish): do nothing unless active.
+
+ * lib/net/http.rb: HTTP#{get,post}2 again (for new impl).
+
+Mon Jul 3 16:47:22 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * cygwin/GNUmakefile: librubys.a -> lib$(RUBY_INSTALL_NAME)s.a
+
+ * configure.in: use AC_CANONICAL_{HOST,TARGET,BUILD}.
+
+Mon Jul 3 13:15:02 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (fix_divmod): x * d + m = y where d, m = x.divmod(y).
+
+ * bignum.c (rb_big_divmod): ditto.
+
+ * numeric.c (fixdivmod): does not depend C's undefined %
+ behavior. adopt to fmod(3m) behavior.
+
+ * numeric.c (flo_mod): modulo now reserves fmod(3m) behavior.
+
+ * numeric.c (num_remainder): 'deprecated' warning.
+
+Mon Jul 3 10:27:28 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: use AC_CANONICAL_SYSTEM.
+
+Sun Jul 2 21:17:37 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: support without --enable-shared for cygwin/mingw32.
+
+ * cygwin/GNUmakefile: ditto.
+
+ * ext/extmk.rb.in: use null device if it exists for cross-compiling.
+
+ * lib/mkmf.rb: ditto.
+
+ * util.c (ruby_mktemp): remove unused ruby_mktemp().
+
+Sun Jul 2 14:18:04 2000 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * eval.c (TMP_PROTECT_END): tmp__protect_tmp may be NULL.
+
+Sun Jul 2 03:37:50 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.25.
+
+ * lib/net/protocol.rb (each_crlf_line): beg = 0 is needed in adding{}
+
+ * lib/net/smtp.rb: allow String for to_addr of SMTP#sendmail
+
+Sat Jul 1 15:22:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (fix_rshift): should handle shift value more than
+ sizeof(long).
+
+Sat Jul 1 15:22:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): the value from RTEST() is not valid Ruby
+ object. result should be either true or false.
+
+Sat Jul 1 09:30:06 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * re.c (rb_reg_initialize): was freeing invalid pointer.
+
+Sat Jul 1 03:25:56 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (call_args): command_call can be the last argument of
+ call_args. It had to be the only argument.
+
+ * re.c (rb_reg_s_quote): should not dump core even for unsane mbc
+ string.
+
+Fri Jun 30 01:36:20 2000 Aleksi Niemela <aleksi.niemela@cinnober.com>
+
+ * parse.y (f_norm_arg): better, nicer error message.
+
+Thu Jun 29 07:45:33 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (udp_send): destination may be packed
+ struct sockaddr.
+
+ * object.c (rb_Integer): Integer(nil) should be invalid, on the
+ other hand, nil.to_i is OK.
+
+Wed Jun 28 17:26:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (ip_recvfrom): udp_recvfrom and tcp_recvfrom
+ is merged and moved to IPSocket#recvfrom.
+
+ * ext/socket/socket.c (sock_s_getaddrinfo): family can be a
+ strings such as "AF_INET" etc.
+
+ * ruby.c (require_libraries): . and RUBYLIB added to $load_path
+ just before -r procedure.
+
+ * ruby.c (proc_options): -e, - did not exec -r.
+
+Wed Jun 28 14:52:28 2000 Koga Youichirou <y-koga@mms.mt.nec.co.jp>
+
+ * config.sub: NetBSD/hpcmips support.
+
+Wed Jun 28 10:11:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c: gc trigger threshold changed; GC_NEWOBJ_LIMIT removed,
+ FREE_MIN is increased to 4096.
+
+Tue Jun 27 22:39:28 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.24.
+
+ * lib/net/protocol.rb: modified each_crlf_line again.
+
+ * lib/net/protocol.rb: do_write_beg,do_write_end -> writing{}
+ do_write_do -> do_write
+
+ * lib/net/http.rb: can make proxy connection by passing
+ addresses to HTTP.new, start.
+
+ * lib/net/http.rb: HTTP.new_implementation, old_implementation:
+ can use 1.2 implementation of head, get, post, put.
+ (see document)
+
+Tue Jun 27 12:05:10 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32.c (myfdclr): new function.
+
+ * win32.h: add FD_CLR.
+
+Mon Jun 26 23:41:41 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ruby.h: add cast for ANSI style.
+
+ * gc.c (rb_data_object_alloc): use RUBY_DATA_FUNC.
+
+Mon Jun 26 22:20:03 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/win32.c (is_socket, extract_file_fd): New function.
+
+ * win32/win32.c (myfdopen): use is_socket().
+
+ * win32/win32.c (myselect): return non socket files immediately
+ if file and socket handles are mixed.
+
+Mon Jun 26 16:21:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_schedule): wait_for cleared too early.
+
+Mon Jun 26 09:15:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c: remove obsolete 'F', 'D' specifiers.
+
+Sun Jun 25 00:55:03 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/socket.c (sock_s_getnameinfo): `res' would not
+ be assigned if TYPE(sa) == T_STRING.
+
+Sat Jun 24 14:36:29 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * config*.dj, configure.bat, top.sed: move to djgpp/.
+
+Sat Jun 24 02:34:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (load_file): call require_libraries() here to let
+ debug.rb work properly.
+
+Fri Jun 23 22:34:51 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * bignum.c (rb_big_lshift): reorder xds assignment to avoid
+ reusing `x' as `len' by VC++ 6.0 SP3 compiler with -Ox switch.
+
+Fri Jun 23 01:11:27 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_substr): should return empty string (""),
+ if beg == str.size and len == zero, mostly for convenience and
+ backward compatibility.
+
+ * parse.y (new_super): should tweak block_pass node for super too.
+
+ * string.c (rb_str_split_m): last split element should not be nil,
+ but "" when limit is specified.
+
+Thu Jun 22 17:27:46 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_substr): str[n,m] now returns nil when n equals
+ to str.size.
+
+Thu Jun 22 13:49:02 2000 Uechi Yasumasa <uechi@ryucom.ne.jp>
+
+ * lib/net/ftp.rb: support resuming.
+
+Thu Jun 22 13:37:19 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * eval.c (rb_thread_sleep_forever): merge pause() macro.
+
+Wed Jun 21 08:49:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): should not raise exception just by defining
+ singleton class.
+
+Wed Jun 21 01:18:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h: two macros RUBY_DATA_FUNC and RUBY_METHOD_FUNC are added
+ to make writing C++ extensions easier.
+
+ * array.c (rb_ary_dup): internal classes should not be shared by dup.
+
+ * hash.c (rb_hash_dup): ditto.
+
+ * object.c (rb_obj_dup): ditto.
+
+ * string.c (rb_str_dup): ditto.
+
+ * error.c (Init_Exception): renamed NotImplementError to
+ NotImplementedError.
+
+Tue Jun 20 16:22:38 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (make_time_t): bug in DST boundary.
+
+Tue Jun 20 10:54:19 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: add eval sitedir.
+
+Tue Jun 20 06:14:43 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: change: version syntax. old: x.yz, now: x.y.z
+
+ * lib/net/telnet.rb: ditto.
+
+Tue Jun 20 00:37:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_kcode_m): Regexp#kcode returns nil for code unfixed
+ regexp object.
+
+ * bignum.c (bigdivmod): bignum zero check was wrong.
+
+Mon Jun 19 10:48:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_cvar_set): forgot to add security check for class
+ variable assignment.
+
+Sun Jun 18 22:49:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: single quoted sitedir.
+
+ * mkconfig.rb: add DESTDIR for cross-compiling.
+
+ * lib/mkmf.rb: add DESTDIR.
+
+ * ruby.c (load_file): force binmode if fname includes ".exe"
+ on DOSISH.
+
+Sat Jun 17 23:22:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (rb_f_sprintf): should ignore negative precision given
+ by <%.*>.
+
+ * sprintf.c (rb_f_sprintf): should allow zero precision.
+
+Sat Jun 17 03:13:29 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_localtime): avoid unnecessary call of localtime.
+
+ * time.c (time_gmtime): avoid unnecessary call of gmtime.
+
+ * process.c (proc_wait2): new method.
+
+ * process.c (proc_waitpid): second argument made optional.
+
+ * process.c (proc_waitpid2): new method.
+
+Sat Jun 17 00:05:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_clone): should initialize member fields.
+
+Fri Jun 16 22:49:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_rewind): set lineno to zero.
+
+Fri Jun 16 22:47:47 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.23.
+
+ * lib/net/protocol.rb: too many CRLF in last line.
+
+Fri Jun 16 21:23:59 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: add pause(2) checking.
+
+ * eval.c: define pause() if missing.
+
+Fri Jun 16 18:41:58 2000 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * process.c (proc_setsid): BSD-style setpgrp() don't return
+ process group ID, but 0 or -1.
+
+Fri Jun 16 16:23:35 2000 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * file.c (rb_stat_inspect): gives detailed information;
+ compatibility with ruby-1.4.x.
+
+Fri Jun 16 05:18:45 2000 Yasuhiro Fukuma <yasuf@bsdclub.org>
+
+ * configure.in: FreeBSD: do not link dummy libxpg4 which was
+ merged into libc.
+
+Fri Jun 16 03:17:36 2000 Satoshi Nojo <nojo@t-samukawa.or.jp>
+
+ * ext/dbm/dbm.c (fdbm_length): use GetDBM. empty?, [] too.
+
+ * ext/gdbm/gdbm.c (fgdbm_length): ditto.
+
+ * ext/sdbm/init.c (fsdbm_length): ditto.
+
+Fri Jun 16 01:57:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_sleep_forever): pause(2) instead of sleep(3).
+
+Thu Jun 15 10:46:36 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_sub_bang): should propagate taintness from
+ replacement string.
+
+Wed Jun 14 17:01:41 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * rubytest.rb: add CONFIG['EXEEXT'] to the executable file name.
+
+Wed Jun 14 14:50:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_f_sub): assign to $_ only if modification happens.
+
+ * string.c (rb_f_gsub): ditto.
+
+ * string.c (rb_f_chop): ditto.
+
+ * string.c (rb_f_chomp): ditto.
+
+ * io.c (io_reopen): preserve file position by ftell/fseek, if io
+ is a seekable.
+
+ * eval.c (method_arity): wrong arity number for the methods with
+ optional arguments.
+
+ * time.c (make_time_t): opposite timezone shift (should be negative).
+
+Wed Jun 14 14:07:38 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * io.c: typo(ig/if).
+
+ * re.c: typo(re/reg). add rb_reg_check().
+
+ * time.c: remove unneeded declare(daylight, timezone).
+
+ * configure.in: add include <time.h> when daylight checking.
+
+Wed Jun 14 11:36:52 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * marshal.c (r_object): modified for symbols.
+
+ * marshal.c (w_object): ditto.
+
+Wed Jun 14 10:04:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_memcmp): should compare according to ruby_ignorecase.
+
+ * string.c (rb_str_cmp): use rb_memcmp.
+
+ * string.c (rb_str_index): ditto.
+
+ * string.c (rb_str_rindex): ditto.
+
+ * string.c (rb_str_each_line): ditto.
+
+Wed Jun 14 04:58:53 2000 Dave Thomas <dave@thomases.com>
+
+ * io.c (rb_io_set_lineno): should have returned VALUE, not
+ integer.
+
+Wed Jun 14 09:29:42 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_dup): dup should always propagate taintness.
+
+Wed Jun 14 00:50:14 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: read_multipart(): if no content body then raise EOFError.
+
+Tue Jun 13 11:46:17 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * process.c (proc_setsid): try implement it using setpgrp() and
+ ioctl(fd, TIOCNOTTY, NULL).
+
+ * re.c (rb_reg_prepare_re): magic variable $= should affect regex
+ pattern match.
+
+ * time.c (make_time_t): use tm.tm_gmtoff if possible.
+
+ * time.c (time_zone): use tm.tm_zone if available.
+
+Tue Jun 13 01:50:57 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.22.
+
+ * lib/net/http.rb: HTTPResponse#body returns body.
+
+Mon Jun 12 23:41:54 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in (daylight): avoid GCC optimization.
+
+Mon Jun 12 19:02:27 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: cygwin has strange timezone.
+
+ * time.c (time_zone): use tzname and daylight.
+
+Sat Jun 10 23:10:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_seek): whence is optional, default is SEEK_SET.
+
+Fri Jun 9 17:00:29 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.21.
+
+ * lib/net/http.rb: exception is raised with response object.
+
+Fri Jun 9 15:11:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (make_time_t): supports daylight saving time.
+
+ * eval.c (rb_thread_safe_level): should retrieve current $SAFE
+ value if a thread is the current thread.
+
+Thu Jun 8 14:25:45 2000 Hiroshi Igarashi <iga@ruby-lang.org>
+
+ * lib/mkmf.rb: add target `distclean' in Makefile for extlib.
+ target `clean' doesn't remove Makefile.
+
+Thu Jun 8 13:34:03 2000 Dave Thomas <dave@thomases.com>
+
+ * numeric.c: add nan?, infinite?, and finite? to Float
+
+Thu Jun 8 00:31:04 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * regex.h: export re_mbctab properly on cygwin.
+
+ * dln.c: use dlopen instead of LoadLibrary on cygwin.
+
+Thu Jun 8 13:41:34 2000 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * file.c (rb_file_s_basename): might dump core.
+
+Tue Jun 6 03:29:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (dir_foreach): now returns nil for consistency.
+
+ * bignum.c (bigdivmod): modulo by small numbers was wrong.
+
+Mon Jun 5 00:18:08 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * bignum.c: avoid conflict with USHORT on mingw32.
+
+Mon Jun 5 00:13:35 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * eval.c (rb_thread_schedule): =/== typo.
+
+Sun Jun 4 03:17:36 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: improve: CGI::pretty()
+
+Sun Jun 4 02:01:10 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * lib/mkmf.rb: do not need to add -L$(topdir) in --enable-shared case.
+
+Sat Jun 3 13:50:06 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (rb_id2name): should support constant attrset
+ identifiers.
+
+ * bignum.c (rb_big_eq): Bignum#== should not raise exception.
+
+Fri Jun 2 11:24:48 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_popen): open with a block returns the value from the
+ block. old behavior was back.
+
+Fri Jun 2 00:42:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+
+ * eval.c (rb_thread_cleanup): should clear priority for thread
+ termination.
+
+Thu Jun 1 22:39:41 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.20.
+
+ * lib/net/http.rb: wrongly closed the socket twice
+ when no Content-Length: was given.
+
+Thu Jun 1 00:59:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_yield_0): convert Qundef to [].
+
+Wed May 31 20:45:59 2000 Dave Thomas <Dave@Thomases.com>
+
+ * string.c (rb_str_slice_bang): wrong argument number.
+
+Wed May 31 12:37:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_exec_end_proc): print error message from END procs.
+
+Wed May 31 04:06:41 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: change: CGI#out() if "HEAD" == REQUEST_METHOD then
+ output only HTTP header.
+
+Wed May 31 01:54:21 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_schedule): set main_thread->status to
+ THREAD_TO_KILL, before raising deadlock error.
+
+ * eval.c (rb_thread_deadlock): if curr_thread == main_thread, do
+ not call rb_thread_restore_context()
+
+Tue May 30 23:33:41 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * lib/mkmf.rb (create_makefile): add $(TARGET).ilk and *.pdb
+ to cleanup files for mswin32.
+
+Mon May 29 10:41:10 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (rb_file_s_basename): should propagate taintness.
+
+Sun May 28 21:37:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * eval.c: bug fix: DLEXT2.
+
+Sun May 28 19:21:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * win32/win32.c: use ruby's glob.
+
+ * dir.c: "glob" exported and renamed to "rb_glob".
+
+ * ruby.h: ditto.
+
+ * main.c: turn off command line mingw32's globbing.
+
+Wed May 25 22:25:13 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/extmk.rb.in: use "ftools" instead of "rm -f".
+
+ * lib/mkmf.rb: ditto.
+
+Thu May 25 22:01:32 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * defines.h: mswin32: remove obsolete USHORT definition.
+
+ * re.h: mswin32: use EXTERN instead of extern.
+
+ * regex.h: mswin32: export re_mbctab properly.
+
+ * win32/ruby.def: add ruby_ignorecase and regex.c's exports.
+
+Thu May 25 21:28:44 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * re.c (rb_reg_expr_str): escape un-printable character.
+
+Thu May 25 01:35:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (tokadd_escape): forgot to add `\x' to hexadecimal
+ escape sequences.
+
+ * object.c (rb_obj_dup): dup for normal object (T_OBJECT) copies
+ instance variables only.
+
+Wed May 24 23:49:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_mod_initialize): should provide initialize.
+
+Wed May 24 23:17:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/Makefile: remove unnecessary mv and rm command call.
+
+Wed May 24 21:01:04 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/pty/pty.c: use "" instead of <> to include ruby.h and rubyio.h
+ for BeOS (PowerPC).
+
+ * file.c (rb_find_file): should check dln_find_file() result.
+
+ * win32/ruby.def: add rb_block_given_p.
+
+Wed May 24 16:32:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_popen): popen does not take 3rd argument anymore.
+
+ * re.c (rb_reg_desc): re may be zero, check before dereferencing.
+
+Wed May 24 16:03:06 2000 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/cgi.rb: bug fix: CGI::escape(), CGI::Cookie::new()
+
+ * lib/net/telnet.rb: improve: binmode(), telnetmode() interface
+
+Wed May 24 13:12:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * misc/ruby-mode.el (ruby-parse-region): support `while .. do'
+ etc. But corresponding keywords must be at the beginning of
+ line.
+
+Tue May 23 23:50:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_initialize_m): wrong kcode value.
+
+ * re.c (rb_reg_s_new): forgot to initialize re->ptr.
+
+Tue May 23 08:36:24 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): forgot to restore old option
+ status by (?ix-ix).
+
+ * regex.c (re_compile_fastmap): anychar may match newline if
+ RE_OPTION_MULTILINE or RE_OPTION_POSIXLINE is set.
+
+Mon May 22 22:45:06 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.19.
+
+ * lib/net/http.rb: do not use Regexp "p" option.
+
+Mon May 22 21:56:43 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * struct.c (rb_struct_getmember): should use ID2SYM, not INT2NUM.
+
+Mon May 22 15:07:37 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (rb_find_file): should check if the file really exists.
+
+Mon May 22 09:08:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_popen): _exit(0) after processing block under the
+ child process.
+
+ * io.c (rb_io_popen): flush stdout/stderr before subprocess
+ termination.
+
+ * eval.c (rb_check_safe_str): insert rb_secure(4); operation
+ requires untainted string should be prohibited in level 4.
+
+Sun May 21 21:17:00 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: add Setup.dj for djgpp cross-compiling.
+
+ * Setup.dj: add readline.
+
+ * instruby.rb: copy win32/win32.h to archlibdir on mingw32.
+
+Sun May 21 20:58:08 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * pack.c: fix OFF16 and OFF32 definitions for Alpha and IRIX64.
+
+Sun May 21 17:31:37 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * instruby.rb: support "make install" for cross-compiling.
+
+ * ext/extmk.rb.in: ditto.
+
+Sun May 21 14:22:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * Makefile.in: rename prep.rb to fake.rb.
+
+ * configure.in: ditto.
+
+Sat May 20 23:29:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (dir_s_new): does not take block; "open" does.
+
+ * io.c (rb_io_s_new): ditto.
+
+Fri May 19 07:44:26 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (dir_s_open): Dir#open does not returns closed Dir if a
+ block is given to the method.
+
+ * re.c (rb_reg_initialize_m): Regexp::new calls initialize now.
+
+ * string.c (Init_String): String#delete_at removed.
+
+ * string.c (rb_str_aset_m): should have checked argc != 2.
+
+ * eval.c (rb_thread_schedule): select(2) was called too many.
+
+ * regex.c (re_compile_pattern): a bug in (?m) support. Pointed
+ out by Dave Thomas <Dave@thomases.com>.
+
+Thu May 18 23:55:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * dln.c (search_undef): st_lookup()'s 3rd parameter should be
+ a pointer of the variable which has the same size and alignment
+ as `char *'.
+
+ * marshal.c (w_symbol, w_object): ditto.
+
+ * parse.y (rb_intern): ditto.
+
+Thu May 18 18:00:35 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.18.
+
+ * lib/net/protocol.rb: Net::Version was removed.
+
+ * lib/net/smtp.rb: use Socket.gethostname to get local host name.
+
+Thu May 18 13:34:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (ruby_connect): should not have replaced
+ thread_write_select() by rb_thread_fd_writable().
+
+Thu May 18 09:01:25 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * configure.in, ext/extmk.rb.in, lib/mkmf.rb: remove BeOS R3 support.
+ Make a shared library (libruby.so) only if the --enable-shared
+ option is specified.
+
+ * instruby.rb: no longer use libruby.so.LIB and import.h.
+
+ * io.c: fix READ_DATA_PENDING definition for BeOS (PowerPC).
+
+Wed May 17 14:14:23 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_new_1): use /m instead of /p.
+
+Wed May 17 02:22:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_polling): wait 0.06 second to let other
+ processes run.
+
+ * process.c (rb_waitpid): avoid busy wait using rb_thread_polling.
+
+ * file.c (rb_thread_flock): ditto.
+
+ * parse.y (expr): avoid calling value_expr() twice.
+
+Wed May 17 00:45:57 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * io.c (rb_io_binmode): should check PLATFORMs, not O_BINARY, sigh...
+
+Wed May 17 00:40:15 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/config.h: add DLEXT2, now DLEXT on mswin32 is "so".
+
+ * win32/config.status: ditto.
+
+ * win32/ruby.def: add symbol "rb_big_divmod".
+
+Tue May 16 19:45:32 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * intern.h: use EXTERN instead of extern.
+
+ * win32/ruby.def: add rb_defout, rb_stdout, ruby_errinfo,
+ ruby_sourceline, ruby_sourcefile to work with eruby
+ reported by Hiroshi Saito <HiroshiSaito@pob.org>.
+ Export both ruby_xmalloc and xmalloc etc.
+
+Tue May 16 17:00:05 2000 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * eval.c (rb_thread_select): should check whether fds are null.
+
+Tue May 16 11:51:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (pipe_open): synchronize subprocess stdout/stderr.
+
+Mon May 15 15:38:09 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h: exported symbols should be for xmalloc etc. are now
+ prefixed by 'ruby_', e.g. ruby_xmalloc().
+
+ * eval.c (rb_thread_select): remove busy wait for select.
+
+ * dir.c (glob): trailing path may be null, e.g. glob("**").
+
+Mon May 15 14:48:41 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * io.c (rb_io_pid): new method; returns nil if no process attached
+ to the IO.
+
+Mon May 15 01:18:20 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_s_popen): _exit after Proc execution.
+
+Sun May 14 18:05:59 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * Makefile.in: missing/nt.c -> win32/win32.c
+
+ * configure.in: bug fix; static linking on mingw32.
+
+ * cygwin/GNUmakefile.in: remove VPATH.
+
+ * ext/extmk.rb.in: Makefile set binmode with mingw32 on cygwin32.
+
+ * lib/mkmf.rb: ditto.
+
+ * win32/config.h: undef HAVE_SYS_FILE_H.
+
+Sun May 14 02:02:48 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * lib/irb/ruby-lex.rb: '/' should be escaped in character class.
+
+Sun May 14 00:54:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in, ...: support mingw32.
+
+ * defines.h: ditto. undef EXTERN for tcl/tk on cygwin.
+
+ * ext/*/extconf.rb: replace PLATFORM with RUBY_PLATFORM.
+
+ * ext/socket/sockport.h: define IN_MULTICAST for missing IN_MULTICAST.
+
+ * ext/tcltklib/tcltklib.c: remove declaration of rb_argv0.
+
+ * file.c: should check S_IXGRP, S_ISGID, not NT.
+
+ * io.c (rb_io_binmode): should check _IOBIN, O_BINARY, not PLATFORMs.
+
+Sat May 13 14:21:15 2000 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * io.c (rb_io_s_popen): should check whether a block is given.
+
+Fri May 12 17:33:44 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): charset_not should not exclude
+ newline from matching set.
+
+Thu May 11 22:51:05 2000 Ryunosuke Ohshima <ryu@jaist.ac.jp>
+
+ * pack.c (pack_pack): Bignum support.
+
+ * pack.c (pack_unpack): ditto.
+
+Thu May 11 21:19:29 2000 Hiroshi Igarashi <iga@ruby-lang.org>
+
+ * intern.h: add missing declarations of ruby API functions.
+
+ * ruby.h: fix function name in declarations.
+
+Thu May 11 22:29:25 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/md5/depend: add $(topdir)/config.h dependency to md5c.o.
+
+ * ext/md5/extconf.rb: new file to add -DHAVE_CONFIG_H flag for Alpha.
+
+Thu May 11 10:55:52 2000 Ryunosuke Ohshima <ryu@jaist.ac.jp>
+
+ * pack.c (pack_pack): packing BER compressed integer by `w'.
+
+ * pack.c (pack_unpack): unpacking BER.
+
+Thu May 11 00:37:55 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_regx): remove in_brack.
+
+Wed May 10 12:51:18 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (proc_options): move adding RUBYLIB and "." to the load
+ path after #! line parsing.
+
+ * parse.y (parse_regx): should parse backslash escape like `\c['
+ here to avoid causing `unterminated regexp' error.
+
+Wed May 10 00:19:53 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * MANIFEST, beos/GNUmakefile.in, configure.in: no longer need
+ beos/GNUmakefile.in to support BeOS R4.5.2 (Intel) as a result
+ of eban's Makefile.in change.
+
+ * io.c: NOFILE is already defined on BeOS R4.5 (Intel) or later.
+
+ * lib/matrix.rb: remove debug print.
+
+ * regex.c: don't use nested comment.
+
+Tue May 9 17:08:43 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (massign): no longer convert nil into empty array.
+
+ * io.c (rb_io_s_popen): optional 3rd argument to give proc, which
+ will be executed in spawned child process.
+
+Mon May 8 23:47:39 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (rb_callcc): prev & next should be initialized to zero.
+
+Mon May 8 23:17:36 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dln.c (dln_init): remove possible buffer overrun. This is
+ suggested by Aleksi Niemela <aleksi.niemela@cinnober.com>.
+
+ * dln.c (init_funcname): ditto.
+
+Sat May 6 23:35:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (lhs): should allow `obj.Attr = 5' type expression.
+
+Sat May 6 15:46:08 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/socket/extconf.rb: add a new configure option to force use
+ of the WIDE Project's getaddrinfo(): --enbale-wide-getaddrinfo.
+
+Fri May 5 21:19:22 2000 MOROHOSHI Akihiko <moro@remus.dti.ne.jp>
+
+ * parse.y (yylex): allow '$1foo' and such.
+
+Fri May 5 17:57:24 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.17.
+
+ * lib/net/http.rb: write also port number in Host: field.
+
+ * lib/net/http.rb: see Proxy-Connection: to decide socket connection.
+
+Fri May 5 03:25:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_fastmap): charset_not for multibyte
+ characters excluded too many characters.
+
+Tue May 2 13:23:43 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_schedule): little bit more impartial context
+ switching.
+
+Tue May 2 09:50:03 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * configure.in: add DLDLIBS to set platform specific library
+ for extensions.
+
+ * ext/extmk.rb.in: use @DLDLIBS@ instead of RUBY_PLATFORM choice.
+
+ * lib/mkmf.rb: use CONFIG["DLDLIBS"] instead of RUBY_PLATFORM choice.
+
+ * config_s.dj: add @DLDLIBS@.
+
+ * win32/config.status: ditto.
+
+ * win32/ruby.def: regular maintenance.
+
+Mon May 1 23:42:44 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in, eval.c: add DLEXT2. now DLEXT on Cygwin is "so".
+
+ * defines.h: use dllimport, dllexport for Cygwin 1.1.x.
+
+ * ruby.h: ditto.
+
+ * cygwin/GNUmakefile.in: ditto.
+
+ * ext/Win32API/Win32API.c: directly "call" in asm statement for
+ gcc 2.95.x or newer.
+
+Sat Apr 29 04:58:12 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * array.c (rb_ary_unshift_m): performance improvement.
+
+Fri Apr 28 00:19:22 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * array.c (rb_ary_unshift_m): takes items to push.
+
+Wed Apr 26 15:23:02 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_succ): insert carrying character just before
+ the leftmost alpha numeric character.
+
+ * string.c (rb_str_succ): proper behavior for "".succ and "\377".succ.
+
+ * string.c (rb_str_succ): use realloc and memmove.
+
+Tue Apr 25 18:28:45 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.16.
+
+ * lib/net/smtp.rb: add SMTP AUTH
+
+Tue Apr 25 14:30:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_gets_internal): shortcut when rs == rb_default_rs.
+
+Sat Apr 22 23:14:41 2000 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * configure.in: MacOS X support.
+
+Sat Apr 22 16:37:10 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.15.
+
+ * lib/net/http.rb: closing socket by watching both
+ user header and server response
+
+Fri Apr 21 21:44:34 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * io.c (rb_io_s_pipe): should set FMODE_SYNC.
+
+Thu Apr 20 16:59:22 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (massign): `*lvalue = false' should assign `[false]' to
+ lvalue.
+
+Wed Apr 19 08:35:08 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (rb_singleton_class): generate singleton class for
+ special constants: nil, true, false.
+
+Wed Apr 19 02:09:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (rb_singleton_class): singleton method for nil, true,
+ false is possible now.
+
+ * eval.c (rb_eval): ditto.
+
+Tue Apr 18 18:54:25 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.14.
+
+ * lib/net/http.rb: new method HTTP#head2.
+
+ * lib/net/http.rb: get2/post2 does not raise exceptions.
+
+Mon Apr 17 15:16:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_close): to detect some exceptional status, writable
+ IO should be flushed before close;
+
+Sat Apr 15 18:29:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_collect_bang): Array#filter renamed.
+
+Fri Apr 14 19:47:11 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.13.
+
+ * lib/net/pop.rb: accept illegal timestamp
+
+ * lib/net/http.rb: when body was chunked, does not set Content-Length:
+
+Tue Apr 11 21:14:42 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * config_s.dj: add @sitedir@.
+ * configure.in: add --with-sitedir=DIR option.
+ * instruby.rb: use CONFIG["sitedir"].
+ * lib/mkmf.rb: support 'make site-install'.
+ * win32/config.status: add @sitedir@.
+
+Tue Apr 11 16:25:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (rb_big_2comp): unnecessary lvalue cast removed.
+
+Tue Apr 11 02:25:53 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (env_fetch): new method.
+
+ * marshal.c (marshal_dump): accepts depth = nil for unlimited depth.
+
+Sun Apr 9 20:49:19 2000 Dave Thomas <Dave@Thomases.com>
+
+ * parse.y (str_extend): Allow class variables to be expanded.
+
+Fri Apr 7 02:03:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (rb_sys_fail): escape non-printable characters.
+
+Thu Apr 6 20:10:47 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/extmk.rb.in (create_makefile): BeOS --program-suffix support.
+ * lib/mkmf.rb (create_makefile): ditto.
+
+Thu Apr 6 09:55:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * error.c (rb_sys_fail): need rb_exc_new2() call on BeOS.
+
+Mon Apr 3 17:22:27 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_reopen): support tempfile.
+
+ * eval.c (catch_i): should supply argument.
+
+Sat Apr 1 22:50:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (r_object): wrong symbol restoration.
+
+Sat Apr 1 21:30:53 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * io.c (rb_io_printf, rb_f_printf): should use rb_io_write.
+
+Sat Apr 1 00:16:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (rb_gc_call_finalizer_at_exit): should be clear flags
+ before calling finalizers.
+
+ * eval.c (specific_eval): can be called without SecurityError, if
+ $SAFE >= 4.
+
+ * object.c (sym_inspect): inspect gives ":sym", to_s gives "sym".
+
+Fri Mar 31 22:07:04 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.12.
+
+ * lib/net/protocol.rb: update Net::Protocol::Proxy#connect
+
+ * lib/net/protocol.rb: ReplyCode is not a class
+
+ * lib/net/http.rb: header value format was change:
+ values do not include header name
+
+ * lib/net/http.rb: header is not a Hash, but HTTPResponse
+
+Thu Mar 30 12:19:44 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * enum.c (enum_find): rb_eval_cmd() should be called with array.
+
+Tue Mar 28 13:57:05 2000 Clemens Hintze <c.hintze@gmx.net>
+
+ * ext/dbm/dbm.c (fdbm_invert): should return new hash.
+
+ * ext/gdbm/gdbm.c (fgdbm_invert): ditto.
+
+Tue Mar 28 00:58:03 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.11.
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: does not
+ dispatch any commands while dispatching command.
+
+ * lib/net/protocol.rb: failed to get error class of
+ inherited ReplyCode
+
+ * lib/net/http.rb: change feature of "get2", "post2"
+
+Mon Mar 27 01:34:58 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.10.
+
+ * lib/net/http.rb: return value of 'head' was wrong.
+
+Sun Mar 26 17:47:35 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.9.
+
+ * lib/net/smtp.rb: SMTP#do_ready wrongly took no arguments
+
+Sat Mar 25 23:21:10 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (w_object): symbols should be converted to ID before
+ dumping out.
+
+Fri Mar 24 18:26:51 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (test_check): should have checked exact number of arguments.
+
+Fri Mar 24 21:02:11 2000 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * signal.c (trap): should treat some symbols as the signal.
+
+Fri Mar 24 06:58:03 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.8.
+
+ * lib/net/http.rb: post, get2, post2, get_body
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: separate
+ Command/Socket documentation.
+
+Thu Mar 23 02:26:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_fptr_finalize): fptr may be null.
+
+ * io.c (rb_io_s_new): now calls `initialize'.
+
+ * io.c (rb_io_initialize): actual open done in this method.
+
+ * io.c (rb_file_initialize): ditto.
+
+ * eval.c (rb_eval): class variables in singleton class definition
+ is now handled properly (I hope).
+
+Wed Mar 22 21:49:36 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * st.c (st_delete_safe): skip already deleted entry.
+
+ * hash.c (rb_hash_delete): modify brace miss.
+
+Wed Mar 22 08:53:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (exec_under): do not push cbase if ruby_cbase == under.
+
+ * node.h (NEW_CREF0): preserve cbase nesting.
+
+Tue Mar 21 12:57:50 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_class_s_new): Class::new should call `inherited'.
+
+Sat Mar 18 12:36:09 2000 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * eval.c (rb_backtrace, make_backtrace): removed unused variable
+ `lev'.
+
+ * eval.c (rb_attr): calls `method_added' at attribute definition.
+
+ * eval.c (rb_mod_modfunc): calls `singleton_method_added' while
+ `module_function'.
+
+ * eval.c (rb_eval): parameter to `method_added' and
+ `singleton_method_added' is Symbol.
+
+ * eval.c (Init_eval): caches IDs for `method_added' and
+ `singleton_method_added'.
+
+Sat Mar 18 11:25:10 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (rescue): allows `rescue Error in foo'. experimental.
+ which is better this or preparing alias `exception' for `$!'?
+
+Fri Mar 17 15:02:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_autoload_id): defining new autoload should be
+ prohibited for $SAFE > 4.
+
+ * variable.c (rb_autoload_load): autoload should be possible for
+ $SAFE > 4.
+
+ * eval.c (call_trace_func): should handle T_ICLASS properly.
+
+Fri Mar 17 14:34:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_gsub): forgot to initialize str->orig.
+
+Fri Mar 17 01:24:59 2000 Dave Thomas <Dave@thomases.com>
+
+ * string.c (rb_str_clone): forgot to copy str->orig if STR_NO_ORIG
+ is set by Array#pack.
+
+Wed Mar 15 21:25:04 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * array.c (rb_ary_join): 'result' is always duplicated
+ before concat string.
+
+Wed Mar 15 17:26:05 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_s_create): unexpected recursive call removed.
+ this bug was found by Satoshi Nojo <nojo@t-samukawa.or.jp>.
+
+Wed Mar 15 13:12:39 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (Init_Thread): Thread.join removed finally.
+
+ * string.c (rb_str_chomp_bang): forgot to call rb_str_modify().
+
+Mon Mar 13 16:12:13 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (block_pass): distinguish real orphan block and still
+ on-stack block passed by block argument.
+
+Mon Mar 13 00:20:25 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (f_norm_arg): proper error message when constant comes
+ in formal argument list. this message is suggested by Muvaw
+ Pnazte <bugathlon@yahoo.com>.
+
+ * eval.c (rb_f_raise): proper error message when the first
+ argument is not an exception class/object.
+
+ * string.c (rb_str_dup): dup now postpone buffer copy as long as
+ possible. performance improved by lazy copying.
+
+Sun Mar 12 13:58:52 2000 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * signal.c (rb_f_kill): should treat some symbols as the signal.
+
+Sat Mar 11 22:03:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_gsub): performance tune by avoiding buffer copy.
+
+ * eval.c (rb_f_missing): check if argv[0] is ID.
+
+Sat Mar 11 15:49:41 2000 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * struct.c (rb_struct_aref): struct aref by symbol.
+
+Sat Mar 11 05:07:11 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * process.c (proc_setpriority): should return 0, not nil.
+
+ * process.c (proc_setpgid): ditto.
+
+Fri Mar 10 18:14:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (path_check_1): confusing buf and path. this bug found
+ by <decoux@moulon.inra.fr>.
+
+Fri Mar 10 09:37:49 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * MANIFEST: add beos/GNUmakefile.in.
+ * configure.in: support BeOS R4.5.2 (Intel).
+ * beos/GNUmakefile.in: new file to support BeOS R4.5.2 (Intel).
+
+Thu Mar 9 11:13:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_fastmap): fixed embarrassing brace bug.
+
+Thu Mar 9 01:36:32 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * missing/flock.c: emulate missing flock() with fcntl().
+
+Thu Mar 9 00:29:35 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (sym_to_s): returns ":sym".
+
+ * object.c (sym_id2name): separated from to_s; returns "sym".
+
+Wed Mar 8 19:16:19 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.7.
+
+ * lib/net/http.rb (connecting): returns header
+
+Wed Mar 8 02:08:43 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y: escape expansion too early.
+
+ * string.c (rb_f_scan): Kernel#scan added.
+
+ * regex.c (re_compile_pattern): support \cX et al.
+
+Tue Mar 7 01:44:27 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (set_stdin): simplified procedure, allows $stdin = DATA;
+ experimental.
+
+ * io.c (set_outfile): ditto.
+
+ * re.c (Init_Regexp): new method Regexp#last_match added; it's an
+ alternative for $~.
+
+ * configure.in (DEFAULT_KCODE): KCODE_NONE should be the default.
+
+ * dir.c (dir_s_rmdir): should return 0 on success.
+
+ * signal.c: remove CWGUSI support.
+
+Mon Mar 6 12:28:37 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (w_symbol): support symbol object.
+
+ * util.c: make symbol as separated class.
+
+ * error.c (Init_Exception): new exception RangeError.
+
+ * ext/socket/socket.c (ip_addrsetup): should check length of hostname.
+
+ * ext/socket/socket.c (ip_addrsetup): check newline at the end of
+ hostname. These fixes suggested by Muvaw Pnazte <bugathlon@yahoo.com>.
+
+Sun Mar 5 20:35:45 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/Win32API/Win32API.c (Win32API_initialize): should call
+ LoadLibrary() everytime and should assign the hdll to Win32API
+ object(protect the hdll from GC).
+
+Sun Mar 5 18:49:06 2000 Nakada.Nobuyoshi <nobu.nokada@softhome.net>
+
+ * misc/ruby-mode.el (ruby-parse-region): not treat method `begin'
+ and `end' as reserved words.
+
+ * misc/ruby-mode.el (ruby-font-lock-docs): ignore after `=begin'
+ and `=end'.
+
+ * misc/ruby-mode.el (ruby-font-lock-keywords, hilit-set-mode-patterns):
+ added `yield' to keywords.
+
+ * misc/ruby-mode.el (ruby-font-lock-keywords, hilit-set-mode-patterns):
+ matches keywords at end of buffer.
+
+Sun Mar 5 18:08:53 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.6.
+
+ * lib/net/http.rb: allow to omit 'start'
+
+Tue Feb 29 01:08:26 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * range.c (range_initialize): initialization done in `initialize';
+ `initialize' should not be called more than once.
+
+ * object.c (Init_Object): default `initialize' should take zero
+ argument.
+
+ * time.c (time_s_new): call `initialize' in Time::new.
+
+Sat Feb 26 22:39:31 2000 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * string.c (rb_str_times): fix String#* with huge string.
+
+Sat Feb 26 00:14:59 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (dir_s_new): call `initialize' in Dir::new.
+
+Fri Feb 25 23:01:49 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ruby.h: export ruby_safe_level by EXTERN for mswin32.
+ * win32/ruby.def: regular maintenance.
+
+Fri Feb 25 22:12:46 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_reopen): IO#reopen should accept path as well.
+
+ * string.c (rb_str_s_new): call `initialize' in String::new.
+
+ * hash.c (rb_hash_s_new): call `initialize' in Hash::new.
+
+ * array.c (rb_ary_s_new): call `initialize' in Array::new.
+
+Fri Feb 25 12:50:20 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_start_timer): interval changed to 10ms from 50ms.
+
+Fri Feb 25 06:42:26 2000 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/socket/socket.c (ip_addrsetup): hostp should remain NULL if
+ host is nil.
+
+Thu Feb 24 16:53:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_schedule): priority check for sleep expired
+ threads needed.
+
+Wed Feb 23 14:22:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_join): forgot to initialize a local variable
+ `taint'.
+
+Tue Feb 22 07:40:55 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (Init_Regexp): renamed to MatchData, old name MatchingData
+ remain as alias.
+
+Tue Feb 22 00:20:21 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.5.
+
+ * lib/net/session.rb: rename to protocol.rb
+
+ * lib/net/protocol.rb: ProtocolSocket -> Net::Socket
+
+ * lib/net/protocol.rb: Net::Socket#write, write_pendstr
+ can take block
+
+ * lib/net/smtp.rb: new methods SMTP#ready SMTPCommand#write_mail
+
+ * lib/net/pop.rb: POPMail#pop can take block
+
+Sat Feb 19 23:58:51 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): pop_loop should not pop at forward jump.
+
+Fri Feb 18 17:15:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (method_clone): method objects are now clonable.
+
+Fri Feb 18 00:27:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_shared_variable_declare): shared variable (aka
+ class/module variable) introduced. prefix `@@'. experimental.
+
+ * class.c (rb_scan_args): new format char '&'.
+
+Thu Feb 17 19:09:05 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/win32.c (mypopen): don't close handle if it is not assigned.
+ * win32/win32.c (my_open_osfhandle): support O_NOINHERIT flag.
+ * win32/win32.c (win32_getcwd): rename getcwd to win32_getcwd
+ in order to avoid using the C/C++ runtime DLL's getcwd.
+ Use CharNext() to process directory name.
+ * win32/win32.h: map getcwd to win32_getcwd.
+
+Wed Feb 16 00:32:49 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (method_arity): nd_rest is -1 for no rest argument.
+
+ * process.c (proc_waitpid): returns nil when waitpid(2) returns 0.
+
+Tue Feb 15 01:47:00 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * process.c (rb_f_waitpid): pid_t should be signed.
+
+Mon Feb 14 13:59:01 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): yylex yields wrong tokens for `:foo=~expr'.
+
+ * ruby.c (load_file): exit if reading file is empty.
+
+Mon Feb 14 03:34:52 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): `foo.bar=1' should be <foo><.><bar><=><1>,
+ not <foo><.><bar=><1>.
+
+ * eval.c (rb_thread_restore_context): process according to
+ RESTORE_* is moved after longjmp().
+
+ * eval.c (thread_switch): new function to process RESTORE_*.
+
+Sun Feb 13 16:19:49 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ruby.c (require_libraries): don't access freed memory.
+
+ * ruby.c (add_modules): ditto.
+
+Fri Feb 11 12:06:22 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_quotedwords): %w() need to split not only by mere
+ spaces, but by all whitespaces.
+
+Thu Feb 10 02:12:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_index_m): did not support negative offset.
+
+Wed Feb 9 21:54:26 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/getaddrinfo.c: gcc --traditional support.
+ Rearrange headers to work AC_C_CONST.
+ * ext/socket/getnameinfo.c: ditto.
+ * ext/socket/socket.c: mswin32: use double instead of long long.
+
+Wed Feb 9 16:30:41 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (num_coerce): should return [y, x].
+
+Wed Feb 9 11:07:30 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (ruby_prog_init): loadpath structure changed.
+
+Tue Feb 8 02:07:33 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): optimize for \G at top.
+
+ * regex.c (re_compile_pattern): \G introduced.
+
+ * regex.c (re_match): ditto.
+
+ * string.c (str_sub_bang): old behavior restored: bang method
+ returns nil if string not changed.
+
+ * regex.c (re_compile_pattern): support independent subexpression
+ `(?>pattern)'.
+
+ * regex.c (re_match): ditto.
+
+Mon Feb 7 15:51:08 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): now understands interrupts under Ruby.
+
+Mon Feb 7 07:51:52 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_uniq_bang): always return an Array.
+
+ * array.c (rb_ary_compact_bang): ditto.
+
+ * array.c (rb_ary_flatten_bang): ditto.
+
+ * hash.c (rb_hash_reject): returns a Hash, not an Array.
+
+ * hash.c (env_reject): ditto.
+
+Fri Feb 4 10:20:25 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (scan_once): scan now leaves information about the last
+ successful pattern match in $&.
+
+ * io.c (rb_io_close): should not check closed IO.
+
+Fri Feb 4 05:44:01 2000 Kentaro Inagaki <inagaki@tg.rim.or.jp>
+
+ * ext/socket/socket.c (s_recv): TRAP_BEG after retry entry.
+
+Wed Feb 2 22:33:45 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (rb_thread_start): receives argument from outside, like
+ `Thread::start(1,2,3){|a,b,c| ... }'.
+
+Wed Feb 2 22:14:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_regsub): should check regs->num_regs.
+
+ * re.c (rb_reg_search): remove matchcache, use static struct
+ re_register instead.
+
+ * re.c (match_getter): avoid cloning match data.
+
+Wed Feb 2 17:12:15 2000 Dave Thomas <Dave@Thomases.com>
+
+ * samples/eval.rb: Rescue new ScriptError exception
+
+Wed Feb 2 02:06:07 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_gsub_bang): gsub! now leaves information about the
+ last successful pattern match in $&.
+
+Mon Jan 31 15:24:58 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_sub_bang): bang method returns string always.
+ experimental.
+
+Sun Jan 30 17:58:09 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * eval.c: arrange to use setitimer(2) for BOW, DJGPP
+
+ * defines.h: ditto. use random(3) on cygwin b20.1.
+
+Sun Jan 30 17:20:16 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * eval.c: use getrlimit(2) on DJGPP.
+
+Thu Jan 27 01:27:10 2000 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+
+ * dir.c (glob): glob pattern "/*" did not match.
+
+Wed Jan 26 22:30:47 2000 Shigeo Kobayashi <shigeo@tinyforest.gr.jp>
+
+ * numeric.c (flo_modulo): wrong result for negative modulo.
+
+Wed Jan 26 02:01:57 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (test_c): should use S_ISCHR.
+
+ * file.c (rb_stat_c): ditto.
+
+ * string.c (rb_str_each_line): should propagate tainting.
+
+Tue Jan 25 04:01:34 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_obj_freeze): all objects made freezable.
+
+Tue Jan 25 00:37:01 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: use AC_CHECK_TOOL for cross compiling.
+
+Mon Jan 24 19:01:54 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * array.c (rb_protect_inspect): should be checked by id of
+ objects; not by object themselves.
+
+Mon Jan 24 18:48:08 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * eval.c (rb_eval): too many warnings; warned on every method
+ overriding. should be on method discarding.
+
+Mon Jan 24 02:56:44 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): -2.abs should be `(-2).abs' to accomplish the
+ principle of less surprise. `+2' too.
+
+ * eval.c (rb_eval): when defining class is already there, and
+ superclass differ, throw away the old class.
+
+ * variable.c (rb_const_set): gives warning again on constant
+ redefinition.
+
+ * error.c (Init_Exception): SyntaxError, NameError, LoadError and
+ NotImplementError are subclasses of ScriptError<Exception, not
+ StandardError. experimental.
+
+Sat Jan 22 00:00:41 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_quotedwords): no longer use `String#split'.
+ and enable space escape within quoted word list.
+ e.g. %w(a\ b\ c abc) => ["a b c", "abc"].
+
+ * string.c (rb_str_slice_bang): new method `slice!'.
+
+Fri Jan 21 21:56:08 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.4.
+
+ * lib/net/http.rb: can receive messages which have
+ no Content-Length:.
+
+Fri Jan 21 16:15:59 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thgroup_s_new): new class ThreadGroup.
+
+Tue Jan 18 12:24:28 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * struct.c (Init_Struct): remove Struct's own hash and eql?.
+
+Sat Jan 15 22:21:08 2000 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * eval.c (search_method): argument klass may be 0.
+
+Sat Jan 15 15:03:46 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * enum.c (enum_index): remove this method.
+
+ * enum.c: remove use of pointers to local variables. find,
+ find_all, min, max, index, member?, each_with_index,
+
+ * eval.c (massign): multiple assignment does not use to_a anymore.
+ experimental.
+
+Fri Jan 14 12:22:04 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_replace): use memmove instead of memcpy for
+ overwrapping strings (e.g. a[1] = a).
+
+Thu Jan 13 11:12:40 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg_add): use new node, ARGSPUSH.
+
+Mon Jan 10 18:32:28 2000 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * marshal.c (w_object): forgot an argument to call w_ivar().
+
+Sun Jan 9 18:13:51 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * random.c: first was not defined unless HAVE_RANDOM.
+
+Sat Jan 8 19:02:49 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_sysread): raise IOError for buffered IO.
+
+ * ext/socket/socket.c (s_recv): ditto.
+
+Fri Jan 7 00:59:29 2000 Masahiro Tomita <tommy@tmtm.org>
+
+ * io.c (io_fread): TRAP_BEG/TRAP_END added around getc().
+
+Thu Jan 6 00:39:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * random.c (rb_f_rand): should be initialized unless srand is
+ called before.
+
+Wed Jan 5 16:59:34 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.3.
+
+ * lib/net/session.rb: Session -> Protocol, ...
+
+ * lib/net/http.rb: HTTPCommand implementation was changed.
+
+Wed Jan 5 02:14:46 2000 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * parse.y: Fix SEGV on empty parens with UMINUS or UPLUS.
+
+Tue Jan 4 22:25:54 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (stmt): `() while cond' dumped core.
+
+Tue Jan 4 06:04:14 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * configure.in: modify for cross-compiling.
+ use target_* instead of host_*.
+ use AC_CANONICAL_TARGET.
+
+ * Makefile.in: ditto.
+
+ * cygwin/GNUmakefile.in: ditto.
+
+Sat Jan 1 13:26:14 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_yield_0): force_recycle ruby_dyna_vars to gain
+ performance.
+
+ * array.c (rb_ary_delete_at_m): takes same argument pattern with
+ rb_ary_aref.
+
+Sat Jan 1 10:12:26 2000 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ruby.h,util.c (rb_special_const_p): peep hole optimization.
+
+ * ruby.h,util.c (rb_test_false_or_nil): removed.
+
+ * ruby.h (RTEST, SPECIAL_CONST_P): peep hole optimization.
+
+ * ruby.h (FL_ABLE, FL_SET, FL_UNSET, FL_REVERSE): made expressions
+ not statements.
+
+ * ruby.h (OBJ_INFECT): newly added macro which copies taint from
+ `s' to `x'.
+
+Sat Jan 1 02:04:18 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_safe_level): new method.
+
+ * eval.c (rb_yield_0): recycle dyna_var_map to reduce object
+ allocation.
+
+Fri Dec 31 00:52:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c: thread independent trace_func not needed.
+
+Thu Dec 30 14:47:31 1999 akira yamada <akira@ruby-lang.org>
+
+ * configure.in: specifies -soname in LIBRUBY_DLDFLAGS on linux
+ platforms.
+
+Thu Dec 30 10:51:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c,io.c,hash,c,re.c,string.c: `_m' suffix instead of
+ `_method' for wrapper functions to implement method,
+ e.g. `rb_str_join_m()'.
+
+Thu Dec 30 02:08:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (rb_cstr2inum): non-numeric format check added.
+ currently it works only with base == 0 (i.e. Integer()).
+
+ * bignum.c (rb_str2inum): now takes VALUE to 1st argument. null
+ byte check added.
+
+ * array.c (rb_ary_replace): unless replacement is an array,
+ replacement shall be converted to array by `[replacement]', not
+ by `replacement.to_a'.
+
+ * array.c (rb_ary_plus): right operand must be an array.
+
+ * array.c (rb_ary_concat): argument must be an array.
+
+Mon Dec 27 12:35:47 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/socket.c (sock_finalize): mswin32: fix socket handle leak.
+
+ * win32/win32.c (myfdclose): ditto.
+
+Sun Dec 26 23:15:13 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/win32.c (mypopen): raise catchable error instead of rb_fatal.
+ * win32/win32.c (mypclose): fix process handle leak.
+
+Sun Dec 26 16:17:11 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/Win32API/Win32API.c (Win32API_initialize): use UINT2NUM
+ instead of INT2NUM to set __dll__ and __proc__.
+
+Sat Dec 25 00:08:59 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+
+ * ext/Win32API/Win32API.c (Win32API_Call): remove 'dword ptr'
+ from _asm.
+
+Fri Dec 24 10:26:47 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
+
+ * win32/win32.h: use "C++" linkage.
+
+Fri Dec 24 02:00:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (THREAD_ALLOC): should initialize th->trace.
+
+Fri Dec 24 00:43:39 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+
+ * io.c (pipe_open): check for `fptr->f == NULL'.
+ * win32/win32.c (mypopen): STDERR does not work during ` function.
+
+Wed Dec 22 22:50:40 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.2.
+
+ * lib/net/http.rb: HTTP support is enhanced a little
+
+ * lib/net/http.rb: support proxy
+
+Tue Dec 21 17:21:28 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
+
+ * ext/socket/socket.c (sock_finalize): mswin32: fix FILE* leak.
+
+Tue Dec 21 05:33:56 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.1.
+
+ * lib/net/http.rb: support HTTP chunk
+
+Mon Dec 20 19:08:12 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (rb_file_s_expand_path): handle dir separator correctly.
+
+Sun Dec 19 22:56:31 1999 KANEKO Naoshi <wbs01621@mail.wbs.ne.jp>
+
+ * lib/find.rb: support dosish root directory.
+ * win32/Makefile: ditto.
+ * win32/config.status: ditto.
+ * win32/win32.c (opendir): ditto.
+ * win32/win32.c (opendir): use CharPrev() to get last character
+ of the directory name.
+
+Sat Dec 18 03:00:01 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (path_check_1): check should be done by absolute path.
+
+ * marshal.c (r_ivar): should restore generic_ivar too.
+
+ * marshal.c (w_ivar): should dump generic_ivar too.
+
+Fri Dec 17 22:46:46 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb, http.rb: 1.1.0.
+
+ * lib/net/http.rb: test release
+
+ * lib/net/session.rb: support class swapping
+
+ * lib/net/session.rb: Socket#flush_rbuf
+
+ * lib/net/session.rb: doquote -> Net.quote
+
+Fri Dec 17 19:27:43 1999 IWAMURO Motonori <iwa@mmp.fujitsu.co.jp>
+
+ * eval.c (rb_load): should initialize ruby_frame->last_class.
+
+Wed Dec 15 01:35:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (proc_options): option to change directory changed to
+ `-C' like tar.
+
+ * ruby.c (proc_options): argv boundary check for `-X'.
+
+Mon Dec 13 15:15:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_adjust_startpos): separate startpos adjustment
+ because of major performance drawback.
+
+ * class.c (rb_singleton_class): tainted status of the singleton
+ class must be synchronized with the object.
+
+ * eval.c (rb_thread_schedule): implement thread priority.
+
+Sat Dec 11 03:34:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (mark_hashentry): key should be VALUE, not ID.
+
+ * io.c (argf_eof): should check next_p too.
+
+Thu Dec 9 18:09:13 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * error.c (exc_set_backtrace): forgot to declare a VALUE argument.
+
+Thu Dec 9 14:19:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_obj_taint): explicit tainting must be prohibited at
+ level 4 to prevent polluting trusted object by untrusted code.
+
+ * file.c: file operations (stat, lstat, chmod, chown, umask,
+ truncate, flock) are prohibited in level 2 (was level 4).
+
+Wed Dec 8 11:48:23 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_f_require): prohibiting require() in the secure mode
+ cause serious autoloading error.
+
+ * variable.c (rb_obj_instance_variables): don't need to prohibit
+ to get list of instance variable names of untainted objects.
+
+ * variable.c (rb_ivar_get): don't need to prohibit to get instance
+ variables of untainted objects.
+
+ * variable.c (rb_mod_remove_const): should prohibit constant
+ removals too.
+
+Wed Dec 8 09:23:01 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): should try autoloading before defining
+ class/module at the toplevel.
+
+Tue Dec 7 22:15:30 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * configure.in: Modified rb_cv_rshift_sign detect routine and
+ more simple/fast RSHIFT() for hpux-10.x.
+
+Tue Dec 7 11:16:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (Init_eval): calculate stack limit from rlimit where
+ getrlimit(2) is available.
+
+Tue Dec 7 09:57:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * file.c (rb_file_ftype): should have removed mode_t.
+
+Mon Dec 6 15:55:30 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * numeric.c (fix_rshift): Fix -1 >> 32 returned 0 (should be -1).
+
+ * numeric.c (fix_rshift): Fix 1 >> -1 returned 0 (should be 2).
+
+Mon Dec 6 11:47:23 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (rb_f_sprintf): formatted string must be tainted if
+ any of parameters is a tainted string.
+
+ * file.c (rb_file_s_expand_path): expanded file path need not to
+ be tainted always.
+
+Sun Dec 5 20:25:29 1999 Katsuhiro Ueno <unnie@blue.sky.or.jp>
+
+ * eval.c (Init_Proc): simple typo.
+
+ * gc.c (add_heap): sizeof(RVALUE*), not sizeof(RVALUE).
+
+Sat Dec 4 01:40:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): adjust startpos for multibyte match unless
+ the first pattern is forced byte match.
+
+ * bignum.c (rb_big_rand): should not use rand/random where drand48
+ may be available. RANDOM_NUMBER should be provided from outside.
+
+Fri Dec 3 09:54:59 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (moreswitches): there may be trailing garbage at #!
+ line.
+
+ * eval.c (rb_f_require): should check require 'feature.o' too.
+
+Thu Dec 2 11:58:15 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * eval.c (rb_thread_loading): should maintain loading_tbl.
+
+Thu Dec 2 10:21:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_loading_done): wrong parameter to st_delete().
+
+Wed Dec 1 11:24:06 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ruby.c (process_sflag): process -s properly (should not force `--').
+
+Wed Dec 1 09:47:33 1999 Kazunori NISHI <kazunori@swlab.csce.kyushu-u.ac.jp>
+
+ * string.c (rb_str_split_method): should increment end too.
+
+Tue Nov 30 18:00:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c: MARSHAL_MINOR incremented; format version is 4.2.
+
+ * marshal.c (w_object): distinguish class and module.
+
+ * marshal.c (w_object): save hash's default value.
+
+ * marshal.c (r_object): restore hash's default value.
+
+Tue Nov 30 01:46:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_source): generated source string must be tainted if
+ regex is tainted.
+
+ * file.c (rb_file_s_basename): basename should not be tainted
+ unless the original path is tainted.
+
+ * file.c (rb_file_s_dirname): ditto.
+
+Mon Nov 29 20:42:13 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c (stat_new): Struct::Stat -> File::Stat; Stat is no longer
+ a Struct.
+
+Mon Nov 29 15:28:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_path2class): evaluated value from path should be
+ module or class.
+
+Fri Nov 26 18:12:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_exec_end_proc): should remove only end_procs defined
+ within load wrapper.
+
+ * eval.c (rb_load): save and restore ruby_wrapper around loading.
+
+ * eval.c (rb_mark_end_proc): mark end procs registered by END{} or
+ at_exit{}.
+
+ * eval.c (rb_set_end_proc): should not call rb_global_variable()
+ on heap address; it crashed mod_ruby.
+
+Mon Nov 22 14:07:24 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ruby.c (proc_options): variable e_script should be visited by
+ garbage collector.
+
+Sat Nov 20 10:10:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (inspect_i): value may be nil, check revised.
+
+Fri Nov 19 18:06:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (glob): recursive wildcard match by `**' ala zsh.
+
+Fri Nov 19 11:44:26 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * variable.c: was returning void value.
+
+Fri Nov 19 03:57:22 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * file.c: add methods Stat struct class to reduce stat(2).
+
+Thu Nov 18 16:18:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/pstore.rb: mutual lock by flock(2).
+
+Thu Nov 18 11:44:13 1999 Masahiro Tomita <tommy@tmtm.org>
+
+ * io.c (read_all): should check bytes too.
+
+Wed Nov 17 02:40:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (Init_IO): $defout (alias of $>) added.
+
+Tue Nov 16 09:47:14 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/pstore.rb: add mutual lock using symlink.
+
+Mon Nov 15 16:50:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * enum.c (enum_grep): non matching grep returns an empty array, no
+ longer returns nil.
+
+ * enum.c (enum_grep): grep with block returns collection of
+ evaluated values of block over matched elements.
+
+Mon Nov 15 04:50:33 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * re.c (rb_reg_source): should not call rb_reg_expr_str()
+ everytime.
+
+Sat Nov 13 07:34:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_mod_constants): traverse superclasses to collect
+ constants.
+
+ * eval.c (assign): modified for shared variables.
+
+ * eval.c (rb_eval): search nested scope, then superclasses to
+ assign shared variables within methods.
+
+ * eval.c (rb_eval): remove warnings from constants modification,
+ because they are no longer constants.
+
+ * parse.y (node_assign): modified for shared variables.
+
+ * parse.y (assignable): allow constant assignment in methods;
+ constants should be called `shared variable'.
+
+Fri Nov 12 23:52:19 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * process.c (rb_f_system): argument check for NT, __EMX__, DJGPP.
+
+Wed Nov 10 21:54:11 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * hash.c (rb_any_cmp): Fixed return without value.
+
+Wed Nov 10 17:57:06 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c: incorporate <yasuf@big.or.jp>'s sprintf patch at
+ [ruby-dev:7754].
+
+Wed Nov 10 08:28:53 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_call0): supply class parameter for each invocation.
+
+Tue Nov 9 13:21:04 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * configure.in: AC_MINIX move to before AC_EXEEXT and AC_OBJEXT.
+
+Mon Nov 8 19:52:29 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * configure.in: Renamed AC_CHAR_UNSIGNED to AC_C_CHAR_UNSIGNED.
+
+ * configure.in: Added default to AC_CHECK_SIZEOF().
+
+Mon Nov 8 14:28:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (stmt): rescue modifier added to the syntax.
+
+ * keywords: kRESCUE_MOD added.
+
+ * eval.c (rb_f_eval): fake outer scope when eval() called without
+ bindings.
+
+ * eval.c (rb_f_binding): should copy last_class in the outer frame too.
+
+Sun Nov 7 18:31:04 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * eval.c (is_defined): last_class may be 0.
+
+Sat Nov 6 19:26:55 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * Makefile.in: Added depend entry make parse.@OBJEXT@ from parse.c
+ for UCB make
+
+Thu Nov 4 17:41:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): \< (wordbeg), \> (wordend) disabled.
+
+Wed Nov 3 08:52:57 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * io.c (Init_IO): forgot to use INT2FIX() around SEEK_SET, etc.
+
+Wed Nov 3 00:25:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_split_method): use mbclen2() to handle kcode
+ option of regexp objects.
+
+Mon Nov 1 14:22:15 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * eval.c (rb_eval): reduce recursive calls to rb_eval()
+ case of ||= and &&= .
+
+Sun Oct 31 13:12:42 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * regex.c (re_compile_pattern): wrong [\W] match.
+
+Fri Oct 29 16:57:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/nkf/lib/kconv.rb: new String methods (kconv, tojis, toeuc,
+ tosjis).
+
+ * time.c (time_s_at): now accepts optional second argument to
+ specify micro second.
+
+Thu Oct 28 13:35:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_split_method): should be mbchar aware with
+ single char separators.
+
+Wed Oct 27 12:57:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * random.c (rb_f_srand): random seed should be unsigned.
+
+Tue Oct 26 23:58:15 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_collect): collect for better performance.
+
+Tue Oct 26 19:20:54 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * marshal.c (r_object): should register class/module objects.
+
+Sat Oct 23 15:59:39 1999 Takaaki Tateishi <ttate@jaist.ac.jp>
+
+ * process.c (rb_f_system): should require at least one argument.
+
+Sat Oct 23 12:42:44 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * enum.c (enum_collect): collect without block will collect
+ elements in enumerable.
+
+Thu Oct 21 16:14:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (moreswitches): function to process string option;
+ the name is stolen from perl (not implementation).
+
+ * ruby.c (proc_options): use RUBYOPT environment variable to
+ retrieve the default options.
+
+ * dir.c (fnmatch): use eban's fnmatch; do not depend on system's
+ fnmatch (which may have portability problem) anymore.
+
+Wed Oct 20 15:14:24 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (marshal_load): should protect the generated object
+ table (arg->data) from GC.
+
+Mon Oct 18 16:15:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/nkf/nkf.c (rb_nkf_kconv): output should be NUL terminated.
+
+Mon Oct 18 09:03:01 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb: 1.0.3
+
+ * lib/net/pop.rb: new methods POP3Command#uidl, POPMail#uidl.
+
+Sun Oct 17 03:35:33 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * array.c (rb_ary_pop): forgot some freeze checks.
+
+Sat Oct 16 12:57:53 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * array.c (rb_ary_sort): always returns the copied array.
+
+Fri Oct 15 22:50:41 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * error.c (sys_nerr): on CYGWIN, it is _sys_nerr.
+
+Fri Oct 15 01:32:31 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * io.c (rb_io_ctl) :need to use NUM2ULONG, not NUM2INT.
+
+ * ext/Win32API/Win32API.c (Win32API_Call): need to use NUM2ULONG,
+ not NUM2INT.
+
+Fri Oct 15 00:22:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (Init_Regexp): super class of the MatchingData, which was
+ Data, to be Object.
+
+ * eval.c (ruby_run): evaluate required libraries before load &
+ compiling the script.
+
+ * parse.y (lex_getline): retrieve a line from the stream, saving
+ lines in the table in debug mode.
+
+ * eval.c (call_trace_func): treat the case ruby_sourcefile is null.
+
+Thu Oct 14 02:00:10 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (string): compile time string concatenation.
+
+Wed Oct 13 07:28:09 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb: 1.0.2
+
+ * lib/net/session.rb: new method Session#set_pipe.
+
+ * lib/net/session.rb, smtp.rb, pop.rb: add RD documentation.
+
+Wed Oct 13 02:17:05 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * array.c (rb_ary_plus): remove recursion.
+
+ * array.c (rb_ary_sort_bang): detect modify attempt.
+
+Wed Oct 13 02:17:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (block_pass): should copy block to prevent modifications.
+ tag in the structure should be updated from latest prot_tag.
+
+ * eval.c (proc_s_new): tag in struct BLOCK should not point into
+ unused stack.
+
+ * dir.c (dir_s_glob): iterate over generated matching filenames if
+ the block is given to the method.
+
+ * array.c (rb_ary_at): new methods; at, first, last.
+
+ * hash.c (rb_hash_fetch): raises exception unless the default
+ value is supplied.
+
+ * hash.c (rb_hash_s_create): need not remove nil from value.
+
+ * hash.c (rb_hash_aset): setting value to nil does not remove key
+ anymore.
+
+Tue Oct 12 22:29:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_read): length may be 0 or negative.
+
+Tue Oct 12 13:26:27 1999 Jun-ichiro itojun Hagino <itojun@itojun.org>
+
+ * signal.c (posix_signal): RETSIGTYPE may be void.
+
+Tue Oct 12 03:28:03 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * array.c (rb_ary_delete_at): allows negative position.
+
+Mon Oct 11 17:42:25 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (rb_intern): should generate distinct ID_ATTRSET symbols
+ for the name with multiple `='s at the end.
+
+ * Makefile.in (CPPFLAGS): separate cpp flags from CFLAGS.
+
+Mon Oct 11 07:27:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): should not execute the `else' clause on the
+ case the exceptions are handled by the `rescue' clause.
+
+ * signal.c (Init_signal): ignore SIGPIPE by default.
+
+Wed Oct 6 17:13:19 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * ruby.c (addpath): rubylib_mangled_path() modified.
+
+Mon Oct 4 12:42:32 1999 Kazuhiko Izawa <izawa@erec.che.tohoku.ac.jp>
+
+ * pack.c (pack_unpack): % in printf format should be %%.
+
+Mon Oct 4 10:01:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_obj_instance_variables): should always return
+ array for all object can have instance variables now.
+
+Mon Oct 4 00:08:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (OFF16): need to adjust pointer address to pack/unpack on
+ 64bit machines.
+
+Sun Oct 3 03:05:59 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * time.c (time_arg): mktime y2k problem.
+
+Sun Sep 26 16:54:45 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * parse.y (here_document): `\r' handling for here documents.
+
+Wed Sep 22 09:20:11 1999 Masahiro Tomita <tommy@tmtm.org>
+
+ * ext/socket/socket.c: SOCKS5 support.
+
+Wed Sep 22 07:33:23 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb: 1.0.1
+
+ * lib/net/pop.rb: APOP did not work.
+
+ * lib/net/pop.rb: modify the way to make APOP challenge.
+
+Wed Sep 22 00:35:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_include): should return boolean value.
+
+ * regex.c (re_compile_fastmap): wrong comparison with mbc.
+
+ * eval.c (specific_eval): default sourcefile name should be
+ "(eval)" for module_eval etc.
+
+Wed Sep 22 00:06:07 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/Makefile: update rules.
+
+ * io.c (io_fread): should not assign in char, it maybe -1.
+
+Tue Sep 21 23:57:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (call_trace_func): should not propagate retval in
+ trace_func.
+
+Mon Sep 20 21:35:39 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/win32.c (myselect): assume non socket files are always
+ readable/writable.
+
+Mon Sep 20 01:08:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_fread): should not block other threads.
+
+ * io.c (rb_io_synchronized): renamed from rb_io_unbuffered(); do
+ not call setbuf(NULL) anymore.
+
+Sat Sep 18 13:45:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * stable version 1.4.2 released.
+
+Fri Sep 17 23:24:17 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (rb_f_missing): dumped core if no argument given.
+
+Fri Sep 17 23:21:06 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/win32.c (myselect): translate WSAEINTR, WSAENOTSOCK into
+ UNIX errno constants.
+
+Fri Sep 17 00:52:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg): assignable() may return 0.
+
+Thu Sep 16 20:46:23 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * eval.c (rb_eval): was doubly evaluating the return expression.
+
+Thu Sep 16 18:40:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * stable version 1.4.1 released.
+
+Thu Sep 16 11:33:22 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (rb_str_match): should return nil.
+
+Wed Sep 15 22:46:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_s_quote): should quote `-' too.
+
+Tue Sep 14 15:23:22 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (yylex): no need to ignore `\r' here.
+
+ * parse.y (nextc): strip `\r' from text.
+
+ * parse.y (nextc): support `__END__\r\n' type terminator.
+
+Mon Sep 13 10:49:19 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * eval.c (rb_eval): needless RTEST(ruby_verbose) removed.
+
+Mon Sep 13 09:10:11 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/net/session.rb, smtp.rb, pop.rb: 1.0.0
+
+Wed Sep 8 11:37:38 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * time.c (make_time_t): bit more strict comparison.
+
+Tue Sep 7 00:50:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * range.c (range_each): use rb_str_upto() for strings.
+
+ * string.c (rb_str_upto): set upper limit by comparing curr <= end.
+
+ * range.c (range_each): should check equality to handle magic
+ increment.
+
+Mon Sep 6 22:43:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): break/next/redo available within -n/-p loop.
+
+Fri Sep 3 11:14:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * compar.c (cmp_equal): should not raise exception; protect by
+ rb_rescue().
+
+Thu Sep 2 05:23:05 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * file.c (rb_file_s_expand_path): use dirsep, instead of character
+ literal '/'.
+
+ * file.c (rb_file_s_expand_path): reduce multiple dirsep at the top.
+
+Wed Sep 1 00:28:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_call): call rb_undefined() if a method appears not to
+ be exist explicitly from cache.
+
+ * eval.c (rb_method_boundp): check method cache before calling
+ rb_get_method_body().
+
+ * eval.c (rb_get_method_body): store method non-existence
+ information in the cache.
+
+ * random.c (rb_f_srand): use getpid(2) to generate seed.
+
+ * regex.c (re_match): do not apply partial mbc match for
+ charset_not.
+
+ * regex.c (re_compile_pattern): put extended literal prefix (0xff)
+ only before numeric literals, not before all >0x80 char.
+
+ * regex.c (re_compile_pattern): put numeric literal in extended
+ charset region, not normal charset bits.
+
+ * regex.c (re_compile_fastmap): calculate fastmap for charset and
+ charset_not to treat numeric literal (e.g. \246) specially.
+
+Fri Aug 28 17:32:55 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * eval.c (rb_eval): should set return value (nil) explicitly if a
+ value is omitted for return statement.
+
+Sun Aug 26 20:26:40 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/readline/readline.c: restore terminal mode
+ even if readline() interrupted.
+
+ * ext/readline/readline.c: returned string need to
+ be tainted.
+
+ * ext/readline/readline.c: fixed memory leak.
+
+ * ext/readline/readline.c: allow negative index.
+
+ * ext/readline/readline.c: added Readline::HISTORY.size
+ same as Readline::HISTORY.length
+
+ * ext/readline/readline.c: allow conditional parsing
+ of the ~/.inputrc file by `$if Ruby'.
+
+ * ext/readline/extconf.rb: check whether the
+ libreadline has the variable `rl_completion_append_character'
+ (this feature was implemented from GNU readline 2.1).
+
+Thu Aug 26 15:06:11 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * gc.c (rb_gc): local variables may be placed beyond stack_end, so
+ use an address from alloca(1) on non C_ALLOCA platforms.
+
+Thu Aug 26 01:24:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (rb_f_sprintf): "%%" is legal, but "%3.14%" is not.
+
+Mon Aug 23 00:00:54 1999 Tsukada Takuya <tsukada@fminn.nagano.nagano.jp>
+
+ * regex.c (re_compile_fastmap): wrong macro caused memory leak.
+
+Sat Aug 21 11:30:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (ADJ): should not adjust addresses to data on heap.
+
+Fri Aug 20 20:50:58 1999 Kenji Nagasawa <kenn@hma.att.ne.jp>
+
+ * defines.h (PATH_SEP): path separator is ";" for OS/2.
+
+Thu Aug 19 10:50:43 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * gc.c (rb_gc): add volatile to avoid GCC optimize bug(?).
+
+Wed Aug 18 23:48:10 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * due to disk trouble, some change records were lost. several
+ modification made to eval.c, gc.c, io.c, pack.c,
+ ext/extmk.rb.in, and lib/mkmf.rb.
+
+Fri Aug 13 15:41:39 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * stable version 1.4.0 released.
+
+Fri Aug 13 03:16:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (argf_forward): since $stdout may be non-IO, ARGF.file is
+ not guaranteed to be IO. check and forwarding added to every ARGF
+ method.
+
+ * io.c (set_outfile): $stdout/$stderr may not be IO now.
+
+ * io.c (set_stdin): $stdin may not be IO now.
+
+ * range.c (rb_range_beg_len): round `end' to length as documented.
+
+ * io.c (Init_IO): preserve original stdin/stdout/stderr.
+
+Thu Aug 12 13:44:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (Init_load): require receives 1 argument.
+
+ * eval.c (frame_dup): should clear tmp to avoid dangling
+ references.
+
+Wed Aug 11 13:33:13 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (rb_eval): no automatic aggregate initialization.
+
+ * eval.c (module_setup): ditto.
+
+Wed Aug 11 18:18:41 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * eval.c (yield_under_i): automatic aggregate initialization is an
+ ANSI feature.
+
+Wed Aug 11 10:10:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): parse `[].length==0' as `([].length)==0', not
+ `([].length=)=0'
+
+ * parse.y (yylex): parse `[].length!=0' as `([].length)!=0', not
+ `([].length!)=0'
+
+ * parse.y (peek): peek-in lexical buffer.
+
+Wed Aug 11 00:34:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): bug on backward jump adjustment concerning
+ stop_paren.
+
+Tue Aug 10 14:54:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/nkf/nkf.c (rb_nkf_guess): binary detection was wrong.
+
+Tue Aug 10 00:07:36 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_clone): should use CLONESETUP().
+
+Mon Aug 9 23:57:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (CLONESETUP): should have copied generic instance
+ variables too.
+
+Mon Aug 9 10:46:54 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/extconf.rb: add check for <arpa/nameser.h> and
+ <resolv.h>.
+
+Sat Aug 7 13:19:06 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * numeric.c (flo_cmp): comparing NaN should not return value.
+ raises FloatDomainError.
+
+Sat Aug 7 03:09:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (blk_free): free copied frames too.
+
+ * eval.c (frame_dup): should copy previous frames from stack to
+ heap to preserve frame information.
+
+Fri Aug 6 15:01:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.7 - version 1.4 beta
+
+ * ext/socket/socket.c (s_recv): UDPsocket#recvfrom now returns
+ IPsocket#addr information.
+
+ * array.c (rb_ary_subary): ary[-3,3] should not return nil.
+
+Thu Aug 5 10:58:01 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_mark): protect old ruby_frame from GC during it
+ replaced by eval().
+
+ * eval.c (eval): do not modify frame.prev; binding should preserve
+ information about calling() too.
+
+ * eval.c (rb_yield_0): no arity check for mere yield; but only for
+ Proc#call.
+
+Tue Aug 3 22:07:13 1999 Kazuhiro HIWADA <hiwada@kuee.kyoto-u.ac.jp>
+
+ * object.c (rb_mod_clone): should check if iv_tbl, m_tbl are
+ initialized.
+
+Tue Aug 3 19:03:02 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_any_cmp): use rb_with_disable_interrupt() to ensure
+ clearance of rb_prohibit_interrupt even on failure.
+
+ * eval.c (rb_with_disable_interrupt): new function added.
+
+Sat Jul 31 23:23:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_create_0): set THREAD_RAISED flag on thread
+ termination by exception.
+
+ * eval.c (rb_thread_join): `$!' may not be nil for the threads
+ created in rescue clause.
+
+ * eval.c (rb_thread_status): ditto.
+
+ * eval.c (rb_thread_join): should re-raise exception for already
+ dead threads too.
+
+Fri Jul 30 17:56:54 1999 GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp>
+
+ * object.c (rb_mod_ge): wrong comparison.
+
+Fri Jul 30 12:15:44 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/tcltklib/extconf.rb: win32 support.
+
+ * lib/mkmf.rb: use append_library().
+
+ * ext/extmk.rb.in: ditto.
+
+Fri Jul 30 02:11:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_delete): should return nil for deleting non
+ existing item.
+
+ * io.c (rb_io_close): call rb_sys_wait() on explicit close.
+
+ * io.c (rb_io_fptr_close): do not call rb_sys_wait() on finalize.
+
+ * eval.c (yield_under_i): cbase context should be maintained for
+ Module#module_eval(). suggested by <inaba@st.rim.or.jp>.
+
+Wed Jul 28 01:18:28 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * Makefile.in: add -I$(hdrdir)/lib to install using ftools.
+
+ * util.c: use HAVE_FCNTL_H, not HAVE_FCNTL
+
+Wed Jul 28 18:24:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.6 - version 1.4 alpha
+
+Tue Jul 27 09:38:08 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * eval.c (rb_eval): reduce recursive rb_eval() calls by
+ NODE_BLOCKs.
+
+Tue Jul 27 01:20:40 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * file.c (rb_file_s_expand_path): drive letter patch.
+
+Mon Jul 26 02:36:31 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * eval.c (rb_load): should clear ruby_nerr.
+
+ * eval.c (rb_thread_join): oldbt should not be empty to unshift.
+
+Sun Jul 25 12:09:16 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * dir.c (push_braces): should treat nested braces.
+
+Fri Jul 23 02:49:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_clear): dummy argument added; suggested by
+ <eguchi@shizuokanet.ne.jp>. thanks.
+
+Thu Jul 22 19:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_join): get_backtrace() may return Qnil.
+ typecheck added.
+
+Tue Jul 20 14:36:43 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * range.c (range_each): do not treat String specially (for future
+ override).
+
+Tue Jul 20 02:28:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_gets): $_ should be nil, when get returns nil.
+
+ * io.c (rb_f_gets): ditto.
+
+Mon Jul 19 17:13:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_fastmap): should continue fastmap compile
+ for anychar_repeat, for it's repeat anyway.
+
+Mon Jul 26 13:33:45 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * lib/jcode.rb: replaced by faster code.
+
+Mon Jul 19 01:57:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/mkmf.rb: no longer use install program.
+
+ * ext/extmk.rb.in: use miniruby to install programs.
+
+Sat Jul 17 00:06:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (ipaddr): don't do reverse lookup if
+ attribute do_not_reverse_lookup is set for socket classes.
+ Experimental. Note this is a global attribute.
+
+Fri Jul 16 22:18:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_eof): use feof() to check EOF already met.
+
+ * io.c (read_all): should return nil at EOF.
+
+Fri Jul 16 13:39:42 1999 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/telnet.rb: version 0.231.
+
+Fri Jul 16 10:58:22 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * regex.c (re_match): debug print removed.
+
+Fri Jul 16 09:58:15 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * many files: clean up unused variables found by gcc -Wall.
+
+ * lib/mkmf.rb: better cygwin support etc.
+
+ * ext/extmk.rb.in: ditto.
+
+ * instruby.rb: ditto.
+
+Fri Jul 16 01:37:50 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * string.c (rb_str_squeeze_bang): the type of local variable `c'
+ should be int, not char.
+
+ * string.c (rb_str_reverse): should always return copy.
+
+Thu Jul 15 23:25:57 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/debug.rb: better display & frame treatment.
+
+Thu Jul 15 21:16:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_each): returns self for normal termination;
+ returns nil for break.
+
+ * string.c: non bang methods (e.g. String#sub) should always
+ return copy of the receiver.
+
+Thu Jul 15 21:09:15 1999 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * eval.c (find_file): do not add empty string to the path.
+
+ * configure.in (with-search-path): should not add empty string if
+ the option is not supplied.
+
+Thu Jul 15 17:49:08 1999 Ryo HAYASAKA <hayasaka@univ21.u-aizu.ac.jp>
+
+ * ext/tcltklib/tcltklib.c: move `#include "ruby.h"' forward.
+
+Thu Jul 15 16:54:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.5 - version 1.4 alpha
+
+Wed Jul 14 23:45:33 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * eval.c (ruby_init): initialize for the first time only.
+
+Tue Jul 13 00:15:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_index): re-defined; method to retrieve a key
+ from the value.
+
+ * hash.c (Init_Hash): member? should be re-defined for Hash.
+
+Tue Jul 12 13:54:51 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * io.c (rb_file_sysopen): wrong number of argument.
+
+Mon Jul 12 11:52:35 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_f_missing): class name included in message.
+
+ * eval.c (print_undef): better error message.
+
+Sun Jul 11 05:36:17 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/debug.rb: patch to show proper position.
+
+Fri Jul 9 23:56:14 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * dln.c (dln_find_1): path conv. moved to conv_to_posix_path.
+
+ * dln.c (conv_to_posix_path): path conv. should be done.
+
+Fri Jul 9 10:26:47 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * random.c (RANDOM_NUMBER): should place parentheses.
+
+Fri Jul 8 11:00:51 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * numeric.c (fix_div): division may be out of fixnum range.
+
+ * bignum.c (bigdivmod): proper sign calculation to result.
+
+Wed Jul 7 18:27:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * st.c (st_delete_safe): was modifying wrong slot.
+
+Mon Jul 5 13:17:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (rb_gc_call_finalizer_at_exit): close all files at exit.
+
+Fri Jul 2 18:00:21 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * lib/Mail/README: Mail-0.3.0 added to the distribution.
+
+Fri Jul 2 01:45:32 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_fastmap): avoid allocation of register
+ variables for each invocation of re_match(). Suggested by
+ Zasukhin Ruslan <ruslan@paradigmasoft.com>. Thanks.
+
+Tue Jun 29 20:39:24 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/tk/lib/tk.rb (TkVariable): bug fix; should value type check
+ be added?
+
+ * string.c (rb_str_each_line): a bug in paragraph mode.
+
+ * ruby.c (load_file): shifted too much to skip #!.
+
+Tue Jun 29 06:50:21 1999 Wakou Aoyama <wakou@fsinet.or.jp>
+
+ * lib/CGI.rb: 0.30 - cleanup release, incompatible.
+
+ * lib/telnet.rb: 0.22 - timeout added.
+
+Tue Jun 29 10:49:25 1999 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * configure.in: better Rhapsody support.
+
+ * lib/mkmf.rb: Rhapsody/NEXTSTEP support.
+
+Tue Jun 29 01:42:13 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/pty/pty.c (chld_changed): should use POSIX.1 style wait.
+
+Mon Jun 28 21:07:36 1999 KIMURA Koichi <kbk@kt.rim.or.jp>
+
+ * ext/extmk.rb.nt: wrong result for have_library().
+
+Mon Jun 28 15:24:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * missing/isinf.c: OSF/1 raises SIGFPE on one()/zero().
+
+ * regex.c (re_search): should search til EOS, for patterns may
+ match beyond the end of range.
+
+Mon Jun 28 12:49:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_f_select): should not accept Time objects as an
+ argument for it is time interval.
+
+ * process.c (rb_f_sleep): ditto.
+
+ * file.c (test_s): should return nil for false condition.
+
+Mon Jun 28 12:23:52 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * bignum.c (rb_dbl2big): typo.
+
+ * file.c (rb_f_test): ditto.
+
+ * string.c (rb_str_crypt): wrong message.
+
+Sun Jun 27 19:50:11 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * eval.c (rb_f_exit): should have treat signed integer status, not
+ VALUE.
+
+ * process.c (rb_f_exit_bang): should work like exit().
+
+Sun Jun 27 16:21:32 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * string.c (rb_str_rindex): wrong position to search.
+
+Sat Jun 26 04:05:30 1999 Takaaki Tateishi <ttate@jaist.ac.jp>
+
+ * configure.in (configure_args): --with-search-path to specify
+ additional ruby search path.
+
+ * ruby.c (ruby_prog_init): additional search path.
+
+Fri Jun 25 13:09:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): needed to initialize natint.
+
+ * regex.c (re_compile_pattern): add start_paren to avoid too much
+ finalization on maybe_finalize_jump.
+
+Fri Jun 25 13:07:20 1999 Koji Oda <oda@bsd1.qnes.nec.co.jp>
+
+ * missing/isinf.c: include "config.h" added.
+
+Fri Jun 25 07:25:05 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * lib/mkmf.rb: initialize $(topdir).
+
+ * ext/extmk.rb.in (install_rb): install lib/*.rb properly.
+
+ * configure.in (linux): specifies -rpath on --enable-shared.
+
+ * configure.in (aix): ruby.imp must reside in $(topdir).
+
+Thu Jun 24 19:11:29 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * parse.y (rb_str_extend): multi-byte identifier in expression
+ interpolation in strings.
+
+ * parse.y (yylex): support multi-byte char identifiers.
+
+Thu Jun 24 15:27:13 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (f_arg): check duplicate argument names.
+
+ * gc.c (rb_gc_mark): marking wrong member for NODE_ARGS.
+
+ * string.c (rb_str_rindex): POSITION specifies start point, not
+ end point.
+
+Thu Jun 24 13:00:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (print_mbc): wrong boundary.
+
+ * pack.c (uv_to_utf8): raises ArgError for too big value.
+
+Thu Jun 24 11:02:51 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * pack.c (uv_to_utf8): mask needed.
+
+Wed Jun 23 21:03:56 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * ruby.h (struct RFile): remove iv_tbl from struct. instance
+ variables are handled as generic ivs.
+
+Wed Jun 23 22:06:26 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * pack.c (utf8_to_uv): pack to 7 bytes sequence.
+
+ * pack.c (uv_to_utf8): wrong boundary.
+
+ * pack.c (pack_unpack): should treat as unsigned long.
+
+Wed Jun 23 15:10:11 1999 Inaba Hiroto <inaba@sdd.tokyo-sc.toshiba.co.jp>
+
+ * parse.y (parse_string): failed to parse nested braces.
+
+ * parse.y (parse_regx): nested braces within #{} available.
+
+Wed Jun 23 11:18:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (slow_search): wrong shift width for mbcs.
+
+ * eval.c (rb_thread_save_context): should not clear th->locals.
+
+Wed Jun 23 02:06:14 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): UMINUS binds too tight with digits. changed so
+ that -2**2 => -4.
+
+ * parse.y (close_paren): `do' for expr termination now works it
+ used to be.
+
+Wed Jun 22 18:26:42 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * pack.c (pack_pack): should initialize local variable `j'.
+
+Wed Jun 22 15:24:59 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * parse.y (here_document): a bug for multiline heredoc.
+
+Tue Jun 22 15:06:36 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/socket/socket.c (ruby_socket): forgot to return fd
+ explicitly.
+
+Tue Jun 22 13:34:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * rubyio.h (MakeOpenFile): should initialize member `iv_tbl'.
+
+Wed Jun 22 10:35:51 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * io.c (rb_io_gets_internal): getc(3) may not set errno on
+ interrupt.
+
+Mon Jun 21 22:39:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (call_required_libraries): ruby_sourceline should be
+ cleared before loading libraries.
+
+ * io.c (set_stdin): do not use reopen(), so that we don't need to
+ dup original stdin before assigning $stdin.
+
+Mon Jun 21 18:04:27 1999 Ryo HAYASAKA <hayasaka@univ21.u-aizu.ac.jp>
+
+ * ext/dbm/dbm.c: include <cdefs.h> for solaris 2.6.
+
+Mon Jun 21 15:59:47 1999 Nobuyoshi Nakada <nobu.nokada@softhome.net>
+
+ * ext/socket/socket.c (ip_addrsetup): forgot to put `else'.
+
+Mon Jun 21 15:38:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (fptr_finalize): remove rb_syswait() invocation to avoid
+ wait4(2) within GC. rb_syswait() moved to rb_io_fptr_close().
+
+Mon Jun 21 12:05:59 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * dir.c (dir_s_glob): remove MAXPATHLEN restriction.
+
+ * ext/md5/md5init.c (md5_hexdigest): should have used "%02x".
+
+Sun Jun 20 19:50:38 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * string.c (rb_str_each_line): should have checked string
+ boundary.
+
+Sat Jun 19 22:24:12 1999 Kenji Nagasawa <kenn@hma.att.ne.jp>
+
+ * OS/2 patch improved.
+
+Fri Jun 18 08:30:17 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (r_byte): add data length check.
+
+ * ext/tcltklib/tcltklib.c (_timer_for_tcl): was doing busy-wait.
+
+Tue Jun 15 10:01:21 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * configure.in: remove trailing slash from interpreter embedded
+ shared library path.
+
+ * configure.in (INSTALL_DLLIB): install shared lib with 0555.
+
+ * instruby.rb: changed mode for shared library into 0555.
+
+Fri Jun 11 23:27:00 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * ext/etc/etc.c (etc_passwd): should return nil, not exception for
+ call after last passwd entry.
+
+Fri Jun 11 15:21:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (rb_gc_mark_locations): add safety margin 1.
+
+ * eval.c (ruby_run): should protect toplevel node tree.
+
+ * ext/etc/etc.c (etc_group): dumps core if there's no more group.
+
+Fri Jun 11 01:50:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (ruby_run): Init_stack() was called too late; local
+ variables happened to be higher (or lower) than stack_start.
+
+Thu Jun 10 16:41:48 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c: do not call `initialize' for IO objects. So with Array,
+ Hash, Range, and Time objects.
+
+ * ext/curses/curses.c (curses_getch): made thread aware using
+ rb_read_check().
+
+ * ext/curses/curses.c (window_getch): ditto.
+
+ * ext/curses/curses.c (curses_getstr): made (partially) thread
+ aware using rb_read_check().
+
+ * ext/curses/curses.c (window_getstr): ditto.
+
+ * io.c (rb_read_check): new function to help making something
+ (like extension libraries) thread aware.
+
+ * eval.c (is_defined): `defined? super' should be true even for
+ private superclass methods.
+
+Fri Jun 10 13:42:10 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * pack.c (pack_pack): template `Z' should be allowed.
+
+Wed Jun 9 13:26:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_loading): modified to avoid nested race
+ condition of require().
+
+ * ext/tcltklib/tcltklib.c (ip_invoke): queue invocation on non
+ main threads.
+
+ * ext/tcltklib/tcltklib.c (lib_mainloop): flush invocation
+ queues periodically.
+
+ * version.c (ruby_show_version): now print the message to stdout.
+
+ * version.c (ruby_show_copyright): ditto.
+
+Tue Jun 8 00:00:34 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): append sentinel (NUL) to the string.
+
+ * ext/md5/md5init.c (md5_hexdigest): new method to obtain
+ printable hash string.
+
+ * ext/md5/md5init.c (md5_update): should return self.
+
+ * pack.c (pack_pack): undocumented template 'U' for UTF8.
+
+ * pack.c (pack_unpack): ditto.
+
+ * marshal.c (r_byte): should replace getc() with rb_getc().
+
+ * io.c (rb_getc): getc() replacement uses READ_DATA_PENDING() and
+ rb_thread_wait_fd().
+
+Mon Jun 7 23:23:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_mod_clone): should call CLOSESETUP().
+
+ * eval.c (bind_clone): should call CLONESETUP() for new clone.
+
+Sat Jun 5 10:32:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_oct): binary (e.g. 0b10111) support.
+
+ * variable.c (rb_const_set): raise warning, not exception.
+
+ * parse.y (yycompile): initialize parser internal variables.
+
+ * parse.y (close_paren): set lex_state to EXPR_PAREN after closing
+ parenthesis.
+
+ * parse.y (yylex): returns kDO for `do' right after method_call.
+
+Thu Jun 3 11:05:30 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * regex.c (read_backslash): should decode \b within class.
+
+Thu Jun 3 01:06:18 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * dln.c (dln_load): AIX improvement (aix_findmain removed).
+
+Wed Jun 2 00:41:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): new undocumented template Z which strips
+ stuff after first null.
+
+ * pack.c (pack_pack): should preserve specified length of the
+ resulting string.
+
+Tue Jun 1 15:29:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (ruby_socket): retry after GC, if socket(2)
+ failed on EMFILE or ENFILE.
+
+ * ext/socket/socket.c (sock_s_socketpair): ditto.
+
+ * eval.c (module_setup): need to add PUSH_VAR/POP_VAR to clear
+ dyna vars link list.
+
+ * version.h (RUBY_RELEASE_CODE): integer macro constant for source
+ version detection.
+
+Sun May 30 22:19:12 1999 Kenji Nagasawa <kenn@tcp-ip.or.jp>
+
+ * ext/socket/socket.c: emx/gcc 0.9d now fixes things about
+ AF_UNIX.
+
+ * process.c: OS/2 EMX kludge.
+
+ * Makefile.in (strncasecmp.o): added dependency.
+
+Mon May 31 16:06:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.4 - preliminary release for 1.4
+
+Mon May 31 15:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_fptr_close): close on IO which main_thread is
+ waiting cause serious exception, that vanishes the actual fd
+ closing. Invocation of rb_thread_fd_close() is deferred
+ a little.
+
+Sat May 29 18:27:13 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * regex.c (re_match): stack boundary check needed.
+
+Sat May 29 12:27:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/tcltklib/tcltklib.c (ip_invoke): proper ref count management
+ to avoid leak. I HATE REF COUNTING!!
+
+ * eval.c (ruby_run): moved ruby_require_libraries() to handle `-r'
+ from ruby_options() to avoid stack corruption for threads
+ created in libraries.
+
+Sat May 29 02:22:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_yield_0): when `for' appeared in blocks, it
+ introduced new scope for local variables.
+
+Fri May 28 17:16:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_squeeze_bang): squeeze AND of the arguments.
+ UNDOCUMENTED.
+
+ * string.c (rb_str_count): new UNDOCUMENTED method.
+
+ * string.c (rb_str_delete_bang): delete AND of the arg ranges.
+ UNDOCUMENTED FEATURE for 1.3.x.
+
+ * ext/socket/socket.c (setipaddr): re-wrote using ip_addrsetup().
+
+ * ext/socket/socket.c (ip_addrsetup): decode symbolic address
+ <broadcast>.
+
+Thu May 27 12:27:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (tr_trans): should handle NUL (\0) within strings.
+
+Tue May 25 16:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_f_syscall): syscall may return values other than zero
+ on success.
+
+ * regex.c (re_match): handle empty loop properly (hopefully).
+
+ * regex.c (re_match): remove empty group check, because it does
+ not help non-grouping parentheses (?:..).
+
+ * regex.c (re_compile_fastmap): treating try_next, finalize_push
+ wrong way.
+
+ * regex.c: remove some obsolete functions such as
+ group_match_null_string_p().
+
+Mon May 24 14:47:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (read_backslash): read backslash by regex.
+
+Sun May 23 19:44:58 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ext/pty/pty.c (getDevice): portability patch.
+
+Fri May 21 23:01:26 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/getaddrinfo.c (GET_AI): should set error code.
+
+Thu May 20 03:43:44 1999 Jun-ichiro itojun Hagino <itojun@itojun.org>
+
+ * ext/socket/socket.c: you should use sockaddr_storage to handle
+ IPv6 addresses.
+
+ * ext/socket/getaddrinfo.c (getaddrinfo): prevent retrieving
+ AF_INET6 address if hints.ai_flags == AI_PASSIVE.
+
+Wed May 19 12:27:07 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (exec_end_proc): should protect exceptions.
+
+ * gc.c (run_final): ditto.
+
+ * parse.y (f_rest_arg): allow just * for rest arg.
+
+ * parse.y (mlhs_basic): allow * without formal argument.
+
+ * regex.c (re_match): the variable `part' should be initialized.
+
+Tue May 18 15:25:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): a bug in range adjustment.
+
+Tue May 18 11:35:59 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * dln.c (conv_to_posix_path): path_len argument added.
+
+Mon May 17 12:26:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (fix_rev): should treat Fixnum as signed long.
+
+ * eval.c (massign): add strict number check for yield (and call).
+
+ * eval.c (proc_arity): new method to return number of arguments.
+
+ * eval.c (method_arity): new method to return number of arguments.
+
+ * parse.y (read_escape): char may be unsigned.
+
+ * string.c (rb_str_succ): ditto.
+
+ * string.c (tr_trans): ditto.
+
+ * object.c (Init_Object): methods `&', `|', `^' are added to nil.
+
+ * range.c (rb_range_beg_len): it should be OK for [0..-len-1].
+
+ * regex.c (re_search): search for byte literal within mbcs.
+
+ * regex.c (is_in_list): parsh
+
+ * regex.c (re_compile_fastmap): should have not alter the loop
+ variable `j' if TRASLATE_P().
+
+ * regex.c (re_compile_pattern): escaped characters should be read
+ by PATFETCH_RAW(c).
+
+Sat May 15 11:23:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): endline2 (\Z) should not match at the point
+ between a newline and end-of-line, like endline ($).
+
+ * class.c (include_class_new): should initialize iv_tbl to share
+ between module and iclass.
+
+Fri May 14 08:50:27 1999 Akira Endo <akendo@t3.rim.or.jp>
+
+ * regex.c (re_compile_fastmap): it should be k != 0 to skip.
+
+Fri May 14 12:46:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_load): a bug in old marshal format support.
+
+ * instruby.rb: make site_ruby directory.
+
+Fri May 14 10:18:02 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * regex.c (re_match): a bug in inline `.*' etc.
+
+Fri May 14 09:58:46 1999 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
+
+ * ruby.c (addpath): should have specified string length.
+
+Thu May 13 10:40:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval_string_wrap): new function.
+
+ * regex.c (re_compile_pattern): POSIX line match should alter
+ behavior for `^' and `$' to begbuf and endbuf2 respectively.
+
+ * ext/pty/pty.c: un-ANSI-fy function arguments.
+
+Wed May 12 14:19:38 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * struct.c (iv_get): in case of inheritance of generated struct
+ class, __member__ and __size__ should also be inherited.
+ Thanks for Pros Yeboah <yeboah@tu-harburg.de>.
+
+ * io.c (rb_f_gets_internal): should check number of arguments
+ before checking rb_rs == rb_default_rs. Thanks for Koji Arai
+ <JCA02266@nifty.ne.jp>.
+
+Tue May 11 08:29:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): .?, .+ did not work.
+
+Mon May 10 00:59:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/jcode.rb: forgot to squeeze on reverse (complement) case.
+
+ * string.c (tr_squeeze): should not set modify flag to be honest,
+ if the string is not modified.
+
+ * signal.c (Init_signal): SIGTERM should not be handled.
+
+ * regex.c (re_match): seeking for longest match is now optional,
+ which can be set using RE_OPTION_POSIXMATCH. This satisfies
+ POSIX longest match as much as Emacs's posix-* functions, which
+ are known to be incomplete.
+
+Sun May 9 13:04:01 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/socket.c (sock_s_getaddrinfo): conversion from
+ Fixnums to C integers needed.
+
+Sun May 9 11:51:43 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * range.c (range_eqq): reverse condition.
+
+ * range.c (range_s_new): default should be end inclusive.
+
+Sat May 8 03:27:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (thread_connect): replace nasty
+ rb_thread_fd_writable() with rb_thread_select().
+
+Fri May 7 20:49:00 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/socket/getaddrinfo.c (inet_pton): wrong parameter to
+ inet_aton().
+
+ * ext/socket/addrinfo.h (__P): silly cut and paste typo.
+
+Fri May 7 17:03:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * dir.c (glob): removed GPL'ed glob.c completely.
+
+Fri May 7 08:17:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/sdbm/extconf.rb: sdbm extension added to the distribution.
+
+Fri May 7 01:42:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): avoid using struct
+ sockaddr_storage.
+
+Thu May 6 13:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_indexes): should not use rb_ary_concat().
+
+Thu May 4 12:34:18 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * parse.y (parse_string): there should be newline escape by
+ backslashes in strings.
+
+ * parse.y (parse_qstring): ditto.
+
+Mon May 3 04:37:20 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/tcltklib/extconf.rb: better search for libX11.
+
+ * range.c (range_s_new): embarrassing =/== typo.
+
+ * re.c (Init_Regexp): failed to set default kcode.
+
+Mon May 3 02:39:55 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ext/socket/socket.c (open_inet): typo (res and res0).
+
+Tue May 4 02:07:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * mkconfig.rb: leave undefined $(VARIABLE) unexpanded in the
+ Config::CONFIG hash table.
+
+Mon May 3 09:37:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): expand exactn{n} at compile time.
+ handles stop_paren specially.
+
+ * regex.c (re_compile_pattern): expand x{n} at compile time.
+
+ * regex.c (re_search): posix line match should be checked.
+
+ * regex.c (re_search): a bug in anchor condition.
+
+Fri Apr 30 18:57:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.3
+
+ * string.c (rb_str_rindex): position should be END point, not
+ START point.
+
+ * re.c (rb_reg_search): pos means end point on reverse now.
+
+ * array.c (rb_ary_s_create): should clear ary->ptr to avoid
+ potential gc crash.
+
+Fri Apr 30 15:24:58 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/addrinfo.h: compatibility hack for ipv4.
+
+ * ext/socket/socket.c: itojun's ipv6 patches applied.
+
+ * ext/socket/extconf.rb: detect ipv6 features based on itojun's
+ ipv6 patches.
+
+ * ext/extmk.rb.in (enable_config): can handle --enable-xxx now.
+
+ * lib/mkmf.rb (enable_config): ditto.
+
+Fri Apr 30 05:22:23 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * string.c (rb_str_aset): last index should not append.
+
+Thu Apr 29 18:55:31 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * dln.c (conv_to_posix_path): remove const from args.
+
+ * ruby.c (rubylib_mangle): remove Fatal(), the obsolete function.
+
+Tue Apr 27 14:11:45 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (fname): lazy workaround for keywords did not work well.
+
+ * ext/extmk.rb.in: `--with-xxx=yyy' argument configuration.
+
+ * lib/mkmf.rb: ditto.
+
+ * misc/ruby-mode.el: forgot to handle $`.
+
+ * ext/extmk.rb.in: better AIX link support proposed by
+ <komatsu@sarion.co.jp>.
+
+Mon Apr 26 16:46:59 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/extmk.rb.in: AIX shared library support modified.
+
+ * ext/aix_mksym.rb: ditto.
+
+ * configure.in: ditto.
+
+ * sprintf.c (rb_f_sprintf): should allocate proper sized buffer
+ for float numbers.
+
+Sat Apr 24 00:00:16 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (operation): syntax like `a.[]=(1,2)' is allowed.
+
+Fri Apr 23 23:54:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (argf_binmode): binmode method added to ARGF.
+
+Fri Apr 23 13:55:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_f_chomp): should assign the result to $_. or maybe
+ sub/gsub/chop/chomp should NOT assign $_ altogether.
+
+Thu Apr 22 16:50:54 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_callcc): call scope_dup() for all scopes in
+ the interpreter stack.
+
+Tue Apr 20 11:24:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_dump): `#' should be escaped.
+
+Tue Apr 20 02:32:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_regx): option /p for posix match added.
+
+ * re.c (rb_reg_desc): did not print options properly.
+
+ * io.c (rb_file_s_open): initialize was called twice.
+
+Mon Apr 19 18:56:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * configure.in (DEFAULT_KCODE): can specify default code for
+ $KCODE by --with-default-kcode=(euc|sjis|utf8|none).
+
+ * regex.c (IS_A_LETTER): a byte sequence shorter than mbc should
+ not match with \w etc.
+
+Mon Apr 19 13:49:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (eval): should restore ruby_dyna_vars.
+
+Fri Apr 16 21:40:43 1999 Nobuyoshi Nakada <gea02117@nifty.ne.jp>
+
+ * io.c (f_backquote): pipe_open may return nil.
+
+ * io.c (f_open): rb_io_open may return nil.
+
+ * io.c (io_s_foreach): ditto.
+
+ * io.c (io_s_readlines): ditto.
+
+ * io.c (io_defset): wrong message.
+
+Fri Apr 16 15:09:20 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (rb_str2inum): strtoul() returns long, not int.
+
+ * eval.c (rb_load): size of VALUE and ID may be different.
+
+ * util.c (mmprepare): int is too small to cast from pointers.
+
+ * config.guess: avoid 'linux-gnu' for alpha-unknown-linux.
+
+Thu Apr 15 23:46:20 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.c (rubylib_mangle): mangle path by RUBYLIB_PREFIX.
+
+Wed Apr 14 23:52:51 1999 SHIROYAMA Takayuki <psi@fortune.nest.or.jp>
+
+ * node.h (NODE_LMASK): should be long to avoid overflow.
+
+Wed Apr 14 13:14:35 1999 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * dln.c: AIX dynamic link.
+
+ * ext/aix_ld.rb: ditto.
+
+Wed Apr 14 12:19:09 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/thread.rb: Queue#{enq,deq} added.
+
+Tue Apr 13 17:43:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_s_create): Hash::[] acts more like casting.
+
+Tue Apr 13 00:33:52 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_stdio_set): warning for assignment to the variables
+ $std{in,out,err}.
+
+Mon Apr 12 23:12:32 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_reopen): check for reopening same IO.
+
+Fri Apr 9 17:45:11 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (rb_compile_string): bug for nested eval().
+
+ * regex.c (re_match): should pop non-greedy stack items on
+ failure, after best_regs are fixed.
+
+Thu Apr 8 17:30:40 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (PACK_LENGTH_ADJUST): need to adjust for `*' length.
+
+Tue Apr 6 23:28:44 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (void_check): add void context checks.
+
+Mon Apr 5 12:23:42 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_s_at): should copy gmt-mode.
+
+ * eval.c (eval_node): preserve ruby_eval_tree.
+
+Fri Apr 2 14:00:34 1999 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/debug.rb: wrong command interpreting.
+
+Fri Apr 2 11:46:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.3.2
+
+Fri Apr 2 10:40:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_s_pipe): forgot to define IO::pipe.
+
+Thu Apr 1 14:40:46 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (assign): modified for rhs change.
+
+ * parse.y (stmt): unparenthesisized method calls can be right hand
+ side expression of the assignment.
+
+Sat Mar 27 22:42:47 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/nkf/nkf.c (rb_nkf_kconv): check size output_ctr before
+ decrement.
+
+Thu Mar 25 09:11:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_s_at): preserve gmt-mode for result.
+
+ * parse.y (rb_compile_string): do not use cur_mid, use
+ compile_for_eval instead.
+
+ * st.c (PTR_NOT_EQUAL): wrong logical condition.
+
+Wed Mar 24 13:06:43 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yycompile): should clear cur_mid after compilation.
+
+ * io.c (next_argv): need to check type for ARGV.shift.
+
+ * eval.c (blk_copy_prev): need to preserve outer scope as well as
+ outer frames.
+
+ * parse.y (rb_compile_string): return can appear within eval().
+
+Tue Mar 23 10:15:07 1999 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * configure.in: AC_C_CONST check added.
+
+Tue Mar 23 02:07:35 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_plus): preserve gmt-mode for result.
+
+Mon Mar 22 01:32:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): adjust line numbers before expression
+ interpolation within strings.
+
+ * eval.c (rb_eval): defined? returns nil for false condition.
+
+ * numeric.c (num_nonzero_p): returns nil for false condition.
+
+Sat Mar 20 13:07:43 1999 Keiju Ishitsuka <keiju@rational.com>
+
+ * lib/weakref.rb: avoid leak for two weakrefs for one object.
+
+Fri Mar 19 11:26:45 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * eval.c (ruby_run): needed to eval END{} on exit.
+
+ * eval.c (rb_exit): ditto.
+
+Fri Mar 19 02:17:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * signal.c (Init_signal): handles terminating signals HUP, TERM,
+ QUIT, PIPE, etc.
+
+Thu Mar 18 15:47:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (rb_big_and): bug in sign calculation.
+
+ * bignum.c (rb_big_or): ditto.
+
+ * io.c (rb_f_select): forgot to use to_io to retrieve IO, after
+ calling select(2).
+
+Tue Mar 16 19:54:31 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/extmk.rb.in: static linking cause infinite make loop.
+
+Tue Mar 16 18:50:04 1999 Yoshida Masato <yoshidam@yoshidam.net>
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): typo, not NUM2INT(),
+ but INT2NUM().
+
+ * ext/socket/socket.c (mkhostent): ditto.
+
+Tue Mar 16 12:31:44 1999 Ryo HAYASAKA <hayasaka@cheer.u-aizu.ac.jp>
+
+ * file.c (utime_internal): suppress warning by const.
+
+ * time.c (time_gmtime): ditto.
+
+Tue Mar 16 10:23:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_clone): Time object can be cloned.
+
+Tue Mar 16 03:13:10 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ruby.c (load_file): argv[argc] should be NULL.
+
+Mon Mar 15 22:12:08 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * sprintf.c (rb_f_sprintf): typo in arg_num check at exit.
+
+Mon Mar 15 16:42:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_dup): dup2 should copy class too.
+
+Mon Mar 15 15:12:53 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * lib/mkmf.rb: install program relative path check.
+
+Mon Mar 15 14:05:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_s_new): 2nd argument is now option.
+ Regexp::EXTENDED can be specified.
+
+Fri Mar 12 10:47:49 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_index): str.index("") should always match at
+ offset point.
+
+ * string.c (rb_str_upto): can specify end point exclusion.
+
+ * string.c (rb_str_index): negative offset.
+
+ * regex.c (re_match): begline should not match at the point
+ between a newline and end-of-string. endline neither.
+
+ * regex.c (re_compile_pattern): context_indep_anchors .
+
+ * parse.y (parse_regx): need not to push backslashes before
+ escaped characters.
+
+ * eval.c (rb_thread_join): re-raises exception within target.
+
+Fri Mar 12 01:09:36 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * ext/readline/readline.c (readline_s_vi_editing_mode): wrong
+ number of arguments.
+
+Fri Mar 12 02:12:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (PACK_ITEM_ADJUST): "a".unpack("C3") => [97, nil, nil]
+
+Thu Mar 11 18:23:50 1999 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ext/socket/socket.c (Init_socket): UDPsocket was omitted.
+
+Thu Mar 11 16:43:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (PACK_LENGTH_ADJUST): push fixed number of items per
+ template to result array.
+
+ * pack.c (pack_unpack): I/N/C etc. push nil in the array for "".
+
+Tue Mar 9 00:19:21 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (ruby_unsetenv): use ruby_setenv(name, 0).
+
+ * hash.c (env_delete): ditto.
+
+ * string.c (rb_str_upto): do not check `beg<end' to generate
+ strings for the pattern like "a".upto("#a").
+
+ * range.c (range_each): treat strings as special case.
+
+ * range.c (range_each): no longer use upto for generic cases.
+
+Sun Mar 7 14:21:32 1999 IKARASHI Akira <ikarashi@itlb.te.noda.sut.ac.jp>
+
+ * string.c (rb_str_index): wrong end point calculation.
+
+Sat Mar 6 02:19:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (match_index): MatchingData#index(n) added.
+
+ * array.c (rb_ary_subseq): ary[n..-1] returns an sub-array unless
+ n is too small negative index.
+
+ * re.c (rb_reg_match_method): Regexp#match(str) added.
+
+ * array.c (rb_ary_indexes): understands ranges as indexes.
+
+ * re.c (match_size): MatchingData#size added.
+
+Fri Mar 5 01:04:57 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_fill): modified for range.
+
+ * array.c (rb_ary_aset): a[n..m] revisited.
+
+Thu Mar 4 14:23:29 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_subseq): a[n..m] revisited.
+
+ * parse.y (method_call): allow Const::method{}.
+
+ * array.c (rb_ary_replace_method): should replace original array.
+
+Thu Mar 4 02:30:22 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * configure.in: remove --disable-thread, thread feature is no
+ longer optional.
+
+Thu Mar 4 00:32:17 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * parse.y (read_escape): wrong arguments for scan_oct,scan_hex.
+
+Wed Mar 3 11:51:53 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (Init_socket): rename class names as
+ TCPsocket -> TCPSocket etc.
+
+Tue Mar 2 19:46:42 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * configure.in (LDSHARED): use gcc -Wl,-G for solaris with gcc.
+
+Tue Mar 2 17:04:19 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): backslashes do not concatenate comment lines
+ anymore.
+
+Mon Mar 1 14:05:12 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_call0): adjust argv for optional arguments. super
+ without arguments emit superclass method with the value from
+ optional arguments. enabled as experiment.
+
+Sun Feb 28 14:04:07 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * parse.y (nextc): backslash at the eof cause infinite loop
+
+Sun Feb 28 11:01:26 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * time.c (make_time_t): month range check added.
+
+Sat Feb 27 02:36:05 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (Init_Regexp): add escape as alias of quote.
+
+ * re.c (rb_reg_s_quote): char-code can be specified now.
+
+Fri Feb 26 18:45:36 1999 Yasuhiro Fukuma <yasuf@big.or.jp>
+
+ * eval.c (error_print): bug for error message with newlines.
+
+Fri Feb 26 12:00:04 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (make_time_t): future check modified to allow 1969-12-31
+ at certain timezone.
+
+ * time.c (time_arg): year >= 1000 should be past.
+
+ * version.c (Init_version): constant RELEASE_DATE added.
+
+Fri Feb 26 01:08:30 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_substr): returns nil for out-of-range access.
+
+ * array.c (rb_ary_subseq): returns nil for out-of-range access.
+
+ * array.c (rb_ary_store): negative index message has changed.
+
+ * string.c (rb_str_aset): reallocation needed.
+
+ * string.c (rb_str_aset): allow char append to the string.
+
+Thu Feb 25 23:30:17 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * time.c (time_load): tm_year should be packed in 17 bits, not 18.
+
+Thu Feb 25 12:50:25 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * missing/dup2.c: replaced by public domain version.
+
+ * time.c (make_time_t): add `future check' in loops.
+
+ * object.c (rb_num2dbl): forbid implicit conversion from nil, or
+ strings. thus `Time.now + str' should raise error.
+
+ * object.c (rb_Float): convert nil into 0.0.
+
+ * object.c (rb_Integer): conversion method improved.
+
+Thu Feb 25 03:27:50 1999 Shugo Maeda <shugo@netlab.co.jp>
+
+ * eval.c (rb_call): should handle T_ICLASS properly.
+
+Thu Feb 25 00:04:00 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (Init_Exception): global function Exception() removed.
+
+ * variable.c (rb_class2name): returns "nil"/"true"/"false" for them.
+
+ * time.c (time_dump): time marshaling format compressed size from
+ 11 bytes to 8 bytes. thanx to tadf@kt.rim.or.jp.
+
+ * eval.c (rb_obj_call_init): should specify arguments explicitly.
+
+Wed Feb 24 15:43:28 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): comment concatenation requires preceding space
+ before backslash at the end of line.
+
+ * io.c (rb_f_pipe): global pipe is obsolete now.
+
+ * object.c (Init_Object): remove true.to_i, false.to_i.
+
+Tue Feb 23 14:21:41 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): warn if identifier! immediately followed by `='.
+
+Tue Feb 23 12:32:41 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * eval.c (rb_load): tilde expansion moved to find_file.
+
+ * eval.c (find_file): tilde expansion 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): negative length raises exception now.
+
+ * array.c (beg_len): if end == -1, it points end of the array.
+
+ * array.c (rb_ary_subseq): negative length raises exception now.
+
+Thu Feb 18 20:57:04 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * time.c (rb_strftime): strftime() may return 0 on success too.
+
+ * time.c (time_strftime): `\0' within format string should not be
+ omitted 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 omitted.
+
+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
+ isinf, 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): accessing $~ 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 support
+ 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 realloc 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 class. 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.
+
+ * ruby.c (load_file): define DATA if __END__ appeared in script.
+
+Tue Jan 19 14:57:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): need to protect lex_lastline.
+
+ * parse.y (yylex): disable %//, %'', %``.
+
+Tue Jan 19 05:01:16 1999 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * array.c (beg_len): round range value too much.
+
+Mon Jan 18 13:02:27 1999 Kuroda Jun <jkuro@dwe.co.jp>
+
+ * hash.c (env_keys): strchr() may return NULL.
+
+Mon Jan 18 17:51:47 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * instruby.rb (wdir): install libruby.a in archdir.
+
+ * lib/ftools.rb (install): removes file before installing.
+
+Mon Jan 18 16:55:31 1999 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * eval.c (rb_callcc): experimental continuation support.
+
+Sun Jan 17 19:45:37 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * pack.c (pack_pack): nil packing caused SEGV.
+
+Sat Jan 16 13:18:03 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_concat): character (fixnum) can be append to
+ strings
+
+ * array.c (rb_ary_unshift): unshift returns array.
+
+Sat Jan 16 01:39:19 1999 Yoshida Masato <yoshidam@tau.bekkoame.ne.jp>
+
+ * string.c (rb_str_split_method): UTF-8 support.
+
+ * regex.c: UTF-8 support.
+
+Thu Jan 14 00:42:55 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_gsub_bang): forget to add offset for null match.
+
+ * eval.c (rb_thread_local_aset): can't modify in tainted mode.
+
+ * hash.c (env_each_key): avoid generating temporary array.
+
+Wed Jan 13 23:58:50 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_f_setenv): name and value can be tainted.
+
+Wed Jan 6 02:42:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (Init_Bignum): forgot to define Bignum#===.
+
+ * gc.c (gc_sweep): if add_heap() is called during GC, objects on
+ allocated heap page(s) are not marked, should not be recycled.
+
+ * gc.c (gc_sweep): should refer latest freelist.
+
+ * gc.c (id2ref): modified to support performance patch.
+
+ * object.c (rb_obj_id): performance patch (no bignum for id).
+
+Tue Jan 5 01:56:18 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * config.guess: merge up-to-date from autoconf 2.12.
+
+ * array.c (rb_ary_join): avoid calling rb_protect_inspect() till
+ it is really needed.
+
+ * object.c (rb_obj_inspect): show detailed information for the
+ instance variables (infinite loop can avoid now).
+
+ * struct.c (rb_struct_inspect): avoid infinite loop.
+
+Sun Jan 3 01:37:58 1999 Takao KAWAMURA <kawamura@ike.tottori-u.ac.jp>
+
+ * misc/ruby-mode.el (ruby-end-of-defun): moved too much.
+
+ * misc/ruby-mode.el (ruby-mode-variables): set paragraph-separator
+ for the mode.
+
+ * misc/ruby-mode.el: proper font-lock for `def' and `nil' etc.
+
+Sat Jan 2 17:09:06 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_jump_tag): new api to invoke JUMP_TAG. tag values
+ can obtained from rb_eval_string_protect()/rb_load_protect().
+
+ * eval.c (rb_rescue): now catches all exceptions but SystemExit.
+
+ * eval.c (rb_eval_string_protect): eval string with protection.
+
+ * eval.c (rb_load_protect): load file with protection.
+
+ * io.c (rb_io_puts): avoid infinite loop for cyclic arrays.
+
+ * eval.c (rb_thread_local_aref): thread local hash tables.
+
+ * object.c (rb_equal): check exact equal before calling `=='.
+
+Thu Dec 31 22:28:53 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * eval.c (rb_f_require): feature names should be provided with
+ DLEXT extension.
+
+ * marshal.c (Init_marshal): need to provide `marshal.so'.
+
+Wed Dec 30 02:29:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (classname): do not call rb_ivar_set().
+
+ * eval.c (ruby_run): finalizers were called too early.
+
+Fri Dec 25 12:19:30 1998 Fukuda Masaki <fukuda@wni.co.jp>
+
+ * gc.c (rb_gc_mark): should not return on FL_EXIVAR.
+
+Fri Dec 25 11:56:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (gc_mark): proper scanning for temporary region.
+
+ * eval.c (TMP_ALLOC): protection for C_ALLOCA was broken.
+
+Thu Dec 24 18:26:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * development version 1.3 released.
+
+Thu Dec 24 00:17:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_load): top self should be set properly.
+
+ * variable.c (classname): check __classpath__ if it is defined.
+
+ * variable.c (classname): invalid warning at -v with static linked
+ ruby interpreter.
+
+ * eval.c (is_defined): modified for expr::Const support.
+
+ * eval.c (rb_eval): invoke method expr::Const if expr is not class
+ nor module.
+
+ * parse.y (primary): enable expr::identifier as method
+ invocation.
+
+Wed Dec 23 03:04:36 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): avoid too many loop pops for (?:..).
+
+Tue Dec 22 18:01:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental version 1.1d1 released.
+
+Mon Dec 21 01:33:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (TMP_PROTECT): add volatile to ensure GC protection.
+
+ * string.c (rb_str_gsub_bang): calculate buffer size properly.
+
+ * parse.y (lex_get_str): needed to return Qnil at EOS.
+
+ * eval.c (find_file): check policy modified, raise exception
+ immediately for tainted load_path.
+
+ * hash.c (rb_f_setenv): do not depend on setenv() nor putenv().
+
+Thu Dec 17 06:29:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/tk/tkutil.c (tk_s_new): use rb_obj_instance_eval(), instead
+ of rb_yield_0().
+
+ * eval.c (rb_f_require): forgot to call find_file in some cases.
+
+ * eval.c (rb_f_require): `require "feature.so"' to load dynamic
+ libraries. old `require "feature.o"' is still OK.
+
+ * eval.c (rb_eval): yield without value dumped core.
+
+Wed Dec 16 16:28:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental version 1.1d0 (pre1.2) released.
+
+Wed Dec 16 10:43:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): bound check before calling re_match().
+
+Tue Dec 15 13:59:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (exc_to_s): returns class name for unset mesg.
+
+ * error.c (exc_initialize): do not initialize @mesg by "".
+
+ * parse.y (nextc): __END__ should handle CR+LF newlines.
+
+Wed Dec 9 13:37:12 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * pack.c (encodes): use buffering for B-encoding.
+
+ * pack.c (pack_pack): Q-encoding by 'M'.
+
+Tue Dec 8 14:10:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (generic_ivar_get): any object can have instance
+ variables now. great improvement.
+
+ * variable.c (rb_name_class): do not set __classpath__ by default,
+ use __classid__ instead.
+
+Mon Dec 7 22:08:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (struct RFile): IO objects can have instance variables now.
+
+ * parse.y (primary): allows `def obj::foo; .. end'.
+
+Mon Dec 7 18:24:50 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ruby.c (set_arg0): $0 support for HP-UX.
+
+Mon Dec 7 01:30:28 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * dln.c (dln_strerror): better error messages on win32.
+
+Sat Dec 5 23:27:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): indentable here-doc delimiter by
+ `<<-'. Proposed by Clemens <c.hintze@gmx.net>. Thanks.
+
+Thu Dec 3 16:50:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/extmk.rb.in (realclean): trouble on install.
+
+Sun Nov 29 22:25:39 1998 Takaaki Tateishi <ttate@jaist.ac.jp>
+
+ * process.c (f_exec): check number of argument.
+
+Thu Nov 26 17:27:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c9 released.
+
+Wed Nov 25 13:07:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_dup): do not copy additional data (STR_NO_ORIG).
+
+ * parse.y (yycompile): reduce known memory leak (hard to remove).
+
+Wed Nov 25 03:41:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * st.c (st_init_table_with_size): round size up to prime number.
+
+Sat Nov 21 23:27:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (rb_hash_aset): reduce copying key strings.
+
+ * gc.c (looks_pointerp): declare as inline function if possible.
+
+ * st.c (PTR_NOT_EQUAL): compare hash values first before calling
+ comparing function.
+
+ * st.c (ADD_DIRECT): save hash value in entries to reduce hash
+ calculation.
+
+ * string.c (rb_str_gsub_bang): avoid rb_scan_args() to speed-up.
+
+ * string.c (rb_str_sub_bang): ditto.
+
+Sat Nov 21 18:44:06 1998 Masaki Fukushima <fukusima@goto.info.waseda.ac.jp>
+
+ * time.c (time_s_now): had memory leak.
+
+ * ext/md5/md5init.c (md5_new): had memory leak.
+
+ * ext/md5/md5init.c (md5_clone): ditto.
+
+Fri Nov 20 23:23:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/delegate.rb: do not propagate hash and eql?.
+
+Thu Nov 19 01:40:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/ruby-mode.el (ruby-expr-beg): failed to find reserved
+ word boundary.
+
+ * eval.c (rb_eval): avoid calling `concat' method. calls
+ rb_ary_concat() directly for efficiency.
+
+ * eval.c (rb_eval): actual rest arguments extended arrays too much.
+
+Wed Nov 18 14:30:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (rb_define_global_function): global functions now be
+ module function of the Kernel.
+
+Wed Nov 18 10:48:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (read_all): SEGV on large files.
+
+Tue Nov 17 18:11:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c8 released.
+
+Tue Nov 17 16:58:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg): assignment to attribute name start with capital
+ should be allowed.
+
+ * eval.c (thread_alloc): needed to mark terminated threads too.
+
+Tue Nov 17 12:33:48 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * ext/extmk.rb.in (create_makefile): Set `libdir' to `@libdir@',
+ Set `pkglibdir' to `$libdir/$(RUBY_INSTALL_NAME)'.
+
+Tue Nov 17 10:30:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (f_sprintf): %l%%c -> %%l%c
+
+Tue Nov 17 01:08:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (ret_args): distinguish `a' and `*a' for the arguments
+ of yield and return.
+
+ * eval.c (rb_eval): flip3 should work like sed.
+
+ * eval.c (rb_eval): flip{2,3} now have independent state for each
+ scope to work fine with thread.
+
+Mon Nov 16 23:26:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (primary): exec else clause if no exception raised.
+
+Sun Nov 15 15:44:07 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * ext/extmk.rb.in (install): bug in target.
+
+Sat Nov 14 11:02:05 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * Makefile.in (install): Give the argument `$(DESTDIR)' to
+ `instruby.rb'.
+
+ * instruby.rb: Recognize ARG[0] as `destdir'.
+
+ * instruby.rb: Give the argument `destdir' to `extmk.rb'.
+
+ * ext/extmk.rb.in: Recognize ARG[1] as `$destdir'.
+
+ * instruby.rb: Create the installation directories (bindir, libdir,
+ archdir, pkglibdir, archdir, and mandir) under `destdir', and
+ install all files under there.
+
+ * ext/extmk.rb.in: Likewise.
+
+Sat Nov 14 10:56:55 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * instruby.rb: Add the variable `pkglibdir'.
+
+ * instruby.rb: Set the variable `libdir' to `$(libdir)', not
+ `$(libdir)/$(ruby_install_name)'. `libruby.so' and `libruby.so.LIB'
+ are installed at `libdir'.
+
+ * instruby.rb: Set the variable `archdir' to `$(pkglibdir)/$(arch)'.
+
+Fri Nov 13 19:43:29 1998 KIMURA Koichi <kbk@kt.rim.or.jp>
+
+ * missing/nt.c (SafeFree): wrong free offset.
+
+Thu Nov 12 20:11:53 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * sample/ruby-mode.el: wrong highlight.
+
+ * parse.y (parse_regx): newline in regexp was ignored.
+
+Wed Nov 11 10:54:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): <<'FOO' should not escape anything.
+
+ * parse.y (here_document): bare << here-doc available, even though
+ it's deprecated.
+
+ * file.c (rb_file_s_readlink): return value should be tainted.
+
+ * ext/etc/etc.c (setup_passwd): information (eg. GCOS name) should
+ be tainted (modified at Perl Conference).
+
+Tue Nov 10 00:22:11 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * configure.in: elf support for FreeBSD 3.x
+
+Tue Nov 10 00:05:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): here document available in eval.
+
+Mon Nov 9 17:55:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c7 released.
+
+Fri Nov 6 19:25:27 1998 Takao KAWAMURA <kawamura@ike.tottori-u.ac.jp>
+
+ * sample/ruby-mode.el: font-lock patch.
+
+Thu Nov 5 15:42:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/README, lib/README: simple description for each file.
+
+Wed Nov 4 18:14:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (assign): attribute assignment should be called as public.
+
+Tue Nov 3 23:36:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_dump): dumps core for negative char value.
+
+ * regex.c (re_compile_pattern): out of boundary access for empty
+ regexp.
+
+Mon Nov 2 22:54:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_aset): `str[str]' replaces first match.
+
+Mon Nov 2 18:24:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_create): was accessing modified status.
+
+Sun Nov 1 01:18:52 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * gc.c (xrealloc): size 0 needs round up to 1.
+
+Sat Oct 31 23:18:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_split_method): negative LIMIT means number of
+ split fields are unlimited, as in perl.
+
+ * string.c (rb_str_split_method): if LIMIT is unspecified,
+ trailing null fields are stripped.
+
+Sat Oct 31 04:16:14 1998 Inaba Hiroto <inaba@st.rim.or.jp>
+
+ * string.c (str_aref): regexp index SEGVed.
+
+Fri Oct 30 14:33:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_match): returns nil for unmatch.
+
+ * dir.c (dir_entries): new method.
+
+ * eval.c (block_pass): do not push block, substitute it.
+
+Fri Oct 30 01:28:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * range.c (range_check): avoid <=> check for Fixnums.
+
+ * array.c (rb_ary_aset): accept negative index.
+
+Wed Oct 28 22:00:54 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): access out of boundary fixed.
+
+Wed Oct 28 11:37:42 1998 TAMITO <tommy@valley.ne.jp>
+
+ * io.c (f_select): fd number comparison bug.
+
+Tue Oct 27 23:07:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/ruby-mode.el (ruby-parse-region): forgot to support %w()
+ style array literal.
+
+ * eval.c (rb_eval): unused block raises warning.
+
+Mon Oct 26 09:37:53 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (dvar_asgn_push): dvar pushed too many times if
+ variable-in-block first appear in loops.
+
+Sun Oct 25 22:59:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (set_list_bits): was using wrong offset.
+
+Thu Oct 22 00:07:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_obj_method): method retrieved from tainted object
+ should be tainted too.
+
+ * eval.c (method_call): safe_level should be restored during
+ Method#call.
+
+Wed Oct 21 14:21:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (Init_IO): new constants IO::SEEK_{SET,CUR,END}.
+
+ * io.c (rb_f_ungetc): ungetc pushes a char back into STDIN.
+
+Mon Oct 19 11:50:00 1998 Motoyuki Kasahara <m-kasahr@sra.co.jp>
+
+ * ext/extmk.rb: Load '@top_srcdir@/lib/find.rb', not
+ '../lib/find.rb'.
+
+ * ext/extmk.rb: Distinguish between `top_srcdir' and `topdir'.
+
+ * Makefile.in (CFLAGS): Add `-I.'.
+
+ * Makefile.in (lex.c): Give `@srcdir@/keywords' to gperf, not
+ `keywords'.
+
+ * instruby.rb: Use `CONFIG["bindir"]', instead of `prefix + "/bin"'.
+
+ * instruby.rb: Use `CONFIG["libdir"]', instead of `prefix + "/lib"'.
+
+ * instruby.rb Use `CONFIG["mandir"]', instead of `prefix + "/man"'.
+
+ * instruby.rb (wdir): Add the variable to preserve the current
+ working directory.
+
+ * instruby.rb: Chdir to wdir before install `config.h' and
+ `rbconfig.rb'.
+
+Mon Oct 19 10:07:01 1998 EGUCHI Osamu <eguchi@shizuokanet.ne.jp>
+
+ * eval.c (rb_eval): reduce recursive calls to rb_eval().
+
+Fri Oct 16 15:31:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_new_internal): timeval must be positive.
+
+Thu Oct 15 13:54:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg): local variables can be accessed within right side
+ expression in assignment, notably in blocks.
+
+Wed Oct 14 00:18:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (Init_Array): Array#=== is now for equal check, not
+ inclusion check.
+
+ * parse.y (when_args): `when a, *b' style new syntax for array
+ expansion in `case'.
+
+Tue Oct 13 14:30:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_obj_untaint): taint marks can be unset.
+
+ * eval.c (rb_eval): taint propagation for embedded strings.
+
+Mon Oct 12 13:27:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_call0): check stack depth more frequently.
+
+Mon Oct 12 08:08:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_p): can print even in secure mode.
+
+Sun Oct 11 22:50:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_const_set): taint check for modification.
+
+ * variable.c (rb_ivar_set): taint check for modification.
+
+ * string.c (rb_str_modify): taint check for modification.
+
+ * hash.c (rb_hash_modify): taint check for modification.
+
+ * array.c (rb_ary_modify): taint check for modification.
+
+ * ruby.h (FL_TAINT): taint for all objects, not only strings.
+
+Fri Oct 9 17:01:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (read_all): read() returns "" at immediate EOF.
+
+ * io.c (io_read): read(nil) read all until EOF.
+
+Thu Oct 8 13:32:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_dump): marshal can dump Time object now.
+
+ * marshal.c (Init_marshal): rename marshal methods `_dump_to' to
+ `_dump', `_load_from' to `_load'.
+
+ * parse.y (rb_intern): "+=".intern generates proper symbol.
+
+Mon Oct 5 18:31:53 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c6 released.
+
+Fri Oct 2 14:22:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): `/\s*(--)$/ =~ "- --"' did not match,
+ because of wrong optimize condition.
+
+Mon Oct 1 01:55:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (rb_intern): should not raise exceptions.
+
+ * parse.y (yylex): symbol like `:foo?=' should not be allowed.
+
+ * ext/extmk.rb.in: makes *.a for static link modules.
+
+Wed Sep 30 14:13:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_start): supports making a subclass of the
+ Thread class.
+
+Tue Sep 29 17:46:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_thread_join): join is now an instance method.
+
+Fri Sep 25 12:01:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): `@foo!' should be an error.
+
+Thu Sep 24 14:55:06 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * ext/etc/etc.c (Init_etc): wrong field definition.
+
+Thu Sep 17 17:09:05 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_reopen): was creating FILE* for wrong fd.
+
+Tue Sep 15 05:28:11 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * regex.c (re_compile_pattern): forgot to fixup for the pattern
+ like (?=(A)|(B)).
+
+Tue Sep 15 01:06:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_gets_internal): do not set $_ by default, only
+ gets/readline set the variable.
+
+ * eval.c (rb_f_load): load toplevel class is set to anonymous
+ module if safe_level >= 5, to encapsulate modification.
+
+ * eval.c (rb_f_load): set frame properly.
+
+ * string.c (rb_str_each_line): do not set $_.
+
+Mon Sep 14 14:42:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): beginning and end of the string, do not
+ automatically match `\b'.
+
+ * string.c (scan_once): consume at least on character.
+
+ * regex.c (re_search): wrong behavior for negative range.
+
+Sat Sep 12 21:21:26 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * regex.c (re_search): range value should be maintained.
+
+Thu Sep 10 10:55:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (backref_error): yyerror does not understand formats.
+
+Tue Sep 8 18:05:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c5 released.
+
+Tue Sep 8 10:03:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_each_line): wrong line splitting with newline at
+ top of the string.
+
+ * string.c: non bang methods return copied string.
+
+ * eval.c (f_END): needed to initialize frame->argc;
+
+Fri Sep 4 11:27:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (bigadd): proper sign combination.
+
+ * regex.c (re_search): wrong return value for \A.
+
+Thu Sep 3 14:08:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c4 released.
+
+Tue Sep 1 10:47:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (slow_search): do not compare llen and blen. llen may
+ be longer than blen, if little contains 0xff.
+
+ * regex.c (mbctab_euc): set 0x8e as multibyte character.
+
+ * string.c (str_inspect): mask character for octal output.
+
+Mon Aug 31 15:32:41 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): use calculated offset if exactn is the
+ first opcode in the compiled regexp.
+
+ * regex.c (bm_search): use Boyer-Moore search for simple search.
+
+ * regex.c (must_instr): wrong length check if pattern includes
+ byte escape by 0xff.
+
+ * regex.c (re_compile_pattern): need not to check current_mbctype.
+
+Sat Aug 29 16:31:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_check_safe_str): avoid calling rb_id2name() in normal
+ cases to speed-up.
+
+ * eval.c (thread_raise): do not save context of terminated thread.
+
+ * regex.c (re_compile_pattern): mask \nnn over 256.
+
+Sat Aug 29 02:09:46 1998 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * sprintf.c (f_sprintf): wrong buffer size check.
+
+Fri Aug 28 01:57:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): accepts (?ix-ix) and (?ix-ix:...).
+
+Fri Aug 28 12:25:33 1998 Hiroshi Igarashi <igarashi@ueda.info.waseda.ac.jp>
+
+ * ruby.c (ruby_require_modules): load modules in appearing order.
+
+Fri Aug 28 01:57:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): accepts (?ix-ix) and (?ix-ix:...).
+
+Thu Aug 27 12:54:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c3 released.
+
+Wed Aug 26 14:40:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): check whether ruby_class is properly set,
+ before accessing it.
+
+ * eval.c (rb_obj_instance_eval): ruby_class should be Qnil for
+ special objects like Fixnums.
+
+ * ext/tkutil/tkutil.c (Init_tkutil): removes calls to
+ rb_yield_0(). used instance_eval() instead in the tk.rb.
+
+Wed Aug 26 11:47:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): pop non-greedy stack elements on success.
+
+Wed Aug 26 09:25:35 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.h: add #define environ for cygwin32.
+
+Tue Aug 25 08:57:41 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (rb_ary_sort_bang): temporarily freeze sorting array.
+
+Mon Aug 24 18:46:44 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * dln.c (dln_find_1): path check was too strict.
+
+Mon Aug 24 15:28:11 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * parse.y (f_arglist): opt_nl added after f_args.
+
+Fri Aug 21 01:06:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c: grand renaming on socket.c.
+
+ * ext/socket/socket.c (inet_aton): supply inet_aton for those
+ systems that do not have it.
+
+ * ext/socket/socket.c (setipaddr): use inet_aton instead of
+ inet_addr.
+
+ * ext/socket/socket.c (tcp_s_gethostbyname): new method: works
+ like Socket.gethostbyname but returning array contains ip-addrs
+ as octet decimal string format like "127.0.0.1".
+
+ * ext/socket/socket.c (mkhostent): return format changed to
+ [host, aliases, type, ipaddr..] as documented.
+
+Wed Aug 19 00:31:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_ctl): forgot to place TRAP_END at right position.
+
+Fri Aug 14 11:01:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (call_trace_func): save __FILE__, __LINE__ before
+ executing trace_func, since trace function should not corrupt
+ line number information.
+
+Thu Aug 13 15:09:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_s_new): was marking unallocated region on GC.
+
+Tue Aug 11 11:57:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c2 released.
+
+Mon Aug 10 14:05:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * process.c (f_system): removed fflush(stdin).
+
+Fri Aug 7 17:44:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (err_snprintf): replace sprintf for fixed sized buffer,
+ with snprintf to avoid buffer over-run. For systems which does
+ dot provide snprintf, missing/snprintf.c added.
+
+Wed Aug 5 00:47:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (rb_reg_search): recycle match object.
+
+Mon Aug 3 09:17:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (rb_str_gsub_bang): do not allocate temporary string.
+
+ * string.c (rb_str_sub_bang): use inline replace.
+
+Wed Jul 29 00:36:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_s_new): the default value can be specified.
+
+ * hash.c (hash_default): method to set the default value.
+
+ * hash.c (hash_aref): now returns the default value.
+
+Tue Jul 28 13:03:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_s_new): argument to specify initial value is added.
+
+ * array.c (ary_s_new): specifies size, not capacity.
+
+Mon Jul 27 12:39:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_replace): zero fill for expansion gap.
+
+ * regex.c (mbctab_euc): set flags on for 0xA1-0xFE. suggested by
+ <inaba@st.rim.or.jp>.
+
+ * string.c (str_inspect): consider current_mbctype.
+
+Sun Jul 26 15:37:11 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * array.c (ary_s_new): Array.new(1<<30) dumps core.
+
+Fri Jul 24 13:40:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c1 released.
+
+Fri Jul 24 02:10:22 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (r_bytes2): allocated buffer size was too short.
+
+ * marshal.c (w_object): saves all options, not only casefold flag.
+
+ * re.c (reg_clone): now copies options properly.
+
+ * re.c (reg_get_kcode): code number was wrong.
+
+Thu Jul 23 13:11:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_attr): argument should be symbol or string.
+
+Wed Jul 22 11:59:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (calculate_must_string): wrong offset added.
+
+Wed Jul 22 11:59:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * st.c (rehash): still had a GC problem. fixed.
+
+Tue Jul 21 13:19:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (gc_mark_threads): crashed on GC before thread allocation.
+
+ * st.c (rehash): GC during rehash caused SEGV.
+
+Tue Jul 21 01:25:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (f_sprintf): integer formatter totally re-written.
+
+ * sprintf.c (remove_sign_bits): support uppercase hexadecimal.
+
+Sat Jul 18 00:14:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (f_sprintf): proper sign position for %X and %O.
+
+Fri Jul 17 14:10:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1c0 released.
+
+Fri Jul 17 08:01:49 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * process.c (f_exec): Check_SafeStr() added.
+
+ * process.c (f_system): Check_SafeStr() moved before fork().
+
+Thu Jul 16 22:58:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (scan_once): substrings to the block should not be
+ tainted. use reg_nth_match(), not str_substr().
+
+ * string.c (str_substr): needed to transfer taint.
+
+Thu Jul 16 16:15:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * gc.c (xmalloc): object allocation count added to GC trigger.
+
+ * eval.c (thread_save_context): avoid marking uninitialized stack
+ in thread_mark. GC may be triggered by REALLOC_N().
+
+Wed Jul 15 15:11:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_31.
+
+Wed Jul 15 15:05:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_create): exit() and abort() in threads now
+ forwarded to main_thread.
+
+Tue Jul 14 14:03:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (obj_instance_variables): list names that is not
+ instance variables.
+
+ * gc.c (GC_MALLOC_LIMIT): choose smaller limit value.
+
+Mon Jul 13 12:39:38 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (str2cstr): should not return NULL.
+
+Fri Jul 10 11:51:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (gettable): needed to add dyna_in_block() check.
+
+Thu Jul 9 17:38:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_30.
+
+Thu Jul 9 16:01:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sprintf.c (fmt_setup): format specifier for long needed.
+
+ * sprintf.c (f_sprintf): ditto.
+
+ * numeric.c (fix2str): ditto.
+
+ * eval.c (thread_create): no more ITIMER_REAL.
+
+ * eval.c (thread_create): thread finalization needed before
+ aborting thread if thread_abort is set.
+
+Wed Jul 8 18:17:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (big_pow): abandon power by bignum (too big).
+
+Tue Jul 7 13:58:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_catch): add C level catch/throw feature.
+
+Mon Jul 6 15:18:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (arg): proper return values for `||=' and `&&='.
+
+Fri Jul 3 16:05:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_29.
+
+Fri Jul 3 11:20:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (r_byte): byte should not extend sign bit.
+
+ * numeric.c (fix_mul): use FIX2LONG() instead of FIX2INT() for
+ 64bit architectures.
+
+ * marshal.c (r_bytes): remove weird casting between pointer and int.
+
+ * process.c (proc_setsid): new method Process#setsid().
+
+Thu Jul 2 12:49:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * marshal.c (w_object): remove `write_bignum' label for 64bit
+ architectures.
+
+ * marshal.c (r_bytes): needs int, not long.
+
+Wed Jul 1 14:21:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (flo_plus): should not allow addition with strings.
+
+Wed Jul 1 13:09:01 1998 Keiju ISHITSUKA <keiju@rational.com>
+
+ * numeric.c (num_uminus): wrong coerce direction.
+
+Tue Jun 30 10:13:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (f_p): accepts arbitrary number of arguments.
+
+ * eval.c (rb_yield_0): there's some case that iterator_p() returns
+ true even if the_block was not set. check added.
+
+Tue Jun 30 01:05:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (BEGIN_CALLARGS): adjust the_block before evaluating the
+ receiver's value and the arguments.
+
+Fri Jun 26 18:02:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_28.
+
+Fri Jun 26 11:01:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_aset_method): needed to convert to string.
+
+Thu Jun 25 02:05:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): optimize for `.*' at beginning of the
+ pattern.
+
+ * regex.c (re_search): optimize for character class repeat at
+ beginning of the pattern.
+
+ * regex.c (re_compile_pattern): detect optimization potential for
+ the compiled patterns.
+
+Thu Jun 25 00:02:26 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * re.c (reg_s_new): flag value was wrong.
+
+Wed Jun 24 23:45:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_search): wrong anchor handling for reverse search.
+
+Wed Jun 24 02:18:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (mlhs): `((a,b)),c = [[1,2]],3' assigns a=1,b=2,c=3.
+
+Tue Jun 23 11:46:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): `&&=' and `||=' added.
+
+Sat Jun 20 02:53:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (assignable): nesting local variables should have higher
+ priority than normal local variables for assignment too.
+
+Fri Jun 19 18:28:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_27.
+
+Fri Jun 19 14:34:49 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (assign): support hack for nested multiple assignment.
+
+ * parse.y (mlhs): nested multiple assignment.
+
+ * eval.c (rb_eval): in-block variables now honors static scope.
+
+ * configure.in: RSHIFT check moved to configure.
+
+Thu Jun 18 16:46:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_26.
+
+Thu Jun 18 13:37:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (file_s_ftype): uses lstat(2) instead of stat(2).
+
+ * dir.c (dir_s_glob): there can be buffer overrun, check added.
+
+ * eval.c (f_binding): handles in-block variables declared after
+ binding's generation.
+
+ * numeric.c (flo_floor): floor, ceil, round added to Float.
+
+Wed Jun 17 11:20:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (gettable): nesting local variables should have higher
+ priority than normal local variables.
+
+Tue Jun 16 12:30:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (str2inum): handles `+ddd'.
+
+ * struct.c (make_struct): name parameter can be nil for unnamed
+ structures.
+
+Mon Jun 15 16:30:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (class_s_inherited): prohibiting to make subclass of
+ class Class.
+
+ * object.c (module_s_new): support for making subclass of Module.
+
+ * parse.y (yycompile): clear eval_tree before compiling.
+
+Fri Jun 12 17:58:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (eval): write back the_dyna_var into the block.
+
+Thu Jun 11 18:19:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_25.
+
+ * eval.c (dvar_add_compiling): register dyna_var at compile time.
+
+ * regex.c (re_compile_pattern): RE_DUP_MAX iteration is too big.
+
+Wed Jun 10 15:12:04 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_eof): do not block other threads.
+
+ * signal.c (trap): reserve SIGALRM for thread.
+
+ * eval.c (thread_create): use ITIMER_REAL also to avoid system
+ call blocking.
+
+ * io.c (f_syscall): add TRAP_BEG, TRAP_END around system calls.
+
+ * io.c (io_ctl): add TRAP_BEG, TRAP_END around system calls.
+
+ * enum.c (enum_collect): did not collect false values.
+
+ * array.c (ary_new2): forgot to initialize capa field.
+
+Tue Jun 9 18:36:15 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_split_method): split dumped core for "\xff".
+
+Tue Jun 9 16:22:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_24.
+
+Tue Jun 9 16:04:07 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/kconv/kconv.c (kconv_guess): more precise decision for EUC,
+ using jless algorithm (3 sequential EUC hiragana characters).
+
+Tue Jun 9 15:12:44 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/kconv/kconv.c (kconv_guess): wrong guess for EUC as SJIS in
+ some cases (0xe0 - 0xef).
+
+ * gc.c (xmalloc): insert size check for big (negative in signed)
+ allocation size.
+
+Tue Jun 9 02:54:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/parsedate.rb: wday moved to the last in the return values.
+
+Mon Jun 8 10:40:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_split_method): split dumped core for "\0".
+
+Sat Jun 6 22:50:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (calculate_must_string): wrong condition for
+ {start,stop}_nowidth.
+
+ * regex.c (re_match): various features imported from GNU regex.c
+ 0.12, such as nested grouping, avoiding infinite loop with empty
+ match, etc.
+
+ * regex.c (register_info_type): now use union.
+
+ * regex.c (re_search): more precise anchor(^) check.
+
+Wed Jun 3 18:07:54 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_raise): check rb_in_compile, not rb_in_eval.
+
+Mon Jun 1 05:26:06 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * string.c (trnext): casting to signed char* needed.
+
+Tue Jun 2 16:00:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c (udp_addrsetup): error check enhanced.
+
+ * ext/socket/socket.c (sock_s_getservbyaname): use strtoul(), if
+ possible.
+
+Sat May 30 07:10:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_prepare_re): no more needless regular expression
+ recompile on casefold conditions.
+
+Thu May 28 18:02:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (nil_plus): no more `+' method for nil.
+
+Wed May 27 17:33:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_fetch): new method.
+
+ * regex.c (re_search): check whether translate table is set.
+
+Tue May 26 11:39:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_23.
+
+ * parse.y (yylex): no UPLUS/UMINUS for 1st argument if
+ parenthesises are omitted.
+
+Tue May 26 01:09:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): (?XI) for turns off the
+ corresponding option.
+
+Mon May 25 12:38:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): inline i option (?i).
+
+ * regex.c (re_compile_pattern): inline x option (?x).
+
+ * regex.c (re_compile_pattern): x option for regexp.
+
+ * dir.c (dir_s_open): returns block's evaluated value.
+
+ * io.c (f_open): returns block's evaluated value.
+
+ * ext/curses/curses.c (curses_addstr): nil argument caused SEGV.
+
+Fri May 22 11:52:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): push mark on (?:), so that
+ laststart check for {a,b} can be done.
+
+Thu May 21 17:31:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): wrong match (too non-greedy) for `{a,b}?'.
+
+ * io.c (io_lineno): new method IO#lineno, IO#lineno=.
+
+Wed May 20 06:04:43 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * BeOS patch.
+
+Wed May 20 16:32:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (BIGDN): use RSHIFT(), instead of mere `>>'.
+
+Tue May 19 16:36:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_22.
+
+Tue May 19 16:31:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (assignable): specification changed for in-block
+ variable definition.
+
+ * eval.c (dyna_var_asgn): error in in-block variables' compile
+ time definition.
+
+ * parse.y (str_extend): wrong nesting detection.
+
+Tue May 19 09:47:55 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * numeric.c (num2int): re-defined (extensions may use this).
+
+Mon May 18 16:40:50 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * error.c (get_syserr): BeOS support.
+
+ * configure.in: modified for BeOS.
+
+ * string.c (str_dump): do not call isascii().
+
+ * sprintf.c (remove_sign_bits): forgot to initialize end pointer.
+
+ * glob.c: #include <alloca.h> added.
+
+Mon May 18 14:52:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_21.
+
+Mon May 18 03:27:57 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * file.c (file_s_expand_path): optional second argument
+ `default_directory' added.
+
+Sat May 16 22:06:52 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * error.c (RAISE_ERROR): wrong error message
+
+Fri May 15 14:43:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_20.
+
+Thu May 14 14:44:21 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * sun4 cc patches for intern.h and regex.h.
+
+Thu May 14 14:03:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * random.c (RANDOM_MAX): guessing proper maximum value for random
+ numbers.
+
+ * random.c (f_rand): use drand48 if possible.
+
+Wed May 13 19:05:20 1998 MAEDA shugo <shugo@aianet.ne.jp>
+
+ * BeOS patches for io.c, error.c and config.guess.
+
+Wed May 13 14:56:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_19.
+
+ * most of the Mac and BeOS patches merged, except path separators.
+
+ * error.c (err_append): generated SyntaxError was String.
+
+ * ruby.h: xxx2INT, xxx2UINT checks values as int, not long.
+
+ * ruby.h: remove typedef's. INT, UINT, UCHAR, USHORT.
+
+Tue May 12 17:38:00 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_18.
+
+Tue May 12 11:38:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * error.c (syserr_errno): returns errno of the SystemCallError.
+
+ * error.c (rb_sys_fail): saves errno in the Exception.
+
+ * error.c (set_syserr): no need to protect syserr_list.
+
+ * error.c (rb_sys_fail): no more bufsize limit.
+
+ * error.c (set_syserr): integer value of errno can be accessed by
+ Errno::EXXX::Errno.
+
+Sun May 10 03:10:33 1998 WATANABE Tetsuya <tetsu@jpn.hp.com>
+
+ * io.c (io_tell etc.): moved from File class to IO class.
+
+Fri May 8 12:26:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_unpack): should be unsigned int (was signed int).
+
+Thu May 7 16:34:10 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * pack.c (pack_pack): `V', `N' uses newly created NUM2UINT().
+
+ * ruby.h (NUM2UINT): new macro.
+
+ * bignum.c (big2uint): try to convert bignum into UINT.
+
+ * re.c (reg_match): needed to return false for match with nil.
+
+ * gc.c (obj_free): wrong condition to free string.
+
+Wed May 6 21:08:08 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.c (ruby_process_options): modified for DJGPP.
+
+Wed May 6 15:48:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_17.
+
+Wed May 6 01:37:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c: remove global variable `errat'.
+
+ * eval.c (rb_longjmp): embed error position information in the
+ exception object.
+
+Sat May 2 12:20:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_search): supports reverse search.
+
+ * string.c (str_index_method): does update $~ etc.
+
+ * eval.c (f_load): needed to clear the_dyna_vars.
+
+ * eval.c (dyna_var_asgn): do not push dyna_var, which is id == 0.
+
+ * error.c (Init_Exception): NotImplementError is no longer
+ StandardError, which is not handled by default rescue.
+
+Fri May 1 00:35:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (proc_options): `-d' turns on verbose flag too.
+
+ * error.c (exception): last argument may be the superclass of the
+ defining exception(s).
+
+ * io.c (Init_IO): EOFError is now subclass of the IOError.
+
+ * io.c (Init_IO): forgot to define IOError.
+
+ * error.c (Init_Exception): old Exception class renamed to
+ StandardError. Exception now replaces old GlobalExit.
+
+ * error.c (Init_Exception): Exception is now the root of the
+ Global Exits. There's no longer GlobalExit class.
+
+ * util.c (ruby_mktemp): check TMP, TMPDIR first.
+
+Thu Apr 30 01:08:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/tk.rb: call 'unknown', if proc not defined.
+
+ * eval.c (handle_rescue): default rescue handles `Exceptional' not
+ only the instance of the `Exception's.
+
+ * eval.c (f_raise): exception can be any object.
+
+ * time.c (time_gm_or_local): call time_gmtime or time_localtime.
+
+ * eval.c (f_raise): raises TypeError if the class which is not a
+ subclass of String is specified (checked in exc_new()).
+
+ * error.c (exc_new): need to check whether invalid class (not a
+ subclass of String) is specified.
+
+Wed Apr 29 21:05:44 1998 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * ruby.c (proc_options): option '-e' via tempfile.
+
+Tue Apr 28 15:27:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_16.
+
+Tue Apr 28 00:07:38 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_is_proc): type check predicate.
+
+ * eval.c (obj_is_block): ditto.
+
+Mon Apr 27 16:59:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/gtk/gtk.c (Init_gtk): use timeout, not idle to avoid
+ consuming CPU too much.
+
+ * lib/tk.rb: use tcltklib#_invoke instead of `_eval'.
+
+Mon Apr 27 16:59:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_sort): use dup, not clone.
+
+Mon Apr 27 13:46:27 1998 Tadahiro Maebashi <maebashi@iij.ad.jp>
+
+ * ext/tcltklib/tcltklib.c (ip_invoke): invoke tcl command
+ directly. need not worry about escaping tcl characters.
+
+Mon Apr 27 12:04:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * random.c (f_rand): do not call srand() implicitly.
+
+Fri Apr 24 14:35:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_15.
+
+ * parse.y (assignable): dyna_var_asgn actually defines nested
+ local variables in outer context.
+
+ * random.c (f_rand): call srand(), if it has not called yet.
+
+ * random.c (f_srand): use tv_usec as the default seed.
+
+ * eval.c (rb_eval): values of nested local variables should be
+ independent.
+
+ * eval.c (rb_yield_0): local variables wrong nested conditions.
+
+Wed Apr 22 23:27:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (select_get_io): get IO object by `to_io'.
+
+ * io.c (io_to_io): method to retrieve IO object, from delegating
+ object for example.
+
+Wed Apr 22 16:52:37 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_14.
+
+ * string.c (str_modify): check for embedded pointer reference.
+
+ * gc.c (obj_free): ditto.
+
+ * pack.c (pack_pack): p/P template to embed pointers.
+
+Wed Apr 22 00:07:10 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * array.c (ary_rindex): embarrassing typo.
+
+Tue Apr 21 12:31:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_13.
+
+ * configure.in (RUBY_LIB): supports --program-{prefix,suffix}.
+
+ * array.c (ary_rindex): new method.
+
+ * io.c (io_binmode): should return self.
+
+Tue Apr 21 08:23:04 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * parse.y (here_document): calling parse_string with wrong
+ arguments.
+
+ * struct.c (struct_aset): problem member assignment with name.
+
+Mon Apr 20 14:47:49 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_12.
+
+ * time.c (time_arg): args may be string (support for reduced
+ implicit type conversion).
+
+ * lib/base64.rb: changed to use pack/unpack with `m' template.
+
+Mon Apr 20 06:23:20 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (mod_remove_const): new method.
+
+Sat Apr 18 03:53:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_each_with_index): removed. use Enumerable's
+ each_with_index instead.
+
+ * class.c (rb_include_module): check for super modules, since
+ module's included modules may be changed.
+
+Fri Apr 17 21:50:47 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * marshal.c (r_long): r_byte() may return signed byte.
+
+Fri Apr 17 11:58:30 1998 NAGAI Hidetoshi <nagai@dumbo.ai.kyutech.ac.jp>
+
+ * ext/tcltklib/tcltklib.c (lib_mainloop): thread and interrupt check.
+
+Fri Apr 17 11:06:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (find_file): try to fopen() to check whether file exists.
+
+ * ruby.c (load_file): ditto.
+
+ * struct.c (struct_aset): struct member can be set by member name.
+
+Fri Apr 17 00:47:19 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/extmk.rb.in: added m68k-human support
+
+ * file.c (LOCK_SH): defines moved.
+
+ * array.c (ary_flatten_bang): simplified loop.
+
+Thu Apr 16 16:52:01 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_11.
+
+ * lib/tk.rb: thread support (experimental - maybe slow).
+
+ * eval.c (rb_longjmp): trace event on exception in raising
+ context, just before raising exception.
+
+ * struct.c (struct_s_members): forgot to check singletons.
+
+ * struct.c (struct_aref): members can be accessed by names too.
+
+ * array.c (ary_flatten): new method.
+
+ * eval.c (rb_longjmp): prints exception information with `-d'.
+
+ * object.c (any_to_s): remove class name restriction.
+
+Thu Apr 16 01:38:02 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (thread_flock): do not block other threads.
+
+ * eval.c (thread_trap_eval): signals are now delivered to the
+ current thread again. In case that the current thread is dead,
+ signals are forwarded to the main thread.
+
+ * string.c (str_new4): need not to duplicate frozen strings.
+
+Wed Apr 15 08:33:47 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * struct.c (struct_inspect): remove restriction for struct names.
+
+Wed Apr 15 02:55:02 1998 Kazuya 'Sharl' Masuda <sharl@www.ufo.co.jp>
+
+ * x68 patches to config.sub, ext/extmk.rb.in
+
+Wed Apr 15 01:22:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_dup_frozen): do not duplicate frozen strings.
+
+ * parse.y (yylex): allow nested parenthesises.
+
+ * io.c (obj_displayln): prints newline after `display'ing the
+ receiver.
+
+ * io.c (io_puts): avoid generating "\n" each time. use RS_default
+ instead.
+
+ * io.c (f_p): ditto.
+
+Tue Apr 14 22:18:17 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * struct.c (struct_aref): should not subtract negative index.
+
+Tue Apr 14 11:34:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_10.
+
+ * parse.y: token names prefixed by `t'.
+
+ * struct.c (struct_s_def): supports subclassing of Struct.
+
+ * io.c (io_s_new): supports subclassing of IO.
+
+Mon Apr 13 11:07:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (f_binding): need to restore method name.
+
+ * eval.c (rb_call0): raises SystemStackError, not Fatal.
+
+ * io.c (obj_display): same as `print self'.
+
+ * io.c (f_p): can now be called in the method form.
+
+ * re.c (reg_regsub): needed to be mbchar aware.
+
+Mon Apr 13 13:18:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_trap_eval): all signals delivered to main_thread.
+
+Mon Apr 13 12:47:03 1998 TAKAHASHI Masayoshi <maki@inac.co.jp>
+
+ * re.c (kcode_set_option): did not set SJIS on SJIS condition.
+
+Sun Apr 12 22:14:07 1998 Kazunori NISHI <kazunori@swlab.csce.kyushu-u.ac.jp>
+
+ * array.c (ary_uniq_bang): should be `==', not `='. embarrassing.
+
+Sat Apr 11 02:13:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_subseq): SEGVed for `[][1,1]'.
+
+Fri Apr 10 21:29:06 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * array.c (ary_subseq): add check for beg larger than array length.
+
+Wed Apr 8 17:24:11 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * dir.c (dir_s_open): can be called with block (like IO#open).
+
+ * dir.c (dir_s_chdir): print directory path on error.
+
+ * dir.c (dir_s_chroot): ditto
+
+ * dir.c (Init_Dir): needed to override `new'.
+
+Thu Apr 9 18:24:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_09.
+
+ * string.c (str_cmp): do not depend on sentinel at the end of the
+ strings.
+
+ * string.c (str_chomp_bang): forgot to set the sentinel.
+
+Wed Apr 8 00:59:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * bignum.c (big2int): converted int may be too big to fit in
+ signed int.
+
+ * parse.y (arg): `foo += 1' should not cause an error.
+
+ * variable.c (rb_const_defined): returned false even if the
+ constant is defined at the top level.
+
+ * eval.c (f_local_variables): dyna_var->id may be null. should
+ have checked before calling str_new2().
+
+Tue Apr 7 01:15:15 1998 Kaneko Naoshi <wbs01621@mail.wbs.or.jp>
+
+ * re.c (reg_regsub): need to check string boundary.
+
+Tue Apr 7 19:19:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_cmp): returns either 1, 0, -1.
+
+ * array.c (ary_cmp): should check array length, too
+
+Tue Apr 7 18:50:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_08.
+
+Tue Apr 7 18:31:27 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * instruby.rb (mandir): dll installation for cygwin32
+
+Tue Apr 7 01:16:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * config.sub (maybe_os): TOWNS support?
+
+ * config.guess: too strict check for libc versions on linuxes.
+
+ * experimental release 1.1b9_07.
+
+ * array.c (ary_cmp): compare each element using `<=>'.
+
+ * hash.c (hash_each_with_index): yields [value, key] pair.
+
+ * class.c (class_protected_instance_methods): list protected
+ method names.
+
+ * class.c (ins_methods_i): exclude protected methods.
+
+ * eval.c (PUSH_BLOCK): dynamic variables can be accessed from
+ eval() with bindings.
+
+Mon Apr 6 14:49:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_yield): must return evaluated value.
+
+Fri Apr 3 13:07:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_schedule): context switch bypassed on wrong
+ conditions.
+
+ * variable.c (rb_name_class): set classname by id before String
+ class is initialized (1.0 behavior restored).
+
+Fri Apr 3 11:25:45 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (num2int): no implicit conversion from string.
+
+ * numeric.c (num2int): check whether `to_i' returns an Integer.
+
+ * numeric.c (num_zero_p): new method.
+
+ * numeric.c (num_nonzero_p): new method. returns the receiver if
+ it's not zero.
+
+ * eval.c (obj_instance_eval): the_class should be the object's
+ singleton class.
+
+ * error.c (exc_s_new): message is converted into a string.
+
+Thu Apr 2 18:31:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_call_init): every object call `initialize'.
+
+Wed Apr 1 08:51:53 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * parse.y (stmt): UNTIL_MOD should be for stmt, not only for expr.
+
+Wed Apr 1 01:20:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (true_and): boolean operators &, | and ^.
+
+Tue Mar 31 13:23:58 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_compact_bang): returns nil, if it does not modify
+ the array like String's bang methods.
+
+ * array.c (ary_uniq_bang): new method to remove duplicate items.
+
+ * eval.c (bind_s_new): new method.
+
+ * numeric.c (num2int): raise exception if Fixnums too big to
+ convert into `int' in case that sizeof(int) < sizeof(INT).
+
+ * string.c (str_center): SEGV on negative width.
+
+ * eval.c (eval): forgot to set sourcefile.
+
+Mon Mar 30 11:12:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (f_test): raises exception for unknown command.
+
+ * eval.c (Init_eval): `class_eval': alias to the module_eval.
+
+Mon Mar 30 18:50:42 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * string.c (str_capitalize_bang): did not check string modification.
+
+ * string.c (str_delete_bang): wrong conversion.
+
+ * string.c (str_intern): typo in error message.
+
+Mon Mar 30 01:44:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_instance_eval): accepts block as evaluation body.
+ No compilation needed each time.
+
+ * eval.c (mod_module_eval): ditto
+
+ * file.c (file_s_umask): umask did not return old values, if no
+ argument given.
+
+Sun Mar 29 00:54:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (f_throw): nil returned always.
+
+Sat Mar 28 20:40:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_06.
+
+Sat Mar 28 16:07:11 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (io_closed): should not cause exception for closed IO.
+
+ * string.c (str_tr): returned nil for success.
+
+Sat Mar 28 00:47:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (f_local_variables): new method to return an array of
+ local variable names.
+
+ * variable.c (obj_instance_variables): now returns an array of
+ variable names, as described in the reference.
+
+ * eval.c (rb_attr): honors default method visibility of the
+ current scope.
+
+Fri Mar 27 13:49:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_05.
+
+ * ruby.c (ruby_prog_init): `site_ruby' added to load_path.
+
+ * ruby.c (ruby_prog_init): load-path order changed. Paths in
+ the RUBYLIB environment variable comes first in non-tainted
+ mode.
+
+Thu Mar 26 11:51:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_call): new feature: `protected' methods.
+
+ * string.c (str_dump): new method.
+
+ * eval.c (block_pass): block argument can be nil, which means no
+ block is supplied for the method.
+
+Wed Mar 25 21:20:13 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * string.c (str_reverse_bang): string copied to wrong place.
+
+Wed Mar 25 08:12:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (flo_modulo): caused SEGV if left operand is not a
+ float value.
+
+ * eval.c (f_eval): optional third and fourth argument to specify
+ file-name and line-number.
+
+ * eval.c (eval): file-name and line-number set properly.
+
+ * parse.y (assign_in_cond): literal assignment is now warning, not
+ compile error.
+
+ * error.c (Warn): Warn() always print message, OTOH Waring()
+ prints when verbose flag is set.
+
+Tue Mar 24 12:50:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (ruby_prog_init): `.' should come last in the load-path.
+
+ * eval.c (Init_eval): `__send__', alias for `send'.
+
+Mon Mar 23 12:44:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_chomp_bang): now takes `rs' as an argument.
+
+ * eval.c (thread_free): main_thread should not be freed.
+
+Fri Mar 20 16:40:34 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_chomp_bang): chomp! (and other ! methods) returns
+ nil if it does not modify the string.
+
+ * string.c (str_sub_iter_s): should check last pattern since it
+ may be matched to null.
+
+Thu Mar 19 13:48:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_04.
+
+ * parse.y (yylex): `10e0.9' should cause syntax error.
+
+Wed Mar 18 17:46:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (load_file): new file object constant DATA. Only
+ available for the script from the file.
+
+ * regex.c (re_match): forwarding failure point popped too much.
+
+Tue Mar 17 18:23:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * math.c (math_frexp): newly added.
+
+ * math.c (math_ldexp): ditto.
+
+ * bignum.c (bigdivmod): calculates modulo.
+
+ * numeric.c (fix_remainder): returns reminder, formerly introduced
+ as modulo.
+
+ * numeric.c (fix_modulo): calculates proper `modulo'.
+
+ * bignum.c (bigdivmod): wrong sign for reminder.
+
+Mon Mar 16 17:07:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_03.
+
+Mon Mar 16 16:33:53 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (pipe_finalize): needed to add pipe_finalize to pipes on
+ cygwin32.
+
+Mon Mar 16 14:11:06 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (ins_methods_i): needed to consider NOEX_UNDEF.
+
+Mon Mar 16 13:23:53 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (io_check_closed): check for `fptr->f2 == NULL'.
+
+ * io.c (io_fptr_close): ditto.
+
+Mon Mar 16 11:49:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (pipe_atexit): free()ing referencing pipe_list.
+
+ * range.c (range_length): returns zero, if the first is greater
+ than the last.
+
+ * signal.c (trap_restore_mask): restore signal mask before raising
+ exceptions and throws.
+
+Fri Mar 13 13:49:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_02.
+
+ * object.c (mod_clone): need to dups constants and instance
+ variables.
+
+ * eval.c (rb_eval): forgot to initialize body for NODE_DEFS.
+
+ * eval.c (rb_eval): retrieve self from calling frame, since self
+ changes sometimes.
+
+ * env.h (FRAME): need to save self in the calling frame.
+
+ * io.c (f_gets_method): rs should be initialized by RS.
+
+Thu Mar 12 15:33:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * experimental release 1.1b9_01.
+
+ * range.c (range_s_new): check values by `first <= last'.
+
+ * parse.y (lastline_set): fixed offset for $_ and $~ in the local
+ variable space.
+
+Wed Mar 11 02:14:17 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_gets): handle normal case specially for speed.
+
+ * eval.c (rb_disable_super): function to disable superclass's
+ method explicitly.
+
+ * eval.c (rb_eval): inherits previous method definition's
+ NOEX_UNDEF-ness, if exists.
+
+ * class.c (rb_define_method): disables superclass's overriding
+ method by default.
+
+Wed Mar 11 01:40:48 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * numeric.c (flo_gt,etc.): do not depend on `<=>', to handle NaN.
+
+Tue Mar 10 00:03:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (load_file): understands multiple options in #! line.
+
+ * regex.c (re_compile_pattern): support for [:alpha:] etc.
+
+Mon Mar 9 16:53:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.h (GetOpenFile): embed io_check_closed in GetOpenFile.
+
+ * sprintf.c (f_sprintf): zero padding failed for negative
+ integers.
+
+ * sprintf.c (remove_sign_bits): failed to remove some bits.
+
+Sat Mar 7 21:51:46 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * class.c (ins_methods_i): body may be NULL for some case.
+
+Fri Mar 6 17:23:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (mbcinit): table driven mbchar detection.
+
+ * object.c (obj_alloc): check for allocating instance for the
+ primitive classes (mostly perfect).
+
+ * ext/curses/curses.c (curses_finalize): restore original state at
+ interpreter termination.
+
+ * ext/curses/curses.c (curses_addstr): forgot to check argument
+ type (caused SEGV). now uses STR2CSTR() macro.
+
+Thu Mar 5 13:47:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (block_pass): accepts method object as block args.
+
+ * eval.c (f_missing): use any_to_s() for stringify.
+
+Wed Mar 4 01:39:52 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (block_arg): new syntax - block argument in the
+ calling arglist.
+
+ * eval.c (rb_call): no module search. simplified a lot.
+
+ * eval.c (rb_eval): block arg support.
+
+ * parse.y (f_block_arg): new syntax - block argument in the
+ formal arglist.
+
+Tue Mar 3 14:20:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (obj_method): returns bound method object.
+
+ * eval.c (rb_call): argument check for empty methods.
+
+ * ruby.h (NUM2CHR): new macro, originally from curses module.
+
+Tue Mar 3 13:03:35 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * io.c (io_putc): new method.
+
+Tue Mar 3 11:21:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_inspect): more strict charcode detection.
+
+ * eval.c (thread_stop): stopping only thread raises ThreadError
+ exception.
+
+Tue Mar 3 08:04:56 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
+
+ * struct.c (struct_alloc): incomplete struct initialization made
+ GC to access unallocated addresses.
+
+Mon Mar 2 16:28:27 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (thread_stop_method): remove Thread#stop.
+
+Fri Feb 27 18:16:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b9 released.
+
+Fri Feb 27 09:36:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (hash_delete_nil): needed to compare value to nil, since
+ nil is the valid key for hashes.
+
+ * hash.c (hash_foreach_iter): rehashing causes IndexError.
+
+ * hash.c (hash_foreach_iter): rehash check by pointer comparison.
+
+Thu Feb 26 17:22:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (fname): convert reswords into symbols.
+
+ * parse.y (reswords): reserved words are now embedded in the
+ syntax (sigh).
+
+ * parse.y: now reserved words can be method names safely.
+
+Wed Feb 25 15:50:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (mod_module_eval): clear the_scope's PRIVATE flag before
+ calling eval().
+
+ * gc.c (gc_call_finalizer_at_exit): run finalizers before any data
+ object being freed.
+
+ * eval.c (rb_eval): needed to keep prot_tag->retval before
+ evaluating the ensure clause.
+
+Tue Feb 24 11:16:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): reserved words can be appear as method names at
+ right after 'def' and `.'(dot), like foo.next.
+
+ * eval.c (return_check): checks for return out of thread (formerly
+ done in return_value).
+
+ * eval.c (POP_TAG): copy retval to outer level.
+
+ * eval.c (return_value): just set retval, no check, no unwinding.
+
+ * parse.y (nextc): line continuation by backslash at end of line.
+
+ * regex.c (re_compile_pattern): forgot to clear pending_exact on
+ closing parentheses.
+
+ * parse.y (assignable): should not assign dyna_var to true, if it
+ is already defined.
+
+Mon Feb 23 14:35:03 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (obj_is_kind_of): no longer accepts true/false/nil.
+
+ * object.c ({true,false,nil}_to_i): can be converted into integers.
+
+Mon Feb 23 12:11:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_s_quote): needed to be mbchar aware.
+
+ * eval.c (proc_s_new): wrong iter mark.
+
+Sat Feb 21 22:59:30 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * io.c (f_syscall): no argument check.
+
+Fri Feb 20 10:17:51 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b8 released.
+
+ * ext/kconv/kconv.c (kconv_kconv): default output code now be
+ determined according to the value of $KCODE.
+
+ * re.c (rb_get_kcode): can retrieve $KCODE from C code.
+
+ * parse.y (stmt): if/unless modifiers returns nil, if condition is
+ not established.
+
+Thu Feb 19 11:06:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/kconv/kconv.c (kconv_kconv): charcode can be specified by
+ code name (JIS, SJIS, EUC like value of $KCODE).
+
+ * regex.c (re_compile_pattern): forgot to fixup_jump for (?:..).
+
+ * regex.c (re_compile_pattern): needed to clear pending_exact on
+ non-registering grouping (?:...).
+
+Wed Feb 18 19:54:21 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (here_document): needed to set lex_state to EXPR_END.
+
+Wed Feb 18 18:45:10 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * patches for cygwin32 applied.
+
+Wed Feb 18 00:41:31 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_sub_s): needed to be mbchar aware to increment one
+ character.
+
+ * regex.c (re_match): \Z matches newline just before the end of
+ the string.
+
+Tue Feb 17 00:04:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_arg): Time.gm and Time.local now understands
+ Time#to_a format.
+
+ * string.c (str_sub_s): replace happened twice for null pattern.
+
+ * regex.c (re_search): null pattern should not match after newline
+ at the end of string.
+
+ * time.c (time_isdst): now returns boolean value.
+
+ * error.c (rb_check_type): treat special constants in messages.
+
+ * parse.y (yylex): new form `::Const' to see toplevel constants.
+
+ * parse.y (cond): SEGV on `if ()'.
+
+ * gc.c (obj_free): some data needed explicit free().
+
+Mon Feb 16 23:55:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (blk_free): release duplicated block informations.
+
+ * eval.c (blk_copy_prev): duplicate outer block information into
+ the heap, when proc/binding created.
+
+Mon Feb 16 14:38:25 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_mon): now 1 for January and so on.
+
+ * time.c (time_year): year in 19xx (no + 1900 needed anymore).
+
+Mon Feb 16 13:28:33 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): need to fetch mbchar's second byte
+ without translation.
+
+Mon Feb 16 12:29:27 1998 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * eval.c (f_pass_block): pass iterator block to other method.
+
+Fri Feb 13 08:16:11 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (parse_regx): handle \s before read_escape().
+
+ * parse.y (read_escape): `\s' in strings as space.
+
+Tue Feb 10 17:29:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b7 released.
+
+ * string.c (str_aset): string insertion by `str[n] = str2'.
+
+ * string.c (str_oct): does recognize `0x'.
+
+ * sprintf.c (f_sprintf): use base 10 for conversion from string to
+ integer.
+
+Mon Feb 9 14:51:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * numeric.c (do_coerce): proper error message.
+
+ * string.c (str_sum): bug - masked by wrong value. (sigh..)
+
+Sat Feb 7 15:11:14 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_empty): new method
+
+Fri Feb 6 01:42:15 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c (time_asctime): use asctime(3), not strftime(3).
+
+Thu Feb 5 18:58:46 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_fptr_close): do not free path on close().
+
+ * array.c (ary_filter): new method.
+
+ * enum.c (enum_each_with_index): new method.
+
+Thu Feb 5 14:10:35 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (primary): singleton class def can be appeared inside
+ method bodies.
+
+ * hash.c (hash_replace): replace content.
+
+ * string.c (str_replace_method): replace content.
+
+ * array.c (ary_replace_method): replace elements.
+
+ * string.c (str_succ_bang): String#succ!
+
+Thu Feb 5 18:20:30 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_upcase_bang): multi byte character support.
+
+Wed Feb 4 13:55:26 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_reverse): SEGV on empty array reverse.
+
+Tue Feb 3 12:24:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (match_to_a): non matching element should be nil.
+
+ * ruby.c (ruby_load_script): load script after all initialization.
+
+ * bignum.c (str2inum): need to interpret prefix `0' of `0x'.
+
+Tue Feb 3 10:00:18 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * numeric.c (fix_rshift): use `sizeof(INT)*8' instead of 32.
+
+Mon Feb 2 14:09:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (set_arg0): grab environment region too.
+
+Thu Jan 29 18:36:25 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * process.c (rb_proc_exec): check `sh' to be exist.
+
+Thu Jan 29 18:18:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_stdio_set): assignment to $stdin or $stdout does
+ reopen() as well as $stderr.
+
+Thu Jan 29 14:18:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (mod_ancestors): should not include singleton classes.
+
+ * object.c (obj_type): should not return internal class.
+
+ * io.c (io_reopen): unwillingly closes stdio streams.
+
+Thu Jan 29 11:50:35 1998 Toshihiko SHIMOKAWA <toshi@csce.kyushu-u.ac.jp>
+
+ * ext/socket/socket.c (udp_addrsetup): forgot to use htons().
+
+Tue Jan 27 23:15:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * keywords: __FILE__, __LINE__ are available again.
+
+Fri Jan 23 14:19:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b6 released.
+
+ * object.c (mod_to_s): need to duplicate classpath.
+
+ * error.c (exc_inspect): need to duplicate classpath.
+
+Thu Jan 22 00:37:47 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (STR2CSTR): new macro to retrieve char*.
+
+ * class.c (rb_define_method): `initialize' should always be
+ private, even if it defined by C extensions.
+
+ * eval.c (rb_eval): `initialize' should always be private.
+
+Thu Jan 22 16:21:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): some singleton class def cause SEGV.
+
+ * eval.c (TMP_ALLOC): replace ALLOCA_N, where thread context
+ switch may happen.
+
+Wed Jan 21 01:43:42 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (PUSH_FRAME): do not use ALLOCA_N(). crash on some
+ platforms that use missing/alloca.c.
+
+ * regex.c (re_compile_pattern): too many pops for non register
+ subexpr.
+
+ * parse.y (yylex): open parentheses after identifiers are argument
+ list, even if whitespaces have seen.
+
+Tue Jan 20 15:19:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (terms): quoted word list by %w(a b c).
+
+ * ext/tcltklib/extconf.rb: more accurate check for tcl/tk libs.
+
+ * file.c (rb_stat): most of the FileTest methods (and function
+ `test') accept File objects as the argument.
+
+Tue Jan 19 18:19:24 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/extmk.rb.in (install): there should be no newline after install:
+
+ * re.c (MIN): renamed from min(). there's a local variable named
+ min in the file, so that some cpp will raise an error.
+
+Mon Jan 19 16:30:05 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b5 released.
+
+ * process.c (rb_syswait): no exception raised.
+
+Fri Jan 16 00:43:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.h (CLONESETUP): copies its singleton classes too.
+
+ * class.c (singleton_class_attached): saves binded object in the
+ singleton classes.
+
+ * eval.c (rb_eval): calls singleton_method_added even in the
+ singleton class clauses.
+
+Fri Jan 15 23:22:43 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.c (proc_options): -S does not recognize PATH.
+
+Thu Jan 15 02:03:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_clear_cache_by_id): clear only affected cache
+ entries.
+
+Wed Jan 14 02:14:48 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c: new UDP/IP socket classes.
+
+Tue Jan 13 10:00:18 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_cmp): ignorecase($=) works wrong.
+
+Fri Jan 9 13:19:55 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b4 released.
+
+ * eval.c (f_missing): class name omitted from the error message.
+
+ * error.c (exc_inspect): description changed.
+
+ * string.c (Init_String): GlobalExit's superclass did not filled,
+ since GlobalExit created earlier than String.
+
+Thu Jan 8 12:10:09 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (aryset): expr in the brackets can be null.
+
+Wed Jan 7 21:13:56 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_reopen): keep stderr unclosed.
+
+ * io.c (io_errset): keep stderr unclosed.
+
+Tue Jan 6 00:27:43 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y: syntax modified for `while expr do .. end' etc.
+
+ * process.c (f_exec,f_system): can supply arbitrary name for the
+ new process.
+
+Mon Jan 5 16:59:13 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * file.c (file_s_basename): removes any extension by ".*".
+
+Sun Jan 4 19:36:22 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * parse.y (yylex): needed to update lex_p (reading point).
+
+Sat Jan 3 19:14:14 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * class.c,object.c: duplicate defines mKernel and cFinxnum.
+
+Fri Jan 2 20:38:59 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/curses/curses.c (NUM2CHAR): uses the first character for
+ string arguments.
+
+ * array.c (ary_fill): did not extend array for ranges.
+
+ * array.c (beg_len): did not return end pos bigger than size.
+
+Fri Jan 2 02:09:16 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * dir.c (dir_s_chdir): bug in nil check.
+
+ * array.c (ary_fill): bug in nil check.
+
+Tue Dec 30 11:46:23 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * hash.c (env_path_tainted): checks directories in PATH
+ environment variable are not world writable.
+
+ * ruby.c (load_file): invoke specified interpreter if the #! line
+ does not contain the word `ruby'.
+
+Fri Dec 26 03:26:41 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (uscore_get): type information included in the error
+ message.
+
+ * variable.c (f_untrace_var): does not free trace-data within
+ trace procedure.
+
+Thu Dec 25 02:50:29 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b3 released.
+
+ * ruby.h: inlining some functions on gcc 2.x
+
+Tue Dec 23 02:47:33 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): public/private information kept in the current
+ scope, to remove undesired state from the class/module.
+
+ * time.c (time_strftime): remove hidden limit of 100 bytes of
+ result string, using malloc'ed buffer.
+
+ * hash.c (hash_update): merges the contents of another hash,
+ overriding existing keys.
+
+ * regex.c (must_instr): totally re-written.
+
+ * io.c (read_all): try to allocate proper sized buffer using
+ fstat(2) for speedup.
+
+Sat Dec 20 00:27:28 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (must_instr): need to skip 2 bytes for mbchars.
+
+Fri Dec 19 01:18:29 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b2 released.
+
+ * eval.c (check_errat): check and convert (if necessary) traceback
+ information before assigning to the variable $@.
+
+ * eval.c (f_raise): optional third argument to specify traceback
+ information.
+
+ * io.c (f_open): prevent infinite recursive call.
+
+Thu Dec 18 19:33:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_rindex): now accepts regexp as index.
+
+Thu Dec 18 18:42:50 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/socket/extconf.rb: modified to detect win32 socket lib.
+
+Thu Dec 18 00:25:03 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * re.c (reg_equal): checks for source and casefold and kcode matching.
+
+ * marshal.c: became built-in module.
+
+ * ext/marshal/marshal.c (r_object): displays struct name for
+ non-compatible struct.
+
+ * string.c (str_index_method): now searches character (fixnum) in
+ the string.
+
+ * string.c (str_include): redefine `include?'.
+
+ * regex.c (re_match): start_nowidth saves current stack position
+ to stop_nowidth.
+
+ * regex.c (re_compile_pattern): add space to stop_nowidth to save
+ runtime stack position.
+
+Tue Dec 16 14:57:43 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (scan_once): wrong exception for regexp that match with
+ null string (use substr instead of subseq).
+
+Sat Dec 13 00:13:32 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (expr): remove bare assocs from expr rule.
+
+ * rbconfig.rb: renamed from config.rb (it was too generic name).
+
+Fri Dec 12 00:50:25 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (expr): warns if BEGIN or END appear in the method
+ bodies.
+
+ * string.c (str_match): calls y =~ x if y is neither String nor
+ Regexp so that eregex.rb works.
+
+ * eval.c (f_at_exit): to register end proc.
+
+ * class.c (rb_define_module_function): define 'function' method
+ for the Module, not private method.
+
+ * class.c (rb_define_function): function to define `function' method.
+
+ * eval.c (rb_eval): inherit visibility from superclass's method
+ except when it is set to `function'
+
+ * eval.c (rb_eval): new visibility status `function'.
+
+ * parse.y (yycompile): do not clear eval_tree. thus enable multiple
+ command line script by option `-e'.
+
+ * eval.c (rb_eval): END execute just once.
+
+ * parse.y (expr): BEGIN/END built in the syntax.
+
+Thu Dec 11 13:14:35 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (mod_le): Module (or Class) comparison.
+
+ * eval.c (rb_remove_method): raises NameError if named method does
+ not exist.
+
+ * ext/curses/curses.c: remove CHECK macro for BSD curses.
+
+Thu Dec 11 12:44:01 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * pack.c: sun4 cc patch
+
+Wed Dec 10 15:21:36 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/marshal/marshal.c (marshal_load): can supply evolution proc
+ object as optional second argument.
+
+ * re.c (reg_source): get source string of the regular expression.
+
+Tue Dec 9 10:05:17 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b1 released.
+
+ * parse.y (tokadd): token buffer overrun.
+
+ * ruby.c (ruby_prog_init): forgot to protect rb_argv0 from gc.
+
+ * eval.c (ruby_run): call finalizers at process termination.
+
+ * gc.c (gc_call_finalizer_at_exit): call free proc for every Data
+ Wrapper, and finalizer for specified objects at termination.
+
+ * version.c (show_version): version format changed.
+
+ * regex.c (re_match): wrong match with non-greedy if they appear
+ more than once in regular expressions.
+
+ * sample/ruby-mode.el (ruby-expr-beg): forgot to handle modifiers.
+
+Mon Dec 8 19:00:15 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_puts): just put a newline if no argument given.
+
+ * ext/tcltklib/tcltklib.c (lib_mainloop): thread-aware tk handle
+ when $tk_thread_safe is set.
+
+ * ext/tcltklib/tcltklib.c (lib_mainloop): use Tcl_DoOneEvent()
+ instead of Tk_MainLoop().
+
+Mon Dec 6 07:11:16 1997 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * io.c (io_puts): core dumped without any argument.
+
+Fri Dec 5 18:17:17 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (mod_remove_method): remove (not undef) a method from the
+ class/module.
+
+ * variable.c (obj_remove_instance_variable): method to remove
+ instance variables.
+
+Thu Dec 4 13:50:29 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1b0 released.
+
+ * string.c (str_aref): called str_index for regexp.
+
+Mon Dec 1 15:24:41 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * compar.c (cmp_between): wrong comparison made.
+
+Wed Nov 26 18:18:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * lib/mkmf.rb: generate Makefile for extension modules out of ruby
+ source tree. use like `ruby -r mkmf extconf.rb'.
+
+ * numeric.c (fix2str): enlarge buffer to prevent overflow on some
+ machines.
+
+ * parse.y (here_document): wrong line number generated after here-doc.
+
+Fri Nov 21 13:17:12 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (yylex): skip multibyte characters in comments.
+
+Wed Nov 19 17:19:20 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (nil_to_a): nil.to_a => [].
+
+ * parse.y (call_args): wrong node generation.
+
+Tue Nov 18 10:13:08 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (Init_Array): Array#=== works as Array#include?
+
+ * regex.c (re_compile_pattern): insert initialize code for jump_n,
+ before entering loops.
+
+ * re.c (reg_search): does not save registers unless $& etc appear
+ in the script.
+
+Mon Nov 17 13:01:43 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (is_defined): add defined? check for receivers and
+ arguments for calls.
+
+ * re.c (reg_search): cache last match object.
+
+ * re.c (match_aref): $[0] etc. are available.
+
+Sat Nov 15 00:11:36 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (io_s_popen): "rb" detection
+
+Fri Nov 14 18:28:40 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (scan_once): returns whole match if the pattern does
+ not contain any parentheses.
+
+Thu Nov 13 14:39:06 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (str_sub): returns copy of the receiver string, even if
+ any substitution occurred.
+
+ * regex.c (re_compile_pattern): no-width match by (?=..), (?!..).
+
+Wed Nov 12 13:44:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * time.c: remove coerce from Time class.
+
+ * regex.c (re_match): non-greedy match by ??, *? +?, {n,m}?.
+
+Mon Nov 10 11:24:51 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): non-registering parens (?:..).
+
+ * regex.c (re_compile_pattern): new meta character \< (wordbeg)
+ and \> (wordend).
+
+ * regex.c (re_compile_pattern): embedded comment for regular
+ expression by (?#...).
+
+Fri Nov 7 16:58:24 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_pattern): perl5 regexp \A and \Z available.
+
+ * regex.c (re_compile_pattern): can expand compile stack dynamically.
+
+ * regex.c (PUSH_FAILURE_POINT): wrong compare condition.
+
+Wed Nov 2 16:00:00 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_sub_s): "".sub! "", "" => "\000"
+
+Fri Oct 31 15:52:10 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (assoc): keyword assoc like {fg->"black"}.
+
+Thu Oct 30 17:33:38 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_println): print with newline, which is not affected by
+ the values of $/ and $\.
+
+Thu Oct 30 16:54:01 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * string.c (str_chop_bang): "".chop caused SEGV.
+
+ * string.c (str_chomp_bang): method to chop out last newline.
+
+Mon Oct 27 13:49:13 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/extmk.rb.in: library may have pathname contains `.'
+
+ * eval.c (rb_rescue): should not protect SystemError.
+
+Fri Oct 24 10:58:53 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_s_with_open_stream): ensures to close stream.
+
+Thu Oct 23 11:17:44 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_errset): value of $stderr can be changed (to any IO
+ object).
+
+ * io.c (next_argv): $< can be anything that responds to `write'.
+
+ * file.c (file_s_with_open_file): ensures to close file.
+
+ * error.c (exception): create error under the current class/module.
+
+ * range.c (range_eqq): fixnum check for last needed too.
+
+Wed Oct 22 12:52:30 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/socket/socket.c: Socket::Constants added.
+
+ * file.c: File::Constants added for inclusion.
+
+ * array.c (ary_join): call ary_join() recursively for the 1st
+ array element.
+
+Mon Oct 20 12:18:29 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ruby.c (load_file): wrong condition for #! check with -x.
+
+ * file.c (file_s_dirname): did return "" for "/a".
+
+Fri Oct 17 14:29:09 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c: now works on alpha-linux.
+
+ * bignum.c (bigadd): some undefined side effect order assumed.
+
+Wed Oct 15 17:49:24 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * intern.h: function prototypes added.
+
+Mon Oct 13 16:54:18 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (rb_define_class_id): call superclass's `inherited'
+ method when making subclasses.
+
+ * parse.y (nextc): clear lex_lastline at the end of file.
+
+ * object.c (Init_Object): need to undef Class#append_features.
+
+ * eval.c (rb_eval): no warning on extending classes or modules.
+
+Thu Oct 9 11:17:50 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (error_print): the exception name follows after the error
+ message.
+
+ * eval.c (compile_error): error message slightly changed.
+
+ * parse.y (nextc): script parsing will be terminated by __END__ at
+ beginning of line.
+
+ * eval.c (compile_error): `__END__' is no longer a keyword.
+
+ * parse.y (nextc): protect lastline read from script stream.
+
+Tue Oct 7 14:06:06 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha9 released.
+
+ * eval.c (mod_append_features): renamed from extend_class.
+
+ * eval.c (rb_eval): defining method calls `method_added'.
+
+ * eval.c (ruby_options): exception while processing options must
+ terminate the interpreter.
+
+ * error.c (Init_Exception): wrong method configuration. `new'
+ should have been a singleton method.
+
+Mon Oct 6 18:55:38 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/kconv/kconv.c (kconv_guess): code to guess character code
+ from string.
+
+Mon Oct 6 18:38:17 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * pack.c: now encode/decode base64 by `m' template.
+
+Fri Oct 3 10:51:10 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * MANIFEST: needed to include lex.c in the distribution.
+
+ * eval.c (ruby_options): f_require() called too early.
+
+ * eval.c (rb_provide): module extensions should always be `.o'.
+
+Thu Oct 2 11:38:31 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha8 released.
+
+ * ext/marshal/marshal.c (r_object): remove temporal regist for
+ structs. (caused problem if structs form cycles.)
+
+ * parse.y (match_gen): static binding for match(=~) calls
+ with regexp literals.
+
+Wed Oct 1 15:26:55 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c: protect retval in struct tag from GC for C_ALLOCA.
+
+ * eval.c: no more pointer value from setjmp/longjmp.
+
+Wed Oct 1 14:01:49 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/marshal/marshal.c (w_byte): argument must be char.
+
+Wed Oct 1 10:30:22 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (mod_const_at): global constants now belongs to the
+ class Object.
+
+ * object.c (Init_Object): new global constant NIL.
+
+ * ext/marshal/marshal.c (marshal_dump): try to set binmode.
+
+ * ext/marshal/marshal.c (r_object): forgot to re-regist structs in
+ the object table.
+
+ * eval.c (ruby_options): call Init_ext() before any require()
+ calls by `-r'.
+
+Fri Sep 30 14:29:22 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/marshal/marshal.c (w_object): marshal dumped core.
+
+Tue Sep 30 10:27:39 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/test.rb: bignum test suits added.
+
+ * eval.c (rb_eval): new pseudo variable `true' and `false'.
+
+ * parse.y: new keywords `true' and `false' added.
+
+Mon Sep 29 13:37:58 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (forbid_setid): forbid some options in suid mode.
+
+ * ruby.h (NUM2DBL): new macro to convert into doubles.
+
+Mon Sep 27 09:53:48 1997 EGUCHI Osamu <eguchi@shizuokanet.or.jp>
+
+ * bignum.c: modified for speeding.
+
+Fri Sep 26 18:27:59 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * sample/from.rb: some extensions.
+
+Mon Sep 29 13:15:56 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (lhs): no more syntax error on `obj.CONSTANT = value'.
+
+Fri Sep 26 14:41:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (ruby_run): deferred calling Init_ext() just before eval_node.
+
+Fri Sep 26 13:27:24 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * io.c (io_isatty): forgot to return TRUE value.
+
+Fri Sep 25 11:10:58 1997 EGUCHI Osamu <eguchi@shizuokanet.or.jp>
+
+ * eval.c: use _setjmp/_longjmp instead of setjmp/longjmp on some
+ platforms.
+
+Wed Sep 24 17:43:13 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * string.c (Init_String): String#taint and String#taint? added.
+
+ * class.c (mod_ancestors): ancestors include the class itself.
+
+Wed Sep 24 00:57:00 1997 Katsuyuki Okabe <HGC02147@niftyserve.or.jp>
+
+ * X68000 patch.
+
+Tue Sep 23 20:42:30 1997 EGUCHI Osamu <eguchi@shizuokanet.or.jp>
+
+ * parse.y (node_newnode): SEGV on null node setup.
+
+Mon Sep 22 11:22:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (ruby_prog_init): wrong safe condition check.
+
+Sun Sep 21 14:46:02 1997 MAEDA shugo <shugo@po.aianet.ne.jp>
+
+ * error.c (exc_inspect): garbage added to classpath.
+
+Fri Sep 19 11:49:23 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (newtok): forgot to adjust buffer size when shrinking
+ the token buffer.
+
+ * enum.c (enum_find): rb_eval_cmd() does not return value.
+
+ * io.c (pipe_open): close fds on pipe exec. fcntl(fd, F_SETFD, 1)
+ no longer used.
+
+Tue Sep 16 17:54:25 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * file.c (f_test): problem if wrong command specified.
+
+ * ruby.c (ruby_prog_init): close stdaux and stdprn for MSDOS.
+
+ * ruby.c (ruby_prog_init): should not add path from environment
+ variable, if ruby is running under setuid.
+
+ * process.c (init_ids): check suid check for setuid/seteuid etc.
+
+Mon Sep 15 00:42:04 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * regex.c (re_compile_pattern): \w{3} and \W{3} did not work.
+
+Thu Sep 11 10:31:48 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha7 released.
+
+ * ext/socket/socket.c (sock_new): no setbuf() for NT.
+
+ * io.c (rb_fopen,rb_fdopen): set close-on-exec for every fd.
+
+Wed Sep 10 15:55:31 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ext/marshal/marshal.c (r_bytes0): extra big length check.
+
+Tue Sep 9 16:27:14 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (pipe_fptr_atexit): clean up popen()'ed fptr.
+
+ * error.c (set_syserr): some system has error code that is bigger
+ than sys_nerr. grrr.
+
+Mon Sep 8 18:33:33 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_s_new): dereferenced nil for optional mode.
+
+Fri Sep 5 10:26:03 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (class_instance_methods): do not include methods which
+ are changed to private in subclasses.
+
+Thu Sep 4 12:38:53 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (f_global_variables): list name of the global
+ variables.
+
+ * object.c (obj_id): returns unique integer.
+
+Wed Sep 3 14:05:16 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha6 released.
+
+ * eval.c (mod_s_constants): context sensitive constant list.
+
+ * variable.c (mod_constants): no more `all' option.
+
+ * variable.c (mod_const_of): the values for autoload classes are
+ their name strings.
+
+ * class.c (class_instance_methods): no special treatment for
+ singleton classes.
+
+ * object.c (obj_singleton_methods): returns list of singleton
+ method names.
+
+ * parse.y (yylex): no here document after `class' keyword.
+
+ * eval.c (f_load): expand path if fname begins with `~'.
+
+Tue Sep 2 13:19:48 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (ins_methods_i): do not list undef'ed methods.
+
+Mon Sep 1 13:42:48 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha5 released.
+
+ * object.c (mod_attr_reader): create methods to define attribute
+ reader/write/accessor.
+
+ * class.c (rb_define_attr): always defines accessors.
+
+ * eval.c (rb_call): alias occurred in the module body caused SEGV.
+
+ * parse.y: did not generate here document strings properly.
+
+Mon Sep 1 11:43:57 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * parse.y (yylex): heredoc dropped an extra character.
+
+Fri Aug 29 11:10:21 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * class.c (class_instance_methods): same method names should not
+ appear more than once.
+
+ * parse.y (yylex): spaces can follow =begin/=end.
+
+ * variable.c (find_class_path): look for class_tbl also for
+ unnamed fundamental classes, such as Object, String, etc.
+
+ * variable.c (rb_name_class): can't name class before String class
+ is initialized.
+
+ * inits.c (rb_call_inits): unrecognized dependency from GC to
+ Array.
+
+ * variable.c (find_class_path): could not find class if Object's
+ iv_tbl is NULL.
+
+Thu Aug 28 13:12:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha4 released.
+
+ * variable.c (mod_constants): wrong condition for singleton
+ class.
+
+ * parse.y (yylex): revised `=begin' skip code.
+
+ * parse.y (here_document): forgot to free(eos).
+
+ * parse.y (yylex): spaces after `<<' prohibited for here
+ documents to avoid confusing with operator `<<'.
+
+ * eval.c (is_defined): separated from rb_eval().
+
+Wed Aug 27 11:32:42 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha3 released.
+
+ * variable.c (mod_name): returns name of the class/module.
+
+ * parse.y (here_document): finally here document available now.
+
+ * variable.c (fc_i): some classes/modules does not have iv_tbl.
+
+ * variable.c (find_class_path): avoid infinite loop.
+
+Tue Aug 26 13:43:47 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (rb_eval): undef'ing non-existing method will raise
+ NameError exception.
+
+ * object.c (class_s_new): needed to create metaclass too.
+
+ * eval.c (error_print): no class name print for anonymous class.
+
+ * eval.c (rb_longjmp): proper exception raised if raise() called
+ without arguments, with $! or $@ set.
+
+ * object.c (Init_Object): superclass()'s method argument setting
+ was wrong again.
+
+ * class.c (mod_ancestors): list superclasses and included modules
+ in priority order.
+
+Mon Aug 25 11:53:11 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha2 released.
+
+ * sample/ruby-mode.el (ruby-parse-region): auto-indent now
+ supports "\\" in the strings.
+
+ * struct.c (struct_getmember): new API to get member value from C
+ language side.
+
+Sat Aug 23 21:39:05 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (assignable): remove unnecessary local variable
+ initialize by nil.
+
+Fri Aug 22 14:26:40 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (error_print): modified exception print format.
+
+Thu Aug 21 16:10:58 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * sample/ruby-mode.el (ruby-calculate-indent): wrong indent level
+ calculated with keyword operators.
+
+Thu Aug 21 11:36:58 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * parse.y (arg): ary[0] += 1 cause SEGV
+
+Wed Aug 20 17:28:50 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * ruby.c (ruby_process_options): require() all modules after
+ processing all options
+
+ * process.c (rb_proc_exec): more security checks added.
+
+ * process.c (rb_proc_exec): insecure path on exec.
+
+ * hash.c (f_getenv): PATH modification security check.
+
+Tue Aug 19 00:15:38 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha1 released.
+
+ * eval.c (mod_eval): work as normal eval() if second binding
+ argument given.
+
+ * eval.c (rb_call): did not raise ArgumentError if too many
+ arguments more than optional arguments (without rest arg).
+
+ * eval.c (rb_eval): did not work well for op_asgn2 (attribute
+ self assignment).
+
+ * eval.c (Init_Thread): returns main thread.
+
+Mon Aug 18 09:25:56 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (inspect_i): did not display T_DATA instance variables.
+
+ * parse.y: provides more accurate line number information.
+
+ * eval.c (thread_value): include value's backtrace information in
+ the variable `$@'.
+
+ * eval.c (f_abort): print backtrace and exit.
+
+Sat Aug 16 00:17:44 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (class_new_instance): do not make instance from virtual
+ classes.
+
+ * object.c (class_s_new): do not make subclass of singleton class.
+
+Fri Aug 15 15:49:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (call_trace_func): block context switch in the trace
+ function.
+
+ * eval.c (rb_eval): clear method cache at class extension.
+
+ * object.c (obj_type): returns object's class even if it defines
+ singleton methods.
+
+Fri Aug 15 19:40:43 1997 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
+
+ * ext/socket/socket.c (Init_socket): small typo caused SEGV.
+
+Wed Aug 13 17:51:46 1997 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * version 1.1 alpha0 released.
+
+Local variables:
+add-log-time-format: (lambda ()
+ (let* ((time (current-time))
+ (diff (+ (cadr time) 32400))
+ (lo (% diff 65536))
+ (hi (+ (car time) (/ diff 65536))))
+ (format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t)))
+indent-tabs-mode: t
+tab-width: 8
+end:
diff --git a/doc/NEWS b/doc/NEWS
new file mode 100644
index 0000000000..b4445fa59f
--- /dev/null
+++ b/doc/NEWS
@@ -0,0 +1,837 @@
+= command line options
+
+: -W option
+
+ new option to specify warning level. -W0 to shut up warnings, -W1 for normal level,
+ -W2 for verbose level. -w equals to -W2.
+
+= language syntax
+
+: arbitrary delimited string array
+
+ %W(...) notation, word list literal like %w(...) with the
+ exception that #{} interpolation is allowed.
+
+: arbitrary delimited symbol literl
+
+ :"foo", :"foo#{bar}", etc.
+
+: expression interpolation in strings
+
+ Now arbitrary statements are allowed inside #{} interpolation
+ without escapes. In other hand, they can no longer access to
+ variables defined in eval.
+
+: negative number literals
+
+ Digits preceded minus sign is a literal integer.
+
+: array expansion
+
+ Fixed with the following behavior:
+
+ a = *[1]
+ p a #=> [1]
+
+ Now 1-element array in rhs is expanded properly.
+
+ a = *[1]
+ p a #=> 1
+
+: break and next
+
+ Extended to take an optional expression, which is used as a value
+ for termination.
+
+: direct assignment to Foo::Bar is allowed
+
+ also, you can define "class Foo::Bar; end".
+
+= language core
+
+: $stdin, $stdout, $stderr
+
+ can be assignable again. the original stdio are preserved as STDIN,
+ STDOUT, STDERR.
+
+: $VERBOSE now has 3 levels
+
+ nil - silence, false - medium (default), true - verbose
+
+: allocation framework
+
+ any instance of class can be allocated by class.allocate,
+ (except for a few classes).
+
+: comparison of exception classes in a rescue clause
+
+ changed to use Module#=== for comparing $! with the exception
+ class specified in each rescue clause.
+
+ as the previous behavior was to use kind_of?, the effect is limited
+ to the SystemCallError case. SystemCallError.=== has been newly
+ defined to return true when the two have the same errno. With this
+ change, SystemCallError's with the same errno, such as Errno::EAGAIN
+ and Errno::EWOULDBLOCK, can both be rescued by listing just one of
+ them.
+
+: constants lookup
+
+ improved at the performance of searching by using an internal hash
+ table.
+
+ calls const_missing method of the class/module, if constant is not
+ found in the look up path.
+
+: expression parenthesis in the first argument
+
+ altered to get the following code (note the space after p):
+
+ p ("xx"*2).to_i
+
+ Interpreted as:
+
+ p (("xx"*2).to_i)
+
+ Instead of:
+
+ (p("xx"*2)).to_i
+
+: implicit comparison in conditional expressions
+
+ Obsoleted except when it is used in -e.
+
+ : between Range and $.
+ Use explicit comparison instead.
+
+ : between Regexp and $_
+ Use the unary method ~/re/ instead.
+
+: to_str
+
+ added to get objects which define to_str() treated as String's.
+
+ now almost all the built-in methods try each argument with to_str()
+ when they expect it to be a String.
+
+ foo = Object.new
+ class <<foo
+ def to_str
+ "foo"
+ end
+ end
+ p File.open(foo)
+ => -:7:in `open': wrong argument type Object (expected String) (TypeError)
+ ruby 1.6.4 (2001-04-19) [i586-linux]
+ => -:7:in `open': No such file or directory - "foo" (Errno::ENOENT)
+ ruby 1.7.0 (2001-05-02) [i586-linux]
+
+: multiple assignment behavior
+
+ Fixed so that "*a = nil" results in "a == []".
+
+= changes in core class library
+
+: open
+
+ Extended so that when the third argument is permission flags it
+ calls open(2) instead of fopen(3).
+
+: sprintf
+
+ new format specifier "%p" is available.
+
+: lambda and proc
+
+ Proc object returns from these methods has the following attributes:
+
+ * strict argument number check
+ * break and return terminates the proc execution.
+
+: warn(message)
+
+ a method to give warnings.
+
+: abort()
+
+ takes optional terminate message argument.
+
+: Object#initialize_copy
+
+ copy constructor for clone and dup.
+
+: Object#instance_variable_set, Object#instance_variable_get
+
+ added.
+
+: Object#singleton_method_removed
+: Object#singleton_method_undefined
+
+ Added.
+
+: Array#transpose
+
+ added.
+
+: Array#fetch(index [, default])
+
+ Added. If a default value isn't given, raises index error if index
+ is out of range.
+
+: Array#insert(n, other, ...)
+
+ Added. [ruby-talk:14289]
+
+ This is much the same as (({ary[n,0] = [other,...]})) except
+ returing self.
+
+ ary = [0,1,2,3]
+ ary[2, 0] = [4, 5, 6]
+ p ary
+
+ ary = [0,1,2,3]
+ ary.insert(2, 4, 5, 6)
+ p ary
+
+: Array#sort!
+
+ Changed to always return self without checking whether the sequence
+ of the elements was modified or not.
+
+ Beware that this behavior is not guaranteed to continue in the
+ future. Do not rely on its return value. [ruby-dev:12506]
+
+: Array#filter
+
+ Previously deprecated, now removed. Use Array#collect!.
+
+: Array#pack, String#unpack
+
+ Allows comment in template strings.
+
+: Array#pack, String#unpack
+
+ New templates 'q' and 'Q' for 64bit integer (signed and unsigned respectively).
+
+: Array#new
+
+ Now takes block to fill initial values. E.g.
+
+ Array.new(10) { |i| i + 1 }
+ => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+
+: Array#fill
+
+ Takes block to get the values to fill.
+
+: Array#fetch
+
+ Takes block to get the default value.
+
+: Array#zip
+
+ added.
+
+: Hash#update
+
+ Takes block to resolve key conflict.
+
+: Hash#merge and Hash#merge!
+
+ update hash. Hash#merge! is a synonym of Hash#update.
+
+: String#split
+
+ if "sep" argument is a string, regular expression meta characters
+ are escaped internally.
+
+: String#rstrip
+
+ chop off NULs at the end of strings.
+
+: String#to_i
+
+ Now accepts optional base argument.
+
+ "101".to_i(10) => 101
+ "101".to_i(2) => 5
+ "101".to_i(8) => 65
+ "101".to_i(16) => 257
+
+ A base argument of 0 guesses at the base.
+
+ "101".to_i(0) => 101
+ "0b101".to_i(0) => 5
+ "0101".to_i(0) => 65
+ "0x101".to_i(0) => 257
+
+: String#[regexp, nth]
+
+ Extended to accepts optional second argument.
+
+ It tries match between self and REGEXP, then returns the
+ content of the NTH regexp register.
+
+: String#casecmp
+
+ Added. This is a case insensitive version of String#<=>.
+
+: String#chomp
+
+ If $/ == "\n", chops off last newlines (any of \n, \r, \r\n).
+
+: String#eql?
+
+ Changed to be always case sensitive.
+
+: String#insert(n, other)
+
+ Added.
+
+ This is much the same as (({str[n, 0] = other})) except returing
+ self.
+
+: String#lstrip, rstrip, lstrip!, rstrip!
+
+ Added. These strip only left or right part of a string.
+
+: String#match
+
+ Added.
+
+: String/Array methods
+
+ Returns an instance of receivers class.
+
+: String.new
+
+ The first argument becomes optional.
+
+: Symbol#intern
+
+ Added.
+
+: Symbol.all_symbols
+
+ Added. [ruby-dev:12921]
+
+: IO
+
+ 64bit off_t support by Janathan Baker.
+
+: IO#read
+: IO#sysread
+
+ takes optinal second argument for read buffer.
+
+: IO::sysopen
+
+ New method to get a raw file descriptor.
+
+: IO#sysseek
+
+ Added.
+
+: IO#fsync
+
+ new method that copies all in-memory parts of a file to disk and
+ waits until the device reports that all parts are on stable storage.
+ Implemented with fsync(2) or equivalent.
+
+: IO.open
+
+ Made public. Can only associate an IO object with a file number
+ like IO.new and IO.for_fd, but can take a block.
+
+: IO.for_fd
+
+ Added as a synonym for IO.new.
+
+: IO.read
+
+ Added. Like IO.readlines, except it returns the entire file as a
+ string. [ruby-talk:9460]
+
+: File#fnmatch, File::Constants::FNM_*
+
+ Added. Refer to the fnmatch(3) manpage for details.
+
+ Localism is FNM_DOTMATCH which has the opposite meaning of the
+ commonly known FNM_PERIOD, which does not exist in Ruby.
+
+ e.g.
+
+ # exclude files matching "*.bak" case-insensitively.
+ files.reject! {|fn| File.fnmatch?("*.bak", fn, File::FNM_CASEFOLD) }
+
+: File.lchmod
+: File.lchown
+
+ Added.
+
+: File.open, IO.open
+
+ File mode can be specified by flags like open(2),
+ e.g. File::open(path, File::CREAT|File::WRONLY).
+
+: Regexp#options
+
+ Added.
+
+: Regexp.last_match(n)
+
+ Extended to take an optional argument.
+
+: MatchData#captures
+
+ added.
+
+: Dir#path
+
+ Added.
+
+: Dir.chdir
+
+ Extended to take a block.
+
+: Dir.glob
+
+ Made to support meta-character escaping by a backslash. Wildcards
+ and spaces may now be escaped using a backslash.
+
+: Dir.open
+
+ Changed to return what the block returns when a block is given, just
+ as File.open does. (It always returned (({nil})) in 1.6 and
+ prior)
+
+: Dir.chdir
+
+ Changed to warn only when invoked from multiple threads or no block
+ is given. [ruby-dev:13823]
+
+ Dir.chdir('foo') {
+ Dir.chdir('bar') { # previously warned
+ puts Dir.pwd
+ }
+ }
+
+: Dir#pos=
+
+ Returns the new position instead of self.
+
+: Dir::glob
+
+ Now accepts optional FNM_* flags via the second argument, whereas
+ Dir::[] doesn't.
+
+ Dir.glob("makefile", File::FNM_CASEFOLD) #=> ['Makefile', 'makefile']
+
+: Class#inherited
+
+ Method is called when Class is inherited by another class.
+
+ class A; end
+ def A.inherited(by)
+ puts "A inherited by #{by.inspect}"
+ end
+ class B < A; end
+
+ Prints out "A inherited by B"
+
+: Module#include?
+
+ Added. [ruby-dev:13941]
+
+: Module#included
+
+ Added. This is a hook called after Module#append_feature.
+
+: Module#method_removed
+: Module#method_undefined
+
+ Added.
+
+: Module.new, Class.new
+
+ Extended to take block.
+
+: Time
+
+ Extended to accept a negative time_t. (Only when the platform
+ supports it)
+
+ p Time.at(-1)
+ => Thu Jan 01 08:59:59 JST 1970
+
+: Time#to_a
+: Time#zone
+
+ Made to return "UTC" under gmtime. It used to return a platform
+ dependent value, typically "GMT", in 1.6 and prior.
+
+: Marshal to use marshal_dump and marshal_load
+
+ if a dumping object responds to 'marshal_dump', Marshal.dump calls
+ it, and dumps object returned. Marshal.load allocates a new instance
+ using "allocate", then calls its "marshal_load" with dumped data.
+ Marshal format version is now 4.8 (was 4.6 in 1.6.8).
+
+: Marshal
+
+ Fixed not to dump anonymous classes/modules.
+
+ Fixed with loading modules.
+
+: Thread#group
+
+ new method to get belonging ThreadGroup.
+
+: Thread#terminate
+
+ synonym of Thread#exit
+
+: Thread#join
+
+ Optional argument limits maximum time to wait the thread in second.
+ And returns nil if timed out.
+
+: ThreagGroup#enclose
+
+ prohibits thread movement from/to enclosed groups.
+
+: Range#step([step=1])
+
+ Added.
+
+: SystemCallError
+
+ SystemCallError's "===" match (used in rescue also) is now based on its errno.
+
+: Interrupt
+
+ Made a subclass of SignalException. (It was a subclass of
+ Exception in 1.6 and prior)
+
+: NameError and NoMethodError
+
+ Moved and now NoMethodError < NameError < StandardError.
+
+: NoMethodError
+
+ Added. [ruby-dev:12763]
+
+: NotImplementError
+
+ Finally obsoleted. Use NotImplementedError.
+
+: SystemCallError.===
+
+ Added. (See the "Comparison of exception classes in a rescue clause"
+ paragraph above) [ruby-dev:12670]
+
+: SystemExit#status
+
+ Added.
+
+: Proc#==
+
+ Added.
+
+: Method#==
+
+ Added.
+
+: UnboundMethod is no longer subclass of Method
+
+ class hierarchy changed.
+
+: Enumerable#all?
+: Enumerable#any?
+: Enumerable#inject
+: Enumerable#sort_by
+
+ Added.
+
+: Math.acos(x)
+: Math.asin(x)
+: Math.atan(x)
+: Math.cosh(x)
+: Math.hypot(x,y)
+: Math.sinh(x)
+: Math.tanh(x)
+
+ Added.
+
+: Process.abort
+: Process.exit
+
+ synonym of Kernel#abort, and Kernel#exit respectively.
+
+: Process::detach(pid)
+
+ new method to detach child process. child process will be "wait"ed
+ automagically.
+
+: Process.times
+
+ Moved from Time.times. (Time.times still remains but emits a
+ warning)
+
+: Process.waitall
+
+ Added.
+
+: Process::Status
+
+ Added. (({$?})) is now an instance of this class.
+
+: Process::UID, Process::GID, Process::Sys,
+
+ Added.
+
+: Signal
+
+ Added. This module has module functions Signal.trap and Signal.list.
+
+= changes in bundled libraries
+
+: lib/cgi.rb
+
+ cgi[name] returns CGI::QueryExtension::Value that wraps string
+ value, no longer array.
+
+: lib/timeout
+
+ timeout "function" wrapped in Timeout module.
+
+: TCPServer#accept, UNIXServer#accept, Socket#accept
+
+ New methods to return an accepted socket fd.
+
+: Date and DateTime
+
+ lib/date.rb now provides both Date and DateTime.
+
+ Some methods have been renamed. But the old names are still alive.
+
+ Some new methods have been added (Date::parse, Date#strftime, etc.).
+
+ Date#mjd now returns the chronological modified Julian day number.
+
+ All facilities about tjd have been removed.
+
+: Curses
+
+ Updated. New methods and constants for using the mouse, character
+ attributes, colors and key codes have been added.
+
+: Net::HTTP
+
+ New version of Net::HTTP has introduced seriously incompatible
+ changes. For details, see document embedded in net/http.rb itself.
+
+: Socket.pack_sockaddr_in, Socket.unpack_sockaddr_in
+
+ Added. Utility for direct Socket access.
+
+: Socket.pack_sockaddr_un, Socket.unpack_sockaddr_un
+
+ Added. Utility for direct Socket access.
+
+: TCPServer#listen, UNIXServer#listen
+
+ Added.
+
+: TCPSocket.new
+: TCPSocket.open
+
+ Extended to take an address and a port number for the local side in
+ optional 3rd and 4th arguments.
+
+= newly bundled library
+
+: ext/bigdecimal
+
+ variable precision decimal number
+
+: ext/dl
+
+ an interface to the dynamic linker.
+
+: ext/enumerator
+
+ a helper module for the Enumerable interface.
+
+: ext/io/wait
+
+ IO wait methods.
+
+: ext/iconv
+
+ wrapper library of (({iconv})).
+
+: ext/openssl
+
+ OpenSSL for Ruby
+
+: ext/racc/cparse
+
+ Racc runtime library in C. (Racc is a parser generator for ruby)
+
+: ext/stringio
+
+ Pseudo (({IO})) class from/to (({String})).
+
+: ext/strscan
+
+ Fast string scanner library.
+
+: ext/syck
+
+ fast YAML parser.
+
+: lib/abbrev
+
+ creates an abbreviation table from a list
+
+: lib/benchmark
+
+ Ruby scripts benchmarker
+
+: lib/cgi/session/pstore
+
+ cgi/session back-end using pstore
+
+: lib/csv
+
+ reads/writes CSV files.
+
+: lib/date/format
+
+ strftime for Date class
+
+: lib/drb
+
+ dRuby or distributed Ruby
+
+: lib/fileutils
+
+ file utility library.
+
+: lib/generator
+
+ converts an internal iterator to an external iterator
+
+: lib/gserver
+
+ generic server used by xmlrpc
+
+: lib/ipaddr
+
+ manipulates IP address.
+
+: lib/multi-tk
+
+ to allow safe Tk, etc.
+
+: lib/open-uri
+
+ easy-to-use wrapper for net/http and net/ftp
+
+: lib/optparse
+
+ command line options utility library
+
+: lib/pathname
+
+ handles pathname in OO manner.
+
+: lib/pp
+
+ prettyprinter for Ruby objects
+
+: lib/prettyprint
+
+ implements prettyprint algorithm.
+
+: lib/profiler
+
+ library to implement -r "profile"
+
+: lib/racc/parser
+
+ RACC parser generator runtime in Ruby.
+
+: lib/scanf
+
+ scan string and retrieve object with format
+
+: lib/set
+
+ Set class
+
+: lib/runit
+
+ RubyUnit compatible layer for test/unit
+
+: lib/test/unit
+
+ unit testing framework for Ruby
+
+: lib/tmpdir
+
+ get temporary directory path.
+
+: lib/tsort
+
+ topological sorting library.
+
+: lib/rexml
+
+ REXML XML library
+
+: lib/webrick
+
+ generic internet server kit
+
+: lib/xmlrpc
+
+ simple RPC via XML
+
+: lib/un
+
+ used like 'ruby -run -e cp -- -p foo bar'. neat, isn't it?
+
+: lib/win32/registry
+
+ win32/registry is registry accessor
+
+: lib/yaml
+
+ YAML Ain't Mark-up Language
+
+= removed libraries
+
+: lib/ftplib
+
+ use net/ftp instead.
+
+: lib/telnet
+
+ use net/telnet instead.
+
+= new port
+
+: WindowsCE port
+: Win32 BCC
+
+= interpreter implementation
+
+: garbage collector
+
+ faster, but uses more memory for the worst case.
+
+: string concatenation
+
+ faster by avoiding too frequent realloc(3).
diff --git a/doc/forwardable.rd b/doc/forwardable.rd
new file mode 100644
index 0000000000..7272c374b6
--- /dev/null
+++ b/doc/forwardable.rd
@@ -0,0 +1,84 @@
+ -- forwardable.rb
+
+ $Release Version: 1.1 $
+ $Revision$
+ $Date$
+ Original version by Tosh
+
+=begin
+
+= Forwardable
+
+A Module to define delegations for selected methods to a class.
+
+== Usage
+
+Using through extending the class.
+
+ class Foo
+ extend Forwardable
+
+ def_delegators("@out", "printf", "print")
+ def_delegators(:@in, :gets)
+ def_delegator(:@contents, :[], "content_at")
+ end
+ f = Foo.new
+ f.printf ...
+ f.gets
+ f.content_at(1)
+
+== Methods
+
+--- Forwardable#def_instance_delegators(accessor, *methods)
+
+ adding the delegations for each method of ((|methods|)) to
+ ((|accessor|)).
+
+--- Forwardable#def_instance_delegator(accessor, method, ali = method)
+
+ adding the delegation for ((|method|)) to ((|accessor|)). When
+ you give optional argument ((|ali|)), ((|ali|)) is used as the
+ name of the delegation method, instead of ((|method|)).
+
+--- Forwardable#def_delegators(accessor, *methods)
+
+ the alias of ((|Forwardable#def_instance_delegators|)).
+
+--- Forwardable#def_delegator(accessor, method, ali = method)
+
+ the alias of ((|Forwardable#def_instance_delegator|)).
+
+= SingleForwardable
+
+a Module to define delegations for selected methods to an object.
+
+== Usage
+
+Using through extending the object.
+
+ g = Goo.new
+ g.extend SingleForwardable
+ g.def_delegator("@out", :puts)
+ g.puts ...
+
+== Methods
+
+--- SingleForwardable#def_singleton_delegators(accessor, *methods)
+
+ adding the delegations for each method of ((|methods|)) to
+ ((|accessor|)).
+
+--- SingleForwardable#def_singleton_delegator(accessor, method, ali = method)
+
+ adding the delegation for ((|method|)) to ((|accessor|)). When
+ you give optional argument ((|ali|)), ((|ali|)) is used as the
+ name of the delegation method, instead of ((|method|)).
+
+--- SingleForwardable#def_delegators(accessor, *methods)
+
+ the alias of ((|SingleForwardable#def_instance_delegators|)).
+
+--- SingleForwardable#def_delegator(accessor, method, ali = method)
+
+ the alias of ((|SingleForwardable#def_instance_delegator|)).
+=end
diff --git a/doc/forwardable.rd.ja b/doc/forwardable.rd.ja
new file mode 100644
index 0000000000..d928fddc5e
--- /dev/null
+++ b/doc/forwardable.rd.ja
@@ -0,0 +1,81 @@
+ -- forwatable.rb
+ $Release Version: 1.1 $
+ $Revision$
+ $Date$
+
+=begin
+= Forwardable
+
+¥¯¥é¥¹¤ËÂФ·¥á¥½¥Ã¥É¤Î°Ñ¾ùµ¡Ç½¤òÄêµÁ¤·¤Þ¤¹.
+
+== »È¤¤Êý
+
+¥¯¥é¥¹¤ËÂФ·¤Æextend¤·¤Æ»È¤¤¤Þ¤¹.
+
+ class Foo
+ extend Forwardable
+
+ def_delegators("@out", "printf", "print")
+ def_delegators(:@in, :gets)
+ def_delegator(:@contents, :[], "content_at")
+ end
+ f = Foo.new
+ f.printf ...
+ f.gets
+ f.content_at(1)
+
+== ¥á¥½¥Ã¥É
+
+--- Forwardable#def_instance_delegators(accessor, *methods)
+
+ ((|methods|))¤ÇÅϤµ¤ì¤¿¥á¥½¥Ã¥É¤Î¥ê¥¹¥È¤ò((|accessor¤Ë|))°Ñ¾ù¤¹¤ë
+ ¤è¤¦¤Ë¤·¤Þ¤¹.
+
+--- Forwardable#def_instance_delegator(accessor, method, ali = method)
+
+ ((||method|))¤ÇÅϤµ¤ì¤¿¥á¥½¥Ã¥É¤ò((|accessor|))¤Ë°Ñ¾ù¤¹¤ë¤è¤¦¤Ë¤·
+ ¤Þ¤¹. ((|ali|))¤¬°ú¿ô¤È¤·¤ÆÅϤµ¤ì¤¿¤È¤­¤Ï, ¥á¥½¥Ã¥É((|ali|))¤¬¸Æ¤Ð
+ ¤ì¤¿¤È¤­¤Ë¤Ï, ((|accessor|))¤ËÂФ·((|method|))¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹.
+
+--- Forwardable#def_delegators(accessor, *methods)
+
+ ((|Forwardable#def_instance_delegators|))¤ÎÊÌ̾¤Ç¤¹.
+
+--- Forwardable#def_delegator(accessor, method, ali = method)
+
+ ((|Forwardable#def_instance_delegator|))¤ÎÊÌ̾¤Ç¤¹.
+
+= SingleForwardable
+
+¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ·, ¥á¥½¥Ã¥É¤Î°Ñ¾ùµ¡Ç½¤òÄêµÁ¤·¤Þ¤¹.
+
+== »È¤¤Êý
+
+¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ·¤Æ((|extend|))¤·¤Æ»È¤¤¤Þ¤¹.
+
+ g = Goo.new
+ g.extend SingleForwardable
+ g.def_delegator("@out", :puts)
+ g.puts ...
+
+== ¥á¥½¥Ã¥É
+
+--- SingleForwardable#def_singleton_delegators(accessor, *methods)
+
+ ((|methods|))¤ÇÅϤµ¤ì¤¿¥á¥½¥Ã¥É¤Î¥ê¥¹¥È¤ò((|accessor|))¤Ë°Ñ¾ù¤¹¤ë
+ ¤è¤¦¤Ë¤·¤Þ¤¹.
+
+--- SingleForwardable#def_singleton_delegator(accessor, method, ali = method)
+
+ ((|method|))¤ÇÅϤµ¤ì¤¿¥á¥½¥Ã¥É¤ò((|accessor|))¤Ë°Ñ¾ù¤¹¤ë¤è¤¦¤Ë¤·¤Þ
+ ¤¹. ((|ali|))¤¬°ú¿ô¤È¤·¤ÆÅϤµ¤ì¤¿¤È¤­¤Ï, ¥á¥½¥Ã¥É((|ali|))¤¬¸Æ¤Ð¤ì
+ ¤¿¤È¤­¤Ë¤Ï, ((|accessor|))¤ËÂФ·((|method|))¤ò¸Æ¤Ó½Ð¤·¤Þ¤¹.
+
+--- SingleForwardable#def_delegators(accessor, *methods)
+
+ ((|SingleForwardable#def_singleton_delegators|))¤ÎÊÌ̾¤Ç¤¹.
+
+--- SingleForwardable#def_delegator(accessor, method, ali = method)
+
+ ((|SingleForwardable#def_singleton_delegator|))¤ÎÊÌ̾¤Ç¤¹.
+=end
diff --git a/doc/irb/irb-tools.rd.ja b/doc/irb/irb-tools.rd.ja
new file mode 100644
index 0000000000..64d9ab29c8
--- /dev/null
+++ b/doc/irb/irb-tools.rd.ja
@@ -0,0 +1,185 @@
+irb´ØÏ¢¤ª¤Þ¤±¥³¥Þ¥ó¥É¤È¥é¥¤¥Ö¥é¥ê
+ $Release Version: 0.7.1 $
+ $Revision$
+ $Date$
+ by Keiju ISHITSUKA(Nihon Rational Co.,Ltd.)
+
+=begin
+
+:¥³¥Þ¥ó¥É:
+* rtags -- ruby tags command
+
+:´Ø¿ô¥é¥¤¥Ö¥é¥ê:
+* xmp -- irb version of gotoken xmp-function
+
+:¥¯¥é¥¹¥é¥¤¥Ö¥é¥ê:
+* frame.rb -- frame tracer
+* completion.rb -- irb completor
+
+= rtags
+
+rtags¤ÏemacsµÚ¤ÓviÍѤÎ, TAG¥Õ¥¡¥¤¥ë¤ò¤Ä¤¯¤ë¥³¥Þ¥ó¥É¤Ç¤¹.
+
+== »È¤¤Êý
+
+ rtags [-vi] file....
+
+¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤ËemacsÍѤÎTAGS¥Õ¥¡¥¤¥ë¤¬¤Ç¤­¤Þ¤¹. -vi¥ª¥×¥·¥ç¥ó¤ò
+¤Ä¤±¤¿»þ¤Ë¤ÏviÍѤÎtags¥Õ¥¡¥¤¥ë¤òºîÀ®¤·¤Þ¤¹.
+
+emacs¤Î¾ì¹ç, Ä̾ï¤Îetags.el¤¬¤½¤Î¤Þ¤Þ»È¤¨¤Þ¤¹. ¸¡º÷²Äǽ¤Ê¤Î¤Ï,
+
+* ¥¯¥é¥¹
+* ¥á¥½¥Ã¥É
+* ÆÃ°Û¥á¥½¥Ã¥É
+* alias
+* attr¤ÇÀë¸À¤µ¤ì¤¿¥¢¥¯¥»¥µ(¥Ñ¥é¥á¡¼¥¿¤¬¥·¥ó¥Ü¥ë¤«Ê¸»úÎó¥ê¥Æ¥é¥ë¤Ë¸Â¤ë)
+* attr_XXX¤ÇÀë¸À¤µ¤ì¤¿¥¢¥¯¥»¥µ(¥Ñ¥é¥á¡¼¥¿¤¬¥·¥ó¥Ü¥ë¤«Ê¸»úÎó¥ê¥Æ¥é¥ë¤Ë¸Â¤ë)
+
+¤Ç¤¹.
+
+C¤Ê¤É¤Ç»È¤Ã¤Æ¤¤¤ë¤Î¤È°ã¤¦¤Î¤Ï, ¥³¥ó¥×¥ê¡¼¥·¥ç¥ó¤Ë´Ø¤¹¤ëÉôʬ¤Ç,
+
+´Ø¿ô̾¤Ï,
+
+ ´Ø¿ô̾(
+
+¥¯¥é¥¹¤Ï,
+
+ ::¥¯¥é¥¹Ì¾::....::¥¯¥é¥¹Ì¾
+
+¥á¥½¥Ã¥É¤Ï,
+
+ ::¥¯¥é¥¹Ì¾::....::¥¯¥é¥¹Ì¾#¥á¥½¥Ã¥É̾
+
+ÆÃ°Û¥á¥½¥Ã¥É(¥¯¥é¥¹¥á¥½¥Ã¥É)¤Ï
+
+ ::¥¯¥é¥¹Ì¾::....::¥¯¥é¥¹Ì¾.¥á¥½¥Ã¥É̾
+
+¤Ç¥³¥ó¥×¥ê¡¼¥·¥ç¥ó¤ò¹Ô¤Ê¤¦¤È¤³¤í¤Ç¤¹.
+
+= xmp.rb
+
+¤´¤È¤±¤óxmp¤Î¾å°Ì¸ß´¹¥Ð¡¼¥¸¥ç¥ó¤Ç¤¹. ¤¿¤À, Èó¾ï¤Ë½Å¤¤¤Î¤Ç¤´¤È¤±¤óxmp¤Ç
+¤ÏÂбþ¤Ç¤­¤Ê¤¤»þ¤Ë, »ÈÍѤ¹¤ë¤ÈÎɤ¤¤Ç¤·¤ç¤¦.
+
+== »È¤¤Êý
+
+=== ´Ø¿ô¤È¤·¤Æ»È¤¦.
+
+ require "irb/xmp"
+ xmp <<END
+ foo = 1
+ foo
+ END
+ ---
+ foo = 1
+ ==>1
+ foo
+ ==>1
+
+=== XMP¥¤¥ó¥¹¥¿¥ó¥¹¤òÍѤ¤¤ë.
+
+¤³¤Î¾ì¹ç¤Ï, XMP¤¬¥³¥ó¥Æ¥­¥¹¥È¾ðÊó¤ò»ý¤Ä¤Î¤Ç, ÊÑ¿ô¤ÎÃͤʤɤòÊÝ»ý¤·¤Æ¤¤
+¤Þ¤¹.
+
+ require "irb/xmp"
+ xmp = XMP.new
+ xmp.puts <<END
+ foo = 1
+ foo
+ END
+ xmp.puts <<END
+ foo
+ END
+ ===
+ foo = 1
+ ==>1
+ foo
+ ==>1
+ foo
+ ==>1
+
+== ¥³¥ó¥Æ¥­¥¹¥È¤Ë´Ø¤·¤Æ
+
+XMP¥á¥½¥Ã¥É·²¤Î¥³¥ó¥Æ¥­¥¹¥È¤Ï, ¸Æ¤Ó½Ð¤¹Á°¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤µ¤ì¤Þ¤¹.
+ÌÀ¼¨Åª¤Ë¥³¥ó¥Æ¥­¥¹¥È¤ò»ØÄꤹ¤ë¤È¤½¤Î¥³¥ó¥Æ¥­¥¹¥È¤Çɾ²Á¤·¤Þ¤¹.
+
+Îã:
+
+ xmp "foo", an_binding
+
+:Ãí:
+¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ë¤ÏÂбþ¤·¤Æ¤¤¤Þ¤»¤ó.
+
+= frame.rb
+¸½ºß¼Â¹ÔÃæ¤Î¥Õ¥ì¡¼¥à¾ðÊó¤ò¼è¤ê°·¤¦¤¿¤á¤Î¥¯¥é¥¹¤Ç¤¹.
+
+* IRB::Frame.top(n = 0)
+ ¾å¤«¤énÈÖÌܤΥ³¥ó¥Æ¥­¥¹¥È¤ò¼è¤ê½Ð¤·¤Þ¤¹. n¤Ï0¤¬ºÇ¾å°Ì¤Ë¤Ê¤ê¤Þ¤¹.
+* IRB::Frame.bottom(n = 0)
+ ²¼¤«¤énÈÖÌܤΥ³¥ó¥Æ¥­¥¹¥È¤ò¼è¤ê½Ð¤·¤Þ¤¹. n¤Ï0¤¬ºÇ²¼°Ì¤Ë¤Ê¤ê¤Þ¤¹.
+* IRB::Frame.sender
+ ¥»¥ó¥À¤Ë¤Ê¤Ã¤Æ¤¤¤ë¥ª¥Ö¥¸¥§¥¯¥È¤ò¼è¤ê½Ð¤·¤Þ¤¹. ¥»¥ó¥À¤È¤Ï, ¤½¤Î¥á¥½¥Ã
+ ¥É¤ò¸Æ¤Ó½Ð¤·¤¿Â¦¤Îself¤Î¤³¤È¤Ç¤¹.
+
+:Ãí:
+set_trace_func¤òÍѤ¤¤ÆRuby¤Î¼Â¹Ô¤ò¥È¥ì¡¼¥¹¤·¤Æ¤¤¤Þ¤¹. ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ë
+¤ÏÂбþ¤·¤Æ¤¤¤Þ¤»¤ó.
+
+= completion.rb
+irb¤Îcompletionµ¡Ç½¤òÄ󶡤¹¤ë¤â¤Î¤Ç¤¹.
+
+== »È¤¤Êý
+
+ % irb -r irb/completion
+
+¤È¤¹¤ë¤«, ~/.irbrc Ãæ¤Ë
+
+ require "irb/completion"
+
+¤òÆþ¤ì¤Æ¤¯¤À¤µ¤¤. irb¼Â¹ÔÃæ¤Ë require "irb/completion" ¤·¤Æ¤â¤è¤¤¤Ç¤¹.
+
+irb¼Â¹ÔÃæ¤Ë (TAB) ¤ò²¡¤¹¤È¥³¥ó¥×¥ì¡¼¥·¥ç¥ó¤·¤Þ¤¹.
+
+¥È¥Ã¥×¥ì¥Ù¥ë¤Ç(TAB)¤ò²¡¤¹¤È¤¹¤Ù¤Æ¤Î¹½Ê¸Í×ÁÇ, ¥¯¥é¥¹, ¥á¥½¥Ã¥É¤Î¸õÊ䤬¤Ç
+¤Þ¤¹. ¸õÊ䤬ͣ°ì¤Ê¤é¤Ð´°Á´¤ËÊä´°¤·¤Þ¤¹.
+
+ irb(main):001:0> in
+ in inspect instance_eval
+ include install_alias_method instance_of?
+ initialize install_aliases instance_variables
+ irb(main):001:0> inspect
+ "main"
+ irb(main):002:0> foo = Object.new
+ #<Object:0x4027146c>
+
+ ((|ÊÑ¿ô̾.|))¤Î¸å¤Ë(TAB)¤ò²¡¤¹¤È, ¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î¥á¥½¥Ã¥É°ìÍ÷¤¬¤Ç¤Þ
+ ¤¹.
+
+ irb(main):003:0> foo.
+ foo.== foo.frozen? foo.protected_methods
+ foo.=== foo.hash foo.public_methods
+ foo.=~ foo.id foo.respond_to?
+ foo.__id__ foo.inspect foo.send
+ foo.__send__ foo.instance_eval foo.singleton_methods
+ foo.class foo.instance_of? foo.taint
+ foo.clone foo.instance_variables foo.tainted?
+ foo.display foo.is_a? foo.to_a
+ foo.dup foo.kind_of? foo.to_s
+ foo.eql? foo.method foo.type
+ foo.equal? foo.methods foo.untaint
+ foo.extend foo.nil?
+ foo.freeze foo.private_methods
+
+=end
+
+% Begin Emacs Environment
+% Local Variables:
+% mode: text
+% comment-column: 0
+% comment-start: "%"
+% comment-end: "\n"
+% End:
+%
+
diff --git a/doc/irb/irb.rd b/doc/irb/irb.rd
new file mode 100644
index 0000000000..a42cd46680
--- /dev/null
+++ b/doc/irb/irb.rd
@@ -0,0 +1,392 @@
+irb -- interactive ruby
+ $Release Version: 0.9 $
+ $Revision$
+ $Date$
+ by Keiju ISHITSUKA(keiju@ishitsuka.com)
+ by gotoken-san who is original translater from japanese version
+
+=begin
+= What is irb?
+
+irb stands for `interactive ruby'. irb is a tool to execute interactively
+ruby expressions read from stdin.
+
+= Invoking
+
+ % irb
+
+= Usage
+
+Use of irb is easy if you know ruby. Executing irb, prompts are
+displayed as follows. Then, enter expression of ruby. A input is
+executed when it is syntacticaly completed.
+
+ dim% irb
+ irb(main):001:0> 1+2
+ 3
+ irb(main):002:0> class Foo
+ irb(main):003:1> def foo
+ irb(main):004:2> print 1
+ irb(main):005:2> end
+ irb(main):006:1> end
+ nil
+ irb(main):007:0>
+
+And, Readline extesion module can be used with irb. Using Readline
+is the standard default action if Readline is installed.
+
+= Command line option
+
+ irb.rb [options] file_name opts
+ options:
+ -f suppress read ~/.irbrc
+ -m bc mode (fraction or matrix are available)
+ -d set $DEBUG to true (same as `ruby -d')
+ -Kc same as `ruby -Kc'
+ -r load-module same as `ruby -r'
+ --verbose command input is echoed(default)
+ --noverbose command input isn't echoed
+ --echo commands are echoed immediately before execution(default)
+ --noecho commands aren't echoed immediately before execution
+ --inspect uses `inspect' for output (the default except bc mode)
+ --noinspect doesn't uses inspect for output
+ --readline uses Readline extension module
+ --noreadline doesn't use Readline extension module
+ --prompt prompt-mode
+ --prompt-mode prompt-mode
+ switches prompt mode. Pre-defined prompt modes are
+ `default', `simple', `xmp' and `inf-ruby'
+
+ --inf-ruby-mode uses prompt appreciate for inf-ruby-mode on emacs.
+ Suppresses --readline.
+ --simple-prompt simple prompt mode
+ --noprompt no prompt
+ --tracer display trace for each execution of commands.
+ --back-trace-limit n
+ displayes backtrace top n and tail n. The default
+ value is 16.
+ --irb_debug n sets internal debug level to n (It shouldn't be used)
+ -v, --version prints the version of irb
+
+= Configurations
+
+irb reads `~/.irbrc' when it is invoked. If `~/.irbrb' doesn't exist
+irb try to read in the order `.irbrc', `irb.rc', `_irbrc' then `$irbrc'.
+
+The following is altanative to the command line option. To use them
+type as follows in an irb session.
+
+ IRB.conf[:IRB_NAME]="irb"
+ IRB.conf[:MATH_MODE]=false
+ IRB.conf[:USE_TRACER]=false
+ IRB.conf[:USE_LOADER]=false
+ IRB.conf[:IGNORE_SIGINT]=true
+ IRB.conf[:IGNORE_EOF]=false
+ IRB.conf[:INSPECT_MODE]=nil
+ IRB.conf[:IRB_RC] = nil
+ IRB.conf[:BACK_TRACE_LIMIT]=16
+ IRB.conf[:USE_LOADER] = false
+ IRB.conf[:USE_READLINE] = nil
+ IRB.conf[:USE_TRACER] = false
+ IRB.conf[:IGNORE_SIGINT] = true
+ IRB.conf[:IGNORE_EOF] = false
+ IRB.conf[:PROMPT_MODE] = :DEFALUT
+ IRB.conf[:PROMPT] = {...}
+ IRB.conf[:DEBUG_LEVEL]=0
+ IRB.conf[:VERBOSE]=true
+
+== Customizing prompt
+
+To costomize the prompt you set a variable
+
+ IRB.conf[:PROMPT]
+
+For example, describe as follows in `.irbrc'.
+
+ IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
+ :PROMPT_I => nil, # normal prompt
+ :PROMPT_S => nil, # prompt for continuated strings
+ :PROMPT_C => nil, # prompt for continuated statement
+ :RETURN => " ==>%s\n" # format to return value
+ }
+
+Then, invoke irb with the above prompt mode by
+
+ % irb --prompt my-prompt
+
+Or add the following in `.irbrc'.
+
+ IRB.conf[:PROMPT_MODE] = :MY_PROMPT
+
+Constants PROMPT_I, PROMPT_S and PROMPT_C specifies the format.
+In the prompt specification, some special strings are available.
+
+ %N command name which is running
+ %m to_s of main object (self)
+ %M inspect of main object (self)
+ %l type of string(", ', /, ]), `]' is inner %w[...]
+ %NNi indent level. NN is degits and means as same as printf("%NNd").
+ It can be ommited
+ %NNn line number.
+ %% %
+
+For instance, the default prompt mode is defined as follows:
+
+IRB.conf[:PROMPT_MODE][:DEFAULT] = {
+ :PROMPT_I => "%N(%m):%03n:%i> ",
+ :PROMPT_S => "%N(%m):%03n:%i%l ",
+ :PROMPT_C => "%N(%m):%03n:%i* ",
+ :RETURN => "%s\n"
+}
+
+RETURN is used to printf.
+
+== Configurating subirb
+
+The command line option or IRB.conf specify the default behavior of
+(sub)irb. On the other hand, each conf of in the next sction `6. Command'
+is used to individually configurate (sub)irb.
+
+If proc is set to IRB.conf[:IRB_RC], its subirb will be invoked after
+execution of that proc under giving the context of irb as its
+aregument. By this mechanism each subirb can be configurated.
+
+= Command
+
+For irb commands, both simple name and `irb_'-prefixed name are prepared.
+
+--- exit, quit, irb_exit
+ Quits (sub)irb.
+
+--- conf, irb_context
+ Displays current configuration. Modifing the configuration is
+ achieved by sending message to `conf'.
+
+--- conf.eval_history = N
+ Sets execution result history.
+ N is a integer or nil. If N > 0, the number of historys is N.
+ If N == 0, the number of historys is unlimited. If N is nill,
+ execution result history isn't used(default).
+
+--- conf.back_trace_limit
+ Sets display lines of backtrace as top n and tail n.
+ The default value is 16.
+
+--- conf.debug_level = N
+ Sets debug level of irb.
+
+--- conf.ignore_eof = true/false
+ Whether ^D (control-d) will be ignored or not.
+ If false is set, ^D means quit.
+
+--- conf.ignore_sigint= true/false
+ Whether ^C (control-c) will be ignored or not.
+ If false is set, ^D means quit. If true,
+ during input: cancel inputing then return to top level.
+ during execute: abondon current execution.
+
+--- conf.inf_ruby_mode = true/false
+ Whether inf-ruby-mode or not. The default value is false.
+
+--- conf.inspect_mode = true/false/nil
+ Specifies inspect mode.
+ true: display inspect
+ false: display to_s
+ nil: inspect mode in non math mode,
+ non inspect mode in math mode.
+
+--- conf.math_mode
+ Whether bc mode or not.
+
+--- conf.use_loader = true/false
+ Whether irb's own file reader method is used when load/require or not.
+ This mode is globaly affected (irb wide).
+
+--- conf.prompt_c
+ prompt for a continuating statement (e.g, immediately after of `if')
+
+--- conf.prompt_i
+ standard prompt
+
+--- conf.prompt_s
+ prompt for a continuating string
+
+--- conf.rc
+ Whether ~/.irbrc is read or not.
+
+--- conf.use_prompt = true/false
+ Prompting or not.
+
+--- conf.use_readline = true/false/nil
+ Whether readline is used or not.
+ true: uses
+ false: doen't use
+ nil: intends to use readline except for inf-ruby-mode (default)
+#
+#--- conf.verbose=T/F
+# Whether verbose messages are display or not.
+
+--- cws, chws, irb_change_workspace [obj]
+ obj will be self. If obj is omitted, self will be home-object, or
+ the main object of first started irb.
+
+--- pushws, irb_pushws, irb_push_workspace [obj]
+ same as UNIX-shell command pushd.
+
+--- popws, irb_popws, irb_pop_workspace
+ same as UNIX-shell command popd
+
+--- irb [obj]
+ Invoke subirb. If obj is given, obj will be self.
+
+--- jobs, irb_jobs
+ List of subirb
+
+--- fg n, irb_fg n
+ Switch into specified subirb. The following is candidates of n:
+
+ irb number
+ thhread
+ irb object
+ self(obj which is specified of irb obj)
+
+--- kill n, irb_kill n
+ Kill subirb. The means of n is as same as the case of irb_fg.
+
+--- souce, irb_source path
+ This is a like UNIX-shell command source. evaluate script in path
+ on current context.
+
+--- irb_load path, prev
+ irb-version of Ruby's load.
+
+= System variable
+
+--- _ The latest value of evaluation (it is local)
+--- __ The history of evaluation values.
+ __[line_no] return an evaluation value of line number<line_no>. If
+ line_no is a negative, return value before -<line_no> from latest
+ value.
+
+= Session Example
+
+ dim% ruby irb.rb
+ irb(main):001:0> irb # invoke subirb
+ irb#1(main):001:0> jobs # list of subirbs
+ #0->irb on main (#<Thread:0x400fb7e4> : stop)
+ #1->irb#1 on main (#<Thread:0x40125d64> : running)
+ nil
+ irb#1(main):002:0> fg 0 # switch job
+ nil
+ irb(main):002:0> class Foo;end
+ nil
+ irb(main):003:0> irb Foo # invoke subirb which has the
+ # context of Foo
+ irb#2(Foo):001:0> def foo # define Foo#foo
+ irb#2(Foo):002:1> print 1
+ irb#2(Foo):003:1> end
+ nil
+ irb#2(Foo):004:0> fg 0 # switch job
+ nil
+ irb(main):004:0> jobs # list of job
+ #0->irb on main (#<Thread:0x400fb7e4> : running)
+ #1->irb#1 on main (#<Thread:0x40125d64> : stop)
+ #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
+ nil
+ irb(main):005:0> Foo.instance_methods # Foo#foo is defined asurely
+ ["foo"]
+ irb(main):006:0> fg 2 # switch job
+ nil
+ irb#2(Foo):005:0> def bar # define Foo#bar
+ irb#2(Foo):006:1> print "bar"
+ irb#2(Foo):007:1> end
+ nil
+ irb#2(Foo):010:0> Foo.instance_methods
+ ["bar", "foo"]
+ irb#2(Foo):011:0> fg 0
+ nil
+ irb(main):007:0> f = Foo.new
+ #<Foo:0x4010af3c>
+ irb(main):008:0> irb f # invoke subirb which has the
+ # context of f (instance of Foo)
+ irb#3(#<Foo:0x4010af3c>):001:0> jobs
+ #0->irb on main (#<Thread:0x400fb7e4> : stop)
+ #1->irb#1 on main (#<Thread:0x40125d64> : stop)
+ #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
+ #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
+ nil
+ irb#3(#<Foo:0x4010af3c>):002:0> foo # evaluate f.foo
+ 1nil
+ irb#3(#<Foo:0x4010af3c>):003:0> bar # evaluate f.bar
+ barnil
+ irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# kill job
+ nil
+ irb(main):009:0> jobs
+ #0->irb on main (#<Thread:0x400fb7e4> : running)
+ nil
+ irb(main):010:0> exit # exit
+ dim%
+
+= Restrictions
+
+Because irb evaluates the inputs immediately after the imput is
+syntactically completed, irb gives slight different result than
+directly use ruby. Known difference is pointed out here.
+
+
+== Declaration of the local variable
+
+The following causes an error in ruby:
+
+ eval "foo = 0"
+ foo
+ --
+ -:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError)
+ ---
+ NameError
+
+Though, the above will successfully done by irb.
+
+ >> eval "foo = 0"
+ => 0
+ >> foo
+ => 0
+
+Ruby evaluates a code after reading entire of code and determination
+of the scope of local variables. On the other hand, irb do
+immediately. More precisely, irb evaluate at first
+
+ evel "foo = 0"
+
+then foo is defined on this timing. It is because of this
+incompatibility.
+
+If you'd like to detect those differences, begin...end can be used:
+
+ >> begin
+ ?> eval "foo = 0"
+ >> foo
+ >> end
+ NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0>
+ (irb):3
+ (irb_local_binding):1:in `eval'
+
+== Here-document
+
+Implementation of Here-document is incomplete.
+
+== Symbol
+
+Irb can not always recognize a symbol as to be Symbol. Concretely, an
+expression have completed, however Irb regard it as continuation line.
+
+=end
+
+% Begin Emacs Environment
+% Local Variables:
+% mode: text
+% comment-column: 0
+% comment-start: "%"
+% comment-end: "\n"
+% End:
+%
diff --git a/doc/irb/irb.rd.ja b/doc/irb/irb.rd.ja
new file mode 100644
index 0000000000..bf8ac5d517
--- /dev/null
+++ b/doc/irb/irb.rd.ja
@@ -0,0 +1,411 @@
+irb -- interactive ruby
+ $Release Version: 0.9 $
+ $Revision$
+ $Date$
+ by Keiju ISHITSUKA(keiju@ishitsuka.com)
+=begin
+= irb¤È¤Ï?
+
+irb¤Ïinteractive ruby¤Îά¤Ç¤¹. ruby¤Î¼°¤òɸ½àÆþÎϤ«¤é´Êñ¤ËÆþÎÏ/¼Â¹Ô¤¹¤ë
+¤¿¤á¤Î¥Ä¡¼¥ë¤Ç¤¹.
+
+= µ¯Æ°
+
+ % irb
+
+¤Ç¹Ô¤Ê¤¤¤Þ¤¹.
+
+= »È¤¤Êý
+
+irb¤Î»È¤¤Êý¤Ï, Ruby¤µ¤¨ÃΤäƤ¤¤ì¤Ð¤¤¤¿¤Ã¤Æ´Êñ¤Ç¤¹. ´ðËÜŪ¤Ë¤Ï irb ¤È
+¤¤¤¦¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤¹¤ë¤À¤±¤Ç¤¹. irb¤ò¼Â¹Ô¤¹¤ë¤È, °Ê²¼¤Î¤è¤¦¤Ê¥×¥í¥ó¥×
+¥È¤¬É½¤ì¤Æ¤­¤Þ¤¹. ¸å¤Ï, ruby¤Î¼°¤òÆþ¤ì¤Æ²¼¤µ¤¤. ¼°¤¬´°·ë¤·¤¿»þÅÀ¤Ç¼Â¹Ô
+¤µ¤ì¤Þ¤¹.
+
+ dim% irb
+ irb(main):001:0> 1+2
+ 3
+ irb(main):002:0> class Foo
+ irb(main):003:1> def foo
+ irb(main):004:2> print 1
+ irb(main):005:2> end
+ irb(main):006:1> end
+ nil
+ irb(main):007:0>
+
+¤Þ¤¿, irb¤ÏReadline¥â¥¸¥å¡¼¥ë¤Ë¤âÂбþ¤·¤Æ¤¤¤Þ¤¹. Readline¥â¥¸¥å¡¼¥ë¤¬
+¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë»þ¤Ë¤Ï, ¤½¤ì¤ò»È¤¦¤Î¤¬É¸½à¤Îưºî¤Ë¤Ê¤ê¤Þ¤¹.
+
+= ¥³¥Þ¥ó¥É¥ª¥×¥·¥ç¥ó
+
+ irb.rb [options] file_name opts
+ options:
+ -f ~/.irbrc ¤òÆÉ¤ß¹þ¤Þ¤Ê¤¤.
+ -m bc¥â¡¼¥É(ʬ¿ô, ¹ÔÎó¤Î·×»»¤¬¤Ç¤­¤ë)
+ -d $DEBUG ¤òtrue¤Ë¤¹¤ë(ruby -d ¤ÈƱ¤¸)
+ -Kc ruby -Kc¤ÈƱ¤¸
+ -r load-module ruby -r ¤ÈƱ¤¸.
+ --verbose ¤³¤ì¤«¤é¼Â¹Ô¤¹¤ë¹Ô¤òɽ¼¨¤¹¤ë(¥Ç¥Õ¥©¥ë¥È)
+ --noverbose ¤³¤ì¤«¤é¼Â¹Ô¤¹¤ë¹Ô¤òɽ¼¨¤·¤Ê¤¤
+ --echo ¼Â¹Ô·ë²Ì¤òɽ¼¨¤¹¤ë(¥Ç¥Õ¥©¥ë¥È)
+ --noecho ¼Â¹Ô·ë²Ì¤òɽ¼¨¤·¤Ê¤¤
+ --inspect ·ë²Ì½ÐÎϤËinspect¤òÍѤ¤¤ë(bc¥â¡¼¥É°Ê³°¤Ï¥Ç¥Õ¥©¥ë¥È).
+ --noinspect ·ë²Ì½ÐÎϤËinspect¤òÍѤ¤¤Ê¤¤.
+ --readline readline¥é¥¤¥Ö¥é¥ê¤òÍøÍѤ¹¤ë.
+ --noreadline readline¥é¥¤¥Ö¥é¥ê¤òÍøÍѤ·¤Ê¤¤. ¥Ç¥Õ¥©¥ë¥È¤Îưºî¤Ï,
+ inf-ruby-mode°Ê³°¤Çreadline¥é¥¤¥Ö¥é¥ê¤òÍøÍѤ·¤è¤¦
+ ¤È¤¹¤ë.
+ --prompt prompt-mode
+ --prompt-mode prompt-mode
+ ¥×¥í¥ó¥×¥È¥â¡¼¥É¤òÀÚÂØ¤¨¤Þ¤¹. ¸½ºßÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥×
+ ¥í¥ó¥×¥È¥â¡¼¥É¤Ï, default, simple, xmp, inf-ruby¤¬
+ ÍѰդµ¤ì¤Æ¤¤¤Þ¤¹. ¥Ç¥Õ¥©¥ë¥È¤Ïdefault¥×¥í¥ó¥×¥È¥â¡¼
+ ¥É¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹.
+
+ --inf-ruby-mode emacs¤Îinf-ruby-modeÍѤΥץí¥ó¥×¥Èɽ¼¨¤ò¹Ô¤Ê¤¦. ÆÃ
+ ¤Ë»ØÄ꤬¤Ê¤¤¸Â¤ê, readline¥é¥¤¥Ö¥é¥ê¤Ï»È¤ï¤Ê¤¯¤Ê¤ë.
+ --simple-prompt
+ Èó¾ï¤Ë¥·¥ó¥×¥ë¤Ê¥×¥í¥ó¥×¥È¤òÍѤ¤¤ë¥â¡¼¥É¤Ç¤¹.
+ --noprompt ¥×¥í¥ó¥×¥Èɽ¼¨¤ò¹Ô¤Ê¤ï¤Ê¤¤.
+ --tracer ¥³¥Þ¥ó¥É¼Â¹Ô»þ¤Ë¥È¥ì¡¼¥¹¤ò¹Ô¤Ê¤¦.
+ --back-trace-limit n
+ ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹É½¼¨¤ò¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤ÎƬ¤«¤é n, ¸å¤í
+ ¤«¤én¤À¤±¹Ô¤Ê¤¦. ¥Ç¥Õ¥©¥ë¥È¤Ï16
+ --irb_debug n irb¤Î¥Ç¥Ð¥Ã¥°¥Ç¥Ð¥Ã¥°¥ì¥Ù¥ë¤òn¤ËÀßÄꤹ¤ë(ÍøÍѤ·¤Ê
+ ¤¤Êý¤¬ÌµÆñ¤Ç¤·¤ç¤¦).
+ -v, --version irb¤Î¥Ð¡¼¥¸¥ç¥ó¤òɽ¼¨¤¹¤ë
+
+= ¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó
+
+irbµ¯Æ°»þ¤Ë``~/.irbrc''¤òÆÉ¤ß¹þ¤ß¤Þ¤¹. ¤â¤·Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï,
+``.irbrc'', ``irb.rc'', ``_irbrc'', ``$irbrc''¤Î½ç¤Ëload¤ò»î¤ß¤Þ¤¹.
+
+¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ëÂå¤ï¤ê¤Ë, °Ê²¼¤Î¥³¥Þ¥ó¥É¤Ç¤â¥Ç¥Õ¥©¥ë¥È¤Îưºî¤òÀßÄê
+¤Ç¤­¤Þ¤¹.
+
+ IRB.conf[:IRB_NAME]="irb"
+ IRB.conf[:MATH_MODE]=false
+ IRB.conf[:USE_TRACER]=false
+ IRB.conf[:USE_LOADER]=false
+ IRB.conf[:IGNORE_SIGINT]=true
+ IRB.conf[:IGNORE_EOF]=false
+ IRB.conf[:INSPECT_MODE]=nil
+ IRB.conf[:IRB_RC] = nil
+ IRB.conf[:BACK_TRACE_LIMIT]=16
+ IRB.conf[:USE_LOADER] = false
+ IRB.conf[:USE_READLINE] = nil
+ IRB.conf[:USE_TRACER] = false
+ IRB.conf[:IGNORE_SIGINT] = true
+ IRB.conf[:IGNORE_EOF] = false
+ IRB.conf[:PROMPT_MODE] = :DEFALUT
+ IRB.conf[:PROMPT] = {...}
+ IRB.conf[:DEBUG_LEVEL]=0
+ IRB.conf[:VERBOSE]=true
+
+== ¥×¥í¥ó¥×¥È¤ÎÀßÄê
+
+¥×¥í¥ó¥×¥È¤ò¥«¥¹¥¿¥Þ¥¤¥º¤·¤¿¤¤»þ¤Ë¤Ï,
+
+ IRB.conf[:PROMPT]
+
+¤òÍѤ¤¤Þ¤¹. Î㤨¤Ð, .irbrc¤ÎÃæ¤Ç²¼¤Î¤è¤¦¤Ê¼°¤òµ­½Ò¤·¤Þ¤¹:
+
+ IRB.conf[:PROMPT][:MY_PROMPT] = { # ¥×¥í¥ó¥×¥È¥â¡¼¥É¤Î̾Á°
+ :PROMPT_I => nil, # Ä̾ï¤Î¥×¥í¥ó¥×¥È
+ :PROMPT_S => nil, # ʸ»úÎó¤Ê¤É¤Î·Ñ³¹Ô¤Î¥×¥í¥ó¥×¥È
+ :PROMPT_C => nil, # ¼°¤¬·Ñ³¤·¤Æ¤¤¤ë»þ¤Î¥×¥í¥ó¥×¥È
+ :RETURN => " ==>%s\n" # ¥ê¥¿¡¼¥ó»þ¤Î¥×¥í¥ó¥×¥È
+ }
+
+¥×¥í¥ó¥×¥È¥â¡¼¥É¤ò»ØÄꤷ¤¿¤¤»þ¤Ë¤Ï,
+
+ irb --prompt my-prompt
+
+¤Ç¤½¤Î¥×¥í¥ó¥×¥È¥â¡¼¥É¤Çµ¯Æ°¤µ¤ì¤Þ¤¹. ¤Þ¤¿¤Ï, .irbrc¤Ë²¼¼°¤òµ­½Ò¤·¤Æ¤â
+OK¤Ç¤¹.
+
+ IRB.conf[:PROMPT_MODE] = :MY_PROMPT
+
+PROMPT_I, PROMPT_S, PROMPT_C¤Ï, ¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤷ¤Þ¤¹.
+
+ %N µ¯Æ°¤·¤Æ¤¤¤ë¥³¥Þ¥ó¥É̾¤¬½ÐÎϤµ¤ì¤ë.
+ %m main¥ª¥Ö¥¸¥§¥¯¥È(self)¤¬to_s¤Ç½ÐÎϤµ¤ì¤ë.
+ %M main¥ª¥Ö¥¸¥§¥¯¥È(self)¤¬inspect¤µ¤ì¤Æ½ÐÎϤµ¤ì¤ë.
+ %l ʸ»úÎóÃæ¤Î¥¿¥¤¥×¤òɽ¤¹(", ', /, ], `]'¤Ï%w¤ÎÃæ¤Î»þ)
+ %NNi ¥¤¥ó¥Ç¥ó¥È¤Î¥ì¥Ù¥ë¤òɽ¤¹. NN¤Ï¿ô»ú¤¬Æþ¤êprintf¤Î%NNd¤ÈƱ¤¸. ¾Ê
+ ά²Äǽ
+ %NNn ¹ÔÈÖ¹æ¤òɽ¤·¤Þ¤¹.
+ %% %
+
+Î㤨¤Ð, ¥Ç¥Õ¥©¥ë¥È¤Î¥×¥í¥ó¥×¥È¥â¡¼¥É¤Ï:
+
+ IRB.conf[:PROMPT_MODE][:DEFAULT] = {
+ :PROMPT_I => "%N(%m):%03n:%i> ",
+ :PROMPT_S => "%N(%m):%03n:%i%l ",
+ :PROMPT_C => "%N(%m):%03n:%i* ",
+ :RETURN => "%s\n"
+ }
+
+¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹.
+
+RETURN¤Ï, ¸½ºß¤Î¤È¤³¤íprintf·Á¼°¤Ç¤¹. ¾­Íè»ÅÍͤ¬ÊѤï¤ë¤«¤âÃΤì¤Þ¤»¤ó.
+
+== ¥µ¥Öirb¤ÎÀßÄê
+
+¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤ª¤è¤ÓIRB.conf¤Ï(¥µ¥Ö)irbµ¯Æ°»þ¤Î¥Ç¥Õ¥©¥ë¥È¤Î
+ÀßÄê¤ò·è¤á¤ë¤â¤Î¤Ç, `5. ¥³¥Þ¥ó¥É'¤Ë¤¢¤ëconf¤Ç¸ÄÊ̤Î(¥µ¥Ö)irb¤ÎÀßÄ꤬¤Ç
+¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹.
+
+IRB.conf[:IRB_RC]¤Ëproc¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È, ¥µ¥Öirb¤òµ¯Æ°¤¹¤ë»þ¤Ë¤½¤Î
+proc¤òirb¤Î¥³¥ó¥Æ¥­¥¹¥È¤ò°ú¿ô¤È¤·¤Æ¸Æ¤Ó½Ð¤·¤Þ¤¹. ¤³¤ì¤Ë¤è¤Ã¤Æ¸ÄÊ̤Υµ
+¥Öirb¤´¤È¤ËÀßÄê¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹.
+
+
+= ¥³¥Þ¥ó¥É
+
+irb³ÈÄ¥¥³¥Þ¥ó¥É¤Ï, ´Êñ¤Ê̾Á°¤ÈƬ¤Ë`irb_'¤ò¤Ä¤±¤¿Ì¾Á°¤ÈξÊýÄêµÁ¤µ¤ì¤Æ
+¤¤¤Þ¤¹. ¤³¤ì¤Ï, ´Êñ¤Ê̾Á°¤¬override¤µ¤ì¤¿»þ¤Î¤¿¤á¤Ç¤¹.
+
+--- exit, quit, irb_exit
+ ½ªÎ»¤¹¤ë.
+ ¥µ¥Öirb¤Î¾ì¹ç, ¤½¤Î¥µ¥Öirb¤ò½ªÎ»¤¹¤ë.
+
+--- conf, irb_context
+ irb¤Î¸½ºß¤ÎÀßÄê¤òɽ¼¨¤¹¤ë. ÀßÄê¤ÎÊѹ¹¤Ï, conf¤Ë¥á¥Ã¥»¡¼¥¸¤òÁ÷¤ë¤³
+ ¤È¤Ë¤è¤Ã¤Æ¹Ô¤Ê¤¨¤ë.
+
+--- conf.eval_history = N
+ ¼Â¹Ô·ë²Ì¤Î¥Ò¥¹¥È¥êµ¡Ç½¤ÎÀßÄê.
+ nn¤ÏÀ°¿ô¤«nil¤Ç nn>0 ¤Ç¤¢¤ì¤Ð¤½¤Î¿ô¤À¤±¥Ò¥¹¥È¥ê¤Ë¤¿¤á¤ë¡£nn==0¤Î»þ¤Ï
+ ̵À©¸Â¤Ëµ­²±¤¹¤ë¡¢nil¤À¤È¥Ò¥¹¥È¥êµ¡Ç½¤Ï¤ä¤á¤ë(¥Ç¥Õ¥©¥ë¥È).
+
+--- Conf.back_trace_limit
+ ¥Ð¥Ã¥¯¥È¥ì¡¼¥¹É½¼¨¤ò¥Ð¥Ã¥¯¥È¥ì¡¼¥¹¤ÎƬ¤«¤én, ¸å¤í¤«¤én¤À¤±¹Ô¤Ê¤¦.
+ ¥Ç¥Õ¥©¥ë¥È¤Ï16
+
+--- conf.debug_level = N
+ irbÍѤΥǥХå°¥ì¥Ù¥ë¤ÎÀßÄê
+
+--- conf.ignore_eof = true/false
+ ^D¤¬ÆþÎϤµ¤ì¤¿»þ¤Îưºî¤òÀßÄꤹ¤ë. true¤Î»þ¤Ï^D¤ò̵»ë¤¹¤ë, false¤Î
+ »þ¤Ïirb¤ò½ªÎ»¤¹¤ë.
+
+--- conf.ignore_sigint= true/false
+ ^C¤¬ÆþÎϤµ¤ì¤¿»þ¤Îưºî¤òÀßÄꤹ¤ë. false»þ¤Ï, irb¤ò½ªÎ»¤¹¤ë. true¤Î
+ »þ¤Îưºî¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ë:
+ ÆþÎÏÃæ: ¤³¤ì¤Þ¤ÇÆþÎϤ·¤¿¤â¤Î¤ò¥­¥ã¥ó¥»¥ë¤·¥È¥Ã¥×¥ì¥Ù¥ë¤ËÌá¤ë.
+ ¼Â¹ÔÃæ: ¼Â¹Ô¤òÃæ»ß¤¹¤ë.
+
+--- conf.inf_ruby_mode = true/false
+ inf-ruby-modeÍѤΥץí¥ó¥×¥Èɽ¼¨¤ò¹Ô¤Ê¤¦. ¥Ç¥Õ¥©¥ë¥È¤Ïfalse.
+
+--- conf.inspect_mode = true/false/nil
+ ¥¤¥ó¥¹¥Ú¥¯¥È¥â¡¼¥É¤òÀßÄꤹ¤ë.
+ true: ¥¤¥ó¥¹¥Ú¥¯¥È¤·¤ÆÉ½¼¨¤¹¤ë.
+ false: Ä̾ï¤Îprint¤Çɽ¼¨¤¹¤ë.
+ nil: Ä̾ï¥â¡¼¥É¤Ç¤¢¤ì¤Ð, inspect mode¤È¤Ê¤ê, math¥â¡¼¥É¤Î»þ¤Ï, non
+ inspect mode¤È¤Ê¤ë.
+
+--- conf.math_mode
+ »²¾È¤Î¤ß. bc¥â¡¼¥É(ʬ¿ô, ¹ÔÎó¤Î·×»»¤¬¤Ç¤­¤Þ¤¹)¤«¤É¤¦¤«?
+
+--- conf.use_loader = true/false
+ load/require»þ¤Ëirb¤ÎfileÆÉ¤ß¹þ¤ßµ¡Ç½¤òÍѤ¤¤ë¥â¡¼¥É¤Î¥¹¥¤¥Ã¥Á(¥Ç¥Õ¥©
+ ¥ë¥È¤ÏÍѤ¤¤Ê¤¤). ¤³¤Î¥â¡¼¥É¤ÏIRBÁ´ÂΤËÈ¿±Ç¤µ¤ì¤ë.
+
+--- conf.prompt_c
+ if¤Îľ¸å¤Ê¤É, ¹Ô¤¬·Ñ³¤·¤Æ¤¤¤ë»þ¤Î¥×¥í¥ó¥×¥È.
+
+--- conf.prompt_i
+ Ä̾ï¤Î¥×¥í¥ó¥×¥È.
+
+--- conf.prompt_s
+ ʸ»úÎóÃæ¤Ê¤É¤òɽ¤¹¥×¥í¥ó¥×¥È.
+
+--- conf.rc
+ ~/.irbrc¤òÆÉ¤ß¹þ¤ó¤À¤«¤É¤¦¤«?
+
+--- conf.use_prompt = true/false
+ ¥×¥í¥ó¥×¥Èɽ¼¨¤¹¤ë¤«¤É¤¦¤«? ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥×¥í¥ó¥×¥È¤òɽ¼¨¤¹¤ë.
+
+--- conf.use_readline = true/false/nil
+ readline¤ò»È¤¦¤«¤É¤¦¤«?
+ true: readline¤ò»È¤¦.
+ false: readline¤ò»È¤ï¤Ê¤¤.
+ nil: (¥Ç¥Õ¥©¥ë¥È)inf-ruby-mode°Ê³°¤Çreadline¥é¥¤¥Ö¥é¥ê¤òÍøÍѤ·¤è
+ ¤¦¤È¤¹¤ë.
+#
+#--- conf.verbose=T/F
+# irb¤«¤é¤¤¤í¤¤¤í¤Ê¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ¹¤ë¤«?
+
+--- cws, chws, irb_cws, irb_chws, irb_change_workspace [obj]
+ obj¤òself¤È¤¹¤ë. obj¤¬¾Êά¤µ¤ì¤¿¤È¤­¤Ï, home workspace, ¤¹¤Ê¤ï¤Á
+ irb¤òµ¯Æ°¤·¤¿¤È¤­¤Îmain object¤òself¤È¤¹¤ë.
+
+--- pushws, irb_pushws, irb_push_workspace [obj]
+ UNIX¥·¥§¥ë¥³¥Þ¥ó¥É¤Îpushd¤ÈƱÍÍ.
+
+--- popws, irb_popws, irb_pop_workspace
+ UNIX¥·¥§¥ë¥³¥Þ¥ó¥É¤Îpopd¤ÈƱÍÍ.
+
+--- irb [obj]
+ ¥µ¥Öirb¤òΩ¤Á¤¢¤²¤ë. obj¤¬»ØÄꤵ¤ì¤¿»þ¤Ï, ¤½¤Îobj¤òself¤È¤¹¤ë.
+
+--- jobs, irb_jobs
+ ¥µ¥Öirb¤Î¥ê¥¹¥È
+
+--- fg n, irb_fg n
+ »ØÄꤷ¤¿¥µ¥Öirb¤Ë¥¹¥¤¥Ã¥Á¤¹¤ë. n¤Ï, ¼¡¤Î¤â¤Î¤ò»ØÄꤹ¤ë.
+
+ irbÈÖ¹æ
+ ¥¹¥ì¥Ã¥É
+ irb¥ª¥Ö¥¸¥§¥¯¥È
+ self(irb obj¤Çµ¯Æ°¤·¤¿»þ¤Îobj)
+
+--- kill n, irb_kill n
+ ¥µ¥Öirb¤òkill¤¹¤ë. n¤Ïfg¤ÈƱ¤¸.
+
+--- souce, irb_source path
+ UNIX¥·¥§¥ë¥³¥Þ¥ó¥É¤Îsource¤È»÷¤Æ¤¤¤ë. ¸½ºß¤Î´Ä¶­¾å¤ÇpathÆâ¤Î¥¹¥¯¥ê
+ ¥×¥È¤òɾ²Á¤¹¤ë.
+
+--- irb_load path, prev
+
+ Ruby¤Îload¤ÎirbÈÇ.
+
+= ¥·¥¹¥Æ¥àÊÑ¿ô
+
+--- _
+ Á°¤Î·×»»¤Î¼Â¹Ô·ë²Ì¤ò³Ð¤¨¤Æ¤¤¤ë(¥í¡¼¥«¥ëÊÑ¿ô).
+--- __
+ ¼Â¹Ô·ë²Ì¤ÎÍúÎò¤ò³Ð¤¨¤Æ¤¤¤ë.
+ __[line_no]¤Ç¡¢¤½¤Î¹Ô¤Ç¼Â¹Ô¤·¤¿·ë²Ì¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë. line_no¤¬Éé¤Î
+ »þ¤Ë¤Ï¡¢ºÇ¿·¤Î·ë²Ì¤«¤é-line_noÁ°¤Î·ë²Ì¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë.
+
+= »ÈÍÑÎã
+
+°Ê²¼¤Î¤è¤¦¤Ê´¶¤¸¤Ç¤¹.
+
+ dim% ruby irb.rb
+ irb(main):001:0> irb # ¥µ¥Öirb¤ÎΩ¤Á¤¢¤²
+ irb#1(main):001:0> jobs # ¥µ¥Öirb¤Î¥ê¥¹¥È
+ #0->irb on main (#<Thread:0x400fb7e4> : stop)
+ #1->irb#1 on main (#<Thread:0x40125d64> : running)
+ nil
+ irb#1(main):002:0> fg 0 # job¤Î¥¹¥¤¥Ã¥Á
+ nil
+ irb(main):002:0> class Foo;end
+ nil
+ irb(main):003:0> irb Foo # Foo¤ò¥³¥ó¥Æ¥­¥¹¥È¤·¤Æirb
+ # Ω¤Á¤¢¤²
+ irb#2(Foo):001:0> def foo # Foo#foo¤ÎÄêµÁ
+ irb#2(Foo):002:1> print 1
+ irb#2(Foo):003:1> end
+ nil
+ irb#2(Foo):004:0> fg 0 # job¤ò¥¹¥¤¥Ã¥Á
+ nil
+ irb(main):004:0> jobs # job¤Î¥ê¥¹¥È
+ #0->irb on main (#<Thread:0x400fb7e4> : running)
+ #1->irb#1 on main (#<Thread:0x40125d64> : stop)
+ #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
+ nil
+ irb(main):005:0> Foo.instance_methods # Foo#foo¤¬¤Á¤ã¤ó¤ÈÄêµÁ¤µ
+ # ¤ì¤Æ¤¤¤ë
+ ["foo"]
+ irb(main):006:0> fg 2 # job¤ò¥¹¥¤¥Ã¥Á
+ nil
+ irb#2(Foo):005:0> def bar # Foo#bar¤òÄêµÁ
+ irb#2(Foo):006:1> print "bar"
+ irb#2(Foo):007:1> end
+ nil
+ irb#2(Foo):010:0> Foo.instance_methods
+ ["bar", "foo"]
+ irb#2(Foo):011:0> fg 0
+ nil
+ irb(main):007:0> f = Foo.new
+ #<Foo:0x4010af3c>
+ irb(main):008:0> irb f # Foo¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤Çirb¤ò
+ # Ω¤Á¤¢¤²¤ë.
+ irb#3(#<Foo:0x4010af3c>):001:0> jobs
+ #0->irb on main (#<Thread:0x400fb7e4> : stop)
+ #1->irb#1 on main (#<Thread:0x40125d64> : stop)
+ #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
+ #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
+ nil
+ irb#3(#<Foo:0x4010af3c>):002:0> foo # f.foo¤Î¼Â¹Ô
+ nil
+ irb#3(#<Foo:0x4010af3c>):003:0> bar # f.bar¤Î¼Â¹Ô
+ barnil
+ irb#3(#<Foo:0x4010af3c>):004:0> kill 1, 2, 3# job¤Îkill
+ nil
+ irb(main):009:0> jobs
+ #0->irb on main (#<Thread:0x400fb7e4> : running)
+ nil
+ irb(main):010:0> exit # ½ªÎ»
+ dim%
+
+= »ÈÍѾå¤ÎÀ©¸Â
+
+irb¤Ï, ɾ²Á¤Ç¤­¤ë»þÅÀ(¼°¤¬ÊĤ¸¤¿»þÅÀ)¤Ç¤ÎÃ༡¼Â¹Ô¤ò¹Ô¤Ê¤¤¤Þ¤¹. ¤·¤¿¤¬¤Ã
+¤Æ, ruby¤òľÀܻȤä¿»þ¤È, ¼ã´³°Û¤Ê¤ëưºî¤ò¹Ô¤Ê¤¦¾ì¹ç¤¬¤¢¤ê¤Þ¤¹.
+
+¸½ºßÌÀ¤é¤«¤Ë¤Ê¤Ã¤Æ¤¤¤ëÌäÂêÅÀ¤òÀâÌÀ¤·¤Þ¤¹.
+
+== ¥í¡¼¥«¥ëÊÑ¿ô¤ÎÀë¸À
+
+ruby¤Ç¤Ï, °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï¥¨¥é¡¼¤Ë¤Ê¤ê¤Þ¤¹.
+
+ eval "foo = 0"
+ foo
+ --
+ -:2: undefined local variable or method `foo' for #<Object:0x40283118> (NameError)
+ ---
+ NameError
+
+¤È¤³¤í¤¬, irb¤òÍѤ¤¤ë¤È
+
+ >> eval "foo = 0"
+ => 0
+ >> foo
+ => 0
+
+¤È¤Ê¤ê, ¥¨¥é¡¼¤òµ¯¤³¤·¤Þ¤»¤ó. ¤³¤ì¤Ï, ruby¤¬ºÇ½é¤Ë¥¹¥¯¥ê¥×¥ÈÁ´ÂΤò¥³¥ó
+¥Ñ¥¤¥ë¤·¤Æ¥í¡¼¥«¥ëÊÑ¿ô¤ò·èÄꤹ¤ë¤«¤é¤Ç¤¹. ¤½¤ì¤ËÂФ·, irb¤Ï¼Â¹Ô²Äǽ¤Ë
+¤Ê¤ë(¼°¤¬ÊĤ¸¤ë)¤È¼«Æ°Åª¤Ëɾ²Á¤·¤Æ¤¤¤ë¤«¤é¤Ç¤¹. ¾åµ­¤ÎÎã¤Ç¤Ï,
+
+ evel "foo = 0"
+
+¤ò¹Ô¤Ê¤Ã¤¿»þÅÀ¤Çɾ²Á¤ò¹Ô¤Ê¤¤, ¤½¤Î»þÅÀ¤ÇÊÑ¿ô¤¬ÄêµÁ¤µ¤ì¤ë¤¿¤á, ¼¡¼°¤Ç
+ÊÑ¿ôfoo¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¤é¤Ç¤¹.
+
+¤³¤Î¤è¤¦¤Êruby¤Èirb¤Îưºî¤Î°ã¤¤¤ò²ò·è¤·¤¿¤¤¾ì¹ç¤Ï, begin...end¤Ç³ç¤Ã¤Æ
+¥Ð¥Ã¥ÁŪ¤Ë¼Â¹Ô¤·¤Æ²¼¤µ¤¤:
+
+ >> begin
+ ?> eval "foo = 0"
+ >> foo
+ >> end
+ NameError: undefined local variable or method `foo' for #<Object:0x4013d0f0>
+ (irb):3
+ (irb_local_binding):1:in `eval'
+
+== ¥Ò¥¢¥É¥­¥å¥á¥ó¥È
+
+¸½ºß¤Î¤È¤³¤í¥Ò¥¢¥É¥­¥å¥á¥ó¥È¤Î¼ÂÁõ¤ÏÉÔ´°Á´¤Ç¤¹.
+
+== ¥·¥ó¥Ü¥ë
+
+¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤«¤É¤¦¤«¤ÎȽÃǤò´Ö°ã¤¨¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹. ¶ñÂÎŪ¤Ë¤Ï¼°¤¬´°Î»
+¤·¤Æ¤¤¤ë¤Î¤Ë·Ñ³¹Ô¤È¸«¤Ê¤¹¤³¤È¤¬¤¢¤ê¤Þ¤¹.
+
+=end
+
+% Begin Emacs Environment
+% Local Variables:
+% mode: text
+% comment-column: 0
+% comment-start: "%"
+% comment-end: "\n"
+% End:
+%
+
diff --git a/doc/shell.rd b/doc/shell.rd
new file mode 100644
index 0000000000..02ee1b020a
--- /dev/null
+++ b/doc/shell.rd
@@ -0,0 +1,348 @@
+ -- shell.rb
+ $Release Version: 0.6.0 $
+ $Revision$
+ $Date$
+ by Keiju ISHITSUKA(keiju@ishitsuka.com)
+
+=begin
+
+= What's shell.rb?
+
+It realizes a wish to do execution of commands with filters and pipes
+like sh/csh by using just native facilities of ruby.
+
+= Main classes
+
+== Shell
+
+Every shell object has its own current working directory, and executes
+each command as if it stands in the directory.
+
+--- Shell#cwd
+--- Shell#dir
+--- Shell#getwd
+--- Shell#pwd
+
+ Returns the current directory
+
+--- Shell#system_path
+
+ Returns the command search path in an array
+
+--- Shell#umask
+
+ Returns the umask
+
+== Filter
+
+Any result of command exection is a Filter. Filter include
+Enumerable, therefore a Filter object can use all Enumerable
+facilities.
+
+= Main methods
+
+== Command definitions
+
+In order to execute a command on your OS, you need to define it as a
+Shell method.
+
+Alternatively, you can execute any command via Shell#system even if it
+is not defined.
+
+--- Shell.def_system_command(command, path = command)
+
+ Defines a command. Registers <path> as a Shell method
+ <command>.
+
+ ex)
+ Shell.def_system_command "ls"
+ Defines ls.
+
+ Shell.def_system_command "sys_sort", "sort"
+ Defines sys_sort as sort.
+
+--- Shell.undef_system_command(command)
+
+ Undefines a commmand
+
+--- Shell.alias_command(ali, command, *opts) {...}
+
+ Aliases a command.
+
+ ex)
+ Shell.alias_command "lsC", "ls", "-CBF", "--show-control-chars"
+ Shell.alias_command("lsC", "ls"){|*opts| ["-CBF", "--show-control-chars", *opts]}
+
+--- Shell.unalias_command(ali)
+
+ Unaliases a command.
+
+--- Shell.install_system_commands(pre = "sys_")
+
+ Defines all commands in the default_system_path as Shell method,
+ all with <pre> prefixed to their names.
+
+== Creation
+
+--- Shell.new
+
+ Creates a Shell object which current directory is set to the
+ process current directory.
+
+--- Shell.cd(path)
+
+ Creates a Shell object which current directory is set to
+ <path>.
+
+== Process management
+
+--- Shell#jobs
+
+ Returns a list of scheduled jobs.
+
+--- Shell#kill sig, job
+
+ Sends a signal <sig> to <job>.
+
+== Current directory operations
+
+--- Shell#cd(path, &block)
+--- Shell#chdir
+
+ Changes the current directory to <path>. If a block is given,
+ it restores the current directory when the block ends.
+
+--- Shell#pushd(path = nil, &block)
+--- Shell#pushdir
+
+ Pushes the current directory to the directory stack, changing
+ the current directory to <path>. If <path> is omitted, it
+ exchanges its current directory and the top of its directory
+ stack. If a block is given, it restores the current directory
+ when the block ends.
+
+--- Shell#popd
+--- Shell#popdir
+
+ Pops a directory from the directory stack, and sets the current
+ directory to it.
+
+== File and directory operations
+
+--- Shell#foreach(path = nil, &block)
+
+ Same as:
+ File#foreach (when path is a file)
+ Dir#foreach (when path is a directory)
+
+--- Shell#open(path, mode)
+
+ Same as:
+ File#open (when path is a file)
+ Dir#open (when path is a directory)
+
+--- Shell#unlink(path)
+
+ Same as:
+ Dir#open (when path is a file)
+ Dir#unlink (when path is a directory)
+
+--- Shell#test(command, file1, file2)
+--- Shell#[command, file1, file2]
+
+ Same as test().
+ ex)
+ sh[?e, "foo"]
+ sh[:e, "foo"]
+ sh["e", "foo"]
+ sh[:exists?, "foo"]
+ sh["exists?", "foo"]
+
+--- Shell#mkdir(*path)
+
+ Same as Dir.mkdir (with multiple directories allowed)
+
+--- Shell#rmdir(*path)
+
+ Same as Dir.rmdir (with multiple directories allowed)
+
+== Command execution
+
+--- System#system(command, *opts)
+
+ Executes <command> with <opts>.
+
+ ex)
+ print sh.system("ls", "-l")
+ sh.system("ls", "-l") | sh.head > STDOUT
+
+--- System#rehash
+
+ Does rehash.
+
+--- Shell#transact &block
+
+ Executes a block as self.
+ ex)
+ sh.transact{system("ls", "-l") | head > STDOUT}
+
+--- Shell#out(dev = STDOUT, &block)
+
+ Does transact, with redirecting the result output to <dev>.
+
+== Internal commands
+
+--- Shell#echo(*strings)
+--- Shell#cat(*files)
+--- Shell#glob(patten)
+--- Shell#tee(file)
+
+ Return Filter objects, which are results of their execution.
+
+--- Filter#each &block
+
+ Iterates a block for each line of it.
+
+--- Filter#<(src)
+
+ Inputs from <src>, which is either a string of a file name or an
+ IO.
+
+--- Filter#>(to)
+
+ Outputs to <to>, which is either a string of a file name or an
+ IO.
+
+--- Filter#>>(to)
+
+ Appends the ouput to <to>, which is either a string of a file
+ name or an IO.
+
+--- Filter#|(filter)
+
+ Processes a pipeline.
+
+--- Filter#+(filter)
+
+ (filter1 + filter2) outputs filter1, and then outputs filter2.
+
+--- Filter#to_a
+--- Filter#to_s
+
+== Built-in commands
+
+--- Shell#atime(file)
+--- Shell#basename(file, *opt)
+--- Shell#chmod(mode, *files)
+--- Shell#chown(owner, group, *file)
+--- Shell#ctime(file)
+--- Shell#delete(*file)
+--- Shell#dirname(file)
+--- Shell#ftype(file)
+--- Shell#join(*file)
+--- Shell#link(file_from, file_to)
+--- Shell#lstat(file)
+--- Shell#mtime(file)
+--- Shell#readlink(file)
+--- Shell#rename(file_from, file_to)
+--- Shell#split(file)
+--- Shell#stat(file)
+--- Shell#symlink(file_from, file_to)
+--- Shell#truncate(file, length)
+--- Shell#utime(atime, mtime, *file)
+
+ Equivalent to the class methods of File with the same names.
+
+--- Shell#blockdev?(file)
+--- Shell#chardev?(file)
+--- Shell#directory?(file)
+--- Shell#executable?(file)
+--- Shell#executable_real?(file)
+--- Shell#exist?(file)/Shell#exists?(file)
+--- Shell#file?(file)
+--- Shell#grpowned?(file)
+--- Shell#owned?(file)
+--- Shell#pipe?(file)
+--- Shell#readable?(file)
+--- Shell#readable_real?(file)
+--- Shell#setgid?(file)
+--- Shell#setuid?(file)
+--- Shell#size(file)/Shell#size?(file)
+--- Shell#socket?(file)
+--- Shell#sticky?(file)
+--- Shell#symlink?(file)
+--- Shell#writable?(file)
+--- Shell#writable_real?(file)
+--- Shell#zero?(file)
+
+ Equivalent to the class methods of FileTest with the same names.
+
+--- Shell#syscopy(filename_from, filename_to)
+--- Shell#copy(filename_from, filename_to)
+--- Shell#move(filename_from, filename_to)
+--- Shell#compare(filename_from, filename_to)
+--- Shell#safe_unlink(*filenames)
+--- Shell#makedirs(*filenames)
+--- Shell#install(filename_from, filename_to, mode)
+
+ Equivalent to the class methods of FileTools with the same
+ names.
+
+ And also, there are some aliases for convenience:
+
+--- Shell#cmp <- Shell#compare
+--- Shell#mv <- Shell#move
+--- Shell#cp <- Shell#copy
+--- Shell#rm_f <- Shell#safe_unlink
+--- Shell#mkpath <- Shell#makedirs
+
+= Samples
+
+== ex1
+
+ sh = Shell.cd("/tmp")
+ sh.mkdir "shell-test-1" unless sh.exists?("shell-test-1")
+ sh.cd("shell-test-1")
+ for dir in ["dir1", "dir3", "dir5"]
+ if !sh.exists?(dir)
+ sh.mkdir dir
+ sh.cd(dir) do
+ f = sh.open("tmpFile", "w")
+ f.print "TEST\n"
+ f.close
+ end
+ print sh.pwd
+ end
+ end
+
+== ex2
+
+ sh = Shell.cd("/tmp")
+ sh.transact do
+ mkdir "shell-test-1" unless exists?("shell-test-1")
+ cd("shell-test-1")
+ for dir in ["dir1", "dir3", "dir5"]
+ if !exists?(dir)
+ mkdir dir
+ cd(dir) do
+ f = open("tmpFile", "w")
+ f.print "TEST\n"
+ f.close
+ end
+ print pwd
+ end
+ end
+ end
+
+== ex3
+
+ sh.cat("/etc/printcap") | sh.tee("tee1") > "tee2"
+ (sh.cat < "/etc/printcap") | sh.tee("tee11") > "tee12"
+ sh.cat("/etc/printcap") | sh.tee("tee1") >> "tee2"
+ (sh.cat < "/etc/printcap") | sh.tee("tee11") >> "tee12"
+
+== ex4
+
+ print sh.cat("/etc/passwd").head.collect{|l| l =~ /keiju/}
+
+=end
diff --git a/doc/shell.rd.ja b/doc/shell.rd.ja
new file mode 100644
index 0000000000..073e71ea42
--- /dev/null
+++ b/doc/shell.rd.ja
@@ -0,0 +1,336 @@
+ -- shell.rb
+ $Release Version: 0.6.0 $
+ $Revision$
+ $Date$
+ by Keiju ISHITSUKA(keiju@ishitsuka.com)
+
+=begin
+
+= ÌÜŪ
+
+ruby¾å¤Çsh/csh¤Î¤è¤¦¤Ë¥³¥Þ¥ó¥É¤Î¼Â¹ÔµÚ¤Ó¥Õ¥£¥ë¥¿¥ê¥ó¥°¤ò¼ê·Ú¤Ë¹Ô¤¦.
+sh/csh¤ÎÀ©¸æÊ¸¤Ïruby¤Îµ¡Ç½¤òÍѤ¤¤Æ¼Â¸½¤¹¤ë.
+
+= ¼ç¤Ê¥¯¥é¥¹°ìÍ÷
+
+== Shell
+
+Shell¥ª¥Ö¥¸¥§¥¯¥È¤Ï¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤ò»ý¤Á, ¥³¥Þ¥ó¥É¼Â¹Ô¤Ï¤½¤³¤«¤é¤Î
+ÁêÂХѥ¹¤Ë¤Ê¤ê¤Þ¤¹.
+
+--- Shell#cwd
+--- Shell#dir
+--- Shell#getwd
+--- Shell#pwd
+
+ ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤òÊÖ¤¹¡£
+
+--- Shell#system_path
+
+ ¥³¥Þ¥ó¥É¥µ¡¼¥Á¥Ñ¥¹¤ÎÇÛÎó¤òÊÖ¤¹¡£
+
+--- Shell#umask
+
+ umask¤òÊÖ¤¹¡£
+
+== Filter
+
+¥³¥Þ¥ó¥É¤Î¼Â¹Ô·ë²Ì¤Ï¤¹¤Ù¤ÆFilter¤È¤·¤Æ¤«¤¨¤ê¤Þ¤¹. Enumerable¤òinclude¤·
+¤Æ¤¤¤Þ¤¹.
+
+= ¼ç¤Ê¥á¥½¥Ã¥É°ìÍ÷
+
+== ¥³¥Þ¥ó¥ÉÄêµÁ
+
+OS¾å¤Î¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤¹¤ë¤Ë¤Ï¤Þ¤º, Shell¤Î¥á¥½¥Ã¥É¤È¤·¤ÆÄêµÁ¤·¤Þ¤¹.
+
+Ãí) ¥³¥Þ¥ó¥É¤òÄêµÁ¤·¤Ê¤¯¤È¤âľÀܼ¹ԤǤ­¤ëShell#system¥³¥Þ¥ó¥É¤â¤¢¤ê¤Þ¤¹.
+
+--- Shell.def_system_command(command, path = command)
+
+ Shell¤Î¥á¥½¥Ã¥É¤È¤·¤Æcommand¤òÅÐÏ¿¤·¤Þ¤¹.
+
+ Îã)
+ Shell.def_system_command "ls"
+ ls ¤òÄêµÁ
+
+ Shell.def_system_command "sys_sort", "sort"
+ sort¥³¥Þ¥ó¥É¤òsys_sort¤È¤·¤ÆÄêµÁ
+
+--- Shell.undef_system_command(command)
+
+ command¤òºï½ü¤·¤Þ¤¹.
+
+--- Shell.alias_command(ali, command, *opts) {...}
+
+ command¤Îalias¤ò¤·¤Þ¤¹.
+
+ Îã)
+ Shell.alias_command "lsC", "ls", "-CBF", "--show-control-chars"
+ Shell.alias_command("lsC", "ls"){|*opts| ["-CBF", "--show-control-chars", *opts]}
+
+--- Shell.unalias_command(ali)
+
+ command¤Îalias¤òºï½ü¤·¤Þ¤¹.
+
+--- Shell.install_system_commands(pre = "sys_")
+
+ system_path¾å¤Ë¤¢¤ëÁ´¤Æ¤Î¼Â¹Ô²Äǽ¥Õ¥¡¥¤¥ë¤òShell¤ËÄêµÁ¤¹¤ë. ¥á¥½¥Ã
+ ¥É̾¤Ï¸µ¤Î¥Õ¥¡¥¤¥ë̾¤ÎƬ¤Ëpre¤ò¤Ä¤±¤¿¤â¤Î¤È¤Ê¤ë.
+
+== À¸À®
+
+--- Shell.new
+
+ ¥×¥í¥»¥¹¤Î¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤ò¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤È¤¹¤ëShell¥ª
+ ¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤·¤Þ¤¹.
+
+--- Shell.cd(path)
+
+ path¤ò¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤È¤¹¤ëShell¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤·¤Þ¤¹.
+
+== ¥×¥í¥»¥¹´ÉÍý
+
+--- Shell#jobs
+
+ ¥¹¥±¥¸¥å¡¼¥ê¥ó¥°¤µ¤ì¤Æ¤¤¤ëjob¤Î°ìÍ÷¤òÊÖ¤¹.
+
+--- Shell#kill sig, job
+
+ job¤Ë¥·¥°¥Ê¥ësig¤òÁ÷¤ë
+
+== ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥êÁàºî
+
+--- Shell#cd(path, &block)
+--- Shell#chdir
+
+ ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤òpath¤Ë¤¹¤ë. ¥¤¥Æ¥ì¡¼¥¿¤È¤·¤Æ¸Æ¤Ð¤ì¤¿¤È¤­¤Ë¤Ï
+ ¥Ö¥í¥Ã¥¯¼Â¹ÔÃæ¤Î¤ß¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤òÊѹ¹¤¹¤ë.
+
+--- Shell#pushd(path = nil, &block)
+--- Shell#pushdir
+
+ ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤ò¥Ç¥£¥ì¥¯¥È¥ê¥¹¥¿¥Ã¥¯¤Ë¤Ä¤ß, ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯
+ ¥È¥ê¤òpath¤Ë¤¹¤ë. path¤¬¾Êά¤µ¤ì¤¿¤È¤­¤Ë¤Ï, ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤È
+ ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥¿¥Ã¥¯¤Î¥È¥Ã¥×¤ò¸ò´¹¤¹¤ë. ¥¤¥Æ¥ì¡¼¥¿¤È¤·¤Æ¸Æ¤Ð¤ì¤¿¤È
+ ¤­¤Ë¤Ï, ¥Ö¥í¥Ã¥¯¼Â¹ÔÃæ¤Î¤ßpushd¤¹¤ë.
+
+--- Shell#popd
+--- Shell#popdir
+
+ ¥Ç¥£¥ì¥¯¥È¥ê¥¹¥¿¥Ã¥¯¤«¤é¥Ý¥Ã¥×¤·, ¤½¤ì¤ò¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤¹¤ë.
+
+== ¥Õ¥¡¥¤¥ë/¥Ç¥£¥ì¥¯¥È¥êÁàºî
+
+--- Shell#foreach(path = nil, &block)
+
+ path¤¬¥Õ¥¡¥¤¥ë¤Ê¤é, File#foreach
+ path¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ê¤é, Dir#foreach
+
+--- Shell#open(path, mode)
+
+ path¤¬¥Õ¥¡¥¤¥ë¤Ê¤é, File#open
+ path¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ê¤é, Dir#open
+
+--- Shell#unlink(path)
+
+ path¤¬¥Õ¥¡¥¤¥ë¤Ê¤é, File#unlink
+ path¤¬¥Ç¥£¥ì¥¯¥È¥ê¤Ê¤é, Dir#unlink
+
+--- Shell#test(command, file1, file2)
+--- Shell#[command, file1, file2]
+
+ ¥Õ¥¡¥¤¥ë¥Æ¥¹¥È´Ø¿ôtest¤ÈƱ¤¸.
+ Îã)
+ sh[?e, "foo"]
+ sh[:e, "foo"]
+ sh["e", "foo"]
+ sh[:exists?, "foo"]
+ sh["exists?", "foo"]
+
+--- Shell#mkdir(*path)
+
+ Dir.mkdir¤ÈƱ¤¸(Ê£¿ô²Ä)
+
+--- Shell#rmdir(*path)
+
+ Dir.rmdir¤ÈƱ¤¸(Ê£¿ô²Ä)
+
+== ¥³¥Þ¥ó¥É¼Â¹Ô
+
+--- System#system(command, *opts)
+
+ command¤ò¼Â¹Ô¤¹¤ë.
+ Îã)
+ print sh.system("ls", "-l")
+ sh.system("ls", "-l") | sh.head > STDOUT
+
+--- System#rehash
+
+ ¥ê¥Ï¥Ã¥·¥å¤¹¤ë
+
+--- Shell#transact &block
+
+ ¥Ö¥í¥Ã¥¯Ãæ¤Ç¤Ïshell¤òself¤È¤·¤Æ¼Â¹Ô¤¹¤ë.
+ Îã)
+ sh.transact{system("ls", "-l") | head > STDOUT}
+
+--- Shell#out(dev = STDOUT, &block)
+
+ transact¤ò¸Æ¤Ó½Ð¤·¤½¤Î·ë²Ì¤òdev¤Ë½ÐÎϤ¹¤ë.
+
+== ÆâÉô¥³¥Þ¥ó¥É
+
+--- Shell#echo(*strings)
+--- Shell#cat(*files)
+--- Shell#glob(patten)
+--- Shell#tee(file)
+
+ ¤³¤ì¤é¤Ï¼Â¹Ô¤¹¤ë¤È, ¤½¤ì¤é¤òÆâÍÆ¤È¤¹¤ëFilter¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹.
+
+--- Filter#each &block
+
+ ¥Õ¥£¥ë¥¿¤Î°ì¹Ô¤º¤Ä¤òblock¤ËÅϤ¹.
+
+--- Filter#<(src)
+
+ src¤ò¥Õ¥£¥ë¥¿¤ÎÆþÎϤȤ¹¤ë. src¤¬, ʸ»úÎó¤Ê¤é¤Ð¥Õ¥¡¥¤¥ë¤ò, IO¤Ç¤¢¤ì
+ ¤Ð¤½¤ì¤ò¤½¤Î¤Þ¤ÞÆþÎϤȤ¹¤ë.
+
+--- Filter#>(to)
+
+ src¤ò¥Õ¥£¥ë¥¿¤Î½ÐÎϤȤ¹¤ë. to¤¬, ʸ»úÎó¤Ê¤é¤Ð¥Õ¥¡¥¤¥ë¤Ë, IO¤Ç¤¢¤ì
+ ¤Ð¤½¤ì¤ò¤½¤Î¤Þ¤Þ½ÐÎϤȤ¹¤ë.
+
+--- Filter#>>(to)
+
+ src¤ò¥Õ¥£¥ë¥¿¤ËÄɲ乤ë. to¤¬, ʸ»úÎó¤Ê¤é¤Ð¥Õ¥¡¥¤¥ë¤Ë, IO¤Ç¤¢¤ì¤Ð
+ ¤½¤ì¤ò¤½¤Î¤Þ¤Þ½ÐÎϤȤ¹¤ë.
+
+--- Filter#|(filter)
+
+ ¥Ñ¥¤¥×·ë¹ç
+
+--- Filter#+(filter)
+
+ filter1 + filter2 ¤Ï filter1¤Î½ÐÎϤθå, filter2¤Î½ÐÎϤò¹Ô¤¦.
+
+--- Filter#to_a
+--- Filter#to_s
+
+== Áȹþ¤ß¥³¥Þ¥ó¥É
+
+--- Shell#atime(file)
+--- Shell#basename(file, *opt)
+--- Shell#chmod(mode, *files)
+--- Shell#chown(owner, group, *file)
+--- Shell#ctime(file)
+--- Shell#delete(*file)
+--- Shell#dirname(file)
+--- Shell#ftype(file)
+--- Shell#join(*file)
+--- Shell#link(file_from, file_to)
+--- Shell#lstat(file)
+--- Shell#mtime(file)
+--- Shell#readlink(file)
+--- Shell#rename(file_from, file_to)
+--- Shell#split(file)
+--- Shell#stat(file)
+--- Shell#symlink(file_from, file_to)
+--- Shell#truncate(file, length)
+--- Shell#utime(atime, mtime, *file)
+
+ ¤³¤ì¤é¤ÏFile¥¯¥é¥¹¤Ë¤¢¤ëƱ̾¤Î¥¯¥é¥¹¥á¥½¥Ã¥É¤ÈƱ¤¸¤Ç¤¹.
+
+--- Shell#blockdev?(file)
+--- Shell#chardev?(file)
+--- Shell#directory?(file)
+--- Shell#executable?(file)
+--- Shell#executable_real?(file)
+--- Shell#exist?(file)/Shell#exists?(file)
+--- Shell#file?(file)
+--- Shell#grpowned?(file)
+--- Shell#owned?(file)
+--- Shell#pipe?(file)
+--- Shell#readable?(file)
+--- Shell#readable_real?(file)
+--- Shell#setgid?(file)
+--- Shell#setuid?(file)
+--- Shell#size(file)/Shell#size?(file)
+--- Shell#socket?(file)
+--- Shell#sticky?(file)
+--- Shell#symlink?(file)
+--- Shell#writable?(file)
+--- Shell#writable_real?(file)
+--- Shell#zero?(file)
+
+ ¤³¤ì¤é¤ÏFileTest¥¯¥é¥¹¤Ë¤¢¤ëƱ̾¤Î¥¯¥é¥¹¥á¥½¥Ã¥É¤ÈƱ¤¸¤Ç¤¹.
+
+--- Shell#syscopy(filename_from, filename_to)
+--- Shell#copy(filename_from, filename_to)
+--- Shell#move(filename_from, filename_to)
+--- Shell#compare(filename_from, filename_to)
+--- Shell#safe_unlink(*filenames)
+--- Shell#makedirs(*filenames)
+--- Shell#install(filename_from, filename_to, mode)
+
+ ¤³¤ì¤é¤ÏFileTools¥¯¥é¥¹¤Ë¤¢¤ëƱ̾¤Î¥¯¥é¥¹¥á¥½¥Ã¥É¤ÈƱ¤¸¤Ç¤¹.
+
+ ¤½¤Î¾, °Ê²¼¤Î¤â¤Î¤¬¥¨¥¤¥ê¥¢¥¹¤µ¤ì¤Æ¤¤¤Þ¤¹.
+
+--- Shell#cmp <- Shell#compare
+--- Shell#mv <- Shell#move
+--- Shell#cp <- Shell#copy
+--- Shell#rm_f <- Shell#safe_unlink
+--- Shell#mkpath <- Shell#makedirs
+
+= ¥µ¥ó¥×¥ë
+
+== ex1
+
+ sh = Shell.cd("/tmp")
+ sh.mkdir "shell-test-1" unless sh.exists?("shell-test-1")
+ sh.cd("shell-test-1")
+ for dir in ["dir1", "dir3", "dir5"]
+ if !sh.exists?(dir)
+ sh.mkdir dir
+ sh.cd(dir) do
+ f = sh.open("tmpFile", "w")
+ f.print "TEST\n"
+ f.close
+ end
+ print sh.pwd
+ end
+ end
+
+== ex2
+
+ sh = Shell.cd("/tmp")
+ sh.transact do
+ mkdir "shell-test-1" unless exists?("shell-test-1")
+ cd("shell-test-1")
+ for dir in ["dir1", "dir3", "dir5"]
+ if !exists?(dir)
+ mkdir dir
+ cd(dir) do
+ f = open("tmpFile", "w")
+ f.print "TEST\n"
+ f.close
+ end
+ print pwd
+ end
+ end
+ end
+
+== ex3
+
+ sh.cat("/etc/printcap") | sh.tee("tee1") > "tee2"
+ (sh.cat < "/etc/printcap") | sh.tee("tee11") > "tee12"
+ sh.cat("/etc/printcap") | sh.tee("tee1") >> "tee2"
+ (sh.cat < "/etc/printcap") | sh.tee("tee11") >> "tee12"
+
+== ex4
+
+ print sh.cat("/etc/passwd").head.collect{|l| l =~ /keiju/}
+
+=end
diff --git a/enum.c b/enum.c
index 4a97811384..a745a6e604 100644
--- a/enum.c
+++ b/enum.c
@@ -6,12 +6,13 @@
$Date$
created at: Fri Oct 1 15:15:19 JST 1993
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
#include "ruby.h"
#include "node.h"
+#include "util.h"
VALUE rb_mEnumerable;
static ID id_each, id_eqq, id_cmp;
@@ -43,20 +44,37 @@ grep_iter_i(i, arg)
return Qnil;
}
+/*
+ * call-seq:
+ * enum.grep(pattern) => array
+ * enum.grep(pattern) {| obj | block } => array
+ *
+ * Returns an array of every element in <i>enum</i> for which
+ * <code>Pattern === element</code>. If the optional <em>block</em> is
+ * supplied, each matching element is passed to it, and the block's
+ * result is stored in the output array.
+ *
+ * (1..100).grep 38..44 #=> [38, 39, 40, 41, 42, 43, 44]
+ * c = IO.constants
+ * c.grep(/SEEK/) #=> ["SEEK_END", "SEEK_SET", "SEEK_CUR"]
+ * res = c.grep(/SEEK/) {|v| IO.const_get(v) }
+ * res #=> [2, 0, 1]
+ *
+ */
+
static VALUE
enum_grep(obj, pat)
VALUE obj, pat;
{
- VALUE tmp, arg[2];
+ VALUE ary = rb_ary_new();
+ VALUE arg[2];
- arg[0] = pat; arg[1] = tmp = rb_ary_new();
- if (rb_block_given_p()) {
- rb_iterate(rb_each, obj, grep_iter_i, (VALUE)arg);
- }
- else {
- rb_iterate(rb_each, obj, grep_i, (VALUE)arg);
- }
- return tmp;
+ arg[0] = pat;
+ arg[1] = ary;
+
+ rb_iterate(rb_each, obj, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)arg);
+
+ return ary;
}
static VALUE
@@ -72,6 +90,21 @@ find_i(i, memo)
return Qnil;
}
+/*
+ * call-seq:
+ * enum.detect(ifnone = nil) {| obj | block } => obj or nil
+ * enum.find(ifnone = nil) {| obj | block } => obj or nil
+ *
+ * Passes each entry in <i>enum</i> to <em>block</em>. Returns the
+ * first for which <em>block</em> is not <code>false</code>. If no
+ * object matches, calls <i>ifnone</i> and returns its result when it
+ * is specified, or returns <code>nil</code>
+ *
+ * (1..10).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> nil
+ * (1..100).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> 35
+ *
+ */
+
static VALUE
enum_find(argc, argv, obj)
int argc;
@@ -84,100 +117,263 @@ enum_find(argc, argv, obj)
rb_scan_args(argc, argv, "01", &if_none);
rb_iterate(rb_each, obj, find_i, (VALUE)memo);
if (memo->u2.value) {
- rb_gc_force_recycle((VALUE)memo);
return memo->u1.value;
}
if (!NIL_P(if_none)) {
- rb_eval_cmd(if_none, rb_ary_new2(0));
+ return rb_funcall(if_none, rb_intern("call"), 0, 0);
}
- rb_gc_force_recycle((VALUE)memo);
return Qnil;
}
static VALUE
-find_all_i(i, tmp)
- VALUE i, tmp;
+find_all_i(i, ary)
+ VALUE i, ary;
{
if (RTEST(rb_yield(i))) {
- rb_ary_push(tmp, i);
+ rb_ary_push(ary, i);
}
return Qnil;
}
+/*
+ * call-seq:
+ * enum.find_all {| obj | block } => array
+ * enum.select {| obj | block } => array
+ *
+ * Returns an array containing all elements of <i>enum</i> for which
+ * <em>block</em> is not <code>false</code> (see also
+ * <code>Enumerable#reject</code>).
+ *
+ * (1..10).find_all {|i| i % 3 == 0 } #=> [3, 6, 9]
+ *
+ */
+
static VALUE
enum_find_all(obj)
VALUE obj;
{
- VALUE tmp;
-
- tmp = rb_ary_new();
- rb_iterate(rb_each, obj, find_all_i, tmp);
+ VALUE ary = rb_ary_new();
+
+ rb_iterate(rb_each, obj, find_all_i, ary);
- return tmp;
+ return ary;
}
static VALUE
-reject_i(i, tmp)
- VALUE i, tmp;
+reject_i(i, ary)
+ VALUE i, ary;
{
if (!RTEST(rb_yield(i))) {
- rb_ary_push(tmp, i);
+ rb_ary_push(ary, i);
}
return Qnil;
}
+/*
+ * call-seq:
+ * enum.reject {| obj | block } => array
+ *
+ * Returns an array for all elements of <i>enum</i> for which
+ * <em>block</em> is false (see also <code>Enumerable#find_all</code>).
+ *
+ * (1..10).reject {|i| i % 3 == 0 } #=> [1, 2, 4, 5, 7, 8, 10]
+ *
+ */
+
static VALUE
enum_reject(obj)
VALUE obj;
{
- VALUE tmp;
+ VALUE ary = rb_ary_new();
+
+ rb_iterate(rb_each, obj, reject_i, ary);
- tmp = rb_ary_new();
- rb_iterate(rb_each, obj, reject_i, tmp);
-
- return tmp;
+ return ary;
}
static VALUE
-collect_i(i, tmp)
- VALUE i, tmp;
+collect_i(i, ary)
+ VALUE i, ary;
{
- rb_ary_push(tmp, rb_yield(i));
+ rb_ary_push(ary, rb_yield(i));
+
return Qnil;
}
static VALUE
-enum_all(i, ary)
+collect_all(i, ary)
VALUE i, ary;
{
rb_ary_push(ary, i);
+
return Qnil;
}
+/*
+ * call-seq:
+ * enum.collect {| obj | block } => array
+ * enum.map {| obj | block } => array
+ *
+ * Returns a new array with the results of running <em>block</em> once
+ * for every element in <i>enum</i>.
+ *
+ * (1..4).collect {|i| i*i } #=> [1, 4, 9, 16]
+ * (1..4).collect { "cat" } #=> ["cat", "cat", "cat", "cat"]
+ *
+ */
+
+static VALUE
+enum_collect(obj)
+ VALUE obj;
+{
+ VALUE ary = rb_ary_new();
+
+ rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : collect_all, ary);
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * enum.to_a => array
+ * enum.entries => array
+ *
+ * Returns an array containing the items in <i>enum</i>.
+ *
+ * (1..7).to_a #=> [1, 2, 3, 4, 5, 6, 7]
+ * { 'a'=>1, 'b'=>2, 'c'=>3 }.to_a #=> [["a", 1], ["b", 2], ["c", 3]]
+ */
static VALUE
enum_to_a(obj)
VALUE obj;
{
- VALUE ary;
+ VALUE ary = rb_ary_new();
- ary = rb_ary_new();
- rb_iterate(rb_each, obj, enum_all, ary);
+ rb_iterate(rb_each, obj, collect_all, ary);
return ary;
}
static VALUE
-enum_collect(obj)
+inject_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (memo->u2.value) {
+ memo->u2.value = Qfalse;
+ memo->u1.value = i;
+ }
+ else {
+ memo->u1.value = rb_yield_values(2, memo->u1.value, i);
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * enum.inject(initial) {| memo, obj | block } => obj
+ * enum.inject {| memo, obj | block } => obj
+ *
+ * Combines the elements of <i>enum</i> by applying the block to an
+ * accumulator value (<i>memo</i>) and each element in turn. At each
+ * step, <i>memo</i> is set to the value returned by the block. The
+ * first form lets you supply an initial value for <i>memo</i>. The
+ * second form uses the first element of the collection as a the
+ * initial value (and skips that element while iterating).
+ *
+ * # Sum some numbers
+ * (5..10).inject {|sum, n| sum + n } #=> 45
+ * # Multiply some numbers
+ * (5..10).inject(1) {|product, n| product * n } #=> 151200
+ *
+ * # find the longest word
+ * longest = %w{ cat sheep bear }.inject do |memo,word|
+ * memo.length > word.length ? memo : word
+ * end
+ * longest #=> "sheep"
+ *
+ * # find the length of the longest word
+ * longest = %w{ cat sheep bear }.inject(0) do |memo,word|
+ * memo >= word.length ? memo : word.length
+ * end
+ * longest #=> 5
+ *
+ */
+
+static VALUE
+enum_inject(argc, argv, obj)
+ int argc;
+ VALUE *argv, obj;
+{
+ NODE *memo;
+ VALUE n;
+
+ if (rb_scan_args(argc, argv, "01", &n) == 1) {
+ memo = rb_node_newnode(NODE_MEMO, n, Qfalse, 0);
+ }
+ else {
+ memo = rb_node_newnode(NODE_MEMO, Qnil, Qtrue, 0);
+ }
+ rb_iterate(rb_each, obj, inject_i, (VALUE)memo);
+ n = memo->u1.value;
+ return n;
+}
+
+static VALUE
+partition_i(i, ary)
+ VALUE i, *ary;
+{
+ if (RTEST(rb_yield(i))) {
+ rb_ary_push(ary[0], i);
+ }
+ else {
+ rb_ary_push(ary[1], i);
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * enum.partition {| obj | block } => [ true_array, false_array ]
+ *
+ * Returns two arrays, the first containing the elements of
+ * <i>enum</i> for which the block evaluates to true, the second
+ * containing the rest.
+ *
+ * (1..6).partition {|i| (i&1).zero?} #=> [[2, 4, 6], [1, 3, 5]]
+ *
+ */
+
+static VALUE
+enum_partition(obj)
VALUE obj;
{
- VALUE tmp;
+ VALUE ary[2];
- tmp = rb_ary_new();
- rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : enum_all, tmp);
+ ary[0] = rb_ary_new();
+ ary[1] = rb_ary_new();
+ rb_iterate(rb_each, obj, partition_i, (VALUE)ary);
- return tmp;
+ return rb_assoc_new(ary[0], ary[1]);
}
+/*
+ * call-seq:
+ * enum.sort => array
+ * enum.sort {| a, b | block } => array
+ *
+ * Returns an array containing the items in <i>enum</i> sorted,
+ * either according to their own <code><=></code> method, or by using
+ * the results of the supplied block. The block should return -1, 0, or
+ * +1 depending on the comparison between <i>a</i> and <i>b</i>. As of
+ * Ruby 1.8, the method <code>Enumerable#sort_by</code> implements a
+ * built-in Schwartzian Transform, useful when key computation or
+ * comparison is expensive..
+ *
+ * %w(rhea kea flea).sort #=> ["flea", "kea", "rhea"]
+ * (1..10).sort {|a,b| b <=> a} #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
+ */
+
static VALUE
enum_sort(obj)
VALUE obj;
@@ -186,18 +382,252 @@ enum_sort(obj)
}
static VALUE
+sort_by_i(i, ary)
+ VALUE i, ary;
+{
+ VALUE v;
+ NODE *memo;
+
+ v = rb_yield(i);
+ if (RBASIC(ary)->klass) {
+ rb_raise(rb_eRuntimeError, "sort_by reentered");
+ }
+ memo = rb_node_newnode(NODE_MEMO, v, i, 0);
+ rb_ary_push(ary, (VALUE)memo);
+ return Qnil;
+}
+
+static int
+sort_by_cmp(aa, bb)
+ NODE **aa, **bb;
+{
+ VALUE a = aa[0]->u1.value;
+ VALUE b = bb[0]->u1.value;
+
+ return rb_cmpint(rb_funcall(a, id_cmp, 1, b), a, b);
+}
+
+/*
+ * call-seq:
+ * enum.sort_by {| obj | block } => array
+ *
+ * Sorts <i>enum</i> using a set of keys generated by mapping the
+ * values in <i>enum</i> through the given block.
+ *
+ * %w{ apple pear fig }.sort_by {|word| word.length}
+ #=> ["fig", "pear", "apple"]
+ *
+ * The current implementation of <code>sort_by</code> generates an
+ * array of tuples containing the original collection element and the
+ * mapped value. This makes <code>sort_by</code> fairly expensive when
+ * the keysets are simple
+ *
+ * require 'benchmark'
+ * include Benchmark
+ *
+ * a = (1..100000).map {rand(100000)}
+ *
+ * bm(10) do |b|
+ * b.report("Sort") { a.sort }
+ * b.report("Sort by") { a.sort_by {|a| a} }
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * user system total real
+ * Sort 0.180000 0.000000 0.180000 ( 0.175469)
+ * Sort by 1.980000 0.040000 2.020000 ( 2.013586)
+ *
+ * However, consider the case where comparing the keys is a non-trivial
+ * operation. The following code sorts some files on modification time
+ * using the basic <code>sort</code> method.
+ *
+ * files = Dir["*"]
+ * sorted = files.sort {|a,b| File.new(a).mtime <=> File.new(b).mtime}
+ * sorted #=> ["mon", "tues", "wed", "thurs"]
+ *
+ * This sort is inefficient: it generates two new <code>File</code>
+ * objects during every comparison. A slightly better technique is to
+ * use the <code>Kernel#test</code> method to generate the modification
+ * times directly.
+ *
+ * files = Dir["*"]
+ * sorted = files.sort { |a,b|
+ * test(?M, a) <=> test(?M, b)
+ * }
+ * sorted #=> ["mon", "tues", "wed", "thurs"]
+ *
+ * This still generates many unnecessary <code>Time</code> objects. A
+ * more efficient technique is to cache the sort keys (modification
+ * times in this case) before the sort. Perl users often call this
+ * approach a Schwartzian Transform, after Randal Schwartz. We
+ * construct a temporary array, where each element is an array
+ * containing our sort key along with the filename. We sort this array,
+ * and then extract the filename from the result.
+ *
+ * sorted = Dir["*"].collect { |f|
+ * [test(?M, f), f]
+ * }.sort.collect { |f| f[1] }
+ * sorted #=> ["mon", "tues", "wed", "thurs"]
+ *
+ * This is exactly what <code>sort_by</code> does internally.
+ *
+ * sorted = Dir["*"].sort_by {|f| test(?M, f)}
+ * sorted #=> ["mon", "tues", "wed", "thurs"]
+ */
+
+static VALUE
+enum_sort_by(obj)
+ VALUE obj;
+{
+ VALUE ary;
+ long i;
+
+ if (TYPE(obj) == T_ARRAY) {
+ ary = rb_ary_new2(RARRAY(obj)->len);
+ }
+ else {
+ ary = rb_ary_new();
+ }
+ RBASIC(ary)->klass = 0;
+ rb_iterate(rb_each, obj, sort_by_i, ary);
+ if (RARRAY(ary)->len > 1) {
+ qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp, 0);
+ }
+ if (RBASIC(ary)->klass) {
+ rb_raise(rb_eRuntimeError, "sort_by reentered");
+ }
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ RARRAY(ary)->ptr[i] = RNODE(RARRAY(ary)->ptr[i])->u2.value;
+ }
+ RBASIC(ary)->klass = rb_cArray;
+ return ary;
+}
+
+static VALUE
+all_iter_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (!RTEST(rb_yield(i))) {
+ memo->u1.value = Qfalse;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+static VALUE
+all_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (!RTEST(i)) {
+ memo->u1.value = Qfalse;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * enum.all? [{|obj| block } ] => true or false
+ *
+ * Passes each element of the collection to the given block. The method
+ * returns <code>true</code> if the block never returns
+ * <code>false</code> or <code>nil</code>. If the block is not given,
+ * Ruby adds an implicit block of <code>{|obj| obj}</code> (that is
+ * <code>all?</code> will return <code>true</code> only if none of the
+ * collection members are <code>false</code> or <code>nil</code>.)
+ *
+ * %w{ ant bear cat}.all? {|word| word.length >= 3} #=> true
+ * %w{ ant bear cat}.all? {|word| word.length >= 4} #=> false
+ * [ nil, true, 99 ].all? #=> false
+ *
+ */
+
+static VALUE
+enum_all(obj)
+ VALUE obj;
+{
+ VALUE result;
+ NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
+
+ memo->u1.value = Qtrue;
+ rb_iterate(rb_each, obj, rb_block_given_p() ? all_iter_i : all_i, (VALUE)memo);
+ result = memo->u1.value;
+ return result;
+}
+
+static VALUE
+any_iter_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (RTEST(rb_yield(i))) {
+ memo->u1.value = Qtrue;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+static VALUE
+any_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (RTEST(i)) {
+ memo->u1.value = Qtrue;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * enum.any? [{|obj| block } ] => true or false
+ *
+ * Passes each element of the collection to the given block. The method
+ * returns <code>true</code> if the block ever returns a value other
+ * that <code>false</code> or <code>nil</code>. If the block is not
+ * given, Ruby adds an implicit block of <code>{|obj| obj}</code> (that
+ * is <code>any?</code> will return <code>true</code> if at least one
+ * of the collection members is not <code>false</code> or
+ * <code>nil</code>.
+ *
+ * %w{ ant bear cat}.any? {|word| word.length >= 3} #=> true
+ * %w{ ant bear cat}.any? {|word| word.length >= 4} #=> true
+ * [ nil, true, 99 ].any? #=> true
+ *
+ */
+
+static VALUE
+enum_any(obj)
+ VALUE obj;
+{
+ VALUE result;
+ NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
+
+ memo->u1.value = Qfalse;
+ rb_iterate(rb_each, obj, rb_block_given_p() ? any_iter_i : any_i, (VALUE)memo);
+ result = memo->u1.value;
+ return result;
+}
+
+static VALUE
min_i(i, memo)
VALUE i;
NODE *memo;
{
VALUE cmp;
- if (NIL_P(memo->u1.value))
+ if (NIL_P(memo->u1.value)) {
memo->u1.value = i;
+ }
else {
cmp = rb_funcall(i, id_cmp, 1, memo->u1.value);
- if (NUM2LONG(cmp) < 0)
+ if (rb_cmpint(cmp, i, memo->u1.value) < 0) {
memo->u1.value = i;
+ }
}
return Qnil;
}
@@ -209,27 +639,59 @@ min_ii(i, memo)
{
VALUE cmp;
- if (NIL_P(memo->u1.value))
+ if (NIL_P(memo->u1.value)) {
memo->u1.value = i;
+ }
else {
- cmp = rb_yield(rb_assoc_new(i, memo->u1.value));
- if (NUM2LONG(cmp) < 0)
+ cmp = rb_yield_values(2, i, memo->u1.value);
+ if (rb_cmpint(cmp, i, memo->u1.value) < 0) {
memo->u1.value = i;
+ }
}
return Qnil;
}
+
+/*
+ * call-seq:
+ * enum.min => obj
+ * enum.min {| a,b | block } => obj
+ *
+ * Returns the object in <i>enum</i> with the minimum value. The
+ * first form assumes all objects implement <code>Comparable</code>;
+ * the second uses the block to return <em>a <=> b</em>.
+ *
+ * a = %w(albatross dog horse)
+ * a.min #=> "albatross"
+ * a.min {|a,b| a.length <=> b.length } #=> "dog"
+ */
+
static VALUE
enum_min(obj)
VALUE obj;
{
+ VALUE result;
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
- rb_iterate(rb_each, obj, rb_block_given_p()?min_ii:min_i, (VALUE)memo);
- rb_gc_force_recycle((VALUE)memo);
- return memo->u1.value;
+ rb_iterate(rb_each, obj, rb_block_given_p() ? min_ii : min_i, (VALUE)memo);
+ result = memo->u1.value;
+ return result;
}
+/*
+ * call-seq:
+ * enum.max => obj
+ * enum.max {| a,b | block } => obj
+ *
+ * Returns the object in <i>enum</i> with the maximum value. The
+ * first form assumes all objects implement <code>Comparable</code>;
+ * the second uses the block to return <em>a <=> b</em>.
+ *
+ * a = %w(albatross dog horse)
+ * a.max #=> "horse"
+ * a.max {|a,b| a.length <=> b.length } #=> "albatross"
+ */
+
static VALUE
max_i(i, memo)
VALUE i;
@@ -237,12 +699,14 @@ max_i(i, memo)
{
VALUE cmp;
- if (NIL_P(memo->u1.value))
+ if (NIL_P(memo->u1.value)) {
memo->u1.value = i;
+ }
else {
cmp = rb_funcall(i, id_cmp, 1, memo->u1.value);
- if (NUM2LONG(cmp) > 0)
+ if (rb_cmpint(cmp, i, memo->u1.value) > 0) {
memo->u1.value = i;
+ }
}
return Qnil;
}
@@ -254,25 +718,42 @@ max_ii(i, memo)
{
VALUE cmp;
- if (NIL_P(memo->u1.value))
+ if (NIL_P(memo->u1.value)) {
memo->u1.value = i;
+ }
else {
- cmp = rb_yield(rb_assoc_new(i, memo->u1.value));
- if (NUM2LONG(cmp) > 0)
+ cmp = rb_yield_values(2, i, memo->u1.value);
+ if (rb_cmpint(cmp, i, memo->u1.value) > 0) {
memo->u1.value = i;
+ }
}
return Qnil;
}
+/*
+ * call-seq:
+ * enum.max => obj
+ * enum.max {|a,b| block } => obj
+ *
+ * Returns the object in _enum_ with the maximum value. The
+ * first form assumes all objects implement <code>Comparable</code>;
+ * the second uses the block to return <em>a <=> b</em>.
+ *
+ * a = %w(albatross dog horse)
+ * a.max #=> "horse"
+ * a.max {|a,b| a.length <=> b.length } #=> "albatross"
+ */
+
static VALUE
enum_max(obj)
VALUE obj;
{
+ VALUE result;
NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
- rb_iterate(rb_each, obj, rb_block_given_p()?max_ii:max_i, (VALUE)memo);
- rb_gc_force_recycle((VALUE)memo);
- return memo->u1.value;
+ rb_iterate(rb_each, obj, rb_block_given_p() ? max_ii : max_i, (VALUE)memo);
+ result = memo->u1.value;
+ return result;
}
static VALUE
@@ -287,17 +768,28 @@ member_i(item, memo)
return Qnil;
}
+/*
+ * call-seq:
+ * enum.include?(obj) => true or false
+ * enum.member?(obj) => true or false
+ *
+ * Returns <code>true</code> if any member of <i>enum</i> equals
+ * <i>obj</i>. Equality is tested using <code>==</code>.
+ *
+ * IO.constants.include? "SEEK_SET" #=> true
+ * IO.constants.include? "SEEK_NO_FURTHER" #=> false
+ *
+ */
+
static VALUE
enum_member(obj, val)
VALUE obj, val;
{
VALUE result;
-
NODE *memo = rb_node_newnode(NODE_MEMO, val, Qfalse, 0);
rb_iterate(rb_each, obj, member_i, (VALUE)memo);
result = memo->u2.value;
- rb_gc_force_recycle((VALUE)memo);
return result;
}
@@ -306,11 +798,26 @@ each_with_index_i(val, memo)
VALUE val;
NODE *memo;
{
- rb_yield(rb_assoc_new(val, INT2FIX(memo->u3.cnt)));
+ rb_yield_values(2, val, INT2FIX(memo->u3.cnt));
memo->u3.cnt++;
return Qnil;
}
+/*
+ * call-seq:
+ * enum.each_with_index {|obj, i| block } -> enum
+ *
+ * Calls <em>block</em> with two arguments, the item and its index, for
+ * each item in <i>enum</i>.
+ *
+ * hash = Hash.new
+ * %w(cat dog wombat).each_with_index {|item, index|
+ * hash[item] = index
+ * }
+ * hash #=> {"cat"=>0, "wombat"=>2, "dog"=>1}
+ *
+ */
+
static VALUE
enum_each_with_index(obj)
VALUE obj;
@@ -318,10 +825,88 @@ enum_each_with_index(obj)
NODE *memo = rb_node_newnode(NODE_MEMO, 0, 0, 0);
rb_iterate(rb_each, obj, each_with_index_i, (VALUE)memo);
- rb_gc_force_recycle((VALUE)memo);
+ return obj;
+}
+
+static VALUE
+zip_i(val, memo)
+ VALUE val;
+ NODE *memo;
+{
+ VALUE result = memo->u1.value;
+ VALUE args = memo->u2.value;
+ int idx = memo->u3.cnt++;
+ VALUE tmp;
+ int i;
+
+ tmp = rb_ary_new2(RARRAY(args)->len + 1);
+ rb_ary_store(tmp, 0, val);
+ for (i=0; i<RARRAY(args)->len; i++) {
+ rb_ary_push(tmp, rb_ary_entry(RARRAY(args)->ptr[i], idx));
+ }
+ if (rb_block_given_p()) {
+ rb_yield(tmp);
+ }
+ else {
+ rb_ary_push(result, tmp);
+ }
return Qnil;
}
+/*
+ * call-seq:
+ * enum.zip(arg, ...) => array
+ * enum.zip(arg, ...) {|arr| block } => nil
+ *
+ * Converts any arguments to arrays, then merges elements of
+ * <i>enum</i> with corresponding elements from each argument. This
+ * generates a sequence of <code>enum#size</code> <em>n</em>-element
+ * arrays, where <em>n</em> is one more that the count of arguments. If
+ * the size of any argument is less than <code>enum#size</code>,
+ * <code>nil</code> values are supplied. If a block given, it is
+ * invoked for each output array, otherwise an array of arrays is
+ * returned.
+ *
+ * a = [ 4, 5, 6 ]
+ * b = [ 7, 8, 9 ]
+ *
+ * (1..3).zip(a, b) #=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
+ * "cat\ndog".zip([1]) #=> [["cat\n", 1], ["dog", nil]]
+ * (1..3).zip #=> [[1], [2], [3]]
+ *
+ */
+
+static VALUE
+enum_zip(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ int i;
+ VALUE result;
+ NODE *memo;
+
+ for (i=0; i<argc; i++) {
+ argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_a");
+ }
+ result = rb_block_given_p() ? Qnil : rb_ary_new();
+ memo = rb_node_newnode(NODE_MEMO, result, rb_ary_new4(argc, argv), 0);
+ rb_iterate(rb_each, obj, zip_i, (VALUE)memo);
+
+ return result;
+}
+
+/*
+ * The <code>Enumerable</code> mixin provides collection classes with
+ * several traversal and searching methods, and with the ability to
+ * sort. The class must provide a method <code>each</code>, which
+ * yields successive members of the collection. If
+ * <code>Enumerable#max</code>, <code>#min</code>, or
+ * <code>#sort</code> is used, the objects in the collection must also
+ * implement a meaningful <code><=></code> operator, as these methods
+ * rely on an ordering between members of the collection.
+ */
+
void
Init_Enumerable()
{
@@ -331,6 +916,7 @@ Init_Enumerable()
rb_define_method(rb_mEnumerable,"entries", enum_to_a, 0);
rb_define_method(rb_mEnumerable,"sort", enum_sort, 0);
+ rb_define_method(rb_mEnumerable,"sort_by", enum_sort_by, 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);
@@ -339,13 +925,19 @@ Init_Enumerable()
rb_define_method(rb_mEnumerable,"reject", enum_reject, 0);
rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
rb_define_method(rb_mEnumerable,"map", enum_collect, 0);
+ rb_define_method(rb_mEnumerable,"inject", enum_inject, -1);
+ rb_define_method(rb_mEnumerable,"partition", enum_partition, 0);
+ rb_define_method(rb_mEnumerable,"all?", enum_all, 0);
+ rb_define_method(rb_mEnumerable,"any?", enum_any, 0);
rb_define_method(rb_mEnumerable,"min", enum_min, 0);
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
rb_define_method(rb_mEnumerable,"include?", enum_member, 1);
rb_define_method(rb_mEnumerable,"each_with_index", enum_each_with_index, 0);
+ rb_define_method(rb_mEnumerable, "zip", enum_zip, -1);
id_eqq = rb_intern("===");
id_each = rb_intern("each");
id_cmp = rb_intern("<=>");
}
+
diff --git a/env.h b/env.h
index 7060fbec8f..c47c01d9db 100644
--- a/env.h
+++ b/env.h
@@ -6,7 +6,7 @@
$Date$
created at: Mon Jul 11 11:53:03 JST 1994
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
@@ -18,14 +18,14 @@ extern struct FRAME {
int argc;
VALUE *argv;
ID last_func;
+ ID orig_func;
VALUE last_class;
- VALUE cbase;
struct FRAME *prev;
struct FRAME *tmp;
- char *file;
- int line;
+ struct RNode *node;
int iter;
int flags;
+ unsigned long uniq;
} *ruby_frame;
void rb_gc_mark_frame _((struct FRAME *));
@@ -37,7 +37,7 @@ extern struct SCOPE {
struct RBasic super;
ID *local_tbl;
VALUE *local_vars;
- int flag;
+ int flags;
} *ruby_scope;
#define SCOPE_ALLOCA 0
diff --git a/error.c b/error.c
index 6a008cdac5..c67fce9d34 100644
--- a/error.c
+++ b/error.c
@@ -6,13 +6,13 @@
$Date$
created at: Mon Aug 9 16:11:34 JST 1993
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
#include "ruby.h"
#include "env.h"
-#include "version.h"
+#include "st.h"
#include <stdio.h>
#ifdef HAVE_STDARG_PROTOTYPES
@@ -22,34 +22,44 @@
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif
-
-#if defined __CYGWIN__
-# include <cygwin/version.h>
-# if (CYGWIN_VERSION_API_MAJOR > 0) || (CYGWIN_VERSION_API_MINOR >= 8)
-# define sys_nerr _sys_nerr
-# endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
#endif
+extern const char ruby_version[], ruby_release_date[], ruby_platform[];
+
int ruby_nerrs;
-static void
-err_snprintf(buf, len, fmt, args)
- char *buf, *fmt;
- int len;
- va_list args;
+static int
+err_position(buf, len)
+ char *buf;
+ long len;
{
- int n;
-
+ ruby_set_current_source();
if (!ruby_sourcefile) {
- vsnprintf(buf, len, fmt, args);
- return;
+ return 0;
}
else if (ruby_sourceline == 0) {
- n = snprintf(buf, len, "%s: ", ruby_sourcefile);
+ return snprintf(buf, len, "%s: ", ruby_sourcefile);
}
else {
- n = snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
+ return snprintf(buf, len, "%s:%d: ", ruby_sourcefile, ruby_sourceline);
}
+}
+
+static void
+err_snprintf(buf, len, fmt, args)
+ char *buf;
+ long len;
+ const char *fmt;
+ va_list args;
+{
+ long n;
+
+ n = err_position(buf, len);
if (len > n) {
vsnprintf((char*)buf+n, len-n, fmt, args);
}
@@ -108,11 +118,12 @@ warn_print(fmt, args)
va_list args;
{
char buf[BUFSIZ];
+ int len;
err_snprintf(buf, BUFSIZ, fmt, args);
- fputs(buf, stderr);
- fputs("\n", stderr);
- fflush(stderr);
+ len = strlen(buf);
+ buf[len++] = '\n';
+ rb_write_error2(buf, len);
}
void
@@ -127,6 +138,8 @@ rb_warn(fmt, va_alist)
char buf[BUFSIZ];
va_list args;
+ if (NIL_P(ruby_verbose)) return;
+
snprintf(buf, BUFSIZ, "warning: %s", fmt);
va_init_list(args, fmt);
@@ -156,6 +169,25 @@ rb_warning(fmt, va_alist)
va_end(args);
}
+/*
+ * call-seq:
+ * warn(msg) => nil
+ *
+ * Display the given message (followed by a newline) on STDERR unless
+ * warnings are disabled (for example with the <code>-W0</code> flag).
+ */
+
+static VALUE
+rb_warn_m(self, mesg)
+ VALUE self, mesg;
+{
+ if (!NIL_P(ruby_verbose)) {
+ rb_io_write(rb_stderr, mesg);
+ rb_io_write(rb_stderr, rb_default_rs);
+ }
+ return Qnil;
+}
+
void
#ifdef HAVE_STDARG_PROTOTYPES
rb_bug(const char *fmt, ...)
@@ -167,14 +199,18 @@ rb_bug(fmt, va_alist)
{
char buf[BUFSIZ];
va_list args;
-
- snprintf(buf, BUFSIZ, "[BUG] %s", fmt);
- ruby_in_eval = 0;
-
- va_init_list(args, fmt);
- warn_print(buf, args);
- va_end(args);
- fprintf(stderr, "ruby %s (%s) [%s]\n", RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM);
+ FILE *out = stderr;
+ int len = err_position(buf, BUFSIZ);
+
+ if (fwrite(buf, 1, len, out) == len ||
+ fwrite(buf, 1, len, (out = stdout)) == len) {
+ fputs("[BUG] ", out);
+ va_init_list(args, fmt);
+ vfprintf(out, fmt, args);
+ va_end(args);
+ fprintf(out, "\nruby %s (%s) [%s]\n\n",
+ ruby_version, ruby_release_date, ruby_platform);
+ }
abort();
}
@@ -182,30 +218,30 @@ static struct types {
int type;
const char *name;
} builtin_types[] = {
- T_NIL, "nil",
- T_OBJECT, "Object",
- T_CLASS, "Class",
- T_ICLASS, "iClass", /* internal use: mixed-in module holder */
- T_MODULE, "Module",
- T_FLOAT, "Float",
- T_STRING, "String",
- T_REGEXP, "Regexp",
- T_ARRAY, "Array",
- T_FIXNUM, "Fixnum",
- T_HASH, "Hash",
- T_STRUCT, "Struct",
- T_BIGNUM, "Bignum",
- T_FILE, "File",
- T_TRUE, "true",
- T_FALSE, "false",
- T_SYMBOL, "Symbol", /* :symbol */
- T_DATA, "Data", /* internal use: wrapped C pointers */
- T_MATCH, "Match", /* data of $~ */
- T_VARMAP, "Varmap", /* internal use: dynamic variables */
- T_SCOPE, "Scope", /* internal use: variable scope */
- T_NODE, "Node", /* internal use: syntax tree node */
- T_UNDEF, "undef", /* internal use: #undef; should not happen */
- -1, 0,
+ {T_NIL, "nil"},
+ {T_OBJECT, "Object"},
+ {T_CLASS, "Class"},
+ {T_ICLASS, "iClass"}, /* internal use: mixed-in module holder */
+ {T_MODULE, "Module"},
+ {T_FLOAT, "Float"},
+ {T_STRING, "String"},
+ {T_REGEXP, "Regexp"},
+ {T_ARRAY, "Array"},
+ {T_FIXNUM, "Fixnum"},
+ {T_HASH, "Hash"},
+ {T_STRUCT, "Struct"},
+ {T_BIGNUM, "Bignum"},
+ {T_FILE, "File"},
+ {T_TRUE, "true"},
+ {T_FALSE, "false"},
+ {T_SYMBOL, "Symbol"}, /* :symbol */
+ {T_DATA, "Data"}, /* internal use: wrapped C pointers */
+ {T_MATCH, "MatchData"}, /* data of $~ */
+ {T_VARMAP, "Varmap"}, /* internal use: dynamic variables */
+ {T_SCOPE, "Scope"}, /* internal use: variable scope */
+ {T_NODE, "Node"}, /* internal use: syntax tree node */
+ {T_UNDEF, "undef"}, /* internal use: #undef; should not happen */
+ {-1, 0}
};
void
@@ -230,11 +266,14 @@ rb_check_type(x, t)
else if (FIXNUM_P(x)) {
etype = "Fixnum";
}
+ else if (SYMBOL_P(x)) {
+ etype = "Symbol";
+ }
else if (rb_special_const_p(x)) {
etype = RSTRING(rb_obj_as_string(x))->ptr;
}
else {
- etype = rb_class2name(CLASS_OF(x));
+ etype = rb_obj_classname(x);
}
rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)",
etype, type->name);
@@ -259,12 +298,14 @@ VALUE rb_eTypeError;
VALUE rb_eArgError;
VALUE rb_eIndexError;
VALUE rb_eRangeError;
+VALUE rb_eNameError;
+VALUE rb_eNoMethodError;
VALUE rb_eSecurityError;
VALUE rb_eNotImpError;
VALUE rb_eNoMemError;
+static VALUE rb_cNameErrorMesg;
VALUE rb_eScriptError;
-VALUE rb_eNameError;
VALUE rb_eSyntaxError;
VALUE rb_eLoadError;
@@ -277,10 +318,7 @@ rb_exc_new(etype, ptr, len)
const char *ptr;
long len;
{
- VALUE exc = rb_obj_alloc(etype);
-
- rb_iv_set(exc, "mesg", rb_str_new(ptr, len));
- return exc;
+ return rb_funcall(etype, rb_intern("new"), 1, rb_str_new(ptr, len));
}
VALUE
@@ -295,60 +333,106 @@ VALUE
rb_exc_new3(etype, str)
VALUE etype, str;
{
- char *s;
- int len;
-
- s = rb_str2cstr(str, &len);
- return rb_exc_new(etype, s, len);
+ StringValue(str);
+ return rb_exc_new(etype, RSTRING(str)->ptr, RSTRING(str)->len);
}
+/*
+ * call-seq:
+ * Exception.new(msg = nil) => exception
+ *
+ * Construct a new Exception object, optionally passing in
+ * a message.
+ */
+
static VALUE
exc_initialize(argc, argv, exc)
int argc;
VALUE *argv;
VALUE exc;
{
- VALUE mesg;
+ VALUE arg;
- if (rb_scan_args(argc, argv, "01", &mesg) == 1) {
- STR2CSTR(mesg); /* ensure mesg can be converted to String */
- }
- rb_iv_set(exc, "mesg", mesg);
+ rb_scan_args(argc, argv, "01", &arg);
+ rb_iv_set(exc, "mesg", arg);
+ rb_iv_set(exc, "bt", Qnil);
return exc;
}
+/*
+ * Document-method: exception
+ *
+ * call-seq:
+ * exc.exception(string) -> an_exception or exc
+ *
+ * With no argument, or if the argument is the same as the receiver,
+ * return the receiver. Otherwise, create a new
+ * exception object of the same class as the receiver, but with a
+ * message equal to <code>string.to_str</code>.
+ *
+ */
+
static VALUE
exc_exception(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
{
- VALUE etype, exc;
+ VALUE exc;
if (argc == 0) return self;
if (argc == 1 && self == argv[0]) return self;
- etype = CLASS_OF(self);
- while (FL_TEST(etype, FL_SINGLETON)) {
- etype = RCLASS(etype)->super;
- }
- exc = rb_obj_alloc(etype);
- rb_obj_call_init(exc, argc, argv);
+ exc = rb_obj_clone(self);
+ exc_initialize(argc, argv, exc);
return exc;
}
+/*
+ * call-seq:
+ * exception.to_s => string
+ *
+ * Returns exception's message (or the name of the exception if
+ * no message is set).
+ */
+
static VALUE
exc_to_s(exc)
VALUE exc;
{
- VALUE mesg = rb_iv_get(exc, "mesg");
+ VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
- if (NIL_P(mesg)) return rb_class_path(CLASS_OF(exc));
+ if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
return mesg;
}
+/*
+ * call-seq:
+ * exception.message => string
+ * exception.to_str => string
+ *
+ * Returns the result of invoking <code>exception.to_s</code>.
+ * Normally this returns the exception's message or name. By
+ * supplying a to_str method, exceptions are agreeing to
+ * be used where Strings are expected.
+ */
+
+static VALUE
+exc_to_str(exc)
+ VALUE exc;
+{
+ return rb_funcall(exc, rb_intern("to_s"), 0, 0);
+}
+
+/*
+ * call-seq:
+ * exception.inspect => string
+ *
+ * Return this exception's class name an message
+ */
+
static VALUE
exc_inspect(exc)
VALUE exc;
@@ -358,19 +442,48 @@ exc_inspect(exc)
klass = CLASS_OF(exc);
exc = rb_obj_as_string(exc);
if (RSTRING(exc)->len == 0) {
- return rb_str_dup(rb_class_path(klass));
+ return rb_str_dup(rb_class_name(klass));
}
- str = rb_str_new2("#<");
- klass = rb_class_path(klass);
- rb_str_append(str, klass);
- rb_str_cat(str, ": ", 2);
- rb_str_append(str, exc);
- rb_str_cat(str, ">", 1);
+ str = rb_str_buf_new2("#<");
+ klass = rb_class_name(klass);
+ rb_str_buf_append(str, klass);
+ rb_str_buf_cat(str, ": ", 2);
+ rb_str_buf_append(str, exc);
+ rb_str_buf_cat(str, ">", 1);
return str;
}
+/*
+ * call-seq:
+ * exception.backtrace => array
+ *
+ * Returns any backtrace associated with the exception. The backtrace
+ * is an array of strings, each containing either ``filename:lineNo: in
+ * `method''' or ``filename:lineNo.''
+ *
+ * def a
+ * raise "boom"
+ * end
+ *
+ * def b
+ * a()
+ * end
+ *
+ * begin
+ * b()
+ * rescue => detail
+ * print detail.backtrace.join("\n")
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:2:in `a'
+ * prog.rb:6:in `b'
+ * prog.rb:10
+*/
+
static VALUE
exc_backtrace(exc)
VALUE exc;
@@ -385,7 +498,7 @@ static VALUE
check_backtrace(bt)
VALUE bt;
{
- int i;
+ long i;
static char *err = "backtrace must be Array of String";
if (!NIL_P(bt)) {
@@ -404,6 +517,16 @@ check_backtrace(bt)
return bt;
}
+/*
+ * call-seq:
+ * exc.set_backtrace(array) => array
+ *
+ * Sets the backtrace information associated with <i>exc</i>. The
+ * argument must be an array of <code>String</code> objects in the
+ * format described in <code>Exception#backtrace</code>.
+ *
+ */
+
static VALUE
exc_set_backtrace(exc, bt)
VALUE exc;
@@ -412,132 +535,448 @@ exc_set_backtrace(exc, bt)
return rb_iv_set(exc, "bt", check_backtrace(bt));
}
-#ifdef __BEOS__
-typedef struct {
- VALUE *list;
- int n;
-} syserr_list_entry;
-
-typedef struct {
- int ix;
- int n;
-} syserr_index_entry;
-
-static VALUE syserr_error;
-static VALUE syserr_list_b_general[16+1];
-static VALUE syserr_list_b_os0[2+1];
-static VALUE syserr_list_b_os1[5+1];
-static VALUE syserr_list_b_os2[2+1];
-static VALUE syserr_list_b_os3[3+1];
-static VALUE syserr_list_b_os4[1+1];
-static VALUE syserr_list_b_app[15+1];
-static VALUE syserr_list_b_interface[0+1];
-static VALUE syserr_list_b_media[8+1];
-static VALUE syserr_list_b_midi[0+1];
-static VALUE syserr_list_b_storage[15+1];
-static VALUE syserr_list_b_posix[38+1];
-static VALUE syserr_list_b_mail[8+1];
-static VALUE syserr_list_b_print[1+1];
-static VALUE syserr_list_b_device[14+1];
-
-# define SYSERR_LIST_B(n) {(n), sizeof(n)/sizeof(VALUE)}
-static const syserr_list_entry syserr_list[] = {
- SYSERR_LIST_B(syserr_list_b_general),
- SYSERR_LIST_B(syserr_list_b_os0),
- SYSERR_LIST_B(syserr_list_b_os1),
- SYSERR_LIST_B(syserr_list_b_os2),
- SYSERR_LIST_B(syserr_list_b_os3),
- SYSERR_LIST_B(syserr_list_b_os4),
- SYSERR_LIST_B(syserr_list_b_app),
- SYSERR_LIST_B(syserr_list_b_interface),
- SYSERR_LIST_B(syserr_list_b_media),
- SYSERR_LIST_B(syserr_list_b_midi),
- SYSERR_LIST_B(syserr_list_b_storage),
- SYSERR_LIST_B(syserr_list_b_posix),
- SYSERR_LIST_B(syserr_list_b_mail),
- SYSERR_LIST_B(syserr_list_b_print),
- SYSERR_LIST_B(syserr_list_b_device),
-};
-# undef SYSERR_LIST_B
+/*
+ * call-seq:
+ * SystemExit.new(status=0) => system_exit
+ *
+ * Create a new +SystemExit+ exception with the given status.
+ */
-static const syserr_index_entry syserr_index[]= {
- {0, 1}, {1, 5}, {6, 1}, {7, 1}, {8, 1}, {9, 1}, {10, 1}, {11, 1},
- {12, 1}, {13, 1}, {14, 1}, {0, 0},
-};
+static VALUE
+exit_initialize(argc, argv, exc)
+ int argc;
+ VALUE *argv;
+ VALUE exc;
+{
+ VALUE status = INT2FIX(EXIT_SUCCESS);
+ if (argc > 0 && FIXNUM_P(argv[0])) {
+ status = *argv++;
+ --argc;
+ }
+ exc_initialize(argc, argv, exc);
+ rb_iv_set(exc, "status", status);
+ return exc;
+}
+
+
+/*
+ * call-seq:
+ * system_exit.status => fixnum
+ *
+ * Return the status value associated with this system exit.
+ */
+
+static VALUE
+exit_status(exc)
+ VALUE exc;
+{
+ return rb_attr_get(exc, rb_intern("status"));
+}
+
+
+/*
+ * call-seq:
+ * system_exit.success? => true or false
+ *
+ * Returns +true+ if exiting successful, +false+ if not.
+ */
+
+static VALUE
+exit_success_p(exc)
+ VALUE exc;
+{
+ VALUE status = rb_attr_get(exc, rb_intern("status"));
+ if (NIL_P(status)) return Qtrue;
+ if (status == INT2FIX(EXIT_SUCCESS)) return Qtrue;
+ return Qfalse;
+}
+
+void
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_name_error(ID id, const char *fmt, ...)
#else
-static VALUE *syserr_list;
+rb_name_error(id, fmt, va_alist)
+ ID id;
+ const char *fmt;
+ va_dcl
#endif
+{
+ VALUE exc, argv[2];
+ va_list args;
+ char buf[BUFSIZ];
-#if !defined NT && !defined sys_nerr
-extern int sys_nerr;
-#endif
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+
+ argv[0] = rb_str_new2(buf);
+ argv[1] = ID2SYM(id);
+ exc = rb_class_new_instance(2, argv, rb_eNameError);
+ rb_exc_raise(exc);
+}
+
+/*
+ * call-seq:
+ * NameError.new(msg [, name]) => name_error
+ *
+ * Construct a new NameError exception. If given the <i>name</i>
+ * parameter may subsequently be examined using the <code>NameError.name</code>
+ * method.
+ */
+
+static VALUE
+name_err_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE name;
+
+ name = (argc > 1) ? argv[--argc] : Qnil;
+ exc_initialize(argc, argv, self);
+ rb_iv_set(self, "name", name);
+ return self;
+}
+
+/*
+ * call-seq:
+ * name_error.name => string or nil
+ *
+ * Return the name associated with this NameError exception.
+ */
+
+static VALUE
+name_err_name(self)
+ VALUE self;
+{
+ return rb_attr_get(self, rb_intern("name"));
+}
+
+/*
+ * call-seq:
+ * name_error.to_s => string
+ *
+ * Produce a nicely-formated string representing the +NameError+.
+ */
+
+static VALUE
+name_err_to_s(exc)
+ VALUE exc;
+{
+ VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), str = mesg;
+
+ if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
+ StringValue(str);
+ if (str != mesg) {
+ rb_iv_set(exc, "mesg", mesg = str);
+ }
+ if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
+ return mesg;
+}
+
+/*
+ * call-seq:
+ * NoMethodError.new(msg, name [, args]) => no_method_error
+ *
+ * Contruct a NoMethodError exception for a method of the given name
+ * called with the given arguments. The name may be accessed using
+ * the <code>#name</code> method on the resulting object, and the
+ * arguments using the <code>#args</code> method.
+ */
+
+static VALUE
+nometh_err_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE args = (argc > 2) ? argv[--argc] : Qnil;
+ name_err_initialize(argc, argv, self);
+ rb_iv_set(self, "args", args);
+ return self;
+}
+
+/* :nodoc: */
+static void
+name_err_mesg_mark(ptr)
+ VALUE *ptr;
+{
+ rb_gc_mark_locations(ptr, ptr+3);
+}
+
+/* :nodoc: */
+static VALUE
+name_err_mesg_new(obj, mesg, recv, method)
+ VALUE obj, mesg, recv, method;
+{
+ VALUE *ptr = ALLOC_N(VALUE, 3);
+
+ ptr[0] = mesg;
+ ptr[1] = recv;
+ ptr[2] = method;
+ return Data_Wrap_Struct(rb_cNameErrorMesg, name_err_mesg_mark, -1, ptr);
+}
+
+/* :nodoc: */
+static VALUE
+name_err_mesg_to_str(obj)
+ VALUE obj;
+{
+ VALUE *ptr, mesg;
+ Data_Get_Struct(obj, VALUE, ptr);
+
+ mesg = ptr[0];
+ if (NIL_P(mesg)) return Qnil;
+ else {
+ char *desc = 0;
+ VALUE d = 0, args[3];
+
+ obj = ptr[1];
+ switch (TYPE(obj)) {
+ case T_NIL:
+ desc = "nil";
+ break;
+ case T_TRUE:
+ desc = "true";
+ break;
+ case T_FALSE:
+ desc = "false";
+ break;
+ default:
+ d = rb_protect(rb_inspect, obj, 0);
+ if (NIL_P(d) || RSTRING(d)->len > 65) {
+ d = rb_any_to_s(obj);
+ }
+ desc = RSTRING(d)->ptr;
+ break;
+ }
+ if (desc && desc[0] != '#') {
+ d = rb_str_new2(desc);
+ rb_str_cat2(d, ":");
+ rb_str_cat2(d, rb_obj_classname(obj));
+ }
+ args[0] = mesg;
+ args[1] = ptr[2];
+ args[2] = d;
+ mesg = rb_f_sprintf(3, args);
+ }
+ if (OBJ_TAINTED(obj)) OBJ_TAINT(mesg);
+ return mesg;
+}
+
+/* :nodoc: */
+static VALUE
+name_err_mesg_load(klass, str)
+ VALUE klass, str;
+{
+ return str;
+}
+
+/*
+ * call-seq:
+ * no_method_error.args => obj
+ *
+ * Return the arguments passed in as the third parameter to
+ * the constructor.
+ */
+
+static VALUE
+nometh_err_args(self)
+ VALUE self;
+{
+ return rb_attr_get(self, rb_intern("args"));
+}
+
+void
+rb_invalid_str(str, type)
+ const char *str, *type;
+{
+ VALUE s = rb_str_inspect(rb_str_new2(str));
+
+ rb_raise(rb_eArgError, "invalid value for %s: %s", type, RSTRING(s)->ptr);
+}
+
+/*
+ * Document-module: Errno
+ *
+ * Ruby exception objects are subclasses of <code>Exception</code>.
+ * However, operating systems typically report errors using plain
+ * integers. Module <code>Errno</code> is created dynamically to map
+ * these operating system errors to Ruby classes, with each error
+ * number generating its own subclass of <code>SystemCallError</code>.
+ * As the subclass is created in module <code>Errno</code>, its name
+ * will start <code>Errno::</code>.
+ *
+ * The names of the <code>Errno::</code> classes depend on
+ * the environment in which Ruby runs. On a typical Unix or Windows
+ * platform, there are <code>Errno</code> classes such as
+ * <code>Errno::EACCES</code>, <code>Errno::EAGAIN</code>,
+ * <code>Errno::EINTR</code>, and so on.
+ *
+ * The integer operating system error number corresponding to a
+ * particular error is available as the class constant
+ * <code>Errno::</code><em>error</em><code>::Errno</code>.
+ *
+ * Errno::EACCES::Errno #=> 13
+ * Errno::EAGAIN::Errno #=> 11
+ * Errno::EINTR::Errno #=> 4
+ *
+ * The full list of operating system errors on your particular platform
+ * are available as the constants of <code>Errno</code>.
+ *
+ * Errno.constants #=> E2BIG, EACCES, EADDRINUSE, EADDRNOTAVAIL, ...
+ */
+
+static st_table *syserr_tbl;
static VALUE
-set_syserr(i, name)
- int i;
+set_syserr(n, name)
+ int n;
const char *name;
{
-#ifdef __BEOS__
- VALUE *list;
- int ix, offset;
-#endif
- VALUE error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
- rb_define_const(error, "Errno", INT2FIX(i));
-#ifdef __BEOS__
- if (i == B_ERROR) {
- syserr_error = error;
- rb_global_variable(&syserr_error);
- return error;
- }
- i -= B_GENERAL_ERROR_BASE;
- ix = (i >> 12) & 0xf;
- offset = (i >> 8) & 0xf;
- if (offset < syserr_index[ix].n) {
- ix = syserr_index[ix].ix;
- if ((i & 0xff) < syserr_list[ix + offset].n) {
- list = syserr_list[ix + offset].list;
- list[i & 0xff] = error;
- rb_global_variable(&list[i & 0xff]);
- }
- }
-#else
- if (i <= sys_nerr) {
- syserr_list[i] = error;
+ VALUE error;
+
+ if (!st_lookup(syserr_tbl, n, &error)) {
+ error = rb_define_class_under(rb_mErrno, name, rb_eSystemCallError);
+ rb_define_const(error, "Errno", INT2NUM(n));
+ st_add_direct(syserr_tbl, n, error);
+ }
+ else {
+ rb_define_const(rb_mErrno, name, error);
}
-#endif
return error;
}
static VALUE
+get_syserr(n)
+ int n;
+{
+ VALUE error;
+
+ if (!st_lookup(syserr_tbl, n, &error)) {
+ char name[8]; /* some Windows' errno have 5 digits. */
+
+ snprintf(name, sizeof(name), "E%03d", n);
+ error = set_syserr(n, name);
+ }
+ return error;
+}
+
+/*
+ * call-seq:
+ * SystemCallError.new(msg, errno) => system_call_error_subclass
+ *
+ * If _errno_ corresponds to a known system error code, constructs
+ * the appropriate <code>Errno</code> class for that error, otherwise
+ * constructs a generic <code>SystemCallError</code> object. The
+ * error number is subsequently available via the <code>errno</code>
+ * method.
+ */
+
+static VALUE
+syserr_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+#if !defined(_WIN32) && !defined(__VMS)
+ char *strerror();
+#endif
+ char *err;
+ VALUE mesg, error;
+ VALUE klass = rb_obj_class(self);
+
+ if (klass == rb_eSystemCallError) {
+ rb_scan_args(argc, argv, "11", &mesg, &error);
+ if (argc == 1 && FIXNUM_P(mesg)) {
+ error = mesg; mesg = Qnil;
+ }
+ if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &klass)) {
+ /* change class */
+ if (TYPE(self) != T_OBJECT) { /* insurance to avoid type crash */
+ rb_raise(rb_eTypeError, "invalid instance type");
+ }
+ RBASIC(self)->klass = klass;
+ }
+ }
+ else {
+ rb_scan_args(argc, argv, "01", &mesg);
+ error = rb_const_get(klass, rb_intern("Errno"));
+ }
+ if (!NIL_P(error)) err = strerror(NUM2LONG(error));
+ else err = "unknown error";
+ if (!NIL_P(mesg)) {
+ VALUE str = mesg;
+ StringValue(str);
+ mesg = rb_str_new(0, strlen(err)+RSTRING(mesg)->len+3);
+ sprintf(RSTRING(mesg)->ptr, "%s - %.*s", err,
+ (int)RSTRING(str)->len, RSTRING(str)->ptr);
+ rb_str_resize(mesg, strlen(RSTRING(mesg)->ptr));
+ }
+ else {
+ mesg = rb_str_new2(err);
+ }
+ exc_initialize(1, &mesg, self);
+ rb_iv_set(self, "errno", error);
+ return self;
+}
+
+/*
+ * call-seq:
+ * system_call_error.errno => fixnum
+ *
+ * Return this SystemCallError's error number.
+ */
+
+static VALUE
syserr_errno(self)
VALUE self;
{
- return rb_iv_get(self, "errno");
+ return rb_attr_get(self, rb_intern("errno"));
}
-#ifdef __BEOS__
+/*
+ * call-seq:
+ * system_call_error === other => true or false
+ *
+ * Return +true+ if the receiver is a generic +SystemCallError+, or
+ * if the error numbers _self_ and _other_ are the same.
+ */
+
+
static VALUE
-get_syserr(int i)
+syserr_eqq(self, exc)
+ VALUE self, exc;
{
- VALUE *list;
- int ix, offset;
-
- if (i == B_ERROR) return syserr_error;
- i -= B_GENERAL_ERROR_BASE;
- ix = (i >> 12) & 0xf;
- offset = (i >> 8) & 0xf;
- if (offset < syserr_index[ix].n) {
- ix = syserr_index[ix].ix;
- if ((i & 0xff) < syserr_list[ix + offset].n) {
- list = syserr_list[ix + offset].list;
- return list[i & 0xff];
- }
- }
- return 0;
+ VALUE num, e;
+
+ if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) return Qfalse;
+ if (self == rb_eSystemCallError) return Qtrue;
+
+ num = rb_attr_get(exc, rb_intern("errno"));
+ if (NIL_P(num)) {
+ VALUE klass = CLASS_OF(exc);
+
+ while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
+ klass = (VALUE)RCLASS(klass)->super;
+ }
+ num = rb_const_get(klass, rb_intern("Errno"));
+ }
+ e = rb_const_get(self, rb_intern("Errno"));
+ if (FIXNUM_P(num) ? num == e : rb_equal(num, e))
+ return Qtrue;
+ return Qfalse;
}
-#endif /* __BEOS__ */
-static void init_syserr _((void));
+/*
+ * Descendents of class <code>Exception</code> are used to communicate
+ * between <code>raise</code> methods and <code>rescue</code>
+ * statements in <code>begin/end</code> blocks. <code>Exception</code>
+ * objects carry information about the exception---its type (the
+ * exception's class name), an optional descriptive string, and
+ * optional traceback information. Programs may subclass
+ * <code>Exception</code> to add additional information.
+ */
void
Init_Exception()
@@ -547,36 +986,57 @@ Init_Exception()
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);
- rb_define_method(rb_eException, "message", exc_to_s, 0);
+ rb_define_method(rb_eException, "to_str", exc_to_str, 0);
+ rb_define_method(rb_eException, "message", exc_to_str, 0);
rb_define_method(rb_eException, "inspect", exc_inspect, 0);
rb_define_method(rb_eException, "backtrace", exc_backtrace, 0);
rb_define_method(rb_eException, "set_backtrace", exc_set_backtrace, 1);
rb_eSystemExit = rb_define_class("SystemExit", rb_eException);
+ rb_define_method(rb_eSystemExit, "initialize", exit_initialize, -1);
+ rb_define_method(rb_eSystemExit, "status", exit_status, 0);
+ rb_define_method(rb_eSystemExit, "success?", exit_success_p, 0);
+
rb_eFatal = rb_define_class("fatal", rb_eException);
- rb_eInterrupt = rb_define_class("Interrupt", rb_eException);
rb_eSignal = rb_define_class("SignalException", rb_eException);
+ rb_eInterrupt = rb_define_class("Interrupt", rb_eSignal);
rb_eStandardError = rb_define_class("StandardError", rb_eException);
- rb_eTypeError = rb_define_class("TypeError", rb_eStandardError);
- rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
- rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
- rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
+ rb_eTypeError = rb_define_class("TypeError", rb_eStandardError);
+ rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
+ rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
+ rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
+ rb_eNameError = rb_define_class("NameError", rb_eStandardError);
+ rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1);
+ rb_define_method(rb_eNameError, "name", name_err_name, 0);
+ rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0);
+ rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData);
+ rb_define_singleton_method(rb_cNameErrorMesg, "!", name_err_mesg_new, 3);
+ rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0);
+ rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1);
+ rb_define_singleton_method(rb_cNameErrorMesg, "_load", name_err_mesg_load, 1);
+ rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
+ rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
+ rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
- rb_eNameError = rb_define_class("NameError", rb_eScriptError);
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);
- /* backward compatibility -- will be removed in the future */
- rb_define_global_const("NotImplementError", rb_eNotImpError);
rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
rb_eSecurityError = rb_define_class("SecurityError", rb_eStandardError);
rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
- init_syserr();
+ syserr_tbl = st_init_numtable();
+ rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError);
+ rb_define_method(rb_eSystemCallError, "initialize", syserr_initialize, -1);
+ rb_define_method(rb_eSystemCallError, "errno", syserr_errno, 0);
+ rb_define_singleton_method(rb_eSystemCallError, "===", syserr_eqq, 1);
+
+ rb_mErrno = rb_define_module("Errno");
+
+ rb_define_global_function("warn", rb_warn_m, 1);
}
void
@@ -648,89 +1108,69 @@ void
rb_sys_fail(mesg)
const char *mesg;
{
-#ifndef NT
- char *strerror();
-#endif
- char *err;
- char *buf;
extern int errno;
int n = errno;
- VALUE ee;
+ VALUE arg;
- err = strerror(errno);
- if (mesg) {
- volatile VALUE tmp = rb_str_inspect(rb_str_new2(mesg));
-
- buf = ALLOCA_N(char, strlen(err)+RSTRING(tmp)->len+4);
- sprintf(buf, "%s - %s", err, RSTRING(tmp)->ptr);
- }
- else {
- buf = ALLOCA_N(char, strlen(err)+1);
- strcpy(buf, err);
+ errno = 0;
+ if (n == 0) {
+ rb_bug("rb_sys_fail(%s) - errno == 0", mesg ? mesg : "");
}
- errno = 0;
-#ifdef __BEOS__
- ee = get_syserr(n);
- if (!ee) {
- char name[6];
-
- sprintf(name, "E%03d", n);
- ee = set_syserr(n, name);
- }
-#else
- if (n > sys_nerr || !syserr_list[n]) {
- char name[6];
+ arg = mesg ? rb_str_new2(mesg) : Qnil;
+ rb_exc_raise(rb_class_new_instance(1, &arg, get_syserr(n)));
+}
- sprintf(name, "E%03d", n);
- ee = set_syserr(n, name);
- }
- else {
- ee = syserr_list[n];
- }
+void
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_sys_warning(const char *fmt, ...)
+#else
+rb_sys_warning(fmt, va_alist)
+ const char *fmt;
+ va_dcl
#endif
- ee = rb_exc_new2(ee, buf);
- rb_iv_set(ee, "errno", INT2FIX(n));
- rb_exc_raise(ee);
+{
+ char buf[BUFSIZ];
+ va_list args;
+ int errno_save;
+
+ errno_save = errno;
+
+ if (!RTEST(ruby_verbose)) return;
+
+ snprintf(buf, BUFSIZ, "warning: %s", fmt);
+ snprintf(buf+strlen(buf), BUFSIZ-strlen(buf), ": %s", strerror(errno_save));
+
+ va_init_list(args, fmt);
+ warn_print(buf, args);
+ va_end(args);
+ errno = errno_save;
}
void
rb_load_fail(path)
- char *path;
+ const char *path;
{
rb_loaderror("%s -- %s", strerror(errno), path);
}
void
rb_error_frozen(what)
- char *what;
+ const char *what;
{
rb_raise(rb_eTypeError, "can't modify frozen %s", what);
}
-static void
-init_syserr()
+void
+rb_check_frozen(obj)
+ VALUE obj;
{
-#ifdef __BEOS__
- int i, ix, offset;
-#endif
- rb_eSystemCallError = rb_define_class("SystemCallError", rb_eStandardError);
- rb_define_method(rb_eSystemCallError, "errno", syserr_errno, 0);
-
- rb_mErrno = rb_define_module("Errno");
-#ifdef __BEOS__
- for (i = 0; syserr_index[i].n != 0; i++) {
- ix = syserr_index[i].ix;
- for (offset = 0; offset < syserr_index[i].n; offset++) {
- MEMZERO(syserr_list[ix + offset].list, VALUE, syserr_list[ix + offset].n);
- }
- }
- set_syserr(B_ERROR, "ERROR");
-#else
- syserr_list = ALLOC_N(VALUE, sys_nerr+1);
- MEMZERO(syserr_list, VALUE, sys_nerr+1);
-#endif
+ if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj));
+}
+void
+Init_syserr()
+{
#ifdef EPERM
set_syserr(EPERM, "EPERM");
#endif
@@ -1110,7 +1550,7 @@ err_append(s)
ruby_errinfo = rb_exc_new2(rb_eSyntaxError, s);
}
else {
- VALUE str = rb_str_to_str(ruby_errinfo);
+ VALUE str = rb_obj_as_string(ruby_errinfo);
rb_str_cat2(str, "\n");
rb_str_cat2(str, s);
@@ -1118,8 +1558,7 @@ err_append(s)
}
}
else {
- fputs(s, stderr);
- fputs("\n", stderr);
- fflush(stderr);
+ rb_write_error(s);
+ rb_write_error("\n");
}
}
diff --git a/eval.c b/eval.c
index b1f01f958d..043f349bbd 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-2001 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -15,13 +15,34 @@
#include "ruby.h"
#include "node.h"
#include "env.h"
+#include "util.h"
#include "rubysig.h"
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
#include <stdio.h>
+#if defined(HAVE_GETCONTEXT) && defined(HAVE_SETCONTEXT)
+#include <ucontext.h>
+#define USE_CONTEXT
+#else
#include <setjmp.h>
+#endif
+
#include "st.h"
#include "dln.h"
+#ifdef __APPLE__
+#include <crt_externs.h>
+#endif
+
/* Make alloca work the best possible way. */
#ifdef __GNUC__
# ifndef atarist
@@ -30,17 +51,19 @@
# endif
# endif /* atarist */
#else
-# if defined(HAVE_ALLOCA_H)
+# ifdef HAVE_ALLOCA_H
# include <alloca.h>
-# elif !defined(alloca)
-char *alloca();
-# endif
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+void *alloca ();
+# endif
+# endif /* AIX */
+# endif /* HAVE_ALLOCA_H */
#endif /* __GNUC__ */
-#ifdef _AIX
-#pragma alloca
-#endif
-
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
@@ -65,50 +88,64 @@ char *strrchr _((const char*,const char));
#include "macruby_private.h"
#endif
+#ifdef USE_CONTEXT
+typedef struct {
+ ucontext_t context;
+ volatile int status;
+} rb_jmpbuf_t[1];
+
+#undef longjmp
+#undef setjmp
+NORETURN(static void rb_jump_context(rb_jmpbuf_t, int));
+static inline void
+rb_jump_context(env, val)
+ rb_jmpbuf_t env;
+ int val;
+{
+ env->status = val;
+ setcontext(&env->context);
+ abort(); /* ensure noreturn */
+}
+#define longjmp(env, val) rb_jump_context(env, val)
+#define setjmp(j) ((j)->status = 0, getcontext(&(j)->context), (j)->status)
+#else
+typedef jmp_buf rb_jmpbuf_t;
#ifndef setjmp
#ifdef HAVE__SETJMP
#define setjmp(env) _setjmp(env)
#define longjmp(env,val) _longjmp(env,val)
#endif
#endif
+#endif
#include <sys/types.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#else
-#ifndef NT
-struct timeval {
- long tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
-};
-#endif /* NT */
-#endif
#include <signal.h>
#include <errno.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
+#if defined(__VMS)
+#pragma nostandard
#endif
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
#endif
#include <sys/stat.h>
VALUE rb_cProc;
static VALUE rb_cBinding;
-static VALUE proc_call _((VALUE,VALUE));
+static VALUE proc_invoke _((VALUE,VALUE,VALUE,VALUE));
static VALUE rb_f_binding _((VALUE));
static void rb_f_END _((void));
static VALUE rb_f_block_given_p _((void));
static VALUE block_pass _((VALUE,NODE*));
static VALUE rb_cMethod;
-static VALUE method_proc _((VALUE));
static VALUE method_call _((int, VALUE*, VALUE));
static VALUE rb_cUnboundMethod;
static VALUE umethod_bind _((VALUE, VALUE));
static VALUE rb_mod_define_method _((int, VALUE*, VALUE));
+NORETURN(static void rb_raise_jump _((VALUE)));
+static VALUE rb_make_exception _((int argc, VALUE *argv));
static int scope_vmode;
#define SCOPE_PUBLIC 0
@@ -116,15 +153,16 @@ static int scope_vmode;
#define SCOPE_PROTECTED 2
#define SCOPE_MODFUNC 5
#define SCOPE_MASK 7
-#define SCOPE_SET(f) do {scope_vmode=(f);} while(0)
+#define SCOPE_SET(f) (scope_vmode=(f))
#define SCOPE_TEST(f) (scope_vmode&(f))
+NODE* ruby_current_node;
int ruby_safe_level = 0;
/* safe-level:
0 - strings from streams/environment/ARGV are tainted (default)
1 - no dangerous operation by tainted value
2 - process/file operations prohibited
- 3 - all genetated objects are tainted
+ 3 - all generated objects are tainted
4 - no global (non-tainted) variable modification/no direct output
*/
@@ -136,13 +174,25 @@ rb_secure(level)
int level;
{
if (level <= ruby_safe_level) {
- rb_raise(rb_eSecurityError, "Insecure operation `%s' at level %d",
- rb_id2name(ruby_frame->last_func), ruby_safe_level);
+ if (ruby_frame->last_func) {
+ rb_raise(rb_eSecurityError, "Insecure operation `%s' at level %d",
+ rb_id2name(ruby_frame->last_func), ruby_safe_level);
+ }
+ else {
+ rb_raise(rb_eSecurityError, "Insecure operation at level %d", ruby_safe_level);
+ }
}
}
void
-rb_check_safe_str(x)
+rb_secure_update(obj)
+ VALUE obj;
+{
+ if (!OBJ_TAINTED(obj)) rb_secure(4);
+}
+
+void
+rb_check_safe_obj(x)
VALUE x;
{
if (ruby_safe_level > 0 && OBJ_TAINTED(x)){
@@ -155,24 +205,32 @@ rb_check_safe_str(x)
}
}
rb_secure(4);
+}
+
+void
+rb_check_safe_str(x)
+ VALUE x;
+{
+ rb_check_safe_obj(x);
if (TYPE(x)!= T_STRING) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected String)",
- rb_class2name(CLASS_OF(x)));
+ rb_obj_classname(x));
}
}
-static void print_undef _((VALUE, ID)) NORETURN;
+NORETURN(static void print_undef _((VALUE, ID)));
static void
print_undef(klass, id)
VALUE klass;
ID id;
{
- rb_raise(rb_eNameError, "undefined method `%s' for %s `%s'",
- rb_id2name(id),
- (TYPE(klass) == T_MODULE)?"module":"class",
- rb_class2name(klass));
+ rb_name_error(id, "undefined method `%s' for %s `%s'",
+ rb_id2name(id),
+ (TYPE(klass) == T_MODULE) ? "module" : "class",
+ rb_class2name(klass));
}
+static ID removed, singleton_removed, undefined, singleton_undefined;
#define CACHE_SIZE 0x800
#define CACHE_MASK 0x7ff
@@ -188,12 +246,14 @@ struct cache_entry { /* method hash table. */
};
static struct cache_entry cache[CACHE_SIZE];
+static int ruby_running = 0;
void
rb_clear_cache()
{
- struct cache_entry *ent, *end;
+ struct cache_entry *ent, *end;
+ if (!ruby_running) return;
ent = cache; end = ent + CACHE_SIZE;
while (ent < end) {
ent->mid = 0;
@@ -202,11 +262,29 @@ rb_clear_cache()
}
static void
+rb_clear_cache_for_undef(klass, id)
+ VALUE klass;
+ ID id;
+{
+ struct cache_entry *ent, *end;
+
+ if (!ruby_running) return;
+ ent = cache; end = ent + CACHE_SIZE;
+ while (ent < end) {
+ if (ent->origin == klass && ent->mid == id) {
+ ent->mid = 0;
+ }
+ ent++;
+ }
+}
+
+static void
rb_clear_cache_by_id(id)
ID id;
{
struct cache_entry *ent, *end;
+ if (!ruby_running) return;
ent = cache; end = ent + CACHE_SIZE;
while (ent < end) {
if (ent->mid == id) {
@@ -217,6 +295,26 @@ rb_clear_cache_by_id(id)
}
void
+rb_clear_cache_by_class(klass)
+ VALUE klass;
+{
+ struct cache_entry *ent, *end;
+
+ if (!ruby_running) return;
+ ent = cache; end = ent + CACHE_SIZE;
+ while (ent < end) {
+ if (ent->klass == klass || ent->origin == klass) {
+ ent->mid = 0;
+ }
+ ent++;
+ }
+}
+
+static ID init, eqq, each, aref, aset, match, missing;
+static ID added, singleton_added;
+static ID __id__, __send__;
+
+void
rb_add_method(klass, mid, node, noex)
VALUE klass;
ID mid;
@@ -226,15 +324,49 @@ rb_add_method(klass, mid, node, noex)
NODE *body;
if (NIL_P(klass)) klass = rb_cObject;
- if (klass == rb_cObject) {
- rb_secure(4);
- }
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
+ if (ruby_safe_level >= 4 && (klass == rb_cObject || !OBJ_TAINTED(klass))) {
rb_raise(rb_eSecurityError, "Insecure: can't define method");
}
+ if (!FL_TEST(klass, FL_SINGLETON) &&
+ node && nd_type(node) != NODE_ZSUPER &&
+ (mid == rb_intern("initialize" )|| mid == rb_intern("initialize_copy"))) {
+ noex = NOEX_PRIVATE | noex;
+ }
+ else if (FL_TEST(klass, FL_SINGLETON) && node && nd_type(node) == NODE_CFUNC &&
+ mid == rb_intern("allocate")) {
+ rb_warn("defining %s.allocate is deprecated; use rb_define_alloc_func()",
+ rb_class2name(rb_iv_get(klass, "__attached__")));
+ mid = ID_ALLOCATOR;
+ }
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
+ rb_clear_cache_by_id(mid);
body = NEW_METHOD(node, noex);
- st_insert(RCLASS(klass)->m_tbl, mid, body);
+ st_insert(RCLASS(klass)->m_tbl, mid, (st_data_t)body);
+ if (node && mid != ID_ALLOCATOR && ruby_running) {
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_funcall(rb_iv_get(klass, "__attached__"), singleton_added, 1, ID2SYM(mid));
+ }
+ else {
+ rb_funcall(klass, added, 1, ID2SYM(mid));
+ }
+ }
+}
+
+void
+rb_define_alloc_func(klass, func)
+ VALUE klass;
+ VALUE (*func) _((VALUE));
+{
+ Check_Type(klass, T_CLASS);
+ rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0), NOEX_PRIVATE);
+}
+
+void
+rb_undef_alloc_func(klass)
+ VALUE klass;
+{
+ Check_Type(klass, T_CLASS);
+ rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
}
static NODE*
@@ -245,7 +377,7 @@ search_method(klass, id, origin)
NODE *body;
if (!klass) return 0;
- while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
+ while (!st_lookup(RCLASS(klass)->m_tbl, id, (st_data_t *)&body)) {
klass = RCLASS(klass)->super;
if (!klass) return 0;
}
@@ -274,33 +406,57 @@ rb_get_method_body(klassp, idp, noexp)
ent->mid = ent->mid0 = id;
ent->noex = 0;
ent->method = 0;
-
+
return 0;
}
- /* store in cache */
- ent = cache + EXPR1(klass, id);
- ent->klass = klass;
- ent->noex = body->nd_noex;
- body = body->nd_body;
- if (nd_type(body) == NODE_FBODY) {
- ent->mid = id;
- *klassp = body->nd_orig;
- ent->origin = body->nd_orig;
- *idp = ent->mid0 = body->nd_mid;
- body = ent->method = body->nd_head;
+ if (ruby_running) {
+ /* store in cache */
+ ent = cache + EXPR1(klass, id);
+ ent->klass = klass;
+ ent->noex = body->nd_noex;
+ if (noexp) *noexp = body->nd_noex;
+ body = body->nd_body;
+ if (nd_type(body) == NODE_FBODY) {
+ ent->mid = id;
+ *klassp = body->nd_orig;
+ ent->origin = body->nd_orig;
+ *idp = ent->mid0 = body->nd_mid;
+ body = ent->method = body->nd_head;
+ }
+ else {
+ *klassp = origin;
+ ent->origin = origin;
+ ent->mid = ent->mid0 = id;
+ ent->method = body;
+ }
}
else {
- *klassp = origin;
- ent->origin = origin;
- ent->mid = ent->mid0 = id;
- ent->method = body;
+ if (noexp) *noexp = body->nd_noex;
+ body = body->nd_body;
+ if (nd_type(body) == NODE_FBODY) {
+ *klassp = body->nd_orig;
+ *idp = body->nd_mid;
+ body = body->nd_head;
+ }
+ else {
+ *klassp = origin;
+ }
}
- if (noexp) *noexp = ent->noex;
return body;
}
+NODE*
+rb_method_node(klass, id)
+ VALUE klass;
+ ID id;
+{
+ int noex;
+
+ return rb_get_method_body(&klass, &id, &noex);
+}
+
static void
remove_method(klass, mid)
VALUE klass;
@@ -311,15 +467,25 @@ remove_method(klass, mid)
if (klass == rb_cObject) {
rb_secure(4);
}
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(klass)) {
rb_raise(rb_eSecurityError, "Insecure: can't remove method");
}
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
- if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body)) {
- rb_raise(rb_eNameError, "method `%s' not defined in %s",
- rb_id2name(mid), rb_class2name(klass));
+ if (mid == __id__ || mid == __send__ || mid == init) {
+ rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
+ }
+ if (!st_delete(RCLASS(klass)->m_tbl, &mid, (st_data_t *)&body) ||
+ !body->nd_body) {
+ rb_name_error(mid, "method `%s' not defined in %s",
+ rb_id2name(mid), rb_class2name(klass));
+ }
+ rb_clear_cache_for_undef(klass, mid);
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_funcall(rb_iv_get(klass, "__attached__"), singleton_removed, 1, ID2SYM(mid));
+ }
+ else {
+ rb_funcall(klass, removed, 1, ID2SYM(mid));
}
- rb_clear_cache_by_id(mid);
}
void
@@ -330,34 +496,37 @@ rb_remove_method(klass, name)
remove_method(klass, rb_intern(name));
}
+/*
+ * call-seq:
+ * remove_method(symbol) => self
+ *
+ * Removes the method identified by _symbol_ from the current
+ * class. For an example, see <code>Module.undef_method</code>.
+ */
+
static VALUE
-rb_mod_remove_method(mod, name)
- VALUE mod, name;
+rb_mod_remove_method(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
{
- remove_method(mod, rb_to_id(name));
+ int i;
+
+ for (i=0; i<argc; i++) {
+ remove_method(mod, rb_to_id(argv[i]));
+ }
return mod;
}
+#undef rb_disable_super
+#undef rb_enable_super
+
void
rb_disable_super(klass, name)
VALUE klass;
const char *name;
{
- VALUE origin;
- NODE *body;
- ID mid = rb_intern(name);
-
- body = search_method(klass, mid, &origin);
- if (!body || !body->nd_body) {
- print_undef(klass, mid);
- }
- if (origin == klass) {
- body->nd_noex |= NOEX_UNDEF;
- }
- else {
- rb_add_method(klass, mid, 0, NOEX_UNDEF);
- rb_clear_cache_by_id(mid);
- }
+ /* obsolete - no use */
}
void
@@ -365,20 +534,7 @@ rb_enable_super(klass, name)
VALUE klass;
const char *name;
{
- VALUE origin;
- NODE *body;
- ID mid = rb_intern(name);
-
- body = search_method(klass, mid, &origin);
- if (!body) {
- print_undef(klass, mid);
- }
- if (!body->nd_body) {
- remove_method(klass, mid);
- }
- else {
- body->nd_noex &= ~NOEX_UNDEF;
- }
+ rb_warning("rb_enable_super() is obsolete");
}
static void
@@ -397,7 +553,7 @@ rb_export_method(klass, name, noex)
if (!body && TYPE(klass) == T_MODULE) {
body = search_method(rb_cObject, name, &origin);
}
- if (!body) {
+ if (!body || !body->nd_body) {
print_undef(klass, name);
}
if (body->nd_noex != noex) {
@@ -406,7 +562,6 @@ rb_export_method(klass, name, noex)
}
else {
rb_add_method(klass, name, NEW_ZSUPER(), noex);
- rb_clear_cache_by_id(name);
}
}
}
@@ -436,10 +591,6 @@ rb_method_boundp(klass, id, ex)
return Qfalse;
}
-static ID init, eqq, each, aref, aset, match, to_ary;
-static ID missing, added, singleton_added;
-static ID __id__, __send__;
-
void
rb_attr(klass, id, read, write, ex)
VALUE klass;
@@ -455,7 +606,9 @@ rb_attr(klass, id, read, write, ex)
else {
if (SCOPE_TEST(SCOPE_PRIVATE)) {
noex = NOEX_PRIVATE;
- rb_warning("private attribute?");
+ rb_warning((scope_vmode == SCOPE_MODFUNC) ?
+ "attribute accessor as module_function" :
+ "private attribute?");
}
else if (SCOPE_TEST(SCOPE_PROTECTED)) {
noex = NOEX_PROTECTED;
@@ -474,15 +627,11 @@ rb_attr(klass, id, read, write, ex)
attriv = rb_intern(buf);
if (read) {
rb_add_method(klass, id, NEW_IVAR(attriv), noex);
- rb_clear_cache_by_id(id);
- rb_funcall(klass, added, 1, ID2SYM(id));
}
if (write) {
sprintf(buf, "%s=", name);
id = rb_intern(buf);
rb_add_method(klass, id, NEW_ATTRSET(attriv), noex);
- rb_clear_cache_by_id(id);
- rb_funcall(klass, added, 1, ID2SYM(id));
}
}
@@ -503,29 +652,24 @@ struct SCOPE *ruby_scope;
static struct FRAME *top_frame;
static struct SCOPE *top_scope;
-#define PUSH_FRAME() { \
+static unsigned long frame_unique = 0;
+
+#define PUSH_FRAME() do { \
struct FRAME _frame; \
_frame.prev = ruby_frame; \
_frame.tmp = 0; \
- _frame.file = ruby_sourcefile; \
- _frame.line = ruby_sourceline; \
+ _frame.node = ruby_current_node; \
_frame.iter = ruby_iter->iter; \
- _frame.cbase = ruby_frame->cbase; \
_frame.argc = 0; \
_frame.argv = 0; \
_frame.flags = FRAME_ALLOCA; \
- ruby_frame = &_frame; \
+ _frame.uniq = frame_unique++; \
+ ruby_frame = &_frame
#define POP_FRAME() \
- ruby_sourcefile = _frame.file; \
- ruby_sourceline = _frame.line; \
- ruby_frame = _frame.prev; }
-
-struct BLOCKTAG {
- struct RBasic super;
- long dst;
- long flags;
-};
+ ruby_current_node = _frame.node; \
+ ruby_frame = _frame.prev; \
+} while (0)
struct BLOCK {
NODE *var;
@@ -533,73 +677,67 @@ struct BLOCK {
VALUE self;
struct FRAME frame;
struct SCOPE *scope;
- struct BLOCKTAG *tag;
VALUE klass;
+ NODE *cref;
int iter;
int vmode;
int flags;
+ int uniq;
struct RVarmap *dyna_vars;
VALUE orig_thread;
+ VALUE wrapper;
+ VALUE block_obj;
+ struct BLOCK *outer;
struct BLOCK *prev;
};
#define BLOCK_D_SCOPE 1
-#define BLOCK_DYNAMIC 2
-#define BLOCK_ORPHAN 4
+#define BLOCK_LAMBDA 2
static struct BLOCK *ruby_block;
+static unsigned long block_unique = 0;
-static struct BLOCKTAG*
-new_blktag()
-{
- NEWOBJ(blktag, struct BLOCKTAG);
- OBJSETUP(blktag, 0, T_BLKTAG);
- blktag->dst = 0;
- blktag->flags = 0;
- return blktag;
-}
-
-#define PUSH_BLOCK(v,b) { \
+#define PUSH_BLOCK(v,b) do { \
struct BLOCK _block; \
- _block.tag = new_blktag(); \
- _block.var = v; \
- _block.body = b; \
+ _block.var = (v); \
+ _block.body = (b); \
_block.self = self; \
_block.frame = *ruby_frame; \
_block.klass = ruby_class; \
- _block.frame.file = ruby_sourcefile;\
- _block.frame.line = ruby_sourceline;\
+ _block.cref = ruby_cref; \
+ _block.frame.node = ruby_current_node;\
_block.scope = ruby_scope; \
_block.prev = ruby_block; \
+ _block.outer = ruby_block; \
_block.iter = ruby_iter->iter; \
_block.vmode = scope_vmode; \
_block.flags = BLOCK_D_SCOPE; \
_block.dyna_vars = ruby_dyna_vars; \
- ruby_block = &_block;
-
-#define POP_BLOCK_TAG(tag) do { \
- if ((tag)->flags & BLOCK_DYNAMIC) \
- (tag)->flags |= BLOCK_ORPHAN; \
- else \
- rb_gc_force_recycle((VALUE)tag); \
+ _block.wrapper = ruby_wrapper; \
+ _block.block_obj = 0; \
+ _block.uniq = (b)?block_unique++:0; \
+ if (b) { \
+ prot_tag->blkid = _block.uniq; \
+ } \
+ ruby_block = &_block
+
+#define POP_BLOCK() \
+ ruby_block = _block.prev; \
} while (0)
-#define POP_BLOCK() \
- POP_BLOCK_TAG(_block.tag); \
- ruby_block = _block.prev; \
-}
-
struct RVarmap *ruby_dyna_vars;
-#define PUSH_VARS() { \
- struct RVarmap * volatile _old; \
- _old = ruby_dyna_vars; \
- ruby_dyna_vars = 0;
-
-#define POP_VARS() \
- if (_old && (ruby_scope->flag & SCOPE_DONT_RECYCLE)) \
- FL_SET(_old, DVAR_DONT_RECYCLE); \
- ruby_dyna_vars = _old; \
-}
+#define PUSH_VARS() do { \
+ struct RVarmap * volatile _old; \
+ _old = ruby_dyna_vars; \
+ ruby_dyna_vars = 0
+
+#define POP_VARS() \
+ if (_old && (ruby_scope->flags & SCOPE_DONT_RECYCLE)) {\
+ if (RBASIC(_old)->flags) /* unless it's already recycled */ \
+ FL_SET(_old, DVAR_DONT_RECYCLE); \
+ }\
+ ruby_dyna_vars = _old; \
+} while (0)
#define DVAR_DONT_RECYCLE FL_USER2
@@ -679,6 +817,7 @@ dvar_asgn_internal(id, value, curr)
while (vars) {
if (curr && vars->id == 0) {
+ /* first null is a dvar header */
n++;
if (n == 2) break;
}
@@ -697,7 +836,7 @@ dvar_asgn_internal(id, value, curr)
}
}
-void
+static inline void
dvar_asgn(id, value)
ID id;
VALUE value;
@@ -705,7 +844,7 @@ dvar_asgn(id, value)
dvar_asgn_internal(id, value, 0);
}
-static void
+static inline void
dvar_asgn_curr(id, value)
ID id;
VALUE value;
@@ -713,6 +852,24 @@ dvar_asgn_curr(id, value)
dvar_asgn_internal(id, value, 1);
}
+VALUE *
+rb_svar(cnt)
+ int cnt;
+{
+ struct RVarmap *vars = ruby_dyna_vars;
+ ID id;
+
+ if (!ruby_scope->local_tbl) return NULL;
+ if (cnt >= ruby_scope->local_tbl[0]) return NULL;
+ id = ruby_scope->local_tbl[cnt+1];
+ while (vars) {
+ if (vars->id == id) return &vars->val;
+ vars = vars->next;
+ }
+ if (ruby_scope->local_vars == 0) return NULL;
+ return &ruby_scope->local_vars[cnt];
+}
+
struct iter {
int iter;
struct iter *prev;
@@ -723,29 +880,30 @@ static struct iter *ruby_iter;
#define ITER_PRE 1
#define ITER_CUR 2
-#define PUSH_ITER(i) { \
+#define PUSH_ITER(i) do { \
struct iter _iter; \
_iter.prev = ruby_iter; \
_iter.iter = (i); \
- ruby_iter = &_iter; \
+ ruby_iter = &_iter
#define POP_ITER() \
ruby_iter = _iter.prev; \
-}
+} while (0)
struct tag {
- jmp_buf buf;
+ rb_jmpbuf_t buf;
struct FRAME *frame;
struct iter *iter;
- ID tag;
+ VALUE tag;
VALUE retval;
struct SCOPE *scope;
- int dst;
+ VALUE dst;
struct tag *prev;
+ int blkid;
};
static struct tag *prot_tag;
-#define PUSH_TAG(ptag) { \
+#define PUSH_TAG(ptag) do { \
struct tag _tag; \
_tag.retval = Qnil; \
_tag.frame = ruby_frame; \
@@ -754,29 +912,29 @@ static struct tag *prot_tag;
_tag.scope = ruby_scope; \
_tag.tag = ptag; \
_tag.dst = 0; \
- prot_tag = &_tag;
+ _tag.blkid = 0; \
+ prot_tag = &_tag
-#define PROT_NONE 0
-#define PROT_FUNC -1
-#define PROT_THREAD -2
+#define PROT_NONE Qfalse /* 0 */
+#define PROT_THREAD Qtrue /* 2 */
+#define PROT_FUNC INT2FIX(0) /* 1 */
+#define PROT_LOOP INT2FIX(1) /* 3 */
+#define PROT_LAMBDA INT2FIX(2) /* 5 */
+#define PROT_YIELD INT2FIX(3) /* 7 */
-#define EXEC_TAG() setjmp(prot_tag->buf)
+#define EXEC_TAG() (FLUSH_REGISTER_WINDOWS, setjmp(prot_tag->buf))
-#define JUMP_TAG(st) { \
+#define JUMP_TAG(st) do { \
ruby_frame = prot_tag->frame; \
ruby_iter = prot_tag->iter; \
longjmp(prot_tag->buf,(st)); \
-}
+} while (0)
#define POP_TAG() \
- if (_tag.prev) \
- _tag.prev->retval = _tag.retval;\
prot_tag = _tag.prev; \
-}
+} while (0)
-#define POP_TMPTAG() \
- prot_tag = _tag.prev; \
-}
+#define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq)
#define TAG_RETURN 0x1
#define TAG_BREAK 0x2
@@ -791,27 +949,29 @@ static struct tag *prot_tag;
VALUE ruby_class;
static VALUE ruby_wrapper; /* security wrapper */
-#define PUSH_CLASS() { \
+#define PUSH_CLASS(c) do { \
VALUE _class = ruby_class; \
+ ruby_class = (c)
-#define POP_CLASS() ruby_class = _class; }
+#define POP_CLASS() ruby_class = _class; \
+} while (0)
static NODE *ruby_cref = 0;
static NODE *top_cref;
-#define PUSH_CREF(c) ruby_cref = rb_node_newnode(NODE_CREF,(c),0,ruby_cref)
+#define PUSH_CREF(c) ruby_cref = NEW_NODE(NODE_CREF,(c),0,ruby_cref)
#define POP_CREF() ruby_cref = ruby_cref->nd_next
-#define PUSH_SCOPE() { \
+#define PUSH_SCOPE() do { \
volatile int _vmode = scope_vmode; \
struct SCOPE * volatile _old; \
NEWOBJ(_scope, struct SCOPE); \
OBJSETUP(_scope, 0, T_SCOPE); \
_scope->local_tbl = 0; \
_scope->local_vars = 0; \
- _scope->flag = 0; \
+ _scope->flags = 0; \
_old = ruby_scope; \
ruby_scope = _scope; \
- scope_vmode = SCOPE_PUBLIC;
+ scope_vmode = SCOPE_PUBLIC
typedef struct thread * rb_thread_t;
static rb_thread_t curr_thread = 0;
@@ -819,28 +979,35 @@ static rb_thread_t main_thread;
static void scope_dup _((struct SCOPE *));
#define POP_SCOPE() \
- if (ruby_scope->flag & SCOPE_DONT_RECYCLE) {\
- if (_old) scope_dup(_old); \
+ if (ruby_scope->flags & SCOPE_DONT_RECYCLE) {\
+ if (_old) scope_dup(_old); \
} \
- if (!(ruby_scope->flag & SCOPE_MALLOC)) {\
+ if (!(ruby_scope->flags & SCOPE_MALLOC)) {\
ruby_scope->local_vars = 0; \
ruby_scope->local_tbl = 0; \
- if (!(ruby_scope->flag & SCOPE_DONT_RECYCLE) && \
- ruby_scope != top_scope) { \
+ if (!(ruby_scope->flags & SCOPE_DONT_RECYCLE) && \
+ ruby_scope != top_scope) { \
rb_gc_force_recycle((VALUE)ruby_scope);\
- } \
+ } \
} \
- ruby_scope->flag |= SCOPE_NOSTACK; \
+ ruby_scope->flags |= SCOPE_NOSTACK; \
ruby_scope = _old; \
scope_vmode = _vmode; \
-}
+} while (0)
static VALUE rb_eval _((VALUE,NODE*));
static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
static NODE *compile _((VALUE, char*, int));
-static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int));
-static VALUE rb_call _((VALUE,VALUE,ID,int,VALUE*,int));
+static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
+
+#define YIELD_LAMBDA_CALL 1
+#define YIELD_PROC_CALL 2
+#define YIELD_PUBLIC_DEF 4
+#define YIELD_FUNC_AVALUE 1
+#define YIELD_FUNC_SVALUE 2
+
+static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int));
static VALUE module_setup _((VALUE,NODE*));
static VALUE massign _((VALUE,NODE*,VALUE,int));
@@ -848,21 +1015,59 @@ static void assign _((VALUE,NODE*,VALUE,int));
static VALUE trace_func = 0;
static int tracing = 0;
-static void call_trace_func _((char*,char*,int,VALUE,ID,VALUE));
+static void call_trace_func _((char*,NODE*,VALUE,ID,VALUE));
+
+#if 0
+#define SET_CURRENT_SOURCE() (ruby_sourcefile = ruby_current_node->nd_file, \
+ ruby_sourceline = nd_line(ruby_current_node))
+#else
+#define SET_CURRENT_SOURCE() ((void)0)
+#endif
+
+void
+ruby_set_current_source()
+{
+ if (ruby_current_node) {
+ ruby_sourcefile = ruby_current_node->nd_file;
+ ruby_sourceline = nd_line(ruby_current_node);
+ }
+}
+
+static void
+#ifdef HAVE_STDARG_PROTOTYPES
+warn_printf(const char *fmt, ...)
+#else
+warn_printf(fmt, va_alist)
+ const char *fmt;
+ va_dcl
+#endif
+{
+ char buf[BUFSIZ];
+ va_list args;
+
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+ rb_write_error(buf);
+}
+
+#define warn_print(x) rb_write_error(x)
+#define warn_print2(x,l) rb_write_error2(x,l)
static void
error_pos()
{
+ ruby_set_current_source();
if (ruby_sourcefile) {
if (ruby_frame->last_func) {
- fprintf(stderr, "%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
- rb_id2name(ruby_frame->last_func));
+ warn_printf("%s:%d:in `%s'", ruby_sourcefile, ruby_sourceline,
+ rb_id2name(ruby_frame->last_func));
}
else if (ruby_sourceline == 0) {
- fprintf(stderr, "%s", ruby_sourcefile);
+ warn_printf("%s", ruby_sourcefile);
}
else {
- fprintf(stderr, "%s:%d", ruby_sourcefile, ruby_sourceline);
+ warn_printf("%s:%d", ruby_sourcefile, ruby_sourceline);
}
}
}
@@ -872,7 +1077,7 @@ get_backtrace(info)
VALUE info;
{
if (NIL_P(info)) return Qnil;
- return rb_funcall(info, rb_intern("backtrace"), 0);
+ return rb_check_array_type(rb_funcall(info, rb_intern("backtrace"), 0));
}
static void
@@ -886,9 +1091,9 @@ static void
error_print()
{
VALUE errat = Qnil; /* OK */
- volatile VALUE eclass;
+ volatile VALUE eclass, e;
char *einfo;
- int elen;
+ long elen;
if (NIL_P(ruby_errinfo)) return;
@@ -899,69 +1104,73 @@ error_print()
else {
errat = Qnil;
}
- POP_TAG();
- if (NIL_P(errat)) {
+ if (EXEC_TAG()) goto error;
+ if (NIL_P(errat)){
+ ruby_set_current_source();
if (ruby_sourcefile)
- fprintf(stderr, "%s:%d", ruby_sourcefile, ruby_sourceline);
+ warn_printf("%s:%d", ruby_sourcefile, ruby_sourceline);
else
- fprintf(stderr, "%d", ruby_sourceline);
+ warn_printf("%d", ruby_sourceline);
+ }
+ else if (RARRAY(errat)->len == 0) {
+ error_pos();
}
else {
VALUE mesg = RARRAY(errat)->ptr[0];
if (NIL_P(mesg)) error_pos();
else {
- fwrite(RSTRING(mesg)->ptr, 1, RSTRING(mesg)->len, stderr);
+ warn_print2(RSTRING(mesg)->ptr, RSTRING(mesg)->len);
}
}
eclass = CLASS_OF(ruby_errinfo);
- PUSH_TAG(PROT_NONE);
if (EXEC_TAG() == 0) {
- einfo = str2cstr(rb_obj_as_string(ruby_errinfo), &elen);
+ e = rb_funcall(ruby_errinfo, rb_intern("message"), 0, 0);
+ StringValue(e);
+ einfo = RSTRING(e)->ptr;
+ elen = RSTRING(e)->len;
}
else {
einfo = "";
elen = 0;
}
- POP_TAG();
+ if (EXEC_TAG()) goto error;
if (eclass == rb_eRuntimeError && elen == 0) {
- fprintf(stderr, ": unhandled exception\n");
+ warn_print(": unhandled exception\n");
}
else {
VALUE epath;
- epath = rb_class_path(eclass);
+ epath = rb_class_name(eclass);
if (elen == 0) {
- fprintf(stderr, ": ");
- fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr);
- putc('\n', stderr);
+ warn_print(": ");
+ warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
}
else {
char *tail = 0;
- int len = elen;
+ long len = elen;
if (RSTRING(epath)->ptr[0] == '#') epath = 0;
- if (tail = strchr(einfo, '\n')) {
+ if (tail = memchr(einfo, '\n', elen)) {
len = tail - einfo;
tail++; /* skip newline */
}
- fprintf(stderr, ": ");
- fwrite(einfo, 1, len, stderr);
+ warn_print(": ");
+ warn_print2(einfo, len);
if (epath) {
- fprintf(stderr, " (");
- fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, stderr);
- fprintf(stderr, ")\n");
+ warn_print(" (");
+ warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
+ warn_print(")\n");
}
if (tail) {
- fwrite(tail, 1, elen-len-1, stderr);
- putc('\n', stderr);
+ warn_print2(tail, elen-len-1);
}
}
}
if (!NIL_P(errat)) {
- int i;
+ long i;
struct RArray *ep = RARRAY(errat);
#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)
@@ -971,27 +1180,39 @@ error_print()
ep = RARRAY(errat);
for (i=1; i<ep->len; i++) {
if (TYPE(ep->ptr[i]) == T_STRING) {
- fprintf(stderr, "\tfrom %s\n", RSTRING(ep->ptr[i])->ptr);
+ warn_printf("\tfrom %s\n", RSTRING(ep->ptr[i])->ptr);
}
if (i == TRACE_HEAD && ep->len > TRACE_MAX) {
- fprintf(stderr, "\t ... %ld levels...\n",
+ warn_printf("\t ... %ld levels...\n",
ep->len - TRACE_HEAD - TRACE_TAIL);
i = ep->len - TRACE_TAIL;
}
}
}
+ error:
+ POP_TAG();
}
-#if !defined(NT) && !defined(__MACOS__)
+#if defined(__APPLE__)
+#define environ (*_NSGetEnviron())
+#elif !defined(_WIN32) && !defined(__MACOS__) || defined(_WIN32_WCE)
extern char **environ;
#endif
char **rb_origenviron;
void rb_call_inits _((void));
-void Init_stack _((void*));
+void Init_stack _((VALUE*));
void Init_heap _((void));
void Init_ext _((void));
+#ifdef HAVE_NATIVETHREAD
+static rb_nativethread_t ruby_thid;
+int
+is_ruby_native_thread() {
+ return NATIVETHREAD_EQUAL(ruby_thid, NATIVETHREAD_CURRENT());
+}
+#endif
+
void
ruby_init()
{
@@ -1003,6 +1224,9 @@ ruby_init()
if (initialized)
return;
initialized = 1;
+#ifdef HAVE_NATIVETHREAD
+ ruby_thid = NATIVETHREAD_CURRENT();
+#endif
ruby_frame = top_frame = &frame;
ruby_iter = &iter;
@@ -1013,7 +1237,7 @@ ruby_init()
rb_origenviron = environ;
#endif
- Init_stack(0);
+ Init_stack((void*)&state);
Init_heap();
PUSH_SCOPE();
ruby_scope->local_vars = 0;
@@ -1029,17 +1253,22 @@ ruby_init()
ruby_frame->self = ruby_top_self;
top_cref = rb_node_newnode(NODE_CREF,rb_cObject,0,0);
ruby_cref = top_cref;
- ruby_frame->cbase = (VALUE)ruby_cref;
rb_define_global_const("TOPLEVEL_BINDING", rb_f_binding(ruby_top_self));
#ifdef __MACOS__
_macruby_init();
#endif
ruby_prog_init();
+ ALLOW_INTS;
}
POP_TAG();
- if (state) error_print();
+ if (state) {
+ error_print();
+ exit(EXIT_FAILURE);
+ }
POP_SCOPE();
ruby_scope = top_scope;
+ top_scope->flags &= ~SCOPE_NOSTACK;
+ ruby_running = 1;
}
static VALUE
@@ -1063,57 +1292,71 @@ int ruby_in_eval;
static void rb_thread_cleanup _((void));
static void rb_thread_wait_other_threads _((void));
-static int exit_status;
+static int thread_set_raised();
+static int thread_reset_raised();
+
+static VALUE exception_error;
+static VALUE sysstack_error;
static int
error_handle(ex)
int ex;
{
+ int status = EXIT_FAILURE;
+
+ if (thread_set_raised()) return EXIT_FAILURE;
switch (ex & TAG_MASK) {
case 0:
- ex = 0;
+ status = EXIT_SUCCESS;
break;
case TAG_RETURN:
error_pos();
- fprintf(stderr, ": unexpected return\n");
- ex = 1;
+ warn_print(": unexpected return\n");
break;
case TAG_NEXT:
error_pos();
- fprintf(stderr, ": unexpected next\n");
- ex = 1;
+ warn_print(": unexpected next\n");
break;
case TAG_BREAK:
error_pos();
- fprintf(stderr, ": unexpected break\n");
- ex = 1;
+ warn_print(": unexpected break\n");
break;
case TAG_REDO:
error_pos();
- fprintf(stderr, ": unexpected redo\n");
- ex = 1;
+ warn_print(": unexpected redo\n");
break;
case TAG_RETRY:
error_pos();
- fprintf(stderr, ": retry outside of rescue clause\n");
- ex = 1;
+ warn_print(": retry outside of rescue clause\n");
+ break;
+ case TAG_THROW:
+ if (prot_tag && prot_tag->frame && prot_tag->frame->node) {
+ NODE *tag = prot_tag->frame->node;
+ warn_printf("%s:%d: uncaught throw\n",
+ tag->nd_file, nd_line(tag));
+ }
+ else {
+ error_pos();
+ warn_printf(": unexpected throw\n");
+ }
break;
case TAG_RAISE:
case TAG_FATAL:
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
- ex = exit_status;
+ VALUE st = rb_iv_get(ruby_errinfo, "status");
+ status = NUM2INT(st);
}
else {
error_print();
- ex = 1;
}
break;
default:
rb_bug("Unknown longjmp status %d", ex);
break;
}
- return ex;
+ thread_reset_raised();
+ return status;
}
void
@@ -1123,38 +1366,59 @@ ruby_options(argc, argv)
{
int state;
- PUSH_TAG(PROT_NONE)
+ Init_stack((void*)&state);
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
ruby_process_options(argc, argv);
}
- POP_TAG();
- if (state) {
+ else {
trace_func = 0;
tracing = 0;
exit(error_handle(state));
}
+ POP_TAG();
}
void rb_exec_end_proc _((void));
-void
-ruby_finalize()
+static void
+ruby_finalize_0()
{
PUSH_TAG(PROT_NONE);
if (EXEC_TAG() == 0) {
rb_trap_exit();
- rb_exec_end_proc();
- rb_gc_call_finalizer_at_exit();
}
POP_TAG();
+ rb_exec_end_proc();
+}
+
+static void
+ruby_finalize_1()
+{
+ ruby_errinfo = 0;
+ rb_gc_call_finalizer_at_exit();
+ trace_func = 0;
+ tracing = 0;
}
void
-ruby_stop(ex)
+ruby_finalize()
+{
+ ruby_finalize_0();
+ ruby_finalize_1();
+}
+
+int
+ruby_cleanup(ex)
int ex;
{
int state;
+ volatile VALUE err = ruby_errinfo;
+ ruby_safe_level = 0;
+ Init_stack((void*)&state);
+ ruby_finalize_0();
+ if (ruby_errinfo) err = ruby_errinfo;
PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
@@ -1163,33 +1427,61 @@ ruby_stop(ex)
}
else if (ex == 0) {
ex = state;
- }
+ }
POP_ITER();
+ ruby_errinfo = err;
+ ex = error_handle(ex);
+ ruby_finalize_1();
POP_TAG();
- ex = error_handle(ex);
- ruby_finalize();
- exit(ex);
+ if (err && rb_obj_is_kind_of(err, rb_eSystemExit)) {
+ VALUE st = rb_iv_get(err, "status");
+ return NUM2INT(st);
+ }
+ return ex;
}
-void
-ruby_run()
+static int
+ruby_exec_internal()
{
int state;
- static int ex;
- volatile NODE *tmp;
-
- if (ruby_nerrs > 0) exit(ruby_nerrs);
- Init_stack(&tmp);
PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
+ /* default visibility is private at toplevel */
+ SCOPE_SET(SCOPE_PRIVATE);
if ((state = EXEC_TAG()) == 0) {
eval_node(ruby_top_self, ruby_eval_tree);
}
POP_ITER();
POP_TAG();
+ return state;
+}
+
+void
+ruby_stop(ex)
+ int ex;
+{
+ exit(ruby_cleanup(ex));
+}
+int
+ruby_exec()
+{
+ volatile NODE *tmp;
+
+ Init_stack((void*)&tmp);
+ return ruby_exec_internal();
+}
+
+void
+ruby_run()
+{
+ int state;
+ static int ex;
+
+ if (ruby_nerrs > 0) exit(EXIT_FAILURE);
+ state = ruby_exec();
if (state && !ex) ex = state;
ruby_stop(ex);
}
@@ -1201,14 +1493,14 @@ compile_error(at)
VALUE str;
ruby_nerrs = 0;
- str = rb_str_new2("compile error");
+ str = rb_str_buf_new2("compile error");
if (at) {
- rb_str_cat2(str, " in ");
- rb_str_cat2(str, at);
+ rb_str_buf_cat2(str, " in ");
+ rb_str_buf_cat2(str, at);
}
- rb_str_cat(str, "\n", 1);
+ rb_str_buf_cat(str, "\n", 1);
if (!NIL_P(ruby_errinfo)) {
- rb_str_concat(str, ruby_errinfo);
+ rb_str_append(str, rb_obj_as_string(ruby_errinfo));
}
rb_exc_raise(rb_exc_new3(rb_eSyntaxError, str));
}
@@ -1218,11 +1510,12 @@ rb_eval_string(str)
const char *str;
{
VALUE v;
- char *oldsrc = ruby_sourcefile;
+ NODE *oldsrc = ruby_current_node;
- ruby_sourcefile = "(eval)";
+ ruby_current_node = 0;
+ ruby_sourcefile = rb_source_filename("(eval)");
v = eval(ruby_top_self, rb_str_new2(str), Qnil, 0, 0);
- ruby_sourcefile = oldsrc;
+ ruby_current_node = oldsrc;
return v;
}
@@ -1232,7 +1525,7 @@ rb_eval_string_protect(str, state)
const char *str;
int *state;
{
- VALUE result; /* OK */
+ VALUE result = Qnil; /* OK */
int status;
PUSH_TAG(PROT_NONE);
@@ -1257,17 +1550,27 @@ rb_eval_string_wrap(str, state)
{
int status;
VALUE self = ruby_top_self;
+ VALUE wrapper = ruby_wrapper;
VALUE val;
- PUSH_CLASS();
- ruby_class = ruby_wrapper = rb_module_new();
+ PUSH_CLASS(ruby_wrapper = rb_module_new());
ruby_top_self = rb_obj_clone(ruby_top_self);
- rb_extend_object(self, ruby_class);
+ rb_extend_object(ruby_top_self, ruby_wrapper);
+ PUSH_FRAME();
+ ruby_frame->last_func = 0;
+ ruby_frame->orig_func = 0;
+ ruby_frame->last_class = 0;
+ ruby_frame->self = self;
+ PUSH_CREF(ruby_wrapper);
+ PUSH_SCOPE();
val = rb_eval_string_protect(str, &status);
ruby_top_self = self;
+ POP_SCOPE();
+ POP_FRAME();
POP_CLASS();
+ ruby_wrapper = wrapper;
if (state) {
*state = status;
}
@@ -1277,129 +1580,149 @@ rb_eval_string_wrap(str, state)
return val;
}
+NORETURN(static void localjump_error(const char*, VALUE, int));
static void
-jump_tag_but_local_jump(state)
+localjump_error(mesg, value, reason)
+ const char *mesg;
+ VALUE value;
+ int reason;
+{
+ VALUE exc = rb_exc_new2(rb_eLocalJumpError, mesg);
+ ID id;
+
+ rb_iv_set(exc, "@exit_value", value);
+ switch (reason) {
+ case TAG_BREAK:
+ id = rb_intern("break"); break;
+ case TAG_REDO:
+ id = rb_intern("redo"); break;
+ case TAG_RETRY:
+ id = rb_intern("retry"); break;
+ case TAG_NEXT:
+ id = rb_intern("next"); break;
+ case TAG_RETURN:
+ id = rb_intern("return"); break;
+ default:
+ id = rb_intern("noreason"); break;
+ }
+ rb_iv_set(exc, "@reason", ID2SYM(id));
+ rb_exc_raise(exc);
+}
+
+/*
+ * call_seq:
+ * local_jump_error.exit_value => obj
+ *
+ * Returns the exit value associated with this +LocalJumpError+.
+ */
+static VALUE
+localjump_xvalue(exc)
+ VALUE exc;
+{
+ return rb_iv_get(exc, "@exit_value");
+}
+
+/*
+ * call-seq:
+ * local_jump_error.reason => symbol
+ *
+ * The reason this block was terminated:
+ * :break, :redo, :retry, :next, :return, or :noreason.
+ */
+
+static VALUE
+localjump_reason(exc)
+ VALUE exc;
+{
+ return rb_iv_get(exc, "@reason");
+}
+
+NORETURN(static void jump_tag_but_local_jump _((int,VALUE)));
+static void
+jump_tag_but_local_jump(state, val)
int state;
+ VALUE val;
{
+
+ if (val == Qundef) val = prot_tag->retval;
switch (state) {
case 0:
break;
case TAG_RETURN:
- rb_raise(rb_eLocalJumpError, "unexpected return");
- break;
- case TAG_NEXT:
- rb_raise(rb_eLocalJumpError, "unexpected next");
+ localjump_error("unexpected return", val, state);
break;
case TAG_BREAK:
- rb_raise(rb_eLocalJumpError, "unexpected break");
+ localjump_error("unexpected break", val, state);
+ break;
+ case TAG_NEXT:
+ localjump_error("unexpected next", val, state);
break;
case TAG_REDO:
- rb_raise(rb_eLocalJumpError, "unexpected redo");
+ localjump_error("unexpected redo", Qnil, state);
break;
case TAG_RETRY:
- rb_raise(rb_eLocalJumpError, "retry outside of rescue clause");
+ localjump_error("retry outside of rescue clause", Qnil, state);
break;
default:
- JUMP_TAG(state);
break;
}
+ JUMP_TAG(state);
}
VALUE
-rb_eval_cmd(cmd, arg)
+rb_eval_cmd(cmd, arg, level)
VALUE cmd, arg;
+ int level;
{
int state;
- VALUE val; /* OK */
+ VALUE val = Qnil; /* OK */
struct SCOPE *saved_scope;
volatile int safe = ruby_safe_level;
+ if (OBJ_TAINTED(cmd)) {
+ level = 4;
+ }
if (TYPE(cmd) != T_STRING) {
- return rb_funcall2(cmd, rb_intern("call"),
- RARRAY(arg)->len, RARRAY(arg)->ptr);
+ PUSH_ITER(ITER_NOT);
+ PUSH_TAG(PROT_NONE);
+ ruby_safe_level = level;
+ if ((state = EXEC_TAG()) == 0) {
+ val = rb_funcall2(cmd, rb_intern("call"), RARRAY(arg)->len, RARRAY(arg)->ptr);
+ }
+ ruby_safe_level = safe;
+ POP_TAG();
+ POP_ITER();
+ if (state) JUMP_TAG(state);
+ return val;
}
- PUSH_CLASS();
- PUSH_TAG(PROT_NONE);
saved_scope = ruby_scope;
ruby_scope = top_scope;
+ PUSH_FRAME();
+ ruby_frame->last_func = 0;
+ ruby_frame->orig_func = 0;
+ ruby_frame->last_class = 0;
+ ruby_frame->self = ruby_top_self;
+ PUSH_CREF(ruby_wrapper ? ruby_wrapper : rb_cObject);
- ruby_class = rb_cObject;
- if (OBJ_TAINTED(cmd)) {
- ruby_safe_level = 4;
- }
+ ruby_safe_level = level;
+ PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
val = eval(ruby_top_self, cmd, Qnil, 0, 0);
}
-
- if (ruby_scope->flag & SCOPE_DONT_RECYCLE)
- scope_dup(saved_scope);
+ if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
+ scope_dup(saved_scope);
ruby_scope = saved_scope;
ruby_safe_level = safe;
POP_TAG();
- POP_CLASS();
-
- jump_tag_but_local_jump(state);
- return val;
-}
-
-static VALUE
-rb_trap_eval(cmd, sig)
- VALUE cmd;
- int sig;
-{
- int state;
- VALUE val; /* OK */
-
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- val = rb_eval_cmd(cmd, rb_ary_new3(1, INT2FIX(sig)));
- }
- POP_TAG();
- if (state) {
- rb_trap_immediate = 0;
- JUMP_TAG(state);
- }
- return val;
-}
-
-static VALUE
-superclass(self, node)
- VALUE self;
- NODE *node;
-{
- VALUE val; /* OK */
- int state;
-
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- val = rb_eval(self, node);
- }
- POP_TAG();
- if (state) {
- superclass_error:
- switch (nd_type(node)) {
- case NODE_COLON2:
- rb_raise(rb_eTypeError, "undefined superclass `%s'",
- rb_id2name(node->nd_mid));
- case NODE_CONST:
- rb_raise(rb_eTypeError, "undefined superclass `%s'",
- rb_id2name(node->nd_vid));
- default:
- rb_raise(rb_eTypeError, "superclass undefined");
- }
- JUMP_TAG(state);
- }
- if (TYPE(val) != T_CLASS) goto superclass_error;
- if (FL_TEST(val, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "can't make subclass of virtual class");
- }
+ POP_FRAME();
+ jump_tag_but_local_jump(state, val);
return val;
}
-#define ruby_cbase (RNODE(ruby_frame->cbase)->nd_clss)
+#define ruby_cbase (ruby_cref->nd_clss)
static VALUE
ev_const_defined(cref, id, self)
@@ -1408,12 +1731,16 @@ ev_const_defined(cref, id, self)
VALUE self;
{
NODE *cbase = cref;
+ VALUE result;
while (cbase && cbase->nd_next) {
struct RClass *klass = RCLASS(cbase->nd_clss);
if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id);
- if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) {
+ if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
+ if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) {
+ return Qfalse;
+ }
return Qtrue;
}
cbase = cbase->nd_next;
@@ -1431,10 +1758,14 @@ ev_const_get(cref, id, self)
VALUE result;
while (cbase && cbase->nd_next) {
- struct RClass *klass = RCLASS(cbase->nd_clss);
+ VALUE klass = cbase->nd_clss;
if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id);
- if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
+ while (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, &result)) {
+ if (result == Qundef) {
+ rb_autoload_load(klass, id);
+ continue;
+ }
return result;
}
cbase = cbase->nd_next;
@@ -1443,31 +1774,84 @@ ev_const_get(cref, id, self)
}
static VALUE
+cvar_cbase()
+{
+ NODE *cref = ruby_cref;
+
+ while (cref && cref->nd_next && (NIL_P(cref->nd_clss) || FL_TEST(cref->nd_clss, FL_SINGLETON))) {
+ cref = cref->nd_next;
+ if (!cref->nd_next) {
+ rb_warn("class variable access from toplevel singleton method");
+ }
+ }
+ if (NIL_P(cref->nd_clss)) {
+ rb_raise(rb_eTypeError, "no class variables available");
+ }
+ return cref->nd_clss;
+}
+
+/*
+ * call-seq:
+ * Module.nesting => array
+ *
+ * Returns the list of +Modules+ nested at the point of call.
+ *
+ * module M1
+ * module M2
+ * $a = Module.nesting
+ * end
+ * end
+ * $a #=> [M1::M2, M1]
+ * $a[0].name #=> "M1::M2"
+ */
+
+static VALUE
rb_mod_nesting()
{
- NODE *cbase = RNODE(ruby_frame->cbase);
+ NODE *cbase = ruby_cref;
VALUE ary = rb_ary_new();
while (cbase && cbase->nd_next) {
if (!NIL_P(cbase->nd_clss)) rb_ary_push(ary, cbase->nd_clss);
cbase = cbase->nd_next;
}
+ if (ruby_wrapper && RARRAY(ary)->len == 0) {
+ rb_ary_push(ary, ruby_wrapper);
+ }
return ary;
}
+/*
+ * call-seq:
+ * Module.constants => array
+ *
+ * Returns an array of the names of all constants defined in the
+ * system. This list includes the names of all modules and classes.
+ *
+ * p Module.constants.sort[1..5]
+ *
+ * <em>produces:</em>
+ *
+ * ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"]
+ */
+
static VALUE
rb_mod_s_constants()
{
- NODE *cbase = RNODE(ruby_frame->cbase);
- VALUE ary = rb_ary_new();
+ NODE *cbase = ruby_cref;
+ void *data = 0;
while (cbase) {
- if (!NIL_P(cbase->nd_clss)) rb_mod_const_at(cbase->nd_clss, ary);
+ if (!NIL_P(cbase->nd_clss)) {
+ data = rb_mod_const_at(cbase->nd_clss, data);
+ }
cbase = cbase->nd_next;
}
- if (!NIL_P(ruby_cbase)) rb_mod_const_of(ruby_cbase, ary);
- return ary;
+ if (!NIL_P(ruby_cbase)) {
+ data = rb_mod_const_of(ruby_cbase, data);
+ }
+ return rb_const_list(data);
}
void
@@ -1500,18 +1884,17 @@ rb_undef(klass, id)
VALUE origin;
NODE *body;
- if (ruby_class == rb_cObject) {
+ if (ruby_cbase == rb_cObject && klass == rb_cObject) {
rb_secure(4);
}
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
- rb_raise(rb_eSecurityError, "Insecure: can't undef");
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(klass)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'", rb_id2name(id));
}
rb_frozen_class_p(klass);
- if (id == __id__ || id == __send__) {
- rb_warn("undefining `%s' may cause serious problem",
- rb_id2name(id));
+ if (id == __id__ || id == __send__ || id == init) {
+ rb_warn("undefining `%s' may cause serious problem", rb_id2name(id));
}
- body = search_method(ruby_class, id, &origin);
+ body = search_method(klass, id, &origin);
if (!body || !body->nd_body) {
char *s0 = " class";
VALUE c = klass;
@@ -1529,18 +1912,73 @@ rb_undef(klass, id)
else if (TYPE(c) == T_MODULE) {
s0 = " module";
}
- rb_raise(rb_eNameError, "undefined method `%s' for%s `%s'",
- rb_id2name(id),s0,rb_class2name(c));
+ rb_name_error(id, "undefined method `%s' for%s `%s'",
+ rb_id2name(id),s0,rb_class2name(c));
}
rb_add_method(klass, id, 0, NOEX_PUBLIC);
- rb_clear_cache_by_id(id);
-}
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_funcall(rb_iv_get(klass, "__attached__"),
+ singleton_undefined, 1, ID2SYM(id));
+ }
+ else {
+ rb_funcall(klass, undefined, 1, ID2SYM(id));
+ }
+}
+
+/*
+ * call-seq:
+ * undef_method(symbol) => self
+ *
+ * Prevents the current class from responding to calls to the named
+ * method. Contrast this with <code>remove_method</code>, which deletes
+ * the method from the particular class; Ruby will still search
+ * superclasses and mixed-in modules for a possible receiver.
+ *
+ * class Parent
+ * def hello
+ * puts "In parent"
+ * end
+ * end
+ * class Child < Parent
+ * def hello
+ * puts "In child"
+ * end
+ * end
+ *
+ *
+ * c = Child.new
+ * c.hello
+ *
+ *
+ * class Child
+ * remove_method :hello # remove from child, still in parent
+ * end
+ * c.hello
+ *
+ *
+ * class Child
+ * undef_method :hello # prevent any calls to 'hello'
+ * end
+ * c.hello
+ *
+ * <em>produces:</em>
+ *
+ * In child
+ * In parent
+ * prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
+ */
static VALUE
-rb_mod_undef_method(mod, name)
- VALUE mod, name;
+rb_mod_undef_method(argc, argv, mod)
+ int argc;
+ VALUE *argv;
+ VALUE mod;
{
- rb_undef(mod, rb_to_id(name));
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_undef(mod, rb_to_id(argv[i]));
+ }
return mod;
}
@@ -1550,7 +1988,8 @@ rb_alias(klass, name, def)
ID name, def;
{
VALUE origin;
- NODE *orig, *body;
+ NODE *orig, *body, *node;
+ VALUE singleton = 0;
rb_frozen_class_p(klass);
if (name == def) return;
@@ -1566,6 +2005,9 @@ rb_alias(klass, name, def)
if (!orig || !orig->nd_body) {
print_undef(klass, def);
}
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ singleton = rb_iv_get(klass, "__attached__");
+ }
body = orig->nd_body;
orig->nd_cnt++;
if (nd_type(body) == NODE_FBODY) { /* was alias */
@@ -1574,10 +2016,43 @@ rb_alias(klass, name, def)
body = body->nd_head;
}
- st_insert(RCLASS(klass)->m_tbl, name,
- NEW_METHOD(NEW_FBODY(body, def, origin), orig->nd_noex));
rb_clear_cache_by_id(name);
-}
+ if (RTEST(ruby_verbose) && st_lookup(RCLASS(klass)->m_tbl, name, (st_data_t *)&node)) {
+ if (node->nd_cnt == 0 && node->nd_body) {
+ rb_warning("discarding old %s", rb_id2name(name));
+ }
+ }
+ st_insert(RCLASS(klass)->m_tbl, name,
+ (st_data_t)NEW_METHOD(NEW_FBODY(body, def, origin), orig->nd_noex));
+ if (singleton) {
+ rb_funcall(singleton, singleton_added, 1, ID2SYM(name));
+ }
+ else {
+ rb_funcall(klass, added, 1, ID2SYM(name));
+ }
+}
+
+/*
+ * call-seq:
+ * alias_method(new_name, old_name) => self
+ *
+ * Makes <i>new_name</i> a new copy of the method <i>old_name</i>. This can
+ * be used to retain access to methods that are overridden.
+ *
+ * module Mod
+ * alias_method :orig_exit, :exit
+ * def exit(code=0)
+ * puts "Exiting with code #{code}"
+ * orig_exit(code)
+ * end
+ * end
+ * include Mod
+ * exit(99)
+ *
+ * <em>produces:</em>
+ *
+ * Exiting with code 99
+ */
static VALUE
rb_mod_alias_method(mod, newname, oldname)
@@ -1590,9 +2065,9 @@ rb_mod_alias_method(mod, newname, oldname)
static NODE*
copy_node_scope(node, rval)
NODE *node;
- VALUE rval;
+ NODE *rval;
{
- NODE *copy = rb_node_newnode(NODE_SCOPE,0,rval,node->nd_next);
+ NODE *copy = NEW_NODE(NODE_SCOPE,0,rval,node->nd_next);
if (node->nd_tbl) {
copy->nd_tbl = ALLOC_N(ID, node->nd_tbl[0]+1);
@@ -1615,59 +2090,55 @@ copy_node_scope(node, rval)
# define TMP_ALLOC(n) ALLOCA_N(VALUE,n)
#endif
-#define SETUP_ARGS(anode) {\
+#define SETUP_ARGS0(anode,alen) do {\
NODE *n = anode;\
if (!n) {\
argc = 0;\
argv = 0;\
}\
else if (nd_type(n) == NODE_ARRAY) {\
- argc=n->nd_alen;\
- if (argc > 0) {\
- char *file = ruby_sourcefile;\
- int line = ruby_sourceline;\
- int i;\
+ argc=alen;\
+ if (argc > 0) {\
+ int i;\
n = anode;\
argv = TMP_ALLOC(argc);\
for (i=0;i<argc;i++) {\
argv[i] = rb_eval(self,n->nd_head);\
n=n->nd_next;\
}\
- ruby_sourcefile = file;\
- ruby_sourceline = line;\
- }\
- else {\
+ }\
+ else {\
argc = 0;\
argv = 0;\
- }\
+ }\
}\
else {\
- VALUE args = rb_eval(self,n);\
- char *file = ruby_sourcefile;\
- int line = ruby_sourceline;\
+ VALUE args = rb_eval(self,n);\
if (TYPE(args) != T_ARRAY)\
- args = rb_Array(args);\
- argc = RARRAY(args)->len;\
+ args = rb_ary_to_ary(args);\
+ argc = RARRAY(args)->len;\
argv = ALLOCA_N(VALUE, argc);\
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);\
- ruby_sourcefile = file;\
- ruby_sourceline = line;\
}\
-}
+} while (0)
-#define BEGIN_CALLARGS {\
+#define SETUP_ARGS(anode) SETUP_ARGS0(anode, anode->nd_alen)
+
+#define BEGIN_CALLARGS do {\
struct BLOCK *tmp_block = ruby_block;\
- if (ruby_iter->iter == ITER_PRE) {\
- ruby_block = ruby_block->prev;\
+ int tmp_iter = ruby_iter->iter;\
+ if (tmp_iter == ITER_PRE) {\
+ ruby_block = ruby_block->outer;\
+ tmp_iter = ITER_NOT;\
}\
- PUSH_ITER(ITER_NOT);
+ PUSH_ITER(tmp_iter)
#define END_CALLARGS \
ruby_block = tmp_block;\
POP_ITER();\
-}
+} while (0)
-#define MATCH_DATA ruby_scope->local_vars[node->nd_cnt]
+#define MATCH_DATA *rb_svar(node->nd_cnt)
static char* is_defined _((VALUE, NODE*, char*));
@@ -1684,20 +2155,20 @@ arg_defined(self, node, buf, type)
if (!node) return type; /* no args */
if (nd_type(node) == NODE_ARRAY) {
argc=node->nd_alen;
- if (argc > 0) {
+ if (argc > 0) {
for (i=0;i<argc;i++) {
if (!is_defined(self, node->nd_head, buf))
return 0;
node = node->nd_next;
}
- }
+ }
}
else if (!is_defined(self, node, buf)) {
return 0;
}
return type;
}
-
+
static char*
is_defined(self, node, buf)
VALUE self;
@@ -1707,13 +2178,15 @@ is_defined(self, node, buf)
VALUE val; /* OK */
int state;
+ again:
+ if (!node) return "expression";
switch (nd_type(node)) {
case NODE_SUPER:
case NODE_ZSUPER:
- if (ruby_frame->last_func == 0) return 0;
+ if (ruby_frame->orig_func == 0) return 0;
else if (ruby_frame->last_class == 0) return 0;
- else if (rb_method_boundp(RCLASS(ruby_frame->last_class)->super,
- ruby_frame->last_func, 0)) {
+ val = ruby_frame->last_class;
+ if (rb_method_boundp(RCLASS(val)->super, ruby_frame->orig_func, 0)) {
if (nd_type(node) == NODE_SUPER) {
return arg_defined(self, node->nd_args, buf, "super");
}
@@ -1723,15 +2196,16 @@ is_defined(self, node, buf)
case NODE_VCALL:
case NODE_FCALL:
- val = CLASS_OF(self);
+ val = self;
goto check_bound;
+ case NODE_ATTRASGN:
+ val = self;
+ if (node->nd_recv == (NODE *)1) goto check_bound;
case NODE_CALL:
- if (!is_defined(self, node->nd_recv, buf)) return 0;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
val = rb_eval(self, node->nd_recv);
- val = CLASS_OF(val);
}
POP_TAG();
if (state) {
@@ -1739,8 +2213,27 @@ is_defined(self, node, buf)
return 0;
}
check_bound:
- if (rb_method_boundp(val, node->nd_mid, nd_type(node)== NODE_CALL)) {
- return arg_defined(self, node->nd_args, buf, "method");
+ {
+ int call = nd_type(node)==NODE_CALL;
+
+ val = CLASS_OF(val);
+ if (call) {
+ int noex;
+ ID id = node->nd_mid;
+
+ if (!rb_get_method_body(&val, &id, &noex))
+ break;
+ if ((noex & NOEX_PRIVATE))
+ break;
+ if ((noex & NOEX_PROTECTED) &&
+ !rb_obj_is_kind_of(self, rb_class_real(val)))
+ break;
+ }
+ else if (!rb_method_boundp(val, node->nd_mid, call))
+ break;
+ return arg_defined(self, node->nd_args, buf,
+ nd_type(node) == NODE_ATTRASGN ?
+ "assignment" : "method");
}
break;
@@ -1797,22 +2290,13 @@ is_defined(self, node, buf)
break;
case NODE_CONST:
- if (ev_const_defined(RNODE(ruby_frame->cbase), node->nd_vid, self)) {
+ if (ev_const_defined(ruby_cref, node->nd_vid, self)) {
return "constant";
}
break;
case NODE_CVAR:
- if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
- if (rb_cvar_defined(ruby_cbase, node->nd_vid)) {
- return "class variable";
- }
- break;
- }
- self = rb_iv_get(ruby_cbase, "__attached__");
- /* fall through */
- case NODE_CVAR2:
- if (rb_cvar_defined(rb_cvar_singleton(self), node->nd_vid)) {
+ if (rb_cvar_defined(cvar_cbase(), node->nd_vid)) {
return "class variable";
}
break;
@@ -1831,30 +2315,41 @@ is_defined(self, node, buf)
switch (TYPE(val)) {
case T_CLASS:
case T_MODULE:
- if (rb_const_defined_at(val, node->nd_mid))
+ if (rb_const_defined_from(val, node->nd_mid))
return "constant";
+ break;
default:
- if (rb_method_boundp(val, node->nd_mid, 1)) {
+ if (rb_method_boundp(CLASS_OF(val), node->nd_mid, 1)) {
return "method";
}
}
}
break;
+ case NODE_COLON3:
+ if (rb_const_defined_from(rb_cObject, node->nd_mid)) {
+ return "constant";
+ }
+ break;
+
case NODE_NTH_REF:
- if (rb_reg_nth_defined(node->nd_nth, MATCH_DATA)) {
- sprintf(buf, "$%d", node->nd_nth);
+ if (RTEST(rb_reg_nth_defined(node->nd_nth, MATCH_DATA))) {
+ sprintf(buf, "$%d", (int)node->nd_nth);
return buf;
}
break;
case NODE_BACK_REF:
- if (rb_reg_nth_defined(0, MATCH_DATA)) {
- sprintf(buf, "$%c", node->nd_nth);
+ if (RTEST(rb_reg_nth_defined(0, MATCH_DATA))) {
+ sprintf(buf, "$%c", (char)node->nd_nth);
return buf;
}
break;
+ case NODE_NEWLINE:
+ node = node->nd_next;
+ goto again;
+
default:
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
@@ -1875,25 +2370,59 @@ static int handle_rescue _((VALUE,NODE*));
static void blk_free();
static VALUE
-rb_obj_is_block(block)
- VALUE block;
-{
- if (TYPE(block) == T_DATA && RDATA(block)->dfree == (RUBY_DATA_FUNC)blk_free) {
- return Qtrue;
- }
- return Qfalse;
-}
-
-static VALUE
rb_obj_is_proc(proc)
VALUE proc;
{
- if (rb_obj_is_block(proc) && rb_obj_is_kind_of(proc, rb_cProc)) {
+ if (TYPE(proc) == T_DATA && RDATA(proc)->dfree == (RUBY_DATA_FUNC)blk_free) {
return Qtrue;
}
return Qfalse;
}
+/*
+ * call-seq:
+ * set_trace_func(proc) => proc
+ * set_trace_func(nil) => nil
+ *
+ * Establishes _proc_ as the handler for tracing, or disables
+ * tracing if the parameter is +nil+. _proc_ takes up
+ * to six parameters: an event name, a filename, a line number, an
+ * object id, a binding, and the name of a class. _proc_ is
+ * invoked whenever an event occurs. Events are: <code>c-call</code>
+ * (call a C-language routine), <code>c-return</code> (return from a
+ * C-language routine), <code>call</code> (call a Ruby method),
+ * <code>class</code> (start a class or module definition),
+ * <code>end</code> (finish a class or module definition),
+ * <code>line</code> (execute code on a new line), <code>raise</code>
+ * (raise an exception), and <code>return</code> (return from a Ruby
+ * method). Tracing is disabled within the context of _proc_.
+ *
+ * class Test
+ * def test
+ * a = 1
+ * b = 2
+ * end
+ * end
+ *
+ * set_trace_func proc { |event, file, line, id, binding, classname|
+ * printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
+ * }
+ * t = Test.new
+ * t.test
+ *
+ * line prog.rb:11 false
+ * c-call prog.rb:11 new Class
+ * c-call prog.rb:11 initialize Object
+ * c-return prog.rb:11 initialize Object
+ * c-return prog.rb:11 new Class
+ * line prog.rb:12 false
+ * call prog.rb:2 test Test
+ * line prog.rb:3 test Test
+ * line prog.rb:4 test Test
+ * return prog.rb:4 test Test
+ */
+
+
static VALUE
set_trace_func(obj, trace)
VALUE obj, trace;
@@ -1909,23 +2438,26 @@ set_trace_func(obj, trace)
}
static void
-call_trace_func(event, file, line, self, id, klass)
+call_trace_func(event, node, self, id, klass)
char *event;
- char *file;
- int line;
+ NODE *node;
VALUE self;
ID id;
VALUE klass; /* OK */
{
- int state;
+ int state, raised;
struct FRAME *prev;
- char *file_save = ruby_sourcefile;
- int line_save = ruby_sourceline;
+ NODE *node_save;
VALUE srcfile;
if (!trace_func) return;
if (tracing) return;
+ if (ruby_in_compile) return;
+ if (id == ID_ALLOCATOR) return;
+ if (!(node_save = ruby_current_node)) {
+ node_save = NEW_NEWLINE(0);
+ }
tracing = 1;
prev = ruby_frame;
PUSH_FRAME();
@@ -1933,9 +2465,11 @@ call_trace_func(event, file, line, self, id, klass)
ruby_frame->prev = prev;
ruby_frame->iter = 0; /* blocks not available anyway */
- if (file) {
- ruby_frame->line = ruby_sourceline = line;
- ruby_frame->file = ruby_sourcefile = file;
+ if (node) {
+ ruby_current_node = node;
+ ruby_frame->node = node;
+ ruby_sourcefile = node->nd_file;
+ ruby_sourceline = nd_line(node);
}
if (klass) {
if (TYPE(klass) == T_ICLASS) {
@@ -1946,47 +2480,208 @@ call_trace_func(event, file, line, self, id, klass)
}
}
PUSH_TAG(PROT_NONE);
+ raised = thread_reset_raised();
if ((state = EXEC_TAG()) == 0) {
srcfile = rb_str_new2(ruby_sourcefile?ruby_sourcefile:"(ruby)");
- proc_call(trace_func, rb_ary_new3(6, rb_str_new2(event),
- srcfile,
- INT2FIX(ruby_sourceline),
- id?ID2SYM(id):Qnil,
- self?rb_f_binding(self):Qnil,
- klass));
- }
- POP_TMPTAG(); /* do not propagate retval */
+ proc_invoke(trace_func, rb_ary_new3(6, rb_str_new2(event),
+ srcfile,
+ INT2FIX(ruby_sourceline),
+ id?ID2SYM(id):Qnil,
+ self?rb_f_binding(self):Qnil,
+ klass),
+ Qundef, 0);
+ }
+ if (raised) thread_set_raised();
+ POP_TAG();
POP_FRAME();
tracing = 0;
- ruby_sourceline = line_save;
- ruby_sourcefile = file_save;
+ ruby_current_node = node_save;
+ SET_CURRENT_SOURCE();
if (state) JUMP_TAG(state);
}
-static void return_check _((void));
-#define return_value(v) prot_tag->retval = (v)
+static VALUE
+avalue_to_svalue(v)
+ VALUE v;
+{
+ VALUE tmp, top;
+
+ tmp = rb_check_array_type(v);
+ if (NIL_P(tmp)) {
+ return v;
+ }
+ if (RARRAY(tmp)->len == 0) {
+ return Qundef;
+ }
+ if (RARRAY(tmp)->len == 1) {
+ top = rb_check_array_type(RARRAY(tmp)->ptr[0]);
+ if (NIL_P(top)) {
+ return RARRAY(tmp)->ptr[0];
+ }
+ if (RARRAY(top)->len > 1) {
+ return v;
+ }
+ return top;
+ }
+ return tmp;
+}
+
+static VALUE
+svalue_to_avalue(v)
+ VALUE v;
+{
+ VALUE tmp, top;
+
+ if (v == Qundef) return rb_ary_new2(0);
+ tmp = rb_check_array_type(v);
+ if (NIL_P(tmp)) {
+ return rb_ary_new3(1, v);
+ }
+ if (RARRAY(tmp)->len == 1) {
+ top = rb_check_array_type(RARRAY(tmp)->ptr[0]);
+ if (!NIL_P(top) && RARRAY(top)->len > 1) {
+ return v;
+ }
+ return rb_ary_new3(1, v);
+ }
+ return tmp;
+}
+
+static VALUE
+svalue_to_mrhs(v, lhs)
+ VALUE v;
+ NODE *lhs;
+{
+ VALUE tmp;
+
+ if (v == Qundef) return rb_ary_new2(0);
+ tmp = rb_check_array_type(v);
+ if (NIL_P(tmp)) {
+ return rb_ary_new3(1, v);
+ }
+ /* no lhs means splat lhs only */
+ if (!lhs) {
+ return rb_ary_new3(1, v);
+ }
+ return tmp;
+}
+
+static VALUE
+avalue_splat(v)
+ VALUE v;
+{
+ if (RARRAY(v)->len == 0) {
+ return Qundef;
+ }
+ if (RARRAY(v)->len == 1) {
+ return RARRAY(v)->ptr[0];
+ }
+ return v;
+}
+
+#if 1
+VALUE
+rb_Array(val)
+ VALUE val;
+{
+ VALUE tmp = rb_check_array_type(val);
+
+ if (NIL_P(tmp)) {
+ /* hack to avoid invoke Object#to_a */
+ VALUE origin;
+ ID id = rb_intern("to_a");
+
+ if (search_method(CLASS_OF(val), id, &origin) &&
+ RCLASS(origin)->m_tbl != RCLASS(rb_mKernel)->m_tbl) { /* exclude Kernel#to_a */
+ val = rb_funcall(val, id, 0);
+ if (TYPE(val) != T_ARRAY) {
+ rb_raise(rb_eTypeError, "`to_a' did not return Array");
+ }
+ return val;
+ }
+ else {
+ return rb_ary_new3(1, val);
+ }
+ }
+ return tmp;
+}
+#endif
+
+static VALUE
+splat_value(v)
+ VALUE v;
+{
+ if (NIL_P(v)) return rb_ary_new3(1, Qnil);
+ return rb_Array(v);
+}
+
+static VALUE
+class_prefix(self, cpath)
+ VALUE self;
+ NODE *cpath;
+{
+ if (!cpath) {
+ rb_bug("class path missing");
+ }
+ if (cpath->nd_head) {
+ VALUE c = rb_eval(self, cpath->nd_head);
+ switch (TYPE(c)) {
+ case T_CLASS:
+ case T_MODULE:
+ break;
+ default:
+ rb_raise(rb_eTypeError, "%s is not a class/module",
+ RSTRING(rb_obj_as_string(c))->ptr);
+ }
+ return c;
+ }
+ else if (nd_type(cpath) == NODE_COLON2) {
+ return ruby_cbase;
+ }
+ else if (ruby_wrapper) {
+ return ruby_wrapper;
+ }
+ else {
+ return rb_cObject;
+ }
+}
+
+#define return_value(v) do {\
+ if ((prot_tag->retval = (v)) == Qundef) {\
+ prot_tag->retval = Qnil;\
+ }\
+} while (0)
+
+NORETURN(static void return_jump _((VALUE)));
+NORETURN(static void break_jump _((VALUE)));
static VALUE
rb_eval(self, n)
VALUE self;
NODE *n;
{
+ NODE * volatile contnode = 0;
NODE * volatile node = n;
int state;
volatile VALUE result = Qnil;
-#define RETURN(v) { result = (v); goto finish; }
+#define RETURN(v) do { \
+ result = (v); \
+ goto finish; \
+} while (0)
again:
if (!node) RETURN(Qnil);
+ ruby_current_node = node;
switch (nd_type(node)) {
case NODE_BLOCK:
- while (node->nd_next) {
- rb_eval(self, node->nd_head);
- node = node->nd_next;
+ if (contnode) {
+ result = rb_eval(self, node);
+ break;
}
+ contnode = node->nd_next;
node = node->nd_head;
goto again;
@@ -2003,32 +2698,35 @@ rb_eval(self, n)
/* nodes for speed-up(default match) */
case NODE_MATCH:
- result = rb_reg_match2(node->nd_head->nd_lit);
+ result = rb_reg_match2(node->nd_lit);
break;
/* nodes for speed-up(literal match) */
case NODE_MATCH2:
- result = rb_reg_match(rb_eval(self,node->nd_recv),
- rb_eval(self,node->nd_value));
+ {
+ VALUE l = rb_eval(self,node->nd_recv);
+ VALUE r = rb_eval(self,node->nd_value);
+ result = rb_reg_match(l, r);
+ }
break;
/* nodes for speed-up(literal match) */
case NODE_MATCH3:
- {
+ {
VALUE r = rb_eval(self,node->nd_recv);
VALUE l = rb_eval(self,node->nd_value);
- if (TYPE(r) == T_STRING) {
- result = rb_reg_match(l, r);
+ if (TYPE(l) == T_STRING) {
+ result = rb_reg_match(r, l);
}
else {
- result = rb_funcall(r, match, 1, l);
+ result = rb_funcall(l, match, 1, r);
}
}
break;
/* node for speed-up(top-level loop for -n/-p) */
case NODE_OPT_N:
- PUSH_TAG(PROT_NONE);
+ PUSH_TAG(PROT_LOOP);
switch (state = EXEC_TAG()) {
case 0:
opt_n_next:
@@ -2066,7 +2764,11 @@ rb_eval(self, n)
RETURN(Qfalse);
case NODE_IF:
- ruby_sourceline = nd_line(node);
+ if (trace_func) {
+ call_trace_func("line", node, self,
+ ruby_frame->last_func,
+ ruby_frame->last_class);
+ }
if (RTEST(rb_eval(self, node->nd_cond))) {
node = node->nd_body;
}
@@ -2083,17 +2785,15 @@ rb_eval(self, n)
tag = node->nd_head;
while (tag) {
if (trace_func) {
- call_trace_func("line", tag->nd_file, nd_line(tag), self,
+ call_trace_func("line", tag, self,
ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->last_class);
}
- ruby_sourcefile = tag->nd_file;
- ruby_sourceline = nd_line(tag);
- if (nd_type(tag->nd_head) == NODE_WHEN) {
+ if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
VALUE v = rb_eval(self, tag->nd_head->nd_head);
- int i;
+ long i;
- if (TYPE(v) != T_ARRAY) v = rb_Array(v);
+ if (TYPE(v) != T_ARRAY) v = rb_ary_to_ary(v);
for (i=0; i<RARRAY(v)->len; i++) {
if (RTEST(RARRAY(v)->ptr[i])) {
node = node->nd_body;
@@ -2128,17 +2828,15 @@ rb_eval(self, n)
tag = node->nd_head;
while (tag) {
if (trace_func) {
- call_trace_func("line", tag->nd_file, nd_line(tag), self,
+ call_trace_func("line", tag, self,
ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->last_class);
}
- ruby_sourcefile = tag->nd_file;
- ruby_sourceline = nd_line(tag);
- if (nd_type(tag->nd_head) == NODE_WHEN) {
+ if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) {
VALUE v = rb_eval(self, tag->nd_head->nd_head);
- int i;
+ long i;
- if (TYPE(v) != T_ARRAY) v = rb_Array(v);
+ if (TYPE(v) != T_ARRAY) v = rb_ary_to_ary(v);
for (i=0; i<RARRAY(v)->len; i++) {
if (RTEST(rb_funcall2(RARRAY(v)->ptr[i], eqq, 1, &val))){
node = node->nd_body;
@@ -2160,10 +2858,10 @@ rb_eval(self, n)
RETURN(Qnil);
case NODE_WHILE:
- PUSH_TAG(PROT_NONE);
+ PUSH_TAG(PROT_LOOP);
+ result = Qnil;
switch (state = EXEC_TAG()) {
case 0:
- ruby_sourceline = nd_line(node);
if (node->nd_state && !RTEST(rb_eval(self, node->nd_cond)))
goto while_out;
do {
@@ -2181,17 +2879,22 @@ rb_eval(self, n)
state = 0;
goto while_next;
case TAG_BREAK:
- state = 0;
+ if (TAG_DST()) {
+ state = 0;
+ result = prot_tag->retval;
+ }
+ /* fall through */
default:
break;
}
while_out:
POP_TAG();
if (state) JUMP_TAG(state);
- RETURN(Qnil);
+ RETURN(result);
case NODE_UNTIL:
- PUSH_TAG(PROT_NONE);
+ PUSH_TAG(PROT_LOOP);
+ result = Qnil;
switch (state = EXEC_TAG()) {
case 0:
if (node->nd_state && RTEST(rb_eval(self, node->nd_cond)))
@@ -2211,14 +2914,18 @@ rb_eval(self, n)
state = 0;
goto until_next;
case TAG_BREAK:
- state = 0;
+ if (TAG_DST()) {
+ state = 0;
+ result = prot_tag->retval;
+ }
+ /* fall through */
default:
break;
}
until_out:
POP_TAG();
if (state) JUMP_TAG(state);
- RETURN(Qnil);
+ RETURN(result);
case NODE_BLOCK_PASS:
result = block_pass(self, node);
@@ -2227,52 +2934,42 @@ rb_eval(self, n)
case NODE_ITER:
case NODE_FOR:
{
- iter_retry:
- PUSH_TAG(PROT_FUNC);
+ PUSH_TAG(PROT_LOOP);
PUSH_BLOCK(node->nd_var, node->nd_body);
state = EXEC_TAG();
if (state == 0) {
+ iter_retry:
PUSH_ITER(ITER_PRE);
if (nd_type(node) == NODE_ITER) {
result = rb_eval(self, node->nd_iter);
}
else {
VALUE recv;
- char *file = ruby_sourcefile;
- int line = ruby_sourceline;
_block.flags &= ~BLOCK_D_SCOPE;
BEGIN_CALLARGS;
recv = rb_eval(self, node->nd_iter);
END_CALLARGS;
- ruby_sourcefile = file;
- ruby_sourceline = line;
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
result = rb_call(CLASS_OF(recv),recv,each,0,0,0);
}
POP_ITER();
}
- else if (_block.tag->dst == state) {
- state &= TAG_MASK;
- if (state == TAG_RETURN) {
- result = prot_tag->retval;
- }
+ else if (state == TAG_BREAK && TAG_DST()) {
+ result = prot_tag->retval;
+ state = 0;
+ }
+ else if (state == TAG_RETRY) {
+ state = 0;
+ goto iter_retry;
}
POP_BLOCK();
POP_TAG();
switch (state) {
case 0:
break;
-
- case TAG_RETRY:
- goto iter_retry;
-
- case TAG_BREAK:
- result = Qnil;
- break;
- case TAG_RETURN:
- return_value(result);
- /* fall through */
default:
JUMP_TAG(state);
}
@@ -2280,86 +2977,103 @@ rb_eval(self, n)
break;
case NODE_BREAK:
- JUMP_TAG(TAG_BREAK);
+ break_jump(rb_eval(self, node->nd_stts));
break;
case NODE_NEXT:
+ CHECK_INTS;
+ return_value(rb_eval(self, node->nd_stts));
JUMP_TAG(TAG_NEXT);
break;
case NODE_REDO:
+ CHECK_INTS;
JUMP_TAG(TAG_REDO);
break;
case NODE_RETRY:
+ CHECK_INTS;
JUMP_TAG(TAG_RETRY);
break;
- case NODE_RESTARGS:
- result = rb_eval(self, node->nd_head);
- if (TYPE(result) != T_ARRAY) {
- result = rb_Array(result);
- }
+ case NODE_SPLAT:
+ result = splat_value(rb_eval(self, node->nd_head));
+ break;
+
+ case NODE_TO_ARY:
+ result = rb_ary_to_ary(rb_eval(self, node->nd_head));
+ break;
+
+ case NODE_SVALUE:
+ result = avalue_splat(rb_eval(self, node->nd_head));
+ if (result == Qundef) result = Qnil;
break;
case NODE_YIELD:
- if (node->nd_stts) {
- result = rb_eval(self, node->nd_stts);
- if (nd_type(node->nd_stts) == NODE_RESTARGS &&
- RARRAY(result)->len == 1)
- {
- result = RARRAY(result)->ptr[0];
- }
+ if (node->nd_head) {
+ result = rb_eval(self, node->nd_head);
+ ruby_current_node = node;
}
else {
- result = Qnil;
+ result = Qundef; /* no arg */
}
- result = rb_yield_0(result, 0, 0, 0);
+ SET_CURRENT_SOURCE();
+ result = rb_yield_0(result, 0, 0, 0, node->nd_state);
break;
case NODE_RESCUE:
- retry_entry:
- {
+ {
volatile VALUE e_info = ruby_errinfo;
+ volatile int rescuing = 0;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
+ retry_entry:
result = rb_eval(self, node->nd_head);
}
- POP_TAG();
- if (state == TAG_RAISE) {
- NODE * volatile resq = node->nd_resq;
+ else if (rescuing) {
+ if (rescuing < 0) {
+ /* in rescue argument, just reraise */
+ }
+ else if (state == TAG_RETRY) {
+ rescuing = state = 0;
+ ruby_errinfo = e_info;
+ goto retry_entry;
+ }
+ else if (state != TAG_RAISE) {
+ result = prot_tag->retval;
+ }
+ }
+ else if (state == TAG_RAISE) {
+ NODE *resq = node->nd_resq;
- ruby_sourceline = nd_line(node);
+ rescuing = -1;
while (resq) {
+ ruby_current_node = resq;
if (handle_rescue(self, resq)) {
state = 0;
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- result = rb_eval(self, resq->nd_body);
- }
- POP_TAG();
- if (state == TAG_RETRY) {
- state = 0;
- ruby_errinfo = Qnil;
- goto retry_entry;
- }
- if (state != TAG_RAISE) {
- ruby_errinfo = e_info;
- }
+ rescuing = 1;
+ result = rb_eval(self, resq->nd_body);
break;
}
resq = resq->nd_head; /* next rescue */
}
}
- else if (node->nd_else) { /* else clause given */
- if (!state) { /* no exception raised */
- result = rb_eval(self, node->nd_else);
- }
+ else {
+ result = prot_tag->retval;
+ }
+ POP_TAG();
+ if (state != TAG_RAISE) ruby_errinfo = e_info;
+ if (state) {
+ if (state == TAG_NEXT) prot_tag->retval = result;
+ JUMP_TAG(state);
+ }
+ /* no exception raised */
+ if (!rescuing && (node = node->nd_else)) { /* else clause given */
+ goto again;
}
- if (state) JUMP_TAG(state);
}
- break;
+ break;
case NODE_ENSURE:
PUSH_TAG(PROT_NONE);
@@ -2369,9 +3083,11 @@ rb_eval(self, n)
POP_TAG();
if (node->nd_ensr) {
VALUE retval = prot_tag->retval; /* save retval */
+ VALUE errinfo = ruby_errinfo;
rb_eval(self, node->nd_ensr);
return_value(retval);
+ ruby_errinfo = errinfo;
}
if (state) JUMP_TAG(state);
break;
@@ -2411,62 +3127,86 @@ rb_eval(self, n)
break;
case NODE_FLIP2: /* like AWK */
- if (ruby_scope->local_vars == 0) {
- rb_bug("unexpected local variable");
- }
- if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) {
- if (RTEST(rb_eval(self, node->nd_beg))) {
- ruby_scope->local_vars[node->nd_cnt] =
- RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue;
- result = Qtrue;
+ {
+ VALUE *flip = rb_svar(node->nd_cnt);
+ if (!flip) rb_bug("unexpected local variable");
+ if (!RTEST(*flip)) {
+ if (RTEST(rb_eval(self, node->nd_beg))) {
+ *flip = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue;
+ result = Qtrue;
+ }
+ else {
+ result = Qfalse;
+ }
}
else {
- result = Qfalse;
- }
- }
- else {
- if (RTEST(rb_eval(self, node->nd_end))) {
- ruby_scope->local_vars[node->nd_cnt] = Qfalse;
+ if (RTEST(rb_eval(self, node->nd_end))) {
+ *flip = Qfalse;
+ }
+ result = Qtrue;
}
- result = Qtrue;
}
break;
case NODE_FLIP3: /* like SED */
- if (ruby_scope->local_vars == 0) {
- rb_bug("unexpected local variable");
- }
- if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) {
- result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse;
- ruby_scope->local_vars[node->nd_cnt] = result;
- }
- else {
- if (RTEST(rb_eval(self, node->nd_end))) {
- ruby_scope->local_vars[node->nd_cnt] = Qfalse;
+ {
+ VALUE *flip = rb_svar(node->nd_cnt);
+ if (!flip) rb_bug("unexpected local variable");
+ if (!RTEST(*flip)) {
+ result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse;
+ *flip = result;
+ }
+ else {
+ if (RTEST(rb_eval(self, node->nd_end))) {
+ *flip = Qfalse;
+ }
+ result = Qtrue;
}
- result = Qtrue;
}
break;
case NODE_RETURN:
- if (node->nd_stts) {
- return_value(rb_eval(self, node->nd_stts));
- }
- else {
- return_value(Qnil);
- }
- return_check();
- JUMP_TAG(TAG_RETURN);
+ return_jump(rb_eval(self, node->nd_stts));
break;
case NODE_ARGSCAT:
- result = rb_ary_concat(rb_eval(self, node->nd_head),
- rb_eval(self, node->nd_body));
+ {
+ VALUE args = rb_eval(self, node->nd_head);
+ result = rb_ary_concat(args, splat_value(rb_eval(self, node->nd_body)));
+ }
break;
case NODE_ARGSPUSH:
- result = rb_ary_push(rb_obj_dup(rb_eval(self, node->nd_head)),
- rb_eval(self, node->nd_body));
+ {
+ VALUE args = rb_ary_dup(rb_eval(self, node->nd_head));
+ result = rb_ary_push(args, rb_eval(self, node->nd_body));
+ }
+ break;
+
+ case NODE_ATTRASGN:
+ {
+ VALUE recv;
+ int argc; VALUE *argv; /* used in SETUP_ARGS */
+ int scope;
+ TMP_PROTECT;
+
+ BEGIN_CALLARGS;
+ if (node->nd_recv == (NODE *)1) {
+ recv = self;
+ scope = 1;
+ }
+ else {
+ recv = rb_eval(self, node->nd_recv);
+ scope = 0;
+ }
+ SETUP_ARGS(node->nd_args);
+ END_CALLARGS;
+
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
+ rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,scope);
+ result = argv[argc-1];
+ }
break;
case NODE_CALL:
@@ -2480,6 +3220,8 @@ rb_eval(self, n)
SETUP_ARGS(node->nd_args);
END_CALLARGS;
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
}
break;
@@ -2493,11 +3235,14 @@ rb_eval(self, n)
SETUP_ARGS(node->nd_args);
END_CALLARGS;
+ ruby_current_node = node;
+ SET_CURRENT_SOURCE();
result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1);
}
break;
case NODE_VCALL:
+ SET_CURRENT_SOURCE();
result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2);
break;
@@ -2507,9 +3252,15 @@ rb_eval(self, n)
int argc; VALUE *argv; /* used in SETUP_ARGS */
TMP_PROTECT;
- if (ruby_frame->last_class == 0) {
- rb_raise(rb_eNameError, "superclass method `%s' disabled",
- rb_id2name(ruby_frame->last_func));
+ if (ruby_frame->last_class == 0) {
+ if (ruby_frame->orig_func) {
+ rb_name_error(ruby_frame->last_func,
+ "superclass method `%s' disabled",
+ rb_id2name(ruby_frame->orig_func));
+ }
+ else {
+ rb_raise(rb_eNoMethodError, "super called outside of method");
+ }
}
if (nd_type(node) == NODE_ZSUPER) {
argc = ruby_frame->argc;
@@ -2519,13 +3270,11 @@ rb_eval(self, n)
BEGIN_CALLARGS;
SETUP_ARGS(node->nd_args);
END_CALLARGS;
+ ruby_current_node = node;
}
- PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
- result = rb_call(RCLASS(ruby_frame->last_class)->super,
- ruby_frame->self, ruby_frame->last_func,
- argc, argv, 3);
- POP_ITER();
+ SET_CURRENT_SOURCE();
+ result = rb_call_super(argc, argv);
}
break;
@@ -2543,7 +3292,6 @@ rb_eval(self, n)
if (node->nd_rval) {
saved_cref = ruby_cref;
ruby_cref = (NODE*)node->nd_rval;
- ruby_frame->cbase = node->nd_rval;
}
if (node->nd_tbl) {
VALUE *vars = ALLOCA_N(VALUE, node->nd_tbl[0]+1);
@@ -2577,7 +3325,7 @@ rb_eval(self, n)
recv = rb_eval(self, node->nd_recv);
rval = node->nd_args->nd_head;
- SETUP_ARGS(node->nd_args->nd_next);
+ SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen - 1);
val = rb_funcall2(recv, aref, argc-1, argv);
switch (node->nd_mid) {
case 0: /* OR */
@@ -2592,7 +3340,7 @@ rb_eval(self, n)
val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
}
argv[argc-1] = val;
- val = rb_funcall2(recv, aset, argc, argv);
+ rb_funcall2(recv, aset, argc, argv);
result = val;
}
break;
@@ -2630,13 +3378,15 @@ rb_eval(self, n)
goto again;
case NODE_OP_ASGN_OR:
- result = rb_eval(self, node->nd_head);
- if (RTEST(result)) break;
- node = node->nd_value;
- goto again;
+ if ((node->nd_aid && !is_defined(self, node->nd_head, 0)) ||
+ !RTEST(result = rb_eval(self, node->nd_head))) {
+ node = node->nd_value;
+ goto again;
+ }
+ break;
case NODE_MASGN:
- result = massign(self, node, rb_eval(self, node->nd_value),0);
+ result = massign(self, node, rb_eval(self, node->nd_value), 0);
break;
case NODE_LASGN:
@@ -2667,11 +3417,16 @@ rb_eval(self, n)
break;
case NODE_CDECL:
- if (NIL_P(ruby_class)) {
- rb_raise(rb_eTypeError, "no class/module to define constant");
- }
result = rb_eval(self, node->nd_value);
- rb_const_set(ruby_class, node->nd_vid, result);
+ if (node->nd_vid == 0) {
+ rb_const_set(class_prefix(self, node->nd_else), node->nd_else->nd_mid, result);
+ }
+ else {
+ if (NIL_P(ruby_cbase)) {
+ rb_raise(rb_eTypeError, "no class/module to define constant");
+ }
+ rb_const_set(ruby_cbase, node->nd_vid, result);
+ }
break;
case NODE_CVDECL:
@@ -2679,17 +3434,12 @@ rb_eval(self, n)
rb_raise(rb_eTypeError, "no class/module to define class variable");
}
result = rb_eval(self, node->nd_value);
- if (FL_TEST(ruby_cbase, FL_SINGLETON)) {
- rb_cvar_declare(rb_cvar_singleton(rb_iv_get(ruby_cbase, "__attached__")),
- node->nd_vid, result);
- break;
- }
- rb_cvar_declare(ruby_cbase, node->nd_vid, result);
+ rb_cvar_set(cvar_cbase(), node->nd_vid, result, Qtrue);
break;
case NODE_CVASGN:
result = rb_eval(self, node->nd_value);
- rb_cvar_set(rb_cvar_singleton(self), node->nd_vid, result);
+ rb_cvar_set(cvar_cbase(), node->nd_vid, result, Qfalse);
break;
case NODE_LVAR:
@@ -2712,25 +3462,18 @@ rb_eval(self, n)
break;
case NODE_CONST:
- result = ev_const_get(RNODE(ruby_frame->cbase), node->nd_vid, self);
+ result = ev_const_get(ruby_cref, node->nd_vid, self);
break;
- case NODE_CVAR: /* normal method */
- if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
- result = rb_cvar_get(ruby_cbase, node->nd_vid);
- break;
- }
- self = rb_iv_get(ruby_cbase, "__attached__");
- /* fall through */
- case NODE_CVAR2: /* singleton method */
- result = rb_cvar_get(rb_cvar_singleton(self), node->nd_vid);
+ case NODE_CVAR:
+ result = rb_cvar_get(cvar_cbase(), node->nd_vid);
break;
case NODE_BLOCK_ARG:
if (ruby_scope->local_vars == 0)
rb_bug("unexpected block argument");
if (rb_block_given_p()) {
- result = rb_f_lambda();
+ result = rb_block_proc();
ruby_scope->local_vars[node->nd_cnt] = result;
}
else {
@@ -2743,19 +3486,26 @@ rb_eval(self, n)
VALUE klass;
klass = rb_eval(self, node->nd_head);
- switch (TYPE(klass)) {
- case T_CLASS:
- case T_MODULE:
- break;
- default:
- return rb_funcall(klass, node->nd_mid, 0, 0);
+ if (rb_is_const_id(node->nd_mid)) {
+ switch (TYPE(klass)) {
+ case T_CLASS:
+ case T_MODULE:
+ result = rb_const_get_from(klass, node->nd_mid);
+ break;
+ default:
+ rb_raise(rb_eTypeError, "%s is not a class/module",
+ RSTRING(rb_obj_as_string(klass))->ptr);
+ break;
+ }
+ }
+ else {
+ result = rb_funcall(klass, node->nd_mid, 0, 0);
}
- result = rb_const_get(klass, node->nd_mid);
}
break;
case NODE_COLON3:
- result = rb_const_get_at(rb_cObject, node->nd_mid);
+ result = rb_const_get_from(rb_cObject, node->nd_mid);
break;
case NODE_NTH_REF:
@@ -2808,7 +3558,7 @@ rb_eval(self, n)
case NODE_ARRAY:
{
VALUE ary;
- int i;
+ long i;
i = node->nd_alen;
ary = rb_ary_new2(i);
@@ -2825,10 +3575,15 @@ rb_eval(self, n)
result = rb_str_new3(node->nd_lit);
break;
+ case NODE_EVSTR:
+ result = rb_obj_as_string(rb_eval(self, node->nd_body));
+ break;
+
case NODE_DSTR:
case NODE_DXSTR:
case NODE_DREGX:
case NODE_DREGX_ONCE:
+ case NODE_DSYM:
{
VALUE str, str2;
NODE *list = node->nd_next;
@@ -2840,23 +3595,8 @@ rb_eval(self, n)
case NODE_STR:
str2 = list->nd_head->nd_lit;
break;
- case NODE_EVSTR:
- result = ruby_errinfo;
- ruby_errinfo = Qnil;
- ruby_sourceline = nd_line(node);
- ruby_in_eval++;
- list->nd_head = compile(list->nd_head->nd_lit,
- ruby_sourcefile,
- ruby_sourceline);
- ruby_eval_tree = 0;
- ruby_in_eval--;
- if (ruby_nerrs > 0) {
- compile_error("string expansion");
- }
- if (!NIL_P(result)) ruby_errinfo = result;
- /* fall through */
default:
- str2 = rb_obj_as_string(rb_eval(self, list->nd_head));
+ str2 = rb_eval(self, list->nd_head);
break;
}
rb_str_append(str, str2);
@@ -2867,17 +3607,23 @@ rb_eval(self, n)
switch (nd_type(node)) {
case NODE_DREGX:
result = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
- node->nd_cflag);
+ node->nd_cflag);
break;
case NODE_DREGX_ONCE: /* regexp expand once */
result = rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len,
- node->nd_cflag);
+ node->nd_cflag);
nd_set_type(node, NODE_LIT);
node->nd_lit = result;
break;
+ case NODE_LIT:
+ /* other thread may replace NODE_DREGX_ONCE to NODE_LIT */
+ goto again;
case NODE_DXSTR:
result = rb_funcall(self, '`', 1, str);
break;
+ case NODE_DSYM:
+ result = rb_str_intern(str);
+ break;
default:
result = str;
break;
@@ -2886,7 +3632,7 @@ rb_eval(self, n)
break;
case NODE_XSTR:
- result = rb_funcall(self, '`', 1, node->nd_lit);
+ result = rb_funcall(self, '`', 1, rb_str_new3(node->nd_lit));
break;
case NODE_LIT:
@@ -2895,7 +3641,7 @@ rb_eval(self, n)
case NODE_ATTRSET:
if (ruby_frame->argc != 1)
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
ruby_frame->argc);
result = rb_ivar_set(self, node->nd_vid, ruby_frame->argv[0]);
break;
@@ -2907,7 +3653,7 @@ rb_eval(self, n)
int noex;
if (NIL_P(ruby_class)) {
- rb_raise(rb_eTypeError, "no class to add method");
+ rb_raise(rb_eTypeError, "no class/module to add method");
}
if (ruby_class == rb_cObject && node->nd_mid == init) {
rb_warn("redefining Object#initialize may cause infinite loop");
@@ -2919,13 +3665,8 @@ rb_eval(self, n)
rb_frozen_class_p(ruby_class);
body = search_method(ruby_class, node->nd_mid, &origin);
if (body){
- if (RTEST(ruby_verbose) && ruby_class == origin && body->nd_cnt == 0) {
- rb_warning("discarding old %s", rb_id2name(node->nd_mid));
- }
- if (node->nd_noex) { /* toplevel */
- /* should upgrade to rb_warn() if no super was called inside? */
- rb_warning("overriding global function `%s'",
- rb_id2name(node->nd_mid));
+ if (RTEST(ruby_verbose) && ruby_class == origin && body->nd_cnt == 0 && body->nd_body) {
+ rb_warning("method redefined; discarding old %s", rb_id2name(node->nd_mid));
}
}
@@ -2935,30 +3676,18 @@ rb_eval(self, n)
else if (SCOPE_TEST(SCOPE_PROTECTED)) {
noex = NOEX_PROTECTED;
}
- else if (ruby_class == rb_cObject) {
- noex = node->nd_noex;
- }
else {
noex = NOEX_PUBLIC;
}
- if (body && origin == ruby_class && body->nd_noex & NOEX_UNDEF) {
- noex |= NOEX_UNDEF;
+ if (body && origin == ruby_class && body->nd_body == 0) {
+ noex |= NOEX_NOSUPER;
}
defn = copy_node_scope(node->nd_defn, ruby_cref);
rb_add_method(ruby_class, node->nd_mid, defn, noex);
- rb_clear_cache_by_id(node->nd_mid);
if (scope_vmode == SCOPE_MODFUNC) {
rb_add_method(rb_singleton_class(ruby_class),
node->nd_mid, defn, NOEX_PUBLIC);
- rb_funcall(ruby_class, singleton_added, 1, ID2SYM(node->nd_mid));
- }
- if (FL_TEST(ruby_class, FL_SINGLETON)) {
- rb_funcall(rb_iv_get(ruby_class, "__attached__"),
- singleton_added, 1, ID2SYM(node->nd_mid));
- }
- else {
- rb_funcall(ruby_class, added, 1, ID2SYM(node->nd_mid));
}
result = Qnil;
}
@@ -2970,20 +3699,20 @@ rb_eval(self, n)
VALUE klass;
NODE *body = 0, *defn;
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(recv)) {
- rb_raise(rb_eSecurityError, "Insecure; can't define singleton method");
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(recv)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't define singleton method");
}
if (FIXNUM_P(recv) || SYMBOL_P(recv)) {
rb_raise(rb_eTypeError,
"can't define singleton method \"%s\" for %s",
rb_id2name(node->nd_mid),
- rb_class2name(CLASS_OF(recv)));
+ rb_obj_classname(recv));
}
if (OBJ_FROZEN(recv)) rb_error_frozen("object");
klass = rb_singleton_class(recv);
- if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, &body)) {
- if (rb_safe_level() >= 4) {
+ if (st_lookup(RCLASS(klass)->m_tbl, node->nd_mid, (st_data_t *)&body)) {
+ if (ruby_safe_level >= 4) {
rb_raise(rb_eSecurityError, "redefining method prohibited");
}
if (RTEST(ruby_verbose)) {
@@ -2991,11 +3720,8 @@ rb_eval(self, n)
}
}
defn = copy_node_scope(node->nd_defn, ruby_cref);
- defn->nd_rval = (VALUE)ruby_cref;
- rb_add_method(klass, node->nd_mid, defn,
+ rb_add_method(klass, node->nd_mid, defn,
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
- rb_clear_cache_by_id(node->nd_mid);
- rb_funcall(recv, singleton_added, 1, ID2SYM(node->nd_mid));
result = Qnil;
}
break;
@@ -3013,7 +3739,6 @@ rb_eval(self, n)
rb_raise(rb_eTypeError, "no class to make alias");
}
rb_alias(ruby_class, node->nd_new, node->nd_old);
- rb_funcall(ruby_class, added, 1, ID2SYM(node->nd_mid));
result = Qnil;
break;
@@ -3024,98 +3749,91 @@ rb_eval(self, n)
case NODE_CLASS:
{
- VALUE super, klass, tmp;
+ VALUE super, klass, tmp, cbase;
+ ID cname;
+ int gen = Qfalse;
- if (NIL_P(ruby_class)) {
+ cbase = class_prefix(self, node->nd_cpath);
+ cname = node->nd_cpath->nd_mid;
+
+ if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no outer class/module");
}
if (node->nd_super) {
- super = superclass(self, node->nd_super);
+ super = rb_eval(self, node->nd_super);
+ rb_check_inheritable(super);
}
else {
super = 0;
}
- klass = 0;
- if ((ruby_class == rb_cObject) && rb_autoload_defined(node->nd_cname)) {
- rb_autoload_load(node->nd_cname);
- }
- if (rb_const_defined_at(ruby_class, node->nd_cname)) {
- klass = rb_const_get(ruby_class, node->nd_cname);
- }
- if (klass) {
+ if (rb_const_defined_at(cbase, cname)) {
+ klass = rb_const_get_at(cbase, cname);
if (TYPE(klass) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class",
- rb_id2name(node->nd_cname));
+ rb_id2name(cname));
}
if (super) {
- tmp = RCLASS(klass)->super;
- if (FL_TEST(tmp, FL_SINGLETON)) {
- tmp = RCLASS(tmp)->super;
- }
- while (TYPE(tmp) == T_ICLASS) {
- tmp = RCLASS(tmp)->super;
- }
+ tmp = rb_class_real(RCLASS(klass)->super);
if (tmp != super) {
- super = tmp;
- goto override_class;
+ rb_raise(rb_eTypeError, "superclass mismatch for class %s",
+ rb_id2name(cname));
}
+ super = 0;
}
- if (rb_safe_level() >= 4) {
+ if (ruby_safe_level >= 4) {
rb_raise(rb_eSecurityError, "extending class prohibited");
}
- rb_clear_cache();
}
else {
- override_class:
if (!super) super = rb_cObject;
- klass = rb_define_class_id(node->nd_cname, super);
- rb_const_set(ruby_class, node->nd_cname, klass);
- rb_set_class_path(klass,ruby_class,rb_id2name(node->nd_cname));
+ klass = rb_define_class_id(cname, super);
+ rb_set_class_path(klass, cbase, rb_id2name(cname));
+ rb_const_set(cbase, cname, klass);
+ gen = Qtrue;
}
if (ruby_wrapper) {
rb_extend_object(klass, ruby_wrapper);
rb_include_module(klass, ruby_wrapper);
}
-
- result = module_setup(klass, node->nd_body);
+ if (super && gen) {
+ rb_class_inherited(super, klass);
+ }
+ result = module_setup(klass, node);
}
break;
case NODE_MODULE:
{
- VALUE module;
+ VALUE module, cbase;
+ ID cname;
- if (NIL_P(ruby_class)) {
+ if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no outer class/module");
}
- module = 0;
- if ((ruby_class == rb_cObject) && rb_autoload_defined(node->nd_cname)) {
- rb_autoload_load(node->nd_cname);
- }
- if (rb_const_defined_at(ruby_class, node->nd_cname)) {
- module = rb_const_get(ruby_class, node->nd_cname);
- }
- if (module) {
+ cbase = class_prefix(self, node->nd_cpath);
+ cname = node->nd_cpath->nd_mid;
+ if (rb_const_defined_at(cbase, cname)) {
+ module = rb_const_get_at(cbase, cname);
if (TYPE(module) != T_MODULE) {
rb_raise(rb_eTypeError, "%s is not a module",
- rb_id2name(node->nd_cname));
+ rb_id2name(cname));
}
- if (rb_safe_level() >= 4) {
+ if (ruby_safe_level >= 4) {
rb_raise(rb_eSecurityError, "extending module prohibited");
}
}
else {
- module = rb_define_module_id(node->nd_cname);
- rb_const_set(ruby_class, node->nd_cname, module);
- rb_set_class_path(module,ruby_class,rb_id2name(node->nd_cname));
+ module = rb_define_module_id(cname);
+ rb_set_class_path(module, cbase, rb_id2name(cname));
+ rb_const_set(cbase, cname, module);
}
if (ruby_wrapper) {
rb_extend_object(module, ruby_wrapper);
rb_include_module(module, ruby_wrapper);
}
- result = module_setup(module, node->nd_body);
+ result = module_setup(module, node);
}
break;
@@ -3123,24 +3841,21 @@ rb_eval(self, n)
{
VALUE klass;
- klass = rb_eval(self, node->nd_recv);
- if (rb_special_const_p(klass)) {
+ result = rb_eval(self, node->nd_recv);
+ if (FIXNUM_P(result) || SYMBOL_P(result)) {
rb_raise(rb_eTypeError, "no virtual class for %s",
- rb_class2name(CLASS_OF(klass)));
+ rb_obj_classname(result));
}
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass))
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(result))
rb_raise(rb_eSecurityError, "Insecure: can't extend object");
- if (FL_TEST(CLASS_OF(klass), FL_SINGLETON)) {
- rb_clear_cache();
- }
- klass = rb_singleton_class(klass);
-
+ klass = rb_singleton_class(result);
+
if (ruby_wrapper) {
rb_extend_object(klass, ruby_wrapper);
rb_include_module(klass, ruby_wrapper);
}
-
- result = module_setup(klass, node->nd_body);
+
+ result = module_setup(klass, node);
}
break;
@@ -3154,13 +3869,11 @@ rb_eval(self, n)
}
break;
- case NODE_NEWLINE:
- ruby_sourcefile = node->nd_file;
- ruby_sourceline = node->nd_nth;
+ case NODE_NEWLINE:
if (trace_func) {
- call_trace_func("line", ruby_sourcefile, ruby_sourceline, self,
+ call_trace_func("line", node, self,
ruby_frame->last_func,
- ruby_frame->last_class);
+ ruby_frame->last_class);
}
node = node->nd_next;
goto again;
@@ -3170,6 +3883,11 @@ rb_eval(self, n)
}
finish:
CHECK_INTS;
+ if (contnode) {
+ node = contnode;
+ contnode = 0;
+ goto again;
+ }
return result;
}
@@ -3178,20 +3896,17 @@ module_setup(module, n)
VALUE module;
NODE *n;
{
- NODE * volatile node = n;
+ NODE * volatile node = n->nd_body;
int state;
struct FRAME frame;
- VALUE result; /* OK */
- char *file = ruby_sourcefile;
- int line = ruby_sourceline;
+ VALUE result = Qnil; /* OK */
TMP_PROTECT;
frame = *ruby_frame;
frame.tmp = ruby_frame;
ruby_frame = &frame;
- PUSH_CLASS();
- ruby_class = module;
+ PUSH_CLASS(module);
PUSH_SCOPE();
PUSH_VARS();
@@ -3208,15 +3923,12 @@ module_setup(module, n)
}
PUSH_CREF(module);
- ruby_frame->cbase = (VALUE)ruby_cref;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
if (trace_func) {
- call_trace_func("class", file, line, ruby_class,
- ruby_frame->last_func,
- ruby_frame->last_class);
+ call_trace_func("class", n, ruby_cbase, ruby_frame->last_func, ruby_frame->last_class);
}
- result = rb_eval(ruby_class, node->nd_next);
+ result = rb_eval(ruby_cbase, node->nd_next);
}
POP_TAG();
POP_CREF();
@@ -3226,8 +3938,7 @@ module_setup(module, n)
ruby_frame = frame.tmp;
if (trace_func) {
- call_trace_func("end", file, line, 0,
- ruby_frame->last_func, ruby_frame->last_class);
+ call_trace_func("end", n, 0, ruby_frame->last_func, ruby_frame->last_class);
}
if (state) JUMP_TAG(state);
@@ -3245,6 +3956,15 @@ rb_respond_to(obj, id)
return Qfalse;
}
+/*
+ * call-seq:
+ * obj.respond_to?(symbol, include_private=false) => true or false
+ *
+ * Returns +true+> if _obj_ responds to the given
+ * method. Private methods are included in the search only if the
+ * optional second parameter evaluates to +true+.
+ */
+
static VALUE
rb_obj_respond_to(argc, argv, obj)
int argc;
@@ -3262,76 +3982,296 @@ rb_obj_respond_to(argc, argv, obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * mod.method_defined?(symbol) => true or false
+ *
+ * Returns +true+ if the named method is defined by
+ * _mod_ (or its included modules and, if _mod_ is a class,
+ * its ancestors). Public and protected methods are matched.
+ *
+ * module A
+ * def method1() end
+ * end
+ * class B
+ * def method2() end
+ * end
+ * class C < B
+ * include A
+ * def method3() end
+ * end
+ *
+ * A.method_defined? :method1 #=> true
+ * C.method_defined? "method1" #=> true
+ * C.method_defined? "method2" #=> true
+ * C.method_defined? "method3" #=> true
+ * C.method_defined? "method4" #=> false
+ */
+
static VALUE
rb_mod_method_defined(mod, mid)
VALUE mod, mid;
{
- if (rb_method_boundp(mod, rb_to_id(mid), 1)) {
- return Qtrue;
+ return rb_method_boundp(mod, rb_to_id(mid), 1);
+}
+
+#define VISI_CHECK(x,f) (((x)&NOEX_MASK) == (f))
+
+/*
+ * call-seq:
+ * mod.public_method_defined?(symbol) => true or false
+ *
+ * Returns +true+ if the named public method is defined by
+ * _mod_ (or its included modules and, if _mod_ is a class,
+ * its ancestors).
+ *
+ * module A
+ * def method1() end
+ * end
+ * class B
+ * protected
+ * def method2() end
+ * end
+ * class C < B
+ * include A
+ * def method3() end
+ * end
+ *
+ * A.method_defined? :method1 #=> true
+ * C.public_method_defined? "method1" #=> true
+ * C.public_method_defined? "method2" #=> false
+ * C.method_defined? "method2" #=> true
+ */
+
+static VALUE
+rb_mod_public_method_defined(mod, mid)
+ VALUE mod, mid;
+{
+ ID id = rb_to_id(mid);
+ int noex;
+
+ if (rb_get_method_body(&mod, &id, &noex)) {
+ if (VISI_CHECK(noex, NOEX_PUBLIC))
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * mod.private_method_defined?(symbol) => true or false
+ *
+ * Returns +true+ if the named private method is defined by
+ * _ mod_ (or its included modules and, if _mod_ is a class,
+ * its ancestors).
+ *
+ * module A
+ * def method1() end
+ * end
+ * class B
+ * private
+ * def method2() end
+ * end
+ * class C < B
+ * include A
+ * def method3() end
+ * end
+ *
+ * A.method_defined? :method1 #=> true
+ * C.private_method_defined? "method1" #=> false
+ * C.private_method_defined? "method2" #=> true
+ * C.method_defined? "method2" #=> false
+ */
+
+static VALUE
+rb_mod_private_method_defined(mod, mid)
+ VALUE mod, mid;
+{
+ ID id = rb_to_id(mid);
+ int noex;
+
+ if (rb_get_method_body(&mod, &id, &noex)) {
+ if (VISI_CHECK(noex, NOEX_PRIVATE))
+ return Qtrue;
}
return Qfalse;
}
+/*
+ * call-seq:
+ * mod.protected_method_defined?(symbol) => true or false
+ *
+ * Returns +true+ if the named protected method is defined
+ * by _mod_ (or its included modules and, if _mod_ is a
+ * class, its ancestors).
+ *
+ * module A
+ * def method1() end
+ * end
+ * class B
+ * protected
+ * def method2() end
+ * end
+ * class C < B
+ * include A
+ * def method3() end
+ * end
+ *
+ * A.method_defined? :method1 #=> true
+ * C.protected_method_defined? "method1" #=> false
+ * C.protected_method_defined? "method2" #=> true
+ * C.method_defined? "method2" #=> true
+ */
+
+static VALUE
+rb_mod_protected_method_defined(mod, mid)
+ VALUE mod, mid;
+{
+ ID id = rb_to_id(mid);
+ int noex;
+
+ if (rb_get_method_body(&mod, &id, &noex)) {
+ if (VISI_CHECK(noex, NOEX_PROTECTED))
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+NORETURN(static VALUE terminate_process _((int, const char *, long)));
+static VALUE
+terminate_process(status, mesg, mlen)
+ int status;
+ const char *mesg;
+ long mlen;
+{
+ VALUE args[2];
+ args[0] = INT2NUM(status);
+ args[1] = rb_str_new(mesg, mlen);
+
+ rb_exc_raise(rb_class_new_instance(2, args, rb_eSystemExit));
+}
+
void
rb_exit(status)
int status;
{
if (prot_tag) {
- VALUE exit;
-
- exit_status = status;
- exit = rb_exc_new(rb_eSystemExit, 0, 0);
- rb_iv_set(exit, "status", INT2NUM(status));
- rb_exc_raise(exit);
+ terminate_process(status, "exit", 4);
}
ruby_finalize();
exit(status);
}
-static VALUE
-rb_f_exit(argc, argv, obj)
+
+/*
+ * call-seq:
+ * exit(integer=0)
+ * Kernel::exit(integer=0)
+ * Process::exit(integer=0)
+ *
+ * Initiates the termination of the Ruby script by raising the
+ * <code>SystemExit</code> exception. This exception may be caught. The
+ * optional parameter is used to return a status code to the invoking
+ * environment.
+ *
+ * begin
+ * exit
+ * puts "never get here"
+ * rescue SystemExit
+ * puts "rescued a SystemExit exception"
+ * end
+ * puts "after begin block"
+ *
+ * <em>produces:</em>
+ *
+ * rescued a SystemExit exception
+ * after begin block
+ *
+ * Just prior to termination, Ruby executes any <code>at_exit</code> functions
+ * (see Kernel::at_exit) and runs any object finalizers (see
+ * ObjectSpace::define_finalizer).
+ *
+ * at_exit { puts "at_exit function" }
+ * ObjectSpace.define_finalizer("string", proc { puts "in finalizer" })
+ * exit
+ *
+ * <em>produces:</em>
+ *
+ * at_exit function
+ * in finalizer
+ */
+
+VALUE
+rb_f_exit(argc, argv)
int argc;
VALUE *argv;
- VALUE obj;
{
VALUE status;
int istatus;
rb_secure(4);
if (rb_scan_args(argc, argv, "01", &status) == 1) {
- istatus = NUM2INT(status);
+ switch (status) {
+ case Qtrue:
+ istatus = EXIT_SUCCESS;
+ break;
+ case Qfalse:
+ istatus = EXIT_FAILURE;
+ break;
+ default:
+ istatus = NUM2INT(status);
+ break;
+ }
}
else {
- istatus = 0;
+ istatus = EXIT_SUCCESS;
}
rb_exit(istatus);
return Qnil; /* not reached */
}
-static void
-rb_abort()
-{
- if (!NIL_P(ruby_errinfo)) {
- error_print();
- }
- rb_exit(1);
-}
-static VALUE
-rb_f_abort()
+/*
+ * call-seq:
+ * abort
+ * Kernel::abort
+ * Process::abort
+ *
+ * Terminate execution immediately, effectively by calling
+ * <code>Kernel.exit(1)</code>. If _msg_ is given, it is written
+ * to STDERR prior to terminating.
+ */
+
+VALUE
+rb_f_abort(argc, argv)
+ int argc;
+ VALUE *argv;
{
rb_secure(4);
- rb_abort();
+ if (argc == 0) {
+ if (!NIL_P(ruby_errinfo)) {
+ error_print();
+ }
+ rb_exit(EXIT_FAILURE);
+ }
+ else {
+ VALUE mesg;
+
+ rb_scan_args(argc, argv, "1", &mesg);
+ StringValue(argv[0]);
+ rb_io_puts(argc, argv, rb_stderr);
+ terminate_process(EXIT_FAILURE, RSTRING(argv[0])->ptr, RSTRING(argv[0])->len);
+ }
return Qnil; /* not reached */
}
void
rb_iter_break()
{
- JUMP_TAG(TAG_BREAK);
+ break_jump(Qnil);
}
-static void rb_longjmp _((int, VALUE)) NORETURN;
+NORETURN(static void rb_longjmp _((int, VALUE)));
static VALUE make_backtrace _((void));
static void
@@ -3341,11 +4281,16 @@ rb_longjmp(tag, mesg)
{
VALUE at;
+ if (thread_set_raised()) {
+ ruby_errinfo = exception_error;
+ JUMP_TAG(TAG_FATAL);
+ }
if (NIL_P(mesg)) mesg = ruby_errinfo;
if (NIL_P(mesg)) {
mesg = rb_exc_new(rb_eRuntimeError, 0, 0);
}
+ ruby_set_current_source();
if (ruby_sourcefile && !NIL_P(mesg)) {
at = get_backtrace(mesg);
if (NIL_P(at)) {
@@ -3359,15 +4304,30 @@ rb_longjmp(tag, mesg)
if (RTEST(ruby_debug) && !NIL_P(ruby_errinfo)
&& !rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
- fprintf(stderr, "Exception `%s' at %s:%d - %s\n",
- rb_class2name(CLASS_OF(ruby_errinfo)),
- ruby_sourcefile, ruby_sourceline,
- STR2CSTR(ruby_errinfo));
+ VALUE e = ruby_errinfo;
+ int status;
+
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ StringValue(e);
+ warn_printf("Exception `%s' at %s:%d - %s\n",
+ rb_obj_classname(ruby_errinfo),
+ ruby_sourcefile, ruby_sourceline,
+ RSTRING(e)->ptr);
+ }
+ POP_TAG();
+ if (status == TAG_FATAL && ruby_errinfo == exception_error) {
+ ruby_errinfo = mesg;
+ }
+ else if (status) {
+ thread_reset_raised();
+ JUMP_TAG(status);
+ }
}
rb_trap_restore_mask();
if (trace_func && tag != TAG_FATAL) {
- call_trace_func("raise", ruby_sourcefile, ruby_sourceline,
+ call_trace_func("raise", ruby_current_node,
ruby_frame->self,
ruby_frame->last_func,
ruby_frame->last_class);
@@ -3375,6 +4335,7 @@ rb_longjmp(tag, mesg)
if (!prot_tag) {
error_print();
}
+ thread_reset_raised();
JUMP_TAG(tag);
}
@@ -3398,11 +4359,44 @@ rb_interrupt()
rb_raise(rb_eInterrupt, "");
}
+/*
+ * call-seq:
+ * raise
+ * raise(string)
+ * raise(exception [, string [, array]])
+ * fail
+ * fail(string)
+ * fail(exception [, string [, array]])
+ *
+ * With no arguments, raises the exception in <code>$!</code> or raises
+ * a <code>RuntimeError</code> if <code>$!</code> is +nil+.
+ * With a single +String+ argument, raises a
+ * +RuntimeError+ with the string as a message. Otherwise,
+ * the first parameter should be the name of an +Exception+
+ * class (or an object that returns an +Exception+ object when sent
+ * an +exception+ message). The optional second parameter sets the
+ * message associated with the exception, and the third parameter is an
+ * array of callback information. Exceptions are caught by the
+ * +rescue+ clause of <code>begin...end</code> blocks.
+ *
+ * raise "Failed to create socket"
+ * raise ArgumentError, "No parameters", caller
+ */
+
static VALUE
rb_f_raise(argc, argv)
int argc;
VALUE *argv;
{
+ rb_raise_jump(rb_make_exception(argc, argv));
+ return Qnil; /* not reached */
+}
+
+static VALUE
+rb_make_exception(argc, argv)
+ int argc;
+ VALUE *argv;
+{
VALUE mesg;
ID exception;
int n;
@@ -3432,15 +4426,23 @@ rb_f_raise(argc, argv)
mesg = rb_funcall(argv[0], exception, n, argv[1]);
break;
default:
- rb_raise(rb_eArgError, "wrong # of arguments");
+ rb_raise(rb_eArgError, "wrong number of arguments");
break;
}
if (argc > 0) {
if (!rb_obj_is_kind_of(mesg, rb_eException))
rb_raise(rb_eTypeError, "exception object expected");
- set_backtrace(mesg, (argc>2)?argv[2]:Qnil);
+ if (argc>2)
+ set_backtrace(mesg, argv[2]);
}
+ return mesg;
+}
+
+static void
+rb_raise_jump(mesg)
+ VALUE mesg;
+{
if (ruby_frame != top_frame) {
PUSH_FRAME(); /* fake frame */
*ruby_frame = *_frame.prev->prev;
@@ -3448,8 +4450,6 @@ rb_f_raise(argc, argv)
POP_FRAME();
}
rb_longjmp(TAG_RAISE, mesg);
-
- return Qnil; /* not reached */
}
void
@@ -3462,7 +4462,8 @@ rb_jump_tag(tag)
int
rb_block_given_p()
{
- if (ruby_frame->iter) return Qtrue;
+ if (ruby_frame->iter == ITER_CUR && ruby_block)
+ return Qtrue;
return Qfalse;
}
@@ -3472,38 +4473,151 @@ rb_iterator_p()
return rb_block_given_p();
}
+/*
+ * call-seq:
+ * block_given? => true or false
+ * iterator? => true or false
+ *
+ * Returns <code>true</code> if <code>yield</code> would execute a
+ * block in the current context. The <code>iterator?</code> form
+ * is mildly deprecated.
+ *
+ * def try
+ * if block_given?
+ * yield
+ * else
+ * "no block"
+ * end
+ * end
+ * try #=> "no block"
+ * try { "hello" } #=> "hello"
+ * try do "hello" end #=> "hello"
+ */
+
+
static VALUE
rb_f_block_given_p()
{
- if (ruby_frame->prev && ruby_frame->prev->iter) return Qtrue;
+ if (ruby_frame->prev && ruby_frame->prev->iter == ITER_CUR && ruby_block)
+ return Qtrue;
return Qfalse;
}
+static VALUE rb_eThreadError;
+
+NORETURN(static void proc_jump_error(int, VALUE));
+static void
+proc_jump_error(state, result)
+ int state;
+ VALUE result;
+{
+ char mesg[32];
+ char *statement;
+
+ switch (state) {
+ case TAG_BREAK:
+ statement = "break"; break;
+ case TAG_RETURN:
+ statement = "return"; break;
+ case TAG_RETRY:
+ statement = "retry"; break;
+ default:
+ statement = "local-jump"; break; /* should not happen */
+ }
+ snprintf(mesg, sizeof mesg, "%s from proc-closure", statement);
+ localjump_error(mesg, result, state);
+}
+
+static void
+return_jump(retval)
+ VALUE retval;
+{
+ struct tag *tt = prot_tag;
+ int yield = Qfalse;
+
+ if (retval == Qundef) retval = Qnil;
+ while (tt) {
+ if (tt->tag == PROT_YIELD) {
+ yield = Qtrue;
+ tt = tt->prev;
+ }
+ if (tt->tag == PROT_FUNC && tt->frame->uniq == ruby_frame->uniq) {
+ tt->dst = (VALUE)ruby_frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_RETURN);
+ }
+ if (tt->tag == PROT_LAMBDA && !yield) {
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_RETURN);
+ }
+ if (tt->tag == PROT_THREAD) {
+ rb_raise(rb_eThreadError, "return can't jump across threads");
+ }
+ tt = tt->prev;
+ }
+ localjump_error("unexpected return", retval, TAG_RETURN);
+}
+
+static void
+break_jump(retval)
+ VALUE retval;
+{
+ struct tag *tt = prot_tag;
+
+ if (retval == Qundef) retval = Qnil;
+ while (tt) {
+ switch (tt->tag) {
+ case PROT_THREAD:
+ case PROT_YIELD:
+ case PROT_LOOP:
+ case PROT_LAMBDA:
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = retval;
+ JUMP_TAG(TAG_BREAK);
+ break;
+ default:
+ break;
+ }
+ tt = tt->prev;
+ }
+ localjump_error("unexpected break", retval, TAG_BREAK);
+}
+
static VALUE
-rb_yield_0(val, self, klass, acheck)
+rb_yield_0(val, self, klass, flags, avalue)
VALUE val, self, klass; /* OK */
- int acheck;
+ int flags, avalue;
{
NODE *node;
volatile VALUE result = Qnil;
- struct BLOCK *block;
- struct SCOPE *old_scope;
+ volatile VALUE old_cref;
+ volatile VALUE old_wrapper;
+ struct BLOCK * volatile block;
+ struct SCOPE * volatile old_scope;
+ int old_vmode;
struct FRAME frame;
+ NODE *cnode = ruby_current_node;
+ int lambda = flags & YIELD_LAMBDA_CALL;
int state;
- static unsigned serial = 1;
- if (!(rb_block_given_p() || rb_f_block_given_p()) || !ruby_block) {
- rb_raise(rb_eLocalJumpError, "yield called out of block");
+ if (!rb_block_given_p()) {
+ localjump_error("no block given", Qnil, 0);
}
PUSH_VARS();
- PUSH_CLASS();
block = ruby_block;
frame = block->frame;
frame.prev = ruby_frame;
ruby_frame = &(frame);
+ old_cref = (VALUE)ruby_cref;
+ ruby_cref = block->cref;
+ old_wrapper = ruby_wrapper;
+ ruby_wrapper = block->wrapper;
old_scope = ruby_scope;
ruby_scope = block->scope;
+ old_vmode = scope_vmode;
+ scope_vmode = (flags & YIELD_PUBLIC_DEF) ? SCOPE_PUBLIC : block->vmode;
ruby_block = block->prev;
if (block->flags & BLOCK_D_SCOPE) {
/* put place holder for dynamic (in-block) local variables */
@@ -3513,46 +4627,87 @@ rb_yield_0(val, self, klass, acheck)
/* FOR does not introduce new scope */
ruby_dyna_vars = block->dyna_vars;
}
- ruby_class = klass?klass:block->klass;
- if (!klass) self = block->self;
+ PUSH_CLASS(klass ? klass : block->klass);
+ if (!klass) {
+ self = block->self;
+ }
node = block->body;
if (block->var) {
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- if (block->var == (NODE*)1) {
- if (acheck && val != Qundef &&
- TYPE(val) == T_ARRAY && RARRAY(val)->len != 0) {
- rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)",
+ if (block->var == (NODE*)1) { /* no parameter || */
+ if (lambda && RARRAY(val)->len != 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
RARRAY(val)->len);
}
}
+ else if (block->var == (NODE*)2) {
+ if (TYPE(val) == T_ARRAY && RARRAY(val)->len != 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
+ RARRAY(val)->len);
+ }
+ }
+ else if (nd_type(block->var) == NODE_MASGN) {
+ if (!avalue) {
+ val = svalue_to_mrhs(val, block->var->nd_head);
+ }
+ massign(self, block->var, val, lambda);
+ }
else {
- if (nd_type(block->var) == NODE_MASGN)
- massign(self, block->var, val, acheck);
- else {
- /* argument adjust for proc_call etc. */
- if (acheck && val != Qundef &&
- TYPE(val) == T_ARRAY && RARRAY(val)->len == 1) {
+ int len = 0;
+ if (avalue) {
+ len = RARRAY(val)->len;
+ if (len == 0) {
+ goto zero_arg;
+ }
+ if (len == 1) {
val = RARRAY(val)->ptr[0];
}
- assign(self, block->var, val, acheck);
+ else {
+ goto multi_values;
+ }
}
+ else if (val == Qundef) {
+ zero_arg:
+ val = Qnil;
+ multi_values:
+ {
+ ruby_current_node = block->var;
+ rb_warn("multiple values for a block parameter (%d for 1)\n\tfrom %s:%d",
+ len, cnode->nd_file, nd_line(cnode));
+ ruby_current_node = cnode;
+ }
+ }
+ assign(self, block->var, val, lambda);
}
}
POP_TAG();
if (state) goto pop_state;
}
+ if (!node) {
+ state = 0;
+ goto pop_state;
+ }
+ ruby_current_node = node;
PUSH_ITER(block->iter);
- PUSH_TAG(PROT_NONE);
+ PUSH_TAG(lambda ? PROT_NONE : PROT_YIELD);
if ((state = EXEC_TAG()) == 0) {
redo:
- if (!node) {
- result = Qnil;
- }
- else if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
- if (val == Qundef) val = rb_ary_new2(0);
+ if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
+ if (node->nd_state == YIELD_FUNC_AVALUE) {
+ if (!avalue) {
+ val = svalue_to_avalue(val);
+ }
+ }
+ else {
+ if (avalue) {
+ val = avalue_to_svalue(val);
+ }
+ if (val == Qundef && node->nd_state != YIELD_FUNC_SVALUE)
+ val = Qnil;
+ }
result = (*node->nd_cfnc)(val, node->nd_tval, self);
}
else {
@@ -3567,40 +4722,24 @@ rb_yield_0(val, self, klass, acheck)
goto redo;
case TAG_NEXT:
state = 0;
- result = Qnil;
+ result = prot_tag->retval;
break;
case TAG_BREAK:
- case TAG_RETURN:
- state |= (serial++ << 8);
- state |= 0x10;
- block->tag->dst = state;
+ if (TAG_DST()) {
+ result = prot_tag->retval;
+ }
+ else {
+ lambda = Qtrue; /* just pass TAG_BREAK */
+ }
break;
default:
break;
}
}
POP_TAG();
- pop_state:
POP_ITER();
+ pop_state:
POP_CLASS();
-#if 0
- if (ruby_dyna_vars && (block->flags & BLOCK_D_SCOPE) &&
- (!(ruby_scope->flags & SCOPE_DONT_RECYCLE) ||
- !(block->tag->flags & BLOCK_DYNAMIC) ||
- !FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE))) {
- struct RVarmap *vars, *tmp;
-
- if (ruby_dyna_vars->id == 0) {
- vars = ruby_dyna_vars->next;
- rb_gc_force_recycle((VALUE)ruby_dyna_vars);
- while (vars && vars->id != 0) {
- tmp = vars->next;
- rb_gc_force_recycle((VALUE)vars);
- vars = tmp;
- }
- }
- }
-#else
if (ruby_dyna_vars && (block->flags & BLOCK_D_SCOPE) &&
!FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE)) {
struct RVarmap *vars = ruby_dyna_vars;
@@ -3608,31 +4747,45 @@ rb_yield_0(val, self, klass, acheck)
if (ruby_dyna_vars->id == 0) {
vars = ruby_dyna_vars->next;
rb_gc_force_recycle((VALUE)ruby_dyna_vars);
- while (vars && vars->id != 0) {
+ while (vars && vars->id != 0 && vars != block->dyna_vars) {
struct RVarmap *tmp = vars->next;
rb_gc_force_recycle((VALUE)vars);
vars = tmp;
}
}
}
-#endif
POP_VARS();
ruby_block = block;
ruby_frame = ruby_frame->prev;
- if (ruby_scope->flag & SCOPE_DONT_RECYCLE)
- scope_dup(old_scope);
+ ruby_cref = (NODE*)old_cref;
+ ruby_wrapper = old_wrapper;
+ if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
+ scope_dup(old_scope);
ruby_scope = old_scope;
- if (state) {
- if (!block->tag) {
- switch (state & TAG_MASK) {
- case TAG_BREAK:
- case TAG_RETURN:
- jump_tag_but_local_jump(state & TAG_MASK);
- break;
+ scope_vmode = old_vmode;
+ switch (state) {
+ case 0:
+ break;
+ case TAG_BREAK:
+ if (!lambda) {
+ struct tag *tt = prot_tag;
+
+ while (tt) {
+ if (tt->tag == PROT_LOOP && tt->blkid == ruby_block->uniq) {
+ tt->dst = (VALUE)tt->frame->uniq;
+ tt->retval = result;
+ JUMP_TAG(TAG_BREAK);
+ }
+ tt = tt->prev;
}
+ proc_jump_error(TAG_BREAK, result);
}
+ /* fall through */
+ default:
JUMP_TAG(state);
+ break;
}
+ ruby_current_node = cnode;
return result;
}
@@ -3640,70 +4793,109 @@ VALUE
rb_yield(val)
VALUE val;
{
- return rb_yield_0(val, 0, 0, 0);
+ return rb_yield_0(val, 0, 0, 0, Qfalse);
+}
+
+VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_yield_values(int n, ...)
+#else
+rb_yield_values(n, va_alist)
+ int n;
+ va_dcl
+#endif
+{
+ va_list args;
+ VALUE ary;
+
+ if (n == 0) {
+ return rb_yield_0(Qundef, 0, 0, 0, Qfalse);
+ }
+ ary = rb_ary_new2(n);
+ va_init_list(args, n);
+ while (n--) {
+ rb_ary_push(ary, va_arg(args, VALUE));
+ }
+ va_end(args);
+ return rb_yield_0(ary, 0, 0, 0, Qtrue);
+}
+
+VALUE
+rb_yield_splat(values)
+ VALUE values;
+{
+ int avalue = Qfalse;
+
+ if (TYPE(values) == T_ARRAY) {
+ if (RARRAY(values)->len == 0) {
+ values = Qundef;
+ }
+ else {
+ avalue = Qtrue;
+ }
+ }
+ return rb_yield_0(values, 0, 0, 0, avalue);
}
+/*
+ * call-seq:
+ * loop {|| block }
+ *
+ * Repeatedly executes the block.
+ *
+ * loop do
+ * print "Input: "
+ * line = gets
+ * break if !line or line =~ /^qQ/
+ * # ...
+ * end
+ */
+
static VALUE
rb_f_loop()
{
for (;;) {
- rb_yield_0(Qnil, 0, 0, 0);
+ rb_yield_0(Qundef, 0, 0, 0, Qfalse);
CHECK_INTS;
}
return Qnil; /* dummy */
}
static VALUE
-massign(self, node, val, check)
+massign(self, node, val, pcall)
VALUE self;
NODE *node;
VALUE val;
- int check;
+ int pcall;
{
NODE *list;
- int i = 0, len;
+ long i = 0, len;
- if (val == Qundef) {
- val = rb_ary_new2(0);
- }
- else if (TYPE(val) != T_ARRAY) {
- if (rb_respond_to(val, to_ary)) {
- VALUE ary = rb_funcall(val, to_ary, 0);
- if (TYPE(ary) != T_ARRAY) {
- rb_raise(rb_eTypeError, "%s#to_ary should return Array",
- rb_class2name(CLASS_OF(val)));
- }
- val = ary;
- }
- else {
- val = rb_ary_new3(1, val);
- }
- }
len = RARRAY(val)->len;
list = node->nd_head;
- for (i=0; list && i<len; i++) {
- assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
+ for (; list && i<len; i++) {
+ assign(self, list->nd_head, RARRAY(val)->ptr[i], pcall);
list = list->nd_next;
}
- if (check && list) goto arg_error;
+ if (pcall && list) goto arg_error;
if (node->nd_args) {
- if (node->nd_args == (NODE*)-1) {
+ if ((long)(node->nd_args) == -1) {
/* no check for mere `*' */
}
else if (!list && i<len) {
- assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
+ assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), pcall);
}
else {
- assign(self, node->nd_args, rb_ary_new2(0), check);
+ assign(self, node->nd_args, rb_ary_new2(0), pcall);
}
}
- else if (check && i < len) {
+ else if (pcall && i < len) {
goto arg_error;
}
while (list) {
i++;
- assign(self, list->nd_head, Qnil, check);
+ assign(self, list->nd_head, Qnil, pcall);
list = list->nd_next;
}
return val;
@@ -3713,17 +4905,21 @@ massign(self, node, val, check)
i++;
list = list->nd_next;
}
- rb_raise(rb_eArgError, "wrong # of arguments (%d for %d)", len, i);
+ rb_raise(rb_eArgError, "wrong number of arguments (%ld for %ld)", len, i);
}
static void
-assign(self, lhs, val, check)
+assign(self, lhs, val, pcall)
VALUE self;
NODE *lhs;
VALUE val;
- int check;
+ int pcall;
{
- if (val == Qundef) val = Qnil;
+ ruby_current_node = lhs;
+ if (val == Qundef) {
+ rb_warning("assigning void value");
+ val = Qnil;
+ }
switch (nd_type(lhs)) {
case NODE_GASGN:
rb_gvar_set(lhs->nd_entry, val);
@@ -3748,31 +4944,47 @@ assign(self, lhs, val, check)
break;
case NODE_CDECL:
- rb_const_set(ruby_class, lhs->nd_vid, val);
+ if (lhs->nd_vid == 0) {
+ rb_const_set(class_prefix(self, lhs->nd_else), lhs->nd_else->nd_mid, val);
+ }
+ else {
+ rb_const_set(ruby_cbase, lhs->nd_vid, val);
+ }
break;
case NODE_CVDECL:
- if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
- rb_cvar_declare(ruby_cbase, lhs->nd_vid, val);
- break;
+ if (RTEST(ruby_verbose) && FL_TEST(ruby_cbase, FL_SINGLETON)) {
+ rb_warn("declaring singleton class variable");
}
- self = rb_iv_get(ruby_cbase, "__attached__");
- /* fall through */
+ rb_cvar_set(cvar_cbase(), lhs->nd_vid, val, Qtrue);
+ break;
+
case NODE_CVASGN:
- rb_cvar_set(rb_cvar_singleton(self), lhs->nd_vid, val);
+ rb_cvar_set(cvar_cbase(), lhs->nd_vid, val, Qfalse);
break;
case NODE_MASGN:
- massign(self, lhs, val, check);
+ massign(self, lhs, svalue_to_mrhs(val, lhs->nd_head), pcall);
break;
case NODE_CALL:
+ case NODE_ATTRASGN:
{
VALUE recv;
- recv = rb_eval(self, lhs->nd_recv);
+ int scope;
+ if (lhs->nd_recv == (NODE *)1) {
+ recv = self;
+ scope = 1;
+ }
+ else {
+ recv = rb_eval(self, lhs->nd_recv);
+ scope = 0;
+ }
if (!lhs->nd_args) {
/* attr set */
- rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, 0);
+ ruby_current_node = lhs;
+ SET_CURRENT_SOURCE();
+ rb_call(CLASS_OF(recv), recv, lhs->nd_mid, 1, &val, scope);
}
else {
/* array set */
@@ -3780,8 +4992,10 @@ assign(self, lhs, val, check)
args = rb_eval(self, lhs->nd_args);
rb_ary_push(args, val);
+ ruby_current_node = lhs;
+ SET_CURRENT_SOURCE();
rb_call(CLASS_OF(recv), recv, lhs->nd_mid,
- RARRAY(args)->len, RARRAY(args)->ptr, 0);
+ RARRAY(args)->len, RARRAY(args)->ptr, scope);
}
}
break;
@@ -3794,7 +5008,7 @@ assign(self, lhs, val, check)
VALUE
rb_iterate(it_proc, data1, bl_proc, data2)
- VALUE (*it_proc)(), (*bl_proc)();
+ VALUE (*it_proc) _((VALUE)), (*bl_proc)(ANYARGS);
VALUE data1, data2;
{
int state;
@@ -3802,39 +5016,29 @@ rb_iterate(it_proc, data1, bl_proc, data2)
NODE *node = NEW_IFUNC(bl_proc, data2);
VALUE self = ruby_top_self;
- iter_retry:
PUSH_ITER(ITER_PRE);
+ PUSH_TAG(PROT_LOOP);
PUSH_BLOCK(0, node);
- PUSH_TAG(PROT_NONE);
-
state = EXEC_TAG();
if (state == 0) {
+ iter_retry:
retval = (*it_proc)(data1);
}
- if (ruby_block->tag->dst == state) {
- state &= TAG_MASK;
- if (state == TAG_RETURN) {
- retval = prot_tag->retval;
- }
+ else if (state == TAG_BREAK && TAG_DST()) {
+ retval = prot_tag->retval;
+ state = 0;
+ }
+ else if (state == TAG_RETRY) {
+ state = 0;
+ goto iter_retry;
}
- POP_TAG();
POP_BLOCK();
+ POP_TAG();
POP_ITER();
switch (state) {
case 0:
break;
-
- case TAG_RETRY:
- goto iter_retry;
-
- case TAG_BREAK:
- retval = Qnil;
- break;
-
- case TAG_RETURN:
- return_value(retval);
- /* fall through */
default:
JUMP_TAG(state);
}
@@ -3861,7 +5065,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(ruby_errinfo, argv[0])) return 1;
+ if (RTEST(rb_funcall(*argv, eqq, 1, ruby_errinfo))) return 1;
argv++;
}
return 0;
@@ -3869,10 +5073,10 @@ handle_rescue(self, node)
VALUE
#ifdef HAVE_STDARG_PROTOTYPES
-rb_rescue2(VALUE (*b_proc)(), VALUE data1, VALUE (*r_proc)(), VALUE data2, ...)
+rb_rescue2(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*r_proc)(ANYARGS), VALUE data2, ...)
#else
rb_rescue2(b_proc, data1, r_proc, data2, va_alist)
- VALUE (*b_proc)(), (*r_proc)();
+ VALUE (*b_proc)(ANYARGS), (*r_proc)(ANYARGS);
VALUE data1, data2;
va_dcl
#endif
@@ -3933,16 +5137,16 @@ rb_rescue(b_proc, data1, r_proc, data2)
VALUE (*b_proc)(), (*r_proc)();
VALUE data1, data2;
{
- return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError, 0);
+ return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError, (VALUE)0);
}
VALUE
rb_protect(proc, data, state)
- VALUE (*proc)();
+ VALUE (*proc) _((VALUE));
VALUE data;
int *state;
{
- VALUE result; /* OK */
+ VALUE result = Qnil; /* OK */
int status;
PUSH_TAG(PROT_NONE);
@@ -3963,8 +5167,9 @@ rb_protect(proc, data, state)
VALUE
rb_ensure(b_proc, data1, e_proc, data2)
VALUE (*b_proc)();
+ VALUE data1;
VALUE (*e_proc)();
- VALUE data1, data2;
+ VALUE data2;
{
int state;
volatile VALUE result = Qnil;
@@ -3975,10 +5180,9 @@ rb_ensure(b_proc, data1, e_proc, data2)
result = (*b_proc)(data1);
}
POP_TAG();
- retval = prot_tag->retval; /* save retval */
+ retval = prot_tag ? prot_tag->retval : Qnil; /* save retval */
(*e_proc)(data2);
- return_value(retval);
-
+ if (prot_tag) return_value(retval);
if (state) JUMP_TAG(state);
return result;
}
@@ -3988,163 +5192,166 @@ rb_with_disable_interrupt(proc, data)
VALUE (*proc)();
VALUE data;
{
- VALUE result; /* OK */
+ VALUE result = Qnil; /* OK */
int status;
DEFER_INTS;
- PUSH_TAG(PROT_NONE);
- if ((status = EXEC_TAG()) == 0) {
- result = (*proc)(data);
+ {
+ int thr_critical = rb_thread_critical;
+
+ rb_thread_critical = Qtrue;
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ result = (*proc)(data);
+ }
+ POP_TAG();
+ rb_thread_critical = thr_critical;
}
- POP_TAG();
- ALLOW_INTS;
+ ENABLE_INTS;
if (status) JUMP_TAG(status);
return result;
}
+static inline void
+stack_check()
+{
+ static int overflowing = 0;
+
+ if (!overflowing && ruby_stack_check()) {
+ int state;
+ overflowing = 1;
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ rb_exc_raise(sysstack_error);
+ }
+ POP_TAG();
+ overflowing = 0;
+ JUMP_TAG(state);
+ }
+}
+
static int last_call_status;
#define CSTAT_PRIV 1
#define CSTAT_PROT 2
#define CSTAT_VCALL 4
+#define CSTAT_SUPER 8
+
+/*
+ * call-seq:
+ * obj.method_missing(symbol [, *args] ) => result
+ *
+ * Invoked by Ruby when <i>obj</i> is sent a message it cannot handle.
+ * <i>symbol</i> is the symbol for the method called, and <i>args</i>
+ * are any arguments that were passed to it. By default, the interpreter
+ * raises an error when this method is called. However, it is possible
+ * to override the method to provide more dynamic behavior.
+ * The example below creates
+ * a class <code>Roman</code>, which responds to methods with names
+ * consisting of roman numerals, returning the corresponding integer
+ * values.
+ *
+ * class Roman
+ * def romanToInt(str)
+ * # ...
+ * end
+ * def method_missing(methId)
+ * str = methId.id2name
+ * romanToInt(str)
+ * end
+ * end
+ *
+ * r = Roman.new
+ * r.iv #=> 4
+ * r.xxiii #=> 23
+ * r.mm #=> 2000
+ */
static VALUE
-rb_f_missing(argc, argv, obj)
+rb_method_missing(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
- ID id;
- volatile VALUE d = 0;
+ ID id;
+ VALUE exc = rb_eNoMethodError;
char *format = 0;
- char *desc = "";
- char *file = ruby_sourcefile;
- int line = ruby_sourceline;
+ NODE *cnode = ruby_current_node;
if (argc == 0 || !SYMBOL_P(argv[0])) {
rb_raise(rb_eArgError, "no id given");
}
+ stack_check();
+
id = SYM2ID(argv[0]);
- argc--; argv++;
- switch (TYPE(obj)) {
- case T_NIL:
- format = "undefined method `%s' for nil";
- break;
- case T_TRUE:
- format = "undefined method `%s' for true";
- break;
- case T_FALSE:
- format = "undefined method `%s' for false";
- break;
- case T_OBJECT:
- d = rb_any_to_s(obj);
- break;
- default:
- d = rb_inspect(obj);
- break;
+ if (last_call_status & CSTAT_PRIV) {
+ format = "private method `%s' called for %s";
}
- if (d) {
- if (last_call_status & CSTAT_PRIV) {
- format = "private method `%s' called for %s%s%s";
- }
- if (last_call_status & CSTAT_PROT) {
- format = "protected method `%s' called for %s%s%s";
- }
- else if (last_call_status & CSTAT_VCALL) {
- const char *mname = rb_id2name(id);
-
- if (('a' <= mname[0] && mname[0] <= 'z') || mname[0] == '_') {
- format = "undefined local variable or method `%s' for %s%s%s";
- }
- }
- if (!format) {
- format = "undefined method `%s' for %s%s%s";
- }
- if (RSTRING(d)->len > 65) {
- d = rb_any_to_s(obj);
- }
- desc = RSTRING(d)->ptr;
+ else if (last_call_status & CSTAT_PROT) {
+ format = "protected method `%s' called for %s";
+ }
+ else if (last_call_status & CSTAT_VCALL) {
+ format = "undefined local variable or method `%s' for %s";
+ exc = rb_eNameError;
+ }
+ else if (last_call_status & CSTAT_SUPER) {
+ format = "super: no superclass method `%s'";
+ }
+ if (!format) {
+ format = "undefined method `%s' for %s";
}
- ruby_sourcefile = file;
- ruby_sourceline = line;
- PUSH_FRAME(); /* fake frame */
- *ruby_frame = *_frame.prev->prev;
+ ruby_current_node = cnode;
+ {
+ int n = 0;
+ VALUE args[3];
- rb_raise(rb_eNameError, format, rb_id2name(id),
- desc, desc[0]=='#'?"":":",
- desc[0]=='#'?"":rb_class2name(CLASS_OF(obj)));
- POP_FRAME();
+ args[n++] = rb_funcall(rb_const_get(exc, rb_intern("message")), '!',
+ 3, rb_str_new2(format), obj, argv[0]);
+ args[n++] = argv[0];
+ if (exc == rb_eNoMethodError) {
+ args[n++] = rb_ary_new4(argc-1, argv+1);
+ }
+ exc = rb_class_new_instance(n, args, exc);
+ ruby_frame = ruby_frame->prev; /* pop frame for "method_missing" */
+ rb_exc_raise(exc);
+ }
return Qnil; /* not reached */
}
static VALUE
-rb_undefined(obj, id, argc, argv, call_status)
+method_missing(obj, id, argc, argv, call_status)
VALUE obj;
ID id;
int argc;
- VALUE*argv;
+ const VALUE *argv;
int call_status;
{
VALUE *nargv;
+ last_call_status = call_status;
+
+ if (id == missing) {
+ PUSH_FRAME();
+ rb_method_missing(argc, argv, obj);
+ POP_FRAME();
+ }
+ else if (id == ID_ALLOCATOR) {
+ rb_raise(rb_eNoMethodError, "allocator undefined for %s", rb_class2name(obj));
+ }
+
nargv = ALLOCA_N(VALUE, argc+1);
nargv[0] = ID2SYM(id);
MEMCPY(nargv+1, argv, VALUE, argc);
- last_call_status = call_status;
-
return rb_funcall2(obj, missing, argc+1, nargv);
}
-#ifdef DJGPP
-static int STACK_LEVEL_MAX = 65535;
-#else
-#ifdef __human68k__
-extern int _stacksize;
-# define STACK_LEVEL_MAX (_stacksize - 4096)
-#undef HAVE_GETRLIMIT
-#else
-#ifdef HAVE_GETRLIMIT
-static int STACK_LEVEL_MAX = 655300;
-#else
-# define STACK_LEVEL_MAX 655300
-#endif
-#endif
-#endif
-
-extern VALUE *rb_gc_stack_start;
-static int
-stack_length(p)
- VALUE **p;
-{
-#ifdef C_ALLOCA
- VALUE stack_end;
- alloca(0);
-# define STACK_END (&stack_end)
-#else
-# if defined(__GNUC__) && defined(__i386__)
- VALUE *stack_end = __builtin_frame_address(0);
-# else
- VALUE *stack_end = alloca(1);
-# endif
-# define STACK_END (stack_end)
-#endif
- if (p) *p = STACK_END;
-
-#ifdef __sparc__
- return rb_gc_stack_start - STACK_END + 0x80;
-#else
- return (STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END
- : STACK_END - rb_gc_stack_start;
-#endif
-}
-
-static VALUE
+static inline VALUE
call_cfunc(func, recv, len, argc, argv)
VALUE (*func)();
VALUE recv;
@@ -4152,7 +5359,7 @@ call_cfunc(func, recv, len, argc, argv)
VALUE *argv;
{
if (len >= 0 && argc != len) {
- rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, len);
}
@@ -4233,9 +5440,10 @@ call_cfunc(func, recv, len, argc, argv)
}
static VALUE
-rb_call0(klass, recv, id, argc, argv, body, nosuper)
+rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
VALUE klass, recv;
ID id;
+ ID oid;
int argc; /* OK */
VALUE *argv; /* OK */
NODE *body; /* OK */
@@ -4259,14 +5467,14 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
if ((++tick & 0xff) == 0) {
CHECK_INTS; /* better than nothing */
- if (stack_length(0) > STACK_LEVEL_MAX) {
- rb_raise(rb_eSysStackError, "stack level too deep");
- }
+ stack_check();
+ rb_gc_finalize_deferred();
}
PUSH_ITER(itr);
PUSH_FRAME();
ruby_frame->last_func = id;
+ ruby_frame->orig_func = oid;
ruby_frame->last_class = nosuper?0:klass;
ruby_frame->self = recv;
ruby_frame->argc = argc;
@@ -4283,20 +5491,15 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
}
if (trace_func) {
int state;
- char *file = ruby_frame->prev->file;
- int line = ruby_frame->prev->line;
- if (!file) {
- file = ruby_sourcefile;
- line = ruby_sourceline;
- }
- call_trace_func("c-call", 0, 0, recv, id, klass);
+ call_trace_func("c-call", ruby_current_node, recv, id, klass);
PUSH_TAG(PROT_FUNC);
if ((state = EXEC_TAG()) == 0) {
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
}
POP_TAG();
- call_trace_func("c-return", 0, 0, recv, id, klass);
+ ruby_current_node = ruby_frame->node;
+ call_trace_func("c-return", ruby_current_node, recv, id, klass);
if (state) JUMP_TAG(state);
}
else {
@@ -4305,11 +5508,17 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
}
break;
- /* for re-scoped/renamed method */
- case NODE_ZSUPER:
/* for attr get/set */
- case NODE_ATTRSET:
case NODE_IVAR:
+ if (argc != 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ result = rb_attr_get(recv, body->nd_vid);
+ break;
+
+ case NODE_ATTRSET:
+ /* for re-scoped/renamed method */
+ case NODE_ZSUPER:
result = rb_eval(recv, body);
break;
@@ -4318,7 +5527,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
break;
case NODE_BMETHOD:
- result = proc_call(body->nd_cval, rb_ary_new4(argc, argv));
+ result = proc_invoke(body->nd_cval, rb_ary_new4(argc, argv), recv, klass);
break;
case NODE_SCOPE:
@@ -4332,8 +5541,8 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
if (body->nd_rval) {
saved_cref = ruby_cref;
ruby_cref = (NODE*)body->nd_rval;
- ruby_frame->cbase = body->nd_rval;
}
+ PUSH_CLASS(ruby_cbase);
if (body->nd_tbl) {
local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
*local_vars++ = (VALUE)body;
@@ -4369,10 +5578,10 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
i = node->nd_cnt;
if (i > argc) {
- rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, i);
}
- if (node->nd_rest == -1) {
+ if ((long)node->nd_rest == -1) {
int opt = i;
NODE *optnode = node->nd_opt;
@@ -4381,7 +5590,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
optnode = optnode->nd_next;
}
if (opt < argc) {
- rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)",
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, opt);
}
ruby_frame->argc = opt;
@@ -4402,51 +5611,54 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
argv++; argc--;
opt = opt->nd_next;
}
- rb_eval(recv, opt);
+ if (opt) {
+ rb_eval(recv, opt);
+ }
}
- if (node->nd_rest >= 0) {
+ local_vars = ruby_scope->local_vars;
+ if ((long)node->nd_rest >= 0) {
+ VALUE v;
+
if (argc > 0)
- local_vars[node->nd_rest]=rb_ary_new4(argc,argv);
+ v = rb_ary_new4(argc,argv);
else
- local_vars[node->nd_rest]=rb_ary_new2(0);
+ v = rb_ary_new2(0);
+ ruby_scope->local_vars[node->nd_rest] = v;
}
}
}
if (trace_func) {
- call_trace_func("call", b2->nd_file, nd_line(b2),
- recv, id, klass);
+ call_trace_func("call", b2, recv, id, klass);
}
result = rb_eval(recv, body);
}
- else if (state == TAG_RETURN) {
+ else if (state == TAG_RETURN && TAG_DST()) {
result = prot_tag->retval;
state = 0;
}
POP_TAG();
POP_VARS();
+ POP_CLASS();
POP_SCOPE();
ruby_cref = saved_cref;
if (trace_func) {
- char *file = ruby_frame->prev->file;
- int line = ruby_frame->prev->line;
- if (!file) {
- file = ruby_sourcefile;
- line = ruby_sourceline;
- }
- call_trace_func("return", file, line, recv, id, klass);
+ call_trace_func("return", ruby_frame->prev->node, recv, id, klass);
}
switch (state) {
case 0:
break;
+ case TAG_BREAK:
+ case TAG_RETURN:
+ JUMP_TAG(state);
+ break;
+
case TAG_RETRY:
- if (rb_block_given_p()) {
- break;
- }
+ if (rb_block_given_p()) JUMP_TAG(state);
/* fall through */
default:
- jump_tag_but_local_jump(state);
+ jump_tag_but_local_jump(state, result);
break;
}
}
@@ -4466,7 +5678,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
VALUE klass, recv;
ID mid;
int argc; /* OK */
- VALUE *argv; /* OK */
+ const VALUE *argv; /* OK */
int scope;
{
NODE *body; /* OK */
@@ -4475,13 +5687,14 @@ rb_call(klass, recv, mid, argc, argv, scope)
struct cache_entry *ent;
if (!klass) {
- rb_raise(rb_eNotImpError, "method call on terminated object");
+ rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)",
+ rb_id2name(mid), recv);
}
/* is it in the method cache? */
ent = cache + EXPR1(klass, mid);
if (ent->mid == mid && ent->klass == klass) {
if (!ent->method)
- return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
+ return method_missing(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
klass = ent->origin;
id = ent->mid0;
noex = ent->noex;
@@ -4489,28 +5702,29 @@ rb_call(klass, recv, mid, argc, argv, scope)
}
else if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
if (scope == 3) {
- rb_raise(rb_eNameError, "super: no superclass method `%s'",
- rb_id2name(mid));
+ return method_missing(recv, mid, argc, argv, CSTAT_SUPER);
}
- return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
+ return method_missing(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
}
if (mid != missing) {
/* receiver specified form for private method */
if ((noex & NOEX_PRIVATE) && scope == 0)
- return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV);
+ return method_missing(recv, mid, argc, argv, CSTAT_PRIV);
- /* self must be kind of a specified form for private method */
+ /* self must be kind of a specified form for protected method */
if ((noex & NOEX_PROTECTED)) {
VALUE defined_class = klass;
- while (TYPE(defined_class) == T_ICLASS)
+
+ if (TYPE(defined_class) == T_ICLASS) {
defined_class = RBASIC(defined_class)->klass;
- if (!rb_obj_is_kind_of(ruby_frame->self, defined_class))
- return rb_undefined(recv, mid, argc, argv, CSTAT_PROT);
+ }
+ if (!rb_obj_is_kind_of(ruby_frame->self, rb_class_real(defined_class)))
+ return method_missing(recv, mid, argc, argv, CSTAT_PROT);
}
}
- return rb_call0(klass, recv, id, argc, argv, body, noex & NOEX_UNDEF);
+ return rb_call0(klass, recv, mid, id, argc, argv, body, noex & NOEX_NOSUPER);
}
VALUE
@@ -4522,12 +5736,30 @@ rb_apply(recv, mid, args)
int argc;
VALUE *argv;
- argc = RARRAY(args)->len;
+ argc = RARRAY(args)->len; /* Assigns LONG, but argc is INT */
argv = ALLOCA_N(VALUE, argc);
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
+/*
+ * call-seq:
+ * obj.send(symbol [, args...]) => obj
+ * obj.__send__(symbol [, args...]) => obj
+ *
+ * Invokes the method identified by _symbol_, passing it any
+ * arguments specified. You can use <code>__send__</code> if the name
+ * +send+ clashes with an existing method in _obj_.
+ *
+ * class Klass
+ * def hello(*args)
+ * "Hello " + args.join(' ')
+ * end
+ * end
+ * k = Klass.new
+ * k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
+ */
+
static VALUE
rb_f_send(argc, argv, recv)
int argc;
@@ -4546,15 +5778,6 @@ rb_f_send(argc, argv, recv)
return vid;
}
-
-#ifdef HAVE_STDARG_PROTOTYPES
-#include <stdarg.h>
-#define va_init_list(a,b) va_start(a,b)
-#else
-#include <varargs.h>
-#define va_init_list(a,b) va_start(a)
-#endif
-
VALUE
#ifdef HAVE_STDARG_PROTOTYPES
rb_funcall(VALUE recv, ID mid, int n, ...)
@@ -4570,7 +5793,7 @@ rb_funcall(recv, mid, n, va_alist)
VALUE *argv;
if (n > 0) {
- int i;
+ long i;
argv = ALLOCA_N(VALUE, n);
@@ -4592,7 +5815,7 @@ rb_funcall2(recv, mid, argc, argv)
VALUE recv;
ID mid;
int argc;
- VALUE *argv;
+ const VALUE *argv;
{
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 1);
}
@@ -4602,7 +5825,7 @@ rb_funcall3(recv, mid, argc, argv)
VALUE recv;
ID mid;
int argc;
- VALUE *argv;
+ const VALUE *argv;
{
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, 0);
}
@@ -4610,19 +5833,20 @@ rb_funcall3(recv, mid, argc, argv)
VALUE
rb_call_super(argc, argv)
int argc;
- VALUE *argv;
+ const VALUE *argv;
{
- VALUE result;
+ VALUE result, self, klass, k;
- if (ruby_frame->last_class == 0) {
- rb_raise(rb_eNameError, "superclass method `%s' must be enabled by rb_enable_super()",
- rb_id2name(ruby_frame->last_func));
+ if (ruby_frame->last_class == 0) {
+ rb_name_error(ruby_frame->last_func, "calling `super' from `%s' is prohibited",
+ rb_id2name(ruby_frame->last_func));
}
- PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
- result = rb_call(RCLASS(ruby_frame->last_class)->super,
- ruby_frame->self, ruby_frame->last_func,
- argc, argv, 3);
+ self = ruby_frame->self;
+ klass = ruby_frame->last_class;
+
+ PUSH_ITER(ruby_iter->iter ? ITER_PRE : ITER_NOT);
+ result = rb_call(RCLASS(klass)->super, self, ruby_frame->orig_func, argc, argv, 3);
POP_ITER();
return result;
@@ -4635,9 +5859,14 @@ backtrace(lev)
struct FRAME *frame = ruby_frame;
char buf[BUFSIZ];
VALUE ary;
+ NODE *n;
ary = rb_ary_new();
+ if (frame->last_func == ID_ALLOCATOR) {
+ frame = frame->prev;
+ }
if (lev < 0) {
+ ruby_set_current_source();
if (frame->last_func) {
snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
ruby_sourcefile, ruby_sourceline,
@@ -4650,6 +5879,7 @@ backtrace(lev)
snprintf(buf, BUFSIZ, "%s:%d", ruby_sourcefile, ruby_sourceline);
}
rb_ary_push(ary, rb_str_new2(buf));
+ if (lev < -1) return ary;
}
else {
while (lev-- > 0) {
@@ -4660,14 +5890,14 @@ backtrace(lev)
}
}
}
- while (frame && frame->file) {
+ while (frame && (n = frame->node)) {
if (frame->prev && frame->prev->last_func) {
snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
- frame->file, frame->line,
+ n->nd_file, nd_line(n),
rb_id2name(frame->prev->last_func));
}
else {
- snprintf(buf, BUFSIZ, "%s:%d", frame->file, frame->line);
+ snprintf(buf, BUFSIZ, "%s:%d", n->nd_file, nd_line(n));
}
rb_ary_push(ary, rb_str_new2(buf));
frame = frame->prev;
@@ -4676,6 +5906,31 @@ backtrace(lev)
return ary;
}
+/*
+ * call-seq:
+ * caller(start=1) => array
+ *
+ * Returns the current execution stack---an array containing strings in
+ * the form ``<em>file:line</em>'' or ``<em>file:line: in
+ * `method'</em>''. The optional _start_ parameter
+ * determines the number of initial stack entries to omit from the
+ * result.
+ *
+ * def a(skip)
+ * caller(skip)
+ * end
+ * def b(skip)
+ * a(skip)
+ * end
+ * def c(skip)
+ * b(skip)
+ * end
+ * c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10"]
+ * c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11"]
+ * c(2) #=> ["prog:8:in `c'", "prog:12"]
+ * c(3) #=> ["prog:13"]
+ */
+
static VALUE
rb_f_caller(argc, argv)
int argc;
@@ -4696,7 +5951,7 @@ rb_f_caller(argc, argv)
void
rb_backtrace()
{
- int i;
+ long i;
VALUE ary;
ary = backtrace(-1);
@@ -4724,10 +5979,14 @@ compile(src, file, line)
int line;
{
NODE *node;
+ int critical;
ruby_nerrs = 0;
- Check_Type(src, T_STRING);
+ StringValue(src);
+ critical = rb_thread_critical;
+ rb_thread_critical = Qtrue;
node = rb_compile_string(file, src, line);
+ rb_thread_critical = critical;
if (ruby_nerrs == 0) return node;
return 0;
@@ -4739,26 +5998,24 @@ eval(self, src, scope, file, line)
char *file;
int line;
{
- struct BLOCK *data;
+ struct BLOCK *data = NULL;
volatile VALUE result = Qnil;
struct SCOPE * volatile old_scope;
struct BLOCK * volatile old_block;
struct RVarmap * volatile old_dyna_vars;
+ VALUE volatile old_cref;
int volatile old_vmode;
+ volatile VALUE old_wrapper;
struct FRAME frame;
- char *filesave = ruby_sourcefile;
- int linesave = ruby_sourceline;
+ NODE *nodesave = ruby_current_node;
volatile int iter = ruby_frame->iter;
+ volatile int safe = ruby_safe_level;
int state;
- if (file == 0) {
- file = ruby_sourcefile;
- line = ruby_sourceline;
- }
if (!NIL_P(scope)) {
- if (!rb_obj_is_block(scope)) {
+ if (!rb_obj_is_proc(scope)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Binding)",
- rb_class2name(CLASS_OF(scope)));
+ rb_obj_classname(scope));
}
Data_Get_Struct(scope, struct BLOCK, data);
@@ -4774,6 +6031,15 @@ eval(self, src, scope, file, line)
ruby_dyna_vars = data->dyna_vars;
old_vmode = scope_vmode;
scope_vmode = data->vmode;
+ old_cref = (VALUE)ruby_cref;
+ ruby_cref = data->cref;
+ old_wrapper = ruby_wrapper;
+ ruby_wrapper = data->wrapper;
+ if ((file == 0 || (line == 1 && strcmp(file, "(eval)") == 0)) && data->frame.node) {
+ file = data->frame.node->nd_file;
+ if (!file) file = "__builtin__";
+ line = nd_line(data->frame.node);
+ }
self = data->self;
ruby_frame->iter = data->iter;
@@ -4783,9 +6049,12 @@ eval(self, src, scope, file, line)
ruby_frame->iter = ruby_frame->prev->iter;
}
}
- PUSH_CLASS();
- ruby_class = ruby_cbase;
-
+ if (file == 0) {
+ ruby_set_current_source();
+ file = ruby_sourcefile;
+ line = ruby_sourceline;
+ }
+ PUSH_CLASS(ruby_cbase);
ruby_in_eval++;
if (TYPE(ruby_class) == T_ICLASS) {
ruby_class = RBASIC(ruby_class)->klass;
@@ -4794,21 +6063,26 @@ eval(self, src, scope, file, line)
if ((state = EXEC_TAG()) == 0) {
NODE *node;
+ ruby_safe_level = 0;
result = ruby_errinfo;
ruby_errinfo = Qnil;
node = compile(src, file, line);
+ ruby_safe_level = safe;
if (ruby_nerrs > 0) {
compile_error(0);
}
if (!NIL_P(result)) ruby_errinfo = result;
- result = eval_node(self, node);
+ result = eval_node(self, node);
}
POP_TAG();
POP_CLASS();
ruby_in_eval--;
+ ruby_safe_level = safe;
if (!NIL_P(scope)) {
- int dont_recycle = ruby_scope->flag & SCOPE_DONT_RECYCLE;
+ int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE;
+ ruby_wrapper = old_wrapper;
+ ruby_cref = (NODE*)old_cref;
ruby_frame = frame.tmp;
ruby_scope = old_scope;
ruby_block = old_block;
@@ -4816,47 +6090,37 @@ eval(self, src, scope, file, line)
data->vmode = scope_vmode; /* write back visibility mode */
scope_vmode = old_vmode;
if (dont_recycle) {
- struct tag *tag;
- struct RVarmap *vars;
-
- scope_dup(ruby_scope);
- for (tag=prot_tag; tag; tag=tag->prev) {
- scope_dup(tag->scope);
- }
- if (ruby_block) {
- struct BLOCK *block = ruby_block;
- while (block) {
- block->tag->flags |= BLOCK_DYNAMIC;
- block = block->prev;
- }
- }
- for (vars = ruby_dyna_vars; vars; vars = vars->next) {
- FL_SET(vars, DVAR_DONT_RECYCLE);
- }
+ struct tag *tag;
+ struct RVarmap *vars;
+
+ scope_dup(ruby_scope);
+ for (tag=prot_tag; tag; tag=tag->prev) {
+ scope_dup(tag->scope);
+ }
+ for (vars = ruby_dyna_vars; vars; vars = vars->next) {
+ FL_SET(vars, DVAR_DONT_RECYCLE);
+ }
}
}
else {
ruby_frame->iter = iter;
}
- ruby_sourcefile = filesave;
- ruby_sourceline = linesave;
+ ruby_current_node = nodesave;
+ ruby_set_current_source();
if (state) {
if (state == TAG_RAISE) {
- VALUE err;
- VALUE errat;
-
if (strcmp(file, "(eval)") == 0) {
- if (ruby_sourceline > 1) {
- errat = get_backtrace(ruby_errinfo);
- err = RARRAY(errat)->ptr[0];
- rb_str_cat2(err, ": ");
- rb_str_append(err, ruby_errinfo);
- }
- else {
- err = rb_str_dup(ruby_errinfo);
+ VALUE mesg, errat;
+
+ errat = get_backtrace(ruby_errinfo);
+ mesg = rb_attr_get(ruby_errinfo, rb_intern("mesg"));
+ if (!NIL_P(errat) && TYPE(errat) == T_ARRAY) {
+ if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) {
+ rb_str_update(mesg, 0, 0, rb_str_new2(": "));
+ rb_str_update(mesg, 0, 0, RARRAY(errat)->ptr[0]);
+ }
+ RARRAY(errat)->ptr[0] = RARRAY(backtrace(-2))->ptr[0];
}
- errat = Qnil;
- rb_exc_raise(rb_exc_new3(CLASS_OF(ruby_errinfo), err));
}
rb_exc_raise(ruby_errinfo);
}
@@ -4866,6 +6130,25 @@ eval(self, src, scope, file, line)
return result;
}
+/*
+ * call-seq:
+ * eval(string [, binding [, filename [,lineno]]]) => obj
+ *
+ * Evaluates the Ruby expression(s) in <em>string</em>. If
+ * <em>binding</em> is given, the evaluation is performed in its
+ * context. The binding may be a <code>Binding</code> object or a
+ * <code>Proc</code> object. If the optional <em>filename</em> and
+ * <em>lineno</em> parameters are present, they will be used when
+ * reporting syntax errors.
+ *
+ * def getBinding(str)
+ * return binding
+ * end
+ * str = "hello"
+ * eval "str + ' Fred'" #=> "hello Fred"
+ * eval "str + ' Fred'", getBinding("bye") #=> "bye Fred"
+ */
+
static VALUE
rb_f_eval(argc, argv, self)
int argc;
@@ -4877,20 +6160,23 @@ rb_f_eval(argc, argv, self)
int line = 1;
rb_scan_args(argc, argv, "13", &src, &scope, &vfile, &vline);
+ if (ruby_safe_level >= 4) {
+ StringValue(src);
+ if (!NIL_P(scope) && !OBJ_TAINTED(scope)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't modify trusted binding");
+ }
+ }
+ else {
+ SafeStringValue(src);
+ }
if (argc >= 3) {
- Check_Type(vfile, T_STRING);
- file = RSTRING(vfile)->ptr;
+ StringValue(vfile);
}
if (argc >= 4) {
line = NUM2INT(vline);
}
- if (ruby_safe_level >= 4) {
- Check_Type(src, T_STRING);
- }
- else {
- Check_SafeStr(src);
- }
+ if (!NIL_P(vfile)) file = RSTRING(vfile)->ptr;
if (NIL_P(scope) && ruby_frame->prev) {
struct FRAME *prev;
VALUE val;
@@ -4909,26 +6195,25 @@ rb_f_eval(argc, argv, self)
/* function to call func under the specified class/module context */
static VALUE
-exec_under(func, under, args)
+exec_under(func, under, cbase, args)
VALUE (*func)();
- VALUE under;
+ VALUE under, cbase;
void *args;
{
- VALUE val; /* OK */
+ VALUE val = Qnil; /* OK */
int state;
int mode;
- PUSH_CLASS();
- ruby_class = under;
+ PUSH_CLASS(under);
PUSH_FRAME();
+ ruby_frame->self = _frame.prev->self;
ruby_frame->last_func = _frame.prev->last_func;
ruby_frame->last_class = _frame.prev->last_class;
ruby_frame->argc = _frame.prev->argc;
ruby_frame->argv = _frame.prev->argv;
- if (ruby_cbase != under) {
- ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,under,0,ruby_frame->cbase);
+ if (cbase) {
+ PUSH_CREF(cbase);
}
- PUSH_CREF(under);
mode = scope_vmode;
SCOPE_SET(SCOPE_PUBLIC);
@@ -4937,7 +6222,7 @@ exec_under(func, under, args)
val = (*func)(args);
}
POP_TAG();
- POP_CREF();
+ if (cbase) POP_CREF();
SCOPE_SET(mode);
POP_FRAME();
POP_CLASS();
@@ -4963,49 +6248,23 @@ eval_under(under, self, src, file, line)
VALUE args[4];
if (ruby_safe_level >= 4) {
- Check_Type(src, T_STRING);
+ StringValue(src);
}
else {
- Check_SafeStr(src);
+ SafeStringValue(src);
}
args[0] = self;
args[1] = src;
args[2] = (VALUE)file;
args[3] = (VALUE)line;
- return exec_under(eval_under_i, under, args);
+ return exec_under(eval_under_i, under, under, args);
}
static VALUE
yield_under_i(self)
VALUE self;
{
- if (ruby_block->flags & BLOCK_DYNAMIC) {
- struct BLOCK * volatile old_block = ruby_block;
- struct BLOCK block;
-
- /* cbase should be pointed from volatile local variable */
- /* to be protected from GC. */
- VALUE result;
- int state;
-
- block = *ruby_block;
- /* copy the block to avoid modifying global data. */
- block.frame.cbase = ruby_frame->cbase;
- ruby_block = &block;
-
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- result = rb_yield_0(self, self, ruby_class, 0);
- }
- POP_TAG();
- ruby_block = old_block;
- if (state) JUMP_TAG(state);
-
- return result;
- }
- /* static block, no need to restore */
- ruby_block->frame.cbase = ruby_frame->cbase;
- return rb_yield_0(self, self, ruby_class, 0);
+ return rb_yield_0(self, self, ruby_class, YIELD_PUBLIC_DEF, Qfalse);
}
/* block eval under the class/module context */
@@ -5013,9 +6272,7 @@ static VALUE
yield_under(under, self)
VALUE under, self;
{
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(self))
- rb_raise(rb_eSecurityError, "Insecure: can't eval");
- return exec_under(yield_under_i, under, self);
+ return exec_under(yield_under_i, under, 0, self);
}
static VALUE
@@ -5026,7 +6283,7 @@ specific_eval(argc, argv, klass, self)
{
if (rb_block_given_p()) {
if (argc > 0) {
- rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
}
return yield_under(klass, self);
}
@@ -5039,23 +6296,48 @@ specific_eval(argc, argv, klass, self)
}
else {
if (ruby_safe_level >= 4) {
- Check_Type(argv[0], T_STRING);
+ StringValue(argv[0]);
}
else {
- Check_SafeStr(argv[0]);
+ SafeStringValue(argv[0]);
}
if (argc > 3) {
- rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
+ rb_raise(rb_eArgError, "wrong number of arguments: %s(src) or %s{..}",
rb_id2name(ruby_frame->last_func),
rb_id2name(ruby_frame->last_func));
}
- if (argc > 1) file = STR2CSTR(argv[1]);
if (argc > 2) line = NUM2INT(argv[2]);
+ if (argc > 1) {
+ file = StringValuePtr(argv[1]);
+ }
}
return eval_under(klass, self, argv[0], file, line);
}
}
+/*
+ * call-seq:
+ * obj.instance_eval(string [, filename [, lineno]] ) => obj
+ * obj.instance_eval {| | block } => obj
+ *
+ * Evaluates a string containing Ruby source code, or the given block,
+ * within the context of the receiver (_obj_). In order to set the
+ * context, the variable +self+ is set to _obj_ while
+ * the code is executing, giving the code access to _obj_'s
+ * instance variables. In the version of <code>instance_eval</code>
+ * that takes a +String+, the optional second and third
+ * parameters supply a filename and starting line number that are used
+ * when reporting compilation errors.
+ *
+ * class Klass
+ * def initialize
+ * @secret = 99
+ * end
+ * end
+ * k = Klass.new
+ * k.instance_eval { @secret } #=> 99
+ */
+
VALUE
rb_obj_instance_eval(argc, argv, self)
int argc;
@@ -5064,17 +6346,40 @@ rb_obj_instance_eval(argc, argv, self)
{
VALUE klass;
- if (rb_special_const_p(self)) {
+ if (FIXNUM_P(self) || SYMBOL_P(self)) {
klass = Qnil;
}
else {
klass = rb_singleton_class(self);
}
-
return specific_eval(argc, argv, klass, self);
}
-static VALUE
+/*
+ * call-seq:
+ * mod.class_eval(string [, filename [, lineno]]) => obj
+ * mod.module_eval {|| block } => obj
+ *
+ * Evaluates the string or block in the context of _mod_. This can
+ * be used to add methods to a class. <code>module_eval</code> returns
+ * the result of evaluating its argument. The optional _filename_
+ * and _lineno_ parameters set the text for error messages.
+ *
+ * class Thing
+ * end
+ * a = %q{def hello() "Hello there!" end}
+ * Thing.module_eval(a)
+ * puts Thing.new.hello()
+ * Thing.module_eval("invalid code", "dummy", 123)
+ *
+ * <em>produces:</em>
+ *
+ * Hello there!
+ * dummy:123:in `module_eval': undefined local variable
+ * or method `code' for Thing:Class
+ */
+
+VALUE
rb_mod_module_eval(argc, argv, mod)
int argc;
VALUE *argv;
@@ -5085,34 +6390,39 @@ rb_mod_module_eval(argc, argv, mod)
VALUE rb_load_path;
+NORETURN(static void load_failed _((VALUE)));
+
void
rb_load(fname, wrap)
VALUE fname;
int wrap;
{
+ VALUE tmp;
int state;
- char *file;
+ volatile int prohibit_int = rb_prohibit_interrupt;
volatile ID last_func;
- volatile VALUE wrapper = 0;
+ volatile VALUE wrapper = ruby_wrapper;
volatile VALUE self = ruby_top_self;
+ NODE *volatile last_node;
NODE *saved_cref = ruby_cref;
TMP_PROTECT;
- if (wrap) {
- Check_Type(fname, T_STRING);
+ if (wrap && ruby_safe_level >= 4) {
+ StringValue(fname);
}
else {
- Check_SafeStr(fname);
+ SafeStringValue(fname);
}
- file = rb_find_file(RSTRING(fname)->ptr);
- if (!file) {
- rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
+ fname = rb_str_new4(fname);
+ tmp = rb_find_file(fname);
+ if (!tmp) {
+ load_failed(fname);
}
+ fname = tmp;
ruby_errinfo = Qnil; /* ensure */
PUSH_VARS();
- PUSH_CLASS();
- wrapper = ruby_wrapper;
+ PUSH_CLASS(ruby_wrapper);
ruby_cref = top_cref;
if (!wrap) {
rb_secure(4); /* should alter global state */
@@ -5123,53 +6433,56 @@ rb_load(fname, wrap)
/* load in anonymous module as toplevel */
ruby_class = ruby_wrapper = rb_module_new();
self = rb_obj_clone(ruby_top_self);
- rb_extend_object(self, ruby_class);
+ rb_extend_object(self, ruby_wrapper);
PUSH_CREF(ruby_wrapper);
}
+ PUSH_ITER(ITER_NOT);
PUSH_FRAME();
ruby_frame->last_func = 0;
ruby_frame->last_class = 0;
ruby_frame->self = self;
- ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,ruby_class,0,0);
PUSH_SCOPE();
- if (ruby_class == rb_cObject && top_scope->local_tbl) {
- int len = top_scope->local_tbl[0]+1;
- ID *tbl = ALLOC_N(ID, len);
- VALUE *vars = TMP_ALLOC(len);
- *vars++ = 0;
- MEMCPY(tbl, top_scope->local_tbl, ID, len);
- MEMCPY(vars, top_scope->local_vars, VALUE, len-1);
- ruby_scope->local_tbl = tbl; /* copy toplevel scope */
- ruby_scope->local_vars = vars; /* will not alter toplevel variables */
- }
/* default visibility is private at loading toplevel */
SCOPE_SET(SCOPE_PRIVATE);
-
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
last_func = ruby_frame->last_func;
+ last_node = ruby_current_node;
+ if (!ruby_current_node && ruby_sourcefile) {
+ last_node = NEW_NEWLINE(0);
+ }
+ ruby_current_node = 0;
if (state == 0) {
NODE *node;
+ volatile int critical;
DEFER_INTS;
ruby_in_eval++;
- rb_load_file(file);
+ critical = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ rb_load_file(RSTRING(fname)->ptr);
ruby_in_eval--;
node = ruby_eval_tree;
+ rb_thread_critical = critical;
ALLOW_INTS;
if (ruby_nerrs == 0) {
eval_node(self, node);
}
}
ruby_frame->last_func = last_func;
- if (ruby_scope->flag == SCOPE_ALLOCA && ruby_class == rb_cObject) {
+ ruby_current_node = last_node;
+ ruby_sourcefile = 0;
+ ruby_set_current_source();
+ if (ruby_scope->flags == SCOPE_ALLOCA && ruby_class == rb_cObject) {
if (ruby_scope->local_tbl) /* toplevel was empty */
free(ruby_scope->local_tbl);
}
POP_TAG();
+ rb_prohibit_interrupt = prohibit_int;
ruby_cref = saved_cref;
POP_SCOPE();
POP_FRAME();
+ POP_ITER();
POP_CLASS();
POP_VARS();
ruby_wrapper = wrapper;
@@ -5177,7 +6490,7 @@ rb_load(fname, wrap)
ruby_nerrs = 0;
rb_exc_raise(ruby_errinfo);
}
- if (state) jump_tag_but_local_jump(state);
+ if (state) jump_tag_but_local_jump(state, Qundef);
if (!NIL_P(ruby_errinfo)) /* exception during load */
rb_exc_raise(ruby_errinfo);
}
@@ -5198,6 +6511,21 @@ rb_load_protect(fname, wrap, state)
if (state) *state = status;
}
+/*
+ * call-seq:
+ * load(filename, wrap=false) => true
+ *
+ * Loads and executes the Ruby
+ * program in the file _filename_. If the filename does not
+ * resolve to an absolute path, the file is searched for in the library
+ * directories listed in <code>$:</code>. If the optional _wrap_
+ * parameter is +true+, the loaded script will be executed
+ * under an anonymous module, protecting the calling program's global
+ * namespace. In no circumstance will any local variables in the loaded
+ * file be propagated to the loading environment.
+ */
+
+
static VALUE
rb_f_load(argc, argv)
int argc;
@@ -5214,217 +6542,302 @@ VALUE ruby_dln_librefs;
static VALUE rb_features;
static st_table *loading_tbl;
-static int
-rb_feature_p(feature, wait)
- const char *feature;
- int wait;
+#define IS_SOEXT(e) (strcmp(e, ".so") == 0 || strcmp(e, ".o") == 0)
+#ifdef DLEXT2
+#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0 || strcmp(e, DLEXT2) == 0)
+#else
+#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0)
+#endif
+
+static char *
+rb_feature_p(feature, ext, rb)
+ const char *feature, *ext;
+ int rb;
{
- VALUE *p, *pend;
- char *f;
- int len;
+ VALUE v;
+ char *f, *e;
+ long i, len, elen;
- p = RARRAY(rb_features)->ptr;
- pend = p + RARRAY(rb_features)->len;
- while (p < pend) {
- f = STR2CSTR(*p);
- if (strcmp(f, feature) == 0) {
- goto load_wait;
- }
+ if (ext) {
+ len = ext - feature;
+ elen = strlen(ext);
+ }
+ else {
len = strlen(feature);
- if (strncmp(f, feature, len) == 0) {
- if (strcmp(f+len, ".so") == 0) {
- return Qtrue;
- }
- if (strcmp(f+len, ".rb") == 0) {
- if (wait) goto load_wait;
- return Qtrue;
- }
- }
- p++;
+ elen = 0;
}
- return Qfalse;
-
- load_wait:
- if (loading_tbl) {
- char *ext = strrchr(f, '.');
- if (ext && strcmp(ext, ".rb") == 0) {
- rb_thread_t th;
-
- while (st_lookup(loading_tbl, f, &th)) {
- if (th == curr_thread) {
- return Qtrue;
- }
- CHECK_INTS;
- rb_thread_schedule();
- }
+ for (i = 0; i < RARRAY(rb_features)->len; ++i) {
+ v = RARRAY(rb_features)->ptr[i];
+ f = StringValuePtr(v);
+ if (strncmp(f, feature, len) != 0) continue;
+ if (!*(e = f + len)) {
+ if (ext) continue;
+ return e;
+ }
+ if (*e != '.') continue;
+ if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
+ return e;
+ }
+ if ((rb || !ext) && (strcmp(e, ".rb") == 0)) {
+ return e;
}
}
- return Qtrue;
+ return 0;
}
+static const char *const loadable_ext[] = {
+ ".rb", DLEXT,
+#ifdef DLEXT2
+ DLEXT2,
+#endif
+ 0
+};
+
int
rb_provided(feature)
const char *feature;
{
- return rb_feature_p(feature, Qfalse);
+ int i;
+ char *buf;
+
+ if (rb_feature_p(feature, 0, Qfalse))
+ return Qtrue;
+ if (!loading_tbl) return Qfalse;
+ if (st_lookup(loading_tbl, (st_data_t)feature, 0)) return Qtrue;
+ buf = ALLOCA_N(char, strlen(feature)+8);
+ strcpy(buf, feature);
+ for (i=0; ; i++) {
+ if (!loadable_ext[i]) break;
+ strcpy(buf+strlen(feature), loadable_ext[i]);
+ if (st_lookup(loading_tbl, (st_data_t)buf, 0)) return Qtrue;
+ }
+ return Qfalse;
+}
+
+static void
+rb_provide_feature(feature)
+ VALUE feature;
+{
+ rb_ary_push(rb_features, feature);
}
void
rb_provide(feature)
const char *feature;
{
- char *buf, *ext;
-
- ext = strrchr(feature, '.');
- if (ext && (strcmp(DLEXT, ext) == 0
-#ifdef DLEXT2
- || strcmp(DLEXT2, ext) == 0
-#endif
- )) {
- buf = ALLOCA_N(char, strlen(feature)+4);
- strcpy(buf, feature);
- ext = strrchr(buf, '.');
- strcpy(ext, ".so");
- feature = buf;
- }
- if (rb_feature_p(feature, Qtrue)) return;
- rb_ary_push(rb_features, rb_str_new2(feature));
+ rb_provide_feature(rb_str_new2(feature));
}
+static void
+load_wait(ftptr)
+ char *ftptr;
+{
+ st_data_t th;
+
+ if (!loading_tbl) return;
+ if (!st_lookup(loading_tbl, (st_data_t)ftptr, &th)) return;
+ if ((rb_thread_t)th == curr_thread) return;
+ do {
+ CHECK_INTS;
+ rb_thread_schedule();
+ } while (st_lookup(loading_tbl, (st_data_t)ftptr, &th));
+}
+
+/*
+ * call-seq:
+ * require(string) => true or false
+ *
+ * Ruby tries to load the library named _string_, returning
+ * +true+ if successful. If the filename does not resolve to
+ * an absolute path, it will be searched for in the directories listed
+ * in <code>$:</code>. If the file has the extension ``.rb'', it is
+ * loaded as a source file; if the extension is ``.so'', ``.o'', or
+ * ``.dll'', or whatever the default shared library extension is on
+ * the current platform, Ruby loads the shared library as a Ruby
+ * extension. Otherwise, Ruby tries adding ``.rb'', ``.so'', and so on
+ * to the name. The name of the loaded feature is added to the array in
+ * <code>$"</code>. A feature will not be loaded if it's name already
+ * appears in <code>$"</code>. However, the file name is not converted
+ * to an absolute path, so that ``<code>require 'a';require
+ * './a'</code>'' will load <code>a.rb</code> twice.
+ *
+ * require "my-library.rb"
+ * require "db-driver"
+ */
+
VALUE
rb_f_require(obj, fname)
VALUE obj, fname;
{
- char *ext, *file, *feature, *buf; /* OK */
- volatile VALUE load;
- int state;
- volatile int safe = ruby_safe_level;
+ return rb_require_safe(fname, ruby_safe_level);
+}
- Check_SafeStr(fname);
- if (rb_feature_p(RSTRING(fname)->ptr, Qtrue))
- return Qfalse;
- ext = strrchr(RSTRING(fname)->ptr, '.');
- if (ext) {
- feature = file = RSTRING(fname)->ptr;
+static int
+search_required(fname, featurep, path)
+ VALUE fname, *featurep, *path;
+{
+ VALUE tmp;
+ char *ext, *ftptr;
+ int type;
+
+ *featurep = fname;
+ *path = 0;
+ ext = strrchr(ftptr = RSTRING(fname)->ptr, '.');
+ if (ext && !strchr(ext, '/')) {
if (strcmp(".rb", ext) == 0) {
- file = rb_find_file(file);
- if (file) goto load_rb;
- }
- else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) {
- if (strcmp(ext, DLEXT) != 0) {
- buf = ALLOCA_N(char, strlen(file)+sizeof(DLEXT)+4);
- strcpy(buf, feature);
- ext = strrchr(buf, '.');
- strcpy(ext, DLEXT);
- file = feature = buf;
- }
- file = rb_find_file(file);
- if (file) goto load_dyna;
+ if (rb_feature_p(ftptr, ext, Qtrue)) return 'r';
+ if (*path = rb_find_file(fname)) return 'r';
+ return 0;
+ }
+ else if (IS_SOEXT(ext)) {
+ if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
+ tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
+ *featurep = tmp;
#ifdef DLEXT2
- file = feature = RSTRING(fname)->ptr;
- if (strcmp(ext, DLEXT2) != 0) {
- buf = ALLOCA_N(char, strlen(file)+sizeof(DLEXT2)+4);
- strcpy(buf, feature);
- ext = strrchr(buf, '.');
- strcpy(ext, DLEXT2);
- file = feature = buf;
- }
- file = rb_find_file(file);
- if (file) goto load_dyna;
+ OBJ_FREEZE(tmp);
+ if (rb_find_file_ext(&tmp, loadable_ext+1)) {
+ *featurep = tmp;
+ *path = rb_find_file(tmp);
+ return 's';
+ }
+#else
+ rb_str_cat2(tmp, DLEXT);
+ OBJ_FREEZE(tmp);
+ if (*path = rb_find_file(tmp)) {
+ return 's';
+ }
#endif
}
- else if (strcmp(DLEXT, ext) == 0) {
- feature = RSTRING(fname)->ptr;
- file = rb_find_file(feature);
- if (file) goto load_dyna;
+ else if (IS_DLEXT(ext)) {
+ if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
+ if (*path = rb_find_file(fname)) return 's';
}
-#ifdef DLEXT2
- else if (strcmp(DLEXT2, ext) == 0) {
- feature = RSTRING(fname)->ptr;
- file = rb_find_file(feature);
- if (file) goto load_dyna;
- }
-#endif
}
- buf = ALLOCA_N(char, strlen(RSTRING(fname)->ptr) + 5);
- strcpy(buf, RSTRING(fname)->ptr);
- strcat(buf, ".rb");
- if (rb_find_file(buf)) {
- fname = rb_str_new2(buf);
- feature = buf;
- goto load_rb;
- }
- strcpy(buf, RSTRING(fname)->ptr);
- strcat(buf, DLEXT);
- file = rb_find_file(buf);
- if (file) {
- feature = buf;
- goto load_dyna;
- }
-#ifdef DLEXT2
- strcpy(buf, RSTRING(fname)->ptr);
- strcat(buf, DLEXT2);
- file = rb_find_file(buf);
- if (file) {
- feature = buf;
- goto load_dyna;
+ tmp = fname;
+ switch (type = rb_find_file_ext(&tmp, loadable_ext)) {
+ case 0:
+ if ((ext = rb_feature_p(ftptr, 0, Qfalse))) {
+ type = strcmp(".rb", ext);
+ break;
+ }
+ return 0;
+
+ default:
+ *featurep = tmp;
+ ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
+ if (rb_feature_p(ftptr, ext, !--type)) break;
+ *path = rb_find_file(tmp);
}
-#endif
- rb_raise(rb_eLoadError, "No such file to load -- %s",
- RSTRING(fname)->ptr);
+ return type ? 's' : 'r';
+}
- load_dyna:
- rb_provide(feature);
+static void
+load_failed(fname)
+ VALUE fname;
+{
+ rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
+}
+VALUE
+rb_require_safe(fname, safe)
+ VALUE fname;
+ int safe;
+{
+ VALUE result = Qnil;
+ volatile VALUE errinfo = ruby_errinfo;
+ int state;
+ struct {
+ NODE *node;
+ ID func;
+ int vmode, safe;
+ } volatile saved;
+ char *volatile ftptr = 0;
+
+ if (OBJ_TAINTED(fname)) {
+ rb_check_safe_obj(fname);
+ }
+ StringValue(fname);
+ fname = rb_str_new4(fname);
+ saved.vmode = scope_vmode;
+ saved.node = ruby_current_node;
+ saved.func = ruby_frame->last_func;
+ saved.safe = ruby_safe_level;
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- void *handle;
+ VALUE feature, path;
+ long handle;
+ int found;
- load = rb_str_new2(file);
- file = RSTRING(load)->ptr;
- handle = dln_load(file);
- rb_ary_push(ruby_dln_librefs, INT2NUM((long)handle));
- }
- POP_TAG();
- if (state) JUMP_TAG(state);
-
- return Qtrue;
-
- load_rb:
- ruby_safe_level = 0;
- rb_provide(feature);
- /* loading ruby library should be serialized. */
- if (!loading_tbl) {
- loading_tbl = st_init_strtable();
- }
- /* partial state */
- st_insert(loading_tbl, strdup(feature), curr_thread);
+ ruby_safe_level = safe;
+ found = search_required(fname, &feature, &path);
+ if (found) {
+ if (!path) {
+ load_wait(RSTRING(feature)->ptr);
+ result = Qfalse;
+ }
+ else {
+ ruby_safe_level = 0;
+ rb_provide_feature(feature);
+ switch (found) {
+ case 'r':
+ /* loading ruby library should be serialized. */
+ if (!loading_tbl) {
+ loading_tbl = st_init_strtable();
+ }
+ /* partial state */
+ ftptr = ruby_strdup(RSTRING(feature)->ptr);
+ st_insert(loading_tbl, (st_data_t)ftptr, (st_data_t)curr_thread);
+ rb_load(path, 0);
+ break;
- PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
- rb_load(fname, 0);
+ case 's':
+ ruby_current_node = 0;
+ ruby_sourcefile = rb_source_filename(RSTRING(path)->ptr);
+ ruby_sourceline = 0;
+ ruby_frame->last_func = 0;
+ SCOPE_SET(SCOPE_PUBLIC);
+ handle = (long)dln_load(RSTRING(path)->ptr);
+ rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
+ break;
+ }
+ result = Qtrue;
+ }
+ }
}
POP_TAG();
- st_delete(loading_tbl, &feature, 0); /* loading done */
- free(feature);
- ruby_safe_level = safe;
+ ruby_current_node = saved.node;
+ ruby_set_current_source();
+ ruby_frame->last_func = saved.func;
+ SCOPE_SET(saved.vmode);
+ ruby_safe_level = saved.safe;
+ if (ftptr) {
+ if (st_delete(loading_tbl, (st_data_t *)&ftptr, 0)) { /* loading done */
+ free(ftptr);
+ }
+ }
if (state) JUMP_TAG(state);
+ if (NIL_P(result)) {
+ load_failed(fname);
+ }
+ ruby_errinfo = errinfo;
- return Qtrue;
+ return result;
}
VALUE
rb_require(fname)
const char *fname;
{
- return rb_f_require(Qnil, rb_str_new2(fname));
+ VALUE fn = rb_str_new2(fname);
+ OBJ_FREEZE(fn);
+ return rb_require_safe(fn, ruby_safe_level);
}
static void
secure_visibility(self)
VALUE self;
{
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
+ if (ruby_safe_level >= 4 && !OBJ_TAINTED(self)) {
rb_raise(rb_eSecurityError, "Insecure: can't change method visibility");
}
}
@@ -5442,8 +6855,19 @@ set_method_visibility(self, argc, argv, ex)
for (i=0; i<argc; i++) {
rb_export_method(self, rb_to_id(argv[i]), ex);
}
+ rb_clear_cache_by_class(self);
}
+/*
+ * call-seq:
+ * public => self
+ * public(symbol, ...) => self
+ *
+ * With no arguments, sets the default visibility for subsequently
+ * defined methods to public. With arguments, sets the named methods to
+ * have public visibility.
+ */
+
static VALUE
rb_mod_public(argc, argv, module)
int argc;
@@ -5460,6 +6884,16 @@ rb_mod_public(argc, argv, module)
return module;
}
+/*
+ * call-seq:
+ * protected => self
+ * protected(symbol, ...) => self
+ *
+ * With no arguments, sets the default visibility for subsequently
+ * defined methods to protected. With arguments, sets the named methods
+ * to have protected visibility.
+ */
+
static VALUE
rb_mod_protected(argc, argv, module)
int argc;
@@ -5476,6 +6910,25 @@ rb_mod_protected(argc, argv, module)
return module;
}
+/*
+ * call-seq:
+ * private => self
+ * private(symbol, ...) => self
+ *
+ * With no arguments, sets the default visibility for subsequently
+ * defined methods to private. With arguments, sets the named methods
+ * to have private visibility.
+ *
+ * module Mod
+ * def a() end
+ * def b() end
+ * private
+ * def c() end
+ * private :a
+ * end
+ * Mod.private_instance_methods #=> ["a", "c"]
+ */
+
static VALUE
rb_mod_private(argc, argv, module)
int argc;
@@ -5492,6 +6945,13 @@ rb_mod_private(argc, argv, module)
return module;
}
+/*
+ * call-seq:
+ * mod.public_class_method(symbol, ...) => mod
+ *
+ * Makes a list of existing class methods public.
+ */
+
static VALUE
rb_mod_public_method(argc, argv, obj)
int argc;
@@ -5502,6 +6962,22 @@ rb_mod_public_method(argc, argv, obj)
return obj;
}
+/*
+ * call-seq:
+ * mod.private_class_method(symbol, ...) => mod
+ *
+ * Makes existing class methods private. Often used to hide the default
+ * constructor <code>new</code>.
+ *
+ * class SimpleSingleton # Not thread safe
+ * private_class_method :new
+ * def SimpleSingleton.create(*args, &block)
+ * @me = new(*args, &block) if ! @me
+ * @me
+ * end
+ * end
+ */
+
static VALUE
rb_mod_private_method(argc, argv, obj)
int argc;
@@ -5512,6 +6988,16 @@ rb_mod_private_method(argc, argv, obj)
return obj;
}
+/*
+ * call-seq:
+ * public
+ * public(symbol, ...)
+ *
+ * With no arguments, sets the default visibility for subsequently
+ * defined methods to public. With arguments, sets the named methods to
+ * have public visibility.
+ */
+
static VALUE
top_public(argc, argv)
int argc;
@@ -5528,6 +7014,42 @@ top_private(argc, argv)
return rb_mod_private(argc, argv, rb_cObject);
}
+/*
+ * call-seq:
+ * module_function(symbol, ...) => self
+ *
+ * Creates module functions for the named methods. These functions may
+ * be called with the module as a receiver, and also become available
+ * as instance methods to classes that mix in the module. Module
+ * functions are copies of the original, and so may be changed
+ * independently. The instance-method versions are made private. If
+ * used with no arguments, subsequently defined methods become module
+ * functions.
+ *
+ * module Mod
+ * def one
+ * "This is one"
+ * end
+ * module_function :one
+ * end
+ * class Cls
+ * include Mod
+ * def callOne
+ * one
+ * end
+ * end
+ * Mod.one #=> "This is one"
+ * c = Cls.new
+ * c.callOne #=> "This is one"
+ * module Mod
+ * def one
+ * "This is the new one"
+ * end
+ * end
+ * Mod.one #=> "This is one"
+ * c.callOne #=> "This is the new one"
+ */
+
static VALUE
rb_mod_modfunc(argc, argv, module)
int argc;
@@ -5550,18 +7072,40 @@ rb_mod_modfunc(argc, argv, module)
set_method_visibility(module, argc, argv, NOEX_PRIVATE);
for (i=0; i<argc; i++) {
+ VALUE m = module;
+
id = rb_to_id(argv[i]);
- body = search_method(module, id, 0);
- if (body == 0 || body->nd_body == 0) {
- rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
+ for (;;) {
+ body = search_method(m, id, &m);
+ if (body == 0) {
+ body = search_method(rb_cObject, id, &m);
+ }
+ if (body == 0 || body->nd_body == 0) {
+ rb_bug("undefined method `%s'; can't happen", rb_id2name(id));
+ }
+ if (nd_type(body->nd_body) != NODE_ZSUPER) {
+ break; /* normal case: need not to follow 'super' link */
+ }
+ m = RCLASS(m)->super;
+ if (!m) break;
}
rb_add_method(rb_singleton_class(module), id, body->nd_body, NOEX_PUBLIC);
- rb_clear_cache_by_id(id);
- rb_funcall(module, singleton_added, 1, ID2SYM(id));
}
return module;
}
+/*
+ * call-seq:
+ * append_features(mod) => mod
+ *
+ * When this module is included in another, Ruby calls
+ * <code>append_features</code> in this module, passing it the
+ * receiving module in _mod_. Ruby's default implementation is
+ * to add the constants, methods, and module variables of this module
+ * to _mod_ if this module has not already been added to
+ * _mod_ or one of its ancestors. See also <code>Module#include</code>.
+ */
+
static VALUE
rb_mod_append_features(module, include)
VALUE module, include;
@@ -5579,6 +7123,13 @@ rb_mod_append_features(module, include)
return module;
}
+/*
+ * call-seq:
+ * include(module, ...) => self
+ *
+ * Invokes <code>Module.append_features</code> on each parameter in turn.
+ */
+
static VALUE
rb_mod_include(argc, argv, module)
int argc;
@@ -5587,9 +7138,10 @@ rb_mod_include(argc, argv, module)
{
int i;
- for (i=0; i<argc; i++) {
- Check_Type(argv[i], T_MODULE);
- rb_funcall(argv[i], rb_intern("append_features"), 1, module);
+ for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
+ while (argc--) {
+ rb_funcall(argv[argc], rb_intern("append_features"), 1, module);
+ rb_funcall(argv[argc], rb_intern("included"), 1, module);
}
return module;
}
@@ -5605,32 +7157,6 @@ rb_obj_call_init(obj, argc, argv)
POP_ITER();
}
-VALUE
-rb_class_new_instance(argc, argv, klass)
- int argc;
- VALUE *argv;
- VALUE klass;
-{
- VALUE obj;
-
- if (FL_TEST(klass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "can't create instance of virtual class");
- }
- obj = rb_obj_alloc(klass);
- rb_obj_call_init(obj, argc, argv);
-
- return obj;
-}
-
-static VALUE
-top_include(argc, argv)
- int argc;
- VALUE *argv;
-{
- rb_secure(4);
- return rb_mod_include(argc, argv, rb_cObject);
-}
-
void
rb_extend_object(obj, module)
VALUE obj, module;
@@ -5638,6 +7164,33 @@ rb_extend_object(obj, module)
rb_include_module(rb_singleton_class(obj), module);
}
+/*
+ * call-seq:
+ * extend_object(obj) => obj
+ *
+ * Extends the specified object by adding this module's constants and
+ * methods (which are added as singleton methods). This is the callback
+ * method used by <code>Object#extend</code>.
+ *
+ * module Picky
+ * def Picky.extend_object(o)
+ * if String === o
+ * puts "Can't add Picky to a String"
+ * else
+ * puts "Picky added to #{o.class}"
+ * super
+ * end
+ * end
+ * end
+ * (s = Array.new).extend Picky # Call Object.extend
+ * (s = "quick brown fox").extend Picky
+ *
+ * <em>produces:</em>
+ *
+ * Picky added to Array
+ * Can't add Picky to a String
+ */
+
static VALUE
rb_mod_extend_object(mod, obj)
VALUE mod, obj;
@@ -5646,6 +7199,31 @@ rb_mod_extend_object(mod, obj)
return obj;
}
+/*
+ * call-seq:
+ * obj.extend(module, ...) => obj
+ *
+ * Adds to _obj_ the instance methods from each module given as a
+ * parameter.
+ *
+ * module Mod
+ * def hello
+ * "Hello from Mod.\n"
+ * end
+ * end
+ *
+ * class Klass
+ * def hello
+ * "Hello from Klass.\n"
+ * end
+ * end
+ *
+ * k = Klass.new
+ * k.hello #=> "Hello from Klass.\n"
+ * k.extend(Mod) #=> #<Klass:0x401b3bc8>
+ * k.hello #=> "Hello from Mod.\n"
+ */
+
static VALUE
rb_obj_extend(argc, argv, obj)
int argc;
@@ -5655,15 +7233,39 @@ rb_obj_extend(argc, argv, obj)
int i;
if (argc == 0) {
- rb_raise(rb_eArgError, "wrong # of arguments(0 for 1)");
+ rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
}
for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
- for (i=0; i<argc; i++) {
- rb_funcall(argv[i], rb_intern("extend_object"), 1, obj);
+ while (argc--) {
+ rb_funcall(argv[argc], rb_intern("extend_object"), 1, obj);
+ rb_funcall(argv[argc], rb_intern("extended"), 1, obj);
}
return obj;
}
+/*
+ * call-seq:
+ * include(module, ...) => self
+ *
+ * Invokes <code>Module.append_features</code>
+ * on each parameter in turn. Effectively adds the methods and constants
+ * in each module to the receiver.
+ */
+
+static VALUE
+top_include(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ rb_secure(4);
+ if (ruby_wrapper) {
+ rb_warning("main#include in the wrapped load is effective only in wrapper module");
+ return rb_mod_include(argc, argv, ruby_wrapper);
+ }
+ return rb_mod_include(argc, argv, rb_cObject);
+}
+
VALUE rb_f_trace_var();
VALUE rb_f_untrace_var();
@@ -5698,6 +7300,19 @@ errat_setter(val, id, var)
set_backtrace(ruby_errinfo, val);
}
+/*
+ * call-seq:
+ * local_variables => array
+ *
+ * Returns the names of the current local variables.
+ *
+ * fred = 1
+ * for i in 1..10
+ * # ...
+ * end
+ * local_variables #=> ["fred", "i"]
+ */
+
static VALUE
rb_f_local_variables()
{
@@ -5710,14 +7325,14 @@ rb_f_local_variables()
if (tbl) {
n = *tbl++;
for (i=2; i<n; i++) { /* skip first 2 ($_ and $~) */
- if (tbl[i] == 0) continue; /* skip flip states */
+ if (!rb_is_local_id(tbl[i])) continue; /* skip flip states */
rb_ary_push(ary, rb_str_new2(rb_id2name(tbl[i])));
}
}
vars = ruby_dyna_vars;
while (vars) {
- if (vars->id) {
+ if (vars->id && rb_is_local_id(vars->id)) { /* skip $_, $~ and flip states */
rb_ary_push(ary, rb_str_new2(rb_id2name(vars->id)));
}
vars = vars->next;
@@ -5727,19 +7342,20 @@ rb_f_local_variables()
}
static VALUE rb_f_catch _((VALUE,VALUE));
-static VALUE rb_f_throw _((int,VALUE*)) NORETURN;
+NORETURN(static VALUE rb_f_throw _((int,VALUE*)));
struct end_proc_data {
void (*func)();
VALUE data;
+ int safe;
struct end_proc_data *next;
};
-static struct end_proc_data *end_procs, *ephemeral_end_procs;
+static struct end_proc_data *end_procs, *ephemeral_end_procs, *tmp_end_procs;
void
rb_set_end_proc(func, data)
- void (*func)();
+ void (*func) _((VALUE));
VALUE data;
{
struct end_proc_data *link = ALLOC(struct end_proc_data);
@@ -5750,6 +7366,7 @@ rb_set_end_proc(func, data)
link->next = *list;
link->func = func;
link->data = data;
+ link->safe = ruby_safe_level;
*list = link;
}
@@ -5768,8 +7385,15 @@ rb_mark_end_proc()
rb_gc_mark(link->data);
link = link->next;
}
+ link = tmp_end_procs;
+ while (link) {
+ rb_gc_mark(link->data);
+ link = link->next;
+ }
}
+static void call_end_proc _((VALUE data));
+
static void
call_end_proc(data)
VALUE data;
@@ -5777,9 +7401,10 @@ call_end_proc(data)
PUSH_ITER(ITER_NOT);
PUSH_FRAME();
ruby_frame->self = ruby_frame->prev->self;
+ ruby_frame->node = 0;
ruby_frame->last_func = 0;
ruby_frame->last_class = 0;
- proc_call(data, Qundef);
+ proc_invoke(data, rb_ary_new2(0), Qundef, 0);
POP_FRAME();
POP_ITER();
}
@@ -5789,17 +7414,41 @@ rb_f_END()
{
PUSH_FRAME();
ruby_frame->argc = 0;
- rb_set_end_proc(call_end_proc, rb_f_lambda());
+ ruby_frame->iter = ITER_CUR;
+ rb_set_end_proc(call_end_proc, rb_block_proc());
POP_FRAME();
}
+/*
+ * call-seq:
+ * at_exit { block } -> proc
+ *
+ * Converts _block_ to a +Proc+ object (and therefore
+ * binds it at the point of call) and registers it for execution when
+ * the program exits. If multiple handlers are registered, they are
+ * executed in reverse order of registration.
+ *
+ * def do_at_exit(str1)
+ * at_exit { print str1 }
+ * end
+ * at_exit { puts "cruel world" }
+ * do_at_exit("goodbye ")
+ * exit
+ *
+ * <em>produces:</em>
+ *
+ * goodbye cruel world
+ */
+
static VALUE
rb_f_at_exit()
{
VALUE proc;
- proc = rb_f_lambda();
-
+ if (!rb_block_given_p()) {
+ rb_raise(rb_eArgError, "called without a block");
+ }
+ proc = rb_block_proc();
rb_set_end_proc(call_end_proc, proc);
return proc;
}
@@ -5807,26 +7456,47 @@ rb_f_at_exit()
void
rb_exec_end_proc()
{
- struct end_proc_data *link;
+ struct end_proc_data *link, *tmp;
int status;
+ volatile int safe = ruby_safe_level;
- link = end_procs;
- while (link) {
- rb_protect((VALUE(*)())link->func, link->data, &status);
- if (status) {
- error_handle(status);
+ while (ephemeral_end_procs) {
+ tmp_end_procs = link = ephemeral_end_procs;
+ ephemeral_end_procs = 0;
+ while (link) {
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ ruby_safe_level = link->safe;
+ (*link->func)(link->data);
+ }
+ POP_TAG();
+ if (status) {
+ error_handle(status);
+ }
+ tmp = link;
+ tmp_end_procs = link = link->next;
+ free(tmp);
}
- link = link->next;
}
- while (ephemeral_end_procs) {
- link = ephemeral_end_procs;
- ephemeral_end_procs = link->next;
- rb_protect((VALUE(*)())link->func, link->data, &status);
- if (status) {
- error_handle(status);
+ while (end_procs) {
+ tmp_end_procs = link = end_procs;
+ end_procs = 0;
+ while (link) {
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ ruby_safe_level = link->safe;
+ (*link->func)(link->data);
+ }
+ POP_TAG();
+ if (status) {
+ error_handle(status);
+ }
+ tmp = link;
+ tmp_end_procs = link = link->next;
+ free(tmp);
}
- free(link);
}
+ ruby_safe_level = safe;
}
void
@@ -5839,10 +7509,13 @@ Init_eval()
aref = rb_intern("[]");
aset = rb_intern("[]=");
match = rb_intern("=~");
- to_ary = rb_intern("to_ary");
missing = rb_intern("method_missing");
added = rb_intern("method_added");
singleton_added = rb_intern("singleton_method_added");
+ removed = rb_intern("method_removed");
+ singleton_removed = rb_intern("singleton_method_removed");
+ undefined = rb_intern("method_undefined");
+ singleton_undefined = rb_intern("singleton_method_undefined");
__id__ = rb_intern("__id__");
__send__ = rb_intern("__send__");
@@ -5859,7 +7532,7 @@ Init_eval()
rb_define_global_function("eval", rb_f_eval, -1);
rb_define_global_function("iterator?", rb_f_block_given_p, 0);
rb_define_global_function("block_given?", rb_f_block_given_p, 0);
- rb_define_global_function("method_missing", rb_f_missing, -1);
+ rb_define_global_function("method_missing", rb_method_missing, -1);
rb_define_global_function("loop", rb_f_loop, 0);
rb_define_method(rb_mKernel, "respond_to?", rb_obj_respond_to, -1);
@@ -5870,13 +7543,13 @@ Init_eval()
rb_define_global_function("caller", rb_f_caller, -1);
rb_define_global_function("exit", rb_f_exit, -1);
- rb_define_global_function("abort", rb_f_abort, 0);
+ rb_define_global_function("abort", rb_f_abort, -1);
rb_define_global_function("at_exit", rb_f_at_exit, 0);
rb_define_global_function("catch", rb_f_catch, 1);
rb_define_global_function("throw", rb_f_throw, -1);
- rb_define_global_function("global_variables", rb_f_global_variables, 0);
+ rb_define_global_function("global_variables", rb_f_global_variables, 0); /* in variable.c */
rb_define_global_function("local_variables", rb_f_local_variables, 0);
rb_define_method(rb_mKernel, "send", rb_f_send, -1);
@@ -5891,6 +7564,9 @@ Init_eval()
rb_define_private_method(rb_cModule, "private", rb_mod_private, -1);
rb_define_private_method(rb_cModule, "module_function", rb_mod_modfunc, -1);
rb_define_method(rb_cModule, "method_defined?", rb_mod_method_defined, 1);
+ rb_define_method(rb_cModule, "public_method_defined?", rb_mod_public_method_defined, 1);
+ rb_define_method(rb_cModule, "private_method_defined?", rb_mod_private_method_defined, 1);
+ rb_define_method(rb_cModule, "protected_method_defined?", rb_mod_protected_method_defined, 1);
rb_define_method(rb_cModule, "public_class_method", rb_mod_public_method, -1);
rb_define_method(rb_cModule, "private_class_method", rb_mod_private_method, -1);
rb_define_method(rb_cModule, "module_eval", rb_mod_module_eval, -1);
@@ -5898,8 +7574,8 @@ Init_eval()
rb_undef_method(rb_cClass, "module_function");
- rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, 1);
- rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, 1);
+ rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1);
+ rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1);
rb_define_private_method(rb_cModule, "alias_method", rb_mod_alias_method, 2);
rb_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1);
@@ -5912,29 +7588,86 @@ Init_eval()
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
- rb_define_global_function("trace_var", rb_f_trace_var, -1);
- rb_define_global_function("untrace_var", rb_f_untrace_var, -1);
+ rb_define_global_function("trace_var", rb_f_trace_var, -1); /* in variable.c */
+ rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
rb_define_global_function("set_trace_func", set_trace_func, 1);
rb_global_variable(&trace_func);
rb_define_virtual_variable("$SAFE", safe_getter, safe_setter);
+}
-#ifdef HAVE_GETRLIMIT
- {
- struct rlimit rlim;
+/*
+ * call-seq:
+ * mod.autoload(name, filename) => nil
+ *
+ * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
+ * the first time that _module_ (which may be a <code>String</code> or
+ * a symbol) is accessed in the namespace of _mod_.
+ *
+ * module A
+ * end
+ * A.autoload(:B, "b")
+ * A::B.doit # autoloads "b"
+ */
+
+static VALUE
+rb_mod_autoload(mod, sym, file)
+ VALUE mod;
+ VALUE sym;
+ VALUE file;
+{
+ ID id = rb_to_id(sym);
- if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
- double space = (double)rlim.rlim_cur*0.2;
+ Check_SafeStr(file);
+ rb_autoload(mod, id, RSTRING(file)->ptr);
+ return Qnil;
+}
- if (space > 1024*1024) space = 1024*1024;
- STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
- }
- }
-#endif
+/*
+ * MISSING: documentation
+ */
+
+static VALUE
+rb_mod_autoload_p(mod, sym)
+ VALUE mod, sym;
+{
+ return rb_autoload_p(mod, rb_to_id(sym));
}
-VALUE rb_f_autoload();
+/*
+ * call-seq:
+ * autoload(module, filename) => nil
+ *
+ * Registers _filename_ to be loaded (using <code>Kernel::require</code>)
+ * the first time that _module_ (which may be a <code>String</code> or
+ * a symbol) is accessed.
+ *
+ * autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
+ */
+
+static VALUE
+rb_f_autoload(obj, sym, file)
+ VALUE obj;
+ VALUE sym;
+ VALUE file;
+{
+ return rb_mod_autoload(ruby_cbase, sym, file);
+}
+
+
+/*
+ * MISSING: documentation
+ */
+
+static VALUE
+rb_f_autoload_p(obj, sym)
+ VALUE obj;
+ VALUE sym;
+{
+ /* use ruby_cbase as same as rb_f_autoload. */
+ return rb_mod_autoload_p(ruby_cbase, sym);
+}
void
Init_load()
@@ -5946,10 +7679,14 @@ Init_load()
rb_features = rb_ary_new();
rb_define_readonly_variable("$\"", &rb_features);
+ rb_define_readonly_variable("$LOADED_FEATURES", &rb_features);
rb_define_global_function("load", rb_f_load, -1);
rb_define_global_function("require", rb_f_require, 1);
- rb_define_global_function("autoload", rb_f_autoload, 2);
+ rb_define_method(rb_cModule, "autoload", rb_mod_autoload, 2);
+ rb_define_method(rb_cModule, "autoload?", rb_mod_autoload_p, 1);
+ rb_define_global_function("autoload", rb_f_autoload, 2);
+ rb_define_global_function("autoload?", rb_f_autoload_p, 1);
rb_global_variable(&ruby_wrapper);
ruby_dln_librefs = rb_ary_new();
@@ -5963,8 +7700,8 @@ scope_dup(scope)
ID *tbl;
VALUE *vars;
- scope->flag |= SCOPE_DONT_RECYCLE;
- if (scope->flag & SCOPE_MALLOC) return;
+ scope->flags |= SCOPE_DONT_RECYCLE;
+ if (scope->flags & SCOPE_MALLOC) return;
if (scope->local_tbl) {
tbl = scope->local_tbl;
@@ -5972,7 +7709,7 @@ scope_dup(scope)
*vars++ = scope->local_vars[-1];
MEMCPY(vars, scope->local_vars, VALUE, tbl[0]);
scope->local_vars = vars;
- scope->flag |= SCOPE_MALLOC;
+ scope->flags |= SCOPE_MALLOC;
}
}
@@ -5982,25 +7719,27 @@ blk_mark(data)
{
while (data) {
rb_gc_mark_frame(&data->frame);
- rb_gc_mark(data->scope);
- rb_gc_mark(data->var);
- rb_gc_mark(data->body);
- rb_gc_mark(data->self);
- rb_gc_mark(data->dyna_vars);
- rb_gc_mark(data->klass);
- rb_gc_mark(data->tag);
+ rb_gc_mark((VALUE)data->scope);
+ rb_gc_mark((VALUE)data->var);
+ rb_gc_mark((VALUE)data->body);
+ rb_gc_mark((VALUE)data->self);
+ rb_gc_mark((VALUE)data->dyna_vars);
+ rb_gc_mark((VALUE)data->cref);
+ rb_gc_mark(data->wrapper);
+ rb_gc_mark(data->block_obj);
data = data->prev;
}
}
static void
-blk_free(data)
- struct BLOCK *data;
-{
+frame_free(frame)
struct FRAME *frame;
- void *tmp;
+{
+ struct FRAME *tmp;
- frame = data->frame.prev;
+ if (frame->argc > 0 && (frame->flags & FRAME_MALLOC))
+ free(frame->argv);
+ frame = frame->prev;
while (frame) {
if (frame->argc > 0 && (frame->flags & FRAME_MALLOC))
free(frame->argv);
@@ -6008,9 +7747,16 @@ blk_free(data)
frame = frame->prev;
free(tmp);
}
+}
+
+static void
+blk_free(data)
+ struct BLOCK *data;
+{
+ void *tmp;
+
while (data) {
- if (data->frame.argc > 0)
- free(data->frame.argv);
+ frame_free(&data->frame);
tmp = data;
data = data->prev;
free(tmp);
@@ -6018,6 +7764,30 @@ blk_free(data)
}
static void
+frame_dup(frame)
+ struct FRAME *frame;
+{
+ VALUE *argv;
+ struct FRAME *tmp;
+
+ for (;;) {
+ if (frame->argc > 0) {
+ argv = ALLOC_N(VALUE, frame->argc);
+ MEMCPY(argv, frame->argv, VALUE, frame->argc);
+ frame->argv = argv;
+ frame->flags |= FRAME_MALLOC;
+ }
+ frame->tmp = 0; /* should not preserve tmp */
+ if (!frame->prev) break;
+ tmp = ALLOC(struct FRAME);
+ *tmp = *frame->prev;
+ frame->prev = tmp;
+ frame = tmp;
+ }
+}
+
+
+static void
blk_copy_prev(block)
struct BLOCK *block;
{
@@ -6027,12 +7797,8 @@ blk_copy_prev(block)
while (block->prev) {
tmp = ALLOC_N(struct BLOCK, 1);
MEMCPY(tmp, block->prev, struct BLOCK, 1);
- if (tmp->frame.argc > 0) {
- tmp->frame.argv = ALLOC_N(VALUE, tmp->frame.argc);
- MEMCPY(tmp->frame.argv, block->prev->frame.argv, VALUE, tmp->frame.argc);
- }
scope_dup(tmp->scope);
- tmp->tag->flags |= BLOCK_DYNAMIC;
+ frame_dup(&tmp->frame);
for (vars = tmp->dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
@@ -6044,52 +7810,75 @@ blk_copy_prev(block)
}
}
+
static void
-frame_dup(frame)
- struct FRAME *frame;
+blk_dup(dup, orig)
+ struct BLOCK *dup, *orig;
{
- VALUE *argv;
- struct FRAME *tmp;
+ MEMCPY(dup, orig, struct BLOCK, 1);
+ frame_dup(&dup->frame);
- for (;;) {
- if (frame->argc > 0) {
- argv = ALLOC_N(VALUE, frame->argc);
- MEMCPY(argv, frame->argv, VALUE, frame->argc);
- frame->argv = argv;
- frame->flags = FRAME_MALLOC;
- }
- frame->tmp = 0; /* should not preserve tmp */
- if (!frame->prev) break;
- tmp = ALLOC(struct FRAME);
- *tmp = *frame->prev;
- frame->prev = tmp;
- frame = tmp;
+ if (dup->iter) {
+ blk_copy_prev(dup);
+ }
+ else {
+ dup->prev = 0;
}
}
+/*
+ * MISSING: documentation
+ */
+
static VALUE
-bind_clone(self)
+proc_clone(self)
VALUE self;
{
struct BLOCK *orig, *data;
VALUE bind;
Data_Get_Struct(self, struct BLOCK, orig);
- bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
+ bind = Data_Make_Struct(rb_obj_class(self),struct BLOCK,blk_mark,blk_free,data);
CLONESETUP(bind, self);
- MEMCPY(data, orig, struct BLOCK, 1);
- frame_dup(&data->frame);
+ blk_dup(data, orig);
- if (data->iter) {
- blk_copy_prev(data);
- }
- else {
- data->prev = 0;
- }
+ return bind;
+}
+
+/*
+ * MISSING: documentation
+ */
+
+static VALUE
+proc_dup(self)
+ VALUE self;
+{
+ struct BLOCK *orig, *data;
+ VALUE bind;
+
+ Data_Get_Struct(self, struct BLOCK, orig);
+ bind = Data_Make_Struct(rb_obj_class(self),struct BLOCK,blk_mark,blk_free,data);
+ blk_dup(data, orig);
return bind;
}
+/*
+ * call-seq:
+ * binding -> a_binding
+ *
+ * Returns a +Binding+ object, describing the variable and
+ * method bindings at the point of call. This object can be used when
+ * calling +eval+ to execute the evaluated command in this
+ * environment. Also see the description of class +Binding+.
+ *
+ * def getBinding(param)
+ * return binding
+ * end
+ * b = getBinding("hello")
+ * eval("param", b) #=> "hello"
+ */
+
static VALUE
rb_f_binding(self)
VALUE self;
@@ -6103,6 +7892,7 @@ rb_f_binding(self)
*data = *ruby_block;
data->orig_thread = rb_thread_current();
+ data->wrapper = ruby_wrapper;
data->iter = rb_f_block_given_p();
frame_dup(&data->frame);
if (ruby_frame->prev) {
@@ -6116,8 +7906,6 @@ rb_f_binding(self)
else {
data->prev = 0;
}
- data->flags |= BLOCK_DYNAMIC;
- data->tag->flags |= BLOCK_DYNAMIC;
for (p = data; p; p = p->prev) {
for (vars = p->dyna_vars; vars; vars = vars->next) {
@@ -6131,68 +7919,61 @@ rb_f_binding(self)
return bind;
}
-#define PROC_T3 FL_USER1
-#define PROC_T4 FL_USER2
-#define PROC_TMAX (FL_USER1|FL_USER2)
-#define PROC_TMASK (FL_USER1|FL_USER2)
+#define PROC_TSHIFT (FL_USHIFT+1)
+#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
+#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
+
+#define SAFE_LEVEL_MAX PROC_TMASK
static void
proc_save_safe_level(data)
VALUE data;
{
- if (OBJ_TAINTED(data)) {
- switch (rb_safe_level()) {
- case 3:
- FL_SET(data, PROC_T3);
- break;
- case 4:
- FL_SET(data, PROC_T4);
- break;
- default:
- if (rb_safe_level() > 4) {
- FL_SET(data, PROC_TMAX);
- }
- break;
- }
- }
+ int safe = ruby_safe_level;
+ if (safe > PROC_TMAX) safe = PROC_TMAX;
+ FL_SET(data, (safe << PROC_TSHIFT) & PROC_TMASK);
+}
+
+static int
+proc_get_safe_level(data)
+ VALUE data;
+{
+ return (RBASIC(data)->flags & PROC_TMASK) >> PROC_TSHIFT;
}
static void
proc_set_safe_level(data)
VALUE data;
{
- if (OBJ_TAINTED(data)) {
- switch (RBASIC(data)->flags & PROC_TMASK) {
- case PROC_T3:
- ruby_safe_level = 3;
- break;
- case PROC_T4:
- ruby_safe_level = 4;
- break;
- case PROC_TMAX:
- ruby_safe_level = 5;
- break;
- }
- }
+ ruby_safe_level = proc_get_safe_level(data);
}
static VALUE
-proc_new(klass)
+proc_alloc(klass, proc)
VALUE klass;
+ int proc;
{
- volatile VALUE proc;
+ volatile VALUE block;
struct BLOCK *data, *p;
struct RVarmap *vars;
if (!rb_block_given_p() && !rb_f_block_given_p()) {
rb_raise(rb_eArgError, "tried to create Proc object without a block");
}
+ if (proc && !rb_block_given_p()) {
+ rb_warn("tried to create Proc object without a block");
+ }
- proc = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
+ if (!proc && ruby_block->block_obj && CLASS_OF(ruby_block->block_obj) == klass) {
+ return ruby_block->block_obj;
+ }
+ block = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
*data = *ruby_block;
data->orig_thread = rb_thread_current();
+ data->wrapper = ruby_wrapper;
data->iter = data->prev?Qtrue:Qfalse;
+ data->block_obj = block;
frame_dup(&data->frame);
if (data->iter) {
blk_copy_prev(data);
@@ -6200,8 +7981,6 @@ proc_new(klass)
else {
data->prev = 0;
}
- data->flags |= BLOCK_DYNAMIC;
- data->tag->flags |= BLOCK_DYNAMIC;
for (p = data; p; p = p->prev) {
for (vars = p->dyna_vars; vars; vars = vars->next) {
@@ -6210,35 +7989,79 @@ proc_new(klass)
}
}
scope_dup(data->scope);
- proc_save_safe_level(proc);
+ proc_save_safe_level(block);
+ if (proc) {
+ data->flags |= BLOCK_LAMBDA;
+ }
+ else {
+ ruby_block->block_obj = block;
+ }
- return proc;
+ return block;
}
+/*
+ * call-seq:
+ * Proc.new {|...| block } => a_proc
+ * Proc.new => a_proc
+ *
+ * Creates a new <code>Proc</code> object, bound to the current
+ * context. <code>Proc::new</code> may be called without a block only
+ * within a method with an attached block, in which case that block is
+ * converted to the <code>Proc</code> object.
+ *
+ * def proc_from
+ * Proc.new
+ * end
+ * proc = proc_from { "hello" }
+ * proc.call #=> "hello"
+ */
+
static VALUE
proc_s_new(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
- VALUE proc = proc_new(klass);
+ VALUE block = proc_alloc(klass, Qfalse);
- rb_obj_call_init(proc, argc, argv);
- return proc;
+ rb_obj_call_init(block, argc, argv);
+ return block;
+}
+
+VALUE
+rb_block_proc()
+{
+ return proc_alloc(rb_cProc, Qfalse);
}
VALUE
rb_f_lambda()
{
- return proc_new(rb_cProc);
+ rb_warn("rb_f_lambda() is deprecated; use rb_block_proc() instead");
+ return proc_alloc(rb_cProc, Qtrue);
+}
+
+/*
+ * call-seq:
+ * proc { |...| block } => a_proc
+ * lambda { |...| block } => a_proc
+ *
+ * Equivalent to <code>Proc.new</code>, except the resulting Proc objects
+ * check the number of parameters passed when called.
+ */
+
+static VALUE
+proc_lambda()
+{
+ return proc_alloc(rb_cProc, Qtrue);
}
static int
-blk_orphan(data)
+block_orphan(data)
struct BLOCK *data;
{
- if (data->scope && data->scope != top_scope &&
- (data->scope->flag & SCOPE_NOSTACK)) {
+ if (data->scope->flags & SCOPE_NOSTACK) {
return 1;
}
if (data->orig_thread != rb_thread_current()) {
@@ -6248,86 +8071,149 @@ blk_orphan(data)
}
static VALUE
-callargs(args)
- VALUE args;
-{
- switch (RARRAY(args)->len) {
- case 0:
- return Qundef;
- break;
- default:
- return args;
- }
-}
-
-static VALUE
-proc_call(proc, args)
+proc_invoke(proc, args, self, klass)
VALUE proc, args; /* OK */
+ VALUE self, klass;
{
struct BLOCK * volatile old_block;
struct BLOCK _block;
struct BLOCK *data;
- volatile VALUE result = Qnil;
+ volatile VALUE result = Qundef;
int state;
- volatile int orphan;
volatile int safe = ruby_safe_level;
+ volatile VALUE old_wrapper = ruby_wrapper;
+ volatile int pcall, avalue = Qtrue;
if (rb_block_given_p() && ruby_frame->last_func) {
+ if (klass != ruby_frame->last_class)
+ klass = rb_obj_class(proc);
rb_warning("block for %s#%s is useless",
- rb_class2name(CLASS_OF(proc)),
+ rb_class2name(klass),
rb_id2name(ruby_frame->last_func));
}
Data_Get_Struct(proc, struct BLOCK, data);
- orphan = blk_orphan(data);
+ pcall = (data->flags & BLOCK_LAMBDA) ? YIELD_LAMBDA_CALL : 0;
+ if (!pcall && RARRAY(args)->len == 1) {
+ avalue = Qfalse;
+ args = RARRAY(args)->ptr[0];
+ }
+ PUSH_VARS();
+ ruby_wrapper = data->wrapper;
+ ruby_dyna_vars = data->dyna_vars;
/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
+ if (self != Qundef) _block.frame.self = self;
+ if (klass) _block.frame.last_class = klass;
ruby_block = &_block;
- ruby_block->frame.iter = ITER_NOT;
PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR;
-
- if (args != Qundef && TYPE(args) == T_ARRAY) {
- args = callargs(args);
- }
-
- PUSH_TAG(PROT_NONE);
+ PUSH_TAG(pcall ? PROT_LAMBDA : PROT_NONE);
state = EXEC_TAG();
if (state == 0) {
proc_set_safe_level(proc);
- result = rb_yield_0(args, 0, 0, Qtrue);
+ result = rb_yield_0(args, self, (self!=Qundef)?CLASS_OF(self):0, pcall, avalue);
+ }
+ else if (TAG_DST()) {
+ result = prot_tag->retval;
}
POP_TAG();
-
POP_ITER();
- if (ruby_block->tag->dst == state) {
- state &= TAG_MASK;
- }
ruby_block = old_block;
+ ruby_wrapper = old_wrapper;
+ POP_VARS();
ruby_safe_level = safe;
- if (state) {
- switch (state) {
- case TAG_BREAK:
- break;
- case TAG_RETRY:
- rb_raise(rb_eLocalJumpError, "retry from proc-closure");
- break;
- case TAG_RETURN:
- if (orphan) { /* orphan procedure */
- rb_raise(rb_eLocalJumpError, "return from proc-closure");
- }
- /* fall through */
- default:
- JUMP_TAG(state);
+ switch (state) {
+ case 0:
+ break;
+ case TAG_RETRY:
+ proc_jump_error(TAG_RETRY, Qnil); /* xxx */
+ JUMP_TAG(state);
+ break;
+ case TAG_BREAK:
+ if (!pcall && result != Qundef) {
+ proc_jump_error(state, result);
+ }
+ case TAG_RETURN:
+ if (result != Qundef) {
+ if (pcall) break;
+ return_jump(result);
}
+ default:
+ JUMP_TAG(state);
}
return result;
}
+/* CHECKME: are the argument checking semantics correct? */
+
+/*
+ * call-seq:
+ * prc.call(params,...) => obj
+ * prc[params,...] => obj
+ *
+ * Invokes the block, setting the block's parameters to the values in
+ * <i>params</i> using something close to method calling semantics.
+ * Generates a warning if multiple values are passed to a proc that
+ * expects just one (previously this silently converted the parameters
+ * to an array).
+ *
+ * For procs created using <code>Kernel.proc</code>, generates an
+ * error if the wrong number of parameters
+ * are passed to a proc with multiple parameters. For procs created using
+ * <code>Proc.new</code>, extra parameters are silently discarded.
+ *
+ * Returns the value of the last expression evaluated in the block. See
+ * also <code>Proc#yield</code>.
+ *
+ * a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
+ * a_proc.call(9, 1, 2, 3) #=> [9, 18, 27]
+ * a_proc[9, 1, 2, 3] #=> [9, 18, 27]
+ * a_proc = Proc.new {|a,b| a}
+ * a_proc.call(1,2,3)
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError)
+ * from prog.rb:4:in `call'
+ * from prog.rb:5
+ */
+
+static VALUE
+proc_call(proc, args)
+ VALUE proc, args; /* OK */
+{
+ return proc_invoke(proc, args, Qundef, 0);
+}
+
+static VALUE bmcall _((VALUE, VALUE));
+static VALUE method_arity _((VALUE));
+
+/*
+ * call-seq:
+ * prc.arity -> fixnum
+ *
+ * Returns the number of arguments required by the block. If the block
+ * is declared to take no arguments, returns 0. If the block is known
+ * to take exactly n arguments, returns n. If the block has optional
+ * arguments, return -n-1, where n is the number of mandatory
+ * arguments. A <code>proc</code> with no argument declarations
+ * returns -1, as it can accept (and ignore) an arbitrary number of
+ * parameters.
+ *
+ * Proc.new {}.arity #=> -1
+ * Proc.new {||}.arity #=> 0
+ * Proc.new {|a|}.arity #=> 1
+ * Proc.new {|a,b|}.arity #=> 2
+ * Proc.new {|a,b,c|}.arity #=> 3
+ * Proc.new {|*a|}.arity #=> -1
+ * Proc.new {|a,*b|}.arity #=> -2
+ */
+
static VALUE
proc_arity(proc)
VALUE proc;
@@ -6337,11 +8223,18 @@ proc_arity(proc)
int n;
Data_Get_Struct(proc, struct BLOCK, data);
- if (data->var == 0) return INT2FIX(-1);
+ if (data->var == 0) {
+ if (data->body && nd_type(data->body) == NODE_IFUNC &&
+ data->body->nd_cfnc == bmcall) {
+ return method_arity(data->body->nd_tval);
+ }
+ return INT2FIX(-1);
+ }
if (data->var == (NODE*)1) return INT2FIX(0);
+ if (data->var == (NODE*)2) return INT2FIX(0);
switch (nd_type(data->var)) {
default:
- return INT2FIX(-1);
+ return INT2FIX(1);
case NODE_MASGN:
list = data->var->nd_head;
n = 0;
@@ -6354,6 +8247,14 @@ proc_arity(proc)
}
}
+/*
+ * call-seq:
+ * prc == other_proc => true or false
+ *
+ * Return <code>true</code> if <i>prc</i> is the same object as
+ * <i>other_proc</i>, or if they are both procs with the same body.
+ */
+
static VALUE
proc_eq(self, other)
VALUE self, other;
@@ -6366,33 +8267,113 @@ proc_eq(self, other)
if (CLASS_OF(self) != CLASS_OF(other)) return Qfalse;
Data_Get_Struct(self, struct BLOCK, data);
Data_Get_Struct(other, struct BLOCK, data2);
- if (data->tag == data2->tag) return Qtrue;
- return Qfalse;
+ if (data->body != data2->body) return Qfalse;
+ if (data->var != data2->var) return Qfalse;
+ if (data->scope != data2->scope) return Qfalse;
+ if (data->dyna_vars != data2->dyna_vars) return Qfalse;
+ if (data->flags != data2->flags) return Qfalse;
+
+ return Qtrue;
}
+/*
+ * call-seq:
+ * prc.to_s => string
+ *
+ * Shows the unique identifier for this proc, along with
+ * an indication of where the proc was defined.
+ */
+
static VALUE
-proc_to_s(self, other)
- VALUE self, other;
+proc_to_s(self)
+ VALUE self;
{
struct BLOCK *data;
- char *cname = rb_class2name(CLASS_OF(self));
+ NODE *node;
+ char *cname = rb_obj_classname(self);
+ const int w = (SIZEOF_LONG * CHAR_BIT) / 4;
+ long len = strlen(cname)+6+w; /* 6:tags 16:addr */
VALUE str;
Data_Get_Struct(self, struct BLOCK, data);
- str = rb_str_new(0, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:eos */
- sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", cname, data->tag);
+ if ((node = data->frame.node) || (node = data->body)) {
+ len += strlen(node->nd_file) + 2 + (SIZEOF_LONG*CHAR_BIT-NODE_LSHIFT)/3;
+ str = rb_str_new(0, len);
+ sprintf(RSTRING(str)->ptr, "#<%s:0x%.*lx@%s:%d>", cname, w, (VALUE)data->body,
+ node->nd_file, nd_line(node));
+ }
+ else {
+ str = rb_str_new(0, len);
+ sprintf(RSTRING(str)->ptr, "#<%s:0x%.*lx>", cname, w, (VALUE)data->body);
+ }
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(self)) OBJ_TAINT(str);
return str;
}
+/*
+ * call-seq:
+ * prc.to_proc -> prc
+ *
+ * Part of the protocol for converting objects to <code>Proc</code>
+ * objects. Instances of class <code>Proc</code> simply return
+ * themselves.
+ */
+
+static VALUE
+proc_to_self(self)
+ VALUE self;
+{
+ return self;
+}
+
+/*
+ * call-seq:
+ * prc.binding => binding
+ *
+ * Returns the binding associated with <i>prc</i>. Note that
+ * <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
+ * <code>Binding</code> object as its second parameter.
+ *
+ * def fred(param)
+ * proc {}
+ * end
+ *
+ * b = fred(99)
+ * eval("param", b.binding) #=> 99
+ * eval("param", b) #=> 99
+ */
+
+static VALUE
+proc_binding(proc)
+ VALUE proc;
+{
+ struct BLOCK *orig, *data;
+ VALUE bind;
+
+ Data_Get_Struct(proc, struct BLOCK, orig);
+ bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
+ MEMCPY(data, orig, struct BLOCK, 1);
+ frame_dup(&data->frame);
+
+ if (data->iter) {
+ blk_copy_prev(data);
+ }
+ else {
+ data->prev = 0;
+ }
+
+ return bind;
+}
+
static VALUE
block_pass(self, node)
VALUE self;
NODE *node;
{
- VALUE block = rb_eval(self, node->nd_body); /* OK */
+ VALUE proc = rb_eval(self, node->nd_body); /* OK */
+ VALUE b;
struct BLOCK * volatile old_block;
struct BLOCK _block;
struct BLOCK *data;
@@ -6401,71 +8382,75 @@ block_pass(self, node)
volatile int orphan;
volatile int safe = ruby_safe_level;
- if (NIL_P(block)) {
- return rb_eval(self, node->nd_iter);
+ if (NIL_P(proc)) {
+ PUSH_ITER(ITER_NOT);
+ result = rb_eval(self, node->nd_iter);
+ POP_ITER();
+ return result;
}
- if (rb_obj_is_kind_of(block, rb_cMethod)) {
- block = method_proc(block);
+ if (!rb_obj_is_proc(proc)) {
+ b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
+ if (!rb_obj_is_proc(b)) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
+ rb_obj_classname(proc));
+ }
+ proc = b;
}
- else if (!rb_obj_is_proc(block)) {
- rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
- rb_class2name(CLASS_OF(block)));
+
+ if (ruby_safe_level >= 1 && OBJ_TAINTED(proc)) {
+ if (ruby_safe_level > proc_get_safe_level(proc)) {
+ rb_raise(rb_eSecurityError, "Insecure: tainted block value");
+ }
}
- Data_Get_Struct(block, struct BLOCK, data);
- orphan = blk_orphan(data);
+ if (ruby_block && ruby_block->block_obj == proc) {
+ PUSH_ITER(ITER_PRE);
+ result = rb_eval(self, node->nd_iter);
+ POP_ITER();
+ return result;
+ }
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ orphan = block_orphan(data);
/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
+ _block.outer = ruby_block;
+ _block.uniq = block_unique++;
ruby_block = &_block;
PUSH_ITER(ITER_PRE);
- ruby_frame->iter = ITER_PRE;
+ if (ruby_frame->iter == ITER_NOT)
+ ruby_frame->iter = ITER_PRE;
- PUSH_TAG(PROT_NONE);
+ PUSH_TAG(PROT_LOOP);
state = EXEC_TAG();
if (state == 0) {
- proc_set_safe_level(block);
+ retry:
+ proc_set_safe_level(proc);
+ if (safe > ruby_safe_level)
+ ruby_safe_level = safe;
result = rb_eval(self, node->nd_iter);
}
+ else if (state == TAG_BREAK && TAG_DST()) {
+ result = prot_tag->retval;
+ state = 0;
+ }
+ else if (state == TAG_RETRY) {
+ state = 0;
+ goto retry;
+ }
POP_TAG();
POP_ITER();
- if (_block.tag->dst == state) {
- if (orphan) {
- state &= TAG_MASK;
- }
- else {
- struct BLOCK *ptr = old_block;
-
- while (ptr) {
- if (ptr->scope == _block.scope) {
- ptr->tag->dst = state;
- break;
- }
- ptr = ptr->prev;
- }
- if (!ptr) {
- state &= TAG_MASK;
- }
- }
- }
ruby_block = old_block;
ruby_safe_level = safe;
- switch (state) {/* escape from orphan procedure */
+ switch (state) {/* escape from orphan block */
case 0:
break;
- case TAG_BREAK:
- if (orphan) {
- rb_raise(rb_eLocalJumpError, "break from proc-closure");
- }
- break;
- case TAG_RETRY:
- rb_raise(rb_eLocalJumpError, "retry from proc-closure");
- break;
case TAG_RETURN:
if (orphan) {
- rb_raise(rb_eLocalJumpError, "return from proc-closure");
+ proc_jump_error(state, prot_tag->retval);
}
default:
JUMP_TAG(state);
@@ -6475,7 +8460,7 @@ block_pass(self, node)
}
struct METHOD {
- VALUE klass, oklass;
+ VALUE klass, rklass;
VALUE recv;
ID id, oid;
NODE *body;
@@ -6485,10 +8470,10 @@ static void
bm_mark(data)
struct METHOD *data;
{
- rb_gc_mark(data->oklass);
+ rb_gc_mark(data->rklass);
rb_gc_mark(data->klass);
rb_gc_mark(data->recv);
- rb_gc_mark(data->body);
+ rb_gc_mark((VALUE)data->body);
}
static VALUE
@@ -6500,12 +8485,12 @@ mnew(klass, obj, id, mklass)
NODE *body;
int noex;
struct METHOD *data;
- VALUE oklass = klass;
+ VALUE rklass = klass;
ID oid = id;
again:
if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
- print_undef(oklass, oid);
+ print_undef(rklass, oid);
}
if (nd_type(body) == NODE_ZSUPER) {
@@ -6513,18 +8498,87 @@ mnew(klass, obj, id, mklass)
goto again;
}
+ while (rklass != klass &&
+ (FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) {
+ rklass = RCLASS(rklass)->super;
+ }
+ if (TYPE(klass) == T_ICLASS) klass = RBASIC(klass)->klass;
method = Data_Make_Struct(mklass, struct METHOD, bm_mark, free, data);
data->klass = klass;
data->recv = obj;
data->id = id;
data->body = body;
- data->oklass = oklass;
+ data->rklass = rklass;
data->oid = oid;
OBJ_INFECT(method, klass);
return method;
}
+
+/**********************************************************************
+ *
+ * Document-class : Method
+ *
+ * Method objects are created by <code>Object#method</code>, and are
+ * associated with a particular object (not just with a class). They
+ * may be used to invoke the method within the object, and as a block
+ * associated with an iterator. They may also be unbound from one
+ * object (creating an <code>UnboundMethod</code>) and bound to
+ * another.
+ *
+ * class Thing
+ * def square(n)
+ * n*n
+ * end
+ * end
+ * thing = Thing.new
+ * meth = thing.method(:square)
+ *
+ * meth.call(9) #=> 81
+ * [ 1, 2, 3 ].collect(&meth) #=> [1, 4, 9]
+ *
+ */
+
+/*
+ * call-seq:
+ * meth == other_meth => true or false
+ *
+ * Two method objects are equal if that are bound to the same
+ * object and contain the same body.
+ */
+
+
+static VALUE
+method_eq(method, other)
+ VALUE method, other;
+{
+ struct METHOD *m1, *m2;
+
+ if (TYPE(other) != T_DATA || RDATA(other)->dmark != (RUBY_DATA_FUNC)bm_mark)
+ return Qfalse;
+ if (CLASS_OF(method) != CLASS_OF(other))
+ return Qfalse;
+
+ Data_Get_Struct(method, struct METHOD, m1);
+ Data_Get_Struct(other, struct METHOD, m2);
+
+ if (m1->klass != m2->klass || m1->rklass != m2->rklass ||
+ m1->recv != m2->recv || m1->body != m2->body)
+ return Qfalse;
+
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * meth.unbind => unbound_method
+ *
+ * Dissociates <i>meth</i> from it's current receiver. The resulting
+ * <code>UnboundMethod</code> can subsequently be bound to a new object
+ * of the same class (see <code>UnboundMethod</code>).
+ */
+
static VALUE
method_unbind(obj)
VALUE obj;
@@ -6535,22 +8589,43 @@ method_unbind(obj)
Data_Get_Struct(obj, struct METHOD, orig);
method = Data_Make_Struct(rb_cUnboundMethod, struct METHOD, bm_mark, free, data);
data->klass = orig->klass;
- data->recv = obj;
+ data->recv = Qundef;
data->id = orig->id;
data->body = orig->body;
- data->oklass = orig->oklass;
+ data->rklass = orig->rklass;
data->oid = orig->oid;
OBJ_INFECT(method, obj);
return method;
}
-static VALUE
-umethod_unbind(obj)
- VALUE obj;
-{
- return obj;
-}
+/*
+ * call-seq:
+ * obj.method(sym) => method
+ *
+ * Looks up the named method as a receiver in <i>obj</i>, returning a
+ * <code>Method</code> object (or raising <code>NameError</code>). The
+ * <code>Method</code> object acts as a closure in <i>obj</i>'s object
+ * instance, so instance variables and the value of <code>self</code>
+ * remain available.
+ *
+ * class Demo
+ * def initialize(n)
+ * @iv = n
+ * end
+ * def hello()
+ * "Hello, @iv = #{@iv}"
+ * end
+ * end
+ *
+ * k = Demo.new(99)
+ * m = k.method(:hello)
+ * m.call #=> "Hello, @iv = 99"
+ *
+ * l = Demo.new('Fred')
+ * m = l.method("hello")
+ * m.call #=> "Hello, @iv = Fred"
+ */
static VALUE
rb_obj_method(obj, vid)
@@ -6560,14 +8635,50 @@ rb_obj_method(obj, vid)
return mnew(CLASS_OF(obj), obj, rb_to_id(vid), rb_cMethod);
}
+/*
+ * call-seq:
+ * mod.instance_method(symbol) => unbound_method
+ *
+ * Returns an +UnboundMethod+ representing the given
+ * instance method in _mod_.
+ *
+ * class Interpreter
+ * def do_a() print "there, "; end
+ * def do_d() print "Hello "; end
+ * def do_e() print "!\n"; end
+ * def do_v() print "Dave"; end
+ * Dispatcher = {
+ * ?a => instance_method(:do_a),
+ * ?d => instance_method(:do_d),
+ * ?e => instance_method(:do_e),
+ * ?v => instance_method(:do_v)
+ * }
+ * def interpret(string)
+ * string.each_byte {|b| Dispatcher[b].bind(self).call }
+ * end
+ * end
+ *
+ *
+ * interpreter = Interpreter.new
+ * interpreter.interpret('dave')
+ *
+ * <em>produces:</em>
+ *
+ * Hello there, Dave!
+ */
+
static VALUE
rb_mod_method(mod, vid)
VALUE mod;
VALUE vid;
{
- return mnew(mod, 0, rb_to_id(vid), rb_cUnboundMethod);
+ return mnew(mod, Qundef, rb_to_id(vid), rb_cUnboundMethod);
}
+/*
+ * MISSING: documentation
+ */
+
static VALUE
method_clone(self)
VALUE self;
@@ -6576,49 +8687,147 @@ method_clone(self)
struct METHOD *orig, *data;
Data_Get_Struct(self, struct METHOD, orig);
- clone = Data_Make_Struct(CLASS_OF(self),struct METHOD,bm_mark,free,data);
+ clone = Data_Make_Struct(CLASS_OF(self),struct METHOD, bm_mark, free, data);
CLONESETUP(clone, self);
*data = *orig;
return clone;
}
+/*
+ * call-seq:
+ * meth.call(args, ...) => obj
+ * meth[args, ...] => obj
+ *
+ * Invokes the <i>meth</i> with the specified arguments, returning the
+ * method's return value.
+ *
+ * m = 12.method("+")
+ * m.call(3) #=> 15
+ * m.call(20) #=> 32
+ */
+
static VALUE
method_call(argc, argv, method)
int argc;
VALUE *argv;
VALUE method;
{
- VALUE result;
+ VALUE result = Qnil; /* OK */
struct METHOD *data;
int state;
- volatile int safe = ruby_safe_level;
+ volatile int safe = -1;
Data_Get_Struct(method, struct METHOD, data);
+ if (data->recv == Qundef) {
+ rb_raise(rb_eTypeError, "you cannot call unbound method; bind first");
+ }
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
PUSH_TAG(PROT_NONE);
- if (OBJ_TAINTED(method) && ruby_safe_level < 4) {
- ruby_safe_level = 4;
+ if (OBJ_TAINTED(method)) {
+ safe = ruby_safe_level;
+ if (ruby_safe_level < 4) ruby_safe_level = 4;
}
if ((state = EXEC_TAG()) == 0) {
- result = rb_call0(data->klass,data->recv,data->id,argc,argv,data->body,0);
+ result = rb_call0(data->klass,data->recv,data->id,data->oid,argc,argv,data->body,0);
}
POP_TAG();
POP_ITER();
- ruby_safe_level = safe;
+ if (safe >= 0) ruby_safe_level = safe;
if (state) JUMP_TAG(state);
return result;
}
-static VALUE
-umethod_call(argc, argv, method)
- int argc;
- VALUE *argv;
- VALUE method;
-{
- rb_raise(rb_eTypeError, "you cannot call unbound method; bind first");
- return Qnil; /* not reached */
-}
+/**********************************************************************
+ *
+ * Document-class: UnboundMethod
+ *
+ * Ruby supports two forms of objectified methods. Class
+ * <code>Method</code> is used to represent methods that are associated
+ * with a particular object: these method objects are bound to that
+ * object. Bound method objects for an object can be created using
+ * <code>Object#method</code>.
+ *
+ * Ruby also supports unbound methods; methods objects that are not
+ * associated with a particular object. These can be created either by
+ * calling <code>Module#instance_method</code> or by calling
+ * <code>unbind</code> on a bound method object. The result of both of
+ * these is an <code>UnboundMethod</code> object.
+ *
+ * Unbound methods can only be called after they are bound to an
+ * object. That object must be be a kind_of? the method's original
+ * class.
+ *
+ * class Square
+ * def area
+ * @side * @side
+ * end
+ * def initialize(side)
+ * @side = side
+ * end
+ * end
+ *
+ * area_un = Square.instance_method(:area)
+ *
+ * s = Square.new(12)
+ * area = area_un.bind(s)
+ * area.call #=> 144
+ *
+ * Unbound methods are a reference to the method at the time it was
+ * objectified: subsequent changes to the underlying class will not
+ * affect the unbound method.
+ *
+ * class Test
+ * def test
+ * :original
+ * end
+ * end
+ * um = Test.instance_method(:test)
+ * class Test
+ * def test
+ * :modified
+ * end
+ * end
+ * t = Test.new
+ * t.test #=> :modified
+ * um.bind(t).call #=> :original
+ *
+ */
+
+/*
+ * call-seq:
+ * umeth.bind(obj) -> method
+ *
+ * Bind <i>umeth</i> to <i>obj</i>. If <code>Klass</code> was the class
+ * from which <i>umeth</i> was obtained,
+ * <code>obj.kind_of?(Klass)</code> must be true.
+ *
+ * class A
+ * def test
+ * puts "In test, class = #{self.class}"
+ * end
+ * end
+ * class B < A
+ * end
+ * class C < B
+ * end
+ *
+ *
+ * um = B.instance_method(:test)
+ * bm = um.bind(C.new)
+ * bm.call
+ * bm = um.bind(B.new)
+ * bm.call
+ * bm = um.bind(A.new)
+ * bm.call
+ *
+ * <em>produces:</em>
+ *
+ * In test, class = C
+ * In test, class = B
+ * prog.rb:16:in `bind': bind argument must be an instance of B (TypeError)
+ * from prog.rb:16
+ */
static VALUE
umethod_bind(method, recv)
@@ -6627,27 +8836,57 @@ umethod_bind(method, recv)
struct METHOD *data, *bound;
Data_Get_Struct(method, struct METHOD, data);
- if (data->oklass != CLASS_OF(recv)) {
- if (FL_TEST(data->oklass, FL_SINGLETON)) {
+ if (data->rklass != CLASS_OF(recv)) {
+ if (FL_TEST(data->rklass, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "singleton method called for a different object");
}
- if (FL_TEST(CLASS_OF(recv), FL_SINGLETON) &&
- st_lookup(RCLASS(CLASS_OF(recv))->m_tbl, data->oid, 0)) {
- rb_raise(rb_eTypeError, "method `%s' overridden", rb_id2name(data->oid));
- }
- if (!rb_obj_is_instance_of(recv, data->oklass)) {
- rb_raise(rb_eTypeError, "first argument must be an instance of %s",
- rb_class2name(data->oklass));
+ if(!rb_obj_is_kind_of(recv, data->rklass)) {
+ rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
+ rb_class2name(data->rklass));
}
}
method = Data_Make_Struct(rb_cMethod,struct METHOD,bm_mark,free,bound);
*bound = *data;
bound->recv = recv;
+ bound->rklass = CLASS_OF(recv);
return method;
}
+/*
+ * call-seq:
+ * meth.arity => fixnum
+ *
+ * Returns an indication of the number of arguments accepted by a
+ * method. Returns a nonnegative integer for methods that take a fixed
+ * number of arguments. For Ruby methods that take a variable number of
+ * arguments, returns -n-1, where n is the number of required
+ * arguments. For methods written in C, returns -1 if the call takes a
+ * variable number of arguments.
+ *
+ * class C
+ * def one; end
+ * def two(a); end
+ * def three(*a); end
+ * def four(a, b); end
+ * def five(a, b, *c); end
+ * def six(a, b, *c, &d); end
+ * end
+ * c = C.new
+ * c.method(:one).arity #=> 0
+ * c.method(:two).arity #=> 1
+ * c.method(:three).arity #=> -1
+ * c.method(:four).arity #=> 2
+ * c.method(:five).arity #=> -3
+ * c.method(:six).arity #=> -3
+ *
+ * "cat".method(:size).arity #=> 0
+ * "cat".method(:replace).arity #=> 1
+ * "cat".method(:squeeze).arity #=> -1
+ * "cat".method(:count).arity #=> -1
+ */
+
static VALUE
method_arity(method)
VALUE method;
@@ -6669,6 +8908,9 @@ method_arity(method)
return INT2FIX(1);
case NODE_IVAR:
return INT2FIX(0);
+ case NODE_BMETHOD:
+ case NODE_DMETHOD:
+ return proc_arity(body->nd_cval);
default:
body = body->nd_next; /* skip NODE_SCOPE */
if (nd_type(body) == NODE_BLOCK)
@@ -6681,6 +8923,16 @@ method_arity(method)
}
}
+/*
+ * call-seq:
+ * meth.to_s => string
+ * meth.inspect => string
+ *
+ * Show the name of the underlying method.
+ *
+ * "cat".method(:count).inspect #=> "#<Method: String#count>"
+ */
+
static VALUE
method_inspect(method)
VALUE method;
@@ -6688,34 +8940,57 @@ method_inspect(method)
struct METHOD *data;
VALUE str;
const char *s;
+ char *sharp = "#";
Data_Get_Struct(method, struct METHOD, data);
- str = rb_str_new2("#<");
- s = rb_class2name(CLASS_OF(method));
- rb_str_cat2(str, s);
- rb_str_cat2(str, ": ");
- s = rb_class2name(data->oklass);
- rb_str_cat2(str, s);
- rb_str_cat2(str, "(");
- s = rb_class2name(data->klass);
- rb_str_cat2(str, s);
- rb_str_cat2(str, ")#");
- s = rb_id2name(data->oid);
- rb_str_cat2(str, s);
- rb_str_cat2(str, ">");
+ str = rb_str_buf_new2("#<");
+ s = rb_obj_classname(method);
+ rb_str_buf_cat2(str, s);
+ rb_str_buf_cat2(str, ": ");
+
+ if (FL_TEST(data->klass, FL_SINGLETON)) {
+ VALUE v = rb_iv_get(data->klass, "__attached__");
+
+ if (data->recv == Qundef) {
+ rb_str_buf_append(str, rb_inspect(data->klass));
+ }
+ else if (data->recv == v) {
+ rb_str_buf_append(str, rb_inspect(v));
+ sharp = ".";
+ }
+ else {
+ rb_str_buf_append(str, rb_inspect(data->recv));
+ rb_str_buf_cat2(str, "(");
+ rb_str_buf_append(str, rb_inspect(v));
+ rb_str_buf_cat2(str, ")");
+ sharp = ".";
+ }
+ }
+ else {
+ rb_str_buf_cat2(str, rb_class2name(data->rklass));
+ if (data->rklass != data->klass) {
+ rb_str_buf_cat2(str, "(");
+ rb_str_buf_cat2(str, rb_class2name(data->klass));
+ rb_str_buf_cat2(str, ")");
+ }
+ }
+ rb_str_buf_cat2(str, sharp);
+ rb_str_buf_cat2(str, rb_id2name(data->oid));
+ rb_str_buf_cat2(str, ">");
return str;
}
static VALUE
-mproc()
+mproc(method)
+ VALUE method;
{
VALUE proc;
/* emulate ruby's method call */
PUSH_ITER(ITER_CUR);
PUSH_FRAME();
- proc = rb_f_lambda();
+ proc = rb_block_proc();
POP_FRAME();
POP_ITER();
@@ -6726,36 +9001,97 @@ static VALUE
bmcall(args, method)
VALUE args, method;
{
- if (TYPE(args) == T_ARRAY) {
- return method_call(RARRAY(args)->len, RARRAY(args)->ptr, method);
- }
- return method_call(1, &args, method);
+ volatile VALUE a;
+
+ a = svalue_to_avalue(args);
+ return method_call(RARRAY(a)->len, RARRAY(a)->ptr, method);
}
-static VALUE
-umcall(args, method)
- VALUE args, method;
+VALUE
+rb_proc_new(func, val)
+ VALUE (*func)(ANYARGS); /* VALUE yieldarg[, VALUE procarg] */
+ VALUE val;
{
- if (TYPE(args) == T_ARRAY) {
- return umethod_call(RARRAY(args)->len, RARRAY(args)->ptr, method);
- }
- return umethod_call(1, &args, method);
+ struct BLOCK *data;
+ VALUE proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ data->body->nd_state = YIELD_FUNC_AVALUE;
+ return proc;
}
+/*
+ * call-seq:
+ * meth.to_proc => prc
+ *
+ * Returns a <code>Proc</code> object corresponding to this method.
+ */
+
static VALUE
method_proc(method)
VALUE method;
{
- return rb_iterate(mproc, 0, bmcall, method);
+ VALUE proc;
+ struct METHOD *mdata;
+ struct BLOCK *bdata;
+
+ proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, bmcall, method);
+ Data_Get_Struct(method, struct METHOD, mdata);
+ Data_Get_Struct(proc, struct BLOCK, bdata);
+ bdata->body->nd_file = mdata->body->nd_file;
+ nd_set_line(bdata->body, nd_line(mdata->body));
+ bdata->body->nd_state = YIELD_FUNC_SVALUE;
+
+ return proc;
}
static VALUE
-umethod_proc(method)
- VALUE method;
+rb_obj_is_method(m)
+ VALUE m;
{
- return rb_iterate(mproc, 0, umcall, method);
+ if (TYPE(m) == T_DATA && RDATA(m)->dmark == (RUBY_DATA_FUNC)bm_mark) {
+ return Qtrue;
+ }
+ return Qfalse;
}
+/*
+ * call-seq:
+ * define_method(symbol, method) => new_method
+ * define_method(symbol) { block } => proc
+ *
+ * Defines an instance method in the receiver. The _method_
+ * parameter can be a +Proc+ or +Method+ object.
+ * If a block is specified, it is used as the method body. This block
+ * is evaluated using <code>instance_eval</code>, a point that is
+ * tricky to demonstrate because <code>define_method</code> is private.
+ * (This is why we resort to the +send+ hack in this example.)
+ *
+ * class A
+ * def fred
+ * puts "In Fred"
+ * end
+ * def create_method(name, &block)
+ * self.class.send(:define_method, name, &block)
+ * end
+ * define_method(:wilma) { puts "Charge it!" }
+ * end
+ * class B < A
+ * define_method(:barney, instance_method(:fred))
+ * end
+ * a = B.new
+ * a.barney
+ * a.wilma
+ * a.create_method(:betty) { p self }
+ * a.betty
+ *
+ * <em>produces:</em>
+ *
+ * In Fred
+ * Charge it!
+ * #<B:0x401b39e8>
+ */
+
static VALUE
rb_mod_define_method(argc, argv, mod)
int argc;
@@ -6764,60 +9100,109 @@ rb_mod_define_method(argc, argv, mod)
{
ID id;
VALUE body;
+ NODE *node;
+ int noex;
if (argc == 1) {
id = rb_to_id(argv[0]);
- body = rb_f_lambda();
+ body = proc_lambda();
}
else if (argc == 2) {
id = rb_to_id(argv[0]);
body = argv[1];
+ if (!rb_obj_is_method(body) && !rb_obj_is_proc(body)) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Method)",
+ rb_obj_classname(body));
+ }
}
else {
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
- }
- if (TYPE(body) != T_DATA) {
- /* type error */
- rb_raise(rb_eTypeError, "wrong argument type (expected Proc)");
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
}
if (RDATA(body)->dmark == (RUBY_DATA_FUNC)bm_mark) {
- rb_add_method(mod, id, NEW_DMETHOD(method_unbind(body)), NOEX_PUBLIC);
+ node = NEW_DMETHOD(method_unbind(body));
}
else if (RDATA(body)->dmark == (RUBY_DATA_FUNC)blk_mark) {
- rb_add_method(mod, id, NEW_BMETHOD(body), NOEX_PUBLIC);
+ struct BLOCK *block;
+
+ body = proc_clone(body);
+ Data_Get_Struct(body, struct BLOCK, block);
+ block->frame.last_func = id;
+ block->frame.orig_func = id;
+ block->frame.last_class = mod;
+ node = NEW_BMETHOD(body);
}
else {
/* type error */
- rb_raise(rb_eTypeError, "wrong argument type (expected Proc)");
+ rb_raise(rb_eTypeError, "wrong argument type (expected Proc/Method)");
}
- rb_clear_cache_by_id(id);
+ if (SCOPE_TEST(SCOPE_PRIVATE)) {
+ noex = NOEX_PRIVATE;
+ }
+ else if (SCOPE_TEST(SCOPE_PROTECTED)) {
+ noex = NOEX_PROTECTED;
+ }
+ else {
+ noex = NOEX_PUBLIC;
+ }
+ rb_add_method(mod, id, node, noex);
return body;
}
+/*
+ * <code>Proc</code> objects are blocks of code that have been bound to
+ * a set of local variables. Once bound, the code may be called in
+ * different contexts and still access those variables.
+ *
+ * def gen_times(factor)
+ * return Proc.new {|n| n*factor }
+ * end
+ *
+ * times3 = gen_times(3)
+ * times5 = gen_times(5)
+ *
+ * times3.call(12) #=> 36
+ * times5.call(5) #=> 25
+ * times3.call(times5.call(4)) #=> 60
+ *
+ */
+
void
Init_Proc()
{
rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError);
+ rb_define_method(rb_eLocalJumpError, "exit_value", localjump_xvalue, 0);
+ rb_define_method(rb_eLocalJumpError, "reason", localjump_reason, 0);
+
+ exception_error = rb_exc_new2(rb_eFatal, "exception reentered");
+ rb_global_variable(&exception_error);
+
rb_eSysStackError = rb_define_class("SystemStackError", rb_eStandardError);
+ sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep");
+ OBJ_TAINT(sysstack_error);
+ rb_global_variable(&sysstack_error);
rb_cProc = rb_define_class("Proc", rb_cObject);
+ rb_undef_alloc_func(rb_cProc);
rb_define_singleton_method(rb_cProc, "new", proc_s_new, -1);
+ rb_define_method(rb_cProc, "clone", proc_clone, 0);
+ rb_define_method(rb_cProc, "dup", proc_dup, 0);
rb_define_method(rb_cProc, "call", proc_call, -2);
rb_define_method(rb_cProc, "arity", proc_arity, 0);
rb_define_method(rb_cProc, "[]", proc_call, -2);
rb_define_method(rb_cProc, "==", proc_eq, 1);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
- rb_define_global_function("proc", rb_f_lambda, 0);
- rb_define_global_function("lambda", rb_f_lambda, 0);
- rb_define_global_function("binding", rb_f_binding, 0);
- rb_cBinding = rb_define_class("Binding", rb_cObject);
- rb_undef_method(CLASS_OF(rb_cBinding), "new");
- rb_define_method(rb_cBinding, "clone", bind_clone, 0);
+ rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
+ rb_define_method(rb_cProc, "binding", proc_binding, 0);
+
+ rb_define_global_function("proc", proc_lambda, 0);
+ rb_define_global_function("lambda", proc_lambda, 0);
rb_cMethod = rb_define_class("Method", rb_cObject);
+ rb_undef_alloc_func(rb_cMethod);
rb_undef_method(CLASS_OF(rb_cMethod), "new");
+ rb_define_method(rb_cMethod, "==", method_eq, 1);
rb_define_method(rb_cMethod, "clone", method_clone, 0);
rb_define_method(rb_cMethod, "call", method_call, -1);
rb_define_method(rb_cMethod, "[]", method_call, -1);
@@ -6828,16 +9213,133 @@ Init_Proc()
rb_define_method(rb_cMethod, "unbind", method_unbind, 0);
rb_define_method(rb_mKernel, "method", rb_obj_method, 1);
- rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cMethod);
- rb_define_method(rb_cUnboundMethod, "call", umethod_call, -1);
- rb_define_method(rb_cUnboundMethod, "[]", umethod_call, -1);
- rb_define_method(rb_cUnboundMethod, "to_proc", umethod_proc, 0);
+ rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject);
+ rb_undef_alloc_func(rb_cUnboundMethod);
+ rb_undef_method(CLASS_OF(rb_cUnboundMethod), "new");
+ rb_define_method(rb_cUnboundMethod, "==", method_eq, 1);
+ rb_define_method(rb_cUnboundMethod, "clone", method_clone, 0);
+ rb_define_method(rb_cUnboundMethod, "arity", method_arity, 0);
+ rb_define_method(rb_cUnboundMethod, "inspect", method_inspect, 0);
+ rb_define_method(rb_cUnboundMethod, "to_s", method_inspect, 0);
rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1);
- rb_define_method(rb_cUnboundMethod, "unbind", umethod_unbind, 0);
rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1);
}
-static VALUE rb_eThreadError;
+/*
+ * Objects of class <code>Binding</code> encapsulate the execution
+ * context at some particular place in the code and retain this context
+ * for future use. The variables, methods, value of <code>self</code>,
+ * and possibly an iterator block that can be accessed in this context
+ * are all retained. Binding objects can be created using
+ * <code>Kernel#binding</code>, and are made available to the callback
+ * of <code>Kernel#set_trace_func</code>.
+ *
+ * These binding objects can be passed as the second argument of the
+ * <code>Kernel#eval</code> method, establishing an environment for the
+ * evaluation.
+ *
+ * class Demo
+ * def initialize(n)
+ * @secret = n
+ * end
+ * def getBinding
+ * return binding()
+ * end
+ * end
+ *
+ * k1 = Demo.new(99)
+ * b1 = k1.getBinding
+ * k2 = Demo.new(-3)
+ * b2 = k2.getBinding
+ *
+ * eval("@secret", b1) #=> 99
+ * eval("@secret", b2) #=> -3
+ * eval("@secret") #=> nil
+ *
+ * Binding objects have no class-specific methods.
+ *
+ */
+
+void
+Init_Binding()
+{
+ rb_cBinding = rb_define_class("Binding", rb_cObject);
+ rb_undef_alloc_func(rb_cBinding);
+ rb_undef_method(CLASS_OF(rb_cBinding), "new");
+ rb_define_method(rb_cBinding, "clone", proc_clone, 0);
+ rb_define_global_function("binding", rb_f_binding, 0);
+}
+
+#ifdef __ia64__
+#if defined(__FreeBSD__)
+/*
+ * FreeBSD/ia64 currently does not have a way for a process to get the
+ * base address for the RSE backing store, so hardcode it.
+ */
+#define __libc_ia64_register_backing_store_base (4ULL<<61)
+#else
+#pragma weak __libc_ia64_register_backing_store_base
+extern unsigned long __libc_ia64_register_backing_store_base;
+#endif
+#endif
+
+/* Windows SEH refers data on the stack. */
+#undef SAVE_WIN32_EXCEPTION_LIST
+#if defined _WIN32 || defined __CYGWIN__
+#if defined __CYGWIN__
+typedef unsigned long DWORD;
+#endif
+
+static inline DWORD
+win32_get_exception_list()
+{
+ DWORD p;
+# if defined _MSC_VER
+# ifdef _M_IX86
+# define SAVE_WIN32_EXCEPTION_LIST
+# if _MSC_VER >= 1310
+ /* warning: unsafe assignment to fs:0 ... this is ok */
+# pragma warning(disable: 4733)
+# endif
+ __asm mov eax, fs:[0];
+ __asm mov p, eax;
+# endif
+# elif defined __GNUC__
+# ifdef __i386__
+# define SAVE_WIN32_EXCEPTION_LIST
+ __asm__("movl %%fs:0,%0" : "=r"(p));
+# endif
+# elif defined __BORLANDC__
+# define SAVE_WIN32_EXCEPTION_LIST
+ __emit__(0x64, 0xA1, 0, 0, 0, 0); /* mov eax, fs:[0] */
+ p = _EAX;
+# endif
+ return p;
+}
+
+static inline void
+win32_set_exception_list(p)
+ DWORD p;
+{
+# if defined _MSC_VER
+# ifdef _M_IX86
+ __asm mov eax, p;
+ __asm mov fs:[0], eax;
+# endif
+# elif defined __GNUC__
+# ifdef __i386__
+ __asm__("movl %0,%%fs:0" :: "r"(p));
+# endif
+# elif defined __BORLANDC__
+ _EAX = p;
+ __emit__(0x64, 0xA3, 0, 0, 0, 0); /* mov fs:[0], eax */
+# endif
+}
+
+#if !defined SAVE_WIN32_EXCEPTION_LIST && !defined _WIN32_WCE
+# error unsupported platform
+#endif
+#endif
int rb_thread_pending = 0;
@@ -6849,7 +9351,7 @@ enum thread_status {
THREAD_TO_KILL,
THREAD_RUNNABLE,
THREAD_STOPPED,
- THREAD_KILLED
+ THREAD_KILLED,
};
#define WAIT_FD (1<<0)
@@ -6861,18 +9363,33 @@ enum thread_status {
/* +infty, for this purpose */
#define DELAY_INFTY 1E30
+#if !defined HAVE_PAUSE
+# if defined _WIN32 && !defined __CYGWIN__
+# define pause() Sleep(INFINITE)
+# else
+# define pause() sleep(0x7fffffff)
+# endif
+#endif
+
/* typedef struct thread * rb_thread_t; */
struct thread {
struct thread *next, *prev;
- jmp_buf context;
+ rb_jmpbuf_t context;
+#ifdef SAVE_WIN32_EXCEPTION_LIST
+ DWORD win32_exception_list;
+#endif
VALUE result;
- int stk_len;
- int stk_max;
- VALUE*stk_ptr;
- VALUE*stk_pos;
+ long stk_len;
+ long stk_max;
+ VALUE *stk_ptr;
+ VALUE *stk_pos;
+#ifdef __ia64__
+ VALUE *bstr_ptr;
+ long bstr_len;
+#endif
struct FRAME *frame;
struct SCOPE *scope;
@@ -6886,8 +9403,7 @@ struct thread {
int flags; /* misc. states (vmode/rb_trap_immediate/raised) */
- char *file;
- int line;
+ NODE *node;
int tracing;
VALUE errinfo;
@@ -6909,7 +9425,7 @@ struct thread {
int abort;
int priority;
- int gid;
+ VALUE thgroup;
st_table *locals;
@@ -6926,12 +9442,126 @@ struct thread {
#define FOREACH_THREAD(x) FOREACH_THREAD_FROM(curr_thread,x)
#define END_FOREACH(x) END_FOREACH_FROM(curr_thread,x)
+struct thread_status_t {
+ NODE *node;
+
+ int tracing;
+ VALUE errinfo;
+ VALUE last_status;
+ VALUE last_line;
+ VALUE last_match;
+
+ int safe;
+
+ enum thread_status status;
+ int wait_for;
+ int fd;
+ fd_set readfds;
+ fd_set writefds;
+ fd_set exceptfds;
+ int select_value;
+ double delay;
+ rb_thread_t join;
+};
+
+#define THREAD_COPY_STATUS(src, dst) (void)( \
+ (dst)->node = (src)->node, \
+ \
+ (dst)->tracing = (src)->tracing, \
+ (dst)->errinfo = (src)->errinfo, \
+ (dst)->last_status = (src)->last_status, \
+ (dst)->last_line = (src)->last_line, \
+ (dst)->last_match = (src)->last_match, \
+ \
+ (dst)->safe = (src)->safe, \
+ \
+ (dst)->status = (src)->status, \
+ (dst)->wait_for = (src)->wait_for, \
+ (dst)->fd = (src)->fd, \
+ (dst)->readfds = (src)->readfds, \
+ (dst)->writefds = (src)->writefds, \
+ (dst)->exceptfds = (src)->exceptfds, \
+ (dst)->select_value = (src)->select_value, \
+ (dst)->delay = (src)->delay, \
+ (dst)->join = (src)->join, \
+ 0)
+
+static int
+thread_set_raised()
+{
+ if (curr_thread->flags & THREAD_RAISED) return 1;
+ curr_thread->flags |= THREAD_RAISED;
+ return 0;
+}
+
+static int
+thread_reset_raised()
+{
+ if (!(curr_thread->flags & THREAD_RAISED)) return 0;
+ curr_thread->flags &= ~THREAD_RAISED;
+ return 1;
+}
+
+static void rb_thread_ready _((rb_thread_t));
+
+static VALUE
+rb_trap_eval(cmd, sig, safe)
+ VALUE cmd;
+ int sig, safe;
+{
+ int state;
+ VALUE val = Qnil; /* OK */
+ volatile struct thread_status_t save;
+
+ THREAD_COPY_STATUS(curr_thread, &save);
+ rb_thread_ready(curr_thread);
+ PUSH_TAG(PROT_NONE);
+ PUSH_ITER(ITER_NOT);
+ if ((state = EXEC_TAG()) == 0) {
+ val = rb_eval_cmd(cmd, rb_ary_new3(1, INT2FIX(sig)), safe);
+ }
+ POP_ITER();
+ POP_TAG();
+ THREAD_COPY_STATUS(&save, curr_thread);
+
+ if (state) {
+ rb_trap_immediate = 0;
+ JUMP_TAG(state);
+ }
+
+ if (curr_thread->status == THREAD_STOPPED) {
+ rb_thread_schedule();
+ }
+ errno = EINTR;
+
+ return val;
+}
+
+static const char *
+thread_status_name(status)
+ enum thread_status status;
+{
+ switch (status) {
+ case THREAD_RUNNABLE:
+ return "run";
+ case THREAD_STOPPED:
+ return "sleep";
+ case THREAD_TO_KILL:
+ return "aborting";
+ case THREAD_KILLED:
+ return "dead";
+ default:
+ return "unknown";
+ }
+}
+
/* $SAFE accessor */
void
rb_set_safe_level(level)
int level;
{
if (level > ruby_safe_level) {
+ if (level > SAFE_LEVEL_MAX) level = SAFE_LEVEL_MAX;
ruby_safe_level = level;
curr_thread->safe = level;
}
@@ -6953,6 +9583,7 @@ safe_setter(val)
rb_raise(rb_eSecurityError, "tried to downgrade safe level from %d to %d",
ruby_safe_level, level);
}
+ if (level > SAFE_LEVEL_MAX) level = SAFE_LEVEL_MAX;
ruby_safe_level = level;
curr_thread->safe = level;
}
@@ -6968,6 +9599,25 @@ timeofday()
#define STACK(addr) (th->stk_pos<(VALUE*)(addr) && (VALUE*)(addr)<th->stk_pos+th->stk_len)
#define ADJ(addr) (void*)(STACK(addr)?(((VALUE*)(addr)-th->stk_pos)+th->stk_ptr):(VALUE*)(addr))
+#ifdef C_ALLOCA
+# define MARK_FRAME_ADJ(f) rb_gc_mark_frame(f)
+#else
+# define MARK_FRAME_ADJ(f) mark_frame_adj(f, th)
+static void
+mark_frame_adj(frame, th)
+ struct FRAME *frame;
+ rb_thread_t th;
+{
+ if (frame->flags & FRAME_MALLOC) {
+ rb_gc_mark_locations(frame->argv, frame->argv+frame->argc);
+ }
+ else {
+ VALUE *start = ADJ(frame->argv);
+ rb_gc_mark_locations(start, start+frame->argc);
+ }
+ rb_gc_mark((VALUE)frame->node);
+}
+#endif
static void
thread_mark(th)
@@ -6982,10 +9632,10 @@ thread_mark(th)
rb_gc_mark(th->klass);
rb_gc_mark(th->wrapper);
- rb_gc_mark(th->cref);
+ rb_gc_mark((VALUE)th->cref);
- rb_gc_mark(th->scope);
- rb_gc_mark(th->dyna_vars);
+ rb_gc_mark((VALUE)th->scope);
+ rb_gc_mark((VALUE)th->dyna_vars);
rb_gc_mark(th->errinfo);
rb_gc_mark(th->last_line);
rb_gc_mark(th->last_match);
@@ -7000,17 +9650,22 @@ thread_mark(th)
#if defined(THINK_C) || defined(__human68k__)
rb_gc_mark_locations(th->stk_ptr+2, th->stk_ptr+th->stk_len+2);
#endif
+#ifdef __ia64__
+ if (th->bstr_ptr) {
+ rb_gc_mark_locations(th->bstr_ptr, th->bstr_ptr+th->bstr_len);
+ }
+#endif
}
frame = th->frame;
while (frame && frame != top_frame) {
frame = ADJ(frame);
- rb_gc_mark_frame(frame);
+ MARK_FRAME_ADJ(frame);
if (frame->tmp) {
struct FRAME *tmp = frame->tmp;
while (tmp && tmp != top_frame) {
tmp = ADJ(tmp);
- rb_gc_mark_frame(tmp);
+ MARK_FRAME_ADJ(tmp);
tmp = tmp->prev;
}
}
@@ -7019,7 +9674,7 @@ thread_mark(th)
block = th->block;
while (block) {
block = ADJ(block);
- rb_gc_mark_frame(&block->frame);
+ MARK_FRAME_ADJ(&block->frame);
block = block->prev;
}
}
@@ -7029,6 +9684,9 @@ rb_gc_mark_threads()
{
rb_thread_t th;
+ /* static global mark */
+ rb_gc_mark((VALUE)ruby_cref);
+
if (!curr_thread) return;
FOREACH_THREAD(th) {
rb_gc_mark(th->thread);
@@ -7041,6 +9699,10 @@ thread_free(th)
{
if (th->stk_ptr) free(th->stk_ptr);
th->stk_ptr = 0;
+#ifdef __ia64__
+ if (th->bstr_ptr) free(th->bstr_ptr);
+ th->bstr_ptr = 0;
+#endif
if (th->locals) st_free_table(th->locals);
if (th->status != THREAD_KILLED) {
if (th->prev) th->prev->next = th->next;
@@ -7053,21 +9715,19 @@ static rb_thread_t
rb_thread_check(data)
VALUE data;
{
- if (TYPE(data) != T_DATA || RDATA(data)->dfree != (RUBY_DATA_FUNC)thread_free) {
+ if (TYPE(data) != T_DATA || RDATA(data)->dmark != (RUBY_DATA_FUNC)thread_mark) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Thread)",
- rb_class2name(CLASS_OF(data)));
+ rb_obj_classname(data));
}
return (rb_thread_t)RDATA(data)->data;
}
static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t));
-static int th_raise_argc;
-static VALUE th_raise_argv[2];
-static char *th_raise_file;
-static int th_raise_line;
+static VALUE th_raise_exception;
+static NODE *th_raise_node;
static VALUE th_cmd;
-static int th_sig;
+static int th_sig, th_safe;
static char *th_signm;
#define RESTORE_NORMAL 1
@@ -7076,6 +9736,9 @@ static char *th_signm;
#define RESTORE_TRAP 4
#define RESTORE_RAISE 5
#define RESTORE_SIGNAL 6
+#define RESTORE_EXIT 7
+
+extern VALUE *rb_gc_stack_start;
static void
rb_thread_save_context(th)
@@ -7083,18 +9746,38 @@ rb_thread_save_context(th)
{
VALUE *pos;
int len;
+ static VALUE tval;
- len = stack_length(&pos);
+ len = ruby_stack_length(&pos);
th->stk_len = 0;
- th->stk_pos = (rb_gc_stack_start<pos)?rb_gc_stack_start
- :rb_gc_stack_start - len;
+ th->stk_pos = pos;
if (len > th->stk_max) {
REALLOC_N(th->stk_ptr, VALUE, len);
th->stk_max = len;
}
th->stk_len = len;
- FLUSH_REGISTER_WINDOWS;
+ FLUSH_REGISTER_WINDOWS;
MEMCPY(th->stk_ptr, th->stk_pos, VALUE, th->stk_len);
+#ifdef __ia64__
+ {
+ ucontext_t ctx;
+ VALUE *top, *bot;
+
+ getcontext(&ctx);
+ bot = (VALUE*)__libc_ia64_register_backing_store_base;
+#if defined(__FreeBSD__)
+ top = (VALUE*)ctx.uc_mcontext.mc_special.bspstore;
+#else
+ top = (VALUE*)ctx.uc_mcontext.sc_ar_bsp;
+#endif
+ th->bstr_len = top - bot;
+ REALLOC_N(th->bstr_ptr, VALUE, th->bstr_len);
+ MEMCPY(th->bstr_ptr, (VALUE*)__libc_ia64_register_backing_store_base, VALUE, th->bstr_len);
+ }
+#endif
+#ifdef SAVE_WIN32_EXCEPTION_LIST
+ th->win32_exception_list = win32_get_exception_list();
+#endif
th->frame = ruby_frame;
th->scope = ruby_scope;
@@ -7110,18 +9793,22 @@ rb_thread_save_context(th)
th->tracing = tracing;
th->errinfo = ruby_errinfo;
th->last_status = rb_last_status;
- th->last_line = rb_lastline_get();
- th->last_match = rb_backref_get();
+ tval = rb_lastline_get();
+ rb_lastline_set(th->last_line);
+ th->last_line = tval;
+ tval = rb_backref_get();
+ rb_backref_set(th->last_match);
+ th->last_match = tval;
th->safe = ruby_safe_level;
- th->file = ruby_sourcefile;
- th->line = ruby_sourceline;
+ th->node = ruby_current_node;
}
static int
-thread_switch(n)
+rb_thread_switch(n)
int n;
{
+ rb_trap_immediate = (curr_thread->flags&0x100)?1:0;
switch (n) {
case 0:
return 0;
@@ -7132,18 +9819,22 @@ thread_switch(n)
rb_interrupt();
break;
case RESTORE_TRAP:
- rb_trap_eval(th_cmd, th_sig);
- errno = EINTR;
+ rb_trap_eval(th_cmd, th_sig, th_safe);
break;
case RESTORE_RAISE:
ruby_frame->last_func = 0;
- ruby_sourcefile = th_raise_file;
- ruby_sourceline = th_raise_line;
- rb_f_raise(th_raise_argc, th_raise_argv);
+ ruby_current_node = th_raise_node;
+ rb_raise_jump(th_raise_exception);
break;
case RESTORE_SIGNAL:
rb_raise(rb_eSignal, "SIG%s", th_signm);
break;
+ case RESTORE_EXIT:
+ ruby_errinfo = th_raise_exception;
+ ruby_current_node = th_raise_node;
+ error_print();
+ terminate_process(EXIT_FAILURE, 0, 0);
+ break;
case RESTORE_NORMAL:
default:
break;
@@ -7152,10 +9843,14 @@ thread_switch(n)
}
#define THREAD_SAVE_CONTEXT(th) \
- (rb_thread_save_context(th),thread_switch(setjmp((th)->context)))
+ (rb_thread_save_context(th),\
+ rb_thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
-static void rb_thread_restore_context _((rb_thread_t,int));
+NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
+# if _MSC_VER >= 1300
+__declspec(noinline)
+# endif
static void
stack_extend(th, exit)
rb_thread_t th;
@@ -7175,9 +9870,15 @@ rb_thread_restore_context(th, exit)
VALUE v;
static rb_thread_t tmp;
static int ex;
+ static VALUE tval;
if (!th->stk_ptr) rb_bug("unsaved context");
+#if STACK_GROW_DIRECTION < 0
+ if (&v > th->stk_pos) stack_extend(th, exit);
+#elif STACK_GROW_DIRECTION > 0
+ if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
+#else
if (&v < rb_gc_stack_start) {
/* Stack grows downward */
if (&v > th->stk_pos) stack_extend(th, exit);
@@ -7186,7 +9887,9 @@ rb_thread_restore_context(th, exit)
/* Stack grows upward */
if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
}
+#endif
+ rb_trap_immediate = 0; /* inhibit interrupts from here */
ruby_frame = th->frame;
ruby_scope = th->scope;
ruby_class = th->klass;
@@ -7195,7 +9898,6 @@ rb_thread_restore_context(th, exit)
ruby_dyna_vars = th->dyna_vars;
ruby_block = th->block;
scope_vmode = th->flags&SCOPE_MASK;
- rb_trap_immediate = (th->flags&0x100)?1:0;
ruby_iter = th->iter;
prot_tag = th->tag;
tracing = th->tracing;
@@ -7203,16 +9905,25 @@ rb_thread_restore_context(th, exit)
rb_last_status = th->last_status;
ruby_safe_level = th->safe;
- ruby_sourcefile = th->file;
- ruby_sourceline = th->line;
+ ruby_current_node = th->node;
+#ifdef SAVE_WIN32_EXCEPTION_LIST
+ win32_set_exception_list(th->win32_exception_list);
+#endif
tmp = th;
ex = exit;
FLUSH_REGISTER_WINDOWS;
MEMCPY(tmp->stk_pos, tmp->stk_ptr, VALUE, tmp->stk_len);
+#ifdef __ia64__
+ MEMCPY((VALUE*)__libc_ia64_register_backing_store_base, tmp->bstr_ptr, VALUE, tmp->bstr_len);
+#endif
+ tval = rb_lastline_get();
rb_lastline_set(tmp->last_line);
+ tmp->last_line = tval;
+ tval = rb_backref_get();
rb_backref_set(tmp->last_match);
+ tmp->last_match = tval;
longjmp(tmp->context, ex);
}
@@ -7222,7 +9933,19 @@ rb_thread_ready(th)
rb_thread_t th;
{
th->wait_for = 0;
- th->status = THREAD_RUNNABLE;
+ if (th->status != THREAD_TO_KILL) {
+ th->status = THREAD_RUNNABLE;
+ }
+}
+
+static void
+rb_thread_die(th)
+ rb_thread_t th;
+{
+ th->thgroup = 0;
+ th->status = THREAD_KILLED;
+ if (th->stk_ptr) free(th->stk_ptr);
+ th->stk_ptr = 0;
}
static void
@@ -7232,7 +9955,7 @@ rb_thread_remove(th)
if (th->status == THREAD_KILLED) return;
rb_thread_ready(th);
- th->status = THREAD_KILLED;
+ rb_thread_die(th);
th->prev->next = th->next;
th->next->prev = th->prev;
}
@@ -7251,7 +9974,11 @@ rb_thread_fd_close(fd)
rb_thread_t th;
FOREACH_THREAD(th) {
- if ((th->wait_for & WAIT_FD) && fd == th->fd) {
+ if (((th->wait_for & WAIT_FD) && fd == th->fd) ||
+ ((th->wait_for & WAIT_SELECT) && (fd < th->fd) &&
+ (FD_ISSET(fd, &th->readfds) ||
+ FD_ISSET(fd, &th->writefds) ||
+ FD_ISSET(fd, &th->exceptfds)))) {
VALUE exc = rb_exc_new2(rb_eIOError, "stream closed");
rb_thread_raise(1, &exc, th);
}
@@ -7259,18 +9986,31 @@ rb_thread_fd_close(fd)
END_FOREACH(th);
}
+NORETURN(static void rb_thread_main_jump _((VALUE, int)));
+static void
+rb_thread_main_jump(err, tag)
+ VALUE err;
+ int tag;
+{
+ curr_thread = main_thread;
+ th_raise_exception = err;
+ th_raise_node = ruby_current_node;
+ rb_thread_restore_context(main_thread, tag);
+}
+
+NORETURN(static void rb_thread_deadlock _((void)));
static void
rb_thread_deadlock()
{
+ char msg[21+SIZEOF_LONG*2];
+ VALUE e;
+
+ sprintf(msg, "Thread(0x%lx): deadlock", curr_thread->thread);
+ e = rb_exc_new2(rb_eFatal, msg);
if (curr_thread == main_thread) {
- rb_raise(rb_eFatal, "Thread: deadlock");
+ rb_exc_raise(e);
}
- 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);
+ rb_thread_main_jump(e, RESTORE_RAISE);
}
static void
@@ -7304,24 +10044,26 @@ match_fds(dst, src, max)
return Qfalse;
}
-static void
+static int
intersect_fds(src, dst, max)
fd_set *src, *dst;
int max;
{
- int i;
+ int i, n = 0;
for (i=0; i<=max; i++) {
if (FD_ISSET(i, dst)) {
if (FD_ISSET(i, src)) {
/* Wake up only one thread per fd. */
FD_CLR(i, src);
+ n++;
}
else {
FD_CLR(i, dst);
}
}
}
+ return n;
}
static int
@@ -7355,7 +10097,13 @@ rb_thread_schedule()
double delay, now; /* OK */
int n, max;
int need_select = 0;
+ int select_timeout = 0;
+#ifdef HAVE_NATIVETHREAD
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on rb_thread_schedule()");
+ }
+#endif
rb_thread_pending = 0;
if (curr_thread == curr_thread->next
&& curr_thread->status == THREAD_RUNNABLE)
@@ -7398,6 +10146,9 @@ rb_thread_schedule()
copy_fds(&exceptfds, &th->exceptfds, th->fd);
if (max < th->fd) max = th->fd;
need_select = 1;
+ if (th->wait_for & WAIT_TIME) {
+ select_timeout = 1;
+ }
th->select_value = 0;
}
if (th->wait_for & WAIT_TIME) {
@@ -7408,14 +10159,18 @@ rb_thread_schedule()
if (th_delay <= 0.0) {
th->status = THREAD_RUNNABLE;
found = 1;
- } else if (th_delay < delay) {
+ }
+ else if (th_delay < delay) {
delay = th_delay;
need_select = 1;
}
+ else if (th->delay == DELAY_INFTY) {
+ need_select = 1;
+ }
}
}
END_FOREACH_FROM(curr, th);
-
+
/* Do the select if needed */
if (need_select) {
/* Convert delay to a timeval */
@@ -7436,8 +10191,13 @@ rb_thread_schedule()
n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
if (n < 0) {
+ int e = errno;
+
if (rb_trap_pending) rb_trap_exec();
- if (errno == EINTR) goto again;
+ if (e == EINTR) goto again;
+#ifdef ERESTART
+ if (e == ERESTART) goto again;
+#endif
FOREACH_THREAD_FROM(curr, th) {
if (th->wait_for & WAIT_SELECT) {
int v = 0;
@@ -7453,9 +10213,25 @@ rb_thread_schedule()
}
END_FOREACH_FROM(curr, th);
}
+ if (select_timeout && n == 0) {
+ if (now < 0.0) now = timeofday();
+ FOREACH_THREAD_FROM(curr, th) {
+ if (((th->wait_for&(WAIT_SELECT|WAIT_TIME)) == (WAIT_SELECT|WAIT_TIME)) &&
+ th->delay <= now) {
+ th->status = THREAD_RUNNABLE;
+ th->wait_for = 0;
+ th->select_value = 0;
+ found = 1;
+ intersect_fds(&readfds, &th->readfds, max);
+ intersect_fds(&writefds, &th->writefds, max);
+ intersect_fds(&exceptfds, &th->exceptfds, max);
+ }
+ }
+ END_FOREACH_FROM(curr, th);
+ }
if (n > 0) {
now = -1.0;
- /* Some descriptors are ready.
+ /* Some descriptors are ready.
Make the corresponding threads runnable. */
FOREACH_THREAD_FROM(curr, th) {
if ((th->wait_for&WAIT_FD) && FD_ISSET(th->fd, &readfds)) {
@@ -7473,9 +10249,9 @@ rb_thread_schedule()
/* Wake up only one thread per fd. */
th->status = THREAD_RUNNABLE;
th->wait_for = 0;
- intersect_fds(&readfds, &th->readfds, max);
- intersect_fds(&writefds, &th->writefds, max);
- intersect_fds(&exceptfds, &th->exceptfds, max);
+ n = intersect_fds(&readfds, &th->readfds, max) +
+ intersect_fds(&writefds, &th->writefds, max) +
+ intersect_fds(&exceptfds, &th->exceptfds, max);
th->select_value = n;
found = 1;
}
@@ -7493,28 +10269,42 @@ rb_thread_schedule()
next = th;
break;
}
- if (th->status == THREAD_RUNNABLE) {
- if (!next || next->priority < th->priority)
+ if (th->status == THREAD_RUNNABLE && th->stk_ptr) {
+ if (!next || next->priority < th->priority)
next = th;
}
}
- END_FOREACH_FROM(curr, th);
+ END_FOREACH_FROM(curr, th);
if (!next) {
/* raise fatal error to main thread */
- curr_thread->file = ruby_sourcefile;
- curr_thread->line = ruby_sourceline;
+ curr_thread->node = ruby_current_node;
+ if (curr->next == curr) {
+ TRAP_BEG;
+ pause();
+ TRAP_END;
+ }
FOREACH_THREAD_FROM(curr, th) {
- fprintf(stderr, "deadlock 0x%lx: %d:%d %s - %s:%d\n",
- th->thread, th->status,
- th->wait_for, th==main_thread?"(main)":"",
- th->file, th->line);
+ warn_printf("deadlock 0x%lx: %s:",
+ th->thread, thread_status_name(th->status));
+ if (th->wait_for & WAIT_FD) warn_printf("F(%d)", th->fd);
+ if (th->wait_for & WAIT_SELECT) warn_printf("S");
+ if (th->wait_for & WAIT_TIME) warn_printf("T(%f)", th->delay);
+ if (th->wait_for & WAIT_JOIN)
+ warn_printf("J(0x%lx)", th->join ? th->join->thread : 0);
+ if (th->wait_for & WAIT_PID) warn_printf("P");
+ if (!th->wait_for) warn_printf("-");
+ warn_printf(" %s - %s:%d\n",
+ th==main_thread ? "(main)" : "",
+ th->node->nd_file, nd_line(th->node));
}
END_FOREACH_FROM(curr, th);
next = main_thread;
- next->gid = 0;
rb_thread_ready(next);
next->status = THREAD_TO_KILL;
+ if (!rb_thread_dead(curr_thread)) {
+ rb_thread_save_context(curr_thread);
+ }
rb_thread_deadlock();
}
next->wait_for = 0;
@@ -7545,6 +10335,7 @@ rb_thread_wait_fd(fd)
int fd;
{
if (rb_thread_critical) return;
+ if (ruby_in_compile) return;
if (curr_thread == curr_thread->next) return;
if (curr_thread->status == THREAD_TO_KILL) return;
@@ -7561,6 +10352,7 @@ rb_thread_fd_writable(fd)
if (rb_thread_critical) return Qtrue;
if (curr_thread == curr_thread->next) return Qtrue;
if (curr_thread->status == THREAD_TO_KILL) return Qtrue;
+
curr_thread->status = THREAD_STOPPED;
FD_ZERO(&curr_thread->readfds);
FD_ZERO(&curr_thread->writefds);
@@ -7582,18 +10374,24 @@ rb_thread_wait_for(time)
curr_thread == curr_thread->next ||
curr_thread->status == THREAD_TO_KILL) {
int n;
+ int thr_critical = rb_thread_critical;
#ifndef linux
double d, limit;
limit = timeofday()+(double)time.tv_sec+(double)time.tv_usec*1e-6;
#endif
for (;;) {
+ rb_thread_critical = Qtrue;
TRAP_BEG;
n = select(0, 0, 0, 0, &time);
+ rb_thread_critical = thr_critical;
TRAP_END;
if (n == 0) return;
if (n < 0) {
switch (errno) {
case EINTR:
+#ifdef ERESTART
+ case ERESTART:
+#endif
return;
default:
rb_sys_fail("sleep");
@@ -7661,33 +10459,36 @@ rb_thread_select(max, read, write, except, timeout)
tv = *timeout;
tvp = &tv;
}
+#else
+ struct timeval *const tvp = timeout;
+#endif
for (;;) {
TRAP_BEG;
n = select(max, read, write, except, tvp);
TRAP_END;
- if (n < 0 && errno == EINTR) {
- if (timeout) {
- double d = timeofday() - limit;
+ if (n < 0) {
+ switch (errno) {
+ case EINTR:
+#ifdef ERESTART
+ case ERESTART:
+#endif
+#ifndef linux
+ if (timeout) {
+ double d = limit - timeofday();
- tv.tv_sec = (unsigned int)d;
- tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6);
+ tv.tv_sec = (unsigned int)d;
+ tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6);
+ if (tv.tv_sec < 0) tv.tv_sec = 0;
+ if (tv.tv_usec < 0) tv.tv_usec = 0;
+ }
+#endif
+ continue;
+ default:
+ break;
}
- continue;
}
return n;
}
-#else
- for (;;) {
- TRAP_BEG;
- n = select(max, read, write, except, timeout);
- TRAP_END;
- if (n < 0 && errno == EINTR) {
- continue;
- }
- return n;
- }
-#endif
-
}
curr_thread->status = THREAD_STOPPED;
@@ -7711,54 +10512,162 @@ rb_thread_select(max, read, write, except, timeout)
return curr_thread->select_value;
}
-static VALUE
-rb_thread_join(thread)
- VALUE thread;
+static int rb_thread_join _((rb_thread_t, double));
+
+static int
+rb_thread_join(th, limit)
+ rb_thread_t th;
+ double limit;
{
- rb_thread_t th = rb_thread_check(thread);
enum thread_status last_status = THREAD_RUNNABLE;
if (rb_thread_critical) rb_thread_deadlock();
if (!rb_thread_dead(th)) {
if (th == curr_thread)
- rb_raise(rb_eThreadError, "thread tried to join itself");
+ rb_raise(rb_eThreadError, "thread 0x%lx tried to join itself",
+ th->thread);
if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread)
- rb_raise(rb_eThreadError, "Thread#join: deadlock - mutual join");
+ rb_raise(rb_eThreadError, "Thread#join: deadlock 0x%lx - mutual join(0x%lx)",
+ curr_thread->thread, th->thread);
if (curr_thread->status == THREAD_TO_KILL)
last_status = THREAD_TO_KILL;
+ if (limit == 0) return Qfalse;
curr_thread->status = THREAD_STOPPED;
curr_thread->join = th;
curr_thread->wait_for = WAIT_JOIN;
+ curr_thread->delay = timeofday() + limit;
+ if (limit < DELAY_INFTY) curr_thread->wait_for |= WAIT_TIME;
rb_thread_schedule();
curr_thread->status = last_status;
+ if (!rb_thread_dead(th)) return Qfalse;
}
if (!NIL_P(th->errinfo) && (th->flags & THREAD_RAISED)) {
VALUE oldbt = get_backtrace(th->errinfo);
VALUE errat = make_backtrace();
+ VALUE errinfo = rb_obj_dup(th->errinfo);
if (TYPE(oldbt) == T_ARRAY && RARRAY(oldbt)->len > 0) {
rb_ary_unshift(errat, rb_ary_entry(oldbt, 0));
}
- set_backtrace(th->errinfo, errat);
- rb_exc_raise(th->errinfo);
+ set_backtrace(errinfo, errat);
+ rb_exc_raise(errinfo);
}
+ return Qtrue;
+}
+
+
+/*
+ * call-seq:
+ * thr.join => thr
+ * thr.join(limit) => thr
+ *
+ * The calling thread will suspend execution and run <i>thr</i>. Does not
+ * return until <i>thr</i> exits or until <i>limit</i> seconds have passed. If
+ * the time limit expires, <code>nil</code> will be returned, otherwise
+ * <i>thr</i> is returned.
+ *
+ * Any threads not joined will be killed when the main program exits. If
+ * <i>thr</i> had previously raised an exception and the
+ * <code>abort_on_exception</code> and <code>$DEBUG</code> flags are not set
+ * (so the exception has not yet been processed) it will be processed at this
+ * time.
+ *
+ * a = Thread.new { print "a"; sleep(10); print "b"; print "c" }
+ * x = Thread.new { print "x"; Thread.pass; print "y"; print "z" }
+ * x.join # Let x thread finish, a will be killed on exit.
+ *
+ * <em>produces:</em>
+ *
+ * axyz
+ *
+ * The following example illustrates the <i>limit</i> parameter.
+ *
+ * y = Thread.new { 4.times { sleep 0.1; puts 'tick... ' }}
+ * puts "Waiting" until y.join(0.15)
+ *
+ * <em>produces:</em>
+ *
+ * tick...
+ * Waiting
+ * tick...
+ * Waitingtick...
+ *
+ *
+ * tick...
+ */
+
+static VALUE
+rb_thread_join_m(argc, argv, thread)
+ int argc;
+ VALUE *argv;
+ VALUE thread;
+{
+ VALUE limit;
+ double delay = DELAY_INFTY;
+ rb_thread_t th = rb_thread_check(thread);
+
+ rb_scan_args(argc, argv, "01", &limit);
+ if (!NIL_P(limit)) delay = rb_num2dbl(limit);
+ if (!rb_thread_join(th, delay))
+ return Qnil;
return thread;
}
+
+/*
+ * call-seq:
+ * Thread.current => thread
+ *
+ * Returns the currently executing thread.
+ *
+ * Thread.current #=> #<Thread:0x401bdf4c run>
+ */
+
VALUE
rb_thread_current()
{
return curr_thread->thread;
}
+
+/*
+ * call-seq:
+ * Thread.main => thread
+ *
+ * Returns the main thread for the process.
+ *
+ * Thread.main #=> #<Thread:0x401bdf4c run>
+ */
+
VALUE
rb_thread_main()
{
return main_thread->thread;
}
+
+/*
+ * call-seq:
+ * Thread.list => array
+ *
+ * Returns an array of <code>Thread</code> objects for all threads that are
+ * either runnable or stopped.
+ *
+ * Thread.new { sleep(200) }
+ * Thread.new { 1000000.times {|i| i*i } }
+ * Thread.new { Thread.stop }
+ * Thread.list.each {|t| p t}
+ *
+ * <em>produces:</em>
+ *
+ * #<Thread:0x401b3e84 sleep>
+ * #<Thread:0x401b3f38 run>
+ * #<Thread:0x401b3fb0 sleep>
+ * #<Thread:0x401bdf4c run>
+ */
+
VALUE
rb_thread_list()
{
@@ -7769,6 +10678,7 @@ rb_thread_list()
switch (th->status) {
case THREAD_RUNNABLE:
case THREAD_STOPPED:
+ case THREAD_TO_KILL:
rb_ary_push(ary, th->thread);
default:
break;
@@ -7779,6 +10689,22 @@ rb_thread_list()
return ary;
}
+
+/*
+ * call-seq:
+ * thr.wakeup => thr
+ *
+ * Marks <i>thr</i> as eligible for scheduling (it may still remain blocked on
+ * I/O, however). Does not invoke the scheduler (see <code>Thread#run</code>).
+ *
+ * c = Thread.new { Thread.stop; puts "hey!" }
+ * c.wakeup
+ *
+ * <em>produces:</em>
+ *
+ * hey!
+ */
+
VALUE
rb_thread_wakeup(thread)
VALUE thread;
@@ -7792,6 +10718,27 @@ rb_thread_wakeup(thread)
return thread;
}
+
+/*
+ * call-seq:
+ * thr.run => thr
+ *
+ * Wakes up <i>thr</i>, making it eligible for scheduling. If not in a critical
+ * section, then invokes the scheduler.
+ *
+ * a = Thread.new { puts "a"; Thread.stop; puts "c" }
+ * Thread.pass
+ * puts "Got here"
+ * a.run
+ * a.join
+ *
+ * <em>produces:</em>
+ *
+ * a
+ * Got here
+ * c
+ */
+
VALUE
rb_thread_run(thread)
VALUE thread;
@@ -7802,7 +10749,20 @@ rb_thread_run(thread)
return thread;
}
-static VALUE
+
+/*
+ * call-seq:
+ * thr.exit => thr or nil
+ * thr.kill => thr or nil
+ * thr.terminate => thr or nil
+ *
+ * Terminates <i>thr</i> and schedules another thread to be run. If this thread
+ * is already marked to be killed, <code>exit</code> returns the
+ * <code>Thread</code>. If this is the main thread, or the last thread, exits
+ * the process.
+ */
+
+VALUE
rb_thread_kill(thread)
VALUE thread;
{
@@ -7812,16 +10772,30 @@ rb_thread_kill(thread)
rb_secure(4);
}
if (th->status == THREAD_TO_KILL || th->status == THREAD_KILLED)
- return thread;
- if (th == th->next || th == main_thread) rb_exit(0);
+ return thread;
+ if (th == th->next || th == main_thread) rb_exit(EXIT_SUCCESS);
rb_thread_ready(th);
- th->gid = 0;
th->status = THREAD_TO_KILL;
if (!rb_thread_critical) rb_thread_schedule();
return thread;
}
+
+/*
+ * call-seq:
+ * Thread.kill(thread) => thread
+ *
+ * Causes the given <em>thread</em> to exit (see <code>Thread::exit</code>).
+ *
+ * count = 0
+ * a = Thread.new { loop { count += 1 } }
+ * sleep(0.1) #=> 0
+ * Thread.kill(a) #=> #<Thread:0x401b3d30 dead>
+ * count #=> 93947
+ * a.alive? #=> false
+ */
+
static VALUE
rb_thread_s_kill(obj, th)
VALUE obj, th;
@@ -7829,12 +10803,44 @@ rb_thread_s_kill(obj, th)
return rb_thread_kill(th);
}
+
+/*
+ * call-seq:
+ * Thread.exit => thread
+ *
+ * Terminates the currently running thread and schedules another thread to be
+ * run. If this thread is already marked to be killed, <code>exit</code>
+ * returns the <code>Thread</code>. If this is the main thread, or the last
+ * thread, exit the process.
+ */
+
static VALUE
rb_thread_exit()
{
return rb_thread_kill(curr_thread->thread);
}
+
+/*
+ * call-seq:
+ * Thread.pass => nil
+ *
+ * Invokes the thread scheduler to pass execution to another thread.
+ *
+ * a = Thread.new { print "a"; Thread.pass;
+ * print "b"; Thread.pass;
+ * print "c" }
+ * b = Thread.new { print "x"; Thread.pass;
+ * print "y"; Thread.pass;
+ * print "z" }
+ * a.join
+ * b.join
+ *
+ * <em>produces:</em>
+ *
+ * axbycz
+ */
+
static VALUE
rb_thread_pass()
{
@@ -7842,6 +10848,26 @@ rb_thread_pass()
return Qnil;
}
+
+/*
+ * call-seq:
+ * Thread.stop => nil
+ *
+ * Stops execution of the current thread, putting it into a ``sleep'' state,
+ * and schedules execution of another thread. Resets the ``critical'' condition
+ * to <code>false</code>.
+ *
+ * a = Thread.new { print "a"; Thread.stop; print "c" }
+ * Thread.pass
+ * print "b"
+ * a.run
+ * a.join
+ *
+ * <em>produces:</em>
+ *
+ * abc
+ */
+
VALUE
rb_thread_stop()
{
@@ -7886,21 +10912,16 @@ rb_thread_sleep(sec)
rb_thread_wait_for(rb_time_timeval(INT2FIX(sec)));
}
-#if !defined HAVE_PAUSE
-# if defined _WIN32 && !defined __CYGWIN__
-# define pause() Sleep(INFINITE)
-# else
-# define pause() sleep(0x7fffffff)
-# endif
-#endif
-
void
rb_thread_sleep_forever()
{
+ int thr_critical = rb_thread_critical;
if (curr_thread == curr_thread->next ||
curr_thread->status == THREAD_TO_KILL) {
+ rb_thread_critical = Qtrue;
TRAP_BEG;
pause();
+ rb_thread_critical = thr_critical;
TRAP_END;
return;
}
@@ -7911,6 +10932,17 @@ rb_thread_sleep_forever()
rb_thread_schedule();
}
+
+/*
+ * call-seq:
+ * thr.priority => integer
+ *
+ * Returns the priority of <i>thr</i>. Default is zero; higher-priority threads
+ * will run before lower-priority threads.
+ *
+ * Thread.current.priority #=> 0
+ */
+
static VALUE
rb_thread_priority(thread)
VALUE thread;
@@ -7918,6 +10950,30 @@ rb_thread_priority(thread)
return INT2NUM(rb_thread_check(thread)->priority);
}
+
+/*
+ * call-seq:
+ * thr.priority= integer => thr
+ *
+ * Sets the priority of <i>thr</i> to <i>integer</i>. Higher-priority threads
+ * will run before lower-priority threads.
+ *
+ * count1 = count2 = 0
+ * a = Thread.new do
+ * loop { count1 += 1 }
+ * end
+ * a.priority = -1
+ *
+ * b = Thread.new do
+ * loop { count2 += 1 }
+ * end
+ * b.priority = -2
+ * sleep 1 #=> 1
+ * Thread.critical = 1
+ * count1 #=> 622504
+ * count2 #=> 5832
+ */
+
static VALUE
rb_thread_priority_set(thread, prio)
VALUE thread, prio;
@@ -7929,9 +10985,22 @@ rb_thread_priority_set(thread, prio)
th->priority = NUM2INT(prio);
rb_thread_schedule();
- return thread;
+ return prio;
}
+
+/*
+ * call-seq:
+ * thr.safe_level => integer
+ *
+ * Returns the safe level in effect for <i>thr</i>. Setting thread-local safe
+ * levels can help when implementing sandboxes which run insecure code.
+ *
+ * thr = Thread.new { $SAFE = 3; sleep }
+ * Thread.current.safe_level #=> 0
+ * thr.safe_level #=> 3
+ */
+
static VALUE
rb_thread_safe_level(thread)
VALUE thread;
@@ -7940,28 +11009,77 @@ rb_thread_safe_level(thread)
th = rb_thread_check(thread);
if (th == curr_thread) {
- return INT2NUM(rb_safe_level());
+ return INT2NUM(ruby_safe_level);
}
return INT2NUM(th->safe);
}
-static int thread_abort;
+static int ruby_thread_abort;
+static VALUE thgroup_default;
+
+
+/*
+ * call-seq:
+ * Thread.abort_on_exception => true or false
+ *
+ * Returns the status of the global ``abort on exception'' condition. The
+ * default is <code>false</code>. When set to <code>true</code>, or if the
+ * global <code>$DEBUG</code> flag is <code>true</code> (perhaps because the
+ * command line option <code>-d</code> was specified) all threads will abort
+ * (the process will <code>exit(0)</code>) if an exception is raised in any
+ * thread. See also <code>Thread::abort_on_exception=</code>.
+ */
static VALUE
rb_thread_s_abort_exc()
{
- return thread_abort?Qtrue:Qfalse;
-}
+ return ruby_thread_abort?Qtrue:Qfalse;
+}
+
+
+/*
+ * call-seq:
+ * Thread.abort_on_exception= boolean => true or false
+ *
+ * When set to <code>true</code>, all threads will abort if an exception is
+ * raised. Returns the new state.
+ *
+ * Thread.abort_on_exception = true
+ * t1 = Thread.new do
+ * puts "In new thread"
+ * raise "Exception from thread"
+ * end
+ * sleep(1)
+ * puts "not reached"
+ *
+ * <em>produces:</em>
+ *
+ * In new thread
+ * prog.rb:4: Exception from thread (RuntimeError)
+ * from prog.rb:2:in `initialize'
+ * from prog.rb:2:in `new'
+ * from prog.rb:2
+ */
static VALUE
rb_thread_s_abort_exc_set(self, val)
VALUE self, val;
{
rb_secure(4);
- thread_abort = RTEST(val);
+ ruby_thread_abort = RTEST(val);
return val;
}
+
+/*
+ * call-seq:
+ * thr.abort_on_exception => true or false
+ *
+ * Returns the status of the thread-local ``abort on exception'' condition for
+ * <i>thr</i>. The default is <code>false</code>. See also
+ * <code>Thread::abort_on_exception=</code>.
+ */
+
static VALUE
rb_thread_abort_exc(thread)
VALUE thread;
@@ -7969,6 +11087,16 @@ rb_thread_abort_exc(thread)
return rb_thread_check(thread)->abort?Qtrue:Qfalse;
}
+
+/*
+ * call-seq:
+ * thr.abort_on_exception= boolean => true or false
+ *
+ * When set to <code>true</code>, causes all threads (including the main
+ * program) to abort if an exception is raised in <i>thr</i>. The process will
+ * effectively <code>exit(0)</code>.
+ */
+
static VALUE
rb_thread_abort_exc_set(thread, val)
VALUE thread, val;
@@ -7978,6 +11106,34 @@ rb_thread_abort_exc_set(thread, val)
return val;
}
+
+/*
+ * call-seq:
+ * thr.group => thgrp or nil
+ *
+ * Returns the <code>ThreadGroup</code> which contains <i>thr</i>, or nil if
+ * the thread is not a member of any group.
+ *
+ * Thread.main.group #=> #<ThreadGroup:0x4029d914>
+ */
+
+VALUE
+rb_thread_group(thread)
+ VALUE thread;
+{
+ VALUE group = rb_thread_check(thread)->thgroup;
+ if (!group) {
+ group = Qnil;
+ }
+ return group;
+}
+
+#ifdef __ia64__
+# define IA64_INIT(x) x
+#else
+# define IA64_INIT(x)
+#endif
+
#define THREAD_ALLOC(th) do {\
th = ALLOC(struct thread);\
\
@@ -7992,6 +11148,8 @@ rb_thread_abort_exc_set(thread, val)
th->stk_len = 0;\
th->stk_max = 0;\
th->wait_for = 0;\
+ IA64_INIT(th->bstr_ptr = 0);\
+ IA64_INIT(th->bstr_len = 0);\
FD_ZERO(&th->readfds);\
FD_ZERO(&th->writefds);\
FD_ZERO(&th->exceptfds);\
@@ -8011,12 +11169,13 @@ rb_thread_abort_exc_set(thread, val)
th->errinfo = Qnil;\
th->last_status = 0;\
th->last_line = 0;\
- th->last_match = 0;\
+ th->last_match = Qnil;\
th->abort = 0;\
th->priority = 0;\
- th->gid = 1;\
+ th->thgroup = thgroup_default;\
th->locals = 0;\
-} while(0)
+ th->thread = 0;\
+} while (0)
static rb_thread_t
rb_thread_alloc(klass)
@@ -8035,7 +11194,9 @@ rb_thread_alloc(klass)
return th;
}
-#if defined(HAVE_SETITIMER)
+static int thread_init = 0;
+
+#if defined(_THREAD_SAFE)
static void
catch_timer(sig)
int sig;
@@ -8043,21 +11204,59 @@ catch_timer(sig)
#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
signal(sig, catch_timer);
#endif
- if (!rb_thread_critical) {
- if (rb_trap_immediate) {
- rb_thread_schedule();
- }
- else rb_thread_pending = 1;
- }
+ /* cause EINTR */
}
+
+static pthread_t time_thread;
+
+static void*
+thread_timer(dummy)
+ void *dummy;
+{
+ for (;;) {
+#ifdef HAVE_NANOSLEEP
+ struct timespec req, rem;
+
+ req.tv_sec = 0;
+ req.tv_nsec = 10000000;
+ nanosleep(&req, &rem);
#else
-int rb_thread_tick = THREAD_TICK;
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 10000;
+ select(0, NULL, NULL, NULL, &tv);
#endif
+ if (!rb_thread_critical) {
+ rb_thread_pending = 1;
+ if (rb_trap_immediate) {
+ pthread_kill(ruby_thid, SIGVTALRM);
+ }
+ }
+ }
+}
-#define SCOPE_SHARED FL_USER1
+void
+rb_thread_start_timer()
+{
+}
-#if defined(HAVE_SETITIMER)
-static int thread_init = 0;
+void
+rb_thread_stop_timer()
+{
+}
+#elif defined(HAVE_SETITIMER)
+static void
+catch_timer(sig)
+ int sig;
+{
+#if !defined(POSIX_SIGNAL) && !defined(BSD_SIGNAL)
+ signal(sig, catch_timer);
+#endif
+ if (!rb_thread_critical) {
+ rb_thread_pending = 1;
+ }
+ /* cause EINTR */
+}
void
rb_thread_start_timer()
@@ -8082,34 +11281,49 @@ rb_thread_stop_timer()
tval.it_value = tval.it_interval;
setitimer(ITIMER_VIRTUAL, &tval, NULL);
}
+#else /* !(_THREAD_SAFE || HAVE_SETITIMER) */
+int rb_thread_tick = THREAD_TICK;
#endif
static VALUE
-rb_thread_start_0(fn, arg, th_arg)
+rb_thread_start_0(fn, arg, th)
VALUE (*fn)();
void *arg;
- rb_thread_t th_arg;
+ rb_thread_t th;
{
- volatile rb_thread_t th = th_arg;
+ volatile rb_thread_t th_save = th;
volatile VALUE thread = th->thread;
- struct BLOCK* saved_block = 0;
+ struct BLOCK *volatile saved_block = 0, *block;
enum thread_status status;
int state;
-#if defined(HAVE_SETITIMER)
+ if (OBJ_FROZEN(curr_thread->thgroup)) {
+ rb_raise(rb_eThreadError,
+ "can't start a new thread (frozen ThreadGroup)");
+ }
+
if (!thread_init) {
-#ifdef POSIX_SIGNAL
+ thread_init = 1;
+#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE)
+#if defined(POSIX_SIGNAL)
posix_signal(SIGVTALRM, catch_timer);
#else
signal(SIGVTALRM, catch_timer);
#endif
- thread_init = 1;
+#ifdef _THREAD_SAFE
+ pthread_create(&time_thread, 0, thread_timer, 0);
+#else
rb_thread_start_timer();
- }
#endif
+#endif
+ }
+
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return thread;
+ }
- if (ruby_block) { /* should nail down higher scopes */
+ if (ruby_block) { /* should nail down higher blocks */
struct BLOCK dummy;
dummy.prev = ruby_block;
@@ -8117,10 +11331,6 @@ rb_thread_start_0(fn, arg, th_arg)
saved_block = ruby_block = dummy.prev;
}
scope_dup(ruby_scope);
- FL_SET(ruby_scope, SCOPE_SHARED);
- if (THREAD_SAVE_CONTEXT(curr_thread)) {
- return thread;
- }
if (!th->next) {
/* merge in thread list */
@@ -8129,7 +11339,7 @@ rb_thread_start_0(fn, arg, th_arg)
th->next = curr_thread->next;
curr_thread->next = th;
th->priority = curr_thread->priority;
- th->gid = curr_thread->gid;
+ th->thgroup = curr_thread->thgroup;
}
PUSH_TAG(PROT_THREAD);
@@ -8138,48 +11348,51 @@ rb_thread_start_0(fn, arg, th_arg)
curr_thread = th;
th->result = (*fn)(arg, th);
}
+ th = th_save;
+ }
+ else if (TAG_DST()) {
+ th = th_save;
+ th->result = prot_tag->retval;
}
POP_TAG();
status = th->status;
- while (saved_block) {
- struct BLOCK *tmp = saved_block;
+ if (th == main_thread) ruby_stop(state);
+ rb_thread_remove(th);
- if (tmp->frame.argc > 0)
- free(tmp->frame.argv);
- saved_block = tmp->prev;
- free(tmp);
+ if (saved_block) {
+ blk_free(saved_block);
}
- if (th == main_thread) ruby_stop(state);
- rb_thread_remove(th);
if (state && status != THREAD_TO_KILL && !NIL_P(ruby_errinfo)) {
th->flags |= THREAD_RAISED;
- if (state == TAG_FATAL) {
+ if (state == TAG_FATAL) {
/* fatal error within this thread, need to stop whole script */
main_thread->errinfo = ruby_errinfo;
rb_thread_cleanup();
}
else if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
if (th->safe >= 4) {
- rb_raise(rb_eSecurityError, "Insecure exit at level %d",
- ruby_safe_level);
+ char buf[32];
+
+ sprintf(buf, "Insecure exit at level %d", th->safe);
+ th->errinfo = rb_exc_new2(rb_eSecurityError, buf);
+ }
+ else {
+ /* delegate exception to main_thread */
+ rb_thread_main_jump(ruby_errinfo, RESTORE_RAISE);
}
- /* delegate exception to main_thread */
- rb_thread_raise(1, &ruby_errinfo, main_thread);
}
- else if (th->safe < 4 &&
- (thread_abort || th->abort || RTEST(ruby_debug))) {
- VALUE err = rb_exc_new(rb_eSystemExit, 0, 0);
- error_print();
+ else if (th->safe < 4 && (ruby_thread_abort || th->abort || RTEST(ruby_debug))) {
/* exit on main_thread */
- rb_thread_raise(1, &err, main_thread);
+ rb_thread_main_jump(ruby_errinfo, RESTORE_EXIT);
}
else {
th->errinfo = ruby_errinfo;
}
}
rb_thread_schedule();
+ ruby_stop(0); /* last thread termination */
return 0; /* not reached */
}
@@ -8188,23 +11401,52 @@ rb_thread_create(fn, arg)
VALUE (*fn)();
void *arg;
{
+ Init_stack((VALUE*)&arg);
return rb_thread_start_0(fn, arg, rb_thread_alloc(rb_cThread));
}
-int
-rb_thread_scope_shared_p()
-{
- return FL_TEST(ruby_scope, SCOPE_SHARED);
-}
-
static VALUE
-rb_thread_yield(arg, th)
+rb_thread_yield(arg, th)
VALUE arg;
rb_thread_t th;
{
+ const ID *tbl;
+
scope_dup(ruby_block->scope);
- return rb_yield_0(callargs(arg), 0, 0, Qtrue);
-}
+
+ tbl = ruby_scope->local_tbl;
+ if (tbl) {
+ int n = *tbl++;
+ for (tbl += 2, n -= 2; n > 0; --n) { /* skip first 2 ($_ and $~) */
+ ID id = *tbl++;
+ if (id != 0 && !rb_is_local_id(id)) /* push flip states */
+ rb_dvar_push(id, Qfalse);
+ }
+ }
+ rb_dvar_push('_', Qnil);
+ rb_dvar_push('~', Qnil);
+ ruby_block->dyna_vars = ruby_dyna_vars;
+
+ return rb_yield_0(arg, 0, 0, YIELD_LAMBDA_CALL, Qtrue);
+}
+
+/*
+ * call-seq:
+ * Thread.new([arg]*) {|args| block } => thread
+ *
+ * Creates and runs a new thread to execute the instructions given in
+ * <i>block</i>. Any arguments passed to <code>Thread::new</code> are passed
+ * into the block.
+ *
+ * x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" }
+ * a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" }
+ * x.join # Let the threads finish before
+ * a.join # main thread exits...
+ *
+ * <em>produces:</em>
+ *
+ * abxyzc
+ */
static VALUE
rb_thread_s_new(argc, argv, klass)
@@ -8225,6 +11467,25 @@ rb_thread_s_new(argc, argv, klass)
return th->thread;
}
+
+/*
+ * call-seq:
+ * Thread.new([arg]*) {|args| block } => thread
+ *
+ * Creates and runs a new thread to execute the instructions given in
+ * <i>block</i>. Any arguments passed to <code>Thread::new</code> are passed
+ * into the block.
+ *
+ * x = Thread.new { sleep 0.1; print "x"; print "y"; print "z" }
+ * a = Thread.new { print "a"; print "b"; sleep 0.2; print "c" }
+ * x.join # Let the threads finish before
+ * a.join # main thread exits...
+ *
+ * <em>produces:</em>
+ *
+ * abxyzc
+ */
+
static VALUE
rb_thread_initialize(thread, args)
VALUE thread, args;
@@ -8235,6 +11496,17 @@ rb_thread_initialize(thread, args)
return rb_thread_start_0(rb_thread_yield, args, rb_thread_check(thread));
}
+
+/*
+ * call-seq:
+ * Thread.start([args]*) {|args| block } => thread
+ * Thread.fork([args]*) {|args| block } => thread
+ *
+ * Basically the same as <code>Thread::new</code>. However, if class
+ * <code>Thread</code> is subclassed, then calling <code>start</code> in that
+ * subclass will not invoke the subclass's <code>initialize</code> method.
+ */
+
static VALUE
rb_thread_start(klass, args)
VALUE klass, args;
@@ -8245,17 +11517,53 @@ rb_thread_start(klass, args)
return rb_thread_start_0(rb_thread_yield, args, rb_thread_alloc(klass));
}
+
+/*
+ * call-seq:
+ * thr.value => obj
+ *
+ * Waits for <i>thr</i> to complete (via <code>Thread#join</code>) and returns
+ * its value.
+ *
+ * a = Thread.new { 2 + 2 }
+ * a.value #=> 4
+ */
+
static VALUE
rb_thread_value(thread)
VALUE thread;
{
rb_thread_t th = rb_thread_check(thread);
- rb_thread_join(thread);
+ while (!rb_thread_join(th, DELAY_INFTY));
return th->result;
}
+
+/*
+ * call-seq:
+ * thr.status => string, false or nil
+ *
+ * Returns the status of <i>thr</i>: ``<code>sleep</code>'' if <i>thr</i> is
+ * sleeping or waiting on I/O, ``<code>run</code>'' if <i>thr</i> is executing,
+ * ``<code>aborting</code>'' if <i>thr</i> is aborting, <code>false</code> if
+ * <i>thr</i> terminated normally, and <code>nil</code> if <i>thr</i>
+ * terminated with an exception.
+ *
+ * a = Thread.new { raise("die now") }
+ * b = Thread.new { Thread.stop }
+ * c = Thread.new { Thread.exit }
+ * d = Thread.new { sleep }
+ * Thread.critical = true
+ * d.kill #=> #<Thread:0x401b3678 aborting>
+ * a.status #=> nil
+ * b.status #=> "sleep"
+ * c.status #=> false
+ * d.status #=> "aborting"
+ * Thread.current.status #=> "run"
+ */
+
static VALUE
rb_thread_status(thread)
VALUE thread;
@@ -8268,11 +11576,22 @@ rb_thread_status(thread)
return Qfalse;
}
- if (th->status == THREAD_STOPPED)
- return rb_str_new2("sleep");
- return rb_str_new2("run");
+ return rb_str_new2(thread_status_name(th->status));
}
+
+/*
+ * call-seq:
+ * thr.alive? => true or false
+ *
+ * Returns <code>true</code> if <i>thr</i> is running or sleeping.
+ *
+ * thr = Thread.new { }
+ * thr.join #=> #<Thread:0x401b3fb0 dead>
+ * Thread.current.alive? #=> true
+ * thr.alive? #=> false
+ */
+
static VALUE
rb_thread_alive_p(thread)
VALUE thread;
@@ -8283,6 +11602,19 @@ rb_thread_alive_p(thread)
return Qtrue;
}
+
+/*
+ * call-seq:
+ * thr.stop? => true or false
+ *
+ * Returns <code>true</code> if <i>thr</i> is dead or sleeping.
+ *
+ * a = Thread.new { Thread.stop }
+ * b = Thread.current
+ * a.stop? #=> true
+ * b.stop? #=> false
+ */
+
static VALUE
rb_thread_stop_p(thread)
VALUE thread;
@@ -8297,8 +11629,20 @@ rb_thread_stop_p(thread)
static void
rb_thread_wait_other_threads()
{
+ rb_thread_t th;
+ int found;
+
/* wait other threads to terminate */
while (curr_thread != curr_thread->next) {
+ found = 0;
+ FOREACH_THREAD(th) {
+ if (th != curr_thread && th->status != THREAD_STOPPED) {
+ found = 1;
+ break;
+ }
+ }
+ END_FOREACH(th);
+ if (!found) return;
rb_thread_schedule();
}
}
@@ -8306,31 +11650,58 @@ rb_thread_wait_other_threads()
static void
rb_thread_cleanup()
{
- rb_thread_t th;
+ rb_thread_t curr, th;
- while (curr_thread->status == THREAD_KILLED) {
- curr_thread = curr_thread->prev;
+ curr = curr_thread;
+ while (curr->status == THREAD_KILLED) {
+ curr = curr->prev;
}
- FOREACH_THREAD(th) {
- if (th != curr_thread && th->status != THREAD_KILLED) {
+ FOREACH_THREAD_FROM(curr, th) {
+ if (th->status != THREAD_KILLED) {
rb_thread_ready(th);
- th->gid = 0;
- th->priority = 0;
- th->status = THREAD_TO_KILL;
+ if (th != main_thread) {
+ th->thgroup = 0;
+ th->priority = 0;
+ th->status = THREAD_TO_KILL;
+ RDATA(th->thread)->dfree = NULL;
+ }
}
}
- END_FOREACH(th);
+ END_FOREACH_FROM(curr, th);
}
int rb_thread_critical;
+
+/*
+ * call-seq:
+ * Thread.critical => true or false
+ *
+ * Returns the status of the global ``thread critical'' condition.
+ */
+
static VALUE
rb_thread_critical_get()
{
return rb_thread_critical?Qtrue:Qfalse;
}
+
+/*
+ * call-seq:
+ * Thread.critical= boolean => true or false
+ *
+ * Sets the status of the global ``thread critical'' condition and returns
+ * it. When set to <code>true</code>, prohibits scheduling of any existing
+ * thread. Does not block new threads from being created and run. Certain
+ * thread operations (such as stopping or killing a thread, sleeping in the
+ * current thread, and raising an exception) may cause a thread to be scheduled
+ * even when in a critical section. <code>Thread::critical</code> is not
+ * intended for daily use: it is primarily there to support folks writing
+ * threading libraries.
+ */
+
static VALUE
rb_thread_critical_set(obj, val)
VALUE obj, val;
@@ -8347,8 +11718,10 @@ rb_thread_interrupt()
if (curr_thread == main_thread) {
rb_interrupt();
}
- if (THREAD_SAVE_CONTEXT(curr_thread)) {
- return;
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return;
+ }
}
curr_thread = main_thread;
rb_thread_restore_context(curr_thread, RESTORE_INTERRUPT);
@@ -8365,8 +11738,10 @@ rb_thread_signal_raise(sig)
rb_raise(rb_eSignal, "SIG%s", sig);
}
rb_thread_ready(main_thread);
- if (THREAD_SAVE_CONTEXT(curr_thread)) {
- return;
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return;
+ }
}
th_signm = sig;
curr_thread = main_thread;
@@ -8374,38 +11749,21 @@ rb_thread_signal_raise(sig)
}
void
-rb_thread_trap_eval(cmd, sig)
+rb_thread_trap_eval(cmd, sig, safe)
VALUE cmd;
- int sig;
+ int sig, safe;
{
-#if 0
- rb_thread_critical = 0;
- if (!rb_thread_dead(curr_thread)) {
- rb_thread_ready(curr_thread);
- rb_trap_eval(cmd, sig);
- return;
- }
- rb_thread_ready(main_thread);
- if (THREAD_SAVE_CONTEXT(curr_thread)) {
- return;
- }
- th_cmd = cmd;
- th_sig = sig;
- curr_thread = main_thread;
- rb_thread_restore_context(curr_thread, RESTORE_TRAP);
-#else
rb_thread_critical = 0;
if (!rb_thread_dead(curr_thread)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) {
return;
}
}
- rb_thread_ready(main_thread);
th_cmd = cmd;
th_sig = sig;
+ th_safe = safe;
curr_thread = main_thread;
rb_thread_restore_context(curr_thread, RESTORE_TRAP);
-#endif
}
static VALUE
@@ -8414,26 +11772,53 @@ rb_thread_raise(argc, argv, th)
VALUE *argv;
rb_thread_t th;
{
+ volatile rb_thread_t th_save = th;
+ VALUE exc;
+
+ if (!th->next) {
+ rb_raise(rb_eArgError, "unstarted thread");
+ }
if (rb_thread_dead(th)) return Qnil;
+ exc = rb_make_exception(argc, argv);
if (curr_thread == th) {
- rb_f_raise(argc, argv);
+ rb_raise_jump(exc);
}
- if (THREAD_SAVE_CONTEXT(curr_thread)) {
- return th->thread;
+ if (!rb_thread_dead(curr_thread)) {
+ if (THREAD_SAVE_CONTEXT(curr_thread)) {
+ return th_save->thread;
+ }
}
- rb_scan_args(argc, argv, "11", &th_raise_argv[0], &th_raise_argv[1]);
rb_thread_ready(th);
curr_thread = th;
- th_raise_argc = argc;
- th_raise_file = ruby_sourcefile;
- th_raise_line = ruby_sourceline;
+ th_raise_exception = exc;
+ th_raise_node = ruby_current_node;
rb_thread_restore_context(curr_thread, RESTORE_RAISE);
return Qnil; /* not reached */
}
+
+/*
+ * call-seq:
+ * thr.raise(exception)
+ *
+ * Raises an exception (see <code>Kernel::raise</code>) from <i>thr</i>. The
+ * caller does not have to be <i>thr</i>.
+ *
+ * Thread.abort_on_exception = true
+ * a = Thread.new { sleep(200) }
+ * a.raise("Gotcha")
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:3: Gotcha (RuntimeError)
+ * from prog.rb:2:in `initialize'
+ * from prog.rb:2:in `new'
+ * from prog.rb:2
+ */
+
static VALUE
rb_thread_raise_m(argc, argv, thread)
int argc;
@@ -8458,7 +11843,7 @@ rb_thread_local_aref(thread, id)
VALUE val;
th = rb_thread_check(thread);
- if (rb_safe_level() >= 4 && th != curr_thread) {
+ if (ruby_safe_level >= 4 && th != curr_thread) {
rb_raise(rb_eSecurityError, "Insecure: thread locals");
}
if (!th->locals) return Qnil;
@@ -8468,6 +11853,28 @@ rb_thread_local_aref(thread, id)
return Qnil;
}
+
+/*
+ * call-seq:
+ * thr[sym] => obj or nil
+ *
+ * Attribute Reference---Returns the value of a thread-local variable, using
+ * either a symbol or a string name. If the specified variable does not exist,
+ * returns <code>nil</code>.
+ *
+ * a = Thread.new { Thread.current["name"] = "A"; Thread.stop }
+ * b = Thread.new { Thread.current[:name] = "B"; Thread.stop }
+ * c = Thread.new { Thread.current["name"] = "C"; Thread.stop }
+ * Thread.list.each {|x| puts "#{x.inspect}: #{x[:name]}" }
+ *
+ * <em>produces:</em>
+ *
+ * #<Thread:0x401b3b3c sleep>: C
+ * #<Thread:0x401b3bc8 sleep>: B
+ * #<Thread:0x401b3c68 sleep>: A
+ * #<Thread:0x401bdf4c run>:
+ */
+
static VALUE
rb_thread_aref(thread, id)
VALUE thread, id;
@@ -8483,7 +11890,7 @@ rb_thread_local_aset(thread, id, val)
{
rb_thread_t th = rb_thread_check(thread);
- if (rb_safe_level() >= 4 && th != curr_thread) {
+ if (ruby_safe_level >= 4 && th != curr_thread) {
rb_raise(rb_eSecurityError, "Insecure: can't modify thread locals");
}
if (OBJ_FROZEN(thread)) rb_error_frozen("thread locals");
@@ -8492,7 +11899,7 @@ rb_thread_local_aset(thread, id, val)
th->locals = st_init_numtable();
}
if (NIL_P(val)) {
- st_delete(th->locals, &id, 0);
+ st_delete(th->locals, (st_data_t*)&id, 0);
return Qnil;
}
st_insert(th->locals, id, val);
@@ -8500,6 +11907,15 @@ rb_thread_local_aset(thread, id, val)
return val;
}
+
+/*
+ * call-seq:
+ * thr[sym] = obj => obj
+ *
+ * Attribute Assignment---Sets or creates the value of a thread-local variable,
+ * using either a symbol or a string. See also <code>Thread#[]</code>.
+ */
+
static VALUE
rb_thread_aset(thread, id, val)
VALUE thread, id, val;
@@ -8507,6 +11923,20 @@ rb_thread_aset(thread, id, val)
return rb_thread_local_aset(thread, rb_to_id(id), val);
}
+
+/*
+ * call-seq:
+ * thr.key?(sym) => true or false
+ *
+ * Returns <code>true</code> if the given string (or symbol) exists as a
+ * thread-local variable.
+ *
+ * me = Thread.current
+ * me[:oliver] = "a"
+ * me.key?(:oliver) #=> true
+ * me.key?(:stanley) #=> false
+ */
+
static VALUE
rb_thread_key_p(thread, id)
VALUE thread, id;
@@ -8519,28 +11949,60 @@ rb_thread_key_p(thread, id)
return Qfalse;
}
+static int
+thread_keys_i(key, value, ary)
+ ID key;
+ VALUE value, ary;
+{
+ rb_ary_push(ary, ID2SYM(key));
+ return ST_CONTINUE;
+}
+
+
+/*
+ * call-seq:
+ * thr.keys => array
+ *
+ * Returns an an array of the names of the thread-local variables (as Symbols).
+ *
+ * thr = Thread.new do
+ * Thread.current[:cat] = 'meow'
+ * Thread.current["dog"] = 'woof'
+ * end
+ * thr.join #=> #<Thread:0x401b3f10 dead>
+ * thr.keys #=> [:dog, :cat]
+ */
+
+static VALUE
+rb_thread_keys(thread)
+ VALUE thread;
+{
+ rb_thread_t th = rb_thread_check(thread);
+ VALUE ary = rb_ary_new();
+
+ if (th->locals) {
+ st_foreach(th->locals, thread_keys_i, ary);
+ }
+ return ary;
+}
+
+/*
+ * call-seq:
+ * thr.inspect => string
+ *
+ * Dump the name, id, and status of _thr_ to a string.
+ */
+
static VALUE
rb_thread_inspect(thread)
VALUE thread;
{
- char *cname = rb_class2name(CLASS_OF(thread));
+ char *cname = rb_obj_classname(thread);
rb_thread_t th = rb_thread_check(thread);
- char *status;
+ const char *status = thread_status_name(th->status);
VALUE str;
- switch (th->status) {
- case THREAD_RUNNABLE:
- status = "run"; break;
- case THREAD_STOPPED:
- status = "sleep"; break;
- case THREAD_TO_KILL:
- status = "aborting"; break;
- case THREAD_KILLED:
- status = "dead"; break;
- default:
- status = "unknown"; break;
- }
- str = rb_str_new(0, strlen(cname)+7+16+9+1); /* 7:tags 16:addr 9:status 1:nul */
+ str = rb_str_new(0, strlen(cname)+7+16+9+1); /* 7:tags 16:addr 9:status 1:nul */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx %s>", cname, thread, status);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
OBJ_INFECT(str, thread);
@@ -8551,32 +12013,94 @@ rb_thread_inspect(thread)
void
rb_thread_atfork()
{
-#if 0 /* enable on 1.7 */
rb_thread_t th;
if (rb_thread_alone()) return;
FOREACH_THREAD(th) {
if (th != curr_thread) {
- th->status = THREAD_KILLED;
+ rb_thread_die(th);
}
}
END_FOREACH(th);
main_thread = curr_thread;
curr_thread->next = curr_thread;
curr_thread->prev = curr_thread;
-#endif
}
+
+/*
+ * Document-class: Continuation
+ *
+ * Continuation objects are generated by
+ * <code>Kernel#callcc</code>. They hold a return address and execution
+ * context, allowing a nonlocal return to the end of the
+ * <code>callcc</code> block from anywhere within a program.
+ * Continuations are somewhat analogous to a structured version of C's
+ * <code>setjmp/longjmp</code> (although they contain more state, so
+ * you might consider them closer to threads).
+ *
+ * For instance:
+ *
+ * arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
+ * callcc{|$cc|}
+ * puts(message = arr.shift)
+ * $cc.call unless message =~ /Max/
+ *
+ * <em>produces:</em>
+ *
+ * Freddie
+ * Herbie
+ * Ron
+ * Max
+ *
+ * This (somewhat contrived) example allows the inner loop to abandon
+ * processing early:
+ *
+ * callcc {|cont|
+ * for i in 0..4
+ * print "\n#{i}: "
+ * for j in i*5...(i+1)*5
+ * cont.call() if j == 17
+ * printf "%3d", j
+ * end
+ * end
+ * }
+ * print "\n"
+ *
+ * <em>produces:</em>
+ *
+ * 0: 0 1 2 3 4
+ * 1: 5 6 7 8 9
+ * 2: 10 11 12 13 14
+ * 3: 15 16
+ */
+
static VALUE rb_cCont;
+/*
+ * call-seq:
+ * callcc {|cont| block } => obj
+ *
+ * Generates a <code>Continuation</code> object, which it passes to the
+ * associated block. Performing a <em>cont</em><code>.call</code> will
+ * cause the <code>callcc</code> to return (as will falling through the
+ * end of the block). The value returned by the <code>callcc</code> is
+ * the value of the block, or the value passed to
+ * <em>cont</em><code>.call</code>. See class <code>Continuation</code>
+ * for more details. Also see <code>Kernel::throw</code> for
+ * an alternative mechanism for unwinding a call stack.
+ */
+
static VALUE
rb_callcc(self)
VALUE self;
{
volatile VALUE cont;
rb_thread_t th;
+ volatile rb_thread_t th_save;
struct tag *tag;
struct RVarmap *vars;
+ struct BLOCK *blk;
THREAD_ALLOC(th);
cont = Data_Wrap_Struct(rb_cCont, thread_mark, thread_free, th);
@@ -8585,29 +12109,37 @@ rb_callcc(self)
for (tag=prot_tag; tag; tag=tag->prev) {
scope_dup(tag->scope);
}
- if (ruby_block) {
- struct BLOCK *block = ruby_block;
-
- while (block) {
- block->tag->flags |= BLOCK_DYNAMIC;
- block = block->prev;
- }
- }
th->thread = curr_thread->thread;
- for (vars = th->dyna_vars; vars; vars = vars->next) {
+ for (vars = ruby_dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
FL_SET(vars, DVAR_DONT_RECYCLE);
}
-
+ th_save = th;
if (THREAD_SAVE_CONTEXT(th)) {
- return th->result;
+ return th_save->result;
}
else {
return rb_yield(cont);
}
}
+/*
+ * call-seq:
+ * cont.call(args, ...)
+ * cont[args, ...]
+ *
+ * Invokes the continuation. The program continues from the end of the
+ * <code>callcc</code> block. If no arguments are given, the original
+ * <code>callcc</code> returns <code>nil</code>. If one argument is
+ * given, <code>callcc</code> returns it. Otherwise, an array
+ * containing <i>args</i> is returned.
+ *
+ * callcc {|cont| cont.call } #=> nil
+ * callcc {|cont| cont.call 1 } #=> 1
+ * callcc {|cont| cont.call 1, 2, 3 } #=> [1, 2, 3]
+ */
+
static VALUE
rb_cont_call(argc, argv, cont)
int argc;
@@ -8624,7 +12156,7 @@ rb_cont_call(argc, argv, cont)
th->result = Qnil;
break;
case 1:
- th->result = *argv;
+ th->result = argv[0];
break;
default:
th->result = rb_ary_new4(argc, argv);
@@ -8636,26 +12168,49 @@ rb_cont_call(argc, argv, cont)
}
struct thgroup {
- int gid;
+ int enclosed;
+ VALUE group;
};
+
+/*
+ * Document-class: ThreadGroup
+ *
+ * <code>ThreadGroup</code> provides a means of keeping track of a number of
+ * threads as a group. A <code>Thread</code> can belong to only one
+ * <code>ThreadGroup</code> at a time; adding a thread to a new group will
+ * remove it from any previous group.
+ *
+ * Newly created threads belong to the same group as the thread from which they
+ * were created.
+ */
+
+static VALUE thgroup_s_alloc _((VALUE));
static VALUE
-thgroup_s_new(argc, argv, klass)
- int argc;
- VALUE *argv;
+thgroup_s_alloc(klass)
VALUE klass;
{
VALUE group;
struct thgroup *data;
- static int serial = 1;
group = Data_Make_Struct(klass, struct thgroup, 0, free, data);
- data->gid = serial++;
+ data->enclosed = 0;
+ data->group = group;
- rb_obj_call_init(group, argc, argv);
return group;
}
+
+/*
+ * call-seq:
+ * thgrp.list => array
+ *
+ * Returns an array of all existing <code>Thread</code> objects that belong to
+ * this group.
+ *
+ * ThreadGroup::Default.list #=> [#<Thread:0x401bdf4c run>]
+ */
+
static VALUE
thgroup_list(group)
VALUE group;
@@ -8668,7 +12223,7 @@ thgroup_list(group)
ary = rb_ary_new();
FOREACH_THREAD(th) {
- if (th->gid == data->gid) {
+ if (th->thgroup == data->group) {
rb_ary_push(ary, th->thread);
}
}
@@ -8677,6 +12232,84 @@ thgroup_list(group)
return ary;
}
+
+/*
+ * call-seq:
+ * thgrp.enclose => thgrp
+ *
+ * Prevents threads from being added to or removed from the receiving
+ * <code>ThreadGroup</code>. New threads can still be started in an enclosed
+ * <code>ThreadGroup</code>.
+ *
+ * ThreadGroup::Default.enclose #=> #<ThreadGroup:0x4029d914>
+ * thr = Thread::new { Thread.stop } #=> #<Thread:0x402a7210 sleep>
+ * tg = ThreadGroup::new #=> #<ThreadGroup:0x402752d4>
+ * tg.add thr
+ *
+ * <em>produces:</em>
+ *
+ * ThreadError: can't move from the enclosed thread group
+ */
+
+VALUE
+thgroup_enclose(group)
+ VALUE group;
+{
+ struct thgroup *data;
+
+ Data_Get_Struct(group, struct thgroup, data);
+ data->enclosed = 1;
+
+ return group;
+}
+
+
+/*
+ * call-seq:
+ * thgrp.enclosed? => true or false
+ *
+ * Returns <code>true</code> if <em>thgrp</em> is enclosed. See also
+ * ThreadGroup#enclose.
+ */
+
+static VALUE
+thgroup_enclosed_p(group)
+ VALUE group;
+{
+ struct thgroup *data;
+
+ Data_Get_Struct(group, struct thgroup, data);
+ if (data->enclosed) return Qtrue;
+ return Qfalse;
+}
+
+
+/*
+ * call-seq:
+ * thgrp.add(thread) => thgrp
+ *
+ * Adds the given <em>thread</em> to this group, removing it from any other
+ * group to which it may have previously belonged.
+ *
+ * puts "Initial group is #{ThreadGroup::Default.list}"
+ * tg = ThreadGroup.new
+ * t1 = Thread.new { sleep }
+ * t2 = Thread.new { sleep }
+ * puts "t1 is #{t1}"
+ * puts "t2 is #{t2}"
+ * tg.add(t1)
+ * puts "Initial group now #{ThreadGroup::Default.list}"
+ * puts "tg group now #{tg.list}"
+ *
+ * <em>produces:</em>
+ *
+ * Initial group is #<Thread:0x401bdf4c>
+ * t1 is #<Thread:0x401b3c90>
+ * t2 is #<Thread:0x401b3c18>
+ * Initial group now #<Thread:0x401b3c18>#<Thread:0x401bdf4c>
+ * tg group now #<Thread:0x401b3c90>
+ */
+
static VALUE
thgroup_add(group, thread)
VALUE group, thread;
@@ -8686,12 +12319,40 @@ thgroup_add(group, thread)
rb_secure(4);
th = rb_thread_check(thread);
+
+ if (OBJ_FROZEN(group)) {
+ rb_raise(rb_eThreadError, "can't move to the frozen thread group");
+ }
Data_Get_Struct(group, struct thgroup, data);
+ if (data->enclosed) {
+ rb_raise(rb_eThreadError, "can't move to the enclosed thread group");
+ }
- th->gid = data->gid;
+ if (!th->thgroup) {
+ return Qnil;
+ }
+ if (OBJ_FROZEN(th->thgroup)) {
+ rb_raise(rb_eThreadError, "can't move from the frozen thread group");
+ }
+ Data_Get_Struct(th->thgroup, struct thgroup, data);
+ if (data->enclosed) {
+ rb_raise(rb_eThreadError, "can't move from the enclosed thread group");
+ }
+
+ th->thgroup = group;
return group;
}
+
+/*
+ * +Thread+ encapsulates the behavior of a thread of
+ * execution, including the main thread of the Ruby script.
+ *
+ * In the descriptions of the methods in this class, the parameter _sym_
+ * refers to a symbol, which is either a quoted string or a
+ * +Symbol+ (such as <code>:name</code>).
+ */
+
void
Init_Thread()
{
@@ -8699,6 +12360,7 @@ Init_Thread()
rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError);
rb_cThread = rb_define_class("Thread", rb_cObject);
+ rb_undef_alloc_func(rb_cThread);
rb_define_singleton_method(rb_cThread, "new", rb_thread_s_new, -1);
rb_define_method(rb_cThread, "initialize", rb_thread_initialize, -2);
@@ -8722,10 +12384,11 @@ Init_Thread()
rb_define_method(rb_cThread, "run", rb_thread_run, 0);
rb_define_method(rb_cThread, "wakeup", rb_thread_wakeup, 0);
rb_define_method(rb_cThread, "kill", rb_thread_kill, 0);
+ rb_define_method(rb_cThread, "terminate", rb_thread_kill, 0);
rb_define_method(rb_cThread, "exit", rb_thread_kill, 0);
rb_define_method(rb_cThread, "value", rb_thread_value, 0);
rb_define_method(rb_cThread, "status", rb_thread_status, 0);
- rb_define_method(rb_cThread, "join", rb_thread_join, 0);
+ rb_define_method(rb_cThread, "join", rb_thread_join_m, -1);
rb_define_method(rb_cThread, "alive?", rb_thread_alive_p, 0);
rb_define_method(rb_cThread, "stop?", rb_thread_stop_p, 0);
rb_define_method(rb_cThread, "raise", rb_thread_raise_m, -1);
@@ -8736,43 +12399,81 @@ Init_Thread()
rb_define_method(rb_cThread, "priority", rb_thread_priority, 0);
rb_define_method(rb_cThread, "priority=", rb_thread_priority_set, 1);
rb_define_method(rb_cThread, "safe_level", rb_thread_safe_level, 0);
+ rb_define_method(rb_cThread, "group", rb_thread_group, 0);
rb_define_method(rb_cThread, "[]", rb_thread_aref, 1);
rb_define_method(rb_cThread, "[]=", rb_thread_aset, 2);
rb_define_method(rb_cThread, "key?", rb_thread_key_p, 1);
+ rb_define_method(rb_cThread, "keys", rb_thread_keys, 0);
rb_define_method(rb_cThread, "inspect", rb_thread_inspect, 0);
- /* allocate main thread */
- main_thread = rb_thread_alloc(rb_cThread);
- curr_thread = main_thread->prev = main_thread->next = main_thread;
-
rb_cCont = rb_define_class("Continuation", rb_cObject);
+ rb_undef_alloc_func(rb_cCont);
rb_undef_method(CLASS_OF(rb_cCont), "new");
rb_define_method(rb_cCont, "call", rb_cont_call, -1);
+ rb_define_method(rb_cCont, "[]", rb_cont_call, -1);
rb_define_global_function("callcc", rb_callcc, 0);
cThGroup = rb_define_class("ThreadGroup", rb_cObject);
- rb_define_singleton_method(cThGroup, "new", thgroup_s_new, -1);
+ rb_define_alloc_func(cThGroup, thgroup_s_alloc);
rb_define_method(cThGroup, "list", thgroup_list, 0);
+ rb_define_method(cThGroup, "enclose", thgroup_enclose, 0);
+ rb_define_method(cThGroup, "enclosed?", thgroup_enclosed_p, 0);
rb_define_method(cThGroup, "add", thgroup_add, 1);
- rb_define_const(cThGroup, "Default", thgroup_s_new(0, 0, cThGroup));
+ thgroup_default = rb_obj_alloc(cThGroup);
+ rb_define_const(cThGroup, "Default", thgroup_default);
+ rb_global_variable(&thgroup_default);
+
+ /* allocate main thread */
+ main_thread = rb_thread_alloc(rb_cThread);
+ curr_thread = main_thread->prev = main_thread->next = main_thread;
}
+/*
+ * call-seq:
+ * catch(symbol) {| | block } > obj
+ *
+ * +catch+ executes its block. If a +throw+ is
+ * executed, Ruby searches up its stack for a +catch+ block
+ * with a tag corresponding to the +throw+'s
+ * _symbol_. If found, that block is terminated, and
+ * +catch+ returns the value given to +throw+. If
+ * +throw+ is not called, the block terminates normally, and
+ * the value of +catch+ is the value of the last expression
+ * evaluated. +catch+ expressions may be nested, and the
+ * +throw+ call need not be in lexical scope.
+ *
+ * def routine(n)
+ * puts n
+ * throw :done if n <= 0
+ * routine(n-1)
+ * end
+ *
+ *
+ * catch(:done) { routine(3) }
+ *
+ * <em>produces:</em>
+ *
+ * 3
+ * 2
+ * 1
+ * 0
+ */
+
static VALUE
rb_f_catch(dmy, tag)
VALUE dmy, tag;
{
int state;
- ID t;
- VALUE val; /* OK */
+ VALUE val = Qnil; /* OK */
- t = rb_to_id(tag);
- PUSH_TAG(t);
+ tag = ID2SYM(rb_to_id(tag));
+ PUSH_TAG(tag);
if ((state = EXEC_TAG()) == 0) {
- val = rb_yield_0(tag, 0, 0, 0);
+ val = rb_yield_0(tag, 0, 0, 0, Qfalse);
}
- else if (state == TAG_THROW && t == prot_tag->dst) {
+ else if (state == TAG_THROW && tag == prot_tag->dst) {
val = prot_tag->retval;
state = 0;
}
@@ -8784,50 +12485,64 @@ rb_f_catch(dmy, tag)
static VALUE
catch_i(tag)
- ID tag;
+ VALUE tag;
{
- return rb_funcall(Qnil, rb_intern("catch"), 1, ID2SYM(tag));
+ return rb_funcall(Qnil, rb_intern("catch"), 1, tag);
}
VALUE
-rb_catch(tag, proc, data)
+rb_catch(tag, func, data)
const char *tag;
- VALUE (*proc)();
+ VALUE (*func)();
VALUE data;
{
- return rb_iterate(catch_i, rb_intern(tag), proc, data);
+ return rb_iterate((VALUE(*)_((VALUE)))catch_i, ID2SYM(rb_intern(tag)), func, data);
}
+/*
+ * call-seq:
+ * throw(symbol [, obj])
+ *
+ * Transfers control to the end of the active +catch+ block
+ * waiting for _symbol_. Raises +NameError+ if there
+ * is no +catch+ block for the symbol. The optional second
+ * parameter supplies a return value for the +catch+ block,
+ * which otherwise defaults to +nil+. For examples, see
+ * <code>Kernel::catch</code>.
+ */
+
static VALUE
rb_f_throw(argc, argv)
int argc;
VALUE *argv;
{
VALUE tag, value;
- ID t;
struct tag *tt = prot_tag;
rb_scan_args(argc, argv, "11", &tag, &value);
- t = rb_to_id(tag);
+ tag = ID2SYM(rb_to_id(tag));
while (tt) {
- if (tt->tag == t) {
- tt->dst = t;
+ if (tt->tag == tag) {
+ tt->dst = tag;
+ tt->retval = value;
break;
}
if (tt->tag == PROT_THREAD) {
- rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%x",
- rb_id2name(t),
+ rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%lx",
+ rb_id2name(SYM2ID(tag)),
curr_thread);
}
tt = tt->prev;
}
if (!tt) {
- rb_raise(rb_eNameError, "uncaught throw `%s'", rb_id2name(t));
+ rb_name_error(SYM2ID(tag), "uncaught throw `%s'", rb_id2name(SYM2ID(tag)));
}
- return_value(value);
rb_trap_restore_mask();
JUMP_TAG(TAG_THROW);
+#ifndef __GNUC__
+ return Qnil; /* not reached */
+#endif
}
void
@@ -8836,26 +12551,8 @@ rb_throw(tag, val)
VALUE val;
{
VALUE argv[2];
- ID t = rb_intern(tag);
- argv[0] = ID2SYM(t);
+ argv[0] = ID2SYM(rb_intern(tag));
argv[1] = val;
rb_f_throw(2, argv);
}
-
-static void
-return_check()
-{
- struct tag *tt = prot_tag;
-
- while (tt) {
- if (tt->tag == PROT_FUNC) {
- break;
- }
- if (tt->tag == PROT_THREAD) {
- rb_raise(rb_eThreadError, "return from within thread 0x%x",
- curr_thread);
- }
- tt = tt->prev;
- }
-}
diff --git a/ext/.cvsignore b/ext/.cvsignore
index d8b8a61d92..ab2424ff7a 100644
--- a/ext/.cvsignore
+++ b/ext/.cvsignore
@@ -1 +1,2 @@
-extmk.rb
+extinit.c
+*.log
diff --git a/ext/.document b/ext/.document
new file mode 100644
index 0000000000..797d8dcef8
--- /dev/null
+++ b/ext/.document
@@ -0,0 +1,5 @@
+# Add files to this as they become documented
+
+iconv/iconv.c
+strscan/strscan.c
+zlib/zlib.c
diff --git a/ext/Setup b/ext/Setup
index 039747115f..7b214abde3 100644
--- a/ext/Setup
+++ b/ext/Setup
@@ -1,15 +1,33 @@
#option nodynamic
-#GD
+#Win32API
+#bigdecimal
#curses
#dbm
+#digest
+#digest/md5
+#digest/rmd160
+#digest/sha1
+#digest/sha2
+#dl
+#enumerator
#etc
#fcntl
-#kconv
-#md5
+#gdbm
+#iconv
+#io/wait
+#nkf
#pty
+#openssl
+#racc/cparse
+#readline
#sdbm
#socket
-#tk
+#stringio
+#strscan
+#syck
+#syslog
#tcltklib
-#gtk
+#tk
+#win32ole
+#zlib
diff --git a/ext/Setup.atheos b/ext/Setup.atheos
new file mode 100644
index 0000000000..9b1bdecb95
--- /dev/null
+++ b/ext/Setup.atheos
@@ -0,0 +1,33 @@
+option nodynamic
+
+#Win32API
+bigdecimal
+curses
+dbm
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+dl
+enumerator
+etc
+fcntl
+gdbm
+iconv
+io/wait
+nkf
+pty
+#openssl
+racc/parse
+readline
+sdbm
+socket
+stringio
+strscan
+syck
+syslog
+#tcltklib
+#tk
+#win32ole
+zlib
diff --git a/ext/Setup.dj b/ext/Setup.dj
index 6c955cba1e..f2ed3a4f16 100644
--- a/ext/Setup.dj
+++ b/ext/Setup.dj
@@ -1,15 +1,33 @@
option nodynamic
-#GD
-#curses
+#Win32API
+bigdecimal
+curses
dbm
-gdbm
-#etc
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+#dl
+etc
+enumerator
fcntl
+gdbm
+#iconv
+#io/wait
nkf
-marshal
-md5
+#pty
+#openssl
+racc/cparse
readline
sdbm
#socket
-#tkutil
+stringio
+strscan
+syck
+#syslog
+#tcltklib
+#tk
+#win32ole
+zlib
diff --git a/ext/Setup.emx b/ext/Setup.emx
index dbb4b7a61c..7ea04543c5 100644
--- a/ext/Setup.emx
+++ b/ext/Setup.emx
@@ -1,16 +1,33 @@
option nodynamic
#Win32API
+bigdecimal
curses
#dbm
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+#dl
+enumerator
etc
fcntl
#gdbm
-md5
+#iconv
+#io/wait
nkf
#pty
+#openssl
+racc/cparse
#readline
#sdbm
socket
+stringio
+strscan
+#syck
+#syslog
#tcltklib
#tk
+#win32ole
+#zlib
diff --git a/ext/Setup.nt b/ext/Setup.nt
index cd7969bb73..7a330f801a 100644
--- a/ext/Setup.nt
+++ b/ext/Setup.nt
@@ -1,19 +1,33 @@
#option nodynamic
-#GD
Win32API
+bigdecimal
#curses
#dbm
-#etc
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+dl
+enumerator
+etc
fcntl
#gdbm
-#gtk
-marshal
-md5
+#iconv
+#io/wait
nkf
#pty
+#openssl
+racc/cparse
#readline
sdbm
socket
+stringio
+strscan
+syck
+#syslog
#tcltklib
#tk
+win32ole
+#zlib
diff --git a/ext/Setup.x68 b/ext/Setup.x68
index 25adea2035..9b9563d941 100644
--- a/ext/Setup.x68
+++ b/ext/Setup.x68
@@ -1,12 +1,33 @@
option nodynamic
-#GD
+#Win32API
+bigdecimal
#curses
dbm
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+#dl
#etc
+enumerator
fcntl
-kconv
-marshal
-md5
+#gdbm
+#iconv
+#io/wait
+nkf
+#pty
+#openssl
+racc/cparse
+#readline
+#sdbm
#socket
-#tkutil
+stringio
+strscan
+#syck
+#syslog
+#tcltklib
+#tk
+#win32ole
+#zlib
diff --git a/ext/Win32API/.cvsignore b/ext/Win32API/.cvsignore
new file mode 100644
index 0000000000..90c83ed9b1
--- /dev/null
+++ b/ext/Win32API/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+*.log
+*.def
diff --git a/ext/Win32API/MANIFEST b/ext/Win32API/MANIFEST
deleted file mode 100644
index 7cc9ac445e..0000000000
--- a/ext/Win32API/MANIFEST
+++ /dev/null
@@ -1,7 +0,0 @@
-MANIFEST
-depend
-MANIFEST
-Win32API.c
-extconf.rb
-getch.rb
-point.rb
diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c
index 0ee28f05ac..776df56ecb 100644
--- a/ext/Win32API/Win32API.c
+++ b/ext/Win32API/Win32API.c
@@ -2,33 +2,17 @@
Win32API - Ruby Win32 API Import Facility
*/
-#if !defined _MSC_VER && !defined NT
+#if !defined _MSC_VER && !defined _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#endif
-#if defined(_MSC_VER)
-#if defined(_M_ALPHA)
-#ifdef __cplusplus
-extern "C" { long __asm(char *,...); };
-#else
-long __asm(char *,...);
-#endif
-#pragma intrinsic(__asm)
-#endif
-#endif
-
#define _T_VOID 0
#define _T_NUMBER 1
#define _T_POINTER 2
#define _T_INTEGER 3
-typedef char *ApiPointer(void);
-typedef long ApiNumber(void);
-typedef void ApiVoid(void);
-typedef int ApiInteger(void);
-
#include "ruby.h"
typedef struct {
@@ -62,14 +46,14 @@ Win32API_initialize(self, dllname, proc, import, export)
char *s;
int i;
int len;
- int ex;
+ int ex = _T_VOID;
- Check_SafeStr(dllname);
- Check_SafeStr(proc);
+ SafeStringValue(dllname);
+ SafeStringValue(proc);
hdll = LoadLibrary(RSTRING(dllname)->ptr);
if (!hdll)
rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr);
- rb_iv_set(self, "__hdll__", Data_Wrap_Struct(self, 0, Win32API_FreeLibrary, hdll));
+ rb_iv_set(self, "__hdll__", Data_Wrap_Struct(rb_cData, 0, Win32API_FreeLibrary, hdll));
hproc = GetProcAddress(hdll, RSTRING(proc)->ptr);
if (!hproc) {
str = rb_str_new3(proc);
@@ -85,60 +69,65 @@ Win32API_initialize(self, dllname, proc, import, export)
a_import = rb_ary_new();
switch (TYPE(import)) {
- case T_NIL:
+ case T_NIL:
break;
- case T_ARRAY:
+ case T_ARRAY:
ptr = RARRAY(import)->ptr;
for (i = 0, len = RARRAY(import)->len; i < len; i++) {
- Check_SafeStr(ptr[i]);
+ SafeStringValue(ptr[i]);
switch (*(char *)RSTRING(ptr[i])->ptr) {
- case 'N': case 'n': case 'L': case 'l':
+ case 'N': case 'n': case 'L': case 'l':
rb_ary_push(a_import, INT2FIX(_T_NUMBER));
break;
- case 'P': case 'p':
+ case 'P': case 'p':
rb_ary_push(a_import, INT2FIX(_T_POINTER));
break;
- case 'I': case 'i':
+ case 'I': case 'i':
rb_ary_push(a_import, INT2FIX(_T_INTEGER));
break;
}
}
break;
- default:
- Check_SafeStr(import);
+ default:
+ SafeStringValue(import);
s = RSTRING(import)->ptr;
for (i = 0, len = RSTRING(import)->len; i < len; i++) {
switch (*s++) {
- case 'N': case 'n': case 'L': case 'l':
+ case 'N': case 'n': case 'L': case 'l':
rb_ary_push(a_import, INT2FIX(_T_NUMBER));
break;
- case 'P': case 'p':
+ case 'P': case 'p':
rb_ary_push(a_import, INT2FIX(_T_POINTER));
break;
- case 'I': case 'i':
+ case 'I': case 'i':
rb_ary_push(a_import, INT2FIX(_T_INTEGER));
break;
}
}
break;
}
+
+ if (16 < RARRAY(a_import)->len) {
+ rb_raise(rb_eRuntimeError, "too many parameters: %d\n", RARRAY(a_import)->len);
+ }
+
rb_iv_set(self, "__import__", a_import);
if (NIL_P(export)) {
ex = _T_VOID;
} else {
- Check_SafeStr(export);
+ SafeStringValue(export);
switch (*RSTRING(export)->ptr) {
- case 'V': case 'v':
+ case 'V': case 'v':
ex = _T_VOID;
break;
- case 'N': case 'n': case 'L': case 'l':
+ case 'N': case 'n': case 'L': case 'l':
ex = _T_NUMBER;
break;
- case 'P': case 'p':
+ case 'P': case 'p':
ex = _T_POINTER;
break;
- case 'I': case 'i':
+ case 'I': case 'i':
ex = _T_INTEGER;
break;
}
@@ -155,146 +144,62 @@ Win32API_Call(argc, argv, obj)
VALUE obj;
{
VALUE args;
+ unsigned long ret;
+ int i;
+ struct {
+ unsigned long params[16];
+ } param;
+#define params param.params
- FARPROC ApiFunction;
-
- ApiPointer *ApiFunctionPointer;
- ApiNumber *ApiFunctionNumber;
- ApiVoid *ApiFunctionVoid;
- ApiInteger *ApiFunctionInteger;
-
- long lParam;
- char *pParam;
-
- VALUE Return;
-
- VALUE obj_proc;
- VALUE obj_import;
- VALUE obj_export;
- VALUE import_type;
- int nimport, timport, texport, i;
- int items;
- int ret;
-
- items = rb_scan_args(argc, argv, "0*", &args);
-
- obj_proc = rb_iv_get(obj, "__proc__");
-
- ApiFunction = (FARPROC)NUM2ULONG(obj_proc);
+ VALUE obj_proc = rb_iv_get(obj, "__proc__");
+ VALUE obj_import = rb_iv_get(obj, "__import__");
+ VALUE obj_export = rb_iv_get(obj, "__export__");
+ FARPROC ApiFunction = (FARPROC)NUM2ULONG(obj_proc);
+ int items = rb_scan_args(argc, argv, "0*", &args);
+ int nimport = RARRAY(obj_import)->len;
- obj_import = rb_iv_get(obj, "__import__");
- obj_export = rb_iv_get(obj, "__export__");
- nimport = RARRAY(obj_import)->len;
- texport = FIX2INT(obj_export);
if (items != nimport)
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--) {
+ for (i = 0; i < nimport; i++) {
+ unsigned long lParam = 0;
+ switch (FIX2INT(rb_ary_entry(obj_import, i))) {
VALUE str;
- import_type = rb_ary_entry(obj_import, i);
- timport = FIX2INT(import_type);
- switch (timport) {
- case _T_NUMBER:
- case _T_INTEGER:
- lParam = NUM2ULONG(rb_ary_entry(args, i));
-#if defined(_MSC_VER) || defined(__LCC__)
-#if defined(_M_IX86)
- _asm {
- mov eax, lParam
- push eax
- }
-#elif defined(_M_ALPHA)
- __asm(
- "ldl r0, 0(%0);"
- "stq r0, -(sp);"
- , lParam
- );
-#else
-#error
-#endif
-#elif defined __GNUC__
- asm volatile ("pushl %0" :: "g" (lParam));
-#else
-#error
-#endif
- break;
- case _T_POINTER:
- str = rb_ary_entry(args, i);
- if (NIL_P(str)) {
- pParam = 0;
- } else if (FIXNUM_P(str)){
- pParam = (char *)NUM2ULONG(str);
- } else {
- Check_Type(str, T_STRING);
- rb_str_modify(str);
- pParam = RSTRING(str)->ptr;
- }
-#if defined(_MSC_VER) || defined(__LCC__)
-#if defined(_M_IX86)
- _asm {
- mov eax, pParam
- push eax
- }
-#elif defined(_M_ALPHA)
- __asm(
- "ldl r0, 0(%0);"
- "stq r0, -(sp);"
- , pParam
- );
-#else
-#error
-#endif
-#elif defined __GNUC__
- asm volatile ("pushl %0" :: "g" (pParam));
-#else
-#error
-#endif
- break;
+ case _T_NUMBER:
+ case _T_INTEGER:
+ default:
+ lParam = NUM2ULONG(rb_ary_entry(args, i));
+ break;
+ case _T_POINTER:
+ str = rb_ary_entry(args, i);
+ if (NIL_P(str)) {
+ lParam = 0;
+ } else if (FIXNUM_P(str)) {
+ lParam = NUM2ULONG(str);
+ } else {
+ StringValue(str);
+ rb_str_modify(str);
+ lParam = (unsigned long)StringValuePtr(str);
}
+ break;
}
+ params[i] = lParam;
}
-#if defined __GNUC__
- asm volatile ("call *%1" : "=r" (ret) : "g" (ApiFunction));
- switch (texport) {
+ ret = ApiFunction(param);
+
+ switch (FIX2INT(obj_export)) {
case _T_NUMBER:
case _T_INTEGER:
- Return = INT2NUM(ret);
- break;
- case _T_POINTER:
- Return = rb_str_new2((char *)ret);
- break;
- case _T_VOID:
- default:
- Return = INT2NUM(0);
- break;
- }
-#else
- switch (texport) {
- case _T_NUMBER:
- ApiFunctionNumber = (ApiNumber *) ApiFunction;
- Return = INT2NUM(ApiFunctionNumber());
- break;
+ return INT2NUM(ret);
case _T_POINTER:
- ApiFunctionPointer = (ApiPointer *) ApiFunction;
- Return = rb_str_new2((char *)ApiFunctionPointer());
- break;
- case _T_INTEGER:
- ApiFunctionInteger = (ApiInteger *) ApiFunction;
- Return = INT2NUM(ApiFunctionInteger());
- break;
+ return rb_str_new2((char *)ret);
case _T_VOID:
default:
- ApiFunctionVoid = (ApiVoid *) ApiFunction;
- ApiFunctionVoid();
- Return = INT2NUM(0);
- break;
+ return INT2NUM(0);
}
-#endif
- return Return;
}
void
diff --git a/ext/Win32API/extconf.rb b/ext/Win32API/extconf.rb
index 5e42f62558..134a6e5b92 100644
--- a/ext/Win32API/extconf.rb
+++ b/ext/Win32API/extconf.rb
@@ -1,7 +1,5 @@
-case RUBY_PLATFORM
-when /cygwin/,/mingw/
- $CFLAGS = "-fno-defer-pop -fno-omit-frame-pointer"
- create_makefile("Win32API")
-when /win32/
+require 'mkmf'
+
+if have_header("windows.h") and have_library("kernel32")
create_makefile("Win32API")
end
diff --git a/ext/Win32API/lib/win32/registry.rb b/ext/Win32API/lib/win32/registry.rb
new file mode 100644
index 0000000000..2671551a33
--- /dev/null
+++ b/ext/Win32API/lib/win32/registry.rb
@@ -0,0 +1,831 @@
+=begin
+= Win32 Registry I/F
+win32/registry is registry accessor library for Win32 platform.
+It uses Win32API to call Win32 Registry APIs.
+
+== example
+ Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
+ value = reg['foo'] # read a value
+ value = reg['foo', Win32::Registry::REG_SZ] # read a value with type
+ type, value = reg.read('foo') # read a value
+ reg['foo'] = 'bar' # write a value
+ reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type
+ reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value
+
+ reg.each_value { |name, type, data| ... } # Enumerate values
+ reg.each_key { |key, wtime| ... } # Enumerate subkeys
+
+ reg.delete_value(name) # Delete a value
+ reg.delete_key(name) # Delete a subkey
+ reg.delete_key(name, true) # Delete a subkey recursively
+ end
+
+= Reference
+
+== Win32::Registry class
+
+=== including modules
+
+* Enumerable
+* Registry::Constants
+
+=== class methods
+--- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+--- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| ... }
+ Open the registry key ((|subkey|)) under ((|key|)).
+ ((|key|)) is Win32::Registry object of parent key.
+ You can use predefined key HKEY_* (see ((<constants>)))
+
+ ((|desired|)) and ((|opt|)) is access mask and key option.
+ For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp>)).
+
+ If block is given, the key is closed automatically.
+
+--- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+--- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... }
+ Create or open the registry key ((|subkey|)) under ((|key|)).
+ You can use predefined key HKEY_* (see ((<constants>)))
+
+ If subkey is already exists, key is opened and Registry#((<created?>))
+ method will return false.
+
+ If block is given, the key is closed automatically.
+
+--- Registry.expand_environ(str)
+ Replace (({%\w+%})) into the environment value of ((|str|)).
+ This method is used for REG_EXPAND_SZ.
+
+ For detail, see ((<ExpandEnvironmentStrings|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp>)) Win32 API.
+
+--- Registry.type2name(type)
+ Convert registry type value to readable string.
+
+--- Registry.wtime2time(wtime)
+ Convert 64-bit FILETIME integer into Time object.
+
+--- Registry.time2wtime(time)
+ Convert Time object or Integer object into 64-bit FILETIME.
+
+=== instance methods
+--- open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+ Same as (({Win32::((<Registry.open>))(self, subkey, desired, opt)}))
+
+--- create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+ Same as (({Win32::((<Registry.create>))(self, subkey, desired, opt)}))
+
+--- close
+ Close key.
+
+ After closed, most method raises error.
+
+--- read(name, *rtype)
+ Read a registry value named ((|name|)) and return array of
+ [ ((|type|)), ((|data|)) ].
+ When name is nil, the `default' value is read.
+
+ ((|type|)) is value type. (see ((<Win32::Registry::Constants module>)))
+ ((|data|)) is value data, its class is:
+ :REG_SZ, REG_EXPAND_SZ
+ String
+ :REG_MULTI_SZ
+ Array of String
+ :REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD
+ Integer
+ :REG_BINARY
+ String (contains binary data)
+
+ When ((|rtype|)) is specified, the value type must be included by
+ ((|rtype|)) array, or TypeError is raised.
+
+--- self[name, *rtype]
+ Read a registry value named ((|name|)) and return its value data.
+ The class of value is same as ((<read>)) method returns.
+
+ If the value type is REG_EXPAND_SZ, returns value data whose environment
+ variables are replaced.
+ If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD,
+ REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised.
+
+ The meaning of ((|rtype|)) is same as ((<read>)) method.
+
+--- read_s(name)
+--- read_i(name)
+--- read_bin(name)
+ Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
+ registry value named ((|name|)).
+
+ If the values type does not match, TypeError is raised.
+
+--- read_s_expand(name)
+ Read a REG_SZ or REG_EXPAND_SZ registry value named ((|name|)).
+
+ If the value type is REG_EXPAND_SZ, environment variables are replaced.
+ Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised.
+
+--- write(name, type, data)
+ Write ((|data|)) to a registry value named ((|name|)).
+ When name is nil, write to the `default' value.
+
+ ((|type|)) is type value. (see ((<Registry::Constants module>)))
+ Class of ((|data|)) must be same as which ((<read>))
+ method returns.
+
+--- self[name, wtype = nil] = value
+ Write ((|value|)) to a registry value named ((|name|)).
+
+ If ((|wtype|)) is specified, the value type is it.
+ Otherwise, the value type is depend on class of ((|value|)):
+ :Integer
+ REG_DWORD
+ :String
+ REG_SZ
+ :Array
+ REG_MULTI_SZ
+
+--- write_s(name, value)
+--- write_i(name, value)
+--- write_bin(name, value)
+ Write ((|value|)) to a registry value named ((|name|)).
+
+ The value type is REG_SZ(write_s), REG_DWORD(write_i), or
+ REG_BINARY(write_bin).
+
+--- each { |name, type, value| ... }
+--- each_value { |name, type, value| ... }
+ Enumerate values.
+
+--- each_key { |subkey, wtime| ... }
+ Enumerate subkeys.
+
+ ((|subkey|)) is String which contains name of subkey.
+ ((|wtime|)) is last write time as FILETIME (64-bit integer).
+ (see ((<Registry.wtime2time>)))
+
+--- delete(name)
+--- delete_value(name)
+ Delete a registry value named ((|name|)).
+ We can not delete the `default' value.
+
+--- delete_key(name, recursive = false)
+ Delete a subkey named ((|name|)) and all its values.
+
+ If ((|recursive|)) is false, the subkey must not have subkeys.
+ Otherwise, this method deletes all subkeys and values recursively.
+
+--- flush
+ Write all the attributes into the registry file.
+
+--- created?
+ Returns if key is created ((*newly*)).
+ (see ((<Registry.create>)))
+
+--- open?
+ Returns if key is not closed.
+
+--- hkey
+ Returns key handle value.
+
+--- parent
+ Win32::Registry object of parent key, or nil if predefeined key.
+
+--- keyname
+ Same as ((|subkey|)) value of ((<Registry.open>)) or
+ ((<Registry.create>)) method.
+
+--- disposition
+ Disposition value (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY).
+
+--- name
+--- to_s
+ Full path of key such as (({'HKEY_CURRENT_USER\SOFTWARE\foo\bar'})).
+
+--- info
+ Returns key information as Array of:
+ :num_keys
+ The number of subkeys.
+ :max_key_length
+ Maximum length of name of subkeys.
+ :num_values
+ The number of values.
+ :max_value_name_length
+ Maximum length of name of values.
+ :max_value_length
+ Maximum length of value of values.
+ :descriptor_length
+ Length of security descriptor.
+ :wtime
+ Last write time as FILETIME(64-bit integer)
+
+ For detail, see ((<RegQueryInfoKey|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp>)) Win32 API.
+
+--- num_keys
+--- max_key_length
+--- num_values
+--- max_value_name_length
+--- max_value_length
+--- descriptor_length
+--- wtime
+ Returns an item of key information.
+
+=== constants
+--- HKEY_CLASSES_ROOT
+--- HKEY_CURRENT_USER
+--- HKEY_LOCAL_MACHINE
+--- HKEY_PERFORMANCE_DATA
+--- HKEY_CURRENT_CONFIG
+--- HKEY_DYN_DATA
+ Win32::Registry object whose key is predefined key.
+ For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/predefined_keys.asp>)).
+
+== Win32::Registry::Constants module
+
+For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/registry.asp>)).
+
+--- HKEY_*
+ Predefined key ((*handle*)).
+ These are Integer, not Win32::Registry.
+
+--- REG_*
+ Registry value type.
+
+--- KEY_*
+ Security access mask.
+
+--- KEY_OPTIONS_*
+ Key options.
+
+--- REG_CREATED_NEW_KEY
+--- REG_OPENED_EXISTING_KEY
+ If the key is created newly or opened existing key.
+ See also Registry#((<disposition>)) method.
+
+=end
+
+require 'Win32API'
+
+module Win32
+ class Registry
+ module Constants
+ HKEY_CLASSES_ROOT = 0x80000000
+ HKEY_CURRENT_USER = 0x80000001
+ HKEY_LOCAL_MACHINE = 0x80000002
+ HKEY_USERS = 0x80000003
+ HKEY_PERFORMANCE_DATA = 0x80000004
+ HKEY_PERFORMANCE_TEXT = 0x80000050
+ HKEY_PERFORMANCE_NLSTEXT = 0x80000060
+ HKEY_CURRENT_CONFIG = 0x80000005
+ HKEY_DYN_DATA = 0x80000006
+
+ REG_NONE = 0
+ REG_SZ = 1
+ REG_EXPAND_SZ = 2
+ REG_BINARY = 3
+ REG_DWORD = 4
+ REG_DWORD_LITTLE_ENDIAN = 4
+ REG_DWORD_BIG_ENDIAN = 5
+ REG_LINK = 6
+ REG_MULTI_SZ = 7
+ REG_RESOURCE_LIST = 8
+ REG_FULL_RESOURCE_DESCRIPTOR = 9
+ REG_RESOURCE_REQUIREMENTS_LIST = 10
+ REG_QWORD = 11
+ REG_QWORD_LITTLE_ENDIAN = 11
+
+ STANDARD_RIGHTS_READ = 0x00020000
+ STANDARD_RIGHTS_WRITE = 0x00020000
+ KEY_QUERY_VALUE = 0x0001
+ KEY_SET_VALUE = 0x0002
+ KEY_CREATE_SUB_KEY = 0x0004
+ KEY_ENUMERATE_SUB_KEYS = 0x0008
+ KEY_NOTIFY = 0x0010
+ KEY_CREATE_LINK = 0x0020
+ KEY_READ = STANDARD_RIGHTS_READ |
+ KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
+ KEY_WRITE = STANDARD_RIGHTS_WRITE |
+ KEY_SET_VALUE | KEY_CREATE_SUB_KEY
+ KEY_EXECUTE = KEY_READ
+ KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
+
+ REG_OPTION_RESERVED = 0x0000
+ REG_OPTION_NON_VOLATILE = 0x0000
+ REG_OPTION_VOLATILE = 0x0001
+ REG_OPTION_CREATE_LINK = 0x0002
+ REG_OPTION_BACKUP_RESTORE = 0x0004
+ REG_OPTION_OPEN_LINK = 0x0008
+ REG_LEGAL_OPTION = REG_OPTION_RESERVED |
+ REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
+ REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
+
+ REG_CREATED_NEW_KEY = 1
+ REG_OPENED_EXISTING_KEY = 2
+
+ REG_WHOLE_HIVE_VOLATILE = 0x0001
+ REG_REFRESH_HIVE = 0x0002
+ REG_NO_LAZY_FLUSH = 0x0004
+ REG_FORCE_RESTORE = 0x0008
+
+ MAX_KEY_LENGTH = 514
+ MAX_VALUE_LENGTH = 32768
+ end
+ include Constants
+ include Enumerable
+
+ #
+ # Error
+ #
+ class Error < ::StandardError
+ FormatMessageA = Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
+ def initialize(code)
+ @code = code
+ msg = "\0" * 1024
+ len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)
+ super msg[0, len].tr("\r", '').chomp
+ end
+ attr_reader :code
+ end
+
+ #
+ # Predefined Keys
+ #
+ class PredefinedKey < Registry
+ def initialize(hkey, keyname)
+ @hkey = hkey
+ @parent = nil
+ @keyname = keyname
+ @disposition = REG_OPENED_EXISTING_KEY
+ end
+
+ # Predefined keys cannot be closed
+ def close
+ raise Error.new(5) ## ERROR_ACCESS_DENIED
+ end
+
+ # Fake class for Registry#open, Registry#create
+ def class
+ Registry
+ end
+
+ # Make all
+ Constants.constants.grep(/^HKEY_/) do |c|
+ Registry.const_set c, new(Constants.const_get(c), c)
+ end
+ end
+
+ #
+ # Win32 APIs
+ #
+ module API
+ [
+ %w/RegOpenKeyExA LPLLP L/,
+ %w/RegCreateKeyExA LPLLLLPPP L/,
+ %w/RegEnumValueA LLPPPPPP L/,
+ %w/RegEnumKeyExA LLPPLLLP L/,
+ %w/RegQueryValueExA LPLPPP L/,
+ %w/RegSetValueExA LPLLPL L/,
+ %w/RegDeleteValue LP L/,
+ %w/RegDeleteKey LP L/,
+ %w/RegFlushKey L L/,
+ %w/RegCloseKey L L/,
+ %w/RegQueryInfoKey LPPPPPPPPPPP L/,
+ ].each do |fn|
+ const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
+ end
+
+ module_function
+
+ def check(result)
+ raise Error, result, caller(2) if result != 0
+ end
+
+ def packdw(dw)
+ [dw].pack('V')
+ end
+
+ def unpackdw(dw)
+ dw += [0].pack('V')
+ dw.unpack('V')[0]
+ end
+
+ def packqw(qw)
+ [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
+ end
+
+ def unpackqw(qw)
+ qw = qw.unpack('VV')
+ (qw[1] << 32) | qw[0]
+ end
+
+ def OpenKey(hkey, name, opt, desired)
+ result = packdw(0)
+ check RegOpenKeyExA.call(hkey, name, opt, desired, result)
+ unpackdw(result)
+ end
+
+ def CreateKey(hkey, name, opt, desired)
+ result = packdw(0)
+ disp = packdw(0)
+ check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,
+ 0, result, disp)
+ [ unpackdw(result), unpackdw(disp) ]
+ end
+
+ def EnumValue(hkey, index)
+ name = ' ' * Constants::MAX_KEY_LENGTH
+ size = packdw(Constants::MAX_KEY_LENGTH)
+ check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
+ name[0, unpackdw(size)]
+ end
+
+ def EnumKey(hkey, index)
+ name = ' ' * Constants::MAX_KEY_LENGTH
+ size = packdw(Constants::MAX_KEY_LENGTH)
+ wtime = ' ' * 8
+ check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
+ [ name[0, unpackdw(size)], unpackqw(wtime) ]
+ end
+
+ def QueryValue(hkey, name)
+ type = packdw(0)
+ size = packdw(0)
+ check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
+ data = ' ' * unpackdw(size)
+ check RegQueryValueExA.call(hkey, name, 0, type, data, size)
+ [ unpackdw(type), data[0, unpackdw(size)] ]
+ end
+
+ def SetValue(hkey, name, type, data, size)
+ check RegSetValueExA.call(hkey, name, 0, type, data, size)
+ end
+
+ def DeleteValue(hkey, name)
+ check RegDeleteValue.call(hkey, name)
+ end
+
+ def DeleteKey(hkey, name)
+ check RegDeleteKey.call(hkey, name)
+ end
+
+ def FlushKey(hkey)
+ check RegFlushKey.call(hkey)
+ end
+
+ def CloseKey(hkey)
+ check RegCloseKey.call(hkey)
+ end
+
+ def QueryInfoKey(hkey)
+ subkeys = packdw(0)
+ maxsubkeylen = packdw(0)
+ values = packdw(0)
+ maxvaluenamelen = packdw(0)
+ maxvaluelen = packdw(0)
+ secdescs = packdw(0)
+ wtime = ' ' * 8
+ check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
+ values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
+ [ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
+ unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
+ unpackdw(secdescs), unpackqw(wtime) ]
+ end
+ end
+
+ #
+ # utility functions
+ #
+ def self.expand_environ(str)
+ str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
+ end
+
+ @@type2name = { }
+ %w[
+ REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
+ REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
+ REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
+ REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
+ ].each do |type|
+ @@type2name[Constants.const_get(type)] = type
+ end
+
+ def self.type2name(type)
+ @@type2name[type] || type.to_s
+ end
+
+ def self.wtime2time(wtime)
+ Time.at((wtime - 116444736000000000) / 10000000)
+ end
+
+ def self.time2wtime(time)
+ time.to_i * 10000000 + 116444736000000000
+ end
+
+ #
+ # constructors
+ #
+ private_class_method :new
+
+ def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+ subkey = subkey.chomp('\\')
+ newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
+ obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
+ if block_given?
+ begin
+ yield obj
+ ensure
+ obj.close
+ end
+ else
+ obj
+ end
+ end
+
+ def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+ newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
+ obj = new(newkey, hkey, subkey, disp)
+ if block_given?
+ begin
+ yield obj
+ ensure
+ obj.close
+ end
+ else
+ obj
+ end
+ end
+
+ #
+ # finalizer
+ #
+ @@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
+
+ #
+ # initialize
+ #
+ def initialize(hkey, parent, keyname, disposition)
+ @hkey = hkey
+ @parent = parent
+ @keyname = keyname
+ @disposition = disposition
+ @hkeyfinal = [ hkey ]
+ ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
+ end
+ attr_reader :hkey, :parent, :keyname, :disposition
+
+ #
+ # attributes
+ #
+ def created?
+ @disposition == REG_CREATED_NEW_KEY
+ end
+
+ def open?
+ !@hkey.nil?
+ end
+
+ def name
+ parent = self
+ name = @keyname
+ while parent = parent.parent
+ name = parent.keyname + '\\' + name
+ end
+ name
+ end
+
+ def inspect
+ "\#<Win32::Registry key=#{name.inspect}>"
+ end
+
+ #
+ # marshalling
+ #
+ def _dump(depth)
+ raise TypeError, "can't dump Win32::Registry"
+ end
+
+ #
+ # open/close
+ #
+ def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
+ self.class.open(self, subkey, desired, opt, &blk)
+ end
+
+ def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
+ self.class.create(self, subkey, desired, opt, &blk)
+ end
+
+ def close
+ API.CloseKey(@hkey)
+ @hkey = @parent = @keyname = nil
+ @hkeyfinal[0] = nil
+ end
+
+ #
+ # iterator
+ #
+ def each_value
+ index = 0
+ while true
+ begin
+ subkey = API.EnumValue(@hkey, index)
+ rescue Error
+ break
+ end
+ begin
+ type, data = read(subkey)
+ rescue Error
+ next
+ end
+ yield subkey, type, data
+ index += 1
+ end
+ index
+ end
+ alias each each_value
+
+ def each_key
+ index = 0
+ while true
+ begin
+ subkey, wtime = API.EnumKey(@hkey, index)
+ rescue Error
+ break
+ end
+ yield subkey, wtime
+ index += 1
+ end
+ index
+ end
+
+ def keys
+ keys_ary = []
+ each_key { |key,| keys_ary << key }
+ keys_ary
+ end
+
+ #
+ # reader
+ #
+ def read(name, *rtype)
+ type, data = API.QueryValue(@hkey, name)
+ unless rtype.empty? or rtype.include?(type)
+ raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)"
+ end
+ case type
+ when REG_SZ, REG_EXPAND_SZ
+ [ type, data.chop ]
+ when REG_MULTI_SZ
+ [ type, data.split(/\0/) ]
+ when REG_BINARY
+ [ type, data ]
+ when REG_DWORD
+ [ type, API.unpackdw(data) ]
+ when REG_DWORD_BIG_ENDIAN
+ [ type, data.unpack('N')[0] ]
+ when REG_QWORD
+ [ type, API.unpackqw(data) ]
+ else
+ raise TypeError, "Type #{type} is not supported."
+ end
+ end
+
+ def [](name, *rtype)
+ type, data = read(name, *rtype)
+ case type
+ when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
+ data
+ when REG_EXPAND_SZ
+ Registry.expand_environ(data)
+ else
+ raise TypeError, "Type #{type} is not supported."
+ end
+ end
+
+ def read_s(name)
+ read(name, REG_SZ)[1]
+ end
+
+ def read_s_expand(name)
+ type, data = read(name, REG_SZ, REG_EXPAND_SZ)
+ if type == REG_EXPAND_SZ
+ Registry.expand_environ(data)
+ else
+ data
+ end
+ end
+
+ def read_i(name)
+ read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
+ end
+
+ def read_bin(name)
+ read(name, REG_BINARY)[1]
+ end
+
+ #
+ # writer
+ #
+ def write(name, type, data)
+ case type
+ when REG_SZ, REG_EXPAND_SZ
+ data = data.to_s + "\0"
+ when REG_MULTI_SZ
+ data = data.to_a.join("\0") + "\0\0"
+ when REG_BINARY
+ data = data.to_s
+ when REG_DWORD
+ data = API.packdw(data.to_i)
+ when REG_DWORD_BIG_ENDIAN
+ data = [data.to_i].pack('N')
+ when REG_QWORD
+ data = API.packqw(data.to_i)
+ else
+ raise TypeError, "Unsupported type #{type}"
+ end
+ API.SetValue(@hkey, name, type, data, data.length)
+ end
+
+ def []=(name, rtype, value = nil)
+ if value
+ write name, rtype, value
+ else
+ case value = rtype
+ when Integer
+ write name, REG_DWORD, value
+ when String
+ write name, REG_SZ, value
+ when Array
+ write name, REG_MULTI_SZ, value
+ else
+ raise TypeError, "Unexpected type #{value.class}"
+ end
+ end
+ value
+ end
+
+ def write_s(name, value)
+ write name, REG_SZ, value.to_s
+ end
+
+ def write_i(name, value)
+ write name, REG_DWORD, value.to_i
+ end
+
+ def write_bin(name, value)
+ write name, REG_BINARY, value.to_s
+ end
+
+ #
+ # delete
+ #
+ def delete_value(name)
+ API.DeleteValue(@hkey, name)
+ end
+ alias delete delete_value
+
+ def delete_key(name, recursive = false)
+ if recursive
+ open(name, KEY_ALL_ACCESS) do |reg|
+ reg.keys.each do |key|
+ begin
+ reg.delete_key(key, true)
+ rescue Error
+ #
+ end
+ end
+ end
+ API.DeleteKey(@hkey, name)
+ else
+ begin
+ API.EnumKey @hkey, 0
+ rescue Error
+ return API.DeleteKey(@hkey, name)
+ end
+ raise Error.new(5) ## ERROR_ACCESS_DENIED
+ end
+ end
+
+ #
+ # flush
+ #
+ def flush
+ API.FlushKey @hkey
+ end
+
+ #
+ # key information
+ #
+ def info
+ API.QueryInfoKey(@hkey)
+ end
+ %w[
+ num_keys max_key_length
+ num_values max_value_name_length max_value_length
+ descriptor_length wtime
+ ].each_with_index do |s, i|
+ eval <<-__END__
+ def #{s}
+ info[#{i}]
+ end
+ __END__
+ end
+ end
+end
diff --git a/ext/Win32API/lib/win32/resolv.rb b/ext/Win32API/lib/win32/resolv.rb
new file mode 100644
index 0000000000..5a99d04d55
--- /dev/null
+++ b/ext/Win32API/lib/win32/resolv.rb
@@ -0,0 +1,366 @@
+=begin
+= Win32 DNS and DHCP I/F
+
+=end
+
+require 'win32/registry'
+
+module Win32
+ module Resolv
+ API = Registry::API
+
+ def self.get_hosts_path
+ path = get_hosts_dir
+ path = File.join(path.gsub(/\\/, File::SEPARATOR), 'hosts')
+ File.exist?(path) ? path : nil
+ end
+
+ def self.get_resolv_info
+ search, nameserver = get_info
+ if search.empty?
+ search = nil
+ else
+ search.delete("")
+ search.uniq!
+ end
+ if nameserver.empty?
+ nameserver = nil
+ else
+ nameserver.delete("")
+ nameserver.delete("0.0.0.0")
+ nameserver.uniq!
+ end
+ [ search, nameserver ]
+ end
+
+getv = Win32API.new('kernel32.dll', 'GetVersionExA', 'P', 'L')
+info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
+getv.call(info)
+if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
+#====================================================================
+# Windows NT
+#====================================================================
+ module_eval <<-'__EOS__', __FILE__, __LINE__+1
+ TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
+
+ class << self
+ private
+ def get_hosts_dir
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
+ reg.read_s_expand('DataBasePath')
+ end
+ end
+
+ def get_info
+ search = nil
+ nameserver = []
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
+ begin
+ slist = reg.read_s('SearchList')
+ search = slist.split(/,\s*/) unless slist.empty?
+ rescue Registry::Error
+ end
+
+ if add_search = search.nil?
+ search = []
+ begin
+ nvdom = reg.read_s('NV Domain')
+ unless nvdom.empty?
+ @search = [ nvdom ]
+ if reg.read_i('UseDomainNameDevolution') != 0
+ if /^[\w\d]+\./ =~ nvdom
+ devo = $'
+ end
+ end
+ end
+ rescue Registry::Error
+ end
+ end
+
+ reg.open('Interfaces') do |reg|
+ reg.each_key do |iface,|
+ reg.open(iface) do |regif|
+ begin
+ [ 'NameServer', 'DhcpNameServer' ].each do |key|
+ ns = regif.read_s(key)
+ unless ns.empty?
+ nameserver.concat(ns.split(/\s+/))
+ break
+ end
+ end
+ rescue Registry::Error
+ end
+
+ if add_search
+ begin
+ [ 'Domain', 'DhcpDomain' ].each do |key|
+ dom = regif.read_s(key)
+ unless dom.empty?
+ search.concat(dom.split(/,\s*/))
+ break
+ end
+ end
+ rescue Registry::Error
+ end
+ end
+ end
+ end
+ end
+ search << devo if add_search and devo
+ end
+ [ search.uniq, nameserver.uniq ]
+ end
+ end
+ __EOS__
+else
+#====================================================================
+# Windows 9x
+#====================================================================
+ module_eval <<-'__EOS__', __FILE__, __LINE__+1
+ TCPIP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\MSTCP'
+ DHCP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\DHCP'
+ WINDOWS = 'Software\Microsoft\Windows\CurrentVersion'
+
+ class << self
+ # private
+
+ def get_hosts_dir
+ Registry::HKEY_LOCAL_MACHINE.open(WINDOWS) do |reg|
+ reg.read_s_expand('SystemRoot')
+ end
+ end
+
+ def get_info
+ search = []
+ nameserver = []
+ begin
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_9X) do |reg|
+ if reg.read_s("EnableDNS") == "1"
+ domain = reg.read_s("Domain")
+ ns = reg.read_s("NameServer")
+ slist = reg.read_s("SearchList")
+ search << domain unless domain.empty?
+ search.concat(slist.split(/,\s*/))
+ nameserver.concat(ns.split(/,\s*/))
+ end
+ end
+ rescue Registry::Error
+ end
+
+ dhcpinfo = get_dhcpinfo
+ search.concat(dhcpinfo[0])
+ nameserver.concat(dhcpinfo[1])
+ [ search, nameserver ]
+ end
+
+ def get_dhcpinfo
+ macaddrs = {}
+ ipaddrs = {}
+ WsControl.get_iflist.each do |index, macaddr, *ipaddr|
+ macaddrs[macaddr] = 1
+ ipaddr.each { |ipaddr| ipaddrs[ipaddr] = 1 }
+ end
+ iflist = [ macaddrs, ipaddrs ]
+
+ search = []
+ nameserver = []
+ version = -1
+ Registry::HKEY_LOCAL_MACHINE.open(DHCP_9X) do |reg|
+ begin
+ version = API.unpackdw(reg.read_bin("Version"))
+ rescue Registry::Error
+ end
+
+ reg.each_key do |key,|
+ catch(:not_used) do
+ reg.open(key) do |regdi|
+ dom, ns = get_dhcpinfo_key(version, regdi, iflist)
+ search << dom if dom
+ nameserver.concat(ns) if ns
+ end
+ end
+ end
+ end
+ [ search, nameserver ]
+ end
+
+ def get_dhcpinfo_95(reg)
+ dhcp = reg.read_bin("DhcpInfo")
+ [
+ API.unpackdw(dhcp[4..7]),
+ API.unpackdw(dhcp[8..11]),
+ 1,
+ dhcp[45..50],
+ reg.read_bin("OptionInfo"),
+ ]
+ end
+
+ def get_dhcpinfo_98(reg)
+ [
+ API.unpackdw(reg.read_bin("DhcpIPAddress")),
+ API.unpackdw(reg.read_bin("DhcpSubnetMask")),
+ API.unpackdw(reg.read_bin("HardwareType")),
+ reg.read_bin("HardwareAddress"),
+ reg.read_bin("OptionInfo"),
+ ]
+ end
+
+ def get_dhcpinfo_key(version, reg, iflist)
+ info = case version
+ when 1
+ get_dhcpinfo_95(reg)
+ when 2
+ get_dhcpinfo_98(reg)
+ else
+ begin
+ get_dhcpinfo_98(reg)
+ rescue Registry::Error
+ get_dhcpinfo_95(reg)
+ end
+ end
+ ipaddr, netmask, hwtype, macaddr, opt = info
+ throw :not_used unless
+ ipaddr and ipaddr != 0 and
+ netmask and netmask != 0 and
+ macaddr and macaddr.size == 6 and
+ hwtype == 1 and
+ iflist[0][macaddr] and iflist[1][ipaddr]
+
+ size = opt.size
+ idx = 0
+ while idx <= size
+ opttype = opt[idx]
+ optsize = opt[idx + 1]
+ optval = opt[idx + 2, optsize]
+ case opttype
+ when 0xFF ## term
+ break
+ when 0x0F ## domain
+ domain = optval.chomp("\0")
+ when 0x06 ## dns
+ nameserver = optval.scan(/..../).collect { |addr|
+ "%d.%d.%d.%d" % addr.unpack('C4')
+ }
+ end
+ idx += optsize + 2
+ end
+ [ domain, nameserver ]
+ rescue Registry::Error
+ throw :not_used
+ end
+ end
+
+ module WsControl
+ WsControl = Win32API.new('wsock32.dll', 'WsControl', 'LLPPPP', 'L')
+ WSAGetLastError = Win32API.new('wsock32.dll', 'WSAGetLastError', 'V', 'L')
+
+ MAX_TDI_ENTITIES = 512
+ IPPROTO_TCP = 6
+ WSCTL_TCP_QUERY_INFORMATION = 0
+ INFO_CLASS_GENERIC = 0x100
+ INFO_CLASS_PROTOCOL = 0x200
+ INFO_TYPE_PROVIDER = 0x100
+ ENTITY_LIST_ID = 0
+ GENERIC_ENTITY = 0
+ CL_NL_ENTITY = 0x301
+ IF_ENTITY = 0x200
+ ENTITY_TYPE_ID = 1
+ CL_NL_IP = 0x303
+ IF_MIB = 0x202
+ IF_MIB_STATS_ID = 1
+ IP_MIB_ADDRTABLE_ENTRY_ID = 0x102
+
+ def self.wsctl(tei_entity, tei_instance,
+ toi_class, toi_type, toi_id,
+ buffsize)
+ reqinfo = [
+ ## TDIEntityID
+ tei_entity, tei_instance,
+ ## TDIObjectID
+ toi_class, toi_type, toi_id,
+ ## TCP_REQUEST_INFORMATION_EX
+ ""
+ ].pack('VVVVVa16')
+ reqsize = API.packdw(reqinfo.size)
+ buff = "\0" * buffsize
+ buffsize = API.packdw(buffsize)
+ result = WsControl.call(
+ IPPROTO_TCP,
+ WSCTL_TCP_QUERY_INFORMATION,
+ reqinfo, reqsize,
+ buff, buffsize)
+ if result != 0
+ raise RuntimeError, "WsControl failed.(#{result})"
+ end
+ [ buff, API.unpackdw(buffsize) ]
+ end
+ private_class_method :wsctl
+
+ def self.get_iflist
+ # Get TDI Entity List
+ entities, size =
+ wsctl(GENERIC_ENTITY, 0,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_LIST_ID,
+ MAX_TDI_ENTITIES * 8) # sizeof(TDIEntityID)
+ entities = entities[0, size].
+ scan(/.{8}/).
+ collect { |e| e.unpack('VV') }
+
+ # Get MIB Interface List
+ iflist = []
+ ifcount = 0
+ entities.each do |entity, instance|
+ if( (entity & IF_ENTITY)>0 )
+ ifcount += 1
+ etype, = wsctl(entity, instance,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_TYPE_ID,
+ 4)
+ if( (API.unpackdw(etype) & IF_MIB)==IF_MIB )
+ ifentry, = wsctl(entity, instance,
+ INFO_CLASS_PROTOCOL,
+ INFO_TYPE_PROVIDER,
+ IF_MIB_STATS_ID,
+ 21 * 4 + 8 + 130) # sizeof(IFEntry)
+ iflist << [
+ API.unpackdw(ifentry[0,4]),
+ ifentry[20, 6]
+ ]
+ end
+ end
+ end
+
+ # Get IP Addresses
+ entities.each do |entity, instance|
+ if entity == CL_NL_ENTITY
+ etype, = wsctl(entity, instance,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_TYPE_ID,
+ 4)
+ if API.unpackdw(etype) == CL_NL_IP
+ ipentries, = wsctl(entity, instance,
+ INFO_CLASS_PROTOCOL,
+ INFO_TYPE_PROVIDER,
+ IP_MIB_ADDRTABLE_ENTRY_ID,
+ 24 * (ifcount+1)) # sizeof(IPAddrEntry)
+ ipentries.scan(/.{24}/) do |ipentry|
+ ipaddr, index = ipentry.unpack('VV')
+ if ifitem = iflist.assoc(index)
+ ifitem << ipaddr
+ end
+ end
+ end
+ end
+ end
+ iflist
+ end
+ end
+ __EOS__
+end
+#====================================================================
+ end
+end
diff --git a/ext/aix_mksym.rb b/ext/aix_mksym.rb
deleted file mode 100644
index 7e1af283dc..0000000000
--- a/ext/aix_mksym.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-
-def uniq(data)
- last=nil
- data.delete_if do |name|
- if last == name
- TRUE
- else
- last = name
- FALSE
- end
- end
-end
-
-def extract(nm, out)
- data = nm.readlines.collect{|line|
- line = line.split
- case line[1]
- when "B", "D"
- line[0]
- else
- next
- end
- }.compact!.sort!
- uniq(data)
- exp = open(out, "w")
- exp.printf "#!\n"
- for line in data
- exp.printf "%s\n", line
- end
- exp.close
- nm.close
-end
-extract(open("|/usr/ccs/bin/nm -p ../libruby.a"), "../ruby.imp")
diff --git a/ext/bigdecimal/.cvsignore b/ext/bigdecimal/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/bigdecimal/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/bigdecimal/README b/ext/bigdecimal/README
new file mode 100644
index 0000000000..a233f47f64
--- /dev/null
+++ b/ext/bigdecimal/README
@@ -0,0 +1,60 @@
+
+ Ruby BIGDECIMAL(Variable Precision) extension library.
+ Copyright (C) 1999 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
+
+BigDecimal is copyrighted free software by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
+You can redistribute it and/or modify it under either the terms of the GPL
+(see COPYING file), or the conditions below:
+
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) rename any non-standard executables so the names do not conflict
+ with standard executables, which must also be provided.
+
+ d) make other distribution arrangements with the author.
+
+ 3. You may distribute the software in object code or executable
+ form, provided that you do at least ONE of the following:
+
+ a) distribute the executables and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
+
+ b) accompany the distribution with the machine-readable source of
+ the software.
+
+ c) give non-standard executables non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial).
+
+ 5. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+* The Author
+
+Feel free to send comments and bug reports to the author. Here is the
+author's latest mail address:
+
+ shigeo@tinyforest.gr.jp
+
+-------------------------------------------------------
+created at: Thu Dec 22 1999
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
new file mode 100644
index 0000000000..4ccba8809a
--- /dev/null
+++ b/ext/bigdecimal/bigdecimal.c
@@ -0,0 +1,4057 @@
+/*
+ *
+ * Ruby BigDecimal(Variable decimal precision) extension library.
+ *
+ * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Artistic License, as specified in the README file
+ * of this BigDecimal distribution.
+ *
+ * NOTE: Change log in this source removed to reduce source code size.
+ * See rev. 1.25 if needed.
+ *
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <float.h>
+#include <math.h>
+#include "ruby.h"
+#include "math.h"
+#include "version.h"
+
+/* #define ENABLE_NUMERIC_STRING */
+
+VALUE rb_cBigDecimal;
+
+#include "bigdecimal.h"
+
+/* MACRO's to guard objects from GC by keeping them in stack */
+#define ENTER(n) volatile VALUE vStack[n];int iStack=0
+#define PUSH(x) vStack[iStack++] = (unsigned long)(x);
+#define SAVE(p) PUSH(p->obj);
+#define GUARD_OBJ(p,y) {p=y;SAVE(p);}
+
+/*
+ * ================== Ruby Interface part ==========================
+ */
+#define DoSomeOne(x,y) rb_num_coerce_bin(x,y)
+
+/*
+ * **** BigDecimal version ****
+ */
+static VALUE
+BigDecimal_version(VALUE self)
+{
+ /*
+ * 1.0.0: Ruby 1.8.0
+ * 1.0.1: Ruby 1.8.1
+ */
+ return rb_str_new2("1.0.1");
+}
+
+/*
+ * VP routines used in BigDecimal part
+ */
+static unsigned short VpGetException(void);
+static void VpSetException(unsigned short f);
+static void VpInternalRound(Real *c,int ixDigit,U_LONG vPrev,U_LONG v);
+static int VpLimitRound(Real *c,U_LONG ixDigit);
+
+/*
+ * **** BigDecimal part ****
+ */
+
+static void
+BigDecimal_delete(Real *pv)
+{
+ VpFree(pv);
+}
+
+static VALUE
+ToValue(Real *p)
+{
+ if(VpIsNaN(p)) {
+ VpException(VP_EXCEPTION_NaN,"Computation results to 'NaN'(Not a Number)",0);
+ } else if(VpIsPosInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY,"Computation results to 'Infinity'",0);
+ } else if(VpIsNegInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY,"Computation results to '-Infinity'",0);
+ }
+ return p->obj;
+}
+
+static Real *
+GetVpValue(VALUE v, int must)
+{
+ Real *pv;
+ VALUE bg;
+ char szD[128];
+
+ switch(TYPE(v))
+ {
+ case T_DATA:
+ if(RDATA(v)->dfree ==(void *) BigDecimal_delete) {
+ Data_Get_Struct(v, Real, pv);
+ return pv;
+ } else {
+ goto SomeOneMayDoIt;
+ }
+ break;
+ case T_FIXNUM:
+ sprintf(szD, "%ld", FIX2LONG(v));
+ return VpCreateRbObject(VpBaseFig() * 2 + 1, szD);
+
+#ifdef ENABLE_NUMERIC_STRING
+ case T_STRING:
+ SafeStringValue(v);
+ return VpCreateRbObject(strlen(RSTRING(v)->ptr) + VpBaseFig() + 1,
+ RSTRING(v)->ptr);
+#endif /* ENABLE_NUMERIC_STRING */
+
+ case T_BIGNUM:
+ bg = rb_big2str(v, 10);
+ return VpCreateRbObject(strlen(RSTRING(bg)->ptr) + VpBaseFig() + 1,
+ RSTRING(bg)->ptr);
+ default:
+ goto SomeOneMayDoIt;
+ }
+
+SomeOneMayDoIt:
+ if(must) {
+ rb_raise(rb_eTypeError, "%s can't be coerced into BigDecimal",
+ rb_special_const_p(v)?
+ RSTRING(rb_inspect(v))->ptr:
+ rb_obj_classname(v)
+ );
+ }
+ return NULL; /* NULL means to coerce */
+}
+
+static VALUE
+BigDecimal_double_fig(VALUE self)
+{
+ return INT2FIX(VpDblFig());
+}
+
+static VALUE
+BigDecimal_prec(VALUE self)
+{
+ ENTER(1);
+ Real *p;
+ VALUE obj;
+
+ GUARD_OBJ(p,GetVpValue(self,1));
+ obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
+ INT2NUM(p->MaxPrec*VpBaseFig()));
+ return obj;
+}
+
+static VALUE
+BigDecimal_hash(VALUE self)
+{
+ ENTER(1);
+ Real *p;
+ U_LONG hash,i;
+
+ GUARD_OBJ(p,GetVpValue(self,1));
+ hash = (U_LONG)p->sign;
+ /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */
+ if(hash==2) {
+ for(i = 0; i < p->Prec;i++) {
+ hash = 31 * hash + p->frac[i];
+ hash ^= p->frac[i];
+ }
+ hash += p->exponent;
+ }
+ return INT2FIX(hash);
+}
+
+static VALUE
+BigDecimal_dump(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ char sz[50];
+ Real *vp;
+ char *psz;
+ VALUE dummy;
+ rb_scan_args(argc, argv, "01", &dummy);
+ GUARD_OBJ(vp,GetVpValue(self,1));
+ sprintf(sz,"%lu:",VpMaxPrec(vp)*VpBaseFig());
+ psz = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp,"E")+strlen(sz));
+ sprintf(psz,"%s",sz);
+ VpToString(vp, psz+strlen(psz), 0, 0);
+ return rb_str_new2(psz);
+}
+
+static VALUE
+BigDecimal_load(VALUE self, VALUE str)
+{
+ ENTER(2);
+ Real *pv;
+ unsigned char *pch;
+ unsigned char ch;
+ unsigned long m=0;
+
+ SafeStringValue(str);
+ pch = RSTRING(str)->ptr;
+ /* First get max prec */
+ while((*pch)!=(unsigned char)'\0' && (ch=*pch++)!=(unsigned char)':') {
+ if(!ISDIGIT(ch)) {
+ rb_raise(rb_eTypeError, "Load failed: invalid character in the marshaled string");
+ }
+ m = m*10 + (unsigned long)(ch-'0');
+ }
+ if(m>VpBaseFig()) m -= VpBaseFig();
+ GUARD_OBJ(pv,VpNewRbClass(m,pch,self));
+ m /= VpBaseFig();
+ if(m && pv->MaxPrec>m) pv->MaxPrec = m+1;
+ return ToValue(pv);
+}
+
+static VALUE
+BigDecimal_mode(int argc, VALUE *argv, VALUE self)
+{
+ VALUE which;
+ VALUE val;
+ unsigned long f,fo;
+
+ if(rb_scan_args(argc,argv,"11",&which,&val)==1) val = Qnil;
+
+ Check_Type(which, T_FIXNUM);
+ f = (unsigned long)FIX2INT(which);
+
+ if(f&VP_EXCEPTION_ALL) {
+ /* Exception mode setting */
+ fo = VpGetException();
+ if(val==Qnil) return INT2FIX(fo);
+ if(val!=Qfalse && val!=Qtrue) {
+ rb_raise(rb_eTypeError, "The second argument must be true or false.");
+ return Qnil; /* Not reached */
+ }
+ if(f&VP_EXCEPTION_INFINITY) {
+ VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_INFINITY):
+ (fo&(~VP_EXCEPTION_INFINITY))));
+ }
+ if(f&VP_EXCEPTION_NaN) {
+ VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_NaN):
+ (fo&(~VP_EXCEPTION_NaN))));
+ }
+ fo = VpGetException();
+ return INT2FIX(fo);
+ }
+ if(VP_ROUND_MODE==f) {
+ /* Rounding mode setting */
+ fo = VpGetRoundMode();
+ if(val==Qnil) return INT2FIX(fo);
+ Check_Type(val, T_FIXNUM);
+ if(!VpIsRoundMode(FIX2INT(val))) {
+ rb_raise(rb_eTypeError, "Invalid rounding mode.");
+ return Qnil;
+ }
+ fo = VpSetRoundMode((unsigned long)FIX2INT(val));
+ return INT2FIX(fo);
+ }
+ rb_raise(rb_eTypeError, "The first argument for BigDecimal#mode is invalid.");
+ return Qnil;
+}
+
+static U_LONG
+GetAddSubPrec(Real *a, Real *b)
+{
+ U_LONG mxs;
+ U_LONG mx = a->Prec;
+ S_INT d;
+
+ if(!VpIsDef(a) || !VpIsDef(b)) return (-1L);
+ if(mx < b->Prec) mx = b->Prec;
+ if(a->exponent!=b->exponent) {
+ mxs = mx;
+ d = a->exponent - b->exponent;
+ if(d<0) d = -d;
+ mx = mx+(U_LONG)d;
+ if(mx<mxs) {
+ return VpException(VP_EXCEPTION_INFINITY,"Exponent overflow",0);
+ }
+ }
+ return mx;
+}
+
+static S_INT
+GetPositiveInt(VALUE v)
+{
+ S_INT n;
+ Check_Type(v, T_FIXNUM);
+ n = FIX2INT(v);
+ if(n < 0) {
+ rb_raise(rb_eArgError, "argument must be positive");
+ }
+ return n;
+}
+
+VP_EXPORT Real *
+VpNewRbClass(U_LONG mx, char *str, VALUE klass)
+{
+ Real *pv = VpAlloc(mx,str);
+ pv->obj = (VALUE)Data_Wrap_Struct(klass, 0, BigDecimal_delete, pv);
+ return pv;
+}
+
+VP_EXPORT Real *
+VpCreateRbObject(U_LONG mx, char *str)
+{
+ Real *pv = VpAlloc(mx,str);
+ pv->obj = (VALUE)Data_Wrap_Struct(rb_cBigDecimal, 0, BigDecimal_delete, pv);
+ return pv;
+}
+
+
+static VALUE
+BigDecimal_IsNaN(VALUE self)
+{
+ Real *p = GetVpValue(self,1);
+ if(VpIsNaN(p)) return Qtrue;
+ return Qfalse;
+}
+
+static VALUE
+BigDecimal_IsInfinite(VALUE self)
+{
+ Real *p = GetVpValue(self,1);
+ if(VpIsPosInf(p)) return INT2FIX(1);
+ if(VpIsNegInf(p)) return INT2FIX(-1);
+ return Qnil;
+}
+
+static VALUE
+BigDecimal_IsFinite(VALUE self)
+{
+ Real *p = GetVpValue(self,1);
+ if(VpIsNaN(p)) return Qfalse;
+ if(VpIsInf(p)) return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+BigDecimal_to_i(VALUE self)
+{
+ ENTER(5);
+ int e,n,i,nf;
+ U_LONG v,b,j;
+ char *psz,*pch;
+ Real *p;
+
+ GUARD_OBJ(p,GetVpValue(self,1));
+
+ /* Infinity or NaN not converted. */
+ if(VpIsNaN(p)) {
+ VpException(VP_EXCEPTION_NaN,"Computation results to 'NaN'(Not a Number)",0);
+ return Qnil;
+ } else if(VpIsPosInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY,"Computation results to 'Infinity'",0);
+ return Qnil;
+ } else if(VpIsNegInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY,"Computation results to '-Infinity'",0);
+ return Qnil;
+ }
+
+ e = VpExponent10(p);
+ if(e<=0) return INT2FIX(0);
+ nf = VpBaseFig();
+ if(e<=nf) {
+ e = VpGetSign(p)*p->frac[0];
+ return INT2FIX(e);
+ }
+ psz = ALLOCA_N(char,(unsigned int)(e+nf+2));
+
+ n = (e+nf-1)/nf;
+ pch = psz;
+ if(VpGetSign(p)<0) *pch++ = '-';
+ for(i=0;i<n;++i) {
+ b = VpBaseVal()/10;
+ if(i>=(int)p->Prec) {
+ while(b) {
+ *pch++ = '0';
+ b /= 10;
+ }
+ continue;
+ }
+ v = p->frac[i];
+ while(b) {
+ j = v/b;
+ *pch++ = (char)(j + '0');
+ v -= j*b;
+ b /= 10;
+ }
+ }
+ *pch++ = 0;
+ return rb_cstr2inum(psz,10);
+}
+
+static VALUE
+BigDecimal_induced_from(VALUE self, VALUE x)
+{
+ Real *p = GetVpValue(x,1);
+ return p->obj;
+}
+
+static VALUE
+BigDecimal_to_f(VALUE self)
+{
+ ENTER(1);
+ Real *p;
+ double d, d2;
+ S_LONG e;
+
+ GUARD_OBJ(p,GetVpValue(self,1));
+ if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d);
+ errno = 0;
+ d2 = pow(10.0,(double)e);
+ if((errno == ERANGE && e>0) || (d2>1.0 && (fabs(d) > (DBL_MAX / d2)))) {
+ VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion.",0);
+ if(d>0.0) return rb_float_new(DBL_MAX);
+ else return rb_float_new(-DBL_MAX);
+ }
+ return rb_float_new(d*d2);
+}
+
+static VALUE
+BigDecimal_coerce(VALUE self, VALUE other)
+{
+ ENTER(2);
+ VALUE obj;
+ Real *b;
+ if(TYPE(other) == T_FLOAT) {
+ obj = rb_assoc_new(other, BigDecimal_to_f(self));
+ } else {
+ GUARD_OBJ(b,GetVpValue(other,1));
+ obj = rb_assoc_new(b->obj, self);
+ }
+ return obj;
+}
+
+static VALUE
+BigDecimal_uplus(VALUE self)
+{
+ return self;
+}
+
+static VALUE
+BigDecimal_add(VALUE self, VALUE r)
+{
+ ENTER(5);
+ Real *c, *a, *b;
+ U_LONG mx;
+ GUARD_OBJ(a,GetVpValue(self,1));
+ b = GetVpValue(r,0);
+ if(!b) return DoSomeOne(self,r);
+ SAVE(b);
+ if(VpIsNaN(b)) return b->obj;
+ if(VpIsNaN(a)) return a->obj;
+ mx = GetAddSubPrec(a,b);
+ if(mx==(-1L)) {
+ GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
+ VpAddSub(c, a, b, 1);
+ } else {
+ GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
+ if(!mx) {
+ VpSetInf(c,VpGetSign(a));
+ } else {
+ VpAddSub(c, a, b, 1);
+ }
+ }
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_sub(VALUE self, VALUE r)
+{
+ ENTER(5);
+ Real *c, *a, *b;
+ U_LONG mx;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ b = GetVpValue(r,0);
+ if(!b) return DoSomeOne(self,r);
+ SAVE(b);
+
+ if(VpIsNaN(b)) return b->obj;
+ if(VpIsNaN(a)) return a->obj;
+
+ mx = GetAddSubPrec(a,b);
+ if(mx==(-1L)) {
+ GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
+ VpAddSub(c, a, b, -1);
+ } else {
+ GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
+ if(!mx) {
+ VpSetInf(c,VpGetSign(a));
+ } else {
+ VpAddSub(c, a, b, -1);
+ }
+ }
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimalCmp(VALUE self, VALUE r,char op)
+{
+ ENTER(5);
+ S_INT e;
+ Real *a, *b;
+ GUARD_OBJ(a,GetVpValue(self,1));
+ b = GetVpValue(r,0);
+ if(!b) return rb_num_coerce_cmp(self,r);
+ SAVE(b);
+ e = VpComp(a, b);
+ if(e==999) return Qnil;
+ switch(op)
+ {
+ case '*': return INT2FIX(e); /* any op */
+ case '=': if(e==0) return Qtrue ; return Qfalse;
+ case '!': if(e!=0) return Qtrue ; return Qfalse;
+ case 'G': if(e>=0) return Qtrue ; return Qfalse;
+ case '>': if(e> 0) return Qtrue ; return Qfalse;
+ case 'L': if(e<=0) return Qtrue ; return Qfalse;
+ case '<': if(e< 0) return Qtrue ; return Qfalse;
+ }
+ rb_bug("Undefined operation in BigDecimalCmp()");
+}
+
+static VALUE
+BigDecimal_zero(VALUE self)
+{
+ Real *a = GetVpValue(self,1);
+ return VpIsZero(a) ? Qtrue : Qfalse;
+}
+
+static VALUE
+BigDecimal_nonzero(VALUE self)
+{
+ Real *a = GetVpValue(self,1);
+ return VpIsZero(a) ? Qnil : self;
+}
+
+static VALUE
+BigDecimal_comp(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '*');
+}
+
+static VALUE
+BigDecimal_eq(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '=');
+}
+
+static VALUE
+BigDecimal_ne(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '!');
+}
+
+static VALUE
+BigDecimal_lt(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '<');
+}
+
+static VALUE
+BigDecimal_le(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, 'L');
+}
+
+static VALUE
+BigDecimal_gt(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '>');
+}
+
+static VALUE
+BigDecimal_ge(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, 'G');
+}
+
+static VALUE
+BigDecimal_neg(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ GUARD_OBJ(a,GetVpValue(self,1));
+ GUARD_OBJ(c,VpCreateRbObject(a->Prec *(VpBaseFig() + 1), "0"));
+ VpAsgn(c, a, -1);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_mult(VALUE self, VALUE r)
+{
+ ENTER(5);
+ Real *c, *a, *b;
+ U_LONG mx;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ b = GetVpValue(r,0);
+ if(!b) return DoSomeOne(self,r);
+ SAVE(b);
+
+ mx = a->Prec + b->Prec;
+ GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
+ VpMult(c, a, b);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
+/* For c = self.div(r): with round operation */
+{
+ ENTER(5);
+ Real *a, *b;
+ U_LONG mx;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ b = GetVpValue(r,0);
+ if(!b) return DoSomeOne(self,r);
+ SAVE(b);
+ *div = b;
+ mx =(a->MaxPrec + b->MaxPrec + 1) * VpBaseFig();
+ GUARD_OBJ((*c),VpCreateRbObject(mx, "#0"));
+ GUARD_OBJ((*res),VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+ VpDivd(*c, *res, a, b);
+ return (VALUE)0;
+}
+
+static VALUE
+BigDecimal_div(VALUE self, VALUE r)
+/* For c = self/r: with round operation */
+{
+ ENTER(5);
+ Real *c=NULL, *res=NULL, *div = NULL;
+ r = BigDecimal_divide(&c, &res, &div, self, r);
+ if(r!=(VALUE)0) return r; /* coerced by other */
+ SAVE(c);SAVE(res);SAVE(div);
+ /* a/b = c + r/b */
+ /* c xxxxx
+ r 00000yyyyy ==> (y/b)*BASE >= HALF_BASE
+ */
+ /* Round */
+ if(VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
+ VpInternalRound(c,0,c->frac[c->Prec-1],(VpBaseVal()*res->frac[0])/div->frac[0]);
+ }
+ return ToValue(c);
+}
+
+/*
+ * %: mod = a%b = a - (a.to_f/b).floor * b
+ * div = (a.to_f/b).floor
+ */
+static VALUE
+BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
+{
+ ENTER(8);
+ Real *c=NULL, *d=NULL, *res=NULL;
+ Real *a, *b;
+ U_LONG mx;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ b = GetVpValue(r,0);
+ if(!b) return DoSomeOne(self,r);
+ SAVE(b);
+
+ if(VpIsNaN(a) || VpIsNaN(b)) goto NaN;
+ if(VpIsInf(a) || VpIsInf(b)) goto NaN;
+ if(VpIsZero(b)) goto NaN;
+ if(VpIsZero(a)) {
+ GUARD_OBJ(c,VpCreateRbObject(1, "0"));
+ GUARD_OBJ(d,VpCreateRbObject(1, "0"));
+ *div = d;
+ *mod = c;
+ return (VALUE)0;
+ }
+
+ mx = a->Prec;
+ if(mx<b->Prec) mx = b->Prec;
+ mx =(mx + 1) * VpBaseFig();
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+ VpDivd(c, res, a, b);
+ mx = c->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(d,VpCreateRbObject(mx, "0"));
+ VpActiveRound(d,c,VP_ROUND_DOWN,0);
+ VpMult(res,d,b);
+ VpAddSub(c,a,res,-1);
+ if(!VpIsZero(c) && (VpGetSign(a)*VpGetSign(b)<0)) {
+ VpAddSub(res,d,VpOne(),-1);
+ VpAddSub(d ,c,b, 1);
+ *div = res;
+ *mod = d;
+ } else {
+ *div = d;
+ *mod = c;
+ }
+ return (VALUE)0;
+
+NaN:
+ GUARD_OBJ(c,VpCreateRbObject(1, "NaN"));
+ GUARD_OBJ(d,VpCreateRbObject(1, "NaN"));
+ *div = d;
+ *mod = c;
+ return (VALUE)0;
+}
+
+static VALUE
+BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */
+{
+ ENTER(3);
+ VALUE obj;
+ Real *div=NULL, *mod=NULL;
+
+ obj = BigDecimal_DoDivmod(self,r,&div,&mod);
+ if(obj!=(VALUE)0) return obj;
+ SAVE(div);SAVE(mod);
+ return ToValue(mod);
+}
+
+static VALUE
+BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv)
+{
+ ENTER(10);
+ U_LONG mx;
+ Real *a=NULL, *b=NULL, *c=NULL, *res=NULL, *d=NULL, *rr=NULL, *ff=NULL;
+ Real *f=NULL;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ b = GetVpValue(r,0);
+ if(!b) return DoSomeOne(self,r);
+ SAVE(b);
+
+ mx =(a->MaxPrec + b->MaxPrec) *VpBaseFig();
+ GUARD_OBJ(c ,VpCreateRbObject(mx, "0"));
+ GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+ GUARD_OBJ(rr ,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+ GUARD_OBJ(ff ,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+
+ VpDivd(c, res, a, b);
+
+ mx = c->Prec *(VpBaseFig() + 1);
+
+ GUARD_OBJ(d,VpCreateRbObject(mx, "0"));
+ GUARD_OBJ(f,VpCreateRbObject(mx, "0"));
+
+ VpActiveRound(d,c,VP_ROUND_DOWN,0); /* 0: round off */
+
+ VpFrac(f, c);
+ VpMult(rr,f,b);
+ VpAddSub(ff,res,rr,1);
+
+ *dv = d;
+ *rv = ff;
+ return (VALUE)0;
+}
+
+static VALUE
+BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
+{
+ VALUE f;
+ Real *d,*rv;
+ f = BigDecimal_divremain(self,r,&d,&rv);
+ if(f!=(VALUE)0) return f;
+ return ToValue(rv);
+}
+
+static VALUE
+BigDecimal_divmod(VALUE self, VALUE r)
+{
+ ENTER(5);
+ VALUE obj;
+ Real *div=NULL, *mod=NULL;
+
+ obj = BigDecimal_DoDivmod(self,r,&div,&mod);
+ if(obj!=(VALUE)0) return obj;
+ SAVE(div);SAVE(mod);
+ obj = rb_assoc_new(ToValue(div), ToValue(mod));
+ return obj;
+}
+
+static VALUE
+BigDecimal_div2(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ VALUE b,n;
+ int na = rb_scan_args(argc,argv,"11",&b,&n);
+ if(na==1) { /* div in Float sense */
+ VALUE obj;
+ Real *div=NULL;
+ Real *mod;
+ obj = BigDecimal_DoDivmod(self,b,&div,&mod);
+ if(obj!=(VALUE)0) return obj;
+ return ToValue(div);
+ } else { /* div in BigDecimal sense */
+ U_LONG ix = (U_LONG)GetPositiveInt(n);
+ if(ix==0) return BigDecimal_div(self,b);
+ else {
+ Real *res=NULL;
+ Real *av=NULL, *bv=NULL, *cv=NULL;
+ U_LONG mx = (ix+VpBaseFig()*2);
+ U_LONG pl = VpSetPrecLimit(0);
+
+ GUARD_OBJ(cv,VpCreateRbObject(mx,"0"));
+ GUARD_OBJ(av,GetVpValue(self,1));
+ GUARD_OBJ(bv,GetVpValue(b,1));
+ mx = av->Prec + bv->Prec + 2;
+ if(mx <= cv->MaxPrec) mx = cv->MaxPrec+1;
+ GUARD_OBJ(res,VpCreateRbObject((mx * 2 + 2)*VpBaseFig(), "#0"));
+ VpDivd(cv,res,av,bv);
+ VpSetPrecLimit(pl);
+ VpLeftRound(cv,VpGetRoundMode(),ix);
+ return ToValue(cv);
+ }
+ }
+}
+
+static VALUE
+BigDecimal_add2(VALUE self, VALUE b, VALUE n)
+{
+ ENTER(2);
+ Real *cv;
+ U_LONG mx = (U_LONG)GetPositiveInt(n);
+ if(mx==0) return BigDecimal_add(self,b);
+ else {
+ U_LONG pl = VpSetPrecLimit(0);
+ VALUE c = BigDecimal_add(self,b);
+ VpSetPrecLimit(pl);
+ GUARD_OBJ(cv,GetVpValue(c,1));
+ VpLeftRound(cv,VpGetRoundMode(),mx);
+ return ToValue(cv);
+ }
+}
+
+static VALUE
+BigDecimal_sub2(VALUE self, VALUE b, VALUE n)
+{
+ ENTER(2);
+ Real *cv;
+ U_LONG mx = (U_LONG)GetPositiveInt(n);
+ if(mx==0) return BigDecimal_sub(self,b);
+ else {
+ U_LONG pl = VpSetPrecLimit(0);
+ VALUE c = BigDecimal_sub(self,b);
+ VpSetPrecLimit(pl);
+ GUARD_OBJ(cv,GetVpValue(c,1));
+ VpLeftRound(cv,VpGetRoundMode(),mx);
+ return ToValue(cv);
+ }
+}
+
+static VALUE
+BigDecimal_mult2(VALUE self, VALUE b, VALUE n)
+{
+ ENTER(2);
+ Real *cv;
+ U_LONG mx = (U_LONG)GetPositiveInt(n);
+ if(mx==0) return BigDecimal_mult(self,b);
+ else {
+ U_LONG pl = VpSetPrecLimit(0);
+ VALUE c = BigDecimal_mult(self,b);
+ VpSetPrecLimit(pl);
+ GUARD_OBJ(cv,GetVpValue(c,1));
+ VpLeftRound(cv,VpGetRoundMode(),mx);
+ return ToValue(cv);
+ }
+}
+
+static VALUE
+BigDecimal_abs(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ U_LONG mx;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpAsgn(c, a, 1);
+ VpChangeSign(c,(S_INT)1);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_sqrt(VALUE self, VALUE nFig)
+{
+ ENTER(5);
+ Real *c, *a;
+ S_INT mx, n;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+
+ n = GetPositiveInt(nFig) + VpDblFig() + 1;
+ if(mx <= n) mx = n;
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpSqrt(c, a);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_fix(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ U_LONG mx;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpActiveRound(c,a,VP_ROUND_DOWN,0); /* 0: round off */
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_round(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ int iLoc;
+ U_LONG mx;
+ VALUE vLoc;
+ VALUE vRound;
+ U_LONG pl;
+
+ int sw = VpGetRoundMode();
+
+ int na = rb_scan_args(argc,argv,"02",&vLoc,&vRound);
+ switch(na) {
+ case 0:
+ iLoc = 0;
+ break;
+ case 1:
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ break;
+ case 2:
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ Check_Type(vRound, T_FIXNUM);
+ sw = FIX2INT(vRound);
+ if(!VpIsRoundMode(sw)) {
+ rb_raise(rb_eTypeError, "Invalid rounding mode.");
+ return Qnil;
+ }
+ break;
+ }
+
+ pl = VpSetPrecLimit(0);
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c,a,sw,iLoc);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_truncate(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ int iLoc;
+ U_LONG mx;
+ VALUE vLoc;
+ U_LONG pl = VpSetPrecLimit(0);
+
+ if(rb_scan_args(argc,argv,"01",&vLoc)==0) {
+ iLoc = 0;
+ } else {
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ }
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c,a,VP_ROUND_DOWN,iLoc); /* 0: truncate */
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_frac(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ U_LONG mx;
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpFrac(c, a);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_floor(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ U_LONG mx;
+ int iLoc;
+ VALUE vLoc;
+ U_LONG pl = VpSetPrecLimit(0);
+
+ if(rb_scan_args(argc,argv,"01",&vLoc)==0) {
+ iLoc = 0;
+ } else {
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ }
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c,a,VP_ROUND_FLOOR,iLoc);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ U_LONG mx;
+ int iLoc;
+ VALUE vLoc;
+ U_LONG pl = VpSetPrecLimit(0);
+
+ if(rb_scan_args(argc,argv,"01",&vLoc)==0) {
+ iLoc = 0;
+ } else {
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ }
+
+ GUARD_OBJ(a,GetVpValue(self,1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c,a,VP_ROUND_CEIL,iLoc);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ int fmt=0; /* 0:E format */
+ int fPlus=0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
+ Real *vp;
+ char *psz;
+ char ch;
+ U_LONG nc;
+ S_INT mc = 0;
+ VALUE f;
+
+ GUARD_OBJ(vp,GetVpValue(self,1));
+
+ if(rb_scan_args(argc,argv,"01",&f)==1) {
+ if(TYPE(f)==T_STRING) {
+ SafeStringValue(f);
+ psz = RSTRING(f)->ptr;
+ if(*psz==' ') {
+ fPlus = 1; psz++;
+ } else if(*psz=='+') {
+ fPlus = 2; psz++;
+ }
+ while(ch=*psz++) {
+ if(ISSPACE(ch)) continue;
+ if(!ISDIGIT(ch)) {
+ if(ch=='F' || ch=='f') fmt = 1; /* F format */
+ break;
+ }
+ mc = mc * 10 + ch - '0';
+ }
+ } else {
+ mc = GetPositiveInt(f);
+ }
+ }
+ if(fmt) {
+ nc = VpNumOfChars(vp,"F");
+ } else {
+ nc = VpNumOfChars(vp,"E");
+ }
+ if(mc>0) nc += (nc + mc - 1) / mc + 1;
+
+ psz = ALLOCA_N(char,(unsigned int)nc);
+
+ if(fmt) {
+ VpToFString(vp, psz, mc, fPlus);
+ } else {
+ VpToString (vp, psz, mc, fPlus);
+ }
+ return rb_str_new2(psz);
+}
+
+static VALUE
+BigDecimal_split(VALUE self)
+{
+ ENTER(5);
+ Real *vp;
+ VALUE obj,obj1;
+ S_LONG e;
+ S_LONG s;
+ char *psz1;
+
+ GUARD_OBJ(vp,GetVpValue(self,1));
+ psz1 = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp,"E"));
+ VpSzMantissa(vp,psz1);
+ s = 1;
+ if(psz1[0]=='-') {
+ s = -1; ++psz1;
+ }
+ if(psz1[0]=='N') s=0; /* NaN */
+ e = VpExponent10(vp);
+ obj1 = rb_str_new2(psz1);
+ obj = rb_ary_new2(4);
+ rb_ary_push(obj, INT2FIX(s));
+ rb_ary_push(obj, obj1);
+ rb_ary_push(obj, INT2FIX(10));
+ rb_ary_push(obj, INT2NUM(e));
+ return obj;
+}
+
+static VALUE
+BigDecimal_exponent(VALUE self)
+{
+ S_LONG e = VpExponent10(GetVpValue(self,1));
+ return INT2NUM(e);
+}
+
+static VALUE
+BigDecimal_inspect(VALUE self)
+{
+ ENTER(5);
+ Real *vp;
+ VALUE obj;
+ unsigned int nc;
+ char *psz1;
+ char *pszAll;
+
+ GUARD_OBJ(vp,GetVpValue(self,1));
+ nc = VpNumOfChars(vp,"E");
+ nc +=(nc + 9) / 10;
+
+ psz1 = ALLOCA_N(char,nc);
+ pszAll = ALLOCA_N(char,nc+256);
+ VpToString(vp, psz1, 10, 0);
+ sprintf(pszAll,"#<BigDecimal:%lx,'%s',%lu(%lu)>",self,psz1,VpPrec(vp)*VpBaseFig(),VpMaxPrec(vp)*VpBaseFig());
+ obj = rb_str_new2(pszAll);
+ return obj;
+}
+
+static VALUE
+BigDecimal_power(VALUE self, VALUE p)
+{
+ ENTER(5);
+ Real *x, *y;
+ S_LONG mp, ma, n;
+
+ Check_Type(p, T_FIXNUM);
+ n = FIX2INT(p);
+ ma = n;
+ if(ma < 0) ma = -ma;
+ if(ma == 0) ma = 1;
+
+ GUARD_OBJ(x,GetVpValue(self,1));
+ if(VpIsDef(x)) {
+ mp = x->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(y,VpCreateRbObject(mp *(ma + 1), "0"));
+ } else {
+ GUARD_OBJ(y,VpCreateRbObject(1, "0"));
+ }
+ VpPower(y, x, n);
+ return ToValue(y);
+}
+
+static VALUE
+BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *pv;
+ S_LONG mf;
+ VALUE nFig;
+ VALUE iniValue;
+
+ if(rb_scan_args(argc,argv,"11",&iniValue,&nFig)==1) {
+ mf = 0;
+ } else {
+ mf = GetPositiveInt(nFig);
+ }
+ SafeStringValue(iniValue);
+ GUARD_OBJ(pv,VpCreateRbObject(mf, RSTRING(iniValue)->ptr));
+ return ToValue(pv);
+}
+
+static VALUE
+BigDecimal_new(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *pv;
+ S_LONG mf;
+ VALUE nFig;
+ VALUE iniValue;
+
+ if(rb_scan_args(argc,argv,"11",&iniValue,&nFig)==1) {
+ mf = 0;
+ } else {
+ mf = GetPositiveInt(nFig);
+ }
+ SafeStringValue(iniValue);
+ GUARD_OBJ(pv,VpNewRbClass(mf, RSTRING(iniValue)->ptr,self));
+ return ToValue(pv);
+}
+
+static VALUE
+BigDecimal_limit(int argc, VALUE *argv, VALUE self)
+{
+ VALUE nFig;
+ VALUE nCur = INT2NUM(VpGetPrecLimit());
+
+ if(rb_scan_args(argc,argv,"01",&nFig)==1) {
+ int nf;
+ if(nFig==Qnil) return nCur;
+ Check_Type(nFig, T_FIXNUM);
+ nf = FIX2INT(nFig);
+ if(nf<0) {
+ rb_raise(rb_eArgError, "argument must be positive");
+ }
+ VpSetPrecLimit(nf);
+ }
+ return nCur;
+}
+
+static VALUE
+BigDecimal_sign(VALUE self)
+{ /* sign */
+ int s = GetVpValue(self,1)->sign;
+ return INT2FIX(s);
+}
+
+void
+Init_bigdecimal(void)
+{
+ /* Initialize VP routines */
+ VpInit((U_LONG)0);
+
+ /* Class and method registration */
+ rb_cBigDecimal = rb_define_class("BigDecimal",rb_cNumeric);
+
+ /* Global function */
+ rb_define_global_function("BigDecimal", BigDecimal_global_new, -1);
+
+ /* Class methods */
+ rb_define_singleton_method(rb_cBigDecimal, "new", BigDecimal_new, -1);
+ rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
+ rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
+ rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
+ rb_define_singleton_method(rb_cBigDecimal, "induced_from",BigDecimal_induced_from, 1);
+ rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1);
+ rb_define_singleton_method(rb_cBigDecimal, "ver", BigDecimal_version, 0);
+
+ /* Constants definition */
+ rb_define_const(rb_cBigDecimal, "BASE", INT2FIX((S_INT)VpBaseVal()));
+
+ /* Exceptions */
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_ALL",INT2FIX(VP_EXCEPTION_ALL));
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_NaN",INT2FIX(VP_EXCEPTION_NaN));
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_INFINITY",INT2FIX(VP_EXCEPTION_INFINITY));
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_UNDERFLOW",INT2FIX(VP_EXCEPTION_UNDERFLOW));
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_OVERFLOW",INT2FIX(VP_EXCEPTION_OVERFLOW));
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_ZERODIVIDE",INT2FIX(VP_EXCEPTION_ZERODIVIDE));
+
+ /* Computation mode */
+ rb_define_const(rb_cBigDecimal, "ROUND_MODE",INT2FIX(VP_ROUND_MODE));
+ rb_define_const(rb_cBigDecimal, "ROUND_UP",INT2FIX(VP_ROUND_UP));
+ rb_define_const(rb_cBigDecimal, "ROUND_DOWN",INT2FIX(VP_ROUND_DOWN));
+ rb_define_const(rb_cBigDecimal, "ROUND_HALF_UP",INT2FIX(VP_ROUND_HALF_UP));
+ rb_define_const(rb_cBigDecimal, "ROUND_HALF_DOWN",INT2FIX(VP_ROUND_HALF_DOWN));
+ rb_define_const(rb_cBigDecimal, "ROUND_CEILING",INT2FIX(VP_ROUND_CEIL));
+ rb_define_const(rb_cBigDecimal, "ROUND_FLOOR",INT2FIX(VP_ROUND_FLOOR));
+ rb_define_const(rb_cBigDecimal, "ROUND_HALF_EVEN",INT2FIX(VP_ROUND_HALF_EVEN));
+
+ /* Constants for sign value */
+ rb_define_const(rb_cBigDecimal, "SIGN_NaN",INT2FIX(VP_SIGN_NaN));
+ rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_ZERO",INT2FIX(VP_SIGN_POSITIVE_ZERO));
+ rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_ZERO",INT2FIX(VP_SIGN_NEGATIVE_ZERO));
+ rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_FINITE",INT2FIX(VP_SIGN_POSITIVE_FINITE));
+ rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_FINITE",INT2FIX(VP_SIGN_NEGATIVE_FINITE));
+ rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_INFINITE",INT2FIX(VP_SIGN_POSITIVE_INFINITE));
+ rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE",INT2FIX(VP_SIGN_NEGATIVE_INFINITE));
+
+ /* instance methods */
+ rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);
+ rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2);
+ rb_define_method(rb_cBigDecimal, "sub", BigDecimal_sub2, 2);
+ rb_define_method(rb_cBigDecimal, "mult", BigDecimal_mult2, 2);
+ rb_define_method(rb_cBigDecimal, "div",BigDecimal_div2, -1);
+ rb_define_method(rb_cBigDecimal, "hash", BigDecimal_hash, 0);
+ rb_define_method(rb_cBigDecimal, "to_s", BigDecimal_to_s, -1);
+ rb_define_method(rb_cBigDecimal, "to_i", BigDecimal_to_i, 0);
+ rb_define_method(rb_cBigDecimal, "to_int", BigDecimal_to_i, 0);
+ rb_define_method(rb_cBigDecimal, "split", BigDecimal_split, 0);
+ rb_define_method(rb_cBigDecimal, "+", BigDecimal_add, 1);
+ rb_define_method(rb_cBigDecimal, "-", BigDecimal_sub, 1);
+ rb_define_method(rb_cBigDecimal, "+@", BigDecimal_uplus, 0);
+ rb_define_method(rb_cBigDecimal, "-@", BigDecimal_neg, 0);
+ rb_define_method(rb_cBigDecimal, "*", BigDecimal_mult, 1);
+ rb_define_method(rb_cBigDecimal, "/", BigDecimal_div, 1);
+ rb_define_method(rb_cBigDecimal, "quo", BigDecimal_div, 1);
+ rb_define_method(rb_cBigDecimal, "%", BigDecimal_mod, 1);
+ rb_define_method(rb_cBigDecimal, "modulo", BigDecimal_mod, 1);
+ rb_define_method(rb_cBigDecimal, "remainder", BigDecimal_remainder, 1);
+ rb_define_method(rb_cBigDecimal, "divmod", BigDecimal_divmod, 1);
+ /* rb_define_method(rb_cBigDecimal, "dup", BigDecimal_dup, 0); */
+ rb_define_method(rb_cBigDecimal, "to_f", BigDecimal_to_f, 0);
+ rb_define_method(rb_cBigDecimal, "abs", BigDecimal_abs, 0);
+ rb_define_method(rb_cBigDecimal, "sqrt", BigDecimal_sqrt, 1);
+ rb_define_method(rb_cBigDecimal, "fix", BigDecimal_fix, 0);
+ rb_define_method(rb_cBigDecimal, "round", BigDecimal_round, -1);
+ rb_define_method(rb_cBigDecimal, "frac", BigDecimal_frac, 0);
+ rb_define_method(rb_cBigDecimal, "floor", BigDecimal_floor, -1);
+ rb_define_method(rb_cBigDecimal, "ceil", BigDecimal_ceil, -1);
+ rb_define_method(rb_cBigDecimal, "power", BigDecimal_power, 1);
+ rb_define_method(rb_cBigDecimal, "**", BigDecimal_power, 1);
+ rb_define_method(rb_cBigDecimal, "<=>", BigDecimal_comp, 1);
+ rb_define_method(rb_cBigDecimal, "==", BigDecimal_eq, 1);
+ rb_define_method(rb_cBigDecimal, "===", BigDecimal_eq, 1);
+ rb_define_method(rb_cBigDecimal, "eql?", BigDecimal_eq, 1);
+ rb_define_method(rb_cBigDecimal, "!=", BigDecimal_ne, 1);
+ rb_define_method(rb_cBigDecimal, "<", BigDecimal_lt, 1);
+ rb_define_method(rb_cBigDecimal, "<=", BigDecimal_le, 1);
+ rb_define_method(rb_cBigDecimal, ">", BigDecimal_gt, 1);
+ rb_define_method(rb_cBigDecimal, ">=", BigDecimal_ge, 1);
+ rb_define_method(rb_cBigDecimal, "zero?", BigDecimal_zero, 0);
+ rb_define_method(rb_cBigDecimal, "nonzero?", BigDecimal_nonzero, 0);
+ rb_define_method(rb_cBigDecimal, "coerce", BigDecimal_coerce, 1);
+ rb_define_method(rb_cBigDecimal, "inspect", BigDecimal_inspect, 0);
+ rb_define_method(rb_cBigDecimal, "exponent", BigDecimal_exponent, 0);
+ rb_define_method(rb_cBigDecimal, "sign", BigDecimal_sign, 0);
+ rb_define_method(rb_cBigDecimal, "nan?", BigDecimal_IsNaN, 0);
+ rb_define_method(rb_cBigDecimal, "infinite?", BigDecimal_IsInfinite, 0);
+ rb_define_method(rb_cBigDecimal, "finite?", BigDecimal_IsFinite, 0);
+ rb_define_method(rb_cBigDecimal, "truncate", BigDecimal_truncate, -1);
+ rb_define_method(rb_cBigDecimal, "_dump", BigDecimal_dump, -1);
+}
+
+/*
+ *
+ * ============================================================================
+ *
+ * vp_ routines begin from here.
+ *
+ * ============================================================================
+ *
+ */
+#ifdef _DEBUG
+/*static int gfDebug = 1;*/ /* Debug switch */
+static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */
+#endif /* _DEBUG */
+
+static U_LONG gnPrecLimit = 0; /* Global upper limit of the precision newly allocated */
+static U_LONG gfRoundMode = VP_ROUND_HALF_UP; /* Mode for general rounding operation */
+
+static U_LONG BASE_FIG = 4; /* =log10(BASE) */
+static U_LONG BASE = 10000L; /* Base value(value must be 10**BASE_FIG) */
+ /* The value of BASE**2 + BASE must be represented */
+ /* within one U_LONG. */
+static U_LONG HALF_BASE = 5000L;/* =BASE/2 */
+static S_LONG DBLE_FIG = 8; /* figure of double */
+static U_LONG BASE1 = 1000L; /* =BASE/10 */
+
+static Real *VpConstOne; /* constant 1.0 */
+static Real *VpPt5; /* constant 0.5 */
+static U_LONG maxnr = 100; /* Maximum iterations for calcurating sqrt. */
+ /* used in VpSqrt() */
+
+/* ETC */
+#define MemCmp(x,y,z) memcmp(x,y,z)
+#define StrCmp(x,y) strcmp(x,y)
+
+static int VpIsDefOP(Real *c,Real *a,Real *b,int sw);
+static int AddExponent(Real *a,S_INT n);
+static U_LONG VpAddAbs(Real *a,Real *b,Real *c);
+static U_LONG VpSubAbs(Real *a,Real *b,Real *c);
+static U_LONG VpSetPTR(Real *a,Real *b,Real *c,U_LONG *a_pos,U_LONG *b_pos,U_LONG *c_pos,U_LONG *av,U_LONG *bv);
+static int VpNmlz(Real *a);
+static void VpFormatSt(char *psz,S_INT fFmt);
+static int VpRdup(Real *m,U_LONG ind_m);
+
+#ifdef _DEBUG
+static int gnAlloc=0; /* Memory allocation counter */
+#endif /* _DEBUG */
+
+VP_EXPORT void *
+VpMemAlloc(U_LONG mb)
+{
+ void *p = xmalloc((unsigned int)mb);
+ if(!p) {
+ VpException(VP_EXCEPTION_MEMORY,"failed to allocate memory",1);
+ }
+ memset(p,0,mb);
+#ifdef _DEBUG
+ gnAlloc++; /* Count allocation call */
+#endif /* _DEBUG */
+ return p;
+}
+
+VP_EXPORT void
+VpFree(Real *pv)
+{
+ if(pv != NULL) {
+ xfree(pv);
+#ifdef _DEBUG
+ gnAlloc--; /* Decrement allocation count */
+ if(gnAlloc==0) {
+ printf(" *************** All memories allocated freed ****************");
+ getchar();
+ }
+ if(gnAlloc<0) {
+ printf(" ??????????? Too many memory free calls(%d) ?????????????\n",gnAlloc);
+ getchar();
+ }
+#endif /* _DEBUG */
+ }
+}
+
+/*
+ * EXCEPTION Handling.
+ */
+static unsigned short gfDoException = 0; /* Exception flag */
+
+static unsigned short
+VpGetException (void)
+{
+ return gfDoException;
+}
+
+static void
+VpSetException(unsigned short f)
+{
+ gfDoException = f;
+}
+
+/* These 2 functions added at v1.1.7 */
+VP_EXPORT U_LONG
+VpGetPrecLimit(void)
+{
+ return gnPrecLimit;
+}
+
+VP_EXPORT U_LONG
+VpSetPrecLimit(U_LONG n)
+{
+ U_LONG s = gnPrecLimit;
+ gnPrecLimit = n;
+ return s;
+}
+
+VP_EXPORT unsigned long
+VpGetRoundMode(void)
+{
+ return gfRoundMode;
+}
+
+VP_EXPORT int
+VpIsRoundMode(unsigned long n)
+{
+ if(n==VP_ROUND_UP || n!=VP_ROUND_DOWN ||
+ n==VP_ROUND_HALF_UP || n!=VP_ROUND_HALF_DOWN ||
+ n==VP_ROUND_CEIL || n!=VP_ROUND_FLOOR ||
+ n==VP_ROUND_HALF_EVEN
+ ) return 1;
+ return 0;
+}
+
+VP_EXPORT unsigned long
+VpSetRoundMode(unsigned long n)
+{
+ if(VpIsRoundMode(n)) gfRoundMode = n;
+ return gfRoundMode;
+}
+
+/*
+ * 0.0 & 1.0 generator
+ * These gZero_..... and gOne_..... can be any name
+ * referenced from nowhere except Zero() and One().
+ * gZero_..... and gOne_..... must have global scope
+ * (to let the compiler know they may be changed in outside
+ * (... but not actually..)).
+ */
+volatile double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
+volatile double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
+static double
+Zero(void)
+{
+ return gZero_ABCED9B1_CE73__00400511F31D;
+}
+
+static double
+One(void)
+{
+ return gOne_ABCED9B4_CE73__00400511F31D;
+}
+
+VP_EXPORT U_LONG
+VpBaseFig(void)
+{
+ return BASE_FIG;
+}
+
+VP_EXPORT U_LONG
+VpDblFig(void)
+{
+ return DBLE_FIG;
+}
+
+VP_EXPORT U_LONG
+VpBaseVal(void)
+{
+ return BASE;
+}
+
+/*
+ ----------------------------------------------------------------
+ Value of sign in Real structure is reserved for future use.
+ short sign;
+ ==0 : NaN
+ 1 : Positive zero
+ -1 : Negative zero
+ 2 : Positive number
+ -2 : Negative number
+ 3 : Positive infinite number
+ -3 : Negative infinite number
+ ----------------------------------------------------------------
+*/
+
+VP_EXPORT double
+VpGetDoubleNaN(void) /* Returns the value of NaN */
+{
+ static double fNaN = 0.0;
+ if(fNaN==0.0) fNaN = Zero()/Zero();
+ return fNaN;
+}
+
+VP_EXPORT double
+VpGetDoublePosInf(void) /* Returns the value of +Infinity */
+{
+ static double fInf = 0.0;
+ if(fInf==0.0) fInf = One()/Zero();
+ return fInf;
+}
+
+VP_EXPORT double
+VpGetDoubleNegInf(void) /* Returns the value of -Infinity */
+{
+ static double fInf = 0.0;
+ if(fInf==0.0) fInf = -(One()/Zero());
+ return fInf;
+}
+
+VP_EXPORT double
+VpGetDoubleNegZero(void) /* Returns the value of -0 */
+{
+ static double nzero = 1000.0;
+ if(nzero!=0.0) nzero = (One()/VpGetDoubleNegInf());
+ return nzero;
+}
+
+VP_EXPORT int
+VpIsNegDoubleZero(double v)
+{
+ double z = VpGetDoubleNegZero();
+ return MemCmp(&v,&z,sizeof(v))==0;
+}
+
+VP_EXPORT int
+VpException(unsigned short f,char *str,int always)
+{
+ VALUE exc;
+ int fatal=0;
+
+ if(f==VP_EXCEPTION_OP || f==VP_EXCEPTION_MEMORY) always = 1;
+
+ if(always||(gfDoException&f)) {
+ switch(f)
+ {
+ /*
+ case VP_EXCEPTION_ZERODIVIDE:
+ case VP_EXCEPTION_OVERFLOW:
+ */
+ case VP_EXCEPTION_INFINITY:
+ exc = rb_eFloatDomainError;
+ goto raise;
+ case VP_EXCEPTION_NaN:
+ exc = rb_eFloatDomainError;
+ goto raise;
+ case VP_EXCEPTION_UNDERFLOW:
+ exc = rb_eFloatDomainError;
+ goto raise;
+ case VP_EXCEPTION_OP:
+ exc = rb_eFloatDomainError;
+ goto raise;
+ case VP_EXCEPTION_MEMORY:
+ fatal = 1;
+ goto raise;
+ default:
+ fatal = 1;
+ goto raise;
+ }
+ }
+ return 0; /* 0 Means VpException() raised no exception */
+
+raise:
+ if(fatal) rb_fatal(str);
+ else rb_raise(exc,str);
+ return 0;
+}
+
+/* Throw exception or returns 0,when resulting c is Inf or NaN */
+/* sw=1:+ 2:- 3:* 4:/ */
+static int
+VpIsDefOP(Real *c,Real *a,Real *b,int sw)
+{
+ if(VpIsNaN(a) || VpIsNaN(b)) {
+ /* at least a or b is NaN */
+ VpSetNaN(c);
+ goto NaN;
+ }
+
+ if(VpIsInf(a)) {
+ if(VpIsInf(b)) {
+ switch(sw)
+ {
+ case 1: /* + */
+ if(VpGetSign(a)==VpGetSign(b)) {
+ VpSetInf(c,VpGetSign(a));
+ goto Inf;
+ } else {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ case 2: /* - */
+ if(VpGetSign(a)!=VpGetSign(b)) {
+ VpSetInf(c,VpGetSign(a));
+ goto Inf;
+ } else {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ break;
+ case 3: /* * */
+ VpSetInf(c,VpGetSign(a)*VpGetSign(b));
+ goto Inf;
+ break;
+ case 4: /* / */
+ VpSetNaN(c);
+ goto NaN;
+ }
+ VpSetNaN(c);
+ goto NaN;
+ }
+ /* Inf op Finite */
+ switch(sw)
+ {
+ case 1: /* + */
+ case 2: /* - */
+ VpSetInf(c,VpGetSign(a));
+ break;
+ case 3: /* * */
+ if(VpIsZero(b)) {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ VpSetInf(c,VpGetSign(a)*VpGetSign(b));
+ break;
+ case 4: /* / */
+ VpSetInf(c,VpGetSign(a)*VpGetSign(b));
+ }
+ goto Inf;
+ }
+
+ if(VpIsInf(b)) {
+ switch(sw)
+ {
+ case 1: /* + */
+ VpSetInf(c,VpGetSign(b));
+ break;
+ case 2: /* - */
+ VpSetInf(c,-VpGetSign(b));
+ break;
+ case 3: /* * */
+ if(VpIsZero(a)) {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ VpSetInf(c,VpGetSign(a)*VpGetSign(b));
+ break;
+ case 4: /* / */
+ VpSetZero(c,VpGetSign(a)*VpGetSign(b));
+ }
+ goto Inf;
+ }
+ return 1; /* Results OK */
+
+Inf:
+ return VpException(VP_EXCEPTION_INFINITY,"Computation results to 'Infinity'",0);
+NaN:
+ return VpException(VP_EXCEPTION_NaN,"Computation results to 'NaN'",0);
+}
+
+/*
+ ----------------------------------------------------------------
+*/
+
+/*
+ * returns number of chars needed to represent vp in specified format.
+ */
+VP_EXPORT U_LONG
+VpNumOfChars(Real *vp,char *pszFmt)
+{
+ S_INT ex;
+ U_LONG nc;
+
+ if(vp == NULL) return BASE_FIG*2+6;
+ if(!VpIsDef(vp)) return 32; /* not sure,may be OK */
+
+ switch(*pszFmt)
+ {
+ case 'F':
+ nc = BASE_FIG*(vp->Prec + 1)+2;
+ ex = vp->exponent;
+ if(ex<0) {
+ nc += BASE_FIG*(-ex);
+ } else {
+ if(ex > (S_INT)vp->Prec) {
+ nc += BASE_FIG*(ex - (S_INT)vp->Prec);
+ }
+ }
+ break;
+ case 'E':
+ default:
+ nc = BASE_FIG*(vp->Prec + 2)+6; /* 3: sign + exponent chars */
+ }
+ return nc;
+}
+
+/*
+ * Initializer for Vp routines and constants used.
+ * [Input]
+ * BaseVal: Base value(assigned to BASE) for Vp calculation.
+ * It must be the form BaseVal=10**n.(n=1,2,3,...)
+ * If Base <= 0L,then the BASE will be calcurated so
+ * that BASE is as large as possible satisfying the
+ * relation MaxVal <= BASE*(BASE+1). Where the value
+ * MaxVal is the largest value which can be represented
+ * by one U_LONG word(LONG) in the computer used.
+ *
+ * [Returns]
+ * DBLE_FIG ... OK
+ */
+VP_EXPORT U_LONG
+VpInit(U_LONG BaseVal)
+{
+ U_LONG w;
+ double v;
+
+ /* Setup +/- Inf NaN -0 */
+ VpGetDoubleNaN();
+ VpGetDoublePosInf();
+ VpGetDoubleNegInf();
+ VpGetDoubleNegZero();
+
+ if(BaseVal <= 0) {
+ /* Base <= 0, then determine Base by calcuration. */
+ BASE = 1;
+ while(
+ (BASE > 0) &&
+ ((w = BASE *(BASE + 1)) > BASE) &&((w / BASE) ==(BASE + 1))
+ ) {
+ BaseVal = BASE;
+ BASE = BaseVal * 10L;
+ }
+ }
+ /* Set Base Values */
+ BASE = BaseVal;
+ HALF_BASE = BASE / 2;
+ BASE1 = BASE / 10;
+ BASE_FIG = 0;
+ while(BaseVal /= 10) ++BASE_FIG;
+ /* Allocates Vp constants. */
+ VpConstOne = VpAlloc((U_LONG)1, "1");
+ VpPt5 = VpAlloc((U_LONG)1, ".5");
+
+#ifdef _DEBUG
+ gnAlloc = 0;
+#endif /* _DEBUG */
+
+ /* Determine # of digits available in one 'double'. */
+
+ v = 1.0;
+ DBLE_FIG = 0;
+ while(v + 1.0 > 1.0) {
+ ++DBLE_FIG;
+ v /= 10;
+ }
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ printf("VpInit: BaseVal = %lu\n", BaseVal);
+ printf(" BASE = %lu\n", BASE);
+ printf(" HALF_BASE = %lu\n", HALF_BASE);
+ printf(" BASE1 = %lu\n", BASE1);
+ printf(" BASE_FIG = %lu\n", BASE_FIG);
+ printf(" DBLE_FIG = %lu\n", DBLE_FIG);
+ }
+#endif /* _DEBUG */
+
+ return DBLE_FIG;
+}
+
+VP_EXPORT Real *
+VpOne()
+{
+ return VpConstOne;
+}
+
+/* If exponent overflows,then raise exception or returns 0 */
+static int
+AddExponent(Real *a,S_INT n)
+{
+ S_INT e = a->exponent;
+ S_INT m = e+n;
+ S_INT eb,mb;
+ if(e>0) {
+ if(n>0) {
+ mb = m*BASE_FIG;
+ eb = e*BASE_FIG;
+ if(mb<eb) goto overflow;
+ }
+ } else if(n<0) {
+ mb = m*BASE_FIG;
+ eb = e*BASE_FIG;
+ if(mb>eb) goto underflow;
+ }
+ a->exponent = m;
+ return 1;
+
+/* Overflow/Underflow ==> Raise exception or returns 0 */
+underflow:
+ VpSetZero(a,VpGetSign(a));
+ return VpException(VP_EXCEPTION_UNDERFLOW,"Exponent underflow",0);
+
+overflow:
+ VpSetInf(a,VpGetSign(a));
+ return VpException(VP_EXCEPTION_OVERFLOW,"Exponent overflow",0);
+}
+
+/*
+ * Allocates variable.
+ * [Input]
+ * mx ... allocation unit, if zero then mx is determined by szVal.
+ * The mx is the number of effective digits can to be stored.
+ * szVal ... value assigned(char). If szVal==NULL,then zero is assumed.
+ * If szVal[0]=='#' then Max. Prec. will not be considered(1.1.7),
+ * full precision specified by szVal is allocated.
+ *
+ * [Returns]
+ * Pointer to the newly allocated variable, or
+ * NULL be returned if memory allocation is failed,or any error.
+ */
+VP_EXPORT Real *
+VpAlloc(U_LONG mx, char *szVal)
+{
+ U_LONG i, ni, ipn, ipf, nf, ipe, ne, nalloc;
+ char v,*psz;
+ int sign=1;
+ Real *vp = NULL;
+ U_LONG mf = VpGetPrecLimit();
+
+ mx = (mx + BASE_FIG - 1) / BASE_FIG + 1; /* Determine allocation unit. */
+ if(szVal) {
+ while(ISSPACE(*szVal)) szVal++;
+ if(*szVal!='#') {
+ if(mf) {
+ mf = (mf + BASE_FIG - 1) / BASE_FIG + 2; /* Needs 1 more for div */
+ if(mx>mf) {
+ mx = mf;
+ }
+ }
+ } else {
+ ++szVal;
+ }
+ } else {
+ /* necessary to be able to store */
+ /* at least mx digits. */
+ /* szVal==NULL ==> allocate zero value. */
+ vp = (Real *) VpMemAlloc(sizeof(Real) + mx * sizeof(U_LONG));
+ /* xmalloc() alway returns(or throw interruption) */
+ vp->MaxPrec = mx; /* set max precision */
+ VpSetZero(vp,1); /* initialize vp to zero. */
+ return vp;
+ }
+
+ /* Skip all spaces */
+ psz = ALLOCA_N(char,strlen(szVal)+1);
+ i = 0;
+ ipn = 0;
+ while(psz[i]=szVal[ipn]) {
+ if(ISSPACE(szVal[ipn])) {ipn++;continue;}
+ ++i; ++ipn;
+ }
+ szVal = psz;
+
+ /* Check on Inf & NaN */
+ if(StrCmp(szVal,SZ_PINF)==0 ||
+ StrCmp(szVal,SZ_INF)==0 ) {
+ vp = (Real *) VpMemAlloc(sizeof(Real) + sizeof(U_LONG));
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetPosInf(vp);
+ return vp;
+ }
+ if(StrCmp(szVal,SZ_NINF)==0) {
+ vp = (Real *) VpMemAlloc(sizeof(Real) + sizeof(U_LONG));
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetNegInf(vp);
+ return vp;
+ }
+ if(StrCmp(szVal,SZ_NaN)==0) {
+ vp = (Real *) VpMemAlloc(sizeof(Real) + sizeof(U_LONG));
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetNaN(vp);
+ return vp;
+ }
+
+ /* check on number szVal[] */
+ ipn = i = 0;
+ if (szVal[i] == '-') {sign=-1;++i;}
+ else if(szVal[i] == '+') ++i;
+ /* Skip digits */
+ ni = 0; /* digits in mantissa */
+ while(v = szVal[i]) {
+ if(!ISDIGIT(v)) break;
+ ++i;
+ ++ni;
+ }
+ nf = 0;
+ ipf = 0;
+ ipe = 0;
+ ne = 0;
+ if(v) {
+ /* other than digit nor \0 */
+ if(szVal[i] == '.') { /* xxx. */
+ ++i;
+ ipf = i;
+ while(v = szVal[i]) { /* get fraction part. */
+ if(!ISDIGIT(v)) break;
+ ++i;
+ ++nf;
+ }
+ }
+ ipe = 0; /* Exponent */
+
+ switch(szVal[i]) {
+ case '\0': break;
+ case 'e':
+ case 'E':
+ case 'd':
+ case 'D':
+ ++i;
+ ipe = i;
+ v = szVal[i];
+ if((v == '-') ||(v == '+')) ++i;
+ while(v=szVal[i]) {
+ if(!ISDIGIT(v)) break;
+ ++i;
+ ++ne;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ nalloc =(ni + nf + BASE_FIG - 1) / BASE_FIG + 1; /* set effective allocation */
+ /* units for szVal[] */
+ if(mx <= 0) mx = 1;
+ nalloc = Max(nalloc, mx);
+ mx = nalloc;
+ vp =(Real *) VpMemAlloc(sizeof(Real) + mx * sizeof(U_LONG));
+ /* xmalloc() alway returns(or throw interruption) */
+ vp->MaxPrec = mx; /* set max precision */
+ VpSetZero(vp,sign);
+ VpCtoV(vp, &(szVal[ipn]), ni, &(szVal[ipf]), nf, &(szVal[ipe]), ne);
+ return vp;
+}
+
+/*
+ * Assignment(c=a).
+ * [Input]
+ * a ... RHSV
+ * isw ... switch for assignment.
+ * c = a when isw > 0
+ * c = -a when isw < 0
+ * if c->MaxPrec < a->Prec,then round operation
+ * will be performed.
+ * [Output]
+ * c ... LHSV
+ */
+VP_EXPORT int
+VpAsgn(Real *c, Real *a, int isw)
+{
+ U_LONG n;
+ if(VpIsNaN(a)) {
+ VpSetNaN(c);
+ return 0;
+ }
+ if(VpIsInf(a)) {
+ VpSetInf(c,isw*VpGetSign(a));
+ return 0;
+ }
+
+ /* check if the RHS is zero */
+ if(!VpIsZero(a)) {
+ c->exponent = a->exponent; /* store exponent */
+ VpSetSign(c,(isw*VpGetSign(a))); /* set sign */
+ n =(a->Prec < c->MaxPrec) ?(a->Prec) :(c->MaxPrec);
+ c->Prec = n;
+ memcpy(c->frac, a->frac, n * sizeof(U_LONG));
+ /* Needs round ? */
+ if(isw!=10) {
+ /* Not in ActiveRound */
+ if(c->Prec < a->Prec) {
+ VpInternalRound(c,n,(n>0)?a->frac[n-1]:0,a->frac[n]);
+ } else {
+ VpLimitRound(c,0);
+ }
+ }
+ } else {
+ /* The value of 'a' is zero. */
+ VpSetZero(c,isw*VpGetSign(a));
+ return 1;
+ }
+ return c->Prec*BASE_FIG;
+}
+
+/*
+ * c = a + b when operation = 1 or 2
+ * = a - b when operation = -1 or -2.
+ * Returns number of significant digits of c
+ */
+VP_EXPORT int
+VpAddSub(Real *c, Real *a, Real *b, int operation)
+{
+ S_INT sw, isw;
+ Real *a_ptr, *b_ptr;
+ U_LONG n, na, nb, i;
+ U_LONG mrv;
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpAddSub(enter) a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ printf(" operation=%d\n", operation);
+ }
+#endif /* _DEBUG */
+
+ if(!VpIsDefOP(c,a,b,(operation>0)?1:2)) return 0; /* No significant digits */
+
+ /* check if a or b is zero */
+ if(VpIsZero(a)) {
+ /* a is zero,then assign b to c */
+ if(!VpIsZero(b)) {
+ VpAsgn(c, b, operation);
+ } else {
+ /* Both a and b are zero. */
+ if(VpGetSign(a)<0 && operation*VpGetSign(b)<0) {
+ /* -0 -0 */
+ VpSetZero(c,-1);
+ } else {
+ VpSetZero(c,1);
+ }
+ return 1; /* 0: 1 significant digits */
+ }
+ return c->Prec*BASE_FIG;
+ }
+ if(VpIsZero(b)) {
+ /* b is zero,then assign a to c. */
+ VpAsgn(c, a, 1);
+ return c->Prec*BASE_FIG;
+ }
+
+ if(operation < 0) sw = -1;
+ else sw = 1;
+
+ /* compare absolute value. As a result,|a_ptr|>=|b_ptr| */
+ if(a->exponent > b->exponent) {
+ a_ptr = a;
+ b_ptr = b;
+ } /* |a|>|b| */
+ else if(a->exponent < b->exponent) {
+ a_ptr = b;
+ b_ptr = a;
+ } /* |a|<|b| */
+ else {
+ /* Exponent part of a and b is the same,then compare fraction */
+ /* part */
+ na = a->Prec;
+ nb = b->Prec;
+ n = Min(na, nb);
+ for(i=0;i < n; ++i) {
+ if(a->frac[i] > b->frac[i]) {
+ a_ptr = a;
+ b_ptr = b;
+ goto end_if;
+ } else if(a->frac[i] < b->frac[i]) {
+ a_ptr = b;
+ b_ptr = a;
+ goto end_if;
+ }
+ }
+ if(na > nb) {
+ a_ptr = a;
+ b_ptr = b;
+ goto end_if;
+ } else if(na < nb) {
+ a_ptr = b;
+ b_ptr = a;
+ goto end_if;
+ }
+ /* |a| == |b| */
+ if(VpGetSign(a) + sw *VpGetSign(b) == 0) {
+ VpSetZero(c,1); /* abs(a)=abs(b) and operation = '-' */
+ return c->Prec*BASE_FIG;
+ }
+ a_ptr = a;
+ b_ptr = b;
+ }
+
+end_if:
+ isw = VpGetSign(a) + sw *VpGetSign(b);
+ /*
+ * isw = 0 ...( 1)+(-1),( 1)-( 1),(-1)+(1),(-1)-(-1)
+ * = 2 ...( 1)+( 1),( 1)-(-1)
+ * =-2 ...(-1)+(-1),(-1)-( 1)
+ * If isw==0, then c =(Sign a_ptr)(|a_ptr|-|b_ptr|)
+ * else c =(Sign ofisw)(|a_ptr|+|b_ptr|)
+ */
+ if(isw) { /* addition */
+ VpSetSign(c,(S_INT)1);
+ mrv = VpAddAbs(a_ptr, b_ptr, c);
+ VpSetSign(c,isw / 2);
+ } else { /* subtraction */
+ VpSetSign(c,(S_INT)1);
+ mrv = VpSubAbs(a_ptr, b_ptr, c);
+ if(a_ptr == a) {
+ VpSetSign(c,VpGetSign(a));
+ } else {
+ VpSetSign(c,VpGetSign(a_ptr) * sw);
+ }
+ }
+ VpInternalRound(c,0,(c->Prec>0)?c->frac[c->Prec-1]:0,mrv);
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpAddSub(result) c=% \n", c);
+ VPrint(stdout, " a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ printf(" operation=%d\n", operation);
+ }
+#endif /* _DEBUG */
+ return c->Prec*BASE_FIG;
+}
+
+/*
+ * Addition of two variable precisional variables
+ * a and b assuming abs(a)>abs(b).
+ * c = abs(a) + abs(b) ; where |a|>=|b|
+ */
+static U_LONG
+VpAddAbs(Real *a, Real *b, Real *c)
+{
+ U_LONG word_shift;
+ U_LONG carry;
+ U_LONG ap;
+ U_LONG bp;
+ U_LONG cp;
+ U_LONG a_pos;
+ U_LONG b_pos;
+ U_LONG c_pos;
+ U_LONG av, bv, mrv;
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpAddAbs called: a = %\n", a);
+ VPrint(stdout, " b = %\n", b);
+ }
+#endif /* _DEBUG */
+
+ word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv);
+ a_pos = ap;
+ b_pos = bp;
+ c_pos = cp;
+ if(word_shift==-1L) return 0; /* Overflow */
+ if(b_pos == -1L) goto Assign_a;
+
+ mrv = av + bv; /* Most right val. Used for round. */
+
+ /* Just assign the last few digits of b to c because a has no */
+ /* corresponding digits to be added. */
+ while(b_pos + word_shift > a_pos) {
+ --c_pos;
+ if(b_pos > 0) {
+ c->frac[c_pos] = b->frac[--b_pos];
+ } else {
+ --word_shift;
+ c->frac[c_pos] = 0;
+ }
+ }
+
+ /* Just assign the last few digits of a to c because b has no */
+ /* corresponding digits to be added. */
+ bv = b_pos + word_shift;
+ while(a_pos > bv) {
+ c->frac[--c_pos] = a->frac[--a_pos];
+ }
+ carry = 0; /* set first carry be zero */
+
+ /* Now perform addition until every digits of b will be */
+ /* exhausted. */
+ while(b_pos > 0) {
+ c->frac[--c_pos] = a->frac[--a_pos] + b->frac[--b_pos] + carry;
+ if(c->frac[c_pos] >= BASE) {
+ c->frac[c_pos] -= BASE;
+ carry = 1;
+ } else {
+ carry = 0;
+ }
+ }
+
+ /* Just assign the first few digits of a with considering */
+ /* the carry obtained so far because b has been exhausted. */
+ while(a_pos > 0) {
+ c->frac[--c_pos] = a->frac[--a_pos] + carry;
+ if(c->frac[c_pos] >= BASE) {
+ c->frac[c_pos] -= BASE;
+ carry = 1;
+ } else {
+ carry = 0;
+ }
+ }
+ if(c_pos) c->frac[c_pos - 1] += carry;
+ goto Exit;
+
+Assign_a:
+ VpAsgn(c, a, 1);
+ mrv = 0;
+
+Exit:
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpAddAbs exit: c=% \n", c);
+ }
+#endif /* _DEBUG */
+ return mrv;
+}
+
+/*
+ * c = abs(a) - abs(b)
+ */
+static U_LONG
+VpSubAbs(Real *a, Real *b, Real *c)
+{
+ U_LONG word_shift;
+ U_LONG mrv;
+ U_LONG borrow;
+ U_LONG ap;
+ U_LONG bp;
+ U_LONG cp;
+ U_LONG a_pos;
+ U_LONG b_pos;
+ U_LONG c_pos;
+ U_LONG av, bv;
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpSubAbs called: a = %\n", a);
+ VPrint(stdout, " b = %\n", b);
+ }
+#endif /* _DEBUG */
+
+ word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv);
+ a_pos = ap;
+ b_pos = bp;
+ c_pos = cp;
+ if(word_shift==-1L) return 0; /* Overflow */
+ if(b_pos == -1L) goto Assign_a;
+
+ if(av >= bv) {
+ mrv = av - bv;
+ borrow = 0;
+ } else {
+ mrv = 0;
+ borrow = 1;
+ }
+
+ /* Just assign the values which are the BASE subtracted by */
+ /* each of the last few digits of the b because the a has no */
+ /* corresponding digits to be subtracted. */
+ if(b_pos + word_shift > a_pos) {
+ while(b_pos + word_shift > a_pos) {
+ --c_pos;
+ if(b_pos > 0) {
+ c->frac[c_pos] = BASE - b->frac[--b_pos] - borrow;
+ } else {
+ --word_shift;
+ c->frac[c_pos] = BASE - borrow;
+ }
+ borrow = 1;
+ }
+ }
+ /* Just assign the last few digits of a to c because b has no */
+ /* corresponding digits to subtract. */
+
+ bv = b_pos + word_shift;
+ while(a_pos > bv) {
+ c->frac[--c_pos] = a->frac[--a_pos];
+ }
+
+ /* Now perform subtraction until every digits of b will be */
+ /* exhausted. */
+ while(b_pos > 0) {
+ --c_pos;
+ if(a->frac[--a_pos] < b->frac[--b_pos] + borrow) {
+ c->frac[c_pos] = BASE + a->frac[a_pos] - b->frac[b_pos] - borrow;
+ borrow = 1;
+ } else {
+ c->frac[c_pos] = a->frac[a_pos] - b->frac[b_pos] - borrow;
+ borrow = 0;
+ }
+ }
+
+ /* Just assign the first few digits of a with considering */
+ /* the borrow obtained so far because b has been exhausted. */
+ while(a_pos > 0) {
+ --c_pos;
+ if(a->frac[--a_pos] < borrow) {
+ c->frac[c_pos] = BASE + a->frac[a_pos] - borrow;
+ borrow = 1;
+ } else {
+ c->frac[c_pos] = a->frac[a_pos] - borrow;
+ borrow = 0;
+ }
+ }
+ if(c_pos) c->frac[c_pos - 1] -= borrow;
+ goto Exit;
+
+Assign_a:
+ VpAsgn(c, a, 1);
+ mrv = 0;
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpSubAbs exit: c=% \n", c);
+ }
+#endif /* _DEBUG */
+ return mrv;
+}
+
+/*
+ * Note: If(av+bv)>= HALF_BASE,then 1 will be added to the least significant
+ * digit of c(In case of addition).
+ * ------------------------- figure of output -----------------------------------
+ * a = xxxxxxxxxxx
+ * b = xxxxxxxxxx
+ * c =xxxxxxxxxxxxxxx
+ * word_shift = | |
+ * right_word = | | (Total digits in RHSV)
+ * left_word = | | (Total digits in LHSV)
+ * a_pos = |
+ * b_pos = |
+ * c_pos = |
+ */
+static U_LONG
+VpSetPTR(Real *a, Real *b, Real *c, U_LONG *a_pos, U_LONG *b_pos, U_LONG *c_pos, U_LONG *av, U_LONG *bv)
+{
+ U_LONG left_word, right_word, word_shift;
+ c->frac[0] = 0;
+ *av = *bv = 0;
+ word_shift =((a->exponent) -(b->exponent));
+ left_word = b->Prec + word_shift;
+ right_word = Max((a->Prec),left_word);
+ left_word =(c->MaxPrec) - 1; /* -1 ... prepare for round up */
+ /*
+ * check if 'round' is needed.
+ */
+ if(right_word > left_word) { /* round ? */
+ /*---------------------------------
+ * Actual size of a = xxxxxxAxx
+ * Actual size of b = xxxBxxxxx
+ * Max. size of c = xxxxxx
+ * Round off = |-----|
+ * c_pos = |
+ * right_word = |
+ * a_pos = |
+ */
+ *c_pos = right_word = left_word + 1; /* Set resulting precision */
+ /* be equal to that of c */
+ if((a->Prec) >=(c->MaxPrec)) {
+ /*
+ * a = xxxxxxAxxx
+ * c = xxxxxx
+ * a_pos = |
+ */
+ *a_pos = left_word;
+ *av = a->frac[*a_pos]; /* av is 'A' shown in above. */
+ } else {
+ /*
+ * a = xxxxxxx
+ * c = xxxxxxxxxx
+ * a_pos = |
+ */
+ *a_pos = a->Prec;
+ }
+ if((b->Prec + word_shift) >= c->MaxPrec) {
+ /*
+ * a = xxxxxxxxx
+ * b = xxxxxxxBxxx
+ * c = xxxxxxxxxxx
+ * b_pos = |
+ */
+ if(c->MaxPrec >=(word_shift + 1)) {
+ *b_pos = c->MaxPrec - word_shift - 1;
+ *bv = b->frac[*b_pos];
+ } else {
+ *b_pos = -1L;
+ }
+ } else {
+ /*
+ * a = xxxxxxxxxxxxxxxx
+ * b = xxxxxx
+ * c = xxxxxxxxxxxxx
+ * b_pos = |
+ */
+ *b_pos = b->Prec;
+ }
+ } else { /* The MaxPrec of c - 1 > The Prec of a + b */
+ /*
+ * a = xxxxxxx
+ * b = xxxxxx
+ * c = xxxxxxxxxxx
+ * c_pos = |
+ */
+ *b_pos = b->Prec;
+ *a_pos = a->Prec;
+ *c_pos = right_word + 1;
+ }
+ c->Prec = *c_pos;
+ c->exponent = a->exponent;
+ if(!AddExponent(c,(S_LONG)1)) return (-1L);
+ return word_shift;
+}
+
+/*
+ * Return number og significant digits
+ * c = a * b , Where a = a0a1a2 ... an
+ * b = b0b1b2 ... bm
+ * c = c0c1c2 ... cl
+ * a0 a1 ... an * bm
+ * a0 a1 ... an * bm-1
+ * . . .
+ * . . .
+ * a0 a1 .... an * b0
+ * +_____________________________
+ * c0 c1 c2 ...... cl
+ * nc <---|
+ * MaxAB |--------------------|
+ */
+VP_EXPORT int
+VpMult(Real *c, Real *a, Real *b)
+{
+ U_LONG MxIndA, MxIndB, MxIndAB, MxIndC;
+ U_LONG ind_c, i, ii, nc;
+ U_LONG ind_as, ind_ae, ind_bs, ind_be;
+ U_LONG Carry, s;
+ Real *w;
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpMult(Enter): a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ }
+#endif /* _DEBUG */
+
+ if(!VpIsDefOP(c,a,b,3)) return 0; /* No significant digit */
+
+ if(VpIsZero(a) || VpIsZero(b)) {
+ /* at least a or b is zero */
+ VpSetZero(c,VpGetSign(a)*VpGetSign(b));
+ return 1; /* 0: 1 significant digit */
+ }
+
+ if(VpIsOne(a)) {
+ VpAsgn(c, b, VpGetSign(a));
+ goto Exit;
+ }
+ if(VpIsOne(b)) {
+ VpAsgn(c, a, VpGetSign(b));
+ goto Exit;
+ }
+ if((b->Prec) >(a->Prec)) {
+ /* Adjust so that digits(a)>digits(b) */
+ w = a;
+ a = b;
+ b = w;
+ }
+ w = NULL;
+ MxIndA = a->Prec - 1;
+ MxIndB = b->Prec - 1;
+ MxIndC = c->MaxPrec - 1;
+ MxIndAB = a->Prec + b->Prec - 1;
+
+ if(MxIndC < MxIndAB) { /* The Max. prec. of c < Prec(a)+Prec(b) */
+ w = c;
+ c = VpAlloc((U_LONG)((MxIndAB + 1) * BASE_FIG), "#0");
+ MxIndC = MxIndAB;
+ }
+
+ /* set LHSV c info */
+
+ c->exponent = a->exponent; /* set exponent */
+ if(!AddExponent(c,b->exponent)) return 0;
+ VpSetSign(c,VpGetSign(a)*VpGetSign(b)); /* set sign */
+ Carry = 0;
+ nc = ind_c = MxIndAB;
+ memset(c->frac, 0, (nc + 1) * sizeof(U_LONG)); /* Initialize c */
+ c->Prec = nc + 1; /* set precision */
+ for(nc = 0; nc < MxIndAB; ++nc, --ind_c) {
+ if(nc < MxIndB) { /* The left triangle of the Fig. */
+ ind_as = MxIndA - nc;
+ ind_ae = MxIndA;
+ ind_bs = MxIndB;
+ ind_be = MxIndB - nc;
+ } else if(nc <= MxIndA) { /* The middle rectangular of the Fig. */
+ ind_as = MxIndA - nc;
+ ind_ae = MxIndA -(nc - MxIndB);
+ ind_bs = MxIndB;
+ ind_be = 0;
+ } else if(nc > MxIndA) { /* The right triangle of the Fig. */
+ ind_as = 0;
+ ind_ae = MxIndAB - nc - 1;
+ ind_bs = MxIndB -(nc - MxIndA);
+ ind_be = 0;
+ }
+
+ for(i = ind_as; i <= ind_ae; ++i) {
+ s =((a->frac[i]) *(b->frac[ind_bs--]));
+ Carry = s / BASE;
+ s = s -(Carry * BASE);
+ c->frac[ind_c] += s;
+ if(c->frac[ind_c] >= BASE) {
+ s = c->frac[ind_c] / BASE;
+ Carry += s;
+ c->frac[ind_c] -= (s * BASE);
+ }
+ if(Carry) {
+ ii = ind_c;
+ while((--ii) >= 0) {
+ c->frac[ii] += Carry;
+ if(c->frac[ii] >= BASE) {
+ Carry = c->frac[ii] / BASE;
+ c->frac[ii] -=(Carry * BASE);
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ if(w != NULL) { /* free work variable */
+ VpNmlz(c);
+ VpAsgn(w, c, 1);
+ VpFree(c);
+ c = w;
+ } else {
+ VpLimitRound(c,0);
+ }
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpMult(c=a*b): c=% \n", c);
+ VPrint(stdout, " a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ }
+#endif /*_DEBUG */
+ return c->Prec*BASE_FIG;
+}
+
+/*
+ * c = a / b, remainder = r
+ */
+VP_EXPORT int
+VpDivd(Real *c, Real *r, Real *a, Real *b)
+{
+ U_LONG word_a, word_b, word_c, word_r;
+ U_LONG i, n, ind_a, ind_b, ind_c, ind_r;
+ U_LONG nLoop;
+ U_LONG q, b1, b1p1, b1b2, b1b2p1, r1r2;
+ U_LONG borrow, borrow1, borrow2, qb;
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, " VpDivd(c=a/b) a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ }
+#endif /*_DEBUG */
+
+ VpSetNaN(r);
+ if(!VpIsDefOP(c,a,b,4)) goto Exit;
+ if(VpIsZero(a)&&VpIsZero(b)) {
+ VpSetNaN(c);
+ return VpException(VP_EXCEPTION_NaN,"(VpDivd) 0/0 not defined(NaN)",0);
+ }
+ if(VpIsZero(b)) {
+ VpSetInf(c,VpGetSign(a)*VpGetSign(b));
+ return VpException(VP_EXCEPTION_ZERODIVIDE,"(VpDivd) Divide by zero",0);
+ }
+ if(VpIsZero(a)) {
+ /* numerator a is zero */
+ VpSetZero(c,VpGetSign(a)*VpGetSign(b));
+ VpSetZero(r,VpGetSign(a)*VpGetSign(b));
+ goto Exit;
+ }
+ if(VpIsOne(b)) {
+ /* divide by one */
+ VpAsgn(c, a, VpGetSign(b));
+ VpSetZero(r,VpGetSign(a));
+ goto Exit;
+ }
+
+ word_a = a->Prec;
+ word_b = b->Prec;
+ word_c = c->MaxPrec;
+ word_r = r->MaxPrec;
+
+ ind_c = 0;
+ ind_r = 1;
+
+ if(word_a >= word_r) goto space_error;
+
+ r->frac[0] = 0;
+ while(ind_r <= word_a) {
+ r->frac[ind_r] = a->frac[ind_r - 1];
+ ++ind_r;
+ }
+
+ while(ind_r < word_r) r->frac[ind_r++] = 0;
+ while(ind_c < word_c) c->frac[ind_c++] = 0;
+
+ /* initial procedure */
+ b1 = b1p1 = b->frac[0];
+ if(b->Prec <= 1) {
+ b1b2p1 = b1b2 = b1p1 * BASE;
+ } else {
+ b1p1 = b1 + 1;
+ b1b2p1 = b1b2 = b1 * BASE + b->frac[1];
+ if(b->Prec > 2) ++b1b2p1;
+ }
+
+ /* */
+ /* loop start */
+ ind_c = word_r - 1;
+ nLoop = Min(word_c,ind_c);
+ ind_c = 1;
+ while(ind_c < nLoop) {
+ if(r->frac[ind_c] == 0) {
+ ++ind_c;
+ continue;
+ }
+ r1r2 = r->frac[ind_c] * BASE + r->frac[ind_c + 1];
+ if(r1r2 == b1b2) {
+ /* The first two word digits is the same */
+ ind_b = 2;
+ ind_a = ind_c + 2;
+ while(ind_b < word_b) {
+ if(r->frac[ind_a] < b->frac[ind_b]) goto div_b1p1;
+ if(r->frac[ind_a] > b->frac[ind_b]) break;
+ ++ind_a;
+ ++ind_b;
+ }
+ /* The first few word digits of r and b is the same and */
+ /* the first different word digit of w is greater than that */
+ /* of b, so quotinet is 1 and just subtract b from r. */
+ borrow = 0; /* quotient=1, then just r-b */
+ ind_b = b->Prec - 1;
+ ind_r = ind_c + ind_b;
+ if(ind_r >= word_r) goto space_error;
+ n = ind_b;
+ for(i = 0; i <= n; ++i) {
+ if(r->frac[ind_r] < b->frac[ind_b] + borrow) {
+ r->frac[ind_r] +=(BASE -(b->frac[ind_b] + borrow));
+ borrow = 1;
+ } else {
+ r->frac[ind_r] = r->frac[ind_r] - b->frac[ind_b] - borrow;
+ borrow = 0;
+ }
+ --ind_r;
+ --ind_b;
+ }
+ ++(c->frac[ind_c]);
+ goto carry;
+ }
+ /* The first two word digits is not the same, */
+ /* then compare magnitude, and divide actually. */
+ if(r1r2 >= b1b2p1) {
+ q = r1r2 / b1b2p1;
+ c->frac[ind_c] += q;
+ ind_r = b->Prec + ind_c - 1;
+ goto sub_mult;
+ }
+
+div_b1p1:
+ if(ind_c + 1 >= word_c) goto out_side;
+ q = r1r2 / b1p1;
+ c->frac[ind_c + 1] += q;
+ ind_r = b->Prec + ind_c;
+
+sub_mult:
+ borrow1 = borrow2 = 0;
+ ind_b = word_b - 1;
+ if(ind_r >= word_r) goto space_error;
+ n = ind_b;
+ for(i = 0; i <= n; ++i) {
+ /* now, perform r = r - q * b */
+ qb = q *(b->frac[ind_b]);
+ if(qb < BASE) borrow1 = 0;
+ else {
+ borrow1 = qb / BASE;
+ qb = qb - borrow1 * BASE;
+ }
+ if(r->frac[ind_r] < qb) {
+ r->frac[ind_r] +=(BASE - qb);
+ borrow2 = borrow2 + borrow1 + 1;
+ } else {
+ r->frac[ind_r] -= qb;
+ borrow2 += borrow1;
+ }
+ if(borrow2) {
+ if(r->frac[ind_r - 1] < borrow2) {
+ r->frac[ind_r - 1] +=(BASE - borrow2);
+ borrow2 = 1;
+ } else {
+ r->frac[ind_r - 1] -= borrow2;
+ borrow2 = 0;
+ }
+ }
+ --ind_r;
+ --ind_b;
+ }
+
+ r->frac[ind_r] -= borrow2;
+carry:
+ ind_r = ind_c;
+ while(c->frac[ind_r] >= BASE) {
+ c->frac[ind_r] -= BASE;
+ --ind_r;
+ ++(c->frac[ind_r]);
+ }
+ }
+ /* End of operation, now final arrangement */
+out_side:
+ c->Prec = word_c;
+ c->exponent = a->exponent;
+ if(!AddExponent(c,(S_LONG)2)) return 0;
+ if(!AddExponent(c,-(b->exponent))) return 0;
+
+ VpSetSign(c,VpGetSign(a)*VpGetSign(b));
+ VpNmlz(c); /* normalize c */
+ r->Prec = word_r;
+ r->exponent = a->exponent;
+ if(!AddExponent(r,(S_LONG)1)) return 0;
+ VpSetSign(r,VpGetSign(a));
+ VpNmlz(r); /* normalize r(remainder) */
+ goto Exit;
+
+space_error:
+#ifdef _DEBUG
+ if(gfDebug) {
+ printf(" word_a=%lu\n", word_a);
+ printf(" word_b=%lu\n", word_b);
+ printf(" word_c=%lu\n", word_c);
+ printf(" word_r=%lu\n", word_r);
+ printf(" ind_r =%lu\n", ind_r);
+ }
+#endif /* _DEBUG */
+ rb_bug("ERROR(VpDivd): space for remainder too small.");
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, " VpDivd(c=a/b), c=% \n", c);
+ VPrint(stdout, " r=% \n", r);
+ }
+#endif /* _DEBUG */
+ return c->Prec*BASE_FIG;
+}
+
+/*
+ * Input a = 00000xxxxxxxx En(5 preceeding zeros)
+ * Output a = xxxxxxxx En-5
+ */
+static int
+VpNmlz(Real *a)
+{
+ U_LONG ind_a, i;
+
+ if(!VpIsDef(a)) goto NoVal;
+ if(VpIsZero(a)) goto NoVal;
+
+ ind_a = a->Prec;
+ while(ind_a--) {
+ if(a->frac[ind_a]) {
+ a->Prec = ind_a + 1;
+ i = 0;
+ while(a->frac[i] == 0) ++i; /* skip the first few zeros */
+ if(i) {
+ a->Prec -= i;
+ if(!AddExponent(a,-((S_INT)i))) return 0;
+ memmove(&(a->frac[0]),&(a->frac[i]),(a->Prec)*sizeof(U_LONG));
+ }
+ return 1;
+ }
+ }
+ /* a is zero(no non-zero digit) */
+ VpSetZero(a,VpGetSign(a));
+ return 0;
+
+NoVal:
+ a->frac[0] = 0;
+ a->Prec=1;
+ return 0;
+}
+
+/*
+ * VpComp = 0 ... if a=b,
+ * Pos ... a>b,
+ * Neg ... a<b.
+ * 999 ... result undefined(NaN)
+ */
+VP_EXPORT int
+VpComp(Real *a, Real *b)
+{
+ int val;
+ U_LONG mx, ind;
+ int e;
+ val = 0;
+ if(VpIsNaN(a)||VpIsNaN(b)) return 999;
+ if(!VpIsDef(a)) {
+ if(!VpIsDef(b)) e = a->sign - b->sign;
+ else e = a->sign;
+ if(e>0) return 1;
+ else if(e<0) return -1;
+ else return 0;
+ }
+ if(!VpIsDef(b)) {
+ e = -b->sign;
+ if(e>0) return 1;
+ else return -1;
+ }
+ /* Zero check */
+ if(VpIsZero(a)) {
+ if(VpIsZero(b)) return 0; /* both zero */
+ val = -VpGetSign(b);
+ goto Exit;
+ }
+ if(VpIsZero(b)) {
+ val = VpGetSign(a);
+ goto Exit;
+ }
+
+ /* compare sign */
+ if(VpGetSign(a) > VpGetSign(b)) {
+ val = 1; /* a>b */
+ goto Exit;
+ }
+ if(VpGetSign(a) < VpGetSign(b)) {
+ val = -1; /* a<b */
+ goto Exit;
+ }
+
+ /* a and b have same sign, && signe!=0,then compare exponent */
+ if((a->exponent) >(b->exponent)) {
+ val = VpGetSign(a);
+ goto Exit;
+ }
+ if((a->exponent) <(b->exponent)) {
+ val = -VpGetSign(b);
+ goto Exit;
+ }
+
+ /* a and b have same exponent, then compare significand. */
+ mx =((a->Prec) <(b->Prec)) ?(a->Prec) :(b->Prec);
+ ind = 0;
+ while(ind < mx) {
+ if((a->frac[ind]) >(b->frac[ind])) {
+ val = VpGetSign(a);
+ goto Exit;
+ }
+ if((a->frac[ind]) <(b->frac[ind])) {
+ val = -VpGetSign(b);
+ goto Exit;
+ }
+ ++ind;
+ }
+ if((a->Prec) >(b->Prec)) {
+ val = VpGetSign(a);
+ } else if((a->Prec) <(b->Prec)) {
+ val = -VpGetSign(b);
+ }
+
+Exit:
+ if (val> 1) val = 1;
+ else if(val<-1) val = -1;
+
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, " VpComp a=%\n", a);
+ VPrint(stdout, " b=%\n", b);
+ printf(" ans=%d\n", val);
+ }
+#endif /* _DEBUG */
+ return (int)val;
+}
+
+#ifdef _DEBUG
+/*
+ * cntl_chr ... ASCIIZ Character, print control characters
+ * Available control codes:
+ * % ... VP variable. To print '%', use '%%'.
+ * \n ... new line
+ * \b ... backspace
+ * ... tab
+ * Note: % must must not appear more than once
+ * a ... VP variable to be printed
+ */
+VP_EXPORT int
+VPrint(FILE *fp, char *cntl_chr, Real *a)
+{
+ U_LONG i, j, nc, nd, ZeroSup;
+ U_LONG n, m, e, nn;
+
+ /* Check if NaN & Inf. */
+ if(VpIsNaN(a)) {
+ fprintf(fp,SZ_NaN);
+ return 8;
+ }
+ if(VpIsPosInf(a)) {
+ fprintf(fp,SZ_INF);
+ return 8;
+ }
+ if(VpIsNegInf(a)) {
+ fprintf(fp,SZ_NINF);
+ return 9;
+ }
+ if(VpIsZero(a)) {
+ fprintf(fp,"0.0");
+ return 3;
+ }
+
+ j = 0;
+ nd = nc = 0; /* nd : number of digits in fraction part(every 10 digits, */
+ /* nd<=10). */
+ /* nc : number of caracters printed */
+ ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
+ while(*(cntl_chr + j)) {
+ if((*(cntl_chr + j) == '%') &&(*(cntl_chr + j + 1) != '%')) {
+ nc = 0;
+ if(!VpIsZero(a)) {
+ if(VpGetSign(a) < 0) {
+ fprintf(fp, "-");
+ ++nc;
+ }
+ nc += fprintf(fp, "0.");
+ n = a->Prec;
+ for(i=0;i < n;++i) {
+ m = BASE1;
+ e = a->frac[i];
+ while(m) {
+ nn = e / m;
+ if((!ZeroSup) || nn) {
+ nc += fprintf(fp, "%lu", nn); /* The reading zero(s) */
+ /* as 0.00xx will not */
+ /* be printed. */
+ ++nd;
+ ZeroSup = 0; /* Set to print succeeding zeros */
+ }
+ if(nd >= 10) { /* print ' ' after every 10 digits */
+ nd = 0;
+ nc += fprintf(fp, " ");
+ }
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ nc += fprintf(fp, "E%ld", VpExponent10(a));
+ } else {
+ nc += fprintf(fp, "0.0");
+ }
+ } else {
+ ++nc;
+ if(*(cntl_chr + j) == '\\') {
+ switch(*(cntl_chr + j + 1)) {
+ case 'n':
+ fprintf(fp, "\n");
+ ++j;
+ break;
+ case 't':
+ fprintf(fp, "\t");
+ ++j;
+ break;
+ case 'b':
+ fprintf(fp, "\n");
+ ++j;
+ break;
+ default:
+ fprintf(fp, "%c", *(cntl_chr + j));
+ break;
+ }
+ } else {
+ fprintf(fp, "%c", *(cntl_chr + j));
+ if(*(cntl_chr + j) == '%') ++j;
+ }
+ }
+ j++;
+ }
+ return (int)nc;
+}
+#endif /* _DEBUG */
+
+static void
+VpFormatSt(char *psz,S_INT fFmt)
+{
+ U_LONG ie;
+ U_LONG i;
+ S_INT nf = 0;
+ char ch;
+
+ if(fFmt<=0) return;
+
+ ie = strlen(psz);
+ for(i = 0; i < ie; ++i) {
+ ch = psz[i];
+ if(!ch) break;
+ if(ISSPACE(ch) || ch=='-' || ch=='+') continue;
+ if(ch == '.') { nf = 0;continue;}
+ if(ch == 'E') break;
+ nf++;
+ if(nf > fFmt) {
+ memmove(psz + i + 1, psz + i, ie - i + 1);
+ ++ie;
+ nf = 0;
+ psz[i] = ' ';
+ }
+ }
+}
+
+VP_EXPORT S_LONG
+VpExponent10(Real *a)
+{
+ S_LONG ex;
+ U_LONG n;
+
+ if(!VpHasVal(a)) return 0;
+
+ ex =(a->exponent) * BASE_FIG;
+ n = BASE1;
+ while((a->frac[0] / n) == 0) {
+ --ex;
+ n /= 10;
+ }
+ return ex;
+}
+
+VP_EXPORT void
+VpSzMantissa(Real *a,char *psz)
+{
+ U_LONG i, ZeroSup;
+ U_LONG n, m, e, nn;
+
+ if(VpIsNaN(a)) {
+ sprintf(psz,SZ_NaN);
+ return;
+ }
+ if(VpIsPosInf(a)) {
+ sprintf(psz,SZ_INF);
+ return;
+ }
+ if(VpIsNegInf(a)) {
+ sprintf(psz,SZ_NINF);
+ return;
+ }
+
+ ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
+ if(!VpIsZero(a)) {
+ if(VpGetSign(a) < 0) *psz++ = '-';
+ n = a->Prec;
+ for(i=0;i < n;++i) {
+ m = BASE1;
+ e = a->frac[i];
+ while(m) {
+ nn = e / m;
+ if((!ZeroSup) || nn) {
+ sprintf(psz, "%lu", nn); /* The reading zero(s) */
+ psz += strlen(psz);
+ /* as 0.00xx will be ignored. */
+ ZeroSup = 0; /* Set to print succeeding zeros */
+ }
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ *psz = 0;
+ while(psz[-1]=='0') *(--psz) = 0;
+ } else {
+ if(VpIsPosZero(a)) sprintf(psz, "0");
+ else sprintf(psz, "-0");
+ }
+}
+
+VP_EXPORT int
+VpToSpecialString(Real *a,char *psz,int fPlus)
+/* fPlus =0:default, =1: set ' ' before digits , =2: set '+' before digits. */
+{
+ if(VpIsNaN(a)) {
+ sprintf(psz,SZ_NaN);
+ return 1;
+ }
+
+ if(VpIsPosInf(a)) {
+ if(fPlus==1) {
+ *psz++ = ' ';
+ } else if(fPlus==2) {
+ *psz++ = '+';
+ }
+ sprintf(psz,SZ_INF);
+ return 1;
+ }
+ if(VpIsNegInf(a)) {
+ sprintf(psz,SZ_NINF);
+ return 1;
+ }
+ if(VpIsZero(a)) {
+ if(VpIsPosZero(a)) {
+ if(fPlus==1) sprintf(psz, " 0.0");
+ else if(fPlus==2) sprintf(psz, "+0.0");
+ else sprintf(psz, "0.0");
+ } else sprintf(psz, "-0.0");
+ return 1;
+ }
+ return 0;
+}
+
+VP_EXPORT void
+VpToString(Real *a,char *psz,int fFmt,int fPlus)
+/* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
+{
+ U_LONG i, ZeroSup;
+ U_LONG n, m, e, nn;
+ char *pszSav = psz;
+ S_LONG ex;
+
+ if(VpToSpecialString(a,psz,fPlus)) return;
+
+ ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
+
+ if(VpGetSign(a) < 0) *psz++ = '-';
+ else if(fPlus==1) *psz++ = ' ';
+ else if(fPlus==2) *psz++ = '+';
+
+ *psz++ = '0';
+ *psz++ = '.';
+ n = a->Prec;
+ for(i=0;i < n;++i) {
+ m = BASE1;
+ e = a->frac[i];
+ while(m) {
+ nn = e / m;
+ if((!ZeroSup) || nn) {
+ sprintf(psz, "%lu", nn); /* The reading zero(s) */
+ psz += strlen(psz);
+ /* as 0.00xx will be ignored. */
+ ZeroSup = 0; /* Set to print succeeding zeros */
+ }
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ ex =(a->exponent) * BASE_FIG;
+ n = BASE1;
+ while((a->frac[0] / n) == 0) {
+ --ex;
+ n /= 10;
+ }
+ while(psz[-1]=='0') *(--psz) = 0;
+ sprintf(psz, "E%ld", ex);
+ if(fFmt) VpFormatSt(pszSav, fFmt);
+}
+
+VP_EXPORT void
+VpToFString(Real *a,char *psz,int fFmt,int fPlus)
+/* fPlus =0:default,=1: set ' ' before digits ,set '+' before digits. */
+{
+ U_LONG i;
+ U_LONG n, m, e, nn;
+ char *pszSav = psz;
+ S_LONG ex;
+
+ if(VpToSpecialString(a,psz,fPlus)) return;
+
+ if(VpGetSign(a) < 0) *psz++ = '-';
+ else if(fPlus==1) *psz++ = ' ';
+ else if(fPlus==2) *psz++ = '+';
+
+ n = a->Prec;
+ ex = a->exponent;
+ if(ex<=0) {
+ *psz++ = '0';*psz++ = '.';
+ while(ex<0) {
+ for(i=0;i<BASE_FIG;++i) *psz++ = '0';
+ ++ex;
+ }
+ ex = -1;
+ }
+
+ for(i=0;i < n;++i) {
+ --ex;
+ if(i==0 && ex >= 0) {
+ sprintf(psz, "%lu", a->frac[i]);
+ psz += strlen(psz);
+ } else {
+ m = BASE1;
+ e = a->frac[i];
+ while(m) {
+ nn = e / m;
+ *psz++ = (char)(nn + '0');
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ if(ex == 0) *psz++ = '.';
+ }
+ while(--ex>=0) {
+ m = BASE;
+ while(m/=10) *psz++ = '0';
+ if(ex == 0) *psz++ = '.';
+ }
+ *psz = 0;
+ while(psz[-1]=='0') *(--psz) = 0;
+ if(psz[-1]=='.') sprintf(psz, "0");
+ if(fFmt) VpFormatSt(pszSav, fFmt);
+}
+
+/*
+ * [Output]
+ * a[] ... variable to be assigned the value.
+ * [Input]
+ * int_chr[] ... integer part(may include '+/-').
+ * ni ... number of characters in int_chr[],not including '+/-'.
+ * frac[] ... fraction part.
+ * nf ... number of characters in frac[].
+ * exp_chr[] ... exponent part(including '+/-').
+ * ne ... number of characters in exp_chr[],not including '+/-'.
+ */
+VP_EXPORT int
+VpCtoV(Real *a, char *int_chr, U_LONG ni, char *frac, U_LONG nf, char *exp_chr, U_LONG ne)
+{
+ U_LONG i, j, ind_a, ma, mi, me;
+ U_LONG loc;
+ S_INT e,es, eb, ef;
+ S_INT sign, signe;
+ /* get exponent part */
+ e = 0;
+ ma = a->MaxPrec;
+ mi = ni;
+ me = ne;
+ signe = 1;
+ memset(a->frac, 0, ma * sizeof(U_LONG));
+ if(ne > 0) {
+ i = 0;
+ if(exp_chr[0] == '-') {
+ signe = -1;
+ ++i;
+ ++me;
+ } else if(exp_chr[0] == '+') {
+ ++i;
+ ++me;
+ }
+ while(i < me) {
+ es = e*((S_INT)BASE_FIG);
+ e = e * 10 + exp_chr[i] - '0';
+ if(es>e*((S_INT)BASE_FIG)) {
+ return VpException(VP_EXCEPTION_INFINITY,"Exponent overflow",0);
+ }
+ ++i;
+ }
+ }
+
+ /* get integer part */
+ i = 0;
+ sign = 1;
+ if(ni > 0) {
+ if(int_chr[0] == '-') {
+ sign = -1;
+ ++i;
+ ++mi;
+ } else if(int_chr[0] == '+') {
+ ++i;
+ ++mi;
+ }
+ }
+
+ e = signe * e; /* e: The value of exponent part. */
+ e = e + ni; /* set actual exponent size. */
+
+ if(e > 0) signe = 1;
+ else signe = -1;
+
+ /* Adjust the exponent so that it is the multiple of BASE_FIG. */
+ j = 0;
+ ef = 1;
+ while(ef) {
+ if(e>=0) eb = e;
+ else eb = -e;
+ ef = eb / ((S_INT)BASE_FIG);
+ ef = eb - ef * ((S_INT)BASE_FIG);
+ if(ef) {
+ ++j; /* Means to add one more preceeding zero */
+ ++e;
+ }
+ }
+
+ eb = e / ((S_INT)BASE_FIG);
+
+ ind_a = 0;
+ while(i < mi) {
+ a->frac[ind_a] = 0;
+ while((j < (U_LONG)BASE_FIG) &&(i < mi)) {
+ a->frac[ind_a] = a->frac[ind_a] * 10 + int_chr[i] - '0';
+ ++j;
+ ++i;
+ }
+ if(i < mi) {
+ ++ind_a;
+ if(ind_a >= ma) goto over_flow;
+ j = 0;
+ }
+ }
+ loc = 1;
+
+ /* get fraction part */
+
+ i = 0;
+ while(i < nf) {
+ while((j < (U_LONG)BASE_FIG) &&(i < nf)) {
+ a->frac[ind_a] = a->frac[ind_a] * 10 + frac[i] - '0';
+ ++j;
+ ++i;
+ }
+ if(i < nf) {
+ ++ind_a;
+ if(ind_a >= ma) goto over_flow;
+ j = 0;
+ }
+ }
+ goto Final;
+
+over_flow:
+ rb_warn("Conversion from String to BigDecimal overflow (last few digits discarded).");
+
+Final:
+ if(ind_a >= ma) ind_a = ma - 1;
+ while(j < (U_LONG)BASE_FIG) {
+ a->frac[ind_a] = a->frac[ind_a] * 10;
+ ++j;
+ }
+ a->Prec = ind_a + 1;
+ a->exponent = eb;
+ VpSetSign(a,sign);
+ VpNmlz(a);
+ return 1;
+}
+
+/*
+ * [Input]
+ * *m ... Real
+ * [Output]
+ * *d ... fraction part of m(d = 0.xxxxxxx). where # of 'x's is fig.
+ * *e ... U_LONG,exponent of m.
+ * DBLE_FIG ... Number of digits in a double variable.
+ *
+ * m -> d*10**e, 0<d<BASE
+ * [Returns]
+ * 0 ... Zero
+ * 1 ... Normal
+ * 2 ... Infinity
+ * -1 ... NaN
+ */
+VP_EXPORT int
+VpVtoD(double *d, S_LONG *e, Real *m)
+{
+ U_LONG ind_m, mm, fig;
+ double div;
+ int f = 1;
+
+ if(VpIsNaN(m)) {
+ *d = VpGetDoubleNaN();
+ *e = 0;
+ f = -1; /* NaN */
+ goto Exit;
+ } else
+ if(VpIsPosZero(m)) {
+ *d = 0.0;
+ *e = 0;
+ f = 0;
+ goto Exit;
+ } else
+ if(VpIsNegZero(m)) {
+ *d = VpGetDoubleNegZero();
+ *e = 0;
+ f = 0;
+ goto Exit;
+ } else
+ if(VpIsPosInf(m)) {
+ *d = VpGetDoublePosInf();
+ *e = 0;
+ f = 2;
+ goto Exit;
+ } else
+ if(VpIsNegInf(m)) {
+ *d = VpGetDoubleNegInf();
+ *e = 0;
+ f = 2;
+ goto Exit;
+ }
+ /* Normal number */
+ fig =(DBLE_FIG + BASE_FIG - 1) / BASE_FIG;
+ ind_m = 0;
+ mm = Min(fig,(m->Prec));
+ *d = 0.0;
+ div = 1.;
+ while(ind_m < mm) {
+ div /=(double)((S_INT)BASE);
+ *d = *d +((double) ((S_INT)m->frac[ind_m++])) * div;
+ }
+ *e = m->exponent * ((S_INT)BASE_FIG);
+ *d *= VpGetSign(m);
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, " VpVtoD: m=%\n", m);
+ printf(" d=%e * 10 **%ld\n", *d, *e);
+ printf(" DBLE_FIG = %ld\n", DBLE_FIG);
+ }
+#endif /*_DEBUG */
+ return f;
+}
+
+/*
+ * m <- d
+ */
+VP_EXPORT void
+VpDtoV(Real *m, double d)
+{
+ U_LONG i, ind_m, mm;
+ U_LONG ne;
+ double val, val2;
+
+ if(isnan(d)) {
+ VpSetNaN(m);
+ goto Exit;
+ }
+ if(isinf(d)) {
+ if(d>0.0) VpSetPosInf(m);
+ else VpSetNegInf(m);
+ goto Exit;
+ }
+
+ if(d == 0.0) {
+ VpSetZero(m,1);
+ goto Exit;
+ }
+ val =(d > 0.) ? d :(-d);
+ ne = 0;
+ if(val >= 1.0) {
+ while(val >= 1.0) {
+ val /=(double)((S_INT)BASE);
+ ++ne;
+ }
+ } else {
+ val2 = 1.0 /(double)((S_INT)BASE);
+ while(val < val2) {
+ val *=(double)((S_INT)BASE);
+ --ne;
+ }
+ }
+ /* Now val = 0.xxxxx*BASE**ne */
+
+ mm = m->MaxPrec;
+ memset(m->frac, 0, mm * sizeof(U_LONG));
+ for(ind_m = 0;val > 0.0 && ind_m < mm;ind_m++) {
+ val *=(double)((S_INT)BASE);
+ i =(U_LONG) val;
+ val -=(double)((S_INT)i);
+ m->frac[ind_m] = i;
+ }
+ if(ind_m >= mm) ind_m = mm - 1;
+ if(d > 0.0) {
+ VpSetSign(m, (S_INT)1);
+ } else {
+ VpSetSign(m,-(S_INT)1);
+ }
+ m->Prec = ind_m + 1;
+ m->exponent = ne;
+
+ VpInternalRound(m,0,(m->Prec>0)?m->frac[m->Prec-1]:0,
+ (U_LONG)(val*((double)((S_INT)BASE))));
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ printf("VpDtoV d=%30.30e\n", d);
+ VPrint(stdout, " m=%\n", m);
+ }
+#endif /* _DEBUG */
+ return;
+}
+
+/*
+ * m <- ival
+ */
+VP_EXPORT void
+VpItoV(Real *m, S_INT ival)
+{
+ U_LONG mm, ind_m;
+ U_LONG val, v1, v2, v;
+ int isign;
+ S_INT ne;
+
+ if(ival == 0) {
+ VpSetZero(m,1);
+ goto Exit;
+ }
+ isign = 1;
+ val = ival;
+ if(ival < 0) {
+ isign = -1;
+ val =(U_LONG)(-ival);
+ }
+ ne = 0;
+ ind_m = 0;
+ mm = m->MaxPrec;
+ while(ind_m < mm) {
+ m->frac[ind_m] = 0;
+ ++ind_m;
+ }
+ ind_m = 0;
+ while(val > 0) {
+ if(val) {
+ v1 = val;
+ v2 = 1;
+ while(v1 >= BASE) {
+ v1 /= BASE;
+ v2 *= BASE;
+ }
+ val = val - v2 * v1;
+ v = v1;
+ } else {
+ v = 0;
+ }
+ m->frac[ind_m] = v;
+ ++ind_m;
+ ++ne;
+ }
+ m->Prec = ind_m - 1;
+ m->exponent = ne;
+ VpSetSign(m,isign);
+ VpNmlz(m);
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ printf(" VpItoV i=%d\n", ival);
+ VPrint(stdout, " m=%\n", m);
+ }
+#endif /* _DEBUG */
+ return;
+}
+
+/*
+ * y = SQRT(x), y*y - x =>0
+ */
+VP_EXPORT int
+VpSqrt(Real *y, Real *x)
+{
+ Real *f = NULL;
+ Real *r = NULL;
+ S_LONG y_prec, f_prec;
+ S_LONG n;
+ S_LONG e;
+ S_LONG prec;
+ S_LONG nr;
+ double val;
+
+ /* Zero, NaN or Infinity ? */
+ if(!VpHasVal(x)) {
+ if(VpIsZero(x)||VpGetSign(x)>0) {
+ VpAsgn(y,x,1);
+ goto Exit;
+ }
+ VpSetNaN(y);
+ return VpException(VP_EXCEPTION_OP,"(VpSqrt) SQRT(NaN or negative value)",0);
+ goto Exit;
+ }
+
+ /* Negative ? */
+ if(VpGetSign(x) < 0) {
+ VpSetNaN(y);
+ return VpException(VP_EXCEPTION_OP,"(VpSqrt) SQRT(negative value)",0);
+ }
+
+ /* One ? */
+ if(VpIsOne(x)) {
+ VpSetOne(y);
+ goto Exit;
+ }
+
+ n = (S_LONG)y->MaxPrec;
+ if((S_LONG)x->MaxPrec > n) n = (S_LONG)x->MaxPrec;
+ /* allocate temporally variables */
+ f = VpAlloc(y->MaxPrec *(BASE_FIG + 2), "#1");
+ r = VpAlloc((n + n) *(BASE_FIG + 2), "#1");
+
+ nr = 0;
+ y_prec = (S_LONG)y->MaxPrec;
+ f_prec = (S_LONG)f->MaxPrec;
+
+ prec = x->exponent;
+ if(prec > 0) ++prec;
+ else --prec;
+ prec = prec - (S_LONG)y->MaxPrec;
+ VpVtoD(&val, &e, x); /* val <- x */
+ e /= ((S_LONG)BASE_FIG);
+ n = e / 2;
+ if(e - n * 2 != 0) {
+ val /=(double)((S_INT)BASE);
+ n =(e + 1) / 2;
+ }
+ VpDtoV(y, sqrt(val)); /* y <- sqrt(val) */
+ y->exponent += n;
+ n = (DBLE_FIG + BASE_FIG - 1) / BASE_FIG;
+ y->MaxPrec = (U_LONG)Min(n , y_prec);
+ f->MaxPrec = y->MaxPrec + 1;
+ n = y_prec*((S_LONG)BASE_FIG);
+ if((U_LONG)n<maxnr) n = (U_LONG)maxnr;
+ do {
+ y->MaxPrec *= 2;
+ if(y->MaxPrec > (U_LONG)y_prec) y->MaxPrec = (U_LONG)y_prec;
+ f->MaxPrec = y->MaxPrec;
+ VpDivd(f, r, x, y); /* f = x/y */
+ VpAddSub(r, f, y, -1); /* r = f - y */
+ VpMult(f, VpPt5, r); /* f = 0.5*r */
+ if(VpIsZero(f)) goto converge;
+ VpAddSub(r, f, y, 1); /* r = y + f */
+ VpAsgn(y, r, 1); /* y = r */
+ if(f->exponent <= prec) goto converge;
+ } while(++nr < n);
+ /* */
+#ifdef _DEBUG
+ if(gfDebug) {
+ printf("ERROR(VpSqrt): did not converge within %ld iterations.\n",
+ nr);
+ }
+#endif /* _DEBUG */
+ y->MaxPrec = y_prec;
+
+converge:
+ VpChangeSign(y,(S_INT)1);
+#ifdef _DEBUG
+ if(gfDebug) {
+ VpMult(r, y, y);
+ VpAddSub(f, x, r, -1);
+ printf("VpSqrt: iterations = %lu\n", nr);
+ VPrint(stdout, " y =% \n", y);
+ VPrint(stdout, " x =% \n", x);
+ VPrint(stdout, " x-y*y = % \n", f);
+ }
+#endif /* _DEBUG */
+ y->MaxPrec = y_prec;
+
+Exit:
+ VpFree(f);
+ VpFree(r);
+ return 1;
+}
+
+/*
+ *
+ * f = 0: Round off/Truncate, 1: round up, 2:ceil, 3: floor, 4: Banker's rounding
+ * nf: digit position for operation.
+ *
+ */
+VP_EXPORT int
+VpMidRound(Real *y, int f, int nf)
+/*
+ * Round reletively from the decimal point.
+ * f: rounding mode
+ * nf: digit location to round from the the decimal point.
+ */
+{
+ int n,i,ix,ioffset;
+ U_LONG v;
+ U_LONG div;
+
+ nf += y->exponent*((int)BASE_FIG);
+ /* ix: x->fraq[ix] contains round position */
+ ix = nf/(int)BASE_FIG;
+ if(ix<0 || ((U_LONG)ix)>=y->Prec) return 0; /* Unable to round */
+ ioffset = nf - ix*((int)BASE_FIG);
+
+ memset(y->frac+ix+1, 0, (y->Prec - (ix+1)) * sizeof(U_LONG));
+ v = y->frac[ix];
+ /* drop digits after pointed digit */
+ n = BASE_FIG - ioffset - 1;
+ for(i=0;i<n;++i) v /= 10;
+ div = v/10;
+ v = v - div*10;
+ switch(f) {
+ case VP_ROUND_DOWN: /* Truncate */
+ break;
+ case VP_ROUND_UP: /* Roundup */
+ if(v) ++div;
+ break;
+ case VP_ROUND_HALF_UP: /* Round half up */
+ if(v>=5) ++div;
+ break;
+ case VP_ROUND_HALF_DOWN: /* Round half down */
+ if(v>=6) ++div;
+ break;
+ case VP_ROUND_CEIL: /* ceil */
+ if(v && (VpGetSign(y)>0)) ++div;
+ break;
+ case VP_ROUND_FLOOR: /* floor */
+ if(v && (VpGetSign(y)<0)) ++div;
+ break;
+ case VP_ROUND_HALF_EVEN: /* Banker's rounding */
+ if(v>5) ++div;
+ else if(v==5) {
+ if((U_LONG)i==(BASE_FIG-1)) {
+ if(ix && (y->frac[ix-1]%2)) ++div;
+ } else {
+ if(div%2) ++div;
+ }
+ }
+ break;
+ }
+ for(i=0;i<=n;++i) div *= 10;
+ if(div>=BASE) {
+ if(ix) {
+ y->frac[ix] = 0;
+ VpRdup(y,ix);
+ } else {
+ S_INT s = VpGetSign(y);
+ VpSetOne(y);
+ VpSetSign(y,s);
+ }
+ } else {
+ y->frac[ix] = div;
+ VpNmlz(y);
+ }
+ return 1;
+}
+
+VP_EXPORT int
+VpLeftRound(Real *y, int f, int nf)
+/*
+ * Round from the left hand side of the digits.
+ */
+{
+ U_LONG v;
+ if(!VpHasVal(y)) return 0; /* Unable to round */
+ v = y->frac[0];
+ nf -= VpExponent(y)*BASE_FIG;
+ while(v=v/10) nf--;
+ nf += (BASE_FIG-1);
+ return VpMidRound(y,f,nf);
+}
+
+VP_EXPORT int
+VpActiveRound(Real *y, Real *x, int f, int nf)
+{
+ /* First,assign whole value in truncation mode */
+ if(VpAsgn(y, x, 10)<=1) return 0; /* Zero,NaN,or Infinity */
+ return VpMidRound(y,f,nf);
+}
+
+static int
+VpLimitRound(Real *c,U_LONG ixDigit)
+{
+ U_LONG ix = VpGetPrecLimit();
+ if(!VpNmlz(c)) return -1;
+ if(!ix) return 0;
+ if(!ixDigit) ixDigit = c->Prec-1;
+ if((ix+BASE_FIG-1)/BASE_FIG > ixDigit+1) return 0;
+ return VpLeftRound(c,VpGetRoundMode(),ix);
+}
+
+static void
+VpInternalRound(Real *c,int ixDigit,U_LONG vPrev,U_LONG v)
+{
+ int f = 0;
+
+ if(VpLimitRound(c,ixDigit)) return;
+ if(!v) return;
+
+ v /= BASE1;
+ switch(gfRoundMode) {
+ case VP_ROUND_DOWN:
+ break;
+ case VP_ROUND_UP:
+ if(v) f = 1;
+ break;
+ case VP_ROUND_HALF_UP:
+ if(v >= 5) f = 1;
+ break;
+ case VP_ROUND_HALF_DOWN:
+ if(v >= 6) f = 1;
+ break;
+ case VP_ROUND_CEIL: /* ceil */
+ if(v && (VpGetSign(c)>0)) f = 1;
+ break;
+ case VP_ROUND_FLOOR: /* floor */
+ if(v && (VpGetSign(c)<0)) f = 1;
+ break;
+ case VP_ROUND_HALF_EVEN: /* Banker's rounding */
+ if(v>5) f = 1;
+ else if(v==5 && vPrev%2) f = 1;
+ break;
+ }
+ if(f) {
+ VpRdup(c,ixDigit); /* round up */
+ VpNmlz(c);
+ }
+}
+
+/*
+ * Rounds up m(plus one to final digit of m).
+ */
+static int
+VpRdup(Real *m,U_LONG ind_m)
+{
+ U_LONG carry;
+
+ if(!ind_m) ind_m = m->Prec;
+
+ carry = 1;
+ while(carry > 0 && (ind_m--)) {
+ m->frac[ind_m] += carry;
+ if(m->frac[ind_m] >= BASE) m->frac[ind_m] -= BASE;
+ else carry = 0;
+ }
+ if(carry > 0) { /* Overflow,count exponent and set fraction part be 1 */
+ if(!AddExponent(m,(S_LONG)1)) return 0;
+ m->Prec = m->frac[0] = 1;
+ } else {
+ VpNmlz(m);
+ }
+ return 1;
+}
+
+/*
+ * y = x - fix(x)
+ */
+VP_EXPORT void
+VpFrac(Real *y, Real *x)
+{
+ U_LONG my, ind_y, ind_x;
+
+ if(!VpHasVal(x)) {
+ VpAsgn(y,x,1);
+ goto Exit;
+ }
+
+ if(x->exponent > 0 && (U_LONG)x->exponent >= x->Prec) {
+ VpSetZero(y,VpGetSign(x));
+ goto Exit;
+ } else if(x->exponent <= 0) {
+ VpAsgn(y, x, 1);
+ goto Exit;
+ }
+
+ y->Prec = x->Prec -(U_LONG) x->exponent;
+ y->Prec = Min(y->Prec, y->MaxPrec);
+ y->exponent = 0;
+ VpSetSign(y,VpGetSign(x));
+ ind_y = 0;
+ my = y->Prec;
+ ind_x = x->exponent;
+ while(ind_y < my) {
+ y->frac[ind_y] = x->frac[ind_x];
+ ++ind_y;
+ ++ind_x;
+ }
+ VpNmlz(y);
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpFrac y=%\n", y);
+ VPrint(stdout, " x=%\n", x);
+ }
+#endif /* _DEBUG */
+ return;
+}
+
+/*
+ * y = x ** n
+ */
+VP_EXPORT int
+VpPower(Real *y, Real *x, S_INT n)
+{
+ U_LONG s, ss;
+ S_LONG sign;
+ Real *w1 = NULL;
+ Real *w2 = NULL;
+
+ if(VpIsZero(x)) {
+ if(n==0) {
+ VpSetOne(y);
+ goto Exit;
+ }
+ sign = VpGetSign(x);
+ if(n<0) {
+ n = -n;
+ if(sign<0) sign = (n%2)?(-1):(1);
+ VpSetInf (y,sign);
+ } else {
+ if(sign<0) sign = (n%2)?(-1):(1);
+ VpSetZero(y,sign);
+ }
+ goto Exit;
+ }
+ if(!VpIsDef(x)) {
+ VpSetNaN(y); /* Not sure !!! */
+ goto Exit;
+ }
+
+ if((x->exponent == 1) &&(x->Prec == 1) &&(x->frac[0] == 1)) {
+ /* abs(x) = 1 */
+ VpSetOne(y);
+ if(VpGetSign(x) > 0) goto Exit;
+ if((n % 2) == 0) goto Exit;
+ VpSetSign(y,-(S_INT)1);
+ goto Exit;
+ }
+
+ if(n > 0) sign = 1;
+ else if(n < 0) {
+ sign = -1;
+ n = -n;
+ } else {
+ VpSetOne(y);
+ goto Exit;
+ }
+
+ /* Allocate working variables */
+
+ w1 = VpAlloc((y->MaxPrec + 2) * BASE_FIG, "#0");
+ w2 = VpAlloc((w1->MaxPrec * 2 + 1) * BASE_FIG, "#0");
+ /* calculation start */
+
+ VpAsgn(y, x, 1);
+ --n;
+ while(n > 0) {
+ VpAsgn(w1, x, 1);
+ s = 1;
+loop1: ss = s;
+ s += s;
+ if(s >(U_LONG) n) goto out_loop1;
+ VpMult(w2, w1, w1);
+ VpAsgn(w1, w2, 1);
+ goto loop1;
+out_loop1:
+ n -= ss;
+ VpMult(w2, y, w1);
+ VpAsgn(y, w2, 1);
+ }
+ if(sign < 0) {
+ VpDivd(w1, w2, VpConstOne, y);
+ VpAsgn(y, w1, 1);
+ }
+
+Exit:
+#ifdef _DEBUG
+ if(gfDebug) {
+ VPrint(stdout, "VpPower y=%\n", y);
+ VPrint(stdout, "VpPower x=%\n", x);
+ printf(" n=%d\n", n);
+ }
+#endif /* _DEBUG */
+ VpFree(w2);
+ VpFree(w1);
+ return 1;
+}
+
+#ifdef _DEBUG
+int
+VpVarCheck(Real * v)
+/*
+ * Checks the validity of the Real variable v.
+ * [Input]
+ * v ... Real *, variable to be checked.
+ * [Returns]
+ * 0 ... correct v.
+ * other ... error
+ */
+{
+ U_LONG i;
+
+ if(v->MaxPrec <= 0) {
+ printf("ERROR(VpVarCheck): Illegal Max. Precision(=%lu)\n",
+ v->MaxPrec);
+ return 1;
+ }
+ if((v->Prec <= 0) ||((v->Prec) >(v->MaxPrec))) {
+ printf("ERROR(VpVarCheck): Illegal Precision(=%lu)\n", v->Prec);
+ printf(" Max. Prec.=%lu\n", v->MaxPrec);
+ return 2;
+ }
+ for(i = 0; i < v->Prec; ++i) {
+ if((v->frac[i] >= BASE)) {
+ printf("ERROR(VpVarCheck): Illegal fraction\n");
+ printf(" Frac[%ld]=%lu\n", i, v->frac[i]);
+ printf(" Prec. =%lu\n", v->Prec);
+ printf(" Exp. =%d\n", v->exponent);
+ printf(" BASE =%lu\n", BASE);
+ return 3;
+ }
+ }
+ return 0;
+}
+#endif /* _DEBUG */
diff --git a/ext/bigdecimal/bigdecimal.def b/ext/bigdecimal/bigdecimal.def
new file mode 100644
index 0000000000..8450e164e6
--- /dev/null
+++ b/ext/bigdecimal/bigdecimal.def
@@ -0,0 +1,2 @@
+EXPORTS
+Init_bigdecimal
diff --git a/ext/bigdecimal/bigdecimal.h b/ext/bigdecimal/bigdecimal.h
new file mode 100644
index 0000000000..aabc551a76
--- /dev/null
+++ b/ext/bigdecimal/bigdecimal.h
@@ -0,0 +1,216 @@
+/*
+ *
+ * Ruby BigDecimal(Variable decimal precision) extension library.
+ *
+ * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Artistic License, as specified in the README file
+ * of this BigDecimal distribution.
+ *
+ * NOTES:
+ * 2003-03-28 V1.0 checked in.
+ *
+ */
+
+#ifndef ____BIG_DECIMAL__H____
+#define ____BIG_DECIMAL__H____
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*
+ * NaN & Infinity
+ */
+#define SZ_NaN "NaN"
+#define SZ_INF "Infinity"
+#define SZ_PINF "+Infinity"
+#define SZ_NINF "-Infinity"
+
+/*
+ * #define VP_EXPORT other than static to let VP_ routines
+ * be called from outside of this module.
+ */
+#define VP_EXPORT static
+
+#define U_LONG unsigned long
+#define S_LONG long
+#define U_INT unsigned int
+#define S_INT int
+
+/* Exception codes */
+#define VP_EXCEPTION_ALL ((unsigned short)0x00FF)
+#define VP_EXCEPTION_INFINITY ((unsigned short)0x0001)
+#define VP_EXCEPTION_NaN ((unsigned short)0x0002)
+#define VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004)
+#define VP_EXCEPTION_OVERFLOW ((unsigned short)0x0001) /* 0x0008) */
+#define VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0001) /* 0x0010) */
+
+/* Following 2 exceptions cann't controlled by user */
+#define VP_EXCEPTION_OP ((unsigned short)0x0020)
+#define VP_EXCEPTION_MEMORY ((unsigned short)0x0040)
+
+/* Computation mode */
+#define VP_ROUND_MODE ((unsigned short)0x0100)
+#define VP_ROUND_UP 1
+#define VP_ROUND_DOWN 2
+#define VP_ROUND_HALF_UP 3
+#define VP_ROUND_HALF_DOWN 4
+#define VP_ROUND_CEIL 5
+#define VP_ROUND_FLOOR 6
+#define VP_ROUND_HALF_EVEN 7
+
+#define VP_SIGN_NaN 0 /* NaN */
+#define VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */
+#define VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */
+#define VP_SIGN_POSITIVE_FINITE 2 /* Positive finite number */
+#define VP_SIGN_NEGATIVE_FINITE -2 /* Negative finite number */
+#define VP_SIGN_POSITIVE_INFINITE 3 /* Positive infinite number */
+#define VP_SIGN_NEGATIVE_INFINITE -3 /* Negative infinite number */
+
+/*
+ * VP representation
+ * r = 0.xxxxxxxxx *BASE**exponent
+ */
+typedef struct {
+ VALUE obj; /* Back pointer(VALUE) for Ruby object. */
+ U_LONG MaxPrec; /* Maximum precision size */
+ /* This is the actual size of pfrac[] */
+ /*(frac[0] to frac[MaxPrec] are available). */
+ U_LONG Prec; /* Current precision size. */
+ /* This indicates how much the. */
+ /* the array frac[] is actually used. */
+ S_INT exponent;/* Exponent part. */
+ short sign; /* Attributes of the value. */
+ /*
+ * ==0 : NaN
+ * 1 : Positive zero
+ * -1 : Negative zero
+ * 2 : Positive number
+ * -2 : Negative number
+ * 3 : Positive infinite number
+ * -3 : Negative infinite number
+ */
+ short flag; /* Not used in vp_routines,space for user. */
+ U_LONG frac[1]; /* Pointer to array of fraction part. */
+} Real;
+
+/*
+ * ------------------
+ * EXPORTables.
+ * ------------------
+ */
+
+VP_EXPORT Real *
+VpNewRbClass(U_LONG mx,char *str,VALUE klass);
+
+VP_EXPORT Real *VpCreateRbObject(U_LONG mx,char *str);
+
+VP_EXPORT U_LONG VpBaseFig(void);
+VP_EXPORT U_LONG VpDblFig(void);
+VP_EXPORT U_LONG VpBaseVal(void);
+
+/* Zero,Inf,NaN (isinf(),isnan() used to check) */
+VP_EXPORT double VpGetDoubleNaN(void);
+VP_EXPORT double VpGetDoublePosInf(void);
+VP_EXPORT double VpGetDoubleNegInf(void);
+VP_EXPORT double VpGetDoubleNegZero(void);
+
+/* These 2 functions added at v1.1.7 */
+VP_EXPORT U_LONG VpGetPrecLimit(void);
+VP_EXPORT U_LONG VpSetPrecLimit(U_LONG n);
+
+/* Round mode */
+VP_EXPORT int VpIsRoundMode(unsigned long n);
+VP_EXPORT unsigned long VpGetRoundMode(void);
+VP_EXPORT unsigned long VpSetRoundMode(unsigned long n);
+
+VP_EXPORT int VpException(unsigned short f,char *str,int always);
+VP_EXPORT int VpIsNegDoubleZero(double v);
+VP_EXPORT U_LONG VpNumOfChars(Real *vp,char *pszFmt);
+VP_EXPORT U_LONG VpInit(U_LONG BaseVal);
+VP_EXPORT void *VpMemAlloc(U_LONG mb);
+VP_EXPORT void VpFree(Real *pv);
+VP_EXPORT Real *VpAlloc(U_LONG mx, char *szVal);
+VP_EXPORT int VpAsgn(Real *c,Real *a,int isw);
+VP_EXPORT int VpAddSub(Real *c,Real *a,Real *b,int operation);
+VP_EXPORT int VpMult(Real *c,Real *a,Real *b);
+VP_EXPORT int VpDivd(Real *c,Real *r,Real *a,Real *b);
+VP_EXPORT int VpComp(Real *a,Real *b);
+VP_EXPORT S_LONG VpExponent10(Real *a);
+VP_EXPORT void VpSzMantissa(Real *a,char *psz);
+VP_EXPORT int VpToSpecialString(Real *a,char *psz,int fPlus);
+VP_EXPORT void VpToString(Real *a,char *psz,int fFmt,int fPlus);
+VP_EXPORT void VpToFString(Real *a,char *psz,int fFmt,int fPlus);
+VP_EXPORT int VpCtoV(Real *a,char *int_chr,U_LONG ni,char *frac,U_LONG nf,char *exp_chr,U_LONG ne);
+VP_EXPORT int VpVtoD(double *d,S_LONG *e,Real *m);
+VP_EXPORT void VpDtoV(Real *m,double d);
+VP_EXPORT void VpItoV(Real *m,S_INT ival);
+VP_EXPORT int VpSqrt(Real *y,Real *x);
+VP_EXPORT int VpActiveRound(Real *y,Real *x,int f,int il);
+VP_EXPORT int VpMidRound(Real *y, int f, int nf);
+VP_EXPORT int VpLeftRound(Real *y, int f, int nf);
+VP_EXPORT void VpFrac(Real *y,Real *x);
+VP_EXPORT int VpPower(Real *y,Real *x,S_INT n);
+
+/* VP constants */
+VP_EXPORT Real *VpOne();
+
+/*
+ * ------------------
+ * MACRO definitions.
+ * ------------------
+ */
+#define Abs(a) (((a)>= 0)?(a):(-(a)))
+#define Max(a, b) (((a)>(b))?(a):(b))
+#define Min(a, b) (((a)>(b))?(b):(a))
+
+#define VpMaxPrec(a) ((a)->MaxPrec)
+#define VpPrec(a) ((a)->Prec)
+#define VpGetFlag(a) ((a)->flag)
+
+/* Sign */
+
+/* VpGetSign(a) returns 1,-1 if a>0,a<0 respectively */
+#define VpGetSign(a) (((a)->sign>0)?1:(-1))
+/* Change sign of a to a>0,a<0 if s = 1,-1 respectively */
+#define VpChangeSign(a,s) {if((s)>0) (a)->sign=(short)Abs((S_LONG)(a)->sign);else (a)->sign=-(short)Abs((S_LONG)(a)->sign);}
+/* Sets sign of a to a>0,a<0 if s = 1,-1 respectively */
+#define VpSetSign(a,s) {if((s)>0) (a)->sign=(short)VP_SIGN_POSITIVE_FINITE;else (a)->sign=(short)VP_SIGN_NEGATIVE_FINITE;}
+
+/* 1 */
+#define VpSetOne(a) {(a)->frac[0]=(a)->exponent=(a)->Prec=1;(a)->sign=VP_SIGN_POSITIVE_FINITE;}
+
+/* ZEROs */
+#define VpIsPosZero(a) ((a)->sign==VP_SIGN_POSITIVE_ZERO)
+#define VpIsNegZero(a) ((a)->sign==VP_SIGN_NEGATIVE_ZERO)
+#define VpIsZero(a) (VpIsPosZero(a) || VpIsNegZero(a))
+#define VpSetPosZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_ZERO)
+#define VpSetNegZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_ZERO)
+#define VpSetZero(a,s) ( ((s)>0)?VpSetPosZero(a):VpSetNegZero(a) )
+
+/* NaN */
+#define VpIsNaN(a) ((a)->sign==VP_SIGN_NaN)
+#define VpSetNaN(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NaN)
+
+/* Infinity */
+#define VpIsPosInf(a) ((a)->sign==VP_SIGN_POSITIVE_INFINITE)
+#define VpIsNegInf(a) ((a)->sign==VP_SIGN_NEGATIVE_INFINITE)
+#define VpIsInf(a) (VpIsPosInf(a) || VpIsNegInf(a))
+#define VpIsDef(a) ( !(VpIsNaN(a)||VpIsInf(a)) )
+#define VpSetPosInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE)
+#define VpSetNegInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE)
+#define VpSetInf(a,s) ( ((s)>0)?VpSetPosInf(a):VpSetNegInf(a) )
+#define VpHasVal(a) (a->frac[0])
+#define VpIsOne(a) ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1))
+#define VpExponent(a) (a->exponent)
+#ifdef _DEBUG
+int VpVarCheck(Real * v);
+VP_EXPORT int VPrint(FILE *fp,char *cntl_chr,Real *a);
+#endif /* _DEBUG */
+
+#if defined(__cplusplus)
+} /* extern "C" { */
+#endif
+#endif /* ____BIG_DECIMAL__H____ */
diff --git a/ext/bigdecimal/bigdecimal_en.html b/ext/bigdecimal/bigdecimal_en.html
new file mode 100644
index 0000000000..02c88df43e
--- /dev/null
+++ b/ext/bigdecimal/bigdecimal_en.html
@@ -0,0 +1,797 @@
+<!-- saved from url=(0022)http://internet.e-mail -->
+<HTML>
+<HEAD>
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html">
+<style type="text/css"><!--
+body { color: #3f0f0f; background: #fefeff; margin-left: 2em; margin-right: 2em;}
+h1 { color: #ffffff; background-color: #3939AD; border-color: #FF00FF; width: 100%; border-style: solid;
+ border-top-width: 0.1em; border-bottom-width: 0.1em; border-right: none; border-left: none;
+ padding: 0.1em; font-weight: bold; font-size: 160%; text-align: center;}
+h2 { color: #00007f; background-color: #e7e7ff; border-color: #000094; width: 100%; border-style: solid; border-le ft: none; border-right: none; border-top-width: 0.1em; border-bottom-width: 0.1em; padding: 0.1em;
+ font-weight: bold; font-size: 110%;
+}
+h3 { color: #00007f; padding: 0.2em; font-size: 110%;}
+h4, h5 { color: #000000; padding: 0.2em; font-size: 100%;}
+table { margin-top: 0.2em; margin-bottom: 0.2em; margin-left: 2em; margin-right: 2em;}
+caption { color: #7f0000; font-weight: bold;}
+th { background: #e7e7ff; padding-left: 0.2em; padding-right: 0.2em;}
+td { background: #f3f7ff; padding-left: 0.2em; padding-right: 0.2em;}
+code { color: #0000df;}
+dt { margin-top: 0.2em;}
+li { margin-top: 0.2em;}
+pre
+{ BACKGROUND-COLOR: #d0d0d0; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none;
+ BORDER-RIGHT: medium none; BORDER-TOP: medium none; LINE-HEIGHT: 100%; MARGIN: 12px 12px 12px 12px;
+ PADDING-BOTTOM: 12px; PADDING-LEFT: 12px; PADDING-RIGHT: 12px; PADDING-TOP: 12px;
+ WHITE-SPACE: pre; WIDTH: 100%
+}
+--></style>
+
+<TITLE>BigDecimal:An extension library for Ruby</TITLE>
+</HEAD>
+<BODY BGCOLOR=#FFFFE0>
+<H1>BigDecimal(Variable Precision Floating Library for Ruby)</H1>
+<DIV align="right"><A HREF="./bigdecimal_ja.html">Japanese</A></DIV><BR>
+BigDecimal is an extension library for the Ruby interpreter.
+Using BigDecimal class, you can obtain any number of significant digits in computation.
+For the details about Ruby see:<BR>
+<UL>
+<LI><A HREF="http://www.ruby-lang.org/en/">http://www.ruby-lang.org/en/</A>:Official Ruby page(English).</LI>
+<LI><A HREF="http://kahori.com/ruby/ring/">http://kahori.com/ruby/ring/</A>:Mutually linked pages relating to Ruby(Japanese).
+</LI>
+</UL>
+NOTE:<BR>
+ This software is provided "AS IS" and without any express or
+ implied warranties,including,without limitation,the implied
+ warranties of merchantibility and fitness for a particular
+ purpose. For the details,see COPYING and README included in this
+ distribution.
+<BR>
+<hr>
+
+<H2>Contents</H2>
+<UL>
+<LI><A HREF="#INTRO">Introduction</LI>
+<LI><A HREF="#SPEC">Usage and methods</A></LI>
+<LI><A HREF="#UNDEF">Infinity,NaN,Zero</A></LI>
+<LI><A HREF="#STRUCT">Internal structure</A></LI>
+<LI><A HREF="#BASE">Binary or decimal number representation</A></LI>
+<LI><A HREF="#PREC">Resulting number of significant digits</A></LI>
+</UL>
+<HR>
+
+<A NAME="#INTRO">
+<H2>Introduction</H2>
+Ruby already has builtin (variable length integer number) class Bignum. Using Bignum class,you can obtain
+ any integer value in magnitude. But, variable length decimal number class is not yet built in.
+This is why I made variable length floating class BigDecimal.
+Feel free to send any comments or bug reports to me.
+<A HREF="mailto:shigeo@tinyforest.gr.jp">shigeo@tinyforest.gr.jp</A>
+I will try(but can't promise) to fix bugs reported.
+<hr>
+<H2>Installation</H2>
+The Ruby latest version can be downloaded from <A HREF="http://www.ruby-lang.org/en/">Official Ruby page</A>.
+Once decompress the downloaded Ruby archive,follow the normal installation procedures according to the
+documents included.
+
+<A NAME="#SPEC">
+<H2>Usage and methods</H2>
+Suppose you already know Ruby programming,
+to create BigDecimal objects,the program would like:<BR>
+
+<CODE><PRE>
+ require 'bigdecimal'
+ a=BigDecimal::new("0.123456789123456789")
+ b=BigDecimal("123456.78912345678",40)
+ c=a+b
+</PRE></CODE>
+
+<H3>List of methods</H3>
+In 32 bits integer system,every 4 digits(in decimal) are computed simultaneously.
+This means the number of significant digits in BigDecimal is always a multiple of 4.
+<P>
+Some more methods are available in Ruby code (not C code).
+Functions such as sin,cos ...,are in math.rb in bigdecimal directory.
+To use them,require math.rb as:
+<CODE><PRE>
+require "bigdecimal/math.rb"
+</PRE></CODE>
+For details,see the math.rb code and comments.
+Other utility methods are in util.rb.
+To use util.rb, require it as:
+<CODE><PRE>
+require "bigdecimal/util.rb"
+</PRE></CODE>
+For details,see the util.rb code.
+
+<H4><U>Class methods</U></H4>
+<UL>
+<LI><B>new</B></LI><BLOCKQUOTE>
+"new" method creates a new BigDecimal object.<BR>
+a=BigDecimal::new(s[,n]) or<BR>
+a=BigDecimal(s[,n]) or<BR>
+where:<BR>
+s: Initial value string. Spaces will be ignored. Any unrecognizable character for
+representing initial value terminates the string.<BR>
+n: Maximum number of significant digits of a. n must be a Fixnum object.
+If n is omitted or is equal to 0,then the maximum number of significant digits of a is determined from the length of s.
+Actual number of digits handled in computations are usually gretaer than n.<BR>
+n is useful when performing divisions like
+<CODE><PRE>
+BigDecimal("1") / BigDecimal("3") # => 0.3333333333 33E0
+BigDecimal("1",10) / BigDecimal("3",10) # => 0.3333333333 3333333333 33333333E0
+</PRE></CODE>
+but the resulting digits obtained may differ in future version.
+</BLOCKQUOTE>
+
+<LI><B>mode</B></LI><BLOCKQUOTE>
+f = BigDecimal.mode(s[,v])<BR>
+mode method controls BigDecimal computation. If the second argument is not given or is nil,then the value
+of current setting is returned.
+Following usage are defined.<BR>
+<P><B>[EXCEPTION control]</B><P>
+Actions when computation results NaN or Infinity can be defined as follows.
+<P>
+<BLOCKQUOTE>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_NaN,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_INFINITY,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_UNDERFLOW,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_OVERFLOW,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_ALL,flag)<BR>
+</BLOCKQUOTE>
+EXCEPTION_NaN controls the execution when computation results to NaN.<BR>
+EXCEPTION_INFINITY controls the execution when computation results to Infinity(}Infinity).<BR>
+EXCEPTION_UNDERFLOW controls the execution when computation underflows.<BR>
+EXCEPTION_OVERFLOW controls the execution when computation overflows.<BR>
+EXCEPTION_ZERODIVIDE controls the execution when zero-division occures.<BR>
+EXCEPTION_ALL controls the execution for any exception defined occures.<BR>
+If the flag is true,then the relating exception is thrown.<BR>
+No exception is thrown when the flag is false(default) and computation
+continues with the result:<BR>
+<BLOCKQUOTE>
+EXCEPTION_NaN results to NaN<BR>
+EXCEPTION_INFINITY results to +Infinity or -Infinity<BR>
+EXCEPTION_UNDERFLOW results to 0.<BR>
+EXCEPTION_OVERFLOW results to +Infinity or -Infinity<BR>
+EXCEPTION_ZERODIVIDE results to +Infinity or -Infinity<BR>
+</BLOCKQUOTE>
+EXCEPTION_INFINITY,EXCEPTION_OVERFLOW, and EXCEPTION_ZERODIVIDE are
+ currently the same.<BR>
+The return value of mode method is the value set.<BR>
+If nil is specified for the second argument,then current setting is returned.<BR>
+Suppose the return value of the mode method is f,then
+ f &amp; BigDecimal::EXCEPTION_NaN !=0 means EXCEPTION_NaN is set to on.
+<P>
+<B>[ROUND error control]</B><P>
+Rounding operation can be controlled as:
+<BLOCKQUOTE>
+f = BigDecimal::mode(BigDecimal::ROUND_MODE,flag)
+</BLOCKQUOTE>
+where flag must be one of:
+<TABLE>
+
+<TR><TD>ROUND_UP</TD><TD>round away from zero.</TD></TR>
+<TR><TD>ROUND_DOWN</TD><TD>round towards zero(truncate).</TD></TR>
+<TR><TD>ROUND_HALF_UP</TD><TD>round up if the digit &gt;= 5 otherwise truncated(default).</TD></TR>
+<TR><TD>ROUND_HALF_DOWN</TD><TD>round up if the digit &gt;= 6 otherwise truncated.</TD></TR>
+<TR><TD>ROUND_HALF_EVEN</TD><TD>round towards the even neighbor(Banker's rounding).
+<TR><TD>ROUND_CEILING</TD><TD>round towards positive infinity(ceil).</TD></TR>
+<TR><TD>ROUND_FLOOR</TD><TD>round towards negative infinity(floor).</TD></TR>
+</TABLE>
+New rounding mode is returned. If nil is specified for the second argument,then current setting is returned.<BR>
+The digit location for rounding operation can not be specified by this mode method,
+use truncate/round/ceil/floor/add/sub/mult/div mthods for each instance instead.
+</BLOCKQUOTE>
+
+<LI><B>limit[(n)]</B></LI><BLOCKQUOTE>
+Limits the maximum digits that the newly created BigDecimal objects can hold never exceed n.
+This means the rounding operation specified by BigDecimal.mode is
+performed if necessary.
+limit returns the value before set if n is nil or is not specified.
+Zero,the default value,means no upper limit.<BR>
+The limit has no more priority than instance methods such as truncate,round,ceil,floor,add,sub,mult,and div. <BR>
+mf = BigDecimal::limit(n)<BR>
+</BLOCKQUOTE>
+
+<LI><B>double_fig</B></LI><BLOCKQUOTE>
+double_fig is a class method which returns the number of digits
+the Float class can have.
+<CODE><PRE>
+ p BigDecimal::double_fig # ==> 20 (depends on the CPU etc.)
+</PRE></CODE>
+The equivalent C programs which calculates the value of
+double_fig is:
+<CODE><PRE>
+ double v = 1.0;
+ int double_fig = 0;
+ while(v + 1.0 > 1.0) {
+ ++double_fig;
+ v /= 10;
+ }
+</PRE></CODE>
+</BLOCKQUOTE>
+
+<LI><B>BASE</B></LI><BLOCKQUOTE>
+Base value used in the BigDecimal calculation.
+On 32 bits integer system,the value of BASE is 10000.<BR>
+b = BigDecimal::BASE<BR>
+</BLOCKQUOTE>
+</UL>
+
+<H4><U>Instance methods</U></H4>
+<UL>
+<LI><B>+</B></LI><BLOCKQUOTE>
+addition(c = a + b)<BR>
+For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>.
+
+</BLOCKQUOTE>
+<LI><B>-</B></LI><BLOCKQUOTE>
+subtraction (c = a - b) or negation (c = -a)<BR>
+For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>.
+
+</BLOCKQUOTE>
+<LI><B>*</B></LI><BLOCKQUOTE>
+multiplication(c = a * b)<BR>
+For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>.
+
+</BLOCKQUOTE>
+<LI><B>/</B></LI><BLOCKQUOTE>
+division(c = a / b)<BR>
+For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>.
+</BLOCKQUOTE>
+
+<LI><B>add(b,n)</B></LI><BLOCKQUOTE>
+c = a.add(b,n)<BR>
+c = a.add(b,n) performs c = a + b.<BR>
+If n is less than the actual significant digits of a + b,
+then c is rounded properly according to the BigDecimal.limit.<BR>
+If n is zero,then the result is the same as +'s.
+</BLOCKQUOTE>
+<LI><B>sub(b,n)</B></LI><BLOCKQUOTE>
+c = a.sub(b,n)<BR>
+c = a.sub(b,n) performs c = a - b.<BR>
+If n is less than the actual significant digits of a - b,
+then c is rounded properly according to the BigDecimal.limit.<BR>
+If n is zero,then the result is the same as -'s.
+
+</BLOCKQUOTE>
+<LI><B>mult(b,n)</B></LI><BLOCKQUOTE>
+c = a.mult(b,n)<BR>
+c = a.mult(b,n) performs c = a * b.<BR>
+If n is less than the actual significant digits of a * b,
+then c is rounded properly according to the BigDecimal.limit.<BR>
+If n is zero,then the result is the same as *'s.
+
+</BLOCKQUOTE>
+<LI><B>div(b[,n])</B></LI><BLOCKQUOTE>
+c = a.div(b,n)<BR>
+c = a.div(b,n) performs c = a / b.<BR>
+If n is less than the actual significant digits of a / b,
+then c is rounded properly according to the BigDecimal.limit.<BR>
+If n is zero,then the result is the same as /'s.
+If n is not given,then the result will be an integer(BigDecimal) like Float#div.
+</BLOCKQUOTE>
+
+<LI><B>fix</B></LI><BLOCKQUOTE>
+c = a.fix<BR>
+returns integer part of a.<BR>
+
+</BLOCKQUOTE>
+<LI><B>frac</B></LI><BLOCKQUOTE>
+c = a.frac<BR>
+returns fraction part of a.<BR>
+
+</BLOCKQUOTE>
+<LI><B>floor[(n)]</B></LI><BLOCKQUOTE>
+c = a.floor<BR>
+returns the maximum integer value (in BigDecimal) which is less than or equal to a.
+<CODE><PRE>
+ c = BigDecimal("1.23456").floor # ==> 1
+ c = BigDecimal("-1.23456").floor # ==> -2
+</PRE></CODE>
+
+As shown in the following example,an optional integer argument (n) specifying the position
+of the target digit can be given.<BR>
+If n> 0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
+If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
+<CODE><PRE>
+ c = BigDecimal("1.23456").floor(4) # ==> 1.2345
+ c = BigDecimal("15.23456").floor(-1) # ==> 10.0
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>ceil[(n)]</B></LI><BLOCKQUOTE>
+c = a.ceil<BR>
+returns the minimum integer value (in BigDecimal) which is greater than or equal to a.
+<CODE><PRE>
+ c = BigDecimal("1.23456").ceil # ==> 2
+ c = BigDecimal("-1.23456").ceil # ==> -1
+</PRE></CODE>
+
+As shown in the following example,an optional integer argument (n) specifying the position
+of the target digit can be given.<BR>
+If n>0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
+If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
+<CODE><PRE>
+ c = BigDecimal("1.23456").ceil(4) # ==> 1.2346
+ c = BigDecimal("15.23456").ceil(-1) # ==> 20.0
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>round[(n[,b])]</B></LI><BLOCKQUOTE>
+c = a.round<BR>
+round a to the nearest 1(default)D<BR>
+<CODE><PRE>
+ c = BigDecimal("1.23456").round # ==> 1
+ c = BigDecimal("-1.23456").round # ==> -1
+</PRE></CODE>
+The rounding operation changes according to BigDecimal::mode(BigDecimal::ROUND_MODE,flag) if specified.
+
+As shown in the following example,an optional integer argument (n) specifying the position
+of the target digit can be given.<BR>
+If n>0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
+If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
+<CODE><PRE>
+c = BigDecimal::new("1.23456").round(4) # ==> 1.2346
+c = BigDecimal::new("15.23456").round(-1) # ==> 20.0
+</PRE></CODE>
+
+Rounding operation can be specified by setting the second optional argument b with the valid ROUND_MODE.<BR>
+<CODE><PRE>
+c = BigDecimal::new("1.23456").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.234
+c = BigDecimal::new("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.234
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>truncate[(n)]</B></LI><BLOCKQUOTE>
+c = a.truncate<BR>
+truncate a to the nearest 1D<BR>
+As shown in the following example,an optional integer argument (n) specifying the position
+of the target digit can be given.<BR>
+If n>0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
+If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
+
+<CODE><PRE>
+c = BigDecimal::new("1.23456").truncate(4) # ==> 1.2345
+c = BigDecimal::new("15.23456").truncate(-1) # ==> 10.0
+</PRE></CODE>
+</BLOCKQUOTE>
+<LI><B>abs</B></LI><BLOCKQUOTE>
+c = a.abs<BR>
+returns an absolute value of a.<BR>
+
+</BLOCKQUOTE>
+<LI><B>to_i</B></LI><BLOCKQUOTE>
+changes a to an integer.<BR>
+i = a.to_i<BR>
+i becomes to Fixnum or Bignum.
+If a is Infinity or NaN,then i becomes to nil.
+
+</BLOCKQUOTE>
+<LI><B>to_s[(n)]</B></LI><BLOCKQUOTE>
+converts to string(default results look like "0.xxxxxEn").
+<CODE><PRE>
+BigDecimal("1.23456").to_s # ==> "0.123456E1"
+</PRE></CODE>
+If n(>0) is given,then a space is inserted to each of two parts divided by the decimal point
+after every n digits for readability.
+<CODE><PRE>
+BigDecimal("0.1234567890123456789").to_s(10) # ==> "0.1234567890 123456789E0"
+</PRE></CODE>
+n can be an string representing a positive integer number.
+<CODE><PRE>
+BigDecimal("0.1234567890123456789").to_s("10") # ==> "0.1234567890 123456789E0"
+</PRE></CODE>
+If the first character is '+'(or ' '),then '+'(or ' ') will be set before value string
+when the value is positive.
+<CODE><PRE>
+BigDecimal("0.1234567890123456789").to_s(" 10") # ==> " 0.1234567890 123456789E0"
+BigDecimal("0.1234567890123456789").to_s("+10") # ==> "+0.1234567890 123456789E0"
+BigDecimal("-0.1234567890123456789").to_s("10") # ==> "-0.1234567890 123456789E0"
+</PRE></CODE>
+
+At the end of the string,'E'(or 'e') or 'F'(or 'f') can be specified to change
+number representation.
+<CODE><PRE>
+BigDecimal("1234567890.123456789").to_s("E") # ==> "0.1234567890123456789E10"
+BigDecimal("1234567890.123456789").to_s("F") # ==> "1234567890.123456789"
+BigDecimal("1234567890.123456789").to_s("5E") # ==> "0.12345 67890 12345 6789E10"
+BigDecimal("1234567890.123456789").to_s("5F") # ==> "12345 67890.12345 6789"
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>exponent</B></LI><BLOCKQUOTE>
+returns an integer holding exponent value of a.<BR>
+n = a.exponent <BR>
+means a = 0.xxxxxxx*10**n.
+</BLOCKQUOTE>
+
+<LI><B>precs</B></LI><BLOCKQUOTE>
+n,m = a.precs <BR>
+prec returns number of significant digits (n) and maximum number of
+significant digits (m) of a.
+</BLOCKQUOTE>
+
+<LI><B>to_f</B></LI><BLOCKQUOTE>
+Creates a new Float object having (nearly) the same value.
+Use split method if you want to convert by yourself.
+</BLOCKQUOTE>
+
+</BLOCKQUOTE>
+<LI><B>sign</B></LI><BLOCKQUOTE>
+n = a.sign <BR>
+returns positive value if a &gt; 0,negative value if a &lt; 0,
+otherwise zero if a == 0.<BR>
+where the value of n means that a is:<BR>
+n = BigDecimal::SIGN_NaN(0) : a is NaN<BR>
+n = BigDecimal::SIGN_POSITIVE_ZERO(1) : a is +0<BR>
+n = BigDecimal::SIGN_NEGATIVE_ZERO(-1) : a is -0<BR>
+n = BigDecimal::SIGN_POSITIVE_FINITE(2) : a is positive<BR>
+n = BigDecimal::SIGN_NEGATIVE_FINITE(-2) : a is negative<BR>
+n = BigDecimal::SIGN_POSITIVE_INFINITE(3) : a is +Infinity<BR>
+n = BigDecimal::SIGN_NEGATIVE_INFINITE(-3) : a is -Infinity<BR>
+The value in () is the actual value,see (<A HREF="#STRUCT">Internal structure</A>.<BR>
+
+</BLOCKQUOTE>
+<LI><B>nan?</B></LI><BLOCKQUOTE>
+a.nan? returns True when a is NaN.
+
+</BLOCKQUOTE>
+<LI><B>infinite?</B></LI><BLOCKQUOTE>
+a.infinite? returns 1 when a is +‡,-1 when a is -‡, nil otherwise.
+
+</BLOCKQUOTE>
+<LI><B>finite?</B></LI><BLOCKQUOTE>
+a.finite? returns true when a is neither ‡ nor NaN.
+</BLOCKQUOTE>
+
+<LI><B>zero?</B></LI><BLOCKQUOTE>
+c = a.zero?<BR>
+returns true if a is equal to 0,otherwise returns false<BR>
+</BLOCKQUOTE>
+<LI><B>nonzero?</B></LI><BLOCKQUOTE>
+c = a.nonzero?<BR>
+returns nil if a is 0,otherwise returns a itself.<BR>
+</BLOCKQUOTE>
+
+<LI><B>split</B></LI><BLOCKQUOTE>
+decomposes a BigDecimal value to 4 parts.
+All 4 parts are returned as an array.<BR>
+Parts consist of a sign(0 when the value is NaN,+1 for positive and
+ -1 for negative value), a string representing fraction part,base value(always 10 currently),and an integer(Fixnum) for exponent respectively.
+a=BigDecimal::new("3.14159265")<BR>
+f,x,y,z = a.split<BR>
+where f=+1,x="314159265",y=10 and z=1<BR>
+therefore,you can translate BigDecimal value to Float as:<BR>
+s = "0."+x<BR>
+b = f*(s.to_f)*(y**z)<BR>
+
+</BLOCKQUOTE>
+<LI><B>inspect</B></LI><BLOCKQUOTE>
+is used for debugging output.<BR>
+p a=BigDecimal::new("3.14",10)<BR>
+should produce output like "#&lt;0x112344:'0.314E1',4(12)%gt;".
+where "0x112344" is the address,
+'0.314E1' is the value,4 is the number of the significant digits,
+and 12 is the maximum number of the significant digits
+the object can hold.
+</BLOCKQUOTE>
+
+<LI><B>sqrt</B></LI><BLOCKQUOTE>
+c = a.sqrt(n)<BR>
+computes square root value of a with significant digit number n at least.<BR>
+</BLOCKQUOTE>
+
+<LI><B>**</B></LI><BLOCKQUOTE>
+c = a ** n<BR>
+returns the value of a powered by n.
+n must be an integer.<BR>
+
+</BLOCKQUOTE>
+<LI><B>power</B></LI><BLOCKQUOTE>
+The same as ** method.<BR>
+c = a.power(n)<BR>
+returns the value of a powered by n(c=a**n).
+n must be an integer.<BR>
+</BLOCKQUOTE>
+
+<LI><B>divmod,quo,modulo,%,remainder</B></LI><BLOCKQUOTE>
+See,corresponding methods in Float class.
+</BLOCKQUOTE>
+
+</BLOCKQUOTE>
+<LI><B>&lt;=&gt;</B></LI><BLOCKQUOTE>
+c = a &lt;=&gt; b <BR>
+returns 0 if a==b,1 if a &gt b,and returns -1 if a &lt b.<BR>
+</BLOCKQUOTE>
+</UL>
+
+Following methods need no explanation.<BR>
+<UL>
+<LI>==</LI>
+<LI>===</LI>
+same as ==,used in case statement.
+<LI>!=</LI>
+<LI>&lt;</LI>
+<LI>&lt;=</LI>
+<LI>&gt;</LI>
+<LI>&gt;=</LI>
+</UL>
+
+<HR>
+<H3>About 'coerce'</H3>
+<B>For the binary operation like A op B:</B>
+<DL>
+<DT> 1.Both A and B are BigDecimal objects</DT>
+<DD> A op B is normally performed.</DD>
+<DT> 2.A is the BigDecimal object but B is other than BigDecimal object</DT>
+<DD> Operation is performed,after B is translated to correcponding BigDecimal object(because BigDecimal supports coerce method).</DD>
+<DT> 3.A is not the BigDecimal object but B is BigDecimal object</DT>
+<DD>If A has coerce mthod,then B will translate A to corresponding
+BigDecimal object and the operation is performed,otherwise an error occures.</DD>
+</DL>
+
+String is not translated to BigDecimal in default.
+Uncomment /* #define ENABLE_NUMERIC_STRING */ in bigdecimal.c, compile and install
+again if you want to enable string to BigDecimal conversion.
+Translation stops without error at the character representing non digit.
+For instance,"10XX" is translated to 10,"XXXX" is translated to 0.<BR>
+String representing zero or infinity such as "Infinity","+Infinity","-Infinity",and "NaN" can also be translated to BigDecimal unless false is specified by mode method.<BR>
+
+BigDecimal class supports coerce method(for the details about coerce method,see Ruby documentations). This means the most binary operation can be performed if the BigDecimal object is at the left hand side of the operation.<BR><BR>
+
+ For example:
+<CODE><PRE>
+ a = BigDecimal.E(20)
+ c = a * "0.123456789123456789123456789" # A String is changed to BigDecimal object.
+</PRE></CODE>
+is performed normally.<BR>
+ But,because String does not have coerce method,the following example can not be performed.<BR>
+
+<CODE><PRE>
+ a = BigDecimal.E(20)
+ c = "0.123456789123456789123456789" * a # ERROR
+</PRE></CODE>
+
+If you actually have any inconvenience about the error above.
+You can define a new class derived from String class,
+and define coerce method within the new class.<BR>
+
+<hr>
+<A NAME="#UNDEF">
+<H2>Infinity,Not a Number(NaN),Zero</H2>
+Infinite numbers and NaN can be represented by string writing "+Infinity"(or "Infinity"),"-Infinity",and "NaN" respectively in your program.
+Infinite numbers can be obtained by 1.0/0.0(=Infinity) or -1.0/0.0(=-Infinity).
+<BR><BR>
+NaN(Not a number) can be obtained by undefined computation like 0.0/0.0
+or Infinity-Infinity.
+Any computation including NaN results to NaN.
+Comparisons with NaN never become true,including comparison with NaN itself.
+<BR><BR>
+Zero has two different variations as +0.0 and -0.0.
+But,still, +0.0==-0.0 is true.
+<BR><BR>
+Computation results including Infinity,NaN,+0.0 or -0.0 become complicated.
+Run following program and comfirm the results.
+Send me any incorrect result if you find.
+
+<CODE><PRE>
+ require "bigdecimal"
+ aa = %w(1 -1 +0.0 -0.0 +Infinity -Infinity NaN)
+ ba = %w(1 -1 +0.0 -0.0 +Infinity -Infinity NaN)
+ opa = %w(+ - * / <=> > >= < == != <=)
+ for a in aa
+ for b in ba
+ for op in opa
+ x = BigDecimal::new(a)
+ y = BigDecimal::new(b)
+ eval("ans= x #{op} y;print a,' ',op,' ',b,' ==> ',ans.to_s,\"\n\"")
+ end
+ end
+ end
+</PRE></CODE>
+<hr>
+
+<A NAME="#STRUCT">
+<H2>Internal structure</H2>
+BigDecimal number is defined by the structure Real in BigDecimal.h.
+Digits representing a float number are kept in the array frac[] defined in the structure.
+In the program,any floating number(BigDecimal number) is represented as:<BR>
+ <BigDecimal number> = 0.xxxxxxxxx*BASE**n<BR><BR>
+where 'x' is any digit representing mantissa(kept in the array frac[]),
+BASE is base value(=10000 in 32 bit integer system),
+and n is the exponent value.<BR>
+Larger BASE value enables smaller size of the array frac[],and increases computation speed.
+The value of BASE is defined ind VpInit(). In 32 bit integer system,this value is
+10000. In 64 bit integer system,the value becomes larger.
+BigDecimal has not yet been compiled and tested on 64 bit integer system.
+It will be very nice if anyone try to run BigDecimal on 64 bit system and
+ inform me the results.
+When BASE is 10000,an element of the array frac[] can have vale of from 0 to 9999.
+(up to 4 digits).<BR>
+The structure Real is defined in bigdecimal.h as:<BR>
+<CODE><PRE>
+ typedef struct {
+ VALUE obj; /* Back pointer(VALUE) for Ruby object. */
+ unsigned long MaxPrec; /* The size of the array frac[] */
+ unsigned long Prec; /* Current size of frac[] actually used. */
+ short sign; /* Attribute of the value. */
+ /* ==0 : NaN */
+ /* 1 : +0 */
+ /* -1 : -0 */
+ /* 2 : Positive number */
+ /* -2 : Negative number */
+ /* 3 : +Infinity */
+ /* -3 : -Infinity */
+ unsigned short flag; /* Control flag */
+ int exponent; /* Exponent value(0.xxxx*BASE**exponent) */
+ unsigned long frac[1]; /* An araay holding mantissa(Variable) */
+ } Real;
+</CODE></PRE>
+The decimal value 1234.56784321 is represented as(BASE=10000):<BR>
+<PRE>
+ 0.1234 5678 4321*(10000)**1
+</PRE>
+where frac[0]=1234,frac[1]=5678,frac[2]=4321,
+Prec=3,sign=2,exponent=1. MaxPrec can be any value greater than or equal to
+Prec.
+<hr>
+
+<A NAME="#BASE">
+<H2>Binary or decimal number representation</H2>
+I adopted decimal number representation for BigDecimal implementation.
+Of cource,binary number representation is common on the most computers.
+
+<H3>Advantages using decimal representation</H3>
+The reason why I adopted decimal number representation for BigDecimal is:<BR>
+<DL>
+<DT>Easy for debugging
+<DD>The floating number 1234.56784321 can be easily represented as:<BR>
+ frac[0]=1234,frac[1]=5678,frac[2]=4321,exponent=1,and sign=2.
+<DT>Exact representation
+<DD>Following program can add all numbers(in decimal) in a file
+ without any error(no round operation).<BR>
+
+<CODE><PRE>
+ file = File::open(....,"r")
+ s = BigDecimal::new("0")
+ while line = file.gets
+ s = s + line
+ end
+</PRE></CODE>
+
+If the internal representation is binary,translation from decimal to
+binary is required and the translation error is inevitable.
+For example, 0.1 can not exactly be represented in binary.<BR>
+0.1 => b1*2**(-1)+b1*2**(-2)+b3*2**(-3)+b4*2**(-4)....<BR>
+where b1=0,b2=0,b3=0,b4=1...<BR>
+bn(n=1,2,3,...) is infinite series of digit with value of 0 or 1,
+and rounding operation is necessary but where we should round the series ?
+Of cource,exact "0.1" is printed if the rouding operation is properly done,
+<DT>Significant digit we can have is automatically determined
+<DD>In binary representation,0.1 can not be represented in finite series of digit.
+
+But we only need one element(frac[0]=1) in decimal representation.
+This means that we can always determine the size of the array frac[] in Real
+structure.
+</DL>
+
+<H3>Disadvantage of decimal representation</H3>
+Advantages stated so far can also be disadvantages if the input from outside is
+ represented in binary.
+Translation error from decimal to binary or vice versa is inevitable.
+So,translation from Float(binary) to BigDecimal(decimal) is not alway done exactly.
+
+<H4>Which is the first input?</H4>
+Because most people uses decimal notatin for numeric data representation,
+BigDecimal can handle numeric data without loss of translation error.
+<hr>
+
+<A NAME="#PREC">
+<H2>Resulting number of significant digits</H2>
+For the fundamental arithmetics such as addition,subtraction,
+multiplication,and division,I prepared 2 group of methods<BR>
+
+<H3>1. +,-,*,/</H3>
+For the operation + - * /,you can not specify the resulting
+number of significant digits.<BR>
+Resulting number of significant digits are defined as:<BR>
+1.1 For *,resulting number of significant digits is the sum of the
+significant digits of both side of the operator. For / ,resulting number of significant digits is the sum of the
+maximum significant digits of both side of the operator.<BR>
+1.2 For + and -,resulting number of significant digits is determined so that
+ no round operation is needed. <br>
+For example, c has more than 100 siginificant digits if c is computed as:<BR>
+c = 0.1+0.1*10**(-100)<br>
+<BR>
+As +,-,and * are always exact(no round operation is performed unless BigDecimal.limit is specified),
+which means more momories are required to keep computation results.
+But,the division such as c=1.0/3.0 will always be rounded.<BR>
+
+<H3>2. add,sub,mult,div</H3>
+The length of the significant digits obtained from +,-,*,/
+is always defined by that of right and left side of the operator.
+To specify the length of the significant digits by your self,
+use methos add,sub,mult,div.
+<CODE><PRE>
+ BigDecimal("2").div(3,12) # 2.0/3.0 => 0.6666666666 67E0
+</PRE></CODE>
+</BLOCKQUOTE>
+
+<H3>3. truncate,round,ceil,floor</H3>
+Using these methods,you can specify rounding location relatively from
+decimal point.
+<CODE><PRE>
+ BigDecimal("6.66666666666666").round(12) # => 0.6666666666 667E1
+</PRE></CODE>
+</BLOCKQUOTE>
+
+
+<H3>4. Example</H3>
+Following example compute the ratio of the circumference of a circle to
+its dirmeter(pi=3.14159265358979....) using J.Machin's formula.
+<BR><BR>
+<CODE><PRE>
+#!/usr/local/bin/ruby
+
+require "bigdecimal"
+#
+# Calculates 3.1415.... (the number of times that a circle's diameter
+# will fit around the circle) using J. Machin's formula.
+#
+def big_pi(sig) # sig: Number of significant figures
+ exp = -sig
+ pi = BigDecimal::new("0")
+ two = BigDecimal::new("2")
+ m25 = BigDecimal::new("-0.04")
+ m57121 = BigDecimal::new("-57121")
+
+ u = BigDecimal::new("1")
+ k = BigDecimal::new("1")
+ w = BigDecimal::new("1")
+ t = BigDecimal::new("-80")
+ while (u.nonzero? && u.exponent >= exp)
+ t = t*m25
+ u = t.div(k,sig)
+ pi = pi + u
+ k = k+two
+ end
+
+ u = BigDecimal::new("1")
+ k = BigDecimal::new("1")
+ w = BigDecimal::new("1")
+ t = BigDecimal::new("956")
+ while (u.nonzero? && u.exponent >= exp )
+ t = t.div(m57121,sig)
+ u = t.div(k,sig)
+ pi = pi + u
+ k = k+two
+ end
+ pi
+end
+
+if $0 == __FILE__
+ if ARGV.size == 1
+ print "PI("+ARGV[0]+"):\n"
+ p big_pi(ARGV[0].to_i)
+ else
+ print "TRY: ruby pi.rb 1000 \n"
+ end
+end
+
+</PRE></CODE>
+<HR>
+<FONT size=2>
+<I>
+<A HREF="http://www.tinyforest.gr.jp">
+Shigeo Kobayashi
+</A>
+(E-Mail:<A HREF="mailto:shigeo@tinyforest.gr.jp">&lt;shigeo@tinyforest.gr.jp&gt;</U></A>)
+</I>
+</FONT>
+</TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>
diff --git a/ext/bigdecimal/bigdecimal_ja.html b/ext/bigdecimal/bigdecimal_ja.html
new file mode 100644
index 0000000000..8fd95a6fe3
--- /dev/null
+++ b/ext/bigdecimal/bigdecimal_ja.html
@@ -0,0 +1,798 @@
+<!-- saved from url=(0022)http://internet.e-mail -->
+<HTML>
+<HEAD>
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Shift_JIS">
+<style type="text/css"><!--
+body { color: #3f0f0f; background: #fefeff; margin-left: 2em; margin-right: 2em;}
+h1 { color: #ffffff; background-color: #3939AD; border-color: #FF00FF; width: 100%;
+ border-style: solid; border-top-width: 0.1em; border-bottom-width: 0.1em; border-right: none;
+ border-left: none; padding: 0.1em; font-weight: bold; font-size: 160%; text-align: center;
+}
+h2 { color: #00007f; background-color: #e7e7ff; border-color: #000094; width: 100%;
+ border-style: solid; border-left: none; border-right: none; border-top-width: 0.1em; border-bottom-width: 0.1em;
+ padding: 0.1em;
+ font-weight: bold; font-size: 110%;
+}
+h3 { color: #00007f; padding: 0.2em; font-size: 110%;}
+h4, h5 { color: #000000; padding: 0.2em; font-size: 100%;}
+table { margin-top: 0.2em; margin-bottom: 0.2em; margin-left: 2em; margin-right: 2em;}
+caption { color: #7f0000; font-weight: bold;}
+th { background: #e7e7ff; padding-left: 0.2em; padding-right: 0.2em;}
+td { background: #f3f7ff; padding-left: 0.2em; padding-right: 0.2em;}
+code { color: #0000df;}
+dt { margin-top: 0.2em;}
+li { margin-top: 0.2em;}
+pre
+{ BACKGROUND-COLOR: #d0d0d0; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none;
+ BORDER-RIGHT: medium none; BORDER-TOP: medium none; LINE-HEIGHT: 100%; MARGIN: 12px 12px 12px 12px;
+ PADDING-BOTTOM: 12px; PADDING-LEFT: 12px; PADDING-RIGHT: 12px; PADDING-TOP: 12px;
+ WHITE-SPACE: pre; WIDTH: 100%
+}
+--></style>
+
+<TITLE>BigDecimal:An extension library for Ruby</TITLE>
+</HEAD>
+<BODY BGCOLOR=#FFFFE0>
+<H1>BigDecimal(‰Â•Ï’·•‚“®­”“_‰‰ŽZ—pŠg’£ƒ‰ƒCƒuƒ‰ƒŠ)</H1>
+<DIV align="right"><A HREF="./bigdecimal_en.html">English</A></DIV><BR>
+BigDecimal ‚̓IƒuƒWƒFƒNƒgŽwŒü‚Ì‹­—͂ȃXƒNƒŠƒvƒgŒ¾Œê‚Å‚ ‚é Ruby ‚ɉ•ϒ·•‚“®¬”“_
+ŒvŽZ‹@”\‚ð’ljÁ‚·‚邽‚߂̊g’£ƒ‰ƒCƒuƒ‰ƒŠ‚Å‚·B
+Ruby ‚ɂ‚¢‚Ä‚ÌÚ‚µ‚¢“à—e‚͈ȉº‚ÌURL‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B
+<UL>
+<LI><A HREF="http://www.ruby-lang.org/ja/">http://www.ruby-lang.org/ja/</A>FRubyŒöŽ®ƒy[ƒW</LI>
+<LI><A HREF="http://kahori.com/ruby/ring/">http://kahori.com/ruby/ring/</A>FRuby‚ÉŠÖ‚·‚éƒy[ƒW‚ð’H‚ê‚Ü‚·</LI>
+</UL>
+<hr>
+<H2>–ÚŽŸ</H2>
+<UL>
+<LI><A HREF="#INTRO">‚Í‚¶‚ß‚É</LI>
+<LI><A HREF="#SPEC">Žg—p•û–@‚ƃƒ\ƒbƒh‚̈ꗗ</A></LI>
+<LI><A HREF="#UNDEF">–³ŒÀA”ñ”Aƒ[ƒ‚̈µ‚¢</A></LI>
+<LI><A HREF="#STRUCT">“à•”\‘¢</A></LI>
+<LI><A HREF="#BASE">2i‚Æ10i</A></LI>
+<LI><A HREF="#PREC">ŒvŽZ¸“x‚ɂ‚¢‚Ä</A></LI>
+</UL>
+
+<HR>
+<A NAME="#INTRO">
+<H2>‚Í‚¶‚ß‚É</H2>
+Ruby ‚É‚Í Bignum ‚Æ‚¢‚¤ƒNƒ‰ƒX‚ª‚ ‚èA”•SŒ…‚Ì®”‚Å‚àŒvŽZ‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·B
+‚½‚¾A”CˆÓŒ…‚Ì•‚“®­”“_‰‰ŽZ—pƒNƒ‰ƒX‚ª–³‚¢‚悤‚Å‚·B‚»‚±‚ÅA
+”CˆÓŒ…‚Ì•‚“®­”“_‰‰ŽZ—pŠg’£ƒ‰ƒCƒuƒ‰ƒŠ BigDecimal ‚ð쬂µ‚Ü‚µ‚½B
+•s‹ï‡‚╌¾E’ñˆÄ‚ª‚ ‚éꇂǂµ‚Ç‚µA
+<A HREF="mailto:shigeo@tinyforest.gr.jp">shigeo@tinyforest.gr.jp</A>
+‚܂ł¨’m‚点‚­‚¾‚³‚¢B•s‹ï‡‚𒼂·‹C‚͑傢‚É‚ ‚è‚Ü‚·B‚½‚¾AŽžŠÔ‚Ȃǂ̊֌W‚Å–ñ‘©
+‚͂ł«‚Ü‚¹‚ñB‚Ü‚½AŒ‹‰Ê‚ɂ‚¢‚Ä‚à•ÛØ‚Å‚«‚é‚à‚̂ł͂ ‚è‚Ü‚¹‚ñB
+—\‚ßA‚²—¹³‚­‚¾‚³‚¢B
+<BR><BR>
+‚±‚̃vƒƒOƒ‰ƒ€‚ÍAŽ©—R‚É”z•zE‰ü•Ï‚µ‚Ä\‚¢‚Ü‚¹‚ñB‚½‚¾‚µA’˜ìŒ ‚Í•úŠü‚µ‚Ä‚¢‚Ü‚¹‚ñB
+”z•zE‰ü•Ï“™‚ÌŒ —˜‚Í Ruby ‚Ì‚»‚ê‚É€‚¶‚Ü‚·BÚ‚µ‚­‚Í README ‚ð“Ç‚ñ‚Å‚­‚¾‚³‚¢B
+
+<hr>
+<H2>ƒCƒ“ƒXƒg[ƒ‹‚ɂ‚¢‚Ä</H2>
+BigDecimal ‚ðŠÜ‚Þ Ruby ‚ÌÅV”Å‚Í<A HREF="http://www.ruby-lang.org/ja/">RubyŒöŽ®ƒy[ƒW</A>‚©‚çƒ_ƒEƒ“ƒ[ƒh‚Å‚«‚Ü‚·B
+ƒ_ƒEƒ“ƒ[ƒh‚µ‚½ÅV”Å‚ð‰ð“€‚µ‚½‚çA’Êí‚̃Cƒ“ƒXƒg[ƒ‹Žè‡‚ðŽÀs‚µ‚ĉº‚³‚¢B
+Ruby ‚ª³‚µ‚­ƒCƒ“ƒXƒg[ƒ‹‚³‚ê‚ê‚ÎA“¯Žž‚É BigDecimal ‚à—˜—p‚Å‚«‚邿‚¤‚ɂȂé‚Í‚¸‚Å‚·B
+ƒ\[ƒXƒtƒ@ƒCƒ‹‚Í
+bigdecimal.c,bigdecimal.h
+‚Ì‚QŒÂ‚݂̂ł·B<BR>
+
+<hr>
+<A NAME="#SPEC">
+<H2>Žg—p•û–@‚ƃƒ\ƒbƒh‚̈ꗗ</H2>
+uRuby‚ÍŠù‚É‘‚¯‚év‚Æ‚¢‚¤‘O’ñ‚ÅA
+<CODE><PRE>
+require 'bigdecimal'
+a=BigDecimal::new("0.123456789123456789")
+b=BigDecimal("123456.78912345678",40)
+c=a+b
+</PRE></CODE>
+<br>
+‚Æ‚¢‚¤‚悤‚ÈŠ´‚¶‚ÅŽg—p‚µ‚Ü‚·B
+
+<H3>ƒƒ\ƒbƒhˆê——</H3>
+ˆÈ‰º‚̃ƒ\ƒbƒh‚ª—˜—p‰Â”\‚Å‚·B
+u—LŒøŒ…”v‚Æ‚Í BigDecimal ‚ª¸“x‚ð•ÛØ‚·‚錅”‚Å‚·B
+‚Ò‚Á‚½‚è‚ł͂ ‚è‚Ü‚¹‚ñAŽáб‚Ì—]—T‚ðŽ‚Á‚ÄŒvŽZ‚³‚ê‚Ü‚·B
+‚Ü‚½A—Ⴆ‚΂R‚Qƒrƒbƒg‚̃VƒXƒeƒ€‚ł͂P‚Oi‚Å‚SŒ…–ˆ‚ÉŒvŽZ‚µ‚Ü‚·B]‚Á‚ÄAŒ»ó‚Å‚ÍA
+“à•”‚Ìu—LŒøŒ…”v‚Í‚S‚Ì”{”‚ƂȂÁ‚Ä‚¢‚Ü‚·B
+<P>
+ˆÈ‰º‚̃ƒ\ƒbƒhˆÈŠO‚É‚àA(C ‚ł͂Ȃ¢) Ruby ƒ\[ƒX‚ÌŒ`‚Å
+’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚à‚ ‚è‚Ü‚·B—Ⴆ‚ÎA
+<CODE><PRE>
+require "bigdecimal/math.rb"
+</PRE></CODE>
+‚Æ‚·‚邱‚Æ‚ÅAsin ‚â cos ‚Æ‚¢‚Á‚½ŠÖ”‚ªŽg—p‚Å‚«‚邿‚¤‚ɂȂè‚Ü‚·B
+Žg—p•û–@‚È‚ÇAÚ×‚Í math.rb ‚Ì“à—e‚ðŽQÆ‚µ‚ĉº‚³‚¢B
+
+‚»‚Ì‘¼AFloat ‚Æ‚Ì‘ŠŒÝ•ÏŠ·‚Ȃǂ̃ƒ\ƒbƒh‚ª util.rb ‚ŃTƒ|[ƒg‚³‚ê‚Ä‚¢‚Ü‚·B
+—˜—p‚·‚é‚É‚Í
+<CODE><PRE>
+require "bigdecimal/util.rb"
+</PRE></CODE>
+‚̂悤‚É‚µ‚Ü‚·BÚ×‚Í util.rb ‚Ì“à—e‚ðŽQÆ‚µ‚ĉº‚³‚¢B
+
+<H4><U>ƒNƒ‰ƒXƒƒ\ƒbƒh</U></H4>
+<UL>
+<LI><B>new</B></LI><BLOCKQUOTE>
+V‚µ‚¢ BigDecimal ƒIƒuƒWƒFƒNƒg‚𶬂µ‚Ü‚·B<BR>
+a=BigDecimal::new(s[,n]) ‚Ü‚½‚Í<BR>
+a=BigDecimal(s[,n])<BR>
+s ‚Í”Žš‚ð•\Œ»‚·‚鉊ú’l‚ð•¶Žš—ñ‚ÅŽw’肵‚Ü‚·B
+ƒXƒy[ƒX‚Í–³Ž‹‚³‚ê‚Ü‚·B‚Ü‚½A”»’f‚Å‚«‚È‚¢•¶Žš‚ªoŒ»‚µ‚½Žž“_‚Å
+•¶Žš—ñ‚ÍI—¹‚µ‚½‚à‚̂Ƃ݂Ȃ³‚ê‚Ü‚·B
+n ‚Í•K—v‚È—LŒøŒ…”ia ‚ÌÅ‘å—LŒøŒ…”j‚ð®”‚ÅŽw’肵‚Ü‚·B
+n ‚ª 0 ‚Ü‚½‚ÍÈ—ª‚³‚ꂽ‚Æ‚«‚ÍAn ‚Ì’l‚Í s ‚Ì—LŒøŒ…”‚Ƃ݂Ȃ³‚ê‚Ü‚·B
+s ‚Ì—LŒøŒ…”‚æ‚è n ‚ª¬‚³‚¢‚Æ‚«‚à n=0 ‚̂Ƃ«‚Æ“¯‚¶‚Å‚·B
+a ‚ÌÅ‘å—LŒøŒ…”‚Í n ‚æ‚èŽáб‘å‚¢’l‚ªÌ—p‚³‚ê‚Ü‚·B
+Å‘å—LŒøŒ…”‚͈ȉº‚̂悤‚ÈŠ„‚èŽZ‚ðŽÀs‚·‚邯‚«“™‚ɈӖ¡‚ðŽ‚¿‚Ü‚·B
+<CODE><PRE>
+BigDecimal("1") / BigDecimal("3") # => 0.3333333333 33E0
+BigDecimal("1",10) / BigDecimal("3",10) # => 0.3333333333 3333333333 33333333E0
+</PRE></CODE>
+‚½‚¾‚µAŒÂX‚̉‰ŽZ‚É‚¨‚¯‚éÅ‘å—LŒøŒ…” n ‚ÌŽæ‚舵‚¢‚Í«—ˆ‚̃o[ƒWƒ‡ƒ“‚Å
+Žáб•ÏX‚³‚ê‚é‰Â”\«‚ª‚ ‚è‚Ü‚·B
+</BLOCKQUOTE>
+
+<LI><B>mode</B></LI><BLOCKQUOTE>
+f = BigDecimal.mode(s[,v])<BR>
+BigDecimal‚ÌŽÀsŒ‹‰Ê‚ð§Œä‚µ‚Ü‚·B‘æ‚Qˆø”‚ðÈ—ªA‚Ü‚½‚Í nil ‚ðŽw’è‚·‚邯
+Œ»ó‚ÌÝ’è’l‚ª–ß‚è‚Ü‚·B<BR>
+ˆÈ‰º‚ÌŽg—p•û–@‚ª’è‹`‚³‚ê‚Ä‚¢‚Ü‚·B
+<P>
+<B>[—áŠOˆ—]</B><P>
+ŒvŽZŒ‹‰Ê‚ª”ñ”(NaN)‚âƒ[ƒ‚É‚æ‚霎Z‚ɂȂÁ‚½‚Æ‚«‚̈—‚ð’è‹`‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·B
+<BLOCKQUOTE>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_NaN,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_INFINITY,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_UNDERFLOW,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_OVERFLOW,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE,flag)<BR>
+f = BigDecimal::mode(BigDecimal::EXCEPTION_ALL,flag)<BR>
+</BLOCKQUOTE>
+
+EXCEPTION_NaN ‚ÍŒ‹‰Ê‚ª NaN ‚ɂȂÁ‚½‚Æ‚«‚ÌŽw’è‚Å‚·B<BR>
+EXCEPTION_INFINITY ‚ÍŒ‹‰Ê‚ª–³ŒÀ‘å(}Infinity)‚ɂȂÁ‚½‚Æ‚«‚ÌŽw’è‚Å‚·B<BR>
+EXCEPTION_UNDERFLOW ‚ÍŽw”•”‚ªƒAƒ“ƒ_[ƒtƒ[‚·‚邯‚«‚ÌŽw’è‚Å‚·B<BR>
+EXCEPTION_OVERFLOW ‚ÍŽw”•”‚ªƒI[ƒo[ƒtƒ[‚·‚邯‚«‚ÌŽw’è‚Å‚·B<BR>
+EXCEPTION_ZERODIVIDE ‚̓[ƒ‚É‚æ‚銄‚èŽZ‚ðŽÀs‚µ‚½‚Æ‚«‚ÌŽw’è‚Å‚·B<BR>
+EXCEPTION_ALL ‚ÍA‰Â”\‚È‘S‚Ăɑ΂µ‚Ĉꊇ‚µ‚ÄÝ’è‚·‚邯‚«‚ÉŽg—p‚µ‚Ü‚·B<BR><BR>
+
+flag ‚ª true ‚̂Ƃ«‚ÍAŽw’肵‚½ó‘ԂɂȂÁ‚½‚Æ‚«‚É—áŠO‚ð”­s‚·‚邿‚¤‚ɂȂè‚Ü‚·B<BR>
+flag ‚ª falseiƒfƒtƒHƒ‹ƒgj‚È‚çA—áŠO‚Í”­s‚³‚ê‚Ü‚¹‚ñBŒvŽZŒ‹‰Ê‚͈ȉº‚̂悤‚ɂȂè‚Ü‚·B<BR>
+<BLOCKQUOTE>
+EXCEPTION_NaN ‚̂Ƃ«A”ñ”(NaN)<BR>
+EXCEPTION_INFINITY ‚̂Ƃ«A–³ŒÀ(+ or -Infinity)<BR>
+EXCEPTION_UNDERFLOW ‚̂Ƃ«Aƒ[ƒ<BR>
+EXCEPTION_OVERFLOW ‚̂Ƃ«A+Infinity ‚© -Infinity<BR>
+EXCEPTION_ZERODIVIDE ‚̂Ƃ«A+Infinity ‚© -Infinity<BR>
+</BLOCKQUOTE>
+EXCEPTION_INFINITYAEXCEPTION_OVERFLOWAEXCEPTION_ZERODIVIDE
+‚Í¡‚̂Ƃ±‚듯‚¶‚Å‚·B<BR>
+–ß‚è’l‚ÍAÝ’èŒã‚Ì’l‚Å‚·Bu’lv‚̈Ӗ¡‚ÍA—Ⴆ‚Î
+BigDecimal::EXCEPTION_NaN‚Æu’lv‚Ì & ‚ª ƒ[ƒˆÈŠO‚È‚ç‚Î
+EXCEPTION_NaN‚ªÝ’肳‚ê‚Ä‚¢‚邯‚¢‚¤ˆÓ–¡‚Å‚·B
+
+<P>
+<B>[ŠÛ‚߈—Žw’è]</B><P>
+ŒvŽZ“r’†‚ÌŠÛ‚ß‘€ì‚ÌŽw’肪‚Å‚«‚Ü‚·B
+<BLOCKQUOTE>
+f = BigDecimal::mode(BigDecimal::ROUND_MODE,flag)
+</BLOCKQUOTE>
+‚ÌŒ`Ž®‚ÅŽw’肵‚Ü‚·B<BR>
+‚±‚±‚ÅAflag ‚͈ȉº(ЇŒÊ“à‚͑Ήž‚·‚éƒCƒ“ƒXƒ^ƒ“ƒXƒƒ\ƒbƒh)‚̈ê‚‚ðŽw’肵‚Ü‚·B
+<TABLE>
+<TR><TD>ROUND_UP</TD><TD>‘S‚ÄØ‚èã‚°‚Ü‚·B</TD></TR>
+<TR><TD>ROUND_DOWN</TD><TD>‘S‚ÄØ‚èŽÌ‚Ă܂·(truncate)B</TD></TR>
+<TR><TD>ROUND_HALF_UP</TD><TD>ŽlŽÌŒÜ“ü‚µ‚Ü‚·(ƒfƒtƒHƒ‹ƒg)B</TD></TR>
+<TR><TD>ROUND_HALF_DOWN</TD><TD>ŒÜŽÌ˜Z“ü‚µ‚Ü‚·B</TD></TR>
+<TR><TD>ROUND_HALF_EVEN</TD><TD>ŽlŽÌ˜Z“ü‚µ‚Ü‚·B‚T‚ÌŽž‚ÍãˆÊ‚PŒ…‚ªŠï”‚ÌŽž‚̂݌J‚èã‚°‚Ü‚·(Banker's rounding)B</TD></TR>
+<TR><TD>ROUND_CEILING</TD><TD>”’l‚̑傫‚¢•û‚ÉŒJ‚èã‚°‚Ü‚·(ceil)B</TD></TR>
+<TR><TD>ROUND_FLOOR</TD><TD>”’l‚̬‚³‚¢•û‚ÉŒJ‚艺‚°‚Ü‚·(floor)B</TD></TR>
+
+</TABLE>
+–ß‚è’l‚ÍŽw’èŒã‚Ì flag ‚Ì’l‚Å‚·B
+‘æ‚Qˆø”‚É nil ‚ðŽw’è‚·‚邯AŒ»ó‚ÌÝ’è’l‚ª•Ô‚è‚Ü‚·B
+mode ƒƒ\ƒbƒh‚ł͊ۂߑ€ì‚̈ʒu‚ðƒ†[ƒU‚ªŽw’è‚·‚邱‚Ƃ͂ł«‚Ü‚¹‚ñB
+ŠÛ‚ß‘€ì‚ƈʒu‚ðŽ©•ª‚ŧŒä‚µ‚½‚¢ê‡‚Í BigDecimal::limit ‚â truncate/round/ceil/floorA
+add/sub/mult/div ‚Æ‚¢‚Á‚½ƒCƒ“ƒXƒ^ƒ“ƒXƒƒ\ƒbƒh‚ðŽg—p‚µ‚ĉº‚³‚¢B
+</BLOCKQUOTE>
+<LI><B>limit([n])</B></LI><BLOCKQUOTE>
+¶¬‚³‚ê‚éBigDecimalƒIƒuƒWƒFƒNƒg‚Ìő包”‚ðnŒ…‚ɧŒÀ‚µ‚Ü‚·B
+–ß‚è’l‚ÍÝ’è‚·‚é‘O‚Ì’l‚Å‚·BÝ’è’l‚̃fƒtƒHƒ‹ƒg’l‚Í‚O‚ÅAŒ…”–³§ŒÀ‚Æ‚¢‚¤ˆÓ–¡‚Å‚·B
+n ‚ðŽw’肵‚È‚¢A‚Ü‚½‚Í n ‚ª nil ‚ÌꇂÍAŒ»ó‚Ìő包”‚ª•Ô‚è‚Ü‚·B<BR>
+ŒvŽZ‚ð‘±s‚·‚éŠÔ‚ÉA”Žš‚ÌŒ…”‚ª–³§ŒÀ‚É‘‚¦‚Ä‚µ‚Ü‚¤‚悤‚Èê‡
+ limit ‚Å—\‚ߌ…”‚ð§ŒÀ‚Å‚«‚Ü‚·B‚±‚Ìê‡ BigDecimal.mode ‚ÅŽw’肳‚ꂽ
+ŠÛ‚߈—‚ªŽÀs‚³‚ê‚Ü‚·B
+‚½‚¾‚µAƒCƒ“ƒXƒ^ƒ“ƒXƒƒ\ƒbƒh (truncate/round/ceil/floor/add/sub/mult/div) ‚Ì
+Œ…”§ŒÀ‚Í limit ‚æ‚è—D悳‚ê‚Ü‚·B<BR>
+mf = BigDecimal::limit(n)<BR>
+</BLOCKQUOTE>
+
+<LI><B>double_fig</B></LI><BLOCKQUOTE>
+Ruby ‚Ì Float ƒNƒ‰ƒX‚ª•ÛŽ‚Å‚«‚é—LŒø”Žš‚Ì”‚ð•Ô‚µ‚Ü‚·B
+<CODE><PRE>
+ p BigDecimal::double_fig # ==> 20 (depends on the CPU etc.)
+</PRE></CODE>
+double_fig‚͈ȉº‚Ì C ƒvƒƒOƒ‰ƒ€‚ÌŒ‹‰Ê‚Æ“¯‚¶‚Å‚·B
+<CODE><PRE>
+ double v = 1.0;
+ int double_fig = 0;
+ while(v + 1.0 > 1.0) {
+ ++double_fig;
+ v /= 10;
+ }
+</PRE></CODE>
+</BLOCKQUOTE>
+
+<LI><B>BASE</B></LI><BLOCKQUOTE>
+“à•”‚ÅŽg—p‚³‚ê‚éŠî”‚Ì’l‚Å‚·B®”‚ª 32 ƒrƒbƒg‚̈—Œn‚Å‚Í10000‚Å‚·B<BR>
+b = BigDecimal::BASE<BR>
+</BLOCKQUOTE>
+</UL>
+
+<H4><U>ƒCƒ“ƒXƒ^ƒ“ƒXƒƒ\ƒbƒh</U></H4>
+<UL>
+<LI><B>+</B></LI><BLOCKQUOTE>
+‰ÁŽZic = a + bj<BR>
+c ‚̸“x‚ɂ‚¢‚Ä‚Íu<A HREF="#PREC">ŒvŽZ¸“x‚ɂ‚¢‚Ä</A>v‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B
+</BLOCKQUOTE>
+
+<LI><B>-</B></LI><BLOCKQUOTE>
+Œ¸ŽZic = a - bjA‚Ü‚½‚Í•„†”½“]ic = -aj<BR>
+c ‚̸“x‚ɂ‚¢‚Ä‚Íu<A HREF="#PREC">ŒvŽZ¸“x‚ɂ‚¢‚Ä</A>v‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B
+
+</BLOCKQUOTE>
+<LI><B>*</B></LI><BLOCKQUOTE>
+æŽZ(c = a * b)<BR>
+c‚̸“x‚Í(a‚̸“x)+(b‚̸“x)’ö“x‚Å‚·B<br>
+Ú‚µ‚­‚Íu<A HREF="#PREC">ŒvŽZ¸“x‚ɂ‚¢‚Ä</A>v‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B
+
+</BLOCKQUOTE>
+<LI><B>/</B></LI><BLOCKQUOTE>
+œŽZ(c = a / b)<BR>
+c ‚̸“x‚ɂ‚¢‚Ä‚Íu<A HREF="#PREC">ŒvŽZ¸“x‚ɂ‚¢‚Ä</A>v‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢B
+
+</BLOCKQUOTE>
+
+<LI><B>add(b,n)</B></LI><BLOCKQUOTE>
+ˆÈ‰º‚̂悤‚ÉŽg—p‚µ‚Ü‚·B<BR>
+c = a.add(b,n)<BR>
+c = a + b ‚ðÅ‘å‚Å n Œ…‚܂ŌvŽZ‚µ‚Ü‚·B<BR>
+a + b ‚̸“x‚ª n ‚æ‚è‘å‚«‚¢‚Æ‚«‚Í BigDecimal.mode ‚ÅŽw’肳‚ꂽ•û–@‚ÅŠÛ‚ß‚ç‚ê‚Ü‚·B<BR>
+n ‚ªƒ[ƒ‚È‚ç + ‚Æ“¯‚¶‚Å‚·B
+</BLOCKQUOTE>
+<LI><B>sub(b,n)</B></LI><BLOCKQUOTE>
+ˆÈ‰º‚̂悤‚ÉŽg—p‚µ‚Ü‚·B<BR>
+c = a.sub(b,n)<BR>
+c = a - b ‚ðÅ‘å‚Å n Œ…‚܂ŌvŽZ‚µ‚Ü‚·B<BR>
+a - b ‚̸“x‚ª n ‚æ‚è‘å‚«‚¢‚Æ‚«‚Í BigDecimal.mode ‚ÅŽw’肳‚ꂽ•û–@‚ÅŠÛ‚ß‚ç‚ê‚Ü‚·B<BR>
+n ‚ªƒ[ƒ‚È‚ç - ‚Æ“¯‚¶‚Å‚·B
+
+</BLOCKQUOTE>
+<LI><B>mult(b,n)</B></LI><BLOCKQUOTE>
+ˆÈ‰º‚̂悤‚ÉŽg—p‚µ‚Ü‚·B<BR>
+c = a.mult(b,n)<BR>
+c = a * b ‚ðÅ‘å‚Å n Œ…‚܂ŌvŽZ‚µ‚Ü‚·B<BR>
+a * b ‚̸“x‚ª n ‚æ‚è‘å‚«‚¢‚Æ‚«‚Í BigDecimal.mode ‚ÅŽw’肳‚ꂽ•û–@‚ÅŠÛ‚ß‚ç‚ê‚Ü‚·B<BR>
+n ‚ªƒ[ƒ‚È‚ç * ‚Æ“¯‚¶‚Å‚·B
+
+</BLOCKQUOTE>
+<LI><B>div(b[,n])</B></LI><BLOCKQUOTE>
+ˆÈ‰º‚̂悤‚ÉŽg—p‚µ‚Ü‚·B<BR>
+c = a.div(b,n)<BR>
+c = a / b ‚ðÅ‘å‚Å n Œ…‚܂ŌvŽZ‚µ‚Ü‚·B
+a / b ‚̸“x‚ª n ‚æ‚è‘å‚«‚¢‚Æ‚«‚Í BigDecimal.mode ‚ÅŽw’肳‚ꂽ•û–@‚ÅŠÛ‚ß‚ç‚ê‚Ü‚·B<BR>
+n ‚ªƒ[ƒ‚È‚ç / ‚Æ“¯‚¶‚Å‚·B<BR>
+n ‚ªÈ—ª‚³‚ꂽ‚Æ‚«‚Í Float#div ‚Æ“¯—l‚ÉŒ‹‰Ê‚ª®”(BigDecimal)‚ɂȂè‚Ü‚·B
+</BLOCKQUOTE>
+
+<LI><B>fix</B></LI><BLOCKQUOTE>
+a ‚̬”“_ˆÈ‰º‚ÌØ‚èŽÌ‚ÄB<BR>
+c = a.fix
+</BLOCKQUOTE>
+<LI><B>frac</B></LI><BLOCKQUOTE>
+a ‚Ì®”•”•ª‚ÌØ‚èŽÌ‚ÄB<BR>
+c = a.frac
+</BLOCKQUOTE>
+
+<LI><B>floor[(n)]</B></LI><BLOCKQUOTE>
+c = a.floor<BR>
+a ˆÈ‰º‚Ìő宔iBigDecimal ’lj‚ð•Ô‚µ‚Ü‚·B
+<CODE><PRE>
+c = BigDecimal("1.23456").floor # ==> 1
+c = BigDecimal("-1.23456").floor # ==> -2
+</PRE></CODE>
+ˆÈ‰º‚̂悤‚Ɉø” n ‚ð—^‚¦‚邱‚Æ‚à‚Å‚«‚Ü‚·B<BR>
+n>=0 ‚È‚çA¬”“_ˆÈ‰º n+1 ˆÊ‚Ì”Žš‚ð‘€ì‚µ‚Ü‚·(­”“_ˆÈ‰º‚ðAÅ‘å n Œ…‚É‚µ‚Ü‚·)B<BR>
+n ‚ª•‰‚̂Ƃ«‚ͬ”“_ˆÈã n Œ…–Ú‚ð‘€ì‚µ‚Ü‚·(¬”“_ˆÊ’u‚©‚ç¶‚É­‚È‚­‚Æ‚à n ŒÂ‚Ì 0 ‚ª•À‚т܂·)B<BR>
+<CODE><PRE>
+ c = BigDecimal("1.23456").floor(4) # ==> 1.2345
+ c = BigDecimal("15.23456").floor(-1) # ==> 10.0
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>ceil[(n)]</B></LI><BLOCKQUOTE>
+c = a.ceil<BR>
+a ˆÈã‚Ì®”‚Ì‚¤‚¿Ałଂ³‚¢®”‚ðŒvŽZ‚µA‚»‚Ì’liBigDecimal ’lj‚ð•Ô‚µ‚Ü‚·B
+<CODE><PRE>
+c = BigDecimal("1.23456").ceil # ==> 2
+c = BigDecimal("-1.23456").ceil # ==> -1
+</PRE></CODE>
+
+ˆÈ‰º‚̂悤‚Ɉø”‚ð—^‚¦‚ÄA¬”“_ˆÈ‰º n+1 ˆÊ‚Ì”Žš‚ð‘€ì‚·‚邱‚Æ‚à‚Å‚«‚Ü‚·B<BR>
+n>=0 ‚È‚çA¬”“_ˆÈ‰º n+1 ˆÊ‚Ì”Žš‚ð‘€ì‚µ‚Ü‚·(­”“_ˆÈ‰º‚ðAÅ‘å n Œ…‚É‚µ‚Ü‚·)B<BR>
+ n ‚ª•‰‚̂Ƃ«‚ͬ”“_ˆÈã n Œ…–Ú‚ð‚ð‘€ì‚µ‚Ü‚·(¬”“_ˆÊ’u‚©‚ç¶‚É­‚È‚­‚Æ‚à n ŒÂ‚Ì 0 ‚ª•À‚т܂·)B<BR>
+<CODE><PRE>
+ c = BigDecimal("1.23456").ceil(4) # ==> 1.2346
+ c = BigDecimal("15.23456").ceil(-1) # ==> 20.0
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>round[(n[,b])]</B></LI><BLOCKQUOTE>
+c = a.round<BR>
+
+ƒNƒ‰ƒXƒƒ\ƒbƒh BigDecimal::mode(BigDecimal::ROUND_MODE,flag) ‚ÅŽw’肵‚½
+ROUND_MODE ‚É]‚Á‚ÄŠÛ‚ß‘€ì‚ðŽÀs‚µ‚Ü‚·B
+BigDecimal::mode(BigDecimal::ROUND_MODE,flag) ‚ʼn½‚àŽw’肹‚¸A‚©‚ÂAˆø”
+‚ðŽw’肵‚È‚¢ê‡‚Íu¬”“_ˆÈ‰º‘æˆêˆÊ‚Ì”‚ðŽlŽÌŒÜ“ü‚µ‚Ä®”iBigDecimal ’ljv‚É‚µ‚Ü‚·B<BR>
+<CODE><PRE>
+ c = BigDecimal("1.23456").round # ==> 1
+ c = BigDecimal("-1.23456").round # ==> -1
+</PRE></CODE>
+
+ˆÈ‰º‚̂悤‚Ɉø”‚ð—^‚¦‚ÄA¬”“_ˆÈ‰º n+1 ˆÊ‚Ì”Žš‚ð‘€ì‚·‚邱‚Æ‚à‚Å‚«‚Ü‚·B<BR>
+n ‚ª³‚ÌŽž‚ÍA¬”“_ˆÈ‰º n+1 ˆÊ‚Ì”Žš‚ðŠÛ‚߂܂·(­”“_ˆÈ‰º‚ðAÅ‘å n Œ…‚É‚µ‚Ü‚·)B<BR>
+n ‚ª•‰‚̂Ƃ«‚ͬ”“_ˆÈã n Œ…–Ú‚ðŠÛ‚߂܂·(¬”“_ˆÊ’u‚©‚ç¶‚É­‚È‚­‚Æ‚à n ŒÂ‚Ì 0 ‚ª•À‚т܂·)B
+<CODE><PRE>
+c = BigDecimal("1.23456").round(4) # ==> 1.2346
+c = BigDecimal("15.23456").round(-1) # ==> 20.0
+</PRE></CODE>
+‚Q”Ԗڂ̈ø”‚ðŽw’è‚·‚邯ABigDecimal#mode ‚ÌŽw’è‚𖳎‹‚µ‚ÄAŽw’肳‚ꂽ•û–@‚Å
+ŠÛ‚ß‘€ì‚ðŽÀs‚µ‚Ü‚·B
+<CODE><PRE>
+c = BigDecimal("1.23456").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.234
+c = BigDecimal("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.234
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>truncate</B></LI><BLOCKQUOTE>
+c = a.truncate<BR>
+¬”“_ˆÈ‰º‚Ì”‚ðØ‚èŽÌ‚ĂĮ”iBigDecimal ’lj‚É‚µ‚Ü‚·B<BR>
+ˆÈ‰º‚̂悤‚Ɉø”‚ð—^‚¦‚ÄA¬”“_ˆÈ‰º n+1 ˆÊ‚Ì”Žš‚ð‘€ì‚·‚邱‚Æ‚à‚Å‚«‚Ü‚·B<BR>
+n ‚ª³‚ÌŽž‚ÍA¬”“_ˆÈ‰º n+1 ˆÊ‚Ì”Žš‚ðØ‚èŽÌ‚Ă܂·(­”“_ˆÈ‰º‚ðAÅ‘å n Œ…‚É‚µ‚Ü‚·)B
+n ‚ª•‰‚̂Ƃ«‚ͬ”“_ˆÈã n Œ…–Ú‚ð‚ð‘€ì‚µ‚Ü‚·(¬”“_ˆÊ’u‚©‚ç¶‚É­‚È‚­‚Æ‚à n ŒÂ‚Ì 0 ‚ª•À‚т܂·)B<BR>
+<CODE><PRE>
+c = BigDecimal("1.23456").truncate(4) # ==> 1.2345
+c = BigDecimal("15.23456").truncate(-1) # ==> 10.0
+</PRE></CODE>
+</BLOCKQUOTE>
+
+</BLOCKQUOTE>
+<LI><B>abs</B></LI><BLOCKQUOTE>
+‚‚Ìâ‘Î’l<BR>
+c = a.abs<BR>
+
+</BLOCKQUOTE>
+<LI><B>to_i</B></LI><BLOCKQUOTE>
+­”“_ˆÈ‰º‚ðØ‚èŽÌ‚ĂĮ”‚ɕϊ·‚µ‚Ü‚·B<BR>
+i = a.to_i<BR>
+i ‚Í’l‚ɉž‚¶‚Ä Fixnum ‚© Bignum ‚ɂȂè‚Ü‚·B
+a ‚ª Infinity ‚â NaN ‚̂Ƃ«Ai ‚Í nil ‚ɂȂè‚Ü‚·B
+</BLOCKQUOTE>
+<LI><B>to_f</B></LI><BLOCKQUOTE>
+Float ƒIƒuƒWƒFƒNƒg‚ɕϊ·‚µ‚Ü‚·B
+‚æ‚è‚«‚ßׂ©‚¢’l‚ª•K—v‚È‚ç‚Î split ƒƒ\ƒbƒh‚ð—˜—p‚µ‚Ä
+‚­‚¾‚³‚¢B
+</BLOCKQUOTE>
+<LI><B>to_s[(n)]</B></LI><BLOCKQUOTE>
+•¶Žš—ñ‚ɕϊ·‚µ‚Ü‚·(ƒfƒtƒHƒ‹ƒg‚Í "0.xxxxxEn" ‚ÌŒ`‚ɂȂè‚Ü‚·jB
+<CODE><PRE>
+BigDecimal("1.23456").to_s # ==> "0.123456E1"
+</PRE></CODE>
+ˆø” n ‚ɳ‚Ì®”‚ªŽw’肳‚ꂽ‚Æ‚«‚ÍA­”“_‚Å•ª‚¯‚ç‚ê‚鶉E•”•ª‚ðA‚»‚ꂼ‚ê n Œ…–ˆ
+‚É‹ó”’‚Å‹æØ‚è‚Ü‚·B
+<CODE><PRE>
+BigDecimal("0.1234567890123456789").to_s(10) # ==> "0.1234567890 123456789E0"
+</PRE></CODE>
+ˆø” n ‚ɳ‚Ì®”‚ð•\‚·•¶Žš—ñ‚ðŽw’è‚·‚邱‚Æ‚à‚Å‚«‚Ü‚·B
+<CODE><PRE>
+BigDecimal("0.1234567890123456789").to_s("10") # ==> "0.1234567890 123456789E0"
+</PRE></CODE>
+•¶Žš—ñ‚Ìʼn‚É '+'i‚Ü‚½‚Í ' 'j‚ð•t‚¯‚邯A’l‚ª³‚Ìê‡A擪‚É '+'i‚Ü‚½‚Í ' 'j‚ª•t‚«‚Ü‚·
+i•‰‚ÌꇂÍAí‚É '-' ‚ª•t‚«‚Ü‚·BjB
+<CODE><PRE>
+BigDecimal("0.1234567890123456789").to_s(" 10") # ==> " 0.1234567890 123456789E0"
+BigDecimal("0.1234567890123456789").to_s("+10") # ==> "+0.1234567890 123456789E0"
+BigDecimal("-0.1234567890123456789").to_s("10") # ==> "-0.1234567890 123456789E0"
+</PRE></CODE>
+
+‚³‚ç‚É•¶Žš—ñ‚ÌÅŒã‚É E(‚Ü‚½‚Í e) ‚© F(‚Ü‚½‚Í f) ‚ðŽw’è‚·‚邱‚Æ‚ÅAˆÈ‰º‚̂悤‚É
+•\ަŒ`Ž®‚ð•ÏX‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·B
+<CODE><PRE>
+BigDecimal("1234567890.123456789").to_s("E") # ==> "0.1234567890123456789E10"
+BigDecimal("1234567890.123456789").to_s("F") # ==> "1234567890.123456789"
+BigDecimal("1234567890.123456789").to_s("5E") # ==> "0.12345 67890 12345 6789E10"
+BigDecimal("1234567890.123456789").to_s("5F") # ==> "12345 67890.12345 6789"
+</PRE></CODE>
+
+</BLOCKQUOTE>
+<LI><B>exponent</B></LI><BLOCKQUOTE>
+Žw”•”‚ð®”’l‚ŕԂµ‚Ü‚·B
+n = a.exponent <BR>
+‚Í a ‚Ì’l‚ª 0.xxxxxxx*10**n ‚ðˆÓ–¡‚µ‚Ü‚·B
+</BLOCKQUOTE>
+
+<LI><B>precs</B></LI><BLOCKQUOTE>
+n,m = a.precs<BR>
+a ‚Ì—LŒø”Žš (n) ‚ÆÅ‘å—LŒø”Žš (m) ‚Ì”z—ñ‚ð•Ô‚µ‚Ü‚·B
+
+</BLOCKQUOTE>
+
+<LI><B>sign</B></LI><BLOCKQUOTE>
+’l‚ª³(sign &gt; 0)A•‰(sign &lt; 0)A‚»‚Ì‘¼(sigh==0)‚Å‚ ‚é‚©‚Ìî•ñ‚ð•Ô‚µ‚Ü‚·B
+n = a.sign <BR>
+‚Æ‚µ‚½‚Æ‚« n ‚Ì’l‚Í a ‚ªˆÈ‰º‚̂Ƃ«‚ðˆÓ–¡‚µ‚Ü‚·B<BR>
+() ‚Ì’†‚Ì”Žš‚ÍAŽÀÛ‚Ì’l‚Å‚·(<A HREF="#STRUCT">u“à•”\‘¢v</A>‚ðŽQÆ)B<BR>
+n = BigDecimal::SIGN_NaN(0) : a ‚Í NaN<BR>
+n = BigDecimal::SIGN_POSITIVE_ZERO(1) : a ‚Í +0<BR>
+n = BigDecimal::SIGN_NEGATIVE_ZERO(-1) : a ‚Í -0<BR>
+n = BigDecimal::SIGN_POSITIVE_FINITE(2) : a ‚ͳ‚Ì’l<BR>
+n = BigDecimal::SIGN_NEGATIVE_FINITE(-2) : a ‚Í•‰‚Ì’l<BR>
+n = BigDecimal::SIGN_POSITIVE_INFINITE(3) : a ‚Í+Infinity<BR>
+n = BigDecimal::SIGN_NEGATIVE_INFINITE(-3) : a ‚Í-Infinity<BR>
+
+</BLOCKQUOTE>
+<LI><B>nan?</B></LI><BLOCKQUOTE>
+a.nan? ‚Í a ‚ªNaN‚̂Ƃ«^‚ð•Ô‚µ‚Ü‚·B
+</BLOCKQUOTE>
+<LI><B>infinite?</B></LI><BLOCKQUOTE>
+a.infinite? ‚Í a ‚ª+‡‚̂Ƃ« 1 A-‡‚̂Ƃ«‚Í -1A‚»‚êˆÈŠO‚̂Ƃ«‚Í nil ‚ð•Ô‚µ‚Ü‚·B
+</BLOCKQUOTE>
+<LI><B>finite?</B></LI><BLOCKQUOTE>
+a.finite? ‚Í a ‚ª‡‚Ü‚½‚Í NaN ‚łȂ¢‚Æ‚«^‚ð•Ô‚µ‚Ü‚·B
+</BLOCKQUOTE>
+
+<LI><B>zero?</B></LI><BLOCKQUOTE>
+a ‚ª 0 ‚È‚ç true ‚ɂȂè‚Ü‚·B<BR>
+c = a.zero?
+</BLOCKQUOTE>
+<LI><B>nonzero?</B></LI><BLOCKQUOTE>
+a ‚ª 0 ‚È‚ç nilA0 ˆÈŠO‚È‚ç a ‚»‚Ì‚à‚Ì‚ª•Ô‚è‚Ü‚·B<BR>
+c = a.nonzero?
+
+</BLOCKQUOTE>
+<LI><B>split</B></LI><BLOCKQUOTE>
+BigDecimal ’l‚ð 0.xxxxxxx*10**n ‚Æ•\Œ»‚µ‚½‚Æ‚«‚ÉA•„†iNaN‚̂Ƃ«‚Í
+0A‚»‚êˆÈŠO‚Í+1‚©-1‚ɂȂè‚Ü‚·jA
+‰¼”•”•ª‚Ì•¶Žš—ñi"xxxxxxx"j‚ÆAŠî”i10jAX‚ÉŽw” n ‚ð”z—ñ‚Å
+•Ô‚µ‚Ü‚·B<BR>
+a=BigDecimal::new("3.14159265")<BR>
+f,x,y,z = a.split<BR>
+‚Æ‚·‚邯Af=+1Ax="314159265"Ay=10Az=1‚ɂȂè‚Ü‚·B<BR>
+]‚Á‚ÄA<BR>
+s = "0."+x<BR>
+b = f*(s.to_f)*(y**z)<BR>
+‚Å Float ‚ɕϊ·‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·B
+</BLOCKQUOTE>
+<LI><B>inspect</B></LI><BLOCKQUOTE>
+ƒfƒoƒbƒOo—͂Ɏg—p‚³‚ê‚Ü‚·B<BR>
+p a=BigDecimal::new("3.14",10)<BR>
+‚Æ‚·‚邯A[0x112344:'0.314E1',4(12)]‚̂悤‚Éo—Í‚³‚ê‚Ü‚·B
+ʼn‚Ì16i”‚̓IƒuƒWƒFƒNƒg‚̃AƒhƒŒƒXAŽŸ‚Ì '0.314E1' ‚Í’lA
+ŽŸ‚Ì4‚ÍŒ»Ý‚Ì—LŒøŒ…”(•\ަ‚æ‚èŽáб‘å‚«‚¢‚±‚Æ‚ª‚ ‚è‚Ü‚·)A
+ÅŒã‚̓IƒuƒWƒFƒNƒg‚ªŽæ‚蓾‚éő包”‚ɂȂè‚Ü‚·B
+</BLOCKQUOTE>
+<LI><B>**</B></LI><BLOCKQUOTE>
+a ‚Ì n æ‚ðŒvŽZ‚µ‚Ü‚·B‚Ž‚Í®”B<BR>
+c = a ** n<BR>
+Œ‹‰Ê‚Æ‚µ‚Ä c ‚Ì—LŒøŒ…‚Í a ‚Ì n ”{ˆÈã‚ɂȂé‚̂ŒˆÓB
+</BLOCKQUOTE>
+<LI><B>power</B></LI><BLOCKQUOTE>
+** ‚Æ“¯‚¶‚ÅAa ‚Ì n æ‚ðŒvŽZ‚µ‚Ü‚·B‚Ž‚Í®”B<BR>
+c = a.power(n)<BR>
+Œ‹‰Ê‚Æ‚µ‚Ä c ‚Ì—LŒøŒ…‚Í a ‚Ì n ”{ˆÈã‚ɂȂé‚̂ŒˆÓB
+</BLOCKQUOTE>
+<LI><B>sqrt</B></LI><BLOCKQUOTE>
+a‚Ì—LŒøŒ… n Œ…‚Ì•½•ûªin ‚Ì•½•ûª‚ł͂ ‚è‚Ü‚¹‚ñj‚ð
+ƒjƒ…[ƒgƒ“–@‚ÅŒvŽZ‚µ‚Ü‚·B<BR>
+c = a.sqrt(n)<BR>
+</BLOCKQUOTE>
+
+<LI><B>divmod,quo,modulo,%,remainder</B></LI><BLOCKQUOTE>
+Úׂ͑Ήž‚·‚é Float ‚ÌŠeƒƒ\ƒbƒh‚ðŽQÆ‚µ‚ĉº‚³‚¢B
+</BLOCKQUOTE>
+
+<LI><B>&lt=&gt</B></LI><BLOCKQUOTE>
+a==b ‚È‚ç 0Aa &gt b ‚È‚ç 1Aa &lt b ‚È‚ç -1 ‚ɂȂè‚Ü‚·B<BR>
+c = a &lt=&gt b
+</BLOCKQUOTE>
+</UL>
+Œã‚ÍA“Ç‚ñ‚ÅŽš‚Ì”@‚­‚Å‚·B<BR>
+<UL>
+<LI><B>==</B></LI>
+<LI><B>===</B></LI>
+u==v‚Æ“¯‚¶‚Å‚·‚ª case •¶‚ÅŽg—p‚³‚ê‚Ü‚·B
+<LI><B>!=</B></LI>
+<LI><B>&lt</B></LI>
+<LI><B>&lt=</B></LI>
+<LI><B>&gt</B></LI>
+<LI><B>&gt=</B></LI>
+</UL>
+
+<H3>coerce‚ɂ‚¢‚Ä</H3>
+BigDecimal ƒIƒuƒWƒFƒNƒg‚ªŽZp‰‰ŽZŽq‚̶‚É‚ ‚邯‚«‚ÍABigDecimal ƒIƒuƒWƒFƒNƒg‚ª
+‰E‚É‚ ‚éƒIƒuƒWƒFƒNƒg‚ð(•K—v‚È‚ç) BigDecimal ‚ɕϊ·‚µ‚Ä‚©‚çŒvŽZ‚µ‚Ü‚·B
+]‚Á‚ÄABigDecimal ƒIƒuƒWƒFƒNƒgˆÈŠO‚Å‚à”’l‚ðˆÓ–¡‚·‚é‚à‚̂Ȃç‰E‚É’u‚¯‚Î
+‰‰ŽZ‚͉”\‚Å‚·B<BR>
+‚½‚¾‚µA•¶Žš—ñ‚Íi’Êíj”’l‚ÉŽ©“®•ÏŠ·‚·‚邱‚Ƃ͂ł«‚Ü‚¹‚ñB
+•¶Žš—ñ‚ð”’l‚ÉŽ©“®•ÏŠ·‚µ‚½‚¢ê‡‚Í bigfloat.c ‚Ì
+u/* #define ENABLE_NUMERIC_STRING */v‚̃Rƒƒ“ƒg‚ðŠO‚µ‚Ä‚©‚çA
+ăRƒ“ƒpƒCƒ‹AăCƒ“ƒXƒg[ƒ‹‚·‚é•K—v‚ª‚ ‚è‚Ü‚·B
+•¶Žš—ñ‚Å”’l‚ð—^‚¦‚éꇂ͒ˆÓ‚ª•K—v‚Å‚·B”’l‚ɕϊ·‚Å‚«‚È‚¢•¶Žš‚ª‚ ‚邯A
+’P‚ɕϊ·‚ðŽ~‚߂邾‚¯‚ŃGƒ‰[‚ɂ͂Ȃè‚Ü‚¹‚ñB"10XX"‚È‚ç‚P‚OA"XXXX"‚Í‚O
+‚ƈµ‚í‚ê‚Ü‚·B<BR>
+<CODE><PRE>
+ a = BigDecimal.E(20)
+ c = a * "0.123456789123456789123456789" # •¶Žš‚ð BigDecimal ‚ɕϊ·‚µ‚Ä‚©‚çŒvŽZ
+</PRE></CODE>
+–³ŒÀ‘å‚â”ñ”‚ð•\‚·•¶Žš‚Æ‚µ‚ÄA"Infinity"A"+Infinity"A"-Infinity"A"NaN"
+‚àŽg—p‚Å‚«‚Ü‚·(‘å•¶ŽšE¬•¶Žš‚ð‹æ•Ê‚µ‚Ü‚·)B‚½‚¾‚µAmode ƒƒ\ƒbƒh‚Å false ‚ð
+Žw’肵‚½ê‡‚Í—áŠO‚ª”­¶‚µ‚Ü‚·B
+<BR>
+‚Ü‚½ABigDecimalƒNƒ‰ƒX‚Í coerceiRuby–{ŽQÆj‚ðƒTƒ|[ƒg‚µ‚Ä‚¢‚Ü‚·B
+]‚Á‚ÄABigDecimal ƒIƒuƒWƒFƒNƒg‚ª‰E‚É‚ ‚éꇂà‘å’ï‚Í‘åä•v‚Å‚·B
+‚½‚¾AŒ»Ý‚Ì Ruby ƒCƒ“ƒ^ƒvƒŠƒ^‚ÌŽd—lãA•¶Žš—ñ‚ª¶‚É‚ ‚邯ŒvŽZ‚Å‚«‚Ü‚¹‚ñB<BR>
+<CODE><PRE>
+ a = BigDecimal.E(20)
+ c = "0.123456789123456789123456789" * a # ƒGƒ‰[
+</PRE></CODE>
+•K—v«‚ª‚ ‚邯‚ÍŽv‚¢‚Ü‚¹‚ñ‚ªA‚Ç‚¤‚µ‚Ä‚à‚ÆŒ¾‚¤l‚Í
+ String ƒIƒuƒWƒFƒNƒg‚ðŒp³‚µ‚½V‚½‚ȃNƒ‰ƒX‚ð쬂µ‚Ä‚©‚çA
+‚»‚̃Nƒ‰ƒX‚Å coerce ‚ðƒTƒ|[ƒg‚µ‚Ä‚­‚¾‚³‚¢B
+
+<hr>
+<A NAME="#UNDEF">
+<H2>–³ŒÀA”ñ”Aƒ[ƒ‚̈µ‚¢</H2>
+u–³ŒÀv‚Ƃ͕\Œ»‚Å‚«‚È‚¢‚­‚ç‚¢‘å‚«‚È”‚Å‚·B“Á•ʂɈµ‚¤‚½‚ß‚É
+ +Infinityi³‚Ì–³ŒÀ‘åj‚â -Infinityi•‰‚Ì–³ŒÀ‘åj‚Æ‚¢‚¤
+‚悤‚É•\‹L‚³‚ê‚Ü‚·B
+–³ŒÀ‚Í 1.0/0.0 ‚̂悤‚Ƀ[ƒ‚ÅŠ„‚邿‚¤‚ÈŒvŽZ‚ð‚µ‚½‚Æ‚«‚ɶ¬‚³‚ê‚Ü‚·B
+<BR><BR>
+u”ñ”v‚Í 0.0/0.0 ‚â Infinity-Infinity “™‚ÌŒ‹‰Ê‚ª’è‹`‚Å‚«‚È‚¢
+ŒvŽZ‚ð‚µ‚½‚Æ‚«‚ɶ¬‚³‚ê‚Ü‚·B”ñ”‚Í NaNiNot a Numberj‚Æ•\‹L‚³‚ê‚Ü‚·B
+NaN ‚ðŠÜ‚ÞŒvŽZ‚Í‘S‚Ä NaN ‚ɂȂè‚Ü‚·B‚Ü‚½ NaN ‚ÍŽ©•ª‚àŠÜ‚ß‚ÄA‚Ç‚ñ‚È”
+‚Æ‚àˆê’v‚µ‚Ü‚¹‚ñB
+<BR><BR>
+ƒ[ƒ‚Í +0.0 ‚Æ -0.0 ‚ª‘¶Ý‚µ‚Ü‚·B‚½‚¾‚µA+0.0==-0.0 ‚Í true ‚Å‚·B
+<BR><BR>
+InfinityANaNA +0.0 ‚Æ -0.0 “™‚ðŠÜ‚ñ‚¾ŒvŽZŒ‹‰Ê‚Í‘g‚݇‚킹‚É
+‚æ‚è•¡ŽG‚Å‚·B‹»–¡‚Ì‚ ‚él‚ÍAˆÈ‰º‚̃vƒƒOƒ‰ƒ€‚ðŽÀs‚µ‚ÄŒ‹‰Ê‚ð
+Šm”F‚µ‚Ä‚­‚¾‚³‚¢iŒ‹‰Ê‚ɂ‚¢‚ÄA‹^–â‚âŠÔˆá‚¢‚ð”­Œ©‚³‚ꂽ•û‚Í
+‚¨’m‚点Šè‚¢‚Ü‚·jB
+
+<PRE>
+<CODE>
+require "bigdecimal"
+
+aa = %w(1 -1 +0.0 -0.0 +Infinity -Infinity NaN)
+ba = %w(1 -1 +0.0 -0.0 +Infinity -Infinity NaN)
+opa = %w(+ - * / <=> > >= < == != <=)
+
+for a in aa
+ for b in ba
+ for op in opa
+ x = BigDecimal::new(a)
+ y = BigDecimal::new(b)
+ eval("ans= x #{op} y;print a,' ',op,' ',b,' ==> ',ans.to_s,\"\n\"")
+ end
+ end
+end
+</CODE>
+</PRE>
+
+<hr>
+<A NAME="#STRUCT">
+<H2>“à•”\‘¢</H2>
+BigDecimal“à•”‚Å•‚“®¬”“_‚Í\‘¢‘Ì(Real)‚Å•\Œ»‚³‚ê‚Ü‚·B
+‚»‚Ì‚¤‚¿‰¼”•”‚Í unsigned long ‚Ì”z—ñ(ˆÈ‰º‚Ì\‘¢‘Ì—v‘ffrac)‚ÅŠÇ—‚³‚ê‚Ü‚·B
+ŠT”O“I‚É‚ÍAˆÈ‰º‚̂悤‚ɂȂè‚Ü‚·B<BR><BR>
+ <•‚“®¬”“_”> = 0.xxxxxxxxx*BASE**n<BR><BR>
+‚±‚±‚ÅAx‚͉¼”•”‚ð•\‚·”ŽšABASE‚ÍŠî”i‚P‚Oi‚È‚ç‚P‚OjAn‚ÍŽw”•”‚ð•\‚·
+®”’l‚Å‚·BBASE‚ª‘å‚«‚¢‚Ù‚ÇA‘å‚«‚È”’l‚ª•\Œ»‚Å‚«‚Ü‚·B‚‚܂èA”z—ñ‚̃TƒCƒY‚ð
+­‚È‚­‚Å‚«‚Ü‚·BBASE‚͑傫‚¢‚Ù‚Ç“s‡‚ª‚æ‚¢‚킯‚Å‚·‚ªAƒfƒoƒbƒO‚Ì‚â‚è‚â‚·‚³‚Ȃǂð
+l—¶‚µ‚ÄA10000‚ɂȂÁ‚Ä‚¢‚Ü‚·iBASE‚ÍVpInit()ŠÖ”‚ÅŽ©“®“I‚ÉŒvŽZ‚µ‚Ü‚·jB
+‚±‚ê‚ÍA32ƒrƒbƒg®”‚Ìꇂł·B64ƒrƒbƒg®”‚Ìꇂ͂à‚Á‚Ƒ傫‚È’l‚ɂȂè‚Ü‚·B
+Žc”O‚È‚ª‚çA64ƒrƒbƒg®”‚ł̃eƒXƒg‚͂܂¾‚â‚Á‚Ä‚¢‚Ü‚¹‚ñi‚à‚µA‚â‚ç‚ꂽ•û‚ª‚¢‚ê‚Î
+Œ‹‰Ê‚ð‹³‚¦‚Ä‚¢‚½‚¾‚¯‚ê‚΂ ‚肪‚½‚¢‚Å‚·jB
+BASE‚ª10000‚̂Ƃ«‚ÍAˆÈ‰º‚̉¼”•”‚Ì”z—ñ(frac)‚ÌŠe—v‘f‚É‚ÍÅ‘å‚Å‚SŒ…‚Ì
+”Žš‚ªŠi”[‚³‚ê‚Ü‚·B<BR><BR>
+•‚“®¬”“_\‘¢‘Ì(Real)‚͈ȉº‚̂悤‚ɂȂÁ‚Ä‚¢‚Ü‚·B
+<BR>
+<CODE><PRE>
+ typedef struct {
+ unsigned long MaxPrec; // ő帓x(frac[]‚Ì”z—ñƒTƒCƒY)
+ unsigned long Prec; // ¸“x(frac[]‚ÌŽg—pƒTƒCƒY)
+ short sign; // ˆÈ‰º‚̂悤‚É•„†“™‚Ìó‘Ô‚ð’è‹`‚µ‚Ü‚·B
+ // ==0 : NaN
+ // 1 : +0
+ // -1 : -0
+ // 2 : ³‚Ì’l
+ // -2 : •‰‚Ì’l
+ // 3 : +Infinity
+ // -3 : -Infinity
+ unsigned short flag; // ŠeŽí‚̧Œäƒtƒ‰ƒbƒO
+ int exponent; // Žw”•”‚Ì’l(‰¼”•”*BASE**exponent)
+ unsigned long frac[1]; // ‰¼”•”‚Ì”z—ñ(‰Â•Ï)
+ } Real;
+</CODE></PRE>
+—Ⴆ‚Î 1234.56784321 ‚Æ‚¢‚¤”Žš‚Í(BASE=10000‚È‚ç)<BR>
+<PRE>
+ 0.1234 5678 4321*(10000)**1
+</PRE>
+‚Å‚·‚©‚ç frac[0]=1234Afrac[1]=5678Afrac[2]=4321A
+Prec=3Asign=2Aexponent=1 ‚ƂȂè‚Ü‚·BMaxPrec‚Í
+Prec ‚æ‚è‘å‚«‚¯‚ê‚΂¢‚­‚Â‚Å‚à‚©‚Ü‚¢‚Ü‚¹‚ñBflag ‚Ì
+Žg—p•û–@‚ÍŽÀ‘•‚Ɉˑ¶‚µ‚Ä“à•”‚ÅŽg—p‚³‚ê‚Ü‚·B
+
+<hr>
+<A NAME="#BASE">
+<H2>2i‚Æ10i</H2>
+BigDecimal ‚Í <•‚“®¬”“_”> = 0.xxxxxxxxx*10**n ‚Æ‚¢‚¤10iŒ`Ž®‚Å”’l‚ð•ÛŽ‚µ‚Ü‚·B
+‚µ‚©‚µAŒvŽZ‹@‚Ì•‚“®¬”“_”‚Ì“à•”•\Œ»‚ÍAŒ¾‚¤‚܂łà‚È‚­ <•‚“®¬”“_”> = 0.bbbbbbbb*2**n ‚Æ‚¢‚¤
+2iŒ`Ž®‚ª•’ʂł·(x ‚Í 0 ‚©‚ç 9 ‚Ü‚ÅAb ‚Í 0 ‚© 1 ‚Ì”Žš)B
+BigDecimal ‚ª‚È‚º10i‚Ì“à•”•\Œ»Œ`Ž®‚ðÌ—p‚µ‚½‚Ì‚©‚ðˆÈ‰º‚Éà–¾‚µ‚Ü‚·B
+<H4>10i‚̃ƒŠƒbƒg</H4>
+<DL>
+<DT>ƒfƒoƒbƒO‚Ì‚µ‚â‚·‚³
+<DD>‚Ü‚¸AƒvƒƒOƒ‰ƒ€ì¬‚ªŠy‚Å‚·Bfrac[0]=1234Afrac[1]=5678Afrac[2]=4321A
+exponent=1Asign=2 ‚Ȃ甒l‚ª 1234.56784321 ‚Å‚ ‚é‚̂͌©‚ê‚Î’¼‚®‚É•ª‚©‚è‚Ü‚·B
+
+<DT>10i•\‹L‚³‚ꂽ”’l‚È‚çŠmŽÀ‚É“à•”•\Œ»‚ɕϊ·‚Å‚«‚é
+<DD>—Ⴆ‚ÎAˆÈ‰º‚̂悤‚ȃvƒƒOƒ‰ƒ€‚Í‘S‚­Œë·–³‚µ‚Å
+ŒvŽZ‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·BˆÈ‰º‚Ì—á‚ÍAˆês‚Ɉê‚‚̔’l
+‚ª‘‚¢‚Ä‚ ‚éƒtƒ@ƒCƒ‹ file ‚̇Œv”’l‚ð‹‚ß‚é‚à‚̂ł·B
+<CODE><PRE>
+ file = File::open(....,"r")
+ s = BigDecimal::new("0")
+ while line = file.gets
+ s = s + line
+ end
+</PRE></CODE>
+‚±‚Ì—á‚ð2i”‚Å‚â‚邯Œë·‚ª“ü‚螂މ”\«‚ª‚ ‚è‚Ü‚·B
+—Ⴆ‚Î 0.1 ‚ð2i‚Å•\Œ»‚·‚邯 0.1 = b1*2**(-1)+b1*2**(-2)+b3*2**(-3)+b4*2**(-4)....
+‚Æ–³ŒÀ‚É‘±‚¢‚Ä‚µ‚Ü‚¢‚Ü‚·(b1=0,b2=0,b3=0,b4=1...)B‚±‚±‚Å bn(n=1,2,3,...) ‚Í
+2i‚ð•\Œ»‚·‚é 0 ‚© 1 ‚Ì”Žš—ñ‚Å‚·B]‚Á‚ÄA‚Ç‚±‚©‚őł¿Ø‚é•K—v‚ª‚ ‚è‚Ü‚·B
+‚±‚±‚ŕϊ·Œë·‚ª“ü‚è‚Ü‚·B‚à‚¿‚ë‚ñA‚±‚ê‚ðÄ“x10i•\‹L‚É‚µ‚Ĉóü‚·‚邿‚¤‚È
+ꇂ͓K؂Ȋۂߑ€ìiŽlŽÌŒÜ“üj‚É‚æ‚Á‚ÄÄ‚Ñ "0.1" ‚Æ•\ަ‚³‚ê‚Ü‚·B‚µ‚©‚µA
+“à•”‚łͳŠm‚È 0.1 ‚ł͂ ‚è‚Ü‚¹‚ñB
+
+<DT>—LŒøŒ…”‚Í—LŒÀ‚Å‚ ‚éi‚‚܂莩“®Œˆ’è‚Å‚«‚éj
+<DD>0.1 ‚ð•\Œ»‚·‚邽‚߂̗̈æ‚Í‚½‚Á‚½ˆê‚‚̔z—ñ—v‘fi frac[0]=1 j‚Åς݂܂·B
+”z—ñ—v‘f‚Ì”‚Í10i”’l‚©‚玩“®“I‚ÉŒˆ’è‚Å‚«‚Ü‚·B‚±‚ê‚ÍA‰Â•Ï’·•‚“®¬”“_‰‰ŽZ‚Å‚Í
+‘厖‚È‚±‚Ƃł·B‹t‚É 0.1 ‚ð2i•\Œ»‚µ‚½‚Æ‚«‚É‚Í2i‚Ì—LŒøŒ…‚ð‚¢‚­‚‚ɂ·‚é‚Ì‚© 0.1 ‚ð
+Œ©‚½‚¾‚¯‚ł͌ˆ’è‚Å‚«‚Ü‚¹‚ñB
+</DL>
+
+<H3>10i‚̃fƒƒŠƒbƒg</H3>
+ŽÀ‚Í¡‚܂ł̃ƒŠƒbƒg‚ÍA‚»‚̂܂܃fƒƒŠƒbƒg‚É‚à‚È‚è‚Ü‚·B
+‚»‚à‚»‚àA10i‚ð2iA2i‚ð10i‚ɕϊ·‚·‚邿‚¤‚È‘€ì‚͕ϊ·Œë·
+‚𔺂¤ê‡‚ð‰ñ”ð‚·‚é‚±‚Ƃ͂ł«‚Ü‚¹‚ñB
+Šù‚ÉŒvŽZ‹@“à•”‚ÉŽæ‚螂܂ꂽ2i”’l‚ð BigDecimal ‚Ì“à•”•\Œ»‚É
+•ÏŠ·‚·‚邯‚«‚ɂ͌뷂ª”ð‚¯‚ç‚ê‚È‚¢ê‡‚ª‚ ‚è‚Ü‚·B
+
+<H3>ʼn‚͉½‚©H</H3>
+Ž©•ª‚ÅŒvŽZ‚·‚邯‚«‚ɂ킴‚í‚´2i”‚ðŽg‚¤l‚͋ɂ߂Ă܂ê‚Å‚·B
+ŒvŽZ‹@‚Ƀf[ƒ^‚ð“ü—Í‚·‚邯‚«‚à‚Ù‚Æ‚ñ‚Ç‚Ìê‡A
+10i”‚Å“ü—Í‚µ‚Ü‚·B‚»‚ÌŒ‹‰ÊAdouble “™‚ÌŒvŽZ‹@“à•”
+•\Œ»‚Íʼn‚©‚çŒë·‚ª“ü‚Á‚Ä‚¢‚éꇂª‚ ‚è‚Ü‚·B
+BigDecimal ‚̓†[ƒU“ü—Í‚ðŒë·–³‚µ‚ÅŽæ‚螂ނ±‚Æ‚ª‚Å‚«‚Ü‚·B
+ƒfƒoƒbƒO‚ª‚µ‚â‚·‚¢‚Ì‚ÆAƒf[ƒ^“ǂ݂±‚ÝŽž‚Ɍ뷂ª“ü‚ç‚È‚¢
+‚Æ‚¢‚¤‚Ì‚ªŽÀۂ̃ƒŠƒbƒg‚Å‚·B
+
+<hr>
+<A NAME="#PREC">
+<H2>ŒvŽZ¸“x‚ɂ‚¢‚Ä</H2>
+c = a op b ‚Æ‚¢‚¤ŒvŽZ(op ‚Í + - * /)‚ð‚µ‚½‚Æ‚«‚Ì“®ì‚Í
+ˆÈ‰º‚̂悤‚ɂȂè‚Ü‚·B<BR><BR>
+‚PDæŽZ‚Í(a ‚Ì—LŒøŒ…”)+(b ‚Ì—LŒøŒ…”)A
+œŽZ‚Í(a ‚ÌÅ‘å—LŒøŒ…”)+(b ‚ÌÅ‘å—LŒøŒ…”)•ª‚Ìő包”iŽÀÛ‚ÍA—]—T‚ðŽ‚Á‚ÄA
+‚à‚¤­‚µ‘å‚«‚­‚È‚è‚Ü‚·j‚ðŽ‚Â•Ï” c ‚ðV‚½‚ɶ¬‚µ‚Ü‚·B
+‰ÁŒ¸ŽZ‚ÌꇂÍAŒë·‚ªo‚È‚¢‚¾‚¯‚̸“x‚ðŽ‚Â c ‚𶬂µ‚Ü‚·B—Ⴆ‚Î
+ c = 0.1+0.1*10**(-100) ‚̂悤‚Èê‡Ac ‚̸“x‚Í‚P‚O‚OŒ…ˆÈã‚̸“x‚ð
+Ž‚Â‚æ‚¤‚ɂȂè‚Ü‚·B
+<BR><BR>
+‚QDŽŸ‚É c = a op b ‚ÌŒvŽZ‚ðŽÀs‚µ‚Ü‚·B<BR><BR>
+‚±‚̂悤‚ÉA‰ÁŒ¸ŽZ‚ÆæŽZ‚Å‚Ì c ‚Í•K‚¸uŒë·‚ªo‚È‚¢v‚¾‚¯‚̸“x‚ð
+Ž‚Á‚ͬ‚³‚ê‚Ü‚·(BigDecimal.limit ‚ðŽw’肵‚È‚¢ê‡)B
+œŽZ‚Í(a ‚ÌÅ‘å—LŒøŒ…”)+(b ‚ÌÅ‘å—LŒøŒ…”)•ª‚Ìő包”
+‚ðŽ‚Â c ‚ª¶¬‚³‚ê‚Ü‚·‚ªAc = 1.0/3.0 ‚̂悤‚ÈŒvŽZ‚Å–¾‚ç‚©‚Ȃ悤‚ÉA
+ c ‚Ìő帓x‚ð’´‚¦‚邯‚±‚ë‚ÅŒvŽZ‚ª‘Å‚¿Ø‚ç‚ê‚éꇂª‚ ‚è‚Ü‚·B<BR><BR>
+‚¢‚¸‚ê‚É‚¹‚æAc ‚Ìő帓x‚Í a ‚â b ‚æ‚è‘å‚«‚­‚È‚è‚Ü‚·‚̂Šc ‚ª•K—v‚Æ‚·‚é
+ƒƒ‚ƒŠ[—̈æ‚͑傫‚­‚Ȃ邱‚ƂɒˆÓ‚µ‚ĉº‚³‚¢B
+<BR><BR>
+’ˆÓFu+,-,*,/v‚ł͌‹‰Ê‚̸“xi—LŒøŒ…”j‚ðŽ©•ª‚ÅŽw’è‚Å‚«‚Ü‚¹‚ñB
+¸“x‚ðƒRƒ“ƒgƒ[ƒ‹‚µ‚½‚¢ê‡‚ÍAˆÈ‰º‚̃Cƒ“ƒXƒ^ƒ“ƒXƒƒ\ƒbƒh‚ðŽg—p‚µ‚Ü‚·B<BR>
+<UL>
+<LI>add,sub,mult,div</LI><BLOCKQUOTE>
+‚±‚ê‚ç‚̃ƒ\ƒbƒh‚Íæ“ª(Ŷ)‚Ì”Žš‚©‚ç‚ÌŒ…”‚ðŽw’è‚Å‚«‚Ü‚·B
+<CODE><PRE>
+ BigDecimal("2").div(3,12) # 2.0/3.0 => 0.6666666666 67E0
+</PRE></CODE>
+</BLOCKQUOTE>
+<LI>truncate,round,ceil,floor</LI><BLOCKQUOTE>
+‚±‚ê‚ç‚̃ƒ\ƒbƒh‚ͬ”“_‚©‚ç‚Ì‘Š‘ÎˆÊ’u‚ðŽw’肵‚ÄŒ…”‚ðŒˆ’è‚µ‚Ü‚·B
+<CODE><PRE>
+ BigDecimal("6.66666666666666").round(12) # => 0.6666666666 667E1
+</PRE></CODE>
+</BLOCKQUOTE>
+</UL>
+<H3>Ž©•ª‚Ÿ“x‚ðƒRƒ“ƒgƒ[ƒ‹‚µ‚½‚¢ê‡</H3>
+Ž©•ª‚Ÿ“x(—LŒøŒ…”)‚ðƒRƒ“ƒgƒ[ƒ‹‚µ‚½‚¢ê‡‚Í addAsubAmultAdiv “™‚̃ƒ\ƒbƒh
+‚ªŽg—p‚Å‚«‚Ü‚·B
+ˆÈ‰º‚̉~Žü—¦‚ðŒvŽZ‚·‚éƒvƒƒOƒ‰ƒ€—á‚̂悤‚ÉA
+‹‚߂錅”‚ÍŽ©•ª‚ÅŽw’è‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚·B
+<BR><BR>
+<CODE><PRE>
+#!/usr/local/bin/ruby
+
+require "bigdecimal"
+#
+# Calculates 3.1415.... (the number of times that a circle's diameter
+# will fit around the circle) using J. Machin's formula.
+#
+def big_pi(sig) # sig: Number of significant figures
+ exp = -sig
+ pi = BigDecimal::new("0")
+ two = BigDecimal::new("2")
+ m25 = BigDecimal::new("-0.04")
+ m57121 = BigDecimal::new("-57121")
+
+ u = BigDecimal::new("1")
+ k = BigDecimal::new("1")
+ w = BigDecimal::new("1")
+ t = BigDecimal::new("-80")
+ while (u.nonzero? && u.exponent >= exp)
+ t = t*m25
+ u = t.div(k,sig)
+ pi = pi + u
+ k = k+two
+ end
+
+ u = BigDecimal::new("1")
+ k = BigDecimal::new("1")
+ w = BigDecimal::new("1")
+ t = BigDecimal::new("956")
+ while (u.nonzero? && u.exponent >= exp )
+ t = t.div(m57121,sig)
+ u = t.div(k,sig)
+ pi = pi + u
+ k = k+two
+ end
+ pi
+end
+
+if $0 == __FILE__
+ if ARGV.size == 1
+ print "PI("+ARGV[0]+"):\n"
+ p big_pi(ARGV[0].to_i)
+ else
+ print "TRY: ruby pi.rb 1000 \n"
+ end
+end
+
+</PRE></CODE>
+<HR>
+<FONT size=2>
+<I>
+<A HREF="http://www.tinyforest.gr.jp">
+¬—Ñ –ΗY
+</A>
+(E-Mail:<A HREF="mailto:shigeo@tinyforest.gr.jp">&ltshigeo@tinyforest.gr.jp&gt</U></A>)
+</I>
+</FONT>
+</TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>
diff --git a/ext/bigdecimal/depend b/ext/bigdecimal/depend
new file mode 100644
index 0000000000..402cae95dd
--- /dev/null
+++ b/ext/bigdecimal/depend
@@ -0,0 +1 @@
+bigdecimal.o: bigdecimal.c bigdecimal.h $(hdrdir)/ruby.h
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
new file mode 100644
index 0000000000..a68a656044
--- /dev/null
+++ b/ext/bigdecimal/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('bigdecimal')
diff --git a/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
new file mode 100644
index 0000000000..34a60ae67a
--- /dev/null
+++ b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
@@ -0,0 +1,63 @@
+#
+# jacobian.rb
+#
+# Computes Jacobian matrix of f at x
+#
+module Jacobian
+ def isEqual(a,b,zero=0.0,e=1.0e-8)
+ aa = a.abs
+ bb = b.abs
+ if aa == zero && bb == zero then
+ true
+ else
+ if ((a-b)/(aa+bb)).abs < e then
+ true
+ else
+ false
+ end
+ end
+ end
+
+ def dfdxi(f,fx,x,i)
+ nRetry = 0
+ n = x.size
+ xSave = x[i]
+ ok = 0
+ ratio = f.ten*f.ten*f.ten
+ dx = x[i].abs/ratio
+ dx = fx[i].abs/ratio if isEqual(dx,f.zero,f.zero,f.eps)
+ dx = f.one/f.ten if isEqual(dx,f.zero,f.zero,f.eps)
+ until ok>0 do
+ s = f.zero
+ deriv = []
+ if(nRetry>100) then
+ raize "Singular Jacobian matrix. No change at x[" + i.to_s + "]"
+ end
+ dx = dx*f.two
+ x[i] += dx
+ fxNew = f.values(x)
+ for j in 0...n do
+ if !isEqual(fxNew[j],fx[j],f.zero,f.eps) then
+ ok += 1
+ deriv <<= (fxNew[j]-fx[j])/dx
+ else
+ deriv <<= f.zero
+ end
+ end
+ x[i] = xSave
+ end
+ deriv
+ end
+
+ def jacobian(f,fx,x)
+ n = x.size
+ dfdx = Array::new(n*n)
+ for i in 0...n do
+ df = dfdxi(f,fx,x,i)
+ for j in 0...n do
+ dfdx[j*n+i] = df[j]
+ end
+ end
+ dfdx
+ end
+end
diff --git a/ext/bigdecimal/lib/bigdecimal/ludcmp.rb b/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
new file mode 100644
index 0000000000..1d5d3170cc
--- /dev/null
+++ b/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
@@ -0,0 +1,77 @@
+#
+# ludcmp.rb
+#
+module LUSolve
+ def ludecomp(a,n,zero=0,one=1)
+ prec = BigDecimal.limit(nil)
+ ps = []
+ scales = []
+ for i in 0...n do # pick up largest(abs. val.) element in each row.
+ ps <<= i
+ nrmrow = zero
+ ixn = i*n
+ for j in 0...n do
+ biggst = a[ixn+j].abs
+ nrmrow = biggst if biggst>nrmrow
+ end
+ if nrmrow>zero then
+ scales <<= one.div(nrmrow,prec)
+ else
+ raise "Singular matrix"
+ end
+ end
+ n1 = n - 1
+ for k in 0...n1 do # Gaussian elimination with partial pivoting.
+ biggst = zero;
+ for i in k...n do
+ size = a[ps[i]*n+k].abs*scales[ps[i]]
+ if size>biggst then
+ biggst = size
+ pividx = i
+ end
+ end
+ raise "Singular matrix" if biggst<=zero
+ if pividx!=k then
+ j = ps[k]
+ ps[k] = ps[pividx]
+ ps[pividx] = j
+ end
+ pivot = a[ps[k]*n+k]
+ for i in (k+1)...n do
+ psin = ps[i]*n
+ a[psin+k] = mult = a[psin+k].div(pivot,prec)
+ if mult!=zero then
+ pskn = ps[k]*n
+ for j in (k+1)...n do
+ a[psin+j] -= mult.mult(a[pskn+j],prec)
+ end
+ end
+ end
+ end
+ raise "Singular matrix" if a[ps[n1]*n+n1] == zero
+ ps
+ end
+
+ def lusolve(a,b,ps,zero=0.0)
+ prec = BigDecimal.limit(nil)
+ n = ps.size
+ x = []
+ for i in 0...n do
+ dot = zero
+ psin = ps[i]*n
+ for j in 0...i do
+ dot = a[psin+j].mult(x[j],prec) + dot
+ end
+ x <<= b[ps[i]] - dot
+ end
+ (n-1).downto(0) do |i|
+ dot = zero
+ psin = ps[i]*n
+ for j in (i+1)...n do
+ dot = a[psin+j].mult(x[j],prec) + dot
+ end
+ x[i] = (x[i]-dot).div(a[psin+i],prec)
+ end
+ x
+ end
+end
diff --git a/ext/bigdecimal/lib/bigdecimal/math.rb b/ext/bigdecimal/lib/bigdecimal/math.rb
new file mode 100644
index 0000000000..7b3f46ed1a
--- /dev/null
+++ b/ext/bigdecimal/lib/bigdecimal/math.rb
@@ -0,0 +1,196 @@
+#
+# Contents:
+# sqrt(x, prec)
+# sin (x, prec)
+# cos (x, prec)
+# atan(x, prec) Note: |x|<1, x=0.9999 may not converge.
+# exp (x, prec)
+# log (x, prec)
+# PI (prec)
+# E (prec) == exp(1.0,prec)
+#
+# where:
+# x ... BigDecimal number to be computed.
+# |x| must be small enough to get convergence.
+# prec ... Number of digits to be obtained.
+#
+# Usage:
+# require "bigdecimal"
+# require "bigdecimal/math.rb"
+# include BigMath
+# a = BigDecimal((PI(100)/2).to_s)
+# puts sin(a,100) # => 0.10000000000000000000......E1
+#
+module BigMath
+ def sqrt(x,prec)
+ x.sqrt(prec)
+ end
+
+ def sin(x, prec)
+ raise ArgumentError, "Zero or negative precision for sin" if prec <= 0
+ return BigDecimal("NaN") if x.infinite? || x.nan?
+ n = prec + BigDecimal.double_fig
+ one = BigDecimal("1")
+ two = BigDecimal("2")
+ x1 = x
+ x2 = x.mult(x,n)
+ sign = 1
+ y = x
+ d = y
+ i = one
+ z = one
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ sign = -sign
+ x1 = x2.mult(x1,n)
+ i += two
+ z *= (i-one) * i
+ d = sign * x1.div(z,m)
+ y += d
+ end
+ y
+ end
+
+ def cos(x, prec)
+ raise ArgumentError, "Zero or negative precision for cos" if prec <= 0
+ return BigDecimal("NaN") if x.infinite? || x.nan?
+ n = prec + BigDecimal.double_fig
+ one = BigDecimal("1")
+ two = BigDecimal("2")
+ x1 = one
+ x2 = x.mult(x,n)
+ sign = 1
+ y = one
+ d = y
+ i = BigDecimal("0")
+ z = one
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ sign = -sign
+ x1 = x2.mult(x1,n)
+ i += two
+ z *= (i-one) * i
+ d = sign * x1.div(z,m)
+ y += d
+ end
+ y
+ end
+
+ def atan(x, prec)
+ raise ArgumentError, "Zero or negative precision for atan" if prec <= 0
+ return BigDecimal("NaN") if x.infinite? || x.nan?
+ raise ArgumentError, "x.abs must be less than 1.0" if x.abs>=1
+ n = prec + BigDecimal.double_fig
+ y = x
+ d = y
+ t = x
+ r = BigDecimal("3")
+ x2 = x.mult(x,n)
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ t = -t.mult(x2,n)
+ d = t.div(r,m)
+ y += d
+ r += 2
+ end
+ y
+ end
+
+ def exp(x, prec)
+ raise ArgumentError, "Zero or negative precision for exp" if prec <= 0
+ return BigDecimal("NaN") if x.infinite? || x.nan?
+ n = prec + BigDecimal.double_fig
+ one = BigDecimal("1")
+ x1 = one
+ y = one
+ d = y
+ z = one
+ i = 0
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ x1 = x1.mult(x,n)
+ i += 1
+ z *= i
+ d = x1.div(z,m)
+ y += d
+ end
+ y
+ end
+
+ def log(x, prec)
+ raise ArgumentError, "Zero or negative argument for log" if x <= 0 || prec <= 0
+ return x if x.infinite? || x.nan?
+ one = BigDecimal("1")
+ two = BigDecimal("2")
+ n = prec + BigDecimal.double_fig
+ x = (x - one).div(x + one,n)
+ x2 = x.mult(x,n)
+ y = x
+ d = y
+ i = one
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ x = x2.mult(x,n)
+ i += two
+ d = x.div(i,m)
+ y += d
+ end
+ y*two
+ end
+
+ def PI(prec)
+ raise ArgumentError, "Zero or negative argument for PI" if prec <= 0
+ n = prec + BigDecimal.double_fig
+ zero = BigDecimal("0")
+ one = BigDecimal("1")
+ two = BigDecimal("2")
+
+ m25 = BigDecimal("-0.04")
+ m57121 = BigDecimal("-57121")
+
+ pi = zero
+
+ d = one
+ k = one
+ w = one
+ t = BigDecimal("-80")
+ while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ t = t*m25
+ d = t.div(k,m)
+ k = k+two
+ pi = pi + d
+ end
+
+ d = one
+ k = one
+ w = one
+ t = BigDecimal("956")
+ while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ t = t.div(m57121,n)
+ d = t.div(k,m)
+ pi = pi + d
+ k = k+two
+ end
+ pi
+ end
+
+ def E(prec)
+ raise ArgumentError, "Zero or negative precision for E" if prec <= 0
+ n = prec + BigDecimal.double_fig
+ one = BigDecimal("1")
+ y = one
+ d = y
+ z = one
+ i = 0
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ i += 1
+ z *= i
+ d = one.div(z,m)
+ y += d
+ end
+ y
+ end
+end
diff --git a/ext/bigdecimal/lib/bigdecimal/newton.rb b/ext/bigdecimal/lib/bigdecimal/newton.rb
new file mode 100644
index 0000000000..67a92474ac
--- /dev/null
+++ b/ext/bigdecimal/lib/bigdecimal/newton.rb
@@ -0,0 +1,75 @@
+#
+# newton.rb
+#
+# Solves nonlinear algebraic equation system f = 0 by Newton's method.
+# (This program is not dependent on BigDecimal)
+#
+# To call:
+# n = nlsolve(f,x)
+# where n is the number of iterations required.
+# x is the solution vector.
+# f is the object to be solved which must have following methods.
+#
+# f ... Object to compute Jacobian matrix of the equation systems.
+# [Methods required for f]
+# f.values(x) returns values of all functions at x.
+# f.zero returns 0.0
+# f.one returns 1.0
+# f.two returns 1.0
+# f.ten returns 10.0
+# f.eps convergence criterion
+# x ... initial values
+#
+require "ludcmp"
+require "jacobian"
+
+module Newton
+ include LUSolve
+ include Jacobian
+
+ def norm(fv,zero=0.0)
+ s = zero
+ n = fv.size
+ for i in 0...n do
+ s += fv[i]*fv[i]
+ end
+ s
+ end
+
+ def nlsolve(f,x)
+ nRetry = 0
+ n = x.size
+
+ f0 = f.values(x)
+ zero = f.zero
+ one = f.one
+ two = f.two
+ p5 = one/two
+ d = norm(f0,zero)
+ minfact = f.ten*f.ten*f.ten
+ minfact = one/minfact
+ e = f.eps
+ while d >= e do
+ nRetry += 1
+ # Not yet converged. => Compute Jacobian matrix
+ dfdx = jacobian(f,f0,x)
+ # Solve dfdx*dx = -f0 to estimate dx
+ dx = lusolve(dfdx,f0,ludecomp(dfdx,n,zero,one),zero)
+ fact = two
+ xs = x.dup
+ begin
+ fact *= p5
+ if fact < minfact then
+ raize "Failed to reduce function values."
+ end
+ for i in 0...n do
+ x[i] = xs[i] - dx[i]*fact
+ end
+ f0 = f.values(x)
+ dn = norm(f0,zero)
+ end while(dn>=d)
+ d = dn
+ end
+ nRetry
+ end
+end
diff --git a/ext/bigdecimal/lib/bigdecimal/nlsolve.rb b/ext/bigdecimal/lib/bigdecimal/nlsolve.rb
new file mode 100644
index 0000000000..08f17f9ecd
--- /dev/null
+++ b/ext/bigdecimal/lib/bigdecimal/nlsolve.rb
@@ -0,0 +1,38 @@
+#!/usr/local/bin/ruby
+
+#
+# nlsolve.rb
+# An example for solving nonlinear algebraic equation system.
+#
+
+require "bigdecimal"
+require "newton"
+include Newton
+
+class Function
+ def initialize()
+ @zero = BigDecimal::new("0.0")
+ @one = BigDecimal::new("1.0")
+ @two = BigDecimal::new("2.0")
+ @ten = BigDecimal::new("10.0")
+ @eps = BigDecimal::new("1.0e-16")
+ end
+ def zero;@zero;end
+ def one ;@one ;end
+ def two ;@two ;end
+ def ten ;@ten ;end
+ def eps ;@eps ;end
+ def values(x) # <= defines functions solved
+ f = []
+ f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0
+ f2 = x[0] - x[1] # f2 = x - y => 0
+ f <<= f1
+ f <<= f2
+ f
+ end
+end
+ f = BigDecimal::limit(100)
+ f = Function.new
+ x = [f.zero,f.zero] # Initial values
+ n = nlsolve(f,x)
+ p x
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
new file mode 100644
index 0000000000..1f8d6c7a49
--- /dev/null
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -0,0 +1,68 @@
+#
+# BigDecimal utility library.
+# ----------------------------------------------------------------------
+# Contents:
+#
+# String#
+# to_d ... to BigDecimal
+#
+# Float#
+# to_d ... to BigDecimal
+#
+# BigDecimal#
+# to_r ... to Rational
+#
+# Rational#
+# to_d ... to BigDecimal
+#
+# ----------------------------------------------------------------------
+#
+class Float < Numeric
+ def to_d
+ BigDecimal(self.to_s)
+ end
+end
+
+class String
+ def to_d
+ BigDecimal(self)
+ end
+end
+
+class BigDecimal < Numeric
+ # to "nnnnnn.mmm" form digit string
+ # Use BigDecimal#to_s("F") instead.
+ def to_digits
+ if self.nan? || self.infinite? || self.zero?
+ self.to_s
+ else
+ i = self.to_i.to_s
+ s,f,y,z = self.frac.split
+ i + "." + ("0"*(-z)) + f
+ end
+ end
+
+ # Convert BigDecimal to Rational
+ def to_r
+ sign,digits,base,power = self.split
+ numerator = sign*digits.to_i
+ denomi_power = power - digits.size # base is always 10
+ if denomi_power < 0
+ denominator = base ** (-denomi_power)
+ else
+ denominator = base ** denomi_power
+ end
+ Rational(numerator,denominator)
+ end
+end
+
+class Rational < Numeric
+ # Convert Rational to BigDecimal
+ def to_d(nFig=0)
+ num = self.numerator.to_s
+ if nFig<=0
+ nFig = BigDecimal.double_fig*2+1
+ end
+ BigDecimal.new(num).div(self.denominator,nFig)
+ end
+end
diff --git a/ext/bigdecimal/sample/linear.rb b/ext/bigdecimal/sample/linear.rb
new file mode 100644
index 0000000000..7c8ca263eb
--- /dev/null
+++ b/ext/bigdecimal/sample/linear.rb
@@ -0,0 +1,71 @@
+#!/usr/local/bin/ruby
+
+#
+# linear.rb
+#
+# Solves linear equation system(A*x = b) by LU decomposition method.
+# where A is a coefficient matrix,x is an answer vector,b is a constant vector.
+#
+# USAGE:
+# ruby linear.rb [input file solved]
+#
+
+require "bigdecimal"
+require "ludcmp"
+
+#
+# NOTE:
+# Change following BigDecimal::limit() if needed.
+BigDecimal::limit(100)
+#
+
+include LUSolve
+def rd_order(na)
+ printf("Number of equations ?") if(na <= 0)
+ n = ARGF.gets().to_i
+end
+
+na = ARGV.size
+zero = BigDecimal::new("0.0")
+one = BigDecimal::new("1.0")
+
+while (n=rd_order(na))>0
+ a = []
+ as= []
+ b = []
+ if na <= 0
+ # Read data from console.
+ printf("\nEnter coefficient matrix element A[i,j]\n");
+ for i in 0...n do
+ for j in 0...n do
+ printf("A[%d,%d]? ",i,j); s = ARGF.gets
+ a << BigDecimal::new(s);
+ as << BigDecimal::new(s);
+ end
+ printf("Contatant vector element b[%d] ? ",i); b << BigDecimal::new(ARGF.gets);
+ end
+ else
+ # Read data from specified file.
+ printf("Coefficient matrix and constant vector.\n");
+ for i in 0...n do
+ s = ARGF.gets
+ printf("%d) %s",i,s)
+ s = s.split
+ for j in 0...n do
+ a << BigDecimal::new(s[j]);
+ as << BigDecimal::new(s[j]);
+ end
+ b << BigDecimal::new(s[n]);
+ end
+ end
+ x = lusolve(a,b,ludecomp(a,n,zero,one),zero)
+ printf("Answer(x[i] & (A*x-b)[i]) follows\n")
+ for i in 0...n do
+ printf("x[%d]=%s ",i,x[i].to_s)
+ s = zero
+ for j in 0...n do
+ s = s + as[i*n+j]*x[j]
+ end
+ printf(" & %s\n",(s-b[i]).to_s)
+ end
+end
diff --git a/ext/bigdecimal/sample/nlsolve.rb b/ext/bigdecimal/sample/nlsolve.rb
new file mode 100644
index 0000000000..08f17f9ecd
--- /dev/null
+++ b/ext/bigdecimal/sample/nlsolve.rb
@@ -0,0 +1,38 @@
+#!/usr/local/bin/ruby
+
+#
+# nlsolve.rb
+# An example for solving nonlinear algebraic equation system.
+#
+
+require "bigdecimal"
+require "newton"
+include Newton
+
+class Function
+ def initialize()
+ @zero = BigDecimal::new("0.0")
+ @one = BigDecimal::new("1.0")
+ @two = BigDecimal::new("2.0")
+ @ten = BigDecimal::new("10.0")
+ @eps = BigDecimal::new("1.0e-16")
+ end
+ def zero;@zero;end
+ def one ;@one ;end
+ def two ;@two ;end
+ def ten ;@ten ;end
+ def eps ;@eps ;end
+ def values(x) # <= defines functions solved
+ f = []
+ f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0
+ f2 = x[0] - x[1] # f2 = x - y => 0
+ f <<= f1
+ f <<= f2
+ f
+ end
+end
+ f = BigDecimal::limit(100)
+ f = Function.new
+ x = [f.zero,f.zero] # Initial values
+ n = nlsolve(f,x)
+ p x
diff --git a/ext/bigdecimal/sample/pi.rb b/ext/bigdecimal/sample/pi.rb
new file mode 100644
index 0000000000..2f7dd27d60
--- /dev/null
+++ b/ext/bigdecimal/sample/pi.rb
@@ -0,0 +1,20 @@
+#!/usr/local/bin/ruby
+
+#
+# pi.rb
+#
+# Calculates 3.1415.... (the number of times that a circle's diameter
+# will fit around the circle) using J. Machin's formula.
+#
+
+require "bigdecimal"
+require "bigdecimal/math.rb"
+
+include BigMath
+
+if ARGV.size == 1
+ print "PI("+ARGV[0]+"):\n"
+ p PI(ARGV[0].to_i)
+else
+ print "TRY: ruby pi.rb 1000 \n"
+end
diff --git a/ext/configsub.rb b/ext/configsub.rb
deleted file mode 100644
index 315cdaf868..0000000000
--- a/ext/configsub.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#!./miniruby -ps
-
-BEGIN {
- CONFIG = {}
-
- VERSION.scan(/(\d+)\.(\d+)\.(\d+)/) do
- # overridden if config.status has version
- CONFIG['MAJOR'] = $1
- CONFIG['MINOR'] = $2
- CONFIG['TEENY'] = $3
- end
-
- File.foreach($config || "config.status") do |$_|
- next if /^#/
- if /^s%@(\w+)@%(.*)%g/
- name = $1
- val = $2 || ""
- next if /^(INSTALL|DEFS|configure_input|srcdir)$/ =~ name
- val.gsub!(/\$\{([^{}]+)\}/) { "$(#{$1})" }
- CONFIG[name] = val
- end
- end
-
- CONFIG['top_srcdir'] = File.expand_path($srcdir || ".")
- CONFIG['RUBY_INSTALL_NAME'] = $install_name if $install_name
- CONFIG['RUBY_SO_NAME'] = $so_name if $so_name
- $defout = open($output, 'w') if $output
-}
-
-gsub!(/@(\w+)@/) {CONFIG[$1] || $&}
-
-# vi:set sw=2:
diff --git a/ext/curses/.cvsignore b/ext/curses/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/curses/.cvsignore
+++ b/ext/curses/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/curses/MANIFEST b/ext/curses/MANIFEST
deleted file mode 100644
index e1a25d962d..0000000000
--- a/ext/curses/MANIFEST
+++ /dev/null
@@ -1,7 +0,0 @@
-MANIFEST
-curses.c
-depend
-extconf.rb
-hello.rb
-rain.rb
-view.rb
diff --git a/ext/curses/curses.c b/ext/curses/curses.c
index 4a8c46f483..106c43da4c 100644
--- a/ext/curses/curses.c
+++ b/ext/curses/curses.c
@@ -1,62 +1,86 @@
-/*
+/* -*- C -*-
+ * $Id$
+ *
* ext/curses/curses.c
*
* by MAEDA Shugo (ender@pic-internet.or.jp)
- * modified by Yukihiro Matsumoto (matz@netlab.co.jp)
+ * modified by Yukihiro Matsumoto (matz@netlab.co.jp),
+ * Toki Yoshinori,
+ * Hitoshi Takahashi,
+ * and Takaaki Tateishi (ttate@kt.jaist.ac.jp)
+ *
+ * maintainers:
+ * - Takaaki Tateishi (ttate@kt.jaist.ac.jp)
*/
-#ifdef HAVE_NCURSES_H
+#include "ruby.h"
+#include "rubyio.h"
+
+#if defined(HAVE_NCURSES_H)
# include <ncurses.h>
+#elif defined(HAVE_NCURSES_CURSES_H)
+# include <ncurses/curses.h>
+#elif defined(HAVE_CURSES_COLR_CURSES_H)
+# include <varargs.h>
+# include <curses_colr/curses.h>
#else
-# ifdef HAVE_NCURSES_CURSES_H
-# include <ncurses/curses.h>
-#else
-# ifdef HAVE_CURSES_COLR_CURSES_H
-# include <varargs.h>
-# include <curses_colr/curses.h>
-# else
-# include <curses.h>
-# if (defined(__bsdi__) || defined(__NetBSD__) || defined(__APPLE__) ) && !defined(_maxx)
-# define _maxx maxx
+# include <curses.h>
+# if defined(__bsdi__) || defined(__NetBSD__) || defined(__APPLE__)
+# if !defined(_maxx)
+# define _maxx maxx
# endif
-# if (defined(__bsdi__) || defined(__NetBSD__) || defined(__APPLE__)) && !defined(_maxy)
-# define _maxy maxy
+# if !defined(_maxy)
+# define _maxy maxy
# endif
-# if (defined(__bsdi__) || defined(__NetBSD__) || defined(__APPLE__)) && !defined(_begx)
-# define _begx begx
+# if !defined(_begx)
+# define _begx begx
# endif
-# if (defined(__bsdi__) || defined(__NetBSD__) || defined(__APPLE__)) && !defined(_begy)
-# define _begy begy
+# if !defined(_begy)
+# define _begy begy
# endif
# endif
#endif
+
+#ifdef HAVE_INIT_COLOR
+# define USE_COLOR 1
#endif
-#include "stdio.h"
-#include "ruby.h"
-#include "rubyio.h"
+/* supports only ncurses mouse routines */
+#ifdef NCURSES_MOUSE_VERSION
+# define USE_MOUSE 1
+#endif
static VALUE mCurses;
+static VALUE mKey;
static VALUE cWindow;
+#ifdef USE_MOUSE
+static VALUE cMouseEvent;
+#endif
-VALUE rb_stdscr;
+static VALUE rb_stdscr;
struct windata {
WINDOW *window;
};
+#define CHECK(c) c
+
+static VALUE window_attroff();
+static VALUE window_attron();
+static VALUE window_attrset();
+
static void
no_window()
{
rb_raise(rb_eRuntimeError, "already closed window");
}
-#define GetWINDOW(obj, winp) {\
+#define GetWINDOW(obj, winp) do {\
+ if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)\
+ rb_raise(rb_eSecurityError, "Insecure: operation on untainted window");\
Data_Get_Struct(obj, struct windata, winp);\
if (winp->window == 0) no_window();\
-}
-
-#define CHECK(c) c
+} while (0)
static void
free_window(winp)
@@ -79,7 +103,8 @@ prep_window(class, window)
rb_raise(rb_eRuntimeError, "failed to create window");
}
- obj = Data_Make_Struct(class, struct windata, 0, free_window, winp);
+ obj = rb_obj_alloc(class);
+ Data_Get_Struct(obj, struct windata, winp);
winp->window = window;
return obj;
@@ -91,22 +116,19 @@ prep_window(class, window)
static VALUE
curses_init_screen()
{
+ rb_secure(4);
+ if (rb_stdscr) return rb_stdscr;
initscr();
if (stdscr == 0) {
rb_raise(rb_eRuntimeError, "cannot initialize curses");
}
clear();
rb_stdscr = prep_window(cWindow, stdscr);
- return Qnil;
+ return rb_stdscr;
}
/* def stdscr */
-static VALUE
-curses_stdscr()
-{
- if (rb_stdscr == 0) curses_init_screen();
- return rb_stdscr;
-}
+#define curses_stdscr curses_init_screen
/* def close_screen */
static VALUE
@@ -116,11 +138,12 @@ curses_close_screen()
if (!isendwin())
#endif
endwin();
+ rb_stdscr = 0;
return Qnil;
}
static void
-curses_finalize()
+curses_finalize(VALUE dummy)
{
if (stdscr
#ifdef HAVE_ISENDWIN
@@ -128,6 +151,8 @@ curses_finalize()
#endif
)
endwin();
+ rb_stdscr = 0;
+ rb_gc_unregister_address(&rb_stdscr);
}
/* def closed? */
@@ -149,6 +174,7 @@ static VALUE
curses_clear(obj)
VALUE obj;
{
+ curses_stdscr();
wclear(stdscr);
return Qnil;
}
@@ -158,6 +184,7 @@ static VALUE
curses_refresh(obj)
VALUE obj;
{
+ curses_stdscr();
refresh();
return Qnil;
}
@@ -167,6 +194,7 @@ static VALUE
curses_doupdate(obj)
VALUE obj;
{
+ curses_stdscr();
#ifdef HAVE_DOUPDATE
doupdate();
#else
@@ -180,6 +208,7 @@ static VALUE
curses_echo(obj)
VALUE obj;
{
+ curses_stdscr();
echo();
return Qnil;
}
@@ -189,6 +218,7 @@ static VALUE
curses_noecho(obj)
VALUE obj;
{
+ curses_stdscr();
noecho();
return Qnil;
}
@@ -198,6 +228,7 @@ static VALUE
curses_raw(obj)
VALUE obj;
{
+ curses_stdscr();
raw();
return Qnil;
}
@@ -207,6 +238,7 @@ static VALUE
curses_noraw(obj)
VALUE obj;
{
+ curses_stdscr();
noraw();
return Qnil;
}
@@ -216,6 +248,7 @@ static VALUE
curses_cbreak(obj)
VALUE obj;
{
+ curses_stdscr();
cbreak();
return Qnil;
}
@@ -225,6 +258,7 @@ static VALUE
curses_nocbreak(obj)
VALUE obj;
{
+ curses_stdscr();
nocbreak();
return Qnil;
}
@@ -234,6 +268,7 @@ static VALUE
curses_nl(obj)
VALUE obj;
{
+ curses_stdscr();
nl();
return Qnil;
}
@@ -243,6 +278,7 @@ static VALUE
curses_nonl(obj)
VALUE obj;
{
+ curses_stdscr();
nonl();
return Qnil;
}
@@ -253,6 +289,7 @@ curses_beep(obj)
VALUE obj;
{
#ifdef HAVE_BEEP
+ curses_stdscr();
beep();
#endif
return Qnil;
@@ -264,6 +301,7 @@ curses_flash(obj)
VALUE obj;
{
#ifdef HAVE_FLASH
+ curses_stdscr();
flash();
#endif
return Qnil;
@@ -276,6 +314,7 @@ curses_ungetch(obj, ch)
VALUE ch;
{
#ifdef HAVE_UNGETCH
+ curses_stdscr();
ungetch(NUM2INT(ch));
#else
rb_notimplement();
@@ -290,6 +329,7 @@ curses_setpos(obj, y, x)
VALUE y;
VALUE x;
{
+ curses_stdscr();
move(NUM2INT(y), NUM2INT(x));
return Qnil;
}
@@ -317,6 +357,7 @@ static VALUE
curses_inch(obj)
VALUE obj;
{
+ curses_stdscr();
return CHR2FIX(inch());
}
@@ -326,6 +367,7 @@ curses_addch(obj, ch)
VALUE obj;
VALUE ch;
{
+ curses_stdscr();
addch(NUM2CHR(ch));
return Qnil;
}
@@ -336,6 +378,7 @@ curses_insch(obj, ch)
VALUE obj;
VALUE ch;
{
+ curses_stdscr();
insch(NUM2CHR(ch));
return Qnil;
}
@@ -346,6 +389,7 @@ curses_addstr(obj, str)
VALUE obj;
VALUE str;
{
+ curses_stdscr();
if (!NIL_P(str)) {
addstr(STR2CSTR(str));
}
@@ -358,7 +402,8 @@ curses_getch(obj)
VALUE obj;
{
rb_read_check(stdin);
- return CHR2FIX(getch());
+ curses_stdscr();
+ return UINT2NUM(getch());
}
/* def getstr */
@@ -369,7 +414,11 @@ curses_getstr(obj)
char rtn[1024]; /* This should be big enough.. I hope */
rb_read_check(stdin);
+#if defined(HAVE_GETNSTR)
+ getnstr(rtn,1023);
+#else
getstr(rtn);
+#endif
return rb_tainted_str_new2(rtn);
}
@@ -387,12 +436,32 @@ static VALUE
curses_deleteln(obj)
VALUE obj;
{
-#ifdef HAVE_DELETELN
+#if defined(HAVE_DELETELN) || defined(deleteln)
deleteln();
#endif
return Qnil;
}
+/* def keyname */
+static VALUE
+curses_keyname(obj, c)
+ VALUE obj;
+ VALUE c;
+{
+#ifdef HAVE_KEYNAME
+ const char *name;
+
+ name = keyname(NUM2INT(c));
+ if (name) {
+ return rb_str_new2(name);
+ } else {
+ return Qnil;
+ }
+#else
+ return Qnil;
+#endif
+}
+
static VALUE
curses_lines()
{
@@ -405,27 +474,292 @@ curses_cols()
return INT2FIX(COLS);
}
+static VALUE
+curses_curs_set(VALUE obj, VALUE visibility)
+{
+#ifdef HAVE_CURS_SET
+ int n;
+ return (n = curs_set(NUM2INT(visibility)) != ERR) ? INT2FIX(n) : Qnil;
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+curses_scrl(VALUE obj, VALUE n)
+{
+ /* may have to raise exception on ERR */
+#ifdef HAVE_SCRL
+ return (scrl(NUM2INT(n)) == OK) ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+curses_setscrreg(VALUE obj, VALUE top, VALUE bottom)
+{
+ /* may have to raise exception on ERR */
+#ifdef HAVE_SETSCRREG
+ return (setscrreg(NUM2INT(top), NUM2INT(bottom)) == OK) ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+curses_attroff(VALUE obj, VALUE attrs)
+{
+ return window_attroff(rb_stdscr,attrs);
+ /* return INT2FIX(attroff(NUM2INT(attrs))); */
+}
+
+static VALUE
+curses_attron(VALUE obj, VALUE attrs)
+{
+ return window_attron(rb_stdscr,attrs);
+ /* return INT2FIX(attroff(NUM2INT(attrs))); */
+}
+
+static VALUE
+curses_attrset(VALUE obj, VALUE attrs)
+{
+ return window_attrset(rb_stdscr,attrs);
+ /* return INT2FIX(attroff(NUM2INT(attrs))); */
+}
+
+static VALUE
+curses_bkgdset(VALUE obj, VALUE ch)
+{
+#ifdef HAVE_BKGDSET
+ bkgdset(NUM2CHR(ch));
+#endif
+ return Qnil;
+}
+
+static VALUE
+curses_bkgd(VALUE obj, VALUE ch)
+{
+#ifdef HAVE_BKGD
+ return (bkgd(NUM2CHR(ch)) == OK) ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+curses_resizeterm(VALUE obj, VALUE lin, VALUE col)
+{
+#if defined(HAVE_RESIZETERM)
+ return (resizeterm(NUM2INT(lin),NUM2INT(col)) == OK) ? Qtrue : Qfalse;
+#else
+ return Qnil;
+#endif
+}
+
+#ifdef USE_COLOR
+static VALUE
+curses_start_color(VALUE obj)
+{
+ /* may have to raise exception on ERR */
+ return (start_color() == OK) ? Qtrue : Qfalse;
+}
+
+static VALUE
+curses_init_pair(VALUE obj, VALUE pair, VALUE f, VALUE b)
+{
+ /* may have to raise exception on ERR */
+ return (init_pair(NUM2INT(pair),NUM2INT(f),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
+}
+
+static VALUE
+curses_init_color(VALUE obj, VALUE color, VALUE r, VALUE g, VALUE b)
+{
+ /* may have to raise exception on ERR */
+ return (init_color(NUM2INT(color),NUM2INT(r),
+ NUM2INT(g),NUM2INT(b)) == OK) ? Qtrue : Qfalse;
+}
+
+static VALUE
+curses_has_colors(VALUE obj)
+{
+ return has_colors() ? Qtrue : Qfalse;
+}
+
+static VALUE
+curses_can_change_color(VALUE obj)
+{
+ return can_change_color() ? Qtrue : Qfalse;
+}
+
+static VALUE
+curses_color_content(VALUE obj, VALUE color)
+{
+ short r,g,b;
+
+ color_content(NUM2INT(color),&r,&g,&b);
+ return rb_ary_new3(3,INT2FIX(r),INT2FIX(g),INT2FIX(b));
+}
+
+static VALUE
+curses_pair_content(VALUE obj, VALUE pair)
+{
+ short f,b;
+
+ pair_content(NUM2INT(pair),&f,&b);
+ return rb_ary_new3(2,INT2FIX(f),INT2FIX(b));
+}
+
+static VALUE
+curses_color_pair(VALUE obj, VALUE attrs)
+{
+ return INT2FIX(COLOR_PAIR(NUM2INT(attrs)));
+}
+
+static VALUE
+curses_pair_number(VALUE obj, VALUE attrs)
+{
+ return INT2FIX(PAIR_NUMBER(NUM2INT(attrs)));
+}
+#endif /* USE_COLOR */
+
+#ifdef USE_MOUSE
+struct mousedata {
+ MEVENT *mevent;
+};
+
+static void
+no_mevent()
+{
+ rb_raise(rb_eRuntimeError, "no such mouse event");
+}
+
+#define GetMOUSE(obj, data) do {\
+ if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)\
+ rb_raise(rb_eSecurityError, "Insecure: operation on untainted mouse");\
+ Data_Get_Struct(obj, struct mousedata, data);\
+ if (data->mevent == 0) no_mevent();\
+} while (0)
+
+static void
+curses_mousedata_free(struct mousedata *mdata)
+{
+ if (mdata->mevent)
+ free(mdata->mevent);
+}
+
+static VALUE
+curses_getmouse(VALUE obj)
+{
+ struct mousedata *mdata;
+ VALUE val;
+
+ val = Data_Make_Struct(cMouseEvent,struct mousedata,
+ 0,curses_mousedata_free,mdata);
+ mdata->mevent = (MEVENT*)malloc(sizeof(MEVENT));
+ return (getmouse(mdata->mevent) == OK) ? val : Qnil;
+}
+
+static VALUE
+curses_ungetmouse(VALUE obj, VALUE mevent)
+{
+ struct mousedata *mdata;
+
+ GetMOUSE(mevent,mdata);
+ return (ungetmouse(mdata->mevent) == OK) ? Qtrue : Qfalse;
+}
+
+static VALUE
+curses_mouseinterval(VALUE obj, VALUE interval)
+{
+ return mouseinterval(NUM2INT(interval)) ? Qtrue : Qfalse;
+}
+
+static VALUE
+curses_mousemask(VALUE obj, VALUE mask)
+{
+ return INT2NUM(mousemask(NUM2UINT(mask),NULL));
+}
+
+#define DEFINE_MOUSE_GET_MEMBER(func_name,mem) \
+static VALUE func_name (VALUE mouse) \
+{ \
+ struct mousedata *mdata; \
+ GetMOUSE(mouse, mdata); \
+ return (UINT2NUM(mdata->mevent -> mem)); \
+}
+
+DEFINE_MOUSE_GET_MEMBER(curs_mouse_id, id)
+DEFINE_MOUSE_GET_MEMBER(curs_mouse_x, x)
+DEFINE_MOUSE_GET_MEMBER(curs_mouse_y, y)
+DEFINE_MOUSE_GET_MEMBER(curs_mouse_z, z)
+DEFINE_MOUSE_GET_MEMBER(curs_mouse_bstate, bstate)
+#undef define_curs_mouse_member
+#endif /* USE_MOUSE */
+
+static VALUE
+curses_timeout(VALUE obj, VALUE delay)
+{
+#ifdef HAVE_TIMEOUT
+ timeout(NUM2INT(delay));
+ return Qnil;
+#else
+ rb_notimplement();
+#endif
+}
+
+static VALUE
+curses_def_prog_mode(VALUE obj)
+{
+#ifdef HAVE_DEF_PROG_MODE
+ return def_prog_mode() == OK ? Qtrue : Qfalse;
+#else
+ rb_notimplement();
+#endif
+}
+
+static VALUE
+curses_reset_prog_mode(VALUE obj)
+{
+#ifdef HAVE_RESET_PROG_MODE
+ return reset_prog_mode() == OK ? Qtrue : Qfalse;
+#else
+ rb_notimplement();
+#endif
+}
+
/*-------------------------- class Window --------------------------*/
-/* def new(h, w, top, left) */
+/* def self.allocate */
static VALUE
-window_s_new(class, h, w, top, left)
- VALUE class;
+window_s_allocate(VALUE class)
+{
+ struct windata *winp;
+
+ return Data_Make_Struct(class, struct windata, 0, free_window, winp);
+}
+
+/* def initialize(h, w, top, left) */
+static VALUE
+window_initialize(obj, h, w, top, left)
+ VALUE obj;
VALUE h;
VALUE w;
VALUE top;
VALUE left;
{
- VALUE win;
+ struct windata *winp;
WINDOW *window;
- VALUE args[4];
-
+
+ rb_secure(4);
+ curses_init_screen();
+ Data_Get_Struct(obj, struct windata, winp);
+ if (winp->window) delwin(winp->window);
window = newwin(NUM2INT(h), NUM2INT(w), NUM2INT(top), NUM2INT(left));
wclear(window);
- win = prep_window(class, window);
- args[0] = h; args[1] = w; args[2] = top; args[3] = left;
+ winp->window = window;
- return win;
+ return obj;
}
/* def subwin(h, w, top, left) */
@@ -440,13 +774,11 @@ window_subwin(obj, h, w, top, left)
struct windata *winp;
WINDOW *window;
VALUE win;
- VALUE args[4];
GetWINDOW(obj, winp);
window = subwin(winp->window, NUM2INT(h), NUM2INT(w),
NUM2INT(top), NUM2INT(left));
- win = prep_window(cWindow, window);
- args[0] = h; args[1] = w; args[2] = top; args[3] = left;
+ win = prep_window(rb_obj_class(obj), window);
return win;
}
@@ -491,22 +823,23 @@ window_refresh(obj)
return Qnil;
}
-/* def box(vert, hor) */
+/* def noutrefresh */
static VALUE
-window_box(obj, vert, hor)
+window_noutrefresh(obj)
VALUE obj;
- VALUE vert;
- VALUE hor;
{
- struct windata *winp;
-
+ struct windata *winp;
+
GetWINDOW(obj, winp);
- box(winp->window, NUM2CHR(vert), NUM2CHR(hor));
-
+#ifdef HAVE_DOUPDATE
+ wnoutrefresh(winp->window);
+#else
+ wrefresh(winp->window);
+#endif
+
return Qnil;
}
-
/* def move(y, x) */
static VALUE
window_move(obj, y, x)
@@ -568,19 +901,19 @@ window_maxy(obj)
VALUE obj;
{
struct windata *winp;
- int x, y;
GetWINDOW(obj, winp);
-#ifdef getmaxy
+#if defined(getmaxy)
return INT2FIX(getmaxy(winp->window));
-#else
-#ifdef getmaxyx
- getmaxyx(winp->window, y, x);
- return INT2FIX(y);
+#elif defined(getmaxyx)
+ {
+ int x, y;
+ getmaxyx(winp->window, y, x);
+ return INT2FIX(y);
+ }
#else
return INT2FIX(winp->window->_maxy+1);
#endif
-#endif
}
/* def maxx */
@@ -589,19 +922,19 @@ window_maxx(obj)
VALUE obj;
{
struct windata *winp;
- int x, y;
GetWINDOW(obj, winp);
-#ifdef getmaxx
+#if defined(getmaxx)
return INT2FIX(getmaxx(winp->window));
-#else
-#ifdef getmaxyx
- getmaxyx(winp->window, y, x);
- return INT2FIX(x);
+#elif defined(getmaxyx)
+ {
+ int x, y;
+ getmaxyx(winp->window, y, x);
+ return INT2FIX(x);
+ }
#else
return INT2FIX(winp->window->_maxx+1);
#endif
-#endif
}
/* def begy */
@@ -638,6 +971,42 @@ window_begx(obj)
#endif
}
+/* def box(vert, hor) */
+static VALUE
+window_box(argc, argv, self)
+ int argc;
+ VALUE argv[], self;
+{
+ struct windata *winp;
+ VALUE vert, hor, corn;
+
+ rb_scan_args(argc, argv, "21", &vert, &hor, &corn);
+
+ GetWINDOW(self, winp);
+ box(winp->window, NUM2CHR(vert), NUM2CHR(hor));
+
+ if (!NIL_P(corn)) {
+ int cur_x, cur_y, x, y;
+ char c;
+
+ c = NUM2CHR(corn);
+ getyx(winp->window, cur_y, cur_x);
+ x = NUM2INT(window_maxx(self)) - 1;
+ y = NUM2INT(window_maxy(self)) - 1;
+ wmove(winp->window, 0, 0);
+ waddch(winp->window, c);
+ wmove(winp->window, y, 0);
+ waddch(winp->window, c);
+ wmove(winp->window, y, x);
+ waddch(winp->window, c);
+ wmove(winp->window, 0, x);
+ waddch(winp->window, c);
+ wmove(winp->window, cur_y, cur_x);
+ }
+
+ return Qnil;
+}
+
/* def standout */
static VALUE
window_standout(obj)
@@ -735,7 +1104,7 @@ window_getch(obj)
rb_read_check(stdin);
GetWINDOW(obj, winp);
- return CHR2FIX(wgetch(winp->window));
+ return UINT2NUM(wgetch(winp->window));
}
/* def getstr */
@@ -748,7 +1117,11 @@ window_getstr(obj)
GetWINDOW(obj, winp);
rb_read_check(stdin);
+#if defined(HAVE_WGETNSTR)
+ wgetnstr(winp->window, rtn, 1023);
+#else
wgetstr(winp->window, rtn);
+#endif
return rb_tainted_str_new2(rtn);
}
@@ -769,7 +1142,7 @@ static VALUE
window_deleteln(obj)
VALUE obj;
{
-#ifdef HAVE_WDELETELN
+#if defined(HAVE_WDELETELN) || defined(wdeleteln)
struct windata *winp;
GetWINDOW(obj, winp);
@@ -778,11 +1151,240 @@ window_deleteln(obj)
return Qnil;
}
+static VALUE
+window_scrollok(VALUE obj, VALUE bf)
+{
+ struct windata *winp;
+
+ GetWINDOW(obj, winp);
+ scrollok(winp->window, RTEST(bf) ? TRUE : FALSE);
+ return Qnil;
+}
+
+static VALUE
+window_idlok(VALUE obj, VALUE bf)
+{
+ struct windata *winp;
+
+ GetWINDOW(obj, winp);
+ idlok(winp->window, RTEST(bf) ? TRUE : FALSE);
+ return Qnil;
+}
+
+static VALUE
+window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
+{
+#ifdef HAVE_WSETSCRREG
+ struct windata *winp;
+ int res;
+
+ GetWINDOW(obj, winp);
+ res = wsetscrreg(winp->window, NUM2INT(top), NUM2INT(bottom));
+ /* may have to raise exception on ERR */
+ return (res == OK) ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+window_scroll(VALUE obj)
+{
+ struct windata *winp;
+
+ GetWINDOW(obj, winp);
+ /* may have to raise exception on ERR */
+ return (scroll(winp->window) == OK) ? Qtrue : Qfalse;
+}
+
+static VALUE
+window_scrl(VALUE obj, VALUE n)
+{
+#ifdef HAVE_WSCRL
+ struct windata *winp;
+
+ GetWINDOW(obj, winp);
+ /* may have to raise exception on ERR */
+ return (wscrl(winp->window,NUM2INT(n)) == OK) ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+window_attroff(VALUE obj, VALUE attrs)
+{
+#ifdef HAVE_WATTROFF
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ return INT2FIX(wattroff(winp->window,NUM2INT(attrs)));
+#else
+ return Qtrue;
+#endif
+}
+
+static VALUE
+window_attron(VALUE obj, VALUE attrs)
+{
+#ifdef HAVE_WATTRON
+ struct windata *winp;
+ VALUE val;
+
+ GetWINDOW(obj,winp);
+ val = INT2FIX(wattron(winp->window,NUM2INT(attrs)));
+ if( rb_block_given_p() ){
+ rb_yield(val);
+ wattroff(winp->window,NUM2INT(attrs));
+ return val;
+ }
+ else{
+ return val;
+ }
+#else
+ return Qtrue;
+#endif
+}
+
+static VALUE
+window_attrset(VALUE obj, VALUE attrs)
+{
+#ifdef HAVE_WATTRSET
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ return INT2FIX(wattrset(winp->window,NUM2INT(attrs)));
+#else
+ return Qtrue;
+#endif
+}
+
+static VALUE
+window_bkgdset(VALUE obj, VALUE ch)
+{
+#ifdef HAVE_WBKGDSET
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ wbkgdset(winp->window, NUM2CHR(ch));
+#endif
+ return Qnil;
+}
+
+static VALUE
+window_bkgd(VALUE obj, VALUE ch)
+{
+#ifdef HAVE_WBKGD
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ return (wbkgd(winp->window, NUM2CHR(ch)) == OK) ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+window_getbkgd(VALUE obj)
+{
+#ifdef HAVE_WGETBKGD
+ char c;
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ return (c = getbkgd(winp->window) != ERR) ? CHR2FIX(c) : Qnil;
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+window_resize(VALUE obj, VALUE lin, VALUE col)
+{
+#if defined(HAVE_WRESIZE)
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ return wresize(winp->window, NUM2INT(lin), NUM2INT(col)) == OK ? Qtrue : Qfalse;
+#else
+ return Qnil;
+#endif
+}
+
+
+static VALUE
+window_keypad(VALUE obj, VALUE val)
+{
+#ifdef HAVE_KEYPAD
+ struct windata *winp;
+
+ GetWINDOW(obj,winp);
+ /* keypad() of NetBSD's libcurses returns no value */
+#if defined(__NetBSD__) && !defined(NCURSES_VERSION)
+ keypad(winp->window,(RTEST(val) ? TRUE : FALSE));
+ return Qnil;
+#else
+ /* may have to raise exception on ERR */
+ return (keypad(winp->window,RTEST(val) ? TRUE : FALSE)) == OK ?
+ Qtrue : Qfalse;
+#endif
+#else
+ rb_notimplement();
+#endif /* HAVE_KEYPAD */
+}
+
+static VALUE
+window_nodelay(VALUE obj, VALUE val)
+{
+#ifdef HAVE_NODELAY
+ struct windata *winp;
+ GetWINDOW(obj,winp);
+
+ /* nodelay() of NetBSD's libcurses returns no value */
+#if defined(__NetBSD__) && !defined(NCURSES_VERSION)
+ nodelay(winp->window, RTEST(val) ? TRUE : FALSE);
+ return Qnil;
+#else
+ return nodelay(winp->window,RTEST(val) ? TRUE : FALSE) == OK ? Qtrue : Qfalse;
+#endif
+#else
+ rb_notimplement();
+#endif
+}
+
+static VALUE
+window_timeout(VALUE obj, VALUE delay)
+{
+#ifdef HAVE_WTIMEOUT
+ struct windata *winp;
+ GetWINDOW(obj,winp);
+
+ wtimeout(winp->window,NUM2INT(delay));
+ return Qnil;
+#else
+ rb_notimplement();
+#endif
+}
+
/*------------------------- Initialization -------------------------*/
void
Init_curses()
{
- mCurses = rb_define_module("Curses");
+ mCurses = rb_define_module("Curses");
+ mKey = rb_define_module_under(mCurses, "Key");
+
+ rb_gc_register_address(&rb_stdscr);
+
+#ifdef USE_MOUSE
+ cMouseEvent = rb_define_class_under(mCurses,"MouseEvent",rb_cObject);
+ rb_undef_method(CLASS_OF(cMouseEvent),"new");
+ rb_define_method(cMouseEvent, "eid", curs_mouse_id, 0);
+ rb_define_method(cMouseEvent, "x", curs_mouse_x, 0);
+ rb_define_method(cMouseEvent, "y", curs_mouse_y, 0);
+ rb_define_method(cMouseEvent, "z", curs_mouse_z, 0);
+ rb_define_method(cMouseEvent, "bstate", curs_mouse_bstate, 0);
+#endif /* USE_MOUSE */
+
rb_define_module_function(mCurses, "init_screen", curses_init_screen, 0);
rb_define_module_function(mCurses, "close_screen", curses_close_screen, 0);
rb_define_module_function(mCurses, "closed?", curses_closed, 0);
@@ -814,16 +1416,51 @@ Init_curses()
rb_define_module_function(mCurses, "getstr", curses_getstr, 0);
rb_define_module_function(mCurses, "delch", curses_delch, 0);
rb_define_module_function(mCurses, "deleteln", curses_deleteln, 0);
+ rb_define_module_function(mCurses, "keyname", curses_keyname, 1);
rb_define_module_function(mCurses, "lines", curses_lines, 0);
rb_define_module_function(mCurses, "cols", curses_cols, 0);
-
- cWindow = rb_define_class_under(mCurses, "Window", rb_cObject);
- rb_define_singleton_method(cWindow, "new", window_s_new, 4);
+ rb_define_module_function(mCurses, "curs_set", curses_curs_set, 1);
+ rb_define_module_function(mCurses, "scrl", curses_scrl, 1);
+ rb_define_module_function(mCurses, "setscrreg", curses_setscrreg, 2);
+ rb_define_module_function(mCurses, "attroff", curses_attroff, 1);
+ rb_define_module_function(mCurses, "attron", curses_attron, 1);
+ rb_define_module_function(mCurses, "attrset", curses_attrset, 1);
+ rb_define_module_function(mCurses, "bkgdset", curses_bkgdset, 1);
+ rb_define_module_function(mCurses, "bkgd", curses_bkgd, 1);
+ rb_define_module_function(mCurses, "resizeterm", curses_resizeterm, 2);
+ rb_define_module_function(mCurses, "resize", curses_resizeterm, 2);
+#ifdef USE_COLOR
+ rb_define_module_function(mCurses, "start_color", curses_start_color, 0);
+ rb_define_module_function(mCurses, "init_pair", curses_init_pair, 3);
+ rb_define_module_function(mCurses, "init_color", curses_init_color, 4);
+ rb_define_module_function(mCurses, "has_colors?", curses_has_colors, 0);
+ rb_define_module_function(mCurses, "can_change_color?",
+ curses_can_change_color, 0);
+ rb_define_module_function(mCurses, "color_content", curses_color_content, 1);
+ rb_define_module_function(mCurses, "pair_content", curses_pair_content, 1);
+ rb_define_module_function(mCurses, "color_pair", curses_color_pair, 1);
+ rb_define_module_function(mCurses, "pair_number", curses_pair_number, 1);
+#endif /* USE_COLOR */
+#ifdef USE_MOUSE
+ rb_define_module_function(mCurses, "getmouse", curses_getmouse, 0);
+ rb_define_module_function(mCurses, "ungetmouse", curses_ungetmouse, 1);
+ rb_define_module_function(mCurses, "mouseinterval", curses_mouseinterval, 1);
+ rb_define_module_function(mCurses, "mousemask", curses_mousemask, 1);
+#endif /* USE_MOUSE */
+
+ rb_define_module_function(mCurses, "timeout=", curses_timeout, 1);
+ rb_define_module_function(mCurses, "def_prog_mode", curses_def_prog_mode, 0);
+ rb_define_module_function(mCurses, "reset_prog_mode", curses_reset_prog_mode, 0);
+
+ cWindow = rb_define_class_under(mCurses, "Window", rb_cData);
+ rb_define_alloc_func(cWindow, window_s_allocate);
+ rb_define_method(cWindow, "initialize", window_initialize, 4);
rb_define_method(cWindow, "subwin", window_subwin, 4);
rb_define_method(cWindow, "close", window_close, 0);
rb_define_method(cWindow, "clear", window_clear, 0);
rb_define_method(cWindow, "refresh", window_refresh, 0);
- rb_define_method(cWindow, "box", window_box, 2);
+ rb_define_method(cWindow, "noutrefresh", window_noutrefresh, 0);
+ rb_define_method(cWindow, "box", window_box, -1);
rb_define_method(cWindow, "move", window_move, 2);
rb_define_method(cWindow, "setpos", window_setpos, 2);
rb_define_method(cWindow, "cury", window_cury, 0);
@@ -843,6 +1480,544 @@ Init_curses()
rb_define_method(cWindow, "getstr", window_getstr, 0);
rb_define_method(cWindow, "delch", window_delch, 0);
rb_define_method(cWindow, "deleteln", window_deleteln, 0);
+ rb_define_method(cWindow, "scroll", window_scroll, 0);
+ rb_define_method(cWindow, "scrollok", window_scrollok, 1);
+ rb_define_method(cWindow, "idlok", window_idlok, 1);
+ rb_define_method(cWindow, "setscrreg", window_setscrreg, 2);
+ rb_define_method(cWindow, "scrl", window_scrl, 1);
+ rb_define_method(cWindow, "resize", window_resize, 2);
+ rb_define_method(cWindow, "keypad", window_keypad, 1);
+ rb_define_method(cWindow, "keypad=", window_keypad, 1);
+
+ rb_define_method(cWindow, "attroff", window_attroff, 1);
+ rb_define_method(cWindow, "attron", window_attron, 1);
+ rb_define_method(cWindow, "attrset", window_attrset, 1);
+ rb_define_method(cWindow, "bkgdset", window_bkgdset, 1);
+ rb_define_method(cWindow, "bkgd", window_bkgd, 1);
+ rb_define_method(cWindow, "getbkgd", window_getbkgd, 0);
+
+ rb_define_method(cWindow, "nodelay=", window_nodelay, 1);
+ rb_define_method(cWindow, "timeout=", window_timeout, 1);
+
+#define rb_curses_define_const(c) rb_define_const(mCurses,#c,UINT2NUM(c))
+
+#ifdef USE_COLOR
+ rb_curses_define_const(A_ATTRIBUTES);
+#ifdef A_NORMAL
+ rb_curses_define_const(A_NORMAL);
+#endif
+ rb_curses_define_const(A_STANDOUT);
+ rb_curses_define_const(A_UNDERLINE);
+ rb_curses_define_const(A_REVERSE);
+ rb_curses_define_const(A_BLINK);
+ rb_curses_define_const(A_DIM);
+ rb_curses_define_const(A_BOLD);
+ rb_curses_define_const(A_PROTECT);
+#ifdef A_INVIS /* for NetBSD */
+ rb_curses_define_const(A_INVIS);
+#endif
+ rb_curses_define_const(A_ALTCHARSET);
+ rb_curses_define_const(A_CHARTEXT);
+#ifdef A_HORIZONTAL
+ rb_curses_define_const(A_HORIZONTAL);
+#endif
+#ifdef A_LEFT
+ rb_curses_define_const(A_LEFT);
+#endif
+#ifdef A_LOW
+ rb_curses_define_const(A_LOW);
+#endif
+#ifdef A_RIGHT
+ rb_curses_define_const(A_RIGHT);
+#endif
+#ifdef A_TOP
+ rb_curses_define_const(A_TOP);
+#endif
+#ifdef A_VERTICAL
+ rb_curses_define_const(A_VERTICAL);
+#endif
+ rb_curses_define_const(A_COLOR);
+
+#ifdef COLORS
+ rb_curses_define_const(COLORS);
+#endif
+ rb_curses_define_const(COLOR_BLACK);
+ rb_curses_define_const(COLOR_RED);
+ rb_curses_define_const(COLOR_GREEN);
+ rb_curses_define_const(COLOR_YELLOW);
+ rb_curses_define_const(COLOR_BLUE);
+ rb_curses_define_const(COLOR_MAGENTA);
+ rb_curses_define_const(COLOR_CYAN);
+ rb_curses_define_const(COLOR_WHITE);
+#endif /* USE_COLOR */
+#ifdef USE_MOUSE
+#ifdef BUTTON1_PRESSED
+ rb_curses_define_const(BUTTON1_PRESSED);
+#endif
+#ifdef BUTTON1_RELEASED
+ rb_curses_define_const(BUTTON1_RELEASED);
+#endif
+#ifdef BUTTON1_CLICKED
+ rb_curses_define_const(BUTTON1_CLICKED);
+#endif
+#ifdef BUTTON1_DOUBLE_CLICKED
+ rb_curses_define_const(BUTTON1_DOUBLE_CLICKED);
+#endif
+#ifdef BUTTON1_TRIPLE_CLICKED
+ rb_curses_define_const(BUTTON1_TRIPLE_CLICKED);
+#endif
+#ifdef BUTTON2_PRESSED
+ rb_curses_define_const(BUTTON2_PRESSED);
+#endif
+#ifdef BUTTON2_RELEASED
+ rb_curses_define_const(BUTTON2_RELEASED);
+#endif
+#ifdef BUTTON2_CLICKED
+ rb_curses_define_const(BUTTON2_CLICKED);
+#endif
+#ifdef BUTTON2_DOUBLE_CLICKED
+ rb_curses_define_const(BUTTON2_DOUBLE_CLICKED);
+#endif
+#ifdef BUTTON2_TRIPLE_CLICKED
+ rb_curses_define_const(BUTTON2_TRIPLE_CLICKED);
+#endif
+#ifdef BUTTON3_PRESSED
+ rb_curses_define_const(BUTTON3_PRESSED);
+#endif
+#ifdef BUTTON3_RELEASED
+ rb_curses_define_const(BUTTON3_RELEASED);
+#endif
+#ifdef BUTTON3_CLICKED
+ rb_curses_define_const(BUTTON3_CLICKED);
+#endif
+#ifdef BUTTON3_DOUBLE_CLICKED
+ rb_curses_define_const(BUTTON3_DOUBLE_CLICKED);
+#endif
+#ifdef BUTTON3_TRIPLE_CLICKED
+ rb_curses_define_const(BUTTON3_TRIPLE_CLICKED);
+#endif
+#ifdef BUTTON4_PRESSED
+ rb_curses_define_const(BUTTON4_PRESSED);
+#endif
+#ifdef BUTTON4_RELEASED
+ rb_curses_define_const(BUTTON4_RELEASED);
+#endif
+#ifdef BUTTON4_CLICKED
+ rb_curses_define_const(BUTTON4_CLICKED);
+#endif
+#ifdef BUTTON4_DOUBLE_CLICKED
+ rb_curses_define_const(BUTTON4_DOUBLE_CLICKED);
+#endif
+#ifdef BUTTON4_TRIPLE_CLICKED
+ rb_curses_define_const(BUTTON4_TRIPLE_CLICKED);
+#endif
+#ifdef BUTTON_SHIFT
+ rb_curses_define_const(BUTTON_SHIFT);
+#endif
+#ifdef BUTTON_CTRL
+ rb_curses_define_const(BUTTON_CTRL);
+#endif
+#ifdef BUTTON_ALT
+ rb_curses_define_const(BUTTON_ALT);
+#endif
+#ifdef ALL_MOUSE_EVENTS
+ rb_curses_define_const(ALL_MOUSE_EVENTS);
+#endif
+#ifdef REPORT_MOUSE_POSITION
+ rb_curses_define_const(REPORT_MOUSE_POSITION);
+#endif
+#endif /* USE_MOUSE */
+
+#if defined(KEY_MOUSE) && defined(USE_MOUSE)
+ rb_curses_define_const(KEY_MOUSE);
+ rb_define_const(mKey, "MOUSE", INT2NUM(KEY_MOUSE));
+#endif
+#ifdef KEY_MIN
+ rb_curses_define_const(KEY_MIN);
+ rb_define_const(mKey, "MIN", INT2NUM(KEY_MIN));
+#endif
+#ifdef KEY_BREAK
+ rb_curses_define_const(KEY_BREAK);
+ rb_define_const(mKey, "BREAK", INT2NUM(KEY_BREAK));
+#endif
+#ifdef KEY_DOWN
+ rb_curses_define_const(KEY_DOWN);
+ rb_define_const(mKey, "DOWN", INT2NUM(KEY_DOWN));
+#endif
+#ifdef KEY_UP
+ rb_curses_define_const(KEY_UP);
+ rb_define_const(mKey, "UP", INT2NUM(KEY_UP));
+#endif
+#ifdef KEY_LEFT
+ rb_curses_define_const(KEY_LEFT);
+ rb_define_const(mKey, "LEFT", INT2NUM(KEY_LEFT));
+#endif
+#ifdef KEY_RIGHT
+ rb_curses_define_const(KEY_RIGHT);
+ rb_define_const(mKey, "RIGHT", INT2NUM(KEY_RIGHT));
+#endif
+#ifdef KEY_HOME
+ rb_curses_define_const(KEY_HOME);
+ rb_define_const(mKey, "HOME", INT2NUM(KEY_HOME));
+#endif
+#ifdef KEY_BACKSPACE
+ rb_curses_define_const(KEY_BACKSPACE);
+ rb_define_const(mKey, "BACKSPACE", INT2NUM(KEY_BACKSPACE));
+#endif
+#ifdef KEY_F
+ /* KEY_F(n) : 0 <= n <= 63 */
+ {
+ int i;
+ char c[8];
+ for( i=0; i<64; i++ ){
+ sprintf(c, "KEY_F%d", i);
+ rb_define_const(mCurses, c, INT2NUM(KEY_F(i)));
+ sprintf(c, "F%d", i);
+ rb_define_const(mKey, c, INT2NUM(KEY_F(i)));
+ }
+ }
+#endif
+#ifdef KEY_DL
+ rb_curses_define_const(KEY_DL);
+ rb_define_const(mKey, "DL", INT2NUM(KEY_DL));
+#endif
+#ifdef KEY_IL
+ rb_curses_define_const(KEY_IL);
+ rb_define_const(mKey, "IL", INT2NUM(KEY_IL));
+#endif
+#ifdef KEY_DC
+ rb_curses_define_const(KEY_DC);
+ rb_define_const(mKey, "DC", INT2NUM(KEY_DC));
+#endif
+#ifdef KEY_IC
+ rb_curses_define_const(KEY_IC);
+ rb_define_const(mKey, "IC", INT2NUM(KEY_IC));
+#endif
+#ifdef KEY_EIC
+ rb_curses_define_const(KEY_EIC);
+ rb_define_const(mKey, "EIC", INT2NUM(KEY_EIC));
+#endif
+#ifdef KEY_CLEAR
+ rb_curses_define_const(KEY_CLEAR);
+ rb_define_const(mKey, "CLEAR", INT2NUM(KEY_CLEAR));
+#endif
+#ifdef KEY_EOS
+ rb_curses_define_const(KEY_EOS);
+ rb_define_const(mKey, "EOS", INT2NUM(KEY_EOS));
+#endif
+#ifdef KEY_EOL
+ rb_curses_define_const(KEY_EOL);
+ rb_define_const(mKey, "EOL", INT2NUM(KEY_EOL));
+#endif
+#ifdef KEY_SF
+ rb_curses_define_const(KEY_SF);
+ rb_define_const(mKey, "SF", INT2NUM(KEY_SF));
+#endif
+#ifdef KEY_SR
+ rb_curses_define_const(KEY_SR);
+ rb_define_const(mKey, "SR", INT2NUM(KEY_SR));
+#endif
+#ifdef KEY_NPAGE
+ rb_curses_define_const(KEY_NPAGE);
+ rb_define_const(mKey, "NPAGE", INT2NUM(KEY_NPAGE));
+#endif
+#ifdef KEY_PPAGE
+ rb_curses_define_const(KEY_PPAGE);
+ rb_define_const(mKey, "PPAGE", INT2NUM(KEY_PPAGE));
+#endif
+#ifdef KEY_STAB
+ rb_curses_define_const(KEY_STAB);
+ rb_define_const(mKey, "STAB", INT2NUM(KEY_STAB));
+#endif
+#ifdef KEY_CTAB
+ rb_curses_define_const(KEY_CTAB);
+ rb_define_const(mKey, "CTAB", INT2NUM(KEY_CTAB));
+#endif
+#ifdef KEY_CATAB
+ rb_curses_define_const(KEY_CATAB);
+ rb_define_const(mKey, "CATAB", INT2NUM(KEY_CATAB));
+#endif
+#ifdef KEY_ENTER
+ rb_curses_define_const(KEY_ENTER);
+ rb_define_const(mKey, "ENTER", INT2NUM(KEY_ENTER));
+#endif
+#ifdef KEY_SRESET
+ rb_curses_define_const(KEY_SRESET);
+ rb_define_const(mKey, "SRESET", INT2NUM(KEY_SRESET));
+#endif
+#ifdef KEY_RESET
+ rb_curses_define_const(KEY_RESET);
+ rb_define_const(mKey, "RESET", INT2NUM(KEY_RESET));
+#endif
+#ifdef KEY_PRINT
+ rb_curses_define_const(KEY_PRINT);
+ rb_define_const(mKey, "PRINT", INT2NUM(KEY_PRINT));
+#endif
+#ifdef KEY_LL
+ rb_curses_define_const(KEY_LL);
+ rb_define_const(mKey, "LL", INT2NUM(KEY_LL));
+#endif
+#ifdef KEY_A1
+ rb_curses_define_const(KEY_A1);
+ rb_define_const(mKey, "A1", INT2NUM(KEY_A1));
+#endif
+#ifdef KEY_A3
+ rb_curses_define_const(KEY_A3);
+ rb_define_const(mKey, "A3", INT2NUM(KEY_A3));
+#endif
+#ifdef KEY_B2
+ rb_curses_define_const(KEY_B2);
+ rb_define_const(mKey, "B2", INT2NUM(KEY_B2));
+#endif
+#ifdef KEY_C1
+ rb_curses_define_const(KEY_C1);
+ rb_define_const(mKey, "C1", INT2NUM(KEY_C1));
+#endif
+#ifdef KEY_C3
+ rb_curses_define_const(KEY_C3);
+ rb_define_const(mKey, "C3", INT2NUM(KEY_C3));
+#endif
+#ifdef KEY_BTAB
+ rb_curses_define_const(KEY_BTAB);
+ rb_define_const(mKey, "BTAB", INT2NUM(KEY_BTAB));
+#endif
+#ifdef KEY_BEG
+ rb_curses_define_const(KEY_BEG);
+ rb_define_const(mKey, "BEG", INT2NUM(KEY_BEG));
+#endif
+#ifdef KEY_CANCEL
+ rb_curses_define_const(KEY_CANCEL);
+ rb_define_const(mKey, "CANCEL", INT2NUM(KEY_CANCEL));
+#endif
+#ifdef KEY_CLOSE
+ rb_curses_define_const(KEY_CLOSE);
+ rb_define_const(mKey, "CLOSE", INT2NUM(KEY_CLOSE));
+#endif
+#ifdef KEY_COMMAND
+ rb_curses_define_const(KEY_COMMAND);
+ rb_define_const(mKey, "COMMAND", INT2NUM(KEY_COMMAND));
+#endif
+#ifdef KEY_COPY
+ rb_curses_define_const(KEY_COPY);
+ rb_define_const(mKey, "COPY", INT2NUM(KEY_COPY));
+#endif
+#ifdef KEY_CREATE
+ rb_curses_define_const(KEY_CREATE);
+ rb_define_const(mKey, "CREATE", INT2NUM(KEY_CREATE));
+#endif
+#ifdef KEY_END
+ rb_curses_define_const(KEY_END);
+ rb_define_const(mKey, "END", INT2NUM(KEY_END));
+#endif
+#ifdef KEY_EXIT
+ rb_curses_define_const(KEY_EXIT);
+ rb_define_const(mKey, "EXIT", INT2NUM(KEY_EXIT));
+#endif
+#ifdef KEY_FIND
+ rb_curses_define_const(KEY_FIND);
+ rb_define_const(mKey, "FIND", INT2NUM(KEY_FIND));
+#endif
+#ifdef KEY_HELP
+ rb_curses_define_const(KEY_HELP);
+ rb_define_const(mKey, "HELP", INT2NUM(KEY_HELP));
+#endif
+#ifdef KEY_MARK
+ rb_curses_define_const(KEY_MARK);
+ rb_define_const(mKey, "MARK", INT2NUM(KEY_MARK));
+#endif
+#ifdef KEY_MESSAGE
+ rb_curses_define_const(KEY_MESSAGE);
+ rb_define_const(mKey, "MESSAGE", INT2NUM(KEY_MESSAGE));
+#endif
+#ifdef KEY_MOVE
+ rb_curses_define_const(KEY_MOVE);
+ rb_define_const(mKey, "MOVE", INT2NUM(KEY_MOVE));
+#endif
+#ifdef KEY_NEXT
+ rb_curses_define_const(KEY_NEXT);
+ rb_define_const(mKey, "NEXT", INT2NUM(KEY_NEXT));
+#endif
+#ifdef KEY_OPEN
+ rb_curses_define_const(KEY_OPEN);
+ rb_define_const(mKey, "OPEN", INT2NUM(KEY_OPEN));
+#endif
+#ifdef KEY_OPTIONS
+ rb_curses_define_const(KEY_OPTIONS);
+ rb_define_const(mKey, "OPTIONS", INT2NUM(KEY_OPTIONS));
+#endif
+#ifdef KEY_PREVIOUS
+ rb_curses_define_const(KEY_PREVIOUS);
+ rb_define_const(mKey, "PREVIOUS", INT2NUM(KEY_PREVIOUS));
+#endif
+#ifdef KEY_REDO
+ rb_curses_define_const(KEY_REDO);
+ rb_define_const(mKey, "REDO", INT2NUM(KEY_REDO));
+#endif
+#ifdef KEY_REFERENCE
+ rb_curses_define_const(KEY_REFERENCE);
+ rb_define_const(mKey, "REFERENCE", INT2NUM(KEY_REFERENCE));
+#endif
+#ifdef KEY_REFRESH
+ rb_curses_define_const(KEY_REFRESH);
+ rb_define_const(mKey, "REFRESH", INT2NUM(KEY_REFRESH));
+#endif
+#ifdef KEY_REPLACE
+ rb_curses_define_const(KEY_REPLACE);
+ rb_define_const(mKey, "REPLACE", INT2NUM(KEY_REPLACE));
+#endif
+#ifdef KEY_RESTART
+ rb_curses_define_const(KEY_RESTART);
+ rb_define_const(mKey, "RESTART", INT2NUM(KEY_RESTART));
+#endif
+#ifdef KEY_RESUME
+ rb_curses_define_const(KEY_RESUME);
+ rb_define_const(mKey, "RESUME", INT2NUM(KEY_RESUME));
+#endif
+#ifdef KEY_SAVE
+ rb_curses_define_const(KEY_SAVE);
+ rb_define_const(mKey, "SAVE", INT2NUM(KEY_SAVE));
+#endif
+#ifdef KEY_SBEG
+ rb_curses_define_const(KEY_SBEG);
+ rb_define_const(mKey, "SBEG", INT2NUM(KEY_SBEG));
+#endif
+#ifdef KEY_SCANCEL
+ rb_curses_define_const(KEY_SCANCEL);
+ rb_define_const(mKey, "SCANCEL", INT2NUM(KEY_SCANCEL));
+#endif
+#ifdef KEY_SCOMMAND
+ rb_curses_define_const(KEY_SCOMMAND);
+ rb_define_const(mKey, "SCOMMAND", INT2NUM(KEY_SCOMMAND));
+#endif
+#ifdef KEY_SCOPY
+ rb_curses_define_const(KEY_SCOPY);
+ rb_define_const(mKey, "SCOPY", INT2NUM(KEY_SCOPY));
+#endif
+#ifdef KEY_SCREATE
+ rb_curses_define_const(KEY_SCREATE);
+ rb_define_const(mKey, "SCREATE", INT2NUM(KEY_SCREATE));
+#endif
+#ifdef KEY_SDC
+ rb_curses_define_const(KEY_SDC);
+ rb_define_const(mKey, "SDC", INT2NUM(KEY_SDC));
+#endif
+#ifdef KEY_SDL
+ rb_curses_define_const(KEY_SDL);
+ rb_define_const(mKey, "SDL", INT2NUM(KEY_SDL));
+#endif
+#ifdef KEY_SELECT
+ rb_curses_define_const(KEY_SELECT);
+ rb_define_const(mKey, "SELECT", INT2NUM(KEY_SELECT));
+#endif
+#ifdef KEY_SEND
+ rb_curses_define_const(KEY_SEND);
+ rb_define_const(mKey, "SEND", INT2NUM(KEY_SEND));
+#endif
+#ifdef KEY_SEOL
+ rb_curses_define_const(KEY_SEOL);
+ rb_define_const(mKey, "SEOL", INT2NUM(KEY_SEOL));
+#endif
+#ifdef KEY_SEXIT
+ rb_curses_define_const(KEY_SEXIT);
+ rb_define_const(mKey, "SEXIT", INT2NUM(KEY_SEXIT));
+#endif
+#ifdef KEY_SFIND
+ rb_curses_define_const(KEY_SFIND);
+ rb_define_const(mKey, "SFIND", INT2NUM(KEY_SFIND));
+#endif
+#ifdef KEY_SHELP
+ rb_curses_define_const(KEY_SHELP);
+ rb_define_const(mKey, "SHELP", INT2NUM(KEY_SHELP));
+#endif
+#ifdef KEY_SHOME
+ rb_curses_define_const(KEY_SHOME);
+ rb_define_const(mKey, "SHOME", INT2NUM(KEY_SHOME));
+#endif
+#ifdef KEY_SIC
+ rb_curses_define_const(KEY_SIC);
+ rb_define_const(mKey, "SIC", INT2NUM(KEY_SIC));
+#endif
+#ifdef KEY_SLEFT
+ rb_curses_define_const(KEY_SLEFT);
+ rb_define_const(mKey, "SLEFT", INT2NUM(KEY_SLEFT));
+#endif
+#ifdef KEY_SMESSAGE
+ rb_curses_define_const(KEY_SMESSAGE);
+ rb_define_const(mKey, "SMESSAGE", INT2NUM(KEY_SMESSAGE));
+#endif
+#ifdef KEY_SMOVE
+ rb_curses_define_const(KEY_SMOVE);
+ rb_define_const(mKey, "SMOVE", INT2NUM(KEY_SMOVE));
+#endif
+#ifdef KEY_SNEXT
+ rb_curses_define_const(KEY_SNEXT);
+ rb_define_const(mKey, "SNEXT", INT2NUM(KEY_SNEXT));
+#endif
+#ifdef KEY_SOPTIONS
+ rb_curses_define_const(KEY_SOPTIONS);
+ rb_define_const(mKey, "SOPTIONS", INT2NUM(KEY_SOPTIONS));
+#endif
+#ifdef KEY_SPREVIOUS
+ rb_curses_define_const(KEY_SPREVIOUS);
+ rb_define_const(mKey, "SPREVIOUS", INT2NUM(KEY_SPREVIOUS));
+#endif
+#ifdef KEY_SPRINT
+ rb_curses_define_const(KEY_SPRINT);
+ rb_define_const(mKey, "SPRINT", INT2NUM(KEY_SPRINT));
+#endif
+#ifdef KEY_SREDO
+ rb_curses_define_const(KEY_SREDO);
+ rb_define_const(mKey, "SREDO", INT2NUM(KEY_SREDO));
+#endif
+#ifdef KEY_SREPLACE
+ rb_curses_define_const(KEY_SREPLACE);
+ rb_define_const(mKey, "SREPLACE", INT2NUM(KEY_SREPLACE));
+#endif
+#ifdef KEY_SRIGHT
+ rb_curses_define_const(KEY_SRIGHT);
+ rb_define_const(mKey, "SRIGHT", INT2NUM(KEY_SRIGHT));
+#endif
+#ifdef KEY_SRSUME
+ rb_curses_define_const(KEY_SRSUME);
+ rb_define_const(mKey, "SRSUME", INT2NUM(KEY_SRSUME));
+#endif
+#ifdef KEY_SSAVE
+ rb_curses_define_const(KEY_SSAVE);
+ rb_define_const(mKey, "SSAVE", INT2NUM(KEY_SSAVE));
+#endif
+#ifdef KEY_SSUSPEND
+ rb_curses_define_const(KEY_SSUSPEND);
+ rb_define_const(mKey, "SSUSPEND", INT2NUM(KEY_SSUSPEND));
+#endif
+#ifdef KEY_SUNDO
+ rb_curses_define_const(KEY_SUNDO);
+ rb_define_const(mKey, "SUNDO", INT2NUM(KEY_SUNDO));
+#endif
+#ifdef KEY_SUSPEND
+ rb_curses_define_const(KEY_SUSPEND);
+ rb_define_const(mKey, "SUSPEND", INT2NUM(KEY_SUSPEND));
+#endif
+#ifdef KEY_UNDO
+ rb_curses_define_const(KEY_UNDO);
+ rb_define_const(mKey, "UNDO", INT2NUM(KEY_UNDO));
+#endif
+#ifdef KEY_RESIZE
+ rb_curses_define_const(KEY_RESIZE);
+ rb_define_const(mKey, "RESIZE", INT2NUM(KEY_RESIZE));
+#endif
+#ifdef KEY_MAX
+ rb_curses_define_const(KEY_MAX);
+ rb_define_const(mKey, "MAX", INT2NUM(KEY_MAX));
+#endif
+ {
+ int c;
+ char name[] = "KEY_CTRL_x";
+ for( c = 'A'; c <= 'Z'; c++ ){
+ sprintf(name, "KEY_CTRL_%c", c);
+ rb_define_const(mCurses, name, INT2FIX(c - 'A' + 1));
+ }
+ }
+#undef rb_curses_define_const
rb_set_end_proc(curses_finalize, 0);
}
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index c16ab00f28..9b319ba30e 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -6,22 +6,26 @@ dir_config('termcap')
make=false
have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM
-if have_header("ncurses.h") and have_library("ncurses", "initscr")
+have_library("tinfo", "tgetent") or have_library("termcap", "tgetent")
+if have_header(*curses=%w"ncurses.h") and have_library("ncurses", "initscr")
make=true
-elsif have_header("ncurses/curses.h") and have_library("ncurses", "initscr")
+elsif have_header(*curses=%w"ncurses/curses.h") and have_library("ncurses", "initscr")
make=true
-elsif have_header("curses_colr/curses.h") and have_library("cur_colr", "initscr")
+elsif have_header(*curses=%w"curses_colr/curses.h") and have_library("cur_colr", "initscr")
+ curses.unshift("varargs.h")
+ make=true
+elsif have_header(*curses=%w"curses.h") and have_library("curses", "initscr")
make=true
-else
- have_library("termcap", "tgetent")
- if have_library("curses", "initscr")
- make=true
- end
end
if make
- for f in %w(isendwin ungetch beep doupdate flash deleteln wdeleteln)
+ for f in %w(beep bkgd bkgdset curs_set deleteln doupdate flash getbkgd getnstr init isendwin keyname keypad resizeterm scrl set setscrreg ungetch wattroff wattron wattrset wbkgd wbkgdset wdeleteln wgetnstr wresize wscrl wsetscrreg def_prog_mode reset_prog_mode timeout wtimeout nodelay init_color)
have_func(f)
end
+ flag = "-D_XOPEN_SOURCE_EXTENDED"
+ src = "int test_var[(sizeof(char*)>sizeof(int))*2-1];"
+ if try_compile(cpp_include(%w[stdio.h stdlib.h]+curses)+src , flag)
+ $defs << flag
+ end
create_makefile("curses")
end
diff --git a/ext/curses/hello.rb b/ext/curses/hello.rb
index a1915ce60d..7f57d801a3 100644
--- a/ext/curses/hello.rb
+++ b/ext/curses/hello.rb
@@ -7,7 +7,7 @@ def show_message(message)
width = message.length + 6
win = Window.new(5, width,
(lines - 5) / 2, (cols - width) / 2)
- win.box(?|, ?=)
+ win.box(?|, ?-)
win.setpos(2, 3)
win.addstr(message)
win.refresh
diff --git a/ext/curses/mouse.rb b/ext/curses/mouse.rb
new file mode 100644
index 0000000000..c42bc31f33
--- /dev/null
+++ b/ext/curses/mouse.rb
@@ -0,0 +1,53 @@
+#!/usr/local/bin/ruby
+
+require "curses"
+include Curses
+
+def show_message(*msgs)
+ message = msgs.join
+ width = message.length + 6
+ win = Window.new(5, width,
+ (lines - 5) / 2, (cols - width) / 2)
+ win.keypad = true
+ win.attron(color_pair(COLOR_RED)){
+ win.box(?|, ?-, ?+)
+ }
+ win.setpos(2, 3)
+ win.addstr(message)
+ win.refresh
+ win.getch
+ win.close
+end
+
+init_screen
+start_color
+init_pair(COLOR_BLUE,COLOR_BLUE,COLOR_WHITE)
+init_pair(COLOR_RED,COLOR_RED,COLOR_WHITE)
+crmode
+noecho
+stdscr.keypad(true)
+
+begin
+ mousemask(BUTTON1_CLICKED|BUTTON2_CLICKED|BUTTON3_CLICKED|BUTTON4_CLICKED)
+ setpos((lines - 5) / 2, (cols - 10) / 2)
+ attron(color_pair(COLOR_BLUE)|A_BOLD){
+ addstr("click")
+ }
+ refresh
+ while( true )
+ c = getch
+ case c
+ when KEY_MOUSE
+ m = getmouse
+ if( m )
+ show_message("getch = #{c.inspect}, ",
+ "mouse event = #{'0x%x' % m.bstate}, ",
+ "axis = (#{m.x},#{m.y},#{m.z})")
+ end
+ break
+ end
+ end
+ refresh
+ensure
+ close_screen
+end
diff --git a/ext/curses/view2.rb b/ext/curses/view2.rb
new file mode 100644
index 0000000000..18d9619216
--- /dev/null
+++ b/ext/curses/view2.rb
@@ -0,0 +1,115 @@
+#!/usr/local/bin/ruby
+
+require "curses"
+
+if ARGV.size != 1 then
+ printf("usage: view file\n");
+ exit
+end
+begin
+ fp = open(ARGV[0], "r")
+rescue
+ raise "cannot open file: #{ARGV[1]}"
+end
+
+# signal(SIGINT, finish)
+
+Curses.init_screen
+Curses.nonl
+Curses.cbreak
+Curses.noecho
+
+$screen = Curses.stdscr
+
+$screen.scrollok(true)
+#$screen.keypad(true)
+
+# slurp the file
+$data_lines = []
+fp.each_line { |l|
+ $data_lines.push(l.chop)
+}
+fp.close
+
+$top = 0
+$data_lines[0..$screen.maxy-1].each_with_index{|line, idx|
+ $screen.setpos(idx, 0)
+ $screen.addstr(line)
+}
+$screen.setpos(0,0)
+$screen.refresh
+
+def scroll_up
+ if( $top > 0 )
+ $screen.scrl(-1)
+ $top -= 1
+ str = $data_lines[$top]
+ if( str )
+ $screen.setpos(0, 0)
+ $screen.addstr(str)
+ end
+ return true
+ else
+ return false
+ end
+end
+
+def scroll_down
+ if( $top + $screen.maxy < $data_lines.length )
+ $screen.scrl(1)
+ $top += 1
+ str = $data_lines[$top + $screen.maxy - 1]
+ if( str )
+ $screen.setpos($screen.maxy - 1, 0)
+ $screen.addstr(str)
+ end
+ return true
+ else
+ return false
+ end
+end
+
+while true
+ result = true
+ c = Curses.getch
+ case c
+ when Curses::KEY_DOWN, Curses::KEY_CTRL_N
+ result = scroll_down
+ when Curses::KEY_UP, Curses::KEY_CTRL_P
+ result = scroll_up
+ when Curses::KEY_NPAGE, ?\s # white space
+ for i in 0..($screen.maxy - 2)
+ if( ! scroll_down )
+ if( i == 0 )
+ result = false
+ end
+ break
+ end
+ end
+ when Curses::KEY_PPAGE
+ for i in 0..($screen.maxy - 2)
+ if( ! scroll_up )
+ if( i == 0 )
+ result = false
+ end
+ break
+ end
+ end
+ when Curses::KEY_LEFT, Curses::KEY_CTRL_T
+ while( scroll_up )
+ end
+ when Curses::KEY_RIGHT, Curses::KEY_CTRL_B
+ while( scroll_down )
+ end
+ when ?q
+ break
+ else
+ $screen.setpos(0,0)
+ $screen.addstr("[unknown key `#{Curses.keyname(c)}'=#{c}] ")
+ end
+ if( !result )
+ Curses.beep
+ end
+ $screen.setpos(0,0)
+end
+Curses.close_screen
diff --git a/ext/dbm/.cvsignore b/ext/dbm/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/dbm/.cvsignore
+++ b/ext/dbm/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/dbm/MANIFEST b/ext/dbm/MANIFEST
deleted file mode 100644
index 8beec6783d..0000000000
--- a/ext/dbm/MANIFEST
+++ /dev/null
@@ -1,4 +0,0 @@
-MANIFEST
-dbm.c
-depend
-extconf.rb
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 55c60bf3b3..e609327c46 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Jan 24 15:59:52 JST 1994
- Copyright (C) 1995-1998 Yukihiro Matsumoto
+ Copyright (C) 1995-2001 Yukihiro Matsumoto
************************************************/
@@ -18,11 +18,13 @@
#ifdef HAVE_SYS_CDEFS_H
# include <sys/cdefs.h>
#endif
-#include <ndbm.h>
+#include DBM_HDR
#include <fcntl.h>
#include <errno.h>
-VALUE cDBM;
+static VALUE rb_cDBM, rb_eDBMError;
+
+#define RUBY_DBM_RW_BIT 0x20000000
struct dbmdata {
int di_size;
@@ -32,11 +34,12 @@ struct dbmdata {
static void
closed_dbm()
{
- rb_raise(rb_eRuntimeError, "closed DBM file");
+ rb_raise(rb_eDBMError, "closed DBM file");
}
#define GetDBM(obj, dbmp) {\
Data_Get_Struct(obj, struct dbmdata, dbmp);\
+ if (dbmp == 0) closed_dbm();\
if (dbmp->di_dbm == 0) closed_dbm();\
}
@@ -44,23 +47,45 @@ static void
free_dbm(dbmp)
struct dbmdata *dbmp;
{
- if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
- free(dbmp);
+ if (dbmp) {
+ if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
+ free(dbmp);
+ }
}
static VALUE
-fdbm_s_open(argc, argv, klass)
+fdbm_close(obj)
+ VALUE obj;
+{
+ struct dbmdata *dbmp;
+
+ GetDBM(obj, dbmp);
+ dbm_close(dbmp->di_dbm);
+ dbmp->di_dbm = 0;
+
+ return Qnil;
+}
+
+static VALUE fdbm_alloc _((VALUE));
+static VALUE
+fdbm_alloc(klass)
+ VALUE klass;
+{
+ return Data_Wrap_Struct(klass, 0, free_dbm, 0);
+}
+
+static VALUE
+fdbm_initialize(argc, argv, obj)
int argc;
VALUE *argv;
- VALUE klass;
+ VALUE obj;
{
- VALUE file, vmode;
+ VALUE file, vmode, vflags;
DBM *dbm;
struct dbmdata *dbmp;
- int mode;
- VALUE obj;
+ int mode, flags = 0;
- if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
+ if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) {
mode = 0666; /* default value */
}
else if (NIL_P(vmode)) {
@@ -69,17 +94,27 @@ fdbm_s_open(argc, argv, klass)
else {
mode = NUM2INT(vmode);
}
- Check_SafeStr(file);
- dbm = 0;
- if (mode >= 0) {
- dbm = dbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
- }
- if (!dbm) {
- dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, 0);
+ if (!NIL_P(vflags))
+ flags = NUM2INT(vflags);
+
+ SafeStringValue(file);
+
+ if (flags & RUBY_DBM_RW_BIT) {
+ flags &= ~RUBY_DBM_RW_BIT;
+ dbm = dbm_open(RSTRING(file)->ptr, flags, mode);
}
- if (!dbm) {
- dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, 0);
+ else {
+ dbm = 0;
+ if (mode >= 0) {
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDWR|O_CREAT, mode);
+ }
+ if (!dbm) {
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDWR, 0);
+ }
+ if (!dbm) {
+ dbm = dbm_open(RSTRING(file)->ptr, O_RDONLY, 0);
+ }
}
if (!dbm) {
@@ -87,7 +122,8 @@ fdbm_s_open(argc, argv, klass)
rb_sys_fail(RSTRING(file)->ptr);
}
- obj = Data_Make_Struct(klass,struct dbmdata,0,free_dbm,dbmp);
+ dbmp = ALLOC(struct dbmdata);
+ DATA_PTR(obj) = dbmp;
dbmp->di_dbm = dbm;
dbmp->di_size = -1;
@@ -95,16 +131,22 @@ fdbm_s_open(argc, argv, klass)
}
static VALUE
-fdbm_close(obj)
- VALUE obj;
+fdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
- struct dbmdata *dbmp;
+ VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
- GetDBM(obj, dbmp);
- dbm_close(dbmp->di_dbm);
- dbmp->di_dbm = 0;
+ if (NIL_P(fdbm_initialize(argc, argv, obj))) {
+ return Qnil;
+ }
- return Qnil;
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, fdbm_close, obj);
+ }
+
+ return obj;
}
static VALUE
@@ -115,7 +157,7 @@ fdbm_fetch(obj, keystr, ifnone)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(keystr, T_STRING);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
@@ -143,10 +185,14 @@ fdbm_fetch_m(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- VALUE keystr, ifnone;
+ VALUE keystr, valstr, ifnone;
rb_scan_args(argc, argv, "11", &keystr, &ifnone);
- return fdbm_fetch(obj, keystr, ifnone);
+ valstr = fdbm_fetch(obj, keystr, ifnone);
+ if (argc == 1 && !rb_block_given_p() && NIL_P(valstr))
+ rb_raise(rb_eIndexError, "key not found");
+
+ return valstr;
}
static VALUE
@@ -157,7 +203,7 @@ fdbm_index(obj, valstr)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(valstr, T_STRING);
+ StringValue(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
@@ -166,8 +212,9 @@ fdbm_index(obj, valstr)
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
if (val.dsize == RSTRING(valstr)->len &&
- memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
+ memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0) {
return rb_tainted_str_new(key.dptr, key.dsize);
+ }
}
return Qnil;
}
@@ -183,22 +230,87 @@ fdbm_indexes(argc, argv, obj)
new = rb_ary_new2(argc);
for (i=0; i<argc; i++) {
- rb_ary_push(new, fdbm_fetch(obj, argv[i]));
+ rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
}
return new;
}
static VALUE
+fdbm_select(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ if (rb_block_given_p()) {
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
+ }
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ VALUE assoc;
+ val = dbm_fetch(dbm, key);
+ assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
+ if (RTEST(rb_yield(assoc)))
+ rb_ary_push(new, assoc);
+ }
+ }
+ else {
+ rb_warn("DBM#select(index..) is deprecated; use DBM#values_at");
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
+ }
+ }
+
+ return new;
+}
+
+static VALUE
+fdbm_values_at(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
+ }
+
+ return new;
+}
+
+static void
+fdbm_modify(obj)
+ VALUE obj;
+{
+ rb_secure(4);
+ if (OBJ_FROZEN(obj)) rb_error_frozen("DBM");
+}
+
+static VALUE
fdbm_delete(obj, keystr)
VALUE obj, keystr;
{
datum key, value;
struct dbmdata *dbmp;
DBM *dbm;
+ VALUE valstr;
- rb_secure(4);
- Check_Type(keystr, T_STRING);
+ fdbm_modify(obj);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
@@ -207,18 +319,21 @@ fdbm_delete(obj, keystr)
value = dbm_fetch(dbm, key);
if (value.dptr == 0) {
- if (rb_block_given_p()) rb_yield(keystr);
+ if (rb_block_given_p()) return rb_yield(keystr);
return Qnil;
}
+ /* need to save value before dbm_delete() */
+ valstr = rb_tainted_str_new(value.dptr, value.dsize);
+
if (dbm_delete(dbm, key)) {
dbmp->di_size = -1;
- rb_raise(rb_eRuntimeError, "dbm_delete failed");
+ rb_raise(rb_eDBMError, "dbm_delete failed");
}
else if (dbmp->di_size >= 0) {
dbmp->di_size--;
}
- return obj;
+ return valstr;
}
static VALUE
@@ -230,17 +345,18 @@ fdbm_shift(obj)
DBM *dbm;
VALUE keystr, valstr;
- rb_secure(4);
+ fdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
+ dbmp->di_size = -1;
key = dbm_firstkey(dbm);
if (!key.dptr) return Qnil;
val = dbm_fetch(dbm, key);
- dbm_delete(dbm, key);
-
keystr = rb_tainted_str_new(key.dptr, key.dsize);
valstr = rb_tainted_str_new(val.dptr, val.dsize);
+ dbm_delete(dbm, key);
+
return rb_assoc_new(keystr, valstr);
}
@@ -252,20 +368,36 @@ fdbm_delete_if(obj)
struct dbmdata *dbmp;
DBM *dbm;
VALUE keystr, valstr;
+ VALUE ret, ary = rb_ary_new();
+ int i, status = 0, n;
- rb_secure(4);
+ fdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
+ n = dbmp->di_size;
+ dbmp->di_size = -1;
+
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
keystr = rb_tainted_str_new(key.dptr, key.dsize);
valstr = rb_tainted_str_new(val.dptr, val.dsize);
- if (RTEST(rb_yield(rb_assoc_new(keystr, valstr)))) {
- if (dbm_delete(dbm, key)) {
- rb_raise(rb_eRuntimeError, "dbm_delete failed");
- }
+ ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
+ if (status != 0) break;
+ if (RTEST(ret)) rb_ary_push(ary, keystr);
+ }
+
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ keystr = RARRAY(ary)->ptr[i];
+ StringValue(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+ if (dbm_delete(dbm, key)) {
+ rb_raise(rb_eDBMError, "dbm_delete failed");
}
}
+ if (status) rb_jump_tag(status);
+ if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
+
return obj;
}
@@ -277,15 +409,17 @@ fdbm_clear(obj)
struct dbmdata *dbmp;
DBM *dbm;
- rb_secure(4);
+ fdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
dbmp->di_size = -1;
- for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ while (key = dbm_firstkey(dbm), key.dptr) {
if (dbm_delete(dbm, key)) {
- rb_raise(rb_eRuntimeError, "dbm_delete failed");
+ rb_raise(rb_eDBMError, "dbm_delete failed");
}
}
+ dbmp->di_size = 0;
+
return obj;
}
@@ -310,6 +444,8 @@ fdbm_invert(obj)
return hash;
}
+static VALUE each_pair _((VALUE));
+
static VALUE
each_pair(obj)
VALUE obj;
@@ -356,7 +492,7 @@ fdbm_store(obj, keystr, valstr)
struct dbmdata *dbmp;
DBM *dbm;
- rb_secure(4);
+ fdbm_modify(obj);
keystr = rb_obj_as_string(keystr);
key.dptr = RSTRING(keystr)->ptr;
@@ -374,7 +510,7 @@ fdbm_store(obj, keystr, valstr)
dbm_clearerr(dbm);
#endif
if (errno == EPERM) rb_sys_fail(0);
- rb_raise(rb_eRuntimeError, "dbm_store failed");
+ rb_raise(rb_eDBMError, "dbm_store failed");
}
return valstr;
@@ -529,7 +665,7 @@ fdbm_has_key(obj, keystr)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(keystr, T_STRING);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
@@ -548,7 +684,7 @@ fdbm_has_value(obj, valstr)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(valstr, T_STRING);
+ StringValue(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
@@ -617,45 +753,60 @@ fdbm_reject(obj)
void
Init_dbm()
{
- cDBM = rb_define_class("DBM", rb_cObject);
- rb_include_module(cDBM, rb_mEnumerable);
-
- rb_define_singleton_method(cDBM, "open", fdbm_s_open, -1);
- rb_define_singleton_method(cDBM, "new", fdbm_s_open, -1);
- rb_define_method(cDBM, "close", fdbm_close, 0);
- rb_define_method(cDBM, "[]", fdbm_aref, 1);
- rb_define_method(cDBM, "fetch", fdbm_fetch_m, -1);
- rb_define_method(cDBM, "[]=", fdbm_store, 2);
- rb_define_method(cDBM, "store", fdbm_store, 2);
- rb_define_method(cDBM, "index", fdbm_index, 1);
- rb_define_method(cDBM, "indexes", fdbm_indexes, -1);
- rb_define_method(cDBM, "indices", fdbm_indexes, -1);
- rb_define_method(cDBM, "length", fdbm_length, 0);
- rb_define_alias(cDBM, "size", "length");
- rb_define_method(cDBM, "empty?", fdbm_empty_p, 0);
- rb_define_method(cDBM, "each", fdbm_each_pair, 0);
- rb_define_method(cDBM, "each_value", fdbm_each_value, 0);
- rb_define_method(cDBM, "each_key", fdbm_each_key, 0);
- rb_define_method(cDBM, "each_pair", fdbm_each_pair, 0);
- rb_define_method(cDBM, "keys", fdbm_keys, 0);
- rb_define_method(cDBM, "values", fdbm_values, 0);
- rb_define_method(cDBM, "shift", fdbm_shift, 1);
- rb_define_method(cDBM, "delete", fdbm_delete, 1);
- rb_define_method(cDBM, "delete_if", fdbm_delete_if, 0);
- rb_define_method(cDBM, "reject!", fdbm_delete_if, 0);
- rb_define_method(cDBM, "reject", fdbm_reject, 0);
- rb_define_method(cDBM, "clear", fdbm_clear, 0);
- rb_define_method(cDBM,"invert", fdbm_invert, 0);
- rb_define_method(cDBM,"update", fdbm_update, 1);
- rb_define_method(cDBM,"replace", fdbm_replace, 1);
-
- rb_define_method(cDBM, "include?", fdbm_has_key, 1);
- rb_define_method(cDBM, "has_key?", fdbm_has_key, 1);
- rb_define_method(cDBM, "member?", fdbm_has_key, 1);
- rb_define_method(cDBM, "has_value?", fdbm_has_value, 1);
- rb_define_method(cDBM, "key?", fdbm_has_key, 1);
- rb_define_method(cDBM, "value?", fdbm_has_value, 1);
-
- rb_define_method(cDBM, "to_a", fdbm_to_a, 0);
- rb_define_method(cDBM, "to_hash", fdbm_to_hash, 0);
+ rb_cDBM = rb_define_class("DBM", rb_cObject);
+ rb_eDBMError = rb_define_class("DBMError", rb_eStandardError);
+ rb_include_module(rb_cDBM, rb_mEnumerable);
+
+ rb_define_alloc_func(rb_cDBM, fdbm_alloc);
+ rb_define_singleton_method(rb_cDBM, "open", fdbm_s_open, -1);
+
+ rb_define_method(rb_cDBM, "initialize", fdbm_initialize, -1);
+ rb_define_method(rb_cDBM, "close", fdbm_close, 0);
+ rb_define_method(rb_cDBM, "[]", fdbm_aref, 1);
+ rb_define_method(rb_cDBM, "fetch", fdbm_fetch_m, -1);
+ rb_define_method(rb_cDBM, "[]=", fdbm_store, 2);
+ rb_define_method(rb_cDBM, "store", fdbm_store, 2);
+ rb_define_method(rb_cDBM, "index", fdbm_index, 1);
+ rb_define_method(rb_cDBM, "indexes", fdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "indices", fdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "select", fdbm_select, 0);
+ rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
+ rb_define_method(rb_cDBM, "length", fdbm_length, 0);
+ rb_define_method(rb_cDBM, "size", fdbm_length, 0);
+ rb_define_method(rb_cDBM, "empty?", fdbm_empty_p, 0);
+ rb_define_method(rb_cDBM, "each", fdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "each_value", fdbm_each_value, 0);
+ rb_define_method(rb_cDBM, "each_key", fdbm_each_key, 0);
+ rb_define_method(rb_cDBM, "each_pair", fdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "keys", fdbm_keys, 0);
+ rb_define_method(rb_cDBM, "values", fdbm_values, 0);
+ rb_define_method(rb_cDBM, "shift", fdbm_shift, 0);
+ rb_define_method(rb_cDBM, "delete", fdbm_delete, 1);
+ rb_define_method(rb_cDBM, "delete_if", fdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject!", fdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject", fdbm_reject, 0);
+ rb_define_method(rb_cDBM, "clear", fdbm_clear, 0);
+ rb_define_method(rb_cDBM,"invert", fdbm_invert, 0);
+ rb_define_method(rb_cDBM,"update", fdbm_update, 1);
+ rb_define_method(rb_cDBM,"replace", fdbm_replace, 1);
+
+ rb_define_method(rb_cDBM, "include?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "has_key?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "member?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "has_value?", fdbm_has_value, 1);
+ rb_define_method(rb_cDBM, "key?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "value?", fdbm_has_value, 1);
+
+ rb_define_method(rb_cDBM, "to_a", fdbm_to_a, 0);
+ rb_define_method(rb_cDBM, "to_hash", fdbm_to_hash, 0);
+
+ /* flags for dbm_open() */
+ rb_define_const(rb_cDBM, "READER", INT2FIX(O_RDONLY|RUBY_DBM_RW_BIT));
+ rb_define_const(rb_cDBM, "WRITER", INT2FIX(O_RDWR|RUBY_DBM_RW_BIT));
+ rb_define_const(rb_cDBM, "WRCREAT", INT2FIX(O_RDWR|O_CREAT|RUBY_DBM_RW_BIT));
+ rb_define_const(rb_cDBM, "NEWDB", INT2FIX(O_RDWR|O_CREAT|O_TRUNC|RUBY_DBM_RW_BIT));
+
+#ifdef DB_VERSION_STRING
+ rb_define_const(rb_cDBM, "VERSION", rb_str_new2(DB_VERSION_STRING));
+#endif
}
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 9ce235a2b5..5a67603e69 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -1,13 +1,61 @@
require 'mkmf'
dir_config("dbm")
-if have_library("gdbm", "dbm_open")
- gdbm = true
+
+dblib = with_config("dbm-type", nil)
+
+$dbm_conf_headers = {
+ "db" => ["db.h"],
+ "db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"],
+ "db2" => ["db2/db.h", "db2.h", "db.h"],
+ "dbm" => ["ndbm.h"],
+ "gdbm" => ["gdbm-ndbm.h", "ndbm.h"],
+ "gdbm_compat" => ["gdbm-ndbm.h", "ndbm.h"],
+ "qdbm" => ["relic.h"],
+}
+
+def db_check(db)
+ $dbm_conf_db_prefix = ""
+ $dbm_conf_have_gdbm = false
+ hsearch = ""
+
+ case db
+ when /^db2?$/
+ $dbm_conf_db_prefix = "__db_n"
+ hsearch = "-DDB_DBM_HSEARCH "
+ when "gdbm"
+ $dbm_conf_have_gdbm = true
+ when "gdbm_compat"
+ $dbm_conf_have_gdbm = true
+ have_library("gdbm") or return false
+ end
+
+ if have_library(db, db_prefix("dbm_open")) || have_func(db_prefix("dbm_open"))
+ for hdr in $dbm_conf_headers.fetch(db, ["ndbm.h"])
+ if have_header(hdr.dup) and have_type("DBM", hdr.dup, hsearch)
+ $CFLAGS += " " + hsearch + '-DDBM_HDR="<'+hdr+'>"'
+ return true
+ end
+ end
+ end
+ return false
end
-gdbm or have_library("db", "dbm_open") or have_library("dbm", "dbm_open")
+
+def db_prefix(func)
+ $dbm_conf_db_prefix+func
+end
+
+if dblib
+ db_check(dblib)
+else
+ for dblib in %w(db db2 db1 dbm gdbm gdbm_compat qdbm)
+ db_check(dblib) and break
+ end
+end
+
have_header("cdefs.h")
have_header("sys/cdefs.h")
-if have_header("ndbm.h") and have_func("dbm_open")
- have_func("dbm_clearerr") unless gdbm
+if /DBM_HDR/ =~ $CFLAGS and have_func(db_prefix("dbm_open"))
+ have_func(db_prefix("dbm_clearerr")) unless $dbm_conf_have_gdbm
create_makefile("dbm")
end
diff --git a/ext/dbm/testdbm.rb b/ext/dbm/testdbm.rb
new file mode 100644
index 0000000000..4942ffb64a
--- /dev/null
+++ b/ext/dbm/testdbm.rb
@@ -0,0 +1,593 @@
+require 'runit/testcase'
+require 'runit/cui/testrunner'
+
+if $".grep(/\bdbm.so\b/).empty?
+ begin
+ require './dbm'
+ rescue LoadError
+ require 'dbm'
+ end
+end
+
+def uname_s
+ require 'rbconfig'
+ case Config::CONFIG['host_os']
+ when 'cygwin'
+ require 'Win32API'
+ uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
+ utsname = ' ' * 100
+ raise 'cannot get system name' if uname.call(utsname) == -1
+
+ utsname.unpack('A20' * 5)[0]
+ else
+ Config::CONFIG['host_os']
+ end
+end
+
+SYSTEM = uname_s
+
+class TestDBM < RUNIT::TestCase
+ def setup
+ @path = "tmptest_dbm_"
+ assert_instance_of(DBM, @dbm = DBM.new(@path))
+
+ # prepare to make readonly DBM file
+ DBM.open("tmptest_dbm_rdonly") {|dbm|
+ dbm['foo'] = 'FOO'
+ }
+
+ File.chmod(0400, *Dir.glob("tmptest_dbm_rdonly.*"))
+
+ assert_instance_of(DBM, @dbm_rdonly = DBM.new("tmptest_dbm_rdonly", nil))
+ end
+ def teardown
+ assert_nil(@dbm.close)
+ assert_nil(@dbm_rdonly.close)
+ GC.start
+ File.delete *Dir.glob("tmptest_dbm*").to_a
+ p Dir.glob("tmptest_dbm*") if $DEBUG
+ end
+
+ def check_size(expect, dbm=@dbm)
+ assert_equals(expect, dbm.size)
+ n = 0
+ dbm.each { n+=1 }
+ assert_equals(expect, n)
+ if expect == 0
+ assert_equals(true, dbm.empty?)
+ else
+ assert_equals(false, dbm.empty?)
+ end
+ end
+
+ def test_version
+ STDERR.print DBM::VERSION
+ end
+
+ def test_s_new_has_no_block
+ # DBM.new ignore the block
+ foo = true
+ assert_instance_of(DBM, dbm = DBM.new("tmptest_dbm") { foo = false })
+ assert_equals(foo, true)
+ assert_nil(dbm.close)
+ end
+ def test_s_open_no_create
+ assert_nil(dbm = DBM.open("tmptest_dbm", nil))
+ ensure
+ dbm.close if dbm
+ end
+ def test_s_open_with_block
+ assert_equals(DBM.open("tmptest_dbm") { :foo }, :foo)
+ end
+ def test_s_open_lock
+ fork() {
+ assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644))
+ sleep 2
+ }
+ begin
+ sleep 1
+ assert_exception(Errno::EWOULDBLOCK, "NEVER MIND IF YOU USE Berkeley DB3") {
+ begin
+ assert_instance_of(DBM, dbm2 = DBM.open("tmptest_dbm", 0644))
+ rescue Errno::EAGAIN, Errno::EACCES, Errno::EINVAL
+ raise Errno::EWOULDBLOCK
+ end
+ }
+ ensure
+ Process.wait
+ end
+ end
+
+=begin
+ # Is it guaranteed on many OS?
+ def test_s_open_lock_one_process
+ # locking on one process
+ assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644))
+ assert_exception(Errno::EWOULDBLOCK) {
+ begin
+ DBM.open("tmptest_dbm", 0644)
+ rescue Errno::EAGAIN
+ raise Errno::EWOULDBLOCK
+ end
+ }
+ end
+=end
+
+ def test_s_open_nolock
+ # dbm 1.8.0 specific
+ if not defined? DBM::NOLOCK
+ return
+ end
+
+ fork() {
+ assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644,
+ DBM::NOLOCK))
+ sleep 2
+ }
+ sleep 1
+ begin
+ dbm2 = nil
+ assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
+ assert_instance_of(DBM, dbm2 = DBM.open("tmptest_dbm", 0644))
+ }
+ ensure
+ Process.wait
+ dbm2.close if dbm2
+ end
+
+ p Dir.glob("tmptest_dbm*") if $DEBUG
+
+ fork() {
+ assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0644))
+ sleep 2
+ }
+ begin
+ sleep 1
+ dbm2 = nil
+ assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
+ # this test is failed on Cygwin98 (???)
+ assert_instance_of(DBM, dbm2 = DBM.open("tmptest_dbm", 0644,
+ DBM::NOLOCK))
+ }
+ ensure
+ Process.wait
+ dbm2.close if dbm2
+ end
+ end
+
+ def test_s_open_error
+ assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm", 0))
+ assert_exception(Errno::EACCES, "NEVER MIND IF YOU USE Berkeley DB3") {
+ DBM.open("tmptest_dbm", 0)
+ }
+ dbm.close
+ end
+
+ def test_close
+ assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm"))
+ assert_nil(dbm.close)
+
+ # closed DBM file
+ assert_exception(DBMError) { dbm.close }
+ end
+
+ def test_aref
+ assert_equals('bar', @dbm['foo'] = 'bar')
+ assert_equals('bar', @dbm['foo'])
+
+ assert_nil(@dbm['bar'])
+ end
+
+ def test_fetch
+ assert_equals('bar', @dbm['foo']='bar')
+ assert_equals('bar', @dbm.fetch('foo'))
+
+ # key not found
+ assert_exception(IndexError) {
+ @dbm.fetch('bar')
+ }
+
+ # test for `ifnone' arg
+ assert_equals('baz', @dbm.fetch('bar', 'baz'))
+
+ # test for `ifnone' block
+ assert_equals('foobar', @dbm.fetch('bar') {|key| 'foo' + key })
+ end
+
+ def test_aset
+ num = 0
+ 2.times {|i|
+ assert_equals('foo', @dbm['foo'] = 'foo')
+ assert_equals('foo', @dbm['foo'])
+ assert_equals('bar', @dbm['foo'] = 'bar')
+ assert_equals('bar', @dbm['foo'])
+
+ num += 1 if i == 0
+ assert_equals(num, @dbm.size)
+
+ # assign nil
+ assert_equals('', @dbm['bar'] = '')
+ assert_equals('', @dbm['bar'])
+
+ num += 1 if i == 0
+ assert_equals(num, @dbm.size)
+
+ # empty string
+ assert_equals('', @dbm[''] = '')
+ assert_equals('', @dbm[''])
+
+ num += 1 if i == 0
+ assert_equals(num, @dbm.size)
+
+ # Fixnum
+ assert_equals('200', @dbm['100'] = '200')
+ assert_equals('200', @dbm['100'])
+
+ num += 1 if i == 0
+ assert_equals(num, @dbm.size)
+
+ # Big key and value
+ assert_equals('y' * 100, @dbm['x' * 100] = 'y' * 100)
+ assert_equals('y' * 100, @dbm['x' * 100])
+
+ num += 1 if i == 0
+ assert_equals(num, @dbm.size)
+ }
+ end
+
+ def test_index
+ assert_equals('bar', @dbm['foo'] = 'bar')
+ assert_equals('foo', @dbm.index('bar'))
+ assert_nil(@dbm['bar'])
+ end
+
+ def test_indexes
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+ assert_equals(values.reverse, @dbm.indexes(*keys.reverse))
+ end
+
+ def test_values_at
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+ assert_equals(values.reverse, @dbm.values_at(*keys.reverse))
+ end
+
+ def test_select_with_block
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+ ret = @dbm.select {|k,v|
+ assert_equals(k.upcase, v)
+ k != "bar"
+ }
+ assert_equals([['baz', 'BAZ'], ['foo', 'FOO']],
+ ret.sort)
+ end
+
+ def test_length
+ num = 10
+ assert_equals(0, @dbm.size)
+ num.times {|i|
+ i = i.to_s
+ @dbm[i] = i
+ }
+ assert_equals(num, @dbm.size)
+
+ @dbm.shift
+
+ assert_equals(num - 1, @dbm.size)
+ end
+
+ def test_empty?
+ assert_equals(true, @dbm.empty?)
+ @dbm['foo'] = 'FOO'
+ assert_equals(false, @dbm.empty?)
+ end
+
+ def test_each_pair
+ n = 0
+ @dbm.each_pair { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+
+ n = 0
+ ret = @dbm.each_pair {|key, val|
+ assert_not_nil(i = keys.index(key))
+ assert_equals(val, values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@dbm, ret)
+ end
+
+ def test_each_value
+ n = 0
+ @dbm.each_value { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+
+ n = 0
+ ret = @dbm.each_value {|val|
+ assert_not_nil(key = @dbm.index(val))
+ assert_not_nil(i = keys.index(key))
+ assert_equals(val, values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@dbm, ret)
+ end
+
+ def test_each_key
+ n = 0
+ @dbm.each_key { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+
+ n = 0
+ ret = @dbm.each_key {|key|
+ assert_not_nil(i = keys.index(key))
+ assert_equals(@dbm[key], values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@dbm, ret)
+ end
+
+ def test_keys
+ assert_equals([], @dbm.keys)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+
+ assert_equals(keys.sort, @dbm.keys.sort)
+ assert_equals(values.sort, @dbm.values.sort)
+ end
+
+ def test_values
+ test_keys
+ end
+
+ def test_shift
+ assert_nil(@dbm.shift)
+ assert_equals(0, @dbm.size)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+
+ ret_keys = []
+ ret_values = []
+ while ret = @dbm.shift
+ ret_keys.push ret[0]
+ ret_values.push ret[1]
+
+ assert_equals(keys.size - ret_keys.size, @dbm.size)
+ end
+
+ assert_equals(keys.sort, ret_keys.sort)
+ assert_equals(values.sort, ret_values.sort)
+ end
+
+ def test_delete
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ key = keys[1]
+
+ assert_nil(@dbm.delete(key))
+ assert_equals(0, @dbm.size)
+
+ @dbm[keys[0]], @dbm[keys[1]], @dbm[keys[2]] = values
+
+ assert_equals('BAR', @dbm.delete(key))
+ assert_nil(@dbm[key])
+ assert_equals(2, @dbm.size)
+
+ assert_nil(@dbm.delete(key))
+
+ if /^CYGWIN_9/ !~ SYSTEM
+ assert_exception(DBMError) {
+ @dbm_rdonly.delete("foo")
+ }
+
+ assert_nil(@dbm_rdonly.delete("bar"))
+ end
+ end
+ def test_delete_with_block
+ key = 'no called block'
+ @dbm[key] = 'foo'
+ assert_equals('foo', @dbm.delete(key) {|k| k.replace 'called block'})
+ assert_equals('no called block', key)
+ assert_equals(0, @dbm.size)
+
+ key = 'no called block'
+ assert_equals(:blockval,
+ @dbm.delete(key) {|k| k.replace 'called block'; :blockval})
+ assert_equals('called block', key)
+ assert_equals(0, @dbm.size)
+ end
+
+ def test_delete_if
+ v = "0"
+ 100.times {@dbm[v] = v; v = v.next}
+
+ ret = @dbm.delete_if {|key, val| key.to_i < 50}
+ assert_equals(@dbm, ret)
+ check_size(50, @dbm)
+
+ ret = @dbm.delete_if {|key, val| key.to_i >= 50}
+ assert_equals(@dbm, ret)
+ check_size(0, @dbm)
+
+ # break
+ v = "0"
+ 100.times {@dbm[v] = v; v = v.next}
+ check_size(100, @dbm)
+ n = 0;
+ @dbm.delete_if {|key, val|
+ break if n > 50
+ n+=1
+ true
+ }
+ assert_equals(51, n)
+ check_size(49, @dbm)
+
+ @dbm.clear
+
+ # raise
+ v = "0"
+ 100.times {@dbm[v] = v; v = v.next}
+ check_size(100, @dbm)
+ n = 0;
+ begin
+ @dbm.delete_if {|key, val|
+ raise "runtime error" if n > 50
+ n+=1
+ true
+ }
+ rescue
+ end
+ assert_equals(51, n)
+ check_size(49, @dbm)
+ end
+
+ def test_reject
+ v = "0"
+ 100.times {@dbm[v] = v; v = v.next}
+
+ hash = @dbm.reject {|key, val| key.to_i < 50}
+ assert_instance_of(Hash, hash)
+ assert_equals(100, @dbm.size)
+
+ assert_equals(50, hash.size)
+ hash.each_pair {|key,val|
+ assert_equals(false, key.to_i < 50)
+ assert_equals(key, val)
+ }
+
+ hash = @dbm.reject {|key, val| key.to_i < 100}
+ assert_instance_of(Hash, hash)
+ assert_equals(true, hash.empty?)
+ end
+
+ def test_clear
+ v = "1"
+ 100.times {v = v.next; @dbm[v] = v}
+
+ assert_equals(@dbm, @dbm.clear)
+
+ # validate DBM#size
+ i = 0
+ @dbm.each { i += 1 }
+ assert_equals(@dbm.size, i)
+ assert_equals(0, i)
+ end
+
+ def test_invert
+ v = "0"
+ 100.times {@dbm[v] = v; v = v.next}
+
+ hash = @dbm.invert
+ assert_instance_of(Hash, hash)
+ assert_equals(100, hash.size)
+ hash.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_update
+ hash = {}
+ v = "0"
+ 100.times {v = v.next; hash[v] = v}
+
+ @dbm["101"] = "101"
+ @dbm.update hash
+ assert_equals(101, @dbm.size)
+ @dbm.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_replace
+ hash = {}
+ v = "0"
+ 100.times {v = v.next; hash[v] = v}
+
+ @dbm["101"] = "101"
+ @dbm.replace hash
+ assert_equals(100, @dbm.size)
+ @dbm.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_haskey?
+ assert_equals('bar', @dbm['foo']='bar')
+ assert_equals(true, @dbm.has_key?('foo'))
+ assert_equals(false, @dbm.has_key?('bar'))
+ end
+
+ def test_has_value?
+ assert_equals('bar', @dbm['foo']='bar')
+ assert_equals(true, @dbm.has_value?('bar'))
+ assert_equals(false, @dbm.has_value?('foo'))
+ end
+
+ def test_to_a
+ v = "0"
+ 100.times {v = v.next; @dbm[v] = v}
+
+ ary = @dbm.to_a
+ assert_instance_of(Array, ary)
+ assert_equals(100, ary.size)
+ ary.each {|key,val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_to_hash
+ v = "0"
+ 100.times {v = v.next; @dbm[v] = v}
+
+ hash = @dbm.to_hash
+ assert_instance_of(Hash, hash)
+ assert_equals(100, hash.size)
+ hash.each {|key,val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+end
+
+if $0 == __FILE__
+ if ARGV.size == 0
+ suite = RUNIT::TestSuite.new
+ suite.add_test(TestDBM.suite)
+ else
+ suite = RUNIT::TestSuite.new
+ ARGV.each do |testmethod|
+ suite.add_test(TestDBM.new(testmethod))
+ end
+ end
+
+ RUNIT::CUI::TestRunner.run(suite)
+end
diff --git a/ext/digest/.cvsignore b/ext/digest/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/digest/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/digest/defs.h b/ext/digest/defs.h
new file mode 100644
index 0000000000..5cfc77dd24
--- /dev/null
+++ b/ext/digest/defs.h
@@ -0,0 +1,37 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#ifndef DEFS_H
+#define DEFS_H
+
+#include "ruby.h"
+#include <sys/types.h>
+
+#if defined(HAVE_SYS_CDEFS_H)
+# include <sys/cdefs.h>
+#endif
+#if !defined(__BEGIN_DECLS)
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+
+#if defined(HAVE_INTTYPES_H)
+# include <inttypes.h>
+#elif !defined __CYGWIN__ || !defined __uint8_t_defined
+ typedef unsigned char uint8_t;
+ typedef unsigned int uint32_t;
+# if SIZEOF_LONG == 8
+ typedef unsigned long uint64_t;
+# elif defined(__GNUC__)
+ typedef unsigned long long uint64_t;
+# elif defined(_MSC_VER)
+ typedef unsigned _int64 uint64_t;
+# elif defined(__BORLANDC__)
+ typedef unsigned __int64 uint64_t;
+# else
+# define NO_UINT64_T
+# endif
+#endif
+
+#endif /* DEFS_H */
diff --git a/ext/digest/depend b/ext/digest/depend
new file mode 100644
index 0000000000..43601a208f
--- /dev/null
+++ b/ext/digest/depend
@@ -0,0 +1,2 @@
+digest.o: digest.c digest.h $(hdrdir)/ruby.h $(topdir)/config.h \
+ $(hdrdir)/defines.h $(hdrdir)/intern.h
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
new file mode 100644
index 0000000000..70f986327a
--- /dev/null
+++ b/ext/digest/digest.c
@@ -0,0 +1,316 @@
+/************************************************
+
+ digest.c -
+
+ $Author$
+ created at: Fri May 25 08:57:27 JST 2001
+
+ Copyright (C) 1995-2001 Yukihiro Matsumoto
+ Copyright (C) 2001 Akinori MUSHA
+
+ $RoughId: digest.c,v 1.16 2001/07/13 15:38:27 knu Exp $
+ $Id$
+
+************************************************/
+
+/*
+ * This module provides an interface to the following hash algorithms:
+ *
+ * - the MD5 Message-Digest Algorithm by the RSA Data Security,
+ * Inc., described in RFC 1321
+ *
+ * - the SHA-1 Secure Hash Algorithm by NIST (the US' National
+ * Institute of Standards and Technology), described in FIPS PUB
+ * 180-1.
+ *
+ * - the SHA-256/384/512 Secure Hash Algorithm by NIST (the US'
+ * National Institute of Standards and Technology), described in
+ * FIPS PUB 180-2.
+ *
+ * - the RIPEMD-160 cryptographic hash function, designed by Hans
+ * Dobbertin, Antoon Bosselaers, and Bart Preneel.
+ */
+
+#include "digest.h"
+
+static VALUE mDigest, cDigest_Base;
+static ID id_metadata;
+
+/*
+ * Digest::Base
+ */
+
+static algo_t *
+get_digest_base_metadata(klass)
+ VALUE klass;
+{
+ VALUE obj;
+ algo_t *algo;
+
+ if (rb_cvar_defined(klass, id_metadata) == Qfalse) {
+ rb_notimplement();
+ }
+
+ obj = rb_cvar_get(klass, id_metadata);
+
+ Data_Get_Struct(obj, algo_t, algo);
+
+ return algo;
+}
+
+static VALUE rb_digest_base_alloc _((VALUE));
+static VALUE
+rb_digest_base_alloc(klass)
+ VALUE klass;
+{
+ algo_t *algo;
+ VALUE obj;
+ void *pctx;
+
+ if (klass == cDigest_Base) {
+ rb_raise(rb_eNotImpError, "Digest::Base is an abstract class");
+ }
+
+ algo = get_digest_base_metadata(klass);
+
+ /* XXX: An uninitialized buffer leads ALGO_Equal() to fail */
+ pctx = xcalloc(algo->ctx_size, 1);
+ algo->init_func(pctx);
+
+ obj = Data_Wrap_Struct(klass, 0, free, pctx);
+
+ return obj;
+}
+
+static VALUE
+rb_digest_base_s_digest(klass, str)
+ VALUE klass;
+ VALUE str;
+{
+ algo_t *algo;
+ void *pctx;
+ size_t len;
+ unsigned char *digest;
+ VALUE obj = rb_digest_base_alloc(klass);
+
+ algo = get_digest_base_metadata(klass);
+ Data_Get_Struct(obj, void, pctx);
+
+ StringValue(str);
+ algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
+
+ len = algo->digest_len;
+
+ digest = xmalloc(len);
+ algo->final_func(digest, pctx);
+
+ obj = rb_str_new(digest, len);
+
+ free(digest);
+
+ return obj;
+}
+
+static VALUE
+rb_digest_base_s_hexdigest(klass, str)
+ VALUE klass;
+ VALUE str;
+{
+ algo_t *algo;
+ void *pctx;
+ size_t len;
+ unsigned char *hexdigest;
+ VALUE obj = rb_digest_base_alloc(klass);
+
+ algo = get_digest_base_metadata(klass);
+ Data_Get_Struct(obj, void, pctx);
+
+ StringValue(str);
+ algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
+
+ len = algo->digest_len * 2;
+
+ hexdigest = xmalloc(len + 1); /* +1 is for '\0' */
+ algo->end_func(pctx, hexdigest);
+
+ obj = rb_str_new(hexdigest, len);
+
+ free(hexdigest);
+
+ return obj;
+}
+
+static VALUE
+rb_digest_base_copy(copy, obj)
+ VALUE copy, obj;
+{
+ algo_t *algo;
+ void *pctx1, *pctx2;
+
+ if (copy == obj) return copy;
+ rb_check_frozen(copy);
+ algo = get_digest_base_metadata(rb_obj_class(copy));
+ if (algo != get_digest_base_metadata(rb_obj_class(obj))) {
+ rb_raise(rb_eTypeError, "wrong argument class");
+ }
+ Data_Get_Struct(obj, void, pctx1);
+ Data_Get_Struct(copy, void, pctx2);
+ memcpy(pctx2, pctx1, algo->ctx_size);
+
+ return copy;
+}
+
+static VALUE
+rb_digest_base_update(self, str)
+ VALUE self, str;
+{
+ algo_t *algo;
+ void *pctx;
+
+ StringValue(str);
+ algo = get_digest_base_metadata(rb_obj_class(self));
+ Data_Get_Struct(self, void, pctx);
+
+ algo->update_func(pctx, RSTRING(str)->ptr, RSTRING(str)->len);
+
+ return self;
+}
+
+static VALUE
+rb_digest_base_init(argc, argv, self)
+ int argc;
+ VALUE* argv;
+ VALUE self;
+{
+ VALUE arg;
+
+ rb_scan_args(argc, argv, "01", &arg);
+
+ if (!NIL_P(arg)) rb_digest_base_update(self, arg);
+
+ return self;
+}
+
+static VALUE
+rb_digest_base_digest(self)
+ VALUE self;
+{
+ algo_t *algo;
+ void *pctx1, *pctx2;
+ unsigned char *digest;
+ size_t len;
+ VALUE str;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
+ Data_Get_Struct(self, void, pctx1);
+
+ len = algo->ctx_size;
+
+ pctx2 = xmalloc(len);
+ memcpy(pctx2, pctx1, len);
+
+ len = algo->digest_len;
+
+ digest = xmalloc(len);
+ algo->final_func(digest, pctx2);
+
+ str = rb_str_new(digest, len);
+
+ free(digest);
+ free(pctx2);
+
+ return str;
+}
+
+static VALUE
+rb_digest_base_hexdigest(self)
+ VALUE self;
+{
+ algo_t *algo;
+ void *pctx1, *pctx2;
+ unsigned char *hexdigest;
+ size_t len;
+ VALUE str;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
+ Data_Get_Struct(self, void, pctx1);
+
+ len = algo->ctx_size;
+
+ pctx2 = xmalloc(len);
+ memcpy(pctx2, pctx1, len);
+
+ len = algo->digest_len * 2;
+
+ hexdigest = xmalloc(len + 1); /* +1 is for '\0' */
+ algo->end_func(pctx2, hexdigest);
+
+ str = rb_str_new(hexdigest, len);
+
+ free(hexdigest);
+ free(pctx2);
+
+ return str;
+}
+
+static VALUE
+rb_digest_base_equal(self, other)
+ VALUE self, other;
+{
+ algo_t *algo;
+ VALUE klass;
+ VALUE str1, str2;
+
+ klass = rb_obj_class(self);
+ algo = get_digest_base_metadata(klass);
+
+ if (rb_obj_class(other) == klass) {
+ void *pctx1, *pctx2;
+
+ Data_Get_Struct(self, void, pctx1);
+ Data_Get_Struct(other, void, pctx2);
+
+ return algo->equal_func(pctx1, pctx2) ? Qtrue : Qfalse;
+ }
+
+ StringValue(other);
+ str2 = other;
+
+ if (RSTRING(str2)->len == algo->digest_len)
+ str1 = rb_digest_base_digest(self);
+ else
+ str1 = rb_digest_base_hexdigest(self);
+
+ if (RSTRING(str1)->len == RSTRING(str2)->len
+ && rb_str_cmp(str1, str2) == 0)
+ return Qtrue;
+
+ return Qfalse;
+}
+
+/*
+ * Init
+ */
+
+void
+Init_digest()
+{
+ mDigest = rb_define_module("Digest");
+
+ cDigest_Base = rb_define_class_under(mDigest, "Base", rb_cObject);
+
+ rb_define_alloc_func(cDigest_Base, rb_digest_base_alloc);
+ rb_define_singleton_method(cDigest_Base, "digest", rb_digest_base_s_digest, 1);
+ rb_define_singleton_method(cDigest_Base, "hexdigest", rb_digest_base_s_hexdigest, 1);
+
+ rb_define_method(cDigest_Base, "initialize", rb_digest_base_init, -1);
+ rb_define_method(cDigest_Base, "initialize_copy", rb_digest_base_copy, 1);
+ rb_define_method(cDigest_Base, "update", rb_digest_base_update, 1);
+ rb_define_method(cDigest_Base, "<<", rb_digest_base_update, 1);
+ rb_define_method(cDigest_Base, "digest", rb_digest_base_digest, 0);
+ rb_define_method(cDigest_Base, "hexdigest", rb_digest_base_hexdigest, 0);
+ rb_define_method(cDigest_Base, "to_s", rb_digest_base_hexdigest, 0);
+ rb_define_method(cDigest_Base, "==", rb_digest_base_equal, 1);
+
+ id_metadata = rb_intern("metadata");
+}
diff --git a/ext/digest/digest.h b/ext/digest/digest.h
new file mode 100644
index 0000000000..5e846df040
--- /dev/null
+++ b/ext/digest/digest.h
@@ -0,0 +1,32 @@
+/************************************************
+
+ digest.c -
+
+ $Author$
+ created at: Fri May 25 08:54:56 JST 2001
+
+
+ Copyright (C) 2001 Akinori MUSHA
+
+ $RoughId: digest.h,v 1.3 2001/07/13 15:38:27 knu Exp $
+ $Id$
+
+************************************************/
+
+#include "ruby.h"
+
+typedef void (*hash_init_func_t) _((void *));
+typedef void (*hash_update_func_t) _((void *, unsigned char *, size_t));
+typedef void (*hash_end_func_t) _((void *, unsigned char *));
+typedef void (*hash_final_func_t) _((unsigned char *, void *));
+typedef int (*hash_equal_func_t) _((void *, void *));
+
+typedef struct {
+ size_t digest_len;
+ size_t ctx_size;
+ hash_init_func_t init_func;
+ hash_update_func_t update_func;
+ hash_end_func_t end_func;
+ hash_final_func_t final_func;
+ hash_equal_func_t equal_func;
+} algo_t;
diff --git a/ext/digest/digest.txt b/ext/digest/digest.txt
new file mode 100644
index 0000000000..5797dd18f9
--- /dev/null
+++ b/ext/digest/digest.txt
@@ -0,0 +1,113 @@
+.\" digest.txt - -*- Indented-Text -*- created at: Fri May 25 08:13:50 JST 2001
+$RoughId: digest.txt,v 1.9 2001/07/13 19:46:51 knu Exp $
+$Id$
+
+** MD5(Class)
+
+A class to implement the MD5 Message-Digest Algorithm by RSA Data
+Security, Inc., described in RFC1321.
+
+Superclass: Digest::Base
+
+require 'digest/md5'
+
+** SHA1(Class)
+
+A class to implement the SHA-1 Secure Hash Algorithm by NIST (the US'
+National Institute of Standards and Technology), described in FIPS PUB
+180-1.
+
+Superclass: Digest::Base
+
+require 'digest/sha1'
+
+** SHA256(Class)
+** SHA384(Class)
+** SHA512(Class)
+
+Classes to implement the SHA-256/384/512 Secure Hash Algorithm(s) by
+NIST (the US' National Institute of Standards and Technology),
+described in FIPS PUB 180-2.
+
+Superclass: Digest::Base
+
+require 'digest/sha2'
+
+** RMD160(Class)
+
+A class to implement the RIPEMD-160 cryptographic hash function,
+designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel.
+
+Superclass: Digest::Base
+
+require 'digest/rmd160'
+
+
+Those above classes provide a common interface as shown below.
+
+
+Class Methods:
+
+ new([str])
+
+ Creates a new digest object. If a string argument is given,
+ it is added to the object. (see update.)
+
+ digest(str)
+
+ Immediately calculates and return the hash of the given
+ strings as a string. Equivalent to new(str).digest.
+
+ hexdigest(str)
+
+ Immediately calculates and return the hash of the given
+ strings as a string of hexadecimal digits. Equivalent to
+ new(str).hexdigest.
+
+Methods:
+
+ clone
+
+ Creates a copy of the digest object.
+
+ digest
+
+ Returns the hash of the added strings as a string of 16 bytes
+ for MD5, 20 bytes for SHA1 and RMD160, 32 bytes for SHA256, 48
+ bytes for SHA384, and 64 bytes for SHA512.
+
+ hexdigest
+ to_s
+
+ Returns the hash of the added strings as a string of 32
+ hexadecimal digits for MD5, 40 hexadecimal digits for SHA1 and
+ RMD160, 64 hexadecimal digits for SHA256, 96 hexadecimal
+ digits for SHA384, and 128 hexadecimal digits for SHA512.
+ This method is equal to:
+
+ def hexdigest
+ digest.unpack("H*")[0]
+ end
+
+ update(str)
+ << str
+
+ Appends the string str to the digest object. Repeated calls
+ are equivalent to a single call with the concatenation of all
+ the arguments, i.e. m.update(a); m.update(b) is equivalent to
+ m.update(a + b) and m << a << b is equivalent to m << a + b.
+
+ == md
+
+ Checks if the object is equal to the given digest object.
+
+ == str
+
+ Regards the value as either a digest value or a hexdigest
+ value (depending on the length) and checks if the object is
+ equal to the given string.
+
+-------------------------------------------------------
+Local variables:
+fill-column: 70
+end:
diff --git a/ext/digest/digest.txt.ja b/ext/digest/digest.txt.ja
new file mode 100644
index 0000000000..8997d25b9d
--- /dev/null
+++ b/ext/digest/digest.txt.ja
@@ -0,0 +1,111 @@
+.\" digest.txt.ja - -*- Indented-Text -*- created at: Fri May 25 08:22:19 JST 2001
+$RoughId: digest.txt.jp,v 1.8 2001/07/13 15:38:27 knu Exp $
+$Id$
+
+** MD5(¥¯¥é¥¹)
+
+RFC1321¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ëRSA Data Security, Inc. ¤Î MD5 Message-Digest
+Algorithm¤ò¼ÂÁõ¤¹¤ë¥¯¥é¥¹¡£
+
+Superclass: Digest::Base
+
+require 'digest/md5'
+
+** SHA1(¥¯¥é¥¹)
+
+FIPS PUB 180-1¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ëNIST (the US' National Institute of
+Standards and Technology) ¤Î SHA-1 Secure Hash Algorithm¤ò¼ÂÁõ¤¹¤ë¥¯¥é¥¹¡£
+
+Superclass: Digest::Base
+
+require 'digest/sha1'
+
+** SHA256(¥¯¥é¥¹)
+** SHA384(¥¯¥é¥¹)
+** SHA512(¥¯¥é¥¹)
+
+FIPS PUB 180-2¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ëNIST (the US' National Institute of
+Standards and Technology) ¤Î SHA-256/384/512 Secure Hash Algorithm¤ò
+¼ÂÁõ¤¹¤ë¥¯¥é¥¹¡£
+
+Superclass: Digest::Base
+
+require 'digest/sha2'
+
+** RMD160(¥¯¥é¥¹)
+
+Hans Dobbertin, Antoon Bosselaers, Bart Preneel ¤Ë¤è¤Ã¤ÆÀ߷פµ¤ì¤¿
+RIPEMD-160 ¥Ï¥Ã¥·¥å´Ø¿ô¤ò¼ÂÁõ¤¹¤ë¥¯¥é¥¹¡£
+
+Superclass: Digest::Base
+
+require 'digest/rmd160'
+
+
+¤³¤ì¤é¤Î¥¯¥é¥¹¤Ï°Ê²¼¤Î¤è¤¦¤Ê¶¦Ä̤Υ¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤òÄ󶡤¹¤ë¡£
+
+
+Class Methods:
+
+ new([str])
+
+ ¿·¤·¤¤¥À¥¤¥¸¥§¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë¡¥Ê¸»úÎó°ú¿ô¤¬Í¿¤¨¤é¤ì¤ë
+ ¤È¤½¤ì¤òÄɲ乤ë(see update)¡£
+
+ digest(str)
+
+ Í¿¤¨¤é¤ì¤¿Ê¸»úÎó¤ËÂФ¹¤ë¥Ï¥Ã¥·¥åÃͤòʸ»úÎó¤ÇÊÖ¤¹¡£
+ new(str).digest ¤ÈÅù²Á¡£
+
+ hexdigest(str)
+
+ Í¿¤¨¤é¤ì¤¿Ê¸»úÎó¤ËÂФ¹¤ë¥Ï¥Ã¥·¥åÃͤò¡¢ASCII¥³¡¼¥É¤ò»È¤Ã¤Æ
+ 16¿Ê¿ô¤ÎÎó¤ò¼¨¤¹Ê¸»úÎó¤Ë¥¨¥ó¥³¡¼¥É¤·¤ÆÊÖ¤¹¡£
+ new(str).hexdigest ¤ÈÅù²Á¡£
+
+Methods:
+
+ clone
+
+ ¥À¥¤¥¸¥§¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤ÎÊ£À½¤òºî¤ë¡£
+
+ digest
+
+ º£¤Þ¤Ç¤ËÄɲä·¤¿Ê¸»úÎó¤ËÂФ¹¤ë¥Ï¥Ã¥·¥åÃͤòʸ»úÎó¤ÇÊÖ¤¹¡£MD5¤Ç¤Ï
+ 16¥Ð¥¤¥ÈĹ¡¢SHA1¤ª¤è¤ÓRMD160¤Ç¤Ï20¥Ð¥¤¥ÈĹ¡¢SHA256¤Ç¤Ï32¥Ð¥¤¥ÈĹ¡¢
+ SHA384¤Ç¤Ï48¥Ð¥¤¥ÈĹ¡¢SHA512¤Ç¤Ï64¥Ð¥¤¥ÈĹ¤È¤Ê¤ë¡£
+
+ hexdigest
+ to_s
+
+ º£¤Þ¤Ç¤ËÄɲä·¤¿Ê¸»úÎó¤ËÂФ¹¤ë¥Ï¥Ã¥·¥åÃͤò¡¢ASCII¥³¡¼¥É¤ò»È¤Ã¤Æ
+ 16¿Ê¿ô¤ÎÎó¤ò¼¨¤¹Ê¸»úÎó¤Ë¥¨¥ó¥³¡¼¥É¤·¤ÆÊÖ¤¹¡£MD5¤Ç¤Ï32¥Ð¥¤¥ÈĹ¡¢
+ SHA1¤ª¤è¤ÓRMD160¤Ç¤Ï40¥Ð¥¤¥ÈĹ¡¢SHA256¤Ç¤Ï64¥Ð¥¤¥ÈĹ¡¢SHA384¤Ç¤Ï
+ 96¥Ð¥¤¥ÈĹ¡¢SHA512¤Ç¤Ï128¥Ð¥¤¥ÈĹ¤È¤Ê¤ë¡£Ruby¤Ç½ñ¤¯¤È°Ê²¼¤ÈƱ¤¸¡£
+
+ def hexdigest
+ digest.unpack("H*")[0]
+ end
+
+ update(str)
+ << str
+
+ ʸ»úÎó¤òÄɲ乤롣ʣ¿ô²óupdate¤ò¸Æ¤Ö¤³¤È¤Ïʸ»úÎó¤òÏ¢·ë¤·¤Æ
+ update¤ò¸Æ¤Ö¤³¤È¤ÈÅù¤·¤¤¡£¤¹¤Ê¤ï¤Á m.update(a); m.update(b) ¤Ï
+ m.update(a + b) ¤È¡¢ m << a << b ¤Ï m << a + b ¤È¤½¤ì¤¾¤ìÅù²Á
+ ¤Ç¤¢¤ë¡£
+
+ == md
+
+ Í¿¤¨¤é¤ì¤¿¥À¥¤¥¸¥§¥¹¥È¥ª¥Ö¥¸¥§¥¯¥È¤ÈÈæ³Ó¤¹¤ë¡£
+
+ == str
+
+ Í¿¤¨¤é¤ì¤¿Ê¸»úÎó¤ò digest ÃÍ¡¢¤â¤·¤¯¤Ï hexdigest ÃͤÈÈæ³Ó¤¹¤ë¡£
+ ¤¤¤º¤ì¤ÎÃͤȸ«¤ë¤«¤ÏÍ¿¤¨¤é¤ì¤¿Ê¸»úÎó¤ÎŤµ¤Ë¤è¤Ã¤Æ¼«Æ°È½ÊÌ
+ ¤µ¤ì¤ë¡£
+
+-------------------------------------------------------
+Local variables:
+fill-column: 70
+end:
diff --git a/ext/digest/extconf.rb b/ext/digest/extconf.rb
new file mode 100644
index 0000000000..cd512622a4
--- /dev/null
+++ b/ext/digest/extconf.rb
@@ -0,0 +1,6 @@
+# $RoughId: extconf.rb,v 1.6 2001/07/13 15:38:27 knu Exp $
+# $Id$
+
+require "mkmf"
+
+create_makefile("digest")
diff --git a/ext/digest/lib/md5.rb b/ext/digest/lib/md5.rb
new file mode 100644
index 0000000000..1d05d7d04e
--- /dev/null
+++ b/ext/digest/lib/md5.rb
@@ -0,0 +1,14 @@
+# just for compatibility; requiring "md5" is obsoleted
+#
+# $RoughId: md5.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
+# $Id$
+
+require 'digest/md5'
+
+MD5 = Digest::MD5
+
+class MD5
+ def self.md5(*args)
+ new(*args)
+ end
+end
diff --git a/ext/digest/lib/sha1.rb b/ext/digest/lib/sha1.rb
new file mode 100644
index 0000000000..c4ac6f66ea
--- /dev/null
+++ b/ext/digest/lib/sha1.rb
@@ -0,0 +1,14 @@
+# just for compatibility; requiring "sha1" is obsoleted
+#
+# $RoughId: sha1.rb,v 1.4 2001/07/13 15:38:27 knu Exp $
+# $Id$
+
+require 'digest/sha1'
+
+SHA1 = Digest::SHA1
+
+class SHA1
+ def self.sha1(*args)
+ new(*args)
+ end
+end
diff --git a/ext/digest/md5/.cvsignore b/ext/digest/md5/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/digest/md5/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/digest/md5/depend b/ext/digest/md5/depend
new file mode 100644
index 0000000000..8eaec20b4b
--- /dev/null
+++ b/ext/digest/md5/depend
@@ -0,0 +1,6 @@
+md5.o: md5.c md5.h $(srcdir)/../defs.h $(hdrdir)/ruby.h $(topdir)/config.h \
+ $(hdrdir)/defines.h $(hdrdir)/intern.h
+md5init.o: md5init.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h md5.h \
+ $(srcdir)/../defs.h
+md5ossl.o: md5ossl.h
diff --git a/ext/digest/md5/extconf.rb b/ext/digest/md5/extconf.rb
new file mode 100644
index 0000000000..9acf7ba9c0
--- /dev/null
+++ b/ext/digest/md5/extconf.rb
@@ -0,0 +1,26 @@
+# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
+# $Id$
+
+require "mkmf"
+
+$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+
+$objs = [ "md5init.#{$OBJEXT}" ]
+
+dir_config("openssl")
+
+if !with_config("bundled-md5") &&
+ have_library("crypto") && have_header("openssl/md5.h")
+ $objs << "md5ossl.#{$OBJEXT}"
+
+else
+ $objs << "md5.#{$OBJEXT}"
+end
+
+have_header("sys/cdefs.h")
+
+have_header("inttypes.h")
+
+have_header("unistd.h")
+
+create_makefile("digest/md5")
diff --git a/ext/digest/md5/md5.c b/ext/digest/md5/md5.c
new file mode 100644
index 0000000000..6b61f031c4
--- /dev/null
+++ b/ext/digest/md5/md5.c
@@ -0,0 +1,432 @@
+/*
+ Copyright (C) 1999, 2000 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321.
+ It is derived directly from the text of the RFC and not from the
+ reference implementation.
+
+ The original and principal author of md5.c is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2000-07-03 lpd Patched to eliminate warnings about "constant is
+ unsigned in ANSI C, signed in traditional";
+ made test program self-checking.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
+ 1999-05-03 lpd Original version.
+ */
+
+/*$OrigId: md5c.c,v 1.2 2001/03/26 08:57:14 matz Exp $ */
+/*$RoughId: md5.c,v 1.2 2001/07/13 19:48:41 knu Exp $ */
+/*$Id$ */
+
+#include "md5.h"
+
+#ifdef TEST
+/*
+ * Compile with -DTEST to create a self-contained executable test program.
+ * The test program should print out the same values as given in section
+ * A.5 of RFC 1321, reproduced below.
+ */
+#include <string.h>
+main()
+{
+ static const char *const test[7*2] = {
+ "", "d41d8cd98f00b204e9800998ecf8427e",
+ "a", "0cc175b9c0f1b6a831c399e269772661",
+ "abc", "900150983cd24fb0d6963f7d28e17f72",
+ "message digest", "f96b697d7cb7938d525a2f31aaf161d0",
+ "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ "d174ab98d277d9f5a5611c2c9f419d9f",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a"
+ };
+ int i;
+
+ for (i = 0; i < 7*2; i += 2) {
+ MD5_CTX state;
+ uint8_t digest[16];
+ char hex_output[16*2 + 1];
+ int di;
+
+ MD5_Init(&state);
+ MD5_Update(&state, (const uint8_t *)test[i], strlen(test[i]));
+ MD5_Final(digest, &state);
+ printf("MD5 (\"%s\") = ", test[i]);
+ for (di = 0; di < 16; ++di)
+ sprintf(hex_output + di * 2, "%02x", digest[di]);
+ puts(hex_output);
+ if (strcmp(hex_output, test[i + 1]))
+ printf("**** ERROR, should be: %s\n", test[i + 1]);
+ }
+ return 0;
+}
+#endif /* TEST */
+
+
+/*
+ * For reference, here is the program that computed the T values.
+ */
+#ifdef COMPUTE_T_VALUES
+#include <math.h>
+main()
+{
+ int i;
+ for (i = 1; i <= 64; ++i) {
+ unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i)));
+
+ /*
+ * The following nonsense is only to avoid compiler warnings about
+ * "integer constant is unsigned in ANSI C, signed with -traditional".
+ */
+ if (v >> 31) {
+ printf("#define T%d /* 0x%08lx */ (T_MASK ^ 0x%08lx)\n", i,
+ v, (unsigned long)(unsigned int)(~v));
+ } else {
+ printf("#define T%d 0x%08lx\n", i, v);
+ }
+ }
+ return 0;
+}
+#endif /* COMPUTE_T_VALUES */
+/*
+ * End of T computation program.
+ */
+#ifdef T_MASK
+#undef T_MASK
+#endif
+#define T_MASK ((uint32_t)~0)
+#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
+#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
+#define T3 0x242070db
+#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
+#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
+#define T6 0x4787c62a
+#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec)
+#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe)
+#define T9 0x698098d8
+#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850)
+#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e)
+#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841)
+#define T13 0x6b901122
+#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c)
+#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71)
+#define T16 0x49b40821
+#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d)
+#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf)
+#define T19 0x265e5a51
+#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855)
+#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2)
+#define T22 0x02441453
+#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e)
+#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437)
+#define T25 0x21e1cde6
+#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829)
+#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278)
+#define T28 0x455a14ed
+#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa)
+#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07)
+#define T31 0x676f02d9
+#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375)
+#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd)
+#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e)
+#define T35 0x6d9d6122
+#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3)
+#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb)
+#define T38 0x4bdecfa9
+#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f)
+#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f)
+#define T41 0x289b7ec6
+#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805)
+#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a)
+#define T44 0x04881d05
+#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6)
+#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a)
+#define T47 0x1fa27cf8
+#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a)
+#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb)
+#define T50 0x432aff97
+#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58)
+#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6)
+#define T53 0x655b59c3
+#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d)
+#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82)
+#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e)
+#define T57 0x6fa87e4f
+#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f)
+#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb)
+#define T60 0x4e0811a1
+#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d)
+#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
+#define T63 0x2ad7d2bb
+#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
+
+
+static void
+md5_process(MD5_CTX *pms, const uint8_t *data /*[64]*/)
+{
+ uint32_t
+ a = pms->state[0], b = pms->state[1],
+ c = pms->state[2], d = pms->state[3];
+ uint32_t t;
+
+#ifdef WORDS_BIGENDIAN
+
+ /*
+ * On big-endian machines, we must arrange the bytes in the right
+ * order. (This also works on machines of unknown byte order.)
+ */
+ uint32_t X[16];
+ const uint8_t *xp = data;
+ int i;
+
+ for (i = 0; i < 16; ++i, xp += 4)
+ X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+
+#else
+
+ /*
+ * On little-endian machines, we can process properly aligned data
+ * without copying it.
+ */
+ uint32_t xbuf[16];
+ const uint32_t *X;
+
+ if (!((data - (const uint8_t *)0) & 3)) {
+ /* data are properly aligned */
+ X = (const uint32_t *)data;
+ } else {
+ /* not aligned */
+ memcpy(xbuf, data, 64);
+ X = xbuf;
+ }
+#endif
+
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+
+ /* Round 1. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
+#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + F(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 7, T1);
+ SET(d, a, b, c, 1, 12, T2);
+ SET(c, d, a, b, 2, 17, T3);
+ SET(b, c, d, a, 3, 22, T4);
+ SET(a, b, c, d, 4, 7, T5);
+ SET(d, a, b, c, 5, 12, T6);
+ SET(c, d, a, b, 6, 17, T7);
+ SET(b, c, d, a, 7, 22, T8);
+ SET(a, b, c, d, 8, 7, T9);
+ SET(d, a, b, c, 9, 12, T10);
+ SET(c, d, a, b, 10, 17, T11);
+ SET(b, c, d, a, 11, 22, T12);
+ SET(a, b, c, d, 12, 7, T13);
+ SET(d, a, b, c, 13, 12, T14);
+ SET(c, d, a, b, 14, 17, T15);
+ SET(b, c, d, a, 15, 22, T16);
+#undef SET
+
+ /* Round 2. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + G(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 1, 5, T17);
+ SET(d, a, b, c, 6, 9, T18);
+ SET(c, d, a, b, 11, 14, T19);
+ SET(b, c, d, a, 0, 20, T20);
+ SET(a, b, c, d, 5, 5, T21);
+ SET(d, a, b, c, 10, 9, T22);
+ SET(c, d, a, b, 15, 14, T23);
+ SET(b, c, d, a, 4, 20, T24);
+ SET(a, b, c, d, 9, 5, T25);
+ SET(d, a, b, c, 14, 9, T26);
+ SET(c, d, a, b, 3, 14, T27);
+ SET(b, c, d, a, 8, 20, T28);
+ SET(a, b, c, d, 13, 5, T29);
+ SET(d, a, b, c, 2, 9, T30);
+ SET(c, d, a, b, 7, 14, T31);
+ SET(b, c, d, a, 12, 20, T32);
+#undef SET
+
+ /* Round 3. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + H(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 5, 4, T33);
+ SET(d, a, b, c, 8, 11, T34);
+ SET(c, d, a, b, 11, 16, T35);
+ SET(b, c, d, a, 14, 23, T36);
+ SET(a, b, c, d, 1, 4, T37);
+ SET(d, a, b, c, 4, 11, T38);
+ SET(c, d, a, b, 7, 16, T39);
+ SET(b, c, d, a, 10, 23, T40);
+ SET(a, b, c, d, 13, 4, T41);
+ SET(d, a, b, c, 0, 11, T42);
+ SET(c, d, a, b, 3, 16, T43);
+ SET(b, c, d, a, 6, 23, T44);
+ SET(a, b, c, d, 9, 4, T45);
+ SET(d, a, b, c, 12, 11, T46);
+ SET(c, d, a, b, 15, 16, T47);
+ SET(b, c, d, a, 2, 23, T48);
+#undef SET
+
+ /* Round 4. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+#define I(x, y, z) ((y) ^ ((x) | ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + I(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 6, T49);
+ SET(d, a, b, c, 7, 10, T50);
+ SET(c, d, a, b, 14, 15, T51);
+ SET(b, c, d, a, 5, 21, T52);
+ SET(a, b, c, d, 12, 6, T53);
+ SET(d, a, b, c, 3, 10, T54);
+ SET(c, d, a, b, 10, 15, T55);
+ SET(b, c, d, a, 1, 21, T56);
+ SET(a, b, c, d, 8, 6, T57);
+ SET(d, a, b, c, 15, 10, T58);
+ SET(c, d, a, b, 6, 15, T59);
+ SET(b, c, d, a, 13, 21, T60);
+ SET(a, b, c, d, 4, 6, T61);
+ SET(d, a, b, c, 11, 10, T62);
+ SET(c, d, a, b, 2, 15, T63);
+ SET(b, c, d, a, 9, 21, T64);
+#undef SET
+
+ /* Then perform the following additions. (That is increment each
+ of the four registers by the value it had before this block
+ was started.) */
+ pms->state[0] += a;
+ pms->state[1] += b;
+ pms->state[2] += c;
+ pms->state[3] += d;
+}
+
+void
+MD5_Init(MD5_CTX *pms)
+{
+ pms->count[0] = pms->count[1] = 0;
+ pms->state[0] = 0x67452301;
+ pms->state[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
+ pms->state[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
+ pms->state[3] = 0x10325476;
+}
+
+void
+MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
+{
+ const uint8_t *p = data;
+ size_t left = nbytes;
+ size_t offset = (pms->count[0] >> 3) & 63;
+ uint32_t nbits = (uint32_t)(nbytes << 3);
+
+ if (nbytes <= 0)
+ return;
+
+ /* Update the message length. */
+ pms->count[1] += nbytes >> 29;
+ pms->count[0] += nbits;
+ if (pms->count[0] < nbits)
+ pms->count[1]++;
+
+ /* Process an initial partial block. */
+ if (offset) {
+ size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+
+ memcpy(pms->buffer + offset, p, copy);
+ if (offset + copy < 64)
+ return;
+ p += copy;
+ left -= copy;
+ md5_process(pms, pms->buffer);
+ }
+
+ /* Process full blocks. */
+ for (; left >= 64; p += 64, left -= 64)
+ md5_process(pms, p);
+
+ /* Process a final partial block. */
+ if (left)
+ memcpy(pms->buffer, p, left);
+}
+
+void
+MD5_Final(uint8_t *digest, MD5_CTX *pms)
+{
+ static const uint8_t pad[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ uint8_t data[8];
+ size_t i;
+
+ /* Save the length before padding. */
+ for (i = 0; i < 8; ++i)
+ data[i] = (uint8_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ /* Pad to 56 bytes mod 64. */
+ MD5_Update(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+ /* Append the length. */
+ MD5_Update(pms, data, 8);
+ for (i = 0; i < 16; ++i)
+ digest[i] = (uint8_t)(pms->state[i >> 2] >> ((i & 3) << 3));
+}
+
+void
+MD5_End(MD5_CTX *pctx, uint8_t *hexdigest)
+{
+ unsigned char digest[16];
+ size_t i;
+
+ MD5_Final(digest, pctx);
+
+ for (i = 0; i < 16; i++)
+ sprintf(hexdigest + i * 2, "%02x", digest[i]);
+}
+
+int MD5_Equal(MD5_CTX* pctx1, MD5_CTX* pctx2) {
+ return memcmp(pctx1->count, pctx2->count, sizeof(pctx1->count)) == 0
+ && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
+ && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
+}
diff --git a/ext/digest/md5/md5.h b/ext/digest/md5/md5.h
new file mode 100644
index 0000000000..fc41380d38
--- /dev/null
+++ b/ext/digest/md5/md5.h
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321.
+ It is derived directly from the text of the RFC and not from the
+ reference implementation.
+
+ The original and principal author of md5.h is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+ added conditionalization for C++ compilation from Martin
+ Purschke <purschke@bnl.gov>.
+ 1999-05-03 lpd Original version.
+ */
+
+/* $OrigId: md5.h,v 1.2 2001/03/26 08:57:14 matz Exp $ */
+/* $RoughId: md5.h,v 1.3 2002/02/24 08:14:31 knu Exp $ */
+/* $Id$ */
+
+#ifndef MD5_INCLUDED
+# define MD5_INCLUDED
+
+#include "defs.h"
+
+/*
+ * This code has some adaptations for the Ghostscript environment, but it
+ * will compile and run correctly in any environment with 8-bit chars and
+ * 32-bit ints. Specifically, it assumes that if the following are
+ * defined, they have the same meaning as in Ghostscript: P1, P2, P3.
+ */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+ uint32_t count[2]; /* message length in bits, lsw first */
+ uint32_t state[4]; /* digest buffer */
+ uint8_t buffer[64]; /* accumulate block */
+} MD5_CTX;
+
+#ifdef RUBY
+#define MD5_Init rb_Digest_MD5_Init
+#define MD5_Update rb_Digest_MD5_Update
+#define MD5_Final rb_Digest_MD5_Final
+#define MD5_End rb_Digest_MD5_End
+#define MD5_Equal rb_Digest_MD5_Equal
+#endif
+
+void MD5_Init _((MD5_CTX *pms));
+void MD5_Update _((MD5_CTX *pms, const uint8_t *data, size_t nbytes));
+void MD5_Final _((uint8_t *digest, MD5_CTX *pms));
+void MD5_End _((MD5_CTX *pctx, uint8_t *hexdigest));
+int MD5_Equal _((MD5_CTX *pctx1, MD5_CTX *pctx2));
+
+#define MD5_BLOCK_LENGTH 64
+#define MD5_DIGEST_LENGTH 16
+#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
+
+#endif /* MD5_INCLUDED */
diff --git a/ext/digest/md5/md5init.c b/ext/digest/md5/md5init.c
new file mode 100644
index 0000000000..2acca16a46
--- /dev/null
+++ b/ext/digest/md5/md5init.c
@@ -0,0 +1,35 @@
+/* $RoughId: md5init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id$ */
+
+#include "digest.h"
+#if defined(HAVE_OPENSSL_MD5_H)
+#include "md5ossl.h"
+#else
+#include "md5.h"
+#endif
+
+static algo_t md5 = {
+ MD5_DIGEST_LENGTH,
+ sizeof(MD5_CTX),
+ (hash_init_func_t)MD5_Init,
+ (hash_update_func_t)MD5_Update,
+ (hash_end_func_t)MD5_End,
+ (hash_final_func_t)MD5_Final,
+ (hash_equal_func_t)MD5_Equal,
+};
+
+void
+Init_md5()
+{
+ VALUE mDigest, cDigest_Base, cDigest_MD5;
+
+ rb_require("digest.so");
+
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+ cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
+
+ rb_cvar_set(cDigest_MD5, rb_intern("metadata"),
+ Data_Wrap_Struct(rb_cObject, 0, 0, &md5), Qtrue);
+}
diff --git a/ext/digest/md5/md5ossl.c b/ext/digest/md5/md5ossl.c
new file mode 100644
index 0000000000..d930c7ab51
--- /dev/null
+++ b/ext/digest/md5/md5ossl.c
@@ -0,0 +1,30 @@
+/* $Id$ */
+
+#include "md5ossl.h"
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+
+void
+MD5_End(MD5_CTX *pctx, unsigned char *hexdigest)
+{
+ unsigned char digest[16];
+ size_t i;
+
+ MD5_Final(digest, pctx);
+
+ for (i = 0; i < 16; i++)
+ sprintf(hexdigest + i * 2, "%02x", digest[i]);
+}
+
+int
+MD5_Equal(MD5_CTX* pctx1, MD5_CTX* pctx2) {
+ return pctx1->num == pctx2->num
+ && pctx1->A == pctx2->A
+ && pctx1->B == pctx2->B
+ && pctx1->C == pctx2->C
+ && pctx1->D == pctx2->D
+ && pctx1->Nl == pctx2->Nl
+ && pctx1->Nh == pctx2->Nh
+ && memcmp(pctx1->data, pctx2->data, sizeof(pctx1->data)) == 0;
+}
diff --git a/ext/digest/md5/md5ossl.h b/ext/digest/md5/md5ossl.h
new file mode 100644
index 0000000000..dda7c743ed
--- /dev/null
+++ b/ext/digest/md5/md5ossl.h
@@ -0,0 +1,11 @@
+/* $Id$ */
+
+#ifndef MD5OSSL_H_INCLUDED
+#define MD5OSSL_H_INCLUDED
+
+#include <openssl/md5.h>
+
+void MD5_End(MD5_CTX *pctx, unsigned char *hexdigest);
+int MD5_Equal(MD5_CTX *pctx1, MD5_CTX *pctx2);
+
+#endif
diff --git a/ext/digest/rmd160/.cvsignore b/ext/digest/rmd160/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/digest/rmd160/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend
new file mode 100644
index 0000000000..0ca79c5f40
--- /dev/null
+++ b/ext/digest/rmd160/depend
@@ -0,0 +1,8 @@
+rmd160.o: rmd160.c rmd160.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
+rmd160hl.o: rmd160hl.c rmd160.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
+rmd160init.o: rmd160init.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h \
+ rmd160.h $(srcdir)/../defs.h
+rmd160ossl.o: rmd160ossl.h $(srcdir)/../defs.h
diff --git a/ext/digest/rmd160/extconf.rb b/ext/digest/rmd160/extconf.rb
new file mode 100644
index 0000000000..5bc968385c
--- /dev/null
+++ b/ext/digest/rmd160/extconf.rb
@@ -0,0 +1,25 @@
+# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
+# $Id$
+
+require "mkmf"
+
+$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+
+$objs = [ "rmd160init.#{$OBJEXT}" ]
+
+dir_config("openssl")
+
+if !with_config("bundled-rmd160") &&
+ have_library("crypto") && have_header("openssl/ripemd.h")
+ $objs << "rmd160ossl.#{$OBJEXT}"
+else
+ $objs << "rmd160.#{$OBJEXT}" << "rmd160hl.#{$OBJEXT}"
+end
+
+have_header("sys/cdefs.h")
+
+have_header("inttypes.h")
+
+have_header("unistd.h")
+
+create_makefile("digest/rmd160")
diff --git a/ext/digest/rmd160/rmd160.c b/ext/digest/rmd160/rmd160.c
new file mode 100644
index 0000000000..2de3c99b29
--- /dev/null
+++ b/ext/digest/rmd160/rmd160.c
@@ -0,0 +1,464 @@
+/* $NetBSD: rmd160.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $ */
+/* $RoughId: rmd160.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id$ */
+
+/********************************************************************\
+ *
+ * FILE: rmd160.c
+ *
+ * CONTENTS: A sample C-implementation of the RIPEMD-160
+ * hash-function.
+ * TARGET: any computer with an ANSI C compiler
+ *
+ * AUTHOR: Antoon Bosselaers, ESAT-COSIC
+ * (Arranged for libc by Todd C. Miller)
+ * DATE: 1 March 1996
+ * VERSION: 1.0
+ *
+ * Copyright (c) Katholieke Universiteit Leuven
+ * 1996, All Rights Reserved
+ *
+\********************************************************************/
+
+#include "rmd160.h"
+
+#ifndef lint
+/* __RCSID("$NetBSD: rmd160.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $"); */
+#endif /* not lint */
+
+/* header files */
+
+#ifdef HAVE_SYS_ENDIAN_H_
+#include <sys/endian.h>
+#endif
+
+#ifdef HAVE_MACHINE_ENDIAN_H_
+#include <machine/endian.h>
+#endif
+
+/* #include "namespace.h" */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+
+/********************************************************************/
+
+/* macro definitions */
+
+/* collect four bytes into one word: */
+#define BYTES_TO_DWORD(strptr) \
+ (((uint32_t) *((strptr)+3) << 24) | \
+ ((uint32_t) *((strptr)+2) << 16) | \
+ ((uint32_t) *((strptr)+1) << 8) | \
+ ((uint32_t) *(strptr)))
+
+/* ROL(x, n) cyclically rotates x over n bits to the left */
+/* x must be of an unsigned 32 bits type and 0 <= n < 32. */
+#define ROL(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* the three basic functions F(), G() and H() */
+#define F(x, y, z) ((x) ^ (y) ^ (z))
+#define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define H(x, y, z) (((x) | ~(y)) ^ (z))
+#define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define J(x, y, z) ((x) ^ ((y) | ~(z)))
+
+/* the eight basic operations FF() through III() */
+#define FF(a, b, c, d, e, x, s) { \
+ (a) += F((b), (c), (d)) + (x); \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define GG(a, b, c, d, e, x, s) { \
+ (a) += G((b), (c), (d)) + (x) + 0x5a827999U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define HH(a, b, c, d, e, x, s) { \
+ (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define II(a, b, c, d, e, x, s) { \
+ (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcU; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define JJ(a, b, c, d, e, x, s) { \
+ (a) += J((b), (c), (d)) + (x) + 0xa953fd4eU; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define FFF(a, b, c, d, e, x, s) { \
+ (a) += F((b), (c), (d)) + (x); \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define GGG(a, b, c, d, e, x, s) { \
+ (a) += G((b), (c), (d)) + (x) + 0x7a6d76e9U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define HHH(a, b, c, d, e, x, s) { \
+ (a) += H((b), (c), (d)) + (x) + 0x6d703ef3U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define III(a, b, c, d, e, x, s) { \
+ (a) += I((b), (c), (d)) + (x) + 0x5c4dd124U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define JJJ(a, b, c, d, e, x, s) { \
+ (a) += J((b), (c), (d)) + (x) + 0x50a28be6U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+
+/********************************************************************/
+
+void
+RMD160_Init(RMD160_CTX *context)
+{
+
+ _DIAGASSERT(context != NULL);
+
+ /* ripemd-160 initialization constants */
+ context->state[0] = 0x67452301U;
+ context->state[1] = 0xefcdab89U;
+ context->state[2] = 0x98badcfeU;
+ context->state[3] = 0x10325476U;
+ context->state[4] = 0xc3d2e1f0U;
+ context->length[0] = context->length[1] = 0;
+ context->buflen = 0;
+}
+
+/********************************************************************/
+
+void
+RMD160_Transform(uint32_t state[5], const uint32_t block[16])
+{
+ uint32_t aa, bb, cc, dd, ee;
+ uint32_t aaa, bbb, ccc, ddd, eee;
+
+ _DIAGASSERT(state != NULL);
+ _DIAGASSERT(block != NULL);
+
+ aa = aaa = state[0];
+ bb = bbb = state[1];
+ cc = ccc = state[2];
+ dd = ddd = state[3];
+ ee = eee = state[4];
+
+ /* round 1 */
+ FF(aa, bb, cc, dd, ee, block[ 0], 11);
+ FF(ee, aa, bb, cc, dd, block[ 1], 14);
+ FF(dd, ee, aa, bb, cc, block[ 2], 15);
+ FF(cc, dd, ee, aa, bb, block[ 3], 12);
+ FF(bb, cc, dd, ee, aa, block[ 4], 5);
+ FF(aa, bb, cc, dd, ee, block[ 5], 8);
+ FF(ee, aa, bb, cc, dd, block[ 6], 7);
+ FF(dd, ee, aa, bb, cc, block[ 7], 9);
+ FF(cc, dd, ee, aa, bb, block[ 8], 11);
+ FF(bb, cc, dd, ee, aa, block[ 9], 13);
+ FF(aa, bb, cc, dd, ee, block[10], 14);
+ FF(ee, aa, bb, cc, dd, block[11], 15);
+ FF(dd, ee, aa, bb, cc, block[12], 6);
+ FF(cc, dd, ee, aa, bb, block[13], 7);
+ FF(bb, cc, dd, ee, aa, block[14], 9);
+ FF(aa, bb, cc, dd, ee, block[15], 8);
+
+ /* round 2 */
+ GG(ee, aa, bb, cc, dd, block[ 7], 7);
+ GG(dd, ee, aa, bb, cc, block[ 4], 6);
+ GG(cc, dd, ee, aa, bb, block[13], 8);
+ GG(bb, cc, dd, ee, aa, block[ 1], 13);
+ GG(aa, bb, cc, dd, ee, block[10], 11);
+ GG(ee, aa, bb, cc, dd, block[ 6], 9);
+ GG(dd, ee, aa, bb, cc, block[15], 7);
+ GG(cc, dd, ee, aa, bb, block[ 3], 15);
+ GG(bb, cc, dd, ee, aa, block[12], 7);
+ GG(aa, bb, cc, dd, ee, block[ 0], 12);
+ GG(ee, aa, bb, cc, dd, block[ 9], 15);
+ GG(dd, ee, aa, bb, cc, block[ 5], 9);
+ GG(cc, dd, ee, aa, bb, block[ 2], 11);
+ GG(bb, cc, dd, ee, aa, block[14], 7);
+ GG(aa, bb, cc, dd, ee, block[11], 13);
+ GG(ee, aa, bb, cc, dd, block[ 8], 12);
+
+ /* round 3 */
+ HH(dd, ee, aa, bb, cc, block[ 3], 11);
+ HH(cc, dd, ee, aa, bb, block[10], 13);
+ HH(bb, cc, dd, ee, aa, block[14], 6);
+ HH(aa, bb, cc, dd, ee, block[ 4], 7);
+ HH(ee, aa, bb, cc, dd, block[ 9], 14);
+ HH(dd, ee, aa, bb, cc, block[15], 9);
+ HH(cc, dd, ee, aa, bb, block[ 8], 13);
+ HH(bb, cc, dd, ee, aa, block[ 1], 15);
+ HH(aa, bb, cc, dd, ee, block[ 2], 14);
+ HH(ee, aa, bb, cc, dd, block[ 7], 8);
+ HH(dd, ee, aa, bb, cc, block[ 0], 13);
+ HH(cc, dd, ee, aa, bb, block[ 6], 6);
+ HH(bb, cc, dd, ee, aa, block[13], 5);
+ HH(aa, bb, cc, dd, ee, block[11], 12);
+ HH(ee, aa, bb, cc, dd, block[ 5], 7);
+ HH(dd, ee, aa, bb, cc, block[12], 5);
+
+ /* round 4 */
+ II(cc, dd, ee, aa, bb, block[ 1], 11);
+ II(bb, cc, dd, ee, aa, block[ 9], 12);
+ II(aa, bb, cc, dd, ee, block[11], 14);
+ II(ee, aa, bb, cc, dd, block[10], 15);
+ II(dd, ee, aa, bb, cc, block[ 0], 14);
+ II(cc, dd, ee, aa, bb, block[ 8], 15);
+ II(bb, cc, dd, ee, aa, block[12], 9);
+ II(aa, bb, cc, dd, ee, block[ 4], 8);
+ II(ee, aa, bb, cc, dd, block[13], 9);
+ II(dd, ee, aa, bb, cc, block[ 3], 14);
+ II(cc, dd, ee, aa, bb, block[ 7], 5);
+ II(bb, cc, dd, ee, aa, block[15], 6);
+ II(aa, bb, cc, dd, ee, block[14], 8);
+ II(ee, aa, bb, cc, dd, block[ 5], 6);
+ II(dd, ee, aa, bb, cc, block[ 6], 5);
+ II(cc, dd, ee, aa, bb, block[ 2], 12);
+
+ /* round 5 */
+ JJ(bb, cc, dd, ee, aa, block[ 4], 9);
+ JJ(aa, bb, cc, dd, ee, block[ 0], 15);
+ JJ(ee, aa, bb, cc, dd, block[ 5], 5);
+ JJ(dd, ee, aa, bb, cc, block[ 9], 11);
+ JJ(cc, dd, ee, aa, bb, block[ 7], 6);
+ JJ(bb, cc, dd, ee, aa, block[12], 8);
+ JJ(aa, bb, cc, dd, ee, block[ 2], 13);
+ JJ(ee, aa, bb, cc, dd, block[10], 12);
+ JJ(dd, ee, aa, bb, cc, block[14], 5);
+ JJ(cc, dd, ee, aa, bb, block[ 1], 12);
+ JJ(bb, cc, dd, ee, aa, block[ 3], 13);
+ JJ(aa, bb, cc, dd, ee, block[ 8], 14);
+ JJ(ee, aa, bb, cc, dd, block[11], 11);
+ JJ(dd, ee, aa, bb, cc, block[ 6], 8);
+ JJ(cc, dd, ee, aa, bb, block[15], 5);
+ JJ(bb, cc, dd, ee, aa, block[13], 6);
+
+ /* parallel round 1 */
+ JJJ(aaa, bbb, ccc, ddd, eee, block[ 5], 8);
+ JJJ(eee, aaa, bbb, ccc, ddd, block[14], 9);
+ JJJ(ddd, eee, aaa, bbb, ccc, block[ 7], 9);
+ JJJ(ccc, ddd, eee, aaa, bbb, block[ 0], 11);
+ JJJ(bbb, ccc, ddd, eee, aaa, block[ 9], 13);
+ JJJ(aaa, bbb, ccc, ddd, eee, block[ 2], 15);
+ JJJ(eee, aaa, bbb, ccc, ddd, block[11], 15);
+ JJJ(ddd, eee, aaa, bbb, ccc, block[ 4], 5);
+ JJJ(ccc, ddd, eee, aaa, bbb, block[13], 7);
+ JJJ(bbb, ccc, ddd, eee, aaa, block[ 6], 7);
+ JJJ(aaa, bbb, ccc, ddd, eee, block[15], 8);
+ JJJ(eee, aaa, bbb, ccc, ddd, block[ 8], 11);
+ JJJ(ddd, eee, aaa, bbb, ccc, block[ 1], 14);
+ JJJ(ccc, ddd, eee, aaa, bbb, block[10], 14);
+ JJJ(bbb, ccc, ddd, eee, aaa, block[ 3], 12);
+ JJJ(aaa, bbb, ccc, ddd, eee, block[12], 6);
+
+ /* parallel round 2 */
+ III(eee, aaa, bbb, ccc, ddd, block[ 6], 9);
+ III(ddd, eee, aaa, bbb, ccc, block[11], 13);
+ III(ccc, ddd, eee, aaa, bbb, block[ 3], 15);
+ III(bbb, ccc, ddd, eee, aaa, block[ 7], 7);
+ III(aaa, bbb, ccc, ddd, eee, block[ 0], 12);
+ III(eee, aaa, bbb, ccc, ddd, block[13], 8);
+ III(ddd, eee, aaa, bbb, ccc, block[ 5], 9);
+ III(ccc, ddd, eee, aaa, bbb, block[10], 11);
+ III(bbb, ccc, ddd, eee, aaa, block[14], 7);
+ III(aaa, bbb, ccc, ddd, eee, block[15], 7);
+ III(eee, aaa, bbb, ccc, ddd, block[ 8], 12);
+ III(ddd, eee, aaa, bbb, ccc, block[12], 7);
+ III(ccc, ddd, eee, aaa, bbb, block[ 4], 6);
+ III(bbb, ccc, ddd, eee, aaa, block[ 9], 15);
+ III(aaa, bbb, ccc, ddd, eee, block[ 1], 13);
+ III(eee, aaa, bbb, ccc, ddd, block[ 2], 11);
+
+ /* parallel round 3 */
+ HHH(ddd, eee, aaa, bbb, ccc, block[15], 9);
+ HHH(ccc, ddd, eee, aaa, bbb, block[ 5], 7);
+ HHH(bbb, ccc, ddd, eee, aaa, block[ 1], 15);
+ HHH(aaa, bbb, ccc, ddd, eee, block[ 3], 11);
+ HHH(eee, aaa, bbb, ccc, ddd, block[ 7], 8);
+ HHH(ddd, eee, aaa, bbb, ccc, block[14], 6);
+ HHH(ccc, ddd, eee, aaa, bbb, block[ 6], 6);
+ HHH(bbb, ccc, ddd, eee, aaa, block[ 9], 14);
+ HHH(aaa, bbb, ccc, ddd, eee, block[11], 12);
+ HHH(eee, aaa, bbb, ccc, ddd, block[ 8], 13);
+ HHH(ddd, eee, aaa, bbb, ccc, block[12], 5);
+ HHH(ccc, ddd, eee, aaa, bbb, block[ 2], 14);
+ HHH(bbb, ccc, ddd, eee, aaa, block[10], 13);
+ HHH(aaa, bbb, ccc, ddd, eee, block[ 0], 13);
+ HHH(eee, aaa, bbb, ccc, ddd, block[ 4], 7);
+ HHH(ddd, eee, aaa, bbb, ccc, block[13], 5);
+
+ /* parallel round 4 */
+ GGG(ccc, ddd, eee, aaa, bbb, block[ 8], 15);
+ GGG(bbb, ccc, ddd, eee, aaa, block[ 6], 5);
+ GGG(aaa, bbb, ccc, ddd, eee, block[ 4], 8);
+ GGG(eee, aaa, bbb, ccc, ddd, block[ 1], 11);
+ GGG(ddd, eee, aaa, bbb, ccc, block[ 3], 14);
+ GGG(ccc, ddd, eee, aaa, bbb, block[11], 14);
+ GGG(bbb, ccc, ddd, eee, aaa, block[15], 6);
+ GGG(aaa, bbb, ccc, ddd, eee, block[ 0], 14);
+ GGG(eee, aaa, bbb, ccc, ddd, block[ 5], 6);
+ GGG(ddd, eee, aaa, bbb, ccc, block[12], 9);
+ GGG(ccc, ddd, eee, aaa, bbb, block[ 2], 12);
+ GGG(bbb, ccc, ddd, eee, aaa, block[13], 9);
+ GGG(aaa, bbb, ccc, ddd, eee, block[ 9], 12);
+ GGG(eee, aaa, bbb, ccc, ddd, block[ 7], 5);
+ GGG(ddd, eee, aaa, bbb, ccc, block[10], 15);
+ GGG(ccc, ddd, eee, aaa, bbb, block[14], 8);
+
+ /* parallel round 5 */
+ FFF(bbb, ccc, ddd, eee, aaa, block[12] , 8);
+ FFF(aaa, bbb, ccc, ddd, eee, block[15] , 5);
+ FFF(eee, aaa, bbb, ccc, ddd, block[10] , 12);
+ FFF(ddd, eee, aaa, bbb, ccc, block[ 4] , 9);
+ FFF(ccc, ddd, eee, aaa, bbb, block[ 1] , 12);
+ FFF(bbb, ccc, ddd, eee, aaa, block[ 5] , 5);
+ FFF(aaa, bbb, ccc, ddd, eee, block[ 8] , 14);
+ FFF(eee, aaa, bbb, ccc, ddd, block[ 7] , 6);
+ FFF(ddd, eee, aaa, bbb, ccc, block[ 6] , 8);
+ FFF(ccc, ddd, eee, aaa, bbb, block[ 2] , 13);
+ FFF(bbb, ccc, ddd, eee, aaa, block[13] , 6);
+ FFF(aaa, bbb, ccc, ddd, eee, block[14] , 5);
+ FFF(eee, aaa, bbb, ccc, ddd, block[ 0] , 15);
+ FFF(ddd, eee, aaa, bbb, ccc, block[ 3] , 13);
+ FFF(ccc, ddd, eee, aaa, bbb, block[ 9] , 11);
+ FFF(bbb, ccc, ddd, eee, aaa, block[11] , 11);
+
+ /* combine results */
+ ddd += cc + state[1]; /* final result for state[0] */
+ state[1] = state[2] + dd + eee;
+ state[2] = state[3] + ee + aaa;
+ state[3] = state[4] + aa + bbb;
+ state[4] = state[0] + bb + ccc;
+ state[0] = ddd;
+}
+
+/********************************************************************/
+
+void
+RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
+{
+ uint32_t X[16];
+ uint32_t ofs = 0;
+ uint32_t i;
+#ifdef WORDS_BIGENDIAN
+ uint32_t j;
+#endif
+
+ _DIAGASSERT(context != NULL);
+ _DIAGASSERT(data != NULL);
+
+ /* update length[] */
+ if (context->length[0] + nbytes < context->length[0])
+ context->length[1]++; /* overflow to msb of length */
+ context->length[0] += nbytes;
+
+ (void)memset(X, 0, sizeof(X));
+
+ if ( context->buflen + nbytes < 64 )
+ {
+ (void)memcpy(context->bbuffer + context->buflen, data, nbytes);
+ context->buflen += nbytes;
+ }
+ else
+ {
+ /* process first block */
+ ofs = 64 - context->buflen;
+ (void)memcpy(context->bbuffer + context->buflen, data, ofs);
+#ifndef WORDS_BIGENDIAN
+ (void)memcpy(X, context->bbuffer, sizeof(X));
+#else
+ for (j=0; j < 16; j++)
+ X[j] = BYTES_TO_DWORD(context->bbuffer + (4 * j));
+#endif
+ RMD160_Transform(context->state, X);
+ nbytes -= ofs;
+
+ /* process remaining complete blocks */
+ for (i = 0; i < (nbytes >> 6); i++) {
+#ifndef WORDS_BIGENDIAN
+ (void)memcpy(X, data + (64 * i) + ofs, sizeof(X));
+#else
+ for (j=0; j < 16; j++)
+ X[j] = BYTES_TO_DWORD(data + (64 * i) + (4 * j) + ofs);
+#endif
+ RMD160_Transform(context->state, X);
+ }
+
+ /*
+ * Put last bytes from data into context's buffer
+ */
+ context->buflen = nbytes & 63;
+ memcpy(context->bbuffer, data + (64 * i) + ofs, context->buflen);
+ }
+}
+
+/********************************************************************/
+
+void
+RMD160_Final(uint8_t digest[20], RMD160_CTX *context)
+{
+ uint32_t i;
+ uint32_t X[16];
+#ifdef WORDS_BIGENDIAN
+ uint32_t j;
+#endif
+
+ _DIAGASSERT(digest != NULL);
+ _DIAGASSERT(context != NULL);
+
+ /* append the bit m_n == 1 */
+ context->bbuffer[context->buflen] = (uint8_t)'\200';
+
+ (void)memset(context->bbuffer + context->buflen + 1, 0,
+ 63 - context->buflen);
+#ifndef WORDS_BIGENDIAN
+ (void)memcpy(X, context->bbuffer, sizeof(X));
+#else
+ for (j=0; j < 16; j++)
+ X[j] = BYTES_TO_DWORD(context->bbuffer + (4 * j));
+#endif
+ if ((context->buflen) > 55) {
+ /* length goes to next block */
+ RMD160_Transform(context->state, X);
+ (void)memset(X, 0, sizeof(X));
+ }
+
+ /* append length in bits */
+ X[14] = context->length[0] << 3;
+ X[15] = (context->length[0] >> 29) |
+ (context->length[1] << 3);
+ RMD160_Transform(context->state, X);
+
+ if (digest != NULL) {
+ for (i = 0; i < 20; i += 4) {
+ /* extracts the 8 least significant bits. */
+ digest[i] = context->state[i>>2];
+ digest[i + 1] = (context->state[i>>2] >> 8);
+ digest[i + 2] = (context->state[i>>2] >> 16);
+ digest[i + 3] = (context->state[i>>2] >> 24);
+ }
+ }
+}
+
+int RMD160_Equal(RMD160_CTX* pctx1, RMD160_CTX* pctx2) {
+ return pctx1->buflen == pctx2->buflen
+ && memcmp(pctx1->length, pctx2->length, sizeof(pctx1->length)) == 0
+ && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
+ && memcmp(pctx1->bbuffer, pctx2->bbuffer, sizeof(pctx1->bbuffer)) == 0;
+}
+
+/************************ end of file rmd160.c **********************/
diff --git a/ext/digest/rmd160/rmd160.h b/ext/digest/rmd160/rmd160.h
new file mode 100644
index 0000000000..24f9a025f0
--- /dev/null
+++ b/ext/digest/rmd160/rmd160.h
@@ -0,0 +1,68 @@
+/* $NetBSD: rmd160.h,v 1.2 2000/07/07 10:47:06 ad Exp $ */
+/* $RoughId: rmd160.h,v 1.3 2002/02/24 08:14:31 knu Exp $ */
+/* $Id$ */
+
+/********************************************************************\
+ *
+ * FILE: rmd160.h
+ *
+ * CONTENTS: Header file for a sample C-implementation of the
+ * RIPEMD-160 hash-function.
+ * TARGET: any computer with an ANSI C compiler
+ *
+ * AUTHOR: Antoon Bosselaers, ESAT-COSIC
+ * DATE: 1 March 1996
+ * VERSION: 1.0
+ *
+ * Copyright (c) Katholieke Universiteit Leuven
+ * 1996, All Rights Reserved
+ *
+\********************************************************************/
+
+/*
+ * from OpenBSD: rmd160.h,v 1.4 1999/08/16 09:59:04 millert Exp
+ */
+
+#ifndef _RMD160_H_
+#define _RMD160_H_
+
+#include "defs.h"
+
+typedef struct {
+ uint32_t state[5]; /* state (ABCDE) */
+ uint32_t length[2]; /* number of bits */
+ uint8_t bbuffer[64]; /* overflow buffer */
+ uint32_t buflen; /* number of chars in bbuffer */
+} RMD160_CTX;
+
+#ifdef RUBY
+#define RMD160_Init rb_Digest_RMD160_Init
+#define RMD160_Transform rb_Digest_RMD160_Transform
+#define RMD160_Update rb_Digest_RMD160_Update
+#define RMD160_Final rb_Digest_RMD160_Final
+#define RMD160_Equal rb_Digest_RMD160_Equal
+#ifndef _KERNEL
+#define RMD160_End rb_Digest_RMD160_End
+#define RMD160_File rb_Digest_RMD160_File
+#define RMD160_Data rb_Digest_RMD160_Data
+#endif /* _KERNEL */
+#endif
+
+__BEGIN_DECLS
+void RMD160_Init _((RMD160_CTX *));
+void RMD160_Transform _((uint32_t[5], const uint32_t[16]));
+void RMD160_Update _((RMD160_CTX *, const uint8_t *, size_t));
+void RMD160_Final _((uint8_t[20], RMD160_CTX *));
+int RMD160_Equal _((RMD160_CTX *, RMD160_CTX *));
+#ifndef _KERNEL
+char *RMD160_End _((RMD160_CTX *, char *));
+char *RMD160_File _((char *, char *));
+char *RMD160_Data _((const uint8_t *, size_t, char *));
+#endif /* _KERNEL */
+__END_DECLS
+
+#define RMD160_BLOCK_LENGTH 64
+#define RMD160_DIGEST_LENGTH 20
+#define RMD160_DIGEST_STRING_LENGTH (RMD160_DIGEST_LENGTH * 2 + 1)
+
+#endif /* !_RMD160_H_ */
diff --git a/ext/digest/rmd160/rmd160hl.c b/ext/digest/rmd160/rmd160hl.c
new file mode 100644
index 0000000000..4c5e0217d9
--- /dev/null
+++ b/ext/digest/rmd160/rmd160hl.c
@@ -0,0 +1,96 @@
+/* $NetBSD: rmd160hl.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $ */
+/* $RoughId: rmd160hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id$ */
+
+/* rmd160hl.c
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * from OpenBSD: rmd160hl.c,v 1.2 1999/08/17 09:13:12 millert Exp $
+ */
+
+#include "rmd160.h"
+
+#ifndef lint
+/* __RCSID("$NetBSD: rmd160hl.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $"); */
+#endif /* not lint */
+
+/* #include "namespace.h" */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#if defined(HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+
+char *
+RMD160_End(RMD160_CTX *ctx, char *buf)
+{
+ size_t i;
+ char *p = buf;
+ uint8_t digest[20];
+ static const char hex[]="0123456789abcdef";
+
+ _DIAGASSERT(ctx != NULL);
+ /* buf may be NULL */
+
+ if (p == NULL && (p = malloc(41)) == NULL)
+ return 0;
+
+ RMD160_Final(digest,ctx);
+ for (i = 0; i < 20; i++) {
+ p[i + i] = hex[(uint32_t)digest[i] >> 4];
+ p[i + i + 1] = hex[digest[i] & 0x0f];
+ }
+ p[i + i] = '\0';
+ return(p);
+}
+
+char *
+RMD160_File(char *filename, char *buf)
+{
+ uint8_t buffer[BUFSIZ];
+ RMD160_CTX ctx;
+ int fd, num, oerrno;
+
+ _DIAGASSERT(filename != NULL);
+ /* XXX: buf may be NULL ? */
+
+ RMD160_Init(&ctx);
+
+ if ((fd = open(filename, O_RDONLY)) < 0)
+ return(0);
+
+ while ((num = read(fd, buffer, sizeof(buffer))) > 0)
+ RMD160_Update(&ctx, buffer, (size_t)num);
+
+ oerrno = errno;
+ close(fd);
+ errno = oerrno;
+ return(num < 0 ? 0 : RMD160_End(&ctx, buf));
+}
+
+char *
+RMD160_Data(const uint8_t *data, size_t len, char *buf)
+{
+ RMD160_CTX ctx;
+
+ _DIAGASSERT(data != NULL);
+ /* XXX: buf may be NULL ? */
+
+ RMD160_Init(&ctx);
+ RMD160_Update(&ctx, data, len);
+ return(RMD160_End(&ctx, buf));
+}
diff --git a/ext/digest/rmd160/rmd160init.c b/ext/digest/rmd160/rmd160init.c
new file mode 100644
index 0000000000..b16cdbbed8
--- /dev/null
+++ b/ext/digest/rmd160/rmd160init.c
@@ -0,0 +1,38 @@
+/* $RoughId: rmd160init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
+/* $Id$ */
+
+#include "digest.h"
+#if defined(HAVE_OPENSSL_RIPEMD_H)
+#include "rmd160ossl.h"
+#else
+#include "rmd160.h"
+#endif
+
+static algo_t rmd160 = {
+ RMD160_DIGEST_LENGTH,
+ sizeof(RMD160_CTX),
+ (hash_init_func_t)RMD160_Init,
+ (hash_update_func_t)RMD160_Update,
+ (hash_end_func_t)RMD160_End,
+ (hash_final_func_t)RMD160_Final,
+ (hash_equal_func_t)RMD160_Equal,
+};
+
+void
+Init_rmd160()
+{
+ VALUE mDigest, cDigest_Base, cDigest_RMD160;
+ ID id_metadata;
+
+ rb_require("digest.so");
+
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+ cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
+
+ id_metadata = rb_intern("metadata");
+
+ rb_cvar_set(cDigest_RMD160, id_metadata,
+ Data_Wrap_Struct(rb_cObject, 0, 0, &rmd160), Qtrue);
+}
diff --git a/ext/digest/rmd160/rmd160ossl.c b/ext/digest/rmd160/rmd160ossl.c
new file mode 100644
index 0000000000..be66d81ff9
--- /dev/null
+++ b/ext/digest/rmd160/rmd160ossl.c
@@ -0,0 +1,45 @@
+/* $Id$ */
+
+#include "rmd160ossl.h"
+#include "defs.h"
+#include <assert.h>
+#include <stdlib.h>
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+char *
+RMD160_End(RMD160_CTX *ctx, char *buf)
+{
+ size_t i;
+ char *p = buf;
+ uint8_t digest[20];
+ static const char hex[]="0123456789abcdef";
+
+ _DIAGASSERT(ctx != NULL);
+ /* buf may be NULL */
+
+ if (p == NULL && (p = malloc(41)) == NULL)
+ return 0;
+
+ RMD160_Final(digest,ctx);
+ for (i = 0; i < 20; i++) {
+ p[i + i] = hex[(uint32_t)digest[i] >> 4];
+ p[i + i + 1] = hex[digest[i] & 0x0f];
+ }
+ p[i + i] = '\0';
+ return(p);
+}
+
+int RMD160_Equal(RMD160_CTX* pctx1, RMD160_CTX* pctx2) {
+ return pctx1->num == pctx2->num
+ && pctx1->A == pctx2->A
+ && pctx1->B == pctx2->B
+ && pctx1->C == pctx2->C
+ && pctx1->D == pctx2->D
+ && pctx1->E == pctx2->E
+ && pctx1->Nl == pctx2->Nl
+ && pctx1->Nh == pctx2->Nh
+ && memcmp(pctx1->data, pctx2->data, sizeof(pctx1->data)) == 0;
+}
diff --git a/ext/digest/rmd160/rmd160ossl.h b/ext/digest/rmd160/rmd160ossl.h
new file mode 100644
index 0000000000..824a1bf32f
--- /dev/null
+++ b/ext/digest/rmd160/rmd160ossl.h
@@ -0,0 +1,20 @@
+/* $Id$ */
+
+#ifndef RMD160OSSL_H_INCLUDED
+#define RMD160OSSL_H_INCLUDED
+
+#include <openssl/ripemd.h>
+
+#define RMD160_CTX RIPEMD160_CTX
+
+#define RMD160_Init RIPEMD160_Init
+#define RMD160_Update RIPEMD160_Update
+#define RMD160_Final RIPEMD160_Final
+
+#define RMD160_BLOCK_LENGTH RIPEMD160_CBLOCK
+#define RMD160_DIGEST_LENGTH RIPEMD160_DIGEST_LENGTH
+
+char *RMD160_End(RMD160_CTX *ctx, char *buf);
+int RMD160_Equal(RMD160_CTX *pctx1, RMD160_CTX *pctx2);
+
+#endif
diff --git a/ext/digest/sha1/.cvsignore b/ext/digest/sha1/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/digest/sha1/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/digest/sha1/depend b/ext/digest/sha1/depend
new file mode 100644
index 0000000000..a159f456d3
--- /dev/null
+++ b/ext/digest/sha1/depend
@@ -0,0 +1,8 @@
+sha1.o: sha1.c sha1.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
+sha1hl.o: sha1hl.c sha1.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
+sha1init.o: sha1init.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h \
+ sha1.h $(srcdir)/../defs.h
+sha1ossl.o: sha1ossl.h $(srcdir)/../defs.h
diff --git a/ext/digest/sha1/extconf.rb b/ext/digest/sha1/extconf.rb
new file mode 100644
index 0000000000..c249a415ed
--- /dev/null
+++ b/ext/digest/sha1/extconf.rb
@@ -0,0 +1,25 @@
+# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
+# $Id$
+
+require "mkmf"
+
+$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+
+$objs = [ "sha1init.#{$OBJEXT}" ]
+
+dir_config("openssl")
+
+if !with_config("bundled-sha1") &&
+ have_library("crypto") && have_header("openssl/sha.h")
+ $objs << "sha1ossl.#{$OBJEXT}"
+else
+ $objs << "sha1.#{$OBJEXT}" << "sha1hl.#{$OBJEXT}"
+end
+
+have_header("sys/cdefs.h")
+
+have_header("inttypes.h")
+
+have_header("unistd.h")
+
+create_makefile("digest/sha1")
diff --git a/ext/digest/sha1/sha1.c b/ext/digest/sha1/sha1.c
new file mode 100644
index 0000000000..1012ef8751
--- /dev/null
+++ b/ext/digest/sha1/sha1.c
@@ -0,0 +1,283 @@
+/* $NetBSD: sha1.c,v 1.2 2001/03/22 09:51:48 agc Exp $ */
+/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
+/* $RoughId: sha1.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id$ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ *
+ * Test Vectors (from FIPS PUB 180-1)
+ * "abc"
+ * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+ * A million repetitions of "a"
+ * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ */
+
+#include "sha1.h"
+
+#define SHA1HANDSOFF /* Copies data before messing with it. */
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/param.h>
+#include <sys/systm.h>
+#define _DIAGASSERT(x) (void)0
+#else
+/* #include "namespace.h" */
+#include <assert.h>
+#include <string.h>
+#endif
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+/*
+ * XXX Kludge until there is resolution regarding mem*() functions
+ * XXX in the kernel.
+ */
+#if defined(_KERNEL) || defined(_STANDALONE)
+#define memcpy(s, d, l) bcopy((d), (s), (l))
+#endif
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/*
+ * blk0() and blk() perform the initial expand.
+ * I got the idea of expanding during the round function from SSLeay
+ */
+#ifndef WORDS_BIGENDIAN
+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+# define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/*
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
+ */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+typedef union {
+ uint8_t c[64];
+ uint32_t l[16];
+} CHAR64LONG16;
+
+#ifdef __sparc_v9__
+void do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+
+#define nR0(v,w,x,y,z,i) R0(*v,*w,*x,*y,*z,i)
+#define nR1(v,w,x,y,z,i) R1(*v,*w,*x,*y,*z,i)
+#define nR2(v,w,x,y,z,i) R2(*v,*w,*x,*y,*z,i)
+#define nR3(v,w,x,y,z,i) R3(*v,*w,*x,*y,*z,i)
+#define nR4(v,w,x,y,z,i) R4(*v,*w,*x,*y,*z,i)
+
+void
+do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR0(a,b,c,d,e, 0); nR0(e,a,b,c,d, 1); nR0(d,e,a,b,c, 2); nR0(c,d,e,a,b, 3);
+ nR0(b,c,d,e,a, 4); nR0(a,b,c,d,e, 5); nR0(e,a,b,c,d, 6); nR0(d,e,a,b,c, 7);
+ nR0(c,d,e,a,b, 8); nR0(b,c,d,e,a, 9); nR0(a,b,c,d,e,10); nR0(e,a,b,c,d,11);
+ nR0(d,e,a,b,c,12); nR0(c,d,e,a,b,13); nR0(b,c,d,e,a,14); nR0(a,b,c,d,e,15);
+ nR1(e,a,b,c,d,16); nR1(d,e,a,b,c,17); nR1(c,d,e,a,b,18); nR1(b,c,d,e,a,19);
+}
+
+void
+do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR2(a,b,c,d,e,20); nR2(e,a,b,c,d,21); nR2(d,e,a,b,c,22); nR2(c,d,e,a,b,23);
+ nR2(b,c,d,e,a,24); nR2(a,b,c,d,e,25); nR2(e,a,b,c,d,26); nR2(d,e,a,b,c,27);
+ nR2(c,d,e,a,b,28); nR2(b,c,d,e,a,29); nR2(a,b,c,d,e,30); nR2(e,a,b,c,d,31);
+ nR2(d,e,a,b,c,32); nR2(c,d,e,a,b,33); nR2(b,c,d,e,a,34); nR2(a,b,c,d,e,35);
+ nR2(e,a,b,c,d,36); nR2(d,e,a,b,c,37); nR2(c,d,e,a,b,38); nR2(b,c,d,e,a,39);
+}
+
+void
+do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR3(a,b,c,d,e,40); nR3(e,a,b,c,d,41); nR3(d,e,a,b,c,42); nR3(c,d,e,a,b,43);
+ nR3(b,c,d,e,a,44); nR3(a,b,c,d,e,45); nR3(e,a,b,c,d,46); nR3(d,e,a,b,c,47);
+ nR3(c,d,e,a,b,48); nR3(b,c,d,e,a,49); nR3(a,b,c,d,e,50); nR3(e,a,b,c,d,51);
+ nR3(d,e,a,b,c,52); nR3(c,d,e,a,b,53); nR3(b,c,d,e,a,54); nR3(a,b,c,d,e,55);
+ nR3(e,a,b,c,d,56); nR3(d,e,a,b,c,57); nR3(c,d,e,a,b,58); nR3(b,c,d,e,a,59);
+}
+
+void
+do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR4(a,b,c,d,e,60); nR4(e,a,b,c,d,61); nR4(d,e,a,b,c,62); nR4(c,d,e,a,b,63);
+ nR4(b,c,d,e,a,64); nR4(a,b,c,d,e,65); nR4(e,a,b,c,d,66); nR4(d,e,a,b,c,67);
+ nR4(c,d,e,a,b,68); nR4(b,c,d,e,a,69); nR4(a,b,c,d,e,70); nR4(e,a,b,c,d,71);
+ nR4(d,e,a,b,c,72); nR4(c,d,e,a,b,73); nR4(b,c,d,e,a,74); nR4(a,b,c,d,e,75);
+ nR4(e,a,b,c,d,76); nR4(d,e,a,b,c,77); nR4(c,d,e,a,b,78); nR4(b,c,d,e,a,79);
+}
+#endif
+
+/*
+ * Hash a single 512-bit block. This is the core of the algorithm.
+ */
+void SHA1_Transform(state, buffer)
+ uint32_t state[5];
+ const uint8_t buffer[64];
+{
+ uint32_t a, b, c, d, e;
+ CHAR64LONG16 *block;
+
+#ifdef SHA1HANDSOFF
+ CHAR64LONG16 workspace;
+#endif
+
+ _DIAGASSERT(buffer != 0);
+ _DIAGASSERT(state != 0);
+
+#ifdef SHA1HANDSOFF
+ block = &workspace;
+ (void)memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16 *)(void *)buffer;
+#endif
+
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+
+#ifdef __sparc_v9__
+ do_R01(&a, &b, &c, &d, &e, block);
+ do_R2(&a, &b, &c, &d, &e, block);
+ do_R3(&a, &b, &c, &d, &e, block);
+ do_R4(&a, &b, &c, &d, &e, block);
+#else
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+#endif
+
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/*
+ * SHA1_Init - Initialize new context
+ */
+void SHA1_Init(context)
+ SHA1_CTX *context;
+{
+
+ _DIAGASSERT(context != 0);
+
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/*
+ * Run your data through this.
+ */
+void SHA1_Update(context, data, len)
+ SHA1_CTX *context;
+ const uint8_t *data;
+ size_t len;
+{
+ uint32_t i, j;
+
+ _DIAGASSERT(context != 0);
+ _DIAGASSERT(data != 0);
+
+ j = context->count[0];
+ if ((context->count[0] += len << 3) < j)
+ context->count[1] += (len>>29)+1;
+ j = (j >> 3) & 63;
+ if ((j + len) > 63) {
+ (void)memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1_Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64)
+ SHA1_Transform(context->state, &data[i]);
+ j = 0;
+ } else {
+ i = 0;
+ }
+ (void)memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/*
+ * Add padding and return the message digest.
+ */
+void SHA1_Final(digest, context)
+ uint8_t digest[20];
+ SHA1_CTX* context;
+{
+ size_t i;
+ uint8_t finalcount[8];
+
+ _DIAGASSERT(digest != 0);
+ _DIAGASSERT(context != 0);
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (uint8_t)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ SHA1_Update(context, (const uint8_t *)"\200", 1);
+ while ((context->count[0] & 504) != 448)
+ SHA1_Update(context, (const uint8_t *)"\0", 1);
+ SHA1_Update(context, finalcount, 8); /* Should cause a SHA1_Transform() */
+
+ if (digest) {
+ for (i = 0; i < 20; i++)
+ digest[i] = (uint8_t)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+}
+
+int SHA1_Equal(SHA1_CTX* pctx1, SHA1_CTX* pctx2) {
+ return memcmp(pctx1->count, pctx2->count, sizeof(pctx1->count)) == 0
+ && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
+ && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
+}
diff --git a/ext/digest/sha1/sha1.h b/ext/digest/sha1/sha1.h
new file mode 100644
index 0000000000..2303cecc2b
--- /dev/null
+++ b/ext/digest/sha1/sha1.h
@@ -0,0 +1,50 @@
+/* $NetBSD: sha1.h,v 1.2 1998/05/29 22:55:44 thorpej Exp $ */
+/* $RoughId: sha1.h,v 1.3 2002/02/24 08:14:32 knu Exp $ */
+/* $Id$ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ */
+
+#ifndef _SYS_SHA1_H_
+#define _SYS_SHA1_H_
+
+#include "defs.h"
+
+typedef struct {
+ uint32_t state[5];
+ uint32_t count[2];
+ uint8_t buffer[64];
+} SHA1_CTX;
+
+#ifdef RUBY
+#define SHA1_Transform rb_Digest_SHA1_Transform
+#define SHA1_Init rb_Digest_SHA1_Init
+#define SHA1_Update rb_Digest_SHA1_Update
+#define SHA1_Final rb_Digest_SHA1_Final
+#define SHA1_Equal rb_Digest_SHA1_Equal
+#ifndef _KERNEL
+#define SHA1_End rb_Digest_SHA1_End
+#define SHA1_File rb_Digest_SHA1_File
+#define SHA1_Data rb_Digest_SHA1_Data
+#endif /* _KERNEL */
+#endif
+
+void SHA1_Transform _((uint32_t state[5], const uint8_t buffer[64]));
+void SHA1_Init _((SHA1_CTX *context));
+void SHA1_Update _((SHA1_CTX *context, const uint8_t *data, size_t len));
+void SHA1_Final _((uint8_t digest[20], SHA1_CTX *context));
+int SHA1_Equal _((SHA1_CTX *pctx1, SHA1_CTX *pctx2));
+#ifndef _KERNEL
+char *SHA1_End _((SHA1_CTX *, char *));
+char *SHA1_File _((char *, char *));
+char *SHA1_Data _((const uint8_t *, size_t, char *));
+#endif /* _KERNEL */
+
+#define SHA1_BLOCK_LENGTH 64
+#define SHA1_DIGEST_LENGTH 20
+#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
+
+#endif /* _SYS_SHA1_H_ */
diff --git a/ext/digest/sha1/sha1hl.c b/ext/digest/sha1/sha1hl.c
new file mode 100644
index 0000000000..d1a236b22c
--- /dev/null
+++ b/ext/digest/sha1/sha1hl.c
@@ -0,0 +1,102 @@
+/* $NetBSD: sha1hl.c,v 1.2 2001/03/10 15:55:14 tron Exp $ */
+/* $RoughId: sha1hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id$ */
+
+/* sha1hl.c
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ */
+
+/* #include "namespace.h" */
+
+#include "sha1.h"
+#include <fcntl.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#if defined(HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#if defined(LIBC_SCCS) && !defined(lint)
+/* __RCSID("$NetBSD: sha1hl.c,v 1.2 2001/03/10 15:55:14 tron Exp $"); */
+#endif /* LIBC_SCCS and not lint */
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+
+/* ARGSUSED */
+char *
+SHA1_End(ctx, buf)
+ SHA1_CTX *ctx;
+ char *buf;
+{
+ int i;
+ char *p = buf;
+ uint8_t digest[20];
+ static const char hex[]="0123456789abcdef";
+
+ _DIAGASSERT(ctx != NULL);
+ /* buf may be NULL */
+
+ if (p == NULL && (p = malloc(41)) == NULL)
+ return 0;
+
+ SHA1_Final(digest,ctx);
+ for (i = 0; i < 20; i++) {
+ p[i + i] = hex[((uint32_t)digest[i]) >> 4];
+ p[i + i + 1] = hex[digest[i] & 0x0f];
+ }
+ p[i + i] = '\0';
+ return(p);
+}
+
+char *
+SHA1_File (filename, buf)
+ char *filename;
+ char *buf;
+{
+ uint8_t buffer[BUFSIZ];
+ SHA1_CTX ctx;
+ int fd, num, oerrno;
+
+ _DIAGASSERT(filename != NULL);
+ /* XXX: buf may be NULL ? */
+
+ SHA1_Init(&ctx);
+
+ if ((fd = open(filename,O_RDONLY)) < 0)
+ return(0);
+
+ while ((num = read(fd, buffer, sizeof(buffer))) > 0)
+ SHA1_Update(&ctx, buffer, (size_t)num);
+
+ oerrno = errno;
+ close(fd);
+ errno = oerrno;
+ return(num < 0 ? 0 : SHA1_End(&ctx, buf));
+}
+
+char *
+SHA1_Data (data, len, buf)
+ const uint8_t *data;
+ size_t len;
+ char *buf;
+{
+ SHA1_CTX ctx;
+
+ _DIAGASSERT(data != NULL);
+ /* XXX: buf may be NULL ? */
+
+ SHA1_Init(&ctx);
+ SHA1_Update(&ctx, data, len);
+ return(SHA1_End(&ctx, buf));
+}
diff --git a/ext/digest/sha1/sha1init.c b/ext/digest/sha1/sha1init.c
new file mode 100644
index 0000000000..426afb7cd0
--- /dev/null
+++ b/ext/digest/sha1/sha1init.c
@@ -0,0 +1,38 @@
+/* $RoughId: sha1init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id$ */
+
+#include "digest.h"
+#if defined(HAVE_OPENSSL_SHA_H)
+#include "sha1ossl.h"
+#else
+#include "sha1.h"
+#endif
+
+static algo_t sha1 = {
+ SHA1_DIGEST_LENGTH,
+ sizeof(SHA1_CTX),
+ (hash_init_func_t)SHA1_Init,
+ (hash_update_func_t)SHA1_Update,
+ (hash_end_func_t)SHA1_End,
+ (hash_final_func_t)SHA1_Final,
+ (hash_equal_func_t)SHA1_Equal,
+};
+
+void
+Init_sha1()
+{
+ VALUE mDigest, cDigest_Base, cDigest_SHA1;
+ ID id_metadata;
+
+ rb_require("digest.so");
+
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+ cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
+
+ id_metadata = rb_intern("metadata");
+
+ rb_cvar_set(cDigest_SHA1, id_metadata,
+ Data_Wrap_Struct(rb_cObject, 0, 0, &sha1), Qtrue);
+}
diff --git a/ext/digest/sha1/sha1ossl.c b/ext/digest/sha1/sha1ossl.c
new file mode 100644
index 0000000000..b125128f82
--- /dev/null
+++ b/ext/digest/sha1/sha1ossl.c
@@ -0,0 +1,45 @@
+/* $Id$ */
+
+#include "sha1ossl.h"
+#include "defs.h"
+#include <assert.h>
+#include <stdlib.h>
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+char *
+SHA1_End(SHA1_CTX *ctx, char *buf)
+{
+ int i;
+ char *p = buf;
+ uint8_t digest[20];
+ static const char hex[]="0123456789abcdef";
+
+ _DIAGASSERT(ctx != NULL);
+ /* buf may be NULL */
+
+ if (p == NULL && (p = malloc(41)) == NULL)
+ return 0;
+
+ SHA1_Final(digest,ctx);
+ for (i = 0; i < 20; i++) {
+ p[i + i] = hex[((uint32_t)digest[i]) >> 4];
+ p[i + i + 1] = hex[digest[i] & 0x0f];
+ }
+ p[i + i] = '\0';
+ return(p);
+}
+
+int SHA1_Equal(SHA1_CTX* pctx1, SHA1_CTX* pctx2) {
+ return pctx1->num == pctx2->num
+ && pctx1->h0 == pctx2->h0
+ && pctx1->h1 == pctx2->h1
+ && pctx1->h2 == pctx2->h2
+ && pctx1->h3 == pctx2->h3
+ && pctx1->h4 == pctx2->h4
+ && pctx1->Nl == pctx2->Nl
+ && pctx1->Nh == pctx2->Nh
+ && memcmp(pctx1->data, pctx2->data, sizeof(pctx1->data)) == 0;
+}
diff --git a/ext/digest/sha1/sha1ossl.h b/ext/digest/sha1/sha1ossl.h
new file mode 100644
index 0000000000..e8d7e74baf
--- /dev/null
+++ b/ext/digest/sha1/sha1ossl.h
@@ -0,0 +1,16 @@
+/* $Id$ */
+
+#ifndef SHA1OSSL_H_INCLUDED
+#define SHA1OSSL_H_INCLUDED
+
+#include <openssl/sha.h>
+
+#define SHA1_CTX SHA_CTX
+
+#define SHA1_BLOCK_LENGTH SHA_BLOCK_LENGTH
+#define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
+
+char *SHA1_End(SHA1_CTX *ctx, char *buf);
+int SHA1_Equal(SHA1_CTX *pctx1, SHA1_CTX *pctx2);
+
+#endif
diff --git a/ext/digest/sha2/.cvsignore b/ext/digest/sha2/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/digest/sha2/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/digest/sha2/depend b/ext/digest/sha2/depend
new file mode 100644
index 0000000000..2587415fdc
--- /dev/null
+++ b/ext/digest/sha2/depend
@@ -0,0 +1,7 @@
+sha2.o: sha2.c sha2.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
+sha2hl.o: sha2hl.c sha2.h $(srcdir)/../defs.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h
+sha2init.o: sha2init.c $(srcdir)/../digest.h $(hdrdir)/ruby.h \
+ $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/intern.h \
+ sha2.h $(srcdir)/../defs.h
diff --git a/ext/digest/sha2/extconf.rb b/ext/digest/sha2/extconf.rb
new file mode 100644
index 0000000000..c982aa64de
--- /dev/null
+++ b/ext/digest/sha2/extconf.rb
@@ -0,0 +1,28 @@
+# $RoughId: extconf.rb,v 1.4 2001/08/14 19:54:51 knu Exp $
+# $Id$
+
+require "mkmf"
+
+$CFLAGS << " -DHAVE_CONFIG_H -I#{File.dirname(__FILE__)}/.."
+
+$objs = [
+ "sha2.#{$OBJEXT}",
+ "sha2hl.#{$OBJEXT}",
+ "sha2init.#{$OBJEXT}",
+]
+
+have_header("sys/cdefs.h")
+
+have_header("inttypes.h")
+
+have_header("unistd.h")
+
+if try_cpp(<<SRC, $defs.join(' '))
+#include "defs.h"
+#ifdef NO_UINT64_T
+ #error ** Cannot find a 64bit integer type - skipping the SHA2 module.
+#endif
+SRC
+then
+ create_makefile("digest/sha2")
+end
diff --git a/ext/digest/sha2/sha2.c b/ext/digest/sha2/sha2.c
new file mode 100644
index 0000000000..24a57ded0d
--- /dev/null
+++ b/ext/digest/sha2/sha2.c
@@ -0,0 +1,937 @@
+/*
+ * sha2.c
+ *
+ * Version 1.0.0beta1
+ *
+ * Written by Aaron D. Gifford <me@aarongifford.com>
+ *
+ * Copyright 2000 Aaron D. Gifford. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/* $RoughId: sha2.c,v 1.3 2002/02/26 22:03:36 knu Exp $ */
+/* $Id$ */
+
+#include "sha2.h"
+#include <stdio.h>
+#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
+#include <assert.h> /* assert() */
+
+/*
+ * ASSERT NOTE:
+ * Some sanity checking code is included using assert(). On my FreeBSD
+ * system, this additional code can be removed by compiling with NDEBUG
+ * defined. Check your own systems manpage on assert() to see how to
+ * compile WITHOUT the sanity checking code on your system.
+ *
+ * UNROLLED TRANSFORM LOOP NOTE:
+ * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform
+ * loop version for the hash transform rounds (defined using macros
+ * later in this file). Either define on the command line, for example:
+ *
+ * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c
+ *
+ * or define below:
+ *
+ * #define SHA2_UNROLL_TRANSFORM
+ *
+ */
+
+
+/*** SHA-256/384/512 Machine Architecture Definitions *****************/
+typedef uint8_t sha2_byte; /* Exactly 1 byte */
+typedef uint32_t sha2_word32; /* Exactly 4 bytes */
+typedef uint64_t sha2_word64; /* Exactly 8 bytes */
+
+#if defined(__GNUC__) || defined(_HPUX_SOURCE)
+#define ULL(number) number##ULL
+#else
+#define ULL(number) (uint64_t)(number)
+#endif
+
+
+/*** SHA-256/384/512 Various Length Definitions ***********************/
+/* NOTE: Most of these are in sha2.h */
+#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
+#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16)
+#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16)
+
+
+/*** ENDIAN REVERSAL MACROS *******************************************/
+#ifndef WORDS_BIGENDIAN
+#define REVERSE32(w,x) { \
+ sha2_word32 tmp = (w); \
+ tmp = (tmp >> 16) | (tmp << 16); \
+ (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \
+}
+#define REVERSE64(w,x) { \
+ sha2_word64 tmp = (w); \
+ tmp = (tmp >> 32) | (tmp << 32); \
+ tmp = ((tmp & ULL(0xff00ff00ff00ff00)) >> 8) | \
+ ((tmp & ULL(0x00ff00ff00ff00ff)) << 8); \
+ (x) = ((tmp & ULL(0xffff0000ffff0000)) >> 16) | \
+ ((tmp & ULL(0x0000ffff0000ffff)) << 16); \
+}
+#endif
+
+/*
+ * Macro for incrementally adding the unsigned 64-bit integer n to the
+ * unsigned 128-bit integer (represented using a two-element array of
+ * 64-bit words):
+ */
+#define ADDINC128(w,n) { \
+ (w)[0] += (sha2_word64)(n); \
+ if ((w)[0] < (n)) { \
+ (w)[1]++; \
+ } \
+}
+
+/*
+ * Macros for copying blocks of memory and for zeroing out ranges
+ * of memory. Using these macros makes it easy to switch from
+ * using memset()/memcpy() and using bzero()/bcopy().
+ *
+ * Please define either SHA2_USE_MEMSET_MEMCPY or define
+ * SHA2_USE_BZERO_BCOPY depending on which function set you
+ * choose to use:
+ */
+#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY)
+/* Default to memset()/memcpy() if no option is specified */
+#define SHA2_USE_MEMSET_MEMCPY 1
+#endif
+#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY)
+/* Abort with an error if BOTH options are defined */
+#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both!
+#endif
+
+#ifdef SHA2_USE_MEMSET_MEMCPY
+#define MEMSET_BZERO(p,l) memset((p), 0, (l))
+#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
+#endif
+#ifdef SHA2_USE_BZERO_BCOPY
+#define MEMSET_BZERO(p,l) bzero((p), (l))
+#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
+#endif
+
+
+/*** THE SIX LOGICAL FUNCTIONS ****************************************/
+/*
+ * Bit shifting and rotation (used by the six SHA-XYZ logical functions:
+ *
+ * NOTE: The naming of R and S appears backwards here (R is a SHIFT and
+ * S is a ROTATION) because the SHA-256/384/512 description document
+ * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this
+ * same "backwards" definition.
+ */
+/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */
+#define R(b,x) ((x) >> (b))
+/* 32-bit Rotate-right (used in SHA-256): */
+#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b))))
+/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */
+#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b))))
+
+/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */
+#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
+#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+
+/* Four of six logical functions used in SHA-256: */
+#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x)))
+#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x)))
+#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x)))
+#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x)))
+
+/* Four of six logical functions used in SHA-384 and SHA-512: */
+#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x)))
+#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x)))
+#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x)))
+#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x)))
+
+/*** INTERNAL FUNCTION PROTOTYPES *************************************/
+/* NOTE: These should not be accessed directly from outside this
+ * library -- they are intended for private internal visibility/use
+ * only.
+ */
+void SHA512_Last(SHA512_CTX*);
+void SHA256_Transform(SHA256_CTX*, const sha2_word32*);
+void SHA512_Transform(SHA512_CTX*, const sha2_word64*);
+
+
+/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
+/* Hash constant words K for SHA-256: */
+const static sha2_word32 K256[64] = {
+ 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
+ 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
+ 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
+ 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
+ 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
+ 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
+ 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
+ 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
+ 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
+ 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
+ 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
+ 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
+ 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
+ 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
+ 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
+ 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
+};
+
+/* Initial hash value H for SHA-256: */
+const static sha2_word32 sha256_initial_hash_value[8] = {
+ 0x6a09e667UL,
+ 0xbb67ae85UL,
+ 0x3c6ef372UL,
+ 0xa54ff53aUL,
+ 0x510e527fUL,
+ 0x9b05688cUL,
+ 0x1f83d9abUL,
+ 0x5be0cd19UL
+};
+
+/* Hash constant words K for SHA-384 and SHA-512: */
+const static sha2_word64 K512[80] = {
+ ULL(0x428a2f98d728ae22), ULL(0x7137449123ef65cd),
+ ULL(0xb5c0fbcfec4d3b2f), ULL(0xe9b5dba58189dbbc),
+ ULL(0x3956c25bf348b538), ULL(0x59f111f1b605d019),
+ ULL(0x923f82a4af194f9b), ULL(0xab1c5ed5da6d8118),
+ ULL(0xd807aa98a3030242), ULL(0x12835b0145706fbe),
+ ULL(0x243185be4ee4b28c), ULL(0x550c7dc3d5ffb4e2),
+ ULL(0x72be5d74f27b896f), ULL(0x80deb1fe3b1696b1),
+ ULL(0x9bdc06a725c71235), ULL(0xc19bf174cf692694),
+ ULL(0xe49b69c19ef14ad2), ULL(0xefbe4786384f25e3),
+ ULL(0x0fc19dc68b8cd5b5), ULL(0x240ca1cc77ac9c65),
+ ULL(0x2de92c6f592b0275), ULL(0x4a7484aa6ea6e483),
+ ULL(0x5cb0a9dcbd41fbd4), ULL(0x76f988da831153b5),
+ ULL(0x983e5152ee66dfab), ULL(0xa831c66d2db43210),
+ ULL(0xb00327c898fb213f), ULL(0xbf597fc7beef0ee4),
+ ULL(0xc6e00bf33da88fc2), ULL(0xd5a79147930aa725),
+ ULL(0x06ca6351e003826f), ULL(0x142929670a0e6e70),
+ ULL(0x27b70a8546d22ffc), ULL(0x2e1b21385c26c926),
+ ULL(0x4d2c6dfc5ac42aed), ULL(0x53380d139d95b3df),
+ ULL(0x650a73548baf63de), ULL(0x766a0abb3c77b2a8),
+ ULL(0x81c2c92e47edaee6), ULL(0x92722c851482353b),
+ ULL(0xa2bfe8a14cf10364), ULL(0xa81a664bbc423001),
+ ULL(0xc24b8b70d0f89791), ULL(0xc76c51a30654be30),
+ ULL(0xd192e819d6ef5218), ULL(0xd69906245565a910),
+ ULL(0xf40e35855771202a), ULL(0x106aa07032bbd1b8),
+ ULL(0x19a4c116b8d2d0c8), ULL(0x1e376c085141ab53),
+ ULL(0x2748774cdf8eeb99), ULL(0x34b0bcb5e19b48a8),
+ ULL(0x391c0cb3c5c95a63), ULL(0x4ed8aa4ae3418acb),
+ ULL(0x5b9cca4f7763e373), ULL(0x682e6ff3d6b2b8a3),
+ ULL(0x748f82ee5defb2fc), ULL(0x78a5636f43172f60),
+ ULL(0x84c87814a1f0ab72), ULL(0x8cc702081a6439ec),
+ ULL(0x90befffa23631e28), ULL(0xa4506cebde82bde9),
+ ULL(0xbef9a3f7b2c67915), ULL(0xc67178f2e372532b),
+ ULL(0xca273eceea26619c), ULL(0xd186b8c721c0c207),
+ ULL(0xeada7dd6cde0eb1e), ULL(0xf57d4f7fee6ed178),
+ ULL(0x06f067aa72176fba), ULL(0x0a637dc5a2c898a6),
+ ULL(0x113f9804bef90dae), ULL(0x1b710b35131c471b),
+ ULL(0x28db77f523047d84), ULL(0x32caab7b40c72493),
+ ULL(0x3c9ebe0a15c9bebc), ULL(0x431d67c49c100d4c),
+ ULL(0x4cc5d4becb3e42b6), ULL(0x597f299cfc657e2a),
+ ULL(0x5fcb6fab3ad6faec), ULL(0x6c44198c4a475817)
+};
+
+/* Initial hash value H for SHA-384 */
+const static sha2_word64 sha384_initial_hash_value[8] = {
+ ULL(0xcbbb9d5dc1059ed8),
+ ULL(0x629a292a367cd507),
+ ULL(0x9159015a3070dd17),
+ ULL(0x152fecd8f70e5939),
+ ULL(0x67332667ffc00b31),
+ ULL(0x8eb44a8768581511),
+ ULL(0xdb0c2e0d64f98fa7),
+ ULL(0x47b5481dbefa4fa4)
+};
+
+/* Initial hash value H for SHA-512 */
+const static sha2_word64 sha512_initial_hash_value[8] = {
+ ULL(0x6a09e667f3bcc908),
+ ULL(0xbb67ae8584caa73b),
+ ULL(0x3c6ef372fe94f82b),
+ ULL(0xa54ff53a5f1d36f1),
+ ULL(0x510e527fade682d1),
+ ULL(0x9b05688c2b3e6c1f),
+ ULL(0x1f83d9abfb41bd6b),
+ ULL(0x5be0cd19137e2179)
+};
+
+
+/*** SHA-256: *********************************************************/
+void SHA256_Init(SHA256_CTX* context) {
+ if (context == (SHA256_CTX*)0) {
+ return;
+ }
+ MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH);
+ context->bitcount = 0;
+}
+
+#ifdef SHA2_UNROLL_TRANSFORM
+
+/* Unrolled SHA-256 round macros: */
+
+#ifndef WORDS_BIGENDIAN
+
+#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
+ REVERSE32(*data++, W256[j]); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
+ K256[j] + W256[j]; \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+
+#else
+
+#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
+ K256[j] + (W256[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+#endif
+
+#define ROUND256(a,b,c,d,e,f,g,h) \
+ s0 = W256[(j+1)&0x0f]; \
+ s0 = sigma0_256(s0); \
+ s1 = W256[(j+14)&0x0f]; \
+ s1 = sigma1_256(s1); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \
+ (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+ sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word32 T1, *W256;
+ int j;
+
+ W256 = (sha2_word32*)context->buffer;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+ /* Rounds 0 to 15 (unrolled): */
+ ROUND256_0_TO_15(a,b,c,d,e,f,g,h);
+ ROUND256_0_TO_15(h,a,b,c,d,e,f,g);
+ ROUND256_0_TO_15(g,h,a,b,c,d,e,f);
+ ROUND256_0_TO_15(f,g,h,a,b,c,d,e);
+ ROUND256_0_TO_15(e,f,g,h,a,b,c,d);
+ ROUND256_0_TO_15(d,e,f,g,h,a,b,c);
+ ROUND256_0_TO_15(c,d,e,f,g,h,a,b);
+ ROUND256_0_TO_15(b,c,d,e,f,g,h,a);
+ } while (j < 16);
+
+ /* Now for the remaining rounds to 64: */
+ do {
+ ROUND256(a,b,c,d,e,f,g,h);
+ ROUND256(h,a,b,c,d,e,f,g);
+ ROUND256(g,h,a,b,c,d,e,f);
+ ROUND256(f,g,h,a,b,c,d,e);
+ ROUND256(e,f,g,h,a,b,c,d);
+ ROUND256(d,e,f,g,h,a,b,c);
+ ROUND256(c,d,e,f,g,h,a,b);
+ ROUND256(b,c,d,e,f,g,h,a);
+ } while (j < 64);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = 0;
+}
+
+#else /* SHA2_UNROLL_TRANSFORM */
+
+void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+ sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word32 T1, T2, *W256;
+ int j;
+
+ W256 = (sha2_word32*)context->buffer;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+#ifndef WORDS_BIGENDIAN
+ /* Copy data while converting to host byte order */
+ REVERSE32(*data++,W256[j]);
+ /* Apply the SHA-256 compression function to update a..h */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j];
+#else
+ /* Apply the SHA-256 compression function to update a..h with copy */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++);
+#endif
+ T2 = Sigma0_256(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 16);
+
+ do {
+ /* Part of the message block expansion: */
+ s0 = W256[(j+1)&0x0f];
+ s0 = sigma0_256(s0);
+ s1 = W256[(j+14)&0x0f];
+ s1 = sigma1_256(s1);
+
+ /* Apply the SHA-256 compression function to update a..h */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] +
+ (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0);
+ T2 = Sigma0_256(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 64);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = T2 = 0;
+}
+
+#endif /* SHA2_UNROLL_TRANSFORM */
+
+void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
+ unsigned int freespace, usedspace;
+
+ if (len == 0) {
+ /* Calling with no data is valid - we do nothing */
+ return;
+ }
+
+ /* Sanity check: */
+ assert(context != NULL && data != NULL);
+
+ usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
+ if (usedspace > 0) {
+ /* Calculate how much free space is available in the buffer */
+ freespace = SHA256_BLOCK_LENGTH - usedspace;
+
+ if (len >= freespace) {
+ /* Fill the buffer completely and process it */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace);
+ context->bitcount += freespace << 3;
+ len -= freespace;
+ data += freespace;
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+ } else {
+ /* The buffer is not yet full */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
+ context->bitcount += len << 3;
+ /* Clean up: */
+ usedspace = freespace = 0;
+ return;
+ }
+ }
+ while (len >= SHA256_BLOCK_LENGTH) {
+ /* Process as many complete blocks as we can */
+ SHA256_Transform(context, (const sha2_word32*)data);
+ context->bitcount += SHA256_BLOCK_LENGTH << 3;
+ len -= SHA256_BLOCK_LENGTH;
+ data += SHA256_BLOCK_LENGTH;
+ }
+ if (len > 0) {
+ /* There's left-overs, so save 'em */
+ MEMCPY_BCOPY(context->buffer, data, len);
+ context->bitcount += len << 3;
+ }
+ /* Clean up: */
+ usedspace = freespace = 0;
+}
+
+void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+ sha2_word32 *d = (sha2_word32*)digest;
+ unsigned int usedspace;
+
+ /* Sanity check: */
+ assert(context != NULL);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH;
+#ifndef WORDS_BIGENDIAN
+ /* Convert FROM host byte order */
+ REVERSE64(context->bitcount,context->bitcount);
+#endif
+ if (usedspace > 0) {
+ /* Begin padding with a 1 bit: */
+ context->buffer[usedspace++] = 0x80;
+
+ if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace);
+ } else {
+ if (usedspace < SHA256_BLOCK_LENGTH) {
+ MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace);
+ }
+ /* Do second-to-last transform: */
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+
+ /* And set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
+ }
+ } else {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
+
+ /* Begin padding with a 1 bit: */
+ *context->buffer = 0x80;
+ }
+ /* Set the bit count: */
+ *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+
+ /* Final transform: */
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+
+#ifndef WORDS_BIGENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 8; j++) {
+ REVERSE32(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Clean up state data: */
+ MEMSET_BZERO(context, sizeof(SHA256_CTX));
+ usedspace = 0;
+}
+
+int SHA256_Equal(SHA256_CTX* pctx1, SHA256_CTX* pctx2) {
+ return pctx1->bitcount == pctx2->bitcount
+ && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
+ && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
+}
+
+/*** SHA-512: *********************************************************/
+void SHA512_Init(SHA512_CTX* context) {
+ if (context == (SHA512_CTX*)0) {
+ return;
+ }
+ MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH);
+ context->bitcount[0] = context->bitcount[1] = 0;
+}
+
+#ifdef SHA2_UNROLL_TRANSFORM
+
+/* Unrolled SHA-512 round macros: */
+#ifndef WORDS_BIGENDIAN
+
+#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
+ REVERSE64(*data++, W512[j]); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
+ K512[j] + W512[j]; \
+ (d) += T1, \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \
+ j++
+
+
+#else
+
+#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
+ K512[j] + (W512[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
+
+#endif
+
+#define ROUND512(a,b,c,d,e,f,g,h) \
+ s0 = W512[(j+1)&0x0f]; \
+ s0 = sigma0_512(s0); \
+ s1 = W512[(j+14)&0x0f]; \
+ s1 = sigma1_512(s1); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
+ (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
+
+void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+ sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word64 T1, *W512 = (sha2_word64*)context->buffer;
+ int j;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+ ROUND512_0_TO_15(a,b,c,d,e,f,g,h);
+ ROUND512_0_TO_15(h,a,b,c,d,e,f,g);
+ ROUND512_0_TO_15(g,h,a,b,c,d,e,f);
+ ROUND512_0_TO_15(f,g,h,a,b,c,d,e);
+ ROUND512_0_TO_15(e,f,g,h,a,b,c,d);
+ ROUND512_0_TO_15(d,e,f,g,h,a,b,c);
+ ROUND512_0_TO_15(c,d,e,f,g,h,a,b);
+ ROUND512_0_TO_15(b,c,d,e,f,g,h,a);
+ } while (j < 16);
+
+ /* Now for the remaining rounds up to 79: */
+ do {
+ ROUND512(a,b,c,d,e,f,g,h);
+ ROUND512(h,a,b,c,d,e,f,g);
+ ROUND512(g,h,a,b,c,d,e,f);
+ ROUND512(f,g,h,a,b,c,d,e);
+ ROUND512(e,f,g,h,a,b,c,d);
+ ROUND512(d,e,f,g,h,a,b,c);
+ ROUND512(c,d,e,f,g,h,a,b);
+ ROUND512(b,c,d,e,f,g,h,a);
+ } while (j < 80);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = 0;
+}
+
+#else /* SHA2_UNROLL_TRANSFORM */
+
+void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+ sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer;
+ int j;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+#ifndef WORDS_BIGENDIAN
+ /* Convert TO host byte order */
+ REVERSE64(*data++, W512[j]);
+ /* Apply the SHA-512 compression function to update a..h */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j];
+#else
+ /* Apply the SHA-512 compression function to update a..h with copy */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++);
+#endif
+ T2 = Sigma0_512(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 16);
+
+ do {
+ /* Part of the message block expansion: */
+ s0 = W512[(j+1)&0x0f];
+ s0 = sigma0_512(s0);
+ s1 = W512[(j+14)&0x0f];
+ s1 = sigma1_512(s1);
+
+ /* Apply the SHA-512 compression function to update a..h */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] +
+ (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0);
+ T2 = Sigma0_512(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 80);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = T2 = 0;
+}
+
+#endif /* SHA2_UNROLL_TRANSFORM */
+
+void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
+ unsigned int freespace, usedspace;
+
+ if (len == 0) {
+ /* Calling with no data is valid - we do nothing */
+ return;
+ }
+
+ /* Sanity check: */
+ assert(context != NULL && data != NULL);
+
+ usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
+ if (usedspace > 0) {
+ /* Calculate how much free space is available in the buffer */
+ freespace = SHA512_BLOCK_LENGTH - usedspace;
+
+ if (len >= freespace) {
+ /* Fill the buffer completely and process it */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace);
+ ADDINC128(context->bitcount, freespace << 3);
+ len -= freespace;
+ data += freespace;
+ SHA512_Transform(context, (const sha2_word64*)context->buffer);
+ } else {
+ /* The buffer is not yet full */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
+ ADDINC128(context->bitcount, len << 3);
+ /* Clean up: */
+ usedspace = freespace = 0;
+ return;
+ }
+ }
+ while (len >= SHA512_BLOCK_LENGTH) {
+ /* Process as many complete blocks as we can */
+ SHA512_Transform(context, (const sha2_word64*)data);
+ ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
+ len -= SHA512_BLOCK_LENGTH;
+ data += SHA512_BLOCK_LENGTH;
+ }
+ if (len > 0) {
+ /* There's left-overs, so save 'em */
+ MEMCPY_BCOPY(context->buffer, data, len);
+ ADDINC128(context->bitcount, len << 3);
+ }
+ /* Clean up: */
+ usedspace = freespace = 0;
+}
+
+void SHA512_Last(SHA512_CTX* context) {
+ unsigned int usedspace;
+
+ usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
+#ifndef WORDS_BIGENDIAN
+ /* Convert FROM host byte order */
+ REVERSE64(context->bitcount[0],context->bitcount[0]);
+ REVERSE64(context->bitcount[1],context->bitcount[1]);
+#endif
+ if (usedspace > 0) {
+ /* Begin padding with a 1 bit: */
+ context->buffer[usedspace++] = 0x80;
+
+ if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace);
+ } else {
+ if (usedspace < SHA512_BLOCK_LENGTH) {
+ MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace);
+ }
+ /* Do second-to-last transform: */
+ SHA512_Transform(context, (const sha2_word64*)context->buffer);
+
+ /* And set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2);
+ }
+ } else {
+ /* Prepare for final transform: */
+ MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH);
+
+ /* Begin padding with a 1 bit: */
+ *context->buffer = 0x80;
+ }
+ /* Store the length of input data (in bits): */
+ *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
+ *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
+
+ /* Final transform: */
+ SHA512_Transform(context, (const sha2_word64*)context->buffer);
+}
+
+void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+ sha2_word64 *d = (sha2_word64*)digest;
+
+ /* Sanity check: */
+ assert(context != NULL);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ SHA512_Last(context);
+
+ /* Save the hash data for output: */
+#ifndef WORDS_BIGENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 8; j++) {
+ REVERSE64(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Zero out state data */
+ MEMSET_BZERO(context, sizeof(SHA512_CTX));
+}
+
+int SHA512_Equal(SHA512_CTX* pctx1, SHA512_CTX* pctx2) {
+ return memcmp(pctx1->bitcount, pctx2->bitcount, sizeof(pctx1->bitcount)) == 0
+ && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
+ && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
+}
+
+/*** SHA-384: *********************************************************/
+void SHA384_Init(SHA384_CTX* context) {
+ if (context == (SHA384_CTX*)0) {
+ return;
+ }
+ MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH);
+ context->bitcount[0] = context->bitcount[1] = 0;
+}
+
+void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
+ SHA512_Update((SHA512_CTX*)context, data, len);
+}
+
+void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
+ sha2_word64 *d = (sha2_word64*)digest;
+
+ /* Sanity check: */
+ assert(context != NULL);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ SHA512_Last((SHA512_CTX*)context);
+
+ /* Save the hash data for output: */
+#ifndef WORDS_BIGENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 6; j++) {
+ REVERSE64(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Zero out state data */
+ MEMSET_BZERO(context, sizeof(SHA384_CTX));
+}
+
+int SHA384_Equal(SHA384_CTX* pctx1, SHA384_CTX* pctx2) {
+ return memcmp(pctx1->bitcount, pctx2->bitcount, sizeof(pctx1->bitcount)) == 0
+ && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
+ && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
+}
diff --git a/ext/digest/sha2/sha2.h b/ext/digest/sha2/sha2.h
new file mode 100644
index 0000000000..4689ad93ce
--- /dev/null
+++ b/ext/digest/sha2/sha2.h
@@ -0,0 +1,133 @@
+/*
+ * sha2.h
+ *
+ * Version 1.0.0beta1
+ *
+ * Written by Aaron D. Gifford <me@aarongifford.com>
+ *
+ * Copyright 2000 Aaron D. Gifford. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/* $RoughId: sha2.h,v 1.3 2002/02/24 08:14:32 knu Exp $ */
+/* $Id$ */
+
+#ifndef __SHA2_H__
+#define __SHA2_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "defs.h"
+
+
+/*** SHA-256/384/512 Various Length Definitions ***********************/
+#define SHA256_BLOCK_LENGTH 64
+#define SHA256_DIGEST_LENGTH 32
+#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
+#define SHA384_BLOCK_LENGTH 128
+#define SHA384_DIGEST_LENGTH 48
+#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
+#define SHA512_BLOCK_LENGTH 128
+#define SHA512_DIGEST_LENGTH 64
+#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
+
+
+/*** SHA-256/384/512 Context Structures *******************************/
+
+typedef struct _SHA256_CTX {
+ uint32_t state[8];
+ uint64_t bitcount;
+ uint8_t buffer[SHA256_BLOCK_LENGTH];
+} SHA256_CTX;
+typedef struct _SHA512_CTX {
+ uint64_t state[8];
+ uint64_t bitcount[2];
+ uint8_t buffer[SHA512_BLOCK_LENGTH];
+} SHA512_CTX;
+
+typedef SHA512_CTX SHA384_CTX;
+
+
+#ifdef RUBY
+#define SHA256_Init rb_Digest_SHA256_Init
+#define SHA256_Update rb_Digest_SHA256_Update
+#define SHA256_Final rb_Digest_SHA256_Final
+#define SHA256_End rb_Digest_SHA256_End
+#define SHA256_Data rb_Digest_SHA256_Data
+#define SHA256_File rb_Digest_SHA256_File
+#define SHA256_Equal rb_Digest_SHA256_Equal
+
+#define SHA384_Init rb_Digest_SHA384_Init
+#define SHA384_Update rb_Digest_SHA384_Update
+#define SHA384_Final rb_Digest_SHA384_Final
+#define SHA384_End rb_Digest_SHA384_End
+#define SHA384_Data rb_Digest_SHA384_Data
+#define SHA384_File rb_Digest_SHA384_File
+#define SHA384_Equal rb_Digest_SHA384_Equal
+
+#define SHA512_Init rb_Digest_SHA512_Init
+#define SHA512_Update rb_Digest_SHA512_Update
+#define SHA512_Final rb_Digest_SHA512_Final
+#define SHA512_End rb_Digest_SHA512_End
+#define SHA512_Data rb_Digest_SHA512_Data
+#define SHA512_File rb_Digest_SHA512_File
+#define SHA512_Equal rb_Digest_SHA512_Equal
+#endif
+
+/*** SHA-256/384/512 Function Prototypes ******************************/
+void SHA256_Init _((SHA256_CTX *));
+void SHA256_Update _((SHA256_CTX*, const uint8_t*, size_t));
+void SHA256_Final _((uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*));
+char* SHA256_End _((SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]));
+char* SHA256_Data _((const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]));
+char *SHA256_File _((char *, char *));
+int SHA256_Equal _((SHA256_CTX*, SHA256_CTX*));
+
+void SHA384_Init _((SHA384_CTX*));
+void SHA384_Update _((SHA384_CTX*, const uint8_t*, size_t));
+void SHA384_Final _((uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*));
+char* SHA384_End _((SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]));
+char* SHA384_Data _((const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]));
+char *SHA384_File _((char *, char *));
+int SHA384_Equal _((SHA384_CTX*, SHA384_CTX*));
+
+void SHA512_Init _((SHA512_CTX*));
+void SHA512_Update _((SHA512_CTX*, const uint8_t*, size_t));
+void SHA512_Final _((uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*));
+char* SHA512_End _((SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]));
+char* SHA512_Data _((const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]));
+char *SHA512_File _((char *, char *));
+int SHA512_Equal _((SHA512_CTX*, SHA512_CTX*));
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __SHA2_H__ */
+
diff --git a/ext/digest/sha2/sha2hl.c b/ext/digest/sha2/sha2hl.c
new file mode 100644
index 0000000000..03fde538c3
--- /dev/null
+++ b/ext/digest/sha2/sha2hl.c
@@ -0,0 +1,252 @@
+/* $NetBSD: sha2hl.c,v 1.1 2001/03/12 09:08:40 agc Exp $ */
+/* $RoughId: sha2hl.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id$ */
+
+/*
+ * sha2hl.c
+ * This code includes some functions taken from sha2.c, hence the
+ * following licence reproduction.
+ *
+ * This code is not a verbatim copy, since some routines have been added,
+ * and some bugs have been fixed.
+ *
+ * Version 1.0.0beta1
+ *
+ * Written by Aaron D. Gifford <me@aarongifford.com>
+ *
+ * Copyright 2000 Aaron D. Gifford. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include "sha2.h"
+
+#ifndef lint
+/* __RCSID("$NetBSD: sha2hl.c,v 1.1 2001/03/12 09:08:40 agc Exp $"); */
+#endif /* not lint */
+
+/* #include "namespace.h" */
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#if defined(HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+/*
+ * Constant used by SHA256/384/512_End() functions for converting the
+ * digest to a readable hexadecimal character string:
+ */
+static const char sha2_hex_digits[] = "0123456789abcdef";
+
+char *
+SHA256_File(char *filename, char *buf)
+{
+ uint8_t buffer[BUFSIZ * 20];
+ SHA256_CTX ctx;
+ int fd, num, oerrno;
+
+ _DIAGASSERT(filename != NULL);
+ /* XXX: buf may be NULL ? */
+
+ SHA256_Init(&ctx);
+
+ if ((fd = open(filename, O_RDONLY)) < 0)
+ return (0);
+
+ while ((num = read(fd, buffer, sizeof(buffer))) > 0)
+ SHA256_Update(&ctx, buffer, (size_t) num);
+
+ oerrno = errno;
+ close(fd);
+ errno = oerrno;
+ return (num < 0 ? 0 : SHA256_End(&ctx, buf));
+}
+
+
+char *
+SHA256_End(SHA256_CTX *ctx, char buffer[])
+{
+ uint8_t digest[SHA256_DIGEST_LENGTH], *d = digest;
+ uint8_t *ret;
+ int i;
+
+ /* Sanity check: */
+ assert(ctx != NULL);
+
+ if ((ret = buffer) != NULL) {
+ SHA256_Final(digest, ctx);
+
+ for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char) 0;
+ } else {
+ (void) memset(ctx, 0, sizeof(SHA256_CTX));
+ }
+ (void) memset(digest, 0, SHA256_DIGEST_LENGTH);
+ return ret;
+}
+
+char *
+SHA256_Data(const uint8_t * data, size_t len, char *digest)
+{
+ SHA256_CTX ctx;
+
+ SHA256_Init(&ctx);
+ SHA256_Update(&ctx, data, len);
+ return SHA256_End(&ctx, digest);
+}
+
+char *
+SHA384_File(char *filename, char *buf)
+{
+ SHA384_CTX ctx;
+ uint8_t buffer[BUFSIZ * 20];
+ int fd, num, oerrno;
+
+ _DIAGASSERT(filename != NULL);
+ /* XXX: buf may be NULL ? */
+
+ SHA384_Init(&ctx);
+
+ if ((fd = open(filename, O_RDONLY)) < 0)
+ return (0);
+
+ while ((num = read(fd, buffer, sizeof(buffer))) > 0)
+ SHA384_Update(&ctx, buffer, (size_t) num);
+
+ oerrno = errno;
+ close(fd);
+ errno = oerrno;
+ return (num < 0 ? 0 : SHA384_End(&ctx, buf));
+}
+
+char *
+SHA384_End(SHA384_CTX * ctx, char buffer[])
+{
+ uint8_t digest[SHA384_DIGEST_LENGTH], *d = digest;
+ uint8_t *ret;
+ int i;
+
+ /* Sanity check: */
+ assert(ctx != NULL);
+
+ if ((ret = buffer) != NULL) {
+ SHA384_Final(digest, ctx);
+
+ for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char) 0;
+ } else {
+ (void) memset(ctx, 0, sizeof(SHA384_CTX));
+ }
+ (void) memset(digest, 0, SHA384_DIGEST_LENGTH);
+ return ret;
+}
+
+char *
+SHA384_Data(const uint8_t * data, size_t len, char *digest)
+{
+ SHA384_CTX ctx;
+
+ SHA384_Init(&ctx);
+ SHA384_Update(&ctx, data, len);
+ return SHA384_End(&ctx, digest);
+}
+
+char *
+SHA512_File(char *filename, char *buf)
+{
+ SHA512_CTX ctx;
+ uint8_t buffer[BUFSIZ * 20];
+ int fd, num, oerrno;
+
+ _DIAGASSERT(filename != NULL);
+ /* XXX: buf may be NULL ? */
+
+ SHA512_Init(&ctx);
+
+ if ((fd = open(filename, O_RDONLY)) < 0)
+ return (0);
+
+ while ((num = read(fd, buffer, sizeof(buffer))) > 0)
+ SHA512_Update(&ctx, buffer, (size_t) num);
+
+ oerrno = errno;
+ close(fd);
+ errno = oerrno;
+ return (num < 0 ? 0 : SHA512_End(&ctx, buf));
+}
+
+char *
+SHA512_End(SHA512_CTX * ctx, char buffer[])
+{
+ uint8_t digest[SHA512_DIGEST_LENGTH], *d = digest;
+ uint8_t *ret;
+ int i;
+
+ /* Sanity check: */
+ assert(ctx != NULL);
+
+ if ((ret = buffer) != NULL) {
+ SHA512_Final(digest, ctx);
+
+ for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char) 0;
+ } else {
+ (void) memset(ctx, 0, sizeof(SHA512_CTX));
+ }
+ (void) memset(digest, 0, SHA512_DIGEST_LENGTH);
+ return ret;
+}
+
+char *
+SHA512_Data(const uint8_t * data, size_t len, char *digest)
+{
+ SHA512_CTX ctx;
+
+ SHA512_Init(&ctx);
+ SHA512_Update(&ctx, data, len);
+ return SHA512_End(&ctx, digest);
+}
diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c
new file mode 100644
index 0000000000..4b14031811
--- /dev/null
+++ b/ext/digest/sha2/sha2init.c
@@ -0,0 +1,47 @@
+/* $RoughId: sha2init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
+/* $Id$ */
+
+#include "digest.h"
+#include "sha2.h"
+
+#define FOREACH_BITLEN(func) func(256) func(384) func(512)
+
+#define DEFINE_ALGO_METADATA(bitlen) \
+static algo_t sha##bitlen = { \
+ SHA##bitlen##_DIGEST_LENGTH, \
+ sizeof(SHA##bitlen##_CTX), \
+ (hash_init_func_t)SHA##bitlen##_Init, \
+ (hash_update_func_t)SHA##bitlen##_Update, \
+ (hash_end_func_t)SHA##bitlen##_End, \
+ (hash_final_func_t)SHA##bitlen##_Final, \
+ (hash_equal_func_t)SHA##bitlen##_Equal, \
+};
+
+FOREACH_BITLEN(DEFINE_ALGO_METADATA)
+
+void
+Init_sha2()
+{
+ VALUE mDigest, cDigest_Base;
+ ID id_metadata;
+
+#define DECLARE_ALGO_CLASS(bitlen) \
+ VALUE cDigest_SHA##bitlen;
+
+ FOREACH_BITLEN(DECLARE_ALGO_CLASS)
+
+ rb_require("digest.so");
+
+ id_metadata = rb_intern("metadata");
+
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+#define DEFINE_ALGO_CLASS(bitlen) \
+ cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
+\
+ rb_cvar_set(cDigest_SHA##bitlen, id_metadata, \
+ Data_Wrap_Struct(rb_cObject, 0, 0, &sha##bitlen), Qtrue);
+
+ FOREACH_BITLEN(DEFINE_ALGO_CLASS)
+}
diff --git a/ext/digest/test.sh b/ext/digest/test.sh
new file mode 100644
index 0000000000..6fb07d2177
--- /dev/null
+++ b/ext/digest/test.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# $RoughId: test.sh,v 1.5 2001/07/13 15:38:27 knu Exp $
+# $Id$
+
+RUBY=${RUBY:=ruby}
+MAKE=${MAKE:=make}
+CFLAGS=${CFLAGS:=-Wall}
+
+${RUBY} extconf.rb --with-cflags="${CFLAGS}"
+${MAKE} clean
+${MAKE}
+
+mkdir -p lib/digest
+
+for algo in md5 rmd160 sha1 sha2; do
+ args=--with-cflags="${CFLAGS}"
+
+ if [ $WITH_BUNDLED_ENGINES ]; then
+ args="$args --with-bundled-$algo"
+ fi
+
+ (cd $algo &&
+ ${RUBY} extconf.rb $args;
+ ${MAKE} clean;
+ ${MAKE})
+ ln -sf ../../$algo/$algo.so lib/digest/
+done
+
+${RUBY} -I. -I./lib test.rb
+
+rm lib/digest/*.so
+rmdir lib/digest
diff --git a/ext/dl/.cvsignore b/ext/dl/.cvsignore
new file mode 100644
index 0000000000..6d884b6cec
--- /dev/null
+++ b/ext/dl/.cvsignore
@@ -0,0 +1,8 @@
+Makefile
+mkmf.log
+dlconfig.h
+dlconfig.rb
+*.func
+*.o
+*~
+*.def
diff --git a/ext/dl/depend b/ext/dl/depend
new file mode 100644
index 0000000000..fba3df7a3d
--- /dev/null
+++ b/ext/dl/depend
@@ -0,0 +1,46 @@
+LDSHARED_TEST = $(LDSHARED) $(LDFLAGS) test/test.o -o test/libtest.so $(LOCAL_LIBS)
+
+libtest.so: test/libtest.so
+
+test/libtest.so: test/test.o $(srcdir)/test/libtest.def
+ $(RUBY) -rftools -e 'ARGV.each do|d|File.mkpath(File.dirname(d))end' $@
+ $(LDSHARED_TEST:dl.def=test/libtest.def)
+
+test/test.o: $(srcdir)/test/test.c
+ @$(RUBY) -rftools -e 'File.mkpath(*ARGV)' test
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/test/test.c -o $@
+
+test:: dl.so libtest.so force
+ $(RUBY) -I. -I$(srcdir)/lib $(srcdir)/test/test.rb
+
+force:
+
+.PHONY: force test
+
+allclean: distclean
+ @rm -f $(CLEANFILES) $(DISTCLEANFILES)
+
+$(OBJS): ./dlconfig.h
+
+sym.o: dl.h call.func
+
+dl.o: dl.h callback.func cbtable.func
+
+ptr.o: dl.h
+
+handle.o: dl.h
+
+call.func: $(srcdir)/mkcall.rb ./dlconfig.rb
+ @echo "Generating call.func"
+ @$(RUBY) $(srcdir)/mkcall.rb > $@
+
+callback.func: $(srcdir)/mkcallback.rb ./dlconfig.rb
+ @echo "Generating callback.func"
+ @$(RUBY) $(srcdir)/mkcallback.rb > $@
+
+cbtable.func: $(srcdir)/mkcbtable.rb ./dlconfig.rb
+ @echo "Generating cbtable.func"
+ @$(RUBY) $(srcdir)/mkcbtable.rb > $@
+
+debug:
+ $(MAKE) CPPFLAGS="$(CPPFLAGS) -DDEBUG"
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
new file mode 100644
index 0000000000..22abb754d2
--- /dev/null
+++ b/ext/dl/dl.c
@@ -0,0 +1,714 @@
+/*
+ * $Id$
+ */
+
+#include <ruby.h>
+#include <rubyio.h>
+#include <ctype.h>
+#include "dl.h"
+
+VALUE rb_mDL;
+VALUE rb_eDLError;
+VALUE rb_eDLTypeError;
+
+static VALUE DLFuncTable;
+static void *rb_dl_callback_table[CALLBACK_TYPES][MAX_CALLBACK];
+static ID id_call;
+
+static int
+rb_dl_scan_callback_args(long stack[], const char *proto,
+ int *argc, VALUE argv[])
+{
+ int i;
+ long *sp;
+ VALUE val;
+
+ sp = stack;
+ for (i=1; proto[i]; i++) {
+ switch (proto[i]) {
+ case 'C':
+ {
+ char v;
+ v = (char)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'H':
+ {
+ short v;
+ v = (short)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'I':
+ {
+ int v;
+ v = (int)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'L':
+ {
+ long v;
+ v = (long)(*sp);
+ sp++;
+ val = INT2NUM(v);
+ }
+ break;
+ case 'F':
+ {
+ float v;
+ memcpy(&v, sp, sizeof(float));
+ sp += sizeof(float)/sizeof(long);
+ val = rb_float_new(v);
+ }
+ break;
+ case 'D':
+ {
+ double v;
+ memcpy(&v, sp, sizeof(double));
+ sp += sizeof(double)/sizeof(long);
+ val = rb_float_new(v);
+ }
+ break;
+ case 'P':
+ {
+ void *v;
+ memcpy(&v, sp, sizeof(void*));
+ sp++;
+ val = rb_dlptr_new(v, 0, 0);
+ }
+ break;
+ case 'S':
+ {
+ char *v;
+ memcpy(&v, sp, sizeof(void*));
+ sp++;
+ val = rb_tainted_str_new2(v);
+ }
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type `%c'", proto[i]);
+ break;
+ }
+ argv[i-1] = val;
+ }
+ *argc = (i - 1);
+
+ return (*argc);
+}
+
+#include "callback.func"
+
+static void
+init_dl_func_table(){
+#include "cbtable.func"
+}
+
+void *
+dlmalloc(size_t size)
+{
+ DEBUG_CODE2({
+ void *ptr;
+
+ printf("dlmalloc(%d)",size);
+ ptr = xmalloc(size);
+ printf(":0x%x\n",ptr);
+ return ptr;
+ },
+ {
+ return xmalloc(size);
+ });
+}
+
+void *
+dlrealloc(void *ptr, size_t size)
+{
+ DEBUG_CODE({
+ printf("dlrealloc(0x%x,%d)\n",ptr,size);
+ });
+ return xrealloc(ptr, size);
+}
+
+void
+dlfree(void *ptr)
+{
+ DEBUG_CODE({
+ printf("dlfree(0x%x)\n",ptr);
+ });
+ xfree(ptr);
+}
+
+char*
+dlstrdup(const char *str)
+{
+ char *newstr;
+
+ newstr = (char*)dlmalloc(strlen(str));
+ strcpy(newstr,str);
+
+ return newstr;
+}
+
+size_t
+dlsizeof(const char *cstr)
+{
+ size_t size;
+ int i, len, n, dlen;
+ char *d;
+
+ len = strlen(cstr);
+ size = 0;
+ for (i=0; i<len; i++) {
+ n = 1;
+ if (isdigit(cstr[i+1])) {
+ dlen = 1;
+ while (isdigit(cstr[i+dlen])) { dlen ++; };
+ dlen --;
+ d = ALLOCA_N(char, dlen + 1);
+ strncpy(d, cstr + i + 1, dlen);
+ d[dlen] = '\0';
+ n = atoi(d);
+ }
+ else{
+ dlen = 0;
+ }
+
+ switch (cstr[i]) {
+ case 'I':
+ DLALIGN(0,size,INT_ALIGN);
+ case 'i':
+ size += sizeof(int) * n;
+ break;
+ case 'L':
+ DLALIGN(0,size,LONG_ALIGN);
+ case 'l':
+ size += sizeof(long) * n;
+ break;
+ case 'F':
+ DLALIGN(0,size,FLOAT_ALIGN);
+ case 'f':
+ size += sizeof(float) * n;
+ break;
+ case 'D':
+ DLALIGN(0,size,DOUBLE_ALIGN);
+ case 'd':
+ size += sizeof(double) * n;
+ break;
+ case 'C':
+ case 'c':
+ size += sizeof(char) * n;
+ break;
+ case 'H':
+ DLALIGN(0,size,SHORT_ALIGN);
+ case 'h':
+ size += sizeof(short) * n;
+ break;
+ case 'P':
+ case 'S':
+ DLALIGN(0,size,VOIDP_ALIGN);
+ case 'p':
+ case 's':
+ size += sizeof(void*) * n;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type '%c'", cstr[i]);
+ break;
+ }
+ i += dlen;
+ }
+
+ return size;
+}
+
+static float *
+c_farray(VALUE v, long *size)
+{
+ int i, len;
+ float *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(float) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FLOAT:
+ ary[i] = (float)(RFLOAT(e)->value);
+ break;
+ case T_NIL:
+ ary[i] = 0.0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static double *
+c_darray(VALUE v, long *size)
+{
+ int i, len;
+ double *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(double) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FLOAT:
+ ary[i] = (double)(RFLOAT(e)->value);
+ break;
+ case T_NIL:
+ ary[i] = 0.0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static long *
+c_larray(VALUE v, long *size)
+{
+ int i, len;
+ long *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(long) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (long)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static int *
+c_iarray(VALUE v, long *size)
+{
+ int i, len;
+ int *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(int) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (int)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static short *
+c_harray(VALUE v, long *size)
+{
+ int i, len;
+ short *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(short) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (short)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static char *
+c_carray(VALUE v, long *size)
+{
+ int i, len;
+ char *ary;
+ VALUE e;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(char) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ ary[i] = (char)(NUM2INT(e));
+ break;
+ case T_NIL:
+ ary[i] = 0;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ break;
+ }
+ }
+
+ return ary;
+}
+
+static void *
+c_parray(VALUE v, long *size)
+{
+ int i, len;
+ void **ary;
+ VALUE e, tmp;
+
+ len = RARRAY(v)->len;
+ *size = sizeof(void*) * len;
+ ary = dlmalloc(*size);
+ for (i=0; i < len; i++) {
+ e = rb_ary_entry(v, i);
+ switch (TYPE(e)) {
+ default:
+ tmp = rb_check_string_type(e);
+ if (NIL_P(tmp)) {
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ }
+ e = tmp;
+ /* fall through */
+ case T_STRING:
+ rb_check_safe_str(e);
+ {
+ char *str, *src;
+ src = RSTRING(e)->ptr;
+ str = dlstrdup(src);
+ ary[i] = (void*)str;
+ }
+ break;
+ case T_NIL:
+ ary[i] = NULL;
+ break;
+ case T_DATA:
+ if (rb_obj_is_kind_of(e, rb_cDLPtrData)) {
+ struct ptr_data *pdata;
+ Data_Get_Struct(e, struct ptr_data, pdata);
+ ary[i] = (void*)(pdata->ptr);
+ }
+ else{
+ rb_raise(rb_eDLTypeError, "unexpected type of the element #%d", i);
+ }
+ break;
+ }
+ }
+
+ return ary;
+}
+
+void *
+rb_ary2cary(char t, VALUE v, long *size)
+{
+ int len;
+ VALUE val0;
+
+ val0 = rb_check_array_type(v);
+ if(NIL_P(TYPE(val0))) {
+ rb_raise(rb_eDLTypeError, "an array is expected.");
+ }
+ v = val0;
+
+ len = RARRAY(v)->len;
+ if (len == 0) {
+ return NULL;
+ }
+
+ if (!size) {
+ size = ALLOCA_N(long,1);
+ }
+
+ val0 = rb_ary_entry(v,0);
+ switch (TYPE(val0)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ switch (t) {
+ case 'C': case 'c':
+ return (void*)c_carray(v,size);
+ case 'H': case 'h':
+ return (void*)c_harray(v,size);
+ case 'I': case 'i':
+ return (void*)c_iarray(v,size);
+ case 'L': case 'l': case 0:
+ return (void*)c_larray(v,size);
+ default:
+ rb_raise(rb_eDLTypeError, "type mismatch");
+ }
+ case T_STRING:
+ return (void*)c_parray(v,size);
+ case T_FLOAT:
+ switch (t) {
+ case 'F': case 'f':
+ return (void*)c_farray(v,size);
+ case 'D': case 'd': case 0:
+ return (void*)c_darray(v,size);
+ }
+ rb_raise(rb_eDLTypeError, "type mismatch");
+ case T_DATA:
+ if (rb_obj_is_kind_of(val0, rb_cDLPtrData)) {
+ return (void*)c_parray(v,size);
+ }
+ rb_raise(rb_eDLTypeError, "type mismatch");
+ case T_NIL:
+ return (void*)c_parray(v, size);
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type");
+ }
+}
+
+VALUE
+rb_str_to_ptr(VALUE self)
+{
+ char *ptr;
+ int len;
+
+ len = RSTRING(self)->len;
+ ptr = (char*)dlmalloc(len + 1);
+ memcpy(ptr, RSTRING(self)->ptr, len);
+ ptr[len] = '\0';
+ return rb_dlptr_new((void*)ptr,len,dlfree);
+}
+
+VALUE
+rb_ary_to_ptr(int argc, VALUE argv[], VALUE self)
+{
+ void *ptr;
+ VALUE t;
+ long size;
+
+ switch (rb_scan_args(argc, argv, "01", &t)) {
+ case 1:
+ ptr = rb_ary2cary(StringValuePtr(t)[0], self, &size);
+ break;
+ case 0:
+ ptr = rb_ary2cary(0, self, &size);
+ break;
+ }
+ return ptr ? rb_dlptr_new(ptr, size, dlfree) : Qnil;
+}
+
+VALUE
+rb_io_to_ptr(VALUE self)
+{
+ OpenFile *fptr;
+ FILE *fp;
+
+ GetOpenFile(self, fptr);
+ fp = fptr->f;
+
+ return fp ? rb_dlptr_new(fp, sizeof(FILE), 0) : Qnil;
+}
+
+VALUE
+rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
+{
+ rb_secure(4);
+ return rb_class_new_instance(argc, argv, rb_cDLHandle);
+}
+
+VALUE
+rb_dl_malloc(VALUE self, VALUE size)
+{
+ rb_secure(4);
+ return rb_dlptr_malloc(DLNUM2LONG(size), dlfree);
+}
+
+VALUE
+rb_dl_strdup(VALUE self, VALUE str)
+{
+ SafeStringValue(str);
+ return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree);
+}
+
+static VALUE
+rb_dl_sizeof(VALUE self, VALUE str)
+{
+ return INT2NUM(dlsizeof(StringValuePtr(str)));
+}
+
+static VALUE
+rb_dl_callback(int argc, VALUE argv[], VALUE self)
+{
+ VALUE type, proc;
+ int rettype, entry, i;
+ char fname[127];
+
+ rb_secure(4);
+ proc = Qnil;
+ switch (rb_scan_args(argc, argv, "11", &type, &proc)) {
+ case 1:
+ if (rb_block_given_p()) {
+ proc = rb_block_proc();
+ }
+ else{
+ proc = Qnil;
+ }
+ default:
+ break;
+ }
+
+ StringValue(type);
+ switch (RSTRING(type)->ptr[0]) {
+ case '0':
+ rettype = 0x00;
+ break;
+ case 'C':
+ rettype = 0x01;
+ break;
+ case 'H':
+ rettype = 0x02;
+ break;
+ case 'I':
+ rettype = 0x03;
+ break;
+ case 'L':
+ rettype = 0x04;
+ break;
+ case 'F':
+ rettype = 0x05;
+ break;
+ case 'D':
+ rettype = 0x06;
+ break;
+ case 'P':
+ rettype = 0x07;
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type `%c'", RSTRING(type)->ptr[0]);
+ }
+
+ entry = -1;
+ for (i=0; i < MAX_CALLBACK; i++) {
+ if (rb_hash_aref(DLFuncTable, rb_assoc_new(INT2NUM(rettype), INT2NUM(i))) == Qnil) {
+ entry = i;
+ break;
+ }
+ }
+ if (entry < 0) {
+ rb_raise(rb_eDLError, "too many callbacks are defined.");
+ }
+
+ rb_hash_aset(DLFuncTable,
+ rb_assoc_new(INT2NUM(rettype),INT2NUM(entry)),
+ rb_assoc_new(type,proc));
+ sprintf(fname, "rb_dl_callback_func_%d_%d", rettype, entry);
+ return rb_dlsym_new((void (*)())rb_dl_callback_table[rettype][entry],
+ fname, RSTRING(type)->ptr);
+}
+
+static VALUE
+rb_dl_remove_callback(VALUE mod, VALUE sym)
+{
+ freefunc_t f;
+ int i, j;
+
+ rb_secure(4);
+ f = rb_dlsym2csym(sym);
+ for (i=0; i < CALLBACK_TYPES; i++) {
+ for (j=0; j < MAX_CALLBACK; j++) {
+ if (rb_dl_callback_table[i][j] == f) {
+ rb_hash_aset(DLFuncTable, rb_assoc_new(INT2NUM(i),INT2NUM(j)),Qnil);
+ break;
+ }
+ }
+ }
+ return Qnil;
+}
+
+void
+Init_dl()
+{
+ void Init_dlptr();
+ void Init_dlsym();
+ void Init_dlhandle();
+
+ id_call = rb_intern("call");
+
+ rb_mDL = rb_define_module("DL");
+
+ rb_eDLError = rb_define_class_under(rb_mDL, "DLError", rb_eStandardError);
+ rb_eDLTypeError = rb_define_class_under(rb_mDL, "DLTypeError", rb_eDLError);
+
+ DLFuncTable = rb_hash_new();
+ init_dl_func_table();
+ rb_define_const(rb_mDL, "FuncTable", DLFuncTable);
+
+ rb_define_const(rb_mDL, "RTLD_GLOBAL", INT2NUM(RTLD_GLOBAL));
+ rb_define_const(rb_mDL, "RTLD_LAZY", INT2NUM(RTLD_LAZY));
+ rb_define_const(rb_mDL, "RTLD_NOW", INT2NUM(RTLD_NOW));
+
+ rb_define_const(rb_mDL, "ALIGN_INT", INT2NUM(ALIGN_INT));
+ rb_define_const(rb_mDL, "ALIGN_LONG", INT2NUM(ALIGN_LONG));
+ rb_define_const(rb_mDL, "ALIGN_FLOAT", INT2NUM(ALIGN_FLOAT));
+ rb_define_const(rb_mDL, "ALIGN_SHORT", INT2NUM(ALIGN_SHORT));
+ rb_define_const(rb_mDL, "ALIGN_DOUBLE",INT2NUM(ALIGN_DOUBLE));
+ rb_define_const(rb_mDL, "ALIGN_VOIDP", INT2NUM(ALIGN_VOIDP));
+
+ rb_define_const(rb_mDL, "MAX_ARG", INT2NUM(MAX_ARG));
+ rb_define_const(rb_mDL, "DLSTACK", rb_tainted_str_new2(DLSTACK_METHOD));
+
+ rb_define_module_function(rb_mDL, "dlopen", rb_dl_dlopen, -1);
+ rb_define_module_function(rb_mDL, "callback", rb_dl_callback, -1);
+ rb_define_module_function(rb_mDL, "define_callback", rb_dl_callback, -1);
+ rb_define_module_function(rb_mDL, "remove_callback", rb_dl_remove_callback, 1);
+ rb_define_module_function(rb_mDL, "malloc", rb_dl_malloc, 1);
+ rb_define_module_function(rb_mDL, "strdup", rb_dl_strdup, 1);
+ rb_define_module_function(rb_mDL, "sizeof", rb_dl_sizeof, 1);
+
+ Init_dlptr();
+ Init_dlsym();
+ Init_dlhandle();
+
+ rb_define_const(rb_mDL, "FREE", rb_dlsym_new(dlfree, "free", "0P"));
+
+ rb_define_method(rb_cString, "to_ptr", rb_str_to_ptr, 0);
+ rb_define_method(rb_cArray, "to_ptr", rb_ary_to_ptr, -1);
+ rb_define_method(rb_cIO, "to_ptr", rb_io_to_ptr, 0);
+}
diff --git a/ext/dl/dl.def b/ext/dl/dl.def
new file mode 100644
index 0000000000..cdab4af90d
--- /dev/null
+++ b/ext/dl/dl.def
@@ -0,0 +1,59 @@
+EXPORTS
+Init_dl
+dlfree
+dlmalloc
+dlrealloc
+dlstrdup
+rb_ary_to_ptr
+rb_dl_dlopen
+rb_dl_malloc
+rb_dl_strdup
+rb_eDLError
+rb_eDLTypeError
+rb_io_to_ptr
+rb_mDL
+rb_str_to_ptr
+Init_dlhandle
+rb_cDLHandle
+rb_dlhandle_close
+rb_dlhandle_disable_close
+rb_dlhandle_enable_close
+rb_dlhandle_sym
+Init_dlptr
+rb_cDLPtrData
+rb_dlmem_each
+rb_dlptr2cptr
+rb_dlptr_malloc
+rb_dlptr_aref
+rb_dlptr_aset
+rb_dlptr_cmp
+rb_dlptr_define_data_type
+rb_dlptr_define_struct
+rb_dlptr_define_union
+rb_dlptr_eql
+rb_dlptr_free_get
+rb_dlptr_free_set
+rb_dlptr_get_data_type
+rb_dlptr_inspect
+rb_dlptr_minus
+rb_dlptr_new
+rb_dlptr_new2
+rb_dlptr_null_p
+rb_dlptr_plus
+rb_dlptr_ptr
+rb_dlptr_ref
+rb_dlptr_to_array
+rb_dlptr_to_i
+rb_dlptr_to_s
+rb_dlptr_to_str
+rb_mDLMemorySpace
+Init_dlsym
+rb_cDLSymbol
+rb_dlsym2csym
+rb_dlsym_call
+rb_dlsym_cproto
+rb_dlsym_inspect
+rb_dlsym_name
+rb_dlsym_new
+rb_dlsym_proto
+rb_dlsym_to_ptr
diff --git a/ext/dl/dl.h b/ext/dl/dl.h
new file mode 100644
index 0000000000..1faa316cf1
--- /dev/null
+++ b/ext/dl/dl.h
@@ -0,0 +1,313 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#ifndef RUBY_DL_H
+#define RUBY_DL_H
+
+#include <ruby.h>
+#include <dlconfig.h>
+
+#if defined(HAVE_DLFCN_H)
+# include <dlfcn.h>
+# /* some stranger systems may not define all of these */
+#ifndef RTLD_LAZY
+#define RTLD_LAZY 0
+#endif
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+#ifndef RTLD_NOW
+#define RTLD_NOW 0
+#endif
+#else
+# if defined(HAVE_WINDOWS_H)
+# include <windows.h>
+# define dlclose(ptr) FreeLibrary((HINSTANCE)ptr)
+# define dlopen(name,flag) ((void*)LoadLibrary(name))
+# define dlerror() "unknown error"
+# define dlsym(handle,name) ((void*)GetProcAddress(handle,name))
+# define RTLD_LAZY -1
+# define RTLD_NOW -1
+# define RTLD_GLOBAL -1
+# endif
+#endif
+
+#if !defined(StringValue)
+# define StringValue(v) if(TYPE(v) != T_STRING) v = rb_str_to_str(v)
+#endif
+#if !defined(StringValuePtr)
+# define StringValuePtr(v) RSTRING((TYPE(v) == T_STRING) ? (v) : rb_str_to_str(v))->ptr
+#endif
+
+#ifdef DEBUG
+#define DEBUG_CODE(b) {printf("DEBUG:%d\n",__LINE__);b;}
+#define DEBUG_CODE2(b1,b2) {printf("DEBUG:%d\n",__LINE__);b1;}
+#else
+#define DEBUG_CODE(b)
+#define DEBUG_CODE2(b1,b2) b2
+#endif
+
+#define VOID_DLTYPE 0x00
+#define CHAR_DLTYPE 0x01
+#define SHORT_DLTYPE 0x02
+#define INT_DLTYPE 0x03
+#define LONG_DLTYPE 0x04
+#define FLOAT_DLTYPE 0x05
+#define DOUBLE_DLTYPE 0x06
+#define VOIDP_DLTYPE 0x07
+
+#define ARG_TYPE(x,i) (((x) & (0x07 << ((i)*3))) >> ((i)*3))
+#define PUSH_ARG(x,t) do{x <<= 3; x |= t;}while(0)
+#define PUSH_0(x) PUSH_ARG(x,VOID_DLTYPE)
+
+#if SIZEOF_INT == SIZEOF_LONG
+# define PUSH_I(x) PUSH_ARG(x,LONG_DLTYPE)
+# define ANY2I(x) x.l
+# define DLINT(x) (long)x
+#else
+# define PUSH_I(x) PUSH_ARG(x,INT_DLTYPE)
+# define ANY2I(x) x.i
+# define DLINT(x) (int)x
+#endif
+#define PUSH_L(x) PUSH_ARG(x,LONG_DLTYPE)
+#define ANY2L(x) x.l
+#define DLLONG(x) (long)x
+
+#if defined(WITH_TYPE_FLOAT)
+# if SIZEOF_FLOAT == SIZEOF_DOUBLE
+# define PUSH_F(x) PUSH_ARG(x,DOUBLE_DLTYPE)
+# define ANY2F(x) (x.d)
+# define DLFLOAT(x) ((double)x)
+# else
+# define PUSH_F(x) PUSH_ARG(x,FLOAT_DLTYPE)
+# define ANY2F(x) (x.f)
+# define DLFLOAT(x) ((float)x)
+# endif
+#else
+# define PUSH_F(x) PUSH_ARG(x,DOUBLE_DLTYPE)
+# define ANY2F(x) (x.d)
+# define DLFLOAT(x) ((double)x)
+#endif
+#define PUSH_D(x) PUSH_ARG(x,DOUBLE_DLTYPE)
+#define ANY2D(x) (x.d)
+#define DLDOUBLE(x) ((double)x)
+
+#if SIZEOF_INT == SIZEOF_VOIDP && SIZEOF_INT != SIZEOF_LONG
+# define PUSH_P(x) PUSH_ARG(x,INT_DLTYPE)
+# define ANY2P(x) (x.i)
+# define DLVOIDP(x) ((int)x)
+#elif SIZEOF_LONG == SIZEOF_VOIDP
+# define PUSH_P(x) PUSH_ARG(x,LONG_DLTYPE)
+# define ANY2P(x) (x.l)
+# define DLVOIDP(x) ((long)x)
+#else
+# define PUSH_P(x) PUSH_ARG(x,VOIDP_DLTYPE)
+# define ANY2P(x) (x.p)
+# define DLVOIDP(x) ((void*)p)
+#endif
+
+#if defined(WITH_TYPE_CHAR)
+# define PUSH_C(x) PUSH_ARG(x,CHAR_DLTYPE)
+# define ANY2C(x) (x.c)
+# define DLCHAR(x) ((char)x)
+#else
+# define PUSH_C(x) PUSH_I(x)
+# define ANY2C(x) ANY2I(x)
+# define DLCHAR(x) DLINT(x)
+#endif
+
+#if defined(WITH_TYPE_SHORT)
+# define PUSH_H(x) PUSH_ARG(x,SHORT_DLTYPE)
+# define ANY2H(x) (x.h)
+# define DLSHORT(x) ((short)x)
+#else
+# define PUSH_H(x) PUSH_I(x)
+# define ANY2H(x) ANY2I(x)
+# define DLSHORT(x) DLINT(x)
+#endif
+
+#define PUSH_S(x) PUSH_P(x)
+#define ANY2S(x) ANY2P(x)
+#define DLSTR(x) DLVOIDP(x)
+
+#define CBPUSH_0(x) PUSH_0(x)
+#define CBPUSH_C(x) PUSH_C(x)
+#define CBPUSH_H(x) PUSH_H(x)
+#define CBPUSH_I(x) PUSH_I(x)
+#define CBPUSH_L(x) PUSH_L(x)
+#define CBPUSH_F(x) PUSH_F(x)
+#define CBPUSH_D(x) PUSH_D(x)
+#if defined(WITH_CBTYPE_VOIDP)
+# define CBPUSH_P(x) PUSH_ARG(x,VOIDP_DLTYPE)
+#else
+# define CBPUSH_P(x) PUSH_P(x)
+#endif
+
+
+#if defined(USE_INLINE_ASM)
+# if defined(__i386__) && defined(__GNUC__)
+# define DLSTACK
+# define DLSTACK_METHOD "asm"
+# define DLSTACK_REVERSE
+# define DLSTACK_PROTO
+# define DLSTACK_ARGS
+# define DLSTACK_START(sym)
+# define DLSTACK_END(sym)
+# define DLSTACK_PUSH_C(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_H(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_I(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_L(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_P(x) asm volatile ("pushl %0" :: "g" (x));
+# define DLSTACK_PUSH_F(x) asm volatile ("flds %0"::"g"(x));\
+ asm volatile ("subl $4,%esp");\
+ asm volatile ("fstps (%esp)");
+# define DLSTACK_PUSH_D(x) asm volatile ("fldl %0"::"g"(x));\
+ asm volatile ("subl $8,%esp");\
+ asm volatile ("fstpl (%esp)")
+# else
+# error --with-asm is not supported on this machine
+# endif
+#elif defined(USE_DLSTACK)
+# define DLSTACK
+# define DLSTACK_GUARD
+# define DLSTACK_METHOD "dl"
+# define DLSTACK_PROTO long,long,long,long,long,\
+ long,long,long,long,long,\
+ long,long,long,long,long
+# define DLSTACK_ARGS stack[0],stack[1],stack[2],stack[3],stack[4],\
+ stack[5],stack[6],stack[7],stack[8],stack[9],\
+ stack[10],stack[11],stack[12],stack[13],stack[14]
+# define DLSTACK_SIZE (sizeof(long)*15)
+# define DLSTACK_START(sym)
+# define DLSTACK_END(sym)
+# define DLSTACK_PUSH_C(x) {long v=(long)x; memcpy(sp,&v,sizeof(long)); sp++;}
+# define DLSTACK_PUSH_H(x) {long v=(long)x; memcpy(sp,&v,sizeof(long)); sp++;}
+# define DLSTACK_PUSH_I(x) {long v=(long)x; memcpy(sp,&v,sizeof(long)); sp++;}
+# define DLSTACK_PUSH_L(x) memcpy(sp,&x,sizeof(long)); sp++;
+# define DLSTACK_PUSH_P(x) memcpy(sp,&x,sizeof(void*)); sp++;
+# define DLSTACK_PUSH_F(x) memcpy(sp,&x,sizeof(float)); sp+=sizeof(float)/sizeof(long);
+# define DLSTACK_PUSH_D(x) memcpy(sp,&x,sizeof(double)); sp+=sizeof(double)/sizeof(long);
+#else
+# define DLSTACK_METHOD "none"
+#endif
+
+extern VALUE rb_mDL;
+extern VALUE rb_mDLMemorySpace;
+extern VALUE rb_cDLHandle;
+extern VALUE rb_cDLSymbol;
+extern VALUE rb_cDLPtrData;
+extern VALUE rb_cDLStructData;
+
+extern VALUE rb_eDLError;
+extern VALUE rb_eDLTypeError;
+
+#if defined(LONG2NUM) && (SIZEOF_LONG == SIZEOF_VOIDP)
+# define DLLONG2NUM(x) LONG2NUM((long)x)
+# define DLNUM2LONG(x) (long)(NUM2LONG(x))
+#else
+# define DLLONG2NUM(x) INT2NUM((long)x)
+# define DLNUM2LONG(x) (long)(NUM2INT(x))
+#endif
+
+typedef struct { char c; void *x; } s_voidp;
+typedef struct { char c; short x; } s_short;
+typedef struct { char c; int x; } s_int;
+typedef struct { char c; long x; } s_long;
+typedef struct { char c; float x; } s_float;
+typedef struct { char c; double x; } s_double;
+
+#define ALIGN_VOIDP (sizeof(s_voidp) - sizeof(void *))
+#define ALIGN_SHORT (sizeof(s_short) - sizeof(short))
+#define ALIGN_INT (sizeof(s_int) - sizeof(int))
+#define ALIGN_LONG (sizeof(s_long) - sizeof(long))
+#define ALIGN_FLOAT (sizeof(s_float) - sizeof(float))
+#define ALIGN_DOUBLE (sizeof(s_double) - sizeof(double))
+
+/* for compatibility */
+#define VOIDP_ALIGN ALIGN_VOIDP
+#define SHORT_ALIGN ALIGN_SHORT
+#define INT_ALIGN ALIGN_INT
+#define LONG_ALIGN ALIGN_LONG
+#define FLOAT_ALIGN ALIGN_FLOAT
+#define DOUBLE_ALIGN ALIGN_DOUBLE
+
+#define DLALIGN(ptr,offset,align) {\
+ while( (((unsigned long)((char *)ptr + offset)) % align) != 0 ) offset++;\
+}
+
+typedef void (*freefunc_t)(void *);
+#define DLFREEFUNC(func) ((freefunc_t)(func))
+
+typedef union {
+ void* p;
+ char c;
+ short h;
+ int i;
+ long l;
+ float f;
+ double d;
+ char *s;
+} ANY_TYPE;
+
+struct dl_handle {
+ void *ptr;
+ int open;
+ int enable_close;
+};
+
+struct sym_data {
+ void *func;
+ char *name;
+ char *type;
+ int len;
+};
+
+enum DLPTR_CTYPE {
+ DLPTR_CTYPE_UNKNOWN,
+ DLPTR_CTYPE_STRUCT,
+ DLPTR_CTYPE_UNION
+};
+
+struct ptr_data {
+ void *ptr; /* a pointer to the data */
+ freefunc_t free; /* free() */
+ char *stype; /* array of type specifiers */
+ int *ssize; /* size[i] = sizeof(type[i]) > 0 */
+ int slen; /* the number of type specifiers */
+ ID *ids;
+ int ids_num;
+ int ctype; /* DLPTR_CTYPE_UNKNOWN, DLPTR_CTYPE_STRUCT, DLPTR_CTYPE_UNION */
+ long size;
+};
+
+#define RDLPTR(obj) ((struct ptr_data *)(DATA_PTR(obj)))
+#define RDLSYM(obj) ((struct sym_data *)(DATA_PTR(obj)))
+
+void dlfree(void*);
+void *dlmalloc(size_t);
+void *dlrealloc(void*,size_t);
+char *dlstrdup(const char *);
+size_t dlsizeof(const char *);
+
+void *rb_ary2cary(char t, VALUE ary, long *size);
+
+/*
+void rb_dlmem_delete(void *ptr);
+void rb_dlmem_aset(void *ptr, VALUE obj);
+VALUE rb_dlmem_aref(void *ptr);
+*/
+
+void dlptr_free(struct ptr_data *data);
+void dlptr_init(VALUE val);
+
+VALUE rb_dlptr_new(void *ptr, long size, freefunc_t func);
+VALUE rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func);
+VALUE rb_dlptr_malloc(long size, freefunc_t func);
+void *rb_dlptr2cptr(VALUE val);
+
+VALUE rb_dlsym_new(void (*func)(), const char *name, const char *type);
+freefunc_t rb_dlsym2csym(VALUE val);
+
+
+#endif /* RUBY_DL_H */
diff --git a/ext/dl/doc/dl.txt b/ext/dl/doc/dl.txt
new file mode 100644
index 0000000000..893bd21d79
--- /dev/null
+++ b/ext/dl/doc/dl.txt
@@ -0,0 +1,266 @@
+=begin
+
+= Ruby/DL
+
+Ruby/DL provides an interface to the dynamic linker such as dlopen() on UNIX
+and LoadLibrary() on Windows.
+
+= Building and Installing
+
+ $ ruby extconf.rb # to create the Makefile
+ $ make # to build the library 'dl.so'
+ $ make libtest.so # to build the C library 'libtest.so' for the test script
+ $ make test # to run the test script
+ $ make install # to install the library
+ $ make clean # to remove the created files without Makefile
+ $ make distclean # to remove the all created files
+
+= Using Ruby/DL
+
+We should usually use DL::Importable module provided by "dl/import.rb".
+It has high-level functions to access library functions. We use
+DL::Importable module to extend a module as follows:
+
+ require "dl/import"
+ module LIBC
+ extend DL::Importable
+ end
+
+Now we can use methods dlload and extern in this module. We load the
+libraries using dlload, and define wrapper methods to library functions
+using extern respectively as follows:
+
+ module LIBC
+ extend DL::Importable
+ dlload "libc.so.6","libm.so.6"
+ extern "int strlen(char*)"
+ end
+ # Note that we should not include the module LIBC from some reason.
+
+We can call the library function strlen() using LIBC.strlen. If the first
+character of given function name is an uppercase, the first character of the
+defined method name becomes lowercase.
+We can also construct memory images of structures and unions using functions
+struct and union which are defined in "dl/struct.rb" as follows:
+
+ require "dl/import"
+ require "dl/struct"
+ module LIBC
+ extend DL::Importable
+ Timeval = struct [ # define timeval structure.
+ "long tv_sec",
+ "long tv_uses",
+ ]
+ end
+ val = LIBC::Timeval.malloc # allocate memory.
+
+Notice that the above example takes LIBC::Timeval.malloc to allocate memory,
+rather than LIBC::Timeval.new. It is because DL::Timeval.new is for wrapping
+an object, PtrData, which has already been created.
+
+We can define a callback using the module function "callback" as follows:
+
+ module Foo
+ extend DL::Importable
+ def my_comp(str1,str2)
+ str1 <=> str2
+ end
+ COMPARE = callback "int my_comp(char*,char*)"
+ end
+
+where Foo::COMPARE is a Symbol object which invokes the method "my_comp".
+
+DL::Importable module is very useful. However, we sometimes encounter a case
+that we must directly use low-level functions such as dlsym(). In such case,
+we would use DL module functions. They are described in next section.
+
+= DL module
+
+Module DL consists of three classes, a few module functions and constants.
+The class Symbol represents the symbol we can call. The class PtrData
+indicates a memory block such as a pointer in C. An object instantiated from
+the class Handle keeps a handle to opened library.
+
+== Constants
+
+* VERSION
+* MAJOR_VERSION
+* MINOR_VERSION
+* PATCH_VERSION
+* RTLD_GLOBAL
+* RTLD_LAZY
+* RTLD_NOW
+* MAX_ARG
+* MAX_CBARG
+* MAX_CBENT
+
+== Functions
+
+* handle = dlopen(lib){|handle| ... }
+ * is quite equal to `Handle.new(lib)'
+
+* sym = set_callback(cbtype, entry){|args| ... }
+* sym = set_callback(cbtype, entry, proc)
+ * makes entry-th pre-defined function to call the proc or given block. the
+ entry-th pre-defined function is specified by cbtype and entry. cbtype is a
+ prototype of the callback. see also the section `Type specifiers' about
+ cbtype.
+
+* sym = get_callback(cbtype, entry)
+ * returns the Proc object which is given by the above function
+ `set_callback'.
+
+* ptr = malloc(size, [free = nil])
+ * allocates the size bytes, and returns the pointer as a PtrData object ptr.
+
+* ptr = strdup(str)
+ * returns a PtrData object ptr which represents the pointer to a new string
+ which is a duplicate of the string str.
+
+* size = sizeof(type)
+ * returns the size of type. `sizeof("C") + sizeof("L")' is not equal to
+ `sizeof("CL")'. the latter is assumed to returns the enough size of the
+ structure `struct foo { char c; long l; }', but the size may not equal to
+ `sizeof(foo)' of C.
+
+== Handle class
+
+* handle = Handle.new(lib){|handle| ... }
+ * opens a library lib and returns a Handle object handle. if a block is
+ given, the handle is automatically closed as the block ends.
+
+* Handle#close
+ * closes the handle opened by the above Handle.new(lib).
+
+* sym = Handle#sym(func, prototype = "0"),
+ sym = Handle#[func, prototype = nil]
+
+ * obtains the pointer to a function called func and returns a Symbol object
+ or a DataPtr object. prototype is a string which consists of type
+ specifiers, it indicates the function's prototype. see also the section
+ `Type specifiers'.
+
+== Symbol class
+
+* sym = Symbol.new(addr, type = nil, name = nil)
+ * creates the Symbol object sym with the type type if type is not nil. addr
+ is the address where the function is allocated. If type is nil, it returns
+ a DataPtr object.
+
+* Symbol::char2type(char)
+ * takes a character char that represents a type and returns the type
+ specifier of the C language.
+
+* str = Symbol#proto()
+ * returns the function prototype.
+
+* str = Symbol#name()
+ * Returns the function name.
+
+* str = Symbol#cproto(),
+ str = Symbol#to_s()
+ * returns the prototype of the C language.
+
+* str = Symbol#inspect()
+ * returns the inspectable string.
+
+* r,rs = Symbol#call(arg1,arg2,...,argN),
+ r,rs = Symbol#[](arg1,arg2,...,argN)
+ * calls the function with parameters arg1, arg2, ..., argN. and the result
+ consists of the return value r and parameters rs. rs is an array.
+
+* ptr = Symbol#to_ptr
+ * returns the corresponding PtrData object ptr.
+
+== PtrData class
+
+* ptr = PtrData.new(addr, [size = 0, free = nil])
+ * returns the PtrData object representing the pointer which indicates the
+ address addr. GC frees the memory using the free function.
+
+* PtrData#free=(sym)
+ * If you specify a symbol object sym, GC frees the memory using the function
+ represented by sym.
+
+* sym = PtrData#free
+ * returns a symbol object sym which is used when GC frees the memory. it
+ usually configured by `PtrData#free=' or `PtrData.new'.
+
+* size = PtrData#size, PtrData#size=(size)
+ * gets and sets allocated size of the memory.
+
+* ary = PtrData#to_a(type, [size])
+ * returns an array of the type which specified with type. type must be one of
+ 'S','P','I','L','D' and 'F'.
+
+* str = PtrData#to_s([len])
+ * returns a string which length is len. if len is omitted, the end of the
+ string is '\0'.
+
+* ptr = PtrData#ptr,+@
+ * returns the pointed value as a PtrData object ptr.
+
+* ptr = PtrData#ref,-@
+ * returns the reference as a PtrData object ptr.
+
+* ptr = PtrData#+
+ * returns the PtrData object
+
+* ptr = PtrData#-
+ * returns the PtrData object
+
+* PtrData#struct!(type, *members)
+ * defines the data type to get access to a structure member with a symbol.
+ (see also PtrData#[])
+
+* PtrData#union!(type, *members)
+ * defines the data type to get access to a union member with a symbol. (see
+ also PtrData#[])
+
+* val = PtrData#[key], PtrData#[key, num = 0]
+ * if the key is a string or symbol, this method returns the value of the
+ structure/union member which has the type defined by PtrData#
+ {struct!,union!}. if the key is a integer value and this object represents
+ the pointer ptr, it returns the value of `(ptr + key).to_s(num)'
+
+* PtrData#[key,num]=val, PtrData#[key]=val
+ * if the key is a string or symbol, this method substitute the value of the
+ structure/union member with val. if the key is a integer value and val is a
+ string, this method copies num bytes of val to the memory area ptr using
+ memcpy(3).
+
+== Type specifiers
+
+the prototype consists of the following type specifiers, first element of
+prototype represents the type of return value, and remaining elements represent
+the type of each argument.
+
+ C : char
+ c : char *
+ H : short
+ h : short *
+ I : int
+ i : int *
+ L : long
+ l : long *
+ F : float
+ f : float *
+ D : double
+ d : double *
+ S : const char *
+ s : char *
+ A : const type[]
+ a : type[] (allocates new memory space)
+ P : void * (same as 'p')
+ p : void * (same as 'P')
+ 0 : void function (this must be a first character of the prototype)
+
+the cbtype consists of type specifiers 0, C, I, H, L, F, D, S and P.
+for example:
+
+ DL.callback('IPP'){|ptr1,ptr2|
+ str1 = ptr1.ptr.to_s
+ str2 = ptr2.ptr.to_s
+ str1 <=> str2
+ }
+=end
diff --git a/ext/dl/extconf.rb b/ext/dl/extconf.rb
new file mode 100644
index 0000000000..beb15ab04c
--- /dev/null
+++ b/ext/dl/extconf.rb
@@ -0,0 +1,193 @@
+require 'mkmf'
+
+begin # for the exception SystemExit
+
+$:.unshift File.dirname(__FILE__)
+require 'type'
+
+if( ARGV.include?("--help") )
+ print <<EOF
+ --help print this messages
+ --with-type-char strictly use type 'char'
+ --with-type-short strictly use type 'short'
+ --with-type-float strictly use type 'float'
+ --with-args=<max_arg>
+ --with-callback=<max_callback>
+ --enable-asm use the embedded assembler for passing arguments.
+ (this option is available for i386 machine now.)
+ --enable-dlstack use a stack emulation for constructing function call.
+EOF
+ exit(0)
+end
+
+($CPPFLAGS || $CFLAGS) << " -I."
+
+if (Config::CONFIG['CC'] =~ /gcc/) # from Win32API
+ $CFLAGS << " -fno-defer-pop -fno-omit-frame-pointer"
+end
+
+$with_dlstack ||= true
+$with_asm = ! $with_dlstack
+
+$with_type_int = try_cpp(<<EOF)
+#include "config.h"
+#if SIZEOF_INT == SIZEOF_LONG
+#error int not needed
+#endif
+EOF
+
+$with_type_float = try_cpp(<<EOF)
+#include "config.h"
+#if SIZEOF_FLOAT == SIZEOF_DOUBLE
+#error float not needed
+#endif
+EOF
+
+$with_type_voidp = try_cpp(<<EOF)
+#include "config.h"
+#if SIZEOF_VOIDP == SIZEOF_INT || SIZEOF_VOIDP == SIZEOF_LONG
+#error void* not needed
+#endif
+EOF
+
+$with_type_char = DLTYPE[CHAR][:sym]
+$with_type_short = DLTYPE[SHORT][:sym]
+$with_type_long = DLTYPE[LONG][:sym]
+$with_type_double= DLTYPE[DOUBLE][:sym]
+$with_type_int &= DLTYPE[INT][:sym]
+$with_type_float &= DLTYPE[FLOAT][:sym]
+$with_type_voidp &= DLTYPE[VOIDP][:sym]
+
+$with_type_char = enable_config("type-char", $with_type_char)
+$with_type_short = enable_config("type-short", $with_type_short)
+$with_type_float = enable_config("type-float", $with_type_float)
+
+$with_asm = enable_config("asm", $with_asm)
+$with_dlstack = enable_config("dlstack", $with_dlstack)
+
+args = with_config("args")
+max_arg = nil
+if( $with_asm || $with_dlstack )
+ $with_type_char = true
+ $with_type_short = true
+ $with_type_float = true
+ max_arg = 0
+end
+if( args )
+ max_arg = args.to_i
+ if( !max_arg )
+ print("--with-args=<max_arg>\n")
+ exit(1)
+ end
+end
+max_arg ||= 6
+
+max_callback = with_config("callback","10").to_i
+callback_types = DLTYPE.keys.length
+
+
+$dlconfig_h = <<EOF
+#define MAX_ARG #{max_arg}
+EOF
+
+def dlc_define(const)
+ $dlconfig_h << "#if !defined(#{const})\n" +
+ "# define #{const}\n" +
+ "#endif\n"
+end
+
+$dlconfig_h << "#define MAX_CALLBACK #{max_callback}\n"
+$dlconfig_h << "#define CALLBACK_TYPES #{callback_types}\n"
+if( $with_dlstack )
+ $dlconfig_h << "#define USE_DLSTACK\n"
+else
+ if( $with_asm )
+ $dlconfig_h << "#define USE_INLINE_ASM\n"
+ end
+end
+if( $with_type_char )
+ $dlconfig_h << "#define WITH_TYPE_CHAR\n"
+end
+if( $with_type_short )
+ $dlconfig_h << "#define WITH_TYPE_SHORT\n"
+end
+if( $with_type_long )
+ $dlconfig_h << "#define WITH_TYPE_LONG\n"
+end
+if( $with_type_double )
+ $dlconfig_h << "#define WITH_TYPE_DOUBLE\n"
+end
+if( $with_type_float )
+ $dlconfig_h << "#define WITH_TYPE_FLOAT\n"
+end
+if( $with_type_int )
+ $dlconfig_h << "#define WITH_TYPE_INT\n"
+end
+if( $with_type_voidp )
+ $dlconfig_h << "#define WITH_TYPE_VOIDP\n"
+end
+
+if( have_header("windows.h") )
+ have_library("kernel32")
+ have_func("GetLastError", "windows.h")
+ dlc_define("HAVE_WINDOWS_H")
+ have_windows_h = true
+end
+
+if( have_header("dlfcn.h") )
+ dlc_define("HAVE_DLFCN_H")
+ have_library("dl")
+ have_func("dlopen")
+ have_func("dlclose")
+ have_func("dlsym")
+ if( have_func("dlerror") )
+ dlc_define("HAVE_DLERROR")
+ end
+elsif ( have_windows_h )
+ have_func("LoadLibrary")
+ have_func("FreeLibrary")
+ have_func("GetProcAddress")
+else
+ exit(0)
+end
+
+def File.update(file, str)
+ begin
+ open(file){|f|f.read} == str
+ rescue Errno::ENOENT
+ false
+ end or open(file, "w"){|f|f.print(str)}
+end
+
+File.update("dlconfig.h", <<EOF)
+#ifndef DLCONFIG_H
+#define DLCONFIG_H
+#{$dlconfig_h}
+#endif /* DLCONFIG_H */
+EOF
+
+File.update("dlconfig.rb", <<EOF)
+MAX_ARG = #{max_arg}
+MAX_CALLBACK = #{max_callback}
+CALLBACK_TYPES = #{callback_types}
+DLTYPE[CHAR][:sym] = #{$with_type_char}
+DLTYPE[SHORT][:sym] = #{$with_type_short}
+DLTYPE[INT][:sym] = #{$with_type_int}
+DLTYPE[LONG][:sym] = #{$with_type_long}
+DLTYPE[FLOAT][:sym] = #{$with_type_float}
+DLTYPE[DOUBLE][:sym]= #{$with_type_double}
+DLTYPE[VOIDP][:sym] = #{$with_type_voidp}
+EOF
+
+$INSTALLFILES = [
+ ["./dlconfig.h", "$(archdir)$(target_prefix)", "."],
+ ["dl.h", "$(archdir)$(target_prefix)", ""],
+]
+$cleanfiles = %w[test/test.o]
+$distcleanfiles = %w[call.func callback.func cbtable.func dlconfig.rb
+./dlconfig.h test/libtest.so test/*~ *~ mkmf.log]
+
+create_makefile('dl')
+rescue SystemExit
+ # do nothing
+end
diff --git a/ext/dl/h2rb b/ext/dl/h2rb
new file mode 100644
index 0000000000..00fbd60c82
--- /dev/null
+++ b/ext/dl/h2rb
@@ -0,0 +1,500 @@
+#!/usr/bin/env ruby
+# -*- ruby -*-
+# $Id$
+
+require 'mkmf'
+require 'ftools'
+
+$recursive = false
+$force = false
+$conly = true
+$inc_path = []
+$infilename= nil
+$insert_require = true
+
+def valid_ruby_code?(code)
+ begin
+ eval("BEGIN {return true}; #{code}")
+ rescue SyntaxError
+ return false
+ end
+ return false
+end
+
+def print_usage
+ print <<EOF
+h2rb [-r] [-I <path>] [-d] [<filename>]
+EOF
+end
+
+while( ARGV[0] )
+ case( ARGV[0] )
+ when "-r"
+ ARGV.shift
+ $recursive = true
+ when "-R"
+ ARGV.shift
+ $recursive = false
+ when "-l"
+ ARGV.shift
+ $insert_require = true
+ when "-L"
+ ARGV.shift
+ $insert_require = false
+ when "-c"
+ ARGV.shift
+ $conly = true
+ when "-C"
+ ARGV.shift
+ $conly = false
+ when "-f"
+ ARGV.shift
+ $force = true
+ when "-F"
+ ARGV.shift
+ $force = false
+ when "-I"
+ ARGV.shift
+ $inc_path << ARGV.shift
+ when "-d"
+ ARGV.shift
+ $DEBUG = true
+ when "-h","--help"
+ print_usage()
+ exit 0
+ when /-.*/
+ $stderr.print("unknown option '#{ARGV[0]}'.\n")
+ print_usage()
+ exit 0
+ else
+ $infilename = ARGV.shift
+ end
+end
+
+$inc_dir = File.join(CONFIG["prefix"], "lib", "ruby",
+ CONFIG["MAJOR"] + "." + CONFIG["MINOR"],
+ "dl")
+
+class H2RBError < StandardError; end
+
+
+class H2RB
+ def initialize(inc_dir = nil, inc_path = nil, insert_require = nil)
+ @inc_path = inc_path || []
+ @inc_dir = inc_dir || '.'
+ @indent = 0
+ @parsed_files = []
+ @insert_require = insert_require || false
+ end
+
+ def find_path(file)
+ if( ! file )
+ return nil
+ end
+ if( File.exist?(file) )
+ if( file[0] == ?/ )
+ return file
+ else
+ return file
+ end
+ end
+ @inc_path.each{|path|
+ full = File.join(path, file)
+ if( File.exist?(full) )
+ return full
+ end
+ }
+ return nil
+ end
+
+ def strip_comment(line)
+ if( @commented )
+ if( e = line.index("*/") )
+ line[0..(e+1)] = ""
+ @commented = false
+ else
+ line = ""
+ end
+ else
+ if( s = line.index("/*") )
+ if( e = line.index("*/") )
+ line[s..(e+1)] = ""
+ else
+ line[s..-1] = ""
+ @commented = true
+ end
+ elsif( s = line.index("//") )
+ line[s..(-1)] = ""
+ end
+ end
+
+ line.gsub!(/\s+$/,"")
+ return line
+ end
+
+ def up_indent
+ @indent += 1
+ end
+
+ def down_indent
+ @indent -= 1
+ if( @indent < 0 )
+ raise
+ end
+ end
+
+ def indent
+ " " * @indent
+ end
+
+ def rescue_begin
+ line = "#{indent}begin"
+ up_indent
+ return line
+ end
+
+ def rescue_nameerror
+ down_indent
+ line = [
+ "#{indent}rescue NameError => e",
+ "#{indent} raise e if( $DEBUG )",
+ "#{indent}end"].join($/)
+ return line
+ end
+
+ def parse_enum(line)
+ if( line =~ /enum\s+(\S+\s+)?\{(.+)\}/ )
+ enum_name = $1
+ enum_block = $2
+ if( enum_name )
+ line = "#{indent}# -- enum #{enum_name}\n"
+ else
+ line = "#{indent}# -- enum\n"
+ end
+ enums = enum_block.split(/,/).collect{|e| e.strip}
+ i = 0
+ enums.each{|elem|
+ var,val = elem.split(/=/).collect{|e| e.strip}
+ if( val )
+ i = val.to_i
+ end
+ line += "#{indent}#{var} = #{i.to_s}\n"
+ i += 1
+ }
+ line += "#{indent}# -- end of enum"
+ return line
+ else
+ return nil
+ end
+ end
+
+ def parse_define(line)
+ case line
+ when /^#\s*define\s+(\S+)\(\)/
+ line = nil
+ when /^#\s*define\s+(\S+)\((.+)\)\s+(.+)$/
+ if( @conly )
+ line = nil
+ else
+ defname = $1
+ defargs = $2
+ defval = $3
+ if( !valid_ruby_code?(defval) )
+ defval = "nil # #{defval}"
+ end
+ if( defname[0,1] =~ /^[A-Z]$/ )
+ line = "#{indent}#{defname} = proc{|#{defargs}| #{defval}}"
+ else
+ line = [
+ "#{indent}def #{defname}(#{defargs})",
+ "#{indent} #{defval}",
+ "#{indent}end"
+ ].join("\n")
+ end
+ end
+ when /^#\s*define\s+(\S+)\((.+)\)$/
+ if( @conly )
+ line = nil
+ else
+ defname = $1
+ defargs = $2
+ defval = nil
+ if( !valid_ruby_code?(defval) )
+ defval = "nil # #{defval}"
+ end
+ if( defname[0,1] =~ /^[A-Z]$/ )
+ line = "#{indent}#{defname} = proc{|#{defargs}| #{defval}}"
+ else
+ line = [
+ "#{indent}def #{defname}(#{defargs})",
+ "#{indent} #{defval}",
+ "#{indent}end"
+ ].join("\n")
+ end
+ end
+ when /^#\s*define\s+(\S+)\s+(.+)$/
+ defname = $1
+ defval = $2
+ if( !valid_ruby_code?(defval) )
+ defval = "nil # #{defval}"
+ end
+ line = [rescue_begin, "#{indent}#{defname} = #{defval}", rescue_nameerror].join($/)
+ when /^#\s*define\s+(\S+)$/
+ defname = $1
+ line = "#{indent}#{defname} = nil"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_undef(line)
+ case line
+ when /^#\s*undef\s+([A-Z]\S+)$/
+ defname = $1
+ line = "#{indent}remove_const(:#{defname})"
+ when /^#\s*undef\s+(\S+)$/
+ defname = $1
+ line = "#{indent}#{defname} = nil"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_ifdef(line)
+ case line
+ when /^#\s*ifdef\s+(\S+)$/
+ defname = $1
+ line = [
+ rescue_begin,
+ "#{indent}if( defined?(#{defname}) && ! #{defname}.nil? )"].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_ifndef(line)
+ case line
+ when /^#\s*ifndef\s+(\S+)$/
+ defname = $1
+ line = [
+ rescue_begin,
+ "#{indent}if( ! defined?(#{defname}) || #{defname}.nil? )"].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_if(line)
+ case line
+ when /^#\s*if\s+(.+)$/
+ cond = $1
+ cond.gsub!(/defined(.+)/){ "defined?(#{$1}) && ! #{$1}.nil?" }
+ if( valid_ruby_code?(cond) )
+ line = "#{indent}if( #{cond} )"
+ else
+ line = "#{indent}if( false ) # #{cond}"
+ end
+ line = [rescue_begin, line].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_elif(line)
+ case line
+ when /^#\s*elif\s+(.+)$/
+ cond = $1
+ cond.gsub!("defined","defined?")
+ line = "#{indent}elsif( #{cond} )"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_else(line)
+ case line
+ when /^#\s*else\s*/
+ line = "#{indent}else"
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_endif(line)
+ case line
+ when /^#\s*endif\s*$/
+ line = ["#{indent}end", rescue_nameerror].join($/)
+ else
+ line = nil
+ end
+ return line
+ end
+
+ def parse_include(line)
+ if( ! @insert_require )
+ return nil
+ end
+
+ file = nil
+ case line
+ when /^#\s*include "(.+)"$/
+ file = $1
+ line = "#{indent}require '#{file}'"
+ when /^#\s*include \<(.+)\>$/
+ file = $1
+ line = "#{indent}require '#{file}'"
+ else
+ line = nil
+ end
+ if( @recursive && file && (!@parsed_files.include?(file)) )
+ parse(file, @recursive, @force, @conly)
+ end
+ return line
+ end
+
+
+ def open_files(infilename)
+ if( ! infilename )
+ return [$stdin, $stdout]
+ end
+
+ old_infilename = infilename
+ infilename = find_path(infilename)
+ if( ! infilename )
+ $stderr.print("'#{old_infilename}' was not found.\n")
+ return [nil,nil]
+ end
+
+ if( infilename )
+ if( infilename[0,1] == '/' )
+ outfilename = File.join(@inc_dir, infilename[1..-1] + ".rb")
+ else
+ outfilename = infilename + ".rb"
+ end
+ File.mkpath(File.dirname(outfilename))
+ else
+ outfilename = nil
+ end
+
+ if( infilename )
+ fin = File.open(infilename,"r")
+ else
+ fin = $stdin
+ end
+ if( outfilename )
+ if( File.exist?(outfilename) && (!@force) )
+ $stderr.print("'#{outfilename}' have already existed.\n")
+ return [fin, nil]
+ end
+ fout = File.open(outfilename,"w")
+ else
+ fout = $stdout
+ end
+
+ $stderr.print("#{infilename} -> #{outfilename}\n")
+ if( fout )
+ dir = File.dirname(outfilename)
+ if( dir[0,1] != "." && dir != "" )
+ fout.print("if( ! $LOAD_PATH.include?('#{dir}') )\n",
+ " $LOAD_PATH.push('#{dir}')\n",
+ "end\n")
+ end
+ end
+ return [fin,fout]
+ end
+
+ def parse(infilename = nil, recursive = false, force = false, conly = false)
+ @commented = false
+ @recursive = recursive
+ @force = force
+ @conly = conly
+ @parsed_files << infilename
+
+ fin,fout = open_files(infilename)
+ if( !fin )
+ return
+ end
+
+ begin
+ line_number = 0
+ pre_line = nil
+ fin.each_line{|line|
+ line_number += 1
+ line.chop!
+ if( $DEBUG )
+ $stderr.print("#{line_number}:(#{@indent}):", line, "\n")
+ end
+
+ if( pre_line )
+ line = pre_line + line
+ pre_line = nil
+ end
+
+ if( line[-1,1] == "\\" )
+ pre_line = line[0..-2]
+ next
+ end
+
+ if( eidx = line.index("enum ") )
+ pre_line = line[eidx .. -1]
+ if( i = line.index("{") && j = line.index("}") )
+ line = line[0..j]
+ pre_line = nil
+ else
+ next
+ end
+ end
+
+ line = strip_comment(line)
+ case line
+ when /^enum\s/
+ line = parse_enum(line)
+ when /^#\s*define\s/
+ line = parse_define(line)
+ when /^#\s*undef\s/
+ line = parse_undef(line)
+ when /^#\s*ifdef\s/
+ line = parse_ifdef(line)
+ up_indent
+ when /^#\s*ifndef\s/
+ line = parse_ifndef(line)
+ up_indent
+ when /^#\s*if\s/
+ line = parse_if(line)
+ up_indent
+ when /^#\s*elif\s/
+ down_indent
+ line = parse_elif(line)
+ up_indent
+ when /^#\s*else/
+ down_indent
+ line = parse_else(line)
+ up_indent
+ when /^#\s*endif/
+ down_indent
+ line = parse_endif(line)
+ when /^#\s*include\s/
+ line = parse_include(line)
+ else
+ line = nil
+ end
+ if( line && fout )
+ fout.print(line, " # #{line_number}",$/)
+ end
+ }
+ ensure
+ fin.close if fin
+ fout.close if fout
+ end
+ end
+end
+
+h2rb = H2RB.new($inc_dir, $inc_path, $insert_require)
+h2rb.parse($infilename, $recursive, $force, $conly)
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
new file mode 100644
index 0000000000..95b6dc74dc
--- /dev/null
+++ b/ext/dl/handle.c
@@ -0,0 +1,215 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#include <ruby.h>
+#include "dl.h"
+
+VALUE rb_cDLHandle;
+
+void
+dlhandle_free(struct dl_handle *dlhandle)
+{
+ if (dlhandle->ptr && dlhandle->open && dlhandle->enable_close) {
+ dlclose(dlhandle->ptr);
+ }
+}
+
+VALUE
+rb_dlhandle_close(VALUE self)
+{
+ struct dl_handle *dlhandle;
+
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ dlhandle->open = 0;
+ return INT2NUM(dlclose(dlhandle->ptr));
+}
+
+VALUE
+rb_dlhandle_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct dl_handle *dlhandle;
+
+ obj = Data_Make_Struct(rb_cDLHandle, struct dl_handle, 0,
+ dlhandle_free, dlhandle);
+ dlhandle->ptr = 0;
+ dlhandle->open = 0;
+ dlhandle->enable_close = 0;
+
+ return obj;
+}
+
+VALUE
+rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
+{
+ void *ptr;
+ struct dl_handle *dlhandle;
+ VALUE lib, flag;
+ char *clib;
+ int cflag;
+ const char *err;
+
+ switch (rb_scan_args(argc, argv, "11", &lib, &flag)) {
+ case 1:
+ clib = NIL_P(lib) ? NULL : StringValuePtr(lib);
+ cflag = RTLD_LAZY | RTLD_GLOBAL;
+ break;
+ case 2:
+ clib = NIL_P(lib) ? NULL : StringValuePtr(lib);
+ cflag = NUM2INT(flag);
+ break;
+ default:
+ rb_bug("rb_dlhandle_new");
+ }
+
+ ptr = dlopen(clib, cflag);
+#if defined(HAVE_DLERROR)
+ if (!ptr && (err = dlerror())) {
+ rb_raise(rb_eRuntimeError, err);
+ }
+#else
+ if (!ptr) {
+ err = dlerror();
+ rb_raise(rb_eRuntimeError, err);
+ }
+#endif
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ if (dlhandle->ptr && dlhandle->open && dlhandle->enable_close) {
+ dlclose(dlhandle->ptr);
+ }
+ dlhandle->ptr = ptr;
+ dlhandle->open = 1;
+ dlhandle->enable_close = 0;
+
+ if (rb_block_given_p()) {
+ rb_ensure(rb_yield, self, rb_dlhandle_close, self);
+ }
+
+ return Qnil;
+}
+
+VALUE
+rb_dlhandle_enable_close(VALUE self)
+{
+ struct dl_handle *dlhandle;
+
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ dlhandle->enable_close = 1;
+ return Qnil;
+}
+
+VALUE
+rb_dlhandle_disable_close(VALUE self)
+{
+ struct dl_handle *dlhandle;
+
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ dlhandle->enable_close = 0;
+ return Qnil;
+}
+
+VALUE
+rb_dlhandle_to_i(VALUE self)
+{
+ struct dl_handle *dlhandle;
+
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ return DLLONG2NUM(dlhandle);
+}
+
+VALUE
+rb_dlhandle_to_ptr(VALUE self)
+{
+ struct dl_handle *dlhandle;
+
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ return rb_dlptr_new(dlhandle, sizeof(dlhandle), 0);
+}
+
+VALUE
+rb_dlhandle_sym(int argc, VALUE argv[], VALUE self)
+{
+ VALUE sym, type;
+ void (*func)();
+ VALUE val;
+ struct dl_handle *dlhandle;
+ void *handle;
+ const char *name, *stype;
+ const char *err;
+
+ rb_secure(2);
+ if (rb_scan_args(argc, argv, "11", &sym, &type) == 2) {
+ SafeStringValue(type);
+ stype = StringValuePtr(type);
+ }
+ else{
+ stype = NULL;
+ }
+
+ if (sym == Qnil) {
+#if defined(RTLD_NEXT)
+ name = RTLD_NEXT;
+#else
+ name = NULL;
+#endif
+ }
+ else{
+ SafeStringValue(sym);
+ name = StringValuePtr(sym);
+ }
+
+ Data_Get_Struct(self, struct dl_handle, dlhandle);
+ if (!dlhandle->open) {
+ rb_raise(rb_eRuntimeError, "Closed handle.");
+ }
+ handle = dlhandle->ptr;
+
+ func = dlsym(handle, name);
+#if defined(HAVE_DLERROR)
+ if (!func && (err = dlerror()))
+#else
+ if (!func)
+#endif
+ {
+#if defined(__CYGWIN__) || defined(WIN32) || defined(__MINGW32__)
+ {
+ int len = strlen(name);
+ char *name_a = (char*)dlmalloc(len+2);
+ strcpy(name_a, name);
+ name_a[len] = 'A';
+ name_a[len+1] = '\0';
+ func = dlsym(handle, name_a);
+ dlfree(name_a);
+#if defined(HAVE_DLERROR)
+ if (!func && (err = dlerror()))
+#else
+ if (!func)
+#endif
+ {
+ rb_raise(rb_eRuntimeError, "Unknown symbol \"%sA\".", name);
+ }
+ }
+#else
+ rb_raise(rb_eRuntimeError, "Unknown symbol \"%s\".", name);
+#endif
+ }
+ val = rb_dlsym_new(func, name, stype);
+
+ return val;
+}
+
+void
+Init_dlhandle()
+{
+ rb_cDLHandle = rb_define_class_under(rb_mDL, "Handle", rb_cObject);
+ rb_define_alloc_func(rb_cDLHandle, rb_dlhandle_s_allocate);
+ rb_define_method(rb_cDLHandle, "initialize", rb_dlhandle_initialize, -1);
+ rb_define_method(rb_cDLHandle, "to_i", rb_dlhandle_to_i, 0);
+ rb_define_method(rb_cDLHandle, "to_ptr", rb_dlhandle_to_ptr, 0);
+ rb_define_method(rb_cDLHandle, "close", rb_dlhandle_close, 0);
+ rb_define_method(rb_cDLHandle, "sym", rb_dlhandle_sym, -1);
+ rb_define_method(rb_cDLHandle, "[]", rb_dlhandle_sym, -1);
+ rb_define_method(rb_cDLHandle, "disable_close", rb_dlhandle_disable_close, 0);
+ rb_define_method(rb_cDLHandle, "enable_close", rb_dlhandle_enable_close, 0);
+}
diff --git a/ext/dl/install.rb b/ext/dl/install.rb
new file mode 100644
index 0000000000..69b1834301
--- /dev/null
+++ b/ext/dl/install.rb
@@ -0,0 +1,49 @@
+require 'mkmf'
+require 'ftools'
+
+SO_LIBS = ["dl.so"]
+
+$ruby_version = CONFIG['MAJOR'] + "." + CONFIG['MINOR']
+$prefix = CONFIG['prefix']
+$libdir = File.join($prefix,'lib')
+$rubylibdir = File.join($libdir, 'ruby', $ruby_version)
+$arch = CONFIG['arch']
+$archdir = File.join($rubylibdir, $arch)
+
+def find(dir, match = /./)
+ Dir.chdir(dir)
+ files = []
+ Dir.new(".").each{|file|
+ if( file != "." && file != ".." )
+ case File.ftype(file)
+ when "file"
+ if( file =~ match )
+ files.push(File.join(dir,file))
+ end
+ when "directory"
+ files += find(file, match).collect{|f| File.join(dir,f)}
+ end
+ end
+ }
+ Dir.chdir("..")
+ return files
+end
+
+def install()
+ rb_files = find(File.join(".","lib"), /.rb$/)
+
+ SO_LIBS.each{|f|
+ File.makedirs($rubylibdir, "#{$archdir}")
+ File.install(f, File.join($archdir,f), 0555, true)
+ }
+
+ rb_files.each{|f|
+ origfile = f
+ instfile = File.join($rubylibdir, origfile.sub("./lib/",""))
+ instdir = File.dirname(instfile)
+ File.makedirs(instdir)
+ File.install(origfile, instfile, 0644, true)
+ }
+end
+
+install()
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
new file mode 100644
index 0000000000..1ab5145def
--- /dev/null
+++ b/ext/dl/lib/dl/import.rb
@@ -0,0 +1,215 @@
+# -*- ruby -*-
+
+require 'dl'
+require 'dl/types'
+
+module DL
+ module Importable
+ LIB_MAP = {}
+
+ module Internal
+ def init_types()
+ @types ||= ::DL::Types.new
+ end
+
+ def init_sym()
+ @SYM ||= {}
+ end
+
+ def [](name)
+ return @SYM[name.to_s][0]
+ end
+
+ def dlload(*libnames)
+ if( !defined?(@LIBS) )
+ @LIBS = []
+ end
+ libnames.each{|libname|
+ if( !LIB_MAP[libname] )
+ LIB_MAP[libname] = DL.dlopen(libname)
+ end
+ @LIBS.push(LIB_MAP[libname])
+ }
+ end
+ alias dllink :dlload
+
+ def parse_cproto(proto)
+ proto = proto.gsub(/\s+/, " ").strip
+ case proto
+ when /^([\d\w\*_\s]+)\(([\d\w\*_\s\,\[\]]*)\)$/
+ ret = $1
+ args = $2
+ ret = ret.split(/\s+/)
+ args = args.split(/\s*,\s*/)
+ func = ret.pop
+ if( func =~ /^\*/ )
+ func.gsub!(/^\*+/,"")
+ ret.push("*")
+ end
+ ret = ret.join(" ")
+ return [func, ret, args]
+ else
+ raise(RuntimeError,"can't parse the function prototype: #{proto}")
+ end
+ end
+
+ # example:
+ # extern "int strlen(char*)"
+ #
+ def extern(proto)
+ func,ret,args = parse_cproto(proto)
+ return import(func, ret, args)
+ end
+
+ # example:
+ # callback "int method_name(int, char*)"
+ #
+ def callback(proto)
+ func,ret,args = parse_cproto(proto)
+
+ init_types()
+ init_sym()
+
+ rty,renc,rdec = @types.encode_type(ret)
+ ty,enc,dec = encode_types(args)
+ symty = rty + ty
+
+ module_eval("module_function :#{func}")
+ sym = module_eval([
+ "DL::callback(\"#{symty}\"){|*args|",
+ " sym,rdec,enc,dec = @SYM['#{func}']",
+ " args = enc.call(args) if enc",
+ " r,rs = #{func}(*args)",
+ " r = renc.call(r) if rdec",
+ " rs = dec.call(rs) if (dec && rs)",
+ " @retval = r",
+ " @args = rs",
+ " @retval",
+ "}",
+ ].join("\n"))
+
+ @SYM[func] = [sym,rdec,enc,dec]
+
+ return sym
+ end
+
+ # example:
+ # typealias("uint", "unsigned int")
+ #
+ def typealias(*args)
+ init_types()
+ @types.typealias(*args)
+ end
+
+ # example:
+ # symbol "foo_value"
+ # symbol "foo_func", "IIP"
+ #
+ def symbol(name, ty = nil)
+ sym = nil
+ @LIBS.each{|lib|
+ begin
+ if( ty )
+ sym = lib[name, ty]
+ else
+ sym = lib[name]
+ end
+ rescue
+ next
+ end
+ }
+ if( !sym )
+ raise(RuntimeError, "can't find the symbol `#{name}'")
+ end
+ return sym
+ end
+
+ # example:
+ # import("get_length", "int", ["void*", "int"])
+ #
+ def import(name, rettype, argtypes = nil)
+ init_types()
+ init_sym()
+
+ rty,_,rdec = @types.encode_type(rettype)
+ ty,enc,dec = encode_types(argtypes)
+ symty = rty + ty
+
+ sym = symbol(name, symty)
+
+ mname = name.dup
+ if( ?A <= mname[0] && mname[0] <= ?Z )
+ mname[0,1] = mname[0,1].downcase
+ end
+ @SYM[mname] = [sym,rdec,enc,dec]
+
+ module_eval [
+ "def #{mname}(*args)",
+ " sym,rdec,enc,dec = @SYM['#{mname}']",
+ " args = enc.call(args) if enc",
+ if( $DEBUG )
+ " p \"[DL] call #{mname} with \#{args.inspect}\""
+ else
+ ""
+ end,
+ " r,rs = sym.call(*args)",
+ if( $DEBUG )
+ " p \"[DL] retval=\#{r.inspect} args=\#{rs.inspect}\""
+ else
+ ""
+ end,
+ " r = rdec.call(r) if rdec",
+ " rs = dec.call(rs) if dec",
+ " @retval = r",
+ " @args = rs",
+ " return @retval",
+ "end",
+ "module_function :#{mname}",
+ ].join("\n")
+
+ return sym
+ end
+
+ def _args_
+ return @args
+ end
+
+ def _retval_
+ return @retval
+ end
+
+ def encode_types(tys)
+ init_types()
+ encty = []
+ enc = nil
+ dec = nil
+ tys.each_with_index{|ty,idx|
+ ty,c1,c2,_,_ = @types.encode_type(ty)
+ encty.push(ty)
+ if( enc )
+ if( c1 )
+ conv1 = enc
+ enc = proc{|v| v = conv1.call(v); v[idx] = c1.call(v[idx]); v}
+ end
+ else
+ if( c1 )
+ enc = proc{|v| v[idx] = c1.call(v[idx]); v}
+ end
+ end
+ if( dec )
+ if( c2 )
+ conv2 = dec
+ dec = proc{|v| v = conv2.call(v); v[idx] = c2.call(v[idx]); v}
+ end
+ else
+ if( c2 )
+ dec = proc{|v| v[idx] = c2.call(v[idx]); v}
+ end
+ end
+ }
+ return [encty.join, enc, dec]
+ end
+ end # end of Internal
+ include Internal
+ end # end of Importable
+end
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
new file mode 100644
index 0000000000..2c52d5040d
--- /dev/null
+++ b/ext/dl/lib/dl/struct.rb
@@ -0,0 +1,146 @@
+# -*- ruby -*-
+
+require 'dl'
+require 'dl/import'
+
+module DL
+ module Importable
+ module Internal
+ def define_struct(contents)
+ init_types()
+ Struct.new(@types, contents)
+ end
+ alias struct define_struct
+
+ def define_union(contents)
+ init_types()
+ Union.new(@types, contents)
+ end
+ alias union define_union
+
+ class Memory
+ def initialize(ptr, names, ty, len, enc, dec)
+ @ptr = ptr
+ @names = names
+ @ty = ty
+ @len = len
+ @enc = enc
+ @dec = dec
+
+ # define methods
+ @names.each{|name|
+ instance_eval [
+ "def #{name}",
+ " v = @ptr[\"#{name}\"]",
+ " if( @len[\"#{name}\"] )",
+ " v = v.collect{|x| @dec[\"#{name}\"].call(x) if @dec[\"#{name}\"] }",
+ " else",
+ " v = @dec[\"#{name}\"].call(v) if @dec[\"#{name}\"]",
+ " end",
+ " return v",
+ "end",
+ "def #{name}=(v)",
+ " if( @len[\"#{name}\"] )",
+ " v = v.collect{|x| @enc[\"#{name}\"].call(x) if @enc[\"#{name}\"] }",
+ " else",
+ " v = @enc[\"#{name}\"].call(v) if @enc[\"#{name}\"]",
+ " end",
+ " @ptr[\"#{name}\"] = v",
+ " return v",
+ "end",
+ ].join("\n")
+ }
+ end
+
+ def to_ptr
+ return @ptr
+ end
+
+ def size
+ return @ptr.size
+ end
+ end
+
+ class Struct
+ def initialize(types, contents)
+ @names = []
+ @ty = {}
+ @len = {}
+ @enc = {}
+ @dec = {}
+ @size = 0
+ @tys = ""
+ @types = types
+ parse(contents)
+ end
+
+ def size
+ return @size
+ end
+
+ def members
+ return @names
+ end
+
+ # ptr must be a PtrData object.
+ def new(ptr)
+ ptr.struct!(@tys, *@names)
+ mem = Memory.new(ptr, @names, @ty, @len, @enc, @dec)
+ return mem
+ end
+
+ def malloc(size = nil)
+ if( !size )
+ size = @size
+ end
+ ptr = DL::malloc(size)
+ return new(ptr)
+ end
+
+ def parse(contents)
+ contents.each{|elem|
+ name,ty,num,enc,dec = parse_elem(elem)
+ @names.push(name)
+ @ty[name] = ty
+ @len[name] = num
+ @enc[name] = enc
+ @dec[name] = dec
+ if( num )
+ @tys += "#{ty}#{num}"
+ else
+ @tys += ty
+ end
+ }
+ @size = DL.sizeof(@tys)
+ end
+
+ def parse_elem(elem)
+ elem.strip!
+ case elem
+ when /^([\w\d_\*]+)([\*\s]+)([\w\d_]+)$/
+ ty = ($1 + $2).strip
+ name = $3
+ num = nil;
+ when /^([\w\d_\*]+)([\*\s]+)([\w\d_]+)\[(\d+)\]$/
+ ty = ($1 + $2).strip
+ name = $3
+ num = $4.to_i
+ else
+ raise(RuntimeError, "invalid element: #{elem}")
+ end
+ ty,_,_,enc,dec = @types.encode_type(ty)
+ return [name,ty,num,enc,dec]
+ end
+ end # class Struct
+
+ class Union < Struct
+ def new
+ ptr = DL::malloc(@size)
+ ptr.union!(@tys, *@names)
+ mem = Memory.new(ptr, @names, @ty, @len, @enc, @dec)
+ return mem
+ end
+ end
+ end # module Internal
+ end # module Importable
+end # module DL
diff --git a/ext/dl/lib/dl/types.rb b/ext/dl/lib/dl/types.rb
new file mode 100644
index 0000000000..139426473a
--- /dev/null
+++ b/ext/dl/lib/dl/types.rb
@@ -0,0 +1,180 @@
+# -*- ruby -*-
+
+require 'dl'
+
+module DL
+ class Types
+ TYPES = [
+ # FORMAT:
+ # ["alias name", "type name",
+ # encoding_method, decoding_method, for function prototypes
+ # encoding_method, decoding_method] for structures (not implemented)
+
+ # for Windows
+ ["DWORD", "unsigned long", nil, nil, nil, nil],
+ ["PDWORD", "unsigned long *", nil, nil, nil, nil],
+ ["WORD", "unsigned short", nil, nil, nil, nil],
+ ["PWORD", "unsigned int *", nil, nil, nil, nil],
+ ["BYTE", "unsigned char", nil, nil, nil, nil],
+ ["PBYTE", "unsigned char *", nil, nil, nil, nil],
+ ["BOOL", "ibool", nil, nil, nil, nil],
+ ["ATOM", "int", nil, nil, nil, nil],
+ ["BYTE", "unsigned char", nil, nil, nil, nil],
+ ["PBYTE", "unsigned char *", nil, nil, nil, nil],
+ ["UINT", "unsigned int", nil, nil, nil, nil],
+ ["ULONG", "unsigned long", nil, nil, nil, nil],
+ ["UCHAR", "unsigned char", nil, nil, nil, nil],
+ ["HANDLE", "unsigned long", nil, nil, nil, nil],
+ ["PHANDLE","void*", nil, nil, nil, nil],
+ ["PVOID", "void*", nil, nil, nil, nil],
+ ["LPCSTR", "char*", nil, nil, nil, nil],
+ ["HDC", "unsigned int", nil, nil, nil, nil],
+ ["HWND", "unsigned int", nil, nil, nil, nil],
+
+ # Others
+ ["uint", "unsigned int", nil, nil, nil, nil],
+ ["u_int", "unsigned int", nil, nil, nil, nil],
+ ["ulong", "unsigned long", nil, nil, nil, nil],
+ ["u_long", "unsigned long", nil, nil, nil, nil],
+
+ # DL::Importable primitive types
+ ["ibool", "I",
+ proc{|v| v ? 1 : 0},
+ proc{|v| (v != 0) ? true : false},
+ proc{|v| v ? 1 : 0 },
+ proc{|v| (v != 0) ? true : false} ],
+ ["cbool", "C",
+ proc{|v| v ? 1 : 0},
+ proc{|v| (v != 0) ? true : false},
+ proc{|v,len| v ? 1 : 0},
+ proc{|v,len| (v != 0) ? true : false}],
+ ["lbool", "L",
+ proc{|v| v ? 1 : 0},
+ proc{|v| (v != 0) ? true : false},
+ proc{|v,len| v ? 1 : 0},
+ proc{|v,len| (v != 0) ? true : false}],
+ ["unsigned char", "C",
+ proc{|v| [v].pack("C").unpack("c")[0]},
+ proc{|v| [v].pack("c").unpack("C")[0]},
+ proc{|v| [v].pack("C").unpack("c")[0]},
+ proc{|v| [v].pack("c").unpack("C")[0]}],
+ ["unsigned short", "H",
+ proc{|v| [v].pack("S").unpack("s")[0]},
+ proc{|v| [v].pack("s").unpack("S")[0]},
+ proc{|v| [v].pack("S").unpack("s")[0]},
+ proc{|v| [v].pack("s").unpack("S")[0]}],
+ ["unsigned int", "I",
+ proc{|v| [v].pack("I").unpack("i")[0]},
+ proc{|v| [v].pack("i").unpack("I")[0]},
+ proc{|v| [v].pack("I").unpack("i")[0]},
+ proc{|v| [v].pack("i").unpack("I")[0]}],
+ ["unsigned long", "L",
+ proc{|v| [v].pack("L").unpack("l")[0]},
+ proc{|v| [v].pack("l").unpack("L")[0]},
+ proc{|v| [v].pack("L").unpack("l")[0]},
+ proc{|v| [v].pack("l").unpack("L")[0]}],
+ ["unsigned char ref", "c",
+ proc{|v| [v].pack("C").unpack("c")[0]},
+ proc{|v| [v].pack("c").unpack("C")[0]},
+ nil, nil],
+ ["unsigned int ref", "i",
+ proc{|v| [v].pack("I").unpack("i")[0]},
+ proc{|v| [v].pack("i").unpack("I")[0]},
+ nil, nil],
+ ["unsigned long ref", "l",
+ proc{|v| [v].pack("L").unpack("l")[0]},
+ proc{|v| [v].pack("l").unpack("L")[0]},
+ nil, nil],
+ ["char ref", "c", nil, nil, nil, nil],
+ ["short ref", "h", nil, nil, nil, nil],
+ ["int ref", "i", nil, nil, nil, nil],
+ ["long ref", "l", nil, nil, nil, nil],
+ ["float ref", "f", nil, nil, nil, nil],
+ ["double ref","d", nil, nil, nil, nil],
+ ["char", "C", nil, nil, nil, nil],
+ ["short", "H", nil, nil, nil, nil],
+ ["int", "I", nil, nil, nil, nil],
+ ["long", "L", nil, nil, nil, nil],
+ ["float", "F", nil, nil, nil, nil],
+ ["double", "D", nil, nil, nil, nil],
+ [/^char\s*\*$/,"s",nil, nil, nil, nil],
+ [/^const char\s*\*$/,"S",nil, nil, nil, nil],
+ [/^.+\*$/, "p", nil, nil, nil, nil],
+ [/^.+\[\]$/, "a", nil, nil, nil, nil],
+ ["void", "0", nil, nil, nil, nil],
+ ]
+
+ def initialize
+ init_types()
+ end
+
+ def typealias(ty1, ty2, enc=nil, dec=nil, senc=nil, sdec=nil)
+ @TYDEFS.unshift([ty1,ty2, enc,dec, senc, sdec])
+ end
+
+ def init_types
+ @TYDEFS = TYPES.dup
+ end
+
+ def encode_type(ty)
+ orig_ty = ty
+ enc = nil
+ dec = nil
+ senc = nil
+ sdec = nil
+ @TYDEFS.each{|t1,t2,c1,c2,c3,c4|
+# if( t1.is_a?(String) )
+# t1 = Regexp.new("^" + t1 + "$")
+# end
+ if( (t1.is_a?(Regexp) && (t1 =~ ty)) || (t1 == ty) )
+ ty = ty.gsub(t1,t2)
+ if( enc )
+ if( c1 )
+ conv1 = enc
+ enc = proc{|v| c1.call(conv1.call(v))}
+ end
+ else
+ if( c1 )
+ enc = c1
+ end
+ end
+ if( dec )
+ if( c2 )
+ conv2 = dec
+ dec = proc{|v| c2.call(conv2.call(v))}
+ end
+ else
+ if( c2 )
+ dec = c2
+ end
+ end
+ if( senc )
+ if( c3 )
+ conv3 = senc
+ senc = proc{|v| c3.call(conv3.call(v))}
+ end
+ else
+ if( c3 )
+ senc = c3
+ end
+ end
+ if( sdec )
+ if( c4 )
+ conv4 = sdec
+ sdec = proc{|v| c4.call(conv4.call(v))}
+ end
+ else
+ if( c4 )
+ sdec = c4
+ end
+ end
+ end
+ }
+ ty = ty.strip
+ if( ty.length != 1 )
+ raise(TypeError, "unknown type: #{orig_ty}.")
+ end
+ return [ty,enc,dec,senc,sdec]
+ end
+ end # end of Types
+end
diff --git a/ext/dl/lib/dl/win32.rb b/ext/dl/lib/dl/win32.rb
new file mode 100644
index 0000000000..92f473d392
--- /dev/null
+++ b/ext/dl/lib/dl/win32.rb
@@ -0,0 +1,25 @@
+# -*- ruby -*-
+
+require 'dl'
+
+class Win32API
+ DLL = {}
+
+ def initialize(dllname, func, import, export = "0")
+ prototype = (export + import.to_s).tr("VPpNnLlIi", "0SSI")
+ handle = DLL[dllname] ||= DL::Handle.new(dllname)
+ @sym = handle.sym(func, prototype)
+ end
+
+ def call(*args)
+ import = @sym.proto.split("", 2)[1]
+ args.each_with_index do |x, i|
+ args[i] = nil if x == 0 and import[i] == ?S
+ args[i], = [x].pack("I").unpack("i") if import[i] == ?I
+ end
+ ret, = @sym.call(*args)
+ return ret || 0
+ end
+
+ alias Call call
+end
diff --git a/ext/dl/mkcall.rb b/ext/dl/mkcall.rb
new file mode 100644
index 0000000000..6a85570152
--- /dev/null
+++ b/ext/dl/mkcall.rb
@@ -0,0 +1,62 @@
+# -*- ruby -*-
+
+require 'mkmf'
+$:.unshift File.dirname(__FILE__)
+require 'type'
+require 'dlconfig'
+
+def output_arg(x,i)
+ "args[#{i}].#{DLTYPE[x][:stmem]}"
+end
+
+def output_args(types)
+ t = []
+ types[1..-1].each_with_index{|x,i| t.push(output_arg(x,i))}
+ t.join(",")
+end
+
+def output_callfunc(types)
+ t = types[0]
+ stmem = DLTYPE[t][:stmem]
+ ctypes = types2ctypes(types)
+ if( t == VOID )
+ callstm = "(*f)(#{output_args(types)})"
+ else
+ callstm = "ret.#{stmem} = (*f)(#{output_args(types)})"
+ end
+ [ "{",
+ "#{ctypes[0]} (*f)(#{ctypes[1..-1].join(',')}) = func;",
+ "#{callstm};",
+ "}"].join(" ")
+end
+
+def output_case(types)
+ num = types2num(types)
+ callfunc_stm = output_callfunc(types)
+<<EOF
+ case #{num}:
+#ifdef DEBUG
+ printf("#{callfunc_stm}\\n");
+#endif
+ #{callfunc_stm};
+ break;
+EOF
+end
+
+def rec_output(types = [VOID])
+ print output_case(types)
+ if( types.length <= MAX_ARG )
+ DLTYPE.keys.sort.each{|t|
+ if( t != VOID && DLTYPE[t][:sym] )
+ rec_output(types + [t])
+ end
+ }
+ end
+end
+
+DLTYPE.keys.sort.each{|t|
+ if( DLTYPE[t][:sym] )
+ $stderr.printf(" #{DLTYPE[t][:ctype]}\n")
+ rec_output([t])
+ end
+}
diff --git a/ext/dl/mkcallback.rb b/ext/dl/mkcallback.rb
new file mode 100644
index 0000000000..b7ea1718d0
--- /dev/null
+++ b/ext/dl/mkcallback.rb
@@ -0,0 +1,53 @@
+# -*- ruby -*-
+
+require 'mkmf'
+$:.unshift File.dirname(__FILE__)
+require 'type'
+require 'dlconfig'
+
+def mkfunc(rettype, fnum, argc)
+ args = (0..(argc-1)).collect{|i| "long arg#{i}"}.join(", ")
+
+ subst_code = (0..(argc-1)).collect{|i|
+ " buff[#{i.to_s}] = arg#{i.to_s};"
+ }.join("\n")
+
+ ret_code =
+ if( DLTYPE[rettype][:c2rb] )
+ " return #{DLTYPE[rettype][:rb2c]['retval']};"
+ else
+ " /* no return value */"
+ end
+
+ code = [
+ "static #{DLTYPE[rettype][:ctype]}",
+ "rb_dl_callback_func_#{rettype.to_s}_#{fnum.to_s}(#{args})",
+ "{",
+ " VALUE retval, proto, proc, obj;",
+ " VALUE argv[#{argc.to_s}];",
+ " int argc;",
+ " long buff[#{argc.to_s}];",
+ "",
+ subst_code,
+ "",
+ " obj = rb_hash_aref(DLFuncTable, rb_assoc_new(INT2NUM(#{rettype.to_s}),INT2NUM(#{fnum.to_s})));",
+ " proto = rb_ary_entry(obj, 0);",
+ " proc = rb_ary_entry(obj, 1);",
+ " Check_Type(proto, T_STRING);",
+ " if( RSTRING(proto)->len >= #{argc.to_s} )",
+ " rb_raise(rb_eArgError, \"too many arguments\");",
+ " rb_dl_scan_callback_args(buff, RSTRING(proto)->ptr, &argc, argv);",
+ " retval = rb_funcall2(proc, id_call, argc, argv);",
+ "",
+ ret_code,
+ "}",
+ ].join("\n")
+
+ return code
+end
+
+DLTYPE.keys.sort.each{|t|
+ for n in 0..(MAX_CALLBACK - 1)
+ print(mkfunc(t, n, 15), "\n\n")
+ end
+}
diff --git a/ext/dl/mkcbtable.rb b/ext/dl/mkcbtable.rb
new file mode 100644
index 0000000000..165c4bdc88
--- /dev/null
+++ b/ext/dl/mkcbtable.rb
@@ -0,0 +1,18 @@
+# -*- ruby -*-
+
+require 'mkmf'
+$:.unshift File.dirname(__FILE__)
+require 'type'
+require 'dlconfig'
+
+def mktable(rettype, fnum, argc)
+ code =
+ "rb_dl_callback_table[#{rettype}][#{fnum}] = &rb_dl_callback_func_#{rettype.to_s}_#{fnum};"
+ return code
+end
+
+DLTYPE.keys.sort.each{|t|
+ for n in 0..(MAX_CALLBACK - 1)
+ print(mktable(t, n, 15), "\n")
+ end
+}
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
new file mode 100644
index 0000000000..32f78c4de5
--- /dev/null
+++ b/ext/dl/ptr.c
@@ -0,0 +1,1065 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#include <ruby.h>
+#include <ctype.h>
+#include <version.h> /* for ruby version code */
+#include "dl.h"
+
+VALUE rb_cDLPtrData;
+VALUE rb_mDLMemorySpace;
+static VALUE DLMemoryTable;
+
+#ifndef T_SYMBOL
+# define T_SYMBOL T_FIXNUM
+#endif
+
+#if RUBY_VERSION_CODE < 171
+static VALUE
+rb_hash_delete(VALUE hash, VALUE key)
+{
+ return rb_funcall(hash, rb_intern("delete"), 1, key);
+}
+#endif
+
+static void
+rb_dlmem_delete(void *ptr)
+{
+ rb_secure(4);
+ rb_hash_delete(DLMemoryTable, DLLONG2NUM(ptr));
+}
+
+static void
+rb_dlmem_aset(void *ptr, VALUE obj)
+{
+ if (obj == Qnil) {
+ rb_dlmem_delete(ptr);
+ }
+ else{
+ rb_hash_aset(DLMemoryTable, DLLONG2NUM(ptr), DLLONG2NUM(obj));
+ }
+}
+
+static VALUE
+rb_dlmem_aref(void *ptr)
+{
+ VALUE val;
+
+ val = rb_hash_aref(DLMemoryTable, DLLONG2NUM(ptr));
+ return val == Qnil ? Qnil : (VALUE)DLNUM2LONG(val);
+}
+
+void
+dlptr_free(struct ptr_data *data)
+{
+ if (data->ptr) {
+ DEBUG_CODE({
+ printf("dlptr_free(): removing the pointer `0x%x' from the MemorySpace\n",
+ data->ptr);
+ });
+ rb_dlmem_delete(data->ptr);
+ if (data->free) {
+ DEBUG_CODE({
+ printf("dlptr_free(): 0x%x(data->ptr:0x%x)\n",data->free,data->ptr);
+ });
+ (*(data->free))(data->ptr);
+ }
+ }
+ if (data->stype) dlfree(data->stype);
+ if (data->ssize) dlfree(data->ssize);
+ if (data->ids) dlfree(data->ids);
+}
+
+void
+dlptr_init(VALUE val)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(val, struct ptr_data, data);
+ DEBUG_CODE({
+ printf("dlptr_init(): add the pointer `0x%x' to the MemorySpace\n",
+ data->ptr);
+ });
+ rb_dlmem_aset(data->ptr, val);
+ OBJ_TAINT(val);
+}
+
+VALUE
+rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
+{
+ struct ptr_data *data;
+ VALUE val;
+
+ rb_secure(4);
+ if (ptr) {
+ val = rb_dlmem_aref(ptr);
+ if (val == Qnil) {
+ val = Data_Make_Struct(klass, struct ptr_data,
+ 0, dlptr_free, data);
+ data->ptr = ptr;
+ data->free = func;
+ data->ctype = DLPTR_CTYPE_UNKNOWN;
+ data->stype = NULL;
+ data->ssize = NULL;
+ data->slen = 0;
+ data->size = size;
+ data->ids = NULL;
+ data->ids_num = 0;
+ dlptr_init(val);
+ }
+ else{
+ if (func) {
+ Data_Get_Struct(val, struct ptr_data, data);
+ data->free = func;
+ }
+ }
+ }
+ else{
+ val = Qnil;
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlptr_new(void *ptr, long size, freefunc_t func)
+{
+ return rb_dlptr_new2(rb_cDLPtrData, ptr, size, func);
+}
+
+VALUE
+rb_dlptr_malloc(long size, freefunc_t func)
+{
+ void *ptr;
+
+ rb_secure(4);
+ ptr = dlmalloc((size_t)size);
+ memset(ptr,0,(size_t)size);
+ return rb_dlptr_new(ptr, size, func);
+}
+
+void *
+rb_dlptr2cptr(VALUE val)
+{
+ struct ptr_data *data;
+ void *ptr;
+
+ if (rb_obj_is_kind_of(val, rb_cDLPtrData)) {
+ Data_Get_Struct(val, struct ptr_data, data);
+ ptr = data->ptr;
+ }
+ else if (val == Qnil) {
+ ptr = NULL;
+ }
+ else{
+ rb_raise(rb_eTypeError, "DL::PtrData was expected");
+ }
+
+ return ptr;
+}
+
+static VALUE
+rb_dlptr_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct ptr_data *data;
+
+ rb_secure(4);
+ obj = Data_Make_Struct(klass, struct ptr_data, 0, dlptr_free, data);
+ data->ptr = 0;
+ data->free = 0;
+ data->ctype = DLPTR_CTYPE_UNKNOWN;
+ data->stype = NULL;
+ data->ssize = NULL;
+ data->slen = 0;
+ data->size = 0;
+ data->ids = NULL;
+ data->ids_num = 0;
+
+ return obj;
+}
+
+static VALUE
+rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
+{
+ VALUE ptr, sym, size;
+ struct ptr_data *data;
+ void *p = NULL;
+ freefunc_t f = NULL;
+ long s = 0;
+
+ switch (rb_scan_args(argc, argv, "12", &ptr, &size, &sym)) {
+ case 1:
+ p = (void*)(DLNUM2LONG(rb_Integer(ptr)));
+ break;
+ case 2:
+ p = (void*)(DLNUM2LONG(rb_Integer(ptr)));
+ s = DLNUM2LONG(size);
+ break;
+ case 3:
+ p = (void*)(DLNUM2LONG(rb_Integer(ptr)));
+ s = DLNUM2LONG(size);
+ f = rb_dlsym2csym(sym);
+ break;
+ default:
+ rb_bug("rb_dlptr_initialize");
+ }
+
+ if (p) {
+ Data_Get_Struct(self, struct ptr_data, data);
+ if (data->ptr && data->free) {
+ /* Free previous memory. Use of inappropriate initialize may cause SEGV. */
+ (*(data->free))(data->ptr);
+ }
+ data->ptr = p;
+ data->size = s;
+ data->free = f;
+ }
+
+ return Qnil;
+}
+
+static VALUE
+rb_dlptr_s_malloc(int argc, VALUE argv[], VALUE klass)
+{
+ VALUE size, sym, obj;
+ int s;
+ freefunc_t f = NULL;
+
+ switch (rb_scan_args(argc, argv, "11", &size, &sym)) {
+ case 1:
+ s = NUM2INT(size);
+ break;
+ case 2:
+ s = NUM2INT(size);
+ f = rb_dlsym2csym(sym);
+ break;
+ default:
+ rb_bug("rb_dlptr_s_malloc");
+ }
+
+ obj = rb_dlptr_malloc(s,f);
+
+ return obj;
+}
+
+VALUE
+rb_dlptr_to_i(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return DLLONG2NUM(data->ptr);
+}
+
+VALUE
+rb_dlptr_ptr(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return rb_dlptr_new(*((void**)(data->ptr)),0,0);
+}
+
+VALUE
+rb_dlptr_ref(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return rb_dlptr_new(&(data->ptr),0,0);
+}
+
+VALUE
+rb_dlptr_null_p(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ return data->ptr ? Qfalse : Qtrue;
+}
+
+VALUE
+rb_dlptr_free_set(VALUE self, VALUE val)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+
+ data->free = DLFREEFUNC(rb_dlsym2csym(val));
+
+ return Qnil;
+}
+
+VALUE
+rb_dlptr_free_get(VALUE self)
+{
+ struct ptr_data *pdata;
+
+ Data_Get_Struct(self, struct ptr_data, pdata);
+
+ return rb_dlsym_new(pdata->free,"(free)","0P");
+}
+
+VALUE
+rb_dlptr_to_array(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ int n;
+ int i;
+ int t;
+ VALUE ary;
+ VALUE type, size;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+
+ switch (rb_scan_args(argc, argv, "11", &type, &size)) {
+ case 2:
+ t = StringValuePtr(type)[0];
+ n = NUM2INT(size);
+ break;
+ case 1:
+ t = StringValuePtr(type)[0];
+ switch (t) {
+ case 'C':
+ n = data->size;
+ break;
+ case 'H':
+ n = data->size / sizeof(short);
+ break;
+ case 'I':
+ n = data->size / sizeof(int);
+ break;
+ case 'L':
+ n = data->size / sizeof(long);
+ break;
+ case 'F':
+ n = data->size / sizeof(float);
+ break;
+ case 'D':
+ n = data->size / sizeof(double);
+ break;
+ case 'P': case 'p':
+ n = data->size / sizeof(void*);
+ break;
+ case 'S': case 's':
+ for (n=0; ((void**)(data->ptr))[n]; n++) {};
+ break;
+ default:
+ n = 0;
+ }
+ break;
+ default:
+ rb_bug("rb_dlptr_to_array");
+ }
+
+ ary = rb_ary_new();
+
+ for (i=0; i < n; i++) {
+ switch (t) {
+ case 'C':
+ rb_ary_push(ary, INT2NUM(((char*)(data->ptr))[i]));
+ break;
+ case 'H':
+ rb_ary_push(ary, INT2NUM(((short*)(data->ptr))[i]));
+ break;
+ case 'I':
+ rb_ary_push(ary, INT2NUM(((int*)(data->ptr))[i]));
+ break;
+ case 'L':
+ rb_ary_push(ary, DLLONG2NUM(((long*)(data->ptr))[i]));
+ break;
+ case 'D':
+ rb_ary_push(ary, rb_float_new(((double*)(data->ptr))[i]));
+ break;
+ case 'F':
+ rb_ary_push(ary, rb_float_new(((float*)(data->ptr))[i]));
+ break;
+ case 'S':
+ {
+ char *str = ((char**)(data->ptr))[i];
+ if (str) {
+ rb_ary_push(ary, rb_tainted_str_new2(str));
+ }
+ else{
+ rb_ary_push(ary, Qnil);
+ }
+ }
+ break;
+ case 's':
+ {
+ char *str = ((char**)(data->ptr))[i];
+ if (str) {
+ rb_ary_push(ary, rb_tainted_str_new2(str));
+ xfree(str);
+ }
+ else{
+ rb_ary_push(ary, Qnil);
+ }
+ }
+ break;
+ case 'P':
+ rb_ary_push(ary, rb_dlptr_new(((void**)(data->ptr))[i],0,0));
+ break;
+ case 'p':
+ rb_ary_push(ary,
+ rb_dlptr_new(((void**)(data->ptr))[i],0,dlfree));
+ break;
+ }
+ }
+
+ return ary;
+}
+
+
+VALUE
+rb_dlptr_to_s(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ VALUE arg1, val;
+ int len;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ switch (rb_scan_args(argc, argv, "01", &arg1)) {
+ case 0:
+ val = rb_tainted_str_new2((char*)(data->ptr));
+ break;
+ case 1:
+ len = NUM2INT(arg1);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
+ break;
+ default:
+ rb_bug("rb_dlptr_to_s");
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlptr_to_str(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ VALUE arg1, val;
+ int len;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ switch (rb_scan_args(argc, argv, "01", &arg1)) {
+ case 0:
+ val = rb_tainted_str_new((char*)(data->ptr),data->size);
+ break;
+ case 1:
+ len = NUM2INT(arg1);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
+ break;
+ default:
+ rb_bug("rb_dlptr_to_str");
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlptr_inspect(VALUE self)
+{
+ struct ptr_data *data;
+ char str[1024];
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ snprintf(str, 1023, "#<%s:0x%p ptr=0x%p size=%ld free=0x%p>",
+ rb_class2name(CLASS_OF(self)), data, data->ptr, data->size, data->free);
+ return rb_str_new2(str);
+}
+
+VALUE
+rb_dlptr_eql(VALUE self, VALUE other)
+{
+ void *ptr1, *ptr2;
+ ptr1 = rb_dlptr2cptr(self);
+ ptr2 = rb_dlptr2cptr(other);
+
+ return ptr1 == ptr2 ? Qtrue : Qfalse;
+}
+
+VALUE
+rb_dlptr_cmp(VALUE self, VALUE other)
+{
+ void *ptr1, *ptr2;
+ ptr1 = rb_dlptr2cptr(self);
+ ptr2 = rb_dlptr2cptr(other);
+ return DLLONG2NUM((long)ptr1 - (long)ptr2);
+}
+
+VALUE
+rb_dlptr_plus(VALUE self, VALUE other)
+{
+ void *ptr;
+ long num, size;
+
+ ptr = rb_dlptr2cptr(self);
+ size = RDLPTR(self)->size;
+ num = DLNUM2LONG(other);
+ return rb_dlptr_new((char *)ptr + num, size - num, 0);
+}
+
+VALUE
+rb_dlptr_minus(VALUE self, VALUE other)
+{
+ void *ptr;
+ long num, size;
+
+ ptr = rb_dlptr2cptr(self);
+ size = RDLPTR(self)->size;
+ num = DLNUM2LONG(other);
+ return rb_dlptr_new((char *)ptr - num, size + num, 0);
+}
+
+VALUE
+rb_dlptr_define_data_type(int argc, VALUE argv[], VALUE self)
+{
+ VALUE data_type, type, rest, vid;
+ struct ptr_data *data;
+ int i, t, num;
+ char *ctype;
+
+ rb_scan_args(argc, argv, "11*", &data_type, &type, &rest);
+ Data_Get_Struct(self, struct ptr_data, data);
+
+ if (argc == 1 || (argc == 2 && type == Qnil)) {
+ if (NUM2INT(data_type) == DLPTR_CTYPE_UNKNOWN) {
+ data->ctype = DLPTR_CTYPE_UNKNOWN;
+ data->slen = 0;
+ data->ids_num = 0;
+ if (data->stype) {
+ dlfree(data->stype);
+ data->stype = NULL;
+ }
+ if (data->ids) {
+ dlfree(data->ids);
+ data->ids = NULL;
+ }
+ return Qnil;
+ }
+ else{
+ rb_raise(rb_eArgError, "wrong arguments");
+ }
+ }
+
+ t = NUM2INT(data_type);
+ StringValue(type);
+ Check_Type(rest, T_ARRAY);
+ num = RARRAY(rest)->len;
+ for (i=0; i<num; i++) {
+ rb_to_id(rb_ary_entry(rest,i));
+ }
+
+ data->ctype = t;
+ data->slen = num;
+ data->ids_num = num;
+ if (data->stype) dlfree(data->stype);
+ data->stype = (char*)dlmalloc(sizeof(char) * num);
+ if (data->ssize) dlfree(data->ssize);
+ data->ssize = (int*)dlmalloc(sizeof(int) * num);
+ if (data->ids) dlfree(data->ids);
+ data->ids = (ID*)dlmalloc(sizeof(ID) * data->ids_num);
+
+ ctype = StringValuePtr(type);
+ for (i=0; i<num; i++) {
+ vid = rb_ary_entry(rest,i);
+ data->ids[i] = rb_to_id(vid);
+ data->stype[i] = *ctype;
+ ctype ++;
+ if (isdigit(*ctype)) {
+ char *p, *d;
+ for (p=ctype; isdigit(*p); p++) ;
+ d = ALLOCA_N(char, p - ctype + 1);
+ strncpy(d, ctype, p - ctype);
+ d[p - ctype] = '\0';
+ data->ssize[i] = atoi(d);
+ ctype = p;
+ }
+ else{
+ data->ssize[i] = 1;
+ }
+ }
+
+ if (*ctype) {
+ rb_raise(rb_eArgError, "too few/many arguments");
+ }
+
+ if (!data->size)
+ data->size = dlsizeof(RSTRING(type)->ptr);
+
+ return Qnil;
+}
+
+VALUE
+rb_dlptr_define_struct(int argc, VALUE argv[], VALUE self)
+{
+ VALUE *pass_argv;
+ int pass_argc, i;
+
+ pass_argc = argc + 1;
+ pass_argv = ALLOCA_N(VALUE, pass_argc);
+ pass_argv[0] = INT2FIX(DLPTR_CTYPE_STRUCT);
+ for (i=1; i<pass_argc; i++) {
+ pass_argv[i] = argv[i-1];
+ }
+ return rb_dlptr_define_data_type(pass_argc, pass_argv, self);
+}
+
+VALUE
+rb_dlptr_define_union(int argc, VALUE argv[], VALUE self)
+{
+ VALUE *pass_argv;
+ int pass_argc, i;
+
+ pass_argc = argc + 1;
+ pass_argv = ALLOCA_N(VALUE, pass_argc);
+ pass_argv[0] = INT2FIX(DLPTR_CTYPE_UNION);
+ for (i=1; i<pass_argc; i++) {
+ pass_argv[i] = argv[i-1];
+ }
+ return rb_dlptr_define_data_type(pass_argc, pass_argv, self);
+}
+
+VALUE
+rb_dlptr_get_data_type(VALUE self)
+{
+ struct ptr_data *data;
+
+ Data_Get_Struct(self, struct ptr_data, data);
+ if (data->stype)
+ return rb_assoc_new(INT2FIX(data->ctype),
+ rb_tainted_str_new(data->stype, data->slen));
+ else
+ return rb_assoc_new(INT2FIX(data->ctype), Qnil);
+}
+
+static VALUE
+cary2ary(void *ptr, char t, int len)
+{
+ VALUE ary;
+ VALUE elem;
+ int i;
+
+ if (len < 1)
+ return Qnil;
+
+ if (len == 1) {
+ switch (t) {
+ case 'I':
+ elem = INT2NUM(*((int*)ptr));
+ ptr = (char *)ptr + sizeof(int);
+ break;
+ case 'L':
+ elem = DLLONG2NUM(*((long*)ptr));
+ ptr = (char *)ptr + sizeof(long);
+ break;
+ case 'P':
+ case 'S':
+ elem = rb_dlptr_new(*((void**)ptr),0, 0);
+ ptr = (char *)ptr + sizeof(void*);
+ break;
+ case 'F':
+ elem = rb_float_new(*((float*)ptr));
+ ptr = (char *)ptr + sizeof(float);
+ break;
+ case 'D':
+ elem = rb_float_new(*((double*)ptr));
+ ptr = (char *)ptr + sizeof(double);
+ break;
+ case 'C':
+ elem = INT2NUM(*((char*)ptr));
+ ptr = (char *)ptr + sizeof(char);
+ break;
+ case 'H':
+ elem = INT2NUM(*((short*)ptr));
+ ptr = (char *)ptr + sizeof(short);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", t);
+ }
+ return elem;
+ }
+
+ ary = rb_ary_new();
+ for (i=0; i < len; i++) {
+ switch (t) {
+ case 'I':
+ elem = INT2NUM(*((int*)ptr));
+ ptr = (char *)ptr + sizeof(int);
+ break;
+ case 'L':
+ elem = DLLONG2NUM(*((long*)ptr));
+ ptr = (char *)ptr + sizeof(long);
+ break;
+ case 'P':
+ case 'S':
+ elem = rb_dlptr_new(*((void**)ptr), 0, 0);
+ ptr = (char *)ptr + sizeof(void*);
+ break;
+ case 'F':
+ elem = rb_float_new(*((float*)ptr));
+ ptr = (char *)ptr + sizeof(float);
+ break;
+ case 'D':
+ elem = rb_float_new(*((float*)ptr));
+ ptr = (char *)ptr + sizeof(double);
+ break;
+ case 'C':
+ elem = INT2NUM(*((char*)ptr));
+ ptr = (char *)ptr + sizeof(char);
+ break;
+ case 'H':
+ elem = INT2NUM(*((short*)ptr));
+ ptr = (char *)ptr + sizeof(short);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", t);
+ }
+ rb_ary_push(ary, elem);
+ }
+
+ return ary;
+}
+
+VALUE
+rb_dlptr_aref(int argc, VALUE argv[], VALUE self)
+{
+ VALUE key = Qnil, num = Qnil;
+ ID id;
+ struct ptr_data *data;
+ int i;
+ int offset;
+
+ if (rb_scan_args(argc, argv, "11", &key, &num) == 1) {
+ num = INT2NUM(0);
+ }
+
+ if (TYPE(key) == T_FIXNUM || TYPE(key) == T_BIGNUM) {
+ VALUE pass[1];
+ pass[0] = num;
+ return rb_dlptr_to_str(1, pass, rb_dlptr_plus(self, key));
+ }
+ rb_to_id(key);
+ if (! (TYPE(key) == T_STRING || TYPE(key) == T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "the key must be a string or symbol");
+ }
+
+ id = rb_to_id(key);
+ Data_Get_Struct(self, struct ptr_data, data);
+ offset = 0;
+ switch (data->ctype) {
+ case DLPTR_CTYPE_STRUCT:
+ for (i=0; i < data->ids_num; i++) {
+ if (data->ids[i] == id) {
+ switch (data->stype[i]) {
+ case 'I':
+ DLALIGN(data->ptr,offset,INT_ALIGN);
+ break;
+ case 'L':
+ DLALIGN(data->ptr,offset,LONG_ALIGN);
+ break;
+ case 'P':
+ case 'S':
+ DLALIGN(data->ptr,offset,VOIDP_ALIGN);
+ break;
+ case 'F':
+ DLALIGN(data->ptr,offset,FLOAT_ALIGN);
+ break;
+ case 'D':
+ DLALIGN(data->ptr,offset,DOUBLE_ALIGN);
+ break;
+ case 'C':
+ break;
+ case 'H':
+ DLALIGN(data->ptr,offset,SHORT_ALIGN);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ return cary2ary((char *)data->ptr + offset, data->stype[i], data->ssize[i]);
+ }
+ switch (data->stype[i]) {
+ case 'I':
+ offset += sizeof(int) * data->ssize[i];
+ break;
+ case 'L':
+ offset += sizeof(long) * data->ssize[i];
+ break;
+ case 'P':
+ case 'S':
+ offset += sizeof(void*) * data->ssize[i];
+ break;
+ case 'F':
+ offset += sizeof(float) * data->ssize[i];
+ break;
+ case 'D':
+ offset += sizeof(double) * data->ssize[i];
+ break;
+ case 'C':
+ offset += sizeof(char) * data->ssize[i];
+ break;
+ case 'H':
+ offset += sizeof(short) * data->ssize[i];
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ }
+ break;
+ case DLPTR_CTYPE_UNION:
+ for (i=0; i < data->ids_num; i++) {
+ if (data->ids[i] == id) {
+ return cary2ary((char *)data->ptr + offset, data->stype[i], data->ssize[i]);
+ }
+ }
+ break;
+ } /* end of switch */
+
+ rb_raise(rb_eNameError, "undefined key `%s' for %s",
+ rb_id2name(id), rb_class2name(CLASS_OF(self)));
+
+ return Qnil;
+}
+
+static void *
+ary2cary(char t, VALUE val, long *size)
+{
+ void *ptr;
+
+ if (TYPE(val) == T_ARRAY) {
+ ptr = rb_ary2cary(t, val, size);
+ }
+ else{
+ ptr = rb_ary2cary(t, rb_ary_new3(1, val), size);
+ }
+ return ptr;
+}
+
+VALUE
+rb_dlptr_aset(int argc, VALUE argv[], VALUE self)
+{
+ VALUE key = Qnil, num = Qnil, val = Qnil;
+ ID id;
+ struct ptr_data *data;
+ int i;
+ int offset;
+ long memsize;
+ void *memimg;
+
+ rb_secure(4);
+ switch (rb_scan_args(argc, argv, "21", &key, &num, &val)) {
+ case 2:
+ val = num;
+ num = Qnil;
+ break;
+ }
+
+ if (TYPE(key) == T_FIXNUM || TYPE(key) == T_BIGNUM) {
+ void *dst, *src;
+ long len;
+
+ StringValue(val);
+ Data_Get_Struct(self, struct ptr_data, data);
+ dst = (void*)((long)(data->ptr) + DLNUM2LONG(key));
+ src = RSTRING(val)->ptr;
+ len = RSTRING(val)->len;
+ if (num == Qnil) {
+ memcpy(dst, src, len);
+ }
+ else{
+ long n = NUM2INT(num);
+ memcpy(dst, src, n < len ? n : len);
+ if (n > len) MEMZERO((char*)dst + len, char, n - len);
+ }
+ return val;
+ }
+
+ id = rb_to_id(key);
+ Data_Get_Struct(self, struct ptr_data, data);
+ switch (data->ctype) {
+ case DLPTR_CTYPE_STRUCT:
+ offset = 0;
+ for (i=0; i < data->ids_num; i++) {
+ if (data->ids[i] == id) {
+ switch (data->stype[i]) {
+ case 'I':
+ DLALIGN(data->ptr,offset,INT_ALIGN);
+ break;
+ case 'L':
+ DLALIGN(data->ptr,offset,LONG_ALIGN);
+ break;
+ case 'P':
+ case 'S':
+ DLALIGN(data->ptr,offset,VOIDP_ALIGN);
+ break;
+ case 'D':
+ DLALIGN(data->ptr,offset,DOUBLE_ALIGN);
+ break;
+ case 'F':
+ DLALIGN(data->ptr,offset,FLOAT_ALIGN);
+ break;
+ case 'C':
+ break;
+ case 'H':
+ DLALIGN(data->ptr,offset,SHORT_ALIGN);
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ memimg = ary2cary(data->stype[i], val, &memsize);
+ memcpy((char *)data->ptr + offset, memimg, memsize);
+ return val;
+ }
+ switch (data->stype[i]) {
+ case 'I':
+ case 'i':
+ offset += sizeof(int) * data->ssize[i];
+ break;
+ case 'L':
+ case 'l':
+ offset += sizeof(long) * data->ssize[i];
+ break;
+ case 'P':
+ case 'p':
+ case 'S':
+ case 's':
+ offset += sizeof(void*) * data->ssize[i];
+ break;
+ case 'D':
+ case 'd':
+ offset += sizeof(double) * data->ssize[i];
+ break;
+ case 'F':
+ case 'f':
+ offset += sizeof(float) * data->ssize[i];
+ break;
+ case 'C':
+ case 'c':
+ offset += sizeof(char) * data->ssize[i];
+ break;
+ case 'H':
+ case 'h':
+ offset += sizeof(short) * data->ssize[i];
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ }
+ return val;
+ /* break; */
+ case DLPTR_CTYPE_UNION:
+ for (i=0; i < data->ids_num; i++) {
+ if (data->ids[i] == id) {
+ switch (data->stype[i]) {
+ case 'I': case 'i':
+ memsize = sizeof(int) * data->ssize[i];
+ break;
+ case 'L': case 'l':
+ memsize = sizeof(long) * data->ssize[i];
+ break;
+ case 'P': case 'p':
+ case 'S': case 's':
+ memsize = sizeof(void*) * data->ssize[i];
+ break;
+ case 'F': case 'f':
+ memsize = sizeof(float) * data->ssize[i];
+ break;
+ case 'D': case 'd':
+ memsize = sizeof(double) * data->ssize[i];
+ break;
+ case 'C': case 'c':
+ memsize = sizeof(char) * data->ssize[i];
+ break;
+ case 'H': case 'h':
+ memsize = sizeof(short) * data->ssize[i];
+ break;
+ default:
+ rb_raise(rb_eDLTypeError, "unsupported type '%c'", data->stype[i]);
+ }
+ memimg = ary2cary(data->stype[i], val, NULL);
+ memcpy(data->ptr, memimg, memsize);
+ }
+ }
+ return val;
+ /* break; */
+ }
+
+ rb_raise(rb_eNameError, "undefined key `%s' for %s",
+ rb_id2name(id), rb_class2name(CLASS_OF(self)));
+
+ return Qnil;
+}
+
+VALUE
+rb_dlptr_size(int argc, VALUE argv[], VALUE self)
+{
+ VALUE size;
+
+ if (rb_scan_args(argc, argv, "01", &size) == 0){
+ return DLLONG2NUM(RDLPTR(self)->size);
+ }
+ else{
+ RDLPTR(self)->size = DLNUM2LONG(size);
+ return size;
+ }
+}
+
+static VALUE
+dlmem_each_i(VALUE assoc, void *data)
+{
+ VALUE key, val;
+ key = rb_ary_entry(assoc, 0);
+ val = rb_ary_entry(assoc, 1);
+ rb_yield(rb_assoc_new(key,(VALUE)DLNUM2LONG(val)));
+ return Qnil;
+}
+
+VALUE
+rb_dlmem_each(VALUE self)
+{
+ rb_iterate(rb_each, DLMemoryTable, dlmem_each_i, 0);
+ return Qnil;
+}
+
+void
+Init_dlptr()
+{
+ rb_cDLPtrData = rb_define_class_under(rb_mDL, "PtrData", rb_cObject);
+ rb_define_alloc_func(rb_cDLPtrData, rb_dlptr_s_allocate);
+ rb_define_singleton_method(rb_cDLPtrData, "malloc", rb_dlptr_s_malloc, -1);
+ rb_define_method(rb_cDLPtrData, "initialize", rb_dlptr_initialize, -1);
+ rb_define_method(rb_cDLPtrData, "free=", rb_dlptr_free_set, 1);
+ rb_define_method(rb_cDLPtrData, "free", rb_dlptr_free_get, 0);
+ rb_define_method(rb_cDLPtrData, "to_i", rb_dlptr_to_i, 0);
+ rb_define_method(rb_cDLPtrData, "ptr", rb_dlptr_ptr, 0);
+ rb_define_method(rb_cDLPtrData, "+@", rb_dlptr_ptr, 0);
+ rb_define_method(rb_cDLPtrData, "ref", rb_dlptr_ref, 0);
+ rb_define_method(rb_cDLPtrData, "-@", rb_dlptr_ref, 0);
+ rb_define_method(rb_cDLPtrData, "null?", rb_dlptr_null_p, 0);
+ rb_define_method(rb_cDLPtrData, "to_a", rb_dlptr_to_array, -1);
+ rb_define_method(rb_cDLPtrData, "to_s", rb_dlptr_to_s, -1);
+ rb_define_method(rb_cDLPtrData, "to_str", rb_dlptr_to_str, -1);
+ rb_define_method(rb_cDLPtrData, "inspect", rb_dlptr_inspect, 0);
+ rb_define_method(rb_cDLPtrData, "<=>", rb_dlptr_cmp, 1);
+ rb_define_method(rb_cDLPtrData, "==", rb_dlptr_eql, 1);
+ rb_define_method(rb_cDLPtrData, "eql?", rb_dlptr_eql, 1);
+ rb_define_method(rb_cDLPtrData, "+", rb_dlptr_plus, 1);
+ rb_define_method(rb_cDLPtrData, "-", rb_dlptr_minus, 1);
+ rb_define_method(rb_cDLPtrData, "define_data_type",
+ rb_dlptr_define_data_type, -1);
+ rb_define_method(rb_cDLPtrData, "struct!", rb_dlptr_define_struct, -1);
+ rb_define_method(rb_cDLPtrData, "union!", rb_dlptr_define_union, -1);
+ rb_define_method(rb_cDLPtrData, "data_type", rb_dlptr_get_data_type, 0);
+ rb_define_method(rb_cDLPtrData, "[]", rb_dlptr_aref, -1);
+ rb_define_method(rb_cDLPtrData, "[]=", rb_dlptr_aset, -1);
+ rb_define_method(rb_cDLPtrData, "size", rb_dlptr_size, -1);
+ rb_define_method(rb_cDLPtrData, "size=", rb_dlptr_size, -1);
+
+ rb_mDLMemorySpace = rb_define_module_under(rb_mDL, "MemorySpace");
+ DLMemoryTable = rb_hash_new();
+ rb_define_const(rb_mDLMemorySpace, "MemoryTable", DLMemoryTable);
+ rb_define_module_function(rb_mDLMemorySpace, "each", rb_dlmem_each, 0);
+}
diff --git a/ext/dl/sample/c++sample.C b/ext/dl/sample/c++sample.C
new file mode 100644
index 0000000000..d083d337a7
--- /dev/null
+++ b/ext/dl/sample/c++sample.C
@@ -0,0 +1,35 @@
+#include <stdio.h>
+
+class Person {
+private:
+ const char *name;
+ int age;
+
+public:
+ Person(const char *name, int age);
+ const char * get_name();
+ int get_age();
+ void set_age(int i);
+};
+
+Person::Person(const char *name, int age)
+ : name(name), age(age)
+{
+ /* empty */
+}
+
+const char *
+Person::get_name()
+{
+ return name;
+}
+
+int
+Person::get_age(){
+ return age;
+}
+
+void
+Person::set_age(int i){
+ age = i;
+}
diff --git a/ext/dl/sample/c++sample.rb b/ext/dl/sample/c++sample.rb
new file mode 100644
index 0000000000..29887df845
--- /dev/null
+++ b/ext/dl/sample/c++sample.rb
@@ -0,0 +1,60 @@
+=begin
+ This script shows how to deal with C++ classes using Ruby/DL.
+ You must build a dynamic loadable library using "c++sample.C"
+ to run this script as follows:
+ $ g++ -o libsample.so -shared c++sample.C
+=end
+
+require 'dl'
+require 'dl/import'
+require 'dl/struct'
+
+# Give a name of dynamic loadable library
+LIBNAME = ARGV[0] || "libsample.so"
+
+class Person
+ module Core
+ extend DL::Importable
+
+ dlload LIBNAME
+
+ # mangled symbol names
+ extern "void __6PersonPCci(void *, const char *, int)"
+ extern "const char *get_name__6Person(void *)"
+ extern "int get_age__6Person(void *)"
+ extern "void set_age__6Personi(void *, int)"
+
+ Data = struct [
+ "char *name",
+ "int age",
+ ]
+ end
+
+ def initialize(name, age)
+ @ptr = Core::Data.alloc
+ Core::__6PersonPCci(@ptr, name, age)
+ end
+
+ def get_name()
+ str = Core::get_name__6Person(@ptr)
+ if( str )
+ str.to_s
+ else
+ nil
+ end
+ end
+
+ def get_age()
+ Core::get_age__6Person(@ptr)
+ end
+
+ def set_age(age)
+ Core::set_age__6Personi(@ptr, age)
+ end
+end
+
+obj = Person.new("ttate", 1)
+p obj.get_name()
+p obj.get_age()
+obj.set_age(10)
+p obj.get_age()
diff --git a/ext/dl/sample/drives.rb b/ext/dl/sample/drives.rb
new file mode 100644
index 0000000000..8a590404b1
--- /dev/null
+++ b/ext/dl/sample/drives.rb
@@ -0,0 +1,70 @@
+# -*- ruby -*-
+# drives.rb -- find existing drives and show the drive type.
+
+require 'dl'
+require 'dl/import'
+
+module Kernel32
+ extend DL::Importable
+
+ dlload "kernel32"
+
+ extern "long GetLogicalDrives()"
+ extern "int GetDriveType(char*)"
+ extern "long GetDiskFreeSpace(char*, long ref, long ref, long ref, long ref)"
+end
+
+include Kernel32
+
+buff = Kernel32.getLogicalDrives()
+
+i = 0
+ds = []
+while( i < 26 )
+ mask = (1 << i)
+ if( buff & mask > 0 )
+ ds.push((65+i).chr)
+ end
+ i += 1
+end
+
+=begin
+From the cygwin's /usr/include/w32api/winbase.h:
+#define DRIVE_UNKNOWN 0
+#define DRIVE_NO_ROOT_DIR 1
+#define DRIVE_REMOVABLE 2
+#define DRIVE_FIXED 3
+#define DRIVE_REMOTE 4
+#define DRIVE_CDROM 5
+#define DRIVE_RAMDISK 6
+=end
+
+types = [
+ "unknown",
+ "no root dir",
+ "Removable",
+ "Fixed",
+ "Remote",
+ "CDROM",
+ "RAM",
+]
+print("Drive : Type (Free Space/Available Space)\n")
+ds.each{|d|
+ t = Kernel32.getDriveType(d + ":\\")
+ Kernel32.getDiskFreeSpace(d + ":\\", 0, 0, 0, 0)
+ _,sec_per_clus,byte_per_sec,free_clus,total_clus = Kernel32._args_
+ fbytes = sec_per_clus * byte_per_sec * free_clus
+ tbytes = sec_per_clus * byte_per_sec * total_clus
+ unit = "B"
+ if( fbytes > 1024 && tbytes > 1024 )
+ fbytes = fbytes / 1024
+ tbytes = tbytes / 1024
+ unit = "K"
+ end
+ if( fbytes > 1024 && tbytes > 1024 )
+ fbytes = fbytes / 1024
+ tbytes = tbytes / 1024
+ unit = "M"
+ end
+ print("#{d} : #{types[t]} (#{fbytes} #{unit}/#{tbytes} #{unit})\n")
+}
diff --git a/ext/dl/sample/getch.rb b/ext/dl/sample/getch.rb
new file mode 100644
index 0000000000..3f7261c979
--- /dev/null
+++ b/ext/dl/sample/getch.rb
@@ -0,0 +1,5 @@
+require 'dl'
+
+crtdll = DL::dlopen("crtdll")
+getch = crtdll['_getch', 'L']
+print(getch.call, "\n")
diff --git a/ext/dl/sample/libc.rb b/ext/dl/sample/libc.rb
new file mode 100644
index 0000000000..a1f6fbe543
--- /dev/null
+++ b/ext/dl/sample/libc.rb
@@ -0,0 +1,69 @@
+require "dl/import"
+require "dl/struct"
+
+module LIBC
+ extend DL::Importable
+
+ begin
+ dlload "libc.so.6"
+ rescue
+ dlload "libc.so.5"
+ end
+
+ extern "int atoi(char*)"
+ extern "ibool isdigit(int)"
+ extern "int gettimeofday(struct timeval *, struct timezone *)"
+ extern "char* strcat(char*, char*)"
+ extern "FILE* fopen(char*, char*)"
+ extern "int fclose(FILE*)"
+ extern "int fgetc(FILE*)"
+ extern "int strlen(char*)"
+ extern "void qsort(void*, int, int, void*)"
+
+ def str_qsort(ary, comp)
+ len = ary.length
+ r,rs = qsort(ary, len, DL.sizeof('P'), comp)
+ return rs[0].to_a('S', len)
+ end
+
+ Timeval = struct [
+ "long tv_sec",
+ "long tv_usec",
+ ]
+
+ Timezone = struct [
+ "int tz_minuteswest",
+ "int tz_dsttime",
+ ]
+
+ def my_compare(ptr1, ptr2)
+ ptr1.ptr.to_s <=> ptr2.ptr.to_s
+ end
+ COMPARE = callback("int my_compare(char**, char**)")
+end
+
+
+$cb1 = DL.callback('IPP'){|ptr1, ptr2|
+ str1 = ptr1.ptr.to_s
+ str2 = ptr2.ptr.to_s
+ str1 <=> str2
+}
+
+p LIBC.atoi("10")
+
+p LIBC.isdigit(?1)
+
+p LIBC.isdigit(?a)
+
+p LIBC.strcat("a", "b")
+
+ary = ["a","c","b"]
+ptr = ary.to_ptr
+LIBC.qsort(ptr, ary.length, DL.sizeof('P'), LIBC::COMPARE)
+p ptr.to_a('S', ary.length)
+
+tv = LIBC::Timeval.malloc
+tz = LIBC::Timezone.malloc
+LIBC.gettimeofday(tv, tz)
+
+p Time.at(tv.tv_sec)
diff --git a/ext/dl/sample/msgbox.rb b/ext/dl/sample/msgbox.rb
new file mode 100644
index 0000000000..091e646091
--- /dev/null
+++ b/ext/dl/sample/msgbox.rb
@@ -0,0 +1,19 @@
+# This script works on Windows.
+
+require 'dl'
+
+User32 = DL.dlopen("user32")
+Kernel32 = DL.dlopen("kernel32")
+
+MB_OK = 0
+MB_OKCANCEL = 1
+
+message_box = User32['MessageBoxA', 'ILSSI']
+r,rs = message_box.call(0, 'ok?', 'error', MB_OKCANCEL)
+
+case r
+when 1
+ print("OK!\n")
+when 2
+ print("Cancel!\n")
+end
diff --git a/ext/dl/sample/msgbox2.rb b/ext/dl/sample/msgbox2.rb
new file mode 100644
index 0000000000..e49846cc5e
--- /dev/null
+++ b/ext/dl/sample/msgbox2.rb
@@ -0,0 +1,18 @@
+# This script works on Windows.
+
+require 'dl/win32'
+
+MB_OK = 0
+MB_OKCANCEL = 1
+
+message_box = Win32API.new("user32",'MessageBoxA', 'ISSI', 'I')
+r = message_box.call(0, 'ok?', 'error', MB_OKCANCEL)
+
+case r
+when 1
+ print("OK!\n")
+when 2
+ print("Cancel!\n")
+else
+ p r
+end
diff --git a/ext/dl/sample/stream.rb b/ext/dl/sample/stream.rb
new file mode 100644
index 0000000000..179836999d
--- /dev/null
+++ b/ext/dl/sample/stream.rb
@@ -0,0 +1,87 @@
+# -*- ruby -*-
+# Display a file name and stream names of a file with those size.
+
+require 'dl'
+require 'dl/import'
+
+module NTFS
+ extend DL::Importable
+
+ dlload "kernel32.dll"
+
+ OPEN_EXISTING = 3
+ GENERIC_READ = 0x80000000
+ BACKUP_DATA = 0x00000001
+ BACKUP_ALTERNATE_DATA = 0x00000004
+ FILE_SHARE_READ = 0x00000001
+ FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
+
+ typealias "LPSECURITY_ATTRIBUTES", "void*"
+
+ extern "BOOL BackupRead(HANDLE, PBYTE, DWORD, PDWORD, BOOL, BOOL, PVOID)"
+ extern "BOOL BackupSeek(HANDLE, DWORD, DWORD, PDWORD, PDWORD, PVOID)"
+ extern "BOOL CloseHandle(HANDLE)"
+ extern "HANDLE CreateFile(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES,
+ DWORD, DWORD, HANDLE)"
+
+ module_function
+
+ def streams(filename)
+ status = []
+ h = createFile(filename,GENERIC_READ,FILE_SHARE_READ,nil,
+ OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0)
+ if( h != 0 )
+ begin
+ # allocate the memory for backup data used in backupRead().
+ data = DL.malloc(DL.sizeof("L5"))
+ data.struct!("LLLLL", :id, :attrs, :size_low, :size_high, :name_size)
+
+ # allocate memories for references to long values used in backupRead().
+ context = DL.malloc(DL.sizeof("L"))
+ lval = DL.malloc(DL.sizeof("L"))
+
+ while( backupRead(h, data, data.size, lval, false, false, context) )
+ size = data[:size_low] + (data[:size_high] << (DL.sizeof("I") * 8))
+ case data[:id]
+ when BACKUP_ALTERNATE_DATA
+ stream_name = DL.malloc(data[:name_size])
+ backupRead(h, stream_name, stream_name.size,
+ lval, false, false, context)
+ name = stream_name[0, stream_name.size]
+ name.tr!("\000","")
+ if( name =~ /^:(.*?):.*$/ )
+ status.push([$1,size])
+ end
+ when BACKUP_DATA
+ status.push([nil,size])
+ else
+ raise(RuntimeError, "unknown data type #{data[:id]}.")
+ end
+ l1 = DL.malloc(DL.sizeof("L"))
+ l2 = DL.malloc(DL.sizeof("L"))
+ if( !backupSeek(h, data[:size_low], data[:size_high], l1, l2, context) )
+ break
+ end
+ end
+ ensure
+ backupRead(h, nil, 0, lval, true, false, context)
+ closeHandle(h)
+ end
+ return status
+ else
+ raise(RuntimeError, "can't open #{filename}.\n")
+ end
+ end
+end
+
+ARGV.each{|filename|
+ if( File.exist?(filename) )
+ NTFS.streams(filename).each{|name,size|
+ if( name )
+ print("#{filename}:#{name}\t#{size}bytes\n")
+ else
+ print("#{filename}\t#{size}bytes\n")
+ end
+ }
+ end
+}
diff --git a/ext/dl/sym.c b/ext/dl/sym.c
new file mode 100644
index 0000000000..c2f5434c61
--- /dev/null
+++ b/ext/dl/sym.c
@@ -0,0 +1,990 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#include <ruby.h>
+#include <errno.h>
+#include "dl.h"
+
+VALUE rb_cDLSymbol;
+
+static const char *
+char2type(int ch)
+{
+ switch (ch) {
+ case '0':
+ return "void";
+ case 'P':
+ return "void *";
+ case 'p':
+ return "void *";
+ case 'C':
+ return "char";
+ case 'c':
+ return "char *";
+ case 'H':
+ return "short";
+ case 'h':
+ return "short *";
+ case 'I':
+ return "int";
+ case 'i':
+ return "int *";
+ case 'L':
+ return "long";
+ case 'l':
+ return "long *";
+ case 'F':
+ return "double";
+ case 'f':
+ return "double *";
+ case 'D':
+ return "double";
+ case 'd':
+ return "double *";
+ case 'S':
+ return "const char *";
+ case 's':
+ return "char *";
+ case 'A':
+ return "[]";
+ case 'a':
+ return "[]"; /* ?? */
+ }
+ return NULL;
+}
+
+void
+dlsym_free(struct sym_data *data)
+{
+ if( data->name ){
+ DEBUG_CODE({
+ printf("dlsym_free(): free(data->name:%s)\n",data->name);
+ });
+ free(data->name);
+ }
+ if( data->type ){
+ DEBUG_CODE({
+ printf("dlsym_free(): free(data->type:%s)\n",data->type);
+ });
+ free(data->type);
+ }
+}
+
+VALUE
+rb_dlsym_new(void (*func)(), const char *name, const char *type)
+{
+ VALUE val;
+ struct sym_data *data;
+ const char *ptype;
+
+ rb_secure(4);
+ if( !type || !type[0] ){
+ return rb_dlptr_new((void*)func, 0, 0);
+ }
+
+ for( ptype = type; *ptype; ptype ++ ){
+ if( ! char2type(*ptype) ){
+ rb_raise(rb_eDLTypeError, "unknown type specifier '%c'", *ptype);
+ }
+ }
+
+ if( func ){
+ val = Data_Make_Struct(rb_cDLSymbol, struct sym_data, 0, dlsym_free, data);
+ data->func = func;
+ data->name = name ? strdup(name) : NULL;
+ data->type = type ? strdup(type) : NULL;
+ data->len = type ? strlen(type) : 0;
+#if !(defined(DLSTACK))
+ if( data->len - 1 > MAX_ARG ){
+ rb_raise(rb_eDLError, "maximum number of arguments is %d.", MAX_ARG);
+ }
+#endif
+ }
+ else{
+ val = Qnil;
+ }
+
+ return val;
+}
+
+freefunc_t
+rb_dlsym2csym(VALUE val)
+{
+ struct sym_data *data;
+ freefunc_t func;
+
+ if( rb_obj_is_kind_of(val, rb_cDLSymbol) ){
+ Data_Get_Struct(val, struct sym_data, data);
+ func = data->func;
+ }
+ else if( val == Qnil ){
+ func = NULL;
+ }
+ else{
+ rb_raise(rb_eTypeError, "DL::Symbol was expected");
+ }
+
+ return func;
+}
+
+VALUE
+rb_dlsym_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct sym_data *data;
+
+ obj = Data_Make_Struct(klass, struct sym_data, 0, dlsym_free, data);
+ data->func = 0;
+ data->name = 0;
+ data->type = 0;
+ data->len = 0;
+
+ return obj;
+}
+
+VALUE
+rb_dlsym_initialize(int argc, VALUE argv[], VALUE self)
+{
+ VALUE addr, name, type;
+ struct sym_data *data;
+ void *saddr;
+ const char *sname, *stype;
+
+ rb_scan_args(argc, argv, "12", &addr, &name, &type);
+
+ saddr = (void*)(DLNUM2LONG(rb_Integer(addr)));
+ sname = NIL_P(name) ? NULL : StringValuePtr(name);
+ stype = NIL_P(type) ? NULL : StringValuePtr(type);
+
+ if( saddr ){
+ Data_Get_Struct(self, struct sym_data, data);
+ if( data->name ) free(data->name);
+ if( data->type ) free(data->type);
+ data->func = saddr;
+ data->name = sname ? strdup(sname) : 0;
+ data->type = stype ? strdup(stype) : 0;
+ data->len = stype ? strlen(stype) : 0;
+ }
+
+ return Qnil;
+}
+
+VALUE
+rb_s_dlsym_char2type(VALUE self, VALUE ch)
+{
+ const char *type;
+
+ type = char2type(StringValuePtr(ch)[0]);
+
+ if (type == NULL)
+ return Qnil;
+ else
+ return rb_str_new2(type);
+}
+
+VALUE
+rb_dlsym_name(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return sym->name ? rb_tainted_str_new2(sym->name) : Qnil;
+}
+
+VALUE
+rb_dlsym_proto(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return sym->type ? rb_tainted_str_new2(sym->type) : Qnil;
+}
+
+VALUE
+rb_dlsym_cproto(VALUE self)
+{
+ struct sym_data *sym;
+ const char *ptype, *typestr;
+ size_t len;
+ VALUE val;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+
+ ptype = sym->type;
+
+ if( ptype ){
+ typestr = char2type(*ptype++);
+ len = strlen(typestr);
+
+ val = rb_tainted_str_new(typestr, len);
+ if (typestr[len - 1] != '*')
+ rb_str_cat(val, " ", 1);
+
+ if( sym->name ){
+ rb_str_cat2(val, sym->name);
+ }
+ else{
+ rb_str_cat2(val, "(null)");
+ }
+ rb_str_cat(val, "(", 1);
+
+ while (*ptype) {
+ const char *ty = char2type(*ptype++);
+ rb_str_cat2(val, ty);
+ if (*ptype)
+ rb_str_cat(val, ", ", 2);
+ }
+
+ rb_str_cat(val, ");", 2);
+ }
+ else{
+ val = rb_tainted_str_new2("void (");
+ if( sym->name ){
+ rb_str_cat2(val, sym->name);
+ }
+ else{
+ rb_str_cat2(val, "(null)");
+ }
+ rb_str_cat2(val, ")()");
+ }
+
+ return val;
+}
+
+VALUE
+rb_dlsym_inspect(VALUE self)
+{
+ VALUE proto;
+ VALUE val;
+ char *str;
+ int str_size;
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ proto = rb_dlsym_cproto(self);
+
+ str_size = RSTRING(proto)->len + 100;
+ str = dlmalloc(str_size);
+ snprintf(str, str_size - 1,
+ "#<DL::Symbol:0x%p func=0x%p '%s'>",
+ sym, sym->func, RSTRING(proto)->ptr);
+ val = rb_tainted_str_new2(str);
+ dlfree(str);
+
+ return val;
+}
+
+static int
+stack_size(struct sym_data *sym)
+{
+ int i;
+ int size;
+
+ size = 0;
+ for( i=1; i < sym->len; i++ ){
+ switch(sym->type[i]){
+ case 'C':
+ case 'H':
+ case 'I':
+ case 'L':
+ size += sizeof(long);
+ break;
+ case 'F':
+ size += sizeof(float);
+ break;
+ case 'D':
+ size += sizeof(double);
+ break;
+ case 'c':
+ case 'h':
+ case 'i':
+ case 'l':
+ case 'f':
+ case 'd':
+ case 'p':
+ case 'P':
+ case 's':
+ case 'S':
+ case 'a':
+ case 'A':
+ size += sizeof(void*);
+ break;
+ default:
+ return -(sym->type[i]);
+ }
+ }
+ return size;
+}
+
+static ID rb_dl_id_DLErrno;
+
+static VALUE
+rb_dl_get_last_error(VALUE self)
+{
+ return rb_thread_local_aref(rb_thread_current(), rb_dl_id_DLErrno);
+}
+
+static VALUE
+rb_dl_set_last_error(VALUE self, VALUE val)
+{
+ errno = NUM2INT(val);
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLErrno, val);
+ return Qnil;
+}
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+static ID rb_dl_id_DLW32Error;
+
+static VALUE
+rb_dl_win32_get_last_error(VALUE self)
+{
+ return rb_thread_local_aref(rb_thread_current(), rb_dl_id_DLW32Error);
+}
+
+static VALUE
+rb_dl_win32_set_last_error(VALUE self, VALUE val)
+{
+ SetLastError(NUM2INT(val));
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLW32Error, val);
+ return Qnil;
+}
+#endif
+
+#ifdef DLSTACK_GUARD
+# ifdef __MSVC_RUNTIME_CHECKS
+# pragma runtime_checks("s", off)
+# endif
+# if _MSC_VER >= 1300
+__declspec(noinline)
+# endif
+static int
+rb_dlsym_guardcall(char type, ANY_TYPE *ret, long *stack, void *func)
+{
+ char *volatile guard = ALLOCA_N(char, 1); /* guard stack pointer */
+ switch(type){
+ case '0':
+ {
+ void (*f)(DLSTACK_PROTO) = func;
+ f(DLSTACK_ARGS);
+ }
+ break;
+ case 'P':
+ case 'p':
+ {
+ void * (*f)(DLSTACK_PROTO) = func;
+ ret->p = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'C':
+ case 'c':
+ {
+ char (*f)(DLSTACK_PROTO) = func;
+ ret->c = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'H':
+ case 'h':
+ {
+ short (*f)(DLSTACK_PROTO) = func;
+ ret->h = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'I':
+ case 'i':
+ {
+ int (*f)(DLSTACK_PROTO) = func;
+ ret->i = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'L':
+ case 'l':
+ {
+ long (*f)(DLSTACK_PROTO) = func;
+ ret->l = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'F':
+ case 'f':
+ {
+ float (*f)(DLSTACK_PROTO) = func;
+ ret->f = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'D':
+ case 'd':
+ {
+ double (*f)(DLSTACK_PROTO) = func;
+ ret->d = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'S':
+ case 's':
+ {
+ char * (*f)(DLSTACK_PROTO) = func;
+ ret->s = f(DLSTACK_ARGS);
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+# ifdef __MSVC_RUNTIME_CHECKS
+# pragma runtime_checks("s", restore)
+# endif
+#endif /* defined(DLSTACK_GUARD) */
+
+VALUE
+rb_dlsym_call(int argc, VALUE argv[], VALUE self)
+{
+ struct sym_data *sym;
+ ANY_TYPE *args;
+ ANY_TYPE *dargs;
+ ANY_TYPE ret;
+ int *dtypes;
+ VALUE val;
+ VALUE dvals;
+ int i;
+ long ftype;
+ void *func;
+
+ rb_secure_update(self);
+ Data_Get_Struct(self, struct sym_data, sym);
+ DEBUG_CODE({
+ printf("rb_dlsym_call(): type = '%s', func = 0x%x\n", sym->type, sym->func);
+ });
+ if( (sym->len - 1) != argc ){
+ rb_raise(rb_eArgError, "%d arguments are needed", sym->len - 1);
+ }
+
+ ftype = 0;
+ dvals = Qnil;
+
+ args = ALLOC_N(ANY_TYPE, sym->len - 1);
+ dargs = ALLOC_N(ANY_TYPE, sym->len - 1);
+ dtypes = ALLOC_N(int, sym->len - 1);
+#define FREE_ARGS {xfree(args); xfree(dargs); xfree(dtypes);}
+
+ for( i = sym->len - 2; i >= 0; i-- ){
+ dtypes[i] = 0;
+
+ switch( sym->type[i+1] ){
+ case 'p':
+ dtypes[i] = 'p';
+ case 'P':
+ {
+ struct ptr_data *data;
+ VALUE pval;
+
+ if( argv[i] == Qnil ){
+ ANY2P(args[i]) = DLVOIDP(0);
+ }
+ else{
+ if( rb_obj_is_kind_of(argv[i], rb_cDLPtrData) ){
+ pval = argv[i];
+ }
+ else{
+ pval = rb_funcall(argv[i], rb_intern("to_ptr"), 0);
+ if( !rb_obj_is_kind_of(pval, rb_cDLPtrData) ){
+ rb_raise(rb_eDLTypeError, "unexpected type of argument #%d", i);
+ }
+ }
+ Data_Get_Struct(pval, struct ptr_data, data);
+ ANY2P(args[i]) = DLVOIDP(data->ptr);
+ }
+ }
+ PUSH_P(ftype);
+ break;
+ case 'a':
+ dtypes[i] = 'a';
+ case 'A':
+ if( argv[i] == Qnil ){
+ ANY2P(args[i]) = DLVOIDP(0);
+ }
+ else{
+ ANY2P(args[i]) = DLVOIDP(rb_ary2cary(0, argv[i], NULL));
+ }
+ PUSH_P(ftype);
+ break;
+ case 'C':
+ ANY2C(args[i]) = DLCHAR(NUM2CHR(argv[i]));
+ PUSH_C(ftype);
+ break;
+ case 'c':
+ ANY2C(dargs[i]) = DLCHAR(NUM2CHR(argv[i]));
+ ANY2P(args[i]) = DLVOIDP(&(ANY2C(dargs[i])));
+ dtypes[i] = 'c';
+ PUSH_P(ftype);
+ break;
+ case 'H':
+ ANY2H(args[i]) = DLSHORT(NUM2INT(argv[i]));
+ PUSH_C(ftype);
+ break;
+ case 'h':
+ ANY2H(dargs[i]) = DLSHORT(NUM2INT(argv[i]));
+ ANY2P(args[i]) = DLVOIDP(&(ANY2H(dargs[i])));
+ dtypes[i] = 'h';
+ PUSH_P(ftype);
+ break;
+ case 'I':
+ ANY2I(args[i]) = DLINT(NUM2INT(argv[i]));
+ PUSH_I(ftype);
+ break;
+ case 'i':
+ ANY2I(dargs[i]) = DLINT(NUM2INT(argv[i]));
+ ANY2P(args[i]) = DLVOIDP(&(ANY2I(dargs[i])));
+ dtypes[i] = 'i';
+ PUSH_P(ftype);
+ break;
+ case 'L':
+ ANY2L(args[i]) = DLNUM2LONG(argv[i]);
+ PUSH_L(ftype);
+ break;
+ case 'l':
+ ANY2L(dargs[i]) = DLNUM2LONG(argv[i]);
+ ANY2P(args[i]) = DLVOIDP(&(ANY2L(dargs[i])));
+ dtypes[i] = 'l';
+ PUSH_P(ftype);
+ break;
+ case 'F':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2F(args[i]) = DLFLOAT(RFLOAT(argv[i])->value);
+ PUSH_F(ftype);
+ break;
+ case 'f':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2F(dargs[i]) = DLFLOAT(RFLOAT(argv[i])->value);
+ ANY2P(args[i]) = DLVOIDP(&(ANY2F(dargs[i])));
+ dtypes[i] = 'f';
+ PUSH_P(ftype);
+ break;
+ case 'D':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2D(args[i]) = RFLOAT(argv[i])->value;
+ PUSH_D(ftype);
+ break;
+ case 'd':
+ Check_Type(argv[i], T_FLOAT);
+ ANY2D(dargs[i]) = RFLOAT(argv[i])->value;
+ ANY2P(args[i]) = DLVOIDP(&(ANY2D(dargs[i])));
+ dtypes[i] = 'd';
+ PUSH_P(ftype);
+ break;
+ case 'S':
+ if( argv[i] == Qnil ){
+ ANY2S(args[i]) = DLSTR(0);
+ }
+ else{
+ VALUE str = argv[i];
+ SafeStringValue(str);
+ ANY2S(args[i]) = DLSTR(RSTRING(str)->ptr);
+ }
+ PUSH_P(ftype);
+ break;
+ case 's':
+ {
+ VALUE str = argv[i];
+ SafeStringValue(str);
+ ANY2S(args[i]) = DLSTR(dlmalloc(RSTRING(str)->len + 1));
+ memcpy((char*)(ANY2S(args[i])), RSTRING(str)->ptr, RSTRING(str)->len + 1);
+ dtypes[i] = 's';
+ }
+ PUSH_P(ftype);
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError,
+ "unknown type '%c' of the return value.",
+ sym->type[i+1]);
+ }
+ }
+
+ switch( sym->type[0] ){
+ case '0':
+ PUSH_0(ftype);
+ break;
+ case 'P':
+ case 'p':
+ case 'S':
+ case 's':
+ case 'A':
+ case 'a':
+ PUSH_P(ftype);
+ break;
+ case 'C':
+ case 'c':
+ PUSH_C(ftype);
+ break;
+ case 'H':
+ case 'h':
+ PUSH_H(ftype);
+ break;
+ case 'I':
+ case 'i':
+ PUSH_I(ftype);
+ break;
+ case 'L':
+ case 'l':
+ PUSH_L(ftype);
+ break;
+ case 'F':
+ case 'f':
+ PUSH_F(ftype);
+ break;
+ case 'D':
+ case 'd':
+ PUSH_D(ftype);
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError,
+ "unknown type `%c' of the return value.",
+ sym->type[0]);
+ }
+
+ func = sym->func;
+
+#if defined(DLSTACK)
+ {
+#if defined(DLSTACK_SIZE)
+ int stk_size;
+ long stack[DLSTACK_SIZE];
+ long *sp;
+
+ sp = stack;
+ stk_size = stack_size(sym);
+ if( stk_size < 0 ){
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type '%c'.", -stk_size);
+ }
+ else if( stk_size > (int)(DLSTACK_SIZE) ){
+ FREE_ARGS;
+ rb_raise(rb_eArgError, "too many arguments.");
+ }
+#endif
+
+ DLSTACK_START(sym);
+
+#if defined(DLSTACK_REVERSE)
+ for( i = sym->len - 2; i >= 0; i-- )
+#else
+ for( i = 0; i <= sym->len -2; i++ )
+#endif
+ {
+ switch( sym->type[i+1] ){
+ case 'p':
+ case 'P':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'a':
+ case 'A':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'C':
+ DLSTACK_PUSH_C(ANY2C(args[i]));
+ break;
+ case 'c':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'H':
+ DLSTACK_PUSH_H(ANY2H(args[i]));
+ break;
+ case 'h':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'I':
+ DLSTACK_PUSH_I(ANY2I(args[i]));
+ break;
+ case 'i':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'L':
+ DLSTACK_PUSH_L(ANY2L(args[i]));
+ break;
+ case 'l':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'F':
+ DLSTACK_PUSH_F(ANY2F(args[i]));
+ break;
+ case 'f':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'D':
+ DLSTACK_PUSH_D(ANY2D(args[i]));
+ break;
+ case 'd':
+ DLSTACK_PUSH_P(ANY2P(args[i]));
+ break;
+ case 'S':
+ case 's':
+ DLSTACK_PUSH_P(ANY2S(args[i]));
+ break;
+ }
+ }
+ DLSTACK_END(sym->type);
+
+#ifdef DLSTACK_GUARD
+ if(!rb_dlsym_guardcall(sym->type[0], &ret, stack, func)) {
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type `%c'", sym->type[0]);
+ }
+#else /* defined(DLSTACK_GUARD) */
+ {
+ switch( sym->type[0] ){
+ case '0':
+ {
+ void (*f)(DLSTACK_PROTO) = func;
+ f(DLSTACK_ARGS);
+ }
+ break;
+ case 'P':
+ case 'p':
+ {
+ void * (*f)(DLSTACK_PROTO) = func;
+ ret.p = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'C':
+ case 'c':
+ {
+ char (*f)(DLSTACK_PROTO) = func;
+ ret.c = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'H':
+ case 'h':
+ {
+ short (*f)(DLSTACK_PROTO) = func;
+ ret.h = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'I':
+ case 'i':
+ {
+ int (*f)(DLSTACK_PROTO) = func;
+ ret.i = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'L':
+ case 'l':
+ {
+ long (*f)(DLSTACK_PROTO) = func;
+ ret.l = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'F':
+ case 'f':
+ {
+ float (*f)(DLSTACK_PROTO) = func;
+ ret.f = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'D':
+ case 'd':
+ {
+ double (*f)(DLSTACK_PROTO) = func;
+ ret.d = f(DLSTACK_ARGS);
+ }
+ break;
+ case 'S':
+ case 's':
+ {
+ char * (*f)(DLSTACK_PROTO) = func;
+ ret.s = f(DLSTACK_ARGS);
+ }
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type `%c'", sym->type[0]);
+ }
+ }
+#endif /* defubed(DLSTACK_GUARD) */
+
+ {
+ /*
+ * We should get the value of errno/GetLastError() before calling another functions.
+ */
+ int last_errno = errno;
+#ifdef _WIN32
+ DWORD win32_last_err = GetLastError();
+#endif
+
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLErrno, INT2NUM(last_errno));
+#ifdef _WIN32
+ rb_thread_local_aset(rb_thread_current(), rb_dl_id_DLW32Error, INT2NUM(win32_last_err));
+#endif
+ }
+
+ }
+#else /* defined(DLSTACK) */
+ switch(ftype){
+#include "call.func"
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unsupported function type `%s'", sym->type);
+ }
+#endif /* defined(DLSTACK) */
+
+ switch( sym->type[0] ){
+ case '0':
+ val = Qnil;
+ break;
+ case 'P':
+ val = rb_dlptr_new((void*)(ANY2P(ret)), 0, 0);
+ break;
+ case 'p':
+ val = rb_dlptr_new((void*)(ANY2P(ret)), 0, dlfree);
+ break;
+ case 'C':
+ case 'c':
+ val = CHR2FIX((char)(ANY2C(ret)));
+ break;
+ case 'H':
+ case 'h':
+ val = INT2NUM((short)(ANY2H(ret)));
+ break;
+ case 'I':
+ case 'i':
+ val = INT2NUM((int)(ANY2I(ret)));
+ break;
+ case 'L':
+ case 'l':
+ val = DLLONG2NUM((long)(ANY2L(ret)));
+ break;
+ case 'F':
+ case 'f':
+ val = rb_float_new((double)(ANY2F(ret)));
+ break;
+ case 'D':
+ case 'd':
+ val = rb_float_new((double)(ANY2D(ret)));
+ break;
+ case 'S':
+ if( ANY2S(ret) ){
+ val = rb_tainted_str_new2((char*)(ANY2S(ret)));
+ }
+ else{
+ val = Qnil;
+ }
+ break;
+ case 's':
+ if( ANY2S(ret) ){
+ val = rb_tainted_str_new2((char*)(ANY2S(ret)));
+ DEBUG_CODE({
+ printf("dlfree(%s)\n",(char*)(ANY2S(ret)));
+ });
+ dlfree((void*)(ANY2S(ret)));
+ }
+ else{
+ val = Qnil;
+ }
+ break;
+ default:
+ FREE_ARGS;
+ rb_raise(rb_eDLTypeError, "unknown type `%c'", sym->type[0]);
+ }
+
+ dvals = rb_ary_new();
+ for( i = 0; i <= sym->len - 2; i++ ){
+ if( dtypes[i] ){
+ switch( dtypes[i] ){
+ case 'c':
+ rb_ary_push(dvals, CHR2FIX(*((char*)(ANY2P(args[i])))));
+ break;
+ case 'h':
+ rb_ary_push(dvals, INT2NUM(*((short*)(ANY2P(args[i])))));
+ break;
+ case 'i':
+ rb_ary_push(dvals, INT2NUM(*((int*)(ANY2P(args[i])))));
+ break;
+ case 'l':
+ rb_ary_push(dvals, DLLONG2NUM(*((long*)(ANY2P(args[i])))));
+ break;
+ case 'f':
+ rb_ary_push(dvals, rb_float_new(*((float*)(ANY2P(args[i])))));
+ break;
+ case 'd':
+ rb_ary_push(dvals, rb_float_new(*((double*)(ANY2P(args[i])))));
+ break;
+ case 'p':
+ rb_ary_push(dvals, rb_dlptr_new((void*)(ANY2P(args[i])), 0, 0));
+ break;
+ case 'a':
+ rb_ary_push(dvals, rb_dlptr_new((void*)ANY2P(args[i]), 0, 0));
+ break;
+ case 's':
+ rb_ary_push(dvals, rb_tainted_str_new2((char*)ANY2S(args[i])));
+ DEBUG_CODE({
+ printf("dlfree(%s)\n",(char*)ANY2S(args[i]));
+ });
+ dlfree((void*)ANY2S(args[i]));
+ break;
+ default:
+ {
+ char c = dtypes[i];
+ FREE_ARGS;
+ rb_raise(rb_eRuntimeError, "unknown argument type '%c'", i, c);
+ }
+ }
+ }
+ else{
+ switch( sym->type[i+1] ){
+ case 'A':
+ dlfree((void*)ANY2P(args[i]));
+ break;
+ }
+ rb_ary_push(dvals, argv[i]);
+ }
+ }
+
+#undef FREE_ARGS
+ return rb_assoc_new(val,dvals);
+}
+
+VALUE
+rb_dlsym_to_i(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return DLLONG2NUM(sym);
+}
+
+VALUE
+rb_dlsym_to_ptr(VALUE self)
+{
+ struct sym_data *sym;
+
+ Data_Get_Struct(self, struct sym_data, sym);
+ return rb_dlptr_new(sym->func, sizeof(freefunc_t), 0);
+}
+
+void
+Init_dlsym()
+{
+ rb_cDLSymbol = rb_define_class_under(rb_mDL, "Symbol", rb_cObject);
+ rb_define_alloc_func(rb_cDLSymbol, rb_dlsym_s_allocate);
+ rb_define_singleton_method(rb_cDLSymbol, "char2type", rb_s_dlsym_char2type, 1);
+ rb_define_method(rb_cDLSymbol, "initialize", rb_dlsym_initialize, -1);
+ rb_define_method(rb_cDLSymbol, "call", rb_dlsym_call, -1);
+ rb_define_method(rb_cDLSymbol, "[]", rb_dlsym_call, -1);
+ rb_define_method(rb_cDLSymbol, "name", rb_dlsym_name, 0);
+ rb_define_method(rb_cDLSymbol, "proto", rb_dlsym_proto, 0);
+ rb_define_method(rb_cDLSymbol, "cproto", rb_dlsym_cproto, 0);
+ rb_define_method(rb_cDLSymbol, "inspect", rb_dlsym_inspect, 0);
+ rb_define_method(rb_cDLSymbol, "to_s", rb_dlsym_cproto, 0);
+ rb_define_method(rb_cDLSymbol, "to_ptr", rb_dlsym_to_ptr, 0);
+ rb_define_method(rb_cDLSymbol, "to_i", rb_dlsym_to_i, 0);
+
+ rb_dl_id_DLErrno = rb_intern("DLErrno");
+ rb_define_singleton_method(rb_mDL, "last_error", rb_dl_get_last_error, 0);
+ rb_define_singleton_method(rb_mDL, "last_error=", rb_dl_set_last_error, 1);
+#ifdef _WIN32
+ rb_dl_id_DLW32Error = rb_intern("DLW32Error");
+ rb_define_singleton_method(rb_mDL, "win32_last_error", rb_dl_win32_get_last_error, 0);
+ rb_define_singleton_method(rb_mDL, "win32_last_error=", rb_dl_win32_set_last_error, 1);
+#endif
+}
diff --git a/ext/dl/test/libtest.def b/ext/dl/test/libtest.def
new file mode 100644
index 0000000000..8ecefc917b
--- /dev/null
+++ b/ext/dl/test/libtest.def
@@ -0,0 +1,28 @@
+EXPORTS
+test_alloc_test_struct
+test_append
+test_arylen
+test_c2i
+test_call_func1
+test_callback1
+test_close
+test_d2f
+test_f2d
+test_fill_test_struct
+test_fill_test_union
+test_gets
+test_i2c
+test_init
+test_isucc
+test_lcc
+test_lsucc
+test_open
+test_strcat
+test_strlen
+test_succ
+test_data_init
+test_data_add
+test_data_aref
+test_set_long_value
+test_get_long_value
+internal_long_value
diff --git a/ext/dl/test/test.c b/ext/dl/test/test.c
new file mode 100644
index 0000000000..7321379390
--- /dev/null
+++ b/ext/dl/test/test.c
@@ -0,0 +1,247 @@
+#include <stdio.h>
+#include <string.h>
+
+static char internal_string[] = "internal_string";
+long internal_long_value = 100;
+
+struct test_struct {
+ char c;
+ long l;
+};
+
+union test_union {
+ char c;
+ int i;
+ long l;
+ void *p;
+};
+
+struct test_data {
+ char name[1024];
+ struct test_data *next;
+};
+
+long
+test_get_long_value()
+{
+ return internal_long_value;
+};
+
+void
+test_set_long_value(long l)
+{
+ internal_long_value = l;
+};
+
+void
+test_fill_test_struct(struct test_struct *ptr, char c, long l)
+{
+ ptr->c = c;
+ ptr->l = l;
+};
+
+void
+test_fill_test_union(union test_union *ptr, long l)
+{
+ ptr->l = l;
+};
+
+struct test_struct *
+test_alloc_test_struct(char c, long l)
+{
+ struct test_struct *data;
+
+ data = (struct test_struct *)malloc(sizeof(struct test_struct));
+ data->c = c;
+ data->l = l;
+
+ return data;
+};
+
+int
+test_c2i(char c)
+{
+ return (int)c;
+};
+
+char
+test_i2c(int i)
+{
+ return (char)i;
+};
+
+long
+test_lcc(char c1, char c2)
+{
+ return (long)(c1 + c2);
+};
+
+double
+test_f2d(float f)
+{
+ double d;
+ d = f;
+ return d;
+};
+
+float
+test_d2f(double d)
+{
+ float f;
+ f = d;
+ return f;
+};
+
+int
+test_strlen(const char *str)
+{
+ return strlen(str);
+};
+
+int
+test_isucc(int i)
+{
+ return (i+1);
+};
+
+long
+test_lsucc(long l)
+{
+ return (l+1);
+};
+
+void
+test_succ(long *l)
+{
+ (*l)++;
+};
+
+char *
+test_strcat(char *str1, const char *str2)
+{
+ return strcat(str1, str2);
+};
+
+int
+test_arylen(char *ary[])
+{
+ int i;
+ for( i=0; ary[i]; i++ ){};
+ return i;
+};
+
+void
+test_append(char *ary[], int len, char *astr)
+{
+ int i;
+ int size1,size2;
+ char *str;
+
+ size2 = strlen(astr);
+
+ for( i=0; i <= len - 1; i++ ){
+ size1 = strlen(ary[i]);
+ str = (char*)malloc(size1 + size2 + 1);
+ strcpy(str, ary[i]);
+ strcat(str, astr);
+ ary[i] = str;
+ };
+};
+
+int
+test_init(int *argc, char **argv[])
+{
+ int i;
+ char s[256];
+
+ for( i=0; i < (*argc); i++ ){
+ sprintf(s, "arg%d", i);
+ if( strcmp((*argv)[i], s) != 0 ){
+ return 1;
+ }
+ }
+ return 0;
+}
+
+FILE *
+test_open(const char *filename, const char *mode)
+{
+ FILE *file;
+ file = fopen(filename,mode);
+ return file;
+};
+
+void
+test_close(FILE *file)
+{
+ fclose(file);
+};
+
+char *
+test_gets(char *s, int size, FILE *f)
+{
+ return fgets(s,size,f);
+};
+
+typedef int callback1_t(int, char *);
+#define CALLBACK_MSG "callback message"
+
+int
+test_callback1(int err, const char *msg)
+{
+ if( strcmp(msg, CALLBACK_MSG) == 0 ){
+ return 1;
+ }
+ else{
+ return 0;
+ }
+}
+
+int
+test_call_func1(callback1_t *func)
+{
+ if( func ){
+ return (*func)(0, CALLBACK_MSG);
+ }
+ else{
+ return 0;
+ }
+}
+
+struct test_data *
+test_data_init()
+{
+ struct test_data *data;
+
+ data = (struct test_data *)malloc(sizeof(struct test_data));
+ data->next = NULL;
+ memset(data->name, 0, 1024);
+
+ return data;
+};
+
+void
+test_data_add(struct test_data *list, const char *name)
+{
+ struct test_data *data;
+
+ data = (struct test_data *)malloc(sizeof(struct test_data));
+ memset(data->name, 0, 1024);
+ strncpy(data->name, name, 1024);
+ data->next = list->next;
+ list->next = data;
+};
+
+struct test_data *
+test_data_aref(struct test_data *list, int i)
+{
+ struct test_data *data;
+ int j;
+
+ for( data = list->next, j=0; data; data = data->next, j++ ){
+ if( i == j ){
+ return data;
+ };
+ };
+ return NULL;
+};
diff --git a/ext/dl/test/test.rb b/ext/dl/test/test.rb
new file mode 100644
index 0000000000..52be04699f
--- /dev/null
+++ b/ext/dl/test/test.rb
@@ -0,0 +1,295 @@
+# -*- ruby -*-
+
+require 'dl'
+require 'dl/import'
+
+$FAIL = 0
+$TOTAL = 0
+
+def assert(label, ty, *conds)
+ $TOTAL += 1
+ cond = !conds.include?(false)
+ if( cond )
+ printf("succeed in `#{label}'\n")
+ else
+ $FAIL += 1
+ case ty
+ when :may
+ printf("fail in `#{label}' ... expected\n")
+ when :must
+ printf("fail in `#{label}' ... unexpected\n")
+ when :raise
+ raise(RuntimeError, "fail in `#{label}'")
+ end
+ end
+end
+
+def debug(*xs)
+ if( $DEBUG )
+ xs.each{|x|
+ p x
+ }
+ end
+end
+
+print("DLSTACK = #{DL::DLSTACK}\n")
+print("MAX_ARG = #{DL::MAX_ARG}\n")
+print("\n")
+print("DL::FREE = #{DL::FREE.inspect}\n")
+print("\n")
+
+$LIB = nil
+if( !$LIB && File.exist?("libtest.so") )
+ $LIB = "./libtest.so"
+end
+if( !$LIB && File.exist?("test/libtest.so") )
+ $LIB = "./test/libtest.so"
+end
+
+module LIBTest
+ extend DL::Importable
+
+ dlload($LIB)
+ extern "int test_c2i(char)"
+ extern "char test_i2c(int)"
+ extern "long test_lcc(char, char)"
+ extern "double test_f2d(float)"
+ extern "float test_d2f(double)"
+ extern "int test_strlen(char*)"
+ extern "int test_isucc(int)"
+ extern "long test_lsucc(long)"
+ extern "void test_succ(long *)"
+ extern "int test_arylen(int [])"
+ extern "void test_append(char*[], int, char *)"
+end
+
+DL.dlopen($LIB){|h|
+ c2i = h["test_c2i","IC"]
+ debug c2i
+ r,rs = c2i[?a]
+ debug r,rs
+ assert("c2i", :may, r == ?a)
+ assert("extern c2i", :must, r == LIBTest.test_c2i(?a))
+
+ i2c = h["test_i2c","CI"]
+ debug i2c
+ r,rs = i2c[?a]
+ debug r,rs
+ assert("i2c", :may, r == ?a)
+ assert("exern i2c", :must, r == LIBTest.test_i2c(?a))
+
+ lcc = h["test_lcc","LCC"]
+ debug lcc
+ r,rs = lcc[1,2]
+ assert("lcc", :may, r == 3)
+ assert("extern lcc", :must, r == LIBTest.test_lcc(1,2))
+
+ f2d = h["test_f2d","DF"]
+ debug f2d
+ r,rs = f2d[20.001]
+ debug r,rs
+ assert("f2d", :may, r.to_i == 20)
+ assert("extern f2d", :must, r = LIBTest.test_f2d(20.001))
+
+ d2f = h["test_d2f","FD"]
+ debug d2f
+ r,rs = d2f[20.001]
+ debug r,rs
+ assert("d2f", :may, r.to_i == 20)
+ assert("extern d2f", :must, r == LIBTest.test_d2f(20.001))
+
+ strlen = h["test_strlen","IS"]
+ debug strlen
+ r,rs = strlen["0123456789"]
+ debug r,rs
+ assert("strlen", :must, r == 10)
+ assert("extern strlen", :must, r == LIBTest.test_strlen("0123456789"))
+
+ isucc = h["test_isucc","II"]
+ debug isucc
+ r,rs = isucc[2]
+ debug r,rs
+ assert("isucc", :must, r == 3)
+ assert("extern isucc", :must, r == LIBTest.test_isucc(2))
+
+ lsucc = h["test_lsucc","LL"]
+ debug lsucc
+ r,rs = lsucc[10000000]
+ debug r,rs
+ assert("lsucc", :must, r == 10000001)
+ assert("extern lsucc", :must, r == LIBTest.test_lsucc(10000000))
+
+ succ = h["test_succ","0l"]
+ debug succ
+ r,rs = succ[0]
+ debug r,rs
+ assert("succ", :must, rs[0] == 1)
+ l = DL.malloc(DL.sizeof("L"))
+ l.struct!("L",:lval)
+ LIBTest.test_succ(l)
+ assert("extern succ", :must, rs[0] == l[:lval])
+
+ arylen = h["test_arylen","IA"]
+ debug arylen
+ r,rs = arylen[["a","b","c","d",nil]]
+ debug r,rs
+ assert("arylen", :must, r == 4)
+
+ arylen = h["test_arylen","IP"]
+ debug arylen
+ r,rs = arylen[["a","b","c","d",nil]]
+ debug r,rs
+ assert("arylen", :must, r == 4)
+ assert("extern arylen", :must, r == LIBTest.test_arylen(["a","b","c","d",nil]))
+
+ append = h["test_append","0aIS"]
+ debug append
+ r,rs = append[["a","b","c"],3,"x"]
+ debug r,rs
+ assert("append", :must, rs[0].to_a('S',3) == ["ax","bx","cx"])
+
+ LIBTest.test_append(["a","b","c"],3,"x")
+ assert("extern append", :must, rs[0].to_a('S',3) == LIBTest._args_[0].to_a('S',3))
+
+ strcat = h["test_strcat","SsS"]
+ debug strcat
+ r,rs = strcat["abc\0","x"]
+ debug r,rs
+ assert("strcat", :must, rs[0].to_s == "abcx")
+
+ init = h["test_init","IiP"]
+ debug init
+ argc = 3
+ argv = ["arg0","arg1","arg2"].to_ptr
+ r,rs = init[argc, argv.ref]
+ assert("init", :must, r == 0)
+}
+
+
+h = DL.dlopen($LIB)
+
+sym_open = h["test_open", "PSS"]
+sym_gets = h["test_gets", "SsIP"]
+sym_close = h["test_close", "0P"]
+debug sym_open,sym_gets,sym_close
+
+line = "Hello world!\n"
+File.open("tmp.txt", "w"){|f|
+ f.print(line)
+}
+
+fp,rs = sym_open["tmp.txt", "r"]
+if( fp )
+ fp.free = sym_close
+ r,rs = sym_gets[" " * 256, 256, fp]
+ debug r,rs
+ assert("open,gets", :must, rs[0] == line)
+ ObjectSpace.define_finalizer(fp) {File.unlink("tmp.txt")}
+ fp = nil
+else
+ assert("open,gets", :must, line == nil)
+ File.unlink("tmp.txt")
+end
+
+
+callback1 = h["test_callback1"]
+debug callback1
+r,rs = h["test_call_func1", "IP"][callback1]
+debug r,rs
+assert("callback1", :must, r == 1)
+
+
+callback2 = DL.callback("LLP"){|num,ptr|
+ msg = ptr.to_s
+ if( msg == "callback message" )
+ 2
+ else
+ 0
+ end
+}
+debug callback2
+r,rs = h["test_call_func1", "IP"][callback2]
+debug r,rs
+assert("callback2", :must, r == 2)
+DL.remove_callback(callback2)
+
+ptr = DL.malloc(DL.sizeof('CL'))
+ptr.struct!("CL", :c, :l)
+ptr["c"] = 0
+ptr["l"] = 0
+r,rs = h["test_fill_test_struct","0PIL"][ptr,100,1000]
+debug r,rs
+assert("fill_test_struct", :must, ptr["c"] == 100, ptr["l"] == 1000)
+assert("fill_test_struct", :must, ptr[:c] == 100, ptr[:l] == 1000) unless (Fixnum === :-)
+
+
+r,rs = h["test_alloc_test_struct", "PIL"][100,200]
+r.free = DL::FREE
+r.struct!("CL", :c, :l)
+assert("alloc_test_struct", :must, r["c"] == 100, r["l"] == 200)
+assert("alloc_test_struct", :must, r[:c] == 100, r[:l] == 200) unless (Fixnum === :-)
+
+ptr = h["test_strlen"]
+sym1 = DL::Symbol.new(ptr,"foo","0")
+sym2 = h["test_strlen","LS"]
+assert("Symbol.new", :must, ptr == sym1.to_ptr, sym1.to_ptr == sym2.to_ptr)
+
+set_val = h["test_set_long_value","0"]
+get_val = h["test_get_long_value","L"]
+lval = get_val[][0]
+ptr = h["internal_long_value"]
+ptr.struct!("L", :l)
+assert("get value", :must, ptr["l"] == lval)
+assert("get value", :must, ptr[:l] == lval) unless (Fixnum === :-)
+ptr["l"] = 200
+lval = get_val[][0]
+assert("set value", :must, ptr["l"] == lval)
+assert("set value", :must, ptr[:l] == lval) unless (Fixnum === :-)
+
+
+data_init = h["test_data_init", "P"]
+data_add = h["test_data_add", "0PS"]
+data_aref = h["test_data_aref", "PPI"]
+r,rs = data_init[]
+ptr = r
+data_add[ptr, "name1"]
+data_add[ptr, "name2"]
+data_add[ptr, "name3"]
+
+r,rs = data_aref[ptr, 1]
+ptr = r
+ptr.struct!("C1024P", :name, :next)
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name2")
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name2") unless (Fixnum === :-)
+
+ptr = ptr["next"]
+ptr.struct!("C1024P", :name, :next)
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name1")
+assert("data_aref", :must,
+ ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name1") unless (Fixnum === :-)
+
+GC.start
+
+ptr = DL::malloc(1024)
+ptr.struct!("CHIL", "c", "h", "i", "l")
+ptr["c"] = 1
+ptr["h"] = 2
+ptr["i"] = 3
+ptr["l"] = 4
+assert("struct!", :must,
+ ptr["c"] == 1 &&
+ ptr["h"] == 2 &&
+ ptr["i"] == 3 &&
+ ptr["l"] == 4)
+
+ptr = DL::malloc(DL::sizeof("IP"))
+ptr.struct!("IP", "n", "ptr")
+ptr["n"] = 10
+ptr["ptr"] = nil
+assert("struct!", :must, ptr["n"] == 10 && ptr["ptr"] == nil)
+
+GC.start
+printf("fail/total = #{$FAIL}/#{$TOTAL}\n")
diff --git a/ext/dl/type.rb b/ext/dl/type.rb
new file mode 100644
index 0000000000..804420c395
--- /dev/null
+++ b/ext/dl/type.rb
@@ -0,0 +1,115 @@
+# example:
+# DLTYPE[INT][:rb2c]["arg0"] => "NUM2INT(arg0)"
+# DLTYPE[DOUBLE][:c2rb]["r"] => "rb_float_new(r)"
+
+DLTYPE = {
+ VOID = 0x00 => {
+ :name => 'VOID',
+ :rb2c => nil,
+ :c2rb => nil,
+ :ctype => "void",
+ :stmem => "v",
+ :sym => true,
+ :cb => true,
+ },
+ CHAR = 0x01 => {
+ :name => 'CHAR',
+ :rb2c => proc{|x| "NUM2CHR(#{x})"},
+ :c2rb => proc{|x| "CHR2FIX(#{x})"},
+ :ctype => "char",
+ :stmem => "c",
+ :sym => false,
+ :cb => false,
+ },
+ SHORT = 0x02 => {
+ :name => 'SHORT',
+ :rb2c => proc{|x| "FIX2INT(#{x})"},
+ :c2rb => proc{|x| "INT2FIX(#{x})"},
+ :ctype => "short",
+ :stmem => "h",
+ :sym => false,
+ :cb => false,
+ },
+ INT = 0x03 => {
+ :name => 'INT',
+ :rb2c => proc{|x| "NUM2INT(#{x})"},
+ :c2rb => proc{|x| "INT2NUM(#{x})"},
+ :ctype => "int",
+ :stmem => "i",
+ :sym => true,
+ :cb => false,
+ },
+ LONG = 0x04 => {
+ :name => 'LONG',
+ :rb2c => proc{|x| "NUM2INT(#{x})"},
+ :c2rb => proc{|x| "INT2NUM(#{x})"},
+ :ctype => "long",
+ :stmem => "l",
+ :sym => true,
+ :cb => true,
+ },
+ FLOAT = 0x05 => {
+ :name => 'FLOAT',
+ :rb2c => proc{|x| "(float)(RFLOAT(#{x})->value)"},
+ :c2rb => proc{|x| "rb_float_new((double)#{x})"},
+ :ctype => "float",
+ :stmem => "f",
+ :sym => false,
+ :cb => false,
+ },
+ DOUBLE = 0x06 => {
+ :name => 'DOUBLE',
+ :rb2c => proc{|x| "RFLOAT(#{x})->value"},
+ :c2rb => proc{|x| "rb_float_new(#{x})"},
+ :ctype => "double",
+ :stmem => "d",
+ :sym => true,
+ :cb => true,
+ },
+ VOIDP = 0x07 => {
+ :name => 'VOIDP',
+ :rb2c => proc{|x| "rb_dlptr2cptr(#{x})"},
+ :c2rb => proc{|x| "rb_dlptr_new(#{x},sizeof(void*),0)"},
+ :ctype => "void *",
+ :stmem => "p",
+ :sym => true,
+ :cb => true,
+ },
+}
+
+def tpush(t, x)
+ (t << 3)|x
+end
+
+def tget(t, i)
+ (t & (0x07 << (i * 3))) >> (i * 3)
+end
+
+def types2num(types)
+ res = 0x00
+ r = types.reverse
+ r.each{|t|
+ res = tpush(res,t)
+ }
+ res
+end
+
+def num2types(num)
+ ts = []
+ i = 0
+ t = tget(num,i)
+ while( (t != VOID && i > 0) || (i == 0) )
+ ts.push(DLTYPE[t][:ctype])
+ i += 1
+ t = tget(num,i)
+ end
+ ts
+end
+
+def types2ctypes(types)
+ res = []
+ types.each{|t|
+ res.push(DLTYPE[t][:ctype])
+ }
+ res
+end
diff --git a/ext/md5/.cvsignore b/ext/enumerator/.cvsignore
index f3c7a7c5da..fc802ff1c2 100644
--- a/ext/md5/.cvsignore
+++ b/ext/enumerator/.cvsignore
@@ -1 +1,2 @@
Makefile
+mkmf.log
diff --git a/ext/enumerator/enumerator.c b/ext/enumerator/enumerator.c
new file mode 100644
index 0000000000..74785569e7
--- /dev/null
+++ b/ext/enumerator/enumerator.c
@@ -0,0 +1,195 @@
+/************************************************
+
+ enumerator.c - provides Enumerator class
+
+ $Author$
+
+ Copyright (C) 2001-2003 Akinori MUSHA
+
+ $Idaemons: /home/cvs/rb/enumerator/enumerator.c,v 1.1.1.1 2001/07/15 10:12:48 knu Exp $
+ $RoughId: enumerator.c,v 1.6 2003/07/27 11:03:24 nobu Exp $
+ $Id$
+
+************************************************/
+
+#include "ruby.h"
+#include "node.h"
+
+static VALUE rb_cEnumerator;
+static ID sym_each, sym_each_with_index, sym_each_slice, sym_each_cons;
+static ID id_new, id_enum_obj, id_enum_method, id_enum_args;
+
+static VALUE
+obj_to_enum(obj, enum_args)
+ VALUE obj, enum_args;
+{
+ rb_ary_unshift(enum_args, obj);
+
+ return rb_apply(rb_cEnumerator, id_new, enum_args);
+}
+
+static VALUE
+enumerator_enum_with_index(obj)
+ VALUE obj;
+{
+ return rb_funcall(rb_cEnumerator, id_new, 2, obj, sym_each_with_index);
+}
+
+static VALUE
+each_slice_i(val, memo)
+ VALUE val;
+ NODE *memo;
+{
+ VALUE ary = memo->u1.value;
+ long size = memo->u3.cnt;
+
+ rb_ary_push(ary, val);
+
+ if (RARRAY(ary)->len == size) {
+ rb_yield(ary);
+ memo->u1.value = rb_ary_new2(size);
+ }
+
+ return Qnil;
+}
+
+static VALUE
+enum_each_slice(obj, n)
+ VALUE obj, n;
+{
+ long size = NUM2LONG(n);
+ NODE *memo;
+ VALUE ary;
+
+ if (size <= 0) rb_raise(rb_eArgError, "invalid slice size");
+
+ memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
+
+ rb_iterate(rb_each, obj, each_slice_i, (VALUE)memo);
+
+ ary = memo->u1.value;
+ if (RARRAY(ary)->len > 0) rb_yield(ary);
+
+ return Qnil;
+}
+
+static VALUE
+enumerator_enum_slice(obj, n)
+ VALUE obj, n;
+{
+ return rb_funcall(rb_cEnumerator, id_new, 3, obj, sym_each_slice, n);
+}
+
+static VALUE
+each_cons_i(val, memo)
+ VALUE val;
+ NODE *memo;
+{
+ VALUE ary = memo->u1.value;
+ long size = memo->u3.cnt;
+
+ if (RARRAY(ary)->len == size) {
+ rb_ary_shift(ary);
+ }
+ rb_ary_push(ary, val);
+ if (RARRAY(ary)->len == size) {
+ rb_yield(rb_ary_dup(ary));
+ }
+ return Qnil;
+}
+
+static VALUE
+enum_each_cons(obj, n)
+ VALUE obj, n;
+{
+ long size = NUM2LONG(n);
+ NODE *memo;
+
+ if (size <= 0) rb_raise(rb_eArgError, "invalid size");
+ memo = rb_node_newnode(NODE_MEMO, rb_ary_new2(size), 0, size);
+
+ rb_iterate(rb_each, obj, each_cons_i, (VALUE)memo);
+
+ return Qnil;
+}
+
+static VALUE
+enumerator_enum_cons(obj, n)
+ VALUE obj, n;
+{
+ return rb_funcall(rb_cEnumerator, id_new, 3, obj, sym_each_cons, n);
+}
+
+static VALUE
+enumerator_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE enum_obj, enum_method, enum_args;
+
+ rb_scan_args(argc, argv, "11*", &enum_obj, &enum_method, &enum_args);
+
+ if (enum_method == Qnil)
+ enum_method = sym_each;
+
+ rb_ivar_set(obj, id_enum_obj, enum_obj);
+ rb_ivar_set(obj, id_enum_method, enum_method);
+ rb_ivar_set(obj, id_enum_args, enum_args);
+
+ return Qnil;
+}
+
+static VALUE
+enumerator_iter(memo)
+ NODE *memo;
+{
+ return rb_apply(memo->u1.value, memo->u2.id, memo->u3.value);
+}
+
+static VALUE
+enumerator_each(obj)
+ VALUE obj;
+{
+ VALUE val;
+
+ obj = (VALUE)rb_node_newnode(NODE_MEMO,
+ rb_ivar_get(obj, id_enum_obj),
+ rb_to_id(rb_ivar_get(obj, id_enum_method)),
+ rb_ivar_get(obj, id_enum_args));
+ val = rb_iterate((VALUE (*)_((VALUE)))enumerator_iter, obj, rb_yield, 0);
+ return val;
+}
+
+void
+Init_enumerator()
+{
+ VALUE rb_mEnumerable;
+
+ rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -2);
+ rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -2);
+
+ rb_mEnumerable = rb_path2class("Enumerable");
+
+ rb_define_method(rb_mEnumerable, "enum_with_index", enumerator_enum_with_index, 0);
+ rb_define_method(rb_mEnumerable, "each_slice", enum_each_slice, 1);
+ rb_define_method(rb_mEnumerable, "enum_slice", enumerator_enum_slice, 1);
+ rb_define_method(rb_mEnumerable, "each_cons", enum_each_cons, 1);
+ rb_define_method(rb_mEnumerable, "enum_cons", enumerator_enum_cons, 1);
+
+ rb_cEnumerator = rb_define_class_under(rb_mEnumerable, "Enumerator", rb_cObject);
+ rb_include_module(rb_cEnumerator, rb_mEnumerable);
+
+ rb_define_method(rb_cEnumerator, "initialize", enumerator_initialize, -1);
+ rb_define_method(rb_cEnumerator, "each", enumerator_each, 0);
+
+ sym_each = ID2SYM(rb_intern("each"));
+ sym_each_with_index = ID2SYM(rb_intern("each_with_index"));
+ sym_each_slice = ID2SYM(rb_intern("each_slice"));
+ sym_each_cons = ID2SYM(rb_intern("each_cons"));
+
+ id_new = rb_intern("new");
+ id_enum_obj = rb_intern("enum_obj");
+ id_enum_method = rb_intern("enum_method");
+ id_enum_args = rb_intern("enum_args");
+}
diff --git a/ext/enumerator/enumerator.txt b/ext/enumerator/enumerator.txt
new file mode 100644
index 0000000000..64c7d50226
--- /dev/null
+++ b/ext/enumerator/enumerator.txt
@@ -0,0 +1,102 @@
+.\" enumerator.txt - -*- Indented-Text -*-
+$Idaemons: /home/cvs/rb/enumerator/enumerator.txt,v 1.2 2001/07/15 10:19:24 knu Exp $
+$RoughId: enumerator.txt,v 1.5 2003/02/20 12:24:51 knu Exp $
+$Id$
+
+** Enumerable::Enumerator(Class)
+
+A class which provides a method `each' to be used as an Enumerable
+object.
+
+Superclass: Object
+
+Mix-ins: Enumerable
+
+require 'enumerator'
+
+Class Methods:
+
+ new(obj, method = :each, *args)
+
+ Creates a new Enumerable::Enumerator object, which is to be
+ used as an Enumerable object using the given object's given
+ method with the given arguments.
+
+ e.g.:
+ str = "xyz"
+
+ enum = Enumerable::Enumerator.new(str, :each_byte)
+ a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
+
+Methods:
+
+ each {...}
+
+ Iterates the given block using the object and the method
+ specified in the first place.
+
+
+Requiring this module also adds some methods to the Object class:
+
+ to_enum(method = :each, *args)
+ enum_for(method = :each, *args)
+
+ Returns Enumerable::Enumerator.new(self, method, *args).
+
+ e.g.:
+ str = "xyz"
+
+ enum = str.enum_for(:each_byte)
+ a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"]
+
+ # protects an array from being modified
+ a = [1, 2, 3]
+ some_method(a.to_enum)
+
+And the Enumerable module.
+
+ each_slice(n) {...}
+
+ Iterates the given block for each slice of <n> elements.
+
+ e.g.:
+ (1..10).each_slice(3) {|a| p a}
+ # outputs below
+ [1, 2, 3]
+ [4, 5, 6]
+ [7, 8, 9]
+ [10]
+
+ enum_slice(n)
+
+ Returns Enumerable::Enumerator.new(self, :each_slice, n).
+
+ each_cons(n) {...}
+
+ Iterates the given block for each array of consecutive <n>
+ elements.
+
+ e.g.:
+ (1..10).each_cons(3) {|a| p a}
+ # outputs below
+ [1, 2, 3]
+ [2, 3, 4]
+ [3, 4, 5]
+ [4, 5, 6]
+ [5, 6, 7]
+ [6, 7, 8]
+ [7, 8, 9]
+ [8, 9, 10]
+
+ enum_cons(n)
+
+ Returns Enumerable::Enumerator.new(self, :each_cons, n).
+
+ enum_with_index
+
+ Returns Enumerable::Enumerator.new(self, :each_with_index).
+
+-------------------------------------------------------
+Local variables:
+fill-column: 70
+end:
diff --git a/ext/enumerator/extconf.rb b/ext/enumerator/extconf.rb
new file mode 100644
index 0000000000..94e2ee38b2
--- /dev/null
+++ b/ext/enumerator/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('enumerator')
diff --git a/ext/etc/.cvsignore b/ext/etc/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/etc/.cvsignore
+++ b/ext/etc/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/etc/MANIFEST b/ext/etc/MANIFEST
deleted file mode 100644
index 79fb1ff34c..0000000000
--- a/ext/etc/MANIFEST
+++ /dev/null
@@ -1,6 +0,0 @@
-MANIFEST
-etc.c
-etc.txt
-etc.txt.jp
-depend
-extconf.rb
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index ee0cd529e4..c42f279d58 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -25,16 +25,19 @@
static VALUE sPasswd, sGroup;
+#ifndef _WIN32
+char *getenv();
+#endif
+char *getlogin();
+
static VALUE
etc_getlogin(obj)
VALUE obj;
{
- char *getenv();
char *login;
+ rb_secure(4);
#ifdef HAVE_GETLOGIN
- char *getlogin();
-
login = getlogin();
if (!login) login = getenv("USER");
#else
@@ -46,6 +49,16 @@ etc_getlogin(obj)
return Qnil;
}
+#if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
+static VALUE
+safe_setup_str(str)
+ const char *str;
+{
+ if (str == 0) str = "";
+ return rb_tainted_str_new2(str);
+}
+#endif
+
#ifdef HAVE_GETPWENT
static VALUE
setup_passwd(pwd)
@@ -53,31 +66,33 @@ setup_passwd(pwd)
{
if (pwd == 0) rb_sys_fail("/etc/passwd");
return rb_struct_new(sPasswd,
- rb_tainted_str_new2(pwd->pw_name),
- rb_tainted_str_new2(pwd->pw_passwd),
+ safe_setup_str(pwd->pw_name),
+#ifdef HAVE_ST_PW_PASSWD
+ safe_setup_str(pwd->pw_passwd),
+#endif
INT2FIX(pwd->pw_uid),
INT2FIX(pwd->pw_gid),
-#ifdef PW_GECOS
- rb_tainted_str_new2(pwd->pw_gecos),
+#ifdef HAVE_ST_PW_GECOS
+ safe_setup_str(pwd->pw_gecos),
#endif
- rb_tainted_str_new2(pwd->pw_dir),
- rb_tainted_str_new2(pwd->pw_shell),
-#ifdef PW_CHANGE
+ safe_setup_str(pwd->pw_dir),
+ safe_setup_str(pwd->pw_shell),
+#ifdef HAVE_ST_PW_CHANGE
INT2FIX(pwd->pw_change),
#endif
-#ifdef PW_QUOTA
+#ifdef HAVE_ST_PW_QUOTA
INT2FIX(pwd->pw_quota),
#endif
-#ifdef PW_AGE
+#ifdef HAVE_ST_PW_AGE
INT2FIX(pwd->pw_age),
#endif
-#ifdef PW_CLASS
- rb_tainted_str_new2(pwd->pw_class),
+#ifdef HAVE_ST_PW_CLASS
+ safe_setup_str(pwd->pw_class),
#endif
-#ifdef PW_COMMENT
- rb_tainted_str_new2(pwd->pw_comment),
+#ifdef HAVE_ST_PW_COMMENT
+ safe_setup_str(pwd->pw_comment),
#endif
-#ifdef PW_EXPIRE
+#ifdef HAVE_ST_PW_EXPIRE
INT2FIX(pwd->pw_expire),
#endif
0 /*dummy*/
@@ -91,11 +106,12 @@ etc_getpwuid(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
-#ifdef HAVE_GETPWENT
+#if defined(HAVE_GETPWENT)
VALUE id;
int uid;
struct passwd *pwd;
+ rb_secure(4);
if (rb_scan_args(argc, argv, "01", &id) == 1) {
uid = NUM2INT(id);
}
@@ -117,7 +133,7 @@ etc_getpwnam(obj, nam)
#ifdef HAVE_GETPWENT
struct passwd *pwd;
- Check_Type(nam, T_STRING);
+ SafeStringValue(nam);
pwd = getpwnam(RSTRING(nam)->ptr);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %s", RSTRING(nam)->ptr);
return setup_passwd(pwd);
@@ -126,6 +142,29 @@ etc_getpwnam(obj, nam)
#endif
}
+#ifdef HAVE_GETPWENT
+static int passwd_blocking = 0;
+static VALUE
+passwd_ensure()
+{
+ passwd_blocking = Qfalse;
+ return Qnil;
+}
+
+static VALUE
+passwd_iterate()
+{
+ struct passwd *pw;
+
+ setpwent();
+ while (pw = getpwent()) {
+ rb_yield(setup_passwd(pw));
+ }
+ endpwent();
+ return Qnil;
+}
+#endif
+
static VALUE
etc_passwd(obj)
VALUE obj;
@@ -133,13 +172,13 @@ etc_passwd(obj)
#ifdef HAVE_GETPWENT
struct passwd *pw;
+ rb_secure(4);
if (rb_block_given_p()) {
- setpwent();
- while (pw = getpwent()) {
- rb_yield(setup_passwd(pw));
+ if (passwd_blocking) {
+ rb_raise(rb_eRuntimeError, "parallel passwd iteration");
}
- endpwent();
- return obj;
+ passwd_blocking = Qtrue;
+ rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
}
if (pw = getpwent()) {
return setup_passwd(pw);
@@ -148,6 +187,40 @@ etc_passwd(obj)
return Qnil;
}
+static VALUE
+etc_setpwent(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETPWENT
+ setpwent();
+#endif
+ return Qnil;
+}
+
+static VALUE
+etc_endpwent(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETPWENT
+ endpwent();
+#endif
+ return Qnil;
+}
+
+static VALUE
+etc_getpwent(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETPWENT
+ struct passwd *pw;
+
+ if (pw = getpwent()) {
+ return setup_passwd(pw);
+ }
+#endif
+ return Qnil;
+}
+
#ifdef HAVE_GETGRENT
static VALUE
setup_group(grp)
@@ -159,12 +232,14 @@ setup_group(grp)
mem = rb_ary_new();
tbl = grp->gr_mem;
while (*tbl) {
- rb_ary_push(mem, rb_tainted_str_new2(*tbl));
+ rb_ary_push(mem, safe_setup_str(*tbl));
tbl++;
}
return rb_struct_new(sGroup,
- rb_tainted_str_new2(grp->gr_name),
- rb_tainted_str_new2(grp->gr_passwd),
+ safe_setup_str(grp->gr_name),
+#ifdef HAVE_ST_GR_PASSWD
+ safe_setup_str(grp->gr_passwd),
+#endif
INT2FIX(grp->gr_gid),
mem);
}
@@ -178,6 +253,7 @@ etc_getgrgid(obj, id)
int gid;
struct group *grp;
+ rb_secure(4);
gid = NUM2INT(id);
grp = getgrgid(gid);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", gid);
@@ -194,7 +270,8 @@ etc_getgrnam(obj, nam)
#ifdef HAVE_GETGRENT
struct group *grp;
- Check_Type(nam, T_STRING);
+ rb_secure(4);
+ SafeStringValue(nam);
grp = getgrnam(RSTRING(nam)->ptr);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %s", RSTRING(nam)->ptr);
return setup_group(grp);
@@ -203,6 +280,29 @@ etc_getgrnam(obj, nam)
#endif
}
+#ifdef HAVE_GETGRENT
+static int group_blocking = 0;
+static VALUE
+group_ensure()
+{
+ group_blocking = Qfalse;
+ return Qnil;
+}
+
+static VALUE
+group_iterate()
+{
+ struct group *pw;
+
+ setgrent();
+ while (pw = getgrent()) {
+ rb_yield(setup_group(pw));
+ }
+ endgrent();
+ return Qnil;
+}
+#endif
+
static VALUE
etc_group(obj)
VALUE obj;
@@ -210,13 +310,13 @@ etc_group(obj)
#ifdef HAVE_GETGRENT
struct group *grp;
+ rb_secure(4);
if (rb_block_given_p()) {
- setgrent();
- while (grp = getgrent()) {
- rb_yield(setup_group(grp));
+ if (group_blocking) {
+ rb_raise(rb_eRuntimeError, "parallel group iteration");
}
- endgrent();
- return obj;
+ group_blocking = Qtrue;
+ rb_ensure(group_iterate, 0, group_ensure, 0);
}
if (grp = getgrent()) {
return setup_group(grp);
@@ -225,6 +325,40 @@ etc_group(obj)
return Qnil;
}
+static VALUE
+etc_setgrent(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETGRENT
+ setgrent();
+#endif
+ return Qnil;
+}
+
+static VALUE
+etc_endgrent(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETGRENT
+ endgrent();
+#endif
+ return Qnil;
+}
+
+static VALUE
+etc_getgrent(obj)
+ VALUE obj;
+{
+#ifdef HAVE_GETGRENT
+ struct group *gr;
+
+ if (gr = getgrent()) {
+ return setup_group(gr);
+ }
+#endif
+ return Qnil;
+}
+
static VALUE mEtc;
void
@@ -236,41 +370,47 @@ Init_etc()
rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);
rb_define_module_function(mEtc, "getpwnam", etc_getpwnam, 1);
+ rb_define_module_function(mEtc, "setpwent", etc_setpwent, 0);
+ rb_define_module_function(mEtc, "endpwent", etc_endpwent, 0);
+ rb_define_module_function(mEtc, "getpwent", etc_getpwent, 0);
rb_define_module_function(mEtc, "passwd", etc_passwd, 0);
rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, 1);
rb_define_module_function(mEtc, "getgrnam", etc_getgrnam, 1);
rb_define_module_function(mEtc, "group", etc_group, 0);
+ rb_define_module_function(mEtc, "setgrent", etc_setgrent, 0);
+ rb_define_module_function(mEtc, "endgrent", etc_endgrent, 0);
+ rb_define_module_function(mEtc, "getgrent", etc_getgrent, 0);
sPasswd = rb_struct_define("Passwd",
"name", "passwd", "uid", "gid",
-#ifdef PW_GECOS
+#ifdef HAVE_ST_PW_GECOS
"gecos",
#endif
"dir", "shell",
-#ifdef PW_CHANGE
+#ifdef HAVE_ST_PW_CHANGE
"change",
#endif
-#ifdef PW_QUOTA
+#ifdef HAVE_ST_PW_QUOTA
"quota",
#endif
-#ifdef PW_AGE
+#ifdef HAVE_ST_PW_AGE
"age",
#endif
-#ifdef PW_CLASS
- "class",
+#ifdef HAVE_ST_PW_CLASS
+ "uclass",
#endif
-#ifdef PW_COMMENT
+#ifdef HAVE_ST_PW_COMMENT
"comment",
#endif
-#ifdef PW_EXPIRE
+#ifdef HAVE_ST_PW_EXPIRE
"expire",
#endif
- 0);
+ NULL);
rb_global_variable(&sPasswd);
#ifdef HAVE_GETGRENT
- sGroup = rb_struct_define("Group", "name", "passwd", "gid", "mem", 0);
+ sGroup = rb_struct_define("Group", "name", "passwd", "gid", "mem", NULL);
rb_global_variable(&sGroup);
#endif
}
diff --git a/ext/etc/etc.txt b/ext/etc/etc.txt
index 9801dc0e02..534790172c 100644
--- a/ext/etc/etc.txt
+++ b/ext/etc/etc.txt
@@ -1,4 +1,4 @@
-.\" etc.doc - -*- Indented-Text -*- created at: Fri Jul 14 00:47:15 JST 1995
+.\" etc.txt - -*- Indented-Text -*- created at: Fri Jul 14 00:47:15 JST 1995
** Etc(Module)
diff --git a/ext/etc/etc.txt.jp b/ext/etc/etc.txt.ja
index 8191f4886b..2dddcfb036 100644
--- a/ext/etc/etc.txt.jp
+++ b/ext/etc/etc.txt.ja
@@ -1,4 +1,4 @@
-.\" etc.doc - -*- Indented-Text -*- created at: Fri Jul 14 00:47:15 JST 1995
+.\" etc.txt.ja - -*- Indented-Text -*- created at: Fri Jul 14 00:47:15 JST 1995
** Etc(¥â¥¸¥å¡¼¥ë)
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 6fe8810464..16f2da352b 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -1,31 +1,18 @@
require 'mkmf'
-def etc_grep_header(field)
- f = open("conftest.c", "w")
- f.print <<EOF
-#include <pwd.h>
-EOF
- f.close
- begin
- if xsystem("#{CPP} | egrep #{field}")
- $defs.push(format("-D%s", field.upcase))
- end
- ensure
- system "rm -f conftest.c"
- end
-end
-
have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
a = have_func("getlogin")
b = have_func("getpwent")
c = have_func("getgrent")
if a or b or c
- etc_grep_header("pw_gecos")
- etc_grep_header("pw_change")
- etc_grep_header("pw_quota")
- etc_grep_header("pw_age")
- etc_grep_header("pw_class")
- etc_grep_header("pw_comment") unless /cygwin/ === RUBY_PLATFORM
- etc_grep_header("pw_expire")
+ have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_change', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_age', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_class', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
+ have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
+ have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
+ have_struct_member('struct group', 'gr_passwd', 'grp.h')
create_makefile("etc")
end
diff --git a/ext/extmk.rb b/ext/extmk.rb
new file mode 100644
index 0000000000..5d26b43e13
--- /dev/null
+++ b/ext/extmk.rb
@@ -0,0 +1,312 @@
+#! /usr/local/bin/ruby
+# -*- ruby -*-
+
+$force_static = nil
+$install = nil
+$destdir = nil
+$clean = nil
+$nodynamic = nil
+$extinit = nil
+$extobjs = nil
+$ignore = nil
+$message = nil
+
+$progname = $0
+alias $PROGRAM_NAME $0
+alias $0 $progname
+
+$extlist = []
+
+$:.replace ["."]
+require 'rbconfig'
+
+srcdir = File.dirname(File.dirname(__FILE__))
+
+$:.replace [srcdir, srcdir+"/lib", "."]
+
+require 'mkmf'
+require 'getopts'
+
+$topdir = "."
+$top_srcdir = srcdir
+$hdrdir = $top_srcdir
+
+def sysquote(x)
+ @quote ||= /human|os2|macos/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
+ @quote ? x.quote : x
+end
+
+def extmake(target)
+ print "#{$message} #{target}\n"
+ $stdout.flush
+ if $force_static or $static_ext[target]
+ $static = target
+ else
+ $static = false
+ end
+
+ unless $ignore
+ return true if $nodynamic and not $static
+ end
+
+ init_mkmf
+
+ begin
+ dir = Dir.pwd
+ FileUtils.mkpath target unless File.directory?(target)
+ Dir.chdir target
+ top_srcdir = $top_srcdir
+ topdir = $topdir
+ prefix = "../" * (target.count("/")+1)
+ if File.expand_path(top_srcdir) != File.expand_path(top_srcdir, dir)
+ $hdrdir = $top_srcdir = prefix + top_srcdir
+ end
+ $topdir = prefix + $topdir
+ $target = target
+ $mdir = target
+ $srcdir = File.join($top_srcdir, "ext", $mdir)
+ $preload = nil
+ makefile = "./Makefile"
+ unless $ignore
+ if $static ||
+ !(t = modified?(makefile, MTIMES)) ||
+ %W<#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb
+ #{$srcdir}/depend>.any? {|f| modified?(f, [t])}
+ then
+ $defs = []
+ Logging::logfile 'mkmf.log'
+ Config::CONFIG["srcdir"] = $srcdir
+ rm_f makefile
+ begin
+ if File.exist?($0 = "#{$srcdir}/makefile.rb")
+ load $0
+ elsif File.exist?($0 = "#{$srcdir}/extconf.rb")
+ load $0
+ else
+ create_makefile(target)
+ end
+ File.exist?(makefile)
+ rescue SystemExit
+ # ignore
+ ensure
+ rm_f "conftest*"
+ $0 = $PROGRAM_NAME
+ Config::CONFIG["srcdir"] = $top_srcdir
+ end
+ else
+ true
+ end
+ else
+ File.exist?(makefile)
+ end or open(makefile, "w") do |f|
+ f.print dummy_makefile($srcdir)
+ return true
+ end
+ args = sysquote($mflags)
+ if $static
+ args += ["static"]
+ $extlist.push [$static, $target, File.basename($target), $preload]
+ end
+ unless system($make, *args)
+ $ignore or $continue or return false
+ end
+ if $static
+ $extflags ||= ""
+ $extlibs ||= []
+ $extpath ||= []
+ $extflags += " " + $DLDFLAGS unless $DLDFLAGS.empty?
+ $extflags += " " + $LDFLAGS unless $LDFLAGS.empty?
+ $extlibs = merge_libs($extlibs, $libs.split, $LOCAL_LIBS.split)
+ $extpath |= $LIBPATH
+ end
+ ensure
+ $hdrdir = $top_srcdir = top_srcdir
+ $topdir = topdir
+ Dir.chdir dir
+ end
+ true
+end
+
+def parse_args()
+ getopts('n', 'extstatic:', 'dest-dir:',
+ 'make:', 'make-flags:', 'mflags:')
+
+ $dryrun = $OPT['n']
+ $force_static = $OPT['extstatic'] == 'static'
+ $destdir = $OPT['dest-dir'] || ''
+ $make = $OPT['make'] || $make || 'make'
+ mflags = ($OPT['make-flags'] || '').strip
+ mflags = ($OPT['mflags'] || '').strip if mflags.empty?
+
+ $mflags = Shellwords.shellwords(mflags)
+ if arg = $mflags.first
+ arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
+ end
+
+ $make, *rest = Shellwords.shellwords($make)
+ $mflags.unshift(*rest) unless rest.empty?
+
+ def $mflags.set?(flag)
+ grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
+ false
+ end
+
+ if $mflags.set?(?n)
+ $dryrun = true
+ else
+ $mflags.unshift '-n' if $dryrun
+ end
+
+ $continue = $mflags.set?(?k)
+ $mflags |= ["DESTDIR=#{$destdir}"]
+end
+
+parse_args()
+
+unless $message
+ if $message = ARGV.shift and /^[a-z]+$/ =~ $message
+ $mflags.push($message)
+ $message = $message.sub(/^(?:dist|real)(?=(?:clean)?$)/, '\1')
+ case $message
+ when "clean"
+ $ignore ||= true
+ when "install"
+ $ignore ||= true
+ $mflags.unshift("INSTALL_PROG=install -c -p -m 0755",
+ "INSTALL_DATA=install -c -p -m 0644",
+ "MAKEDIRS=mkdir -p") if $dryrun
+ end
+ $message.sub!(/e?$/, "ing")
+ else
+ $message = "compiling"
+ end
+end
+
+EXEEXT = CONFIG['EXEEXT']
+if CROSS_COMPILING
+ $ruby = CONFIG['MINIRUBY']
+elsif $nmake
+ $ruby = '$(topdir:/=\\)\\miniruby' + EXEEXT
+else
+ $ruby = '$(topdir)/miniruby' + EXEEXT
+end
+$ruby << " -I$(topdir) -I$(hdrdir)/lib"
+$config_h = '$(topdir)/config.h'
+
+MTIMES = [__FILE__, 'rbconfig.rb', srcdir+'/lib/mkmf.rb'].collect {|f| File.mtime(f)}
+
+# get static-link modules
+$static_ext = {}
+for dir in ["ext", File::join($top_srcdir, "ext")]
+ setup = File::join(dir, CONFIG['setup'])
+ if File.file? setup
+ f = open(setup)
+ while line = f.gets()
+ line.chomp!
+ line.sub!(/#.*$/, '')
+ next if /^\s*$/ =~ line
+ target, opt = line.split(nil, 3)
+ if target == 'option'
+ case opt
+ when 'nodynamic'
+ $nodynamic = true
+ end
+ next
+ end
+ target = target.downcase if /mswin32|bccwin32/ =~ RUBY_PLATFORM
+ $static_ext[target] = true
+ end
+ MTIMES << f.mtime
+ $setup = setup
+ f.close
+ break
+ end
+end
+
+dir = Dir.pwd
+FileUtils::makedirs('ext')
+Dir::chdir('ext')
+
+if File.expand_path(srcdir) != File.expand_path(srcdir, dir)
+ $hdrdir = $top_srcdir = "../" + srcdir
+end
+$topdir = ".."
+ext_prefix = "#{$top_srcdir}/ext"
+Dir.glob("#{ext_prefix}/*/**/extconf.rb") do |d|
+ d = File.dirname(d)
+ d.slice!(0, ext_prefix.length + 1)
+ extmake(d) or exit(1)
+end
+$hdrdir = $top_srcdir = srcdir
+$topdir = "."
+
+if $ignore
+ Dir.chdir ".."
+ exit
+end
+
+if $extlist.size > 0
+ $extinit ||= ""
+ $extobjs ||= ""
+ list = $extlist.dup
+ built = []
+ while e = list.shift
+ s,t,i,r = e
+ if r and !(r -= built).empty?
+ l = list.size
+ if (while l > 0; break true if r.include?(list[l-=1][1]) end)
+ list.insert(l + 1, e)
+ end
+ next
+ end
+ f = format("%s/%s.%s", s, i, $LIBEXT)
+ if File.exist?(f)
+ $extinit += "\tinit(Init_#{i}, \"#{t}.so\");\n"
+ $extobjs += "ext/#{f} "
+ built << t
+ end
+ end
+
+ src = <<SRC
+extern char *ruby_sourcefile, *rb_source_filename();
+#define init(func, name) (ruby_sourcefile = src = rb_source_filename(name), func(), rb_provide(src))
+void Init_ext() {\n\tchar* src;\n#$extinit}
+SRC
+ if !modified?("extinit.c", MTIMES) || IO.read("extinit.c") != src
+ open("extinit.c", "w") {|f| f.print src}
+ end
+
+ $extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs
+ if RUBY_PLATFORM =~ /m68k-human|beos/
+ $extflags.delete("-L/usr/local/lib")
+ end
+ $extpath.delete("$(topdir)")
+ $extflags = libpathflag($extpath) << " " << $extflags.strip
+ conf = [
+ ['SETUP', $setup], [$enable_shared ? 'DLDOBJS' : 'EXTOBJS', $extobjs],
+ ['EXTLIBS', $extlibs.join(' ')], ['EXTLDFLAGS', $extflags]
+ ].map {|n, v|
+ "#{n}=#{v}" if v and !(v = v.strip).empty?
+ }.compact
+ puts conf
+ $stdout.flush
+ $mflags.concat(conf)
+end
+rubies = []
+%w[RUBY RUBYW].each {|r|
+ config_string(r+"_INSTALL_NAME") {|r| rubies << r+EXEEXT}
+}
+
+Dir.chdir ".."
+if $extlist.size > 0
+ rm_f(Config::CONFIG["LIBRUBY_SO"])
+end
+puts "making #{rubies.join(', ')}"
+$stdout.flush
+$mflags.concat(rubies)
+
+system($make, *sysquote($mflags)) or exit($?.exitstatus)
+
+#Local variables:
+# mode: ruby
+#end:
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
deleted file mode 100644
index a369933a14..0000000000
--- a/ext/extmk.rb.in
+++ /dev/null
@@ -1,778 +0,0 @@
-#! /usr/local/bin/ruby
-# -*- ruby -*-
-
-$".push 'mkmf.rb'
-ORIG_LIBPATH = ENV['LIB']
-
-if ARGV[0] == 'static'
- $force_static = true
- ARGV.shift
-elsif ARGV[0] == 'install'
- $install = true
- $destdir = ARGV[1] || ''
- ARGV.shift
-elsif ARGV[0] == 'clean'
- $clean = true
- ARGV.shift
-end
-
-SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
-$extlist = []
-
-$includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@')
-
-$top_srcdir = "@top_srcdir@"
-if $top_srcdir !~ "^/"
- # get absolute path
- $top_srcdir = File.expand_path($top_srcdir)
-end
-# get absolute path
-$topdir = File.expand_path("..")
-
-$:.replace [$top_srcdir, $top_srcdir+"/lib", "."]
-
-require 'find'
-
-def rm_f(*files)
- targets = []
- for file in files
- targets.concat Dir[file]
- end
- if not targets.empty?
- File::chmod 0777, *targets
- File::unlink *targets
- end
-end
-
-def older(file1, file2)
- if !File.exist?(file1) then
- return true
- end
- if !File.exist?(file2) then
- return false
- end
- if File.mtime(file1) < File.mtime(file2)
- return true
- end
- return false
-end
-
-if RUBY_PLATFORM == "m68k-human"
- CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
-else
- CFLAGS = "@CFLAGS@"
-end
-LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir @LDFLAGS@ %s %s %s conftest.c %s %s @LIBS@"
-CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir %s %s %s conftest.c"
-
-if FileTest.readable? 'nul'
- $null = open('nul', 'w')
-elsif FileTest.readable? '/dev/null'
- $null = open('/dev/null', 'w')
-else
- $null = open('test.log', 'w')
-end
-
-$orgerr = $stderr.dup
-$orgout = $stdout.dup
-def xsystem command
- if $DEBUG
- puts command
- return system(command)
- end
- $stderr.reopen($null)
- $stdout.reopen($null)
- r = system(command)
- $stderr.reopen($orgerr)
- $stdout.reopen($orgout)
- return r
-end
-
-def try_link0(src, opt="")
- cfile = open("conftest.c", "w")
- cfile.print src
- cfile.close
- ldflags = $LDFLAGS
- if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty?
- ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';')
- else
- $LDFLAGS = ldflags.dup
- $LIBPATH.each {|d| $LDFLAGS << " -L" + d}
- end
- begin
- xsystem(format(LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
- ensure
- $LDFLAGS = ldflags
- ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM
- end
-end
-
-def try_link(src, opt="")
- begin
- try_link0(src, opt)
- ensure
- rm_f "conftest*"
- end
-end
-
-def try_cpp(src, opt="")
- cfile = open("conftest.c", "w")
- cfile.print src
- cfile.close
- begin
- xsystem(format(CPP, $CFLAGS, $CPPFLAGS, opt))
- ensure
- rm_f "conftest*"
- end
-end
-
-def egrep_cpp(pat, src, opt="")
- cfile = open("conftest.c", "w")
- cfile.print src
- cfile.close
- begin
- xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, $CPPFLAGS, opt))
- ensure
- rm_f "conftest*"
- end
-end
-
-def try_run(src, opt="")
- begin
- if try_link0(src, opt)
- if xsystem("./conftest")
- true
- else
- false
- end
- else
- nil
- end
- ensure
- rm_f "conftest*"
- end
-end
-
-def install_rb(mfile, srcdir = nil)
- libdir = "lib"
- libdir = srcdir + "/" + libdir if srcdir
- path = []
- dir = []
- if File.directory? libdir
- Find.find(libdir) do |f|
- next unless /\.rb$/ =~ f
- f = f[libdir.length+1..-1]
- path.push f
- dir |= [File.dirname(f)]
- end
- end
- for f in dir
- next if f == "."
- mfile.printf "\t@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(pkglibdir)/%s\n", f
- end
- for f in path
- mfile.printf "\t@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' $(srcdir)/lib/%s $(DESTDIR)$(pkglibdir)/%s\n", f, f
- end
-end
-
-def append_library(libs, lib)
- if /mswin32/ =~ RUBY_PLATFORM
- lib + ".lib " + libs
- else
- "-l" + lib + " " + libs
- end
-end
-
-def have_library(lib, func="main")
- if func && func != ""
- libs = append_library($libs, lib)
- if /mswin32|mingw/ =~ RUBY_PLATFORM
- r = try_link(<<"SRC", libs)
-#include <windows.h>
-#include <winsock.h>
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- unless r
- r = try_link(<<"SRC", libs)
-#include <windows.h>
-#include <winsock.h>
-int main() { return 0; }
-int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
-SRC
- end
- else
- r = try_link(<<"SRC", libs)
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- end
- unless r
- return false
- end
- else
- libs = append_library($libs, lib)
- end
-
- $libs = libs
- return true
-end
-
-def find_library(lib, func, *paths)
- libpath = $LIBPATH
- libs = append_library($libs, lib)
- until try_link(<<"SRC", libs)
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- if paths.size == 0
- $LIBPATH = libpath
- return false
- end
- $LIBPATH = libpath | [paths.shift]
- end
- $libs = libs
- return true
-end
-
-def have_func(func, header=nil)
- libs = $libs
- src =
- if /mswin32|mingw/ =~ RUBY_PLATFORM
- r = <<"SRC"
-#include <windows.h>
-#include <winsock.h>
-SRC
- else
- ""
- end
- unless header.nil?
- src << <<"SRC"
-#include <#{header}>
-SRC
- end
- r = try_link(src + <<"SRC", libs)
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- unless r
- r = try_link(src + <<"SRC", libs)
-int main() { return 0; }
-int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
-SRC
- end
- unless r
- return false
- end
- $defs.push(format("-DHAVE_%s", func.upcase))
- return true
-end
-
-def have_header(header)
- unless try_cpp(<<"SRC")
-#include <#{header}>
-SRC
- return false
- end
- header.tr!("a-z./\055", "A-Z___")
- $defs.push(format("-DHAVE_%s", header))
- return true
-end
-
-def arg_config(config, default=nil)
- unless defined? $configure_args
- $configure_args = {}
- args = "@configure_args@"
- if /mswin32|mingw/ =~ RUBY_PLATFORM and ENV["CONFIGURE_ARGS"]
- args << " " << ENV["CONFIGURE_ARGS"]
- end
- for arg in args.split
- next unless /^--/ =~ arg
- if /=/ =~ arg
- $configure_args[$`] = $'
- else
- $configure_args[arg] = true
- end
- end
- end
- $configure_args.fetch(config, default)
-end
-
-def with_config(config, default=nil)
- unless /^--with-/ =~ config
- config = '--with-' + config
- end
- arg_config(config, default)
-end
-
-def enable_config(config, default=nil)
- if arg_config("--enable-"+config, default)
- true
- elsif arg_config("--disable-"+config, false)
- false
- else
- default
- end
-end
-
-def create_header()
- if $defs.length > 0
- hfile = open("extconf.h", "w")
- for line in $defs
- line =~ /^-D(.*)/
- hfile.printf "#define %s 1\n", $1
- end
- hfile.close
- end
-end
-
-def dir_config(target, idefault=nil, ldefault=nil)
- if idefault && ldefault == nil
- default = idefault
- idefault = default + "/include"
- ldefault = default + "/lib"
- end
- dir = with_config("%s-dir"%target, default)
- if dir
- idir = " -I"+dir+"/include"
- ldir = dir+"/lib"
- end
- unless idir
- dir = with_config("%s-include"%target, idefault)
- idir = " -I"+dir if dir
- end
- unless ldir
- ldir = with_config("%s-lib"%target, ldefault)
- end
-
- $CPPFLAGS += idir if idir
- $LIBPATH |= [ldir] if ldir
-end
-
-def create_makefile(target)
- $target = target
- if target.rindex(%r!/!)
- target = $'
- target_prefix = "/"+$`
- else
- target_prefix = ""
- end
- rm_f "conftest*"
- if "@DLEXT@" == $OBJEXT
- libs = $libs.split
- for lib in libs
- lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
- end
- $defs.push(format("-DEXTLIB='%s'", libs.join(",")))
- end
-
- $DLDFLAGS = '@DLDFLAGS@'
-
- if $configure_args['--enable-shared'] or "@LIBRUBY@" != "@LIBRUBY_A@"
- $libs = "@LIBRUBYARG@ " + $libs
- $LIBPATH.unshift $topdir
- end
-
- defflag = ''
- if RUBY_PLATFORM =~ /cygwin|mingw/ and not $static
- if not File.exist? target + '.def'
- open(target + '.def', 'wb') do |f|
- f.print "EXPORTS\n", "Init_", target, "\n"
- end
- end
- defflag = "--def=" + target + ".def"
- end
-
- if RUBY_PLATFORM =~ /mswin32/
- libpath = $LIBPATH.join(';')
- else
- $LIBPATH.each {|d| $DLDFLAGS << " -L" << d}
- end
-
- $srcdir = $top_srcdir + "/ext/" + $mdir
- mfile = open("Makefile", "w")
- mfile.binmode if /mingw/ =~ RUBY_PLATFORM
- mfile.printf "\
-SHELL = /bin/sh
-
-#### Start of system configuration section. ####
-
-srcdir = #{$srcdir}
-VPATH = #{$srcdir}
-
-topdir = #{$topdir}
-hdrdir = #{$top_srcdir}
-
-CC = @CC@
-
-CFLAGS = %s #{CFLAGS} #$CFLAGS
-CPPFLAGS = -I$(topdir) -I$(hdrdir) -I@includedir@ %s #$CPPFLAGS
-DLDFLAGS = #$DLDFLAGS #$LDFLAGS
-LDSHARED = @LDSHARED@ #{defflag}
-", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ")
- mfile.puts "LIBPATH = #{libpath}" if libpath
-
- mfile.puts ".SUFFIXES: .@OBJEXT@" unless "@OBJEXT@" == "o"
-
- mfile.printf "\
-
-RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@
-RUBY_SO_NAME = @RUBY_SO_NAME@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-libdir = @libdir@
-#pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)/@MAJOR@.@MINOR@
-pkglibdir = $(libdir)/ruby/@MAJOR@.@MINOR@
-archdir = $(pkglibdir)/@arch@
-@SET_MAKE@
-
-#### End of system configuration section. ####
-
-"
- mfile.printf "LOCAL_LIBS = %s %s\n", $LOCAL_LIBS, $local_flags
- mfile.printf "LIBS = %s\n", $libs
- mfile.printf "OBJS = "
- if !$objs then
- $objs = []
- for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{#{SRC_EXT.join(%q{,})}}"]
- f = File.basename(f)
- f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT)
- $objs.push f
- end
- else
- for i in $objs
- i.sub!(/\.o\z/, ".#{$OBJEXT}")
- end
- end
- mfile.printf $objs.join(" ")
- mfile.printf "\n"
-
- ruby_interpreter = "$(topdir)/miniruby@EXEEXT@"
- if /nmake/i =~ $make
- ruby_interpreter = '$(topdir:/=\)\miniruby@EXEEXT@'
- end
- if defined? CROSS_COMPILING
- ruby_interpreter = "@MINIRUBY@"
- end
-
- mfile.printf <<EOS
-TARGET = #{target}
-DLLIB = $(TARGET).#{$static ? $LIBEXT : "@DLEXT@"}
-
-RUBY = #{ruby_interpreter} -I$(topdir) -I$(hdrdir)/lib
-RM = $(RUBY) -r ftools -e "File::rm_f(*Dir[ARGV.join(' ')])"
-
-EXEEXT = @EXEEXT@
-
-all: $(DLLIB)
-
-clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB)
- @$(RM) *.ilk *.exp *.pdb *.bak
-
-distclean: clean
- @$(RM) Makefile extconf.h conftest.*
- @$(RM) core ruby$(EXEEXT) *~
-
-realclean: distclean
-EOS
-
- mfile.printf <<EOS
-
-install:
- @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(libdir) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(archdir)
-EOS
- unless $static
- mfile.printf "\
- @$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
-"
- end
- install_rb(mfile, $srcdir)
- mfile.printf "\n"
-
- if /mswin32/ !~ RUBY_PLATFORM
- mfile.puts "
-.c.@OBJEXT@:
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
-
-.cc.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
-.cpp.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
-.cxx.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
-.C.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
-"
- elsif /nmake/i =~ $make
- mfile.print "
-{$(srcdir)}.c{}.@OBJEXT@:
- $(CC) -I. -I$(<D) $(CFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-.c.@OBJEXT@:
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-
-{$(srcdir)}.cc{}.@OBJEXT@:
- $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-.cc.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-{$(srcdir)}.cpp{}.@OBJEXT@:
- $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-.cpp.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-{$(srcdir)}.cxx{}.@OBJEXT@:
- $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-.cxx.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-"
- else
- mfile.print "
-.c.@OBJEXT@:
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
-
-.cc.@OBJEXT@ .cpp.@OBJEXT@ .cxx.@OBJEXT@ .C.@OBJEXT@:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
-"
- end
-
- if $static
- if "@AR@" =~ /^lib\b/i
- mfile.printf "\
-$(DLLIB): $(OBJS)
- @AR@ /OUT:$(DLLIB) $(OBJS)
-"
- else
- mfile.printf "\
-$(DLLIB): $(OBJS)
- @AR@ cru $(DLLIB) $(OBJS)
- @-@RANLIB@ $(DLLIB) 2> /dev/null || true
-"
- end
- elsif "@DLEXT@" != $OBJEXT
- mfile.print "$(DLLIB): $(OBJS)\n"
- if /mswin32/ =~ RUBY_PLATFORM
- if /nmake/i =~ $make
- mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n"
- else
- mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n"
- end
- end
- mfile.print "\t$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n"
- elsif RUBY_PLATFORM == "m68k-human"
- mfile.printf "\
-$(DLLIB): $(OBJS)
- ar cru $(DLLIB) $(OBJS)
-"
- else
- mfile.printf "\
-$(DLLIB): $(OBJS)
- ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)
-"
- end
-
- if File.exist?("#{$srcdir}/depend")
- dfile = open("#{$srcdir}/depend", "r")
- mfile.printf "###\n"
- while line = dfile.gets()
- line.gsub!(/\.o\b/, ".#{$OBJEXT}")
- line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1$(srcdir)/\2') if /nmake/i =~ $make
- mfile.printf "%s", line.gsub('\$\(hdrdir\)/config.h', '$(topdir)/config.h')
- end
- dfile.close
- end
- mfile.close
-end
-
-def extmake(target)
- if $force_static or $static_ext[target]
- $static = target
- else
- $static = false
- end
-
- unless $install or $clean
- return if $nodynamic and not $static
- end
-
- $OBJEXT = "@OBJEXT@"
- $LIBEXT = "a"
- $objs = nil
- $libs = "@DLDLIBS@"
- $local_flags = ""
- if /mswin32/ =~ RUBY_PLATFORM
- $LIBEXT = "lib"
- $local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)"
- end
- $LOCAL_LIBS = "" # to be assigned in extconf.rb
- dir = with_config("opt-dir")
- if dir
- idir = "-I"+dir+"/include"
- ldir = dir+"/lib"
- end
- unless idir
- dir = with_config("opt-include")
- idir = "-I"+dir if dir
- end
- unless ldir
- ldir = with_config("opt-lib")
- end
-
- $CFLAGS = ""
- $CPPFLAGS = idir || ""
- $LDFLAGS = ""
- $LIBPATH = [ldir].compact
-
- begin
- Dir.mkdir target unless File.directory?(target)
- Dir.chdir target
- $target = target
- $mdir = target
- unless $install or $clean
- if $static_ext.size > 0 ||
- !File.exist?("./Makefile") ||
- older("./Makefile", "#{$top_srcdir}/ext/@setup@") ||
- older("./Makefile", "../extmk.rb") ||
- older("./Makefile", "#{$top_srcdir}/ext/#{target}/makefile.rb") ||
- older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
- then
- $defs = []
- if File.exist?("#{$top_srcdir}/ext/#{target}/makefile.rb")
- load "#{$top_srcdir}/ext/#{target}/makefile.rb"
- elsif File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
- load "#{$top_srcdir}/ext/#{target}/extconf.rb"
- else
- create_makefile(target)
- end
- end
- end
- if File.exist?("./Makefile")
- if $static
- $extlist.push [$static,$target]
- end
- if $install
- system "#{$make} install DESTDIR=#{$destdir}"
- elsif $clean
- system "#{$make} clean"
- else
- unless system "#{$make} all"
- if ENV["MAKEFLAGS"] != "k" and ENV["MFLAGS"] != "-k"
- exit
- end
- end
- end
- end
- if $static
- $extlibs ||= ""
- $extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
- $extlibs += " " + $libs unless $libs == ""
- $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
- end
- ensure
- rm_f "conftest*"
- Dir.chdir ".."
- end
-end
-
-$make = ENV["MAKE"]
-$make ||= with_config("make-prog", "make")
-
-# get static-link modules
-$static_ext = {}
-for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"]
- if File.file? setup
- f = open(setup)
- while f.gets()
- $_.chomp!
- sub!(/#.*$/, '')
- next if /^\s*$/
- if /^option +nodynamic/
- $nodynamic = true
- next
- end
- target = $_.split[0]
- target = target.downcase if /mswin32/ =~ RUBY_PLATFORM
- $static_ext[target] = true
- end
- f.close
- break
- end
-end
-
-for d in Dir["#{$top_srcdir}/ext/*"]
- File.directory?(d) || next
- File.file?(d + "/MANIFEST") || next
-
- d = File.basename(d)
- if $install
- print "installing ", d, "\n"
- elsif $clean
- print "cleaning ", d, "\n"
- else
- print "compiling ", d, "\n"
- if RUBY_PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby")
- load "#{$top_srcdir}/ext/aix_mksym.rb"
- end
- end
- extmake(d)
-end
-
-if $install or $clean
- Dir.chdir ".."
- exit
-end
-$extinit = "" unless $extinit
-
-ruby = "@RUBY_INSTALL_NAME@@EXEEXT@"
-miniruby = "miniruby@EXEEXT@"
-
-$extobjs = "" unless $extobjs
-if $extlist.size > 0
- for s,t in $extlist
- f = format("%s/%s.%s", s, t, $LIBEXT)
- if File.exist?(f)
- $extinit += format("\
-\tInit_%s();\n\
-\trb_provide(\"%s.so\");\n\
-", t, t)
- $extobjs += "ext/"
- $extobjs += f
- $extobjs += " "
- else
- false
- end
- end
-
- if older("extinit.c", "#{$top_srcdir}/ext/@setup@")
- f = open("extinit.c", "w")
- f.printf "void Init_ext() {\n"
- f.printf $extinit
- f.printf "}\n"
- f.close
- end
- if older("extinit.#{$OBJEXT}", "extinit.c")
- cmd = "@CC@ " + CFLAGS + " -c extinit.c"
- print cmd, "\n"
- system cmd or exit 1
- end
-
- Dir.chdir ".."
-
- if older(ruby, "#{$top_srcdir}/ext/@setup@") or older(ruby, miniruby)
- rm_f ruby
- end
-
- $extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs
- if RUBY_PLATFORM =~ /m68k-human|beos/
- $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
- end
- system format(%[#{$make} #{ruby} EXTOBJS='%s' EXTLIBS='%s'], $extobjs, $extlibs)
-else
- Dir.chdir ".."
- if older(ruby, miniruby)
- rm_f ruby
- system("#{$make} #{ruby}")
- end
-end
-
-#Local variables:
-# mode: ruby
-#end:
diff --git a/ext/fcntl/.cvsignore b/ext/fcntl/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/fcntl/.cvsignore
+++ b/ext/fcntl/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/fcntl/MANIFEST b/ext/fcntl/MANIFEST
deleted file mode 100644
index aef7ad4ca0..0000000000
--- a/ext/fcntl/MANIFEST
+++ /dev/null
@@ -1,3 +0,0 @@
-MANIFEST
-depend
-fcntl.c
diff --git a/ext/fcntl/extconf.rb b/ext/fcntl/extconf.rb
new file mode 100644
index 0000000000..8b717d4a5b
--- /dev/null
+++ b/ext/fcntl/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('fcntl')
diff --git a/ext/fcntl/fcntl.c b/ext/fcntl/fcntl.c
index 80e0112e4c..d48630fc66 100644
--- a/ext/fcntl/fcntl.c
+++ b/ext/fcntl/fcntl.c
@@ -5,7 +5,7 @@
$Author$
created at: Mon Apr 7 18:53:05 JST 1997
- Copyright (C) 1997-1998 Yukihiro Matsumoto
+ Copyright (C) 1997-2001 Yukihiro Matsumoto
************************************************/
@@ -104,4 +104,9 @@ Init_fcntl()
#ifdef O_WRONLY
rb_define_const(mFcntl, "O_WRONLY", INT2NUM(O_WRONLY));
#endif
+#ifdef O_ACCMODE
+ rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_ACCMODE));
+#else
+ rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_RDONLY | O_WRONLY | O_RDWR));
+#endif
}
diff --git a/ext/gdbm/.cvsignore b/ext/gdbm/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/gdbm/.cvsignore
+++ b/ext/gdbm/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/gdbm/MANIFEST b/ext/gdbm/MANIFEST
deleted file mode 100644
index f4a8796d18..0000000000
--- a/ext/gdbm/MANIFEST
+++ /dev/null
@@ -1,5 +0,0 @@
-MANIFEST
-README
-depend
-extconf.rb
-gdbm.c
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index d84c7bedd4..799445a89c 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -14,10 +14,18 @@
#include <fcntl.h>
#include <errno.h>
-VALUE cGDBM;
+static VALUE rb_cGDBM, rb_eGDBMError, rb_eGDBMFatalError;
+
+#define RUBY_GDBM_RW_BIT 0x20000000
#define MY_BLOCK_SIZE (2048)
-#define MY_FATAL_FUNC (0)
+#define MY_FATAL_FUNC rb_gdbm_fatal
+static void
+rb_gdbm_fatal(msg)
+ char *msg;
+{
+ rb_raise(rb_eGDBMFatalError, msg);
+}
struct dbmdata {
int di_size;
@@ -30,32 +38,56 @@ closed_dbm()
rb_raise(rb_eRuntimeError, "closed GDBM file");
}
-#define GetDBM(obj, dbmp) {\
+#define GetDBM(obj, dbmp) do {\
Data_Get_Struct(obj, struct dbmdata, dbmp);\
+ if (dbmp == 0) closed_dbm();\
if (dbmp->di_dbm == 0) closed_dbm();\
-}
+} while (0)
static void
free_dbm(dbmp)
struct dbmdata *dbmp;
{
- if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
- free(dbmp);
+ if (dbmp) {
+ if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
+ free(dbmp);
+ }
}
static VALUE
-fgdbm_s_open(argc, argv, klass)
+fgdbm_close(obj)
+ VALUE obj;
+{
+ struct dbmdata *dbmp;
+
+ GetDBM(obj, dbmp);
+ gdbm_close(dbmp->di_dbm);
+ dbmp->di_dbm = 0;
+
+ return Qnil;
+}
+
+static VALUE fgdbm_s_alloc _((VALUE));
+
+static VALUE
+fgdbm_s_alloc(klass)
+ VALUE klass;
+{
+ return Data_Wrap_Struct(klass, 0, free_dbm, 0);
+}
+
+static VALUE
+fgdbm_initialize(argc, argv, obj)
int argc;
VALUE *argv;
- VALUE klass;
+ VALUE obj;
{
- VALUE file, vmode;
+ VALUE file, vmode, vflags;
GDBM_FILE dbm;
struct dbmdata *dbmp;
- int mode;
- VALUE obj;
+ int mode, flags = 0;
- if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
+ if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) {
mode = 0666; /* default value */
}
else if (NIL_P(vmode)) {
@@ -64,25 +96,44 @@ fgdbm_s_open(argc, argv, klass)
else {
mode = NUM2INT(vmode);
}
- Check_SafeStr(file);
- dbm = 0;
- if (mode >= 0)
- dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
- O_RDWR|O_CREAT, mode, MY_FATAL_FUNC);
- if (!dbm)
- dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
- O_RDWR, 0, MY_FATAL_FUNC);
- if (!dbm)
+ if (!NIL_P(vflags))
+ flags = NUM2INT(vflags);
+
+ SafeStringValue(file);
+
+ if (flags & RUBY_GDBM_RW_BIT) {
+ flags &= ~RUBY_GDBM_RW_BIT;
dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
- O_RDONLY, 0, MY_FATAL_FUNC);
+ flags, mode, MY_FATAL_FUNC);
+ }
+ else {
+ dbm = 0;
+ if (mode >= 0)
+ dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
+ GDBM_WRCREAT|flags, mode, MY_FATAL_FUNC);
+ if (!dbm)
+ dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
+ GDBM_WRITER|flags, 0, MY_FATAL_FUNC);
+ if (!dbm)
+ dbm = gdbm_open(RSTRING(file)->ptr, MY_BLOCK_SIZE,
+ GDBM_READER|flags, 0, MY_FATAL_FUNC);
+ }
if (!dbm) {
if (mode == -1) return Qnil;
- rb_sys_fail(RSTRING(file)->ptr);
+
+ if (gdbm_errno == GDBM_FILE_OPEN_ERROR ||
+ gdbm_errno == GDBM_CANT_BE_READER ||
+ gdbm_errno == GDBM_CANT_BE_WRITER)
+ rb_sys_fail(RSTRING(file)->ptr);
+ else
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
- obj = Data_Make_Struct(klass,struct dbmdata,0,free_dbm,dbmp);
+ dbmp = ALLOC(struct dbmdata);
+ free_dbm(DATA_PTR(obj));
+ DATA_PTR(obj) = dbmp;
dbmp->di_dbm = dbm;
dbmp->di_size = -1;
@@ -90,46 +141,137 @@ fgdbm_s_open(argc, argv, klass)
}
static VALUE
-fgdbm_close(obj)
- VALUE obj;
+fgdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
- struct dbmdata *dbmp;
+ VALUE obj = Data_Wrap_Struct(klass, 0, free_dbm, 0);
- GetDBM(obj, dbmp);
- gdbm_close(dbmp->di_dbm);
- dbmp->di_dbm = 0;
+ if (NIL_P(fgdbm_initialize(argc, argv, obj))) {
+ return Qnil;
+ }
- return Qnil;
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, fgdbm_close, obj);
+ }
+
+ return obj;
}
static VALUE
-fgdbm_fetch(obj, keystr, ifnone)
- VALUE obj, keystr, ifnone;
+rb_gdbm_fetch(dbm, key)
+ GDBM_FILE dbm;
+ datum key;
{
- datum key, value;
- struct dbmdata *dbmp;
+ datum val;
+ VALUE str;
+
+ val = gdbm_fetch(dbm, key);
+ if (val.dptr == 0)
+ return Qnil;
+
+ str = rb_obj_alloc(rb_cString);
+ RSTRING(str)->len = val.dsize;
+ RSTRING(str)->aux.capa = val.dsize;
+ RSTRING(str)->ptr = REALLOC_N(val.dptr,char,val.dsize+1);
+ RSTRING(str)->ptr[val.dsize] = '\0';
+
+ OBJ_TAINT(str);
+ return (VALUE)str;
+}
+
+static VALUE
+rb_gdbm_fetch2(dbm, keystr)
GDBM_FILE dbm;
+ VALUE keystr;
+{
+ datum key;
- Check_Type(keystr, T_STRING);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
+ return rb_gdbm_fetch(dbm, key);
+}
+
+static VALUE
+rb_gdbm_fetch3(obj, keystr)
+ VALUE obj, keystr;
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- value = gdbm_fetch(dbm, key);
- if (value.dptr == 0) {
+ return rb_gdbm_fetch2(dbm, keystr);
+}
+
+static VALUE
+rb_gdbm_firstkey(dbm)
+ GDBM_FILE dbm;
+{
+ datum key;
+ VALUE str;
+
+ key = gdbm_firstkey(dbm);
+ if (key.dptr == 0)
+ return Qnil;
+
+ str = rb_obj_alloc(rb_cString);
+ RSTRING(str)->len = key.dsize;
+ RSTRING(str)->aux.capa = key.dsize;
+ RSTRING(str)->ptr = REALLOC_N(key.dptr,char,key.dsize+1);
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
+
+ OBJ_TAINT(str);
+ return str;
+}
+
+static VALUE
+rb_gdbm_nextkey(dbm, keystr)
+ GDBM_FILE dbm;
+ VALUE keystr;
+{
+ datum key, key2;
+ VALUE str;
+
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+ key2 = gdbm_nextkey(dbm, key);
+ if (key2.dptr == 0)
+ return Qnil;
+
+ str = rb_obj_alloc(rb_cString);
+ RSTRING(str)->len = key2.dsize;
+ RSTRING(str)->aux.capa = key2.dsize;
+ RSTRING(str)->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1);
+ RSTRING(str)->ptr[RSTRING(str)->len] = '\0';
+
+ OBJ_TAINT(str);
+ return str;
+}
+
+static VALUE
+fgdbm_fetch(obj, keystr, ifnone)
+ VALUE obj, keystr, ifnone;
+{
+ VALUE valstr;
+
+ valstr = rb_gdbm_fetch3(obj, keystr);
+ if (NIL_P(valstr)) {
if (ifnone == Qnil && rb_block_given_p())
- return rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
+ return rb_yield(keystr);
return ifnone;
}
- return rb_tainted_str_new(value.dptr, value.dsize);
+ return valstr;
}
static VALUE
fgdbm_aref(obj, keystr)
VALUE obj, keystr;
{
- return fgdbm_fetch(obj, keystr, Qnil);
+ return rb_gdbm_fetch3(obj, keystr);
}
static VALUE
@@ -138,31 +280,37 @@ fgdbm_fetch_m(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- VALUE keystr, ifnone;
+ VALUE keystr, valstr, ifnone;
rb_scan_args(argc, argv, "11", &keystr, &ifnone);
- return fgdbm_fetch(obj, keystr, ifnone);
+ valstr = fgdbm_fetch(obj, keystr, ifnone);
+ if (argc == 1 && !rb_block_given_p() && NIL_P(valstr))
+ rb_raise(rb_eIndexError, "key not found");
+
+ return valstr;
}
static VALUE
fgdbm_index(obj, valstr)
VALUE obj, valstr;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
+ VALUE keystr, valstr2;
- Check_Type(valstr, T_STRING);
- val.dptr = RSTRING(valstr)->ptr;
- val.dsize = RSTRING(valstr)->len;
-
+ StringValue(valstr);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- if (val.dsize == RSTRING(valstr)->len &&
- memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
- return rb_tainted_str_new(key.dptr, key.dsize);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ valstr2 = rb_gdbm_fetch2(dbm, keystr);
+ if (!NIL_P(valstr2) &&
+ RSTRING(valstr)->len == RSTRING(valstr2)->len &&
+ memcmp(RSTRING(valstr)->ptr, RSTRING(valstr2)->ptr,
+ RSTRING(valstr)->len) == 0) {
+ return keystr;
+ }
}
return Qnil;
}
@@ -178,37 +326,98 @@ fgdbm_indexes(argc, argv, obj)
new = rb_ary_new2(argc);
for (i=0; i<argc; i++) {
- rb_ary_push(new, fgdbm_fetch(obj, argv[i]));
+ rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
}
return new;
}
static VALUE
-fgdbm_delete(obj, keystr)
+fgdbm_select(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ if (rb_block_given_p()) {
+ GDBM_FILE dbm;
+ struct dbmdata *dbmp;
+ VALUE keystr;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number arguments(%d for 0)", argc);
+ }
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+ VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr));
+
+ if (RTEST(rb_yield(assoc)))
+ rb_ary_push(new, assoc);
+ }
+ }
+ else {
+ rb_warn("GDBM#select(index..) is deprecated; use GDBM#values_at");
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
+ }
+ }
+
+ return new;
+}
+
+static VALUE
+fgdbm_values_at(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
+ }
+
+ return new;
+}
+
+static void
+rb_gdbm_modify(obj)
+ VALUE obj;
+{
+ rb_secure(4);
+ if (OBJ_FROZEN(obj)) rb_error_frozen("GDBM");
+}
+
+static VALUE
+rb_gdbm_delete(obj, keystr)
VALUE obj, keystr;
{
- datum key, value;
+ datum key;
struct dbmdata *dbmp;
GDBM_FILE dbm;
- rb_secure(4);
- Check_Type(keystr, T_STRING);
+ rb_gdbm_modify(obj);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- value = gdbm_fetch(dbm, key);
- if (value.dptr == 0) {
- if (rb_block_given_p()) rb_yield(keystr);
+ if (!gdbm_exists(dbm, key)) {
return Qnil;
}
if (gdbm_delete(dbm, key)) {
dbmp->di_size = -1;
- rb_raise(rb_eRuntimeError, "gdbm_delete failed");
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
else if (dbmp->di_size >= 0) {
dbmp->di_size--;
@@ -217,25 +426,33 @@ fgdbm_delete(obj, keystr)
}
static VALUE
+fgdbm_delete(obj, keystr)
+ VALUE obj, keystr;
+{
+ VALUE valstr;
+
+ valstr = fgdbm_fetch(obj, keystr, Qnil);
+ rb_gdbm_delete(obj, keystr);
+ return valstr;
+}
+
+static VALUE
fgdbm_shift(obj)
VALUE obj;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
VALUE keystr, valstr;
- rb_secure(4);
+ rb_gdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- key = gdbm_firstkey(dbm);
- if (!key.dptr) return Qnil;
- val = gdbm_fetch(dbm, key);
- gdbm_delete(dbm, key);
+ keystr = rb_gdbm_firstkey(dbm);
+ if (NIL_P(keystr)) return Qnil;
+ valstr = rb_gdbm_fetch2(dbm, keystr);
+ rb_gdbm_delete(obj, keystr);
- keystr = rb_tainted_str_new(key.dptr, key.dsize);
- valstr = rb_tainted_str_new(val.dptr, val.dsize);
return rb_assoc_new(keystr, valstr);
}
@@ -243,24 +460,32 @@ static VALUE
fgdbm_delete_if(obj)
VALUE obj;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
VALUE keystr, valstr;
+ VALUE ret, ary = rb_ary_new();
+ int i, status = 0, n;
- rb_secure(4);
+ rb_gdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- keystr = rb_tainted_str_new(key.dptr, key.dsize);
- valstr = rb_tainted_str_new(val.dptr, val.dsize);
- if (RTEST(rb_yield(rb_assoc_new(keystr, valstr)))) {
- if (gdbm_delete(dbm, key)) {
- rb_raise(rb_eRuntimeError, "gdbm_delete failed");
- }
- }
+ n = dbmp->di_size;
+ dbmp->di_size = -1;
+
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ valstr = rb_gdbm_fetch2(dbm, keystr);
+ ret = rb_protect(rb_yield, rb_assoc_new(keystr, valstr), &status);
+ if (status != 0) break;
+ if (RTEST(ret)) rb_ary_push(ary, keystr);
}
+
+ for (i = 0; i < RARRAY(ary)->len; i++)
+ rb_gdbm_delete(obj, RARRAY(ary)->ptr[i]);
+ if (status) rb_jump_tag(status);
+ if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
+
return obj;
}
@@ -272,16 +497,34 @@ fgdbm_clear(obj)
struct dbmdata *dbmp;
GDBM_FILE dbm;
- rb_secure(4);
+ rb_gdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
dbmp->di_size = -1;
- for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
- nextkey = gdbm_nextkey(dbm, key);
+
+#if 0
+ while (key = gdbm_firstkey(dbm), key.dptr) {
if (gdbm_delete(dbm, key)) {
- rb_raise(rb_eRuntimeError, "gdbm_delete failed");
+ free(key.dptr);
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
+ free(key.dptr);
}
+#else
+ while (key = gdbm_firstkey(dbm), key.dptr) {
+ for (; key.dptr; key = nextkey) {
+ nextkey = gdbm_nextkey(dbm, key);
+ if (gdbm_delete(dbm, key)) {
+ free(key.dptr);
+ if (nextkey.dptr) free(nextkey.dptr);
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ free(key.dptr);
+ }
+ }
+#endif
+ dbmp->di_size = 0;
+
return obj;
}
@@ -289,7 +532,6 @@ static VALUE
fgdbm_invert(obj)
VALUE obj;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
VALUE keystr, valstr;
@@ -297,15 +539,17 @@ fgdbm_invert(obj)
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- keystr = rb_tainted_str_new(key.dptr, key.dsize);
- valstr = rb_tainted_str_new(val.dptr, val.dsize);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+ valstr = rb_gdbm_fetch2(dbm, keystr);
+
rb_hash_aset(hash, valstr, keystr);
}
return hash;
}
+static VALUE each_pair _((VALUE));
+
static VALUE
each_pair(obj)
VALUE obj;
@@ -352,13 +596,12 @@ fgdbm_store(obj, keystr, valstr)
struct dbmdata *dbmp;
GDBM_FILE dbm;
- rb_secure(4);
- keystr = rb_obj_as_string(keystr);
-
+ rb_gdbm_modify(obj);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
- valstr = rb_obj_as_string(valstr);
+ StringValue(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
@@ -367,7 +610,7 @@ fgdbm_store(obj, keystr, valstr)
dbm = dbmp->di_dbm;
if (gdbm_store(dbm, key, val, GDBM_REPLACE)) {
if (errno == EPERM) rb_sys_fail(0);
- rb_raise(rb_eRuntimeError, "gdbm_store failed");
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
}
return valstr;
@@ -377,7 +620,7 @@ static VALUE
fgdbm_length(obj)
VALUE obj;
{
- datum key;
+ datum key, nextkey;
struct dbmdata *dbmp;
GDBM_FILE dbm;
int i = 0;
@@ -386,7 +629,9 @@ fgdbm_length(obj)
if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
+ for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
+ nextkey = gdbm_nextkey(dbm, key);
+ free(key.dptr);
i++;
}
dbmp->di_size = i;
@@ -401,20 +646,20 @@ fgdbm_empty_p(obj)
datum key;
struct dbmdata *dbmp;
GDBM_FILE dbm;
- int i = 0;
GetDBM(obj, dbmp);
if (dbmp->di_size < 0) {
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- i++;
+ key = gdbm_firstkey(dbm);
+ if (key.dptr) {
+ free(key.dptr);
+ return Qfalse;
}
+ return Qtrue;
}
- else {
- i = dbmp->di_size;
- }
- if (i == 0) return Qtrue;
+
+ if (dbmp->di_size == 0) return Qtrue;
return Qfalse;
}
@@ -422,15 +667,17 @@ static VALUE
fgdbm_each_value(obj)
VALUE obj;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
+ VALUE keystr;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- rb_yield(rb_tainted_str_new(val.dptr, val.dsize));
+
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_yield(rb_gdbm_fetch2(dbm, keystr));
}
return obj;
}
@@ -439,14 +686,17 @@ static VALUE
fgdbm_each_key(obj)
VALUE obj;
{
- datum key;
struct dbmdata *dbmp;
GDBM_FILE dbm;
+ VALUE keystr;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
+
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_yield(keystr);
}
return obj;
}
@@ -455,19 +705,17 @@ static VALUE
fgdbm_each_pair(obj)
VALUE obj;
{
- datum key, val;
GDBM_FILE dbm;
struct dbmdata *dbmp;
- VALUE keystr, valstr;
+ VALUE keystr;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- keystr = rb_tainted_str_new(key.dptr, key.dsize);
- valstr = rb_tainted_str_new(val.dptr, val.dsize);
- rb_yield(rb_assoc_new(keystr, valstr));
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_yield(rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr)));
}
return obj;
@@ -477,17 +725,18 @@ static VALUE
fgdbm_keys(obj)
VALUE obj;
{
- datum key;
struct dbmdata *dbmp;
GDBM_FILE dbm;
- VALUE ary;
+ VALUE keystr, ary;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
ary = rb_ary_new();
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- rb_ary_push(ary, rb_tainted_str_new(key.dptr, key.dsize));
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_ary_push(ary, keystr);
}
return ary;
@@ -497,18 +746,20 @@ static VALUE
fgdbm_values(obj)
VALUE obj;
{
- datum key, val;
+ datum key, nextkey;
struct dbmdata *dbmp;
GDBM_FILE dbm;
- VALUE ary;
+ VALUE valstr, ary;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
ary = rb_ary_new();
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- rb_ary_push(ary, rb_tainted_str_new(val.dptr, val.dsize));
+ for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
+ nextkey = gdbm_nextkey(dbm, key);
+ valstr = rb_gdbm_fetch(dbm, key);
+ free(key.dptr);
+ rb_ary_push(ary, valstr);
}
return ary;
@@ -518,18 +769,18 @@ static VALUE
fgdbm_has_key(obj, keystr)
VALUE obj, keystr;
{
- datum key, val;
+ datum key;
struct dbmdata *dbmp;
GDBM_FILE dbm;
- Check_Type(keystr, T_STRING);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- val = gdbm_fetch(dbm, key);
- if (val.dptr) return Qtrue;
+ if (gdbm_exists(dbm, key))
+ return Qtrue;
return Qfalse;
}
@@ -537,21 +788,24 @@ static VALUE
fgdbm_has_value(obj, valstr)
VALUE obj, valstr;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
+ VALUE keystr, valstr2;
- Check_Type(valstr, T_STRING);
- val.dptr = RSTRING(valstr)->ptr;
- val.dsize = RSTRING(valstr)->len;
-
+ StringValue(valstr);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- if (val.dsize == RSTRING(valstr)->len &&
- memcmp(val.dptr, RSTRING(valstr)->ptr, val.dsize) == 0)
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ valstr2 = rb_gdbm_fetch2(dbm, keystr);
+
+ if (!NIL_P(valstr2) &&
+ RSTRING(valstr)->len == RSTRING(valstr2)->len &&
+ memcmp(RSTRING(valstr)->ptr, RSTRING(valstr2)->ptr,
+ RSTRING(valstr)->len) == 0) {
return Qtrue;
+ }
}
return Qfalse;
}
@@ -560,19 +814,18 @@ static VALUE
fgdbm_to_a(obj)
VALUE obj;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
- VALUE ary;
+ VALUE keystr, ary;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
ary = rb_ary_new();
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- rb_ary_push(ary, rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
- rb_tainted_str_new(val.dptr, val.dsize)));
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_ary_push(ary, rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr)));
}
return ary;
@@ -585,7 +838,7 @@ fgdbm_reorganize(obj)
struct dbmdata *dbmp;
GDBM_FILE dbm;
- rb_secure(4);
+ rb_gdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
gdbm_reorganize(dbm);
@@ -593,22 +846,100 @@ fgdbm_reorganize(obj)
}
static VALUE
+fgdbm_sync(obj)
+ VALUE obj;
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ rb_gdbm_modify(obj);
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+ gdbm_sync(dbm);
+ return obj;
+}
+
+static VALUE
+fgdbm_set_cachesize(obj, val)
+ VALUE obj, val;
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ int optval;
+
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
+ optval = FIX2INT(val);
+ if (gdbm_setopt(dbm, GDBM_CACHESIZE, &optval, sizeof(optval)) == -1) {
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ return val;
+}
+
+static VALUE
+fgdbm_set_fastmode(obj, val)
+ VALUE obj, val;
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ int optval;
+
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
+ optval = 0;
+ if (RTEST(val))
+ optval = 1;
+
+ if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) {
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ return val;
+}
+
+static VALUE
+fgdbm_set_syncmode(obj, val)
+ VALUE obj, val;
+{
+#if !defined(GDBM_SYNCMODE)
+ fgdbm_set_fastmode(obj, RTEST(val) ? Qfalse : Qtrue);
+ return val;
+#else
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ int optval;
+
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
+ optval = 0;
+ if (RTEST(val))
+ optval = 1;
+
+ if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) {
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ return val;
+#endif
+}
+
+static VALUE
fgdbm_to_hash(obj)
VALUE obj;
{
- datum key, val;
struct dbmdata *dbmp;
GDBM_FILE dbm;
- VALUE hash;
+ VALUE keystr, hash;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
hash = rb_hash_new();
- for (key = gdbm_firstkey(dbm); key.dptr; key = gdbm_nextkey(dbm, key)) {
- val = gdbm_fetch(dbm, key);
- rb_hash_aset(hash, rb_tainted_str_new(key.dptr, key.dsize),
- rb_tainted_str_new(val.dptr, val.dsize));
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_hash_aset(hash, keystr, rb_gdbm_fetch2(dbm, keystr));
}
return hash;
@@ -624,46 +955,76 @@ fgdbm_reject(obj)
void
Init_gdbm()
{
- cGDBM = rb_define_class("GDBM", rb_cObject);
- rb_include_module(cGDBM, rb_mEnumerable);
-
- rb_define_singleton_method(cGDBM, "open", fgdbm_s_open, -1);
- rb_define_singleton_method(cGDBM, "new", fgdbm_s_open, -1);
- rb_define_method(cGDBM, "close", fgdbm_close, 0);
- rb_define_method(cGDBM, "[]", fgdbm_aref, 1);
- rb_define_method(cGDBM, "fetch", fgdbm_fetch_m, -1);
- rb_define_method(cGDBM, "[]=", fgdbm_store, 2);
- rb_define_method(cGDBM, "store", fgdbm_store, 2);
- rb_define_method(cGDBM, "index", fgdbm_index, 1);
- rb_define_method(cGDBM, "indexes", fgdbm_indexes, -1);
- rb_define_method(cGDBM, "indices", fgdbm_indexes, -1);
- rb_define_method(cGDBM, "length", fgdbm_length, 0);
- rb_define_alias(cGDBM, "size", "length");
- rb_define_method(cGDBM, "empty?", fgdbm_empty_p, 0);
- rb_define_method(cGDBM, "each", fgdbm_each_pair, 0);
- rb_define_method(cGDBM, "each_value", fgdbm_each_value, 0);
- rb_define_method(cGDBM, "each_key", fgdbm_each_key, 0);
- rb_define_method(cGDBM, "each_pair", fgdbm_each_pair, 0);
- rb_define_method(cGDBM, "keys", fgdbm_keys, 0);
- rb_define_method(cGDBM, "values", fgdbm_values, 0);
- rb_define_method(cGDBM, "shift", fgdbm_shift, 1);
- rb_define_method(cGDBM, "delete", fgdbm_delete, 1);
- rb_define_method(cGDBM, "delete_if", fgdbm_delete_if, 0);
- rb_define_method(cGDBM, "reject!", fgdbm_delete_if, 0);
- rb_define_method(cGDBM, "reject", fgdbm_reject, 0);
- rb_define_method(cGDBM, "clear", fgdbm_clear, 0);
- rb_define_method(cGDBM,"invert", fgdbm_invert, 0);
- rb_define_method(cGDBM,"update", fgdbm_update, 1);
- rb_define_method(cGDBM,"replace", fgdbm_replace, 1);
- rb_define_method(cGDBM,"reorganize", fgdbm_reorganize, 0);
-
- rb_define_method(cGDBM, "include?", fgdbm_has_key, 1);
- rb_define_method(cGDBM, "has_key?", fgdbm_has_key, 1);
- rb_define_method(cGDBM, "member?", fgdbm_has_key, 1);
- rb_define_method(cGDBM, "has_value?", fgdbm_has_value, 1);
- rb_define_method(cGDBM, "key?", fgdbm_has_key, 1);
- rb_define_method(cGDBM, "value?", fgdbm_has_value, 1);
-
- rb_define_method(cGDBM, "to_a", fgdbm_to_a, 0);
- rb_define_method(cGDBM, "to_hash", fgdbm_to_hash, 0);
+ rb_cGDBM = rb_define_class("GDBM", rb_cObject);
+ rb_eGDBMError = rb_define_class("GDBMError", rb_eStandardError);
+ rb_eGDBMFatalError = rb_define_class("GDBMFatalError", rb_eException);
+ rb_include_module(rb_cGDBM, rb_mEnumerable);
+
+ rb_define_alloc_func(rb_cGDBM, fgdbm_s_alloc);
+ rb_define_singleton_method(rb_cGDBM, "open", fgdbm_s_open, -1);
+
+ rb_define_method(rb_cGDBM, "initialize", fgdbm_initialize, -1);
+ rb_define_method(rb_cGDBM, "close", fgdbm_close, 0);
+ rb_define_method(rb_cGDBM, "[]", fgdbm_aref, 1);
+ rb_define_method(rb_cGDBM, "fetch", fgdbm_fetch_m, -1);
+ rb_define_method(rb_cGDBM, "[]=", fgdbm_store, 2);
+ rb_define_method(rb_cGDBM, "store", fgdbm_store, 2);
+ rb_define_method(rb_cGDBM, "index", fgdbm_index, 1);
+ rb_define_method(rb_cGDBM, "indexes", fgdbm_indexes, -1);
+ rb_define_method(rb_cGDBM, "indices", fgdbm_indexes, -1);
+ rb_define_method(rb_cGDBM, "select", fgdbm_select, -1);
+ rb_define_method(rb_cGDBM, "values_at", fgdbm_values_at, -1);
+ rb_define_method(rb_cGDBM, "length", fgdbm_length, 0);
+ rb_define_method(rb_cGDBM, "size", fgdbm_length, 0);
+ rb_define_method(rb_cGDBM, "empty?", fgdbm_empty_p, 0);
+ rb_define_method(rb_cGDBM, "each", fgdbm_each_pair, 0);
+ rb_define_method(rb_cGDBM, "each_value", fgdbm_each_value, 0);
+ rb_define_method(rb_cGDBM, "each_key", fgdbm_each_key, 0);
+ rb_define_method(rb_cGDBM, "each_pair", fgdbm_each_pair, 0);
+ rb_define_method(rb_cGDBM, "keys", fgdbm_keys, 0);
+ rb_define_method(rb_cGDBM, "values", fgdbm_values, 0);
+ rb_define_method(rb_cGDBM, "shift", fgdbm_shift, 0);
+ rb_define_method(rb_cGDBM, "delete", fgdbm_delete, 1);
+ rb_define_method(rb_cGDBM, "delete_if", fgdbm_delete_if, 0);
+ rb_define_method(rb_cGDBM, "reject!", fgdbm_delete_if, 0);
+ rb_define_method(rb_cGDBM, "reject", fgdbm_reject, 0);
+ rb_define_method(rb_cGDBM, "clear", fgdbm_clear, 0);
+ rb_define_method(rb_cGDBM,"invert", fgdbm_invert, 0);
+ rb_define_method(rb_cGDBM,"update", fgdbm_update, 1);
+ rb_define_method(rb_cGDBM,"replace", fgdbm_replace, 1);
+ rb_define_method(rb_cGDBM,"reorganize", fgdbm_reorganize, 0);
+ rb_define_method(rb_cGDBM,"sync", fgdbm_sync, 0);
+ /* rb_define_method(rb_cGDBM,"setopt", fgdbm_setopt, 2); */
+ rb_define_method(rb_cGDBM,"cachesize=", fgdbm_set_cachesize, 1);
+ rb_define_method(rb_cGDBM,"fastmode=", fgdbm_set_fastmode, 1);
+ rb_define_method(rb_cGDBM,"syncmode=", fgdbm_set_syncmode, 1);
+
+ rb_define_method(rb_cGDBM, "include?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "has_key?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "member?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "has_value?", fgdbm_has_value, 1);
+ rb_define_method(rb_cGDBM, "key?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "value?", fgdbm_has_value, 1);
+
+ rb_define_method(rb_cGDBM, "to_a", fgdbm_to_a, 0);
+ rb_define_method(rb_cGDBM, "to_hash", fgdbm_to_hash, 0);
+
+ /* flags for gdbm_open() */
+ rb_define_const(rb_cGDBM, "READER", INT2FIX(GDBM_READER|RUBY_GDBM_RW_BIT));
+ rb_define_const(rb_cGDBM, "WRITER", INT2FIX(GDBM_WRITER|RUBY_GDBM_RW_BIT));
+ rb_define_const(rb_cGDBM, "WRCREAT", INT2FIX(GDBM_WRCREAT|RUBY_GDBM_RW_BIT));
+ rb_define_const(rb_cGDBM, "NEWDB", INT2FIX(GDBM_NEWDB|RUBY_GDBM_RW_BIT));
+
+ rb_define_const(rb_cGDBM, "FAST", INT2FIX(GDBM_FAST));
+ /* this flag is obsolete in gdbm 1.8.
+ On gdbm 1.8, fast mode is default behavior. */
+
+ /* gdbm version 1.8 specific */
+#if defined(GDBM_SYNC)
+ rb_define_const(rb_cGDBM, "SYNC", INT2FIX(GDBM_SYNC));
+#endif
+#if defined(GDBM_NOLOCK)
+ rb_define_const(rb_cGDBM, "NOLOCK", INT2FIX(GDBM_NOLOCK));
+#endif
+ rb_define_const(rb_cGDBM, "VERSION", rb_str_new2(gdbm_version));
}
diff --git a/ext/gdbm/testgdbm.rb b/ext/gdbm/testgdbm.rb
new file mode 100644
index 0000000000..a435498640
--- /dev/null
+++ b/ext/gdbm/testgdbm.rb
@@ -0,0 +1,663 @@
+require 'runit/testcase'
+require 'runit/cui/testrunner'
+
+if $".grep(/\bgdbm.so\b/).empty?
+ begin
+ require './gdbm'
+ rescue LoadError
+ require 'gdbm'
+ end
+end
+
+def uname_s
+ require 'rbconfig'
+ case Config::CONFIG['host_os']
+ when 'cygwin'
+ require 'Win32API'
+ uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
+ utsname = ' ' * 100
+ raise 'cannot get system name' if uname.call(utsname) == -1
+
+ utsname.unpack('A20' * 5)[0]
+ else
+ Config::CONFIG['host_os']
+ end
+end
+
+SYSTEM = uname_s
+
+class TestGDBM < RUNIT::TestCase
+ def setup
+ @path = "tmptest_gdbm_"
+ assert_instance_of(GDBM, @gdbm = GDBM.new(@path))
+
+ # prepare to make readonly GDBM file
+ GDBM.open("tmptest_gdbm_rdonly", 0400) {|gdbm|
+ gdbm['foo'] = 'FOO'
+ }
+ assert_instance_of(GDBM, @gdbm_rdonly = GDBM.new("tmptest_gdbm_rdonly", nil))
+ end
+ def teardown
+ assert_nil(@gdbm.close)
+ assert_nil(@gdbm_rdonly.close)
+ GC.start
+ File.delete *Dir.glob("tmptest_gdbm*").to_a
+ p Dir.glob("tmptest_gdbm*") if $DEBUG
+ end
+
+ def check_size(expect, gdbm=@gdbm)
+ assert_equals(expect, gdbm.size)
+ n = 0
+ gdbm.each { n+=1 }
+ assert_equals(expect, n)
+ if expect == 0
+ assert_equals(true, gdbm.empty?)
+ else
+ assert_equals(false, gdbm.empty?)
+ end
+ end
+
+ def test_version
+ STDERR.print GDBM::VERSION
+ end
+
+ def test_s_new_has_no_block
+ # GDBM.new ignore the block
+ foo = true
+ assert_instance_of(GDBM, gdbm = GDBM.new("tmptest_gdbm") { foo = false })
+ assert_equals(foo, true)
+ assert_nil(gdbm.close)
+ end
+ def test_s_open_create_new
+ return if /^CYGWIN_9/ =~ SYSTEM
+
+ save_mask = File.umask(0)
+ begin
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm"))
+ gdbm.close
+ assert_equals(File.stat("tmptest_gdbm").mode & 0777, 0666)
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm2", 0644))
+ gdbm.close
+ assert_equals(File.stat("tmptest_gdbm2").mode & 0777, 0644)
+ ensure
+ File.umask save_mask
+ end
+ end
+ def test_s_open_no_create
+ # this test is failed on libgdbm 1.8.0
+ assert_nil(gdbm = GDBM.open("tmptest_gdbm", nil))
+ ensure
+ gdbm.close if gdbm
+ end
+ def test_s_open_3rd_arg
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
+ GDBM::FAST))
+ gdbm.close
+
+ # gdbm 1.8.0 specific
+ if defined? GDBM::SYNC
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
+ GDBM::SYNC))
+ gdbm.close
+ end
+ # gdbm 1.8.0 specific
+ if defined? GDBM::NOLOCK
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
+ GDBM::NOLOCK))
+ gdbm.close
+ end
+ end
+ def test_s_open_with_block
+ assert_equals(GDBM.open("tmptest_gdbm") { :foo }, :foo)
+ end
+ def test_s_open_lock
+ fork() {
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
+ sleep 2
+ }
+ begin
+ sleep 1
+ assert_exception(Errno::EWOULDBLOCK) {
+ begin
+ assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644))
+ rescue Errno::EAGAIN, Errno::EACCES
+ raise Errno::EWOULDBLOCK
+ end
+ }
+ ensure
+ Process.wait
+ end
+ end
+
+=begin
+ # Is it guaranteed on many OS?
+ def test_s_open_lock_one_process
+ # locking on one process
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
+ assert_exception(Errno::EWOULDBLOCK) {
+ begin
+ GDBM.open("tmptest_gdbm", 0644)
+ rescue Errno::EAGAIN
+ raise Errno::EWOULDBLOCK
+ end
+ }
+ end
+=end
+
+ def test_s_open_nolock
+ # gdbm 1.8.0 specific
+ if not defined? GDBM::NOLOCK
+ return
+ end
+
+ fork() {
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644,
+ GDBM::NOLOCK))
+ sleep 2
+ }
+ sleep 1
+ begin
+ gdbm2 = nil
+ assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
+ assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644))
+ }
+ ensure
+ Process.wait
+ gdbm2.close if gdbm2
+ end
+
+ p Dir.glob("tmptest_gdbm*") if $DEBUG
+
+ fork() {
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0644))
+ sleep 2
+ }
+ begin
+ sleep 1
+ gdbm2 = nil
+ assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
+ # this test is failed on Cygwin98 (???)
+ assert_instance_of(GDBM, gdbm2 = GDBM.open("tmptest_gdbm", 0644,
+ GDBM::NOLOCK))
+ }
+ ensure
+ Process.wait
+ gdbm2.close if gdbm2
+ end
+ end
+
+ def test_s_open_error
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm", 0))
+ assert_exception(Errno::EACCES) {
+ GDBM.open("tmptest_gdbm", 0)
+ }
+ gdbm.close
+ end
+
+ def test_close
+ assert_instance_of(GDBM, gdbm = GDBM.open("tmptest_gdbm"))
+ assert_nil(gdbm.close)
+
+ # closed GDBM file
+ assert_exception(RuntimeError) { gdbm.close }
+ end
+
+ def test_aref
+ assert_equals('bar', @gdbm['foo'] = 'bar')
+ assert_equals('bar', @gdbm['foo'])
+
+ assert_nil(@gdbm['bar'])
+ end
+
+ def test_fetch
+ assert_equals('bar', @gdbm['foo']='bar')
+ assert_equals('bar', @gdbm.fetch('foo'))
+
+ # key not found
+ assert_exception(IndexError) {
+ @gdbm.fetch('bar')
+ }
+
+ # test for `ifnone' arg
+ assert_equals('baz', @gdbm.fetch('bar', 'baz'))
+
+ # test for `ifnone' block
+ assert_equals('foobar', @gdbm.fetch('bar') {|key| 'foo' + key })
+ end
+
+ def test_aset
+ num = 0
+ 2.times {|i|
+ assert_equals('foo', @gdbm['foo'] = 'foo')
+ assert_equals('foo', @gdbm['foo'])
+ assert_equals('bar', @gdbm['foo'] = 'bar')
+ assert_equals('bar', @gdbm['foo'])
+
+ num += 1 if i == 0
+ assert_equals(num, @gdbm.size)
+
+ # assign nil
+ assert_equals('', @gdbm['bar'] = '')
+ assert_equals('', @gdbm['bar'])
+
+ num += 1 if i == 0
+ assert_equals(num, @gdbm.size)
+
+ # empty string
+ assert_equals('', @gdbm[''] = '')
+ assert_equals('', @gdbm[''])
+
+ num += 1 if i == 0
+ assert_equals(num, @gdbm.size)
+
+ # Fixnum
+ assert_equals('200', @gdbm['100'] = '200')
+ assert_equals('200', @gdbm['100'])
+
+ num += 1 if i == 0
+ assert_equals(num, @gdbm.size)
+
+ # Big key and value
+ assert_equals('y' * 100, @gdbm['x' * 100] = 'y' * 100)
+ assert_equals('y' * 100, @gdbm['x' * 100])
+
+ num += 1 if i == 0
+ assert_equals(num, @gdbm.size)
+ }
+ end
+
+ def test_index
+ assert_equals('bar', @gdbm['foo'] = 'bar')
+ assert_equals('foo', @gdbm.index('bar'))
+ assert_nil(@gdbm['bar'])
+ end
+
+ def test_indexes
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+ assert_equals(values.reverse, @gdbm.indexes(*keys.reverse))
+ end
+
+ def test_values_at
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+ assert_equals(values.reverse, @gdbm.values_at(*keys.reverse))
+ end
+
+ def test_select_with_block
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+ ret = @gdbm.select {|k,v|
+ assert_equals(k.upcase, v)
+ k != "bar"
+ }
+ assert_equals([['baz', 'BAZ'], ['foo', 'FOO']],
+ ret.sort)
+ end
+
+ def test_length
+ num = 10
+ assert_equals(0, @gdbm.size)
+ num.times {|i|
+ i = i.to_s
+ @gdbm[i] = i
+ }
+ assert_equals(num, @gdbm.size)
+
+ @gdbm.shift
+
+ assert_equals(num - 1, @gdbm.size)
+ end
+
+ def test_empty?
+ assert_equals(true, @gdbm.empty?)
+ @gdbm['foo'] = 'FOO'
+ assert_equals(false, @gdbm.empty?)
+ end
+
+ def test_each_pair
+ n = 0
+ @gdbm.each_pair { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+
+ n = 0
+ ret = @gdbm.each_pair {|key, val|
+ assert_not_nil(i = keys.index(key))
+ assert_equals(val, values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@gdbm, ret)
+ end
+
+ def test_each_value
+ n = 0
+ @gdbm.each_value { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+
+ n = 0
+ ret = @gdbm.each_value {|val|
+ assert_not_nil(key = @gdbm.index(val))
+ assert_not_nil(i = keys.index(key))
+ assert_equals(val, values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@gdbm, ret)
+ end
+
+ def test_each_key
+ n = 0
+ @gdbm.each_key { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+
+ n = 0
+ ret = @gdbm.each_key {|key|
+ assert_not_nil(i = keys.index(key))
+ assert_equals(@gdbm[key], values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@gdbm, ret)
+ end
+
+ def test_keys
+ assert_equals([], @gdbm.keys)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+
+ assert_equals(keys.sort, @gdbm.keys.sort)
+ assert_equals(values.sort, @gdbm.values.sort)
+ end
+
+ def test_values
+ test_keys
+ end
+
+ def test_shift
+ assert_nil(@gdbm.shift)
+ assert_equals(0, @gdbm.size)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+
+ ret_keys = []
+ ret_values = []
+ while ret = @gdbm.shift
+ ret_keys.push ret[0]
+ ret_values.push ret[1]
+
+ assert_equals(keys.size - ret_keys.size, @gdbm.size)
+ end
+
+ assert_equals(keys.sort, ret_keys.sort)
+ assert_equals(values.sort, ret_values.sort)
+ end
+
+ def test_delete
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ key = keys[1]
+
+ assert_nil(@gdbm.delete(key))
+ assert_equals(0, @gdbm.size)
+
+ @gdbm[keys[0]], @gdbm[keys[1]], @gdbm[keys[2]] = values
+
+ assert_equals('BAR', @gdbm.delete(key))
+ assert_nil(@gdbm[key])
+ assert_equals(2, @gdbm.size)
+
+ assert_nil(@gdbm.delete(key))
+
+ if /^CYGWIN_9/ !~ SYSTEM
+ assert_exception(GDBMError) {
+ @gdbm_rdonly.delete("foo")
+ }
+
+ assert_nil(@gdbm_rdonly.delete("bar"))
+ end
+ end
+ def test_delete_with_block
+ key = 'no called block'
+ @gdbm[key] = 'foo'
+ assert_equals('foo', @gdbm.delete(key) {|k| k.replace 'called block'})
+ assert_equals('no called block', key)
+ assert_equals(0, @gdbm.size)
+
+ key = 'no called block'
+ assert_equals(:blockval,
+ @gdbm.delete(key) {|k| k.replace 'called block'; :blockval})
+ assert_equals('called block', key)
+ assert_equals(0, @gdbm.size)
+ end
+
+ def test_delete_if
+ v = "0"
+ 100.times {@gdbm[v] = v; v = v.next}
+
+ ret = @gdbm.delete_if {|key, val| key.to_i < 50}
+ assert_equals(@gdbm, ret)
+ check_size(50, @gdbm)
+
+ ret = @gdbm.delete_if {|key, val| key.to_i >= 50}
+ assert_equals(@gdbm, ret)
+ check_size(0, @gdbm)
+
+ # break
+ v = "0"
+ 100.times {@gdbm[v] = v; v = v.next}
+ check_size(100, @gdbm)
+ n = 0;
+ @gdbm.delete_if {|key, val|
+ break if n > 50
+ n+=1
+ true
+ }
+ assert_equals(51, n)
+ check_size(49, @gdbm)
+
+ @gdbm.clear
+
+ # raise
+ v = "0"
+ 100.times {@gdbm[v] = v; v = v.next}
+ check_size(100, @gdbm)
+ n = 0;
+ begin
+ @gdbm.delete_if {|key, val|
+ raise "runtime error" if n > 50
+ n+=1
+ true
+ }
+ rescue
+ end
+ assert_equals(51, n)
+ check_size(49, @gdbm)
+ end
+
+ def test_reject
+ v = "0"
+ 100.times {@gdbm[v] = v; v = v.next}
+
+ hash = @gdbm.reject {|key, val| key.to_i < 50}
+ assert_instance_of(Hash, hash)
+ assert_equals(100, @gdbm.size)
+
+ assert_equals(50, hash.size)
+ hash.each_pair {|key,val|
+ assert_equals(false, key.to_i < 50)
+ assert_equals(key, val)
+ }
+
+ hash = @gdbm.reject {|key, val| key.to_i < 100}
+ assert_instance_of(Hash, hash)
+ assert_equals(true, hash.empty?)
+ end
+
+ def test_clear
+ v = "1"
+ 100.times {v = v.next; @gdbm[v] = v}
+
+ assert_equals(@gdbm, @gdbm.clear)
+
+ # validate GDBM#size
+ i = 0
+ @gdbm.each { i += 1 }
+ assert_equals(@gdbm.size, i)
+ assert_equals(0, i)
+ end
+
+ def test_invert
+ v = "0"
+ 100.times {@gdbm[v] = v; v = v.next}
+
+ hash = @gdbm.invert
+ assert_instance_of(Hash, hash)
+ assert_equals(100, hash.size)
+ hash.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_update
+ hash = {}
+ v = "0"
+ 100.times {v = v.next; hash[v] = v}
+
+ @gdbm["101"] = "101"
+ @gdbm.update hash
+ assert_equals(101, @gdbm.size)
+ @gdbm.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_replace
+ hash = {}
+ v = "0"
+ 100.times {v = v.next; hash[v] = v}
+
+ @gdbm["101"] = "101"
+ @gdbm.replace hash
+ assert_equals(100, @gdbm.size)
+ @gdbm.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_reorganize
+ size1 = File.size(@path)
+ i = "1"
+ 1000.times {i = i.next; @gdbm[i] = i}
+ @gdbm.clear
+ @gdbm.sync
+
+ size2 = File.size(@path)
+ @gdbm.reorganize
+ size3 = File.size(@path)
+
+ # p [size1, size2, size3]
+ assert_equals(true, size1 < size2)
+ # this test is failed on Cygwin98. `GDBM version 1.8.0, as of May 19, 1999'
+ assert_equals(true, size3 < size2)
+ assert_equals(size1, size3)
+ end
+
+ def test_sync
+ assert_instance_of(GDBM, gdbm = GDBM.open('tmptest_gdbm', 0666, GDBM::FAST))
+ assert_equals(gdbm.sync, gdbm)
+ gdbm.close
+ assert_instance_of(GDBM, gdbm = GDBM.open('tmptest_gdbm', 0666))
+ assert_equals(gdbm.sync, gdbm)
+ gdbm.close
+ end
+
+ def test_cachesize=
+ assert_equals(@gdbm.cachesize = 1024, 1024)
+ end
+
+ def test_fastmode=
+ assert_equals(@gdbm.fastmode = true, true)
+ end
+
+ def test_syncmode=
+ assert_equals(@gdbm.syncmode = true, true)
+ end
+
+ def test_haskey?
+ assert_equals('bar', @gdbm['foo']='bar')
+ assert_equals(true, @gdbm.has_key?('foo'))
+ assert_equals(false, @gdbm.has_key?('bar'))
+ end
+
+ def test_has_value?
+ assert_equals('bar', @gdbm['foo']='bar')
+ assert_equals(true, @gdbm.has_value?('bar'))
+ assert_equals(false, @gdbm.has_value?('foo'))
+ end
+
+ def test_to_a
+ v = "0"
+ 100.times {v = v.next; @gdbm[v] = v}
+
+ ary = @gdbm.to_a
+ assert_instance_of(Array, ary)
+ assert_equals(100, ary.size)
+ ary.each {|key,val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_to_hash
+ v = "0"
+ 100.times {v = v.next; @gdbm[v] = v}
+
+ hash = @gdbm.to_hash
+ assert_instance_of(Hash, hash)
+ assert_equals(100, hash.size)
+ hash.each {|key,val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+end
+
+if $0 == __FILE__
+ if ARGV.size == 0
+ suite = RUNIT::TestSuite.new
+ suite.add_test(TestGDBM.suite)
+ else
+ suite = RUNIT::TestSuite.new
+ ARGV.each do |testmethod|
+ suite.add_test(TestGDBM.new(testmethod))
+ end
+ end
+
+ RUNIT::CUI::TestRunner.run(suite)
+end
diff --git a/ext/iconv/.cvsignore b/ext/iconv/.cvsignore
new file mode 100644
index 0000000000..394787fced
--- /dev/null
+++ b/ext/iconv/.cvsignore
@@ -0,0 +1,5 @@
+Makefile
+mkmf.log
+*.def
+iconv.rb
+config.charset
diff --git a/ext/iconv/charset_alias.rb b/ext/iconv/charset_alias.rb
new file mode 100644
index 0000000000..65fd41759b
--- /dev/null
+++ b/ext/iconv/charset_alias.rb
@@ -0,0 +1,52 @@
+#! /usr/bin/ruby
+# :stopdoc:
+require 'rbconfig'
+
+# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
+# Fri, 30 May 2003 00:09:00 GMT'
+
+OS = Config::CONFIG["target"]
+SHELL = Config::CONFIG['SHELL']
+
+class Hash::Ordered < Hash
+ def [](key)
+ val = super and val.last
+ end
+ def []=(key, val)
+ ary = fetch(key) {return super(key, [self.size, key, val])} and
+ ary.last = val
+ end
+ def each
+ values.sort.each {|i, key, val| yield key, val}
+ end
+end
+
+def charset_alias(config_charset, mapfile, target = OS)
+ map = Hash::Ordered.new
+ comments = []
+ IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list|
+ next comments << list if /^\#/ =~ list
+ next unless /^(\S+)\s+(\S+)$/ =~ list
+ sys, can = $1, $2
+ can.downcase!
+ map[can] = sys
+ end
+ case target
+ when /linux|-gnu/
+ map.delete('ascii')
+ when /cygwin/
+ # get rid of tilde/yen problem.
+ map['shift_jis'] = 'cp932'
+ end
+ open(mapfile, "w") do |f|
+ f.puts("require 'iconv.so'")
+ f.puts
+ f.puts(comments)
+ f.puts("class Iconv")
+ map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")}
+ f.puts("end")
+ end
+end
+
+(2..3) === ARGV.size or abort "usage: #$0 config.status map.rb [target]"
+charset_alias(*ARGV)
diff --git a/ext/iconv/depend b/ext/iconv/depend
new file mode 100644
index 0000000000..688ddd97b7
--- /dev/null
+++ b/ext/iconv/depend
@@ -0,0 +1,2 @@
+iconv.o: iconv.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h \
+ $(hdrdir)/intern.h
diff --git a/ext/iconv/extconf.rb b/ext/iconv/extconf.rb
new file mode 100644
index 0000000000..65ea327950
--- /dev/null
+++ b/ext/iconv/extconf.rb
@@ -0,0 +1,49 @@
+require 'mkmf'
+
+dir_config("iconv")
+
+conf = File.exist?(File.join($srcdir, "config.charset"))
+conf = with_config("config-charset", enable_config("config-charset", conf))
+
+if have_func("iconv", "iconv.h") or
+ have_library("iconv", "iconv") {|s| s.sub(/(?=\n\/\*top\*\/)/, "#include <iconv.h>")}
+ if checking_for("const of iconv() 2nd argument") do
+ create_tmpsrc(cpp_include("iconv.h") + "---> iconv(cd,0,0,0,0) <---")
+ src = xpopen(cpp_command("")) {|f|f.read}
+ if !(func = src[/^--->\s*(\w+).*\s*<---/, 1])
+ Logging::message "iconv function name not found"
+ false
+ elsif !(second = src[%r"\b#{func}\s*\(.*?,(.*?),.*?\)\s*;"m, 1])
+ Logging::message "prototype for #{func}() not found"
+ false
+ else
+ Logging::message $&+"\n"
+ /\bconst\b/ =~ second
+ end
+ end
+ $defs.push('-DICONV_INPTR_CAST=""')
+ else
+ $defs.push('-DICONV_INPTR_CAST="(char **)"')
+ end
+ if conf
+ prefix = '$(srcdir)'
+ prefix = $nmake ? "{#{prefix}}" : "#{prefix}/"
+ wrapper = "./iconv.rb"
+ $INSTALLFILES = [[wrapper, "$(RUBYARCHDIR)"]]
+ if String === conf
+ require 'uri'
+ scheme = URI.parse(conf).scheme
+ else
+ conf = prefix + "config.charset"
+ end
+ $cleanfiles << wrapper
+ end
+ create_makefile("iconv")
+ if conf
+ open("Makefile", "a") do |mf|
+ mf.print("\nall: #{wrapper}\n\n#{wrapper}: #{prefix}charset_alias.rb")
+ mf.print(" ", conf) unless scheme
+ mf.print("\n\t$(RUBY) ", prefix, "charset_alias.rb ", conf, " $@\n")
+ end
+ end
+end
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
new file mode 100644
index 0000000000..29ab2c7d7b
--- /dev/null
+++ b/ext/iconv/iconv.c
@@ -0,0 +1,885 @@
+/* -*- mode:c; c-file-style:"ruby" -*- */
+/**********************************************************************
+
+ iconv.c -
+
+ $Author$
+ $Date$
+ created at: Wed Dec 1 20:28:09 JST 1999
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+ Documentation by Yukihiro Matsumoto and Gavin Sinclair.
+
+**********************************************************************/
+
+#include "ruby.h"
+#include <errno.h>
+#include <iconv.h>
+#include <assert.h>
+#include "st.h"
+#include "intern.h"
+
+/*
+ * Document-class: Iconv
+ *
+ * == Summary
+ *
+ * Ruby extension for charset conversion.
+ *
+ * == Abstract
+ *
+ * Iconv is a wrapper class for the UNIX 95 <tt>iconv()</tt> function family,
+ * which translates string between various encoding systems.
+ *
+ * See Open Group's on-line documents for more details.
+ * * <tt>iconv.h</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.h.html
+ * * <tt>iconv_open()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_open.html
+ * * <tt>iconv()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html
+ * * <tt>iconv_close()</tt>: http://www.opengroup.org/onlinepubs/007908799/xsh/iconv_close.html
+ *
+ * Which coding systems are available is platform-dependent.
+ *
+ * == Examples
+ *
+ * 1. Instantiate a new Iconv and use method Iconv#iconv.
+ *
+ * cd = Iconv.new(to, from)
+ * begin
+ * input.each { |s| output << cd.iconv(s) }
+ * output << cd.iconv(nil) # Don't forget this!
+ * ensure
+ * cd.close
+ * end
+ *
+ * 2. Invoke Iconv.open with a block.
+ *
+ * Iconv.open(to, from) do |cd|
+ * input.each { |s| output << cd.iconv(s) }
+ * output << cd.iconv(nil)
+ * end
+ *
+ * 3. Shorthand for (2).
+ *
+ * Iconv.iconv(to, from, *input.to_a)
+ *
+ * 4. Simple conversion between two charsets.
+ *
+ * converted_text = Iconv.new('iso-8859-15', 'utf-8').iconv(text)
+ */
+
+/* Invalid value for iconv_t is -1 but 0 for VALUE, I hope VALUE is
+ big enough to keep iconv_t */
+#define VALUE2ICONV(v) ((iconv_t)((VALUE)(v) ^ -1))
+#define ICONV2VALUE(c) ((VALUE)(c) ^ -1)
+
+struct iconv_env_t
+{
+ iconv_t cd;
+ int argc;
+ VALUE *argv;
+ VALUE ret;
+ VALUE (*append)_((VALUE, VALUE));
+};
+
+static VALUE rb_eIconvFailure;
+static VALUE rb_eIconvIllegalSeq;
+static VALUE rb_eIconvInvalidChar;
+static VALUE rb_eIconvOutOfRange;
+
+static ID rb_success, rb_failed;
+static VALUE iconv_fail _((VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg));
+static VALUE iconv_failure_initialize _((VALUE error, VALUE mesg, VALUE success, VALUE failed));
+static VALUE iconv_failure_success _((VALUE self));
+static VALUE iconv_failure_failed _((VALUE self));
+
+static iconv_t iconv_create _((VALUE to, VALUE from));
+static void iconv_dfree _((void *cd));
+static VALUE iconv_free _((VALUE cd));
+static VALUE iconv_try _((iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen));
+static VALUE rb_str_derive _((VALUE str, const char* ptr, int len));
+static VALUE iconv_convert _((iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env));
+static VALUE iconv_s_allocate _((VALUE klass));
+static VALUE iconv_initialize _((VALUE self, VALUE to, VALUE from));
+static VALUE iconv_s_open _((VALUE self, VALUE to, VALUE from));
+static VALUE iconv_s_convert _((struct iconv_env_t* env));
+static VALUE iconv_s_iconv _((int argc, VALUE *argv, VALUE self));
+static VALUE iconv_init_state _((VALUE cd));
+static VALUE iconv_finish _((VALUE self));
+static VALUE iconv_iconv _((int argc, VALUE *argv, VALUE self));
+
+static VALUE charset_map;
+
+static VALUE charset_map_get _((void))
+{
+ return charset_map;
+}
+
+static char *
+map_charset
+#ifdef HAVE_PROTOTYPES
+ (VALUE *code)
+#else /* HAVE_PROTOTYPES */
+ (code)
+ VALUE *code;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE val = *code;
+
+ if (RHASH(charset_map)->tbl && RHASH(charset_map)->tbl->num_entries) {
+ VALUE key = rb_funcall2(val, rb_intern("downcase"), 0, 0);
+ StringValuePtr(key);
+ if (st_lookup(RHASH(charset_map)->tbl, key, &val)) {
+ *code = val;
+ }
+ }
+ return StringValuePtr(*code);
+}
+
+static iconv_t
+iconv_create
+#ifdef HAVE_PROTOTYPES
+ (VALUE to, VALUE from)
+#else /* HAVE_PROTOTYPES */
+ (to, from)
+ VALUE to;
+ VALUE from;
+#endif /* HAVE_PROTOTYPES */
+{
+ const char* tocode = map_charset(&to);
+ const char* fromcode = map_charset(&from);
+
+ iconv_t cd = iconv_open(tocode, fromcode);
+
+ if (cd == (iconv_t)-1) {
+ switch (errno) {
+ case EMFILE:
+ case ENFILE:
+ case ENOMEM:
+ rb_gc();
+ cd = iconv_open(tocode, fromcode);
+ }
+ if (cd == (iconv_t)-1) {
+ volatile VALUE msg = rb_str_new2("iconv(\"");
+ rb_str_buf_cat2(rb_str_buf_append(msg, to), "\", \"");
+ rb_str_buf_cat2(rb_str_buf_append(msg, from), "\")");
+ rb_sys_fail(StringValuePtr(msg));
+ }
+ }
+
+ return cd;
+}
+
+static void
+iconv_dfree
+#ifdef HAVE_PROTOTYPES
+ (void *cd)
+#else /* HAVE_PROTOTYPES */
+ (cd)
+ void *cd;
+#endif /* HAVE_PROTOTYPES */
+{
+ iconv_close(VALUE2ICONV(cd));
+}
+
+#define ICONV_FREE iconv_dfree
+
+static VALUE
+iconv_free
+#ifdef HAVE_PROTOTYPES
+ (VALUE cd)
+#else /* HAVE_PROTOTYPES */
+ (cd)
+ VALUE cd;
+#endif /* HAVE_PROTOTYPES */
+{
+ if (cd && iconv_close(VALUE2ICONV(cd)) == -1)
+ rb_sys_fail("iconv_close");
+ return Qnil;
+}
+
+static VALUE
+check_iconv
+#ifdef HAVE_PROTOTYPES
+ (VALUE obj)
+#else /* HAVE_PROTOTYPES */
+ (obj)
+ VALUE obj;
+#endif /* HAVE_PROTOTYPES */
+{
+ Check_Type(obj, T_DATA);
+ if (RDATA(obj)->dfree != ICONV_FREE) {
+ rb_raise(rb_eArgError, "Iconv expected (%s)", rb_class2name(CLASS_OF(obj)));
+ }
+ return (VALUE)DATA_PTR(obj);
+}
+
+static VALUE
+iconv_try
+#ifdef HAVE_PROTOTYPES
+ (iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen)
+#else /* HAVE_PROTOTYPES */
+ (cd, inptr, inlen, outptr, outlen)
+ iconv_t cd;
+ const char **inptr;
+ size_t *inlen;
+ char **outptr;
+ size_t *outlen;
+#endif /* HAVE_PROTOTYPES */
+{
+ size_t ret = iconv(cd, ICONV_INPTR_CAST inptr, inlen, outptr, outlen);
+ if (ret == (size_t)-1) {
+ if (!*inlen)
+ return Qfalse;
+ switch (errno) {
+ case E2BIG:
+ /* try the left in next loop */
+ break;
+ case EILSEQ:
+ return rb_eIconvIllegalSeq;
+ case EINVAL:
+ return rb_eIconvInvalidChar;
+ default:
+ rb_sys_fail("iconv");
+ }
+ }
+ else if (*inlen > 0) {
+ /* something goes wrong */
+ return rb_eIconvIllegalSeq;
+ }
+ else if (ret) {
+ return Qnil; /* conversion */
+ }
+ return Qfalse;
+}
+
+#define FAILED_MAXLEN 16
+
+static VALUE iconv_failure_initialize
+#ifdef HAVE_PROTOTYPES
+ (VALUE error, VALUE mesg, VALUE success, VALUE failed)
+#else /* HAVE_PROTOTYPES */
+ (error, mesg, success, failed)
+ VALUE error, mesg, success, failed;
+#endif /* HAVE_PROTOTYPES */
+{
+ rb_call_super(1, &mesg);
+ rb_ivar_set(error, rb_success, success);
+ rb_ivar_set(error, rb_failed, failed);
+ return error;
+}
+
+static VALUE
+iconv_fail
+#ifdef HAVE_PROTOTYPES
+ (VALUE error, VALUE success, VALUE failed, struct iconv_env_t* env, const char *mesg)
+#else /* HAVE_PROTOTYPES */
+ (error, success, failed, env, mesg)
+ VALUE error, success, failed;
+ struct iconv_env_t *env;
+ const char *mesg;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE args[3];
+
+ if (mesg && *mesg) {
+ args[0] = rb_str_new2(mesg);
+ }
+ else if (TYPE(failed) != T_STRING || RSTRING(failed)->len < FAILED_MAXLEN) {
+ args[0] = rb_inspect(failed);
+ }
+ else {
+ args[0] = rb_inspect(rb_str_substr(failed, 0, FAILED_MAXLEN));
+ rb_str_cat2(args[0], "...");
+ }
+ args[1] = success;
+ args[2] = failed;
+ if (env) {
+ args[1] = env->append(rb_obj_dup(env->ret), success);
+ if (env->argc > 0) {
+ *(env->argv) = failed;
+ args[2] = rb_ary_new4(env->argc, env->argv);
+ }
+ }
+ error = rb_class_new_instance(3, args, error);
+ if (!rb_block_given_p()) rb_exc_raise(error);
+ ruby_errinfo = error;
+ return rb_yield(failed);
+}
+
+static VALUE
+rb_str_derive
+#ifdef HAVE_PROTOTYPES
+ (VALUE str, const char* ptr, int len)
+#else /* HAVE_PROTOTYPES */
+ (str, ptr, len)
+ VALUE str;
+ const char *ptr;
+ int len;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE ret;
+
+ if (NIL_P(str))
+ return rb_str_new(ptr, len);
+ if (RSTRING(str)->ptr == ptr && RSTRING(str)->len == len)
+ return str;
+ if (RSTRING(str)->ptr + RSTRING(str)->len == ptr + len)
+ ret = rb_str_substr(str, ptr - RSTRING(str)->ptr, len);
+ else
+ ret = rb_str_new(ptr, len);
+ OBJ_INFECT(ret, str);
+ return ret;
+}
+
+static VALUE
+iconv_convert
+#ifdef HAVE_PROTOTYPES
+ (iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env)
+#else /* HAVE_PROTOTYPES */
+ (cd, str, start, length, env)
+ iconv_t cd;
+ VALUE str;
+ int start;
+ int length;
+ struct iconv_env_t *env;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE ret = Qfalse;
+ VALUE error = Qfalse;
+ VALUE rescue;
+ const char *inptr, *instart;
+ size_t inlen;
+ /* I believe ONE CHARACTER never exceed this. */
+ char buffer[BUFSIZ];
+ char *outptr;
+ size_t outlen;
+
+ if (cd == (iconv_t)-1)
+ rb_raise(rb_eArgError, "closed iconv");
+
+ if (NIL_P(str)) {
+ /* Reset output pointer or something. */
+ inptr = "";
+ inlen = 0;
+ outptr = buffer;
+ outlen = sizeof(buffer);
+ error = iconv_try(cd, &inptr, &inlen, &outptr, &outlen);
+ if (RTEST(error)) {
+ unsigned int i;
+ rescue = iconv_fail(error, Qnil, Qnil, env, 0);
+ if (TYPE(rescue) == T_ARRAY) {
+ str = RARRAY(rescue)->len > 0 ? RARRAY(rescue)->ptr[0] : Qnil;
+ }
+ if (FIXNUM_P(str) && (i = FIX2INT(str)) <= 0xff) {
+ char c = i;
+ str = rb_str_new(&c, 1);
+ }
+ else if (!NIL_P(str)) {
+ StringValue(str);
+ }
+ }
+
+ inptr = NULL;
+ length = 0;
+ }
+ else {
+ int slen;
+
+ StringValue(str);
+ slen = RSTRING(str)->len;
+ inptr = RSTRING(str)->ptr;
+
+ if (start < 0 ? (start += slen) < 0 : start >= slen)
+ length = 0;
+ else if (length < 0 && (length += slen + 1) < 0)
+ length = 0;
+ else if ((length -= start) < 0)
+ length = 0;
+ else
+ inptr += start;
+ }
+ instart = inptr;
+ inlen = length;
+
+ do {
+ char errmsg[50];
+ const char *tmpstart = inptr;
+ outptr = buffer;
+ outlen = sizeof(buffer);
+
+ errmsg[0] = 0;
+ error = iconv_try(cd, &inptr, &inlen, &outptr, &outlen);
+
+ if (0 <= outlen && outlen <= sizeof(buffer)) {
+ outlen = sizeof(buffer) - outlen;
+ if (NIL_P(error) || /* something converted */
+ outlen > inptr - tmpstart || /* input can't contain output */
+ (outlen < inptr - tmpstart && inlen > 0) || /* something skipped */
+ memcmp(buffer, tmpstart, outlen)) /* something differs */
+ {
+ if (NIL_P(str)) {
+ ret = rb_str_new(buffer, outlen);
+ }
+ else {
+ if (ret) {
+ ret = rb_str_buf_cat(ret, instart, tmpstart - instart);
+ }
+ else {
+ ret = rb_str_new(instart, tmpstart - instart);
+ OBJ_INFECT(ret, str);
+ }
+ ret = rb_str_buf_cat(ret, buffer, outlen);
+ instart = inptr;
+ }
+ }
+ else if (!inlen) {
+ inptr = tmpstart + outlen;
+ }
+ }
+ else {
+ /* Some iconv() have a bug, return *outlen out of range */
+ sprintf(errmsg, "bug?(output length = %ld)", (long)(sizeof(buffer) - outlen));
+ error = rb_eIconvOutOfRange;
+ }
+
+ if (RTEST(error)) {
+ long len = 0;
+
+ if (!ret)
+ ret = rb_str_derive(str, instart, inptr - instart);
+ else if (inptr > instart)
+ rb_str_cat(ret, instart, inptr - instart);
+ str = rb_str_derive(str, inptr, inlen);
+ rescue = iconv_fail(error, ret, str, env, errmsg);
+ if (TYPE(rescue) == T_ARRAY) {
+ if ((len = RARRAY(rescue)->len) > 0)
+ rb_str_concat(ret, RARRAY(rescue)->ptr[0]);
+ if (len > 1 && !NIL_P(str = RARRAY(rescue)->ptr[1])) {
+ StringValue(str);
+ inlen = length = RSTRING(str)->len;
+ instart = inptr = RSTRING(str)->ptr;
+ continue;
+ }
+ }
+ else if (!NIL_P(rescue)) {
+ rb_str_concat(ret, rescue);
+ }
+ break;
+ }
+ } while (inlen > 0);
+
+ if (!ret)
+ ret = rb_str_derive(str, instart, inptr - instart);
+ else if (inptr > instart)
+ rb_str_cat(ret, instart, inptr - instart);
+ return ret;
+}
+
+static VALUE
+iconv_s_allocate
+#ifdef HAVE_PROTOTYPES
+ (VALUE klass)
+#else /* HAVE_PROTOTYPES */
+ (klass)
+ VALUE klass;
+#endif /* HAVE_PROTOTYPES */
+{
+ return Data_Wrap_Struct(klass, 0, ICONV_FREE, 0);
+}
+
+/*
+ * Document-method: new
+ * call-seq: Iconv.new(to, from)
+ *
+ * Creates new code converter from a coding-system designated with +from+
+ * to another one designated with +to+.
+ *
+ * === Parameters
+ *
+ * +to+:: encoding name for destination
+ * +from+:: encoding name for source
+ *
+ * === Exceptions
+ *
+ * TypeError:: if +to+ or +from+ aren't String
+ * ArgumentError:: if designated converter couldn't find out
+ * SystemCallError:: if <tt>iconv_open3</tt> fails
+ */
+static VALUE
+iconv_initialize
+#ifdef HAVE_PROTOTYPES
+ (VALUE self, VALUE to, VALUE from)
+#else /* HAVE_PROTOTYPES */
+ (self, to, from)
+ VALUE self;
+ VALUE to;
+ VALUE from;
+#endif /* HAVE_PROTOTYPES */
+{
+ iconv_free(check_iconv(self));
+ DATA_PTR(self) = NULL;
+ DATA_PTR(self) = (void *)ICONV2VALUE(iconv_create(to, from));
+ return self;
+}
+
+/*
+ * Document-method: open
+ * call-seq: Iconv.open(to, from) { |iconv| ... }
+ *
+ * Equivalent to Iconv.new except that when it is called with a block, it
+ * yields with the new instance and closes it, and returns the result which
+ * returned from the block.
+ */
+static VALUE
+iconv_s_open
+#ifdef HAVE_PROTOTYPES
+ (VALUE self, VALUE to, VALUE from)
+#else /* HAVE_PROTOTYPES */
+ (self, to, from)
+ VALUE self;
+ VALUE to;
+ VALUE from;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE cd = ICONV2VALUE(iconv_create(to, from));
+
+ self = Data_Wrap_Struct(self, NULL, ICONV_FREE, (void *)cd);
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, self, (VALUE(*)())iconv_finish, self);
+ }
+ else {
+ return self;
+ }
+}
+
+static VALUE
+iconv_s_convert
+#ifdef HAVE_PROTOTYPES
+ (struct iconv_env_t* env)
+#else /* HAVE_PROTOTYPES */
+ (env)
+ struct iconv_env_t *env;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE last = 0;
+
+ for (; env->argc > 0; --env->argc, ++env->argv) {
+ VALUE s = iconv_convert(env->cd, last = *(env->argv), 0, -1, env);
+ env->append(env->ret, s);
+ }
+
+ if (!NIL_P(last)) {
+ VALUE s = iconv_convert(env->cd, Qnil, 0, 0, env);
+ if (RSTRING(s)->len)
+ env->append(env->ret, s);
+ }
+
+ return env->ret;
+}
+
+/*
+ * Document-method: iconv
+ * call-seq: Iconv.iconv(to, from, *strs)
+ *
+ * Shorthand for
+ * Iconv.open(to, from) { |cd|
+ * (strs + [nil]).collect { |s| cd.iconv(s) }
+ * }
+ *
+ * === Parameters
+ *
+ * <tt>to, from</tt>:: see Iconv.new
+ * <tt>strs</tt>:: strings to be converted
+ *
+ * === Exceptions
+ *
+ * Exceptions thrown by Iconv.new, Iconv.open and Iconv#iconv.
+*/
+static VALUE
+iconv_s_iconv
+#ifdef HAVE_PROTOTYPES
+ (int argc, VALUE *argv, VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
+{
+ struct iconv_env_t arg;
+
+ if (argc < 2) /* needs `to' and `from' arguments at least */
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, 2);
+
+ arg.argc = argc -= 2;
+ arg.argv = argv + 2;
+ arg.append = rb_ary_push;
+ arg.ret = rb_ary_new2(argc);
+ arg.cd = iconv_create(argv[0], argv[1]);
+ return rb_ensure(iconv_s_convert, (VALUE)&arg, iconv_free, ICONV2VALUE(arg.cd));
+}
+
+/*
+ * Document-method: Iconv::conv
+ * call-seq: Iconv.iconv(to, from, *strs)
+ *
+ * See Iconv.iconv ???
+ */
+static VALUE
+iconv_s_conv
+#ifdef HAVE_PROTOTYPES
+ (VALUE self, VALUE to, VALUE from, VALUE str)
+#else /* HAVE_PROTOTYPES */
+ (self, to, from, str)
+ VALUE self, to, from, str;
+#endif /* HAVE_PROTOTYPES */
+{
+ struct iconv_env_t arg;
+
+ arg.argc = 1;
+ arg.argv = &str;
+ arg.append = rb_str_append;
+ arg.ret = rb_str_new(0, 0);
+ arg.cd = iconv_create(to, from);
+ return rb_ensure(iconv_s_convert, (VALUE)&arg, iconv_free, ICONV2VALUE(arg.cd));
+}
+
+/*
+ * Document-method: close
+ *
+ * Finishes conversion.
+ *
+ * After calling this, calling Iconv#iconv will cause an exception, but
+ * multiple calls of #close are guaranteed to end successfully.
+ *
+ * Returns a string containing the byte sequence to change the output buffer to
+ * its initial shift state. <i>???</i>
+*/
+static VALUE
+iconv_init_state
+#ifdef HAVE_PROTOTYPES
+ (VALUE cd)
+#else /* HAVE_PROTOTYPES */
+ (cd)
+ VALUE cd;
+#endif /* HAVE_PROTOTYPES */
+{
+ return iconv_convert(VALUE2ICONV(cd), Qnil, 0, 0, NULL);
+}
+
+static VALUE
+iconv_finish
+#ifdef HAVE_PROTOTYPES
+ (VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE cd = check_iconv(self);
+
+ if (!cd) return Qnil;
+ DATA_PTR(self) = NULL;
+
+ return rb_ensure(iconv_init_state, cd, iconv_free, cd);
+}
+
+/*
+ * Document-method: iconv
+ * call-seq: iconv(str, start=0, length=-1)
+ *
+ * Converts string and returns the result.
+ * * If +str+ is a String, converts <tt>str[start, length]</tt> and returns the converted string.
+ * * If +str+ is +nil+, places converter itself into initial shift state and
+ * just returns a string containing the byte sequence to change the output
+ * buffer to its initial shift state.
+ * * Otherwise, raises an exception.
+ *
+ * === Parameters
+ *
+ * str:: string to be converted, or nil
+ * start:: starting offset
+ * length:: conversion length; nil or -1 means whole the string from start
+ *
+ * === Exceptions
+ *
+ * * IconvIllegalSequence
+ * * IconvInvalidCharacter
+ * * IconvOutOfRange
+ *
+ * === Examples
+ *
+ * See the Iconv documentation.
+*/
+static VALUE
+iconv_iconv
+#ifdef HAVE_PROTOTYPES
+ (int argc, VALUE *argv, VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
+{
+ VALUE str, n1, n2;
+ VALUE cd = check_iconv(self);
+
+ n1 = n2 = Qnil;
+ rb_scan_args(argc, argv, "12", &str, &n1, &n2);
+
+ return iconv_convert(VALUE2ICONV(cd), str,
+ NIL_P(n1) ? 0 : NUM2INT(n1),
+ NIL_P(n2) ? -1 : NUM2INT(n1),
+ NULL);
+}
+
+/*
+ * Document-class: Iconv::Failure
+ *
+ * Base attributes for Iconv exceptions.
+ *
+ * === Iconv::Failure#success
+ *
+ * Returns string(s) translated successfully until the exception occurred.
+ * * In the case of failure occurred within Iconv.iconv, returned
+ * value is an array of strings translated successfully preceding
+ * failure and the last element is string on the way.
+ *
+ * === Iconv::Failure#failed
+ *
+ * Returns substring of the original string passed to Iconv that starts at the
+ * character caused the exception.
+ *
+ * === Iconv::Failure#inspect
+ *
+ * Returns inspected string like as: #<_class_: _success_, _failed_>
+ */
+static VALUE
+iconv_failure_success
+#ifdef HAVE_PROTOTYPES
+(VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
+{
+ return rb_attr_get(self, rb_success);
+}
+
+/*
+ * Comment!
+ */
+static VALUE
+iconv_failure_failed
+#ifdef HAVE_PROTOTYPES
+(VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
+{
+ return rb_attr_get(self, rb_failed);
+}
+
+static VALUE
+iconv_failure_inspect
+#ifdef HAVE_PROTOTYPES
+ (VALUE self)
+#else /* HAVE_PROTOTYPES */
+ (self)
+ VALUE self;
+#endif /* HAVE_PROTOTYPES */
+{
+ char *cname = rb_class2name(CLASS_OF(self));
+ VALUE success = rb_attr_get(self, rb_success);
+ VALUE failed = rb_attr_get(self, rb_failed);
+ VALUE str = rb_str_buf_cat2(rb_str_new2("#<"), cname);
+ str = rb_str_buf_cat(str, ": ", 2);
+ str = rb_str_buf_append(str, rb_inspect(success));
+ str = rb_str_buf_cat(str, ", ", 2);
+ str = rb_str_buf_append(str, rb_inspect(failed));
+ return rb_str_buf_cat(str, ">", 1);
+}
+
+/*
+ * Document-class: Iconv::IllegalSequence
+ *
+ * Input conversion stopped due to an input byte that does not belong to
+ * the input codeset, or the output codeset does not contain the
+ * character.
+ *
+ * === Superclass
+ *
+ * ArgumentError
+ *
+ * === Included Modules
+ *
+ * Iconv::Failure
+ */
+
+/*
+ * Document-class: Iconv::InvalidCharacter
+ *
+ * Input conversion stopped due to an incomplete character or shift
+ * sequence at the end of the input buffer.
+ *
+ * === Superclass
+ *
+ * ArgumentError
+ *
+ * === Included Modules
+ *
+ * Iconv::Failure
+ */
+
+/*
+ * Document-class: Iconv::OutOfRange
+ *
+ * Iconv library internal error. Must not occur.
+ *
+ * === Superclass
+ *
+ * RuntimeError
+ *
+ * === Included Modules
+ *
+ * Iconv::Failure
+ */
+
+void
+Init_iconv _((void))
+{
+ VALUE rb_cIconv = rb_define_class("Iconv", rb_cData);
+
+ rb_define_alloc_func(rb_cIconv, iconv_s_allocate);
+ rb_define_singleton_method(rb_cIconv, "open", iconv_s_open, 2);
+ rb_define_singleton_method(rb_cIconv, "iconv", iconv_s_iconv, -1);
+ rb_define_singleton_method(rb_cIconv, "conv", iconv_s_conv, 3);
+ rb_define_method(rb_cIconv, "initialize", iconv_initialize, 2);
+ rb_define_method(rb_cIconv, "close", iconv_finish, 0);
+ rb_define_method(rb_cIconv, "iconv", iconv_iconv, -1);
+
+ rb_eIconvFailure = rb_define_module_under(rb_cIconv, "Failure");
+ rb_define_method(rb_eIconvFailure, "initialize", iconv_failure_initialize, 3);
+ rb_define_method(rb_eIconvFailure, "success", iconv_failure_success, 0);
+ rb_define_method(rb_eIconvFailure, "failed", iconv_failure_failed, 0);
+ rb_define_method(rb_eIconvFailure, "inspect", iconv_failure_inspect, 0);
+
+ rb_eIconvIllegalSeq = rb_define_class_under(rb_cIconv, "IllegalSequence", rb_eArgError);
+ rb_eIconvInvalidChar = rb_define_class_under(rb_cIconv, "InvalidCharacter", rb_eArgError);
+ rb_eIconvOutOfRange = rb_define_class_under(rb_cIconv, "OutOfRange", rb_eRuntimeError);
+ rb_include_module(rb_eIconvIllegalSeq, rb_eIconvFailure);
+ rb_include_module(rb_eIconvInvalidChar, rb_eIconvFailure);
+ rb_include_module(rb_eIconvOutOfRange, rb_eIconvFailure);
+
+ rb_success = rb_intern("success");
+ rb_failed = rb_intern("failed");
+
+ charset_map = rb_hash_new();
+ rb_gc_register_address(&charset_map);
+ rb_define_singleton_method(rb_cIconv, "charset_map", charset_map_get, 0);
+}
+
diff --git a/ext/io/wait/.cvsignore b/ext/io/wait/.cvsignore
new file mode 100644
index 0000000000..fc802ff1c2
--- /dev/null
+++ b/ext/io/wait/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+mkmf.log
diff --git a/ext/io/wait/extconf.rb b/ext/io/wait/extconf.rb
new file mode 100644
index 0000000000..ea7dc9f6cf
--- /dev/null
+++ b/ext/io/wait/extconf.rb
@@ -0,0 +1,12 @@
+require 'mkmf'
+target = "io/wait"
+
+unless macro_defined?("DOSISH", "#include <ruby.h>")
+ fionread = %w[sys/ioctl.h sys/filio.h].find do |h|
+ checking_for("FIONREAD") {macro_defined?("FIONREAD", "#include <#{h}>\n")}
+ end
+ if fionread
+ $defs << "-DFIONREAD_HEADER=\"<#{fionread}>\""
+ create_makefile(target)
+ end
+end
diff --git a/ext/io/wait/lib/nonblock.rb b/ext/io/wait/lib/nonblock.rb
new file mode 100644
index 0000000000..46511fb40c
--- /dev/null
+++ b/ext/io/wait/lib/nonblock.rb
@@ -0,0 +1,23 @@
+require "fcntl"
+class IO
+ def nonblock?
+ (fcntl(Fcntl::F_GETFL) & File::NONBLOCK) != 0
+ end
+
+ def nonblock=(nb)
+ f = fcntl(Fcntl::F_GETFL)
+ if nb
+ f |= File::NONBLOCK
+ else
+ f &= ~File::NONBLOCK
+ end
+ fcntl(Fcntl::F_SETFL, f)
+ end
+
+ def nonblock(nb = true)
+ nb, self.nonblock = nonblock?, nb
+ yield
+ ensure
+ self.nonblock = nb
+ end
+end
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
new file mode 100644
index 0000000000..53d5bd7d18
--- /dev/null
+++ b/ext/io/wait/wait.c
@@ -0,0 +1,106 @@
+/**********************************************************************
+
+ io/wait.c -
+
+ $Author$
+ $Date$
+ created at: Tue Aug 28 09:08:06 JST 2001
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "ruby.h"
+#include "rubyio.h"
+
+#include <sys/types.h>
+#include FIONREAD_HEADER
+
+static VALUE io_ready_p _((VALUE io));
+static VALUE io_wait _((int argc, VALUE *argv, VALUE io));
+void Init_wait _((void));
+
+EXTERN struct timeval rb_time_interval _((VALUE time));
+
+/*
+=begin
+= IO wait methods.
+=end
+ */
+
+/*
+=begin
+--- IO#ready?
+ returns non-nil if input available without blocking, or nil.
+=end
+*/
+static VALUE
+io_ready_p(io)
+ VALUE io;
+{
+ OpenFile *fptr;
+ FILE *fp;
+ int n;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ fp = fptr->f;
+ if (feof(fp)) return Qfalse;
+ if (rb_read_pending(fp)) return Qtrue;
+ if (ioctl(fileno(fp), FIONREAD, &n)) rb_sys_fail(0);
+ if (n > 0) return INT2NUM(n);
+ return Qnil;
+}
+
+/*
+=begin
+--- IO#wait([timeout])
+ waits until input available or timed out and returns self, or nil
+ when EOF reached.
+=end
+*/
+static VALUE
+io_wait(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
+{
+ OpenFile *fptr;
+ fd_set rd;
+ FILE *fp;
+ int fd, n;
+ VALUE timeout;
+ struct timeval *tp, timerec;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ rb_scan_args(argc, argv, "01", &timeout);
+ if (NIL_P(timeout)) {
+ tp = 0;
+ }
+ else {
+ timerec = rb_time_interval(timeout);
+ tp = &timerec;
+ }
+
+ fp = fptr->f;
+ if (feof(fp)) return Qfalse;
+ if (rb_read_pending(fp)) return Qtrue;
+ fd = fileno(fp);
+ FD_ZERO(&rd);
+ FD_SET(fd, &rd);
+ if (rb_thread_select(fd + 1, &rd, NULL, NULL, tp) < 0)
+ rb_sys_fail(0);
+ rb_io_check_closed(fptr);
+ if (ioctl(fileno(fp), FIONREAD, &n)) rb_sys_fail(0);
+ if (n > 0) return io;
+ return Qnil;
+}
+
+void
+Init_wait()
+{
+ rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
+ rb_define_method(rb_cIO, "wait", io_wait, -1);
+}
diff --git a/ext/md5/MANIFEST b/ext/md5/MANIFEST
deleted file mode 100644
index 189a482afb..0000000000
--- a/ext/md5/MANIFEST
+++ /dev/null
@@ -1,8 +0,0 @@
-MANIFEST
-depend
-extconf.rb
-md5.txt
-md5.txt.jp
-md5.h
-md5c.c
-md5init.c
diff --git a/ext/md5/depend b/ext/md5/depend
deleted file mode 100644
index 14427861f8..0000000000
--- a/ext/md5/depend
+++ /dev/null
@@ -1,2 +0,0 @@
-md5c.o: md5c.c md5.h $(topdir)/config.h
-md5init.o: md5init.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h md5.h
diff --git a/ext/md5/extconf.rb b/ext/md5/extconf.rb
deleted file mode 100644
index a57a976a39..0000000000
--- a/ext/md5/extconf.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'mkmf'
-$CFLAGS += " -DHAVE_CONFIG_H"
-create_makefile('md5')
diff --git a/ext/md5/md5.h b/ext/md5/md5.h
deleted file mode 100644
index 81a6d7ff36..0000000000
--- a/ext/md5/md5.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* MD5.H - header file for MD5C.C
- */
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
- */
-
-/* ========== include global.h ========== */
-/* GLOBAL.H - RSAREF types and constants
- */
-
-/* PROTOTYPES should be set to one if and only if the compiler supports
- function argument prototyping.
-The following makes PROTOTYPES default to 0 if it has not already
- been defined with C compiler flags.
- */
-#ifdef HAVE_PROTOTYPES
-#define PROTOTYPES 1
-#endif
-#ifndef PROTOTYPES
-#define PROTOTYPES 0
-#endif
-
-/* POINTER defines a generic pointer type */
-typedef unsigned char *POINTER;
-
-/* UINT2 defines a two byte word */
-typedef unsigned short int UINT2;
-
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#else
-/* Wild guess */
-#define LONG_MAX 2147483647L
-#endif
-
-/* UINT4 defines a four byte word */
-#if defined(INT_MAX) && INT_MAX == 2147483647
-typedef unsigned int UINT4;
-#else
-#if defined(LONG_MAX) && LONG_MAX == 2147483647L
-typedef unsigned long int UINT4;
-#endif
-/* Too bad if neither is */
-#endif
-
-/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
-If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
- returns an empty list.
- */
-#if PROTOTYPES
-#define PROTO_LIST(list) list
-#else
-#define PROTO_LIST(list) ()
-#endif
-/* ========== End global.h; continue md5.h ========== */
-
-/* MD5 context. */
-typedef struct {
- UINT4 state[4]; /* state (ABCD) */
- UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
- unsigned char buffer[64]; /* input buffer */
-} MD5_CTX;
-
-void MD5Init PROTO_LIST ((MD5_CTX *));
-void MD5Update PROTO_LIST
- ((MD5_CTX *, unsigned char *, unsigned int));
-void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
diff --git a/ext/md5/md5.txt b/ext/md5/md5.txt
deleted file mode 100644
index e2b072401b..0000000000
--- a/ext/md5/md5.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-.\" md5.doc - -*- Indented-Text -*- created at: Fri Aug 2 12:01:27 JST 1996
-
-** MD5(Class)
-
-A class to implement MD5 Message-Digest Algorithm by RSA Data
-Security, Inc., described in RFC1321.
-
-SuperClass: Object
-
-Class Methods:
-
- new([str])
- md5([str])
-
- creates a new MD5 object. If a string argument is given, it
- is added to the object. (see update.)
-
-Methods:
-
- clone
-
- copies the MD5 object.
-
- digest
-
- returns have value of the added strings as a 16 bytes string.
-
- hexdigest
-
- returns have value of the added strings as an 32 bytes ASCII
- string. This method is equal to:
-
- def hexdigest
- ret = ''
- digest.each_byte {|i| ret << sprintf('%02x', i) }
- ret
- end
-
- update(str)
-
- Update the MD5 object with the string. Repeated calls are
- equivalent to a single call with the concatenation of all the
- arguments, i.e. m.update(a); m.update(b) is equivalent to
- m.update(a+b).
-
--------------------------------------------------------
-Local variables:
-fill-column: 70
-end:
diff --git a/ext/md5/md5.txt.jp b/ext/md5/md5.txt.jp
deleted file mode 100644
index 04cf32908d..0000000000
--- a/ext/md5/md5.txt.jp
+++ /dev/null
@@ -1,49 +0,0 @@
-.\" md5.doc - -*- Indented-Text -*- created at: Fri Aug 2 12:01:27 JST 1996
-
-** MD5(¥¯¥é¥¹)
-
-RFC1321¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ëRSA Data Security, Inc. ¤Î MD5 Message-Digest
-Algorithm¤ò¼ÂÁõ¤¹¤ë¥¯¥é¥¹¡¥
-
-SuperClass: Object
-
-Class Methods:
-
- new([str])
- md5([str])
-
- ¿·¤·¤¤MD5¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤¹¤ë¡¥Ê¸»úÎó°ú¿ô¤¬Í¿¤¨¤é¤ì¤ë¤È¤½¤ì
- ¤òÄɲ乤ë(see update)¡¥
-
-Methods:
-
- clone
-
- MD5¥ª¥Ö¥¸¥§¥¯¥È¤ÎÊ£À½¤òºî¤ë
-
- digest
-
- º£¤Þ¤Ç¤ËÄɲä·¤¿Ê¸»úÎó¤ËÂФ¹¤ë¥Ï¥Ã¥·¥åÃͤò16¥Ð¥¤¥ÈŤÎʸ»úÎó¤Ç
- ÊÖ¤¹¡¥
-
- hexdigest
-
- º£¤Þ¤Ç¤ËÄɲä·¤¿Ê¸»úÎó¤ËÂФ¹¤ë¥Ï¥Ã¥·¥åÃͤò¡¢ASCII¥³¡¼¥É¤ò»È¤Ã¤Æ
- 16¿Ê¿ô¤ÎÎó¤ò¼¨¤¹'fe5c2235f48d2bcc911afabea23cd5aa'¤Î¤è¤¦¤Ê32ʸ»ú
- ¤Îʸ»úÎó¤Ë¥¨¥ó¥³¡¼¥É¤·¤ÆÊÖ¤¹¡£Ruby¤Ç½ñ¤¯¤È°Ê²¼¤ÈƱ¤¸¡£
-
- def hexdigest
- ret = ''
- digest.each_byte {|i| ret << sprintf('%02x', i) }
- ret
- end
-
- update(str)
-
- MD5¥ª¥Ö¥¸¥§¥¯¥È¤Ëʸ»úÎó¤òÄɲ乤롣ʣ¿ô²óupdate¤ò¸Æ¤Ö¤³¤È¤Ïʸ
- »úÎó¤òÏ¢·ë¤·¤Æupdate¤ò¸Æ¤Ö¤³¤È¤ÈÅù¤·¤¤¡¥
-
--------------------------------------------------------
-Local variables:
-fill-column: 70
-end:
diff --git a/ext/md5/md5c.c b/ext/md5/md5c.c
deleted file mode 100644
index d7c7e4fb27..0000000000
--- a/ext/md5/md5c.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
- */
-
-/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
-rights reserved.
-
-License to copy and use this software is granted provided that it
-is identified as the "RSA Data Security, Inc. MD5 Message-Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-License is also granted to make and use derivative works provided
-that such works are identified as "derived from the RSA Data
-Security, Inc. MD5 Message-Digest Algorithm" in all material
-mentioning or referencing the derived work.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "md5.h"
-
-/* Constants for MD5Transform routine.
- */
-
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
-
-static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
-static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
-static void Decode PROTO_LIST
- ((UINT4 *, unsigned char *, unsigned int));
-static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
-static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
-
-static unsigned char PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/* F, G, H and I are basic MD5 functions.
- */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-/* ROTATE_LEFT rotates x left n bits.
- */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
-Rotation is separate from addition to prevent recomputation.
- */
-#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-/* MD5 initialization. Begins an MD5 operation, writing a new context.
- */
-void MD5Init (context)
-MD5_CTX *context; /* context */
-{
- context->count[0] = context->count[1] = 0;
- /* Load magic initialization constants.
-*/
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
-}
-
-/* MD5 block update operation. Continues an MD5 message-digest
- operation, processing another message block, and updating the
- context.
- */
-void MD5Update (context, input, inputLen)
-MD5_CTX *context; /* context */
-unsigned char *input; /* input block */
-unsigned int inputLen; /* length of input block */
-{
- unsigned int i, index, partLen;
-
- /* Compute number of bytes mod 64 */
- index = (unsigned int)((context->count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((UINT4)inputLen >> 29);
-
- partLen = 64 - index;
-
- /* Transform as many times as possible.
-*/
- if (inputLen >= partLen) {
- MD5_memcpy
- ((POINTER)&context->buffer[index], (POINTER)input, partLen);
- MD5Transform (context->state, context->buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform (context->state, &input[i]);
-
- index = 0;
- }
- else
- i = 0;
-
- /* Buffer remaining input */
- MD5_memcpy
- ((POINTER)&context->buffer[index], (POINTER)&input[i],
- inputLen-i);
-}
-
-/* MD5 finalization. Ends an MD5 message-digest operation, writing the
- the message digest and zeroizing the context.
- */
-void MD5Final (digest, context)
-unsigned char digest[16]; /* message digest */
-MD5_CTX *context; /* context */
-{
- unsigned char bits[8];
- unsigned int index, padLen;
-
- /* Save number of bits */
- Encode (bits, context->count, 8);
-
- /* Pad out to 56 mod 64.
-*/
- index = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (index < 56) ? (56 - index) : (120 - index);
- MD5Update (context, PADDING, padLen);
-
- /* Append length (before padding) */
- MD5Update (context, bits, 8);
-
- /* Store state in digest */
- Encode (digest, context->state, 16);
-
- /* Zeroize sensitive information.
-*/
- MD5_memset ((POINTER)context, 0, sizeof (*context));
-}
-
-/* MD5 basic transformation. Transforms state based on block.
- */
-static void MD5Transform (state, block)
-UINT4 state[4];
-unsigned char block[64];
-{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode (x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information.
-*/
- MD5_memset ((POINTER)x, 0, sizeof (x));
-}
-
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
- a multiple of 4.
- */
-static void Encode (output, input, len)
-unsigned char *output;
-UINT4 *input;
-unsigned int len;
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char)(input[i] & 0xff);
- output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
- }
-}
-
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
- a multiple of 4.
- */
-static void Decode (output, input, len)
-UINT4 *output;
-unsigned char *input;
-unsigned int len;
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
- (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
-}
-
-/* Note: Replace "for loop" with standard memcpy if possible.
- */
-
-static void MD5_memcpy (output, input, len)
-POINTER output;
-POINTER input;
-unsigned int len;
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- output[i] = input[i];
-}
-
-/* Note: Replace "for loop" with standard memset if possible.
- */
-static void MD5_memset (output, value, len)
-POINTER output;
-int value;
-unsigned int len;
-{
- unsigned int i;
-
- for (i = 0; i < len; i++)
- ((char *)output)[i] = (char)value;
-}
diff --git a/ext/md5/md5init.c b/ext/md5/md5init.c
deleted file mode 100644
index a57d5f8f30..0000000000
--- a/ext/md5/md5init.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/************************************************
-
- md5init.c -
-
- $Author$
- created at: Fri Aug 2 09:24:12 JST 1996
-
- Copyright (C) 1995-1998 Yukihiro Matsumoto
-
-************************************************/
-/* This module provides an interface to the RSA Data Security,
- Inc. MD5 Message-Digest Algorithm, described in RFC 1321.
- It requires the files md5c.c and md5.h (which are slightly changed
- from the versions in the RFC to avoid the "global.h" file.) */
-
-#include "ruby.h"
-#include "md5.h"
-
-static VALUE cMD5;
-
-static VALUE
-md5_update(obj, str)
- VALUE obj;
- struct RString *str;
-{
- MD5_CTX *md5;
-
- Check_Type(str, T_STRING);
- Data_Get_Struct(obj, MD5_CTX, md5);
- MD5Update(md5, str->ptr, str->len);
-
- return obj;
-}
-
-static VALUE
-md5_digest(obj)
- VALUE obj;
-{
- MD5_CTX *md5, ctx;
- unsigned char digest[16];
-
- Data_Get_Struct(obj, MD5_CTX, md5);
- ctx = *md5;
- MD5Final(digest, &ctx);
-
- return rb_str_new(digest, 16);
-}
-
-static VALUE
-md5_hexdigest(obj)
- VALUE obj;
-{
- MD5_CTX *md5, ctx;
- unsigned char digest[16];
- char buf[33];
- int i;
-
- Data_Get_Struct(obj, MD5_CTX, md5);
- ctx = *md5;
- MD5Final(digest, &ctx);
-
- for (i=0; i<16; i++) {
- sprintf(buf+i*2, "%02x", digest[i]);
- }
- return rb_str_new(buf, 32);
-}
-
-static VALUE
-md5_clone(obj)
- VALUE obj;
-{
- MD5_CTX *md5, *md5_new;
-
- Data_Get_Struct(obj, MD5_CTX, md5);
- obj = Data_Make_Struct(CLASS_OF(obj), MD5_CTX, 0, free, md5_new);
- *md5_new = *md5;
-
- return obj;
-}
-
-static VALUE
-md5_new(argc, argv, class)
- int argc;
- VALUE* argv;
- VALUE class;
-{
- VALUE arg, obj;
- MD5_CTX *md5;
-
- rb_scan_args(argc, argv, "01", &arg);
- if (!NIL_P(arg)) Check_Type(arg, T_STRING);
-
- obj = Data_Make_Struct(class, MD5_CTX, 0, free, md5);
- MD5Init(md5);
- if (!NIL_P(arg)) {
- md5_update(obj, arg);
- }
-
- return obj;
-}
-
-void
-Init_md5()
-{
- cMD5 = rb_define_class("MD5", rb_cObject);
-
- rb_define_singleton_method(cMD5, "new", md5_new, -1);
- rb_define_singleton_method(cMD5, "md5", md5_new, -1);
-
- rb_define_method(cMD5, "update", md5_update, 1);
- rb_define_method(cMD5, "digest", md5_digest, 0);
- rb_define_method(cMD5, "hexdigest", md5_hexdigest, 0);
- rb_define_method(cMD5, "clone", md5_clone, 0);
-}
diff --git a/ext/nkf/.cvsignore b/ext/nkf/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/nkf/.cvsignore
+++ b/ext/nkf/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/nkf/MANIFEST b/ext/nkf/MANIFEST
deleted file mode 100644
index 5114a3762a..0000000000
--- a/ext/nkf/MANIFEST
+++ /dev/null
@@ -1,7 +0,0 @@
-MANIFEST
-depend
-extconf.rb
-lib/kconv.rb
-nkf.c
-nkf1.7/nkf.c
-test.rb
diff --git a/ext/nkf/depend b/ext/nkf/depend
index 13e32e6074..0ed8fea8d2 100644
--- a/ext/nkf/depend
+++ b/ext/nkf/depend
@@ -1 +1 @@
-nkf.o : nkf.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h $(srcdir)/nkf1.7/nkf.c
+nkf.o : nkf.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h $(srcdir)/nkf-utf8/nkf.c $(srcdir)/nkf-utf8/utf8tbl.c $(srcdir)/nkf-utf8/config.h
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb
index af6d82275f..1fd28a5a59 100644
--- a/ext/nkf/lib/kconv.rb
+++ b/ext/nkf/lib/kconv.rb
@@ -1,73 +1,226 @@
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
+ #Constant of Encoding
+ AUTO = ::NKF::AUTO
+ JIS = ::NKF::JIS
+ EUC = ::NKF::EUC
+ SJIS = ::NKF::SJIS
+ BINARY = ::NKF::BINARY
+ NOCONV = ::NKF::NOCONV
+ ASCII = ::NKF::ASCII
+ UTF8 = ::NKF::UTF8
+ UTF16 = ::NKF::UTF16
+ UTF32 = ::NKF::UTF32
+ UNKNOWN = ::NKF::UNKNOWN
+
+ #Regexp of Encoding
+ Iconv_Shift_JIS = /\A(?:
+ [\x00-\x7f\xa1-\xdf] |
+ \x81[\x40-\x7e\x80-\xac\xb8-\xbf\xc8-\xce\xda-\xe8\xf0-\xf7\xfc] |
+ \x82[\x4f-\x58\x60-\x79\x81-\x9a\x9f-\xf1] |
+ \x83[\x40-\x7e\x80-\x96\x9f-\xb6\xbf-\xd6\x40-\x60] |
+ \x84[\x40-\x60\x70-\x7e\x80-\x91\x9f-\xbe\x9f-\xfc] |
+ [\x89-\x8f\x90-\x97\x99-\x9f\xe0-\xea][\x40-\x7e] |
+ [\x89-\x97\x99-\x9f\xe0-\xe9][\x80-\xfc] |
+ \x98[\x40-\x72\x9f-\xfc] |
+ \xea[\x80-\xa4]
+ )*\z/nx
+ Iconv_EUC_JP = /\A(?:
+ [\x00-\x7f] |
+ \x8e [\xa1-\xdf] |
+ \x8f [\xa1-\xdf] [\xa1-\xdf] |
+ [\xa1\xb0-\xbce\xd0-\xf3][\xa1-\xfe] |
+ \xa2[\xa1-\xae\xba-\xc1\xca-\xd0\xdc-\xea\xf2-\xf9\xfe] |
+ \xa3[\xb0-\xb9\xc1-\xda\xe1-\xfa] |
+ \xa4[\xa1-\xf3] |
+ \xa5[\xa1-\xf6] |
+ \xa6[\xa1-\xb8\xc1-\xd8] |
+ \xa7[\xa1-\xc1\xd1-\xf1] |
+ \xa8[\xa1-\xc0] |
+ \xcf[\xa1-\xd3] |
+ \xf4[\xa1-\xa6]
+ )*\z/nx
+ Iconv_UTF8 = /\A(?:\xef\xbb\xbf)?(?:
+ [\x00-\x7f] |
+ \xc2[\x80-\x8d\x90-\x9f\xa1\xaa\xac\xae-\xb1\xb4\xb6\xb8\xba\xbf] |
+ \xc3[\x80-\xbf] |
+ \xc4[\x80-\x93\x96-\xa2\xa4-\xab\xae-\xbf] |
+ \xc5[\x80-\x8d\x90-\xbe] |
+ \xc7[\x8d-\x9c\xb5] |
+ \xcb[\x87\x98-\x9b\x9d] |
+ \xce[\x84-\x86\x88-\x8a\x8c\x8e-\xa1\xa3-\xbf] |
+ \xcf[\x80-\x8e] |
+ \xd0[\x81-\x8c\x8e-\xbf] |
+ \xd1[\x80-\x8f\x91-\x9f] |
+ \xe2\x84[\x83\x96\xa2\xab] |
+ \xe2\x86[\x83\x91-\x93\x96\xa2\xab] |
+ \xe2\x87[\x83\x91-\x94\x96\xa2\xab] |
+ \xe2\x88[\x82-\x83\x87-\x88\x8b\x91-\x94\x96\x9a\x9d-\x9e\xa0\xa2\xa7-\xac\xb4-\xb5\xbd] |
+ \xe2\x89[\x82-\x83\x87-\x88\x8b\x91-\x94\x96\x9a\x9d-\x9e\xa0-\xa2\xa6-\xac\xb4-\xb5\xbd] |
+ \xe2[\x8a\x8c][\x82-\x83\x86-\x88\x8b\x91-\x94\x96\x9a\x9d-\x9e\xa0-\xa2\xa5-\xac\xb4-\xb5\xbd] |
+ \xe2[\x94-\x99][\x81-\x83\x86-\x88\x8b-\x8c\x8f-\x94\x96-\x98\x9a-\x9e\xa0-\xac\xaf-\xb0\xb3-\xb5\xb7-\xb8\xbb-\xbd\xbf] |
+ \xe3\x80[\x81-\x83\x85-\x98\x9a-\x9e\xa0-\xad\xaf-\xb0\xb2-\xb5\xb7-\xb8\xbb-\xbd\xbf] |
+ \xe3[\x81-\x83\xb8-\xbf][\x81-\xbf] |
+ [\xe5-\xe7][\x80-\xbf][\x81-\xbf] |
+ \xe8[\x80-\xae\xb0-\xbf][\x81-\xbf] |
+ \xe9[\x80-\x92\x95-\xb1\xb3-\xbe][\x81-\xbf] |
+ \xef[\xbc-\xbe][\x81-\xbf] |
+ )*\z/nx
+ RegexpShiftjis = /\A(?:
+ [\x00-\x7f\xa1-\xdf] |
+ [\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc]
+ )*\z/nx
+ RegexpEucjp = /\A(?:
+ [\x00-\x7f] |
+ \x8e [\xa1-\xdf] |
+ \x8f [\xa1-\xdf] [\xa1-\xdf] |
+ [\xa1-\xdf] [\xa1-\xdf]
+ )*\z/nx
+ RegexpUtf8 = /\A(?:
+ [\x00-\x7f] |
+ [\xc2-\xdf] [\x80-\xbf] |
+ \xe0 [\xa0-\xbf] [\x80-\xbf] |
+ [\xe1-\xef] [\x80-\xbf] [\x80-\xbf] |
+ \xf0 [\x90-\xbf] [\x80-\xbf] [\x80-\xbf] |
+ [\xf1-\xf3] [\x80-\xbf] [\x80-\xbf] [\x80-\xbf] |
+ \xf4 [\x80-\x8f] [\x80-\xbf] [\x80-\xbf]
+ )*\z/nx
+
+ #
+ # kconv
+ #
+
def kconv(str, out_code, in_code = AUTO)
opt = '-'
case in_code
- when NKF::JIS
+ when ::NKF::JIS
opt << 'J'
- when NKF::EUC
+ when ::NKF::EUC
opt << 'E'
- when NKF::SJIS
+ when ::NKF::SJIS
opt << 'S'
+ when ::NKF::UTF8
+ when ::NKF::UTF16
+ opt << 'W'
end
case out_code
- when NKF::JIS
+ when ::NKF::JIS
opt << 'j'
- when NKF::EUC
+ when ::NKF::EUC
opt << 'e'
- when NKF::SJIS
+ when ::NKF::SJIS
opt << 's'
- when NKF::NOCONV
+ when ::NKF::UTF8
+ when ::NKF::UTF16
+ opt << 'w'
+ when ::NKF::NOCONV
return str
end
opt = '' if opt == '-'
- NKF::nkf(opt, str)
+ ::NKF::nkf(opt, str)
end
module_function :kconv
+ #
+ # Encode to
+ #
+
def tojis(str)
- NKF::nkf('-j', str)
+ ::NKF::nkf('-j', str)
end
module_function :tojis
def toeuc(str)
- NKF::nkf('-e', str)
+ ::NKF::nkf('-e', str)
end
module_function :toeuc
def tosjis(str)
- NKF::nkf('-s', str)
+ ::NKF::nkf('-s', str)
end
module_function :tosjis
+ def toutf8(str)
+ ::NKF::nkf('-w', str)
+ end
+ module_function :toutf8
+
+ def toutf16(str)
+ ::NKF::nkf('-w16', str)
+ end
+ module_function :toutf16
+
+ #
+ # guess
+ #
+
def guess(str)
- NKF::guess(str)
+ ::NKF::guess(str)
end
module_function :guess
+
+ def guess_old(str)
+ ::NKF::guess_old(str)
+ end
+ module_function :guess_old
+
+ #
+ # isEncoding
+ #
+
+ def iseuc(str)
+ RegexpEucjp.match( str )
+ end
+ module_function :iseuc
+
+ def issjis(str)
+ RegexpShiftjis.match( str )
+ end
+ module_function :issjis
+
+ def isutf8(str)
+ RegexpUtf8.match( str )
+ end
+ module_function :isutf8
+
end
class String
def kconv(out_code, in_code=Kconv::AUTO)
Kconv::kconv(self, out_code, in_code)
end
+
+ # to Encoding
def tojis
- NKF::nkf('-j', self)
+ ::NKF::nkf('-j', self)
end
def toeuc
- NKF::nkf('-e', self)
+ ::NKF::nkf('-e', self)
end
def tosjis
- NKF::nkf('-s', self)
+ ::NKF::nkf('-s', self)
+ end
+ def toutf8
+ ::NKF::nkf('-w', self)
+ end
+ def toutf16
+ ::NKF::nkf('-w16', self)
+ end
+
+ # is Encoding
+ def iseuc
+ Kconv.iseuc( self )
+ end
+
+ def issjis
+ Kconv.issjis( self )
+ end
+
+ def isutf8
+ Kconv.isutf8( self )
end
end
diff --git a/ext/nkf/nkf-utf8/config.h b/ext/nkf/nkf-utf8/config.h
new file mode 100644
index 0000000000..0f202baafd
--- /dev/null
+++ b/ext/nkf/nkf-utf8/config.h
@@ -0,0 +1,52 @@
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
+/* UTF8 $BF~=PNO(B */
+#define UTF8_INPUT_ENABLE
+#define UTF8_OUTPUT_ENABLE
+
+/* Shift_JIS $BHO0O30$NJ8;z$r!"(BCP932 $B$GF1CM$JJ8;z$KFI$_49$($k(B */
+#define SHIFTJIS_CP932
+
+/* $B%*%W%7%g%s$GF~NO$r;XDj$7$?;~$K!"J8;z%3!<%I$r8GDj$9$k(B */
+#define INPUT_CODE_FIX
+
+/* --overwrite $B%*%W%7%g%s(B */
+/* by Satoru Takabayashi <ccsatoru@vega.aichi-u.ac.jp> */
+#define OVERWRITE
+
+/* --cap-input, --url-input $B%*%W%7%g%s(B */
+#define INPUT_OPTION
+
+/* --numchar-input $B%*%W%7%g%s(B */
+#define NUMCHAR_OPTION
+
+/* --debug, --no-output $B%*%W%7%g%s(B */
+#define CHECK_OPTION
+
+/* --exec-in, --exec-out $B%*%W%7%g%s(B
+ * pipe, fork, execvp $B$"$?$j$,L5$$$HF0$-$^$;$s!#(B
+ * MS-DOS, MinGW $B$J$I$G$O(B undef $B$K$7$F$/$@$5$$(B
+ * child process $B=*N;;~$N=hM}$,$$$$$+$2$s$J$N$G!"(B
+ * $B%G%U%)%k%H$GL58z$K$7$F$$$^$9!#(B
+ */
+/* #define EXEC_IO */
+
+/* SunOS $B$N(B cc $B$r;H$&$H$-$O(B undef $B$K$7$F$/$@$5$$(B */
+#define ANSI_C_PROTOTYPE
+
+/* int $B$,(B 32bit $BL$K~$N4D6-$G(B NUMCHAR_OPTION $B$r;H$&$K$O!"(B
+ * $B%3%a%s%H$r30$7$F$/$@$5$$!#(B
+ */
+/* #define INT_IS_SHORT */
+
+/******************************/
+/* $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 */
+/* #define DEFAULT_CODE_UTF8 */
+/******************************/
+
+#endif /* _CONFIG_H_ */
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c
new file mode 100644
index 0000000000..aa7c459b83
--- /dev/null
+++ b/ext/nkf/nkf-utf8/nkf.c
@@ -0,0 +1,4060 @@
+/** 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
+** Copyright (C) 2002
+** $BO"Mm@h!'(B $BN05eBg3X>pJs9)3X2J(B $B2OLn(B $B??<#(B mime/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
+** $B1DMxMxMQ$b>e5-$KH?$7$J$$HO0O$G5v2D$7$^$9!#(B
+** $B%P%$%J%j$NG[I[$N:]$K$O(Bversion message$B$rJ]B8$9$k$3$H$r>r7o$H$7$^$9!#(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.
+** Binary distribution requires original version messages.
+** You don't have to ask before copying, redistribution or publishing.
+** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
+***********************************************************************/
+
+/***********************************************************************
+** UTF-8 $B%5%]!<%H$K$D$$$F(B
+** $B=>Mh$N(B nkf $B$HF~$l$+$($F$=$N$^$^;H$($k$h$&$K$J$C$F$$$^$9(B
+** nkf -e $B$J$I$H$7$F5/F0$9$k$H!"<+F0H=JL$G(B UTF-8 $B$HH=Dj$5$l$l$P!"(B
+** $B$=$N$^$^(B euc-jp $B$KJQ49$5$l$^$9(B
+**
+** $B$^$@%P%0$,$"$k2DG=@-$,9b$$$G$9!#(B
+** ($BFC$K<+F0H=JL!"%3!<%I:.:_!"%(%i!<=hM}7O(B)
+**
+** $B2?$+LdBj$r8+$D$1$?$i!"(B
+** E-Mail: furukawa@tcp-ip.or.jp
+** $B$^$G8fO"Mm$r$*4j$$$7$^$9!#(B
+***********************************************************************/
+#include "config.h"
+
+static char *CopyRight =
+ "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW, 2002-2004 Kono, Furukawa";
+static char *Version =
+ "2.0";
+static char *Patchlevel =
+ "4/0401/Shinji Kono";
+
+/*
+**
+**
+**
+** USAGE: nkf [flags] [file]
+**
+** Flags:
+** b Output is buffered (DEFAULT)
+** u Output is unbuffered
+**
+** 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)
+** w 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 Convert non ISO-2022-JP charactor to GETA by Pekoe <pekoe@lair.net>
+** i_ Output sequence to designate JIS-kanji (DEFAULT_J)
+** o_ Output sequence to designate single-byte roman characters (DEFAULT_R)
+** M MIME output conversion
+**
+** 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 or last file name
+** d Delete \r in line feed
+** c Add \r in line feed
+** -- other long option
+** -- ignore following option (don't use with -O )
+**
+**/
+
+#if (defined(__TURBOC__) || defined(_MSC_VER) || defined(LSI_C) || defined(__MINGW32__)) && !defined(MSDOS)
+#define MSDOS
+#if (defined(__Win32__) || defined(_WIN32)) && !defined(__WIN32__)
+#define __WIN32__
+#endif
+#endif
+
+#ifdef PERL_XS
+#undef OVERWRITE
+#endif
+
+#ifndef PERL_XS
+#include <stdio.h>
+#endif
+
+#if defined(MSDOS) || defined(__OS2__)
+#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, Windows */
+#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
+#ifndef __WIN16__
+#define __WIN16__
+#endif
+#include <windows.h>
+#endif
+
+#ifdef OVERWRITE
+/* added by satoru@isoternet.org */
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#ifndef MSDOS /* UNIX, OS/2 */
+#include <unistd.h>
+#include <utime.h>
+#else
+#if defined(_MSC_VER) || defined(__MINGW32__) /* VC++, MinGW */
+#include <sys/utime.h>
+#elif defined(__TURBOC__) /* BCC */
+#include <utime.h>
+#elif defined(LSI_C) /* LSI C */
+#endif
+#endif
+#endif
+
+#ifdef INT_IS_SHORT
+#define int long
+#endif
+
+#define FALSE 0
+#define TRUE 1
+
+/* state of output_mode and input_mode
+
+ c2 0 means ASCII
+ X0201
+ ISO8859_1
+ X0208
+ EOF all termination
+ c1 32bit data
+
+ */
+
+#define ASCII 0
+#define X0208 1
+#define X0201 2
+#define ISO8859_1 8
+#define NO_X0201 3
+
+/* Input Assumption */
+
+#define JIS_INPUT 4
+#define SJIS_INPUT 5
+#define LATIN1_INPUT 6
+#define FIXED_MIME 7
+#define STRICT_MIME 8
+
+/* MIME ENCODE */
+
+#define ISO2022JP 9
+#define JAPANESE_EUC 10
+#define SHIFT_JIS 11
+
+#define UTF8 12
+#define UTF8_INPUT 13
+#define UTF16_INPUT 14
+#define UTF16BE_INPUT 15
+
+#define WISH_TRUE 15
+
+/* ASCII CODE */
+
+#define BS 0x08
+#define NL 0x0a
+#define CR 0x0d
+#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 is_alnum(c) \
+ (('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))
+
+#define HOLD_SIZE 1024
+#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 */
+
+#define RANGE_NUM_MAX 18
+#define GETA1 0x22
+#define GETA2 0x2e
+
+
+#if defined( UTF8_OUTPUT_ENABLE ) || defined( UTF8_INPUT_ENABLE )
+#define sizeof_euc_utf8 94
+#define sizeof_euc_to_utf8_1byte 94
+#define sizeof_euc_to_utf8_2bytes 94
+#define sizeof_utf8_to_euc_C2 64
+#define sizeof_utf8_to_euc_E5B8 64
+#define sizeof_utf8_to_euc_2bytes 112
+#define sizeof_utf8_to_euc_3bytes 112
+#endif
+
+/* MIME preprocessor */
+
+
+#ifdef EASYWIN /*Easy Win */
+extern POINT _BufferSize;
+#endif
+
+/* function prototype */
+
+#ifdef ANSI_C_PROTOTYPE
+#define PROTO(x) x
+#define STATIC static
+#else
+#define PROTO(x) ()
+#define STATIC
+#endif
+
+struct input_code{
+ char *name;
+ int stat;
+ int score;
+ int index;
+ int buf[3];
+ void (*status_func)PROTO((struct input_code *, int));
+ int (*iconv_func)PROTO((int c2, int c1, int c0));
+ int _file_stat;
+};
+
+STATIC char *input_codename = "";
+
+STATIC int noconvert PROTO((FILE *f));
+STATIC int kanji_convert PROTO((FILE *f));
+STATIC int h_conv PROTO((FILE *f,int c2,int c1));
+STATIC int push_hold_buf PROTO((int c2));
+STATIC void set_iconv PROTO((int f, int (*iconv_func)()));
+STATIC int s_iconv PROTO((int c2,int c1,int c0));
+STATIC int s2e_conv PROTO((int c2, int c1, int *p2, int *p1));
+STATIC int e_iconv PROTO((int c2,int c1,int c0));
+#ifdef UTF8_INPUT_ENABLE
+STATIC int w2e_conv PROTO((int c2,int c1,int c0,int *p2,int *p1));
+STATIC int w_iconv PROTO((int c2,int c1,int c0));
+STATIC int w_iconv16 PROTO((int c2,int c1,int c0));
+STATIC int w_iconv_common PROTO((int c1,int c0,unsigned short **pp,int psize,int *p2,int *p1));
+STATIC int ww16_conv PROTO((int c2, int c1, int c0));
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+STATIC int e2w_conv PROTO((int c2,int c1));
+STATIC void w_oconv PROTO((int c2,int c1));
+STATIC void w_oconv16 PROTO((int c2,int c1));
+#endif
+STATIC void e_oconv PROTO((int c2,int c1));
+STATIC void e2s_conv PROTO((int c2, int c1, int *p2, int *p1));
+STATIC void s_oconv PROTO((int c2,int c1));
+STATIC void j_oconv PROTO((int c2,int c1));
+STATIC void fold_conv PROTO((int c2,int c1));
+STATIC void cr_conv PROTO((int c2,int c1));
+STATIC void z_conv PROTO((int c2,int c1));
+STATIC void rot_conv PROTO((int c2,int c1));
+STATIC void hira_conv PROTO((int c2,int c1));
+STATIC void base64_conv PROTO((int c2,int c1));
+STATIC void iso2022jp_check_conv PROTO((int c2,int c1));
+STATIC void no_connection PROTO((int c2,int c1));
+STATIC int no_connection2 PROTO((int c2,int c1,int c0));
+
+STATIC void code_score PROTO((struct input_code *ptr));
+STATIC void code_status PROTO((int c));
+
+STATIC void std_putc PROTO((int c));
+STATIC int std_getc PROTO((FILE *f));
+STATIC int std_ungetc PROTO((int c,FILE *f));
+
+STATIC int broken_getc PROTO((FILE *f));
+STATIC int broken_ungetc PROTO((int c,FILE *f));
+
+STATIC int mime_begin PROTO((FILE *f));
+STATIC int mime_getc PROTO((FILE *f));
+STATIC int mime_ungetc PROTO((int c,FILE *f));
+
+STATIC int mime_begin_strict PROTO((FILE *f));
+STATIC int mime_getc_buf PROTO((FILE *f));
+STATIC int mime_ungetc_buf PROTO((int c,FILE *f));
+STATIC int mime_integrity PROTO((FILE *f,unsigned char *p));
+
+STATIC int base64decode PROTO((int c));
+STATIC void mime_putc PROTO((int c));
+STATIC void open_mime PROTO((int c));
+STATIC void close_mime PROTO(());
+STATIC void usage PROTO(());
+STATIC void version PROTO(());
+STATIC void options PROTO((unsigned char *c));
+#ifdef PERL_XS
+STATIC void reinit PROTO(());
+#endif
+
+/* buffers */
+
+static unsigned char stdibuf[IOBUF_SIZE];
+static unsigned char stdobuf[IOBUF_SIZE];
+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 */
+static unsigned int mime_input = 0; /* undecoded */
+
+/* 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 hira_f = FALSE; /* hira/kata henkan */
+static int input_f = FALSE; /* non fixed input code */
+static int alpha_f = FALSE; /* convert JIx0208 alphbet to ASCII */
+static int mime_f = STRICT_MIME; /* 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 */
+static int mimeout_f = FALSE; /* base64 mode */
+#if defined(MSDOS) || defined(__OS2__)
+static int x0201_f = TRUE; /* Assume JISX0201 kana */
+#else
+static int x0201_f = NO_X0201; /* Assume NO JISX0201 */
+#endif
+static int iso2022jp_f = FALSE; /* convert ISO-2022-JP */
+#ifdef UTF8_OUTPUT_ENABLE
+static int w_oconv16_begin_f= 0; /* utf-16 header */
+static int w_oconv16_LE = 0; /* utf-16 little endian */
+#endif
+
+
+#ifdef NUMCHAR_OPTION
+
+#define CLASS_MASK 0x0f000000
+#define CLASS_UTF16 0x01000000
+#endif
+
+#ifdef INPUT_OPTION
+static int cap_f = FALSE;
+static int (*i_cgetc)PROTO((FILE *)) = std_getc; /* input of cgetc */
+static int (*i_cungetc)PROTO((int c ,FILE *f)) = std_ungetc;
+STATIC int cap_getc PROTO((FILE *f));
+STATIC int cap_ungetc PROTO((int c,FILE *f));
+
+static int url_f = FALSE;
+static int (*i_ugetc)PROTO((FILE *)) = std_getc; /* input of ugetc */
+static int (*i_uungetc)PROTO((int c ,FILE *f)) = std_ungetc;
+STATIC int url_getc PROTO((FILE *f));
+STATIC int url_ungetc PROTO((int c,FILE *f));
+
+static int numchar_f = FALSE;
+static int (*i_ngetc)PROTO((FILE *)) = std_getc; /* input of ugetc */
+static int (*i_nungetc)PROTO((int c ,FILE *f)) = std_ungetc;
+STATIC int numchar_getc PROTO((FILE *f));
+STATIC int numchar_ungetc PROTO((int c,FILE *f));
+#endif
+
+#ifdef CHECK_OPTION
+static int noout_f = FALSE;
+STATIC void no_putc PROTO((int c));
+static int debug_f = FALSE;
+STATIC void debug PROTO((char *str));
+#endif
+
+static int guess_f = FALSE;
+STATIC void print_guessed_code PROTO((char *filename));
+STATIC void set_input_codename PROTO((char *codename));
+static int is_inputcode_mixed = FALSE;
+static int is_inputcode_set = FALSE;
+
+#ifdef EXEC_IO
+static int exec_f = 0;
+#endif
+
+#ifdef SHIFTJIS_CP932
+STATIC int cp932_f = TRUE;
+#define CP932_TABLE_BEGIN (0xfa)
+#define CP932_TABLE_END (0xfc)
+
+STATIC int cp932inv_f = FALSE;
+#define CP932INV_TABLE_BEGIN (0xed)
+#define CP932INV_TABLE_END (0xee)
+
+#endif /* SHIFTJIS_CP932 */
+
+STATIC unsigned char prefix_table[256];
+
+STATIC void e_status PROTO((struct input_code *, int));
+STATIC void s_status PROTO((struct input_code *, int));
+
+#ifdef UTF8_INPUT_ENABLE
+STATIC void w_status PROTO((struct input_code *, int));
+STATIC void w16_status PROTO((struct input_code *, int));
+static int utf16_mode = UTF16_INPUT;
+#endif
+
+struct input_code input_code_list[] = {
+ {"EUC-JP", 0, 0, 0, {0, 0, 0}, e_status, e_iconv, 0},
+ {"Shift_JIS", 0, 0, 0, {0, 0, 0}, s_status, s_iconv, 0},
+ {"UTF-8", 0, 0, 0, {0, 0, 0}, w_status, w_iconv, 0},
+ {"UTF-16", 0, 0, 0, {0, 0, 0}, w16_status, w_iconv16, 0},
+ {0}
+};
+
+static int mimeout_mode = 0;
+static int base64_count = 0;
+
+/* X0208 -> ASCII converter */
+
+/* fold parameter */
+static int f_line = 0; /* chars in line */
+static int f_prev = 0;
+static int fold_preserve_f = FALSE; /* preserve new lines */
+static int fold_f = FALSE;
+static int fold_len = 0;
+
+/* options */
+static unsigned char kanji_intro = DEFAULT_J,
+ ascii_intro = DEFAULT_R;
+
+/* Folding */
+
+#define FOLD_MARGIN 10
+#define DEFAULT_FOLD 60
+
+static int fold_margin = FOLD_MARGIN;
+
+/* 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
+#ifdef DEFAULT_CODE_UTF8
+# define DEFAULT_CONV w_oconv
+#endif
+
+/* process default */
+static void (*output_conv)PROTO((int c2,int c1)) = DEFAULT_CONV;
+
+static void (*oconv)PROTO((int c2,int c1)) = no_connection;
+/* s_iconv or oconv */
+static int (*iconv)PROTO((int c2,int c1,int c0)) = no_connection2;
+
+static void (*o_zconv)PROTO((int c2,int c1)) = no_connection;
+static void (*o_fconv)PROTO((int c2,int c1)) = no_connection;
+static void (*o_crconv)PROTO((int c2,int c1)) = no_connection;
+static void (*o_rot_conv)PROTO((int c2,int c1)) = no_connection;
+static void (*o_hira_conv)PROTO((int c2,int c1)) = no_connection;
+static void (*o_base64conv)PROTO((int c2,int c1)) = no_connection;
+static void (*o_iso2022jp_check_conv)PROTO((int c2,int c1)) = no_connection;
+
+/* static redirections */
+
+static void (*o_putc)PROTO((int c)) = std_putc;
+
+static int (*i_getc)PROTO((FILE *f)) = std_getc; /* general input */
+static int (*i_ungetc)PROTO((int c,FILE *f)) =std_ungetc;
+
+static int (*i_bgetc)PROTO((FILE *)) = std_getc; /* input of mgetc */
+static int (*i_bungetc)PROTO((int c ,FILE *f)) = std_ungetc;
+
+static void (*o_mputc)PROTO((int c)) = std_putc ; /* output of mputc */
+
+static int (*i_mgetc)PROTO((FILE *)) = std_getc; /* input of mgetc */
+static int (*i_mungetc)PROTO((int c ,FILE *f)) = std_ungetc;
+
+/* for strict mime */
+static int (*i_mgetc_buf)PROTO((FILE *)) = std_getc; /* input of mgetc_buf */
+static int (*i_mungetc_buf)PROTO((int c,FILE *f)) = std_ungetc;
+
+/* 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_decode_mode = FALSE; /* MIME mode B base64, Q hex */
+
+/* X0201 / X0208 conversion tables */
+
+/* X0201 kana conversion table */
+/* 90-9F A0-DF */
+static
+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 */
+static
+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,0x25,0x74,
+ 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 */
+static
+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 */
+static
+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
+} ;
+
+
+#define CRLF 1
+
+static int file_out = FALSE;
+#ifdef OVERWRITE
+static int overwrite = FALSE;
+#endif
+
+static int crmode_f = 0; /* CR, NL, CRLF */
+#ifdef EASYWIN /*Easy Win */
+static int end_check;
+#endif /*Easy Win */
+
+#ifndef PERL_XS
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ FILE *fin;
+ unsigned char *cp;
+
+ char *outfname;
+ char *origfname;
+
+#ifdef EASYWIN /*Easy Win */
+ _BufferSize.y = 400;/*Set Scroll Buffer Size*/
+#endif
+
+ for (argc--,argv++; (argc > 0) && **argv == '-'; argc--, argv++) {
+ cp = (unsigned char *)*argv;
+ options(cp);
+#ifdef EXEC_IO
+ if (exec_f){
+ int fds[2], pid;
+ if (pipe(fds) < 0 || (pid = fork()) < 0){
+ abort();
+ }
+ if (pid == 0){
+ if (exec_f > 0){
+ close(fds[0]);
+ dup2(fds[1], 1);
+ }else{
+ close(fds[1]);
+ dup2(fds[0], 0);
+ }
+ execvp(argv[1], &argv[1]);
+ }
+ if (exec_f > 0){
+ close(fds[1]);
+ dup2(fds[0], 0);
+ }else{
+ close(fds[0]);
+ dup2(fds[1], 1);
+ }
+ argc = 0;
+ break;
+ }
+#endif
+ }
+ if(x0201_f == WISH_TRUE)
+ x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
+
+ 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);
+ if (guess_f) print_guessed_code(NULL);
+ }
+ } else {
+ int nfiles = argc;
+ while (argc--) {
+ if ((fin = fopen((origfname = *argv++), "r")) == NULL) {
+ perror(*--argv);
+ return(-1);
+ } else {
+#ifdef OVERWRITE
+ int fd;
+ int fd_backup;
+#endif
+
+/* reopen file for stdout */
+ if (file_out == TRUE) {
+#ifdef OVERWRITE
+ if (overwrite){
+ outfname = malloc(strlen(origfname)
+ + strlen(".nkftmpXXXXXX")
+ + 1);
+ if (!outfname){
+ perror(origfname);
+ return -1;
+ }
+ strcpy(outfname, origfname);
+#ifdef MSDOS
+ {
+ int i;
+ for (i = strlen(outfname); i; --i){
+ if (outfname[i - 1] == '/'
+ || outfname[i - 1] == '\\'){
+ break;
+ }
+ }
+ outfname[i] = '\0';
+ }
+ strcat(outfname, "ntXXXXXX");
+ mktemp(outfname);
+ fd = open(outfname, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IREAD | S_IWRITE);
+#else
+ strcat(outfname, ".nkftmpXXXXXX");
+ fd = mkstemp(outfname);
+#endif
+ if (fd < 0
+ || (fd_backup = dup(fileno(stdout))) < 0
+ || dup2(fd, fileno(stdout)) < 0
+ ){
+ perror(origfname);
+ return -1;
+ }
+ }else
+#endif
+ if(argc == 1 ) {
+ outfname = *argv++;
+ argc--;
+ } else {
+ outfname = "nkf.out";
+ }
+
+ if(freopen(outfname, "w", stdout) == NULL) {
+ perror (outfname);
+ 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 {
+ char *filename = NULL;
+ kanji_convert(fin);
+ if (nfiles > 1) filename = origfname;
+ if (guess_f) print_guessed_code(filename);
+ }
+ fclose(fin);
+#ifdef OVERWRITE
+ if (overwrite) {
+ struct stat sb;
+#if defined(MSDOS) && !defined(__MINGW32__)
+ time_t tb[2];
+#else
+ struct utimbuf tb;
+#endif
+
+ fflush(stdout);
+ close(fd);
+ if (dup2(fd_backup, fileno(stdout)) < 0){
+ perror("dup2");
+ }
+ if (stat(origfname, &sb)) {
+ fprintf(stderr, "Can't stat %s\n", origfname);
+ }
+ /* $B%Q!<%_%C%7%g%s$rI|85(B */
+ if (chmod(outfname, sb.st_mode)) {
+ fprintf(stderr, "Can't set permission %s\n", outfname);
+ }
+
+ /* $B%?%$%`%9%?%s%W$rI|85(B */
+#if defined(MSDOS) && !defined(__MINGW32__)
+ tb[0] = tb[1] = sb.st_mtime;
+ if (utime(outfname, tb)) {
+ fprintf(stderr, "Can't set timestamp %s\n", outfname);
+ }
+#else
+ tb.actime = sb.st_atime;
+ tb.modtime = sb.st_mtime;
+ if (utime(outfname, &tb)) {
+ fprintf(stderr, "Can't set timestamp %s\n", outfname);
+ }
+#endif
+#ifdef MSDOS
+ if (unlink(origfname)){
+ perror(origfname);
+ }
+#endif
+ if (rename(outfname, origfname)) {
+ perror(origfname);
+ fprintf(stderr, "Can't rename %s to %s\n",
+ outfname, origfname);
+ }
+ free(outfname);
+ }
+#endif
+ }
+ }
+ }
+#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
+
+static
+struct {
+ char *name;
+ char *alias;
+} long_option[] = {
+ {"base64","jMB"},
+ {"euc","e"},
+ {"euc-input","E"},
+ {"fj","jm"},
+ {"help","v"},
+ {"jis","j"},
+ {"jis-input","J"},
+ {"mac","sLm"},
+ {"mime","jM"},
+ {"mime-input","m"},
+ {"msdos","sLw"},
+ {"sjis","s"},
+ {"sjis-input","S"},
+ {"unix","eLu"},
+ {"version","V"},
+ {"windows","sLw"},
+ {"hiragana","h1"},
+ {"katakana","h2"},
+ {"katakana-hiragana","h3"},
+ {"guess", "g"},
+#ifdef UTF8_OUTPUT_ENABLE
+ {"utf8", "w"},
+ {"utf16", "w16"},
+#endif
+#ifdef UTF8_INPUT_ENABLE
+ {"utf8-input", "W"},
+ {"utf16-input", "W16"},
+#endif
+#ifdef OVERWRITE
+ {"overwrite", ""},
+#endif
+#ifdef INPUT_OPTION
+ {"cap-input", ""},
+ {"url-input", ""},
+#endif
+#ifdef NUMCHAR_OPTION
+ {"numchar-input", ""},
+#endif
+#ifdef CHECK_OPTION
+ {"no-output", ""},
+ {"debug", ""},
+#endif
+#ifdef SHIFTJIS_CP932
+ {"no-cp932", ""},
+ {"cp932inv", ""},
+#endif
+#ifdef EXEC_IO
+ {"exec-in", ""},
+ {"exec-out", ""},
+#endif
+ {"prefix=", ""},
+};
+
+static int option_mode;
+
+void
+options(cp)
+ unsigned char *cp;
+{
+ int i;
+ unsigned char *p;
+
+ if (option_mode==1)
+ return;
+ if (*cp++ != '-')
+ return;
+ while (*cp) {
+ switch (*cp++) {
+ case '-': /* literal options */
+ if (!*cp) { /* ignore the rest of arguments */
+ option_mode = 1;
+ return;
+ }
+ for (i=0;i<sizeof(long_option)/sizeof(long_option[0]);i++) {
+ int j;
+ p = (unsigned char *)long_option[i].name;
+ for (j=0;*p && (*p != '=') && *p == cp[j];p++, j++);
+ if (*p == cp[j]){
+ p = &cp[j];
+ break;
+ }
+ p = 0;
+ }
+ if (p == 0) return;
+ cp = (unsigned char *)long_option[i].alias;
+ if (!*cp){
+#ifdef OVERWRITE
+ if (strcmp(long_option[i].name, "overwrite") == 0){
+ file_out = TRUE;
+ overwrite = TRUE;
+ continue;
+ }
+#endif
+#ifdef INPUT_OPTION
+ if (strcmp(long_option[i].name, "cap-input") == 0){
+ cap_f = TRUE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "url-input") == 0){
+ url_f = TRUE;
+ continue;
+ }
+#endif
+#ifdef NUMCHAR_OPTION
+ if (strcmp(long_option[i].name, "numchar-input") == 0){
+ numchar_f = TRUE;
+ continue;
+ }
+#endif
+#ifdef CHECK_OPTION
+ if (strcmp(long_option[i].name, "no-output") == 0){
+ noout_f = TRUE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "debug") == 0){
+ debug_f = TRUE;
+ continue;
+ }
+#endif
+#ifdef SHIFTJIS_CP932
+ if (strcmp(long_option[i].name, "no-cp932") == 0){
+ cp932_f = FALSE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "cp932inv") == 0){
+ cp932inv_f = TRUE;
+ continue;
+ }
+#endif
+#ifdef EXEC_IO
+ if (strcmp(long_option[i].name, "exec-in") == 0){
+ exec_f = 1;
+ return;
+ }
+ if (strcmp(long_option[i].name, "exec-out") == 0){
+ exec_f = -1;
+ return;
+ }
+#endif
+ if (strcmp(long_option[i].name, "prefix=") == 0){
+ if (*p == '=' && ' ' < p[1] && p[1] < 128){
+ for (i = 2; ' ' < p[i] && p[i] < 128; i++){
+ prefix_table[p[i]] = p[1];
+ }
+ }
+ continue;
+ }
+ }
+ continue;
+ 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':
+ output_conv = j_oconv;
+ continue;
+ case 'e': /* AT&T EUC output */
+ output_conv = e_oconv;
+ continue;
+ case 's': /* SJIS output */
+ output_conv = 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 'h':
+ /*
+ bit:1 hira -> kata
+ bit:2 kata -> hira
+ */
+ if ('9'>= *cp && *cp>='0')
+ hira_f |= (*cp++ -'0');
+ else
+ hira_f |= 1;
+ continue;
+ case 'r':
+ rot_f = TRUE;
+ continue;
+#if defined(MSDOS) || defined(__OS2__)
+ case 'T':
+ binmode_f = FALSE;
+ continue;
+#endif
+#ifndef PERL_XS
+ case 'V':
+ version();
+ exit(1);
+ break;
+ case 'v':
+ usage();
+ exit(1);
+ break;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ case 'w': /* UTF-8 output */
+ if ('1'== cp[0] && '6'==cp[1]) {
+ output_conv = w_oconv16; cp+=2;
+ if (cp[0]=='L') {
+ w_oconv16_begin_f=2; cp++;
+ w_oconv16_LE = 1;
+ if (cp[0] == '0'){
+ w_oconv16_begin_f=1; cp++;
+ }
+ } else if (cp[0] == 'B') {
+ w_oconv16_begin_f=2; cp++;
+ if (cp[0] == '0'){
+ w_oconv16_begin_f=1; cp++;
+ }
+ }
+ } else
+ output_conv = w_oconv;
+ continue;
+#endif
+#ifdef UTF8_INPUT_ENABLE
+ case 'W': /* UTF-8 input */
+ if ('1'== cp[0] && '6'==cp[1]) {
+ input_f = UTF16_INPUT;
+ } else
+ input_f = UTF8_INPUT;
+ continue;
+#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
+ bit:3 Convert HTML Entity
+ */
+ 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': /* prserve new lines */
+ fold_preserve_f = TRUE;
+ case 'f': /* folding -f60 or -f */
+ fold_f = TRUE;
+ fold_len = 0;
+ while('0'<= *cp && *cp <='9') { /* we don't use atoi here */
+ fold_len *= 10;
+ fold_len += *cp++ - '0';
+ }
+ if (!(0<fold_len && fold_len<BUFSIZ))
+ fold_len = DEFAULT_FOLD;
+ if (*cp=='-') {
+ fold_margin = 0;
+ cp++;
+ while('0'<= *cp && *cp <='9') { /* we don't use atoi here */
+ fold_margin *= 10;
+ fold_margin += *cp++ - '0';
+ }
+ }
+ continue;
+ case 'm': /* MIME support */
+ if (*cp=='B'||*cp=='Q') {
+ mime_decode_mode = *cp++;
+ mimebuf_f = FIXED_MIME;
+ } else if (*cp=='N') {
+ mime_f = TRUE; cp++;
+ } else if (*cp=='S') {
+ mime_f = STRICT_MIME; cp++;
+ } else if (*cp=='0') {
+ mime_f = FALSE; cp++;
+ }
+ continue;
+ case 'M': /* MIME output */
+ if (*cp=='B') {
+ mimeout_mode = 'B';
+ mimeout_f = FIXED_MIME; cp++;
+ } else if (*cp=='Q') {
+ mimeout_mode = 'Q';
+ mimeout_f = FIXED_MIME; cp++;
+ } else {
+ mimeout_f = TRUE;
+ }
+ 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 */
+ crmode_f = CRLF;
+ continue;
+ case 'd':/* delete cr code */
+ crmode_f = NL;
+ continue;
+ case 'I': /* ISO-2022-JP output */
+ iso2022jp_f = TRUE;
+ continue;
+ case 'L': /* line mode */
+ if (*cp=='u') { /* unix */
+ crmode_f = NL; cp++;
+ } else if (*cp=='m') { /* mac */
+ crmode_f = CR; cp++;
+ } else if (*cp=='w') { /* windows */
+ crmode_f = CRLF; cp++;
+ } else if (*cp=='0') { /* no conversion */
+ crmode_f = 0; cp++;
+ }
+ continue;
+ case 'g':
+#ifndef PERL_XS
+ guess_f = TRUE;
+#endif
+ continue;
+ case ' ':
+ /* module muliple options in a string are allowed for Perl moudle */
+ while(*cp && *cp!='-') cp++;
+ if(*cp=='-') cp++;
+ continue;
+ default:
+ /* bogus option but ignored */
+ continue;
+ }
+ }
+}
+
+#ifdef ANSI_C_PROTOTYPE
+struct input_code * find_inputcode_byfunc(int (*iconv_func)(int c2,int c1,int c0))
+#else
+struct input_code * find_inputcode_byfunc(iconv_func)
+ int (*iconv_func)();
+#endif
+{
+ if (iconv_func){
+ struct input_code *p = input_code_list;
+ while (p->name){
+ if (iconv_func == p->iconv_func){
+ return p;
+ }
+ p++;
+ }
+ }
+ return 0;
+}
+
+#ifdef ANSI_C_PROTOTYPE
+void set_iconv(int f, int (*iconv_func)(int c2,int c1,int c0))
+#else
+void set_iconv(f, iconv_func)
+ int f;
+ int (*iconv_func)();
+#endif
+{
+#ifdef CHECK_OPTION
+ static int (*iconv_for_check)() = 0;
+#endif
+#ifdef INPUT_CODE_FIX
+ if (f || !input_f)
+#endif
+ if (estab_f != f){
+ estab_f = f;
+ }
+
+ if (iconv_func
+#ifdef INPUT_CODE_FIX
+ && (f == -TRUE || !input_f) /* -TRUE means "FORCE" */
+#endif
+ ){
+ iconv = iconv_func;
+ }
+#ifdef CHECK_OPTION
+ if (estab_f && iconv_for_check != iconv){
+ struct input_code *p = find_inputcode_byfunc(iconv);
+ if (p){
+ set_input_codename(p->name);
+ debug(input_codename);
+ }
+ iconv_for_check = iconv;
+ }
+#endif
+}
+
+#define SCORE_L2 (1) /* $BBh(B2$B?e=`4A;z(B */
+#define SCORE_KANA (SCORE_L2 << 1) /* $B$$$o$f$kH>3Q%+%J(B */
+#define SCORE_DEPEND (SCORE_KANA << 1) /* $B5!<o0MB8J8;z(B */
+#ifdef SHIFTJIS_CP932
+#define SCORE_CP932 (SCORE_DEPEND << 1) /* CP932 $B$K$h$kFI$_49$((B */
+#define SCORE_NO_EXIST (SCORE_CP932 << 1) /* $BB8:_$7$J$$J8;z(B */
+#else
+#define SCORE_NO_EXIST (SCORE_DEPEND << 1) /* $BB8:_$7$J$$J8;z(B */
+#endif
+#define SCORE_iMIME (SCORE_NO_EXIST << 1) /* MIME $B$K$h$k;XDj(B */
+#define SCORE_ERROR (SCORE_iMIME << 1) /* $B%(%i!<(B */
+
+#define SCORE_INIT (SCORE_iMIME)
+
+int score_table_A0[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND,
+ SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND, SCORE_NO_EXIST,
+};
+
+int score_table_F0[] = {
+ SCORE_L2, SCORE_L2, SCORE_L2, SCORE_L2,
+ SCORE_L2, SCORE_DEPEND, SCORE_NO_EXIST, SCORE_NO_EXIST,
+ SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND,
+ SCORE_DEPEND, SCORE_NO_EXIST, SCORE_NO_EXIST, SCORE_ERROR,
+};
+
+void set_code_score(ptr, score)
+ struct input_code *ptr;
+ int score;
+{
+ if (ptr){
+ ptr->score |= score;
+ }
+}
+
+void clr_code_score(ptr, score)
+ struct input_code *ptr;
+ int score;
+{
+ if (ptr){
+ ptr->score &= ~score;
+ }
+}
+
+void code_score(ptr)
+ struct input_code *ptr;
+{
+ int c2 = ptr->buf[0];
+ int c1 = ptr->buf[1];
+ if (c2 < 0){
+ set_code_score(ptr, SCORE_ERROR);
+ }else if (c2 == SSO){
+ set_code_score(ptr, SCORE_KANA);
+#ifdef UTF8_OUTPUT_ENABLE
+ }else if (!e2w_conv(c2, c1)){
+ set_code_score(ptr, SCORE_NO_EXIST);
+#endif
+ }else if ((c2 & 0x70) == 0x20){
+ set_code_score(ptr, score_table_A0[c2 & 0x0f]);
+ }else if ((c2 & 0x70) == 0x70){
+ set_code_score(ptr, score_table_F0[c2 & 0x0f]);
+ }else if ((c2 & 0x70) >= 0x50){
+ set_code_score(ptr, SCORE_L2);
+ }
+}
+
+void status_disable(ptr)
+struct input_code *ptr;
+{
+ ptr->stat = -1;
+ ptr->buf[0] = -1;
+ code_score(ptr);
+ if (iconv == ptr->iconv_func) set_iconv(FALSE, 0);
+}
+
+void status_push_ch(ptr, c)
+ struct input_code *ptr;
+ int c;
+{
+ ptr->buf[ptr->index++] = c;
+}
+
+void status_clear(ptr)
+ struct input_code *ptr;
+{
+ ptr->stat = 0;
+ ptr->index = 0;
+}
+
+void status_reset(ptr)
+ struct input_code *ptr;
+{
+ status_clear(ptr);
+ ptr->score = SCORE_INIT;
+}
+
+void status_reinit(ptr)
+ struct input_code *ptr;
+{
+ status_reset(ptr);
+ ptr->_file_stat = 0;
+}
+
+void status_check(ptr, c)
+ struct input_code *ptr;
+ int c;
+{
+ if (c <= DEL && estab_f){
+ status_reset(ptr);
+ }
+}
+
+void s_status(ptr, c)
+ struct input_code *ptr;
+ int c;
+{
+ switch(ptr->stat){
+ case -1:
+ status_check(ptr, c);
+ break;
+ case 0:
+ if (c <= DEL){
+ break;
+#ifdef NUMCHAR_OPTION
+ }else if ((c & CLASS_MASK) == CLASS_UTF16){
+ break;
+#endif
+ }else if (0xa1 <= c && c <= 0xdf){
+ status_push_ch(ptr, SSO);
+ status_push_ch(ptr, c);
+ code_score(ptr);
+ status_clear(ptr);
+ }else if ((0x81 <= c && c < 0xa0) || (0xe0 <= c && c <= 0xef)){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+#ifdef SHIFTJIS_CP932
+ }else if (cp932_f
+ && CP932_TABLE_BEGIN <= c && c <= CP932_TABLE_END){
+ ptr->stat = 2;
+ status_push_ch(ptr, c);
+#endif /* SHIFTJIS_CP932 */
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 1:
+ if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)){
+ status_push_ch(ptr, c);
+ s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]);
+ code_score(ptr);
+ status_clear(ptr);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+#ifdef SHIFTJIS_CP932
+ case 2:
+ if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)){
+ status_push_ch(ptr, c);
+ if (s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]) == 0){
+ set_code_score(ptr, SCORE_CP932);
+ status_clear(ptr);
+ break;
+ }
+ }
+ status_disable(ptr);
+ break;
+#endif /* SHIFTJIS_CP932 */
+ }
+}
+
+void e_status(ptr, c)
+ struct input_code *ptr;
+ int c;
+{
+ switch (ptr->stat){
+ case -1:
+ status_check(ptr, c);
+ break;
+ case 0:
+ if (c <= DEL){
+ break;
+#ifdef NUMCHAR_OPTION
+ }else if ((c & CLASS_MASK) == CLASS_UTF16){
+ break;
+#endif
+ }else if (SSO == c || (0xa1 <= c && c <= 0xfe)){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 1:
+ if (0xa1 <= c && c <= 0xfe){
+ status_push_ch(ptr, c);
+ code_score(ptr);
+ status_clear(ptr);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ }
+}
+
+#ifdef UTF8_INPUT_ENABLE
+void w16_status(ptr, c)
+ struct input_code *ptr;
+ int c;
+{
+ switch (ptr->stat){
+ case -1:
+ break;
+ case 0:
+ if (ptr->_file_stat == 0){
+ if (c == 0xfe || c == 0xff){
+ ptr->stat = c;
+ status_push_ch(ptr, c);
+ ptr->_file_stat = 1;
+ }else{
+ status_disable(ptr);
+ ptr->_file_stat = -1;
+ }
+ }else if (ptr->_file_stat > 0){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+ }else if (ptr->_file_stat < 0){
+ status_disable(ptr);
+ }
+ break;
+
+ case 1:
+ if (c == EOF){
+ status_disable(ptr);
+ ptr->_file_stat = -1;
+ }else{
+ status_push_ch(ptr, c);
+ status_clear(ptr);
+ }
+ break;
+
+ case 0xfe:
+ case 0xff:
+ if (ptr->stat != c && (c == 0xfe || c == 0xff)){
+ status_push_ch(ptr, c);
+ status_clear(ptr);
+ }else{
+ status_disable(ptr);
+ ptr->_file_stat = -1;
+ }
+ break;
+ }
+}
+
+void w_status(ptr, c)
+ struct input_code *ptr;
+ int c;
+{
+ switch (ptr->stat){
+ case -1:
+ status_check(ptr, c);
+ break;
+ case 0:
+ if (c <= DEL){
+ break;
+#ifdef NUMCHAR_OPTION
+ }else if ((c & CLASS_MASK) == CLASS_UTF16){
+ break;
+#endif
+ }else if (0xc0 <= c && c <= 0xdf){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+ }else if (0xe0 <= c && c <= 0xef){
+ ptr->stat = 2;
+ status_push_ch(ptr, c);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 1:
+ case 2:
+ if (0x80 <= c && c <= 0xbf){
+ status_push_ch(ptr, c);
+ if (ptr->index > ptr->stat){
+ int bom = (ptr->buf[0] == 0xef && ptr->buf[1] == 0xbb
+ && ptr->buf[2] == 0xbf);
+ w2e_conv(ptr->buf[0], ptr->buf[1], ptr->buf[2],
+ &ptr->buf[0], &ptr->buf[1]);
+ if (!bom){
+ code_score(ptr);
+ }
+ status_clear(ptr);
+ }
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ }
+}
+#endif
+
+void
+code_status(c)
+ int c;
+{
+ int action_flag = 1;
+ struct input_code *result = 0;
+ struct input_code *p = input_code_list;
+ while (p->name){
+ (p->status_func)(p, c);
+ if (p->stat > 0){
+ action_flag = 0;
+ }else if(p->stat == 0){
+ if (result){
+ action_flag = 0;
+ }else{
+ result = p;
+ }
+ }
+ ++p;
+ }
+
+ if (action_flag){
+ if (result && !estab_f){
+ set_iconv(TRUE, result->iconv_func);
+ }else if (c <= DEL){
+ struct input_code *ptr = input_code_list;
+ while (ptr->name){
+ status_reset(ptr);
+ ++ptr;
+ }
+ }
+ }
+}
+
+#ifdef PERL_XS
+#define STD_GC_BUFSIZE (256)
+int std_gc_buf[STD_GC_BUFSIZE];
+int std_gc_ndx;
+#endif
+
+int
+std_getc(f)
+FILE *f;
+{
+#ifdef PERL_XS
+ if (std_gc_ndx){
+ return std_gc_buf[--std_gc_ndx];
+ }
+#endif
+ return getc(f);
+}
+
+int
+std_ungetc(c,f)
+int c;
+FILE *f;
+{
+#ifdef PERL_XS
+ if (std_gc_ndx == STD_GC_BUFSIZE){
+ return EOF;
+ }
+ std_gc_buf[std_gc_ndx++] = c;
+ return c;
+#endif
+ return ungetc(c,f);
+}
+
+void
+std_putc(c)
+int c;
+{
+ if(c!=EOF)
+ putchar(c);
+}
+
+int
+noconvert(f)
+ FILE *f;
+{
+ int c;
+
+ while ((c = (*i_getc)(f)) != EOF)
+ (*o_putc)(c);
+ return 1;
+}
+
+
+void
+module_connection()
+{
+ oconv = output_conv;
+ o_putc = std_putc;
+
+ /* replace continucation module, from output side */
+
+ /* output redicrection */
+#ifdef CHECK_OPTION
+ if (noout_f || guess_f){
+ o_putc = no_putc;
+ }
+#endif
+ if (mimeout_f) {
+ o_mputc = o_putc;
+ o_putc = mime_putc;
+ if (mimeout_f == TRUE) {
+ o_base64conv = oconv; oconv = base64_conv;
+ }
+ /* base64_count = 0; */
+ }
+
+ if (crmode_f) {
+ o_crconv = oconv; oconv = cr_conv;
+ }
+ if (rot_f) {
+ o_rot_conv = oconv; oconv = rot_conv;
+ }
+ if (iso2022jp_f) {
+ o_iso2022jp_check_conv = oconv; oconv = iso2022jp_check_conv;
+ }
+ if (hira_f) {
+ o_hira_conv = oconv; oconv = hira_conv;
+ }
+ if (fold_f) {
+ o_fconv = oconv; oconv = fold_conv;
+ f_line = 0;
+ }
+ if (alpha_f || x0201_f) {
+ o_zconv = oconv; oconv = z_conv;
+ }
+
+ i_getc = std_getc;
+ i_ungetc = std_ungetc;
+ /* input redicrection */
+#ifdef INPUT_OPTION
+ if (cap_f){
+ i_cgetc = i_getc; i_getc = cap_getc;
+ i_cungetc = i_ungetc; i_ungetc= cap_ungetc;
+ }
+ if (url_f){
+ i_ugetc = i_getc; i_getc = url_getc;
+ i_uungetc = i_ungetc; i_ungetc= url_ungetc;
+ }
+#endif
+#ifdef NUMCHAR_OPTION
+ if (numchar_f){
+ i_ngetc = i_getc; i_getc = numchar_getc;
+ i_nungetc = i_ungetc; i_ungetc= numchar_ungetc;
+ }
+#endif
+ if (mime_f && mimebuf_f==FIXED_MIME) {
+ i_mgetc = i_getc; i_getc = mime_getc;
+ i_mungetc = i_ungetc; i_ungetc = mime_ungetc;
+ }
+ if (broken_f & 1) {
+ i_bgetc = i_getc; i_getc = broken_getc;
+ i_bungetc = i_ungetc; i_ungetc = broken_ungetc;
+ }
+ if (input_f == JIS_INPUT || input_f == LATIN1_INPUT) {
+ set_iconv(-TRUE, e_iconv);
+ } else if (input_f == SJIS_INPUT) {
+ set_iconv(-TRUE, s_iconv);
+#ifdef UTF8_INPUT_ENABLE
+ } else if (input_f == UTF8_INPUT) {
+ set_iconv(-TRUE, w_iconv);
+ } else if (input_f == UTF16_INPUT) {
+ set_iconv(-TRUE, w_iconv16);
+#endif
+ } else {
+ set_iconv(FALSE, e_iconv);
+ }
+
+ {
+ struct input_code *p = input_code_list;
+ while (p->name){
+ status_reinit(p++);
+ }
+ }
+}
+
+/*
+ Conversion main loop. Code detection only.
+ */
+
+int
+kanji_convert(f)
+ FILE *f;
+{
+ int c1,
+ c2, c3;
+
+ module_connection();
+ c2 = 0;
+
+
+ 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 = (*i_getc)(f)) != EOF) {
+ code_status(c1);
+ if (c2) {
+ /* second byte */
+ if (c2 > DEL) {
+ /* in case of 8th bit is on */
+ if (!estab_f) {
+ /* in case of not established yet */
+ /* It is still ambiguious */
+ if (h_conv(f, c2, c1)==EOF)
+ LAST;
+ else
+ c2 = 0;
+ NEXT;
+ } else
+ /* in case of already established */
+ if (c1 < AT) {
+ /* ignore bogus code */
+ c2 = 0;
+ NEXT;
+ } else
+ SEND;
+ } else
+ /* second byte, 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 (
+#ifdef UTF8_INPUT_ENABLE
+ iconv == w_iconv16
+#else
+ 0
+#endif
+ ) {
+ c2 = c1;
+ c1 = (*i_getc)(f);
+ SEND;
+#ifdef NUMCHAR_OPTION
+ } else if ((c1 & CLASS_MASK) == CLASS_UTF16){
+ SEND;
+#endif
+ } else if (c1 > DEL) {
+ /* 8 bit code */
+ if (!estab_f && !iso8859_f) {
+ /* not established yet */
+ c2 = c1;
+ NEXT;
+ } else { /* estab_f==TRUE */
+ if (iso8859_f) {
+ c2 = ISO8859_1;
+ c1 &= 0x7f;
+ SEND;
+ } else if (SSP<=c1 && c1<0xe0 && iconv == s_iconv) {
+ /* SJIS X0201 Case... */
+ if(iso2022jp_f && x0201_f==NO_X0201) {
+ (*oconv)(GETA1, GETA2);
+ NEXT;
+ } else {
+ c2 = X0201;
+ c1 &= 0x7f;
+ SEND;
+ }
+ } else if (c1==SSO && iconv != s_iconv) {
+ /* EUC X0201 Case */
+ c1 = (*i_getc)(f); /* skip SSO */
+ code_status(c1);
+ if (SSP<=c1 && c1<0xe0) {
+ if(iso2022jp_f && x0201_f==NO_X0201) {
+ (*oconv)(GETA1, GETA2);
+ NEXT;
+ } else {
+ c2 = X0201;
+ c1 &= 0x7f;
+ SEND;
+ }
+ } else { /* bogus code, skip SSO and one byte */
+ NEXT;
+ }
+ } else {
+ /* already established */
+ c2 = c1;
+ NEXT;
+ }
+ }
+ } else if ((c1 > SPACE) && (c1 != DEL)) {
+ /* in case of Roman characters */
+ if (shift_mode) {
+ /* output 1 shifted byte */
+ if (iso8859_f) {
+ c2 = ISO8859_1;
+ SEND;
+ } else if (SPACE<=c1 && c1<(0xe0&0x7f) ){
+ /* output 1 shifted byte */
+ if(iso2022jp_f && x0201_f==NO_X0201) {
+ (*oconv)(GETA1, GETA2);
+ NEXT;
+ } else {
+ c2 = X0201;
+ SEND;
+ }
+ } else {
+ /* look like bogus code */
+ NEXT;
+ }
+ } else if (input_mode == X0208) {
+ /* in case of Kanji shifted */
+ c2 = c1;
+ NEXT;
+ } else if (c1 == '=' && mime_f && !mime_decode_mode ) {
+ /* Check MIME code */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ (*oconv)(0, '=');
+ LAST;
+ } else if (c1 == '?') {
+ /* =? is mime conversion start sequence */
+ if(mime_f == STRICT_MIME) {
+ /* check in real detail */
+ if (mime_begin_strict(f) == EOF)
+ LAST;
+ else
+ NEXT;
+ } else if (mime_begin(f) == EOF)
+ LAST;
+ else
+ NEXT;
+ } else {
+ (*oconv)(0, '=');
+ (*i_ungetc)(c1,f);
+ NEXT;
+ }
+ } else {
+ /* normal ASCII code */
+ SEND;
+ }
+ } else if (c1 == SI) {
+ shift_mode = FALSE;
+ NEXT;
+ } else if (c1 == SO) {
+ shift_mode = TRUE;
+ NEXT;
+ } else if (c1 == ESC ) {
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /* (*oconv)(0, ESC); don't send bogus code */
+ LAST;
+ } else if (c1 == '$') {
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /*
+ (*oconv)(0, ESC); don't send bogus code
+ (*oconv)(0, '$'); */
+ LAST;
+ } else if (c1 == '@'|| c1 == 'B') {
+ /* This is kanji introduction */
+ input_mode = X0208;
+ shift_mode = FALSE;
+ set_input_codename("ISO-2022-JP");
+ debug(input_codename);
+ NEXT;
+ } else if (c1 == '(') {
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /* don't send bogus code
+ (*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 {
+ /* could be some special code */
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, '(');
+ (*oconv)(0, c1);
+ NEXT;
+ }
+ } else if (broken_f&0x2) {
+ /* accept any ESC-(-x as broken code ... */
+ input_mode = X0208;
+ shift_mode = FALSE;
+ NEXT;
+ } else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, c1);
+ NEXT;
+ }
+ } else if (c1 == '(') {
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /* don't send bogus code
+ (*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 if ( c1 == 'N' || c1 == 'n' ){
+ /* SS2 */
+ c3 = (*i_getc)(f); /* skip SS2 */
+ if ( (SPACE<=c3 && c3 < 0x60) || (0xa0<=c3 && c3 < 0xe0)){
+ c1 = c3;
+ c2 = X0201;
+ SEND;
+ }else{
+ (*i_ungetc)(c3, f);
+ /* lonely ESC */
+ (*oconv)(0, ESC);
+ SEND;
+ }
+ } else {
+ /* lonely ESC */
+ (*oconv)(0, ESC);
+ SEND;
+ }
+ } else if ((c1 == NL || c1 == CR) && broken_f&4) {
+ input_mode = ASCII; set_iconv(FALSE, 0);
+ SEND;
+ } else
+ SEND;
+ }
+ /* send: */
+ if (input_mode == X0208)
+ (*oconv)(c2, c1); /* this is JIS, not SJIS/EUC case */
+ else if (input_mode)
+ (*oconv)(input_mode, c1); /* other special case */
+ else if ((*iconv)(c2, c1, 0) < 0){ /* can be EUC/SJIS */
+ int c0 = (*i_getc)(f);
+ if (c0 != EOF){
+ code_status(c0);
+ (*iconv)(c2, c1, c0);
+ }
+ }
+
+ c2 = 0;
+ continue;
+ /* goto next_word */
+ }
+
+ /* epilogue */
+ (*iconv)(EOF, 0, 0);
+ return 1;
+}
+
+int
+h_conv(f, c2, c1)
+ FILE *f;
+ int c1,
+ c2;
+{
+ int wc,c3;
+
+
+ /** 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);
+ push_hold_buf(c1);
+ c2 = 0;
+
+ while ((c1 = (*i_getc)(f)) != EOF) {
+ if (c1 == ESC){
+ (*i_ungetc)(c1,f);
+ break;
+ }
+ code_status(c1);
+ if (push_hold_buf(c1) == EOF || estab_f){
+ break;
+ }
+ }
+
+ if (!estab_f){
+ struct input_code *p = input_code_list;
+ struct input_code *result = p;
+ if (c1 == EOF){
+ code_status(c1);
+ }
+ while (p->name){
+ if (p->score < result->score){
+ result = p;
+ }
+ ++p;
+ }
+ set_iconv(FALSE, result->iconv_func);
+ }
+
+
+ /** 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.
+ **/
+
+ c3=c1;
+ wc = 0;
+ while (wc < hold_count){
+ c2 = hold_buf[wc++];
+ if (c2 <= DEL
+#ifdef NUMCHAR_OPTION
+ || (c2 & CLASS_MASK) == CLASS_UTF16
+#endif
+ ){
+ (*iconv)(0, c2, 0);
+ continue;
+ }else if (iconv == s_iconv && 0xa1 <= c2 && c2 <= 0xdf){
+ (*iconv)(X0201, c2, 0);
+ continue;
+ }
+ if (wc < hold_count){
+ c1 = hold_buf[wc++];
+ }else{
+ c1 = (*i_getc)(f);
+ if (c1 == EOF){
+ c3 = EOF;
+ break;
+ }
+ code_status(c1);
+ }
+ if ((*iconv)(c2, c1, 0) < 0){
+ int c0;
+ if (wc < hold_count){
+ c0 = hold_buf[wc++];
+ }else{
+ c0 = (*i_getc)(f);
+ if (c0 == EOF){
+ c3 = EOF;
+ break;
+ }
+ code_status(c0);
+ }
+ (*iconv)(c2, c1, c0);
+ c1 = c0;
+ }
+ }
+ return c3;
+}
+
+
+
+int
+push_hold_buf(c2)
+ int c2;
+{
+ if (hold_count >= HOLD_SIZE*2)
+ return (EOF);
+ hold_buf[hold_count++] = c2;
+ return ((hold_count >= HOLD_SIZE*2) ? EOF : hold_count);
+}
+
+int s2e_conv(c2, c1, p2, p1)
+ int c2, c1;
+ int *p2, *p1;
+{
+#ifdef SHIFTJIS_CP932
+ if (cp932_f && CP932_TABLE_BEGIN <= c2 && c2 <= CP932_TABLE_END){
+ extern unsigned short shiftjis_cp932[3][189];
+ c1 = shiftjis_cp932[c2 - CP932_TABLE_BEGIN][c1 - 0x40];
+ if (c1 == 0) return 1;
+ c2 = c1 >> 8;
+ c1 &= 0xff;
+ }
+#endif /* SHIFTJIS_CP932 */
+ c2 = c2 + c2 - ((c2 <= 0x9f) ? SJ0162 : SJ6394);
+ if (c1 < 0x9f)
+ c1 = c1 - ((c1 > DEL) ? SPACE : 0x1f);
+ else {
+ c1 = c1 - 0x7e;
+ c2++;
+ }
+ if (p2) *p2 = c2;
+ if (p1) *p1 = c1;
+ return 0;
+}
+
+int
+s_iconv(c2, c1, c0)
+ int c2,
+ c1, c0;
+{
+ if (c2 == X0201) {
+ c1 &= 0x7f;
+ } else if ((c2 == EOF) || (c2 == 0) || c2 < SPACE) {
+ /* NOP */
+ } else {
+ int ret = s2e_conv(c2, c1, &c2, &c1);
+ if (ret) return ret;
+ }
+ (*oconv)(c2, c1);
+ return 0;
+}
+
+int
+e_iconv(c2, c1, c0)
+ int c2,
+ c1, c0;
+{
+ if (c2 == X0201) {
+ c1 &= 0x7f;
+ } else if (c2 == SSO){
+ c2 = X0201;
+ c1 &= 0x7f;
+ } else if ((c2 == EOF) || (c2 == 0) || c2 < SPACE) {
+ /* NOP */
+ } else {
+ c1 &= 0x7f;
+ c2 &= 0x7f;
+ }
+ (*oconv)(c2, c1);
+ return 0;
+}
+
+#ifdef UTF8_INPUT_ENABLE
+int
+w2e_conv(c2, c1, c0, p2, p1)
+ int c2, c1, c0;
+ int *p2, *p1;
+{
+ extern unsigned short * utf8_to_euc_2bytes[];
+ extern unsigned short ** utf8_to_euc_3bytes[];
+ int ret = 0;
+
+ if (0xc0 <= c2 && c2 <= 0xef) {
+ unsigned short **pp;
+
+ if (0xe0 <= c2) {
+ if (c0 == 0) return -1;
+ pp = utf8_to_euc_3bytes[c2 - 0x80];
+ ret = w_iconv_common(c1, c0, pp, sizeof_utf8_to_euc_C2, p2, p1);
+ } else {
+ ret = w_iconv_common(c2, c1, utf8_to_euc_2bytes, sizeof_utf8_to_euc_2bytes, p2, p1);
+ }
+#ifdef NUMCHAR_OPTION
+ if (ret){
+ if (p2) *p2 = 0;
+ if (p1) *p1 = CLASS_UTF16 | ww16_conv(c2, c1, c0);
+ ret = 0;
+ }
+#endif
+ return ret;
+ } else if (c2 == X0201) {
+ c1 &= 0x7f;
+ }
+ if (p2) *p2 = c2;
+ if (p1) *p1 = c1;
+ return ret;
+}
+
+int
+w_iconv(c2, c1, c0)
+ int c2,
+ c1, c0;
+{
+ int ret = w2e_conv(c2, c1, c0, &c2, &c1);
+ if (ret == 0){
+ (*oconv)(c2, c1);
+ }
+ return ret;
+}
+
+void
+w16w_conv(val, p2, p1, p0)
+ unsigned short val;
+ int *p2, *p1, *p0;
+{
+ if (val < 0x80){
+ *p2 = val;
+ *p1 = 0;
+ *p0 = 0;
+ }else if (val < 0x800){
+ *p2 = 0xc0 | (val >> 6);
+ *p1 = 0x80 | (val & 0x3f);
+ *p0 = 0;
+ }else{
+ *p2 = 0xe0 | (val >> 12);
+ *p1 = 0x80 | ((val >> 6) & 0x3f);
+ *p0 = 0x80 | (val & 0x3f);
+ }
+}
+
+int
+ww16_conv(c2, c1, c0)
+ int c2, c1, c0;
+{
+ unsigned short val;
+ if (c2 >= 0xe0){
+ val = (c2 & 0x0f) << 12;
+ val |= (c1 & 0x3f) << 6;
+ val |= (c0 & 0x3f);
+ }else if (c2 >= 0xc0){
+ val = (c2 & 0x1f) << 6;
+ val |= (c1 & 0x3f) << 6;
+ }else{
+ val = c2;
+ }
+ return val;
+}
+
+int
+w16e_conv(val, p2, p1)
+ unsigned short val;
+ int *p2, *p1;
+{
+ extern unsigned short * utf8_to_euc_2bytes[];
+ extern unsigned short ** utf8_to_euc_3bytes[];
+ int c2, c1, c0;
+ unsigned short **pp;
+ int psize;
+ int ret = 0;
+
+ w16w_conv(val, &c2, &c1, &c0);
+ if (c1){
+ if (c0){
+ pp = utf8_to_euc_3bytes[c2 - 0x80];
+ psize = sizeof_utf8_to_euc_C2;
+ ret = w_iconv_common(c1, c0, pp, psize, p2, p1);
+ }else{
+ pp = utf8_to_euc_2bytes;
+ psize = sizeof_utf8_to_euc_2bytes;
+ ret = w_iconv_common(c2, c1, pp, psize, p2, p1);
+ }
+#ifdef NUMCHAR_OPTION
+ if (ret){
+ *p2 = 0;
+ *p1 = CLASS_UTF16 | val;
+ ret = 0;
+ }
+#endif
+ }
+ return ret;
+}
+
+int
+w_iconv16(c2, c1, c0)
+ int c2, c1,c0;
+{
+ int ret;
+
+ if (c2==0376 && c1==0377){
+ utf16_mode = UTF16_INPUT;
+ return 0;
+ } else if (c2==0377 && c1==0376){
+ utf16_mode = UTF16BE_INPUT;
+ return 0;
+ }
+ if (c2 != EOF && utf16_mode == UTF16BE_INPUT) {
+ int tmp;
+ tmp=c1; c1=c2; c2=tmp;
+ }
+ if ((c2==0 && c1 < 0x80) || c2==EOF) {
+ (*oconv)(c2, c1);
+ return 0;
+ }
+ ret = w16e_conv(((c2<<8)&0xff00) + c1, &c2, &c1);
+ if (ret) return ret;
+ (*oconv)(c2, c1);
+ return 0;
+}
+
+int
+w_iconv_common(c1, c0, pp, psize, p2, p1)
+ int c1,c0;
+ unsigned short **pp;
+ int psize;
+ int *p2, *p1;
+{
+ int c2;
+ unsigned short *p ;
+ unsigned short val;
+
+ if (pp == 0) return 1;
+
+ c1 -= 0x80;
+ if (c1 < 0 || psize <= c1) return 1;
+ p = pp[c1];
+ if (p == 0) return 1;
+
+ c0 -= 0x80;
+ if (c0 < 0 || sizeof_utf8_to_euc_E5B8 <= c0) return 1;
+ val = p[c0];
+ if (val == 0) return 1;
+
+ c2 = val >> 8;
+ if (c2 == SO) c2 = X0201;
+ c1 = val & 0x7f;
+ if (p2) *p2 = c2;
+ if (p1) *p1 = c1;
+ return 0;
+}
+
+#endif
+
+#ifdef UTF8_OUTPUT_ENABLE
+int
+e2w_conv(c2, c1)
+ int c2, c1;
+{
+ extern unsigned short euc_to_utf8_1byte[];
+ extern unsigned short * euc_to_utf8_2bytes[];
+ unsigned short *p;
+
+ if (c2 == X0201) {
+ p = euc_to_utf8_1byte;
+ } else {
+ c2 &= 0x7f;
+ c2 = (c2&0x7f) - 0x21;
+ if (0<=c2 && c2<sizeof_euc_to_utf8_2bytes)
+ p = euc_to_utf8_2bytes[c2];
+ else
+ return 0;
+ }
+ if (!p) return 0;
+ c1 = (c1 & 0x7f) - 0x21;
+ if (0<=c1 && c1<sizeof_euc_to_utf8_1byte)
+ return p[c1];
+ return 0;
+}
+
+void
+w_oconv(c2, c1)
+ int c2,
+ c1;
+{
+ int c0;
+#ifdef NUMCHAR_OPTION
+ if (c2 == 0 && (c1 & CLASS_MASK) == CLASS_UTF16){
+ w16w_conv(c1, &c2, &c1, &c0);
+ (*o_putc)(c2);
+ if (c1){
+ (*o_putc)(c1);
+ if (c0) (*o_putc)(c0);
+ }
+ }
+#endif
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ } else if (c2 == 0) {
+ output_mode = ASCII;
+ (*o_putc)(c1);
+ } else if (c2 == ISO8859_1) {
+ output_mode = ISO8859_1;
+ (*o_putc)(c1 | 0x080);
+ } else {
+ output_mode = UTF8;
+ w16w_conv((unsigned short)e2w_conv(c2, c1), &c2, &c1, &c0);
+ (*o_putc)(c2);
+ if (c1){
+ (*o_putc)(c1);
+ if (c0) (*o_putc)(c0);
+ }
+ }
+}
+
+void
+w_oconv16(c2, c1)
+ int c2,
+ c1;
+{
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ }
+
+ if (w_oconv16_begin_f==2) {
+ if (w_oconv16_LE){
+ (*o_putc)((unsigned char)'\377');
+ (*o_putc)('\376');
+ }else{
+ (*o_putc)('\376');
+ (*o_putc)((unsigned char)'\377');
+ }
+ w_oconv16_begin_f=1;
+ }
+
+ if (c2 == ISO8859_1) {
+ c2 = 0;
+ c1 |= 0x80;
+#ifdef NUMCHAR_OPTION
+ } else if (c2 == 0 && (c1 & CLASS_MASK) == CLASS_UTF16) {
+ c2 = (c1 >> 8) & 0xff;
+ c1 &= 0xff;
+#endif
+ } else if (c2) {
+ unsigned short val = (unsigned short)e2w_conv(c2, c1);
+ c2 = (val >> 8) & 0xff;
+ c1 = val & 0xff;
+ }
+ if (w_oconv16_LE){
+ (*o_putc)(c1);
+ (*o_putc)(c2);
+ }else{
+ (*o_putc)(c2);
+ (*o_putc)(c1);
+ }
+}
+
+#endif
+
+void
+e_oconv(c2, c1)
+ int c2,
+ c1;
+{
+#ifdef NUMCHAR_OPTION
+ if (c2 == 0 && (c1 & CLASS_MASK) == CLASS_UTF16){
+ w16e_conv(c1, &c2, &c1);
+ }
+#endif
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ } else if (c2 == 0) {
+ output_mode = ASCII;
+ (*o_putc)(c1);
+ } else if (c2 == X0201) {
+ output_mode = JAPANESE_EUC;
+ (*o_putc)(SSO); (*o_putc)(c1|0x80);
+ } else if (c2 == ISO8859_1) {
+ output_mode = ISO8859_1;
+ (*o_putc)(c1 | 0x080);
+ } else {
+ if ((c1<0x21 || 0x7e<c1) ||
+ (c2<0x21 || 0x7e<c2)) {
+ set_iconv(FALSE, 0);
+ return; /* too late to rescue this char */
+ }
+ output_mode = JAPANESE_EUC;
+ (*o_putc)(c2 | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }
+}
+
+void
+e2s_conv(c2, c1, p2, p1)
+ int c2, c1, *p2, *p1;
+{
+ if (p2) *p2 = ((c2 - 1) >> 1) + ((c2 <= 0x5e) ? 0x71 : 0xb1);
+ if (p1) *p1 = c1 + ((c2 & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);
+}
+
+void
+s_oconv(c2, c1)
+ int c2,
+ c1;
+{
+#ifdef NUMCHAR_OPTION
+ if (c2 == 0 && (c1 & CLASS_MASK) == CLASS_UTF16){
+ w16e_conv(c1, &c2, &c1);
+ }
+#endif
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ } else if (c2 == 0) {
+ output_mode = ASCII;
+ (*o_putc)(c1);
+ } else if (c2 == X0201) {
+ output_mode = SHIFT_JIS;
+ (*o_putc)(c1|0x80);
+ } else if (c2 == ISO8859_1) {
+ output_mode = ISO8859_1;
+ (*o_putc)(c1 | 0x080);
+ } else {
+ if ((c1<0x20 || 0x7e<c1) ||
+ (c2<0x20 || 0x7e<c2)) {
+ set_iconv(FALSE, 0);
+ return; /* too late to rescue this char */
+ }
+ output_mode = SHIFT_JIS;
+ e2s_conv(c2, c1, &c2, &c1);
+
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f
+ && CP932INV_TABLE_BEGIN <= c2 && c2 <= CP932INV_TABLE_END){
+ extern unsigned short cp932inv[2][189];
+ int c = cp932inv[c2 - CP932INV_TABLE_BEGIN][c1 - 0x40];
+ if (c){
+ c2 = c >> 8;
+ c1 = c & 0xff;
+ }
+ }
+#endif /* SHIFTJIS_CP932 */
+
+ (*o_putc)(c2);
+ if (prefix_table[(unsigned char)c1]){
+ (*o_putc)(prefix_table[(unsigned char)c1]);
+ }
+ (*o_putc)(c1);
+ }
+}
+
+void
+j_oconv(c2, c1)
+ int c2,
+ c1;
+{
+#ifdef NUMCHAR_OPTION
+ if ((c1 & CLASS_MASK) == CLASS_UTF16){
+ w16e_conv(c1, &c2, &c1);
+ }
+#endif
+ if (c2 == EOF) {
+ if (output_mode !=ASCII && output_mode!=ISO8859_1) {
+ (*o_putc)(ESC);
+ (*o_putc)('(');
+ (*o_putc)(ascii_intro);
+ output_mode = ASCII;
+ }
+ (*o_putc)(EOF);
+ } else if (c2==X0201) {
+ if (output_mode!=X0201) {
+ output_mode = X0201;
+ (*o_putc)(ESC);
+ (*o_putc)('(');
+ (*o_putc)('I');
+ }
+ (*o_putc)(c1);
+ } else if (c2==ISO8859_1) {
+ /* iso8859 introduction, or 8th bit on */
+ /* Can we convert in 7bit form using ESC-'-'-A ?
+ Is this popular? */
+ output_mode = ISO8859_1;
+ (*o_putc)(c1|0x80);
+ } else if (c2 == 0) {
+ if (output_mode !=ASCII && output_mode!=ISO8859_1) {
+ (*o_putc)(ESC);
+ (*o_putc)('(');
+ (*o_putc)(ascii_intro);
+ output_mode = ASCII;
+ }
+ (*o_putc)(c1);
+ } else {
+ if (output_mode != X0208) {
+ output_mode = X0208;
+ (*o_putc)(ESC);
+ (*o_putc)('$');
+ (*o_putc)(kanji_intro);
+ }
+ if (c1<0x20 || 0x7e<c1)
+ return;
+ if (c2<0x20 || 0x7e<c2)
+ return;
+ (*o_putc)(c2);
+ (*o_putc)(c1);
+ }
+}
+
+void
+base64_conv(c2, c1)
+ int c2,
+ c1;
+{
+ if (base64_count>50 && !mimeout_mode && c2==0 && c1==SPACE) {
+ (*o_putc)(NL);
+ } else if (base64_count>66 && mimeout_mode) {
+ (*o_base64conv)(EOF,0);
+ (*o_putc)(NL);
+ (*o_putc)('\t'); base64_count += 7;
+ }
+ (*o_base64conv)(c2,c1);
+}
+
+
+static int broken_buf[3];
+static int broken_counter = 0;
+static int broken_last = 0;
+int
+broken_getc(f)
+FILE *f;
+{
+ int c,c1;
+
+ if (broken_counter>0) {
+ return broken_buf[--broken_counter];
+ }
+ c= (*i_bgetc)(f);
+ if (c=='$' && broken_last != ESC
+ && (input_mode==ASCII || input_mode==X0201)) {
+ c1= (*i_bgetc)(f);
+ broken_last = 0;
+ if (c1=='@'|| c1=='B') {
+ broken_buf[0]=c1; broken_buf[1]=c;
+ broken_counter=2;
+ return ESC;
+ } else {
+ (*i_bungetc)(c1,f);
+ return c;
+ }
+ } else if (c=='(' && broken_last != ESC
+ && (input_mode==X0208 || input_mode==X0201)) { /* ) */
+ c1= (*i_bgetc)(f);
+ broken_last = 0;
+ if (c1=='J'|| c1=='B') {
+ broken_buf[0]=c1; broken_buf[1]=c;
+ broken_counter=2;
+ return ESC;
+ } else {
+ (*i_bungetc)(c1,f);
+ return c;
+ }
+ } else {
+ broken_last = c;
+ return c;
+ }
+}
+
+int
+broken_ungetc(c,f)
+int c;
+FILE *f;
+{
+ if (broken_counter<2)
+ broken_buf[broken_counter++]=c;
+ return c;
+}
+
+static int prev_cr = 0;
+
+void
+cr_conv(c2,c1)
+int c2,c1;
+{
+ if (prev_cr) {
+ prev_cr = 0;
+ if (! (c2==0&&c1==NL) ) {
+ cr_conv(0,'\n');
+ }
+ }
+ if (c2) {
+ (*o_crconv)(c2,c1);
+ } else if (c1=='\r') {
+ prev_cr = c1;
+ } else if (c1=='\n') {
+ if (crmode_f==CRLF) {
+ (*o_crconv)(0,'\r');
+ } else if (crmode_f==CR) {
+ (*o_crconv)(0,'\r');
+ return;
+ }
+ (*o_crconv)(0,NL);
+ } else if (c1!='\032' || crmode_f!=NL){
+ (*o_crconv)(c2,c1);
+ }
+}
+
+/*
+ Return value of fold_conv()
+
+ \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.
+*/
+
+#define char_size(c2,c1) (c2?2:1)
+
+void
+fold_conv(c2,c1)
+int c2,c1;
+{
+ int prev0;
+ int fold_state=0;
+
+ if (c1== '\r' && !fold_preserve_f) {
+ fold_state=0; /* ignore cr */
+ }else if (c1== '\n'&&f_prev=='\r' && fold_preserve_f) {
+ f_prev = '\n';
+ fold_state=0; /* ignore cr */
+ } else if (c1== BS) {
+ if (f_line>0) f_line--;
+ fold_state = 1;
+ } else if (c2==EOF && f_line != 0) { /* close open last line */
+ fold_state = '\n';
+ } else if ((c1=='\n' && !fold_preserve_f)
+ || ((c1=='\r'||(c1=='\n'&&f_prev!='\r'))
+ && fold_preserve_f)) {
+ /* new line */
+ if (fold_preserve_f) {
+ f_prev = c1;
+ f_line = 0;
+ fold_state = '\r';
+ } else if ((f_prev == c1 && !fold_preserve_f)
+ || (f_prev == '\n' && fold_preserve_f)
+ ) { /* duplicate newline */
+ if (f_line) {
+ f_line = 0;
+ fold_state = '\n'; /* output two newline */
+ } else {
+ f_line = 0;
+ fold_state = 1;
+ }
+ } else {
+ if (f_prev&0x80) { /* Japanese? */
+ f_prev = c1;
+ fold_state = 0; /* ignore given single newline */
+ } else if (f_prev==' ') {
+ fold_state = 0;
+ } else {
+ f_prev = c1;
+ if (++f_line<=fold_len)
+ fold_state = ' ';
+ else {
+ f_line = 0;
+ fold_state = '\r'; /* fold and output nothing */
+ }
+ }
+ }
+ } else if (c1=='\f') {
+ f_prev = '\n';
+ if (f_line==0)
+ fold_state = 1;
+ f_line = 0;
+ fold_state = '\n'; /* output newline and clear */
+ } else if ( (c2==0 && c1==' ')||
+ (c2==0 && c1=='\t')||
+ (c2=='!'&& c1=='!')) {
+ /* X0208 kankaku or ascii space */
+ if (f_prev == ' ') {
+ fold_state = 0; /* remove duplicate spaces */
+ } else {
+ f_prev = ' ';
+ if (++f_line<=fold_len)
+ fold_state = ' '; /* output ASCII space only */
+ else {
+ f_prev = ' '; f_line = 0;
+ fold_state = '\r'; /* fold and output nothing */
+ }
+ }
+ } else {
+ prev0 = f_prev; /* we still need this one... , but almost done */
+ f_prev = c1;
+ if (c2 || c2==X0201)
+ f_prev |= 0x80; /* this is Japanese */
+ f_line += char_size(c2,c1);
+ if (f_line<=fold_len) { /* normal case */
+ fold_state = 1;
+ } else {
+ if (f_line>=fold_len+fold_margin) { /* too many kinsou suspension */
+ f_line = char_size(c2,c1);
+ fold_state = '\n'; /* We can't wait, do fold now */
+ } else if (c2==X0201) {
+ /* simple kinsoku rules return 1 means no folding */
+ if (c1==(0xde&0x7f)) fold_state = 1; /* $B!+(B*/
+ else if (c1==(0xdf&0x7f)) fold_state = 1; /* $B!,(B*/
+ else if (c1==(0xa4&0x7f)) fold_state = 1; /* $B!#(B*/
+ else if (c1==(0xa3&0x7f)) fold_state = 1; /* $B!$(B*/
+ else if (c1==(0xa1&0x7f)) fold_state = 1; /* $B!W(B*/
+ else if (c1==(0xb0&0x7f)) fold_state = 1; /* - */
+ else if (SPACE<=c1 && c1<=(0xdf&0x7f)) { /* X0201 */
+ f_line = 1;
+ fold_state = '\n';/* add one new f_line before this character */
+ } else {
+ f_line = 1;
+ fold_state = '\n';/* add one new f_line before this character */
+ }
+ } else if (c2==0) {
+ /* kinsoku point in ASCII */
+ if ( c1==')'|| /* { [ ( */
+ c1==']'||
+ c1=='}'||
+ c1=='.'||
+ c1==','||
+ c1=='!'||
+ c1=='?'||
+ c1=='/'||
+ c1==':'||
+ c1==';' ) {
+ fold_state = 1;
+ /* just after special */
+ } else if (!is_alnum(prev0)) {
+ f_line = char_size(c2,c1);
+ fold_state = '\n';
+ } else if ((prev0==' ') || /* ignored new f_line */
+ (prev0=='\n')|| /* ignored new f_line */
+ (prev0&0x80)) { /* X0208 - ASCII */
+ f_line = char_size(c2,c1);
+ fold_state = '\n';/* add one new f_line before this character */
+ } else {
+ fold_state = 1; /* default no fold in ASCII */
+ }
+ } else {
+ if (c2=='!') {
+ if (c1=='"') fold_state = 1; /* $B!"(B */
+ else if (c1=='#') fold_state = 1; /* $B!#(B */
+ else if (c1=='W') fold_state = 1; /* $B!W(B */
+ else if (c1=='K') fold_state = 1; /* $B!K(B */
+ else if (c1=='$') fold_state = 1; /* $B!$(B */
+ else if (c1=='%') fold_state = 1; /* $B!%(B */
+ else if (c1=='\'') fold_state = 1; /* $B!\(B */
+ else if (c1=='(') fold_state = 1; /* $B!((B */
+ else if (c1==')') fold_state = 1; /* $B!)(B */
+ else if (c1=='*') fold_state = 1; /* $B!*(B */
+ else if (c1=='+') fold_state = 1; /* $B!+(B */
+ else if (c1==',') fold_state = 1; /* $B!,(B */
+ /* default no fold in kinsoku */
+ else {
+ fold_state = '\n';
+ f_line = char_size(c2,c1);
+ /* add one new f_line before this character */
+ }
+ } else {
+ f_line = char_size(c2,c1);
+ fold_state = '\n';
+ /* add one new f_line before this character */
+ }
+ }
+ }
+ }
+ /* terminator process */
+ switch(fold_state) {
+ case '\n':
+ (*o_fconv)(0,'\n');
+ (*o_fconv)(c2,c1);
+ break;
+ case 0:
+ return;
+ case '\r':
+ (*o_fconv)(0,'\n');
+ break;
+ case '\t':
+ case ' ':
+ (*o_fconv)(0,' ');
+ break;
+ default:
+ (*o_fconv)(c2,c1);
+ }
+}
+
+int z_prev2=0,z_prev1=0;
+
+void
+z_conv(c2,c1)
+int c2,c1;
+{
+
+ /* if (c2) c1 &= 0x7f; assertion */
+
+ if (x0201_f && z_prev2==X0201) { /* X0201 */
+ if (c1==(0xde&0x7f)) { /* $BByE@(B */
+ z_prev2=0;
+ (*o_zconv)(dv[(z_prev1-SPACE)*2],dv[(z_prev1-SPACE)*2+1]);
+ return;
+ } else if (c1==(0xdf&0x7f)&&ev[(z_prev1-SPACE)*2]) { /* $BH>ByE@(B */
+ z_prev2=0;
+ (*o_zconv)(ev[(z_prev1-SPACE)*2],ev[(z_prev1-SPACE)*2+1]);
+ return;
+ } else {
+ z_prev2=0;
+ (*o_zconv)(cv[(z_prev1-SPACE)*2],cv[(z_prev1-SPACE)*2+1]);
+ }
+ }
+
+ if (c2==EOF) {
+ (*o_zconv)(c2,c1);
+ return;
+ }
+
+ if (x0201_f && c2==X0201) {
+ if (dv[(c1-SPACE)*2]||ev[(c1-SPACE)*2]) {
+ /* wait for $BByE@(B or $BH>ByE@(B */
+ z_prev1 = c1; z_prev2 = c2;
+ return;
+ } else {
+ (*o_zconv)(cv[(c1-SPACE)*2],cv[(c1-SPACE)*2+1]);
+ return;
+ }
+ }
+
+ /* JISX0208 Alphabet */
+ if (alpha_f && c2 == 0x23 ) {
+ c2 = 0;
+ } else if (alpha_f && c2 == 0x21 ) {
+ /* JISX0208 Kigou */
+ if (0x21==c1) {
+ if (alpha_f&0x2) {
+ c1 = ' ';
+ c2 = 0;
+ } else if (alpha_f&0x4) {
+ (*o_zconv)(0,' ');
+ (*o_zconv)(0,' ');
+ return;
+ }
+ } else if (0x20<c1 && c1<0x7f && fv[c1-0x20]) {
+ c1 = fv[c1-0x20];
+ c2 = 0;
+ if (alpha_f&0x8) {
+ char *entity = 0;
+ switch (c1){
+ case '>': entity = "&gt;"; break;
+ case '<': entity = "&lt;"; break;
+ case '\"': entity = "&quot;"; break;
+ case '&': entity = "&amp;"; break;
+ }
+ if (entity){
+ while (*entity) (*o_zconv)(0, *entity++);
+ return;
+ }
+ }
+ }
+ }
+ (*o_zconv)(c2,c1);
+}
+
+
+#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 \
+)
+
+void
+rot_conv(c2,c1)
+int c2,c1;
+{
+ if (c2==0 || c2==X0201 || c2==ISO8859_1) {
+ c1 = rot13(c1);
+ } else if (c2) {
+ c1 = rot47(c1);
+ c2 = rot47(c2);
+ }
+ (*o_rot_conv)(c2,c1);
+}
+
+void
+hira_conv(c2,c1)
+int c2,c1;
+{
+ if ((hira_f & 1) && c2==0x25 && 0x20<c1 && c1<0x74) {
+ c2 = 0x24;
+ } else if ((hira_f & 2) && c2==0x24 && 0x20<c1 && c1<0x74) {
+ c2 = 0x25;
+ }
+ (*o_hira_conv)(c2,c1);
+}
+
+
+void
+iso2022jp_check_conv(c2,c1)
+int c2, c1;
+{
+ static int range[RANGE_NUM_MAX][2] = {
+ {0x222f, 0x2239,},
+ {0x2242, 0x2249,},
+ {0x2251, 0x225b,},
+ {0x226b, 0x2271,},
+ {0x227a, 0x227d,},
+ {0x2321, 0x232f,},
+ {0x233a, 0x2340,},
+ {0x235b, 0x2360,},
+ {0x237b, 0x237e,},
+ {0x2474, 0x247e,},
+ {0x2577, 0x257e,},
+ {0x2639, 0x2640,},
+ {0x2659, 0x267e,},
+ {0x2742, 0x2750,},
+ {0x2772, 0x277e,},
+ {0x2841, 0x287e,},
+ {0x4f54, 0x4f7e,},
+ {0x7425, 0x747e},
+ };
+ int i;
+ int start, end, c;
+
+ if(c2 >= 0x00 && c2 <= 0x20 && c1 >= 0x7f && c1 <= 0xff) {
+ c2 = GETA1;
+ c1 = GETA2;
+ }
+ if((c2 >= 0x29 && c2 <= 0x2f) || (c2 >= 0x75 && c2 <= 0x7e)) {
+ c2 = GETA1;
+ c1 = GETA2;
+ }
+
+ for (i = 0; i < RANGE_NUM_MAX; i++) {
+ start = range[i][0];
+ end = range[i][1];
+ c = (c2 << 8) + c1;
+ if (c >= start && c <= end) {
+ c2 = GETA1;
+ c1 = GETA2;
+ }
+ }
+ (*o_iso2022jp_check_conv)(c2,c1);
+}
+
+
+/* This converts =?ISO-2022-JP?B?HOGE HOGE?= */
+
+unsigned char *mime_pattern[] = {
+ (unsigned char *)"\075?EUC-JP?B?",
+ (unsigned char *)"\075?SHIFT_JIS?B?",
+ (unsigned char *)"\075?ISO-8859-1?Q?",
+ (unsigned char *)"\075?ISO-8859-1?B?",
+ (unsigned char *)"\075?ISO-2022-JP?B?",
+ (unsigned char *)"\075?ISO-2022-JP?Q?",
+#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
+ (unsigned char *)"\075?UTF-8?B?",
+ (unsigned char *)"\075?UTF-8?Q?",
+#endif
+ (unsigned char *)"\075?US-ASCII?Q?",
+ NULL
+};
+
+
+/* $B3:Ev$9$k%3!<%I$NM%@hEY$r>e$2$k$?$a$NL\0u(B */
+int (*mime_priority_func[])PROTO((int c2, int c1, int c0)) = {
+ e_iconv, s_iconv, 0, 0, 0, 0,
+#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
+ w_iconv, w_iconv,
+#endif
+ 0,
+};
+
+int mime_encode[] = {
+ JAPANESE_EUC, SHIFT_JIS,ISO8859_1, ISO8859_1, X0208, X0201,
+#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
+ UTF8, UTF8,
+#endif
+ ASCII,
+ 0
+};
+
+int mime_encode_method[] = {
+ 'B', 'B','Q', 'B', 'B', 'Q',
+#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
+ 'B', 'Q',
+#endif
+ 'Q',
+ 0
+};
+
+
+#define MAXRECOVER 20
+
+/* I don't trust portablity of toupper */
+#define nkf_toupper(c) (('a'<=c && c<='z')?(c-('a'-'A')):c)
+#define nkf_isdigit(c) ('0'<=c && c<='9')
+#define nkf_isxdigit(c) (nkf_isdigit(c) || ('a'<=c && c<='f') || ('A'<=c && c <= 'F'))
+
+void
+switch_mime_getc()
+{
+ if (i_getc!=mime_getc) {
+ i_mgetc = i_getc; i_getc = mime_getc;
+ i_mungetc = i_ungetc; i_ungetc = mime_ungetc;
+ if(mime_f==STRICT_MIME) {
+ i_mgetc_buf = i_mgetc; i_mgetc = mime_getc_buf;
+ i_mungetc_buf = i_mungetc; i_mungetc = mime_ungetc_buf;
+ }
+ }
+}
+
+void
+unswitch_mime_getc()
+{
+ if(mime_f==STRICT_MIME) {
+ i_mgetc = i_mgetc_buf;
+ i_mungetc = i_mungetc_buf;
+ }
+ i_getc = i_mgetc;
+ i_ungetc = i_mungetc;
+}
+
+int
+mime_begin_strict(f)
+FILE *f;
+{
+ int c1 = 0;
+ int i,j,k;
+ unsigned char *p,*q;
+ int r[MAXRECOVER]; /* recovery buffer, max mime pattern lenght */
+
+ mime_decode_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 = (*i_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 */
+ (*i_ungetc)(c1,f);
+ for(j=0;j<i;j++) {
+ (*oconv)(0,r[j]);
+ }
+ return c1;
+ }
+ }
+ mime_decode_mode = p[i-2];
+
+ clr_code_score(find_inputcode_byfunc(mime_priority_func[j]), SCORE_iMIME);
+
+ if (mime_decode_mode=='B') {
+ mimebuf_f = unbuf_f;
+ if (!unbuf_f) {
+ /* do MIME integrity check */
+ return mime_integrity(f,mime_pattern[j]);
+ }
+ }
+ switch_mime_getc();
+ mimebuf_f = TRUE;
+ return c1;
+}
+
+int
+mime_getc_buf(f)
+FILE *f;
+{
+ /* we don't keep eof of Fifo, becase it contains ?= as
+ a terminator. It was checked in mime_integrity. */
+ return ((mimebuf_f)?
+ (*i_mgetc_buf)(f):Fifo(mime_input++));
+}
+
+int
+mime_ungetc_buf(c,f)
+FILE *f;
+int c;
+{
+ if (mimebuf_f)
+ (*i_mungetc_buf)(c,f);
+ else
+ Fifo(--mime_input)=c;
+ return c;
+}
+
+int
+mime_begin(f)
+FILE *f;
+{
+ int c1;
+ int i,k;
+
+ /* In NONSTRICT mode, only =? is checked. In case of failure, we */
+ /* re-read and convert again from mime_buffer. */
+
+ /* =? has been checked */
+ k = mime_last;
+ Fifo(mime_last++)='='; Fifo(mime_last++)='?';
+ for(i=2;i<MAXRECOVER;i++) { /* start at =? */
+ /* We accept any character type even if it is breaked by new lines */
+ c1 = (*i_getc)(f); Fifo(mime_last++)= c1 ;
+ if (c1=='\n'||c1==' '||c1=='\r'||
+ c1=='-'||c1=='_'||is_alnum(c1) ) continue;
+ if (c1=='=') {
+ /* Failed. But this could be another MIME preemble */
+ (*i_ungetc)(c1,f);
+ mime_last--;
+ break;
+ }
+ if (c1!='?') break;
+ else {
+ /* c1=='?' */
+ c1 = (*i_getc)(f); Fifo(mime_last++) = c1;
+ if (!(++i<MAXRECOVER) || c1==EOF) break;
+ if (c1=='b'||c1=='B') {
+ mime_decode_mode = 'B';
+ } else if (c1=='q'||c1=='Q') {
+ mime_decode_mode = 'Q';
+ } else {
+ break;
+ }
+ c1 = (*i_getc)(f); Fifo(mime_last++) = c1;
+ if (!(++i<MAXRECOVER) || c1==EOF) break;
+ if (c1!='?') {
+ mime_decode_mode = FALSE;
+ }
+ break;
+ }
+ }
+ switch_mime_getc();
+ if (!mime_decode_mode) {
+ /* false MIME premble, restart from mime_buffer */
+ mime_decode_mode = 1; /* no decode, but read from the mime_buffer */
+ /* Since we are in MIME mode until buffer becomes empty, */
+ /* we never go into mime_begin again for a while. */
+ return c1;
+ }
+ /* discard mime preemble, and goto MIME mode */
+ mime_last = k;
+ /* do no MIME integrity check */
+ return c1; /* used only for checking EOF */
+}
+
+#ifdef CHECK_OPTION
+void
+no_putc(c)
+ int c;
+{
+ ;
+}
+
+void debug(str)
+ char *str;
+{
+ if (debug_f){
+ fprintf(stderr, "%s\n", str);
+ }
+}
+#endif
+
+void
+set_input_codename (codename)
+ char *codename;
+{
+ if (guess_f &&
+ is_inputcode_set &&
+ strcmp(codename, "") != 0 &&
+ strcmp(codename, input_codename) != 0)
+ {
+ is_inputcode_mixed = TRUE;
+ }
+ input_codename = codename;
+ is_inputcode_set = TRUE;
+}
+
+void
+print_guessed_code (filename)
+ char *filename;
+{
+ char *codename = "BINARY";
+ if (!is_inputcode_mixed) {
+ if (strcmp(input_codename, "") == 0) {
+ codename = "ASCII";
+ } else {
+ codename = input_codename;
+ }
+ }
+ if (filename != NULL) printf("%s:", filename);
+ printf("%s\n", codename);
+}
+
+int
+hex2bin(x)
+ int x;
+{
+ if (nkf_isdigit(x)) return x - '0';
+ return nkf_toupper(x) - 'A' + 10;
+}
+
+#ifdef INPUT_OPTION
+
+#ifdef ANSI_C_PROTOTYPE
+int hex_getc(int ch, FILE *f, int (*g)(FILE *f), int (*u)(int c, FILE *f))
+#else
+int
+hex_getc(ch, f, g, u)
+ int ch;
+ FILE *f;
+ int (*g)();
+ int (*u)();
+#endif
+{
+ int c1, c2, c3;
+ c1 = (*g)(f);
+ if (c1 != ch){
+ return c1;
+ }
+ c2 = (*g)(f);
+ if (!nkf_isxdigit(c2)){
+ (*u)(c2, f);
+ return c1;
+ }
+ c3 = (*g)(f);
+ if (!nkf_isxdigit(c3)){
+ (*u)(c2, f);
+ (*u)(c3, f);
+ return c1;
+ }
+ return (hex2bin(c2) << 4) | hex2bin(c3);
+}
+
+int
+cap_getc(f)
+ FILE *f;
+{
+ return hex_getc(':', f, i_cgetc, i_cungetc);
+}
+
+int
+cap_ungetc(c, f)
+ int c;
+ FILE *f;
+{
+ return (*i_cungetc)(c, f);
+}
+
+int
+url_getc(f)
+ FILE *f;
+{
+ return hex_getc('%', f, i_ugetc, i_uungetc);
+}
+
+int
+url_ungetc(c, f)
+ int c;
+ FILE *f;
+{
+ return (*i_uungetc)(c, f);
+}
+#endif
+
+#ifdef NUMCHAR_OPTION
+int
+numchar_getc(f)
+ FILE *f;
+{
+ int (*g)() = i_ngetc;
+ int (*u)() = i_nungetc;
+ int i = 0, j;
+ int buf[8];
+ long c = -1;
+
+ buf[i] = (*g)(f);
+ if (buf[i] == '&'){
+ buf[++i] = (*g)(f);
+ if (buf[i] == '#'){
+ c = 0;
+ buf[++i] = (*g)(f);
+ if (buf[i] == 'x' || buf[i] == 'X'){
+ for (j = 0; j < 5; j++){
+ buf[++i] = (*g)(f);
+ if (!nkf_isxdigit(buf[i])){
+ if (buf[i] != ';'){
+ c = -1;
+ }
+ break;
+ }
+ c <<= 4;
+ c |= hex2bin(buf[i]);
+ }
+ }else{
+ for (j = 0; j < 6; j++){
+ if (j){
+ buf[++i] = (*g)(f);
+ }
+ if (!nkf_isdigit(buf[i])){
+ if (buf[i] != ';'){
+ c = -1;
+ }
+ break;
+ }
+ c *= 10;
+ c += hex2bin(buf[i]);
+ }
+ }
+ }
+ }
+ if (c != -1){
+ return CLASS_UTF16 | c;
+ }
+ while (i > 0){
+ (*u)(buf[i], f);
+ --i;
+ }
+ return buf[0];
+}
+
+int
+numchar_ungetc(c, f)
+ int c;
+ FILE *f;
+{
+ return (*i_nungetc)(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 (mime_decode_mode==1 ||mime_decode_mode==FALSE) {
+ mime_decode_mode=FALSE;
+ unswitch_mime_getc();
+ return (*i_getc)(f);
+ }
+
+ if (mimebuf_f == FIXED_MIME)
+ exit_mode = mime_decode_mode;
+ else
+ exit_mode = FALSE;
+ if (mime_decode_mode == 'Q') {
+ if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
+restart_mime_q:
+ if (c1=='_') return ' ';
+ if (c1!='=' && c1!='?') {
+ return c1;
+ }
+
+ mime_decode_mode = exit_mode; /* prepare for quit */
+ if (c1<=' ') return c1;
+ if ((c2 = (*i_mgetc)(f)) == EOF) return (EOF);
+ if (c1=='?'&&c2=='=' && mimebuf_f != FIXED_MIME) {
+ /* end Q encoding */
+ input_mode = exit_mode;
+ while((c1=(*i_getc)(f))!=EOF && c1==SPACE
+ /* && (c1==NL||c1==TAB||c1=='\r') */ ) ;
+ return c1;
+ }
+ if (c1=='='&&c2<' ') { /* this is soft wrap */
+ while((c1 = (*i_mgetc)(f)) <=' ') {
+ if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
+ }
+ mime_decode_mode = 'Q'; /* still in MIME */
+ goto restart_mime_q;
+ }
+ if (c1=='?') {
+ mime_decode_mode = 'Q'; /* still in MIME */
+ (*i_mungetc)(c2,f);
+ return c1;
+ }
+ if ((c3 = (*i_mgetc)(f)) == EOF) return (EOF);
+ if (c2<=' ') return c2;
+ mime_decode_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_decode_mode != 'B') {
+ mime_decode_mode = FALSE;
+ return (*i_mgetc)(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_decode_mode;
+ mime_decode_mode = exit_mode; /* prepare for quit */
+
+ while ((c1 = (*i_mgetc)(f))<=' ') {
+ if (c1==EOF)
+ return (EOF);
+ }
+mime_c2_retry:
+ if ((c2 = (*i_mgetc)(f))<=' ') {
+ if (c2==EOF)
+ return (EOF);
+ if (mime_f != STRICT_MIME) goto mime_c2_retry;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c2;
+ }
+ if ((c1 == '?') && (c2 == '=')) {
+ input_mode = ASCII;
+ while((c1=(*i_getc)(f))!=EOF && c1==SPACE
+ /* && (c1==NL||c1==TAB||c1=='\r') */ ) ;
+ return c1;
+ }
+mime_c3_retry:
+ if ((c3 = (*i_mgetc)(f))<=' ') {
+ if (c3==EOF)
+ return (EOF);
+ if (mime_f != STRICT_MIME) goto mime_c3_retry;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c3;
+ }
+mime_c4_retry:
+ if ((c4 = (*i_mgetc)(f))<=' ') {
+ if (c4==EOF)
+ return (EOF);
+ if (mime_f != STRICT_MIME) goto mime_c4_retry;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c4;
+ }
+
+ mime_decode_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,f)
+int c;
+FILE *f;
+{
+ Fifo(--mime_top) = c;
+ return c;
+}
+
+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 full
+ */
+ mime_input = mime_top;
+ mime_last = mime_top;
+ while(*p) Fifo(mime_input++) = *p++;
+ d = 0;
+ q = mime_input;
+ while((c=(*i_getc)(f))!=EOF) {
+ if (((mime_input-mime_top)&MIME_BUF_MASK)==0) {
+ break; /* buffer full */
+ }
+ if (c=='=' && d=='?') {
+ /* checked. skip header, start decode */
+ Fifo(mime_input++) = c;
+ /* mime_last_input = mime_input; */
+ mime_input = q;
+ switch_mime_getc();
+ return 1;
+ }
+ if (!( (c=='+'||c=='/'|| c=='=' || c=='?' || is_alnum(c))))
+ 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_decode_mode = 1; /* no decode on Fifo last in mime_getc */
+ switch_mime_getc(); /* anyway we need buffered getc */
+ return 1;
+}
+
+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);
+}
+
+static char basis_64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static int b64c;
+
+void
+open_mime(mode)
+int mode;
+{
+ unsigned char *p;
+ int i;
+ p = mime_pattern[0];
+ for(i=0;mime_encode[i];i++) {
+ if (mode == mime_encode[i]) {
+ p = mime_pattern[i];
+ break;
+ }
+ }
+ mimeout_mode = mime_encode_method[i];
+
+ /* (*o_mputc)(' '); */
+ while(*p) {
+ (*o_mputc)(*p++);
+ base64_count ++;
+ }
+}
+
+void
+close_mime()
+{
+ (*o_mputc)('?');
+ (*o_mputc)('=');
+ (*o_mputc)(' ');
+ base64_count += 3;
+ mimeout_mode = 0;
+}
+
+#define itoh4(c) (c>=10?c+'A'-10:c+'0')
+
+void
+mime_putc(c)
+ int c;
+{
+ if (mimeout_f==FIXED_MIME) {
+ if (base64_count>71) {
+ (*o_mputc)('\n');
+ base64_count=0;
+ }
+ } else if (c==NL) {
+ base64_count=0;
+ }
+ if (c!=EOF) {
+ if ( c<=DEL &&(output_mode==ASCII ||output_mode == ISO8859_1 )
+ && mimeout_f!=FIXED_MIME) {
+ if (mimeout_mode=='Q') {
+ if (c<=SPACE) {
+ close_mime();
+ }
+ (*o_mputc)(c);
+ return;
+ }
+ if (mimeout_mode!='B' || c!=SPACE) {
+ if (mimeout_mode) {
+ mime_putc(EOF);
+ mimeout_mode=0;
+ }
+ (*o_mputc)(c);
+ base64_count ++;
+ return;
+ }
+ } else if (!mimeout_mode && mimeout_f!=FIXED_MIME) {
+ open_mime(output_mode);
+ }
+ } else { /* c==EOF */
+ switch(mimeout_mode) {
+ case 'Q':
+ case 'B':
+ break;
+ case 2:
+ (*o_mputc)(basis_64[((b64c & 0x3)<< 4)]);
+ (*o_mputc)('=');
+ (*o_mputc)('=');
+ base64_count += 3;
+ break;
+ case 1:
+ (*o_mputc)(basis_64[((b64c & 0xF) << 2)]);
+ (*o_mputc)('=');
+ base64_count += 2;
+ break;
+ }
+ if (mimeout_mode) {
+ if (mimeout_f!=FIXED_MIME) {
+ close_mime();
+ } else if (mimeout_mode != 'Q')
+ mimeout_mode = 'B';
+ }
+ return;
+ }
+ switch(mimeout_mode) {
+ case 'Q':
+ if(c>=DEL) {
+ (*o_mputc)('=');
+ (*o_mputc)(itoh4(((c>>4)&0xf)));
+ (*o_mputc)(itoh4((c&0xf)));
+ } else {
+ (*o_mputc)(c);
+ }
+ break;
+ case 'B':
+ b64c=c;
+ (*o_mputc)(basis_64[c>>2]);
+ mimeout_mode=2;
+ base64_count ++;
+ break;
+ case 2:
+ (*o_mputc)(basis_64[((b64c & 0x3)<< 4) | ((c & 0xF0) >> 4)]);
+ b64c=c;
+ mimeout_mode=1;
+ base64_count ++;
+ break;
+ case 1:
+ (*o_mputc)(basis_64[((b64c & 0xF) << 2) | ((c & 0xC0) >>6)]);
+ (*o_mputc)(basis_64[c & 0x3F]);
+ mimeout_mode='B';
+ base64_count += 2;
+ break;
+ }
+}
+
+
+#ifdef PERL_XS
+void
+reinit()
+{
+ unbuf_f = FALSE;
+ estab_f = FALSE;
+ nop_f = FALSE;
+ binmode_f = TRUE;
+ rot_f = FALSE;
+ hira_f = FALSE;
+ input_f = FALSE;
+ alpha_f = FALSE;
+ mime_f = STRICT_MIME;
+ mimebuf_f = FALSE;
+ broken_f = FALSE;
+ iso8859_f = FALSE;
+#if defined(MSDOS) || defined(__OS2__)
+ x0201_f = TRUE;
+#else
+ x0201_f = NO_X0201;
+#endif
+ iso2022jp_f = FALSE;
+
+ kanji_intro = DEFAULT_J;
+ ascii_intro = DEFAULT_R;
+
+ output_conv = DEFAULT_CONV;
+ oconv = DEFAULT_CONV;
+
+ i_mgetc = std_getc;
+ i_mungetc = std_ungetc;
+ i_mgetc_buf = std_getc;
+ i_mungetc_buf = std_ungetc;
+
+ i_getc= std_getc;
+ i_ungetc=std_ungetc;
+
+ i_bgetc= std_getc;
+ i_bungetc= std_ungetc;
+
+ o_putc = std_putc;
+ o_mputc = std_putc;
+ o_crconv = no_connection;
+ o_rot_conv = no_connection;
+ o_iso2022jp_check_conv = no_connection;
+ o_hira_conv = no_connection;
+ o_fconv = no_connection;
+ o_zconv = no_connection;
+
+ i_getc = std_getc;
+ i_ungetc = std_ungetc;
+ i_mgetc = std_getc;
+ i_mungetc = std_ungetc;
+
+ output_mode = ASCII;
+ input_mode = ASCII;
+ shift_mode = FALSE;
+ mime_decode_mode = FALSE;
+ file_out = FALSE;
+ mimeout_mode = 0;
+ mimeout_f = FALSE;
+ base64_count = 0;
+ option_mode = 0;
+ crmode_f = 0;
+
+ {
+ struct input_code *p = input_code_list;
+ while (p->name){
+ status_reinit(p++);
+ }
+ }
+#ifdef UTF8_OUTPUT_ENABLE
+ if (w_oconv16_begin_f) {
+ w_oconv16_begin_f = 2;
+ }
+#endif
+ f_line = 0;
+ f_prev = 0;
+ fold_preserve_f = FALSE;
+ fold_f = FALSE;
+ fold_len = 0;
+ fold_margin = FOLD_MARGIN;
+ broken_counter = 0;
+ broken_last = 0;
+ z_prev2=0,z_prev1=0;
+
+ {
+ int i;
+ for (i = 0; i < 256; i++){
+ prefix_table[i] = 0;
+ }
+ }
+ input_codename = "";
+ is_inputcode_mixed = FALSE;
+ is_inputcode_set = FALSE;
+}
+#endif
+
+void
+no_connection(c2,c1)
+int c2,c1;
+{
+ no_connection2(c2,c1,0);
+}
+
+int
+no_connection2(c2,c1,c0)
+int c2,c1,c0;
+{
+ fprintf(stderr,"nkf internal module connection failure.\n");
+ exit(1);
+}
+
+#ifndef PERL_XS
+void
+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 buffered (DEFAULT),Output is unbuffered\n");
+#ifdef DEFAULT_CODE_SJIS
+ fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift JIS (DEFAULT), AT&T JIS (EUC), UTF-8\n");
+#endif
+#ifdef DEFAULT_CODE_JIS
+ fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit (DEFAULT), Shift JIS, AT&T JIS (EUC), UTF-8\n");
+#endif
+#ifdef DEFAULT_CODE_EUC
+ fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift JIS, AT&T JIS (EUC) (DEFAULT), UTF-8\n");
+#endif
+#ifdef DEFAULT_CODE_UTF8
+ fprintf(stderr,"j,s,e,w Outout code is JIS 7 bit, Shift JIS, AT&T JIS (EUC), UTF-8 (DEFAULT)\n");
+#endif
+ fprintf(stderr,"J,S,E,W Input assumption is JIS 7 bit , Shift JIS, AT&T JIS (EUC), UTF-8\n");
+ fprintf(stderr,"t no conversion\n");
+ fprintf(stderr,"i_/o_ Output sequence to designate JIS-kanji/ASCII (DEFAULT B)\n");
+ fprintf(stderr,"r {de/en}crypt ROT13/47\n");
+ fprintf(stderr,"h 1 hirakana->katakana, 2 katakana->hirakana,3 both\n");
+ fprintf(stderr,"v Show this usage. V: show version\n");
+ fprintf(stderr,"m[BQN0] MIME decode [B:base64,Q:quoted,N:non-strict,0:no decode]\n");
+ fprintf(stderr,"M[BQ] MIME encode [B:base64 Q:quoted]\n");
+ fprintf(stderr,"l ISO8859-1 (Latin-1) support\n");
+ fprintf(stderr,"f/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl\n");
+ fprintf(stderr,"Z[0-3] Convert X0208 alphabet to ASCII 1: Kankaku to space,2: 2 spaces,\n");
+ fprintf(stderr," 3: Convert HTML Entity\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 and \\032, Add \\r in line feed\n");
+ fprintf(stderr,"I Convert non ISO-2022-JP charactor to GETA\n");
+ fprintf(stderr,"-L[uwm] line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n");
+ fprintf(stderr,"long name options\n");
+ fprintf(stderr," --fj,--unix,--mac,--windows convert for the system\n");
+ fprintf(stderr," --jis,--euc,--sjis,--utf8,--utf16,--mime,--base64 convert for the code\n");
+#ifdef OVERWRITE
+ fprintf(stderr," --overwrite Overwrite original listed files by filtered result\n");
+#endif
+ fprintf(stderr," -g, --guess Guess the input code\n");
+ fprintf(stderr," --help,--version\n");
+ version();
+}
+
+void
+version()
+{
+ fprintf(stderr,"Network Kanji Filter Version %s (%s) "
+#if defined(MSDOS) && !defined(__WIN32__) && !defined(__WIN16__)
+ "for DOS"
+#endif
+#if defined(MSDOS) && defined(__WIN16__)
+ "for Win16"
+#endif
+#if defined(MSDOS) && defined(__WIN32__)
+ "for Win32"
+#endif
+#ifdef __OS2__
+ "for OS/2"
+#endif
+ ,Version,Patchlevel);
+ fprintf(stderr,"\n%s\n",CopyRight);
+}
+#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)
+ **
+ **/
+
+/* end */
diff --git a/ext/nkf/nkf-utf8/utf8tbl.c b/ext/nkf/nkf-utf8/utf8tbl.c
new file mode 100644
index 0000000000..b2e49c49d2
--- /dev/null
+++ b/ext/nkf/nkf-utf8/utf8tbl.c
@@ -0,0 +1,5313 @@
+#include "config.h"
+
+#ifdef UTF8_OUTPUT_ENABLE
+unsigned short euc_to_utf8_A1[] = {
+ 0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A,
+ 0xFF1B, 0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8,
+ 0xFF3E, 0xFFE3, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003,
+ 0x4EDD, 0x3005, 0x3006, 0x3007, 0x30FC, 0x2015, 0x2010, 0xFF0F,
+ 0xFF3C, 0x301C, 0x2016, 0xFF5C, 0x2026, 0x2025, 0x2018, 0x2019,
+ 0x201C, 0x201D, 0xFF08, 0xFF09, 0x3014, 0x3015, 0xFF3B, 0xFF3D,
+ 0xFF5B, 0xFF5D, 0x3008, 0x3009, 0x300A, 0x300B, 0x300C, 0x300D,
+ 0x300E, 0x300F, 0x3010, 0x3011, 0xFF0B, 0x2212, 0x00B1, 0x00D7,
+ 0x00F7, 0xFF1D, 0x2260, 0xFF1C, 0xFF1E, 0x2266, 0x2267, 0x221E,
+ 0x2234, 0x2642, 0x2640, 0x00B0, 0x2032, 0x2033, 0x2103, 0xFFE5,
+ 0xFF04, 0x00A2, 0x00A3, 0xFF05, 0xFF03, 0xFF06, 0xFF0A, 0xFF20,
+ 0x00A7, 0x2606, 0x2605, 0x25CB, 0x25CF, 0x25CE, 0x25C7,
+};
+unsigned short euc_to_utf8_A2[] = {
+ 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
+ 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
+ 0x222A, 0x2229, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2227, 0x2228, 0x00AC, 0x21D2, 0x21D4, 0x2200,
+ 0x2203, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2220, 0x22A5, 0x2312, 0x2202,
+ 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
+ 0x2235, 0x222B, 0x222C, 0, 0, 0, 0, 0,
+ 0, 0, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
+ 0x2021, 0x00B6, 0, 0, 0, 0, 0x25EF,
+};
+unsigned short euc_to_utf8_A3[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17,
+ 0xFF18, 0xFF19, 0, 0, 0, 0, 0, 0,
+ 0, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27,
+ 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F,
+ 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37,
+ 0xFF38, 0xFF39, 0xFF3A, 0, 0, 0, 0, 0,
+ 0, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
+ 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
+ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
+ 0xFF58, 0xFF59, 0xFF5A, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_A4[] = {
+ 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047,
+ 0x3048, 0x3049, 0x304A, 0x304B, 0x304C, 0x304D, 0x304E, 0x304F,
+ 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057,
+ 0x3058, 0x3059, 0x305A, 0x305B, 0x305C, 0x305D, 0x305E, 0x305F,
+ 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067,
+ 0x3068, 0x3069, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F,
+ 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077,
+ 0x3078, 0x3079, 0x307A, 0x307B, 0x307C, 0x307D, 0x307E, 0x307F,
+ 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087,
+ 0x3088, 0x3089, 0x308A, 0x308B, 0x308C, 0x308D, 0x308E, 0x308F,
+ 0x3090, 0x3091, 0x3092, 0x3093, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_A5[] = {
+ 0x30A1, 0x30A2, 0x30A3, 0x30A4, 0x30A5, 0x30A6, 0x30A7,
+ 0x30A8, 0x30A9, 0x30AA, 0x30AB, 0x30AC, 0x30AD, 0x30AE, 0x30AF,
+ 0x30B0, 0x30B1, 0x30B2, 0x30B3, 0x30B4, 0x30B5, 0x30B6, 0x30B7,
+ 0x30B8, 0x30B9, 0x30BA, 0x30BB, 0x30BC, 0x30BD, 0x30BE, 0x30BF,
+ 0x30C0, 0x30C1, 0x30C2, 0x30C3, 0x30C4, 0x30C5, 0x30C6, 0x30C7,
+ 0x30C8, 0x30C9, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF,
+ 0x30D0, 0x30D1, 0x30D2, 0x30D3, 0x30D4, 0x30D5, 0x30D6, 0x30D7,
+ 0x30D8, 0x30D9, 0x30DA, 0x30DB, 0x30DC, 0x30DD, 0x30DE, 0x30DF,
+ 0x30E0, 0x30E1, 0x30E2, 0x30E3, 0x30E4, 0x30E5, 0x30E6, 0x30E7,
+ 0x30E8, 0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EE, 0x30EF,
+ 0x30F0, 0x30F1, 0x30F2, 0x30F3, 0x30F4, 0x30F5, 0x30F6, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_A6[] = {
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8,
+ 0x03A9, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
+ 0x03C9, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_A7[] = {
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401,
+ 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D,
+ 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425,
+ 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D,
+ 0x042E, 0x042F, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451,
+ 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D,
+ 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445,
+ 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D,
+ 0x044E, 0x044F, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_A8[] = {
+ 0x2500, 0x2502, 0x250C, 0x2510, 0x2518, 0x2514, 0x251C,
+ 0x252C, 0x2524, 0x2534, 0x253C, 0x2501, 0x2503, 0x250F, 0x2513,
+ 0x251B, 0x2517, 0x2523, 0x2533, 0x252B, 0x253B, 0x254B, 0x2520,
+ 0x252F, 0x2528, 0x2537, 0x253F, 0x251D, 0x2530, 0x2525, 0x2538,
+ 0x2542, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_A9[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
+ 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
+ 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2474,
+ 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247A, 0x247B, 0x247C,
+ 0x247D, 0x247E, 0x247F, 0x2480, 0x2481, 0x2482, 0x2483, 0x2484,
+ 0x2485, 0x2486, 0x2487, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2776, 0x2777, 0x2778,
+ 0x2779, 0x277A, 0x277B, 0x277C, 0x277D, 0x277E, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2488, 0x2489, 0x248A, 0x248B, 0x248C, 0x248D,
+ 0x248E, 0x248F, 0x2490, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_AA[] = {
+ 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166,
+ 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2170, 0x2171, 0x2172,
+ 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A,
+ 0x217B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x249C, 0x249D, 0x249E,
+ 0x249F, 0x24A0, 0x24A1, 0x24A2, 0x24A3, 0x24A4, 0x24A5, 0x24A6,
+ 0x24A7, 0x24A8, 0x24A9, 0x24AA, 0x24AB, 0x24AC, 0x24AD, 0x24AE,
+ 0x24AF, 0x24B0, 0x24B1, 0x24B2, 0x24B3, 0x24B4, 0x24B5, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_AB[] = {
+ 0x339C, 0x339F, 0x339D, 0x33A0, 0x33A4, 0, 0x33A1,
+ 0x33A5, 0x339E, 0x33A2, 0x338E, 0, 0x338F, 0x33C4, 0x3396,
+ 0x3397, 0x2113, 0x3398, 0x33B3, 0x33B2, 0x33B1, 0x33B0, 0x2109,
+ 0x33D4, 0x33CB, 0x3390, 0x3385, 0x3386, 0x3387, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2116, 0x33CD, 0x2121, 0,
+};
+unsigned short euc_to_utf8_AC[] = {
+ 0x2664, 0x2667, 0x2661, 0x2662, 0x2660, 0x2663, 0x2665,
+ 0x2666, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x3020, 0x260E, 0x3004,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x261E, 0x261C, 0x261D, 0x261F, 0x21C6, 0x21C4, 0x21C5,
+ 0, 0x21E8, 0x21E6, 0x21E7, 0x21E9, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_AD[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
+ 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
+ 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0x2160, 0x2161, 0x2162,
+ 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0,
+ 0x3349, 0x3314, 0x3322, 0x334D, 0x3318, 0x3327, 0x3303, 0x3336,
+ 0x3351, 0x3357, 0x330D, 0x3326, 0x3323, 0x332B, 0x334A, 0x333B,
+ 0x339C, 0x339D, 0x339E, 0x338E, 0x338F, 0x33C4, 0x33A1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x337B,
+ 0x301D, 0x301F, 0x2116, 0x33CD, 0x2121, 0x32A4, 0x32A5, 0x32A6,
+ 0x32A7, 0x32A8, 0x3231, 0x3232, 0x3239, 0x337E, 0x337D, 0x337C,
+ 0x2252, 0x2261, 0x222B, 0x222E, 0x2211, 0x221A, 0x22A5, 0x2220,
+ 0x221F, 0x22BF, 0x2235, 0x2229, 0x222A, 0, 0x3299,
+};
+unsigned short euc_to_utf8_AE[] = {
+ 0x3349, 0x3322, 0x334D, 0x3314, 0x3316, 0x3305, 0x3333,
+ 0x334E, 0x3303, 0x3336, 0x3318, 0x3315, 0x3327, 0x3351, 0x334A,
+ 0x3339, 0x3357, 0x330D, 0x3342, 0x3323, 0x3326, 0x333B, 0x332B,
+ 0, 0, 0, 0, 0, 0, 0, 0x3300,
+ 0x331E, 0x332A, 0x3331, 0x3347, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x337E,
+ 0x337D, 0x337C, 0x337B, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x337F, 0, 0,
+};
+unsigned short euc_to_utf8_AF[] = {
+ 0x222E, 0x221F, 0x22BF, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x301D, 0x301F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3094, 0, 0x30F7, 0x30F8, 0x30F9, 0x30FA, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_B0[] = {
+ 0x4E9C, 0x5516, 0x5A03, 0x963F, 0x54C0, 0x611B, 0x6328,
+ 0x59F6, 0x9022, 0x8475, 0x831C, 0x7A50, 0x60AA, 0x63E1, 0x6E25,
+ 0x65ED, 0x8466, 0x82A6, 0x9BF5, 0x6893, 0x5727, 0x65A1, 0x6271,
+ 0x5B9B, 0x59D0, 0x867B, 0x98F4, 0x7D62, 0x7DBE, 0x9B8E, 0x6216,
+ 0x7C9F, 0x88B7, 0x5B89, 0x5EB5, 0x6309, 0x6697, 0x6848, 0x95C7,
+ 0x978D, 0x674F, 0x4EE5, 0x4F0A, 0x4F4D, 0x4F9D, 0x5049, 0x56F2,
+ 0x5937, 0x59D4, 0x5A01, 0x5C09, 0x60DF, 0x610F, 0x6170, 0x6613,
+ 0x6905, 0x70BA, 0x754F, 0x7570, 0x79FB, 0x7DAD, 0x7DEF, 0x80C3,
+ 0x840E, 0x8863, 0x8B02, 0x9055, 0x907A, 0x533B, 0x4E95, 0x4EA5,
+ 0x57DF, 0x80B2, 0x90C1, 0x78EF, 0x4E00, 0x58F1, 0x6EA2, 0x9038,
+ 0x7A32, 0x8328, 0x828B, 0x9C2F, 0x5141, 0x5370, 0x54BD, 0x54E1,
+ 0x56E0, 0x59FB, 0x5F15, 0x98F2, 0x6DEB, 0x80E4, 0x852D,
+};
+unsigned short euc_to_utf8_B1[] = {
+ 0x9662, 0x9670, 0x96A0, 0x97FB, 0x540B, 0x53F3, 0x5B87,
+ 0x70CF, 0x7FBD, 0x8FC2, 0x96E8, 0x536F, 0x9D5C, 0x7ABA, 0x4E11,
+ 0x7893, 0x81FC, 0x6E26, 0x5618, 0x5504, 0x6B1D, 0x851A, 0x9C3B,
+ 0x59E5, 0x53A9, 0x6D66, 0x74DC, 0x958F, 0x5642, 0x4E91, 0x904B,
+ 0x96F2, 0x834F, 0x990C, 0x53E1, 0x55B6, 0x5B30, 0x5F71, 0x6620,
+ 0x66F3, 0x6804, 0x6C38, 0x6CF3, 0x6D29, 0x745B, 0x76C8, 0x7A4E,
+ 0x9834, 0x82F1, 0x885B, 0x8A60, 0x92ED, 0x6DB2, 0x75AB, 0x76CA,
+ 0x99C5, 0x60A6, 0x8B01, 0x8D8A, 0x95B2, 0x698E, 0x53AD, 0x5186,
+ 0x5712, 0x5830, 0x5944, 0x5BB4, 0x5EF6, 0x6028, 0x63A9, 0x63F4,
+ 0x6CBF, 0x6F14, 0x708E, 0x7114, 0x7159, 0x71D5, 0x733F, 0x7E01,
+ 0x8276, 0x82D1, 0x8597, 0x9060, 0x925B, 0x9D1B, 0x5869, 0x65BC,
+ 0x6C5A, 0x7525, 0x51F9, 0x592E, 0x5965, 0x5F80, 0x5FDC,
+};
+unsigned short euc_to_utf8_B2[] = {
+ 0x62BC, 0x65FA, 0x6A2A, 0x6B27, 0x6BB4, 0x738B, 0x7FC1,
+ 0x8956, 0x9D2C, 0x9D0E, 0x9EC4, 0x5CA1, 0x6C96, 0x837B, 0x5104,
+ 0x5C4B, 0x61B6, 0x81C6, 0x6876, 0x7261, 0x4E59, 0x4FFA, 0x5378,
+ 0x6069, 0x6E29, 0x7A4F, 0x97F3, 0x4E0B, 0x5316, 0x4EEE, 0x4F55,
+ 0x4F3D, 0x4FA1, 0x4F73, 0x52A0, 0x53EF, 0x5609, 0x590F, 0x5AC1,
+ 0x5BB6, 0x5BE1, 0x79D1, 0x6687, 0x679C, 0x67B6, 0x6B4C, 0x6CB3,
+ 0x706B, 0x73C2, 0x798D, 0x79BE, 0x7A3C, 0x7B87, 0x82B1, 0x82DB,
+ 0x8304, 0x8377, 0x83EF, 0x83D3, 0x8766, 0x8AB2, 0x5629, 0x8CA8,
+ 0x8FE6, 0x904E, 0x971E, 0x868A, 0x4FC4, 0x5CE8, 0x6211, 0x7259,
+ 0x753B, 0x81E5, 0x82BD, 0x86FE, 0x8CC0, 0x96C5, 0x9913, 0x99D5,
+ 0x4ECB, 0x4F1A, 0x89E3, 0x56DE, 0x584A, 0x58CA, 0x5EFB, 0x5FEB,
+ 0x602A, 0x6094, 0x6062, 0x61D0, 0x6212, 0x62D0, 0x6539,
+};
+unsigned short euc_to_utf8_B3[] = {
+ 0x9B41, 0x6666, 0x68B0, 0x6D77, 0x7070, 0x754C, 0x7686,
+ 0x7D75, 0x82A5, 0x87F9, 0x958B, 0x968E, 0x8C9D, 0x51F1, 0x52BE,
+ 0x5916, 0x54B3, 0x5BB3, 0x5D16, 0x6168, 0x6982, 0x6DAF, 0x788D,
+ 0x84CB, 0x8857, 0x8A72, 0x93A7, 0x9AB8, 0x6D6C, 0x99A8, 0x86D9,
+ 0x57A3, 0x67FF, 0x86CE, 0x920E, 0x5283, 0x5687, 0x5404, 0x5ED3,
+ 0x62E1, 0x64B9, 0x683C, 0x6838, 0x6BBB, 0x7372, 0x78BA, 0x7A6B,
+ 0x899A, 0x89D2, 0x8D6B, 0x8F03, 0x90ED, 0x95A3, 0x9694, 0x9769,
+ 0x5B66, 0x5CB3, 0x697D, 0x984D, 0x984E, 0x639B, 0x7B20, 0x6A2B,
+ 0x6A7F, 0x68B6, 0x9C0D, 0x6F5F, 0x5272, 0x559D, 0x6070, 0x62EC,
+ 0x6D3B, 0x6E07, 0x6ED1, 0x845B, 0x8910, 0x8F44, 0x4E14, 0x9C39,
+ 0x53F6, 0x691B, 0x6A3A, 0x9784, 0x682A, 0x515C, 0x7AC3, 0x84B2,
+ 0x91DC, 0x938C, 0x565B, 0x9D28, 0x6822, 0x8305, 0x8431,
+};
+unsigned short euc_to_utf8_B4[] = {
+ 0x7CA5, 0x5208, 0x82C5, 0x74E6, 0x4E7E, 0x4F83, 0x51A0,
+ 0x5BD2, 0x520A, 0x52D8, 0x52E7, 0x5DFB, 0x559A, 0x582A, 0x59E6,
+ 0x5B8C, 0x5B98, 0x5BDB, 0x5E72, 0x5E79, 0x60A3, 0x611F, 0x6163,
+ 0x61BE, 0x63DB, 0x6562, 0x67D1, 0x6853, 0x68FA, 0x6B3E, 0x6B53,
+ 0x6C57, 0x6F22, 0x6F97, 0x6F45, 0x74B0, 0x7518, 0x76E3, 0x770B,
+ 0x7AFF, 0x7BA1, 0x7C21, 0x7DE9, 0x7F36, 0x7FF0, 0x809D, 0x8266,
+ 0x839E, 0x89B3, 0x8ACC, 0x8CAB, 0x9084, 0x9451, 0x9593, 0x9591,
+ 0x95A2, 0x9665, 0x97D3, 0x9928, 0x8218, 0x4E38, 0x542B, 0x5CB8,
+ 0x5DCC, 0x73A9, 0x764C, 0x773C, 0x5CA9, 0x7FEB, 0x8D0B, 0x96C1,
+ 0x9811, 0x9854, 0x9858, 0x4F01, 0x4F0E, 0x5371, 0x559C, 0x5668,
+ 0x57FA, 0x5947, 0x5B09, 0x5BC4, 0x5C90, 0x5E0C, 0x5E7E, 0x5FCC,
+ 0x63EE, 0x673A, 0x65D7, 0x65E2, 0x671F, 0x68CB, 0x68C4,
+};
+unsigned short euc_to_utf8_B5[] = {
+ 0x6A5F, 0x5E30, 0x6BC5, 0x6C17, 0x6C7D, 0x757F, 0x7948,
+ 0x5B63, 0x7A00, 0x7D00, 0x5FBD, 0x898F, 0x8A18, 0x8CB4, 0x8D77,
+ 0x8ECC, 0x8F1D, 0x98E2, 0x9A0E, 0x9B3C, 0x4E80, 0x507D, 0x5100,
+ 0x5993, 0x5B9C, 0x622F, 0x6280, 0x64EC, 0x6B3A, 0x72A0, 0x7591,
+ 0x7947, 0x7FA9, 0x87FB, 0x8ABC, 0x8B70, 0x63AC, 0x83CA, 0x97A0,
+ 0x5409, 0x5403, 0x55AB, 0x6854, 0x6A58, 0x8A70, 0x7827, 0x6775,
+ 0x9ECD, 0x5374, 0x5BA2, 0x811A, 0x8650, 0x9006, 0x4E18, 0x4E45,
+ 0x4EC7, 0x4F11, 0x53CA, 0x5438, 0x5BAE, 0x5F13, 0x6025, 0x6551,
+ 0x673D, 0x6C42, 0x6C72, 0x6CE3, 0x7078, 0x7403, 0x7A76, 0x7AAE,
+ 0x7B08, 0x7D1A, 0x7CFE, 0x7D66, 0x65E7, 0x725B, 0x53BB, 0x5C45,
+ 0x5DE8, 0x62D2, 0x62E0, 0x6319, 0x6E20, 0x865A, 0x8A31, 0x8DDD,
+ 0x92F8, 0x6F01, 0x79A6, 0x9B5A, 0x4EA8, 0x4EAB, 0x4EAC,
+};
+unsigned short euc_to_utf8_B6[] = {
+ 0x4F9B, 0x4FA0, 0x50D1, 0x5147, 0x7AF6, 0x5171, 0x51F6,
+ 0x5354, 0x5321, 0x537F, 0x53EB, 0x55AC, 0x5883, 0x5CE1, 0x5F37,
+ 0x5F4A, 0x602F, 0x6050, 0x606D, 0x631F, 0x6559, 0x6A4B, 0x6CC1,
+ 0x72C2, 0x72ED, 0x77EF, 0x80F8, 0x8105, 0x8208, 0x854E, 0x90F7,
+ 0x93E1, 0x97FF, 0x9957, 0x9A5A, 0x4EF0, 0x51DD, 0x5C2D, 0x6681,
+ 0x696D, 0x5C40, 0x66F2, 0x6975, 0x7389, 0x6850, 0x7C81, 0x50C5,
+ 0x52E4, 0x5747, 0x5DFE, 0x9326, 0x65A4, 0x6B23, 0x6B3D, 0x7434,
+ 0x7981, 0x79BD, 0x7B4B, 0x7DCA, 0x82B9, 0x83CC, 0x887F, 0x895F,
+ 0x8B39, 0x8FD1, 0x91D1, 0x541F, 0x9280, 0x4E5D, 0x5036, 0x53E5,
+ 0x533A, 0x72D7, 0x7396, 0x77E9, 0x82E6, 0x8EAF, 0x99C6, 0x99C8,
+ 0x99D2, 0x5177, 0x611A, 0x865E, 0x55B0, 0x7A7A, 0x5076, 0x5BD3,
+ 0x9047, 0x9685, 0x4E32, 0x6ADB, 0x91E7, 0x5C51, 0x5C48,
+};
+unsigned short euc_to_utf8_B7[] = {
+ 0x6398, 0x7A9F, 0x6C93, 0x9774, 0x8F61, 0x7AAA, 0x718A,
+ 0x9688, 0x7C82, 0x6817, 0x7E70, 0x6851, 0x936C, 0x52F2, 0x541B,
+ 0x85AB, 0x8A13, 0x7FA4, 0x8ECD, 0x90E1, 0x5366, 0x8888, 0x7941,
+ 0x4FC2, 0x50BE, 0x5211, 0x5144, 0x5553, 0x572D, 0x73EA, 0x578B,
+ 0x5951, 0x5F62, 0x5F84, 0x6075, 0x6176, 0x6167, 0x61A9, 0x63B2,
+ 0x643A, 0x656C, 0x666F, 0x6842, 0x6E13, 0x7566, 0x7A3D, 0x7CFB,
+ 0x7D4C, 0x7D99, 0x7E4B, 0x7F6B, 0x830E, 0x834A, 0x86CD, 0x8A08,
+ 0x8A63, 0x8B66, 0x8EFD, 0x981A, 0x9D8F, 0x82B8, 0x8FCE, 0x9BE8,
+ 0x5287, 0x621F, 0x6483, 0x6FC0, 0x9699, 0x6841, 0x5091, 0x6B20,
+ 0x6C7A, 0x6F54, 0x7A74, 0x7D50, 0x8840, 0x8A23, 0x6708, 0x4EF6,
+ 0x5039, 0x5026, 0x5065, 0x517C, 0x5238, 0x5263, 0x55A7, 0x570F,
+ 0x5805, 0x5ACC, 0x5EFA, 0x61B2, 0x61F8, 0x62F3, 0x6372,
+};
+unsigned short euc_to_utf8_B8[] = {
+ 0x691C, 0x6A29, 0x727D, 0x72AC, 0x732E, 0x7814, 0x786F,
+ 0x7D79, 0x770C, 0x80A9, 0x898B, 0x8B19, 0x8CE2, 0x8ED2, 0x9063,
+ 0x9375, 0x967A, 0x9855, 0x9A13, 0x9E78, 0x5143, 0x539F, 0x53B3,
+ 0x5E7B, 0x5F26, 0x6E1B, 0x6E90, 0x7384, 0x73FE, 0x7D43, 0x8237,
+ 0x8A00, 0x8AFA, 0x9650, 0x4E4E, 0x500B, 0x53E4, 0x547C, 0x56FA,
+ 0x59D1, 0x5B64, 0x5DF1, 0x5EAB, 0x5F27, 0x6238, 0x6545, 0x67AF,
+ 0x6E56, 0x72D0, 0x7CCA, 0x88B4, 0x80A1, 0x80E1, 0x83F0, 0x864E,
+ 0x8A87, 0x8DE8, 0x9237, 0x96C7, 0x9867, 0x9F13, 0x4E94, 0x4E92,
+ 0x4F0D, 0x5348, 0x5449, 0x543E, 0x5A2F, 0x5F8C, 0x5FA1, 0x609F,
+ 0x68A7, 0x6A8E, 0x745A, 0x7881, 0x8A9E, 0x8AA4, 0x8B77, 0x9190,
+ 0x4E5E, 0x9BC9, 0x4EA4, 0x4F7C, 0x4FAF, 0x5019, 0x5016, 0x5149,
+ 0x516C, 0x529F, 0x52B9, 0x52FE, 0x539A, 0x53E3, 0x5411,
+};
+unsigned short euc_to_utf8_B9[] = {
+ 0x540E, 0x5589, 0x5751, 0x57A2, 0x597D, 0x5B54, 0x5B5D,
+ 0x5B8F, 0x5DE5, 0x5DE7, 0x5DF7, 0x5E78, 0x5E83, 0x5E9A, 0x5EB7,
+ 0x5F18, 0x6052, 0x614C, 0x6297, 0x62D8, 0x63A7, 0x653B, 0x6602,
+ 0x6643, 0x66F4, 0x676D, 0x6821, 0x6897, 0x69CB, 0x6C5F, 0x6D2A,
+ 0x6D69, 0x6E2F, 0x6E9D, 0x7532, 0x7687, 0x786C, 0x7A3F, 0x7CE0,
+ 0x7D05, 0x7D18, 0x7D5E, 0x7DB1, 0x8015, 0x8003, 0x80AF, 0x80B1,
+ 0x8154, 0x818F, 0x822A, 0x8352, 0x884C, 0x8861, 0x8B1B, 0x8CA2,
+ 0x8CFC, 0x90CA, 0x9175, 0x9271, 0x783F, 0x92FC, 0x95A4, 0x964D,
+ 0x9805, 0x9999, 0x9AD8, 0x9D3B, 0x525B, 0x52AB, 0x53F7, 0x5408,
+ 0x58D5, 0x62F7, 0x6FE0, 0x8C6A, 0x8F5F, 0x9EB9, 0x514B, 0x523B,
+ 0x544A, 0x56FD, 0x7A40, 0x9177, 0x9D60, 0x9ED2, 0x7344, 0x6F09,
+ 0x8170, 0x7511, 0x5FFD, 0x60DA, 0x9AA8, 0x72DB, 0x8FBC,
+};
+unsigned short euc_to_utf8_BA[] = {
+ 0x6B64, 0x9803, 0x4ECA, 0x56F0, 0x5764, 0x58BE, 0x5A5A,
+ 0x6068, 0x61C7, 0x660F, 0x6606, 0x6839, 0x68B1, 0x6DF7, 0x75D5,
+ 0x7D3A, 0x826E, 0x9B42, 0x4E9B, 0x4F50, 0x53C9, 0x5506, 0x5D6F,
+ 0x5DE6, 0x5DEE, 0x67FB, 0x6C99, 0x7473, 0x7802, 0x8A50, 0x9396,
+ 0x88DF, 0x5750, 0x5EA7, 0x632B, 0x50B5, 0x50AC, 0x518D, 0x6700,
+ 0x54C9, 0x585E, 0x59BB, 0x5BB0, 0x5F69, 0x624D, 0x63A1, 0x683D,
+ 0x6B73, 0x6E08, 0x707D, 0x91C7, 0x7280, 0x7815, 0x7826, 0x796D,
+ 0x658E, 0x7D30, 0x83DC, 0x88C1, 0x8F09, 0x969B, 0x5264, 0x5728,
+ 0x6750, 0x7F6A, 0x8CA1, 0x51B4, 0x5742, 0x962A, 0x583A, 0x698A,
+ 0x80B4, 0x54B2, 0x5D0E, 0x57FC, 0x7895, 0x9DFA, 0x4F5C, 0x524A,
+ 0x548B, 0x643E, 0x6628, 0x6714, 0x67F5, 0x7A84, 0x7B56, 0x7D22,
+ 0x932F, 0x685C, 0x9BAD, 0x7B39, 0x5319, 0x518A, 0x5237,
+};
+unsigned short euc_to_utf8_BB[] = {
+ 0x5BDF, 0x62F6, 0x64AE, 0x64E6, 0x672D, 0x6BBA, 0x85A9,
+ 0x96D1, 0x7690, 0x9BD6, 0x634C, 0x9306, 0x9BAB, 0x76BF, 0x6652,
+ 0x4E09, 0x5098, 0x53C2, 0x5C71, 0x60E8, 0x6492, 0x6563, 0x685F,
+ 0x71E6, 0x73CA, 0x7523, 0x7B97, 0x7E82, 0x8695, 0x8B83, 0x8CDB,
+ 0x9178, 0x9910, 0x65AC, 0x66AB, 0x6B8B, 0x4ED5, 0x4ED4, 0x4F3A,
+ 0x4F7F, 0x523A, 0x53F8, 0x53F2, 0x55E3, 0x56DB, 0x58EB, 0x59CB,
+ 0x59C9, 0x59FF, 0x5B50, 0x5C4D, 0x5E02, 0x5E2B, 0x5FD7, 0x601D,
+ 0x6307, 0x652F, 0x5B5C, 0x65AF, 0x65BD, 0x65E8, 0x679D, 0x6B62,
+ 0x6B7B, 0x6C0F, 0x7345, 0x7949, 0x79C1, 0x7CF8, 0x7D19, 0x7D2B,
+ 0x80A2, 0x8102, 0x81F3, 0x8996, 0x8A5E, 0x8A69, 0x8A66, 0x8A8C,
+ 0x8AEE, 0x8CC7, 0x8CDC, 0x96CC, 0x98FC, 0x6B6F, 0x4E8B, 0x4F3C,
+ 0x4F8D, 0x5150, 0x5B57, 0x5BFA, 0x6148, 0x6301, 0x6642,
+};
+unsigned short euc_to_utf8_BC[] = {
+ 0x6B21, 0x6ECB, 0x6CBB, 0x723E, 0x74BD, 0x75D4, 0x78C1,
+ 0x793A, 0x800C, 0x8033, 0x81EA, 0x8494, 0x8F9E, 0x6C50, 0x9E7F,
+ 0x5F0F, 0x8B58, 0x9D2B, 0x7AFA, 0x8EF8, 0x5B8D, 0x96EB, 0x4E03,
+ 0x53F1, 0x57F7, 0x5931, 0x5AC9, 0x5BA4, 0x6089, 0x6E7F, 0x6F06,
+ 0x75BE, 0x8CEA, 0x5B9F, 0x8500, 0x7BE0, 0x5072, 0x67F4, 0x829D,
+ 0x5C61, 0x854A, 0x7E1E, 0x820E, 0x5199, 0x5C04, 0x6368, 0x8D66,
+ 0x659C, 0x716E, 0x793E, 0x7D17, 0x8005, 0x8B1D, 0x8ECA, 0x906E,
+ 0x86C7, 0x90AA, 0x501F, 0x52FA, 0x5C3A, 0x6753, 0x707C, 0x7235,
+ 0x914C, 0x91C8, 0x932B, 0x82E5, 0x5BC2, 0x5F31, 0x60F9, 0x4E3B,
+ 0x53D6, 0x5B88, 0x624B, 0x6731, 0x6B8A, 0x72E9, 0x73E0, 0x7A2E,
+ 0x816B, 0x8DA3, 0x9152, 0x9996, 0x5112, 0x53D7, 0x546A, 0x5BFF,
+ 0x6388, 0x6A39, 0x7DAC, 0x9700, 0x56DA, 0x53CE, 0x5468,
+};
+unsigned short euc_to_utf8_BD[] = {
+ 0x5B97, 0x5C31, 0x5DDE, 0x4FEE, 0x6101, 0x62FE, 0x6D32,
+ 0x79C0, 0x79CB, 0x7D42, 0x7E4D, 0x7FD2, 0x81ED, 0x821F, 0x8490,
+ 0x8846, 0x8972, 0x8B90, 0x8E74, 0x8F2F, 0x9031, 0x914B, 0x916C,
+ 0x96C6, 0x919C, 0x4EC0, 0x4F4F, 0x5145, 0x5341, 0x5F93, 0x620E,
+ 0x67D4, 0x6C41, 0x6E0B, 0x7363, 0x7E26, 0x91CD, 0x9283, 0x53D4,
+ 0x5919, 0x5BBF, 0x6DD1, 0x795D, 0x7E2E, 0x7C9B, 0x587E, 0x719F,
+ 0x51FA, 0x8853, 0x8FF0, 0x4FCA, 0x5CFB, 0x6625, 0x77AC, 0x7AE3,
+ 0x821C, 0x99FF, 0x51C6, 0x5FAA, 0x65EC, 0x696F, 0x6B89, 0x6DF3,
+ 0x6E96, 0x6F64, 0x76FE, 0x7D14, 0x5DE1, 0x9075, 0x9187, 0x9806,
+ 0x51E6, 0x521D, 0x6240, 0x6691, 0x66D9, 0x6E1A, 0x5EB6, 0x7DD2,
+ 0x7F72, 0x66F8, 0x85AF, 0x85F7, 0x8AF8, 0x52A9, 0x53D9, 0x5973,
+ 0x5E8F, 0x5F90, 0x6055, 0x92E4, 0x9664, 0x50B7, 0x511F,
+};
+unsigned short euc_to_utf8_BE[] = {
+ 0x52DD, 0x5320, 0x5347, 0x53EC, 0x54E8, 0x5546, 0x5531,
+ 0x5617, 0x5968, 0x59BE, 0x5A3C, 0x5BB5, 0x5C06, 0x5C0F, 0x5C11,
+ 0x5C1A, 0x5E84, 0x5E8A, 0x5EE0, 0x5F70, 0x627F, 0x6284, 0x62DB,
+ 0x638C, 0x6377, 0x6607, 0x660C, 0x662D, 0x6676, 0x677E, 0x68A2,
+ 0x6A1F, 0x6A35, 0x6CBC, 0x6D88, 0x6E09, 0x6E58, 0x713C, 0x7126,
+ 0x7167, 0x75C7, 0x7701, 0x785D, 0x7901, 0x7965, 0x79F0, 0x7AE0,
+ 0x7B11, 0x7CA7, 0x7D39, 0x8096, 0x83D6, 0x848B, 0x8549, 0x885D,
+ 0x88F3, 0x8A1F, 0x8A3C, 0x8A54, 0x8A73, 0x8C61, 0x8CDE, 0x91A4,
+ 0x9266, 0x937E, 0x9418, 0x969C, 0x9798, 0x4E0A, 0x4E08, 0x4E1E,
+ 0x4E57, 0x5197, 0x5270, 0x57CE, 0x5834, 0x58CC, 0x5B22, 0x5E38,
+ 0x60C5, 0x64FE, 0x6761, 0x6756, 0x6D44, 0x72B6, 0x7573, 0x7A63,
+ 0x84B8, 0x8B72, 0x91B8, 0x9320, 0x5631, 0x57F4, 0x98FE,
+};
+unsigned short euc_to_utf8_BF[] = {
+ 0x62ED, 0x690D, 0x6B96, 0x71ED, 0x7E54, 0x8077, 0x8272,
+ 0x89E6, 0x98DF, 0x8755, 0x8FB1, 0x5C3B, 0x4F38, 0x4FE1, 0x4FB5,
+ 0x5507, 0x5A20, 0x5BDD, 0x5BE9, 0x5FC3, 0x614E, 0x632F, 0x65B0,
+ 0x664B, 0x68EE, 0x699B, 0x6D78, 0x6DF1, 0x7533, 0x75B9, 0x771F,
+ 0x795E, 0x79E6, 0x7D33, 0x81E3, 0x82AF, 0x85AA, 0x89AA, 0x8A3A,
+ 0x8EAB, 0x8F9B, 0x9032, 0x91DD, 0x9707, 0x4EBA, 0x4EC1, 0x5203,
+ 0x5875, 0x58EC, 0x5C0B, 0x751A, 0x5C3D, 0x814E, 0x8A0A, 0x8FC5,
+ 0x9663, 0x976D, 0x7B25, 0x8ACF, 0x9808, 0x9162, 0x56F3, 0x53A8,
+ 0x9017, 0x5439, 0x5782, 0x5E25, 0x63A8, 0x6C34, 0x708A, 0x7761,
+ 0x7C8B, 0x7FE0, 0x8870, 0x9042, 0x9154, 0x9310, 0x9318, 0x968F,
+ 0x745E, 0x9AC4, 0x5D07, 0x5D69, 0x6570, 0x67A2, 0x8DA8, 0x96DB,
+ 0x636E, 0x6749, 0x6919, 0x83C5, 0x9817, 0x96C0, 0x88FE,
+};
+unsigned short euc_to_utf8_C0[] = {
+ 0x6F84, 0x647A, 0x5BF8, 0x4E16, 0x702C, 0x755D, 0x662F,
+ 0x51C4, 0x5236, 0x52E2, 0x59D3, 0x5F81, 0x6027, 0x6210, 0x653F,
+ 0x6574, 0x661F, 0x6674, 0x68F2, 0x6816, 0x6B63, 0x6E05, 0x7272,
+ 0x751F, 0x76DB, 0x7CBE, 0x8056, 0x58F0, 0x88FD, 0x897F, 0x8AA0,
+ 0x8A93, 0x8ACB, 0x901D, 0x9192, 0x9752, 0x9759, 0x6589, 0x7A0E,
+ 0x8106, 0x96BB, 0x5E2D, 0x60DC, 0x621A, 0x65A5, 0x6614, 0x6790,
+ 0x77F3, 0x7A4D, 0x7C4D, 0x7E3E, 0x810A, 0x8CAC, 0x8D64, 0x8DE1,
+ 0x8E5F, 0x78A9, 0x5207, 0x62D9, 0x63A5, 0x6442, 0x6298, 0x8A2D,
+ 0x7A83, 0x7BC0, 0x8AAC, 0x96EA, 0x7D76, 0x820C, 0x8749, 0x4ED9,
+ 0x5148, 0x5343, 0x5360, 0x5BA3, 0x5C02, 0x5C16, 0x5DDD, 0x6226,
+ 0x6247, 0x64B0, 0x6813, 0x6834, 0x6CC9, 0x6D45, 0x6D17, 0x67D3,
+ 0x6F5C, 0x714E, 0x717D, 0x65CB, 0x7A7F, 0x7BAD, 0x7DDA,
+};
+unsigned short euc_to_utf8_C1[] = {
+ 0x7E4A, 0x7FA8, 0x817A, 0x821B, 0x8239, 0x85A6, 0x8A6E,
+ 0x8CCE, 0x8DF5, 0x9078, 0x9077, 0x92AD, 0x9291, 0x9583, 0x9BAE,
+ 0x524D, 0x5584, 0x6F38, 0x7136, 0x5168, 0x7985, 0x7E55, 0x81B3,
+ 0x7CCE, 0x564C, 0x5851, 0x5CA8, 0x63AA, 0x66FE, 0x66FD, 0x695A,
+ 0x72D9, 0x758F, 0x758E, 0x790E, 0x7956, 0x79DF, 0x7C97, 0x7D20,
+ 0x7D44, 0x8607, 0x8A34, 0x963B, 0x9061, 0x9F20, 0x50E7, 0x5275,
+ 0x53CC, 0x53E2, 0x5009, 0x55AA, 0x58EE, 0x594F, 0x723D, 0x5B8B,
+ 0x5C64, 0x531D, 0x60E3, 0x60F3, 0x635C, 0x6383, 0x633F, 0x63BB,
+ 0x64CD, 0x65E9, 0x66F9, 0x5DE3, 0x69CD, 0x69FD, 0x6F15, 0x71E5,
+ 0x4E89, 0x75E9, 0x76F8, 0x7A93, 0x7CDF, 0x7DCF, 0x7D9C, 0x8061,
+ 0x8349, 0x8358, 0x846C, 0x84BC, 0x85FB, 0x88C5, 0x8D70, 0x9001,
+ 0x906D, 0x9397, 0x971C, 0x9A12, 0x50CF, 0x5897, 0x618E,
+};
+unsigned short euc_to_utf8_C2[] = {
+ 0x81D3, 0x8535, 0x8D08, 0x9020, 0x4FC3, 0x5074, 0x5247,
+ 0x5373, 0x606F, 0x6349, 0x675F, 0x6E2C, 0x8DB3, 0x901F, 0x4FD7,
+ 0x5C5E, 0x8CCA, 0x65CF, 0x7D9A, 0x5352, 0x8896, 0x5176, 0x63C3,
+ 0x5B58, 0x5B6B, 0x5C0A, 0x640D, 0x6751, 0x905C, 0x4ED6, 0x591A,
+ 0x592A, 0x6C70, 0x8A51, 0x553E, 0x5815, 0x59A5, 0x60F0, 0x6253,
+ 0x67C1, 0x8235, 0x6955, 0x9640, 0x99C4, 0x9A28, 0x4F53, 0x5806,
+ 0x5BFE, 0x8010, 0x5CB1, 0x5E2F, 0x5F85, 0x6020, 0x614B, 0x6234,
+ 0x66FF, 0x6CF0, 0x6EDE, 0x80CE, 0x817F, 0x82D4, 0x888B, 0x8CB8,
+ 0x9000, 0x902E, 0x968A, 0x9EDB, 0x9BDB, 0x4EE3, 0x53F0, 0x5927,
+ 0x7B2C, 0x918D, 0x984C, 0x9DF9, 0x6EDD, 0x7027, 0x5353, 0x5544,
+ 0x5B85, 0x6258, 0x629E, 0x62D3, 0x6CA2, 0x6FEF, 0x7422, 0x8A17,
+ 0x9438, 0x6FC1, 0x8AFE, 0x8338, 0x51E7, 0x86F8, 0x53EA,
+};
+unsigned short euc_to_utf8_C3[] = {
+ 0x53E9, 0x4F46, 0x9054, 0x8FB0, 0x596A, 0x8131, 0x5DFD,
+ 0x7AEA, 0x8FBF, 0x68DA, 0x8C37, 0x72F8, 0x9C48, 0x6A3D, 0x8AB0,
+ 0x4E39, 0x5358, 0x5606, 0x5766, 0x62C5, 0x63A2, 0x65E6, 0x6B4E,
+ 0x6DE1, 0x6E5B, 0x70AD, 0x77ED, 0x7AEF, 0x7BAA, 0x7DBB, 0x803D,
+ 0x80C6, 0x86CB, 0x8A95, 0x935B, 0x56E3, 0x58C7, 0x5F3E, 0x65AD,
+ 0x6696, 0x6A80, 0x6BB5, 0x7537, 0x8AC7, 0x5024, 0x77E5, 0x5730,
+ 0x5F1B, 0x6065, 0x667A, 0x6C60, 0x75F4, 0x7A1A, 0x7F6E, 0x81F4,
+ 0x8718, 0x9045, 0x99B3, 0x7BC9, 0x755C, 0x7AF9, 0x7B51, 0x84C4,
+ 0x9010, 0x79E9, 0x7A92, 0x8336, 0x5AE1, 0x7740, 0x4E2D, 0x4EF2,
+ 0x5B99, 0x5FE0, 0x62BD, 0x663C, 0x67F1, 0x6CE8, 0x866B, 0x8877,
+ 0x8A3B, 0x914E, 0x92F3, 0x99D0, 0x6A17, 0x7026, 0x732A, 0x82E7,
+ 0x8457, 0x8CAF, 0x4E01, 0x5146, 0x51CB, 0x558B, 0x5BF5,
+};
+unsigned short euc_to_utf8_C4[] = {
+ 0x5E16, 0x5E33, 0x5E81, 0x5F14, 0x5F35, 0x5F6B, 0x5FB4,
+ 0x61F2, 0x6311, 0x66A2, 0x671D, 0x6F6E, 0x7252, 0x753A, 0x773A,
+ 0x8074, 0x8139, 0x8178, 0x8776, 0x8ABF, 0x8ADC, 0x8D85, 0x8DF3,
+ 0x929A, 0x9577, 0x9802, 0x9CE5, 0x52C5, 0x6357, 0x76F4, 0x6715,
+ 0x6C88, 0x73CD, 0x8CC3, 0x93AE, 0x9673, 0x6D25, 0x589C, 0x690E,
+ 0x69CC, 0x8FFD, 0x939A, 0x75DB, 0x901A, 0x585A, 0x6802, 0x63B4,
+ 0x69FB, 0x4F43, 0x6F2C, 0x67D8, 0x8FBB, 0x8526, 0x7DB4, 0x9354,
+ 0x693F, 0x6F70, 0x576A, 0x58F7, 0x5B2C, 0x7D2C, 0x722A, 0x540A,
+ 0x91E3, 0x9DB4, 0x4EAD, 0x4F4E, 0x505C, 0x5075, 0x5243, 0x8C9E,
+ 0x5448, 0x5824, 0x5B9A, 0x5E1D, 0x5E95, 0x5EAD, 0x5EF7, 0x5F1F,
+ 0x608C, 0x62B5, 0x633A, 0x63D0, 0x68AF, 0x6C40, 0x7887, 0x798E,
+ 0x7A0B, 0x7DE0, 0x8247, 0x8A02, 0x8AE6, 0x8E44, 0x9013,
+};
+unsigned short euc_to_utf8_C5[] = {
+ 0x90B8, 0x912D, 0x91D8, 0x9F0E, 0x6CE5, 0x6458, 0x64E2,
+ 0x6575, 0x6EF4, 0x7684, 0x7B1B, 0x9069, 0x93D1, 0x6EBA, 0x54F2,
+ 0x5FB9, 0x64A4, 0x8F4D, 0x8FED, 0x9244, 0x5178, 0x586B, 0x5929,
+ 0x5C55, 0x5E97, 0x6DFB, 0x7E8F, 0x751C, 0x8CBC, 0x8EE2, 0x985B,
+ 0x70B9, 0x4F1D, 0x6BBF, 0x6FB1, 0x7530, 0x96FB, 0x514E, 0x5410,
+ 0x5835, 0x5857, 0x59AC, 0x5C60, 0x5F92, 0x6597, 0x675C, 0x6E21,
+ 0x767B, 0x83DF, 0x8CED, 0x9014, 0x90FD, 0x934D, 0x7825, 0x783A,
+ 0x52AA, 0x5EA6, 0x571F, 0x5974, 0x6012, 0x5012, 0x515A, 0x51AC,
+ 0x51CD, 0x5200, 0x5510, 0x5854, 0x5858, 0x5957, 0x5B95, 0x5CF6,
+ 0x5D8B, 0x60BC, 0x6295, 0x642D, 0x6771, 0x6843, 0x68BC, 0x68DF,
+ 0x76D7, 0x6DD8, 0x6E6F, 0x6D9B, 0x706F, 0x71C8, 0x5F53, 0x75D8,
+ 0x7977, 0x7B49, 0x7B54, 0x7B52, 0x7CD6, 0x7D71, 0x5230,
+};
+unsigned short euc_to_utf8_C6[] = {
+ 0x8463, 0x8569, 0x85E4, 0x8A0E, 0x8B04, 0x8C46, 0x8E0F,
+ 0x9003, 0x900F, 0x9419, 0x9676, 0x982D, 0x9A30, 0x95D8, 0x50CD,
+ 0x52D5, 0x540C, 0x5802, 0x5C0E, 0x61A7, 0x649E, 0x6D1E, 0x77B3,
+ 0x7AE5, 0x80F4, 0x8404, 0x9053, 0x9285, 0x5CE0, 0x9D07, 0x533F,
+ 0x5F97, 0x5FB3, 0x6D9C, 0x7279, 0x7763, 0x79BF, 0x7BE4, 0x6BD2,
+ 0x72EC, 0x8AAD, 0x6803, 0x6A61, 0x51F8, 0x7A81, 0x6934, 0x5C4A,
+ 0x9CF6, 0x82EB, 0x5BC5, 0x9149, 0x701E, 0x5678, 0x5C6F, 0x60C7,
+ 0x6566, 0x6C8C, 0x8C5A, 0x9041, 0x9813, 0x5451, 0x66C7, 0x920D,
+ 0x5948, 0x90A3, 0x5185, 0x4E4D, 0x51EA, 0x8599, 0x8B0E, 0x7058,
+ 0x637A, 0x934B, 0x6962, 0x99B4, 0x7E04, 0x7577, 0x5357, 0x6960,
+ 0x8EDF, 0x96E3, 0x6C5D, 0x4E8C, 0x5C3C, 0x5F10, 0x8FE9, 0x5302,
+ 0x8CD1, 0x8089, 0x8679, 0x5EFF, 0x65E5, 0x4E73, 0x5165,
+};
+unsigned short euc_to_utf8_C7[] = {
+ 0x5982, 0x5C3F, 0x97EE, 0x4EFB, 0x598A, 0x5FCD, 0x8A8D,
+ 0x6FE1, 0x79B0, 0x7962, 0x5BE7, 0x8471, 0x732B, 0x71B1, 0x5E74,
+ 0x5FF5, 0x637B, 0x649A, 0x71C3, 0x7C98, 0x4E43, 0x5EFC, 0x4E4B,
+ 0x57DC, 0x56A2, 0x60A9, 0x6FC3, 0x7D0D, 0x80FD, 0x8133, 0x81BF,
+ 0x8FB2, 0x8997, 0x86A4, 0x5DF4, 0x628A, 0x64AD, 0x8987, 0x6777,
+ 0x6CE2, 0x6D3E, 0x7436, 0x7834, 0x5A46, 0x7F75, 0x82AD, 0x99AC,
+ 0x4FF3, 0x5EC3, 0x62DD, 0x6392, 0x6557, 0x676F, 0x76C3, 0x724C,
+ 0x80CC, 0x80BA, 0x8F29, 0x914D, 0x500D, 0x57F9, 0x5A92, 0x6885,
+ 0x6973, 0x7164, 0x72FD, 0x8CB7, 0x58F2, 0x8CE0, 0x966A, 0x9019,
+ 0x877F, 0x79E4, 0x77E7, 0x8429, 0x4F2F, 0x5265, 0x535A, 0x62CD,
+ 0x67CF, 0x6CCA, 0x767D, 0x7B94, 0x7C95, 0x8236, 0x8584, 0x8FEB,
+ 0x66DD, 0x6F20, 0x7206, 0x7E1B, 0x83AB, 0x99C1, 0x9EA6,
+};
+unsigned short euc_to_utf8_C8[] = {
+ 0x51FD, 0x7BB1, 0x7872, 0x7BB8, 0x8087, 0x7B48, 0x6AE8,
+ 0x5E61, 0x808C, 0x7551, 0x7560, 0x516B, 0x9262, 0x6E8C, 0x767A,
+ 0x9197, 0x9AEA, 0x4F10, 0x7F70, 0x629C, 0x7B4F, 0x95A5, 0x9CE9,
+ 0x567A, 0x5859, 0x86E4, 0x96BC, 0x4F34, 0x5224, 0x534A, 0x53CD,
+ 0x53DB, 0x5E06, 0x642C, 0x6591, 0x677F, 0x6C3E, 0x6C4E, 0x7248,
+ 0x72AF, 0x73ED, 0x7554, 0x7E41, 0x822C, 0x85E9, 0x8CA9, 0x7BC4,
+ 0x91C6, 0x7169, 0x9812, 0x98EF, 0x633D, 0x6669, 0x756A, 0x76E4,
+ 0x78D0, 0x8543, 0x86EE, 0x532A, 0x5351, 0x5426, 0x5983, 0x5E87,
+ 0x5F7C, 0x60B2, 0x6249, 0x6279, 0x62AB, 0x6590, 0x6BD4, 0x6CCC,
+ 0x75B2, 0x76AE, 0x7891, 0x79D8, 0x7DCB, 0x7F77, 0x80A5, 0x88AB,
+ 0x8AB9, 0x8CBB, 0x907F, 0x975E, 0x98DB, 0x6A0B, 0x7C38, 0x5099,
+ 0x5C3E, 0x5FAE, 0x6787, 0x6BD8, 0x7435, 0x7709, 0x7F8E,
+};
+unsigned short euc_to_utf8_C9[] = {
+ 0x9F3B, 0x67CA, 0x7A17, 0x5339, 0x758B, 0x9AED, 0x5F66,
+ 0x819D, 0x83F1, 0x8098, 0x5F3C, 0x5FC5, 0x7562, 0x7B46, 0x903C,
+ 0x6867, 0x59EB, 0x5A9B, 0x7D10, 0x767E, 0x8B2C, 0x4FF5, 0x5F6A,
+ 0x6A19, 0x6C37, 0x6F02, 0x74E2, 0x7968, 0x8868, 0x8A55, 0x8C79,
+ 0x5EDF, 0x63CF, 0x75C5, 0x79D2, 0x82D7, 0x9328, 0x92F2, 0x849C,
+ 0x86ED, 0x9C2D, 0x54C1, 0x5F6C, 0x658C, 0x6D5C, 0x7015, 0x8CA7,
+ 0x8CD3, 0x983B, 0x654F, 0x74F6, 0x4E0D, 0x4ED8, 0x57E0, 0x592B,
+ 0x5A66, 0x5BCC, 0x51A8, 0x5E03, 0x5E9C, 0x6016, 0x6276, 0x6577,
+ 0x65A7, 0x666E, 0x6D6E, 0x7236, 0x7B26, 0x8150, 0x819A, 0x8299,
+ 0x8B5C, 0x8CA0, 0x8CE6, 0x8D74, 0x961C, 0x9644, 0x4FAE, 0x64AB,
+ 0x6B66, 0x821E, 0x8461, 0x856A, 0x90E8, 0x5C01, 0x6953, 0x98A8,
+ 0x847A, 0x8557, 0x4F0F, 0x526F, 0x5FA9, 0x5E45, 0x670D,
+};
+unsigned short euc_to_utf8_CA[] = {
+ 0x798F, 0x8179, 0x8907, 0x8986, 0x6DF5, 0x5F17, 0x6255,
+ 0x6CB8, 0x4ECF, 0x7269, 0x9B92, 0x5206, 0x543B, 0x5674, 0x58B3,
+ 0x61A4, 0x626E, 0x711A, 0x596E, 0x7C89, 0x7CDE, 0x7D1B, 0x96F0,
+ 0x6587, 0x805E, 0x4E19, 0x4F75, 0x5175, 0x5840, 0x5E63, 0x5E73,
+ 0x5F0A, 0x67C4, 0x4E26, 0x853D, 0x9589, 0x965B, 0x7C73, 0x9801,
+ 0x50FB, 0x58C1, 0x7656, 0x78A7, 0x5225, 0x77A5, 0x8511, 0x7B86,
+ 0x504F, 0x5909, 0x7247, 0x7BC7, 0x7DE8, 0x8FBA, 0x8FD4, 0x904D,
+ 0x4FBF, 0x52C9, 0x5A29, 0x5F01, 0x97AD, 0x4FDD, 0x8217, 0x92EA,
+ 0x5703, 0x6355, 0x6B69, 0x752B, 0x88DC, 0x8F14, 0x7A42, 0x52DF,
+ 0x5893, 0x6155, 0x620A, 0x66AE, 0x6BCD, 0x7C3F, 0x83E9, 0x5023,
+ 0x4FF8, 0x5305, 0x5446, 0x5831, 0x5949, 0x5B9D, 0x5CF0, 0x5CEF,
+ 0x5D29, 0x5E96, 0x62B1, 0x6367, 0x653E, 0x65B9, 0x670B,
+};
+unsigned short euc_to_utf8_CB[] = {
+ 0x6CD5, 0x6CE1, 0x70F9, 0x7832, 0x7E2B, 0x80DE, 0x82B3,
+ 0x840C, 0x84EC, 0x8702, 0x8912, 0x8A2A, 0x8C4A, 0x90A6, 0x92D2,
+ 0x98FD, 0x9CF3, 0x9D6C, 0x4E4F, 0x4EA1, 0x508D, 0x5256, 0x574A,
+ 0x59A8, 0x5E3D, 0x5FD8, 0x5FD9, 0x623F, 0x66B4, 0x671B, 0x67D0,
+ 0x68D2, 0x5192, 0x7D21, 0x80AA, 0x81A8, 0x8B00, 0x8C8C, 0x8CBF,
+ 0x927E, 0x9632, 0x5420, 0x982C, 0x5317, 0x50D5, 0x535C, 0x58A8,
+ 0x64B2, 0x6734, 0x7267, 0x7766, 0x7A46, 0x91E6, 0x52C3, 0x6CA1,
+ 0x6B86, 0x5800, 0x5E4C, 0x5954, 0x672C, 0x7FFB, 0x51E1, 0x76C6,
+ 0x6469, 0x78E8, 0x9B54, 0x9EBB, 0x57CB, 0x59B9, 0x6627, 0x679A,
+ 0x6BCE, 0x54E9, 0x69D9, 0x5E55, 0x819C, 0x6795, 0x9BAA, 0x67FE,
+ 0x9C52, 0x685D, 0x4EA6, 0x4FE3, 0x53C8, 0x62B9, 0x672B, 0x6CAB,
+ 0x8FC4, 0x4FAD, 0x7E6D, 0x9EBF, 0x4E07, 0x6162, 0x6E80,
+};
+unsigned short euc_to_utf8_CC[] = {
+ 0x6F2B, 0x8513, 0x5473, 0x672A, 0x9B45, 0x5DF3, 0x7B95,
+ 0x5CAC, 0x5BC6, 0x871C, 0x6E4A, 0x84D1, 0x7A14, 0x8108, 0x5999,
+ 0x7C8D, 0x6C11, 0x7720, 0x52D9, 0x5922, 0x7121, 0x725F, 0x77DB,
+ 0x9727, 0x9D61, 0x690B, 0x5A7F, 0x5A18, 0x51A5, 0x540D, 0x547D,
+ 0x660E, 0x76DF, 0x8FF7, 0x9298, 0x9CF4, 0x59EA, 0x725D, 0x6EC5,
+ 0x514D, 0x68C9, 0x7DBF, 0x7DEC, 0x9762, 0x9EBA, 0x6478, 0x6A21,
+ 0x8302, 0x5984, 0x5B5F, 0x6BDB, 0x731B, 0x76F2, 0x7DB2, 0x8017,
+ 0x8499, 0x5132, 0x6728, 0x9ED9, 0x76EE, 0x6762, 0x52FF, 0x9905,
+ 0x5C24, 0x623B, 0x7C7E, 0x8CB0, 0x554F, 0x60B6, 0x7D0B, 0x9580,
+ 0x5301, 0x4E5F, 0x51B6, 0x591C, 0x723A, 0x8036, 0x91CE, 0x5F25,
+ 0x77E2, 0x5384, 0x5F79, 0x7D04, 0x85AC, 0x8A33, 0x8E8D, 0x9756,
+ 0x67F3, 0x85AE, 0x9453, 0x6109, 0x6108, 0x6CB9, 0x7652,
+};
+unsigned short euc_to_utf8_CD[] = {
+ 0x8AED, 0x8F38, 0x552F, 0x4F51, 0x512A, 0x52C7, 0x53CB,
+ 0x5BA5, 0x5E7D, 0x60A0, 0x6182, 0x63D6, 0x6709, 0x67DA, 0x6E67,
+ 0x6D8C, 0x7336, 0x7337, 0x7531, 0x7950, 0x88D5, 0x8A98, 0x904A,
+ 0x9091, 0x90F5, 0x96C4, 0x878D, 0x5915, 0x4E88, 0x4F59, 0x4E0E,
+ 0x8A89, 0x8F3F, 0x9810, 0x50AD, 0x5E7C, 0x5996, 0x5BB9, 0x5EB8,
+ 0x63DA, 0x63FA, 0x64C1, 0x66DC, 0x694A, 0x69D8, 0x6D0B, 0x6EB6,
+ 0x7194, 0x7528, 0x7AAF, 0x7F8A, 0x8000, 0x8449, 0x84C9, 0x8981,
+ 0x8B21, 0x8E0A, 0x9065, 0x967D, 0x990A, 0x617E, 0x6291, 0x6B32,
+ 0x6C83, 0x6D74, 0x7FCC, 0x7FFC, 0x6DC0, 0x7F85, 0x87BA, 0x88F8,
+ 0x6765, 0x83B1, 0x983C, 0x96F7, 0x6D1B, 0x7D61, 0x843D, 0x916A,
+ 0x4E71, 0x5375, 0x5D50, 0x6B04, 0x6FEB, 0x85CD, 0x862D, 0x89A7,
+ 0x5229, 0x540F, 0x5C65, 0x674E, 0x68A8, 0x7406, 0x7483,
+};
+unsigned short euc_to_utf8_CE[] = {
+ 0x75E2, 0x88CF, 0x88E1, 0x91CC, 0x96E2, 0x9678, 0x5F8B,
+ 0x7387, 0x7ACB, 0x844E, 0x63A0, 0x7565, 0x5289, 0x6D41, 0x6E9C,
+ 0x7409, 0x7559, 0x786B, 0x7C92, 0x9686, 0x7ADC, 0x9F8D, 0x4FB6,
+ 0x616E, 0x65C5, 0x865C, 0x4E86, 0x4EAE, 0x50DA, 0x4E21, 0x51CC,
+ 0x5BEE, 0x6599, 0x6881, 0x6DBC, 0x731F, 0x7642, 0x77AD, 0x7A1C,
+ 0x7CE7, 0x826F, 0x8AD2, 0x907C, 0x91CF, 0x9675, 0x9818, 0x529B,
+ 0x7DD1, 0x502B, 0x5398, 0x6797, 0x6DCB, 0x71D0, 0x7433, 0x81E8,
+ 0x8F2A, 0x96A3, 0x9C57, 0x9E9F, 0x7460, 0x5841, 0x6D99, 0x7D2F,
+ 0x985E, 0x4EE4, 0x4F36, 0x4F8B, 0x51B7, 0x52B1, 0x5DBA, 0x601C,
+ 0x73B2, 0x793C, 0x82D3, 0x9234, 0x96B7, 0x96F6, 0x970A, 0x9E97,
+ 0x9F62, 0x66A6, 0x6B74, 0x5217, 0x52A3, 0x70C8, 0x88C2, 0x5EC9,
+ 0x604B, 0x6190, 0x6F23, 0x7149, 0x7C3E, 0x7DF4, 0x806F,
+};
+unsigned short euc_to_utf8_CF[] = {
+ 0x84EE, 0x9023, 0x932C, 0x5442, 0x9B6F, 0x6AD3, 0x7089,
+ 0x8CC2, 0x8DEF, 0x9732, 0x52B4, 0x5A41, 0x5ECA, 0x5F04, 0x6717,
+ 0x697C, 0x6994, 0x6D6A, 0x6F0F, 0x7262, 0x72FC, 0x7BED, 0x8001,
+ 0x807E, 0x874B, 0x90CE, 0x516D, 0x9E93, 0x7984, 0x808B, 0x9332,
+ 0x8AD6, 0x502D, 0x548C, 0x8A71, 0x6B6A, 0x8CC4, 0x8107, 0x60D1,
+ 0x67A0, 0x9DF2, 0x4E99, 0x4E98, 0x9C10, 0x8A6B, 0x85C1, 0x8568,
+ 0x6900, 0x6E7E, 0x7897, 0x8155, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_D0[] = {
+ 0x5F0C, 0x4E10, 0x4E15, 0x4E2A, 0x4E31, 0x4E36, 0x4E3C,
+ 0x4E3F, 0x4E42, 0x4E56, 0x4E58, 0x4E82, 0x4E85, 0x8C6B, 0x4E8A,
+ 0x8212, 0x5F0D, 0x4E8E, 0x4E9E, 0x4E9F, 0x4EA0, 0x4EA2, 0x4EB0,
+ 0x4EB3, 0x4EB6, 0x4ECE, 0x4ECD, 0x4EC4, 0x4EC6, 0x4EC2, 0x4ED7,
+ 0x4EDE, 0x4EED, 0x4EDF, 0x4EF7, 0x4F09, 0x4F5A, 0x4F30, 0x4F5B,
+ 0x4F5D, 0x4F57, 0x4F47, 0x4F76, 0x4F88, 0x4F8F, 0x4F98, 0x4F7B,
+ 0x4F69, 0x4F70, 0x4F91, 0x4F6F, 0x4F86, 0x4F96, 0x5118, 0x4FD4,
+ 0x4FDF, 0x4FCE, 0x4FD8, 0x4FDB, 0x4FD1, 0x4FDA, 0x4FD0, 0x4FE4,
+ 0x4FE5, 0x501A, 0x5028, 0x5014, 0x502A, 0x5025, 0x5005, 0x4F1C,
+ 0x4FF6, 0x5021, 0x5029, 0x502C, 0x4FFE, 0x4FEF, 0x5011, 0x5006,
+ 0x5043, 0x5047, 0x6703, 0x5055, 0x5050, 0x5048, 0x505A, 0x5056,
+ 0x506C, 0x5078, 0x5080, 0x509A, 0x5085, 0x50B4, 0x50B2,
+};
+unsigned short euc_to_utf8_D1[] = {
+ 0x50C9, 0x50CA, 0x50B3, 0x50C2, 0x50D6, 0x50DE, 0x50E5,
+ 0x50ED, 0x50E3, 0x50EE, 0x50F9, 0x50F5, 0x5109, 0x5101, 0x5102,
+ 0x5116, 0x5115, 0x5114, 0x511A, 0x5121, 0x513A, 0x5137, 0x513C,
+ 0x513B, 0x513F, 0x5140, 0x5152, 0x514C, 0x5154, 0x5162, 0x7AF8,
+ 0x5169, 0x516A, 0x516E, 0x5180, 0x5182, 0x56D8, 0x518C, 0x5189,
+ 0x518F, 0x5191, 0x5193, 0x5195, 0x5196, 0x51A4, 0x51A6, 0x51A2,
+ 0x51A9, 0x51AA, 0x51AB, 0x51B3, 0x51B1, 0x51B2, 0x51B0, 0x51B5,
+ 0x51BD, 0x51C5, 0x51C9, 0x51DB, 0x51E0, 0x8655, 0x51E9, 0x51ED,
+ 0x51F0, 0x51F5, 0x51FE, 0x5204, 0x520B, 0x5214, 0x520E, 0x5227,
+ 0x522A, 0x522E, 0x5233, 0x5239, 0x524F, 0x5244, 0x524B, 0x524C,
+ 0x525E, 0x5254, 0x526A, 0x5274, 0x5269, 0x5273, 0x527F, 0x527D,
+ 0x528D, 0x5294, 0x5292, 0x5271, 0x5288, 0x5291, 0x8FA8,
+};
+unsigned short euc_to_utf8_D2[] = {
+ 0x8FA7, 0x52AC, 0x52AD, 0x52BC, 0x52B5, 0x52C1, 0x52CD,
+ 0x52D7, 0x52DE, 0x52E3, 0x52E6, 0x98ED, 0x52E0, 0x52F3, 0x52F5,
+ 0x52F8, 0x52F9, 0x5306, 0x5308, 0x7538, 0x530D, 0x5310, 0x530F,
+ 0x5315, 0x531A, 0x5323, 0x532F, 0x5331, 0x5333, 0x5338, 0x5340,
+ 0x5346, 0x5345, 0x4E17, 0x5349, 0x534D, 0x51D6, 0x535E, 0x5369,
+ 0x536E, 0x5918, 0x537B, 0x5377, 0x5382, 0x5396, 0x53A0, 0x53A6,
+ 0x53A5, 0x53AE, 0x53B0, 0x53B6, 0x53C3, 0x7C12, 0x96D9, 0x53DF,
+ 0x66FC, 0x71EE, 0x53EE, 0x53E8, 0x53ED, 0x53FA, 0x5401, 0x543D,
+ 0x5440, 0x542C, 0x542D, 0x543C, 0x542E, 0x5436, 0x5429, 0x541D,
+ 0x544E, 0x548F, 0x5475, 0x548E, 0x545F, 0x5471, 0x5477, 0x5470,
+ 0x5492, 0x547B, 0x5480, 0x5476, 0x5484, 0x5490, 0x5486, 0x54C7,
+ 0x54A2, 0x54B8, 0x54A5, 0x54AC, 0x54C4, 0x54C8, 0x54A8,
+};
+unsigned short euc_to_utf8_D3[] = {
+ 0x54AB, 0x54C2, 0x54A4, 0x54BE, 0x54BC, 0x54D8, 0x54E5,
+ 0x54E6, 0x550F, 0x5514, 0x54FD, 0x54EE, 0x54ED, 0x54FA, 0x54E2,
+ 0x5539, 0x5540, 0x5563, 0x554C, 0x552E, 0x555C, 0x5545, 0x5556,
+ 0x5557, 0x5538, 0x5533, 0x555D, 0x5599, 0x5580, 0x54AF, 0x558A,
+ 0x559F, 0x557B, 0x557E, 0x5598, 0x559E, 0x55AE, 0x557C, 0x5583,
+ 0x55A9, 0x5587, 0x55A8, 0x55DA, 0x55C5, 0x55DF, 0x55C4, 0x55DC,
+ 0x55E4, 0x55D4, 0x5614, 0x55F7, 0x5616, 0x55FE, 0x55FD, 0x561B,
+ 0x55F9, 0x564E, 0x5650, 0x71DF, 0x5634, 0x5636, 0x5632, 0x5638,
+ 0x566B, 0x5664, 0x562F, 0x566C, 0x566A, 0x5686, 0x5680, 0x568A,
+ 0x56A0, 0x5694, 0x568F, 0x56A5, 0x56AE, 0x56B6, 0x56B4, 0x56C2,
+ 0x56BC, 0x56C1, 0x56C3, 0x56C0, 0x56C8, 0x56CE, 0x56D1, 0x56D3,
+ 0x56D7, 0x56EE, 0x56F9, 0x5700, 0x56FF, 0x5704, 0x5709,
+};
+unsigned short euc_to_utf8_D4[] = {
+ 0x5708, 0x570B, 0x570D, 0x5713, 0x5718, 0x5716, 0x55C7,
+ 0x571C, 0x5726, 0x5737, 0x5738, 0x574E, 0x573B, 0x5740, 0x574F,
+ 0x5769, 0x57C0, 0x5788, 0x5761, 0x577F, 0x5789, 0x5793, 0x57A0,
+ 0x57B3, 0x57A4, 0x57AA, 0x57B0, 0x57C3, 0x57C6, 0x57D4, 0x57D2,
+ 0x57D3, 0x580A, 0x57D6, 0x57E3, 0x580B, 0x5819, 0x581D, 0x5872,
+ 0x5821, 0x5862, 0x584B, 0x5870, 0x6BC0, 0x5852, 0x583D, 0x5879,
+ 0x5885, 0x58B9, 0x589F, 0x58AB, 0x58BA, 0x58DE, 0x58BB, 0x58B8,
+ 0x58AE, 0x58C5, 0x58D3, 0x58D1, 0x58D7, 0x58D9, 0x58D8, 0x58E5,
+ 0x58DC, 0x58E4, 0x58DF, 0x58EF, 0x58FA, 0x58F9, 0x58FB, 0x58FC,
+ 0x58FD, 0x5902, 0x590A, 0x5910, 0x591B, 0x68A6, 0x5925, 0x592C,
+ 0x592D, 0x5932, 0x5938, 0x593E, 0x7AD2, 0x5955, 0x5950, 0x594E,
+ 0x595A, 0x5958, 0x5962, 0x5960, 0x5967, 0x596C, 0x5969,
+};
+unsigned short euc_to_utf8_D5[] = {
+ 0x5978, 0x5981, 0x599D, 0x4F5E, 0x4FAB, 0x59A3, 0x59B2,
+ 0x59C6, 0x59E8, 0x59DC, 0x598D, 0x59D9, 0x59DA, 0x5A25, 0x5A1F,
+ 0x5A11, 0x5A1C, 0x5A09, 0x5A1A, 0x5A40, 0x5A6C, 0x5A49, 0x5A35,
+ 0x5A36, 0x5A62, 0x5A6A, 0x5A9A, 0x5ABC, 0x5ABE, 0x5ACB, 0x5AC2,
+ 0x5ABD, 0x5AE3, 0x5AD7, 0x5AE6, 0x5AE9, 0x5AD6, 0x5AFA, 0x5AFB,
+ 0x5B0C, 0x5B0B, 0x5B16, 0x5B32, 0x5AD0, 0x5B2A, 0x5B36, 0x5B3E,
+ 0x5B43, 0x5B45, 0x5B40, 0x5B51, 0x5B55, 0x5B5A, 0x5B5B, 0x5B65,
+ 0x5B69, 0x5B70, 0x5B73, 0x5B75, 0x5B78, 0x6588, 0x5B7A, 0x5B80,
+ 0x5B83, 0x5BA6, 0x5BB8, 0x5BC3, 0x5BC7, 0x5BC9, 0x5BD4, 0x5BD0,
+ 0x5BE4, 0x5BE6, 0x5BE2, 0x5BDE, 0x5BE5, 0x5BEB, 0x5BF0, 0x5BF6,
+ 0x5BF3, 0x5C05, 0x5C07, 0x5C08, 0x5C0D, 0x5C13, 0x5C20, 0x5C22,
+ 0x5C28, 0x5C38, 0x5C39, 0x5C41, 0x5C46, 0x5C4E, 0x5C53,
+};
+unsigned short euc_to_utf8_D6[] = {
+ 0x5C50, 0x5C4F, 0x5B71, 0x5C6C, 0x5C6E, 0x4E62, 0x5C76,
+ 0x5C79, 0x5C8C, 0x5C91, 0x5C94, 0x599B, 0x5CAB, 0x5CBB, 0x5CB6,
+ 0x5CBC, 0x5CB7, 0x5CC5, 0x5CBE, 0x5CC7, 0x5CD9, 0x5CE9, 0x5CFD,
+ 0x5CFA, 0x5CED, 0x5D8C, 0x5CEA, 0x5D0B, 0x5D15, 0x5D17, 0x5D5C,
+ 0x5D1F, 0x5D1B, 0x5D11, 0x5D14, 0x5D22, 0x5D1A, 0x5D19, 0x5D18,
+ 0x5D4C, 0x5D52, 0x5D4E, 0x5D4B, 0x5D6C, 0x5D73, 0x5D76, 0x5D87,
+ 0x5D84, 0x5D82, 0x5DA2, 0x5D9D, 0x5DAC, 0x5DAE, 0x5DBD, 0x5D90,
+ 0x5DB7, 0x5DBC, 0x5DC9, 0x5DCD, 0x5DD3, 0x5DD2, 0x5DD6, 0x5DDB,
+ 0x5DEB, 0x5DF2, 0x5DF5, 0x5E0B, 0x5E1A, 0x5E19, 0x5E11, 0x5E1B,
+ 0x5E36, 0x5E37, 0x5E44, 0x5E43, 0x5E40, 0x5E4E, 0x5E57, 0x5E54,
+ 0x5E5F, 0x5E62, 0x5E64, 0x5E47, 0x5E75, 0x5E76, 0x5E7A, 0x9EBC,
+ 0x5E7F, 0x5EA0, 0x5EC1, 0x5EC2, 0x5EC8, 0x5ED0, 0x5ECF,
+};
+unsigned short euc_to_utf8_D7[] = {
+ 0x5ED6, 0x5EE3, 0x5EDD, 0x5EDA, 0x5EDB, 0x5EE2, 0x5EE1,
+ 0x5EE8, 0x5EE9, 0x5EEC, 0x5EF1, 0x5EF3, 0x5EF0, 0x5EF4, 0x5EF8,
+ 0x5EFE, 0x5F03, 0x5F09, 0x5F5D, 0x5F5C, 0x5F0B, 0x5F11, 0x5F16,
+ 0x5F29, 0x5F2D, 0x5F38, 0x5F41, 0x5F48, 0x5F4C, 0x5F4E, 0x5F2F,
+ 0x5F51, 0x5F56, 0x5F57, 0x5F59, 0x5F61, 0x5F6D, 0x5F73, 0x5F77,
+ 0x5F83, 0x5F82, 0x5F7F, 0x5F8A, 0x5F88, 0x5F91, 0x5F87, 0x5F9E,
+ 0x5F99, 0x5F98, 0x5FA0, 0x5FA8, 0x5FAD, 0x5FBC, 0x5FD6, 0x5FFB,
+ 0x5FE4, 0x5FF8, 0x5FF1, 0x5FDD, 0x60B3, 0x5FFF, 0x6021, 0x6060,
+ 0x6019, 0x6010, 0x6029, 0x600E, 0x6031, 0x601B, 0x6015, 0x602B,
+ 0x6026, 0x600F, 0x603A, 0x605A, 0x6041, 0x606A, 0x6077, 0x605F,
+ 0x604A, 0x6046, 0x604D, 0x6063, 0x6043, 0x6064, 0x6042, 0x606C,
+ 0x606B, 0x6059, 0x6081, 0x608D, 0x60E7, 0x6083, 0x609A,
+};
+unsigned short euc_to_utf8_D8[] = {
+ 0x6084, 0x609B, 0x6096, 0x6097, 0x6092, 0x60A7, 0x608B,
+ 0x60E1, 0x60B8, 0x60E0, 0x60D3, 0x60B4, 0x5FF0, 0x60BD, 0x60C6,
+ 0x60B5, 0x60D8, 0x614D, 0x6115, 0x6106, 0x60F6, 0x60F7, 0x6100,
+ 0x60F4, 0x60FA, 0x6103, 0x6121, 0x60FB, 0x60F1, 0x610D, 0x610E,
+ 0x6147, 0x613E, 0x6128, 0x6127, 0x614A, 0x613F, 0x613C, 0x612C,
+ 0x6134, 0x613D, 0x6142, 0x6144, 0x6173, 0x6177, 0x6158, 0x6159,
+ 0x615A, 0x616B, 0x6174, 0x616F, 0x6165, 0x6171, 0x615F, 0x615D,
+ 0x6153, 0x6175, 0x6199, 0x6196, 0x6187, 0x61AC, 0x6194, 0x619A,
+ 0x618A, 0x6191, 0x61AB, 0x61AE, 0x61CC, 0x61CA, 0x61C9, 0x61F7,
+ 0x61C8, 0x61C3, 0x61C6, 0x61BA, 0x61CB, 0x7F79, 0x61CD, 0x61E6,
+ 0x61E3, 0x61F6, 0x61FA, 0x61F4, 0x61FF, 0x61FD, 0x61FC, 0x61FE,
+ 0x6200, 0x6208, 0x6209, 0x620D, 0x620C, 0x6214, 0x621B,
+};
+unsigned short euc_to_utf8_D9[] = {
+ 0x621E, 0x6221, 0x622A, 0x622E, 0x6230, 0x6232, 0x6233,
+ 0x6241, 0x624E, 0x625E, 0x6263, 0x625B, 0x6260, 0x6268, 0x627C,
+ 0x6282, 0x6289, 0x627E, 0x6292, 0x6293, 0x6296, 0x62D4, 0x6283,
+ 0x6294, 0x62D7, 0x62D1, 0x62BB, 0x62CF, 0x62FF, 0x62C6, 0x64D4,
+ 0x62C8, 0x62DC, 0x62CC, 0x62CA, 0x62C2, 0x62C7, 0x629B, 0x62C9,
+ 0x630C, 0x62EE, 0x62F1, 0x6327, 0x6302, 0x6308, 0x62EF, 0x62F5,
+ 0x6350, 0x633E, 0x634D, 0x641C, 0x634F, 0x6396, 0x638E, 0x6380,
+ 0x63AB, 0x6376, 0x63A3, 0x638F, 0x6389, 0x639F, 0x63B5, 0x636B,
+ 0x6369, 0x63BE, 0x63E9, 0x63C0, 0x63C6, 0x63E3, 0x63C9, 0x63D2,
+ 0x63F6, 0x63C4, 0x6416, 0x6434, 0x6406, 0x6413, 0x6426, 0x6436,
+ 0x651D, 0x6417, 0x6428, 0x640F, 0x6467, 0x646F, 0x6476, 0x644E,
+ 0x652A, 0x6495, 0x6493, 0x64A5, 0x64A9, 0x6488, 0x64BC,
+};
+unsigned short euc_to_utf8_DA[] = {
+ 0x64DA, 0x64D2, 0x64C5, 0x64C7, 0x64BB, 0x64D8, 0x64C2,
+ 0x64F1, 0x64E7, 0x8209, 0x64E0, 0x64E1, 0x62AC, 0x64E3, 0x64EF,
+ 0x652C, 0x64F6, 0x64F4, 0x64F2, 0x64FA, 0x6500, 0x64FD, 0x6518,
+ 0x651C, 0x6505, 0x6524, 0x6523, 0x652B, 0x6534, 0x6535, 0x6537,
+ 0x6536, 0x6538, 0x754B, 0x6548, 0x6556, 0x6555, 0x654D, 0x6558,
+ 0x655E, 0x655D, 0x6572, 0x6578, 0x6582, 0x6583, 0x8B8A, 0x659B,
+ 0x659F, 0x65AB, 0x65B7, 0x65C3, 0x65C6, 0x65C1, 0x65C4, 0x65CC,
+ 0x65D2, 0x65DB, 0x65D9, 0x65E0, 0x65E1, 0x65F1, 0x6772, 0x660A,
+ 0x6603, 0x65FB, 0x6773, 0x6635, 0x6636, 0x6634, 0x661C, 0x664F,
+ 0x6644, 0x6649, 0x6641, 0x665E, 0x665D, 0x6664, 0x6667, 0x6668,
+ 0x665F, 0x6662, 0x6670, 0x6683, 0x6688, 0x668E, 0x6689, 0x6684,
+ 0x6698, 0x669D, 0x66C1, 0x66B9, 0x66C9, 0x66BE, 0x66BC,
+};
+unsigned short euc_to_utf8_DB[] = {
+ 0x66C4, 0x66B8, 0x66D6, 0x66DA, 0x66E0, 0x663F, 0x66E6,
+ 0x66E9, 0x66F0, 0x66F5, 0x66F7, 0x670F, 0x6716, 0x671E, 0x6726,
+ 0x6727, 0x9738, 0x672E, 0x673F, 0x6736, 0x6741, 0x6738, 0x6737,
+ 0x6746, 0x675E, 0x6760, 0x6759, 0x6763, 0x6764, 0x6789, 0x6770,
+ 0x67A9, 0x677C, 0x676A, 0x678C, 0x678B, 0x67A6, 0x67A1, 0x6785,
+ 0x67B7, 0x67EF, 0x67B4, 0x67EC, 0x67B3, 0x67E9, 0x67B8, 0x67E4,
+ 0x67DE, 0x67DD, 0x67E2, 0x67EE, 0x67B9, 0x67CE, 0x67C6, 0x67E7,
+ 0x6A9C, 0x681E, 0x6846, 0x6829, 0x6840, 0x684D, 0x6832, 0x684E,
+ 0x68B3, 0x682B, 0x6859, 0x6863, 0x6877, 0x687F, 0x689F, 0x688F,
+ 0x68AD, 0x6894, 0x689D, 0x689B, 0x6883, 0x6AAE, 0x68B9, 0x6874,
+ 0x68B5, 0x68A0, 0x68BA, 0x690F, 0x688D, 0x687E, 0x6901, 0x68CA,
+ 0x6908, 0x68D8, 0x6922, 0x6926, 0x68E1, 0x690C, 0x68CD,
+};
+unsigned short euc_to_utf8_DC[] = {
+ 0x68D4, 0x68E7, 0x68D5, 0x6936, 0x6912, 0x6904, 0x68D7,
+ 0x68E3, 0x6925, 0x68F9, 0x68E0, 0x68EF, 0x6928, 0x692A, 0x691A,
+ 0x6923, 0x6921, 0x68C6, 0x6979, 0x6977, 0x695C, 0x6978, 0x696B,
+ 0x6954, 0x697E, 0x696E, 0x6939, 0x6974, 0x693D, 0x6959, 0x6930,
+ 0x6961, 0x695E, 0x695D, 0x6981, 0x696A, 0x69B2, 0x69AE, 0x69D0,
+ 0x69BF, 0x69C1, 0x69D3, 0x69BE, 0x69CE, 0x5BE8, 0x69CA, 0x69DD,
+ 0x69BB, 0x69C3, 0x69A7, 0x6A2E, 0x6991, 0x69A0, 0x699C, 0x6995,
+ 0x69B4, 0x69DE, 0x69E8, 0x6A02, 0x6A1B, 0x69FF, 0x6B0A, 0x69F9,
+ 0x69F2, 0x69E7, 0x6A05, 0x69B1, 0x6A1E, 0x69ED, 0x6A14, 0x69EB,
+ 0x6A0A, 0x6A12, 0x6AC1, 0x6A23, 0x6A13, 0x6A44, 0x6A0C, 0x6A72,
+ 0x6A36, 0x6A78, 0x6A47, 0x6A62, 0x6A59, 0x6A66, 0x6A48, 0x6A38,
+ 0x6A22, 0x6A90, 0x6A8D, 0x6AA0, 0x6A84, 0x6AA2, 0x6AA3,
+};
+unsigned short euc_to_utf8_DD[] = {
+ 0x6A97, 0x8617, 0x6ABB, 0x6AC3, 0x6AC2, 0x6AB8, 0x6AB3,
+ 0x6AAC, 0x6ADE, 0x6AD1, 0x6ADF, 0x6AAA, 0x6ADA, 0x6AEA, 0x6AFB,
+ 0x6B05, 0x8616, 0x6AFA, 0x6B12, 0x6B16, 0x9B31, 0x6B1F, 0x6B38,
+ 0x6B37, 0x76DC, 0x6B39, 0x98EE, 0x6B47, 0x6B43, 0x6B49, 0x6B50,
+ 0x6B59, 0x6B54, 0x6B5B, 0x6B5F, 0x6B61, 0x6B78, 0x6B79, 0x6B7F,
+ 0x6B80, 0x6B84, 0x6B83, 0x6B8D, 0x6B98, 0x6B95, 0x6B9E, 0x6BA4,
+ 0x6BAA, 0x6BAB, 0x6BAF, 0x6BB2, 0x6BB1, 0x6BB3, 0x6BB7, 0x6BBC,
+ 0x6BC6, 0x6BCB, 0x6BD3, 0x6BDF, 0x6BEC, 0x6BEB, 0x6BF3, 0x6BEF,
+ 0x9EBE, 0x6C08, 0x6C13, 0x6C14, 0x6C1B, 0x6C24, 0x6C23, 0x6C5E,
+ 0x6C55, 0x6C62, 0x6C6A, 0x6C82, 0x6C8D, 0x6C9A, 0x6C81, 0x6C9B,
+ 0x6C7E, 0x6C68, 0x6C73, 0x6C92, 0x6C90, 0x6CC4, 0x6CF1, 0x6CD3,
+ 0x6CBD, 0x6CD7, 0x6CC5, 0x6CDD, 0x6CAE, 0x6CB1, 0x6CBE,
+};
+unsigned short euc_to_utf8_DE[] = {
+ 0x6CBA, 0x6CDB, 0x6CEF, 0x6CD9, 0x6CEA, 0x6D1F, 0x884D,
+ 0x6D36, 0x6D2B, 0x6D3D, 0x6D38, 0x6D19, 0x6D35, 0x6D33, 0x6D12,
+ 0x6D0C, 0x6D63, 0x6D93, 0x6D64, 0x6D5A, 0x6D79, 0x6D59, 0x6D8E,
+ 0x6D95, 0x6FE4, 0x6D85, 0x6DF9, 0x6E15, 0x6E0A, 0x6DB5, 0x6DC7,
+ 0x6DE6, 0x6DB8, 0x6DC6, 0x6DEC, 0x6DDE, 0x6DCC, 0x6DE8, 0x6DD2,
+ 0x6DC5, 0x6DFA, 0x6DD9, 0x6DE4, 0x6DD5, 0x6DEA, 0x6DEE, 0x6E2D,
+ 0x6E6E, 0x6E2E, 0x6E19, 0x6E72, 0x6E5F, 0x6E3E, 0x6E23, 0x6E6B,
+ 0x6E2B, 0x6E76, 0x6E4D, 0x6E1F, 0x6E43, 0x6E3A, 0x6E4E, 0x6E24,
+ 0x6EFF, 0x6E1D, 0x6E38, 0x6E82, 0x6EAA, 0x6E98, 0x6EC9, 0x6EB7,
+ 0x6ED3, 0x6EBD, 0x6EAF, 0x6EC4, 0x6EB2, 0x6ED4, 0x6ED5, 0x6E8F,
+ 0x6EA5, 0x6EC2, 0x6E9F, 0x6F41, 0x6F11, 0x704C, 0x6EEC, 0x6EF8,
+ 0x6EFE, 0x6F3F, 0x6EF2, 0x6F31, 0x6EEF, 0x6F32, 0x6ECC,
+};
+unsigned short euc_to_utf8_DF[] = {
+ 0x6F3E, 0x6F13, 0x6EF7, 0x6F86, 0x6F7A, 0x6F78, 0x6F81,
+ 0x6F80, 0x6F6F, 0x6F5B, 0x6FF3, 0x6F6D, 0x6F82, 0x6F7C, 0x6F58,
+ 0x6F8E, 0x6F91, 0x6FC2, 0x6F66, 0x6FB3, 0x6FA3, 0x6FA1, 0x6FA4,
+ 0x6FB9, 0x6FC6, 0x6FAA, 0x6FDF, 0x6FD5, 0x6FEC, 0x6FD4, 0x6FD8,
+ 0x6FF1, 0x6FEE, 0x6FDB, 0x7009, 0x700B, 0x6FFA, 0x7011, 0x7001,
+ 0x700F, 0x6FFE, 0x701B, 0x701A, 0x6F74, 0x701D, 0x7018, 0x701F,
+ 0x7030, 0x703E, 0x7032, 0x7051, 0x7063, 0x7099, 0x7092, 0x70AF,
+ 0x70F1, 0x70AC, 0x70B8, 0x70B3, 0x70AE, 0x70DF, 0x70CB, 0x70DD,
+ 0x70D9, 0x7109, 0x70FD, 0x711C, 0x7119, 0x7165, 0x7155, 0x7188,
+ 0x7166, 0x7162, 0x714C, 0x7156, 0x716C, 0x718F, 0x71FB, 0x7184,
+ 0x7195, 0x71A8, 0x71AC, 0x71D7, 0x71B9, 0x71BE, 0x71D2, 0x71C9,
+ 0x71D4, 0x71CE, 0x71E0, 0x71EC, 0x71E7, 0x71F5, 0x71FC,
+};
+unsigned short euc_to_utf8_E0[] = {
+ 0x71F9, 0x71FF, 0x720D, 0x7210, 0x721B, 0x7228, 0x722D,
+ 0x722C, 0x7230, 0x7232, 0x723B, 0x723C, 0x723F, 0x7240, 0x7246,
+ 0x724B, 0x7258, 0x7274, 0x727E, 0x7282, 0x7281, 0x7287, 0x7292,
+ 0x7296, 0x72A2, 0x72A7, 0x72B9, 0x72B2, 0x72C3, 0x72C6, 0x72C4,
+ 0x72CE, 0x72D2, 0x72E2, 0x72E0, 0x72E1, 0x72F9, 0x72F7, 0x500F,
+ 0x7317, 0x730A, 0x731C, 0x7316, 0x731D, 0x7334, 0x732F, 0x7329,
+ 0x7325, 0x733E, 0x734E, 0x734F, 0x9ED8, 0x7357, 0x736A, 0x7368,
+ 0x7370, 0x7378, 0x7375, 0x737B, 0x737A, 0x73C8, 0x73B3, 0x73CE,
+ 0x73BB, 0x73C0, 0x73E5, 0x73EE, 0x73DE, 0x74A2, 0x7405, 0x746F,
+ 0x7425, 0x73F8, 0x7432, 0x743A, 0x7455, 0x743F, 0x745F, 0x7459,
+ 0x7441, 0x745C, 0x7469, 0x7470, 0x7463, 0x746A, 0x7476, 0x747E,
+ 0x748B, 0x749E, 0x74A7, 0x74CA, 0x74CF, 0x74D4, 0x73F1,
+};
+unsigned short euc_to_utf8_E1[] = {
+ 0x74E0, 0x74E3, 0x74E7, 0x74E9, 0x74EE, 0x74F2, 0x74F0,
+ 0x74F1, 0x74F8, 0x74F7, 0x7504, 0x7503, 0x7505, 0x750C, 0x750E,
+ 0x750D, 0x7515, 0x7513, 0x751E, 0x7526, 0x752C, 0x753C, 0x7544,
+ 0x754D, 0x754A, 0x7549, 0x755B, 0x7546, 0x755A, 0x7569, 0x7564,
+ 0x7567, 0x756B, 0x756D, 0x7578, 0x7576, 0x7586, 0x7587, 0x7574,
+ 0x758A, 0x7589, 0x7582, 0x7594, 0x759A, 0x759D, 0x75A5, 0x75A3,
+ 0x75C2, 0x75B3, 0x75C3, 0x75B5, 0x75BD, 0x75B8, 0x75BC, 0x75B1,
+ 0x75CD, 0x75CA, 0x75D2, 0x75D9, 0x75E3, 0x75DE, 0x75FE, 0x75FF,
+ 0x75FC, 0x7601, 0x75F0, 0x75FA, 0x75F2, 0x75F3, 0x760B, 0x760D,
+ 0x7609, 0x761F, 0x7627, 0x7620, 0x7621, 0x7622, 0x7624, 0x7634,
+ 0x7630, 0x763B, 0x7647, 0x7648, 0x7646, 0x765C, 0x7658, 0x7661,
+ 0x7662, 0x7668, 0x7669, 0x766A, 0x7667, 0x766C, 0x7670,
+};
+unsigned short euc_to_utf8_E2[] = {
+ 0x7672, 0x7676, 0x7678, 0x767C, 0x7680, 0x7683, 0x7688,
+ 0x768B, 0x768E, 0x7696, 0x7693, 0x7699, 0x769A, 0x76B0, 0x76B4,
+ 0x76B8, 0x76B9, 0x76BA, 0x76C2, 0x76CD, 0x76D6, 0x76D2, 0x76DE,
+ 0x76E1, 0x76E5, 0x76E7, 0x76EA, 0x862F, 0x76FB, 0x7708, 0x7707,
+ 0x7704, 0x7729, 0x7724, 0x771E, 0x7725, 0x7726, 0x771B, 0x7737,
+ 0x7738, 0x7747, 0x775A, 0x7768, 0x776B, 0x775B, 0x7765, 0x777F,
+ 0x777E, 0x7779, 0x778E, 0x778B, 0x7791, 0x77A0, 0x779E, 0x77B0,
+ 0x77B6, 0x77B9, 0x77BF, 0x77BC, 0x77BD, 0x77BB, 0x77C7, 0x77CD,
+ 0x77D7, 0x77DA, 0x77DC, 0x77E3, 0x77EE, 0x77FC, 0x780C, 0x7812,
+ 0x7926, 0x7820, 0x792A, 0x7845, 0x788E, 0x7874, 0x7886, 0x787C,
+ 0x789A, 0x788C, 0x78A3, 0x78B5, 0x78AA, 0x78AF, 0x78D1, 0x78C6,
+ 0x78CB, 0x78D4, 0x78BE, 0x78BC, 0x78C5, 0x78CA, 0x78EC,
+};
+unsigned short euc_to_utf8_E3[] = {
+ 0x78E7, 0x78DA, 0x78FD, 0x78F4, 0x7907, 0x7912, 0x7911,
+ 0x7919, 0x792C, 0x792B, 0x7940, 0x7960, 0x7957, 0x795F, 0x795A,
+ 0x7955, 0x7953, 0x797A, 0x797F, 0x798A, 0x799D, 0x79A7, 0x9F4B,
+ 0x79AA, 0x79AE, 0x79B3, 0x79B9, 0x79BA, 0x79C9, 0x79D5, 0x79E7,
+ 0x79EC, 0x79E1, 0x79E3, 0x7A08, 0x7A0D, 0x7A18, 0x7A19, 0x7A20,
+ 0x7A1F, 0x7980, 0x7A31, 0x7A3B, 0x7A3E, 0x7A37, 0x7A43, 0x7A57,
+ 0x7A49, 0x7A61, 0x7A62, 0x7A69, 0x9F9D, 0x7A70, 0x7A79, 0x7A7D,
+ 0x7A88, 0x7A97, 0x7A95, 0x7A98, 0x7A96, 0x7AA9, 0x7AC8, 0x7AB0,
+ 0x7AB6, 0x7AC5, 0x7AC4, 0x7ABF, 0x9083, 0x7AC7, 0x7ACA, 0x7ACD,
+ 0x7ACF, 0x7AD5, 0x7AD3, 0x7AD9, 0x7ADA, 0x7ADD, 0x7AE1, 0x7AE2,
+ 0x7AE6, 0x7AED, 0x7AF0, 0x7B02, 0x7B0F, 0x7B0A, 0x7B06, 0x7B33,
+ 0x7B18, 0x7B19, 0x7B1E, 0x7B35, 0x7B28, 0x7B36, 0x7B50,
+};
+unsigned short euc_to_utf8_E4[] = {
+ 0x7B7A, 0x7B04, 0x7B4D, 0x7B0B, 0x7B4C, 0x7B45, 0x7B75,
+ 0x7B65, 0x7B74, 0x7B67, 0x7B70, 0x7B71, 0x7B6C, 0x7B6E, 0x7B9D,
+ 0x7B98, 0x7B9F, 0x7B8D, 0x7B9C, 0x7B9A, 0x7B8B, 0x7B92, 0x7B8F,
+ 0x7B5D, 0x7B99, 0x7BCB, 0x7BC1, 0x7BCC, 0x7BCF, 0x7BB4, 0x7BC6,
+ 0x7BDD, 0x7BE9, 0x7C11, 0x7C14, 0x7BE6, 0x7BE5, 0x7C60, 0x7C00,
+ 0x7C07, 0x7C13, 0x7BF3, 0x7BF7, 0x7C17, 0x7C0D, 0x7BF6, 0x7C23,
+ 0x7C27, 0x7C2A, 0x7C1F, 0x7C37, 0x7C2B, 0x7C3D, 0x7C4C, 0x7C43,
+ 0x7C54, 0x7C4F, 0x7C40, 0x7C50, 0x7C58, 0x7C5F, 0x7C64, 0x7C56,
+ 0x7C65, 0x7C6C, 0x7C75, 0x7C83, 0x7C90, 0x7CA4, 0x7CAD, 0x7CA2,
+ 0x7CAB, 0x7CA1, 0x7CA8, 0x7CB3, 0x7CB2, 0x7CB1, 0x7CAE, 0x7CB9,
+ 0x7CBD, 0x7CC0, 0x7CC5, 0x7CC2, 0x7CD8, 0x7CD2, 0x7CDC, 0x7CE2,
+ 0x9B3B, 0x7CEF, 0x7CF2, 0x7CF4, 0x7CF6, 0x7CFA, 0x7D06,
+};
+unsigned short euc_to_utf8_E5[] = {
+ 0x7D02, 0x7D1C, 0x7D15, 0x7D0A, 0x7D45, 0x7D4B, 0x7D2E,
+ 0x7D32, 0x7D3F, 0x7D35, 0x7D46, 0x7D73, 0x7D56, 0x7D4E, 0x7D72,
+ 0x7D68, 0x7D6E, 0x7D4F, 0x7D63, 0x7D93, 0x7D89, 0x7D5B, 0x7D8F,
+ 0x7D7D, 0x7D9B, 0x7DBA, 0x7DAE, 0x7DA3, 0x7DB5, 0x7DC7, 0x7DBD,
+ 0x7DAB, 0x7E3D, 0x7DA2, 0x7DAF, 0x7DDC, 0x7DB8, 0x7D9F, 0x7DB0,
+ 0x7DD8, 0x7DDD, 0x7DE4, 0x7DDE, 0x7DFB, 0x7DF2, 0x7DE1, 0x7E05,
+ 0x7E0A, 0x7E23, 0x7E21, 0x7E12, 0x7E31, 0x7E1F, 0x7E09, 0x7E0B,
+ 0x7E22, 0x7E46, 0x7E66, 0x7E3B, 0x7E35, 0x7E39, 0x7E43, 0x7E37,
+ 0x7E32, 0x7E3A, 0x7E67, 0x7E5D, 0x7E56, 0x7E5E, 0x7E59, 0x7E5A,
+ 0x7E79, 0x7E6A, 0x7E69, 0x7E7C, 0x7E7B, 0x7E83, 0x7DD5, 0x7E7D,
+ 0x8FAE, 0x7E7F, 0x7E88, 0x7E89, 0x7E8C, 0x7E92, 0x7E90, 0x7E93,
+ 0x7E94, 0x7E96, 0x7E8E, 0x7E9B, 0x7E9C, 0x7F38, 0x7F3A,
+};
+unsigned short euc_to_utf8_E6[] = {
+ 0x7F45, 0x7F4C, 0x7F4D, 0x7F4E, 0x7F50, 0x7F51, 0x7F55,
+ 0x7F54, 0x7F58, 0x7F5F, 0x7F60, 0x7F68, 0x7F69, 0x7F67, 0x7F78,
+ 0x7F82, 0x7F86, 0x7F83, 0x7F88, 0x7F87, 0x7F8C, 0x7F94, 0x7F9E,
+ 0x7F9D, 0x7F9A, 0x7FA3, 0x7FAF, 0x7FB2, 0x7FB9, 0x7FAE, 0x7FB6,
+ 0x7FB8, 0x8B71, 0x7FC5, 0x7FC6, 0x7FCA, 0x7FD5, 0x7FD4, 0x7FE1,
+ 0x7FE6, 0x7FE9, 0x7FF3, 0x7FF9, 0x98DC, 0x8006, 0x8004, 0x800B,
+ 0x8012, 0x8018, 0x8019, 0x801C, 0x8021, 0x8028, 0x803F, 0x803B,
+ 0x804A, 0x8046, 0x8052, 0x8058, 0x805A, 0x805F, 0x8062, 0x8068,
+ 0x8073, 0x8072, 0x8070, 0x8076, 0x8079, 0x807D, 0x807F, 0x8084,
+ 0x8086, 0x8085, 0x809B, 0x8093, 0x809A, 0x80AD, 0x5190, 0x80AC,
+ 0x80DB, 0x80E5, 0x80D9, 0x80DD, 0x80C4, 0x80DA, 0x80D6, 0x8109,
+ 0x80EF, 0x80F1, 0x811B, 0x8129, 0x8123, 0x812F, 0x814B,
+};
+unsigned short euc_to_utf8_E7[] = {
+ 0x968B, 0x8146, 0x813E, 0x8153, 0x8151, 0x80FC, 0x8171,
+ 0x816E, 0x8165, 0x8166, 0x8174, 0x8183, 0x8188, 0x818A, 0x8180,
+ 0x8182, 0x81A0, 0x8195, 0x81A4, 0x81A3, 0x815F, 0x8193, 0x81A9,
+ 0x81B0, 0x81B5, 0x81BE, 0x81B8, 0x81BD, 0x81C0, 0x81C2, 0x81BA,
+ 0x81C9, 0x81CD, 0x81D1, 0x81D9, 0x81D8, 0x81C8, 0x81DA, 0x81DF,
+ 0x81E0, 0x81E7, 0x81FA, 0x81FB, 0x81FE, 0x8201, 0x8202, 0x8205,
+ 0x8207, 0x820A, 0x820D, 0x8210, 0x8216, 0x8229, 0x822B, 0x8238,
+ 0x8233, 0x8240, 0x8259, 0x8258, 0x825D, 0x825A, 0x825F, 0x8264,
+ 0x8262, 0x8268, 0x826A, 0x826B, 0x822E, 0x8271, 0x8277, 0x8278,
+ 0x827E, 0x828D, 0x8292, 0x82AB, 0x829F, 0x82BB, 0x82AC, 0x82E1,
+ 0x82E3, 0x82DF, 0x82D2, 0x82F4, 0x82F3, 0x82FA, 0x8393, 0x8303,
+ 0x82FB, 0x82F9, 0x82DE, 0x8306, 0x82DC, 0x8309, 0x82D9,
+};
+unsigned short euc_to_utf8_E8[] = {
+ 0x8335, 0x8334, 0x8316, 0x8332, 0x8331, 0x8340, 0x8339,
+ 0x8350, 0x8345, 0x832F, 0x832B, 0x8317, 0x8318, 0x8385, 0x839A,
+ 0x83AA, 0x839F, 0x83A2, 0x8396, 0x8323, 0x838E, 0x8387, 0x838A,
+ 0x837C, 0x83B5, 0x8373, 0x8375, 0x83A0, 0x8389, 0x83A8, 0x83F4,
+ 0x8413, 0x83EB, 0x83CE, 0x83FD, 0x8403, 0x83D8, 0x840B, 0x83C1,
+ 0x83F7, 0x8407, 0x83E0, 0x83F2, 0x840D, 0x8422, 0x8420, 0x83BD,
+ 0x8438, 0x8506, 0x83FB, 0x846D, 0x842A, 0x843C, 0x855A, 0x8484,
+ 0x8477, 0x846B, 0x84AD, 0x846E, 0x8482, 0x8469, 0x8446, 0x842C,
+ 0x846F, 0x8479, 0x8435, 0x84CA, 0x8462, 0x84B9, 0x84BF, 0x849F,
+ 0x84D9, 0x84CD, 0x84BB, 0x84DA, 0x84D0, 0x84C1, 0x84C6, 0x84D6,
+ 0x84A1, 0x8521, 0x84FF, 0x84F4, 0x8517, 0x8518, 0x852C, 0x851F,
+ 0x8515, 0x8514, 0x84FC, 0x8540, 0x8563, 0x8558, 0x8548,
+};
+unsigned short euc_to_utf8_E9[] = {
+ 0x8541, 0x8602, 0x854B, 0x8555, 0x8580, 0x85A4, 0x8588,
+ 0x8591, 0x858A, 0x85A8, 0x856D, 0x8594, 0x859B, 0x85EA, 0x8587,
+ 0x859C, 0x8577, 0x857E, 0x8590, 0x85C9, 0x85BA, 0x85CF, 0x85B9,
+ 0x85D0, 0x85D5, 0x85DD, 0x85E5, 0x85DC, 0x85F9, 0x860A, 0x8613,
+ 0x860B, 0x85FE, 0x85FA, 0x8606, 0x8622, 0x861A, 0x8630, 0x863F,
+ 0x864D, 0x4E55, 0x8654, 0x865F, 0x8667, 0x8671, 0x8693, 0x86A3,
+ 0x86A9, 0x86AA, 0x868B, 0x868C, 0x86B6, 0x86AF, 0x86C4, 0x86C6,
+ 0x86B0, 0x86C9, 0x8823, 0x86AB, 0x86D4, 0x86DE, 0x86E9, 0x86EC,
+ 0x86DF, 0x86DB, 0x86EF, 0x8712, 0x8706, 0x8708, 0x8700, 0x8703,
+ 0x86FB, 0x8711, 0x8709, 0x870D, 0x86F9, 0x870A, 0x8734, 0x873F,
+ 0x8737, 0x873B, 0x8725, 0x8729, 0x871A, 0x8760, 0x875F, 0x8778,
+ 0x874C, 0x874E, 0x8774, 0x8757, 0x8768, 0x876E, 0x8759,
+};
+unsigned short euc_to_utf8_EA[] = {
+ 0x8753, 0x8763, 0x876A, 0x8805, 0x87A2, 0x879F, 0x8782,
+ 0x87AF, 0x87CB, 0x87BD, 0x87C0, 0x87D0, 0x96D6, 0x87AB, 0x87C4,
+ 0x87B3, 0x87C7, 0x87C6, 0x87BB, 0x87EF, 0x87F2, 0x87E0, 0x880F,
+ 0x880D, 0x87FE, 0x87F6, 0x87F7, 0x880E, 0x87D2, 0x8811, 0x8816,
+ 0x8815, 0x8822, 0x8821, 0x8831, 0x8836, 0x8839, 0x8827, 0x883B,
+ 0x8844, 0x8842, 0x8852, 0x8859, 0x885E, 0x8862, 0x886B, 0x8881,
+ 0x887E, 0x889E, 0x8875, 0x887D, 0x88B5, 0x8872, 0x8882, 0x8897,
+ 0x8892, 0x88AE, 0x8899, 0x88A2, 0x888D, 0x88A4, 0x88B0, 0x88BF,
+ 0x88B1, 0x88C3, 0x88C4, 0x88D4, 0x88D8, 0x88D9, 0x88DD, 0x88F9,
+ 0x8902, 0x88FC, 0x88F4, 0x88E8, 0x88F2, 0x8904, 0x890C, 0x890A,
+ 0x8913, 0x8943, 0x891E, 0x8925, 0x892A, 0x892B, 0x8941, 0x8944,
+ 0x893B, 0x8936, 0x8938, 0x894C, 0x891D, 0x8960, 0x895E,
+};
+unsigned short euc_to_utf8_EB[] = {
+ 0x8966, 0x8964, 0x896D, 0x896A, 0x896F, 0x8974, 0x8977,
+ 0x897E, 0x8983, 0x8988, 0x898A, 0x8993, 0x8998, 0x89A1, 0x89A9,
+ 0x89A6, 0x89AC, 0x89AF, 0x89B2, 0x89BA, 0x89BD, 0x89BF, 0x89C0,
+ 0x89DA, 0x89DC, 0x89DD, 0x89E7, 0x89F4, 0x89F8, 0x8A03, 0x8A16,
+ 0x8A10, 0x8A0C, 0x8A1B, 0x8A1D, 0x8A25, 0x8A36, 0x8A41, 0x8A5B,
+ 0x8A52, 0x8A46, 0x8A48, 0x8A7C, 0x8A6D, 0x8A6C, 0x8A62, 0x8A85,
+ 0x8A82, 0x8A84, 0x8AA8, 0x8AA1, 0x8A91, 0x8AA5, 0x8AA6, 0x8A9A,
+ 0x8AA3, 0x8AC4, 0x8ACD, 0x8AC2, 0x8ADA, 0x8AEB, 0x8AF3, 0x8AE7,
+ 0x8AE4, 0x8AF1, 0x8B14, 0x8AE0, 0x8AE2, 0x8AF7, 0x8ADE, 0x8ADB,
+ 0x8B0C, 0x8B07, 0x8B1A, 0x8AE1, 0x8B16, 0x8B10, 0x8B17, 0x8B20,
+ 0x8B33, 0x97AB, 0x8B26, 0x8B2B, 0x8B3E, 0x8B28, 0x8B41, 0x8B4C,
+ 0x8B4F, 0x8B4E, 0x8B49, 0x8B56, 0x8B5B, 0x8B5A, 0x8B6B,
+};
+unsigned short euc_to_utf8_EC[] = {
+ 0x8B5F, 0x8B6C, 0x8B6F, 0x8B74, 0x8B7D, 0x8B80, 0x8B8C,
+ 0x8B8E, 0x8B92, 0x8B93, 0x8B96, 0x8B99, 0x8B9A, 0x8C3A, 0x8C41,
+ 0x8C3F, 0x8C48, 0x8C4C, 0x8C4E, 0x8C50, 0x8C55, 0x8C62, 0x8C6C,
+ 0x8C78, 0x8C7A, 0x8C82, 0x8C89, 0x8C85, 0x8C8A, 0x8C8D, 0x8C8E,
+ 0x8C94, 0x8C7C, 0x8C98, 0x621D, 0x8CAD, 0x8CAA, 0x8CBD, 0x8CB2,
+ 0x8CB3, 0x8CAE, 0x8CB6, 0x8CC8, 0x8CC1, 0x8CE4, 0x8CE3, 0x8CDA,
+ 0x8CFD, 0x8CFA, 0x8CFB, 0x8D04, 0x8D05, 0x8D0A, 0x8D07, 0x8D0F,
+ 0x8D0D, 0x8D10, 0x9F4E, 0x8D13, 0x8CCD, 0x8D14, 0x8D16, 0x8D67,
+ 0x8D6D, 0x8D71, 0x8D73, 0x8D81, 0x8D99, 0x8DC2, 0x8DBE, 0x8DBA,
+ 0x8DCF, 0x8DDA, 0x8DD6, 0x8DCC, 0x8DDB, 0x8DCB, 0x8DEA, 0x8DEB,
+ 0x8DDF, 0x8DE3, 0x8DFC, 0x8E08, 0x8E09, 0x8DFF, 0x8E1D, 0x8E1E,
+ 0x8E10, 0x8E1F, 0x8E42, 0x8E35, 0x8E30, 0x8E34, 0x8E4A,
+};
+unsigned short euc_to_utf8_ED[] = {
+ 0x8E47, 0x8E49, 0x8E4C, 0x8E50, 0x8E48, 0x8E59, 0x8E64,
+ 0x8E60, 0x8E2A, 0x8E63, 0x8E55, 0x8E76, 0x8E72, 0x8E7C, 0x8E81,
+ 0x8E87, 0x8E85, 0x8E84, 0x8E8B, 0x8E8A, 0x8E93, 0x8E91, 0x8E94,
+ 0x8E99, 0x8EAA, 0x8EA1, 0x8EAC, 0x8EB0, 0x8EC6, 0x8EB1, 0x8EBE,
+ 0x8EC5, 0x8EC8, 0x8ECB, 0x8EDB, 0x8EE3, 0x8EFC, 0x8EFB, 0x8EEB,
+ 0x8EFE, 0x8F0A, 0x8F05, 0x8F15, 0x8F12, 0x8F19, 0x8F13, 0x8F1C,
+ 0x8F1F, 0x8F1B, 0x8F0C, 0x8F26, 0x8F33, 0x8F3B, 0x8F39, 0x8F45,
+ 0x8F42, 0x8F3E, 0x8F4C, 0x8F49, 0x8F46, 0x8F4E, 0x8F57, 0x8F5C,
+ 0x8F62, 0x8F63, 0x8F64, 0x8F9C, 0x8F9F, 0x8FA3, 0x8FAD, 0x8FAF,
+ 0x8FB7, 0x8FDA, 0x8FE5, 0x8FE2, 0x8FEA, 0x8FEF, 0x9087, 0x8FF4,
+ 0x9005, 0x8FF9, 0x8FFA, 0x9011, 0x9015, 0x9021, 0x900D, 0x901E,
+ 0x9016, 0x900B, 0x9027, 0x9036, 0x9035, 0x9039, 0x8FF8,
+};
+unsigned short euc_to_utf8_EE[] = {
+ 0x904F, 0x9050, 0x9051, 0x9052, 0x900E, 0x9049, 0x903E,
+ 0x9056, 0x9058, 0x905E, 0x9068, 0x906F, 0x9076, 0x96A8, 0x9072,
+ 0x9082, 0x907D, 0x9081, 0x9080, 0x908A, 0x9089, 0x908F, 0x90A8,
+ 0x90AF, 0x90B1, 0x90B5, 0x90E2, 0x90E4, 0x6248, 0x90DB, 0x9102,
+ 0x9112, 0x9119, 0x9132, 0x9130, 0x914A, 0x9156, 0x9158, 0x9163,
+ 0x9165, 0x9169, 0x9173, 0x9172, 0x918B, 0x9189, 0x9182, 0x91A2,
+ 0x91AB, 0x91AF, 0x91AA, 0x91B5, 0x91B4, 0x91BA, 0x91C0, 0x91C1,
+ 0x91C9, 0x91CB, 0x91D0, 0x91D6, 0x91DF, 0x91E1, 0x91DB, 0x91FC,
+ 0x91F5, 0x91F6, 0x921E, 0x91FF, 0x9214, 0x922C, 0x9215, 0x9211,
+ 0x925E, 0x9257, 0x9245, 0x9249, 0x9264, 0x9248, 0x9295, 0x923F,
+ 0x924B, 0x9250, 0x929C, 0x9296, 0x9293, 0x929B, 0x925A, 0x92CF,
+ 0x92B9, 0x92B7, 0x92E9, 0x930F, 0x92FA, 0x9344, 0x932E,
+};
+unsigned short euc_to_utf8_EF[] = {
+ 0x9319, 0x9322, 0x931A, 0x9323, 0x933A, 0x9335, 0x933B,
+ 0x935C, 0x9360, 0x937C, 0x936E, 0x9356, 0x93B0, 0x93AC, 0x93AD,
+ 0x9394, 0x93B9, 0x93D6, 0x93D7, 0x93E8, 0x93E5, 0x93D8, 0x93C3,
+ 0x93DD, 0x93D0, 0x93C8, 0x93E4, 0x941A, 0x9414, 0x9413, 0x9403,
+ 0x9407, 0x9410, 0x9436, 0x942B, 0x9435, 0x9421, 0x943A, 0x9441,
+ 0x9452, 0x9444, 0x945B, 0x9460, 0x9462, 0x945E, 0x946A, 0x9229,
+ 0x9470, 0x9475, 0x9477, 0x947D, 0x945A, 0x947C, 0x947E, 0x9481,
+ 0x947F, 0x9582, 0x9587, 0x958A, 0x9594, 0x9596, 0x9598, 0x9599,
+ 0x95A0, 0x95A8, 0x95A7, 0x95AD, 0x95BC, 0x95BB, 0x95B9, 0x95BE,
+ 0x95CA, 0x6FF6, 0x95C3, 0x95CD, 0x95CC, 0x95D5, 0x95D4, 0x95D6,
+ 0x95DC, 0x95E1, 0x95E5, 0x95E2, 0x9621, 0x9628, 0x962E, 0x962F,
+ 0x9642, 0x964C, 0x964F, 0x964B, 0x9677, 0x965C, 0x965E,
+};
+unsigned short euc_to_utf8_F0[] = {
+ 0x965D, 0x965F, 0x9666, 0x9672, 0x966C, 0x968D, 0x9698,
+ 0x9695, 0x9697, 0x96AA, 0x96A7, 0x96B1, 0x96B2, 0x96B0, 0x96B4,
+ 0x96B6, 0x96B8, 0x96B9, 0x96CE, 0x96CB, 0x96C9, 0x96CD, 0x894D,
+ 0x96DC, 0x970D, 0x96D5, 0x96F9, 0x9704, 0x9706, 0x9708, 0x9713,
+ 0x970E, 0x9711, 0x970F, 0x9716, 0x9719, 0x9724, 0x972A, 0x9730,
+ 0x9739, 0x973D, 0x973E, 0x9744, 0x9746, 0x9748, 0x9742, 0x9749,
+ 0x975C, 0x9760, 0x9764, 0x9766, 0x9768, 0x52D2, 0x976B, 0x9771,
+ 0x9779, 0x9785, 0x977C, 0x9781, 0x977A, 0x9786, 0x978B, 0x978F,
+ 0x9790, 0x979C, 0x97A8, 0x97A6, 0x97A3, 0x97B3, 0x97B4, 0x97C3,
+ 0x97C6, 0x97C8, 0x97CB, 0x97DC, 0x97ED, 0x9F4F, 0x97F2, 0x7ADF,
+ 0x97F6, 0x97F5, 0x980F, 0x980C, 0x9838, 0x9824, 0x9821, 0x9837,
+ 0x983D, 0x9846, 0x984F, 0x984B, 0x986B, 0x986F, 0x9870,
+};
+unsigned short euc_to_utf8_F1[] = {
+ 0x9871, 0x9874, 0x9873, 0x98AA, 0x98AF, 0x98B1, 0x98B6,
+ 0x98C4, 0x98C3, 0x98C6, 0x98E9, 0x98EB, 0x9903, 0x9909, 0x9912,
+ 0x9914, 0x9918, 0x9921, 0x991D, 0x991E, 0x9924, 0x9920, 0x992C,
+ 0x992E, 0x993D, 0x993E, 0x9942, 0x9949, 0x9945, 0x9950, 0x994B,
+ 0x9951, 0x9952, 0x994C, 0x9955, 0x9997, 0x9998, 0x99A5, 0x99AD,
+ 0x99AE, 0x99BC, 0x99DF, 0x99DB, 0x99DD, 0x99D8, 0x99D1, 0x99ED,
+ 0x99EE, 0x99F1, 0x99F2, 0x99FB, 0x99F8, 0x9A01, 0x9A0F, 0x9A05,
+ 0x99E2, 0x9A19, 0x9A2B, 0x9A37, 0x9A45, 0x9A42, 0x9A40, 0x9A43,
+ 0x9A3E, 0x9A55, 0x9A4D, 0x9A5B, 0x9A57, 0x9A5F, 0x9A62, 0x9A65,
+ 0x9A64, 0x9A69, 0x9A6B, 0x9A6A, 0x9AAD, 0x9AB0, 0x9ABC, 0x9AC0,
+ 0x9ACF, 0x9AD1, 0x9AD3, 0x9AD4, 0x9ADE, 0x9ADF, 0x9AE2, 0x9AE3,
+ 0x9AE6, 0x9AEF, 0x9AEB, 0x9AEE, 0x9AF4, 0x9AF1, 0x9AF7,
+};
+unsigned short euc_to_utf8_F2[] = {
+ 0x9AFB, 0x9B06, 0x9B18, 0x9B1A, 0x9B1F, 0x9B22, 0x9B23,
+ 0x9B25, 0x9B27, 0x9B28, 0x9B29, 0x9B2A, 0x9B2E, 0x9B2F, 0x9B32,
+ 0x9B44, 0x9B43, 0x9B4F, 0x9B4D, 0x9B4E, 0x9B51, 0x9B58, 0x9B74,
+ 0x9B93, 0x9B83, 0x9B91, 0x9B96, 0x9B97, 0x9B9F, 0x9BA0, 0x9BA8,
+ 0x9BB4, 0x9BC0, 0x9BCA, 0x9BB9, 0x9BC6, 0x9BCF, 0x9BD1, 0x9BD2,
+ 0x9BE3, 0x9BE2, 0x9BE4, 0x9BD4, 0x9BE1, 0x9C3A, 0x9BF2, 0x9BF1,
+ 0x9BF0, 0x9C15, 0x9C14, 0x9C09, 0x9C13, 0x9C0C, 0x9C06, 0x9C08,
+ 0x9C12, 0x9C0A, 0x9C04, 0x9C2E, 0x9C1B, 0x9C25, 0x9C24, 0x9C21,
+ 0x9C30, 0x9C47, 0x9C32, 0x9C46, 0x9C3E, 0x9C5A, 0x9C60, 0x9C67,
+ 0x9C76, 0x9C78, 0x9CE7, 0x9CEC, 0x9CF0, 0x9D09, 0x9D08, 0x9CEB,
+ 0x9D03, 0x9D06, 0x9D2A, 0x9D26, 0x9DAF, 0x9D23, 0x9D1F, 0x9D44,
+ 0x9D15, 0x9D12, 0x9D41, 0x9D3F, 0x9D3E, 0x9D46, 0x9D48,
+};
+unsigned short euc_to_utf8_F3[] = {
+ 0x9D5D, 0x9D5E, 0x9D64, 0x9D51, 0x9D50, 0x9D59, 0x9D72,
+ 0x9D89, 0x9D87, 0x9DAB, 0x9D6F, 0x9D7A, 0x9D9A, 0x9DA4, 0x9DA9,
+ 0x9DB2, 0x9DC4, 0x9DC1, 0x9DBB, 0x9DB8, 0x9DBA, 0x9DC6, 0x9DCF,
+ 0x9DC2, 0x9DD9, 0x9DD3, 0x9DF8, 0x9DE6, 0x9DED, 0x9DEF, 0x9DFD,
+ 0x9E1A, 0x9E1B, 0x9E1E, 0x9E75, 0x9E79, 0x9E7D, 0x9E81, 0x9E88,
+ 0x9E8B, 0x9E8C, 0x9E92, 0x9E95, 0x9E91, 0x9E9D, 0x9EA5, 0x9EA9,
+ 0x9EB8, 0x9EAA, 0x9EAD, 0x9761, 0x9ECC, 0x9ECE, 0x9ECF, 0x9ED0,
+ 0x9ED4, 0x9EDC, 0x9EDE, 0x9EDD, 0x9EE0, 0x9EE5, 0x9EE8, 0x9EEF,
+ 0x9EF4, 0x9EF6, 0x9EF7, 0x9EF9, 0x9EFB, 0x9EFC, 0x9EFD, 0x9F07,
+ 0x9F08, 0x76B7, 0x9F15, 0x9F21, 0x9F2C, 0x9F3E, 0x9F4A, 0x9F52,
+ 0x9F54, 0x9F63, 0x9F5F, 0x9F60, 0x9F61, 0x9F66, 0x9F67, 0x9F6C,
+ 0x9F6A, 0x9F77, 0x9F72, 0x9F76, 0x9F95, 0x9F9C, 0x9FA0,
+};
+unsigned short euc_to_utf8_F4[] = {
+ 0x582F, 0x69C7, 0x9059, 0x7464, 0x51DC, 0x7199, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_F5[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFE33, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFE31, 0, 0,
+ 0, 0, 0, 0, 0, 0xFE30, 0, 0,
+ 0, 0, 0xFE35, 0xFE36, 0xFE39, 0xFE3A, 0, 0,
+ 0xFE37, 0xFE38, 0xFE3F, 0xFE40, 0xFE3D, 0xFE3E, 0xFE41, 0xFE42,
+ 0xFE43, 0xFE44, 0xFE3B, 0xFE3C, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short euc_to_utf8_F9[] = {
+ 0x7E8A, 0x891C, 0x9348, 0x9288, 0x84DC, 0x4FC9, 0x70BB,
+ 0x6631, 0x68C8, 0x92F9, 0x66FB, 0x5F45, 0x4E28, 0x4EE1, 0x4EFC,
+ 0x4F00, 0x4F03, 0x4F39, 0x4F56, 0x4F92, 0x4F8A, 0x4F9A, 0x4F94,
+ 0x4FCD, 0x5040, 0x5022, 0x4FFF, 0x501E, 0x5046, 0x5070, 0x5042,
+ 0x5094, 0x50F4, 0x50D8, 0x514A, 0x5164, 0x519D, 0x51BE, 0x51EC,
+ 0x5215, 0x529C, 0x52A6, 0x52C0, 0x52DB, 0x5300, 0x5307, 0x5324,
+ 0x5372, 0x5393, 0x53B2, 0x53DD, 0xFA0E, 0x549C, 0x548A, 0x54A9,
+ 0x54FF, 0x5586, 0x5759, 0x5765, 0x57AC, 0x57C8, 0x57C7, 0xFA0F,
+ 0xFA10, 0x589E, 0x58B2, 0x590B, 0x5953, 0x595B, 0x595D, 0x5963,
+ 0x59A4, 0x59BA, 0x5B56, 0x5BC0, 0x752F, 0x5BD8, 0x5BEC, 0x5C1E,
+ 0x5CA6, 0x5CBA, 0x5CF5, 0x5D27, 0x5D53, 0xFA11, 0x5D42, 0x5D6D,
+ 0x5DB8, 0x5DB9, 0x5DD0, 0x5F21, 0x5F34, 0x5F67, 0x5FB7,
+};
+unsigned short euc_to_utf8_FA[] = {
+ 0x5FDE, 0x605D, 0x6085, 0x608A, 0x60DE, 0x60D5, 0x6120,
+ 0x60F2, 0x6111, 0x6137, 0x6130, 0x6198, 0x6213, 0x62A6, 0x63F5,
+ 0x6460, 0x649D, 0x64CE, 0x654E, 0x6600, 0x6615, 0x663B, 0x6609,
+ 0x662E, 0x661E, 0x6624, 0x6665, 0x6657, 0x6659, 0xFA12, 0x6673,
+ 0x6699, 0x66A0, 0x66B2, 0x66BF, 0x66FA, 0x670E, 0xF929, 0x6766,
+ 0x67BB, 0x6852, 0x67C0, 0x6801, 0x6844, 0x68CF, 0xFA13, 0x6968,
+ 0xFA14, 0x6998, 0x69E2, 0x6A30, 0x6A6B, 0x6A46, 0x6A73, 0x6A7E,
+ 0x6AE2, 0x6AE4, 0x6BD6, 0x6C3F, 0x6C5C, 0x6C86, 0x6C6F, 0x6CDA,
+ 0x6D04, 0x6D87, 0x6D6F, 0x6D96, 0x6DAC, 0x6DCF, 0x6DF8, 0x6DF2,
+ 0x6DFC, 0x6E39, 0x6E5C, 0x6E27, 0x6E3C, 0x6EBF, 0x6F88, 0x6FB5,
+ 0x6FF5, 0x7005, 0x7007, 0x7028, 0x7085, 0x70AB, 0x710F, 0x7104,
+ 0x715C, 0x7146, 0x7147, 0xFA15, 0x71C1, 0x71FE, 0x72B1,
+};
+unsigned short euc_to_utf8_FB[] = {
+ 0x72BE, 0x7324, 0xFA16, 0x7377, 0x73BD, 0x73C9, 0x73D6,
+ 0x73E3, 0x73D2, 0x7407, 0x73F5, 0x7426, 0x742A, 0x7429, 0x742E,
+ 0x7462, 0x7489, 0x749F, 0x7501, 0x756F, 0x7682, 0x769C, 0x769E,
+ 0x769B, 0x76A6, 0xFA17, 0x7746, 0x52AF, 0x7821, 0x784E, 0x7864,
+ 0x787A, 0x7930, 0xFA18, 0xFA19, 0xFA1A, 0x7994, 0xFA1B, 0x799B,
+ 0x7AD1, 0x7AE7, 0xFA1C, 0x7AEB, 0x7B9E, 0xFA1D, 0x7D48, 0x7D5C,
+ 0x7DB7, 0x7DA0, 0x7DD6, 0x7E52, 0x7F47, 0x7FA1, 0xFA1E, 0x8301,
+ 0x8362, 0x837F, 0x83C7, 0x83F6, 0x8448, 0x84B4, 0x8553, 0x8559,
+ 0x856B, 0xFA1F, 0x85B0, 0xFA20, 0xFA21, 0x8807, 0x88F5, 0x8A12,
+ 0x8A37, 0x8A79, 0x8AA7, 0x8ABE, 0x8ADF, 0xFA22, 0x8AF6, 0x8B53,
+ 0x8B7F, 0x8CF0, 0x8CF4, 0x8D12, 0x8D76, 0xFA23, 0x8ECF, 0xFA24,
+ 0xFA25, 0x9067, 0x90DE, 0xFA26, 0x9115, 0x9127, 0x91DA,
+};
+unsigned short euc_to_utf8_FC[] = {
+ 0x91D7, 0x91DE, 0x91ED, 0x91EE, 0x91E4, 0x91E5, 0x9206,
+ 0x9210, 0x920A, 0x923A, 0x9240, 0x923C, 0x924E, 0x9259, 0x9251,
+ 0x9239, 0x9267, 0x92A7, 0x9277, 0x9278, 0x92E7, 0x92D7, 0x92D9,
+ 0x92D0, 0xFA27, 0x92D5, 0x92E0, 0x92D3, 0x9325, 0x9321, 0x92FB,
+ 0xFA28, 0x931E, 0x92FF, 0x931D, 0x9302, 0x9370, 0x9357, 0x93A4,
+ 0x93C6, 0x93DE, 0x93F8, 0x9431, 0x9445, 0x9448, 0x9592, 0xF9DC,
+ 0xFA29, 0x969D, 0x96AF, 0x9733, 0x973B, 0x9743, 0x974D, 0x974F,
+ 0x9751, 0x9755, 0x9857, 0x9865, 0xFA2A, 0xFA2B, 0x9927, 0xFA2C,
+ 0x999E, 0x9A4E, 0x9AD9, 0x9ADC, 0x9B75, 0x9B72, 0x9B8F, 0x9BB1,
+ 0x9BBB, 0x9C00, 0x9D70, 0x9D6B, 0xFA2D, 0x9E19, 0x9ED1, 0,
+ 0, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176,
+ 0x2177, 0x2178, 0x2179, 0xFFE2, 0xFFE4, 0xFF07, 0xFF02,
+};
+unsigned short euc_to_utf8_1byte[] = {
+ 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
+ 0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F,
+ 0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77,
+ 0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F,
+ 0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87,
+ 0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F,
+ 0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97,
+ 0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x00A9, 0x2122,
+};
+unsigned short * euc_to_utf8_2bytes[] = {
+ euc_to_utf8_A1, euc_to_utf8_A2, euc_to_utf8_A3,
+ euc_to_utf8_A4, euc_to_utf8_A5, euc_to_utf8_A6, euc_to_utf8_A7,
+ euc_to_utf8_A8, euc_to_utf8_A9, euc_to_utf8_AA, euc_to_utf8_AB,
+ euc_to_utf8_AC, euc_to_utf8_AD, euc_to_utf8_AE, euc_to_utf8_AF,
+ euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
+ euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
+ euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
+ euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
+ euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
+ euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
+ euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
+ euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
+ euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
+ euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
+ euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
+ euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
+ euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
+ euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
+ euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
+ euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
+ euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
+ euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
+ 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
+ euc_to_utf8_FC, 0, 0,
+};
+#endif /* UTF8_OUTPUT_ENABLE */
+
+#ifdef UTF8_INPUT_ENABLE
+unsigned short utf8_to_euc_C2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x0E20, 0, 0x2171, 0x2172, 0, 0, 0, 0x2178,
+ 0x212F, 0x0E7D, 0, 0, 0x224C, 0, 0, 0,
+ 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_C3[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x215F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2160,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_CE[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2621, 0x2622, 0x2623, 0x2624, 0x2625, 0x2626, 0x2627,
+ 0x2628, 0x2629, 0x262A, 0x262B, 0x262C, 0x262D, 0x262E, 0x262F,
+ 0x2630, 0x2631, 0, 0x2632, 0x2633, 0x2634, 0x2635, 0x2636,
+ 0x2637, 0x2638, 0, 0, 0, 0, 0, 0,
+ 0, 0x2641, 0x2642, 0x2643, 0x2644, 0x2645, 0x2646, 0x2647,
+ 0x2648, 0x2649, 0x264A, 0x264B, 0x264C, 0x264D, 0x264E, 0x264F,
+};
+unsigned short utf8_to_euc_CF[] = {
+ 0x2650, 0x2651, 0, 0x2652, 0x2653, 0x2654, 0x2655, 0x2656,
+ 0x2657, 0x2658, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_D0[] = {
+ 0, 0x2727, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2721, 0x2722, 0x2723, 0x2724, 0x2725, 0x2726, 0x2728, 0x2729,
+ 0x272A, 0x272B, 0x272C, 0x272D, 0x272E, 0x272F, 0x2730, 0x2731,
+ 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738, 0x2739,
+ 0x273A, 0x273B, 0x273C, 0x273D, 0x273E, 0x273F, 0x2740, 0x2741,
+ 0x2751, 0x2752, 0x2753, 0x2754, 0x2755, 0x2756, 0x2758, 0x2759,
+ 0x275A, 0x275B, 0x275C, 0x275D, 0x275E, 0x275F, 0x2760, 0x2761,
+};
+unsigned short utf8_to_euc_D1[] = {
+ 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x2768, 0x2769,
+ 0x276A, 0x276B, 0x276C, 0x276D, 0x276E, 0x276F, 0x2770, 0x2771,
+ 0, 0x2757, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E280[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x213E, 0, 0, 0, 0x213D, 0x213D, 0x2142, 0,
+ 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
+ 0x2277, 0x2278, 0, 0, 0, 0x2145, 0x2144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
+ 0, 0, 0, 0x2228, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E284[] = {
+ 0, 0, 0, 0x216E, 0, 0, 0, 0,
+ 0, 0x2B37, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2B31, 0, 0, 0x2D62, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2D64, 0x0E7E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2272, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E285[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2D35, 0x2D36, 0x2D37, 0x2D38, 0x2D39, 0x2D3A, 0x2D3B, 0x2D3C,
+ 0x2D3D, 0x2D3E, 0x2A2B, 0x2A2C, 0, 0, 0, 0,
+ 0x7C71, 0x7C72, 0x7C73, 0x7C74, 0x7C75, 0x7C76, 0x7C77, 0x7C78,
+ 0x7C79, 0x7C7A, 0x2A3F, 0x2A40, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E286[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x222B, 0x222C, 0x222A, 0x222D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E287[] = {
+ 0, 0, 0, 0, 0x2C4E, 0x2C4F, 0x2C4D, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x224D, 0, 0x224E, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2C52, 0x2C53,
+ 0x2C51, 0x2C54, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E288[] = {
+ 0x224F, 0, 0x225F, 0x2250, 0, 0, 0, 0x2260,
+ 0x223A, 0, 0, 0x223B, 0, 0, 0, 0,
+ 0, 0x2D74, 0x215D, 0, 0, 0, 0, 0,
+ 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2D78,
+ 0x225C, 0, 0, 0, 0, 0x2142, 0, 0x224A,
+ 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2D73, 0,
+ 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
+ 0, 0, 0, 0, 0, 0x2266, 0, 0,
+};
+unsigned short utf8_to_euc_E289[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2262, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2162, 0x2261, 0, 0, 0, 0, 0x2165, 0x2166,
+ 0, 0, 0x2263, 0x2264, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E28A[] = {
+ 0, 0, 0x223E, 0x223F, 0, 0, 0x223C, 0x223D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x225D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2D79,
+};
+unsigned short utf8_to_euc_E28C[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x225E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E291[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2D21, 0x2D22, 0x2D23, 0x2D24, 0x2D25, 0x2D26, 0x2D27, 0x2D28,
+ 0x2D29, 0x2D2A, 0x2D2B, 0x2D2C, 0x2D2D, 0x2D2E, 0x2D2F, 0x2D30,
+ 0x2D31, 0x2D32, 0x2D33, 0x2D34, 0x293F, 0x2940, 0x2941, 0x2942,
+ 0x2943, 0x2944, 0x2945, 0x2946, 0x2947, 0x2948, 0x2949, 0x294A,
+};
+unsigned short utf8_to_euc_E292[] = {
+ 0x294B, 0x294C, 0x294D, 0x294E, 0x294F, 0x2950, 0x2951, 0x2952,
+ 0x2972, 0x2973, 0x2974, 0x2975, 0x2976, 0x2977, 0x2978, 0x2979,
+ 0x297A, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2A5D, 0x2A5E, 0x2A5F, 0x2A60,
+ 0x2A61, 0x2A62, 0x2A63, 0x2A64, 0x2A65, 0x2A66, 0x2A67, 0x2A68,
+ 0x2A69, 0x2A6A, 0x2A6B, 0x2A6C, 0x2A6D, 0x2A6E, 0x2A6F, 0x2A70,
+ 0x2A71, 0x2A72, 0x2A73, 0x2A74, 0x2A75, 0x2A76, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E294[] = {
+ 0x2821, 0x282C, 0x2822, 0x282D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2823, 0, 0, 0x282E,
+ 0x2824, 0, 0, 0x282F, 0x2826, 0, 0, 0x2831,
+ 0x2825, 0, 0, 0x2830, 0x2827, 0x283C, 0, 0,
+ 0x2837, 0, 0, 0x2832, 0x2829, 0x283E, 0, 0,
+ 0x2839, 0, 0, 0x2834, 0x2828, 0, 0, 0x2838,
+ 0x283D, 0, 0, 0x2833, 0x282A, 0, 0, 0x283A,
+ 0x283F, 0, 0, 0x2835, 0x282B, 0, 0, 0x283B,
+};
+unsigned short utf8_to_euc_E295[] = {
+ 0, 0, 0x2840, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2836, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E296[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2223, 0x2222, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2225, 0x2224, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2227, 0x2226, 0, 0,
+};
+unsigned short utf8_to_euc_E297[] = {
+ 0, 0, 0, 0, 0, 0, 0x2221, 0x217E,
+ 0, 0, 0, 0x217B, 0, 0, 0x217D, 0x217C,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x227E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E298[] = {
+ 0, 0, 0, 0, 0, 0x217A, 0x2179, 0,
+ 0, 0, 0, 0, 0, 0, 0x2C36, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2C4A, 0x2C4B, 0x2C49, 0x2C4C,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E299[] = {
+ 0x216A, 0, 0x2169, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2C25, 0x2C23, 0x2C24, 0x2C26, 0x2C21, 0x2C27, 0x2C28, 0x2C22,
+ 0, 0, 0x2276, 0, 0, 0x2275, 0, 0x2274,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E29D[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x295D, 0x295E,
+ 0x295F, 0x2960, 0x2961, 0x2962, 0x2963, 0x2964, 0x2965, 0,
+};
+unsigned short utf8_to_euc_E380[] = {
+ 0x2121, 0x2122, 0x2123, 0x2137, 0x2C37, 0x2139, 0x213A, 0x213B,
+ 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
+ 0x215A, 0x215B, 0x2229, 0x222E, 0x214C, 0x214D, 0, 0,
+ 0, 0, 0, 0, 0x2141, 0x2D60, 0, 0x2D61,
+ 0x2C35, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E381[] = {
+ 0, 0x2421, 0x2422, 0x2423, 0x2424, 0x2425, 0x2426, 0x2427,
+ 0x2428, 0x2429, 0x242A, 0x242B, 0x242C, 0x242D, 0x242E, 0x242F,
+ 0x2430, 0x2431, 0x2432, 0x2433, 0x2434, 0x2435, 0x2436, 0x2437,
+ 0x2438, 0x2439, 0x243A, 0x243B, 0x243C, 0x243D, 0x243E, 0x243F,
+ 0x2440, 0x2441, 0x2442, 0x2443, 0x2444, 0x2445, 0x2446, 0x2447,
+ 0x2448, 0x2449, 0x244A, 0x244B, 0x244C, 0x244D, 0x244E, 0x244F,
+ 0x2450, 0x2451, 0x2452, 0x2453, 0x2454, 0x2455, 0x2456, 0x2457,
+ 0x2458, 0x2459, 0x245A, 0x245B, 0x245C, 0x245D, 0x245E, 0x245F,
+};
+unsigned short utf8_to_euc_E382[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
+ 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E, 0x246F,
+ 0x2470, 0x2471, 0x2472, 0x2473, 0x2F49, 0, 0, 0,
+ 0, 0x0E5E, 0x0E5F, 0x212B, 0x212C, 0x2135, 0x2136, 0,
+ 0, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
+ 0x2528, 0x2529, 0x252A, 0x252B, 0x252C, 0x252D, 0x252E, 0x252F,
+ 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
+ 0x2538, 0x2539, 0x253A, 0x253B, 0x253C, 0x253D, 0x253E, 0x253F,
+};
+unsigned short utf8_to_euc_E383[] = {
+ 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547,
+ 0x2548, 0x2549, 0x254A, 0x254B, 0x254C, 0x254D, 0x254E, 0x254F,
+ 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557,
+ 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, 0x255F,
+ 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
+ 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x256D, 0x256E, 0x256F,
+ 0x2570, 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576, 0x2F4B,
+ 0x2F4C, 0x2F4D, 0x2F4E, 0x2126, 0x213C, 0x2133, 0x2134, 0,
+};
+unsigned short utf8_to_euc_E388[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2D22, 0x2D23, 0x2D24, 0x2D25, 0x2D26, 0x2D27,
+ 0x2D21, 0x2D6A, 0x2D6B, 0x2D34, 0x2D30, 0x2D35, 0x2D33, 0x2D29,
+ 0x2D39, 0x2D6C, 0x2D2D, 0x2D32, 0x2D36, 0x2D37, 0x2D2F, 0x2D38,
+};
+unsigned short utf8_to_euc_E389[] = {
+ 0x2D28, 0, 0x2D2A, 0x2D2B, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E38A[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2D79, 0,
+ 0x2D7B, 0x2D7E, 0, 0, 0, 0x2D7A, 0x2D7C, 0,
+ 0, 0, 0, 0, 0x2D65, 0x2D66, 0x2D67, 0x2D68,
+ 0x2D69, 0x2D78, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E38C[] = {
+ 0x2E3F, 0, 0, 0x2D46, 0, 0x2E26, 0, 0,
+ 0, 0, 0, 0, 0, 0x2D4A, 0, 0,
+ 0, 0, 0, 0, 0x2D41, 0x2E2C, 0x2E25, 0,
+ 0x2D44, 0, 0, 0, 0, 0, 0x2E40, 0,
+ 0, 0, 0x2D42, 0x2D4C, 0, 0, 0x2D4B, 0x2D45,
+ 0, 0, 0x2E41, 0x2D4D, 0, 0, 0, 0,
+ 0, 0x2E42, 0, 0x2E27, 0, 0, 0x2D47, 0,
+ 0, 0x2E30, 0, 0x2D4F, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E38D[] = {
+ 0, 0, 0x2E33, 0, 0, 0, 0, 0x2E43,
+ 0, 0x2D40, 0x2D4E, 0, 0, 0x2D43, 0x2E28, 0,
+ 0, 0x2D48, 0, 0, 0, 0, 0, 0x2D49,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2D5F, 0x2D6F, 0x2D6E, 0x2D6D, 0x2E7C,
+};
+unsigned short utf8_to_euc_E38E[] = {
+ 0, 0, 0, 0, 0, 0x2B3B, 0x2B3C, 0x2B3D,
+ 0, 0, 0, 0, 0, 0, 0x2D53, 0x2D54,
+ 0x2B3A, 0, 0, 0, 0, 0, 0x2B2F, 0x2B30,
+ 0x2B32, 0, 0, 0, 0x2D50, 0x2D51, 0x2D52, 0x2B22,
+ 0x2B24, 0x2D56, 0x2B2A, 0, 0x2B25, 0x2B28, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2B36, 0x2B35, 0x2B34, 0x2B33, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E38F[] = {
+ 0, 0, 0, 0, 0x2D55, 0, 0, 0,
+ 0, 0, 0, 0x2B39, 0, 0x2D63, 0, 0,
+ 0, 0, 0, 0, 0x2B38, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E4B8[] = {
+ 0x306C, 0x437A, 0, 0x3C37, 0, 0, 0, 0x4B7C,
+ 0x3E66, 0x3B30, 0x3E65, 0x323C, 0, 0x4954, 0x4D3F, 0,
+ 0x5022, 0x312F, 0, 0, 0x336E, 0x5023, 0x4024, 0x5242,
+ 0x3556, 0x4A3A, 0, 0, 0, 0, 0x3E67, 0,
+ 0, 0x4E3E, 0, 0, 0, 0, 0x4A42, 0,
+ 0x792D, 0, 0x5024, 0, 0, 0x4366, 0, 0,
+ 0, 0x5025, 0x367A, 0, 0, 0, 0x5026, 0,
+ 0x345D, 0x4330, 0, 0x3C67, 0x5027, 0, 0, 0x5028,
+};
+unsigned short utf8_to_euc_E4B9[] = {
+ 0, 0, 0x5029, 0x4735, 0, 0x3557, 0, 0,
+ 0, 0, 0, 0x4737, 0, 0x4663, 0x3843, 0x4B33,
+ 0, 0, 0, 0, 0, 0x6949, 0x502A, 0x3E68,
+ 0x502B, 0x3235, 0, 0, 0, 0x3665, 0x3870, 0x4C69,
+ 0, 0, 0x5626, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x4D70, 0, 0x467D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3425, 0,
+};
+unsigned short utf8_to_euc_E4BA[] = {
+ 0x3535, 0, 0x502C, 0, 0, 0x502D, 0x4E3B, 0,
+ 0x4D3D, 0x4168, 0x502F, 0x3B76, 0x4673, 0, 0x5032, 0,
+ 0, 0x313E, 0x385F, 0, 0x385E, 0x3066, 0, 0,
+ 0x4F4B, 0x4F4A, 0, 0x3A33, 0x3021, 0, 0x5033, 0x5034,
+ 0x5035, 0x4B34, 0x5036, 0, 0x3872, 0x3067, 0x4B72, 0,
+ 0x357C, 0, 0, 0x357D, 0x357E, 0x4462, 0x4E3C, 0,
+ 0x5037, 0, 0, 0x5038, 0, 0, 0x5039, 0,
+ 0, 0, 0x3F4D, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E4BB[] = {
+ 0x3D3A, 0x3F4E, 0x503E, 0, 0x503C, 0, 0x503D, 0x3558,
+ 0, 0, 0x3A23, 0x3270, 0, 0x503B, 0x503A, 0x4A29,
+ 0, 0, 0, 0, 0x3B46, 0x3B45, 0x423E, 0x503F,
+ 0x4955, 0x4067, 0, 0, 0, 0x2138, 0x5040, 0x5042,
+ 0, 0x792E, 0, 0x4265, 0x4E61, 0x304A, 0, 0,
+ 0, 0, 0, 0, 0, 0x5041, 0x323E, 0,
+ 0x3644, 0, 0x4367, 0, 0, 0, 0x376F, 0x5043,
+ 0, 0, 0, 0x4724, 0x792F, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E4BC[] = {
+ 0x7930, 0x346B, 0, 0x7931, 0, 0, 0, 0,
+ 0, 0x5044, 0x304B, 0, 0, 0x3860, 0x346C, 0x497A,
+ 0x4832, 0x3559, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3271, 0, 0x5067, 0x4541, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x476C,
+ 0x5046, 0, 0, 0, 0x483C, 0, 0x4E62, 0,
+ 0x3F2D, 0x7932, 0x3B47, 0, 0x3B77, 0x3240, 0, 0,
+};
+unsigned short utf8_to_euc_E4BD[] = {
+ 0, 0, 0, 0x4451, 0, 0, 0x4322, 0x504A,
+ 0, 0, 0, 0, 0, 0x304C, 0x4463, 0x3D3B,
+ 0x3A34, 0x4D24, 0, 0x424E, 0, 0x323F, 0x7933, 0x5049,
+ 0, 0x4D3E, 0x5045, 0x5047, 0x3A6E, 0x5048, 0x5524, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5050, 0, 0, 0, 0, 0, 0x5053,
+ 0x5051, 0, 0, 0x3242, 0, 0x4A3B, 0x504B, 0,
+ 0, 0, 0, 0x504F, 0x3873, 0, 0, 0x3B48,
+};
+unsigned short utf8_to_euc_E4BE[] = {
+ 0, 0, 0, 0x3426, 0, 0, 0x5054, 0,
+ 0x504C, 0, 0x7935, 0x4E63, 0, 0x3B78, 0, 0x504D,
+ 0, 0x5052, 0x7934, 0, 0x7937, 0, 0x5055, 0,
+ 0x504E, 0, 0x7936, 0x3621, 0, 0x304D, 0, 0,
+ 0x3622, 0x3241, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5525, 0, 0x4B79, 0x496E, 0x3874,
+ 0, 0, 0, 0, 0, 0x3F2F, 0x4E37, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4A58,
+};
+unsigned short utf8_to_euc_E4BF[] = {
+ 0, 0, 0x3738, 0x4225, 0x3264, 0, 0, 0,
+ 0, 0x7926, 0x3D53, 0, 0, 0x7938, 0x5059, 0,
+ 0x505E, 0x505C, 0, 0, 0x5057, 0, 0, 0x422F,
+ 0x505A, 0, 0x505D, 0x505B, 0, 0x4A5D, 0, 0x5058,
+ 0, 0x3F2E, 0, 0x4B73, 0x505F, 0x5060, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3D24, 0x506D,
+ 0, 0, 0, 0x4750, 0, 0x4936, 0x5068, 0,
+ 0x4A70, 0, 0x3236, 0, 0, 0, 0x506C, 0x793B,
+};
+unsigned short utf8_to_euc_E580[] = {
+ 0, 0, 0, 0, 0, 0x5066, 0x506F, 0,
+ 0, 0x4152, 0, 0x3844, 0, 0x475C, 0, 0x6047,
+ 0, 0x506E, 0x455D, 0, 0x5063, 0, 0x3876, 0,
+ 0, 0x3875, 0x5061, 0, 0, 0, 0x793C, 0x3C5A,
+ 0, 0x5069, 0x793A, 0x4A6F, 0x434D, 0x5065, 0x3771, 0,
+ 0x5062, 0x506A, 0x5064, 0x4E51, 0x506B, 0x4F41, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3666, 0,
+ 0, 0x3770, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E581[] = {
+ 0x7939, 0, 0x793F, 0x5070, 0, 0, 0x793D, 0x5071,
+ 0x5075, 0x304E, 0, 0, 0, 0, 0, 0x4A50,
+ 0x5074, 0, 0, 0, 0, 0x5073, 0x5077, 0,
+ 0, 0, 0x5076, 0, 0x4464, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x3772, 0, 0,
+ 0, 0, 0, 0, 0x5078, 0, 0, 0,
+ 0x793E, 0, 0x3C45, 0, 0x4226, 0x4465, 0x3676, 0,
+ 0x5079, 0, 0, 0, 0, 0x3536, 0, 0,
+};
+unsigned short utf8_to_euc_E582[] = {
+ 0x507A, 0, 0, 0, 0, 0x507C, 0, 0,
+ 0, 0, 0, 0, 0, 0x4B35, 0, 0,
+ 0, 0x3766, 0, 0, 0x7940, 0, 0, 0,
+ 0x3B31, 0x4877, 0x507B, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x3A45, 0x4D43, 0, 0,
+ 0, 0, 0x507E, 0x5123, 0x507D, 0x3A44, 0, 0x3D7D,
+ 0, 0, 0, 0, 0, 0, 0x3739, 0,
+};
+unsigned short utf8_to_euc_E583[] = {
+ 0, 0, 0x5124, 0, 0, 0x364F, 0, 0,
+ 0, 0x5121, 0x5122, 0, 0, 0x462F, 0, 0x417C,
+ 0, 0x3623, 0, 0, 0, 0x4B4D, 0x5125, 0,
+ 0x7942, 0, 0x4E3D, 0, 0, 0, 0x5126, 0,
+ 0, 0, 0, 0x5129, 0, 0x5127, 0, 0x414E,
+ 0, 0, 0, 0, 0, 0x5128, 0x512A, 0,
+ 0, 0, 0, 0, 0x7941, 0x512C, 0, 0,
+ 0, 0x512B, 0, 0x4A48, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E584[] = {
+ 0x3537, 0x512E, 0x512F, 0, 0x322F, 0, 0, 0,
+ 0, 0x512D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3C74, 0, 0x5132, 0x5131, 0x5130, 0,
+ 0x5056, 0, 0x5133, 0, 0, 0, 0, 0x3D7E,
+ 0, 0x5134, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4D25, 0, 0, 0, 0, 0,
+ 0, 0, 0x4C59, 0, 0, 0, 0, 0x5136,
+ 0, 0, 0x5135, 0x5138, 0x5137, 0, 0, 0x5139,
+};
+unsigned short utf8_to_euc_E585[] = {
+ 0x513A, 0x3074, 0, 0x3835, 0x373B, 0x3D3C, 0x437B, 0x3624,
+ 0x4068, 0x3877, 0x7943, 0x396E, 0x513C, 0x4C48, 0x4546, 0,
+ 0x3B79, 0, 0x513B, 0, 0x513D, 0, 0, 0,
+ 0, 0, 0x455E, 0, 0x3375, 0, 0, 0,
+ 0, 0, 0x513E, 0, 0x7944, 0x467E, 0, 0,
+ 0x4134, 0x5140, 0x5141, 0x482C, 0x3878, 0x4F3B, 0x5142, 0,
+ 0, 0x3626, 0, 0, 0, 0x4A3C, 0x4236, 0x3671,
+ 0x4535, 0, 0, 0, 0x3773, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E586[] = {
+ 0x5143, 0, 0x5144, 0, 0, 0x4662, 0x315F, 0,
+ 0, 0x5147, 0x3A7D, 0, 0x5146, 0x3A46, 0, 0x5148,
+ 0x666E, 0x5149, 0x4B41, 0x514A, 0, 0x514B, 0x514C, 0x3E69,
+ 0, 0x3C4C, 0, 0, 0, 0x7945, 0, 0,
+ 0x3427, 0, 0x514F, 0, 0x514D, 0x4C3D, 0x514E, 0,
+ 0x495A, 0x5150, 0x5151, 0x5152, 0x455F, 0, 0, 0,
+ 0x5156, 0x5154, 0x5155, 0x5153, 0x3A63, 0x5157, 0x4C6A, 0x4E64,
+ 0, 0, 0, 0, 0, 0x5158, 0x7946, 0,
+};
+unsigned short utf8_to_euc_E587[] = {
+ 0, 0, 0, 0, 0x4028, 0x5159, 0x3D5A, 0,
+ 0, 0x515A, 0, 0x437C, 0x4E3F, 0x4560, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5245, 0,
+ 0, 0, 0, 0x515B, 0x7425, 0x3645, 0, 0,
+ 0x515C, 0x4B5E, 0, 0, 0, 0, 0x3D68, 0x427C,
+ 0, 0x515E, 0x4664, 0, 0x7947, 0x515F, 0, 0,
+ 0x5160, 0x332E, 0, 0, 0, 0x5161, 0x3627, 0,
+ 0x464C, 0x317A, 0x3D50, 0, 0, 0x4821, 0x5162, 0,
+};
+unsigned short utf8_to_euc_E588[] = {
+ 0x4561, 0, 0, 0x3F4F, 0x5163, 0, 0x4A2C, 0x405A,
+ 0x3422, 0, 0x3429, 0x5164, 0, 0, 0x5166, 0,
+ 0, 0x373A, 0, 0, 0x5165, 0x7948, 0, 0x4E73,
+ 0, 0, 0, 0, 0, 0x3D69, 0, 0,
+ 0, 0, 0, 0, 0x483D, 0x4A4C, 0, 0x5167,
+ 0, 0x4D78, 0x5168, 0, 0, 0, 0x5169, 0,
+ 0x457E, 0, 0, 0x516A, 0, 0, 0x4029, 0x3A7E,
+ 0x3774, 0x516B, 0x3B49, 0x396F, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E589[] = {
+ 0, 0, 0, 0x4466, 0x516D, 0, 0, 0x4227,
+ 0, 0, 0x3A6F, 0x516E, 0x516F, 0x4130, 0, 0x516C,
+ 0, 0, 0, 0, 0x5171, 0, 0x4B36, 0,
+ 0, 0, 0, 0x3964, 0, 0, 0x5170, 0,
+ 0, 0, 0, 0x3775, 0x3A5E, 0x476D, 0, 0,
+ 0, 0x5174, 0x5172, 0, 0, 0, 0, 0x497B,
+ 0x3E6A, 0x517B, 0x3364, 0x5175, 0x5173, 0x414F, 0, 0,
+ 0, 0, 0, 0, 0, 0x5177, 0, 0x5176,
+};
+unsigned short utf8_to_euc_E58A[] = {
+ 0, 0, 0, 0x3344, 0, 0, 0, 0x3760,
+ 0x517C, 0x4E2D, 0, 0, 0, 0x5178, 0, 0,
+ 0, 0x517D, 0x517A, 0, 0x5179, 0, 0, 0,
+ 0, 0, 0, 0x4E4F, 0x7949, 0, 0, 0x3879,
+ 0x3243, 0, 0, 0x4E74, 0, 0, 0x794A, 0,
+ 0, 0x3D75, 0x4558, 0x3965, 0x5222, 0x5223, 0, 0x7B3C,
+ 0, 0x4E65, 0, 0, 0x4F2B, 0x5225, 0, 0,
+ 0, 0x387A, 0, 0, 0x5224, 0, 0x332F, 0,
+};
+unsigned short utf8_to_euc_E58B[] = {
+ 0x794B, 0x5226, 0, 0x4B56, 0, 0x443C, 0, 0x4D26,
+ 0, 0x4A59, 0, 0, 0, 0x5227, 0, 0,
+ 0, 0, 0x7055, 0, 0, 0x4630, 0, 0x5228,
+ 0x342A, 0x4C33, 0, 0x794C, 0, 0x3E21, 0x5229, 0x4A67,
+ 0x522D, 0, 0x402A, 0x522A, 0x3650, 0, 0x522B, 0x342B,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x372E, 0x522E, 0, 0x522F, 0, 0,
+ 0x5230, 0x5231, 0x3C5B, 0, 0, 0, 0x387B, 0x4C5E,
+};
+unsigned short utf8_to_euc_E58C[] = {
+ 0x794D, 0x4C68, 0x4677, 0, 0, 0x4A71, 0x5232, 0x794E,
+ 0x5233, 0, 0, 0, 0, 0x5235, 0, 0x5237,
+ 0x5236, 0, 0, 0, 0, 0x5238, 0x323D, 0x4B4C,
+ 0, 0x3A7C, 0x5239, 0, 0, 0x4159, 0, 0,
+ 0x3E22, 0x3629, 0, 0x523A, 0x794F, 0, 0, 0,
+ 0, 0, 0x485B, 0, 0, 0, 0, 0x523B,
+ 0, 0x523C, 0, 0x523D, 0, 0, 0, 0,
+ 0x523E, 0x4924, 0x3668, 0x3065, 0, 0, 0, 0x463F,
+};
+unsigned short utf8_to_euc_E58D[] = {
+ 0x523F, 0x3D3D, 0, 0x4069, 0, 0x5241, 0x5240, 0x3E23,
+ 0x3861, 0x5243, 0x483E, 0, 0, 0x5244, 0, 0,
+ 0, 0x485C, 0x4234, 0x426E, 0x3628, 0, 0, 0x466E,
+ 0x4331, 0, 0x476E, 0, 0x4B4E, 0, 0x5246, 0,
+ 0x406A, 0, 0, 0, 0, 0, 0x3735, 0,
+ 0, 0x5247, 0, 0, 0, 0, 0x5248, 0x312C,
+ 0x3075, 0x346D, 0x7950, 0x4228, 0x3551, 0x4D71, 0, 0x524B,
+ 0x3237, 0, 0, 0x524A, 0, 0, 0, 0x362A,
+};
+unsigned short utf8_to_euc_E58E[] = {
+ 0, 0, 0x524C, 0, 0x4C71, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x7951, 0, 0, 0x524D, 0,
+ 0x4E52, 0, 0x387C, 0, 0, 0, 0, 0x3836,
+ 0x524E, 0, 0, 0, 0, 0x5250, 0x524F, 0,
+ 0x3F5F, 0x3139, 0, 0, 0, 0x315E, 0x5251, 0,
+ 0x5252, 0, 0x7952, 0x3837, 0, 0, 0x5253, 0,
+ 0, 0, 0, 0x356E, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E58F[] = {
+ 0, 0, 0x3B32, 0x5254, 0, 0, 0, 0,
+ 0x4B74, 0x3A35, 0x355A, 0x4D27, 0x4150, 0x483F, 0x3C7D, 0,
+ 0, 0, 0, 0, 0x3D47, 0, 0x3C68, 0x3C75,
+ 0, 0x3D76, 0, 0x4840, 0, 0x7953, 0, 0x5257,
+ 0, 0x3143, 0x4151, 0x387D, 0x3845, 0x3667, 0, 0,
+ 0x525B, 0x4321, 0x427E, 0x362B, 0x3E24, 0x525C, 0x525A, 0x3244,
+ 0x4266, 0x3C38, 0x3B4B, 0x3126, 0, 0, 0x3370, 0x3966,
+ 0x3B4A, 0, 0x525D, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E590[] = {
+ 0, 0x525E, 0, 0x3549, 0x3346, 0, 0, 0,
+ 0x3967, 0x3548, 0x445F, 0x3125, 0x4631, 0x4C3E, 0x3921, 0x4D79,
+ 0x4547, 0x387E, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x372F, 0, 0x5267, 0, 0x3663,
+ 0x4B4A, 0, 0, 0, 0, 0, 0x485D, 0,
+ 0, 0x5266, 0, 0x345E, 0x5261, 0x5262, 0x5264, 0,
+ 0, 0, 0, 0, 0, 0, 0x5265, 0,
+ 0x355B, 0x3F61, 0, 0x4A2D, 0x5263, 0x525F, 0x3863, 0,
+};
+unsigned short utf8_to_euc_E591[] = {
+ 0x5260, 0, 0x4F24, 0, 0, 0, 0x4A72, 0,
+ 0x4468, 0x3862, 0x3970, 0, 0, 0, 0x5268, 0,
+ 0, 0x465D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x526C,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x3C7E, 0, 0x3C76, 0, 0, 0, 0, 0,
+ 0x526F, 0x526D, 0, 0x4C23, 0, 0x526A, 0x5273, 0x526E,
+ 0, 0, 0, 0x5271, 0x3846, 0x4C3F, 0, 0,
+};
+unsigned short utf8_to_euc_E592[] = {
+ 0x5272, 0, 0, 0, 0x5274, 0, 0x5276, 0,
+ 0, 0, 0x7956, 0x3A70, 0x4F42, 0, 0x526B, 0x5269,
+ 0x5275, 0, 0x5270, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7955, 0, 0, 0,
+ 0, 0, 0x5278, 0, 0x5323, 0x527A, 0, 0,
+ 0x527E, 0x7957, 0, 0x5321, 0x527B, 0, 0, 0x533E,
+ 0, 0, 0x3A69, 0x3331, 0, 0, 0, 0,
+ 0x5279, 0, 0, 0, 0x5325, 0x3076, 0x5324, 0,
+};
+unsigned short utf8_to_euc_E593[] = {
+ 0x3025, 0x494A, 0x5322, 0, 0x527C, 0, 0, 0x5277,
+ 0x527D, 0x3A48, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5326, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3077, 0x532F, 0, 0, 0x5327, 0x5328, 0,
+ 0x3E25, 0x4B69, 0, 0, 0, 0x532D, 0x532C, 0,
+ 0, 0, 0x452F, 0, 0, 0, 0, 0,
+ 0, 0, 0x532E, 0, 0, 0x532B, 0, 0x7958,
+};
+unsigned short utf8_to_euc_E594[] = {
+ 0, 0, 0, 0, 0x3134, 0, 0x3A36, 0x3F30,
+ 0, 0, 0, 0, 0, 0, 0, 0x5329,
+ 0x4562, 0, 0, 0, 0x532A, 0, 0x3022, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5334, 0x4D23,
+ 0, 0x3E27, 0, 0x533A, 0, 0, 0, 0,
+ 0x5339, 0x5330, 0, 0, 0, 0, 0x4243, 0,
+};
+unsigned short utf8_to_euc_E595[] = {
+ 0x5331, 0, 0, 0, 0x426F, 0x5336, 0x3E26, 0,
+ 0, 0, 0, 0, 0x5333, 0, 0, 0x4C64,
+ 0, 0, 0, 0x373C, 0, 0, 0x5337, 0x5338,
+ 0, 0, 0, 0, 0x5335, 0x533B, 0, 0,
+ 0, 0, 0, 0x5332, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5341, 0x5346, 0, 0x5342, 0,
+};
+unsigned short utf8_to_euc_E596[] = {
+ 0x533D, 0, 0, 0x5347, 0x4131, 0, 0x7959, 0x5349,
+ 0, 0x3922, 0x533F, 0x437D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5343, 0x533C, 0x342D, 0, 0x346E, 0x3365, 0x5344, 0x5340,
+ 0, 0, 0, 0, 0, 0, 0, 0x3776,
+ 0x534A, 0x5348, 0x4153, 0x354A, 0x362C, 0, 0x5345, 0,
+ 0x3674, 0, 0, 0, 0, 0, 0x3144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E597[] = {
+ 0, 0, 0, 0, 0x534E, 0x534C, 0, 0x5427,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5351, 0, 0, 0,
+ 0, 0, 0x534B, 0, 0x534F, 0, 0, 0x534D,
+ 0, 0, 0, 0x3B4C, 0x5350, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x5353,
+ 0, 0x5358, 0, 0, 0, 0x5356, 0x5355, 0,
+};
+unsigned short utf8_to_euc_E598[] = {
+ 0, 0, 0, 0, 0, 0, 0x4332, 0,
+ 0, 0x3245, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5352, 0, 0x5354, 0x3E28,
+ 0x3133, 0, 0, 0x5357, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x325E, 0, 0, 0, 0, 0, 0x5362,
+ 0, 0x3E7C, 0x535E, 0, 0x535C, 0, 0x535D, 0,
+ 0x535F, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E599[] = {
+ 0, 0, 0x313D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x4139, 0, 0x5359, 0,
+ 0x535A, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x337A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5361, 0, 0, 0,
+ 0x346F, 0, 0x5364, 0x5360, 0x5363, 0, 0, 0,
+ 0, 0, 0, 0, 0x4A2E, 0, 0, 0,
+ 0x4655, 0, 0x4838, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E59A[] = {
+ 0x5366, 0, 0, 0, 0, 0, 0x5365, 0x3345,
+ 0, 0, 0x5367, 0, 0, 0, 0, 0x536A,
+ 0, 0, 0, 0, 0x5369, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5368, 0, 0x4739, 0, 0, 0x536B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x536C, 0,
+ 0, 0, 0, 0, 0x536E, 0, 0x536D, 0,
+ 0, 0, 0, 0, 0x5370, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E59B[] = {
+ 0x5373, 0x5371, 0x536F, 0x5372, 0, 0, 0, 0,
+ 0x5374, 0, 0, 0, 0, 0, 0x5375, 0,
+ 0, 0x5376, 0, 0x5377, 0, 0, 0, 0x5378,
+ 0x5145, 0, 0x3C7C, 0x3B4D, 0, 0, 0x3273, 0,
+ 0x3078, 0, 0, 0x4344, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5379, 0,
+ 0x3A24, 0, 0x304F, 0x3F5E, 0, 0, 0, 0,
+ 0, 0x537A, 0x3847, 0, 0, 0x3971, 0, 0x537C,
+};
+unsigned short utf8_to_euc_E59C[] = {
+ 0x537B, 0, 0, 0x4A60, 0x537D, 0, 0, 0,
+ 0x5421, 0x537E, 0, 0x5422, 0, 0x5423, 0, 0x3777,
+ 0, 0, 0x3160, 0x5424, 0, 0, 0x5426, 0,
+ 0x5425, 0, 0, 0, 0x5428, 0, 0, 0x455A,
+ 0, 0, 0, 0, 0, 0, 0x5429, 0x3035,
+ 0x3A5F, 0, 0, 0, 0, 0x373D, 0, 0,
+ 0x434F, 0, 0, 0, 0, 0, 0, 0x542A,
+ 0x542B, 0, 0, 0x542D, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E59D[] = {
+ 0x542E, 0, 0x3A64, 0, 0, 0, 0, 0x3651,
+ 0, 0, 0x4B37, 0, 0, 0, 0x542C, 0x542F,
+ 0x3A41, 0x3923, 0, 0, 0, 0, 0, 0,
+ 0, 0x795A, 0, 0, 0, 0, 0, 0,
+ 0, 0x5433, 0, 0, 0x3A25, 0x795B, 0x4333, 0,
+ 0, 0x5430, 0x445A, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x5434,
+};
+unsigned short utf8_to_euc_E59E[] = {
+ 0, 0, 0x3F62, 0, 0, 0, 0, 0,
+ 0x5432, 0x5435, 0, 0x373F, 0, 0, 0, 0,
+ 0, 0, 0, 0x5436, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5437, 0, 0x3924, 0x3340, 0x5439, 0, 0, 0,
+ 0, 0, 0x543A, 0, 0x795C, 0, 0, 0,
+ 0x543B, 0, 0, 0x5438, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E59F[] = {
+ 0x5431, 0, 0, 0x543C, 0, 0, 0x543D, 0x795E,
+ 0x795D, 0, 0, 0x4B64, 0, 0, 0x3E6B, 0,
+ 0, 0, 0x543F, 0x5440, 0x543E, 0, 0x5442, 0,
+ 0, 0, 0, 0, 0x4738, 0, 0, 0x3068,
+ 0x4956, 0, 0, 0x5443, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x3E7D, 0, 0, 0x3C39,
+ 0, 0x475D, 0x3470, 0, 0x3A6B, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5A0[] = {
+ 0x4B59, 0, 0x4632, 0, 0, 0x3778, 0x424F, 0,
+ 0, 0, 0x5441, 0x5444, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x4244, 0, 0,
+ 0, 0x5445, 0, 0, 0, 0x5446, 0, 0,
+ 0, 0x5448, 0, 0, 0x4469, 0, 0, 0,
+ 0, 0, 0x342E, 0, 0, 0, 0, 0x7421,
+ 0x3161, 0x4A73, 0, 0, 0x3E6C, 0x4548, 0, 0,
+ 0, 0, 0x3A66, 0, 0, 0x544E, 0, 0,
+};
+unsigned short utf8_to_euc_E5A1[] = {
+ 0x4A3D, 0x4E5D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3274, 0x544A, 0, 0, 0, 0,
+ 0, 0x413A, 0x544D, 0, 0x4563, 0, 0, 0x4549,
+ 0x4564, 0x4839, 0x444D, 0, 0, 0, 0x3A49, 0,
+ 0, 0, 0x5449, 0, 0, 0, 0, 0,
+ 0, 0x3176, 0, 0x4536, 0, 0, 0, 0,
+ 0x544B, 0, 0x5447, 0, 0, 0x3F50, 0, 0,
+ 0, 0x544F, 0, 0, 0, 0, 0x3D4E, 0,
+};
+unsigned short utf8_to_euc_E5A2[] = {
+ 0, 0, 0, 0x362D, 0, 0x5450, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4A68, 0, 0, 0, 0x417D,
+ 0, 0, 0, 0, 0x4446, 0, 0x7961, 0x5452,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4B4F, 0, 0, 0x5453, 0, 0, 0x5458, 0,
+ 0, 0, 0x7962, 0x4A2F, 0, 0, 0, 0,
+ 0x5457, 0x5451, 0x5454, 0x5456, 0, 0, 0x3A26, 0,
+};
+unsigned short utf8_to_euc_E5A3[] = {
+ 0, 0x4A49, 0, 0, 0, 0x5459, 0, 0x4345,
+ 0, 0, 0x3275, 0, 0x3E6D, 0, 0, 0,
+ 0, 0x545B, 0, 0x545A, 0, 0x3968, 0, 0x545C,
+ 0x545E, 0x545D, 0, 0, 0x5460, 0, 0x5455, 0x5462,
+ 0, 0, 0, 0, 0x5461, 0x545F, 0, 0,
+ 0, 0, 0, 0x3B4E, 0x3F51, 0, 0x4154, 0x5463,
+ 0x403C, 0x306D, 0x4764, 0, 0, 0, 0, 0x445B,
+ 0, 0x5465, 0x5464, 0x5466, 0x5467, 0x5468, 0, 0,
+};
+unsigned short utf8_to_euc_E5A4[] = {
+ 0, 0, 0x5469, 0, 0, 0, 0, 0,
+ 0, 0x4A51, 0x546A, 0x7963, 0, 0, 0, 0x3246,
+ 0x546B, 0, 0, 0, 0, 0x4D3C, 0x3330, 0,
+ 0x5249, 0x3D48, 0x423F, 0x546C, 0x4C6B, 0, 0, 0,
+ 0, 0, 0x4C34, 0, 0, 0x546E, 0, 0x4267,
+ 0, 0x4537, 0x4240, 0x4957, 0x546F, 0x5470, 0x317B, 0,
+ 0, 0x3C3A, 0x5471, 0, 0, 0, 0, 0x3050,
+ 0x5472, 0, 0, 0, 0, 0, 0x5473, 0,
+};
+unsigned short utf8_to_euc_E5A5[] = {
+ 0, 0, 0, 0, 0x3162, 0, 0, 0x3471,
+ 0x4660, 0x4A74, 0, 0, 0, 0, 0x5477, 0x4155,
+ 0x5476, 0x3740, 0, 0x7964, 0x4B5B, 0x5475, 0, 0x4565,
+ 0x5479, 0, 0x5478, 0x7965, 0, 0x7966, 0, 0,
+ 0x547B, 0, 0x547A, 0x7967, 0, 0x317C, 0, 0x547C,
+ 0x3E29, 0x547E, 0x4325, 0, 0x547D, 0, 0x4A33, 0,
+ 0, 0, 0, 0x3D77, 0x455B, 0, 0, 0,
+ 0x5521, 0, 0, 0, 0, 0x3925, 0, 0,
+};
+unsigned short utf8_to_euc_E5A6[] = {
+ 0, 0x5522, 0x4721, 0x485E, 0x4C51, 0, 0, 0,
+ 0, 0, 0x4725, 0, 0, 0x552B, 0, 0,
+ 0, 0, 0, 0x3538, 0, 0, 0x4D45, 0,
+ 0, 0x4C2F, 0, 0x562C, 0, 0x5523, 0, 0,
+ 0, 0, 0, 0x5526, 0x7968, 0x4245, 0, 0,
+ 0x4B38, 0, 0, 0, 0x454A, 0, 0, 0,
+ 0, 0, 0x5527, 0, 0, 0, 0, 0,
+ 0, 0x4B65, 0x7969, 0x3A4A, 0, 0, 0x3E2A, 0,
+};
+unsigned short utf8_to_euc_E5A7[] = {
+ 0, 0, 0, 0, 0, 0, 0x5528, 0,
+ 0, 0x3B50, 0, 0x3B4F, 0, 0, 0, 0,
+ 0x3039, 0x3848, 0, 0x402B, 0x3051, 0, 0, 0,
+ 0, 0x552C, 0x552D, 0, 0x552A, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x3138, 0x342F, 0,
+ 0x5529, 0, 0x4C45, 0x4931, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3028, 0,
+ 0, 0, 0, 0x3079, 0, 0, 0, 0x3B51,
+};
+unsigned short utf8_to_euc_E5A8[] = {
+ 0, 0x3052, 0, 0x3023, 0, 0, 0, 0,
+ 0, 0x5532, 0, 0, 0, 0, 0, 0,
+ 0, 0x5530, 0, 0, 0, 0, 0, 0,
+ 0x4C3C, 0, 0x5533, 0, 0x5531, 0, 0, 0x552F,
+ 0x3F31, 0, 0, 0, 0, 0x552E, 0, 0,
+ 0, 0x4A5A, 0, 0, 0, 0, 0, 0x3864,
+ 0, 0, 0, 0, 0, 0x5537, 0x5538, 0,
+ 0, 0, 0, 0, 0x3E2B, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5A9[] = {
+ 0x5534, 0x4F2C, 0, 0, 0, 0, 0x474C, 0,
+ 0, 0x5536, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3A27, 0, 0, 0, 0, 0,
+ 0, 0, 0x5539, 0, 0, 0, 0x4958, 0,
+ 0, 0, 0x553A, 0, 0x5535, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4C3B,
+};
+unsigned short utf8_to_euc_E5AA[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x475E, 0, 0, 0, 0, 0,
+ 0, 0, 0x553B, 0x4932, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x553C, 0x5540, 0x553D, 0,
+};
+unsigned short utf8_to_euc_E5AB[] = {
+ 0, 0x3247, 0x553F, 0, 0, 0, 0, 0,
+ 0, 0x3C3B, 0, 0x553E, 0x3779, 0, 0, 0,
+ 0x554C, 0, 0, 0, 0, 0, 0x5545, 0x5542,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x4364, 0, 0x5541, 0, 0, 0x5543, 0,
+ 0, 0x5544, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x5546, 0x5547, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5AC[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3472, 0, 0x5549, 0x5548, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x554A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3E6E, 0, 0, 0, 0, 0,
+ 0, 0, 0x554D, 0, 0x445C, 0, 0, 0,
+ 0x3145, 0, 0x554B, 0, 0, 0, 0x554E, 0,
+ 0, 0, 0, 0, 0, 0, 0x554F, 0,
+};
+unsigned short utf8_to_euc_E5AD[] = {
+ 0x5552, 0, 0, 0x5550, 0, 0x5551, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x3B52, 0x5553, 0, 0, 0x3926, 0x5554, 0x796A, 0x3B7A,
+ 0x4238, 0, 0x5555, 0x5556, 0x3B5A, 0x3927, 0, 0x4C52,
+ 0, 0, 0, 0x3528, 0x3849, 0x5557, 0x3358, 0,
+ 0, 0x5558, 0, 0x4239, 0, 0, 0, 0,
+ 0x5559, 0x5623, 0, 0x555A, 0, 0x555B, 0, 0,
+ 0x555C, 0, 0x555E, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5AE[] = {
+ 0x555F, 0, 0, 0x5560, 0, 0x4270, 0, 0x3127,
+ 0x3C69, 0x3042, 0, 0x4157, 0x3430, 0x3C35, 0, 0x3928,
+ 0, 0, 0, 0, 0, 0x4566, 0, 0x3D21,
+ 0x3431, 0x4368, 0x446A, 0x3038, 0x3539, 0x4A75, 0, 0x3C42,
+ 0, 0, 0x3552, 0x406B, 0x3C3C, 0x4D28, 0x5561, 0,
+ 0, 0, 0, 0, 0, 0, 0x355C, 0,
+ 0x3A4B, 0, 0, 0x3332, 0x3163, 0x3E2C, 0x3248, 0,
+ 0x5562, 0x4D46, 0, 0, 0, 0, 0, 0x3D49,
+};
+unsigned short utf8_to_euc_E5AF[] = {
+ 0x796B, 0, 0x3C64, 0x5563, 0x3473, 0x4652, 0x4C29, 0x5564,
+ 0, 0x5565, 0, 0, 0x4959, 0, 0, 0,
+ 0x5567, 0, 0x3428, 0x3677, 0x5566, 0, 0, 0,
+ 0x796D, 0, 0, 0x3432, 0, 0x3F32, 0x556B, 0x3B21,
+ 0, 0x3249, 0x556A, 0, 0x5568, 0x556C, 0x5569, 0x472B,
+ 0x5C4D, 0x3F33, 0, 0x556D, 0x796E, 0, 0x4E40, 0,
+ 0x556E, 0, 0, 0x5570, 0, 0x437E, 0x556F, 0,
+ 0x4023, 0, 0x3B7B, 0, 0, 0, 0x4250, 0x3C77,
+};
+unsigned short utf8_to_euc_E5B0[] = {
+ 0, 0x4975, 0x406C, 0, 0x3C4D, 0x5571, 0x3E2D, 0x5572,
+ 0x5573, 0x3053, 0x423A, 0x3F52, 0, 0x5574, 0x4633, 0x3E2E,
+ 0, 0x3E2F, 0, 0x5575, 0, 0, 0x406D, 0,
+ 0, 0, 0x3E30, 0, 0, 0, 0x796F, 0,
+ 0x5576, 0, 0x5577, 0, 0x4C60, 0, 0, 0,
+ 0x5578, 0, 0, 0, 0, 0x3646, 0, 0,
+ 0, 0x3D22, 0, 0, 0, 0, 0, 0,
+ 0x5579, 0x557A, 0x3C5C, 0x3F2C, 0x4674, 0x3F54, 0x4878, 0x4722,
+};
+unsigned short utf8_to_euc_E5B1[] = {
+ 0x3649, 0x557B, 0, 0, 0, 0x356F, 0x557C, 0,
+ 0x367E, 0, 0x464F, 0x3230, 0, 0x3B53, 0x557D, 0x5622,
+ 0x5621, 0x367D, 0, 0x557E, 0, 0x4538, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x4230, 0,
+ 0x454B, 0x3C48, 0, 0, 0x4158, 0x4D7A, 0, 0,
+ 0, 0, 0, 0, 0x5624, 0, 0x5625, 0x4656,
+ 0, 0x3B33, 0, 0, 0, 0, 0x5627, 0,
+ 0, 0x5628, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5B2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5629, 0, 0, 0,
+ 0x3474, 0x562A, 0, 0, 0x562B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x322C, 0, 0, 0, 0, 0x7970, 0,
+ 0x413B, 0x3464, 0, 0x562D, 0x4C28, 0, 0, 0,
+ 0, 0x4252, 0, 0x3359, 0, 0, 0x562F, 0x5631,
+ 0x345F, 0, 0x7971, 0x562E, 0x5630, 0, 0x5633, 0,
+};
+unsigned short utf8_to_euc_E5B3[] = {
+ 0, 0, 0, 0, 0, 0x5632, 0, 0x5634,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5635, 0, 0, 0, 0, 0, 0,
+ 0x463D, 0x362E, 0, 0, 0, 0, 0, 0,
+ 0x3265, 0x5636, 0x563B, 0, 0, 0x5639, 0, 0x4A77,
+ 0x4A76, 0, 0, 0, 0, 0x7972, 0x4567, 0,
+ 0, 0, 0x5638, 0x3D54, 0, 0x5637, 0, 0,
+};
+unsigned short utf8_to_euc_E5B4[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0x3F72,
+ 0, 0, 0, 0x563C, 0, 0, 0x3A6A, 0,
+ 0, 0x5642, 0, 0, 0x5643, 0x563D, 0x3333, 0x563E,
+ 0x5647, 0x5646, 0x5645, 0x5641, 0, 0, 0, 0x5640,
+ 0, 0, 0x5644, 0, 0, 0, 0, 0x7973,
+ 0, 0x4A78, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5B5[] = {
+ 0, 0, 0x7976, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x564B, 0x5648, 0, 0x564A, 0,
+ 0x4D72, 0, 0x5649, 0x7974, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x563F, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3F73, 0, 0, 0x564C, 0x7977, 0, 0x3A37,
+ 0, 0, 0, 0x564D, 0, 0, 0x564E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5B6[] = {
+ 0, 0, 0x5651, 0, 0x5650, 0, 0, 0x564F,
+ 0, 0, 0, 0x4568, 0x563A, 0, 0, 0,
+ 0x5657, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x5653, 0, 0,
+ 0, 0, 0x5652, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5654, 0, 0x5655, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x5658,
+ 0x7978, 0x7979, 0x4E66, 0, 0x5659, 0x5656, 0, 0,
+};
+unsigned short utf8_to_euc_E5B7[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x565A, 0, 0, 0x3460, 0x565B, 0, 0,
+ 0x797A, 0, 0x565D, 0x565C, 0, 0, 0x565E, 0,
+ 0, 0, 0, 0x565F, 0, 0x406E, 0x3D23, 0,
+ 0, 0x3D64, 0, 0x4163, 0, 0x3929, 0x3A38, 0x392A,
+ 0x3570, 0, 0, 0x5660, 0, 0, 0x3A39, 0,
+ 0, 0x384A, 0x5661, 0x4C26, 0x4743, 0x5662, 0, 0x392B,
+ 0, 0, 0, 0x342C, 0, 0x4327, 0x3652, 0,
+};
+unsigned short utf8_to_euc_E5B8[] = {
+ 0, 0, 0x3B54, 0x495B, 0, 0, 0x4841, 0,
+ 0, 0, 0, 0x5663, 0x3475, 0, 0, 0,
+ 0, 0x5666, 0, 0, 0, 0, 0x4421, 0,
+ 0, 0x5665, 0x5664, 0x5667, 0, 0x446B, 0, 0,
+ 0, 0, 0, 0, 0, 0x3F63, 0, 0,
+ 0, 0, 0, 0x3B55, 0, 0x404A, 0, 0x4253,
+ 0x3522, 0, 0, 0x4422, 0, 0, 0x5668, 0x5669,
+ 0x3E6F, 0, 0, 0, 0, 0x4B39, 0, 0,
+};
+unsigned short utf8_to_euc_E5B9[] = {
+ 0x566C, 0, 0, 0x566B, 0x566A, 0x497D, 0, 0x5673,
+ 0, 0, 0, 0, 0x4B5A, 0, 0x566D, 0,
+ 0, 0, 0, 0, 0x566F, 0x4B6B, 0, 0x566E,
+ 0, 0, 0, 0, 0, 0, 0, 0x5670,
+ 0, 0x4828, 0x5671, 0x4A3E, 0x5672, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3433, 0x4A3F, 0x472F, 0x5674, 0x5675, 0,
+ 0x392C, 0x3434, 0x5676, 0x3838, 0x4D44, 0x4D29, 0x3476, 0x5678,
+};
+unsigned short utf8_to_euc_E5BA[] = {
+ 0, 0x4423, 0, 0x392D, 0x3E31, 0, 0, 0x485F,
+ 0, 0, 0x3E32, 0, 0, 0, 0, 0x3D78,
+ 0, 0, 0, 0, 0, 0x446C, 0x4A79, 0x4539,
+ 0, 0, 0x392E, 0, 0x495C, 0, 0, 0,
+ 0x5679, 0, 0, 0, 0, 0, 0x4559, 0x3A42,
+ 0, 0, 0, 0x384B, 0, 0x446D, 0, 0,
+ 0, 0, 0, 0, 0, 0x3043, 0x3D6E, 0x392F,
+ 0x4D47, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E5BB[] = {
+ 0, 0x567A, 0x567B, 0x4751, 0, 0, 0, 0,
+ 0x567C, 0x4E77, 0x4F2D, 0, 0, 0, 0, 0x567E,
+ 0x567D, 0, 0, 0x3347, 0, 0, 0x5721, 0,
+ 0, 0, 0x5724, 0x5725, 0, 0x5723, 0, 0x4940,
+ 0x3E33, 0x5727, 0x5726, 0x5722, 0, 0, 0, 0,
+ 0x5728, 0x5729, 0, 0, 0x572A, 0, 0, 0,
+ 0x572D, 0x572B, 0, 0x572C, 0x572E, 0, 0x3164, 0x446E,
+ 0x572F, 0, 0x377A, 0x3276, 0x4736, 0, 0x5730, 0x467B,
+};
+unsigned short utf8_to_euc_E5BC[] = {
+ 0, 0x4A5B, 0, 0x5731, 0x4F2E, 0, 0, 0,
+ 0, 0x5732, 0x4A40, 0x5735, 0x5021, 0x5031, 0, 0x3C30,
+ 0x4675, 0x5736, 0, 0x355D, 0x4424, 0x307A, 0x5737, 0x4A26,
+ 0x3930, 0, 0, 0x4350, 0, 0, 0, 0x446F,
+ 0, 0x797B, 0, 0, 0, 0x4C6F, 0x3839, 0x384C,
+ 0, 0x5738, 0, 0, 0, 0x5739, 0, 0x573F,
+ 0, 0x3C65, 0, 0, 0x797C, 0x4425, 0, 0x362F,
+ 0x573A, 0, 0, 0, 0x492B, 0, 0x4346, 0,
+};
+unsigned short utf8_to_euc_E5BD[] = {
+ 0, 0x573B, 0, 0, 0, 0x792C, 0, 0,
+ 0x573C, 0, 0x3630, 0, 0x573D, 0, 0x573E, 0,
+ 0, 0x5740, 0, 0x4576, 0, 0, 0x5741, 0x5742,
+ 0, 0x5743, 0, 0, 0x5734, 0x5733, 0, 0,
+ 0, 0x5744, 0x3741, 0, 0, 0, 0x4927, 0x797D,
+ 0, 0x3A4C, 0x4937, 0x4426, 0x494B, 0x5745, 0, 0,
+ 0x3E34, 0x3146, 0, 0x5746, 0, 0, 0, 0x5747,
+ 0, 0x4C72, 0, 0, 0x4860, 0, 0, 0x574A,
+};
+unsigned short utf8_to_euc_E5BE[] = {
+ 0x317D, 0x402C, 0x5749, 0x5748, 0x3742, 0x4254, 0, 0x574E,
+ 0x574C, 0, 0x574B, 0x4E27, 0x3865, 0, 0, 0,
+ 0x3D79, 0x574D, 0x454C, 0x3D3E, 0, 0, 0, 0x4640,
+ 0x5751, 0x5750, 0, 0, 0, 0, 0x574F, 0,
+ 0x5752, 0x3866, 0, 0, 0, 0, 0, 0,
+ 0x5753, 0x497C, 0x3D5B, 0, 0, 0x5754, 0x4879, 0,
+ 0, 0, 0, 0x4641, 0x4427, 0, 0, 0x797E,
+ 0, 0x4530, 0, 0, 0x5755, 0x352B, 0, 0,
+};
+unsigned short utf8_to_euc_E5BF[] = {
+ 0, 0, 0, 0x3F34, 0, 0x492C, 0, 0,
+ 0, 0, 0, 0, 0x3477, 0x4726, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5756, 0x3B56,
+ 0x4B3A, 0x4B3B, 0, 0, 0x317E, 0x575B, 0x7A21, 0,
+ 0x4369, 0, 0, 0, 0x5758, 0, 0, 0,
+ 0, 0, 0, 0x3277, 0, 0, 0, 0,
+ 0x582D, 0x575A, 0, 0, 0, 0x4730, 0, 0,
+ 0x5759, 0, 0, 0x5757, 0, 0x397A, 0, 0x575D,
+};
+unsigned short utf8_to_euc_E680[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5763, 0x5769,
+ 0x5761, 0, 0x455C, 0, 0, 0x5766, 0x495D, 0,
+ 0, 0x5760, 0, 0x5765, 0x4E67, 0x3B57, 0, 0,
+ 0x4255, 0x575E, 0, 0, 0, 0x355E, 0x5768, 0x402D,
+ 0x3165, 0x5762, 0x3278, 0x5767, 0, 0, 0, 0x3631,
+ 0, 0x5764, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x576A, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E681[] = {
+ 0, 0x576C, 0x5776, 0x5774, 0, 0, 0x5771, 0,
+ 0, 0, 0x5770, 0x4E78, 0, 0x5772, 0, 0,
+ 0x3632, 0, 0x3931, 0, 0, 0x3D7A, 0, 0,
+ 0, 0x5779, 0x576B, 0, 0, 0x7A22, 0, 0x576F,
+ 0x575F, 0, 0x327A, 0x5773, 0x5775, 0x4351, 0, 0,
+ 0x3A28, 0x3238, 0x576D, 0x5778, 0x5777, 0x3633, 0, 0x4229,
+ 0x3366, 0, 0, 0, 0, 0x3743, 0, 0x576E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E682[] = {
+ 0, 0x577A, 0, 0x577D, 0x5821, 0x7A23, 0, 0,
+ 0, 0x3C3D, 0x7A24, 0x5827, 0x4470, 0x577B, 0, 0,
+ 0, 0, 0x5825, 0, 0x3279, 0, 0x5823, 0x5824,
+ 0, 0, 0x577E, 0x5822, 0, 0, 0, 0x3867,
+ 0x4D2A, 0, 0, 0x3435, 0, 0, 0x3159, 0x5826,
+ 0, 0x473A, 0x302D, 0, 0, 0, 0, 0,
+ 0, 0, 0x4861, 0x575C, 0x582C, 0x5830, 0x4C65, 0,
+ 0x5829, 0, 0, 0, 0x4569, 0x582E, 0, 0,
+};
+unsigned short utf8_to_euc_E683[] = {
+ 0, 0, 0, 0, 0, 0x3E70, 0x582F, 0x4657,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x4F47, 0, 0x582B, 0, 0x7A26, 0, 0,
+ 0x5831, 0, 0x397B, 0, 0x404B, 0, 0x7A25, 0x3054,
+ 0x582A, 0x5828, 0, 0x415A, 0, 0, 0, 0x577C,
+ 0x3B34, 0, 0, 0, 0, 0, 0, 0,
+ 0x4246, 0x583D, 0x7A28, 0x415B, 0x5838, 0, 0x5835, 0x5836,
+ 0, 0x3C66, 0x5839, 0x583C, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E684[] = {
+ 0x5837, 0x3D25, 0, 0x583A, 0, 0, 0x5834, 0,
+ 0x4C7C, 0x4C7B, 0, 0, 0, 0x583E, 0x583F, 0x3055,
+ 0, 0x7A29, 0, 0, 0, 0x5833, 0, 0,
+ 0, 0, 0x3672, 0x3026, 0, 0, 0, 0x3436,
+ 0x7A27, 0x583B, 0, 0, 0, 0, 0, 0x5843,
+ 0x5842, 0, 0, 0, 0x5847, 0, 0, 0,
+ 0x7A2B, 0, 0, 0, 0x5848, 0, 0, 0x7A2A,
+ 0, 0, 0, 0, 0x5846, 0x5849, 0x5841, 0x5845,
+};
+unsigned short utf8_to_euc_E685[] = {
+ 0, 0, 0x584A, 0, 0x584B, 0, 0, 0x5840,
+ 0x3B7C, 0, 0x5844, 0x4256, 0x3932, 0x5832, 0x3F35, 0,
+ 0, 0, 0, 0x5858, 0, 0x4A69, 0, 0,
+ 0x584E, 0x584F, 0x5850, 0, 0, 0x5857, 0, 0x5856,
+ 0, 0, 0x4B7D, 0x3437, 0, 0x5854, 0, 0x3745,
+ 0x3334, 0, 0, 0x5851, 0, 0, 0x4E38, 0x5853,
+ 0x3056, 0x5855, 0, 0x584C, 0x5852, 0x5859, 0x3744, 0x584D,
+ 0, 0, 0, 0, 0, 0, 0x4D5D, 0,
+};
+unsigned short utf8_to_euc_E686[] = {
+ 0, 0, 0x4D2B, 0, 0, 0, 0, 0x585C,
+ 0, 0, 0x5860, 0, 0, 0, 0x417E, 0,
+ 0x4E79, 0x5861, 0, 0, 0x585E, 0, 0x585B, 0,
+ 0x7A2C, 0x585A, 0x585F, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x4A30, 0, 0, 0x4634,
+ 0, 0x3746, 0, 0x5862, 0x585D, 0, 0x5863, 0,
+ 0, 0, 0x377B, 0, 0, 0, 0x3231, 0,
+ 0, 0, 0x586B, 0, 0, 0, 0x3438, 0,
+};
+unsigned short utf8_to_euc_E687[] = {
+ 0, 0, 0, 0x5869, 0, 0, 0x586A, 0x3A29,
+ 0x5868, 0x5866, 0x5865, 0x586C, 0x5864, 0x586E, 0, 0,
+ 0x327B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5870, 0, 0, 0x586F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4428, 0, 0x5873, 0, 0x5871, 0x5867,
+ 0x377C, 0, 0x5872, 0, 0x5876, 0x5875, 0x5877, 0x5874,
+};
+unsigned short utf8_to_euc_E688[] = {
+ 0x5878, 0, 0, 0, 0, 0, 0, 0,
+ 0x5879, 0x587A, 0x4A6A, 0, 0x587C, 0x587B, 0x3D3F, 0,
+ 0x402E, 0x3266, 0x327C, 0x7A2D, 0x587D, 0, 0x303F, 0,
+ 0, 0, 0x404C, 0x587E, 0, 0x6C43, 0x5921, 0x3761,
+ 0, 0x5922, 0, 0, 0, 0, 0x406F, 0,
+ 0, 0, 0x5923, 0, 0, 0, 0x5924, 0x353A,
+ 0x5925, 0, 0x5926, 0x5927, 0x4257, 0, 0, 0,
+ 0x384D, 0, 0, 0x4C61, 0, 0, 0, 0x4B3C,
+};
+unsigned short utf8_to_euc_E689[] = {
+ 0x3D6A, 0x5928, 0, 0, 0, 0, 0, 0x4070,
+ 0x6E3D, 0x4862, 0, 0x3C6A, 0, 0x3A4D, 0x5929, 0,
+ 0, 0, 0, 0x4247, 0, 0x4A27, 0, 0,
+ 0x4271, 0, 0, 0x592C, 0, 0, 0x592A, 0,
+ 0x592D, 0, 0, 0x592B, 0, 0, 0, 0,
+ 0x592E, 0, 0, 0, 0, 0, 0x4A31, 0,
+ 0, 0x3037, 0, 0, 0, 0, 0x495E, 0,
+ 0, 0x4863, 0, 0, 0x592F, 0, 0x5932, 0x3E35,
+};
+unsigned short utf8_to_euc_E68A[] = {
+ 0x353B, 0, 0x5930, 0x5937, 0x3E36, 0, 0, 0,
+ 0, 0x5931, 0x4744, 0, 0, 0, 0, 0,
+ 0, 0x4D5E, 0x5933, 0x5934, 0x5938, 0x456A, 0x5935, 0x3933,
+ 0x405E, 0, 0, 0x5946, 0x4834, 0, 0x4272, 0,
+ 0, 0, 0, 0, 0, 0, 0x7A2E, 0,
+ 0, 0, 0, 0x4864, 0x5A2D, 0, 0, 0,
+ 0, 0x4A7A, 0, 0, 0, 0x4471, 0, 0,
+ 0, 0x4B75, 0, 0x593B, 0x3221, 0x436A, 0, 0,
+};
+unsigned short utf8_to_euc_E68B[] = {
+ 0, 0, 0x5944, 0, 0, 0x4334, 0x593E, 0x5945,
+ 0x5940, 0x5947, 0x5943, 0, 0x5942, 0x476F, 0, 0x593C,
+ 0x327D, 0x593A, 0x3571, 0x4273, 0x5936, 0, 0, 0x5939,
+ 0x3934, 0x405B, 0, 0x3E37, 0x5941, 0x4752, 0, 0,
+ 0x3572, 0x3348, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x3367, 0x3F21, 0x5949, 0x594E,
+ 0, 0x594A, 0, 0x377D, 0, 0x594F, 0x3B22, 0x3969,
+ 0, 0, 0, 0, 0, 0, 0x3D26, 0x593D,
+};
+unsigned short utf8_to_euc_E68C[] = {
+ 0, 0x3B7D, 0x594C, 0, 0, 0, 0, 0x3B58,
+ 0x594D, 0x3044, 0, 0, 0x5948, 0, 0, 0,
+ 0, 0x4429, 0, 0, 0, 0, 0, 0,
+ 0, 0x3573, 0, 0, 0, 0, 0, 0x3634,
+ 0, 0, 0, 0, 0, 0, 0, 0x594B,
+ 0x3027, 0, 0, 0x3A43, 0, 0, 0, 0x3F36,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4472, 0, 0, 0x4854, 0x5951, 0x415E,
+};
+unsigned short utf8_to_euc_E68D[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x422A, 0, 0, 0x3B2B, 0x5952, 0, 0x5954,
+ 0x5950, 0, 0, 0, 0, 0x4A61, 0, 0x443D,
+ 0, 0, 0, 0, 0x415C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4A7B,
+ 0x3C4E, 0x5960, 0, 0x595F, 0, 0, 0x3F78, 0,
+ 0, 0, 0x377E, 0, 0, 0, 0x5959, 0x3E39,
+ 0, 0, 0x4668, 0x4731, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E68E[] = {
+ 0x5957, 0, 0, 0x415D, 0, 0, 0, 0,
+ 0x3C78, 0x595C, 0, 0, 0x3E38, 0, 0x5956, 0x595B,
+ 0, 0, 0x4753, 0, 0, 0, 0x5955, 0,
+ 0x3721, 0, 0, 0x335D, 0, 0, 0, 0x595D,
+ 0x4E2B, 0x3A4E, 0x4335, 0x595A, 0, 0x405C, 0, 0x3935,
+ 0x3F64, 0x3166, 0x413C, 0x5958, 0x3545, 0, 0, 0,
+ 0, 0, 0x3747, 0, 0x444F, 0x595E, 0, 0,
+ 0, 0, 0, 0x415F, 0, 0, 0x5961, 0,
+};
+unsigned short utf8_to_euc_E68F[] = {
+ 0x5963, 0, 0, 0x4237, 0x5969, 0, 0x5964, 0,
+ 0, 0x5966, 0, 0, 0, 0, 0, 0x4941,
+ 0x4473, 0, 0x5967, 0, 0, 0, 0x4D2C, 0,
+ 0, 0, 0x4D48, 0x3439, 0, 0, 0, 0,
+ 0, 0x302E, 0, 0x5965, 0, 0, 0, 0,
+ 0, 0x5962, 0, 0, 0, 0, 0x3478, 0,
+ 0, 0, 0, 0, 0x3167, 0x7A2F, 0x5968, 0,
+ 0, 0, 0x4D49, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E690[] = {
+ 0, 0, 0, 0, 0, 0, 0x596C, 0,
+ 0, 0, 0, 0, 0, 0x423B, 0, 0x5973,
+ 0, 0, 0, 0x596D, 0, 0, 0x596A, 0x5971,
+ 0, 0, 0, 0, 0x5953, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x596E, 0,
+ 0x5972, 0, 0, 0, 0x4842, 0x456B, 0, 0,
+ 0, 0, 0, 0, 0x596B, 0, 0x596F, 0,
+ 0, 0, 0x3748, 0, 0, 0, 0x3A71, 0,
+};
+unsigned short utf8_to_euc_E691[] = {
+ 0, 0, 0x405D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5977, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4526, 0, 0, 0, 0, 0, 0, 0,
+ 0x7A30, 0, 0, 0, 0, 0, 0, 0x5974,
+ 0, 0x4B60, 0, 0, 0, 0, 0, 0x5975,
+ 0, 0, 0, 0, 0, 0, 0x5976, 0,
+ 0x4C4E, 0, 0x4022, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E692[] = {
+ 0, 0, 0, 0x3762, 0, 0, 0, 0,
+ 0x597D, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3B35, 0x597A, 0, 0x5979, 0, 0,
+ 0, 0, 0x4732, 0, 0, 0x7A31, 0x4635, 0,
+ 0, 0, 0, 0, 0x4531, 0x597B, 0, 0,
+ 0, 0x597C, 0, 0x496F, 0, 0x4745, 0x3B23, 0,
+ 0x4071, 0, 0x4B50, 0, 0, 0, 0, 0,
+ 0, 0x3349, 0, 0x5A25, 0x597E, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E693[] = {
+ 0, 0x4D4A, 0x5A27, 0, 0, 0x5A23, 0, 0x5A24,
+ 0, 0, 0, 0, 0, 0x4160, 0x7A32, 0,
+ 0, 0, 0x5A22, 0, 0x593F, 0, 0, 0,
+ 0x5A26, 0, 0x5A21, 0, 0, 0, 0, 0,
+ 0x5A2B, 0x5A2C, 0x4527, 0x5A2E, 0, 0, 0x3B24, 0x5A29,
+ 0, 0, 0, 0, 0x353C, 0, 0, 0x5A2F,
+ 0, 0x5A28, 0x5A33, 0, 0x5A32, 0, 0x5A31, 0,
+ 0, 0, 0x5A34, 0, 0, 0x5A36, 0x3E71, 0,
+};
+unsigned short utf8_to_euc_E694[] = {
+ 0x5A35, 0, 0, 0, 0, 0x5A39, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5A37, 0, 0, 0, 0x5A38, 0x5970, 0, 0,
+ 0, 0, 0, 0x5A3B, 0x5A3A, 0, 0, 0,
+ 0, 0, 0x5978, 0x5A3C, 0x5A30, 0, 0, 0x3B59,
+ 0, 0, 0, 0, 0x5A3D, 0x5A3E, 0x5A40, 0x5A3F,
+ 0x5A41, 0x327E, 0, 0x3936, 0, 0, 0x4A7C, 0x402F,
+};
+unsigned short utf8_to_euc_E695[] = {
+ 0, 0, 0, 0, 0, 0x384E, 0, 0,
+ 0x5A43, 0, 0, 0, 0, 0x5A46, 0x7A33, 0x4952,
+ 0, 0x355F, 0, 0, 0, 0x5A45, 0x5A44, 0x4754,
+ 0x5A47, 0x3635, 0, 0, 0, 0x5A49, 0x5A48, 0,
+ 0, 0, 0x343A, 0x3B36, 0, 0, 0x4658, 0,
+ 0, 0, 0, 0, 0x3749, 0, 0, 0,
+ 0x3F74, 0, 0x5A4A, 0, 0x4030, 0x4528, 0, 0x495F,
+ 0x5A4B, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E696[] = {
+ 0, 0, 0x5A4C, 0x5A4D, 0, 0, 0, 0x4A38,
+ 0x555D, 0x4046, 0, 0, 0x494C, 0, 0x3A58, 0,
+ 0x4865, 0x4843, 0, 0, 0, 0, 0, 0x454D,
+ 0, 0x4E41, 0, 0x5A4F, 0x3C50, 0, 0, 0x5A50,
+ 0, 0x3036, 0, 0, 0x3654, 0x404D, 0, 0x4960,
+ 0, 0, 0, 0x5A51, 0x3B42, 0x4347, 0, 0x3B5B,
+ 0x3F37, 0, 0, 0, 0, 0, 0, 0x5A52,
+ 0, 0x4A7D, 0, 0, 0x3177, 0x3B5C, 0, 0,
+};
+unsigned short utf8_to_euc_E697[] = {
+ 0, 0x5A55, 0, 0x5A53, 0x5A56, 0x4E39, 0x5A54, 0,
+ 0, 0, 0, 0x407B, 0x5A57, 0, 0, 0x4232,
+ 0, 0, 0x5A58, 0, 0, 0, 0, 0x347A,
+ 0, 0x5A5A, 0, 0x5A59, 0, 0, 0, 0,
+ 0x5A5B, 0x5A5C, 0x347B, 0, 0, 0x467C, 0x4336, 0x356C,
+ 0x3B5D, 0x4161, 0, 0, 0x3D5C, 0x3030, 0, 0,
+ 0, 0x5A5D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3222, 0x5A61, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E698[] = {
+ 0x7A34, 0, 0x3937, 0x5A60, 0, 0, 0x3A2B, 0x3E3A,
+ 0, 0x7A37, 0x5A5F, 0, 0x3E3B, 0, 0x4C40, 0x3A2A,
+ 0, 0, 0, 0x3057, 0x404E, 0x7A35, 0, 0,
+ 0, 0, 0, 0, 0x5A66, 0, 0x7A39, 0x4031,
+ 0x3147, 0, 0, 0, 0x7A3A, 0x3D55, 0, 0x4B66,
+ 0x3A72, 0, 0, 0, 0, 0x3E3C, 0x7A38, 0x4027,
+ 0, 0x7928, 0, 0, 0x5A65, 0x5A63, 0x5A64, 0,
+ 0, 0, 0, 0x7A36, 0x436B, 0, 0, 0x5B26,
+};
+unsigned short utf8_to_euc_E699[] = {
+ 0, 0x5A6A, 0x3B7E, 0x3938, 0x5A68, 0, 0, 0,
+ 0, 0x5A69, 0, 0x3F38, 0, 0, 0, 0x5A67,
+ 0, 0, 0x3B2F, 0, 0, 0, 0, 0x7A3C,
+ 0, 0x7A3D, 0, 0, 0, 0x5A6C, 0x5A6B, 0x5A70,
+ 0, 0, 0x5A71, 0, 0x5A6D, 0x7A3B, 0x3322, 0x5A6E,
+ 0x5A6F, 0x4855, 0, 0, 0, 0, 0x4961, 0x374A,
+ 0x5A72, 0, 0, 0x7A3F, 0x4032, 0, 0x3E3D, 0,
+ 0, 0, 0x4352, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E69A[] = {
+ 0, 0x3647, 0, 0x5A73, 0x5A77, 0, 0, 0x324B,
+ 0x5A74, 0x5A76, 0, 0, 0, 0, 0x5A75, 0,
+ 0, 0x3D6B, 0, 0, 0, 0, 0x4348, 0x3045,
+ 0x5A78, 0x7A40, 0, 0, 0, 0x5A79, 0, 0,
+ 0x7A41, 0, 0x442A, 0, 0, 0, 0x4E71, 0,
+ 0, 0, 0, 0x3B43, 0, 0, 0x4A6B, 0,
+ 0, 0, 0x7A42, 0, 0x4B3D, 0, 0, 0,
+ 0x5B22, 0x5A7B, 0, 0, 0x5A7E, 0, 0x5A7D, 0x7A43,
+};
+unsigned short utf8_to_euc_E69B[] = {
+ 0, 0x5A7A, 0, 0, 0x5B21, 0, 0, 0x465E,
+ 0, 0x5A7C, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5B23, 0,
+ 0, 0x3D6C, 0x5B24, 0, 0x4D4B, 0x4778, 0, 0,
+ 0x5B25, 0, 0, 0, 0, 0, 0x5B27, 0,
+ 0, 0x5B28, 0, 0, 0, 0, 0, 0,
+ 0x5B29, 0, 0x364A, 0x3148, 0x3939, 0x5B2A, 0, 0x5B2B,
+ 0x3D71, 0x4162, 0x7A44, 0x792B, 0x5258, 0x413E, 0x413D, 0x4258,
+};
+unsigned short utf8_to_euc_E69C[] = {
+ 0x3A47, 0, 0, 0x5072, 0, 0, 0, 0,
+ 0x376E, 0x4D2D, 0, 0x4A7E, 0, 0x497E, 0x7A45, 0x5B2C,
+ 0, 0, 0, 0, 0x3A73, 0x443F, 0x5B2D, 0x4F2F,
+ 0, 0, 0, 0x4B3E, 0, 0x442B, 0x5B2E, 0x347C,
+ 0, 0, 0, 0, 0, 0, 0x5B2F, 0x5B30,
+ 0x4C5A, 0, 0x4C24, 0x4B76, 0x4B5C, 0x3B25, 0x5B32, 0,
+ 0, 0x3C6B, 0, 0, 0x4B51, 0, 0x5B34, 0x5B37,
+ 0x5B36, 0, 0x3479, 0, 0, 0x3560, 0, 0x5B33,
+};
+unsigned short utf8_to_euc_E69D[] = {
+ 0, 0x5B35, 0, 0, 0, 0, 0x5B38, 0,
+ 0, 0x3F79, 0, 0, 0, 0, 0x4D7B, 0x3049,
+ 0x3A60, 0x423C, 0, 0x3C5D, 0, 0, 0x3E73, 0,
+ 0, 0x5B3B, 0, 0, 0x454E, 0, 0x5B39, 0x422B,
+ 0x5B3A, 0x3E72, 0x4C5D, 0x5B3C, 0x5B3D, 0x4D68, 0x7A47, 0,
+ 0, 0, 0x5B42, 0, 0, 0x393A, 0, 0x4755,
+ 0x5B3F, 0x456C, 0x5A5E, 0x5A62, 0, 0x354F, 0, 0x4747,
+ 0, 0, 0, 0, 0x5B41, 0, 0x3E3E, 0x4844,
+};
+unsigned short utf8_to_euc_E69E[] = {
+ 0, 0, 0, 0, 0, 0x5B47, 0, 0x487A,
+ 0, 0x5B3E, 0, 0x5B44, 0x5B43, 0, 0, 0,
+ 0x404F, 0, 0, 0, 0, 0x4B6D, 0, 0x4E53,
+ 0, 0, 0x4B67, 0, 0x324C, 0x3B5E, 0, 0,
+ 0x4F48, 0x5B46, 0x3F75, 0, 0, 0, 0x5B45, 0,
+ 0, 0x5B40, 0, 0, 0, 0, 0, 0x384F,
+ 0, 0, 0, 0x5B4C, 0x5B4A, 0, 0x324D, 0x5B48,
+ 0x5B4E, 0x5B54, 0, 0x7A48, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E69F[] = {
+ 0x7A4A, 0x4248, 0, 0, 0x4A41, 0, 0x5B56, 0,
+ 0, 0, 0x4922, 0, 0, 0, 0x5B55, 0x4770,
+ 0x4B3F, 0x343B, 0, 0x4077, 0x3D40, 0, 0, 0,
+ 0x4453, 0, 0x4D2E, 0, 0, 0x5B51, 0x5B50, 0,
+ 0, 0, 0x5B52, 0, 0x5B4F, 0, 0, 0x5B57,
+ 0, 0x5B4D, 0, 0, 0x5B4B, 0, 0x5B53, 0x5B49,
+ 0, 0x436C, 0, 0x4C78, 0x3C46, 0x3A74, 0, 0,
+ 0, 0, 0, 0x3A3A, 0, 0, 0x4B6F, 0x3341,
+};
+unsigned short utf8_to_euc_E6A0[] = {
+ 0, 0x7A4B, 0x444E, 0x464A, 0x3149, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4072, 0, 0, 0x4034, 0x372A,
+ 0, 0, 0, 0, 0, 0, 0x5B59, 0,
+ 0, 0x393B, 0x337C, 0, 0, 0, 0, 0,
+ 0, 0x5B5B, 0x3374, 0x5B61, 0, 0, 0, 0,
+ 0, 0, 0x5B5E, 0, 0x4073, 0, 0, 0,
+ 0x334B, 0x3A2C, 0, 0, 0x334A, 0x3A4F, 0, 0,
+};
+unsigned short utf8_to_euc_E6A1[] = {
+ 0x5B5C, 0x3765, 0x374B, 0x456D, 0x7A4C, 0, 0x5B5A, 0,
+ 0x3046, 0, 0, 0, 0, 0x5B5D, 0x5B5F, 0,
+ 0x364D, 0x372C, 0x7A49, 0x343C, 0x354B, 0, 0, 0,
+ 0, 0x5B62, 0, 0, 0x3A79, 0x4B71, 0, 0x3B37,
+ 0, 0, 0, 0x5B63, 0, 0, 0, 0x4930,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5B6F, 0, 0x3233, 0x5B64,
+ 0, 0, 0, 0, 0, 0, 0x5B75, 0x5B65,
+};
+unsigned short utf8_to_euc_E6A2[] = {
+ 0, 0x4E42, 0, 0x5B6C, 0, 0x475F, 0, 0,
+ 0, 0, 0, 0, 0, 0x5B74, 0, 0x5B67,
+ 0, 0, 0, 0x3034, 0x5B69, 0, 0, 0x393C,
+ 0, 0, 0, 0x5B6B, 0, 0x5B6A, 0, 0x5B66,
+ 0x5B71, 0, 0x3E3F, 0, 0, 0, 0x546D, 0x3868,
+ 0x4D7C, 0, 0, 0, 0, 0x5B68, 0, 0x4474,
+ 0x3323, 0x3A2D, 0, 0x5B60, 0, 0x5B70, 0x3361, 0,
+ 0, 0x5B6E, 0x5B72, 0, 0x456E, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6A3[] = {
+ 0, 0, 0, 0, 0x347E, 0, 0x5C32, 0,
+ 0x7929, 0x4C49, 0x5B77, 0x347D, 0, 0x5B7E, 0, 0x7A4D,
+ 0, 0, 0x4B40, 0, 0x5C21, 0x5C23, 0, 0x5C27,
+ 0x5B79, 0, 0x432A, 0, 0, 0, 0, 0x456F,
+ 0x5C2B, 0x5B7C, 0, 0x5C28, 0, 0, 0, 0x5C22,
+ 0, 0, 0, 0, 0, 0, 0x3F39, 0x5C2C,
+ 0, 0, 0x4033, 0, 0, 0, 0, 0,
+ 0, 0x5C2A, 0x343D, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6A4[] = {
+ 0x4F50, 0x5B76, 0, 0, 0x5C26, 0x3058, 0, 0,
+ 0x5B78, 0, 0, 0x4C3A, 0x5B7D, 0x3F22, 0x4447, 0x5B73,
+ 0, 0, 0x5C25, 0, 0, 0, 0, 0,
+ 0, 0x3F7A, 0x5C2F, 0x3371, 0x3821, 0, 0, 0,
+ 0, 0x5C31, 0x5B7A, 0x5C30, 0, 0x5C29, 0x5B7B, 0,
+ 0x5C2D, 0, 0x5C2E, 0, 0, 0, 0, 0,
+ 0x5C3F, 0, 0, 0, 0x464E, 0, 0x5C24, 0,
+ 0, 0x5C3B, 0, 0, 0, 0x5C3D, 0, 0x4458,
+};
+unsigned short utf8_to_euc_E6A5[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4D4C, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4976, 0x5C38, 0x424A, 0, 0,
+ 0, 0x5C3E, 0x413F, 0, 0x5C35, 0x5C42, 0x5C41, 0,
+ 0x466F, 0x5C40, 0x466A, 0, 0, 0, 0, 0,
+ 0x7A4F, 0, 0x5C44, 0x5C37, 0, 0x3648, 0x5C3A, 0x3D5D,
+ 0, 0, 0, 0x4760, 0x5C3C, 0x364B, 0, 0x5C34,
+ 0x5C36, 0x5C33, 0, 0, 0x4F30, 0x335A, 0x5C39, 0,
+};
+unsigned short utf8_to_euc_E6A6[] = {
+ 0, 0x5C43, 0x3335, 0, 0, 0, 0, 0,
+ 0, 0, 0x3A67, 0, 0, 0, 0x315D, 0,
+ 0, 0x5C54, 0, 0, 0x4F31, 0x5C57, 0, 0,
+ 0x7A51, 0, 0, 0x3F3A, 0x5C56, 0, 0, 0,
+ 0x5C55, 0, 0, 0, 0, 0, 0, 0x5C52,
+ 0, 0, 0, 0, 0, 0, 0x5C46, 0,
+ 0, 0x5C63, 0x5C45, 0, 0x5C58, 0, 0, 0,
+ 0, 0, 0, 0x5C50, 0, 0, 0x5C4B, 0x5C48,
+};
+unsigned short utf8_to_euc_E6A7[] = {
+ 0, 0x5C49, 0, 0x5C51, 0, 0, 0, 0x7422,
+ 0, 0, 0x5C4E, 0x393D, 0x4448, 0x4164, 0x5C4C, 0,
+ 0x5C47, 0, 0, 0x5C4A, 0, 0, 0, 0,
+ 0x4D4D, 0x4B6A, 0, 0, 0, 0x5C4F, 0x5C59, 0,
+ 0, 0, 0x7A52, 0, 0, 0, 0, 0x5C61,
+ 0x5C5A, 0, 0, 0x5C67, 0, 0x5C65, 0, 0,
+ 0, 0, 0x5C60, 0, 0, 0, 0, 0,
+ 0, 0x5C5F, 0, 0x4450, 0, 0x4165, 0, 0x5C5D,
+};
+unsigned short utf8_to_euc_E6A8[] = {
+ 0, 0, 0x5C5B, 0, 0, 0x5C62, 0, 0,
+ 0, 0, 0x5C68, 0x4875, 0x5C6E, 0, 0, 0,
+ 0, 0, 0x5C69, 0x5C6C, 0x5C66, 0, 0, 0x4374,
+ 0, 0x4938, 0, 0x5C5C, 0, 0, 0x5C64, 0x3E40,
+ 0, 0x4C4F, 0x5C78, 0x5C6B, 0, 0, 0, 0,
+ 0, 0x3822, 0x3223, 0x335F, 0, 0, 0x5C53, 0,
+ 0x7A53, 0, 0, 0, 0, 0x3E41, 0x5C70, 0,
+ 0x5C77, 0x3C79, 0x3372, 0, 0, 0x432E, 0, 0,
+};
+unsigned short utf8_to_euc_E6A9[] = {
+ 0, 0, 0, 0, 0x5C6D, 0, 0x7A55, 0x5C72,
+ 0x5C76, 0, 0, 0x3636, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x354C, 0x5C74, 0, 0, 0, 0, 0, 0x3521,
+ 0, 0x464B, 0x5C73, 0, 0, 0, 0x5C75, 0,
+ 0, 0, 0, 0x7A54, 0, 0, 0, 0,
+ 0, 0, 0x5C6F, 0x7A56, 0, 0, 0, 0,
+ 0x5C71, 0, 0, 0, 0, 0, 0x7A57, 0x3360,
+};
+unsigned short utf8_to_euc_E6AA[] = {
+ 0x4349, 0, 0, 0, 0x5C7C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x5C7A, 0x3869, 0,
+ 0x5C79, 0, 0, 0, 0, 0, 0, 0x5D21,
+ 0, 0, 0, 0, 0x5B58, 0, 0, 0,
+ 0x5C7B, 0, 0x5C7D, 0x5C7E, 0, 0, 0, 0,
+ 0, 0, 0x5D2C, 0, 0x5D28, 0, 0x5B6D, 0,
+ 0, 0, 0, 0x5D27, 0, 0, 0, 0,
+ 0x5D26, 0, 0, 0x5D23, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6AB[] = {
+ 0, 0x5C6A, 0x5D25, 0x5D24, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5D2A, 0, 0x4F26, 0, 0, 0, 0,
+ 0, 0, 0x5D2D, 0x367B, 0, 0, 0x5D29, 0x5D2B,
+ 0, 0, 0x7A58, 0, 0x7A59, 0, 0, 0,
+ 0x4827, 0, 0x5D2E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x5D32, 0x5D2F, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6AC[] = {
+ 0, 0, 0, 0, 0x4D73, 0x5D30, 0, 0,
+ 0, 0, 0x5C5E, 0, 0, 0, 0, 0,
+ 0, 0, 0x5D33, 0, 0, 0, 0x5D34, 0,
+ 0, 0, 0, 0, 0, 0x3135, 0, 0x5D36,
+ 0x3767, 0x3C21, 0, 0x3655, 0, 0, 0, 0x3224,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4D5F, 0, 0, 0, 0, 0x5D38,
+ 0x5D37, 0x5D3A, 0x353D, 0, 0, 0x3656, 0x343E, 0,
+};
+unsigned short utf8_to_euc_E6AD[] = {
+ 0, 0, 0, 0x5D3D, 0, 0, 0, 0x5D3C,
+ 0, 0x5D3E, 0, 0, 0x324E, 0, 0x4337, 0,
+ 0x5D3F, 0, 0, 0x343F, 0x5D41, 0, 0, 0,
+ 0, 0x5D40, 0, 0x5D42, 0, 0, 0, 0x5D43,
+ 0, 0x5D44, 0x3B5F, 0x4035, 0x3A21, 0, 0x4970, 0,
+ 0, 0x4A62, 0x4F44, 0, 0, 0, 0, 0x3B75,
+ 0, 0, 0, 0x3A50, 0x4E72, 0, 0, 0,
+ 0x5D45, 0x5D46, 0, 0x3B60, 0, 0, 0, 0x5D47,
+};
+unsigned short utf8_to_euc_E6AE[] = {
+ 0x5D48, 0, 0, 0x5D4A, 0x5D49, 0, 0x4B58, 0,
+ 0, 0x3D5E, 0x3C6C, 0x3B44, 0, 0x5D4B, 0, 0,
+ 0, 0, 0, 0, 0, 0x5D4D, 0x3F23, 0,
+ 0x5D4C, 0, 0, 0, 0, 0, 0x5D4E, 0,
+ 0, 0, 0, 0, 0x5D4F, 0, 0, 0,
+ 0, 0, 0x5D50, 0x5D51, 0, 0, 0, 0x5D52,
+ 0, 0x5D54, 0x5D53, 0x5D55, 0x3225, 0x434A, 0, 0x5D56,
+ 0, 0, 0x3B26, 0x334C, 0x5D57, 0, 0, 0x4542,
+};
+unsigned short utf8_to_euc_E6AF[] = {
+ 0x544C, 0, 0, 0, 0, 0x3523, 0x5D58, 0,
+ 0, 0, 0, 0x5D59, 0, 0x4A6C, 0x4B68, 0,
+ 0, 0, 0x4647, 0x5D5A, 0x4866, 0, 0x7A5A, 0,
+ 0x487B, 0, 0, 0x4C53, 0, 0, 0, 0x5D5B,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5D5D, 0x5D5C, 0, 0, 0x5D5F,
+ 0, 0, 0, 0x5D5E, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6B0[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5D61, 0, 0, 0, 0, 0, 0, 0x3B61,
+ 0, 0x4C31, 0, 0x5D62, 0x5D63, 0, 0, 0x3524,
+ 0, 0, 0, 0x5D64, 0, 0, 0, 0,
+ 0, 0, 0, 0x5D66, 0x5D65, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x3F65, 0, 0, 0x4939,
+ 0x314A, 0, 0, 0, 0, 0, 0x4845, 0x7A5B,
+};
+unsigned short utf8_to_euc_E6B1[] = {
+ 0x4475, 0x3D41, 0x3561, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x4846, 0,
+ 0x3C2E, 0, 0, 0, 0, 0x5D68, 0, 0x3440,
+ 0, 0, 0x3178, 0, 0x7A5C, 0x4672, 0x5D67, 0x393E,
+ 0x4353, 0, 0x5D69, 0, 0, 0, 0, 0,
+ 0x5D71, 0, 0x5D6A, 0, 0, 0, 0, 0x7A5E,
+ 0x4241, 0, 0x3562, 0x5D72, 0, 0, 0, 0,
+ 0, 0, 0x3768, 0, 0, 0x3525, 0x5D70, 0,
+};
+unsigned short utf8_to_euc_E6B2[] = {
+ 0, 0x5D6E, 0x5D6B, 0x4D60, 0, 0, 0x7A5D, 0,
+ 0x4440, 0, 0, 0, 0x4659, 0x5D6C, 0, 0,
+ 0x5D74, 0, 0x5D73, 0x3723, 0, 0, 0x322D, 0,
+ 0, 0x3A3B, 0x5D6D, 0x5D6F, 0, 0, 0, 0,
+ 0, 0x4B57, 0x4274, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4B77, 0, 0, 0x5D7C, 0,
+ 0, 0x5D7D, 0, 0x324F, 0, 0, 0, 0,
+ 0x4A28, 0x4C7D, 0x5E21, 0x3C23, 0x3E42, 0x5D78, 0x5D7E, 0x3168,
+};
+unsigned short utf8_to_euc_E6B3[] = {
+ 0, 0x3637, 0, 0, 0x5D75, 0x5D7A, 0, 0,
+ 0, 0x4074, 0x4771, 0, 0x4867, 0, 0, 0,
+ 0, 0, 0, 0x5D77, 0, 0x4B21, 0, 0x5D79,
+ 0, 0x5E24, 0x7A5F, 0x5E22, 0, 0x5D7B, 0, 0,
+ 0, 0x4B22, 0x4748, 0x3563, 0, 0x4525, 0, 0,
+ 0x436D, 0, 0x5E25, 0, 0, 0, 0, 0x5E23,
+ 0x4259, 0x5D76, 0, 0x314B, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6B4[] = {
+ 0, 0, 0, 0, 0x7A60, 0, 0, 0,
+ 0, 0, 0, 0x4D4E, 0x5E30, 0, 0, 0,
+ 0, 0, 0x5E2F, 0, 0, 0, 0, 0x4076,
+ 0, 0x5E2C, 0, 0x4D6C, 0, 0, 0x4636, 0x5E26,
+ 0, 0, 0, 0, 0, 0x4445, 0, 0,
+ 0, 0x314C, 0x393F, 0x5E29, 0, 0, 0, 0,
+ 0, 0, 0x3D27, 0x5E2E, 0, 0x5E2D, 0x5E28, 0,
+ 0x5E2B, 0, 0, 0x3368, 0, 0x5E2A, 0x4749, 0,
+};
+unsigned short utf8_to_euc_E6B5[] = {
+ 0, 0x4E2E, 0, 0, 0x3E74, 0x4075, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5E36, 0x5E34, 0, 0x494D, 0, 0, 0,
+ 0, 0, 0, 0x5E31, 0x5E33, 0, 0x313A, 0,
+ 0, 0x3940, 0x4F32, 0, 0x333D, 0, 0x4962, 0x7A62,
+ 0, 0, 0, 0, 0x4D61, 0, 0, 0x3324,
+ 0x3F3B, 0x5E35, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6B6[] = {
+ 0, 0, 0, 0, 0, 0x5E3A, 0, 0x7A61,
+ 0x3E43, 0, 0, 0, 0x4D30, 0, 0x5E37, 0,
+ 0, 0, 0, 0x5E32, 0, 0x5E38, 0x7A63, 0,
+ 0, 0x4E5E, 0, 0x4573, 0x4642, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7A64, 0, 0, 0x3336,
+ 0, 0, 0x3155, 0, 0, 0x5E3E, 0, 0,
+ 0x5E41, 0, 0, 0, 0x4E43, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6B7[] = {
+ 0x4D64, 0, 0, 0, 0, 0x5E48, 0x5E42, 0x5E3F,
+ 0, 0, 0, 0x4E54, 0x5E45, 0, 0, 0x7A65,
+ 0, 0x3D4A, 0x5E47, 0, 0, 0x5E4C, 0, 0,
+ 0x4571, 0x5E4A, 0, 0, 0, 0, 0x5E44, 0,
+ 0, 0x4338, 0, 0, 0x5E4B, 0, 0x5E40, 0,
+ 0x5E46, 0, 0x5E4D, 0x307C, 0x5E43, 0, 0x5E4E, 0,
+ 0, 0x3F3C, 0x7A67, 0x3D5F, 0, 0x4A25, 0, 0x3A2E,
+ 0x7A66, 0x5E3B, 0x5E49, 0x453A, 0x7A68, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6B8[] = {
+ 0, 0, 0, 0, 0, 0x4036, 0, 0x3369,
+ 0x3A51, 0x3E44, 0x5E3D, 0x3D42, 0, 0, 0, 0,
+ 0, 0, 0, 0x374C, 0, 0x5E3C, 0, 0,
+ 0, 0x5E52, 0x3D6D, 0x383A, 0, 0x5E61, 0, 0x5E5B,
+ 0x3574, 0x454F, 0, 0x5E56, 0x5E5F, 0x302F, 0x3132, 0x7A6B,
+ 0, 0x3239, 0, 0x5E58, 0x422C, 0x5E4F, 0x5E51, 0x3941,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5E62, 0x7A69, 0x5E5D, 0, 0x7A6C, 0, 0x5E55, 0,
+};
+unsigned short utf8_to_euc_E6B9[] = {
+ 0, 0, 0, 0x5E5C, 0, 0, 0, 0,
+ 0, 0, 0x4C2B, 0, 0, 0x5E5A, 0x5E5E, 0,
+ 0, 0, 0, 0, 0, 0, 0x3850, 0,
+ 0x3E45, 0, 0, 0x4339, 0x7A6A, 0, 0, 0x5E54,
+ 0, 0, 0, 0, 0, 0, 0, 0x4D2F,
+ 0, 0, 0, 0x5E57, 0, 0, 0x5E50, 0x4572,
+ 0, 0, 0x5E53, 0, 0, 0, 0x5E59, 0,
+ 0, 0, 0, 0, 0, 0, 0x4F51, 0x3C3E,
+};
+unsigned short utf8_to_euc_E6BA[] = {
+ 0x4B7E, 0, 0x5E63, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x482E, 0, 0, 0x5E6F,
+ 0x383B, 0, 0, 0, 0, 0, 0x3D60, 0,
+ 0x5E65, 0, 0, 0, 0x4E2F, 0x3942, 0, 0x5E72,
+ 0, 0, 0x306E, 0, 0, 0x5E70, 0, 0,
+ 0, 0, 0x5E64, 0, 0, 0, 0, 0x5E6A,
+ 0, 0, 0x5E6C, 0, 0, 0, 0x4D4F, 0x5E67,
+ 0, 0, 0x452E, 0, 0, 0x5E69, 0, 0x7A6D,
+};
+unsigned short utf8_to_euc_E6BB[] = {
+ 0, 0, 0x5E71, 0, 0x5E6B, 0x4C47, 0, 0,
+ 0, 0x5E66, 0, 0x3C22, 0x5E7E, 0, 0, 0,
+ 0, 0x336A, 0, 0x5E68, 0x5E6D, 0x5E6E, 0, 0,
+ 0, 0, 0, 0, 0, 0x426C, 0x425A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5E76, 0, 0, 0x5E7C,
+ 0, 0, 0x5E7A, 0, 0x4529, 0, 0, 0x5F23,
+ 0x5E77, 0, 0, 0, 0, 0, 0x5E78, 0x5E60,
+};
+unsigned short utf8_to_euc_E6BC[] = {
+ 0, 0x3579, 0x493A, 0, 0, 0, 0x3C3F, 0,
+ 0, 0x3977, 0, 0, 0, 0, 0, 0x4F33,
+ 0, 0x5E74, 0, 0x5F22, 0x3169, 0x4166, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4779, 0, 0x3441, 0x4E7A, 0, 0, 0, 0,
+ 0, 0, 0, 0x4C21, 0x4452, 0, 0, 0,
+ 0, 0x5E7B, 0x5E7D, 0, 0, 0, 0, 0,
+ 0x4132, 0, 0, 0, 0, 0, 0x5F21, 0x5E79,
+};
+unsigned short utf8_to_euc_E6BD[] = {
+ 0, 0x5E73, 0, 0, 0, 0x3443, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x3769, 0, 0, 0,
+ 0x5F2F, 0, 0, 0x5F2A, 0x4078, 0, 0, 0x3363,
+ 0, 0, 0, 0, 0x3D61, 0, 0x5F33, 0,
+ 0, 0, 0, 0, 0, 0x5F2C, 0x442C, 0x5F29,
+ 0x4459, 0, 0, 0, 0x5F4C, 0, 0, 0,
+ 0x5F26, 0, 0x5F25, 0, 0x5F2E, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6BE[] = {
+ 0x5F28, 0x5F27, 0x5F2D, 0, 0x4021, 0, 0x5F24, 0,
+ 0x7A6E, 0, 0, 0, 0, 0, 0x5F30, 0,
+ 0, 0x5F31, 0, 0, 0, 0, 0, 0x3442,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5F36, 0, 0x5F35, 0x5F37, 0, 0, 0,
+ 0, 0, 0x5F3A, 0, 0, 0, 0, 0,
+ 0, 0x4543, 0, 0x5F34, 0, 0x7A6F, 0, 0,
+ 0, 0x5F38, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E6BF[] = {
+ 0x3763, 0x4279, 0x5F32, 0x473B, 0, 0, 0x5F39, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5F3E, 0x5F3C, 0, 0,
+ 0x5F3F, 0, 0, 0x5F42, 0, 0, 0, 0x5F3B,
+ 0x396A, 0x4728, 0, 0, 0x5E39, 0, 0, 0,
+ 0, 0, 0, 0x4D74, 0x5F3D, 0, 0x5F41, 0x4275,
+ 0, 0x5F40, 0, 0x5F2B, 0, 0x7A70, 0x6F69, 0,
+ 0, 0, 0x5F45, 0, 0, 0, 0x5F49, 0,
+};
+unsigned short utf8_to_euc_E780[] = {
+ 0, 0x5F47, 0, 0, 0, 0x7A71, 0, 0x7A72,
+ 0, 0x5F43, 0, 0x5F44, 0, 0, 0, 0x5F48,
+ 0, 0x5F46, 0, 0, 0, 0x494E, 0, 0,
+ 0x5F4E, 0, 0x5F4B, 0x5F4A, 0, 0x5F4D, 0x4654, 0x5F4F,
+ 0, 0, 0, 0, 0, 0, 0x4375, 0x426D,
+ 0x7A73, 0, 0, 0, 0x4025, 0, 0, 0,
+ 0x5F50, 0, 0x5F52, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x5F51, 0,
+};
+unsigned short utf8_to_euc_E781[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5E75, 0, 0, 0,
+ 0, 0x5F53, 0, 0, 0, 0, 0, 0,
+ 0x4667, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5F54, 0, 0, 0, 0,
+ 0, 0, 0, 0x3250, 0, 0, 0, 0x4574,
+ 0x3325, 0, 0, 0, 0, 0, 0, 0,
+ 0x3564, 0, 0, 0, 0x3C5E, 0x3A52, 0, 0,
+};
+unsigned short utf8_to_euc_E782[] = {
+ 0, 0, 0, 0, 0, 0x7A74, 0, 0,
+ 0, 0x4F27, 0x3F66, 0, 0, 0, 0x316A, 0,
+ 0, 0, 0x5F56, 0, 0, 0, 0, 0,
+ 0, 0x5F55, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x7A75, 0x5F59, 0x433A, 0x5F5C, 0x5F57,
+ 0, 0, 0, 0x5F5B, 0, 0, 0, 0,
+ 0x5F5A, 0x4540, 0x3059, 0x7927, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E783[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4E75, 0, 0, 0x5F5E, 0, 0, 0, 0x3128,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5F60, 0, 0, 0, 0x5F5F, 0, 0x5F5D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5F58, 0, 0, 0, 0, 0, 0,
+ 0, 0x4B23, 0, 0, 0, 0x5F62, 0, 0,
+};
+unsigned short utf8_to_euc_E784[] = {
+ 0, 0, 0, 0, 0x7A77, 0, 0, 0,
+ 0, 0x5F61, 0, 0, 0, 0, 0, 0x7A76,
+ 0, 0, 0, 0, 0x316B, 0, 0, 0,
+ 0, 0x5F64, 0x4A32, 0, 0x5F63, 0, 0, 0,
+ 0, 0x4C35, 0, 0, 0, 0, 0x3E47, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x4133, 0,
+ 0, 0, 0, 0, 0x3E46, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E785[] = {
+ 0, 0, 0, 0, 0, 0, 0x7A79, 0x7A7A,
+ 0, 0x4E7B, 0, 0, 0x5F6A, 0, 0x4079, 0,
+ 0, 0, 0, 0, 0, 0x5F66, 0x5F6B, 0,
+ 0, 0x316C, 0, 0, 0x7A78, 0, 0, 0,
+ 0, 0, 0x5F69, 0, 0x4761, 0x5F65, 0x5F68, 0x3E48,
+ 0, 0x4851, 0, 0, 0x5F6C, 0, 0x3C51, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x407A, 0, 0,
+};
+unsigned short utf8_to_euc_E786[] = {
+ 0, 0, 0, 0, 0x5F6F, 0, 0, 0,
+ 0x5F67, 0, 0x3727, 0, 0, 0, 0, 0x5F6D,
+ 0, 0, 0, 0, 0x4D50, 0x5F70, 0, 0,
+ 0, 0x7426, 0, 0, 0, 0, 0, 0x3D4F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5F71, 0, 0, 0, 0x5F72, 0, 0, 0,
+ 0, 0x472E, 0, 0, 0, 0, 0, 0,
+ 0, 0x5F74, 0, 0, 0, 0, 0x5F75, 0,
+};
+unsigned short utf8_to_euc_E787[] = {
+ 0, 0x7A7C, 0, 0x4733, 0, 0, 0, 0,
+ 0x4575, 0x5F77, 0, 0, 0, 0, 0x5F79, 0,
+ 0x4E55, 0, 0x5F76, 0, 0x5F78, 0x316D, 0, 0x5F73,
+ 0, 0, 0, 0, 0, 0, 0, 0x535B,
+ 0x5F7A, 0, 0, 0, 0, 0x4167, 0x3B38, 0x5F7C,
+ 0, 0, 0, 0, 0x5F7B, 0x3F24, 0x5259, 0,
+ 0, 0, 0, 0, 0, 0x5F7D, 0, 0,
+ 0, 0x6021, 0, 0x5F6E, 0x5F7E, 0, 0x7A7D, 0x6022,
+};
+unsigned short utf8_to_euc_E788[] = {
+ 0, 0, 0, 0, 0, 0, 0x477A, 0,
+ 0, 0, 0, 0, 0, 0x6023, 0, 0,
+ 0x6024, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6025, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x6026, 0, 0x445E, 0, 0x6028, 0x6027, 0, 0,
+ 0x6029, 0, 0x602A, 0, 0, 0x3C5F, 0x4963, 0,
+ 0, 0, 0x4C6C, 0x602B, 0x602C, 0x4156, 0x3C24, 0x602D,
+};
+unsigned short utf8_to_euc_E789[] = {
+ 0x602E, 0, 0, 0, 0, 0, 0x602F, 0x4A52,
+ 0x4847, 0, 0, 0x6030, 0x4757, 0, 0, 0,
+ 0, 0, 0x442D, 0, 0, 0, 0, 0,
+ 0x6031, 0x3267, 0, 0x356D, 0, 0x4C46, 0, 0x4C36,
+ 0, 0x3234, 0x4F34, 0, 0, 0, 0, 0x4B52,
+ 0, 0x4A2A, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4037, 0, 0x6032, 0, 0, 0,
+ 0, 0x4643, 0, 0, 0, 0x3823, 0x6033, 0,
+};
+unsigned short utf8_to_euc_E78A[] = {
+ 0x3A54, 0x6035, 0x6034, 0, 0, 0, 0, 0x6036,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x6037, 0, 0, 0, 0x6038, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x353E, 0, 0x6039, 0, 0, 0, 0, 0x603A,
+ 0, 0, 0, 0, 0x3824, 0, 0, 0x4848,
+ 0, 0x7A7E, 0x603C, 0, 0, 0, 0x3E75, 0,
+ 0, 0x603B, 0, 0, 0, 0, 0x7B21, 0,
+};
+unsigned short utf8_to_euc_E78B[] = {
+ 0, 0, 0x3638, 0x603D, 0x603F, 0, 0x603E, 0,
+ 0, 0, 0, 0, 0, 0, 0x6040, 0,
+ 0x3851, 0, 0x6041, 0, 0, 0, 0, 0x3669,
+ 0, 0x4140, 0, 0x397D, 0, 0, 0, 0,
+ 0x6043, 0x6044, 0x6042, 0, 0, 0, 0, 0,
+ 0, 0x3C6D, 0, 0, 0x4648, 0x3639, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6046,
+ 0x432C, 0x6045, 0, 0, 0x4F35, 0x4762, 0, 0,
+};
+unsigned short utf8_to_euc_E78C[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x6049, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x604B, 0x6048,
+ 0, 0, 0, 0x4C54, 0x604A, 0x604C, 0, 0x4E44,
+ 0, 0, 0, 0, 0x7B22, 0x6050, 0, 0,
+ 0, 0x604F, 0x4376, 0x472D, 0, 0, 0x3825, 0x604E,
+ 0, 0, 0, 0, 0x604D, 0, 0x4D31, 0x4D32,
+ 0, 0, 0, 0, 0, 0, 0x6051, 0x316E,
+};
+unsigned short utf8_to_euc_E78D[] = {
+ 0, 0, 0, 0, 0x3976, 0x3B62, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x6052, 0x6053,
+ 0, 0, 0, 0, 0, 0, 0, 0x6055,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3D43, 0, 0, 0, 0,
+ 0x6057, 0, 0x6056, 0, 0, 0, 0, 0,
+ 0x6058, 0, 0x334D, 0, 0, 0x605A, 0, 0x7B24,
+ 0x6059, 0, 0x605C, 0x605B, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E78E[] = {
+ 0, 0, 0, 0, 0x383C, 0, 0, 0x4E28,
+ 0, 0x364C, 0, 0x3226, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x366A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3461, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4E68, 0x605E, 0, 0, 0, 0,
+ 0, 0, 0, 0x6060, 0, 0x7B25, 0, 0,
+};
+unsigned short utf8_to_euc_E78F[] = {
+ 0x6061, 0, 0x3251, 0, 0, 0, 0, 0,
+ 0x605D, 0x7B26, 0x3B39, 0, 0, 0x4441, 0x605F, 0,
+ 0, 0, 0x7B29, 0, 0, 0, 0x7B27, 0,
+ 0, 0, 0, 0, 0, 0, 0x6064, 0,
+ 0x3C6E, 0, 0, 0x7B28, 0, 0x6062, 0, 0,
+ 0, 0, 0x373E, 0, 0, 0x4849, 0x6063, 0,
+ 0, 0x607E, 0, 0, 0, 0x7B2B, 0, 0,
+ 0x6069, 0, 0, 0, 0, 0, 0x383D, 0,
+};
+unsigned short utf8_to_euc_E790[] = {
+ 0, 0, 0, 0x3565, 0, 0x6066, 0x4D7D, 0x7B2A,
+ 0, 0x4E30, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4276, 0, 0, 0x6068, 0x7B2C, 0,
+ 0, 0x7B2E, 0x7B2D, 0, 0, 0, 0x7B2F, 0,
+ 0, 0, 0x606A, 0x4E56, 0x3657, 0x487C, 0x474A, 0,
+ 0, 0, 0x606B, 0, 0, 0, 0, 0x606D,
+};
+unsigned short utf8_to_euc_E791[] = {
+ 0, 0x6070, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x606C, 0, 0,
+ 0, 0x606F, 0x386A, 0x314D, 0x6071, 0, 0x3F70, 0x606E,
+ 0x4E5C, 0, 0x7B30, 0x6074, 0x7424, 0, 0, 0,
+ 0, 0x6072, 0x6075, 0, 0, 0, 0, 0x6067,
+ 0x6073, 0, 0, 0x3A3C, 0, 0, 0x6076, 0,
+ 0, 0, 0, 0, 0, 0, 0x6077, 0,
+};
+unsigned short utf8_to_euc_E792[] = {
+ 0, 0, 0, 0x4D7E, 0, 0, 0, 0,
+ 0, 0x7B31, 0, 0x6078, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x6079, 0x7B32,
+ 0, 0, 0x6065, 0, 0, 0, 0, 0x607A,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x3444, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x3C25, 0, 0,
+};
+unsigned short utf8_to_euc_E793[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x607B, 0, 0, 0, 0, 0x607C,
+ 0, 0, 0, 0, 0x607D, 0, 0, 0,
+ 0, 0, 0, 0, 0x313B, 0, 0, 0,
+ 0x6121, 0, 0x493B, 0x6122, 0, 0, 0x3424, 0x6123,
+ 0, 0x6124, 0, 0, 0, 0, 0x6125, 0,
+ 0x6127, 0x6128, 0x6126, 0, 0, 0, 0x4953, 0x612A,
+ 0x6129, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E794[] = {
+ 0, 0x7B33, 0, 0x612C, 0x612B, 0x612D, 0, 0,
+ 0, 0, 0, 0, 0x612E, 0x6130, 0x612F, 0,
+ 0, 0x3979, 0, 0x6132, 0, 0x6131, 0, 0,
+ 0x3445, 0, 0x3F53, 0, 0x453C, 0, 0x6133, 0x4038,
+ 0, 0, 0, 0x3B3A, 0, 0x3179, 0x6134, 0,
+ 0x4D51, 0, 0, 0x4A63, 0x6135, 0, 0, 0x796C,
+ 0x4544, 0x4D33, 0x3943, 0x3F3D, 0, 0, 0, 0x434B,
+ 0x5234, 0, 0x442E, 0x3268, 0x6136, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E795[] = {
+ 0, 0, 0, 0, 0x6137, 0, 0x613C, 0,
+ 0, 0x613A, 0x6139, 0x5A42, 0x3326, 0x6138, 0, 0x305A,
+ 0, 0x482A, 0, 0, 0x484A, 0, 0, 0,
+ 0, 0x4E31, 0x613D, 0x613B, 0x435C, 0x4026, 0, 0,
+ 0x482B, 0, 0x492D, 0, 0x613F, 0x4E2C, 0x374D, 0x6140,
+ 0, 0x613E, 0x4856, 0x6141, 0, 0x6142, 0, 0x7B34,
+ 0x305B, 0, 0, 0x3E76, 0x6147, 0, 0x6144, 0x466D,
+ 0x6143, 0, 0, 0, 0, 0, 0, 0x3526,
+};
+unsigned short utf8_to_euc_E796[] = {
+ 0, 0, 0x614A, 0, 0, 0, 0x6145, 0x6146,
+ 0, 0x6149, 0x6148, 0x4925, 0, 0, 0x4142, 0x4141,
+ 0, 0x353F, 0, 0, 0x614B, 0, 0, 0,
+ 0, 0, 0x614C, 0, 0, 0x614D, 0, 0,
+ 0, 0, 0, 0x614F, 0, 0x614E, 0, 0,
+ 0, 0, 0, 0x3156, 0, 0, 0, 0,
+ 0, 0x6157, 0x4868, 0x6151, 0, 0x6153, 0, 0,
+ 0x6155, 0x3F3E, 0, 0, 0x6156, 0x6154, 0x3C40, 0,
+};
+unsigned short utf8_to_euc_E797[] = {
+ 0, 0, 0x6150, 0x6152, 0, 0x4942, 0, 0x3E49,
+ 0, 0, 0x6159, 0, 0, 0x6158, 0, 0,
+ 0, 0, 0x615A, 0, 0x3C26, 0x3A2F, 0, 0,
+ 0x4577, 0x615B, 0, 0x444B, 0, 0, 0x615D, 0,
+ 0, 0, 0x4E21, 0x615C, 0, 0, 0, 0,
+ 0, 0x4169, 0, 0, 0, 0, 0, 0,
+ 0x6162, 0, 0x6164, 0x6165, 0x4354, 0, 0, 0,
+ 0, 0, 0x6163, 0, 0x6160, 0, 0x615E, 0x615F,
+};
+unsigned short utf8_to_euc_E798[] = {
+ 0, 0x6161, 0, 0, 0, 0, 0, 0,
+ 0, 0x6168, 0, 0x6166, 0, 0x6167, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6169,
+ 0x616B, 0x616C, 0x616D, 0, 0x616E, 0, 0, 0x616A,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x6170, 0, 0, 0, 0x616F, 0, 0, 0,
+ 0, 0, 0, 0x6171, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E799[] = {
+ 0, 0, 0x4E45, 0, 0, 0, 0x6174, 0x6172,
+ 0x6173, 0, 0, 0, 0x3462, 0, 0, 0,
+ 0, 0, 0x4C7E, 0, 0, 0, 0x4A4A, 0,
+ 0x6176, 0, 0, 0, 0x6175, 0, 0, 0,
+ 0, 0x6177, 0x6178, 0, 0, 0, 0, 0x617C,
+ 0x6179, 0x617A, 0x617B, 0, 0x617D, 0, 0, 0,
+ 0x617E, 0, 0x6221, 0, 0, 0, 0x6222, 0,
+ 0x6223, 0, 0x482F, 0x4550, 0x6224, 0x4772, 0x4934, 0,
+};
+unsigned short utf8_to_euc_E79A[] = {
+ 0x6225, 0, 0x7B35, 0x6226, 0x452A, 0, 0x3327, 0x3944,
+ 0x6227, 0, 0, 0x6228, 0, 0, 0x6229, 0,
+ 0x3B29, 0, 0, 0x622B, 0, 0, 0x622A, 0,
+ 0, 0x622C, 0x622D, 0x7B38, 0x7B36, 0, 0x7B37, 0,
+ 0, 0, 0, 0, 0, 0, 0x7B39, 0,
+ 0, 0, 0, 0, 0, 0, 0x4869, 0,
+ 0x622E, 0, 0, 0, 0x622F, 0, 0, 0x7369,
+ 0x6230, 0x6231, 0x6232, 0, 0, 0, 0, 0x3B2E,
+};
+unsigned short utf8_to_euc_E79B[] = {
+ 0, 0, 0x6233, 0x4756, 0, 0, 0x4B5F, 0,
+ 0x314E, 0, 0x3157, 0, 0, 0x6234, 0, 0,
+ 0, 0, 0x6236, 0, 0, 0, 0x6235, 0x4570,
+ 0, 0, 0, 0x4039, 0x5D39, 0, 0x6237, 0x4C41,
+ 0, 0x6238, 0, 0x3446, 0x4857, 0x6239, 0, 0x623A,
+ 0, 0, 0x623B, 0, 0, 0, 0x4C5C, 0,
+ 0, 0, 0x4C55, 0, 0x443E, 0, 0, 0,
+ 0x416A, 0, 0, 0x623D, 0, 0, 0x3D62, 0,
+};
+unsigned short utf8_to_euc_E79C[] = {
+ 0, 0x3E4A, 0, 0, 0x6240, 0, 0, 0x623F,
+ 0x623E, 0x487D, 0, 0x3447, 0x3829, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6246, 0, 0, 0x6243, 0x3F3F,
+ 0x4C32, 0, 0, 0, 0x6242, 0x6244, 0x6245, 0,
+ 0, 0x6241, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6247,
+ 0x6248, 0, 0x442F, 0, 0x3463, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E79D[] = {
+ 0x4365, 0, 0, 0, 0, 0, 0x7B3B, 0x6249,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x624A, 0x624D, 0, 0, 0, 0,
+ 0, 0x3F67, 0, 0x4644, 0, 0x624E, 0x4B53, 0,
+ 0x624B, 0, 0, 0x624C, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6251, 0, 0, 0, 0, 0x6250, 0x624F,
+};
+unsigned short utf8_to_euc_E79E[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6253, 0, 0, 0x6252, 0,
+ 0, 0x6254, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x6256, 0,
+ 0x6255, 0, 0, 0, 0, 0x4A4D, 0, 0,
+ 0, 0, 0, 0, 0x3D56, 0x4E46, 0, 0,
+ 0x6257, 0, 0, 0x4637, 0, 0, 0x6258, 0,
+ 0, 0x6259, 0, 0x625D, 0x625B, 0x625C, 0, 0x625A,
+};
+unsigned short utf8_to_euc_E79F[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0x625E,
+ 0, 0, 0, 0, 0, 0x625F, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6260,
+ 0, 0, 0x6261, 0x4C37, 0x6262, 0, 0, 0,
+ 0, 0, 0x4C70, 0x6263, 0, 0x434E, 0, 0x476A,
+ 0, 0x366B, 0, 0, 0, 0x433B, 0x6264, 0x363A,
+ 0, 0, 0, 0x4050, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x6265, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7A0[] = {
+ 0, 0, 0x3A3D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x6266, 0, 0, 0,
+ 0, 0, 0x6267, 0, 0x3826, 0x3A55, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x6269, 0x7B3D, 0, 0, 0, 0x4556, 0x3A56, 0x354E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4B24, 0, 0x474B, 0, 0, 0,
+ 0, 0, 0x4557, 0, 0, 0, 0, 0x395C,
+};
+unsigned short utf8_to_euc_E7A1[] = {
+ 0, 0, 0, 0, 0, 0x626B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x7B3E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x3E4B, 0, 0,
+ 0, 0, 0, 0, 0x7B3F, 0, 0, 0,
+ 0, 0, 0, 0x4E32, 0x3945, 0, 0, 0x3827,
+ 0, 0, 0x4823, 0, 0x626D, 0, 0, 0,
+ 0, 0, 0x7B40, 0, 0x626F, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7A2[] = {
+ 0, 0x386B, 0, 0, 0, 0, 0x626E, 0x4476,
+ 0, 0, 0, 0, 0x6271, 0x3337, 0x626C, 0,
+ 0, 0x486A, 0, 0x3130, 0, 0x3A6C, 0, 0x4F52,
+ 0, 0, 0x6270, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6272, 0, 0, 0, 0x4A4B,
+ 0, 0x4059, 0x6274, 0, 0, 0, 0, 0x6275,
+ 0, 0, 0, 0, 0, 0x6273, 0, 0,
+ 0, 0, 0x334E, 0, 0x627B, 0, 0x627A, 0,
+};
+unsigned short utf8_to_euc_E7A3[] = {
+ 0, 0x3C27, 0, 0, 0, 0x627C, 0x6277, 0,
+ 0, 0, 0x627D, 0x6278, 0, 0, 0, 0,
+ 0x4858, 0x6276, 0, 0, 0x6279, 0, 0, 0,
+ 0, 0, 0x6322, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6321,
+ 0x4B61, 0, 0, 0, 0x627E, 0, 0, 0x306B,
+ 0, 0, 0, 0, 0x6324, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x6323, 0, 0,
+};
+unsigned short utf8_to_euc_E7A4[] = {
+ 0, 0x3E4C, 0, 0, 0, 0, 0, 0x6325,
+ 0, 0, 0, 0, 0, 0, 0x4143, 0,
+ 0, 0x6327, 0x6326, 0, 0, 0, 0, 0,
+ 0, 0x6328, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x6268, 0,
+ 0, 0, 0x626A, 0x632A, 0x6329, 0, 0, 0,
+ 0x7B41, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3C28, 0, 0x4E69, 0, 0x3C52, 0,
+};
+unsigned short utf8_to_euc_E7A5[] = {
+ 0x632B, 0x3737, 0, 0, 0, 0, 0, 0x3540,
+ 0x3527, 0x3B63, 0, 0, 0, 0, 0, 0,
+ 0x4D34, 0, 0, 0x6331, 0, 0x6330, 0x4144, 0x632D,
+ 0, 0, 0x632F, 0, 0, 0x3D4B, 0x3F40, 0x632E,
+ 0x632C, 0, 0x472A, 0, 0, 0x3E4D, 0, 0,
+ 0x493C, 0, 0, 0, 0, 0x3A57, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4578,
+ 0, 0, 0x6332, 0, 0, 0, 0, 0x6333,
+};
+unsigned short utf8_to_euc_E7A6[] = {
+ 0x6349, 0x3658, 0, 0, 0x4F3D, 0x4135, 0, 0,
+ 0, 0, 0x6334, 0, 0, 0x3252, 0x4477, 0x4A21,
+ 0, 0, 0, 0, 0x7B45, 0, 0, 0,
+ 0, 0, 0, 0x7B47, 0, 0x6335, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x357A, 0x6336,
+ 0, 0, 0x6338, 0, 0, 0, 0x6339, 0,
+ 0x4729, 0, 0, 0x633A, 0, 0, 0, 0,
+ 0, 0x633B, 0x633C, 0, 0, 0x3659, 0x3253, 0x4645,
+};
+unsigned short utf8_to_euc_E7A7[] = {
+ 0x3D28, 0x3B64, 0, 0, 0, 0, 0, 0,
+ 0, 0x633D, 0, 0x3D29, 0, 0, 0, 0,
+ 0, 0x324A, 0x4943, 0, 0, 0x633E, 0, 0,
+ 0x486B, 0, 0, 0, 0, 0, 0, 0x4145,
+ 0, 0x6341, 0, 0x6342, 0x4769, 0, 0x3F41, 0x633F,
+ 0, 0x4361, 0, 0, 0x6340, 0, 0, 0,
+ 0x3E4E, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x305C, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7A8[] = {
+ 0x3529, 0, 0, 0, 0, 0, 0, 0,
+ 0x6343, 0, 0, 0x4478, 0, 0x6344, 0x4047, 0,
+ 0, 0, 0, 0, 0x4C2D, 0, 0, 0x4923,
+ 0x6345, 0x6346, 0x4355, 0, 0x4E47, 0, 0, 0x6348,
+ 0x6347, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3C6F, 0,
+ 0, 0x634A, 0x3070, 0, 0, 0, 0, 0x634D,
+ 0, 0, 0, 0x634B, 0x3254, 0x374E, 0x634C, 0x3946,
+};
+unsigned short utf8_to_euc_E7A9[] = {
+ 0x3972, 0, 0x4A66, 0x634E, 0, 0, 0x4B54, 0,
+ 0, 0x6350, 0, 0, 0, 0x4051, 0x314F, 0x323A,
+ 0x302C, 0, 0, 0, 0, 0, 0, 0x634F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6351, 0x6352, 0x3E77, 0, 0, 0, 0,
+ 0, 0x6353, 0, 0x334F, 0, 0, 0, 0,
+ 0x6355, 0, 0, 0, 0x376A, 0, 0x3566, 0,
+ 0, 0x6356, 0x3675, 0, 0, 0x6357, 0, 0x407C,
+};
+unsigned short utf8_to_euc_E7AA[] = {
+ 0, 0x464D, 0, 0x4060, 0x3A75, 0, 0, 0,
+ 0x6358, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4362, 0x416B, 0, 0x635A, 0x635C, 0x6359,
+ 0x635B, 0, 0, 0, 0, 0, 0, 0x3722,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x635D, 0x3726, 0, 0, 0, 0x3567, 0x4D52,
+ 0x635F, 0, 0, 0, 0, 0, 0x6360, 0,
+ 0, 0, 0x312E, 0, 0, 0, 0, 0x6363,
+};
+unsigned short utf8_to_euc_E7AB[] = {
+ 0, 0, 0, 0x3376, 0x6362, 0x6361, 0, 0x6365,
+ 0x635E, 0, 0x6366, 0x4E29, 0, 0x6367, 0, 0x6368,
+ 0, 0x7B48, 0x5474, 0x636A, 0, 0x6369, 0, 0,
+ 0, 0x636B, 0x636C, 0, 0x4E35, 0x636D, 0, 0x706F,
+ 0x3E4F, 0x636E, 0x636F, 0x3D57, 0, 0x4638, 0x6370, 0x7B49,
+ 0, 0, 0x4328, 0x7B4B, 0, 0x6371, 0, 0x433C,
+ 0x6372, 0, 0, 0, 0, 0, 0x3625, 0,
+ 0x513F, 0x435D, 0x3C33, 0, 0, 0, 0, 0x3448,
+};
+unsigned short utf8_to_euc_E7AC[] = {
+ 0, 0, 0x6373, 0, 0x6422, 0, 0x6376, 0,
+ 0x3568, 0, 0x6375, 0x6424, 0, 0, 0, 0x6374,
+ 0, 0x3E50, 0, 0, 0, 0, 0, 0,
+ 0x6378, 0x6379, 0, 0x452B, 0, 0, 0x637A, 0,
+ 0x335E, 0, 0, 0, 0, 0x3F5A, 0x4964, 0,
+ 0x637C, 0, 0, 0, 0x4268, 0, 0, 0,
+ 0, 0, 0, 0x6377, 0, 0x637B, 0x637D, 0,
+ 0, 0x3A7B, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7AD[] = {
+ 0, 0, 0, 0, 0, 0x6426, 0x492E, 0,
+ 0x4826, 0x4579, 0, 0x365A, 0x6425, 0x6423, 0, 0x4835,
+ 0x637E, 0x435E, 0x457B, 0, 0x457A, 0, 0x3A76, 0,
+ 0, 0, 0, 0, 0, 0x6438, 0, 0,
+ 0, 0, 0, 0, 0, 0x6428, 0, 0x642A,
+ 0, 0, 0, 0, 0x642D, 0, 0x642E, 0,
+ 0x642B, 0x642C, 0, 0, 0x6429, 0x6427, 0, 0,
+ 0, 0, 0x6421, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7AE[] = {
+ 0, 0, 0, 0, 0, 0, 0x4A4F, 0x3255,
+ 0, 0, 0, 0x6435, 0, 0x6432, 0, 0x6437,
+ 0, 0, 0x6436, 0, 0x4773, 0x4C27, 0, 0x3B3B,
+ 0x6430, 0x6439, 0x6434, 0, 0x6433, 0x642F, 0x7B4C, 0x6431,
+ 0, 0x3449, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x433D, 0, 0, 0x407D, 0, 0,
+ 0, 0x4822, 0, 0, 0x643E, 0, 0, 0,
+ 0x4824, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7AF[] = {
+ 0x4061, 0x643B, 0, 0, 0x484F, 0, 0x643F, 0x4A53,
+ 0, 0x435B, 0, 0x643A, 0x643C, 0, 0, 0x643D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x6440, 0, 0,
+ 0x3C44, 0, 0, 0, 0x4646, 0x6445, 0x6444, 0,
+ 0, 0x6441, 0, 0, 0, 0x4F36, 0, 0,
+ 0, 0, 0, 0x644A, 0, 0, 0x644E, 0x644B,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7B0[] = {
+ 0x6447, 0, 0, 0, 0, 0, 0, 0x6448,
+ 0, 0, 0, 0, 0, 0x644D, 0, 0,
+ 0, 0x6442, 0x5255, 0x6449, 0x6443, 0, 0, 0x644C,
+ 0, 0, 0, 0, 0, 0, 0, 0x6452,
+ 0, 0x344A, 0, 0x644F, 0, 0, 0, 0x6450,
+ 0, 0, 0x6451, 0x6454, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6453,
+ 0x4876, 0, 0, 0, 0, 0x6455, 0x4E7C, 0x4A6D,
+};
+unsigned short utf8_to_euc_E7B1[] = {
+ 0x645A, 0, 0, 0x6457, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x6456, 0x4052, 0, 0x6459,
+ 0x645B, 0, 0, 0, 0x6458, 0, 0x645F, 0,
+ 0x645C, 0, 0, 0, 0, 0, 0, 0x645D,
+ 0x6446, 0, 0, 0, 0x645E, 0x6460, 0, 0,
+ 0, 0, 0, 0, 0x6461, 0, 0, 0,
+ 0, 0, 0, 0x4A46, 0, 0x6462, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x4C62, 0,
+};
+unsigned short utf8_to_euc_E7B2[] = {
+ 0, 0x364E, 0x3729, 0x6463, 0, 0, 0, 0,
+ 0, 0x4A34, 0, 0x3F68, 0, 0x4C30, 0, 0,
+ 0x6464, 0, 0x4E33, 0, 0, 0x4774, 0, 0x4146,
+ 0x4734, 0, 0, 0x3D4D, 0, 0, 0, 0x3040,
+ 0, 0x6469, 0x6467, 0, 0x6465, 0x3421, 0, 0x3E51,
+ 0x646A, 0, 0, 0x6468, 0, 0x6466, 0x646E, 0,
+ 0, 0x646D, 0x646C, 0x646B, 0, 0, 0, 0,
+ 0, 0x646F, 0, 0, 0, 0x6470, 0x403A, 0,
+};
+unsigned short utf8_to_euc_E7B3[] = {
+ 0x6471, 0, 0x6473, 0, 0, 0x6472, 0, 0,
+ 0, 0, 0x3852, 0, 0, 0, 0x4138, 0,
+ 0, 0, 0x6475, 0, 0, 0, 0x457C, 0,
+ 0x6474, 0, 0, 0, 0x6476, 0, 0x4A35, 0x416C,
+ 0x3947, 0, 0x6477, 0, 0, 0, 0, 0x4E48,
+ 0, 0, 0, 0, 0, 0, 0, 0x6479,
+ 0, 0, 0x647A, 0, 0x647B, 0, 0x647C, 0,
+ 0x3B65, 0, 0x647D, 0x374F, 0, 0, 0x356A, 0,
+};
+unsigned short utf8_to_euc_E7B4[] = {
+ 0x352A, 0, 0x6521, 0, 0x4C73, 0x3948, 0x647E, 0,
+ 0, 0, 0x6524, 0x4C66, 0, 0x473C, 0, 0,
+ 0x4933, 0, 0, 0, 0x3D63, 0x6523, 0, 0x3C53,
+ 0x3949, 0x3B66, 0x3569, 0x4A36, 0x6522, 0, 0, 0,
+ 0x4147, 0x4B42, 0x3A77, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3B67, 0x445D, 0, 0x6527, 0x4E5F,
+ 0x3A59, 0, 0x6528, 0x3F42, 0, 0x652A, 0, 0,
+ 0, 0x3E52, 0x3A30, 0, 0, 0, 0, 0x6529,
+};
+unsigned short utf8_to_euc_E7B5[] = {
+ 0, 0, 0x3D2A, 0x383E, 0x4148, 0x6525, 0x652B, 0,
+ 0x7B4E, 0, 0, 0x6526, 0x3750, 0, 0x652E, 0x6532,
+ 0x376B, 0, 0, 0, 0, 0, 0x652D, 0,
+ 0, 0, 0, 0x6536, 0x7B4F, 0, 0x394A, 0,
+ 0, 0x4D6D, 0x303C, 0x6533, 0, 0, 0x356B, 0,
+ 0x6530, 0, 0, 0, 0, 0, 0x6531, 0,
+ 0, 0x457D, 0x652F, 0x652C, 0, 0x3328, 0x4064, 0,
+ 0, 0x3828, 0, 0, 0, 0x6538, 0, 0,
+};
+unsigned short utf8_to_euc_E7B6[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6535, 0, 0, 0, 0, 0, 0x6537,
+ 0, 0, 0, 0x6534, 0, 0, 0, 0,
+ 0, 0x3751, 0x4233, 0x6539, 0x416E, 0, 0, 0x6546,
+ 0x7B51, 0, 0x6542, 0x653C, 0, 0, 0, 0,
+ 0, 0, 0, 0x6540, 0x3C7A, 0x305D, 0x653B, 0x6543,
+ 0x6547, 0x394B, 0x4C56, 0, 0x4456, 0x653D, 0, 0x7B50,
+ 0x6545, 0, 0x653A, 0x433E, 0, 0x653F, 0x303D, 0x4C4A,
+};
+unsigned short utf8_to_euc_E7B7[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0x653E,
+ 0, 0, 0x365B, 0x486C, 0, 0, 0, 0x416D,
+ 0, 0x4E50, 0x3D6F, 0, 0, 0x656E, 0x7B52, 0,
+ 0x6548, 0, 0x407E, 0, 0x6544, 0x6549, 0x654B, 0,
+ 0x4479, 0x654E, 0, 0, 0x654A, 0, 0, 0,
+ 0x4A54, 0x344B, 0, 0, 0x4C4B, 0, 0, 0x305E,
+ 0, 0, 0x654D, 0, 0x4E7D, 0, 0, 0,
+ 0, 0, 0, 0x654C, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7B8[] = {
+ 0, 0x316F, 0, 0, 0x466C, 0x654F, 0, 0,
+ 0, 0x6556, 0x6550, 0x6557, 0, 0, 0, 0,
+ 0, 0, 0x6553, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x477B, 0, 0, 0x3C4A, 0x6555,
+ 0, 0x6552, 0x6558, 0x6551, 0, 0, 0x3D44, 0,
+ 0, 0, 0, 0x4B25, 0, 0, 0x3D4C, 0,
+ 0, 0x6554, 0x6560, 0, 0, 0x655C, 0, 0x655F,
+ 0, 0x655D, 0x6561, 0x655B, 0, 0x6541, 0x4053, 0,
+};
+unsigned short utf8_to_euc_E7B9[] = {
+ 0, 0x484B, 0, 0x655E, 0, 0, 0x6559, 0,
+ 0, 0, 0x4121, 0x3752, 0, 0x3D2B, 0, 0,
+ 0, 0, 0x7B53, 0, 0x3F25, 0x4136, 0x6564, 0,
+ 0, 0x6566, 0x6567, 0, 0, 0x6563, 0x6565, 0,
+ 0, 0, 0, 0, 0, 0, 0x655A, 0x6562,
+ 0, 0x656A, 0x6569, 0, 0, 0x4B7A, 0, 0,
+ 0x372B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6568, 0, 0x656C, 0x656B, 0x656F, 0, 0x6571,
+};
+unsigned short utf8_to_euc_E7BA[] = {
+ 0, 0, 0x3B3C, 0x656D, 0, 0, 0, 0,
+ 0x6572, 0x6573, 0x7921, 0, 0x6574, 0, 0x657A, 0x453B,
+ 0x6576, 0, 0x6575, 0x6577, 0x6578, 0, 0x6579, 0,
+ 0, 0, 0, 0x657B, 0x657C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7BC[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x344C, 0,
+ 0x657D, 0, 0x657E, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7BD[] = {
+ 0, 0, 0, 0, 0, 0x6621, 0, 0x7B54,
+ 0, 0, 0, 0, 0x6622, 0x6623, 0x6624, 0,
+ 0x6625, 0x6626, 0, 0, 0x6628, 0x6627, 0, 0,
+ 0x6629, 0, 0, 0, 0, 0, 0, 0x662A,
+ 0x662B, 0, 0, 0, 0, 0, 0, 0x662E,
+ 0x662C, 0x662D, 0x3A61, 0x3753, 0, 0, 0x4356, 0,
+ 0x4833, 0, 0x3D70, 0, 0, 0x474D, 0, 0x486D,
+ 0x662F, 0x586D, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E7BE[] = {
+ 0, 0, 0x6630, 0x6632, 0, 0x4D65, 0x6631, 0x6634,
+ 0x6633, 0, 0x4D53, 0, 0x6635, 0, 0x487E, 0,
+ 0, 0, 0, 0, 0x6636, 0, 0, 0,
+ 0, 0, 0x6639, 0, 0, 0x6638, 0x6637, 0,
+ 0, 0x7B55, 0, 0x663A, 0x3732, 0, 0, 0,
+ 0x4122, 0x3541, 0, 0, 0, 0, 0x663E, 0x663B,
+ 0, 0, 0x663C, 0, 0, 0, 0x663F, 0,
+ 0x6640, 0x663D, 0, 0, 0, 0x3129, 0, 0,
+};
+unsigned short utf8_to_euc_E7BF[] = {
+ 0, 0x3227, 0, 0, 0, 0x6642, 0x6643, 0,
+ 0, 0, 0x6644, 0, 0x4D62, 0, 0, 0,
+ 0, 0, 0x3D2C, 0, 0x6646, 0x6645, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x3F69, 0x6647, 0, 0, 0, 0, 0x6648, 0,
+ 0, 0x6649, 0, 0x3465, 0, 0, 0, 0,
+ 0x344D, 0, 0, 0x664A, 0, 0, 0, 0,
+ 0, 0x664B, 0, 0x4B5D, 0x4D63, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E880[] = {
+ 0x4D54, 0x4F37, 0, 0x394D, 0x664E, 0x3C54, 0x664D, 0,
+ 0, 0, 0, 0x664F, 0x3C29, 0, 0, 0,
+ 0x4251, 0, 0x6650, 0, 0, 0x394C, 0, 0x4C57,
+ 0x6651, 0x6652, 0, 0, 0x6653, 0, 0, 0,
+ 0, 0x6654, 0, 0, 0, 0, 0, 0,
+ 0x6655, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3C2A, 0, 0, 0x4C6D, 0,
+ 0, 0, 0, 0x6657, 0, 0x433F, 0, 0x6656,
+};
+unsigned short utf8_to_euc_E881[] = {
+ 0, 0, 0, 0, 0, 0, 0x6659, 0,
+ 0, 0, 0x6658, 0, 0, 0, 0, 0,
+ 0, 0, 0x665A, 0, 0, 0, 0x403B, 0,
+ 0x665B, 0, 0x665C, 0, 0, 0, 0x4A39, 0x665D,
+ 0, 0x416F, 0x665E, 0, 0, 0, 0, 0,
+ 0x665F, 0, 0, 0, 0, 0, 0, 0x4E7E,
+ 0x6662, 0, 0x6661, 0x6660, 0x4430, 0, 0x6663, 0x3F26,
+ 0, 0x6664, 0, 0, 0, 0x6665, 0x4F38, 0x6666,
+};
+unsigned short utf8_to_euc_E882[] = {
+ 0, 0, 0, 0, 0x6667, 0x6669, 0x6668, 0x4825,
+ 0, 0x4679, 0, 0x4F3E, 0x4829, 0, 0, 0,
+ 0, 0, 0, 0x666B, 0, 0, 0x3E53, 0,
+ 0x492A, 0, 0x666C, 0x666A, 0, 0x344E, 0, 0,
+ 0, 0x3854, 0x3B68, 0, 0, 0x486E, 0, 0,
+ 0, 0x382A, 0x4B43, 0, 0x666F, 0x666D, 0, 0x394E,
+ 0, 0x394F, 0x3069, 0, 0x3A68, 0, 0, 0,
+ 0, 0, 0x4759, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E883[] = {
+ 0, 0, 0, 0x305F, 0x6674, 0, 0x4340, 0,
+ 0, 0, 0, 0, 0x4758, 0, 0x425B, 0,
+ 0, 0, 0, 0, 0, 0, 0x6676, 0,
+ 0, 0x6672, 0x6675, 0x6670, 0, 0x6673, 0x4B26, 0,
+ 0, 0x3855, 0, 0, 0x307D, 0x6671, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6678,
+ 0, 0x6679, 0, 0, 0x4639, 0, 0, 0,
+ 0x363B, 0, 0, 0, 0x6726, 0x473D, 0, 0,
+};
+unsigned short utf8_to_euc_E884[] = {
+ 0, 0, 0x3B69, 0, 0, 0x363C, 0x4048, 0x4F46,
+ 0x4C2E, 0x6677, 0x4054, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3553, 0x667A, 0, 0, 0, 0,
+ 0, 0, 0, 0x667C, 0, 0, 0, 0,
+ 0, 0x667B, 0, 0, 0, 0, 0, 0x667D,
+ 0, 0x4326, 0, 0x473E, 0, 0, 0, 0,
+ 0, 0x4431, 0, 0, 0, 0, 0x6723, 0,
+};
+unsigned short utf8_to_euc_E885[] = {
+ 0, 0, 0, 0, 0, 0, 0x6722, 0,
+ 0, 0, 0, 0x667E, 0, 0, 0x3F55, 0,
+ 0x4965, 0x6725, 0, 0x6724, 0x3950, 0x4F53, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6735,
+ 0, 0, 0, 0, 0, 0x6729, 0x672A, 0,
+ 0, 0, 0, 0x3C70, 0, 0, 0x6728, 0,
+ 0x3978, 0x6727, 0, 0, 0x672B, 0, 0, 0,
+ 0x4432, 0x4A22, 0x4123, 0, 0, 0, 0, 0x425C,
+};
+unsigned short utf8_to_euc_E886[] = {
+ 0x672F, 0, 0x6730, 0x672C, 0, 0, 0, 0,
+ 0x672D, 0, 0x672E, 0, 0, 0, 0, 0x3951,
+ 0, 0, 0, 0x6736, 0, 0x6732, 0, 0,
+ 0, 0, 0x4966, 0, 0x4B6C, 0x4928, 0, 0,
+ 0x6731, 0, 0, 0x6734, 0x6733, 0, 0, 0,
+ 0x4B44, 0x6737, 0, 0, 0, 0, 0, 0,
+ 0x6738, 0, 0, 0x4137, 0, 0x6739, 0, 0,
+ 0x673B, 0, 0x673F, 0, 0, 0x673C, 0x673A, 0x473F,
+};
+unsigned short utf8_to_euc_E887[] = {
+ 0x673D, 0, 0x673E, 0, 0, 0, 0x3232, 0,
+ 0x6745, 0x6740, 0, 0, 0, 0x6741, 0, 0,
+ 0, 0x6742, 0, 0x4221, 0, 0, 0, 0,
+ 0x6744, 0x6743, 0x6746, 0, 0, 0, 0, 0x6747,
+ 0x6748, 0, 0, 0x3F43, 0, 0x3269, 0, 0x6749,
+ 0x4E57, 0, 0x3C2B, 0, 0, 0x3D2D, 0, 0,
+ 0, 0, 0, 0x3B6A, 0x4357, 0, 0, 0,
+ 0, 0, 0x674A, 0x674B, 0x3131, 0, 0x674C, 0,
+};
+unsigned short utf8_to_euc_E888[] = {
+ 0, 0x674D, 0x674E, 0, 0, 0x674F, 0, 0x6750,
+ 0x363D, 0x5A2A, 0x6751, 0, 0x4065, 0x6752, 0x3C4B, 0,
+ 0x6753, 0, 0x5030, 0, 0, 0, 0x6754, 0x4A5E,
+ 0x345C, 0, 0, 0x4124, 0x3D58, 0, 0x4971, 0x3D2E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6755, 0x3952, 0x6756, 0x484C, 0, 0x6764, 0,
+ 0, 0, 0, 0x6758, 0, 0x4249, 0x4775, 0x383F,
+ 0x6757, 0x4125, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E889[] = {
+ 0x6759, 0, 0, 0, 0, 0, 0, 0x447A,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x675B, 0x675A, 0x675D, 0, 0, 0x675C, 0, 0x675E,
+ 0, 0, 0x6760, 0, 0x675F, 0, 0x344F, 0,
+ 0x6761, 0, 0x6762, 0x6763, 0, 0, 0x3A31, 0x4E49,
+ 0, 0x6765, 0x3F27, 0, 0, 0, 0x3170, 0x6766,
+ 0x6767, 0, 0, 0, 0, 0, 0x6768, 0,
+};
+unsigned short utf8_to_euc_E88A[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3072, 0, 0x6769, 0, 0,
+ 0, 0, 0x676A, 0, 0, 0, 0, 0,
+ 0, 0x4967, 0, 0, 0, 0x3C47, 0, 0x676C,
+ 0, 0, 0, 0, 0, 0x3329, 0x3032, 0,
+ 0, 0, 0, 0x676B, 0x676E, 0x474E, 0, 0x3F44,
+ 0, 0x3256, 0, 0x4B27, 0, 0, 0, 0,
+ 0x375D, 0x365C, 0, 0x676D, 0, 0x326A, 0, 0,
+};
+unsigned short utf8_to_euc_E88B[] = {
+ 0, 0, 0, 0, 0, 0x3423, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3171, 0x6772, 0x4E6A, 0x425D, 0, 0, 0x4944,
+ 0, 0x677E, 0, 0x3257, 0x677C, 0, 0x677A, 0x6771,
+ 0, 0x676F, 0, 0x6770, 0, 0x3C63, 0x366C, 0x4377,
+ 0, 0, 0, 0x4651, 0, 0, 0, 0,
+ 0, 0x3151, 0, 0x6774, 0x6773, 0, 0, 0,
+ 0, 0x6779, 0x6775, 0x6778, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E88C[] = {
+ 0, 0x7B57, 0x4C50, 0x6777, 0x3258, 0x337D, 0x677B, 0,
+ 0, 0x677D, 0, 0, 0, 0, 0x3754, 0,
+ 0, 0, 0, 0, 0, 0, 0x6823, 0x682C,
+ 0x682D, 0, 0, 0, 0x302B, 0, 0, 0,
+ 0, 0, 0, 0x6834, 0, 0, 0, 0,
+ 0x3071, 0, 0, 0x682B, 0, 0, 0, 0x682A,
+ 0, 0x6825, 0x6824, 0, 0x6822, 0x6821, 0x4363, 0,
+ 0x427B, 0x6827, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E88D[] = {
+ 0x6826, 0, 0, 0, 0, 0x6829, 0, 0,
+ 0, 0x4170, 0x3755, 0, 0, 0, 0, 0x3141,
+ 0x6828, 0, 0x3953, 0, 0, 0, 0, 0,
+ 0x4171, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x7B58, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x683A, 0, 0x683B, 0, 0x3259,
+ 0, 0, 0, 0x322E, 0x6838, 0, 0, 0x7B59,
+};
+unsigned short utf8_to_euc_E88E[] = {
+ 0, 0, 0, 0, 0, 0x682E, 0, 0x6836,
+ 0, 0x683D, 0x6837, 0, 0, 0, 0x6835, 0,
+ 0, 0, 0, 0x6776, 0, 0, 0x6833, 0,
+ 0, 0, 0x682F, 0, 0, 0, 0x3450, 0x6831,
+ 0x683C, 0, 0x6832, 0, 0, 0, 0, 0,
+ 0x683E, 0, 0x6830, 0x477C, 0, 0, 0, 0,
+ 0, 0x4D69, 0, 0, 0, 0x6839, 0, 0,
+ 0, 0, 0, 0, 0, 0x684F, 0, 0,
+};
+unsigned short utf8_to_euc_E88F[] = {
+ 0, 0x6847, 0, 0, 0, 0x3F7B, 0, 0x7B5A,
+ 0, 0, 0x3546, 0, 0x365D, 0, 0x6842, 0,
+ 0, 0, 0, 0x325B, 0, 0, 0x3E54, 0,
+ 0x6845, 0, 0, 0, 0x3A5A, 0, 0, 0x4551,
+ 0x684A, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x4A6E, 0, 0x6841, 0, 0, 0, 0x325A,
+ 0x3856, 0x4929, 0x684B, 0, 0x683F, 0, 0x7B5B, 0x6848,
+ 0, 0, 0, 0x6852, 0, 0x6843, 0, 0,
+};
+unsigned short utf8_to_euc_E890[] = {
+ 0, 0, 0, 0x6844, 0x463A, 0, 0, 0x6849,
+ 0, 0, 0, 0x6846, 0x4B28, 0x684C, 0x3060, 0,
+ 0, 0, 0, 0x6840, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x684E, 0, 0x684D, 0, 0, 0, 0, 0,
+ 0, 0x476B, 0x6854, 0, 0x685F, 0, 0, 0,
+ 0, 0x337E, 0, 0, 0, 0x6862, 0, 0,
+ 0x6850, 0, 0, 0, 0x6855, 0x4D6E, 0, 0,
+};
+unsigned short utf8_to_euc_E891[] = {
+ 0, 0, 0, 0, 0, 0, 0x685E, 0,
+ 0x7B5C, 0x4D55, 0, 0, 0, 0, 0x4E2A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4378,
+ 0, 0, 0, 0x336B, 0, 0, 0, 0,
+ 0, 0x4972, 0x6864, 0x4621, 0, 0, 0x3031, 0,
+ 0, 0x685D, 0, 0x6859, 0x4172, 0x6853, 0x685B, 0x6860,
+ 0, 0x472C, 0, 0, 0, 0x302A, 0, 0x6858,
+ 0, 0x6861, 0x4978, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E892[] = {
+ 0, 0, 0x685C, 0, 0x6857, 0, 0, 0,
+ 0, 0, 0, 0x3E55, 0, 0, 0, 0,
+ 0x3D2F, 0, 0, 0, 0x3C2C, 0, 0, 0,
+ 0, 0x4C58, 0, 0, 0x4947, 0, 0, 0x6867,
+ 0, 0x6870, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x685A, 0, 0,
+ 0, 0, 0x3377, 0, 0x7B5D, 0, 0, 0,
+ 0x3E78, 0x6865, 0, 0x686A, 0x4173, 0, 0, 0x6866,
+};
+unsigned short utf8_to_euc_E893[] = {
+ 0, 0x686D, 0, 0, 0x435F, 0, 0x686E, 0,
+ 0, 0x4D56, 0x6863, 0x3338, 0, 0x6869, 0, 0,
+ 0x686C, 0x4C2C, 0, 0, 0, 0, 0x686F, 0,
+ 0, 0x6868, 0x686B, 0, 0x7925, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x4B29, 0, 0x4F21, 0,
+ 0, 0, 0, 0, 0x6873, 0, 0, 0,
+ 0, 0, 0, 0, 0x687A, 0, 0, 0x6872,
+};
+unsigned short utf8_to_euc_E894[] = {
+ 0x3C43, 0, 0, 0, 0, 0, 0x6851, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x4A4E, 0, 0x4C22, 0x6879, 0x6878, 0, 0x6874,
+ 0x6875, 0, 0x3136, 0, 0, 0, 0, 0x6877,
+ 0, 0x6871, 0, 0, 0, 0, 0x4455, 0,
+ 0, 0, 0, 0, 0x6876, 0x307E, 0, 0,
+ 0, 0, 0, 0, 0, 0x4222, 0, 0,
+ 0, 0, 0, 0, 0, 0x4A43, 0, 0,
+};
+unsigned short utf8_to_euc_E895[] = {
+ 0x687B, 0x6921, 0, 0x4859, 0, 0, 0, 0,
+ 0x687E, 0x3E56, 0x3C49, 0x6923, 0, 0, 0x363E, 0,
+ 0, 0, 0, 0x7B5E, 0, 0x6924, 0, 0x4979,
+ 0x687D, 0x7B5F, 0x6856, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x687C, 0, 0, 0, 0,
+ 0x4F4F, 0x4622, 0x4973, 0x7B60, 0, 0x692B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6931,
+ 0, 0, 0, 0, 0, 0, 0x6932, 0,
+};
+unsigned short utf8_to_euc_E896[] = {
+ 0x6925, 0, 0, 0, 0x4776, 0, 0, 0x692F,
+ 0x6927, 0, 0x6929, 0, 0, 0, 0, 0,
+ 0x6933, 0x6928, 0, 0, 0x692C, 0, 0, 0x3172,
+ 0, 0x4665, 0, 0x692D, 0x6930, 0, 0, 0,
+ 0, 0, 0, 0, 0x6926, 0, 0x4126, 0,
+ 0x692A, 0x3B27, 0x3F45, 0x3730, 0x4C74, 0, 0x4C79, 0x3D72,
+ 0x7B62, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6937, 0x6935, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E897[] = {
+ 0, 0x4F4E, 0, 0, 0, 0, 0, 0,
+ 0, 0x6934, 0, 0, 0, 0x4D75, 0, 0x6936,
+ 0x6938, 0, 0, 0, 0, 0x6939, 0, 0,
+ 0, 0, 0, 0, 0x693C, 0x693A, 0, 0,
+ 0, 0, 0, 0, 0x4623, 0x693B, 0, 0,
+ 0, 0x484D, 0x692E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x3D73,
+ 0, 0x693D, 0x6942, 0x4174, 0, 0, 0x6941, 0,
+};
+unsigned short utf8_to_euc_E898[] = {
+ 0, 0, 0x6922, 0, 0, 0, 0x6943, 0x4149,
+ 0, 0, 0x693E, 0x6940, 0, 0, 0, 0,
+ 0, 0, 0, 0x693F, 0, 0, 0x5D31, 0x5D22,
+ 0, 0, 0x6945, 0, 0, 0, 0, 0,
+ 0, 0, 0x6944, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x4D76, 0, 0x623C,
+ 0x6946, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6947,
+};
+unsigned short utf8_to_euc_E899[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x6948, 0x3857, 0,
+ 0x3554, 0, 0, 0, 0x694A, 0x515D, 0, 0,
+ 0, 0, 0x3575, 0, 0x4E3A, 0, 0x3673, 0x694B,
+ 0, 0, 0, 0, 0, 0, 0, 0x694C,
+ 0, 0, 0, 0x436E, 0, 0, 0, 0,
+ 0, 0x694D, 0, 0, 0, 0, 0, 0,
+ 0, 0x467A, 0, 0x303A, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E89A[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3263, 0x6952, 0x6953, 0, 0, 0,
+ 0, 0, 0, 0x694E, 0, 0x3B3D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x694F, 0x4742, 0, 0, 0,
+ 0, 0x6950, 0x6951, 0x695B, 0, 0, 0, 0x6955,
+ 0x6958, 0, 0, 0, 0, 0, 0x6954, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E89B[] = {
+ 0, 0, 0, 0, 0x6956, 0, 0x6957, 0x3C58,
+ 0, 0x6959, 0, 0x4341, 0, 0x3756, 0x3342, 0,
+ 0, 0, 0, 0, 0x695C, 0, 0, 0,
+ 0, 0x333F, 0, 0x6961, 0, 0, 0x695D, 0x6960,
+ 0, 0, 0, 0, 0x483A, 0, 0, 0,
+ 0, 0x695E, 0, 0, 0x695F, 0x4948, 0x485A, 0x6962,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x427D, 0x696C, 0, 0x6968, 0, 0, 0x326B, 0,
+};
+unsigned short utf8_to_euc_E89C[] = {
+ 0x6966, 0, 0x4B2A, 0x6967, 0, 0, 0x6964, 0,
+ 0x6965, 0x696A, 0x696D, 0, 0, 0x696B, 0, 0,
+ 0, 0x6969, 0x6963, 0, 0, 0, 0, 0,
+ 0x4358, 0, 0x6974, 0, 0x4C2A, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x6972, 0, 0,
+ 0, 0x6973, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x696E, 0, 0, 0x6970,
+ 0, 0, 0, 0x6971, 0, 0, 0, 0x696F,
+};
+unsigned short utf8_to_euc_E89D[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x4066, 0, 0x4F39, 0x6978, 0, 0x6979, 0,
+ 0, 0, 0, 0x6A21, 0, 0x3F2A, 0, 0x697B,
+ 0, 0x697E, 0, 0, 0, 0, 0, 0x6976,
+ 0x6975, 0, 0, 0x6A22, 0, 0, 0x325C, 0,
+ 0x697C, 0, 0x6A23, 0, 0, 0, 0x697D, 0,
+ 0, 0, 0, 0, 0x697A, 0, 0x4433, 0,
+ 0x6977, 0, 0, 0, 0, 0, 0, 0x4768,
+};
+unsigned short utf8_to_euc_E89E[] = {
+ 0, 0, 0x6A27, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x4D3B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6A26,
+ 0, 0, 0x6A25, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6A2E, 0, 0, 0, 0x6A28,
+ 0, 0, 0, 0x6A30, 0, 0, 0, 0,
+ 0, 0, 0x4D66, 0x6A33, 0, 0x6A2A, 0, 0,
+};
+unsigned short utf8_to_euc_E89F[] = {
+ 0x6A2B, 0, 0, 0, 0x6A2F, 0, 0x6A32, 0x6A31,
+ 0, 0, 0, 0x6A29, 0, 0, 0, 0,
+ 0x6A2C, 0, 0x6A3D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x6A36, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6A34,
+ 0, 0, 0x6A35, 0, 0, 0, 0x6A3A, 0x6A3B,
+ 0, 0x332A, 0, 0x3542, 0, 0, 0x6A39, 0,
+};
+unsigned short utf8_to_euc_E8A0[] = {
+ 0, 0, 0, 0, 0, 0x6A24, 0, 0x7B65,
+ 0, 0, 0, 0, 0, 0x6A38, 0x6A3C, 0x6A37,
+ 0, 0x6A3E, 0, 0, 0, 0x6A40, 0x6A3F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6A42, 0x6A41, 0x695A, 0, 0, 0, 0x6A46,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6A43, 0, 0, 0, 0, 0x6A44, 0,
+ 0, 0x6A45, 0, 0x6A47, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8A1[] = {
+ 0x376C, 0, 0x6A49, 0, 0x6A48, 0, 0x3D30, 0,
+ 0, 0, 0, 0, 0x3954, 0x5E27, 0, 0,
+ 0, 0, 0x6A4A, 0x3D51, 0, 0, 0, 0x3339,
+ 0, 0x6A4B, 0, 0x3152, 0, 0x3E57, 0x6A4C, 0,
+ 0, 0x3955, 0x6A4D, 0x3061, 0, 0, 0, 0,
+ 0x493D, 0, 0, 0x6A4E, 0, 0, 0, 0,
+ 0x3F6A, 0, 0x6A55, 0, 0, 0x6A52, 0, 0x436F,
+ 0, 0, 0, 0, 0, 0x6A53, 0x6A50, 0x365E,
+};
+unsigned short utf8_to_euc_E8A2[] = {
+ 0, 0x6A4F, 0x6A56, 0, 0, 0, 0, 0,
+ 0x3736, 0, 0, 0x425E, 0, 0x6A5C, 0, 0,
+ 0, 0, 0x6A58, 0, 0, 0, 0x4235, 0x6A57,
+ 0, 0x6A5A, 0, 0, 0, 0, 0x6A51, 0,
+ 0, 0, 0x6A5B, 0, 0x6A5D, 0, 0, 0,
+ 0, 0, 0, 0x486F, 0, 0, 0x6A59, 0,
+ 0x6A5E, 0x6A60, 0, 0, 0x3853, 0x6A54, 0, 0x3041,
+ 0, 0, 0, 0, 0, 0, 0, 0x6A5F,
+};
+unsigned short utf8_to_euc_E8A3[] = {
+ 0, 0x3A5B, 0x4E76, 0x6A61, 0x6A62, 0x4175, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4E22,
+ 0, 0, 0, 0, 0x6A63, 0x4D35, 0, 0,
+ 0x6A64, 0x6A65, 0, 0, 0x4A64, 0x6A66, 0, 0x3A40,
+ 0, 0x4E23, 0, 0, 0, 0, 0, 0,
+ 0x6A6B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x6A6C, 0x3E58, 0x6A6A, 0x7B66, 0, 0,
+ 0x4D67, 0x6A67, 0, 0, 0x6A69, 0x403D, 0x3F7E, 0,
+};
+unsigned short utf8_to_euc_E8A4[] = {
+ 0, 0, 0x6A68, 0, 0x6A6D, 0, 0, 0x4A23,
+ 0, 0, 0x6A6F, 0, 0x6A6E, 0, 0, 0,
+ 0x336C, 0, 0x4B2B, 0x6A70, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7922, 0x6A7C, 0x6A72, 0,
+ 0, 0, 0, 0, 0, 0x6A73, 0, 0,
+ 0, 0, 0x6A74, 0x6A75, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x6A79, 0,
+ 0x6A7A, 0, 0, 0x6A78, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8A5[] = {
+ 0, 0x6A76, 0, 0x6A71, 0x6A77, 0, 0, 0,
+ 0, 0, 0, 0, 0x6A7B, 0x7037, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3228, 0,
+ 0, 0, 0, 0, 0, 0, 0x6A7E, 0x365F,
+ 0x6A7D, 0, 0, 0, 0x6B22, 0, 0x6B21, 0,
+ 0, 0, 0x6B24, 0, 0, 0x6B23, 0, 0x6B25,
+ 0, 0, 0x3D31, 0, 0x6B26, 0, 0, 0x6B27,
+ 0, 0, 0, 0, 0, 0, 0x6B28, 0x403E,
+};
+unsigned short utf8_to_euc_E8A6[] = {
+ 0, 0x4D57, 0, 0x6B29, 0, 0, 0x4A24, 0x4746,
+ 0x6B2A, 0, 0x6B2B, 0x382B, 0, 0, 0, 0x352C,
+ 0, 0, 0, 0x6B2C, 0, 0, 0x3B6B, 0x4741,
+ 0x6B2D, 0, 0x3350, 0, 0, 0, 0, 0,
+ 0, 0x6B2E, 0, 0, 0, 0, 0x6B30, 0x4D77,
+ 0, 0x6B2F, 0x3F46, 0, 0x6B31, 0, 0, 0x6B32,
+ 0, 0, 0x6B33, 0x3451, 0, 0, 0, 0,
+ 0, 0, 0x6B34, 0, 0, 0x6B35, 0, 0x6B36,
+};
+unsigned short utf8_to_euc_E8A7[] = {
+ 0x6B37, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3351, 0, 0, 0, 0, 0,
+ 0, 0, 0x6B38, 0, 0x6B39, 0x6B3A, 0, 0,
+ 0, 0, 0, 0x3272, 0, 0, 0x3F28, 0x6B3B,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x6B3C, 0, 0, 0,
+ 0x6B3D, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8A8[] = {
+ 0x3840, 0, 0x447B, 0x6B3E, 0, 0, 0, 0,
+ 0x3757, 0, 0x3F56, 0, 0x6B41, 0, 0x4624, 0,
+ 0x6B40, 0, 0x7B67, 0x3731, 0, 0, 0x6B3F, 0x4277,
+ 0x352D, 0, 0, 0x6B42, 0, 0x6B43, 0, 0x3E59,
+ 0, 0, 0, 0x376D, 0, 0x6B44, 0, 0,
+ 0, 0, 0x4B2C, 0, 0, 0x405F, 0, 0,
+ 0, 0x3576, 0, 0x4C75, 0x414A, 0, 0x6B45, 0x7B68,
+ 0, 0, 0x3F47, 0x4370, 0x3E5A, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8A9[] = {
+ 0, 0x6B46, 0, 0, 0, 0, 0x6B49, 0,
+ 0x6B4A, 0, 0, 0, 0, 0, 0, 0,
+ 0x3A3E, 0x4242, 0x6B48, 0, 0x3E5B, 0x493E, 0, 0,
+ 0, 0, 0, 0x6B47, 0, 0, 0x3B6C, 0,
+ 0x3153, 0, 0x6B4E, 0x3758, 0, 0, 0x3B6E, 0,
+ 0, 0x3B6D, 0, 0x4F4D, 0x6B4D, 0x6B4C, 0x4127, 0,
+ 0x354D, 0x4F43, 0x333A, 0x3E5C, 0, 0, 0, 0,
+ 0, 0x7B69, 0, 0, 0x6B4B, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8AA[] = {
+ 0, 0, 0x6B50, 0, 0x6B51, 0x6B4F, 0, 0x3858,
+ 0, 0x4D40, 0, 0, 0x3B6F, 0x4727, 0, 0,
+ 0, 0x6B54, 0, 0x4040, 0, 0x4342, 0, 0,
+ 0x4D36, 0, 0x6B57, 0, 0, 0, 0x386C, 0,
+ 0x403F, 0x6B53, 0, 0x6B58, 0x386D, 0x6B55, 0x6B56, 0x7B6A,
+ 0x6B52, 0, 0, 0, 0x4062, 0x4649, 0, 0,
+ 0x432F, 0, 0x325D, 0, 0, 0, 0, 0,
+ 0, 0x4870, 0, 0, 0x3543, 0, 0x7B6B, 0x4434,
+};
+unsigned short utf8_to_euc_E8AB[] = {
+ 0, 0, 0x6B5B, 0, 0x6B59, 0, 0, 0x434C,
+ 0, 0, 0, 0x4041, 0x3452, 0x6B5A, 0, 0x3F5B,
+ 0, 0, 0x4E4A, 0, 0, 0, 0x4F40, 0,
+ 0, 0, 0x6B5C, 0x6B67, 0x4435, 0, 0x6B66, 0x7B6C,
+ 0x6B63, 0x6B6B, 0x6B64, 0, 0x6B60, 0, 0x447C, 0x6B5F,
+ 0, 0, 0, 0x6B5D, 0, 0x4D21, 0x3B70, 0,
+ 0, 0x6B61, 0, 0x6B5E, 0, 0, 0x7B6E, 0x6B65,
+ 0x3D74, 0, 0x3841, 0, 0, 0, 0x427A, 0,
+};
+unsigned short utf8_to_euc_E8AC[] = {
+ 0x4B45, 0x315A, 0x3062, 0, 0x4625, 0, 0, 0x6B69,
+ 0, 0, 0, 0, 0x6B68, 0, 0x4666, 0,
+ 0x6B6D, 0, 0, 0, 0x6B62, 0, 0x6B6C, 0x6B6E,
+ 0, 0x382C, 0x6B6A, 0x3956, 0, 0x3C55, 0, 0,
+ 0x6B6F, 0x4D58, 0, 0, 0, 0, 0x6B72, 0,
+ 0x6B75, 0, 0, 0x6B73, 0x4935, 0, 0, 0,
+ 0, 0, 0, 0x6B70, 0, 0, 0, 0,
+ 0, 0x3660, 0, 0, 0, 0, 0x6B74, 0,
+};
+unsigned short utf8_to_euc_E8AD[] = {
+ 0, 0x6B76, 0, 0, 0, 0, 0, 0,
+ 0, 0x6B7A, 0, 0, 0x6B77, 0, 0x6B79, 0x6B78,
+ 0, 0, 0, 0x7B6F, 0, 0, 0x6B7B, 0,
+ 0x3C31, 0, 0x6B7D, 0x6B7C, 0x4968, 0, 0, 0x6C21,
+ 0, 0, 0, 0, 0, 0, 0x3759, 0,
+ 0, 0, 0, 0x6B7E, 0x6C22, 0, 0, 0x6C23,
+ 0x3544, 0x6641, 0x3E79, 0, 0x6C24, 0, 0, 0x386E,
+ 0, 0, 0, 0, 0, 0x6C25, 0, 0x7B70,
+};
+unsigned short utf8_to_euc_E8AE[] = {
+ 0x6C26, 0, 0, 0x3B3E, 0, 0, 0, 0,
+ 0, 0, 0x5A4E, 0, 0x6C27, 0, 0x6C28, 0,
+ 0x3D32, 0, 0x6C29, 0x6C2A, 0, 0, 0x6C2B, 0,
+ 0, 0x6C2C, 0x6C2D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8B0[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x432B,
+ 0, 0, 0x6C2E, 0, 0, 0, 0, 0x6C30,
+};
+unsigned short utf8_to_euc_E8B1[] = {
+ 0, 0x6C2F, 0, 0, 0, 0, 0x4626, 0,
+ 0x6C31, 0, 0x4B2D, 0, 0x6C32, 0, 0x6C33, 0,
+ 0x6C34, 0, 0, 0, 0, 0x6C35, 0, 0,
+ 0, 0, 0x465A, 0, 0, 0, 0, 0,
+ 0, 0x3E5D, 0x6C36, 0, 0, 0, 0, 0,
+ 0, 0, 0x396B, 0x502E, 0x6C37, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x6C38, 0x493F, 0x6C39, 0, 0x6C41, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8B2[] = {
+ 0, 0, 0x6C3A, 0, 0, 0x6C3C, 0, 0,
+ 0, 0x6C3B, 0x6C3D, 0, 0x4B46, 0x6C3E, 0x6C3F, 0,
+ 0, 0, 0, 0, 0x6C40, 0, 0, 0,
+ 0x6C42, 0, 0, 0, 0, 0x332D, 0x4467, 0,
+ 0x4969, 0x3A62, 0x3957, 0, 0, 0, 0, 0x494F,
+ 0x325F, 0x484E, 0x6C45, 0x3453, 0x4055, 0x6C44, 0x6C49, 0x4379,
+ 0x4C63, 0, 0x6C47, 0x6C48, 0x352E, 0, 0x6C4A, 0x4763,
+ 0x425F, 0, 0, 0x4871, 0x453D, 0x6C46, 0, 0x4B47,
+};
+unsigned short utf8_to_euc_E8B3[] = {
+ 0x326C, 0x6C4C, 0x4F28, 0x4442, 0x4F45, 0, 0, 0x3B71,
+ 0x6C4B, 0, 0x4231, 0, 0, 0x6C5C, 0x4128, 0,
+ 0, 0x4678, 0, 0x4950, 0, 0, 0, 0,
+ 0, 0, 0x6C4F, 0x3B3F, 0x3B72, 0, 0x3E5E, 0,
+ 0x4765, 0, 0x382D, 0x6C4E, 0x6C4D, 0, 0x496A, 0,
+ 0, 0, 0x3C41, 0, 0, 0x4552, 0, 0,
+ 0x7B71, 0, 0, 0, 0x7B72, 0, 0, 0,
+ 0, 0, 0x6C51, 0x6C52, 0x3958, 0x6C50, 0, 0,
+};
+unsigned short utf8_to_euc_E8B4[] = {
+ 0, 0, 0, 0, 0x6C53, 0x6C54, 0, 0x6C56,
+ 0x4223, 0, 0x6C55, 0x3466, 0, 0x6C58, 0, 0x6C57,
+ 0x6C59, 0, 0x7B73, 0x6C5B, 0x6C5D, 0, 0x6C5E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8B5[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x4056, 0, 0x3C4F, 0x6C5F,
+ 0, 0, 0, 0x3352, 0, 0x6C60, 0, 0,
+ 0x4176, 0x6C61, 0, 0x6C62, 0x496B, 0, 0x7B74, 0x352F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8B6[] = {
+ 0, 0x6C63, 0, 0, 0, 0x4436, 0, 0,
+ 0, 0, 0x315B, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6C64, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3C71, 0, 0, 0, 0,
+ 0x3F76, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x422D, 0, 0, 0, 0,
+ 0, 0, 0x6C67, 0, 0, 0, 0x6C66, 0,
+};
+unsigned short utf8_to_euc_E8B7[] = {
+ 0, 0, 0x6C65, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6C6D, 0x6C6B, 0, 0, 0x6C68,
+ 0, 0, 0, 0, 0, 0, 0x6C6A, 0,
+ 0, 0, 0x6C69, 0x6C6C, 0, 0x3577, 0, 0x6C70,
+ 0, 0x4057, 0, 0x6C71, 0, 0, 0, 0,
+ 0x3859, 0, 0x6C6E, 0x6C6F, 0, 0, 0, 0x4F29,
+ 0, 0, 0, 0x4437, 0, 0x4129, 0, 0,
+ 0, 0, 0, 0, 0x6C72, 0, 0, 0x6C75,
+};
+unsigned short utf8_to_euc_E8B8[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x6C73, 0x6C74, 0x4D59, 0, 0, 0, 0, 0x4627,
+ 0x6C78, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x6C76, 0x6C77, 0x6C79,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x6D29, 0, 0, 0, 0, 0,
+ 0x6C7C, 0, 0, 0, 0x6C7D, 0x6C7B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8B9[] = {
+ 0, 0, 0x6C7A, 0, 0x447D, 0, 0, 0x6D21,
+ 0x6D25, 0x6D22, 0x6C7E, 0, 0x6D23, 0, 0, 0,
+ 0x6D24, 0, 0, 0, 0, 0x6D2B, 0, 0,
+ 0, 0x6D26, 0, 0, 0, 0, 0, 0x4058,
+ 0x6D28, 0, 0, 0x6D2A, 0x6D27, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x6D2D, 0, 0x3D33, 0, 0x6D2C, 0,
+ 0, 0, 0, 0, 0x6D2E, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8BA[] = {
+ 0, 0x6D2F, 0, 0, 0x6D32, 0x6D31, 0, 0x6D30,
+ 0, 0, 0x6D34, 0x6D33, 0, 0x4C76, 0, 0,
+ 0, 0x6D36, 0, 0x6D35, 0x6D37, 0, 0, 0,
+ 0, 0x6D38, 0, 0, 0, 0, 0, 0,
+ 0, 0x6D3A, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x6D39, 0x3F48, 0x6D3B, 0, 0, 0x366D,
+ 0x6D3C, 0x6D3E, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x6D3F, 0,
+};
+unsigned short utf8_to_euc_E8BB[] = {
+ 0, 0, 0, 0, 0, 0x6D40, 0x6D3D, 0,
+ 0x6D41, 0, 0x3C56, 0x6D42, 0x3530, 0x3733, 0, 0x7B76,
+ 0, 0, 0x382E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6D43, 0, 0, 0, 0x4670,
+ 0, 0, 0x453E, 0x6D44, 0, 0, 0, 0,
+ 0, 0, 0, 0x6D47, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x3C34, 0, 0, 0x6D46, 0x6D45, 0x375A, 0x6D48, 0,
+};
+unsigned short utf8_to_euc_E8BC[] = {
+ 0, 0, 0, 0x3353, 0, 0x6D4A, 0, 0,
+ 0, 0x3A5C, 0x6D49, 0, 0x6D52, 0, 0, 0,
+ 0, 0, 0x6D4C, 0x6D4E, 0x4A65, 0x6D4B, 0, 0,
+ 0, 0x6D4D, 0, 0x6D51, 0x6D4F, 0x3531, 0, 0x6D50,
+ 0, 0, 0, 0, 0, 0, 0x6D53, 0,
+ 0, 0x475A, 0x4E58, 0, 0, 0, 0, 0x3D34,
+ 0, 0, 0, 0x6D54, 0, 0, 0, 0,
+ 0x4D22, 0x6D56, 0, 0x6D55, 0, 0, 0x6D59, 0x4D41,
+};
+unsigned short utf8_to_euc_E8BD[] = {
+ 0, 0, 0x6D58, 0, 0x336D, 0x6D57, 0x6D5C, 0,
+ 0, 0x6D5B, 0, 0, 0x6D5A, 0x4532, 0x6D5D, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6D5E,
+ 0, 0, 0, 0, 0x6D5F, 0, 0, 0x396C,
+ 0, 0x3725, 0x6D60, 0x6D61, 0x6D62, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E8BE[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3F49, 0x6D63, 0, 0x3C2D, 0x6D64,
+ 0, 0, 0, 0x6D65, 0, 0, 0, 0x5221,
+ 0x517E, 0, 0, 0, 0, 0x6D66, 0x6570, 0x6D67,
+ 0x4324, 0x3F2B, 0x4740, 0, 0, 0, 0, 0x6D68,
+ 0, 0, 0x4A55, 0x4454, 0x397E, 0, 0, 0x4329,
+};
+unsigned short utf8_to_euc_E8BF[] = {
+ 0, 0, 0x312A, 0, 0x4B78, 0x3F57, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x375E, 0,
+ 0, 0x3661, 0, 0, 0x4A56, 0, 0, 0,
+ 0, 0, 0x6D69, 0, 0, 0, 0, 0,
+ 0, 0, 0x6D6B, 0, 0, 0x6D6A, 0x3260, 0,
+ 0, 0x4676, 0x6D6C, 0x4777, 0, 0x4533, 0, 0x6D6D,
+ 0x3D52, 0, 0, 0, 0x6D6F, 0, 0, 0x4C42,
+ 0x6D7E, 0x6D71, 0x6D72, 0, 0, 0x4449, 0, 0,
+};
+unsigned short utf8_to_euc_E980[] = {
+ 0x4260, 0x4177, 0, 0x4628, 0, 0x6D70, 0x3555, 0,
+ 0, 0, 0, 0x6D79, 0, 0x6D76, 0x6E25, 0x4629,
+ 0x4360, 0x6D73, 0, 0x447E, 0x4553, 0x6D74, 0x6D78, 0x3F60,
+ 0, 0x4767, 0x444C, 0, 0, 0x4042, 0x6D77, 0x422E,
+ 0x4224, 0x6D75, 0x3029, 0x4F22, 0, 0, 0, 0x6D7A,
+ 0, 0, 0, 0, 0, 0, 0x4261, 0,
+ 0, 0x3D35, 0x3F4A, 0, 0, 0x6D7C, 0x6D7B, 0,
+ 0x306F, 0x6D7D, 0, 0, 0x492F, 0, 0x6E27, 0,
+};
+unsigned short utf8_to_euc_E981[] = {
+ 0, 0x465B, 0x3F6B, 0, 0, 0x4359, 0, 0x3678,
+ 0, 0x6E26, 0x4D37, 0x313F, 0, 0x4A57, 0x3261, 0x6E21,
+ 0x6E22, 0x6E23, 0x6E24, 0x463B, 0x4323, 0x3063, 0x6E28, 0,
+ 0x6E29, 0x7423, 0, 0, 0x423D, 0, 0x6E2A, 0,
+ 0x3173, 0x414C, 0, 0x382F, 0, 0x4D5A, 0, 0x7B79,
+ 0x6E2B, 0x452C, 0, 0, 0, 0x4178, 0x3C57, 0x6E2C,
+ 0, 0, 0x6E2F, 0, 0, 0x3D65, 0x6E2D, 0x412B,
+ 0x412A, 0, 0x3064, 0, 0x4E4B, 0x6E31, 0, 0x4872,
+};
+unsigned short utf8_to_euc_E982[] = {
+ 0x6E33, 0x6E32, 0x6E30, 0x6364, 0x3454, 0, 0, 0x6D6E,
+ 0, 0x6E35, 0x6E34, 0, 0, 0, 0, 0x6E36,
+ 0, 0x4D38, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4661, 0, 0, 0x4B2E, 0,
+ 0x6E37, 0, 0x3C59, 0, 0, 0, 0, 0x6E38,
+ 0, 0x6E39, 0, 0, 0, 0x6E3A, 0, 0,
+ 0x4521, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E983[] = {
+ 0, 0x306A, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3959, 0, 0, 0, 0x4F3A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6E3E, 0, 0, 0x7B7A, 0,
+ 0, 0x3734, 0x6E3B, 0, 0x6E3C, 0, 0, 0,
+ 0x4974, 0, 0, 0, 0, 0x3354, 0, 0,
+ 0, 0, 0, 0, 0, 0x4D39, 0, 0x363F,
+ 0, 0, 0, 0, 0, 0x4554, 0, 0,
+};
+unsigned short utf8_to_euc_E984[] = {
+ 0, 0, 0x6E3F, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x6E40, 0, 0, 0x7B7C, 0, 0,
+ 0, 0x6E41, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x7B7D,
+ 0, 0, 0, 0, 0, 0x4522, 0, 0,
+ 0x6E43, 0, 0x6E42, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E985[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x4653, 0x6E44, 0x3D36, 0x3C60, 0x475B, 0x4371, 0,
+ 0, 0, 0x3C72, 0, 0x3F6C, 0, 0x6E45, 0,
+ 0x6E46, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3F5D, 0x6E47, 0, 0x6E48, 0, 0,
+ 0, 0x6E49, 0x4D6F, 0, 0x3D37, 0, 0, 0,
+ 0, 0, 0x6E4B, 0x6E4A, 0, 0x395A, 0, 0x3973,
+ 0x3B40, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E986[] = {
+ 0, 0, 0x6E4E, 0, 0, 0, 0, 0x3D66,
+ 0, 0x6E4D, 0, 0x6E4C, 0, 0x4269, 0, 0,
+ 0x386F, 0, 0x4043, 0, 0, 0, 0, 0x4830,
+ 0, 0, 0, 0, 0x3D39, 0, 0, 0,
+ 0, 0, 0x6E4F, 0, 0x3E5F, 0, 0, 0,
+ 0, 0, 0x6E52, 0x6E50, 0, 0, 0, 0x6E51,
+ 0, 0, 0, 0, 0x6E54, 0x6E53, 0, 0,
+ 0x3E7A, 0, 0x6E55, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E987[] = {
+ 0x6E56, 0x6E57, 0, 0, 0, 0, 0x4850, 0x3A53,
+ 0x3C61, 0x6E58, 0, 0x6E59, 0x4E24, 0x3D45, 0x4C6E, 0x4E4C,
+ 0x6E5A, 0x3662, 0, 0, 0, 0, 0x6E5B, 0x7C21,
+ 0x4523, 0, 0x7B7E, 0x6E5E, 0x3378, 0x3F4B, 0x7C22, 0x6E5C,
+ 0, 0x6E5D, 0, 0x4460, 0x7C25, 0x7C26, 0x4B55, 0x367C,
+ 0, 0, 0, 0, 0, 0x7C23, 0x7C24, 0,
+ 0, 0, 0, 0, 0, 0x6E60, 0x6E61, 0,
+ 0, 0, 0, 0, 0x6E5F, 0, 0, 0x6E63,
+};
+unsigned short utf8_to_euc_E988[] = {
+ 0, 0, 0, 0, 0, 0, 0x7C27, 0,
+ 0, 0, 0x7C29, 0, 0, 0x465F, 0x3343, 0,
+ 0x7C28, 0x6E67, 0, 0, 0x6E64, 0x6E66, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x6E62, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6F4F, 0, 0, 0x6E65, 0, 0, 0,
+ 0, 0, 0, 0, 0x4E6B, 0, 0, 0x385A,
+ 0, 0x7C30, 0x7C2A, 0, 0x7C2C, 0, 0, 0x6E6F,
+};
+unsigned short utf8_to_euc_E989[] = {
+ 0x7C2B, 0, 0, 0, 0x4534, 0x6E6A, 0, 0,
+ 0x6E6D, 0x6E6B, 0, 0x6E70, 0, 0, 0x7C2D, 0,
+ 0x6E71, 0x7C2F, 0, 0, 0, 0, 0, 0x6E69,
+ 0, 0x7C2E, 0x6E76, 0x3174, 0, 0, 0x6E68, 0,
+ 0, 0, 0x482D, 0, 0x6E6C, 0, 0x3E60, 0x7C31,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x395B, 0, 0, 0, 0, 0, 0x7C33,
+ 0x7C34, 0, 0, 0, 0, 0, 0x4B48, 0,
+};
+unsigned short utf8_to_euc_E98A[] = {
+ 0x3664, 0, 0, 0x3D46, 0, 0x463C, 0, 0,
+ 0x7924, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x412D, 0, 0x6E74, 0, 0x6E6E, 0x6E73, 0,
+ 0x4C43, 0, 0x4438, 0x6E75, 0x6E72, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x7C32,
+ 0, 0, 0, 0, 0, 0x412C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6E79,
+ 0, 0x6E78, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E98B[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6E77,
+ 0x7C38, 0, 0x4B2F, 0x7C3C, 0, 0x7C3A, 0, 0x7C36,
+ 0, 0x7C37, 0, 0, 0, 0, 0, 0,
+ 0x7C3B, 0, 0, 0, 0x3D7B, 0, 0, 0x7C35,
+ 0, 0x6E7A, 0x4A5F, 0, 0, 0x3154, 0, 0,
+ 0, 0, 0x4946, 0x4372, 0, 0, 0, 0,
+ 0x3578, 0x792A, 0x6E7C, 0x7C3F, 0x395D, 0, 0, 0x7C42,
+};
+unsigned short utf8_to_euc_E98C[] = {
+ 0, 0, 0x7C44, 0, 0, 0, 0x3B2C, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x6E7B,
+ 0x3F6D, 0, 0, 0, 0, 0, 0, 0,
+ 0x3F6E, 0x6F21, 0x6F23, 0, 0, 0x7C43, 0x7C41, 0,
+ 0x3E7B, 0x7C3E, 0x6F22, 0x6F24, 0, 0x7C3D, 0x3653, 0,
+ 0x4945, 0, 0, 0x3C62, 0x4F23, 0, 0x6E7E, 0x3A78,
+ 0, 0, 0x4F3F, 0, 0, 0x6F26, 0, 0,
+ 0, 0, 0x6F25, 0x6F27, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E98D[] = {
+ 0, 0, 0, 0, 0x6E7D, 0, 0, 0,
+ 0x7923, 0, 0, 0x4669, 0, 0x4555, 0, 0,
+ 0, 0, 0, 0, 0x4457, 0, 0x6F2C, 0x7C46,
+ 0, 0, 0, 0x4343, 0x6F28, 0, 0, 0,
+ 0x6F29, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x372D, 0, 0x6F2B, 0,
+ 0x7C45, 0, 0, 0, 0, 0x3830, 0, 0,
+ 0, 0, 0, 0, 0x6F2A, 0, 0x3E61, 0,
+};
+unsigned short utf8_to_euc_E98E[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x3379, 0, 0, 0,
+ 0, 0, 0, 0, 0x6F30, 0, 0x3A3F, 0x4179,
+ 0, 0, 0x444A, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7C47, 0, 0, 0x333B,
+ 0, 0, 0, 0, 0x6F2E, 0x6F2F, 0x4443, 0,
+ 0x6F2D, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x6F31, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E98F[] = {
+ 0, 0, 0, 0x6F37, 0, 0, 0x7C48, 0,
+ 0x6F3A, 0, 0, 0, 0, 0, 0, 0,
+ 0x6F39, 0x452D, 0, 0, 0, 0, 0x6F32, 0x6F33,
+ 0x6F36, 0, 0, 0, 0, 0x6F38, 0x7C49, 0,
+ 0, 0x3640, 0, 0, 0x6F3B, 0x6F35, 0, 0,
+ 0x6F34, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7C4A, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E990[] = {
+ 0, 0, 0, 0x6F3F, 0, 0, 0, 0x6F40,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x6F41, 0, 0, 0x6F3E, 0x6F3D, 0, 0, 0,
+ 0x3E62, 0x462A, 0x6F3C, 0, 0, 0, 0, 0,
+ 0, 0x6F45, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6F43, 0, 0, 0, 0,
+ 0, 0x7C4B, 0, 0, 0, 0x6F44, 0x6F42, 0,
+ 0x4278, 0, 0x6F46, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E991[] = {
+ 0, 0x6F47, 0, 0, 0x6F49, 0x7C4C, 0, 0,
+ 0x7C4D, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3455, 0x6F48, 0x4C7A, 0, 0, 0, 0,
+ 0, 0, 0x6F54, 0x6F4A, 0, 0, 0x6F4D, 0,
+ 0x6F4B, 0, 0x6F4C, 0, 0, 0, 0, 0,
+ 0, 0, 0x6F4E, 0, 0, 0, 0, 0,
+ 0x6F50, 0, 0, 0, 0, 0x6F51, 0, 0x6F52,
+ 0, 0, 0, 0, 0x6F55, 0x6F53, 0x6F56, 0x6F58,
+};
+unsigned short utf8_to_euc_E992[] = {
+ 0, 0x6F57, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E995[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4439,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E996[] = {
+ 0x4C67, 0, 0x6F59, 0x412E, 0, 0, 0, 0x6F5A,
+ 0, 0x4A44, 0x6F5B, 0x332B, 0, 0, 0, 0x313C,
+ 0, 0x3457, 0x7C4E, 0x3456, 0x6F5C, 0, 0x6F5D, 0,
+ 0x6F5E, 0x6F5F, 0, 0, 0, 0, 0, 0,
+ 0x6F60, 0, 0x3458, 0x3355, 0x395E, 0x4836, 0, 0x6F62,
+ 0x6F61, 0, 0, 0, 0, 0x6F63, 0, 0,
+ 0, 0, 0x315C, 0, 0, 0, 0, 0,
+ 0, 0x6F66, 0, 0x6F65, 0x6F64, 0, 0x6F67, 0,
+};
+unsigned short utf8_to_euc_E997[] = {
+ 0, 0, 0, 0x6F6A, 0, 0, 0, 0x3047,
+ 0, 0, 0x6F68, 0, 0x6F6C, 0x6F6B, 0, 0,
+ 0, 0, 0, 0, 0x6F6E, 0x6F6D, 0x6F6F, 0,
+ 0x462E, 0, 0, 0, 0x6F70, 0, 0, 0,
+ 0, 0x6F71, 0x6F73, 0, 0, 0x6F72, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E998[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x496C, 0, 0, 0,
+ 0, 0x6F74, 0, 0, 0, 0, 0, 0,
+ 0x6F75, 0, 0x3A65, 0, 0, 0, 0x6F76, 0x6F77,
+ 0, 0, 0x4B49, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x414B, 0, 0, 0, 0x3024,
+};
+unsigned short utf8_to_euc_E999[] = {
+ 0x424B, 0, 0x6F78, 0, 0x496D, 0, 0, 0,
+ 0, 0, 0, 0x6F7B, 0x6F79, 0x395F, 0, 0x6F7A,
+ 0x3842, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4A45, 0x6F7D, 0x7021, 0x6F7E, 0x7022,
+ 0, 0, 0x3121, 0x3F58, 0x3D7C, 0x3459, 0x7023, 0,
+ 0, 0, 0x4766, 0, 0x7025, 0, 0, 0,
+ 0x3122, 0, 0x7024, 0x4444, 0, 0x4E4D, 0x462B, 0x6F7C,
+ 0x4E26, 0, 0x3831, 0, 0, 0x4D5B, 0, 0,
+};
+unsigned short utf8_to_euc_E99A[] = {
+ 0, 0, 0, 0, 0, 0x3679, 0x4E34, 0,
+ 0x3728, 0, 0x4262, 0x6721, 0, 0x7026, 0x332C, 0x3F6F,
+ 0, 0, 0, 0, 0x3356, 0x7028, 0, 0x7029,
+ 0x7027, 0x3764, 0, 0x3A5D, 0x3E63, 0x7C51, 0, 0,
+ 0x3123, 0, 0, 0x4E59, 0, 0, 0, 0x702B,
+ 0x6E2E, 0, 0x702A, 0, 0, 0, 0, 0x7C52,
+ 0x702E, 0x702C, 0x702D, 0, 0x702F, 0, 0x7030, 0x4E6C,
+ 0x7031, 0x7032, 0, 0x4049, 0x483B, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E99B[] = {
+ 0x3F7D, 0x3467, 0, 0, 0x4D3A, 0x326D, 0x3D38, 0x385B,
+ 0, 0x7035, 0, 0x7034, 0x3B73, 0x7036, 0x7033, 0,
+ 0, 0x3B28, 0, 0, 0, 0x703A, 0x6A2D, 0,
+ 0, 0x5256, 0, 0x3F77, 0x7038, 0, 0, 0,
+ 0, 0, 0x4E25, 0x4671, 0, 0, 0, 0,
+ 0x312B, 0, 0x4063, 0x3C36, 0, 0, 0, 0,
+ 0x4A37, 0, 0x3140, 0, 0, 0, 0x4E6D, 0x4D6B,
+ 0, 0x703B, 0, 0x4545, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E99C[] = {
+ 0x3C7B, 0, 0, 0, 0x703C, 0, 0x703D, 0x3F4C,
+ 0x703E, 0, 0x4E6E, 0, 0, 0x7039, 0x7040, 0x7042,
+ 0, 0x7041, 0, 0x703F, 0, 0, 0x7043, 0,
+ 0, 0x7044, 0, 0, 0x417A, 0, 0x3262, 0,
+ 0, 0, 0, 0, 0x7045, 0, 0, 0x4C38,
+ 0, 0, 0x7046, 0, 0, 0, 0, 0,
+ 0x7047, 0, 0x4F2A, 0x7C53, 0, 0, 0, 0,
+ 0x5B31, 0x7048, 0, 0x7C54, 0, 0x7049, 0x704A, 0,
+};
+unsigned short utf8_to_euc_E99D[] = {
+ 0, 0, 0x704E, 0x7C55, 0x704B, 0, 0x704C, 0,
+ 0x704D, 0x704F, 0, 0, 0, 0x7C56, 0, 0x7C57,
+ 0, 0x7C58, 0x4044, 0, 0, 0x7C59, 0x4C77, 0,
+ 0, 0x4045, 0, 0, 0x7050, 0, 0x4873, 0,
+ 0x7051, 0x7353, 0x4C4C, 0, 0x7052, 0, 0x7053, 0,
+ 0x7054, 0x3357, 0, 0x7056, 0, 0x3F59, 0, 0,
+ 0, 0x7057, 0, 0, 0x3724, 0, 0, 0,
+ 0, 0x7058, 0x705C, 0, 0x705A, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E99E[] = {
+ 0, 0x705B, 0, 0, 0x3373, 0x7059, 0x705D, 0,
+ 0, 0, 0, 0x705E, 0, 0x3048, 0, 0x705F,
+ 0x7060, 0, 0, 0, 0, 0, 0, 0,
+ 0x3E64, 0, 0, 0, 0x7061, 0, 0, 0,
+ 0x3547, 0, 0, 0x7064, 0, 0, 0x7063, 0,
+ 0x7062, 0, 0, 0x6B71, 0, 0x4A5C, 0, 0,
+ 0, 0, 0, 0x7065, 0x7066, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E99F[] = {
+ 0, 0, 0, 0x7067, 0, 0, 0x7068, 0,
+ 0x7069, 0, 0, 0x706A, 0, 0, 0, 0,
+ 0, 0, 0, 0x345A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x706B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x706C, 0x4723, 0,
+ 0, 0, 0x706E, 0x323B, 0, 0x7071, 0x7070, 0,
+ 0, 0, 0, 0x3124, 0, 0, 0, 0x3641,
+};
+unsigned short utf8_to_euc_E9A0[] = {
+ 0, 0x4A47, 0x443A, 0x3A22, 0, 0x3960, 0x3D67, 0,
+ 0x3F5C, 0, 0, 0, 0x7073, 0, 0, 0x7072,
+ 0x4D42, 0x3468, 0x4852, 0x465C, 0, 0, 0, 0x3F7C,
+ 0x4E4E, 0, 0x375B, 0, 0, 0, 0, 0,
+ 0, 0x7076, 0, 0, 0x7075, 0, 0, 0,
+ 0, 0, 0, 0, 0x4B4B, 0x462C, 0, 0,
+ 0, 0, 0, 0, 0x3150, 0, 0, 0x7077,
+ 0x7074, 0, 0, 0x4951, 0x4D6A, 0x7078, 0, 0,
+};
+unsigned short utf8_to_euc_E9A1[] = {
+ 0, 0, 0, 0, 0, 0, 0x7079, 0,
+ 0, 0, 0, 0x707B, 0x426A, 0x335B, 0x335C, 0x707A,
+ 0, 0, 0, 0, 0x3469, 0x3832, 0, 0x7C5A,
+ 0x346A, 0, 0, 0x453F, 0, 0, 0x4E60, 0,
+ 0, 0, 0, 0, 0, 0x7C5B, 0, 0x385C,
+ 0, 0, 0, 0x707C, 0, 0, 0, 0x707D,
+ 0x707E, 0x7121, 0, 0x7123, 0x7122, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9A2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4977, 0, 0x7124, 0, 0, 0, 0, 0x7125,
+ 0, 0x7126, 0, 0, 0, 0, 0x7127, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9A3[] = {
+ 0, 0, 0, 0x7129, 0x7128, 0, 0x712A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4874, 0x664C, 0, 0, 0x3F29,
+ 0, 0, 0x3532, 0, 0, 0, 0, 0,
+ 0, 0x712B, 0, 0x712C, 0, 0x522C, 0x5D3B, 0x4853,
+ 0, 0, 0x307B, 0, 0x303B, 0, 0, 0,
+ 0, 0, 0, 0, 0x3B74, 0x4B30, 0x3E7E, 0,
+};
+unsigned short utf8_to_euc_E9A4[] = {
+ 0, 0, 0, 0x712D, 0, 0x4C5F, 0, 0,
+ 0, 0x712E, 0x4D5C, 0, 0x3142, 0, 0, 0,
+ 0x3B41, 0, 0x712F, 0x326E, 0x7130, 0, 0, 0,
+ 0x7131, 0, 0, 0, 0, 0x7133, 0x7134, 0,
+ 0x7136, 0x7132, 0, 0, 0x7135, 0, 0, 0x7C5E,
+ 0x345B, 0, 0, 0, 0x7137, 0, 0x7138, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x7139, 0x713A, 0,
+};
+unsigned short utf8_to_euc_E9A5[] = {
+ 0, 0, 0x713B, 0, 0, 0x713D, 0, 0,
+ 0, 0x713C, 0, 0x713F, 0x7142, 0, 0, 0,
+ 0x713E, 0x7140, 0x7141, 0, 0, 0x7143, 0, 0x3642,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9A6[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3C73, 0x7144,
+ 0x7145, 0x3961, 0, 0, 0, 0, 0x7C60, 0,
+ 0, 0, 0, 0, 0, 0x7146, 0, 0,
+ 0x333E, 0, 0, 0, 0x474F, 0x7147, 0x7148, 0,
+ 0, 0, 0, 0x435A, 0x466B, 0, 0, 0,
+ 0, 0, 0, 0, 0x7149, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9A7[] = {
+ 0, 0x477D, 0, 0, 0x424C, 0x3158, 0x366E, 0,
+ 0x366F, 0, 0, 0, 0, 0, 0, 0,
+ 0x4373, 0x714E, 0x3670, 0, 0, 0x326F, 0, 0,
+ 0x714D, 0, 0, 0x714B, 0, 0x714C, 0, 0x714A,
+ 0, 0, 0x7158, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x714F, 0x7150, 0,
+ 0, 0x7151, 0x7152, 0, 0, 0, 0, 0,
+ 0x7154, 0, 0, 0x7153, 0, 0, 0, 0x3D59,
+};
+unsigned short utf8_to_euc_E9A8[] = {
+ 0, 0x7155, 0, 0, 0, 0x7157, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3533, 0x7156,
+ 0, 0, 0x417B, 0x3833, 0, 0, 0, 0,
+ 0, 0x7159, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x424D, 0, 0, 0x715A, 0, 0, 0, 0,
+ 0x462D, 0, 0, 0, 0, 0, 0, 0x715B,
+ 0, 0, 0, 0, 0, 0, 0x7160, 0,
+};
+unsigned short utf8_to_euc_E9A9[] = {
+ 0x715E, 0, 0x715D, 0x715F, 0, 0x715C, 0, 0,
+ 0, 0, 0, 0, 0, 0x7162, 0x7C61, 0,
+ 0, 0, 0, 0, 0, 0x7161, 0, 0x7164,
+ 0, 0, 0x3643, 0x7163, 0, 0, 0, 0x7165,
+ 0, 0, 0x7166, 0, 0x7168, 0x7167, 0, 0,
+ 0, 0x7169, 0x716B, 0x716A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9AA[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x397C, 0, 0, 0, 0, 0x716C, 0, 0,
+ 0x716D, 0, 0, 0, 0, 0, 0, 0,
+ 0x333C, 0, 0, 0, 0x716E, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9AB[] = {
+ 0x716F, 0, 0, 0, 0x3F71, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x7170,
+ 0, 0x7171, 0, 0x7172, 0x7173, 0, 0, 0,
+ 0x3962, 0x7C62, 0, 0, 0x7C63, 0, 0x7174, 0x7175,
+ 0, 0, 0x7176, 0x7177, 0, 0, 0x7178, 0,
+ 0, 0, 0x4831, 0x717A, 0, 0x4926, 0x717B, 0x7179,
+ 0, 0x717D, 0, 0, 0x717C, 0, 0, 0x717E,
+ 0, 0, 0, 0x7221, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9AC[] = {
+ 0, 0, 0, 0, 0, 0, 0x7222, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7223, 0, 0x7224, 0, 0, 0, 0, 0x7225,
+ 0, 0, 0x7226, 0x7227, 0, 0x7228, 0, 0x7229,
+ 0x722A, 0x722B, 0x722C, 0, 0, 0, 0x722D, 0x722E,
+ 0, 0x5D35, 0x722F, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6478, 0x3534, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9AD[] = {
+ 0, 0x3321, 0x3A32, 0x7231, 0x7230, 0x4C25, 0, 0,
+ 0, 0, 0, 0, 0, 0x7233, 0x7234, 0x7232,
+ 0, 0x7235, 0, 0, 0x4B62, 0, 0, 0,
+ 0x7236, 0, 0x357B, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4F25,
+ 0, 0, 0x7C65, 0, 0x7237, 0x7C64, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9AE[] = {
+ 0, 0, 0, 0x7239, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x303E, 0x7C66,
+ 0, 0x723A, 0x4A2B, 0x7238, 0, 0, 0x723B, 0x723C,
+ 0, 0, 0, 0, 0, 0, 0, 0x723D,
+ 0x723E, 0, 0, 0, 0, 0, 0, 0,
+ 0x723F, 0, 0x4B6E, 0x3B2D, 0, 0x3A7A, 0x412F, 0,
+ 0, 0x7C67, 0, 0, 0x7240, 0, 0, 0,
+ 0, 0x7243, 0, 0x7C68, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9AF[] = {
+ 0x7241, 0, 0, 0, 0, 0, 0x7244, 0,
+ 0, 0x3871, 0x7242, 0, 0, 0, 0, 0x7245,
+ 0, 0x7246, 0x7247, 0, 0x724B, 0, 0x3B2A, 0,
+ 0, 0, 0, 0x4264, 0, 0, 0, 0,
+ 0, 0x724C, 0x7249, 0x7248, 0x724A, 0, 0, 0,
+ 0x375F, 0, 0, 0, 0, 0, 0, 0,
+ 0x7250, 0x724F, 0x724E, 0, 0, 0x3033, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9B0[] = {
+ 0x7C69, 0, 0, 0, 0x725A, 0, 0x7256, 0,
+ 0x7257, 0x7253, 0x7259, 0, 0x7255, 0x3362, 0, 0,
+ 0x4F4C, 0, 0x7258, 0x7254, 0x7252, 0x7251, 0, 0,
+ 0, 0, 0, 0x725C, 0, 0, 0, 0,
+ 0, 0x725F, 0, 0, 0x725E, 0x725D, 0, 0,
+ 0, 0, 0, 0, 0, 0x4949, 0x725B, 0x3073,
+ 0x7260, 0, 0x7262, 0, 0, 0, 0, 0,
+ 0, 0x336F, 0x724D, 0x3137, 0, 0, 0x7264, 0,
+};
+unsigned short utf8_to_euc_E9B1[] = {
+ 0, 0, 0, 0, 0, 0, 0x7263, 0x7261,
+ 0x432D, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4B70, 0, 0, 0, 0, 0x4E5A,
+ 0, 0, 0x7265, 0, 0, 0, 0, 0,
+ 0x7266, 0, 0, 0, 0, 0, 0, 0x7267,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x7268, 0,
+ 0x7269, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9B3[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x443B, 0, 0x726A,
+ 0, 0x4837, 0, 0x726F, 0x726B, 0, 0, 0,
+ 0x726C, 0, 0, 0x4B31, 0x4C44, 0, 0x4650, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9B4[] = {
+ 0, 0, 0, 0x7270, 0, 0, 0x7271, 0x463E,
+ 0x726E, 0x726D, 0, 0, 0, 0, 0x322A, 0,
+ 0, 0, 0x7279, 0, 0, 0x7278, 0, 0,
+ 0, 0, 0, 0x3175, 0, 0, 0, 0x7276,
+ 0, 0, 0, 0x7275, 0, 0, 0x7273, 0,
+ 0x337B, 0, 0x7272, 0x3C32, 0x3229, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3963, 0, 0, 0x727C, 0x727B,
+};
+unsigned short utf8_to_euc_E9B5[] = {
+ 0, 0x727A, 0, 0, 0x7277, 0, 0x727D, 0,
+ 0x727E, 0, 0, 0, 0, 0, 0, 0,
+ 0x7325, 0x7324, 0, 0, 0, 0, 0, 0,
+ 0, 0x7326, 0, 0, 0x312D, 0x7321, 0x7322, 0,
+ 0x3974, 0x4C39, 0, 0, 0x7323, 0, 0, 0,
+ 0, 0, 0, 0x7C6B, 0x4B32, 0, 0, 0x732B,
+ 0x7C6A, 0, 0x7327, 0, 0, 0, 0, 0,
+ 0, 0, 0x732C, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9B6[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0x7329,
+ 0, 0x7328, 0, 0, 0, 0, 0, 0x375C,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x732D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x732E, 0, 0, 0,
+ 0, 0x732F, 0, 0x732A, 0, 0, 0, 0x7274,
+ 0, 0, 0x7330, 0, 0x4461, 0, 0, 0,
+ 0x7334, 0, 0x7335, 0x7333, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9B7[] = {
+ 0, 0x7332, 0x7338, 0, 0x7331, 0, 0x7336, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x7337,
+ 0, 0, 0, 0x733A, 0, 0, 0, 0,
+ 0, 0x7339, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x733C, 0,
+ 0, 0, 0, 0, 0, 0x733D, 0, 0x733E,
+ 0, 0, 0x4F49, 0, 0, 0, 0, 0,
+ 0x733B, 0x426B, 0x3A6D, 0, 0, 0x733F, 0, 0,
+};
+unsigned short utf8_to_euc_E9B8[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x7C6D, 0x7340, 0x7341, 0, 0, 0x7342, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9B9[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x7343, 0, 0,
+ 0x3834, 0x7344, 0, 0, 0, 0x7345, 0, 0x3C2F,
+};
+unsigned short utf8_to_euc_E9BA[] = {
+ 0, 0x7346, 0, 0, 0, 0, 0, 0,
+ 0x7347, 0, 0, 0x7348, 0x7349, 0, 0, 0,
+ 0, 0x734C, 0x734A, 0x4F3C, 0, 0x734B, 0, 0x4E6F,
+ 0, 0, 0, 0, 0, 0x734D, 0, 0x4E5B,
+ 0, 0, 0, 0, 0, 0x734E, 0x477E, 0,
+ 0, 0x734F, 0x7351, 0, 0, 0x7352, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7350, 0x396D, 0x4C4D, 0x4B63, 0x5677, 0, 0x5D60, 0x4B7B,
+};
+unsigned short utf8_to_euc_E9BB[] = {
+ 0, 0, 0, 0, 0x322B, 0, 0, 0,
+ 0, 0, 0, 0, 0x7354, 0x3550, 0x7355, 0x7356,
+ 0x7357, 0x7C6E, 0x3975, 0, 0x7358, 0, 0, 0,
+ 0x6054, 0x4C5B, 0, 0x4263, 0x7359, 0x735B, 0x735A, 0,
+ 0x735C, 0, 0, 0, 0, 0x735D, 0, 0,
+ 0x735E, 0, 0, 0, 0, 0, 0, 0x735F,
+ 0, 0, 0, 0, 0x7360, 0, 0x7361, 0x7362,
+ 0, 0x7363, 0, 0x7364, 0x7365, 0x7366, 0, 0,
+};
+unsigned short utf8_to_euc_E9BC[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0x7367,
+ 0x7368, 0, 0, 0, 0, 0, 0x4524, 0,
+ 0, 0, 0, 0x385D, 0, 0x736A, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x414D, 0x736B, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x736C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4921, 0, 0, 0x736D, 0,
+};
+unsigned short utf8_to_euc_E9BD[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x736E, 0x6337, 0, 0, 0x6C5A, 0x706D,
+ 0, 0, 0x736F, 0, 0x7370, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x7372,
+ 0x7373, 0x7374, 0x4E70, 0x7371, 0, 0, 0x7375, 0x7376,
+ 0, 0, 0x7378, 0, 0x7377, 0, 0, 0,
+ 0, 0, 0x737A, 0, 0, 0, 0x737B, 0x7379,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_E9BE[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x4E36, 0, 0,
+ 0, 0, 0, 0, 0, 0x737C, 0, 0,
+ 0, 0, 0, 0, 0x737D, 0x6354, 0, 0,
+ 0x737E, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_EFA4[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x7A46, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_EFA7[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7C4F, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_EFA8[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x7954, 0x795F,
+ 0x7960, 0x7975, 0x7A3E, 0x7A4E, 0x7A50, 0x7A7B, 0x7B23, 0x7B3A,
+ 0x7B42, 0x7B43, 0x7B44, 0x7B46, 0x7B4A, 0x7B4D, 0x7B56, 0x7B61,
+ 0x7B63, 0x7B64, 0x7B6D, 0x7B75, 0x7B77, 0x7B78, 0x7B7B, 0x7C39,
+ 0x7C40, 0x7C50, 0x7C5C, 0x7C5D, 0x7C5F, 0x7C6C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_EFB8[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7545, 0x753D, 0, 0x7532, 0, 0x754A, 0x754B, 0x7550,
+ 0x7551, 0x754C, 0x754D, 0x755A, 0x755B, 0x7554, 0x7555, 0x7552,
+};
+unsigned short utf8_to_euc_EFB9[] = {
+ 0x7553, 0x7556, 0x7557, 0x7558, 0x7559, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_EFBC[] = {
+ 0, 0x212A, 0x7C7E, 0x2174, 0x2170, 0x2173, 0x2175, 0x7C7D,
+ 0x214A, 0x214B, 0x2176, 0x215C, 0x2124, 0x215D, 0x2125, 0x213F,
+ 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337,
+ 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129,
+ 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347,
+ 0x2348, 0x2349, 0x234A, 0x234B, 0x234C, 0x234D, 0x234E, 0x234F,
+ 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357,
+ 0x2358, 0x2359, 0x235A, 0x214E, 0x2140, 0x214F, 0x2130, 0x2132,
+};
+unsigned short utf8_to_euc_EFBD[] = {
+ 0x212E, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367,
+ 0x2368, 0x2369, 0x236A, 0x236B, 0x236C, 0x236D, 0x236E, 0x236F,
+ 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377,
+ 0x2378, 0x2379, 0x237A, 0x2150, 0x2143, 0x2151, 0x2141, 0,
+ 0, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+ 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+ 0x0E38, 0x0E39, 0x0E3A, 0x0E3B, 0x0E3C, 0x0E3D, 0x0E3E, 0x0E3F,
+};
+unsigned short utf8_to_euc_EFBE[] = {
+ 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
+ 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
+ 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
+ 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0E5C, 0x0E5D, 0x0E5E, 0x0E5F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short utf8_to_euc_EFBF[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2171, 0x2172, 0x224C, 0x2131, 0x7C7C, 0x216F, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+unsigned short * utf8_to_euc_E2[] = {
+ utf8_to_euc_E280, 0, 0, 0,
+ utf8_to_euc_E284, utf8_to_euc_E285, utf8_to_euc_E286, utf8_to_euc_E287,
+ utf8_to_euc_E288, utf8_to_euc_E289, utf8_to_euc_E28A, 0,
+ utf8_to_euc_E28C, 0, 0, 0,
+ 0, utf8_to_euc_E291, utf8_to_euc_E292, 0,
+ utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296, utf8_to_euc_E297,
+ utf8_to_euc_E298, utf8_to_euc_E299, 0, 0,
+ 0, utf8_to_euc_E29D, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+unsigned short * utf8_to_euc_E3[] = {
+ utf8_to_euc_E380, utf8_to_euc_E381, utf8_to_euc_E382, utf8_to_euc_E383,
+ 0, 0, 0, 0,
+ utf8_to_euc_E388, utf8_to_euc_E389, utf8_to_euc_E38A, 0,
+ utf8_to_euc_E38C, utf8_to_euc_E38D, utf8_to_euc_E38E, utf8_to_euc_E38F,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+unsigned short * utf8_to_euc_E4[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_E4B8, utf8_to_euc_E4B9, utf8_to_euc_E4BA, utf8_to_euc_E4BB,
+ utf8_to_euc_E4BC, utf8_to_euc_E4BD, utf8_to_euc_E4BE, utf8_to_euc_E4BF,
+};
+unsigned short * utf8_to_euc_E5[] = {
+ utf8_to_euc_E580, utf8_to_euc_E581, utf8_to_euc_E582, utf8_to_euc_E583,
+ utf8_to_euc_E584, utf8_to_euc_E585, utf8_to_euc_E586, utf8_to_euc_E587,
+ utf8_to_euc_E588, utf8_to_euc_E589, utf8_to_euc_E58A, utf8_to_euc_E58B,
+ utf8_to_euc_E58C, utf8_to_euc_E58D, utf8_to_euc_E58E, utf8_to_euc_E58F,
+ utf8_to_euc_E590, utf8_to_euc_E591, utf8_to_euc_E592, utf8_to_euc_E593,
+ utf8_to_euc_E594, utf8_to_euc_E595, utf8_to_euc_E596, utf8_to_euc_E597,
+ utf8_to_euc_E598, utf8_to_euc_E599, utf8_to_euc_E59A, utf8_to_euc_E59B,
+ utf8_to_euc_E59C, utf8_to_euc_E59D, utf8_to_euc_E59E, utf8_to_euc_E59F,
+ utf8_to_euc_E5A0, utf8_to_euc_E5A1, utf8_to_euc_E5A2, utf8_to_euc_E5A3,
+ utf8_to_euc_E5A4, utf8_to_euc_E5A5, utf8_to_euc_E5A6, utf8_to_euc_E5A7,
+ utf8_to_euc_E5A8, utf8_to_euc_E5A9, utf8_to_euc_E5AA, utf8_to_euc_E5AB,
+ utf8_to_euc_E5AC, utf8_to_euc_E5AD, utf8_to_euc_E5AE, utf8_to_euc_E5AF,
+ utf8_to_euc_E5B0, utf8_to_euc_E5B1, utf8_to_euc_E5B2, utf8_to_euc_E5B3,
+ utf8_to_euc_E5B4, utf8_to_euc_E5B5, utf8_to_euc_E5B6, utf8_to_euc_E5B7,
+ utf8_to_euc_E5B8, utf8_to_euc_E5B9, utf8_to_euc_E5BA, utf8_to_euc_E5BB,
+ utf8_to_euc_E5BC, utf8_to_euc_E5BD, utf8_to_euc_E5BE, utf8_to_euc_E5BF,
+};
+unsigned short * utf8_to_euc_E6[] = {
+ utf8_to_euc_E680, utf8_to_euc_E681, utf8_to_euc_E682, utf8_to_euc_E683,
+ utf8_to_euc_E684, utf8_to_euc_E685, utf8_to_euc_E686, utf8_to_euc_E687,
+ utf8_to_euc_E688, utf8_to_euc_E689, utf8_to_euc_E68A, utf8_to_euc_E68B,
+ utf8_to_euc_E68C, utf8_to_euc_E68D, utf8_to_euc_E68E, utf8_to_euc_E68F,
+ utf8_to_euc_E690, utf8_to_euc_E691, utf8_to_euc_E692, utf8_to_euc_E693,
+ utf8_to_euc_E694, utf8_to_euc_E695, utf8_to_euc_E696, utf8_to_euc_E697,
+ utf8_to_euc_E698, utf8_to_euc_E699, utf8_to_euc_E69A, utf8_to_euc_E69B,
+ utf8_to_euc_E69C, utf8_to_euc_E69D, utf8_to_euc_E69E, utf8_to_euc_E69F,
+ utf8_to_euc_E6A0, utf8_to_euc_E6A1, utf8_to_euc_E6A2, utf8_to_euc_E6A3,
+ utf8_to_euc_E6A4, utf8_to_euc_E6A5, utf8_to_euc_E6A6, utf8_to_euc_E6A7,
+ utf8_to_euc_E6A8, utf8_to_euc_E6A9, utf8_to_euc_E6AA, utf8_to_euc_E6AB,
+ utf8_to_euc_E6AC, utf8_to_euc_E6AD, utf8_to_euc_E6AE, utf8_to_euc_E6AF,
+ utf8_to_euc_E6B0, utf8_to_euc_E6B1, utf8_to_euc_E6B2, utf8_to_euc_E6B3,
+ utf8_to_euc_E6B4, utf8_to_euc_E6B5, utf8_to_euc_E6B6, utf8_to_euc_E6B7,
+ utf8_to_euc_E6B8, utf8_to_euc_E6B9, utf8_to_euc_E6BA, utf8_to_euc_E6BB,
+ utf8_to_euc_E6BC, utf8_to_euc_E6BD, utf8_to_euc_E6BE, utf8_to_euc_E6BF,
+};
+unsigned short * utf8_to_euc_E7[] = {
+ utf8_to_euc_E780, utf8_to_euc_E781, utf8_to_euc_E782, utf8_to_euc_E783,
+ utf8_to_euc_E784, utf8_to_euc_E785, utf8_to_euc_E786, utf8_to_euc_E787,
+ utf8_to_euc_E788, utf8_to_euc_E789, utf8_to_euc_E78A, utf8_to_euc_E78B,
+ utf8_to_euc_E78C, utf8_to_euc_E78D, utf8_to_euc_E78E, utf8_to_euc_E78F,
+ utf8_to_euc_E790, utf8_to_euc_E791, utf8_to_euc_E792, utf8_to_euc_E793,
+ utf8_to_euc_E794, utf8_to_euc_E795, utf8_to_euc_E796, utf8_to_euc_E797,
+ utf8_to_euc_E798, utf8_to_euc_E799, utf8_to_euc_E79A, utf8_to_euc_E79B,
+ utf8_to_euc_E79C, utf8_to_euc_E79D, utf8_to_euc_E79E, utf8_to_euc_E79F,
+ utf8_to_euc_E7A0, utf8_to_euc_E7A1, utf8_to_euc_E7A2, utf8_to_euc_E7A3,
+ utf8_to_euc_E7A4, utf8_to_euc_E7A5, utf8_to_euc_E7A6, utf8_to_euc_E7A7,
+ utf8_to_euc_E7A8, utf8_to_euc_E7A9, utf8_to_euc_E7AA, utf8_to_euc_E7AB,
+ utf8_to_euc_E7AC, utf8_to_euc_E7AD, utf8_to_euc_E7AE, utf8_to_euc_E7AF,
+ utf8_to_euc_E7B0, utf8_to_euc_E7B1, utf8_to_euc_E7B2, utf8_to_euc_E7B3,
+ utf8_to_euc_E7B4, utf8_to_euc_E7B5, utf8_to_euc_E7B6, utf8_to_euc_E7B7,
+ utf8_to_euc_E7B8, utf8_to_euc_E7B9, utf8_to_euc_E7BA, 0,
+ utf8_to_euc_E7BC, utf8_to_euc_E7BD, utf8_to_euc_E7BE, utf8_to_euc_E7BF,
+};
+unsigned short * utf8_to_euc_E8[] = {
+ utf8_to_euc_E880, utf8_to_euc_E881, utf8_to_euc_E882, utf8_to_euc_E883,
+ utf8_to_euc_E884, utf8_to_euc_E885, utf8_to_euc_E886, utf8_to_euc_E887,
+ utf8_to_euc_E888, utf8_to_euc_E889, utf8_to_euc_E88A, utf8_to_euc_E88B,
+ utf8_to_euc_E88C, utf8_to_euc_E88D, utf8_to_euc_E88E, utf8_to_euc_E88F,
+ utf8_to_euc_E890, utf8_to_euc_E891, utf8_to_euc_E892, utf8_to_euc_E893,
+ utf8_to_euc_E894, utf8_to_euc_E895, utf8_to_euc_E896, utf8_to_euc_E897,
+ utf8_to_euc_E898, utf8_to_euc_E899, utf8_to_euc_E89A, utf8_to_euc_E89B,
+ utf8_to_euc_E89C, utf8_to_euc_E89D, utf8_to_euc_E89E, utf8_to_euc_E89F,
+ utf8_to_euc_E8A0, utf8_to_euc_E8A1, utf8_to_euc_E8A2, utf8_to_euc_E8A3,
+ utf8_to_euc_E8A4, utf8_to_euc_E8A5, utf8_to_euc_E8A6, utf8_to_euc_E8A7,
+ utf8_to_euc_E8A8, utf8_to_euc_E8A9, utf8_to_euc_E8AA, utf8_to_euc_E8AB,
+ utf8_to_euc_E8AC, utf8_to_euc_E8AD, utf8_to_euc_E8AE, 0,
+ utf8_to_euc_E8B0, utf8_to_euc_E8B1, utf8_to_euc_E8B2, utf8_to_euc_E8B3,
+ utf8_to_euc_E8B4, utf8_to_euc_E8B5, utf8_to_euc_E8B6, utf8_to_euc_E8B7,
+ utf8_to_euc_E8B8, utf8_to_euc_E8B9, utf8_to_euc_E8BA, utf8_to_euc_E8BB,
+ utf8_to_euc_E8BC, utf8_to_euc_E8BD, utf8_to_euc_E8BE, utf8_to_euc_E8BF,
+};
+unsigned short * utf8_to_euc_E9[] = {
+ utf8_to_euc_E980, utf8_to_euc_E981, utf8_to_euc_E982, utf8_to_euc_E983,
+ utf8_to_euc_E984, utf8_to_euc_E985, utf8_to_euc_E986, utf8_to_euc_E987,
+ utf8_to_euc_E988, utf8_to_euc_E989, utf8_to_euc_E98A, utf8_to_euc_E98B,
+ utf8_to_euc_E98C, utf8_to_euc_E98D, utf8_to_euc_E98E, utf8_to_euc_E98F,
+ utf8_to_euc_E990, utf8_to_euc_E991, utf8_to_euc_E992, 0,
+ 0, utf8_to_euc_E995, utf8_to_euc_E996, utf8_to_euc_E997,
+ utf8_to_euc_E998, utf8_to_euc_E999, utf8_to_euc_E99A, utf8_to_euc_E99B,
+ utf8_to_euc_E99C, utf8_to_euc_E99D, utf8_to_euc_E99E, utf8_to_euc_E99F,
+ utf8_to_euc_E9A0, utf8_to_euc_E9A1, utf8_to_euc_E9A2, utf8_to_euc_E9A3,
+ utf8_to_euc_E9A4, utf8_to_euc_E9A5, utf8_to_euc_E9A6, utf8_to_euc_E9A7,
+ utf8_to_euc_E9A8, utf8_to_euc_E9A9, utf8_to_euc_E9AA, utf8_to_euc_E9AB,
+ utf8_to_euc_E9AC, utf8_to_euc_E9AD, utf8_to_euc_E9AE, utf8_to_euc_E9AF,
+ utf8_to_euc_E9B0, utf8_to_euc_E9B1, 0, utf8_to_euc_E9B3,
+ utf8_to_euc_E9B4, utf8_to_euc_E9B5, utf8_to_euc_E9B6, utf8_to_euc_E9B7,
+ utf8_to_euc_E9B8, utf8_to_euc_E9B9, utf8_to_euc_E9BA, utf8_to_euc_E9BB,
+ utf8_to_euc_E9BC, utf8_to_euc_E9BD, utf8_to_euc_E9BE, 0,
+};
+unsigned short * utf8_to_euc_EF[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_EFA4, 0, 0, utf8_to_euc_EFA7,
+ utf8_to_euc_EFA8, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_EFB8, utf8_to_euc_EFB9, 0, 0,
+ utf8_to_euc_EFBC, utf8_to_euc_EFBD, utf8_to_euc_EFBE, utf8_to_euc_EFBF,
+};
+unsigned short * utf8_to_euc_2bytes[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_C2, utf8_to_euc_C3,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_CE, utf8_to_euc_CF,
+ utf8_to_euc_D0, utf8_to_euc_D1, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+unsigned short ** utf8_to_euc_3bytes[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_E2, utf8_to_euc_E3,
+ utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
+ utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
+ 0, 0, 0, utf8_to_euc_EF,
+};
+#endif /* UTF8_INPUT_ENABLE */
+
+#ifdef SHIFTJIS_CP932
+unsigned short shiftjis_cp932[3][189] = {
+ {
+ 0xEEEF, 0xEEF0, 0xEEF1, 0xEEF2, 0xEEF3, 0xEEF4, 0xEEF5, 0xEEF6,
+ 0xEEF7, 0xEEF8, 0x8754, 0x8755, 0x8756, 0x8757, 0x8758, 0x8759,
+ 0x875A, 0x875B, 0x875C, 0x875D, 0x81CA, 0xEEFA, 0xEEFB, 0xEEFC,
+ 0x878A, 0x8782, 0x8784, 0x81E6, 0xED40, 0xED41, 0xED42, 0xED43,
+ 0xED44, 0xED45, 0xED46, 0xED47, 0xED48, 0xED49, 0xED4A, 0xED4B,
+ 0xED4C, 0xED4D, 0xED4E, 0xED4F, 0xED50, 0xED51, 0xED52, 0xED53,
+ 0xED54, 0xED55, 0xED56, 0xED57, 0xED58, 0xED59, 0xED5A, 0xED5B,
+ 0xED5C, 0xED5D, 0xED5E, 0xED5F, 0xED60, 0xED61, 0xED62, 0,
+ 0xED63, 0xED64, 0xED65, 0xED66, 0xED67, 0xED68, 0xED69, 0xED6A,
+ 0xED6B, 0xED6C, 0xED6D, 0xED6E, 0xED6F, 0xED70, 0xED71, 0xED72,
+ 0xED73, 0xED74, 0xED75, 0xED76, 0xED77, 0xED78, 0xED79, 0xED7A,
+ 0xED7B, 0xED7C, 0xED7D, 0xED7E, 0xED80, 0xED81, 0xED82, 0xED83,
+ 0xED84, 0xED85, 0xED86, 0xED87, 0xED88, 0xED89, 0xED8A, 0xED8B,
+ 0xED8C, 0xED8D, 0xED8E, 0xED8F, 0xED90, 0xED91, 0xED92, 0xED93,
+ 0xED94, 0xED95, 0xED96, 0xED97, 0xED98, 0xED99, 0xED9A, 0xED9B,
+ 0xED9C, 0xED9D, 0xED9E, 0xED9F, 0xEDA0, 0xEDA1, 0xEDA2, 0xEDA3,
+ 0xEDA4, 0xEDA5, 0xEDA6, 0xEDA7, 0xEDA8, 0xEDA9, 0xEDAA, 0xEDAB,
+ 0xEDAC, 0xEDAD, 0xEDAE, 0xEDAF, 0xEDB0, 0xEDB1, 0xEDB2, 0xEDB3,
+ 0xEDB4, 0xEDB5, 0xEDB6, 0xEDB7, 0xEDB8, 0xEDB9, 0xEDBA, 0xEDBB,
+ 0xEDBC, 0xEDBD, 0xEDBE, 0xEDBF, 0xEDC0, 0xEDC1, 0xEDC2, 0xEDC3,
+ 0xEDC4, 0xEDC5, 0xEDC6, 0xEDC7, 0xEDC8, 0xEDC9, 0xEDCA, 0xEDCB,
+ 0xEDCC, 0xEDCD, 0xEDCE, 0xEDCF, 0xEDD0, 0xEDD1, 0xEDD2, 0xEDD3,
+ 0xEDD4, 0xEDD5, 0xEDD6, 0xEDD7, 0xEDD8, 0xEDD9, 0xEDDA, 0xEDDB,
+ 0xEDDC, 0xEDDD, 0xEDDE, 0xEDDF, 0xEDE0,
+ },
+ {
+ 0xEDE1, 0xEDE2, 0xEDE3, 0xEDE4, 0xEDE5, 0xEDE6, 0xEDE7, 0xEDE8,
+ 0xEDE9, 0xEDEA, 0xEDEB, 0xEDEC, 0xEDED, 0xEDEE, 0xEDEF, 0xEDF0,
+ 0xEDF1, 0xEDF2, 0xEDF3, 0xEDF4, 0xEDF5, 0xEDF6, 0xEDF7, 0xEDF8,
+ 0xEDF9, 0xEDFA, 0xEDFB, 0xEDFC, 0xEE40, 0xEE41, 0xEE42, 0xEE43,
+ 0xEE44, 0xEE45, 0xEE46, 0xEE47, 0xEE48, 0xEE49, 0xEE4A, 0xEE4B,
+ 0xEE4C, 0xEE4D, 0xEE4E, 0xEE4F, 0xEE50, 0xEE51, 0xEE52, 0xEE53,
+ 0xEE54, 0xEE55, 0xEE56, 0xEE57, 0xEE58, 0xEE59, 0xEE5A, 0xEE5B,
+ 0xEE5C, 0xEE5D, 0xEE5E, 0xEE5F, 0xEE60, 0xEE61, 0xEE62, 0,
+ 0xEE63, 0xEE64, 0xEE65, 0xEE66, 0xEE67, 0xEE68, 0xEE69, 0xEE6A,
+ 0xEE6B, 0xEE6C, 0xEE6D, 0xEE6E, 0xEE6F, 0xEE70, 0xEE71, 0xEE72,
+ 0xEE73, 0xEE74, 0xEE75, 0xEE76, 0xEE77, 0xEE78, 0xEE79, 0xEE7A,
+ 0xEE7B, 0xEE7C, 0xEE7D, 0xEE7E, 0xEE80, 0xEE81, 0xEE82, 0xEE83,
+ 0xEE84, 0xEE85, 0xEE86, 0xEE87, 0xEE88, 0xEE89, 0xEE8A, 0xEE8B,
+ 0xEE8C, 0xEE8D, 0xEE8E, 0xEE8F, 0xEE90, 0xEE91, 0xEE92, 0xEE93,
+ 0xEE94, 0xEE95, 0xEE96, 0xEE97, 0xEE98, 0xEE99, 0xEE9A, 0xEE9B,
+ 0xEE9C, 0xEE9D, 0xEE9E, 0xEE9F, 0xEEA0, 0xEEA1, 0xEEA2, 0xEEA3,
+ 0xEEA4, 0xEEA5, 0xEEA6, 0xEEA7, 0xEEA8, 0xEEA9, 0xEEAA, 0xEEAB,
+ 0xEEAC, 0xEEAD, 0xEEAE, 0xEEAF, 0xEEB0, 0xEEB1, 0xEEB2, 0xEEB3,
+ 0xEEB4, 0xEEB5, 0xEEB6, 0xEEB7, 0xEEB8, 0xEEB9, 0xEEBA, 0xEEBB,
+ 0xEEBC, 0xEEBD, 0xEEBE, 0xEEBF, 0xEEC0, 0xEEC1, 0xEEC2, 0xEEC3,
+ 0xEEC4, 0xEEC5, 0xEEC6, 0xEEC7, 0xEEC8, 0xEEC9, 0xEECA, 0xEECB,
+ 0xEECC, 0xEECD, 0xEECE, 0xEECF, 0xEED0, 0xEED1, 0xEED2, 0xEED3,
+ 0xEED4, 0xEED5, 0xEED6, 0xEED7, 0xEED8, 0xEED9, 0xEEDA, 0xEEDB,
+ 0xEEDC, 0xEEDD, 0xEEDE, 0xEEDF, 0xEEE0,
+ },
+ {
+ 0xEEE1, 0xEEE2, 0xEEE3, 0xEEE4, 0xEEE5, 0xEEE6, 0xEEE7, 0xEEE8,
+ 0xEEE9, 0xEEEA, 0xEEEB, 0xEEEC, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ },
+};
+unsigned short cp932inv[2][189] = {
+ {
+ 0xFA5C, 0xFA5D, 0xFA5E, 0xFA5F, 0xFA60, 0xFA61, 0xFA62, 0xFA63,
+ 0xFA64, 0xFA65, 0xFA66, 0xFA67, 0xFA68, 0xFA69, 0xFA6A, 0xFA6B,
+ 0xFA6C, 0xFA6D, 0xFA6E, 0xFA6F, 0xFA70, 0xFA71, 0xFA72, 0xFA73,
+ 0xFA74, 0xFA75, 0xFA76, 0xFA77, 0xFA78, 0xFA79, 0xFA7A, 0xFA7B,
+ 0xFA7C, 0xFA7D, 0xFA7E, 0xFA80, 0xFA81, 0xFA82, 0xFA83, 0xFA84,
+ 0xFA85, 0xFA86, 0xFA87, 0xFA88, 0xFA89, 0xFA8A, 0xFA8B, 0xFA8C,
+ 0xFA8D, 0xFA8E, 0xFA8F, 0xFA90, 0xFA91, 0xFA92, 0xFA93, 0xFA94,
+ 0xFA95, 0xFA96, 0xFA97, 0xFA98, 0xFA99, 0xFA9A, 0xFA9B, 0,
+ 0xFA9C, 0xFA9D, 0xFA9E, 0xFA9F, 0xFAA0, 0xFAA1, 0xFAA2, 0xFAA3,
+ 0xFAA4, 0xFAA5, 0xFAA6, 0xFAA7, 0xFAA8, 0xFAA9, 0xFAAA, 0xFAAB,
+ 0xFAAC, 0xFAAD, 0xFAAE, 0xFAAF, 0xFAB0, 0xFAB1, 0xFAB2, 0xFAB3,
+ 0xFAB4, 0xFAB5, 0xFAB6, 0xFAB7, 0xFAB8, 0xFAB9, 0xFABA, 0xFABB,
+ 0xFABC, 0xFABD, 0xFABE, 0xFABF, 0xFAC0, 0xFAC1, 0xFAC2, 0xFAC3,
+ 0xFAC4, 0xFAC5, 0xFAC6, 0xFAC7, 0xFAC8, 0xFAC9, 0xFACA, 0xFACB,
+ 0xFACC, 0xFACD, 0xFACE, 0xFACF, 0xFAD0, 0xFAD1, 0xFAD2, 0xFAD3,
+ 0xFAD4, 0xFAD5, 0xFAD6, 0xFAD7, 0xFAD8, 0xFAD9, 0xFADA, 0xFADB,
+ 0xFADC, 0xFADD, 0xFADE, 0xFADF, 0xFAE0, 0xFAE1, 0xFAE2, 0xFAE3,
+ 0xFAE4, 0xFAE5, 0xFAE6, 0xFAE7, 0xFAE8, 0xFAE9, 0xFAEA, 0xFAEB,
+ 0xFAEC, 0xFAED, 0xFAEE, 0xFAEF, 0xFAF0, 0xFAF1, 0xFAF2, 0xFAF3,
+ 0xFAF4, 0xFAF5, 0xFAF6, 0xFAF7, 0xFAF8, 0xFAF9, 0xFAFA, 0xFAFB,
+ 0xFAFC, 0xFB40, 0xFB41, 0xFB42, 0xFB43, 0xFB44, 0xFB45, 0xFB46,
+ 0xFB47, 0xFB48, 0xFB49, 0xFB4A, 0xFB4B, 0xFB4C, 0xFB4D, 0xFB4E,
+ 0xFB4F, 0xFB50, 0xFB51, 0xFB52, 0xFB53, 0xFB54, 0xFB55, 0xFB56,
+ 0xFB57, 0xFB58, 0xFB59, 0xFB5A, 0xFB5B,
+ },
+ {
+ 0xFB5C, 0xFB5D, 0xFB5E, 0xFB5F, 0xFB60, 0xFB61, 0xFB62, 0xFB63,
+ 0xFB64, 0xFB65, 0xFB66, 0xFB67, 0xFB68, 0xFB69, 0xFB6A, 0xFB6B,
+ 0xFB6C, 0xFB6D, 0xFB6E, 0xFB6F, 0xFB70, 0xFB71, 0xFB72, 0xFB73,
+ 0xFB74, 0xFB75, 0xFB76, 0xFB77, 0xFB78, 0xFB79, 0xFB7A, 0xFB7B,
+ 0xFB7C, 0xFB7D, 0xFB7E, 0xFB80, 0xFB81, 0xFB82, 0xFB83, 0xFB84,
+ 0xFB85, 0xFB86, 0xFB87, 0xFB88, 0xFB89, 0xFB8A, 0xFB8B, 0xFB8C,
+ 0xFB8D, 0xFB8E, 0xFB8F, 0xFB90, 0xFB91, 0xFB92, 0xFB93, 0xFB94,
+ 0xFB95, 0xFB96, 0xFB97, 0xFB98, 0xFB99, 0xFB9A, 0xFB9B, 0,
+ 0xFB9C, 0xFB9D, 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3,
+ 0xFBA4, 0xFBA5, 0xFBA6, 0xFBA7, 0xFBA8, 0xFBA9, 0xFBAA, 0xFBAB,
+ 0xFBAC, 0xFBAD, 0xFBAE, 0xFBAF, 0xFBB0, 0xFBB1, 0xFBB2, 0xFBB3,
+ 0xFBB4, 0xFBB5, 0xFBB6, 0xFBB7, 0xFBB8, 0xFBB9, 0xFBBA, 0xFBBB,
+ 0xFBBC, 0xFBBD, 0xFBBE, 0xFBBF, 0xFBC0, 0xFBC1, 0xFBC2, 0xFBC3,
+ 0xFBC4, 0xFBC5, 0xFBC6, 0xFBC7, 0xFBC8, 0xFBC9, 0xFBCA, 0xFBCB,
+ 0xFBCC, 0xFBCD, 0xFBCE, 0xFBCF, 0xFBD0, 0xFBD1, 0xFBD2, 0xFBD3,
+ 0xFBD4, 0xFBD5, 0xFBD6, 0xFBD7, 0xFBD8, 0xFBD9, 0xFBDA, 0xFBDB,
+ 0xFBDC, 0xFBDD, 0xFBDE, 0xFBDF, 0xFBE0, 0xFBE1, 0xFBE2, 0xFBE3,
+ 0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEB,
+ 0xFBEC, 0xFBED, 0xFBEE, 0xFBEF, 0xFBF0, 0xFBF1, 0xFBF2, 0xFBF3,
+ 0xFBF4, 0xFBF5, 0xFBF6, 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB,
+ 0xFBFC, 0xFC40, 0xFC41, 0xFC42, 0xFC43, 0xFC44, 0xFC45, 0xFC46,
+ 0xFC47, 0xFC48, 0xFC49, 0xFC4A, 0xFC4B, 0, 0, 0xFA40,
+ 0xFA41, 0xFA42, 0xFA43, 0xFA44, 0xFA45, 0xFA46, 0xFA47, 0xFA48,
+ 0xFA49, 0, 0xFA55, 0xFA56, 0xFA57,
+ },
+};
+#endif /* SHIFTJIS_CP932_TRANS */
+;
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index b59688cb03..6517b3aba1 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -1,120 +1,155 @@
+/*
+ * NKF Module for Ruby base on nkf 2.x
+ *
+ * original nkf2.0 is maintained at http://sourceforge.jp/projects/nkf/
+ *
+ */
+
+static char *RVersion = "2.0.4.1r1";
+
#include "ruby.h"
+/* Encoding Constants */
#define _AUTO 0
#define _JIS 1
#define _EUC 2
#define _SJIS 3
#define _BINARY 4
#define _NOCONV 4
+#define _ASCII 5
+/* 0b011x is reserved for UTF-8 Family */
+#define _UTF8 6
+/* 0b10xx is reserved for UTF-16 Family */
+#define _UTF16 8
+/* 0b11xx is reserved for UTF-32 Family */
+#define _UTF32 12
+#define _OTHER 16
#define _UNKNOWN _AUTO
+/* Replace nkf's getchar/putchar for variable modification */
+/* we never use getc, ungetc */
+
#undef getc
#undef ungetc
-#define getc(f) (input_ctr<i_len?input[input_ctr++]:-1)
-#define ungetc(c,f) input_ctr--
+#define getc(f) (input_ctr>=i_len?-1:input[input_ctr++])
+#define ungetc(c,f) input_ctr--
+#define INCSIZE 32
#undef putchar
-#define putchar(c) rb_nkf_putchar(c)
+#undef TRUE
+#undef FALSE
+#define putchar(c) rb_nkf_putchar(c)
-#define INCSIZE 32
-static int incsize;
+/* Input/Output pointers */
-static unsigned char *input, *output;
-static int input_ctr, i_len;
-static int output_ctr, o_len;
+static unsigned char *output;
+static unsigned char *input;
+static int input_ctr;
+static int i_len;
+static int output_ctr;
+static int o_len;
+static int incsize;
-static VALUE dst;
+static VALUE result;
static int
rb_nkf_putchar(c)
- unsigned int c;
+ unsigned int c;
{
if (output_ctr >= o_len) {
o_len += incsize;
- rb_str_cat(dst, 0, incsize);
- output = RSTRING(dst)->ptr;
+ rb_str_resize(result, o_len);
incsize *= 2;
+ output = RSTRING(result)->ptr;
}
output[output_ctr++] = c;
return c;
}
+/* Include kanji filter main part */
+/* getchar and putchar will be replaced during inclusion */
+
#define PERL_XS 1
-#include "nkf1.7/nkf.c"
+#include "nkf-utf8/utf8tbl.c"
+#include "nkf-utf8/nkf.c"
static VALUE
rb_nkf_kconv(obj, opt, src)
- VALUE obj, opt, src;
+ VALUE obj, opt, src;
{
- int i;
char *opt_ptr, *opt_end;
volatile VALUE v;
reinit();
- opt_ptr = str2cstr(opt, &i);
- opt_end = opt_ptr + i;
+ StringValue(opt);
+ opt_ptr = RSTRING(opt)->ptr;
+ opt_end = opt_ptr + RSTRING(opt)->len;
for (; opt_ptr < opt_end; opt_ptr++) {
if (*opt_ptr != '-') {
continue;
}
- arguments(opt_ptr);
+ options(opt_ptr);
}
incsize = INCSIZE;
- input_ctr = 0;
- input = str2cstr(src, &i_len);
- dst = rb_str_new(0, i_len*3 + 10);
- v = dst;
+ input_ctr = 0;
+ StringValue(src);
+ input = RSTRING(src)->ptr;
+ i_len = RSTRING(src)->len;
+ result = rb_str_new(0, i_len*3 + 10);
+ v = result;
output_ctr = 0;
- output = RSTRING(dst)->ptr;
- o_len = RSTRING(dst)->len;
+ output = RSTRING(result)->ptr;
+ o_len = RSTRING(result)->len;
*output = '\0';
- if(iso8859_f && (oconv != j_oconv || !x0201_f )) {
- iso8859_f = FALSE;
- }
+ if(x0201_f == WISH_TRUE)
+ x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
kanji_convert(NULL);
- RSTRING(dst)->ptr[output_ctr] = '\0';
- RSTRING(dst)->len = output_ctr;
+ RSTRING(result)->ptr[output_ctr] = '\0';
+ RSTRING(result)->len = output_ctr;
+ OBJ_INFECT(result, src);
- return dst;
+ return result;
}
+
/*
+ * NKF.guess1
+ *
* 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;
+rb_nkf_guess1(obj, src)
+ VALUE obj, src;
{
unsigned char *p;
unsigned char *pend;
- int plen;
int sequence_counter = 0;
- Check_Type(src, T_STRING);
-
- p = str2cstr(src, &plen);
- pend = p + plen;
+ StringValue(src);
+ p = RSTRING(src)->ptr;
+ pend = p + RSTRING(src)->len;
+ if (p == pend) return INT2FIX(_UNKNOWN);
#define INCR do {\
- p++;\
- if (p==pend) return INT2FIX(_UNKNOWN);\
- sequence_counter++;\
- if (sequence_counter % 2 == 1 && *p != 0xa4)\
+ 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 (6 <= sequence_counter) {\
+ sequence_counter = 0;\
+ return INT2FIX(_EUC);\
+ }\
+ } while (0)
if (*p == 0xa4)
sequence_counter = 1;
@@ -178,19 +213,77 @@ rb_nkf_guess(obj, src)
return INT2FIX(_UNKNOWN);
}
+
+/*
+ * NKF.guess2
+ *
+ * Guess Encoding By NKF2.0 Routine
+ */
+
+static VALUE
+rb_nkf_guess2(obj, src)
+ VALUE obj, src;
+{
+ int code = _BINARY;
+
+ reinit();
+
+ input_ctr = 0;
+ StringValue(src);
+ input = RSTRING(src)->ptr;
+ i_len = RSTRING(src)->len;
+
+ if(x0201_f == WISH_TRUE)
+ x0201_f = ((!iso2022jp_f)? TRUE : NO_X0201);
+
+ guess_f = TRUE;
+ kanji_convert( NULL );
+ guess_f = FALSE;
+
+ if (!is_inputcode_mixed) {
+ if (strcmp(input_codename, "") == 0) {
+ code = _ASCII;
+ } else if (strcmp(input_codename, "ISO-2022-JP") == 0) {
+ code = _JIS;
+ } else if (strcmp(input_codename, "EUC-JP") == 0) {
+ code = _EUC;
+ } else if (strcmp(input_codename, "Shift_JIS") == 0) {
+ code = _SJIS;
+ } else if (strcmp(input_codename, "UTF-8") == 0) {
+ code = _UTF8;
+ } else if (strcmp(input_codename, "UTF-16") == 0) {
+ code = _UTF16;
+ } else if (strlen(input_codename) > 0) {
+ code = _UNKNOWN;
+ }
+ }
+
+ return INT2FIX( code );
+}
+
+
+/* Initialize NKF Module */
+
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));
+ VALUE mKconv = rb_define_module("NKF");
+
+ rb_define_module_function(mKconv, "nkf", rb_nkf_kconv, 2);
+ rb_define_module_function(mKconv, "guess", rb_nkf_guess1, 1);
+ rb_define_module_function(mKconv, "guess1", rb_nkf_guess1, 1);
+ rb_define_module_function(mKconv, "guess2", rb_nkf_guess2, 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, "ASCII", INT2FIX(_ASCII));
+ rb_define_const(mKconv, "UTF8", INT2FIX(_UTF8));
+ rb_define_const(mKconv, "UTF16", INT2FIX(_UTF16));
+ rb_define_const(mKconv, "UTF32", INT2FIX(_UTF32));
+ rb_define_const(mKconv, "UNKNOWN", INT2FIX(_UNKNOWN));
+ rb_define_const(mKconv, "VERSION", rb_str_new2(RVersion));
}
diff --git a/ext/nkf/nkf1.7/nkf.c b/ext/nkf/nkf1.7/nkf.c
deleted file mode 100644
index 09419f40a7..0000000000
--- a/ext/nkf/nkf1.7/nkf.c
+++ /dev/null
@@ -1,1900 +0,0 @@
-/** 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
-
-static 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;
-}
-
-
-
-static 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.
-*/
-
-static 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 */
- }
-}
-
-static 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 */
-
-static 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
-static int
-mime_begin(f)
-FILE *f;
-{
- int c1;
- int i,j;
- 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);
- if (i == MAXRECOVER)
- i--;
- 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
-
-static 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++);
-}
-
-static 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
-
-static 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);
-}
-
-static 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;
- line = 0;
-}
-
-#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
index 4519f8ba7e..7a2390d649 100644
--- a/ext/nkf/test.rb
+++ b/ext/nkf/test.rb
@@ -1,3 +1,19 @@
+#!/usr/local/bin/ruby
+#
+# nkf test program for nkf 1.7
+# Shinji KONO <kono@ie.u-ryukyu.ac.jp>
+# Sun Aug 18 12:25:40 JST 1996
+# Sun Nov 8 00:16:06 JST 1998
+#
+# This is useful when you add new patch on nkf.
+# Since this test is too strict, faileurs may not mean
+# wrong conversion.
+#
+# nkf 1.5 differs on MIME decoding
+# nkf 1.4 passes Basic Conversion tests
+# nkf PDS version passes Basic Conversion tests using "nkf -iB -oB "
+#
+
$counter = 0
def result(result, message = nil)
$counter += 1
@@ -49,41 +65,150 @@ end
$detail = false
-def test(opt, input, expect)
+def test(opt, input, expects)
print "\nINPUT:\n", input if $detail
- print "\nEXPECT:\n", expect if $detail
+ print "\nEXPECT:\n", expects.to_s if $detail
result = nkf(opt, input)
print "\nGOT:\n", result if $detail
- print result == expect ? "Ok\n" : "Fail\n"
- return result
+ expects.each do |e|
+ if result == e then
+ puts "Ok"
+ return result
+ end
+ end
+ puts "Fail"
end
+
+example = Hash.new
+
# Basic Conversion
-print "\nBasic Conversion test\n\n"
+print "\nBasic Conversion test\n\n";
+
+# I gave up simple literal quote because there are big difference
+# on perl4 and perl5 on literal quote. Of course we cannot use
+# jperl.
-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['utf'] = <<'eofeof'.unpack('u')[0]
+M1FER<W0@4W1A9V4@XX"%Z9FBY;^<YK.5YKJ`Z(65(%-E8V]N9"!3=&%G92#D
+MN+SI@:4@2&ER86=A;F$@XX&"XX&$XX&&XX&(XX&*XX*/XX*2XX*3"DMA=&%K
+M86YA(.."HN."I.."IN."J.."JN.#K^.#LN.#LR!+:6=O=2#C@[OBB)[OO)#O
+.O*'.L<^)T)'0K^*5@@H`
+eofeof
+
+
+example['jis1'] = <<'eofeof'.unpack('u')[0]
+M&R1";3%Q<$$L&RA""ALD0F4Z3F\;*$(*&R1"<FT;*$()&R1"/F5.3D]+&RA"
+#"0D*
+eofeof
+
+example['sjis1'] = <<'eofeof'.unpack('u')[0]
+8YU#ID)%+"N-9E^T*Z>L)C^.7S)AJ"0D*
+eofeof
+
+example['euc1'] = <<'eofeof'.unpack('u')[0]
+8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
+eofeof
+
+example['utf1'] = <<'eofeof'.unpack('u')[0]
+AZ+J%Z:N/Z8JM"N>VNNFZEPKIM(D)Y+B*Z:"8Y+J8"0D*
+eofeof
+
+example['jis2'] = <<'eofeof'.unpack('u')[0]
++&R1".EA&(QLH0@H`
+eofeof
+
+example['sjis2'] = <<'eofeof'.unpack('u')[0]
+%C=:3H0H`
+eofeof
+
+example['euc2'] = <<'eofeof'.unpack('u')[0]
+%NMC&HPH`
+eofeof
+
+example['utf2'] = <<'eofeof'.unpack('u')[0]
+'YI:.Z)>D"@``
+eofeof
+
+# From JIS
+
+print "JIS to JIS ... ";test('-j',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 "JIS to UTF8... ";test('-w',example['jis'],[example['utf']]);
+
+# From SJIS
+
+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 "SJIS to UTF8... ";test('-w',example['sjis'],[example['utf']]);
+
+# From EUC
+
+print "EUC to JIS ... ";test('-j',example['euc'],[example['jis']]);
+print "EUC to SJIS... ";test('-s',example['euc'],[example['sjis']]);
+print "EUC to EUC ... ";test('-e',example['euc'],[example['euc']]);
+print "EUC to UTF8... ";test('-w',example['euc'],[example['utf']]);
+
+# From UTF8
+
+print "UTF8 to JIS ... ";test('-j',example['utf'],[example['jis']]);
+print "UTF8 to SJIS... ";test('-s',example['utf'],[example['sjis']]);
+print "UTF8 to EUC ... ";test('-e',example['utf'],[example['euc']]);
+print "UTF8 to UTF8... ";test('-w',example['utf'],[example['utf']]);
+
+
+
+# From JIS
+
+print "JIS to JIS ... ";test('-j',example['jis1'],[example['jis1']]);
+print "JIS to SJIS... ";test('-s',example['jis1'],[example['sjis1']]);
+print "JIS to EUC ... ";test('-e',example['jis1'],[example['euc1']]);
+print "JIS to UTF8... ";test('-w',example['jis1'],[example['utf1']]);
+
+# From SJIS
+
+print "SJIS to JIS ... ";test('-j',example['sjis1'],[example['jis1']]);
+print "SJIS to SJIS... ";test('-s',example['sjis1'],[example['sjis1']]);
+print "SJIS to EUC ... ";test('-e',example['sjis1'],[example['euc1']]);
+print "SJIS to UTF8... ";test('-w',example['sjis1'],[example['utf1']]);
+
+# From EUC
+
+print "EUC to JIS ... ";test('-j',example['euc1'],[example['jis1']]);
+print "EUC to SJIS... ";test('-s',example['euc1'],[example['sjis1']]);
+print "EUC to EUC ... ";test('-e',example['euc1'],[example['euc1']]);
+print "EUC to UTF8... ";test('-w',example['euc1'],[example['utf1']]);
+
+# From UTF8
+
+print "UTF8 to JIS ... ";test('-j',example['utf1'],[example['jis1']]);
+print "UTF8 to SJIS... ";test('-s',example['utf1'],[example['sjis1']]);
+print "UTF8 to EUC ... ";test('-e',example['utf1'],[example['euc1']]);
+print "UTF8 to UTF8... ";test('-w',example['utf1'],[example['utf1']]);
+
+# Ambigous Case
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
@@ -117,6 +242,31 @@ 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
+print "Ambiguous Case. ";
+ test('-j',example['amb'],[example['amb.euc']]);
+
+# Input assumption
+
+print "SJIS Input assumption ";
+ test('-jSx',example['amb'],[example['amb.sjis']]);
+
+# Broken JIS
+
+print "Broken JIS ";
+ $input = example['jis'];
+ $input.gsub("\033",'');
+ test('-Be',$input,[example['euc']]);
+print "Broken JIS is safe on Normal JIS? ";
+ $input = example['jis'];
+ test('-Be',$input,[example['euc']]);
+
+# X0201 ²¾Ì¾
+# X0201->X0208 conversion
+# X0208 aphabet -> ASCII
+# X0201 Áê¸ßÊÑ´¹
+
+print "\nX0201 test\n\n";
+
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&!
@@ -124,7 +274,6 @@ 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
@@ -134,7 +283,17 @@ 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.utf'] = <<'eofeof'.unpack('u')[0]
+MY86HZ*>2XX*KXX*MXX*OXX*QXX*SXX*LXX*NXX*PXX*RXX*T"N6%J.B+L>^\
+MH>^\HN^\H^^\I.^\I>^\IN^\I^^]@>^]@N^]@^^]A.^]A>^]AN^]APKEA:CH
+MJ)CEC[?OO('OO*#OO(/OO(3OO(7OO+[OO(;OO(KOO(COO(GBB)+OO(OOO)WO
+MO+OOO+WOO9OOO9WOOZ4*Y8V*Z*>2[[VV[[VW[[VX/>^]N>^]NN^]MN^^GN^]
+MM^^^GN^]N.^^GN^]N>^^GN^]NN^^GN.!J`KEC8KHIY+OOHKOOI_OOHOOOI_O
+MOHSOOI_OOHWOOI_OOH[OOI_OO;?OOI_OO;'OOIX*[[Z*[[Z?[[Z+[[Z?[[Z,
+M"FAA;FMA:W4@[[Z*[[Z?[[Z+[[Z?[[Z,[[VD"N^^BN^^G^^^B^^^G^^^C.^^
+2G>^]H0KEC8KHIY+C@:[EOHP*
+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
@@ -144,7 +303,6 @@ 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
@@ -154,7 +312,6 @@ 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-$
@@ -164,7 +321,34 @@ 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
-#`
+
+# -X is necessary to allow X0201 in SJIS
+# -Z convert X0208 alphabet to ASCII
+print "X0201 conversion: SJIS ";
+ test('-jXZ',example['x0201.sjis'],[example['x0201.x0208']]);
+print "X0201 conversion: JIS ";
+ test('-jZ',example['x0201.jis'],[example['x0201.x0208']]);
+print "X0201 conversion:SI/SO ";
+ test('-jZ',example['x0201.sosi'],[example['x0201.x0208']]);
+print "X0201 conversion: EUC ";
+ test('-jZ',example['x0201.euc'],[example['x0201.x0208']]);
+print "X0201 conversion: UTF8 ";
+ test('-jZ',example['x0201.utf'],[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']]);
+print "X0201 output: UTF8 ";
+ test('-xw',example['x0201.jis'],[example['x0201.utf']]);
+
+# MIME decode
+
+print "\nMIME test\n\n";
+
+# MIME ISO-2022-JP
example['mime.iso2022'] = <<'eofeof'.unpack('u')[0]
M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23TI566Q/4U9)1WEH2S\]"CT_
@@ -178,7 +362,6 @@ 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
@@ -188,7 +371,6 @@ 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
@@ -206,7 +388,6 @@ 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
@@ -215,21 +396,48 @@ 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
-#'
+
+# print "Next test is expected to Fail.\n";
+print "MIME decode (strict) ";
+ $tmp = test('-jmS',example['mime.iso2022'],[example['mime.ans.strict']]);
+
+example['mime.ans.alt'] = <<'eofeof'.unpack('u')[0]
+M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
+M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
+M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
+H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
+eofeof
+
+example['mime.unbuf.alt'] = <<'eofeof'.unpack('u')[0]
+M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
+M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
+M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
+H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
+eofeof
+
+print "MIME decode (nonstrict)";
+ $tmp = test('-jmN',example['mime.iso2022'],[example['mime.ans'],example['mime.ans.alt']]);
+ # open(OUT,">tmp1");print OUT pack('u',$tmp);close(OUT);
+# unbuf mode implies more pessimistic decode
+print "MIME decode (unbuf) ";
+ $tmp = test('-jmNu',example['mime.iso2022'],[example['mime.unbuf'],example['mime.unbuf.alt']]);
+ # open(OUT,">tmp2");print OUT pack('u',$tmp);close(OUT);
+print "MIME decode (base64) ";
+ test('-jTmB',example['mime.base64'],[example['mime.base64.ans']]);
+
+# MIME ISO-8859-1
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
@@ -244,75 +452,255 @@ 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'])
+# Without -l, ISO-8859-1 was handled as X0201.
-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 "MIME ISO-8859-1 (Q) ";
+ test('-ml',example['mime.is8859'],[example['mime.is8859.ans']]);
-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'])
+# test for -f is not so simple.
+print "\nBug Fixes\n\n";
-# Ambigous Case
-print 'Ambiguous Case. '; test('' , example['amb'], example['amb.euc'])
+# test_data/cr
-# Input assumption
-print 'SJIS Input assumption '
-test('-Sx', example['amb'], example['amb.sjis'])
+example['test_data/cr'] = <<'eofeof'.unpack('u')[0]
+1I,:DN:3(#71E<W0-=&5S=`T`
+eofeof
-# X0201 ²¾Ì¾
-# X0201->X0208 conversion
-# X0208 aphabet -> ASCII
-# X0201 Áê¸ßÊÑ´¹
+example['test_data/cr.ans'] = <<'eofeof'.unpack('u')[0]
+7&R1")$8D.21(&RA""G1E<W0*=&5S=`H`
+eofeof
-print "\nX0201 test\n\n"
+print "test_data/cr ";
+ test('-jd',example['test_data/cr'],[example['test_data/cr.ans']]);
+# test_data/fixed-qencode
-# -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'])
+example['test_data/fixed-qencode'] = <<'eofeof'.unpack('u')[0]
+M("`@("`@("`],4(D0CYE/STS1#TQ0BA""B`@("`@("`@/3%")$(^93TS1CTS
+'1#TQ0BA""@``
+eofeof
-# MIME decode
+example['test_data/fixed-qencode.ans'] = <<'eofeof'.unpack('u')[0]
+F("`@("`@("`;)$(^93\]&RA""B`@("`@("`@&R1"/F4_/1LH0@H`
+eofeof
-print "\nMIME test\n\n"
+print "test_data/fixed-qencode ";
+ test('-jmQ',example['test_data/fixed-qencode'],[example['test_data/fixed-qencode.ans']]);
+# test_data/long-fold-1
-# MIME ISO-2022-JP
+example['test_data/long-fold-1'] = <<'eofeof'.unpack('u')[0]
+MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
+M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
+MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DSR!#
+M4B],1B"DSKG4H:,-"J2SI+.DSR!#4B"DSKG4H:,-I+.DLZ3/($Q&+T-2(*3.
+9N=2AHPH-"J2SI+.DSR!,1B"DSKG4H:,*"@``
+eofeof
-print "Next test is expeced to Fail.\n"
+example['test_data/long-fold-1.ans'] = <<'eofeof'.unpack('u')[0]
+M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
+M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
+M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
+M)$(D2B0D(2,;*$(*&R1")#,D,R1/&RA"($-2+TQ&(!LD0B1..50A(QLH0@H;
+M)$(D,R0S)$\;*$(@0U(@&R1")$XY5"$C&RA""ALD0B0S)#,D3QLH0B!,1B]#
+M4B`;)$(D3CE4(2,;*$(*"ALD0B0S)#,D3QLH0B!,1B`;)$(D3CE4(2,;*$(*
+!"@``
+eofeof
-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'])
+print "test_data/long-fold-1 ";
+ test('-jTF60',example['test_data/long-fold-1'],[example['test_data/long-fold-1.ans']]);
+# test_data/long-fold
-# MIME ISO-8859-1
+example['test_data/long-fold'] = <<'eofeof'.unpack('u')[0]
+MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
+M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
+MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DS\.[
+'I*2YU*&C"@``
+eofeof
-# Without -l, ISO-8859-1 was handled as X0201.
+example['test_data/long-fold.ans'] = <<'eofeof'.unpack('u')[0]
+M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
+M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
+M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
+:)$(D2B0D(2,D,R0S)$]#.R0D.50A(QLH0@H`
+eofeof
+
+print "test_data/long-fold ";
+ test('-jTf60',example['test_data/long-fold'],[example['test_data/long-fold.ans']]);
+# test_data/mime_out
+
+example['test_data/mime_out'] = <<'eofeof'.unpack('u')[0]
+M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
+M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A86%A"BTM+2T*
+M4W5B:F5C=#H@I**DI*2FI*BDJJ2KI*VDKZ2QI+.DM:2WI+FDNZ2]I+^DP:3$
+MI,:DR*3*I,NDS*3-I,ZDSZ32I-6DV*3;I-ZDWZ3@I.&DXJ3DI*2DYJ2HI.@*
+M+2TM+0I3=6)J96-T.B!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A
+I86%A(*2BI*2DIJ2HI*H@86%A82!A86%A(&%A86$@86%A80HM+2TM"@H`
+eofeof
+
+example['test_data/mime_out.ans'] = <<'eofeof'.unpack('u')[0]
+M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
+M86%A82!A86%A(&%A86$*(&%A86$@86%A82!A86%A(&%A86$@86%A80HM+2TM
+M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
+M<DI#,&M,>5%X2D1-:TY343-*1&MK3WAS;U%G/3T_/2`*"3T_25-/+3(P,C(M
+M2E`_0C]'>5)#2D0P:U!Y4D)*15%K4FE224I%;VM3>5)-2D4P:U1I4E!*1DEK
+M5E-264=Y:$,_/2`*"3T_25-/+3(P,C(M2E`_0C]'>5)#2D9S:UAI4F9*1T%K
+M65-2:4I'46M*0U)M2D-G:V%"<V]19ST]/ST@"BTM+2T*4W5B:F5C=#H@86%A
+M82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82`]/TE33RTR,#(R+4I0
+M/T(_1WE20TI#26)+14D]/ST@"@D]/TE33RTR,#(R+4I0/T(_1WE20TI#46M*
+J:5%O2D-O8DM%23T_/2`@86%A80H@86%A82!A86%A(&%A86$*+2TM+0H*
+eofeof
+
+print "test_data/mime_out ";
+ test('-jM',example['test_data/mime_out'],[example['test_data/mime_out.ans']]);
+# test_data/multi-line
+
+example['test_data/multi-line'] = <<'eofeof'.unpack('u')[0]
+MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
+MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
+MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
+8NZ2DN=2AHP`*I+.DLZ3/P[NDI+G4H:,*
+eofeof
+
+example['test_data/multi-line.ans'] = <<'eofeof'.unpack('u')[0]
+MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
+MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
+MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
+8NZ2DN=2AHP`*I+.DLZ3/P[NDI+G4H:,*
+eofeof
+
+print "test_data/multi-line ";
+ test('-e',example['test_data/multi-line'],[example['test_data/multi-line.ans']]);
+# test_data/nkf-19-bug-1
+
+example['test_data/nkf-19-bug-1'] = <<'eofeof'.unpack('u')[0]
+,I*:DJZ2D"KK8QJ,*
+eofeof
+
+example['test_data/nkf-19-bug-1.ans'] = <<'eofeof'.unpack('u')[0]
+8&R1")"8D*R0D&RA""ALD0CI81B,;*$(*
+eofeof
+
+print "test_data/nkf-19-bug-1 ";
+ test('-Ej',example['test_data/nkf-19-bug-1'],[example['test_data/nkf-19-bug-1.ans']]);
+# test_data/nkf-19-bug-2
+
+example['test_data/nkf-19-bug-2'] = <<'eofeof'.unpack('u')[0]
+%I-NDL@H`
+eofeof
+
+example['test_data/nkf-19-bug-2.ans'] = <<'eofeof'.unpack('u')[0]
+%I-NDL@H`
+eofeof
+
+print "test_data/nkf-19-bug-2 ";
+ test('-Ee',example['test_data/nkf-19-bug-2'],[example['test_data/nkf-19-bug-2.ans']]);
+# test_data/nkf-19-bug-3
+
+example['test_data/nkf-19-bug-3'] = <<'eofeof'.unpack('u')[0]
+8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
+eofeof
+
+example['test_data/nkf-19-bug-3.ans'] = <<'eofeof'.unpack('u')[0]
+8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
+eofeof
+
+print "test_data/nkf-19-bug-3 ";
+ test('-e',example['test_data/nkf-19-bug-3'],[example['test_data/nkf-19-bug-3.ans']]);
+# test_data/non-strict-mime
+
+example['test_data/non-strict-mime'] = <<'eofeof'.unpack('u')[0]
+M/3])4T\M,C`R,BU*4#]"/PIG<U-#;V]+.6=R-D-O;TQ%9W1Y0W0T1D-$46].
+M0V\V16=S,D]N;T999S1Y1%=)3$IG=4-0:UD*2W!G<FU#>$E+:6=R,D-V;TMI
+,9W-30V]O3&,*/ST*
+eofeof
+
+example['test_data/non-strict-mime.ans'] = <<'eofeof'.unpack('u')[0]
+M&R1")$8D)"0_)$`D)"1&)%XD.2$C&RA"#0H-"ALD0CMD)$\[?B$Y)6PE.21+
+<)&(]<20K)#LD1B0D)#\D0"0D)$8D)"1>&RA""@``
+eofeof
+
+print "test_data/non-strict-mime ";
+ test('-jTmN',example['test_data/non-strict-mime'],[example['test_data/non-strict-mime.ans']]);
+# test_data/q-encode-softrap
+
+example['test_data/q-encode-softrap'] = <<'eofeof'.unpack('u')[0]
+H/3%")$(T03MZ)3T*,R$\)4DD3CTQ0BA""CTQ0B1"2E$T.3TQ0BA""@``
+eofeof
+
+example['test_data/q-encode-softrap.ans'] = <<'eofeof'.unpack('u')[0]
+>&R1"-$$[>B4S(3PE221.&RA""ALD0DI1-#D;*$(*
+eofeof
+
+print "test_data/q-encode-softrap ";
+ test('-jTmQ',example['test_data/q-encode-softrap'],[example['test_data/q-encode-softrap.ans']]);
+# test_data/rot13
+
+example['test_data/rot13'] = <<'eofeof'.unpack('u')[0]
+MI+.D\Z3+I,&DSZ&BS:W"]*3(I*2DI*3>I+FAHPH*;FMF('9E<BXQ+CDR(*3R
+MS?C-T:2UI+NDQJ2DI+^DP*2DI,:DI*3>I+FDK*&B05-#24D@I,O"T*2WI,8@
+M4D]4,3,@I*P*P+6DMZ2OQK"DI*3&I*2DRJ2DI.BDIJ3'H:*PRK*\I,ZDZ*2F
+MI,O*T;2YI+6D[*3>I+ND\Z&C"@HE(&5C:&\@)VAO9V4G('P@;FMF("UR"FAO
+#9V4*
+eofeof
+
+example['test_data/rot13.ans'] = <<'eofeof'.unpack('u')[0]
+M&R1"4V)31%-Z4W!3?E!1?%QQ15-W4U-34U,O4VA04ALH0@H*87AS(&ER92XQ
+M+CDR(!LD0E-#?$E\(E-D4VI3=5-34VY3;U-34W534U,O4VA36U!1&RA"3D90
+M5E8@&R1"4WIQ(5-F4W4;*$(@14)',3,@&R1"4UL;*$(*&R1";V139E->=5]3
+M4U-U4U-3>5-34SE355-V4%%?>6%K4WU3.5-54WIY(F-H4V13/5,O4VI31%!2
+A&RA""@HE(')P=6(@)W5B='(G('P@87AS("UE"G5B='(*
+eofeof
+
+print "test_data/rot13 ";
+ test('-jr',example['test_data/rot13'],[example['test_data/rot13.ans']]);
+# test_data/slash
+
+example['test_data/slash'] = <<'eofeof'.unpack('u')[0]
+7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
+eofeof
+
+example['test_data/slash.ans'] = <<'eofeof'.unpack('u')[0]
+7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
+eofeof
+
+print "test_data/slash ";
+ test(' ',example['test_data/slash'],[example['test_data/slash.ans']]);
+# test_data/z1space-0
+
+example['test_data/z1space-0'] = <<'eofeof'.unpack('u')[0]
+"H:$`
+eofeof
+
+example['test_data/z1space-0.ans'] = <<'eofeof'.unpack('u')[0]
+"H:$`
+eofeof
+
+print "test_data/z1space-0 ";
+ test('-e -Z',example['test_data/z1space-0'],[example['test_data/z1space-0.ans']]);
+# test_data/z1space-1
+
+example['test_data/z1space-1'] = <<'eofeof'.unpack('u')[0]
+"H:$`
+eofeof
+
+example['test_data/z1space-1.ans'] = <<'eofeof'.unpack('u')[0]
+!(```
+eofeof
+
+print "test_data/z1space-1 ";
+ test('-e -Z1',example['test_data/z1space-1'],[example['test_data/z1space-1.ans']]);
+# test_data/z1space-2
+
+example['test_data/z1space-2'] = <<'eofeof'.unpack('u')[0]
+"H:$`
+eofeof
+
+example['test_data/z1space-2.ans'] = <<'eofeof'.unpack('u')[0]
+"("``
+eofeof
+
+print "test_data/z1space-2 ";
+ test('-e -Z2',example['test_data/z1space-2'],[example['test_data/z1space-2.ans']]);
-print 'MIME ISO-8859-1 (Q) '
-test('-ml', example['mime.is8859'], example['mime.is8859.ans'])
+# end
diff --git a/ext/openssl/.cvsignore b/ext/openssl/.cvsignore
new file mode 100644
index 0000000000..dfb8bfb8bb
--- /dev/null
+++ b/ext/openssl/.cvsignore
@@ -0,0 +1,4 @@
+GNUmakefile
+Makefile
+mkmf.log
+dep
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
new file mode 100644
index 0000000000..d587116c82
--- /dev/null
+++ b/ext/openssl/extconf.rb
@@ -0,0 +1,145 @@
+=begin
+= $RCSfile$ -- Generator for Makefile
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+require "mkmf"
+
+dir_config("openssl")
+dir_config("kerberos")
+
+message "=== OpenSSL for Ruby configurator ===\n"
+
+##
+# Adds -Wall -DOSSL_DEBUG for compilation and some more targets when GCC is used
+# To turn it on, use: --with-debug or --enable-debug
+#
+if with_config("debug") or enable_config("debug")
+ $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+
+ if /gcc/ =~ CONFIG["CC"]
+ $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
+ end
+end
+
+message "=== Checking for system dependent stuff... ===\n"
+have_library("nsl", "t_open")
+have_library("socket", "socket")
+have_header("unistd.h")
+have_header("sys/time.h")
+have_header("assert.h")
+
+message "=== Checking for required stuff... ===\n"
+if $mingw
+ have_library("wsock32")
+ have_library("gdi32")
+end
+result = have_header("openssl/ssl.h")
+result &&= %w[crypto libeay32].any? {|lib| have_library(lib, "OpenSSL_add_all_digests")}
+result &&= %w[ssl ssleay32].any? {|lib| have_library(lib, "SSL_library_init")}
+if !result
+ unless pkg_config("openssl") and have_header("openssl/ssl.h")
+ message "=== Checking for required stuff failed. ===\n"
+ message "Makefile wasn't created. Fix the errors above.\n"
+ exit 1
+ end
+end
+
+unless have_header("openssl/conf_api.h")
+ message "OpenSSL 0.9.6 or later required.\n"
+ exit 1
+end
+
+message "=== Checking for OpenSSL features... ===\n"
+have_func("BN_mod_add")
+have_func("BN_mod_sqr")
+have_func("BN_mod_sub")
+have_func("BN_pseudo_rand_range")
+have_func("BN_rand_range")
+have_func("CONF_get1_default_config_file")
+have_func("EVP_CIPHER_CTX_copy")
+have_func("EVP_CIPHER_CTX_set_padding")
+have_func("EVP_CipherFinal_ex")
+have_func("EVP_CipherInit_ex")
+have_func("EVP_DigestFinal_ex")
+have_func("EVP_DigestInit_ex")
+have_func("EVP_MD_CTX_cleanup")
+have_func("EVP_MD_CTX_create")
+have_func("EVP_MD_CTX_destroy")
+have_func("EVP_MD_CTX_init")
+have_func("HMAC_CTX_cleanup")
+have_func("HMAC_CTX_copy")
+have_func("HMAC_CTX_init")
+have_func("PEM_def_callback")
+have_func("X509V3_set_nconf")
+have_func("X509_CRL_add0_revoked")
+have_func("X509_CRL_set_issuer_name")
+have_func("X509_CRL_set_version")
+have_func("X509_CRL_sort")
+have_func("X509_STORE_get_ex_data")
+have_func("X509_STORE_set_ex_data")
+if try_compile("#define FOO(a, ...) foo(a, ##__VA_ARGS__)\n int x(){FOO(1);FOO(1,2);FOO(1,2,3);}\n")
+ $defs.push("-DHAVE_VA_ARGS_MACRO")
+end
+if have_header("openssl/engine.h")
+ have_func("ENGINE_add")
+ have_func("ENGINE_load_builtin_engines")
+ have_func("ENGINE_load_openbsd_dev_crypto")
+ have_func("ENGINE_get_digest")
+ have_func("ENGINE_get_cipher")
+ have_func("ENGINE_cleanup")
+end
+if try_compile(<<SRC)
+#include <openssl/opensslv.h>
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+# error "OpenSSL version is less than 0.9.7."
+#endif
+SRC
+ have_header("openssl/ocsp.h")
+end
+have_struct_member("EVP_CIPHER_CTX", "flags", "openssl/evp.h")
+have_struct_member("EVP_CIPHER_CTX", "engine", "openssl/evp.h")
+have_struct_member("X509_ATTRIBUTE", "single", "openssl/x509.h")
+
+message "=== Checking done. ===\n"
+$distcleanfiles << "GNUmakefile" << "dep"
+create_makefile("openssl")
+if /gcc/ =~ CONFIG["CC"]
+ File.open("GNUmakefile", "w") {|f|
+ f.print <<EOD
+include Makefile
+
+SRCS = $(OBJS:.o=.c)
+
+test-link: $(OBJS)
+ $(CC) $(DLDFLAGS) #{OUTFLAG}.testlink $(OBJS) $(LIBPATH) $(LIBS) $(LOCAL_LIBS)
+ @$(RM) .testlink
+ @echo "Done."
+
+dep:
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $(SRCS) -MM | \\
+ $(RUBY) -p -e 'BEGIN{S = []' \\
+ -e 'while !ARGV.empty? and /^(\\w+)=(.*)/ =~ ARGV[0]' \\
+ -e 'S << [/\#{Regexp.quote($$2)}\\//, "$$(\#{$$1})/"]' \\
+ -e 'ARGV.shift' \\
+ -e 'end' \\
+ -e '}' -e 'S.each(&method(:gsub!))' -- \\
+ 'topdir=$(topdir)' 'srcdir=$(srcdir)' 'hdrdir=$(hdrdir)' \\
+ > dep
+
+include dep
+EOD
+ }
+end
+message "Done.\n"
diff --git a/ext/openssl/lib/net/ftptls.rb b/ext/openssl/lib/net/ftptls.rb
new file mode 100644
index 0000000000..f433457923
--- /dev/null
+++ b/ext/openssl/lib/net/ftptls.rb
@@ -0,0 +1,43 @@
+=begin
+= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2003 Blaz Grilc <farmer@gmx.co.uk>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Requirements
+
+= Version
+ $Id$
+
+= Notes
+ Tested on FreeBSD 5-CURRENT and 4-STABLE
+ - ruby 1.6.8 (2003-01-17) [i386-freebsd5]
+ - OpenSSL 0.9.7a Feb 19 2003
+ - ruby-openssl-0.2.0.p0
+ tested on ftp server: glftpd 1.30
+=end
+
+require 'socket'
+require 'openssl'
+require 'net/ftp'
+
+module Net
+ class FTPTLS < FTP
+ def login(user = "anonymous", passwd = nil, acct = nil)
+ ctx = OpenSSL::SSL::SSLContext.new('SSLv23')
+ ctx.key = nil
+ ctx.cert = nil
+ voidcmd("AUTH TLS")
+ @sock = OpenSSL::SSL::SSLSocket.new(@sock, ctx)
+ @sock.connect
+ super(user, passwd, acct)
+ voidcmd("PBSZ 0")
+ end
+ end
+end
diff --git a/ext/openssl/lib/net/https.rb b/ext/openssl/lib/net/https.rb
new file mode 100644
index 0000000000..fb7f53c555
--- /dev/null
+++ b/ext/openssl/lib/net/https.rb
@@ -0,0 +1,188 @@
+=begin
+= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Requirements
+ This program requires Net 1.2.0 or higher version.
+ You can get it from RAA or Ruby's CVS repository.
+
+= Version
+ $Id$
+
+ 2001/11/06: Contiributed to Ruby/OpenSSL project.
+
+== class Net::HTTP
+
+== Example
+
+Simple HTTP client is here:
+
+ require 'net/http'
+ host, port, path = "localhost", 80, "/"
+ if %r!http://(.*?)(?::(\d+))?(/.*)! =~ ARGV[0]
+ host = $1
+ port = $2.to_i if $2
+ path = $3
+ end
+ h = Net::HTTP.new(host, port)
+ h.get2(path){ |resp| print resp.body }
+
+It can be replaced by follow one:
+
+ require 'net/https'
+ host, port, path = "localhost", 80, "/"
+ if %r!(https?)://(.*?)(?::(\d+))?(/.*)! =~ ARGV[0]
+ scheme = $1
+ host = $2
+ port = $3 ? $3.to_i : ((scheme == "http") ? 80 : 443)
+ path = $4
+ end
+ h = Net::HTTP.new(host, port)
+ h.use_ssl = true if scheme == "https" # enable SSL/TLS
+ h.get2(path){ |resp| print resp.body }
+
+=== Instance Methods
+
+: use_ssl
+ returns ture if use SSL/TLS with HTTP.
+
+: use_ssl=((|true_or_false|))
+ sets use_ssl.
+
+: peer_cert
+ return the X.509 certificates the server presented.
+
+: key=((|key|))
+ Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
+ (This method is appeared in Michal Rokos's OpenSSL extention.)
+
+: key_file=((|path|))
+ Sets a private key file to use in PEM format.
+
+: cert=((|cert|))
+ Sets an OpenSSL::X509::Certificate object as client certificate.
+ (This method is appeared in Michal Rokos's OpenSSL extention.)
+
+: cert_file=((|path|))
+ Sets pathname of a X.509 certification file in PEM format.
+
+: ca_file=((|path|))
+ Sets path of a CA certification file in PEM format.
+ The file can contrain several CA certificats.
+
+: ca_path=((|path|))
+ Sets path of a CA certification directory containing certifications
+ in PEM format.
+
+: verify_mode=((|mode|))
+ Sets the flags for server the certification verification at
+ begining of SSL/TLS session.
+ OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable.
+
+: verify_callback=((|proc|))
+ Sets the verify callback for the server certification verification.
+
+: verify_depth=((|num|))
+ Sets the maximum depth for the certificate chain verification.
+
+: cert_store=((|store|))
+ Sets the X509::Store to verify peer certificate.
+
+=end
+
+require 'net/protocols'
+require 'net/http'
+
+module Net
+ class HTTP
+ class Conn < HTTPRequest
+ REQUEST_HAS_BODY=false
+ RESPONSE_HAS_BODY=false
+ METHOD="connect"
+
+ def initialize
+ super nil, nil
+ end
+
+ def exec( sock, addr, port, ver )
+ @socket = sock
+ request(addr, port, ver)
+ end
+
+ def request( addr, port, ver )
+ @socket.writeline sprintf('CONNECT %s:%s HTTP/%s', addr, port, ver)
+ @socket.writeline ''
+ end
+ end
+
+ module ProxyMod
+ def edit_path( path )
+ if use_ssl
+ 'https://' + addr_port + path
+ else
+ 'http://' + addr_port + path
+ end
+ end
+ end
+
+ def self.socket_type
+ SSLIO
+ end
+
+ attr_reader :use_ssl
+ attr_writer :key, :cert
+ attr_writer :ca_file, :ca_path
+ attr_writer :verify_mode, :verify_callback, :verify_depth
+ attr_writer :cert_store, :timeout
+ attr_reader :peer_cert
+
+ alias :default_initialize :initialize
+
+ def initialize(*args)
+ default_initialize(*args)
+ @key = @cert = @ca_file = @ca_path = @verify_mode =
+ @verify_callback = @verify_depth = @timeout = @cert_store = nil
+ @already_connected = false
+ end
+
+ def use_ssl=(flag)
+ if @already_connected && !@use_ssl
+ raise ProtocolError, "connection is alrady set up"
+ end
+ @use_ssl = flag
+ end
+
+ def on_connect
+ if use_ssl
+ if proxy?
+ Conn.new.exec(@socket, @address, @port, "1.0")
+ resp = HTTPResponse.read_new(@socket)
+ if resp.code != '200'
+ raise resp.message
+ end
+ end
+ @socket.key = @key if @key
+ @socket.cert = @cert if @cert
+ @socket.ca_file = @ca_file
+ @socket.ca_path = @ca_path
+ @socket.verify_mode = @verify_mode
+ @socket.verify_callback = @verify_callback
+ @socket.verify_depth = @verify_depth
+ @socket.timeout = @timeout
+ @socket.cert_store = @cert_store
+ @socket.ssl_connect
+ @peer_cert = @socket.peer_cert
+ end
+ @already_connected = true
+ end
+
+ end
+end
diff --git a/ext/openssl/lib/net/protocols.rb b/ext/openssl/lib/net/protocols.rb
new file mode 100644
index 0000000000..073d4f3027
--- /dev/null
+++ b/ext/openssl/lib/net/protocols.rb
@@ -0,0 +1,56 @@
+=begin
+= $RCSfile$ -- SSL/TLS enhancement for Net.
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Requirements
+ This program requires Net 1.2.0 or higher version.
+ You can get it from RAA or Ruby's CVS repository.
+
+= Version
+ $Id$
+
+ 2001/11/06: Contiributed to Ruby/OpenSSL project.
+=end
+
+require 'net/protocol'
+require 'forwardable'
+require 'openssl'
+
+module Net
+ class SSLIO < InternetMessageIO
+ extend Forwardable
+
+ def_delegators(:@ssl_context,
+ :key=, :cert=, :key_file=, :cert_file=,
+ :ca_file=, :ca_path=,
+ :verify_mode=, :verify_callback=, :verify_depth=,
+ :timeout=, :cert_store=)
+
+ def initialize(addr, port, otime = nil, rtime = nil, dout = nil)
+ super
+ @ssl_context = OpenSSL::SSL::SSLContext.new()
+ end
+
+ def ssl_connect()
+ unless @ssl_context.verify_mode
+ warn "warning: peer certificate won't be verified in this SSL session."
+ @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+ @socket = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context)
+ @socket.sync_close = true
+ @socket.connect
+ end
+
+ def peer_cert
+ @socket.peer_cert
+ end
+ end
+end
diff --git a/ext/openssl/lib/net/telnets.rb b/ext/openssl/lib/net/telnets.rb
new file mode 100644
index 0000000000..c7ecbd717a
--- /dev/null
+++ b/ext/openssl/lib/net/telnets.rb
@@ -0,0 +1,250 @@
+=begin
+= $RCSfile$ -- SSL/TLS enhancement for Net::Telnet.
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+
+ 2001/11/06: Contiributed to Ruby/OpenSSL project.
+
+== class Net::Telnet
+
+This class will initiate SSL/TLS session automaticaly if the server
+sent OPT_STARTTLS. Some options are added for SSL/TLS.
+
+ host = Net::Telnet::new({
+ "Host" => "localhost",
+ "Port" => "telnets",
+ ## follows are new options.
+ 'CertFile' => "user.crt",
+ 'KeyFile' => "user.key",
+ 'CAFile' => "/some/where/certs/casert.pem",
+ 'CAPath' => "/some/where/caserts",
+ 'VerifyMode' => SSL::VERIFY_PEER,
+ 'VerifyCallback' => verify_proc
+ })
+
+Or, the new options ('Cert', 'Key' and 'CACert') are available from
+Michal Rokos's OpenSSL module.
+
+ cert_data = File.open("user.crt"){|io| io.read }
+ pkey_data = File.open("user.key"){|io| io.read }
+ cacert_data = File.open("your_ca.pem"){|io| io.read }
+ host = Net::Telnet::new({
+ "Host" => "localhost",
+ "Port" => "telnets",
+ 'Cert' => OpenSSL::X509::Certificate.new(cert_data)
+ 'Key' => OpenSSL::PKey::RSA.new(pkey_data)
+ 'CACert' => OpenSSL::X509::Certificate.new(cacert_data)
+ 'CAFile' => "/some/where/certs/casert.pem",
+ 'CAPath' => "/some/where/caserts",
+ 'VerifyMode' => SSL::VERIFY_PEER,
+ 'VerifyCallback' => verify_proc
+ })
+
+This class is expected to be a superset of usual Net::Telnet.
+=end
+
+require "net/telnet"
+require "openssl"
+
+module Net
+ class Telnet
+ attr_reader :ssl
+
+ OPT_STARTTLS = 46.chr # "\056" # "\x2e" # Start TLS
+ TLS_FOLLOWS = 1.chr # "\001" # "\x01" # FOLLOWS (for STARTTLS)
+
+ alias preprocess_orig preprocess
+
+ def ssl?; @ssl; end
+
+ def preprocess(string)
+ # combine CR+NULL into CR
+ string = string.gsub(/#{CR}#{NULL}/no, CR) if @options["Telnetmode"]
+
+ # combine EOL into "\n"
+ string = string.gsub(/#{EOL}/no, "\n") unless @options["Binmode"]
+
+ string.gsub(/#{IAC}(
+ [#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]|
+ [#{DO}#{DONT}#{WILL}#{WONT}][#{OPT_BINARY}-#{OPT_EXOPL}]|
+ #{SB}[#{OPT_BINARY}-#{OPT_EXOPL}]
+ (#{IAC}#{IAC}|[^#{IAC}])+#{IAC}#{SE}
+ )/xno) do
+ if IAC == $1 # handle escaped IAC characters
+ IAC
+ elsif AYT == $1 # respond to "IAC AYT" (are you there)
+ self.write("nobody here but us pigeons" + EOL)
+ ''
+ elsif DO[0] == $1[0] # respond to "IAC DO x"
+ if OPT_BINARY[0] == $1[1]
+ @telnet_option["BINARY"] = true
+ self.write(IAC + WILL + OPT_BINARY)
+ elsif OPT_STARTTLS[0] == $1[1]
+ self.write(IAC + WILL + OPT_STARTTLS)
+ self.write(IAC + SB + OPT_STARTTLS + TLS_FOLLOWS + IAC + SE)
+ else
+ self.write(IAC + WONT + $1[1..1])
+ end
+ ''
+ elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x"
+ self.write(IAC + WONT + $1[1..1])
+ ''
+ elsif WILL[0] == $1[0] # respond to "IAC WILL x"
+ if OPT_BINARY[0] == $1[1]
+ self.write(IAC + DO + OPT_BINARY)
+ elsif OPT_ECHO[0] == $1[1]
+ self.write(IAC + DO + OPT_ECHO)
+ elsif OPT_SGA[0] == $1[1]
+ @telnet_option["SGA"] = true
+ self.write(IAC + DO + OPT_SGA)
+ else
+ self.write(IAC + DONT + $1[1..1])
+ end
+ ''
+ elsif WONT[0] == $1[0] # respond to "IAC WON'T x"
+ if OPT_ECHO[0] == $1[1]
+ self.write(IAC + DONT + OPT_ECHO)
+ elsif OPT_SGA[0] == $1[1]
+ @telnet_option["SGA"] = false
+ self.write(IAC + DONT + OPT_SGA)
+ else
+ self.write(IAC + DONT + $1[1..1])
+ end
+ ''
+ elsif SB[0] == $1[0] # respond to "IAC SB xxx IAC SE"
+ if OPT_STARTTLS[0] == $1[1] && TLS_FOLLOWS[0] == $2[0]
+ @sock = OpenSSL::SSL::SSLSocket.new(@sock)
+ @sock.cert_file = @options['CertFile']
+ @sock.cert = @options['Cert'] unless @sock.cert
+ @sock.key_file = @options['KeyFile']
+ @sock.key = @options['Key'] unless @sock.key
+ @sock.ca_cert = @options['CACert']
+ @sock.ca_file = @options['CAFile']
+ @sock.ca_path = @options['CAPath']
+ @sock.timeout = @options['Timeout']
+ @sock.verify_mode = @options['VerifyMode']
+ @sock.verify_callback = @options['VerifyCallback']
+ @sock.verify_depth = @options['VerifyDepth']
+ @sock.connect
+ @ssl = true
+ end
+ ''
+ else
+ ''
+ end
+ end
+ end # preprocess
+
+ alias waitfor_org waitfor
+
+ def waitfor(options)
+ time_out = @options["Timeout"]
+ waittime = @options["Waittime"]
+
+ if options.kind_of?(Hash)
+ prompt = if options.has_key?("Match")
+ options["Match"]
+ elsif options.has_key?("Prompt")
+ options["Prompt"]
+ elsif options.has_key?("String")
+ Regexp.new( Regexp.quote(options["String"]) )
+ end
+ time_out = options["Timeout"] if options.has_key?("Timeout")
+ waittime = options["Waittime"] if options.has_key?("Waittime")
+ else
+ prompt = options
+ end
+
+ if time_out == false
+ time_out = nil
+ end
+
+ line = ''
+ buf = ''
+ @rest = '' unless @rest
+
+ until(prompt === line and not IO::select([@sock], nil, nil, waittime))
+ unless IO::select([@sock], nil, nil, time_out)
+ raise TimeoutError, "timed-out; wait for the next data"
+ end
+ begin
+ c = @rest + @sock.sysread(1024 * 1024)
+ @dumplog.log_dump('<', c) if @options.has_key?("Dump_log")
+ if @options["Telnetmode"]
+ pos = 0
+ catch(:next){
+ while true
+ case c[pos]
+ when IAC[0]
+ case c[pos+1]
+ when DO[0], DONT[0], WILL[0], WONT[0]
+ throw :next unless c[pos+2]
+ pos += 3
+ when SB[0]
+ ret = detect_sub_negotiation(c, pos)
+ throw :next unless ret
+ pos = ret
+ when nil
+ throw :next
+ else
+ pos += 2
+ end
+ when nil
+ throw :next
+ else
+ pos += 1
+ end
+ end
+ }
+
+ buf = preprocess(c[0...pos])
+ @rest = c[pos..-1]
+ end
+ @log.print(buf) if @options.has_key?("Output_log")
+ line.concat(buf)
+ yield buf if block_given?
+ rescue EOFError # End of file reached
+ if line == ''
+ line = nil
+ yield nil if block_given?
+ end
+ break
+ end
+ end
+ line
+ end
+
+ private
+
+ def detect_sub_negotiation(data, pos)
+ return nil if data.length < pos+6 # IAC SB x param IAC SE
+ pos += 3
+ while true
+ case data[pos]
+ when IAC[0]
+ if data[pos+1] == SE[0]
+ pos += 2
+ return pos
+ else
+ pos += 2
+ end
+ when nil
+ return nil
+ else
+ pos += 1
+ end
+ end
+ end
+
+ end
+end
diff --git a/ext/openssl/lib/openssl.rb b/ext/openssl/lib/openssl.rb
new file mode 100644
index 0000000000..24a9eed136
--- /dev/null
+++ b/ext/openssl/lib/openssl.rb
@@ -0,0 +1,24 @@
+=begin
+= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+require 'openssl.so'
+
+require 'openssl/bn'
+require 'openssl/cipher'
+require 'openssl/digest'
+require 'openssl/ssl'
+require 'openssl/x509'
+
diff --git a/ext/openssl/lib/openssl/bn.rb b/ext/openssl/lib/openssl/bn.rb
new file mode 100644
index 0000000000..e7cbf2cfaf
--- /dev/null
+++ b/ext/openssl/lib/openssl/bn.rb
@@ -0,0 +1,35 @@
+=begin
+= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for BN
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+##
+# Should we care what if somebody require this file directly?
+#require 'openssl'
+
+module OpenSSL
+ class BN
+ include Comparable
+ end # BN
+end # OpenSSL
+
+##
+# Add double dispatch to Integer
+#
+class Integer
+ def to_bn
+ OpenSSL::BN::new(self)
+ end
+end # Integer
+
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
new file mode 100644
index 0000000000..31dcdf1f9a
--- /dev/null
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -0,0 +1,200 @@
+=begin
+= $RCSfile$ -- Buffering mix-in module.
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+module Buffering
+ include Enumerable
+ attr_accessor :sync
+ BLOCK_SIZE = 1024*16
+
+ def initialize(*args)
+ @sync = @io.sync
+ end
+
+ #
+ # for reading.
+ #
+ private
+
+ def fill_rbuff
+ @rbuffer = "" unless defined? @rbuffer
+ begin
+ @rbuffer << self.sysread(BLOCK_SIZE)
+ rescue EOFError
+ @eof = true
+ end
+ end
+
+ def consume_rbuff(size=nil)
+ if @rbuffer.size == 0
+ @eof = nil
+ nil
+ else
+ size = @rbuffer.size unless size
+ ret = @rbuffer[0, size]
+ @rbuffer[0, size] = ""
+ ret
+ end
+ end
+
+ public
+
+ def read(size=nil, buf=nil)
+ fill_rbuff unless defined? @rbuffer
+ @eof ||= nil
+ until @eof
+ break if size && size <= @rbuffer.size
+ fill_rbuff
+ end
+ ret = consume_rbuff(size) || ""
+ if buf
+ buf.replace(ret)
+ ret = buf
+ end
+ (size && ret.empty?) ? nil : ret
+ end
+
+ def gets(eol=$/)
+ fill_rbuff unless defined? @rbuffer
+ idx = @rbuffer.index(eol)
+ @eof ||= nil
+ until @eof
+ break if idx
+ fill_rbuff
+ idx = @rbuffer.index(eol)
+ end
+ if eol.is_a?(Regexp)
+ size = idx ? idx+$&.size : nil
+ else
+ size = idx ? idx+eol.size : nil
+ end
+ consume_rbuff(size)
+ end
+
+ def each(eol=$/)
+ while line = self.gets(eol?)
+ yield line
+ end
+ end
+ alias each_line each
+
+ def readlines(eol=$/)
+ ary = []
+ while line = self.gets(eol)
+ ary << line
+ end
+ ary
+ end
+
+ def readline(eol=$/)
+ raise EOFErorr if eof?
+ gets(eol)
+ end
+
+ def getc
+ c = read(1)
+ c ? c.to_i : nil
+ end
+
+ def each_byte
+ while c = getc
+ yield(c)
+ end
+ end
+
+ def readchar
+ raise EOFErorr if eof?
+ getc
+ end
+
+ def ungetc(c)
+ @rbuffer[0,0] = c.chr
+ end
+
+ def eof?
+ @eof ||= nil
+ @eof && @rbuffer.size == 0
+ end
+ alias eof eof?
+
+ #
+ # for writing.
+ #
+ private
+
+ def do_write(s)
+ @wbuffer = "" unless defined? @wbuffer
+ @wbuffer << s
+ @sync ||= false
+ if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
+ remain = idx ? idx + $/.size : @wbuffer.length
+ nwritten = 0
+ while remain > 0
+ nwrote = syswrite(@wbuffer[nwritten,remain])
+ remain -= nwrote
+ nwritten += nwrote
+ end
+ @wbuffer = ""
+ end
+ end
+
+ public
+
+ def write(s)
+ do_write(s)
+ s.length
+ end
+
+ def << (s)
+ do_write(s)
+ self
+ end
+
+ def puts(*args)
+ s = ""
+ args.each{|arg|
+ s << arg.to_s
+ unless /#{$/}\z/o =~ s
+ s << $/
+ end
+ }
+ do_write(s)
+ nil
+ end
+
+ def print(*args)
+ s = ""
+ args.each{ |arg| s << arg.to_s }
+ do_write(s)
+ nil
+ end
+
+ def printf(s, *args)
+ do_write(s % args)
+ nil
+ end
+
+ def flush
+ osync = @sync
+ @sync = true
+ do_write ""
+ @sync = osync
+ end
+
+ def close
+ flush rescue nil
+ sysclose
+ end
+end
diff --git a/ext/openssl/lib/openssl/cipher.rb b/ext/openssl/lib/openssl/cipher.rb
new file mode 100644
index 0000000000..11153104ee
--- /dev/null
+++ b/ext/openssl/lib/openssl/cipher.rb
@@ -0,0 +1,52 @@
+=begin
+= $RCSfile$ -- Ruby-space predefined Cipher subclasses
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+##
+# Should we care what if somebody require this file directly?
+#require 'openssl'
+
+module OpenSSL
+ module Cipher
+ %w(AES Cast5 BF DES Idea RC2 RC4 RC5).each{|cipher|
+ eval(<<-EOD)
+ class #{cipher} < Cipher
+ def initialize(*args)
+ args = args.join('-')
+ if args.size == 0
+ super(\"#{cipher}\")
+ else
+ super(\"#{cipher}-#\{args\}\")
+ end
+ end
+ end
+ EOD
+ }
+
+ class Cipher
+ def random_key
+ str = OpenSSL::Random.random_bytes(self.key_len)
+ self.key = str
+ return str
+ end
+
+ def random_iv
+ str = OpenSSL::Random.random_bytes(self.iv_len)
+ self.iv = str
+ return str
+ end
+ end
+ end # Cipher
+end # OpenSSL
diff --git a/ext/openssl/lib/openssl/digest.rb b/ext/openssl/lib/openssl/digest.rb
new file mode 100644
index 0000000000..58622f543e
--- /dev/null
+++ b/ext/openssl/lib/openssl/digest.rb
@@ -0,0 +1,44 @@
+=begin
+= $RCSfile$ -- Ruby-space predefined Digest subclasses
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+##
+# Should we care what if somebody require this file directly?
+#require 'openssl'
+
+module OpenSSL
+ module Digest
+
+ %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1).each{|digest|
+ eval(<<-EOD)
+ class #{digest} < Digest
+ def initialize(data=nil)
+ super(\"#{digest}\", data)
+ end
+
+ def #{digest}::digest(data)
+ Digest::digest(\"#{digest}\", data)
+ end
+
+ def #{digest}::hexdigest(data)
+ Digest::hexdigest(\"#{digest}\", data)
+ end
+ end
+ EOD
+ }
+
+ end # Digest
+end # OpenSSL
+
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
new file mode 100644
index 0000000000..629109a1de
--- /dev/null
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -0,0 +1,93 @@
+=begin
+= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+require "openssl"
+require "openssl/buffering"
+
+module OpenSSL
+ module SSL
+ module SocketForwarder
+ def addr
+ to_io.addr
+ end
+
+ def peeraddr
+ to_io.peeraddr
+ end
+
+ def getsockopt(level, optname, optval)
+ to_io.setsockopt(level, optname, optval)
+ end
+
+ def setsockopt(level, optname)
+ to_io.setsockopt(level, optname)
+ end
+
+ def fcntl(*args)
+ to_io.fcntl(*args)
+ end
+
+ def closed?
+ to_io.closed?
+ end
+
+ def do_not_reverse_lookup=(flag)
+ to_io.do_not_reverse_lookup = flag
+ end
+ end
+
+ class SSLSocket
+ include Buffering
+ include SocketForwarder
+ end
+
+ class SSLServer
+ include SocketForwarder
+ attr_accessor :start_immediately
+
+ def initialize(svr, ctx)
+ @svr = svr
+ @ctx = ctx
+ @start_immediately = true
+ end
+
+ def to_io
+ @svr
+ end
+
+ def listen(backlog=5)
+ @svr.listen(backlog)
+ end
+
+ def accept
+ sock = @svr.accept
+ begin
+ ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
+ ssl.sync_close = true
+ ssl.accept if @start_immediately
+ ssl
+ rescue SSLError => ex
+ sock.close
+ raise ex
+ end
+ end
+
+ def close
+ @svr.close
+ end
+ end
+ end
+end
diff --git a/ext/openssl/lib/openssl/x509.rb b/ext/openssl/lib/openssl/x509.rb
new file mode 100644
index 0000000000..6dd469827a
--- /dev/null
+++ b/ext/openssl/lib/openssl/x509.rb
@@ -0,0 +1,71 @@
+=begin
+= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for X509 and subclasses
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id$
+=end
+
+require "openssl"
+
+module OpenSSL
+ module X509
+ class ExtensionFactory
+ def create_extension(*arg)
+ if arg.size > 1
+ create_ext(*arg)
+ else
+ send("create_ext_from_"+arg[0].class.name.downcase, arg[0])
+ end
+ end
+
+ def create_ext_from_array(ary)
+ raise ExtensionError, "unexpected array form" if ary.size > 3
+ create_ext(ary[0], ary[1], ary[2])
+ end
+
+ def create_ext_from_string(str) # "oid = critical, value"
+ oid, value = str.split(/=/, 2)
+ oid.strip!
+ value.strip!
+ create_ext(oid, value)
+ end
+
+ def create_ext_from_hash(hash)
+ create_ext(hash["oid"], hash["value"], hash["critical"])
+ end
+ end
+
+ class Extension
+ def to_s # "oid = critical, value"
+ str = self.oid
+ str << " = "
+ str << "critical, " if self.critical?
+ str << self.value.gsub(/\n/, ", ")
+ end
+
+ def to_h # {"oid"=>sn|ln, "value"=>value, "critical"=>true|false}
+ {"oid"=>self.oid,"value"=>self.value,"critical"=>self.critical?}
+ end
+
+ def to_a
+ [ self.oid, self.value, self.critical? ]
+ end
+ end
+
+ class Name
+ def self.parse(str, template=OBJECT_TYPE_TEMPLATE)
+ ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
+ self.new(ary, template)
+ end
+ end
+ end
+end
diff --git a/ext/openssl/openssl_missing.c b/ext/openssl/openssl_missing.c
new file mode 100644
index 0000000000..dfa5f90012
--- /dev/null
+++ b/ext/openssl/openssl_missing.c
@@ -0,0 +1,338 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+
+#if !defined(OPENSSL_NO_HMAC)
+#include <string.h> /* memcpy() */
+#include <openssl/hmac.h>
+
+#if !defined(HAVE_HMAC_CTX_COPY)
+int
+HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
+{
+ if (!out || !in) return 0;
+ memcpy(out, in, sizeof(HMAC_CTX));
+
+ if (!EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx)
+ || !EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx)
+ || !EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx))
+ return 0;
+ return 1;
+}
+#endif /* HAVE_HMAC_CTX_COPY */
+#endif /* NO_HMAC */
+
+#if !defined(HAVE_X509_STORE_SET_EX_DATA)
+#include <openssl/x509_vfy.h>
+
+int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data)
+{
+ return CRYPTO_set_ex_data(&str->ex_data, idx, data);
+}
+
+void *X509_STORE_get_ex_data(X509_STORE *str, int idx)
+{
+ return CRYPTO_get_ex_data(&str->ex_data, idx);
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_CREATE)
+EVP_MD_CTX *
+EVP_MD_CTX_create(void)
+{
+ EVP_MD_CTX *ctx = OPENSSL_malloc(sizeof(EVP_MD_CTX));
+ if (!ctx) return NULL;
+
+ memset(ctx, 0, sizeof(EVP_MD_CTX));
+
+ return ctx;
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_CLEANUP)
+int
+EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
+{
+ /* FIXME!!! */
+ memset(ctx, 0, sizeof(EVP_MD_CTX));
+
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_DESTROY)
+void
+EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
+{
+ EVP_MD_CTX_cleanup(ctx);
+ OPENSSL_free(ctx);
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_INIT)
+void
+EVP_MD_CTX_init(EVP_MD_CTX *ctx)
+{
+ memset(ctx, 0, sizeof(EVP_MD_CTX));
+}
+#endif
+
+#if !defined(HAVE_HMAC_CTX_INIT)
+void
+HMAC_CTX_init(HMAC_CTX *ctx)
+{
+ EVP_MD_CTX_init(&ctx->i_ctx);
+ EVP_MD_CTX_init(&ctx->o_ctx);
+ EVP_MD_CTX_init(&ctx->md_ctx);
+}
+#endif
+
+#if !defined(HAVE_HMAC_CTX_CLEANUP)
+void
+HMAC_CTX_cleanup(HMAC_CTX *ctx)
+{
+ EVP_MD_CTX_cleanup(&ctx->i_ctx);
+ EVP_MD_CTX_cleanup(&ctx->o_ctx);
+ EVP_MD_CTX_cleanup(&ctx->md_ctx);
+ memset(ctx, 0, sizeof(HMAC_CTX));
+}
+#endif
+
+#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
+/*
+ * this function does not exist in OpenSSL yet... or ever?.
+ * a future version may break this function.
+ * tested on 0.9.7d.
+ */
+int
+EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in)
+{
+ memcpy(out, in, sizeof(EVP_CIPHER_CTX));
+
+#if defined(HAVE_ENGINE_ADD) && defined(HAVE_ST_ENGINE)
+ if (in->engine) ENGINE_add(out->engine);
+ if (in->cipher_data) {
+ out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
+ memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size);
+ }
+#endif
+
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_SET_VERSION)
+int
+X509_CRL_set_version(X509_CRL *x, long version)
+{
+ if (x == NULL || x->crl == NULL) return 0;
+ if (x->crl->version == NULL) {
+ x->crl->version = M_ASN1_INTEGER_new();
+ if (x->crl->version == NULL) return 0;
+ }
+ return ASN1_INTEGER_set(x->crl->version, version);
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_SET_ISSUER_NAME)
+int
+X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
+{
+ if (x == NULL || x->crl == NULL) return 0;
+ return X509_NAME_set(&x->crl->issuer, name);
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_SORT)
+int
+X509_CRL_sort(X509_CRL *c)
+{
+ int i;
+ X509_REVOKED *r;
+ /* sort the data so it will be written in serial
+ * number order */
+ sk_X509_REVOKED_sort(c->crl->revoked);
+ for (i=0; i<sk_X509_REVOKED_num(c->crl->revoked); i++) {
+ r=sk_X509_REVOKED_value(c->crl->revoked, i);
+ r->sequence=i;
+ }
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_ADD0_REVOKED)
+static int
+OSSL_X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b)
+{
+ return(ASN1_STRING_cmp(
+ (ASN1_STRING *)(*a)->serialNumber,
+ (ASN1_STRING *)(*b)->serialNumber));
+}
+
+int
+X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
+{
+ X509_CRL_INFO *inf;
+
+ inf = crl->crl;
+ if (!inf->revoked)
+ inf->revoked = sk_X509_REVOKED_new(OSSL_X509_REVOKED_cmp);
+ if (!inf->revoked || !sk_X509_REVOKED_push(inf->revoked, rev))
+ return 0;
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_SQR)
+int
+BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
+{
+ if (!BN_sqr(r, (BIGNUM*)a, ctx)) return 0;
+ return BN_mod(r, r, m, ctx);
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_ADD) || !defined(HAVE_BN_MOD_SUB)
+int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
+{
+ if (!BN_mod(r,m,d,ctx)) return 0;
+ if (!r->neg) return 1;
+ return (d->neg ? BN_sub : BN_add)(r, r, d);
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_ADD)
+int
+BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
+{
+ if (!BN_add(r, a, b)) return 0;
+ return BN_nnmod(r, r, m, ctx);
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_SUB)
+int
+BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
+{
+ if (!BN_sub(r, a, b)) return 0;
+ return BN_nnmod(r, r, m, ctx);
+}
+#endif
+
+#if !defined(HAVE_BN_RAND_RANGE) || !defined(HAVE_BN_PSEUDO_RAND_RANGE)
+static int
+bn_rand_range(int pseudo, BIGNUM *r, BIGNUM *range)
+{
+ int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
+ int n;
+
+ if (range->neg || BN_is_zero(range)) return 0;
+
+ n = BN_num_bits(range);
+
+ if (n == 1) {
+ if (!BN_zero(r)) return 0;
+ } else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) {
+ do {
+ if (!bn_rand(r, n + 1, -1, 0)) return 0;
+ if (BN_cmp(r ,range) >= 0) {
+ if (!BN_sub(r, r, range)) return 0;
+ if (BN_cmp(r, range) >= 0)
+ if (!BN_sub(r, r, range)) return 0;
+ }
+ } while (BN_cmp(r, range) >= 0);
+ } else {
+ do {
+ if (!bn_rand(r, n, -1, 0)) return 0;
+ } while (BN_cmp(r, range) >= 0);
+ }
+
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_BN_RAND_RANGE)
+int
+BN_rand_range(BIGNUM *r, BIGNUM *range)
+{
+ return bn_rand_range(0, r, range);
+}
+#endif
+
+#if !defined(HAVE_BN_PSEUDO_RAND_RANGE)
+int
+BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range)
+{
+ return bn_rand_range(1, r, range);
+}
+#endif
+
+#if !defined(HAVE_CONF_GET1_DEFAULT_CONFIG_FILE)
+#define OPENSSL_CONF "openssl.cnf"
+char *
+CONF_get1_default_config_file(void)
+{
+ char *file;
+ int len;
+
+ file = getenv("OPENSSL_CONF");
+ if (file) return BUF_strdup(file);
+ len = strlen(X509_get_default_cert_area());
+#ifndef OPENSSL_SYS_VMS
+ len++;
+#endif
+ len += strlen(OPENSSL_CONF);
+ file = OPENSSL_malloc(len + 1);
+ if (!file) return NULL;
+ strcpy(file,X509_get_default_cert_area());
+#ifndef OPENSSL_SYS_VMS
+ strcat(file,"/");
+#endif
+ strcat(file,OPENSSL_CONF);
+
+ return file;
+}
+#endif
+
+#if !defined(HAVE_PEM_DEF_CALLBACK)
+#define OSSL_PASS_MIN_LENGTH 4
+int
+PEM_def_callback(char *buf, int num, int w, void *key)
+{
+ int i,j;
+ const char *prompt;
+
+ if (key) {
+ i = strlen(key);
+ i = (i > num) ? num : i;
+ memcpy(buf, key, i);
+ return i;
+ }
+
+ prompt = EVP_get_pw_prompt();
+ if (prompt == NULL) prompt = "Enter PEM pass phrase:";
+ for (;;) {
+ i = EVP_read_pw_string(buf, num, prompt, w);
+ if (i != 0) {
+ memset(buf, 0, (unsigned int)num);
+ return(-1);
+ }
+ j = strlen(buf);
+ if (j < OSSL_PASS_MIN_LENGTH) {
+ fprintf(stderr,
+ "phrase is too short, needs to be at least %d chars\n",
+ OSSL_PASS_MIN_LENGTH);
+ }
+ else break;
+ }
+ return j;
+}
+#endif
+
diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h
new file mode 100644
index 0000000000..2a082f3fe0
--- /dev/null
+++ b/ext/openssl/openssl_missing.h
@@ -0,0 +1,126 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_OPENSSL_MISSING_H_)
+#define _OSSL_OPENSSL_MISSING_H_
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*
+ * These functions are not included in headers of OPENSSL <= 0.9.6b
+ */
+
+#if !defined(PEM_read_bio_DSAPublicKey)
+# define PEM_read_bio_DSAPublicKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
+ (char *(*)())d2i_DSAPublicKey,PEM_STRING_DSA_PUBLIC,bp,(char **)x,cb,u)
+#endif
+
+#if !defined(PEM_write_bio_DSAPublicKey)
+# define PEM_write_bio_DSAPublicKey(bp,x) \
+ PEM_ASN1_write_bio((int (*)())i2d_DSAPublicKey,\
+ PEM_STRING_DSA_PUBLIC,\
+ bp,(char *)x, NULL, NULL, 0, NULL, NULL)
+#endif
+
+#if !defined(DSAPrivateKey_dup)
+# define DSAPrivateKey_dup(dsa) (DSA *)ASN1_dup((int (*)())i2d_DSAPrivateKey, \
+ (char *(*)())d2i_DSAPrivateKey,(char *)dsa)
+#endif
+
+#if !defined(DSAPublicKey_dup)
+# define DSAPublicKey_dup(dsa) (DSA *)ASN1_dup((int (*)())i2d_DSAPublicKey, \
+ (char *(*)())d2i_DSAPublicKey,(char *)dsa)
+#endif
+
+#if !defined(X509_REVOKED_dup)
+# define X509_REVOKED_dup(rev) (X509_REVOKED *)ASN1_dup((int (*)())i2d_X509_REVOKED, \
+ (char *(*)())d2i_X509_REVOKED, (char *)rev)
+#endif
+
+#if !defined(PKCS7_SIGNER_INFO_dup)
+# define PKCS7_SIGNER_INFO_dup(si) (PKCS7_SIGNER_INFO *)ASN1_dup((int (*)())i2d_PKCS7_SIGNER_INFO, \
+ (char *(*)())d2i_PKCS7_SIGNER_INFO, (char *)si)
+#endif
+
+#if !defined(PKCS7_RECIP_INFO_dup)
+# define PKCS7_RECIP_INFO_dup(ri) (PKCS7_RECIP_INFO *)ASN1_dup((int (*)())i2d_PKCS7_RECIP_INFO, \
+ (char *(*)())d2i_PKCS7_RECIP_INFO, (char *)ri)
+#endif
+
+void HMAC_CTX_init(HMAC_CTX *ctx);
+int HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
+void HMAC_CTX_cleanup(HMAC_CTX *ctx);
+
+EVP_MD_CTX *EVP_MD_CTX_create(void);
+void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
+int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
+void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
+
+#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
+int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in);
+#endif
+
+#if !defined(HAVE_EVP_DIGESTINIT_EX)
+# define EVP_DigestInit_ex(ctx, md, engine) EVP_DigestInit(ctx, md)
+#endif
+#if !defined(HAVE_EVP_DIGESTFINAL_EX)
+# define EVP_DigestFinal_ex(ctx, buf, len) EVP_DigestFinal(ctx, buf, len)
+#endif
+
+#if !defined(HAVE_EVP_CIPHERINIT_EX)
+# define EVP_CipherInit_ex(ctx, type, impl, key, iv, enc) EVP_CipherInit(ctx, type, key, iv, enc)
+#endif
+#if !defined(HAVE_EVP_CIPHERFINAL_EX)
+# define EVP_CipherFinal_ex(ctx, outm, outl) EVP_CipherFinal(ctx, outm, outl)
+#endif
+
+#if !defined(EVP_CIPHER_name)
+# define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
+#endif
+
+#if !defined(EVP_MD_name)
+# define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_type(e))
+#endif
+
+#if !defined(HAVE_EVP_HMAC_INIT_EX)
+# define HMAC_Init_ex(ctx, key, len, digest, engine) HMAC_Init(ctx, key, len, digest)
+#endif
+
+#if !defined(PKCS7_is_detached)
+# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))
+#endif
+
+#if !defined(PKCS7_type_is_encrypted)
+# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
+#endif
+
+void *X509_STORE_get_ex_data(X509_STORE *str, int idx);
+int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data);
+int X509_CRL_set_version(X509_CRL *x, long version);
+int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
+int X509_CRL_sort(X509_CRL *c);
+int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
+int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+int BN_rand_range(BIGNUM *r, BIGNUM *range);
+int BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range);
+char *CONF_get1_default_config_file(void);
+int PEM_def_callback(char *buf, int num, int w, void *key);
+
+#if defined(__cplusplus)
+}
+#endif
+
+
+#endif /* _OSSL_OPENSSL_MISSING_H_ */
+
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
new file mode 100644
index 0000000000..36a7aa5042
--- /dev/null
+++ b/ext/openssl/ossl.c
@@ -0,0 +1,449 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+#include <stdarg.h> /* for ossl_raise */
+
+/*
+ * String to HEXString conversion
+ */
+int
+string2hex(char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
+{
+ static const char hex[]="0123456789abcdef";
+ int i, len = 2 * buf_len;
+
+ if (buf_len < 0 || len < buf_len) { /* PARANOIA? */
+ return -1;
+ }
+ if (!hexbuf) { /* if no buf, return calculated len */
+ if (hexbuf_len) {
+ *hexbuf_len = len;
+ }
+ return len;
+ }
+ if (!(*hexbuf = OPENSSL_malloc(len + 1))) {
+ return -1;
+ }
+ for (i = 0; i < buf_len; i++) {
+ (*hexbuf)[2 * i] = hex[((unsigned char)buf[i]) >> 4];
+ (*hexbuf)[2 * i + 1] = hex[buf[i] & 0x0f];
+ }
+ (*hexbuf)[2 * i] = '\0';
+
+ if (hexbuf_len) {
+ *hexbuf_len = len;
+ }
+ return len;
+}
+
+/*
+ * Data Conversion
+ */
+STACK_OF(X509) *
+ossl_x509_ary2sk0(VALUE ary)
+{
+ STACK_OF(X509) *sk;
+ VALUE val;
+ X509 *x509;
+ int i;
+
+ Check_Type(ary, T_ARRAY);
+ sk = sk_X509_new_null();
+ if (!sk) ossl_raise(eOSSLError, NULL);
+
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ val = rb_ary_entry(ary, i);
+ if (!rb_obj_is_kind_of(val, cX509Cert)) {
+ sk_X509_pop_free(sk, X509_free);
+ ossl_raise(eOSSLError, "object not X509 cert in array");
+ }
+ x509 = DupX509CertPtr(val); /* NEED TO DUP */
+ sk_X509_push(sk, x509);
+ }
+ return sk;
+}
+
+STACK_OF(X509) *
+ossl_protect_x509_ary2sk(VALUE ary, int *status)
+{
+ return (STACK_OF(X509)*)rb_protect((VALUE(*)_((VALUE)))ossl_x509_ary2sk0,
+ ary, status);
+}
+
+STACK_OF(X509) *
+ossl_x509_ary2sk(VALUE ary)
+{
+ STACK_OF(X509) *sk;
+ int status = 0;
+
+ sk = ossl_protect_x509_ary2sk(ary, &status);
+ if(status) rb_jump_tag(status);
+
+ return sk;
+}
+
+#define OSSL_IMPL_SK2ARY(name, type) \
+VALUE \
+ossl_##name##_sk2ary(STACK *sk) \
+{ \
+ type *t; \
+ int i, num; \
+ VALUE ary; \
+ \
+ if (!sk) { \
+ OSSL_Debug("empty sk!"); \
+ return Qnil; \
+ } \
+ num = sk_num(sk); \
+ if (num < 0) { \
+ OSSL_Debug("items in sk < -1???"); \
+ return rb_ary_new(); \
+ } \
+ ary = rb_ary_new2(num); \
+ \
+ for (i=0; i<num; i++) { \
+ t = (type *)sk_value(sk, i); \
+ rb_ary_push(ary, ossl_##name##_new(t)); \
+ } \
+ return ary; \
+}
+OSSL_IMPL_SK2ARY(x509, X509)
+OSSL_IMPL_SK2ARY(x509crl, X509_CRL)
+
+static VALUE
+ossl_str_new(int size)
+{
+ return rb_str_new(0, size);
+}
+
+VALUE
+ossl_buf2str(char *buf, int len)
+{
+ VALUE str;
+ int status = 0;
+
+ str = rb_protect((VALUE(*)_((VALUE)))ossl_str_new, len, &status);
+ if(!NIL_P(str)) memcpy(RSTRING(str)->ptr, buf, len);
+ OPENSSL_free(buf);
+ if(status) rb_jump_tag(status);
+
+ return str;
+}
+
+/*
+ * our default PEM callback
+ */
+static VALUE
+ossl_pem_passwd_cb0(VALUE flag)
+{
+ VALUE pass;
+
+ pass = rb_yield(flag);
+ SafeStringValue(pass);
+
+ return pass;
+}
+
+int
+ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
+{
+ int len, status = 0;
+ VALUE rflag, pass;
+
+ if (pwd || !rb_block_given_p())
+ return PEM_def_callback(buf, max_len, flag, pwd);
+
+ while (1) {
+ /*
+ * when the flag is nonzero, this passphrase
+ * will be used to perform encryption; otherwise it will
+ * be used to perform decryption.
+ */
+ rflag = flag ? Qtrue : Qfalse;
+ pass = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
+ if (status) return -1; /* exception was raised. */
+ len = RSTRING(pass)->len;
+ if (len < 4) { /* 4 is OpenSSL hardcoded limit */
+ rb_warning("password must be longer than 4 bytes");
+ continue;
+ }
+ if (len > max_len) {
+ rb_warning("password must be shorter then %d bytes", max_len-1);
+ continue;
+ }
+ memcpy(buf, RSTRING(pass)->ptr, len);
+ break;
+ }
+ return len;
+}
+
+/*
+ * Verify callback
+ */
+int ossl_verify_cb_idx;
+
+VALUE
+ossl_call_verify_cb_proc(struct ossl_verify_cb_args *args)
+{
+ return rb_funcall(args->proc, rb_intern("call"), 2,
+ args->preverify_ok, args->store_ctx);
+}
+
+int
+ossl_verify_cb(int ok, X509_STORE_CTX *ctx)
+{
+ VALUE proc, rctx, ret;
+ struct ossl_verify_cb_args args;
+ int state = 0;
+
+ proc = (VALUE)X509_STORE_CTX_get_ex_data(ctx, ossl_verify_cb_idx);
+ if ((void*)proc == 0)
+ proc = (VALUE)X509_STORE_get_ex_data(ctx->ctx, ossl_verify_cb_idx);
+ if ((void*)proc == 0)
+ return ok;
+ if (!NIL_P(proc)) {
+ rctx = rb_protect((VALUE(*)(VALUE))ossl_x509stctx_new,
+ (VALUE)ctx, &state);
+ ret = Qfalse;
+ if (!state) {
+ args.proc = proc;
+ args.preverify_ok = ok ? Qtrue : Qfalse;
+ args.store_ctx = rctx;
+ ret = rb_ensure(ossl_call_verify_cb_proc, (VALUE)&args,
+ ossl_x509stctx_clear_ptr, rctx);
+ }
+ if (ret == Qtrue) {
+ X509_STORE_CTX_set_error(ctx, X509_V_OK);
+ ok = 1;
+ }
+ else{
+ if (X509_STORE_CTX_get_error(ctx) == X509_V_OK) {
+ X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REJECTED);
+ }
+ ok = 0;
+ }
+ }
+
+ return ok;
+}
+
+/*
+ * main module
+ */
+VALUE mOSSL;
+
+/*
+ * OpenSSLError < StandardError
+ */
+VALUE eOSSLError;
+
+/*
+ * Convert to DER string
+ */
+ID ossl_s_to_der;
+
+VALUE
+ossl_to_der(VALUE obj)
+{
+ VALUE tmp;
+
+ tmp = rb_funcall(obj, ossl_s_to_der, 0);
+ StringValue(tmp);
+
+ return tmp;
+}
+
+VALUE
+ossl_to_der_if_possible(VALUE obj)
+{
+ if(rb_respond_to(obj, ossl_s_to_der))
+ return ossl_to_der(obj);
+ return obj;
+}
+
+/*
+ * Errors
+ */
+void
+ossl_raise(VALUE exc, const char *fmt, ...)
+{
+ va_list args;
+ char buf[BUFSIZ];
+ const char *msg;
+ long e = ERR_get_error();
+ int len = 0;
+
+ if (fmt) {
+ va_start(args, fmt);
+ len = vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+ len += snprintf(buf+len, BUFSIZ-len, ": ");
+ }
+ if (e) {
+ if (dOSSL == Qtrue) /* FULL INFO */
+ msg = ERR_error_string(e, NULL);
+ else
+ msg = ERR_reason_error_string(e);
+ ERR_clear_error();
+ len += snprintf(buf+len, BUFSIZ-len, "%s", msg);
+ }
+
+ rb_exc_raise(rb_exc_new(exc, buf, len));
+}
+
+/*
+ * Debug
+ */
+VALUE dOSSL;
+
+#if !defined(HAVE_VA_ARGS_MACRO)
+void
+ossl_debug(const char *fmt, ...)
+{
+ va_list args;
+
+ if (dOSSL == Qtrue) {
+ fprintf(stderr, "OSSL_DEBUG: ");
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ fprintf(stderr, " [CONTEXT N/A]\n");
+ }
+}
+#endif
+
+static VALUE
+ossl_debug_get(VALUE self)
+{
+ return dOSSL;
+}
+
+static VALUE
+ossl_debug_set(VALUE self, VALUE val)
+{
+ VALUE old = dOSSL;
+ dOSSL = val;
+
+ if (old != dOSSL) {
+ if (dOSSL == Qtrue) {
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
+ fprintf(stderr, "OSSL_DEBUG: IS NOW ON!\n");
+ } else if (old == Qtrue) {
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF);
+ fprintf(stderr, "OSSL_DEBUG: IS NOW OFF!\n");
+ }
+ }
+ return val;
+}
+
+/*
+ * OSSL library init
+ */
+void
+Init_openssl()
+{
+ /*
+ * Init timezone info
+ */
+#if 0
+ tzset();
+#endif
+
+ /*
+ * Init all digests, ciphers
+ */
+ /* CRYPTO_malloc_init(); */
+ /* ENGINE_load_builtin_engines(); */
+ OpenSSL_add_all_algorithms();
+ ERR_load_crypto_strings();
+ SSL_load_error_strings();
+
+ /*
+ * FIXME:
+ * On unload do:
+ */
+#if 0
+ CONF_modules_unload(1);
+ destroy_ui_method();
+ EVP_cleanup();
+ ENGINE_cleanup();
+ CRYPTO_cleanup_all_ex_data();
+ ERR_remove_state(0);
+ ERR_free_strings();
+#endif
+
+ /*
+ * Init main module
+ */
+ mOSSL = rb_define_module("OpenSSL");
+
+ /*
+ * Constants
+ */
+ rb_define_const(mOSSL, "VERSION", rb_str_new2(OSSL_VERSION));
+ rb_define_const(mOSSL, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
+ rb_define_const(mOSSL, "OPENSSL_VERSION_NUMBER", INT2NUM(OPENSSL_VERSION_NUMBER));
+
+ /*
+ * Generic error,
+ * common for all classes under OpenSSL module
+ */
+ eOSSLError = rb_define_class_under(mOSSL,"OpenSSLError",rb_eStandardError);
+
+ /*
+ * Verify callback Proc index for ext-data
+ */
+ ossl_verify_cb_idx =
+ X509_STORE_CTX_get_ex_new_index(0, "ossl_verify_cb_idx", 0, 0, 0);
+
+ /*
+ * Init debug core
+ */
+ dOSSL = Qfalse;
+ rb_define_module_function(mOSSL, "debug", ossl_debug_get, 0);
+ rb_define_module_function(mOSSL, "debug=", ossl_debug_set, 1);
+
+ /*
+ * Get ID of to_der
+ */
+ ossl_s_to_der = rb_intern("to_der");
+
+ /*
+ * Init components
+ */
+ Init_ossl_bn();
+ Init_ossl_cipher();
+ Init_ossl_config();
+ Init_ossl_digest();
+ Init_ossl_hmac();
+ Init_ossl_ns_spki();
+ Init_ossl_pkcs12();
+ Init_ossl_pkcs7();
+ Init_ossl_pkey();
+ Init_ossl_rand();
+ Init_ossl_ssl();
+ Init_ossl_x509();
+ Init_ossl_ocsp();
+ Init_ossl_engine();
+ Init_ossl_asn1();
+}
+
+#if defined(OSSL_DEBUG)
+/*
+ * Check if all symbols are OK with 'make LDSHARED=gcc all'
+ */
+int
+main(int argc, char *argv[], char *env[])
+{
+ return 0;
+}
+#endif /* OSSL_DEBUG */
+
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
new file mode 100644
index 0000000000..c5054beba2
--- /dev/null
+++ b/ext/openssl/ossl.h
@@ -0,0 +1,217 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_H_)
+#define _OSSL_H_
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*
+ * Check the OpenSSL version
+ * The only supported are:
+ * OpenSSL >= 0.9.7
+ */
+#include <openssl/opensslv.h>
+
+#ifdef HAVE_ASSERT_H
+# include <assert.h>
+#else
+# define assert(condition)
+#endif
+
+#if defined(_WIN32)
+# define OpenFile WINAPI_OpenFile
+# define OSSL_NO_CONF_API 1
+#endif
+#include <errno.h>
+#include <openssl/err.h>
+#include <openssl/asn1_mac.h>
+#include <openssl/x509v3.h>
+#include <openssl/ssl.h>
+#include <openssl/pkcs12.h>
+#include <openssl/pkcs7.h>
+#include <openssl/hmac.h>
+#include <openssl/rand.h>
+#include <openssl/conf.h>
+#include <openssl/conf_api.h>
+#undef X509_NAME
+#undef PKCS7_SIGNER_INFO
+#if defined(HAVE_OPENSSL_ENGINE_H) && !defined(OPENSSL_NO_ENGINE)
+# define OSSL_ENGINE_ENABLED
+# include <openssl/engine.h>
+#endif
+#if defined(HAVE_OPENSSL_OCSP_H)
+# define OSSL_OCSP_ENABLED
+# include <openssl/ocsp.h>
+#endif
+#if defined(_WIN32)
+# undef OpenFile
+#endif
+
+/*
+ * OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!
+ */
+#if defined(RFILE) /*&& !defined(OSSL_DEBUG)*/
+# undef RFILE
+#endif
+#include <ruby.h>
+#include <rubyio.h>
+
+/*
+ * Common Module
+ */
+extern VALUE mOSSL;
+
+/*
+ * Common Error Class
+ */
+extern VALUE eOSSLError;
+
+/*
+ * CheckTypes
+ */
+#define OSSL_Check_Kind(obj, klass) do {\
+ if (!rb_obj_is_kind_of(obj, klass)) {\
+ ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\
+ rb_obj_classname(obj), rb_class2name(klass));\
+ }\
+} while (0)
+
+#define OSSL_Check_Instance(obj, klass) do {\
+ if (!rb_obj_is_instance_of(obj, klass)) {\
+ ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\
+ rb_obj_classname(obj), rb_class2name(klass));\
+ }\
+} while (0)
+
+#define OSSL_Check_Same_Class(obj1, obj2) do {\
+ if (!rb_obj_is_instance_of(obj1, rb_obj_class(obj2))) {\
+ ossl_raise(rb_eTypeError, "wrong argument type");\
+ }\
+} while (0)
+
+/*
+ * String to HEXString conversion
+ */
+int string2hex(char *, int, char **, int *);
+
+/*
+ * Data Conversion
+ */
+STACK_OF(X509) *ossl_x509_ary2sk0(VALUE);
+STACK_OF(X509) *ossl_x509_ary2sk(VALUE);
+STACK_OF(X509) *ossl_protect_x509_ary2sk(VALUE,int*);
+VALUE ossl_x509_sk2ary(STACK_OF(X509) *certs);
+VALUE ossl_x509crl_sk2ary(STACK_OF(X509_CRL) *crl);
+VALUE ossl_buf2str(char *buf, int len);
+#define ossl_str_adjust(str, p) \
+do{\
+ int len = RSTRING(str)->len;\
+ int newlen = (p) - (unsigned char*)RSTRING(str)->ptr;\
+ assert(newlen <= len);\
+ RSTRING(str)->len = newlen;\
+ RSTRING(str)->ptr[newlen] = 0;\
+}while(0)
+
+/*
+ * our default PEM callback
+ */
+int ossl_pem_passwd_cb(char *, int, int, void *);
+
+/*
+ * ERRor messages
+ */
+#define OSSL_ErrMsg() ERR_reason_error_string(ERR_get_error())
+NORETURN(void ossl_raise(VALUE, const char *, ...));
+
+/*
+ * Verify callback
+ */
+extern int ossl_verify_cb_idx;
+
+struct ossl_verify_cb_args {
+ VALUE proc;
+ VALUE preverify_ok;
+ VALUE store_ctx;
+};
+
+VALUE ossl_call_verify_cb_proc(struct ossl_verify_cb_args *);
+int ossl_verify_cb(int, X509_STORE_CTX *);
+
+/*
+ * String to DER String
+ */
+extern ID ossl_s_to_der;
+VALUE ossl_to_der(VALUE);
+VALUE ossl_to_der_if_possible(VALUE);
+
+/*
+ * Debug
+ */
+extern VALUE dOSSL;
+
+#if defined(HAVE_VA_ARGS_MACRO)
+#define OSSL_Debug(fmt, ...) do { \
+ if (dOSSL == Qtrue) { \
+ fprintf(stderr, "OSSL_DEBUG: "); \
+ fprintf(stderr, fmt, ##__VA_ARGS__); \
+ fprintf(stderr, " [in %s (%s:%d)]\n", __func__, __FILE__, __LINE__); \
+ } \
+} while (0)
+
+#define OSSL_Warning(fmt, ...) do { \
+ OSSL_Debug(fmt, ##__VA_ARGS__); \
+ rb_warning(fmt, ##__VA_ARGS__); \
+} while (0)
+
+#define OSSL_Warn(fmt, ...) do { \
+ OSSL_Debug(fmt, ##__VA_ARGS__); \
+ rb_warn(fmt, ##__VA_ARGS__); \
+} while (0)
+#else
+void ossl_debug(const char *, ...);
+#define OSSL_Debug ossl_debug
+#define OSSL_Warning rb_warning
+#define OSSL_Warn rb_warn
+#endif
+
+/*
+ * Include all parts
+ */
+#include "openssl_missing.h"
+#include "ruby_missing.h"
+#include "ossl_asn1.h"
+#include "ossl_bio.h"
+#include "ossl_bn.h"
+#include "ossl_cipher.h"
+#include "ossl_config.h"
+#include "ossl_digest.h"
+#include "ossl_hmac.h"
+#include "ossl_ns_spki.h"
+#include "ossl_ocsp.h"
+#include "ossl_pkcs12.h"
+#include "ossl_pkcs7.h"
+#include "ossl_pkey.h"
+#include "ossl_rand.h"
+#include "ossl_ssl.h"
+#include "ossl_version.h"
+#include "ossl_x509.h"
+#include "ossl_engine.h"
+
+void Init_openssl(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _OSSL_H_ */
+
diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c
new file mode 100644
index 0000000000..a961c16bc0
--- /dev/null
+++ b/ext/openssl/ossl_asn1.c
@@ -0,0 +1,1156 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#if defined(HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#elif !defined(NT) && !defined(_WIN32)
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+#endif
+
+/*
+ * DATE conversion
+ */
+VALUE
+asn1time_to_time(ASN1_TIME *time)
+{
+ struct tm tm;
+ VALUE argv[6];
+
+ if (!time || !time->data) return Qnil;
+ memset(&tm, 0, sizeof(struct tm));
+
+ switch (time->type) {
+ case V_ASN1_UTCTIME:
+ if (sscanf(time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
+ &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ ossl_raise(rb_eTypeError, "bad UTCTIME format");
+ }
+ if (tm.tm_year < 69) {
+ tm.tm_year += 2000;
+ } else {
+ tm.tm_year += 1900;
+ }
+ tm.tm_mon -= 1;
+ break;
+ case V_ASN1_GENERALIZEDTIME:
+ if (sscanf(time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
+ &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format" );
+ }
+ tm.tm_mon -= 1;
+ break;
+ default:
+ rb_warning("unknown time format");
+ return Qnil;
+ }
+ argv[0] = INT2NUM(tm.tm_year);
+ argv[1] = INT2NUM(tm.tm_mon+1);
+ argv[2] = INT2NUM(tm.tm_mday);
+ argv[3] = INT2NUM(tm.tm_hour);
+ argv[4] = INT2NUM(tm.tm_min);
+ argv[5] = INT2NUM(tm.tm_sec);
+
+ return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
+}
+
+/*
+ * This function is not exported in Ruby's *.h
+ */
+extern struct timeval rb_time_timeval(VALUE);
+
+time_t
+time_to_time_t(VALUE time)
+{
+ return (time_t)NUM2LONG(rb_Integer(time));
+}
+
+/*
+ * ASN1_INTEGER conversions
+ * TODO: Make a decision what's the right way to do this.
+ */
+#define DO_IT_VIA_RUBY 0
+VALUE
+asn1integer_to_num(ASN1_INTEGER *ai)
+{
+ BIGNUM *bn;
+#if DO_IT_VIA_RUBY
+ char *txt;
+#endif
+ VALUE num;
+
+ if (!ai) {
+ ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
+ }
+ if (!(bn = ASN1_INTEGER_to_BN(ai, NULL))) {
+ ossl_raise(eOSSLError, NULL);
+ }
+#if DO_IT_VIA_RUBY
+ if (!(txt = BN_bn2dec(bn))) {
+ BN_free(bn);
+ ossl_raise(eOSSLError, NULL);
+ }
+ num = rb_cstr_to_inum(txt, 10, Qtrue);
+ OPENSSL_free(txt);
+#else
+ num = ossl_bn_new(bn);
+#endif
+ BN_free(bn);
+
+ return num;
+}
+
+#if DO_IT_VIA_RUBY
+ASN1_INTEGER *
+num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
+{
+ BIGNUM *bn = NULL;
+
+ if (RTEST(rb_obj_is_kind_of(obj, cBN))) {
+ bn = GetBNPtr(obj);
+ } else {
+ obj = rb_String(obj);
+ if (!BN_dec2bn(&bn, StringValuePtr(obj))) {
+ ossl_raise(eOSSLError, NULL);
+ }
+ }
+ if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
+ BN_free(bn);
+ ossl_raise(eOSSLError, NULL);
+ }
+ BN_free(bn);
+ return ai;
+}
+#else
+ASN1_INTEGER *
+num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
+{
+ BIGNUM *bn = GetBNPtr(obj);
+
+ if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
+ ossl_raise(eOSSLError, NULL);
+ }
+ return ai;
+}
+#endif
+
+/********/
+/*
+ * ASN1 module
+ */
+#define ossl_asn1_get_value(o) rb_attr_get((o),rb_intern("@value"))
+#define ossl_asn1_get_tag(o) rb_attr_get((o),rb_intern("@tag"))
+#define ossl_asn1_get_tagging(o) rb_attr_get((o),rb_intern("@tagging"))
+#define ossl_asn1_get_tag_class(o) rb_attr_get((o),rb_intern("@tag_class"))
+
+#define ossl_asn1_set_value(o,v) rb_iv_set((o),"@value",(v))
+#define ossl_asn1_set_tag(o,v) rb_iv_set((o),"@tag",(v))
+#define ossl_asn1_set_tagging(o,v) rb_iv_set((o),"@tagging",(v))
+#define ossl_asn1_set_tag_class(o,v) rb_iv_set((o),"@tag_class",(v))
+
+VALUE mASN1;
+VALUE eASN1Error;
+
+VALUE cASN1Data;
+VALUE cASN1Primitive;
+VALUE cASN1Constructive;
+
+VALUE cASN1Boolean; /* BOOLEAN */
+VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
+VALUE cASN1BitString; /* BIT STRING */
+VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
+VALUE cASN1NumericString, cASN1PrintableString;
+VALUE cASN1T61String, cASN1VideotexString;
+VALUE cASN1IA5String, cASN1GraphicString;
+VALUE cASN1ISO64String, cASN1GeneralString;
+VALUE cASN1UniversalString, cASN1BMPString;
+VALUE cASN1Null; /* NULL */
+VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
+VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
+VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
+
+static ID sIMPLICIT, sEXPLICIT;
+static ID sUNIVERSAL, sAPPLICATION, sCONTEXT_SPECIFIC, sPRIVATE;
+
+/*
+ * Ruby to ASN1 converters
+ */
+static ASN1_BOOLEAN
+obj_to_asn1bool(VALUE obj)
+{
+ return RTEST(obj) ? 0xff : 0x100;
+}
+
+static ASN1_INTEGER*
+obj_to_asn1int(VALUE obj)
+{
+ return num_to_asn1integer(obj, NULL);
+}
+
+static ASN1_BIT_STRING*
+obj_to_asn1bstr(VALUE obj, long unused_bits)
+{
+ ASN1_BIT_STRING *bstr;
+
+ if(unused_bits < 0) unused_bits = 0;
+ StringValue(obj);
+ if(!(bstr = ASN1_BIT_STRING_new()))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_BIT_STRING_set(bstr, RSTRING(obj)->ptr, RSTRING(obj)->len);
+ bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
+ bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT|(unused_bits&0x07);
+
+ return bstr;
+}
+
+static ASN1_STRING*
+obj_to_asn1str(VALUE obj)
+{
+ ASN1_STRING *str;
+
+ StringValue(obj);
+ if(!(str = ASN1_STRING_new()))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_STRING_set(str, RSTRING(obj)->ptr, RSTRING(obj)->len);
+
+ return str;
+}
+
+static ASN1_NULL*
+obj_to_asn1null(VALUE obj)
+{
+ ASN1_NULL *null;
+
+ if(!NIL_P(obj))
+ ossl_raise(eASN1Error, "nil expected");
+ if(!(null = ASN1_NULL_new()))
+ ossl_raise(eASN1Error, NULL);
+
+ return null;
+}
+
+static ASN1_OBJECT*
+obj_to_asn1obj(VALUE obj)
+{
+ ASN1_OBJECT *a1obj;
+
+ StringValue(obj);
+ a1obj = OBJ_txt2obj(RSTRING(obj)->ptr, 0);
+ if(!a1obj) a1obj = OBJ_txt2obj(RSTRING(obj)->ptr, 1);
+ if(!a1obj) ossl_raise(eASN1Error, "invalid OBJECT ID");
+
+ return a1obj;
+}
+
+static ASN1_UTCTIME*
+obj_to_asn1utime(VALUE time)
+{
+ time_t sec;
+ ASN1_UTCTIME *t;
+
+ sec = time_to_time_t(time);
+ if(!(t = ASN1_UTCTIME_set(NULL, sec)))
+ ossl_raise(eASN1Error, NULL);
+
+ return t;
+}
+
+static ASN1_GENERALIZEDTIME*
+obj_to_asn1gtime(VALUE time)
+{
+ time_t sec;
+ ASN1_GENERALIZEDTIME *t;
+
+ sec = time_to_time_t(time);
+ if(!(t =ASN1_GENERALIZEDTIME_set(NULL, sec)))
+ ossl_raise(eASN1Error, NULL);
+
+ return t;
+}
+
+static ASN1_STRING*
+obj_to_asn1derstr(VALUE obj)
+{
+ ASN1_STRING *a1str;
+ VALUE str;
+
+ str = ossl_to_der(obj);
+ if(!(a1str = ASN1_STRING_new()))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_STRING_set(a1str, RSTRING(str)->ptr, RSTRING(str)->len);
+
+ return a1str;
+}
+
+/*
+ * DER to Ruby converters
+ */
+static VALUE
+decode_bool(unsigned char* der, int length)
+{
+ int bool;
+ unsigned char *p;
+
+ p = der;
+ if((bool = d2i_ASN1_BOOLEAN(NULL, &p, length)) < 0)
+ ossl_raise(eASN1Error, NULL);
+
+ return bool ? Qtrue : Qfalse;
+}
+
+static VALUE
+decode_int(unsigned char* der, int length)
+{
+ ASN1_INTEGER *ai;
+ unsigned char *p;
+ VALUE ret;
+ int status = 0;
+
+ p = der;
+ if(!(ai = d2i_ASN1_INTEGER(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ret = rb_protect((VALUE(*)_((VALUE)))asn1integer_to_num,
+ (VALUE)ai, &status);
+ ASN1_INTEGER_free(ai);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
+
+static VALUE
+decode_bstr(unsigned char* der, int length, long *unused_bits)
+{
+ ASN1_BIT_STRING *bstr;
+ unsigned char *p, *buf;
+ long len;
+ VALUE ret;
+
+ p = der;
+ if(!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ len = bstr->length;
+ if(!(buf = OPENSSL_malloc(len))){
+ ASN1_BIT_STRING_free(bstr);
+ ossl_raise(eASN1Error, NULL);
+ }
+ *unused_bits = 0;
+ if(bstr->flags & ASN1_STRING_FLAG_BITS_LEFT)
+ *unused_bits = bstr->flags & 0x07;
+ memcpy(buf, bstr->data, len);
+ ASN1_BIT_STRING_free(bstr);
+ ret = ossl_buf2str(buf, len);
+
+ return ret;
+}
+
+static VALUE
+decode_enum(unsigned char* der, int length)
+{
+ ASN1_ENUMERATED *ai;
+ unsigned char *p;
+ VALUE ret;
+ int status = 0;
+
+ p = der;
+ if(!(ai = d2i_ASN1_ENUMERATED(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ret = rb_protect((VALUE(*)_((VALUE)))asn1integer_to_num,
+ (VALUE)ai, &status);
+ ASN1_ENUMERATED_free(ai);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
+
+static VALUE
+decode_null(unsigned char* der, int length)
+{
+ ASN1_NULL *null;
+ unsigned char *p;
+
+ p = der;
+ if(!(null = d2i_ASN1_NULL(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_NULL_free(null);
+
+ return Qnil;
+}
+
+static VALUE
+decode_obj(unsigned char* der, int length)
+{
+ ASN1_OBJECT *obj;
+ unsigned char *p;
+ VALUE ret;
+ int nid;
+ BIO *bio;
+
+ p = der;
+ if(!(obj = d2i_ASN1_OBJECT(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ if((nid = OBJ_obj2nid(obj)) != NID_undef){
+ ASN1_OBJECT_free(obj);
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+ }
+ else{
+ if(!(bio = BIO_new(BIO_s_mem()))){
+ ASN1_OBJECT_free(obj);
+ ossl_raise(eASN1Error, NULL);
+ }
+ i2a_ASN1_OBJECT(bio, obj);
+ ASN1_OBJECT_free(obj);
+ ret = ossl_membio2str(bio);
+ }
+
+ return ret;
+}
+
+static VALUE
+decode_time(unsigned char* der, int length)
+{
+ ASN1_TIME *time;
+ unsigned char *p;
+ VALUE ret;
+ int status = 0;
+
+ p = der;
+ if(!(time = d2i_ASN1_TIME(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ret = rb_protect((VALUE(*)_((VALUE)))asn1time_to_time,
+ (VALUE)time, &status);
+ ASN1_TIME_free(time);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
+
+/********/
+
+typedef struct {
+ char *name;
+ VALUE *klass;
+} ossl_asn1_info_t;
+
+static ossl_asn1_info_t ossl_asn1_info[] = {
+ { "EOC", NULL, }, /* 0 */
+ { "BOOLEAN", &cASN1Boolean, }, /* 1 */
+ { "INTEGER", &cASN1Integer, }, /* 2 */
+ { "BIT_STRING", &cASN1BitString, }, /* 3 */
+ { "OCTET_STRING", &cASN1OctetString, }, /* 4 */
+ { "NULL", &cASN1Null, }, /* 5 */
+ { "OBJECT", &cASN1ObjectId, }, /* 6 */
+ { "OBJECT_DESCRIPTOR", NULL, }, /* 7 */
+ { "EXTERNAL", NULL, }, /* 8 */
+ { "REAL", NULL, }, /* 9 */
+ { "ENUMERATED", &cASN1Enumerated, }, /* 10 */
+ { "EMBEDDED_PDV", NULL, }, /* 11 */
+ { "UTF8STRING", &cASN1UTF8String, }, /* 12 */
+ { "RELATIVE_OID", NULL, }, /* 13 */
+ { "[UNIVERSAL 14]", NULL, }, /* 14 */
+ { "[UNIVERSAL 15]", NULL, }, /* 15 */
+ { "SEQUENCE", &cASN1Sequence, }, /* 16 */
+ { "SET", &cASN1Set, }, /* 17 */
+ { "NUMERICSTRING", &cASN1NumericString, }, /* 18 */
+ { "PRINTABLESTRING", &cASN1PrintableString, }, /* 19 */
+ { "T61STRING", &cASN1T61String, }, /* 20 */
+ { "VIDEOTEXSTRING", &cASN1VideotexString, }, /* 21 */
+ { "IA5STRING", &cASN1IA5String, }, /* 22 */
+ { "UTCTIME", &cASN1UTCTime, }, /* 23 */
+ { "GENERALIZEDTIME", &cASN1GeneralizedTime, }, /* 24 */
+ { "GRAPHICSTRING", &cASN1GraphicString, }, /* 25 */
+ { "ISO64STRING", &cASN1ISO64String, }, /* 26 */
+ { "GENERALSTRING", &cASN1GeneralString, }, /* 27 */
+ { "UNIVERSALSTRING", &cASN1UniversalString, }, /* 28 */
+ { "CHARACTER_STRING", NULL, }, /* 29 */
+ { "BMPSTRING", &cASN1BMPString, }, /* 30 */
+};
+
+int ossl_asn1_info_size = (sizeof(ossl_asn1_info)/sizeof(ossl_asn1_info[0]));
+
+static int ossl_asn1_default_tag(VALUE obj);
+
+ASN1_TYPE*
+ossl_asn1_get_asn1type(VALUE obj)
+{
+ ASN1_TYPE *ret;
+ VALUE value, rflag;
+ void *ptr;
+ void (*free_func)();
+ long tag, flag;
+
+ tag = ossl_asn1_default_tag(obj);
+ value = ossl_asn1_get_value(obj);
+ switch(tag){
+ case V_ASN1_BOOLEAN:
+ ptr = (void*)obj_to_asn1bool(value);
+ free_func = NULL;
+ break;
+ case V_ASN1_INTEGER: /* FALLTHROUGH */
+ case V_ASN1_ENUMERATED:
+ ptr = obj_to_asn1int(value);
+ free_func = ASN1_INTEGER_free;
+ break;
+ case V_ASN1_BIT_STRING:
+ rflag = rb_attr_get(obj, rb_intern("@unused_bits"));
+ flag = NIL_P(rflag) ? -1 : NUM2INT(rflag);
+ ptr = obj_to_asn1bstr(value, flag);
+ free_func = ASN1_BIT_STRING_free;
+ break;
+ case V_ASN1_NULL:
+ ptr = obj_to_asn1null(value);
+ free_func = ASN1_NULL_free;
+ break;
+ case V_ASN1_OCTET_STRING: /* FALLTHROUGH */
+ case V_ASN1_UTF8STRING: /* FALLTHROUGH */
+ case V_ASN1_NUMERICSTRING: /* FALLTHROUGH */
+ case V_ASN1_PRINTABLESTRING: /* FALLTHROUGH */
+ case V_ASN1_T61STRING: /* FALLTHROUGH */
+ case V_ASN1_VIDEOTEXSTRING: /* FALLTHROUGH */
+ case V_ASN1_IA5STRING: /* FALLTHROUGH */
+ case V_ASN1_GRAPHICSTRING: /* FALLTHROUGH */
+ case V_ASN1_ISO64STRING: /* FALLTHROUGH */
+ case V_ASN1_GENERALSTRING: /* FALLTHROUGH */
+ case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */
+ case V_ASN1_BMPSTRING:
+ ptr = obj_to_asn1str(value);
+ free_func = ASN1_STRING_free;
+ break;
+ case V_ASN1_OBJECT:
+ ptr = obj_to_asn1obj(value);
+ free_func = ASN1_OBJECT_free;
+ break;
+ case V_ASN1_UTCTIME:
+ ptr = obj_to_asn1utime(value);
+ free_func = ASN1_TIME_free;
+ break;
+ case V_ASN1_GENERALIZEDTIME:
+ ptr = obj_to_asn1gtime(value);
+ free_func = ASN1_TIME_free;
+ break;
+ case V_ASN1_SET: /* FALLTHROUGH */
+ case V_ASN1_SEQUENCE:
+ ptr = obj_to_asn1derstr(obj);
+ free_func = ASN1_STRING_free;
+ break;
+ default:
+ ossl_raise(eASN1Error, "unsupported ASN.1 type");
+ }
+ if(!(ret = OPENSSL_malloc(sizeof(ASN1_TYPE)))){
+ if(free_func) free_func(ptr);
+ ossl_raise(eASN1Error, "ASN1_TYPE alloc failure");
+ }
+ memset(ret, 0, sizeof(ASN1_TYPE));
+ ASN1_TYPE_set(ret, tag, ptr);
+
+ return ret;
+}
+
+static int
+ossl_asn1_default_tag(VALUE obj)
+{
+ int i;
+
+ for(i = 0; i < ossl_asn1_info_size; i++){
+ if(ossl_asn1_info[i].klass &&
+ rb_obj_is_kind_of(obj, *ossl_asn1_info[i].klass)){
+ return i;
+ }
+ }
+ ossl_raise(eASN1Error, "universal tag for %s not found",
+ rb_class2name(CLASS_OF(obj)));
+
+ return -1; /* dummy */
+}
+
+static int
+ossl_asn1_tag(VALUE obj)
+{
+ VALUE tag;
+
+ tag = ossl_asn1_get_tag(obj);
+ if(NIL_P(tag))
+ ossl_raise(eASN1Error, "tag number not specified");
+
+ return NUM2INT(tag);
+}
+
+static int
+ossl_asn1_is_explicit(VALUE obj)
+{
+ VALUE s;
+ int ret = -1;
+
+ s = ossl_asn1_get_tagging(obj);
+ if(NIL_P(s)) return 0;
+ else if(SYMBOL_P(s)){
+ if (SYM2ID(s) == sIMPLICIT)
+ ret = 0;
+ else if (SYM2ID(s) == sEXPLICIT)
+ ret = 1;
+ }
+ if(ret < 0){
+ ossl_raise(eASN1Error, "invalid tag default");
+ }
+
+ return ret;
+}
+
+static int
+ossl_asn1_tag_class(VALUE obj)
+{
+ VALUE s;
+ int ret = -1;
+
+ s = ossl_asn1_get_tag_class(obj);
+ if(NIL_P(s)) ret = V_ASN1_UNIVERSAL;
+ else if(SYMBOL_P(s)){
+ if (SYM2ID(s) == sUNIVERSAL)
+ ret = V_ASN1_UNIVERSAL;
+ else if (SYM2ID(s) == sAPPLICATION)
+ ret = V_ASN1_APPLICATION;
+ else if (SYM2ID(s) == sCONTEXT_SPECIFIC)
+ ret = V_ASN1_CONTEXT_SPECIFIC;
+ else if (SYM2ID(s) == sPRIVATE)
+ ret = V_ASN1_PRIVATE;
+ }
+ if(ret < 0){
+ ossl_raise(eASN1Error, "invalid tag class");
+ }
+
+ return ret;
+}
+
+static VALUE
+ossl_asn1_class2sym(int tc)
+{
+ if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
+ return ID2SYM(sPRIVATE);
+ else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
+ return ID2SYM(sCONTEXT_SPECIFIC);
+ else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
+ return ID2SYM(sAPPLICATION);
+ else
+ return ID2SYM(sUNIVERSAL);
+}
+
+static VALUE
+ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
+{
+ if(!SYMBOL_P(tag_class))
+ ossl_raise(eASN1Error, "invalid tag class");
+ if((SYM2ID(tag_class) == sUNIVERSAL) && NUM2INT(tag) > 31)
+ ossl_raise(eASN1Error, "tag number for Universal too large");
+ ossl_asn1_set_tag(self, tag);
+ ossl_asn1_set_value(self, value);
+ ossl_asn1_set_tag_class(self, tag_class);
+
+ return self;
+}
+
+static VALUE
+join_der_i(VALUE i, VALUE str)
+{
+ i = ossl_to_der_if_possible(i);
+ StringValue(i);
+ rb_str_append(str, i);
+ return Qnil;
+}
+
+static VALUE
+join_der(VALUE enumerable)
+{
+ VALUE str = rb_str_new(0, 0);
+ rb_iterate(rb_each, enumerable, join_der_i, str);
+ return str;
+}
+
+static VALUE
+ossl_asn1data_to_der(VALUE self)
+{
+ VALUE value, der;
+ int tag, tag_class, is_cons = 0;
+ long length;
+ unsigned char *p;
+
+ value = ossl_asn1_get_value(self);
+ if(rb_obj_is_kind_of(value, rb_cArray)){
+ is_cons = 1;
+ value = join_der(value);
+ }
+ StringValue(value);
+
+ tag = ossl_asn1_tag(self);
+ tag_class = ossl_asn1_tag_class(self);
+ if((length = ASN1_object_size(1, RSTRING(value)->len, tag)) <= 0)
+ ossl_raise(eASN1Error, NULL);
+ der = rb_str_new(0, length);
+ p = RSTRING(der)->ptr;
+ ASN1_put_object(&p, is_cons, RSTRING(value)->len, tag, tag_class);
+ memcpy(p, RSTRING(value)->ptr, RSTRING(value)->len);
+ p += RSTRING(value)->len;
+ ossl_str_adjust(der, p);
+
+ return der;
+}
+
+static VALUE
+ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
+ int once, int yield)
+{
+ unsigned char *start, *p;
+ long len, off = *offset;
+ int hlen, tag, tc, j;
+ VALUE ary, asn1data, value, tag_class;
+
+ ary = rb_ary_new();
+ p = *pp;
+ while(length > 0){
+ start = p;
+ j = ASN1_get_object(&p, &len, &tag, &tc, length);
+ if(j & 0x80) ossl_raise(eASN1Error, NULL);
+ hlen = p - start;
+ if(yield){
+ VALUE arg = rb_ary_new();
+ rb_ary_push(arg, LONG2NUM(depth));
+ rb_ary_push(arg, LONG2NUM(off));
+ rb_ary_push(arg, LONG2NUM(hlen));
+ rb_ary_push(arg, LONG2NUM(len));
+ rb_ary_push(arg, (j & V_ASN1_CONSTRUCTED) ? Qtrue : Qfalse);
+ rb_ary_push(arg, ossl_asn1_class2sym(tc));
+ rb_ary_push(arg, INT2NUM(tag));
+ rb_yield(arg);
+ }
+ length -= hlen;
+ off += hlen;
+ if(len > length) ossl_raise(eASN1Error, "value is too short");
+ if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
+ tag_class = sPRIVATE;
+ else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
+ tag_class = sCONTEXT_SPECIFIC;
+ else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
+ tag_class = sAPPLICATION;
+ else
+ tag_class = sUNIVERSAL;
+ if(j & V_ASN1_CONSTRUCTED){
+ /* TODO: if j == 0x21 it is indefinite length object. */
+ if((j == 0x21) && (len == 0)){
+ long lastoff = off;
+ value = ossl_asn1_decode0(&p, length, &off, depth+1, 0, yield);
+ len = off - lastoff;
+ }
+ else value = ossl_asn1_decode0(&p, len, &off, depth+1, 0, yield);
+ }
+ else{
+ value = rb_str_new(p, len);
+ p += len;
+ off += len;
+ }
+ if(tag_class == sUNIVERSAL &&
+ tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass){
+ VALUE klass = *ossl_asn1_info[tag].klass;
+ long flag;
+ if(!rb_obj_is_kind_of(value, rb_cArray)){
+ switch(tag){
+ case V_ASN1_BOOLEAN:
+ value = decode_bool(start, hlen+len);
+ break;
+ case V_ASN1_INTEGER:
+ value = decode_int(start, hlen+len);
+ break;
+ case V_ASN1_BIT_STRING:
+ value = decode_bstr(start, hlen+len, &flag);
+ break;
+ case V_ASN1_NULL:
+ value = decode_null(start, hlen+len);
+ break;
+ case V_ASN1_ENUMERATED:
+ value = decode_enum(start, hlen+len);
+ break;
+ case V_ASN1_OBJECT:
+ value = decode_obj(start, hlen+len);
+ break;
+ case V_ASN1_UTCTIME: /* FALLTHROUGH */
+ case V_ASN1_GENERALIZEDTIME:
+ value = decode_time(start, hlen+len);
+ break;
+ default:
+ /* use original value */
+ break;
+ }
+ }
+ asn1data = rb_funcall(klass, rb_intern("new"), 1, value);
+ if(tag == V_ASN1_BIT_STRING){
+ rb_iv_set(asn1data, "@unused_bits", LONG2NUM(flag));
+ }
+ }
+ else{
+ asn1data = rb_funcall(cASN1Data, rb_intern("new"), 3,
+ value, INT2NUM(tag), ID2SYM(tag_class));
+ }
+ rb_ary_push(ary, asn1data);
+ length -= len;
+ if(once) break;
+ }
+ *pp = p;
+ *offset = off;
+
+ return ary;
+}
+
+static VALUE
+ossl_asn1_traverse(VALUE self, VALUE obj)
+{
+ unsigned char *p;
+ long offset = 0;
+
+ obj = ossl_to_der_if_possible(obj);
+ StringValue(obj);
+ p = RSTRING(obj)->ptr;
+ ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 0, 1);
+
+ return obj;
+}
+
+static VALUE
+ossl_asn1_decode(VALUE self, VALUE obj)
+{
+ VALUE ret, ary;
+ unsigned char *p;
+ long offset = 0;
+
+ obj = ossl_to_der_if_possible(obj);
+ StringValue(obj);
+ p = RSTRING(obj)->ptr;
+ ary = ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 1, 0);
+ ret = rb_ary_entry(ary, 0);
+
+ return ret;
+}
+
+static VALUE
+ossl_asn1_decode_all(VALUE self, VALUE obj)
+{
+ VALUE ret;
+ unsigned char *p;
+ long offset = 0;
+
+ obj = ossl_to_der_if_possible(obj);
+ StringValue(obj);
+ p = RSTRING(obj)->ptr;
+ ret = ossl_asn1_decode0(&p, RSTRING(obj)->len, &offset, 0, 0, 0);
+
+ return ret;
+}
+
+static VALUE
+ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE value, tag, tagging, tag_class;
+
+ rb_scan_args(argc, argv, "13", &value, &tag, &tagging, &tag_class);
+ if(argc > 1){
+ if(NIL_P(tag))
+ ossl_raise(eASN1Error, "must specify tag number");
+ if(NIL_P(tagging))
+ tagging = ID2SYM(sEXPLICIT);
+ if(!SYMBOL_P(tagging))
+ ossl_raise(eASN1Error, "invalid tag default");
+ if(NIL_P(tag_class))
+ tag_class = ID2SYM(sCONTEXT_SPECIFIC);
+ if(!SYMBOL_P(tag_class))
+ ossl_raise(eASN1Error, "invalid tag class");
+ if(SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31)
+ ossl_raise(eASN1Error, "tag number for Universal too large");
+ }
+ else{
+ tag = INT2NUM(ossl_asn1_default_tag(self));
+ tagging = Qnil;
+ tag_class = ID2SYM(sUNIVERSAL);
+ }
+ ossl_asn1_set_tag(self, tag);
+ ossl_asn1_set_value(self, value);
+ ossl_asn1_set_tagging(self, tagging);
+ ossl_asn1_set_tag_class(self, tag_class);
+
+ return self;
+}
+
+static int
+ossl_i2d_ASN1_TYPE(ASN1_TYPE *a, unsigned char **pp)
+{
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ if(!a) return 0;
+ if(a->type == V_ASN1_BOOLEAN)
+ return i2d_ASN1_BOOLEAN(a->value.boolean, pp);
+#endif
+ return i2d_ASN1_TYPE(a, pp);
+}
+
+static void
+ossl_ASN1_TYPE_free(ASN1_TYPE *a)
+{
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ if(!a) return;
+ if(a->type == V_ASN1_BOOLEAN){
+ OPENSSL_free(a);
+ return;
+ }
+#endif
+ ASN1_TYPE_free(a);
+}
+
+static VALUE
+ossl_asn1prim_to_der(VALUE self)
+{
+ ASN1_TYPE *asn1;
+ int tn, tc, explicit;
+ long length, reallen;
+ unsigned char *buf, *p;
+ VALUE str;
+
+ tn = NUM2INT(ossl_asn1_get_tag(self));
+ tc = ossl_asn1_tag_class(self);
+ explicit = ossl_asn1_is_explicit(self);
+ asn1 = ossl_asn1_get_asn1type(self);
+
+ length = ASN1_object_size(1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn);
+ if(!(buf = OPENSSL_malloc(length))){
+ ossl_ASN1_TYPE_free(asn1);
+ ossl_raise(eASN1Error, "cannot alloc buffer");
+ }
+ p = buf;
+ if(tc == V_ASN1_UNIVERSAL) ossl_i2d_ASN1_TYPE(asn1, &p);
+ else{
+ if(explicit){
+ ASN1_put_object(&p, 1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn, tc);
+ ossl_i2d_ASN1_TYPE(asn1, &p);
+ }
+ else{
+ ossl_i2d_ASN1_TYPE(asn1, &p);
+ *buf = tc | tn | (*buf & V_ASN1_CONSTRUCTED);
+ }
+ }
+ ossl_ASN1_TYPE_free(asn1);
+ reallen = p - buf;
+ assert(reallen <= length);
+ str = ossl_buf2str(buf, reallen); /* buf will be free in ossl_buf2str */
+
+ return str;
+}
+
+static VALUE
+ossl_asn1cons_to_der(VALUE self)
+{
+ int tag, tn, tc, explicit;
+ long seq_len, length;
+ unsigned char *p;
+ VALUE value, str;
+
+ tag = ossl_asn1_default_tag(self);
+ tn = NUM2INT(ossl_asn1_get_tag(self));
+ tc = ossl_asn1_tag_class(self);
+ explicit = ossl_asn1_is_explicit(self);
+ value = join_der(ossl_asn1_get_value(self));
+
+ seq_len = ASN1_object_size(1, RSTRING(value)->len, tag);
+ length = ASN1_object_size(1, seq_len, tn);
+ str = rb_str_new(0, length);
+ p = RSTRING(str)->ptr;
+ if(tc == V_ASN1_UNIVERSAL)
+ ASN1_put_object(&p, 1, RSTRING(value)->len, tn, tc);
+ else{
+ if(explicit){
+ ASN1_put_object(&p, 1, seq_len, tn, tc);
+ ASN1_put_object(&p, 1, RSTRING(value)->len, tag, V_ASN1_UNIVERSAL);
+ }
+ else ASN1_put_object(&p, 1, RSTRING(value)->len, tn, tc);
+ }
+ memcpy(p, RSTRING(value)->ptr, RSTRING(value)->len);
+ p += RSTRING(value)->len;
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+static VALUE
+ossl_asn1cons_each(VALUE self)
+{
+ rb_ary_each(ossl_asn1_get_value(self));
+ return self;
+}
+
+static VALUE
+ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
+{
+ StringValue(oid);
+ StringValue(sn);
+ StringValue(ln);
+
+ if(!OBJ_create(RSTRING(oid)->ptr, RSTRING(sn)->ptr, RSTRING(ln)->ptr))
+ ossl_raise(eASN1Error, NULL);
+
+ return Qtrue;
+}
+
+static VALUE
+ossl_asn1obj_get_sn(VALUE self)
+{
+ VALUE val, ret = Qnil;
+ int nid;
+
+ val = ossl_asn1_get_value(self);
+ if ((nid = OBJ_txt2nid(StringValuePtr(val))) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+
+ return ret;
+}
+
+static VALUE
+ossl_asn1obj_get_ln(VALUE self)
+{
+ VALUE val, ret = Qnil;
+ int nid;
+
+ val = ossl_asn1_get_value(self);
+ if ((nid = OBJ_txt2nid(StringValuePtr(val))) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2ln(nid));
+
+ return ret;
+}
+
+static VALUE
+ossl_asn1obj_get_oid(VALUE self)
+{
+ VALUE val;
+ ASN1_OBJECT *a1obj;
+ char buf[128];
+
+ val = ossl_asn1_get_value(self);
+ a1obj = obj_to_asn1obj(val);
+ OBJ_obj2txt(buf, sizeof(buf), a1obj, 1);
+ ASN1_OBJECT_free(a1obj);
+
+ return rb_str_new2(buf);
+}
+
+#define OSSL_ASN1_IMPL_FACTORY_METHOD(klass) \
+static VALUE ossl_asn1_##klass(int argc, VALUE *argv, VALUE self)\
+{ return rb_funcall3(cASN1##klass, rb_intern("new"), argc, argv); }
+
+OSSL_ASN1_IMPL_FACTORY_METHOD(Boolean)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Integer)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Enumerated)
+OSSL_ASN1_IMPL_FACTORY_METHOD(BitString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(OctetString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(UTF8String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(NumericString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(PrintableString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(T61String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(VideotexString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(IA5String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(GraphicString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(ISO64String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(GeneralString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(UniversalString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(BMPString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Null)
+OSSL_ASN1_IMPL_FACTORY_METHOD(ObjectId)
+OSSL_ASN1_IMPL_FACTORY_METHOD(UTCTime)
+OSSL_ASN1_IMPL_FACTORY_METHOD(GeneralizedTime)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Sequence)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Set)
+
+void
+Init_ossl_asn1()
+{
+ VALUE ary;
+ int i;
+
+ sUNIVERSAL = rb_intern("UNIVERSAL");
+ sCONTEXT_SPECIFIC = rb_intern("CONTEXT_SPECIFIC");
+ sAPPLICATION = rb_intern("APPLICATION");
+ sPRIVATE = rb_intern("PRIVATE");
+ sEXPLICIT = rb_intern("EXPLICIT");
+ sIMPLICIT = rb_intern("IMPLICIT");
+
+ mASN1 = rb_define_module_under(mOSSL, "ASN1");
+ eASN1Error = rb_define_class_under(mASN1, "ASN1Error", eOSSLError);
+ rb_define_module_function(mASN1, "traverse", ossl_asn1_traverse, 1);
+ rb_define_module_function(mASN1, "decode", ossl_asn1_decode, 1);
+ rb_define_module_function(mASN1, "decode_all", ossl_asn1_decode_all, 1);
+ ary = rb_ary_new();
+ rb_define_const(mASN1, "UNIVERSAL_TAG_NAME", ary);
+ for(i = 0; i < ossl_asn1_info_size; i++){
+ if(ossl_asn1_info[i].name[0] == '[') continue;
+ rb_define_const(mASN1, ossl_asn1_info[i].name, INT2NUM(i));
+ rb_ary_store(ary, i, rb_str_new2(ossl_asn1_info[i].name));
+ }
+
+ cASN1Data = rb_define_class_under(mASN1, "ASN1Data", rb_cObject);
+ rb_attr(cASN1Data, rb_intern("value"), 1, 1, Qtrue);
+ rb_attr(cASN1Data, rb_intern("tag"), 1, 1, Qtrue);
+ rb_attr(cASN1Data, rb_intern("tag_class"), 1, 1, Qtrue);
+ rb_define_method(cASN1Data, "initialize", ossl_asn1data_initialize, 3);
+ rb_define_method(cASN1Data, "to_der", ossl_asn1data_to_der, 0);
+
+ cASN1Primitive = rb_define_class_under(mASN1, "Primitive", cASN1Data);
+ rb_attr(cASN1Primitive, rb_intern("tagging"), 1, 1, Qtrue);
+ rb_define_method(cASN1Primitive, "initialize", ossl_asn1_initialize, -1);
+ rb_define_method(cASN1Primitive, "to_der", ossl_asn1prim_to_der, 0);
+
+ cASN1Constructive = rb_define_class_under(mASN1,"Constructive", cASN1Data);
+ rb_include_module(cASN1Constructive, rb_mEnumerable);
+ rb_attr(cASN1Constructive, rb_intern("tagging"), 1, 1, Qtrue);
+ rb_define_method(cASN1Constructive, "initialize", ossl_asn1_initialize, -1);
+ rb_define_method(cASN1Constructive, "to_der", ossl_asn1cons_to_der, 0);
+ rb_define_method(cASN1Constructive, "each", ossl_asn1cons_each, 0);
+
+#define OSSL_ASN1_DEFINE_CLASS(name, super) \
+do{\
+ cASN1##name = rb_define_class_under(mASN1, #name, cASN1##super);\
+ rb_define_module_function(mASN1, #name, ossl_asn1_##name, -1);\
+}while(0)
+
+ OSSL_ASN1_DEFINE_CLASS(Boolean, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(Integer, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(Enumerated, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(BitString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(OctetString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(UTF8String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(NumericString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(PrintableString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(T61String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(VideotexString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(IA5String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(GraphicString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(ISO64String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(GeneralString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(UniversalString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(BMPString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(Null, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(ObjectId, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(UTCTime, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(GeneralizedTime, Primitive);
+
+ OSSL_ASN1_DEFINE_CLASS(Sequence, Constructive);
+ OSSL_ASN1_DEFINE_CLASS(Set, Constructive);
+
+ rb_define_singleton_method(cASN1ObjectId, "register", ossl_asn1obj_s_register, 3);
+ rb_define_method(cASN1ObjectId, "sn", ossl_asn1obj_get_sn, 0);
+ rb_define_method(cASN1ObjectId, "ln", ossl_asn1obj_get_ln, 0);
+ rb_define_method(cASN1ObjectId, "oid", ossl_asn1obj_get_oid, 0);
+ rb_define_alias(cASN1ObjectId, "short_name", "sn");
+ rb_define_alias(cASN1ObjectId, "long_name", "ln");
+ rb_attr(cASN1BitString, rb_intern("unused_bits"), 1, 1, Qtrue);
+}
diff --git a/ext/openssl/ossl_asn1.h b/ext/openssl/ossl_asn1.h
new file mode 100644
index 0000000000..919ede0f3b
--- /dev/null
+++ b/ext/openssl/ossl_asn1.h
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_ASN1_H_)
+#define _OSSL_ASN1_H_
+
+/*
+ * ASN1_DATE conversions
+ */
+VALUE asn1time_to_time(ASN1_TIME *);
+time_t time_to_time_t(VALUE);
+
+/*
+ * ASN1_INTEGER conversions
+ */
+VALUE asn1integer_to_num(ASN1_INTEGER *);
+ASN1_INTEGER *num_to_asn1integer(VALUE, ASN1_INTEGER *);
+
+/*
+ * ASN1 module
+ */
+extern VALUE mASN1;
+extern VALUE eASN1Error;
+
+extern VALUE cASN1Data;
+extern VALUE cASN1Primitive;
+extern VALUE cASN1Constructive;
+
+extern VALUE cASN1Boolean; /* BOOLEAN */
+extern VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
+extern VALUE cASN1BitString; /* BIT STRING */
+extern VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
+extern VALUE cASN1NumericString, cASN1PrintableString;
+extern VALUE cASN1T61String, cASN1VideotexString;
+extern VALUE cASN1IA5String, cASN1GraphicString;
+extern VALUE cASN1ISO64String, cASN1GeneralString;
+extern VALUE cASN1UniversalString, cASN1BMPString;
+extern VALUE cASN1Null; /* NULL */
+extern VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
+extern VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
+extern VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
+
+ASN1_TYPE *ossl_asn1_get_asn1type(VALUE);
+
+void Init_ossl_asn1(void);
+
+#endif
diff --git a/ext/openssl/ossl_bio.c b/ext/openssl/ossl_bio.c
new file mode 100644
index 0000000000..8e80f412ee
--- /dev/null
+++ b/ext/openssl/ossl_bio.c
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+BIO *
+ossl_obj2bio(VALUE obj)
+{
+ BIO *bio;
+
+ if (TYPE(obj) == T_FILE) {
+ OpenFile *fptr;
+ GetOpenFile(obj, fptr);
+ rb_io_check_readable(fptr);
+ bio = BIO_new_fp(fptr->f, BIO_NOCLOSE);
+ }
+ else {
+ StringValue(obj);
+ bio = BIO_new_mem_buf(RSTRING(obj)->ptr, RSTRING(obj)->len);
+ }
+ if (!bio) ossl_raise(eOSSLError, NULL);
+
+ return bio;
+}
+
+BIO *
+ossl_protect_obj2bio(VALUE obj, int *status)
+{
+ BIO *ret = NULL;
+ ret = (BIO*)rb_protect((VALUE(*)_((VALUE)))ossl_obj2bio, obj, status);
+ return ret;
+}
+
+VALUE
+ossl_membio2str0(BIO *bio)
+{
+ VALUE ret;
+ BUF_MEM *buf;
+
+ BIO_get_mem_ptr(bio, &buf);
+ ret = rb_str_new(buf->data, buf->length);
+
+ return ret;
+}
+
+VALUE
+ossl_protect_membio2str(BIO *bio, int *status)
+{
+ return rb_protect((VALUE(*)_((VALUE)))ossl_membio2str0, (VALUE)bio, status);
+}
+
+VALUE
+ossl_membio2str(BIO *bio)
+{
+ VALUE ret;
+ int status = 0;
+
+ ret = ossl_protect_membio2str(bio, &status);
+ BIO_free(bio);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
diff --git a/ext/openssl/ossl_bio.h b/ext/openssl/ossl_bio.h
new file mode 100644
index 0000000000..2d8f675c5b
--- /dev/null
+++ b/ext/openssl/ossl_bio.h
@@ -0,0 +1,21 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_BIO_H_)
+#define _OSSL_BIO_H_
+
+BIO *ossl_obj2bio(VALUE);
+BIO *ossl_protect_obj2bio(VALUE,int*);
+VALUE ossl_membio2str0(BIO*);
+VALUE ossl_membio2str(BIO*);
+VALUE ossl_protect_membio2str(BIO*,int*);
+
+#endif
+
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
new file mode 100644
index 0000000000..c3a371a008
--- /dev/null
+++ b/ext/openssl/ossl_bn.c
@@ -0,0 +1,719 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Technorama team <oss-ruby@technorama.net>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+/* modified by Michal Rokos <m.rokos@sh.cvut.cz> */
+#include "ossl.h"
+
+#define WrapBN(klass, obj, bn) do { \
+ if (!bn) { \
+ ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, BN_clear_free, bn); \
+} while (0)
+
+#define GetBN(obj, bn) do { \
+ Data_Get_Struct(obj, BIGNUM, bn); \
+ if (!bn) { \
+ ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
+ } \
+} while (0)
+
+#define SafeGetBN(obj, bn) do { \
+ OSSL_Check_Kind(obj, cBN); \
+ GetBN(obj, bn); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cBN;
+VALUE eBNError;
+
+/*
+ * Public
+ */
+VALUE
+ossl_bn_new(BIGNUM *bn)
+{
+ BIGNUM *newbn;
+ VALUE obj;
+
+ newbn = bn ? BN_dup(bn) : BN_new();
+ if (!newbn) {
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(cBN, obj, newbn);
+
+ return obj;
+}
+
+BIGNUM *
+GetBNPtr(VALUE obj)
+{
+ BIGNUM *bn = NULL;
+
+ if (RTEST(rb_obj_is_kind_of(obj, cBN))) {
+ GetBN(obj, bn);
+ } else switch (TYPE(obj)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ obj = rb_String(obj);
+ if (!BN_dec2bn(&bn, StringValuePtr(obj))) {
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(cBN, obj, bn); /* Handle potencial mem leaks */
+ break;
+ default:
+ ossl_raise(rb_eTypeError, "Cannot convert into OpenSSL::BN");
+ }
+ return bn;
+}
+
+/*
+ * Private
+ */
+/*
+ * BN_CTX - is used in more difficult math. ops
+ * (Why just 1? Because Ruby itself isn't thread safe,
+ * we don't need to care about threads)
+ */
+BN_CTX *ossl_bn_ctx;
+
+static VALUE
+ossl_bn_alloc(VALUE klass)
+{
+ BIGNUM *bn;
+ VALUE obj;
+
+ if (!(bn = BN_new())) {
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(klass, obj, bn);
+
+ return obj;
+}
+
+static VALUE
+ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE str, bs;
+ int base = 10;
+
+ GetBN(self, bn);
+
+ if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) {
+ base = NUM2INT(bs);
+ }
+ if (RTEST(rb_obj_is_kind_of(str, cBN))) {
+ BIGNUM *other;
+
+ GetBN(str, other); /* Safe - we checked kind_of? above */
+ if (!BN_copy(bn, other)) {
+ ossl_raise(eBNError, NULL);
+ }
+ return self;
+ }
+ str = rb_String(str);
+ StringValue(str);
+
+ switch (base) {
+ case 0:
+ if (!BN_mpi2bn(RSTRING(str)->ptr, RSTRING(str)->len, bn)) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 2:
+ if (!BN_bin2bn(RSTRING(str)->ptr, RSTRING(str)->len, bn)) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 10:
+ if (!BN_dec2bn(&bn, RSTRING(str)->ptr)) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 16:
+ if (!BN_hex2bn(&bn, RSTRING(str)->ptr)) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ default:
+ ossl_raise(rb_eArgError, "illegal radix %d", base);
+ }
+ return self;
+}
+
+static VALUE
+ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE str, bs;
+ int base = 10, len;
+ char *buf;
+
+ GetBN(self, bn);
+
+ if (rb_scan_args(argc, argv, "01", &bs) == 1) {
+ base = NUM2INT(bs);
+ }
+ switch (base) {
+ case 0:
+ len = BN_bn2mpi(bn, NULL);
+ str = rb_str_new(0, len);
+ if (BN_bn2mpi(bn, RSTRING(str)->ptr) != len)
+ ossl_raise(eBNError, NULL);
+ break;
+ case 2:
+ len = BN_num_bytes(bn);
+ str = rb_str_new(0, len);
+ if (BN_bn2bin(bn, RSTRING(str)->ptr) != len)
+ ossl_raise(eBNError, NULL);
+ break;
+ case 10:
+ if (!(buf = BN_bn2dec(bn))) ossl_raise(eBNError, NULL);
+ str = ossl_buf2str(buf, strlen(buf));
+ break;
+ case 16:
+ if (!(buf = BN_bn2hex(bn))) ossl_raise(eBNError, NULL);
+ str = ossl_buf2str(buf, strlen(buf));
+ break;
+ default:
+ ossl_raise(rb_eArgError, "illegal radix %d", base);
+ }
+
+ return str;
+}
+
+static VALUE
+ossl_bn_to_i(VALUE self)
+{
+ BIGNUM *bn;
+ char *txt;
+ VALUE num;
+
+ GetBN(self, bn);
+
+ if (!(txt = BN_bn2dec(bn))) {
+ ossl_raise(eBNError, NULL);
+ }
+ num = rb_cstr_to_inum(txt, 10, Qtrue);
+ OPENSSL_free(txt);
+
+ return num;
+}
+
+static VALUE
+ossl_bn_to_bn(VALUE self)
+{
+ return self;
+}
+
+static VALUE
+ossl_bn_coerce(VALUE self, VALUE other)
+{
+ switch(TYPE(other)) {
+ case T_STRING:
+ self = ossl_bn_to_s(0, NULL, self);
+ break;
+ case T_FIXNUM:
+ case T_BIGNUM:
+ self = ossl_bn_to_i(self);
+ break;
+ default:
+ if (!RTEST(rb_obj_is_kind_of(other, cBN))) {
+ ossl_raise(rb_eTypeError, "Don't know how to coerce");
+ }
+ }
+ return rb_assoc_new(other, self);
+}
+
+#define BIGNUM_BOOL1(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ if (BN_##func(bn)) { \
+ return Qtrue; \
+ } \
+ return Qfalse; \
+ }
+BIGNUM_BOOL1(is_zero);
+BIGNUM_BOOL1(is_one);
+BIGNUM_BOOL1(is_odd);
+
+#define BIGNUM_1c(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn, *result; \
+ VALUE obj; \
+ GetBN(self, bn); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn, ossl_bn_ctx)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_1c(sqr);
+
+#define BIGNUM_2(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn1, bn2)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_2(add);
+BIGNUM_2(sub);
+
+#define BIGNUM_2c(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn1, bn2, ossl_bn_ctx)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_2c(mul);
+BIGNUM_2c(mod);
+BIGNUM_2c(exp);
+BIGNUM_2c(gcd);
+BIGNUM_2c(mod_sqr);
+BIGNUM_2c(mod_inverse);
+
+static VALUE
+ossl_bn_div(VALUE self, VALUE other)
+{
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *r1, *r2;
+ VALUE obj1, obj2;
+
+ GetBN(self, bn1);
+
+ if (!(r1 = BN_new())) {
+ ossl_raise(eBNError, NULL);
+ }
+ if (!(r2 = BN_new())) {
+ BN_free(r1);
+ ossl_raise(eBNError, NULL);
+ }
+ if (!BN_div(r1, r2, bn1, bn2, ossl_bn_ctx)) {
+ BN_free(r1);
+ BN_free(r2);
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(CLASS_OF(self), obj1, r1);
+ WrapBN(CLASS_OF(self), obj2, r2);
+
+ return rb_ary_new3(2, obj1, obj2);
+}
+
+#define BIGNUM_3c(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other1, VALUE other2) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other1); \
+ BIGNUM *bn3 = GetBNPtr(other2), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_3c(mod_add);
+BIGNUM_3c(mod_sub);
+BIGNUM_3c(mod_mul);
+BIGNUM_3c(mod_exp);
+
+#define BIGNUM_BIT(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE bit) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ if (!BN_##func(bn, NUM2INT(bit))) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ return self; \
+ }
+BIGNUM_BIT(set_bit);
+BIGNUM_BIT(clear_bit);
+BIGNUM_BIT(mask_bits);
+
+static VALUE
+ossl_bn_is_bit_set(VALUE self, VALUE bit)
+{
+ BIGNUM *bn;
+
+ GetBN(self, bn);
+
+ if (BN_is_bit_set(bn, NUM2INT(bit))) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+#define BIGNUM_SHIFT(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE bits) \
+ { \
+ BIGNUM *bn, *result; \
+ int b; \
+ VALUE obj; \
+ GetBN(self, bn); \
+ b = NUM2INT(bits); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn, b)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_SHIFT(lshift);
+BIGNUM_SHIFT(rshift);
+
+#define BIGNUM_RAND(func) \
+ static VALUE \
+ ossl_bn_s_##func(int argc, VALUE *argv, VALUE klass) \
+ { \
+ BIGNUM *result; \
+ int bottom = 0, top = 0, b; \
+ VALUE bits, fill, odd, obj; \
+ \
+ switch (rb_scan_args(argc, argv, "12", &bits, &fill, &odd)) { \
+ case 3: \
+ bottom = (odd == Qtrue) ? 1 : 0; \
+ /* FALLTHROUGH */ \
+ case 2: \
+ top = FIX2INT(fill); \
+ } \
+ b = NUM2INT(bits); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, b, top, bottom)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(klass, obj, result); \
+ return obj; \
+ }
+BIGNUM_RAND(rand);
+BIGNUM_RAND(pseudo_rand);
+
+#define BIGNUM_RAND_RANGE(func) \
+ static VALUE \
+ ossl_bn_s_##func##_range(VALUE klass, VALUE range) \
+ { \
+ BIGNUM *bn = GetBNPtr(range), *result; \
+ VALUE obj; \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func##_range(result, bn)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(klass, obj, result); \
+ return obj; \
+ }
+BIGNUM_RAND_RANGE(rand);
+BIGNUM_RAND_RANGE(pseudo_rand);
+
+static VALUE
+ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass)
+{
+ BIGNUM *add = NULL, *rem = NULL, *result;
+ int safe = 1, num;
+ VALUE vnum, vsafe, vadd, vrem, obj;
+
+ rb_scan_args(argc, argv, "13", &vnum, &vsafe, &vadd, &vrem);
+
+ num = NUM2INT(vnum);
+
+ if (vsafe == Qfalse) {
+ safe = 0;
+ }
+ if (!NIL_P(vadd)) {
+ if (NIL_P(vrem)) {
+ ossl_raise(rb_eArgError,
+ "if ADD is specified, REM must be also given");
+ }
+ add = GetBNPtr(vadd);
+ rem = GetBNPtr(vrem);
+ }
+ if (!(result = BN_new())) {
+ ossl_raise(eBNError, NULL);
+ }
+ if (!BN_generate_prime(result, num, safe, add, rem, NULL, NULL)) {
+ BN_free(result);
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(klass, obj, result);
+
+ return obj;
+}
+
+#define BIGNUM_NUM(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ return INT2FIX(BN_##func(bn)); \
+ }
+BIGNUM_NUM(num_bytes);
+BIGNUM_NUM(num_bits);
+
+static VALUE
+ossl_bn_copy(VALUE self, VALUE other)
+{
+ BIGNUM *bn1, *bn2;
+
+ rb_check_frozen(self);
+
+ if (self == other) return self;
+
+ GetBN(self, bn1);
+ bn2 = GetBNPtr(other);
+
+ if (!BN_copy(bn1, bn2)) {
+ ossl_raise(eBNError, NULL);
+ }
+ return self;
+}
+
+#define BIGNUM_CMP(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other); \
+ GetBN(self, bn1); \
+ return INT2FIX(BN_##func(bn1, bn2)); \
+ }
+BIGNUM_CMP(cmp);
+BIGNUM_CMP(ucmp);
+
+static VALUE
+ossl_bn_eql(VALUE self, VALUE other)
+{
+ if (ossl_bn_cmp(self, other) == INT2FIX(0)) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+static VALUE
+ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE vchecks;
+ int checks = BN_prime_checks;
+
+ GetBN(self, bn);
+
+ if (rb_scan_args(argc, argv, "01", &vchecks) == 0) {
+ checks = NUM2INT(vchecks);
+ }
+ switch (BN_is_prime(bn, checks, NULL, ossl_bn_ctx, NULL)) {
+ case 1:
+ return Qtrue;
+ case 0:
+ return Qfalse;
+ default:
+ ossl_raise(eBNError, NULL);
+ }
+ /* not reachable */
+ return Qnil;
+}
+
+static VALUE
+ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE vchecks, vtrivdiv;
+ int checks = BN_prime_checks, do_trial_division = 1;
+
+ GetBN(self, bn);
+
+ rb_scan_args(argc, argv, "02", &vchecks, &vtrivdiv);
+
+ if (!NIL_P(vchecks)) {
+ checks = NUM2INT(vchecks);
+ }
+ /* handle true/false */
+ if (vtrivdiv == Qfalse) {
+ do_trial_division = 0;
+ }
+ switch (BN_is_prime_fasttest(bn, checks, NULL, ossl_bn_ctx, NULL, do_trial_division)) {
+ case 1:
+ return Qtrue;
+ case 0:
+ return Qfalse;
+ default:
+ ossl_raise(eBNError, NULL);
+ }
+ /* not reachable */
+ return Qnil;
+}
+
+/*
+ * INIT
+ * (NOTE: ordering of methods is the same as in 'man bn')
+ */
+void
+Init_ossl_bn()
+{
+ if (!(ossl_bn_ctx = BN_CTX_new())) {
+ ossl_raise(rb_eRuntimeError, "Cannot init BN_CTX");
+ }
+
+ eBNError = rb_define_class_under(mOSSL, "BNError", eOSSLError);
+
+ cBN = rb_define_class_under(mOSSL, "BN", rb_cObject);
+
+ rb_define_alloc_func(cBN, ossl_bn_alloc);
+ rb_define_method(cBN, "initialize", ossl_bn_initialize, -1);
+
+ rb_define_copy_func(cBN, ossl_bn_copy);
+ rb_define_method(cBN, "copy", ossl_bn_copy, 1);
+
+ /* swap (=coerce?) */
+
+ rb_define_method(cBN, "num_bytes", ossl_bn_num_bytes, 0);
+ rb_define_method(cBN, "num_bits", ossl_bn_num_bits, 0);
+ /* num_bits_word */
+
+ rb_define_method(cBN, "+", ossl_bn_add, 1);
+ rb_define_method(cBN, "-", ossl_bn_sub, 1);
+ rb_define_method(cBN, "*", ossl_bn_mul, 1);
+ rb_define_method(cBN, "sqr", ossl_bn_sqr, 0);
+ rb_define_method(cBN, "/", ossl_bn_div, 1);
+ rb_define_method(cBN, "%", ossl_bn_mod, 1);
+ /* nnmod */
+
+ rb_define_method(cBN, "mod_add", ossl_bn_mod_add, 2);
+ rb_define_method(cBN, "mod_sub", ossl_bn_mod_sub, 2);
+ rb_define_method(cBN, "mod_mul", ossl_bn_mod_mul, 2);
+ rb_define_method(cBN, "mod_sqr", ossl_bn_mod_sqr, 1);
+ rb_define_method(cBN, "**", ossl_bn_exp, 1);
+ rb_define_method(cBN, "mod_exp", ossl_bn_mod_exp, 2);
+ rb_define_method(cBN, "gcd", ossl_bn_gcd, 1);
+
+ /* add_word
+ * sub_word
+ * mul_word
+ * div_word
+ * mod_word */
+
+ rb_define_method(cBN, "cmp", ossl_bn_cmp, 1);
+ rb_define_alias(cBN, "<=>", "cmp");
+ rb_define_method(cBN, "ucmp", ossl_bn_ucmp, 1);
+ rb_define_method(cBN, "eql?", ossl_bn_eql, 1);
+ rb_define_alias(cBN, "==", "eql?");
+ rb_define_alias(cBN, "===", "eql?");
+ rb_define_method(cBN, "zero?", ossl_bn_is_zero, 0);
+ rb_define_method(cBN, "one?", ossl_bn_is_one, 0);
+ /* is_word */
+ rb_define_method(cBN, "odd?", ossl_bn_is_odd, 0);
+
+ /* zero
+ * one
+ * value_one - DON'T IMPL.
+ * set_word
+ * get_word */
+
+ rb_define_singleton_method(cBN, "rand", ossl_bn_s_rand, -1);
+ rb_define_singleton_method(cBN, "pseudo_rand", ossl_bn_s_pseudo_rand, -1);
+ rb_define_singleton_method(cBN, "rand_range", ossl_bn_s_rand_range, 1);
+ rb_define_singleton_method(cBN, "pseudo_rand_range", ossl_bn_s_pseudo_rand_range, 1);
+
+ rb_define_singleton_method(cBN, "generate_prime", ossl_bn_s_generate_prime, -1);
+ rb_define_method(cBN, "prime?", ossl_bn_is_prime, -1);
+
+ rb_define_method(cBN, "set_bit!", ossl_bn_set_bit, 1);
+ rb_define_method(cBN, "clear_bit!", ossl_bn_clear_bit, 1);
+ rb_define_method(cBN, "bit_set?", ossl_bn_is_bit_set, 1);
+ rb_define_method(cBN, "mask_bits!", ossl_bn_mask_bits, 1);
+ rb_define_method(cBN, "<<", ossl_bn_lshift, 1);
+ /* lshift1 - DON'T IMPL. */
+ rb_define_method(cBN, ">>", ossl_bn_rshift, 1);
+ /* rshift1 - DON'T IMPL. */
+
+ /*
+ * bn2bin
+ * bin2bn
+ * bn2hex
+ * bn2dec
+ * hex2bn
+ * dec2bn - all these are implemented in ossl_bn_initialize, and ossl_bn_to_s
+ * print - NOT IMPL.
+ * print_fp - NOT IMPL.
+ * bn2mpi
+ * mpi2bn
+ */
+ rb_define_method(cBN, "to_s", ossl_bn_to_s, -1);
+ rb_define_method(cBN, "to_i", ossl_bn_to_i, 0);
+ rb_define_alias(cBN, "to_int", "to_i");
+ rb_define_method(cBN, "to_bn", ossl_bn_to_bn, 0);
+ rb_define_method(cBN, "coerce", ossl_bn_coerce, 1);
+
+ /*
+ * TODO:
+ * But how to: from_bin, from_mpi? PACK?
+ * to_bin
+ * to_mpi
+ */
+
+ rb_define_method(cBN, "mod_inverse", ossl_bn_mod_inverse, 1);
+
+ /* RECiProcal
+ * MONTgomery */
+
+ /*
+ * TODO:
+ * Where to belong these?
+ */
+ rb_define_method(cBN, "prime_fasttest?", ossl_bn_is_prime_fasttest, -1);
+}
+
diff --git a/ext/openssl/ossl_bn.h b/ext/openssl/ossl_bn.h
new file mode 100644
index 0000000000..12aa484873
--- /dev/null
+++ b/ext/openssl/ossl_bn.h
@@ -0,0 +1,22 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_BN_H_)
+#define _OSSL_BN_H_
+
+extern VALUE cBN;
+extern VALUE eBNError;
+
+VALUE ossl_bn_new(BIGNUM *);
+BIGNUM *GetBNPtr(VALUE);
+void Init_ossl_bn(void);
+
+#endif /* _OSS_BN_H_ */
+
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
new file mode 100644
index 0000000000..98468e0f28
--- /dev/null
+++ b/ext/openssl/ossl_cipher.c
@@ -0,0 +1,377 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define MakeCipher(obj, klass, ctx) \
+ obj = Data_Make_Struct(klass, EVP_CIPHER_CTX, 0, ossl_cipher_free, ctx)
+#define GetCipher(obj, ctx) do { \
+ Data_Get_Struct(obj, EVP_CIPHER_CTX, ctx); \
+ if (!ctx) { \
+ ossl_raise(rb_eRuntimeError, "Cipher not inititalized!"); \
+ } \
+} while (0)
+#define SafeGetCipher(obj, ctx) do { \
+ OSSL_Check_Kind(obj, cCipher); \
+ GetCipher(obj, ctx); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE mCipher;
+VALUE cCipher;
+VALUE eCipherError;
+
+static VALUE ossl_cipher_alloc(VALUE klass);
+
+/*
+ * PUBLIC
+ */
+const EVP_CIPHER *
+GetCipherPtr(VALUE obj)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ SafeGetCipher(obj, ctx);
+
+ return EVP_CIPHER_CTX_cipher(ctx);
+}
+
+VALUE
+ossl_cipher_new(const EVP_CIPHER *cipher)
+{
+ VALUE ret;
+ EVP_CIPHER_CTX *ctx;
+
+ ret = ossl_cipher_alloc(cCipher);
+ GetCipher(ret, ctx);
+ EVP_CIPHER_CTX_init(ctx);
+ if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return ret;
+}
+
+/*
+ * PRIVATE
+ */
+static void
+ossl_cipher_free(EVP_CIPHER_CTX *ctx)
+{
+ if (ctx) {
+ EVP_CIPHER_CTX_cleanup(ctx);
+ free(ctx);
+ }
+}
+
+static VALUE
+ossl_cipher_alloc(VALUE klass)
+{
+ EVP_CIPHER_CTX *ctx;
+ VALUE obj;
+
+ MakeCipher(obj, klass, ctx);
+ EVP_CIPHER_CTX_init(ctx);
+
+ return obj;
+}
+
+static VALUE
+ossl_cipher_initialize(VALUE self, VALUE str)
+{
+ EVP_CIPHER_CTX *ctx;
+ const EVP_CIPHER *cipher;
+ char *name;
+
+ GetCipher(self, ctx);
+
+ name = StringValuePtr(str);
+
+ if (!(cipher = EVP_get_cipherbyname(name))) {
+ ossl_raise(rb_eRuntimeError, "Unsupported cipher algorithm (%s).", name);
+ }
+ if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return self;
+}
+static VALUE
+ossl_cipher_copy(VALUE self, VALUE other)
+{
+ EVP_CIPHER_CTX *ctx1, *ctx2;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetCipher(self, ctx1);
+ SafeGetCipher(other, ctx2);
+ if (EVP_CIPHER_CTX_copy(ctx1, ctx2) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_cipher_reset(VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
+{
+ EVP_CIPHER_CTX *ctx;
+ unsigned char key[EVP_MAX_KEY_LENGTH], *p_key = NULL;
+ unsigned char iv[EVP_MAX_IV_LENGTH], *p_iv = NULL;
+ VALUE pass, init_v;
+
+ GetCipher(self, ctx);
+ if(rb_scan_args(argc, argv, "02", &pass, &init_v) > 0){
+ /*
+ * oops. this code mistakes salt for IV.
+ * We deprecated the arguments for this method, but we decided
+ * keeping this behaviour for backward compatibility.
+ */
+ StringValue(pass);
+ if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv));
+ else{
+ char *cname = rb_class2name(rb_obj_class(self));
+ rb_warning("key derivation by %s#encrypt is deprecated; "
+ "use %s::pkcs5_keyivgen instead", cname, cname);
+ StringValue(init_v);
+ if (EVP_MAX_IV_LENGTH > RSTRING(init_v)->len) {
+ memset(iv, 0, EVP_MAX_IV_LENGTH);
+ memcpy(iv, RSTRING(init_v)->ptr, RSTRING(init_v)->len);
+ }
+ else memcpy(iv, RSTRING(init_v)->ptr, sizeof(iv));
+ }
+ EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
+ RSTRING(pass)->ptr, RSTRING(pass)->len, 1, key, NULL);
+ p_key = key;
+ p_iv = iv;
+ }
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) {
+ ossl_raise(eCipherError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self)
+{
+ return ossl_cipher_init(argc, argv, self, 1);
+}
+
+static VALUE
+ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self)
+{
+ return ossl_cipher_init(argc, argv, self, 0);
+}
+
+static VALUE
+ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+ const EVP_MD *digest;
+ VALUE vpass, vsalt, viter, vdigest;
+ unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH], *salt = NULL;
+ int iter;
+
+ GetCipher(self, ctx);
+ rb_scan_args(argc, argv, "13", &vpass, &vsalt, &viter, &vdigest);
+ StringValue(vpass);
+ if(!NIL_P(vsalt)){
+ StringValue(vsalt);
+ if(RSTRING(vsalt)->len != PKCS5_SALT_LEN)
+ rb_raise(eCipherError, "salt must be an 8-octet string.");
+ salt = RSTRING(vsalt)->ptr;
+ }
+ iter = NIL_P(viter) ? 2048 : NUM2INT(viter);
+ digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
+ EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
+ RSTRING(vpass)->ptr, RSTRING(vpass)->len, iter, key, iv);
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+ OPENSSL_cleanse(key, sizeof key);
+ OPENSSL_cleanse(iv, sizeof iv);
+
+ return Qnil;
+}
+
+static VALUE
+ossl_cipher_update(VALUE self, VALUE data)
+{
+ EVP_CIPHER_CTX *ctx;
+ char *in;
+ int in_len, out_len;
+ VALUE str;
+
+ GetCipher(self, ctx);
+ StringValue(data);
+ in = RSTRING(data)->ptr;
+ in_len = RSTRING(data)->len;
+ str = rb_str_new(0, in_len+EVP_CIPHER_CTX_block_size(ctx));
+ if (!EVP_CipherUpdate(ctx, RSTRING(str)->ptr, &out_len, in, in_len))
+ ossl_raise(eCipherError, NULL);
+ assert(out_len < RSTRING(str)->len);
+ RSTRING(str)->len = out_len;
+ RSTRING(str)->ptr[out_len] = 0;
+
+ return str;
+}
+
+static VALUE
+ossl_cipher_update_deprecated(VALUE self, VALUE data)
+{
+ char *cname;
+
+ cname = rb_class2name(rb_obj_class(self));
+ rb_warning("%s#<< is deprecated; use %s#update instead", cname, cname);
+ return ossl_cipher_update(self, data);
+}
+
+static VALUE
+ossl_cipher_final(VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+ int out_len;
+ VALUE str;
+
+ GetCipher(self, ctx);
+ str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx));
+ if (!EVP_CipherFinal_ex(ctx, RSTRING(str)->ptr, &out_len))
+ ossl_raise(eCipherError, NULL);
+ assert(out_len <= RSTRING(str)->len);
+ RSTRING(str)->len = out_len;
+ RSTRING(str)->ptr[out_len] = 0;
+
+ return str;
+}
+
+static VALUE
+ossl_cipher_name(VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+
+ return rb_str_new2(EVP_CIPHER_name(EVP_CIPHER_CTX_cipher(ctx)));
+}
+
+static VALUE
+ossl_cipher_set_key(VALUE self, VALUE key)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ StringValue(key);
+ GetCipher(self, ctx);
+
+ if (RSTRING(key)->len < EVP_CIPHER_CTX_key_length(ctx))
+ ossl_raise(eCipherError, "key length too short");
+
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, RSTRING(key)->ptr, NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return key;
+}
+
+static VALUE
+ossl_cipher_set_iv(VALUE self, VALUE iv)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ StringValue(iv);
+ GetCipher(self, ctx);
+
+ if (RSTRING(iv)->len < EVP_CIPHER_CTX_iv_length(ctx))
+ ossl_raise(eCipherError, "iv length too short");
+
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, RSTRING(iv)->ptr, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return iv;
+}
+
+static VALUE
+ossl_cipher_set_key_length(VALUE self, VALUE key_length)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+ if (EVP_CIPHER_CTX_set_key_length(ctx, NUM2INT(key_length)) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return key_length;
+}
+
+static VALUE
+ossl_cipher_set_padding(VALUE self, VALUE padding)
+{
+#if defined(HAVE_EVP_CIPHER_CTX_SET_PADDING)
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+ if (EVP_CIPHER_CTX_set_padding(ctx, NUM2INT(padding)) != 1)
+ ossl_raise(eCipherError, NULL);
+#else
+ rb_notimplement();
+#endif
+ return padding;
+}
+
+#define CIPHER_0ARG_INT(func) \
+ static VALUE \
+ ossl_cipher_##func(VALUE self) \
+ { \
+ EVP_CIPHER_CTX *ctx; \
+ GetCipher(self, ctx); \
+ return INT2NUM(EVP_CIPHER_##func(EVP_CIPHER_CTX_cipher(ctx))); \
+ }
+CIPHER_0ARG_INT(key_length)
+CIPHER_0ARG_INT(iv_length)
+CIPHER_0ARG_INT(block_size)
+
+/*
+ * INIT
+ */
+void
+Init_ossl_cipher(void)
+{
+ mCipher = rb_define_module_under(mOSSL, "Cipher");
+ eCipherError = rb_define_class_under(mOSSL, "CipherError", eOSSLError);
+ cCipher = rb_define_class_under(mCipher, "Cipher", rb_cObject);
+
+ rb_define_alloc_func(cCipher, ossl_cipher_alloc);
+ rb_define_copy_func(cCipher, ossl_cipher_copy);
+ rb_define_method(cCipher, "initialize", ossl_cipher_initialize, 1);
+ rb_define_method(cCipher, "reset", ossl_cipher_reset, 0);
+ rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, -1);
+ rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, -1);
+ rb_define_method(cCipher, "pkcs5_keyivgen", ossl_cipher_pkcs5_keyivgen, -1);
+ rb_define_method(cCipher, "update", ossl_cipher_update, 1);
+ rb_define_method(cCipher, "<<", ossl_cipher_update_deprecated, 1);
+ rb_define_method(cCipher, "final", ossl_cipher_final, 0);
+ rb_define_method(cCipher, "name", ossl_cipher_name, 0);
+ rb_define_method(cCipher, "key=", ossl_cipher_set_key, 1);
+ rb_define_method(cCipher, "key_len=", ossl_cipher_set_key_length, 1);
+ rb_define_method(cCipher, "key_len", ossl_cipher_key_length, 0);
+ rb_define_method(cCipher, "iv=", ossl_cipher_set_iv, 1);
+ rb_define_method(cCipher, "iv_len", ossl_cipher_iv_length, 0);
+ rb_define_method(cCipher, "block_size", ossl_cipher_block_size, 0);
+ rb_define_method(cCipher, "padding=", ossl_cipher_set_padding, 1);
+}
diff --git a/ext/openssl/ossl_cipher.h b/ext/openssl/ossl_cipher.h
new file mode 100644
index 0000000000..63c7a875e8
--- /dev/null
+++ b/ext/openssl/ossl_cipher.h
@@ -0,0 +1,23 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_CIPHER_H_)
+#define _OSSL_CIPHER_H_
+
+extern VALUE mCipher;
+extern VALUE cCipher;
+extern VALUE eCipherError;
+
+const EVP_CIPHER *GetCipherPtr(VALUE);
+VALUE ossl_cipher_new(const EVP_CIPHER *);
+void Init_ossl_cipher(void);
+
+#endif /* _OSSL_CIPHER_H_ */
+
diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c
new file mode 100644
index 0000000000..37abff508b
--- /dev/null
+++ b/ext/openssl/ossl_config.c
@@ -0,0 +1,455 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapConfig(klass, obj, conf) do { \
+ if (!conf) { \
+ ossl_raise(rb_eRuntimeError, "Config wasn't intitialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, NCONF_free, conf); \
+} while (0)
+#define GetConfig(obj, conf) do { \
+ Data_Get_Struct(obj, CONF, conf); \
+ if (!conf) { \
+ ossl_raise(rb_eRuntimeError, "Config wasn't intitialized!"); \
+ } \
+} while (0)
+#define SafeGetConfig(obj, conf) do { \
+ OSSL_Check_Kind(obj, cConfig); \
+ GetConfig(obj, conf); \
+} while(0);
+
+/*
+ * Classes
+ */
+VALUE cConfig;
+VALUE eConfigError;
+
+/*
+ * Public
+ */
+
+static CONF *parse_config(VALUE, CONF*);
+
+CONF *
+GetConfigPtr(VALUE obj)
+{
+ CONF *conf;
+
+ SafeGetConfig(obj, conf);
+
+ return conf;
+}
+
+CONF *
+DupConfigPtr(VALUE obj)
+{
+ VALUE str;
+
+ OSSL_Check_Kind(obj, cConfig);
+ str = rb_funcall(obj, rb_intern("to_s"), 0);
+
+ return parse_config(str, NULL);
+}
+
+/*
+ * Private
+ */
+static CONF *
+parse_config(VALUE str, CONF *dst)
+{
+ CONF *conf;
+ BIO *bio;
+ long eline = -1;
+
+ bio = ossl_obj2bio(str);
+ conf = dst ? dst : NCONF_new(NULL);
+ if(!conf){
+ BIO_free(bio);
+ ossl_raise(eConfigError, NULL);
+ }
+ if(!NCONF_load_bio(conf, bio, &eline)){
+ BIO_free(bio);
+ if(!dst) NCONF_free(conf);
+ if (eline <= 0) ossl_raise(eConfigError, "wrong config format");
+ else ossl_raise(eConfigError, "error in line %d", eline);
+ ossl_raise(eConfigError, NULL);
+ }
+ BIO_free(bio);
+
+ return conf;
+}
+
+static VALUE
+ossl_config_s_parse(VALUE klass, VALUE str)
+{
+ CONF *conf;
+ VALUE obj;
+
+ conf = parse_config(str, NULL);
+ WrapConfig(klass, obj, conf);
+
+ return obj;
+}
+
+static VALUE
+ossl_config_s_alloc(VALUE klass)
+{
+ CONF *conf;
+ VALUE obj;
+
+ if(!(conf = NCONF_new(NULL)))
+ ossl_raise(eConfigError, NULL);
+ WrapConfig(klass, obj, conf);
+
+ return obj;
+}
+
+static VALUE
+ossl_config_copy(VALUE self, VALUE other)
+{
+ VALUE str;
+ CONF *conf;
+
+ GetConfig(other, conf);
+ str = rb_funcall(self, rb_intern("to_s"), 0);
+ parse_config(str, conf);
+
+ return self;
+}
+
+static VALUE
+ossl_config_initialize(int argc, VALUE *argv, VALUE self)
+{
+ CONF *conf;
+ long eline = -1;
+ char *filename;
+ VALUE path;
+
+ GetConfig(self, conf);
+ rb_scan_args(argc, argv, "01", &path);
+ if(!NIL_P(path)){
+ SafeStringValue(path);
+ filename = StringValuePtr(path);
+ if (!NCONF_load(conf, filename, &eline)){
+ if (eline <= 0)
+ ossl_raise(eConfigError, "wrong config file %s", filename);
+ else
+ ossl_raise(eConfigError, "error in %s:%d", filename, eline);
+ }
+ }
+#ifdef OSSL_NO_CONF_API
+ else rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
+#else
+ else _CONF_new_data(conf);
+#endif
+
+ return self;
+}
+
+static VALUE
+ossl_config_add_value(VALUE self, VALUE section, VALUE name, VALUE value)
+{
+#ifdef OSSL_NO_CONF_API
+ rb_notimplement();
+#else
+ CONF *conf;
+ CONF_VALUE *sv, *cv;
+
+ GetConfig(self, conf);
+ StringValue(section);
+ StringValue(name);
+ StringValue(value);
+ if(!(sv = _CONF_get_section(conf, RSTRING(section)->ptr))){
+ if(!(sv = _CONF_new_section(conf, RSTRING(section)->ptr))){
+ ossl_raise(eConfigError, NULL);
+ }
+ }
+ if(!(cv = OPENSSL_malloc(sizeof(CONF_VALUE)))){
+ ossl_raise(eConfigError, NULL);
+ }
+ cv->name = BUF_strdup(RSTRING(name)->ptr);
+ cv->value = BUF_strdup(RSTRING(value)->ptr);
+ if(!cv->name || !cv->value || !_CONF_add_string(conf, sv, cv)){
+ OPENSSL_free(cv->name);
+ OPENSSL_free(cv->value);
+ OPENSSL_free(cv);
+ ossl_raise(eConfigError, "_CONF_add_string failure");
+ }
+
+ return value;
+#endif
+}
+
+static VALUE
+ossl_config_get_value(VALUE self, VALUE section, VALUE name)
+{
+ CONF *conf;
+ char *str;
+
+ GetConfig(self, conf);
+ StringValue(section);
+ StringValue(name);
+ str = NCONF_get_string(conf, RSTRING(section)->ptr, RSTRING(name)->ptr);
+ if(!str){
+ ERR_clear_error();
+ return Qnil;
+ }
+
+ return rb_str_new2(str);
+}
+
+static VALUE
+ossl_config_get_value_old(int argc, VALUE *argv, VALUE self)
+{
+ VALUE section, name;
+
+ rb_scan_args(argc, argv, "11", &section, &name);
+
+ /* support conf.value(nil, "HOME") -> conf.get_value("", "HOME") */
+ if (NIL_P(section)) section = rb_str_new2("");
+ /* support conf.value("HOME") -> conf.get_value("", "HOME") */
+ if (NIL_P(name)) {
+ name = section;
+ section = rb_str_new2("");
+ }
+ /* NOTE: Don't care about conf.get_value(nil, nil) */
+ rb_warn("Config#value is deprecated; use Config#get_value");
+ return ossl_config_get_value(self, section, name);
+}
+
+static VALUE
+set_conf_section_i(VALUE i, VALUE *arg)
+{
+ VALUE name, value;
+
+ Check_Type(i, T_ARRAY);
+ name = rb_ary_entry(i, 0);
+ value = rb_ary_entry(i, 1);
+ ossl_config_add_value(arg[0], arg[1], name, value);
+
+ return Qnil;
+}
+
+static VALUE
+ossl_config_set_section(VALUE self, VALUE section, VALUE hash)
+{
+ VALUE arg[2] = { self, section };
+ rb_iterate(rb_each, hash, set_conf_section_i, (VALUE)arg);
+ return hash;
+}
+
+/*
+ * Get all numbers as strings - use str.to_i to convert
+ * long number = CONF_get_number(confp->config, sect, StringValuePtr(item));
+ */
+static VALUE
+ossl_config_get_section(VALUE self, VALUE section)
+{
+ CONF *conf;
+ STACK_OF(CONF_VALUE) *sk;
+ CONF_VALUE *entry;
+ int i, entries;
+ VALUE hash;
+
+ hash = rb_hash_new();
+ GetConfig(self, conf);
+ if (!(sk = NCONF_get_section(conf, StringValuePtr(section)))) {
+ ERR_clear_error();
+ return hash;
+ }
+ if ((entries = sk_CONF_VALUE_num(sk)) < 0) {
+ OSSL_Debug("# of items in section is < 0?!?");
+ return hash;
+ }
+ for (i=0; i<entries; i++) {
+ entry = sk_CONF_VALUE_value(sk, i);
+ rb_hash_aset(hash, rb_str_new2(entry->name), rb_str_new2(entry->value));
+ }
+
+ return hash;
+}
+
+static VALUE
+ossl_config_get_section_old(VALUE self, VALUE section)
+{
+ rb_warn("Config#section is deprecated; use Config#[]");
+ return ossl_config_get_section(self, section);
+}
+
+#ifdef IMPLEMENT_LHASH_DOALL_ARG_FN
+static void
+get_conf_section(CONF_VALUE *cv, VALUE ary)
+{
+ if(cv->name) return;
+ rb_ary_push(ary, rb_str_new2(cv->section));
+}
+
+static IMPLEMENT_LHASH_DOALL_ARG_FN(get_conf_section, CONF_VALUE*, VALUE);
+
+static VALUE
+ossl_config_get_sections(VALUE self)
+{
+ CONF *conf;
+ VALUE ary;
+
+ GetConfig(self, conf);
+ ary = rb_ary_new();
+ lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(get_conf_section), (void*)ary);
+
+ return ary;
+}
+
+static void
+dump_conf_value(CONF_VALUE *cv, VALUE str)
+{
+ STACK_OF(CONF_VALUE) *sk;
+ CONF_VALUE *v;
+ int i, num;
+
+ if (cv->name) return;
+ sk = (STACK_OF(CONF_VALUE)*)cv->value;
+ num = sk_CONF_VALUE_num(sk);
+ rb_str_cat2(str, "[ ");
+ rb_str_cat2(str, cv->section);
+ rb_str_cat2(str, " ]\n");
+ for(i = 0; i < num; i++){
+ v = sk_CONF_VALUE_value(sk, i);
+ rb_str_cat2(str, v->name ? v->name : "None");
+ rb_str_cat2(str, "=");
+ rb_str_cat2(str, v->value ? v->value : "None");
+ rb_str_cat2(str, "\n");
+ }
+ rb_str_cat2(str, "\n");
+}
+
+static IMPLEMENT_LHASH_DOALL_ARG_FN(dump_conf_value, CONF_VALUE*, VALUE);
+
+static VALUE
+dump_conf(CONF *conf)
+{
+ VALUE str;
+
+ str = rb_str_new(0, 0);
+ lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(dump_conf_value), (void*)str);
+
+ return str;
+}
+
+static VALUE
+ossl_config_to_s(VALUE self)
+{
+ CONF *conf;
+
+ GetConfig(self, conf);
+
+ return dump_conf(conf);
+}
+
+static void
+each_conf_value(CONF_VALUE *cv, void* dummy)
+{
+ STACK_OF(CONF_VALUE) *sk;
+ CONF_VALUE *v;
+ VALUE section, name, value, args;
+ int i, num;
+
+ if (cv->name) return;
+ sk = (STACK_OF(CONF_VALUE)*)cv->value;
+ num = sk_CONF_VALUE_num(sk);
+ section = rb_str_new2(cv->section);
+ for(i = 0; i < num; i++){
+ v = sk_CONF_VALUE_value(sk, i);
+ name = v->name ? rb_str_new2(v->name) : Qnil;
+ value = v->value ? rb_str_new2(v->value) : Qnil;
+ args = rb_ary_new3(3, section, name, value);
+ rb_yield(args);
+ }
+}
+
+static IMPLEMENT_LHASH_DOALL_ARG_FN(each_conf_value, CONF_VALUE*, void*);
+
+static VALUE
+ossl_config_each(VALUE self)
+{
+ CONF *conf;
+
+ GetConfig(self, conf);
+ lh_doall_arg(conf->data, LHASH_DOALL_ARG_FN(each_conf_value), (void*)NULL);
+
+ return self;
+}
+#else
+static VALUE
+ossl_config_get_sections(VALUE self)
+{
+ rb_warn("#sections don't work with %s", OPENSSL_VERSION_TEXT);
+ return rb_ary_new();
+}
+
+static VALUE
+ossl_config_to_s(VALUE self)
+{
+ rb_warn("#to_s don't work with %s", OPENSSL_VERSION_TEXT);
+ return rb_str_new(0, 0);
+}
+
+static VALUE
+ossl_config_each(VALUE self)
+{
+ rb_warn("#each don't work with %s", OPENSSL_VERSION_TEXT);
+ return self;
+}
+#endif
+
+static VALUE
+ossl_config_inspect(VALUE self)
+{
+ VALUE str, ary = ossl_config_get_sections(self);
+ char *cname = rb_class2name(rb_obj_class(self));
+
+ str = rb_str_new2("#<");
+ rb_str_cat2(str, cname);
+ rb_str_cat2(str, " sections=");
+ rb_str_append(str, rb_inspect(ary));
+ rb_str_cat2(str, ">");
+
+ return str;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_config()
+{
+ eConfigError = rb_define_class_under(mOSSL, "ConfigError", eOSSLError);
+ cConfig = rb_define_class_under(mOSSL, "Config", rb_cObject);
+
+ rb_define_const(cConfig, "DEFAULT_CONFIG_FILE",
+ rb_str_new2(CONF_get1_default_config_file()));
+ rb_include_module(cConfig, rb_mEnumerable);
+ rb_define_singleton_method(cConfig, "parse", ossl_config_s_parse, 1);
+ rb_define_alias(CLASS_OF(cConfig), "load", "new");
+ rb_define_alloc_func(cConfig, ossl_config_s_alloc);
+ rb_define_copy_func(cConfig, ossl_config_copy);
+ rb_define_method(cConfig, "initialize", ossl_config_initialize, -1);
+ rb_define_method(cConfig, "get_value", ossl_config_get_value, 2);
+ rb_define_method(cConfig, "value", ossl_config_get_value_old, -1);
+ rb_define_method(cConfig, "add_value", ossl_config_add_value, 3);
+ rb_define_method(cConfig, "[]", ossl_config_get_section, 1);
+ rb_define_method(cConfig, "section", ossl_config_get_section_old, 1);
+ rb_define_method(cConfig, "[]=", ossl_config_set_section, 2);
+ rb_define_method(cConfig, "sections", ossl_config_get_sections, 0);
+ rb_define_method(cConfig, "to_s", ossl_config_to_s, 0);
+ rb_define_method(cConfig, "each", ossl_config_each, 0);
+ rb_define_method(cConfig, "inspect", ossl_config_inspect, 0);
+}
diff --git a/ext/openssl/ossl_config.h b/ext/openssl/ossl_config.h
new file mode 100644
index 0000000000..cb226b27e5
--- /dev/null
+++ b/ext/openssl/ossl_config.h
@@ -0,0 +1,22 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_CONFIG_H_)
+#define _OSSL_CONFIG_H_
+
+extern VALUE cConfig;
+extern VALUE eConfigError;
+
+CONF* GetConfigPtr(VALUE obj);
+CONF* DupConfigPtr(VALUE obj);
+void Init_ossl_config(void);
+
+#endif /* _OSSL_CONFIG_H_ */
+
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
new file mode 100644
index 0000000000..8ad9f01dc4
--- /dev/null
+++ b/ext/openssl/ossl_digest.c
@@ -0,0 +1,294 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define GetDigest(obj, ctx) do { \
+ Data_Get_Struct(obj, EVP_MD_CTX, ctx); \
+ if (!ctx) { \
+ ossl_raise(rb_eRuntimeError, "Digest CTX wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetDigest(obj, ctx) do { \
+ OSSL_Check_Kind(obj, cDigest); \
+ GetDigest(obj, ctx); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE mDigest;
+VALUE cDigest;
+VALUE eDigestError;
+
+static VALUE ossl_digest_alloc(VALUE klass);
+
+/*
+ * Public
+ */
+const EVP_MD *
+GetDigestPtr(VALUE obj)
+{
+ EVP_MD_CTX *ctx;
+
+ SafeGetDigest(obj, ctx);
+
+ return EVP_MD_CTX_md(ctx); /*== ctx->digest*/
+}
+
+VALUE
+ossl_digest_new(const EVP_MD *md)
+{
+ VALUE ret;
+ EVP_MD_CTX *ctx;
+
+ ret = ossl_digest_alloc(cDigest);
+ GetDigest(ret, ctx);
+ EVP_MD_CTX_init(ctx);
+ EVP_DigestInit_ex(ctx, md, NULL);
+
+ return ret;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_digest_alloc(VALUE klass)
+{
+ EVP_MD_CTX *ctx;
+ VALUE obj;
+
+ ctx = EVP_MD_CTX_create();
+ if (ctx == NULL)
+ ossl_raise(rb_eRuntimeError, "EVP_MD_CTX_create() failed");
+ EVP_MD_CTX_init(ctx);
+ obj = Data_Wrap_Struct(klass, 0, EVP_MD_CTX_destroy, ctx);
+
+ return obj;
+}
+
+VALUE ossl_digest_update(VALUE, VALUE);
+
+static VALUE
+ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_MD_CTX *ctx;
+ const EVP_MD *md;
+ char *name;
+ VALUE type, data;
+
+ GetDigest(self, ctx);
+
+ rb_scan_args(argc, argv, "11", &type, &data);
+ name = StringValuePtr(type);
+ if (!NIL_P(data)) StringValue(data);
+
+ md = EVP_get_digestbyname(name);
+ if (!md) {
+ ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
+ }
+ EVP_DigestInit_ex(ctx, md, NULL);
+
+ if (!NIL_P(data)) return ossl_digest_update(self, data);
+ return self;
+}
+
+static VALUE
+ossl_digest_copy(VALUE self, VALUE other)
+{
+ EVP_MD_CTX *ctx1, *ctx2;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetDigest(self, ctx1);
+ SafeGetDigest(other, ctx2);
+
+ if (!EVP_MD_CTX_copy(ctx1, ctx2)) {
+ ossl_raise(eDigestError, NULL);
+ }
+ return self;
+}
+
+static VALUE
+ossl_digest_reset(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+ EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL);
+
+ return self;
+}
+
+VALUE
+ossl_digest_update(VALUE self, VALUE data)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+ StringValue(data);
+ EVP_DigestUpdate(ctx, RSTRING(data)->ptr, RSTRING(data)->len);
+
+ return self;
+}
+
+static void
+digest_final(EVP_MD_CTX *ctx, char **buf, int *buf_len)
+{
+ EVP_MD_CTX final;
+
+ if (!EVP_MD_CTX_copy(&final, ctx)) {
+ ossl_raise(eDigestError, NULL);
+ }
+ if (!(*buf = OPENSSL_malloc(EVP_MD_CTX_size(&final)))) {
+ EVP_MD_CTX_cleanup(&final);
+ ossl_raise(eDigestError, "Cannot allocate mem for digest");
+ }
+ EVP_DigestFinal_ex(&final, *buf, buf_len);
+ EVP_MD_CTX_cleanup(&final);
+}
+
+static VALUE
+ossl_digest_digest(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+ char *buf;
+ int buf_len;
+ VALUE digest;
+
+ GetDigest(self, ctx);
+ digest_final(ctx, &buf, &buf_len);
+ digest = ossl_buf2str(buf, buf_len);
+
+ return digest;
+}
+
+static VALUE
+ossl_digest_hexdigest(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+ char *buf, *hexbuf;
+ int buf_len;
+ VALUE hexdigest;
+
+ GetDigest(self, ctx);
+ digest_final(ctx, &buf, &buf_len);
+ if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * buf_len) {
+ OPENSSL_free(buf);
+ ossl_raise(eDigestError, "Memory alloc error");
+ }
+ OPENSSL_free(buf);
+ hexdigest = ossl_buf2str(hexbuf, 2 * buf_len);
+
+ return hexdigest;
+}
+
+static VALUE
+ossl_digest_s_digest(VALUE klass, VALUE str, VALUE data)
+{
+ VALUE obj = rb_class_new_instance(1, &str, klass);
+
+ ossl_digest_update(obj, data);
+
+ return ossl_digest_digest(obj);
+}
+
+static VALUE
+ossl_digest_s_hexdigest(VALUE klass, VALUE str, VALUE data)
+{
+ VALUE obj = rb_class_new_instance(1, &str, klass);
+
+ ossl_digest_update(obj, data);
+
+ return ossl_digest_hexdigest(obj);
+}
+
+static VALUE
+ossl_digest_equal(VALUE self, VALUE other)
+{
+ EVP_MD_CTX *ctx;
+ VALUE str1, str2;
+
+ GetDigest(self, ctx);
+ if (rb_obj_is_kind_of(other, cDigest) == Qtrue) {
+ str2 = ossl_digest_digest(other);
+ } else {
+ StringValue(other);
+ str2 = other;
+ }
+ if (RSTRING(str2)->len == EVP_MD_CTX_size(ctx)) {
+ str1 = ossl_digest_digest(self);
+ } else {
+ str1 = ossl_digest_hexdigest(self);
+ }
+ if (RSTRING(str1)->len == RSTRING(str2)->len
+ && rb_str_cmp(str1, str2) == 0) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+static VALUE
+ossl_digest_name(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+
+ return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
+}
+
+static VALUE
+ossl_digest_size(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+
+ return INT2NUM(EVP_MD_CTX_size(ctx));
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_digest()
+{
+ mDigest = rb_define_module_under(mOSSL, "Digest");
+
+ eDigestError = rb_define_class_under(mDigest, "DigestError", eOSSLError);
+
+ cDigest = rb_define_class_under(mDigest, "Digest", rb_cObject);
+
+ rb_define_alloc_func(cDigest, ossl_digest_alloc);
+ rb_define_singleton_method(cDigest, "digest", ossl_digest_s_digest, 2);
+ rb_define_singleton_method(cDigest, "hexdigest", ossl_digest_s_hexdigest, 2);
+
+ rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
+ rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
+
+ rb_define_copy_func(cDigest, ossl_digest_copy);
+
+ rb_define_method(cDigest, "digest", ossl_digest_digest, 0);
+ rb_define_method(cDigest, "hexdigest", ossl_digest_hexdigest, 0);
+ rb_define_alias(cDigest, "inspect", "hexdigest");
+ rb_define_alias(cDigest, "to_s", "hexdigest");
+
+ rb_define_method(cDigest, "update", ossl_digest_update, 1);
+ rb_define_alias(cDigest, "<<", "update");
+
+ rb_define_method(cDigest, "==", ossl_digest_equal, 1);
+
+ rb_define_method(cDigest, "name", ossl_digest_name, 0);
+ rb_define_method(cDigest, "size", ossl_digest_size, 0);
+}
diff --git a/ext/openssl/ossl_digest.h b/ext/openssl/ossl_digest.h
new file mode 100644
index 0000000000..8a1f7964f2
--- /dev/null
+++ b/ext/openssl/ossl_digest.h
@@ -0,0 +1,23 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_DIGEST_H_)
+#define _OSSL_DIGEST_H_
+
+extern VALUE mDigest;
+extern VALUE cDigest;
+extern VALUE eDigestError;
+
+const EVP_MD *GetDigestPtr(VALUE);
+VALUE ossl_digest_new(const EVP_MD *);
+void Init_ossl_digest(void);
+
+#endif /* _OSSL_DIGEST_H_ */
+
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
new file mode 100644
index 0000000000..91025941b9
--- /dev/null
+++ b/ext/openssl/ossl_engine.c
@@ -0,0 +1,329 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#if defined(OSSL_ENGINE_ENABLED)
+
+#define WrapEngine(klass, obj, engine) do { \
+ if (!engine) { \
+ ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, ENGINE_free, engine); \
+} while(0)
+#define GetEngine(obj, engine) do { \
+ Data_Get_Struct(obj, ENGINE, engine); \
+ if (!engine) { \
+ ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetEngine(obj, engine) do { \
+ OSSL_Check_Kind(obj, cEngine); \
+ GetPKCS7(obj, engine); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cEngine;
+VALUE eEngineError;
+
+/*
+ * Private
+ */
+#define OSSL_ENGINE_LOAD_IF_MATCH(x) \
+do{\
+ if(!strcmp(#x, RSTRING(name)->ptr)){\
+ ENGINE_load_##x();\
+ return Qtrue;\
+ }\
+}while(0)
+
+static VALUE
+ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
+{
+#if !defined(HAVE_ENGINE_LOAD_BUILTIN_ENGINES)
+ return Qnil;
+#else
+ VALUE name;
+
+ rb_scan_args(argc, argv, "01", &name);
+ if(NIL_P(name)) ENGINE_load_builtin_engines();
+ StringValue(name);
+ OSSL_ENGINE_LOAD_IF_MATCH(openssl);
+ OSSL_ENGINE_LOAD_IF_MATCH(dynamic);
+ OSSL_ENGINE_LOAD_IF_MATCH(cswift);
+ OSSL_ENGINE_LOAD_IF_MATCH(chil);
+ OSSL_ENGINE_LOAD_IF_MATCH(atalla);
+ OSSL_ENGINE_LOAD_IF_MATCH(nuron);
+ OSSL_ENGINE_LOAD_IF_MATCH(ubsec);
+ OSSL_ENGINE_LOAD_IF_MATCH(aep);
+ OSSL_ENGINE_LOAD_IF_MATCH(sureware);
+ OSSL_ENGINE_LOAD_IF_MATCH(4758cca);
+#ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO
+ OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto);
+#endif
+ rb_raise(eEngineError, "no such engine `%s'", RSTRING(name)->ptr);
+#endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
+}
+
+static VALUE
+ossl_engine_s_cleanup(VALUE self)
+{
+#if defined(HAVE_ENGINE_CLEANUP)
+ ENGINE_cleanup();
+#endif
+ return Qnil;
+}
+
+static VALUE
+ossl_engine_s_engines(VALUE klass)
+{
+ ENGINE *e;
+ VALUE ary, obj;
+
+ ary = rb_ary_new();
+ for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){
+ WrapEngine(klass, obj, e);
+ rb_ary_push(ary, obj);
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_engine_s_by_id(VALUE klass, VALUE id)
+{
+ ENGINE *e;
+ VALUE obj;
+
+ StringValue(id);
+ ossl_engine_s_load(1, &id, klass);
+ if(!(e = ENGINE_by_id(RSTRING(id)->ptr)))
+ ossl_raise(eEngineError, NULL);
+ if(!ENGINE_init(e))
+ ossl_raise(eEngineError, NULL);
+ ENGINE_ctrl(e, ENGINE_CTRL_SET_PASSWORD_CALLBACK,
+ 0, NULL, (void(*)())ossl_pem_passwd_cb);
+ ERR_clear_error();
+ WrapEngine(klass, obj, e);
+
+ return obj;
+}
+
+static VALUE
+ossl_engine_s_alloc(VALUE klass)
+{
+ ENGINE *e;
+ VALUE obj;
+
+ if (!(e = ENGINE_new())) {
+ ossl_raise(eEngineError, NULL);
+ }
+ WrapEngine(klass, obj, e);
+
+ return obj;
+}
+
+static VALUE
+ossl_engine_get_id(VALUE self)
+{
+ ENGINE *e;
+ GetEngine(self, e);
+ return rb_str_new2(ENGINE_get_id(e));
+}
+
+static VALUE
+ossl_engine_get_name(VALUE self)
+{
+ ENGINE *e;
+ GetEngine(self, e);
+ return rb_str_new2(ENGINE_get_name(e));
+}
+
+static VALUE
+ossl_engine_finish(VALUE self)
+{
+ ENGINE *e;
+
+ GetEngine(self, e);
+ if(!ENGINE_finish(e)) ossl_raise(eEngineError, NULL);
+
+ return Qnil;
+}
+
+static VALUE
+ossl_engine_get_cipher(VALUE self, VALUE name)
+{
+#if defined(HAVE_ENGINE_GET_CIPHER)
+ ENGINE *e;
+ const EVP_CIPHER *ciph, *tmp;
+ char *s;
+ int nid;
+
+ s = StringValuePtr(name);
+ tmp = EVP_get_cipherbyname(s);
+ if(!tmp) ossl_raise(eEngineError, "no such cipher `%s'", s);
+ nid = EVP_CIPHER_nid(tmp);
+ GetEngine(self, e);
+ ciph = ENGINE_get_cipher(e, nid);
+ if(!ciph) ossl_raise(eEngineError, NULL);
+
+ return ossl_cipher_new(ciph);
+#else
+ rb_notimplement();
+#endif
+}
+
+static VALUE
+ossl_engine_get_digest(VALUE self, VALUE name)
+{
+#if defined(HAVE_ENGINE_GET_DIGEST)
+ ENGINE *e;
+ const EVP_MD *md, *tmp;
+ char *s;
+ int nid;
+
+ s = StringValuePtr(name);
+ tmp = EVP_get_digestbyname(s);
+ if(!tmp) ossl_raise(eEngineError, "no such digest `%s'", s);
+ nid = EVP_MD_nid(tmp);
+ GetEngine(self, e);
+ md = ENGINE_get_digest(e, nid);
+ if(!md) ossl_raise(eEngineError, NULL);
+
+ return ossl_digest_new(md);
+#else
+ rb_notimplement();
+#endif
+}
+
+static VALUE
+ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self)
+{
+ ENGINE *e;
+ EVP_PKEY *pkey;
+ VALUE id, data;
+ char *sid, *sdata;
+
+ rb_scan_args(argc, argv, "11", &id, &data);
+ sid = StringValuePtr(id);
+ sdata = NIL_P(data) ? NULL : StringValuePtr(data);
+ GetEngine(self, e);
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ pkey = ENGINE_load_private_key(e, sid, sdata);
+#else
+ pkey = ENGINE_load_private_key(e, sid, NULL, sdata);
+#endif
+ if (!pkey) ossl_raise(eEngineError, NULL);
+
+ return ossl_pkey_new(pkey);
+}
+
+static VALUE
+ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self)
+{
+ ENGINE *e;
+ EVP_PKEY *pkey;
+ VALUE id, data;
+ char *sid, *sdata;
+
+ rb_scan_args(argc, argv, "11", &id, &data);
+ sid = StringValuePtr(id);
+ sdata = NIL_P(data) ? NULL : StringValuePtr(data);
+ GetEngine(self, e);
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ pkey = ENGINE_load_public_key(e, sid, sdata);
+#else
+ pkey = ENGINE_load_public_key(e, sid, NULL, sdata);
+#endif
+ if (!pkey) ossl_raise(eEngineError, NULL);
+
+ return ossl_pkey_new(pkey);
+}
+
+static VALUE
+ossl_engine_set_default(VALUE self, VALUE flag)
+{
+ ENGINE *e;
+
+ GetEngine(self, e);
+ ENGINE_set_default(e, NUM2INT(flag));
+
+ return Qtrue;
+}
+
+static VALUE
+ossl_engine_inspect(VALUE self)
+{
+ VALUE str;
+ char *cname = rb_class2name(rb_obj_class(self));
+
+ str = rb_str_new2("#<");
+ rb_str_cat2(str, cname);
+ rb_str_cat2(str, " id=\"");
+ rb_str_append(str, ossl_engine_get_id(self));
+ rb_str_cat2(str, "\" name=\"");
+ rb_str_append(str, ossl_engine_get_name(self));
+ rb_str_cat2(str, "\">");
+
+ return str;
+}
+
+#define DefEngineConst(x) rb_define_const(cEngine, #x, INT2NUM(ENGINE_##x))
+
+void
+Init_ossl_engine()
+{
+ cEngine = rb_define_class_under(mOSSL, "Engine", rb_cObject);
+ eEngineError = rb_define_class_under(cEngine, "EngineError", eOSSLError);
+
+ rb_define_alloc_func(cEngine, ossl_engine_s_alloc);
+ rb_define_singleton_method(cEngine, "load", ossl_engine_s_load, -1);
+ rb_define_singleton_method(cEngine, "cleanup", ossl_engine_s_cleanup, 0);
+ rb_define_singleton_method(cEngine, "engines", ossl_engine_s_engines, 0);
+ rb_define_singleton_method(cEngine, "by_id", ossl_engine_s_by_id, 1);
+ rb_undef_method(CLASS_OF(cEngine), "new");
+
+ rb_define_method(cEngine, "id", ossl_engine_get_id, 0);
+ rb_define_method(cEngine, "name", ossl_engine_get_name, 0);
+ rb_define_method(cEngine, "finish", ossl_engine_finish, 0);
+ rb_define_method(cEngine, "cipher", ossl_engine_get_cipher, 1);
+ rb_define_method(cEngine, "digest", ossl_engine_get_digest, 1);
+ rb_define_method(cEngine, "load_private_key", ossl_engine_load_privkey, -1);
+ rb_define_method(cEngine, "load_public_key", ossl_engine_load_pubkey, -1);
+ rb_define_method(cEngine, "set_default", ossl_engine_set_default, 1);
+ rb_define_method(cEngine, "inspect", ossl_engine_inspect, 0);
+
+ DefEngineConst(METHOD_RSA);
+ DefEngineConst(METHOD_DSA);
+ DefEngineConst(METHOD_DH);
+ DefEngineConst(METHOD_RAND);
+#ifdef ENGINE_METHOD_BN_MOD_EXP
+ DefEngineConst(METHOD_BN_MOD_EXP);
+#endif
+#ifdef ENGINE_METHOD_BN_MOD_EXP_CRT
+ DefEngineConst(METHOD_BN_MOD_EXP_CRT);
+#endif
+#ifdef ENGINE_METHOD_CIPHERS
+ DefEngineConst(METHOD_CIPHERS);
+#endif
+#ifdef ENGINE_METHOD_DIGESTS
+ DefEngineConst(METHOD_DIGESTS);
+#endif
+ DefEngineConst(METHOD_ALL);
+ DefEngineConst(METHOD_NONE);
+}
+#else
+void
+Init_ossl_engine()
+{
+}
+#endif
diff --git a/ext/openssl/ossl_engine.h b/ext/openssl/ossl_engine.h
new file mode 100644
index 0000000000..ea2f256912
--- /dev/null
+++ b/ext/openssl/ossl_engine.h
@@ -0,0 +1,20 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OSSL_ENGINE_H)
+#define OSSL_ENGINE_H
+
+extern VALUE cEngine;
+extern VALUE eEngineError;
+
+void Init_ossl_engine(void);
+
+#endif /* OSSL_ENGINE_H */
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
new file mode 100644
index 0000000000..fb3d0a6a8f
--- /dev/null
+++ b/ext/openssl/ossl_hmac.c
@@ -0,0 +1,220 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_HMAC)
+
+#include "ossl.h"
+
+#define MakeHMAC(obj, klass, ctx) \
+ obj = Data_Make_Struct(klass, HMAC_CTX, 0, ossl_hmac_free, ctx)
+#define GetHMAC(obj, ctx) do { \
+ Data_Get_Struct(obj, HMAC_CTX, ctx); \
+ if (!ctx) { \
+ ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
+ } \
+} while (0)
+#define SafeGetHMAC(obj, ctx) do { \
+ OSSL_Check_Kind(obj, cHMAC); \
+ GetHMAC(obj, ctx); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cHMAC;
+VALUE eHMACError;
+
+/*
+ * Public
+ */
+
+/*
+ * Private
+ */
+static void
+ossl_hmac_free(HMAC_CTX *ctx)
+{
+ HMAC_CTX_cleanup(ctx);
+ free(ctx);
+}
+
+static VALUE
+ossl_hmac_alloc(VALUE klass)
+{
+ HMAC_CTX *ctx;
+ VALUE obj;
+
+ MakeHMAC(obj, klass, ctx);
+ HMAC_CTX_init(ctx);
+
+ return obj;
+}
+
+static VALUE
+ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
+{
+ HMAC_CTX *ctx;
+
+ GetHMAC(self, ctx);
+ StringValue(key);
+ HMAC_Init_ex(ctx, RSTRING(key)->ptr, RSTRING(key)->len,
+ GetDigestPtr(digest), NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_hmac_copy(VALUE self, VALUE other)
+{
+ HMAC_CTX *ctx1, *ctx2;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetHMAC(self, ctx1);
+ SafeGetHMAC(other, ctx2);
+
+ if (!HMAC_CTX_copy(ctx1, ctx2)) {
+ ossl_raise(eHMACError, NULL);
+ }
+ return self;
+}
+
+static VALUE
+ossl_hmac_update(VALUE self, VALUE data)
+{
+ HMAC_CTX *ctx;
+
+ GetHMAC(self, ctx);
+ StringValue(data);
+ HMAC_Update(ctx, RSTRING(data)->ptr, RSTRING(data)->len);
+
+ return self;
+}
+
+static void
+hmac_final(HMAC_CTX *ctx, char **buf, int *buf_len)
+{
+ HMAC_CTX final;
+
+ if (!HMAC_CTX_copy(&final, ctx)) {
+ ossl_raise(eHMACError, NULL);
+ }
+ if (!(*buf = OPENSSL_malloc(HMAC_size(&final)))) {
+ HMAC_CTX_cleanup(&final);
+ OSSL_Debug("Allocating %d mem", HMAC_size(&final));
+ ossl_raise(eHMACError, "Cannot allocate memory for hmac");
+ }
+ HMAC_Final(&final, *buf, buf_len);
+ HMAC_CTX_cleanup(&final);
+}
+
+static VALUE
+ossl_hmac_digest(VALUE self)
+{
+ HMAC_CTX *ctx;
+ char *buf;
+ int buf_len;
+ VALUE digest;
+
+ GetHMAC(self, ctx);
+ hmac_final(ctx, &buf, &buf_len);
+ digest = ossl_buf2str(buf, buf_len);
+
+ return digest;
+}
+
+static VALUE
+ossl_hmac_hexdigest(VALUE self)
+{
+ HMAC_CTX *ctx;
+ char *buf, *hexbuf;
+ int buf_len;
+ VALUE hexdigest;
+
+ GetHMAC(self, ctx);
+ hmac_final(ctx, &buf, &buf_len);
+ if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * buf_len) {
+ OPENSSL_free(buf);
+ ossl_raise(eHMACError, "Memory alloc error");
+ }
+ OPENSSL_free(buf);
+ hexdigest = ossl_buf2str(hexbuf, 2 * buf_len);
+
+ return hexdigest;
+}
+
+static VALUE
+ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
+{
+ char *buf;
+ int buf_len;
+
+ StringValue(key);
+ StringValue(data);
+ buf = HMAC(GetDigestPtr(digest), RSTRING(key)->ptr, RSTRING(key)->len,
+ RSTRING(data)->ptr, RSTRING(data)->len, NULL, &buf_len);
+
+ return rb_str_new(buf, buf_len);
+}
+
+static VALUE
+ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
+{
+ char *buf, *hexbuf;
+ int buf_len;
+ VALUE hexdigest;
+
+ StringValue(key);
+ StringValue(data);
+
+ buf = HMAC(GetDigestPtr(digest), RSTRING(key)->ptr, RSTRING(key)->len,
+ RSTRING(data)->ptr, RSTRING(data)->len, NULL, &buf_len);
+ if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * buf_len) {
+ ossl_raise(eHMACError, "Cannot convert buf to hexbuf");
+ }
+ hexdigest = ossl_buf2str(hexbuf, 2 * buf_len);
+
+ return hexdigest;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_hmac()
+{
+ eHMACError = rb_define_class_under(mOSSL, "HMACError", eOSSLError);
+
+ cHMAC = rb_define_class_under(mOSSL, "HMAC", rb_cObject);
+
+ rb_define_alloc_func(cHMAC, ossl_hmac_alloc);
+ rb_define_singleton_method(cHMAC, "digest", ossl_hmac_s_digest, 3);
+ rb_define_singleton_method(cHMAC, "hexdigest", ossl_hmac_s_hexdigest, 3);
+
+ rb_define_method(cHMAC, "initialize", ossl_hmac_initialize, 2);
+ rb_define_copy_func(cHMAC, ossl_hmac_copy);
+
+ rb_define_method(cHMAC, "update", ossl_hmac_update, 1);
+ rb_define_alias(cHMAC, "<<", "update");
+ rb_define_method(cHMAC, "digest", ossl_hmac_digest, 0);
+ rb_define_method(cHMAC, "hexdigest", ossl_hmac_hexdigest, 0);
+ rb_define_alias(cHMAC, "inspect", "hexdigest");
+ rb_define_alias(cHMAC, "to_s", "hexdigest");
+}
+
+#else /* NO_HMAC */
+# warning >>> OpenSSL is compiled without HMAC support <<<
+void
+Init_ossl_hmac()
+{
+ rb_warning("HMAC will NOT be avaible: OpenSSL is compiled without HMAC.");
+}
+#endif /* NO_HMAC */
diff --git a/ext/openssl/ossl_hmac.h b/ext/openssl/ossl_hmac.h
new file mode 100644
index 0000000000..1a2978b39a
--- /dev/null
+++ b/ext/openssl/ossl_hmac.h
@@ -0,0 +1,19 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_HMAC_H_)
+#define _OSSL_HMAC_H_
+
+extern VALUE cHMAC;
+extern VALUE eHMACError;
+
+void Init_ossl_hmac(void);
+
+#endif /* _OSSL_HMAC_H_ */
diff --git a/ext/openssl/ossl_ns_spki.c b/ext/openssl/ossl_ns_spki.c
new file mode 100644
index 0000000000..9aed773edc
--- /dev/null
+++ b/ext/openssl/ossl_ns_spki.c
@@ -0,0 +1,230 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapSPKI(klass, obj, spki) do { \
+ if (!spki) { \
+ ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, NETSCAPE_SPKI_free, spki); \
+} while (0)
+#define GetSPKI(obj, spki) do { \
+ Data_Get_Struct(obj, NETSCAPE_SPKI, spki); \
+ if (!spki) { \
+ ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
+ } \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE mNetscape;
+VALUE cSPKI;
+VALUE eSPKIError;
+
+/*
+ * Public functions
+ */
+
+/*
+ * Private functions
+ */
+static VALUE
+ossl_spki_alloc(VALUE klass)
+{
+ NETSCAPE_SPKI *spki;
+ VALUE obj;
+
+ if (!(spki = NETSCAPE_SPKI_new())) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ WrapSPKI(klass, obj, spki);
+
+ return obj;
+}
+
+static VALUE
+ossl_spki_initialize(int argc, VALUE *argv, VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ VALUE buffer;
+
+ if (rb_scan_args(argc, argv, "01", &buffer) == 0) {
+ return self;
+ }
+ if (!(spki = NETSCAPE_SPKI_b64_decode(StringValuePtr(buffer), -1))) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ NETSCAPE_SPKI_free(DATA_PTR(self));
+ DATA_PTR(self) = spki;
+
+ return self;
+}
+
+static VALUE
+ossl_spki_to_pem(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ char *data;
+ VALUE str;
+
+ GetSPKI(self, spki);
+ if (!(data = NETSCAPE_SPKI_b64_encode(spki))) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ str = ossl_buf2str(data, strlen(data));
+
+ return str;
+}
+
+static VALUE
+ossl_spki_print(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetSPKI(self, spki);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ if (!NETSCAPE_SPKI_print(out, spki)) {
+ BIO_free(out);
+ ossl_raise(eSPKIError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+static VALUE
+ossl_spki_get_public_key(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ EVP_PKEY *pkey;
+
+ GetSPKI(self, spki);
+ if (!(pkey = NETSCAPE_SPKI_get_pubkey(spki))) { /* adds an reference */
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return ossl_pkey_new(pkey); /* NO DUP - OK */
+}
+
+static VALUE
+ossl_spki_set_public_key(VALUE self, VALUE key)
+{
+ NETSCAPE_SPKI *spki;
+
+ GetSPKI(self, spki);
+ if (!NETSCAPE_SPKI_set_pubkey(spki, GetPKeyPtr(key))) { /* NO NEED TO DUP */
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return key;
+}
+
+static VALUE
+ossl_spki_get_challenge(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+
+ GetSPKI(self, spki);
+ if (spki->spkac->challenge->length <= 0) {
+ OSSL_Debug("Challenge.length <= 0?");
+ return rb_str_new2(NULL);
+ }
+
+ return rb_str_new(spki->spkac->challenge->data,
+ spki->spkac->challenge->length);
+}
+
+static VALUE
+ossl_spki_set_challenge(VALUE self, VALUE str)
+{
+ NETSCAPE_SPKI *spki;
+
+ GetSPKI(self, spki);
+ StringValue(str);
+ if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING(str)->ptr,
+ RSTRING(str)->len)) {
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return str;
+}
+
+static VALUE
+ossl_spki_sign(VALUE self, VALUE key, VALUE digest)
+{
+ NETSCAPE_SPKI *spki;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ GetSPKI(self, spki);
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ if (!NETSCAPE_SPKI_sign(spki, pkey, md)) {
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
+ */
+static VALUE
+ossl_spki_verify(VALUE self, VALUE key)
+{
+ NETSCAPE_SPKI *spki;
+
+ GetSPKI(self, spki);
+ switch (NETSCAPE_SPKI_verify(spki, GetPKeyPtr(key))) { /* NO NEED TO DUP */
+ case 0:
+ return Qfalse;
+ case 1:
+ return Qtrue;
+ default:
+ ossl_raise(eSPKIError, NULL);
+ }
+ return Qnil; /* dummy */
+}
+
+/*
+ * NETSCAPE_SPKI init
+ */
+void
+Init_ossl_ns_spki()
+{
+ mNetscape = rb_define_module_under(mOSSL, "Netscape");
+
+ eSPKIError = rb_define_class_under(mNetscape, "SPKIError", eOSSLError);
+
+ cSPKI = rb_define_class_under(mNetscape, "SPKI", rb_cObject);
+
+ rb_define_alloc_func(cSPKI, ossl_spki_alloc);
+ rb_define_method(cSPKI, "initialize", ossl_spki_initialize, -1);
+
+ rb_define_method(cSPKI, "to_pem", ossl_spki_to_pem, 0);
+ rb_define_alias(cSPKI, "to_s", "to_pem");
+ rb_define_method(cSPKI, "to_text", ossl_spki_print, 0);
+ rb_define_method(cSPKI, "public_key", ossl_spki_get_public_key, 0);
+ rb_define_method(cSPKI, "public_key=", ossl_spki_set_public_key, 1);
+ rb_define_method(cSPKI, "sign", ossl_spki_sign, 2);
+ rb_define_method(cSPKI, "verify", ossl_spki_verify, 1);
+ rb_define_method(cSPKI, "challenge", ossl_spki_get_challenge, 0);
+ rb_define_method(cSPKI, "challenge=", ossl_spki_set_challenge, 1);
+}
+
diff --git a/ext/openssl/ossl_ns_spki.h b/ext/openssl/ossl_ns_spki.h
new file mode 100644
index 0000000000..9977035a9c
--- /dev/null
+++ b/ext/openssl/ossl_ns_spki.h
@@ -0,0 +1,21 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_NS_SPKI_H_)
+#define _OSSL_NS_SPKI_H_
+
+extern VALUE mNetscape;
+extern VALUE cSPKI;
+extern VALUE eSPKIError;
+
+void Init_ossl_ns_spki(void);
+
+#endif /* _OSSL_NS_SPKI_H_ */
+
diff --git a/ext/openssl/ossl_ocsp.c b/ext/openssl/ossl_ocsp.c
new file mode 100644
index 0000000000..d1f1b84127
--- /dev/null
+++ b/ext/openssl/ossl_ocsp.c
@@ -0,0 +1,765 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#if defined(OSSL_OCSP_ENABLED)
+
+#define WrapOCSPReq(klass, obj, req) do { \
+ if(!req) ossl_raise(rb_eRuntimeError, "Request wasn't initialized!"); \
+ obj = Data_Wrap_Struct(klass, 0, OCSP_REQUEST_free, req); \
+} while (0)
+#define GetOCSPReq(obj, req) do { \
+ Data_Get_Struct(obj, OCSP_REQUEST, req); \
+ if(!req) ossl_raise(rb_eRuntimeError, "Request wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPReq(obj, req) do { \
+ OSSL_Check_Kind(obj, cOCSPReq); \
+ GetOCSPReq(obj, req); \
+} while (0)
+
+#define WrapOCSPRes(klass, obj, res) do { \
+ if(!res) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+ obj = Data_Wrap_Struct(klass, 0, OCSP_RESPONSE_free, res); \
+} while (0)
+#define GetOCSPRes(obj, res) do { \
+ Data_Get_Struct(obj, OCSP_RESPONSE, res); \
+ if(!res) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPRes(obj, res) do { \
+ OSSL_Check_Kind(obj, cOCSPRes); \
+ GetOCSPRes(obj, res); \
+} while (0)
+
+#define WrapOCSPBasicRes(klass, obj, res) do { \
+ if(!res) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+ obj = Data_Wrap_Struct(klass, 0, OCSP_BASICRESP_free, res); \
+} while (0)
+#define GetOCSPBasicRes(obj, res) do { \
+ Data_Get_Struct(obj, OCSP_BASICRESP, res); \
+ if(!res) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPBasicRes(obj, res) do { \
+ OSSL_Check_Kind(obj, cOCSPBasicRes); \
+ GetOCSPBasicRes(obj, res); \
+} while (0)
+
+#define WrapOCSPCertId(klass, obj, cid) do { \
+ if(!cid) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
+ obj = Data_Wrap_Struct(klass, 0, OCSP_CERTID_free, cid); \
+} while (0)
+#define GetOCSPCertId(obj, cid) do { \
+ Data_Get_Struct(obj, OCSP_CERTID, cid); \
+ if(!cid) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPCertId(obj, cid) do { \
+ OSSL_Check_Kind(obj, cOCSPCertId); \
+ GetOCSPCertId(obj, cid); \
+} while (0)
+
+VALUE mOCSP;
+VALUE eOCSPError;
+VALUE cOCSPReq;
+VALUE cOCSPRes;
+VALUE cOCSPBasicRes;
+VALUE cOCSPCertId;
+
+/*
+ * Public
+ */
+static VALUE
+ossl_ocspcertid_new(OCSP_CERTID *cid)
+{
+ VALUE obj;
+ WrapOCSPCertId(cOCSPCertId, obj, cid);
+ return obj;
+}
+
+/*
+ * OCSP::Resquest
+ */
+static VALUE
+ossl_ocspreq_alloc(VALUE klass)
+{
+ OCSP_REQUEST *req;
+ VALUE obj;
+
+ if (!(req = OCSP_REQUEST_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPReq(klass, obj, req);
+
+ return obj;
+}
+
+static VALUE
+ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE arg;
+ unsigned char *p;
+
+ rb_scan_args(argc, argv, "01", &arg);
+ if(!NIL_P(arg)){
+ arg = ossl_to_der_if_possible(arg);
+ StringValue(arg);
+ p = (unsigned char*)RSTRING(arg)->ptr;
+ if(!d2i_OCSP_REQUEST((OCSP_REQUEST**)&DATA_PTR(self), &p,
+ RSTRING(arg)->len)){
+ ossl_raise(eOCSPError, "cannot load DER encoded request");
+ }
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self)
+{
+ OCSP_REQUEST *req;
+ VALUE val;
+ int ret;
+
+ rb_scan_args(argc, argv, "01", &val);
+ GetOCSPReq(self, req);
+ if(NIL_P(val))
+ ret = OCSP_request_add1_nonce(req, NULL, -1);
+ else{
+ StringValue(val);
+ ret = OCSP_request_add1_nonce(req, RSTRING(val)->ptr, RSTRING(val)->len);
+ }
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+/* Check nonce validity in a request and response.
+ * Return value reflects result:
+ * 1: nonces present and equal.
+ * 2: nonces both absent.
+ * 3: nonce present in response only.
+ * 0: nonces both present and not equal.
+ * -1: nonce in request only.
+ *
+ * For most responders clients can check return > 0.
+ * If responder doesn't handle nonces return != 0 may be
+ * necessary. return == 0 is always an error.
+ */
+static VALUE
+ossl_ocspreq_check_nonce(VALUE self, VALUE basic_resp)
+{
+ OCSP_REQUEST *req;
+ OCSP_BASICRESP *bs;
+ int res;
+
+ GetOCSPReq(self, req);
+ SafeGetOCSPBasicRes(basic_resp, bs);
+ res = OCSP_check_nonce(req, bs);
+
+ return INT2NUM(res);
+}
+
+static VALUE
+ossl_ocspreq_add_certid(VALUE self, VALUE certid)
+{
+ OCSP_REQUEST *req;
+ OCSP_CERTID *id;
+
+ GetOCSPReq(self, req);
+ GetOCSPCertId(certid, id);
+ if(!OCSP_request_add0_id(req, OCSP_CERTID_dup(id)))
+ ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_ocspreq_get_certid(VALUE self)
+{
+ OCSP_REQUEST *req;
+ OCSP_ONEREQ *one;
+ OCSP_CERTID *id;
+ VALUE ary, tmp;
+ int i, count;
+
+ GetOCSPReq(self, req);
+ count = OCSP_request_onereq_count(req);
+ ary = (count > 0) ? rb_ary_new() : Qnil;
+ for(i = 0; i < count; i++){
+ one = OCSP_request_onereq_get0(req, i);
+ if(!(id = OCSP_CERTID_dup(OCSP_onereq_get0_id(one))))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPCertId(cOCSPCertId, tmp, id);
+ rb_ary_push(ary, tmp);
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
+{
+ VALUE signer_cert, signer_key, certs, flags;
+ OCSP_REQUEST *req;
+ X509 *signer;
+ EVP_PKEY *key;
+ STACK_OF(X509) *x509s;
+ unsigned long flg;
+ int ret;
+
+ rb_scan_args(argc, argv, "22", &signer_cert, &signer_key, &certs, &flags);
+ GetOCSPReq(self, req);
+ signer = GetX509CertPtr(signer_cert);
+ key = GetPrivPKeyPtr(signer_key);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(certs)){
+ x509s = sk_X509_new_null();
+ flags |= OCSP_NOCERTS;
+ }
+ else x509s = ossl_x509_ary2sk(certs);
+ ret = OCSP_request_sign(req, signer, key, EVP_sha1(), x509s, flg);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_ocspreq_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE certs, store, flags;
+ OCSP_REQUEST *req;
+ STACK_OF(X509) *x509s;
+ X509_STORE *x509st;
+ int flg, result;
+
+ rb_scan_args(argc, argv, "21", &certs, &store, &flags);
+ GetOCSPReq(self, req);
+ x509st = GetX509StorePtr(store);
+ flg = NIL_P(flags) ? 0 : INT2NUM(flags);
+ x509s = ossl_x509_ary2sk(certs);
+ result = OCSP_request_verify(req, x509s, x509st, flg);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!result) rb_warn("%s", ERR_error_string(ERR_peek_error(), NULL));
+
+ return result ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_ocspreq_to_der(VALUE self)
+{
+ OCSP_REQUEST *req;
+ VALUE str;
+ unsigned char *p;
+ long len;
+
+ GetOCSPReq(self, req);
+
+ if((len = i2d_OCSP_REQUEST(req, NULL)) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_OCSP_REQUEST(req, &p) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * OCSP::Response
+ */
+static VALUE
+ossl_ocspres_s_create(VALUE klass, VALUE status, VALUE basic_resp)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_RESPONSE *res;
+ VALUE obj;
+
+ if(NIL_P(basic_resp)) bs = NULL;
+ else GetOCSPBasicRes(basic_resp, bs); /* NO NEED TO DUP */
+ if(!(res = OCSP_response_create(NUM2INT(status), bs)))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPRes(klass, obj, res);
+
+ return obj;
+}
+
+static VALUE
+ossl_ocspres_alloc(VALUE klass)
+{
+ OCSP_RESPONSE *res;
+ VALUE obj;
+
+ if(!(res = OCSP_RESPONSE_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPRes(klass, obj, res);
+
+ return obj;
+}
+
+static VALUE
+ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE arg;
+ unsigned char *p;
+
+ rb_scan_args(argc, argv, "01", &arg);
+ if(!NIL_P(arg)){
+ arg = ossl_to_der_if_possible(arg);
+ StringValue(arg);
+ p = RSTRING(arg)->ptr;
+ if(!d2i_OCSP_RESPONSE((OCSP_RESPONSE**)&DATA_PTR(self), &p,
+ RSTRING(arg)->len)){
+ ossl_raise(eOCSPError, "cannot load DER encoded response");
+ }
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_ocspres_status(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ int st;
+
+ GetOCSPRes(self, res);
+ st = OCSP_response_status(res);
+
+ return INT2NUM(st);
+}
+
+static VALUE
+ossl_ocspres_status_string(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ int st;
+
+ GetOCSPRes(self, res);
+ st = OCSP_response_status(res);
+
+ return rb_str_new2(OCSP_response_status_str(st));
+}
+
+static VALUE
+ossl_ocspres_get_basic(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ OCSP_BASICRESP *bs;
+ VALUE ret;
+
+ GetOCSPRes(self, res);
+ if(!(bs = OCSP_response_get1_basic(res)))
+ return Qnil;
+ WrapOCSPBasicRes(cOCSPBasicRes, ret, bs);
+
+ return ret;
+}
+
+static VALUE
+ossl_ocspres_to_der(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetOCSPRes(self, res);
+ if((len = i2d_OCSP_RESPONSE(res, NULL)) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_OCSP_RESPONSE(res, NULL) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * OCSP::BasicResponse
+ */
+static VALUE
+ossl_ocspbres_alloc(VALUE klass)
+{
+ OCSP_BASICRESP *bs;
+ VALUE obj;
+
+ if(!(bs = OCSP_BASICRESP_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPBasicRes(klass, obj, bs);
+
+ return obj;
+}
+
+static VALUE
+ossl_ocspbres_initialize(int argc, VALUE *argv, VALUE self)
+{
+ return self;
+}
+
+static VALUE
+ossl_ocspbres_copy_nonce(VALUE self, VALUE request)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_REQUEST *req;
+ int ret;
+
+ GetOCSPBasicRes(self, bs);
+ SafeGetOCSPReq(request, req);
+ ret = OCSP_copy_nonce(bs, req);
+
+ return INT2NUM(ret);
+}
+
+static VALUE
+ossl_ocspbres_add_nonce(int argc, VALUE *argv, VALUE self)
+{
+ OCSP_BASICRESP *bs;
+ VALUE val;
+ int ret;
+
+ GetOCSPBasicRes(self, bs);
+ rb_scan_args(argc, argv, "01", &val);
+ if(NIL_P(val))
+ ret = OCSP_basic_add1_nonce(bs, NULL, -1);
+ else{
+ StringValue(val);
+ ret = OCSP_basic_add1_nonce(bs, RSTRING(val)->ptr, RSTRING(val)->len);
+ }
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
+ VALUE reason, VALUE revtime,
+ VALUE thisupd, VALUE nextupd, VALUE ext)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_SINGLERESP *single;
+ OCSP_CERTID *id;
+ int st, rsn;
+ ASN1_TIME *ths, *nxt, *rev;
+ int error, i, rstatus = 0;
+ VALUE tmp;
+
+ GetOCSPBasicRes(self, bs);
+ SafeGetOCSPCertId(cid, id);
+ st = NUM2INT(status);
+ rsn = NIL_P(status) ? 0 : NUM2INT(reason);
+ if(!NIL_P(ext)){
+ /* All ary's members should be X509Extension */
+ Check_Type(ext, T_ARRAY);
+ for (i = 0; i < RARRAY(ext)->len; i++)
+ OSSL_Check_Kind(RARRAY(ext)->ptr[i], cX509Ext);
+ }
+
+ error = 0;
+ ths = nxt = rev = NULL;
+ if(!NIL_P(revtime)){
+ tmp = rb_protect(rb_Integer, revtime, &rstatus);
+ if(rstatus) goto err;
+ rev = X509_gmtime_adj(NULL, NUM2INT(tmp));
+ }
+ tmp = rb_protect(rb_Integer, thisupd, &rstatus);
+ if(rstatus) goto err;
+ ths = X509_gmtime_adj(NULL, NUM2INT(tmp));
+ tmp = rb_protect(rb_Integer, nextupd, &rstatus);
+ if(rstatus) goto err;
+ nxt = X509_gmtime_adj(NULL, NUM2INT(tmp));
+
+ if(!(single = OCSP_basic_add1_status(bs, id, st, rsn, rev, ths, nxt))){
+ error = 1;
+ goto err;
+ }
+
+ if(!NIL_P(ext)){
+ X509_EXTENSION *x509ext;
+ sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
+ single->singleExtensions = NULL;
+ for(i = 0; i < RARRAY(ext)->len; i++){
+ x509ext = DupX509ExtPtr(RARRAY(ext)->ptr[i]);
+ if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
+ X509_EXTENSION_free(x509ext);
+ error = 1;
+ goto err;
+ }
+ X509_EXTENSION_free(x509ext);
+ }
+ }
+
+ err:
+ ASN1_TIME_free(ths);
+ ASN1_TIME_free(nxt);
+ ASN1_TIME_free(rev);
+ if(error) ossl_raise(eOCSPError, NULL);
+ if(rstatus) rb_jump_tag(rstatus);
+
+ return self;
+}
+
+static VALUE
+ossl_ocspbres_get_status(VALUE self)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_SINGLERESP *single;
+ OCSP_CERTID *cid;
+ ASN1_TIME *revtime, *thisupd, *nextupd;
+ int status, reason;
+ X509_EXTENSION *x509ext;
+ VALUE ret, ary, ext;
+ int count, ext_count, i, j;
+
+ GetOCSPBasicRes(self, bs);
+ ret = rb_ary_new();
+ count = OCSP_resp_count(bs);
+ for(i = 0; i < count; i++){
+ single = OCSP_resp_get0(bs, i);
+ if(!single) continue;
+
+ revtime = thisupd = nextupd = NULL;
+ status = OCSP_single_get0_status(single, &reason, &revtime,
+ &thisupd, &nextupd);
+ if(status < 0) continue;
+ if(!(cid = OCSP_CERTID_dup(single->certId)))
+ ossl_raise(eOCSPError, NULL);
+ ary = rb_ary_new();
+ rb_ary_push(ary, ossl_ocspcertid_new(cid));
+ rb_ary_push(ary, INT2NUM(status));
+ rb_ary_push(ary, INT2NUM(reason));
+ rb_ary_push(ary, revtime ? asn1time_to_time(revtime) : Qnil);
+ rb_ary_push(ary, thisupd ? asn1time_to_time(thisupd) : Qnil);
+ rb_ary_push(ary, nextupd ? asn1time_to_time(nextupd) : Qnil);
+ ext = rb_ary_new();
+ ext_count = OCSP_SINGLERESP_get_ext_count(single);
+ for(j = 0; j < ext_count; j++){
+ x509ext = OCSP_SINGLERESP_get_ext(single, j);
+ rb_ary_push(ext, ossl_x509ext_new(x509ext));
+ }
+ rb_ary_push(ary, ext);
+ rb_ary_push(ret, ary);
+ }
+
+ return ret;
+}
+
+static VALUE
+ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self)
+{
+ VALUE signer_cert, signer_key, certs, flags;
+ OCSP_BASICRESP *bs;
+ X509 *signer;
+ EVP_PKEY *key;
+ STACK_OF(X509) *x509s;
+ unsigned long flg;
+ int ret;
+
+ rb_scan_args(argc, argv, "22", &signer_cert, &signer_key, &certs, &flags);
+ GetOCSPBasicRes(self, bs);
+ signer = GetX509CertPtr(signer_cert);
+ key = GetPrivPKeyPtr(signer_key);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(certs)){
+ x509s = sk_X509_new_null();
+ flg |= OCSP_NOCERTS;
+ }
+ else{
+ x509s = ossl_x509_ary2sk(certs);
+ }
+ ret = OCSP_basic_sign(bs, signer, key, EVP_sha1(), x509s, flg);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_ocspbres_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE certs, store, flags;
+ OCSP_BASICRESP *bs;
+ STACK_OF(X509) *x509s;
+ X509_STORE *x509st;
+ int flg, result;
+
+ rb_scan_args(argc, argv, "21", &certs, &store, &flags);
+ GetOCSPBasicRes(self, bs);
+ x509st = GetX509StorePtr(store);
+ flg = NIL_P(flags) ? 0 : INT2NUM(flags);
+ x509s = ossl_x509_ary2sk(certs);
+ result = OCSP_basic_verify(bs, x509s, x509st, flg);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!result) rb_warn("%s", ERR_error_string(ERR_peek_error(), NULL));
+
+ return result ? Qtrue : Qfalse;
+}
+
+/*
+ * OCSP::CertificateId
+ */
+static VALUE
+ossl_ocspcid_alloc(VALUE klass)
+{
+ OCSP_CERTID *id;
+ VALUE obj;
+
+ if(!(id = OCSP_CERTID_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPCertId(klass, obj, id);
+
+ return obj;
+}
+
+static VALUE
+ossl_ocspcid_initialize(VALUE self, VALUE subject, VALUE issuer)
+{
+ OCSP_CERTID *id, *newid;
+ X509 *x509s, *x509i;
+
+ GetOCSPCertId(self, id);
+ x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */
+ x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */
+ if(!(newid = OCSP_cert_to_id(NULL, x509s, x509i)))
+ ossl_raise(eOCSPError, NULL);
+ OCSP_CERTID_free(id);
+ RDATA(self)->data = newid;
+
+ return self;
+}
+
+static VALUE
+ossl_ocspcid_cmp(VALUE self, VALUE other)
+{
+ OCSP_CERTID *id, *id2;
+ int result;
+
+ GetOCSPCertId(self, id);
+ SafeGetOCSPCertId(other, id2);
+ result = OCSP_id_cmp(id, id2);
+
+ return (result == 0) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_ocspcid_cmp_issuer(VALUE self, VALUE other)
+{
+ OCSP_CERTID *id, *id2;
+ int result;
+
+ GetOCSPCertId(self, id);
+ SafeGetOCSPCertId(other, id2);
+ result = OCSP_id_issuer_cmp(id, id2);
+
+ return (result == 0) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_ocspcid_get_serial(VALUE self)
+{
+ OCSP_CERTID *id;
+
+ GetOCSPCertId(self, id);
+
+ return asn1integer_to_num(id->serialNumber);
+}
+
+void
+Init_ossl_ocsp()
+{
+ mOCSP = rb_define_module_under(mOSSL, "OCSP");
+
+ eOCSPError = rb_define_class_under(mOCSP, "OCSPError", rb_cObject);
+
+ cOCSPReq = rb_define_class_under(mOCSP, "Request", rb_cObject);
+ rb_define_alloc_func(cOCSPReq, ossl_ocspreq_alloc);
+ rb_define_method(cOCSPReq, "initialize", ossl_ocspreq_initialize, -1);
+ rb_define_method(cOCSPReq, "add_nonce", ossl_ocspreq_add_nonce, -1);
+ rb_define_method(cOCSPReq, "check_nonce", ossl_ocspreq_check_nonce, 1);
+ rb_define_method(cOCSPReq, "add_certid", ossl_ocspreq_add_certid, 1);
+ rb_define_method(cOCSPReq, "certid", ossl_ocspreq_get_certid, 0);
+ rb_define_method(cOCSPReq, "sign", ossl_ocspreq_sign, -1);
+ rb_define_method(cOCSPReq, "verify", ossl_ocspreq_verify, -1);
+ rb_define_method(cOCSPReq, "to_der", ossl_ocspreq_to_der, 0);
+
+ cOCSPRes = rb_define_class_under(mOCSP, "Response", rb_cObject);
+ rb_define_singleton_method(cOCSPRes, "create", ossl_ocspres_s_create, 2);
+ rb_define_alloc_func(cOCSPRes, ossl_ocspres_alloc);
+ rb_define_method(cOCSPRes, "initialize", ossl_ocspres_initialize, -1);
+ rb_define_method(cOCSPRes, "status", ossl_ocspres_status, 0);
+ rb_define_method(cOCSPRes, "status_string", ossl_ocspres_status_string, 0);
+ rb_define_method(cOCSPRes, "basic", ossl_ocspres_get_basic, 0);
+ rb_define_method(cOCSPRes, "to_der", ossl_ocspres_to_der, 0);
+
+ cOCSPBasicRes = rb_define_class_under(mOCSP, "BasicResponse", rb_cObject);
+ rb_define_alloc_func(cOCSPBasicRes, ossl_ocspbres_alloc);
+ rb_define_method(cOCSPBasicRes, "initialize", ossl_ocspbres_initialize, -1);
+ rb_define_method(cOCSPBasicRes, "copy_nonce", ossl_ocspbres_copy_nonce, 1);
+ rb_define_method(cOCSPBasicRes, "add_nonce", ossl_ocspbres_add_nonce, -1);
+ rb_define_method(cOCSPBasicRes, "add_status", ossl_ocspbres_add_status, 7);
+ rb_define_method(cOCSPBasicRes, "status", ossl_ocspbres_get_status, 0);
+ rb_define_method(cOCSPBasicRes, "sign", ossl_ocspbres_sign, -1);
+ rb_define_method(cOCSPBasicRes, "verify", ossl_ocspbres_verify, -1);
+
+ cOCSPCertId = rb_define_class_under(mOCSP, "CertificateId", rb_cObject);
+ rb_define_alloc_func(cOCSPCertId, ossl_ocspcid_alloc);
+ rb_define_method(cOCSPCertId, "initialize", ossl_ocspcid_initialize, 2);
+ rb_define_method(cOCSPCertId, "cmp", ossl_ocspcid_cmp, 1);
+ rb_define_method(cOCSPCertId, "cmp_issuer", ossl_ocspcid_cmp_issuer, 1);
+ rb_define_method(cOCSPCertId, "serial", ossl_ocspcid_get_serial, 0);
+
+#define DefOCSPConst(x) rb_define_const(mOCSP, #x, INT2NUM(OCSP_##x))
+
+ DefOCSPConst(RESPONSE_STATUS_SUCCESSFUL);
+ DefOCSPConst(RESPONSE_STATUS_MALFORMEDREQUEST);
+ DefOCSPConst(RESPONSE_STATUS_INTERNALERROR);
+ DefOCSPConst(RESPONSE_STATUS_TRYLATER);
+ DefOCSPConst(RESPONSE_STATUS_SIGREQUIRED);
+ DefOCSPConst(RESPONSE_STATUS_UNAUTHORIZED);
+
+ DefOCSPConst(REVOKED_STATUS_NOSTATUS);
+ DefOCSPConst(REVOKED_STATUS_UNSPECIFIED);
+ DefOCSPConst(REVOKED_STATUS_KEYCOMPROMISE);
+ DefOCSPConst(REVOKED_STATUS_CACOMPROMISE);
+ DefOCSPConst(REVOKED_STATUS_AFFILIATIONCHANGED);
+ DefOCSPConst(REVOKED_STATUS_SUPERSEDED);
+ DefOCSPConst(REVOKED_STATUS_CESSATIONOFOPERATION);
+ DefOCSPConst(REVOKED_STATUS_CERTIFICATEHOLD);
+ DefOCSPConst(REVOKED_STATUS_REMOVEFROMCRL);
+
+ DefOCSPConst(NOCERTS);
+ DefOCSPConst(NOINTERN);
+ DefOCSPConst(NOSIGS);
+ DefOCSPConst(NOCHAIN);
+ DefOCSPConst(NOVERIFY);
+ DefOCSPConst(NOEXPLICIT);
+ DefOCSPConst(NOCASIGN);
+ DefOCSPConst(NODELEGATED);
+ DefOCSPConst(NOCHECKS);
+ DefOCSPConst(TRUSTOTHER);
+ DefOCSPConst(RESPID_KEY);
+ DefOCSPConst(NOTIME);
+
+#define DefOCSPVConst(x) rb_define_const(mOCSP, "V_" #x, INT2NUM(V_OCSP_##x))
+
+ DefOCSPVConst(CERTSTATUS_GOOD);
+ DefOCSPVConst(CERTSTATUS_REVOKED);
+ DefOCSPVConst(CERTSTATUS_UNKNOWN);
+ DefOCSPVConst(RESPID_NAME);
+ DefOCSPVConst(RESPID_KEY);
+}
+
+#else /* ! OSSL_OCSP_ENABLED */
+void
+Init_ossl_ocsp()
+{
+}
+#endif
diff --git a/ext/openssl/ossl_ocsp.h b/ext/openssl/ossl_ocsp.h
new file mode 100644
index 0000000000..65b4f2e23f
--- /dev/null
+++ b/ext/openssl/ossl_ocsp.h
@@ -0,0 +1,24 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_OCSP_H_)
+#define _OSSL_OCSP_H_
+
+#if defined(OSSL_OCSP_ENABLED)
+extern VALUE mOCSP;
+extern VALUE cOPCSReq;
+extern VALUE cOPCSRes;
+extern VALUE cOPCSBasicRes;
+#endif
+
+void Init_ossl_ocsp(void);
+
+#endif /* _OSSL_OCSP_H_ */
diff --git a/ext/openssl/ossl_pkcs12.c b/ext/openssl/ossl_pkcs12.c
new file mode 100644
index 0000000000..e7d9954c5a
--- /dev/null
+++ b/ext/openssl/ossl_pkcs12.c
@@ -0,0 +1,154 @@
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ * $Id$
+ */
+#include "ossl.h"
+
+#define WrapPKCS12(klass, obj, p12) do { \
+ if(!p12) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
+ obj = Data_Wrap_Struct(klass, 0, PKCS12_free, p12); \
+} while (0)
+
+#define GetPKCS12(obj, p12) do { \
+ Data_Get_Struct(obj, PKCS12, p12); \
+ if(!p12) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
+} while (0)
+
+#define SafeGetPKCS12(obj, p12) do { \
+ OSSL_Check_Kind(obj, cPKCS12); \
+ GetPKCS12(obj, p12); \
+} while (0)
+
+#define ossl_pkcs12_set_key(o,v) rb_iv_set((o), "@key", (v))
+#define ossl_pkcs12_set_cert(o,v) rb_iv_set((o), "@certificate", (v))
+#define ossl_pkcs12_set_ca_certs(o,v) rb_iv_set((o), "@ca_certs", (v))
+#define ossl_pkcs12_get_key(o) rb_iv_get((o), "@key")
+#define ossl_pkcs12_get_cert(o) rb_iv_get((o), "@certificate")
+#define ossl_pkcs12_get_ca_certs(o) rb_iv_get((o), "@ca_certs")
+
+/*
+ * Classes
+ */
+VALUE mPKCS12;
+VALUE cPKCS12;
+VALUE ePKCS12Error;
+
+/*
+ * Private
+ */
+static VALUE
+ossl_pkcs12_s_allocate(VALUE klass)
+{
+ PKCS12 *p12;
+ VALUE obj;
+
+ if(!(p12 = PKCS12_new())) ossl_raise(ePKCS12Error, NULL);
+ WrapPKCS12(klass, obj, p12);
+
+ return obj;
+}
+
+static VALUE
+ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
+{
+ VALUE pass, name, pkey, cert, ca;
+ VALUE obj;
+ char *passphrase, *friendlyname;
+ EVP_PKEY *key;
+ X509 *x509;
+ STACK_OF(X509) *x509s;
+ PKCS12 *p12;
+
+ rb_scan_args(argc, argv, "41", &pass, &name, &pkey, &cert, &ca);
+ passphrase = NIL_P(pass) ? NULL : StringValuePtr(pass);
+ friendlyname = NIL_P(name) ? NULL : StringValuePtr(name);
+ key = GetPKeyPtr(pkey);
+ x509 = GetX509CertPtr(cert);
+ x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
+ p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
+ 0, 0, 0, 0, 0);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!p12) ossl_raise(ePKCS12Error, NULL);
+ WrapPKCS12(cPKCS12, obj, p12);
+
+ return obj;
+}
+
+static VALUE
+ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ VALUE arg, pass, pkey, cert, ca;
+ char *passphrase;
+ EVP_PKEY *key;
+ X509 *x509;
+ STACK_OF(X509) *x509s = NULL;
+ int st = 0;
+
+ if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) return self;
+ passphrase = NIL_P(pass) ? NULL : StringValuePtr(pass);
+ in = ossl_obj2bio(arg);
+ d2i_PKCS12_bio(in, (PKCS12 **)&DATA_PTR(self));
+ BIO_free(in);
+
+ pkey = cert = ca = Qnil;
+ if(!PKCS12_parse((PKCS12*)DATA_PTR(self), passphrase, &key, &x509, &x509s))
+ ossl_raise(ePKCS12Error, NULL);
+ pkey = rb_protect((VALUE(*)_((VALUE)))ossl_pkey_new, (VALUE)key,
+ &st); /* NO DUP */
+ if(st) goto err;
+ cert = rb_protect((VALUE(*)_((VALUE)))ossl_x509_new, (VALUE)x509, &st);
+ if(st) goto err;
+ if(x509s){
+ ca =
+ rb_protect((VALUE(*)_((VALUE)))ossl_x509_sk2ary, (VALUE)x509s, &st);
+ if(st) goto err;
+ }
+
+ err:
+ X509_free(x509);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_pkcs12_set_key(self, pkey);
+ ossl_pkcs12_set_cert(self, cert);
+ ossl_pkcs12_set_ca_certs(self, ca);
+ if(st) rb_jump_tag(st);
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs12_to_der(VALUE self)
+{
+ PKCS12 *p12;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetPKCS12(self, p12);
+ if((len = i2d_PKCS12(p12, NULL)) <= 0)
+ ossl_raise(ePKCS12Error, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_PKCS12(p12, &p) <= 0)
+ ossl_raise(ePKCS12Error, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+void
+Init_ossl_pkcs12()
+{
+ mPKCS12 = rb_define_module_under(mOSSL, "PKCS12");
+ cPKCS12 = rb_define_class_under(mPKCS12, "PKCS12", rb_cObject);
+ ePKCS12Error = rb_define_class_under(mPKCS12, "PKCS12Error", eOSSLError);
+ rb_define_module_function(mPKCS12, "create", ossl_pkcs12_s_create, -1);
+
+ rb_define_alloc_func(cPKCS12, ossl_pkcs12_s_allocate);
+ rb_attr(cPKCS12, rb_intern("key"), 1, 0, Qfalse);
+ rb_attr(cPKCS12, rb_intern("certificate"), 1, 0, Qfalse);
+ rb_attr(cPKCS12, rb_intern("ca_certs"), 1, 0, Qfalse);
+ rb_define_method(cPKCS12, "initialize", ossl_pkcs12_initialize, -1);
+ rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
+}
diff --git a/ext/openssl/ossl_pkcs12.h b/ext/openssl/ossl_pkcs12.h
new file mode 100644
index 0000000000..fa73c4bec5
--- /dev/null
+++ b/ext/openssl/ossl_pkcs12.h
@@ -0,0 +1,16 @@
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ * $Id$
+ */
+#if !defined(_OSSL_PKCS12_H_)
+#define _OSSL_PKCS7_H_
+
+extern VALUE mPKCS12;
+extern VALUE cPKCS12;
+extern VALUE ePKCS12Error;
+
+void Init_ossl_pkcs12(void);
+
+#endif /* _OSSL_PKCS12_H_ */
+
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
new file mode 100644
index 0000000000..57825e8bb1
--- /dev/null
+++ b/ext/openssl/ossl_pkcs7.c
@@ -0,0 +1,858 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapPKCS7(klass, obj, pkcs7) do { \
+ if (!pkcs7) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, PKCS7_free, pkcs7); \
+} while (0)
+#define GetPKCS7(obj, pkcs7) do { \
+ Data_Get_Struct(obj, PKCS7, pkcs7); \
+ if (!pkcs7) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetPKCS7(obj, pkcs7) do { \
+ OSSL_Check_Kind(obj, cPKCS7); \
+ GetPKCS7(obj, pkcs7); \
+} while (0)
+
+#define WrapPKCS7si(klass, obj, p7si) do { \
+ if (!p7si) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, PKCS7_SIGNER_INFO_free, p7si); \
+} while (0)
+#define GetPKCS7si(obj, p7si) do { \
+ Data_Get_Struct(obj, PKCS7_SIGNER_INFO, p7si); \
+ if (!p7si) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetPKCS7si(obj, p7si) do { \
+ OSSL_Check_Kind(obj, cPKCS7Signer); \
+ GetPKCS7si(obj, p7si); \
+} while (0)
+
+#define numberof(ary) (sizeof(ary)/sizeof(ary[0]))
+
+#define ossl_pkcs7_set_data(o,v) rb_iv_set((o), "@data", (v))
+#define ossl_pkcs7_get_data(o) rb_iv_get((o), "@data")
+#define ossl_pkcs7_set_err_string(o,v) rb_iv_set((o), "@error_string", (v))
+#define ossl_pkcs7_get_err_string(o) rb_iv_get((o), "@error_string")
+
+/*
+ * Classes
+ */
+VALUE mPKCS7;
+VALUE cPKCS7;
+VALUE cPKCS7Signer;
+VALUE ePKCS7Error;
+
+/*
+ * Public
+ * (MADE PRIVATE UNTIL SOMEBODY WILL NEED THEM)
+ */
+static VALUE
+ossl_pkcs7si_new(PKCS7_SIGNER_INFO *p7si)
+{
+ PKCS7_SIGNER_INFO *pkcs7;
+ VALUE obj;
+
+ pkcs7 = p7si ? PKCS7_SIGNER_INFO_dup(p7si) : PKCS7_SIGNER_INFO_new();
+ if (!pkcs7) ossl_raise(ePKCS7Error, NULL);
+ WrapPKCS7si(cPKCS7Signer, obj, pkcs7);
+
+ return obj;
+}
+
+static PKCS7_SIGNER_INFO *
+DupPKCS7SignerPtr(VALUE obj)
+{
+ PKCS7_SIGNER_INFO *p7si, *pkcs7;
+
+ SafeGetPKCS7si(obj, p7si);
+ if (!(pkcs7 = PKCS7_SIGNER_INFO_dup(p7si))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return pkcs7;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
+{
+ BIO *in, *out;
+ PKCS7 *pkcs7;
+ VALUE ret, data;
+
+ in = ossl_obj2bio(arg);
+ out = NULL;
+ pkcs7 = SMIME_read_PKCS7(in, &out);
+ BIO_free(in);
+ if(!pkcs7) ossl_raise(ePKCS7Error, NULL);
+ data = out ? ossl_membio2str(out) : Qnil;
+ WrapPKCS7(cPKCS7, ret, pkcs7);
+ ossl_pkcs7_set_data(ret, data);
+ ossl_pkcs7_set_err_string(ret, Qnil);
+
+ return ret;
+}
+
+static VALUE
+ossl_pkcs7_s_write_smime(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE pkcs7, data, flags;
+ BIO *out, *in;
+ PKCS7 *p7;
+ VALUE str;
+ int flg;
+
+ rb_scan_args(argc, argv, "12", &pkcs7, &data, &flags);
+ SafeGetPKCS7(pkcs7, p7);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(data)) data = ossl_pkcs7_get_data(pkcs7);
+ if(!NIL_P(data) && PKCS7_is_detached(p7))
+ flg |= PKCS7_DETACHED;
+ in = NIL_P(data) ? NULL : ossl_obj2bio(data);
+ if(!(out = BIO_new(BIO_s_mem()))){
+ BIO_free(in);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if(!SMIME_write_PKCS7(out, p7, in, flg)){
+ BIO_free(out);
+ BIO_free(in);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ BIO_free(in);
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+static VALUE
+ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE cert, key, data, certs, flags;
+ X509 *x509;
+ EVP_PKEY *pkey;
+ BIO *in;
+ STACK_OF(X509) *x509s;
+ int flg, status = 0;
+ PKCS7 *pkcs7;
+ VALUE ret;
+
+ rb_scan_args(argc, argv, "32", &cert, &key, &data, &certs, &flags);
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ in = ossl_obj2bio(data);
+ if(NIL_P(certs)) x509s = NULL;
+ else{
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
+ }
+ if(!(pkcs7 = PKCS7_sign(x509, pkey, x509s, in, flg))){
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ WrapPKCS7(cPKCS7, ret, pkcs7);
+ ossl_pkcs7_set_data(ret, data);
+ ossl_pkcs7_set_err_string(ret, Qnil);
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+
+ return ret;
+}
+
+static VALUE
+ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE certs, data, cipher, flags;
+ STACK_OF(X509) *x509s;
+ BIO *in;
+ const EVP_CIPHER *ciph;
+ int flg, status = 0;
+ VALUE ret;
+ PKCS7 *p7;
+
+ rb_scan_args(argc, argv, "22", &certs, &data, &cipher, &flags);
+ if(NIL_P(cipher)){
+#if !defined(OPENSSL_NO_RC2)
+ ciph = EVP_rc2_40_cbc();
+#elif !defined(OPENSSL_NO_DES)
+ ciph = EVP_des_ede3_cbc();
+#elif !defined(OPENSSL_NO_RC2)
+ ciph = EVP_rc2_40_cbc();
+#elif !defined(OPENSSL_NO_AES)
+ ciph = EVP_EVP_aes_128_cbc();
+#else
+ ossl_raise(ePKCS7Error, "Must specify cipher");
+#endif
+
+ }
+ else ciph = GetCipherPtr(cipher); /* NO NEED TO DUP */
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ in = ossl_obj2bio(data);
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
+ if(!(p7 = PKCS7_encrypt(x509s, in, (EVP_CIPHER*)ciph, flg))){
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ BIO_free(in);
+ WrapPKCS7(cPKCS7, ret, p7);
+ ossl_pkcs7_set_data(ret, data);
+ sk_X509_pop_free(x509s, X509_free);
+
+ return ret;
+}
+
+static VALUE
+ossl_pkcs7_alloc(VALUE klass)
+{
+ PKCS7 *pkcs7;
+ VALUE obj;
+
+ if (!(pkcs7 = PKCS7_new())) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ WrapPKCS7(klass, obj, pkcs7);
+
+ return obj;
+}
+
+static VALUE
+ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
+{
+ PKCS7 *p7;
+ BIO *in;
+ VALUE arg;
+
+ if(rb_scan_args(argc, argv, "01", &arg) == 0)
+ return self;
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ p7 = PEM_read_bio_PKCS7(in, (PKCS7 **)&DATA_PTR(self), NULL, NULL);
+ if (!p7) {
+ BIO_reset(in);
+ p7 = d2i_PKCS7_bio(in, (PKCS7 **)&DATA_PTR(self));
+ }
+ BIO_free(in);
+ ossl_pkcs7_set_data(self, Qnil);
+ ossl_pkcs7_set_err_string(self, Qnil);
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_copy(VALUE self, VALUE other)
+{
+ PKCS7 *a, *b, *pkcs7;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetPKCS7(self, a);
+ SafeGetPKCS7(other, b);
+
+ pkcs7 = PKCS7_dup(b);
+ if (!pkcs7) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ DATA_PTR(self) = pkcs7;
+ PKCS7_free(a);
+
+ return self;
+}
+
+static int
+ossl_pkcs7_sym2typeid(VALUE sym)
+{
+ int i, ret = Qnil;
+ char *s;
+
+ static struct {
+ const char *name;
+ int nid;
+ } p7_type_tab[] = {
+ { "signed", NID_pkcs7_signed },
+ { "data", NID_pkcs7_data },
+ { "signedAndEnveloped", NID_pkcs7_signedAndEnveloped },
+ { "enveloped", NID_pkcs7_enveloped },
+ { "encrypted", NID_pkcs7_encrypted },
+ { "digest", NID_pkcs7_digest },
+ { NULL, 0 },
+ };
+
+ if(TYPE(sym) == T_SYMBOL) s = rb_id2name(SYM2ID(sym));
+ else s = StringValuePtr(sym);
+ for(i = 0; i < numberof(p7_type_tab); i++){
+ if(p7_type_tab[i].name == NULL)
+ ossl_raise(ePKCS7Error, "unknown type \"%s\"", s);
+ if(strcmp(p7_type_tab[i].name, s) == 0){
+ ret = p7_type_tab[i].nid;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static VALUE
+ossl_pkcs7_set_type(VALUE self, VALUE type)
+{
+ PKCS7 *p7;
+
+ GetPKCS7(self, p7);
+ if(!PKCS7_set_type(p7, ossl_pkcs7_sym2typeid(type)))
+ ossl_raise(ePKCS7Error, NULL);
+
+ return type;
+}
+
+static VALUE
+ossl_pkcs7_get_type(VALUE self)
+{
+ PKCS7 *p7;
+
+ GetPKCS7(self, p7);
+ if(PKCS7_type_is_signed(p7))
+ return ID2SYM(rb_intern("signed"));
+ if(PKCS7_type_is_encrypted(p7))
+ return ID2SYM(rb_intern("encrypted"));
+ if(PKCS7_type_is_enveloped(p7))
+ return ID2SYM(rb_intern("enveloped"));
+ if(PKCS7_type_is_signedAndEnveloped(p7))
+ return ID2SYM(rb_intern("signedAndEnveloped"));
+ if(PKCS7_type_is_data(p7))
+ return ID2SYM(rb_intern("data"));
+ return Qnil;
+}
+
+static VALUE
+ossl_pkcs7_set_detached(VALUE self, VALUE flag)
+{
+ PKCS7 *p7;
+
+ GetPKCS7(self, p7);
+ if(flag != Qtrue && flag != Qfalse)
+ ossl_raise(ePKCS7Error, "must specify a boolean");
+ if(!PKCS7_set_detached(p7, flag == Qtrue ? 1 : 0))
+ ossl_raise(ePKCS7Error, NULL);
+
+ return flag;
+}
+
+static VALUE
+ossl_pkcs7_get_detached(VALUE self)
+{
+ PKCS7 *p7;
+ GetPKCS7(self, p7);
+ return PKCS7_get_detached(p7) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_pkcs7_detached_p(VALUE self)
+{
+ PKCS7 *p7;
+ GetPKCS7(self, p7);
+ return PKCS7_is_detached(p7) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_pkcs7_set_cipher(VALUE self, VALUE cipher)
+{
+ PKCS7 *pkcs7;
+
+ GetPKCS7(self, pkcs7);
+ if (!PKCS7_set_cipher(pkcs7, GetCipherPtr(cipher))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return cipher;
+}
+
+static VALUE
+ossl_pkcs7_add_signer(VALUE self, VALUE signer)
+{
+ PKCS7 *pkcs7;
+ PKCS7_SIGNER_INFO *p7si;
+
+ GetPKCS7(self, pkcs7);
+ p7si = DupPKCS7SignerPtr(signer); /* NEED TO DUP */
+ if (!PKCS7_add_signer(pkcs7, p7si)) {
+ PKCS7_SIGNER_INFO_free(p7si);
+ ossl_raise(ePKCS7Error, "Could not add signer.");
+ }
+ if (PKCS7_type_is_signed(pkcs7)){
+ PKCS7_add_signed_attribute(p7si, NID_pkcs9_contentType,
+ V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data));
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_get_signer(VALUE self)
+{
+ PKCS7 *pkcs7;
+ STACK_OF(PKCS7_SIGNER_INFO) *sk;
+ PKCS7_SIGNER_INFO *si;
+ int num, i;
+ VALUE ary;
+
+ GetPKCS7(self, pkcs7);
+ if (!(sk = PKCS7_get_signer_info(pkcs7))) {
+ OSSL_Debug("OpenSSL::PKCS7#get_signer_info == NULL!");
+ return rb_ary_new();
+ }
+ if ((num = sk_PKCS7_SIGNER_INFO_num(sk)) < 0) {
+ ossl_raise(ePKCS7Error, "Negative number of signers!");
+ }
+ ary = rb_ary_new2(num);
+ for (i=0; i<num; i++) {
+ si = sk_PKCS7_SIGNER_INFO_value(sk, i);
+ rb_ary_push(ary, ossl_pkcs7si_new(si));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_pkcs7_add_recipient(VALUE self, VALUE cert)
+{
+ PKCS7 *pkcs7;
+ PKCS7_RECIP_INFO *ri;
+ X509 *x509;
+
+ GetPKCS7(self, pkcs7);
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ if (!(ri = PKCS7_RECIP_INFO_new())) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if (!PKCS7_RECIP_INFO_set(ri, x509)) {
+ PKCS7_RECIP_INFO_free(ri);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if (!PKCS7_add_recipient_info(pkcs7, ri)) {
+ PKCS7_RECIP_INFO_free(ri);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_add_certificate(VALUE self, VALUE cert)
+{
+ PKCS7 *pkcs7;
+ X509 *x509;
+
+ GetPKCS7(self, pkcs7);
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ if (!PKCS7_add_certificate(pkcs7, x509)){
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static STACK *
+pkcs7_get_certs_or_crls(VALUE self, int want_certs)
+{
+ PKCS7 *pkcs7;
+ STACK_OF(X509) *certs;
+ STACK_OF(X509_CRL) *crls;
+ int i;
+
+ GetPKCS7(self, pkcs7);
+ i = OBJ_obj2nid(pkcs7->type);
+ switch(i){
+ case NID_pkcs7_signed:
+ certs = pkcs7->d.sign->cert;
+ crls = pkcs7->d.sign->crl;
+ break;
+ case NID_pkcs7_signedAndEnveloped:
+ certs = pkcs7->d.signed_and_enveloped->cert;
+ crls = pkcs7->d.signed_and_enveloped->crl;
+ break;
+ default:
+ certs = crls = NULL;
+ }
+
+ return want_certs ? certs : crls;
+}
+
+static VALUE
+ossl_pkcs7_set_certs_i(VALUE i, VALUE arg)
+{
+ return ossl_pkcs7_add_certificate(arg, i);
+}
+
+static VALUE
+ossl_pkcs7_set_certificates(VALUE self, VALUE ary)
+{
+ STACK_OF(X509) *certs;
+ X509 *cert;
+
+ certs = pkcs7_get_certs_or_crls(self, 1);
+ while((cert = sk_X509_pop(certs))) X509_free(cert);
+ rb_iterate(rb_each, ary, ossl_pkcs7_set_certs_i, self);
+
+ return ary;
+}
+
+static VALUE
+ossl_pkcs7_get_certificates(VALUE self)
+{
+ return ossl_x509_sk2ary(pkcs7_get_certs_or_crls(self, 1));
+}
+
+static VALUE
+ossl_pkcs7_add_crl(VALUE self, VALUE crl)
+{
+ PKCS7 *pkcs7;
+ X509_CRL *x509crl;
+
+ GetPKCS7(self, pkcs7); /* NO DUP needed! */
+ x509crl = GetX509CRLPtr(crl);
+ if (!PKCS7_add_crl(pkcs7, x509crl)) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_set_crls_i(VALUE i, VALUE arg)
+{
+ return ossl_pkcs7_add_crl(arg, i);
+}
+
+static VALUE
+ossl_pkcs7_set_crls(VALUE self, VALUE ary)
+{
+ STACK_OF(X509_CRL) *crls;
+ X509_CRL *crl;
+
+ crls = pkcs7_get_certs_or_crls(self, 0);
+ while((crl = sk_X509_CRL_pop(crls))) X509_CRL_free(crl);
+ rb_iterate(rb_each, ary, ossl_pkcs7_set_crls_i, self);
+
+ return ary;
+}
+
+static VALUE
+ossl_pkcs7_get_crls(VALUE self)
+{
+ return ossl_x509crl_sk2ary(pkcs7_get_certs_or_crls(self, 0));
+}
+
+static VALUE
+ossl_pkcs7_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE certs, store, indata, flags;
+ STACK_OF(X509) *x509s;
+ X509_STORE *x509st;
+ int flg, ok, status = 0;
+ BIO *in, *out;
+ PKCS7 *p7;
+ VALUE data;
+ const char *msg;
+
+ GetPKCS7(self, p7);
+ rb_scan_args(argc, argv, "22", &certs, &store, &indata, &flags);
+ x509st = GetX509StorePtr(store);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(indata)) indata = ossl_pkcs7_get_data(self);
+ in = NIL_P(indata) ? NULL : ossl_obj2bio(indata);
+ if(NIL_P(certs)) x509s = NULL;
+ else{
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
+ }
+ if(!(out = BIO_new(BIO_s_mem()))){
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ ok = PKCS7_verify(p7, x509s, x509st, in, out, flg);
+ BIO_free(in);
+ msg = ERR_reason_error_string(ERR_get_error());
+ ossl_pkcs7_set_err_string(self, msg ? rb_str_new2(msg) : Qnil);
+ data = ossl_membio2str(out);
+ ossl_pkcs7_set_data(self, data);
+ sk_X509_pop_free(x509s, X509_free);
+
+ return (ok == 1) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_pkcs7_decrypt(int argc, VALUE *argv, VALUE self)
+{
+ VALUE pkey, cert, flags;
+ EVP_PKEY *key;
+ X509 *x509;
+ int flg;
+ PKCS7 *p7;
+ BIO *out;
+ VALUE str;
+
+ rb_scan_args(argc, argv, "21", &pkey, &cert, &flags);
+ GetPKCS7(self, p7);
+ key = GetPrivPKeyPtr(pkey); /* NO NEED TO DUP */
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(ePKCS7Error, NULL);
+ if(!PKCS7_decrypt(p7, key, x509, out, flg)){
+ BIO_free(out);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ str = ossl_membio2str(out); /* out will be free */
+
+ return str;
+}
+
+static VALUE
+ossl_pkcs7_add_data(VALUE self, VALUE data)
+{
+ PKCS7 *pkcs7;
+ BIO *out, *in;
+ char buf[4096];
+ int len;
+
+ in = out = NULL;
+ GetPKCS7(self, pkcs7);
+ if(PKCS7_type_is_signed(pkcs7)){
+ if(!PKCS7_content_new(pkcs7, NID_pkcs7_data))
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ in = ossl_obj2bio(data);
+ if(!(out = PKCS7_dataInit(pkcs7, NULL))) goto err;
+ for(;;){
+ if((len = BIO_read(in, buf, sizeof(buf))) <= 0)
+ break;
+ if(BIO_write(out, buf, len) != len)
+ goto err;
+ }
+ if(!PKCS7_dataFinal(pkcs7, out)) goto err;
+ ossl_pkcs7_set_data(self, Qnil);
+
+ err:
+ BIO_free(out);
+ BIO_free(in);
+ if(ERR_peek_error()){
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return data;
+}
+
+static VALUE
+ossl_pkcs7_to_der(VALUE self)
+{
+ PKCS7 *pkcs7;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetPKCS7(self, pkcs7);
+ if((len = i2d_PKCS7(pkcs7, NULL)) <= 0)
+ ossl_raise(ePKCS7Error, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_PKCS7(pkcs7, &p) <= 0)
+ ossl_raise(ePKCS7Error, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+static VALUE
+ossl_pkcs7_to_pem(VALUE self)
+{
+ PKCS7 *pkcs7;
+ BIO *out;
+ VALUE str;
+
+ GetPKCS7(self, pkcs7);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if (!PEM_write_bio_PKCS7(out, pkcs7)) {
+ BIO_free(out);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * SIGNER INFO
+ */
+static VALUE
+ossl_pkcs7si_alloc(VALUE klass)
+{
+ PKCS7_SIGNER_INFO *p7si;
+ VALUE obj;
+
+ if (!(p7si = PKCS7_SIGNER_INFO_new())) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ WrapPKCS7si(klass, obj, p7si);
+
+ return obj;
+}
+
+static VALUE
+ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest)
+{
+ PKCS7_SIGNER_INFO *p7si;
+ EVP_PKEY *pkey;
+ X509 *x509;
+ const EVP_MD *md;
+
+ GetPKCS7si(self, p7si);
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ if (!(PKCS7_SIGNER_INFO_set(p7si, x509, pkey, (EVP_MD*)md))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7si_get_name(VALUE self)
+{
+ PKCS7_SIGNER_INFO *p7si;
+
+ GetPKCS7si(self, p7si);
+
+ return ossl_x509name_new(p7si->issuer_and_serial->issuer);
+}
+
+static VALUE
+ossl_pkcs7si_get_serial(VALUE self)
+{
+ PKCS7_SIGNER_INFO *p7si;
+
+ GetPKCS7si(self, p7si);
+
+ return asn1integer_to_num(p7si->issuer_and_serial->serial);
+}
+
+static VALUE
+ossl_pkcs7si_get_signed_time(VALUE self)
+{
+ PKCS7_SIGNER_INFO *p7si;
+ ASN1_TYPE *asn1obj;
+
+ GetPKCS7si(self, p7si);
+
+ if (!(asn1obj = PKCS7_get_signed_attribute(p7si, NID_pkcs9_signingTime))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if (asn1obj->type == V_ASN1_UTCTIME) {
+ return asn1time_to_time(asn1obj->value.utctime);
+ }
+ /*
+ * OR
+ * ossl_raise(ePKCS7Error, "...");
+ * ?
+ */
+
+ return Qnil;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_pkcs7()
+{
+ mPKCS7 = rb_define_module_under(mOSSL, "PKCS7");
+
+ ePKCS7Error = rb_define_class_under(mPKCS7, "PKCS7Error", eOSSLError);
+
+ cPKCS7 = rb_define_class_under(mPKCS7, "PKCS7", rb_cObject);
+ rb_define_singleton_method(mPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1);
+ rb_define_singleton_method(mPKCS7, "write_smime", ossl_pkcs7_s_write_smime, -1);
+ rb_define_singleton_method(mPKCS7, "sign", ossl_pkcs7_s_sign, -1);
+ rb_define_singleton_method(mPKCS7, "encrypt", ossl_pkcs7_s_encrypt, -1);
+ rb_attr(cPKCS7, rb_intern("data"), 1, 0, Qfalse);
+ rb_attr(cPKCS7, rb_intern("error_string"), 1, 1, Qfalse);
+ rb_define_alloc_func(cPKCS7, ossl_pkcs7_alloc);
+ rb_define_copy_func(cPKCS7, ossl_pkcs7_copy);
+ rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, -1);
+ rb_define_method(cPKCS7, "type=", ossl_pkcs7_set_type, 1);
+ rb_define_method(cPKCS7, "type", ossl_pkcs7_get_type, 0);
+ rb_define_method(cPKCS7, "detached=", ossl_pkcs7_set_detached, 1);
+ rb_define_method(cPKCS7, "detached", ossl_pkcs7_get_detached, 0);
+ rb_define_method(cPKCS7, "detached?", ossl_pkcs7_detached_p, 0);
+ rb_define_method(cPKCS7, "cipher=", ossl_pkcs7_set_cipher, 1);
+ rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 1);
+ rb_define_method(cPKCS7, "signers", ossl_pkcs7_get_signer, 0);
+ rb_define_method(cPKCS7, "add_recipient", ossl_pkcs7_add_recipient, 1);
+ rb_define_method(cPKCS7, "add_certificate", ossl_pkcs7_add_certificate, 1);
+ rb_define_method(cPKCS7, "certificates=", ossl_pkcs7_set_certificates, 1);
+ rb_define_method(cPKCS7, "certificates", ossl_pkcs7_get_certificates, 0);
+ rb_define_method(cPKCS7, "add_crl", ossl_pkcs7_add_crl, 1);
+ rb_define_method(cPKCS7, "crls=", ossl_pkcs7_set_crls, 1);
+ rb_define_method(cPKCS7, "crls", ossl_pkcs7_get_crls, 0);
+ rb_define_method(cPKCS7, "add_data", ossl_pkcs7_add_data, 1);
+ rb_define_alias(cPKCS7, "data=", "add_data");
+ rb_define_method(cPKCS7, "verify", ossl_pkcs7_verify, -1);
+ rb_define_method(cPKCS7, "decrypt", ossl_pkcs7_decrypt, -1);
+ rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0);
+ rb_define_alias(cPKCS7, "to_s", "to_pem");
+ rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0);
+
+ cPKCS7Signer = rb_define_class_under(mPKCS7, "Signer", rb_cObject);
+ rb_define_alloc_func(cPKCS7Signer, ossl_pkcs7si_alloc);
+ rb_define_method(cPKCS7Signer, "initialize", ossl_pkcs7si_initialize,3);
+ rb_define_method(cPKCS7Signer, "name", ossl_pkcs7si_get_name,0);
+ rb_define_method(cPKCS7Signer, "serial", ossl_pkcs7si_get_serial,0);
+ rb_define_method(cPKCS7Signer, "signed_time", ossl_pkcs7si_get_signed_time,0);
+
+#define DefPKCS7Const(x) rb_define_const(mPKCS7, #x, INT2NUM(PKCS7_##x))
+
+ DefPKCS7Const(TEXT);
+ DefPKCS7Const(NOCERTS);
+ DefPKCS7Const(NOSIGS);
+ DefPKCS7Const(NOCHAIN);
+ DefPKCS7Const(NOINTERN);
+ DefPKCS7Const(NOVERIFY);
+ DefPKCS7Const(DETACHED);
+ DefPKCS7Const(BINARY);
+ DefPKCS7Const(NOATTR);
+ DefPKCS7Const(NOSMIMECAP);
+}
diff --git a/ext/openssl/ossl_pkcs7.h b/ext/openssl/ossl_pkcs7.h
new file mode 100644
index 0000000000..9378397f25
--- /dev/null
+++ b/ext/openssl/ossl_pkcs7.h
@@ -0,0 +1,22 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_PKCS7_H_)
+#define _OSSL_PKCS7_H_
+
+extern VALUE mPKCS7;
+extern VALUE cPKCS7;
+extern VALUE cPKCS7SignerInfo;
+extern VALUE ePKCS7Error;
+
+void Init_ossl_pkcs7(void);
+
+#endif /* _OSSL_PKCS7_H_ */
+
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
new file mode 100644
index 0000000000..1a38a2c1d7
--- /dev/null
+++ b/ext/openssl/ossl_pkey.c
@@ -0,0 +1,221 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+/*
+ * Classes
+ */
+VALUE mPKey;
+VALUE cPKey;
+VALUE ePKeyError;
+ID id_private_q;
+
+/*
+ * callback for generating keys
+ */
+void
+ossl_generate_cb(int p, int n, void *arg)
+{
+ VALUE ary;
+
+ ary = rb_ary_new2(2);
+ rb_ary_store(ary, 0, INT2NUM(p));
+ rb_ary_store(ary, 1, INT2NUM(n));
+
+ rb_yield(ary);
+}
+
+/*
+ * Public
+ */
+VALUE
+ossl_pkey_new(EVP_PKEY *pkey)
+{
+ if (!pkey) {
+ ossl_raise(ePKeyError, "Cannot make new key from NULL.");
+ }
+ switch (EVP_PKEY_type(pkey->type)) {
+#if !defined(OPENSSL_NO_RSA)
+ case EVP_PKEY_RSA:
+ return ossl_rsa_new(pkey);
+#endif
+#if !defined(OPENSSL_NO_DSA)
+ case EVP_PKEY_DSA:
+ return ossl_dsa_new(pkey);
+#endif
+#if !defined(OPENSSL_NO_DH)
+ case EVP_PKEY_DH:
+ return ossl_dh_new(pkey);
+#endif
+ default:
+ ossl_raise(ePKeyError, "unsupported key type");
+ }
+ return Qnil; /* not reached */
+}
+
+VALUE
+ossl_pkey_new_from_file(VALUE filename)
+{
+ FILE *fp;
+ EVP_PKEY *pkey;
+
+ SafeStringValue(filename);
+ if (!(fp = fopen(RSTRING(filename)->ptr, "r"))) {
+ ossl_raise(ePKeyError, "%s", strerror(errno));
+ }
+
+ pkey = PEM_read_PrivateKey(fp, NULL, ossl_pem_passwd_cb, NULL);
+ fclose(fp);
+ if (!pkey) {
+ ossl_raise(ePKeyError, NULL);
+ }
+
+ return ossl_pkey_new(pkey);
+}
+
+EVP_PKEY *
+GetPKeyPtr(VALUE obj)
+{
+ EVP_PKEY *pkey;
+
+ SafeGetPKey(obj, pkey);
+
+ return pkey;
+}
+
+EVP_PKEY *
+GetPrivPKeyPtr(VALUE obj)
+{
+ EVP_PKEY *pkey;
+
+ SafeGetPKey(obj, pkey);
+ if (rb_funcall(obj, id_private_q, 0, NULL) != Qtrue) { /* returns Qtrue */
+ ossl_raise(rb_eArgError, "Private key is needed.");
+ }
+
+ return pkey;
+}
+
+EVP_PKEY *
+DupPrivPKeyPtr(VALUE obj)
+{
+ EVP_PKEY *pkey;
+
+ SafeGetPKey(obj, pkey);
+ if (rb_funcall(obj, id_private_q, 0, NULL) != Qtrue) { /* returns Qtrue */
+ ossl_raise(rb_eArgError, "Private key is needed.");
+ }
+ CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+
+ return pkey;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_pkey_alloc(VALUE klass)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!(pkey = EVP_PKEY_new())) {
+ ossl_raise(ePKeyError, NULL);
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+static VALUE
+ossl_pkey_initialize(VALUE self)
+{
+ if (rb_obj_is_instance_of(self, cPKey)) {
+ ossl_raise(rb_eNotImpError, "OpenSSL::PKey::PKey is an abstract class.");
+ }
+ return self;
+}
+
+static VALUE
+ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
+{
+ EVP_PKEY *pkey;
+ EVP_MD_CTX ctx;
+ int buf_len;
+ VALUE str;
+
+ GetPKey(self, pkey);
+ if (rb_funcall(self, id_private_q, 0, NULL) != Qtrue) {
+ ossl_raise(rb_eArgError, "Private key is needed.");
+ }
+ EVP_SignInit(&ctx, GetDigestPtr(digest));
+ StringValue(data);
+ EVP_SignUpdate(&ctx, RSTRING(data)->ptr, RSTRING(data)->len);
+ str = rb_str_new(0, EVP_PKEY_size(pkey)+16);
+ if (!EVP_SignFinal(&ctx, RSTRING(str)->ptr, &buf_len, pkey))
+ ossl_raise(ePKeyError, NULL);
+ assert(buf_len <= RSTRING(str)->len);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
+
+ return str;
+}
+
+static VALUE
+ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
+{
+ EVP_PKEY *pkey;
+ EVP_MD_CTX ctx;
+
+ GetPKey(self, pkey);
+ EVP_VerifyInit(&ctx, GetDigestPtr(digest));
+ StringValue(sig);
+ StringValue(data);
+ EVP_VerifyUpdate(&ctx, RSTRING(data)->ptr, RSTRING(data)->len);
+ switch (EVP_VerifyFinal(&ctx, RSTRING(sig)->ptr, RSTRING(sig)->len, pkey)) {
+ case 0:
+ return Qfalse;
+ case 1:
+ return Qtrue;
+ default:
+ ossl_raise(ePKeyError, NULL);
+ }
+ return Qnil; /* dummy */
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_pkey()
+{
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+
+ ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
+
+ cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
+
+ rb_define_alloc_func(cPKey, ossl_pkey_alloc);
+ rb_define_method(cPKey, "initialize", ossl_pkey_initialize, 0);
+
+ rb_define_method(cPKey, "sign", ossl_pkey_sign, 2);
+ rb_define_method(cPKey, "verify", ossl_pkey_verify, 3);
+
+ id_private_q = rb_intern("private?");
+
+ /*
+ * INIT rsa, dsa
+ */
+ Init_ossl_rsa();
+ Init_ossl_dsa();
+ Init_ossl_dh();
+}
+
diff --git a/ext/openssl/ossl_pkey.h b/ext/openssl/ossl_pkey.h
new file mode 100644
index 0000000000..189573546e
--- /dev/null
+++ b/ext/openssl/ossl_pkey.h
@@ -0,0 +1,113 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_PKEY_H_)
+#define _OSSL_PKEY_H_
+
+extern VALUE mPKey;
+extern VALUE cPKey;
+extern VALUE ePKeyError;
+extern ID id_private_q;
+
+#define WrapPKey(klass, obj, pkey) do { \
+ if (!pkey) { \
+ rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, EVP_PKEY_free, pkey); \
+} while (0)
+#define GetPKey(obj, pkey) do {\
+ Data_Get_Struct(obj, EVP_PKEY, pkey);\
+ if (!pkey) { \
+ rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
+ } \
+} while (0)
+#define SafeGetPKey(obj, pkey) do { \
+ OSSL_Check_Kind(obj, cPKey); \
+ GetPKey(obj, pkey); \
+} while (0)
+
+void ossl_generate_cb(int, int, void *);
+
+VALUE ossl_pkey_new(EVP_PKEY *);
+VALUE ossl_pkey_new_from_file(VALUE);
+EVP_PKEY *GetPKeyPtr(VALUE);
+/*EVP_PKEY *DupPKeyPtr(VALUE);*/
+EVP_PKEY *GetPrivPKeyPtr(VALUE);
+EVP_PKEY *DupPrivPKeyPtr(VALUE);
+void Init_ossl_pkey(void);
+
+/*
+ * RSA
+ */
+extern VALUE cRSA;
+extern VALUE eRSAError;
+
+VALUE ossl_rsa_new(EVP_PKEY *);
+void Init_ossl_rsa(void);
+
+/*
+ * DSA
+ */
+extern VALUE cDSA;
+extern VALUE eDSAError;
+
+VALUE ossl_dsa_new(EVP_PKEY *);
+void Init_ossl_dsa(void);
+
+/*
+ * DH
+ */
+extern VALUE cDH;
+extern VALUE eDHError;
+
+VALUE ossl_dh_new(EVP_PKEY *);
+void Init_ossl_dh(void);
+
+#define OSSL_PKEY_BN(keytype, name) \
+static VALUE ossl_##keytype##_get_##name(VALUE self) \
+{ \
+ EVP_PKEY *pkey; \
+ BIGNUM *bn; \
+ \
+ GetPKey(self, pkey); \
+ bn = pkey->pkey.keytype->name; \
+ if (bn == NULL) \
+ return Qnil; \
+ return ossl_bn_new(bn); \
+} \
+static VALUE ossl_##keytype##_set_##name(VALUE self, VALUE bignum) \
+{ \
+ EVP_PKEY *pkey; \
+ BIGNUM *bn; \
+ \
+ GetPKey(self, pkey); \
+ if (NIL_P(bignum)) { \
+ BN_clear_free(pkey->pkey.keytype->name); \
+ pkey->pkey.keytype->name = NULL; \
+ return Qnil; \
+ } \
+ \
+ bn = GetBNPtr(bignum); \
+ if (pkey->pkey.keytype->name == NULL) \
+ pkey->pkey.keytype->name = BN_new(); \
+ if (pkey->pkey.keytype->name == NULL) \
+ ossl_raise(eBNError, NULL); \
+ if (BN_copy(pkey->pkey.keytype->name, bn) == NULL) \
+ ossl_raise(eBNError, NULL); \
+ return bignum; \
+}
+
+#define DEF_OSSL_PKEY_BN(class, keytype, name) \
+do { \
+ rb_define_method(class, #name, ossl_##keytype##_get_##name, 0); \
+ rb_define_method(class, #name "=", ossl_##keytype##_set_##name, 1); \
+} while (0)
+
+#endif /* _OSSL_PKEY_H_ */
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
new file mode 100644
index 0000000000..7070cf03f4
--- /dev/null
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -0,0 +1,395 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_DH)
+
+#include "ossl.h"
+
+#define GetPKeyDH(obj, pkey) do { \
+ GetPKey(obj, pkey); \
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH) { /* PARANOIA? */ \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A DH!") ; \
+ } \
+} while (0)
+
+#define DH_HAS_PRIVATE(dh) ((dh)->priv_key)
+
+#ifdef OSSL_ENGINE_ENABLED
+# define DH_PRIVATE(dh) (DH_HAS_PRIVATE(dh) || (dh)->engine)
+#else
+# define DH_PRIVATE(dh) DH_HAS_PRIVATE(dh)
+#endif
+
+
+/*
+ * Classes
+ */
+VALUE cDH;
+VALUE eDHError;
+
+/*
+ * Public
+ */
+static VALUE
+dh_instance(VALUE klass, DH *dh)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!dh) {
+ return Qfalse;
+ }
+ if (!(pkey = EVP_PKEY_new())) {
+ return Qfalse;
+ }
+ if (!EVP_PKEY_assign_DH(pkey, dh)) {
+ EVP_PKEY_free(pkey);
+ return Qfalse;
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+VALUE
+ossl_dh_new(EVP_PKEY *pkey)
+{
+ VALUE obj;
+
+ if (!pkey) {
+ obj = dh_instance(cDH, DH_new());
+ } else {
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH) {
+ ossl_raise(rb_eTypeError, "Not a DH key!");
+ }
+ WrapPKey(cDH, obj, pkey);
+ }
+ if (obj == Qfalse) {
+ ossl_raise(eDHError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * Private
+ */
+static DH *
+dh_generate(int size, int gen)
+{
+ DH *dh;
+
+ dh = DH_generate_parameters(size, gen,
+ rb_block_given_p() ? ossl_generate_cb : NULL,
+ NULL);
+ if (!dh) return 0;
+
+ if (!DH_generate_key(dh)) {
+ DH_free(dh);
+ return 0;
+ }
+
+ return dh;
+}
+
+static VALUE
+ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
+{
+ DH *dh ;
+ int g = 2;
+ VALUE size, gen, obj;
+
+ if (rb_scan_args(argc, argv, "11", &size, &gen) == 2) {
+ g = FIX2INT(gen);
+ }
+ dh = dh_generate(FIX2INT(size), g);
+ obj = dh_instance(klass, dh);
+ if (obj == Qfalse) {
+ DH_free(dh);
+ ossl_raise(eDHError, NULL);
+ }
+
+ return obj;
+}
+
+static VALUE
+ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ DH *dh;
+ int g = 2;
+ BIO *in;
+ VALUE arg, gen;
+
+ GetPKey(self, pkey);
+ if(rb_scan_args(argc, argv, "02", &arg, &gen) == 0) {
+ dh = DH_new();
+ }
+ else if (FIXNUM_P(arg)) {
+ if (!NIL_P(gen)) {
+ g = FIX2INT(gen);
+ }
+ if (!(dh = dh_generate(FIX2INT(arg), g))) {
+ ossl_raise(eDHError, NULL);
+ }
+ }
+ else {
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
+ if (!dh){
+ BIO_reset(in);
+ dh = d2i_DHparams_bio(in, NULL);
+ }
+ BIO_free(in);
+ if (!dh) ossl_raise(eDHError, NULL);
+ }
+ if (!EVP_PKEY_assign_DH(pkey, dh)) {
+ DH_free(dh);
+ ossl_raise(eDHError, NULL);
+ }
+ return self;
+}
+
+static VALUE
+ossl_dh_is_public(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDH(self, pkey);
+ /*
+ * Do we need to check dhp->dh->public_pkey?
+ * return Qtrue;
+ */
+ return (pkey->pkey.dh->pub_key) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_dh_is_private(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDH(self, pkey);
+
+ return (DH_PRIVATE(pkey->pkey.dh)) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_dh_export(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyDH(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDHError, NULL);
+ }
+ if (!PEM_write_bio_DHparams(out, pkey->pkey.dh)) {
+ BIO_free(out);
+ ossl_raise(eDHError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+static VALUE
+ossl_dh_to_der(VALUE self)
+{
+ EVP_PKEY *pkey;
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetPKeyDH(self, pkey);
+ if((len = i2d_DHparams(pkey->pkey.dh, NULL)) <= 0)
+ ossl_raise(eDHError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_DHparams(pkey->pkey.dh, &p) < 0)
+ ossl_raise(eDHError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * Stores all parameters of key to the hash
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dh_get_params(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE hash;
+
+ GetPKeyDH(self, pkey);
+
+ hash = rb_hash_new();
+
+ rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(pkey->pkey.dh->p));
+ rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dh->g));
+ rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dh->pub_key));
+ rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dh->priv_key));
+
+ return hash;
+}
+
+/*
+ * Prints all parameters of key to buffer
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dh_to_text(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyDH(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDHError, NULL);
+ }
+ if (!DHparams_print(out, pkey->pkey.dh)) {
+ BIO_free(out);
+ ossl_raise(eDHError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * Makes new instance DH PUBLIC_KEY from PRIVATE_KEY
+ */
+static VALUE
+ossl_dh_to_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ DH *dh;
+ VALUE obj;
+
+ GetPKeyDH(self, pkey);
+ dh = DHparams_dup(pkey->pkey.dh); /* err check perfomed by dh_instance */
+ obj = dh_instance(CLASS_OF(self), dh);
+ if (obj == Qfalse) {
+ DH_free(dh);
+ ossl_raise(eDHError, NULL);
+ }
+
+ return obj;
+}
+
+static VALUE
+ossl_dh_check_params(VALUE self)
+{
+ DH *dh;
+ EVP_PKEY *pkey;
+ int codes;
+
+ GetPKeyDH(self, pkey);
+ dh = pkey->pkey.dh;
+
+ if (!DH_check(dh, &codes)) {
+ return Qfalse;
+ }
+
+ return codes == 0 ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_dh_generate_key(VALUE self)
+{
+ DH *dh;
+ EVP_PKEY *pkey;
+
+ GetPKeyDH(self, pkey);
+ dh = pkey->pkey.dh;
+
+ if (!DH_generate_key(dh))
+ ossl_raise(eDHError, "Failed to generate key");
+ return self;
+}
+
+static VALUE
+ossl_dh_compute_key(VALUE self, VALUE pub)
+{
+ DH *dh;
+ EVP_PKEY *pkey;
+ BIGNUM *pub_key;
+ VALUE str;
+ int len;
+
+ GetPKeyDH(self, pkey);
+ dh = pkey->pkey.dh;
+ pub_key = GetBNPtr(pub);
+ len = DH_size(dh);
+ str = rb_str_new(0, len);
+ if ((len = DH_compute_key(RSTRING(str)->ptr, pub_key, dh)) < 0) {
+ ossl_raise(eDHError, NULL);
+ }
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = 0;
+
+ return str;
+}
+
+OSSL_PKEY_BN(dh, p);
+OSSL_PKEY_BN(dh, g);
+OSSL_PKEY_BN(dh, pub_key);
+OSSL_PKEY_BN(dh, priv_key);
+
+/*
+ * INIT
+ */
+void
+Init_ossl_dh()
+{
+ eDHError = rb_define_class_under(mPKey, "DHError", ePKeyError);
+
+ cDH = rb_define_class_under(mPKey, "DH", cPKey);
+
+ rb_define_singleton_method(cDH, "generate", ossl_dh_s_generate, -1);
+ rb_define_method(cDH, "initialize", ossl_dh_initialize, -1);
+
+ rb_define_method(cDH, "public?", ossl_dh_is_public, 0);
+ rb_define_method(cDH, "private?", ossl_dh_is_private, 0);
+ rb_define_method(cDH, "to_text", ossl_dh_to_text, 0);
+ rb_define_method(cDH, "export", ossl_dh_export, 0);
+ rb_define_alias(cDH, "to_pem", "export");
+ rb_define_alias(cDH, "to_s", "export");
+ rb_define_method(cDH, "to_der", ossl_dh_to_der, 0);
+ rb_define_method(cDH, "public_key", ossl_dh_to_public_key, 0);
+
+ rb_define_method(cDH, "params_ok?", ossl_dh_check_params, 0);
+ rb_define_method(cDH, "generate_key!", ossl_dh_generate_key, 0);
+ rb_define_method(cDH, "compute_key", ossl_dh_compute_key, 1);
+
+ DEF_OSSL_PKEY_BN(cDH, dh, p);
+ DEF_OSSL_PKEY_BN(cDH, dh, g);
+ DEF_OSSL_PKEY_BN(cDH, dh, pub_key);
+ DEF_OSSL_PKEY_BN(cDH, dh, priv_key);
+
+ rb_define_method(cDH, "params", ossl_dh_get_params, 0);
+}
+
+#else /* defined NO_DH */
+# warning >>> OpenSSL is compiled without DH support <<<
+
+void
+Init_ossl_dh()
+{
+ rb_warning("OpenSSL is compiled without DH support");
+}
+#endif /* NO_DH */
+
diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c
new file mode 100644
index 0000000000..daa0f4cd83
--- /dev/null
+++ b/ext/openssl/ossl_pkey_dsa.c
@@ -0,0 +1,423 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_DSA)
+
+#include "ossl.h"
+
+#define GetPKeyDSA(obj, pkey) do { \
+ GetPKey(obj, pkey); \
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DSA) { /* PARANOIA? */ \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A DSA!"); \
+ } \
+} while (0)
+
+#define DSA_HAS_PRIVATE(dsa) ((dsa)->priv_key)
+
+#ifdef OSSL_ENGINE_ENABLED
+# define DSA_PRIVATE(dsa) (DSA_HAS_PRIVATE(dsa) || (dsa)->engine)
+#else
+# define DSA_PRIVATE(dsa) DSA_HAS_PRIVATE(dsa)
+#endif
+
+
+/*
+ * Classes
+ */
+VALUE cDSA;
+VALUE eDSAError;
+
+/*
+ * Public
+ */
+static VALUE
+dsa_instance(VALUE klass, DSA *dsa)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!dsa) {
+ return Qfalse;
+ }
+ if (!(pkey = EVP_PKEY_new())) {
+ return Qfalse;
+ }
+ if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
+ EVP_PKEY_free(pkey);
+ return Qfalse;
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+VALUE
+ossl_dsa_new(EVP_PKEY *pkey)
+{
+ VALUE obj;
+
+ if (!pkey) {
+ obj = dsa_instance(cDSA, DSA_new());
+ } else {
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DSA) {
+ ossl_raise(rb_eTypeError, "Not a DSA key!");
+ }
+ WrapPKey(cDSA, obj, pkey);
+ }
+ if (obj == Qfalse) {
+ ossl_raise(eDSAError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * Private
+ */
+static DSA *
+dsa_generate(int size)
+{
+ DSA *dsa;
+ unsigned char seed[20];
+ int seed_len = 20, counter;
+ unsigned long h;
+
+ if (!RAND_bytes(seed, seed_len)) {
+ return 0;
+ }
+ dsa = DSA_generate_parameters(size, seed, seed_len, &counter, &h,
+ rb_block_given_p() ? ossl_generate_cb : NULL,
+ NULL);
+ if(!dsa) return 0;
+
+ if (!DSA_generate_key(dsa)) {
+ DSA_free(dsa);
+ return 0;
+ }
+
+ return dsa;
+}
+
+static VALUE
+ossl_dsa_s_generate(VALUE klass, VALUE size)
+{
+ DSA *dsa = dsa_generate(FIX2INT(size)); /* err handled by dsa_instance */
+ VALUE obj = dsa_instance(klass, dsa);
+
+ if (obj == Qfalse) {
+ DSA_free(dsa);
+ ossl_raise(eDSAError, NULL);
+ }
+
+ return obj;
+}
+
+static VALUE
+ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ DSA *dsa;
+ BIO *in;
+ char *passwd = NULL;
+ VALUE arg, pass;
+
+ GetPKey(self, pkey);
+ if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) {
+ dsa = DSA_new();
+ }
+ else if (FIXNUM_P(arg)) {
+ if (!(dsa = dsa_generate(FIX2INT(arg)))) {
+ ossl_raise(eDSAError, NULL);
+ }
+ }
+ else {
+ if (!NIL_P(pass)) passwd = StringValuePtr(pass);
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ dsa = PEM_read_bio_DSAPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
+ if (!dsa) {
+ BIO_reset(in);
+ dsa = PEM_read_bio_DSAPublicKey(in, NULL, NULL, NULL);
+ }
+ if (!dsa) {
+ BIO_reset(in);
+ dsa = PEM_read_bio_DSA_PUBKEY(in, NULL, NULL, NULL);
+ }
+ if (!dsa) {
+ BIO_reset(in);
+ dsa = d2i_DSAPrivateKey_bio(in, NULL);
+ }
+ if (!dsa) {
+ BIO_reset(in);
+ dsa = d2i_DSA_PUBKEY_bio(in, NULL);
+ }
+ BIO_free(in);
+ if (!dsa) ossl_raise(eDSAError, "Neither PUB key nor PRIV key:");
+ }
+ if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
+ DSA_free(dsa);
+ ossl_raise(eDSAError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_dsa_is_public(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDSA(self, pkey);
+
+ /*
+ * Do we need to check dsap->dsa->public_pkey?
+ * return Qtrue;
+ */
+ return (pkey->pkey.dsa->pub_key) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_dsa_is_private(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDSA(self, pkey);
+
+ return (DSA_PRIVATE(pkey->pkey.dsa)) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_dsa_export(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ const EVP_CIPHER *ciph = NULL;
+ char *passwd = NULL;
+ VALUE cipher, pass, str;
+
+ GetPKeyDSA(self, pkey);
+ rb_scan_args(argc, argv, "02", &cipher, &pass);
+ if (!NIL_P(cipher)) {
+ ciph = GetCipherPtr(cipher);
+ if (!NIL_P(pass)) {
+ passwd = StringValuePtr(pass);
+ }
+ }
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDSAError, NULL);
+ }
+ if (DSA_HAS_PRIVATE(pkey->pkey.dsa)) {
+ if (!PEM_write_bio_DSAPrivateKey(out, pkey->pkey.dsa, ciph,
+ NULL, 0, ossl_pem_passwd_cb, passwd)){
+ BIO_free(out);
+ ossl_raise(eDSAError, NULL);
+ }
+ } else {
+ if (!PEM_write_bio_DSAPublicKey(out, pkey->pkey.dsa)) {
+ BIO_free(out);
+ ossl_raise(eDSAError, NULL);
+ }
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+static VALUE
+ossl_dsa_to_der(VALUE self)
+{
+ EVP_PKEY *pkey;
+ int (*i2d_func)_((DSA*, unsigned char**));
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetPKeyDSA(self, pkey);
+ if(DSA_HAS_PRIVATE(pkey->pkey.dsa))
+ i2d_func = (int(*)_((DSA*,unsigned char**)))i2d_DSAPrivateKey;
+ else
+ i2d_func = i2d_DSA_PUBKEY;
+ if((len = i2d_func(pkey->pkey.dsa, NULL)) <= 0)
+ ossl_raise(eDSAError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_func(pkey->pkey.dsa, &p) < 0)
+ ossl_raise(eDSAError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * Stores all parameters of key to the hash
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dsa_get_params(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE hash;
+
+ GetPKeyDSA(self, pkey);
+
+ hash = rb_hash_new();
+
+ rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(pkey->pkey.dsa->p));
+ rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(pkey->pkey.dsa->q));
+ rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dsa->g));
+ rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dsa->pub_key));
+ rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dsa->priv_key));
+
+ return hash;
+}
+
+/*
+ * Prints all parameters of key to buffer
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dsa_to_text(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyDSA(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDSAError, NULL);
+ }
+ if (!DSA_print(out, pkey->pkey.dsa, 0)) { /* offset = 0 */
+ BIO_free(out);
+ ossl_raise(eDSAError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * Makes new instance DSA PUBLIC_KEY from PRIVATE_KEY
+ */
+static VALUE
+ossl_dsa_to_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ DSA *dsa;
+ VALUE obj;
+
+ GetPKeyDSA(self, pkey);
+ /* err check performed by dsa_instance */
+ dsa = DSAPublicKey_dup(pkey->pkey.dsa);
+ obj = dsa_instance(CLASS_OF(self), dsa);
+ if (obj == Qfalse) {
+ DSA_free(dsa);
+ ossl_raise(eDSAError, NULL);
+ }
+ return obj;
+}
+
+#define ossl_dsa_buf_size(pkey) (DSA_size((pkey)->pkey.dsa)+16)
+
+static VALUE
+ossl_dsa_sign(VALUE self, VALUE data)
+{
+ EVP_PKEY *pkey;
+ int buf_len;
+ VALUE str;
+
+ GetPKeyDSA(self, pkey);
+ StringValue(data);
+ if (!DSA_PRIVATE(pkey->pkey.dsa)) {
+ ossl_raise(eDSAError, "Private DSA key needed!");
+ }
+ str = rb_str_new(0, ossl_dsa_buf_size(pkey));
+ if (!DSA_sign(0, RSTRING(data)->ptr, RSTRING(data)->len, RSTRING(str)->ptr,
+ &buf_len, pkey->pkey.dsa)) { /* type is ignored (0) */
+ ossl_raise(eDSAError, NULL);
+ }
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
+
+ return str;
+}
+
+static VALUE
+ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
+{
+ EVP_PKEY *pkey;
+ int ret;
+
+ GetPKeyDSA(self, pkey);
+ StringValue(digest);
+ StringValue(sig);
+ /* type is ignored (0) */
+ ret = DSA_verify(0, RSTRING(digest)->ptr, RSTRING(digest)->len,
+ RSTRING(sig)->ptr, RSTRING(sig)->len, pkey->pkey.dsa);
+ if (ret < 0) {
+ ossl_raise(eDSAError, NULL);
+ }
+ else if (ret == 1) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+OSSL_PKEY_BN(dsa, p);
+OSSL_PKEY_BN(dsa, q);
+OSSL_PKEY_BN(dsa, g);
+OSSL_PKEY_BN(dsa, pub_key);
+OSSL_PKEY_BN(dsa, priv_key);
+
+/*
+ * INIT
+ */
+void
+Init_ossl_dsa()
+{
+ eDSAError = rb_define_class_under(mPKey, "DSAError", ePKeyError);
+
+ cDSA = rb_define_class_under(mPKey, "DSA", cPKey);
+
+ rb_define_singleton_method(cDSA, "generate", ossl_dsa_s_generate, 1);
+ rb_define_method(cDSA, "initialize", ossl_dsa_initialize, -1);
+
+ rb_define_method(cDSA, "public?", ossl_dsa_is_public, 0);
+ rb_define_method(cDSA, "private?", ossl_dsa_is_private, 0);
+ rb_define_method(cDSA, "to_text", ossl_dsa_to_text, 0);
+ rb_define_method(cDSA, "export", ossl_dsa_export, -1);
+ rb_define_alias(cDSA, "to_pem", "export");
+ rb_define_alias(cDSA, "to_s", "export");
+ rb_define_method(cDSA, "to_der", ossl_dsa_to_der, 0);
+ rb_define_method(cDSA, "public_key", ossl_dsa_to_public_key, 0);
+ rb_define_method(cDSA, "syssign", ossl_dsa_sign, 1);
+ rb_define_method(cDSA, "sysverify", ossl_dsa_verify, 2);
+
+ DEF_OSSL_PKEY_BN(cDSA, dsa, p);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, q);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, g);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, pub_key);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, priv_key);
+
+ rb_define_method(cDSA, "params", ossl_dsa_get_params, 0);
+}
+
+#else /* defined NO_DSA */
+# warning >>> OpenSSL is compiled without DSA support <<<
+
+void
+Init_ossl_dsa()
+{
+ rb_warning("OpenSSL is compiled without DSA support");
+}
+
+#endif /* NO_DSA */
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
new file mode 100644
index 0000000000..f8b3ae1387
--- /dev/null
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -0,0 +1,503 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_RSA)
+
+#include "ossl.h"
+
+#define GetPKeyRSA(obj, pkey) do { \
+ GetPKey(obj, pkey); \
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_RSA) { /* PARANOIA? */ \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
+ } \
+} while (0)
+
+#define RSA_HAS_PRIVATE(rsa) ((rsa)->p && (rsa)->q)
+
+#ifdef OSSL_ENGINE_ENABLED
+# define RSA_PRIVATE(rsa) (RSA_HAS_PRIVATE(rsa) || (rsa)->engine)
+#else
+# define RSA_PRIVATE(rsa) RSA_HAS_PRIVATE(rsa)
+#endif
+
+/*
+ * Classes
+ */
+VALUE cRSA;
+VALUE eRSAError;
+
+/*
+ * Public
+ */
+static VALUE
+rsa_instance(VALUE klass, RSA *rsa)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!rsa) {
+ return Qfalse;
+ }
+ if (!(pkey = EVP_PKEY_new())) {
+ return Qfalse;
+ }
+ if (!EVP_PKEY_assign_RSA(pkey, rsa)) {
+ EVP_PKEY_free(pkey);
+ return Qfalse;
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+VALUE
+ossl_rsa_new(EVP_PKEY *pkey)
+{
+ VALUE obj;
+
+ if (!pkey) {
+ obj = rsa_instance(cRSA, RSA_new());
+ }
+ else {
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_RSA) {
+ ossl_raise(rb_eTypeError, "Not a RSA key!");
+ }
+ WrapPKey(cRSA, obj, pkey);
+ }
+ if (obj == Qfalse) {
+ ossl_raise(eRSAError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * Private
+ */
+static RSA *
+rsa_generate(int size, int exp)
+{
+ return RSA_generate_key(size, exp,
+ rb_block_given_p() ? ossl_generate_cb : NULL,
+ NULL);
+}
+
+static VALUE
+ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass)
+{
+ RSA *rsa;
+ VALUE size, exp;
+ VALUE obj;
+
+ rb_scan_args(argc, argv, "11", &size, &exp);
+
+ rsa = rsa_generate(NUM2INT(size), NIL_P(exp) ? RSA_F4 : NUM2INT(exp)); /* err handled by rsa_instance */
+ obj = rsa_instance(klass, rsa);
+
+ if (obj == Qfalse) {
+ RSA_free(rsa);
+ ossl_raise(eRSAError, NULL);
+ }
+
+ return obj;
+}
+
+static VALUE
+ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ RSA *rsa;
+ BIO *in;
+ char *passwd = NULL;
+ VALUE arg, pass;
+
+ GetPKey(self, pkey);
+ if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) {
+ rsa = RSA_new();
+ }
+ else if (FIXNUM_P(arg)) {
+ rsa = rsa_generate(FIX2INT(arg), NIL_P(pass) ? RSA_F4 : NUM2INT(pass));
+ if (!rsa) ossl_raise(eRSAError, NULL);
+ }
+ else {
+ if (!NIL_P(pass)) passwd = StringValuePtr(pass);
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
+ if (!rsa) {
+ BIO_reset(in);
+ rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL);
+ }
+ if (!rsa) {
+ BIO_reset(in);
+ rsa = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL);
+ }
+ if (!rsa) {
+ BIO_reset(in);
+ rsa = d2i_RSAPrivateKey_bio(in, NULL);
+ }
+ if (!rsa) {
+ BIO_reset(in);
+ rsa = d2i_RSAPublicKey_bio(in, NULL);
+ }
+ if (!rsa) {
+ BIO_reset(in);
+ rsa = d2i_RSA_PUBKEY_bio(in, NULL);
+ }
+ BIO_free(in);
+ if (!rsa) ossl_raise(eRSAError, "Neither PUB key nor PRIV key:");
+ }
+ if (!EVP_PKEY_assign_RSA(pkey, rsa)) {
+ RSA_free(rsa);
+ ossl_raise(eRSAError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_rsa_is_public(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+ /*
+ * SURPRISE! :-))
+ * Every key is public at the same time!
+ */
+ return Qtrue;
+}
+
+static VALUE
+ossl_rsa_is_private(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+
+ return (RSA_PRIVATE(pkey->pkey.rsa)) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_rsa_export(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ const EVP_CIPHER *ciph = NULL;
+ char *passwd = NULL;
+ VALUE cipher, pass, str;
+
+ GetPKeyRSA(self, pkey);
+
+ rb_scan_args(argc, argv, "02", &cipher, &pass);
+
+ if (!NIL_P(cipher)) {
+ ciph = GetCipherPtr(cipher);
+ if (!NIL_P(pass)) {
+ passwd = StringValuePtr(pass);
+ }
+ }
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eRSAError, NULL);
+ }
+ if (RSA_HAS_PRIVATE(pkey->pkey.rsa)) {
+ if (!PEM_write_bio_RSAPrivateKey(out, pkey->pkey.rsa, ciph,
+ NULL, 0, ossl_pem_passwd_cb, passwd)) {
+ BIO_free(out);
+ ossl_raise(eRSAError, NULL);
+ }
+ } else {
+ if (!PEM_write_bio_RSAPublicKey(out, pkey->pkey.rsa)) {
+ BIO_free(out);
+ ossl_raise(eRSAError, NULL);
+ }
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+static VALUE
+ossl_rsa_to_der(VALUE self)
+{
+ EVP_PKEY *pkey;
+ int (*i2d_func)_((const RSA*, unsigned char**));
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ if(RSA_HAS_PRIVATE(pkey->pkey.rsa))
+ i2d_func = i2d_RSAPrivateKey;
+ else
+ i2d_func = i2d_RSAPublicKey;
+ if((len = i2d_func(pkey->pkey.rsa, NULL)) <= 0)
+ ossl_raise(eRSAError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_func(pkey->pkey.rsa, &p) < 0)
+ ossl_raise(eRSAError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+#define ossl_rsa_buf_size(pkey) (RSA_size((pkey)->pkey.rsa)+16)
+
+static VALUE
+ossl_rsa_public_encrypt(VALUE self, VALUE buffer)
+{
+ EVP_PKEY *pkey;
+ int buf_len;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_public_encrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
+ RSA_PKCS1_PADDING);
+ if (buf_len < 0) ossl_raise(eRSAError, NULL);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
+
+ return str;
+}
+
+static VALUE
+ossl_rsa_public_decrypt(VALUE self, VALUE buffer)
+{
+ EVP_PKEY *pkey;
+ int buf_len;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_public_decrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
+ RSA_PKCS1_PADDING);
+ if(buf_len < 0) ossl_raise(eRSAError, NULL);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
+
+ return str;
+}
+
+static VALUE
+ossl_rsa_private_encrypt(VALUE self, VALUE buffer)
+{
+ EVP_PKEY *pkey;
+ int buf_len;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ if (!RSA_PRIVATE(pkey->pkey.rsa)) {
+ ossl_raise(eRSAError, "PRIVATE key needed for this operation!");
+ }
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_private_encrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
+ RSA_PKCS1_PADDING);
+ if (buf_len < 0) ossl_raise(eRSAError, NULL);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
+
+ return str;
+}
+
+static VALUE
+ossl_rsa_private_decrypt(VALUE self, VALUE buffer)
+{
+ EVP_PKEY *pkey;
+ int buf_len;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ if (!RSA_PRIVATE(pkey->pkey.rsa)) {
+ ossl_raise(eRSAError, "Private RSA key needed!");
+ }
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_private_decrypt(RSTRING(buffer)->len, RSTRING(buffer)->ptr,
+ RSTRING(str)->ptr, pkey->pkey.rsa,
+ RSA_PKCS1_PADDING);
+ if (buf_len < 0) ossl_raise(eRSAError, NULL);
+ RSTRING(str)->len = buf_len;
+ RSTRING(str)->ptr[buf_len] = 0;
+
+ return str;
+}
+
+/*
+ * Stores all parameters of key to the hash
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_rsa_get_params(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE hash;
+
+ GetPKeyRSA(self, pkey);
+
+ hash = rb_hash_new();
+
+ rb_hash_aset(hash, rb_str_new2("n"), ossl_bn_new(pkey->pkey.rsa->n));
+ rb_hash_aset(hash, rb_str_new2("e"), ossl_bn_new(pkey->pkey.rsa->e));
+ rb_hash_aset(hash, rb_str_new2("d"), ossl_bn_new(pkey->pkey.rsa->d));
+ rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(pkey->pkey.rsa->p));
+ rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(pkey->pkey.rsa->q));
+ rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(pkey->pkey.rsa->dmp1));
+ rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(pkey->pkey.rsa->dmq1));
+ rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(pkey->pkey.rsa->iqmp));
+
+ return hash;
+}
+
+/*
+ * Prints all parameters of key to buffer
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (It's up to you)
+ */
+static VALUE
+ossl_rsa_to_text(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eRSAError, NULL);
+ }
+ if (!RSA_print(out, pkey->pkey.rsa, 0)) { /* offset = 0 */
+ BIO_free(out);
+ ossl_raise(eRSAError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * Makes new instance RSA PUBLIC_KEY from PRIVATE_KEY
+ */
+static VALUE
+ossl_rsa_to_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ RSA *rsa;
+ VALUE obj;
+
+ GetPKeyRSA(self, pkey);
+ /* err check performed by rsa_instance */
+ rsa = RSAPublicKey_dup(pkey->pkey.rsa);
+ obj = rsa_instance(CLASS_OF(self), rsa);
+ if (obj == Qfalse) {
+ RSA_free(rsa);
+ ossl_raise(eRSAError, NULL);
+ }
+ return obj;
+}
+
+/*
+ * TODO: Test me
+extern BN_CTX *ossl_bn_ctx;
+
+static VALUE
+ossl_rsa_blinding_on(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+
+ if (RSA_blinding_on(pkey->pkey.rsa, ossl_bn_ctx) != 1) {
+ ossl_raise(eRSAError, NULL);
+ }
+ return self;
+}
+
+static VALUE
+ossl_rsa_blinding_off(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+ RSA_blinding_off(pkey->pkey.rsa);
+
+ return self;
+}
+ */
+
+OSSL_PKEY_BN(rsa, n);
+OSSL_PKEY_BN(rsa, e);
+OSSL_PKEY_BN(rsa, d);
+OSSL_PKEY_BN(rsa, p);
+OSSL_PKEY_BN(rsa, q);
+OSSL_PKEY_BN(rsa, dmp1);
+OSSL_PKEY_BN(rsa, dmq1);
+OSSL_PKEY_BN(rsa, iqmp);
+
+/*
+ * INIT
+ */
+void
+Init_ossl_rsa()
+{
+ eRSAError = rb_define_class_under(mPKey, "RSAError", ePKeyError);
+
+ cRSA = rb_define_class_under(mPKey, "RSA", cPKey);
+
+ rb_define_singleton_method(cRSA, "generate", ossl_rsa_s_generate, -1);
+ rb_define_method(cRSA, "initialize", ossl_rsa_initialize, -1);
+
+ rb_define_method(cRSA, "public?", ossl_rsa_is_public, 0);
+ rb_define_method(cRSA, "private?", ossl_rsa_is_private, 0);
+ rb_define_method(cRSA, "to_text", ossl_rsa_to_text, 0);
+ rb_define_method(cRSA, "export", ossl_rsa_export, -1);
+ rb_define_alias(cRSA, "to_pem", "export");
+ rb_define_alias(cRSA, "to_s", "export");
+ rb_define_method(cRSA, "to_der", ossl_rsa_to_der, 0);
+ rb_define_method(cRSA, "public_key", ossl_rsa_to_public_key, 0);
+ rb_define_method(cRSA, "public_encrypt", ossl_rsa_public_encrypt, 1);
+ rb_define_method(cRSA, "public_decrypt", ossl_rsa_public_decrypt, 1);
+ rb_define_method(cRSA, "private_encrypt", ossl_rsa_private_encrypt, 1);
+ rb_define_method(cRSA, "private_decrypt", ossl_rsa_private_decrypt, 1);
+
+ DEF_OSSL_PKEY_BN(cRSA, rsa, n);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, e);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, d);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, p);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, q);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, dmp1);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, dmq1);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, iqmp);
+
+ rb_define_method(cRSA, "params", ossl_rsa_get_params, 0);
+
+/*
+ * TODO: Test it
+ rb_define_method(cRSA, "blinding_on!", ossl_rsa_blinding_on, 0);
+ rb_define_method(cRSA, "blinding_off!", ossl_rsa_blinding_off, 0);
+ */
+}
+
+#else /* defined NO_RSA */
+# warning >>> OpenSSL is compiled without RSA support <<<
+void
+Init_ossl_rsa()
+{
+ rb_warning("OpenSSL is compiled without RSA support");
+}
+#endif /* NO_RSA */
+
diff --git a/ext/openssl/ossl_rand.c b/ext/openssl/ossl_rand.c
new file mode 100644
index 0000000000..ec9883d70a
--- /dev/null
+++ b/ext/openssl/ossl_rand.c
@@ -0,0 +1,130 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+/*
+ * Classes
+ */
+VALUE mRandom;
+VALUE eRandomError;
+
+/*
+ * Struct
+ */
+
+/*
+ * Public
+ */
+
+/*
+ * Private
+ */
+static VALUE
+ossl_rand_seed(VALUE self, VALUE str)
+{
+ StringValue(str);
+ RAND_seed(RSTRING(str)->ptr, RSTRING(str)->len);
+
+ return str;
+}
+
+static VALUE
+ossl_rand_load_file(VALUE self, VALUE filename)
+{
+ SafeStringValue(filename);
+
+ if(!RAND_load_file(RSTRING(filename)->ptr, -1)) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+static VALUE
+ossl_rand_write_file(VALUE self, VALUE filename)
+{
+ SafeStringValue(filename);
+ if (RAND_write_file(RSTRING(filename)->ptr) == -1) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+static VALUE
+ossl_rand_bytes(VALUE self, VALUE len)
+{
+ VALUE str;
+
+ str = rb_str_new(0, FIX2INT(len));
+ if (!RAND_bytes(RSTRING(str)->ptr, FIX2INT(len))) {
+ ossl_raise(eRandomError, NULL);
+ }
+
+ return str;
+}
+
+static VALUE
+ossl_rand_pseudo_bytes(VALUE self, VALUE len)
+{
+ VALUE str;
+
+ str = rb_str_new(0, FIX2INT(len));
+ if (!RAND_pseudo_bytes(RSTRING(str)->ptr, FIX2INT(len))) {
+ ossl_raise(eRandomError, NULL);
+ }
+
+ return str;
+}
+
+static VALUE
+ossl_rand_egd(VALUE self, VALUE filename)
+{
+ SafeStringValue(filename);
+
+ if(!RAND_egd(RSTRING(filename)->ptr)) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+static VALUE
+ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
+{
+ SafeStringValue(filename);
+
+ if (!RAND_egd_bytes(RSTRING(filename)->ptr, FIX2INT(len))) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+#define DEFMETH(class, name, func, argc) \
+ rb_define_method(class, name, func, argc); \
+ rb_define_singleton_method(class, name, func, argc);
+
+/*
+ * INIT
+ */
+void
+Init_ossl_rand()
+{
+ mRandom = rb_define_module_under(mOSSL, "Random");
+
+ eRandomError = rb_define_class_under(mRandom, "RandomError", eOSSLError);
+
+ DEFMETH(mRandom, "seed", ossl_rand_seed, 1);
+ DEFMETH(mRandom, "load_random_file", ossl_rand_load_file, 1);
+ DEFMETH(mRandom, "write_random_file", ossl_rand_write_file, 1);
+ DEFMETH(mRandom, "random_bytes", ossl_rand_bytes, 1);
+ DEFMETH(mRandom, "pseudo_bytes", ossl_rand_pseudo_bytes, 1);
+ DEFMETH(mRandom, "egd", ossl_rand_egd, 1);
+ DEFMETH(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);
+}
+
diff --git a/ext/openssl/ossl_rand.h b/ext/openssl/ossl_rand.h
new file mode 100644
index 0000000000..ce2ae0d129
--- /dev/null
+++ b/ext/openssl/ossl_rand.h
@@ -0,0 +1,20 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_RAND_H_)
+#define _OSSL_RAND_H_
+
+extern VALUE mRandom;
+extern VALUE eRandomError;
+
+void Init_ossl_rand(void);
+
+#endif /* _OSSL_RAND_H_ */
+
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
new file mode 100644
index 0000000000..4d8a64fc11
--- /dev/null
+++ b/ext/openssl/ossl_ssl.c
@@ -0,0 +1,793 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2000-2002 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+#include <rubysig.h>
+#include <rubyio.h>
+
+#if defined(HAVE_UNISTD_H)
+# include <unistd.h> /* for read(), and write() */
+#endif
+
+#define numberof(ary) (sizeof(ary)/sizeof(ary[0]))
+
+#ifdef _WIN32
+# define TO_SOCKET(s) _get_osfhandle(s)
+#else
+# define TO_SOCKET(s) s
+#endif
+
+VALUE mSSL;
+VALUE eSSLError;
+VALUE cSSLContext;
+VALUE cSSLSocket;
+
+/*
+ * SSLContext class
+ */
+#define ossl_sslctx_set_cert(o,v) rb_iv_set((o),"@cert",(v))
+#define ossl_sslctx_set_key(o,v) rb_iv_set((o),"@key",(v))
+#define ossl_sslctx_set_client_ca(o,v) rb_iv_set((o),"@client_ca",(v))
+#define ossl_sslctx_set_ca_file(o,v) rb_iv_set((o),"@ca_file",(v))
+#define ossl_sslctx_set_ca_path(o,v) rb_iv_set((o),"@ca_path",(v))
+#define ossl_sslctx_set_timeout(o,v) rb_iv_set((o),"@timeout",(v))
+#define ossl_sslctx_set_verify_mode(o,v) rb_iv_set((o),"@verify_mode",(v))
+#define ossl_sslctx_set_verify_dep(o,v) rb_iv_set((o),"@verify_depth",(v))
+#define ossl_sslctx_set_verify_cb(o,v) rb_iv_set((o),"@verify_callback",(v))
+#define ossl_sslctx_set_options(o,v) rb_iv_set((o),"@options",(v))
+#define ossl_sslctx_set_cert_store(o,v) rb_iv_set((o),"@cert_store",(v))
+#define ossl_sslctx_set_extra_cert(o,v) rb_iv_set((o),"@extra_chain_cert",(v))
+
+#define ossl_sslctx_get_cert(o) rb_iv_get((o),"@cert")
+#define ossl_sslctx_get_key(o) rb_iv_get((o),"@key")
+#define ossl_sslctx_get_client_ca(o) rb_iv_get((o),"@client_ca")
+#define ossl_sslctx_get_ca_file(o) rb_iv_get((o),"@ca_file")
+#define ossl_sslctx_get_ca_path(o) rb_iv_get((o),"@ca_path")
+#define ossl_sslctx_get_timeout(o) rb_iv_get((o),"@timeout")
+#define ossl_sslctx_get_verify_mode(o) rb_iv_get((o),"@verify_mode")
+#define ossl_sslctx_get_verify_dep(o) rb_iv_get((o),"@verify_depth")
+#define ossl_sslctx_get_verify_cb(o) rb_iv_get((o),"@verify_callback")
+#define ossl_sslctx_get_options(o) rb_iv_get((o),"@options")
+#define ossl_sslctx_get_cert_store(o) rb_iv_get((o),"@cert_store")
+#define ossl_sslctx_get_extra_cert(o) rb_iv_get((o),"@extra_chain_cert")
+
+static char *ossl_sslctx_attrs[] = {
+ "cert", "key", "client_ca", "ca_file", "ca_path",
+ "timeout", "verify_mode", "verify_depth",
+ "verify_callback", "options", "cert_store", "extra_chain_cert"
+};
+
+struct {
+ const char *name;
+ SSL_METHOD *(*func)(void);
+} ossl_ssl_method_tab[] = {
+#define OSSL_SSL_METHOD_ENTRY(name) { #name, name##_method }
+ OSSL_SSL_METHOD_ENTRY(TLSv1),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_server),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_client),
+ OSSL_SSL_METHOD_ENTRY(SSLv2),
+ OSSL_SSL_METHOD_ENTRY(SSLv2_server),
+ OSSL_SSL_METHOD_ENTRY(SSLv2_client),
+ OSSL_SSL_METHOD_ENTRY(SSLv3),
+ OSSL_SSL_METHOD_ENTRY(SSLv3_server),
+ OSSL_SSL_METHOD_ENTRY(SSLv3_client),
+ OSSL_SSL_METHOD_ENTRY(SSLv23),
+ OSSL_SSL_METHOD_ENTRY(SSLv23_server),
+ OSSL_SSL_METHOD_ENTRY(SSLv23_client),
+#undef OSSL_SSL_METHOD_ENTRY
+};
+
+int ossl_ssl_ex_vcb_idx;
+int ossl_ssl_ex_store_p;
+
+static void
+ossl_sslctx_free(SSL_CTX *ctx)
+{
+ if(ctx && SSL_CTX_get_ex_data(ctx, ossl_ssl_ex_store_p)== (void*)1)
+ ctx->cert_store = NULL;
+ SSL_CTX_free(ctx);
+}
+
+static VALUE
+ossl_sslctx_s_alloc(VALUE klass)
+{
+ SSL_CTX *ctx;
+
+ ctx = SSL_CTX_new(SSLv23_method());
+ if (!ctx) {
+ ossl_raise(eSSLError, "SSL_CTX_new:");
+ }
+ SSL_CTX_set_mode(ctx, SSL_MODE_ENABLE_PARTIAL_WRITE);
+ SSL_CTX_set_options(ctx, SSL_OP_ALL);
+ return Data_Wrap_Struct(klass, 0, ossl_sslctx_free, ctx);
+}
+
+static VALUE
+ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE ssl_method;
+ SSL_METHOD *method = NULL;
+ SSL_CTX *ctx;
+ int i;
+ char *s;
+
+ Data_Get_Struct(self, SSL_CTX, ctx);
+
+ for(i = 0; i < numberof(ossl_sslctx_attrs); i++){
+ char buf[32];
+ snprintf(buf, sizeof(buf), "@%s", ossl_sslctx_attrs[i]);
+ rb_iv_set(self, buf, Qnil);
+ }
+ if (rb_scan_args(argc, argv, "01", &ssl_method) == 0){
+ return self;
+ }
+ if(TYPE(ssl_method) == T_SYMBOL)
+ s = rb_id2name(SYM2ID(ssl_method));
+ else
+ s = StringValuePtr(ssl_method);
+ for (i = 0; i < numberof(ossl_ssl_method_tab); i++) {
+ if (strcmp(ossl_ssl_method_tab[i].name, s) == 0) {
+ method = ossl_ssl_method_tab[i].func();
+ break;
+ }
+ }
+ if (!method) {
+ ossl_raise(rb_eArgError, "unknown SSL method `%s'.", s);
+ }
+ if (SSL_CTX_set_ssl_version(ctx, method) != 1) {
+ ossl_raise(eSSLError, "SSL_CTX_set_ssl_version:");
+ }
+
+ return self;
+}
+
+static int
+ossl_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
+{
+ VALUE cb;
+ SSL *ssl;
+
+ ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
+ cb = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_vcb_idx);
+ X509_STORE_CTX_set_ex_data(ctx, ossl_verify_cb_idx, (void*)cb);
+ return ossl_verify_cb(preverify_ok, ctx);
+}
+
+static VALUE
+ossl_sslctx_add_extra_chain_cert_i(VALUE i, VALUE arg)
+{
+ X509 *x509;
+ SSL_CTX *ctx;
+
+ Data_Get_Struct(arg, SSL_CTX, ctx);
+ x509 = DupX509CertPtr(i);
+ if(!SSL_CTX_add_extra_chain_cert(ctx, x509)){
+ ossl_raise(eSSLError, NULL);
+ }
+
+ return i;
+}
+
+static VALUE
+ossl_sslctx_setup(VALUE self)
+{
+ SSL_CTX *ctx;
+ X509 *cert = NULL, *client_ca = NULL;
+ X509_STORE *store;
+ EVP_PKEY *key = NULL;
+ char *ca_path = NULL, *ca_file = NULL;
+ int i, verify_mode;
+ VALUE val;
+
+ if(OBJ_FROZEN(self)) return Qnil;
+ Data_Get_Struct(self, SSL_CTX, ctx);
+
+ val = ossl_sslctx_get_cert_store(self);
+ if(!NIL_P(val)){
+ /*
+ * WORKAROUND:
+ * X509_STORE can count references, but
+ * X509_STORE_free() doesn't care it.
+ * So we won't increment it but mark it by ex_data.
+ */
+ store = GetX509StorePtr(val); /* NO NEED TO DUP */
+ SSL_CTX_set_cert_store(ctx, store);
+ SSL_CTX_set_ex_data(ctx, ossl_ssl_ex_store_p, (void*)1);
+ }
+
+ val = ossl_sslctx_get_extra_cert(self);
+ if(!NIL_P(val)){
+ rb_iterate(rb_each, val, ossl_sslctx_add_extra_chain_cert_i, self);
+ }
+
+ /* private key may be bundled in certificate file. */
+ val = ossl_sslctx_get_cert(self);
+ cert = NIL_P(val) ? NULL : GetX509CertPtr(val); /* NO DUP NEEDED */
+ val = ossl_sslctx_get_key(self);
+ key = NIL_P(val) ? NULL : GetPKeyPtr(val); /* NO DUP NEEDED */
+ if (cert && key) {
+ if (!SSL_CTX_use_certificate(ctx, cert)) {
+ /* Adds a ref => Safe to FREE */
+ ossl_raise(eSSLError, "SSL_CTX_use_certificate:");
+ }
+ if (!SSL_CTX_use_PrivateKey(ctx, key)) {
+ /* Adds a ref => Safe to FREE */
+ ossl_raise(eSSLError, "SSL_CTX_use_PrivateKey:");
+ }
+ if (!SSL_CTX_check_private_key(ctx)) {
+ ossl_raise(eSSLError, "SSL_CTX_check_private_key:");
+ }
+ }
+
+ val = ossl_sslctx_get_client_ca(self);
+ if(!NIL_P(val)){
+ if(TYPE(val) == T_ARRAY){
+ for(i = 0; i < RARRAY(val)->len; i++){
+ client_ca = GetX509CertPtr(RARRAY(val)->ptr[i]);
+ if (!SSL_CTX_add_client_CA(ctx, client_ca)){
+ /* Copies X509_NAME => FREE it. */
+ ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
+ }
+ }
+ }
+ else{
+ client_ca = GetX509CertPtr(val); /* NO DUP NEEDED. */
+ if (!SSL_CTX_add_client_CA(ctx, client_ca)){
+ /* Copies X509_NAME => FREE it. */
+ ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
+ }
+ }
+ }
+
+ val = ossl_sslctx_get_ca_file(self);
+ ca_file = NIL_P(val) ? NULL : StringValuePtr(val);
+ val = ossl_sslctx_get_ca_path(self);
+ ca_path = NIL_P(val) ? NULL : StringValuePtr(val);
+ if(ca_file || ca_path){
+ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path))
+ rb_warning("can't set verify locations");
+ }
+
+ val = ossl_sslctx_get_verify_mode(self);
+ verify_mode = NIL_P(val) ? SSL_VERIFY_NONE : NUM2INT(val);
+ SSL_CTX_set_verify(ctx, verify_mode, ossl_ssl_verify_callback);
+
+ val = ossl_sslctx_get_timeout(self);
+ if(!NIL_P(val)) SSL_CTX_set_timeout(ctx, NUM2LONG(val));
+
+ val = ossl_sslctx_get_verify_dep(self);
+ if(!NIL_P(val)) SSL_CTX_set_verify_depth(ctx, NUM2LONG(val));
+
+ val = ossl_sslctx_get_options(self);
+ if(!NIL_P(val)) SSL_CTX_set_options(ctx, NUM2LONG(val));
+ rb_obj_freeze(self);
+
+ return Qtrue;
+}
+
+static VALUE
+ossl_ssl_cipher_to_ary(SSL_CIPHER *cipher)
+{
+ VALUE ary;
+ int bits, alg_bits;
+
+ ary = rb_ary_new2(4);
+ rb_ary_push(ary, rb_str_new2(SSL_CIPHER_get_name(cipher)));
+ rb_ary_push(ary, rb_str_new2(SSL_CIPHER_get_version(cipher)));
+ bits = SSL_CIPHER_get_bits(cipher, &alg_bits);
+ rb_ary_push(ary, INT2FIX(bits));
+ rb_ary_push(ary, INT2FIX(alg_bits));
+
+ return ary;
+}
+
+static VALUE
+ossl_sslctx_get_ciphers(VALUE self)
+{
+ SSL_CTX *ctx;
+ STACK_OF(SSL_CIPHER) *ciphers;
+ SSL_CIPHER *cipher;
+ VALUE ary;
+ int i, num;
+
+ Data_Get_Struct(self, SSL_CTX, ctx);
+ if(!ctx){
+ rb_warning("SSL_CTX is not initialized.");
+ return Qnil;
+ }
+ ciphers = ctx->cipher_list;
+
+ if (!ciphers)
+ return rb_ary_new();
+
+ num = sk_num((STACK*)ciphers);
+ ary = rb_ary_new2(num);
+ for(i = 0; i < num; i++){
+ cipher = (SSL_CIPHER*)sk_value((STACK*)ciphers, i);
+ rb_ary_push(ary, ossl_ssl_cipher_to_ary(cipher));
+ }
+ return ary;
+}
+
+static VALUE
+ossl_sslctx_set_ciphers(VALUE self, VALUE v)
+{
+ SSL_CTX *ctx;
+ VALUE str, elem;
+ int i;
+
+ rb_check_frozen(self);
+ Data_Get_Struct(self, SSL_CTX, ctx);
+ if(!ctx){
+ ossl_raise(eSSLError, "SSL_CTX is not initialized.");
+ return Qnil;
+ }
+
+ if (TYPE(v) == T_ARRAY) {
+ str = rb_str_new2(NULL);
+ for (i = 0; i < RARRAY(v)->len; i++) {
+ elem = rb_ary_entry(v, i);
+ if (TYPE(elem) == T_ARRAY) elem = rb_ary_entry(elem, 0);
+ elem = rb_String(elem);
+ rb_str_append(str, elem);
+ if (i < RARRAY(v)->len-1) rb_str_cat2(str, ":");
+ }
+ } else {
+ str = v;
+ StringValue(str);
+ }
+
+ if (!SSL_CTX_set_cipher_list(ctx, RSTRING(str)->ptr)) {
+ ossl_raise(eSSLError, "SSL_CTX_set_ciphers:");
+ }
+ return Qnil;
+}
+
+/*
+ * SSLSocket class
+ */
+#define ossl_ssl_get_io(o) rb_iv_get((o),"@io")
+#define ossl_ssl_get_ctx(o) rb_iv_get((o),"@context")
+#define ossl_ssl_get_sync_close(o) rb_iv_get((o),"@sync_close")
+
+#define ossl_ssl_set_io(o,v) rb_iv_set((o),"@io",(v))
+#define ossl_ssl_set_ctx(o,v) rb_iv_set((o),"@context",(v))
+#define ossl_ssl_set_sync_close(o,v) rb_iv_set((o),"@sync_close",(v))
+
+static char *ossl_ssl_attr_readers[] = { "io", "context", };
+static char *ossl_ssl_attrs[] = { "sync_close", };
+
+static void
+ossl_ssl_shutdown(SSL *ssl)
+{
+ if (ssl) {
+ SSL_shutdown(ssl);
+ SSL_clear(ssl);
+ }
+}
+
+static void
+ossl_ssl_free(SSL *ssl)
+{
+ ossl_ssl_shutdown(ssl);
+ SSL_free(ssl);
+}
+
+static VALUE
+ossl_ssl_s_alloc(VALUE klass)
+{
+ return Data_Wrap_Struct(klass, 0, ossl_ssl_free, NULL);
+}
+
+static VALUE
+ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE io, ctx;
+
+ if (rb_scan_args(argc, argv, "11", &io, &ctx) == 1) {
+ ctx = rb_funcall(cSSLContext, rb_intern("new"), 0);
+ }
+ OSSL_Check_Kind(ctx, cSSLContext);
+ Check_Type(io, T_FILE);
+ ossl_ssl_set_io(self, io);
+ ossl_ssl_set_ctx(self, ctx);
+ ossl_ssl_set_sync_close(self, Qfalse);
+ ossl_sslctx_setup(ctx);
+ rb_call_super(0, 0);
+
+ return self;
+}
+
+static VALUE
+ossl_ssl_setup(VALUE self)
+{
+ VALUE io, v_ctx;
+ SSL_CTX *ctx;
+ SSL *ssl;
+ OpenFile *fptr;
+
+ Data_Get_Struct(self, SSL, ssl);
+ if(!ssl){
+ v_ctx = ossl_ssl_get_ctx(self);
+ Data_Get_Struct(v_ctx, SSL_CTX, ctx);
+
+ ssl = SSL_new(ctx);
+ if (!ssl) {
+ ossl_raise(eSSLError, "SSL_new:");
+ }
+ DATA_PTR(self) = ssl;
+
+ io = ossl_ssl_get_io(self);
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ rb_io_check_writable(fptr);
+ SSL_set_fd(ssl, TO_SOCKET(fileno(fptr->f)));
+ }
+
+ return Qtrue;
+}
+
+static void
+ossl_start_ssl(SSL *ssl, int (*func)())
+{
+ int ret;
+
+ for(;;){
+ if((ret = func(ssl)) > 0) break;
+ switch(SSL_get_error(ssl, ret)){
+ case SSL_ERROR_WANT_WRITE:
+ case SSL_ERROR_WANT_READ:
+ rb_thread_schedule();
+ continue;
+ default:
+ ossl_raise(eSSLError, NULL);
+ }
+ }
+}
+
+static VALUE
+ossl_ssl_connect(VALUE self)
+{
+ SSL *ssl;
+ VALUE cb;
+
+ ossl_ssl_setup(self);
+ Data_Get_Struct(self, SSL, ssl);
+ cb = ossl_sslctx_get_verify_cb(ossl_ssl_get_ctx(self));
+ SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void *)cb);
+ ossl_start_ssl(ssl, SSL_connect);
+
+ return self;
+}
+
+static VALUE
+ossl_ssl_accept(VALUE self)
+{
+ SSL *ssl;
+ VALUE cb;
+
+ ossl_ssl_setup(self);
+ Data_Get_Struct(self, SSL, ssl);
+ cb = ossl_sslctx_get_verify_cb(ossl_ssl_get_ctx(self));
+ SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void *)cb);
+ ossl_start_ssl(ssl, SSL_accept);
+
+ return self;
+}
+
+static VALUE
+ossl_ssl_read(int argc, VALUE *argv, VALUE self)
+{
+ SSL *ssl;
+ int ilen, nread = 0;
+ VALUE len, str;
+ OpenFile *fptr;
+
+ Data_Get_Struct(self, SSL, ssl);
+ GetOpenFile(ossl_ssl_get_io(self), fptr);
+ rb_scan_args(argc, argv, "11", &len, &str);
+ ilen = NUM2INT(len);
+ if(NIL_P(str)) str = rb_str_new(0, ilen);
+ else{
+ StringValue(str);
+ rb_str_modify(str);
+ rb_str_resize(str, ilen);
+ }
+ if(ilen == 0) return str;
+
+ if (ssl) {
+ if(SSL_pending(ssl) <= 0)
+ rb_thread_wait_fd(fileno(fptr->f));
+ for (;;){
+ nread = SSL_read(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
+ switch(SSL_get_error(ssl, nread)){
+ case SSL_ERROR_NONE:
+ goto end;
+ case SSL_ERROR_ZERO_RETURN:
+ rb_eof_error();
+ case SSL_ERROR_WANT_WRITE:
+ case SSL_ERROR_WANT_READ:
+ rb_thread_schedule();
+ continue;
+ case SSL_ERROR_SYSCALL:
+ if(ERR_peek_error() == 0 && nread == 0) rb_eof_error();
+ ossl_raise(eSSLError, "SSL_read: %s", strerror(errno));
+ default:
+ ossl_raise(eSSLError, "SSL_read:");
+ }
+ }
+ }
+ else {
+ ID id_sysread = rb_intern("sysread");
+ rb_warning("SSL session is not started yet.");
+ return rb_funcall(ossl_ssl_get_io(self), id_sysread, 2, len, str);
+ }
+
+ end:
+ RSTRING(str)->len = nread;
+ RSTRING(str)->ptr[nread] = 0;
+ OBJ_TAINT(str);
+
+ return str;
+}
+
+static VALUE
+ossl_ssl_write(VALUE self, VALUE str)
+{
+ SSL *ssl;
+ int nwrite = 0;
+ FILE *fp;
+
+ Data_Get_Struct(self, SSL, ssl);
+ StringValue(str);
+
+ if (ssl) {
+ for (;;){
+ nwrite = SSL_write(ssl, RSTRING(str)->ptr, RSTRING(str)->len);
+ switch(SSL_get_error(ssl, nwrite)){
+ case SSL_ERROR_NONE:
+ goto end;
+ case SSL_ERROR_WANT_WRITE:
+ case SSL_ERROR_WANT_READ:
+ rb_thread_schedule();
+ continue;
+ default:
+ ossl_raise(eSSLError, "SSL_write:");
+ }
+ }
+ }
+ else {
+ ID id_syswrite = rb_intern("syswrite");
+ rb_warning("SSL session is not started yet.");
+ return rb_funcall(ossl_ssl_get_io(self), id_syswrite, 1, str);
+ }
+
+ end:
+ return INT2NUM(nwrite);
+}
+
+static VALUE
+ossl_ssl_close(VALUE self)
+{
+ SSL *ssl;
+
+ Data_Get_Struct(self, SSL, ssl);
+ ossl_ssl_shutdown(ssl);
+ if (RTEST(ossl_ssl_get_sync_close(self)))
+ rb_funcall(ossl_ssl_get_io(self), rb_intern("close"), 0);
+
+ return Qnil;
+}
+
+static VALUE
+ossl_ssl_get_cert(VALUE self)
+{
+ SSL *ssl;
+ X509 *cert = NULL;
+
+ Data_Get_Struct(self, SSL, ssl);
+ if (ssl) {
+ rb_warning("SSL session is not started yet.");
+ return Qnil;
+ }
+
+ /*
+ * Is this OpenSSL bug? Should add a ref?
+ * TODO: Ask for.
+ */
+ cert = SSL_get_certificate(ssl); /* NO DUPs => DON'T FREE. */
+
+ if (!cert) {
+ return Qnil;
+ }
+ return ossl_x509_new(cert);
+}
+
+static VALUE
+ossl_ssl_get_peer_cert(VALUE self)
+{
+ SSL *ssl;
+ X509 *cert = NULL;
+ VALUE obj;
+
+ Data_Get_Struct(self, SSL, ssl);
+
+ if (!ssl){
+ rb_warning("SSL session is not started yet.");
+ return Qnil;
+ }
+
+ cert = SSL_get_peer_certificate(ssl); /* Adds a ref => Safe to FREE. */
+
+ if (!cert) {
+ return Qnil;
+ }
+ obj = ossl_x509_new(cert);
+ X509_free(cert);
+
+ return obj;
+}
+
+static VALUE
+ossl_ssl_get_peer_cert_chain(VALUE self)
+{
+ SSL *ssl;
+ STACK_OF(X509) *chain;
+ X509 *cert;
+ VALUE ary;
+ int i, num;
+
+ Data_Get_Struct(self, SSL, ssl);
+ if(!ssl){
+ rb_warning("SSL session is not started yet.");
+ return Qnil;
+ }
+ chain = SSL_get_peer_cert_chain(ssl);
+ if(!chain) return Qnil;
+ num = sk_num(chain);
+ ary = rb_ary_new2(num);
+ for (i = 0; i < num; i++){
+ cert = (X509*)sk_value(chain, i);
+ rb_ary_push(ary, ossl_x509_new(cert));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_ssl_get_cipher(VALUE self)
+{
+ SSL *ssl;
+ SSL_CIPHER *cipher;
+
+ Data_Get_Struct(self, SSL, ssl);
+ if (!ssl) {
+ rb_warning("SSL session is not started yet.");
+ return Qnil;
+ }
+ cipher = SSL_get_current_cipher(ssl);
+
+ return ossl_ssl_cipher_to_ary(cipher);
+}
+
+static VALUE
+ossl_ssl_get_state(VALUE self)
+{
+ SSL *ssl;
+ VALUE ret;
+
+ Data_Get_Struct(self, SSL, ssl);
+ if (!ssl) {
+ rb_warning("SSL session is not started yet.");
+ return Qnil;
+ }
+ ret = rb_str_new2(SSL_state_string(ssl));
+ if (ruby_verbose) {
+ rb_str_cat2(ret, ": ");
+ rb_str_cat2(ret, SSL_state_string_long(ssl));
+ }
+ return ret;
+}
+
+static VALUE
+ossl_ssl_pending(VALUE self)
+{
+ SSL *ssl;
+
+ Data_Get_Struct(self, SSL, ssl);
+ if (!ssl) {
+ rb_warning("SSL session is not started yet.");
+ return Qnil;
+ }
+
+ return INT2NUM(SSL_pending(ssl));
+}
+
+void
+Init_ossl_ssl()
+{
+ int i;
+
+ ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0,"ossl_ssl_ex_vcb_idx",0,0,0);
+ ossl_ssl_ex_store_p = SSL_get_ex_new_index(0,"ossl_ssl_ex_store_p",0,0,0);
+
+ mSSL = rb_define_module_under(mOSSL, "SSL");
+ eSSLError = rb_define_class_under(mSSL, "SSLError", eOSSLError);
+
+ /* class SSLContext */
+ cSSLContext = rb_define_class_under(mSSL, "SSLContext", rb_cObject);
+ rb_define_alloc_func(cSSLContext, ossl_sslctx_s_alloc);
+ for(i = 0; i < numberof(ossl_sslctx_attrs); i++)
+ rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse);
+ rb_define_method(cSSLContext, "initialize", ossl_sslctx_initialize, -1);
+ rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);
+ rb_define_method(cSSLContext, "ciphers=", ossl_sslctx_set_ciphers, 1);
+
+ /* class SSLSocket */
+ cSSLSocket = rb_define_class_under(mSSL, "SSLSocket", rb_cObject);
+ rb_define_alloc_func(cSSLSocket, ossl_ssl_s_alloc);
+ for(i = 0; i < numberof(ossl_ssl_attr_readers); i++)
+ rb_attr(cSSLSocket, rb_intern(ossl_ssl_attr_readers[i]), 1, 0, Qfalse);
+ for(i = 0; i < numberof(ossl_ssl_attrs); i++)
+ rb_attr(cSSLSocket, rb_intern(ossl_ssl_attrs[i]), 1, 1, Qfalse);
+ rb_define_alias(cSSLSocket, "to_io", "io");
+ rb_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1);
+ rb_define_method(cSSLSocket, "connect", ossl_ssl_connect, 0);
+ rb_define_method(cSSLSocket, "accept", ossl_ssl_accept, 0);
+ rb_define_method(cSSLSocket, "sysread", ossl_ssl_read, -1);
+ rb_define_method(cSSLSocket, "syswrite", ossl_ssl_write, 1);
+ rb_define_method(cSSLSocket, "sysclose", ossl_ssl_close, 0);
+ rb_define_method(cSSLSocket, "cert", ossl_ssl_get_cert, 0);
+ rb_define_method(cSSLSocket, "peer_cert", ossl_ssl_get_peer_cert, 0);
+ rb_define_method(cSSLSocket, "peer_cert_chain", ossl_ssl_get_peer_cert_chain, 0);
+ rb_define_method(cSSLSocket, "cipher", ossl_ssl_get_cipher, 0);
+ rb_define_method(cSSLSocket, "state", ossl_ssl_get_state, 0);
+ rb_define_method(cSSLSocket, "pending", ossl_ssl_pending, 0);
+
+#define ossl_ssl_def_const(x) rb_define_const(mSSL, #x, INT2FIX(SSL_##x))
+
+ ossl_ssl_def_const(VERIFY_NONE);
+ ossl_ssl_def_const(VERIFY_PEER);
+ ossl_ssl_def_const(VERIFY_FAIL_IF_NO_PEER_CERT);
+ ossl_ssl_def_const(VERIFY_CLIENT_ONCE);
+ /* Not introduce constants included in OP_ALL such as...
+ * ossl_ssl_def_const(OP_MICROSOFT_SESS_ID_BUG);
+ * ossl_ssl_def_const(OP_NETSCAPE_CHALLENGE_BUG);
+ * ossl_ssl_def_const(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
+ * ossl_ssl_def_const(OP_SSLREF2_REUSE_CERT_TYPE_BUG);
+ * ossl_ssl_def_const(OP_MICROSOFT_BIG_SSLV3_BUFFER);
+ * ossl_ssl_def_const(OP_MSIE_SSLV2_RSA_PADDING);
+ * ossl_ssl_def_const(OP_SSLEAY_080_CLIENT_DH_BUG);
+ * ossl_ssl_def_const(OP_TLS_D5_BUG);
+ * ossl_ssl_def_const(OP_TLS_BLOCK_PADDING_BUG);
+ * ossl_ssl_def_const(OP_DONT_INSERT_EMPTY_FRAGMENTS);
+ */
+ ossl_ssl_def_const(OP_ALL);
+#if defined(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)
+ ossl_ssl_def_const(OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
+#endif
+#if defined(SSL_OP_SINGLE_ECDH_USE)
+ ossl_ssl_def_const(OP_SINGLE_ECDH_USE);
+#endif
+ ossl_ssl_def_const(OP_SINGLE_DH_USE);
+ ossl_ssl_def_const(OP_EPHEMERAL_RSA);
+#if defined(SSL_OP_CIPHER_SERVER_PREFERENCE)
+ ossl_ssl_def_const(OP_CIPHER_SERVER_PREFERENCE);
+#endif
+ ossl_ssl_def_const(OP_TLS_ROLLBACK_BUG);
+ ossl_ssl_def_const(OP_NO_SSLv2);
+ ossl_ssl_def_const(OP_NO_SSLv3);
+ ossl_ssl_def_const(OP_NO_TLSv1);
+ ossl_ssl_def_const(OP_PKCS1_CHECK_1);
+ ossl_ssl_def_const(OP_PKCS1_CHECK_2);
+ ossl_ssl_def_const(OP_NETSCAPE_CA_DN_BUG);
+ ossl_ssl_def_const(OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
+}
diff --git a/ext/openssl/ossl_ssl.h b/ext/openssl/ossl_ssl.h
new file mode 100644
index 0000000000..5929eef856
--- /dev/null
+++ b/ext/openssl/ossl_ssl.h
@@ -0,0 +1,21 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_SSL_H_)
+#define _OSSL_SSL_H_
+
+extern VALUE mSSL;
+extern VALUE eSSLError;
+extern VALUE cSSLSocket;
+extern VALUE cSSLContext;
+
+void Init_ossl_ssl(void);
+
+#endif /* _OSSL_SSL_H_ */
diff --git a/ext/openssl/ossl_version.h b/ext/openssl/ossl_version.h
new file mode 100644
index 0000000000..63878e0d8e
--- /dev/null
+++ b/ext/openssl/ossl_version.h
@@ -0,0 +1,16 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_VERSION_H_)
+#define _OSSL_VERSION_H_
+
+#define OSSL_VERSION "1.0.0"
+
+#endif /* _OSSL_VERSION_H_ */
diff --git a/ext/openssl/ossl_x509.c b/ext/openssl/ossl_x509.c
new file mode 100644
index 0000000000..fd1d9b6c7e
--- /dev/null
+++ b/ext/openssl/ossl_x509.c
@@ -0,0 +1,104 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+VALUE mX509;
+
+#define DefX509Const(x) rb_define_const(mX509, #x,INT2FIX(X509_##x))
+#define DefX509Default(x,i) \
+ rb_define_const(mX509, "DEFAULT_" #x, rb_str_new2(X509_get_default_##i()))
+
+void
+Init_ossl_x509()
+{
+ mX509 = rb_define_module_under(mOSSL, "X509");
+
+ Init_ossl_x509attr();
+ Init_ossl_x509cert();
+ Init_ossl_x509crl();
+ Init_ossl_x509ext();
+ Init_ossl_x509name();
+ Init_ossl_x509req();
+ Init_ossl_x509revoked();
+ Init_ossl_x509store();
+
+ DefX509Const(V_OK);
+ DefX509Const(V_ERR_UNABLE_TO_GET_ISSUER_CERT);
+ DefX509Const(V_ERR_UNABLE_TO_GET_CRL);
+ DefX509Const(V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
+ DefX509Const(V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE);
+ DefX509Const(V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY);
+ DefX509Const(V_ERR_CERT_SIGNATURE_FAILURE);
+ DefX509Const(V_ERR_CRL_SIGNATURE_FAILURE);
+ DefX509Const(V_ERR_CERT_NOT_YET_VALID);
+ DefX509Const(V_ERR_CERT_HAS_EXPIRED);
+ DefX509Const(V_ERR_CRL_NOT_YET_VALID);
+ DefX509Const(V_ERR_CRL_HAS_EXPIRED);
+ DefX509Const(V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD);
+ DefX509Const(V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD);
+ DefX509Const(V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD);
+ DefX509Const(V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD);
+ DefX509Const(V_ERR_OUT_OF_MEM);
+ DefX509Const(V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
+ DefX509Const(V_ERR_SELF_SIGNED_CERT_IN_CHAIN);
+ DefX509Const(V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY);
+ DefX509Const(V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE);
+ DefX509Const(V_ERR_CERT_CHAIN_TOO_LONG);
+ DefX509Const(V_ERR_CERT_REVOKED);
+ DefX509Const(V_ERR_INVALID_CA);
+ DefX509Const(V_ERR_PATH_LENGTH_EXCEEDED);
+ DefX509Const(V_ERR_INVALID_PURPOSE);
+ DefX509Const(V_ERR_CERT_UNTRUSTED);
+ DefX509Const(V_ERR_CERT_REJECTED);
+ DefX509Const(V_ERR_SUBJECT_ISSUER_MISMATCH);
+ DefX509Const(V_ERR_AKID_SKID_MISMATCH);
+ DefX509Const(V_ERR_AKID_ISSUER_SERIAL_MISMATCH);
+ DefX509Const(V_ERR_KEYUSAGE_NO_CERTSIGN);
+ DefX509Const(V_ERR_APPLICATION_VERIFICATION);
+
+#if defined(X509_V_FLAG_CRL_CHECK)
+ DefX509Const(V_FLAG_CRL_CHECK);
+#endif
+#if defined(X509_V_FLAG_CRL_CHECK_ALL)
+ DefX509Const(V_FLAG_CRL_CHECK_ALL);
+#endif
+
+ DefX509Const(PURPOSE_SSL_CLIENT);
+ DefX509Const(PURPOSE_SSL_SERVER);
+ DefX509Const(PURPOSE_NS_SSL_SERVER);
+ DefX509Const(PURPOSE_SMIME_SIGN);
+ DefX509Const(PURPOSE_SMIME_ENCRYPT);
+ DefX509Const(PURPOSE_CRL_SIGN);
+ DefX509Const(PURPOSE_ANY);
+#if defined(X509_PURPOSE_OCSP_HELPER)
+ DefX509Const(PURPOSE_OCSP_HELPER);
+#endif
+
+ DefX509Const(TRUST_COMPAT);
+ DefX509Const(TRUST_SSL_CLIENT);
+ DefX509Const(TRUST_SSL_SERVER);
+ DefX509Const(TRUST_EMAIL);
+ DefX509Const(TRUST_OBJECT_SIGN);
+#if defined(X509_TRUST_OCSP_SIGN)
+ DefX509Const(TRUST_OCSP_SIGN);
+#endif
+#if defined(X509_TRUST_OCSP_REQUEST)
+ DefX509Const(TRUST_OCSP_REQUEST);
+#endif
+
+ DefX509Default(CERT_AREA, cert_area);
+ DefX509Default(CERT_DIR, cert_dir);
+ DefX509Default(CERT_FILE, cert_file);
+ DefX509Default(CERT_DIR_ENV, cert_dir_env);
+ DefX509Default(CERT_FILE_ENV, cert_file_env);
+ DefX509Default(PRIVATE_DIR, private_dir);
+}
+
diff --git a/ext/openssl/ossl_x509.h b/ext/openssl/ossl_x509.h
new file mode 100644
index 0000000000..1a43569073
--- /dev/null
+++ b/ext/openssl/ossl_x509.h
@@ -0,0 +1,114 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_X509_H_)
+#define _OSSL_X509_H_
+
+/*
+ * X509 main module
+ */
+extern VALUE mX509;
+
+void Init_ossl_x509(void);
+
+/*
+ * X509Attr
+ */
+extern VALUE cX509Attr;
+extern VALUE eX509AttrError;
+
+VALUE ossl_x509attr_new(X509_ATTRIBUTE *);
+X509_ATTRIBUTE *DupX509AttrPtr(VALUE);
+void Init_ossl_x509attr(void);
+
+/*
+ * X509Cert
+ */
+extern VALUE cX509Cert;
+extern VALUE eX509CertError;
+
+VALUE ossl_x509_new(X509 *);
+VALUE ossl_x509_new_from_file(VALUE);
+X509 *GetX509CertPtr(VALUE);
+X509 *DupX509CertPtr(VALUE);
+void Init_ossl_x509cert(void);
+
+/*
+ * X509CRL
+ */
+extern VALUE cX509CRL;
+extern VALUE eX509CRLError;
+
+VALUE ossl_x509crl_new(X509_CRL *);
+X509_CRL *GetX509CRLPtr(VALUE);
+X509_CRL *DupX509CRLPtr(VALUE);
+void Init_ossl_x509crl(void);
+
+/*
+ * X509Extension
+ */
+extern VALUE cX509Ext;
+extern VALUE cX509ExtFactory;
+extern VALUE eX509ExtError;
+
+VALUE ossl_x509ext_new(X509_EXTENSION *);
+X509_EXTENSION *GetX509ExtPtr(VALUE);
+X509_EXTENSION *DupX509ExtPtr(VALUE);
+void Init_ossl_x509ext(void);
+
+/*
+ * X509Name
+ */
+extern VALUE cX509Name;
+extern VALUE eX509NameError;
+
+VALUE ossl_x509name_new(X509_NAME *);
+X509_NAME *GetX509NamePtr(VALUE);
+void Init_ossl_x509name(void);
+
+/*
+ * X509Request
+ */
+extern VALUE cX509Req;
+extern VALUE eX509ReqError;
+
+VALUE ossl_x509req_new(X509_REQ *);
+X509_REQ *GetX509ReqPtr(VALUE);
+X509_REQ *DupX509ReqPtr(VALUE);
+void Init_ossl_x509req(void);
+
+/*
+ * X509Revoked
+ */
+extern VALUE cX509Rev;
+extern VALUE eX509RevError;
+
+VALUE ossl_x509revoked_new(X509_REVOKED *);
+X509_REVOKED *DupX509RevokedPtr(VALUE);
+void Init_ossl_x509revoked(void);
+
+/*
+ * X509Store and X509StoreContext
+ */
+extern VALUE cX509Store;
+extern VALUE cX509StoreContext;
+extern VALUE eX509StoreError;
+
+VALUE ossl_x509store_new(X509_STORE *);
+X509_STORE *GetX509StorePtr(VALUE);
+X509_STORE *DupX509StorePtr(VALUE);
+
+VALUE ossl_x509stctx_new(X509_STORE_CTX *);
+VALUE ossl_x509stctx_clear_ptr(VALUE);
+X509_STORE_CTX *GetX509StCtxtPtr(VALUE);
+
+void Init_ossl_x509store(void);
+
+#endif /* _OSSL_X509_H_ */
diff --git a/ext/openssl/ossl_x509attr.c b/ext/openssl/ossl_x509attr.c
new file mode 100644
index 0000000000..f03302d352
--- /dev/null
+++ b/ext/openssl/ossl_x509attr.c
@@ -0,0 +1,249 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Attr(klass, obj, attr) do { \
+ if (!attr) { \
+ ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_ATTRIBUTE_free, attr); \
+} while (0)
+#define GetX509Attr(obj, attr) do { \
+ Data_Get_Struct(obj, X509_ATTRIBUTE, attr); \
+ if (!attr) { \
+ ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Attr(obj, attr) do { \
+ OSSL_Check_Kind(obj, cX509Attr); \
+ GetX509Attr(obj, attr); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Attr;
+VALUE eX509AttrError;
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509attr_new(X509_ATTRIBUTE *attr)
+{
+ X509_ATTRIBUTE *new;
+ VALUE obj;
+
+ if (!attr) {
+ new = X509_ATTRIBUTE_new();
+ } else {
+ new = X509_ATTRIBUTE_dup(attr);
+ }
+ if (!new) {
+ ossl_raise(eX509AttrError, NULL);
+ }
+ WrapX509Attr(cX509Attr, obj, new);
+
+ return obj;
+}
+
+X509_ATTRIBUTE *
+DupX509AttrPtr(VALUE obj)
+{
+ X509_ATTRIBUTE *attr, *new;
+
+ SafeGetX509Attr(obj, attr);
+ if (!(new = X509_ATTRIBUTE_dup(attr))) {
+ ossl_raise(eX509AttrError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_x509attr_alloc(VALUE klass)
+{
+ X509_ATTRIBUTE *attr;
+ VALUE obj;
+
+ if (!(attr = X509_ATTRIBUTE_new()))
+ ossl_raise(eX509AttrError, NULL);
+ WrapX509Attr(klass, obj, attr);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE oid, value;
+ X509_ATTRIBUTE *attr;
+ unsigned char *p;
+
+ GetX509Attr(self, attr);
+ if(rb_scan_args(argc, argv, "11", &oid, &value) == 1){
+ oid = ossl_to_der_if_possible(oid);
+ StringValue(oid);
+ p = RSTRING(oid)->ptr;
+ if(!d2i_X509_ATTRIBUTE((X509_ATTRIBUTE**)&DATA_PTR(self),
+ &p, RSTRING(oid)->len)){
+ ossl_raise(eX509AttrError, NULL);
+ }
+ return self;
+ }
+ rb_funcall(self, rb_intern("oid="), 1, oid);
+ rb_funcall(self, rb_intern("value="), 1, value);
+
+ return self;
+}
+
+static VALUE
+ossl_x509attr_set_oid(VALUE self, VALUE oid)
+{
+ X509_ATTRIBUTE *attr;
+ ASN1_OBJECT *obj;
+ char *s;
+
+ GetX509Attr(self, attr);
+ s = StringValuePtr(oid);
+ obj = OBJ_txt2obj(s, 0);
+ if(!obj) obj = OBJ_txt2obj(s, 1);
+ if(!obj) ossl_raise(eX509AttrError, NULL);
+ X509_ATTRIBUTE_set1_object(attr, obj);
+
+ return oid;
+}
+
+static VALUE
+ossl_x509attr_get_oid(VALUE self)
+{
+ X509_ATTRIBUTE *attr;
+ ASN1_OBJECT *oid;
+ BIO *out;
+ VALUE ret;
+ int nid;
+
+ GetX509Attr(self, attr);
+ oid = X509_ATTRIBUTE_get0_object(attr);
+ if ((nid = OBJ_obj2nid(oid)) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+ else{
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eX509AttrError, NULL);
+ i2a_ASN1_OBJECT(out, oid);
+ ret = ossl_membio2str(out);
+ }
+
+ return ret;
+}
+
+#if defined(HAVE_ST_X509_ATTRIBUTE_SINGLE) || defined(HAVE_ST_SINGLE)
+# define OSSL_X509ATTR_IS_SINGLE(attr) ((attr)->single)
+# define OSSL_X509ATTR_SET_SINGLE(attr) ((attr)->single = 1)
+#else
+# define OSSL_X509ATTR_IS_SINGLE(attr) (!(attr)->set)
+# define OSSL_X509ATTR_SET_SINGLE(attr) ((attr)->set = 0)
+#endif
+
+static VALUE
+ossl_x509attr_set_value(VALUE self, VALUE value)
+{
+ X509_ATTRIBUTE *attr;
+ ASN1_TYPE *a1type;
+
+ GetX509Attr(self, attr);
+ if(!(a1type = ossl_asn1_get_asn1type(value)))
+ ossl_raise(eASN1Error, "could not get ASN1_TYPE");
+ if(ASN1_TYPE_get(a1type) == V_ASN1_SEQUENCE){
+ ASN1_TYPE_free(a1type);
+ ossl_raise(eASN1Error, "couldn't set SEQUENCE for attribute value.");
+ }
+ if(attr->value.set){
+ if(OSSL_X509ATTR_IS_SINGLE(attr)) ASN1_TYPE_free(attr->value.single);
+ else sk_ASN1_TYPE_free(attr->value.set);
+ }
+ OSSL_X509ATTR_SET_SINGLE(attr);
+ attr->value.single = a1type;
+
+ return value;
+}
+
+static VALUE
+ossl_x509attr_get_value(VALUE self)
+{
+ X509_ATTRIBUTE *attr;
+ VALUE str, asn1;
+ long length;
+ unsigned char *p;
+
+ GetX509Attr(self, attr);
+ if(attr->value.ptr == NULL) return Qnil;
+ if(OSSL_X509ATTR_IS_SINGLE(attr)){
+ length = i2d_ASN1_TYPE(attr->value.single, NULL);
+ str = rb_str_new(0, length);
+ p = RSTRING(str)->ptr;
+ i2d_ASN1_TYPE(attr->value.single, &p);
+ ossl_str_adjust(str, p);
+ }
+ else{
+ length = i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, NULL,
+ i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
+ str = rb_str_new(0, length);
+ p = RSTRING(str)->ptr;
+ i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, &p,
+ i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
+ ossl_str_adjust(str, p);
+ }
+ asn1 = rb_funcall(mASN1, rb_intern("decode"), 1, str);
+
+ return asn1;
+}
+
+static VALUE
+ossl_x509attr_to_der(VALUE self)
+{
+ X509_ATTRIBUTE *attr;
+ VALUE str;
+ int len;
+ unsigned char *p;
+
+ GetX509Attr(self, attr);
+ if((len = i2d_X509_ATTRIBUTE(attr, NULL)) <= 0)
+ ossl_raise(eX509AttrError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_X509_ATTRIBUTE(attr, &p) <= 0)
+ ossl_raise(eX509AttrError, NULL);
+ RSTRING(str)->len = p - (unsigned char*)RSTRING(str)->ptr;
+
+ return str;
+}
+
+/*
+ * X509_ATTRIBUTE init
+ */
+void
+Init_ossl_x509attr()
+{
+ eX509AttrError = rb_define_class_under(mX509, "AttributeError", eOSSLError);
+
+ cX509Attr = rb_define_class_under(mX509, "Attribute", rb_cObject);
+ rb_define_alloc_func(cX509Attr, ossl_x509attr_alloc);
+ rb_define_method(cX509Attr, "initialize", ossl_x509attr_initialize, -1);
+ rb_define_method(cX509Attr, "oid=", ossl_x509attr_set_oid, 1);
+ rb_define_method(cX509Attr, "oid", ossl_x509attr_get_oid, 0);
+ rb_define_method(cX509Attr, "value=", ossl_x509attr_set_value, 1);
+ rb_define_method(cX509Attr, "value", ossl_x509attr_get_value, 0);
+ rb_define_method(cX509Attr, "to_der", ossl_x509attr_to_der, 0);
+}
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
new file mode 100644
index 0000000000..443a2ba4c3
--- /dev/null
+++ b/ext/openssl/ossl_x509cert.c
@@ -0,0 +1,672 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509(klass, obj, x509) do { \
+ if (!x509) { \
+ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_free, x509); \
+} while (0)
+#define GetX509(obj, x509) do { \
+ Data_Get_Struct(obj, X509, x509); \
+ if (!x509) { \
+ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509(obj, x509) do { \
+ OSSL_Check_Kind(obj, cX509Cert); \
+ GetX509(obj, x509); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Cert;
+VALUE eX509CertError;
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509_new(X509 *x509)
+{
+ X509 *new;
+ VALUE obj;
+
+ if (!x509) {
+ new = X509_new();
+ } else {
+ new = X509_dup(x509);
+ }
+ if (!new) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ WrapX509(cX509Cert, obj, new);
+
+ return obj;
+}
+
+VALUE
+ossl_x509_new_from_file(VALUE filename)
+{
+ X509 *x509;
+ FILE *fp;
+ VALUE obj;
+
+ SafeStringValue(filename);
+ if (!(fp = fopen(RSTRING(filename)->ptr, "r"))) {
+ ossl_raise(eX509CertError, "%s", strerror(errno));
+ }
+ x509 = PEM_read_X509(fp, NULL, NULL, NULL);
+ /*
+ * prepare for DER...
+#if !defined(OPENSSL_NO_FP_API)
+ if (!x509) {
+ rewind(fp);
+
+ x509 = d2i_X509_fp(fp, NULL);
+ }
+#endif
+ */
+ fclose(fp);
+ if (!x509) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ WrapX509(cX509Cert, obj, x509);
+
+ return obj;
+}
+
+X509 *
+GetX509CertPtr(VALUE obj)
+{
+ X509 *x509;
+
+ SafeGetX509(obj, x509);
+
+ return x509;
+}
+
+X509 *
+DupX509CertPtr(VALUE obj)
+{
+ X509 *x509;
+
+ SafeGetX509(obj, x509);
+
+ CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509);
+
+ return x509;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_x509_alloc(VALUE klass)
+{
+ X509 *x509;
+ VALUE obj;
+
+ x509 = X509_new();
+ if (!x509) ossl_raise(eX509CertError, NULL);
+
+ WrapX509(klass, obj, x509);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ X509 *x509;
+ VALUE arg;
+
+ if (rb_scan_args(argc, argv, "01", &arg) == 0) {
+ /* create just empty X509Cert */
+ return self;
+ }
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ x509 = PEM_read_bio_X509(in, (X509 **)&DATA_PTR(self), NULL, NULL);
+ if (!x509) {
+ BIO_reset(in);
+ x509 = d2i_X509_bio(in, (X509 **)&DATA_PTR(self));
+ }
+ BIO_free(in);
+ if (!x509) ossl_raise(eX509CertError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_x509_copy(VALUE self, VALUE other)
+{
+ X509 *a, *b, *x509;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetX509(self, a);
+ SafeGetX509(other, b);
+
+ x509 = X509_dup(b);
+ if (!x509) ossl_raise(eX509CertError, NULL);
+
+ DATA_PTR(self) = x509;
+ X509_free(a);
+
+ return self;
+}
+
+static VALUE
+ossl_x509_to_der(VALUE self)
+{
+ X509 *x509;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetX509(self, x509);
+ if ((len = i2d_X509(x509, NULL)) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if (i2d_X509(x509, &p) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+static VALUE
+ossl_x509_to_pem(VALUE self)
+{
+ X509 *x509;
+ BIO *out;
+ VALUE str;
+
+ GetX509(self, x509);
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eX509CertError, NULL);
+
+ if (!PEM_write_bio_X509(out, x509)) {
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509_to_text(VALUE self)
+{
+ X509 *x509;
+ BIO *out;
+ VALUE str;
+
+ GetX509(self, x509);
+
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eX509CertError, NULL);
+
+ if (!X509_print(out, x509)) {
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+#if 0
+/*
+ * Makes from X509 X509_REQuest
+ */
+static VALUE
+ossl_x509_to_req(VALUE self)
+{
+ X509 *x509;
+ X509_REQ *req;
+ VALUE obj;
+
+ GetX509(self, x509);
+ if (!(req = X509_to_X509_REQ(x509, NULL, EVP_md5()))) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ obj = ossl_x509req_new(req);
+ X509_REQ_free(req);
+
+ return obj;
+}
+#endif
+
+static VALUE
+ossl_x509_get_version(VALUE self)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+
+ return LONG2NUM(X509_get_version(x509));
+}
+
+static VALUE
+ossl_x509_set_version(VALUE self, VALUE version)
+{
+ X509 *x509;
+ long ver;
+
+ GetX509(self, x509);
+ if ((ver = NUM2LONG(version)) < 0) {
+ ossl_raise(eX509CertError, "version must be >= 0!");
+ }
+ if (!X509_set_version(x509, ver)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return version;
+}
+
+static VALUE
+ossl_x509_get_serial(VALUE self)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+
+ return asn1integer_to_num(X509_get_serialNumber(x509));
+}
+
+static VALUE
+ossl_x509_set_serial(VALUE self, VALUE num)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+
+ x509->cert_info->serialNumber =
+ num_to_asn1integer(num, X509_get_serialNumber(x509));
+
+ return num;
+}
+
+static VALUE
+ossl_x509_get_signature_algorithm(VALUE self)
+{
+ X509 *x509;
+ BIO *out;
+ VALUE str;
+
+ GetX509(self, x509);
+
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eX509CertError, NULL);
+
+ if (!i2a_ASN1_OBJECT(out, x509->cert_info->signature->algorithm)) {
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509_get_subject(VALUE self)
+{
+ X509 *x509;
+ X509_NAME *name;
+
+ GetX509(self, x509);
+ if (!(name = X509_get_subject_name(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return ossl_x509name_new(name);
+}
+
+static VALUE
+ossl_x509_set_subject(VALUE self, VALUE subject)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+ if (!X509_set_subject_name(x509, GetX509NamePtr(subject))) { /* DUPs name */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return subject;
+}
+
+static VALUE
+ossl_x509_get_issuer(VALUE self)
+{
+ X509 *x509;
+ X509_NAME *name;
+
+ GetX509(self, x509);
+ if(!(name = X509_get_issuer_name(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return ossl_x509name_new(name);
+}
+
+static VALUE
+ossl_x509_set_issuer(VALUE self, VALUE issuer)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+ if (!X509_set_issuer_name(x509, GetX509NamePtr(issuer))) { /* DUPs name */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return issuer;
+}
+
+static VALUE
+ossl_x509_get_not_before(VALUE self)
+{
+ X509 *x509;
+ ASN1_UTCTIME *asn1time;
+
+ GetX509(self, x509);
+ if (!(asn1time = X509_get_notBefore(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return asn1time_to_time(asn1time);
+}
+
+static VALUE
+ossl_x509_set_not_before(VALUE self, VALUE time)
+{
+ X509 *x509;
+ time_t sec;
+
+ GetX509(self, x509);
+ sec = time_to_time_t(time);
+ if (!X509_time_adj(X509_get_notBefore(x509), 0, &sec)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return time;
+}
+
+static VALUE
+ossl_x509_get_not_after(VALUE self)
+{
+ X509 *x509;
+ ASN1_TIME *asn1time;
+
+ GetX509(self, x509);
+ if (!(asn1time = X509_get_notAfter(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return asn1time_to_time(asn1time);
+}
+
+static VALUE
+ossl_x509_set_not_after(VALUE self, VALUE time)
+{
+ X509 *x509;
+ time_t sec;
+
+ GetX509(self, x509);
+ sec = time_to_time_t(time);
+ if (!X509_time_adj(X509_get_notAfter(x509), 0, &sec)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return time;
+}
+
+static VALUE
+ossl_x509_get_public_key(VALUE self)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+
+ GetX509(self, x509);
+ if (!(pkey = X509_get_pubkey(x509))) { /* adds an reference */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return ossl_pkey_new(pkey); /* NO DUP - OK */
+}
+
+static VALUE
+ossl_x509_set_public_key(VALUE self, VALUE key)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+ if (!X509_set_pubkey(x509, GetPKeyPtr(key))) { /* DUPs pkey */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return key;
+}
+
+static VALUE
+ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ GetX509(self, x509);
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ if (!X509_sign(x509, pkey, md)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
+ */
+static VALUE
+ossl_x509_verify(VALUE self, VALUE key)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+ int i;
+
+ GetX509(self, x509);
+ pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
+ if ((i = X509_verify(x509, pkey)) < 0) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ if (i > 0) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+/*
+ * Checks if 'key' is PRIV key for this cert
+ */
+static VALUE
+ossl_x509_check_private_key(VALUE self, VALUE key)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+
+ GetX509(self, x509);
+ /* not needed private key, but should be */
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ if (!X509_check_private_key(x509, pkey)) {
+ OSSL_Warning("Check private key:%s", OSSL_ErrMsg());
+ return Qfalse;
+ }
+
+ return Qtrue;
+}
+
+/*
+ * Gets X509v3 extensions as array of X509Ext objects
+ */
+static VALUE
+ossl_x509_get_extensions(VALUE self)
+{
+ X509 *x509;
+ int count, i;
+ X509_EXTENSION *ext;
+ VALUE ary;
+
+ GetX509(self, x509);
+ count = X509_get_ext_count(x509);
+ if (count < 0) {
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ ext = X509_get_ext(x509, i); /* NO DUP - don't free! */
+ rb_ary_push(ary, ossl_x509ext_new(ext));
+ }
+
+ return ary;
+}
+
+/*
+ * Sets X509_EXTENSIONs
+ */
+static VALUE
+ossl_x509_set_extensions(VALUE self, VALUE ary)
+{
+ X509 *x509;
+ X509_EXTENSION *ext;
+ int i;
+
+ GetX509(self, x509);
+ Check_Type(ary, T_ARRAY);
+ /* All ary's members should be X509Extension */
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
+ }
+ sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
+ x509->cert_info->extensions = NULL;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
+
+ if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CertError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509_add_extension(VALUE self, VALUE extension)
+{
+ X509 *x509;
+ X509_EXTENSION *ext;
+
+ GetX509(self, x509);
+ ext = DupX509ExtPtr(extension);
+ if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CertError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+
+ return extension;
+}
+
+static VALUE
+ossl_x509_inspect(VALUE self)
+{
+ VALUE str;
+ char *cname = rb_class2name(rb_obj_class(self));
+
+ str = rb_str_new2("#<");
+ rb_str_cat2(str, cname);
+ rb_str_cat2(str, " ");
+
+ rb_str_cat2(str, "subject=");
+ rb_str_append(str, rb_inspect(ossl_x509_get_subject(self)));
+ rb_str_cat2(str, ", ");
+
+ rb_str_cat2(str, "issuer=");
+ rb_str_append(str, rb_inspect(ossl_x509_get_issuer(self)));
+ rb_str_cat2(str, ", ");
+
+ rb_str_cat2(str, "serial=");
+ rb_str_append(str, rb_inspect(ossl_x509_get_serial(self)));
+ rb_str_cat2(str, ", ");
+
+ rb_str_cat2(str, "not_before=");
+ rb_str_append(str, rb_inspect(ossl_x509_get_not_before(self)));
+ rb_str_cat2(str, ", ");
+
+ rb_str_cat2(str, "not_after=");
+ rb_str_append(str, rb_inspect(ossl_x509_get_not_after(self)));
+
+ str = rb_str_cat2(str, ">");
+
+ return str;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509cert()
+{
+ eX509CertError = rb_define_class_under(mX509, "CertificateError", eOSSLError);
+
+ cX509Cert = rb_define_class_under(mX509, "Certificate", rb_cObject);
+
+ rb_define_alloc_func(cX509Cert, ossl_x509_alloc);
+ rb_define_method(cX509Cert, "initialize", ossl_x509_initialize, -1);
+ rb_define_copy_func(cX509Cert, ossl_x509_copy);
+
+ rb_define_method(cX509Cert, "to_der", ossl_x509_to_der, 0);
+ rb_define_method(cX509Cert, "to_pem", ossl_x509_to_pem, 0);
+ rb_define_alias(cX509Cert, "to_s", "to_pem");
+ rb_define_method(cX509Cert, "to_text", ossl_x509_to_text, 0);
+ rb_define_method(cX509Cert, "version", ossl_x509_get_version, 0);
+ rb_define_method(cX509Cert, "version=", ossl_x509_set_version, 1);
+ rb_define_method(cX509Cert, "signature_algorithm", ossl_x509_get_signature_algorithm, 0);
+ rb_define_method(cX509Cert, "serial", ossl_x509_get_serial, 0);
+ rb_define_method(cX509Cert, "serial=", ossl_x509_set_serial, 1);
+ rb_define_method(cX509Cert, "subject", ossl_x509_get_subject, 0);
+ rb_define_method(cX509Cert, "subject=", ossl_x509_set_subject, 1);
+ rb_define_method(cX509Cert, "issuer", ossl_x509_get_issuer, 0);
+ rb_define_method(cX509Cert, "issuer=", ossl_x509_set_issuer, 1);
+ rb_define_method(cX509Cert, "not_before", ossl_x509_get_not_before, 0);
+ rb_define_method(cX509Cert, "not_before=", ossl_x509_set_not_before, 1);
+ rb_define_method(cX509Cert, "not_after", ossl_x509_get_not_after, 0);
+ rb_define_method(cX509Cert, "not_after=", ossl_x509_set_not_after, 1);
+ rb_define_method(cX509Cert, "public_key", ossl_x509_get_public_key, 0);
+ rb_define_method(cX509Cert, "public_key=", ossl_x509_set_public_key, 1);
+ rb_define_method(cX509Cert, "sign", ossl_x509_sign, 2);
+ rb_define_method(cX509Cert, "verify", ossl_x509_verify, 1);
+ rb_define_method(cX509Cert, "check_private_key", ossl_x509_check_private_key, 1);
+ rb_define_method(cX509Cert, "extensions", ossl_x509_get_extensions, 0);
+ rb_define_method(cX509Cert, "extensions=", ossl_x509_set_extensions, 1);
+ rb_define_method(cX509Cert, "add_extension", ossl_x509_add_extension, 1);
+ rb_define_method(cX509Cert, "inspect", ossl_x509_inspect, 0);
+}
+
diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c
new file mode 100644
index 0000000000..a7746aa2b3
--- /dev/null
+++ b/ext/openssl/ossl_x509crl.c
@@ -0,0 +1,537 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509CRL(klass, obj, crl) do { \
+ if (!crl) { \
+ ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_CRL_free, crl); \
+} while (0)
+#define GetX509CRL(obj, crl) do { \
+ Data_Get_Struct(obj, X509_CRL, crl); \
+ if (!crl) { \
+ ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509CRL(obj, crl) do { \
+ OSSL_Check_Kind(obj, cX509CRL); \
+ GetX509CRL(obj, crl); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509CRL;
+VALUE eX509CRLError;
+
+/*
+ * PUBLIC
+ */
+X509_CRL *
+GetX509CRLPtr(VALUE obj)
+{
+ X509_CRL *crl;
+
+ SafeGetX509CRL(obj, crl);
+
+ return crl;
+}
+
+X509_CRL *
+DupX509CRLPtr(VALUE obj)
+{
+ X509_CRL *crl;
+
+ SafeGetX509CRL(obj, crl);
+ CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509_CRL);
+
+ return crl;
+}
+
+VALUE
+ossl_x509crl_new(X509_CRL *crl)
+{
+ X509_CRL *tmp;
+ VALUE obj;
+
+ tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
+ if(!tmp) ossl_raise(eX509CRLError, NULL);
+ WrapX509CRL(cX509CRL, obj, tmp);
+
+ return obj;
+}
+
+/*
+ * PRIVATE
+ */
+static VALUE
+ossl_x509crl_alloc(VALUE klass)
+{
+ X509_CRL *crl;
+ VALUE obj;
+
+ if (!(crl = X509_CRL_new())) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ WrapX509CRL(klass, obj, crl);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ X509_CRL *crl;
+ VALUE arg;
+
+ if (rb_scan_args(argc, argv, "01", &arg) == 0) {
+ return self;
+ }
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ crl = PEM_read_bio_X509_CRL(in, (X509_CRL **)&DATA_PTR(self), NULL, NULL);
+ if (!crl) {
+ BIO_reset(in);
+ crl = d2i_X509_CRL_bio(in, (X509_CRL **)&DATA_PTR(self));
+ }
+ BIO_free(in);
+ if (!crl) ossl_raise(eX509CRLError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_x509crl_copy(VALUE self, VALUE other)
+{
+ X509_CRL *a, *b, *crl;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+ GetX509CRL(self, a);
+ SafeGetX509CRL(other, b);
+ if (!(crl = X509_CRL_dup(b))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_CRL_free(a);
+ DATA_PTR(self) = crl;
+
+ return self;
+}
+
+static VALUE
+ossl_x509crl_get_version(VALUE self)
+{
+ X509_CRL *crl;
+ long ver;
+
+ GetX509CRL(self, crl);
+ ver = X509_CRL_get_version(crl);
+
+ return LONG2NUM(ver);
+}
+
+static VALUE
+ossl_x509crl_set_version(VALUE self, VALUE version)
+{
+ X509_CRL *crl;
+ long ver;
+
+ GetX509CRL(self, crl);
+
+ if ((ver = NUM2LONG(version)) < 0) {
+ ossl_raise(eX509CRLError, "version must be >= 0!");
+ }
+ if (!X509_CRL_set_version(crl, ver)) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return version;
+}
+
+static VALUE
+ossl_x509crl_get_signature_algorithm(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!i2a_ASN1_OBJECT(out, crl->sig_alg->algorithm)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+ return str;
+}
+
+static VALUE
+ossl_x509crl_get_issuer(VALUE self)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ return ossl_x509name_new(X509_CRL_get_issuer(crl)); /* NO DUP - don't free */
+}
+
+static VALUE
+ossl_x509crl_set_issuer(VALUE self, VALUE issuer)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ if (!X509_CRL_set_issuer_name(crl, GetX509NamePtr(issuer))) { /* DUPs name */
+ ossl_raise(eX509CRLError, NULL);
+ }
+ return issuer;
+}
+
+static VALUE
+ossl_x509crl_get_last_update(VALUE self)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ return asn1time_to_time(X509_CRL_get_lastUpdate(crl));
+}
+
+static VALUE
+ossl_x509crl_set_last_update(VALUE self, VALUE time)
+{
+ X509_CRL *crl;
+ time_t sec;
+
+ GetX509CRL(self, crl);
+ sec = time_to_time_t(time);
+ if (!X509_time_adj(crl->crl->lastUpdate, 0, &sec)) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return time;
+}
+
+static VALUE
+ossl_x509crl_get_next_update(VALUE self)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ return asn1time_to_time(X509_CRL_get_nextUpdate(crl));
+}
+
+static VALUE
+ossl_x509crl_set_next_update(VALUE self, VALUE time)
+{
+ X509_CRL *crl;
+ time_t sec;
+
+ GetX509CRL(self, crl);
+ sec = time_to_time_t(time);
+ /* This must be some thinko in OpenSSL */
+ if (!(crl->crl->nextUpdate = X509_time_adj(crl->crl->nextUpdate, 0, &sec))){
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return time;
+}
+
+static VALUE
+ossl_x509crl_get_revoked(VALUE self)
+{
+ X509_CRL *crl;
+ int i, num;
+ X509_REVOKED *rev;
+ VALUE ary, revoked;
+
+ GetX509CRL(self, crl);
+ num = sk_X509_CRL_num(X509_CRL_get_REVOKED(crl));
+ if (num < 0) {
+ OSSL_Debug("num < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(num);
+ for(i=0; i<num; i++) {
+ /* NO DUP - don't free! */
+ rev = (X509_REVOKED *)sk_X509_CRL_value(X509_CRL_get_REVOKED(crl), i);
+ revoked = ossl_x509revoked_new(rev);
+ rb_ary_push(ary, revoked);
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509crl_set_revoked(VALUE self, VALUE ary)
+{
+ X509_CRL *crl;
+ X509_REVOKED *rev;
+ int i;
+
+ GetX509CRL(self, crl);
+ Check_Type(ary, T_ARRAY);
+ /* All ary members should be X509 Revoked */
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Rev);
+ }
+ sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
+ crl->crl->revoked = NULL;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ rev = DupX509RevokedPtr(RARRAY(ary)->ptr[i]);
+ if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
+ ossl_raise(eX509CRLError, NULL);
+ }
+ }
+ X509_CRL_sort(crl);
+
+ return ary;
+}
+
+static VALUE
+ossl_x509crl_add_revoked(VALUE self, VALUE revoked)
+{
+ X509_CRL *crl;
+ X509_REVOKED *rev;
+
+ GetX509CRL(self, crl);
+ rev = DupX509RevokedPtr(revoked);
+ if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_CRL_sort(crl);
+
+ return revoked;
+}
+
+static VALUE
+ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest)
+{
+ X509_CRL *crl;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ GetX509CRL(self, crl);
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ if (!X509_CRL_sign(crl, pkey, md)) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509crl_verify(VALUE self, VALUE key)
+{
+ X509_CRL *crl;
+ int ret;
+
+ GetX509CRL(self, crl);
+ if ((ret = X509_CRL_verify(crl, GetPKeyPtr(key))) < 0) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (ret == 1) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+static VALUE
+ossl_x509crl_to_der(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!i2d_X509_CRL_bio(out, crl)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509crl_to_pem(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!PEM_write_bio_X509_CRL(out, crl)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509crl_to_text(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!X509_CRL_print(out, crl)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+/*
+ * Gets X509v3 extensions as array of X509Ext objects
+ */
+static VALUE
+ossl_x509crl_get_extensions(VALUE self)
+{
+ X509_CRL *crl;
+ int count, i;
+ X509_EXTENSION *ext;
+ VALUE ary;
+
+ GetX509CRL(self, crl);
+ count = X509_CRL_get_ext_count(crl);
+ if (count < 0) {
+ OSSL_Debug("count < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ ext = X509_CRL_get_ext(crl, i); /* NO DUP - don't free! */
+ rb_ary_push(ary, ossl_x509ext_new(ext));
+ }
+
+ return ary;
+}
+
+/*
+ * Sets X509_EXTENSIONs
+ */
+static VALUE
+ossl_x509crl_set_extensions(VALUE self, VALUE ary)
+{
+ X509_CRL *crl;
+ X509_EXTENSION *ext;
+ int i;
+
+ GetX509CRL(self, crl);
+ Check_Type(ary, T_ARRAY);
+ /* All ary members should be X509 Extensions */
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
+ }
+ sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free);
+ crl->crl->extensions = NULL;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ ext = DupX509ExtPtr(RARRAY(ary)->ptr[i]);
+ if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509crl_add_extension(VALUE self, VALUE extension)
+{
+ X509_CRL *crl;
+ X509_EXTENSION *ext;
+
+ GetX509CRL(self, crl);
+ ext = DupX509ExtPtr(extension);
+ if (!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+
+ return extension;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509crl()
+{
+ eX509CRLError = rb_define_class_under(mX509, "CRLError", eOSSLError);
+
+ cX509CRL = rb_define_class_under(mX509, "CRL", rb_cObject);
+
+ rb_define_alloc_func(cX509CRL, ossl_x509crl_alloc);
+ rb_define_method(cX509CRL, "initialize", ossl_x509crl_initialize, -1);
+ rb_define_copy_func(cX509CRL, ossl_x509crl_copy);
+
+ rb_define_method(cX509CRL, "version", ossl_x509crl_get_version, 0);
+ rb_define_method(cX509CRL, "version=", ossl_x509crl_set_version, 1);
+ rb_define_method(cX509CRL, "signature_algorithm", ossl_x509crl_get_signature_algorithm, 0);
+ rb_define_method(cX509CRL, "issuer", ossl_x509crl_get_issuer, 0);
+ rb_define_method(cX509CRL, "issuer=", ossl_x509crl_set_issuer, 1);
+ rb_define_method(cX509CRL, "last_update", ossl_x509crl_get_last_update, 0);
+ rb_define_method(cX509CRL, "last_update=", ossl_x509crl_set_last_update, 1);
+ rb_define_method(cX509CRL, "next_update", ossl_x509crl_get_next_update, 0);
+ rb_define_method(cX509CRL, "next_update=", ossl_x509crl_set_next_update, 1);
+ rb_define_method(cX509CRL, "revoked", ossl_x509crl_get_revoked, 0);
+ rb_define_method(cX509CRL, "revoked=", ossl_x509crl_set_revoked, 1);
+ rb_define_method(cX509CRL, "add_revoked", ossl_x509crl_add_revoked, 1);
+ rb_define_method(cX509CRL, "sign", ossl_x509crl_sign, 2);
+ rb_define_method(cX509CRL, "verify", ossl_x509crl_verify, 1);
+ rb_define_method(cX509CRL, "to_der", ossl_x509crl_to_der, 0);
+ rb_define_method(cX509CRL, "to_pem", ossl_x509crl_to_pem, 0);
+ rb_define_alias(cX509CRL, "to_s", "to_pem");
+ rb_define_method(cX509CRL, "to_text", ossl_x509crl_to_text, 0);
+ rb_define_method(cX509CRL, "extensions", ossl_x509crl_get_extensions, 0);
+ rb_define_method(cX509CRL, "extensions=", ossl_x509crl_set_extensions, 1);
+ rb_define_method(cX509CRL, "add_extension", ossl_x509crl_add_extension, 1);
+}
+
diff --git a/ext/openssl/ossl_x509ext.c b/ext/openssl/ossl_x509ext.c
new file mode 100644
index 0000000000..57e005489a
--- /dev/null
+++ b/ext/openssl/ossl_x509ext.c
@@ -0,0 +1,439 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Ext(klass, obj, ext) do { \
+ if (!ext) { \
+ ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_EXTENSION_free, ext); \
+} while (0)
+#define GetX509Ext(obj, ext) do { \
+ Data_Get_Struct(obj, X509_EXTENSION, ext); \
+ if (!ext) { \
+ ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Ext(obj, ext) do { \
+ OSSL_Check_Kind(obj, cX509Ext); \
+ GetX509Ext(obj, ext); \
+} while (0)
+
+#define MakeX509ExtFactory(klass, obj, ctx) \
+ obj = Data_Make_Struct(klass, X509V3_CTX, 0, ossl_x509extfactory_free, ctx)
+#define GetX509ExtFactory(obj, ctx) do { \
+ Data_Get_Struct(obj, X509V3_CTX, ctx); \
+ if (!ctx) { \
+ ossl_raise(rb_eRuntimeError, "CTX wasn't initialized!"); \
+ } \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Ext;
+VALUE cX509ExtFactory;
+VALUE eX509ExtError;
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509ext_new(X509_EXTENSION *ext)
+{
+ X509_EXTENSION *new;
+ VALUE obj;
+
+ if (!ext) {
+ new = X509_EXTENSION_new();
+ } else {
+ new = X509_EXTENSION_dup(ext);
+ }
+ if (!new) {
+ ossl_raise(eX509ExtError, NULL);
+ }
+ WrapX509Ext(cX509Ext, obj, new);
+
+ return obj;
+}
+
+X509_EXTENSION *
+GetX509ExtPtr(VALUE obj)
+{
+ X509_EXTENSION *ext;
+
+ SafeGetX509Ext(obj, ext);
+
+ return ext;
+}
+
+X509_EXTENSION *
+DupX509ExtPtr(VALUE obj)
+{
+ X509_EXTENSION *ext, *new;
+
+ SafeGetX509Ext(obj, ext);
+ if (!(new = X509_EXTENSION_dup(ext))) {
+ ossl_raise(eX509ExtError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * Private
+ */
+/*
+ * Ext factory
+ */
+static void
+ossl_x509extfactory_free(X509V3_CTX *ctx)
+{
+ OPENSSL_free(ctx);
+}
+
+static VALUE
+ossl_x509extfactory_alloc(VALUE klass)
+{
+ X509V3_CTX *ctx;
+ VALUE obj;
+
+ MakeX509ExtFactory(klass, obj, ctx);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@issuer_certificate", cert);
+ ctx->issuer_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */
+
+ return cert;
+}
+
+static VALUE
+ossl_x509extfactory_set_subject_cert(VALUE self, VALUE cert)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@subject_certificate", cert);
+ ctx->subject_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */
+
+ return cert;
+}
+
+static VALUE
+ossl_x509extfactory_set_subject_req(VALUE self, VALUE req)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@subject_request", req);
+ ctx->subject_req = GetX509ReqPtr(req); /* NO DUP NEEDED */
+
+ return req;
+}
+
+static VALUE
+ossl_x509extfactory_set_crl(VALUE self, VALUE crl)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@crl", crl);
+ ctx->crl = GetX509CRLPtr(crl); /* NO DUP NEEDED */
+
+ return crl;
+}
+
+static VALUE
+ossl_x509extfactory_set_config(VALUE self, VALUE config)
+{
+#ifdef HAVE_X509V3_SET_NCONF
+ X509V3_CTX *ctx;
+ CONF *conf;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@config", config);
+ conf = GetConfigPtr(config); /* NO DUP NEEDED */
+ X509V3_set_nconf(ctx, conf);
+
+ return config;
+#else
+ rb_notimplement();
+#endif
+}
+
+static VALUE
+ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self)
+{
+ /*X509V3_CTX *ctx;*/
+ VALUE issuer_cert, subject_cert, subject_req, crl;
+
+ /*GetX509ExtFactory(self, ctx);*/
+
+ rb_scan_args(argc, argv, "04",
+ &issuer_cert, &subject_cert, &subject_req, &crl);
+ if (!NIL_P(issuer_cert))
+ ossl_x509extfactory_set_issuer_cert(self, issuer_cert);
+ if (!NIL_P(subject_cert))
+ ossl_x509extfactory_set_subject_cert(self, subject_cert);
+ if (!NIL_P(subject_req))
+ ossl_x509extfactory_set_subject_req(self, subject_req);
+ if (!NIL_P(crl))
+ ossl_x509extfactory_set_crl(self, crl);
+
+ return self;
+}
+
+/*
+ * Array to X509_EXTENSION
+ * Structure:
+ * ["ln", "value", bool_critical] or
+ * ["sn", "value", bool_critical] or
+ * ["ln", "critical,value"] or the same for sn
+ * ["ln", "value"] => not critical
+ */
+static VALUE
+ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
+{
+ X509V3_CTX *ctx;
+ X509_EXTENSION *ext;
+ VALUE oid, value, critical, valstr, obj;
+ int nid;
+
+ GetX509ExtFactory(self, ctx);
+ rb_scan_args(argc, argv, "21", &oid, &value, &critical);
+ StringValue(oid);
+ StringValue(value);
+ if(NIL_P(critical)) critical = Qfalse;
+
+ nid = OBJ_ln2nid(RSTRING(oid)->ptr);
+ if(!nid) nid = OBJ_sn2nid(RSTRING(oid)->ptr);
+ if(!nid) ossl_raise(eX509ExtError, "unknown OID `%s'", RSTRING(oid)->ptr);
+ valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
+ rb_str_append(valstr, value);
+ ext = X509V3_EXT_conf_nid(NULL, ctx, nid, RSTRING(valstr)->ptr);
+ if (!ext){
+ ossl_raise(eX509ExtError, "%s = %s",
+ RSTRING(oid)->ptr, RSTRING(value)->ptr);
+ }
+ WrapX509Ext(cX509Ext, obj, ext);
+
+ return obj;
+}
+
+/*
+ * Ext
+ */
+static VALUE
+ossl_x509ext_alloc(VALUE klass)
+{
+ X509_EXTENSION *ext;
+ VALUE obj;
+
+ if(!(ext = X509_EXTENSION_new())){
+ ossl_raise(eX509ExtError, NULL);
+ }
+ WrapX509Ext(klass, obj, ext);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE oid, value, critical;
+ unsigned char *p;
+ X509_EXTENSION *ext;
+
+ GetX509Ext(self, ext);
+ if(rb_scan_args(argc, argv, "12", &oid, &value, &critical) == 1){
+ oid = ossl_to_der_if_possible(oid);
+ StringValue(oid);
+ p = RSTRING(oid)->ptr;
+ if(!d2i_X509_EXTENSION((X509_EXTENSION**)&DATA_PTR(self),
+ &p, RSTRING(oid)->len))
+ ossl_raise(eX509ExtError, NULL);
+ return self;
+ }
+ rb_funcall(self, rb_intern("oid="), 1, oid);
+ rb_funcall(self, rb_intern("value="), 1, value);
+ if(argc > 2) rb_funcall(self, rb_intern("critical="), 1, critical);
+
+ return self;
+}
+
+static VALUE
+ossl_x509ext_set_oid(VALUE self, VALUE oid)
+{
+ X509_EXTENSION *ext;
+ ASN1_OBJECT *obj;
+ char *s;
+
+ GetX509Ext(self, ext);
+ s = StringValuePtr(oid);
+ obj = OBJ_txt2obj(s, 0);
+ if(!obj) obj = OBJ_txt2obj(s, 1);
+ if(!obj) ossl_raise(eX509ExtError, NULL);
+ X509_EXTENSION_set_object(ext, obj);
+
+ return oid;
+}
+
+static VALUE
+ossl_x509ext_set_value(VALUE self, VALUE data)
+{
+ X509_EXTENSION *ext;
+ ASN1_OCTET_STRING *asn1s;
+ char *s;
+
+ GetX509Ext(self, ext);
+ data = ossl_to_der_if_possible(data);
+ StringValue(data);
+ if(!(s = OPENSSL_malloc(RSTRING(data)->len)))
+ ossl_raise(eX509ExtError, "malloc error");
+ memcpy(s, RSTRING(data)->ptr, RSTRING(data)->len);
+ if(!(asn1s = ASN1_OCTET_STRING_new())){
+ free(s);
+ ossl_raise(eX509ExtError, NULL);
+ }
+ if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING(data)->len)){
+ free(s);
+ ASN1_OCTET_STRING_free(asn1s);
+ ossl_raise(eX509ExtError, NULL);
+ }
+ X509_EXTENSION_set_data(ext, asn1s);
+
+ return data;
+}
+
+static VALUE
+ossl_x509ext_set_critical(VALUE self, VALUE flag)
+{
+ X509_EXTENSION *ext;
+
+ GetX509Ext(self, ext);
+ X509_EXTENSION_set_critical(ext, RTEST(flag) ? 1 : 0);
+
+ return flag;
+}
+
+static VALUE
+ossl_x509ext_get_oid(VALUE obj)
+{
+ X509_EXTENSION *ext;
+ ASN1_OBJECT *extobj;
+ BIO *out;
+ VALUE ret;
+ int nid;
+
+ GetX509Ext(obj, ext);
+ extobj = X509_EXTENSION_get_object(ext);
+ if ((nid = OBJ_obj2nid(extobj)) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+ else{
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eX509ExtError, NULL);
+ i2a_ASN1_OBJECT(out, extobj);
+ ret = ossl_membio2str(out);
+ }
+
+ return ret;
+}
+
+static VALUE
+ossl_x509ext_get_value(VALUE obj)
+{
+ X509_EXTENSION *ext;
+ BIO *out;
+ VALUE ret;
+
+ GetX509Ext(obj, ext);
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eX509ExtError, NULL);
+ if (!X509V3_EXT_print(out, ext, 0, 0))
+ M_ASN1_OCTET_STRING_print(out, ext->value);
+ ret = ossl_membio2str(out);
+
+ return ret;
+}
+
+static VALUE
+ossl_x509ext_get_critical(VALUE obj)
+{
+ X509_EXTENSION *ext;
+ GetX509Ext(obj, ext);
+ return X509_EXTENSION_get_critical(ext) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_x509ext_to_der(VALUE obj)
+{
+ X509_EXTENSION *ext;
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetX509Ext(obj, ext);
+ if((len = i2d_X509_EXTENSION(ext, NULL)) <= 0)
+ ossl_raise(eX509ExtError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_X509_EXTENSION(ext, &p) < 0)
+ ossl_raise(eX509ExtError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509ext()
+{
+ eX509ExtError = rb_define_class_under(mX509, "ExtensionError", eOSSLError);
+
+ cX509ExtFactory = rb_define_class_under(mX509, "ExtensionFactory", rb_cObject);
+
+ rb_define_alloc_func(cX509ExtFactory, ossl_x509extfactory_alloc);
+ rb_define_method(cX509ExtFactory, "initialize", ossl_x509extfactory_initialize, -1);
+
+ rb_attr(cX509ExtFactory, rb_intern("issuer_certificate"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("subject_certificate"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("subject_request"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("crl"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("config"), 1, 0, Qfalse);
+
+ rb_define_method(cX509ExtFactory, "issuer_certificate=", ossl_x509extfactory_set_issuer_cert, 1);
+ rb_define_method(cX509ExtFactory, "subject_certificate=", ossl_x509extfactory_set_subject_cert, 1);
+ rb_define_method(cX509ExtFactory, "subject_request=", ossl_x509extfactory_set_subject_req, 1);
+ rb_define_method(cX509ExtFactory, "crl=", ossl_x509extfactory_set_crl, 1);
+ rb_define_method(cX509ExtFactory, "config=", ossl_x509extfactory_set_config, 1);
+ rb_define_method(cX509ExtFactory, "create_ext", ossl_x509extfactory_create_ext, -1);
+
+ cX509Ext = rb_define_class_under(mX509, "Extension", rb_cObject);
+ rb_define_alloc_func(cX509Ext, ossl_x509ext_alloc);
+ rb_define_method(cX509Ext, "initialize", ossl_x509ext_initialize, -1);
+ rb_define_method(cX509Ext, "oid=", ossl_x509ext_set_oid, 1);
+ rb_define_method(cX509Ext, "value=", ossl_x509ext_set_value, 1);
+ rb_define_method(cX509Ext, "critical=", ossl_x509ext_set_critical, 1);
+ rb_define_method(cX509Ext, "oid", ossl_x509ext_get_oid, 0);
+ rb_define_method(cX509Ext, "value", ossl_x509ext_get_value, 0);
+ rb_define_method(cX509Ext, "critical?", ossl_x509ext_get_critical, 0);
+ rb_define_method(cX509Ext, "to_der", ossl_x509ext_to_der, 0);
+}
diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c
new file mode 100644
index 0000000000..b198157504
--- /dev/null
+++ b/ext/openssl/ossl_x509name.c
@@ -0,0 +1,311 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Name(klass, obj, name) do { \
+ if (!name) { \
+ ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_NAME_free, name); \
+} while (0)
+#define GetX509Name(obj, name) do { \
+ Data_Get_Struct(obj, X509_NAME, name); \
+ if (!name) { \
+ ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetX509Name(obj, name) do { \
+ OSSL_Check_Kind(obj, cX509Name); \
+ GetX509Name(obj, name); \
+} while (0)
+
+#define OBJECT_TYPE_TEMPLATE \
+ rb_const_get(cX509Name, rb_intern("OBJECT_TYPE_TEMPLATE"))
+#define DEFAULT_OBJECT_TYPE \
+ rb_const_get(cX509Name, rb_intern("DEFAULT_OBJECT_TYPE"))
+
+/*
+ * Classes
+ */
+VALUE cX509Name;
+VALUE eX509NameError;
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509name_new(X509_NAME *name)
+{
+ X509_NAME *new;
+ VALUE obj;
+
+ if (!name) {
+ new = X509_NAME_new();
+ } else {
+ new = X509_NAME_dup(name);
+ }
+ if (!new) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ WrapX509Name(cX509Name, obj, new);
+
+ return obj;
+}
+
+X509_NAME *
+GetX509NamePtr(VALUE obj)
+{
+ X509_NAME *name;
+
+ SafeGetX509Name(obj, name);
+
+ return name;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_x509name_alloc(VALUE klass)
+{
+ X509_NAME *name;
+ VALUE obj;
+
+ if (!(name = X509_NAME_new())) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ WrapX509Name(klass, obj, name);
+
+ return obj;
+}
+
+static int id_aref;
+static VALUE ossl_x509name_add_entry(int, VALUE*, VALUE);
+#define rb_aref(obj, key) rb_funcall(obj, id_aref, 1, key)
+
+static VALUE
+ossl_x509name_init_i(VALUE i, VALUE args)
+{
+ VALUE self = rb_ary_entry(args, 0);
+ VALUE template = rb_ary_entry(args, 1);
+ VALUE entry[3];
+
+ Check_Type(i, T_ARRAY);
+ entry[0] = rb_ary_entry(i, 0);
+ entry[1] = rb_ary_entry(i, 1);
+ entry[2] = rb_ary_entry(i, 2);
+ if(NIL_P(entry[2])) entry[2] = rb_aref(template, entry[0]);
+ if(NIL_P(entry[2])) entry[2] = DEFAULT_OBJECT_TYPE;
+ ossl_x509name_add_entry(3, entry, self);
+
+ return Qnil;
+}
+
+static VALUE
+ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
+{
+ X509_NAME *name;
+ VALUE arg, template;
+
+ GetX509Name(self, name);
+ if (rb_scan_args(argc, argv, "02", &arg, &template) == 0) {
+ return self;
+ }
+ else if (rb_obj_is_kind_of(arg, rb_cArray) == Qtrue){
+ VALUE args;
+ if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE;
+ args = rb_ary_new3(2, self, template);
+ rb_iterate(rb_each, arg, ossl_x509name_init_i, args);
+ }
+ else{
+ unsigned char *p;
+ VALUE str = ossl_to_der_if_possible(arg);
+ StringValue(str);
+ p = RSTRING(str)->ptr;
+ if(!d2i_X509_NAME((X509_NAME**)&DATA_PTR(self), &p, RSTRING(str)->len)){
+ ossl_raise(eX509NameError, NULL);
+ }
+ }
+
+ return self;
+}
+
+static
+VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
+{
+ X509_NAME *name;
+ VALUE oid, value, type;
+
+ rb_scan_args(argc, argv, "21", &oid, &value, &type);
+ StringValue(oid);
+ StringValue(value);
+ if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
+ GetX509Name(self, name);
+ if (!X509_NAME_add_entry_by_txt(name, RSTRING(oid)->ptr, NUM2INT(type),
+ RSTRING(value)->ptr, RSTRING(value)->len, -1, 0)) {
+ ossl_raise(eX509NameError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509name_to_s(VALUE self)
+{
+ X509_NAME *name;
+ char *buf;
+ VALUE str;
+
+ GetX509Name(self, name);
+ buf = X509_NAME_oneline(name, NULL, 0);
+ str = rb_str_new2(buf);
+ OPENSSL_free(buf);
+
+ return str;
+}
+
+static VALUE
+ossl_x509name_to_a(VALUE self)
+{
+ X509_NAME *name;
+ X509_NAME_ENTRY *entry;
+ int i,entries;
+ char long_name[512];
+ const char *short_name;
+ VALUE ary, ret;
+
+ GetX509Name(self, name);
+ entries = X509_NAME_entry_count(name);
+ if (entries < 0) {
+ OSSL_Debug("name entries < 0!");
+ return rb_ary_new();
+ }
+ ret = rb_ary_new2(entries);
+ for (i=0; i<entries; i++) {
+ if (!(entry = X509_NAME_get_entry(name, i))) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ if (!i2t_ASN1_OBJECT(long_name, sizeof(long_name), entry->object)) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ short_name = OBJ_nid2sn(OBJ_ln2nid(long_name));
+ ary = rb_ary_new3(3, rb_str_new2(short_name),
+ rb_str_new(entry->value->data, entry->value->length),
+ INT2FIX(entry->value->type));
+ rb_ary_push(ret, ary);
+ }
+ return ret;
+}
+
+static int
+ossl_x509name_cmp0(VALUE self, VALUE other)
+{
+ X509_NAME *name1, *name2;
+
+ GetX509Name(self, name1);
+ SafeGetX509Name(other, name2);
+
+ return X509_NAME_cmp(name1, name2);
+}
+
+static VALUE
+ossl_x509name_cmp(VALUE self, VALUE other)
+{
+ int result;
+
+ result = ossl_x509name_cmp0(self, other);
+ if (result < 0) return INT2FIX(-1);
+ if (result > 1) return INT2FIX(1);
+
+ return INT2FIX(0);
+}
+
+static VALUE
+ossl_x509name_eql(VALUE self, VALUE other)
+{
+ int result;
+
+ if(CLASS_OF(other) != cX509Name) return Qfalse;
+ result = ossl_x509name_cmp0(self, other);
+
+ return (result == 0) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_x509name_hash(VALUE self)
+{
+ X509_NAME *name;
+ unsigned long hash;
+
+ GetX509Name(self, name);
+
+ hash = X509_NAME_hash(name);
+
+ return ULONG2NUM(hash);
+}
+
+static VALUE
+ossl_x509name_to_der(VALUE self)
+{
+ X509_NAME *name;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetX509Name(self, name);
+ if((len = i2d_X509_NAME(name, NULL)) <= 0)
+ ossl_raise(eX509NameError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if(i2d_X509_NAME(name, &p) <= 0)
+ ossl_raise(eX509NameError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509name()
+{
+ VALUE utf8str, ptrstr, ia5str, hash;
+
+ id_aref = rb_intern("[]");
+ eX509NameError = rb_define_class_under(mX509, "NameError", eOSSLError);
+ cX509Name = rb_define_class_under(mX509, "Name", rb_cObject);
+
+ rb_define_alloc_func(cX509Name, ossl_x509name_alloc);
+ rb_define_method(cX509Name, "initialize", ossl_x509name_initialize, -1);
+ rb_define_method(cX509Name, "add_entry", ossl_x509name_add_entry, -1);
+ rb_define_method(cX509Name, "to_s", ossl_x509name_to_s, 0);
+ rb_define_method(cX509Name, "to_a", ossl_x509name_to_a, 0);
+ rb_define_method(cX509Name, "cmp", ossl_x509name_cmp, 1);
+ rb_define_alias(cX509Name, "<=>", "cmp");
+ rb_define_method(cX509Name, "eql?", ossl_x509name_eql, 1);
+ rb_define_method(cX509Name, "hash", ossl_x509name_hash, 0);
+ rb_define_method(cX509Name, "to_der", ossl_x509name_to_der, 0);
+
+ utf8str = INT2NUM(V_ASN1_UTF8STRING);
+ ptrstr = INT2NUM(V_ASN1_PRINTABLESTRING);
+ ia5str = INT2NUM(V_ASN1_IA5STRING);
+ rb_define_const(cX509Name, "DEFAULT_OBJECT_TYPE", utf8str);
+ hash = rb_funcall(rb_cHash, rb_intern("new"), 1, DEFAULT_OBJECT_TYPE);
+ rb_hash_aset(hash, rb_str_new2("C"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("countryName"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("serialNumber"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("dnQualifier"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("DC"), ia5str);
+ rb_hash_aset(hash, rb_str_new2("domainComponent"), ia5str);
+ rb_hash_aset(hash, rb_str_new2("emailAddress"), ia5str);
+ rb_define_const(cX509Name, "OBJECT_TYPE_TEMPLATE", hash);
+}
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
new file mode 100644
index 0000000000..c532739997
--- /dev/null
+++ b/ext/openssl/ossl_x509req.c
@@ -0,0 +1,466 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Req(klass, obj, req) do { \
+ if (!req) { \
+ ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_REQ_free, req); \
+} while (0)
+#define GetX509Req(obj, req) do { \
+ Data_Get_Struct(obj, X509_REQ, req); \
+ if (!req) { \
+ ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Req(obj, req) do { \
+ OSSL_Check_Kind(obj, cX509Req); \
+ GetX509Req(obj, req); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Req;
+VALUE eX509ReqError;
+
+/*
+ * Public functions
+ */
+VALUE
+ossl_x509req_new(X509_REQ *req)
+{
+ X509_REQ *new;
+ VALUE obj;
+
+ if (!req) {
+ new = X509_REQ_new();
+ } else {
+ new = X509_REQ_dup(req);
+ }
+ if (!new) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ WrapX509Req(cX509Req, obj, new);
+
+ return obj;
+}
+
+X509_REQ *
+GetX509ReqPtr(VALUE obj)
+{
+ X509_REQ *req;
+
+ SafeGetX509Req(obj, req);
+
+ return req;
+}
+
+X509_REQ *
+DupX509ReqPtr(VALUE obj)
+{
+ X509_REQ *req, *new;
+
+ SafeGetX509Req(obj, req);
+ if (!(new = X509_REQ_dup(req))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * Private functions
+ */
+static VALUE
+ossl_x509req_alloc(VALUE klass)
+{
+ X509_REQ *req;
+ VALUE obj;
+
+ if (!(req = X509_REQ_new())) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ WrapX509Req(klass, obj, req);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509req_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ X509_REQ *req;
+ VALUE arg;
+
+ if (rb_scan_args(argc, argv, "01", &arg) == 0) {
+ return self;
+ }
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ req = PEM_read_bio_X509_REQ(in, (X509_REQ **)&DATA_PTR(self), NULL, NULL);
+ if (!req) {
+ BIO_reset(in);
+ req = d2i_X509_REQ_bio(in, (X509_REQ **)&DATA_PTR(self));
+ }
+ BIO_free(in);
+ if (!req) ossl_raise(eX509ReqError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_x509req_copy(VALUE self, VALUE other)
+{
+ X509_REQ *a, *b, *req;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+ GetX509Req(self, a);
+ SafeGetX509Req(other, b);
+ if (!(req = X509_REQ_dup(b))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ X509_REQ_free(a);
+ DATA_PTR(self) = req;
+
+ return self;
+}
+
+static VALUE
+ossl_x509req_to_pem(VALUE self)
+{
+ X509_REQ *req;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509Req(self, req);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (!PEM_write_bio_X509_REQ(out, req)) {
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509req_to_der(VALUE self)
+{
+ X509_REQ *req;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetX509Req(self, req);
+ if ((len = i2d_X509_REQ(req, NULL)) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ str = rb_str_new(0, len);
+ p = RSTRING(str)->ptr;
+ if (i2d_X509_REQ(req, &p) <= 0)
+ ossl_raise(eX509ReqError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+static VALUE
+ossl_x509req_to_text(VALUE self)
+{
+ X509_REQ *req;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509Req(self, req);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (!X509_REQ_print(out, req)) {
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+#if 0
+/*
+ * Makes X509 from X509_REQuest
+ */
+static VALUE
+ossl_x509req_to_x509(VALUE self, VALUE days, VALUE key)
+{
+ X509_REQ *req;
+ X509 *x509;
+
+ GetX509Req(self, req);
+ ...
+ if (!(x509 = X509_REQ_to_X509(req, d, pkey))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return ossl_x509_new(x509);
+}
+#endif
+
+static VALUE
+ossl_x509req_get_version(VALUE self)
+{
+ X509_REQ *req;
+ long version;
+
+ GetX509Req(self, req);
+ version = X509_REQ_get_version(req);
+
+ return LONG2FIX(version);
+}
+
+static VALUE
+ossl_x509req_set_version(VALUE self, VALUE version)
+{
+ X509_REQ *req;
+ long ver;
+
+ GetX509Req(self, req);
+ if ((ver = FIX2LONG(version)) < 0) {
+ ossl_raise(eX509ReqError, "version must be >= 0!");
+ }
+ if (!X509_REQ_set_version(req, ver)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return version;
+}
+
+static VALUE
+ossl_x509req_get_subject(VALUE self)
+{
+ X509_REQ *req;
+ X509_NAME *name;
+
+ GetX509Req(self, req);
+ if (!(name = X509_REQ_get_subject_name(req))) { /* NO DUP - don't free */
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return ossl_x509name_new(name);
+}
+
+static VALUE
+ossl_x509req_set_subject(VALUE self, VALUE subject)
+{
+ X509_REQ *req;
+
+ GetX509Req(self, req);
+ /* DUPs name */
+ if (!X509_REQ_set_subject_name(req, GetX509NamePtr(subject))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return subject;
+}
+
+static VALUE
+ossl_x509req_get_signature_algorithm(VALUE self)
+{
+ X509_REQ *req;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509Req(self, req);
+
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (!i2a_ASN1_OBJECT(out, req->sig_alg->algorithm)) {
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+ return str;
+}
+
+static VALUE
+ossl_x509req_get_public_key(VALUE self)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+
+ GetX509Req(self, req);
+ if (!(pkey = X509_REQ_get_pubkey(req))) { /* adds reference */
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return ossl_pkey_new(pkey); /* NO DUP - OK */
+}
+
+static VALUE
+ossl_x509req_set_public_key(VALUE self, VALUE key)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+
+ GetX509Req(self, req);
+ pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
+ if (!X509_REQ_set_pubkey(req, pkey)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return key;
+}
+
+static VALUE
+ossl_x509req_sign(VALUE self, VALUE key, VALUE digest)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ GetX509Req(self, req);
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ if (!X509_REQ_sign(req, pkey, md)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
+ */
+static VALUE
+ossl_x509req_verify(VALUE self, VALUE key)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+ int i;
+
+ GetX509Req(self, req);
+ pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
+ if ((i = X509_REQ_verify(req, pkey)) < 0) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (i > 0) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+static VALUE
+ossl_x509req_get_attributes(VALUE self)
+{
+ X509_REQ *req;
+ int count, i;
+ X509_ATTRIBUTE *attr;
+ VALUE ary;
+
+ GetX509Req(self, req);
+
+ count = X509_REQ_get_attr_count(req);
+ if (count < 0) {
+ OSSL_Debug("count < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ attr = X509_REQ_get_attr(req, i);
+ rb_ary_push(ary, ossl_x509attr_new(attr));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509req_set_attributes(VALUE self, VALUE ary)
+{
+ X509_REQ *req;
+ X509_ATTRIBUTE *attr;
+ int i;
+ VALUE item;
+
+ GetX509Req(self, req);
+ Check_Type(ary, T_ARRAY);
+ for (i=0;i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Attr);
+ }
+ sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free);
+ req->req_info->attributes = NULL;
+ for (i=0;i<RARRAY(ary)->len; i++) {
+ item = RARRAY(ary)->ptr[i];
+ attr = DupX509AttrPtr(item);
+ if (!X509_REQ_add1_attr(req, attr)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ }
+ return ary;
+}
+
+static VALUE
+ossl_x509req_add_attribute(VALUE self, VALUE attr)
+{
+ X509_REQ *req;
+
+ GetX509Req(self, req);
+ if (!X509_REQ_add1_attr(req, DupX509AttrPtr(attr))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return attr;
+}
+
+/*
+ * X509_REQUEST init
+ */
+void
+Init_ossl_x509req()
+{
+ eX509ReqError = rb_define_class_under(mX509, "RequestError", eOSSLError);
+
+ cX509Req = rb_define_class_under(mX509, "Request", rb_cObject);
+
+ rb_define_alloc_func(cX509Req, ossl_x509req_alloc);
+ rb_define_method(cX509Req, "initialize", ossl_x509req_initialize, -1);
+ rb_define_copy_func(cX509Req, ossl_x509req_copy);
+
+ rb_define_method(cX509Req, "to_pem", ossl_x509req_to_pem, 0);
+ rb_define_method(cX509Req, "to_der", ossl_x509req_to_der, 0);
+ rb_define_alias(cX509Req, "to_s", "to_pem");
+ rb_define_method(cX509Req, "to_text", ossl_x509req_to_text, 0);
+ rb_define_method(cX509Req, "version", ossl_x509req_get_version, 0);
+ rb_define_method(cX509Req, "version=", ossl_x509req_set_version, 1);
+ rb_define_method(cX509Req, "subject", ossl_x509req_get_subject, 0);
+ rb_define_method(cX509Req, "subject=", ossl_x509req_set_subject, 1);
+ rb_define_method(cX509Req, "signature_algorithm", ossl_x509req_get_signature_algorithm, 0);
+ rb_define_method(cX509Req, "public_key", ossl_x509req_get_public_key, 0);
+ rb_define_method(cX509Req, "public_key=", ossl_x509req_set_public_key, 1);
+ rb_define_method(cX509Req, "sign", ossl_x509req_sign, 2);
+ rb_define_method(cX509Req, "verify", ossl_x509req_verify, 1);
+ rb_define_method(cX509Req, "attributes", ossl_x509req_get_attributes, 0);
+ rb_define_method(cX509Req, "attributes=", ossl_x509req_set_attributes, 1);
+ rb_define_method(cX509Req, "add_attribute", ossl_x509req_add_attribute, 1);
+}
+
diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c
new file mode 100644
index 0000000000..30ce75207f
--- /dev/null
+++ b/ext/openssl/ossl_x509revoked.c
@@ -0,0 +1,229 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Rev(klass, obj, rev) do { \
+ if (!rev) { \
+ ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_REVOKED_free, rev); \
+} while (0)
+#define GetX509Rev(obj, rev) do { \
+ Data_Get_Struct(obj, X509_REVOKED, rev); \
+ if (!rev) { \
+ ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Rev(obj, rev) do { \
+ OSSL_Check_Kind(obj, cX509Rev); \
+ GetX509Rev(obj, rev); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Rev;
+VALUE eX509RevError;
+
+/*
+ * PUBLIC
+ */
+VALUE
+ossl_x509revoked_new(X509_REVOKED *rev)
+{
+ X509_REVOKED *new;
+ VALUE obj;
+
+ if (!rev) {
+ new = X509_REVOKED_new();
+ } else {
+ new = X509_REVOKED_dup(rev);
+ }
+ if (!new) {
+ ossl_raise(eX509RevError, NULL);
+ }
+ WrapX509Rev(cX509Rev, obj, new);
+
+ return obj;
+}
+
+X509_REVOKED *
+DupX509RevokedPtr(VALUE obj)
+{
+ X509_REVOKED *rev, *new;
+
+ SafeGetX509Rev(obj, rev);
+ if (!(new = X509_REVOKED_dup(rev))) {
+ ossl_raise(eX509RevError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * PRIVATE
+ */
+static VALUE
+ossl_x509revoked_alloc(VALUE klass)
+{
+ X509_REVOKED *rev;
+ VALUE obj;
+
+ if (!(rev = X509_REVOKED_new())) {
+ ossl_raise(eX509RevError, NULL);
+ }
+ WrapX509Rev(klass, obj, rev);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)
+{
+ /* EMPTY */
+ return self;
+}
+
+static VALUE
+ossl_x509revoked_get_serial(VALUE self)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+
+ return asn1integer_to_num(rev->serialNumber);
+}
+
+static VALUE
+ossl_x509revoked_set_serial(VALUE self, VALUE num)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+ rev->serialNumber = num_to_asn1integer(num, rev->serialNumber);
+
+ return num;
+}
+
+static VALUE
+ossl_x509revoked_get_time(VALUE self)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+
+ return asn1time_to_time(rev->revocationDate);
+}
+
+static VALUE
+ossl_x509revoked_set_time(VALUE self, VALUE time)
+{
+ X509_REVOKED *rev;
+ time_t sec;
+
+ GetX509Rev(self, rev);
+ sec = time_to_time_t(time);
+ if (!X509_time_adj(rev->revocationDate, 0, &sec)) {
+ ossl_raise(eX509RevError, NULL);
+ }
+
+ return time;
+}
+/*
+ * Gets X509v3 extensions as array of X509Ext objects
+ */
+static VALUE
+ossl_x509revoked_get_extensions(VALUE self)
+{
+ X509_REVOKED *rev;
+ int count, i;
+ X509_EXTENSION *ext;
+ VALUE ary;
+
+ GetX509Rev(self, rev);
+ count = X509_REVOKED_get_ext_count(rev);
+ if (count < 0) {
+ OSSL_Debug("count < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ ext = X509_REVOKED_get_ext(rev, i);
+ rb_ary_push(ary, ossl_x509ext_new(ext));
+ }
+
+ return ary;
+}
+
+/*
+ * Sets X509_EXTENSIONs
+ */
+static VALUE
+ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
+{
+ X509_REVOKED *rev;
+ X509_EXTENSION *ext;
+ int i;
+ VALUE item;
+
+ GetX509Rev(self, rev);
+ Check_Type(ary, T_ARRAY);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ OSSL_Check_Kind(RARRAY(ary)->ptr[i], cX509Ext);
+ }
+ sk_X509_EXTENSION_pop_free(rev->extensions, X509_EXTENSION_free);
+ rev->extensions = NULL;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ item = RARRAY(ary)->ptr[i];
+ ext = DupX509ExtPtr(item);
+ if(!X509_REVOKED_add_ext(rev, ext, -1)) {
+ ossl_raise(eX509RevError, NULL);
+ }
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509revoked_add_extension(VALUE self, VALUE ext)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+ if(!X509_REVOKED_add_ext(rev, DupX509ExtPtr(ext), -1)) {
+ ossl_raise(eX509RevError, NULL);
+ }
+
+ return ext;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509revoked()
+{
+ eX509RevError = rb_define_class_under(mX509, "RevokedError", eOSSLError);
+
+ cX509Rev = rb_define_class_under(mX509, "Revoked", rb_cObject);
+
+ rb_define_alloc_func(cX509Rev, ossl_x509revoked_alloc);
+ rb_define_method(cX509Rev, "initialize", ossl_x509revoked_initialize, -1);
+
+ rb_define_method(cX509Rev, "serial", ossl_x509revoked_get_serial, 0);
+ rb_define_method(cX509Rev, "serial=", ossl_x509revoked_set_serial, 1);
+ rb_define_method(cX509Rev, "time", ossl_x509revoked_get_time, 0);
+ rb_define_method(cX509Rev, "time=", ossl_x509revoked_set_time, 1);
+ rb_define_method(cX509Rev, "extensions", ossl_x509revoked_get_extensions, 0);
+ rb_define_method(cX509Rev, "extensions=", ossl_x509revoked_set_extensions, 1);
+ rb_define_method(cX509Rev, "add_extension", ossl_x509revoked_add_extension, 1);
+}
+
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
new file mode 100644
index 0000000000..4c5f0624a9
--- /dev/null
+++ b/ext/openssl/ossl_x509store.c
@@ -0,0 +1,559 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+#include <rubysig.h>
+
+#define WrapX509Store(klass, obj, st) do { \
+ if (!st) { \
+ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, X509_STORE_free, st); \
+} while (0)
+#define GetX509Store(obj, st) do { \
+ Data_Get_Struct(obj, X509_STORE, st); \
+ if (!st) { \
+ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Store(obj, st) do { \
+ OSSL_Check_Kind(obj, cX509Store); \
+ GetX509Store(obj, st); \
+} while (0)
+
+#define WrapX509StCtx(klass, obj, ctx) do { \
+ if (!ctx) { \
+ ossl_raise(rb_eRuntimeError, "STORE_CTX wasn't initialized!"); \
+ } \
+ obj = Data_Wrap_Struct(klass, 0, ossl_x509stctx_free, ctx); \
+} while (0)
+#define GetX509StCtx(obj, ctx) do { \
+ Data_Get_Struct(obj, X509_STORE_CTX, ctx); \
+ if (!ctx) { \
+ ossl_raise(rb_eRuntimeError, "STORE_CTX is out of scope!"); \
+ } \
+} while (0)
+#define SafeGetX509StCtx(obj, storep) do { \
+ OSSL_Check_Kind(obj, cX509StoreContext); \
+ GetX509Store(obj, ctx); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Store;
+VALUE cX509StoreContext;
+VALUE eX509StoreError;
+
+/*
+ * Public functions
+ */
+VALUE
+ossl_x509store_new(X509_STORE *store)
+{
+ VALUE obj;
+
+ WrapX509Store(cX509Store, obj, store);
+
+ return obj;
+}
+
+X509_STORE *
+GetX509StorePtr(VALUE obj)
+{
+ X509_STORE *store;
+
+ SafeGetX509Store(obj, store);
+
+ return store;
+}
+
+X509_STORE *
+DupX509StorePtr(VALUE obj)
+{
+ X509_STORE *store;
+
+ SafeGetX509Store(obj, store);
+ CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE);
+
+ return store;
+}
+
+/*
+ * Private functions
+ */
+static VALUE
+ossl_x509store_alloc(VALUE klass)
+{
+ X509_STORE *store;
+ VALUE obj;
+
+ if((store = X509_STORE_new()) == NULL){
+ ossl_raise(eX509StoreError, NULL);
+ }
+ WrapX509Store(klass, obj, store);
+
+ return obj;
+}
+
+/*
+ * General callback for OpenSSL verify
+ */
+static VALUE
+ossl_x509store_set_vfy_cb(VALUE self, VALUE cb)
+{
+ X509_STORE *store;
+
+ GetX509Store(self, store);
+ X509_STORE_set_ex_data(store, ossl_verify_cb_idx, (void*)cb);
+ rb_iv_set(self, "@verify_callback", cb);
+
+ return cb;
+}
+
+static VALUE
+ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
+{
+ X509_STORE *store;
+
+ GetX509Store(self, store);
+ X509_STORE_set_verify_cb_func(store, ossl_verify_cb);
+ ossl_x509store_set_vfy_cb(self, Qnil);
+
+#if (OPENSSL_VERSION_NUMBER < 0x00907000L)
+ rb_iv_set(self, "@flags", INT2NUM(0));
+ rb_iv_set(self, "@purpose", INT2NUM(0));
+ rb_iv_set(self, "@trust", INT2NUM(0));
+#endif
+
+ /* last verification status */
+ rb_iv_set(self, "@error", Qnil);
+ rb_iv_set(self, "@error_string", Qnil);
+ rb_iv_set(self, "@chain", Qnil);
+
+ return self;
+}
+
+static VALUE
+ossl_x509store_set_flags(VALUE self, VALUE flags)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE *store;
+
+ GetX509Store(self, store);
+ X509_STORE_set_flags(store, NUM2LONG(flags));
+#else
+ rb_iv_set(self, "@flags", flags);
+#endif
+
+ return flags;
+}
+
+static VALUE
+ossl_x509store_set_purpose(VALUE self, VALUE purpose)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE *store;
+
+ GetX509Store(self, store);
+ X509_STORE_set_purpose(store, NUM2LONG(purpose));
+#else
+ rb_iv_set(self, "@purpose", purpose);
+#endif
+
+ return purpose;
+}
+
+static VALUE
+ossl_x509store_set_trust(VALUE self, VALUE trust)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE *store;
+
+ GetX509Store(self, store);
+ X509_STORE_set_trust(store, NUM2LONG(trust));
+#else
+ rb_iv_set(self, "@trust", trust);
+#endif
+
+ return trust;
+}
+
+static VALUE
+ossl_x509store_add_file(VALUE self, VALUE file)
+{
+ X509_STORE *store;
+ X509_LOOKUP *lookup;
+ char *path = NULL;
+
+ if(file != Qnil){
+ Check_SafeStr(file);
+ path = RSTRING(file)->ptr;
+ }
+ GetX509Store(self, store);
+ lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
+ if(lookup == NULL) ossl_raise(eX509StoreError, NULL);
+ if(X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509store_add_path(VALUE self, VALUE dir)
+{
+ X509_STORE *store;
+ X509_LOOKUP *lookup;
+ char *path = NULL;
+
+ if(dir != Qnil){
+ Check_SafeStr(dir);
+ path = RSTRING(dir)->ptr;
+ }
+ GetX509Store(self, store);
+ lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
+ if(lookup == NULL) ossl_raise(eX509StoreError, NULL);
+ if(X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509store_add_cert(VALUE self, VALUE arg)
+{
+ X509_STORE *store;
+ X509 *cert;
+
+ cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
+ GetX509Store(self, store);
+ X509_STORE_add_cert(store, cert);
+
+ return self;
+}
+
+static VALUE
+ossl_x509store_add_crl(VALUE self, VALUE arg)
+{
+ X509_STORE *store;
+ X509_CRL *crl;
+
+ crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
+ GetX509Store(self, store);
+ X509_STORE_add_crl(store, crl);
+
+ return self;
+}
+
+static VALUE ossl_x509stctx_get_err(VALUE);
+static VALUE ossl_x509stctx_get_err_string(VALUE);
+static VALUE ossl_x509stctx_get_chain(VALUE);
+
+static VALUE
+ossl_x509store_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE cert, chain;
+ VALUE ctx, proc, result;
+
+ rb_scan_args(argc, argv, "11", &cert, &chain);
+ ctx = rb_funcall(cX509StoreContext, rb_intern("new"), 3, self, cert, chain);
+ proc = rb_block_given_p() ? rb_block_proc() :
+ rb_iv_get(self, "@verify_callback");
+ rb_iv_set(ctx, "@verify_callback", proc);
+ result = rb_funcall(ctx, rb_intern("verify"), 0);
+
+ rb_iv_set(self, "@error", ossl_x509stctx_get_err(ctx));
+ rb_iv_set(self, "@error_string", ossl_x509stctx_get_err_string(ctx));
+ rb_iv_set(self, "@chain", ossl_x509stctx_get_chain(ctx));
+
+ return result;
+}
+
+/*
+ * Public Functions
+ */
+static void ossl_x509stctx_free(X509_STORE_CTX*);
+
+VALUE
+ossl_x509stctx_new(X509_STORE_CTX *ctx)
+{
+ VALUE obj;
+
+ WrapX509StCtx(cX509StoreContext, obj, ctx);
+
+ return obj;
+}
+
+VALUE
+ossl_x509stctx_clear_ptr(VALUE obj)
+{
+ OSSL_Check_Kind(obj, cX509StoreContext);
+ RDATA(obj)->data = NULL;
+
+ return obj;
+}
+
+/*
+ * Private functions
+ */
+static void
+ossl_x509stctx_free(X509_STORE_CTX *ctx)
+{
+ if(ctx->untrusted)
+ sk_X509_pop_free(ctx->untrusted, X509_free);
+ if(ctx->cert)
+ X509_free(ctx->cert);
+ X509_STORE_CTX_free(ctx);
+}
+
+static VALUE
+ossl_x509stctx_alloc(VALUE klass)
+{
+ X509_STORE_CTX *ctx;
+ VALUE obj;
+
+ if((ctx = X509_STORE_CTX_new()) == NULL){
+ ossl_raise(eX509StoreError, NULL);
+ }
+ WrapX509StCtx(klass, obj, ctx);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE store, cert, chain;
+ X509_STORE_CTX *ctx;
+ X509_STORE *x509st;
+ X509 *x509 = NULL;
+ STACK_OF(X509) *x509s = NULL;
+
+ GetX509StCtx(self, ctx);
+ rb_scan_args(argc, argv, "12", &store, &cert, &chain);
+ SafeGetX509Store(store, x509st);
+ if(!NIL_P(cert)) x509 = DupX509CertPtr(cert); /* NEED TO DUP */
+ if(!NIL_P(chain)) x509s = ossl_x509_ary2sk(chain);
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ if(X509_STORE_CTX_init(ctx, x509st, x509, x509s) != 1){
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(eX509StoreError, NULL);
+ }
+#else
+ X509_STORE_CTX_init(ctx, x509st, x509, x509s);
+ X509_STORE_CTX_set_flags(ctx, NUM2INT(rb_iv_get(store, "@flags")));
+ X509_STORE_CTX_set_purpose(ctx, NUM2INT(rb_iv_get(store, "@purpose")));
+ X509_STORE_CTX_set_trust(ctx, NUM2INT(rb_iv_get(store, "@trust")));
+#endif
+ rb_iv_set(self, "@verify_callback", rb_iv_get(store, "@verify_callback"));
+ rb_iv_set(self, "@cert", cert);
+
+ return self;
+}
+
+static VALUE
+ossl_x509stctx_verify(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+ int result;
+
+ GetX509StCtx(self, ctx);
+ X509_STORE_CTX_set_ex_data(ctx, ossl_verify_cb_idx,
+ (void*)rb_iv_get(self, "@verify_callback"));
+ result = X509_verify_cert(ctx);
+
+ return result ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_x509stctx_get_chain(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+ STACK_OF(X509) *chain;
+ X509 *x509;
+ int i, num;
+ VALUE ary;
+
+ GetX509StCtx(self, ctx);
+ if((chain = X509_STORE_CTX_get_chain(ctx)) == NULL){
+ return Qnil;
+ }
+ if((num = sk_X509_num(chain)) < 0){
+ OSSL_Debug("certs in chain < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(num);
+ for(i = 0; i < num; i++) {
+ x509 = sk_X509_value(chain, i);
+ rb_ary_push(ary, ossl_x509_new(x509));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509stctx_get_err(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+
+ return INT2FIX(X509_STORE_CTX_get_error(ctx));
+}
+
+static VALUE
+ossl_x509stctx_set_error(VALUE self, VALUE err)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+ X509_STORE_CTX_set_error(ctx, FIX2INT(err));
+
+ return err;
+}
+
+static VALUE
+ossl_x509stctx_get_err_string(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+ long err;
+
+ GetX509StCtx(self, ctx);
+ err = X509_STORE_CTX_get_error(ctx);
+
+ return rb_str_new2(X509_verify_cert_error_string(err));
+}
+
+static VALUE
+ossl_x509stctx_get_err_depth(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+
+ return INT2FIX(X509_STORE_CTX_get_error_depth(ctx));
+}
+
+static VALUE
+ossl_x509stctx_get_curr_cert(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+
+ return ossl_x509_new(X509_STORE_CTX_get_current_cert(ctx));
+}
+
+static VALUE
+ossl_x509stctx_get_curr_crl(VALUE self)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+ if(!ctx->current_crl) return Qnil;
+
+ return ossl_x509crl_new(ctx->current_crl);
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+ossl_x509stctx_cleanup(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+ X509_STORE_CTX_cleanup(ctx);
+
+ return self;
+}
+
+static VALUE
+ossl_x509stctx_set_flags(VALUE self, VALUE flags)
+{
+ X509_STORE_CTX *store;
+
+ GetX509StCtx(self, store);
+ X509_STORE_CTX_set_flags(store, NUM2LONG(flags));
+
+ return flags;
+}
+
+static VALUE
+ossl_x509stctx_set_purpose(VALUE self, VALUE purpose)
+{
+ X509_STORE_CTX *store;
+
+ GetX509StCtx(self, store);
+ X509_STORE_CTX_set_purpose(store, NUM2LONG(purpose));
+
+ return purpose;
+}
+
+static VALUE
+ossl_x509stctx_set_trust(VALUE self, VALUE trust)
+{
+ X509_STORE_CTX *store;
+
+ GetX509StCtx(self, store);
+ X509_STORE_CTX_set_trust(store, NUM2LONG(trust));
+
+ return trust;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509store()
+{
+ VALUE x509stctx;
+
+ eX509StoreError = rb_define_class_under(mX509, "StoreError", eOSSLError);
+
+ cX509Store = rb_define_class_under(mX509, "Store", rb_cObject);
+ rb_attr(cX509Store, rb_intern("verify_callback"), 1, 0, Qfalse);
+ rb_attr(cX509Store, rb_intern("error"), 1, 0, Qfalse);
+ rb_attr(cX509Store, rb_intern("error_string"), 1, 0, Qfalse);
+ rb_attr(cX509Store, rb_intern("chain"), 1, 0, Qfalse);
+ rb_define_alloc_func(cX509Store, ossl_x509store_alloc);
+ rb_define_method(cX509Store, "initialize", ossl_x509store_initialize, -1);
+ rb_define_method(cX509Store, "verify_callback=", ossl_x509store_set_vfy_cb, 1);
+ rb_define_method(cX509Store, "flags=", ossl_x509store_set_flags, 1);
+ rb_define_method(cX509Store, "purpose=", ossl_x509store_set_purpose, 1);
+ rb_define_method(cX509Store, "trust=", ossl_x509store_set_trust, 1);
+ rb_define_method(cX509Store, "add_path", ossl_x509store_add_path, 1);
+ rb_define_method(cX509Store, "add_file", ossl_x509store_add_file, 1);
+ rb_define_method(cX509Store, "add_cert", ossl_x509store_add_cert, 1);
+ rb_define_method(cX509Store, "add_crl", ossl_x509store_add_crl, 1);
+ rb_define_method(cX509Store, "verify", ossl_x509store_verify, -1);
+
+ cX509StoreContext = rb_define_class_under(mX509,"StoreContext",rb_cObject);
+ x509stctx = cX509StoreContext;
+ rb_define_alloc_func(cX509StoreContext, ossl_x509stctx_alloc);
+ rb_define_method(x509stctx,"initialize", ossl_x509stctx_initialize, -1);
+ rb_define_method(x509stctx,"verify", ossl_x509stctx_verify, 0);
+ rb_define_method(x509stctx,"chain", ossl_x509stctx_get_chain,0);
+ rb_define_method(x509stctx,"error", ossl_x509stctx_get_err, 0);
+ rb_define_method(x509stctx,"error=", ossl_x509stctx_set_error, 1);
+ rb_define_method(x509stctx,"error_string",ossl_x509stctx_get_err_string,0);
+ rb_define_method(x509stctx,"error_depth", ossl_x509stctx_get_err_depth, 0);
+ rb_define_method(x509stctx,"current_cert",ossl_x509stctx_get_curr_cert, 0);
+ rb_define_method(x509stctx,"current_crl", ossl_x509stctx_get_curr_crl, 0);
+ rb_define_method(x509stctx,"cleanup", ossl_x509stctx_cleanup, 0);
+ rb_define_method(x509stctx,"flags=", ossl_x509stctx_set_flags, 1);
+ rb_define_method(x509stctx,"purpose=", ossl_x509stctx_set_purpose, 1);
+ rb_define_method(x509stctx,"trust=", ossl_x509stctx_set_trust, 1);
+
+}
diff --git a/ext/openssl/ruby_missing.h b/ext/openssl/ruby_missing.h
new file mode 100644
index 0000000000..4bd08890f8
--- /dev/null
+++ b/ext/openssl/ruby_missing.h
@@ -0,0 +1,18 @@
+/*
+ * $Id$
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_RUBY_MISSING_H_)
+#define _OSS_RUBY_MISSING_H_
+
+#define rb_define_copy_func(klass, func) \
+ rb_define_method(klass, "initialize_copy", func, 1)
+
+#endif /* _OSS_RUBY_MISSING_H_ */
+
diff --git a/ext/pty/.cvsignore b/ext/pty/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/pty/.cvsignore
+++ b/ext/pty/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/pty/MANIFEST b/ext/pty/MANIFEST
deleted file mode 100644
index f46d611e5b..0000000000
--- a/ext/pty/MANIFEST
+++ /dev/null
@@ -1,12 +0,0 @@
-MANIFEST
-README
-README.expect
-README.expect.jp
-README.jp
-depend
-expect_sample.rb
-extconf.rb
-lib/expect.rb
-pty.c
-script.rb
-shl.rb
diff --git a/ext/pty/README b/ext/pty/README
index a09469d39c..42c7d4f891 100644
--- a/ext/pty/README
+++ b/ext/pty/README
@@ -33,43 +33,15 @@ following module fungtions:
the array is passed to the block as block parameters, and the
function itself returns nil.
- While the process spawned by this function is active, SIGCHLD
- is captured to handle the change of the child process. When the
- child process is suspended or finished, an exception is raised.
- As all SIGCHLD signal is captured and processed by PTY module,
- you can't use other function or method which spawns subprosesses
- (including signal() and IO.popen()) while the PTY subprocesses
- are active. Otherwise, unexpected exception will occur. To avoid
- this problem, see protect_signal() below.
-
- If this function is called with an iterator block, SIGCHLD signal
- is captured only within the block. Therefore, it is risky to use
- File objects for PTY subprocess outside the iterator block.
-
+ When the child process is suspended or finished, an exception is
+ raised. If this function is called with an iterator block,
+ exception is raised only within the block. Child process
+ monitor is terminated on block exit.
protect_signal
+ reset_signal
- This function takes an iterator block. Within the iterator block,
- no exception is raised even if any subprocess is terminated.
- This function is used to enable functions like system() or IO.popen()
- while PTY subprocess is active. For example,
-
- PTY.spawn("command_foo") do |r,w|
- ...
- ...
- PTY.protect_signal do
- system "some other commands"
- end
- ...
- end
-
- disables to send exception when "some other commands" is
- terminated.
-
- reset_signal
-
- Disables to handle SIGCHLD while PTY subprocess is active.
-
+ These functions are obsolete in this version of pty.
4. License
diff --git a/ext/pty/README.expect.jp b/ext/pty/README.expect.ja
index db84695ee5..db84695ee5 100644
--- a/ext/pty/README.expect.jp
+++ b/ext/pty/README.expect.ja
diff --git a/ext/pty/README.jp b/ext/pty/README.ja
index 5ae4fb06a0..5ae4fb06a0 100644
--- a/ext/pty/README.jp
+++ b/ext/pty/README.ja
diff --git a/ext/pty/expect_sample.rb b/ext/pty/expect_sample.rb
index 1311476c5d..bf8a2352fe 100644
--- a/ext/pty/expect_sample.rb
+++ b/ext/pty/expect_sample.rb
@@ -4,17 +4,16 @@
# by A. Ito
#
# This program reports the latest version of ruby interpreter
-# by connecting to ftp server at netlab.co.jp.
+# by connecting to ftp server at ruby-lang.org.
#
require 'pty'
require 'expect'
fnames = []
-PTY.spawn("ftp ftp.netlab.co.jp") do
- |r_f,w_f,pid|
+PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
w_f.sync = true
- $expect_verbose = true
+ $expect_verbose = false
r_f.expect(/^Name.*: /) do
w_f.print "ftp\n"
@@ -31,14 +30,14 @@ PTY.spawn("ftp ftp.netlab.co.jp") do
r_f.expect('word:') do
w_f.print username+"@\n"
end
- r_f.expect("ftp> ") do
- w_f.print "cd pub/lang/ruby\n"
+ r_f.expect("> ") do
+ w_f.print "cd pub/ruby\n"
end
- r_f.expect("ftp> ") do
+ r_f.expect("> ") do
w_f.print "dir\n"
end
- r_f.expect("ftp> ") do |output|
+ r_f.expect("> ") do |output|
for x in output[0].split("\n")
if x =~ /(ruby.*\.tar\.gz)/ then
fnames.push $1
diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb
index ba2b44c70b..5e126fe0cf 100644
--- a/ext/pty/extconf.rb
+++ b/ext/pty/extconf.rb
@@ -1,11 +1,14 @@
require 'mkmf'
-if /mswin32|mingw/ !~ RUBY_PLATFORM
+if /mswin32|mingw|bccwin32/ !~ RUBY_PLATFORM
have_header("sys/stropts.h")
have_func("setresuid")
- $CFLAGS << "-DHAVE_DEV_PTMX" if /cygwin/ === RUBY_PLATFORM
+ have_header("libutil.h")
+ have_header("pty.h")
+ have_library("util", "openpty")
if have_func("openpty") or
have_func("_getpty") or
+ have_func("ptsname") or
have_func("ioctl")
create_makefile('pty')
end
diff --git a/ext/pty/lib/expect.rb b/ext/pty/lib/expect.rb
index 54c69edadb..aa9ab895d3 100644
--- a/ext/pty/lib/expect.rb
+++ b/ext/pty/lib/expect.rb
@@ -20,12 +20,12 @@ class IO
STDOUT.print c
STDOUT.flush
end
- if buf =~ e_pat then
- result = [buf,$1,$2,$3,$4,$5,$6,$7,$8,$9]
+ if mat=e_pat.match(buf) then
+ result = [buf,*mat.to_a[1..-1]]
break
end
end
- if iterator? then
+ if block_given? then
yield result
else
return result
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 66907416eb..cfd7e4854e 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -1,13 +1,20 @@
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/file.h>
#include <fcntl.h>
#include <errno.h>
#include <pwd.h>
-#if !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY)
+#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+#ifdef HAVE_PTY_H
+#include <pty.h>
+#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#else
@@ -17,6 +24,7 @@
#include "ruby.h"
#include "rubyio.h"
+#include "util.h"
#include <signal.h>
#ifdef HAVE_SYS_STROPTS_H
@@ -30,7 +38,8 @@
#define DEVICELEN 16
#if !defined(HAVE_OPENPTY)
-#ifdef __hpux
+#if defined(__hpux)
+static
char *MasterDevice = "/dev/ptym/pty%s",
*SlaveDevice = "/dev/pty/tty%s",
*deviceNo[] = {
@@ -52,8 +61,8 @@ char *MasterDevice = "/dev/ptym/pty%s",
"w8","w9","wa","wb","wc","wd","we","wf",
0,
};
-#else /* NOT HPUX */
-#ifdef _IBMESA /* AIX/ESA */
+#elif defined(_IBMESA) /* AIX/ESA */
+static
char *MasterDevice = "/dev/ptyp%s",
*SlaveDevice = "/dev/ttyp%s",
*deviceNo[] = {
@@ -74,7 +83,8 @@ char *MasterDevice = "/dev/ptyp%s",
"e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef",
"f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff",
};
-#else
+#elif !defined(HAVE_PTSNAME)
+static
char *MasterDevice = "/dev/pty%s",
*SlaveDevice = "/dev/tty%s",
*deviceNo[] = {
@@ -84,20 +94,17 @@ char *MasterDevice = "/dev/pty%s",
"q8","q9","qa","qb","qc","qd","qe","qf",
"r0","r1","r2","r3","r4","r5","r6","r7",
"r8","r9","ra","rb","rc","rd","re","rf",
+ "s0","s1","s2","s3","s4","s5","s6","s7",
+ "s8","s9","sa","sb","sc","sd","se","sf",
0,
};
-#endif /* _IBMESA */
-#endif /* HPUX */
+#endif
#endif /* !defined(HAVE_OPENPTY) */
-char SlaveName[DEVICELEN];
+static char SlaveName[DEVICELEN];
extern int errno;
-#define MAX_PTY 16
-static int n_pty,last_pty;
-static int chld_pid[MAX_PTY];
-
#ifndef HAVE_SETEUID
# ifdef HAVE_SETREUID
# define seteuid(e) setreuid(-1, (e))
@@ -110,109 +117,97 @@ static int chld_pid[MAX_PTY];
# endif /* HAVE_SETREUID */
#endif /* NO_SETEUID */
-struct pty_info {
- int fd;
- pid_t child_pid;
-};
+static VALUE eChildExited;
-static void
-set_signal_action(action)
- RETSIGTYPE (*action)();
+static VALUE
+echild_status(self)
+ VALUE self;
{
-#ifdef __hpux
- struct sigvec sv;
- /*
- * signal SIGCHLD should be delivered on stop of the child
- */
- sv.sv_handler = action;
- sv.sv_mask = sigmask(SIGCHLD);
- sv.sv_flags = SV_BSDSIG;
- sigvector(SIGCHLD, &sv, (struct sigvec *) 0);
-#else /* not HPUX */
-#if defined(SA_NOCLDSTOP)
- struct sigaction sa;
- /*
- * signal SIGCHLD should be delivered on stop of the child
- * (for SVR4)
- */
- sa.sa_handler = action;
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGCHLD);
- sa.sa_flags = 0; /* SA_NOCLDSTOP flag is removed */
- sigaction(SIGCHLD, &sa, (struct sigaction *) 0);
-#else
- signal(SIGCHLD,action);
-#endif
-#endif /* not HPUX */
-
+ return rb_ivar_get(self, rb_intern("status"));
}
+struct pty_info {
+ int fd;
+ pid_t child_pid;
+ VALUE thread;
+};
+
static void
-reset_signal_action()
+raise_from_wait(state, info)
+ struct pty_info *info;
+ char *state;
{
- set_signal_action(SIG_DFL);
+ extern VALUE rb_last_status;
+ char buf[1024];
+ VALUE exc;
+
+ snprintf(buf, sizeof(buf), "pty - %s: %d", state, info->child_pid);
+ exc = rb_exc_new2(eChildExited, buf);
+ rb_iv_set(exc, "status", rb_last_status);
+ rb_funcall(info->thread, rb_intern("raise"), 1, exc);
}
-static RETSIGTYPE
-chld_changed()
+static VALUE
+pty_syswait(info)
+ struct pty_info *info;
{
- int cpid;
- int i,n = -1;
- int statusp;
+ int cpid, status;
for (;;) {
-#ifdef HAVE_WAITPID
- cpid = waitpid(-1, &statusp, WUNTRACED|WNOHANG);
-#else
- cpid = wait3(&statusp, WUNTRACED|WNOHANG, 0);
-#endif
- if (cpid == 0 || cpid == -1)
- return;
- for (i = 0; i < last_pty; i++) {
- if (chld_pid[i] == cpid) {
- n = i;
- goto catched;
- }
- }
- rb_raise(rb_eRuntimeError, "fork: %d", cpid);
- }
- catched:
+ cpid = rb_waitpid(info->child_pid, &status, WUNTRACED);
+ if (cpid == -1) return Qnil;
-#ifdef IF_STOPPED
- if (IF_STOPPED(statusp)) { /* suspend */
- rb_raise(rb_eRuntimeError, "Stopped: %d",cpid);
- }
-#else
-#ifdef WIFSTOPPED
- if (WIFSTOPPED(statusp)) { /* suspend */
- rb_raise(rb_eRuntimeError, "Stopped: %d",cpid);
- }
+#if defined(IF_STOPPED)
+ if (IF_STOPPED(status)) { /* suspend */
+ raise_from_wait("stopped", info);
+ }
+#elif defined(WIFSTOPPED)
+ if (WIFSTOPPED(status)) { /* suspend */
+ raise_from_wait("stopped", info);
+ }
#else
---->> Either IF_STOPPED or WIFSTOPPED is needed <<----
-#endif /* WIFSTOPPED */
-#endif /* IF_STOPPED */
- if (n >= 0) {
- chld_pid[n] = 0;
- n_pty--;
- if (n_pty == 0)
- reset_signal_action();
+#endif /* WIFSTOPPED | IF_STOPPED */
+ else if (kill(info->child_pid, 0) == 0) {
+ raise_from_wait("changed", info);
+ }
+ else {
+ raise_from_wait("exited", info);
+ return Qnil;
+ }
}
- rb_raise(rb_eRuntimeError, "Child_changed: %d",cpid);
}
static void getDevice _((int*, int*));
+struct exec_info {
+ int argc;
+ VALUE *argv;
+};
+
+static VALUE
+pty_exec(arg)
+ struct exec_info *arg;
+{
+ return rb_f_exec(arg->argc, arg->argv);
+}
+
static void
-establishShell(shellname, info)
- char *shellname;
+establishShell(argc, argv, info)
+ int argc;
+ VALUE *argv;
struct pty_info *info;
{
- static int i,j,master,slave,currentPid;
+ static int i,master,slave,currentPid;
char *p,*getenv();
struct passwd *pwent;
- RETSIGTYPE chld_changed();
-
- if (shellname[0] == '\0') {
+ VALUE v;
+ struct exec_info arg;
+ int status;
+
+ if (argc == 0) {
+ char *shellname;
+
if ((p = getenv("SHELL")) != NULL) {
shellname = p;
}
@@ -223,18 +218,21 @@ establishShell(shellname, info)
else
shellname = "/bin/sh";
}
+ v = rb_str_new2(shellname);
+ argc = 1;
+ argv = &v;
}
getDevice(&master,&slave);
+ info->thread = rb_thread_current();
currentPid = getpid();
- set_signal_action(chld_changed);
- if((i = vfork()) < 0) {
+ if((i = fork()) < 0) {
+ close(master);
+ close(slave);
rb_sys_fail("fork failed");
}
if(i == 0) { /* child */
- int argc;
- char *argv[1024];
currentPid = getpid();
/*
@@ -281,46 +279,33 @@ establishShell(shellname, info)
dup2(slave,1);
dup2(slave,2);
close(slave);
-
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRESUID)
seteuid(getuid());
#endif
- argc = 0;
- for (i = 0; shellname[i];) {
- while (isspace(shellname[i])) i++;
- for (j = i; shellname[j] && !isspace(shellname[j]); j++);
- argv[argc] = (char*)xmalloc(j-i+1);
- strncpy(argv[argc],&shellname[i],j-i);
- argv[argc][j-i] = 0;
- i = j;
- argc++;
- }
- argv[argc] = NULL;
- execvp(argv[0],argv);
+ arg.argc = argc;
+ arg.argv = argv;
+ rb_protect(pty_exec, (VALUE)&arg, &status);
sleep(1);
_exit(1);
}
close(slave);
- if (n_pty == last_pty) {
- chld_pid[n_pty] = i;
- n_pty++;
- last_pty++;
- }
- else {
- for (j = 0; j < last_pty; j++) {
- if (chld_pid[j] == 0) {
- chld_pid[j] = i;
- n_pty++;
- }
- }
- }
info->child_pid = i;
info->fd = master;
}
+static VALUE
+pty_finalize_syswait(info)
+ struct pty_info *info;
+{
+ rb_thread_kill(info->thread);
+ rb_funcall(info->thread, rb_intern("value"), 0);
+ rb_detach_process(info->child_pid);
+ return Qnil;
+}
+
#ifdef HAVE_OPENPTY
/*
* Use openpty(3) of 4.3BSD Reno and later,
@@ -355,11 +340,9 @@ static void
getDevice(master,slave)
int *master,*slave;
{
- char **p;
int i,j;
- char MasterName[DEVICELEN];
-#ifdef HAVE_DEV_PTMX
+#ifdef HAVE_PTSNAME
char *pn;
void (*s)();
@@ -374,7 +357,7 @@ getDevice(master,slave)
if(unlockpt(i) != -1) {
if((pn = ptsname(i)) != NULL) {
if((j = open(pn, O_RDWR, 0)) != -1) {
-#if defined I_PUSH
+#if defined I_PUSH && !defined linux
if(ioctl(j, I_PUSH, "ptem") != -1) {
if(ioctl(j, I_PUSH, "ldterm") != -1) {
#endif
@@ -382,7 +365,7 @@ getDevice(master,slave)
*slave = j;
strcpy(SlaveName, pn);
return;
-#if defined I_PUSH
+#if defined I_PUSH && !defined linux
}
}
#endif
@@ -394,11 +377,14 @@ getDevice(master,slave)
}
rb_raise(rb_eRuntimeError, "Cannot get Master/Slave device");
#else
+ char **p;
+ char MasterName[DEVICELEN];
+
for (p = deviceNo; *p != NULL; p++) {
- sprintf(MasterName ,MasterDevice,*p);
+ sprintf(MasterName,MasterDevice,*p);
if ((i = open(MasterName,O_RDWR,0)) >= 0) {
*master = i;
- sprintf(SlaveName ,SlaveDevice,*p);
+ sprintf(SlaveName,SlaveDevice,*p);
if ((j = open(SlaveName,O_RDWR,0)) >= 0) {
*slave = j;
chown(SlaveName, getuid(), getgid());
@@ -408,7 +394,7 @@ getDevice(master,slave)
close(i);
}
}
- rb_raise(rb_eRuntimeError, "Cannot get %s\n", SlaveDevice);
+ rb_raise(rb_eRuntimeError, "Cannot get %s", SlaveName);
#endif
}
#endif /* HAVE__GETPTY */
@@ -423,66 +409,63 @@ freeDevice()
/* ruby function: getpty */
static VALUE
-pty_getpty(self, shell)
- VALUE self, shell;
+pty_getpty(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE res;
struct pty_info info;
+ struct pty_info thinfo;
OpenFile *wfptr,*rfptr;
- NEWOBJ(rport, struct RFile);
- NEWOBJ(wport, struct RFile);
+ VALUE rport = rb_obj_alloc(rb_cFile);
+ VALUE wport = rb_obj_alloc(rb_cFile);
- if (n_pty == MAX_PTY+1) {
- rb_raise(rb_eRuntimeError, "Too many ptys are open");
- }
-
- OBJSETUP(rport, rb_cFile, T_FILE);
MakeOpenFile(rport, rfptr);
-
- OBJSETUP(wport, rb_cFile, T_FILE);
MakeOpenFile(wport, wfptr);
- establishShell(RSTRING(shell)->ptr,&info);
+ establishShell(argc, argv, &info);
rfptr->mode = rb_io_mode_flags("r");
rfptr->f = fdopen(info.fd, "r");
- rfptr->path = strdup(RSTRING(shell)->ptr);
+ rfptr->path = strdup(SlaveName);
- wfptr->mode = rb_io_mode_flags("w");
+ wfptr->mode = rb_io_mode_flags("w") | FMODE_SYNC;
wfptr->f = fdopen(dup(info.fd), "w");
- wfptr->path = strdup(RSTRING(shell)->ptr);
+ wfptr->path = strdup(SlaveName);
- res = rb_ary_new2(2);
+ res = rb_ary_new2(3);
rb_ary_store(res,0,(VALUE)rport);
rb_ary_store(res,1,(VALUE)wport);
rb_ary_store(res,2,INT2FIX(info.child_pid));
+ thinfo.thread = rb_thread_create(pty_syswait, (void*)&info);
+ thinfo.child_pid = info.child_pid;
+ rb_thread_schedule();
+
if (rb_block_given_p()) {
- rb_yield((VALUE)res);
- reset_signal_action();
+ rb_ensure(rb_yield, res, pty_finalize_syswait, (VALUE)&thinfo);
return Qnil;
}
- else {
- return (VALUE)res;
- }
+ return res;
}
-/* ruby function: protect_signal */
+/* ruby function: protect_signal - obsolete */
static VALUE
pty_protect(self)
VALUE self;
{
- reset_signal_action();
+ rb_warn("PTY::protect_signal is no longer needed");
rb_yield(Qnil);
- set_signal_action(chld_changed);
return self;
}
+/* ruby function: reset_signal - obsolete */
static VALUE
pty_reset_signal(self)
VALUE self;
{
- reset_signal_action();
+ rb_warn("PTY::reset_signal is no longer needed");
return self;
}
@@ -492,8 +475,11 @@ void
Init_pty()
{
cPTY = rb_define_module("PTY");
- rb_define_module_function(cPTY,"getpty",pty_getpty,1);
- rb_define_module_function(cPTY,"spawn",pty_getpty,1);
+ rb_define_module_function(cPTY,"getpty",pty_getpty,-1);
+ rb_define_module_function(cPTY,"spawn",pty_getpty,-1);
rb_define_module_function(cPTY,"protect_signal",pty_protect,0);
rb_define_module_function(cPTY,"reset_signal",pty_reset_signal,0);
+
+ eChildExited = rb_define_class_under(cPTY,"ChildExited",rb_eRuntimeError);
+ rb_define_method(eChildExited,"status",echild_status,0);
}
diff --git a/ext/pty/script.rb b/ext/pty/script.rb
index 3084935637..dbb933171f 100644
--- a/ext/pty/script.rb
+++ b/ext/pty/script.rb
@@ -10,8 +10,7 @@ logfile = File.open(ofile,"a")
system "stty -echo raw lnext ^_"
-PTY.spawn("/bin/csh") do
- |r_pty,w_pty,pid|
+PTY.spawn("/bin/csh") do |r_pty,w_pty,pid|
Thread.new do
while true
diff --git a/ext/pty/shl.rb b/ext/pty/shl.rb
index 0c04a2735c..cdaf8d7398 100644
--- a/ext/pty/shl.rb
+++ b/ext/pty/shl.rb
@@ -18,9 +18,7 @@ $r_pty = nil
$w_pty = nil
def writer
- PTY.protect_signal do
- system "stty -echo raw"
- end
+ system "stty -echo raw"
begin
while true
c = STDIN.getc
@@ -35,9 +33,7 @@ def writer
$reader.raise(nil)
return 'Exit'
ensure
- PTY.protect_signal do
- system "stty echo -raw"
- end
+ system "stty echo -raw"
end
end
diff --git a/ext/racc/cparse/.cvsignore b/ext/racc/cparse/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/racc/cparse/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
new file mode 100644
index 0000000000..24c4e36f2b
--- /dev/null
+++ b/ext/racc/cparse/cparse.c
@@ -0,0 +1,824 @@
+/*
+
+ cparse.c -- racc runtime core
+
+ Copyright (c) 1999-2003 Minero Aoki <aamine@loveruby.net>
+
+ This library is free software.
+ You can distribute/modify this program under the same terms of ruby.
+
+ $raccId: cparse.c,v 1.3 2003/11/03 12:20:54 aamine Exp $
+
+*/
+
+#include "ruby.h"
+#include <stdio.h>
+
+
+/* -----------------------------------------------------------------------
+ Important Constants
+----------------------------------------------------------------------- */
+
+#define RACC_VERSION "1.4.4"
+
+#define DEFAULT_TOKEN -1
+#define ERROR_TOKEN 1
+#define FINAL_TOKEN 0
+
+#define vDEFAULT_TOKEN INT2FIX(DEFAULT_TOKEN)
+#define vERROR_TOKEN INT2FIX(ERROR_TOKEN)
+#define vFINAL_TOKEN INT2FIX(FINAL_TOKEN)
+
+
+/* -----------------------------------------------------------------------
+ File Local Variables
+----------------------------------------------------------------------- */
+
+static VALUE RaccBug;
+static VALUE CparseParams;
+
+static ID id_yydebug;
+static ID id_nexttoken;
+static ID id_onerror;
+static ID id_noreduce;
+static ID id_catch;
+static VALUE sym_raccjump;
+static ID id_errstatus;
+
+static ID id_d_shift;
+static ID id_d_reduce;
+static ID id_d_accept;
+static ID id_d_read_token;
+static ID id_d_next_state;
+static ID id_d_e_pop;
+
+
+/* -----------------------------------------------------------------------
+ Utils
+----------------------------------------------------------------------- */
+
+static ID value_to_id _((VALUE v));
+static inline long num_to_long _((VALUE n));
+
+#ifdef ID2SYM
+# define id_to_value(i) ID2SYM(i)
+#else
+# define id_to_value(i) ULONG2NUM(i)
+#endif
+
+static ID
+value_to_id(v)
+ VALUE v;
+{
+#ifndef SYMBOL_P
+# define SYMBOL_P(v) FIXNUM_P(v)
+#endif
+ if (! SYMBOL_P(v)) {
+ rb_raise(rb_eTypeError, "not symbol");
+ }
+#ifdef SYM2ID
+ return SYM2ID(v);
+#else
+ return (ID)NUM2ULONG(v);
+#endif
+}
+
+#ifndef LONG2NUM
+# define LONG2NUM(i) INT2NUM(i)
+#endif
+
+static inline long
+num_to_long(n)
+ VALUE n;
+{
+ return NUM2LONG(n);
+}
+
+#define AREF(s, idx) \
+ ((0 <= idx && idx < RARRAY(s)->len) ? RARRAY(s)->ptr[idx] : Qnil)
+
+
+/* -----------------------------------------------------------------------
+ Parser Stack Interfaces
+----------------------------------------------------------------------- */
+
+static VALUE get_stack_tail _((VALUE stack, long len));
+static void cut_stack_tail _((VALUE stack, long len));
+
+static VALUE
+get_stack_tail(stack, len)
+ VALUE stack;
+ long len;
+{
+ if (len < 0) return Qnil; /* system error */
+ if (len > RARRAY(stack)->len) len = RARRAY(stack)->len;
+ return rb_ary_new4(len, RARRAY(stack)->ptr + RARRAY(stack)->len - len);
+}
+
+static void
+cut_stack_tail(stack, len)
+ VALUE stack;
+ long len;
+{
+ while (len > 0) {
+ rb_ary_pop(stack);
+ len--;
+ }
+}
+
+#define STACK_INIT_LEN 64
+#define NEW_STACK() rb_ary_new2(STACK_INIT_LEN)
+#define PUSH(s, i) rb_ary_store(s, RARRAY(s)->len, i)
+#define POP(s) rb_ary_pop(s)
+#define LAST_I(s) \
+ ((RARRAY(s)->len > 0) ? RARRAY(s)->ptr[RARRAY(s)->len - 1] : Qnil)
+#define GET_TAIL(s, len) get_stack_tail(s, len)
+#define CUT_TAIL(s, len) cut_stack_tail(s, len)
+
+
+/* -----------------------------------------------------------------------
+ struct cparse_params
+----------------------------------------------------------------------- */
+
+struct cparse_params {
+ VALUE value_v; /* VALUE version of this struct */
+
+ VALUE parser; /* parser object */
+
+ int lex_is_iterator;
+ VALUE lexer; /* scanner object */
+ ID lexmid; /* name of scanner method (must be an iterator) */
+
+ /* State transition tables (immutable)
+ Data structure is from Dragon Book 4.9 */
+ /* action table */
+ VALUE action_table;
+ VALUE action_check;
+ VALUE action_default;
+ VALUE action_pointer;
+ /* goto table */
+ VALUE goto_table;
+ VALUE goto_check;
+ VALUE goto_default;
+ VALUE goto_pointer;
+
+ long nt_base; /* NonTerminal BASE index */
+ VALUE reduce_table; /* reduce data table */
+ VALUE token_table; /* token conversion table */
+
+ /* parser stacks and parameters */
+ VALUE state;
+ long curstate;
+ VALUE vstack;
+ VALUE tstack;
+ VALUE t;
+ long shift_n;
+ long reduce_n;
+ long ruleno;
+
+ long errstatus; /* nonzero in error recovering mode */
+ long nerr; /* number of error */
+
+ int use_result_var;
+
+ VALUE retval; /* return value of parser routine */
+ long fin; /* parse result status */
+#define CP_FIN_ACCEPT 1
+#define CP_FIN_EOT 2
+#define CP_FIN_CANTPOP 3
+
+ int debug; /* user level debug */
+ int sys_debug; /* system level debug */
+
+ long i; /* table index */
+};
+
+
+/* -----------------------------------------------------------------------
+ Parser Main Routines
+----------------------------------------------------------------------- */
+
+static VALUE racc_cparse _((VALUE parser, VALUE arg, VALUE sysdebug));
+static VALUE racc_yyparse _((VALUE parser, VALUE lexer, VALUE lexmid,
+ VALUE arg, VALUE sysdebug));
+
+static void call_lexer _((struct cparse_params *v));
+static VALUE lexer_iter _((VALUE data));
+static VALUE lexer_i _((VALUE block_args, VALUE data, VALUE self));
+
+static VALUE assert_array _((VALUE a));
+static long assert_integer _((VALUE n));
+static VALUE assert_hash _((VALUE h));
+static void initialize_params _((struct cparse_params *v,
+ VALUE parser, VALUE arg,
+ VALUE lexer, VALUE lexmid));
+
+static void parse_main _((struct cparse_params *v,
+ VALUE tok, VALUE val, int resume));
+static void extract_user_token _((struct cparse_params *v,
+ VALUE block_args, VALUE *tok, VALUE *val));
+static void shift _((struct cparse_params* v, long act, VALUE tok, VALUE val));
+static int reduce _((struct cparse_params* v, long act));
+static VALUE catch_iter _((VALUE dummy));
+static VALUE reduce0 _((VALUE block_args, VALUE data, VALUE self));
+
+#ifdef DEBUG
+# define D_puts(msg) if (v->sys_debug) puts(msg)
+# define D_printf(fmt,arg) if (v->sys_debug) printf(fmt,arg)
+#else
+# define D_puts(msg)
+# define D_printf(fmt,arg)
+#endif
+
+static VALUE
+racc_cparse(parser, arg, sysdebug)
+ VALUE parser, arg, sysdebug;
+{
+ struct cparse_params params;
+ struct cparse_params *v = &params;
+
+ D_puts("starting cparse");
+ v->sys_debug = RTEST(sysdebug);
+ initialize_params(v, parser, arg, Qnil, Qnil);
+ v->lex_is_iterator = Qfalse;
+ parse_main(v, Qnil, Qnil, 0);
+
+ return v->retval;
+}
+
+static VALUE
+racc_yyparse(parser, lexer, lexmid, arg, sysdebug)
+ VALUE parser, lexer, lexmid, arg, sysdebug;
+{
+ struct cparse_params params;
+ struct cparse_params *v = &params;
+
+ v->sys_debug = RTEST(sysdebug);
+ D_puts("start C yyparse");
+ initialize_params(v, parser, arg, lexer, lexmid);
+ v->lex_is_iterator = Qtrue;
+ D_puts("params initialized");
+ parse_main(v, Qnil, Qnil, 0);
+ call_lexer(v);
+ if (!v->fin) {
+ rb_raise(rb_eArgError, "%s() is finished before EndOfToken",
+ rb_id2name(v->lexmid));
+ }
+
+ return v->retval;
+}
+
+static void
+call_lexer(v)
+ struct cparse_params *v;
+{
+ rb_iterate(lexer_iter, v->value_v, lexer_i, v->value_v);
+}
+
+static VALUE
+lexer_iter(data)
+ VALUE data;
+{
+ struct cparse_params *v;
+
+ Data_Get_Struct(data, struct cparse_params, v);
+ rb_funcall(v->lexer, v->lexmid, 0);
+ return Qnil;
+}
+
+static VALUE
+lexer_i(block_args, data, self)
+ VALUE block_args, data, self;
+{
+ struct cparse_params *v;
+ VALUE tok, val;
+
+ Data_Get_Struct(data, struct cparse_params, v);
+ if (v->fin)
+ rb_raise(rb_eArgError, "extra token after EndOfToken");
+ extract_user_token(v, block_args, &tok, &val);
+ parse_main(v, tok, val, 1);
+ if (v->fin && v->fin != CP_FIN_ACCEPT)
+ rb_iter_break();
+ return Qnil;
+}
+
+static VALUE
+assert_array(a)
+ VALUE a;
+{
+ Check_Type(a, T_ARRAY);
+ return a;
+}
+
+static VALUE
+assert_hash(h)
+ VALUE h;
+{
+ Check_Type(h, T_HASH);
+ return h;
+}
+
+static long
+assert_integer(n)
+ VALUE n;
+{
+ return NUM2LONG(n);
+}
+
+static void
+initialize_params(v, parser, arg, lexer, lexmid)
+ struct cparse_params *v;
+ VALUE parser, arg, lexer, lexmid;
+{
+ v->value_v = Data_Wrap_Struct(CparseParams, 0, 0, v);
+
+ v->parser = parser;
+ v->lexer = lexer;
+ if (! NIL_P(lexmid))
+ v->lexmid = value_to_id(lexmid);
+
+ v->debug = RTEST(rb_ivar_get(parser, id_yydebug));
+
+ Check_Type(arg, T_ARRAY);
+ if (!(13 <= RARRAY(arg)->len && RARRAY(arg)->len <= 14))
+ rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY(arg)->len);
+ v->action_table = assert_array (RARRAY(arg)->ptr[ 0]);
+ v->action_check = assert_array (RARRAY(arg)->ptr[ 1]);
+ v->action_default = assert_array (RARRAY(arg)->ptr[ 2]);
+ v->action_pointer = assert_array (RARRAY(arg)->ptr[ 3]);
+ v->goto_table = assert_array (RARRAY(arg)->ptr[ 4]);
+ v->goto_check = assert_array (RARRAY(arg)->ptr[ 5]);
+ v->goto_default = assert_array (RARRAY(arg)->ptr[ 6]);
+ v->goto_pointer = assert_array (RARRAY(arg)->ptr[ 7]);
+ v->nt_base = assert_integer(RARRAY(arg)->ptr[ 8]);
+ v->reduce_table = assert_array (RARRAY(arg)->ptr[ 9]);
+ v->token_table = assert_hash (RARRAY(arg)->ptr[10]);
+ v->shift_n = assert_integer(RARRAY(arg)->ptr[11]);
+ v->reduce_n = assert_integer(RARRAY(arg)->ptr[12]);
+ if (RARRAY(arg)->len > 13) {
+ v->use_result_var = RTEST(RARRAY(arg)->ptr[13]);
+ }
+ else {
+ v->use_result_var = Qtrue;
+ }
+
+ v->tstack = v->debug ? NEW_STACK() : Qnil;
+ v->vstack = NEW_STACK();
+ v->state = NEW_STACK();
+ v->curstate = 0;
+ PUSH(v->state, INT2FIX(0));
+ v->t = INT2FIX(FINAL_TOKEN + 1); /* must not init to FINAL_TOKEN */
+ v->nerr = 0;
+ v->errstatus = 0;
+ rb_ivar_set(parser, id_errstatus, LONG2NUM(v->errstatus));
+
+ v->retval = Qnil;
+ v->fin = 0;
+
+ v->lex_is_iterator = Qfalse;
+}
+
+static void
+extract_user_token(v, block_args, tok, val)
+ struct cparse_params *v;
+ VALUE block_args;
+ VALUE *tok, *val;
+{
+ if (NIL_P(block_args)) {
+ /* EOF */
+ *tok = Qfalse;
+ *val = rb_str_new("$", 1);
+ return;
+ }
+
+ if (TYPE(block_args) != T_ARRAY) {
+ rb_raise(rb_eTypeError,
+ "%s() %s %s (must be Array[2])",
+ v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
+ v->lex_is_iterator ? "yielded" : "returned",
+ rb_class2name(CLASS_OF(block_args)));
+ }
+ if (RARRAY(block_args)->len != 2) {
+ rb_raise(rb_eArgError,
+ "%s() %s wrong size of array (%ld for 2)",
+ v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
+ v->lex_is_iterator ? "yielded" : "returned",
+ RARRAY(block_args)->len);
+ }
+ *tok = AREF(block_args, 0);
+ *val = AREF(block_args, 1);
+}
+
+#define SHIFT(v,act,tok,val) shift(v,act,tok,val)
+#define REDUCE(v,act) do {\
+ switch (reduce(v,act)) { \
+ case 0: /* normal */ \
+ break; \
+ case 1: /* yyerror */ \
+ goto user_yyerror; \
+ case 2: /* yyaccept */ \
+ D_puts("u accept"); \
+ goto accept; \
+ default: \
+ break; \
+ } \
+} while (0)
+
+static void
+parse_main(v, tok, val, resume)
+ struct cparse_params *v;
+ VALUE tok, val;
+ int resume;
+{
+ long i; /* table index */
+ long act; /* action type */
+ VALUE act_value; /* action type, VALUE version */
+ int read_next = 1; /* true if we need to read next token */
+ VALUE tmp;
+
+ if (resume)
+ goto resume;
+
+ while (1) {
+ D_puts("");
+ D_puts("---- enter new loop ----");
+ D_puts("");
+
+ D_printf("(act) k1=%ld\n", v->curstate);
+ tmp = AREF(v->action_pointer, v->curstate);
+ if (NIL_P(tmp)) goto notfound;
+ D_puts("(act) pointer[k1] ok");
+ i = NUM2LONG(tmp);
+
+ D_printf("read_next=%d\n", read_next);
+ if (read_next && (v->t != vFINAL_TOKEN)) {
+ if (v->lex_is_iterator) {
+ D_puts("resuming...");
+ if (v->fin) rb_raise(rb_eArgError, "token given after EOF");
+ v->i = i; /* save i */
+ return;
+ resume:
+ D_puts("resumed");
+ i = v->i; /* load i */
+ }
+ else {
+ D_puts("next_token");
+ tmp = rb_funcall(v->parser, id_nexttoken, 0);
+ extract_user_token(v, tmp, &tok, &val);
+ }
+ /* convert token */
+ tmp = rb_hash_aref(v->token_table, tok);
+ v->t = NIL_P(tmp) ? vERROR_TOKEN : tmp;
+ D_printf("(act) t(k2)=%ld\n", NUM2LONG(v->t));
+ if (v->debug) {
+ rb_funcall(v->parser, id_d_read_token,
+ 3, v->t, tok, val);
+ }
+ }
+ read_next = 0;
+
+ i += NUM2LONG(v->t);
+ D_printf("(act) i=%ld\n", i);
+ if (i < 0) goto notfound;
+
+ act_value = AREF(v->action_table, i);
+ if (NIL_P(act_value)) goto notfound;
+ act = NUM2LONG(act_value);
+ D_printf("(act) table[i]=%ld\n", act);
+
+ tmp = AREF(v->action_check, i);
+ if (NIL_P(tmp)) goto notfound;
+ if (NUM2LONG(tmp) != v->curstate) goto notfound;
+ D_printf("(act) check[i]=%ld\n", NUM2LONG(tmp));
+
+ D_puts("(act) found");
+ act_fixed:
+ D_printf("act=%ld\n", act);
+ goto handle_act;
+
+ notfound:
+ D_puts("(act) not found: use default");
+ act_value = AREF(v->action_default, v->curstate);
+ act = NUM2LONG(act_value);
+ goto act_fixed;
+
+
+ handle_act:
+ if (act > 0 && act < v->shift_n) {
+ D_puts("shift");
+ if (v->errstatus > 0) {
+ v->errstatus--;
+ rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
+ }
+ SHIFT(v, act, v->t, val);
+ read_next = 1;
+ }
+ else if (act < 0 && act > -(v->reduce_n)) {
+ D_puts("reduce");
+ REDUCE(v, act);
+ }
+ else if (act == -(v->reduce_n)) {
+ goto error;
+ error_recovered:
+ ; /* goto label requires stmt */
+ }
+ else if (act == v->shift_n) {
+ D_puts("accept");
+ goto accept;
+ }
+ else {
+ rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
+ }
+
+ if (v->debug) {
+ rb_funcall(v->parser, id_d_next_state,
+ 2, LONG2NUM(v->curstate), v->state);
+ }
+ }
+ /* not reach */
+
+
+ accept:
+ if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
+ v->retval = RARRAY(v->vstack)->ptr[0];
+ v->fin = CP_FIN_ACCEPT;
+ return;
+
+
+ error:
+ D_printf("error detected, status=%ld\n", v->errstatus);
+ if (v->errstatus == 0) {
+ v->nerr++;
+ rb_funcall(v->parser, id_onerror,
+ 3, v->t, val, v->vstack);
+ }
+ user_yyerror:
+ if (v->errstatus == 3) {
+ if (v->t == vFINAL_TOKEN) {
+ v->retval = Qfalse;
+ v->fin = CP_FIN_EOT;
+ return;
+ }
+ read_next = 1;
+ }
+ v->errstatus = 3;
+ rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
+
+ /* check if we can shift/reduce error token */
+ D_printf("(err) k1=%ld\n", v->curstate);
+ D_printf("(err) k2=%d (error)\n", ERROR_TOKEN);
+ while (1) {
+ tmp = AREF(v->action_pointer, v->curstate);
+ if (NIL_P(tmp)) goto error_pop;
+ D_puts("(err) pointer[k1] ok");
+
+ i = NUM2LONG(tmp) + ERROR_TOKEN;
+ D_printf("(err) i=%ld\n", i);
+ if (i < 0) goto error_pop;
+
+ act_value = AREF(v->action_table, i);
+ if (NIL_P(act_value)) {
+ D_puts("(err) table[i] == nil");
+ goto error_pop;
+ }
+ act = NUM2LONG(act_value);
+ D_printf("(err) table[i]=%ld\n", act);
+
+ tmp = AREF(v->action_check, i);
+ if (NIL_P(tmp)) {
+ D_puts("(err) check[i] == nil");
+ goto error_pop;
+ }
+ if (NUM2LONG(tmp) != v->curstate) {
+ D_puts("(err) check[i] != k1");
+ goto error_pop;
+ }
+
+ D_puts("(err) found: can handle error token");
+ break;
+
+ error_pop:
+ D_puts("(err) act not found: can't handle error token; pop");
+
+ if (RARRAY(v->state)->len <= 1) {
+ v->retval = Qnil;
+ v->fin = CP_FIN_CANTPOP;
+ return;
+ }
+ POP(v->state);
+ POP(v->vstack);
+ v->curstate = num_to_long(LAST_I(v->state));
+ if (v->debug) {
+ POP(v->tstack);
+ rb_funcall(v->parser, id_d_e_pop,
+ 3, v->state, v->tstack, v->vstack);
+ }
+ }
+
+ /* shift/reduce error token */
+ if (act > 0 && act < v->shift_n) {
+ D_puts("e shift");
+ SHIFT(v, act, ERROR_TOKEN, val);
+ }
+ else if (act < 0 && act > -(v->reduce_n)) {
+ D_puts("e reduce");
+ REDUCE(v, act);
+ }
+ else if (act == v->shift_n) {
+ D_puts("e accept");
+ goto accept;
+ }
+ else {
+ rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
+ }
+ goto error_recovered;
+}
+
+static void
+shift(v, act, tok, val)
+ struct cparse_params *v;
+ long act;
+ VALUE tok, val;
+{
+ PUSH(v->vstack, val);
+ if (v->debug) {
+ PUSH(v->tstack, tok);
+ rb_funcall(v->parser, id_d_shift,
+ 3, tok, v->tstack, v->vstack);
+ }
+ v->curstate = act;
+ PUSH(v->state, LONG2NUM(v->curstate));
+}
+
+static int
+reduce(v, act)
+ struct cparse_params *v;
+ long act;
+{
+ VALUE code;
+ v->ruleno = -act * 3;
+ code = rb_iterate(catch_iter, Qnil, reduce0, v->value_v);
+ v->errstatus = num_to_long(rb_ivar_get(v->parser, id_errstatus));
+ return NUM2INT(code);
+}
+
+static VALUE
+catch_iter(dummy)
+ VALUE dummy;
+{
+ return rb_funcall(rb_mKernel, id_catch, 1, sym_raccjump);
+}
+
+static VALUE
+reduce0(val, data, self)
+ VALUE val, data, self;
+{
+ struct cparse_params *v;
+ VALUE reduce_to, reduce_len, method_id;
+ long len;
+ ID mid;
+ VALUE tmp, tmp_t, tmp_v;
+ long i, k1, k2;
+ VALUE goto_state;
+
+ Data_Get_Struct(data, struct cparse_params, v);
+ reduce_len = RARRAY(v->reduce_table)->ptr[v->ruleno];
+ reduce_to = RARRAY(v->reduce_table)->ptr[v->ruleno+1];
+ method_id = RARRAY(v->reduce_table)->ptr[v->ruleno+2];
+ len = NUM2LONG(reduce_len);
+ mid = value_to_id(method_id);
+
+ /* call action */
+ if (len == 0) {
+ tmp = Qnil;
+ if (mid != id_noreduce)
+ tmp_v = rb_ary_new();
+ if (v->debug)
+ tmp_t = rb_ary_new();
+ }
+ else {
+ if (mid != id_noreduce) {
+ tmp_v = GET_TAIL(v->vstack, len);
+ tmp = RARRAY(tmp_v)->ptr[0];
+ }
+ else {
+ tmp = RARRAY(v->vstack)->ptr[ RARRAY(v->vstack)->len - len ];
+ }
+ CUT_TAIL(v->vstack, len);
+ if (v->debug) {
+ tmp_t = GET_TAIL(v->tstack, len);
+ CUT_TAIL(v->tstack, len);
+ }
+ CUT_TAIL(v->state, len);
+ }
+ if (mid != id_noreduce) {
+ if (v->use_result_var) {
+ tmp = rb_funcall(v->parser, mid,
+ 3, tmp_v, v->vstack, tmp);
+ }
+ else {
+ tmp = rb_funcall(v->parser, mid,
+ 2, tmp_v, v->vstack);
+ }
+ }
+
+ /* then push result */
+ PUSH(v->vstack, tmp);
+ if (v->debug) {
+ PUSH(v->tstack, reduce_to);
+ rb_funcall(v->parser, id_d_reduce,
+ 4, tmp_t, reduce_to, v->tstack, v->vstack);
+ }
+
+ /* calculate transition state */
+ if (RARRAY(v->state)->len == 0)
+ rb_raise(RaccBug, "state stack unexpectedly empty");
+ k2 = num_to_long(LAST_I(v->state));
+ k1 = num_to_long(reduce_to) - v->nt_base;
+ D_printf("(goto) k1=%ld\n", k1);
+ D_printf("(goto) k2=%ld\n", k2);
+
+ tmp = AREF(v->goto_pointer, k1);
+ if (NIL_P(tmp)) goto notfound;
+
+ i = NUM2LONG(tmp) + k2;
+ D_printf("(goto) i=%ld\n", i);
+ if (i < 0) goto notfound;
+
+ goto_state = AREF(v->goto_table, i);
+ if (NIL_P(goto_state)) {
+ D_puts("(goto) table[i] == nil");
+ goto notfound;
+ }
+ D_printf("(goto) table[i]=%ld (goto_state)\n", NUM2LONG(goto_state));
+
+ tmp = AREF(v->goto_check, i);
+ if (NIL_P(tmp)) {
+ D_puts("(goto) check[i] == nil");
+ goto notfound;
+ }
+ if (tmp != LONG2NUM(k1)) {
+ D_puts("(goto) check[i] != table[i]");
+ goto notfound;
+ }
+ D_printf("(goto) check[i]=%ld\n", NUM2LONG(tmp));
+
+ D_puts("(goto) found");
+ transit:
+ PUSH(v->state, goto_state);
+ v->curstate = NUM2LONG(goto_state);
+ return INT2FIX(0);
+
+ notfound:
+ D_puts("(goto) not found: use default");
+ /* overwrite `goto-state' by default value */
+ goto_state = AREF(v->goto_default, k1);
+ goto transit;
+}
+
+
+/* -----------------------------------------------------------------------
+ Ruby Interface
+----------------------------------------------------------------------- */
+
+void
+Init_cparse()
+{
+ VALUE Racc, Parser;
+ ID id_racc = rb_intern("Racc");
+
+ if (rb_const_defined(rb_cObject, id_racc)) {
+ Racc = rb_const_get(rb_cObject, id_racc);
+ Parser = rb_const_get_at(Racc, rb_intern("Parser"));
+ }
+ else {
+ Racc = rb_define_module("Racc");
+ Parser = rb_define_class_under(Racc, "Parser", rb_cObject);
+ }
+ rb_define_private_method(Parser, "_racc_do_parse_c", racc_cparse, 2);
+ rb_define_private_method(Parser, "_racc_yyparse_c", racc_yyparse, 4);
+ rb_define_const(Parser, "Racc_Runtime_Core_Version_C",
+ rb_str_new2(RACC_VERSION));
+ rb_define_const(Parser, "Racc_Runtime_Core_Id_C",
+ rb_str_new2("$raccId: cparse.c,v 1.3 2003/11/03 12:20:54 aamine Exp $"));
+
+ CparseParams = rb_define_class_under(Racc, "CparseParams", rb_cObject);
+
+ RaccBug = rb_eRuntimeError;
+
+ id_yydebug = rb_intern("@yydebug");
+ id_nexttoken = rb_intern("next_token");
+ id_onerror = rb_intern("on_error");
+ id_noreduce = rb_intern("_reduce_none");
+ id_catch = rb_intern("catch");
+ id_errstatus = rb_intern("@racc_error_status");
+ sym_raccjump = id_to_value(rb_intern("racc_jump"));
+
+ id_d_shift = rb_intern("racc_shift");
+ id_d_reduce = rb_intern("racc_reduce");
+ id_d_accept = rb_intern("racc_accept");
+ id_d_read_token = rb_intern("racc_read_token");
+ id_d_next_state = rb_intern("racc_next_state");
+ id_d_e_pop = rb_intern("racc_e_pop");
+}
diff --git a/ext/racc/cparse/depend b/ext/racc/cparse/depend
new file mode 100644
index 0000000000..7b06a880f5
--- /dev/null
+++ b/ext/racc/cparse/depend
@@ -0,0 +1 @@
+cparse.o: cparse.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h
diff --git a/ext/racc/cparse/extconf.rb b/ext/racc/cparse/extconf.rb
new file mode 100644
index 0000000000..dd953a7e15
--- /dev/null
+++ b/ext/racc/cparse/extconf.rb
@@ -0,0 +1,4 @@
+# $Id$
+
+require 'mkmf'
+create_makefile 'racc/cparse'
diff --git a/ext/readline/.cvsignore b/ext/readline/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/readline/.cvsignore
+++ b/ext/readline/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/readline/MANIFEST b/ext/readline/MANIFEST
deleted file mode 100644
index f8bfd1ea2c..0000000000
--- a/ext/readline/MANIFEST
+++ /dev/null
@@ -1,5 +0,0 @@
-MANIFEST
-README
-depend
-extconf.rb
-readline.c
diff --git a/ext/readline/README b/ext/readline/README
index 8a5fe9120f..9bbf325c99 100644
--- a/ext/readline/README
+++ b/ext/readline/README
@@ -1,55 +1,62 @@
-GNU Readline Library¤òÍøÍѤ¹¤ë¤¿¤á¤Î³ÈÄ¥¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£
+Extension for GNU Readline Library
-require "readline"
-include Readline
+Example:
-line = readline("Prompt> ", TRUE)
+ require "readline"
+ include Readline
-¤Î¤è¤¦¤Ë»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£
+ line = readline("Prompt> ", true)
[Readline]
-<¥â¥¸¥å¡¼¥ë´Ø¿ô>
+<module function>
-readline(prompt, add=nil)
+readline(prompt, add_history=nil)
- °ì¹ÔÆþÎϤòÆÉ¤ß¹þ¤ß¤Þ¤¹¡£
- add¤¬TRUE¤Î¾ì¹ç¡¢¥Ò¥¹¥È¥ê¤ËÆÉ¤ß¹þ¤ó¤Àʸ»úÎó¤òÄɲä·¤Þ¤¹¡£
+ Reads one line with line editing. The inputted line is added to the
+ history if add_history is true.
-<¥¯¥é¥¹¥á¥½¥Ã¥É>
+<class methods>
completion_proc = proc
- Êä´°»þ¤Îưºî¤ò·èÄꤹ¤ëProc¥ª¥Ö¥¸¥§¥¯¥È¤ò»ØÄꤷ¤Þ¤¹¡£
- proc¤Ï°ú¿ô¤ËÆþÎÏʸ»úÎó¤ò¼è¤ê¡¢¸õÊäʸ»úÎó¤ÎÇÛÎó¤òÊÖ¤¹¤è¤¦¤Ë
- ¤·¤Æ¤¯¤À¤µ¤¤¡£
+ Specifies a Proc object to determine completion behavior. It
+ should take input-string, and return an array of completion
+ candidates.
completion_proc
- Êä´°»þ¤Îưºî¤ò·èÄꤹ¤ëProc¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹¡£
+ Returns the completion Proc object.
-completion_case_fold = case_fold
+completion_case_fold = bool
- Êä´°»þ¤ËÂçʸ»ú¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤¾ì¹ç¡¢TRUE¤ò»ØÄꤷ¤Þ¤¹¡£
+ Sets whether or not to ignore case on completion.
completion_case_fold
- Êä´°»þ¤ËÂçʸ»ú¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤¾ì¹ç¡¢TRUE¤òÊÖ¤·¤Þ¤¹¡£
+ Returns true if completion ignores case.
+
+completion_append_character = char
+
+ Specifies a character to be appended on completion.
+ Nothing will be appended if an empty string ("") or nil is
+ specified.
+
+completion_append_character
+
+ Returns a string containing a character to be appended on
+ completion. The default is a space (" ").
vi_editing_mode
- VI¥â¡¼¥É¤Ë¤Ê¤ê¤Þ¤¹¡£
+ Specifies VI editing mode.
emacs_editing_mode
- Emacs¥â¡¼¥É¤Ë¤Ê¤ê¤Þ¤¹¡£
+ Specifies Emacs editing mode.
-<¥¯¥é¥¹Äê¿ô>
+<class constants>
HISTORY
-¥Ò¥¹¥È¥ê¤ËÂФ¹¤ëÁàºî¤Ï¤³¤ÎÄê¿ô¤òÄ̤·¤Æ¹Ô¤Ã¤Æ¤¯¤À¤µ¤¤¡£
-ÇÛÎó¤ÈƱ¤¸¤è¤¦¤Ë°·¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
-
-
- \ No newline at end of file
+The history buffer. It behaves just like an array.
diff --git a/ext/readline/README.ja b/ext/readline/README.ja
new file mode 100644
index 0000000000..beb951fbf0
--- /dev/null
+++ b/ext/readline/README.ja
@@ -0,0 +1,63 @@
+GNU Readline Library¤òÍøÍѤ¹¤ë¤¿¤á¤Î³ÈÄ¥¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£
+
+require "readline"
+include Readline
+
+line = readline("Prompt> ", true)
+
+¤Î¤è¤¦¤Ë»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£
+
+[Readline]
+
+<¥â¥¸¥å¡¼¥ë´Ø¿ô>
+
+readline(prompt, add_history=nil)
+
+ °ì¹ÔÆþÎϤòÆÉ¤ß¹þ¤ß¤Þ¤¹¡£
+ add_history¤¬true¤Î¾ì¹ç¡¢¥Ò¥¹¥È¥ê¤ËÆÉ¤ß¹þ¤ó¤Àʸ»úÎó¤òÄɲä·¤Þ¤¹¡£
+
+<¥¯¥é¥¹¥á¥½¥Ã¥É>
+
+completion_proc = proc
+
+ Êä´°»þ¤Îưºî¤ò·èÄꤹ¤ëProc¥ª¥Ö¥¸¥§¥¯¥È¤ò»ØÄꤷ¤Þ¤¹¡£
+ proc¤Ï°ú¿ô¤ËÆþÎÏʸ»úÎó¤ò¼è¤ê¡¢¸õÊäʸ»úÎó¤ÎÇÛÎó¤òÊÖ¤¹¤è¤¦¤Ë
+ ¤·¤Æ¤¯¤À¤µ¤¤¡£
+
+completion_proc
+
+ Êä´°»þ¤Îưºî¤ò·èÄꤹ¤ëProc¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤·¤Þ¤¹¡£
+
+completion_case_fold = case_fold
+
+ Êä´°»þ¤ËÂçʸ»ú¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤¾ì¹ç¡¢true¤ò»ØÄꤷ¤Þ¤¹¡£
+
+completion_case_fold
+
+ Êä´°»þ¤ËÂçʸ»ú¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤¾ì¹ç¡¢true¤òÊÖ¤·¤Þ¤¹¡£
+
+completion_append_character = char
+
+ Êä´°»þ¤ËÉղ䵤ì¤ëʸ»ú¤òʸ»úÎó¤Ç»ØÄꤷ¤Þ¤¹¡£ÀèÆ¬¤Î°ìʸ»ú¤¬
+ ÀßÄꤵ¤ì¡¢¶õʸ»úÎó ("") ¤Þ¤¿¤Ï nil ¤ò»ØÄꤹ¤ë¤È²¿¤âÉÕ²Ã
+ ¤µ¤ì¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£
+
+completion_append_character
+
+ Êä´°»þ¤ËÉղ䵤ì¤ëʸ»ú¤òʸ»úÎó¤ÇÊÖ¤·¤Þ¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ï
+ ¶õÇò (" ") ¤Ç¤¹¡£
+
+vi_editing_mode
+
+ VI¥â¡¼¥É¤Ë¤Ê¤ê¤Þ¤¹¡£
+
+emacs_editing_mode
+
+ Emacs¥â¡¼¥É¤Ë¤Ê¤ê¤Þ¤¹¡£
+
+<¥¯¥é¥¹Äê¿ô>
+
+HISTORY
+
+¥Ò¥¹¥È¥ê¤ËÂФ¹¤ëÁàºî¤Ï¤³¤ÎÄê¿ô¤òÄ̤·¤Æ¹Ô¤Ã¤Æ¤¯¤À¤µ¤¤¡£
+ÇÛÎó¤ÈƱ¤¸¤è¤¦¤Ë°·¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index 431ed213bb..d8d8643d08 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -1,5 +1,8 @@
require "mkmf"
+dir_config('curses')
+dir_config('ncurses')
+dir_config('termcap')
dir_config("readline")
have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM
have_library("ncurses", "tgetnum") or
@@ -10,7 +13,18 @@ if have_header("readline/readline.h") and
have_header("readline/history.h") and
have_library("readline", "readline")
if have_func("rl_filename_completion_function")
- $CFLAGS += "-DREADLINE_42_OR_LATER"
+ $CFLAGS += " -DREADLINE_42_OR_LATER"
+ end
+ if have_func("rl_cleanup_after_signal")
+ $CFLAGS += " -DREADLINE_40_OR_LATER"
+ end
+ if try_link(<<EOF, $libs)
+#include <stdio.h>
+#include <readline/readline.h>
+main() {rl_completion_append_character = 1;}
+EOF
+ # this feature is implemented in readline-2.1 or later.
+ $CFLAGS += " -DREADLINE_21_OR_LATER"
end
create_makefile("readline")
end
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index b96f818194..78a8b17fe5 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -1,6 +1,7 @@
/* readline.c -- GNU Readline module
- Copyright (C) 1997-1998 Shugo Maeda */
+ Copyright (C) 1997-2001 Shugo Maeda */
+#include <errno.h>
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
@@ -8,6 +9,10 @@
#include "ruby.h"
#include "rubysig.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
static VALUE mReadline;
#define TOLOWER(c) (isupper(c) ? tolower(c) : c)
@@ -18,6 +23,7 @@ static VALUE mReadline;
#ifndef READLINE_42_OR_LATER
# define rl_filename_completion_function filename_completion_function
# define rl_username_completion_function username_completion_function
+# define rl_completion_matches completion_matches
#endif
static int
@@ -25,6 +31,7 @@ readline_event()
{
CHECK_INTS;
rb_thread_schedule();
+ return 0;
}
static VALUE
@@ -36,16 +43,34 @@ readline_readline(argc, argv, self)
VALUE tmp, add_hist, result;
char *prompt = NULL;
char *buff;
+ int status;
if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
- prompt = STR2CSTR(tmp);
+ prompt = StringValuePtr(tmp);
+ }
+
+ if (!isatty(0) && errno == EBADF) rb_raise(rb_eIOError, "stdin closed");
+
+ buff = (char*)rb_protect((VALUE(*)_((VALUE)))readline, (VALUE)prompt,
+ &status);
+ if (status) {
+#if defined READLINE_40_OR_LATER
+ /* restore terminal mode and signal handler*/
+ rl_cleanup_after_signal();
+#elif defined READLINE_21_OR_LATER
+ /* restore terminal mode */
+ (*rl_deprep_term_function)();
+#else
+ rl_deprep_terminal();
+#endif
+ rb_jump_tag(status);
}
- buff = readline(prompt);
+
if (RTEST(add_hist) && buff) {
add_history(buff);
}
if (buff)
- result = rb_str_new2(buff);
+ result = rb_tainted_str_new2(buff);
else
result = Qnil;
if (buff) free(buff);
@@ -58,7 +83,7 @@ readline_s_set_completion_proc(self, proc)
VALUE proc;
{
if (!rb_respond_to(proc, rb_intern("call")))
- rb_raise(rb_eArgError, "argument have to respond to `call'");
+ rb_raise(rb_eArgError, "argument must respond to `call'");
return rb_iv_set(mReadline, COMPLETION_PROC, proc);
}
@@ -100,7 +125,7 @@ readline_attempted_completion_function(text, start, end)
return NULL;
rl_attempted_completion_over = 1;
case_fold = RTEST(rb_iv_get(mReadline, COMPLETION_CASE_FOLD));
- ary = rb_funcall(proc, rb_intern("call"), 1, rb_str_new2(text));
+ ary = rb_funcall(proc, rb_intern("call"), 1, rb_tainted_str_new2(text));
if (TYPE(ary) != T_ARRAY)
ary = rb_Array(ary);
matches = RARRAY(ary)->len;
@@ -166,6 +191,254 @@ readline_s_emacs_editing_mode(self)
}
static VALUE
+readline_s_set_completion_append_character(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ if (NIL_P(str) || !StringValuePtr(str) || !RSTRING(str)->len) {
+ rl_completion_append_character = '\0';
+ } else {
+ rl_completion_append_character = RSTRING(str)->ptr[0];
+ }
+
+ return self;
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_get_completion_append_character(self)
+ VALUE self;
+{
+#ifdef READLINE_21_OR_LATER
+ VALUE str;
+
+ if (rl_completion_append_character == '\0')
+ return Qnil;
+
+ str = rb_str_new("", 1);
+ RSTRING(str)->ptr[0] = rl_completion_append_character;
+
+ return str;
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_set_basic_word_break_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ static char *basic_word_break_characters = NULL;
+
+ StringValue(str);
+ if (basic_word_break_characters == NULL) {
+ basic_word_break_characters =
+ ALLOC_N(char, RSTRING(str)->len + 1);
+ }
+ else {
+ REALLOC_N(basic_word_break_characters, char, RSTRING(str)->len + 1);
+ }
+ strncpy(basic_word_break_characters,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ basic_word_break_characters[RSTRING(str)->len] = '\0';
+ rl_basic_word_break_characters = basic_word_break_characters;
+
+ return self;
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_get_basic_word_break_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ if (rl_basic_word_break_characters == NULL)
+ return Qnil;
+ return rb_str_new2(rl_basic_word_break_characters);
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_set_completer_word_break_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ static char *completer_word_break_characters = NULL;
+
+ StringValue(str);
+ if (completer_word_break_characters == NULL) {
+ completer_word_break_characters =
+ ALLOC_N(char, RSTRING(str)->len + 1);
+ }
+ else {
+ REALLOC_N(completer_word_break_characters, char, RSTRING(str)->len + 1);
+ }
+ strncpy(completer_word_break_characters,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ completer_word_break_characters[RSTRING(str)->len] = '\0';
+ rl_completer_word_break_characters = completer_word_break_characters;
+
+ return self;
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_get_completer_word_break_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ if (rl_completer_word_break_characters == NULL)
+ return Qnil;
+ return rb_str_new2(rl_completer_word_break_characters);
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_set_basic_quote_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ static char *basic_quote_characters = NULL;
+
+ StringValue(str);
+ if (basic_quote_characters == NULL) {
+ basic_quote_characters =
+ ALLOC_N(char, RSTRING(str)->len + 1);
+ }
+ else {
+ REALLOC_N(basic_quote_characters, char, RSTRING(str)->len + 1);
+ }
+ strncpy(basic_quote_characters,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ basic_quote_characters[RSTRING(str)->len] = '\0';
+ rl_basic_quote_characters = basic_quote_characters;
+
+ return self;
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_get_basic_quote_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ if (rl_basic_quote_characters == NULL)
+ return Qnil;
+ return rb_str_new2(rl_basic_quote_characters);
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_set_completer_quote_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ static char *completer_quote_characters = NULL;
+
+ StringValue(str);
+ if (completer_quote_characters == NULL) {
+ completer_quote_characters =
+ ALLOC_N(char, RSTRING(str)->len + 1);
+ }
+ else {
+ REALLOC_N(completer_quote_characters, char, RSTRING(str)->len + 1);
+ }
+ strncpy(completer_quote_characters,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ completer_quote_characters[RSTRING(str)->len] = '\0';
+ rl_completer_quote_characters = completer_quote_characters;
+
+ return self;
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_get_completer_quote_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ if (rl_completer_quote_characters == NULL)
+ return Qnil;
+ return rb_str_new2(rl_completer_quote_characters);
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_set_filename_quote_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ static char *filename_quote_characters = NULL;
+
+ StringValue(str);
+ if (filename_quote_characters == NULL) {
+ filename_quote_characters =
+ ALLOC_N(char, RSTRING(str)->len + 1);
+ }
+ else {
+ REALLOC_N(filename_quote_characters, char, RSTRING(str)->len + 1);
+ }
+ strncpy(filename_quote_characters,
+ RSTRING(str)->ptr, RSTRING(str)->len);
+ filename_quote_characters[RSTRING(str)->len] = '\0';
+ rl_filename_quote_characters = filename_quote_characters;
+
+ return self;
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+readline_s_get_filename_quote_characters(self, str)
+ VALUE self, str;
+{
+#ifdef READLINE_21_OR_LATER
+ if (rl_filename_quote_characters == NULL)
+ return Qnil;
+ return rb_str_new2(rl_filename_quote_characters);
+#else
+ rb_notimplement();
+#endif /* READLINE_21_OR_LATER */
+}
+
+static VALUE
+rb_remove_history(index)
+ int index;
+{
+ HIST_ENTRY *entry;
+ VALUE val;
+
+ entry = remove_history(index);
+ if (entry) {
+ val = rb_tainted_str_new2(entry->line);
+ free(entry->line);
+ free(entry);
+ return val;
+ }
+ return Qnil;
+}
+
+static VALUE
hist_to_s(self)
VALUE self;
{
@@ -182,10 +455,13 @@ hist_get(self, index)
state = history_get_history_state();
i = NUM2INT(index);
+ if (i < 0) {
+ i += state->length;
+ }
if (i < 0 || i > state->length - 1) {
rb_raise(rb_eIndexError, "Invalid index");
}
- return rb_str_new2(state->entries[i]->line);
+ return rb_tainted_str_new2(state->entries[i]->line);
}
static VALUE
@@ -195,14 +471,18 @@ hist_set(self, index, str)
VALUE str;
{
HISTORY_STATE *state;
+ VALUE s = str;
int i;
state = history_get_history_state();
i = NUM2INT(index);
+ if (i < 0) {
+ i += state->length;
+ }
if (i < 0 || i > state->length - 1) {
rb_raise(rb_eIndexError, "Invalid index");
}
- replace_history_entry(i, STR2CSTR(str), NULL);
+ replace_history_entry(i, StringValuePtr(s), NULL);
return str;
}
@@ -211,7 +491,7 @@ hist_push(self, str)
VALUE self;
VALUE str;
{
- add_history(STR2CSTR(str));
+ add_history(StringValuePtr(str));
return self;
}
@@ -225,7 +505,7 @@ hist_push_method(argc, argv, self)
while (argc--) {
str = *argv++;
- add_history(STR2CSTR(str));
+ add_history(StringValuePtr(str));
}
return self;
}
@@ -235,12 +515,10 @@ hist_pop(self)
VALUE self;
{
HISTORY_STATE *state;
- HIST_ENTRY *entry;
state = history_get_history_state();
if (state->length > 0) {
- entry = remove_history(state->length - 1);
- return rb_str_new2(entry->line);
+ return rb_remove_history(state->length - 1);
} else {
return Qnil;
}
@@ -251,12 +529,10 @@ hist_shift(self)
VALUE self;
{
HISTORY_STATE *state;
- HIST_ENTRY *entry;
state = history_get_history_state();
if (state->length > 0) {
- entry = remove_history(0);
- return rb_str_new2(entry->line);
+ return rb_remove_history(0);
} else {
return Qnil;
}
@@ -271,7 +547,7 @@ hist_each(self)
state = history_get_history_state();
for (i = 0; i < state->length; i++) {
- rb_yield(rb_str_new2(state->entries[i]->line));
+ rb_yield(rb_tainted_str_new2(state->entries[i]->line));
}
return self;
}
@@ -305,16 +581,16 @@ hist_delete_at(self, index)
VALUE index;
{
HISTORY_STATE *state;
- HIST_ENTRY *entry;
int i;
state = history_get_history_state();
i = NUM2INT(index);
+ if (i < 0)
+ i += state->length;
if (i < 0 || i > state->length - 1) {
rb_raise(rb_eIndexError, "Invalid index");
}
- entry = remove_history(NUM2INT(index));
- return rb_str_new2(entry->line);
+ return rb_remove_history(i);
}
static VALUE
@@ -326,12 +602,12 @@ filename_completion_proc_call(self, str)
char **matches;
int i;
- matches = completion_matches(STR2CSTR(str),
- rl_filename_completion_function);
+ matches = rl_completion_matches(StringValuePtr(str),
+ rl_filename_completion_function);
if (matches) {
result = rb_ary_new();
for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_str_new2(matches[i]));
+ rb_ary_push(result, rb_tainted_str_new2(matches[i]));
free(matches[i]);
}
free(matches);
@@ -353,12 +629,12 @@ username_completion_proc_call(self, str)
char **matches;
int i;
- matches = completion_matches(STR2CSTR(str),
- rl_username_completion_function);
+ matches = rl_completion_matches(StringValuePtr(str),
+ rl_username_completion_function);
if (matches) {
result = rb_ary_new();
for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_str_new2(matches[i]));
+ rb_ary_push(result, rb_tainted_str_new2(matches[i]));
free(matches[i]);
}
free(matches);
@@ -374,7 +650,10 @@ username_completion_proc_call(self, str)
void
Init_readline()
{
- VALUE histary, fcomp, ucomp;
+ VALUE history, fcomp, ucomp;
+
+ /* Allow conditional parsing of the ~/.inputrc file. */
+ rl_readline_name = "Ruby";
using_history();
@@ -393,21 +672,47 @@ Init_readline()
readline_s_vi_editing_mode, 0);
rb_define_singleton_method(mReadline, "emacs_editing_mode",
readline_s_emacs_editing_mode, 0);
-
- histary = rb_obj_alloc(rb_cObject);
- rb_extend_object(histary, rb_mEnumerable);
- rb_define_singleton_method(histary,"to_s", hist_to_s, 0);
- rb_define_singleton_method(histary,"[]", hist_get, 1);
- rb_define_singleton_method(histary,"[]=", hist_set, 2);
- rb_define_singleton_method(histary,"<<", hist_push, 1);
- rb_define_singleton_method(histary,"push", hist_push_method, -1);
- rb_define_singleton_method(histary,"pop", hist_pop, 0);
- rb_define_singleton_method(histary,"shift", hist_shift, 0);
- rb_define_singleton_method(histary,"each", hist_each, 0);
- rb_define_singleton_method(histary,"length", hist_length, 0);
- rb_define_singleton_method(histary,"empty?", hist_empty_p, 0);
- rb_define_singleton_method(histary,"delete_at", hist_delete_at, 1);
- rb_define_const(mReadline, "HISTORY", histary);
+ rb_define_singleton_method(mReadline, "completion_append_character=",
+ readline_s_set_completion_append_character, 1);
+ rb_define_singleton_method(mReadline, "completion_append_character",
+ readline_s_get_completion_append_character, 0);
+ rb_define_singleton_method(mReadline, "basic_word_break_characters=",
+ readline_s_set_basic_word_break_characters, 1);
+ rb_define_singleton_method(mReadline, "basic_word_break_characters",
+ readline_s_get_basic_word_break_characters, 0);
+ rb_define_singleton_method(mReadline, "completer_word_break_characters=",
+ readline_s_set_completer_word_break_characters, 1);
+ rb_define_singleton_method(mReadline, "completer_word_break_characters",
+ readline_s_get_completer_word_break_characters, 0);
+ rb_define_singleton_method(mReadline, "basic_quote_characters=",
+ readline_s_set_basic_quote_characters, 1);
+ rb_define_singleton_method(mReadline, "basic_quote_characters",
+ readline_s_get_basic_quote_characters, 0);
+ rb_define_singleton_method(mReadline, "completer_quote_characters=",
+ readline_s_set_completer_quote_characters, 1);
+ rb_define_singleton_method(mReadline, "completer_quote_characters",
+ readline_s_get_completer_quote_characters, 0);
+ rb_define_singleton_method(mReadline, "filename_quote_characters=",
+ readline_s_set_filename_quote_characters, 1);
+ rb_define_singleton_method(mReadline, "filename_quote_characters",
+ readline_s_get_filename_quote_characters, 0);
+
+ history = rb_obj_alloc(rb_cObject);
+ rb_extend_object(history, rb_mEnumerable);
+ rb_define_singleton_method(history,"to_s", hist_to_s, 0);
+ rb_define_singleton_method(history,"[]", hist_get, 1);
+ rb_define_singleton_method(history,"[]=", hist_set, 2);
+ rb_define_singleton_method(history,"<<", hist_push, 1);
+ rb_define_singleton_method(history,"push", hist_push_method, -1);
+ rb_define_singleton_method(history,"pop", hist_pop, 0);
+ rb_define_singleton_method(history,"shift", hist_shift, 0);
+ rb_define_singleton_method(history,"each", hist_each, 0);
+ rb_define_singleton_method(history,"length", hist_length, 0);
+ rb_define_singleton_method(history,"size", hist_length, 0);
+
+ rb_define_singleton_method(history,"empty?", hist_empty_p, 0);
+ rb_define_singleton_method(history,"delete_at", hist_delete_at, 1);
+ rb_define_const(mReadline, "HISTORY", history);
fcomp = rb_obj_alloc(rb_cObject);
rb_define_singleton_method(fcomp, "call",
@@ -418,9 +723,21 @@ Init_readline()
rb_define_singleton_method(ucomp, "call",
username_completion_proc_call, 1);
rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp);
+#if defined READLINE_21_OR_LATER
+ rb_define_const(mReadline, "VERSION", rb_str_new2(rl_library_version));
+#else
+ rb_define_const(mReadline, "VERSION",
+ rb_str_new2("2.0 or before version"));
+#endif
+#if defined READLINE_42_OR_LATER
+ rl_attempted_completion_function
+ = (rl_completion_func_t *)readline_attempted_completion_function;
+ rl_event_hook = (rl_hook_func_t *)readline_event;
+#else
rl_attempted_completion_function
= (CPPFunction *) readline_attempted_completion_function;
rl_event_hook = readline_event;
+#endif
rl_clear_signals();
}
diff --git a/ext/sdbm/.cvsignore b/ext/sdbm/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/sdbm/.cvsignore
+++ b/ext/sdbm/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/sdbm/MANIFEST b/ext/sdbm/MANIFEST
deleted file mode 100644
index 8888e69ad4..0000000000
--- a/ext/sdbm/MANIFEST
+++ /dev/null
@@ -1,6 +0,0 @@
-MANIFEST
-_sdbm.c
-depend
-extconf.rb
-init.c
-sdbm.h
diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c
index 92c96f26d0..d8bfae80b2 100644
--- a/ext/sdbm/_sdbm.c
+++ b/ext/sdbm/_sdbm.c
@@ -103,7 +103,7 @@ static int duppair proto((char *, datum));
/*
* externals
*/
-#if !defined(sun) && !defined(MSDOS) && !defined(_WIN32)
+#if !defined sun && !defined MSDOS && !defined _WIN32 && !defined __CYGWIN__
extern int errno;
#endif
diff --git a/ext/sdbm/init.c b/ext/sdbm/init.c
index 87136e9bdb..ed39769e7a 100644
--- a/ext/sdbm/init.c
+++ b/ext/sdbm/init.c
@@ -6,7 +6,7 @@
$Date$
created at: Fri May 7 08:34:24 JST 1999
- Copyright (C) 1995-1998 Yukihiro Matsumoto
+ Copyright (C) 1995-2001 Yukihiro Matsumoto
************************************************/
@@ -16,7 +16,7 @@
#include <fcntl.h>
#include <errno.h>
-VALUE cSDBM;
+static VALUE rb_cDBM, rb_eDBMError;
struct dbmdata {
int di_size;
@@ -26,7 +26,7 @@ struct dbmdata {
static void
closed_sdbm()
{
- rb_raise(rb_eRuntimeError, "closed SDBM file");
+ rb_raise(rb_eDBMError, "closed SDBM file");
}
#define GetDBM(obj, dbmp) {\
@@ -44,16 +44,36 @@ free_sdbm(dbmp)
}
static VALUE
-fsdbm_s_open(argc, argv, klass)
+fsdbm_close(obj)
+ VALUE obj;
+{
+ struct dbmdata *dbmp;
+
+ GetDBM(obj, dbmp);
+ sdbm_close(dbmp->di_dbm);
+ dbmp->di_dbm = 0;
+
+ return Qnil;
+}
+
+static VALUE fsdbm_alloc _((VALUE));
+static VALUE
+fsdbm_alloc(klass)
+ VALUE klass;
+{
+ return Data_Wrap_Struct(klass, 0, free_sdbm, 0);
+}
+
+static VALUE
+fsdbm_initialize(argc, argv, obj)
int argc;
VALUE *argv;
- VALUE klass;
+ VALUE obj;
{
VALUE file, vmode;
DBM *dbm;
struct dbmdata *dbmp;
int mode;
- VALUE obj;
if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
mode = 0666; /* default value */
@@ -64,7 +84,7 @@ fsdbm_s_open(argc, argv, klass)
else {
mode = NUM2INT(vmode);
}
- Check_SafeStr(file);
+ SafeStringValue(file);
dbm = 0;
if (mode >= 0)
@@ -79,7 +99,8 @@ fsdbm_s_open(argc, argv, klass)
rb_sys_fail(RSTRING(file)->ptr);
}
- obj = Data_Make_Struct(klass,struct dbmdata,0,free_sdbm,dbmp);
+ dbmp = ALLOC(struct dbmdata);
+ DATA_PTR(obj) = dbmp;
dbmp->di_dbm = dbm;
dbmp->di_size = -1;
@@ -87,16 +108,22 @@ fsdbm_s_open(argc, argv, klass)
}
static VALUE
-fsdbm_close(obj)
- VALUE obj;
+fsdbm_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
{
- struct dbmdata *dbmp;
+ VALUE obj = Data_Wrap_Struct(klass, 0, free_sdbm, 0);
- GetDBM(obj, dbmp);
- sdbm_close(dbmp->di_dbm);
- dbmp->di_dbm = 0;
+ if (NIL_P(fsdbm_initialize(argc, argv, obj))) {
+ return Qnil;
+ }
- return Qnil;
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, fsdbm_close, obj);
+ }
+
+ return obj;
}
static VALUE
@@ -107,7 +134,7 @@ fsdbm_fetch(obj, keystr, ifnone)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(keystr, T_STRING);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
@@ -135,10 +162,14 @@ fsdbm_fetch_m(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
- VALUE keystr, ifnone;
+ VALUE keystr, valstr, ifnone;
rb_scan_args(argc, argv, "11", &keystr, &ifnone);
- return fsdbm_fetch(obj, keystr, ifnone);
+ valstr = fsdbm_fetch(obj, keystr, ifnone);
+ if (argc == 1 && !rb_block_given_p() && NIL_P(valstr))
+ rb_raise(rb_eIndexError, "key not found");
+
+ return valstr;
}
static VALUE
@@ -149,7 +180,7 @@ fsdbm_index(obj, valstr)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(valstr, T_STRING);
+ StringValue(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
@@ -175,12 +206,76 @@ fsdbm_indexes(argc, argv, obj)
new = rb_ary_new2(argc);
for (i=0; i<argc; i++) {
- rb_ary_push(new, fsdbm_fetch(obj, argv[i]));
+ rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
+ }
+
+ return new;
+}
+
+static VALUE
+fsdbm_select(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ if (rb_block_given_p()) {
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ GetDBM(obj, dbmp);
+ dbm = dbmp->di_dbm;
+
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ VALUE assoc;
+ val = sdbm_fetch(dbm, key);
+ assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
+ if (RTEST(rb_yield(assoc)))
+ rb_ary_push(new, assoc);
+ }
+ }
+ else {
+ rb_warn("SDBM#select(index..) is deprecated; use SDBM#values_at");
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
+ }
+ }
+
+ return new;
+}
+
+static VALUE
+fsdbm_values_at(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
}
return new;
}
+static void
+fdbm_modify(obj)
+ VALUE obj;
+{
+ rb_secure(4);
+ if (OBJ_FROZEN(obj)) rb_error_frozen("SDBM");
+}
+
static VALUE
fsdbm_delete(obj, keystr)
VALUE obj, keystr;
@@ -188,29 +283,34 @@ fsdbm_delete(obj, keystr)
datum key, value;
struct dbmdata *dbmp;
DBM *dbm;
+ VALUE valstr;
- rb_secure(4);
- Check_Type(keystr, T_STRING);
+ fdbm_modify(obj);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
+ dbmp->di_size = -1;
value = sdbm_fetch(dbm, key);
if (value.dptr == 0) {
- if (rb_block_given_p()) rb_yield(keystr);
+ if (rb_block_given_p()) return rb_yield(keystr);
return Qnil;
}
+ /* need to save value before sdbm_delete() */
+ valstr = rb_tainted_str_new(value.dptr, value.dsize);
+
if (sdbm_delete(dbm, key)) {
dbmp->di_size = -1;
- rb_raise(rb_eRuntimeError, "dbm_delete failed");
+ rb_raise(rb_eDBMError, "dbm_delete failed");
}
else if (dbmp->di_size >= 0) {
dbmp->di_size--;
}
- return obj;
+ return valstr;
}
static VALUE
@@ -222,17 +322,20 @@ fsdbm_shift(obj)
DBM *dbm;
VALUE keystr, valstr;
- rb_secure(4);
+ fdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
key = sdbm_firstkey(dbm);
if (!key.dptr) return Qnil;
val = sdbm_fetch(dbm, key);
- sdbm_delete(dbm, key);
-
keystr = rb_tainted_str_new(key.dptr, key.dsize);
valstr = rb_tainted_str_new(val.dptr, val.dsize);
+ sdbm_delete(dbm, key);
+ if (dbmp->di_size >= 0) {
+ dbmp->di_size--;
+ }
+
return rb_assoc_new(keystr, valstr);
}
@@ -244,20 +347,35 @@ fsdbm_delete_if(obj)
struct dbmdata *dbmp;
DBM *dbm;
VALUE keystr, valstr;
+ VALUE ret, ary = rb_ary_new();
+ int i, status = 0, n;
- rb_secure(4);
+ fdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
+ n = dbmp->di_size;
+ dbmp->di_size = -1;
for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
val = sdbm_fetch(dbm, key);
keystr = rb_tainted_str_new(key.dptr, key.dsize);
valstr = rb_tainted_str_new(val.dptr, val.dsize);
- if (RTEST(rb_yield(rb_assoc_new(keystr, valstr)))) {
- if (sdbm_delete(dbm, key)) {
- rb_raise(rb_eRuntimeError, "sdbm_delete failed");
- }
+ ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
+ if (status != 0) break;
+ if (RTEST(ret)) rb_ary_push(ary, keystr);
+ }
+
+ for (i = 0; i < RARRAY(ary)->len; i++) {
+ keystr = RARRAY(ary)->ptr[i];
+ StringValue(keystr);
+ key.dptr = RSTRING(keystr)->ptr;
+ key.dsize = RSTRING(keystr)->len;
+ if (sdbm_delete(dbm, key)) {
+ rb_raise(rb_eDBMError, "sdbm_delete failed");
}
}
+ if (status) rb_jump_tag(status);
+ if (n > 0) dbmp->di_size = n - RARRAY(ary)->len;
+
return obj;
}
@@ -269,15 +387,17 @@ fsdbm_clear(obj)
struct dbmdata *dbmp;
DBM *dbm;
- rb_secure(4);
+ fdbm_modify(obj);
GetDBM(obj, dbmp);
dbm = dbmp->di_dbm;
dbmp->di_size = -1;
- for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ while (key = sdbm_firstkey(dbm), key.dptr) {
if (sdbm_delete(dbm, key)) {
- rb_raise(rb_eRuntimeError, "sdbm_delete failed");
+ rb_raise(rb_eDBMError, "sdbm_delete failed");
}
}
+ dbmp->di_size = 0;
+
return obj;
}
@@ -299,9 +419,11 @@ fsdbm_invert(obj)
valstr = rb_tainted_str_new(val.dptr, val.dsize);
rb_hash_aset(hash, valstr, keystr);
}
- return obj;
+ return hash;
}
+static VALUE each_pair _((VALUE));
+
static VALUE
each_pair(obj)
VALUE obj;
@@ -353,15 +475,13 @@ fsdbm_store(obj, keystr, valstr)
return Qnil;
}
- rb_secure(4);
- keystr = rb_obj_as_string(keystr);
+ fdbm_modify(obj);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
- if (NIL_P(valstr)) return fsdbm_delete(obj, keystr);
-
- valstr = rb_obj_as_string(valstr);
+ StringValue(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
@@ -373,7 +493,7 @@ fsdbm_store(obj, keystr, valstr)
sdbm_clearerr(dbm);
#endif
if (errno == EPERM) rb_sys_fail(0);
- rb_raise(rb_eRuntimeError, "sdbm_store failed");
+ rb_raise(rb_eDBMError, "sdbm_store failed");
}
return valstr;
@@ -528,7 +648,7 @@ fsdbm_has_key(obj, keystr)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(keystr, T_STRING);
+ StringValue(keystr);
key.dptr = RSTRING(keystr)->ptr;
key.dsize = RSTRING(keystr)->len;
@@ -547,7 +667,7 @@ fsdbm_has_value(obj, valstr)
struct dbmdata *dbmp;
DBM *dbm;
- Check_Type(valstr, T_STRING);
+ StringValue(valstr);
val.dptr = RSTRING(valstr)->ptr;
val.dsize = RSTRING(valstr)->len;
@@ -616,45 +736,50 @@ fsdbm_reject(obj)
void
Init_sdbm()
{
- cSDBM = rb_define_class("SDBM", rb_cObject);
- rb_include_module(cSDBM, rb_mEnumerable);
-
- rb_define_singleton_method(cSDBM, "open", fsdbm_s_open, -1);
- rb_define_singleton_method(cSDBM, "new", fsdbm_s_open, -1);
- rb_define_method(cSDBM, "close", fsdbm_close, 0);
- rb_define_method(cSDBM, "[]", fsdbm_aref, 1);
- rb_define_method(cSDBM, "fetch", fsdbm_fetch_m, -1);
- rb_define_method(cSDBM, "[]=", fsdbm_store, 2);
- rb_define_method(cSDBM, "store", fsdbm_store, 2);
- rb_define_method(cSDBM, "index", fsdbm_index, 1);
- rb_define_method(cSDBM, "indexes", fsdbm_indexes, -1);
- rb_define_method(cSDBM, "indices", fsdbm_indexes, -1);
- rb_define_method(cSDBM, "length", fsdbm_length, 0);
- rb_define_alias(cSDBM, "size", "length");
- rb_define_method(cSDBM, "empty?", fsdbm_empty_p, 0);
- rb_define_method(cSDBM, "each", fsdbm_each_pair, 0);
- rb_define_method(cSDBM, "each_value", fsdbm_each_value, 0);
- rb_define_method(cSDBM, "each_key", fsdbm_each_key, 0);
- rb_define_method(cSDBM, "each_pair", fsdbm_each_pair, 0);
- rb_define_method(cSDBM, "keys", fsdbm_keys, 0);
- rb_define_method(cSDBM, "values", fsdbm_values, 0);
- rb_define_method(cSDBM, "shift", fsdbm_shift, 1);
- rb_define_method(cSDBM, "delete", fsdbm_delete, 1);
- rb_define_method(cSDBM, "delete_if", fsdbm_delete_if, 0);
- rb_define_method(cSDBM, "reject!", fsdbm_delete_if, 0);
- rb_define_method(cSDBM, "reject", fsdbm_reject, 0);
- rb_define_method(cSDBM, "clear", fsdbm_clear, 0);
- rb_define_method(cSDBM,"invert", fsdbm_invert, 0);
- rb_define_method(cSDBM,"update", fsdbm_update, 1);
- rb_define_method(cSDBM,"replace", fsdbm_replace, 1);
-
- rb_define_method(cSDBM, "include?", fsdbm_has_key, 1);
- rb_define_method(cSDBM, "has_key?", fsdbm_has_key, 1);
- rb_define_method(cSDBM, "member?", fsdbm_has_key, 1);
- rb_define_method(cSDBM, "has_value?", fsdbm_has_value, 1);
- rb_define_method(cSDBM, "key?", fsdbm_has_key, 1);
- rb_define_method(cSDBM, "value?", fsdbm_has_value, 1);
-
- rb_define_method(cSDBM, "to_a", fsdbm_to_a, 0);
- rb_define_method(cSDBM, "to_hash", fsdbm_to_hash, 0);
+ rb_cDBM = rb_define_class("SDBM", rb_cObject);
+ rb_eDBMError = rb_define_class("SDBMError", rb_eStandardError);
+ rb_include_module(rb_cDBM, rb_mEnumerable);
+
+ rb_define_alloc_func(rb_cDBM, fsdbm_alloc);
+ rb_define_singleton_method(rb_cDBM, "open", fsdbm_s_open, -1);
+
+ rb_define_method(rb_cDBM, "initialize", fsdbm_initialize, -1);
+ rb_define_method(rb_cDBM, "close", fsdbm_close, 0);
+ rb_define_method(rb_cDBM, "[]", fsdbm_aref, 1);
+ rb_define_method(rb_cDBM, "fetch", fsdbm_fetch_m, -1);
+ rb_define_method(rb_cDBM, "[]=", fsdbm_store, 2);
+ rb_define_method(rb_cDBM, "store", fsdbm_store, 2);
+ rb_define_method(rb_cDBM, "index", fsdbm_index, 1);
+ rb_define_method(rb_cDBM, "indexes", fsdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "indices", fsdbm_indexes, -1);
+ rb_define_method(rb_cDBM, "select", fsdbm_select, -1);
+ rb_define_method(rb_cDBM, "values_at", fsdbm_values_at, -1);
+ rb_define_method(rb_cDBM, "length", fsdbm_length, 0);
+ rb_define_method(rb_cDBM, "size", fsdbm_length, 0);
+ rb_define_method(rb_cDBM, "empty?", fsdbm_empty_p, 0);
+ rb_define_method(rb_cDBM, "each", fsdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "each_value", fsdbm_each_value, 0);
+ rb_define_method(rb_cDBM, "each_key", fsdbm_each_key, 0);
+ rb_define_method(rb_cDBM, "each_pair", fsdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "keys", fsdbm_keys, 0);
+ rb_define_method(rb_cDBM, "values", fsdbm_values, 0);
+ rb_define_method(rb_cDBM, "shift", fsdbm_shift, 0);
+ rb_define_method(rb_cDBM, "delete", fsdbm_delete, 1);
+ rb_define_method(rb_cDBM, "delete_if", fsdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject!", fsdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject", fsdbm_reject, 0);
+ rb_define_method(rb_cDBM, "clear", fsdbm_clear, 0);
+ rb_define_method(rb_cDBM,"invert", fsdbm_invert, 0);
+ rb_define_method(rb_cDBM,"update", fsdbm_update, 1);
+ rb_define_method(rb_cDBM,"replace", fsdbm_replace, 1);
+
+ rb_define_method(rb_cDBM, "include?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "has_key?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "member?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "has_value?", fsdbm_has_value, 1);
+ rb_define_method(rb_cDBM, "key?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "value?", fsdbm_has_value, 1);
+
+ rb_define_method(rb_cDBM, "to_a", fsdbm_to_a, 0);
+ rb_define_method(rb_cDBM, "to_hash", fsdbm_to_hash, 0);
}
diff --git a/ext/sdbm/testsdbm.rb b/ext/sdbm/testsdbm.rb
new file mode 100644
index 0000000000..5a185fd5c4
--- /dev/null
+++ b/ext/sdbm/testsdbm.rb
@@ -0,0 +1,556 @@
+require 'runit/testcase'
+require 'runit/cui/testrunner'
+
+if $".grep(/\bsdbm.so\b/).empty?
+ begin
+ require './sdbm'
+ rescue LoadError
+ require 'sdbm'
+ end
+end
+
+def uname_s
+ require 'rbconfig'
+ case Config::CONFIG['host_os']
+ when 'cygwin'
+ require 'Win32API'
+ uname = Win32API.new('cygwin1', 'uname', 'P', 'I')
+ utsname = ' ' * 100
+ raise 'cannot get system name' if uname.call(utsname) == -1
+
+ utsname.unpack('A20' * 5)[0]
+ else
+ Config::CONFIG['host_os']
+ end
+end
+
+SYSTEM = uname_s
+
+class TestSDBM < RUNIT::TestCase
+ def setup
+ @path = "tmptest_sdbm_"
+ assert_instance_of(SDBM, @sdbm = SDBM.new(@path))
+ end
+ def teardown
+ assert_nil(@sdbm.close)
+ GC.start
+ File.delete *Dir.glob("tmptest_sdbm*").to_a
+ p Dir.glob("tmptest_sdbm*") if $DEBUG
+ end
+
+ def check_size(expect, sdbm=@sdbm)
+ assert_equals(expect, sdbm.size)
+ n = 0
+ sdbm.each { n+=1 }
+ assert_equals(expect, n)
+ if expect == 0
+ assert_equals(true, sdbm.empty?)
+ else
+ assert_equals(false, sdbm.empty?)
+ end
+ end
+
+ def test_version
+ assert(! SDBM.const_defined?(:VERSION))
+ end
+
+ def test_s_new_has_no_block
+ # SDBM.new ignore the block
+ foo = true
+ assert_instance_of(SDBM, sdbm = SDBM.new("tmptest_sdbm") { foo = false })
+ assert_equals(foo, true)
+ assert_nil(sdbm.close)
+ end
+ def test_s_open_no_create
+ assert_nil(sdbm = SDBM.open("tmptest_sdbm", nil))
+ ensure
+ sdbm.close if sdbm
+ end
+ def test_s_open_with_block
+ assert_equals(SDBM.open("tmptest_sdbm") { :foo }, :foo)
+ end
+=begin
+ # Is it guaranteed on many OS?
+ def test_s_open_lock_one_process
+ # locking on one process
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644))
+ assert_exception(Errno::EWOULDBLOCK) {
+ begin
+ SDBM.open("tmptest_sdbm", 0644)
+ rescue Errno::EAGAIN
+ raise Errno::EWOULDBLOCK
+ end
+ }
+ end
+=end
+
+ def test_s_open_nolock
+ # sdbm 1.8.0 specific
+ if not defined? SDBM::NOLOCK
+ return
+ end
+
+ fork() {
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644,
+ SDBM::NOLOCK))
+ sleep 2
+ }
+ sleep 1
+ begin
+ sdbm2 = nil
+ assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
+ assert_instance_of(SDBM, sdbm2 = SDBM.open("tmptest_sdbm", 0644))
+ }
+ ensure
+ Process.wait
+ sdbm2.close if sdbm2
+ end
+
+ p Dir.glob("tmptest_sdbm*") if $DEBUG
+
+ fork() {
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0644))
+ sleep 2
+ }
+ begin
+ sleep 1
+ sdbm2 = nil
+ assert_no_exception(Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EACCES) {
+ # this test is failed on Cygwin98 (???)
+ assert_instance_of(SDBM, sdbm2 = SDBM.open("tmptest_sdbm", 0644,
+ SDBM::NOLOCK))
+ }
+ ensure
+ Process.wait
+ sdbm2.close if sdbm2
+ end
+ end
+
+ def test_s_open_error
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm", 0))
+ assert_exception(Errno::EACCES) {
+ SDBM.open("tmptest_sdbm", 0)
+ }
+ sdbm.close
+ end
+
+ def test_close
+ assert_instance_of(SDBM, sdbm = SDBM.open("tmptest_sdbm"))
+ assert_nil(sdbm.close)
+
+ # closed SDBM file
+ assert_exception(SDBMError) { sdbm.close }
+ end
+
+ def test_aref
+ assert_equals('bar', @sdbm['foo'] = 'bar')
+ assert_equals('bar', @sdbm['foo'])
+
+ assert_nil(@sdbm['bar'])
+ end
+
+ def test_fetch
+ assert_equals('bar', @sdbm['foo']='bar')
+ assert_equals('bar', @sdbm.fetch('foo'))
+
+ # key not found
+ assert_exception(IndexError) {
+ @sdbm.fetch('bar')
+ }
+
+ # test for `ifnone' arg
+ assert_equals('baz', @sdbm.fetch('bar', 'baz'))
+
+ # test for `ifnone' block
+ assert_equals('foobar', @sdbm.fetch('bar') {|key| 'foo' + key })
+ end
+
+ def test_aset
+ num = 0
+ 2.times {|i|
+ assert_equals('foo', @sdbm['foo'] = 'foo')
+ assert_equals('foo', @sdbm['foo'])
+ assert_equals('bar', @sdbm['foo'] = 'bar')
+ assert_equals('bar', @sdbm['foo'])
+
+ num += 1 if i == 0
+ assert_equals(num, @sdbm.size)
+
+ # assign nil
+ assert_equals('', @sdbm['bar'] = '')
+ assert_equals('', @sdbm['bar'])
+
+ num += 1 if i == 0
+ assert_equals(num, @sdbm.size)
+
+ # empty string
+ assert_equals('', @sdbm[''] = '')
+ assert_equals('', @sdbm[''])
+
+ num += 1 if i == 0
+ assert_equals(num, @sdbm.size)
+
+ # Fixnum
+ assert_equals('200', @sdbm['100'] = '200')
+ assert_equals('200', @sdbm['100'])
+
+ num += 1 if i == 0
+ assert_equals(num, @sdbm.size)
+
+ # Big key and value
+ assert_equals('y' * 100, @sdbm['x' * 100] = 'y' * 100)
+ assert_equals('y' * 100, @sdbm['x' * 100])
+
+ num += 1 if i == 0
+ assert_equals(num, @sdbm.size)
+ }
+ end
+
+ def test_index
+ assert_equals('bar', @sdbm['foo'] = 'bar')
+ assert_equals('foo', @sdbm.index('bar'))
+ assert_nil(@sdbm['bar'])
+ end
+
+ def test_indexes
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+ assert_equals(values.reverse, @sdbm.indexes(*keys.reverse))
+ end
+
+ def test_values_at
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+ assert_equals(values.reverse, @sdbm.values_at(*keys.reverse))
+ end
+
+ def test_select_with_block
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+ ret = @sdbm.select {|k,v|
+ assert_equals(k.upcase, v)
+ k != "bar"
+ }
+ assert_equals([['baz', 'BAZ'], ['foo', 'FOO']],
+ ret.sort)
+ end
+
+ def test_length
+ num = 10
+ assert_equals(0, @sdbm.size)
+ num.times {|i|
+ i = i.to_s
+ @sdbm[i] = i
+ }
+ assert_equals(num, @sdbm.size)
+
+ @sdbm.shift
+
+ assert_equals(num - 1, @sdbm.size)
+ end
+
+ def test_empty?
+ assert_equals(true, @sdbm.empty?)
+ @sdbm['foo'] = 'FOO'
+ assert_equals(false, @sdbm.empty?)
+ end
+
+ def test_each_pair
+ n = 0
+ @sdbm.each_pair { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+
+ n = 0
+ ret = @sdbm.each_pair {|key, val|
+ assert_not_nil(i = keys.index(key))
+ assert_equals(val, values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@sdbm, ret)
+ end
+
+ def test_each_value
+ n = 0
+ @sdbm.each_value { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+
+ n = 0
+ ret = @sdbm.each_value {|val|
+ assert_not_nil(key = @sdbm.index(val))
+ assert_not_nil(i = keys.index(key))
+ assert_equals(val, values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@sdbm, ret)
+ end
+
+ def test_each_key
+ n = 0
+ @sdbm.each_key { n += 1 }
+ assert_equals(0, n)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+
+ n = 0
+ ret = @sdbm.each_key {|key|
+ assert_not_nil(i = keys.index(key))
+ assert_equals(@sdbm[key], values[i])
+
+ n += 1
+ }
+ assert_equals(keys.size, n)
+ assert_equals(@sdbm, ret)
+ end
+
+ def test_keys
+ assert_equals([], @sdbm.keys)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+
+ assert_equals(keys.sort, @sdbm.keys.sort)
+ assert_equals(values.sort, @sdbm.values.sort)
+ end
+
+ def test_values
+ test_keys
+ end
+
+ def test_shift
+ assert_nil(@sdbm.shift)
+ assert_equals(0, @sdbm.size)
+
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+
+ ret_keys = []
+ ret_values = []
+ while ret = @sdbm.shift
+ ret_keys.push ret[0]
+ ret_values.push ret[1]
+
+ assert_equals(keys.size - ret_keys.size, @sdbm.size)
+ end
+
+ assert_equals(keys.sort, ret_keys.sort)
+ assert_equals(values.sort, ret_values.sort)
+ end
+
+ def test_delete
+ keys = %w(foo bar baz)
+ values = %w(FOO BAR BAZ)
+ key = keys[1]
+
+ assert_nil(@sdbm.delete(key))
+ assert_equals(0, @sdbm.size)
+
+ @sdbm[keys[0]], @sdbm[keys[1]], @sdbm[keys[2]] = values
+
+ assert_equals('BAR', @sdbm.delete(key))
+ assert_nil(@sdbm[key])
+ assert_equals(2, @sdbm.size)
+
+ assert_nil(@sdbm.delete(key))
+ end
+ def test_delete_with_block
+ key = 'no called block'
+ @sdbm[key] = 'foo'
+ assert_equals('foo', @sdbm.delete(key) {|k| k.replace 'called block'})
+ assert_equals('no called block', key)
+ assert_equals(0, @sdbm.size)
+
+ key = 'no called block'
+ assert_equals(:blockval,
+ @sdbm.delete(key) {|k| k.replace 'called block'; :blockval})
+ assert_equals('called block', key)
+ assert_equals(0, @sdbm.size)
+ end
+
+ def test_delete_if
+ v = "0"
+ 100.times {@sdbm[v] = v; v = v.next}
+
+ ret = @sdbm.delete_if {|key, val| key.to_i < 50}
+ assert_equals(@sdbm, ret)
+ check_size(50, @sdbm)
+
+ ret = @sdbm.delete_if {|key, val| key.to_i >= 50}
+ assert_equals(@sdbm, ret)
+ check_size(0, @sdbm)
+
+ # break
+ v = "0"
+ 100.times {@sdbm[v] = v; v = v.next}
+ check_size(100, @sdbm)
+ n = 0;
+ @sdbm.delete_if {|key, val|
+ break if n > 50
+ n+=1
+ true
+ }
+ assert_equals(51, n)
+ check_size(49, @sdbm)
+
+ @sdbm.clear
+
+ # raise
+ v = "0"
+ 100.times {@sdbm[v] = v; v = v.next}
+ check_size(100, @sdbm)
+ n = 0;
+ begin
+ @sdbm.delete_if {|key, val|
+ raise "runtime error" if n > 50
+ n+=1
+ true
+ }
+ rescue
+ end
+ assert_equals(51, n)
+ check_size(49, @sdbm)
+ end
+
+ def test_reject
+ v = "0"
+ 100.times {@sdbm[v] = v; v = v.next}
+
+ hash = @sdbm.reject {|key, val| key.to_i < 50}
+ assert_instance_of(Hash, hash)
+ assert_equals(100, @sdbm.size)
+
+ assert_equals(50, hash.size)
+ hash.each_pair {|key,val|
+ assert_equals(false, key.to_i < 50)
+ assert_equals(key, val)
+ }
+
+ hash = @sdbm.reject {|key, val| key.to_i < 100}
+ assert_instance_of(Hash, hash)
+ assert_equals(true, hash.empty?)
+ end
+
+ def test_clear
+ v = "1"
+ 100.times {v = v.next; @sdbm[v] = v}
+
+ assert_equals(@sdbm, @sdbm.clear)
+
+ # validate SDBM#size
+ i = 0
+ @sdbm.each { i += 1 }
+ assert_equals(@sdbm.size, i)
+ assert_equals(0, i)
+ end
+
+ def test_invert
+ v = "0"
+ 100.times {@sdbm[v] = v; v = v.next}
+
+ hash = @sdbm.invert
+ assert_instance_of(Hash, hash)
+ assert_equals(100, hash.size)
+ hash.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_update
+ hash = {}
+ v = "0"
+ 100.times {v = v.next; hash[v] = v}
+
+ @sdbm["101"] = "101"
+ @sdbm.update hash
+ assert_equals(101, @sdbm.size)
+ @sdbm.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_replace
+ hash = {}
+ v = "0"
+ 100.times {v = v.next; hash[v] = v}
+
+ @sdbm["101"] = "101"
+ @sdbm.replace hash
+ assert_equals(100, @sdbm.size)
+ @sdbm.each_pair {|key, val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_haskey?
+ assert_equals('bar', @sdbm['foo']='bar')
+ assert_equals(true, @sdbm.has_key?('foo'))
+ assert_equals(false, @sdbm.has_key?('bar'))
+ end
+
+ def test_has_value?
+ assert_equals('bar', @sdbm['foo']='bar')
+ assert_equals(true, @sdbm.has_value?('bar'))
+ assert_equals(false, @sdbm.has_value?('foo'))
+ end
+
+ def test_to_a
+ v = "0"
+ 100.times {v = v.next; @sdbm[v] = v}
+
+ ary = @sdbm.to_a
+ assert_instance_of(Array, ary)
+ assert_equals(100, ary.size)
+ ary.each {|key,val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+
+ def test_to_hash
+ v = "0"
+ 100.times {v = v.next; @sdbm[v] = v}
+
+ hash = @sdbm.to_hash
+ assert_instance_of(Hash, hash)
+ assert_equals(100, hash.size)
+ hash.each {|key,val|
+ assert_equals(key.to_i, val.to_i)
+ }
+ end
+end
+
+if $0 == __FILE__
+ if ARGV.size == 0
+ suite = RUNIT::TestSuite.new
+ suite.add_test(TestSDBM.suite)
+ else
+ suite = RUNIT::TestSuite.new
+ ARGV.each do |testmethod|
+ suite.add_test(TestSDBM.new(testmethod))
+ end
+ end
+
+ RUNIT::CUI::TestRunner.run(suite)
+end
diff --git a/ext/socket/.cvsignore b/ext/socket/.cvsignore
index f3c7a7c5da..4088712231 100644
--- a/ext/socket/.cvsignore
+++ b/ext/socket/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.def
diff --git a/ext/socket/MANIFEST b/ext/socket/MANIFEST
deleted file mode 100644
index 616d459d92..0000000000
--- a/ext/socket/MANIFEST
+++ /dev/null
@@ -1,8 +0,0 @@
-MANIFEST
-addrinfo.h
-depend
-extconf.rb
-getaddrinfo.c
-getnameinfo.c
-sockport.h
-socket.c
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h
index 6000a466ba..a22615ee00 100644
--- a/ext/socket/addrinfo.h
+++ b/ext/socket/addrinfo.h
@@ -115,8 +115,10 @@
/*
* Constants for getnameinfo()
*/
+#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
+#endif
/*
* Flag values for getnameinfo()
@@ -153,7 +155,10 @@ extern int getnameinfo __P((
int flags));
extern void freehostent __P((struct hostent *));
-extern void freeaddrent __P((struct addrinfo *));
+extern void freeaddrinfo __P((struct addrinfo *));
+#if defined __UCLIBC__
+const
+#endif
extern char *gai_strerror __P((int));
/* In case there is no definition of offsetof() provided - though any proper
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 3582c21c41..4f7b49407f 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -1,18 +1,16 @@
require 'mkmf'
-$LIBPATH << "/usr/local/lib" if File.directory?("/usr/local/lib")
-$CPPFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"
-
case RUBY_PLATFORM
+when /bccwin32/
+ test_func = "WSACleanup"
+ have_library("ws2_32", "WSACleanup")
+ have_func("closesocket")
when /mswin32|mingw/
test_func = "WSACleanup"
have_library("wsock32", "WSACleanup")
have_func("closesocket")
when /cygwin/
-# $LDFLAGS << " -L/usr/lib" if File.directory?("/usr/lib")
-# $CFLAGS << " -I/usr/include"
test_func = "socket"
-# have_library("bind", "gethostbyaddr")
when /beos/
test_func = "socket"
have_library("net", "socket")
@@ -27,7 +25,8 @@ else
end
$ipv6 = false
-if enable_config("ipv6", false)
+default_ipv6 = /cygwin/ !~ RUBY_PLATFORM
+if enable_config("ipv6", default_ipv6)
if try_link(<<EOF)
#include <sys/types.h>
#include <sys/socket.h>
@@ -46,19 +45,13 @@ $ipv6lib = nil
$ipv6libdir = nil
$ipv6trylibc = nil
if $ipv6
- if egrep_cpp("yes", <<EOF)
+ if macro_defined?("IPV6_INRIA_VERSION", <<EOF)
#include <netinet/in.h>
-#ifdef IPV6_INRIA_VERSION
-yes
-#endif
EOF
$ipv6type = "inria"
$CFLAGS="-DINET6 "+$CFLAGS
- elsif egrep_cpp("yes", <<EOF)
+ elsif macro_defined?("__KAME__", <<EOF)
#include <netinet/in.h>
-#ifdef __KAME__
-yes
-#endif
EOF
$ipv6type = "kame"
$ipv6lib="inet6"
@@ -70,31 +63,22 @@ EOF
$ipv6lib="inet6"
$ipv6libdir="/usr/inet6/lib"
$CFLAGS="-DINET6 -I/usr/inet6/include "+$CFLAGS
- elsif egrep_cpp("yes", <<EOF)
+ elsif macro_defined?("_TOSHIBA_INET6", <<EOF)
#include <sys/param.h>
-#ifdef _TOSHIBA_INET6
-yes
-#endif
EOF
$ipv6type = "toshiba"
$ipv6lib="inet6"
$ipv6libdir="/usr/local/v6/lib"
$CFLAGS="-DINET6 "+$CFLAGS
- elsif egrep_cpp("yes", <<EOF)
+ elsif macro_defined?("__V6D__", <<EOF)
#include </usr/local/v6/include/sys/v6config.h>
-#ifdef __V6D__
-yes
-#endif
EOF
$ipv6type = "v6d"
$ipv6lib="v6"
$ipv6libdir="/usr/local/v6/lib"
$CFLAGS="-DINET6 -I/usr/local/v6/include "+$CFLAGS
- elsif egrep_cpp("yes", <<EOF)
+ elsif macro_defined?("_ZETA_MINAMI_INET6", <<EOF)
#include <sys/param.h>
-#ifdef _ZETA_MINAMI_INET6
-yes
-#endif
EOF
$ipv6type = "zeta"
$ipv6lib="inet6"
@@ -122,11 +106,16 @@ EOS
end
if try_link(<<EOF)
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+#ifdef _WIN32
+# include <windows.h>
+# include <winsock.h>
+#else
+# include <sys/types.h>
+# include <netdb.h>
+# include <string.h>
+# include <sys/socket.h>
+# include <netinet/in.h>
+#endif
int
main()
{
@@ -140,10 +129,37 @@ EOF
end
if try_link(<<EOF)
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
+#ifdef _WIN32
+# include <windows.h>
+# include <winsock.h>
+#else
+# include <sys/types.h>
+# include <netdb.h>
+# include <string.h>
+# include <sys/socket.h>
+#endif
+int
+main()
+{
+ struct sockaddr_storage ss;
+
+ ss.ss_family;
+ return 0;
+}
+EOF
+ $CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS
+else # doug's fix, NOW add -Dss_family... only if required!
+$CPPFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"
+ if try_link(<<EOF)
+#ifdef _WIN32
+# include <windows.h>
+# include <winsock.h>
+#else
+# include <sys/types.h>
+# include <netdb.h>
+# include <string.h>
+# include <sys/socket.h>
+#endif
int
main()
{
@@ -155,6 +171,7 @@ main()
EOF
$CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS
end
+end
if try_link(<<EOF)
#include <sys/types.h>
@@ -174,11 +191,16 @@ EOF
$CFLAGS="-DHAVE_SA_LEN "+$CFLAGS
end
-have_header("netinet/tcp.h") if not /cygwin/ === RUBY_PLATFORM # for cygwin 1.1.5
+have_header("netinet/tcp.h") if not /cygwin/ =~ RUBY_PLATFORM # for cygwin 1.1.5
have_header("netinet/udp.h")
+if have_func("sendmsg") | have_func("recvmsg")
+ have_struct_member('struct msghdr', 'msg_control', ['sys/types.h', 'sys/socket.h'])
+ have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
+end
+
$getaddr_info_ok = false
-if not enable_config("wide-getaddrinfo", false) and try_run(<<EOF)
+if !enable_config("wide-getaddrinfo", false) and try_run(<<EOF)
#include <sys/types.h>
#include <netdb.h>
#include <string.h>
@@ -198,6 +220,7 @@ main()
for (passive = 0; passive <= 1; passive++) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
+ hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = passive ? AI_PASSIVE : 0;
hints.ai_socktype = SOCK_STREAM;
if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
@@ -274,6 +297,7 @@ if $ipv6 and not $getaddr_info_ok
Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
you cannot compile IPv6 socket classes with broken these functions.
+You can try --enable-wide-getaddrinfo.
EOS
exit
end
@@ -295,8 +319,35 @@ end
$objs = ["socket.#{$OBJEXT}"]
-if $getaddr_info_ok and have_func("getaddrinfo") and have_func("getnameinfo")
+if $getaddr_info_ok and have_func("getaddrinfo", "netdb.h") and have_func("getnameinfo", "netdb.h")
have_getaddrinfo = true
+else
+ if try_link(<<EOF)
+#ifndef _WIN32
+# include <sys/types.h>
+# include <netdb.h>
+# include <string.h>
+# include <sys/socket.h>
+# include <netinet/in.h>
+#else
+# include <windows.h>
+# ifdef _WIN32_WCE
+# include <winsock.h>
+# else
+# include <winsock.h>
+# endif
+#endif
+int
+main()
+{
+ struct in6_addr addr;
+ unsigned char c;
+ c = addr.s6_addr8;
+ return 0;
+}
+EOF
+ $CFLAGS="-DHAVE_ADDR8 "+$CFLAGS
+ end
end
if have_getaddrinfo
@@ -330,17 +381,19 @@ EOF
end
have_header("sys/un.h")
+have_header("sys/uio.h")
if have_func(test_func)
have_func("hsterror")
+ have_func("getipnodebyname") or have_func("gethostbyname2")
unless have_func("gethostname")
have_func("uname")
end
- if ENV["SOCKS_SERVER"] or enable_config("socks", false)
+ if enable_config("socks", ENV["SOCKS_SERVER"])
if have_library("socks5", "SOCKSinit")
- $CFLAGS="-DSOCKS5 -DSOCKS"
+ $CFLAGS+=" -DSOCKS5 -DSOCKS"
elsif have_library("socks", "Rconnect")
- $CFLAGS="-DSOCKS"
+ $CFLAGS+=" -DSOCKS"
end
end
create_makefile("socket")
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index d518017bc8..14bedb2e9b 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -40,7 +40,7 @@
#include "config.h"
#include <sys/types.h>
-#ifndef NT
+#ifndef _WIN32
#include <sys/param.h>
#if defined(__BEOS__)
# include <net/socket.h>
@@ -56,6 +56,9 @@
#endif
#include <netdb.h>
#if defined(HAVE_RESOLV_H)
+#ifdef _SX
+#include <stdio.h>
+#endif
#include <resolv.h>
#endif
#include <unistd.h>
@@ -105,7 +108,7 @@ struct sockinet {
u_short si_port;
};
-static struct afd {
+static const struct afd {
int a_af;
int a_addrlen;
int a_socklen;
@@ -136,14 +139,14 @@ static struct afd {
#define PTON_MAX 4
#endif
-static int get_name __P((const char *, struct afd *,
+static int get_name __P((const char *, const struct afd *,
struct addrinfo **, char *, struct addrinfo *,
int));
static int get_addr __P((const char *, int, struct addrinfo **,
struct addrinfo *, int));
static int str_isnumber __P((const char *));
-static char *ai_errlist[] = {
+static const char *const ai_errlist[] = {
"success.",
"address family for hostname not supported.", /* EAI_ADDRFAMILY */
"temporary failure in name resolution.", /* EAI_AGAIN */
@@ -191,13 +194,16 @@ if (pai->ai_flags & AI_CANONNAME) {\
#define ERR(err) { error = (err); goto bad; }
+#if defined __UCLIBC__
+const
+#endif
char *
gai_strerror(ecode)
int ecode;
{
if (ecode < 0 || ecode > EAI_MAX)
ecode = EAI_MAX;
- return ai_errlist[ecode];
+ return (char *)ai_errlist[ecode];
}
void
@@ -394,7 +400,7 @@ getaddrinfo(hostname, servname, hints, res)
fprintf(stderr, "panic!\n");
break;
}
- if ((sp = getservbyname(servname, proto)) == NULL)
+ if ((sp = getservbyname((char*)servname, proto)) == NULL)
ERR(EAI_SERVICE);
port = sp->s_port;
if (pai->ai_socktype == ANY)
@@ -415,7 +421,7 @@ getaddrinfo(hostname, servname, hints, res)
* non-passive socket -> localhost (127.0.0.1 or ::1)
*/
if (hostname == NULL) {
- struct afd *afd;
+ const struct afd *afd;
int s;
for (afd = &afdl[0]; afd->a_af; afd++) {
@@ -477,7 +483,11 @@ getaddrinfo(hostname, servname, hints, res)
break;
#ifdef INET6
case AF_INET6:
+#ifdef HAVE_ADDR8
pfx = ((struct in6_addr *)pton)->s6_addr8[0];
+#else
+ pfx = ((struct in6_addr *)pton)->s6_addr[0];
+#endif
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
pai->ai_flags &= ~AI_CANONNAME;
break;
@@ -530,7 +540,7 @@ getaddrinfo(hostname, servname, hints, res)
static int
get_name(addr, afd, res, numaddr, pai, port0)
const char *addr;
- struct afd *afd;
+ const struct afd *afd;
struct addrinfo **res;
char *numaddr;
struct addrinfo *pai;
@@ -547,7 +557,7 @@ get_name(addr, afd, res, numaddr, pai, port0)
#ifdef INET6
hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
#else
- hp = gethostbyaddr(addr, afd->a_addrlen, AF_INET);
+ hp = gethostbyaddr((char*)addr, afd->a_addrlen, AF_INET);
#endif
if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
GET_AI(cur, afd, hp->h_addr_list[0], port);
@@ -585,7 +595,7 @@ get_addr(hostname, af, res, pai, port0)
struct addrinfo sentinel;
struct hostent *hp;
struct addrinfo *top, *cur;
- struct afd *afd;
+ const struct afd *afd;
int i, error = 0, h_error;
char *ap;
@@ -599,7 +609,7 @@ get_addr(hostname, af, res, pai, port0)
} else
hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error);
#else
- hp = gethostbyname(hostname);
+ hp = gethostbyname((char*)hostname);
h_error = h_errno;
#endif
if (hp == NULL) {
diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
index bd3bd129bf..4c9c8f03c4 100644
--- a/ext/socket/getnameinfo.c
+++ b/ext/socket/getnameinfo.c
@@ -36,7 +36,7 @@
#include "config.h"
#include <sys/types.h>
-#ifndef NT
+#ifndef _WIN32
#if defined(__BEOS__)
# include <net/socket.h>
#else
@@ -51,10 +51,13 @@
#endif
#include <netdb.h>
#if defined(HAVE_RESOLV_H)
+#ifdef _SX
+#include <stdio.h>
+#endif
#include <resolv.h>
#endif
#endif
-#ifdef NT
+#ifdef _WIN32
#include <winsock2.h>
#include <stdio.h>
#define snprintf _snprintf
@@ -180,14 +183,14 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
/* what we should do? */
} else if (flags & NI_NUMERICSERV) {
snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
- if (strlen(numserv) > servlen)
+ if (strlen(numserv) + 1 > servlen)
return ENI_MEMORY;
strcpy(serv, numserv);
} else {
#if defined(HAVE_GETSERVBYPORT)
sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
if (sp) {
- if (strlen(sp->s_name) > servlen)
+ if (strlen(sp->s_name) + 1 > servlen)
return ENI_MEMORY;
strcpy(serv, sp->s_name);
} else
@@ -199,16 +202,20 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
switch (sa->sa_family) {
case AF_INET:
- v4a = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
+ v4a = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0 || v4a == IN_LOOPBACKNET)
+ if (v4a == 0)
flags |= NI_NUMERICHOST;
break;
#ifdef INET6
case AF_INET6:
+#ifdef HAVE_ADDR8
pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0];
+#else
+ pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[0];
+#endif
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
flags |= NI_NUMERICHOST;
break;
@@ -236,7 +243,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
p = strchr(hp->h_name, '.');
if (p) *p = '\0';
}
- if (strlen(hp->h_name) > hostlen) {
+ if (strlen(hp->h_name) + 1 > hostlen) {
#ifdef INET6
freehostent(hp);
#endif
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index e77e3d609f..1df7cb988c 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -6,13 +6,14 @@
$Date$
created at: Thu Mar 31 12:21:29 JST 1994
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2001 Yukihiro Matsumoto
************************************************/
#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
+#include "util.h"
#include <stdio.h>
#include <sys/types.h>
@@ -20,13 +21,20 @@
#include <unistd.h>
#endif
-#ifndef NT
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
+#ifndef _WIN32
#if defined(__BEOS__)
# include <net/socket.h>
#else
# include <sys/socket.h>
#endif
#include <netinet/in.h>
+#ifdef HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
@@ -121,7 +129,7 @@ static int lookup_order_table[LOOKUP_ORDERS] = {
};
static int
-rb_getaddrinfo(nodename, servname, hints, res)
+ruby_getaddrinfo(nodename, servname, hints, res)
char *nodename;
char *servname;
struct addrinfo *hints;
@@ -151,46 +159,40 @@ rb_getaddrinfo(nodename, servname, hints, res)
return error;
}
-#define getaddrinfo(node,serv,hints,res) rb_getaddrinfo((node),(serv),(hints),(res))
+#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo((node),(serv),(hints),(res))
#endif
-#ifdef NT
-static void
-sock_finalize(fptr)
- OpenFile *fptr;
-{
- SOCKET s;
-
- if (!fptr->f) return;
- s = get_osfhandle(fileno(fptr->f));
- myfdclose(fptr->f);
- if (fptr->f2) myfdclose(fptr->f2);
- closesocket(s);
-}
+#ifdef HAVE_CLOSESOCKET
+#undef close
+#define close closesocket
#endif
static VALUE
-sock_new(class, fd)
- VALUE class;
+init_sock(sock, fd)
+ VALUE sock;
int fd;
{
OpenFile *fp;
- NEWOBJ(sock, struct RFile);
- OBJSETUP(sock, class, T_FILE);
MakeOpenFile(sock, fp);
fp->f = rb_fdopen(fd, "r");
-#ifdef NT
- fp->finalize = sock_finalize;
- fd = myfddup(fd);
-#else
- fd = dup(fd);
-#endif
fp->f2 = rb_fdopen(fd, "w");
fp->mode = FMODE_READWRITE;
rb_io_synchronized(fp);
- return (VALUE)sock;
+ return sock;
+}
+
+static VALUE
+bsock_s_for_fd(klass, fd)
+ VALUE klass, fd;
+{
+ OpenFile *fptr;
+ VALUE sock = init_sock(rb_obj_alloc(klass), NUM2INT(fd));
+
+ GetOpenFile(sock, fptr);
+
+ return sock;
}
static VALUE
@@ -233,18 +235,10 @@ bsock_close_read(sock)
}
GetOpenFile(sock, fptr);
shutdown(fileno(fptr->f), 0);
- if (fptr->f2 == 0) {
+ if (!(fptr->mode & FMODE_WRITABLE)) {
return rb_io_close(sock);
}
- rb_thread_fd_close(fileno(fptr->f));
fptr->mode &= ~FMODE_READABLE;
-#ifdef NT
- myfdclose(fptr->f);
-#else
- fclose(fptr->f);
-#endif
- fptr->f = fptr->f2;
- fptr->f2 = 0;
return Qnil;
}
@@ -259,17 +253,11 @@ bsock_close_write(sock)
rb_raise(rb_eSecurityError, "Insecure: can't close socket");
}
GetOpenFile(sock, fptr);
- if (fptr->f2 == 0) {
+ if (!(fptr->mode & FMODE_READABLE)) {
return rb_io_close(sock);
}
shutdown(fileno(fptr->f2), 1);
fptr->mode &= ~FMODE_WRITABLE;
-#ifdef NT
- myfdclose(fptr->f2);
-#else
- fclose(fptr->f2);
-#endif
- fptr->f2 = 0;
return Qnil;
}
@@ -287,6 +275,8 @@ bsock_setsockopt(sock, lev, optname, val)
rb_secure(2);
level = NUM2INT(lev);
option = NUM2INT(optname);
+ GetOpenFile(sock, fptr);
+
switch (TYPE(val)) {
case T_FIXNUM:
i = FIX2INT(val);
@@ -300,10 +290,12 @@ bsock_setsockopt(sock, lev, optname, val)
v = (char*)&i; vlen = sizeof(i);
break;
default:
- v = rb_str2cstr(val, &vlen);
+ StringValue(val);
+ v = RSTRING(val)->ptr;
+ vlen = RSTRING(val)->len;
+ break;
}
- GetOpenFile(sock, fptr);
if (setsockopt(fileno(fptr->f), level, option, v, vlen) < 0)
rb_sys_fail(fptr->path);
@@ -329,7 +321,7 @@ bsock_getsockopt(sock, lev, optname)
if (getsockopt(fileno(fptr->f), level, option, buf, &len) < 0)
rb_sys_fail(fptr->path);
- return rb_tainted_str_new(buf, len);
+ return rb_str_new(buf, len);
#else
rb_notimplement();
#endif
@@ -337,7 +329,7 @@ bsock_getsockopt(sock, lev, optname)
static VALUE
bsock_getsockname(sock)
- VALUE sock;
+ VALUE sock;
{
char buf[1024];
socklen_t len = sizeof buf;
@@ -346,12 +338,12 @@ bsock_getsockname(sock)
GetOpenFile(sock, fptr);
if (getsockname(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
rb_sys_fail("getsockname(2)");
- return rb_tainted_str_new(buf, len);
+ return rb_str_new(buf, len);
}
static VALUE
bsock_getpeername(sock)
- VALUE sock;
+ VALUE sock;
{
char buf[1024];
socklen_t len = sizeof buf;
@@ -360,7 +352,7 @@ bsock_getpeername(sock)
GetOpenFile(sock, fptr);
if (getpeername(fileno(fptr->f), (struct sockaddr*)buf, &len) < 0)
rb_sys_fail("getpeername(2)");
- return rb_tainted_str_new(buf, len);
+ return rb_str_new(buf, len);
}
static VALUE
@@ -369,41 +361,31 @@ bsock_send(argc, argv, sock)
VALUE *argv;
VALUE sock;
{
- VALUE msg, to;
+ VALUE mesg, to;
VALUE flags;
OpenFile *fptr;
FILE *f;
int fd, n;
- char *m, *t;
- int mlen, tlen;
rb_secure(4);
- rb_scan_args(argc, argv, "21", &msg, &flags, &to);
+ rb_scan_args(argc, argv, "21", &mesg, &flags, &to);
GetOpenFile(sock, fptr);
f = GetWriteFile(fptr);
fd = fileno(f);
- retry:
rb_thread_fd_writable(fd);
- m = rb_str2cstr(msg, &mlen);
+ StringValue(mesg);
+ retry:
if (!NIL_P(to)) {
- t = rb_str2cstr(to, &tlen);
- n = sendto(fd, m, mlen, NUM2INT(flags),
- (struct sockaddr*)t, tlen);
+ StringValue(to);
+ n = sendto(fd, RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags),
+ (struct sockaddr*)RSTRING(to)->ptr, RSTRING(to)->len);
}
else {
- n = send(fd, m, mlen, NUM2INT(flags));
+ n = send(fd, RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags));
}
if (n < 0) {
- switch (errno) {
- case EINTR:
- rb_thread_schedule();
- goto retry;
- case EWOULDBLOCK:
-#if EAGAIN != EWOULDBLOCK
- case EAGAIN:
-#endif
- rb_thread_fd_writable(fd);
+ if (rb_io_wait_writable(fd)) {
goto retry;
}
rb_sys_fail("send(2)");
@@ -411,16 +393,16 @@ bsock_send(argc, argv, sock)
return INT2FIX(n);
}
-static VALUE ipaddr _((struct sockaddr *));
+static VALUE ipaddr _((struct sockaddr*));
#ifdef HAVE_SYS_UN_H
-static VALUE unixaddr _((struct sockaddr_un *));
+static VALUE unixaddr _((struct sockaddr_un*));
#endif
enum sock_recv_type {
RECV_RECV, /* BasicSocket#recv(no from) */
RECV_IP, /* IPSocket#recvfrom */
RECV_UNIX, /* UNIXSocket#recvfrom */
- RECV_SOCKET, /* Socket#recvfrom */
+ RECV_SOCKET /* Socket#recvfrom */
};
static VALUE
@@ -435,6 +417,8 @@ s_recvfrom(sock, argc, argv, from)
char buf[1024];
socklen_t alen = sizeof buf;
VALUE len, flg;
+ long buflen;
+ long slen;
int fd, flags;
rb_scan_args(argc, argv, "11", &len, &flg);
@@ -448,30 +432,27 @@ s_recvfrom(sock, argc, argv, from)
}
fd = fileno(fptr->f);
- str = rb_tainted_str_new(0, NUM2INT(len));
+ buflen = NUM2INT(len);
+ str = rb_tainted_str_new(0, buflen);
- rb_thread_wait_fd(fd);
retry:
+ rb_str_locktmp(str);
+ rb_thread_wait_fd(fd);
TRAP_BEG;
- RSTRING(str)->len = recvfrom(fd, RSTRING(str)->ptr, RSTRING(str)->len, flags,
- (struct sockaddr*)buf, &alen);
+ slen = recvfrom(fd, RSTRING(str)->ptr, buflen, flags, (struct sockaddr*)buf, &alen);
TRAP_END;
+ rb_str_unlocktmp(str);
- if (RSTRING(str)->len < 0) {
- switch (errno) {
- case EINTR:
- rb_thread_schedule();
- goto retry;
-
- case EWOULDBLOCK:
-#if EAGAIN != EWOULDBLOCK
- case EAGAIN:
-#endif
- rb_thread_wait_fd(fd);
+ if (slen < 0) {
+ if (rb_io_wait_readable(fd)) {
goto retry;
}
rb_sys_fail("recvfrom(2)");
}
+ if (slen < RSTRING(str)->len) {
+ RSTRING(str)->len = slen;
+ RSTRING(str)->ptr[slen] = '\0';
+ }
rb_obj_taint(str);
switch (from) {
case RECV_RECV:
@@ -482,13 +463,18 @@ s_recvfrom(sock, argc, argv, from)
rb_raise(rb_eTypeError, "sockaddr size differs - should not happen");
}
#endif
- return rb_assoc_new(str, ipaddr((struct sockaddr *)buf));
+ if (alen) /* OSX doesn't return a 'from' result from recvfrom for connection-oriented sockets */
+ return rb_assoc_new(str, ipaddr((struct sockaddr*)buf));
+ else
+ return rb_assoc_new(str, Qnil);
#ifdef HAVE_SYS_UN_H
case RECV_UNIX:
- return rb_assoc_new(str, unixaddr((struct sockaddr_un *)buf));
+ return rb_assoc_new(str, unixaddr((struct sockaddr_un*)buf));
#endif
case RECV_SOCKET:
- return rb_assoc_new(str, rb_tainted_str_new(buf, alen));
+ return rb_assoc_new(str, rb_str_new(buf, alen));
+ default:
+ rb_bug("s_recvfrom called with bad value");
}
}
@@ -509,13 +495,15 @@ bsock_do_not_rev_lookup()
static VALUE
bsock_do_not_rev_lookup_set(self, val)
+ VALUE self, val;
{
+ rb_secure(4);
do_not_reverse_lookup = RTEST(val);
return val;
}
static void
-mkipaddr0(addr, buf, len)
+make_ipaddr0(addr, buf, len)
struct sockaddr *addr;
char *buf;
size_t len;
@@ -529,17 +517,17 @@ mkipaddr0(addr, buf, len)
}
static VALUE
-mkipaddr(addr)
+make_ipaddr(addr)
struct sockaddr *addr;
{
char buf[1024];
- mkipaddr0(addr, buf, sizeof(buf));
- return rb_tainted_str_new2(buf);
+ make_ipaddr0(addr, buf, sizeof(buf));
+ return rb_str_new2(buf);
}
static void
-mkinetaddr(host, buf, len)
+make_inetaddr(host, buf, len)
long host;
char *buf;
size_t len;
@@ -550,61 +538,116 @@ mkinetaddr(host, buf, len)
sin.sin_family = AF_INET;
SET_SIN_LEN(&sin, sizeof(sin));
sin.sin_addr.s_addr = host;
- mkipaddr0((struct sockaddr *)&sin, buf, len);
+ make_ipaddr0((struct sockaddr*)&sin, buf, len);
}
-static struct addrinfo*
-ip_addrsetup(host, port)
- VALUE host, port;
+static int
+str_isnumber(p)
+ const char *p;
{
- struct addrinfo hints, *res;
- char *hostp, *portp;
- int error;
- char hbuf[1024], pbuf[16];
+ char *ep;
+
+ if (!p || *p == '\0')
+ return 0;
+ ep = NULL;
+ (void)strtoul(p, &ep, 10);
+ if (ep && *ep == '\0')
+ return 1;
+ else
+ return 0;
+}
+static char *
+host_str(host, hbuf, len)
+ VALUE host;
+ char *hbuf;
+ size_t len;
+{
if (NIL_P(host)) {
- hostp = NULL;
+ return NULL;
}
else if (rb_obj_is_kind_of(host, rb_cInteger)) {
long i = NUM2LONG(host);
- mkinetaddr(htonl(i), hbuf, sizeof(hbuf));
- hostp = hbuf;
+ make_inetaddr(htonl(i), hbuf, len);
+ return hbuf;
}
else {
char *name;
- Check_SafeStr(host);
+ SafeStringValue(host);
name = RSTRING(host)->ptr;
- if (*name == 0) {
- mkinetaddr(INADDR_ANY, hbuf, sizeof(hbuf));
+ if (!name || *name == 0 || (name[0] == '<' && strcmp(name, "<any>") == 0)) {
+ make_inetaddr(INADDR_ANY, hbuf, len);
}
else if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
- mkinetaddr(INADDR_BROADCAST, hbuf, sizeof(hbuf));
+ make_inetaddr(INADDR_BROADCAST, hbuf, len);
}
- else if (strlen(name) >= sizeof(hbuf)) {
+ else if (strlen(name) >= len) {
rb_raise(rb_eArgError, "hostname too long (%d)", strlen(name));
}
else {
strcpy(hbuf, name);
}
- hostp = hbuf;
+ return hbuf;
}
+}
+
+static char *
+port_str(port, pbuf, len)
+ VALUE port;
+ char *pbuf;
+ size_t len;
+{
if (NIL_P(port)) {
- portp = 0;
+ return 0;
}
else if (FIXNUM_P(port)) {
- snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port));
- portp = pbuf;
+ snprintf(pbuf, len, "%ld", FIX2LONG(port));
+ return pbuf;
}
else {
- Check_SafeStr(port);
- portp = STR2CSTR(port);
+ char *serv;
+
+ SafeStringValue(port);
+ serv = RSTRING(port)->ptr;
+ if (strlen(serv) >= len) {
+ rb_raise(rb_eArgError, "service name too long (%d)", strlen(serv));
+ }
+ strcpy(pbuf, serv);
+ return pbuf;
+ }
+}
+
+#ifndef NI_MAXHOST
+# define 1025
+#endif
+#ifndef NI_MAXSERV
+# define 32
+#endif
+
+static struct addrinfo*
+sock_addrinfo(host, port, socktype, flags)
+ VALUE host, port;
+ int socktype, flags;
+{
+ struct addrinfo hints;
+ struct addrinfo* res = NULL;
+ char *hostp, *portp;
+ int error;
+ char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+
+ hostp = host_str(host, hbuf, sizeof(hbuf));
+ portp = port_str(port, pbuf, sizeof(pbuf));
+
+ if (socktype == 0 && flags == 0 && str_isnumber(portp)) {
+ socktype = SOCK_DGRAM;
}
MEMZERO(&hints, struct addrinfo, 1);
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = socktype;
+ hints.ai_flags = flags;
error = getaddrinfo(hostp, portp, &hints, &res);
if (error) {
if (hostp && hostp[strlen(hostp)-1] == '\n') {
@@ -613,21 +656,26 @@ ip_addrsetup(host, port)
rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
}
+#if defined(__APPLE__) && defined(__MACH__)
+ {
+ struct addrinfo *r;
+ r = res;
+ while (r) {
+ if (! r->ai_socktype) r->ai_socktype = hints.ai_socktype;
+ if (! r->ai_protocol) {
+ if (r->ai_socktype == SOCK_DGRAM) {
+ r->ai_protocol = IPPROTO_UDP;
+ } else if (r->ai_socktype == SOCK_STREAM) {
+ r->ai_protocol = IPPROTO_TCP;
+ }
+ }
+ r = r->ai_next;
+ }
+ }
+#endif
return res;
}
-static void
-setipaddr(name, addr)
- VALUE name;
- struct sockaddr *addr;
-{
- struct addrinfo *res = ip_addrsetup(name, Qnil);
-
- /* just take the first one */
- memcpy(addr, res->ai_addr, res->ai_addrlen);
- freeaddrinfo(res);
-}
-
static VALUE
ipaddr(sockaddr)
struct sockaddr *sockaddr;
@@ -663,21 +711,21 @@ ipaddr(sockaddr)
family = rb_str_new2(pbuf);
break;
}
+ addr1 = Qnil;
if (!do_not_reverse_lookup) {
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
NULL, 0, 0);
- if (error) {
- rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
+ if (! error) {
+ addr1 = rb_str_new2(hbuf);
}
- addr1 = rb_tainted_str_new2(hbuf);
}
error = getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
- rb_raise(rb_eSocket, "getnameinfo %s", gai_strerror(error));
+ rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
- addr2 = rb_tainted_str_new2(hbuf);
- if (do_not_reverse_lookup) {
+ addr2 = rb_str_new2(hbuf);
+ if (addr1 == Qnil) {
addr1 = addr2;
}
port = INT2FIX(atoi(pbuf));
@@ -713,6 +761,21 @@ thread_write_select(fd)
rb_thread_select(fd+1, 0, &fds, 0, 0);
}
+#ifdef __CYGWIN__
+#define WAIT_IN_PROGRESS 10
+#endif
+#ifdef __APPLE__
+#define WAIT_IN_PROGRESS 10
+#endif
+#ifdef __linux__
+/* returns correct error */
+#define WAIT_IN_PROGRESS 0
+#endif
+#ifndef WAIT_IN_PROGRESS
+/* BSD origin code apparently has a problem */
+#define WAIT_IN_PROGRESS 1
+#endif
+
static int
ruby_connect(fd, sockaddr, len, socks)
int fd;
@@ -722,11 +785,15 @@ ruby_connect(fd, sockaddr, len, socks)
{
int status;
int mode;
+#if WAIT_IN_PROGRESS > 0
+ int wait_in_progress = -1;
+ int sockerr, sockerrlen;
+#endif
#if defined(HAVE_FCNTL)
mode = fcntl(fd, F_GETFL, 0);
-#ifdef O_NDELAY
+#ifdef O_NDELAY
# define NONBLOCKING O_NDELAY
#else
#ifdef O_NBIO
@@ -757,15 +824,54 @@ ruby_connect(fd, sockaddr, len, socks)
#ifdef EINPROGRESS
case EINPROGRESS:
#endif
+#if WAIT_IN_PROGRESS > 0
+ sockerrlen = sizeof(sockerr);
+ status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen);
+ if (status) break;
+ if (sockerr) {
+ status = -1;
+ errno = sockerr;
+ break;
+ }
+#endif
+#ifdef EALREADY
+ case EALREADY:
+#endif
+#if WAIT_IN_PROGRESS > 0
+ wait_in_progress = WAIT_IN_PROGRESS;
+#endif
thread_write_select(fd);
continue;
+#if WAIT_IN_PROGRESS > 0
+ case EINVAL:
+ if (wait_in_progress-- > 0) {
+ /*
+ * connect() after EINPROGRESS returns EINVAL on
+ * some platforms, need to check true error
+ * status.
+ */
+ sockerrlen = sizeof(sockerr);
+ status = getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen);
+ if (!status && !sockerr) {
+ struct timeval tv = {0, 100000};
+ rb_thread_wait_for(tv);
+ continue;
+ }
+ status = -1;
+ errno = sockerr;
+ }
+ break;
+#endif
+
#ifdef EISCONN
case EISCONN:
status = 0;
errno = 0;
break;
#endif
+ default:
+ break;
}
}
#ifdef HAVE_FCNTL
@@ -775,110 +881,144 @@ ruby_connect(fd, sockaddr, len, socks)
}
}
-static VALUE
-open_inet(class, h, serv, type)
- VALUE class, h, serv;
- int type;
+struct inetsock_arg
{
- struct addrinfo hints, *res, *res0;
- int fd, status;
- char *syscall;
- char pbuf[1024], *portp;
- char *host;
- int error;
+ VALUE sock;
+ struct {
+ VALUE host, serv;
+ struct addrinfo *res;
+ } remote, local;
+ int type;
+ int fd;
+};
- if (h) {
- Check_SafeStr(h);
- host = RSTRING(h)->ptr;
- }
- else {
- host = NULL;
- }
- if (FIXNUM_P(serv)) {
- snprintf(pbuf, sizeof(pbuf), "%ld", FIX2UINT(serv));
- portp = pbuf;
+static VALUE
+inetsock_cleanup(arg)
+ struct inetsock_arg *arg;
+{
+ if (arg->remote.res) {
+ freeaddrinfo(arg->remote.res);
+ arg->remote.res = 0;
}
- else {
- Check_SafeStr(serv);
- if (RSTRING(serv)->len >= sizeof(pbuf))
- rb_raise(rb_eArgError, "servicename too long (%d)", RSTRING(serv)->len);
- strcpy(pbuf, RSTRING(serv)->ptr);
- portp = pbuf;
+ if (arg->local.res) {
+ freeaddrinfo(arg->local.res);
+ arg->local.res = 0;
}
- MEMZERO(&hints, struct addrinfo, 1);
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- if (type == INET_SERVER) {
- hints.ai_flags = AI_PASSIVE;
+ if (arg->fd >= 0) {
+ close(arg->fd);
}
- error = getaddrinfo(host, portp, &hints, &res0);
- if (error) {
- rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
+ return Qnil;
+}
+
+static VALUE
+init_inetsock_internal(arg)
+ struct inetsock_arg *arg;
+{
+ int type = arg->type;
+ struct addrinfo *res;
+ int fd, status = 0;
+ char *syscall;
+
+ arg->remote.res = sock_addrinfo(arg->remote.host, arg->remote.serv, SOCK_STREAM,
+ (type == INET_SERVER) ? AI_PASSIVE : 0);
+ /*
+ * Maybe also accept a local address
+ */
+
+ if (type != INET_SERVER && (!NIL_P(arg->local.host) || !NIL_P(arg->local.serv))) {
+ arg->local.res = sock_addrinfo(arg->local.host, arg->local.serv, SOCK_STREAM, 0);
}
- fd = -1;
- for (res = res0; res; res = res->ai_next) {
+ arg->fd = fd = -1;
+ for (res = arg->remote.res; res; res = res->ai_next) {
status = ruby_socket(res->ai_family,res->ai_socktype,res->ai_protocol);
syscall = "socket(2)";
fd = status;
if (fd < 0) {
continue;
}
+ arg->fd = fd;
if (type == INET_SERVER) {
+#ifndef _WIN32
status = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
(char*)&status, sizeof(status));
+#endif
status = bind(fd, res->ai_addr, res->ai_addrlen);
syscall = "bind(2)";
}
else {
- status = ruby_connect(fd, res->ai_addr, res->ai_addrlen,
- (type == INET_SOCKS));
- syscall = "connect(2)";
+ if (arg->local.res) {
+ status = bind(fd, arg->local.res->ai_addr, arg->local.res->ai_addrlen);
+ syscall = "bind(2)";
+ }
+
+ if (status >= 0) {
+ status = ruby_connect(fd, res->ai_addr, res->ai_addrlen,
+ (type == INET_SOCKS));
+ syscall = "connect(2)";
+ }
}
if (status < 0) {
-#if defined(HAVE_CLOSESOCKET)
- closesocket(fd);
-#else
close(fd);
-#endif
- fd = -1;
+ arg->fd = fd = -1;
continue;
} else
break;
}
if (status < 0) {
- if (fd >= 0)
-#if defined(HAVE_CLOSESOCKET)
- closesocket(fd);
-#else
- close(fd);
-#endif
- freeaddrinfo(res0);
rb_sys_fail(syscall);
}
+ arg->fd = -1;
+
if (type == INET_SERVER)
listen(fd, 5);
/* create new instance */
- freeaddrinfo(res0);
- return sock_new(class, fd);
+ return init_sock(arg->sock, fd);
}
static VALUE
-tcp_s_open(class, host, serv)
- VALUE class, host, serv;
+init_inetsock(sock, remote_host, remote_serv, local_host, local_serv, type)
+ VALUE sock, remote_host, remote_serv, local_host, local_serv;
+ int type;
{
- Check_SafeStr(host);
- return open_inet(class, host, serv, INET_CLIENT);
+ struct inetsock_arg arg;
+ arg.sock = sock;
+ arg.remote.host = remote_host;
+ arg.remote.serv = remote_serv;
+ arg.remote.res = 0;
+ arg.local.host = local_host;
+ arg.local.serv = local_serv;
+ arg.local.res = 0;
+ arg.type = type;
+ arg.fd = -1;
+ return rb_ensure(init_inetsock_internal, (VALUE)&arg,
+ inetsock_cleanup, (VALUE)&arg);
+}
+
+static VALUE
+tcp_init(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
+{
+ VALUE remote_host, remote_serv;
+ VALUE local_host, local_serv;
+
+ rb_scan_args(argc, argv, "22", &remote_host, &remote_serv,
+ &local_host, &local_serv);
+
+ return init_inetsock(sock, remote_host, remote_serv,
+ local_host, local_serv, INET_CLIENT);
}
#ifdef SOCKS
static VALUE
-socks_s_open(class, host, serv)
- VALUE class, host, serv;
+socks_init(sock, host, serv)
+ VALUE sock, host, serv;
{
static init = 0;
@@ -886,9 +1026,8 @@ socks_s_open(class, host, serv)
SOCKSinit("ruby");
init = 1;
}
-
- Check_SafeStr(host);
- return open_inet(class, host, serv, INET_SOCKS);
+
+ return init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS);
}
#ifdef SOCKS5
@@ -909,136 +1048,104 @@ socks_s_close(sock)
#endif
#endif
-/*
- * NOTE: using gethostbyname() against AF_INET6 is a bad idea, as it
- * does not initialize sin_flowinfo nor sin_scope_id properly.
- */
+struct hostent_arg {
+ VALUE host;
+ struct addrinfo* addr;
+ VALUE (*ipaddr)_((struct sockaddr*, size_t));
+};
+
static VALUE
-tcp_s_gethostbyname(obj, host)
- VALUE obj, host;
+make_hostent_internal(arg)
+ struct hostent_arg *arg;
{
- struct sockaddr_storage addr;
+ VALUE host = arg->host;
+ struct addrinfo* addr = arg->addr;
+ VALUE (*ipaddr)_((struct sockaddr*, size_t)) = arg->ipaddr;
+
+ struct addrinfo *ai;
struct hostent *h;
- char **pch;
VALUE ary, names;
+ char **pch;
+ const char* hostp;
+ char hbuf[NI_MAXHOST];
- rb_secure(3);
- if (rb_obj_is_kind_of(host, rb_cInteger)) {
- long i = NUM2LONG(host);
- struct sockaddr_in *sin;
-
- sin = (struct sockaddr_in *)&addr;
- MEMZERO(sin, struct sockaddr_in, 1);
- sin->sin_family = AF_INET;
- SET_SIN_LEN(sin, sizeof(*sin));
- sin->sin_addr.s_addr = htonl(i);
+ ary = rb_ary_new();
+ if (addr->ai_canonname) {
+ hostp = addr->ai_canonname;
}
else {
- setipaddr(host, &addr);
- }
- switch (addr.ss_family) {
- case AF_INET:
- {
- struct sockaddr_in *sin;
- sin = (struct sockaddr_in *)&addr;
- h = gethostbyaddr((char *)&sin->sin_addr,
- sizeof(sin->sin_addr),
- sin->sin_family);
- break;
- }
-#ifdef INET6
- case AF_INET6:
- {
- struct sockaddr_in6 *sin6;
- sin6 = (struct sockaddr_in6 *)&addr;
- h = gethostbyaddr((char *)&sin6->sin6_addr,
- sizeof(sin6->sin6_addr),
- sin6->sin6_family);
- break;
- }
-#endif
- default:
- h = NULL;
+ hostp = host_str(host, hbuf, sizeof(hbuf));
}
+ rb_ary_push(ary, rb_str_new2(hostp));
- if (h == NULL) {
-#ifdef HAVE_HSTERROR
- extern int h_errno;
- rb_raise(rb_eSocket, "%s", (char *)hsterror(h_errno));
-#else
- rb_raise(rb_eSocket, "host not found");
-#endif
+ if (addr->ai_canonname && (h = gethostbyname(addr->ai_canonname))) {
+ names = rb_ary_new();
+ if (h->h_aliases != NULL) {
+ for (pch = h->h_aliases; *pch; pch++) {
+ rb_ary_push(names, rb_str_new2(*pch));
+ }
+ }
}
- ary = rb_ary_new();
- rb_ary_push(ary, rb_tainted_str_new2(h->h_name));
- names = rb_ary_new();
- rb_ary_push(ary, names);
- for (pch = h->h_aliases; *pch; pch++) {
- rb_ary_push(names, rb_tainted_str_new2(*pch));
+ else {
+ names = rb_ary_new2(0);
}
- rb_ary_push(ary, INT2NUM(h->h_addrtype));
-#ifdef h_addr
- for (pch = h->h_addr_list; *pch; pch++) {
- switch (addr.ss_family) {
- case AF_INET:
- {
- struct sockaddr_in sin;
- MEMZERO(&sin, struct sockaddr_in, 1);
- sin.sin_family = AF_INET;
- SET_SIN_LEN(&sin, sizeof(sin));
- memcpy((char *) &sin.sin_addr, *pch, h->h_length);
- h = gethostbyaddr((char *)&sin.sin_addr,
- sizeof(sin.sin_addr),
- sin.sin_family);
- rb_ary_push(ary, mkipaddr((struct sockaddr *)&sin));
- break;
- }
-#ifdef INET6
- case AF_INET6:
- {
- struct sockaddr_in6 sin6;
- MEMZERO(&sin6, struct sockaddr_in6, 1);
- sin6.sin6_family = AF_INET;
-#ifdef SIN6_LEN
- sin6.sin6_len = sizeof(sin6);
-#endif
- memcpy((char *) &sin6.sin6_addr, *pch, h->h_length);
- h = gethostbyaddr((char *)&sin6.sin6_addr,
- sizeof(sin6.sin6_addr),
- sin6.sin6_family);
- rb_ary_push(ary, mkipaddr((struct sockaddr *)&sin6));
- break;
- }
-#endif
- default:
- h = NULL;
- }
+ rb_ary_push(ary, names);
+ rb_ary_push(ary, INT2NUM(addr->ai_family));
+ for (ai = addr; ai; ai = ai->ai_next) {
+ rb_ary_push(ary, (*ipaddr)(ai->ai_addr, ai->ai_addrlen));
}
-#else
- memcpy((char *)&addr.sin_addr, h->h_addr, h->h_length);
- rb_ary_push(ary, mkipaddr((struct sockaddr *)&addr));
-#endif
return ary;
}
static VALUE
-tcp_svr_s_open(argc, argv, class)
+make_hostent(host, addr, ipaddr)
+ VALUE host;
+ struct addrinfo* addr;
+ VALUE (*ipaddr)_((struct sockaddr*, size_t));
+{
+ struct hostent_arg arg;
+
+ arg.host = host;
+ arg.addr = addr;
+ arg.ipaddr = ipaddr;
+ return rb_ensure(make_hostent_internal, (VALUE)&arg,
+ RUBY_METHOD_FUNC(freeaddrinfo), (VALUE)addr);
+}
+
+VALUE
+tcp_sockaddr(addr, len)
+ struct sockaddr *addr;
+ size_t len;
+{
+ return make_ipaddr(addr);
+}
+
+static VALUE
+tcp_s_gethostbyname(obj, host)
+ VALUE obj, host;
+{
+ rb_secure(3);
+ return make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), tcp_sockaddr);
+}
+
+static VALUE
+tcp_svr_init(argc, argv, sock)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE sock;
{
VALUE arg1, arg2;
if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2)
- return open_inet(class, arg1, arg2, INET_SERVER);
+ return init_inetsock(sock, arg1, arg2, Qnil, Qnil, INET_SERVER);
else
- return open_inet(class, 0, arg1, INET_SERVER);
+ return init_inetsock(sock, Qnil, arg1, Qnil, Qnil, INET_SERVER);
}
static VALUE
-s_accept(class, fd, sockaddr, len)
- VALUE class;
+s_accept(klass, fd, sockaddr, len)
+ VALUE klass;
int fd;
struct sockaddr *sockaddr;
socklen_t *len;
@@ -1049,9 +1156,13 @@ s_accept(class, fd, sockaddr, len)
rb_secure(3);
retry:
rb_thread_wait_fd(fd);
+#if defined(_nec_ews)
+ fd2 = accept(fd, sockaddr, len);
+#else
TRAP_BEG;
fd2 = accept(fd, sockaddr, len);
TRAP_END;
+#endif
if (fd2 < 0) {
switch (errno) {
case EMFILE:
@@ -1060,20 +1171,17 @@ s_accept(class, fd, sockaddr, len)
rb_gc();
retry = 1;
goto retry;
- case EINTR:
- rb_thread_schedule();
- goto retry;
-
case EWOULDBLOCK:
-#if EAGAIN != EWOULDBLOCK
- case EAGAIN:
-#endif
- rb_thread_wait_fd(fd);
+ break;
+ default:
+ if (!rb_io_wait_readable(fd)) break;
+ retry = 0;
goto retry;
}
rb_sys_fail(0);
}
- return sock_new(class, fd2);
+ if (!klass) return INT2NUM(fd2);
+ return init_sock(rb_obj_alloc(klass), fd2);
}
static VALUE
@@ -1090,19 +1198,44 @@ tcp_accept(sock)
(struct sockaddr*)&from, &fromlen);
}
+static VALUE
+tcp_sysaccept(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_storage from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = sizeof(from);
+ return s_accept(0, fileno(fptr->f), (struct sockaddr*)&from, &fromlen);
+}
+
#ifdef HAVE_SYS_UN_H
+struct unixsock_arg {
+ struct sockaddr_un *sockaddr;
+ int fd;
+};
+
+static VALUE
+unixsock_connect_internal(arg)
+ struct unixsock_arg *arg;
+{
+ return (VALUE)ruby_connect(arg->fd, arg->sockaddr, sizeof(*arg->sockaddr),
+ 0);
+}
+
static VALUE
-open_unix(class, path, server)
- VALUE class;
- struct RString *path;
+init_unixsock(sock, path, server)
+ VALUE sock;
+ VALUE path;
int server;
{
struct sockaddr_un sockaddr;
int fd, status;
- VALUE sock;
OpenFile *fptr;
- Check_SafeStr(path);
+ SafeStringValue(path);
fd = ruby_socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
rb_sys_fail("socket(2)");
@@ -1110,30 +1243,34 @@ open_unix(class, path, server)
MEMZERO(&sockaddr, struct sockaddr_un, 1);
sockaddr.sun_family = AF_UNIX;
- strncpy(sockaddr.sun_path, path->ptr, sizeof(sockaddr.sun_path)-1);
+ strncpy(sockaddr.sun_path, RSTRING(path)->ptr, sizeof(sockaddr.sun_path)-1);
sockaddr.sun_path[sizeof(sockaddr.sun_path)-1] = '\0';
if (server) {
status = bind(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr));
}
else {
- status = ruby_connect(fd, (struct sockaddr*)&sockaddr, sizeof(sockaddr), 0);
+ int prot;
+ struct unixsock_arg arg;
+ arg.sockaddr = &sockaddr;
+ arg.fd = fd;
+ status = rb_protect(unixsock_connect_internal, (VALUE)&arg, &prot);
+ if (prot) {
+ close(fd);
+ rb_jump_tag(prot);
+ }
}
if (status < 0) {
-#if defined(HAVE_CLOSESOCKET)
- closesocket(fd);
-#else
close(fd);
-#endif
rb_sys_fail(sockaddr.sun_path);
}
if (server) listen(fd, 5);
- sock = sock_new(class, fd);
+ init_sock(sock, fd);
GetOpenFile(sock, fptr);
- fptr->path = strdup(path->ptr);
+ fptr->path = strdup(RSTRING(path)->ptr);
return sock;
}
@@ -1151,7 +1288,7 @@ ip_addr(sock)
if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
- return ipaddr((struct sockaddr *)&addr);
+ return ipaddr((struct sockaddr*)&addr);
}
static VALUE
@@ -1166,7 +1303,7 @@ ip_peeraddr(sock)
if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getpeername(2)");
- return ipaddr((struct sockaddr *)&addr);
+ return ipaddr((struct sockaddr*)&addr);
}
static VALUE
@@ -1183,16 +1320,20 @@ ip_s_getaddress(obj, host)
VALUE obj, host;
{
struct sockaddr_storage addr;
+ struct addrinfo *res = sock_addrinfo(host, Qnil, SOCK_STREAM, 0);
- setipaddr(host, &addr);
- return mkipaddr((struct sockaddr *)&addr);
+ /* just take the first one */
+ memcpy(&addr, res->ai_addr, res->ai_addrlen);
+ freeaddrinfo(res);
+
+ return make_ipaddr((struct sockaddr*)&addr);
}
static VALUE
-udp_s_open(argc, argv, class)
+udp_init(argc, argv, sock)
int argc;
VALUE *argv;
- VALUE class;
+ VALUE sock;
{
VALUE arg;
int socktype = AF_INET;
@@ -1207,7 +1348,28 @@ udp_s_open(argc, argv, class)
rb_sys_fail("socket(2) - udp");
}
- return sock_new(class, fd);
+ return init_sock(sock, fd);
+}
+
+struct udp_arg
+{
+ struct addrinfo *res;
+ int fd;
+};
+
+static VALUE
+udp_connect_internal(arg)
+ struct udp_arg *arg;
+{
+ int fd = arg->fd;
+ struct addrinfo *res;
+
+ for (res = arg->res; res; res = res->ai_next) {
+ if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
+ return Qtrue;
+ }
+ }
+ return Qfalse;
}
static VALUE
@@ -1215,22 +1377,16 @@ udp_connect(sock, host, port)
VALUE sock, host, port;
{
OpenFile *fptr;
- int fd;
- struct addrinfo *res0, *res;
+ struct udp_arg arg;
+ VALUE ret;
rb_secure(3);
GetOpenFile(sock, fptr);
- fd = fileno(fptr->f);
- res0 = ip_addrsetup(host, port);
- for (res = res0; res; res = res->ai_next) {
- if (ruby_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
- freeaddrinfo(res0);
- return INT2FIX(0);
- }
- }
-
- freeaddrinfo(res0);
- rb_sys_fail("connect(2)");
+ arg.res = sock_addrinfo(host, port, SOCK_DGRAM, 0);
+ arg.fd = fileno(fptr->f);
+ ret = rb_ensure(udp_connect_internal, (VALUE)&arg,
+ RUBY_METHOD_FUNC(freeaddrinfo), (VALUE)arg.res);
+ if (!ret) rb_sys_fail("connect(2)");
return INT2FIX(0);
}
@@ -1243,7 +1399,7 @@ udp_bind(sock, host, port)
rb_secure(3);
GetOpenFile(sock, fptr);
- res0 = ip_addrsetup(host, port);
+ res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0);
for (res = res0; res; res = res->ai_next) {
if (bind(fileno(fptr->f), res->ai_addr, res->ai_addrlen) < 0) {
continue;
@@ -1266,8 +1422,6 @@ udp_send(argc, argv, sock)
OpenFile *fptr;
FILE *f;
int n;
- char *m;
- int mlen;
struct addrinfo *res0, *res;
if (argc == 2 || argc == 3) {
@@ -1277,27 +1431,18 @@ udp_send(argc, argv, sock)
rb_scan_args(argc, argv, "4", &mesg, &flags, &host, &port);
GetOpenFile(sock, fptr);
- res0 = ip_addrsetup(host, port);
+ res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0);
f = GetWriteFile(fptr);
- m = rb_str2cstr(mesg, &mlen);
+ StringValue(mesg);
for (res = res0; res; res = res->ai_next) {
retry:
- n = sendto(fileno(f), m, mlen, NUM2INT(flags), res->ai_addr,
- res->ai_addrlen);
+ n = sendto(fileno(f), RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags),
+ res->ai_addr, res->ai_addrlen);
if (n >= 0) {
freeaddrinfo(res0);
return INT2FIX(n);
}
- switch (errno) {
- case EINTR:
- rb_thread_schedule();
- goto retry;
-
- case EWOULDBLOCK:
-#if EAGAIN != EWOULDBLOCK
- case EAGAIN:
-#endif
- rb_thread_fd_writable(fileno(f));
+ if (rb_io_wait_writable(fileno(f))) {
goto retry;
}
}
@@ -1308,10 +1453,10 @@ udp_send(argc, argv, sock)
#ifdef HAVE_SYS_UN_H
static VALUE
-unix_s_sock_open(sock, path)
+unix_init(sock, path)
VALUE sock, path;
{
- return open_unix(sock, path, 0);
+ return init_unixsock(sock, path, 0);
}
static VALUE
@@ -1328,14 +1473,14 @@ unix_path(sock)
rb_sys_fail(0);
fptr->path = strdup(addr.sun_path);
}
- return rb_tainted_str_new2(fptr->path);
+ return rb_str_new2(fptr->path);
}
static VALUE
-unix_svr_s_open(sock, path)
+unix_svr_init(sock, path)
VALUE sock, path;
{
- return open_unix(sock, path, 1);
+ return init_unixsock(sock, path, 1);
}
static VALUE
@@ -1347,6 +1492,188 @@ unix_recvfrom(argc, argv, sock)
return s_recvfrom(sock, argc, argv, RECV_UNIX);
}
+#if defined(HAVE_ST_MSG_CONTROL) && defined(SCM_RIGHTS)
+#define FD_PASSING_BY_MSG_CONTROL 1
+#else
+#define FD_PASSING_BY_MSG_CONTROL 0
+#endif
+
+#if defined(HAVE_ST_MSG_ACCRIGHTS)
+#define FD_PASSING_BY_MSG_ACCRIGHTS 1
+#else
+#define FD_PASSING_BY_MSG_ACCRIGHTS 0
+#endif
+
+static VALUE
+unix_send_io(sock, val)
+ VALUE sock, val;
+{
+#if defined(HAVE_SENDMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
+ int fd;
+ OpenFile *fptr;
+ struct msghdr msg;
+ struct iovec vec[1];
+ char buf[1];
+
+#if FD_PASSING_BY_MSG_CONTROL
+ struct {
+ struct cmsghdr hdr;
+ int fd;
+ } cmsg;
+#endif
+
+ if (rb_obj_is_kind_of(val, rb_cIO)) {
+ OpenFile *valfptr;
+ GetOpenFile(val, valfptr);
+ fd = fileno(valfptr->f);
+ }
+ else if (FIXNUM_P(val)) {
+ fd = FIX2INT(val);
+ }
+ else {
+ rb_raise(rb_eTypeError, "IO nor file descriptor");
+ }
+
+ GetOpenFile(sock, fptr);
+
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
+
+ /* Linux and Solaris doesn't work if msg_iov is NULL. */
+ buf[0] = '\0';
+ vec[0].iov_base = buf;
+ vec[0].iov_len = 1;
+ msg.msg_iov = vec;
+ msg.msg_iovlen = 1;
+
+#if FD_PASSING_BY_MSG_CONTROL
+ msg.msg_control = (caddr_t)&cmsg;
+ msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int);
+ msg.msg_flags = 0;
+ cmsg.hdr.cmsg_len = sizeof(struct cmsghdr) + sizeof(int);
+ cmsg.hdr.cmsg_level = SOL_SOCKET;
+ cmsg.hdr.cmsg_type = SCM_RIGHTS;
+ cmsg.fd = fd;
+#else
+ msg.msg_accrights = (caddr_t)&fd;
+ msg.msg_accrightslen = sizeof(fd);
+#endif
+
+ if (sendmsg(fileno(fptr->f), &msg, 0) == -1)
+ rb_sys_fail("sendmsg(2)");
+
+ return Qnil;
+#else
+ rb_notimplement();
+ return Qnil; /* not reached */
+#endif
+}
+
+#if defined(HAVE_RECVMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
+static void
+thread_read_select(fd)
+ int fd;
+{
+ fd_set fds;
+
+ FD_ZERO(&fds);
+ FD_SET(fd, &fds);
+ rb_thread_select(fd+1, &fds, 0, 0, 0);
+}
+#endif
+
+static VALUE
+unix_recv_io(argc, argv, sock)
+ int argc;
+ VALUE *argv;
+ VALUE sock;
+{
+#if defined(HAVE_RECVMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
+ VALUE klass, mode;
+ OpenFile *fptr;
+ struct msghdr msg;
+ struct iovec vec[2];
+ char buf[1];
+
+ int fd;
+#if FD_PASSING_BY_MSG_CONTROL
+ struct {
+ struct cmsghdr hdr;
+ int fd;
+ } cmsg;
+#endif
+
+ rb_scan_args(argc, argv, "02", &klass, &mode);
+ if (argc == 0)
+ klass = rb_cIO;
+ if (argc <= 1)
+ mode = Qnil;
+
+ GetOpenFile(sock, fptr);
+
+ thread_read_select(fileno(fptr->f));
+
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
+
+ vec[0].iov_base = buf;
+ vec[0].iov_len = sizeof(buf);
+ msg.msg_iov = vec;
+ msg.msg_iovlen = 1;
+
+#if FD_PASSING_BY_MSG_CONTROL
+ msg.msg_control = (caddr_t)&cmsg;
+ msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int);
+ msg.msg_flags = 0;
+ cmsg.hdr.cmsg_len = sizeof(struct cmsghdr) + sizeof(int);
+ cmsg.hdr.cmsg_level = SOL_SOCKET;
+ cmsg.hdr.cmsg_type = SCM_RIGHTS;
+ cmsg.fd = -1;
+#else
+ msg.msg_accrights = (caddr_t)&fd;
+ msg.msg_accrightslen = sizeof(fd);
+ fd = -1;
+#endif
+
+ if (recvmsg(fileno(fptr->f), &msg, 0) == -1)
+ rb_sys_fail("recvmsg(2)");
+
+ if (
+#if FD_PASSING_BY_MSG_CONTROL
+ msg.msg_controllen != sizeof(struct cmsghdr) + sizeof(int) ||
+ cmsg.hdr.cmsg_len != sizeof(struct cmsghdr) + sizeof(int) ||
+ cmsg.hdr.cmsg_level != SOL_SOCKET ||
+ cmsg.hdr.cmsg_type != SCM_RIGHTS
+#else
+ msg.msg_accrightslen != sizeof(fd)
+#endif
+ ) {
+ rb_raise(rb_eSocket, "File descriptor was not passed");
+ }
+
+#if FD_PASSING_BY_MSG_CONTROL
+ fd = cmsg.fd;
+#endif
+
+ if (klass == Qnil)
+ return INT2FIX(fd);
+ else {
+ static ID for_fd = 0;
+ int ff_argc;
+ VALUE ff_argv[2];
+ if (!for_fd)
+ for_fd = rb_intern("for_fd");
+ ff_argc = mode == Qnil ? 1 : 2;
+ ff_argv[0] = INT2FIX(fd);
+ ff_argv[1] = mode;
+ return rb_funcall2(klass, for_fd, ff_argc, ff_argv);
+ }
+#else
+ rb_notimplement();
+ return Qnil; /* not reached */
+#endif
+}
+
static VALUE
unix_accept(sock)
VALUE sock;
@@ -1362,11 +1689,24 @@ unix_accept(sock)
}
static VALUE
+unix_sysaccept(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ struct sockaddr_un from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = sizeof(struct sockaddr_un);
+ return s_accept(0, fileno(fptr->f), (struct sockaddr*)&from, &fromlen);
+}
+
+static VALUE
unixaddr(sockaddr)
struct sockaddr_un *sockaddr;
{
return rb_assoc_new(rb_str_new2("AF_UNIX"),
- rb_tainted_str_new2(sockaddr->sun_path));
+ rb_str_new2(sockaddr->sun_path));
}
static VALUE
@@ -1381,6 +1721,8 @@ unix_addr(sock)
if (getsockname(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
+ if (len == 0)
+ addr.sun_path[0] = '\0';
return unixaddr(&addr);
}
@@ -1396,6 +1738,8 @@ unix_peeraddr(sock)
if (getpeername(fileno(fptr->f), (struct sockaddr*)&addr, &len) < 0)
rb_sys_fail("getsockname(2)");
+ if (len == 0)
+ addr.sun_path[0] = '\0';
return unixaddr(&addr);
}
#endif
@@ -1405,10 +1749,13 @@ setup_domain_and_type(domain, dv, type, tv)
VALUE domain, type;
int *dv, *tv;
{
+ VALUE tmp;
char *ptr;
- if (TYPE(domain) == T_STRING) {
- Check_SafeStr(domain);
+ tmp = rb_check_string_type(domain);
+ if (!NIL_P(tmp)) {
+ domain = tmp;
+ rb_check_safe_obj(domain);
ptr = RSTRING(domain)->ptr;
if (strcmp(ptr, "AF_INET") == 0)
*dv = AF_INET;
@@ -1456,8 +1803,10 @@ setup_domain_and_type(domain, dv, type, tv)
else {
*dv = NUM2INT(domain);
}
- if (TYPE(type) == T_STRING) {
- Check_SafeStr(type);
+ tmp = rb_check_string_type(type);
+ if (!NIL_P(tmp)) {
+ type = tmp;
+ rb_check_safe_obj(type);
ptr = RSTRING(type)->ptr;
if (strcmp(ptr, "SOCK_STREAM") == 0)
*tv = SOCK_STREAM;
@@ -1488,8 +1837,8 @@ setup_domain_and_type(domain, dv, type, tv)
}
static VALUE
-sock_s_open(class, domain, type, protocol)
- VALUE class, domain, type, protocol;
+sock_initialize(sock, domain, type, protocol)
+ VALUE sock, domain, type, protocol;
{
int fd;
int d, t;
@@ -1499,21 +1848,14 @@ sock_s_open(class, domain, type, protocol)
fd = ruby_socket(d, t, NUM2INT(protocol));
if (fd < 0) rb_sys_fail("socket(2)");
- return sock_new(class, fd);
-}
-
-static VALUE
-sock_s_for_fd(class, fd)
- VALUE class, fd;
-{
- return sock_new(class, NUM2INT(fd));
+ return init_sock(sock, fd);
}
static VALUE
-sock_s_socketpair(class, domain, type, protocol)
- VALUE class, domain, type, protocol;
+sock_s_socketpair(klass, domain, type, protocol)
+ VALUE klass, domain, type, protocol;
{
-#if !defined(NT) && !defined(__BEOS__) && !defined(__EMX__)
+#if !defined(_WIN32) && !defined(__BEOS__) && !defined(__EMX__) && !defined(__QNXNTO__)
int d, t, sp[2];
setup_domain_and_type(domain, &d, type, &t);
@@ -1526,12 +1868,33 @@ sock_s_socketpair(class, domain, type, protocol)
rb_sys_fail("socketpair(2)");
}
- return rb_assoc_new(sock_new(class, sp[0]), sock_new(class, sp[1]));
+ return rb_assoc_new(init_sock(rb_obj_alloc(klass), sp[0]),
+ init_sock(rb_obj_alloc(klass), sp[1]));
#else
rb_notimplement();
#endif
}
+#ifdef HAVE_SYS_UN_H
+static VALUE
+unix_s_socketpair(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE domain, type, protocol;
+ domain = INT2FIX(PF_UNIX);
+
+ rb_scan_args(argc, argv, "02", &type, &protocol);
+ if (argc == 0)
+ type = INT2FIX(SOCK_STREAM);
+ if (argc <= 1)
+ protocol = INT2FIX(0);
+
+ return sock_s_socketpair(klass, domain, type, protocol);
+}
+#endif
+
static VALUE
sock_connect(sock, addr)
VALUE sock, addr;
@@ -1539,7 +1902,7 @@ sock_connect(sock, addr)
OpenFile *fptr;
int fd;
- Check_Type(addr, T_STRING);
+ StringValue(addr);
rb_str_modify(addr);
GetOpenFile(sock, fptr);
@@ -1557,7 +1920,7 @@ sock_bind(sock, addr)
{
OpenFile *fptr;
- Check_Type(addr, T_STRING);
+ StringValue(addr);
rb_str_modify(addr);
GetOpenFile(sock, fptr);
@@ -1569,7 +1932,7 @@ sock_bind(sock, addr)
static VALUE
sock_listen(sock, log)
- VALUE sock, log;
+ VALUE sock, log;
{
OpenFile *fptr;
@@ -1592,7 +1955,7 @@ sock_recvfrom(argc, argv, sock)
static VALUE
sock_accept(sock)
- VALUE sock;
+ VALUE sock;
{
OpenFile *fptr;
VALUE sock2;
@@ -1602,7 +1965,22 @@ sock_accept(sock)
GetOpenFile(sock, fptr);
sock2 = s_accept(rb_cSocket,fileno(fptr->f),(struct sockaddr*)buf,&len);
- return rb_assoc_new(sock2, rb_tainted_str_new(buf, len));
+ return rb_assoc_new(sock2, rb_str_new(buf, len));
+}
+
+static VALUE
+sock_sysaccept(sock)
+ VALUE sock;
+{
+ OpenFile *fptr;
+ VALUE sock2;
+ char buf[1024];
+ socklen_t len = sizeof buf;
+
+ GetOpenFile(sock, fptr);
+ sock2 = s_accept(0,fileno(fptr->f),(struct sockaddr*)buf,&len);
+
+ return rb_assoc_new(sock2, rb_str_new(buf, len));
}
#ifdef HAVE_GETHOSTNAME
@@ -1617,7 +1995,7 @@ sock_gethostname(obj)
rb_sys_fail("gethostname");
buf[sizeof buf - 1] = '\0';
- return rb_tainted_str_new2(buf);
+ return rb_str_new2(buf);
}
#else
#ifdef HAVE_UNAME
@@ -1632,7 +2010,7 @@ sock_gethostname(obj)
rb_secure(3);
uname(&un);
- return rb_tainted_str_new2(un.nodename);
+ return rb_str_new2(un.nodename);
}
#else
static VALUE
@@ -1645,41 +2023,7 @@ sock_gethostname(obj)
#endif
static VALUE
-mkhostent(h)
- struct hostent *h;
-{
- char **pch;
- VALUE ary, names;
-
- if (h == NULL) {
-#ifdef HAVE_HSTRERROR
- extern int h_errno;
- rb_raise(rb_eSocket, "%s", (char *)hstrerror(h_errno));
-#else
- rb_raise(rb_eSocket, "host not found");
-#endif
- }
- ary = rb_ary_new();
- rb_ary_push(ary, rb_tainted_str_new2(h->h_name));
- names = rb_ary_new();
- rb_ary_push(ary, names);
- for (pch = h->h_aliases; *pch; pch++) {
- rb_ary_push(names, rb_tainted_str_new2(*pch));
- }
- rb_ary_push(ary, INT2NUM(h->h_addrtype));
-#ifdef h_addr
- for (pch = h->h_addr_list; *pch; pch++) {
- rb_ary_push(ary, rb_tainted_str_new(*pch, h->h_length));
- }
-#else
- rb_ary_push(ary, rb_tainted_str_new(h->h_addr, h->h_length));
-#endif
-
- return ary;
-}
-
-static VALUE
-mkaddrinfo(res0)
+make_addrinfo(res0)
struct addrinfo *res0;
{
VALUE base, ary;
@@ -1699,55 +2043,37 @@ mkaddrinfo(res0)
return base;
}
-/*
- * NOTE: using gethostbyname() against AF_INET6 is a bad idea, as it
- * does not initialize sin_flowinfo nor sin_scope_id properly.
- */
-static VALUE
-sock_s_gethostbyname(obj, host)
- VALUE obj, host;
+VALUE
+sock_sockaddr(addr, len)
+ struct sockaddr *addr;
+ size_t len;
{
- struct sockaddr_storage addr;
- struct hostent *h;
+ char *ptr;
- if (rb_obj_is_kind_of(host, rb_cInteger)) {
- long i = NUM2LONG(host);
- struct sockaddr_in *sin;
- sin = (struct sockaddr_in *)&addr;
- MEMZERO(sin, struct sockaddr_in, 1);
- sin->sin_family = AF_INET;
- SET_SIN_LEN(sin, sizeof(*sin));
- sin->sin_addr.s_addr = htonl(i);
- }
- else {
- setipaddr(host, (struct sockaddr *)&addr);
- }
- switch (addr.ss_family) {
- case AF_INET:
- {
- struct sockaddr_in *sin;
- sin = (struct sockaddr_in *)&addr;
- h = gethostbyaddr((char *)&sin->sin_addr,
- sizeof(sin->sin_addr),
- sin->sin_family);
+ switch (addr->sa_family) {
+ case AF_INET:
+ ptr = (char*)&((struct sockaddr_in*)addr)->sin_addr.s_addr;
+ len = sizeof(((struct sockaddr_in*)addr)->sin_addr.s_addr);
break;
- }
#ifdef INET6
- case AF_INET6:
- {
- struct sockaddr_in6 *sin6;
- sin6 = (struct sockaddr_in6 *)&addr;
- h = gethostbyaddr((char *)&sin6->sin6_addr,
- sizeof(sin6->sin6_addr),
- sin6->sin6_family);
+ case AF_INET6:
+ ptr = (char*)&((struct sockaddr_in6*)addr)->sin6_addr.s6_addr;
+ len = sizeof(((struct sockaddr_in6*)addr)->sin6_addr.s6_addr);
break;
- }
#endif
- default:
- h = NULL;
+ default:
+ rb_raise(rb_eSocket, "unknown socket family:%d", addr->sa_family);
+ break;
}
+ return rb_str_new(ptr, len);
+}
- return mkhostent(h);
+static VALUE
+sock_s_gethostbyname(obj, host)
+ VALUE obj, host;
+{
+ rb_secure(3);
+ return make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr);
}
static VALUE
@@ -1755,24 +2081,51 @@ sock_s_gethostbyaddr(argc, argv)
int argc;
VALUE *argv;
{
- VALUE vaddr, vtype;
- int type;
- int alen;
- char *addr;
+ VALUE addr, type;
struct hostent *h;
+ struct sockaddr *sa;
+ char **pch;
+ VALUE ary, names;
+ int t = AF_INET;
- rb_scan_args(argc, argv, "11", &vaddr, &vtype);
- addr = rb_str2cstr(vaddr, &alen);
- if (!NIL_P(vtype)) {
- type = NUM2INT(vtype);
+ rb_scan_args(argc, argv, "11", &addr, &type);
+ sa = (struct sockaddr*)StringValuePtr(addr);
+ if (!NIL_P(type)) {
+ t = NUM2INT(type);
}
- else {
- type = AF_INET;
+#ifdef INET6
+ else if (RSTRING(addr)->len == 16) {
+ t = AF_INET6;
}
+#endif
+ h = gethostbyaddr(RSTRING(addr)->ptr, RSTRING(addr)->len, t);
+ if (h == NULL) {
+#ifdef HAVE_HSTRERROR
+ extern int h_errno;
+ rb_raise(rb_eSocket, "%s", (char*)hstrerror(h_errno));
+#else
+ rb_raise(rb_eSocket, "host not found");
+#endif
+ }
+ ary = rb_ary_new();
+ rb_ary_push(ary, rb_str_new2(h->h_name));
+ names = rb_ary_new();
+ rb_ary_push(ary, names);
+ if (h->h_aliases != NULL) {
+ for (pch = h->h_aliases; *pch; pch++) {
+ rb_ary_push(names, rb_str_new2(*pch));
+ }
+ }
+ rb_ary_push(ary, INT2NUM(h->h_addrtype));
+#ifdef h_addr
+ for (pch = h->h_addr_list; *pch; pch++) {
+ rb_ary_push(ary, rb_str_new(*pch, h->h_length));
+ }
+#else
+ rb_ary_push(ary, rb_str_new(h->h_addr, h->h_length));
+#endif
- h = gethostbyaddr(addr, alen, type);
-
- return mkhostent(h);
+ return ary;
}
static VALUE
@@ -1780,29 +2133,28 @@ sock_s_getservbyaname(argc, argv)
int argc;
VALUE *argv;
{
- VALUE service, protocol;
- char *proto;
+ VALUE service, proto;
struct servent *sp;
int port;
- rb_scan_args(argc, argv, "11", &service, &protocol);
- if (NIL_P(protocol)) proto = "tcp";
- else proto = STR2CSTR(protocol);
+ rb_scan_args(argc, argv, "11", &service, &proto);
+ if (NIL_P(proto)) proto = rb_str_new2("tcp");
+ StringValue(service);
+ StringValue(proto);
- sp = getservbyname(STR2CSTR(service), proto);
+ sp = getservbyname(StringValueCStr(service), StringValueCStr(proto));
if (sp) {
port = ntohs(sp->s_port);
}
else {
- char *s = STR2CSTR(service);
+ char *s = RSTRING(service)->ptr;
char *end;
port = strtoul(s, &end, 0);
if (*end != '\0') {
- rb_raise(rb_eSocket, "no such servce %s/%s", s, proto);
+ rb_raise(rb_eSocket, "no such service %s/%s", s, RSTRING(proto)->ptr);
}
}
-
return INT2FIX(port);
}
@@ -1813,7 +2165,7 @@ sock_s_getaddrinfo(argc, argv)
{
VALUE host, port, family, socktype, protocol, flags, ret;
char hbuf[1024], pbuf[1024];
- char *hptr, *pptr;
+ char *hptr, *pptr, *ap;
struct addrinfo hints, *res;
int error;
@@ -1823,7 +2175,7 @@ sock_s_getaddrinfo(argc, argv)
hptr = NULL;
}
else {
- strncpy(hbuf, STR2CSTR(host), sizeof(hbuf));
+ strncpy(hbuf, StringValuePtr(host), sizeof(hbuf));
hbuf[sizeof(hbuf) - 1] = '\0';
hptr = hbuf;
}
@@ -1831,11 +2183,11 @@ sock_s_getaddrinfo(argc, argv)
pptr = NULL;
}
else if (FIXNUM_P(port)) {
- snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port));
+ snprintf(pbuf, sizeof(pbuf), "%ld", FIX2LONG(port));
pptr = pbuf;
}
else {
- strncpy(pbuf, STR2CSTR(port), sizeof(pbuf));
+ strncpy(pbuf, StringValuePtr(port), sizeof(pbuf));
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
@@ -1847,14 +2199,16 @@ sock_s_getaddrinfo(argc, argv)
else if (FIXNUM_P(family)) {
hints.ai_family = FIX2INT(family);
}
- else if (strcmp(STR2CSTR(family), "AF_INET") == 0) {
- hints.ai_family = PF_INET;
- }
+ else if ((ap = StringValuePtr(family)) != 0) {
+ if (strcmp(ap, "AF_INET") == 0) {
+ hints.ai_family = PF_INET;
+ }
#ifdef INET6
- else if (strcmp(STR2CSTR(family), "AF_INET6") == 0) {
- hints.ai_family = PF_INET6;
- }
+ else if (strcmp(ap, "AF_INET6") == 0) {
+ hints.ai_family = PF_INET6;
+ }
#endif
+ }
if (!NIL_P(socktype)) {
hints.ai_socktype = NUM2INT(socktype);
@@ -1870,7 +2224,7 @@ sock_s_getaddrinfo(argc, argv)
rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
}
- ret = mkaddrinfo(res);
+ ret = make_addrinfo(res);
freeaddrinfo(res);
return ret;
}
@@ -1880,7 +2234,7 @@ sock_s_getnameinfo(argc, argv)
int argc;
VALUE *argv;
{
- VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags;
+ VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags, tmp;
char *hptr, *pptr;
char hbuf[1024], pbuf[1024];
int fl;
@@ -1888,7 +2242,7 @@ sock_s_getnameinfo(argc, argv)
int error;
struct sockaddr_storage ss;
struct sockaddr *sap;
- char *ep;
+ char *ap;
sa = flags = Qnil;
rb_scan_args(argc, argv, "11", &sa, &flags);
@@ -1897,17 +2251,22 @@ sock_s_getnameinfo(argc, argv)
if (!NIL_P(flags)) {
fl = NUM2INT(flags);
}
- if (TYPE(sa) == T_STRING) {
+ tmp = rb_check_string_type(sa);
+ if (!NIL_P(tmp)) {
+ sa = tmp;
if (sizeof(ss) < RSTRING(sa)->len) {
rb_raise(rb_eTypeError, "sockaddr length too big");
}
memcpy(&ss, RSTRING(sa)->ptr, RSTRING(sa)->len);
- if (RSTRING(sa)->len != SA_LEN((struct sockaddr *)&ss)) {
+ if (RSTRING(sa)->len != SA_LEN((struct sockaddr*)&ss)) {
rb_raise(rb_eTypeError, "sockaddr size differs - should not happen");
}
- sap = (struct sockaddr *)&ss;
+ sap = (struct sockaddr*)&ss;
+ goto call_nameinfo;
}
- else if (TYPE(sa) == T_ARRAY) {
+ tmp = rb_check_array_type(sa);
+ if (!NIL_P(tmp)) {
+ sa = tmp;
MEMZERO(&hints, struct addrinfo, 1);
if (RARRAY(sa)->len == 3) {
af = RARRAY(sa)->ptr[0];
@@ -1930,7 +2289,7 @@ sock_s_getnameinfo(argc, argv)
}
}
else {
- rb_raise(rb_eArgError, "array size should be 3 or 4, %d given",
+ rb_raise(rb_eArgError, "array size should be 3 or 4, %ld given",
RARRAY(sa)->len);
}
/* host */
@@ -1938,7 +2297,7 @@ sock_s_getnameinfo(argc, argv)
hptr = NULL;
}
else {
- strncpy(hbuf, STR2CSTR(host), sizeof(hbuf));
+ strncpy(hbuf, StringValuePtr(host), sizeof(hbuf));
hbuf[sizeof(hbuf) - 1] = '\0';
hptr = hbuf;
}
@@ -1948,11 +2307,11 @@ sock_s_getnameinfo(argc, argv)
pptr = NULL;
}
else if (FIXNUM_P(port)) {
- snprintf(pbuf, sizeof(pbuf), "%ld", NUM2INT(port));
+ snprintf(pbuf, sizeof(pbuf), "%ld", NUM2LONG(port));
pptr = pbuf;
}
else {
- strncpy(pbuf, STR2CSTR(port), sizeof(pbuf));
+ strncpy(pbuf, StringValuePtr(port), sizeof(pbuf));
pbuf[sizeof(pbuf) - 1] = '\0';
pptr = pbuf;
}
@@ -1964,14 +2323,16 @@ sock_s_getnameinfo(argc, argv)
else if (FIXNUM_P(af)) {
hints.ai_family = FIX2INT(af);
}
- else if (strcmp(STR2CSTR(af), "AF_INET") == 0) {
- hints.ai_family = PF_INET;
- }
+ else if ((ap = StringValuePtr(af)) != 0) {
+ if (strcmp(ap, "AF_INET") == 0) {
+ hints.ai_family = PF_INET;
+ }
#ifdef INET6
- else if (strcmp(STR2CSTR(af), "AF_INET6") == 0) {
- hints.ai_family = PF_INET6;
- }
+ else if (strcmp(ap, "AF_INET6") == 0) {
+ hints.ai_family = PF_INET6;
+ }
#endif
+ }
error = getaddrinfo(hptr, pptr, &hints, &res);
if (error) goto error_exit_addr;
sap = res->ai_addr;
@@ -1980,6 +2341,7 @@ sock_s_getnameinfo(argc, argv)
rb_raise(rb_eTypeError, "expecting String or Array");
}
+ call_nameinfo:
error = getnameinfo(sap, SA_LEN(sap), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), fl);
if (error) goto error_exit_name;
@@ -1998,7 +2360,7 @@ sock_s_getnameinfo(argc, argv)
}
freeaddrinfo(res);
}
- return rb_assoc_new(rb_tainted_str_new2(hbuf), rb_tainted_str_new2(pbuf));
+ return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
error_exit_addr:
if (res) freeaddrinfo(res);
@@ -2009,6 +2371,69 @@ sock_s_getnameinfo(argc, argv)
rb_raise(rb_eSocket, "getnameinfo: %s", gai_strerror(error));
}
+static VALUE
+sock_s_pack_sockaddr_in(self, port, host)
+ VALUE self, port, host;
+{
+ struct addrinfo *res = sock_addrinfo(host, port, 0, 0);
+ VALUE addr = rb_str_new((char*)res->ai_addr, res->ai_addrlen);
+
+ freeaddrinfo(res);
+ OBJ_INFECT(addr, port);
+ OBJ_INFECT(addr, host);
+
+ return addr;
+}
+
+static VALUE
+sock_s_unpack_sockaddr_in(self, addr)
+ VALUE self, addr;
+{
+ struct sockaddr_in * sockaddr;
+ VALUE host;
+
+ sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
+ host = make_ipaddr((struct sockaddr*)sockaddr);
+ OBJ_INFECT(host, addr);
+ return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host);
+}
+
+#ifdef HAVE_SYS_UN_H
+static VALUE
+sock_s_pack_sockaddr_un(self, path)
+ VALUE self, path;
+{
+ struct sockaddr_un sockaddr;
+ VALUE addr;
+
+ MEMZERO(&sockaddr, struct sockaddr_un, 1);
+ sockaddr.sun_family = AF_UNIX;
+ strncpy(sockaddr.sun_path, StringValuePtr(path), sizeof(sockaddr.sun_path)-1);
+ addr = rb_str_new((char*)&sockaddr, sizeof(sockaddr));
+ OBJ_INFECT(addr, path);
+
+ return addr;
+}
+
+static VALUE
+sock_s_unpack_sockaddr_un(self, addr)
+ VALUE self, addr;
+{
+ struct sockaddr_un * sockaddr;
+ VALUE path;
+
+ sockaddr = (struct sockaddr_un*)StringValuePtr(addr);
+ if (RSTRING(addr)->len != sizeof(struct sockaddr_un)) {
+ rb_raise(rb_eTypeError, "sockaddr_un size differs - %ld required; %d given",
+ RSTRING(addr)->len, sizeof(struct sockaddr_un));
+ }
+ /* xxx: should I check against sun_path size? */
+ path = rb_str_new2(sockaddr->sun_path);
+ OBJ_INFECT(path, addr);
+ return path;
+}
+#endif
+
static VALUE mConst;
static void
@@ -2026,13 +2451,13 @@ Init_socket()
rb_eSocket = rb_define_class("SocketError", rb_eStandardError);
rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO);
- rb_undef_method(CLASS_OF(rb_cBasicSocket), "new");
- rb_undef_method(CLASS_OF(rb_cBasicSocket), "open");
+ rb_undef_method(rb_cBasicSocket, "initialize");
rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup",
bsock_do_not_rev_lookup, 0);
rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup=",
bsock_do_not_rev_lookup_set, 1);
+ rb_define_singleton_method(rb_cBasicSocket, "for_fd", bsock_s_for_fd, 1);
rb_define_method(rb_cBasicSocket, "close_read", bsock_close_read, 0);
rb_define_method(rb_cBasicSocket, "close_write", bsock_close_write, 0);
@@ -2053,15 +2478,13 @@ Init_socket()
rb_cTCPSocket = rb_define_class("TCPSocket", rb_cIPSocket);
rb_define_global_const("TCPsocket", rb_cTCPSocket);
- rb_define_singleton_method(rb_cTCPSocket, "open", tcp_s_open, 2);
- rb_define_singleton_method(rb_cTCPSocket, "new", tcp_s_open, 2);
rb_define_singleton_method(rb_cTCPSocket, "gethostbyname", tcp_s_gethostbyname, 1);
+ rb_define_method(rb_cTCPSocket, "initialize", tcp_init, -1);
#ifdef SOCKS
rb_cSOCKSSocket = rb_define_class("SOCKSSocket", rb_cTCPSocket);
rb_define_global_const("SOCKSsocket", rb_cSOCKSSocket);
- rb_define_singleton_method(rb_cSOCKSSocket, "open", socks_s_open, 2);
- rb_define_singleton_method(rb_cSOCKSSocket, "new", socks_s_open, 2);
+ rb_define_method(rb_cSOCKSSocket, "initialize", socks_init, 2);
#ifdef SOCKS5
rb_define_method(rb_cSOCKSSocket, "close", socks_s_close, 0);
#endif
@@ -2069,14 +2492,14 @@ Init_socket()
rb_cTCPServer = rb_define_class("TCPServer", rb_cTCPSocket);
rb_define_global_const("TCPserver", rb_cTCPServer);
- rb_define_singleton_method(rb_cTCPServer, "open", tcp_svr_s_open, -1);
- rb_define_singleton_method(rb_cTCPServer, "new", tcp_svr_s_open, -1);
rb_define_method(rb_cTCPServer, "accept", tcp_accept, 0);
+ rb_define_method(rb_cTCPServer, "sysaccept", tcp_sysaccept, 0);
+ rb_define_method(rb_cTCPServer, "initialize", tcp_svr_init, -1);
+ rb_define_method(rb_cTCPServer, "listen", sock_listen, 1);
rb_cUDPSocket = rb_define_class("UDPSocket", rb_cIPSocket);
rb_define_global_const("UDPsocket", rb_cUDPSocket);
- rb_define_singleton_method(rb_cUDPSocket, "open", udp_s_open, -1);
- rb_define_singleton_method(rb_cUDPSocket, "new", udp_s_open, -1);
+ rb_define_method(rb_cUDPSocket, "initialize", udp_init, -1);
rb_define_method(rb_cUDPSocket, "connect", udp_connect, 2);
rb_define_method(rb_cUDPSocket, "bind", udp_bind, 2);
rb_define_method(rb_cUDPSocket, "send", udp_send, -1);
@@ -2084,29 +2507,32 @@ Init_socket()
#ifdef HAVE_SYS_UN_H
rb_cUNIXSocket = rb_define_class("UNIXSocket", rb_cBasicSocket);
rb_define_global_const("UNIXsocket", rb_cUNIXSocket);
- rb_define_singleton_method(rb_cUNIXSocket, "open", unix_s_sock_open, 1);
- rb_define_singleton_method(rb_cUNIXSocket, "new", unix_s_sock_open, 1);
+ rb_define_method(rb_cUNIXSocket, "initialize", unix_init, 1);
rb_define_method(rb_cUNIXSocket, "path", unix_path, 0);
rb_define_method(rb_cUNIXSocket, "addr", unix_addr, 0);
rb_define_method(rb_cUNIXSocket, "peeraddr", unix_peeraddr, 0);
rb_define_method(rb_cUNIXSocket, "recvfrom", unix_recvfrom, -1);
+ rb_define_method(rb_cUNIXSocket, "send_io", unix_send_io, 1);
+ rb_define_method(rb_cUNIXSocket, "recv_io", unix_recv_io, -1);
+ rb_define_singleton_method(rb_cUNIXSocket, "socketpair", unix_s_socketpair, -1);
+ rb_define_singleton_method(rb_cUNIXSocket, "pair", unix_s_socketpair, -1);
rb_cUNIXServer = rb_define_class("UNIXServer", rb_cUNIXSocket);
rb_define_global_const("UNIXserver", rb_cUNIXServer);
- rb_define_singleton_method(rb_cUNIXServer, "open", unix_svr_s_open, 1);
- rb_define_singleton_method(rb_cUNIXServer, "new", unix_svr_s_open, 1);
+ rb_define_method(rb_cUNIXServer, "initialize", unix_svr_init, 1);
rb_define_method(rb_cUNIXServer, "accept", unix_accept, 0);
+ rb_define_method(rb_cUNIXServer, "sysaccept", unix_sysaccept, 0);
+ rb_define_method(rb_cUNIXServer, "listen", sock_listen, 1);
#endif
rb_cSocket = rb_define_class("Socket", rb_cBasicSocket);
- rb_define_singleton_method(rb_cSocket, "open", sock_s_open, 3);
- rb_define_singleton_method(rb_cSocket, "new", sock_s_open, 3);
- rb_define_singleton_method(rb_cSocket, "for_fd", sock_s_for_fd, 1);
+ rb_define_method(rb_cSocket, "initialize", sock_initialize, 3);
rb_define_method(rb_cSocket, "connect", sock_connect, 1);
rb_define_method(rb_cSocket, "bind", sock_bind, 1);
rb_define_method(rb_cSocket, "listen", sock_listen, 1);
rb_define_method(rb_cSocket, "accept", sock_accept, 0);
+ rb_define_method(rb_cSocket, "sysaccept", sock_sysaccept, 0);
rb_define_method(rb_cSocket, "recvfrom", sock_recvfrom, -1);
@@ -2118,6 +2544,14 @@ Init_socket()
rb_define_singleton_method(rb_cSocket, "getservbyname", sock_s_getservbyaname, -1);
rb_define_singleton_method(rb_cSocket, "getaddrinfo", sock_s_getaddrinfo, -1);
rb_define_singleton_method(rb_cSocket, "getnameinfo", sock_s_getnameinfo, -1);
+ rb_define_singleton_method(rb_cSocket, "sockaddr_in", sock_s_pack_sockaddr_in, 2);
+ rb_define_singleton_method(rb_cSocket, "pack_sockaddr_in", sock_s_pack_sockaddr_in, 2);
+ rb_define_singleton_method(rb_cSocket, "unpack_sockaddr_in", sock_s_unpack_sockaddr_in, 1);
+#ifdef HAVE_SYS_UN_H
+ rb_define_singleton_method(rb_cSocket, "sockaddr_un", sock_s_pack_sockaddr_un, 1);
+ rb_define_singleton_method(rb_cSocket, "pack_sockaddr_un", sock_s_pack_sockaddr_un, 1);
+ rb_define_singleton_method(rb_cSocket, "unpack_sockaddr_un", sock_s_unpack_sockaddr_un, 1);
+#endif
/* constants */
mConst = rb_define_module_under(rb_cSocket, "Constants");
@@ -2160,10 +2594,10 @@ Init_socket()
sock_define_const("AF_UNSPEC", AF_UNSPEC);
sock_define_const("PF_UNSPEC", PF_UNSPEC);
#endif
-#ifdef AF_INET6
+#ifdef INET6
sock_define_const("AF_INET6", AF_INET6);
#endif
-#ifdef PF_INET6
+#ifdef INET6
sock_define_const("PF_INET6", PF_INET6);
#endif
@@ -2195,6 +2629,165 @@ Init_socket()
sock_define_const("SOL_UDP", SOL_UDP);
#endif
+#ifdef IPPROTO_IP
+ sock_define_const("IPPROTO_IP", IPPROTO_IP);
+#else
+ sock_define_const("IPPROTO_IP", 0);
+#endif
+#ifdef IPPROTO_ICMP
+ sock_define_const("IPPROTO_ICMP", IPPROTO_ICMP);
+#else
+ sock_define_const("IPPROTO_ICMP", 1);
+#endif
+#ifdef IPPROTO_IGMP
+ sock_define_const("IPPROTO_IGMP", IPPROTO_IGMP);
+#endif
+#ifdef IPPROTO_GGP
+ sock_define_const("IPPROTO_GGP", IPPROTO_GGP);
+#endif
+#ifdef IPPROTO_TCP
+ sock_define_const("IPPROTO_TCP", IPPROTO_TCP);
+#else
+ sock_define_const("IPPROTO_TCP", 6);
+#endif
+#ifdef IPPROTO_EGP
+ sock_define_const("IPPROTO_EGP", IPPROTO_EGP);
+#endif
+#ifdef IPPROTO_PUP
+ sock_define_const("IPPROTO_PUP", IPPROTO_PUP);
+#endif
+#ifdef IPPROTO_UDP
+ sock_define_const("IPPROTO_UDP", IPPROTO_UDP);
+#else
+ sock_define_const("IPPROTO_UDP", 17);
+#endif
+#ifdef IPPROTO_IDP
+ sock_define_const("IPPROTO_IDP", IPPROTO_IDP);
+#endif
+#ifdef IPPROTO_HELLO
+ sock_define_const("IPPROTO_HELLO", IPPROTO_HELLO);
+#endif
+#ifdef IPPROTO_ND
+ sock_define_const("IPPROTO_ND", IPPROTO_ND);
+#endif
+#ifdef IPPROTO_TP
+ sock_define_const("IPPROTO_TP", IPPROTO_TP);
+#endif
+#ifdef IPPROTO_XTP
+ sock_define_const("IPPROTO_XTP", IPPROTO_XTP);
+#endif
+#ifdef IPPROTO_EON
+ sock_define_const("IPPROTO_EON", IPPROTO_EON);
+#endif
+#ifdef IPPROTO_BIP
+ sock_define_const("IPPROTO_BIP", IPPROTO_BIP);
+#endif
+/**/
+#ifdef IPPROTO_RAW
+ sock_define_const("IPPROTO_RAW", IPPROTO_RAW);
+#else
+ sock_define_const("IPPROTO_RAW", 255);
+#endif
+#ifdef IPPROTO_MAX
+ sock_define_const("IPPROTO_MAX", IPPROTO_MAX);
+#endif
+
+ /* Some port configuration */
+#ifdef IPPORT_RESERVED
+ sock_define_const("IPPORT_RESERVED", IPPORT_RESERVED);
+#else
+ sock_define_const("IPPORT_RESERVED", 1024);
+#endif
+#ifdef IPPORT_USERRESERVED
+ sock_define_const("IPPORT_USERRESERVED", IPPORT_USERRESERVED);
+#else
+ sock_define_const("IPPORT_USERRESERVED", 5000);
+#endif
+ /* Some reserved IP v.4 addresses */
+#ifdef INADDR_ANY
+ sock_define_const("INADDR_ANY", INADDR_ANY);
+#else
+ sock_define_const("INADDR_ANY", 0x00000000);
+#endif
+#ifdef INADDR_BROADCAST
+ sock_define_const("INADDR_BROADCAST", INADDR_BROADCAST);
+#else
+ sock_define_const("INADDR_BROADCAST", 0xffffffff);
+#endif
+#ifdef INADDR_LOOPBACK
+ sock_define_const("INADDR_LOOPBACK", INADDR_LOOPBACK);
+#else
+ sock_define_const("INADDR_LOOPBACK", 0x7F000001);
+#endif
+#ifdef INADDR_UNSPEC_GROUP
+ sock_define_const("INADDR_UNSPEC_GROUP", INADDR_UNSPEC_GROUP);
+#else
+ sock_define_const("INADDR_UNSPEC_GROUP", 0xe0000000);
+#endif
+#ifdef INADDR_ALLHOSTS_GROUP
+ sock_define_const("INADDR_ALLHOSTS_GROUP", INADDR_ALLHOSTS_GROUP);
+#else
+ sock_define_const("INADDR_ALLHOSTS_GROUP", 0xe0000001);
+#endif
+#ifdef INADDR_MAX_LOCAL_GROUP
+ sock_define_const("INADDR_MAX_LOCAL_GROUP", INADDR_MAX_LOCAL_GROUP);
+#else
+ sock_define_const("INADDR_MAX_LOCAL_GROUP", 0xe00000ff);
+#endif
+#ifdef INADDR_NONE
+ sock_define_const("INADDR_NONE", INADDR_NONE);
+#else
+ sock_define_const("INADDR_NONE", 0xffffffff);
+#endif
+ /* IP [gs]etsockopt options */
+#ifdef IP_OPTIONS
+ sock_define_const("IP_OPTIONS", IP_OPTIONS);
+#endif
+#ifdef IP_HDRINCL
+ sock_define_const("IP_HDRINCL", IP_HDRINCL);
+#endif
+#ifdef IP_TOS
+ sock_define_const("IP_TOS", IP_TOS);
+#endif
+#ifdef IP_TTL
+ sock_define_const("IP_TTL", IP_TTL);
+#endif
+#ifdef IP_RECVOPTS
+ sock_define_const("IP_RECVOPTS", IP_RECVOPTS);
+#endif
+#ifdef IP_RECVRETOPTS
+ sock_define_const("IP_RECVRETOPTS", IP_RECVRETOPTS);
+#endif
+#ifdef IP_RECVDSTADDR
+ sock_define_const("IP_RECVDSTADDR", IP_RECVDSTADDR);
+#endif
+#ifdef IP_RETOPTS
+ sock_define_const("IP_RETOPTS", IP_RETOPTS);
+#endif
+#ifdef IP_MULTICAST_IF
+ sock_define_const("IP_MULTICAST_IF", IP_MULTICAST_IF);
+#endif
+#ifdef IP_MULTICAST_TTL
+ sock_define_const("IP_MULTICAST_TTL", IP_MULTICAST_TTL);
+#endif
+#ifdef IP_MULTICAST_LOOP
+ sock_define_const("IP_MULTICAST_LOOP", IP_MULTICAST_LOOP);
+#endif
+#ifdef IP_ADD_MEMBERSHIP
+ sock_define_const("IP_ADD_MEMBERSHIP", IP_ADD_MEMBERSHIP);
+#endif
+#ifdef IP_DROP_MEMBERSHIP
+ sock_define_const("IP_DROP_MEMBERSHIP", IP_DROP_MEMBERSHIP);
+#endif
+#ifdef IP_DEFAULT_MULTICAST_TTL
+ sock_define_const("IP_DEFAULT_MULTICAST_TTL", IP_DEFAULT_MULTICAST_TTL);
+#endif
+#ifdef IP_DEFAULT_MULTICAST_LOOP
+ sock_define_const("IP_DEFAULT_MULTICAST_LOOP", IP_DEFAULT_MULTICAST_LOOP);
+#endif
+#ifdef IP_MAX_MEMBERSHIPS
+ sock_define_const("IP_MAX_MEMBERSHIPS", IP_MAX_MEMBERSHIPS);
+#endif
#ifdef SO_DEBUG
sock_define_const("SO_DEBUG", SO_DEBUG);
#endif
@@ -2232,38 +2825,59 @@ Init_socket()
#ifdef SO_LINGER
sock_define_const("SO_LINGER", SO_LINGER);
#endif
+#ifdef SO_PASSCRED
+ sock_define_const("SO_PASSCRED", SO_PASSCRED);
+#endif
+#ifdef SO_PEERCRED
+ sock_define_const("SO_PEERCRED", SO_PEERCRED);
+#endif
+#ifdef SO_RCVLOWAT
+ sock_define_const("SO_RCVLOWAT", SO_RCVLOWAT);
+#endif
+#ifdef SO_SNDLOWAT
+ sock_define_const("SO_SNDLOWAT", SO_SNDLOWAT);
+#endif
+#ifdef SO_RCVTIMEO
+ sock_define_const("SO_RCVTIMEO", SO_RCVTIMEO);
+#endif
+#ifdef SO_SNDTIMEO
+ sock_define_const("SO_SNDTIMEO", SO_SNDTIMEO);
+#endif
-#ifdef SOPRI_INTERACTIVE
- sock_define_const("SOPRI_INTERACTIVE", SOPRI_INTERACTIVE);
+#ifdef SO_SECURITY_AUTHENTICATION
+ sock_define_const("SO_SECURITY_AUTHENTICATION", SO_SECURITY_AUTHENTICATION);
#endif
-#ifdef SOPRI_NORMAL
- sock_define_const("SOPRI_NORMAL", SOPRI_NORMAL);
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ sock_define_const("SO_SECURITY_ENCRYPTION_TRANSPORT", SO_SECURITY_ENCRYPTION_TRANSPORT);
#endif
-#ifdef SOPRI_BACKGROUND
- sock_define_const("SOPRI_BACKGROUND", SOPRI_BACKGROUND);
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ sock_define_const("SO_SECURITY_ENCRYPTION_NETWORK", SO_SECURITY_ENCRYPTION_NETWORK);
#endif
-#ifdef IP_MULTICAST_IF
- sock_define_const("IP_MULTICAST_IF", IP_MULTICAST_IF);
+#ifdef SO_BINDTODEVICE
+ sock_define_const("SO_BINDTODEVICE", SO_BINDTODEVICE);
#endif
-#ifdef IP_MULTICAST_TTL
- sock_define_const("IP_MULTICAST_TTL", IP_MULTICAST_TTL);
+#ifdef SO_ATTACH_FILTER
+ sock_define_const("SO_ATTACH_FILTER", SO_ATTACH_FILTER);
#endif
-#ifdef IP_MULTICAST_LOOP
- sock_define_const("IP_MULTICAST_LOOP", IP_MULTICAST_LOOP);
+#ifdef SO_DETACH_FILTER
+ sock_define_const("SO_DETACH_FILTER", SO_DETACH_FILTER);
#endif
-#ifdef IP_ADD_MEMBERSHIP
- sock_define_const("IP_ADD_MEMBERSHIP", IP_ADD_MEMBERSHIP);
+#ifdef SO_PEERNAME
+ sock_define_const("SO_PEERNAME", SO_PEERNAME);
+#endif
+#ifdef SO_TIMESTAMP
+ sock_define_const("SO_TIMESTAMP", SO_TIMESTAMP);
#endif
-#ifdef IP_DEFAULT_MULTICAST_TTL
- sock_define_const("IP_DEFAULT_MULTICAST_TTL", IP_DEFAULT_MULTICAST_TTL);
+#ifdef SOPRI_INTERACTIVE
+ sock_define_const("SOPRI_INTERACTIVE", SOPRI_INTERACTIVE);
#endif
-#ifdef IP_DEFAULT_MULTICAST_LOOP
- sock_define_const("IP_DEFAULT_MULTICAST_LOOP", IP_DEFAULT_MULTICAST_LOOP);
+#ifdef SOPRI_NORMAL
+ sock_define_const("SOPRI_NORMAL", SOPRI_NORMAL);
#endif
-#ifdef IP_MAX_MEMBERSHIPS
- sock_define_const("IP_MAX_MEMBERSHIPS", IP_MAX_MEMBERSHIPS);
+#ifdef SOPRI_BACKGROUND
+ sock_define_const("SOPRI_BACKGROUND", SOPRI_BACKGROUND);
#endif
#ifdef IPX_TYPE
@@ -2367,4 +2981,19 @@ Init_socket()
#ifdef NI_DGRAM
sock_define_const("NI_DGRAM", NI_DGRAM);
#endif
+#ifdef SHUT_RD
+ sock_define_const("SHUT_RD", SHUT_RD);
+#else
+ sock_define_const("SHUT_RD", 0);
+#endif
+#ifdef SHUT_WR
+ sock_define_const("SHUT_WR", SHUT_WR);
+#else
+ sock_define_const("SHUT_WR", 1);
+#endif
+#ifdef SHUT_RDWR
+ sock_define_const("SHUT_RDWR", SHUT_RDWR);
+#else
+ sock_define_const("SHUT_RDWR", 2);
+#endif
}
diff --git a/ext/stringio/.cvsignore b/ext/stringio/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/stringio/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/stringio/README b/ext/stringio/README
new file mode 100644
index 0000000000..c4031f7e97
--- /dev/null
+++ b/ext/stringio/README
@@ -0,0 +1,19 @@
+-*- rd -*-
+$Author$
+$Date$
+
+=begin
+
+= StringIO
+Pseudo (({IO})) class from/to (({String})).
+
+This library is based on MoonWolf version written in Ruby. Thanks a lot.
+
+= Differences to (({IO}))
+
+* not implemented: (({fcntl})), (({reopen})).
+* (({fileno})) returns nil.
+* (({pos=})) returns new position, not 0.
+* (({ungetc})) does nothing at start of the string.
+
+=end
diff --git a/ext/stringio/depend b/ext/stringio/depend
new file mode 100644
index 0000000000..cc9eae3f55
--- /dev/null
+++ b/ext/stringio/depend
@@ -0,0 +1,2 @@
+stringio.o: stringio.c $(hdrdir)/ruby.h $(topdir)/config.h \
+ $(hdrdir)/defines.h $(hdrdir)/intern.h $(hdrdir)/rubyio.h
diff --git a/ext/stringio/extconf.rb b/ext/stringio/extconf.rb
new file mode 100644
index 0000000000..8fc84b3735
--- /dev/null
+++ b/ext/stringio/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('stringio')
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
new file mode 100644
index 0000000000..790e567608
--- /dev/null
+++ b/ext/stringio/stringio.c
@@ -0,0 +1,1017 @@
+/**********************************************************************
+
+ stringio.c -
+
+ $Author$
+ $Date$
+ $RoughId: stringio.c,v 1.13 2002/03/14 03:24:18 nobu Exp $
+ created at: Tue Feb 19 04:10:38 JST 2002
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "ruby.h"
+#include "rubyio.h"
+
+#define STRIO_EOF FMODE_SYNC
+
+struct StringIO {
+ VALUE string;
+ long pos;
+ long lineno;
+ int flags;
+ int count;
+};
+
+static struct StringIO* strio_alloc _((void));
+static void strio_mark _((struct StringIO *));
+static void strio_free _((struct StringIO *));
+static struct StringIO* check_strio _((VALUE));
+static struct StringIO* get_strio _((VALUE));
+static struct StringIO* readable _((struct StringIO *));
+static struct StringIO* writable _((struct StringIO *));
+static void check_modifiable _((struct StringIO *));
+
+#define IS_STRIO(obj) (RDATA(obj)->dmark == (RUBY_DATA_FUNC)strio_mark)
+#define error_inval(msg) (errno = EINVAL, rb_sys_fail(msg))
+
+static struct StringIO *
+strio_alloc()
+{
+ struct StringIO *ptr = ALLOC(struct StringIO);
+ ptr->string = Qnil;
+ ptr->pos = 0;
+ ptr->lineno = 0;
+ ptr->flags = 0;
+ ptr->count = 1;
+ return ptr;
+}
+
+static void
+strio_mark(ptr)
+ struct StringIO *ptr;
+{
+ if (ptr) {
+ rb_gc_mark(ptr->string);
+ }
+}
+
+static void
+strio_free(ptr)
+ struct StringIO *ptr;
+{
+ if (--ptr->count <= 0) {
+ xfree(ptr);
+ }
+}
+
+static struct StringIO*
+check_strio(self)
+ VALUE self;
+{
+ Check_Type(self, T_DATA);
+ if (!IS_STRIO(self)) {
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String::IO)",
+ rb_class2name(CLASS_OF(self)));
+ }
+ return DATA_PTR(self);
+}
+
+static struct StringIO*
+get_strio(self)
+ VALUE self;
+{
+ struct StringIO *ptr = check_strio(self);
+
+ if (!ptr) {
+ rb_raise(rb_eIOError, "uninitialized stream");
+ }
+ return ptr;
+}
+
+#define StringIO(obj) get_strio(obj)
+
+#define CLOSED(ptr) NIL_P((ptr)->string)
+#define READABLE(ptr) (!CLOSED(ptr) && ((ptr)->flags & FMODE_READABLE))
+#define WRITABLE(ptr) (!CLOSED(ptr) && ((ptr)->flags & FMODE_WRITABLE))
+
+static struct StringIO*
+readable(ptr)
+ struct StringIO *ptr;
+{
+ if (!READABLE(ptr)) {
+ rb_raise(rb_eIOError, "not opened for reading");
+ }
+ return ptr;
+}
+
+static struct StringIO*
+writable(ptr)
+ struct StringIO *ptr;
+{
+ if (!WRITABLE(ptr)) {
+ rb_raise(rb_eIOError, "not opened for writing");
+ }
+ if (!OBJ_TAINTED(ptr->string)) {
+ rb_secure(4);
+ }
+ return ptr;
+}
+
+static void
+check_modifiable(ptr)
+ struct StringIO *ptr;
+{
+ if (OBJ_FROZEN(ptr->string)) {
+ rb_raise(rb_eIOError, "not modifiable string");
+ }
+}
+
+static VALUE strio_s_allocate _((VALUE));
+static VALUE strio_s_open _((int, VALUE *, VALUE));
+static VALUE strio_initialize _((int, VALUE *, VALUE));
+static VALUE strio_finalize _((VALUE));
+static VALUE strio_self _((VALUE));
+static VALUE strio_false _((VALUE));
+static VALUE strio_nil _((VALUE));
+static VALUE strio_0 _((VALUE));
+static VALUE strio_first _((VALUE, VALUE));
+static VALUE strio_unimpl _((int, VALUE *, VALUE));
+static VALUE strio_get_string _((VALUE));
+static VALUE strio_set_string _((VALUE, VALUE));
+static VALUE strio_close _((VALUE));
+static VALUE strio_close_read _((VALUE));
+static VALUE strio_close_write _((VALUE));
+static VALUE strio_closed _((VALUE));
+static VALUE strio_closed_read _((VALUE));
+static VALUE strio_closed_write _((VALUE));
+static VALUE strio_eof _((VALUE));
+static VALUE strio_get_lineno _((VALUE));
+static VALUE strio_set_lineno _((VALUE, VALUE));
+static VALUE strio_get_pos _((VALUE));
+static VALUE strio_set_pos _((VALUE, VALUE));
+static VALUE strio_rewind _((VALUE));
+static VALUE strio_seek _((int, VALUE *, VALUE));
+static VALUE strio_get_sync _((VALUE));
+static VALUE strio_each_byte _((VALUE));
+static VALUE strio_getc _((VALUE));
+static VALUE strio_ungetc _((VALUE, VALUE));
+static VALUE strio_readchar _((VALUE));
+static VALUE strio_getline _((int, VALUE *, struct StringIO *));
+static VALUE strio_gets _((int, VALUE *, VALUE));
+static VALUE strio_readline _((int, VALUE *, VALUE));
+static VALUE strio_each _((int, VALUE *, VALUE));
+static VALUE strio_readlines _((int, VALUE *, VALUE));
+static VALUE strio_write _((VALUE, VALUE));
+static VALUE strio_putc _((VALUE, VALUE));
+static VALUE strio_read _((int, VALUE *, VALUE));
+static VALUE strio_size _((VALUE));
+static VALUE strio_truncate _((VALUE, VALUE));
+void Init_stringio _((void));
+
+/* Boyer-Moore search: copied from regex.c */
+static void bm_init_skip _((long *, const char *, long));
+static long bm_search _((const char *, long, const char *, long, const long *));
+
+static VALUE
+strio_s_allocate(klass)
+ VALUE klass;
+{
+ return Data_Wrap_Struct(klass, strio_mark, strio_free, 0);
+}
+
+static VALUE
+strio_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE obj = rb_class_new_instance(argc, argv, klass);
+ if (!rb_block_given_p()) return obj;
+ return rb_ensure(rb_yield, obj, strio_finalize, obj);
+}
+
+static VALUE
+strio_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct StringIO *ptr = check_strio(self);
+ VALUE string, mode;
+ const char* m;
+
+ if (!ptr) {
+ DATA_PTR(self) = ptr = strio_alloc();
+ }
+ rb_call_super(0, 0);
+ switch (rb_scan_args(argc, argv, "02", &string, &mode)) {
+ case 2:
+ StringValue(mode);
+ StringValue(string);
+ if (!(m = RSTRING(mode)->ptr)) m = "";
+ ptr->flags = rb_io_mode_flags(m);
+ if ((ptr->flags & FMODE_WRITABLE) && OBJ_FROZEN(string)) {
+ errno = EACCES;
+ rb_sys_fail(0);
+ }
+ switch (*m) {
+ case 'a':
+ ptr->flags |= FMODE_APPEND;
+ break;
+ case 'w':
+ rb_str_resize(string, 0);
+ break;
+ }
+ break;
+ case 1:
+ StringValue(string);
+ ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
+ break;
+ case 0:
+ string = rb_str_new("", 0);
+ ptr->flags = FMODE_READWRITE;
+ break;
+ }
+ ptr->string = string;
+ return self;
+}
+
+static VALUE
+strio_finalize(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ ptr->string = Qnil;
+ ptr->flags &= ~FMODE_READWRITE;
+ return self;
+}
+
+static VALUE
+strio_false(self)
+ VALUE self;
+{
+ StringIO(self);
+ return Qfalse;
+}
+
+static VALUE
+strio_nil(self)
+ VALUE self;
+{
+ StringIO(self);
+ return Qnil;
+}
+
+static VALUE
+strio_self(self)
+ VALUE self;
+{
+ StringIO(self);
+ return self;
+}
+
+static VALUE
+strio_0(self)
+ VALUE self;
+{
+ StringIO(self);
+ return INT2FIX(0);
+}
+
+static VALUE
+strio_first(self, arg)
+ VALUE self, arg;
+{
+ StringIO(self);
+ return arg;
+}
+
+static VALUE
+strio_unimpl(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ StringIO(self);
+ rb_notimplement();
+ return Qnil; /* not reached */
+}
+
+static VALUE
+strio_get_string(self)
+ VALUE self;
+{
+ return StringIO(self)->string;
+}
+
+static VALUE
+strio_set_string(self, string)
+ VALUE self, string;
+{
+ struct StringIO *ptr = StringIO(self);
+
+ if (!OBJ_TAINTED(self)) rb_secure(4);
+ ptr->flags &= ~FMODE_READWRITE;
+ if (!NIL_P(string)) {
+ StringValue(string);
+ ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
+ }
+ ptr->pos = 0;
+ ptr->lineno = 0;
+ return ptr->string = string;
+}
+
+static VALUE
+strio_close(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ if (CLOSED(ptr)) {
+ rb_raise(rb_eIOError, "closed stream");
+ }
+ ptr->string = Qnil;
+ ptr->flags &= ~FMODE_READWRITE;
+ return self;
+}
+
+static VALUE
+strio_close_read(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ if (!READABLE(ptr)) {
+ rb_raise(rb_eIOError, "closing non-duplex IO for reading");
+ }
+ if (!((ptr->flags &= ~FMODE_READABLE) & FMODE_READWRITE)) {
+ ptr->string = Qnil;
+ }
+ return self;
+}
+
+static VALUE
+strio_close_write(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ if (!WRITABLE(ptr)) {
+ rb_raise(rb_eIOError, "closing non-duplex IO for writing");
+ }
+ if (!((ptr->flags &= ~FMODE_WRITABLE) & FMODE_READWRITE)) {
+ ptr->string = Qnil;
+ }
+ return self;
+}
+
+static VALUE
+strio_closed(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ if (!CLOSED(ptr)) return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+strio_closed_read(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ if (READABLE(ptr)) return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+strio_closed_write(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ if (WRITABLE(ptr)) return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+strio_eof(self)
+ VALUE self;
+{
+ struct StringIO *ptr = readable(StringIO(self));
+ if (ptr->pos < RSTRING(ptr->string)->len) return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+strio_copy(copy, orig)
+ VALUE copy, orig;
+{
+ struct StringIO *ptr;
+
+ orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio");
+ if (copy == orig) return copy;
+ ptr = StringIO(orig);
+ if (check_strio(copy)) {
+ strio_free(DATA_PTR(copy));
+ }
+ DATA_PTR(copy) = ptr;
+ OBJ_INFECT(copy, orig);
+ ++ptr->count;
+ return copy;
+}
+
+static VALUE
+strio_get_lineno(self)
+ VALUE self;
+{
+ return LONG2NUM(StringIO(self)->lineno);
+}
+
+static VALUE
+strio_set_lineno(self, lineno)
+ VALUE self, lineno;
+{
+ StringIO(self)->lineno = NUM2LONG(lineno);
+ return lineno;
+}
+
+#define strio_binmode strio_self
+
+#define strio_fcntl strio_unimpl
+
+#define strio_flush strio_self
+
+#define strio_fsync strio_0
+
+static VALUE
+strio_reopen(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ if (!OBJ_TAINTED(self)) rb_secure(4);
+ if (argc == 1 && TYPE(*argv) != T_STRING) {
+ return strio_copy(self, *argv);
+ }
+ return strio_initialize(argc, argv, self);
+}
+
+static VALUE
+strio_get_pos(self)
+ VALUE self;
+{
+ return LONG2NUM(StringIO(self)->pos);
+}
+
+static VALUE
+strio_set_pos(self, pos)
+ VALUE self;
+ VALUE pos;
+{
+ struct StringIO *ptr = StringIO(self);
+ long p = NUM2LONG(pos);
+ if (p < 0) {
+ error_inval(0);
+ }
+ ptr->pos = p;
+ return pos;
+}
+
+static VALUE
+strio_rewind(self)
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ ptr->pos = 0;
+ ptr->lineno = 0;
+ ptr->flags &= ~STRIO_EOF;
+ return INT2FIX(0);
+}
+
+static VALUE
+strio_seek(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE whence;
+ struct StringIO *ptr = StringIO(self);
+ long offset;
+
+ rb_scan_args(argc, argv, "11", NULL, &whence);
+ offset = NUM2LONG(argv[0]);
+ switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) {
+ case 0:
+ break;
+ case 1:
+ offset += ptr->pos;
+ break;
+ case 2:
+ offset += RSTRING(ptr->string)->len;
+ break;
+ default:
+ rb_raise(rb_eArgError, "invalid whence %ld", NUM2LONG(whence));
+ }
+ if (offset < 0) {
+ error_inval(0);
+ }
+ ptr->pos = offset;
+ ptr->flags &= ~STRIO_EOF;
+ return INT2FIX(0);
+}
+
+static VALUE
+strio_get_sync(self)
+ VALUE self;
+{
+ StringIO(self);
+ return Qtrue;
+}
+
+#define strio_set_sync strio_first
+
+#define strio_tell strio_get_pos
+
+static VALUE
+strio_each_byte(self)
+ VALUE self;
+{
+ struct StringIO *ptr = readable(StringIO(self));
+ while (ptr->pos < RSTRING(ptr->string)->len) {
+ char c = RSTRING(ptr->string)->ptr[ptr->pos++];
+ rb_yield(CHR2FIX(c));
+ }
+ return Qnil;
+}
+
+static VALUE
+strio_getc(self)
+ VALUE self;
+{
+ struct StringIO *ptr = readable(StringIO(self));
+ int c;
+ if (ptr->pos >= RSTRING(ptr->string)->len) {
+ ptr->flags |= STRIO_EOF;
+ return Qnil;
+ }
+ c = RSTRING(ptr->string)->ptr[ptr->pos++];
+ return CHR2FIX(c);
+}
+
+static VALUE
+strio_ungetc(self, ch)
+ VALUE self, ch;
+{
+ struct StringIO *ptr = readable(StringIO(self));
+ int cc = NUM2INT(ch);
+ long len, pos = ptr->pos;
+
+ if (cc != EOF && pos > 0) {
+ if ((len = RSTRING(ptr->string)->len) < pos ||
+ (unsigned char)RSTRING(ptr->string)->ptr[pos - 1] !=
+ (unsigned char)cc) {
+ check_modifiable(ptr);
+ if (len < pos) {
+ rb_str_resize(ptr->string, pos);
+ MEMZERO(RSTRING(ptr->string)->ptr + len, char, pos - len - 1);
+ }
+ else {
+ rb_str_modify(ptr->string);
+ }
+ RSTRING(ptr->string)->ptr[pos - 1] = cc;
+ OBJ_INFECT(ptr->string, self);
+ }
+ --ptr->pos;
+ ptr->flags &= ~STRIO_EOF;
+ }
+ return Qnil;
+}
+
+static VALUE
+strio_readchar(self)
+ VALUE self;
+{
+ VALUE c = strio_getc(self);
+ if (NIL_P(c)) rb_eof_error();
+ return c;
+}
+
+static void
+bm_init_skip(skip, pat, m)
+ long *skip;
+ const char *pat;
+ long m;
+{
+ int c;
+
+ for (c = 0; c < (1 << CHAR_BIT); c++) {
+ skip[c] = m;
+ }
+ while (--m) {
+ skip[(unsigned char)*pat++] = m;
+ }
+}
+
+static long
+bm_search(little, llen, big, blen, skip)
+ const char *little;
+ long llen;
+ const char *big;
+ long blen;
+ const long *skip;
+{
+ long i, j, k;
+
+ i = llen - 1;
+ while (i < blen) {
+ k = i;
+ j = llen - 1;
+ while (j >= 0 && big[k] == little[j]) {
+ k--;
+ j--;
+ }
+ if (j < 0) return k + 1;
+ i += skip[(unsigned char)big[i]];
+ }
+ return -1;
+}
+
+static VALUE
+strio_getline(argc, argv, ptr)
+ int argc;
+ VALUE *argv;
+ struct StringIO *ptr;
+{
+ const char *s, *e, *p;
+ long n;
+ VALUE str;
+
+ if (argc == 0) {
+ str = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &str);
+ if (!NIL_P(str)) StringValue(str);
+ }
+
+ if (ptr->pos >= (n = RSTRING(ptr->string)->len)) {
+ ptr->flags |= STRIO_EOF;
+ return Qnil;
+ }
+ s = RSTRING(ptr->string)->ptr;
+ e = s + RSTRING(ptr->string)->len;
+ s += ptr->pos;
+ if (NIL_P(str)) {
+ str = rb_str_substr(ptr->string, ptr->pos, e - s);
+ }
+ else if ((n = RSTRING(str)->len) == 0) {
+ p = s;
+ while (*p == '\n') {
+ if (++p == e) {
+ ptr->flags |= STRIO_EOF;
+ return Qnil;
+ }
+ }
+ s = p;
+ while (p = memchr(p, '\n', e - p)) {
+ if (p == e) break;
+ if (*++p == '\n') {
+ e = p;
+ break;
+ }
+ }
+ str = rb_str_substr(ptr->string, s - RSTRING(ptr->string)->ptr, e - s);
+ }
+ else if (n == 1) {
+ if (p = memchr(s, RSTRING(str)->ptr[0], e - s)) {
+ e = p + 1;
+ }
+ str = rb_str_substr(ptr->string, ptr->pos, e - s);
+ }
+ else {
+ if (n < e - s) {
+ if (e - s < 1024) {
+ for (p = s; p + n <= e; ++p) {
+ if (MEMCMP(p, RSTRING(str)->ptr, char, n) == 0) {
+ e = p + n;
+ break;
+ }
+ }
+ }
+ else {
+ long skip[1 << CHAR_BIT], pos;
+ p = RSTRING(str)->ptr;
+ bm_init_skip(skip, p, n);
+ if ((pos = bm_search(p, n, s, e - s, skip)) >= 0) {
+ e = s + pos + n;
+ }
+ }
+ }
+ str = rb_str_substr(ptr->string, ptr->pos, e - s);
+ }
+ ptr->pos = e - RSTRING(ptr->string)->ptr;
+ ptr->lineno++;
+ return str;
+}
+
+static VALUE
+strio_gets(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE str = strio_getline(argc, argv, readable(StringIO(self)));
+
+ rb_lastline_set(str);
+ return str;
+}
+
+static VALUE
+strio_readline(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE line = strio_getline(argc, argv, readable(StringIO(self)));
+ if (NIL_P(line)) rb_eof_error();
+ return line;
+}
+
+static VALUE
+strio_each(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ VALUE line;
+
+ while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) {
+ rb_yield(line);
+ }
+ return self;
+}
+
+static VALUE
+strio_readlines(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct StringIO *ptr = StringIO(self);
+ VALUE ary = rb_ary_new(), line;
+ while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) {
+ rb_ary_push(ary, line);
+ }
+ return ary;
+}
+
+static VALUE
+strio_write(self, str)
+ VALUE self, str;
+{
+ struct StringIO *ptr = writable(StringIO(self));
+ long len, olen;
+
+ if (TYPE(str) != T_STRING)
+ str = rb_obj_as_string(str);
+ len = RSTRING(str)->len;
+ if (!len) return INT2FIX(0);
+ check_modifiable(ptr);
+ olen = RSTRING(ptr->string)->len;
+ if (ptr->flags & FMODE_APPEND) {
+ ptr->pos = olen;
+ }
+ if (ptr->pos == olen) {
+ rb_str_cat(ptr->string, RSTRING(str)->ptr, len);
+ }
+ else {
+ if (ptr->pos + len > olen) {
+ rb_str_resize(ptr->string, ptr->pos + len);
+ MEMZERO(RSTRING(ptr->string)->ptr + olen, char, ptr->pos - olen);
+ }
+ else {
+ rb_str_modify(ptr->string);
+ }
+ rb_str_update(ptr->string, ptr->pos, len, str);
+ }
+ OBJ_INFECT(ptr->string, self);
+ ptr->pos += len;
+ return LONG2NUM(len);
+}
+
+#define strio_addstr rb_io_addstr
+
+#define strio_print rb_io_print
+
+#define strio_printf rb_io_printf
+
+static VALUE
+strio_putc(self, ch)
+ VALUE self, ch;
+{
+ struct StringIO *ptr = writable(StringIO(self));
+ int c = NUM2CHR(ch);
+
+ check_modifiable(ptr);
+ if (ptr->flags & FMODE_APPEND) {
+ ptr->pos = RSTRING(ptr->string)->len;
+ }
+ if (ptr->pos >= RSTRING(ptr->string)->len) {
+ rb_str_resize(ptr->string, ptr->pos + 1);
+ }
+ else {
+ rb_str_modify(ptr->string);
+ }
+ RSTRING(ptr->string)->ptr[ptr->pos++] = c;
+ OBJ_INFECT(ptr->string, self);
+ return ch;
+}
+
+#define strio_puts rb_io_puts
+
+static VALUE
+strio_read(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct StringIO *ptr = readable(StringIO(self));
+ VALUE str = Qnil;
+ long len, olen;
+
+ switch (argc) {
+ case 2:
+ str = argv[1];
+ StringValue(str);
+ rb_str_modify(str);
+ case 1:
+ if (!NIL_P(argv[0])) {
+ len = olen = NUM2LONG(argv[0]);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative length %ld given", len);
+ }
+ if (len > 0 && ptr->pos >= RSTRING(ptr->string)->len) {
+ ptr->flags |= STRIO_EOF;
+ if (!NIL_P(str)) rb_str_resize(str, 0);
+ return Qnil;
+ }
+ else if (ptr->flags & STRIO_EOF) {
+ if (!NIL_P(str)) rb_str_resize(str, 0);
+ return Qnil;
+ }
+ break;
+ }
+ /* fall through */
+ case 0:
+ olen = -1;
+ len = RSTRING(ptr->string)->len;
+ if (len <= ptr->pos) {
+ ptr->flags |= STRIO_EOF;
+ if (NIL_P(str)) {
+ str = rb_str_new(0, 0);
+ }
+ else {
+ rb_str_resize(str, 0);
+ }
+ return str;
+ }
+ else {
+ len -= ptr->pos;
+ }
+ break;
+ default:
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ if (NIL_P(str)) {
+ str = rb_str_substr(ptr->string, ptr->pos, len);
+ }
+ else {
+ long rest = RSTRING(ptr->string)->len - ptr->pos;
+ if (len > rest) len = rest;
+ rb_str_resize(str, len);
+ MEMCPY(RSTRING(str)->ptr, RSTRING(ptr->string)->ptr, char, len);
+ }
+ if (NIL_P(str)) {
+ if (!(ptr->flags & STRIO_EOF)) str = rb_str_new(0, 0);
+ len = 0;
+ }
+ else {
+ ptr->pos += len = RSTRING(str)->len;
+ }
+ if (olen < 0 || olen > len) ptr->flags |= STRIO_EOF;
+ return str;
+}
+
+static VALUE
+strio_sysread(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE val = strio_read(argc, argv, self);
+ if (NIL_P(val) || RSTRING(val)->len == 0) {
+ rb_eof_error();
+ }
+ return val;
+}
+
+#define strio_syswrite strio_write
+
+#define strio_path strio_nil
+
+#define strio_isatty strio_false
+
+#define strio_pid strio_nil
+
+#define strio_fileno strio_nil
+
+static VALUE
+strio_size(self)
+ VALUE self;
+{
+ VALUE string = StringIO(self)->string;
+ if (NIL_P(string)) {
+ rb_raise(rb_eIOError, "not opened");
+ }
+ return ULONG2NUM(RSTRING(string)->len);
+}
+
+static VALUE
+strio_truncate(self, len)
+ VALUE self, len;
+{
+ VALUE string = writable(StringIO(self))->string;
+ long l = NUM2LONG(len);
+ if (l < 0) {
+ error_inval("negative legnth");
+ }
+ rb_str_resize(string, l);
+ return len;
+}
+
+void
+Init_stringio()
+{
+ VALUE StringIO = rb_define_class("StringIO", rb_cData);
+
+ rb_include_module(StringIO, rb_mEnumerable);
+ rb_define_alloc_func(StringIO, strio_s_allocate);
+ rb_define_singleton_method(StringIO, "open", strio_s_open, -1);
+ rb_define_method(StringIO, "initialize", strio_initialize, -1);
+ rb_define_method(StringIO, "initialize_copy", strio_copy, 1);
+ rb_define_method(StringIO, "reopen", strio_reopen, -1);
+
+ rb_define_method(StringIO, "string", strio_get_string, 0);
+ rb_define_method(StringIO, "string=", strio_set_string, 1);
+ rb_define_method(StringIO, "lineno", strio_get_lineno, 0);
+ rb_define_method(StringIO, "lineno=", strio_set_lineno, 1);
+
+ rb_define_method(StringIO, "binmode", strio_binmode, 0);
+ rb_define_method(StringIO, "close", strio_close, 0);
+ rb_define_method(StringIO, "close_read", strio_close_read, 0);
+ rb_define_method(StringIO, "close_write", strio_close_write, 0);
+ rb_define_method(StringIO, "closed?", strio_closed, 0);
+ rb_define_method(StringIO, "closed_read?", strio_closed_read, 0);
+ rb_define_method(StringIO, "closed_write?", strio_closed_write, 0);
+ rb_define_method(StringIO, "eof", strio_eof, 0);
+ rb_define_method(StringIO, "eof?", strio_eof, 0);
+ rb_define_method(StringIO, "fcntl", strio_fcntl, -1);
+ rb_define_method(StringIO, "flush", strio_flush, 0);
+ rb_define_method(StringIO, "fsync", strio_fsync, 0);
+ rb_define_method(StringIO, "pos", strio_get_pos, 0);
+ rb_define_method(StringIO, "pos=", strio_set_pos, 1);
+ rb_define_method(StringIO, "rewind", strio_rewind, 0);
+ rb_define_method(StringIO, "seek", strio_seek, -1);
+ rb_define_method(StringIO, "sync", strio_get_sync, 0);
+ rb_define_method(StringIO, "sync=", strio_set_sync, 1);
+ rb_define_method(StringIO, "tell", strio_tell, 0);
+ rb_define_method(StringIO, "path", strio_path, 0);
+
+ rb_define_method(StringIO, "each", strio_each, -1);
+ rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
+ rb_define_method(StringIO, "each_line", strio_each, -1);
+ rb_define_method(StringIO, "getc", strio_getc, 0);
+ rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
+ rb_define_method(StringIO, "readchar", strio_readchar, 0);
+ rb_define_method(StringIO, "gets", strio_gets, -1);
+ rb_define_method(StringIO, "readline", strio_readline, -1);
+ rb_define_method(StringIO, "readlines", strio_readlines, -1);
+ rb_define_method(StringIO, "read", strio_read, -1);
+ rb_define_method(StringIO, "sysread", strio_sysread, -1);
+
+ rb_define_method(StringIO, "write", strio_write, 1);
+ rb_define_method(StringIO, "<<", strio_addstr, 1);
+ rb_define_method(StringIO, "print", strio_print, -1);
+ rb_define_method(StringIO, "printf", strio_printf, -1);
+ rb_define_method(StringIO, "putc", strio_putc, 1);
+ rb_define_method(StringIO, "puts", strio_puts, -1);
+ rb_define_method(StringIO, "syswrite", strio_syswrite, 1);
+
+ rb_define_method(StringIO, "isatty", strio_isatty, 0);
+ rb_define_method(StringIO, "tty?", strio_isatty, 0);
+ rb_define_method(StringIO, "pid", strio_pid, 0);
+ rb_define_method(StringIO, "fileno", strio_fileno, 0);
+ rb_define_method(StringIO, "size", strio_size, 0);
+ rb_define_method(StringIO, "length", strio_size, 0);
+ rb_define_method(StringIO, "truncate", strio_truncate, 1);
+}
diff --git a/ext/strscan/.cvsignore b/ext/strscan/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/strscan/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/strscan/depend b/ext/strscan/depend
new file mode 100644
index 0000000000..9199574c3f
--- /dev/null
+++ b/ext/strscan/depend
@@ -0,0 +1 @@
+strscan.o: strscan.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h
diff --git a/ext/strscan/extconf.rb b/ext/strscan/extconf.rb
new file mode 100644
index 0000000000..0d21966fc2
--- /dev/null
+++ b/ext/strscan/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile 'strscan'
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
new file mode 100644
index 0000000000..227ed92305
--- /dev/null
+++ b/ext/strscan/strscan.c
@@ -0,0 +1,1346 @@
+/*
+
+ strscan.c
+
+ Copyright (c) 1999-2004 Minero Aoki
+
+ This program is free software.
+ You can distribute/modify this program under the terms of
+ the Ruby License. For details, see the file COPYING.
+
+ $Id$
+
+*/
+
+
+#include "ruby.h"
+#include "re.h"
+#include "version.h"
+
+#if (RUBY_VERSION_CODE < 150)
+# define rb_eRangeError rb_eArgError
+# define rb_obj_freeze(obj) rb_str_freeze(obj)
+#endif
+
+#define STRSCAN_VERSION "0.7.0"
+
+/* =======================================================================
+ Data Type Definitions
+ ======================================================================= */
+
+static VALUE StringScanner;
+static VALUE ScanError;
+
+struct strscanner
+{
+ /* multi-purpose flags */
+ unsigned long flags;
+#define FLAG_MATCHED (1 << 0)
+
+ /* the string to scan */
+ VALUE str;
+
+ /* scan pointers */
+ long prev; /* legal only when MATCHED_P(s) */
+ long curr; /* always legal */
+
+ /* the regexp register; legal only when MATCHED_P(s) */
+ struct re_registers regs;
+};
+
+#define MATCHED_P(s) ((s)->flags & FLAG_MATCHED)
+#define MATCHED(s) (s)->flags |= FLAG_MATCHED
+#define CLEAR_MATCH_STATUS(s) (s)->flags &= ~FLAG_MATCHED
+
+#define S_PBEG(s) (RSTRING((s)->str)->ptr)
+#define S_LEN(s) (RSTRING((s)->str)->len)
+#define S_PEND(s) (S_PBEG(s) + S_LEN(s))
+#define CURPTR(s) (S_PBEG(s) + (s)->curr)
+#define S_RESTLEN(s) (S_LEN(s) - (s)->curr)
+
+#define EOS_P(s) ((s)->curr >= RSTRING(p->str)->len)
+
+#define GET_SCANNER(obj,var) do {\
+ Data_Get_Struct(obj, struct strscanner, var);\
+ if (NIL_P(var->str)) rb_raise(rb_eArgError, "uninitialized StringScanner object");\
+} while (0)
+
+/* =======================================================================
+ Function Prototypes
+ ======================================================================= */
+
+static VALUE infect _((VALUE str, struct strscanner *p));
+static VALUE extract_range _((struct strscanner *p, long beg_i, long end_i));
+static VALUE extract_beg_len _((struct strscanner *p, long beg_i, long len));
+
+static void strscan_mark _((struct strscanner *p));
+static void strscan_free _((struct strscanner *p));
+static VALUE strscan_s_allocate _((VALUE klass));
+static VALUE strscan_initialize _((int argc, VALUE *argv, VALUE self));
+
+static VALUE strscan_s_mustc _((VALUE self));
+static VALUE strscan_terminate _((VALUE self));
+static VALUE strscan_clear _((VALUE self));
+static VALUE strscan_get_string _((VALUE self));
+static VALUE strscan_set_string _((VALUE self, VALUE str));
+static VALUE strscan_concat _((VALUE self, VALUE str));
+static VALUE strscan_get_pos _((VALUE self));
+static VALUE strscan_set_pos _((VALUE self, VALUE pos));
+static VALUE strscan_do_scan _((VALUE self, VALUE regex,
+ int succptr, int getstr, int headonly));
+static VALUE strscan_scan _((VALUE self, VALUE re));
+static VALUE strscan_match_p _((VALUE self, VALUE re));
+static VALUE strscan_skip _((VALUE self, VALUE re));
+static VALUE strscan_check _((VALUE self, VALUE re));
+static VALUE strscan_scan_full _((VALUE self, VALUE re,
+ VALUE succp, VALUE getp));
+static VALUE strscan_scan_until _((VALUE self, VALUE re));
+static VALUE strscan_skip_until _((VALUE self, VALUE re));
+static VALUE strscan_check_until _((VALUE self, VALUE re));
+static VALUE strscan_search_full _((VALUE self, VALUE re,
+ VALUE succp, VALUE getp));
+static void adjust_registers_to_matched _((struct strscanner *p));
+static VALUE strscan_getch _((VALUE self));
+static VALUE strscan_get_byte _((VALUE self));
+static VALUE strscan_getbyte _((VALUE self));
+static VALUE strscan_peek _((VALUE self, VALUE len));
+static VALUE strscan_peep _((VALUE self, VALUE len));
+static VALUE strscan_unscan _((VALUE self));
+static VALUE strscan_bol_p _((VALUE self));
+static VALUE strscan_eos_p _((VALUE self));
+static VALUE strscan_empty_p _((VALUE self));
+static VALUE strscan_rest_p _((VALUE self));
+static VALUE strscan_matched_p _((VALUE self));
+static VALUE strscan_matched _((VALUE self));
+static VALUE strscan_matched_size _((VALUE self));
+static VALUE strscan_aref _((VALUE self, VALUE idx));
+static VALUE strscan_pre_match _((VALUE self));
+static VALUE strscan_post_match _((VALUE self));
+static VALUE strscan_rest _((VALUE self));
+static VALUE strscan_rest_size _((VALUE self));
+
+static VALUE strscan_inspect _((VALUE self));
+static VALUE inspect1 _((struct strscanner *p));
+static VALUE inspect2 _((struct strscanner *p));
+
+/* =======================================================================
+ Utils
+ ======================================================================= */
+
+static VALUE
+infect(str, p)
+ VALUE str;
+ struct strscanner *p;
+{
+ OBJ_INFECT(str, p->str);
+ return str;
+}
+
+static VALUE
+extract_range(p, beg_i, end_i)
+ struct strscanner *p;
+ long beg_i, end_i;
+{
+ if (beg_i > S_LEN(p)) return Qnil;
+ if (end_i > S_LEN(p))
+ end_i = S_LEN(p);
+ return infect(rb_str_new(S_PBEG(p) + beg_i, end_i - beg_i), p);
+}
+
+static VALUE
+extract_beg_len(p, beg_i, len)
+ struct strscanner *p;
+ long beg_i, len;
+{
+ if (beg_i > S_LEN(p)) return Qnil;
+ if (beg_i + len > S_LEN(p))
+ len = S_LEN(p) - beg_i;
+ return infect(rb_str_new(S_PBEG(p) + beg_i, len), p);
+}
+
+
+/* =======================================================================
+ Constructor
+ ======================================================================= */
+
+
+static void
+strscan_mark(p)
+ struct strscanner *p;
+{
+ rb_gc_mark(p->str);
+}
+
+static void
+strscan_free(p)
+ struct strscanner *p;
+{
+ re_free_registers(&(p->regs));
+ memset(p, sizeof(struct strscanner), 0);
+ free(p);
+}
+
+static VALUE
+strscan_s_allocate(klass)
+ VALUE klass;
+{
+ struct strscanner *p;
+
+ p = ALLOC(struct strscanner);
+ MEMZERO(p, struct strscanner, 1);
+ CLEAR_MATCH_STATUS(p);
+ MEMZERO(&(p->regs), struct re_registers, 1);
+ p->str = Qnil;
+ return Data_Wrap_Struct(klass, strscan_mark, strscan_free, p);
+}
+
+/*
+ * call-seq: StringScanner.new(string, dup = false)
+ *
+ * Creates a new StringScanner object to scan over the given +string+.
+ * +dup+ argument is obsolete and not used now.
+ */
+static VALUE
+strscan_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct strscanner *p;
+ VALUE str, need_dup;
+
+ Data_Get_Struct(self, struct strscanner, p);
+ rb_scan_args(argc, argv, "11", &str, &need_dup);
+ StringValue(str);
+ p->str = str;
+
+ return self;
+}
+
+
+/* =======================================================================
+ Instance Methods
+ ======================================================================= */
+
+/*
+ * call-seq: StringScanner.must_C_version
+ *
+ * This method is defined for backward compatibility.
+ */
+static VALUE
+strscan_s_mustc(self)
+ VALUE self;
+{
+ return self;
+}
+
+/*
+ * Reset the scan pointer (index 0) and clear matching data.
+ */
+static VALUE
+strscan_reset(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ p->curr = 0;
+ CLEAR_MATCH_STATUS(p);
+ return self;
+}
+
+/*
+ * call-seq:
+ * terminate
+ * clear
+ *
+ * Set the scan pointer to the end of the string and clear matching data.
+ */
+static VALUE
+strscan_terminate(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ p->curr = S_LEN(p);
+ CLEAR_MATCH_STATUS(p);
+ return self;
+}
+
+/*
+ * Returns the string being scanned.
+ */
+static VALUE
+strscan_clear(self)
+ VALUE self;
+{
+ rb_warning("StringScanner#clear is obsolete; use #terminate instead");
+ return strscan_terminate(self);
+}
+
+static VALUE
+strscan_get_string(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ return p->str;
+}
+
+/*
+ * call-seq: string=(str)
+ *
+ * Changes the string being scanned to +str+ and resets the scanner.
+ * Returns +str+.
+ */
+static VALUE
+strscan_set_string(self, str)
+ VALUE self, str;
+{
+ struct strscanner *p;
+
+ Data_Get_Struct(self, struct strscanner, p);
+ StringValue(str);
+ p->str = rb_str_dup(str);
+ rb_obj_freeze(p->str);
+ p->curr = 0;
+ CLEAR_MATCH_STATUS(p);
+ return str;
+}
+
+/*
+ * call-seq:
+ * concat(str)
+ * <<(str)
+ *
+ * Appends +str+ to the string being scanned.
+ * This method does not affect scan pointer.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.scan(/Fri /)
+ * s << " +1000 GMT"
+ * s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT"
+ * s.scan(/Dec/) # -> "Dec"
+ */
+static VALUE
+strscan_concat(self, str)
+ VALUE self, str;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ StringValue(str);
+ rb_str_append(p->str, str);
+ return self;
+}
+
+/*
+ * Returns the position of the scan pointer. In the 'reset' position, this
+ * value is zero. In the 'terminated' position (i.e. the string is exhausted),
+ * this value is the length of the string.
+ *
+ * In short, it's a 1-based index into the string.
+ *
+ * s = StringScanner.new('test string')
+ * s.pos # -> 0
+ * s.scan_until /str/ # -> "test str"
+ * s.pos # -> 8
+ * s.terminate # -> #<StringScanner fin>
+ * s.pos # -> 11
+ */
+static VALUE
+strscan_get_pos(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ return INT2FIX(p->curr);
+}
+
+/*
+ * call-seq: pos=(n)
+ *
+ * Modify the scan pointer.
+ *
+ * s = StringScanner.new('test string')
+ * s.pos = 7 # -> 7
+ * s.rest # -> "ring"
+ */
+static VALUE
+strscan_set_pos(self, v)
+ VALUE self, v;
+{
+ struct strscanner *p;
+ long i;
+
+ GET_SCANNER(self, p);
+ i = NUM2INT(v);
+ if (i < 0) i += S_LEN(p);
+ if (i < 0) rb_raise(rb_eRangeError, "index out of range");
+ if (i > S_LEN(p)) rb_raise(rb_eRangeError, "index out of range");
+ p->curr = i;
+ return INT2NUM(i);
+}
+
+
+/* I should implement this function? */
+#define strscan_prepare_re(re) /* none */
+
+static VALUE
+strscan_do_scan(self, regex, succptr, getstr, headonly)
+ VALUE self, regex;
+ int succptr, getstr, headonly;
+{
+ struct strscanner *p;
+ int ret;
+
+ Check_Type(regex, T_REGEXP);
+ GET_SCANNER(self, p);
+
+ CLEAR_MATCH_STATUS(p);
+ if (EOS_P(p)) {
+ return Qnil;
+ }
+ strscan_prepare_re(regex);
+ if (headonly) {
+ ret = re_match(RREGEXP(regex)->ptr,
+ CURPTR(p), S_RESTLEN(p),
+ 0,
+ &(p->regs));
+ }
+ else {
+ ret = re_search(RREGEXP(regex)->ptr,
+ CURPTR(p), S_RESTLEN(p),
+ 0,
+ S_RESTLEN(p),
+ &(p->regs));
+ }
+
+ if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
+ if (ret < 0) {
+ /* not matched */
+ return Qnil;
+ }
+
+ MATCHED(p);
+ p->prev = p->curr;
+ if (succptr) {
+ p->curr += p->regs.end[0];
+ }
+ if (getstr) {
+ return extract_beg_len(p, p->prev, p->regs.end[0]);
+ }
+ else {
+ return INT2FIX(p->regs.end[0]);
+ }
+}
+
+/*
+ * call-seq:
+ * scanner.scan(pattern) => String
+ *
+ */
+
+/*
+ * call-seq: scan(pattern)
+ *
+ * Tries to match with +pattern+ at the current position. If there's a match,
+ * the scanner advances the "scan pointer" and returns the matched string.
+ * Otherwise, the scanner returns +nil+.
+ *
+ * s = StringScanner.new('test string')
+ * p s.scan(/\w+/) # -> "test"
+ * p s.scan(/\w+/) # -> nil
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "string"
+ * p s.scan(/./) # -> nil
+ *
+ */
+static VALUE
+strscan_scan(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 1, 1, 1);
+}
+
+/*
+ * call-seq: match?(pattern)
+ *
+ * Tests whether the given +pattern+ is matched from the current scan pointer.
+ * Returns the length of the match, or +nil+. The scan pointer is not advanced.
+ *
+ * s = StringScanner.new('test string')
+ * p s.match?(/\w+/) # -> 4
+ * p s.match?(/\w+/) # -> 4
+ * p s.match?(/\s+/) # -> nil
+ */
+static VALUE
+strscan_match_p(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 0, 0, 1);
+}
+
+/*
+ * call-seq: skip(pattern)
+ *
+ * Attempts to skip over the given +pattern+ beginning with the scan pointer.
+ * If it matches, the scan pointer is advanced to the end of the match, and the
+ * length of the match is returned. Otherwise, +nil+ is returned.
+ *
+ * It's similar to #scan, but without returning the matched string.
+ *
+ * s = StringScanner.new('test string')
+ * p s.skip(/\w+/) # -> 4
+ * p s.skip(/\w+/) # -> nil
+ * p s.skip(/\s+/) # -> 1
+ * p s.skip(/\w+/) # -> 6
+ * p s.skip(/./) # -> nil
+ *
+ */
+static VALUE
+strscan_skip(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 1, 0, 1);
+}
+
+/*
+ * call-seq: check(pattern)
+ *
+ * This returns the value that #scan would return, without advancing the scan
+ * pointer. The match register is affected, though.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.check /Fri/ # -> "Fri"
+ * s.pos # -> 0
+ * s.matched # -> "Fri"
+ * s.check /12/ # -> nil
+ * s.matched # -> nil
+ *
+ * Mnemonic: it "checks" to see whether a #scan will return a value.
+ */
+static VALUE
+strscan_check(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 0, 1, 1);
+}
+
+/*
+ * call-seq: scan_full(pattern, return_string_p, advance_pointer_p)
+ *
+ * Tests whether the given +pattern+ is matched from the current scan pointer.
+ * Returns the matched string if +return_string_p+ is true.
+ * Advances the scan pointer if +advance_pointer_p+ is true.
+ * The match register is affected.
+ *
+ * "full" means "#scan with full parameters".
+ */
+static VALUE
+strscan_scan_full(self, re, s, f)
+ VALUE self, re, s, f;
+{
+ return strscan_do_scan(self, re, RTEST(s), RTEST(f), 1);
+}
+
+
+/*
+ * call-seq: scan_until(pattern)
+ *
+ * Scans the string _until_ the +pattern+ is matched. Returns the substring up
+ * to and including the end of the match, advancing the scan pointer to that
+ * location. If there is no match, +nil+ is returned.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.scan_until(/1/) # -> "Fri Dec 1"
+ * s.pre_match # -> "Fri Dec "
+ * s.scan_until(/XYZ/) # -> nil
+ */
+static VALUE
+strscan_scan_until(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 1, 1, 0);
+}
+
+/*
+ * call-seq: exist?(pattern)
+ *
+ * Looks _ahead_ to see if the +pattern+ exists _anywhere_ in the string,
+ * without advancing the scan pointer. This predicates whether a #scan_until
+ * will return a value.
+ *
+ * s = StringScanner.new('test string')
+ * s.exist? /s/ # -> 3
+ * s.scan /test/ # -> "test"
+ * s.exist? /s/ # -> 6
+ * s.exist? /e/ # -> nil
+ */
+static VALUE
+strscan_exist_p(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 0, 0, 0);
+}
+
+/*
+ * call-seq: skip_until(pattern)
+ *
+ * Advances the scan pointer until +pattern+ is matched and consumed. Returns
+ * the number of bytes advanced, or +nil+ if no match was found.
+ *
+ * Look ahead to match +pattern+, and advance the scan pointer to the _end_
+ * of the match. Return the number of characters advanced, or +nil+ if the
+ * match was unsuccessful.
+ *
+ * It's similar to #scan_until, but without returning the intervening string.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.skip_until /12/ # -> 10
+ * s #
+ */
+static VALUE
+strscan_skip_until(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 1, 0, 0);
+}
+
+/*
+ * call-seq: check_until(pattern)
+ *
+ * This returns the value that #scan_until would return, without advancing the
+ * scan pointer. The match register is affected, though.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.check_until /12/ # -> "Fri Dec 12"
+ * s.pos # -> 0
+ * s.matched # -> 12
+ *
+ * Mnemonic: it "checks" to see whether a #scan_until will return a value.
+ */
+static VALUE
+strscan_check_until(self, re)
+ VALUE self, re;
+{
+ return strscan_do_scan(self, re, 0, 1, 0);
+}
+
+/*
+ * call-seq: search_full(pattern, return_string_p, advance_pointer_p)
+ *
+ * Scans the string _until_ the +pattern+ is matched.
+ * Returns the matched string if +return_string_p+ is true, otherwise
+ * returns the number of bytes advanced.
+ * Advances the scan pointer if +advance_pointer_p+, otherwise not.
+ * This method does affect the match register.
+ */
+static VALUE
+strscan_search_full(self, re, s, f)
+ VALUE self, re, s, f;
+{
+ return strscan_do_scan(self, re, RTEST(s), RTEST(f), 0);
+}
+
+/* DANGEROUS; need to synchronize with regex.c */
+static void
+adjust_registers_to_matched(p)
+ struct strscanner *p;
+{
+ if (p->regs.allocated == 0) {
+ p->regs.beg = ALLOC_N(int, RE_NREGS);
+ p->regs.end = ALLOC_N(int, RE_NREGS);
+ p->regs.allocated = RE_NREGS;
+ }
+ p->regs.num_regs = 1;
+ p->regs.beg[0] = 0;
+ p->regs.end[0] = p->curr - p->prev;
+}
+
+/*
+ * Scans one character and returns it.
+ *
+ * s = StringScanner.new('ab')
+ * s.getch # => "a"
+ * s.getch # => "b"
+ * s.getch # => nil
+ */
+static VALUE
+strscan_getch(self)
+ VALUE self;
+{
+ struct strscanner *p;
+ long len;
+
+ GET_SCANNER(self, p);
+ CLEAR_MATCH_STATUS(p);
+ if (EOS_P(p))
+ return Qnil;
+
+ len = mbclen(*CURPTR(p));
+ if (p->curr + len > S_LEN(p))
+ len = S_LEN(p) - p->curr;
+ p->prev = p->curr;
+ p->curr += len;
+ MATCHED(p);
+ adjust_registers_to_matched(p);
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
+}
+
+/*
+ * Scans one byte and returns it. Similar to, but not the same as, #getch.
+ *
+ * s = StringScanner.new('ab')
+ * s.get_byte # => "a"
+ * s.get_byte # => "b"
+ * s.get_byte # => nil
+ */
+static VALUE
+strscan_get_byte(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ CLEAR_MATCH_STATUS(p);
+ if (EOS_P(p))
+ return Qnil;
+
+ p->prev = p->curr;
+ p->curr++;
+ MATCHED(p);
+ adjust_registers_to_matched(p);
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
+}
+
+static VALUE
+strscan_getbyte(self)
+ VALUE self;
+{
+ rb_warning("StringScanner#getbyte is obsolete; use #get_byte instead");
+ return strscan_get_byte(self);
+}
+
+/*
+ * call-seq: peek(len)
+ *
+ * Extracts a string corresponding to <tt>string[pos,len]</tt>, without
+ * advancing the scan pointer.
+ *
+ * s = StringScanner.new('test string')
+ * s.peek(7) # => "test st"
+ * s.peek(7) # => "test st"
+ *
+ */
+static VALUE
+strscan_peek(self, vlen)
+ VALUE self, vlen;
+{
+ struct strscanner *p;
+ long len;
+
+ GET_SCANNER(self, p);
+
+ len = NUM2LONG(vlen);
+ if (EOS_P(p))
+ return infect(rb_str_new("", 0), p);
+
+ if (p->curr + len > S_LEN(p))
+ len = S_LEN(p) - p->curr;
+ return extract_beg_len(p, p->curr, len);
+}
+
+/*
+ * Set the scan pointer to the previous position. Only one previous position is
+ * remembered, and it changes with each scanning operation.
+ *
+ * s = StringScanner.new('test string')
+ * s.scan(/\w+/) # => "test"
+ * s.unscan
+ * s.scan(/../) # => "te"
+ * s.scan(/\d/) # => nil
+ * s.unscan # ScanError: cannot unscan: prev match had failed
+ */
+static VALUE
+strscan_peep(self, vlen)
+ VALUE self, vlen;
+{
+ rb_warning("StringScanner#peep is obsolete; use #peek instead");
+ return strscan_peek(self, vlen);
+}
+
+static VALUE
+strscan_unscan(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p))
+ rb_raise(ScanError, "cannot unscan: prev match had failed");
+
+ p->curr = p->prev;
+ CLEAR_MATCH_STATUS(p);
+ return self;
+}
+
+/*
+ * Returns +true+ iff the scan pointer is at the beginning of the line.
+ *
+ * s = StringScanner.new("test\ntest\n")
+ * s.bol? # => true
+ * s.scan(/te/)
+ * s.bol? # => false
+ * s.scan(/st\n/)
+ * s.bol? # => true
+ * s.terminate
+ * s.bol? # => true
+ */
+static VALUE
+strscan_bol_p(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (CURPTR(p) > S_PEND(p)) return Qnil;
+ if (p->curr == 0) return Qtrue;
+ return (*(CURPTR(p) - 1) == '\n') ? Qtrue : Qfalse;
+}
+
+/*
+ * Returns +true+ if the scan pointer is at the end of the string.
+ *
+ * s = StringScanner.new('test string')
+ * p s.eos? # => false
+ * s.scan(/test/)
+ * p s.eos? # => false
+ * s.terminate
+ * p s.eos? # => true
+ */
+static VALUE
+strscan_eos_p(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (EOS_P(p))
+ return Qtrue;
+ else
+ return Qfalse;
+}
+
+/*
+ * Equivalent to #eos?.
+ * This method is obsolete, use #eos? instead.
+ */
+static VALUE
+strscan_empty_p(self)
+ VALUE self;
+{
+ rb_warning("StringScanner#empty? is obsolete; use #eos? instead");
+ return strscan_eos_p(self);
+}
+
+/*
+ * Returns true iff there is more data in the string. See #eos?.
+ * This method is obsolete; use #eos? instead.
+ *
+ * s = StringScanner.new('test string')
+ * s.eos? # These two
+ * s.rest? # are opposites.
+ */
+static VALUE
+strscan_rest_p(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (EOS_P(p))
+ return Qfalse;
+ else
+ return Qtrue;
+}
+
+/*
+ * Returns +true+ iff the last match was successful.
+ *
+ * s = StringScanner.new('test string')
+ * s.match?(/\w+/) # => 4
+ * s.matched? # => true
+ * s.match?(/\d+/) # => nil
+ * s.matched? # => false
+ */
+static VALUE
+strscan_matched_p(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (MATCHED_P(p))
+ return Qtrue;
+ else
+ return Qfalse;
+}
+
+/*
+ * Returns the last matched string.
+ *
+ * s = StringScanner.new('test string')
+ * s.match?(/\w+/) # -> 4
+ * s.matched # -> "test"
+ */
+static VALUE
+strscan_matched(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
+}
+
+/*
+ * Returns the size of the most recent match (see #matched), or +nil+ if there
+ * was no recent match.
+ *
+ * s = StringScanner.new('test string')
+ * s.check /\w+/ # -> "test"
+ * s.matched_size # -> 4
+ * s.check /\d+/ # -> nil
+ * s.matched_size # -> nil
+ */
+static VALUE
+strscan_matched_size(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+
+ return INT2NUM(p->regs.end[0] - p->regs.beg[0]);
+}
+
+/*
+ * Equivalent to #matched_size.
+ * This method is obsolete; use #matched_size instead.
+ */
+static VALUE
+strscan_matchedsize(self)
+ VALUE self;
+{
+ rb_warning("StringScanner#matchedsize is obsolete; use #matched_size instead");
+ return strscan_matched_size(self);
+}
+
+/*
+ * call-seq: [](n)
+ *
+ * Return the n-th subgroup in the most recent match.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 "
+ * s[0] # -> "Fri Dec 12 "
+ * s[1] # -> "Fri"
+ * s[2] # -> "Dec"
+ * s[3] # -> "12"
+ * s.post_match # -> "1975 14:39"
+ * s.pre_match # -> ""
+ */
+static VALUE
+strscan_aref(self, idx)
+ VALUE self, idx;
+{
+ struct strscanner *p;
+ long i;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+
+ i = NUM2LONG(idx);
+ if (i < 0)
+ i += p->regs.num_regs;
+ if (i < 0) return Qnil;
+ if (i >= p->regs.num_regs) return Qnil;
+ if (p->regs.beg[i] == -1) return Qnil;
+
+ return extract_range(p, p->prev + p->regs.beg[i],
+ p->prev + p->regs.end[i]);
+}
+
+/*
+ * Return the <i><b>pre</b>-match</i> (in the regular expression sense) of the last scan.
+ *
+ * s = StringScanner.new('test string')
+ * s.scan(/\w+/) # -> "test"
+ * s.scan(/\s+/) # -> " "
+ * s.pre_match # -> "test"
+ * s.post_match # -> "string"
+ */
+static VALUE
+strscan_pre_match(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+
+ return extract_range(p, 0, p->prev + p->regs.beg[0]);
+}
+
+/*
+ * Return the <i><b>post</b>-match</i> (in the regular expression sense) of the last scan.
+ *
+ * s = StringScanner.new('test string')
+ * s.scan(/\w+/) # -> "test"
+ * s.scan(/\s+/) # -> " "
+ * s.pre_match # -> "test"
+ * s.post_match # -> "string"
+ */
+static VALUE
+strscan_post_match(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+
+ return extract_range(p, p->prev + p->regs.end[0], S_LEN(p));
+}
+
+/*
+ * Returns the "rest" of the string (i.e. everything after the scan pointer).
+ * If there is no more data (eos? = true), it returns <tt>""</tt>.
+ */
+static VALUE
+strscan_rest(self)
+ VALUE self;
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (EOS_P(p)) {
+ return infect(rb_str_new("", 0), p);
+ }
+ return extract_range(p, p->curr, S_LEN(p));
+}
+
+/*
+ * <tt>s.rest_size</tt> is equivalent to <tt>s.rest.size</tt>.
+ */
+static VALUE
+strscan_rest_size(self)
+ VALUE self;
+{
+ struct strscanner *p;
+ long i;
+
+ GET_SCANNER(self, p);
+ if (EOS_P(p)) {
+ return INT2FIX(0);
+ }
+
+ i = S_LEN(p) - p->curr;
+ return INT2FIX(i);
+}
+
+/*
+ * <tt>s.restsize</tt> is equivalent to <tt>s.rest_size</tt>.
+ * This method is obsolete; use #rest_size instead.
+ */
+static VALUE
+strscan_restsize(self)
+ VALUE self;
+{
+ rb_warning("StringScanner#restsize is obsolete; use #rest_size instead");
+ return strscan_rest_size(self);
+}
+
+#define INSPECT_LENGTH 5
+#define BUFSIZE 256
+
+/*
+ * Returns a string that represents the StringScanner object, showing:
+ * - the current position
+ * - the size of the string
+ * - the characters surrounding the scan pointer
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.inspect # -> '#<StringScanner 0/21 @ "Fri D...">'
+ * s.scan_until /12/ # -> "Fri Dec 12"
+ * s.inspect # -> '#<StringScanner 10/21 "...ec 12" @ " 1975...">'
+ */
+static VALUE
+strscan_inspect(self)
+ VALUE self;
+{
+ struct strscanner *p;
+ char buf[BUFSIZE];
+ long len;
+ VALUE a, b;
+
+ Data_Get_Struct(self, struct strscanner, p);
+ if (NIL_P(p->str)) {
+ len = snprintf(buf, BUFSIZE, "#<%s (uninitialized)>",
+ rb_class2name(CLASS_OF(self)));
+ return infect(rb_str_new(buf, len), p);
+ }
+ if (EOS_P(p)) {
+ len = snprintf(buf, BUFSIZE, "#<%s fin>",
+ rb_class2name(CLASS_OF(self)));
+ return infect(rb_str_new(buf, len), p);
+ }
+ if (p->curr == 0) {
+ b = inspect2(p);
+ len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld @ %s>",
+ rb_class2name(CLASS_OF(self)),
+ p->curr, S_LEN(p),
+ RSTRING(b)->ptr);
+ return infect(rb_str_new(buf, len), p);
+ }
+ a = inspect1(p);
+ b = inspect2(p);
+ len = snprintf(buf, BUFSIZE, "#<%s %ld/%ld %s @ %s>",
+ rb_class2name(CLASS_OF(self)),
+ p->curr, S_LEN(p),
+ RSTRING(a)->ptr,
+ RSTRING(b)->ptr);
+ return infect(rb_str_new(buf, len), p);
+}
+
+static VALUE
+inspect1(p)
+ struct strscanner *p;
+{
+ char buf[BUFSIZE];
+ char *bp = buf;
+ long len;
+
+ if (p->curr == 0) return rb_str_new2("");
+ if (p->curr > INSPECT_LENGTH) {
+ strcpy(bp, "..."); bp += 3;
+ len = INSPECT_LENGTH;
+ }
+ else {
+ len = p->curr;
+ }
+ memcpy(bp, CURPTR(p) - len, len); bp += len;
+ return rb_str_dump(rb_str_new(buf, bp - buf));
+}
+
+static VALUE
+inspect2(p)
+ struct strscanner *p;
+{
+ char buf[BUFSIZE];
+ char *bp = buf;
+ long len;
+
+ if (EOS_P(p)) return rb_str_new2("");
+ len = S_LEN(p) - p->curr;
+ if (len > INSPECT_LENGTH) {
+ len = INSPECT_LENGTH;
+ memcpy(bp, CURPTR(p), len); bp += len;
+ strcpy(bp, "..."); bp += 3;
+ }
+ else {
+ memcpy(bp, CURPTR(p), len); bp += len;
+ }
+ return rb_str_dump(rb_str_new(buf, bp - buf));
+}
+
+/* =======================================================================
+ Ruby Interface
+ ======================================================================= */
+
+/*
+ * Document-class: StringScanner
+ *
+ * StringScanner provides for lexical scanning operations on a String. Here is
+ * an example of its usage:
+ *
+ * s = StringScanner.new('This is an example string')
+ * s.eos? # -> false
+ *
+ * p s.scan(/\w+/) # -> "This"
+ * p s.scan(/\w+/) # -> nil
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\s+/) # -> nil
+ * p s.scan(/\w+/) # -> "is"
+ * s.eos? # -> false
+ *
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "an"
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "example"
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "string"
+ * s.eos? # -> true
+ *
+ * p s.scan(/\s+/) # -> nil
+ * p s.scan(/\w+/) # -> nil
+ *
+ * Scanning a string means remembering the position of a <i>scan pointer</i>,
+ * which is just an index. The point of scanning is to move forward a bit at
+ * a time, so matches are sought after the scan pointer; usually immediately
+ * after it.
+ *
+ * Given the string "test string", here are the pertinent scan pointer
+ * positions:
+ *
+ * t e s t s t r i n g
+ * 0 1 2 ... 1
+ * 0
+ *
+ * When you #scan for a pattern (a regular expression), the match must occur
+ * at the character after the scan pointer. If you use #scan_until, then the
+ * match can occur anywhere after the scan pointer. In both cases, the scan
+ * pointer moves <i>just beyond</i> the last character of the match, ready to
+ * scan again from the next character onwards. This is demonstrated by the
+ * example above.
+ *
+ * == Method Categories
+ *
+ * There are other methods besides the plain scanners. You can look ahead in
+ * the string without actually scanning. You can access the most recent match.
+ * You can modify the string being scanned, reset or terminate the scanner,
+ * find out or change the position of the scan pointer, skip ahead, and so on.
+ *
+ * === Advancing the Scan Pointer
+ *
+ * - #getch
+ * - #getbyte
+ * - #scan
+ * - #scan_until
+ * - #skip
+ * - #skip_until
+ *
+ * === Looking Ahead
+ *
+ * - #check
+ * - #check_until
+ * - #exist?
+ * - #match?
+ * - #peek
+ *
+ * === Finding Where we Are
+ *
+ * - #bol?
+ * - #eos?
+ * - #rest?
+ * - #rest_size
+ * - #pos
+ *
+ * === Setting Where we Are
+ *
+ * - #reset
+ * - #terminate
+ * - #pos=
+ *
+ * === Match Data
+ *
+ * - #matched
+ * - #matched?
+ * - #matched_size
+ * - []
+ * - #pre_match
+ * - #post_match
+ *
+ * === Miscellaneous
+ *
+ * - <<
+ * - #concat
+ * - #string
+ * - #string=
+ * - #unscan
+ *
+ * There are aliases to several of the methods.
+ */
+void
+Init_strscan()
+{
+ ID id_scanerr = rb_intern("ScanError");
+ VALUE tmp;
+
+ StringScanner = rb_define_class("StringScanner", rb_cObject);
+ ScanError = rb_define_class_under(StringScanner, "Error", rb_eStandardError);
+ if (!rb_const_defined(rb_cObject, id_scanerr)) {
+ rb_const_set(rb_cObject, id_scanerr, ScanError);
+ }
+ tmp = rb_str_new2(STRSCAN_VERSION);
+ rb_obj_freeze(tmp);
+ rb_const_set(StringScanner, rb_intern("Version"), tmp);
+ tmp = rb_str_new2("$Id$");
+ rb_obj_freeze(tmp);
+ rb_const_set(StringScanner, rb_intern("Id"), tmp);
+
+ rb_define_alloc_func(StringScanner, strscan_s_allocate);
+ rb_define_private_method(StringScanner, "initialize", strscan_initialize, -1);
+ rb_define_singleton_method(StringScanner, "must_C_version", strscan_s_mustc, 0);
+ rb_define_method(StringScanner, "reset", strscan_reset, 0);
+ rb_define_method(StringScanner, "terminate", strscan_terminate, 0);
+ rb_define_method(StringScanner, "clear", strscan_clear, 0);
+ rb_define_method(StringScanner, "string", strscan_get_string, 0);
+ rb_define_method(StringScanner, "string=", strscan_set_string, 1);
+ rb_define_method(StringScanner, "concat", strscan_concat, 1);
+ rb_define_method(StringScanner, "<<", strscan_concat, 1);
+ rb_define_method(StringScanner, "pos", strscan_get_pos, 0);
+ rb_define_method(StringScanner, "pos=", strscan_set_pos, 1);
+ rb_define_method(StringScanner, "pointer", strscan_get_pos, 0);
+ rb_define_method(StringScanner, "pointer=", strscan_set_pos, 1);
+
+ rb_define_method(StringScanner, "scan", strscan_scan, 1);
+ rb_define_method(StringScanner, "skip", strscan_skip, 1);
+ rb_define_method(StringScanner, "match?", strscan_match_p, 1);
+ rb_define_method(StringScanner, "check", strscan_check, 1);
+ rb_define_method(StringScanner, "scan_full", strscan_scan_full, 3);
+
+ rb_define_method(StringScanner, "scan_until", strscan_scan_until, 1);
+ rb_define_method(StringScanner, "skip_until", strscan_skip_until, 1);
+ rb_define_method(StringScanner, "exist?", strscan_exist_p, 1);
+ rb_define_method(StringScanner, "check_until", strscan_check_until, 1);
+ rb_define_method(StringScanner, "search_full", strscan_search_full, 3);
+
+ rb_define_method(StringScanner, "getch", strscan_getch, 0);
+ rb_define_method(StringScanner, "get_byte", strscan_get_byte, 0);
+ rb_define_method(StringScanner, "getbyte", strscan_getbyte, 0);
+ rb_define_method(StringScanner, "peek", strscan_peek, 1);
+ rb_define_method(StringScanner, "peep", strscan_peep, 1);
+
+ rb_define_method(StringScanner, "unscan", strscan_unscan, 0);
+
+ rb_define_method(StringScanner, "beginning_of_line?", strscan_bol_p, 0);
+ rb_define_method(StringScanner, "bol?", strscan_bol_p, 0);
+ rb_define_method(StringScanner, "eos?", strscan_eos_p, 0);
+ rb_define_method(StringScanner, "empty?", strscan_empty_p, 0);
+ rb_define_method(StringScanner, "rest?", strscan_rest_p, 0);
+
+ rb_define_method(StringScanner, "matched?", strscan_matched_p, 0);
+ rb_define_method(StringScanner, "matched", strscan_matched, 0);
+ rb_define_method(StringScanner, "matched_size", strscan_matched_size, 0);
+ rb_define_method(StringScanner, "matchedsize", strscan_matchedsize, 0);
+ rb_define_method(StringScanner, "[]", strscan_aref, 1);
+ rb_define_method(StringScanner, "pre_match", strscan_pre_match, 0);
+ rb_define_method(StringScanner, "post_match", strscan_post_match, 0);
+
+ rb_define_method(StringScanner, "rest", strscan_rest, 0);
+ rb_define_method(StringScanner, "rest_size", strscan_rest_size, 0);
+ rb_define_method(StringScanner, "restsize", strscan_restsize, 0);
+
+ rb_define_method(StringScanner, "inspect", strscan_inspect, 0);
+}
diff --git a/ext/syck/.cvsignore b/ext/syck/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/syck/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/syck/bytecode.c b/ext/syck/bytecode.c
new file mode 100644
index 0000000000..ae5f19d7da
--- /dev/null
+++ b/ext/syck/bytecode.c
@@ -0,0 +1,1171 @@
+/* Generated by re2c 0.9.3 on Fri Aug 13 11:47:50 2004 */
+#line 1 "bytecode.re"
+/*
+ * bytecode.re
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+#include "ruby.h"
+#include "syck.h"
+#include "gram.h"
+
+#define QUOTELEN 128
+
+/*
+ * They do my bidding...
+ */
+#define YYCTYPE char
+#define YYCURSOR parser->cursor
+#define YYMARKER parser->marker
+#define YYLIMIT parser->limit
+#define YYTOKEN parser->token
+#define YYTOKTMP parser->toktmp
+#define YYLINEPTR parser->lineptr
+#define YYLINECTPTR parser->linectptr
+#define YYLINE parser->linect
+#define YYFILL(n) syck_parser_read(parser)
+
+extern SyckParser *syck_parser_ptr;
+
+char *get_inline( SyckParser *parser );
+
+/*
+ * Repositions the cursor at `n' offset from the token start.
+ * Only works in `Header' and `Document' sections.
+ */
+#define YYPOS(n) YYCURSOR = YYTOKEN + n
+
+/*
+ * Track line numbers
+ */
+#define CHK_NL(ptr) if ( *( ptr - 1 ) == '\n' && ptr > YYLINECTPTR ) { YYLINEPTR = ptr; YYLINE++; YYLINECTPTR = YYLINEPTR; }
+
+/*
+ * I like seeing the level operations as macros...
+ */
+#define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status )
+#define POP_LEVEL() syck_parser_pop_level( parser )
+#define CURRENT_LEVEL() syck_parser_current_level( parser )
+
+/*
+ * Force a token next time around sycklex()
+ */
+#define FORCE_NEXT_TOKEN(tok) parser->force_token = tok;
+
+/*
+ * Adding levels in bytecode requires us to make sure
+ * we've got all our tokens worked out.
+ */
+#define ADD_BYTE_LEVEL(lvl, len, s ) \
+ switch ( lvl->status ) \
+ { \
+ case syck_lvl_seq: \
+ lvl->ncount++; \
+ ADD_LEVEL(len, syck_lvl_open); \
+ YYPOS(0); \
+ return '-'; \
+ \
+ case syck_lvl_map: \
+ lvl->ncount++; \
+ ADD_LEVEL(len, s); \
+ break; \
+ \
+ case syck_lvl_open: \
+ lvl->status = s; \
+ break; \
+ \
+ default: \
+ ADD_LEVEL(len, s); \
+ break; \
+ }
+
+/*
+ * Nice little macro to ensure we're YAML_IOPENed to the current level.
+ * * Only use this macro in the "Document" section *
+ */
+#define ENSURE_YAML_IOPEN(last_lvl, lvl_type, to_len, reset) \
+ if ( last_lvl->spaces < to_len ) \
+ { \
+ if ( last_lvl->status == syck_lvl_inline ) \
+ { \
+ goto Document; \
+ } \
+ else \
+ { \
+ ADD_LEVEL( to_len, lvl_type ); \
+ if ( reset == 1 ) YYPOS(0); \
+ return YAML_IOPEN; \
+ } \
+ }
+
+/*
+ * Nice little macro to ensure closure of levels.
+ * * Only use this macro in the "Document" section *
+ */
+#define ENSURE_YAML_IEND(last_lvl, to_len) \
+ if ( last_lvl->spaces > to_len ) \
+ { \
+ syck_parser_pop_level( parser ); \
+ YYPOS(0); \
+ return YAML_IEND; \
+ }
+
+/*
+ * Concatenates string items and manages allocation
+ * to the string
+ */
+#define CAT(s, c, i, l) \
+ { \
+ if ( i + 1 >= c ) \
+ { \
+ c += QUOTELEN; \
+ S_REALLOC_N( s, char, c ); \
+ } \
+ s[i++] = l; \
+ s[i] = '\0'; \
+ }
+
+/*
+ * Parser for standard YAML Bytecode [UTF-8]
+ */
+int
+sycklex_bytecode_utf8( YYSTYPE *sycklval, SyckParser *parser )
+{
+ SyckLevel *lvl;
+ int doc_level = 0;
+ syck_parser_ptr = parser;
+ if ( YYCURSOR == NULL )
+ {
+ syck_parser_read( parser );
+ }
+
+ if ( parser->force_token != 0 )
+ {
+ int t = parser->force_token;
+ parser->force_token = 0;
+ return t;
+ }
+
+#line 173 "bytecode.re"
+
+
+ lvl = CURRENT_LEVEL();
+ if ( lvl->status == syck_lvl_doc )
+ {
+ goto Document;
+ }
+
+Header:
+
+ YYTOKEN = YYCURSOR;
+
+
+#line 7 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy0;
+yy1: ++YYCURSOR;
+yy0:
+ if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy2;
+ case 'D': goto yy3;
+ default: goto yy5;
+ }
+yy2: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy4;
+ }
+yy3: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy6;
+ case '\r': goto yy8;
+ default: goto yy4;
+ }
+yy4:
+#line 200 "bytecode.re"
+{ YYPOS(0);
+ goto Document;
+ }
+#line 37 "<stdout>"
+yy5: yych = *++YYCURSOR;
+ goto yy4;
+yy6: ++YYCURSOR;
+ goto yy7;
+yy7:
+#line 187 "bytecode.re"
+{ if ( lvl->status == syck_lvl_header )
+ {
+ CHK_NL(YYCURSOR);
+ goto Directive;
+ }
+ else
+ {
+ ENSURE_YAML_IEND(lvl, -1);
+ YYPOS(0);
+ return 0;
+ }
+ }
+#line 56 "<stdout>"
+yy8: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy6;
+ default: goto yy2;
+ }
+}
+#line 204 "bytecode.re"
+
+
+Document:
+ {
+ lvl = CURRENT_LEVEL();
+ if ( lvl->status == syck_lvl_header )
+ {
+ lvl->status = syck_lvl_doc;
+ }
+
+ YYTOKEN = YYCURSOR;
+
+
+#line 65 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy9;
+yy10: ++YYCURSOR;
+yy9:
+ if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy30;
+ case '\n': goto yy27;
+ case '\r': goto yy29;
+ case 'A': goto yy19;
+ case 'D': goto yy12;
+ case 'E': goto yy16;
+ case 'M': goto yy14;
+ case 'P': goto yy13;
+ case 'Q': goto yy15;
+ case 'R': goto yy21;
+ case 'S': goto yy17;
+ case 'T': goto yy23;
+ case 'c': goto yy25;
+ default: goto yy11;
+ }
+yy11:yy12: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy41;
+ case '\r': goto yy44;
+ default: goto yy11;
+ }
+yy13: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy41;
+ case '\r': goto yy43;
+ default: goto yy11;
+ }
+yy14: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy38;
+ case '\r': goto yy40;
+ default: goto yy11;
+ }
+yy15: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy35;
+ case '\r': goto yy37;
+ default: goto yy11;
+ }
+yy16: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy32;
+ case '\r': goto yy34;
+ default: goto yy11;
+ }
+yy17: ++YYCURSOR;
+ goto yy18;
+yy18:
+#line 289 "bytecode.re"
+{ ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str);
+ goto Scalar;
+ }
+#line 127 "<stdout>"
+yy19: ++YYCURSOR;
+ goto yy20;
+yy20:
+#line 293 "bytecode.re"
+{ ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open);
+ sycklval->name = get_inline( parser );
+ syck_hdlr_remove_anchor( parser, sycklval->name );
+ CHK_NL(YYCURSOR);
+ return YAML_ANCHOR;
+ }
+#line 138 "<stdout>"
+yy21: ++YYCURSOR;
+ goto yy22;
+yy22:
+#line 300 "bytecode.re"
+{ ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_str);
+ sycklval->name = get_inline( parser );
+ POP_LEVEL();
+ if ( *( YYCURSOR - 1 ) == '\n' ) YYCURSOR--;
+ return YAML_ALIAS;
+ }
+#line 149 "<stdout>"
+yy23: ++YYCURSOR;
+ goto yy24;
+yy24:
+#line 307 "bytecode.re"
+{ char *qstr;
+ ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_open);
+ qstr = get_inline( parser );
+ CHK_NL(YYCURSOR);
+ if ( qstr[0] == '!' )
+ {
+ int qidx = strlen( qstr );
+ if ( qstr[1] == '\0' )
+ {
+ free( qstr );
+ return YAML_ITRANSFER;
+ }
+
+ lvl = CURRENT_LEVEL();
+
+ /*
+ * URL Prefixing
+ */
+ if ( qstr[1] == '^' )
+ {
+ sycklval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) );
+ sycklval->name[0] = '\0';
+ strcat( sycklval->name, lvl->domain );
+ strncat( sycklval->name, qstr + 2, qidx - 2 );
+ free( qstr );
+ }
+ else
+ {
+ char *carat = qstr + 1;
+ char *qend = qstr + qidx;
+ while ( (++carat) < qend )
+ {
+ if ( *carat == '^' )
+ break;
+ }
+
+ if ( carat < qend )
+ {
+ free( lvl->domain );
+ lvl->domain = syck_strndup( qstr + 1, carat - ( qstr + 1 ) );
+ sycklval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) );
+ sycklval->name[0] = '\0';
+ strcat( sycklval->name, lvl->domain );
+ strncat( sycklval->name, carat + 1, ( qend - carat ) - 1 );
+ free( qstr );
+ }
+ else
+ {
+ sycklval->name = S_ALLOC_N( char, strlen( qstr ) );
+ sycklval->name[0] = '\0';
+ S_MEMCPY( sycklval->name, qstr + 1, char, strlen( qstr ) );
+ free( qstr );
+ }
+ }
+ return YAML_TRANSFER;
+ }
+ sycklval->name = qstr;
+ return YAML_TAGURI;
+ }
+#line 213 "<stdout>"
+yy25: ++YYCURSOR;
+ goto yy26;
+yy26:
+#line 367 "bytecode.re"
+{ goto Comment; }
+#line 219 "<stdout>"
+yy27: ++YYCURSOR;
+ goto yy28;
+yy28:
+#line 369 "bytecode.re"
+{ CHK_NL(YYCURSOR);
+ if ( lvl->status == syck_lvl_seq )
+ {
+ return YAML_INDENT;
+ }
+ else if ( lvl->status == syck_lvl_map )
+ {
+ if ( lvl->ncount % 2 == 1 ) return ':';
+ else return YAML_INDENT;
+ }
+ goto Document;
+ }
+#line 236 "<stdout>"
+yy29: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy27;
+ default: goto yy11;
+ }
+yy30: ++YYCURSOR;
+ goto yy31;
+yy31:
+#line 382 "bytecode.re"
+{ ENSURE_YAML_IEND(lvl, -1);
+ YYPOS(0);
+ return 0;
+ }
+#line 250 "<stdout>"
+yy32: ++YYCURSOR;
+ goto yy33;
+yy33:
+#line 253 "bytecode.re"
+{ if ( lvl->status == syck_lvl_seq && lvl->ncount == 0 )
+ {
+ lvl->ncount++;
+ YYPOS(0);
+ FORCE_NEXT_TOKEN( ']' );
+ return '[';
+ }
+ else if ( lvl->status == syck_lvl_map && lvl->ncount == 0 )
+ {
+ lvl->ncount++;
+ YYPOS(0);
+ FORCE_NEXT_TOKEN( '}' );
+ return '{';
+ }
+
+ POP_LEVEL();
+ lvl = CURRENT_LEVEL();
+ if ( lvl->status == syck_lvl_seq )
+ {
+ FORCE_NEXT_TOKEN(YAML_INDENT);
+ }
+ else if ( lvl->status == syck_lvl_map )
+ {
+ if ( lvl->ncount % 2 == 1 )
+ {
+ FORCE_NEXT_TOKEN(':');
+ }
+ else
+ {
+ FORCE_NEXT_TOKEN(YAML_INDENT);
+ }
+ }
+ CHK_NL(YYCURSOR);
+ return YAML_IEND;
+ }
+#line 290 "<stdout>"
+yy34: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy32;
+ default: goto yy11;
+ }
+yy35: ++YYCURSOR;
+ goto yy36;
+yy36:
+#line 238 "bytecode.re"
+{ int complex = 0;
+ if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) )
+ {
+ complex = 1;
+ }
+ ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_seq);
+ CHK_NL(YYCURSOR);
+ if ( complex )
+ {
+ FORCE_NEXT_TOKEN( YAML_IOPEN );
+ return '?';
+ }
+ return YAML_IOPEN;
+ }
+#line 314 "<stdout>"
+yy37: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy35;
+ default: goto yy11;
+ }
+yy38: ++YYCURSOR;
+ goto yy39;
+yy39:
+#line 223 "bytecode.re"
+{ int complex = 0;
+ if ( lvl->ncount % 2 == 0 && ( lvl->status == syck_lvl_map || lvl->status == syck_lvl_seq ) )
+ {
+ complex = 1;
+ }
+ ADD_BYTE_LEVEL(lvl, lvl->spaces + 1, syck_lvl_map);
+ CHK_NL(YYCURSOR);
+ if ( complex )
+ {
+ FORCE_NEXT_TOKEN( YAML_IOPEN );
+ return '?';
+ }
+ return YAML_IOPEN;
+ }
+#line 338 "<stdout>"
+yy40: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy38;
+ default: goto yy11;
+ }
+yy41: ++YYCURSOR;
+ goto yy42;
+yy42:
+#line 218 "bytecode.re"
+{ ENSURE_YAML_IEND(lvl, -1);
+ YYPOS(0);
+ return 0;
+ }
+#line 352 "<stdout>"
+yy43: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy41;
+ default: goto yy11;
+ }
+yy44: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy41;
+ default: goto yy11;
+ }
+}
+#line 387 "bytecode.re"
+
+
+ }
+
+Directive:
+ {
+ YYTOKEN = YYCURSOR;
+
+
+#line 366 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy45;
+yy46: ++YYCURSOR;
+yy45:
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy47;
+ case 'V': goto yy48;
+ default: goto yy50;
+ }
+yy47: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy49;
+ }
+yy48: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy51;
+ default: goto yy49;
+ }
+yy49:
+#line 400 "bytecode.re"
+{ YYCURSOR = YYTOKEN;
+ return YAML_DOCSEP;
+ }
+#line 469 "<stdout>"
+yy50: yych = *++YYCURSOR;
+ goto yy49;
+yy51: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy52;
+yy52: switch(yych){
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy51;
+ case ':': goto yy53;
+ default: goto yy47;
+ }
+yy53: yych = *++YYCURSOR;
+ switch(yych){
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy54;
+ default: goto yy47;
+ }
+yy54: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy55;
+yy55: switch(yych){
+ case '\n': goto yy56;
+ case '\r': goto yy58;
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy54;
+ default: goto yy47;
+ }
+yy56: ++YYCURSOR;
+ goto yy57;
+yy57:
+#line 397 "bytecode.re"
+{ CHK_NL(YYCURSOR);
+ goto Directive; }
+#line 724 "<stdout>"
+yy58: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy56;
+ default: goto yy47;
+ }
+}
+#line 403 "bytecode.re"
+
+
+ }
+
+Comment:
+ {
+ YYTOKEN = YYCURSOR;
+
+
+#line 733 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy59;
+yy60: ++YYCURSOR;
+yy59:
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy61;
+ case '\n': goto yy62;
+ case '\r': goto yy64;
+ default: goto yy66;
+ }
+yy61:yy62: ++YYCURSOR;
+ goto yy63;
+yy63:
+#line 413 "bytecode.re"
+{ CHK_NL(YYCURSOR);
+ goto Document; }
+#line 754 "<stdout>"
+yy64: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy67;
+ default: goto yy65;
+ }
+yy65:
+#line 416 "bytecode.re"
+{ goto Comment; }
+#line 763 "<stdout>"
+yy66: yych = *++YYCURSOR;
+ goto yy65;
+yy67: ++YYCURSOR;
+ yych = *YYCURSOR;
+ goto yy63;
+}
+#line 418 "bytecode.re"
+
+
+ }
+
+Scalar:
+ {
+ int idx = 0;
+ int cap = 100;
+ char *str = S_ALLOC_N( char, cap );
+ char *tok;
+
+ str[0] = '\0';
+
+Scalar2:
+ tok = YYCURSOR;
+
+
+#line 771 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy68;
+yy69: ++YYCURSOR;
+yy68:
+ if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy74;
+ case '\n': goto yy70;
+ case '\r': goto yy72;
+ default: goto yy76;
+ }
+yy70: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case 'C': goto yy78;
+ case 'N': goto yy80;
+ case 'Z': goto yy83;
+ default: goto yy71;
+ }
+yy71:
+#line 462 "bytecode.re"
+{ YYCURSOR = tok;
+ goto ScalarEnd;
+ }
+#line 798 "<stdout>"
+yy72: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy77;
+ default: goto yy73;
+ }
+yy73:
+#line 470 "bytecode.re"
+{ CAT(str, cap, idx, tok[0]);
+ goto Scalar2;
+ }
+#line 809 "<stdout>"
+yy74: ++YYCURSOR;
+ goto yy75;
+yy75:
+#line 466 "bytecode.re"
+{ YYCURSOR = tok;
+ goto ScalarEnd;
+ }
+#line 817 "<stdout>"
+yy76: yych = *++YYCURSOR;
+ goto yy73;
+yy77: yych = *++YYCURSOR;
+ switch(yych){
+ case 'C': goto yy78;
+ case 'N': goto yy80;
+ case 'Z': goto yy83;
+ default: goto yy71;
+ }
+yy78: ++YYCURSOR;
+ goto yy79;
+yy79:
+#line 436 "bytecode.re"
+{ CHK_NL(tok+1);
+ goto Scalar2; }
+#line 833 "<stdout>"
+yy80: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy81;
+yy81: switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy80;
+ default: goto yy82;
+ }
+yy82:
+#line 439 "bytecode.re"
+{ CHK_NL(tok+1);
+ if ( tok + 2 < YYCURSOR )
+ {
+ char *count = tok + 2;
+ int total = strtod( count, NULL );
+ int i;
+ for ( i = 0; i < total; i++ )
+ {
+ CAT(str, cap, idx, '\n');
+ }
+ }
+ else
+ {
+ CAT(str, cap, idx, '\n');
+ }
+ goto Scalar2;
+ }
+#line 871 "<stdout>"
+yy83: ++YYCURSOR;
+ goto yy84;
+yy84:
+#line 457 "bytecode.re"
+{ CHK_NL(tok+1);
+ CAT(str, cap, idx, '\0');
+ goto Scalar2;
+ }
+#line 880 "<stdout>"
+}
+#line 474 "bytecode.re"
+
+
+ScalarEnd:
+ {
+ SyckNode *n = syck_alloc_str();
+ n->data.str->ptr = str;
+ n->data.str->len = idx;
+ sycklval->nodeData = n;
+ POP_LEVEL();
+ if ( parser->implicit_typing == 1 )
+ {
+ try_tag_implicit( sycklval->nodeData, parser->taguri_expansion );
+ }
+ return YAML_PLAIN;
+ }
+ }
+
+}
+
+char *
+get_inline( SyckParser *parser )
+{
+ int idx = 0;
+ int cap = 100;
+ char *str = S_ALLOC_N( char, cap );
+ char *tok;
+
+ str[0] = '\0';
+
+Inline:
+ {
+ tok = YYCURSOR;
+
+
+#line 884 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy85;
+yy86: ++YYCURSOR;
+yy85:
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy91;
+ case '\n': goto yy87;
+ case '\r': goto yy89;
+ default: goto yy93;
+ }
+yy87: ++YYCURSOR;
+ goto yy88;
+yy88:
+#line 509 "bytecode.re"
+{ CHK_NL(YYCURSOR);
+ return str; }
+#line 905 "<stdout>"
+yy89: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy94;
+ default: goto yy90;
+ }
+yy90:
+#line 516 "bytecode.re"
+{ CAT(str, cap, idx, tok[0]);
+ goto Inline;
+ }
+#line 916 "<stdout>"
+yy91: ++YYCURSOR;
+ goto yy92;
+yy92:
+#line 512 "bytecode.re"
+{ YYCURSOR = tok;
+ return str;
+ }
+#line 924 "<stdout>"
+yy93: yych = *++YYCURSOR;
+ goto yy90;
+yy94: ++YYCURSOR;
+ yych = *YYCURSOR;
+ goto yy88;
+}
+#line 520 "bytecode.re"
+
+
+ }
+
+}
+
diff --git a/ext/syck/depend b/ext/syck/depend
new file mode 100644
index 0000000000..3eec4de72a
--- /dev/null
+++ b/ext/syck/depend
@@ -0,0 +1,12 @@
+ruby_headers = $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h \
+ $(hdrdir)/missing.h $(hdrdir)/intern.h $(hdrdir)/st.h
+bytecode.o: bytecode.c syck.h gram.h $(ruby_headers)
+emitter.o: emitter.c syck.h $(ruby_headers)
+gram.o: gram.c syck.h $(hdrdir)/st.h
+handler.o: handler.c syck.h $(ruby_headers)
+implicit.o: implicit.c syck.h $(ruby_headers)
+node.o: node.c syck.h $(ruby_headers)
+rubyext.o: rubyext.c syck.h $(ruby_headers)
+syck.o: syck.c syck.h $(ruby_headers)
+token.o: token.c syck.h gram.h $(ruby_headers)
+yaml2byte.o: yaml2byte.c syck.h yamlbyte.h $(ruby_headers)
diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c
new file mode 100644
index 0000000000..25437b230c
--- /dev/null
+++ b/ext/syck/emitter.c
@@ -0,0 +1,444 @@
+/*
+ * emitter.c
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ *
+ * All Base64 code from Ruby's pack.c.
+ * Ruby is Copyright (C) 1993-2003 Yukihiro Matsumoto
+ */
+#include "ruby.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "syck.h"
+
+#define DEFAULT_ANCHOR_FORMAT "id%03d"
+
+static char b64_table[] =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+struct adjust_arg {
+ /* Position to start adjusting */
+ long startpos;
+ /* Adjusting by an offset */
+ int offset;
+};
+
+/*
+ * Built-in base64 (from Ruby's pack.c)
+ */
+char *
+syck_base64enc( char *s, long len )
+{
+ long i = 0;
+ int padding = '=';
+ char *buff = S_ALLOCA_N(char, len * 4 / 3 + 6);
+
+ while (len >= 3) {
+ buff[i++] = b64_table[077 & (*s >> 2)];
+ buff[i++] = b64_table[077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017))];
+ buff[i++] = b64_table[077 & (((s[1] << 2) & 074) | ((s[2] >> 6) & 03))];
+ buff[i++] = b64_table[077 & s[2]];
+ s += 3;
+ len -= 3;
+ }
+ if (len == 2) {
+ buff[i++] = b64_table[077 & (*s >> 2)];
+ buff[i++] = b64_table[077 & (((*s << 4) & 060) | ((s[1] >> 4) & 017))];
+ buff[i++] = b64_table[077 & (((s[1] << 2) & 074) | (('\0' >> 6) & 03))];
+ buff[i++] = padding;
+ }
+ else if (len == 1) {
+ buff[i++] = b64_table[077 & (*s >> 2)];
+ buff[i++] = b64_table[077 & (((*s << 4) & 060) | (('\0' >> 4) & 017))];
+ buff[i++] = padding;
+ buff[i++] = padding;
+ }
+ buff[i++] = '\n';
+ return buff;
+}
+
+char *
+syck_base64dec( char *s, long len )
+{
+ int a = -1,b = -1,c = 0,d;
+ static int first = 1;
+ static int b64_xtable[256];
+ char *ptr = syck_strndup( s, len );
+ char *end = ptr;
+ char *send = s + len;
+
+ if (first) {
+ int i;
+ first = 0;
+
+ for (i = 0; i < 256; i++) {
+ b64_xtable[i] = -1;
+ }
+ for (i = 0; i < 64; i++) {
+ b64_xtable[(int)b64_table[i]] = i;
+ }
+ }
+ while (s < send) {
+ while (s[0] == '\r' || s[0] == '\n') { s++; }
+ if ((a = b64_xtable[(int)s[0]]) == -1) break;
+ if ((b = b64_xtable[(int)s[1]]) == -1) break;
+ if ((c = b64_xtable[(int)s[2]]) == -1) break;
+ if ((d = b64_xtable[(int)s[3]]) == -1) break;
+ *end++ = a << 2 | b >> 4;
+ *end++ = b << 4 | c >> 2;
+ *end++ = c << 6 | d;
+ s += 4;
+ }
+ if (a != -1 && b != -1) {
+ if (s + 2 < send && s[2] == '=')
+ *end++ = a << 2 | b >> 4;
+ if (c != -1 && s + 3 < send && s[3] == '=') {
+ *end++ = a << 2 | b >> 4;
+ *end++ = b << 4 | c >> 2;
+ }
+ }
+ *end = '\0';
+ /*RSTRING(buf)->len = ptr - RSTRING(buf)->ptr;*/
+ return ptr;
+}
+
+/*
+ * Allocate an emitter
+ */
+SyckEmitter *
+syck_new_emitter()
+{
+ SyckEmitter *e;
+ e = S_ALLOC( SyckEmitter );
+ e->headless = 0;
+ e->seq_map = 0;
+ e->use_header = 0;
+ e->use_version = 0;
+ e->sort_keys = 0;
+ e->anchor_format = NULL;
+ e->explicit_typing = 0;
+ e->best_width = 80;
+ e->block_style = block_arbitrary;
+ e->stage = doc_open;
+ e->indent = 2;
+ e->level = -1;
+ e->ignore_id = 0;
+ e->anchors = NULL;
+ e->markers = NULL;
+ e->bufsize = SYCK_BUFFERSIZE;
+ e->buffer = NULL;
+ e->marker = NULL;
+ e->bufpos = 0;
+ e->handler = NULL;
+ e->bonus = NULL;
+ return e;
+}
+
+int
+syck_st_free_anchors( char *key, char *name, char *arg )
+{
+ S_FREE( name );
+ return ST_CONTINUE;
+}
+
+int
+syck_st_free_markers( char *key, SyckEmitterNode *n, char *arg )
+{
+ S_FREE( n );
+ return ST_CONTINUE;
+}
+
+void
+syck_emitter_st_free( SyckEmitter *e )
+{
+ /*
+ * Free the anchor tables
+ */
+ if ( e->anchors != NULL )
+ {
+ st_foreach( e->anchors, syck_st_free_anchors, 0 );
+ st_free_table( e->anchors );
+ e->anchors = NULL;
+ }
+
+ /*
+ * Free the markers tables
+ */
+ if ( e->markers != NULL )
+ {
+ st_foreach( e->markers, syck_st_free_markers, 0 );
+ st_free_table( e->markers );
+ e->markers = NULL;
+ }
+}
+
+void
+syck_emitter_ignore_id( SyckEmitter *e, SYMID id )
+{
+ e->ignore_id = id;
+}
+
+void
+syck_emitter_handler( SyckEmitter *e, SyckOutputHandler hdlr )
+{
+ e->handler = hdlr;
+}
+
+void
+syck_free_emitter( SyckEmitter *e )
+{
+ /*
+ * Free tables
+ */
+ syck_emitter_st_free( e );
+ if ( e->buffer != NULL )
+ {
+ S_FREE( e->buffer );
+ }
+ S_FREE( e );
+}
+
+void
+syck_emitter_clear( SyckEmitter *e )
+{
+ if ( e->buffer == NULL )
+ {
+ e->buffer = S_ALLOC_N( char, e->bufsize );
+ S_MEMZERO( e->buffer, char, e->bufsize );
+ }
+ e->buffer[0] = '\0';
+ e->marker = e->buffer;
+ e->bufpos = 0;
+}
+
+/*
+ * Raw write to the emitter buffer.
+ */
+void
+syck_emitter_write( SyckEmitter *e, char *str, long len )
+{
+ long at;
+ ASSERT( str != NULL )
+ if ( e->buffer == NULL )
+ {
+ syck_emitter_clear( e );
+ }
+
+ /*
+ * Flush if at end of buffer
+ */
+ at = e->marker - e->buffer;
+ if ( len + at >= e->bufsize )
+ {
+ syck_emitter_flush( e, 0 );
+ for (;;) {
+ long rest = e->bufsize - (e->marker - e->buffer);
+ if (len <= rest) break;
+ S_MEMCPY( e->marker, str, char, rest );
+ e->marker += rest;
+ str += rest;
+ len -= rest;
+ syck_emitter_flush( e, 0 );
+ }
+ }
+
+ /*
+ * Write to buffer
+ */
+ S_MEMCPY( e->marker, str, char, len );
+ e->marker += len;
+}
+
+/*
+ * Write a chunk of data out.
+ */
+void
+syck_emitter_flush( SyckEmitter *e, long check_room )
+{
+ /*
+ * Check for enough space in the buffer for check_room length.
+ */
+ if ( check_room > 0 )
+ {
+ if ( e->bufsize > ( e->marker - e->buffer ) + check_room )
+ {
+ return;
+ }
+ }
+ else
+ {
+ check_room = e->bufsize;
+ }
+
+ /*
+ * Determine headers.
+ */
+ if ( ( e->stage == doc_open && ( e->headless == 0 || e->use_header == 1 ) ) ||
+ e->stage == doc_need_header )
+ {
+ if ( e->use_version == 1 )
+ {
+ char *header = S_ALLOC_N( char, 64 );
+ S_MEMZERO( header, char, 64 );
+ sprintf( header, "--- %%YAML:%d.%d ", SYCK_YAML_MAJOR, SYCK_YAML_MINOR );
+ (e->handler)( e, header, strlen( header ) );
+ S_FREE( header );
+ }
+ else
+ {
+ (e->handler)( e, "--- ", 4 );
+ }
+ e->stage = doc_processing;
+ }
+
+ /*
+ * Commit buffer.
+ */
+ if ( check_room > e->marker - e->buffer )
+ {
+ check_room = e->marker - e->buffer;
+ }
+ (e->handler)( e, e->buffer, check_room );
+ e->bufpos += check_room;
+ e->marker -= check_room;
+}
+
+/*
+ * Emit a simple, unquoted string.
+ */
+void
+syck_emitter_simple( SyckEmitter *e, char *str, long len )
+{
+ e->seq_map = 0;
+ syck_emitter_write( e, str, len );
+}
+
+/*
+ * Shift the offsets of all applicable anchors
+ */
+int
+syck_adjust_anchors( char *key, SyckEmitterNode *n, struct adjust_arg *arg )
+{
+ if ( arg->startpos < n->pos )
+ {
+ n->pos += arg->offset;
+ }
+ return ST_CONTINUE;
+}
+
+/*
+ * call on start of an object's marshalling
+ * (handles anchors, returns an alias)
+ */
+char *
+syck_emitter_start_obj( SyckEmitter *e, SYMID oid )
+{
+ SyckEmitterNode *n = NULL;
+ char *anchor_name = NULL;
+
+ e->level++;
+ if ( oid != e->ignore_id )
+ {
+ /*
+ * Look for anchors
+ */
+ if ( e->markers == NULL )
+ {
+ e->markers = st_init_numtable();
+ }
+
+ /*
+ * Markers table initially marks the string position of the
+ * object. Doesn't yet create an anchor, simply notes the
+ * position.
+ */
+ if ( ! st_lookup( e->markers, (st_data_t)oid, (st_data_t *)&n ) )
+ {
+ /*
+ * Store all markers
+ */
+ n = S_ALLOC( SyckEmitterNode );
+ n->is_shortcut = 0;
+ n->indent = e->level * e->indent;
+ n->pos = e->bufpos + ( e->marker - e->buffer );
+ st_insert( e->markers, (st_data_t)oid, (st_data_t)n );
+ }
+ else
+ {
+ if ( e->anchors == NULL )
+ {
+ e->anchors = st_init_numtable();
+ }
+
+ if ( ! st_lookup( e->anchors, (st_data_t)oid, (st_data_t *)&anchor_name ) )
+ {
+ int idx = 0;
+ /*
+ * Second time hitting this object, let's give it an anchor
+ */
+ idx = e->anchors->num_entries + 1;
+
+ /*
+ * Create the anchor tag
+ */
+ if ( n->pos >= e->bufpos )
+ {
+ int alen;
+ struct adjust_arg *args = S_ALLOC( struct adjust_arg );
+ char *start = e->buffer + ( n->pos - e->bufpos );
+
+ char *anc = ( e->anchor_format == NULL ? DEFAULT_ANCHOR_FORMAT : e->anchor_format );
+ anchor_name = S_ALLOC_N( char, strlen( anc ) + 10 );
+ S_MEMZERO( anchor_name, char, strlen( anc ) + 10 );
+ sprintf( anchor_name, anc, idx );
+
+ /*
+ * Need to flush the buffer some, if there is not room for the anchor.
+ */
+ alen = strlen( anchor_name ) + 2;
+ syck_emitter_flush( e, alen );
+
+ /*
+ * Write the anchor into the buffer
+ */
+ S_MEMMOVE( start + alen, start, char, e->marker - start );
+ S_MEMCPY( start + 1, anchor_name, char, strlen( anchor_name ) );
+ start[0] = '&';
+ start[alen - 1] = ' ';
+ e->marker += alen;
+
+ /*
+ * Cycle through anchors, modify for the size of the anchor.
+ */
+ args->startpos = n->pos;
+ args->offset = alen;
+ st_foreach( e->markers, syck_adjust_anchors, (st_data_t)args );
+ S_FREE( args );
+
+ /*
+ * Insert into anchors table
+ */
+ st_insert( e->anchors, (st_data_t)oid, (st_data_t)anchor_name );
+ }
+ }
+
+ }
+ }
+
+ return anchor_name;
+}
+
+/*
+ * call on completion of an object's marshalling
+ */
+void
+syck_emitter_end_obj( SyckEmitter *e )
+{
+ e->level--;
+}
+
diff --git a/ext/syck/extconf.rb b/ext/syck/extconf.rb
new file mode 100644
index 0000000000..6c10448c70
--- /dev/null
+++ b/ext/syck/extconf.rb
@@ -0,0 +1,5 @@
+require 'mkmf'
+
+have_header( "st.h" )
+create_makefile( "syck" )
+
diff --git a/ext/syck/gram.c b/ext/syck/gram.c
new file mode 100644
index 0000000000..dd65ea1deb
--- /dev/null
+++ b/ext/syck/gram.c
@@ -0,0 +1,1796 @@
+/* A Bison parser, made from gram.y, by GNU bison 1.75. */
+
+/* Skeleton parser for Yacc-like parsing with Bison,
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+/* Written by Richard Stallman by simplifying the original so called
+ ``semantic'' parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Pure parsers. */
+#define YYPURE 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* If NAME_PREFIX is specified substitute the variables and functions
+ names. */
+#define yyparse syckparse
+#define yylex sycklex
+#define yyerror syckerror
+#define yylval sycklval
+#define yychar syckchar
+#define yydebug syckdebug
+#define yynerrs sycknerrs
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ YAML_ANCHOR = 258,
+ YAML_ALIAS = 259,
+ YAML_TRANSFER = 260,
+ YAML_TAGURI = 261,
+ YAML_ITRANSFER = 262,
+ YAML_WORD = 263,
+ YAML_PLAIN = 264,
+ YAML_BLOCK = 265,
+ YAML_DOCSEP = 266,
+ YAML_IOPEN = 267,
+ YAML_INDENT = 268,
+ YAML_IEND = 269
+ };
+#endif
+#define YAML_ANCHOR 258
+#define YAML_ALIAS 259
+#define YAML_TRANSFER 260
+#define YAML_TAGURI 261
+#define YAML_ITRANSFER 262
+#define YAML_WORD 263
+#define YAML_PLAIN 264
+#define YAML_BLOCK 265
+#define YAML_DOCSEP 266
+#define YAML_IOPEN 267
+#define YAML_INDENT 268
+#define YAML_IEND 269
+
+
+
+
+/* Copy the first part of user declarations. */
+#line 14 "gram.y"
+
+
+#include "syck.h"
+
+#define YYPARSE_PARAM parser
+#define YYLEX_PARAM parser
+
+#define NULL_NODE(parser, node) \
+ SyckNode *node = syck_new_str( "", scalar_plain ); \
+ if ( ((SyckParser *)parser)->taguri_expansion == 1 ) \
+ { \
+ node->type_id = syck_taguri( YAML_DOMAIN, "null", 4 ); \
+ } \
+ else \
+ { \
+ node->type_id = syck_strndup( "null", 4 ); \
+ }
+
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 1
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+#ifndef YYSTYPE
+#line 33 "gram.y"
+typedef union {
+ SYMID nodeId;
+ SyckNode *nodeData;
+ char *name;
+} yystype;
+/* Line 193 of /usr/local/share/bison/yacc.c. */
+#line 135 "y.tab.c"
+# define YYSTYPE yystype
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+#ifndef YYLTYPE
+typedef struct yyltype
+{
+ int first_line;
+ int first_column;
+ int last_line;
+ int last_column;
+} yyltype;
+# define YYLTYPE yyltype
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 213 of /usr/local/share/bison/yacc.c. */
+#line 156 "y.tab.c"
+
+#if ! defined (yyoverflow) || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# if YYSTACK_USE_ALLOCA
+# define YYSTACK_ALLOC alloca
+# else
+# ifndef YYSTACK_USE_ALLOCA
+# if defined (alloca) || defined (_ALLOCA_H)
+# define YYSTACK_ALLOC alloca
+# else
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+# else
+# if defined (__STDC__) || defined (__cplusplus)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# endif
+# define YYSTACK_ALLOC malloc
+# define YYSTACK_FREE free
+# endif
+#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+
+
+#if (! defined (yyoverflow) \
+ && (! defined (__cplusplus) \
+ || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ short yyss;
+ YYSTYPE yyvs;
+ };
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAX)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ register YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (0)
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack, Stack, yysize); \
+ Stack = &yyptr->Stack; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (0)
+
+#endif
+
+#if defined (__STDC__) || defined (__cplusplus)
+ typedef signed char yysigned_char;
+#else
+ typedef short yysigned_char;
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 38
+#define YYLAST 422
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 23
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 28
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 75
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 128
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 269
+
+#define YYTRANSLATE(X) \
+ ((unsigned)(X) <= YYMAXUTOK ? yytranslate[X] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const unsigned char yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 21, 15, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 16, 2,
+ 2, 2, 2, 22, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 17, 2, 18, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 19, 2, 20, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const unsigned char yyprhs[] =
+{
+ 0, 0, 3, 5, 8, 9, 11, 13, 15, 19,
+ 21, 24, 27, 30, 34, 36, 39, 40, 42, 45,
+ 47, 49, 51, 54, 57, 60, 63, 66, 68, 70,
+ 72, 76, 78, 80, 82, 84, 86, 90, 93, 95,
+ 99, 102, 106, 109, 113, 116, 118, 122, 125, 129,
+ 132, 134, 138, 140, 142, 146, 150, 154, 157, 161,
+ 164, 168, 171, 175, 177, 183, 185, 189, 193, 196,
+ 200, 204, 207, 209, 213, 215
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yysigned_char yyrhs[] =
+{
+ 24, 0, -1, 26, -1, 11, 28, -1, -1, 33,
+ -1, 27, -1, 34, -1, 29, 26, 32, -1, 34,
+ -1, 5, 27, -1, 6, 27, -1, 3, 27, -1,
+ 29, 27, 32, -1, 25, -1, 29, 30, -1, -1,
+ 12, -1, 29, 13, -1, 14, -1, 13, -1, 14,
+ -1, 31, 32, -1, 5, 33, -1, 6, 33, -1,
+ 7, 33, -1, 3, 33, -1, 4, -1, 8, -1,
+ 9, -1, 29, 33, 32, -1, 10, -1, 35, -1,
+ 39, -1, 42, -1, 48, -1, 29, 37, 30, -1,
+ 15, 28, -1, 38, -1, 5, 31, 37, -1, 5,
+ 37, -1, 6, 31, 37, -1, 6, 37, -1, 3,
+ 31, 37, -1, 3, 37, -1, 36, -1, 38, 31,
+ 36, -1, 38, 31, -1, 17, 40, 18, -1, 17,
+ 18, -1, 41, -1, 40, 21, 41, -1, 25, -1,
+ 47, -1, 29, 43, 30, -1, 29, 46, 30, -1,
+ 5, 31, 46, -1, 5, 43, -1, 6, 31, 46,
+ -1, 6, 43, -1, 3, 31, 46, -1, 3, 43,
+ -1, 33, 16, 28, -1, 44, -1, 22, 25, 31,
+ 16, 28, -1, 45, -1, 46, 31, 36, -1, 46,
+ 31, 45, -1, 46, 31, -1, 25, 16, 28, -1,
+ 19, 49, 20, -1, 19, 20, -1, 50, -1, 49,
+ 21, 50, -1, 25, -1, 47, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const unsigned short yyrline[] =
+{
+ 0, 54, 54, 58, 62, 68, 69, 72, 73, 79,
+ 80, 85, 90, 99, 105, 106, 111, 121, 122, 125,
+ 128, 131, 132, 140, 145, 150, 158, 162, 170, 183,
+ 184, 194, 195, 196, 197, 198, 204, 210, 216, 217,
+ 222, 227, 232, 237, 241, 247, 251, 256, 265, 269,
+ 275, 279, 286, 287, 293, 298, 305, 310, 315, 320,
+ 325, 329, 335, 350, 351, 368, 369, 381, 389, 398,
+ 406, 410, 416, 417, 426, 433
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE
+/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "YAML_ANCHOR", "YAML_ALIAS",
+ "YAML_TRANSFER", "YAML_TAGURI", "YAML_ITRANSFER", "YAML_WORD",
+ "YAML_PLAIN", "YAML_BLOCK", "YAML_DOCSEP", "YAML_IOPEN", "YAML_INDENT",
+ "YAML_IEND", "'-'", "':'", "'['", "']'", "'{'", "'}'", "','", "'?'",
+ "$accept", "doc", "atom", "doc_struct_rep", "ind_rep", "atom_or_empty",
+ "indent_open", "indent_end", "indent_sep", "indent_flex_end",
+ "word_rep", "struct_rep", "implicit_seq", "basic_seq", "top_imp_seq",
+ "in_implicit_seq", "inline_seq", "in_inline_seq", "inline_seq_atom",
+ "implicit_map", "top_imp_map", "basic_mapping", "complex_mapping",
+ "in_implicit_map", "basic_mapping2", "inline_map", "in_inline_map",
+ "inline_map_atom", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const unsigned short yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 45, 58, 91, 93, 123,
+ 125, 44, 63
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const unsigned char yyr1[] =
+{
+ 0, 23, 24, 24, 24, 25, 25, 26, 26, 27,
+ 27, 27, 27, 27, 28, 28, 28, 29, 29, 30,
+ 31, 32, 32, 33, 33, 33, 33, 33, 33, 33,
+ 33, 34, 34, 34, 34, 34, 35, 36, 37, 37,
+ 37, 37, 37, 37, 37, 38, 38, 38, 39, 39,
+ 40, 40, 41, 41, 42, 42, 43, 43, 43, 43,
+ 43, 43, 44, 45, 45, 46, 46, 46, 46, 47,
+ 48, 48, 49, 49, 50, 50
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const unsigned char yyr2[] =
+{
+ 0, 2, 1, 2, 0, 1, 1, 1, 3, 1,
+ 2, 2, 2, 3, 1, 2, 0, 1, 2, 1,
+ 1, 1, 2, 2, 2, 2, 2, 1, 1, 1,
+ 3, 1, 1, 1, 1, 1, 3, 2, 1, 3,
+ 2, 3, 2, 3, 2, 1, 3, 2, 3, 2,
+ 1, 3, 1, 1, 3, 3, 3, 2, 3, 2,
+ 3, 2, 3, 1, 5, 1, 3, 3, 2, 3,
+ 3, 2, 1, 3, 1, 1
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const unsigned char yydefact[] =
+{
+ 4, 31, 16, 17, 0, 0, 0, 2, 0, 7,
+ 32, 33, 34, 35, 0, 27, 0, 0, 0, 28,
+ 29, 14, 6, 3, 0, 5, 9, 49, 52, 0,
+ 0, 50, 53, 71, 74, 75, 0, 72, 1, 0,
+ 0, 0, 18, 16, 0, 0, 0, 0, 45, 0,
+ 38, 0, 63, 65, 0, 12, 26, 10, 23, 11,
+ 24, 0, 0, 0, 0, 25, 0, 0, 0, 19,
+ 0, 15, 0, 16, 48, 0, 70, 0, 20, 0,
+ 44, 61, 0, 40, 57, 0, 42, 59, 37, 0,
+ 21, 0, 8, 16, 36, 47, 54, 55, 68, 0,
+ 13, 30, 69, 51, 73, 0, 0, 0, 43, 60,
+ 39, 56, 41, 58, 0, 22, 62, 46, 66, 67,
+ 0, 0, 0, 16, 0, 0, 0, 64
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yysigned_char yydefgoto[] =
+{
+ -1, 6, 21, 45, 22, 23, 64, 71, 91, 101,
+ 25, 26, 10, 48, 49, 50, 11, 30, 31, 12,
+ 51, 52, 53, 54, 32, 13, 36, 37
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -77
+static const short yypact[] =
+{
+ 163, -77, 356, -77, 339, 304, 7, -77, 224, -77,
+ -77, -77, -77, -77, 356, -77, 356, 356, 410, -77,
+ -77, -77, -77, -77, 204, -77, -77, -77, -15, 244,
+ 24, -77, -77, -77, -15, -77, 30, -77, -77, 373,
+ 373, 373, -77, 356, 356, 41, 224, -3, -77, 18,
+ 21, 18, -77, -77, 46, -77, -77, -77, -77, -77,
+ -77, 410, 410, 410, 399, -77, 322, 322, 322, -77,
+ 41, -77, 14, 356, -77, 356, -77, 356, -77, 264,
+ -77, -77, 264, -77, -77, 264, -77, -77, -77, 21,
+ -77, 41, -77, 356, -77, 33, -77, -77, 284, 41,
+ -77, -77, -77, -77, -77, 386, 386, 386, -77, 21,
+ -77, 21, -77, 21, 22, -77, -77, -77, -77, -77,
+ 20, 20, 20, 356, 91, 91, 91, -77
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const short yypgoto[] =
+{
+ -77, -77, 5, 56, 138, -40, 0, 25, 59, -34,
+ 23, 12, -77, -76, 71, -77, -77, -77, -14, -77,
+ 75, -77, -33, -64, 1, -77, -77, -7
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, parse error. */
+#define YYTABLE_NINF -1
+static const unsigned char yytable[] =
+{
+ 8, 73, 24, 88, 29, 29, 35, 38, 46, 28,
+ 34, 92, 9, 93, 29, 109, 29, 29, 111, 117,
+ 9, 113, 118, 124, 29, 125, 126, 78, 90, 29,
+ 93, 47, 69, 102, 78, 43, 100, 56, 123, 58,
+ 60, 65, 74, 24, 29, 75, 46, 72, 43, 89,
+ 76, 77, 72, 116, 78, 90, 7, 115, 9, 78,
+ 69, 103, 56, 58, 60, 119, 29, 29, 29, 72,
+ 104, 0, 0, 24, 94, 29, 96, 29, 35, 97,
+ 28, 0, 34, 127, 56, 58, 60, 99, 0, 56,
+ 58, 60, 0, 24, 124, 0, 125, 126, 79, 82,
+ 85, 0, 47, 0, 78, 47, 43, 0, 47, 95,
+ 80, 83, 86, 98, 81, 84, 87, 0, 0, 0,
+ 0, 47, 0, 24, 0, 79, 82, 85, 56, 58,
+ 60, 0, 0, 0, 0, 0, 0, 80, 83, 86,
+ 0, 81, 84, 87, 0, 0, 0, 0, 114, 0,
+ 108, 0, 55, 110, 57, 59, 112, 0, 0, 0,
+ 0, 0, 70, 0, 120, 121, 122, 70, 98, 0,
+ 98, 0, 98, 1, 2, 3, 80, 83, 86, 0,
+ 4, 0, 5, 120, 121, 122, 0, 0, 0, 0,
+ 0, 108, 110, 112, 0, 80, 83, 86, 0, 0,
+ 0, 0, 0, 0, 55, 57, 59, 66, 15, 67,
+ 68, 18, 19, 20, 1, 0, 3, 42, 69, 43,
+ 0, 4, 0, 5, 0, 0, 44, 39, 15, 40,
+ 41, 18, 19, 20, 1, 0, 3, 42, 0, 43,
+ 0, 4, 0, 5, 0, 0, 44, 66, 15, 67,
+ 68, 18, 19, 20, 1, 0, 3, 42, 0, 43,
+ 0, 4, 0, 5, 0, 0, 44, 105, 15, 106,
+ 107, 18, 19, 20, 0, 0, 3, 0, 0, 43,
+ 0, 0, 0, 0, 0, 0, 44, 61, 15, 62,
+ 63, 18, 19, 20, 0, 0, 3, 0, 0, 43,
+ 0, 0, 0, 0, 0, 0, 44, 14, 15, 16,
+ 17, 18, 19, 20, 1, 0, 3, 0, 0, 0,
+ 0, 4, 0, 5, 33, 66, 15, 67, 68, 18,
+ 19, 20, 1, 0, 3, 78, 0, 43, 0, 4,
+ 0, 5, 14, 15, 16, 17, 18, 19, 20, 1,
+ 0, 3, 0, 0, 0, 0, 4, 27, 5, 14,
+ 15, 16, 17, 18, 19, 20, 1, 0, 3, 0,
+ 0, 0, 0, 4, 0, 5, 39, 15, 40, 41,
+ 18, 19, 20, 0, 0, 3, 78, 0, 43, 105,
+ 15, 106, 107, 18, 19, 20, 0, 0, 3, 78,
+ 0, 43, 61, 15, 62, 63, 18, 19, 20, 0,
+ 0, 3, 42, 61, 15, 62, 63, 18, 19, 20,
+ 0, 0, 3
+};
+
+static const yysigned_char yycheck[] =
+{
+ 0, 16, 2, 43, 4, 5, 5, 0, 8, 4,
+ 5, 45, 0, 16, 14, 79, 16, 17, 82, 95,
+ 8, 85, 98, 3, 24, 5, 6, 13, 14, 29,
+ 16, 8, 14, 73, 13, 15, 70, 14, 16, 16,
+ 17, 18, 18, 43, 44, 21, 46, 24, 15, 44,
+ 20, 21, 29, 93, 13, 14, 0, 91, 46, 13,
+ 14, 75, 39, 40, 41, 98, 66, 67, 68, 46,
+ 77, -1, -1, 73, 49, 75, 51, 77, 77, 54,
+ 75, -1, 77, 123, 61, 62, 63, 64, -1, 66,
+ 67, 68, -1, 93, 3, -1, 5, 6, 39, 40,
+ 41, -1, 79, -1, 13, 82, 15, -1, 85, 50,
+ 39, 40, 41, 54, 39, 40, 41, -1, -1, -1,
+ -1, 98, -1, 123, -1, 66, 67, 68, 105, 106,
+ 107, -1, -1, -1, -1, -1, -1, 66, 67, 68,
+ -1, 66, 67, 68, -1, -1, -1, -1, 89, -1,
+ 79, -1, 14, 82, 16, 17, 85, -1, -1, -1,
+ -1, -1, 24, -1, 105, 106, 107, 29, 109, -1,
+ 111, -1, 113, 10, 11, 12, 105, 106, 107, -1,
+ 17, -1, 19, 124, 125, 126, -1, -1, -1, -1,
+ -1, 120, 121, 122, -1, 124, 125, 126, -1, -1,
+ -1, -1, -1, -1, 66, 67, 68, 3, 4, 5,
+ 6, 7, 8, 9, 10, -1, 12, 13, 14, 15,
+ -1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
+ 6, 7, 8, 9, 10, -1, 12, 13, -1, 15,
+ -1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
+ 6, 7, 8, 9, 10, -1, 12, 13, -1, 15,
+ -1, 17, -1, 19, -1, -1, 22, 3, 4, 5,
+ 6, 7, 8, 9, -1, -1, 12, -1, -1, 15,
+ -1, -1, -1, -1, -1, -1, 22, 3, 4, 5,
+ 6, 7, 8, 9, -1, -1, 12, -1, -1, 15,
+ -1, -1, -1, -1, -1, -1, 22, 3, 4, 5,
+ 6, 7, 8, 9, 10, -1, 12, -1, -1, -1,
+ -1, 17, -1, 19, 20, 3, 4, 5, 6, 7,
+ 8, 9, 10, -1, 12, 13, -1, 15, -1, 17,
+ -1, 19, 3, 4, 5, 6, 7, 8, 9, 10,
+ -1, 12, -1, -1, -1, -1, 17, 18, 19, 3,
+ 4, 5, 6, 7, 8, 9, 10, -1, 12, -1,
+ -1, -1, -1, 17, -1, 19, 3, 4, 5, 6,
+ 7, 8, 9, -1, -1, 12, 13, -1, 15, 3,
+ 4, 5, 6, 7, 8, 9, -1, -1, 12, 13,
+ -1, 15, 3, 4, 5, 6, 7, 8, 9, -1,
+ -1, 12, 13, 3, 4, 5, 6, 7, 8, 9,
+ -1, -1, 12
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const unsigned char yystos[] =
+{
+ 0, 10, 11, 12, 17, 19, 24, 26, 29, 34,
+ 35, 39, 42, 48, 3, 4, 5, 6, 7, 8,
+ 9, 25, 27, 28, 29, 33, 34, 18, 25, 29,
+ 40, 41, 47, 20, 25, 47, 49, 50, 0, 3,
+ 5, 6, 13, 15, 22, 26, 29, 33, 36, 37,
+ 38, 43, 44, 45, 46, 27, 33, 27, 33, 27,
+ 33, 3, 5, 6, 29, 33, 3, 5, 6, 14,
+ 27, 30, 33, 16, 18, 21, 20, 21, 13, 31,
+ 37, 43, 31, 37, 43, 31, 37, 43, 28, 25,
+ 14, 31, 32, 16, 30, 31, 30, 30, 31, 33,
+ 32, 32, 28, 41, 50, 3, 5, 6, 37, 46,
+ 37, 46, 37, 46, 31, 32, 28, 36, 36, 45,
+ 31, 31, 31, 16, 3, 5, 6, 28
+};
+
+#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
+# define YYSIZE_T __SIZE_TYPE__
+#endif
+#if ! defined (YYSIZE_T) && defined (size_t)
+# define YYSIZE_T size_t
+#endif
+#if ! defined (YYSIZE_T)
+# if defined (__STDC__) || defined (__cplusplus)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# endif
+#endif
+#if ! defined (YYSIZE_T)
+# define YYSIZE_T unsigned int
+#endif
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY -2
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrlab1
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+
+#define YYFAIL goto yyerrlab
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ yychar1 = YYTRANSLATE (yychar); \
+ YYPOPSTACK; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror ("syntax error: cannot back up"); \
+ YYERROR; \
+ } \
+while (0)
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+/* YYLLOC_DEFAULT -- Compute the default location (before the actions
+ are run). */
+
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ Current.first_line = Rhs[1].first_line; \
+ Current.first_column = Rhs[1].first_column; \
+ Current.last_line = Rhs[N].last_line; \
+ Current.last_column = Rhs[N].last_column;
+#endif
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (&yylval, YYLEX_PARAM)
+#else
+# define YYLEX yylex (&yylval)
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (0)
+# define YYDSYMPRINT(Args) \
+do { \
+ if (yydebug) \
+ yysymprint Args; \
+} while (0)
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YYDSYMPRINT(Args)
+#endif /* !YYDEBUG */
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#if YYMAXDEPTH == 0
+# undef YYMAXDEPTH
+#endif
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined (__GLIBC__) && defined (_STRING_H)
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+static YYSIZE_T
+# if defined (__STDC__) || defined (__cplusplus)
+yystrlen (const char *yystr)
+# else
+yystrlen (yystr)
+ const char *yystr;
+# endif
+{
+ register const char *yys = yystr;
+
+ while (*yys++ != '\0')
+ continue;
+
+ return yys - yystr - 1;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+static char *
+# if defined (__STDC__) || defined (__cplusplus)
+yystpcpy (char *yydest, const char *yysrc)
+# else
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+# endif
+{
+ register char *yyd = yydest;
+ register const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+#endif /* !YYERROR_VERBOSE */
+
+
+
+#if YYDEBUG
+/*-----------------------------.
+| Print this symbol on YYOUT. |
+`-----------------------------*/
+
+static void
+#if defined (__STDC__) || defined (__cplusplus)
+yysymprint (FILE* yyout, int yytype, YYSTYPE yyvalue)
+#else
+yysymprint (yyout, yytype, yyvalue)
+ FILE* yyout;
+ int yytype;
+ YYSTYPE yyvalue;
+#endif
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvalue;
+
+ if (yytype < YYNTOKENS)
+ {
+ YYFPRINTF (yyout, "token %s (", yytname[yytype]);
+# ifdef YYPRINT
+ YYPRINT (yyout, yytoknum[yytype], yyvalue);
+# endif
+ }
+ else
+ YYFPRINTF (yyout, "nterm %s (", yytname[yytype]);
+
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+ YYFPRINTF (yyout, ")");
+}
+#endif /* YYDEBUG. */
+
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+static void
+#if defined (__STDC__) || defined (__cplusplus)
+yydestruct (int yytype, YYSTYPE yyvalue)
+#else
+yydestruct (yytype, yyvalue)
+ int yytype;
+ YYSTYPE yyvalue;
+#endif
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvalue;
+
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+
+/* The user can define YYPARSE_PARAM as the name of an argument to be passed
+ into yyparse. The argument should have type void *.
+ It should actually point to an object.
+ Grammar actions can access the variable by casting it
+ to the proper pointer type. */
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
+# define YYPARSE_PARAM_DECL
+# else
+# define YYPARSE_PARAM_ARG YYPARSE_PARAM
+# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+# endif
+#else /* !YYPARSE_PARAM */
+# define YYPARSE_PARAM_ARG
+# define YYPARSE_PARAM_DECL
+#endif /* !YYPARSE_PARAM */
+
+/* Prevent warning if -Wstrict-prototypes. */
+#ifdef __GNUC__
+# ifdef YYPARSE_PARAM
+int yyparse (void *);
+# else
+int yyparse (void);
+# endif
+#endif
+
+
+
+
+int
+yyparse (YYPARSE_PARAM_ARG)
+ YYPARSE_PARAM_DECL
+{
+ /* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of parse errors so far. */
+int yynerrs;
+
+ register int yystate;
+ register int yyn;
+ int yyresult;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+ /* Lookahead token as an internal (translated) token number. */
+ int yychar1 = 0;
+
+ /* Three stacks and their tools:
+ `yyss': related to states,
+ `yyvs': related to semantic values,
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ short yyssa[YYINITDEPTH];
+ short *yyss = yyssa;
+ register short *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs = yyvsa;
+ register YYSTYPE *yyvsp;
+
+
+
+#define YYPOPSTACK (yyvsp--, yyssp--)
+
+ YYSIZE_T yystacksize = YYINITDEPTH;
+
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+
+ /* When reducing, the number of symbols on the RHS of the reduced
+ rule. */
+ int yylen;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. so pushing a state here evens the stacks.
+ */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyssp >= yyss + yystacksize - 1)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ short *yyss1 = yyss;
+
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow ("parser stack overflow",
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyoverflowlab;
+# else
+ /* Extend the stack our own way. */
+ if (yystacksize >= YYMAXDEPTH)
+ goto yyoverflowlab;
+ yystacksize *= 2;
+ if (yystacksize > YYMAXDEPTH)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ short *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyoverflowlab;
+ YYSTACK_RELOCATE (yyss);
+ YYSTACK_RELOCATE (yyvs);
+
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyssp >= yyss + yystacksize - 1)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+/* Do appropriate processing given the current state. */
+/* Read a lookahead token if we need one and don't already have one. */
+/* yyresume: */
+
+ /* First try to decide what to do without reference to lookahead token. */
+
+ yyn = yypact[yystate];
+ if (yyn == YYPACT_NINF)
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* yychar is either YYEMPTY or YYEOF
+ or a valid token in external form. */
+
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ /* Convert token to internal form (in yychar1) for indexing tables with. */
+
+ if (yychar <= 0) /* This means end of input. */
+ {
+ yychar1 = 0;
+ yychar = YYEOF; /* Don't call YYLEX any more. */
+
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yychar1 = YYTRANSLATE (yychar);
+
+ /* We have to keep this `#if YYDEBUG', since we use variables
+ which are defined only if `YYDEBUG' is set. */
+ YYDPRINTF ((stderr, "Next token is "));
+ YYDSYMPRINT ((stderr, yychar1, yylval));
+ YYDPRINTF ((stderr, "\n"));
+ }
+
+ /* If the proper action on seeing token YYCHAR1 is to reduce or to
+ detect an error, take that action. */
+ yyn += yychar1;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yyn == 0 || yyn == YYTABLE_NINF)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Shift the lookahead token. */
+ YYDPRINTF ((stderr, "Shifting token %d (%s), ",
+ yychar, yytname[yychar1]));
+
+ /* Discard the token being shifted unless it is eof. */
+ if (yychar != YYEOF)
+ yychar = YYEMPTY;
+
+ *++yyvsp = yylval;
+
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+
+#if YYDEBUG
+ /* We have to keep this `#if YYDEBUG', since we use variables which
+ are defined only if `YYDEBUG' is set. */
+ if (yydebug)
+ {
+ int yyi;
+
+ YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
+ yyn - 1, yyrline[yyn]);
+
+ /* Print the symbols being reduced, and their result. */
+ for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++)
+ YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
+ YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+ }
+#endif
+ switch (yyn)
+ {
+ case 2:
+#line 55 "gram.y"
+ {
+ ((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 3:
+#line 59 "gram.y"
+ {
+ ((SyckParser *)parser)->root = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 4:
+#line 63 "gram.y"
+ {
+ ((SyckParser *)parser)->eof = 1;
+ }
+ break;
+
+ case 8:
+#line 74 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 10:
+#line 81 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 11:
+#line 86 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 12:
+#line 91 "gram.y"
+ {
+ /*
+ * _Anchors_: The language binding must keep a separate symbol table
+ * for anchors. The actual ID in the symbol table is returned to the
+ * higher nodes, though.
+ */
+ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 13:
+#line 100 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 15:
+#line 107 "gram.y"
+ {
+ NULL_NODE( parser, n );
+ yyval.nodeData = n;
+ }
+ break;
+
+ case 16:
+#line 112 "gram.y"
+ {
+ NULL_NODE( parser, n );
+ yyval.nodeData = n;
+ }
+ break;
+
+ case 23:
+#line 141 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 24:
+#line 146 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 25:
+#line 151 "gram.y"
+ {
+ if ( ((SyckParser *)parser)->implicit_typing == 1 )
+ {
+ try_tag_implicit( yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ }
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 26:
+#line 159 "gram.y"
+ {
+ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 27:
+#line 163 "gram.y"
+ {
+ /*
+ * _Aliases_: The anchor symbol table is scanned for the anchor name.
+ * The anchor's ID in the language's symbol table is returned.
+ */
+ yyval.nodeData = syck_hdlr_get_anchor( (SyckParser *)parser, yyvsp[0].name );
+ }
+ break;
+
+ case 28:
+#line 171 "gram.y"
+ {
+ SyckNode *n = yyvsp[0].nodeData;
+ if ( ((SyckParser *)parser)->taguri_expansion == 1 )
+ {
+ n->type_id = syck_taguri( YAML_DOMAIN, "str", 3 );
+ }
+ else
+ {
+ n->type_id = syck_strndup( "str", 3 );
+ }
+ yyval.nodeData = n;
+ }
+ break;
+
+ case 30:
+#line 185 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 36:
+#line 205 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 37:
+#line 211 "gram.y"
+ {
+ yyval.nodeId = syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 39:
+#line 218 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 40:
+#line 223 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 41:
+#line 228 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 42:
+#line 233 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 43:
+#line 238 "gram.y"
+ {
+ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 44:
+#line 242 "gram.y"
+ {
+ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 45:
+#line 248 "gram.y"
+ {
+ yyval.nodeData = syck_new_seq( yyvsp[0].nodeId );
+ }
+ break;
+
+ case 46:
+#line 252 "gram.y"
+ {
+ syck_seq_add( yyvsp[-2].nodeData, yyvsp[0].nodeId );
+ yyval.nodeData = yyvsp[-2].nodeData;
+ }
+ break;
+
+ case 47:
+#line 257 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 48:
+#line 266 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 49:
+#line 270 "gram.y"
+ {
+ yyval.nodeData = syck_alloc_seq();
+ }
+ break;
+
+ case 50:
+#line 276 "gram.y"
+ {
+ yyval.nodeData = syck_new_seq( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
+ }
+ break;
+
+ case 51:
+#line 280 "gram.y"
+ {
+ syck_seq_add( yyvsp[-2].nodeData, syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
+ yyval.nodeData = yyvsp[-2].nodeData;
+ }
+ break;
+
+ case 54:
+#line 294 "gram.y"
+ {
+ apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData );
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 55:
+#line 299 "gram.y"
+ {
+ apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData );
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 56:
+#line 306 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 57:
+#line 311 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, ((SyckParser *)parser)->taguri_expansion );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 58:
+#line 316 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-2].name, yyvsp[0].nodeData, 0 );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 59:
+#line 321 "gram.y"
+ {
+ syck_add_transfer( yyvsp[-1].name, yyvsp[0].nodeData, 0 );
+ yyval.nodeData = yyvsp[0].nodeData;
+ }
+ break;
+
+ case 60:
+#line 326 "gram.y"
+ {
+ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-2].name, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 61:
+#line 330 "gram.y"
+ {
+ yyval.nodeData = syck_hdlr_add_anchor( (SyckParser *)parser, yyvsp[-1].name, yyvsp[0].nodeData );
+ }
+ break;
+
+ case 62:
+#line 336 "gram.y"
+ {
+ yyval.nodeData = syck_new_map(
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ),
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
+ }
+ break;
+
+ case 64:
+#line 352 "gram.y"
+ {
+ yyval.nodeData = syck_new_map(
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-3].nodeData ),
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
+ }
+ break;
+
+ case 66:
+#line 370 "gram.y"
+ {
+ if ( yyvsp[-2].nodeData->shortcut == NULL )
+ {
+ yyvsp[-2].nodeData->shortcut = syck_new_seq( yyvsp[0].nodeId );
+ }
+ else
+ {
+ syck_seq_add( yyvsp[-2].nodeData->shortcut, yyvsp[0].nodeId );
+ }
+ yyval.nodeData = yyvsp[-2].nodeData;
+ }
+ break;
+
+ case 67:
+#line 382 "gram.y"
+ {
+ apply_seq_in_map( (SyckParser *)parser, yyvsp[-2].nodeData );
+ syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData );
+ syck_free_node( yyvsp[0].nodeData );
+ yyvsp[0].nodeData = NULL;
+ yyval.nodeData = yyvsp[-2].nodeData;
+ }
+ break;
+
+ case 68:
+#line 390 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 69:
+#line 399 "gram.y"
+ {
+ yyval.nodeData = syck_new_map(
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ),
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ) );
+ }
+ break;
+
+ case 70:
+#line 407 "gram.y"
+ {
+ yyval.nodeData = yyvsp[-1].nodeData;
+ }
+ break;
+
+ case 71:
+#line 411 "gram.y"
+ {
+ yyval.nodeData = syck_alloc_map();
+ }
+ break;
+
+ case 73:
+#line 418 "gram.y"
+ {
+ syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData );
+ syck_free_node( yyvsp[0].nodeData );
+ yyvsp[0].nodeData = NULL;
+ yyval.nodeData = yyvsp[-2].nodeData;
+ }
+ break;
+
+ case 74:
+#line 427 "gram.y"
+ {
+ NULL_NODE( parser, n );
+ yyval.nodeData = syck_new_map(
+ syck_hdlr_add_node( (SyckParser *)parser, yyvsp[0].nodeData ),
+ syck_hdlr_add_node( (SyckParser *)parser, n ) );
+ }
+ break;
+
+
+ }
+
+/* Line 1016 of /usr/local/share/bison/yacc.c. */
+#line 1559 "y.tab.c"
+
+ yyvsp -= yylen;
+ yyssp -= yylen;
+
+
+#if YYDEBUG
+ if (yydebug)
+ {
+ short *yyssp1 = yyss - 1;
+ YYFPRINTF (stderr, "state stack now");
+ while (yyssp1 != yyssp)
+ YYFPRINTF (stderr, " %d", *++yyssp1);
+ YYFPRINTF (stderr, "\n");
+ }
+#endif
+
+ *++yyvsp = yyval;
+
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if YYERROR_VERBOSE
+ yyn = yypact[yystate];
+
+ if (YYPACT_NINF < yyn && yyn < YYLAST)
+ {
+ YYSIZE_T yysize = 0;
+ int yytype = YYTRANSLATE (yychar);
+ char *yymsg;
+ int yyx, yycount;
+
+ yycount = 0;
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ for (yyx = yyn < 0 ? -yyn : 0;
+ yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ yysize += yystrlen (yytname[yyx]) + 15, yycount++;
+ yysize += yystrlen ("parse error, unexpected ") + 1;
+ yysize += yystrlen (yytname[yytype]);
+ yymsg = (char *) YYSTACK_ALLOC (yysize);
+ if (yymsg != 0)
+ {
+ char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
+ yyp = yystpcpy (yyp, yytname[yytype]);
+
+ if (yycount < 5)
+ {
+ yycount = 0;
+ for (yyx = yyn < 0 ? -yyn : 0;
+ yyx < (int) (sizeof (yytname) / sizeof (char *));
+ yyx++)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ const char *yyq = ! yycount ? ", expecting " : " or ";
+ yyp = yystpcpy (yyp, yyq);
+ yyp = yystpcpy (yyp, yytname[yyx]);
+ yycount++;
+ }
+ }
+ yyerror (yymsg);
+ YYSTACK_FREE (yymsg);
+ }
+ else
+ yyerror ("parse error; also virtual memory exhausted");
+ }
+ else
+#endif /* YYERROR_VERBOSE */
+ yyerror ("parse error");
+ }
+ goto yyerrlab1;
+
+
+/*----------------------------------------------------.
+| yyerrlab1 -- error raised explicitly by an action. |
+`----------------------------------------------------*/
+yyerrlab1:
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ {
+ /* Pop the error token. */
+ YYPOPSTACK;
+ /* Pop the rest of the stack. */
+ while (yyssp > yyss)
+ {
+ YYDPRINTF ((stderr, "Error: popping "));
+ YYDSYMPRINT ((stderr,
+ yystos[*yyssp],
+ *yyvsp));
+ YYDPRINTF ((stderr, "\n"));
+ yydestruct (yystos[*yyssp], *yyvsp);
+ YYPOPSTACK;
+ }
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
+ yychar, yytname[yychar1]));
+ yydestruct (yychar1, yylval);
+ yychar = YYEMPTY;
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (yyn != YYPACT_NINF)
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+ YYDPRINTF ((stderr, "Error: popping "));
+ YYDSYMPRINT ((stderr,
+ yystos[*yyssp], *yyvsp));
+ YYDPRINTF ((stderr, "\n"));
+
+ yydestruct (yystos[yystate], *yyvsp);
+ yyvsp--;
+ yystate = *--yyssp;
+
+
+#if YYDEBUG
+ if (yydebug)
+ {
+ short *yyssp1 = yyss - 1;
+ YYFPRINTF (stderr, "Error: state stack now");
+ while (yyssp1 != yyssp)
+ YYFPRINTF (stderr, " %d", *++yyssp1);
+ YYFPRINTF (stderr, "\n");
+ }
+#endif
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ YYDPRINTF ((stderr, "Shifting error token, "));
+
+ *++yyvsp = yylval;
+
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#ifndef yyoverflow
+/*----------------------------------------------.
+| yyoverflowlab -- parser overflow comes here. |
+`----------------------------------------------*/
+yyoverflowlab:
+ yyerror ("parser stack overflow");
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+ return yyresult;
+}
+
+
+#line 436 "gram.y"
+
+
+void
+apply_seq_in_map( SyckParser *parser, SyckNode *n )
+{
+ long map_len;
+ if ( n->shortcut == NULL )
+ {
+ return;
+ }
+
+ map_len = syck_map_count( n );
+ syck_map_assign( n, map_value, map_len - 1,
+ syck_hdlr_add_node( parser, n->shortcut ) );
+
+ n->shortcut = NULL;
+}
+
+
diff --git a/ext/syck/gram.h b/ext/syck/gram.h
new file mode 100644
index 0000000000..4c0e199832
--- /dev/null
+++ b/ext/syck/gram.h
@@ -0,0 +1,81 @@
+/* A Bison parser, made from gram.y, by GNU bison 1.75. */
+
+/* Skeleton parser for Yacc-like parsing with Bison,
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+#ifndef BISON_Y_TAB_H
+# define BISON_Y_TAB_H
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ YAML_ANCHOR = 258,
+ YAML_ALIAS = 259,
+ YAML_TRANSFER = 260,
+ YAML_TAGURI = 261,
+ YAML_ITRANSFER = 262,
+ YAML_WORD = 263,
+ YAML_PLAIN = 264,
+ YAML_BLOCK = 265,
+ YAML_DOCSEP = 266,
+ YAML_IOPEN = 267,
+ YAML_INDENT = 268,
+ YAML_IEND = 269
+ };
+#endif
+#define YAML_ANCHOR 258
+#define YAML_ALIAS 259
+#define YAML_TRANSFER 260
+#define YAML_TAGURI 261
+#define YAML_ITRANSFER 262
+#define YAML_WORD 263
+#define YAML_PLAIN 264
+#define YAML_BLOCK 265
+#define YAML_DOCSEP 266
+#define YAML_IOPEN 267
+#define YAML_INDENT 268
+#define YAML_IEND 269
+
+
+
+
+#ifndef YYSTYPE
+#line 33 "gram.y"
+typedef union {
+ SYMID nodeId;
+ SyckNode *nodeData;
+ char *name;
+} yystype;
+/* Line 1281 of /usr/local/share/bison/yacc.c. */
+#line 74 "y.tab.h"
+# define YYSTYPE yystype
+#endif
+
+
+
+
+#endif /* not BISON_Y_TAB_H */
+
diff --git a/ext/syck/handler.c b/ext/syck/handler.c
new file mode 100644
index 0000000000..563feb10ae
--- /dev/null
+++ b/ext/syck/handler.c
@@ -0,0 +1,156 @@
+/*
+ * handler.c
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+
+#include "ruby.h"
+#include "syck.h"
+
+SYMID
+syck_hdlr_add_node( SyckParser *p, SyckNode *n )
+{
+ SYMID id;
+
+ if ( ! n->id )
+ {
+ n->id = (p->handler)( p, n );
+ }
+ id = n->id;
+
+ if ( n->anchor == NULL )
+ {
+ syck_free_node( n );
+ }
+ return id;
+}
+
+SyckNode *
+syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n )
+{
+ n->anchor = a;
+ if ( p->bad_anchors != NULL )
+ {
+ SyckNode *bad;
+ if ( st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&bad ) )
+ {
+ if ( n->kind != syck_str_kind )
+ {
+ n->id = bad->id;
+ (p->handler)( p, n );
+ }
+ }
+ }
+ if ( p->anchors == NULL )
+ {
+ p->anchors = st_init_strtable();
+ }
+ st_insert( p->anchors, (st_data_t)a, (st_data_t)n );
+ return n;
+}
+
+void
+syck_hdlr_remove_anchor( SyckParser *p, char *a )
+{
+ if ( p->anchors == NULL )
+ {
+ p->anchors = st_init_strtable();
+ }
+ st_insert( p->anchors, (st_data_t)a, (st_data_t)1 );
+}
+
+SyckNode *
+syck_hdlr_get_anchor( SyckParser *p, char *a )
+{
+ SyckNode *n = NULL;
+
+ if ( p->anchors != NULL )
+ {
+ if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&n ) )
+ {
+ if ( n != (void *)1 )
+ {
+ S_FREE( a );
+ return n;
+ }
+ else
+ {
+ if ( p->bad_anchors == NULL )
+ {
+ p->bad_anchors = st_init_strtable();
+ }
+ if ( ! st_lookup( p->bad_anchors, (st_data_t)a, (st_data_t *)&n ) )
+ {
+ n = (p->bad_anchor_handler)( p, a );
+ st_insert( p->bad_anchors, (st_data_t)a, (st_data_t)n );
+ }
+ }
+ }
+ }
+
+ if ( n == NULL )
+ {
+ n = (p->bad_anchor_handler)( p, a );
+ }
+
+ if ( n->anchor )
+ {
+ S_FREE( a );
+ }
+ else
+ {
+ n->anchor = a;
+ }
+
+ return n;
+}
+
+void
+syck_add_transfer( char *uri, SyckNode *n, int taguri )
+{
+ if ( n->type_id != NULL )
+ {
+ S_FREE( n->type_id );
+ }
+
+ if ( taguri == 0 )
+ {
+ n->type_id = uri;
+ return;
+ }
+
+ n->type_id = syck_type_id_to_uri( uri );
+ S_FREE( uri );
+}
+
+char *
+syck_xprivate( char *type_id, int type_len )
+{
+ char *uri = S_ALLOC_N( char, type_len + 14 );
+ uri[0] = '\0';
+ strcat( uri, "x-private:" );
+ strncat( uri, type_id, type_len );
+ return uri;
+}
+
+char *
+syck_taguri( char *domain, char *type_id, int type_len )
+{
+ char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 );
+ uri[0] = '\0';
+ strcat( uri, "tag:" );
+ strcat( uri, domain );
+ strcat( uri, ":" );
+ strncat( uri, type_id, type_len );
+ return uri;
+}
+
+int
+syck_try_implicit( SyckNode *n )
+{
+ return 1;
+}
+
diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c
new file mode 100644
index 0000000000..66f0520233
--- /dev/null
+++ b/ext/syck/implicit.c
@@ -0,0 +1,2965 @@
+/* Generated by re2c 0.9.3 on Fri Aug 13 11:47:51 2004 */
+#line 1 "implicit.re"
+/*
+ * implicit.re
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+
+#include "ruby.h"
+#include "syck.h"
+
+#define YYCTYPE char
+#define YYCURSOR cursor
+#define YYMARKER marker
+#define YYLIMIT limit
+#define YYFILL(n)
+
+void
+try_tag_implicit( SyckNode *n, int taguri )
+{
+ char *tid = "";
+ switch ( n->kind )
+ {
+ case syck_str_kind:
+ tid = syck_match_implicit( n->data.str->ptr, n->data.str->len );
+ break;
+
+ case syck_seq_kind:
+ tid = "seq";
+ break;
+
+ case syck_map_kind:
+ tid = "map";
+ break;
+ }
+ if ( taguri == 1 )
+ {
+ n->type_id = syck_taguri( YAML_DOMAIN, tid, strlen( tid ) );
+ } else {
+ n->type_id = syck_strndup( tid, strlen( tid ) );
+ }
+}
+
+char *syck_match_implicit( char *str, size_t len )
+{
+ char *cursor, *limit, *marker;
+ cursor = str;
+ limit = str + len;
+
+
+#line 6 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy0;
+yy1: ++YYCURSOR;
+yy0:
+ if((YYLIMIT - YYCURSOR) < 26) YYFILL(26);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy6;
+ case '+': goto yy16;
+ case '-': goto yy17;
+ case '.': goto yy20;
+ case '0': goto yy18;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy19;
+ case '<': goto yy22;
+ case '=': goto yy21;
+ case 'F': goto yy15;
+ case 'N': goto yy5;
+ case 'O': goto yy13;
+ case 'T': goto yy11;
+ case 'Y': goto yy9;
+ case 'f': goto yy14;
+ case 'n': goto yy4;
+ case 'o': goto yy12;
+ case 't': goto yy10;
+ case 'y': goto yy8;
+ case '~': goto yy2;
+ default: goto yy23;
+ }
+yy2: ++YYCURSOR;
+ if((yych = *YYCURSOR) <= '\000') goto yy6;
+ goto yy3;
+yy3:
+#line 122 "implicit.re"
+{ return "str"; }
+#line 51 "<stdout>"
+yy4: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'o': goto yy172;
+ case 'u': goto yy200;
+ default: goto yy3;
+ }
+yy5: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'O': case 'o': goto yy172;
+ case 'U': goto yy195;
+ case 'u': goto yy196;
+ default: goto yy3;
+ }
+yy6: ++YYCURSOR;
+ goto yy7;
+yy7:
+#line 84 "implicit.re"
+{ return "null"; }
+#line 72 "<stdout>"
+yy8: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'e': goto yy194;
+ default: goto yy3;
+ }
+yy9: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'E': goto yy192;
+ case 'e': goto yy193;
+ default: goto yy3;
+ }
+yy10: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'r': goto yy190;
+ default: goto yy3;
+ }
+yy11: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'R': goto yy186;
+ case 'r': goto yy187;
+ default: goto yy3;
+ }
+yy12: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'f': goto yy185;
+ case 'n': goto yy182;
+ default: goto yy3;
+ }
+yy13: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'F': goto yy180;
+ case 'N': case 'n': goto yy182;
+ case 'f': goto yy181;
+ default: goto yy3;
+ }
+yy14: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'a': goto yy177;
+ default: goto yy3;
+ }
+yy15: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'A': goto yy168;
+ case 'a': goto yy169;
+ default: goto yy3;
+ }
+yy16: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '.': goto yy167;
+ case '0': goto yy158;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy47;
+ default: goto yy3;
+ }
+yy17: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '.': goto yy157;
+ case '0': goto yy158;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy47;
+ default: goto yy3;
+ }
+yy18: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\000': goto yy52;
+ case ',': goto yy142;
+ case '.': goto yy50;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7': goto yy140;
+ case '8':
+ case '9': goto yy141;
+ case ':': goto yy49;
+ case 'x': goto yy144;
+ default: goto yy3;
+ }
+yy19: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\000': goto yy52;
+ case ',': goto yy47;
+ case '.': goto yy50;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy46;
+ case ':': goto yy49;
+ default: goto yy3;
+ }
+yy20: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case 'I': goto yy33;
+ case 'N': goto yy31;
+ case 'i': goto yy32;
+ case 'n': goto yy30;
+ default: goto yy3;
+ }
+yy21: yych = *++YYCURSOR;
+ if(yych <= '\000') goto yy28;
+ goto yy3;
+yy22: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '<': goto yy24;
+ default: goto yy3;
+ }
+yy23: yych = *++YYCURSOR;
+ goto yy3;
+yy24: yych = *++YYCURSOR;
+ if(yych <= '\000') goto yy26;
+ goto yy25;
+yy25: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy3;
+ }
+yy26: ++YYCURSOR;
+ goto yy27;
+yy27:
+#line 120 "implicit.re"
+{ return "merge"; }
+#line 230 "<stdout>"
+yy28: ++YYCURSOR;
+ goto yy29;
+yy29:
+#line 118 "implicit.re"
+{ return "default"; }
+#line 236 "<stdout>"
+yy30: yych = *++YYCURSOR;
+ switch(yych){
+ case 'a': goto yy45;
+ default: goto yy25;
+ }
+yy31: yych = *++YYCURSOR;
+ switch(yych){
+ case 'A': goto yy40;
+ case 'a': goto yy41;
+ default: goto yy25;
+ }
+yy32: yych = *++YYCURSOR;
+ switch(yych){
+ case 'n': goto yy39;
+ default: goto yy25;
+ }
+yy33: yych = *++YYCURSOR;
+ switch(yych){
+ case 'N': goto yy34;
+ case 'n': goto yy35;
+ default: goto yy25;
+ }
+yy34: yych = *++YYCURSOR;
+ switch(yych){
+ case 'F': goto yy36;
+ default: goto yy25;
+ }
+yy35: yych = *++YYCURSOR;
+ switch(yych){
+ case 'f': goto yy36;
+ default: goto yy25;
+ }
+yy36: yych = *++YYCURSOR;
+ if(yych >= '\001') goto yy25;
+ goto yy37;
+yy37: ++YYCURSOR;
+ goto yy38;
+yy38:
+#line 104 "implicit.re"
+{ return "float#inf"; }
+#line 277 "<stdout>"
+yy39: yych = *++YYCURSOR;
+ switch(yych){
+ case 'f': goto yy36;
+ default: goto yy25;
+ }
+yy40: yych = *++YYCURSOR;
+ switch(yych){
+ case 'N': goto yy42;
+ default: goto yy25;
+ }
+yy41: yych = *++YYCURSOR;
+ switch(yych){
+ case 'N': goto yy42;
+ default: goto yy25;
+ }
+yy42: yych = *++YYCURSOR;
+ if(yych >= '\001') goto yy25;
+ goto yy43;
+yy43: ++YYCURSOR;
+ goto yy44;
+yy44:
+#line 108 "implicit.re"
+{ return "float#nan"; }
+#line 301 "<stdout>"
+yy45: yych = *++YYCURSOR;
+ switch(yych){
+ case 'n': goto yy42;
+ default: goto yy25;
+ }
+yy46: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy74;
+ default: goto yy48;
+ }
+yy47: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy48;
+yy48: switch(yych){
+ case '\000': goto yy52;
+ case ',': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy47;
+ case '.': goto yy50;
+ case ':': goto yy49;
+ default: goto yy25;
+ }
+yy49: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5': goto yy66;
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy67;
+ default: goto yy25;
+ }
+yy50: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy51;
+yy51: switch(yych){
+ case '\000': goto yy56;
+ case ',': goto yy54;
+ case '.': goto yy58;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy50;
+ case 'E': case 'e': goto yy60;
+ default: goto yy25;
+ }
+yy52: ++YYCURSOR;
+ goto yy53;
+yy53:
+#line 96 "implicit.re"
+{ return "int"; }
+#line 386 "<stdout>"
+yy54: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy55;
+yy55: switch(yych){
+ case '\000': goto yy56;
+ case ',': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy54;
+ default: goto yy25;
+ }
+yy56: ++YYCURSOR;
+ goto yy57;
+yy57:
+#line 98 "implicit.re"
+{ return "float#fix"; }
+#line 411 "<stdout>"
+yy58: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy59;
+yy59: switch(yych){
+ case '.': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy58;
+ case 'E': case 'e': goto yy60;
+ default: goto yy25;
+ }
+yy60: yych = *++YYCURSOR;
+ switch(yych){
+ case '+': case '-': goto yy61;
+ default: goto yy25;
+ }
+yy61: yych = *++YYCURSOR;
+ if(yych <= '\000') goto yy25;
+ goto yy63;
+yy62: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy63;
+yy63: switch(yych){
+ case '\000': goto yy64;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy62;
+ default: goto yy25;
+ }
+yy64: ++YYCURSOR;
+ goto yy65;
+yy65:
+#line 100 "implicit.re"
+{ return "float#exp"; }
+#line 463 "<stdout>"
+yy66: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy70;
+ case '.': goto yy68;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy67;
+ case ':': goto yy49;
+ default: goto yy25;
+ }
+yy67: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy70;
+ case '.': goto yy68;
+ case ':': goto yy49;
+ default: goto yy25;
+ }
+yy68: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy69;
+yy69: switch(yych){
+ case '\000': goto yy72;
+ case ',': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy68;
+ default: goto yy25;
+ }
+yy70: ++YYCURSOR;
+ goto yy71;
+yy71:
+#line 94 "implicit.re"
+{ return "int#base60"; }
+#line 518 "<stdout>"
+yy72: ++YYCURSOR;
+ goto yy73;
+yy73:
+#line 102 "implicit.re"
+{ return "float#base60"; }
+#line 524 "<stdout>"
+yy74: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy75;
+ default: goto yy48;
+ }
+yy75: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy76;
+ default: goto yy48;
+ }
+yy76: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy77;
+ default: goto yy25;
+ }
+yy77: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy78;
+ default: goto yy25;
+ }
+yy78: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy79;
+ default: goto yy25;
+ }
+yy79: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy80;
+ default: goto yy25;
+ }
+yy80: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy81;
+ default: goto yy25;
+ }
+yy81: yych = *++YYCURSOR;
+ switch(yych){
+ case '\000': goto yy82;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy25;
+ case 'T': goto yy84;
+ case 't': goto yy85;
+ default: goto yy87;
+ }
+yy82: ++YYCURSOR;
+ goto yy83;
+yy83:
+#line 110 "implicit.re"
+{ return "timestamp#ymd"; }
+#line 627 "<stdout>"
+yy84: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy126;
+ default: goto yy25;
+ }
+yy85: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy108;
+ default: goto yy25;
+ }
+yy86: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy87;
+yy87: switch(yych){
+ case '\t': case ' ': goto yy86;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy88;
+ default: goto yy25;
+ }
+yy88: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy89;
+ default: goto yy25;
+ }
+yy89: yych = *++YYCURSOR;
+ switch(yych){
+ case ':': goto yy90;
+ default: goto yy25;
+ }
+yy90: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy91;
+ default: goto yy25;
+ }
+yy91: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy92;
+ default: goto yy25;
+ }
+yy92: yych = *++YYCURSOR;
+ switch(yych){
+ case ':': goto yy93;
+ default: goto yy25;
+ }
+yy93: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy94;
+ default: goto yy25;
+ }
+yy94: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy95;
+ default: goto yy25;
+ }
+yy95: yych = *++YYCURSOR;
+ switch(yych){
+ case '\t': case ' ': goto yy98;
+ case '.': goto yy96;
+ default: goto yy25;
+ }
+yy96: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy97;
+yy97: switch(yych){
+ case '\t': case ' ': goto yy98;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy96;
+ default: goto yy25;
+ }
+yy98: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy99;
+yy99: switch(yych){
+ case '\t': case ' ': goto yy98;
+ case '+': case '-': goto yy101;
+ case 'Z': goto yy100;
+ default: goto yy25;
+ }
+yy100: yych = *++YYCURSOR;
+ if(yych <= '\000') goto yy105;
+ goto yy25;
+yy101: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy102;
+ default: goto yy25;
+ }
+yy102: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy103;
+ default: goto yy25;
+ }
+yy103: yych = *++YYCURSOR;
+ switch(yych){
+ case '\000': goto yy105;
+ case ':': goto yy104;
+ default: goto yy25;
+ }
+yy104: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy107;
+ default: goto yy25;
+ }
+yy105: ++YYCURSOR;
+ goto yy106;
+yy106:
+#line 114 "implicit.re"
+{ return "timestamp#spaced"; }
+#line 847 "<stdout>"
+yy107: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy100;
+ default: goto yy25;
+ }
+yy108: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy109;
+ default: goto yy25;
+ }
+yy109: yych = *++YYCURSOR;
+ switch(yych){
+ case ':': goto yy110;
+ default: goto yy25;
+ }
+yy110: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy111;
+ default: goto yy25;
+ }
+yy111: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy112;
+ default: goto yy25;
+ }
+yy112: yych = *++YYCURSOR;
+ switch(yych){
+ case ':': goto yy113;
+ default: goto yy25;
+ }
+yy113: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy114;
+ default: goto yy25;
+ }
+yy114: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy115;
+ default: goto yy25;
+ }
+yy115: yych = *++YYCURSOR;
+ switch(yych){
+ case '.': goto yy116;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy25;
+ default: goto yy117;
+ }
+yy116: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy117;
+yy117: switch(yych){
+ case '+': case '-': goto yy119;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy116;
+ case 'Z': goto yy118;
+ default: goto yy25;
+ }
+yy118: yych = *++YYCURSOR;
+ if(yych <= '\000') goto yy123;
+ goto yy25;
+yy119: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy120;
+ default: goto yy25;
+ }
+yy120: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy121;
+ default: goto yy25;
+ }
+yy121: yych = *++YYCURSOR;
+ switch(yych){
+ case '\000': goto yy123;
+ case ':': goto yy122;
+ default: goto yy25;
+ }
+yy122: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy125;
+ default: goto yy25;
+ }
+yy123: ++YYCURSOR;
+ goto yy124;
+yy124:
+#line 112 "implicit.re"
+{ return "timestamp#iso8601"; }
+#line 1033 "<stdout>"
+yy125: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy118;
+ default: goto yy25;
+ }
+yy126: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy127;
+ default: goto yy25;
+ }
+yy127: yych = *++YYCURSOR;
+ switch(yych){
+ case ':': goto yy128;
+ default: goto yy25;
+ }
+yy128: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy129;
+ default: goto yy25;
+ }
+yy129: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy130;
+ default: goto yy25;
+ }
+yy130: yych = *++YYCURSOR;
+ switch(yych){
+ case ':': goto yy131;
+ default: goto yy25;
+ }
+yy131: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy132;
+ default: goto yy25;
+ }
+yy132: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy133;
+ default: goto yy25;
+ }
+yy133: yych = *++YYCURSOR;
+ switch(yych){
+ case '.': goto yy134;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy25;
+ case 'Z': goto yy136;
+ default: goto yy135;
+ }
+yy134: ++YYCURSOR;
+ if((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
+ yych = *YYCURSOR;
+ goto yy135;
+yy135: switch(yych){
+ case '+': case '-': goto yy119;
+ case '0': goto yy134;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy138;
+ case 'Z': goto yy118;
+ default: goto yy25;
+ }
+yy136: yych = *++YYCURSOR;
+ if(yych >= '\001') goto yy25;
+ goto yy137;
+yy137: yych = *++YYCURSOR;
+ goto yy124;
+yy138: ++YYCURSOR;
+ if((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
+ yych = *YYCURSOR;
+ goto yy139;
+yy139: switch(yych){
+ case '+': case '-': goto yy119;
+ case '0': goto yy134;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy138;
+ case 'Z': goto yy136;
+ default: goto yy25;
+ }
+yy140: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7': goto yy155;
+ case '8':
+ case '9': goto yy153;
+ default: goto yy143;
+ }
+yy141: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy153;
+ default: goto yy152;
+ }
+yy142: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy143;
+yy143: switch(yych){
+ case '\000': goto yy149;
+ case ',': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7': goto yy142;
+ case '.': goto yy50;
+ case '8':
+ case '9': goto yy151;
+ case ':': goto yy49;
+ default: goto yy25;
+ }
+yy144: yych = *++YYCURSOR;
+ if(yych <= '\000') goto yy25;
+ goto yy146;
+yy145: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy146;
+yy146: switch(yych){
+ case '\000': goto yy147;
+ case ',': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f': goto yy145;
+ default: goto yy25;
+ }
+yy147: ++YYCURSOR;
+ goto yy148;
+yy148:
+#line 90 "implicit.re"
+{ return "int#hex"; }
+#line 1275 "<stdout>"
+yy149: ++YYCURSOR;
+ goto yy150;
+yy150:
+#line 92 "implicit.re"
+{ return "int#oct"; }
+#line 1281 "<stdout>"
+yy151: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy152;
+yy152: switch(yych){
+ case ',': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy151;
+ case '.': goto yy50;
+ case ':': goto yy49;
+ default: goto yy25;
+ }
+yy153: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy154;
+ default: goto yy152;
+ }
+yy154: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy76;
+ default: goto yy152;
+ }
+yy155: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7': goto yy156;
+ case '8':
+ case '9': goto yy154;
+ default: goto yy143;
+ }
+yy156: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy76;
+ default: goto yy143;
+ }
+yy157: yych = *++YYCURSOR;
+ switch(yych){
+ case 'I': goto yy160;
+ case 'i': goto yy159;
+ default: goto yy25;
+ }
+yy158: yych = *++YYCURSOR;
+ switch(yych){
+ case '\000': goto yy52;
+ case 'x': goto yy144;
+ default: goto yy143;
+ }
+yy159: yych = *++YYCURSOR;
+ switch(yych){
+ case 'n': goto yy166;
+ default: goto yy25;
+ }
+yy160: yych = *++YYCURSOR;
+ switch(yych){
+ case 'N': goto yy161;
+ case 'n': goto yy162;
+ default: goto yy25;
+ }
+yy161: yych = *++YYCURSOR;
+ switch(yych){
+ case 'F': goto yy163;
+ default: goto yy25;
+ }
+yy162: yych = *++YYCURSOR;
+ switch(yych){
+ case 'f': goto yy163;
+ default: goto yy25;
+ }
+yy163: yych = *++YYCURSOR;
+ if(yych >= '\001') goto yy25;
+ goto yy164;
+yy164: ++YYCURSOR;
+ goto yy165;
+yy165:
+#line 106 "implicit.re"
+{ return "float#neginf"; }
+#line 1381 "<stdout>"
+yy166: yych = *++YYCURSOR;
+ switch(yych){
+ case 'f': goto yy163;
+ default: goto yy25;
+ }
+yy167: yych = *++YYCURSOR;
+ switch(yych){
+ case 'I': goto yy33;
+ case 'i': goto yy32;
+ default: goto yy25;
+ }
+yy168: yych = *++YYCURSOR;
+ switch(yych){
+ case 'L': goto yy175;
+ default: goto yy25;
+ }
+yy169: yych = *++YYCURSOR;
+ switch(yych){
+ case 'l': goto yy170;
+ default: goto yy25;
+ }
+yy170: yych = *++YYCURSOR;
+ switch(yych){
+ case 's': goto yy171;
+ default: goto yy25;
+ }
+yy171: yych = *++YYCURSOR;
+ switch(yych){
+ case 'e': goto yy172;
+ default: goto yy25;
+ }
+yy172: yych = *++YYCURSOR;
+ if(yych >= '\001') goto yy25;
+ goto yy173;
+yy173: ++YYCURSOR;
+ goto yy174;
+yy174:
+#line 88 "implicit.re"
+{ return "bool#no"; }
+#line 1421 "<stdout>"
+yy175: yych = *++YYCURSOR;
+ switch(yych){
+ case 'S': goto yy176;
+ default: goto yy25;
+ }
+yy176: yych = *++YYCURSOR;
+ switch(yych){
+ case 'E': goto yy172;
+ default: goto yy25;
+ }
+yy177: yych = *++YYCURSOR;
+ switch(yych){
+ case 'l': goto yy178;
+ default: goto yy25;
+ }
+yy178: yych = *++YYCURSOR;
+ switch(yych){
+ case 's': goto yy179;
+ default: goto yy25;
+ }
+yy179: yych = *++YYCURSOR;
+ switch(yych){
+ case 'e': goto yy172;
+ default: goto yy25;
+ }
+yy180: yych = *++YYCURSOR;
+ switch(yych){
+ case 'F': goto yy172;
+ default: goto yy25;
+ }
+yy181: yych = *++YYCURSOR;
+ switch(yych){
+ case 'f': goto yy172;
+ default: goto yy25;
+ }
+yy182: yych = *++YYCURSOR;
+ if(yych >= '\001') goto yy25;
+ goto yy183;
+yy183: ++YYCURSOR;
+ goto yy184;
+yy184:
+#line 86 "implicit.re"
+{ return "bool#yes"; }
+#line 1465 "<stdout>"
+yy185: yych = *++YYCURSOR;
+ switch(yych){
+ case 'f': goto yy172;
+ default: goto yy25;
+ }
+yy186: yych = *++YYCURSOR;
+ switch(yych){
+ case 'U': goto yy189;
+ default: goto yy25;
+ }
+yy187: yych = *++YYCURSOR;
+ switch(yych){
+ case 'u': goto yy188;
+ default: goto yy25;
+ }
+yy188: yych = *++YYCURSOR;
+ switch(yych){
+ case 'e': goto yy182;
+ default: goto yy25;
+ }
+yy189: yych = *++YYCURSOR;
+ switch(yych){
+ case 'E': goto yy182;
+ default: goto yy25;
+ }
+yy190: yych = *++YYCURSOR;
+ switch(yych){
+ case 'u': goto yy191;
+ default: goto yy25;
+ }
+yy191: yych = *++YYCURSOR;
+ switch(yych){
+ case 'e': goto yy182;
+ default: goto yy25;
+ }
+yy192: yych = *++YYCURSOR;
+ switch(yych){
+ case 'S': goto yy182;
+ default: goto yy25;
+ }
+yy193: yych = *++YYCURSOR;
+ switch(yych){
+ case 's': goto yy182;
+ default: goto yy25;
+ }
+yy194: yych = *++YYCURSOR;
+ switch(yych){
+ case 's': goto yy182;
+ default: goto yy25;
+ }
+yy195: yych = *++YYCURSOR;
+ switch(yych){
+ case 'L': goto yy199;
+ default: goto yy25;
+ }
+yy196: yych = *++YYCURSOR;
+ switch(yych){
+ case 'l': goto yy197;
+ default: goto yy25;
+ }
+yy197: yych = *++YYCURSOR;
+ switch(yych){
+ case 'l': goto yy198;
+ default: goto yy25;
+ }
+yy198: yych = *++YYCURSOR;
+ if(yych <= '\000') goto yy6;
+ goto yy25;
+yy199: yych = *++YYCURSOR;
+ switch(yych){
+ case 'L': goto yy198;
+ default: goto yy25;
+ }
+yy200: yych = *++YYCURSOR;
+ switch(yych){
+ case 'l': goto yy201;
+ default: goto yy25;
+ }
+yy201: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case 'l': goto yy198;
+ default: goto yy25;
+ }
+}
+#line 124 "implicit.re"
+
+
+}
+
+char *
+syck_type_id_to_uri( char *type_id )
+{
+ char *cursor, *limit, *marker;
+
+ cursor = type_id;
+ limit = type_id + strlen( type_id );
+
+
+#line 1552 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy202;
+yy203: ++YYCURSOR;
+yy202:
+ if((YYLIMIT - YYCURSOR) < 21) YYFILL(21);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy204;
+ case '!': goto yy208;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's': case 'u':
+ case 'v':
+ case 'w': case 'y':
+ case 'z': goto yy210;
+ case 't': goto yy205;
+ case 'x': goto yy207;
+ default: goto yy211;
+ }
+yy204: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy206;
+ }
+yy205: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case ',': goto yy216;
+ case '-': goto yy212;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy214;
+ case 'a': goto yy246;
+ default: goto yy206;
+ }
+yy206:
+#line 176 "implicit.re"
+{ return syck_taguri( YAML_DOMAIN, type_id, strlen( type_id ) ); }
+#line 1700 "<stdout>"
+yy207: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case ',': case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy215;
+ case '-': goto yy236;
+ default: goto yy206;
+ }
+yy208: ++YYCURSOR;
+ goto yy209;
+yy209:
+#line 150 "implicit.re"
+{ return syck_xprivate( type_id + 1, strlen( type_id ) - 1 ); }
+#line 1774 "<stdout>"
+yy210: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case ',': goto yy216;
+ case '-': goto yy212;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy214;
+ default: goto yy206;
+ }
+yy211: yych = *++YYCURSOR;
+ goto yy206;
+yy212: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy213;
+yy213: switch(yych){
+ case '-': goto yy212;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy214;
+ default: goto yy204;
+ }
+yy214: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy215;
+yy215: switch(yych){
+ case ',': goto yy216;
+ case '-': goto yy212;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy214;
+ default: goto yy204;
+ }
+yy216: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy224;
+ default: goto yy204;
+ }
+yy217: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy220;
+ default: goto yy204;
+ }
+yy218: ++YYCURSOR;
+ goto yy219;
+yy219:
+#line 152 "implicit.re"
+{ char *domain = S_ALLOC_N( char, ( YYCURSOR - type_id ) + 15 );
+ char *uri;
+
+ domain[0] = '\0';
+ strncat( domain, type_id, ( YYCURSOR - type_id ) - 1 );
+ strcat( domain, "." );
+ strcat( domain, YAML_DOMAIN );
+ uri = syck_taguri( domain, YYCURSOR, YYLIMIT - YYCURSOR );
+
+ S_FREE( domain );
+ return uri;
+ }
+#line 2084 "<stdout>"
+yy220: ++YYCURSOR;
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ goto yy221;
+yy221: switch(yych){
+ case ',': goto yy216;
+ case '-': goto yy222;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy220;
+ default: goto yy204;
+ }
+yy222: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy223;
+yy223: switch(yych){
+ case '-': goto yy222;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy220;
+ default: goto yy204;
+ }
+yy224: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy225;
+ default: goto yy204;
+ }
+yy225: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy226;
+ default: goto yy204;
+ }
+yy226: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy227;
+ default: goto yy204;
+ }
+yy227: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy228;
+ case '/': goto yy229;
+ default: goto yy204;
+ }
+yy228: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy231;
+ default: goto yy204;
+ }
+yy229: ++YYCURSOR;
+ goto yy230;
+yy230:
+#line 165 "implicit.re"
+{ char *domain = S_ALLOC_N( char, YYCURSOR - type_id );
+ char *uri;
+
+ domain[0] = '\0';
+ strncat( domain, type_id, ( YYCURSOR - type_id ) - 1 );
+ uri = syck_taguri( domain, YYCURSOR, YYLIMIT - YYCURSOR );
+
+ S_FREE( domain );
+ return uri;
+ }
+#line 2302 "<stdout>"
+yy231: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy232;
+ default: goto yy204;
+ }
+yy232: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy233;
+ case '/': goto yy229;
+ default: goto yy204;
+ }
+yy233: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy234;
+ default: goto yy204;
+ }
+yy234: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy235;
+ default: goto yy204;
+ }
+yy235: yych = *++YYCURSOR;
+ switch(yych){
+ case '/': goto yy229;
+ default: goto yy204;
+ }
+yy236: yych = *++YYCURSOR;
+ switch(yych){
+ case 'p': goto yy237;
+ default: goto yy213;
+ }
+yy237: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case 'r': goto yy238;
+ default: goto yy213;
+ }
+yy238: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case 'i': goto yy239;
+ default: goto yy213;
+ }
+yy239: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case 'v': goto yy240;
+ default: goto yy213;
+ }
+yy240: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case 'a': goto yy241;
+ default: goto yy213;
+ }
+yy241: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case 't': goto yy242;
+ default: goto yy213;
+ }
+yy242: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case 'e': goto yy243;
+ default: goto yy213;
+ }
+yy243: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case ':': goto yy244;
+ default: goto yy213;
+ }
+yy244: ++YYCURSOR;
+ goto yy245;
+yy245:
+#line 148 "implicit.re"
+{ return type_id; }
+#line 2422 "<stdout>"
+yy246: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case 'g': goto yy247;
+ default: goto yy213;
+ }
+yy247: yych = *++YYCURSOR;
+ switch(yych){
+ case ',': goto yy216;
+ case '.': goto yy217;
+ case '/': goto yy218;
+ case ':': goto yy248;
+ default: goto yy213;
+ }
+yy248: yych = *++YYCURSOR;
+ switch(yych){
+ case ',':
+ case '-':
+ case '.': goto yy204;
+ default: goto yy250;
+ }
+yy249: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy250;
+yy250: switch(yych){
+ case ',': goto yy253;
+ case '-': goto yy251;
+ case '.': goto yy254;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy249;
+ default: goto yy204;
+ }
+yy251: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy252;
+yy252: switch(yych){
+ case '-': goto yy251;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy249;
+ default: goto yy204;
+ }
+yy253: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy259;
+ default: goto yy204;
+ }
+yy254: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy255;
+ default: goto yy204;
+ }
+yy255: ++YYCURSOR;
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ goto yy256;
+yy256: switch(yych){
+ case ',': goto yy253;
+ case '-': goto yy257;
+ case '.': goto yy254;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy255;
+ default: goto yy204;
+ }
+yy257: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy258;
+yy258: switch(yych){
+ case '-': goto yy257;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy255;
+ default: goto yy204;
+ }
+yy259: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy260;
+ default: goto yy204;
+ }
+yy260: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy261;
+ default: goto yy204;
+ }
+yy261: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy262;
+ default: goto yy204;
+ }
+yy262: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy263;
+ case ':': goto yy264;
+ default: goto yy204;
+ }
+yy263: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy266;
+ default: goto yy204;
+ }
+yy264: ++YYCURSOR;
+ goto yy265;
+yy265:
+#line 146 "implicit.re"
+{ return type_id; }
+#line 2874 "<stdout>"
+yy266: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy267;
+ default: goto yy204;
+ }
+yy267: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy268;
+ case ':': goto yy264;
+ default: goto yy204;
+ }
+yy268: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy269;
+ default: goto yy204;
+ }
+yy269: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy270;
+ default: goto yy204;
+ }
+yy270: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case ':': goto yy264;
+ default: goto yy204;
+ }
+}
+#line 178 "implicit.re"
+
+
+}
+
diff --git a/ext/syck/node.c b/ext/syck/node.c
new file mode 100644
index 0000000000..500ede2a4c
--- /dev/null
+++ b/ext/syck/node.c
@@ -0,0 +1,337 @@
+/*
+ * node.c
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+
+#include "ruby.h"
+#include "syck.h"
+
+/*
+ * Node allocation functions
+ */
+SyckNode *
+syck_alloc_node( enum syck_kind_tag type )
+{
+ SyckNode *s;
+
+ s = S_ALLOC( SyckNode );
+ s->kind = type;
+ s->id = 0;
+ s->type_id = NULL;
+ s->anchor = NULL;
+ s->shortcut = NULL;
+
+ return s;
+}
+
+void
+syck_free_node( SyckNode *n )
+{
+ syck_free_members( n );
+ if ( n->type_id != NULL )
+ S_FREE( n->type_id );
+ if ( n->anchor != NULL )
+ S_FREE( n->anchor );
+ S_FREE( n );
+}
+
+SyckNode *
+syck_alloc_map()
+{
+ SyckNode *n;
+ struct SyckMap *m;
+
+ m = S_ALLOC( struct SyckMap );
+ m->idx = 0;
+ m->capa = ALLOC_CT;
+ m->keys = S_ALLOC_N( SYMID, m->capa );
+ m->values = S_ALLOC_N( SYMID, m->capa );
+
+ n = syck_alloc_node( syck_map_kind );
+ n->data.pairs = m;
+
+ return n;
+}
+
+SyckNode *
+syck_alloc_seq()
+{
+ SyckNode *n;
+ struct SyckSeq *s;
+
+ s = S_ALLOC( struct SyckSeq );
+ s->idx = 0;
+ s->capa = ALLOC_CT;
+ s->items = S_ALLOC_N( SYMID, s->capa );
+
+ n = syck_alloc_node( syck_seq_kind );
+ n->data.list = s;
+
+ return n;
+}
+
+SyckNode *
+syck_alloc_str()
+{
+ SyckNode *n;
+ struct SyckStr *s;
+
+ s = S_ALLOC( struct SyckStr );
+ s->len = 0;
+ s->ptr = NULL;
+ s->style = scalar_none;
+
+ n = syck_alloc_node( syck_str_kind );
+ n->data.str = s;
+
+ return n;
+}
+
+SyckNode *
+syck_new_str( char *str, enum scalar_style style )
+{
+ return syck_new_str2( str, strlen( str ), style );
+}
+
+SyckNode *
+syck_new_str2( char *str, long len, enum scalar_style style )
+{
+ SyckNode *n;
+
+ n = syck_alloc_str();
+ n->data.str->ptr = S_ALLOC_N( char, len + 1 );
+ n->data.str->len = len;
+ n->data.str->style = style;
+ memcpy( n->data.str->ptr, str, len );
+ n->data.str->ptr[len] = '\0';
+
+ return n;
+}
+
+void
+syck_str_blow_away_commas( SyckNode *n )
+{
+ char *go, *end;
+
+ go = n->data.str->ptr;
+ end = go + n->data.str->len;
+ while ( *(++go) != '\0' )
+ {
+ if ( *go == ',' )
+ {
+ n->data.str->len -= 1;
+ memmove( go, go + 1, end - go );
+ end -= 1;
+ }
+ }
+}
+
+char *
+syck_str_read( SyckNode *n )
+{
+ ASSERT( n != NULL );
+ return n->data.str->ptr;
+}
+
+SyckNode *
+syck_new_map( SYMID key, SYMID value )
+{
+ SyckNode *n;
+
+ n = syck_alloc_map();
+ syck_map_add( n, key, value );
+
+ return n;
+}
+
+void
+syck_map_add( SyckNode *map, SYMID key, SYMID value )
+{
+ struct SyckMap *m;
+ long idx;
+
+ ASSERT( map != NULL );
+ ASSERT( map->data.pairs != NULL );
+
+ m = map->data.pairs;
+ idx = m->idx;
+ m->idx += 1;
+ if ( m->idx > m->capa )
+ {
+ m->capa += ALLOC_CT;
+ S_REALLOC_N( m->keys, SYMID, m->capa );
+ S_REALLOC_N( m->values, SYMID, m->capa );
+ }
+ m->keys[idx] = key;
+ m->values[idx] = value;
+}
+
+void
+syck_map_update( SyckNode *map1, SyckNode *map2 )
+{
+ struct SyckMap *m1, *m2;
+ long new_idx, new_capa;
+ ASSERT( map1 != NULL );
+ ASSERT( map2 != NULL );
+
+ m1 = map1->data.pairs;
+ m2 = map2->data.pairs;
+ if ( m2->idx < 1 ) return;
+
+ new_idx = m1->idx;
+ new_idx += m2->idx;
+ new_capa = m1->capa;
+ while ( new_idx > new_capa )
+ {
+ new_capa += ALLOC_CT;
+ }
+ if ( new_capa > m1->capa )
+ {
+ m1->capa = new_capa;
+ S_REALLOC_N( m1->keys, SYMID, m1->capa );
+ S_REALLOC_N( m1->values, SYMID, m1->capa );
+ }
+ for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ )
+ {
+ m1->keys[m1->idx] = m2->keys[new_idx];
+ m1->values[m1->idx] = m2->values[new_idx];
+ }
+}
+
+long
+syck_map_count( SyckNode *map )
+{
+ ASSERT( map != NULL );
+ ASSERT( map->data.pairs != NULL );
+ return map->data.pairs->idx;
+}
+
+void
+syck_map_assign( SyckNode *map, enum map_part p, long idx, SYMID id )
+{
+ struct SyckMap *m;
+
+ ASSERT( map != NULL );
+ m = map->data.pairs;
+ ASSERT( m != NULL );
+ if ( p == map_key )
+ {
+ m->keys[idx] = id;
+ }
+ else
+ {
+ m->values[idx] = id;
+ }
+}
+
+SYMID
+syck_map_read( SyckNode *map, enum map_part p, long idx )
+{
+ struct SyckMap *m;
+
+ ASSERT( map != NULL );
+ m = map->data.pairs;
+ ASSERT( m != NULL );
+ if ( p == map_key )
+ {
+ return m->keys[idx];
+ }
+ else
+ {
+ return m->values[idx];
+ }
+}
+
+SyckNode *
+syck_new_seq( SYMID value )
+{
+ SyckNode *n;
+
+ n = syck_alloc_seq();
+ syck_seq_add( n, value );
+
+ return n;
+}
+
+void
+syck_seq_add( SyckNode *arr, SYMID value )
+{
+ struct SyckSeq *s;
+ long idx;
+
+ ASSERT( arr != NULL );
+ ASSERT( arr->data.list != NULL );
+
+ s = arr->data.list;
+ idx = s->idx;
+ s->idx += 1;
+ if ( s->idx > s->capa )
+ {
+ s->capa += ALLOC_CT;
+ S_REALLOC_N( s->items, SYMID, s->capa );
+ }
+ s->items[idx] = value;
+}
+
+long
+syck_seq_count( SyckNode *seq )
+{
+ ASSERT( seq != NULL );
+ ASSERT( seq->data.list != NULL );
+ return seq->data.list->idx;
+}
+
+SYMID
+syck_seq_read( SyckNode *seq, long idx )
+{
+ struct SyckSeq *s;
+
+ ASSERT( seq != NULL );
+ s = seq->data.list;
+ ASSERT( s != NULL );
+ return s->items[idx];
+}
+
+void
+syck_free_members( SyckNode *n )
+{
+ if ( n == NULL ) return;
+
+ switch ( n->kind )
+ {
+ case syck_str_kind:
+ if ( n->data.str != NULL )
+ {
+ S_FREE( n->data.str->ptr );
+ n->data.str->ptr = NULL;
+ n->data.str->len = 0;
+ S_FREE( n->data.str );
+ n->data.str = NULL;
+ }
+ break;
+
+ case syck_seq_kind:
+ if ( n->data.list != NULL )
+ {
+ S_FREE( n->data.list->items );
+ S_FREE( n->data.list );
+ n->data.list = NULL;
+ }
+ break;
+
+ case syck_map_kind:
+ if ( n->data.pairs != NULL )
+ {
+ S_FREE( n->data.pairs->keys );
+ S_FREE( n->data.pairs->values );
+ S_FREE( n->data.pairs );
+ n->data.pairs = NULL;
+ }
+ break;
+ }
+}
+
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
new file mode 100644
index 0000000000..c54deea618
--- /dev/null
+++ b/ext/syck/rubyext.c
@@ -0,0 +1,1581 @@
+/* -*- indent-tabs-mode: nil -*-
+/*
+ * rubyext.c
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+
+#include "ruby.h"
+#include "syck.h"
+#include <sys/types.h>
+#include <time.h>
+
+typedef struct RVALUE {
+ union {
+#if 0
+ struct {
+ unsigned long flags; /* always 0 for freed obj */
+ struct RVALUE *next;
+ } free;
+#endif
+ struct RBasic basic;
+ struct RObject object;
+ struct RClass klass;
+ /*struct RFloat flonum;*/
+ /*struct RString string;*/
+ struct RArray array;
+ /*struct RRegexp regexp;*/
+ struct RHash hash;
+ /*struct RData data;*/
+ struct RStruct rstruct;
+ /*struct RBignum bignum;*/
+ /*struct RFile file;*/
+ } as;
+} RVALUE;
+
+typedef struct {
+ long hash;
+ char *buffer;
+ long length;
+ long remaining;
+ int printed;
+} bytestring_t;
+
+#define RUBY_DOMAIN "ruby.yaml.org,2002"
+
+/*
+ * symbols and constants
+ */
+static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_match, s_keys, s_to_str, s_unpack, s_tr_bang, s_anchors, s_default_set;
+static ID s_anchors, s_domain, s_families, s_kind, s_name, s_options, s_private_types, s_type_id, s_value;
+static VALUE sym_model, sym_generic, sym_input, sym_bytecode;
+static VALUE sym_scalar, sym_seq, sym_map;
+VALUE cDate, cParser, cLoader, cNode, cPrivateType, cDomainType, cBadAlias, cDefaultKey, cMergeKey, cEmitter;
+VALUE oDefaultLoader;
+
+/*
+ * my private collection of numerical oddities.
+ */
+static double S_zero() { return 0.0; }
+static double S_one() { return 1.0; }
+static double S_inf() { return S_one() / S_zero(); }
+static double S_nan() { return S_zero() / S_zero(); }
+
+static VALUE syck_node_transform( VALUE );
+
+/*
+ * handler prototypes
+ */
+SYMID rb_syck_parse_handler _((SyckParser *, SyckNode *));
+SYMID rb_syck_load_handler _((SyckParser *, SyckNode *));
+void rb_syck_err_handler _((SyckParser *, char *));
+SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *));
+void rb_syck_output_handler _((SyckEmitter *, char *, long));
+int syck_parser_assign_io _((SyckParser *, VALUE));
+
+struct parser_xtra {
+ VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */
+ VALUE proc;
+ int taint;
+};
+
+/*
+ * Convert YAML to bytecode
+ */
+VALUE
+rb_syck_compile(self, port)
+ VALUE self, port;
+{
+ SYMID oid;
+ int taint;
+ char *ret;
+ VALUE bc;
+ bytestring_t *sav;
+
+ SyckParser *parser = syck_new_parser();
+ taint = syck_parser_assign_io(parser, port);
+ syck_parser_handler( parser, syck_yaml2byte_handler );
+ syck_parser_error_handler( parser, NULL );
+ syck_parser_implicit_typing( parser, 0 );
+ syck_parser_taguri_expansion( parser, 0 );
+ oid = syck_parse( parser );
+ syck_lookup_sym( parser, oid, (char **)&sav );
+
+ ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 );
+ ret[0] = '\0';
+ strcat( ret, "D\n" );
+ strcat( ret, sav->buffer );
+
+ syck_free_parser( parser );
+
+ bc = rb_str_new2( ret );
+ if ( taint ) OBJ_TAINT( bc );
+ return bc;
+}
+
+/*
+ * read from io.
+ */
+long
+rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
+{
+ long len = 0;
+
+ ASSERT( str != NULL );
+ max_size -= skip;
+
+ if ( max_size <= 0 ) max_size = 0;
+ else
+ {
+ /*
+ * call io#read.
+ */
+ VALUE src = (VALUE)str->ptr;
+ VALUE n = LONG2NUM(max_size);
+ VALUE str2 = rb_funcall2(src, s_read, 1, &n);
+ if (!NIL_P(str2))
+ {
+ len = RSTRING(str2)->len;
+ memcpy( buf + skip, RSTRING(str2)->ptr, len );
+ }
+ }
+ len += skip;
+ buf[len] = '\0';
+ return len;
+}
+
+/*
+ * determine: are we reading from a string or io?
+ * (returns tainted? boolean)
+ */
+int
+syck_parser_assign_io(parser, port)
+ SyckParser *parser;
+ VALUE port;
+{
+ int taint = Qtrue;
+ if (rb_respond_to(port, s_to_str)) {
+ taint = OBJ_TAINTED(port); /* original taintedness */
+ StringValue(port); /* possible conversion */
+ syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL );
+ }
+ else if (rb_respond_to(port, s_read)) {
+ if (rb_respond_to(port, s_binmode)) {
+ rb_funcall2(port, s_binmode, 0, 0);
+ }
+ syck_parser_str( parser, (char *)port, 0, rb_syck_io_str_read );
+ }
+ else {
+ rb_raise(rb_eTypeError, "instance of IO needed");
+ }
+ return taint;
+}
+
+/*
+ * Get value in hash by key, forcing an empty hash if nil.
+ */
+VALUE
+syck_get_hash_aref(hsh, key)
+ VALUE hsh, key;
+{
+ VALUE val = rb_hash_aref( hsh, key );
+ if ( NIL_P( val ) )
+ {
+ val = rb_hash_new();
+ rb_hash_aset(hsh, key, val);
+ }
+ return val;
+}
+
+/*
+ * creating timestamps
+ */
+SYMID
+rb_syck_mktime(str)
+ char *str;
+{
+ VALUE time;
+ char *ptr = str;
+ VALUE year, mon, day, hour, min, sec;
+ long usec;
+
+ /* Year*/
+ ptr[4] = '\0';
+ year = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Month*/
+ ptr += 4;
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ mon = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Day*/
+ ptr += 2;
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ day = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Hour*/
+ ptr += 2;
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ hour = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Minute */
+ ptr += 2;
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ min = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Second */
+ ptr += 2;
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ sec = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Millisecond */
+ ptr += 2;
+ if ( *ptr == '.' )
+ {
+ char *padded = syck_strndup( "000000", 6 );
+ char *end = ptr + 1;
+ while ( isdigit( *end ) ) end++;
+ MEMCPY(padded, ptr + 1, char, end - (ptr + 1));
+ usec = strtol(padded, NULL, 10);
+ }
+ else
+ {
+ usec = 0;
+ }
+
+ /* Time Zone*/
+ while ( *ptr != 'Z' && *ptr != '+' && *ptr != '-' && *ptr != '\0' ) ptr++;
+ if ( *ptr == '-' || *ptr == '+' )
+ {
+ time_t tz_offset = strtol(ptr, NULL, 10) * 3600;
+ time_t tmp;
+
+ while ( *ptr != ':' && *ptr != '\0' ) ptr++;
+ if ( *ptr == ':' )
+ {
+ ptr += 1;
+ if ( tz_offset < 0 )
+ {
+ tz_offset -= strtol(ptr, NULL, 10) * 60;
+ }
+ else
+ {
+ tz_offset += strtol(ptr, NULL, 10) * 60;
+ }
+ }
+
+ /* Make TZ time*/
+ time = rb_funcall(rb_cTime, s_utc, 6, year, mon, day, hour, min, sec);
+ tmp = NUM2LONG(rb_funcall(time, s_to_i, 0)) - tz_offset;
+ return rb_funcall(rb_cTime, s_at, 2, LONG2NUM(tmp), LONG2NUM(usec));
+ }
+ else
+ {
+ /* Make UTC time*/
+ return rb_funcall(rb_cTime, s_utc, 7, year, mon, day, hour, min, sec, LONG2NUM(usec));
+
+ }
+}
+
+/*
+ * {generic mode} node handler
+ * - Loads data into Node classes
+ */
+SYMID
+rb_syck_parse_handler(p, n)
+ SyckParser *p;
+ SyckNode *n;
+{
+ VALUE t, obj, v = Qnil;
+ int i;
+ struct parser_xtra *bonus;
+
+ obj = rb_obj_alloc(cNode);
+ if ( n->type_id != NULL )
+ {
+ t = rb_str_new2(n->type_id);
+ rb_ivar_set(obj, s_type_id, t);
+ }
+
+ switch (n->kind)
+ {
+ case syck_str_kind:
+ rb_ivar_set(obj, s_kind, sym_scalar);
+ v = rb_str_new( n->data.str->ptr, n->data.str->len );
+ break;
+
+ case syck_seq_kind:
+ rb_ivar_set(obj, s_kind, sym_seq);
+ v = rb_ary_new2( n->data.list->idx );
+ for ( i = 0; i < n->data.list->idx; i++ )
+ {
+ rb_ary_store( v, i, syck_seq_read( n, i ) );
+ }
+ break;
+
+ case syck_map_kind:
+ rb_ivar_set(obj, s_kind, sym_map);
+ v = rb_hash_new();
+ for ( i = 0; i < n->data.pairs->idx; i++ )
+ {
+ VALUE key = syck_node_transform( syck_map_read( n, map_key, i ) );
+ VALUE val = rb_ary_new();
+ rb_ary_push(val, syck_map_read( n, map_key, i ));
+ rb_ary_push(val, syck_map_read( n, map_value, i ));
+
+ rb_hash_aset( v, key, val );
+ }
+ break;
+ }
+
+ bonus = (struct parser_xtra *)p->bonus;
+ if ( bonus->taint) OBJ_TAINT( obj );
+ if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, v);
+
+ rb_ivar_set(obj, s_value, v);
+ rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
+ return obj;
+}
+
+/*
+ * handles merging of an array of hashes
+ * (see http://www.yaml.org/type/merge/)
+ */
+VALUE
+syck_merge_i( entry, hsh )
+ VALUE entry, hsh;
+{
+ if ( rb_obj_is_kind_of( entry, rb_cHash ) )
+ {
+ rb_funcall( hsh, s_update, 1, entry );
+ }
+ return Qnil;
+}
+
+/*
+ * build a syck node from a Ruby VALUE
+ */
+SyckNode *
+rb_new_syck_node( obj, type_id )
+ VALUE obj, type_id;
+{
+ long i = 0;
+ SyckNode *n = NULL;
+
+ if (rb_respond_to(obj, s_to_str))
+ {
+ StringValue(obj); /* possible conversion */
+ n = syck_alloc_str();
+ n->data.str->ptr = RSTRING(obj)->ptr;
+ n->data.str->len = RSTRING(obj)->len;
+ }
+ else if ( rb_obj_is_kind_of( obj, rb_cArray ) )
+ {
+ n = syck_alloc_seq();
+ for ( i = 0; i < RARRAY(obj)->len; i++ )
+ {
+ syck_seq_add(n, rb_ary_entry(obj, i));
+ }
+ }
+ else if ( rb_obj_is_kind_of( obj, rb_cHash ) )
+ {
+ VALUE keys;
+ n = syck_alloc_map();
+ keys = rb_funcall( obj, s_keys, 0 );
+ for ( i = 0; i < RARRAY(keys)->len; i++ )
+ {
+ VALUE key = rb_ary_entry(keys, i);
+ syck_map_add(n, key, rb_hash_aref(obj, key));
+ }
+ }
+
+ if ( n!= NULL && rb_respond_to( type_id, s_to_str ) )
+ {
+ StringValue(type_id);
+ n->type_id = syck_strndup( RSTRING(type_id)->ptr, RSTRING(type_id)->len );
+ }
+
+ return n;
+}
+
+/*
+ * default handler for ruby.yaml.org types
+ */
+int
+yaml_org_handler( n, ref )
+ SyckNode *n;
+ VALUE *ref;
+{
+ char *type_id = n->type_id;
+ int transferred = 0;
+ long i = 0;
+ VALUE obj = Qnil;
+
+ switch (n->kind)
+ {
+ case syck_str_kind:
+ transferred = 1;
+ if ( type_id == NULL )
+ {
+ obj = rb_str_new( n->data.str->ptr, n->data.str->len );
+ }
+ else if ( strcmp( type_id, "null" ) == 0 )
+ {
+ obj = Qnil;
+ }
+ else if ( strcmp( type_id, "binary" ) == 0 )
+ {
+ VALUE arr;
+ obj = rb_str_new( n->data.str->ptr, n->data.str->len );
+ rb_funcall( obj, s_tr_bang, 2, rb_str_new2( "\n\t " ), rb_str_new2( "" ) );
+ arr = rb_funcall( obj, s_unpack, 1, rb_str_new2( "m" ) );
+ obj = rb_ary_shift( arr );
+ }
+ else if ( strcmp( type_id, "bool#yes" ) == 0 )
+ {
+ obj = Qtrue;
+ }
+ else if ( strcmp( type_id, "bool#no" ) == 0 )
+ {
+ obj = Qfalse;
+ }
+ else if ( strcmp( type_id, "int#hex" ) == 0 )
+ {
+ syck_str_blow_away_commas( n );
+ obj = rb_cstr2inum( n->data.str->ptr, 16 );
+ }
+ else if ( strcmp( type_id, "int#oct" ) == 0 )
+ {
+ syck_str_blow_away_commas( n );
+ obj = rb_cstr2inum( n->data.str->ptr, 8 );
+ }
+ else if ( strcmp( type_id, "int#base60" ) == 0 )
+ {
+ char *ptr, *end;
+ long sixty = 1;
+ long total = 0;
+ syck_str_blow_away_commas( n );
+ ptr = n->data.str->ptr;
+ end = n->data.str->ptr + n->data.str->len;
+ while ( end > ptr )
+ {
+ long bnum = 0;
+ char *colon = end - 1;
+ while ( colon >= ptr && *colon != ':' )
+ {
+ colon--;
+ }
+ if ( *colon == ':' ) *colon = '\0';
+
+ bnum = strtol( colon + 1, NULL, 10 );
+ total += bnum * sixty;
+ sixty *= 60;
+ end = colon;
+ }
+ obj = INT2FIX(total);
+ }
+ else if ( strncmp( type_id, "int", 3 ) == 0 )
+ {
+ syck_str_blow_away_commas( n );
+ obj = rb_cstr2inum( n->data.str->ptr, 10 );
+ }
+ else if ( strcmp( type_id, "float#base60" ) == 0 )
+ {
+ char *ptr, *end;
+ long sixty = 1;
+ double total = 0.0;
+ syck_str_blow_away_commas( n );
+ ptr = n->data.str->ptr;
+ end = n->data.str->ptr + n->data.str->len;
+ while ( end > ptr )
+ {
+ double bnum = 0;
+ char *colon = end - 1;
+ while ( colon >= ptr && *colon != ':' )
+ {
+ colon--;
+ }
+ if ( *colon == ':' ) *colon = '\0';
+
+ bnum = strtod( colon + 1, NULL );
+ total += bnum * sixty;
+ sixty *= 60;
+ end = colon;
+ }
+ obj = rb_float_new( total );
+ }
+ else if ( strcmp( type_id, "float#nan" ) == 0 )
+ {
+ obj = rb_float_new( S_nan() );
+ }
+ else if ( strcmp( type_id, "float#inf" ) == 0 )
+ {
+ obj = rb_float_new( S_inf() );
+ }
+ else if ( strcmp( type_id, "float#neginf" ) == 0 )
+ {
+ obj = rb_float_new( -S_inf() );
+ }
+ else if ( strncmp( type_id, "float", 5 ) == 0 )
+ {
+ double f;
+ syck_str_blow_away_commas( n );
+ f = strtod( n->data.str->ptr, NULL );
+ obj = rb_float_new( f );
+ }
+ else if ( strcmp( type_id, "timestamp#iso8601" ) == 0 )
+ {
+ obj = rb_syck_mktime( n->data.str->ptr );
+ }
+ else if ( strcmp( type_id, "timestamp#spaced" ) == 0 )
+ {
+ obj = rb_syck_mktime( n->data.str->ptr );
+ }
+ else if ( strcmp( type_id, "timestamp#ymd" ) == 0 )
+ {
+ char *ptr = n->data.str->ptr;
+ VALUE year, mon, day;
+
+ /* Year*/
+ ptr[4] = '\0';
+ year = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Month*/
+ ptr += 4;
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ mon = INT2FIX(strtol(ptr, NULL, 10));
+
+ /* Day*/
+ ptr += 2;
+ while ( !ISDIGIT( *ptr ) ) ptr++;
+ day = INT2FIX(strtol(ptr, NULL, 10));
+
+ if ( !cDate ) {
+ /*
+ * Load Date module
+ */
+ rb_require( "date" );
+ cDate = rb_const_get( rb_cObject, rb_intern("Date") );
+ }
+
+ obj = rb_funcall( cDate, s_new, 3, year, mon, day );
+ }
+ else if ( strncmp( type_id, "timestamp", 9 ) == 0 )
+ {
+ obj = rb_syck_mktime( n->data.str->ptr );
+ }
+ else if ( strncmp( type_id, "merge", 5 ) == 0 )
+ {
+ obj = rb_funcall( cMergeKey, s_new, 0 );
+ }
+ else if ( strncmp( type_id, "default", 7 ) == 0 )
+ {
+ obj = rb_funcall( cDefaultKey, s_new, 0 );
+ }
+ else if ( n->data.str->style == scalar_plain &&
+ n->data.str->len > 1 &&
+ strncmp( n->data.str->ptr, ":", 1 ) == 0 )
+ {
+ obj = rb_funcall( oDefaultLoader, s_transfer, 2,
+ rb_str_new2( "ruby/sym" ),
+ rb_str_new( n->data.str->ptr + 1, n->data.str->len - 1 ) );
+ }
+ else if ( strcmp( type_id, "str" ) == 0 )
+ {
+ obj = rb_str_new( n->data.str->ptr, n->data.str->len );
+ }
+ else
+ {
+ transferred = 0;
+ obj = rb_str_new( n->data.str->ptr, n->data.str->len );
+ }
+ break;
+
+ case syck_seq_kind:
+ if ( type_id == NULL || strcmp( type_id, "seq" ) == 0 )
+ {
+ transferred = 1;
+ }
+ obj = rb_ary_new2( n->data.list->idx );
+ for ( i = 0; i < n->data.list->idx; i++ )
+ {
+ rb_ary_store( obj, i, syck_seq_read( n, i ) );
+ }
+ break;
+
+ case syck_map_kind:
+ if ( type_id == NULL || strcmp( type_id, "map" ) == 0 )
+ {
+ transferred = 1;
+ }
+ obj = rb_hash_new();
+ for ( i = 0; i < n->data.pairs->idx; i++ )
+ {
+ VALUE k = syck_map_read( n, map_key, i );
+ VALUE v = syck_map_read( n, map_value, i );
+ int skip_aset = 0;
+
+ /*
+ * Handle merge keys
+ */
+ if ( rb_obj_is_kind_of( k, cMergeKey ) )
+ {
+ if ( rb_obj_is_kind_of( v, rb_cHash ) )
+ {
+ VALUE dup = rb_funcall( v, s_dup, 0 );
+ rb_funcall( dup, s_update, 1, obj );
+ obj = dup;
+ skip_aset = 1;
+ }
+ else if ( rb_obj_is_kind_of( v, rb_cArray ) )
+ {
+ VALUE end = rb_ary_pop( v );
+ if ( rb_obj_is_kind_of( end, rb_cHash ) )
+ {
+ VALUE dup = rb_funcall( end, s_dup, 0 );
+ v = rb_ary_reverse( v );
+ rb_ary_push( v, obj );
+ rb_iterate( rb_each, v, syck_merge_i, dup );
+ obj = dup;
+ skip_aset = 1;
+ }
+ }
+ }
+ else if ( rb_obj_is_kind_of( k, cDefaultKey ) )
+ {
+ rb_funcall( obj, s_default_set, 1, v );
+ skip_aset = 1;
+ }
+
+ if ( ! skip_aset )
+ {
+ rb_hash_aset( obj, k, v );
+ }
+ }
+ break;
+ }
+
+ *ref = obj;
+ return transferred;
+}
+
+/*
+ * {native mode} node handler
+ * - Converts data into native Ruby types
+ */
+SYMID
+rb_syck_load_handler(p, n)
+ SyckParser *p;
+ SyckNode *n;
+{
+ VALUE obj = Qnil;
+ struct parser_xtra *bonus;
+
+ /*
+ * Attempt common transfers
+ */
+ int transferred = yaml_org_handler(n, &obj);
+ if ( transferred == 0 && n->type_id != NULL )
+ {
+ obj = rb_funcall( oDefaultLoader, s_transfer, 2, rb_str_new2( n->type_id ), obj );
+ }
+
+ /*
+ * ID already set, let's alter the symbol table to accept the new object
+ */
+ if (n->id > 0 && !NIL_P(obj))
+ {
+ MEMCPY((void *)n->id, (void *)obj, RVALUE, 1);
+ MEMZERO((void *)obj, RVALUE, 1);
+ obj = n->id;
+ }
+
+ bonus = (struct parser_xtra *)p->bonus;
+ if ( bonus->taint) OBJ_TAINT( obj );
+ if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
+
+ rb_hash_aset(bonus->data, INT2FIX(RHASH(bonus->data)->tbl->num_entries), obj);
+ return obj;
+}
+
+/*
+ * friendly errors.
+ */
+void
+rb_syck_err_handler(p, msg)
+ SyckParser *p;
+ char *msg;
+{
+ char *endl = p->cursor;
+
+ while ( *endl != '\0' && *endl != '\n' )
+ endl++;
+
+ endl[0] = '\0';
+ rb_raise(rb_eArgError, "%s on line %d, col %d: `%s'",
+ msg,
+ p->linect,
+ p->cursor - p->lineptr,
+ p->lineptr);
+}
+
+/*
+ * provide bad anchor object to the parser.
+ */
+SyckNode *
+rb_syck_bad_anchor_handler(p, a)
+ SyckParser *p;
+ char *a;
+{
+ VALUE anchor_name = rb_str_new2( a );
+ SyckNode *badanc = syck_new_map( rb_str_new2( "name" ), anchor_name );
+ badanc->type_id = syck_strndup( "tag:ruby.yaml.org,2002:object:YAML::Syck::BadAlias", 53 );
+ return badanc;
+}
+
+/*
+ * data loaded based on the model requested.
+ */
+void
+syck_set_model( parser, input, model )
+ SyckParser *parser;
+ VALUE input, model;
+{
+ if ( model == sym_generic )
+ {
+ syck_parser_handler( parser, rb_syck_parse_handler );
+ syck_parser_implicit_typing( parser, 1 );
+ syck_parser_taguri_expansion( parser, 1 );
+ }
+ else
+ {
+ syck_parser_handler( parser, rb_syck_load_handler );
+ syck_parser_implicit_typing( parser, 1 );
+ syck_parser_taguri_expansion( parser, 0 );
+ }
+ if ( input == sym_bytecode )
+ {
+ syck_parser_set_input_type( parser, syck_bytecode_utf8 );
+ }
+ syck_parser_error_handler( parser, rb_syck_err_handler );
+ syck_parser_bad_anchor_handler( parser, rb_syck_bad_anchor_handler );
+}
+
+/*
+ * mark parser nodes
+ */
+static void
+syck_mark_parser(parser)
+ SyckParser *parser;
+{
+ rb_gc_mark(parser->root);
+ rb_gc_mark(parser->root_on_error);
+}
+
+/*
+ * YAML::Syck::Parser.new
+ */
+VALUE
+syck_parser_new(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ VALUE pobj, options, init_argv[1];
+ SyckParser *parser = syck_new_parser();
+
+ rb_scan_args(argc, argv, "01", &options);
+ pobj = Data_Wrap_Struct( class, syck_mark_parser, syck_free_parser, parser );
+
+ syck_parser_set_root_on_error( parser, Qnil );
+
+ if ( ! rb_obj_is_instance_of( options, rb_cHash ) )
+ {
+ options = rb_hash_new();
+ }
+ init_argv[0] = options;
+ rb_obj_call_init(pobj, 1, init_argv);
+ return pobj;
+}
+
+/*
+ * YAML::Syck::Parser.initialize( options )
+ */
+static VALUE
+syck_parser_initialize( self, options )
+ VALUE self, options;
+{
+ rb_ivar_set(self, s_options, options);
+ return self;
+}
+
+/*
+ * YAML::Syck::Parser.bufsize = Integer
+ */
+static VALUE
+syck_parser_bufsize_set( self, size )
+ VALUE self, size;
+{
+ SyckParser *parser;
+
+ Data_Get_Struct(self, SyckParser, parser);
+ if ( rb_respond_to( size, s_to_i ) ) {
+ parser->bufsize = NUM2INT(rb_funcall(size, s_to_i, 0));
+ }
+ return self;
+}
+
+/*
+ * YAML::Syck::Parser.bufsize => Integer
+ */
+static VALUE
+syck_parser_bufsize_get( self )
+ VALUE self;
+{
+ SyckParser *parser;
+
+ Data_Get_Struct(self, SyckParser, parser);
+ return INT2FIX( parser->bufsize );
+}
+
+/*
+ * YAML::Syck::Parser.load( IO or String )
+ */
+VALUE
+syck_parser_load(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE port, proc, model, input;
+ SyckParser *parser;
+ struct parser_xtra bonus;
+ volatile VALUE hash; /* protect from GC */
+
+ rb_scan_args(argc, argv, "11", &port, &proc);
+ Data_Get_Struct(self, SyckParser, parser);
+
+ input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
+ model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
+ syck_set_model( parser, input, model );
+
+ bonus.taint = syck_parser_assign_io(parser, port);
+ bonus.data = hash = rb_hash_new();
+ if ( NIL_P( proc ) ) bonus.proc = 0;
+ else bonus.proc = proc;
+
+ parser->bonus = (void *)&bonus;
+
+ return syck_parse( parser );
+}
+
+/*
+ * YAML::Syck::Parser.load_documents( IO or String ) { |doc| }
+ */
+VALUE
+syck_parser_load_documents(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE port, proc, v, input, model;
+ SyckParser *parser;
+ struct parser_xtra bonus;
+ volatile VALUE hash;
+
+ rb_scan_args(argc, argv, "1&", &port, &proc);
+ Data_Get_Struct(self, SyckParser, parser);
+
+ input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
+ model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
+ syck_set_model( parser, input, model );
+
+ bonus.taint = syck_parser_assign_io(parser, port);
+ while ( 1 )
+ {
+ /* Reset hash for tracking nodes */
+ bonus.data = hash = rb_hash_new();
+ bonus.proc = 0;
+ parser->bonus = (void *)&bonus;
+
+ /* Parse a document */
+ v = syck_parse( parser );
+ if ( parser->eof == 1 )
+ {
+ break;
+ }
+
+ /* Pass document to block */
+ rb_funcall( proc, s_call, 1, v );
+ }
+
+ return Qnil;
+}
+
+/*
+ * YAML::Syck::Loader.initialize
+ */
+static VALUE
+syck_loader_initialize( self )
+ VALUE self;
+{
+ VALUE families;
+
+ families = rb_hash_new();
+ rb_ivar_set(self, s_families, families);
+ rb_ivar_set(self, s_private_types, rb_hash_new());
+ rb_ivar_set(self, s_anchors, rb_hash_new());
+
+ rb_hash_aset(families, rb_str_new2( YAML_DOMAIN ), rb_hash_new());
+ rb_hash_aset(families, rb_str_new2( RUBY_DOMAIN ), rb_hash_new());
+
+ return self;
+}
+
+/*
+ * Add type family, used by add_*_type methods.
+ */
+VALUE
+syck_loader_add_type_family( self, domain, type_re, proc )
+ VALUE self, domain, type_re, proc;
+{
+ VALUE families, domain_types;
+
+ families = rb_attr_get(self, s_families);
+ domain_types = syck_get_hash_aref(families, domain);
+ rb_hash_aset( domain_types, type_re, proc );
+ return Qnil;
+}
+
+/*
+ * YAML::Syck::Loader.add_domain_type
+ */
+VALUE
+syck_loader_add_domain_type( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE domain, type_re, proc;
+
+ rb_scan_args(argc, argv, "2&", &domain, &type_re, &proc);
+ syck_loader_add_type_family( self, domain, type_re, proc );
+ return Qnil;
+}
+
+
+/*
+ * YAML::Syck::Loader.add_builtin_type
+ */
+VALUE
+syck_loader_add_builtin_type( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE type_re, proc;
+
+ rb_scan_args(argc, argv, "1&", &type_re, &proc);
+ syck_loader_add_type_family( self, rb_str_new2( YAML_DOMAIN ), type_re, proc );
+ return Qnil;
+}
+
+/*
+ * YAML::Syck::Loader.add_ruby_type
+ */
+VALUE
+syck_loader_add_ruby_type( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE type_re, proc;
+
+ rb_scan_args(argc, argv, "1&", &type_re, &proc);
+ syck_loader_add_type_family( self, rb_str_new2( RUBY_DOMAIN ), type_re, proc );
+ return Qnil;
+}
+
+/*
+ * YAML::Syck::Loader.add_private_type
+ */
+VALUE
+syck_loader_add_private_type( argc, argv, self )
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE type_re, proc, priv_types;
+
+ rb_scan_args(argc, argv, "1&", &type_re, &proc);
+
+ priv_types = rb_attr_get(self, s_private_types);
+ rb_hash_aset( priv_types, type_re, proc );
+ return Qnil;
+}
+
+/*
+ * YAML::Syck::Loader#detect
+ */
+VALUE
+syck_loader_detect_implicit( self, val )
+ VALUE self, val;
+{
+ char *type_id;
+
+ if ( TYPE(val) == T_STRING )
+ {
+ type_id = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len );
+ return rb_str_new2( type_id );
+ }
+
+ return rb_str_new2( "" );
+}
+
+/*
+ * iterator to search a type hash for a match.
+ */
+static VALUE
+transfer_find_i(entry, col)
+ VALUE entry, col;
+{
+ VALUE key = rb_ary_entry( entry, 0 );
+ VALUE tid = rb_ary_entry( col, 0 );
+ if ( rb_respond_to( key, s_match ) )
+ {
+ VALUE match = rb_funcall( key, rb_intern("match"), 1, tid );
+ if ( ! NIL_P( match ) )
+ {
+ rb_ary_push( col, rb_ary_entry( entry, 1 ) );
+ rb_iter_break();
+ }
+ }
+ return Qnil;
+}
+
+/*
+ * YAML::Syck::Loader#transfer
+ */
+VALUE
+syck_loader_transfer( self, type, val )
+ VALUE self, type, val;
+{
+ char *taguri = NULL;
+
+ if (NIL_P(type) || !RSTRING(type)->ptr || RSTRING(type)->len == 0)
+ {
+ /*
+ * Empty transfer, detect type
+ */
+ if ( TYPE(val) == T_STRING )
+ {
+ StringValue(val);
+ taguri = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len );
+ taguri = syck_taguri( YAML_DOMAIN, taguri, strlen( taguri ) );
+ }
+ }
+ else
+ {
+ taguri = syck_type_id_to_uri( RSTRING(type)->ptr );
+ }
+
+ if ( taguri != NULL )
+ {
+ int transferred = 0;
+ VALUE scheme, name, type_hash, domain = Qnil, type_proc = Qnil;
+ VALUE type_uri = rb_str_new2( taguri );
+ VALUE str_taguri = rb_str_new2("tag");
+ VALUE str_xprivate = rb_str_new2("x-private");
+ VALUE str_yaml_domain = rb_str_new2(YAML_DOMAIN);
+ VALUE parts = rb_str_split( type_uri, ":" );
+
+ scheme = rb_ary_shift( parts );
+
+ if ( rb_str_cmp( scheme, str_xprivate ) == 0 )
+ {
+ name = rb_ary_join( parts, rb_str_new2( ":" ) );
+ type_hash = rb_attr_get(self, s_private_types);
+ }
+ else if ( rb_str_cmp( scheme, str_taguri ) == 0 )
+ {
+ domain = rb_ary_shift( parts );
+ name = rb_ary_join( parts, rb_str_new2( ":" ) );
+ type_hash = rb_attr_get(self, s_families);
+ type_hash = rb_hash_aref(type_hash, domain);
+
+ /*
+ * Route yaml.org types through the transfer
+ * method here in this extension
+ */
+ if ( rb_str_cmp( domain, str_yaml_domain ) == 0 )
+ {
+ SyckNode *n = rb_new_syck_node(val, name);
+ if ( n != NULL )
+ {
+ transferred = yaml_org_handler(n, &val);
+ S_FREE( n );
+ }
+ }
+
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "invalid typing scheme: %s given",
+ scheme);
+ }
+
+ if ( ! transferred )
+ {
+ if ( rb_obj_is_instance_of( type_hash, rb_cHash ) )
+ {
+ type_proc = rb_hash_aref( type_hash, name );
+ if ( NIL_P( type_proc ) )
+ {
+ VALUE col = rb_ary_new();
+ rb_ary_push( col, name );
+ rb_iterate(rb_each, type_hash, transfer_find_i, col );
+ name = rb_ary_shift( col );
+ type_proc = rb_ary_shift( col );
+ }
+ }
+
+ if ( rb_respond_to( type_proc, s_call ) )
+ {
+ val = rb_funcall(type_proc, s_call, 2, type_uri, val);
+ }
+ else if ( rb_str_cmp( scheme, str_xprivate ) == 0 )
+ {
+ val = rb_funcall(cPrivateType, s_new, 2, name, val);
+ }
+ else
+ {
+ val = rb_funcall(cDomainType, s_new, 3, domain, name, val);
+ }
+ transferred = 1;
+ }
+ }
+
+ return val;
+}
+
+/*
+ * YAML::Syck::BadAlias.initialize
+ */
+VALUE
+syck_badalias_initialize( self, val )
+ VALUE self, val;
+{
+ rb_ivar_set( self, s_name, val );
+ return self;
+}
+
+/*
+ * YAML::Syck::BadAlias.<=>
+ */
+VALUE
+syck_badalias_cmp( alias1, alias2 )
+ VALUE alias1, alias2;
+{
+ VALUE str1 = rb_ivar_get( alias1, s_name );
+ VALUE str2 = rb_ivar_get( alias2, s_name );
+ VALUE val = rb_funcall( str1, s_cmp, 1, str2 );
+ return val;
+}
+
+/*
+ * YAML::Syck::DomainType.initialize
+ */
+VALUE
+syck_domaintype_initialize( self, domain, type_id, val )
+ VALUE self, type_id, val;
+{
+ rb_ivar_set( self, s_domain, domain );
+ rb_ivar_set( self, s_type_id, type_id );
+ rb_ivar_set( self, s_value, val );
+ return self;
+}
+
+/*
+ * YAML::Syck::PrivateType.initialize
+ */
+VALUE
+syck_privatetype_initialize( self, type_id, val )
+ VALUE self, type_id, val;
+{
+ rb_ivar_set( self, s_type_id, type_id );
+ rb_ivar_set( self, s_value, val );
+ return self;
+}
+
+/*
+ * YAML::Syck::Node.initialize
+ */
+VALUE
+syck_node_initialize( self, type_id, val )
+ VALUE self, type_id, val;
+{
+ rb_ivar_set( self, s_type_id, type_id );
+ rb_ivar_set( self, s_value, val );
+ return self;
+}
+
+VALUE
+syck_node_thash( entry, t )
+ VALUE entry, t;
+{
+ VALUE key, val;
+ key = rb_ary_entry( entry, 0 );
+ val = syck_node_transform( rb_ary_entry( rb_ary_entry( entry, 1 ), 1 ) );
+ rb_hash_aset( t, key, val );
+ return Qnil;
+}
+
+VALUE
+syck_node_ahash( entry, t )
+ VALUE entry, t;
+{
+ VALUE val = syck_node_transform( entry );
+ rb_ary_push( t, val );
+ return Qnil;
+}
+
+/*
+ * YAML::Syck::Node.transform
+ */
+VALUE
+syck_node_transform( self )
+ VALUE self;
+{
+ VALUE t = Qnil;
+ VALUE type_id = rb_attr_get( self, s_type_id );
+ VALUE val = rb_attr_get( self, s_value );
+ if ( rb_obj_is_instance_of( val, rb_cHash ) )
+ {
+ t = rb_hash_new();
+ rb_iterate( rb_each, val, syck_node_thash, t );
+ }
+ else if ( rb_obj_is_instance_of( val, rb_cArray ) )
+ {
+ t = rb_ary_new();
+ rb_iterate( rb_each, val, syck_node_ahash, t );
+ }
+ else
+ {
+ t = val;
+ }
+ return rb_funcall( oDefaultLoader, s_transfer, 2, type_id, t );
+}
+
+/*
+ * Handle output from the emitter
+ */
+void
+rb_syck_output_handler( emitter, str, len )
+ SyckEmitter *emitter;
+ char *str;
+ long len;
+{
+ VALUE dest = (VALUE)emitter->bonus;
+ if ( rb_respond_to( dest, s_to_str ) ) {
+ rb_str_cat( dest, str, len );
+ } else {
+ rb_io_write( dest, rb_str_new( str, len ) );
+ }
+}
+
+/*
+ * Mark emitter values.
+ */
+static void
+syck_mark_emitter(emitter)
+ SyckEmitter *emitter;
+{
+ rb_gc_mark(emitter->ignore_id);
+ if ( emitter->bonus != NULL )
+ {
+ rb_gc_mark( (VALUE)emitter->bonus );
+ }
+}
+
+/*
+ * YAML::Syck::Emitter.new
+ */
+VALUE
+syck_emitter_new(argc, argv, class)
+ int argc;
+ VALUE *argv;
+ VALUE class;
+{
+ VALUE pobj, options, init_argv[1];
+ SyckEmitter *emitter = syck_new_emitter();
+ rb_scan_args(argc, argv, "01", &options);
+
+ pobj = Data_Wrap_Struct( class, syck_mark_emitter, syck_free_emitter, emitter );
+ syck_emitter_ignore_id( emitter, Qnil );
+ syck_emitter_handler( emitter, rb_syck_output_handler );
+ emitter->bonus = (void *)rb_str_new2( "" );
+
+ if ( ! rb_obj_is_instance_of( options, rb_cHash ) )
+ {
+ options = rb_hash_new();
+ }
+ init_argv[0] = options;
+ rb_obj_call_init(pobj, 1, init_argv);
+ return pobj;
+}
+
+/*
+ * YAML::Syck::Emitter.initialize( options )
+ */
+static VALUE
+syck_emitter_initialize( self, options )
+ VALUE self, options;
+{
+ rb_ivar_set(self, s_options, options);
+ return self;
+}
+
+/*
+ * YAML::Syck::Emitter.level
+ */
+VALUE
+syck_emitter_level_m( self )
+ VALUE self;
+{
+ SyckEmitter *emitter;
+
+ Data_Get_Struct(self, SyckEmitter, emitter);
+ return LONG2NUM( emitter->level );
+}
+
+/*
+ * YAML::Syck::Emitter.flush
+ */
+VALUE
+syck_emitter_flush_m( self )
+ VALUE self;
+{
+ SyckEmitter *emitter;
+
+ Data_Get_Struct(self, SyckEmitter, emitter);
+ syck_emitter_flush( emitter, 0 );
+ return self;
+}
+
+/*
+ * YAML::Syck::Emitter.write( str )
+ */
+VALUE
+syck_emitter_write_m( self, str )
+ VALUE self, str;
+{
+ SyckEmitter *emitter;
+
+ Data_Get_Struct(self, SyckEmitter, emitter);
+ StringValue(str);
+ syck_emitter_write( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
+ return self;
+}
+
+/*
+ * YAML::Syck::Emitter.simple( str )
+ */
+VALUE
+syck_emitter_simple_write( self, str )
+ VALUE self, str;
+{
+ SyckEmitter *emitter;
+
+ Data_Get_Struct(self, SyckEmitter, emitter);
+ StringValue(str);
+ syck_emitter_simple( emitter, RSTRING(str)->ptr, RSTRING(str)->len );
+ return self;
+}
+
+/*
+ * YAML::Syck::Emitter.start_object( object_id )
+ */
+VALUE
+syck_emitter_start_object( self, oid )
+ VALUE self, oid;
+{
+ char *anchor_name;
+ SyckEmitter *emitter;
+
+ Data_Get_Struct(self, SyckEmitter, emitter);
+ anchor_name = syck_emitter_start_obj( emitter, oid );
+
+ if ( anchor_name == NULL )
+ {
+ return Qnil;
+ }
+
+ return rb_str_new2( anchor_name );
+}
+
+/*
+ * YAML::Syck::Emitter.end_object
+ */
+VALUE
+syck_emitter_end_object( self )
+ VALUE self;
+{
+ SyckEmitter *emitter;
+
+ Data_Get_Struct(self, SyckEmitter, emitter);
+ syck_emitter_end_obj( emitter );
+
+ if ( emitter->level < 0 )
+ {
+ syck_emitter_flush( emitter, 0 );
+ }
+ return (VALUE)emitter->bonus;
+}
+
+/*
+ * Initialize Syck extension
+ */
+void
+Init_syck()
+{
+ VALUE rb_yaml = rb_define_module( "YAML" );
+ VALUE rb_syck = rb_define_module_under( rb_yaml, "Syck" );
+ rb_define_const( rb_syck, "VERSION", rb_str_new2( SYCK_VERSION ) );
+ rb_define_module_function( rb_syck, "compile", rb_syck_compile, 1 );
+
+ /*
+ * Global symbols
+ */
+ s_new = rb_intern("new");
+ s_utc = rb_intern("utc");
+ s_at = rb_intern("at");
+ s_to_f = rb_intern("to_f");
+ s_to_i = rb_intern("to_i");
+ s_read = rb_intern("read");
+ s_anchors = rb_intern("anchors");
+ s_binmode = rb_intern("binmode");
+ s_transfer = rb_intern("transfer");
+ s_call = rb_intern("call");
+ s_cmp = rb_intern("<=>");
+ s_update = rb_intern("update");
+ s_dup = rb_intern("dup");
+ s_default_set = rb_intern("default=");
+ s_match = rb_intern("match");
+ s_keys = rb_intern("keys");
+ s_to_str = rb_intern("to_str");
+ s_tr_bang = rb_intern("tr!");
+ s_unpack = rb_intern("unpack");
+
+ s_anchors = rb_intern("@anchors");
+ s_domain = rb_intern("@domain");
+ s_families = rb_intern("@families");
+ s_kind = rb_intern("@kind");
+ s_name = rb_intern("@name");
+ s_options = rb_intern("@options");
+ s_private_types = rb_intern("@private_types");
+ s_type_id = rb_intern("@type_id");
+ s_value = rb_intern("@value");
+
+ sym_model = ID2SYM(rb_intern("Model"));
+ sym_generic = ID2SYM(rb_intern("Generic"));
+ sym_input = ID2SYM(rb_intern("Input"));
+ sym_bytecode = ID2SYM(rb_intern("Bytecode"));
+ sym_map = ID2SYM(rb_intern("map"));
+ sym_scalar = ID2SYM(rb_intern("scalar"));
+ sym_seq = ID2SYM(rb_intern("seq"));
+
+ /*
+ * Define YAML::Syck::Loader class
+ */
+ cLoader = rb_define_class_under( rb_syck, "Loader", rb_cObject );
+ rb_define_attr( cLoader, "families", 1, 1 );
+ rb_define_attr( cLoader, "private_types", 1, 1 );
+ rb_define_attr( cLoader, "anchors", 1, 1 );
+ rb_define_method( cLoader, "initialize", syck_loader_initialize, 0 );
+ rb_define_method( cLoader, "add_domain_type", syck_loader_add_domain_type, -1 );
+ rb_define_method( cLoader, "add_builtin_type", syck_loader_add_builtin_type, -1 );
+ rb_define_method( cLoader, "add_ruby_type", syck_loader_add_ruby_type, -1 );
+ rb_define_method( cLoader, "add_private_type", syck_loader_add_private_type, -1 );
+ rb_define_method( cLoader, "bufsize=", syck_parser_bufsize_set, 1 );
+ rb_define_method( cLoader, "bufsize", syck_parser_bufsize_get, 0 );
+ rb_define_method( cLoader, "detect_implicit", syck_loader_detect_implicit, 1 );
+ rb_define_method( cLoader, "transfer", syck_loader_transfer, 2 );
+
+ oDefaultLoader = rb_funcall( cLoader, rb_intern( "new" ), 0 );
+ rb_define_const( rb_syck, "DefaultLoader", oDefaultLoader );
+
+ /*
+ * Define YAML::Syck::Parser class
+ */
+ cParser = rb_define_class_under( rb_syck, "Parser", rb_cObject );
+ rb_define_attr( cParser, "options", 1, 1 );
+ rb_define_singleton_method( cParser, "new", syck_parser_new, -1 );
+ rb_define_method(cParser, "initialize", syck_parser_initialize, 1);
+ rb_define_method(cParser, "load", syck_parser_load, -1);
+ rb_define_method(cParser, "load_documents", syck_parser_load_documents, -1);
+
+ /*
+ * Define YAML::Syck::Node class
+ */
+ cNode = rb_define_class_under( rb_syck, "Node", rb_cObject );
+ rb_define_attr( cNode, "kind", 1, 1 );
+ rb_define_attr( cNode, "type_id", 1, 1 );
+ rb_define_attr( cNode, "value", 1, 1 );
+ rb_define_attr( cNode, "anchor", 1, 1 );
+ rb_define_method( cNode, "initialize", syck_node_initialize, 2);
+ rb_define_method( cNode, "transform", syck_node_transform, 0);
+
+ /*
+ * Define YAML::Syck::PrivateType class
+ */
+ cPrivateType = rb_define_class_under( rb_syck, "PrivateType", rb_cObject );
+ rb_define_attr( cPrivateType, "type_id", 1, 1 );
+ rb_define_attr( cPrivateType, "value", 1, 1 );
+ rb_define_method( cPrivateType, "initialize", syck_privatetype_initialize, 2);
+
+ /*
+ * Define YAML::Syck::DomainType class
+ */
+ cDomainType = rb_define_class_under( rb_syck, "DomainType", rb_cObject );
+ rb_define_attr( cDomainType, "domain", 1, 1 );
+ rb_define_attr( cDomainType, "type_id", 1, 1 );
+ rb_define_attr( cDomainType, "value", 1, 1 );
+ rb_define_method( cDomainType, "initialize", syck_domaintype_initialize, 3);
+
+ /*
+ * Define YAML::Syck::BadAlias class
+ */
+ cBadAlias = rb_define_class_under( rb_syck, "BadAlias", rb_cObject );
+ rb_define_attr( cBadAlias, "name", 1, 1 );
+ rb_define_method( cBadAlias, "initialize", syck_badalias_initialize, 1);
+ rb_define_method( cBadAlias, "<=>", syck_badalias_cmp, 1);
+ rb_include_module( cBadAlias, rb_const_get( rb_cObject, rb_intern("Comparable") ) );
+
+ /*
+ * Define YAML::Syck::MergeKey class
+ */
+ cMergeKey = rb_define_class_under( rb_syck, "MergeKey", rb_cObject );
+
+ /*
+ * Define YAML::Syck::DefaultKey class
+ */
+ cDefaultKey = rb_define_class_under( rb_syck, "DefaultKey", rb_cObject );
+
+ /*
+ * Define YAML::Syck::Emitter class
+ */
+ cEmitter = rb_define_class_under( rb_syck, "Emitter", rb_cObject );
+ rb_define_singleton_method( cEmitter, "new", syck_emitter_new, -1 );
+ rb_define_method( cEmitter, "initialize", syck_emitter_initialize, 1 );
+ rb_define_method( cEmitter, "level", syck_emitter_level_m, 0 );
+ rb_define_method( cEmitter, "write", syck_emitter_write_m, 1 );
+ rb_define_method( cEmitter, "<<", syck_emitter_write_m, 1 );
+ rb_define_method( cEmitter, "simple", syck_emitter_simple_write, 1 );
+ rb_define_method( cEmitter, "flush", syck_emitter_flush_m, 0 );
+ rb_define_method( cEmitter, "start_object", syck_emitter_start_object, 1 );
+ rb_define_method( cEmitter, "end_object", syck_emitter_end_object, 0 );
+}
+
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
new file mode 100644
index 0000000000..5a15ab4947
--- /dev/null
+++ b/ext/syck/syck.c
@@ -0,0 +1,506 @@
+/*
+ * syck.c
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+#include "ruby.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "syck.h"
+
+void syck_parser_pop_level( SyckParser * );
+
+/*
+ * Custom assert
+ */
+void
+syck_assert( char *file_name, unsigned line_num )
+{
+ fflush( NULL );
+ fprintf( stderr, "\nAssertion failed: %s, line %u\n",
+ file_name, line_num );
+ fflush( stderr );
+ abort();
+}
+
+/*
+ * Allocates and copies a string
+ */
+char *
+syck_strndup( char *buf, long len )
+{
+ char *new = S_ALLOC_N( char, len + 1 );
+ S_MEMZERO( new, char, len + 1 );
+ S_MEMCPY( new, buf, char, len );
+ return new;
+}
+
+/*
+ * Default FILE IO function
+ */
+long
+syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip )
+{
+ long len = 0;
+
+ ASSERT( file != NULL );
+
+ max_size -= skip;
+ len = fread( buf + skip, sizeof( char ), max_size, file->ptr );
+ len += skip;
+ buf[len] = '\0';
+
+ return len;
+}
+
+/*
+ * Default string IO function
+ */
+long
+syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
+{
+ char *beg;
+ long len = 0;
+
+ ASSERT( str != NULL );
+ beg = str->ptr;
+ if ( max_size >= 0 )
+ {
+ max_size -= skip;
+ if ( max_size <= 0 ) max_size = 0;
+ else str->ptr += max_size;
+
+ if ( str->ptr > str->end )
+ {
+ str->ptr = str->end;
+ }
+ }
+ else
+ {
+ /* Use exact string length */
+ while ( str->ptr < str->end ) {
+ if (*(str->ptr++) == '\n') break;
+ }
+ }
+ if ( beg < str->ptr )
+ {
+ len = ( str->ptr - beg );
+ S_MEMCPY( buf + skip, beg, char, len );
+ }
+ len += skip;
+ buf[len] = '\0';
+
+ return len;
+}
+
+void
+syck_parser_reset_levels( SyckParser *p )
+{
+ while ( p->lvl_idx > 1 )
+ {
+ syck_parser_pop_level( p );
+ }
+
+ if ( p->lvl_idx < 1 )
+ {
+ p->lvl_idx = 1;
+ p->levels[0].spaces = -1;
+ p->levels[0].ncount = 0;
+ p->levels[0].domain = syck_strndup( "", 0 );
+ }
+ p->levels[0].status = syck_lvl_header;
+}
+
+void
+syck_parser_reset_cursor( SyckParser *p )
+{
+ if ( p->buffer == NULL )
+ {
+ p->buffer = S_ALLOC_N( char, p->bufsize );
+ S_MEMZERO( p->buffer, char, p->bufsize );
+ }
+ p->buffer[0] = '\0';
+
+ p->cursor = NULL;
+ p->lineptr = NULL;
+ p->linectptr = NULL;
+ p->token = NULL;
+ p->toktmp = NULL;
+ p->marker = NULL;
+ p->limit = NULL;
+
+ p->root = 0;
+ p->root_on_error = 0;
+ p->linect = 0;
+ p->eof = 0;
+ p->last_token = 0;
+ p->force_token = 0;
+}
+
+/*
+ * Value to return on a parse error
+ */
+void
+syck_parser_set_root_on_error( SyckParser *p, SYMID roer )
+{
+ p->root_on_error = roer;
+}
+
+/*
+ * Allocate the parser
+ */
+SyckParser *
+syck_new_parser()
+{
+ SyckParser *p;
+ p = S_ALLOC( SyckParser );
+ S_MEMZERO( p, SyckParser, 1 );
+ p->lvl_capa = ALLOC_CT;
+ p->levels = S_ALLOC_N( SyckLevel, p->lvl_capa );
+ p->input_type = syck_yaml_utf8;
+ p->io_type = syck_io_str;
+ p->io.str = NULL;
+ p->syms = NULL;
+ p->anchors = NULL;
+ p->bad_anchors = NULL;
+ p->implicit_typing = 1;
+ p->taguri_expansion = 0;
+ p->bufsize = SYCK_BUFFERSIZE;
+ p->buffer = NULL;
+ p->lvl_idx = 0;
+ syck_parser_reset_levels( p );
+ return p;
+}
+
+int
+syck_add_sym( SyckParser *p, char *data )
+{
+ SYMID id = 0;
+ if ( p->syms == NULL )
+ {
+ p->syms = st_init_numtable();
+ }
+ id = p->syms->num_entries + 1;
+ st_insert( p->syms, id, (st_data_t)data );
+ return id;
+}
+
+int
+syck_lookup_sym( SyckParser *p, SYMID id, char **data )
+{
+ if ( p->syms == NULL ) return 0;
+ return st_lookup( p->syms, id, (st_data_t *)data );
+}
+
+int
+syck_st_free_nodes( char *key, SyckNode *n, char *arg )
+{
+ if ( n != (void *)1 ) syck_free_node( n );
+ n = NULL;
+ return ST_CONTINUE;
+}
+
+void
+syck_st_free( SyckParser *p )
+{
+ /*
+ * Free the adhoc symbol table
+ */
+ if ( p->syms != NULL )
+ {
+ st_free_table( p->syms );
+ p->syms = NULL;
+ }
+
+ /*
+ * Free the anchor tables
+ */
+ if ( p->anchors != NULL )
+ {
+ st_foreach( p->anchors, syck_st_free_nodes, 0 );
+ st_free_table( p->anchors );
+ p->anchors = NULL;
+ }
+
+ if ( p->bad_anchors != NULL )
+ {
+ st_foreach( p->bad_anchors, syck_st_free_nodes, 0 );
+ st_free_table( p->bad_anchors );
+ p->bad_anchors = NULL;
+ }
+}
+
+void
+syck_free_parser( SyckParser *p )
+{
+ /*
+ * Free tables, levels
+ */
+ syck_st_free( p );
+ syck_parser_reset_levels( p );
+ S_FREE( p->levels[0].domain );
+ S_FREE( p->levels );
+
+ if ( p->buffer != NULL )
+ {
+ S_FREE( p->buffer );
+ }
+ free_any_io( p );
+ S_FREE( p );
+}
+
+void
+syck_parser_handler( SyckParser *p, SyckNodeHandler hdlr )
+{
+ ASSERT( p != NULL );
+ p->handler = hdlr;
+}
+
+void
+syck_parser_implicit_typing( SyckParser *p, int flag )
+{
+ p->implicit_typing = ( flag == 0 ? 0 : 1 );
+}
+
+void
+syck_parser_taguri_expansion( SyckParser *p, int flag )
+{
+ p->taguri_expansion = ( flag == 0 ? 0 : 1 );
+}
+
+void
+syck_parser_error_handler( SyckParser *p, SyckErrorHandler hdlr )
+{
+ ASSERT( p != NULL );
+ p->error_handler = hdlr;
+}
+
+void
+syck_parser_bad_anchor_handler( SyckParser *p, SyckBadAnchorHandler hdlr )
+{
+ ASSERT( p != NULL );
+ p->bad_anchor_handler = hdlr;
+}
+
+void
+syck_parser_set_input_type( SyckParser *p, enum syck_parser_input input_type )
+{
+ ASSERT( p != NULL );
+ p->input_type = input_type;
+}
+
+void
+syck_parser_file( SyckParser *p, FILE *fp, SyckIoFileRead read )
+{
+ ASSERT( p != NULL );
+ free_any_io( p );
+ syck_parser_reset_cursor( p );
+ p->io_type = syck_io_file;
+ p->io.file = S_ALLOC( SyckIoFile );
+ p->io.file->ptr = fp;
+ if ( read != NULL )
+ {
+ p->io.file->read = read;
+ }
+ else
+ {
+ p->io.file->read = syck_io_file_read;
+ }
+}
+
+void
+syck_parser_str( SyckParser *p, char *ptr, long len, SyckIoStrRead read )
+{
+ ASSERT( p != NULL );
+ free_any_io( p );
+ syck_parser_reset_cursor( p );
+ p->io_type = syck_io_str;
+ p->io.str = S_ALLOC( SyckIoStr );
+ p->io.str->beg = ptr;
+ p->io.str->ptr = ptr;
+ p->io.str->end = ptr + len;
+ if ( read != NULL )
+ {
+ p->io.str->read = read;
+ }
+ else
+ {
+ p->io.str->read = syck_io_str_read;
+ }
+}
+
+void
+syck_parser_str_auto( SyckParser *p, char *ptr, SyckIoStrRead read )
+{
+ syck_parser_str( p, ptr, strlen( ptr ), read );
+}
+
+SyckLevel *
+syck_parser_current_level( SyckParser *p )
+{
+ return &p->levels[p->lvl_idx-1];
+}
+
+void
+syck_parser_pop_level( SyckParser *p )
+{
+ ASSERT( p != NULL );
+
+ /* The root level should never be popped */
+ if ( p->lvl_idx <= 1 ) return;
+
+ p->lvl_idx -= 1;
+ free( p->levels[p->lvl_idx].domain );
+}
+
+void
+syck_parser_add_level( SyckParser *p, int len, enum syck_level_status status )
+{
+ ASSERT( p != NULL );
+ if ( p->lvl_idx + 1 > p->lvl_capa )
+ {
+ p->lvl_capa += ALLOC_CT;
+ S_REALLOC_N( p->levels, SyckLevel, p->lvl_capa );
+ }
+
+ ASSERT( len > p->levels[p->lvl_idx-1].spaces );
+ p->levels[p->lvl_idx].spaces = len;
+ p->levels[p->lvl_idx].ncount = 0;
+ p->levels[p->lvl_idx].domain = syck_strndup( p->levels[p->lvl_idx-1].domain, strlen( p->levels[p->lvl_idx-1].domain ) );
+ p->levels[p->lvl_idx].status = status;
+ p->lvl_idx += 1;
+}
+
+void
+free_any_io( SyckParser *p )
+{
+ ASSERT( p != NULL );
+ switch ( p->io_type )
+ {
+ case syck_io_str:
+ if ( p->io.str != NULL )
+ {
+ S_FREE( p->io.str );
+ p->io.str = NULL;
+ }
+ break;
+
+ case syck_io_file:
+ if ( p->io.file != NULL )
+ {
+ S_FREE( p->io.file );
+ p->io.file = NULL;
+ }
+ break;
+ }
+}
+
+long
+syck_move_tokens( SyckParser *p )
+{
+ long count, skip;
+ ASSERT( p->buffer != NULL );
+
+ if ( p->token == NULL )
+ return 0;
+
+ skip = p->limit - p->token;
+ if ( skip < 1 )
+ return 0;
+
+ if ( ( count = p->token - p->buffer ) )
+ {
+ S_MEMMOVE( p->buffer, p->token, char, skip );
+ p->token = p->buffer;
+ p->marker -= count;
+ p->cursor -= count;
+ p->toktmp -= count;
+ p->limit -= count;
+ p->lineptr -= count;
+ p->linectptr -= count;
+ }
+ return skip;
+}
+
+void
+syck_check_limit( SyckParser *p, long len )
+{
+ if ( p->cursor == NULL )
+ {
+ p->cursor = p->buffer;
+ p->lineptr = p->buffer;
+ p->linectptr = p->buffer;
+ p->marker = p->buffer;
+ }
+ p->limit = p->buffer + len;
+}
+
+long
+syck_parser_read( SyckParser *p )
+{
+ long len = 0;
+ long skip = 0;
+ ASSERT( p != NULL );
+ switch ( p->io_type )
+ {
+ case syck_io_str:
+ skip = syck_move_tokens( p );
+ len = (p->io.str->read)( p->buffer, p->io.str, SYCK_BUFFERSIZE - 1, skip );
+ break;
+
+ case syck_io_file:
+ skip = syck_move_tokens( p );
+ len = (p->io.file->read)( p->buffer, p->io.file, SYCK_BUFFERSIZE - 1, skip );
+ break;
+ }
+ syck_check_limit( p, len );
+ return len;
+}
+
+long
+syck_parser_readlen( SyckParser *p, long max_size )
+{
+ long len = 0;
+ long skip = 0;
+ ASSERT( p != NULL );
+ switch ( p->io_type )
+ {
+ case syck_io_str:
+ skip = syck_move_tokens( p );
+ len = (p->io.str->read)( p->buffer, p->io.str, max_size, skip );
+ break;
+
+ case syck_io_file:
+ skip = syck_move_tokens( p );
+ len = (p->io.file->read)( p->buffer, p->io.file, max_size, skip );
+ break;
+ }
+ syck_check_limit( p, len );
+ return len;
+}
+
+SYMID
+syck_parse( SyckParser *p )
+{
+ ASSERT( p != NULL );
+
+ syck_st_free( p );
+ syck_parser_reset_levels( p );
+ syckparse( p );
+ return p->root;
+}
+
+void
+syck_default_error_handler( SyckParser *p, char *msg )
+{
+ printf( "Error at [Line %d, Col %d]: %s\n",
+ p->linect,
+ p->cursor - p->lineptr,
+ msg );
+}
+
diff --git a/ext/syck/syck.h b/ext/syck/syck.h
new file mode 100644
index 0000000000..02dbce9835
--- /dev/null
+++ b/ext/syck/syck.h
@@ -0,0 +1,409 @@
+/*
+ * syck.h
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+
+#ifndef SYCK_H
+#define SYCK_H
+
+#define SYCK_YAML_MAJOR 1
+#define SYCK_YAML_MINOR 0
+
+#define SYCK_VERSION "0.45"
+#define YAML_DOMAIN "yaml.org,2002"
+
+#include <stdio.h>
+#include <ctype.h>
+#include "st.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/*
+ * Memory Allocation
+ */
+#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
+#include <alloca.h>
+#endif
+
+#if DEBUG
+ void syck_assert( char *, unsigned );
+# define ASSERT(f) \
+ if ( f ) \
+ {} \
+ else \
+ syck_assert( __FILE__, __LINE__ )
+#else
+# define ASSERT(f)
+#endif
+
+#ifndef NULL
+# define NULL (void *)0
+#endif
+
+#define ALLOC_CT 8
+#define SYCK_BUFFERSIZE 4096
+#define S_ALLOC_N(type,n) (type*)malloc(sizeof(type)*(n))
+#define S_ALLOC(type) (type*)malloc(sizeof(type))
+#define S_REALLOC_N(var,type,n) (var)=(type*)realloc((char*)(var),sizeof(type)*(n))
+#define S_FREE(n) free(n); n = NULL;
+
+#define S_ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
+
+#define S_MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
+#define S_MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
+#define S_MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
+#define S_MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
+
+#define BLOCK_FOLD 10
+#define BLOCK_LIT 20
+#define BLOCK_PLAIN 30
+#define NL_CHOMP 130
+#define NL_KEEP 140
+
+/*
+ * Node definitions
+ */
+#define SYMID unsigned long
+
+typedef struct _syck_node SyckNode;
+
+enum syck_kind_tag {
+ syck_map_kind,
+ syck_seq_kind,
+ syck_str_kind
+};
+
+enum map_part {
+ map_key,
+ map_value
+};
+
+enum scalar_style {
+ scalar_none,
+ scalar_plain,
+ scalar_1quote,
+ scalar_2quote,
+ scalar_block
+};
+
+/*
+ * Node metadata struct
+ */
+struct _syck_node {
+ /* Symbol table ID */
+ SYMID id;
+ /* Underlying kind */
+ enum syck_kind_tag kind;
+ /* Fully qualified tag-uri for type */
+ char *type_id;
+ /* Anchor name */
+ char *anchor;
+ union {
+ /* Storage for map data */
+ struct SyckMap {
+ SYMID *keys;
+ SYMID *values;
+ long capa;
+ long idx;
+ } *pairs;
+ /* Storage for sequence data */
+ struct SyckSeq {
+ SYMID *items;
+ long capa;
+ long idx;
+ } *list;
+ /* Storage for string data */
+ struct SyckStr {
+ enum scalar_style style;
+ char *ptr;
+ long len;
+ } *str;
+ } data;
+ /* Shortcut node */
+ void *shortcut;
+};
+
+/*
+ * Parser definitions
+ */
+typedef struct _syck_parser SyckParser;
+typedef struct _syck_file SyckIoFile;
+typedef struct _syck_str SyckIoStr;
+typedef struct _syck_level SyckLevel;
+
+typedef SYMID (*SyckNodeHandler)(SyckParser *, SyckNode *);
+typedef void (*SyckErrorHandler)(SyckParser *, char *);
+typedef SyckNode * (*SyckBadAnchorHandler)(SyckParser *, char *);
+typedef long (*SyckIoFileRead)(char *, SyckIoFile *, long, long);
+typedef long (*SyckIoStrRead)(char *, SyckIoStr *, long, long);
+
+enum syck_io_type {
+ syck_io_str,
+ syck_io_file
+};
+
+enum syck_parser_input {
+ syck_yaml_utf8,
+ syck_yaml_utf16,
+ syck_yaml_utf32,
+ syck_bytecode_utf8
+};
+
+enum syck_level_status {
+ syck_lvl_header,
+ syck_lvl_doc,
+ syck_lvl_open,
+ syck_lvl_seq,
+ syck_lvl_map,
+ syck_lvl_block,
+ syck_lvl_str,
+ syck_lvl_inline,
+ syck_lvl_end,
+ syck_lvl_pause
+};
+
+/*
+ * Parser structs
+ */
+struct _syck_file {
+ /* File pointer */
+ FILE *ptr;
+ /* Function which FILE -> buffer */
+ SyckIoFileRead read;
+};
+
+struct _syck_str {
+ /* String buffer pointers */
+ char *beg, *ptr, *end;
+ /* Function which string -> buffer */
+ SyckIoStrRead read;
+};
+
+struct _syck_level {
+ int spaces;
+ int ncount;
+ char *domain;
+ enum syck_level_status status;
+};
+
+struct _syck_parser {
+ /* Root node */
+ SYMID root, root_on_error;
+ /* Implicit typing flag */
+ int implicit_typing, taguri_expansion;
+ /* Scripting language function to handle nodes */
+ SyckNodeHandler handler;
+ /* Error handler */
+ SyckErrorHandler error_handler;
+ /* InvalidAnchor handler */
+ SyckBadAnchorHandler bad_anchor_handler;
+ /* Parser input type */
+ enum syck_parser_input input_type;
+ /* IO type */
+ enum syck_io_type io_type;
+ /* Custom buffer size */
+ size_t bufsize;
+ /* Buffer pointers */
+ char *buffer, *linectptr, *lineptr, *toktmp, *token, *cursor, *marker, *limit;
+ /* Line counter */
+ int linect;
+ /* Last token from yylex() */
+ int last_token;
+ /* Force a token upon next call to yylex() */
+ int force_token;
+ /* EOF flag */
+ int eof;
+ union {
+ SyckIoFile *file;
+ SyckIoStr *str;
+ } io;
+ /* Symbol table for anchors */
+ st_table *anchors, *bad_anchors;
+ /* Optional symbol table for SYMIDs */
+ st_table *syms;
+ /* Levels of indentation */
+ SyckLevel *levels;
+ int lvl_idx;
+ int lvl_capa;
+ void *bonus;
+};
+
+/*
+ * Emitter definitions
+ */
+typedef struct _syck_emitter SyckEmitter;
+typedef struct _syck_emitter_node SyckEmitterNode;
+
+typedef void (*SyckOutputHandler)(SyckEmitter *, char *, long);
+
+enum doc_stage {
+ doc_open,
+ doc_need_header,
+ doc_processing
+};
+
+enum block_styles {
+ block_arbitrary,
+ block_fold,
+ block_literal
+};
+
+/*
+ * Emitter struct
+ */
+struct _syck_emitter {
+ /* Headerless doc flag */
+ int headless;
+ /* Sequence map shortcut flag */
+ int seq_map;
+ /* Force header? */
+ int use_header;
+ /* Force version? */
+ int use_version;
+ /* Sort hash keys */
+ int sort_keys;
+ /* Anchor format */
+ char *anchor_format;
+ /* Explicit typing on all collections? */
+ int explicit_typing;
+ /* Best width on folded scalars */
+ int best_width;
+ /* Use literal[1] or folded[2] blocks on all text? */
+ enum block_styles block_style;
+ /* Stage of written document */
+ enum doc_stage stage;
+ /* Level counter */
+ int level;
+ /* Default indentation */
+ int indent;
+ /* Object ignore ID */
+ SYMID ignore_id;
+ /* Symbol table for anchors */
+ st_table *markers, *anchors;
+ /* Custom buffer size */
+ size_t bufsize;
+ /* Buffer */
+ char *buffer, *marker;
+ /* Absolute position of the buffer */
+ long bufpos;
+ /* Handler for output */
+ SyckOutputHandler handler;
+ /* Pointer for extension's use */
+ void *bonus;
+};
+
+/*
+ * Emitter node metadata struct
+ */
+struct _syck_emitter_node {
+ /* Node buffer position */
+ long pos;
+ /* Current indent */
+ long indent;
+ /* Collection? */
+ int is_shortcut;
+};
+
+/*
+ * Handler prototypes
+ */
+SYMID syck_hdlr_add_node( SyckParser *, SyckNode * );
+SyckNode *syck_hdlr_add_anchor( SyckParser *, char *, SyckNode * );
+void syck_hdlr_remove_anchor( SyckParser *, char * );
+SyckNode *syck_hdlr_get_anchor( SyckParser *, char * );
+void syck_add_transfer( char *, SyckNode *, int );
+char *syck_xprivate( char *, int );
+char *syck_taguri( char *, char *, int );
+int syck_add_sym( SyckParser *, char * );
+int syck_lookup_sym( SyckParser *, SYMID, char ** );
+int syck_try_implicit( SyckNode * );
+char *syck_type_id_to_uri( char * );
+void try_tag_implicit( SyckNode *, int );
+char *syck_match_implicit( char *, size_t );
+
+/*
+ * API prototypes
+ */
+char *syck_strndup( char *, long );
+long syck_io_file_read( char *, SyckIoFile *, long, long );
+long syck_io_str_read( char *, SyckIoStr *, long, long );
+char *syck_base64enc( char *, long );
+char *syck_base64dec( char *, long );
+SyckEmitter *syck_new_emitter();
+void syck_emitter_ignore_id( SyckEmitter *, SYMID );
+void syck_emitter_handler( SyckEmitter *, SyckOutputHandler );
+void syck_free_emitter( SyckEmitter * );
+void syck_emitter_clear( SyckEmitter * );
+void syck_emitter_simple( SyckEmitter *, char *, long );
+void syck_emitter_write( SyckEmitter *, char *, long );
+void syck_emitter_flush( SyckEmitter *, long );
+char *syck_emitter_start_obj( SyckEmitter *, SYMID );
+void syck_emitter_end_obj( SyckEmitter * );
+SyckParser *syck_new_parser();
+void syck_free_parser( SyckParser * );
+void syck_parser_set_root_on_error( SyckParser *, SYMID );
+void syck_parser_implicit_typing( SyckParser *, int );
+void syck_parser_taguri_expansion( SyckParser *, int );
+void syck_parser_handler( SyckParser *, SyckNodeHandler );
+void syck_parser_error_handler( SyckParser *, SyckErrorHandler );
+void syck_parser_bad_anchor_handler( SyckParser *, SyckBadAnchorHandler );
+void syck_parser_file( SyckParser *, FILE *, SyckIoFileRead );
+void syck_parser_str( SyckParser *, char *, long, SyckIoStrRead );
+void syck_parser_str_auto( SyckParser *, char *, SyckIoStrRead );
+SyckLevel *syck_parser_current_level( SyckParser * );
+void syck_parser_add_level( SyckParser *, int, enum syck_level_status );
+void syck_parser_pop_level( SyckParser * );
+void free_any_io( SyckParser * );
+long syck_parser_read( SyckParser * );
+long syck_parser_readlen( SyckParser *, long );
+void syck_parser_init( SyckParser *, int );
+SYMID syck_parse( SyckParser * );
+void syck_default_error_handler( SyckParser *, char * );
+SYMID syck_yaml2byte_handler( SyckParser *, SyckNode * );
+char *syck_yaml2byte( char * );
+
+/*
+ * Allocation prototypes
+ */
+SyckNode *syck_alloc_map();
+SyckNode *syck_alloc_seq();
+SyckNode *syck_alloc_str();
+void syck_free_node( SyckNode * );
+void syck_free_members( SyckNode * );
+SyckNode *syck_new_str( char *, enum scalar_style );
+SyckNode *syck_new_str2( char *, long, enum scalar_style );
+void syck_str_blow_away_commas( SyckNode * );
+char *syck_str_read( SyckNode * );
+SyckNode *syck_new_map( SYMID, SYMID );
+void syck_map_add( SyckNode *, SYMID, SYMID );
+SYMID syck_map_read( SyckNode *, enum map_part, long );
+void syck_map_assign( SyckNode *, enum map_part, long, SYMID );
+long syck_map_count( SyckNode * );
+void syck_map_update( SyckNode *, SyckNode * );
+SyckNode *syck_new_seq( SYMID );
+void syck_seq_add( SyckNode *, SYMID );
+SYMID syck_seq_read( SyckNode *, long );
+long syck_seq_count( SyckNode * );
+
+void apply_seq_in_map( SyckParser *, SyckNode * );
+
+/*
+ * Lexer prototypes
+ */
+void syckerror( char * );
+
+#ifndef ST_DATA_T_DEFINED
+typedef long st_data_t;
+#endif
+
+#if defined(__cplusplus)
+} /* extern "C" { */
+#endif
+
+#endif /* ifndef SYCK_H */
diff --git a/ext/syck/token.c b/ext/syck/token.c
new file mode 100644
index 0000000000..85a4e103ab
--- /dev/null
+++ b/ext/syck/token.c
@@ -0,0 +1,2636 @@
+/* Generated by re2c 0.9.3 on Fri Aug 13 11:47:50 2004 */
+#line 1 "token.re"
+/*
+ * token.re
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
+#include "ruby.h"
+#include "syck.h"
+#include "gram.h"
+
+/*
+ * Allocate quoted strings in chunks
+ */
+#define QUOTELEN 1024
+
+/*
+ * They do my bidding...
+ */
+#define YYCTYPE char
+#define YYCURSOR parser->cursor
+#define YYMARKER parser->marker
+#define YYLIMIT parser->limit
+#define YYTOKEN parser->token
+#define YYTOKTMP parser->toktmp
+#define YYLINEPTR parser->lineptr
+#define YYLINECTPTR parser->linectptr
+#define YYLINE parser->linect
+#define YYFILL(n) syck_parser_read(parser)
+
+/*
+ * Repositions the cursor at `n' offset from the token start.
+ * Only works in `Header' and `Document' sections.
+ */
+#define YYPOS(n) YYCURSOR = YYTOKEN + n
+
+/*
+ * Track line numbers
+ */
+#define NEWLINE(ptr) YYLINEPTR = ptr + newline_len(ptr); if ( YYLINEPTR > YYLINECTPTR ) { YYLINE++; YYLINECTPTR = YYLINEPTR; }
+
+/*
+ * I like seeing the level operations as macros...
+ */
+#define ADD_LEVEL(len, status) syck_parser_add_level( parser, len, status )
+#define POP_LEVEL() syck_parser_pop_level( parser )
+#define CURRENT_LEVEL() syck_parser_current_level( parser )
+
+/*
+ * Force a token next time around sycklex()
+ */
+#define FORCE_NEXT_TOKEN(tok) parser->force_token = tok;
+
+/*
+ * Nice little macro to ensure we're YAML_IOPENed to the current level.
+ * * Only use this macro in the "Document" section *
+ */
+#define ENSURE_YAML_IOPEN(last_lvl, to_len, reset) \
+ if ( last_lvl->spaces < to_len ) \
+ { \
+ if ( last_lvl->status == syck_lvl_inline ) \
+ { \
+ goto Document; \
+ } \
+ else \
+ { \
+ ADD_LEVEL( to_len, syck_lvl_doc ); \
+ if ( reset == 1 ) YYPOS(0); \
+ return YAML_IOPEN; \
+ } \
+ }
+
+/*
+ * Nice little macro to ensure closure of levels.
+ * * Only use this macro in the "Document" section *
+ */
+#define ENSURE_YAML_IEND(last_lvl, to_len) \
+ if ( last_lvl->spaces > to_len ) \
+ { \
+ syck_parser_pop_level( parser ); \
+ YYPOS(0); \
+ return YAML_IEND; \
+ }
+
+/*
+ * Concatenates quoted string items and manages allocation
+ * to the quoted string
+ */
+#define QUOTECAT(s, c, i, l) \
+ { \
+ if ( i + 1 >= c ) \
+ { \
+ c += QUOTELEN; \
+ S_REALLOC_N( s, char, c ); \
+ } \
+ s[i++] = l; \
+ s[i] = '\0'; \
+ }
+
+#define QUOTECATS(s, c, i, cs, cl) \
+ { \
+ while ( i + cl >= c ) \
+ { \
+ c += QUOTELEN; \
+ S_REALLOC_N( s, char, c ); \
+ } \
+ S_MEMCPY( s + i, cs, char, cl ); \
+ i += cl; \
+ s[i] = '\0'; \
+ }
+
+/*
+ * Tags a plain scalar with a transfer method
+ * * Use only in "Plain" section *
+ */
+#define RETURN_IMPLICIT() \
+ { \
+ SyckNode *n = syck_alloc_str(); \
+ YYCURSOR = YYTOKEN; \
+ n->data.str->ptr = qstr; \
+ n->data.str->len = qidx; \
+ n->data.str->style = scalar_plain; \
+ sycklval->nodeData = n; \
+ if ( parser->implicit_typing == 1 ) \
+ { \
+ try_tag_implicit( sycklval->nodeData, parser->taguri_expansion ); \
+ } \
+ return YAML_PLAIN; \
+ }
+
+/*
+ * Keep or chomp block?
+ * * Use only in "ScalarBlock" section *
+ */
+#define RETURN_YAML_BLOCK() \
+ { \
+ SyckNode *n = syck_alloc_str(); \
+ n->type_id = syck_strndup( "str", 3 ); \
+ n->data.str->ptr = qstr; \
+ n->data.str->len = qidx; \
+ n->data.str->style = scalar_block; \
+ if ( qidx > 0 ) \
+ { \
+ if ( nlDoWhat != NL_KEEP ) \
+ { \
+ char *fc = n->data.str->ptr + n->data.str->len - 1; \
+ while ( is_newline( fc ) ) fc--; \
+ if ( nlDoWhat != NL_CHOMP && fc < n->data.str->ptr + n->data.str->len - 1 ) \
+ fc += 1; \
+ n->data.str->len = fc - n->data.str->ptr + 1; \
+ } \
+ } \
+ sycklval->nodeData = n; \
+ return YAML_BLOCK; \
+ }
+
+/*
+ * Handles newlines, calculates indent
+ */
+#define GOBBLE_UP_YAML_INDENT( ict, start ) \
+ char *indent = start; \
+ NEWLINE(indent); \
+ while ( indent < YYCURSOR ) \
+ { \
+ if ( is_newline( ++indent ) ) \
+ { \
+ NEWLINE(indent); \
+ } \
+ } \
+ ict = 0; \
+ if ( *YYCURSOR == '\0' ) \
+ { \
+ ict = -1; \
+ start = YYCURSOR - 1; \
+ } \
+ else if ( *YYLINEPTR == ' ' ) \
+ { \
+ ict = YYCURSOR - YYLINEPTR; \
+ }
+
+/*
+ * If an indent exists at the current level, back up.
+ */
+#define GET_TRUE_YAML_INDENT(indt_len) \
+ { \
+ SyckLevel *lvl_deep = CURRENT_LEVEL(); \
+ indt_len = lvl_deep->spaces; \
+ if ( indt_len == YYTOKEN - YYLINEPTR ) \
+ { \
+ SyckLevel *lvl_over; \
+ parser->lvl_idx--; \
+ lvl_over = CURRENT_LEVEL(); \
+ indt_len = lvl_over->spaces; \
+ parser->lvl_idx++; \
+ } \
+ }
+
+/*
+ * Argjh! I hate globals! Here for syckerror() only!
+ */
+SyckParser *syck_parser_ptr = NULL;
+
+/*
+ * Accessory funcs later in this file.
+ */
+void eat_comments( SyckParser * );
+char escape_seq( char );
+int is_newline( char *ptr );
+int newline_len( char *ptr );
+int sycklex_yaml_utf8( YYSTYPE *, SyckParser * );
+int sycklex_bytecode_utf8( YYSTYPE *, SyckParser * );
+int syckwrap();
+
+/*
+ * My own re-entrant sycklex() using re2c.
+ * You really get used to the limited regexp.
+ * It's really nice to not rely on backtracking and such.
+ */
+int
+sycklex( YYSTYPE *sycklval, SyckParser *parser )
+{
+ switch ( parser->input_type )
+ {
+ case syck_yaml_utf8:
+ return sycklex_yaml_utf8( sycklval, parser );
+
+ case syck_yaml_utf16:
+ syckerror( "UTF-16 is not currently supported in Syck.\nPlease contribute code to help this happen!" );
+ break;
+
+ case syck_yaml_utf32:
+ syckerror( "UTF-32 is not currently supported in Syck.\nPlease contribute code to help this happen!" );
+ break;
+
+ case syck_bytecode_utf8:
+ return sycklex_bytecode_utf8( sycklval, parser );
+ }
+}
+
+/*
+ * Parser for standard YAML [UTF-8]
+ */
+int
+sycklex_yaml_utf8( YYSTYPE *sycklval, SyckParser *parser )
+{
+ int doc_level = 0;
+ syck_parser_ptr = parser;
+ if ( YYCURSOR == NULL )
+ {
+ syck_parser_read( parser );
+ }
+
+ if ( parser->force_token != 0 )
+ {
+ int t = parser->force_token;
+ parser->force_token = 0;
+ return t;
+ }
+
+#line 279 "token.re"
+
+
+ if ( YYLINEPTR != YYCURSOR )
+ {
+ goto Document;
+ }
+
+Header:
+
+ YYTOKEN = YYCURSOR;
+
+
+#line 7 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy0;
+yy1: ++YYCURSOR;
+yy0:
+ if((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy7;
+ case '\n': goto yy9;
+ case '\r': goto yy11;
+ case ' ': goto yy12;
+ case '#': goto yy5;
+ case '-': goto yy2;
+ case '.': goto yy4;
+ default: goto yy14;
+ }
+yy2: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '-': goto yy28;
+ default: goto yy3;
+ }
+yy3:
+#line 338 "token.re"
+{ YYPOS(0);
+ goto Document;
+ }
+#line 37 "<stdout>"
+yy4: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '.': goto yy21;
+ default: goto yy3;
+ }
+yy5: ++YYCURSOR;
+ goto yy6;
+yy6:
+#line 320 "token.re"
+{ eat_comments( parser );
+ goto Header;
+ }
+#line 51 "<stdout>"
+yy7: ++YYCURSOR;
+ goto yy8;
+yy8:
+#line 324 "token.re"
+{ SyckLevel *lvl = CURRENT_LEVEL();
+ ENSURE_YAML_IEND(lvl, -1);
+ YYPOS(0);
+ return 0;
+ }
+#line 61 "<stdout>"
+yy9: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ goto yy18;
+yy10:
+#line 330 "token.re"
+{ GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN );
+ goto Header;
+ }
+#line 70 "<stdout>"
+yy11: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy17;
+ default: goto yy3;
+ }
+yy12: ++YYCURSOR;
+ yych = *YYCURSOR;
+ goto yy16;
+yy13:
+#line 334 "token.re"
+{ doc_level = YYCURSOR - YYLINEPTR;
+ goto Header;
+ }
+#line 83 "<stdout>"
+yy14: yych = *++YYCURSOR;
+ goto yy3;
+yy15: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy16;
+yy16: switch(yych){
+ case ' ': goto yy15;
+ default: goto yy13;
+ }
+yy17: yyaccept = 1;
+ YYMARKER = ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy18;
+yy18: switch(yych){
+ case '\n': case ' ': goto yy17;
+ case '\r': goto yy19;
+ default: goto yy10;
+ }
+yy19: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\n': goto yy17;
+ default: goto yy20;
+ }
+yy20: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 1: goto yy10;
+ case 0: goto yy3;
+ }
+yy21: yych = *++YYCURSOR;
+ switch(yych){
+ case '.': goto yy22;
+ default: goto yy20;
+ }
+yy22: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy23;
+ case '\r': goto yy27;
+ case ' ': goto yy25;
+ default: goto yy20;
+ }
+yy23: ++YYCURSOR;
+ goto yy24;
+yy24:
+#line 306 "token.re"
+{ SyckLevel *lvl = CURRENT_LEVEL();
+ if ( lvl->status == syck_lvl_header )
+ {
+ goto Header;
+ }
+ else
+ {
+ ENSURE_YAML_IEND(lvl, -1);
+ YYPOS(0);
+ return 0;
+ }
+ return 0;
+ }
+#line 147 "<stdout>"
+yy25: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy26;
+yy26: switch(yych){
+ case ' ': goto yy25;
+ default: goto yy24;
+ }
+yy27: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy23;
+ default: goto yy20;
+ }
+yy28: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy29;
+ default: goto yy20;
+ }
+yy29: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy30;
+ case '\r': goto yy34;
+ case ' ': goto yy32;
+ default: goto yy20;
+ }
+yy30: ++YYCURSOR;
+ goto yy31;
+yy31:
+#line 292 "token.re"
+{ SyckLevel *lvl = CURRENT_LEVEL();
+ if ( lvl->status == syck_lvl_header )
+ {
+ YYPOS(3);
+ goto Directive;
+ }
+ else
+ {
+ ENSURE_YAML_IEND(lvl, -1);
+ YYPOS(0);
+ return 0;
+ }
+ }
+#line 191 "<stdout>"
+yy32: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy33;
+yy33: switch(yych){
+ case ' ': goto yy32;
+ default: goto yy31;
+ }
+yy34: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy30;
+ default: goto yy20;
+ }
+}
+#line 342 "token.re"
+
+
+Document:
+ {
+ SyckLevel *lvl = CURRENT_LEVEL();
+ if ( lvl->status == syck_lvl_header )
+ {
+ lvl->status = syck_lvl_doc;
+ }
+
+ YYTOKEN = YYCURSOR;
+
+
+#line 209 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy35;
+yy36: ++YYCURSOR;
+yy35:
+ if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy60;
+ case '\n': goto yy37;
+ case '\r': goto yy39;
+ case ' ': goto yy58;
+ case '!': goto yy49;
+ case '"': goto yy53;
+ case '#': goto yy56;
+ case '&': goto yy47;
+ case '\'': goto yy51;
+ case '*': goto yy48;
+ case ',': case ':': goto yy45;
+ case '-': case '?': goto yy46;
+ case '>': case '|': goto yy55;
+ case '[': case '{': goto yy41;
+ case ']': case '}': goto yy43;
+ default: goto yy62;
+ }
+yy37: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ goto yy90;
+yy38:
+#line 356 "token.re"
+{ /* Isolate spaces */
+ int indt_len;
+ GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN );
+ lvl = CURRENT_LEVEL();
+ doc_level = 0;
+
+ /* XXX: Comment lookahead */
+ if ( *YYCURSOR == '#' )
+ {
+ goto Document;
+ }
+
+ /* Ignore indentation inside inlines */
+ if ( lvl->status == syck_lvl_inline )
+ {
+ goto Document;
+ }
+
+ /* Check for open indent */
+ ENSURE_YAML_IEND(lvl, indt_len);
+ ENSURE_YAML_IOPEN(lvl, indt_len, 0);
+ if ( indt_len == -1 )
+ {
+ return 0;
+ }
+ return YAML_INDENT;
+ }
+#line 268 "<stdout>"
+yy39: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy89;
+ default: goto yy40;
+ }
+yy40:
+#line 454 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
+ goto Plain;
+ }
+#line 279 "<stdout>"
+yy41: ++YYCURSOR;
+ goto yy42;
+yy42:
+#line 384 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
+ lvl = CURRENT_LEVEL();
+ ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline);
+ return YYTOKEN[0];
+ }
+#line 289 "<stdout>"
+yy43: ++YYCURSOR;
+ goto yy44;
+yy44:
+#line 390 "token.re"
+{ POP_LEVEL();
+ return YYTOKEN[0];
+ }
+#line 297 "<stdout>"
+yy45: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy84;
+ case '\r': goto yy88;
+ case ' ': goto yy86;
+ default: goto yy40;
+ }
+yy46: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy79;
+ case '\r': goto yy83;
+ case ' ': goto yy81;
+ default: goto yy40;
+ }
+yy47: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy76;
+ default: goto yy40;
+ }
+yy48: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy73;
+ default: goto yy40;
+ }
+yy49: ++YYCURSOR;
+ goto yy50;
+yy50:
+#line 428 "token.re"
+{ goto TransferMethod; }
+#line 447 "<stdout>"
+yy51: ++YYCURSOR;
+ goto yy52;
+yy52:
+#line 430 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
+ goto SingleQuote; }
+#line 454 "<stdout>"
+yy53: ++YYCURSOR;
+ goto yy54;
+yy54:
+#line 433 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
+ goto DoubleQuote; }
+#line 461 "<stdout>"
+yy55: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy68;
+ case '\r': goto yy72;
+ case ' ': goto yy70;
+ case '+': case '-': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy65;
+ default: goto yy40;
+ }
+yy56: ++YYCURSOR;
+ goto yy57;
+yy57:
+#line 443 "token.re"
+{ eat_comments( parser );
+ goto Document;
+ }
+#line 487 "<stdout>"
+yy58: ++YYCURSOR;
+ yych = *YYCURSOR;
+ goto yy64;
+yy59:
+#line 447 "token.re"
+{ goto Document; }
+#line 493 "<stdout>"
+yy60: ++YYCURSOR;
+ goto yy61;
+yy61:
+#line 449 "token.re"
+{ ENSURE_YAML_IEND(lvl, -1);
+ YYPOS(0);
+ return 0;
+ }
+#line 502 "<stdout>"
+yy62: yych = *++YYCURSOR;
+ goto yy40;
+yy63: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy64;
+yy64: switch(yych){
+ case ' ': goto yy63;
+ default: goto yy59;
+ }
+yy65: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy66;
+yy66: switch(yych){
+ case '\n': goto yy68;
+ case '\r': goto yy72;
+ case ' ': goto yy70;
+ case '+': case '-': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': goto yy65;
+ default: goto yy67;
+ }
+yy67: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy38;
+ case 1: goto yy40;
+ }
+yy68: ++YYCURSOR;
+ goto yy69;
+yy69:
+#line 436 "token.re"
+{ if ( is_newline( YYCURSOR - 1 ) )
+ {
+ YYCURSOR--;
+ }
+ goto ScalarBlock;
+ }
+#line 550 "<stdout>"
+yy70: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy71;
+yy71: switch(yych){
+ case ' ': goto yy70;
+ default: goto yy69;
+ }
+yy72: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy68;
+ default: goto yy67;
+ }
+yy73: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy74;
+yy74: switch(yych){
+ case '-': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy73;
+ default: goto yy75;
+ }
+yy75:
+#line 423 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
+ sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
+ return YAML_ALIAS;
+ }
+#line 639 "<stdout>"
+yy76: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy77;
+yy77: switch(yych){
+ case '-': case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z': case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy76;
+ default: goto yy78;
+ }
+yy78:
+#line 412 "token.re"
+{ sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
+
+ /*
+ * Remove previous anchors of the same name. Since the parser will likely
+ * construct deeper nodes first, we want those nodes to be placed in the
+ * queue for matching at a higher level of indentation.
+ */
+ syck_hdlr_remove_anchor(parser, sycklval->name);
+ return YAML_ANCHOR;
+ }
+#line 720 "<stdout>"
+yy79: ++YYCURSOR;
+ goto yy80;
+yy80:
+#line 398 "token.re"
+{ ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1);
+ FORCE_NEXT_TOKEN(YAML_IOPEN);
+ if ( *YYCURSOR == '#' || is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) )
+ {
+ YYCURSOR--;
+ ADD_LEVEL((YYTOKEN + 1) - YYLINEPTR, syck_lvl_doc);
+ }
+ else /* spaces followed by content uses the space as indentation */
+ {
+ ADD_LEVEL(YYCURSOR - YYLINEPTR, syck_lvl_doc);
+ }
+ return YYTOKEN[0];
+ }
+#line 738 "<stdout>"
+yy81: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy82;
+yy82: switch(yych){
+ case ' ': goto yy81;
+ default: goto yy80;
+ }
+yy83: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy79;
+ default: goto yy67;
+ }
+yy84: ++YYCURSOR;
+ goto yy85;
+yy85:
+#line 394 "token.re"
+{ YYPOS(1);
+ return YYTOKEN[0];
+ }
+#line 760 "<stdout>"
+yy86: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy87;
+yy87: switch(yych){
+ case ' ': goto yy86;
+ default: goto yy85;
+ }
+yy88: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy84;
+ default: goto yy67;
+ }
+yy89: yyaccept = 0;
+ YYMARKER = ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy90;
+yy90: switch(yych){
+ case '\n': case ' ': goto yy89;
+ case '\r': goto yy91;
+ default: goto yy38;
+ }
+yy91: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\n': goto yy89;
+ default: goto yy67;
+ }
+}
+#line 458 "token.re"
+
+ }
+
+Directive:
+ {
+ YYTOKTMP = YYCURSOR;
+
+
+#line 796 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy92;
+yy93: ++YYCURSOR;
+yy92:
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy94;
+ case ' ': goto yy97;
+ case '%': goto yy95;
+ default: goto yy99;
+ }
+yy94: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy96;
+ }
+yy95: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy102;
+ default: goto yy96;
+ }
+yy96:
+#line 471 "token.re"
+{ YYCURSOR = YYTOKTMP;
+ return YAML_DOCSEP;
+ }
+#line 900 "<stdout>"
+yy97: ++YYCURSOR;
+ yych = *YYCURSOR;
+ goto yy101;
+yy98:
+#line 469 "token.re"
+{ goto Directive; }
+#line 906 "<stdout>"
+yy99: yych = *++YYCURSOR;
+ goto yy96;
+yy100: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy101;
+yy101: switch(yych){
+ case ' ': goto yy100;
+ default: goto yy98;
+ }
+yy102: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy103;
+yy103: switch(yych){
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy102;
+ case ':': goto yy104;
+ default: goto yy94;
+ }
+yy104: yych = *++YYCURSOR;
+ switch(yych){
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy105;
+ default: goto yy94;
+ }
+yy105: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy106;
+yy106: switch(yych){
+ case '.':
+ case '/':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ':':
+ case ';':
+ case '<':
+ case '=':
+ case '>':
+ case '?':
+ case '@':
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '_': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z': goto yy105;
+ default: goto yy107;
+ }
+yy107:
+#line 467 "token.re"
+{ goto Directive; }
+#line 1165 "<stdout>"
+}
+#line 474 "token.re"
+
+
+ }
+
+Plain:
+ {
+ int qidx = 0;
+ int qcapa = 100;
+ char *qstr = S_ALLOC_N( char, qcapa );
+ SyckLevel *plvl;
+ int parentIndent;
+
+ YYCURSOR = YYTOKEN;
+ plvl = CURRENT_LEVEL();
+ GET_TRUE_YAML_INDENT(parentIndent);
+
+Plain2:
+ YYTOKEN = YYCURSOR;
+
+Plain3:
+
+
+#line 1169 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy108;
+yy109: ++YYCURSOR;
+yy108:
+ if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy120;
+ case '\n': goto yy110;
+ case '\r': goto yy112;
+ case ' ': goto yy118;
+ case ',': goto yy117;
+ case ':': goto yy114;
+ case ']': case '}': goto yy115;
+ default: goto yy122;
+ }
+yy110: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ goto yy136;
+yy111:
+#line 497 "token.re"
+{ int indt_len, nl_count = 0;
+ SyckLevel *lvl;
+ char *tok = YYTOKEN;
+ GOBBLE_UP_YAML_INDENT( indt_len, tok );
+ lvl = CURRENT_LEVEL();
+
+ if ( indt_len <= parentIndent )
+ {
+ RETURN_IMPLICIT();
+ }
+
+ while ( YYTOKEN < YYCURSOR )
+ {
+ int nl_len = 0;
+ if ( nl_len = newline_len( YYTOKEN++ ) )
+ {
+ nl_count++;
+ YYTOKEN += nl_len - 1;
+ }
+ }
+ if ( nl_count <= 1 )
+ {
+ QUOTECAT(qstr, qcapa, qidx, ' ');
+ }
+ else
+ {
+ int i;
+ for ( i = 0; i < nl_count - 1; i++ )
+ {
+ QUOTECAT(qstr, qcapa, qidx, '\n');
+ }
+ }
+
+ goto Plain2;
+ }
+#line 1228 "<stdout>"
+yy112: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy135;
+ default: goto yy113;
+ }
+yy113:
+#line 566 "token.re"
+{ QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN);
+ goto Plain2;
+ }
+#line 1239 "<stdout>"
+yy114: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy130;
+ case '\r': goto yy134;
+ case ' ': goto yy132;
+ default: goto yy113;
+ }
+yy115: ++YYCURSOR;
+ goto yy116;
+yy116:
+#line 535 "token.re"
+{ if ( plvl->status != syck_lvl_inline )
+ {
+ if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) )
+ {
+ YYCURSOR--;
+ }
+ QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN);
+ goto Plain2;
+ }
+ else
+ {
+ /* trim spaces off the end in case of indent */
+ char *walker = qstr + qidx - 1;
+ while ( walker > qstr && ( *walker == '\n' || *walker == ' ' ) )
+ {
+ qidx--;
+ walker[0] = '\0';
+ walker--;
+ }
+ }
+ RETURN_IMPLICIT();
+ }
+#line 1274 "<stdout>"
+yy117: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy125;
+ case '\r': goto yy128;
+ case ' ': goto yy126;
+ default: goto yy113;
+ }
+yy118: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '#': goto yy123;
+ default: goto yy119;
+ }
+yy119:
+#line 564 "token.re"
+{ goto Plain3; }
+#line 1291 "<stdout>"
+yy120: ++YYCURSOR;
+ goto yy121;
+yy121:
+#line 562 "token.re"
+{ RETURN_IMPLICIT(); }
+#line 1297 "<stdout>"
+yy122: yych = *++YYCURSOR;
+ goto yy113;
+yy123: ++YYCURSOR;
+ goto yy124;
+yy124:
+#line 558 "token.re"
+{ eat_comments( parser );
+ RETURN_IMPLICIT();
+ }
+#line 1307 "<stdout>"
+yy125: yych = *++YYCURSOR;
+ goto yy116;
+yy126: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy127;
+yy127: switch(yych){
+ case ' ': goto yy126;
+ default: goto yy116;
+ }
+yy128: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy125;
+ default: goto yy129;
+ }
+yy129: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy111;
+ case 1: goto yy113;
+ }
+yy130: ++YYCURSOR;
+ goto yy131;
+yy131:
+#line 533 "token.re"
+{ RETURN_IMPLICIT(); }
+#line 1334 "<stdout>"
+yy132: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy133;
+yy133: switch(yych){
+ case ' ': goto yy132;
+ default: goto yy131;
+ }
+yy134: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy130;
+ default: goto yy129;
+ }
+yy135: yyaccept = 0;
+ YYMARKER = ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy136;
+yy136: switch(yych){
+ case '\n': case ' ': goto yy135;
+ case '\r': goto yy137;
+ default: goto yy111;
+ }
+yy137: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\n': goto yy135;
+ default: goto yy129;
+ }
+}
+#line 570 "token.re"
+
+ }
+
+SingleQuote:
+ {
+ int qidx = 0;
+ int qcapa = 100;
+ char *qstr = S_ALLOC_N( char, qcapa );
+
+SingleQuote2:
+ YYTOKEN = YYCURSOR;
+
+
+#line 1370 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy138;
+yy139: ++YYCURSOR;
+yy138:
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy146;
+ case '\n': goto yy140;
+ case '\r': goto yy142;
+ case '\'': goto yy144;
+ default: goto yy147;
+ }
+yy140: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ goto yy151;
+yy141:
+#line 584 "token.re"
+{ int indt_len;
+ int nl_count = 0;
+ SyckLevel *lvl;
+ GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN );
+ lvl = CURRENT_LEVEL();
+
+ if ( lvl->status != syck_lvl_str )
+ {
+ ADD_LEVEL( indt_len, syck_lvl_str );
+ }
+ else if ( indt_len < lvl->spaces )
+ {
+ /* Error! */
+ }
+
+ while ( YYTOKEN < YYCURSOR )
+ {
+ int nl_len = 0;
+ if ( nl_len = newline_len( YYTOKEN++ ) )
+ {
+ nl_count++;
+ YYTOKEN += nl_len - 1;
+ }
+ }
+ if ( nl_count <= 1 )
+ {
+ QUOTECAT(qstr, qcapa, qidx, ' ');
+ }
+ else
+ {
+ int i;
+ for ( i = 0; i < nl_count - 1; i++ )
+ {
+ QUOTECAT(qstr, qcapa, qidx, '\n');
+ }
+ }
+
+ goto SingleQuote2;
+ }
+#line 1430 "<stdout>"
+yy142: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy150;
+ default: goto yy143;
+ }
+yy143:
+#line 644 "token.re"
+{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
+ goto SingleQuote2;
+ }
+#line 1441 "<stdout>"
+yy144: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\'': goto yy148;
+ default: goto yy145;
+ }
+yy145:
+#line 628 "token.re"
+{ SyckLevel *lvl;
+ SyckNode *n = syck_alloc_str();
+ lvl = CURRENT_LEVEL();
+
+ if ( lvl->status == syck_lvl_str )
+ {
+ POP_LEVEL();
+ }
+ n->type_id = syck_strndup( "str", 3 );
+ n->data.str->ptr = qstr;
+ n->data.str->len = qidx;
+ n->data.str->style = scalar_1quote;
+ sycklval->nodeData = n;
+ return YAML_PLAIN;
+ }
+#line 1464 "<stdout>"
+yy146: yych = *++YYCURSOR;
+ goto yy145;
+yy147: yych = *++YYCURSOR;
+ goto yy143;
+yy148: ++YYCURSOR;
+ goto yy149;
+yy149:
+#line 624 "token.re"
+{ QUOTECAT(qstr, qcapa, qidx, '\'');
+ goto SingleQuote2;
+ }
+#line 1476 "<stdout>"
+yy150: yyaccept = 0;
+ YYMARKER = ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy151;
+yy151: switch(yych){
+ case '\n': case ' ': goto yy150;
+ case '\r': goto yy152;
+ default: goto yy141;
+ }
+yy152: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\n': goto yy150;
+ default: goto yy153;
+ }
+yy153: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy141;
+ }
+}
+#line 648 "token.re"
+
+
+ }
+
+
+DoubleQuote:
+ {
+ int keep_nl = 1;
+ int qidx = 0;
+ int qcapa = 100;
+ char *qstr = S_ALLOC_N( char, qcapa );
+
+DoubleQuote2:
+ YYTOKEN = YYCURSOR;
+
+
+
+#line 1502 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy154;
+yy155: ++YYCURSOR;
+yy154:
+ if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy161;
+ case '\n': goto yy156;
+ case '\r': goto yy158;
+ case '"': goto yy163;
+ case '\\': goto yy160;
+ default: goto yy164;
+ }
+yy156: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ goto yy178;
+yy157:
+#line 666 "token.re"
+{ int indt_len;
+ int nl_count = 0;
+ SyckLevel *lvl;
+ GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN );
+ lvl = CURRENT_LEVEL();
+
+ if ( lvl->status != syck_lvl_str )
+ {
+ ADD_LEVEL( indt_len, syck_lvl_str );
+ }
+ else if ( indt_len < lvl->spaces )
+ {
+ /* FIXME */
+ }
+
+ if ( keep_nl == 1 )
+ {
+ while ( YYTOKEN < YYCURSOR )
+ {
+ int nl_len = 0;
+ if ( nl_len = newline_len( YYTOKEN++ ) )
+ {
+ nl_count++;
+ YYTOKEN += nl_len - 1;
+ }
+ }
+ if ( nl_count <= 1 )
+ {
+ QUOTECAT(qstr, qcapa, qidx, ' ');
+ }
+ else
+ {
+ int i;
+ for ( i = 0; i < nl_count - 1; i++ )
+ {
+ QUOTECAT(qstr, qcapa, qidx, '\n');
+ }
+ }
+ }
+
+ keep_nl = 1;
+ goto DoubleQuote2;
+ }
+#line 1567 "<stdout>"
+yy158: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy177;
+ default: goto yy159;
+ }
+yy159:
+#line 745 "token.re"
+{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
+ goto DoubleQuote2;
+ }
+#line 1578 "<stdout>"
+yy160: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '\n': goto yy168;
+ case '\r': goto yy170;
+ case ' ': goto yy165;
+ case '"': case '0': case '\\': case 'a':
+ case 'b': case 'e':
+ case 'f': case 'n': case 'r': case 't': case 'v': goto yy172;
+ case 'x': goto yy171;
+ default: goto yy159;
+ }
+yy161: ++YYCURSOR;
+ goto yy162;
+yy162:
+#line 729 "token.re"
+{ SyckLevel *lvl;
+ SyckNode *n = syck_alloc_str();
+ lvl = CURRENT_LEVEL();
+
+ if ( lvl->status == syck_lvl_str )
+ {
+ POP_LEVEL();
+ }
+ n->type_id = syck_strndup( "str", 3 );
+ n->data.str->ptr = qstr;
+ n->data.str->len = qidx;
+ n->data.str->style = scalar_2quote;
+ sycklval->nodeData = n;
+ return YAML_PLAIN;
+ }
+#line 1610 "<stdout>"
+yy163: yych = *++YYCURSOR;
+ goto yy162;
+yy164: yych = *++YYCURSOR;
+ goto yy159;
+yy165: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy166;
+yy166: switch(yych){
+ case '\n': goto yy168;
+ case '\r': goto yy170;
+ case ' ': goto yy165;
+ default: goto yy167;
+ }
+yy167: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy157;
+ case 1: goto yy159;
+ }
+yy168: ++YYCURSOR;
+ goto yy169;
+yy169:
+#line 724 "token.re"
+{ keep_nl = 0;
+ YYCURSOR--;
+ goto DoubleQuote2;
+ }
+#line 1639 "<stdout>"
+yy170: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy168;
+ default: goto yy167;
+ }
+yy171: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f': goto yy174;
+ default: goto yy167;
+ }
+yy172: ++YYCURSOR;
+ goto yy173;
+yy173:
+#line 710 "token.re"
+{ char ch = *( YYCURSOR - 1 );
+ QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
+ goto DoubleQuote2;
+ }
+#line 1677 "<stdout>"
+yy174: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f': goto yy175;
+ default: goto yy167;
+ }
+yy175: ++YYCURSOR;
+ goto yy176;
+yy176:
+#line 715 "token.re"
+{ long ch;
+ char *chr_text = syck_strndup( YYTOKEN, 4 );
+ chr_text[0] = '0';
+ ch = strtol( chr_text, NULL, 16 );
+ free( chr_text );
+ QUOTECAT(qstr, qcapa, qidx, ch);
+ goto DoubleQuote2;
+ }
+#line 1714 "<stdout>"
+yy177: yyaccept = 0;
+ YYMARKER = ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy178;
+yy178: switch(yych){
+ case '\n': case ' ': goto yy177;
+ case '\r': goto yy179;
+ default: goto yy157;
+ }
+yy179: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\n': goto yy177;
+ default: goto yy167;
+ }
+}
+#line 749 "token.re"
+
+ }
+
+TransferMethod:
+ {
+ int qidx = 0;
+ int qcapa = 100;
+ char *qstr = S_ALLOC_N( char, qcapa );
+
+TransferMethod2:
+ YYTOKTMP = YYCURSOR;
+
+
+#line 1736 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy180;
+yy181: ++YYCURSOR;
+yy180:
+ if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy182;
+ case '\n': goto yy183;
+ case '\r': goto yy186;
+ case ' ': goto yy185;
+ case '\\': goto yy188;
+ default: goto yy189;
+ }
+yy182: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy187;
+ }
+yy183: ++YYCURSOR;
+ goto yy184;
+yy184:
+#line 763 "token.re"
+{ SyckLevel *lvl;
+ YYCURSOR = YYTOKTMP;
+ if ( YYCURSOR == YYTOKEN + 1 )
+ {
+ free( qstr );
+ return YAML_ITRANSFER;
+ }
+
+ lvl = CURRENT_LEVEL();
+
+ /*
+ * URL Prefixing
+ */
+ if ( *qstr == '^' )
+ {
+ sycklval->name = S_ALLOC_N( char, qidx + strlen( lvl->domain ) );
+ sycklval->name[0] = '\0';
+ strcat( sycklval->name, lvl->domain );
+ strncat( sycklval->name, qstr + 1, qidx - 1 );
+ free( qstr );
+ }
+ else
+ {
+ char *carat = qstr;
+ char *qend = qstr + qidx;
+ while ( (++carat) < qend )
+ {
+ if ( *carat == '^' )
+ break;
+ }
+
+ if ( carat < qend )
+ {
+ free( lvl->domain );
+ lvl->domain = syck_strndup( qstr, carat - qstr );
+ sycklval->name = S_ALLOC_N( char, ( qend - carat ) + strlen( lvl->domain ) );
+ sycklval->name[0] = '\0';
+ strcat( sycklval->name, lvl->domain );
+ strncat( sycklval->name, carat + 1, ( qend - carat ) - 1 );
+ free( qstr );
+ }
+ else
+ {
+ sycklval->name = qstr;
+ }
+ }
+
+ return YAML_TRANSFER;
+ }
+#line 1810 "<stdout>"
+yy185: yych = *++YYCURSOR;
+ goto yy198;
+yy186: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy196;
+ default: goto yy187;
+ }
+yy187:
+#line 830 "token.re"
+{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
+ goto TransferMethod2;
+ }
+#line 1823 "<stdout>"
+yy188: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '"': case '0': case '\\': case 'a':
+ case 'b': case 'e':
+ case 'f': case 'n': case 'r': case 't': case 'v': goto yy191;
+ case 'x': goto yy190;
+ default: goto yy187;
+ }
+yy189: yych = *++YYCURSOR;
+ goto yy187;
+yy190: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f': goto yy193;
+ default: goto yy182;
+ }
+yy191: ++YYCURSOR;
+ goto yy192;
+yy192:
+#line 816 "token.re"
+{ char ch = *( YYCURSOR - 1 );
+ QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
+ goto TransferMethod2;
+ }
+#line 1867 "<stdout>"
+yy193: yych = *++YYCURSOR;
+ switch(yych){
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9': case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F': case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f': goto yy194;
+ default: goto yy182;
+ }
+yy194: ++YYCURSOR;
+ goto yy195;
+yy195:
+#line 821 "token.re"
+{ long ch;
+ char *chr_text = syck_strndup( YYTOKTMP, 4 );
+ chr_text[0] = '0';
+ ch = strtol( chr_text, NULL, 16 );
+ free( chr_text );
+ QUOTECAT(qstr, qcapa, qidx, ch);
+ goto TransferMethod2;
+ }
+#line 1904 "<stdout>"
+yy196: yych = *++YYCURSOR;
+ goto yy184;
+yy197: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy198;
+yy198: switch(yych){
+ case ' ': goto yy197;
+ default: goto yy184;
+ }
+}
+#line 835 "token.re"
+
+ }
+
+ScalarBlock:
+ {
+ int qidx = 0;
+ int qcapa = 100;
+ char *qstr = S_ALLOC_N( char, qcapa );
+ int blockType = 0;
+ int nlDoWhat = 0;
+ int lastIndent = 0;
+ int forceIndent = -1;
+ char *yyt = YYTOKEN;
+ SyckLevel *lvl = CURRENT_LEVEL();
+ int parentIndent;
+ GET_TRUE_YAML_INDENT(parentIndent);
+
+ switch ( *yyt )
+ {
+ case '|': blockType = BLOCK_LIT; break;
+ case '>': blockType = BLOCK_FOLD; break;
+ }
+
+ while ( ++yyt <= YYCURSOR )
+ {
+ if ( *yyt == '-' )
+ {
+ nlDoWhat = NL_CHOMP;
+ }
+ else if ( *yyt == '+' )
+ {
+ nlDoWhat = NL_KEEP;
+ }
+ else if ( isdigit( *yyt ) )
+ {
+ forceIndent = strtol( yyt, NULL, 10 ) + parentIndent;
+ }
+ }
+
+ qstr[0] = '\0';
+ YYTOKEN = YYCURSOR;
+
+ScalarBlock2:
+ YYTOKEN = YYCURSOR;
+
+
+#line 1919 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy199;
+yy200: ++YYCURSOR;
+yy199:
+ if((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy207;
+ case '\n': goto yy201;
+ case '\r': goto yy203;
+ case '#': goto yy205;
+ case '-': goto yy209;
+ default: goto yy210;
+ }
+yy201: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ goto yy220;
+yy202:
+#line 882 "token.re"
+{ char *pacer;
+ char *tok = YYTOKEN;
+ int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0;
+ GOBBLE_UP_YAML_INDENT( indt_len, tok );
+ lvl = CURRENT_LEVEL();
+
+ if ( indt_len > parentIndent && lvl->status != syck_lvl_block )
+ {
+ int new_spaces = forceIndent > 0 ? forceIndent : indt_len;
+ ADD_LEVEL( new_spaces, syck_lvl_block );
+ lastIndent = indt_len - new_spaces;
+ nl_begin = 1;
+ lvl = CURRENT_LEVEL();
+ }
+ else if ( lvl->status != syck_lvl_block )
+ {
+ YYCURSOR = YYTOKEN;
+ RETURN_YAML_BLOCK();
+ }
+
+ /*
+ * Fold only in the event of two lines being on the leftmost
+ * indentation.
+ */
+ if ( blockType == BLOCK_FOLD && lastIndent == 0 && ( indt_len - lvl->spaces ) == 0 )
+ {
+ fold_nl = 1;
+ }
+
+ pacer = YYTOKEN;
+ while ( pacer < YYCURSOR )
+ {
+ int nl_len = 0;
+ if ( nl_len = newline_len( pacer++ ) )
+ {
+ nl_count++;
+ pacer += nl_len - 1;
+ }
+ }
+
+ if ( fold_nl == 1 || nl_begin == 1 )
+ {
+ nl_count--;
+ }
+
+ if ( nl_count < 1 && nl_begin == 0 )
+ {
+ QUOTECAT(qstr, qcapa, qidx, ' ');
+ }
+ else
+ {
+ int i;
+ for ( i = 0; i < nl_count; i++ )
+ {
+ QUOTECAT(qstr, qcapa, qidx, '\n');
+ }
+ }
+
+ lastIndent = indt_len - lvl->spaces;
+ YYCURSOR -= lastIndent;
+
+ if ( indt_len < lvl->spaces )
+ {
+ POP_LEVEL();
+ YYCURSOR = YYTOKEN;
+ RETURN_YAML_BLOCK();
+ }
+ goto ScalarBlock2;
+ }
+#line 2010 "<stdout>"
+yy203: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy219;
+ default: goto yy204;
+ }
+yy204:
+#line 991 "token.re"
+{ QUOTECAT(qstr, qcapa, qidx, *YYTOKEN);
+ goto ScalarBlock2;
+ }
+#line 2021 "<stdout>"
+yy205: ++YYCURSOR;
+ goto yy206;
+yy206:
+#line 953 "token.re"
+{ lvl = CURRENT_LEVEL();
+ if ( lvl->status != syck_lvl_block )
+ {
+ eat_comments( parser );
+ YYTOKEN = YYCURSOR;
+ }
+ else
+ {
+ QUOTECAT(qstr, qcapa, qidx, *YYTOKEN);
+ }
+ goto ScalarBlock2;
+ }
+#line 2038 "<stdout>"
+yy207: ++YYCURSOR;
+ goto yy208;
+yy208:
+#line 967 "token.re"
+{ YYCURSOR--;
+ POP_LEVEL();
+ RETURN_YAML_BLOCK();
+ }
+#line 2047 "<stdout>"
+yy209: yyaccept = 1;
+ yych = *(YYMARKER = ++YYCURSOR);
+ switch(yych){
+ case '-': goto yy211;
+ default: goto yy204;
+ }
+yy210: yych = *++YYCURSOR;
+ goto yy204;
+yy211: yych = *++YYCURSOR;
+ switch(yych){
+ case '-': goto yy213;
+ default: goto yy212;
+ }
+yy212: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy202;
+ case 1: goto yy204;
+ }
+yy213: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy214;
+ case '\r': goto yy218;
+ case ' ': goto yy216;
+ default: goto yy212;
+ }
+yy214: ++YYCURSOR;
+ goto yy215;
+yy215:
+#line 972 "token.re"
+{ if ( YYTOKEN == YYLINEPTR )
+ {
+ if ( blockType == BLOCK_FOLD && qidx > 0 )
+ {
+ qidx -= 1;
+ }
+ QUOTECAT(qstr, qcapa, qidx, '\n');
+ POP_LEVEL();
+ YYCURSOR = YYTOKEN;
+ RETURN_YAML_BLOCK();
+ }
+ else
+ {
+ QUOTECAT(qstr, qcapa, qidx, *YYTOKEN);
+ YYCURSOR = YYTOKEN + 1;
+ goto ScalarBlock2;
+ }
+ }
+#line 2095 "<stdout>"
+yy216: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy217;
+yy217: switch(yych){
+ case ' ': goto yy216;
+ default: goto yy215;
+ }
+yy218: yych = *++YYCURSOR;
+ switch(yych){
+ case '\n': goto yy214;
+ default: goto yy212;
+ }
+yy219: yyaccept = 0;
+ YYMARKER = ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy220;
+yy220: switch(yych){
+ case '\n': case ' ': goto yy219;
+ case '\r': goto yy221;
+ default: goto yy202;
+ }
+yy221: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\n': goto yy219;
+ default: goto yy212;
+ }
+}
+#line 996 "token.re"
+
+ }
+
+ return 0;
+
+}
+
+void
+eat_comments( SyckParser *parser )
+{
+Comment:
+ {
+ YYTOKEN = YYCURSOR;
+
+
+#line 2131 "<stdout>"
+{
+ YYCTYPE yych;
+ unsigned int yyaccept;
+ goto yy222;
+yy223: ++YYCURSOR;
+yy222:
+ if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\000': goto yy224;
+ case '\n': goto yy226;
+ case '\r': goto yy227;
+ default: goto yy229;
+ }
+yy224: ++YYCURSOR;
+ goto yy225;
+yy225:
+#line 1012 "token.re"
+{ YYCURSOR = YYTOKEN;
+ return;
+ }
+#line 2153 "<stdout>"
+yy226: yyaccept = 0;
+ yych = *(YYMARKER = ++YYCURSOR);
+ goto yy231;
+yy227: ++YYCURSOR;
+ switch((yych = *YYCURSOR)) {
+ case '\n': goto yy230;
+ default: goto yy228;
+ }
+yy228:
+#line 1016 "token.re"
+{ goto Comment;
+ }
+#line 2166 "<stdout>"
+yy229: yych = *++YYCURSOR;
+ goto yy228;
+yy230: yyaccept = 0;
+ YYMARKER = ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ goto yy231;
+yy231: switch(yych){
+ case '\n': goto yy230;
+ case '\r': goto yy232;
+ default: goto yy225;
+ }
+yy232: ++YYCURSOR;
+ if(YYLIMIT == YYCURSOR) YYFILL(1);
+ yych = *YYCURSOR;
+ switch(yych){
+ case '\n': goto yy230;
+ default: goto yy233;
+ }
+yy233: YYCURSOR = YYMARKER;
+ switch(yyaccept){
+ case 0: goto yy225;
+ }
+}
+#line 1019 "token.re"
+
+
+ }
+
+}
+
+char
+escape_seq( char ch )
+{
+ switch ( ch )
+ {
+ case '0': return '\0';
+ case 'a': return 7;
+ case 'b': return '\010';
+ case 'e': return '\033';
+ case 'f': return '\014';
+ case 'n': return '\n';
+ case 'r': return '\015';
+ case 't': return '\t';
+ case 'v': return '\013';
+ default: return ch;
+ }
+}
+
+int
+is_newline( char *ptr )
+{
+ return newline_len( ptr );
+}
+
+int
+newline_len( char *ptr )
+{
+ if ( *ptr == '\n' )
+ return 1;
+
+ if ( *ptr == '\r' && *( ptr + 1 ) == '\n' )
+ return 2;
+
+ return 0;
+}
+
+int
+syckwrap()
+{
+ return 1;
+}
+
+void
+syckerror( char *msg )
+{
+ if ( syck_parser_ptr->error_handler == NULL )
+ syck_parser_ptr->error_handler = syck_default_error_handler;
+
+ syck_parser_ptr->root = syck_parser_ptr->root_on_error;
+ (syck_parser_ptr->error_handler)(syck_parser_ptr, msg);
+}
+
diff --git a/ext/syck/yaml2byte.c b/ext/syck/yaml2byte.c
new file mode 100644
index 0000000000..b2dc450ffa
--- /dev/null
+++ b/ext/syck/yaml2byte.c
@@ -0,0 +1,251 @@
+/*
+ * ybext.c
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff, clark evans
+ *
+ * WARNING WARNING WARNING --- THIS IS *NOT JUST* PLAYING
+ * ANYMORE! -- WHY HAS EMBRACED THIS AS THE REAL THING!
+ */
+#include "ruby.h"
+#include <syck.h>
+#include <assert.h>
+#define YAMLBYTE_UTF8
+#include "yamlbyte.h"
+
+#include <stdio.h>
+#define TRACE0(a) \
+ do { printf(a); printf("\n"); fflush(stdout); } while(0)
+#define TRACE1(a,b) \
+ do { printf(a,b); printf("\n"); fflush(stdout); } while(0)
+#define TRACE2(a,b,c) \
+ do { printf(a,b,c); printf("\n"); fflush(stdout); } while(0)
+#define TRACE3(a,b,c,d) \
+ do { printf(a,b,c,d); printf("\n"); fflush(stdout); } while(0)
+
+/* Reinvent the wheel... */
+#define CHUNKSIZE 64
+#define HASH ((long)0xCAFECAFE)
+typedef struct {
+ long hash;
+ char *buffer;
+ long length;
+ long remaining;
+ int printed;
+} bytestring_t;
+bytestring_t *bytestring_alloc() {
+ bytestring_t *ret;
+ /*TRACE0("bytestring_alloc()");*/
+ ret = S_ALLOC(bytestring_t);
+ ret->hash = HASH;
+ ret->length = CHUNKSIZE;
+ ret->remaining = ret->length;
+ ret->buffer = S_ALLOC_N(char, ret->length + 1 );
+ ret->buffer[0] = 0;
+ ret->printed = 0;
+ return ret;
+}
+void bytestring_append(bytestring_t *str, char code,
+ char *start, char *finish)
+{
+ long grow;
+ long length = 2; /* CODE + LF */
+ char *curr;
+ assert(str && HASH == str->hash);
+ /*TRACE0("bytestring_append()");*/
+ if(start) {
+ if(!finish)
+ finish = start + strlen(start);
+ length += (finish-start);
+ }
+ if(length > str->remaining) {
+ grow = (length - str->remaining) + CHUNKSIZE;
+ str->remaining += grow;
+ str->length += grow;
+ str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 );
+ assert(str->buffer);
+ }
+ curr = str->buffer + (str->length - str->remaining);
+ *curr = code;
+ curr += 1;
+ if(start)
+ while(start < finish)
+ *curr ++ = *start ++;
+ *curr = '\n';
+ curr += 1;
+ *curr = 0;
+ str->remaining = str->remaining - length;
+ assert( (str->buffer + str->length) - str->remaining );
+}
+void bytestring_extend(bytestring_t *str, bytestring_t *ext)
+{
+ char *from;
+ char *curr;
+ char *stop;
+ long grow;
+ long length;
+ assert(str && HASH == str->hash);
+ assert(ext && HASH == ext->hash);
+ if(ext->printed) {
+ assert(ext->buffer[0] ==YAMLBYTE_ANCHOR);
+ curr = ext->buffer;
+ while( '\n' != *curr)
+ curr++;
+ bytestring_append(str, YAMLBYTE_ALIAS, ext->buffer + 1, curr);
+ } else {
+ ext->printed = 1;
+ length = (ext->length - ext->remaining);
+ if(length > str->remaining) {
+ grow = (length - str->remaining) + CHUNKSIZE;
+ str->remaining += grow;
+ str->length += grow;
+ str->buffer = S_REALLOC_N( str->buffer, char, str->length + 1 );
+ }
+ curr = str->buffer + (str->length - str->remaining);
+ from = ext->buffer;
+ stop = ext->buffer + length;
+ while( from < stop )
+ *curr ++ = *from ++;
+ *curr = 0;
+ str->remaining = str->remaining - length;
+ assert( (str->buffer + str->length) - str->remaining );
+ }
+}
+
+/* convert SyckNode into yamlbyte_buffer_t objects */
+SYMID
+syck_yaml2byte_handler(p, n)
+ SyckParser *p;
+ SyckNode *n;
+{
+ SYMID oid;
+ long i;
+ char ch;
+ char nextcode;
+ char *start;
+ char *current;
+ char *finish;
+ bytestring_t *val = NULL;
+ bytestring_t *sav = NULL;
+ /*TRACE0("syck_yaml2byte_handler()");*/
+ val = bytestring_alloc();
+ if(n->anchor) bytestring_append(val,YAMLBYTE_ANCHOR, n->anchor, NULL);
+ if ( n->type_id )
+ {
+ if ( p->taguri_expansion )
+ {
+ bytestring_append(val,YAMLBYTE_TRANSFER, n->type_id, NULL);
+ }
+ else
+ {
+ char *type_tag = S_ALLOC_N( char, strlen( n->type_id ) + 1 );
+ type_tag[0] = '\0';
+ strcat( type_tag, "!" );
+ strcat( type_tag, n->type_id );
+ bytestring_append( val, YAMLBYTE_TRANSFER, type_tag, NULL);
+ }
+ }
+ switch (n->kind)
+ {
+ case syck_str_kind:
+ nextcode = YAMLBYTE_SCALAR;
+ start = n->data.str->ptr;
+ finish = start + n->data.str->len - 1;
+ current = start;
+ /*TRACE2("SCALAR: %s %d", start, n->data.str->len); */
+ while(1) {
+ ch = *current;
+ if('\n' == ch || 0 == ch || current > finish) {
+ if(current >= start) {
+ bytestring_append(val, nextcode, start, current);
+ nextcode = YAMLBYTE_CONTINUE;
+ }
+ start = current + 1;
+ if(current > finish)
+ {
+ break;
+ }
+ else if('\n' == ch )
+ {
+ bytestring_append(val,YAMLBYTE_NEWLINE,NULL,NULL);
+ }
+ else if(0 == ch)
+ {
+ bytestring_append(val,YAMLBYTE_NULLCHAR,NULL,NULL);
+ }
+ else
+ {
+ assert("oops");
+ }
+ }
+ current += 1;
+ }
+ break;
+ case syck_seq_kind:
+ bytestring_append(val,YAMLBYTE_SEQUENCE,NULL,NULL);
+ for ( i = 0; i < n->data.list->idx; i++ )
+ {
+ oid = syck_seq_read( n, i );
+ syck_lookup_sym( p, oid, (char **)&sav );
+ bytestring_extend(val, sav);
+ }
+ bytestring_append(val,YAMLBYTE_END_BRANCH,NULL,NULL);
+ break;
+ case syck_map_kind:
+ bytestring_append(val,YAMLBYTE_MAPPING,NULL,NULL);
+ for ( i = 0; i < n->data.pairs->idx; i++ )
+ {
+ oid = syck_map_read( n, map_key, i );
+ syck_lookup_sym( p, oid, (char **)&sav );
+ bytestring_extend(val, sav);
+ oid = syck_map_read( n, map_value, i );
+ syck_lookup_sym( p, oid, (char **)&sav );
+ bytestring_extend(val, sav);
+ }
+ bytestring_append(val,YAMLBYTE_END_BRANCH,NULL,NULL);
+ break;
+ }
+ oid = syck_add_sym( p, (char *) val );
+ /*TRACE1("Saving: %s", val->buffer );*/
+ return oid;
+}
+
+char *
+syck_yaml2byte(char *yamlstr)
+{
+ SYMID oid;
+ char *ret;
+ bytestring_t *sav;
+
+ SyckParser *parser = syck_new_parser();
+ syck_parser_str_auto( parser, yamlstr, NULL );
+ syck_parser_handler( parser, syck_yaml2byte_handler );
+ syck_parser_error_handler( parser, NULL );
+ syck_parser_implicit_typing( parser, 1 );
+ syck_parser_taguri_expansion( parser, 1 );
+ oid = syck_parse( parser );
+ syck_lookup_sym( parser, oid, (char **)&sav );
+
+ ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 );
+ ret[0] = '\0';
+ strcat( ret, "D\n" );
+ strcat( ret, sav->buffer );
+
+ syck_free_parser( parser );
+ return ret;
+}
+
+#ifdef TEST_YBEXT
+#include <stdio.h>
+int main() {
+ char *yaml = "test: 1\nand: \"with new\\nline\\n\"\nalso: &3 three\nmore: *3";
+ printf("--- # YAML \n");
+ printf(yaml);
+ printf("\n...\n");
+ printf(syck_yaml2byte(yaml));
+ return 0;
+}
+#endif
+
diff --git a/ext/syck/yamlbyte.h b/ext/syck/yamlbyte.h
new file mode 100644
index 0000000000..0fe4e7b576
--- /dev/null
+++ b/ext/syck/yamlbyte.h
@@ -0,0 +1,170 @@
+/* yamlbyte.h
+ *
+ * The YAML bytecode "C" interface header file. See the YAML bytecode
+ * reference for bytecode sequence rules and for the meaning of each
+ * bytecode.
+ */
+
+#ifndef YAMLBYTE_H
+#define YAMLBYTE_H
+#include <stddef.h>
+
+/* define what a character is */
+typedef unsigned char yamlbyte_utf8_t;
+typedef unsigned short yamlbyte_utf16_t;
+#ifdef YAMLBYTE_UTF8
+ #ifdef YAMLBYTE_UTF16
+ #error Must only define YAMLBYTE_UTF8 or YAMLBYTE_UTF16
+ #endif
+ typedef yamlbyte_utf8_t yamlbyte_char_t;
+#else
+ #ifdef YAMLBYTE_UTF16
+ typedef yamlbyte_utf16_t yamlbyte_char_t;
+ #else
+ #error Must define YAMLBYTE_UTF8 or YAMLBYTE_UTF16
+ #endif
+#endif
+
+/* specify list of bytecodes */
+#define YAMLBYTE_FINISH ((yamlbyte_char_t) 0)
+#define YAMLBYTE_DOCUMENT ((yamlbyte_char_t)'D')
+#define YAMLBYTE_DIRECTIVE ((yamlbyte_char_t)'V')
+#define YAMLBYTE_PAUSE ((yamlbyte_char_t)'P')
+#define YAMLBYTE_MAPPING ((yamlbyte_char_t)'M')
+#define YAMLBYTE_SEQUENCE ((yamlbyte_char_t)'Q')
+#define YAMLBYTE_END_BRANCH ((yamlbyte_char_t)'E')
+#define YAMLBYTE_SCALAR ((yamlbyte_char_t)'S')
+#define YAMLBYTE_CONTINUE ((yamlbyte_char_t)'C')
+#define YAMLBYTE_NEWLINE ((yamlbyte_char_t)'N')
+#define YAMLBYTE_NULLCHAR ((yamlbyte_char_t)'Z')
+#define YAMLBYTE_ANCHOR ((yamlbyte_char_t)'A')
+#define YAMLBYTE_ALIAS ((yamlbyte_char_t)'R')
+#define YAMLBYTE_TRANSFER ((yamlbyte_char_t)'T')
+/* formatting bytecodes */
+#define YAMLBYTE_COMMENT ((yamlbyte_char_t)'c')
+#define YAMLBYTE_INDENT ((yamlbyte_char_t)'i')
+#define YAMLBYTE_STYLE ((yamlbyte_char_t)'s')
+/* other bytecodes */
+#define YAMLBYTE_LINE_NUMBER ((yamlbyte_char_t)'#')
+#define YAMLBYTE_WHOLE_SCALAR ((yamlbyte_char_t)'<')
+#define YAMLBYTE_NOTICE ((yamlbyte_char_t)'!')
+#define YAMLBYTE_SPAN ((yamlbyte_char_t)')')
+#define YAMLBYTE_ALLOC ((yamlbyte_char_t)'@')
+
+/* second level style bytecodes, ie "s>" */
+#define YAMLBYTE_FLOW ((yamlbyte_char_t)'>')
+#define YAMLBYTE_LITERAL ((yamlbyte_char_t)'|')
+#define YAMLBYTE_BLOCK ((yamlbyte_char_t)'b')
+#define YAMLBYTE_PLAIN ((yamlbyte_char_t)'p')
+#define YAMLBYTE_INLINE_MAPPING ((yamlbyte_char_t)'{')
+#define YAMLBYTE_INLINE_SEQUENCE ((yamlbyte_char_t)'[')
+#define YAMLBYTE_SINGLE_QUOTED ((yamlbyte_char_t)39)
+#define YAMLBYTE_DOUBLE_QUOTED ((yamlbyte_char_t)'"')
+
+/*
+ * The "C" API has two variants, one based on instructions,
+ * with events delivered via pointers; and the other one
+ * is character based where one or more instructions are
+ * serialized into a buffer.
+ *
+ * Note: In the instruction based API, WHOLE_SCALAR does
+ * not have the '<here' marshalling stuff.
+ */
+
+typedef void * yamlbyte_consumer_t;
+typedef void * yamlbyte_producer_t;
+
+/* push and pull APIs need a way to communicate results */
+typedef enum {
+ YAMLBYTE_OK = 0, /* proceed */
+ YAMLBYTE_E_MEMORY = 'M', /* could not allocate memory */
+ YAMLBYTE_E_READ = 'R', /* input stream read error */
+ YAMLBYTE_E_WRITE = 'W', /* output stream write error */
+ YAMLBYTE_E_OTHER = '?', /* some other error condition */
+ YAMLBYTE_E_PARSE = 'P', /* parse error, check bytecodes */
+} yamlbyte_result_t;
+
+typedef const yamlbyte_char_t *yamlbyte_buff_t;
+
+/*
+ * The "Instruction" API
+ */
+
+typedef struct yaml_instruction {
+ yamlbyte_char_t bytecode;
+ yamlbyte_buff_t start;
+ yamlbyte_buff_t finish; /* open range, *finish is _not_ part */
+} *yamlbyte_inst_t;
+
+/* producer pushes the instruction with one bytecode event to the
+ * consumer; if the consumer's result is not YAMLBYTE_OK, then
+ * the producer should stop */
+typedef
+ yamlbyte_result_t
+ (*yamlbyte_push_t)(
+ yamlbyte_consumer_t self,
+ yamlbyte_inst_t inst
+ );
+
+/* consumer pulls a bytecode instruction from the producer; in this
+ * case the instruction (and is buffer) are owned by the producer and
+ * will remain valid till the pull function is called once again;
+ * if the instruction is NULL, then there are no more results; and
+ * it is important to call the pull function till it returns NULL so
+ * that the producer can clean up its memory allocations */
+typedef
+ yamlbyte_result_t
+ (*yamlbyte_pull_t)(
+ yamlbyte_producer_t self,
+ yamlbyte_inst_t *inst /* to be filled in by the producer */
+ );
+
+/*
+ * Buffer based API
+ */
+
+/* producer pushes a null terminated buffer filled with one or more
+ * bytecode events to the consumer; if the consumer's result is not
+ * YAMLBYTE_OK, then the producer should stop */
+typedef
+ yamlbyte_result_t
+ (*yamlbyte_pushbuff_t)(
+ yamlbyte_consumer_t self,
+ yamlbyte_buff_t buff
+ );
+
+/* consumer pulls bytecode events from the producer; in this case
+ * the buffer is owned by the producer, and will remain valid till
+ * the pull function is called once again; if the buffer pointer
+ * is set to NULL, then there are no more results; it is important
+ * to call the pull function till it returns NULL so that the
+ * producer can clean up its memory allocations */
+typedef
+ yamlbyte_result_t
+ (*yamlbyte_pullbuff_t)(
+ yamlbyte_producer_t self,
+ yamlbyte_buff_t *buff /* to be filled in by the producer */
+ );
+
+/* convert a pull interface to a push interface; the reverse process
+ * requires threads and thus is language dependent */
+#define YAMLBYTE_PULL2PUSH(pull,producer,push,consumer,result) \
+ do { \
+ yamlbyte_pullbuff_t _pull = (pull); \
+ yamlbyte_pushbuff_t _push = (push); \
+ yamlbyte_result_t _result = YAMLBYTE_OK; \
+ yamlbyte_producer_t _producer = (producer); \
+ yamlbyte_consumer_t _consumer = (consumer); \
+ while(1) { \
+ yamlbyte_buff_t buff = NULL; \
+ _result = _pull(_producer,&buff); \
+ if(YAMLBYTE_OK != result || NULL == buff) \
+ break; \
+ _result = _push(_consumer,buff); \
+ if(YAMLBYTE_OK != result) \
+ break; \
+ } \
+ (result) = _result; \
+ } while(0)
+
+#endif
diff --git a/ext/syslog/.cvsignore b/ext/syslog/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/syslog/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/syslog/depend b/ext/syslog/depend
new file mode 100644
index 0000000000..45cbea293a
--- /dev/null
+++ b/ext/syslog/depend
@@ -0,0 +1,2 @@
+syslog.o: syslog.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h \
+ $(hdrdir)/intern.h
diff --git a/ext/syslog/extconf.rb b/ext/syslog/extconf.rb
new file mode 100644
index 0000000000..0fa0bc339b
--- /dev/null
+++ b/ext/syslog/extconf.rb
@@ -0,0 +1,10 @@
+# $RoughId: extconf.rb,v 1.3 2001/11/24 17:49:26 knu Exp $
+# $Id$
+
+require 'mkmf'
+
+have_header("syslog.h") &&
+ have_func("openlog") &&
+ have_func("setlogmask") &&
+ create_makefile("syslog")
+
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
new file mode 100644
index 0000000000..477489ddfe
--- /dev/null
+++ b/ext/syslog/syslog.c
@@ -0,0 +1,394 @@
+/*
+ * UNIX Syslog extension for Ruby
+ * Amos Gouaux, University of Texas at Dallas
+ * <amos+ruby@utdallas.edu>
+ *
+ * $RoughId: syslog.c,v 1.21 2002/02/25 12:21:17 knu Exp $
+ * $Id$
+ */
+
+#include "ruby.h"
+#include "util.h"
+#include <syslog.h>
+
+/* Syslog class */
+static VALUE mSyslog, mSyslogConstants;
+static const char *syslog_ident = NULL;
+static int syslog_options = -1, syslog_facility = -1, syslog_mask = -1;
+static int syslog_opened = 0;
+
+/* Package helper routines */
+static void syslog_write(int pri, int argc, VALUE *argv)
+{
+ VALUE str;
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "no log message supplied");
+ }
+
+ if (!syslog_opened) {
+ rb_raise(rb_eRuntimeError, "must open syslog before write");
+ }
+
+ str = rb_f_sprintf(argc, argv);
+
+ syslog(pri, "%s", RSTRING(str)->ptr);
+}
+
+/* Syslog module methods */
+static VALUE mSyslog_close(VALUE self)
+{
+ if (!syslog_opened) {
+ rb_raise(rb_eRuntimeError, "syslog not opened");
+ }
+
+ closelog();
+
+ free((void *)syslog_ident);
+ syslog_ident = NULL;
+ syslog_options = syslog_facility = syslog_mask = -1;
+ syslog_opened = 0;
+
+ return Qnil;
+}
+
+static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
+{
+ VALUE ident, opt, fac;
+
+ if (syslog_opened) {
+ rb_raise(rb_eRuntimeError, "syslog already open");
+ }
+
+ rb_scan_args(argc, argv, "03", &ident, &opt, &fac);
+
+ if (NIL_P(ident)) {
+ ident = rb_gv_get("$0");
+ }
+#ifdef SafeStringValue
+ SafeStringValue(ident);
+#else
+ Check_SafeStr(ident);
+#endif
+ syslog_ident = strdup(RSTRING(ident)->ptr);
+
+ if (NIL_P(opt)) {
+ syslog_options = LOG_PID | LOG_CONS;
+ } else {
+ syslog_options = NUM2INT(opt);
+ }
+
+ if (NIL_P(fac)) {
+ syslog_facility = LOG_USER;
+ } else {
+ syslog_facility = NUM2INT(fac);
+ }
+
+ openlog(syslog_ident, syslog_options, syslog_facility);
+
+ syslog_opened = 1;
+
+ setlogmask(syslog_mask = setlogmask(0));
+
+ /* be like File.new.open {...} */
+ if (rb_block_given_p()) {
+ rb_ensure(rb_yield, self, mSyslog_close, self);
+ }
+
+ return self;
+}
+
+static VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self)
+{
+ mSyslog_close(self);
+
+ return mSyslog_open(argc, argv, self);
+}
+
+static VALUE mSyslog_isopen(VALUE self)
+{
+ return syslog_opened ? Qtrue : Qfalse;
+}
+
+static VALUE mSyslog_ident(VALUE self)
+{
+ return syslog_opened ? rb_str_new2(syslog_ident) : Qnil;
+}
+
+static VALUE mSyslog_options(VALUE self)
+{
+ return syslog_opened ? INT2NUM(syslog_options) : Qnil;
+}
+
+static VALUE mSyslog_facility(VALUE self)
+{
+ return syslog_opened ? INT2NUM(syslog_facility) : Qnil;
+}
+
+static VALUE mSyslog_get_mask(VALUE self)
+{
+ return syslog_opened ? INT2NUM(syslog_mask) : Qnil;
+}
+
+static VALUE mSyslog_set_mask(VALUE self, VALUE mask)
+{
+ if (!syslog_opened) {
+ rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
+ }
+
+ setlogmask(syslog_mask = NUM2INT(mask));
+
+ return mask;
+}
+
+static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
+{
+ VALUE pri;
+
+ if (argc < 2) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
+ }
+
+ argc--;
+ pri = *argv++;
+
+ if (!FIXNUM_P(pri)) {
+ rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri)));
+ }
+
+ syslog_write(FIX2INT(pri), argc, argv);
+
+ return self;
+}
+
+static VALUE mSyslog_inspect(VALUE self)
+{
+ char buf[1024];
+
+ if (syslog_opened) {
+ snprintf(buf, sizeof(buf),
+ "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
+ rb_class2name(self),
+ syslog_ident,
+ syslog_options,
+ syslog_facility,
+ syslog_mask);
+ } else {
+ snprintf(buf, sizeof(buf),
+ "<#%s: opened=false>", rb_class2name(self));
+ }
+
+ return rb_str_new2(buf);
+}
+
+static VALUE mSyslog_instance(VALUE self)
+{
+ return self;
+}
+
+#define define_syslog_shortcut_method(pri, name) \
+static VALUE mSyslog_##name(int argc, VALUE *argv, VALUE self) \
+{ \
+ syslog_write(pri, argc, argv); \
+\
+ return self; \
+}
+
+#ifdef LOG_EMERG
+define_syslog_shortcut_method(LOG_EMERG, emerg)
+#endif
+#ifdef LOG_ALERT
+define_syslog_shortcut_method(LOG_ALERT, alert)
+#endif
+#ifdef LOG_CRIT
+define_syslog_shortcut_method(LOG_CRIT, crit)
+#endif
+#ifdef LOG_ERR
+define_syslog_shortcut_method(LOG_ERR, err)
+#endif
+#ifdef LOG_WARNING
+define_syslog_shortcut_method(LOG_WARNING, warning)
+#endif
+#ifdef LOG_NOTICE
+define_syslog_shortcut_method(LOG_NOTICE, notice)
+#endif
+#ifdef LOG_INFO
+define_syslog_shortcut_method(LOG_INFO, info)
+#endif
+#ifdef LOG_DEBUG
+define_syslog_shortcut_method(LOG_DEBUG, debug)
+#endif
+
+static VALUE mSyslogConstants_LOG_MASK(VALUE klass, VALUE pri)
+{
+ return INT2FIX(LOG_MASK(FIX2INT(pri)));
+}
+
+static VALUE mSyslogConstants_LOG_UPTO(VALUE klass, VALUE pri)
+{
+ return INT2FIX(LOG_UPTO(FIX2INT(pri)));
+}
+
+/* Init for package syslog */
+void Init_syslog()
+{
+ mSyslog = rb_define_module("Syslog");
+
+ mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
+
+ rb_include_module(mSyslog, mSyslogConstants);
+
+ rb_define_module_function(mSyslog, "open", mSyslog_open, -1);
+ rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, -1);
+ rb_define_module_function(mSyslog, "open!", mSyslog_reopen, -1);
+ rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0);
+
+ rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0);
+ rb_define_module_function(mSyslog, "options", mSyslog_options, 0);
+ rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0);
+
+ rb_define_module_function(mSyslog, "log", mSyslog_log, -1);
+ rb_define_module_function(mSyslog, "close", mSyslog_close, 0);
+ rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0);
+ rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1);
+
+ rb_define_module_function(mSyslog, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
+ rb_define_module_function(mSyslog, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);
+
+ rb_define_module_function(mSyslog, "inspect", mSyslog_inspect, 0);
+ rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0);
+
+ rb_define_module_function(mSyslogConstants, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
+ rb_define_module_function(mSyslogConstants, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);
+
+#define rb_define_syslog_const(id) \
+ rb_define_const(mSyslogConstants, #id, INT2NUM(id))
+
+ /* Various options when opening log */
+#ifdef LOG_PID
+ rb_define_syslog_const(LOG_PID);
+#endif
+#ifdef LOG_CONS
+ rb_define_syslog_const(LOG_CONS);
+#endif
+#ifdef LOG_ODELAY
+ rb_define_syslog_const(LOG_ODELAY); /* deprecated */
+#endif
+#ifdef LOG_NDELAY
+ rb_define_syslog_const(LOG_NDELAY);
+#endif
+#ifdef LOG_NOWAIT
+ rb_define_syslog_const(LOG_NOWAIT); /* deprecated */
+#endif
+#ifdef LOG_PERROR
+ rb_define_syslog_const(LOG_PERROR);
+#endif
+
+ /* Various syslog facilities */
+#ifdef LOG_AUTH
+ rb_define_syslog_const(LOG_AUTH);
+#endif
+#ifdef LOG_AUTHPRIV
+ rb_define_syslog_const(LOG_AUTHPRIV);
+#endif
+#ifdef LOG_CONSOLE
+ rb_define_syslog_const(LOG_CONSOLE);
+#endif
+#ifdef LOG_CRON
+ rb_define_syslog_const(LOG_CRON);
+#endif
+#ifdef LOG_DAEMON
+ rb_define_syslog_const(LOG_DAEMON);
+#endif
+#ifdef LOG_FTP
+ rb_define_syslog_const(LOG_FTP);
+#endif
+#ifdef LOG_KERN
+ rb_define_syslog_const(LOG_KERN);
+#endif
+#ifdef LOG_LPR
+ rb_define_syslog_const(LOG_LPR);
+#endif
+#ifdef LOG_MAIL
+ rb_define_syslog_const(LOG_MAIL);
+#endif
+#ifdef LOG_NEWS
+ rb_define_syslog_const(LOG_NEWS);
+#endif
+#ifdef LOG_NTP
+ rb_define_syslog_const(LOG_NTP);
+#endif
+#ifdef LOG_SECURITY
+ rb_define_syslog_const(LOG_SECURITY);
+#endif
+#ifdef LOG_SYSLOG
+ rb_define_syslog_const(LOG_SYSLOG);
+#endif
+#ifdef LOG_USER
+ rb_define_syslog_const(LOG_USER);
+#endif
+#ifdef LOG_UUCP
+ rb_define_syslog_const(LOG_UUCP);
+#endif
+#ifdef LOG_LOCAL0
+ rb_define_syslog_const(LOG_LOCAL0);
+#endif
+#ifdef LOG_LOCAL1
+ rb_define_syslog_const(LOG_LOCAL1);
+#endif
+#ifdef LOG_LOCAL2
+ rb_define_syslog_const(LOG_LOCAL2);
+#endif
+#ifdef LOG_LOCAL3
+ rb_define_syslog_const(LOG_LOCAL3);
+#endif
+#ifdef LOG_LOCAL4
+ rb_define_syslog_const(LOG_LOCAL4);
+#endif
+#ifdef LOG_LOCAL5
+ rb_define_syslog_const(LOG_LOCAL5);
+#endif
+#ifdef LOG_LOCAL6
+ rb_define_syslog_const(LOG_LOCAL6);
+#endif
+#ifdef LOG_LOCAL7
+ rb_define_syslog_const(LOG_LOCAL7);
+#endif
+
+#define rb_define_syslog_shortcut(name) \
+ rb_define_module_function(mSyslog, #name, mSyslog_##name, -1)
+
+ /* Various syslog priorities and the shortcut methods */
+#ifdef LOG_EMERG
+ rb_define_syslog_const(LOG_EMERG);
+ rb_define_syslog_shortcut(emerg);
+#endif
+#ifdef LOG_ALERT
+ rb_define_syslog_const(LOG_ALERT);
+ rb_define_syslog_shortcut(alert);
+#endif
+#ifdef LOG_CRIT
+ rb_define_syslog_const(LOG_CRIT);
+ rb_define_syslog_shortcut(crit);
+#endif
+#ifdef LOG_ERR
+ rb_define_syslog_const(LOG_ERR);
+ rb_define_syslog_shortcut(err);
+#endif
+#ifdef LOG_WARNING
+ rb_define_syslog_const(LOG_WARNING);
+ rb_define_syslog_shortcut(warning);
+#endif
+#ifdef LOG_NOTICE
+ rb_define_syslog_const(LOG_NOTICE);
+ rb_define_syslog_shortcut(notice);
+#endif
+#ifdef LOG_INFO
+ rb_define_syslog_const(LOG_INFO);
+ rb_define_syslog_shortcut(info);
+#endif
+#ifdef LOG_DEBUG
+ rb_define_syslog_const(LOG_DEBUG);
+ rb_define_syslog_shortcut(debug);
+#endif
+}
diff --git a/ext/syslog/syslog.txt b/ext/syslog/syslog.txt
new file mode 100644
index 0000000000..9aed35133d
--- /dev/null
+++ b/ext/syslog/syslog.txt
@@ -0,0 +1,121 @@
+.\" syslog.txt - -*- Indented-Text -*-
+$RoughId: syslog.txt,v 1.18 2002/02/25 08:20:14 knu Exp $
+$Id$
+
+UNIX Syslog extension for Ruby
+Amos Gouaux, University of Texas at Dallas
+<amos+ruby@utdallas.edu>
+&
+Akinori MUSHA
+<knu@ruby-lang.org>
+
+** Syslog(Module)
+
+Included Modules: Syslog::Constants
+
+require 'syslog'
+
+A Simple wrapper for the UNIX syslog system calls that might be handy
+if you're writing a server in Ruby. For the details of the syslog(8)
+architecture and constants, see the syslog(3) manual page of your
+platform.
+
+Module Methods:
+
+ open(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
+ facility = Syslog::LOG_USER) [{ |syslog| ... }]
+
+ Opens syslog with the given options and returns the module
+ itself. If a block is given, calls it with an argument of
+ itself. If syslog is already opened, raises RuntimeError.
+
+ Example:
+ Syslog.open('ftpd', Syslog::LOG_PID | Syslog::LOG_NDELAY,
+ Syslog::LOG_FTP)
+
+ open!(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
+ facility = Syslog::LOG_USER)
+ reopen(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
+ facility = Syslog::LOG_USER)
+
+ Same as open, but does a close first.
+
+ opened?
+
+ Returns true if syslog opened, otherwise false.
+
+ ident
+ options
+ facility
+
+ Returns the parameters given in the last open, respectively.
+ Every call of Syslog::open resets these values.
+
+ log(pri, message, ...)
+
+ Writes message to syslog.
+
+ Example:
+ Syslog.log(Syslog::LOG_CRIT, "the sky is falling in %d seconds!", 10)
+
+ crit(message, ...)
+ emerg(message, ...)
+ alert(message, ...)
+ err(message, ...)
+ warning(message, ...)
+ notice(message, ...)
+ info(message, ...)
+ debug(message, ...)
+
+ These are shortcut methods of Syslog::log(). The lineup may
+ vary depending on what priorities are defined on your system.
+
+ Example:
+ Syslog.crit("the sky is falling in %d seconds!", 5)
+
+ mask
+ mask=(mask)
+
+ Returns or sets the log priority mask. The value of the mask
+ is persistent and will not be reset by Syslog::open or
+ Syslog::close.
+
+ Example:
+ Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
+
+ close
+
+ Closes syslog.
+
+ inspect
+
+ Returns the "inspect" string of the Syslog module.
+
+ instance
+
+ Returns the module itself. (Just for backward compatibility)
+
+ LOG_MASK(pri)
+
+ Creates a mask for one priority.
+
+ LOG_UPTO(pri)
+
+ Creates a mask for all priorities up to pri.
+
+** Syslog::Constants(Module)
+
+require 'syslog'
+include Syslog::Constants
+
+This module includes the LOG_* constants available on the system.
+
+Module Methods:
+
+ LOG_MASK(pri)
+
+ Creates a mask for one priority.
+
+ LOG_UPTO(pri)
+
+ Creates a mask for all priorities up to pri.
diff --git a/ext/syslog/test.rb b/ext/syslog/test.rb
new file mode 100644
index 0000000000..cfa33eff8f
--- /dev/null
+++ b/ext/syslog/test.rb
@@ -0,0 +1,164 @@
+#!/usr/bin/env ruby
+# $RoughId: test.rb,v 1.9 2002/02/25 08:20:14 knu Exp $
+# $Id$
+
+# Please only run this test on machines reasonable for testing.
+# If in doubt, ask your admin.
+
+require 'test/unit'
+
+# Prepend current directory to load path for testing.
+$:.unshift('.')
+
+require 'syslog'
+
+class TestSyslog < Test::Unit::TestCase
+ def test_new
+ assert_raises(NoMethodError) {
+ Syslog.new
+ }
+ end
+
+ def test_instance
+ sl1 = Syslog.instance
+ sl2 = Syslog.open
+ sl3 = Syslog.instance
+
+ assert_equal(Syslog, sl1)
+ assert_equal(Syslog, sl2)
+ assert_equal(Syslog, sl3)
+ ensure
+ Syslog.close if Syslog.opened?
+ end
+
+ def test_open
+ # default parameters
+ Syslog.open
+
+ assert_equal($0, Syslog.ident)
+ assert_equal(Syslog::LOG_PID | Syslog::LOG_CONS, Syslog.options)
+ assert_equal(Syslog::LOG_USER, Syslog.facility)
+
+ # open without close
+ assert_raises(RuntimeError) {
+ Syslog.open
+ }
+
+ Syslog.close
+
+ # given parameters
+ Syslog.open("foo", Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog::LOG_DAEMON)
+
+ assert_equal('foo', Syslog.ident)
+ assert_equal(Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog.options)
+ assert_equal(Syslog::LOG_DAEMON, Syslog.facility)
+
+ Syslog.close
+
+ # default parameters again (after close)
+ Syslog.open
+ Syslog.close
+
+ assert_equal(nil, Syslog.ident)
+ assert_equal(nil, Syslog.options)
+ assert_equal(nil, Syslog.facility)
+
+ # block
+ param = nil
+ Syslog.open { |param| }
+ assert_equal(Syslog, param)
+ ensure
+ Syslog.close if Syslog.opened?
+ end
+
+ def test_opened?
+ assert_equal(false, Syslog.opened?)
+
+ Syslog.open
+ assert_equal(true, Syslog.opened?)
+
+ Syslog.close
+ assert_equal(false, Syslog.opened?)
+
+ Syslog.open {
+ assert_equal(true, Syslog.opened?)
+ }
+
+ assert_equal(false, Syslog.opened?)
+ end
+
+ def test_close
+ assert_raises(RuntimeError) {
+ Syslog.close
+ }
+ end
+
+ def test_mask
+ assert_equal(nil, Syslog.mask)
+
+ Syslog.open
+
+ orig = Syslog.mask
+
+ Syslog.mask = Syslog.LOG_UPTO(Syslog::LOG_ERR)
+ assert_equal(Syslog.LOG_UPTO(Syslog::LOG_ERR), Syslog.mask)
+
+ Syslog.mask = Syslog.LOG_MASK(Syslog::LOG_CRIT)
+ assert_equal(Syslog.LOG_MASK(Syslog::LOG_CRIT), Syslog.mask)
+
+ Syslog.mask = orig
+ ensure
+ Syslog.close if Syslog.opened?
+ end
+
+ def test_log
+ stderr = IO::pipe
+
+ pid = fork {
+ stderr[0].close
+ STDERR.reopen(stderr[1])
+ stderr[1].close
+
+ options = Syslog::LOG_PERROR | Syslog::LOG_NDELAY
+
+ Syslog.open("syslog_test", options) { |sl|
+ sl.log(Syslog::LOG_NOTICE, "test1 - hello, %s!", "world")
+ sl.notice("test1 - hello, %s!", "world")
+ }
+
+ Syslog.open("syslog_test", options | Syslog::LOG_PID) { |sl|
+ sl.log(Syslog::LOG_CRIT, "test2 - pid")
+ sl.crit("test2 - pid")
+ }
+ exit!
+ }
+
+ stderr[1].close
+ Process.waitpid(pid)
+
+ # LOG_PERROR is not yet implemented on Cygwin.
+ return if RUBY_PLATFORM =~ /cygwin/
+
+ 2.times {
+ assert_equal("syslog_test: test1 - hello, world!\n", stderr[0].gets)
+ }
+
+ 2.times {
+ assert_equal(format("syslog_test[%d]: test2 - pid\n", pid), stderr[0].gets)
+ }
+ end
+
+ def test_inspect
+ Syslog.open { |sl|
+ assert_equal(format('<#%s: opened=true, ident="%s", options=%d, facility=%d, mask=%d>',
+ Syslog,
+ sl.ident,
+ sl.options,
+ sl.facility,
+ sl.mask),
+ sl.inspect)
+ }
+
+ assert_equal(format('<#%s: opened=false>', Syslog), Syslog.inspect)
+ end
+end
diff --git a/ext/tcltklib/.cvsignore b/ext/tcltklib/.cvsignore
index f3c7a7c5da..90c83ed9b1 100644
--- a/ext/tcltklib/.cvsignore
+++ b/ext/tcltklib/.cvsignore
@@ -1 +1,3 @@
Makefile
+*.log
+*.def
diff --git a/ext/tcltklib/MANIFEST b/ext/tcltklib/MANIFEST
deleted file mode 100644
index 4e37fb900f..0000000000
--- a/ext/tcltklib/MANIFEST
+++ /dev/null
@@ -1,16 +0,0 @@
-MANIFEST
-README.euc
-MANUAL.euc
-tcltklib.c
-stubs.c
-depend
-extconf.rb
-lib/tcltk.rb
-demo/lines1.rb
-demo/lines0.tcl
-demo/lines2.rb
-sample/sample1.rb
-sample/sample2.rb
-sample/maru.gif
-sample/batsu.gif
-sample/sample0.rb
diff --git a/ext/tcltklib/MANUAL.eng b/ext/tcltklib/MANUAL.eng
new file mode 100644
index 0000000000..d3417f5dff
--- /dev/null
+++ b/ext/tcltklib/MANUAL.eng
@@ -0,0 +1,420 @@
+(tof)
+ 2004/03/28 Hidetoshi NAGAI
+
+This document discribes about the 'tcltklib' library. Although there
+is the 'tcltk' library (tcltk.rb) under this directory, no description
+in this document (because it is not maintained recently).
+
+==============================================================
+module TclTklib
+ : Defines methods to do operations which are independed on
+ : Tcl/Tk interpreters
+
+ module TclTkLib::EventFlag
+ : Defines flags to define taget events on 'do_one_event' methos.
+ : When to give, please use bit-operator (e.g. WINDOW | DONT_WAIT).
+
+ [constants]
+ NONE
+ : Is 0. It means "there is no target". But on the real
+ : operation, it is same to ALL.
+
+ WINDOW
+ : 'window' event is processed.
+
+ FILE
+ : 'file' event is processed.
+
+ TIMER
+ : 'timer' event is processed.
+
+ IDLE
+ : 'idle' operation (e.g. 're-draw'; the operations when the
+ : other kinds of events doesn't occur) is processed.
+
+ ALL
+ : All kinds of events are processed.
+ : Same to 'WINDOW | FILE | TIMER | IDLE'.
+
+ DONT_WAIT
+ : Without this flag, 'do_one_event' waits the occurence of
+ : a target event. With this flag, doesn't wait and returns
+ : false if there is no target event for processing.
+
+ module TclTkLib::VarAccessFlag
+ : Defines flags to give '_get_variable' and so on. When to give,
+ : please use bit-operator (e.g. GLOBAL_ONLY | LEAVE_ERR_MSG ).
+
+ [constants]
+ NONE
+ : Is 0. It means "set no flag".
+
+ GLOBAL_ONLY
+ : (site Tcl/Tk's man page)
+ : Under normal circumstances the procedures look up
+ : variables as follows: If a procedure call is active
+ : in interp, a variable is looked up at the current
+ : level of procedure call. Otherwise, a variable is
+ : looked up first in the current namespace, then in
+ : the global namespace. However, if this bit is set
+ : in flags then the variable is looked up only in the
+ : global namespace even if there is a procedure call
+ : active. If both GLOBAL_ONLY and NAMESPACE_ONLY are
+ : given, GLOBAL_ONLY is ignored.
+ :
+ : *** ATTENTION ***
+ : Tcl7.6 doesn't have namespaces. So NAMESPACE_ONLY
+ : is defined as 0, and then GLOBAL_ONLY is available
+ : even if flag is (GLOBAL_ONLY | NAMESPACE_ONLY).
+
+ NAMESPACE_ONLY
+ : (site Tcl/Tk's man page)
+ : Under normal circumstances the procedures look up
+ : variables as follows: If a procedure call is active
+ : in interp, a variable is looked up at the current
+ : level of procedure call. Otherwise, a variable is
+ : looked up first in the current namespace, then in
+ : the global namespace. However, if this bit is set
+ : in flags then the variable is looked up only in the
+ : current namespace even if there is a procedure call
+ : active.
+ :
+ : *** ATTENTION ***
+ : Tcl7.6 doesn't have namespaces. So NAMESPACE_ONLY
+ : is defined as 0.
+
+ LEAVE_ERR_MSG
+ : (site Tcl/Tk's man page)
+ : If an error is returned and this bit is set in flags,
+ : then an error message will be left in the interpreter's
+ : result, where it can be retrieved with Tcl_GetObjResult
+ : or Tcl_GetStringResult. If this flag bit isn't set then
+ : no error message is left and the interpreter's result
+ : will not be modified.
+
+ APPEND_VALUE
+ : (site Tcl/Tk's man page)
+ : If this bit is set then newValue is appended to the
+ : current value, instead of replacing it. If the variable
+ : is currently undefined, then this bit is ignored.
+
+ LIST_ELEMENT
+ : (site Tcl/Tk's man page)
+ : If this bit is set, then newValue is converted to a
+ : valid Tcl list element before setting (or appending
+ : to) the variable. A separator space is appended before
+ : the new list element unless the list element is going
+ : to be the first element in a list or sublist (i.e. the
+ : variable's current value is empty, or contains the
+ : single character ``{'', or ends in `` }'').
+
+ PARSE_VARNAME
+ : (site Tcl/Tk's man page)
+ : If this bit is set when calling _set_variable and so
+ : on, var_name argument may contain both an array and an
+ : element name: if the name contains an open parenthesis
+ : and ends with a close parenthesis, then the value
+ : between the parentheses is treated as an element name
+ : (which can have any string value) and the characters
+ : before the first open parenthesis are treated as the
+ : name of an array variable. If the flag PARSE_VARNAME
+ : is given, index_name argument should be 'nil' since the
+ : array and element names are taken from var_name.
+ :
+ : *** ATTENTION ***
+ : Tcl7.6 doesn't have this flag. So PARSE_VARNAME is
+ : defined as 0.
+
+ [module methods]
+ mainloop(check_root = true)
+ : Starts the eventloop. If 'check_root' is true, this method
+ : doesn't return when a root widget exists.
+ : If 'check_root' is false, doen't return by the other
+ : reasons than exceptions.
+
+ mainloop_watchdog(check_root = true)
+ : On the normal eventloop, some kinds of callback operations
+ : cause deadlock. To avoid some of such deadlocks, this
+ : method starts an eventloop and a watchdog-thread.
+
+ do_one_event(flag = TclTkLib::EventFlag::ALL |
+ TclTkLib::EventFlag::DONT_WAIT)
+ : Do one event for processing. When processed an event,
+ : returns true.
+ : If NOT set DONT_WAIT flag, this method waits occurrence of
+ : a target event.
+ : If set DONT_WAIT flag and no event for processing, returns
+ : false immediately.
+ : If $SAFE >= 4, or $SAFE >= 1 and the flag is tainted,
+ : force to set DONT_WAIT flag.
+
+ set_eventloop_tick(timer_tick)
+ : Define the interval of thread-switching with an integer
+ : value of mili-seconds.
+ : Default timer_tick is 0. It means that thread-switching
+ : is based on the count of processed events.
+ : ( see 'set_eventloop_weight' method )
+ : However, if the eventloop thread is the only thread,
+ : timer_tick cannt be set to 0. If 0, then is set to 100 ms
+ : automatically (see NO_THREAD_INTERRUPT_TIME on tcltklib.c).
+ : On $SAFE >= 4, cannot call this method.
+
+ get_eventloop_tick
+ : Get current value of 'timer_tick'
+
+ set_no_event_wait(no_event_wait)
+ : Define sleeping time of the eventloop when two or more
+ : thread are running and there is no event for processing.
+ : Default value is 20 (ms).
+ : If the eventloop thread is the only thread, this value is
+ : invalid.
+ : On $SAFE >= 4, cannot call this method.
+
+ get_no_event_wait
+ : Get current value of 'no_event_wait'.
+
+ set_eventloop_weight(loop_max, no_event_tick)
+ : Define the weight parameters for the eventloop thread.
+ : That is invalid when the eventloop is the only thread.
+ : 'loop_max' is the max events for thread-switching.
+ : 'no_event_tick' is the increment value of the event count
+ : when no event for processing (And then, the eventloop thead
+ : sleeps 'no_event_wait' mili-seconds).
+ : 'loop_max == 800' and 'no_event_tick == 10' are defalut.
+ : On $SAFE >= 4, cannot call this method.
+
+ get_eventloop_weight
+ : Get current values of 'loop_max' and 'no_event_tick'.
+
+ mainloop_abort_on_exception=(bool)
+ : Define whether the eventloop stops on exception or not.
+ : If true (default value), stops on exception.
+ : If false, show a warinig message but ignore the exception.
+ : If nil, no warning message and ignore the excepsion.
+ : This parameter is sometimes useful when multiple Tk
+ : interpreters are working. Because the only one eventloop
+ : admins all Tk interpreters, sometimes exception on a
+ : interpreter kills the eventloop thread. Even if such
+ : situation, when abort_on_exception == false or nil,
+ : the eventloop ignores the exception and continue to working.
+ : On $SAFE >= 4, cannot call this method.
+
+ mainloop_abort_on_exception
+ : Get current status of that.
+
+ num_of_mainwindows
+ : Returns the number of main-windows (root-widget).
+ : Because there is only one main-window for one Tk interpreter,
+ : the value is same to the number of interpreters which has
+ : available Tk functions.
+
+ _merge_tklist(str, str, ... )
+ : Get a Tcl's list string from arguments with a Tcl/Tk's
+ : library function. Each arguemnt is converted to a valid
+ : Tcl list element.
+
+ _conv_listelement(str)
+ : Convert the argument to a valid Tcl list element with
+ : Tcl/Tk's library function.
+
+ _toUTF8(str, encoding)
+ _fromUTF8(str, encoding)
+ : Call the function (which is internal function of Tcl/Tk) to
+ : convert to/from a UTF8 string.
+
+ _subst_UTF_backslash(str)
+ _subst_Tcl_backslash(str)
+ : Substitute backslash sequence with Tcl's rule (include \uhhhh;
+ : give a sixteen-bit hexadecimal value for Unicode character).
+ : _subst_Tcl_backslash method parses all backslash sequence.
+ : _subst_UTF_backslash method parses \uhhhh only.
+
+class TclTkIp
+ [class methods]
+ new(ip_name=nil, options='')
+ : Generate an instance of TclTkIp class.
+ : If 'ip_name' argument is given as a string, it is the name
+ : of the Tk interpreter which is shown by 'winfo interps'
+ : command.
+ : 'options' argument accepts a string which is the command
+ : line options of wish; such as '-geometry' or '-use'.
+ : The information is used to generate the root widget of the
+ : interpreter.
+ : ( e.g. TclTkIp.new('FOO', '-geometry 500x200 -use 0x2200009') )
+ : If is given nil or falsr for the 'option' argument, generates
+ : the Tcl interpreter without Tk library. Then the interpreter
+ : doesn't need GUI environment. Therefore, even if a window
+ : system doesn't exist or cannot be used, Ruby can control the
+ : Tcl interpreter and the extention libraries loaded on the
+ : interpreter.
+
+ [instance methods]
+ create_slave(name, safe=false)
+ : Create a slave interpreter.
+ : The parent of the interpreter is the receiver of this method.
+ : The name of the slave interpreter is given by 'name' argument.
+ : The 'safe' argument decides whether the slave interpreter is
+ : created as a safe interpreter or not. If true, create a safe
+ : interpreter. Default is false. However, if the parent
+ : interpreter is a safe interpreter, the created interpreter is
+ : a safe interpreter (ignore 'safe' argument value).
+ : If $SAFE >= 4, can create a safe interpreter only.
+
+ make_safe
+ : Make the interpreter to the safe interpreter, and returns
+ : self. If fail, raise RuntimeError.
+
+ safe?
+ : Check whether the interpreter is the safe interpreter.
+ : If is the safe interpreter, returns true.
+
+ allow_ruby_exit?
+ : Return the mode whether 'exit' function of ruby or 'exit'
+ : command of Tcl/Tk can quit the ruby process or not on the
+ : interpreter. If false, such a command quit the interpreter
+ : only.
+ : The default value for a master interpreter is true, and
+ : for a slave interpreter is false.
+
+ allow_ruby_exit=(mode)
+ : Change the mode of 'allow_ruby_exit?'.
+ : If $SAFE >= 4 or the interpreter is a "safe" interpreter,
+ : this is not permitted (raise an exception).
+
+ delete
+ : Delete the interpreter.
+ : The deleted interpreter doesn't accept command and then
+ : raise an exception.
+
+ deleted?
+ : Check whether the interpreter is already deleted.
+ : If deleted, returns true.
+
+ restart
+ : Restart Tk part of the interpreter.
+ : Use this when you need Tk functions after destroying the
+ : root widget.
+ : On $SAFE >= 4, cannot call this method.
+
+ _eval(str)
+ _invoke(*args)
+ : Estimates the arguments as a command on the Tk interpreter.
+ : The argument of _eval is a script of Tcl/Tk.
+ : Each argument of _invoke is a token of one command line of
+ : Tcl/Tk.
+ : Because the operation of _invoke doesn't through the
+ : command line parser of Tk interpreter, the cost of
+ : estimation is smaller than _eval. However, auto_load
+ : mechanism of the Tk interpreter doesn't work on _invoke.
+ : So _invoke can call only the command which already
+ : registered on the interpreter by 'load' command and so on.
+ : On _eval command, auto_load mechanism words. So if succeed
+ : to _eval and regist the command once, after that, the
+ : command can be called by _invoke.
+
+ _toUTF8(str, encoding)
+ _fromUTF8(str, encoding)
+ : Call the function (which is internal function of Tcl/Tk) to
+ : convert to/from a UTF8 string.
+
+ _thread_vwait(var_name)
+ _thread_tkwait(mode, target)
+ : 'vwait' or 'tkwait' with thread support.
+ : The difference from normal 'vwait' or 'tkwait' command is
+ : doing independent wait from the vwait stack when they are
+ : called on the other thread than the eventloop thread.
+ : In the case of Tcl/Tk's vwait / tkwait, if 2nd vwait /
+ : tkwait is called on waiting for 1st vwait / tkwait,
+ : returns the order of [2nd]->[1st] regardless of the order
+ : of when the wait condition was fulfilled.
+ : If _thread_vwait / _thread_tkwait is called on the
+ : eventloop thread, there is no difference from vwait /
+ : tkwait. But if called on the other thread than the
+ : eventloop, stops the thread. And when the wait condition
+ : is fulfilled, the thread restarts. The meaning of
+ : "independent from the vwait stack" is that the timing of
+ : restarting is independent from the waiting status of the
+ : other threads. That is, even if the eventloop thread is
+ : waiting by vwait and is not fulfilled the condition,
+ : _thread_vwait completes the waiting when its waiting
+ : condition is fulfilled and the thread which stopped by
+ : _thread_vwait can continue the operation.
+
+ _return_value
+ : Get the last result value on the interpreter.
+
+ _get_variable(var_name, flag)
+ _get_variable2(var_name, index_name, flag)
+ : Get the current value of a variable. If specified a
+ : index_name (see also the PARSE_VARNAME flag), get the
+ : value of the index_name element.
+
+ _set_variable(var_name, value, flag)
+ _set_variable2(var_name, index_name, value, flag)
+ : Create or modify a variable. If specified a index_name
+ : (see also the PARSE_VARNAME flag), create or modify the
+ : index_name element.
+
+ _unset_variable(var_name)
+ _unset_variable2(var_name, index_name)
+ : Remove a variable. If specified a index_name (see also
+ : the PARSE_VARNAME flag), remove the index_name element.
+
+ _get_global_var(var_name)
+ _get_global_var2(var_name, index_name)
+ _set_global_var(var_name, value)
+ _set_global_var2(var_name, index_name, value)
+ _unset_global_var(var_name)
+ _unset_global_var2(var_name, index_name)
+ : Call the associated method with the flag argument
+ : (GLOBAL_ONLY | LEAVE_ERR_MSG).
+
+ _split_tklist(str)
+ : Split the argument with Tcl/Tk's library function and
+ : get an array as a list of Tcl list elements.
+
+ _merge_tklist(str, str, ... )
+ : Get a Tcl's list string from arguments with a Tcl/Tk's
+ : library function. Each arguemnt is converted to a valid
+ : Tcl list element.
+
+ _conv_listelement(str)
+ : Convert the argument to a valid Tcl list element with
+ : Tcl/Tk's library function.
+
+ mainloop
+ mainloop_watchdog
+ : If on the slave interpreter, never start an eventloop and
+ : returns nil.
+ : With the exception that, same to the TclTkLib module method
+ : with the same name.
+
+ do_one_event
+ : With the exception that the argument is forced to set
+ : DONT_WAIT flag on the slave interpreter, same to
+ : TclTkLib#do_one_event.
+
+ set_eventloop_tick
+ get_eventloop_tick
+ set_no_event_wait
+ get_no_event_wait
+ set_eventloop_weight
+ get_eventloop_weight
+ mainloop_abort_on_exception
+ mainloop_abort_on_exception=
+ : With the exception that it is ignored to set value on the
+ : slave interpreter, same to the TclTkLib module method with
+ : the same name.
+
+class TkCallbackBreak < StandardError
+class TkCallbackContinue < StandardError
+ : They are exception classes to break or continue the Tk callback
+ : operation.
+ : If raise TkCallbackBreak on the callback procedure, Ruby returns
+ : 'break' code to Tk interpreter (Then the Tk interpreter will
+ : break the operation for the current event).
+ : If raise TkCallbackContinue, returns 'continue' code (Then the Tk
+ : interpreter will break the operateion for the current bindtag and
+ : starts the operation for the next buindtag for the current event).
+
+(eof)
diff --git a/ext/tcltklib/MANUAL.euc b/ext/tcltklib/MANUAL.euc
index 789e85a9de..a0d7e42307 100644
--- a/ext/tcltklib/MANUAL.euc
+++ b/ext/tcltklib/MANUAL.euc
@@ -1,4 +1,20 @@
(tof)
+ 2004/03/28 Hidetoshi NAGAI
+
+Ëܥɥ­¥å¥á¥ó¥È¤Ë¤Ï¸Å¤¤ tcltk ¥é¥¤¥Ö¥é¥ê¡¤tcltklib ¥é¥¤¥Ö¥é¥ê¤ÎÀâÌÀ
+¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¤¤½¤Îµ­½ÒÆâÍÆ¤Ï¸Å¤¤¤â¤Î¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥
+
+tcltk ¥é¥¤¥Ö¥é¥ê¡Êtcltk.rb¡Ë¤Ï¸½ºß¤Ç¤Ï¥á¥ó¥Æ¥Ê¥ó¥¹¤¬»ö¼Â¾å¹Ô¤ï¤ì¤Æ
+¤¤¤Ê¤¤¤¿¤á¡¤¸Å¤¤¥É¥­¥å¥á¥ó¥È¤ÎÀâÌÀ¤¬¤½¤Î¤Þ¤ÞÍ­¸ú¤Ç¤¹¡¥¤½¤ì¤ËÂФ·¡¤
+tcltklib ¥é¥¤¥Ö¥é¥ê¤Ë¤Ä¤¤¤Æ¤Ï¡¤¸½ºß¤Î Ruby/Tk¡Êtk.rb °Ê²¼¤Î¥é¥¤¥Ö¥é
+¥ê·²¡Ë¤ò²ÔƯ¤µ¤»¤ë¤¿¤á¤ÎÃæ¿´¤È¤·¤Æ¥á¥ó¥Æ¥Ê¥ó¥¹¤µ¤ì¤Æ¤¤¤ë¤¿¤á¡¤¾¯¡¹
+°ã¤¤¤¬À¸¤¸¤Æ¤¤¤Þ¤¹¡¥
+
+¤½¤³¤Ç¡¤¤Þ¤º¸Å¤¤ÀâÌÀʸ½ñ¤ò¼¨¤·¤¿¸å¡¤¸½ºß¤Î tcltklib ¥é¥¤¥Ö¥é¥ê¤Ë¤Ä
+¤¤¤Æ¤ÎÀâÌÀ¤ò²Ã¤¨¤Þ¤¹¡¥
+
+°Ê²¼¤¬¥é¥¤¥Ö¥é¥ê¤Î¸Å¤¤ÀâÌÀʸ½ñ¤Ç¤¹¡¥
+==============================================================
MANUAL.euc
Sep. 19, 1997 Y. Shigehiro
@@ -121,4 +137,397 @@ require "tcltklib" ¤¹¤ë¤È, °Ê²¼¤Î¥â¥¸¥å¡¼¥ë, ¥¯¥é¥¹¤¬ÍøÍѲÄǽ¤Ç¤¹.
°ú¿ô: ̵¤·
Ìá¤êÃÍ (Fixnum): ľÁ°¤Î Tcl_Eval() ¤¬ÊÖ¤·¤¿ÃÍ.
+==============================================================
+
+°Ê²¼¤¬Ëܥɥ­¥å¥á¥ó¥ÈºîÀ®»þÅÀ¤Ç¤Î tcltklib ¥é¥¤¥Ö¥é¥ê¤ÎÀâÌÀ¤Ç¤¹¡¥
+==============================================================
+¥â¥¸¥å¡¼¥ë TclTkLib
+ : ¸Ä¡¹¤Î Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Ë°Í¸¤·¤Ê¤¤½èÍý ( == ¥¤¥Ù¥ó¥È¥ë¡¼
+ : ¥×¤Ë´Ø¤¹¤ë½èÍý ) ¤ò¸Æ¤Ó½Ð¤¹¥á¥½¥Ã¥É¤òÄêµÁ¤·¤¿¥â¥¸¥å¡¼¥ë¡¥
+
+ ¥â¥¸¥å¡¼¥ë TclTkLib::EventFlag
+ : do_one_event ¤ò¸Æ¤Ó½Ð¤¹ºÝ¤Î½èÍýÂоݥ¤¥Ù¥ó¥È¤ò»ØÄꤹ¤ë¤¿¤á¤Î
+ : ¥Õ¥é¥° ( WINDOW|DONT_WAIT ¤È¤¤¤¦¤è¤¦¤Ë¥Ó¥Ã¥È±é»»»Ò¤ÇÏ¢·ë¤·¤Æ
+ : »ØÄê ) ¤òÄê¿ô¤È¤·¤ÆÄêµÁ¤·¤¿¥â¥¸¥å¡¼¥ë¡¥°Ê²¼¤ÎÄê¿ô¤¬´Þ¤Þ¤ì¤ë¡¥
+
+ Äê¿ô NONE
+ : ÃÍ¤Ï 0 ¤Ç¡¤ÃͤȤ·¤Æ¤Ï¤¤¤«¤Ê¤ë¼ïÎà¤Î¥¤¥Ù¥ó¥È¤â»ØÄꤷ¤Æ¤¤¤Ê¤¤
+ : ¤³¤È¤Ë¤Ê¤ë¤¬¡¤¼ÂºÝ¤Î½èÍý¾å¤Ï ALL ¤ÈƱ¤¸¤È¤·¤Æ°·¤ï¤ì¤ë¡¥
+
+ Äê¿ô WINDOW
+ : window ¥¤¥Ù¥ó¥È¤ò½èÍýÂоݤȤ¹¤ë
+
+ Äê¿ô FILE
+ : file ¥¤¥Ù¥ó¥È¤ò½èÍýÂоݤȤ¹¤ë
+
+ Äê¿ô TIMER
+ : timer ¥¤¥Ù¥ó¥È¤ò½èÍýÂоݤȤ¹¤ë
+
+ Äê¿ô IDLE
+ : ¥¢¥¤¥É¥ë¥ë¡¼¥×½èÍý ( ºÆÉÁ²è¤Ê¤É¡¤Â¾¤Î¼ïÎà¤Î¥¤¥Ù¥ó¥È¤¬È¯À¸
+ : ¤·¤Æ¤¤¤Ê¤¤¤È¤­¤Ë¹Ô¤ï¤ì¤ë½èÍý ) ¤ò½èÍýÂоݤȤ¹¤ë
+
+ Äê¿ô ALL
+ : ¤¹¤Ù¤Æ¤Î¼ïÎà¤Î¥¤¥Ù¥ó¥È¤ò½èÍýÂоݤȤ¹¤ë
+ : WINDOW|FILE|TIMER|IDLE ¤ÈƱ¤¸
+
+ Äê¿ô DONT_WAIT
+ : ½èÍýÂоݥ¤¥Ù¥ó¥È¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ë¡¤¥¤¥Ù¥ó¥ÈȯÀ¸¤òÂÔ¤¿¤º
+ : ¤Ë do_one_event ¤ò½ªÎ» ( false ¤òÊÖ¤¹ ) ¤¹¤ë
+
+ ¥â¥¸¥å¡¼¥ë TclTkLib::VarAccessFlag
+ : _get_variable ¤Ê¤É¤Ç¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¤¿¤á¤Î¤â¤Î¡¥¥Õ¥é¥°¤Ë
+ : ¤Ï°Ê²¼¤ÎÄê¿ô¤ò OR ¤ÇÏ¢·ë¤·¤ÆÍ¿¤¨¤ë¡¥
+
+ Äê¿ô NONE
+ : ÃÍ¤Ï 0 ¤Ç¡¤²¿¤â¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¤Î¤ËÅù¤·¤¤¡¥
+
+ Äê¿ô GLOBAL_ONLY
+ : Ä̾ÊÑ¿ô¤Î¸¡º÷¤Ï¤Þ¤º¼ê³¤­¸Æ¤Ó½Ð¤·¤ò¹Ô¤Ã¤¿¥ì¥Ù¥ë¤Ç¸¡
+ : º÷¤·¡¤¼¡¤Ë¸½ºß¤Î̾Á°¶õ´Ö¤Ç¸¡º÷¡¤ºÇ¸å¤Ë¥°¥í¡¼¥Ð¥ë¶õ´Ö¤Ç
+ : ¸¡º÷¤ò¹Ô¤¦¡¥¤·¤«¤·¡¤¤³¤Î¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¤¥°
+ : ¥í¡¼¥Ð¥ë¶õ´Ö¤Ç¤Î¤ß¸¡º÷¤¹¤ë¡¥
+ : ¤â¤· GLOBAL_ONLY ¤È NAMESPACE_ONLY ¤È¤¬Î¾Êý»ØÄꤵ¤ì¤¿¾ì
+ : ¹ç¤Ë¤Ï¡¤GLOBAL_ONLY ¤Î»ØÄê¤Ï̵»ë¤µ¤ì¤ë¡¥
+
+ Äê¿ô NAMESPACE_ONLY
+ : ¤³¤Î¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¤¸½ºß¤Î̾Á°¶õ´Ö¤Ç¤Î¤ßÊÑ
+ : ¿ô¤Î¸¡º÷¤ò¹Ô¤¦¡¥GLOBAL_ONLY ¤ÎÀâÌÀ¤â»²¾È¤¹¤ë¤³¤È¡¥
+
+ Äê¿ô LEAVE_ERR_MSG
+ : ÊÑ¿ô¥¢¥¯¥»¥¹¤Ë¤ª¤¤¤Æ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¡¤¤³¤Î¥Õ¥é¥°¤¬
+ : »ØÄꤵ¤ì¤Æ¤¤¤ì¤Ð¡¤¼Â¹Ô·ë²Ì¤È¤·¤Æ Tcl ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Ë¥¨
+ : ¥é¡¼¥á¥Ã¥»¡¼¥¸¤¬»Ä¤µ¤ì¤ë¡¥¤³¤Î¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤±
+ : ¤ì¤Ð¡¤¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Ï°ìÀڻĤµ¤ì¤Ê¤¤¡¥
+
+ Äê¿ô APPEND_VALUE
+ : ¤³¤Î¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¡¤ÊÑ¿ô¤ÎÃͤòÃÖ¤­´¹¤¨¤Î¤Ç
+ : ¤Ï¤Ê¤¯¡¤¸½ºß¤ÎÃͤËÂåÆþÃͤ¬Äɲà (append; ʸ»úÎóÏ¢·ë) ¤µ
+ : ¤ì¤ë¡¥ÊÑ¿ô¤¬Ì¤ÄêµÁ¤¢¤Ã¤¿¾ì¹ç¡¤¤³¤Î¥Õ¥é¥°¤Ï̵»ë¤µ¤ì¤ë¡¥
+
+ Äê¿ô LIST_ELEMENT
+ : ¤³¤Î¥Õ¥é¥°¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¡¤ÂåÆþÃͤϤޤº Tcl ¤Î¥ê¥¹
+ : ¥ÈÍ×ÁǤȤ·¤ÆÅ¬ÀڤȤʤë¤è¤¦¤ËÊÑ´¹¤µ¤ì¤ë¡¥ÂåÆþÃͤ¬¥ê¥¹¥È
+ : (¤Þ¤¿¤Ï¥µ¥Ö¥ê¥¹¥È) ¤ÎºÇ½é¤ÎÍ×ÁǤȤʤë¤Î¤Ç¤Ê¤¤¸Â¤ê¡¤ÂåÆþ
+ : ÃͤÎľÁ°¤Ë¤Ï¶õÇòʸ»ú¤¬Äɲ䵤ì¤ë¡¥
+
+ Äê¿ô PARSE_VARNAME
+ : _set_variable ¤Ê¤É¤Î¸Æ¤Ó½Ð¤·¤Ë¤ª¤¤¤Æ¤³¤Î¥Õ¥é¥°¤¬»ØÄꤵ
+ : ¤ì¤Æ¤¤¤¿¾ì¹ç¡¤var_name °ú¿ô¤¬Ï¢ÁÛÇÛÎó̾¤ÈÍ×ÁÇ̾¤È¤òξÊý
+ : ´Þ¤à²ÄǽÀ­¤¬¤¢¤ë (³«¤­³ç¸Ì¤ò´Þ¤ß¡¤ÊĤ¸³ç¸Ì¤Ç½ª¤ï¤ë) ¤³
+ : ¤È¤ò¼¨¤¹¡¥¤½¤Î¾ì¹ç¡¤³ç¸Ì¤Î´Ö¤¬Í×ÁÇ̾»ØÄꡤºÇ½é¤Î³«¤­³ç
+ : ¸Ì¤Þ¤Ç¤¬Ï¢ÁÛÇÛÎó̾¤È¤·¤Æ°·¤ï¤ì¤ë¡¥_set_variable2 ¤Ê¤É¤Ç
+ : ¤³¤Î¥Õ¥é¥°¤ò»ØÄꤹ¤ë¾ì¹ç¡¤Ï¢ÁÛÇÛÎó̾¤ÈÍ×ÁÇ̾¤Ï var_name
+ : ¤«¤éÃê½Ð¤µ¤ì¤ë¤Ï¤º¤Ç¤¢¤ë¤«¤é¡¤index_name °ú¿ô¤Ï nil ¤È
+ : ¤»¤Í¤Ð¤Ê¤é¤Ê¤¤¡¥
+
+ ¥â¥¸¥å¡¼¥ë¥á¥½¥Ã¥É
+ mainloop(check_root = true)
+ : ¥¤¥Ù¥ó¥È¥ë¡¼¥×¤òµ¯Æ°¤¹¤ë¡¥check_root ¤¬ true ¤Ç¤¢¤ì¤Ð¡¤
+ : root widget ¤¬Â¸ºß¤¹¤ë¸Â¤ê¡¤¤³¤Î¥á¥½¥Ã¥É¤Ï½ªÎ»¤·¤Ê¤¤¡¥
+ : check_root ¤¬ false ¤Î¾ì¹ç¤Ï¡¤root widget ¤¬¾ÃÌǤ·¤Æ¤â
+ : ¤³¤Î¥á¥½¥Ã¥É¤Ï½ªÎ»¤·¤Ê¤¤ ( root widget ¤¬¾ÃÌǤ·¤Æ¤â¡¤
+ : WINDOW °Ê³°¤Î¥¤¥Ù¥ó¥È¤ÏȯÀ¸¤·¤¦¤ë¤¿¤á )¡¥½ªÎ»¤Ë¤Ï¡¤³°Éô
+ : ¤«¤é¤ÎƯ¤­³Ý¤± ( ¥¹¥ì¥Ã¥É¤ò³èÍѤ¹¤ë¤Ê¤É ) ¤¬É¬Íס¥
+
+ mainloop_watchdog(check_root = true)
+ : Ä̾ï¤Î¥¤¥Ù¥ó¥È¥ë¡¼¥×¤Ç¤Ï¡¤¥¤¥Ù¥ó¥È½èÍý¤ÎÆâÍÆ¤Ë¤è¤Ã¤Æ¤Ï
+ : ¥Ç¥Ã¥É¥í¥Ã¥¯¤ò°ú¤­µ¯¤³¤¹²ÄǽÀ­¤¬¤¢¤ë (Î㤨¤Ð¥¤¥Ù¥ó¥È¤Ë
+ : ÂФ¹¤ë¥³¡¼¥ë¥Ð¥Ã¥¯½èÍýÃæ¤Ç widget Áàºî¤ò¤·¡¤¤½¤Î½ªÎ»¤ò
+ : ÂԤĤʤÉ)¡¥¤³¤Î¥á¥½¥Ã¥É¤Ï¡¤¤½¤¦¤·¤¿¥Ç¥Ã¥É¥í¥Ã¥¯¤ò²óÈò¤¹
+ : ¤ë¤¿¤á¤Î´Æ»ë¥¹¥ì¥Ã¥ÉÉÕ¤­¤Ç¥¤¥Ù¥ó¥È¥ë¡¼¥×¤òµ¯Æ°¤¹¤ë
+ : ( ´Æ»ë¥¹¥ì¥Ã¥É¤òÀ¸À®¤·¤¿¸å¤Ë¥¤¥Ù¥ó¥È¥ë¡¼¥×¤ò¼Â¹Ô¤¹¤ë )¡¥
+ : °ú¿ô¤Î°ÕÌ£¤Ï mainloop ¤ÈƱ¤¸¤Ç¤¢¤ë¡¥
+
+ do_one_event(flag = TclTkLib::EventFlag::ALL |
+ TclTkLib::EventFlag::DONT_WAIT)
+ : ½èÍýÂÔ¤Á¤Î¥¤¥Ù¥ó¥È 1 ¸Ä¤ò¼Â¹Ô¤¹¤ë¡¥
+ : ¥¤¥Ù¥ó¥È¤ò½èÍý¤·¤¿¾ì¹ç¤Ï true ¤òÊÖ¤¹¡¥
+ : ¥Õ¥é¥°¤Ç DONT_WAIT ¤ò»ØÄꤷ¤Æ¤¤¤Ê¤¤¾ì¹ç¡¤¥Õ¥é¥°¤Ç½èÍýÂÐ
+ : ¾Ý¤È¤Ê¤Ã¤Æ¤¤¤ë¼ïÎà¤Î¥¤¥Ù¥ó¥È¤¬È¯À¸¤¹¤ë¤Þ¤ÇÂÔ¤Á³¤±¤ë¡¥
+ : DONT_WAIT ¤ò»ØÄꤷ¤Æ¤¤¤¿¾ì¹ç¡¤½èÍýÂоݥ¤¥Ù¥ó¥È¤¬¤Ê¤¯¤Æ¤â
+ : ¤¹¤°¤Ë½ªÎ»¤· false ¤òÊÖ¤¹¡¥
+ : $SAFE >= 4 ¤«¡¤$SAFE >= 1 ¤«¤Ä flag ¤¬±øÀ÷¤µ¤ì¤Æ¤¤¤ë¤Ê¤é¤Ð
+ : flag ¤Ë¤Ï DONT_WAIT ¤¬¶¯À©Åª¤ËÉÕ¤±¤é¤ì¤ë¡¥
+
+ set_eventloop_tick(timer_tick)
+ : ¥¤¥Ù¥ó¥È¥ë¡¼¥×¤ÈƱ»þ¤ËÊÌ¥¹¥ì¥Ã¥É¤¬²ÔƯ¤·¤Æ¤¤¤ë¾ì¹ç¤Ë¡¤»þ
+ : ´Ö¤Ë´ð¤Å¤¤¤¿¶¯À©Åª¤Ê¥¹¥ì¥Ã¥É¥¹¥¤¥Ã¥Á¥ó¥°¤ò¤É¤ÎÄøÅÙ¤ÎÉÑÅÙ
+ : ( »þ´Ö´Ö³Ö ) ¤ÇȯÀ¸¤µ¤»¤ë¤«¤ò¥ß¥êÉÃñ°Ì¤ÎÀ°¿ôÃͤǻØÄꤹ¤ë¡¥
+ : 0 ¤ò»ØÄꤹ¤ë¤È¡¤¤³¤Î¶¯À©Åª¤Ê¥¹¥¤¥Ã¥Á¥ó¥°¤Ï¹Ô¤ï¤ì¤Ê¤¤¡¥
+ : ɸ½à¤Ç¤Ï 0 ¤ËÀßÄꤵ¤ì¤Æ¤ª¤ê¡¤¥¤¥Ù¥ó¥È½èÍý¿ô¤Ë´ð¤Å¤¯¥¹¥¤¥Ã
+ : ¥Á¥ó¥°¤À¤±¤¬¹Ô¤ï¤ì¤ë ( see set_eventloop_weight )¡¥
+ : ¤¿¤À¤·¡¤²ÔƯ¤·¤Æ¤¤¤ë¥¹¥ì¥Ã¥É¤¬¥¤¥Ù¥ó¥È¥ë¡¼¥×¤À¤±¤Î¾ì¹ç¡¤
+ : timer_tick ¤ò 0 ¤ËÀßÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡¥¤â¤·ÀßÄꤵ¤ì¤Æ
+ : ¤¤¤¿¤é¡¤100 ms ( see NO_THREAD_INTERRUPT_TIME ) ¤Ë¼«Æ°Àß
+ : Äꤵ¤ì¤ë¡¥
+ : ¾ÜºÙ¤ÊÀâÌÀ¤Ïά¤¹¤¬¡¤¤³¤ì¤Ï CPU ¥Ñ¥ï¡¼¤òÀáÌ󤷤ĤİÂÁ´¤Ç
+ : °ÂÄꤷ¤¿Æ°ºî¤ò¼Â¸½¤¹¤ë¤¿¤á¤Ë¼ÂÁõ¤·¤¿»ÅÍͤǤ¢¤ë¡¥
+ : $SAFE >= 4 ¤Ç¤Ï¼Â¹Ô¤¬¶Ø»ß¤µ¤ì¤ë¡¥
+
+ get_eventloop_tick
+ : timer_tick ¤Î¸½ºßÃͤòÊÖ¤¹¡¥
+
+ set_no_event_wait(no_event_wait)
+ : Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬²ÔƯ¤·¤Æ¤¤¤ë¾ì¹ç¤Ç¡¤½èÍýÂÔ¤Á¥¤¥Ù¥ó¥È¤¬Á´
+ : ¤¯Â¸ºß¤·¤Ê¤«¤Ã¤¿ºÝ¤Ë sleep ¾õÂÖ¤ËÆþ¤ë»þ´ÖŤò»ØÄꤹ¤ë¡¥
+ : ²ÔƯ¥¹¥ì¥Ã¥É¤¬¥¤¥Ù¥ó¥È¥ë¡¼¥×¤À¤±¤Î¾ì¹ç¤Ë¤Ï°ÕÌ£¤ò¤Ê¤µ¤Ê¤¤¡¥
+ : ¥Ç¥Õ¥©¥ë¥È¤ÎÃÍ¤Ï 20 (ms)
+ : $SAFE >= 4 ¤Ç¤Ï¼Â¹Ô¤¬¶Ø»ß¤µ¤ì¤ë¡¥
+
+ get_no_event_wait
+ : no_event_wait ¤Î¸½ºßÃͤòÊÖ¤¹¡¥
+
+ set_eventloop_weight(loop_max, no_event_tick)
+ : Ê£¿ô¤Î¥¹¥ì¥Ã¥É¤¬²ÔƯ¤·¤Æ¤¤¤ëºÝ¤Ë Ruby/Tk ¤Î¥¤¥Ù¥ó¥È¥ë¡¼
+ : ¥×¤Ë³ä¤êÅö¤Æ¤ëÈæ½Å¤òÄê¤á¤ë¤¿¤á¤Î¥Ñ¥é¥á¡¼¥¿¤òÀßÄꤹ¤ë¡¥
+ : ²ÔƯ¥¹¥ì¥Ã¥É¤¬¥¤¥Ù¥ó¥È¥ë¡¼¥×¤À¤±¤Î¾ì¹ç¤Ë¤Ï°ÕÌ£¤ò¤Ê¤µ¤Ê¤¤¡¥
+ : °ìÅ٤Υ¹¥ì¥Ã¥ÉÀÚ¤êÂØ¤¨¤Î´Ö¤Ë½èÍý¤¹¤ë¥¤¥Ù¥ó¥È¤ÎºÇÂç¿ô¤È¡¤
+ : ½èÍýÂÔ¤Á¤Î¥¤¥Ù¥ó¥È¤¬Â¸ºß¤·¤Ê¤¤ºÝ¤Î²Ã»»¿ô¤È¤òÀßÄꤹ¤ë¡¥
+ : ½èÍýÂÔ¤Á¥¤¥Ù¥ó¥È¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï no_event_wait ( see
+ : set_no_event_wait ) ¤À¤±¤Î´Ö sleep ¾õÂÖ¤ËÆþ¤ë¡¥
+ : ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¤½¤ì¤¾¤ì 800 ²ó¤È 10 ²ó¡¤¤Ä¤Þ¤ê¡¤800 ¸Ä¤Î¥¤
+ : ¥Ù¥ó¥È (¥¢¥¤¥É¥ë¥¤¥Ù¥ó¥È¤ò´Þ¤à) ¤ò½èÍý¤¹¤ë¤È¤«¡¤¥¤¥Ù¥ó¥È
+ : ¤¬Á´¤¯È¯À¸¤·¤Ê¤¤¤Þ¤Þ¤Ë 80 ²ó¤Î½èÍýÂÔ¤Á¥¤¥Ù¥ó¥È¸¡ºº¤¬´°Î»
+ : ¤¹¤ë¤È¤«¤Ç¥«¥¦¥ó¥È¤¬ 800 °Ê¾å¤Ë¤Ê¤ë¤È¥¹¥ì¥Ã¥É¥¹¥¤¥Ã¥Á¥ó¥°
+ : ¤¬È¯À¸¤¹¤ë¤³¤È¤Ë¤Ê¤ë¡¥
+ : $SAFE >= 4 ¤Ç¤Ï¼Â¹Ô¤¬¶Ø»ß¤µ¤ì¤ë¡¥
+
+ get_eventloop_weight
+ : ¸½ºß¤Î loop_max ¤È no_event_tick ¤È¤ÎÃͤòÊÖ¤¹¡¥
+ : ( see set_eventloop_wait )
+
+ mainloop_abort_on_exception=(bool)
+ : Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¾å¤ÇÎã³°¤òȯÀ¸¤·¤¿ºÝ¤Ë¡¤¥¤¥Ù¥ó¥È¥ë¡¼¥×¤ò
+ : ¥¨¥é¡¼Ää»ß¤µ¤»¤ë¤«¤É¤¦¤«¤ò»ØÄꤹ¤ë¡¥true ¤ò»ØÄꤷ¤¿¾ì¹ç¤Ï
+ : ¥¨¥é¡¼Ää»ß¤¹¤ë¤¬¡¤false ¤Î¾ì¹ç¤ÏÎã³°¤ò̵»ë¤·¤Æ¥¤¥Ù¥ó¥È¥ë¡¼
+ : ¥×¤ò·Ñ³¤¹¤ë¡¥¤µ¤é¤Ë nil ¤Î¾ì¹ç¤Ï·Ù¹ð¥â¡¼¥É¤Ç¤Ê¤¤¸Â¤ê¤Ï¥¨
+ : ¥é¡¼¥á¥Ã¥»¡¼¥¸¤Î½ÐÎϤ¹¤é¾Êά¤·¤Æ¡¤Îã³°¤ò̵»ë¤¹¤ë¡¥
+ : ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï true ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¡¥
+ : £±¸Ä¤Î¥¤¥ó¥¿¡¼¥×¥ê¥¿¤À¤±¤ò»È¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¥¨¥é¡¼»þ¤Ë¤½¤Î
+ : ¤Þ¤ÞÄä»ß¤·¤Æ¤âÄ̾ï¤ÏÌäÂê¤Ê¤¤¤¬¡¤Ê£¿ô¤Î¥¤¥ó¥¿¡¼¥×¥ê¥¿¤¬Æ±»þ
+ : ¤Ëưºî¤·¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¤¤½¤ì¤é¤ò´ÉÍý¤¹¤ë¥¤¥Ù¥ó¥È¥ë¡¼¥×¤Ï£±
+ : ¸Ä¤À¤±¤Ç¤¢¤ë¤¿¤á¡¤¤¤¤º¤ì¤«¤Î¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Î¥¨¥é¡¼¤¬¸¶°ø¤Ç¡¤
+ : ¾¤Î¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Î½èÍý·Ñ³¤¬ÉÔ²Äǽ¤Ë¤Ê¤ë¤³¤È¤¬¤¢¤ë¡¥¤½¤Î
+ : ¤è¤¦¤Ê¾ì¹ç¤Ç¤â¥¨¥é¡¼¤ò̵»ë¤·¤Æ¥¤¥Ù¥ó¥È¥ë¡¼¥×¤¬²ÔƯ¤ò³¤±¤ë
+ : ¤³¤È¤Ç¡¤Â¾¤Î¥¤¥ó¥¿¡¼¥×¥ê¥¿¤¬Àµ¾ï¤Ëưºî¤·Â³¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡¥
+ : $SAFE >= 4 ¤Ç¤Ï¼Â¹Ô¤¬¶Ø»ß¤µ¤ì¤ë¡¥
+
+ mainloop_abort_on_exception
+ : Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¾å¤ÇÎã³°¤òȯÀ¸¤·¤¿ºÝ¤Ë¡¤¥¤¥Ù¥ó¥È¥ë¡¼¥×¤ò¥¨
+ : ¥é¡¼Ää»ß¤µ¤»¤ë¤«¤É¤¦¤«¤ÎÀßÄê¾õÂÖ¤ò true/false ¤ÇÆÀ¤ë¡¥
+
+ num_of_mainwindows
+ : ¸½ºß¤Î¥á¥¤¥ó¥¦¥£¥ó¥É¥¦ (¥ë¡¼¥È¥¦¥£¥¸¥§¥Ã¥È) ¤Î¿ô¤òÊÖ¤¹¡¥
+ : ¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤Ï°ì¤Ä¤Î¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ËÉÕ¤­ºÇÂç°ì¤Ä¤Ç¤¢¤ë
+ : ¤Î¤Ç¡¤¤³¤ÎÃͤϸ½ºß Tk ¤Îµ¡Ç½¤¬Í­¸ú¤Ç¤¢¤ë¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ÎÁí
+ : ¿ô¤ËÅù¤·¤¤¡¥
+
+ _merge_tklist(str, str, ... )
+ : Tcl/Tk ¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ò»È¤Ã¤Æ¡¤°ú¿ô¤Îʸ»úÎ󤬤½¤ì¤¾¤ì
+ : Àµ¤·¤¯°ì¤Ä¤Î¥ê¥¹¥ÈÍ×ÁǤȤʤë¤è¤¦¤ËÏ¢·ë¤·¤¿Ê¸»úÎó¤òÊÖ¤¹¡¥
+
+ _conv_listelement(str)
+ : Tcl/Tk ¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ò»È¤Ã¤Æ¡¤°ú¿ô¤Îʸ»úÎó¤¬ Tcl ¤Î
+ : °ì¤Ä¤Î¥ê¥¹¥ÈÍ×ÁǤȤ·¤ÆÅ¬ÀÚ¤Êɽ¸½¤Ë¤Ê¤ë¤è¤¦¤ËÊÑ´¹¤·¤¿Ê¸
+ : »úÎó¤òÊÖ¤¹¡¥
+
+ _toUTF8(str, encoding)
+ _fromUTF8(str, encoding)
+ : Tcl/Tk ¤¬Æâ¢¤·¤Æ¤¤¤ë UTF8 ÊÑ´¹½èÍý¤ò¸Æ¤Ó½Ð¤¹¡¥
+
+ _subst_UTF_backslash(str)
+ _subst_Tcl_backslash(str)
+ : Tcl ¤Î¥ë¡¼¥ë¤Ç¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥åµ­Ë¡ ( \uhhhh ¤Ë¤è¤ë
+ : Unicode ʸ»úɽ¸½¤ò´Þ¤à ) ¤ò²òÀϤ¹¤ë¡¥
+ : _subst_Tcl_backslash ¤Ï¤¹¤Ù¤Æ¤Î¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥åµ­Ë¡¤ò
+ : ÃÖ¤­´¹¤¨¤ë¤Î¤ËÂФ·¡¤_subst_UTF_backslash ¤Ï \uhhhh
+ : ¤Ë¤è¤ë Unicode ʸ»úɽ¸½¤À¤±¤òÃÖ¤­´¹¤¨¤ë¡¥
+
+¥¯¥é¥¹ TclTkIp
+ ¥¯¥é¥¹¥á¥½¥Ã¥É
+ new(ip_name=nil, options='')
+ : TclTkIp ¥¯¥é¥¹¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÀ¸À®¤¹¤ë¡¥
+ : ip_name ¤Ëʸ»úÎó¤òÍ¿¤¨¤¿¾ì¹ç¤Ï¡¤¤½¤ì¤¬ winfo interps ¤Ê¤É¤Ç
+ : ɽ¼¨¤µ¤ì¤ë̾Á°¤Ë¤Ê¤ë¡¥
+ : options ¤Ë¤Ï¡¤-geometry ¤ä -use ¤Ê¤É¡¤wish ¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó
+ : °ú¿ô¤È¤·¤ÆÍ¿¤¨¤ë¥ª¥×¥·¥ç¥ó¤ÈƱÍͤξðÊó¤òʸ»úÎó¤È¤·¤ÆÍ¿¤¨¤ë¡¥
+ : Í¿¤¨¤é¤ì¤¿¾ðÊó¤Ï¡¤root widget À¸À®¤ÎºÝ¤ËÍѤ¤¤é¤ì¤ë¡¥
+ : ( e.g. TclTkIp.new('FOO', '-geometry 500x200 -use 0x2200009') )
+ : ¤â¤· options ¤Ë´º¤¨¤Æ nil ¤Þ¤¿¤Ï false ¤òÍ¿¤¨¤¿¾ì¹ç¡¤Tk ¥é¥¤
+ : ¥Ö¥é¥ê¤¬Æ³Æþ¤µ¤ì¤Æ¤¤¤Ê¤¤ (¤Ä¤Þ¤ê¤Ï Tcl ¤Î¤ß¤Î) ¥¤¥ó¥¿¡¼¥×¥ê
+ : ¥¿¤òÀ¸À®¤¹¤ë¡¥¤³¤Î¾ì¹ç¤Ï GUI ´Ä¶­¤ÏɬÍפʤ¤¤¿¤á¡¤¥¦¥¤¥ó¥É¥¦
+ : ¥·¥¹¥Æ¥à¤¬Â¸ºß¤·¤Ê¤¤¡¤¤Þ¤¿¤Ï»ÈÍѤǤ­¤Ê¤¤´Ä¶­¤Ç¤â Tcl ¥¤¥ó¥¿¡¼
+ : ¥×¥ê¥¿¤òÀ¸À®¤·¡¤Tcl ¤ä¤½¤Î³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤ò³èÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡¥
+
+ ¥¤¥ó¥¹¥¿¥ó¥¹¥á¥½¥Ã¥É
+ create_slave(name, safe=false)
+ : ¥ì¥·¡¼¥Ð¤ò¿Æ¤È¤¹¤ë name ¤È¤¤¤¦Ì¾Á°¤Î¥¹¥ì¡¼¥Ö¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ò
+ : À¸À®¤¹¤ë¡¥
+ : safe ¤Ë¤ÏÀ¸À®¤¹¤ë¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ò safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤È¤¹¤ë
+ : ¤«¤ò»ØÄꤹ¤ë¡¥¥Ç¥Õ¥©¥ë¥È¤Ï false ¤È¤¤¤¦¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤¬¡¤
+ : ¤¿¤È¤¨ÌÀ³Î¤Ë false ¤ò»ØÄꤷ¤Æ¤¤¤¿¤È¤·¤Æ¤â¡¤¿Æ¤È¤Ê¤ë¥¤¥ó¥¿¡¼
+ : ¥×¥ê¥¿¤¬ safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Ç¤¢¤ì¤Ð¡¤¤½¤ÎÀßÄê¤ò°ú¤­·Ñ¤¤¤Ç
+ : safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤È¤·¤ÆÀ¸À®¤µ¤ì¤ë¡¥
+ : $SAFE >= 4 ¤Ç¤Ï¡¤safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿°Ê³°¤ÎÀ¸À®¤¬¶Ø»ß¤µ¤ì¤ë¡¥
+
+ make_safe
+ : Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ò safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ËÊѹ¹¤¹¤ë¡¥
+ : Ìá¤êÃͤϥ쥷¡¼¥Ð¤Ç¤¢¤ë¥¤¥ó¥¿¡¼¥×¥ê¥¿¼«¿È¤Ç¤¢¤ë¡¥
+ : ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï RuntimeError ¤ÎÎã³°¤òȯÀ¸¤¹¤ë¡¥
+
+ safe?
+ : Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ò safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Ç¤¢¤ë¤«¤òÄ´¤Ù¤ë¡¥
+ : safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Ç¤¢¤ì¤Ð true ¤òÊÖ¤¹¡¥
+
+ allow_ruby_exit?
+ : ÂоݤȤʤ륤¥ó¥¿¡¼¥×¥ê¥¿¾å¤Îɾ²Á¤Ç¡¤ruby ¤Î exit ´Ø¿ô¤Þ¤¿¤Ï
+ : Tcl/Tk ¾å¤Î exit ¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤Æ ruby ¼«ÂΤò½ªÎ»¤µ¤»¤ë¤³¤È
+ : ¤òµö¤¹¤«¤É¤¦¤«¤òÊÖ¤¹¡¥
+ : µö¤µ¤Ê¤¤¾ì¹ç¤ÏÂоݤΥ¤¥ó¥¿¡¼¥×¥ê¥¿¤À¤±¤¬½ªÎ»¤¹¤ë¡¥
+ : ¥Þ¥¹¥¿¡¼¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Î¥Ç¥Õ¥©¥ë¥ÈÃÍ¤Ï true¡¤¥¹¥ì¡¼¥Ö¥¤¥ó¥¿¡¼
+ : ¥×¥ê¥¿¤Î¥Ç¥Õ¥©¥ë¥ÈÃÍ¤Ï false ¤Ç¤¢¤ë¡¥
+
+ allow_ruby_exit=(mode)
+ : ÂоݤȤʤ륤¥ó¥¿¡¼¥×¥ê¥¿¤Î allow_ruby_exit? ¤Î¾õÂÖ¤òÊѹ¹¤¹¤ë¡¥
+ : $SAFE >= 4 ¤Þ¤¿¤Ï¥¤¥ó¥¿¡¼¥×¥ê¥¿¤¬ safe ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Î¾ì¹ç¤Ï
+ : Êѹ¹¤¬µö¤µ¤ì¤Ê¤¤ (Îã³°¤òȯÀ¸)¡¥
+
+ delete
+ : Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤ò delete ¤¹¤ë¡¥
+ : delete ¤µ¤ì¤¿¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Ï¡¤°Ê¸å°ìÀÚ¤ÎÁàºî¤¬¤Ç¤­¤Ê¤¯¤Ê¤ê¡¤
+ : ¥³¥Þ¥ó¥É¤òÁ÷¤Ã¤Æ¤âÎã³°¤òȯÀ¸¤¹¤ë¤è¤¦¤Ë¤Ê¤ë¡¥
+
+ deleted?
+ : Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤¬¤¹¤Ç¤Ë delete ¤µ¤ì¤Æ¤¤¤ë¤«¤òÄ´¤Ù¤ë¡¥
+ : delete ºÑ¤ß¤Ç¥³¥Þ¥ó¥É¤ò¼õ¤±ÉÕ¤±¤Ê¤¤¾õÂ֤ˤʤäƤ¤¤ë¤Ê¤é¤Ð
+ : true ¤òÊÖ¤¹¡¥
+
+ restart
+ : Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Î Tk Éôʬ¤Î½é´ü²½¡¤ºÆµ¯Æ°¤ò¹Ô¤¦¡¥
+ : °ìö root widget ¤òÇ˲õ¤·¤¿¸å¤ËºÆÅÙ Tk ¤Îµ¡Ç½¤¬É¬ÍפÈ
+ : ¤Ê¤Ã¤¿¾ì¹ç¤ËÍѤ¤¤ë¡¥
+ : $SAFE >= 4 ¤Ç¤Ï¼Â¹Ô¤¬¶Ø»ß¤µ¤ì¤ë¡¥
+
+ _eval(str)
+ _invoke(*args)
+ : Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¾å¤Çɾ²Á¤ò¹Ô¤¦¡¥
+ : _eval ¤Ïɾ²Á¥¹¥¯¥ê¥×¥È¤¬°ì¤Ä¤Îʸ»úÎó¤Ç¤¢¤ë¤³¤È¤ËÂФ·¡¤
+ : _invoke ¤Ïɾ²Á¥¹¥¯¥ê¥×¥È¤Î token ¤´¤È¤Ë°ì¤Ä¤Î°ú¿ô¤È¤Ê
+ : ¤ë¤è¤¦¤ËÍ¿¤¨¤ë¡¥
+ : _invoke ¤ÎÊý¤Ï Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Î»ú¶ç²òÀÏ´ï¤òÍѤ¤
+ : ¤Ê¤¤¤¿¤á¡¤É¾²Á¤ÎÉé²Ù¤¬¤è¤ê¾¯¤Ê¤¯¤Æ¤¹¤à¡¥¤¿¤À¤·¡¤¤½¤ÎÂå
+ : ¤ï¤ê¤Ë auto_load ¤Î¤è¤¦¤Êµ¡¹½¤ÏƯ¤«¤º¡¤load Åù¤Ë¤è¤Ã¤Æ
+ : Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿¾å¤Ë´û¤ËÅÐÏ¿ºÑ¤ß¤Î¥³¥Þ¥ó¥É¤·¤«¸Æ
+ : ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Ê¤¤¡¥
+ : _eval ¤Ç¤Ï auto_load µ¡¹½¤¬Æ¯¤¯¤¿¤á¡¤°ìÅÙ _eval ¤ò¼Â¹Ô
+ : ¤·¤ÆÅÐÏ¿¤ËÀ®¸ù¤·¤µ¤¨¤¹¤ì¤Ð¡¤°Ê¹ß¤Ï _invoke ¤Ç¤âÍøÍѤÇ
+ : ¤­¤ë¤è¤¦¤Ë¤Ê¤ë¡¥
+
+ _toUTF8(str, encoding)
+ _fromUTF8(str, encoding)
+ : Tcl/Tk ¤¬Æâ¢¤·¤Æ¤¤¤ë UTF8 ÊÑ´¹½èÍý¤ò¸Æ¤Ó½Ð¤¹¡¥
+
+ _thread_vwait(var_name)
+ _thread_tkwait(mode, target)
+ : ¥¹¥ì¥Ã¥ÉÂбþ¤Î vwait ¤¢¤ë¤¤¤Ï tkwait ÁêÅö¤Î¥á¥½¥Ã¥É¡¥
+ : Ä̾ï¤Î vwait ¤¢¤ë¤¤¤Ï tkwait ¥³¥Þ¥ó¥É¤È°Û¤Ê¤ë¤Î¤Ï¡¤¥¤¥Ù¥ó
+ : ¥È¥ë¡¼¥×¤È¤Ï°Û¤Ê¤ë¥¹¥ì¥Ã¥É¤«¤é¸Æ¤Ó½Ð¤·¤¿¾ì¹ç¤Ë vwait Åù¤Î
+ : ¥¹¥¿¥Ã¥¯¤È¤ÏÆÈΩ¤Ë¾ò·ï¤ÎÀ®Î©ÂÔ¤Á¤¬¤Ê¤µ¤ì¤ë¤³¤È¤Ç¤¢¤ë¡¥
+ : Ä̾ï¤Î vwait / tkwait ¤Ç¤Ï¡¤vwait / tkwait (1) ¤ÎÂÔ¤Á¤ÎÅÓ
+ : Ãæ¤Ç¤µ¤é¤Ë vwait / tkwait (2) ¤¬¸Æ¤Ð¤ì¤¿¾ì¹ç¡¤ÂÔ¤Á¤ÎÂоÝ
+ : ¤È¤Ê¤Ã¤Æ¤¤¤ë¾ò·ï¤ÎÀ®Î©½ç½ø¤¬¤É¤¦¤¢¤ì¡¤(2)->(1) ¤Î½ç¤ÇÂÔ¤Á
+ : ¤ò½ªÎ»¤·¤ÆÌá¤Ã¤Æ¤¯¤ë¡¥
+ : _thread_vwait / _thread_tkwait ¤Ï¡¤¥¤¥Ù¥ó¥È¥ë¡¼¥×¤Î¥¹¥ì¥Ã
+ : ¥É¤Ç¸Æ¤Ð¤ì¤¿¾ì¹ç¤ÏÄ̾ï¤Î vwait / tkwait ¤ÈƱÍÍ¤ËÆ°ºî¤¹¤ë
+ : ¤¬¡¤¥¤¥Ù¥ó¥È¥ë¡¼¥×°Ê³°¤Î¥¹¥ì¥Ã¥É¤Ç¸Æ¤Ð¤ì¤¿¾ì¹ç¤Ë¤Ï¤½¤Î¥¹
+ : ¥ì¥Ã¥É¤òÄä»ß¤µ¤»¤ÆÂÔ¤Á¤ËÆþ¤ê¡¤¾ò·ï¤¬À®Î©¤·¤¿»þ¤Ë¥¹¥ì¥Ã¥É
+ : ¤Î¼Â¹Ô¤òºÆ³«¤¹¤ë¡¥¡Övwait Åù¤ÎÂÔ¤Á¥¹¥¿¥Ã¥¯¤È¤ÏÆÈΩ¡×¤È¤¤
+ : ¤¦°ÕÌ£¤Ï¡¤¤³¤ÎºÆ³«¤Î¥¿¥¤¥ß¥ó¥°¤¬Â¾¤Î¥¹¥ì¥Ã¥É¤Ç¤ÎÂÔ¤Á¾õ¶·
+ : ¤È¤Ï̵´Ø·¸¤È¤¤¤¦¤³¤È¤Ç¤¢¤ë¡¥¤Ä¤Þ¤ê¡¤¥¤¥Ù¥ó¥È¥ë¡¼¥×Åù¤Î¾
+ : ¤Î¥¹¥ì¥Ã¥É¤Ç vwait Åù¤ÇÂÔ¤Á¤Î¾õÂ֤ˤ¢¤Ã¤¿¤È¤·¤Æ¤â¤½¤Î´°Î»
+ : ¤òÂԤĤ³¤È¤Ê¤¯¡¤¼«¤é¤ÎÂÔ¤Á¾ò·ï¤¬À®Î©¼¡Â衤½èÍý¤ò·Ñ³¤¹¤ë
+ : ¤³¤È¤Ë¤Ê¤ë¡¥
+
+ _return_value
+ : ľÁ°¤Î Tcl/Tk ¾å¤Ç¤Îɾ²Á¤Î¼Â¹Ô·ë²Ì¤È¤·¤Æ¤ÎÌá¤êÃͤòÊÖ¤¹¡¥
+
+ _get_variable(var_name, flag)
+ _get_variable2(var_name, index_name, flag)
+ : Tcl/Tk ¾å¤Î var ¤È¤¤¤¦ÊÑ¿ô̾¤ÎÊÑ¿ô¤ÎÃͤòÊÖ¤¹¡¥
+ : ¤â¤· index_name ¤¬»ØÄê (PARSE_VARNAME ¥Õ¥é¥°¤ÎÀâÌÀ¤â»²¾È)
+ : ¤µ¤ì¤¿¾ì¹ç¤ÏÏ¢ÁÛÇÛÎó var_name ¤Î index_name ¤ÎÍ×ÁǤòÊÖ¤¹¡¥
+ : flag ¤Ë¤ÏÊÑ¿ô¤ò¸¡º÷¤¹¤ëºÝ¤Î¾ò·ï¤ò»ØÄꤹ¤ë¡¥flag ¤ËÍ¿¤¨¤ë
+ : Ãͤϥ⥸¥å¡¼¥ë TclTkLib::VarAccessFlag ¤ò»²¾È¤¹¤ë¤³¤È¡¥
+
+ _set_variable(var_name, value, flag)
+ _set_variable2(var_name, index_name, value, flag)
+ : Tcl/Tk ¾å¤Î var ¤È¤¤¤¦ÊÑ¿ô̾¤ÎÊÑ¿ô¤ËÃͤòÀßÄꤹ¤ë¡¥
+ : ¤â¤· index_name ¤¬»ØÄê (PARSE_VARNAME ¥Õ¥é¥°¤ÎÀâÌÀ¤â»²¾È)
+ : ¤µ¤ì¤¿¾ì¹ç¤ÏÏ¢ÁÛÇÛÎó var_name ¤Î index_name ¤ÎÍ×ÁǤòÀßÄê
+ : ¤¹¤ë¡¥
+ : flag ¤Ë¤ÏÊÑ¿ô¤ò¸¡º÷¤¹¤ëºÝ¤Î¾ò·ï¤ò»ØÄꤹ¤ë¡¥flag ¤ËÍ¿¤¨¤ë
+ : Ãͤϥ⥸¥å¡¼¥ë TclTkLib::VarAccessFlag ¤ò»²¾È¤¹¤ë¤³¤È¡¥
+
+ _unset_variable(var_name)
+ _unset_variable2(var_name, index_name)
+ : Tcl/Tk ¾å¤Î var_name ¤È¤¤¤¦ÊÑ¿ô̾¤ÎÊÑ¿ô¤ò¾Ãµî¤¹¤ë¡¥
+ : ¤â¤· index_name ¤¬»ØÄê (PARSE_VARNAME ¥Õ¥é¥°¤ÎÀâÌÀ¤â»²¾È)
+ : ¤µ¤ì¤¿¾ì¹ç¤ÏÏ¢ÁÛÇÛÎó var_name ¤«¤é index_name ¤ÎÍ×ÁǤÀ¤±
+ : ¤ò¾Ãµî¤¹¤ë¡¥
+
+ _get_global_var(var_name)
+ _get_global_var2(var_name, index_name)
+ _set_global_var(var_name, value)
+ _set_global_var2(var_name, index_name, value)
+ _unset_global_var(var_name)
+ _unset_global_var2(var_name, index_name)
+ : ¤½¤ì¤¾¤ì¡¤Âбþ¤¹¤ëÊÑ¿ô¥¢¥¯¥»¥¹¥á¥½¥Ã¥É¤Î flag ¤ËÂФ·¤Æ
+ : (GLOBAL_ONLY | LEAVE_ERR_MSG) ¤òÍ¿¤¨¤¿¤â¤Î¡¥
+
+ _split_tklist(str)
+ : Tcl/Tk ¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ò»È¤Ã¤Æ¡¤Ê¸»úÎó str ¤ò¥ê¥¹¥È¤Ë
+ : ʬ³ä¤¹¤ë (ʸ»úÎó¤ÎÇÛÎó¤È¤·¤ÆÊÖ¤¹)¡¥
+
+ _merge_tklist(str, str, ... )
+ : Tcl/Tk ¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ò»È¤Ã¤Æ¡¤°ú¿ô¤Îʸ»úÎ󤬤½¤ì¤¾¤ì
+ : Àµ¤·¤¯°ì¤Ä¤Î¥ê¥¹¥ÈÍ×ÁǤȤʤë¤è¤¦¤ËÏ¢·ë¤·¤¿Ê¸»úÎó¤òÊÖ¤¹¡¥
+
+ _conv_listelement(str)
+ : Tcl/Tk ¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ò»È¤Ã¤Æ¡¤°ú¿ô¤Îʸ»úÎó¤¬ Tcl ¤Î
+ : °ì¤Ä¤Î¥ê¥¹¥ÈÍ×ÁǤȤ·¤ÆÅ¬ÀÚ¤Êɽ¸½¤Ë¤Ê¤ë¤è¤¦¤ËÊÑ´¹¤·¤¿Ê¸
+ : »úÎó¤òÊÖ¤¹¡¥
+
+ mainloop
+ mainloop_watchdog
+ : ¥¹¥ì¡¼¥Ö IP ¤Î¾ì¹ç¤Ë¤Ï¥¤¥Ù¥ó¥È¥ë¡¼¥×¤òµ¯Æ°¤»¤º¤Ë nil ¤òÊÖ¤¹¡¥
+ : ¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï°ú¿ô¤ò´Þ¤á¤Æ TclTkLib ¤ÎƱ̾¥á¥½¥Ã¥É¤ËƱ¤¸¡¥
+
+ do_one_event
+ : ¥¹¥ì¡¼¥Ö IP ¤Î¾ì¹ç¤Ë¤Ï°ú¿ô¤Î¥¤¥Ù¥ó¥È¥Õ¥é¥°¤Ë DONT_WAIT ¤¬
+ : ¶¯À©Åª¤ËÄɲ䵤ì¤ë (¥¤¥Ù¥ó¥ÈÂÔ¤Á¤Ç¥¹¥ê¡¼¥×¤¹¤ë¤³¤È¤Ï¶Ø»ß)¡¥
+ : ¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï°ú¿ô¤ò´Þ¤á¤Æ TclTkLib ¤ÎƱ̾¥á¥½¥Ã¥É¤ËƱ¤¸¡¥
+
+ set_eventloop_tick
+ get_eventloop_tick
+ set_no_event_wait
+ get_no_event_wait
+ set_eventloop_weight
+ get_eventloop_weight
+ mainloop_abort_on_exception
+ mainloop_abort_on_exception=
+ : ¥¹¥ì¡¼¥Ö IP ¤Î¾ì¹ç¤Ë¤ÏÃͤÎÀßÄ꤬µö¤µ¤ì¤Ê¤¤ (̵»ë¤µ¤ì¤ë)¡¥
+ : ¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï°ú¿ô¤ò´Þ¤á¤Æ TclTkLib ¤ÎƱ̾¥á¥½¥Ã¥É¤ËƱ¤¸¡¥
+
+¥¯¥é¥¹ TkCallbackBreak < StandardError
+¥¯¥é¥¹ TkCallbackContinue < StandardError
+ : ¤³¤ì¤é¤Ï¥¤¥Ù¥ó¥È¥³¡¼¥ë¥Ð¥Ã¥¯¤Ë¤ª¤¤¤Æ¡¤¥³¡¼¥ë¥Ð¥Ã¥¯½èÍý¤òŬÀÚ¤ËÃæ
+ : ÃǤ·¤¿¤ê¡¤¼¡¤Î¥Ð¥¤¥ó¥É¥¿¥°¤Î¥Ð¥¤¥ó¥Ç¥£¥ó¥°½èÍý¤Ë¿Ê¤á¤¿¤ê¤¹¤ë¤³¤È
+ : ¤ò²Äǽ¤Ë¤¹¤ë¤¿¤á¤ÎÎã³°¥¯¥é¥¹¤Ç¤¢¤ë¡¥
+ : ¥³¡¼¥ë¥Ð¥Ã¥¯¤Ç break ¤ä continue ¤ò¼Â¸½¤¹¤ë¤¿¤á¤Ë¤Ï¡¤¥³¡¼¥ë¥Ð¥Ã¥¯
+ : ¤Ç¤¢¤ë Ruby ¼ê³¤­¤¬ Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿Â¦¤ËŬÀڤʥ꥿¡¼¥ó¥³¡¼
+ : ¥É¤òÊÖ¤¹É¬Íפ¬¤¢¤ë¡¥Ruby ¤Î¼ê³¤­¤¬ÉáÄ̤ËÃͤòÊÖ¤¹¤Î¤Ç¤Ï¡¤¤½¤ì¤¬Éá
+ : Ä̤ÎÌá¤êÃͤǤ¢¤ë¤Î¤«Èݤ«¤ò¶èÊ̤¬¤Ç¤­¤Ê¤¤¤¿¤á¡¤Î㳰ȯÀ¸¤òÍøÍѤ·¤¿
+ : ¼ÂÁõ¤ò¹Ô¤Ã¤Æ¤¤¤ë¡¥
+
(eof)
diff --git a/ext/tcltklib/README.1st b/ext/tcltklib/README.1st
new file mode 100644
index 0000000000..4d5cd93283
--- /dev/null
+++ b/ext/tcltklib/README.1st
@@ -0,0 +1,55 @@
+To compile 'tcltklib', you must have Tcl/Tk libraries on your environment.
+Although 'extconf.rb' script searches Tcl/Tk libraries and header files,
+sometimes fails to find them. And then, 'tcltklib' cannot be compiled. If
+Tcl/Tk libraries or header files are installed but are not found, you can
+give the information by arguments of the 'configure' script. Please give
+some or all of the following options.
+
+ --with-tcllib=<libname> (e.g. libtcl8.4.so ==> --with-tcllib=tcl8.4)
+ --with-tklib=<libname> (e.g. libtk8.4.so ==> --with-tklib=tk8.4)
+
+ --enable-tcltk_stubs (if you force to enable stubs)
+
+ --with-tcl-dir=<path>
+ equal to "--with-tcl-include=<path>/include --with-tcl-lib=<path>/lib"
+
+ --with-tk-dir=<path>
+ equal to "--with-tk-include=<path>/include --with-tk-lib=<path>/lib"
+
+ --with-tcl-include=<dir> the directry containts 'tcl.h'
+ --with-tk-include=<dir> the directry containts 'tk.h'
+
+ --with-tcl-lib=<dir> the directry containts 'libtcl<version>.so'
+ --with-tk-lib=<dir> the directry containts 'libtk<version>.so'
+
+ --enable-mac-tcltk-framework (Mac OSX only) use Tcl/Tk framework
+
+If you forgot to give the options when do 'configure' on toplevel
+directry of Ruby sources, please try something like as the followings.
+
+ $ cd ext/tcltklib
+ $ rm Makefile
+ $ CONFIGURE_ARGS='--with-tcl-include=/usr/local/include/tcl8.4/ --with-tcllib=tcl8.4 --with-tklib=tk8.4' ruby extconf.rb
+
+
+ *** ATTENTION ***
+When your Tcl/Tk libraries are compiled with "pthread support",
+Ruby/Tk may cause "Hang-up" or "Segmentation Fault" frequently.
+If you have such a trouble, please try to use the '--enable-pthread'
+option of the 'configure' command and re-compile Ruby sources.
+It may help you to avoid this trouble. The following configure
+options may be useful.
+
+ --enable-tcl-thread/--disable-tcl-thread
+ --with-tclConfig-file=<path of 'tclConfig.sh'>
+
+It is not need that 'tclConfig.sh' is a normal Tcl/Tk's tclConfig.sh.
+But the file is expected to include the line "TCL_THREADS=0" or "...=1".
+When no "TCL_THREADS=?" line, if Tcl version is 7.x or 8.0 which is
+given by "TCL_MAJOR_VERSION=?" line and "TCL_MINOR_VERSION=?" line,
+then --disable-tcl-thread is expected. Else, ignore the 'tclConfig.sh'.
+If --enable-tcl-thread or --disable-tcl-thread option is given, then
+--with-tclConfig-file option is ignored.
+
+==========================================================
+ Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/ext/tcltklib/README.ActiveTcl b/ext/tcltklib/README.ActiveTcl
new file mode 100644
index 0000000000..3afb3f4cf6
--- /dev/null
+++ b/ext/tcltklib/README.ActiveTcl
@@ -0,0 +1,49 @@
+ActiveTcl is ActiveState's quality-assured distribution of Tcl.
+
+# see <http://www.activestate.com/Products/ActiveTcl/>
+# <http://www.tcl.tk/>
+
+If you want to use ActiveTcl binary package as the Tcl/Tk libraries,
+please use the following configure options.
+
+ --with-tcl-dir=<ActiveTcl_root>
+ --with-tk-dir=<ActiveTcl_root>
+
+And use the followings if you need.
+
+ --with-tcllib=<libname>
+ --with-tklib=<libname>
+ --enable-tcltk-stubs
+
+For example, when you install ActiveTcl-8.4.x to '/usr/local/ActiveTcl',
+
+ configure --with-tcl-dir=/usr/local/ActiveTcl/ \
+ --with-tk-dir=/usr/local/ActiveTcl/ \
+ --with-tcllib=tclstub8.4 \
+ --with-tklib=tkstub8.4 \
+ --enable-tcltk-stubs
+
+It depends on your environment that you have to add the directory of
+ActiveTcl's libraries to your library path when execute Ruby/Tk.
+One of the way is to add entries to TCLLIBPATH environment variable,
+and one of the others add to LD_LIBRARY_PATH environment variable
+
+Probably, using TCLLIBPATH is better. The value is appended at the
+head of Tcl's 'auto_path' variable. You can see the value of the
+variable by using 'Tk::AUTO_PATH.value' or 'Tk::AUTO_PATH.list'.
+
+For example, on Linux, one of the ways is to use LD_LIBRARY_PATH
+environment variable.
+-------------------------------------------------------------------------
+ [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH \
+ ruby your-Ruby/Tk-script
+
+ [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH irb
+-------------------------------------------------------------------------
+Based on it, the Tcl interpreter changes auto_path variable's value.
+
+Then, you'll be able to use Tcl/Tk extension libraries included in the
+ActiveTcl package (e.g. call TkPackage.require('BWidget'), and then,
+use functions/widgets of BWidget extention).
+
+ Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/ext/tcltklib/README.euc b/ext/tcltklib/README.euc
index 290ffb0b60..fd75202c18 100644
--- a/ext/tcltklib/README.euc
+++ b/ext/tcltklib/README.euc
@@ -1,4 +1,30 @@
(tof)
+ 2003/06/19 Hidetoshi NAGAI
+
+Ëܥɥ­¥å¥á¥ó¥È¤Ë¤Ï¸Å¤¤ tcltk ¥é¥¤¥Ö¥é¥ê¡¤tcltklib ¥é¥¤¥Ö¥é¥ê¤ÎÀâÌÀ
+¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¤¤½¤Îµ­½ÒÆâÍÆ¤Ï¸Å¤¤¤â¤Î¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥
+
+¤Þ¤º¡¤¸½ºß¤Î Ruby/Tk ¤ÎÃæ¿´¤Ç¤¢¤ë tk.rb ¤Ï wish ¤ò¸Æ¤Ó½Ð¤·¤¿¤ê¤Ï¤»
+¤º¡¤tcltklib ¥é¥¤¥Ö¥é¥ê¤ò wrap ¤·¤ÆÆ°ºî¤¹¤ë¤â¤Î¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥¤½¤Î
+¤¿¤á¡¤¸Å¤¤ÀâÌÀµ­½Ò¤Ç½Ò¤Ù¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Ê¥×¥í¥»¥¹´ÖÄÌ¿®¤Ë¤è¤ë¥ª¡¼¥Ð
+¥Ø¥Ã¥É¤Ï¸ºß¤·¤Þ¤»¤ó¡¥
+
+¸½ºß¤Î tcltklib ¥é¥¤¥Ö¥é¥ê¤Ç¤â¡¤Tcl/Tk ¤Î C ¥é¥¤¥Ö¥é¥ê¤ò¥ê¥ó¥¯¤·¤Æ
+ľÀÜ¤ËÆ°¤«¤¹¤³¤È¤Ç¡¤¥ª¡¼¥Ð¥Ø¥Ã¥É¤ò²¡¤µ¤¨¤Ä¤Ä Tcl/Tk ¥¤¥ó¥¿¡¼¥×¥ê¥¿
+¤Î¤Û¤ÜÁ´µ¡Ç½¡Ê³ÈÄ¥¥é¥¤¥Ö¥é¥ê¤ò´Þ¤à¡Ë¤ò»È¤¨¤ëÅÀ¤ÏƱ¤¸¤Ç¤¹¡¥¤·¤«¤·¡¤
+¤½¤ÎÌò³ä¤Ï¤Û¤Ü¡Ötk.rb °Ê²¼¤Î¥é¥¤¥Ö¥é¥ê¤ò¸ú²ÌŪ¤ËƯ¤«¤»¤ë¤¿¤á¤Î¤â¤Î¡×
+¤È¸«¤Ê¤µ¤ì¤Æ¤ª¤ê¡¤¤½¤ÎÌÜŪ¤Ç¥á¥ó¥Æ¥Ê¥ó¥¹¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥
+
+tk.rb ¤Î¹âµ¡Ç½²½¤Ëȼ¤Ã¤Æ¡¤Ãæ¿å½à¤Î¥é¥¤¥Ö¥é¥ê¤Ç¤¢¤ë tcltk ¥é¥¤¥Ö¥é¥ê
+¡Êtcltk.rb¡Ë¤Ï¤½¤Î¸ºß°ÕµÁ¤ò¸º¤¸¤Æ¤ª¤ê¡¤¸½ºß¤Ç¤Ï¥á¥ó¥Æ¥Ê¥ó¥¹¤Ï¹Ô¤ï
+¤ì¤Æ¤¤¤Þ¤»¤ó¡¥
+
+¤Ê¤ª¡¤¸Å¤¤ÀâÌÀ¤Ç¤Ï¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤Ë¤ª¤±¤ë¥¹¥¯¥ê¥×¥È¤ÎÄɲäϤǤ­¤Ê¤¤¤³
+¤È¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¤¸½ºß¤Î tk.rb ¤Ç¤Ï¤³¤ì¤â²Äǽ¤Ç¤¢¤ë¤³¤È¤òÊä­¤·¤Æ
+¤ª¤­¤Þ¤¹¡¥
+
+°Ê²¼¤¬¥é¥¤¥Ö¥é¥ê¤Î¸Å¤¤ÀâÌÀʸ½ñ¤Ç¤¹¡¥
+==============================================================
tcltk ¥é¥¤¥Ö¥é¥ê
tcltklib ¥é¥¤¥Ö¥é¥ê
Sep. 19, 1997 Y. Shigehiro
diff --git a/ext/tcltklib/demo/lines1.rb b/ext/tcltklib/demo/lines1.rb
index e459589f50..9f21ae6377 100644
--- a/ext/tcltklib/demo/lines1.rb
+++ b/ext/tcltklib/demo/lines1.rb
@@ -1,6 +1,6 @@
#! /usr/local/bin/ruby
-require "tk"
+require "tcltk"
def drawlines()
print Time.now, "\n"
@@ -14,7 +14,7 @@ def drawlines()
col = "red"
end
for i in 0 .. 99
-# TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
+# $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
end
end
@@ -29,26 +29,22 @@ def drawlines()
col = "red"
end
for i in 0 .. 99
- TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
+ $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
end
end
print Time.now, "\n"
-# Tk.root.destroy
+# $ip.commands()["destroy"].e($root)
end
-$a = TkCanvas.new{
- height(500)
- width(500)
-}
+$ip = TclTkInterpreter.new()
+$root = $ip.rootwidget()
+$a = TclTkWidget.new($ip, $root, "canvas", "-height 500 -width 500")
+$c = TclTkCallback.new($ip, proc{drawlines()})
+$b = TclTkWidget.new($ip, $root, "button", "-text draw -command", $c)
-$b = TkButton.new{
- text("draw")
- command(proc{drawlines()})
-}
+$ip.commands()["pack"].e($a, $b, "-side left")
-TkPack.configure($a, $b, {"side"=>"left"})
-
-Tk.mainloop
+TclTk.mainloop
# eof
diff --git a/ext/tcltklib/demo/lines2.rb b/ext/tcltklib/demo/lines2.rb
index 9f21ae6377..e459589f50 100644
--- a/ext/tcltklib/demo/lines2.rb
+++ b/ext/tcltklib/demo/lines2.rb
@@ -1,6 +1,6 @@
#! /usr/local/bin/ruby
-require "tcltk"
+require "tk"
def drawlines()
print Time.now, "\n"
@@ -14,7 +14,7 @@ def drawlines()
col = "red"
end
for i in 0 .. 99
-# $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
+# TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
end
end
@@ -29,22 +29,26 @@ def drawlines()
col = "red"
end
for i in 0 .. 99
- $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
+ TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
end
end
print Time.now, "\n"
-# $ip.commands()["destroy"].e($root)
+# Tk.root.destroy
end
-$ip = TclTkInterpreter.new()
-$root = $ip.rootwidget()
-$a = TclTkWidget.new($ip, $root, "canvas", "-height 500 -width 500")
-$c = TclTkCallback.new($ip, proc{drawlines()})
-$b = TclTkWidget.new($ip, $root, "button", "-text draw -command", $c)
+$a = TkCanvas.new{
+ height(500)
+ width(500)
+}
-$ip.commands()["pack"].e($a, $b, "-side left")
+$b = TkButton.new{
+ text("draw")
+ command(proc{drawlines()})
+}
-TclTk.mainloop
+TkPack.configure($a, $b, {"side"=>"left"})
+
+Tk.mainloop
# eof
diff --git a/ext/tcltklib/demo/lines3.rb b/ext/tcltklib/demo/lines3.rb
new file mode 100644
index 0000000000..caa50f92e7
--- /dev/null
+++ b/ext/tcltklib/demo/lines3.rb
@@ -0,0 +1,54 @@
+#! /usr/local/bin/ruby
+
+require "tk"
+
+def drawlines()
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+# $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col)
+ end
+ end
+
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+ $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col)
+ end
+ end
+
+ print Time.now, "\n"
+# Tk.root.destroy
+end
+
+$a = TkCanvas.new{
+ height(500)
+ width(500)
+}
+
+$b = TkButton.new{
+ text("draw")
+ command(proc{drawlines()})
+}
+
+TkPack.configure($a, $b, {"side"=>"left"})
+
+Tk.mainloop
+
+# eof
diff --git a/ext/tcltklib/demo/lines4.rb b/ext/tcltklib/demo/lines4.rb
new file mode 100644
index 0000000000..7a1175bce0
--- /dev/null
+++ b/ext/tcltklib/demo/lines4.rb
@@ -0,0 +1,54 @@
+#! /usr/local/bin/ruby
+
+require "tk"
+
+def drawlines()
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+# TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+ TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+# Tk.root.destroy
+end
+
+$a = TkCanvas.new{
+ height(500)
+ width(500)
+}
+
+$b = TkButton.new{
+ text("draw")
+ command(proc{drawlines()})
+}
+
+TkPack.configure($a, $b, {"side"=>"left"})
+
+Tk.mainloop
+
+# eof
diff --git a/ext/tcltklib/demo/safeTk.rb b/ext/tcltklib/demo/safeTk.rb
new file mode 100644
index 0000000000..5d2c60e700
--- /dev/null
+++ b/ext/tcltklib/demo/safeTk.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tcltklib'
+
+master = TclTkIp.new
+slave_name = 'slave0'
+slave = master.create_slave(slave_name, true)
+master._eval("::safe::interpInit #{slave_name}")
+master._eval("::safe::loadTk #{slave_name}")
+
+master._invoke('label', '.l1', '-text', 'master')
+master._invoke('pack', '.l1', '-padx', '30', '-pady', '50')
+master._eval('label .l2 -text {root widget of master-ip}')
+master._eval('pack .l2 -padx 30 -pady 50')
+
+slave._invoke('label', '.l1', '-text', 'slave')
+slave._invoke('pack', '.l1', '-padx', '30', '-pady', '50')
+slave._eval('label .l2 -text {root widget of slave-ip}')
+slave._eval('pack .l2 -padx 30 -pady 20')
+slave._eval('label .l3 -text {( container frame widget of master-ip )}')
+slave._eval('pack .l3 -padx 30 -pady 20')
+
+TclTkLib.mainloop
diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb
index c9082e0a7f..8ec34f0214 100644
--- a/ext/tcltklib/extconf.rb
+++ b/ext/tcltklib/extconf.rb
@@ -2,7 +2,16 @@
require 'mkmf'
-if RUBY_PLATFORM !~ /mswin32|mingw|cygwin/
+is_win32 = (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM)
+is_macosx = (/darwin/ =~ RUBY_PLATFORM)
+
+mac_need_framework =
+ is_macosx &&
+ enable_config("mac-tcltk-framework", false) &&
+ FileTest.directory?("/Library/Frameworks/Tcl.framework/") &&
+ FileTest.directory?("/Library/Frameworks/Tk.framework/")
+
+unless is_win32
have_library("nsl", "t_open")
have_library("socket", "socket")
have_library("dl", "dlopen")
@@ -18,54 +27,220 @@ tcllib = with_config("tcllib")
stubs = enable_config("tcltk_stubs") || with_config("tcltk_stubs")
def find_tcl(tcllib, stubs)
- paths = ["/usr/local/lib", "/usr/pkg", "/usr/lib"]
- func = stubs ? "Tcl_InitStubs" : "Tcl_FindExecutable"
+ paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
+ if stubs
+ func = "Tcl_InitStubs"
+ lib = "tclstub"
+ else
+ func = "Tcl_FindExecutable"
+ lib = "tcl"
+ end
if tcllib
find_library(tcllib, func, *paths)
- elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin/
- find_library("tcl", func, *paths) or
- find_library("tcl84", func, *paths) or
- find_library("tcl83", func, *paths) or
- find_library("tcl82", func, *paths) or
- find_library("tcl80", func, *paths) or
- find_library("tcl76", func, *paths)
+ elsif find_library(lib, func, *paths)
+ true
else
- find_library("tcl", func, *paths) or
- find_library("tcl8.4", func, *paths) or
- find_library("tcl8.3", func, *paths) or
- find_library("tcl8.2", func, *paths) or
- find_library("tcl8.0", func, *paths) or
- find_library("tcl7.6", func, *paths)
+ %w[8.5 8.4 8.3 8.2 8.1 8.0 7.6].find { |ver|
+ find_library("tcl#{ver}", func, *paths) or
+ find_library("tcl#{ver.delete('.')}", func, *paths)
+ }
end
end
def find_tk(tklib, stubs)
- paths = ["/usr/local/lib", "/usr/pkg", "/usr/lib"]
- func = stubs ? "Tk_InitStubs" : "Tk_Init"
+ paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
+ if stubs
+ func = "Tk_InitStubs"
+ lib = "tkstub"
+ else
+ func = "Tk_Init"
+ lib = "tk"
+ end
if tklib
find_library(tklib, func, *paths)
- elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin/
- find_library("tk", func, *paths) or
- find_library("tk84", func, *paths) or
- find_library("tk83", func, *paths) or
- find_library("tk82", func, *paths) or
- find_library("tk80", func, *paths) or
- find_library("tk42", func, *paths)
+ elsif find_library(lib, func, *paths)
+ true
+ else
+ %w[8.5 8.4 8.3 8.2 8.1 8.0 4.2].find { |ver|
+ find_library("tk#{ver}", func, *paths) or
+ find_library("tk#{ver.delete('.')}", func, *paths)
+ }
+ end
+end
+
+def pthread_check()
+ tcl_major_ver = nil
+ tcl_minor_ver = nil
+
+ # Is tcl-thread given by user ?
+ case enable_config("tcl-thread")
+ when true
+ tcl_enable_thread = true
+ when false
+ tcl_enable_thread = false
+ else
+ tcl_enable_thread = nil
+ end
+
+ if (tclConfig = with_config("tclConfig-file"))
+ if tcl_enable_thread == true
+ puts("Warning: --with-tclConfig-file option is ignored, because --enable-tcl-thread option is given.")
+ elsif tcl_enable_thread == false
+ puts("Warning: --with-tclConfig-file option is ignored, because --disable-tcl-thread option is given.")
+ else
+ # tcl-thread is unknown and tclConfig.sh is given
+ begin
+ open(tclConfig, "r") do |cfg|
+ while line = cfg.gets()
+ if line =~ /^\s*TCL_THREADS=(0|1)/
+ tcl_enable_thread = ($1 == "1")
+ break
+ end
+
+ if line =~ /^\s*TCL_MAJOR_VERSION=("|')(\d+)\1/
+ tcl_major_ver = $2
+ if tcl_major_ver =~ /^[1-7]$/
+ tcl_enable_thread = false
+ break
+ end
+ if tcl_major_ver == "8" && tcl_minor_ver == "0"
+ tcl_enable_thread = false
+ break
+ end
+ end
+
+ if line =~ /^\s*TCL_MINOR_VERSION=("|')(\d+)\1/
+ tcl_minor_ver = $2
+ if tcl_major_ver == "8" && tcl_minor_ver == "0"
+ tcl_enable_thread = false
+ break
+ end
+ end
+ end
+ end
+
+ if tcl_enable_thread == nil
+ # not find definition
+ if tcl_major_ver
+ puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
+ else
+ puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
+ end
+ tclConfig = false
+ end
+ rescue Exception
+ puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
+ tclConfig = false
+ end
+ end
+ end
+
+ if tcl_enable_thread == nil && !tclConfig
+ # tcl-thread is unknown and tclConfig is unavailable
+ begin
+ try_run_available = try_run("int main() { exit(0); }")
+ rescue Exception
+ # cannot try_run. Is CROSS-COMPILE environment?
+ puts(%Q'\
+*****************************************************************************
+**
+** PTHREAD SUPPORT CHECK WARNING:
+**
+** We cannot check the consistency of pthread support between Ruby
+** and Tcl/Tk library on your environment (do coss-compile?). If the
+** consistency is not kept, some memory troubles (e.g. "Hang-up" or
+** "Segmentation Fault") may bother you. We strongly you to check the
+** consistency by your own hand.
+**
+*****************************************************************************
+')
+ return true
+ end
+ end
+
+ if tcl_enable_thread == nil
+ # tcl-thread is unknown
+ if try_run(<<EOF)
+#include <tcl.h>
+static Tcl_ThreadDataKey dataKey;
+int main() { exit((Tcl_GetThreadData(&dataKey, 1) == dataKey)? 1: 0); }
+EOF
+ tcl_enable_thread = true
+ else
+ tcl_enable_thread = false
+ end
+ end
+
+ # check pthread mode
+ if (macro_defined?('HAVE_LIBPTHREAD', '#include "ruby.h"'))
+ # ruby -> enable
+ unless tcl_enable_thread
+ # ruby -> enable && tcl -> disable
+ puts(%Q'\
+*****************************************************************************
+**
+** PTHREAD SUPPORT MODE WARNING:
+**
+** Ruby is compiled with --enable-pthread, but your Tcl/Tk libraries
+** seems to be compiled without "pthread support". Although You can
+** create tcltklib library, this combination may cause memory trouble
+** (e.g. "Hang-up" or "Segmentation Fault"). If you have no reason you
+** must have to keep current pthread support status, we recommend you
+** to make both or neither libraries to support pthread.
+**
+** If you want change the status of pthread support, please recompile
+** Ruby without "--enable-pthread" configure option or recompile Tcl/Tk
+** with "--enable-threads" configure option (if your Tcl/Tk is later
+** than or equal to Tcl/Tk8.1).
+**
+*****************************************************************************
+')
+ end
+
+ # ruby -> enable && tcl -> enable/disable
+ return true
+
else
- find_library("tk", func, *paths) or
- find_library("tk8.4", func, *paths) or
- find_library("tk8.3", func, *paths) or
- find_library("tk8.2", func, *paths) or
- find_library("tk8.0", func, *paths) or
- find_library("tk4.2", func, *paths)
+ # ruby -> disable
+ if tcl_enable_thread
+ # ruby -> disable && tcl -> enable
+ puts(%Q'\
+*****************************************************************************
+**
+** PTHREAD SUPPORT MODE ERRROR:
+**
+** Ruby is not compiled with --enable-pthread, but your Tcl/Tk
+** libararies seems to be compiled with "pthread support". This
+** combination possibly cause "Hang-up" or "Segmentation Fault"
+** frequently when Ruby/Tk is working. We NEVER recommend you to
+** create the library under such combination of pthread support.
+**
+** Please recompile Ruby with "--enable-pthread" configure option
+** or recompile Tcl/Tk with "--disable-threads" configure option.
+**
+*****************************************************************************
+')
+ return false
+ else
+ # ruby -> disable && tcl -> disable
+ return true
+ end
end
end
-if have_header("tcl.h") && have_header("tk.h") &&
- (/mswin32|mingw|cygwin/ =~ RUBY_PLATFORM || find_library("X11", "XOpenDisplay",
- "/usr/X11/lib", "/usr/X11R6/lib", "/usr/openwin/lib")) &&
+if mac_need_framework ||
+ (have_header("tcl.h") && have_header("tk.h") &&
+ (is_win32 || find_library("X11", "XOpenDisplay",
+ "/usr/X11/lib", "/usr/lib/X11", "/usr/X11R6/lib", "/usr/openwin/lib")) &&
find_tcl(tcllib, stubs) &&
- find_tk(tklib, stubs)
+ find_tk(tklib, stubs))
$CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' if stubs
- create_makefile("tcltklib")
+ $CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
+
+ if mac_need_framework
+ $CPPFLAGS += ' -I/Library/Frameworks/Tcl.framework/headers -I/Library/Frameworks/Tk.framework/Headers'
+ $LDFLAGS += ' -framework Tk -framework Tcl'
+ end
+
+ create_makefile("tcltklib") if stubs or pthread_check
end
diff --git a/ext/tcltklib/lib/tcltk.rb b/ext/tcltklib/lib/tcltk.rb
index 54a00e8f3c..1a6694dbff 100644
--- a/ext/tcltklib/lib/tcltk.rb
+++ b/ext/tcltklib/lib/tcltk.rb
@@ -1,7 +1,7 @@
# tof
#### tcltk library, more direct manipulation of tcl/tk
-#### Sep. 5, 1997 Y. Shigehiro
+#### Sep. 5, 1997 Y. Shigehiro
require "tcltklib"
@@ -93,9 +93,9 @@ class TclTkInterpreter
# ruby_fmt command format arguments by `format' and call `ruby' command
# (notice ruby command receives only one argument)
if $DEBUG
- @ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; ruby [format $fmt $args] }")
+ @ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }")
else
- @ip._eval("proc ruby_fmt {fmt args} { ruby [format $fmt $args] }")
+ @ip._eval("proc ruby_fmt {fmt args} { set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }")
end
# @ip._get_eval_string(*args): generate string to evaluate in tcl interpreter
@@ -103,14 +103,14 @@ class TclTkInterpreter
def @ip._get_eval_string(*args)
argstr = ""
args.each{|arg|
- argstr += " " if argstr != ""
- # call to_eval if it is defined
- if (arg.respond_to?(:to_eval))
- argstr += arg.to_eval()
- else
- # call to_s unless defined
- argstr += arg.to_s()
- end
+ argstr += " " if argstr != ""
+ # call to_eval if it is defined
+ if (arg.respond_to?(:to_eval))
+ argstr += arg.to_eval()
+ else
+ # call to_s unless defined
+ argstr += arg.to_s()
+ end
}
return argstr
end
@@ -126,9 +126,9 @@ class TclTkInterpreter
print("_eval: \"", argstr, "\"") if $DEBUG
res = _eval(argstr)
if $DEBUG
- print(" -> \"", res, "\"\n")
+ print(" -> \"", res, "\"\n")
elsif _return_value() != 0
- print(res, "\n")
+ print(res, "\n")
end
fail(%Q/can't eval "#{argstr}"/) if _return_value() != 0 #'
return res
@@ -139,12 +139,12 @@ class TclTkInterpreter
# for all commands registered in tcl/tk interpreter:
@ip._eval("info command").split(/ /).each{|comname|
if comname =~ /^[.]/
- # if command is a widget (path), generate TclTkWidget,
- # and register it in the hash
- @commands[comname] = TclTkWidget.new(@ip, comname)
+ # if command is a widget (path), generate TclTkWidget,
+ # and register it in the hash
+ @commands[comname] = TclTkWidget.new(@ip, comname)
else
- # otherwise, generate TclTkCommand
- @commands[comname] = TclTkCommand.new(@ip, comname)
+ # otherwise, generate TclTkCommand
+ @commands[comname] = TclTkCommand.new(@ip, comname)
end
}
end
diff --git a/ext/tcltklib/sample/sample1.rb b/ext/tcltklib/sample/sample1.rb
index 28ba7b547a..77b79e6dbf 100644
--- a/ext/tcltklib/sample/sample1.rb
+++ b/ext/tcltklib/sample/sample1.rb
@@ -189,8 +189,8 @@ class Test1
grid.e(w, "-row", ro, "-column", co, "-sticky news")
ro += 1
if ro == 7
- ro = 0
- co += 1
+ ro = 0
+ co += 1
end
}
end
@@ -535,7 +535,7 @@ class Test1
# clipboard ¤ò¥¯¥ê¥¢.
clipboard.e("clear")
# selection ¤«¤éʸ»úÎó¤òÆÉ¤ß¹þ¤ß clipboard ¤ËÄɲ乤ë.
- clipboard.e("append {#{selection.e(\"get\")}}")}))
+ clipboard.e("append {#{selection.e('get')}}")}))
me1.e("add command -label {selection -> clipboard} -command",c)
cb.push(c = TclTkCallback.new(ip, proc{
# li1 ¤ò¥¯¥ê¥¢.
diff --git a/ext/tcltklib/sample/sample2.rb b/ext/tcltklib/sample/sample2.rb
index 969d8de09a..5d43470de3 100644
--- a/ext/tcltklib/sample/sample2.rb
+++ b/ext/tcltklib/sample/sample2.rb
@@ -6,13 +6,13 @@
# maeda shugo (shuto@po.aianet.ne.jp)
#---------------------------------------------------------------------------
-# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library
-# maeda shugo (shugo@po.aianet.ne.jp) »á¤Ë¤è¤ë
+# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library
+# maeda shugo (shugo@po.aianet.ne.jp) »á¤Ë¤è¤ë
# (ruby/tk ¤Ç½ñ¤«¤ì¤Æ¤¤¤¿) ruby ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à
-# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
-# ¤ò tcltk ¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤è¤¦¤Ë, µ¡³£Åª¤ËÊѹ¹¤·¤Æ¤ß¤Þ¤·¤¿.
+# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
+# ¤ò tcltk ¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤è¤¦¤Ë, µ¡³£Åª¤ËÊѹ¹¤·¤Æ¤ß¤Þ¤·¤¿.
#
-# ¤Ê¤ë¤Ù¤¯¥ª¥ê¥¸¥Ê¥ë¤ÈƱ¤¸¤Ë¤Ê¤ë¤è¤¦¤Ë¤·¤Æ¤¢¤ê¤Þ¤¹.
+# ¤Ê¤ë¤Ù¤¯¥ª¥ê¥¸¥Ê¥ë¤ÈƱ¤¸¤Ë¤Ê¤ë¤è¤¦¤Ë¤·¤Æ¤¢¤ê¤Þ¤¹.
require "observer"
require "tcltk"
@@ -36,141 +36,141 @@ class Othello
include Observable
DIRECTIONS = [
- [-1, -1], [-1, 0], [-1, 1],
- [ 0, -1], [ 0, 1],
- [ 1, -1], [ 1, 0], [ 1, 1]
+ [-1, -1], [-1, 0], [-1, 1],
+ [ 0, -1], [ 0, 1],
+ [ 1, -1], [ 1, 0], [ 1, 1]
]
attr :com_disk, TRUE
def initialize(othello)
- @othello = othello
- reset
+ @othello = othello
+ reset
end
def notify_observers(*arg)
- if @observer_peers != nil
- super(*arg)
- end
+ if @observer_peers != nil
+ super(*arg)
+ end
end
def reset
- @data = [
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
- [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY]
- ]
- changed
- notify_observers
+ @data = [
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY]
+ ]
+ changed
+ notify_observers
end
def man_disk
- return - @com_disk
+ return - @com_disk
end
def other_disk(disk)
- return - disk
+ return - disk
end
def get_disk(row, col)
- return @data[row][col]
+ return @data[row][col]
end
def reverse_to(row, col, my_disk, dir_y, dir_x)
- y = row
- x = col
- begin
- y += dir_y
- x += dir_x
- if y < 0 || x < 0 || y > 7 || x > 7 ||
- @data[y][x] == EMPTY
- return
- end
- end until @data[y][x] == my_disk
- begin
- @data[y][x] = my_disk
- changed
- notify_observers(y, x)
- y -= dir_y
- x -= dir_x
- end until y == row && x == col
+ y = row
+ x = col
+ begin
+ y += dir_y
+ x += dir_x
+ if y < 0 || x < 0 || y > 7 || x > 7 ||
+ @data[y][x] == EMPTY
+ return
+ end
+ end until @data[y][x] == my_disk
+ begin
+ @data[y][x] = my_disk
+ changed
+ notify_observers(y, x)
+ y -= dir_y
+ x -= dir_x
+ end until y == row && x == col
end
def put_disk(row, col, disk)
- @data[row][col] = disk
- changed
- notify_observers(row, col)
- DIRECTIONS.each do |dir|
- reverse_to(row, col, disk, *dir)
- end
+ @data[row][col] = disk
+ changed
+ notify_observers(row, col)
+ DIRECTIONS.each do |dir|
+ reverse_to(row, col, disk, *dir)
+ end
end
def count_disk(disk)
- num = 0
- @data.each do |rows|
- rows.each do |d|
- if d == disk
- num += 1
- end
- end
- end
- return num
+ num = 0
+ @data.each do |rows|
+ rows.each do |d|
+ if d == disk
+ num += 1
+ end
+ end
+ end
+ return num
end
def count_point_to(row, col, my_disk, dir_y, dir_x)
- return 0 if @data[row][col] != EMPTY
- count = 0
- loop do
- row += dir_y
- col += dir_x
- break if row < 0 || col < 0 || row > 7 || col > 7
- case @data[row][col]
- when my_disk
- return count
- when other_disk(my_disk)
- count += 1
- when EMPTY
- break
- end
- end
- return 0
+ return 0 if @data[row][col] != EMPTY
+ count = 0
+ loop do
+ row += dir_y
+ col += dir_x
+ break if row < 0 || col < 0 || row > 7 || col > 7
+ case @data[row][col]
+ when my_disk
+ return count
+ when other_disk(my_disk)
+ count += 1
+ when EMPTY
+ break
+ end
+ end
+ return 0
end
def count_point(row, col, my_disk)
- count = 0
- DIRECTIONS.each do |dir|
- count += count_point_to(row, col, my_disk, *dir)
- end
- return count
+ count = 0
+ DIRECTIONS.each do |dir|
+ count += count_point_to(row, col, my_disk, *dir)
+ end
+ return count
end
def corner?(row, col)
- return (row == 0 && col == 0) ||
- (row == 0 && col == 7) ||
- (row == 7 && col == 0) ||
- (row == 7 && col == 7)
+ return (row == 0 && col == 0) ||
+ (row == 0 && col == 7) ||
+ (row == 7 && col == 0) ||
+ (row == 7 && col == 7)
end
def search(my_disk)
- max = 0
- max_row = nil
- max_col = nil
- for row in 0 .. 7
- for col in 0 .. 7
- buf = count_point(row, col, my_disk)
- if (corner?(row, col) && buf > 0) || max < buf
- max = buf
- max_row = row
- max_col = col
- end
- end
- end
- return max_row, max_col
+ max = 0
+ max_row = nil
+ max_col = nil
+ for row in 0 .. 7
+ for col in 0 .. 7
+ buf = count_point(row, col, my_disk)
+ if (corner?(row, col) && buf > 0) || max < buf
+ max = buf
+ max_row = row
+ max_col = col
+ end
+ end
+ end
+ return max_row, max_col
end
end #--------------------------> class Board ends here
@@ -189,145 +189,145 @@ class Othello
attr :bottom
class Square
-
- attr :oval, TRUE
- attr :row
- attr :col
-
- def initialize(view, row, col)
- @view = view
- @id = @view.e("create rectangle", *view.tk_rect(view.left + col,
- view.top + row,
- view.left + col + 1,
- view.top + row + 1))
- @row = row
- @col = col
- @view.e("itemconfigure", @id,
- "-width 0.5m -outline #{BORDER_COLOR}")
- @view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{
- if @oval == nil
- view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}")
- end
- }))
- @view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{
- view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
- }))
- @view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip,
- proc{
- view.click_square(self)
- }))
- end
-
- def blink(color)
- @view.e("itemconfigure", @id, "-fill #{color}")
- $update.e()
- sleep(0.1)
- @view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
- end
+
+ attr :oval, TRUE
+ attr :row
+ attr :col
+
+ def initialize(view, row, col)
+ @view = view
+ @id = @view.e("create rectangle", *view.tk_rect(view.left + col,
+ view.top + row,
+ view.left + col + 1,
+ view.top + row + 1))
+ @row = row
+ @col = col
+ @view.e("itemconfigure", @id,
+ "-width 0.5m -outline #{BORDER_COLOR}")
+ @view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{
+ if @oval == nil
+ view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}")
+ end
+ }))
+ @view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{
+ view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
+ }))
+ @view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip,
+ proc{
+ view.click_square(self)
+ }))
+ end
+
+ def blink(color)
+ @view.e("itemconfigure", @id, "-fill #{color}")
+ $update.e()
+ sleep(0.1)
+ @view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
+ end
end #-----------------------> class Square ends here
def initialize(othello, board)
- super($ip, $root, $canvas)
- @othello = othello
- @board = board
- @board.add_observer(self)
-
- @squares = Array.new(8)
- for i in 0 .. 7
- @squares[i] = Array.new(8)
- end
- @left = 1
- @top = 0.5
- @right = @left + 8
- @bottom = @top + 8
-
- i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom))
- self.e("itemconfigure", i,
- "-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}")
+ super($ip, $root, $canvas)
+ @othello = othello
+ @board = board
+ @board.add_observer(self)
+
+ @squares = Array.new(8)
+ for i in 0 .. 7
+ @squares[i] = Array.new(8)
+ end
+ @left = 1
+ @top = 0.5
+ @right = @left + 8
+ @bottom = @top + 8
+
+ i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom))
+ self.e("itemconfigure", i,
+ "-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}")
- for row in 0 .. 7
- for col in 0 .. 7
- @squares[row][col] = Square.new(self, row, col)
- end
- end
-
- update
+ for row in 0 .. 7
+ for col in 0 .. 7
+ @squares[row][col] = Square.new(self, row, col)
+ end
+ end
+
+ update
end
def tk_rect(left, top, right, bottom)
- return left.to_s + "c", top.to_s + "c",
- right.to_s + "c", bottom.to_s + "c"
+ return left.to_s + "c", top.to_s + "c",
+ right.to_s + "c", bottom.to_s + "c"
end
def clear
- each_square do |square|
- if square.oval != nil
- self.e("delete", square.oval)
- square.oval = nil
- end
- end
+ each_square do |square|
+ if square.oval != nil
+ self.e("delete", square.oval)
+ square.oval = nil
+ end
+ end
end
def draw_disk(row, col, disk)
- if disk == EMPTY
- if @squares[row][col].oval != nil
- self.e("delete", @squares[row][col].oval)
- @squares[row][col].oval = nil
- end
- return
- end
-
- $update.e()
- sleep(0.05)
- oval = @squares[row][col].oval
- if oval == nil
- oval = self.e("create oval", *tk_rect(@left + col + 0.2,
- @top + row + 0.2,
- @left + col + 0.8,
- @top + row + 0.8))
- @squares[row][col].oval = oval
- end
- case disk
- when BLACK
- color = BLACK_COLOR
- when WHITE
- color = WHITE_COLOR
- else
- fail format("Unknown disk type: %d", disk)
- end
- self.e("itemconfigure", oval, "-outline #{color} -fill #{color}")
+ if disk == EMPTY
+ if @squares[row][col].oval != nil
+ self.e("delete", @squares[row][col].oval)
+ @squares[row][col].oval = nil
+ end
+ return
+ end
+
+ $update.e()
+ sleep(0.05)
+ oval = @squares[row][col].oval
+ if oval == nil
+ oval = self.e("create oval", *tk_rect(@left + col + 0.2,
+ @top + row + 0.2,
+ @left + col + 0.8,
+ @top + row + 0.8))
+ @squares[row][col].oval = oval
+ end
+ case disk
+ when BLACK
+ color = BLACK_COLOR
+ when WHITE
+ color = WHITE_COLOR
+ else
+ fail format("Unknown disk type: %d", disk)
+ end
+ self.e("itemconfigure", oval, "-outline #{color} -fill #{color}")
end
def update(row = nil, col = nil)
- if row && col
- draw_disk(row, col, @board.get_disk(row, col))
- else
- each_square do |square|
- draw_disk(square.row, square.col,
- @board.get_disk(square.row, square.col))
- end
- end
- @othello.show_point
+ if row && col
+ draw_disk(row, col, @board.get_disk(row, col))
+ else
+ each_square do |square|
+ draw_disk(square.row, square.col,
+ @board.get_disk(square.row, square.col))
+ end
+ end
+ @othello.show_point
end
def each_square
- @squares.each do |rows|
- rows.each do |square|
- yield(square)
- end
- end
+ @squares.each do |rows|
+ rows.each do |square|
+ yield(square)
+ end
+ end
end
def click_square(square)
- if @othello.in_com_turn || @othello.game_over ||
- @board.count_point(square.row,
- square.col,
- @board.man_disk) == 0
- square.blink(STOP_COLOR)
- return
- end
- @board.put_disk(square.row, square.col, @board.man_disk)
- @othello.com_turn
+ if @othello.in_com_turn || @othello.game_over ||
+ @board.count_point(square.row,
+ square.col,
+ @board.man_disk) == 0
+ square.blink(STOP_COLOR)
+ return
+ end
+ @board.put_disk(square.row, square.col, @board.man_disk)
+ @othello.com_turn
end
private :draw_disk
@@ -347,7 +347,7 @@ class Othello
@board_view.e("configure -height", y2 - y1)
## scrollregion ¤òÀßÄꤹ¤ë.
@board_view.e("configure -scrollregion {", @board_view.e("bbox all"),
- "}")
+ "}")
#### ¤³¤³¤Þ¤Ç
$pack.e(@board_view, "-fill both -expand true")
@@ -355,19 +355,19 @@ class Othello
@play_black = TclTkWidget.new($ip, panel, $checkbutton,
"-text {com is black} -command", TclTkCallback.new($ip, proc{
- switch_side
+ switch_side
}))
$pack.e(@play_black, "-side left")
quit = TclTkWidget.new($ip, panel, $button, "-text Quit -command",
- TclTkCallback.new($ip, proc{
- exit
+ TclTkCallback.new($ip, proc{
+ exit
}))
$pack.e(quit, "-side right -fill x")
reset = TclTkWidget.new($ip, panel, $button, "-text Reset -command",
- TclTkCallback.new($ip, proc{
- reset_game
+ TclTkCallback.new($ip, proc{
+ reset_game
}))
$pack.e(reset, "-side right -fill x")
@@ -385,17 +385,17 @@ class Othello
def switch_side
if @in_com_turn
- @play_black.e("toggle")
+ @play_black.e("toggle")
else
- @board.com_disk = @board.man_disk
- com_turn unless @game_over
+ @board.com_disk = @board.man_disk
+ com_turn unless @game_over
end
end
def reset_game
if @board.com_disk == BLACK
- @board.com_disk = WHITE
- @play_black.e("toggle")
+ @board.com_disk = WHITE
+ @play_black.e("toggle")
end
@board_view.clear
@board.reset
@@ -408,30 +408,30 @@ class Othello
$update.e()
sleep(0.5)
begin
- com_disk = @board.count_disk(@board.com_disk)
- man_disk = @board.count_disk(@board.man_disk)
- if @board.count_disk(EMPTY) == 0
- if man_disk == com_disk
- $wm.e("title", $root, "{Othello - Draw!}")
- elsif man_disk > com_disk
- $wm.e("title", $root, "{Othello - You Win!}")
- else
- $wm.e("title", $root, "{Othello - You Loose!}")
- end
- @game_over = TRUE
- break
- elsif com_disk == 0
- $wm.e("title", $root, "{Othello - You Win!}")
- @game_over = TRUE
- break
- elsif man_disk == 0
- $wm.e("title", $root, "{Othello - You Loose!}")
- @game_over = TRUE
- break
- end
- row, col = @board.search(@board.com_disk)
- break if row == nil || col == nil
- @board.put_disk(row, col, @board.com_disk)
+ com_disk = @board.count_disk(@board.com_disk)
+ man_disk = @board.count_disk(@board.man_disk)
+ if @board.count_disk(EMPTY) == 0
+ if man_disk == com_disk
+ $wm.e("title", $root, "{Othello - Draw!}")
+ elsif man_disk > com_disk
+ $wm.e("title", $root, "{Othello - You Win!}")
+ else
+ $wm.e("title", $root, "{Othello - You Loose!}")
+ end
+ @game_over = TRUE
+ break
+ elsif com_disk == 0
+ $wm.e("title", $root, "{Othello - You Win!}")
+ @game_over = TRUE
+ break
+ elsif man_disk == 0
+ $wm.e("title", $root, "{Othello - You Loose!}")
+ @game_over = TRUE
+ break
+ end
+ row, col = @board.search(@board.com_disk)
+ break if row == nil || col == nil
+ @board.put_disk(row, col, @board.com_disk)
end while @board.search(@board.man_disk) == [nil, nil]
@in_com_turn = FALSE
end
@@ -440,7 +440,7 @@ class Othello
black = @board.count_disk(BLACK)
white = @board.count_disk(WHITE)
@msg_label.e("configure -text",
- %Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/)
+ %Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/)
end
end #----------------------> class Othello ends here
diff --git a/ext/tcltklib/stubs.c b/ext/tcltklib/stubs.c
index 537ca74d37..3913abb570 100644
--- a/ext/tcltklib/stubs.c
+++ b/ext/tcltklib/stubs.c
@@ -1,9 +1,10 @@
+int ruby_tcltk_stubs();
+
#if defined USE_TCL_STUBS && defined USE_TK_STUBS
-#include <tcl.h>
-#include <tk.h>
#include "ruby.h"
-#if defined _WIN32
+#if defined _WIN32 || defined __CYGWIN__
+# include "util.h"
# include <windows.h>
typedef HINSTANCE DL_HANDLE;
# define DL_OPEN LoadLibrary
@@ -25,59 +26,76 @@
# define TK_NAME "libtk8.9%s"
#endif
+#include <tcl.h>
+#include <tk.h>
+
int
ruby_tcltk_stubs()
{
DL_HANDLE tcl_dll;
DL_HANDLE tk_dll;
+ void (*p_Tcl_FindExecutable)(const char *);
Tcl_Interp *(*p_Tcl_CreateInterp)();
- int (*p_Tk_Init) _((Tcl_Interp *));
+ int (*p_Tk_Init)(Tcl_Interp *);
Tcl_Interp *tcl_ip;
int n;
- char *ruby_tcl_dll;
- char *ruby_tk_dll;
+ char *ruby_tcl_dll = 0;
+ char *ruby_tk_dll = 0;
char tcl_name[20];
char tk_name[20];
ruby_tcl_dll = getenv("RUBY_TCL_DLL");
+#if defined _WIN32
+ if (ruby_tcl_dll) ruby_tcl_dll = ruby_strdup(ruby_tcl_dll);
+#endif
ruby_tk_dll = getenv("RUBY_TK_DLL");
if (ruby_tcl_dll && ruby_tk_dll) {
- tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
- tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
+ tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
+ tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
} else {
- snprintf(tcl_name, sizeof tcl_name, TCL_NAME, DLEXT);
- snprintf(tk_name, sizeof tk_name, TK_NAME, DLEXT);
- /* examin from 8.9 to 8.1 */
- for (n = '9'; n > '0'; n--) {
- tcl_name[TCL_INDEX] = n;
- tk_name[TK_INDEX] = n;
- tcl_dll = (DL_HANDLE)DL_OPEN(tcl_name);
- tk_dll = (DL_HANDLE)DL_OPEN(tk_name);
- if (tcl_dll && tk_dll)
- break;
- }
+ snprintf(tcl_name, sizeof tcl_name, TCL_NAME, DLEXT);
+ snprintf(tk_name, sizeof tk_name, TK_NAME, DLEXT);
+ /* examine from 8.9 to 8.1 */
+ for (n = '9'; n > '0'; n--) {
+ tcl_name[TCL_INDEX] = n;
+ tk_name[TK_INDEX] = n;
+ tcl_dll = (DL_HANDLE)DL_OPEN(tcl_name);
+ tk_dll = (DL_HANDLE)DL_OPEN(tk_name);
+ if (tcl_dll && tk_dll)
+ break;
+ }
}
+#if defined _WIN32
+ if (ruby_tcl_dll) ruby_xfree(ruby_tcl_dll);
+#endif
+
if (!tcl_dll || !tk_dll)
- return -1;
+ return -1;
+
+ p_Tcl_FindExecutable = (void (*)(const char *))DL_SYM(tcl_dll, "Tcl_FindExecutable");
+ if (!p_Tcl_FindExecutable)
+ return -7;
+
+ p_Tcl_FindExecutable("ruby");
p_Tcl_CreateInterp = (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_CreateInterp");
if (!p_Tcl_CreateInterp)
- return -2;
+ return -2;
tcl_ip = (*p_Tcl_CreateInterp)();
if (!tcl_ip)
- return -3;
+ return -3;
- p_Tk_Init = (int (*) _((Tcl_Interp *)))DL_SYM(tk_dll, "Tk_Init");
+ p_Tk_Init = (int (*)(Tcl_Interp *))DL_SYM(tk_dll, "Tk_Init");
if (!p_Tk_Init)
- return -4;
+ return -4;
(*p_Tk_Init)(tcl_ip);
if (!Tcl_InitStubs(tcl_ip, "8.1", 0))
- return -5;
+ return -5;
if (!Tk_InitStubs(tcl_ip, "8.1", 0))
- return -6;
+ return -6;
Tcl_DeleteInterp(tcl_ip);
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index b0a4880bfd..765417d925 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -1,13 +1,20 @@
/*
- * tcltklib.c
- * Aug. 27, 1997 Y. Shigehiro
- * Oct. 24, 1997 Y. Matsumoto
+ * tcltklib.c
+ * Aug. 27, 1997 Y. Shigehiro
+ * Oct. 24, 1997 Y. Matsumoto
*/
#include "ruby.h"
#include "rubysig.h"
-#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */
+#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */
#include <stdio.h>
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
#include <string.h>
#include <tcl.h>
#include <tk.h>
@@ -17,25 +24,82 @@
# include <Quickdraw.h>
#endif
-/* for ruby_debug */
+#if TCL_MAJOR_VERSION >= 8
+# ifndef CONST84
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 4 /* Tcl8.0.x -- 8.4b1 */
+# define CONST84
+# else /* unknown (maybe TCL_VERSION >= 8.5) */
+# ifdef CONST
+# define CONST84 CONST
+# else
+# define CONST84
+# endif
+# endif
+# endif
+#else /* TCL_MAJOR_VERSION < 8 */
+# ifdef CONST
+# define CONST84 CONST
+# else
+# define CONST
+# define CONST84
+# endif
+#endif
+
+/* copied from eval.c */
+#define TAG_RETURN 0x1
+#define TAG_BREAK 0x2
+#define TAG_NEXT 0x3
+#define TAG_RETRY 0x4
+#define TAG_REDO 0x5
+#define TAG_RAISE 0x6
+#define TAG_THROW 0x7
+#define TAG_FATAL 0x8
-#define DUMP1(ARG1) if (ruby_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1);}
+/* for ruby_debug */
+#define DUMP1(ARG1) if (ruby_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1); fflush(stderr); }
#define DUMP2(ARG1, ARG2) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\
-fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); }
+fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); fflush(stderr); }
/*
#define DUMP1(ARG1)
#define DUMP2(ARG1, ARG2)
*/
+/*finalize_proc_name */
+static char *finalize_hook_name = "INTERP_FINALIZE_HOOK";
+
/* for callback break & continue */
+static VALUE eTkCallbackReturn;
static VALUE eTkCallbackBreak;
static VALUE eTkCallbackContinue;
+static VALUE eLocalJumpError;
+
+static ID ID_at_enc;
+static ID ID_at_interp;
+
+static ID ID_stop_p;
+static ID ID_kill;
+static ID ID_join;
+
+static ID ID_call;
+static ID ID_backtrace;
+static ID ID_message;
+
+static ID ID_at_reason;
+static ID ID_return;
+static ID ID_break;
+static ID ID_next;
+
+static ID ID_to_s;
+static ID ID_inspect;
+
static VALUE ip_invoke_real _((int, VALUE*, VALUE));
+static VALUE ip_invoke _((int, VALUE*, VALUE));
/* from tkAppInit.c */
-#if !defined __MINGW32__
+#if TCL_MAJOR_VERSION < 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 4)
+# if !defined __MINGW32__ && !defined __BORLANDC__
/*
* The following variable is a special hack that is needed in order for
* Sun shared libraries to be used for Tcl.
@@ -43,440 +107,6053 @@ static VALUE ip_invoke_real _((int, VALUE*, VALUE));
extern int matherr();
int *tclDummyMathPtr = (int *) matherr;
+# endif
#endif
/*---- module TclTkLib ----*/
struct invoke_queue {
+ Tcl_Event ev;
int argc;
- VALUE *argv;
- VALUE obj;
- int done;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **argv;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **argv;
+#endif
+ VALUE interp;
+ int *done;
+ int safe_level;
+ VALUE result;
+ VALUE thread;
+};
+
+struct eval_queue {
+ Tcl_Event ev;
+ char *str;
+ int len;
+ VALUE interp;
+ int *done;
+ int safe_level;
VALUE result;
VALUE thread;
- struct invoke_queue *next;
};
+
+void
+invoke_queue_mark(struct invoke_queue *q)
+{
+ rb_gc_mark(q->interp);
+ rb_gc_mark(q->result);
+ rb_gc_mark(q->thread);
+}
+
+void
+eval_queue_mark(struct eval_queue *q)
+{
+ rb_gc_mark(q->interp);
+ rb_gc_mark(q->result);
+ rb_gc_mark(q->thread);
+}
+
-static struct invoke_queue *iqueue;
-static VALUE main_thread;
+static VALUE eventloop_thread;
+static VALUE watchdog_thread;
+Tcl_Interp *current_interp;
+
+/*
+ * 'event_loop_max' is a maximum events which the eventloop processes in one
+ * term of thread scheduling. 'no_event_tick' is the count-up value when
+ * there are no event for processing.
+ * 'timer_tick' is a limit of one term of thread scheduling.
+ * If 'timer_tick' == 0, then not use the timer for thread scheduling.
+ */
+#define DEFAULT_EVENT_LOOP_MAX 800/*counts*/
+#define DEFAULT_NO_EVENT_TICK 10/*counts*/
+#define DEFAULT_NO_EVENT_WAIT 20/*milliseconds ( 1 -- 999 ) */
+#define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */
+#define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */
+#define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */
+
+static int event_loop_max = DEFAULT_EVENT_LOOP_MAX;
+static int no_event_tick = DEFAULT_NO_EVENT_TICK;
+static int no_event_wait = DEFAULT_NO_EVENT_WAIT;
+static int timer_tick = DEFAULT_TIMER_TICK;
+static int req_timer_tick = DEFAULT_TIMER_TICK;
+static int run_timer_flag = 0;
+
+static int event_loop_wait_event = 0;
+static int event_loop_abort_on_exc = 1;
+static int loop_counter = 0;
+
+static int check_rootwidget_flag = 0;
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_ruby_eval _((ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*));
+static int ip_ruby_cmd _((ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*));
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_ruby_eval _((ClientData, Tcl_Interp *, int, char **));
+static int ip_ruby_cmd _((ClientData, Tcl_Interp *, int, char **));
+#endif
+
+/*---- class TclTkIp ----*/
+struct tcltkip {
+ Tcl_Interp *ip; /* the interpreter */
+ int has_orig_exit; /* has original 'exit' command ? */
+ Tcl_CmdInfo orig_exit_info; /* command info of original 'exit' command */
+ int ref_count; /* reference count of rbtk_preserve_ip call */
+ int allow_ruby_exit; /* allow exiting ruby by 'exit' function */
+ int return_value; /* return value */
+};
+
+static struct tcltkip *
+get_ip(self)
+ VALUE self;
+{
+ struct tcltkip *ptr;
+
+ Data_Get_Struct(self, struct tcltkip, ptr);
+ if (ptr == 0) {
+ rb_raise(rb_eTypeError, "uninitialized TclTkIp");
+ }
+ return ptr;
+}
+
+/* increment/decrement reference count of tcltkip */
+static int
+rbtk_preserve_ip(ptr)
+ struct tcltkip *ptr;
+{
+ ptr->ref_count++;
+ Tcl_Preserve((ClientData)ptr->ip);
+ return(ptr->ref_count);
+}
+
+static int
+rbtk_release_ip(ptr)
+ struct tcltkip *ptr;
+{
+ ptr->ref_count--;
+ if (ptr->ref_count < 0) {
+ ptr->ref_count = 0;
+ } else {
+ Tcl_Release((ClientData)ptr->ip);
+ }
+ return(ptr->ref_count);
+}
+
+/* call original 'exit' command */
+static void
+call_original_exit(ptr, state)
+ struct tcltkip *ptr;
+ int state;
+{
+ int thr_crit_bup;
+ Tcl_CmdInfo *info;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj *state_obj;
+#endif
+
+ if (!(ptr->has_orig_exit)) return;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_ResetResult(ptr->ip);
+
+ info = &(ptr->orig_exit_info);
+
+ /* memory allocation for arguments of this command */
+#if TCL_MAJOR_VERSION >= 8
+ state_obj = Tcl_NewIntObj(state);
+ Tcl_IncrRefCount(state_obj);
+
+ if (info->isNativeObjectProc) {
+ Tcl_Obj **argv;
+ argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3);
+ argv[0] = Tcl_NewStringObj("exit", 4);
+ argv[1] = state_obj;
+ argv[2] = (Tcl_Obj *)NULL;
+
+ ptr->return_value
+ = (*(info->objProc))(info->objClientData, ptr->ip, 2, argv);
+
+ free(argv);
+
+ } else {
+ /* string interface */
+ char **argv;
+ argv = (char **)ALLOC_N(char *, 3);
+ argv[0] = "exit";
+ argv[1] = Tcl_GetString(state_obj);
+ argv[2] = (char *)NULL;
+
+ ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
+ 2, (CONST84 char **)argv);
+
+ free(argv);
+ }
+
+ Tcl_DecrRefCount(state_obj);
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ /* string interface */
+ char **argv;
+ argv = (char **)ALLOC_N(char *, 3);
+ argv[0] = "exit";
+ argv[1] = RSTRING(rb_fix2str(INT2NUM(state), 10))->ptr;
+ argv[2] = (char *)NULL;
+
+ ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
+ 2, argv);
+
+ free(argv);
+ }
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+}
/* Tk_ThreadTimer */
-static Tcl_TimerToken timer_token;
+static Tcl_TimerToken timer_token = (Tcl_TimerToken)NULL;
/* timer callback */
+static void _timer_for_tcl _((ClientData));
static void
_timer_for_tcl(clientData)
ClientData clientData;
{
- struct invoke_queue *q, *tmp;
- VALUE thread;
+ int thr_crit_bup;
+
+ /* struct invoke_queue *q, *tmp; */
+ /* VALUE thread; */
+
+ DUMP1("called timer_for_tcl");
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
Tk_DeleteTimerHandler(timer_token);
- timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, (ClientData)0);
- CHECK_INTS;
- q = iqueue;
- while (q) {
- tmp = q;
- q = q->next;
- if (!tmp->done) {
- tmp->done = 1;
- tmp->result = ip_invoke_real(tmp->argc, tmp->argv, tmp->obj);
- thread = tmp->thread;
- tmp = tmp->next;
- rb_thread_run(thread);
- }
+ run_timer_flag = 1;
+
+ if (timer_tick > 0) {
+ timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
+ } else {
+ timer_token = (Tcl_TimerToken)NULL;
}
- rb_thread_schedule();
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* rb_thread_schedule(); */
+ /* tick_counter += event_loop_max; */
}
-/* execute Tk_MainLoop */
static VALUE
-lib_mainloop(self)
+set_eventloop_tick(self, tick)
VALUE self;
+ VALUE tick;
{
- timer_token = Tk_CreateTimerHandler(100, _timer_for_tcl, (ClientData)0);
- DUMP1("start Tk_Mainloop");
- Tk_MainLoop();
- DUMP1("stop Tk_Mainloop");
+ int ttick = NUM2INT(tick);
+ int thr_crit_bup;
+
+ rb_secure(4);
+
+ if (ttick < 0) {
+ rb_raise(rb_eArgError,
+ "timer-tick parameter must be 0 or positive number");
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* delete old timer callback */
Tk_DeleteTimerHandler(timer_token);
+ timer_tick = req_timer_tick = ttick;
+ if (timer_tick > 0) {
+ /* start timer callback */
+ timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
+ } else {
+ timer_token = (Tcl_TimerToken)NULL;
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ return tick;
+}
+
+static VALUE
+get_eventloop_tick(self)
+ VALUE self;
+{
+ return INT2NUM(timer_tick);
+}
+
+static VALUE
+ip_set_eventloop_tick(self, tick)
+ VALUE self;
+ VALUE tick;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return get_eventloop_tick(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return get_eventloop_tick(self);
+ }
+ return set_eventloop_tick(self, tick);
+}
+
+static VALUE
+ip_get_eventloop_tick(self)
+ VALUE self;
+{
+ return get_eventloop_tick(self);
+}
+
+static VALUE
+set_no_event_wait(self, wait)
+ VALUE self;
+ VALUE wait;
+{
+ int t_wait = NUM2INT(wait);
+
+ rb_secure(4);
+
+ if (t_wait <= 0) {
+ rb_raise(rb_eArgError,
+ "no_event_wait parameter must be positive number");
+ }
+
+ no_event_wait = t_wait;
+
+ return wait;
+}
+
+static VALUE
+get_no_event_wait(self)
+ VALUE self;
+{
+ return INT2NUM(no_event_wait);
+}
+
+static VALUE
+ip_set_no_event_wait(self, wait)
+ VALUE self;
+ VALUE wait;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return get_no_event_wait(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return get_no_event_wait(self);
+ }
+ return set_no_event_wait(self, wait);
+}
+
+static VALUE
+ip_get_no_event_wait(self)
+ VALUE self;
+{
+ return get_no_event_wait(self);
+}
+
+static VALUE
+set_eventloop_weight(self, loop_max, no_event)
+ VALUE self;
+ VALUE loop_max;
+ VALUE no_event;
+{
+ int lpmax = NUM2INT(loop_max);
+ int no_ev = NUM2INT(no_event);
+
+ rb_secure(4);
+
+ if (lpmax <= 0 || no_ev <= 0) {
+ rb_raise(rb_eArgError, "weight parameters must be positive numbers");
+ }
+
+ event_loop_max = lpmax;
+ no_event_tick = no_ev;
+
+ return rb_ary_new3(2, loop_max, no_event);
+}
+
+static VALUE
+get_eventloop_weight(self)
+ VALUE self;
+{
+ return rb_ary_new3(2, INT2NUM(event_loop_max), INT2NUM(no_event_tick));
+}
+
+static VALUE
+ip_set_eventloop_weight(self, loop_max, no_event)
+ VALUE self;
+ VALUE loop_max;
+ VALUE no_event;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return get_eventloop_weight(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return get_eventloop_weight(self);
+ }
+ return set_eventloop_weight(self, loop_max, no_event);
+}
+
+static VALUE
+ip_get_eventloop_weight(self)
+ VALUE self;
+{
+ return get_eventloop_weight(self);
+}
+
+static VALUE
+set_max_block_time(self, time)
+ VALUE self;
+ VALUE time;
+{
+ struct Tcl_Time tcl_time;
+ VALUE divmod;
+
+ switch(TYPE(time)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ /* time is micro-second value */
+ divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
+ tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
+ tcl_time.usec = NUM2LONG(RARRAY(divmod)->ptr[1]);
+ break;
+
+ case T_FLOAT:
+ /* time is second value */
+ divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
+ tcl_time.sec = NUM2LONG(RARRAY(divmod)->ptr[0]);
+ tcl_time.usec = (long)(NUM2DBL(RARRAY(divmod)->ptr[1]) * 1000000);
+
+ default:
+ rb_raise(rb_eArgError, "invalid value for time: '%s'",
+ RSTRING(rb_funcall(time, ID_inspect, 0, 0))->ptr);
+ }
+
+ Tcl_SetMaxBlockTime(&tcl_time);
+
return Qnil;
}
-/*---- class TclTkIp ----*/
-struct tcltkip {
- Tcl_Interp *ip; /* the interpreter */
- int return_value; /* return value */
-};
+static VALUE
+lib_evloop_abort_on_exc(self)
+ VALUE self;
+{
+ if (event_loop_abort_on_exc > 0) {
+ return Qtrue;
+ } else if (event_loop_abort_on_exc == 0) {
+ return Qfalse;
+ } else {
+ return Qnil;
+ }
+}
+
+static VALUE
+ip_evloop_abort_on_exc(self)
+ VALUE self;
+{
+ return lib_evloop_abort_on_exc(self);
+}
+
+static VALUE
+lib_evloop_abort_on_exc_set(self, val)
+ VALUE self, val;
+{
+ rb_secure(4);
+ if (RTEST(val)) {
+ event_loop_abort_on_exc = 1;
+ } else if (NIL_P(val)) {
+ event_loop_abort_on_exc = -1;
+ } else {
+ event_loop_abort_on_exc = 0;
+ }
+ return lib_evloop_abort_on_exc(self);
+}
+
+static VALUE
+ip_evloop_abort_on_exc_set(self, val)
+ VALUE self, val;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ rb_secure(4);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return lib_evloop_abort_on_exc(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return lib_evloop_abort_on_exc(self);
+ }
+ return lib_evloop_abort_on_exc_set(self, val);
+}
+
+static VALUE
+lib_num_of_mainwindows(self)
+ VALUE self;
+{
+ return INT2FIX(Tk_GetNumMainWindows());
+}
+
+static int
+lib_eventloop_core(check_root, update_flag, check_var)
+ int check_root;
+ int update_flag;
+ int *check_var;
+{
+ volatile VALUE current = eventloop_thread;
+ int found_event = 1;
+ int event_flag;
+ struct timeval t;
+ int thr_crit_bup;
+
+
+ if (update_flag) DUMP1("update loop start!!");
+
+ t.tv_sec = (time_t)0;
+ t.tv_usec = (time_t)(no_event_wait*1000.0);
+
+ Tk_DeleteTimerHandler(timer_token);
+ run_timer_flag = 0;
+ if (timer_tick > 0) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ timer_token = Tk_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
+ rb_thread_critical = thr_crit_bup;
+ } else {
+ timer_token = (Tcl_TimerToken)NULL;
+ }
+
+ for(;;) {
+ if (rb_thread_alone()) {
+ DUMP1("no other thread");
+ event_loop_wait_event = 0;
+
+ if (update_flag) {
+ event_flag = update_flag | TCL_DONT_WAIT; /* for safety */
+ } else {
+ event_flag = TCL_ALL_EVENTS;
+ }
+
+ if (timer_tick == 0 && update_flag == 0) {
+ timer_tick = NO_THREAD_INTERRUPT_TIME;
+ timer_token = Tk_CreateTimerHandler(timer_tick,
+ _timer_for_tcl,
+ (ClientData)0);
+ }
+
+ if (check_var != (int *)NULL) {
+ if (*check_var || !found_event) {
+ return found_event;
+ }
+ }
+
+ found_event = Tcl_DoOneEvent(event_flag);
+
+ if (update_flag != 0) {
+ if (found_event) {
+ DUMP1("next update loop");
+ continue;
+ } else {
+ DUMP1("update complete");
+ return 0;
+ }
+ }
+
+ DUMP1("check Root Widget");
+ if (check_root && Tk_GetNumMainWindows() == 0) {
+ run_timer_flag = 0;
+ if (!rb_prohibit_interrupt) {
+ if (rb_trap_pending) rb_trap_exec();
+ }
+ return 1;
+ }
+
+ if (loop_counter++ > 30000) {
+ /* fprintf(stderr, "loop_counter > 30000\n"); */
+ loop_counter = 0;
+ }
+
+ } else {
+ int tick_counter;
+
+ DUMP1("there are other threads");
+ event_loop_wait_event = 1;
+
+ found_event = 1;
+
+ if (update_flag) {
+ event_flag = update_flag | TCL_DONT_WAIT; /* for safety */
+ } else {
+ event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT;
+ }
+
+ timer_tick = req_timer_tick;
+ tick_counter = 0;
+ while(tick_counter < event_loop_max) {
+ if (check_var != (int *)NULL) {
+ if (*check_var || !found_event) {
+ return found_event;
+ }
+ }
+
+ if (Tcl_DoOneEvent(event_flag)) {
+ tick_counter++;
+ } else {
+ if (update_flag != 0) {
+ DUMP1("update complete");
+ return 0;
+ }
+ tick_counter += no_event_tick;
+ rb_thread_wait_for(t);
+ }
+
+ if (watchdog_thread != 0 && eventloop_thread != current) {
+ return 1;
+ }
+
+ DUMP1("check Root Widget");
+ if (check_root && Tk_GetNumMainWindows() == 0) {
+ run_timer_flag = 0;
+ if (!rb_prohibit_interrupt) {
+ if (rb_trap_pending) rb_trap_exec();
+ }
+ return 1;
+ }
+
+ DUMP1("trap check");
+ if (!rb_prohibit_interrupt) {
+ if (rb_trap_pending) rb_trap_exec();
+ }
+
+ if (loop_counter++ > 30000) {
+ /* fprintf(stderr, "loop_counter > 30000\n"); */
+ loop_counter = 0;
+ }
+
+ if (run_timer_flag) {
+ /*
+ DUMP1("timer interrupt");
+ run_timer_flag = 0;
+ */
+ break; /* switch to other thread */
+ }
+ }
+ }
+
+ DUMP1("trap check & thread scheduling");
+ if (update_flag == 0) CHECK_INTS;
+
+ }
+ return 1;
+}
+
+VALUE
+lib_eventloop_main(check_rootwidget)
+ VALUE check_rootwidget;
+{
+ check_rootwidget_flag = RTEST(check_rootwidget);
+
+ if (lib_eventloop_core(check_rootwidget_flag, 0, (int *)NULL)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+VALUE
+lib_eventloop_ensure(parent_evloop)
+ VALUE parent_evloop;
+{
+ Tk_DeleteTimerHandler(timer_token);
+ timer_token = (Tcl_TimerToken)NULL;
+ DUMP2("eventloop-ensure: current-thread : %lx\n", rb_thread_current());
+ DUMP2("eventloop-ensure: eventloop-thread : %lx\n", eventloop_thread);
+ if (eventloop_thread == rb_thread_current()) {
+ DUMP2("eventloop-thread -> %lx\n", parent_evloop);
+ eventloop_thread = parent_evloop;
+ }
+ return Qnil;
+}
+
+static VALUE
+lib_eventloop_launcher(check_rootwidget)
+ VALUE check_rootwidget;
+{
+ VALUE parent_evloop = eventloop_thread;
+
+ eventloop_thread = rb_thread_current();
+
+ if (ruby_debug) {
+ fprintf(stderr, "tcltklib: eventloop-thread : %lx -> %lx\n",
+ parent_evloop, eventloop_thread);
+ }
+
+ return rb_ensure(lib_eventloop_main, check_rootwidget,
+ lib_eventloop_ensure, parent_evloop);
+}
+
+/* execute Tk_MainLoop */
+static VALUE
+lib_mainloop(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE check_rootwidget;
+
+ if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
+ check_rootwidget = Qtrue;
+ } else if (RTEST(check_rootwidget)) {
+ check_rootwidget = Qtrue;
+ } else {
+ check_rootwidget = Qfalse;
+ }
+
+ return lib_eventloop_launcher(check_rootwidget);
+}
-/* Tcl command `ruby' */
static VALUE
-ip_eval_rescue(failed, einfo)
- VALUE *failed;
+ip_mainloop(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return Qnil;
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return Qnil;
+ }
+ return lib_mainloop(argc, argv, self);
+}
+
+VALUE
+lib_watchdog_core(check_rootwidget)
+ VALUE check_rootwidget;
+{
+ VALUE evloop;
+ int prev_val = -1;
+ int chance = 0;
+ int check = RTEST(check_rootwidget);
+ struct timeval t0, t1;
+
+ t0.tv_sec = (time_t)0;
+ t0.tv_usec = (time_t)((NO_THREAD_INTERRUPT_TIME)*1000.0);
+ t1.tv_sec = (time_t)0;
+ t1.tv_usec = (time_t)((WATCHDOG_INTERVAL)*1000.0);
+
+ /* check other watchdog thread */
+ if (watchdog_thread != 0) {
+ if (RTEST(rb_funcall(watchdog_thread, ID_stop_p, 0))) {
+ rb_funcall(watchdog_thread, ID_kill, 0);
+ } else {
+ return Qnil;
+ }
+ }
+ watchdog_thread = rb_thread_current();
+
+ /* watchdog start */
+ do {
+ if (eventloop_thread == 0
+ || (loop_counter == prev_val
+ && RTEST(rb_funcall(eventloop_thread, ID_stop_p, 0))
+ && ++chance >= 3 )
+ ) {
+ /* start new eventloop thread */
+ DUMP2("eventloop thread %lx is sleeping or dead",
+ eventloop_thread);
+ evloop = rb_thread_create(lib_eventloop_launcher,
+ (void*)&check_rootwidget);
+ DUMP2("create new eventloop thread %lx", evloop);
+ loop_counter = -1;
+ chance = 0;
+ rb_thread_run(evloop);
+ } else {
+ loop_counter = prev_val;
+ chance = 0;
+ if (event_loop_wait_event) {
+ rb_thread_wait_for(t0);
+ } else {
+ rb_thread_wait_for(t1);
+ }
+ /* rb_thread_schedule(); */
+ }
+ } while(!check || Tk_GetNumMainWindows() != 0);
+
+ return Qnil;
+}
+
+VALUE
+lib_watchdog_ensure(arg)
+ VALUE arg;
+{
+ eventloop_thread = 0; /* stop eventloops */
+ return Qnil;
+}
+
+static VALUE
+lib_mainloop_watchdog(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE check_rootwidget;
+
+ if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
+ check_rootwidget = Qtrue;
+ } else if (RTEST(check_rootwidget)) {
+ check_rootwidget = Qtrue;
+ } else {
+ check_rootwidget = Qfalse;
+ }
+
+ return rb_ensure(lib_watchdog_core, check_rootwidget,
+ lib_watchdog_ensure, Qnil);
+}
+
+static VALUE
+ip_mainloop_watchdog(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return Qnil;
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return Qnil;
+ }
+ return lib_mainloop_watchdog(argc, argv, self);
+}
+
+static VALUE
+lib_do_one_event_core(argc, argv, self, is_ip)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+ int is_ip;
+{
+ volatile VALUE vflags;
+ int flags;
+ int found_event;
+
+ if (rb_scan_args(argc, argv, "01", &vflags) == 0) {
+ flags = TCL_ALL_EVENTS | TCL_DONT_WAIT;
+ } else {
+ Check_Type(vflags, T_FIXNUM);
+ flags = FIX2INT(vflags);
+ }
+
+ if (rb_safe_level() >= 4 || (rb_safe_level() >=1 && OBJ_TAINTED(vflags))) {
+ flags |= TCL_DONT_WAIT;
+ }
+
+ if (is_ip) {
+ /* check IP */
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return Qfalse;
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ flags |= TCL_DONT_WAIT;
+ }
+ }
+
+ /* found_event = Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT); */
+ found_event = Tcl_DoOneEvent(flags);
+
+ if (found_event) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+static VALUE
+lib_do_one_event(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return lib_do_one_event_core(argc, argv, self, 0);
+}
+
+static VALUE
+ip_do_one_event(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return lib_do_one_event_core(argc, argv, self, 0);
+}
+
+
+static void
+ip_set_exc_message(interp, exc)
+ Tcl_Interp *interp;
+ VALUE exc;
+{
+ char *buf;
+ Tcl_DString dstr;
+ volatile VALUE msg;
+ int thr_crit_bup;
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
+ volatile VALUE enc;
+ Tcl_Encoding encoding;
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ msg = rb_funcall(exc, ID_message, 0, 0);
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(exc, ID_at_enc))) {
+ enc = rb_ivar_get(exc, ID_at_enc);
+ }
+ if (NIL_P(enc) && RTEST(rb_ivar_defined(msg, ID_at_enc))) {
+ enc = rb_ivar_get(msg, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else if (TYPE(enc) == T_STRING) {
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ } else {
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ }
+
+ /* to avoid a garbled error message dialog */
+ buf = ALLOC_N(char, (RSTRING(msg)->len)+1);
+ strncpy(buf, RSTRING(msg)->ptr, RSTRING(msg)->len);
+ buf[RSTRING(msg)->len] = 0;
+
+ Tcl_DStringInit(&dstr);
+ Tcl_DStringFree(&dstr);
+ Tcl_ExternalToUtfDString(encoding, buf, RSTRING(msg)->len, &dstr);
+
+ Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (char*)NULL);
+ DUMP2("error message:%s", Tcl_DStringValue(&dstr));
+ free(buf);
+
+#else /* TCL_VERSION <= 8.0 */
+ Tcl_AppendResult(interp, RSTRING(msg)->ptr, (char*)NULL);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+}
+
+static VALUE
+TkStringValue(obj)
+ VALUE obj;
+{
+ switch(TYPE(obj)) {
+ case T_STRING:
+ return obj;
+
+ case T_NIL:
+ return rb_str_new2("");
+
+ case T_TRUE:
+ return rb_str_new2("1");
+
+ case T_FALSE:
+ return rb_str_new2("0");
+
+ case T_ARRAY:
+ return rb_funcall(obj, ID_join, 1, rb_str_new2(" "));
+
+ default:
+ if (rb_respond_to(obj, ID_to_s)) {
+ return rb_funcall(obj, ID_to_s, 0, 0);
+ }
+ }
+
+ return rb_funcall(obj, ID_inspect, 0, 0);
+}
+
+/* Tcl command `ruby'|`ruby_eval' */
+static VALUE
+ip_ruby_eval_rescue(failed, einfo)
+ VALUE failed;
VALUE einfo;
{
- *failed = einfo;
+ DUMP1("call ip_ruby_eval_rescue");
+ RARRAY(failed)->ptr[0] = einfo;
return Qnil;
}
+struct eval_body_arg {
+ char *string;
+ VALUE failed;
+};
+
+static VALUE
+ip_ruby_eval_body(arg)
+ struct eval_body_arg *arg;
+{
+ volatile VALUE ret;
+ int status = 0;
+ int thr_crit_bup;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ DUMP1("call ip_ruby_eval_body");
+ rb_trap_immediate = 0;
+
+#if 0
+ ret = rb_rescue2(rb_eval_string, (VALUE)arg->string,
+ ip_ruby_eval_rescue, arg->failed,
+ rb_eStandardError, rb_eScriptError, rb_eSystemExit,
+ (VALUE)0);
+#else
+
+ rb_thread_critical = Qfalse;
+ ret = rb_eval_string_protect(arg->string, &status);
+ rb_thread_critical = Qtrue;
+ if (status) {
+ char *errtype, *buf;
+ int errtype_len, len;
+ VALUE old_gc;
+
+ old_gc = rb_gc_disable();
+
+ switch(status) {
+ case TAG_RETURN:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf);
+ free(buf);
+ break;
+
+ case TAG_BREAK:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf);
+ free(buf);
+ break;
+
+ case TAG_NEXT:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf);
+ free(buf);
+ break;
+
+ case TAG_RETRY:
+ case TAG_REDO:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(status);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_RAISE:
+ case TAG_FATAL:
+ if (NIL_P(ruby_errinfo)) {
+ RARRAY(arg->failed)->ptr[0]
+ = rb_exc_new2(rb_eException, "unknown exception");
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_THROW:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(TAG_THROW);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ default:
+ buf = ALLOC_N(char, 256);
+ sprintf(buf, "unknown loncaljmp status %d", status);
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf);
+ free(buf);
+ break;
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+
+ ret = Qnil;
+ }
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ return ret;
+}
+
+static VALUE
+ip_ruby_eval_ensure(trapflag)
+ VALUE trapflag;
+{
+ rb_trap_immediate = NUM2INT(trapflag);
+ return Qnil;
+}
+
+
static int
#if TCL_MAJOR_VERSION >= 8
-ip_ruby(clientData, interp, argc, argv)
+ip_ruby_eval(clientData, interp, argc, argv)
ClientData clientData;
Tcl_Interp *interp;
int argc;
Tcl_Obj *CONST argv[];
-#else
-ip_ruby(clientData, interp, argc, argv)
+#else /* TCL_MAJOR_VERSION < 8 */
+ip_ruby_eval(clientData, interp, argc, argv)
ClientData clientData;
Tcl_Interp *interp;
int argc;
char *argv[];
#endif
{
- VALUE res;
- int old_trapflg;
- VALUE failed = 0;
- char *arg;
- int dummy;
+ volatile VALUE res;
+ volatile VALUE exception = rb_ary_new2(1);
+ int old_trapflag;
+ struct eval_body_arg *arg;
+ int thr_crit_bup;
/* ruby command has 1 arg. */
if (argc != 2) {
- rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)",
+ argc - 1);
}
+ /* allocate */
+ arg = ALLOC(struct eval_body_arg);
+
/* get C string from Tcl object */
#if TCL_MAJOR_VERSION >= 8
- arg = Tcl_GetStringFromObj(argv[1], &dummy);
-#else
- arg = argv[1];
+ {
+ char *str;
+ int len;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ str = Tcl_GetStringFromObj(argv[1], &len);
+ arg->string = ALLOC_N(char, len + 1);
+ strncpy(arg->string, str, len);
+ arg->string[len] = 0;
+
+ rb_thread_critical = thr_crit_bup;
+
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ arg->string = argv[1];
#endif
+ /* arg.failed = 0; */
+ RARRAY(exception)->ptr[0] = Qnil;
+ RARRAY(exception)->len = 1;
+ arg->failed = exception;
/* evaluate the argument string by ruby */
- DUMP2("rb_eval_string(%s)", arg);
- old_trapflg = rb_trap_immediate;
- rb_trap_immediate = 0;
- res = rb_rescue(rb_eval_string, (VALUE)arg, ip_eval_rescue, (VALUE)&failed);
- rb_trap_immediate = old_trapflg;
+ DUMP2("rb_eval_string(%s)", arg->string);
+ old_trapflag = rb_trap_immediate;
+#ifdef HAVE_NATIVETHREAD
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on ip_ruby_eval()");
+ }
+#endif
+ res = rb_ensure(ip_ruby_eval_body, (VALUE)arg,
+ ip_ruby_eval_ensure, INT2FIX(old_trapflag));
+
+#if TCL_MAJOR_VERSION >= 8
+ free(arg->string);
+#endif
+
+ free(arg);
+
+ /* status check */
+ /* if (arg.failed) { */
+ if (!NIL_P(RARRAY(exception)->ptr[0])) {
+ VALUE eclass;
+ volatile VALUE bt_ary;
+ volatile VALUE backtrace;
+
+ DUMP1("(rb_eval_string result) failed");
+
+ Tcl_ResetResult(interp);
+
+ res = RARRAY(exception)->ptr[0];
+ eclass = rb_obj_class(res);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ DUMP1("set backtrace");
+ if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) {
+ backtrace = rb_ary_join(bt_ary, rb_str_new2("\n"));
+ StringValue(backtrace);
+ Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr);
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (eclass == eTkCallbackReturn) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
+
+ } else if (eclass == eTkCallbackBreak) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
+
+ } else if (eclass == eTkCallbackContinue) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
+
+ } else if (eclass == rb_eSystemExit) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* Tcl_Eval(interp, "destroy ."); */
+ if (Tk_GetNumMainWindows() > 0) {
+ Tk_Window main_win = Tk_MainWindow(interp);
+ if (main_win != (Tk_Window)NULL) {
+ Tk_DestroyWindow(main_win);
+ }
+ }
+
+ /* StringValue(res); */
+ res = rb_funcall(res, ID_message, 0, 0);
+
+ Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL);
+ rb_thread_critical = thr_crit_bup;
+
+ rb_raise(rb_eSystemExit, RSTRING(res)->ptr);
+
+ } else if (rb_obj_is_kind_of(res, eLocalJumpError)) {
+ VALUE reason = rb_ivar_get(res, ID_at_reason);
+
+ if (TYPE(reason) != T_SYMBOL) {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
+
+ if (SYM2ID(reason) == ID_return) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
+
+ } else if (SYM2ID(reason) == ID_break) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
+
+ } else if (SYM2ID(reason) == ID_next) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
+
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
+ }
+
+ /* result must be string or nil */
+ if (NIL_P(res)) {
+ DUMP1("(rb_eval_string result) nil");
+ Tcl_ResetResult(interp);
+ return TCL_OK;
+ }
+
+ /* copy result to the tcl interpreter */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ res = TkStringValue(res);
+ DUMP2("(rb_eval_string result) %s", RSTRING(res)->ptr);
+ DUMP1("Tcl_AppendResult");
Tcl_ResetResult(interp);
- if (failed) {
- VALUE eclass = CLASS_OF(failed);
- Tcl_AppendResult(interp, STR2CSTR(failed), (char*)NULL);
- if (eclass == eTkCallbackBreak) {
- return TCL_BREAK;
- } else if (eclass == eTkCallbackContinue) {
- return TCL_CONTINUE;
- } else {
- return TCL_ERROR;
- }
+ Tcl_AppendResult(interp, RSTRING(res)->ptr, (char *)NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+ return TCL_OK;
+}
+
+
+/* Tcl command `ruby_cmd' */
+struct cmd_body_arg {
+ VALUE receiver;
+ ID method;
+ VALUE args;
+ VALUE failed;
+};
+
+static VALUE
+ip_ruby_cmd_core(arg)
+ struct cmd_body_arg *arg;
+{
+ volatile VALUE ret;
+ int thr_crit_bup;
+
+ DUMP1("call ip_ruby_cmd_core");
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qfalse;
+ ret = rb_apply(arg->receiver, arg->method, arg->args);
+ rb_thread_critical = thr_crit_bup;
+ DUMP1("finish ip_ruby_cmd_core");
+
+ return ret;
+}
+
+static VALUE
+ip_ruby_cmd_rescue(failed, einfo)
+ VALUE failed;
+ VALUE einfo;
+{
+ DUMP1("call ip_ruby_cmd_rescue");
+ RARRAY(failed)->ptr[0] = einfo;
+ return Qnil;
+}
+
+static VALUE
+ip_ruby_cmd_body(arg)
+ struct cmd_body_arg *arg;
+{
+ volatile VALUE ret;
+ int status = 0;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ volatile VALUE receiver = arg->receiver;
+ volatile VALUE args = arg->args;
+ volatile VALUE failed = arg->failed;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ DUMP1("call ip_ruby_cmd_body");
+ rb_trap_immediate = 0;
+
+#if 0
+ ret = rb_rescue2(ip_ruby_cmd_core, (VALUE)arg,
+ ip_ruby_cmd_rescue, arg->failed,
+ rb_eStandardError, rb_eScriptError, rb_eSystemExit,
+ (VALUE)0);
+#else
+ ret = rb_protect(ip_ruby_cmd_core, (VALUE)arg, &status);
+
+ if (status) {
+ char *errtype, *buf;
+ int errtype_len, len;
+
+ old_gc = rb_gc_disable();
+
+ switch(status) {
+ case TAG_RETURN:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf);
+ free(buf);
+ break;
+
+ case TAG_BREAK:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf);
+ free(buf);
+ break;
+
+ case TAG_NEXT:
+ errtype = "LocalJumpError: ";
+ errtype_len = strlen(errtype);
+ len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
+ buf = ALLOC_N(char, len + 1);
+ strncpy(buf, errtype, errtype_len);
+ strncpy(buf + errtype_len,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
+ RSTRING(rb_obj_as_string(ruby_errinfo))->len);
+ *(buf + len) = 0;
+
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf);
+ free(buf);
+ break;
+
+ case TAG_RETRY:
+ case TAG_REDO:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(status);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_RAISE:
+ case TAG_FATAL:
+ if (NIL_P(ruby_errinfo)) {
+ RARRAY(arg->failed)->ptr[0]
+ = rb_exc_new2(rb_eException, "unknown exception");
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ case TAG_THROW:
+ if (NIL_P(ruby_errinfo)) {
+ rb_jump_tag(TAG_THROW);
+ } else {
+ RARRAY(arg->failed)->ptr[0] = ruby_errinfo;
+ }
+ break;
+
+ default:
+ buf = ALLOC_N(char, 256);
+ rb_warn(buf, "unknown loncaljmp status %d", status);
+ RARRAY(arg->failed)->ptr[0] = rb_exc_new2(rb_eException, buf);
+ free(buf);
+ break;
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+
+ ret = Qnil;
+ }
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+ DUMP1("finish ip_ruby_cmd_body");
+
+ return ret;
+}
+
+static VALUE
+ip_ruby_cmd_ensure(trapflag)
+ VALUE trapflag;
+{
+ rb_trap_immediate = NUM2INT(trapflag);
+ return Qnil;
+}
+
+/* ruby_cmd receiver method arg ... */
+static int
+#if TCL_MAJOR_VERSION >= 8
+ip_ruby_cmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+ip_ruby_cmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+{
+ volatile VALUE res;
+ volatile VALUE receiver;
+ volatile ID method;
+ volatile VALUE args = rb_ary_new2(argc - 2);
+ volatile VALUE exception = rb_ary_new2(1);
+ char *str;
+ int i;
+ int len;
+ int old_trapflag;
+ struct cmd_body_arg *arg;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ if (argc < 3) {
+ rb_raise(rb_eArgError, "too few arguments");
+ }
+
+ /* allocate */
+ arg = ALLOC(struct cmd_body_arg);
+
+ /* get arguments from Tcl objects */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ old_gc = rb_gc_disable();
+
+ /* get receiver */
+#if TCL_MAJOR_VERSION >= 8
+ str = Tcl_GetStringFromObj(argv[1], &len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ str = argv[1];
+#endif
+ DUMP2("receiver:%s",str);
+ if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) {
+ /* class | module | constant */
+ receiver = rb_const_get(rb_cObject, rb_intern(str));
+ } else if (str[0] == '$') {
+ /* global variable */
+ receiver = rb_gv_get(str);
+ } else {
+ /* global variable omitted '$' */
+ char *buf;
+
+ len = strlen(str);
+ buf = ALLOC_N(char, len + 2);
+ buf[0] = '$';
+ strncpy(buf + 1, str, len);
+ buf[len + 1] = 0;
+ receiver = rb_gv_get(buf);
+ free(buf);
+ }
+ if (NIL_P(receiver)) {
+ rb_raise(rb_eArgError, "unknown class/module/global-variable '%s'",
+ str);
+ }
+
+ /* get metrhod */
+#if TCL_MAJOR_VERSION >= 8
+ str = Tcl_GetStringFromObj(argv[2], &len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ str = argv[2];
+#endif
+ method = rb_intern(str);
+
+ /* get args */
+ RARRAY(args)->len = 0;
+ for(i = 3; i < argc; i++) {
+#if TCL_MAJOR_VERSION >= 8
+ str = Tcl_GetStringFromObj(argv[i], &len);
+ DUMP2("arg:%s",str);
+ RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP2("arg:%s",argv[i]);
+ RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]);
+#endif
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ RARRAY(exception)->ptr[0] = Qnil;
+ RARRAY(exception)->len = 1;
+
+ arg->receiver = receiver;
+ arg->method = method;
+ arg->args = args;
+ arg->failed = exception;
+
+ /* evaluate the argument string by ruby */
+ old_trapflag = rb_trap_immediate;
+#ifdef HAVE_NATIVETHREAD
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on ip_ruby_cmd()");
+ }
+#endif
+
+ res = rb_ensure(ip_ruby_cmd_body, (VALUE)arg,
+ ip_ruby_cmd_ensure, INT2FIX(old_trapflag));
+
+ free(arg);
+
+ /* status check */
+ /* if (arg.failed) { */
+ if (!NIL_P(RARRAY(exception)->ptr[0])) {
+ VALUE eclass;
+ volatile VALUE bt_ary;
+ volatile VALUE backtrace;
+
+ DUMP1("(rb_eval_cmd result) failed");
+
+ Tcl_ResetResult(interp);
+
+ res = RARRAY(exception)->ptr[0];
+ eclass = rb_obj_class(res);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ DUMP1("set backtrace");
+ if (!NIL_P(bt_ary = rb_funcall(res, ID_backtrace, 0, 0))) {
+ backtrace = rb_ary_join(bt_ary, rb_str_new2("\n"));
+ StringValue(backtrace);
+ Tcl_AddErrorInfo(interp, RSTRING(backtrace)->ptr);
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (eclass == eTkCallbackReturn) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
+
+ } else if (eclass == eTkCallbackBreak) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
+
+ } else if (eclass == eTkCallbackContinue) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
+
+ } else if (eclass == rb_eSystemExit) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* Tcl_Eval(interp, "destroy ."); */
+ if (Tk_GetNumMainWindows() > 0) {
+ Tk_Window main_win = Tk_MainWindow(interp);
+ if (main_win != (Tk_Window)NULL) {
+ Tk_DestroyWindow(main_win);
+ }
+ }
+
+ /* StringValue(res); */
+ res = rb_funcall(res, ID_message, 0, 0);
+
+ Tcl_AppendResult(interp, RSTRING(res)->ptr, (char*)NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+ rb_raise(rb_eSystemExit, RSTRING(res)->ptr);
+
+ } else if (rb_obj_is_kind_of(res, eLocalJumpError)) {
+ VALUE reason = rb_ivar_get(res, ID_at_reason);
+
+ if (TYPE(reason) != T_SYMBOL) {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
+
+ if (SYM2ID(reason) == ID_return) {
+ ip_set_exc_message(interp, res);
+ return TCL_RETURN;
+
+ } else if (SYM2ID(reason) == ID_break) {
+ ip_set_exc_message(interp, res);
+ return TCL_BREAK;
+
+ } else if (SYM2ID(reason) == ID_next) {
+ ip_set_exc_message(interp, res);
+ return TCL_CONTINUE;
+
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
+ } else {
+ ip_set_exc_message(interp, res);
+ return TCL_ERROR;
+ }
}
/* result must be string or nil */
if (NIL_P(res)) {
- DUMP1("(rb_eval_string result) nil");
- return TCL_OK;
+ DUMP1("(rb_eval_cmd result) nil");
+ Tcl_ResetResult(interp);
+ return TCL_OK;
}
+
/* copy result to the tcl interpreter */
- DUMP2("(rb_eval_string result) %s", STR2CSTR(res));
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ old_gc = rb_gc_disable();
+
+ res = TkStringValue(res);
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ DUMP2("(rb_eval_cmd result) '%s'", RSTRING(res)->ptr);
DUMP1("Tcl_AppendResult");
- Tcl_AppendResult(interp, STR2CSTR(res), (char *)NULL);
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, RSTRING(res)->ptr, (char *)NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+ DUMP1("end of ip_ruby_cmd");
+ return TCL_OK;
+}
+
+
+static int
+#if TCL_MAJOR_VERSION >= 8
+ip_InterpExitObjCmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+ip_InterpExitCommand(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+{
+ if (!Tcl_InterpDeleted(interp)) {
+ Tcl_Preserve(interp);
+ Tcl_Eval(interp, "interp eval {} {destroy .}; interp delete {}");
+ Tcl_Release(interp);
+ }
+ return TCL_OK;
+}
+
+static int
+#if TCL_MAJOR_VERSION >= 8
+ip_RubyExitObjCmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+ip_RubyExitCommand(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+{
+ int state;
+ char *cmd, *param;
+
+#if TCL_MAJOR_VERSION >= 8
+ cmd = Tcl_GetString(argv[0]);
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ char *endptr;
+ cmd = argv[0];
+#endif
+
+ if (rb_safe_level() >= 4) {
+ rb_raise(rb_eSecurityError,
+ "Insecure operation `exit' at level %d",
+ rb_safe_level());
+ } else if (Tcl_IsSafe(interp)) {
+ rb_raise(rb_eSecurityError,
+ "Insecure operation `exit' on a safe interpreter");
+#if 0
+ } else if (Tcl_GetMaster(interp) != (Tcl_Interp *)NULL) {
+ Tcl_Preserve(interp);
+ Tcl_Eval(interp, "interp eval {} {destroy .}");
+ Tcl_Eval(interp, "interp delete {}");
+ Tcl_Release(interp);
+ return TCL_OK;
+#endif
+ }
+
+ Tcl_ResetResult(interp);
+
+ switch(argc) {
+ case 1:
+ rb_exit(0); /* not return if succeed */
+
+ Tcl_AppendResult(interp,
+ "fail to call \"", cmd, "\"", (char *)NULL);
+ return TCL_ERROR;
+
+ case 2:
+#if TCL_MAJOR_VERSION >= 8
+ if (!Tcl_GetIntFromObj(interp, argv[1], &state)) {
+ return TCL_ERROR;
+ }
+ param = Tcl_GetString(argv[1]);
+#else /* TCL_MAJOR_VERSION < 8 */
+ state = (int)strtol(argv[1], &endptr, 0);
+ if (endptr) {
+ Tcl_AppendResult(interp,
+ "expected integer but got \"",
+ argv[1], "\"", (char *)NULL);
+ }
+ param = argv[1];
+#endif
+ rb_exit(state); /* not return if succeed */
+
+ Tcl_AppendResult(interp, "fail to call \"", cmd, " ",
+ param, "\"", (char *)NULL);
+ return TCL_ERROR;
+ default:
+ /* arguemnt error */
+ Tcl_AppendResult(interp,
+ "wrong number of arguments: should be \"",
+ cmd, " ?returnCode?\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+}
+
+
+/**************************/
+/* based on tclEvent.c */
+/**************************/
+
+#if 0 /*
+ Disable the following "update" and "thread_update". Bcause,
+ they don't work in a callback-proc. After calling update in
+ a callback-proc, the callback proc never be worked.
+ If the problem will be fixed in the future, may enable the
+ functions.
+ */
+/*********************/
+/* replace of update */
+/*********************/
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rbUpdateObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rbUpdateObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rbUpdateCommand _((ClientData, Tcl_Interp *, int, char *[]));
+static int
+ip_rbUpdateCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ int optionIndex;
+ int ret, done;
+ int flags = 0;
+ static CONST char *updateOptions[] = {"idletasks", (char *) NULL};
+ enum updateOptions {REGEXP_IDLETASKS};
+ char *nameString;
+ int dummy;
+
+ DUMP1("Ruby's 'update' is called");
+ if (objc == 1) {
+ flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
+
+ } else if (objc == 2) {
+ if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
+ "option", 0, &optionIndex) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum updateOptions) optionIndex) {
+ case REGEXP_IDLETASKS: {
+ flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
+ break;
+ }
+ default: {
+ Tcl_Panic("ip_rbUpdateObjCmd: bad option index to UpdateOptions");
+ }
+ }
+ } else {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]");
+#else
+# if TCL_MAJOR_VERSION >= 8
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " [ idletasks ]\"",
+ (char *) NULL);
+# else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " [ idletasks ]\"", (char *) NULL);
+# endif
+#endif
+ return TCL_ERROR;
+ }
+
+ /* call eventloop */
+#if 1
+ ret = lib_eventloop_core(0, flags, (int *)NULL); /* ignore result */
+#else
+ Tcl_UpdateObjCmd(clientData, interp, objc, objv);
+#endif
+
+ /*
+ * Must clear the interpreter's result because event handlers could
+ * have executed commands.
+ */
+
+ DUMP2("last result '%s'", Tcl_GetStringResult(interp));
+ Tcl_ResetResult(interp);
+ DUMP1("finish Ruby's 'update'");
+ return TCL_OK;
+}
+
+
+/**********************/
+/* update with thread */
+/**********************/
+struct th_update_param {
+ VALUE thread;
+ int done;
+};
+
+static void rb_threadUpdateProc _((ClientData));
+static void
+rb_threadUpdateProc(clientData)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+{
+ struct th_update_param *param = (struct th_update_param *) clientData;
+
+ DUMP1("threadUpdateProc is called");
+ param->done = 1;
+ rb_thread_wakeup(param->thread);
+
+ return;
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rb_threadUpdateObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rb_threadUpdateCommand _((ClientData, Tcl_Interp *, int,
+ char *[]));
+static int
+ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ int optionIndex;
+ int ret, done;
+ int flags = 0;
+ int dummy;
+ struct th_update_param *param;
+ static CONST char *updateOptions[] = {"idletasks", (char *) NULL};
+ enum updateOptions {REGEXP_IDLETASKS};
+ volatile VALUE current_thread = rb_thread_current();
+
+ DUMP1("Ruby's 'thread_update' is called");
+
+ if (rb_thread_alone() || eventloop_thread == current_thread) {
+#define USE_TCL_UPDATE 0
+#if TCL_MAJOR_VERSION >= 8
+# if USE_TCL_UPDATE
+ DUMP1("call Tcl_UpdateObjCmd");
+ return Tcl_UpdateObjCmd(clientData, interp, objc, objv);
+# else
+ DUMP1("call ip_rbUpdateObjCmd");
+ return ip_rbUpdateObjCmd(clientData, interp, objc, objv);
+# endif
+#else /* TCL_MAJOR_VERSION < 8 */
+# if USE_TCL_UPDATE
+ DUMP1("call ip_rbUpdateCommand");
+ return Tcl_UpdateCommand(clientData, interp, objc, objv);
+# else
+ DUMP1("call ip_rbUpdateCommand");
+ return ip_rbUpdateCommand(clientData, interp, objc, objv);
+# endif
+#endif
+ }
+
+ DUMP1("start Ruby's 'thread_update' body");
+
+ if (objc == 1) {
+ flags = TCL_ALL_EVENTS|TCL_DONT_WAIT;
+
+ } else if (objc == 2) {
+ if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions,
+ "option", 0, &optionIndex) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum updateOptions) optionIndex) {
+ case REGEXP_IDLETASKS: {
+ flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT;
+ break;
+ }
+ default: {
+ Tcl_Panic("ip_rb_threadUpdateObjCmd: bad option index to UpdateOptions");
+ }
+ }
+ } else {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]");
+#else
+# if TCL_MAJOR_VERSION >= 8
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " [ idletasks ]\"",
+ (char *) NULL);
+# else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " [ idletasks ]\"", (char *) NULL);
+# endif
+#endif
+ return TCL_ERROR;
+ }
+
+ DUMP1("pass argument check");
+
+ param = (struct th_update_param *)Tcl_Alloc(sizeof(struct th_update_param));
+ Tcl_Preserve(param);
+ param->thread = current_thread;
+ param->done = 0;
+
+ DUMP1("set idle proc");
+ Tcl_DoWhenIdle(rb_threadUpdateProc, (ClientData) param);
+
+ while(!param->done) {
+ DUMP1("wait for complete idle proc");
+ rb_thread_stop();
+ }
+
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
+
+ DUMP1("finish Ruby's 'thread_update'");
+ return TCL_OK;
+}
+#endif /* update and thread_update don't work */
+
+
+/***************************/
+/* replace of vwait/tkwait */
+/***************************/
+#if TCL_MAJOR_VERSION >= 8
+static char *VwaitVarProc _((ClientData, Tcl_Interp *,
+ CONST84 char *,CONST84 char *, int));
+static char *
+VwaitVarProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ CONST84 char *name1; /* Name of variable. */
+ CONST84 char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#else /* TCL_MAJOR_VERSION < 8 */
+static char *VwaitVarProc _((ClientData, Tcl_Interp *, char *, char *, int));
+static char *
+VwaitVarProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ char *name1; /* Name of variable. */
+ char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#endif
+{
+ int *donePtr = (int *) clientData;
+
+ *donePtr = 1;
+ return (char *) NULL;
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rbVwaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rbVwaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rbVwaitCommand _((ClientData, Tcl_Interp *, int, char *[]));
+static int
+ip_rbVwaitCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ int ret, done, foundEvent;
+ char *nameString;
+ int dummy;
+ int thr_crit_bup;
+
+ DUMP1("Ruby's 'vwait' is called");
+ Tcl_Preserve(interp);
+
+ if (objc != 2) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ /* nameString = Tcl_GetString(objv[0]); */
+ nameString = Tcl_GetStringFromObj(objv[0], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[0];
+#endif
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ nameString, " name\"", (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[1]);
+ /* nameString = Tcl_GetString(objv[1]); */
+ nameString = Tcl_GetStringFromObj(objv[1], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[1];
+#endif
+
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ done = 0;
+ foundEvent = lib_eventloop_core(/* not check root-widget */0, 0, &done);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /*
+ * Clear out the interpreter's result, since it may have been set
+ * by event handlers.
+ */
+
+ Tcl_ResetResult(interp);
+ if (!foundEvent) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_AppendResult(interp, "can't wait for variable \"", nameString,
+ "\": would wait forever", (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_OK;
+}
+
+
+/**************************/
+/* based on tkCmd.c */
+/**************************/
+#if TCL_MAJOR_VERSION >= 8
+static char *WaitVariableProc _((ClientData, Tcl_Interp *,
+ CONST84 char *,CONST84 char *, int));
+static char *
+WaitVariableProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ CONST84 char *name1; /* Name of variable. */
+ CONST84 char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#else /* TCL_MAJOR_VERSION < 8 */
+static char *WaitVariableProc _((ClientData, Tcl_Interp *,
+ char *, char *, int));
+static char *
+WaitVariableProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ char *name1; /* Name of variable. */
+ char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#endif
+{
+ int *donePtr = (int *) clientData;
+
+ *donePtr = 1;
+ return (char *) NULL;
+}
+
+static void WaitVisibilityProc _((ClientData, XEvent *));
+static void
+WaitVisibilityProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event (not used). */
+{
+ int *donePtr = (int *) clientData;
+
+ if (eventPtr->type == VisibilityNotify) {
+ *donePtr = 1;
+ }
+ if (eventPtr->type == DestroyNotify) {
+ *donePtr = 2;
+ }
+}
+
+static void WaitWindowProc _((ClientData, XEvent *));
+static void
+WaitWindowProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event. */
+{
+ int *donePtr = (int *) clientData;
+
+ if (eventPtr->type == DestroyNotify) {
+ *donePtr = 1;
+ }
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rbTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rbTkWaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rbTkWaitCommand _((ClientData, Tcl_Interp *, int, char *[]));
+static int
+ip_rbTkWaitCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ Tk_Window tkwin = (Tk_Window) clientData;
+ Tk_Window window;
+ int done, index;
+ static CONST char *optionStrings[] = { "variable", "visibility", "window",
+ (char *) NULL };
+ enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
+ char *nameString;
+ int ret, dummy;
+ int thr_crit_bup;
+
+ DUMP1("Ruby's 'tkwait' is called");
+
+ Tcl_Preserve(interp);
+
+ if (objc != 3) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " variable|visibility|window name\"",
+ (char *) NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " variable|visibility|window name\"",
+ (char *) NULL);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /*
+ if (Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ int c = objv[1][0];
+ size_t length = strlen(objv[1]);
+
+ if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VARIABLE;
+ } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VISIBILITY;
+ } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
+ index = TKWAIT_WINDOW;
+ } else {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be variable, visibility, or window",
+ (char *) NULL);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ }
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[2]);
+ /* nameString = Tcl_GetString(objv[2]); */
+ nameString = Tcl_GetStringFromObj(objv[2], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[2];
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ switch ((enum options) index) {
+ case TKWAIT_VARIABLE:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ done = 0;
+ lib_eventloop_core(check_rootwidget_flag, 0, &done);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done);
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ break;
+
+ case TKWAIT_VISIBILITY:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tk_CreateEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ done = 0;
+ lib_eventloop_core(check_rootwidget_flag, 0, &done);
+ if (done != 1) {
+ /*
+ * Note that we do not delete the event handler because it
+ * was deleted automatically when the window was destroyed.
+ */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "window \"", nameString,
+ "\" was deleted before its visibility changed",
+ (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ Tk_DeleteEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ break;
+
+ case TKWAIT_WINDOW:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tk_CreateEventHandler(window, StructureNotifyMask,
+ WaitWindowProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ done = 0;
+ lib_eventloop_core(check_rootwidget_flag, 0, &done);
+ /*
+ * Note: there's no need to delete the event handler. It was
+ * deleted automatically when the window was destroyed.
+ */
+ break;
+ }
+
+ /*
+ * Clear out the interpreter's result, since it may have been set
+ * by event handlers.
+ */
+
+ Tcl_ResetResult(interp);
+ Tcl_Release(interp);
+ return TCL_OK;
+}
+
+/****************************/
+/* vwait/tkwait with thread */
+/****************************/
+struct th_vwait_param {
+ VALUE thread;
+ int done;
+};
+
+#if TCL_MAJOR_VERSION >= 8
+static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *,
+ CONST84 char *,CONST84 char *, int));
+static char *
+rb_threadVwaitProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ CONST84 char *name1; /* Name of variable. */
+ CONST84 char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#else /* TCL_MAJOR_VERSION < 8 */
+static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *,
+ char *, char *, int));
+static char *
+rb_threadVwaitProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ char *name1; /* Name of variable. */
+ char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#endif
+{
+ struct th_vwait_param *param = (struct th_vwait_param *) clientData;
+
+ if (flags & (TCL_INTERP_DESTROYED | TCL_TRACE_DESTROYED)) {
+ param->done = -1;
+ } else {
+ param->done = 1;
+ }
+ rb_thread_wakeup(param->thread);
+
+ return (char *)NULL;
+}
+
+#define TKWAIT_MODE_VISIBILITY 1
+#define TKWAIT_MODE_DESTROY 2
+
+static void rb_threadWaitVisibilityProc _((ClientData, XEvent *));
+static void
+rb_threadWaitVisibilityProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event (not used). */
+{
+ struct th_vwait_param *param = (struct th_vwait_param *) clientData;
+
+ if (eventPtr->type == VisibilityNotify) {
+ param->done = TKWAIT_MODE_VISIBILITY;
+ }
+ if (eventPtr->type == DestroyNotify) {
+ param->done = TKWAIT_MODE_DESTROY;
+ }
+ rb_thread_wakeup(param->thread);
+}
+
+static void rb_threadWaitWindowProc _((ClientData, XEvent *));
+static void
+rb_threadWaitWindowProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event. */
+{
+ struct th_vwait_param *param = (struct th_vwait_param *) clientData;
+
+ if (eventPtr->type == DestroyNotify) {
+ param->done = TKWAIT_MODE_DESTROY;
+ }
+ rb_thread_wakeup(param->thread);
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rb_threadVwaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rb_threadVwaitCommand _((ClientData, Tcl_Interp *, int,
+ char *[]));
+static int
+ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ struct th_vwait_param *param;
+ char *nameString;
+ int ret, dummy;
+ int thr_crit_bup;
+ volatile VALUE current_thread = rb_thread_current();
+
+ DUMP1("Ruby's 'thread_vwait' is called");
+
+ if (rb_thread_alone() || eventloop_thread == current_thread) {
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("call ip_rbVwaitObjCmd");
+ return ip_rbVwaitObjCmd(clientData, interp, objc, objv);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("call ip_rbVwaitCommand");
+ return ip_rbVwaitCommand(clientData, interp, objc, objv);
+#endif
+ }
+
+ Tcl_Preserve(interp);
+
+ if (objc != 2) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ /* nameString = Tcl_GetString(objv[0]); */
+ nameString = Tcl_GetStringFromObj(objv[0], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[0];
+#endif
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ nameString, " name\"", (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[1]);
+ /* nameString = Tcl_GetString(objv[1]); */
+ nameString = Tcl_GetStringFromObj(objv[1], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[1];
+#endif
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param));
+ Tcl_Preserve(param);
+ param->thread = current_thread;
+ param->done = 0;
+
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ /* if (!param->done) { */
+ while(!param->done) {
+ rb_thread_stop();
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (param->done > 0) {
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+ }
+
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
+
+ rb_thread_critical = thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_OK;
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rb_threadTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rb_threadTkWaitCommand _((ClientData, Tcl_Interp *, int,
+ char *[]));
+static int
+ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ struct th_vwait_param *param;
+ Tk_Window tkwin = (Tk_Window) clientData;
+ Tk_Window window;
+ int index;
+ static CONST char *optionStrings[] = { "variable", "visibility", "window",
+ (char *) NULL };
+ enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
+ char *nameString;
+ int ret, dummy;
+ int thr_crit_bup;
+ volatile VALUE current_thread = rb_thread_current();
+
+ DUMP1("Ruby's 'thread_tkwait' is called");
+
+ if (rb_thread_alone() || eventloop_thread == current_thread) {
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("call ip_rbTkWaitObjCmd");
+ return ip_rbTkWaitObjCmd(clientData, interp, objc, objv);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("call rb_VwaitCommand");
+ return ip_rbTkWaitCommand(clientData, interp, objc, objv);
+#endif
+ }
+
+ Tcl_Preserve(interp);
+ Tcl_Preserve(tkwin);
+
+ if (objc != 3) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " variable|visibility|window name\"",
+ (char *) NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " variable|visibility|window name\"",
+ (char *) NULL);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ int c = objv[1][0];
+ size_t length = strlen(objv[1]);
+
+ if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VARIABLE;
+ } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VISIBILITY;
+ } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
+ index = TKWAIT_WINDOW;
+ } else {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be variable, visibility, or window",
+ (char *) NULL);
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ }
+#endif
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[2]);
+ /* nameString = Tcl_GetString(objv[2]); */
+ nameString = Tcl_GetStringFromObj(objv[2], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[2];
+#endif
+
+ param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param));
+ Tcl_Preserve(param);
+ param->thread = current_thread;
+ param->done = 0;
+
+ rb_thread_critical = thr_crit_bup;
+
+ switch ((enum options) index) {
+ case TKWAIT_VARIABLE:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ /* if (!param->done) { */
+ while(!param->done) {
+ rb_thread_stop();
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (param->done > 0) {
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ break;
+
+ case TKWAIT_VISIBILITY:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
+
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ Tcl_Preserve(window);
+
+ Tk_CreateEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ rb_threadWaitVisibilityProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* if (!param->done) { */
+ /*
+ while(!param->done) {
+ rb_thread_stop();
+ }
+ */
+ while(param->done != TKWAIT_MODE_VISIBILITY) {
+ if (param->done == TKWAIT_MODE_DESTROY) break;
+ rb_thread_stop();
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* when a window is destroyed, no need to call Tk_DeleteEventHandler */
+ if (param->done != TKWAIT_MODE_DESTROY) {
+ Tk_DeleteEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ rb_threadWaitVisibilityProc,
+ (ClientData) param);
+ }
+
+ if (param->done != 1) {
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "window \"", nameString,
+ "\" was deleted before its visibility changed",
+ (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+ Tcl_Release(window);
+
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tcl_Release(window);
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ break;
+
+ case TKWAIT_WINDOW:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ if (window == NULL) {
+ rb_thread_critical = thr_crit_bup;
+
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tcl_Preserve(window);
+
+ Tk_CreateEventHandler(window, StructureNotifyMask,
+ rb_threadWaitWindowProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* if (!param->done) { */
+ /*
+ while(!param->done) {
+ rb_thread_stop();
+ }
+ */
+ while(param->done != TKWAIT_MODE_DESTROY) {
+ rb_thread_stop();
+ }
+
+ Tcl_Release(window);
+
+ /* when a window is destroyed, no need to call Tk_DeleteEventHandler
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tk_DeleteEventHandler(window, StructureNotifyMask,
+ rb_threadWaitWindowProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+ */
+
+ break;
+ } /* end of 'switch' statement */
+
+ Tcl_Release(param);
+ Tcl_Free((char *)param);
+
+ /*
+ * Clear out the interpreter's result, since it may have been set
+ * by event handlers.
+ */
+
+ Tcl_ResetResult(interp);
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
return TCL_OK;
}
+static VALUE
+ip_thread_vwait(self, var)
+ VALUE self;
+ VALUE var;
+{
+ VALUE argv[2];
+ volatile VALUE cmd_str = rb_str_new2("thread_vwait");
+
+ argv[0] = cmd_str;
+ argv[1] = var;
+ return ip_invoke_real(2, argv, self);
+}
+
+static VALUE
+ip_thread_tkwait(self, mode, target)
+ VALUE self;
+ VALUE mode;
+ VALUE target;
+{
+ VALUE argv[3];
+ volatile VALUE cmd_str = rb_str_new2("thread_tkwait");
+
+ argv[0] = cmd_str;
+ argv[1] = mode;
+ argv[2] = target;
+ return ip_invoke_real(3, argv, self);
+}
+
/* destroy interpreter */
+VALUE del_root(ip)
+ Tcl_Interp *ip;
+{
+ Tk_Window main_win;
+
+ if (!Tcl_InterpDeleted(ip)) {
+ Tcl_Preserve(ip);
+ while((main_win = Tk_MainWindow(ip)) != (Tk_Window)NULL) {
+ DUMP1("wait main_win is destroyed");
+ Tk_DestroyWindow(main_win);
+ }
+ Tcl_Release(ip);
+ }
+ return Qnil;
+}
+
+
+static void
+delete_slaves(ip)
+ Tcl_Interp *ip;
+{
+ Tcl_Interp *slave;
+ Tcl_Obj *slave_list, *elem;
+ char *slave_name;
+ int i, len;
+
+ DUMP2("delete slaves of ip(%lx)", ip);
+
+ Tcl_Preserve(ip);
+
+ if (Tcl_Eval(ip, "info slaves") == TCL_ERROR) {
+ DUMP2("ip(%lx) cannot get a list of slave IPs", ip);
+ return;
+ }
+
+ slave_list = Tcl_GetObjResult(ip);
+ Tcl_IncrRefCount(slave_list);
+
+ if (Tcl_ListObjLength((Tcl_Interp*)NULL, slave_list, &len) == TCL_ERROR) {
+ DUMP1("slave_list is not a list object");
+ Tcl_DecrRefCount(slave_list);
+ return;
+ }
+
+ for(i = 0; i < len; i++) {
+ Tcl_ListObjIndex((Tcl_Interp*)NULL, slave_list, i, &elem);
+ Tcl_IncrRefCount(elem);
+
+ if (elem == (Tcl_Obj*)NULL) continue;
+
+ /* get slave */
+ slave_name = Tcl_GetString(elem);
+ slave = Tcl_GetSlave(ip, slave_name);
+ if (slave == (Tcl_Interp*)NULL) {
+ DUMP2("slave \"%s\" does not exist", slave_name);
+ continue;
+ }
+
+ Tcl_DecrRefCount(elem);
+
+ Tcl_Preserve(slave);
+
+ if (!Tcl_InterpDeleted(slave)) {
+ Tcl_Eval(slave, "foreach i [after info] { after cancel $i }");
+ }
+
+ /* delete slaves of slave */
+ delete_slaves(slave);
+
+ /* delete slave */
+ del_root(slave);
+ while(!Tcl_InterpDeleted(slave)) {
+ DUMP1("wait ip is deleted");
+ Tcl_DeleteInterp(slave);
+ }
+
+ Tcl_Release(slave);
+ }
+
+ Tcl_DecrRefCount(slave_list);
+
+ Tcl_Release(ip);
+}
+
static void
ip_free(ptr)
struct tcltkip *ptr;
{
- DUMP1("Tcl_DeleteInterp");
- Tcl_DeleteInterp(ptr->ip);
- free(ptr);
+ Tcl_CmdInfo info;
+ int thr_crit_bup;
+
+ DUMP2("free Tcl Interp %lx", ptr->ip);
+ if (ptr) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ DUMP2("IP ref_count = %d", ptr->ref_count);
+
+ if (!Tcl_InterpDeleted(ptr->ip)) {
+ DUMP2("IP(%lx) is not deleted", ptr->ip);
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+ delete_slaves(ptr->ip);
+
+ Tcl_ResetResult(ptr->ip);
+
+ if (Tcl_GetCommandInfo(ptr->ip, finalize_hook_name, &info)) {
+ DUMP2("call finalize hook proc '%s'", finalize_hook_name);
+ Tcl_Eval(ptr->ip, finalize_hook_name);
+ }
+
+ if (!Tcl_InterpDeleted(ptr->ip)) {
+ Tcl_Eval(ptr->ip, "foreach i [after info] {after cancel $i}");
+ }
+
+ del_root(ptr->ip);
+
+ DUMP1("delete interp");
+ while(!Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("wait ip is deleted");
+ Tcl_DeleteInterp(ptr->ip);
+ }
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ }
+
+ rbtk_release_ip(ptr);
+ DUMP2("IP ref_count = %d", ptr->ref_count);
+
+ free(ptr);
+
+ rb_thread_critical = thr_crit_bup;
+ }
+ DUMP1("complete freeing Tcl Interp");
}
/* create and initialize interpreter */
+static VALUE ip_alloc _((VALUE));
+static VALUE
+ip_alloc(self)
+ VALUE self;
+{
+ return Data_Wrap_Struct(self, 0, ip_free, 0);
+}
+
static VALUE
-ip_new(self)
+ip_init(argc, argv, self)
+ int argc;
+ VALUE *argv;
VALUE self;
{
- struct tcltkip *ptr; /* tcltkip data struct */
- VALUE obj; /* newly created object */
+ struct tcltkip *ptr; /* tcltkip data struct */
+ VALUE argv0, opts;
+ int cnt;
+ int with_tk = 1;
+ Tk_Window mainWin;
+
+ /* security check */
+ if (ruby_safe_level >= 4) {
+ rb_raise(rb_eSecurityError, "Cannot create a TclTkIp object at level %d", ruby_safe_level);
+ }
/* create object */
- obj = Data_Make_Struct(self, struct tcltkip, 0, ip_free, ptr);
+ Data_Get_Struct(self, struct tcltkip, ptr);
+ ptr = ALLOC(struct tcltkip);
+ DATA_PTR(self) = ptr;
+ ptr->ref_count = 0;
+ ptr->allow_ruby_exit = 1;
ptr->return_value = 0;
/* from Tk_Main() */
DUMP1("Tcl_CreateInterp");
ptr->ip = Tcl_CreateInterp();
+ if (ptr->ip == NULL) {
+ rb_raise(rb_eRuntimeError, "fail to create a new Tk interpreter");
+ }
+
+ rbtk_preserve_ip(ptr);
+ DUMP2("IP ref_count = %d", ptr->ref_count);
+ current_interp = ptr->ip;
+
+ ptr->has_orig_exit
+ = Tcl_GetCommandInfo(ptr->ip, "exit", &(ptr->orig_exit_info));
/* from Tcl_AppInit() */
DUMP1("Tcl_Init");
if (Tcl_Init(ptr->ip) == TCL_ERROR) {
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+#if TCL_MAJOR_VERSION >= 8
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+#endif
}
- DUMP1("Tk_Init");
- if (Tk_Init(ptr->ip) == TCL_ERROR) {
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+
+ /* set variables */
+ cnt = rb_scan_args(argc, argv, "02", &argv0, &opts);
+ switch(cnt) {
+ case 2:
+ /* options */
+ if (NIL_P(opts) || opts == Qfalse) {
+ /* without Tk */
+ with_tk = 0;
+ } else {
+ /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */
+ Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY);
+ }
+ case 1:
+ /* argv0 */
+ if (!NIL_P(argv0)) {
+ /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */
+ Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), TCL_GLOBAL_ONLY);
+ }
+ case 0:
+ /* no args */
+ ;
}
- DUMP1("Tcl_StaticPackage(\"Tk\")");
- Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
- (Tcl_PackageInitProc *) NULL);
+
+ /* from Tcl_AppInit() */
+ if (with_tk) {
+ DUMP1("Tk_Init");
+ if (Tk_Init(ptr->ip) == TCL_ERROR) {
+#if TCL_MAJOR_VERSION >= 8
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+#endif
+ }
+ DUMP1("Tcl_StaticPackage(\"Tk\")");
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
+ (Tcl_PackageInitProc *) NULL);
+#endif
+ }
+
+ /* get main window */
+ mainWin = Tk_MainWindow(ptr->ip);
+ Tk_Preserve((ClientData)mainWin);
/* add ruby command to the interpreter */
#if TCL_MAJOR_VERSION >= 8
DUMP1("Tcl_CreateObjCommand(\"ruby\")");
- Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
-#else
+ Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"ruby_eval\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"ruby_cmd\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
DUMP1("Tcl_CreateCommand(\"ruby\")");
- Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby, (ClientData)NULL,
- (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"ruby_eval\")");
+ Tcl_CreateCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"ruby_cmd\")");
+ Tcl_CreateCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* add 'interp_exit', 'ruby_exit' and replace 'exit' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"interp_exit\")");
+ Tcl_CreateObjCommand(ptr->ip, "interp_exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"ruby_exit\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby_exit", ip_RubyExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"interp_exit\")");
+ Tcl_CreateCommand(ptr->ip, "interp_exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"ruby_exit\")");
+ Tcl_CreateCommand(ptr->ip, "ruby_exit", ip_RubyExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+#if 0 /*
+ Disable the following "update" and "thread_update". Bcause,
+ they don't work in a callback-proc. After calling update in
+ a callback-proc, the callback proc never be worked.
+ If the problem will be fixed in the future, may enable the
+ functions.
+ */
+ /* replace 'update' command */
+# if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"update\")");
+ Tcl_CreateObjCommand(ptr->ip, "update", ip_rbUpdateObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+# else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"update\")");
+ Tcl_CreateCommand(ptr->ip, "update", ip_rbUpdateCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+# endif
+
+ /* add 'thread_update' command */
+# if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"thread_update\")");
+ Tcl_CreateObjCommand(ptr->ip, "thread_update", ip_rb_threadUpdateObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+# else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"thread_update\")");
+ Tcl_CreateCommand(ptr->ip, "thread_update", ip_rb_threadUpdateCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+# endif
+#endif
+
+ /* replace 'vwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"vwait\")");
+ Tcl_CreateObjCommand(ptr->ip, "vwait", ip_rbVwaitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"vwait\")");
+ Tcl_CreateCommand(ptr->ip, "vwait", ip_rbVwaitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* replace 'tkwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"tkwait\")");
+ Tcl_CreateObjCommand(ptr->ip, "tkwait", ip_rbTkWaitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"tkwait\")");
+ Tcl_CreateCommand(ptr->ip, "tkwait", ip_rbTkWaitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* add 'thread_vwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"thread_vwait\")");
+ Tcl_CreateObjCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"thread_vwait\")");
+ Tcl_CreateCommand(ptr->ip, "thread_vwait", ip_rb_threadVwaitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* add 'thread_tkwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"thread_tkwait\")");
+ Tcl_CreateObjCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"thread_tkwait\")");
+ Tcl_CreateCommand(ptr->ip, "thread_tkwait", ip_rb_threadTkWaitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ Tk_Release((ClientData)mainWin);
+
+ return self;
+}
+
+static VALUE
+ip_create_slave(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct tcltkip *master = get_ip(self);
+ struct tcltkip *slave = ALLOC(struct tcltkip);
+ VALUE safemode;
+ VALUE name;
+ int safe;
+ int thr_crit_bup;
+ Tk_Window mainWin;
+
+ /* safe-mode check */
+ if (rb_scan_args(argc, argv, "11", &name, &safemode) == 1) {
+ safemode = Qfalse;
+ }
+ if (Tcl_IsSafe(master->ip) == 1) {
+ safe = 1;
+ } else if (safemode == Qfalse || NIL_P(safemode)) {
+ safe = 0;
+ rb_secure(4);
+ } else {
+ safe = 1;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(master->ip)) {
+ DUMP1("master-ip is deleted");
+ rb_thread_critical = thr_crit_bup;
+ rb_raise(rb_eRuntimeError, "deleted master cannot create a new slave interpreter");
+ }
+
+ /* create slave-ip */
+ slave->ref_count = 0;
+ slave->allow_ruby_exit = 0;
+ slave->return_value = 0;
+
+ slave->ip = Tcl_CreateSlave(master->ip, StringValuePtr(name), safe);
+ if (slave->ip == NULL) {
+ rb_thread_critical = thr_crit_bup;
+ rb_raise(rb_eRuntimeError, "fail to create the new slave interpreter");
+ }
+ rbtk_preserve_ip(slave);
+
+ slave->has_orig_exit
+ = Tcl_GetCommandInfo(slave->ip, "exit", &(slave->orig_exit_info));
+
+ /* replace 'exit' command --> 'interp_exit' command */
+ mainWin = Tk_MainWindow(slave->ip);
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(slave->ip, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(slave->ip, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ return Data_Wrap_Struct(CLASS_OF(self), 0, ip_free, slave);
+}
+
+/* make ip "safe" */
+static VALUE
+ip_make_safe(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+ Tk_Window mainWin;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_MakeSafe(ptr->ip) == TCL_ERROR) {
+#if TCL_MAJOR_VERSION >= 8
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+#endif
+ }
+
+ ptr->allow_ruby_exit = 0;
+
+ /* replace 'exit' command --> 'interp_exit' command */
+ mainWin = Tk_MainWindow(ptr->ip);
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ return self;
+}
+
+/* is safe? */
+static VALUE
+ip_is_safe_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_IsSafe(ptr->ip)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+/* allow_ruby_exit? */
+static VALUE
+ip_allow_ruby_exit_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (ptr->allow_ruby_exit) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+/* allow_ruby_exit = mode */
+static VALUE
+ip_allow_ruby_exit_set(self, val)
+ VALUE self, val;
+{
+ struct tcltkip *ptr = get_ip(self);
+ Tk_Window mainWin;
+
+ rb_secure(4);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_IsSafe(ptr->ip)) {
+ rb_raise(rb_eSecurityError,
+ "insecure operation on a safe interpreter");
+ }
+
+ mainWin = Tk_MainWindow(ptr->ip);
+
+ if (RTEST(val)) {
+ ptr->allow_ruby_exit = 1;
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+ return Qtrue;
+
+ } else {
+ ptr->allow_ruby_exit = 0;
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+ return Qfalse;
+ }
+}
+
+/* delete interpreter */
+static VALUE
+ip_delete(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+ if (!Tcl_InterpDeleted(ptr->ip)) {
+ Tcl_Eval(ptr->ip, "foreach i [after info] { after cancel $i }");
+ }
+
+ del_root(ptr->ip);
+
+ DUMP1("delete interp");
+ while(!Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("wait ip is deleted");
+ Tcl_DeleteInterp(ptr->ip);
+ }
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+
+ return Qnil;
+}
+
+/* is deleted? */
+static VALUE
+ip_is_deleted_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+
+static VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
+create_ip_exc(VALUE interp, VALUE exc, const char *fmt, ...)
+#else
+create_ip_exc(interp, exc, fmt, va_alist)
+ VALUE interp:
+ VALUE exc;
+ const char *fmt;
+ va_dcl
#endif
+{
+ va_list args;
+ char buf[BUFSIZ];
+ VALUE einfo;
+
+ va_init_list(args,fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ buf[BUFSIZ - 1] = '\0';
+ va_end(args);
+ einfo = rb_exc_new2(exc, buf);
+ rb_ivar_set(einfo, ID_at_interp, interp);
+ Tcl_ResetResult(get_ip(interp)->ip);
+
+ return einfo;
+}
+
+static VALUE
+ip_get_result_string_obj(interp)
+ Tcl_Interp *interp;
+{
+#if TCL_MAJOR_VERSION >= 8
+ int len;
+ char *s;
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ s = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &len);
+ return(rb_tainted_str_new(s, len));
+
+# else /* TCL_VERSION >= 8.1 */
+ volatile VALUE strval;
+ Tcl_Obj *retobj = Tcl_GetObjResult(interp);
+ int thr_crit_bup;
+
+ Tcl_IncrRefCount(retobj);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (Tcl_GetCharLength(retobj) != Tcl_UniCharLen(Tcl_GetUnicode(retobj))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(retobj, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(retobj, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
- return obj;
+ rb_thread_critical = thr_crit_bup;
+
+ Tcl_DecrRefCount(retobj);
+
+ return(strval);
+
+# endif
+#else /* TCL_MAJOR_VERSION < 8 */
+ return(rb_tainted_str_new2(interp->result));
+#endif
}
/* eval string in tcl by Tcl_Eval() */
static VALUE
-ip_eval(self, str)
+ip_eval_real(self, cmd_str, cmd_len)
VALUE self;
- VALUE str;
+ char *cmd_str;
+ int cmd_len;
{
+ volatile VALUE ret;
char *s;
- char *buf; /* Tcl_Eval requires re-writable string region */
- struct tcltkip *ptr; /* tcltkip data struct */
+ int len;
+ struct tcltkip *ptr = get_ip(self);
+ int thr_crit_bup;
- /* get the data struct */
- Data_Get_Struct(self, struct tcltkip, ptr);
+#if TCL_MAJOR_VERSION >= 8
+ /* call Tcl_EvalObj() */
+ {
+ Tcl_Obj *cmd;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ cmd = Tcl_NewStringObj(cmd_str, cmd_len);
+ Tcl_IncrRefCount(cmd);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(cmd);
+ rb_thread_critical = thr_crit_bup;
+ ptr->return_value = TCL_OK;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+ ptr->return_value = Tcl_EvalObj(ptr->ip, cmd);
+ /* ptr->return_value = Tcl_GlobalEvalObj(ptr->ip, cmd); */
+ }
+
+ Tcl_DecrRefCount(cmd);
+
+ }
- /* call Tcl_Eval() */
- s = STR2CSTR(str);
- buf = ALLOCA_N(char, strlen(s)+1);
- strcpy(buf, s);
- DUMP2("Tcl_Eval(%s)", buf);
- ptr->return_value = Tcl_Eval(ptr->ip, buf);
if (ptr->return_value == TCL_ERROR) {
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ volatile VALUE exc;
+ exc = create_ip_exc(self, rb_eRuntimeError,
+ "%s", Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
}
DUMP2("(TCL_Eval result) %d", ptr->return_value);
/* pass back the result (as string) */
- return(rb_str_new2(ptr->ip->result));
+ ret = ip_get_result_string_obj(ptr->ip);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return ret;
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP2("Tcl_Eval(%s)", cmd_str);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ ptr->return_value = TCL_OK;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ptr->return_value = Tcl_Eval(ptr->ip, cmd_str);
+ /* ptr->return_value = Tcl_GlobalEval(ptr->ip, cmd_str); */
+ }
+
+ if (ptr->return_value == TCL_ERROR) {
+ volatile VALUE exc;
+ exc = create_ip_exc(self, rb_eRuntimeError, "%s", ptr->ip->result);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_exc_raise(exc);
+ }
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+
+ /* pass back the result (as string) */
+ ret = ip_get_result_string_obj(ptr->ip);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ return ret;
+#endif
+}
+
+static VALUE
+evq_safelevel_handler(arg, evq)
+ VALUE arg;
+ VALUE evq;
+{
+ struct eval_queue *q;
+
+ Data_Get_Struct(evq, struct eval_queue, q);
+ DUMP2("(safe-level handler) $SAFE = %d", q->safe_level);
+ rb_set_safe_level(q->safe_level);
+ return ip_eval_real(q->interp, q->str, q->len);
}
+int eval_queue_handler _((Tcl_Event *, int));
+int
+eval_queue_handler(evPtr, flags)
+ Tcl_Event *evPtr;
+ int flags;
+{
+ struct eval_queue *q = (struct eval_queue *)evPtr;
+ volatile VALUE ret;
+ volatile VALUE q_dat;
+
+ DUMP2("do_eval_queue_handler : evPtr = %p", evPtr);
+ DUMP2("eval queue_thread : %lx", rb_thread_current());
+ DUMP2("added by thread : %lx", q->thread);
+
+ if (*(q->done)) {
+ DUMP1("processed by another event-loop");
+ return 0;
+ } else {
+ DUMP1("process it on current event-loop");
+ }
+
+ /* process it */
+ *(q->done) = 1;
+
+ /* check safe-level */
+ if (rb_safe_level() != q->safe_level) {
+#ifdef HAVE_NATIVETHREAD
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on eval_queue_handler()");
+ }
+#endif
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
+ q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,0,q);
+ ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat),
+ ID_call, 0);
+ rb_gc_force_recycle(q_dat);
+ } else {
+ DUMP2("call eval_real (for caller thread:%lx)", q->thread);
+ DUMP2("call eval_real (current thread:%lx)", rb_thread_current());
+ ret = ip_eval_real(q->interp, q->str, q->len);
+ }
+
+ /* set result */
+ RARRAY(q->result)->ptr[0] = ret;
+
+ /* complete */
+ *(q->done) = -1;
+
+ /* back to caller */
+ DUMP2("back to caller (caller thread:%lx)", q->thread);
+ DUMP2(" (current thread:%lx)", rb_thread_current());
+ rb_thread_run(q->thread);
+ DUMP1("finish back to caller");
+
+ /* end of handler : remove it */
+ return 1;
+}
static VALUE
-ip_toUTF8(self, str, encodename)
+ip_eval(self, str)
VALUE self;
VALUE str;
+{
+ struct eval_queue *evq;
+ char *eval_str;
+ int *alloc_done;
+ int thr_crit_bup;
+ volatile VALUE current = rb_thread_current();
+ volatile VALUE ip_obj = self;
+ volatile VALUE result;
+ volatile VALUE ret;
+ Tcl_QueuePosition position;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ StringValue(str);
+ rb_thread_critical = thr_crit_bup;
+
+ if (eventloop_thread == 0 || current == eventloop_thread) {
+ if (eventloop_thread) {
+ DUMP2("eval from current eventloop %lx", current);
+ } else {
+ DUMP2("eval from thread:%lx but no eventloop", current);
+ }
+ result = ip_eval_real(self, RSTRING(str)->ptr, RSTRING(str)->len);
+ if (rb_obj_is_kind_of(result, rb_eException)) {
+ rb_exc_raise(result);
+ }
+ return result;
+ }
+
+ DUMP2("eval from thread %lx (NOT current eventloop)", current);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* allocate memory (protected from Tcl_ServiceEvent) */
+ alloc_done = (int*)ALLOC(int);
+ *alloc_done = 0;
+
+ eval_str = ALLOC_N(char, RSTRING(str)->len + 1);
+ strncpy(eval_str, RSTRING(str)->ptr, RSTRING(str)->len);
+ eval_str[RSTRING(str)->len] = 0;
+
+ /* allocate memory (freed by Tcl_ServiceEvent) */
+ evq = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue));
+ Tcl_Preserve(evq);
+
+ /* allocate result obj */
+ result = rb_ary_new2(1);
+ RARRAY(result)->ptr[0] = Qnil;
+ RARRAY(result)->len = 1;
+
+ /* construct event data */
+ evq->done = alloc_done;
+ evq->str = eval_str;
+ evq->len = RSTRING(str)->len;
+ evq->interp = ip_obj;
+ evq->result = result;
+ evq->thread = current;
+ evq->safe_level = rb_safe_level();
+ evq->ev.proc = eval_queue_handler;
+ position = TCL_QUEUE_TAIL;
+
+ /* add the handler to Tcl event queue */
+ DUMP1("add handler");
+ Tcl_QueueEvent(&(evq->ev), position);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* wait for the handler to be processed */
+ DUMP2("wait for handler (current thread:%lx)", current);
+ while(*alloc_done >= 0) {
+ rb_thread_stop();
+ }
+ DUMP2("back from handler (current thread:%lx)", current);
+
+ /* get result & free allocated memory */
+ ret = RARRAY(result)->ptr[0];
+
+ free(alloc_done);
+ free(eval_str);
+ Tcl_Release(evq);
+
+ if (rb_obj_is_kind_of(ret, rb_eException)) {
+ rb_exc_raise(ret);
+ }
+
+ return ret;
+}
+
+
+/* restart Tk */
+static VALUE
+lib_restart(self)
+ VALUE self;
+{
+ volatile VALUE exc;
+ struct tcltkip *ptr = get_ip(self);
+ int thr_crit_bup;
+
+ rb_secure(4);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+ /* destroy the root wdiget */
+ ptr->return_value = Tcl_Eval(ptr->ip, "destroy .");
+ /* ignore ERROR */
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+ Tcl_ResetResult(ptr->ip);
+
+ /* delete namespace ( tested on tk8.4.5 ) */
+ ptr->return_value = Tcl_Eval(ptr->ip, "namespace delete ::tk::msgcat");
+ /* ignore ERROR */
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+ Tcl_ResetResult(ptr->ip);
+
+ /* delete trace proc ( tested on tk8.4.5 ) */
+ ptr->return_value = Tcl_Eval(ptr->ip, "trace vdelete ::tk_strictMotif w ::tk::EventMotifBindings");
+ /* ignore ERROR */
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+ Tcl_ResetResult(ptr->ip);
+
+ /* execute Tk_Init of Tk_SafeInit */
+#if TCL_MAJOR_VERSION >= 8
+ if (Tcl_IsSafe(ptr->ip)) {
+ DUMP1("Tk_SafeInit");
+ if (Tk_SafeInit(ptr->ip) == TCL_ERROR) {
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+ } else {
+ DUMP1("Tk_Init");
+ if (Tk_Init(ptr->ip) == TCL_ERROR) {
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tk_Init");
+ if (Tk_Init(ptr->ip) == TCL_ERROR) {
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_exc_raise(exc);
+ }
+#endif
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+
+ rb_thread_critical = thr_crit_bup;
+
+ return Qnil;
+}
+
+
+static VALUE
+ip_restart(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ rb_secure(4);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return Qnil;
+ }
+ return lib_restart(self);
+}
+
+static VALUE
+lib_toUTF8_core(ip_obj, src, encodename)
+ VALUE ip_obj;
+ VALUE src;
VALUE encodename;
{
+ volatile VALUE str = src;
+
#ifdef TCL_UTF_MAX
Tcl_Interp *interp;
Tcl_Encoding encoding;
Tcl_DString dstr;
+ int taint_flag = OBJ_TAINTED(str);
struct tcltkip *ptr;
char *buf;
+ int thr_crit_bup;
+
+ if (NIL_P(ip_obj)) {
+ interp = (Tcl_Interp *)NULL;
+ } else {
+ interp = get_ip(ip_obj)->ip;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(interp)) {
+ DUMP1("ip is deleted");
+ interp = (Tcl_Interp *)NULL;
+ }
+ }
- Data_Get_Struct(self,struct tcltkip, ptr);
- interp = ptr->ip;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename));
- buf = ALLOCA_N(char,strlen(STR2CSTR(str))+1);
- strcpy(buf,STR2CSTR(str));
+ if (NIL_P(encodename)) {
+ if (TYPE(str) == T_STRING) {
+ volatile VALUE enc;
+
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(str, ID_at_enc))) {
+ enc = rb_ivar_get(str, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ if (NIL_P(ip_obj)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) {
+ enc = rb_ivar_get(ip_obj, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ StringValue(enc);
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
+ }
+ }
+ }
+ } else {
+ StringValue(enc);
+ if (strcmp(RSTRING(enc)->ptr, "binary") == 0) {
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
+ }
+ }
+ } else {
+ encoding = (Tcl_Encoding)NULL;
+ }
+ } else {
+ StringValue(encodename);
+ encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ /*
+ rb_warning("unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ */
+ rb_raise(rb_eArgError, "unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ }
+ }
+
+ StringValue(str);
+ if (!RSTRING(str)->len) {
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+
+ buf = ALLOC_N(char,(RSTRING(str)->len)+1);
+ strncpy(buf, RSTRING(str)->ptr, RSTRING(str)->len);
+ buf[RSTRING(str)->len] = 0;
Tcl_DStringInit(&dstr);
Tcl_DStringFree(&dstr);
- Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr);
+ /* Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr); */
+ Tcl_ExternalToUtfDString(encoding, buf, RSTRING(str)->len, &dstr);
+
+ /* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
str = rb_str_new2(Tcl_DStringValue(&dstr));
+ rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("utf-8"));
+ if (taint_flag) OBJ_TAINT(str);
- Tcl_FreeEncoding(encoding);
+ if (encoding != (Tcl_Encoding)NULL) {
+ Tcl_FreeEncoding(encoding);
+ }
Tcl_DStringFree(&dstr);
+
+ free(buf);
+
+ rb_thread_critical = thr_crit_bup;
#endif
+
return str;
}
static VALUE
-ip_fromUTF8(self, str, encodename)
+lib_toUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
VALUE self;
- VALUE str;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_toUTF8_core(Qnil, str, encodename);
+}
+
+static VALUE
+ip_toUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_toUTF8_core(self, str, encodename);
+}
+
+static VALUE
+lib_fromUTF8_core(ip_obj, src, encodename)
+ VALUE ip_obj;
+ VALUE src;
VALUE encodename;
{
+ volatile VALUE str = src;
+
#ifdef TCL_UTF_MAX
Tcl_Interp *interp;
Tcl_Encoding encoding;
Tcl_DString dstr;
- struct tcltkip *ptr;
+ int taint_flag = OBJ_TAINTED(str);
char *buf;
+ int thr_crit_bup;
+
+ if (NIL_P(ip_obj)) {
+ interp = (Tcl_Interp *)NULL;
+ } else {
+ interp = get_ip(ip_obj)->ip;
+ }
- Data_Get_Struct(self,struct tcltkip, ptr);
- interp = ptr->ip;
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
- encoding = Tcl_GetEncoding(interp,STR2CSTR(encodename));
- buf = ALLOCA_N(char,strlen(STR2CSTR(str))+1);
- strcpy(buf,STR2CSTR(str));
+ if (NIL_P(encodename)) {
+ volatile VALUE enc;
+
+ if (TYPE(str) == T_STRING) {
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(str, ID_at_enc))) {
+ enc = rb_ivar_get(str, ID_at_enc);
+ }
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ }
+
+ if (NIL_P(ip_obj)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(ip_obj, ID_at_enc))) {
+ enc = rb_ivar_get(ip_obj, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ StringValue(enc);
+ encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
+ } else {
+ encodename = rb_obj_dup(enc);
+ }
+ }
+ }
+
+ } else {
+ StringValue(encodename);
+
+ if (strcmp(RSTRING(encodename)->ptr, "binary") == 0) {
+ char *s;
+ int len;
+
+ s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr,
+ RSTRING(str)->len),
+ &len);
+ str = rb_tainted_str_new(s, len);
+ rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("binary"));
+
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+
+ encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
+ if (encoding == (Tcl_Encoding)NULL) {
+ /*
+ rb_warning("unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ encodename = Qnil;
+ */
+ rb_raise(rb_eArgError, "unknown encoding name '%s'",
+ RSTRING(encodename)->ptr);
+ }
+ }
+
+ StringValue(str);
+
+ if (RSTRING(str)->len == 0) {
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ }
+
+ buf = ALLOC_N(char,strlen(RSTRING(str)->ptr)+1);
+ strncpy(buf, RSTRING(str)->ptr, RSTRING(str)->len);
+ buf[RSTRING(str)->len] = 0;
Tcl_DStringInit(&dstr);
Tcl_DStringFree(&dstr);
- Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr);
+ /* Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr); */
+ Tcl_UtfToExternalDString(encoding,buf,RSTRING(str)->len,&dstr);
+
+ /* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
str = rb_str_new2(Tcl_DStringValue(&dstr));
+ rb_ivar_set(str, ID_at_enc, encodename);
+
+ if (taint_flag) OBJ_TAINT(str);
- Tcl_FreeEncoding(encoding);
+ if (encoding != (Tcl_Encoding)NULL) {
+ Tcl_FreeEncoding(encoding);
+ }
Tcl_DStringFree(&dstr);
+ free(buf);
+
+ rb_thread_critical = thr_crit_bup;
#endif
+
return str;
}
+static VALUE
+lib_fromUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_fromUTF8_core(Qnil, str, encodename);
+}
static VALUE
-ip_invoke_real(argc, argv, obj)
- int argc;
+ip_fromUTF8(argc, argv, self)
+ int argc;
VALUE *argv;
- VALUE obj;
+ VALUE self;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_fromUTF8_core(self, str, encodename);
+}
+
+static VALUE
+lib_UTF_backslash_core(self, str, all_bs)
+ VALUE self;
+ VALUE str;
+ int all_bs;
+{
+#ifdef TCL_UTF_MAX
+ char *src_buf, *dst_buf, *ptr;
+ int read_len = 0, dst_len = 0;
+ int taint_flag = OBJ_TAINTED(str);
+ int thr_crit_bup;
+
+ StringValue(str);
+ if (!RSTRING(str)->len) {
+ return str;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ src_buf = ALLOC_N(char,(RSTRING(str)->len)+1);
+ strncpy(src_buf, RSTRING(str)->ptr, RSTRING(str)->len);
+ src_buf[RSTRING(str)->len] = 0;
+
+ dst_buf = ALLOC_N(char,(RSTRING(str)->len)+1);
+
+ ptr = src_buf;
+ while(RSTRING(str)->len > ptr - src_buf) {
+ if (*ptr == '\\' && (all_bs || *(ptr + 1) == 'u')) {
+ dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len));
+ ptr += read_len;
+ } else {
+ *(dst_buf + (dst_len++)) = *(ptr++);
+ }
+ }
+
+ str = rb_str_new(dst_buf, dst_len);
+ if (taint_flag) OBJ_TAINT(str);
+
+ free(src_buf);
+ free(dst_buf);
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ return str;
+}
+
+static VALUE
+lib_UTF_backslash(self, str)
+ VALUE self;
+ VALUE str;
+{
+ return lib_UTF_backslash_core(self, str, 0);
+}
+
+static VALUE
+lib_Tcl_backslash(self, str)
+ VALUE self;
+ VALUE str;
{
- struct tcltkip *ptr; /* tcltkip data struct */
+ return lib_UTF_backslash_core(self, str, 1);
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static VALUE
+ip_invoke_core(interp, objc, objv)
+ VALUE interp;
+ int objc;
+ Tcl_Obj **objv;
+#else
+static VALUE
+ip_invoke_core(interp, argc, argv)
+ VALUE interp;
+ int argc;
+ char **argv;
+#endif
+{
+ struct tcltkip *ptr;
int i;
Tcl_CmdInfo info;
char *cmd;
- char **av = (char **)NULL;
+ char *s;
+ int len;
+ int thr_crit_bup;
+
#if TCL_MAJOR_VERSION >= 8
- Tcl_Obj **ov = (Tcl_Obj **)NULL;
+ int argc = objc;
+ char **argv = (char **)NULL;
Tcl_Obj *resultPtr;
#endif
+ /* get the command name string */
+#if TCL_MAJOR_VERSION >= 8
+ cmd = Tcl_GetStringFromObj(objv[0], &len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ cmd = argv[0];
+#endif
+
/* get the data struct */
- Data_Get_Struct(obj, struct tcltkip, ptr);
+ ptr = get_ip(interp);
- /* get the command name string */
- cmd = STR2CSTR(argv[0]);
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ }
/* map from the command name to a C procedure */
+ DUMP2("call Tcl_GetCommandInfo, %s", cmd);
if (!Tcl_GetCommandInfo(ptr->ip, cmd, &info)) {
- rb_raise(rb_eNameError, "invalid command name `%s'", cmd);
+ DUMP1("error Tcl_GetCommandInfo");
+ /* if (event_loop_abort_on_exc || cmd[0] != '.') { */
+ if (event_loop_abort_on_exc > 0) {
+ /*rb_ip_raise(obj,rb_eNameError,"invalid command name `%s'",cmd);*/
+ return create_ip_exc(interp, rb_eNameError,
+ "invalid command name `%s'", cmd);
+ } else {
+ if (event_loop_abort_on_exc < 0) {
+ rb_warning("invalid command name `%s' (ignore)", cmd);
+ } else {
+ rb_warn("invalid command name `%s' (ignore)", cmd);
+ }
+ Tcl_ResetResult(ptr->ip);
+ return rb_tainted_str_new2("");
+ }
}
+ DUMP1("end Tcl_GetCommandInfo");
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
/* memory allocation for arguments of this command */
#if TCL_MAJOR_VERSION >= 8
- if (info.isNativeObjectProc) {
- /* object interface */
- ov = (Tcl_Obj **)ALLOCA_N(Tcl_Obj *, argc+1);
- for (i = 0; i < argc; ++i) {
- char *s = STR2CSTR(argv[i]);
- ov[i] = Tcl_NewStringObj(s, strlen(s));
- Tcl_IncrRefCount(ov[i]);
- }
- ov[argc] = (Tcl_Obj *)NULL;
- }
- else
-#endif
- {
- /* string interface */
- av = (char **)ALLOCA_N(char *, argc+1);
- for (i = 0; i < argc; ++i) {
- char *s = STR2CSTR(argv[i]);
-
- av[i] = ALLOCA_N(char, strlen(s)+1);
- strcpy(av[i], s);
- }
- av[argc] = (char *)NULL;
+ if (!info.isNativeObjectProc) {
+ /* string interface */
+ argv = (char **)ALLOC_N(char *, argc+1);
+ for (i = 0; i < argc; ++i) {
+ argv[i] = Tcl_GetStringFromObj(objv[i], &len);
+ }
+ argv[argc] = (char *)NULL;
}
+#endif
Tcl_ResetResult(ptr->ip);
/* Invoke the C procedure */
#if TCL_MAJOR_VERSION >= 8
if (info.isNativeObjectProc) {
- int dummy;
- ptr->return_value = (*info.objProc)(info.objClientData,
- ptr->ip, argc, ov);
-
- /* get the string value from the result object */
- resultPtr = Tcl_GetObjResult(ptr->ip);
- Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &dummy),
- TCL_VOLATILE);
-
- for (i=0; i<argc; i++) {
- Tcl_DecrRefCount(ov[i]);
- }
+ ptr->return_value = (*info.objProc)(info.objClientData, ptr->ip,
+ objc, objv);
+#if 0
+ /* get the string value from the result object */
+ resultPtr = Tcl_GetObjResult(ptr->ip);
+ Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &len),
+ TCL_VOLATILE);
+#endif
}
else
#endif
{
- ptr->return_value = (*info.proc)(info.clientData,
- ptr->ip, argc, av);
+#if TCL_MAJOR_VERSION >= 8
+ ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
+ argc, (CONST84 char **)argv);
+
+ free(argv);
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
+ argc, argv);
+#endif
}
+ rb_thread_critical = thr_crit_bup;
+
+ /* exception on mainloop */
if (ptr->return_value == TCL_ERROR) {
- rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) {
+#if TCL_MAJOR_VERSION >= 8
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "%s", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "%s", ptr->ip->result);
+#endif
+ } else {
+ if (event_loop_abort_on_exc < 0) {
+#if TCL_MAJOR_VERSION >= 8
+ rb_warning("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_warning("%s (ignore)", ptr->ip->result);
+#endif
+ } else {
+#if TCL_MAJOR_VERSION >= 8
+ rb_warn("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_warn("%s (ignore)", ptr->ip->result);
+#endif
+ }
+ Tcl_ResetResult(ptr->ip);
+ return rb_tainted_str_new2("");
+ }
}
/* pass back the result (as string) */
- return rb_str_new2(ptr->ip->result);
+ return ip_get_result_string_obj(ptr->ip);
+}
+
+
+#if TCL_MAJOR_VERSION >= 8
+static Tcl_Obj **
+#else /* TCL_MAJOR_VERSION < 8 */
+static char **
+#endif
+alloc_invoke_arguments(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ int i;
+ VALUE v;
+ char *s;
+ int thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av = (Tcl_Obj **)NULL;
+ Tcl_Obj *resultPtr;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av = (char **)NULL;
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* memory allocation */
+#if TCL_MAJOR_VERSION >= 8
+ av = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, argc+1);
+ for (i = 0; i < argc; ++i) {
+ VALUE enc;
+
+ v = argv[i];
+ s = StringValuePtr(v);
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ av[i] = Tcl_NewStringObj(s, RSTRING(v)->len);
+# else /* TCL_VERSION >= 8.1 */
+ enc = Qnil;
+ if (RTEST(rb_ivar_defined(v, ID_at_enc))) {
+ enc = rb_ivar_get(v, ID_at_enc);
+ }
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len);
+ } else if (strlen(s) != RSTRING(v)->len) {
+ /* probably binary string */
+ av[i] = Tcl_NewByteArrayObj(s, RSTRING(v)->len);
+ } else {
+ /* probably text string */
+ av[i] = Tcl_NewStringObj(s, RSTRING(v)->len);
+ }
+# endif
+ Tcl_IncrRefCount(av[i]);
+ }
+ av[argc] = (Tcl_Obj *)NULL;
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ /* string interface */
+ av = (char **)ALLOC_N(char *, argc+1);
+ for (i = 0; i < argc; ++i) {
+ v = argv[i];
+ s = StringValuePtr(v);
+ av[i] = ALLOC_N(char, strlen(s)+1);
+ strcpy(av[i], s);
+ }
+ av[argc] = (char *)NULL;
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ return av;
+}
+
+static void
+free_invoke_arguments(argc, av)
+ int argc;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av;
+#endif
+{
+ int i;
+
+ for (i = 0; i < argc; ++i) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(av[i]);
+#else /* TCL_MAJOR_VERSION < 8 */
+ free(av[i]);
+#endif
+ }
+ free(av);
}
static VALUE
-ip_invoke(argc, argv, obj)
+ip_invoke_real(argc, argv, interp)
+ int argc;
+ VALUE *argv;
+ VALUE interp;
+{
+ VALUE v;
+ struct tcltkip *ptr; /* tcltkip data struct */
+ int i;
+ Tcl_CmdInfo info;
+ char *s;
+ int len;
+ int thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av = (Tcl_Obj **)NULL;
+ Tcl_Obj *resultPtr;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av = (char **)NULL;
+#endif
+
+ DUMP2("invoke_real called by thread:%lx", rb_thread_current());
+
+ /* allocate memory for arguments */
+ av = alloc_invoke_arguments(argc, argv);
+
+ /* get the data struct */
+ ptr = get_ip(interp);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ }
+
+ /* Invoke the C procedure */
+ Tcl_ResetResult(ptr->ip);
+ v = ip_invoke_core(interp, argc, av);
+
+ /* free allocated memory */
+ free_invoke_arguments(argc, av);
+
+ return v;
+}
+
+VALUE
+ivq_safelevel_handler(arg, ivq)
+ VALUE arg;
+ VALUE ivq;
+{
+ struct invoke_queue *q;
+
+ Data_Get_Struct(ivq, struct invoke_queue, q);
+ DUMP2("(safe-level handler) $SAFE = %d", q->safe_level);
+ rb_set_safe_level(q->safe_level);
+ return ip_invoke_core(q->interp, q->argc, q->argv);
+}
+
+int invoke_queue_handler _((Tcl_Event *, int));
+int
+invoke_queue_handler(evPtr, flags)
+ Tcl_Event *evPtr;
+ int flags;
+{
+ struct invoke_queue *q = (struct invoke_queue *)evPtr;
+ volatile VALUE ret;
+ volatile VALUE q_dat;
+
+ DUMP2("do_invoke_queue_handler : evPtr = %p", evPtr);
+ DUMP2("invoke queue_thread : %lx", rb_thread_current());
+ DUMP2("added by thread : %lx", q->thread);
+
+ if (*(q->done)) {
+ DUMP1("processed by another event-loop");
+ return 0;
+ } else {
+ DUMP1("process it on current event-loop");
+ }
+
+ /* process it */
+ *(q->done) = 1;
+
+ /* check safe-level */
+ if (rb_safe_level() != q->safe_level) {
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
+ q_dat = Data_Wrap_Struct(rb_cData,invoke_queue_mark,0,q);
+ ret = rb_funcall(rb_proc_new(ivq_safelevel_handler, q_dat),
+ ID_call, 0);
+ rb_gc_force_recycle(q_dat);
+ } else {
+ DUMP2("call invoke_real (for caller thread:%lx)", q->thread);
+ DUMP2("call invoke_real (current thread:%lx)", rb_thread_current());
+ ret = ip_invoke_core(q->interp, q->argc, q->argv);
+ }
+
+ /* set result */
+ RARRAY(q->result)->ptr[0] = ret;
+
+ /* complete */
+ *(q->done) = -1;
+
+ /* back to caller */
+ DUMP2("back to caller (caller thread:%lx)", q->thread);
+ DUMP2(" (current thread:%lx)", rb_thread_current());
+ rb_thread_run(q->thread);
+ DUMP1("finish back to caller");
+
+ /* end of handler : remove it */
+ return 1;
+}
+
+static VALUE
+ip_invoke_with_position(argc, argv, obj, position)
int argc;
VALUE *argv;
VALUE obj;
+ Tcl_QueuePosition position;
{
- struct invoke_queue *tmp, *p;
- VALUE result = rb_thread_current();
+ struct invoke_queue *ivq;
+ char *s;
+ int len;
+ int i;
+ int *alloc_done;
+ int thr_crit_bup;
+ volatile VALUE current = rb_thread_current();
+ volatile VALUE ip_obj = obj;
+ volatile VALUE result;
+ volatile VALUE ret;
- if (result == main_thread) {
- return ip_invoke_real(argc, argv, obj);
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av = (Tcl_Obj **)NULL;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av = (char **)NULL;
+#endif
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "command name missing");
+ }
+ if (eventloop_thread == 0 || current == eventloop_thread) {
+ if (eventloop_thread) {
+ DUMP2("invoke from current eventloop %lx", current);
+ } else {
+ DUMP2("invoke from thread:%lx but no eventloop", current);
+ }
+ result = ip_invoke_real(argc, argv, ip_obj);
+ if (rb_obj_is_kind_of(result, rb_eException)) {
+ rb_exc_raise(result);
+ }
+ return result;
}
- tmp = ALLOC(struct invoke_queue);
- tmp->obj = obj;
- tmp->argc = argc;
- tmp->argv = ALLOC_N(VALUE, argc);
- MEMCPY(tmp->argv, argv, VALUE, argc);
- tmp->thread = result;
- tmp->done = 0;
- tmp->next = iqueue;
- iqueue = tmp;
+ DUMP2("invoke from thread %lx (NOT current eventloop)", current);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* allocate memory (for arguments) */
+ av = alloc_invoke_arguments(argc, argv);
+
+ /* allocate memory (keep result) */
+ alloc_done = (int*)ALLOC(int);
+ *alloc_done = 0;
+
+ /* allocate memory (freed by Tcl_ServiceEvent) */
+ ivq = (struct invoke_queue *)Tcl_Alloc(sizeof(struct invoke_queue));
+ Tcl_Preserve(ivq);
- rb_thread_stop();
- result = tmp->result;
- if (iqueue == tmp) {
- iqueue = tmp->next;
- free(tmp->argv);
- free(tmp);
- return result;
+ /* allocate result obj */
+ result = rb_ary_new2(1);
+ RARRAY(result)->ptr[0] = Qnil;
+ RARRAY(result)->len = 1;
+
+ /* construct event data */
+ ivq->done = alloc_done;
+ ivq->argc = argc;
+ ivq->argv = av;
+ ivq->interp = ip_obj;
+ ivq->result = result;
+ ivq->thread = current;
+ ivq->safe_level = rb_safe_level();
+ ivq->ev.proc = invoke_queue_handler;
+
+ /* add the handler to Tcl event queue */
+ DUMP1("add handler");
+ Tcl_QueueEvent(&(ivq->ev), position);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* wait for the handler to be processed */
+ DUMP2("wait for handler (current thread:%lx)", current);
+ while(*alloc_done >= 0) {
+ rb_thread_stop();
}
+ DUMP2("back from handler (current thread:%lx)", current);
- p = iqueue;
- while (p->next) {
- if (p->next == tmp) {
- p->next = tmp->next;
- free(tmp->argv);
- free(tmp);
- break;
- }
- p = p->next;
+ /* get result & free allocated memory */
+ ret = RARRAY(result)->ptr[0];
+ free(alloc_done);
+
+ Tcl_Release(ivq);
+
+ /* free allocated memory */
+ free_invoke_arguments(argc, av);
+
+ /* exception? */
+ if (rb_obj_is_kind_of(ret, rb_eException)) {
+ DUMP1("raise exception");
+ rb_exc_raise(ret);
}
- return result;
+
+ DUMP1("exit ip_invoke");
+ return ret;
}
+
/* get return code from Tcl_Eval() */
static VALUE
ip_retval(self)
VALUE self;
{
- struct tcltkip *ptr; /* tcltkip data struct */
+ struct tcltkip *ptr; /* tcltkip data struct */
/* get the data strcut */
- Data_Get_Struct(self, struct tcltkip, ptr);
+ ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ }
return (INT2FIX(ptr->return_value));
}
+static VALUE
+ip_invoke(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ return ip_invoke_with_position(argc, argv, obj, TCL_QUEUE_TAIL);
+}
+
+static VALUE
+ip_invoke_immediate(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ return ip_invoke_with_position(argc, argv, obj, TCL_QUEUE_HEAD);
+}
+
+/* access Tcl variables */
+static VALUE
+ip_get_variable(self, varname_arg, flag_arg)
+ VALUE self;
+ VALUE varname_arg;
+ VALUE flag_arg;
+{
+ struct tcltkip *ptr = get_ip(self);
+ int thr_crit_bup;
+ volatile VALUE varname, flag;
+
+ varname = varname_arg;
+ flag = flag_arg;
+
+ StringValue(varname);
+
+#if TCL_MAJOR_VERSION >= 8
+ {
+ Tcl_Obj *nameobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
+ Tcl_IncrRefCount(nameobj);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjGetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL,
+ FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
+#if TCL_MAJOR_VERSION >= 8
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+#endif
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+
+ Tcl_IncrRefCount(ret);
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return(strval);
+
+# else /* TCL_VERSION >= 8.1 */
+ if (Tcl_GetCharLength(ret)
+ != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
+
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+# endif
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ char *ret;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr,
+ (char*)NULL, FIX2INT(flag));
+ }
+
+ if (ret == (char*)NULL) {
+ volatile VALUE exc;
+#if TCL_MAJOR_VERSION >= 8
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+#endif
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+
+ strval = rb_tainted_str_new2(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#endif
+}
+
+static VALUE
+ip_get_variable2(self, varname_arg, index_arg, flag_arg)
+ VALUE self;
+ VALUE varname_arg;
+ VALUE index_arg;
+ VALUE flag_arg;
+{
+ struct tcltkip *ptr = get_ip(self);
+ int thr_crit_bup;
+ volatile VALUE varname, index, flag;
+
+ if (NIL_P(index_arg)) {
+ return ip_get_variable(self, varname_arg, flag_arg);
+ }
+
+ varname = varname_arg;
+ index = index_arg;
+ flag = flag_arg;
+
+ StringValue(varname);
+ StringValue(index);
+
+#if TCL_MAJOR_VERSION >= 8
+ {
+ Tcl_Obj *nameobj, *idxobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
+ Tcl_IncrRefCount(nameobj);
+ idxobj = Tcl_NewStringObj(RSTRING(index)->ptr, RSTRING(index)->len);
+ Tcl_IncrRefCount(idxobj);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjGetVar2(ptr->ip, nameobj, idxobj, FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
+#if TCL_MAJOR_VERSION >= 8
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+#endif
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+
+ Tcl_IncrRefCount(ret);
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return(strval);
+
+# else /* TCL_VERSION >= 8.1 */
+ if (Tcl_GetCharLength(ret)
+ != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_tainted_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
+
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+# endif
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ char *ret;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr,
+ RSTRING(index)->ptr, FIX2INT(flag));
+ }
+
+ if (ret == (char*)NULL) {
+ volatile VALUE exc;
+#if TCL_MAJOR_VERSION >= 8
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+#endif
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+
+ strval = rb_tainted_str_new2(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#endif
+}
+
+static VALUE
+ip_set_variable(self, varname_arg, value_arg, flag_arg)
+ VALUE self;
+ VALUE varname_arg;
+ VALUE value_arg;
+ VALUE flag_arg;
+{
+ struct tcltkip *ptr = get_ip(self);
+ int thr_crit_bup;
+ volatile VALUE varname, value, flag;
+
+ varname = varname_arg;
+ value = value_arg;
+ flag = flag_arg;
+
+ StringValue(varname);
+ StringValue(value);
+
+#if TCL_MAJOR_VERSION >= 8
+ {
+ Tcl_Obj *nameobj, *valobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
+
+ Tcl_IncrRefCount(nameobj);
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ Tcl_IncrRefCount(valobj);
+# else /* TCL_VERSION >= 8.1 */
+ {
+ volatile VALUE enc = Qnil;
+
+ if (RTEST(rb_ivar_defined(value, ID_at_enc))) {
+ enc = rb_ivar_get(value, ID_at_enc);
+ }
+
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) {
+ /* probably binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else {
+ /* probably text string */
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ }
+
+ Tcl_IncrRefCount(valobj);
+ }
+# endif
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(valobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjSetVar2(ptr->ip, nameobj, (Tcl_Obj*)NULL, valobj,
+ FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(valobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
+#if TCL_MAJOR_VERSION >= 8
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+#endif
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+
+ Tcl_IncrRefCount(ret);
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+# else /* TCL_VERSION >= 8.1 */
+ {
+ VALUE old_gc;
+
+ old_gc = rb_gc_disable();
+
+ if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
+ if (old_gc == Qfalse) rb_gc_enable();
+ }
+# endif
+
+ Tcl_DecrRefCount(ret);
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ CONST char *ret;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr, (char*)NULL,
+ RSTRING(value)->ptr, (int)FIX2INT(flag));
+ }
+
+ if (ret == NULL) {
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ }
+
+ strval = rb_tainted_str_new2(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#endif
+}
+
+static VALUE
+ip_set_variable2(self, varname_arg, index_arg, value_arg, flag_arg)
+ VALUE self;
+ VALUE varname_arg;
+ VALUE index_arg;
+ VALUE value_arg;
+ VALUE flag_arg;
+{
+ struct tcltkip *ptr = get_ip(self);
+ int thr_crit_bup;
+ volatile VALUE varname, index, value, flag;
+
+ if (NIL_P(index_arg)) {
+ return ip_set_variable(self, varname_arg, value_arg, flag_arg);
+ }
+
+ varname = varname_arg;
+ index = index_arg;
+ value = value_arg;
+ flag = flag_arg;
+
+ StringValue(varname);
+ StringValue(index);
+ StringValue(value);
+
+#if TCL_MAJOR_VERSION >= 8
+ {
+ Tcl_Obj *nameobj, *idxobj, *valobj, *ret;
+ char *s;
+ int len;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ nameobj = Tcl_NewStringObj(RSTRING(varname)->ptr,
+ RSTRING(varname)->len);
+ Tcl_IncrRefCount(nameobj);
+
+ idxobj = Tcl_NewStringObj(RSTRING(index)->ptr,
+ RSTRING(index)->len);
+ Tcl_IncrRefCount(idxobj);
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+# else /* TCL_VERSION >= 8.1 */
+ {
+ VALUE enc = Qnil;
+
+ if (RTEST(rb_ivar_defined(value, ID_at_enc))) {
+ enc = rb_ivar_get(value, ID_at_enc);
+ }
+
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else if (strlen(RSTRING(value)->ptr) != RSTRING(value)->len) {
+ /* probably binary string */
+ valobj = Tcl_NewByteArrayObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ } else {
+ /* probably text string */
+ valobj = Tcl_NewStringObj(RSTRING(value)->ptr,
+ RSTRING(value)->len);
+ }
+ }
+
+# endif
+ Tcl_IncrRefCount(valobj);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+ Tcl_DecrRefCount(valobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_ObjSetVar2(ptr->ip, nameobj, idxobj, valobj,
+ FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(nameobj);
+ Tcl_DecrRefCount(idxobj);
+ Tcl_DecrRefCount(valobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
+#if TCL_MAJOR_VERSION >= 8
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ exc = rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+#endif
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ rb_exc_raise(exc);
+ }
+
+ Tcl_IncrRefCount(ret);
+
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+# else /* TCL_VERSION >= 8.1 */
+ if (Tcl_GetCharLength(ret) != Tcl_UniCharLen(Tcl_GetUnicode(ret))) {
+ /* possibly binary string */
+ s = Tcl_GetByteArrayFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ rb_ivar_set(strval, ID_at_enc, rb_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(ret, &len);
+ strval = rb_tainted_str_new(s, len);
+ }
+# endif
+
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ CONST char *ret;
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr,
+ RSTRING(index)->ptr,
+ RSTRING(value)->ptr, FIX2INT(flag));
+ }
+
+ if (ret == (char*)NULL) {
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+ }
+
+ Tcl_IncrRefCount(ret);
+
+ strval = rb_tainted_str_new2(ret);
+
+ Tcl_DecrRefCount(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#endif
+}
+
+static VALUE
+ip_unset_variable(self, varname_arg, flag_arg)
+ VALUE self;
+ VALUE varname_arg;
+ VALUE flag_arg;
+{
+ struct tcltkip *ptr = get_ip(self);
+ volatile VALUE varname, value, flag;
+
+ varname = varname_arg;
+ flag = flag_arg;
+
+ StringValue(varname);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return Qtrue;
+ }
+
+ ptr->return_value = Tcl_UnsetVar(ptr->ip, RSTRING(varname)->ptr,
+ FIX2INT(flag));
+ if (ptr->return_value == TCL_ERROR) {
+ if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
+#if TCL_MAJOR_VERSION >= 8
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+#endif
+ }
+ return Qfalse;
+ }
+ return Qtrue;
+}
+
+static VALUE
+ip_unset_variable2(self, varname_arg, index_arg, flag_arg)
+ VALUE self;
+ VALUE varname_arg;
+ VALUE index_arg;
+ VALUE flag_arg;
+{
+ struct tcltkip *ptr = get_ip(self);
+ volatile VALUE varname, index, value, flag;
+
+ if (NIL_P(index_arg)) {
+ return ip_unset_variable(self, varname_arg, flag_arg);
+ }
+
+ varname = varname_arg;
+ index = index_arg;
+ flag = flag_arg;
+
+ StringValue(varname);
+ StringValue(index);
+
+ /* ip is deleted? */
+ if (Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("ip is deleted");
+ return Qtrue;
+ }
+
+ ptr->return_value = Tcl_UnsetVar2(ptr->ip, RSTRING(varname)->ptr,
+ RSTRING(index)->ptr, FIX2INT(flag));
+ if (ptr->return_value == TCL_ERROR) {
+ if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
+#if TCL_MAJOR_VERSION >= 8
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
+#endif
+ }
+ return Qfalse;
+ }
+ return Qtrue;
+}
+
+static VALUE
+ip_get_global_var(self, varname)
+ VALUE self;
+ VALUE varname;
+{
+ return ip_get_variable(self, varname,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_get_global_var2(self, varname, index)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+{
+ return ip_get_variable2(self, varname, index,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_set_global_var(self, varname, value)
+ VALUE self;
+ VALUE varname;
+ VALUE value;
+{
+ return ip_set_variable(self, varname, value,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_set_global_var2(self, varname, index, value)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+ VALUE value;
+{
+ return ip_set_variable2(self, varname, index, value,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_unset_global_var(self, varname)
+ VALUE self;
+ VALUE varname;
+{
+ return ip_unset_variable(self, varname,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_unset_global_var2(self, varname, index)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+{
+ return ip_unset_variable2(self, varname, index,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+
+/* treat Tcl_List */
+static VALUE
+lib_split_tklist_core(ip_obj, list_str)
+ VALUE ip_obj;
+ VALUE list_str;
+{
+ Tcl_Interp *interp;
+ volatile VALUE ary, elem;
+ int idx;
+ int taint_flag = OBJ_TAINTED(list_str);
+ int result;
+ VALUE old_gc;
+
+ if (NIL_P(ip_obj)) {
+ interp = (Tcl_Interp *)NULL;
+ } else {
+ interp = get_ip(ip_obj)->ip;
+ }
+
+ StringValue(list_str);
+
+ {
+#if TCL_MAJOR_VERSION >= 8
+ /* object style interface */
+ Tcl_Obj *listobj;
+ int objc;
+ Tcl_Obj **objv;
+ int thr_crit_bup;
+
+# if 1
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+# else /* TCL_VERSION >= 8.1 */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ {
+ VALUE enc = Qnil;
+
+ if (RTEST(rb_ivar_defined(list_str, ID_at_enc))) {
+ enc = rb_ivar_get(list_str, ID_at_enc);
+ }
+
+ if (!NIL_P(enc) && strcmp(StringValuePtr(enc), "binary") == 0) {
+ /* binary string */
+ listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+ } else if (strlen(RSTRING(list_str)->ptr)
+ != RSTRING(list_str)->len) {
+ /* probably binary string */
+ listobj = Tcl_NewByteArrayObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+ } else {
+ /* probably text string */
+ listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+ }
+ }
+
+ rb_thread_critical = thr_crit_bup;
+# endif
+# else
+ listobj = Tcl_NewStringObj(RSTRING(list_str)->ptr,
+ RSTRING(list_str)->len);
+# endif
+
+ Tcl_IncrRefCount(listobj);
+
+ result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv);
+
+ if (result == TCL_ERROR) {
+ Tcl_DecrRefCount(listobj);
+ if (interp == (Tcl_Interp*)NULL) {
+ rb_raise(rb_eRuntimeError, "cannot get elements from list");
+ } else {
+#if TCL_MAJOR_VERSION >= 8
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp));
+#else /* TCL_MAJOR_VERSION < 8 */
+ rb_raise(rb_eRuntimeError, "%s", interp->result);
+#endif
+ }
+ }
+
+ for(idx = 0; idx < objc; idx++) {
+ Tcl_IncrRefCount(objv[idx]);
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ ary = rb_ary_new2(objc);
+ if (taint_flag) OBJ_TAINT(ary);
+
+ old_gc = rb_gc_disable();
+
+ for(idx = 0; idx < objc; idx++) {
+ char *str;
+ int len;
+
+# if 1
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ str = Tcl_GetStringFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
+# else /* TCL_VERSION >= 8.1 */
+ if (Tcl_GetCharLength(objv[idx])
+ != Tcl_UniCharLen(Tcl_GetUnicode(objv[idx]))) {
+ /* possibly binary string */
+ str = Tcl_GetByteArrayFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
+ rb_ivar_set(elem, ID_at_enc, rb_tainted_str_new2("binary"));
+ } else {
+ /* possibly text string */
+ str = Tcl_GetStringFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
+ }
+# endif
+# else
+ str = Tcl_GetStringFromObj(objv[idx], &len);
+ elem = rb_str_new(str, len);
+# endif
+
+ if (taint_flag) OBJ_TAINT(elem);
+ RARRAY(ary)->ptr[idx] = elem;
+ }
+
+ RARRAY(ary)->len = objc;
+
+ if (old_gc == Qfalse) rb_gc_enable();
+
+ rb_thread_critical = thr_crit_bup;
+
+ for(idx = 0; idx < objc; idx++) {
+ Tcl_DecrRefCount(objv[idx]);
+ }
+
+ Tcl_DecrRefCount(listobj);
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ /* string style interface */
+ int argc;
+ char **argv;
+
+ if (Tcl_SplitList(interp, RSTRING(list_str)->ptr,
+ &argc, &argv) == TCL_ERROR) {
+ if (interp == (Tcl_Interp*)NULL) {
+ rb_raise(rb_eRuntimeError, "cannot get elements from list");
+ } else {
+ rb_raise(rb_eRuntimeError, "%s", interp->result);
+ }
+ }
+
+ ary = rb_ary_new2(argc);
+ if (taint_flag) OBJ_TAINT(ary);
+
+ old_gc = rb_gc_disable();
+
+ for(idx = 0; idx < argc; idx++) {
+ if (taint_flag) {
+ elem = rb_tainted_str_new2(argv[idx]);
+ } else {
+ elem = rb_str_new2(argv[idx]);
+ }
+ /* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */
+ RARRAY(ary)->ptr[idx] = elem;
+ }
+ RARRAY(ary)->len = argc;
+
+ if (old_gc == Qfalse) rb_gc_enable();
+#endif
+ }
+
+ return ary;
+}
+
+static VALUE
+lib_split_tklist(self, list_str)
+ VALUE self;
+ VALUE list_str;
+{
+ return lib_split_tklist_core(Qnil, list_str);
+}
+
+
+static VALUE
+ip_split_tklist(self, list_str)
+ VALUE self;
+ VALUE list_str;
+{
+ return lib_split_tklist_core(self, list_str);
+}
+
+static VALUE
+lib_merge_tklist(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ int num, len;
+ int *flagPtr;
+ char *dst, *result;
+ volatile VALUE str;
+ int taint_flag = 0;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ if (argc == 0) return rb_str_new2("");
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ old_gc = rb_gc_disable();
+
+ /* based on Tcl/Tk's Tcl_Merge() */
+ flagPtr = ALLOC_N(int, argc);
+
+ /* pass 1 */
+ len = 1;
+ for(num = 0; num < argc; num++) {
+ if (OBJ_TAINTED(argv[num])) taint_flag = 1;
+ dst = StringValuePtr(argv[num]);
+#if TCL_MAJOR_VERSION >= 8
+ len += Tcl_ScanCountedElement(dst, RSTRING(argv[num])->len,
+ &flagPtr[num]) + 1;
+#else /* TCL_MAJOR_VERSION < 8 */
+ len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
+#endif
+ }
+
+ /* pass 2 */
+ result = (char *)Tcl_Alloc(len);
+ dst = result;
+ for(num = 0; num < argc; num++) {
+#if TCL_MAJOR_VERSION >= 8
+ len = Tcl_ConvertCountedElement(RSTRING(argv[num])->ptr,
+ RSTRING(argv[num])->len,
+ dst, flagPtr[num]);
+#else /* TCL_MAJOR_VERSION < 8 */
+ len = Tcl_ConvertElement(RSTRING(argv[num])->ptr, dst, flagPtr[num]);
+#endif
+ dst += len;
+ *dst = ' ';
+ dst++;
+ }
+ if (dst == result) {
+ *dst = 0;
+ } else {
+ dst[-1] = 0;
+ }
+
+ free(flagPtr);
+
+ /* create object */
+ str = rb_str_new(result, dst - result - 1);
+ if (taint_flag) OBJ_TAINT(str);
+ Tcl_Free(result);
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ return str;
+}
+
+static VALUE
+lib_conv_listelement(self, src)
+ VALUE self;
+ VALUE src;
+{
+ int len, scan_flag;
+ volatile VALUE dst;
+ int taint_flag = OBJ_TAINTED(src);
+ int thr_crit_bup;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ StringValue(src);
+
+#if TCL_MAJOR_VERSION >= 8
+ len = Tcl_ScanCountedElement(RSTRING(src)->ptr, RSTRING(src)->len,
+ &scan_flag);
+ dst = rb_str_new(0, len + 1);
+ len = Tcl_ConvertCountedElement(RSTRING(src)->ptr, RSTRING(src)->len,
+ RSTRING(dst)->ptr, scan_flag);
+#else /* TCL_MAJOR_VERSION < 8 */
+ len = Tcl_ScanElement(RSTRING(src)->ptr, &scan_flag);
+ dst = rb_str_new(0, len + 1);
+ len = Tcl_ConvertElement(RSTRING(src)->ptr, RSTRING(dst)->ptr, scan_flag);
+#endif
+
+ RSTRING(dst)->len = len;
+ RSTRING(dst)->ptr[len] = '\0';
+ if (taint_flag) OBJ_TAINT(dst);
+
+ rb_thread_critical = thr_crit_bup;
+
+ return dst;
+}
+
+
#ifdef __MACOS__
static void
_macinit()
@@ -490,38 +6167,205 @@ _macinit()
void
Init_tcltklib()
{
+ int thr_crit_bup;
+
VALUE lib = rb_define_module("TclTkLib");
VALUE ip = rb_define_class("TclTkIp", rb_cObject);
+ VALUE ev_flag = rb_define_module_under(lib, "EventFlag");
+ VALUE var_flag = rb_define_module_under(lib, "VarAccessFlag");
+
+ /* --------------------------------------------------------------- */
+
#if defined USE_TCL_STUBS && defined USE_TK_STUBS
extern int ruby_tcltk_stubs();
int ret = ruby_tcltk_stubs();
+
if (ret)
- rb_raise(rb_eLoadError, "tcltklib: tcltk_stubs init error(%d)", ret);
+ rb_raise(rb_eLoadError, "tcltklib: tcltk_stubs init error(%d)", ret);
#endif
+ /* --------------------------------------------------------------- */
+
+ rb_global_variable(&eTkCallbackReturn);
+ rb_global_variable(&eTkCallbackBreak);
+ rb_global_variable(&eTkCallbackContinue);
+
+ rb_global_variable(&eventloop_thread);
+ rb_global_variable(&watchdog_thread);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_const(lib, "FINALIZE_PROC_NAME",
+ rb_str_new2(finalize_hook_name));
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_const(ev_flag, "NONE", INT2FIX(0));
+ rb_define_const(ev_flag, "WINDOW", INT2FIX(TCL_WINDOW_EVENTS));
+ rb_define_const(ev_flag, "FILE", INT2FIX(TCL_FILE_EVENTS));
+ rb_define_const(ev_flag, "TIMER", INT2FIX(TCL_TIMER_EVENTS));
+ rb_define_const(ev_flag, "IDLE", INT2FIX(TCL_IDLE_EVENTS));
+ rb_define_const(ev_flag, "ALL", INT2FIX(TCL_ALL_EVENTS));
+ rb_define_const(ev_flag, "DONT_WAIT", INT2FIX(TCL_DONT_WAIT));
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_const(var_flag, "NONE", INT2FIX(0));
+ rb_define_const(var_flag, "GLOBAL_ONLY", INT2FIX(TCL_GLOBAL_ONLY));
+#ifdef TCL_NAMESPACE_ONLY
+ rb_define_const(var_flag, "NAMESPACE_ONLY", INT2FIX(TCL_NAMESPACE_ONLY));
+#else /* probably Tcl7.6 */
+ rb_define_const(var_flag, "NAMESPACE_ONLY", INT2FIX(0));
+#endif
+ rb_define_const(var_flag, "LEAVE_ERR_MSG", INT2FIX(TCL_LEAVE_ERR_MSG));
+ rb_define_const(var_flag, "APPEND_VALUE", INT2FIX(TCL_APPEND_VALUE));
+ rb_define_const(var_flag, "LIST_ELEMENT", INT2FIX(TCL_LIST_ELEMENT));
+#ifdef TCL_PARSE_PART1
+ rb_define_const(var_flag, "PARSE_VARNAME", INT2FIX(TCL_PARSE_PART1));
+#else /* probably Tcl7.6 */
+ rb_define_const(var_flag, "PARSE_VARNAME", INT2FIX(0));
+#endif
+
+ /* --------------------------------------------------------------- */
+
+ eTkCallbackBreak = rb_define_class("TkCallbackReturn", rb_eStandardError);
eTkCallbackBreak = rb_define_class("TkCallbackBreak", rb_eStandardError);
- eTkCallbackContinue = rb_define_class("TkCallbackContinue",rb_eStandardError);
+ eTkCallbackContinue = rb_define_class("TkCallbackContinue",
+ rb_eStandardError);
+
+ /* --------------------------------------------------------------- */
+
+ eLocalJumpError = rb_const_get(rb_cObject, rb_intern("LocalJumpError"));
+
+ ID_at_enc = rb_intern("@encoding");
+ ID_at_interp = rb_intern("@interp");
+
+ ID_stop_p = rb_intern("stop?");
+ ID_kill = rb_intern("kill");
+ ID_join = rb_intern("join");
+
+ ID_call = rb_intern("call");
+ ID_backtrace = rb_intern("backtrace");
+ ID_message = rb_intern("message");
+
+ ID_at_reason = rb_intern("@reason");
+ ID_return = rb_intern("return");
+ ID_break = rb_intern("break");
+ ID_next = rb_intern("next");
- rb_define_module_function(lib, "mainloop", lib_mainloop, 0);
+ ID_to_s = rb_intern("to_s");
+ ID_inspect = rb_intern("inspect");
- rb_define_singleton_method(ip, "new", ip_new, 0);
+ /* --------------------------------------------------------------- */
+
+ rb_define_module_function(lib, "mainloop", lib_mainloop, -1);
+ rb_define_module_function(lib, "mainloop_watchdog",
+ lib_mainloop_watchdog, -1);
+ rb_define_module_function(lib, "do_one_event", lib_do_one_event, -1);
+ rb_define_module_function(lib, "mainloop_abort_on_exception",
+ lib_evloop_abort_on_exc, 0);
+ rb_define_module_function(lib, "mainloop_abort_on_exception=",
+ lib_evloop_abort_on_exc_set, 1);
+ rb_define_module_function(lib, "set_eventloop_tick",set_eventloop_tick,1);
+ rb_define_module_function(lib, "get_eventloop_tick",get_eventloop_tick,0);
+ rb_define_module_function(lib, "set_no_event_wait", set_no_event_wait, 1);
+ rb_define_module_function(lib, "get_no_event_wait", get_no_event_wait, 0);
+ rb_define_module_function(lib, "set_eventloop_weight",
+ set_eventloop_weight, 2);
+ rb_define_module_function(lib, "set_max_block_time", set_max_block_time,1);
+ rb_define_module_function(lib, "get_eventloop_weight",
+ get_eventloop_weight, 0);
+ rb_define_module_function(lib, "num_of_mainwindows",
+ lib_num_of_mainwindows, 0);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_module_function(lib, "_split_tklist", lib_split_tklist, 1);
+ rb_define_module_function(lib, "_merge_tklist", lib_merge_tklist, -1);
+ rb_define_module_function(lib, "_conv_listelement",
+ lib_conv_listelement, 1);
+ rb_define_module_function(lib, "_toUTF8", lib_toUTF8, -1);
+ rb_define_module_function(lib, "_fromUTF8", lib_fromUTF8, -1);
+ rb_define_module_function(lib, "_subst_UTF_backslash",
+ lib_UTF_backslash, 1);
+ rb_define_module_function(lib, "_subst_Tcl_backslash",
+ lib_Tcl_backslash, 1);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_alloc_func(ip, ip_alloc);
+ rb_define_method(ip, "initialize", ip_init, -1);
+ rb_define_method(ip, "create_slave", ip_create_slave, -1);
+ rb_define_method(ip, "make_safe", ip_make_safe, 0);
+ rb_define_method(ip, "safe?", ip_is_safe_p, 0);
+ rb_define_method(ip, "allow_ruby_exit?", ip_allow_ruby_exit_p, 0);
+ rb_define_method(ip, "allow_ruby_exit=", ip_allow_ruby_exit_set, 1);
+ rb_define_method(ip, "delete", ip_delete, 0);
+ rb_define_method(ip, "deleted?", ip_is_deleted_p, 0);
rb_define_method(ip, "_eval", ip_eval, 1);
- rb_define_method(ip, "_toUTF8",ip_toUTF8,2);
- rb_define_method(ip, "_fromUTF8",ip_fromUTF8,2);
+ rb_define_method(ip, "_toUTF8", ip_toUTF8, -1);
+ rb_define_method(ip, "_fromUTF8", ip_fromUTF8, -1);
+ rb_define_method(ip, "_thread_vwait", ip_thread_vwait, 1);
+ rb_define_method(ip, "_thread_tkwait", ip_thread_tkwait, 2);
rb_define_method(ip, "_invoke", ip_invoke, -1);
rb_define_method(ip, "_return_value", ip_retval, 0);
- rb_define_method(ip, "mainloop", lib_mainloop, 0);
- main_thread = rb_thread_current();
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "_get_variable", ip_get_variable, 2);
+ rb_define_method(ip, "_get_variable2", ip_get_variable2, 3);
+ rb_define_method(ip, "_set_variable", ip_set_variable, 3);
+ rb_define_method(ip, "_set_variable2", ip_set_variable2, 4);
+ rb_define_method(ip, "_unset_variable", ip_unset_variable, 2);
+ rb_define_method(ip, "_unset_variable2", ip_unset_variable2, 3);
+ rb_define_method(ip, "_get_global_var", ip_get_global_var, 1);
+ rb_define_method(ip, "_get_global_var2", ip_get_global_var2, 2);
+ rb_define_method(ip, "_set_global_var", ip_set_global_var, 2);
+ rb_define_method(ip, "_set_global_var2", ip_set_global_var2, 3);
+ rb_define_method(ip, "_unset_global_var", ip_unset_global_var, 1);
+ rb_define_method(ip, "_unset_global_var2", ip_unset_global_var2, 2);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "_split_tklist", ip_split_tklist, 1);
+ rb_define_method(ip, "_merge_tklist", lib_merge_tklist, -1);
+ rb_define_method(ip, "_conv_listelement", lib_conv_listelement, 1);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "mainloop", ip_mainloop, -1);
+ rb_define_method(ip, "mainloop_watchdog", ip_mainloop_watchdog, -1);
+ rb_define_method(ip, "do_one_event", ip_do_one_event, -1);
+ rb_define_method(ip, "mainloop_abort_on_exception",
+ ip_evloop_abort_on_exc, 0);
+ rb_define_method(ip, "mainloop_abort_on_exception=",
+ ip_evloop_abort_on_exc_set, 1);
+ rb_define_method(ip, "set_eventloop_tick", ip_set_eventloop_tick, 1);
+ rb_define_method(ip, "get_eventloop_tick", ip_get_eventloop_tick, 0);
+ rb_define_method(ip, "set_no_event_wait", ip_set_no_event_wait, 1);
+ rb_define_method(ip, "get_no_event_wait", ip_get_no_event_wait, 0);
+ rb_define_method(ip, "set_eventloop_weight", ip_set_eventloop_weight, 2);
+ rb_define_method(ip, "get_eventloop_weight", ip_get_eventloop_weight, 0);
+ rb_define_method(ip, "set_max_block_time", set_max_block_time, 1);
+ rb_define_method(ip, "restart", ip_restart, 0);
+
+ /* --------------------------------------------------------------- */
+
+ eventloop_thread = 0;
+ watchdog_thread = 0;
+
+ /* --------------------------------------------------------------- */
+
#ifdef __MACOS__
_macinit();
#endif
- /*---- initialize tcl/tk libraries ----*/
/* from Tk_Main() */
DUMP1("Tcl_FindExecutable");
Tcl_FindExecutable(RSTRING(rb_argv0)->ptr);
+
+ /* --------------------------------------------------------------- */
}
/* eof */
diff --git a/ext/tk/.cvsignore b/ext/tk/.cvsignore
index f3c7a7c5da..44e7f262dc 100644
--- a/ext/tk/.cvsignore
+++ b/ext/tk/.cvsignore
@@ -1 +1,3 @@
Makefile
+mkmf.log
+*.log
diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib
new file mode 100644
index 0000000000..6386f727f6
--- /dev/null
+++ b/ext/tk/ChangeLog.tkextlib
@@ -0,0 +1,87 @@
+2004-11-03 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * SUPPORT_STATUS: BLT moves to 'plan to support' from 'not determined'
+
+ * itk/incr_tk.rb: __cget_cmd and __config_cmd are private methods
+
+ * tcllib/autoscroll.rb: extend TkCore
+
+ * tcllib/cursor.rb: ditto.
+
+ * tcllib/plotchart.rb: ditto.
+
+ * tcllib/style.rb: ditto.
+
+ * tile/style.rb: ditto.
+
+ * tkDND/shape.rb: ditto.
+
+2004-10-24 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bwidget/tree.rb: bug fix on Windows
+
+2004-10-16 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * tcllib/ico.rb: new library (Tk::Tcllib:ICO)
+
+ * tcllib.rb: add Tk::Tcllib::ICO (based on tcllib 1.7)
+
+2004-10-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bwidget.rb (BWidget.grab): bug fix
+
+ * tcllib.rb: typo fix
+
+2004-07-28 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * add winico support
+
+2004-07-23 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * add TclX support (partially; infox command and XPG/3 MsgCat only)
+
+2004-07-15 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bug fix
+
+ * support TkTable extension
+
+2004-07-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bug fix
+
+ * support Iwidgets extension
+
+2004-07-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bug fix
+
+ * add more part of [incr Widget] support (about 65%? are complete)
+
+ * use Tk::ValidateConfigure.__def_validcmd() method
+ (new function to define validatecommand methods easier)
+
+ * tcllib.rb : avoid the loading trouble that almost all part of
+ the extension is not available when some libraries are invalid.
+
+2004-07-09 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * add some part of [incr Widget] support (about 50%? are complete)
+
+2004-07-07 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * add [incr Tck], [incr Tk] support
+
+2004-07-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * support BWidget extension
+
+ * add BWidget extension demo
+
+ * add ICONS extension demo
+
+ * many bug fix
+
+2004-07-01 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * 1st release of tkextlib ( to support Tcl/Tk extensions )
diff --git a/ext/tk/MANIFEST b/ext/tk/MANIFEST
deleted file mode 100644
index 9689186bf0..0000000000
--- a/ext/tk/MANIFEST
+++ /dev/null
@@ -1,25 +0,0 @@
-MANIFEST
-extconf.rb
-depend
-tkutil.c
-lib/tk.rb
-lib/tkafter.rb
-lib/tkbgerror.rb
-lib/tkcanvas.rb
-lib/tkclass.rb
-lib/tkdialog.rb
-lib/tkentry.rb
-lib/tkfont.rb
-lib/tkmenubar.rb
-lib/tkmngfocus.rb
-lib/tkpalette.rb
-lib/tkscrollbox.rb
-lib/tktext.rb
-lib/tkvirtevent.rb
-sample/tkbiff.rb
-sample/tkbrowse.rb
-sample/tkdialog.rb
-sample/tkfrom.rb
-sample/tkhello.rb
-sample/tkline.rb
-sample/tktimer.rb
diff --git a/ext/tk/README.1st b/ext/tk/README.1st
new file mode 100644
index 0000000000..038528e553
--- /dev/null
+++ b/ext/tk/README.1st
@@ -0,0 +1,23 @@
+If you want to use Ruby/Tk (tk.rb and so on), you must have
+tcltklib.so which is working collectry. If you fail to call
+'require "tcltklib"', you may not have tcltklib.so.
+( see also README files of tcltklib )
+Even if there is a tcltklib.so on your Ruby library directry,
+it will not work without Tcl/Tk libraries (e.g. libtcl8.4.so)
+on your environment. You must also check that your Tcl/Tk is
+installed properly.
+
+--------------------------------------------
+ ( the following is written in EUC-JP )
+
+Ruby/Tk (tk.rb ¤Ê¤É) ¤ò»È¤¤¤¿¤¤¾ì¹ç¤Ë¤Ï¡¤tcltklib.so ¤¬Àµ¤·¤¯
+ư¤¤¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡¥¤â¤· require "tcltklib" ¤Ë¼ºÇÔ¤¹¤ë
+¤è¤¦¤Ê¤é¡¤tcltklib.so ¤¬Â¸ºß¤·¤Æ¤¤¤Ê¤¤¤Î¤«¤â¤·¤ì¤Þ¤»¤ó¡¥
+( tcltklib ¤Î README ¥Õ¥¡¥¤¥ë¤â¸«¤Æ¤¯¤À¤µ¤¤ )
+¤¿¤È¤¨ Ruby ¤Î¥é¥¤¥Ö¥é¥ê¥Ç¥£¥ì¥¯¥È¥ê¤Ë tcltklib.so ¤¬Â¸ºß¤·¤Æ
+¤¤¤¿¤È¤·¤Æ¤â¡¤¼Â¹Ô´Ä¶­¤Ë Tcl/Tk ¥é¥¤¥Ö¥é¥ê (libtcl8.4.so ¤Ê¤É)
+¤¬¤Ê¤±¤ì¤Ðµ¡Ç½¤·¤Þ¤»¤ó¡¥Tcl/Tk ¤¬Àµ¤·¤¯¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¤«
+¤É¤¦¤«¤â¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡¥
+
+==========================================================
+ Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/ext/tk/README.fork b/ext/tk/README.fork
new file mode 100644
index 0000000000..707d78fc12
--- /dev/null
+++ b/ext/tk/README.fork
@@ -0,0 +1,34 @@
+Ruby/Tk does NOT support forking the process on which Tk interpreter
+is running (unless NEVER control Tk interpreter under the forked child
+process). In the library 'tk.rb', a Tk interpreter is initialized.
+Therefore, if you want running Tk under a child process, please call
+"require 'tk'" in the child process.
+
+# If do fork and exec(<new Ruby/Tk>) on the child process, you can
+# control Ruby/Tk interpreter on the child process by 'send' command
+# of Tcl/Tk. About this, please see Tk.appsend and Tk.rb_appsend, or
+# 'remote-tk.rb' and the sample 'sample/remote-ip_sample.rb'.
+
+For example, the following sample1 will NOT work, and sample2 will
+work properly.
+
+---<sample1: NOT work>---------------------------------------
+require 'tk' ## init Tk interpreter under parent process
+
+exit! if fork ## exit parent process
+
+## child process
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack
+Tk.mainloop
+-------------------------------------------------------------
+
+---<sample2: will work>--------------------------------------
+exit! if fork ## exit main process
+
+## child process
+require 'tk' ## init Tk interpreter under child process
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack
+Tk.mainloop
+-------------------------------------------------------------
+
+ 2004/05/22 Hidetoshi NAGAI
diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb
index f769b06e30..8b10353d1a 100644
--- a/ext/tk/extconf.rb
+++ b/ext/tk/extconf.rb
@@ -1,2 +1,4 @@
require 'mkmf'
+$preload = ["tcltklib"]
+($INSTALLFILES||=[]) << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
create_makefile("tkutil")
diff --git a/ext/tk/lib/README b/ext/tk/lib/README
new file mode 100644
index 0000000000..5918fe4bf0
--- /dev/null
+++ b/ext/tk/lib/README
@@ -0,0 +1,30 @@
+README this file
+multi-tk.rb multiple Tk interpreter (included safe-Tk) support
+remotei-tk.rb control remote Tk interpreter on the other process support
+tk.rb Tk interface
+
+tk/ library files construct Ruby/Tk
+
+tkextlib/ non-standard Tcl/Tk extension support libraries
+
+*********************************************************************
+*** The followings exists for backward compatibility only.
+*** The only thing which they work is that requires current
+*** library files ( tk/*.rb ).
+*********************************************************************
+tkafter.rb handles Tcl after
+tkbgerror.rb Tk error module
+tkcanvas.rb Tk canvas interface
+tkclass.rb provides generic names for Tk classes
+tkconsole.rb console command support
+tkdialog.rb Tk dialog class
+tkentry.rb Tk entry class
+tkfont.rb Tk font support
+tkmacpkg.rb Mac resource support
+tkmenubar.rb TK menubar utility
+tkmngfocus.rb focus manager
+tkpalette.rb pallete support
+tkscrollbox.rb scroll box, also example of compound widget
+tktext.rb text classes
+tkvirtevent.rb virtual event support
+tkwinpkg.rb Win DDE and registry support
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb
new file mode 100644
index 0000000000..38e4b28dec
--- /dev/null
+++ b/ext/tk/lib/multi-tk.rb
@@ -0,0 +1,2381 @@
+#
+# multi-tk.rb - supports multi Tk interpreters
+# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+require 'tcltklib'
+require 'tkutil'
+require 'thread'
+
+if defined? Tk
+ fail RuntimeError, "'multi-tk' library must be required before requiring 'tk'"
+end
+
+################################################
+# ignore exception on the mainloop?
+
+TclTkLib.mainloop_abort_on_exception = true
+# TclTkLib.mainloop_abort_on_exception = false
+# TclTkLib.mainloop_abort_on_exception = nil
+
+
+################################################
+# add ThreadGroup check to TclTkIp.new
+class << TclTkIp
+ alias __new__ new
+ private :__new__
+
+ def new(*args)
+ if Thread.current.group != ThreadGroup::Default
+ raise SecurityError, 'only ThreadGroup::Default can call TclTkIp.new'
+ end
+ __new__(*args)
+ end
+end
+
+
+################################################
+# exceptiopn to treat the return value from IP
+class MultiTkIp_OK < Exception
+ def self.send(thread, ret=nil)
+ thread.raise self.new(ret)
+ end
+
+ def initialize(ret=nil)
+ super('succeed')
+ @return_value = ret
+ end
+
+ attr_reader :return_value
+ alias value return_value
+end
+MultiTkIp_OK.freeze
+
+
+################################################
+# methods for construction
+class MultiTkIp
+ SLAVE_IP_ID = ['slave'.freeze, '0'.taint].freeze
+
+ @@IP_TABLE = {}.taint unless defined?(@@IP_TABLE)
+
+ @@INIT_IP_ENV = [].taint unless defined?(@@INIT_IP_ENV) # table of Procs
+ @@ADD_TK_PROCS = [].taint unless defined?(@@ADD_TK_PROCS) # table of [name, args, body]
+
+ @@TK_TABLE_LIST = [].taint unless defined?(@@TK_TABLE_LIST)
+
+ @@TK_CMD_TBL = {}.taint unless defined?(@@TK_CMD_TBL)
+
+ ######################################
+
+ @@CB_ENTRY_CLASS = Class.new(TkCallbackEntry){|c|
+ def initialize(ip, cmd)
+ @ip = ip
+ @cmd = cmd
+ end
+ attr_reader :ip, :cmd
+ def inspect
+ cmd.inspect
+ end
+ def call(*args)
+ begin
+ unless @ip.deleted?
+ @ip.cb_eval(@cmd, *args)
+ end
+ rescue TkCallbackBreak, TkCallbackContinue => e
+ fail e
+ rescue Exception => e
+ if @ip.safe?
+ # ignore
+ else
+ fail e
+ end
+ end
+ end
+ }.freeze
+
+ ######################################
+
+ def _keys2opts(src_keys)
+ return nil if src_keys == nil
+ keys = {}; src_keys.each{|k, v| keys[k.to_s] = v}
+ #keys.collect{|k,v| "-#{k} #{v}"}.join(' ')
+ keys.collect{|k,v| "-#{k} #{TclTkLib._conv_listelement(TkComm::_get_eval_string(v))}"}.join(' ')
+ end
+ private :_keys2opts
+
+ def _check_and_return(thread, exception, wait=0)
+ unless thread
+ unless exception.kind_of?(MultiTkIp_OK) || safe?
+ msg = "#{exception.class}: #{exception.message}"
+ begin
+ if @interp.deleted?
+ warn('Warning: ' + msg)
+ elsif @interp._eval_without_enc('info command bgerror').size != 0
+ @interp._eval(@interp._merge_tklist('bgerror', msg))
+ else
+ warn('Warning: ' + msg)
+ end
+ rescue Exception => e
+ warn('Warning: ' + msg)
+ warn('Warning: ' + e.message)
+ end
+ end
+ return nil
+ end
+
+ if wait == 0
+ # no wait
+ Thread.pass
+ if thread.stop?
+ thread.raise exception
+ end
+ return thread
+ end
+
+ # wait to stop the caller thread
+ wait.times{
+ if thread.stop?
+ # ready to send exception
+ thread.raise exception
+ return thread
+ end
+
+ # wait
+ Thread.pass
+ }
+
+ # unexpected error
+ thread.raise RuntimeError, "the thread may not wait for the return value"
+ return thread
+ end
+
+ ######################################
+
+ def set_safe_level(safe)
+ if safe > @safe_level[0]
+ @safe_level[0] = safe
+ @cmd_queue.enq([@system, 'set_safe_level', safe])
+ end
+ @safe_level[0]
+ end
+ def safe_level=(safe)
+ set_safe_level(safe)
+ end
+ def self.set_safe_level(safe)
+ __getip.set_safe_level(safe)
+ end
+ def self.safe_level=(safe)
+ self.set_safe_level(safe)
+ end
+ def safe_level
+ @safe_level[0]
+ end
+ def self.safe_level
+ __getip.safe_level
+ end
+
+ def wait_on_mainloop?
+ @wait_on_mainloop[0]
+ end
+ def wait_on_mainloop=(bool)
+ @wait_on_mainloop[0] = bool
+ end
+
+ def running_mainloop?
+ @wait_on_mainloop[1]
+ end
+
+ def _destroy_slaves_of_slaveIP(ip)
+ unless ip.deleted?
+ ip._split_tklist(ip._invoke('interp', 'slaves')).each{|name|
+ begin
+ ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}")
+ rescue Exception
+ end
+ begin
+ # ip._invoke('interp', 'eval', name, 'destroy', '.')
+ ip._invoke(name, 'eval', 'destroy', '.')
+ rescue Exception
+ end
+
+ # safe_base?
+ if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ ip._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ end
+ end
+=begin
+ if ip._invoke('interp', 'exists', name) == '1'
+ begin
+ ip._invoke(name, 'eval', 'exit')
+ rescue Exception
+ end
+ end
+=end
+ unless ip.deleted?
+ if ip._invoke('interp', 'exists', name) == '1'
+ begin
+ ip._invoke('interp', 'delete', name)
+ rescue Exception
+ end
+ end
+ end
+ }
+ end
+ end
+
+ def _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ begin
+ #ret = proc{$SAFE = safe_level; cmd.call(*args)}.call
+ ret = cmd.call(safe_level, *args)
+
+ rescue SystemExit => e
+ # delete IP
+ unless @interp.deleted?
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+ begin
+ subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
+=begin
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
+=end
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ else
+ @interp.delete unless @interp.deleted?
+ end
+ end
+
+ if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/
+ _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit'))
+ else
+ _check_and_return(thread, MultiTkIp_OK.new(nil))
+ end
+
+ if master? && !safe? && allow_ruby_exit?
+=begin
+ ObjectSpace.each_object(TclTkIp){|obj|
+ obj.delete unless obj.deleted?
+ }
+=end
+ #exit(e.status)
+ fail e
+ end
+ # break
+
+ rescue SecurityError => e
+ # in 'exit', 'exit!', and 'abort' : security error --> delete IP
+ if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/
+ ret = ($3 == 'exit')
+ unless @interp.deleted?
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+ begin
+ subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
+=begin
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
+=end
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
+=begin
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
+=end
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ else
+ @interp.delete unless @interp.deleted?
+ end
+ end
+ _check_and_return(thread, MultiTkIp_OK.new(ret))
+ # break
+
+ else
+ # raise security error
+ _check_and_return(thread, e)
+ end
+
+ rescue Exception => e
+ # raise exception
+ _check_and_return(thread, e)
+
+ else
+ # no exception
+ _check_and_return(thread, MultiTkIp_OK.new(ret))
+ end
+ end
+
+ def _receiver_eval_proc(last_thread, safe_level, thread, cmd, *args)
+ if thread
+ Thread.new{
+ last_thread.join if last_thread
+ unless @interp.deleted?
+ _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ end
+ }
+ else
+ Thread.new{
+ unless @interp.deleted?
+ _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ end
+ }
+ last_thread
+ end
+ end
+
+ private :_receiver_eval_proc, :_receiver_eval_proc_core
+
+ def _receiver_mainloop(check_root)
+ Thread.new{
+ while !@interp.deleted?
+ break if @interp._invoke_without_enc('info', 'command', '.').size == 0
+ sleep 0.5
+ end
+ }
+ end
+
+ def _create_receiver_and_watchdog(lvl = $SAFE)
+ lvl = $SAFE if lvl < $SAFE
+
+ # command-procedures receiver
+ receiver = Thread.new(lvl){|safe_level|
+ last_thread = nil
+
+ loop do
+ break if @interp.deleted?
+ thread, cmd, *args = @cmd_queue.deq
+ if thread == @system
+ # control command
+ case cmd
+ when 'set_safe_level'
+ begin
+ safe_level = args[0] if safe_level < args[0]
+ rescue Exception
+ end
+ when 'call_mainloop'
+ thread = args.shift
+ _check_and_return(thread,
+ MultiTkIp_OK.new(_receiver_mainloop(*args)))
+ else
+ # ignore
+ end
+
+ else
+ # procedure
+ last_thread = _receiver_eval_proc(last_thread, safe_level,
+ thread, cmd, *args)
+ end
+ end
+ }
+
+ # watchdog of receiver
+ watchdog = Thread.new{
+ begin
+ loop do
+ sleep 1
+ break unless receiver.alive?
+ end
+ rescue Exception
+ # ignore all kind of Exception
+ end
+ # receiver is dead
+ loop do
+ thread, cmd, *args = @cmd_queue.deq
+ next unless thread
+ if thread.alive?
+ if @interp.deleted?
+ thread.raise RuntimeError, 'the interpreter is already deleted'
+ else
+ thread.raise RuntimeError,
+ 'the interpreter no longer receives command procedures'
+ end
+ end
+ end
+ }
+
+ # return threads
+ [receiver, watchdog]
+ end
+ private :_check_and_return, :_create_receiver_and_watchdog
+
+ ######################################
+
+ if self.const_defined? :DEFAULT_MASTER_NAME
+ name = DEFAULT_MASTER_NAME.to_s
+ else
+ name = nil
+ end
+ if self.const_defined?(:DEFAULT_MASTER_OPTS) &&
+ DEFAULT_MASTER_OPTS.kind_of?(Hash)
+ keys = DEFAULT_MASTER_OPTS
+ else
+ keys = {}
+ end
+
+ @@DEFAULT_MASTER = self.allocate
+ @@DEFAULT_MASTER.instance_eval{
+ @tk_windows = {}.taint
+
+ @tk_table_list = [].taint
+
+ @slave_ip_tbl = {}.taint
+
+ @slave_ip_top = {}.taint
+
+ unless keys.kind_of? Hash
+ fail ArgumentError, "expecting a Hash object for the 2nd argument"
+ end
+
+ @interp = TclTkIp.new(name, _keys2opts(keys))
+ @ip_name = nil
+
+ @system = Object.new
+
+ @wait_on_mainloop = [true, false]
+
+ @threadgroup = Thread.current.group
+
+ @safe_base = false
+
+ @safe_level = [$SAFE]
+
+ @cmd_queue = Queue.new
+
+ @cmd_receiver, @receiver_watchdog = _create_receiver_and_watchdog(@safe_level[0])
+
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+
+ # NOT enclose @threadgroup for @@DEFAULT_MASTER
+
+ @@IP_TABLE[ThreadGroup::Default] = self
+ @@IP_TABLE[@threadgroup] = self
+
+ #################################
+
+ @assign_request = Class.new(Exception){
+ def self.new(target, ret)
+ obj = super()
+ obj.target = target
+ obj.ret = ret
+ obj
+ end
+ attr_accessor :target, :ret
+ }
+
+ @assign_thread = Thread.new{
+ loop do
+ begin
+ Thread.stop
+ rescue @assign_request=>req
+ begin
+ req.ret[0] = req.target.instance_eval{
+ @cmd_receiver, @receiver_watchdog =
+ _create_receiver_and_watchdog(@safe_level[0])
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+ @threadgroup.enclose
+ true
+ }
+ rescue Exception=>e
+ begin
+ req.ret[0] = e
+ rescue Exception
+ # ignore
+ end
+ end
+ rescue Exception
+ # ignore
+ end
+ end
+ }
+
+ def self.assign_receiver_and_watchdog(target)
+ ret = [nil]
+ @assign_thread.raise(@assign_request.new(target, ret))
+ while ret[0] == nil
+ unless @assign_thread.alive?
+ raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread'
+ end
+ end
+ if ret[0].kind_of?(Exception)
+ raise ret[0]
+ else
+ ret[0]
+ end
+ end
+
+ #################################
+
+ class << self
+ undef :instance_eval
+ end
+ }
+ @@DEFAULT_MASTER.freeze # defend against modification
+
+ ######################################
+
+ def self.inherited(subclass)
+ # trust if on ThreadGroup::Default or @@DEFAULT_MASTER's ThreadGroup
+ if @@IP_TABLE[Thread.current.group] == @@DEFAULT_MASTER
+ begin
+ class << subclass
+ self.methods.each{|m|
+ begin
+ unless m == '__id__' || m == '__send__' || m == 'freeze'
+ undef_method(m)
+ end
+ rescue Exception
+ # ignore all exceptions
+ end
+ }
+ end
+ ensure
+ subclass.freeze
+ fail SecurityError,
+ "cannot create subclass of MultiTkIp on a untrusted ThreadGroup"
+ end
+ end
+ end
+
+ ######################################
+
+ SAFE_OPT_LIST = [
+ 'accessPath'.freeze,
+ 'statics'.freeze,
+ 'nested'.freeze,
+ 'deleteHook'.freeze
+ ].freeze
+
+ def _parse_slaveopts(keys)
+ name = nil
+ safe = false
+ safe_opts = {}
+ tk_opts = {}
+
+ keys.each{|k,v|
+ k_str = k.to_s
+ if k_str == 'name'
+ name = v
+ elsif k_str == 'safe'
+ safe = v
+ elsif SAFE_OPT_LIST.member?(k_str)
+ safe_opts[k_str] = v
+ else
+ tk_opts[k_str] = v
+ end
+ }
+
+ if keys['without_tk'] || keys[:without_tk]
+ [name, safe, safe_opts, nil]
+ else
+ [name, safe, safe_opts, tk_opts]
+ end
+ end
+ private :_parse_slaveopts
+
+ def _create_slave_ip_name
+ name = SLAVE_IP_ID.join('')
+ SLAVE_IP_ID[1].succ!
+ name
+ end
+ private :_create_slave_ip_name
+
+ ######################################
+
+ def __check_safetk_optkeys(optkeys)
+ # based on 'safetk.tcl'
+ new_keys = {}
+ optkeys.each{|k,v| new_keys[k.to_s] = v}
+
+ # check 'display'
+ if !new_keys.key?('display')
+ begin
+ #new_keys['display'] = @interp._invoke('winfo screen .')
+ new_keys['display'] = @interp._invoke('winfo', 'screen', '.')
+ rescue
+ if ENV[DISPLAY]
+ new_keys['display'] = ENV[DISPLAY]
+ elsif !new_keys.key?('use')
+ warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'"
+ new_keys['display'] = ':0.0'
+ end
+ end
+ end
+
+ # check 'use'
+ if new_keys.key?('use')
+ # given 'use'
+ case new_keys['use']
+ when TkWindow
+ new_keys['use'] = TkWinfo.id(new_keys['use'])
+ #assoc_display = @interp._eval('winfo screen .')
+ assoc_display = @interp._invoke('winfo', 'screen', '.')
+ when /^\..*/
+ new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use'])
+ assoc_display = @interp._invoke('winfo', 'screen', new_keys['use'])
+ else
+ begin
+ pathname = @interp._invoke('winfo', 'pathname', new_keys['use'])
+ assco_display = @interp._invoke('winfo', 'screen', pathname)
+ rescue
+ assoc_display = new_keys['display']
+ end
+ end
+
+ # match display?
+ if assoc_display != new_keys['display']
+ if optkeys.keys?(:display) || optkeys.keys?('display')
+ fail RuntimeError,
+ "conflicting 'display'=>#{new_keys['display']} " +
+ "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}"
+ else
+ new_keys['display'] = assoc_display
+ end
+ end
+ end
+
+ # return
+ new_keys
+ end
+ private :__check_safetk_optkeys
+
+ def __create_safetk_frame(slave_ip, slave_name, app_name, keys)
+ # display option is used by ::safe::loadTk
+ loadTk_keys = {}
+ loadTk_keys['display'] = keys['display']
+ dup_keys = keys.dup
+
+ # keys for toplevel : allow followings
+ toplevel_keys = {}
+ ['height', 'width', 'background', 'menu'].each{|k|
+ toplevel_keys[k] = dup_keys.delete(k) if dup_keys.key?(k)
+ }
+ toplevel_keys['classname'] = 'SafeTk'
+ toplevel_keys['screen'] = dup_keys.delete('display')
+
+ # other keys used by pack option of container frame
+
+ # create toplevel widget
+ begin
+ top = TkToplevel.new(toplevel_keys)
+ rescue NameError
+ fail unless @interp.safe?
+ fail SecurityError, "unable create toplevel on the safe interpreter"
+ end
+ msg = "Untrusted Ruby/Tk applet (#{slave_name})"
+ if app_name.kind_of?(String)
+ top.title "#{app_name} (#{slave_name})"
+ else
+ top.title msg
+ end
+
+ # procedure to delete slave interpreter
+ slave_delete_proc = proc{
+ unless slave_ip.deleted?
+ #if slave_ip._invoke('info', 'command', '.') != ""
+ # slave_ip._invoke('destroy', '.')
+ #end
+ #slave_ip.delete
+ slave_ip._eval_without_enc('exit')
+ end
+ top.destroy if top.winfo_exist?
+ }
+ tag = TkBindTag.new.bind('Destroy', slave_delete_proc)
+
+ top.bindtags = top.bindtags.unshift(tag)
+
+ # create control frame
+ TkFrame.new(top, :bg=>'red', :borderwidth=>3, :relief=>'ridge') {|fc|
+ fc.bindtags = fc.bindtags.unshift(tag)
+
+ TkFrame.new(fc, :bd=>0){|f|
+ TkButton.new(f,
+ :text=>'Delete', :bd=>1, :padx=>2, :pady=>0,
+ :highlightthickness=>0, :command=>slave_delete_proc
+ ).pack(:side=>:right, :fill=>:both)
+ f.pack(:side=>:right, :fill=>:both, :expand=>true)
+ }
+
+ TkLabel.new(fc, :text=>msg, :padx=>2, :pady=>0,
+ :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true)
+
+ fc.pack(:side=>:bottom, :fill=>:x)
+ }
+
+ # container frame for slave interpreter
+ dup_keys['fill'] = :both unless dup_keys.key?('fill')
+ dup_keys['expand'] = true unless dup_keys.key?('expand')
+ c = TkFrame.new(top, :container=>true).pack(dup_keys)
+
+ # return keys
+ loadTk_keys['use'] = TkWinfo.id(c)
+ [loadTk_keys, top.path]
+ end
+ private :__create_safetk_frame
+
+ def __create_safe_slave_obj(safe_opts, app_name, tk_opts)
+ # safe interpreter
+ ip_name = _create_slave_ip_name
+ slave_ip = @interp.create_slave(ip_name, true)
+ @slave_ip_tbl[ip_name] = slave_ip
+ def slave_ip.safe_base?
+ true
+ end
+
+ @interp._eval("::safe::interpInit #{ip_name}")
+
+ slave_ip._invoke('set', 'argv0', app_name) if app_name.kind_of?(String)
+
+ if tk_opts
+ tk_opts = __check_safetk_optkeys(tk_opts)
+ if tk_opts.key?('use')
+ @slave_ip_top[ip_name] = ''
+ else
+ tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name,
+ tk_opts)
+ @slave_ip_top[ip_name] = top_path
+ end
+ @interp._eval("::safe::loadTk #{ip_name} #{_keys2opts(tk_opts)}")
+ else
+ @slave_ip_top[ip_name] = nil
+ end
+
+ if safe_opts.key?('deleteHook') || safe_opts.key?(:deleteHook)
+ @interp._eval("::safe::interpConfigure #{ip_name} " +
+ _keys2opts(safe_opts))
+ else
+ @interp._eval("::safe::interpConfigure #{ip_name} " +
+ _keys2opts(safe_opts) + '-deleteHook {' +
+ TkComm._get_eval_string(proc{|slave|
+ self._default_delete_hook(slave)
+ }) + '}')
+ end
+
+ [slave_ip, ip_name]
+ end
+
+ def __create_trusted_slave_obj(name, keys)
+ ip_name = _create_slave_ip_name
+ slave_ip = @interp.create_slave(ip_name, false)
+ slave_ip._invoke('set', 'argv0', name) if name.kind_of?(String)
+ slave_ip._invoke('set', 'argv', _keys2opts(keys))
+ @interp._invoke('load', '', 'Tk', ip_name)
+ @slave_ip_tbl[ip_name] = slave_ip
+ [slave_ip, ip_name]
+ end
+
+ ######################################
+
+ def _create_slave_object(keys={})
+ ip = MultiTkIp.new_slave(self, keys={})
+ @slave_ip_tbl[ip.name] = ip
+ end
+
+ ######################################
+
+ def initialize(master, safeip=true, keys={})
+ if $SAFE >= 4
+ fail SecurityError, "cannot create a new interpreter at level #{$SAFE}"
+ end
+
+ if safeip == nil && $SAFE >= 2
+ fail SecurityError, "cannot create a master-ip at level #{$SAFE}"
+ end
+
+ if !master.master? && master.safe?
+ fail SecurityError, "safe-slave-ip cannot create a new interpreter"
+ end
+
+ if safeip == nil && !master.master?
+ fail SecurityError, "slave-ip cannot create a master-ip"
+ end
+
+ unless keys.kind_of? Hash
+ fail ArgumentError, "expecting a Hash object for the 2nd argument"
+ end
+
+ @tk_windows = {}
+ @tk_table_list = []
+ @slave_ip_tbl = {}
+ @slave_ip_top = {}
+
+ @tk_windows.taint unless @tk_windows.tainted?
+ @tk_table_list.taint unless @tk_table_list.tainted?
+ @slave_ip_tbl.taint unless @slave_ip_tbl.tainted?
+ @slave_ip_top.taint unless @slave_ip_top.tainted?
+
+ name, safe, safe_opts, tk_opts = _parse_slaveopts(keys)
+
+ safe = 4 if safe && !safe.kind_of?(Fixnum)
+
+ @safe_base = false
+
+ if safeip == nil
+ # create master-ip
+ @interp = TclTkIp.new(name, _keys2opts(tk_opts))
+
+ @ip_name = nil
+ if safe
+ safe = $SAFE if safe < $SAFE
+ @safe_level = [safe]
+ else
+ @safe_level = [$SAFE]
+ end
+ else
+ # create slave-ip
+ if safeip || master.safe?
+ @safe_base = true
+ @interp, @ip_name = master.__create_safe_slave_obj(safe_opts,
+ name, tk_opts)
+ if safe
+ safe = master.safe_level if safe < master.safe_level
+ @safe_level = [safe]
+ else
+ @safe_level = [4]
+ end
+ else
+ @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts)
+ if safe
+ safe = master.safe_level if safe < master.safe_level
+ @safe_level = [safe]
+ else
+ @safe_level = [master.safe_level]
+ end
+ end
+ @set_alias_proc = proc{|name|
+ master._invoke('interp', 'alias', @ip_name, name, '', name)
+ }.freeze
+ end
+
+ @system = Object.new
+
+ @wait_on_mainloop = [true, false]
+
+ @threadgroup = ThreadGroup.new
+
+ @cmd_queue = Queue.new
+
+=begin
+ @cmd_receiver, @receiver_watchdog = _create_receiver_and_watchdog(@safe_level[0])
+
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+
+ @threadgroup.enclose
+=end
+ @@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
+
+ @@IP_TABLE[@threadgroup] = self
+ _init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
+ @@TK_TABLE_LIST.size.times{
+ (tbl = {}).tainted? || tbl.taint
+ @tk_table_list << tbl
+ }
+
+ class << self
+ undef :instance_eval
+ end
+
+ self.freeze # defend against modification
+ end
+
+ ######################################
+
+ def _default_delete_hook(slave)
+ if @slave_ip_top[slave].kind_of?(String)
+ # call default hook of safetk.tcl (ignore exceptions)
+ if @slave_ip_top[slave] == ''
+ begin
+ @interp._eval("::safe::disallowTk #{slave}")
+ rescue
+ warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG
+ end
+ else # toplevel path
+ begin
+ @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}")
+ rescue
+ warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG
+ begin
+ @interp._eval("destroy #{@slave_ip_top[slave]}")
+ rescue
+ warn("Waring: fail to destroy toplevel") if $DEBUG
+ end
+ end
+ end
+ end
+ @slave_ip_tbl.delete(slave)
+ @slave_ip_top.delete(slave)
+ end
+end
+
+
+# get target IP
+class MultiTkIp
+ def self._ip_id_
+ __getip._ip_id_
+ end
+ def _ip_id_
+ ''
+ end
+
+ def self.__getip
+ if Thread.current.group == ThreadGroup::Default
+ @@DEFAULT_MASTER
+ else
+ ip = @@IP_TABLE[Thread.current.group]
+ unless ip
+ fail SecurityError,
+ "cannot call Tk methods on #{Thread.current.inspect}"
+ end
+ ip
+ end
+ end
+end
+
+
+# aliases of constructor
+class << MultiTkIp
+ alias __new new
+ private :__new
+
+
+ def new_master(safe=nil, keys={})
+ if safe.kind_of?(Hash)
+ keys = safe
+ elsif safe.kind_of?(Integer)
+ raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
+ if !keys.key?(:safe) && !keys.key?('safe')
+ keys[:safe] = safe
+ end
+ elsif safe == nil
+ # do nothing
+ else
+ raise ArgumentError, "unexpected argument(s)"
+ end
+
+ ip = __new(__getip, nil, keys)
+ ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given?
+ ip
+ end
+
+ alias new new_master
+
+ def new_slave(safe=nil, keys={})
+ if safe.kind_of?(Hash)
+ keys = safe
+ elsif safe.kind_of?(Integer)
+ raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
+ if !keys.key?(:safe) && !keys.key?('safe')
+ keys[:safe] = safe
+ end
+ elsif safe == nil
+ # do nothing
+ else
+ raise ArgumentError, "unexpected argument(s)"
+ end
+
+ ip = __new(__getip, false, keys)
+ ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given?
+ ip
+ end
+ alias new_trusted_slave new_slave
+
+ def new_safe_slave(safe=4, keys={})
+ if safe.kind_of?(Hash)
+ keys = safe
+ elsif safe.kind_of?(Integer)
+ raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
+ if !keys.key?(:safe) && !keys.key?('safe')
+ keys[:safe] = safe
+ end
+ else
+ raise ArgumentError, "unexpected argument(s)"
+ end
+
+ ip = __new(__getip, true, keys)
+ ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given?
+ ip
+ end
+ alias new_safeTk new_safe_slave
+end
+
+
+# get info
+class MultiTkIp
+ def inspect
+ s = self.to_s.chop!
+ if master?
+ s << ':master'
+ else
+ if @interp.safe?
+ s << ':safe-slave'
+ else
+ s << ':trusted-slave'
+ end
+ end
+ s << '>'
+ end
+
+ def master?
+ if @ip_name
+ false
+ else
+ true
+ end
+ end
+ def self.master?
+ __getip.master?
+ end
+
+ def slave?
+ not master?
+ end
+ def self.slave?
+ not self.master?
+ end
+
+ def alive?
+ begin
+ return false unless @cmd_receiver.alive?
+ return false if @interp.deleted?
+ return false if @interp._invoke('interp', 'exists', '') == '0'
+ rescue Exception
+ return false
+ end
+ true
+ end
+ def self.alive?
+ __getip.alive?
+ end
+
+ def path
+ @ip_name || ''
+ end
+ def self.path
+ __getip.path
+ end
+ def ip_name
+ @ip_name || ''
+ end
+ def self.ip_name
+ __getip.ip_name
+ end
+ def to_eval
+ @ip_name || ''
+ end
+ def self.to_eval
+ __getip.to_eval
+ end
+
+ def slaves(all = false)
+ @interp._invoke('interp','slaves').split.map!{|name|
+ if @slave_ip_tbl.key?(name)
+ @slave_ip_tbl[name]
+ elsif all
+ name
+ else
+ nil
+ end
+ }.compact!
+ end
+ def self.slaves(all = false)
+ __getip.slaves(all)
+ end
+end
+
+
+# instance methods to treat tables
+class MultiTkIp
+ def _tk_cmd_tbl
+ tbl = {}
+ MultiTkIp.tk_cmd_tbl.each{|id, ent| tbl[id] = ent if ent.ip == self }
+ tbl
+ end
+
+ def _tk_windows
+ @tk_windows
+ end
+
+ def _tk_table_list
+ @tk_table_list
+ end
+
+ def _add_new_tables
+ (@@TK_TABLE_LIST.size - @tk_table_list.size).times{
+ (tbl = {}).tainted? || tbl.taint
+ @tk_table_list << tbl
+ }
+ end
+
+ def _init_ip_env(script)
+ script.call(self)
+ end
+
+ def _add_tk_procs(name, args, body)
+ return if slave?
+ @interp._invoke('proc', name, args, body) if args && body
+ @interp._invoke('interp', 'slaves').split.each{|slave|
+ @interp._invoke('interp', 'alias', slave, name, '', name)
+ }
+ end
+
+ def _init_ip_internal(init_ip_env, add_tk_procs)
+ init_ip_env.each{|script| script.call(self)}
+ add_tk_procs.each{|name, args, body|
+ if master?
+ @interp._invoke('proc', name, args, body) if args && body
+ else
+ @set_alias_proc.call(name)
+ end
+ }
+ end
+end
+
+
+# class methods to treat tables
+class MultiTkIp
+ def self.tk_cmd_tbl
+ @@TK_CMD_TBL
+ end
+ def self.tk_windows
+ __getip._tk_windows
+ end
+ def self.tk_object_table(id)
+ __getip._tk_table_list[id]
+ end
+ def self.create_table
+ #if __getip.slave?
+ # raise SecurityError, "slave-IP has no permission creating a new table"
+ #end
+ id = @@TK_TABLE_LIST.size
+ obj = Object.new
+ @@TK_TABLE_LIST << obj
+ obj.instance_eval <<-EOD
+ def self.method_missing(m, *args)
+ MultiTkIp.tk_object_table(#{id}).__send__(m, *args)
+ end
+ EOD
+ obj.freeze
+ @@IP_TABLE.each{|tg, ip| ip._add_new_tables }
+ return obj
+ end
+
+ def self.init_ip_env(script = Proc.new)
+ @@INIT_IP_ENV << script
+ @@IP_TABLE.each{|tg, ip|
+ ip._init_ip_env(script)
+ }
+ end
+
+ def self.add_tk_procs(name, args=nil, body=nil)
+ @@ADD_TK_PROCS << [name, args, body]
+ @@IP_TABLE.each{|tg, ip|
+ ip._add_tk_procs(name, args, body)
+ }
+ end
+
+ def self.init_ip_internal
+ __getip._init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
+ end
+end
+
+
+# for callback operation
+class MultiTkIp
+ def self.get_cb_entry(cmd)
+ @@CB_ENTRY_CLASS.new(__getip, cmd).freeze
+ end
+
+ def cb_eval(cmd, *args)
+ #self.eval_callback{ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *args)) }
+ #ret = self.eval_callback{ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *args)) }
+ ret = self.eval_callback(*args){|safe, *params|
+ $SAFE=safe; TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *params))
+ }
+ if ret.kind_of?(Exception)
+ raise ret
+ end
+ end
+end
+
+
+# evaluate a procedure on the proper interpreter
+class MultiTkIp
+ # instance method
+ def eval_proc_core(req_val, cmd, *args)
+ # check
+ unless cmd.kind_of?(Proc) || cmd.kind_of?(Method)
+ raise RuntimeError, "A Proc/Method object is expected for the 'cmd' argument"
+ end
+
+ # on IP thread
+ if (@cmd_receiver == Thread.current)
+ begin
+ ret = cmd.call(*args)
+ rescue SystemExit
+ # exit IP
+ warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception
+ end
+ self.delete
+ ret = nil
+ rescue Exception => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ ret = e
+ end
+ return ret
+ end
+
+ # send cmd to the proc-queue
+ unless req_val
+ begin
+ @cmd_queue.enq([nil, cmd, *args])
+ rescue Exception => e
+ # ignore
+ if $DEBUG || true
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ return e
+ end
+ return nil
+ end
+
+ # send and get return value by exception
+ begin
+ @cmd_queue.enq([Thread.current, cmd, *args])
+ Thread.stop
+ rescue MultiTkIp_OK => ret
+ # return value
+ return ret.value
+ rescue SystemExit => e
+ # exit IP
+ warn("Warning: " + $! + " on " + self.inspect) if $DEBUG
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception
+ end
+ if !safe? && allow_ruby_exit?
+ self.delete
+ fail e
+ else
+ self.delete
+ end
+ rescue Exception => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ return e
+ end
+ return nil
+ end
+ private :eval_proc_core
+
+=begin
+ def eval_callback(*args)
+ if block_given?
+ eval_proc_core(false, proc{$SAFE=@safe_level[0]; Proc.new}.call, *args)
+ else
+ eval_proc_core(false, *args)
+ end
+ end
+=end
+ def eval_callback(*args)
+ if block_given?
+ eval_proc_core(false, Proc.new, *args)
+ else
+ eval_proc_core(false, *args)
+ end
+ end
+
+=begin
+ def eval_proc(*args)
+ if block_given?
+ eval_proc_core(true, proc{$SAFE=@safe_level[0]; Proc.new}.call, *args)
+ else
+ eval_proc_core(true, *args)
+ end
+ end
+=end
+ def eval_proc(*args)
+ # The scope of the eval-block of 'eval_proc' method is different from
+ # the enternal. If you want to pass local values to the eval-block,
+ # use arguments of eval_proc method. They are passed to block-arguments.
+ if block_given?
+ cmd = Proc.new
+ else
+ unless (cmd = args.shift)
+ fail ArgumentError, "A Proc or Method object is expected for 1st argument"
+ end
+ end
+ eval_proc_core(true,
+ proc{|safe, *params|
+ $SAFE=safe; Thread.new(*params, &cmd).value
+ },
+ *args)
+ end
+ alias call eval_proc
+
+ def bg_eval_proc(*args)
+ if block_given?
+ cmd = Proc.new
+ else
+ unless (cmd = args.shift)
+ fail ArgumentError, "A Proc or Method object is expected for 1st argument"
+ end
+ end
+ Thread.new{
+ eval_proc_core(false,
+ proc{|safe, *params|
+ $SAFE=safe; Thread.new(*params, &cmd).value
+ },
+ *args)
+ }
+ end
+ alias background_eval_proc bg_eval_proc
+ alias bg_call bg_eval_proc
+ alias background_call bg_eval_proc
+
+ def eval_string(cmd, *eval_args)
+ # cmd string ==> proc
+ unless cmd.kind_of?(String)
+ raise RuntimeError, "A String object is expected for the 'cmd' argument"
+ end
+
+ eval_proc_core(true, proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)})
+ end
+ alias eval_str eval_string
+
+ def bg_eval_string(*args)
+ # cmd string ==> proc
+ unless cmd.kind_of?(String)
+ raise RuntimeError, "A String object is expected for the 'cmd' argument"
+ end
+ Thread.new{
+ eval_proc_core(true,
+ proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)})
+ }
+ end
+ alias background_eval_string bg_eval_string
+ alias bg_eval_str bg_eval_string
+ alias background_eval_str bg_eval_string
+end
+
+class << MultiTkIp
+ # class method
+=begin
+ def eval_proc(cmd = proc{$SAFE=__getip.safe_level; Proc.new}.call, *args)
+ # class ==> interp object
+ __getip.eval_proc(cmd, *args)
+ end
+=end
+=begin
+ def eval_proc(*args)
+ # class ==> interp object
+ if block_given?
+ __getip.eval_proc(proc{$SAFE=__getip.safe_level; Proc.new}.call, *args)
+ else
+ __getip.eval_proc(*args)
+ end
+ end
+=end
+#=begin
+ def eval_proc(*args, &blk)
+ # class ==> interp object
+ __getip.eval_proc(*args, &blk)
+ end
+#=end
+ alias call eval_proc
+ alias eval_string eval_proc
+end
+
+
+# event loop
+# all master/slave IPs are controled by only one event-loop
+class << MultiTkIp
+ def mainloop(check_root = true)
+ __getip.mainloop(check_root)
+ end
+ def mainloop_watchdog(check_root = true)
+ __getip.mainloop_watchdog(check_root)
+ end
+ def do_one_event(flag = TclTkLib::EventFlag::ALL)
+ __getip.do_one_event(flag)
+ end
+ def mainloop_abort_on_exception
+ # __getip.mainloop_abort_on_exception
+ TclTkLib.mainloop_abort_on_exception
+ end
+ def mainloop_abort_on_exception=(mode)
+ # __getip.mainloop_abort_on_exception=(mode)
+ TclTkLib.mainloop_abort_on_exception=(mode)
+ end
+ def set_eventloop_tick(tick)
+ __getip.set_eventloop_tick(tick)
+ end
+ def get_eventloop_tick
+ __getip.get_eventloop_tick
+ end
+ def set_no_event_wait(tick)
+ __getip.set_no_event_wait(tick)
+ end
+ def get_no_event_wait
+ __getip.get_no_event_wait
+ end
+ def set_eventloop_weight(loop_max, no_event_tick)
+ __getip.set_eventloop_weight(loop_max, no_event_tick)
+ end
+ def get_eventloop_weight
+ __getip.get_eventloop_weight
+ end
+end
+
+# class methods to delegate to TclTkIp
+class << MultiTkIp
+ def method_missing(id, *args)
+ __getip.__send__(id, *args)
+ end
+
+ def make_safe
+ __getip.make_safe
+ end
+
+ def safe?
+ __getip.safe?
+ end
+
+ def safe_base?
+ begin
+ __getip.safe_base?
+ rescue
+ false
+ end
+ end
+
+ def allow_ruby_exit?
+ __getip.allow_ruby_exit?
+ end
+
+ def allow_ruby_exit= (mode)
+ __getip.allow_ruby_exit = mode
+ end
+
+ def delete
+ __getip.delete
+ end
+
+ def deleteed?
+ __getip.deleted?
+ end
+
+ def abort(msg = nil)
+ __getip.abort(msg)
+ end
+
+ def exit(st = true)
+ __getip.exit(st)
+ end
+
+ def exit!(st = false)
+ __getip.exit!(st)
+ end
+
+ def restart(app_name = nil, keys = {})
+ init_ip_internal
+
+ __getip._invoke('set', 'argv0', app_name) if app_name
+ if keys.kind_of?(Hash)
+ __getip._invoke('set', 'argv', _keys2opts(keys))
+ end
+
+ __getip.restart
+ end
+
+ def _eval(str)
+ __getip._eval(str)
+ end
+
+ def _invoke(*args)
+ __getip._invoke(*args)
+ end
+
+ def _eval_without_enc(str)
+ __getip._eval_without_enc(str)
+ end
+
+ def _invoke_without_enc(*args)
+ __getip._invoke_without_enc(*args)
+ end
+
+ def _eval_with_enc(str)
+ __getip._eval_with_enc(str)
+ end
+
+ def _invoke_with_enc(*args)
+ __getip._invoke_with_enc(*args)
+ end
+
+ def _toUTF8(str, encoding)
+ __getip._toUTF8(str, encoding)
+ end
+
+ def _fromUTF8(str, encoding)
+ __getip._fromUTF8(str, encoding)
+ end
+
+ def _thread_vwait(var)
+ __getip._thread_vwait(var)
+ end
+
+ def _thread_tkwait(mode, target)
+ __getip._thread_tkwait(mode, target)
+ end
+
+ def _return_value
+ __getip._return_value
+ end
+
+ def _get_variable(var, flag)
+ __getip._get_variable(var, flag)
+ end
+ def _get_variable2(var, idx, flag)
+ __getip._get_variable2(var, idx, flag)
+ end
+ def _set_variable(var, value, flag)
+ __getip._set_variable(var, value, flag)
+ end
+ def _set_variable2(var, idx, value, flag)
+ __getip._set_variable2(var, idx, value, flag)
+ end
+ def _unset_variable(var, flag)
+ __getip._unset_variable(var, flag)
+ end
+ def _unset_variable2(var, idx, flag)
+ __getip._unset_variable2(var, idx, flag)
+ end
+
+ def _get_global_var(var)
+ __getip._get_global_var(var)
+ end
+ def _get_global_var2(var, idx)
+ __getip._get_global_var2(var, idx)
+ end
+ def _set_global_var(var, value)
+ __getip._set_global_var(var, value)
+ end
+ def _set_global_var2(var, idx, value)
+ __getip._set_global_var2(var, idx, value)
+ end
+ def _unset_global_var(var)
+ __getip._unset_global_var(var)
+ end
+ def _unset_global_var2(var, idx)
+ __getip._unset_global_var2(var, idx)
+ end
+
+ def _split_tklist(str)
+ __getip._split_tklist(str)
+ end
+ def _merge_tklist(*args)
+ __getip._merge_tklist(*args)
+ end
+ def _conv_listelement(arg)
+ __getip._conv_listelement(arg)
+ end
+end
+
+
+# wrap methods on TclTkLib : not permit calling TclTkLib module methods
+class << TclTkLib
+ def mainloop(check_root = true)
+ MultiTkIp.mainloop(check_root)
+ end
+ def mainloop_watchdog(check_root = true)
+ MultiTkIp.mainloop_watchdog(check_root)
+ end
+ def do_one_event(flag = TclTkLib::EventFlag::ALL)
+ MultiTkIp.do_one_event(flag)
+ end
+ #def mainloop_abort_on_exception
+ # MultiTkIp.mainloop_abort_on_exception
+ #end
+ #def mainloop_abort_on_exception=(mode)
+ # MultiTkIp.mainloop_abort_on_exception=(mode)
+ #end
+ def set_eventloop_tick(tick)
+ MultiTkIp.set_eventloop_tick(tick)
+ end
+ def get_eventloop_tick
+ MultiTkIp.get_eventloop_tick
+ end
+ def set_no_event_wait(tick)
+ MultiTkIp.set_no_event_wait(tick)
+ end
+ def get_no_event_wait
+ MultiTkIp.get_no_event_wait
+ end
+ def set_eventloop_weight(loop_max, no_event_tick)
+ MultiTkIp.set_eventloop_weight(loop_max, no_event_tick)
+ end
+ def get_eventloop_weight
+ MultiTkIp.get_eventloop_weight
+ end
+ def restart(*args)
+ MultiTkIp.restart(*args)
+ end
+
+ def _merge_tklist(*args)
+ MultiTkIp._merge_tklist(*args)
+ end
+ def _conv_listelement(arg)
+ MultiTkIp._conv_listelement(arg)
+ end
+end
+
+
+# depend on TclTkIp
+class MultiTkIp
+ def mainloop(check_root = true, restart_on_dead = false)
+ #return self if self.slave?
+ #return self if self != @@DEFAULT_MASTER
+ if self != @@DEFAULT_MASTER
+ if @wait_on_mainloop[0]
+ begin
+ @wait_on_mainloop[1] = true
+ @cmd_queue.enq([@system, 'call_mainloop',
+ Thread.current, check_root])
+ Thread.stop
+ rescue MultiTkIp_OK => ret
+ # return value
+ @wait_on_mainloop[1] = false
+ return ret.value.value
+ rescue SystemExit
+ # exit IP
+ warn("Warning: " + $! + " on " + self.inspect) if $DEBUG
+ @wait_on_mainloop[1] = false
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception
+ end
+ self.delete
+ rescue Exception => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ @wait_on_mainloop[1] = false
+ return e
+ ensure
+ @wait_on_mainloop[1] = false
+ end
+ end
+ return
+ end
+
+ unless restart_on_dead
+ @wait_on_mainloop[1] = true
+ @interp.mainloop(check_root)
+ @wait_on_mainloop[1] = false
+ else
+ begin
+ @wait_on_mainloop[1] = true
+ loop do
+ break unless self.alive?
+ if check_root
+ begin
+ break if TclTkLib.num_of_mainwindows == 0
+ rescue Exception
+ break
+ end
+ end
+ @interp.mainloop(check_root)
+ end
+ #rescue StandardError
+ rescue Exception
+ if TclTkLib.mainloop_abort_on_exception != nil
+ STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect,
+ " exception (ignore) : ", $!.message, "\n");
+ end
+ retry
+ ensure
+ @wait_on_mainloop[1] = false
+ end
+ end
+ self
+ end
+
+ def make_safe
+ @interp.make_safe
+ end
+
+ def safe?
+ @interp.safe?
+ end
+
+ def safe_base?
+ @safe_base
+ end
+
+ def allow_ruby_exit?
+ @interp.allow_ruby_exit?
+ end
+
+ def allow_ruby_exit= (mode)
+ @interp.allow_ruby_exit = mode
+ end
+
+ def delete
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+=begin
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
+=end
+ begin
+ subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
+
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ rescue Exception
+ end
+=begin
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
+=end
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ else
+ @interp.delete unless @interp.deleted?
+ end
+ self
+ end
+
+ def deleted?
+ @interp.deleted?
+ end
+
+ def abort(msg = nil)
+ if master?
+ if msg
+ Kernel.abort(msg)
+ else
+ Kernel.abort
+ end
+ else
+ # ignore msg
+ delete
+ 1
+ end
+ end
+
+ def exit(st = true)
+ if master?
+ Kernel.exit(st)
+ else
+ delete
+ st
+ end
+ end
+
+ def exit!(st = false)
+ if master? && !safe? && allow_ruby_exit?
+ Kernel.exit!(st)
+ else
+ delete
+ st
+ end
+ end
+
+ def restart(app_name = nil, keys = {})
+ _init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
+
+ @interp._invoke('set', 'argv0', app_name) if app_name
+ if keys.kind_of?(Hash)
+ @interp._invoke('set', 'argv', _keys2opts(keys))
+ end
+
+ @interp.restart
+ end
+
+ def __eval(str)
+ @interp.__eval(str)
+ end
+
+ def __invoke(*args)
+ @interp.__invoke(*args)
+ end
+
+ def _eval(str)
+ @interp._eval(str)
+ end
+
+ def _invoke(*args)
+ @interp._invoke(*args)
+ end
+
+ def _eval_without_enc(str)
+ @interp._eval_without_enc(str)
+ end
+
+ def _invoke_without_enc(*args)
+ @interp._invoke_without_enc(*args)
+ end
+
+ def _eval_with_enc(str)
+ @interp._eval_with_enc(str)
+ end
+
+ def _invoke_with_enc(*args)
+ @interp._invoke_with_enc(*args)
+ end
+
+ def _toUTF8(str, encoding)
+ @interp._toUTF8(str, encoding)
+ end
+
+ def _fromUTF8(str, encoding)
+ @interp._fromUTF8(str, encoding)
+ end
+
+ def _thread_vwait(var)
+ @interp._thread_vwait(var)
+ end
+
+ def _thread_tkwait(mode, target)
+ @interp._thread_tkwait(mode, target)
+ end
+
+ def _return_value
+ @interp._return_value
+ end
+
+ def _get_variable(var, flag)
+ @interp._get_variable(var, flag)
+ end
+ def _get_variable2(var, idx, flag)
+ @interp._get_variable2(var, idx, flag)
+ end
+ def _set_variable(var, value, flag)
+ @interp._set_variable(var, value, flag)
+ end
+ def _set_variable2(var, idx, value, flag)
+ @interp._set_variable2(var, idx, value, flag)
+ end
+ def _unset_variable(var, flag)
+ @interp._unset_variable(var, flag)
+ end
+ def _unset_variable2(var, idx, flag)
+ @interp._unset_variable2(var, idx, flag)
+ end
+
+ def _get_global_var(var)
+ @interp._get_global_var(var)
+ end
+ def _get_global_var2(var, idx)
+ @interp._get_global_var2(var, idx)
+ end
+ def _set_global_var(var, value)
+ @interp._set_global_var(var, value)
+ end
+ def _set_global_var2(var, idx, value)
+ @interp._set_global_var2(var, idx, value)
+ end
+ def _unset_global_var(var)
+ @interp._unset_global_var(var)
+ end
+ def _unset_global_var2(var, idx)
+ @interp._unset_global_var2(var, idx)
+ end
+
+ def _split_tklist(str)
+ @interp._split_tklist(str)
+ end
+ def _merge_tklist(*args)
+ @interp._merge_tklist(*args)
+ end
+ def _conv_listelement(arg)
+ @interp._conv_listelement(arg)
+ end
+end
+
+
+# interp command support
+class MultiTkIp
+ def _lst2ary(str)
+ return [] if str == ""
+ idx = str.index('{')
+ while idx and idx > 0 and str[idx-1] == ?\\
+ idx = str.index('{', idx+1)
+ end
+ return str.split unless idx
+
+ list = str[0,idx].split
+ str = str[idx+1..-1]
+ i = -1
+ brace = 1
+ str.each_byte {|c|
+ i += 1
+ brace += 1 if c == ?{
+ brace -= 1 if c == ?}
+ break if brace == 0
+ }
+ if i == 0
+ list.push ''
+ elsif str[0, i] == ' '
+ list.push ' '
+ else
+ list.push str[0..i-1]
+ end
+ #list += _lst2ary(str[i+1..-1])
+ list.concat(_lst2ary(str[i+1..-1]))
+ list
+ end
+ private :_lst2ary
+
+ def _slavearg(slave)
+ if slave.kind_of?(MultiTkIp)
+ slave.path
+ elsif slave.kind_of?(String)
+ slave
+ else
+ cmd_name.to_s
+ end
+ end
+ private :_slavearg
+
+ def alias_info(slave, cmd_name)
+ _lst2ary(@interp._invoke('interp', 'alias', _slavearg(slave), cmd_name))
+ end
+ def self.alias_info(slave, cmd_name)
+ __getip.alias_info(slave, cmd_name)
+ end
+
+ def alias_delete(slave, cmd_name)
+ @interp._invoke('interp', 'alias', _slavearg(slave), cmd_name, '')
+ self
+ end
+ def self.alias_delete(slave, cmd_name)
+ __getip.alias_delete(slave, cmd_name)
+ self
+ end
+
+ def def_alias(slave, new_cmd, org_cmd, *args)
+ ret = @interp._invoke('interp', 'alias', _slavearg(slave), new_cmd,
+ '', org_cmd, *args)
+ (ret == new_cmd)? self: nil
+ end
+ def self.def_alias(slave, new_cmd, org_cmd, *args)
+ ret = __getip.def_alias(slave, new_cmd, org_cmd, *args)
+ (ret == new_cmd)? self: nil
+ end
+
+ def aliases(slave = '')
+ _lst2ary(@interp._invoke('interp', 'aliases', _slavearg(slave)))
+ end
+ def self.aliases(slave = '')
+ __getip.aliases(slave)
+ end
+
+ def delete_slaves(*args)
+ slaves = args.collect{|s| _slavearg(s)}
+ @interp._invoke('interp', 'delete', *slaves) if slaves.size > 0
+ self
+ end
+ def self.delete_slaves(*args)
+ __getip.delete_slaves(*args)
+ self
+ end
+
+ def exist?(slave = '')
+ ret = @interp._invoke('interp', 'exists', _slavearg(slave))
+ (ret == '1')? true: false
+ end
+ def self.exist?(slave = '')
+ __getip.exist?(slave)
+ end
+
+ def delete_cmd(slave, cmd)
+ slave_invoke = @interp._invoke('list', 'rename', cmd, '')
+ @interp._invoke('interp', 'eval', _slavearg(slave), slave_invoke)
+ self
+ end
+ def self.delete_cmd(slave, cmd)
+ __getip.delete_cmd(slave, cmd)
+ self
+ end
+
+ def expose_cmd(slave, cmd, aliasname = nil)
+ if aliasname
+ @interp._invoke('interp', 'expose', _slavearg(slave), cmd, aliasname)
+ else
+ @interp._invoke('interp', 'expose', _slavearg(slave), cmd)
+ end
+ self
+ end
+ def self.expose_cmd(slave, cmd, aliasname = nil)
+ __getip.expose_cmd(slave, cmd, aliasname)
+ self
+ end
+
+ def hide_cmd(slave, cmd, aliasname = nil)
+ if aliasname
+ @interp._invoke('interp', 'hide', _slavearg(slave), cmd, aliasname)
+ else
+ @interp._invoke('interp', 'hide', _slavearg(slave), cmd)
+ end
+ self
+ end
+ def self.hide_cmd(slave, cmd, aliasname = nil)
+ __getip.hide_cmd(slave, cmd, aliasname)
+ self
+ end
+
+ def hidden_cmds(slave = '')
+ _lst2ary(@interp._invoke('interp', 'hidden', _slavearg(slave)))
+ end
+ def self.hidden_cmds(slave = '')
+ __getip.hidden_cmds(slave)
+ end
+
+ def invoke_hidden(slave, cmd, *args)
+ @interp._invoke('interp', 'invokehidden', _slavearg(slave), cmd, *args)
+ end
+ def self.invoke_hidden(slave, cmd, *args)
+ __getip.invoke_hidden(slave, cmd, *args)
+ end
+
+ def invoke_hidden_on_global(slave, cmd, *args)
+ @interp._invoke('interp', 'invokehidden', _slavearg(slave),
+ '-global', cmd, *args)
+ end
+ def self.invoke_hidden_on_global(slave, cmd, *args)
+ __getip.invoke_hidden_on_global(slave, cmd, *args)
+ end
+
+ def mark_trusted(slave = '')
+ @interp._invoke('interp', 'marktrusted', _slavearg(slave))
+ self
+ end
+ def self.mark_trusted(slave = '')
+ __getip.mark_trusted(slave)
+ self
+ end
+
+ def recursion_limit(slave = '', limit = None)
+ number(@interp._invoke('interp', 'recursionlimit',
+ _slavearg(slave), limit))
+ end
+ def self.recursion_limit(slave = '', limit = None)
+ __getip.recursion_limit(slave)
+ end
+
+ def alias_target(aliascmd, slave = '')
+ @interp._invoke('interp', 'target', _slavearg(slave), aliascmd)
+ end
+ def self.alias_target(aliascmd, slave = '')
+ __getip.alias_target(aliascmd, slave)
+ end
+
+ def share_stdin(dist, src = '')
+ @interp._invoke('interp', 'share', src, 'stdin', dist)
+ self
+ end
+ def self.share_stdin(dist, src = '')
+ __getip.share_stdin(dist, src)
+ self
+ end
+
+ def share_stdout(dist, src = '')
+ @interp._invoke('interp', 'share', src, 'stdout', dist)
+ self
+ end
+ def self.share_stdout(dist, src = '')
+ __getip.share_stdout(dist, src)
+ self
+ end
+
+ def share_stderr(dist, src = '')
+ @interp._invoke('interp', 'share', src, 'stderr', dist)
+ self
+ end
+ def self.share_stderr(dist, src = '')
+ __getip.share_stderr(dist, src)
+ self
+ end
+
+ def transfer_stdin(dist, src = '')
+ @interp._invoke('interp', 'transfer', src, 'stdin', dist)
+ self
+ end
+ def self.transfer_stdin(dist, src = '')
+ __getip.transfer_stdin(dist, src)
+ self
+ end
+
+ def transfer_stdout(dist, src = '')
+ @interp._invoke('interp', 'transfer', src, 'stdout', dist)
+ self
+ end
+ def self.transfer_stdout(dist, src = '')
+ __getip.transfer_stdout(dist, src)
+ self
+ end
+
+ def transfer_stderr(dist, src = '')
+ @interp._invoke('interp', 'transfer', src, 'stderr', dist)
+ self
+ end
+ def self.transfer_stderr(dist, src = '')
+ __getip.transfer_stderr(dist, src)
+ self
+ end
+
+ def share_stdio(dist, src = '')
+ @interp._invoke('interp', 'share', src, 'stdin', dist)
+ @interp._invoke('interp', 'share', src, 'stdout', dist)
+ @interp._invoke('interp', 'share', src, 'stderr', dist)
+ self
+ end
+ def self.share_stdio(dist, src = '')
+ __getip.share_stdio(dist, src)
+ self
+ end
+
+ def transfer_stdio(dist, src = '')
+ @interp._invoke('interp', 'transfer', src, 'stdin', dist)
+ @interp._invoke('interp', 'transfer', src, 'stdout', dist)
+ @interp._invoke('interp', 'transfer', src, 'stderr', dist)
+ self
+ end
+ def self.transfer_stdio(dist, src = '')
+ __getip.transfer_stdio(dist, src)
+ self
+ end
+end
+
+
+# Safe Base :: manipulating safe interpreter
+class MultiTkIp
+ def safeip_configure(slot, value=None)
+ # use for '-noStatics' option ==> {statics=>false}
+ # for '-nestedLoadOk' option ==> {nested=>true}
+ if slot.kind_of?(Hash)
+ ip = MultiTkIp.__getip
+ ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + _keys2opts(slot))
+ else
+ ip._eval('::safe::interpConfigure ' + @ip_name + ' ' +
+ "-#{slot} #{_get_eval_string(value)}")
+ end
+ self
+ end
+
+ def safeip_configinfo(slot = nil)
+ ip = MultiTkIp.__getip
+ ret = {}
+ if slot
+ conf = _lst2ary(ip._eval("::safe::interpConfigure " +
+ @ip_name + " -#{slot}"))
+ if conf[0] == '-deleteHook'
+ if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
+ else
+ ret[conf[0][1..-1]] = conf[1]
+ end
+ else
+ ret[conf[0][1..-1]] = conf[1]
+ end
+ else
+ Hash[*_lst2ary(ip._eval("::safe::interpConfigure " +
+ @ip_name))].each{|k, v|
+ if k == '-deleteHook'
+ if v =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
+ else
+ ret[k[1..-1]] = v
+ end
+ else
+ ret[k[1..-1]] = v
+ end
+ }
+ end
+ ret
+ end
+
+ def safeip_delete
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::interpDelete " + @ip_name)
+ end
+
+ def safeip_add_to_access_path(dir)
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::interpAddToAccessPath #{@ip_name} #{dir}")
+ end
+
+ def safeip_find_in_access_path(dir)
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::interpFindInAccessPath #{@ip_name} #{dir}")
+ end
+
+ def safeip_set_log_cmd(cmd = Proc.new)
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::setLogCmd #{@ip_name} #{_get_eval_string(cmd)}")
+ end
+end
+
+
+# encoding convert
+class MultiTkIp
+ def encoding
+ @interp.encoding
+ end
+ def encoding=(enc)
+ @interp.encoding = enc
+ end
+
+ def encoding_convertfrom(str, enc=None)
+ @interp.encoding_convertfrom(str, enc)
+ end
+ alias encoding_convert_from encoding_convertfrom
+
+ def encoding_convertto(str, enc=None)
+ @interp.encoding_convertto(str, enc)
+ end
+ alias encoding_convert_to encoding_convertto
+end
+
+
+# remove methods for security
+class MultiTkIp
+ # undef_method :instance_eval
+ undef_method :instance_variable_get
+ undef_method :instance_variable_set
+end
+
+
+# end of MultiTkIp definition
+
+# defend against modification
+#MultiTkIp.freeze
+#TclTkLib.freeze
+
+########################################
+# start Tk which depends on MultiTkIp
+module TkCore
+ INTERP = MultiTkIp
+end
+require 'tk'
diff --git a/ext/tk/lib/remote-tk.rb b/ext/tk/lib/remote-tk.rb
new file mode 100644
index 0000000000..1ef5310bde
--- /dev/null
+++ b/ext/tk/lib/remote-tk.rb
@@ -0,0 +1,468 @@
+#
+# remote-tk.rb - supports to control remote Tk interpreters
+# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+if defined? MultiTkIp
+ fail RuntimeError, "'remote-tk' library must be required before requiring 'multi-tk'"
+end
+
+class MultiTkIp; end
+class RemoteTkIp < MultiTkIp; end
+
+class MultiTkIp
+ @@IP_TABLE = {}.taint unless defined?(@@IP_TABLE)
+ @@TK_TABLE_LIST = [].taint unless defined?(@@TK_TABLE_LIST)
+ def self._IP_TABLE; @@IP_TABLE; end
+ def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end
+
+ @flag = true
+ def self._DEFAULT_MASTER
+ # work only once
+ if @flag
+ @flag = nil
+ @@DEFAULT_MASTER
+ else
+ nil
+ end
+ end
+end
+class RemoteTkIp
+ @@IP_TABLE = MultiTkIp._IP_TABLE unless defined?(@@IP_TABLE)
+ @@TK_TABLE_LIST = MultiTkIp._TK_TABLE_LIST unless defined?(@@TK_TABLE_LIST)
+end
+class << MultiTkIp
+ undef _IP_TABLE
+ undef _TK_TABLE_LIST
+end
+
+require 'multi-tk'
+
+class RemoteTkIp
+ if defined?(@@DEFAULT_MASTER)
+ MultiTkIp._DEFAULT_MASTER
+ else
+ @@DEFAULT_MASTER = MultiTkIp._DEFAULT_MASTER
+ end
+end
+
+
+###############################
+
+class << RemoteTkIp
+ undef new_master, new_slave, new_safe_slave
+ undef new_trusted_slave, new_safeTk
+
+ def new(*args, &b)
+ ip = __new(*args)
+ ip.eval_proc(&b) if b
+ ip
+ end
+end
+
+class RemoteTkIp
+ include TkUtil
+
+ def initialize(remote_ip, displayof=nil, timeout=5)
+ if $SAFE >= 4
+ fail SecurityError, "cannot access another interpreter at level #{$SAFE}"
+ end
+
+ @interp = MultiTkIp.__getip
+ @interp.allow_ruby_exit = false
+ @appname = @interp._invoke('tk', 'appname')
+ @remote = remote_ip.dup.freeze
+ if displayof.kind_of?(TkWindow)
+ @displayof = displayof.path.dup.freeze
+ else
+ @displayof = nil
+ end
+ if self.deleted?
+ fail RuntimeError, "no Tk application named \"#{@remote}\""
+ end
+
+ @tk_windows = {}
+ @tk_table_list = []
+ @slave_ip_tbl = {}
+ @slave_ip_top = {}
+
+ @tk_windows.taint unless @tk_windows.tainted?
+ @tk_table_list.taint unless @tk_table_list.tainted?
+ @slave_ip_tbl.taint unless @slave_ip_tbl.tainted?
+ @slave_ip_top.taint unless @slave_ip_top.tainted?
+
+ @system = Object.new
+
+ @threadgroup = ThreadGroup.new
+
+ @safe_level = [$SAFE]
+
+ @wait_on_mainloop = [true, false]
+
+ @cmd_queue = Queue.new
+
+=begin
+ @cmd_receiver, @receiver_watchdog = _create_receiver_and_watchdog()
+
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+
+ @threadgroup.enclose
+=end
+ @@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
+
+ @@IP_TABLE[@threadgroup] = self
+ @@TK_TABLE_LIST.size.times{
+ (tbl = {}).tainted? || tbl.taint
+ @tk_table_list << tbl
+ }
+
+ @ret_val = TkVariable.new
+ if timeout > 0 && ! _available_check(timeout)
+ fail RuntimeError, "cannot create connection"
+ end
+ @ip_id = _create_connection
+
+ class << self
+ undef :instance_eval
+ end
+
+ self.freeze # defend against modification
+ end
+
+ def _ip_id_
+ @ip_id
+ end
+
+ def _available_check(timeout = 5)
+ return nil if timeout < 1
+ @ret_val.value = ''
+ @interp._invoke('send', '-async', @remote,
+ 'send', '-async', Tk.appname,
+ "set #{@ret_val.id} ready")
+ Tk.update
+ if @ret_val != 'ready'
+ (1..(timeout*5)).each{
+ sleep 0.2
+ Tk.update
+ break if @ret_val == 'ready'
+ }
+ end
+ @ret_val.value == 'ready'
+ end
+ private :_available_check
+
+ def _create_connection
+ ip_id = '_' + @interp._invoke('send', @remote, <<-'EOS') + '_'
+ if {[catch {set _rubytk_control_ip_id_} ret] != 0} {
+ set _rubytk_control_ip_id_ 0
+ } else {
+ set _rubytk_control_ip_id_ [expr $ret + 1]
+ }
+ return $_rubytk_control_ip_id_
+ EOS
+
+ @interp._invoke('send', @remote, <<-EOS)
+ proc rb_out#{ip_id} args {
+ send #{@appname} rb_out \$args
+ }
+ EOS
+
+ ip_id
+ end
+ private :_create_connection
+
+ def _appsend(enc_mode, async, *cmds)
+ p ['_appsend', [@remote, @displayof], enc_mode, async, cmds] if $DEBUG
+ if $SAFE >= 4
+ fail SecurityError, "cannot send commands at level 4"
+ elsif $SAFE >= 1 && cmds.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted commands at level #{$SAFE}"
+ end
+
+ cmds = @interp._merge_tklist(*_conv_args([], enc_mode, *cmds))
+ if @displayof
+ if async
+ @interp.__invoke('send', '-async', '-displayof', @displayof,
+ '--', @remote, *cmds)
+ else
+ @interp.__invoke('send', '-displayof', @displayof,
+ '--', @remote, *cmds)
+ end
+ else
+ if async
+ @interp.__invoke('send', '-async', '--', @remote, *cmds)
+ else
+ @interp.__invoke('send', '--', @remote, *cmds)
+ end
+ end
+ end
+ private :_appsend
+
+ def ready?(timeout=5)
+ if timeout < 0
+ fail ArgumentError, "timeout must be positive number"
+ end
+ _available_check(timeout)
+ end
+
+ def is_rubytk?
+ return false if _appsend(false, false, 'info', 'command', 'ruby') == ""
+ [ _appsend(false, false, 'ruby', 'RUBY_VERSION'),
+ _appsend(false, false, 'set', 'tk_patchLevel') ]
+ end
+
+ def appsend(async, *args)
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ if @displayof
+ Tk.appsend_displayof(@remote, @displayof, async, *args)
+ else
+ Tk.appsend(@remote, async, *args)
+ end
+ end
+
+ def rb_appsend(async, *args)
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ if @displayof
+ Tk.rb_appsend_displayof(@remote, @displayof, async, *args)
+ else
+ Tk.rb_appsend(@remote, async, *args)
+ end
+ end
+
+ def create_slave(name, safe=false)
+ if safe
+ safe_opt = ''
+ else
+ safe_opt = '-safe'
+ end
+ _appsend(false, false, "interp create #{safe_opt} -- #{name}")
+ end
+
+ def make_safe
+ fail RuntimeError, 'cannot change safe mode of the remote interpreter'
+ end
+
+ def safe?
+ _appsend(false, false, 'interp issafe')
+ end
+
+ def safe_base?
+ false
+ end
+
+ def allow_ruby_exit?
+ false
+ end
+
+ def allow_ruby_exit= (mode)
+ fail RuntimeError, 'cannot change mode of the remote interpreter'
+ end
+
+ def delete
+ _appsend(false, true, 'exit')
+ end
+
+ def deleted?
+ if @displayof
+ lst = @interp._invoke_without_enc('winfo', 'interps',
+ '-displayof', @displayof)
+ else
+ lst = @interp._invoke_without_enc('winfo', 'interps')
+ end
+ unless @interp._split_tklist(lst).index(@remote)
+ true
+ else
+ false
+ end
+ end
+
+ def restart
+ fail RuntimeError, 'cannot restart the remote interpreter'
+ end
+
+ def __eval(str)
+ _appsend(false, false, str)
+ end
+ def _eval(str)
+ _appsend(nil, false, str)
+ end
+ def _eval_without_enc(str)
+ _appsend(false, false, str)
+ end
+ def _eval_with_enc(str)
+ _appsend(true, false, str)
+ end
+
+ def _invoke(*args)
+ _appsend(nil, false, *args)
+ end
+
+ def __invoke(*args)
+ _appsend(false, false, *args)
+ end
+ def _invoke(*args)
+ _appsend(nil, false, *args)
+ end
+ def _invoke_without_enc(*args)
+ _appsend(false, false, *args)
+ end
+ def _invoke_with_enc(*args)
+ _appsend(true, false, *args)
+ end
+
+ def _toUTF8(str, encoding)
+ @interp._toUTF8(str, encoding)
+ end
+
+ def _fromUTF8(str, encoding)
+ @interp._fromUTF8(str, encoding)
+ end
+
+ def _thread_vwait(var_name)
+ _appsend(false, 'thread_vwait', varname)
+ end
+
+ def _thread_tkwait(mode, target)
+ _appsend(false, 'thread_tkwait', mode, target)
+ end
+
+ def _return_value
+ @interp._return_value
+ end
+
+ def _get_variable(var_name, flag)
+ # ignore flag
+ _appsend(false, 'set', _get_eval_string(var_name))
+ end
+ def _get_variable2(var_name, index_name, flag)
+ # ignore flag
+ _appsend(false, 'set', "#{_get_eval_string(var_name)}(#{_get_eval_string(index_name)})")
+ end
+
+ def _set_variable(var_name, value, flag)
+ # ignore flag
+ _appsend(false, 'set', _get_eval_string(var_name), _get_eval_string(value))
+ end
+ def _set_variable2(var_name, index_name, value, flag)
+ # ignore flag
+ _appsend(false, 'set', "#{_get_eval_string(var_name)}(#{_get_eval_string(index_name)})", _get_eval_string(value))
+ end
+
+ def _unset_variable(var_name, flag)
+ # ignore flag
+ _appsend(false, 'unset', _get_eval_string(var_name))
+ end
+ def _unset_variable2(var_name, index_name, flag)
+ # ignore flag
+ _appsend(false, 'unset', "#{var_name}(#{index_name})")
+ end
+
+ def _get_global_var(var_name)
+ _appsend(false, 'set', _get_eval_string(var_name))
+ end
+ def _get_global_var2(var_name, index_name)
+ _appsend(false, 'set', "#{_get_eval_string(var_name)}(#{_get_eval_string(index_name)})")
+ end
+
+ def _set_global_var(var_name, value)
+ _appsend(false, 'set', _get_eval_string(var_name), _get_eval_string(value))
+ end
+ def _set_global_var2(var_name, index_name, value)
+ _appsend(false, 'set', "#{_get_eval_string(var_name)}(#{_get_eval_string(index_name)})", _get_eval_string(value))
+ end
+
+ def _unset_global_var(var_name)
+ _appsend(false, 'unset', _get_eval_string(var_name))
+ end
+ def _unset_global_var2(var_name, index_name)
+ _appsend(false, 'unset', "#{var_name}(#{index_name})")
+ end
+
+ def _split_tklist(str)
+ @interp._split_tklist(str)
+ end
+
+ def _merge_tklist(*args)
+ @interp._merge_tklist(*args)
+ end
+
+ def _conv_listelement(str)
+ @interp._conv_listelement(str)
+ end
+
+ def mainloop
+ fail RuntimeError, 'not support "mainloop" on the remote interpreter'
+ end
+ def mainloop_watchdog
+ fail RuntimeError, 'not support "mainloop_watchdog" on the remote interpreter'
+ end
+ def do_one_evant(flag = nil)
+ fail RuntimeError, 'not support "do_one_event" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception
+ fail RuntimeError, 'not support "mainloop_abort_on_exception" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception=(mode)
+ fail RuntimeError, 'not support "mainloop_abort_on_exception=" on the remote interpreter'
+ end
+ def set_eventloop_tick(*args)
+ fail RuntimeError, 'not support "set_eventloop_tick" on the remote interpreter'
+ end
+ def get_eventloop_tick
+ fail RuntimeError, 'not support "get_eventloop_tick" on the remote interpreter'
+ end
+ def set_no_event_wait(*args)
+ fail RuntimeError, 'not support "set_no_event_wait" on the remote interpreter'
+ end
+ def get_no_event_wait
+ fail RuntimeError, 'not support "get_no_event_wait" on the remote interpreter'
+ end
+ def set_eventloop_weight(*args)
+ fail RuntimeError, 'not support "set_eventloop_weight" on the remote interpreter'
+ end
+ def get_eventloop_weight
+ fail RuntimeError, 'not support "get_eventloop_weight" on the remote interpreter'
+ end
+end
+
+class << RemoteTkIp
+ def mainloop(*args)
+ fail RuntimeError, 'not support "mainloop" on the remote interpreter'
+ end
+ def mainloop_watchdog(*args)
+ fail RuntimeError, 'not support "mainloop_watchdog" on the remote interpreter'
+ end
+ def do_one_evant(flag = nil)
+ fail RuntimeError, 'not support "do_one_event" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception
+ fail RuntimeError, 'not support "mainloop_abort_on_exception" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception=(mode)
+ fail RuntimeError, 'not support "mainloop_abort_on_exception=" on the remote interpreter'
+ end
+ def set_eventloop_tick(*args)
+ fail RuntimeError, 'not support "set_eventloop_tick" on the remote interpreter'
+ end
+ def get_eventloop_tick
+ fail RuntimeError, 'not support "get_eventloop_tick" on the remote interpreter'
+ end
+ def set_no_event_wait(*args)
+ fail RuntimeError, 'not support "set_no_event_wait" on the remote interpreter'
+ end
+ def get_no_event_wait
+ fail RuntimeError, 'not support "get_no_event_wait" on the remote interpreter'
+ end
+ def set_eventloop_weight(*args)
+ fail RuntimeError, 'not support "set_eventloop_weight" on the remote interpreter'
+ end
+ def get_eventloop_weight
+ fail RuntimeError, 'not support "get_eventloop_weight" on the remote interpreter'
+ end
+end
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index 59d78da5d2..807ccd2285 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -1,22 +1,73 @@
#
-# tk.rb - Tk interface modue using tcltklib
-# $Date$
-# by Yukihiro Matsumoto <matz@netlab.co.jp>
+# tk.rb - Tk interface module using tcltklib
+# $Date$
+# by Yukihiro Matsumoto <matz@netlab.jp>
# use Shigehiro's tcltklib
-require "tcltklib"
-require "tkutil"
+require 'tcltklib'
+require 'tkutil'
+# autoload
+require 'tk/autoload'
+
+class TclTkIp
+ # backup original (without encoding) _eval and _invoke
+ alias _eval_without_enc _eval
+ alias _invoke_without_enc _invoke
+
+ def _ip_id_
+ ''
+ end
+end
+
+# define TkComm module (step 1: basic functions)
module TkComm
- WidgetClassNames = {}
+ include TkUtil
+ extend TkUtil
+
+ WidgetClassNames = {}.taint
+ TkExtlibAutoloadModule = [].taint
- None = Object.new
- def None.to_s
- 'None'
+ # None = Object.new ### --> definition is moved to TkUtil module
+ # def None.to_s
+ # 'None'
+ # end
+ # None.freeze
+
+ #Tk_CMDTBL = {}
+ #Tk_WINDOWS = {}
+ Tk_IDs = ["00000".taint, "00000".taint].freeze # [0]-cmdid, [1]-winid
+
+ # for backward compatibility
+ Tk_CMDTBL = Object.new
+ def Tk_CMDTBL.method_missing(id, *args)
+ TkCore::INTERP.tk_cmd_tbl.__send__(id, *args)
+ end
+ Tk_CMDTBL.freeze
+ Tk_WINDOWS = Object.new
+ def Tk_WINDOWS.method_missing(id, *args)
+ TkCore::INTERP.tk_windows.__send__(id, *args)
end
+ Tk_WINDOWS.freeze
- Tk_CMDTBL = {}
- Tk_WINDOWS = {}
+ self.instance_eval{
+ @cmdtbl = [].taint
+ }
+
+ unless const_defined?(:GET_CONFIGINFO_AS_ARRAY)
+ # GET_CONFIGINFO_AS_ARRAY = false => returns a Hash { opt =>val, ... }
+ # true => returns an Array [[opt,val], ... ]
+ # val is a list which includes resource info.
+ GET_CONFIGINFO_AS_ARRAY = true
+ end
+ unless const_defined?(:GET_CONFIGINFOwoRES_AS_ARRAY)
+ # for configinfo without resource info; list of [opt, value] pair
+ # false => returns a Hash { opt=>val, ... }
+ # true => returns an Array [[opt,val], ... ]
+ GET_CONFIGINFOwoRES_AS_ARRAY = true
+ end
+ # *** ATTENTION ***
+ # 'current_configinfo' method always returns a Hash under all cases of above.
def error_at
frames = caller()
@@ -31,65 +82,310 @@ module TkComm
return TkRoot.new if path == '.'
begin
- tk_class = TkCore::INTERP._invoke('winfo', 'class', path)
+ #tk_class = TkCore::INTERP._invoke('winfo', 'class', path)
+ tk_class = Tk.ip_invoke_without_enc('winfo', 'class', path)
rescue
return path
end
- ruby_class = WidgetClassNames[tk_class]
- gen_class_name = ruby_class.name + 'GeneratedOnTk'
- unless Object.const_defined? gen_class_name
- eval "class #{gen_class_name}<#{ruby_class.name}
- def initialize(path)
- @path=path
- Tk_WINDOWS[@path] = self
- end
- end"
+ if ruby_class = WidgetClassNames[tk_class]
+ ruby_class_name = ruby_class.name
+ # gen_class_name = ruby_class_name + 'GeneratedOnTk'
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else # ruby_class == nil
+ mods = TkExtlibAutoloadModule.find_all{|m| m.const_defined?(tk_class)}
+ mods.each{|mod|
+ begin
+ mod.const_get(tk_class) # auto_load
+ break if (ruby_class = WidgetClassNames[tk_class])
+ rescue LoadError
+ # ignore load error
+ end
+ }
+
+ unless ruby_class
+ std_class = 'Tk' << tk_class
+ if Object.const_defined?(std_class)
+ Object.const_get(std_class) # auto_load
+ ruby_class = WidgetClassNames[tk_class]
+ end
+ end
+
+ if ruby_class
+ # found
+ ruby_class_name = ruby_class.name
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else
+ # unknown
+ ruby_class_name = 'TkWindow'
+ gen_class_name = 'TkWidget_' + tk_class
+ classname_def = "WidgetClassName = '#{tk_class}'.freeze"
+ end
end
- eval "#{gen_class_name}.new('#{path}')"
+
+###################################
+=begin
+ if ruby_class = WidgetClassNames[tk_class]
+ ruby_class_name = ruby_class.name
+ # gen_class_name = ruby_class_name + 'GeneratedOnTk'
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else
+ mod = TkExtlibAutoloadModule.find{|m| m.const_defined?(tk_class)}
+ if mod
+ ruby_class_name = mod.name + '::' + tk_class
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ elsif Object.const_defined?('Tk' + tk_class)
+ ruby_class_name = 'Tk' + tk_class
+ # gen_class_name = ruby_class_name + 'GeneratedOnTk'
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else
+ ruby_class_name = 'TkWindow'
+ # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk'
+ gen_class_name = 'TkWidget_' + tk_class
+ classname_def = "WidgetClassName = '#{tk_class}'.freeze"
+ end
+ end
+=end
+
+=begin
+ unless Object.const_defined? gen_class_name
+ Object.class_eval "class #{gen_class_name}<#{ruby_class_name}
+ #{classname_def}
+ end"
+ end
+ Object.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}',
+ 'without_creating'=>true)"
+=end
+ base = Object
+ gen_class_name.split('::').each{|klass|
+ next if klass == ''
+ if base.const_defined?(klass)
+ base = base.class_eval klass
+ else
+ base = base.class_eval "class #{klass}<#{ruby_class_name}
+ #{classname_def}
+ end
+ #{klass}"
+ end
+ }
+ base.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}',
+ 'without_creating'=>true)"
end
+ private :_genobj_for_tkwidget
+ module_function :_genobj_for_tkwidget
- def tk_tcl2ruby(val)
- if val =~ /^rb_out (c\d+)/
- return Tk_CMDTBL[$1]
+ def _at(x,y=nil)
+ if y
+ "@#{Integer(x)},#{Integer(y)}"
+ else
+ "@#{Integer(x)}"
end
- if val.include? ?\s
- return val.split.collect{|v| tk_tcl2ruby(v)}
+ end
+ module_function :_at
+
+ def tk_tcl2ruby(val, enc_mode = false, listobj = true)
+ if val =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ #return Tk_CMDTBL[$1]
+ return TkCore::INTERP.tk_cmd_tbl[$1]
+ #cmd_obj = TkCore::INTERP.tk_cmd_tbl[$1]
+ #if cmd_obj.kind_of?(Proc) || cmd_obj.kind_of?(Method)
+ # cmd_obj
+ #else
+ # cmd_obj.cmd
+ #end
end
+ #if val.include? ?\s
+ # return val.split.collect{|v| tk_tcl2ruby(v)}
+ #end
case val
when /^@font/
TkFont.get_obj(val)
when /^-?\d+$/
val.to_i
when /^\./
- Tk_WINDOWS[val] ? Tk_WINDOWS[val] : _genobj_for_tkwidget(val)
- when / /
- val.split.collect{|elt|
- tk_tcl2ruby(elt)
- }
- when /^-?\d+\.\d*$/
+ #Tk_WINDOWS[val] ? Tk_WINDOWS[val] : _genobj_for_tkwidget(val)
+ TkCore::INTERP.tk_windows[val]?
+ TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val)
+ when /^i(_\d+_)?\d+$/
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ when /^-?\d+\.?\d*(e[-+]?\d+)?$/
val.to_f
+ when /\\ /
+ val.gsub(/\\ /, ' ')
+ when /[^\\] /
+ if listobj
+ tk_split_escstr(val).collect{|elt|
+ tk_tcl2ruby(elt, enc_mode, listobj)
+ }
+ elsif enc_mode
+ _fromUTF8(val)
+ else
+ val
+ end
else
- val
+ if enc_mode
+ _fromUTF8(val)
+ else
+ val
+ end
end
end
+ private :tk_tcl2ruby
+ module_function :tk_tcl2ruby
+ #private_class_method :tk_tcl2ruby
+
+unless const_defined?(:USE_TCLs_LIST_FUNCTIONS)
+ USE_TCLs_LIST_FUNCTIONS = true
+end
+
+if USE_TCLs_LIST_FUNCTIONS
+ ###########################################################################
+ # use Tcl function version of split_list
+ ###########################################################################
+
+ def tk_split_escstr(str)
+ TkCore::INTERP._split_tklist(str)
+ end
+
+ def tk_split_sublist(str, depth=-1)
+ # return [] if str == ""
+ # list = TkCore::INTERP._split_tklist(str)
+ if depth == 0
+ return "" if str == ""
+ list = [str]
+ else
+ return [] if str == ""
+ list = TkCore::INTERP._split_tklist(str)
+ end
+ if list.size == 1
+ tk_tcl2ruby(list[0], nil, false)
+ else
+ list.collect{|token| tk_split_sublist(token, depth - 1)}
+ end
+ end
+
+ def tk_split_list(str, depth=0)
+ return [] if str == ""
+ TkCore::INTERP._split_tklist(str).collect{|token|
+ tk_split_sublist(token, depth - 1)
+ }
+ end
+
+ def tk_split_simplelist(str)
+ #lst = TkCore::INTERP._split_tklist(str)
+ #if (lst.size == 1 && lst =~ /^\{.*\}$/)
+ # TkCore::INTERP._split_tklist(str[1..-2])
+ #else
+ # lst
+ #end
+ TkCore::INTERP._split_tklist(str)
+ end
+
+ def array2tk_list(ary)
+ return "" if ary.size == 0
+
+ dst = ary.collect{|e|
+ if e.kind_of? Array
+ array2tk_list(e)
+ elsif e.kind_of? Hash
+ tmp_ary = []
+ #e.each{|k,v| tmp_ary << k << v }
+ e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
+ array2tk_list(tmp_ary)
+ else
+ _get_eval_string(e)
+ end
+ }
+ TkCore::INTERP._merge_tklist(*dst)
+ end
+
+else
+ ###########################################################################
+ # use Ruby script version of split_list (traditional methods)
+ ###########################################################################
+
+ def tk_split_escstr(str)
+ return [] if str == ""
+ list = []
+ token = nil
+ escape = false
+ brace = 0
+ str.split('').each {|c|
+ brace += 1 if c == '{' && !escape
+ brace -= 1 if c == '}' && !escape
+ if brace == 0 && c == ' ' && !escape
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ token = nil
+ else
+ token = (token || "") << c
+ end
+ escape = (c == '\\' && !escape)
+ }
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ list
+ end
+
+ def tk_split_sublist(str, depth=-1)
+ #return [] if str == ""
+ #return [tk_split_sublist(str[1..-2])] if str =~ /^\{.*\}$/
+ #list = tk_split_escstr(str)
+ if depth == 0
+ return "" if str == ""
+ str = str[1..-2] if str =~ /^\{.*\}$/
+ list = [str]
+ else
+ return [] if str == []
+ return [tk_split_sublist(str[1..-2], depth - 1)] if str =~ /^\{.*\}$/
+ list = tk_split_escstr(str)
+ end
+ if list.size == 1
+ tk_tcl2ruby(list[0], nil, false)
+ else
+ list.collect{|token| tk_split_sublist(token, depth - 1)}
+ end
+ end
+
+ def tk_split_list(str, depth=0)
+ return [] if str == ""
+ tk_split_escstr(str).collect{|token| tk_split_sublist(token, depth - 1)}
+ end
+=begin
def tk_split_list(str)
return [] if str == ""
idx = str.index('{')
- return tk_tcl2ruby(str) unless idx
+ while idx and idx > 0 and str[idx-1] == ?\\
+ idx = str.index('{', idx+1)
+ end
+ unless idx
+ list = tk_tcl2ruby(str)
+ unless Array === list
+ list = [list]
+ end
+ return list
+ end
list = tk_tcl2ruby(str[0,idx])
list = [] if list == ""
str = str[idx+1..-1]
i = -1
+ escape = false
brace = 1
str.each_byte {|c|
i += 1
- brace += 1 if c == ?{
- brace -= 1 if c == ?}
+ brace += 1 if c == ?{ && !escape
+ brace -= 1 if c == ?} && !escape
+ escape = (c == ?\\)
break if brace == 0
}
+ if str.size == i + 1
+ return tk_split_list(str[0, i])
+ end
if str[0, i] == ' '
list.push ' '
else
@@ -98,110 +394,202 @@ module TkComm
list += tk_split_list(str[i+1..-1])
list
end
+=end
def tk_split_simplelist(str)
return [] if str == ""
- idx = str.index('{')
- return str.split unless idx
-
- list = str[0,idx].split
- str = str[idx+1..-1]
- i = -1
- brace = 1
- str.each_byte {|c|
- i += 1
- brace += 1 if c == ?{
- brace -= 1 if c == ?}
- break if brace == 0
+ list = []
+ token = nil
+ escape = false
+ brace = 0
+ str.split('').each {|c|
+ if c == '\\' && !escape
+ escape = true
+ token = (token || "") << c if brace > 0
+ next
+ end
+ brace += 1 if c == '{' && !escape
+ brace -= 1 if c == '}' && !escape
+ if brace == 0 && c == ' ' && !escape
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ token = nil
+ else
+ token = (token || "") << c
+ end
+ escape = false
}
- if i == 0
- list.push ''
- elsif str[0, i] == ' '
- list.push ' '
- else
- list.push str[0..i-1]
- end
- list += tk_split_simplelist(str[i+1..-1])
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
list
end
- private :tk_tcl2ruby, :tk_split_list, :tk_split_simplelist
-
- def hash_kv(keys)
- conf = []
- if keys and keys != None
- for k, v in keys
- conf.push("-#{k}")
- conf.push(v)
- end
- end
- conf
- end
- private :hash_kv
def array2tk_list(ary)
ary.collect{|e|
if e.kind_of? Array
- "{#{array2tk_list(e)}}"
+ "{#{array2tk_list(e)}}"
elsif e.kind_of? Hash
- "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
+ # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
+ e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
+ array2tk_list(tmp_ary)
else
- s = _get_eval_string(e)
- (s.index(/\s/))? "{#{s}}": s
+ s = _get_eval_string(e)
+ (s.index(/\s/) || s.size == 0)? "{#{s}}": s
end
}.join(" ")
end
+end
+
+ private :tk_split_escstr, :tk_split_sublist
+ private :tk_split_list, :tk_split_simplelist
private :array2tk_list
+ module_function :tk_split_escstr, :tk_split_sublist
+ module_function :tk_split_list, :tk_split_simplelist
+ module_function :array2tk_list
+
+ private_class_method :tk_split_escstr, :tk_split_sublist
+ private_class_method :tk_split_list, :tk_split_simplelist
+ private_class_method :array2tk_list
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _symbolkey2str(keys)
+ h = {}
+ keys.each{|key,value| h[key.to_s] = value}
+ h
+ end
+ private :_symbolkey2str
+ module_function :_symbolkey2str
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
+ # def hash_kv(keys, enc_mode = nil, conf = [], flat = false)
+ def hash_kv(keys, enc_mode = nil, conf = nil)
+ # Hash {key=>val, key=>val, ... } or Array [ [key, val], [key, val], ... ]
+ # ==> Array ['-key', val, '-key', val, ... ]
+ dst = []
+ if keys and keys != None
+ keys.each{|k, v|
+ #dst.push("-#{k}")
+ dst.push('-' + k.to_s)
+ if v != None
+ # v = _get_eval_string(v, enc_mode) if (enc_mode || flat)
+ v = _get_eval_string(v, enc_mode) if enc_mode
+ dst.push(v)
+ end
+ }
+ end
+ if conf
+ conf + dst
+ else
+ dst
+ end
+ end
+ private :hash_kv
+ module_function :hash_kv
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
def bool(val)
case val
when "1", 1, 'yes', 'true'
- TRUE
+ true
else
- FALSE
+ false
end
end
+
def number(val)
case val
when /^-?\d+$/
val.to_i
- when /^-?\d+\.\d*$/
+ when /^-?\d+\.?\d*(e[-+]?\d+)?$/
val.to_f
else
- val
+ fail(ArgumentError, "invalid value for Number:'#{val}'")
end
end
def string(val)
if val == "{}"
''
- elsif val[0] == ?{
+ elsif val[0] == ?{ && val[-1] == ?}
val[1..-2]
else
val
end
end
- def list(val)
- tk_split_list(val).to_a
+ def num_or_str(val)
+ begin
+ number(val)
+ rescue ArgumentError
+ string(val)
+ end
+ end
+=end
+
+ def list(val, depth=0)
+ tk_split_list(val, depth)
+ end
+ def simplelist(val)
+ tk_split_simplelist(val)
end
def window(val)
- Tk_WINDOWS[val]
+ if val =~ /^\./
+ #Tk_WINDOWS[val]? Tk_WINDOWS[val] : _genobj_for_tkwidget(val)
+ TkCore::INTERP.tk_windows[val]?
+ TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val)
+ else
+ nil
+ end
+ end
+ def image_obj(val)
+ if val =~ /^i(_\d+_)?\d+$/
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ else
+ val
+ end
end
def procedure(val)
- if val =~ /^rb_out (c\d+)/
- Tk_CMDTBL[$1]
+ if val =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ #Tk_CMDTBL[$1]
+ #TkCore::INTERP.tk_cmd_tbl[$1]
+ TkCore::INTERP.tk_cmd_tbl[$1].cmd
else
- nil
+ #nil
+ val
end
end
- private :bool, :number, :string, :list, :window, :procedure
+ private :bool, :number, :string, :num_or_str
+ private :list, :simplelist, :window, :procedure
+ module_function :bool, :number, :num_or_str, :string
+ module_function :list, :simplelist, :window, :image_obj, :procedure
- def _get_eval_string(str)
+ def _toUTF8(str, encoding = nil)
+ TkCore::INTERP._toUTF8(str, encoding)
+ end
+ def _fromUTF8(str, encoding = nil)
+ TkCore::INTERP._fromUTF8(str, encoding)
+ end
+ private :_toUTF8, :_fromUTF8
+ module_function :_toUTF8, :_fromUTF8
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _get_eval_string(str, enc_mode = nil)
return nil if str == None
- if str.kind_of?(String)
- # do nothing
+ if str.kind_of?(TkObject)
+ str = str.path
+ elsif str.kind_of?(String)
+ str = _toUTF8(str) if enc_mode
+ elsif str.kind_of?(Symbol)
+ str = str.id2name
+ str = _toUTF8(str) if enc_mode
elsif str.kind_of?(Hash)
- str = hash_kv(str).join(" ")
+ str = hash_kv(str, enc_mode).join(" ")
elsif str.kind_of?(Array)
str = array2tk_list(str)
+ str = _toUTF8(str) if enc_mode
elsif str.kind_of?(Proc)
str = install_cmd(str)
elsif str == nil
@@ -212,138 +600,203 @@ module TkComm
str = "1"
elsif (str.respond_to?(:to_eval))
str = str.to_eval()
+ str = _toUTF8(str) if enc_mode
else
- str = str.to_s()
+ str = str.to_s() || ''
+ unless str.kind_of? String
+ fail RuntimeError, "fail to convert the object to a string"
+ end
+ str = _toUTF8(str) if enc_mode
end
return str
end
+=end
+=begin
+ def _get_eval_string(obj, enc_mode = nil)
+ case obj
+ when Numeric
+ obj.to_s
+ when String
+ (enc_mode)? _toUTF8(obj): obj
+ when Symbol
+ (enc_mode)? _toUTF8(obj.id2name): obj.id2name
+ when TkObject
+ obj.path
+ when Hash
+ hash_kv(obj, enc_mode).join(' ')
+ when Array
+ (enc_mode)? _toUTF8(array2tk_list(obj)): array2tk_list(obj)
+ when Proc, Method, TkCallbackEntry
+ install_cmd(obj)
+ when false
+ '0'
+ when true
+ '1'
+ when nil
+ ''
+ when None
+ nil
+ else
+ if (obj.respond_to?(:to_eval))
+ (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval
+ else
+ begin
+ obj = obj.to_s || ''
+ rescue
+ fail RuntimeError, "fail to convert object '#{obj}' to string"
+ end
+ (enc_mode)? _toUTF8(obj): obj
+ end
+ end
+ end
private :_get_eval_string
-
- def ruby2tcl(v)
+ module_function :_get_eval_string
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _get_eval_enc_str(obj)
+ return obj if obj == None
+ _get_eval_string(obj, true)
+ end
+ private :_get_eval_enc_str
+ module_function :_get_eval_enc_str
+=end
+
+=begin
+ ### --> obsolete
+ def ruby2tcl(v, enc_mode = nil)
if v.kind_of?(Hash)
v = hash_kv(v)
v.flatten!
- v.collect{|e|ruby2tcl(e)}
+ v.collect{|e|ruby2tcl(e, enc_mode)}
else
- _get_eval_string(v)
+ _get_eval_string(v, enc_mode)
end
end
private :ruby2tcl
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _conv_args(args, enc_mode, *src_args)
+ conv_args = []
+ src_args.each{|arg|
+ conv_args << _get_eval_string(arg, enc_mode) unless arg == None
+ # if arg.kind_of?(Hash)
+ # arg.each{|k, v|
+ # args << '-' + k.to_s
+ # args << _get_eval_string(v, enc_mode)
+ # }
+ # elsif arg != None
+ # args << _get_eval_string(arg, enc_mode)
+ # end
+ }
+ args + conv_args
+ end
+ private :_conv_args
+=end
- Tk_IDs = [0, 0] # [0]-cmdid, [1]-winid
def _curr_cmd_id
- id = format("c%.4d", Tk_IDs[0])
+ #id = format("c%.4d", Tk_IDs[0])
+ id = "c" + TkCore::INTERP._ip_id_ + TkComm::Tk_IDs[0]
end
def _next_cmd_id
id = _curr_cmd_id
- Tk_IDs[0] += 1
+ #Tk_IDs[0] += 1
+ TkComm::Tk_IDs[0].succ!
id
end
+ private :_curr_cmd_id, :_next_cmd_id
+ module_function :_curr_cmd_id, :_next_cmd_id
+
def install_cmd(cmd)
return '' if cmd == ''
id = _next_cmd_id
- Tk_CMDTBL[id] = cmd
- @cmdtbl = [] unless @cmdtbl
+ #Tk_CMDTBL[id] = cmd
+ if cmd.kind_of?(TkCallbackEntry)
+ TkCore::INTERP.tk_cmd_tbl[id] = cmd
+ else
+ TkCore::INTERP.tk_cmd_tbl[id] = TkCore::INTERP.get_cb_entry(cmd)
+ end
+ @cmdtbl = [] unless defined? @cmdtbl
+ @cmdtbl.taint unless @cmdtbl.tainted?
@cmdtbl.push id
- return format("rb_out %s", id);
+ #return Kernel.format("rb_out %s", id);
+ return 'rb_out' + TkCore::INTERP._ip_id_ + ' ' + id
end
def uninstall_cmd(id)
- id = $1 if /rb_out (c\d+)/ =~ id
- Tk_CMDTBL[id] = nil
- end
- private :install_cmd, :uninstall_cmd
-
- def install_win(ppath)
- id = format("w%.4d", Tk_IDs[1])
- Tk_IDs[1] += 1
- if !ppath or ppath == "."
- @path = format(".%s", id);
+ id = $1 if /rb_out\S* (c(_\d+_)?\d+)/ =~ id
+ #Tk_CMDTBL.delete(id)
+ TkCore::INTERP.tk_cmd_tbl.delete(id)
+ end
+ # private :install_cmd, :uninstall_cmd
+ module_function :install_cmd, :uninstall_cmd
+
+=begin
+ def install_win(ppath,name=nil)
+ if !name or name == ''
+ #name = format("w%.4d", Tk_IDs[1])
+ #Tk_IDs[1] += 1
+ name = "w" + Tk_IDs[1]
+ Tk_IDs[1].succ!
+ end
+ if name[0] == ?.
+ @path = name.dup
+ elsif !ppath or ppath == "."
+ @path = Kernel.format(".%s", name);
+ else
+ @path = Kernel.format("%s.%s", ppath, name)
+ end
+ #Tk_WINDOWS[@path] = self
+ TkCore::INTERP.tk_windows[@path] = self
+ end
+=end
+ def install_win(ppath,name=nil)
+ if name
+ if name == ''
+ raise ArgumentError, "invalid wiget-name '#{name}'"
+ end
+ if name[0] == ?.
+ @path = '' + name
+ @path.freeze
+ return TkCore::INTERP.tk_windows[@path] = self
+ end
+ else
+ name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1]
+ Tk_IDs[1].succ!
+ end
+ if !ppath or ppath == '.'
+ @path = '.' + name
else
- @path = format("%s.%s", ppath, id)
+ @path = ppath + '.' + name
end
- Tk_WINDOWS[@path] = self
+ @path.freeze
+ TkCore::INTERP.tk_windows[@path] = self
end
def uninstall_win()
- Tk_WINDOWS[@path] = nil
- end
-
- class Event
- def initialize(seq,a,b,c,d,f,h,k,m,o,p,s,t,w,x,y,
- aa,bb,dd,ee,kk,nn,rr,ss,tt,ww,xx,yy)
- @serial = seq
- @above = a
- @num = b
- @count = c
- @detail = d
- @focus = (f == 1)
- @height = h
- @keycode = k
- @mode = m
- @override = (o == 1)
- @place = p
- @state = s
- @time = t
- @width = w
- @x = x
- @y = y
- @char = aa
- @borderwidth = bb
- @wheel_delta = dd
- @send_event = (ee == 1)
- @keysym = kk
- @keysym_num = nn
- @rootwin_id = rr
- @subwindow = ss
- @type = tt
- @widget = ww
- @x_root = xx
- @y_root = yy
- end
- attr :serial
- attr :above
- attr :num
- attr :count
- attr :detail
- attr :focus
- attr :height
- attr :keycode
- attr :mode
- attr :override
- attr :place
- attr :state
- attr :time
- attr :width
- attr :x
- attr :y
- attr :char
- attr :borderwidth
- attr :wheel_delta
- attr :send_event
- attr :keysym
- attr :keysym_num
- attr :rootwin_id
- attr :subwindow
- attr :type
- attr :widget
- attr :x_root
- attr :y_root
- end
-
- def install_bind(cmd, args=nil)
- if args
- id = install_cmd(proc{|*arg|
- TkUtil.eval_cmd cmd, *arg
- })
- id + " " + args
- else
- id = install_cmd(proc{|arg|
- TkUtil.eval_cmd cmd, Event.new(*arg)
- })
- id + ' %# %a %b %c %d %f %h %k %m %o %p %s %t %w %x %y' +
- ' %A %B %D %E %K %N %R %S %T %W %X %Y'
+ #Tk_WINDOWS.delete(@path)
+ TkCore::INTERP.tk_windows.delete(@path)
+ end
+ private :install_win, :uninstall_win
+
+ def _epath(win)
+ if win.kind_of?(TkObject)
+ win.epath
+ elsif win.respond_to?(:epath)
+ win.epath
+ else
+ win
end
end
+ private :_epath
+end
+
+# define TkComm module (step 2: event binding)
+module TkComm
+ include TkEvent
+ extend TkEvent
def tk_event_sequence(context)
if context.kind_of? TkVirtualEvent
@@ -351,11 +804,11 @@ module TkComm
end
if context.kind_of? Array
context = context.collect{|ev|
- if ev.kind_of? TkVirtualEvent
- ev.path
- else
- ev
- end
+ if ev.kind_of? TkVirtualEvent
+ ev.path
+ else
+ ev
+ end
}.join("><")
end
if /,/ =~ context
@@ -368,7 +821,8 @@ module TkComm
def _bind_core(mode, what, context, cmd, args=nil)
id = install_bind(cmd, args) if cmd
begin
- tk_call(*(what + ["<#{tk_event_sequence(context)}>", mode + id]))
+ tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>",
+ mode + id]))
rescue
uninstall_cmd(id) if cmd
fail
@@ -384,47 +838,82 @@ module TkComm
end
def _bind_remove(what, context)
- tk_call(*(what + ["<#{tk_event_sequence(context)}>", '']))
+ tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", '']))
end
def _bindinfo(what, context=nil)
if context
- tk_call(*what+["<#{tk_event_sequence(context)}>"]).collect {|cmdline|
- if cmdline =~ /^rb_out (c\d+)\s+(.*)$/
- [Tk_CMDTBL[$1], $2]
- else
- cmdline
- end
+ tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]) .collect {|cmdline|
+ if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/
+ #[Tk_CMDTBL[$1], $2]
+ [TkCore::INTERP.tk_cmd_tbl[$1], $2]
+ else
+ cmdline
+ end
}
else
- tk_split_simplelist(tk_call(*what)).collect!{|seq|
- l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
- case (subseq)
- when /^<<[^<>]+>>$/
- TkVirtualEvent.getobj(subseq[1..-2])
- when /^<[^<>]+>$/
- subseq[1..-2]
- else
- subseq.split('')
- end
- }.flatten
- (l.size == 1) ? l[0] : l
+ tk_split_simplelist(tk_call_without_enc(*what)).collect!{|seq|
+ l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
+ case (subseq)
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(subseq[1..-2])
+ when /^<[^<>]+>$/
+ subseq[1..-2]
+ else
+ subseq.split('')
+ end
+ }.flatten
+ (l.size == 1) ? l[0] : l
}
end
end
- private :install_bind, :tk_event_sequence,
- :_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo
+
+ def _bind_core_for_event_class(klass, mode, what, context, cmd, args=nil)
+ id = install_bind_for_event_class(klass, cmd, args) if cmd
+ begin
+ tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>",
+ mode + id]))
+ rescue
+ uninstall_cmd(id) if cmd
+ fail
+ end
+ end
+
+ def _bind_for_event_class(klass, what, context, cmd, args=nil)
+ _bind_core_for_event_class(klass, '', what, context, cmd, args)
+ end
+
+ def _bind_append_for_event_class(klass, what, context, cmd, args=nil)
+ _bind_core_for_event_class(klass, '+', what, context, cmd, args)
+ end
+
+ def _bind_remove_for_event_class(klass, what, context)
+ _bind_remove(what, context)
+ end
+
+ def _bindinfo_for_event_class(klass, what, context=nil)
+ _bindinfo(what, context)
+ end
+
+ private :tk_event_sequence
+ private :_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo
+ private :_bind_core_for_event_class, :_bind_for_event_class,
+ :_bind_append_for_event_class, :_bind_remove_for_event_class,
+ :_bindinfo_for_event_class
def bind(tagOrClass, context, cmd=Proc.new, args=nil)
_bind(["bind", tagOrClass], context, cmd, args)
+ tagOrClass
end
def bind_append(tagOrClass, context, cmd=Proc.new, args=nil)
_bind_append(["bind", tagOrClass], context, cmd, args)
+ tagOrClass
end
def bind_remove(tagOrClass, context)
_bind_remove(['bind', tagOrClass], context)
+ tagOrClass
end
def bindinfo(tagOrClass, context=nil)
@@ -433,41 +922,202 @@ module TkComm
def bind_all(context, cmd=Proc.new, args=nil)
_bind(['bind', 'all'], context, cmd, args)
+ TkBindTag::ALL
end
def bind_append_all(context, cmd=Proc.new, args=nil)
_bind_append(['bind', 'all'], context, cmd, args)
+ TkBindTag::ALL
+ end
+
+ def bind_remove_all(context)
+ _bind_remove(['bind', 'all'], context)
+ TkBindTag::ALL
end
def bindinfo_all(context=nil)
_bindinfo(['bind', 'all'], context)
end
+end
- def pack(*args)
- TkPack.configure *args
- end
- def grid(*args)
- TkGrid.configure *args
- end
+module TkCore
+ include TkComm
+ extend TkComm
- def update(idle=nil)
- if idle
- tk_call 'update', 'idletasks'
+ unless self.const_defined? :INTERP
+ if self.const_defined? :IP_NAME
+ name = IP_NAME.to_s
else
- tk_call 'update'
+ #name = nil
+ name = $0
+ end
+ if self.const_defined? :IP_OPTS
+ if IP_OPTS.kind_of?(Hash)
+ opts = hash_kv(IP_OPTS).join(' ')
+ else
+ opts = IP_OPTS.to_s
+ end
+ else
+ opts = ''
end
- end
-end
+ INTERP = TclTkIp.new(name, opts)
-module TkCore
- include TkComm
- extend TkComm
+ def INTERP.__getip
+ self
+ end
+
+ INTERP.instance_eval{
+ @tk_cmd_tbl = {}.taint
+ @tk_windows = {}.taint
+
+ @tk_table_list = [].taint
+
+ @init_ip_env = [].taint # table of Procs
+ @add_tk_procs = [].taint # table of [name, args, body]
+
+ @cb_entry_class = Class.new(TkCallbackEntry){|c|
+ class << c
+ def inspect
+ sprintf("#<Class(TkCallbackEntry):%0x>", self.__id__)
+ end
+ alias to_s inspect
+ end
+
+ def initialize(ip, cmd)
+ @ip = ip
+ @cmd = cmd
+ end
+ attr_reader :ip, :cmd
+ def call(*args)
+ @ip.cb_eval(@cmd, *args)
+ end
+ def inspect
+ sprintf("#<cb_entry:%0x>", self.__id__)
+ end
+ alias to_s inspect
+ }.freeze
+ }
+
+ def INTERP.cb_entry_class
+ @cb_entry_class
+ end
+ def INTERP.tk_cmd_tbl
+ @tk_cmd_tbl
+ end
+ def INTERP.tk_windows
+ @tk_windows
+ end
- INTERP = TclTkIp.new
+ class Tk_OBJECT_TABLE
+ def initialize(id)
+ @id = id
+ end
+ def method_missing(m, *args, &b)
+ TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b)
+ end
+ end
+
+ def INTERP.tk_object_table(id)
+ @tk_table_list[id]
+ end
+ def INTERP.create_table
+ id = @tk_table_list.size
+ (tbl = {}).tainted? || tbl.taint
+ @tk_table_list << tbl
+# obj = Object.new
+# obj.instance_eval <<-EOD
+# def self.method_missing(m, *args)
+# TkCore::INTERP.tk_object_table(#{id}).send(m, *args)
+# end
+# EOD
+# return obj
+ Tk_OBJECT_TABLE.new(id)
+ end
+
+ def INTERP.get_cb_entry(cmd)
+ @cb_entry_class.new(__getip, cmd).freeze
+ end
+ def INTERP.cb_eval(cmd, *args)
+ TkUtil._get_eval_string(TkUtil.eval_cmd(cmd, *args))
+ end
+
+ def INTERP.init_ip_env(script = Proc.new)
+ @init_ip_env << script
+ script.call(self)
+ end
+ def INTERP.add_tk_procs(name, args = nil, body = nil)
+ @add_tk_procs << [name, args, body]
+ self._invoke('proc', name, args, body) if args && body
+ end
+ def INTERP.init_ip_internal
+ ip = self
+ @init_ip_env.each{|script| script.call(ip)}
+ @add_tk_procs.each{|name,args,body| ip._invoke('proc',name,args,body)}
+ end
+ end
+
+ WIDGET_DESTROY_HOOK = '<WIDGET_DESTROY_HOOK>'
+ INTERP._invoke_without_enc('event', 'add',
+ "<#{WIDGET_DESTROY_HOOK}>", 'Destroy')
+ INTERP._invoke_without_enc('bind', 'all', "<#{WIDGET_DESTROY_HOOK}>",
+ install_bind(proc{|xpath|
+ path = xpath[1..-1]
+ unless TkCore::INTERP.deleted?
+ if (widget = TkCore::INTERP.tk_windows[path])
+ if widget.respond_to?(:__destroy_hook__)
+ begin
+ widget.__destroy_hook__
+ rescue Exception
+ end
+ end
+ end
+ end
+ }, 'x%W'))
+ INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '',
+ "bind all <#{WIDGET_DESTROY_HOOK}> {}")
+
+ INTERP.add_tk_procs('rb_out', 'args', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkCore callback} $args} ret]] != 0} {
+ #return -code $st $ret
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ return -code $st \
+ -errorinfo [string range $ret [expr $idx + 2] \
+ [string length $ret]] \
+ [string range $ret 0 [expr $idx - 1]]
+ } else {
+ return -code $st $ret
+ }
+ } else {
+ return $ret
+ }
+ EOL
+=begin
+ INTERP.add_tk_procs('rb_out', 'args', <<-'EOL')
+ #regsub -all {\\} $args {\\\\} args
+ #regsub -all {!} $args {\\!} args
+ #regsub -all "{" $args "\\{" args
+ regsub -all {(\\|!|\{|\})} $args {\\\1} args
+ if {[set st [catch {ruby [format "TkCore.callback %%Q!%s!" $args]} ret]] != 0} {
+ #return -code $st $ret
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ return -code $st \
+ -errorinfo [string range $ret [expr $idx + 2] \
+ [string length $ret]] \
+ [string range $ret 0 [expr $idx - 1]]
+ } else {
+ return -code $st $ret
+ }
+ } else {
+ return $ret
+ }
+ EOL
+=end
- INTERP._invoke("proc", "rb_out", "args", "if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $args]} ret]] != 0} {if {[regsub -all {!} $args {\\!} newargs] == 0} {return -code $st $ret} {if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $newargs]} ret]] != 0} {return -code $st $ret} {return $ret}}} {return $ret}")
+ EventFlag = TclTkLib::EventFlag
def callback_break
fail TkCallbackBreak, "Tk callback returns 'break' status"
@@ -477,91 +1127,125 @@ module TkCore
fail TkCallbackContinue, "Tk callback returns 'continue' status"
end
- def after(ms, cmd=Proc.new)
- myid = _curr_cmd_id
- cmdid = install_cmd(cmd)
- tk_call("after",ms,cmdid)
- return
- if false #defined? Thread
- Thread.start do
- ms = Float(ms)/1000
- ms = 10 if ms == 0
- sleep ms/1000
- cmd.call
+ def TkCore.callback(*arg)
+ begin
+ TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
+ rescue SystemExit
+ exit(0)
+ rescue Interrupt
+ exit!(1)
+ rescue Exception => e
+ begin
+ msg = _toUTF8(e.class.inspect) + ': ' +
+ _toUTF8(e.message) + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ _toUTF8(e.backtrace.join("\n")) +
+ "\n---< backtrace of Tk side >-------"
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ rescue Exception
+ msg = e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------"
end
- else
- cmdid = install_cmd(cmd)
- tk_call("after",ms,cmdid)
+ fail(e, msg)
end
end
+=begin
+ def TkCore.callback(arg_str)
+ # arg = tk_split_list(arg_str)
+ arg = tk_split_simplelist(arg_str)
+ #_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg))
+ #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift],
+ # *arg))
+ # TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
+ begin
+ TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
+ rescue Exception => e
+ raise(e, e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------")
+ end
+#=begin
+# cb_obj = TkCore::INTERP.tk_cmd_tbl[arg.shift]
+# unless $DEBUG
+# cb_obj.call(*arg)
+# else
+# begin
+# raise 'check backtrace'
+# rescue
+# # ignore backtrace before 'callback'
+# pos = -($!.backtrace.size)
+# end
+# begin
+# cb_obj.call(*arg)
+# rescue
+# trace = $!.backtrace
+# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
+# "\tfrom #{trace[1..pos].join("\n\tfrom ")}"
+# end
+# end
+#=end
+ end
+=end
+
+ def load_cmd_on_ip(tk_cmd)
+ bool(tk_call('auto_load', tk_cmd))
+ end
+
+ def after(ms, cmd=Proc.new)
+ crit_bup = Thread.critical
+ Thread.critical = true
- def after_idle(cmd=Proc.new)
myid = _curr_cmd_id
- cmdid = install_cmd(cmd)
- tk_call('after','idle',cmdid)
- end
+ cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret})
- def clock_clicks(ms=nil)
- if ms
- tk_call('clock','clicks','-milliseconds').to_i
- else
- tk_call('clock','clicks').to_i
- end
- end
+ Thread.critical = crit_bup
- def clock_format(clk, form=nil)
- if form
- tk_call('clock','format',clk,'-format',form).to_i
- else
- tk_call('clock','format',clk).to_i
- end
+ tk_call_without_enc("after",ms,cmdid) # return id
+# return
+# if false #defined? Thread
+# Thread.start do
+# ms = Float(ms)/1000
+# ms = 10 if ms == 0
+# sleep ms/1000
+# cmd.call
+# end
+# else
+# cmdid = install_cmd(cmd)
+# tk_call("after",ms,cmdid)
+# end
end
- def clock_formatGMT(clk, form=nil)
- if form
- tk_call('clock','format',clk,'-format',form,'-gmt','1').to_i
- else
- tk_call('clock','format',clk,'-gmt','1').to_i
- end
- end
+ def after_idle(cmd=Proc.new)
+ crit_bup = Thread.critical
+ Thread.critical = true
- def clock_scan(str, base=nil)
- if base
- tk_call('clock','scan',str,'-base',base).to_i
- else
- tk_call('clock','scan',str).to_i
- end
- end
+ myid = _curr_cmd_id
+ cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret})
- def clock_scanGMT(str, base=nil)
- if base
- tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
- else
- tk_call('clock','scan',str,'-gmt','1').to_i
- end
- end
+ Thread.critical = crit_bup
- def clock_seconds
- tk_call('clock','seconds').to_i
+ tk_call_without_enc('after','idle',cmdid)
end
- def TkCore.callback(arg)
- arg = Array(tk_split_list(arg))
- _get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg))
+ def windowingsystem
+ tk_call_without_enc('tk', 'windowingsystem')
end
def scaling(scale=nil)
if scale
- tk_call('tk', 'scaling', scale)
+ tk_call_without_enc('tk', 'scaling', scale)
else
- Float(number(tk_call('tk', 'scaling')))
+ Float(number(tk_call_without_enc('tk', 'scaling')))
end
end
def scaling_displayof(win, scale=nil)
if scale
- tk_call('tk', 'scaling', '-displayof', win, scale)
+ tk_call_without_enc('tk', 'scaling', '-displayof', win, scale)
else
- Float(number(tk_call('tk', '-displayof', win, 'scaling')))
+ Float(number(tk_call_without_enc('tk', '-displayof', win, 'scaling')))
end
end
@@ -569,7 +1253,20 @@ module TkCore
tk_call('tk', 'appname', name)
end
+ def appsend_deny
+ tk_call('rename', 'send', '')
+ end
+
def appsend(interp, async, *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Tk commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
+ end
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
if async
tk_call('send', '-async', '--', interp, *args)
else
@@ -578,13 +1275,34 @@ module TkCore
end
def rb_appsend(interp, async, *args)
- args = args.collect!{|c| _get_eval_string(c).gsub(/[][$"]/, '\\\\\&')}
- args.push(').to_s"')
- appsend(interp, async, 'ruby "(', *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Ruby commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
+ end
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')}
+ args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')}
+ # args.push(').to_s"')
+ # appsend(interp, async, 'ruby "(', *args)
+ args.push('}.call)"')
+ appsend(interp, async, 'ruby "TkComm._get_eval_string(proc{', *args)
end
def appsend_displayof(interp, win, async, *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Tk commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
+ end
win = '.' if win == nil
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
if async
tk_call('send', '-async', '-displayof', win, '--', interp, *args)
else
@@ -593,169 +1311,456 @@ module TkCore
end
def rb_appsend_displayof(interp, win, async, *args)
- args = args.collect!{|c| _get_eval_string(c).gsub(/[][$"]/, '\\\\\&')}
- args.push(').to_s"')
- appsend_displayof(interp, win, async, 'ruby "(', *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Ruby commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
+ end
+ win = '.' if win == nil
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')}
+ args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')}
+ # args.push(').to_s"')
+ # appsend_displayof(interp, win, async, 'ruby "(', *args)
+ args.push('}.call)"')
+ appsend(interp, win, async, 'ruby "TkComm._get_eval_string(proc{', *args)
end
def info(*args)
tk_call('info', *args)
end
- def mainloop
- TclTkLib.mainloop
+ def mainloop(check_root = true)
+ TclTkLib.mainloop(check_root)
+ end
+
+ def mainloop_watchdog(check_root = true)
+ # watchdog restarts mainloop when mainloop is dead
+ TclTkLib.mainloop_watchdog(check_root)
+ end
+
+ def do_one_event(flag = TclTkLib::EventFlag::ALL)
+ TclTkLib.do_one_event(flag)
+ end
+
+ def set_eventloop_tick(timer_tick)
+ TclTkLib.set_eventloop_tick(timer_tick)
+ end
+
+ def get_eventloop_tick()
+ TclTkLib.get_eventloop_tick
+ end
+
+ def set_no_event_wait(wait)
+ TclTkLib.set_no_even_wait(wait)
+ end
+
+ def get_no_event_wait()
+ TclTkLib.get_no_eventloop_wait
+ end
+
+ def set_eventloop_weight(loop_max, no_event_tick)
+ TclTkLib.set_eventloop_weight(loop_max, no_event_tick)
+ end
+
+ def get_eventloop_weight()
+ TclTkLib.get_eventloop_weight
+ end
+
+ def restart(app_name = nil, keys = {})
+ TkCore::INTERP.init_ip_internal
+
+ tk_call('set', 'argv0', app_name) if app_name
+ if keys.kind_of?(Hash)
+ # tk_call('set', 'argc', keys.size * 2)
+ tk_call('set', 'argv', hash_kv(keys).join(' '))
+ end
+
+ INTERP.restart
+ nil
end
def event_generate(window, context, keys=nil)
- window = window.path if window.kind_of? TkObject
+ #window = window.path if window.kind_of?(TkObject)
if keys
- tk_call('event', 'generate', window,
- "<#{tk_event_sequence(context)}>", *hash_kv(keys))
+ tk_call_without_enc('event', 'generate', window,
+ "<#{tk_event_sequence(context)}>",
+ *hash_kv(keys, true))
else
- tk_call('event', 'generate', window, "<#{tk_event_sequence(context)}>")
+ tk_call_without_enc('event', 'generate', window,
+ "<#{tk_event_sequence(context)}>")
end
+ nil
end
def messageBox(keys)
- tk_call 'tk_messageBox', *hash_kv(keys)
+ tk_call('tk_messageBox', *hash_kv(keys))
end
def getOpenFile(keys = nil)
- tk_call 'tk_getOpenFile', *hash_kv(keys)
+ tk_call('tk_getOpenFile', *hash_kv(keys))
end
def getSaveFile(keys = nil)
- tk_call 'tk_getSaveFile', *hash_kv(keys)
+ tk_call('tk_getSaveFile', *hash_kv(keys))
end
def chooseColor(keys = nil)
- tk_call 'tk_chooseColor', *hash_kv(keys)
+ tk_call('tk_chooseColor', *hash_kv(keys))
end
def chooseDirectory(keys = nil)
- tk_call 'tk_chooseDirectory', *hash_kv(keys)
+ tk_call('tk_chooseDirectory', *hash_kv(keys))
end
- def tk_call(*args)
- print args.join(" "), "\n" if $DEBUG
- args.collect! {|x|ruby2tcl(x)}
- args.compact!
- args.flatten!
- begin
- res = INTERP._invoke(*args)
- rescue NameError
- err = $!
- begin
- args.unshift "unknown"
- res = INTERP._invoke(*args)
- rescue
- fail unless /^invalid command/ =~ $!
- fail err
- end
+ def _ip_eval_core(enc_mode, cmd_string)
+ case enc_mode
+ when nil
+ res = INTERP._eval(cmd_string)
+ when false
+ res = INTERP._eval_without_enc(cmd_string)
+ when true
+ res = INTERP._eval_with_enc(cmd_string)
end
if INTERP._return_value() != 0
fail RuntimeError, res, error_at
end
- print "==> ", res, "\n" if $DEBUG
return res
end
-end
+ private :_ip_eval_core
-module TkPackage
- include TkCore
- extend TkPackage
+ def ip_eval(cmd_string)
+ _ip_eval_core(nil, cmd_string)
+ end
- def forget(package)
- tk_call('package', 'forget', package)
- nil
+ def ip_eval_without_enc(cmd_string)
+ _ip_eval_core(false, cmd_string)
end
- def names
- tk_split_simplelist(tk_call('package', 'names'))
+ def ip_eval_with_enc(cmd_string)
+ _ip_eval_core(true, cmd_string)
end
- def provide(package, version=nil)
- if version
- tk_call('package', 'provide', package, version)
- nil
- else
- tk_call('package', 'provide', package)
+ def _ip_invoke_core(enc_mode, *args)
+ case enc_mode
+ when false
+ res = INTERP._invoke_without_enc(*args)
+ when nil
+ res = INTERP._invoke(*args)
+ when true
+ res = INTERP._invoke_with_enc(*args)
+ end
+ if INTERP._return_value() != 0
+ fail RuntimeError, res, error_at
end
+ return res
end
+ private :_ip_invoke_core
- def present(package, version=None)
- tk_call('package', 'present', package, version)
+ def ip_invoke(*args)
+ _ip_invoke_core(nil, *args)
end
- def present_exact(package, version)
- tk_call('package', 'present', '-exact', package, version)
+ def ip_invoke_without_enc(*args)
+ _ip_invoke_core(false, *args)
end
- def require(package, version=None)
- tk_call('package', 'require', package, version)
+ def ip_invoke_with_enc(*args)
+ _ip_invoke_core(true, *args)
end
- def require_exact(package, version)
- tk_call('package', 'require', '-exact', package, version)
+ def _tk_call_core(enc_mode, *args)
+ ### puts args.inspect if $DEBUG
+ #args.collect! {|x|ruby2tcl(x, enc_mode)}
+ #args.compact!
+ #args.flatten!
+ args = _conv_args([], enc_mode, *args)
+ puts 'invoke args => ' + args.inspect if $DEBUG
+ ### print "=> ", args.join(" ").inspect, "\n" if $DEBUG
+ begin
+ # res = INTERP._invoke(*args).taint
+ # res = INTERP._invoke(enc_mode, *args)
+ res = _ip_invoke_core(enc_mode, *args)
+ # >>>>> _invoke returns a TAINTED string <<<<<
+ rescue NameError => err
+ # err = $!
+ begin
+ args.unshift "unknown"
+ #res = INTERP._invoke(*args).taint
+ #res = INTERP._invoke(enc_mode, *args)
+ res = _ip_invoke_core(enc_mode, *args)
+ # >>>>> _invoke returns a TAINTED string <<<<<
+ rescue StandardError => err2
+ fail err2 unless /^invalid command/ =~ err2.message
+ fail err
+ end
+ end
+ if INTERP._return_value() != 0
+ fail RuntimeError, res, error_at
+ end
+ ### print "==> ", res.inspect, "\n" if $DEBUG
+ return res
end
+ private :_tk_call_core
- def versions(package)
- tk_split_simplelist(tk_call('package', 'versions', package))
+ def tk_call(*args)
+ _tk_call_core(nil, *args)
end
- def vcompare(version1, version2)
- Integer(tk_call('package', 'vcompare', version1, version2))
+ def tk_call_without_enc(*args)
+ _tk_call_core(false, *args)
end
- def vsatisfies(version1, version2)
- bool(tk_call('package', 'vsatisfies', version1, version2))
+ def tk_call_with_enc(*args)
+ _tk_call_core(true, *args)
end
end
+
module Tk
include TkCore
extend Tk
- TCL_VERSION = INTERP._invoke("info", "tclversion")
- TK_VERSION = INTERP._invoke("set", "tk_version")
+ TCL_VERSION = INTERP._invoke_without_enc("info", "tclversion").freeze
+ TCL_PATCHLEVEL = INTERP._invoke_without_enc("info", "patchlevel").freeze
+
+ major, minor = TCL_VERSION.split('.')
+ TCL_MAJOR_VERSION = major.to_i
+ TCL_MINOR_VERSION = minor.to_i
+
+ TK_VERSION = INTERP._invoke_without_enc("set", "tk_version").freeze
+ TK_PATCHLEVEL = INTERP._invoke_without_enc("set", "tk_patchLevel").freeze
+
+ major, minor = TK_VERSION.split('.')
+ TK_MAJOR_VERSION = major.to_i
+ TK_MINOR_VERSION = minor.to_i
+
+ JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands",
+ "kanji") != "").freeze
+
+ def Tk.const_missing(sym)
+ case(sym)
+ when :TCL_LIBRARY
+ INTERP._invoke_without_enc('global', 'tcl_library')
+ INTERP._invoke("set", "tcl_library").freeze
+
+ when :TK_LIBRARY
+ INTERP._invoke_without_enc('global', 'tk_library')
+ INTERP._invoke("set", "tk_library").freeze
+
+ when :LIBRARY
+ INTERP._invoke("info", "library").freeze
+
+ #when :PKG_PATH, :PACKAGE_PATH, :TCL_PACKAGE_PATH
+ # INTERP._invoke_without_enc('global', 'tcl_pkgPath')
+ # tk_split_simplelist(INTERP._invoke('set', 'tcl_pkgPath'))
- TCL_PATCHLEVEL = INTERP._invoke("info", "patchlevel")
- TK_PATCHLEVEL = INTERP._invoke("set", "tk_patchLevel")
+ #when :LIB_PATH, :LIBRARY_PATH, :TCL_LIBRARY_PATH
+ # INTERP._invoke_without_enc('global', 'tcl_libPath')
+ # tk_split_simplelist(INTERP._invoke('set', 'tcl_libPath'))
- TCL_LIBRARY = INTERP._invoke("set", "tcl_library")
- TK_LIBRARY = INTERP._invoke("set", "tk_library")
- LIBRARY = INTERP._invoke("info", "library")
+ when :PLATFORM, :TCL_PLATFORM
+ if $SAFE >= 4
+ fail SecurityError, "can't get #{sym} when $SAFE >= 4"
+ end
+ INTERP._invoke_without_enc('global', 'tcl_platform')
+ Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get',
+ 'tcl_platform'))]
+
+ when :ENV
+ INTERP._invoke_without_enc('global', 'env')
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'env'))]
+
+ #when :AUTO_PATH #<===
+ # tk_split_simplelist(INTERP._invoke('set', 'auto_path'))
+
+ #when :AUTO_OLDPATH
+ # tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath'))
+
+ when :AUTO_INDEX
+ INTERP._invoke_without_enc('global', 'auto_index')
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'auto_index'))]
+
+ when :PRIV, :PRIVATE, :TK_PRIV
+ priv = {}
+ if INTERP._invoke_without_enc('info', 'vars', 'tk::Priv') != ""
+ var_nam = 'tk::Priv'
+ else
+ var_nam = 'tkPriv'
+ end
+ INTERP._invoke_without_enc('global', var_nam)
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get',
+ var_nam))].each{|k,v|
+ k.freeze
+ case v
+ when /^-?\d+$/
+ priv[k] = v.to_i
+ when /^-?\d+\.?\d*(e[-+]?\d+)?$/
+ priv[k] = v.to_f
+ else
+ priv[k] = v.freeze
+ end
+ }
+ priv
- TCL_PACKAGE_PATH = INTERP._invoke("set", "tcl_pkgPath")
- AUTO_PATH = tk_split_simplelist(INTERP._invoke("set", "auto_path"))
+ else
+ raise NameError, 'uninitialized constant Tk::' + sym.id2name
+ end
+ end
- PLATFORM = Hash[*tk_split_simplelist(INTERP._eval('array get tcl_platform'))]
+ def Tk.errorInfo
+ INTERP._invoke_without_enc('global', 'errorInfo')
+ INTERP._invoke_without_enc('set', 'errorInfo')
+ end
- JAPANIZED_TK = (INTERP._invoke("info", "commands", "kanji") != "")
+ def Tk.errorCode
+ INTERP._invoke_without_enc('global', 'errorCode')
+ code = tk_split_simplelist(INTERP._invoke_without_enc('set', 'errorCode'))
+ case code[0]
+ when 'CHILDKILLED', 'CHILDSTATUS', 'CHILDSUSP'
+ begin
+ pid = Integer(code[1])
+ code[1] = pid
+ rescue
+ end
+ end
+ code
+ end
def root
TkRoot.new
end
- def bell
- tk_call 'bell'
+ def Tk.load_tclscript(file, enc=nil)
+ if enc
+ # TCL_VERSION >= 8.5
+ tk_call('source', '-encoding', enc, file)
+ else
+ tk_call('source', file)
+ end
+ end
+
+ def Tk.load_tcllibrary(file, pkg_name=None, interp=None)
+ tk_call('load', file, pkg_name, interp)
+ end
+
+ def Tk.unload_tcllibrary(*args)
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ nocomp = (keys['nocomplain'])? '-nocomplain': None
+ keeplib = (keys['keeplibrary'])? '-keeplibrary': None
+ tk_call('unload', nocomp, keeplib, '--', *args)
+ else
+ tk_call('unload', *args)
+ end
+ end
+
+ def Tk.bell(nice = false)
+ if nice
+ tk_call_without_enc('bell', '-nice')
+ else
+ tk_call_without_enc('bell')
+ end
+ nil
+ end
+
+ def Tk.bell_on_display(win, nice = false)
+ if nice
+ tk_call_without_enc('bell', '-displayof', win, '-nice')
+ else
+ tk_call_without_enc('bell', '-displayof', win)
+ end
+ nil
+ end
+
+ def Tk.destroy(*wins)
+ tk_call_without_enc('destroy', *wins)
+ end
+
+ def Tk.exit
+ tk_call_without_enc('destroy', '.')
+ end
+
+ def Tk.pack(*args)
+ #TkPack.configure(*args)
+ TkPack(*args)
+ end
+
+ def Tk.grid(*args)
+ TkGrid.configure(*args)
+ end
+
+ def Tk.update(idle=nil)
+ if idle
+ tk_call_without_enc('update', 'idletasks')
+ else
+ tk_call_without_enc('update')
+ end
+ end
+ def Tk.update_idletasks
+ update(true)
+ end
+ def update(idle=nil)
+ # only for backward compatibility (This never be recommended to use)
+ Tk.update(idle)
+ self
+ end
+
+=begin
+ # See tcltklib.c for the reason of why the following methods are disabled.
+ def Tk.thread_update(idle=nil)
+ if idle
+ tk_call_without_enc('thread_update', 'idletasks')
+ else
+ tk_call_without_enc('thread_update')
+ end
+ end
+ def Tk.thread_update_idletasks
+ thread_update(true)
+ end
+=end
+
+ def Tk.current_grabs(win = nil)
+ if win
+ window(tk_call_without_enc('grab', 'current', win))
+ else
+ tk_split_list(tk_call_without_enc('grab', 'current'))
+ end
end
def Tk.focus(display=nil)
if display == nil
- r = tk_call('focus')
+ window(tk_call_without_enc('focus'))
else
- r = tk_call('focus', '-displayof', display)
+ window(tk_call_without_enc('focus', '-displayof', display))
+ end
+ end
+
+ def Tk.focus_to(win, force=false)
+ if force
+ tk_call_without_enc('focus', '-force', win)
+ else
+ tk_call_without_enc('focus', win)
end
- tk_tcl2ruby(r)
end
def Tk.focus_lastfor(win)
- tk_tcl2ruby(tk_call('focus', '-lastfor', win))
+ window(tk_call_without_enc('focus', '-lastfor', win))
+ end
+
+ def Tk.focus_next(win)
+ TkManageFocus.next(win)
+ end
+
+ def Tk.focus_prev(win)
+ TkManageFocus.prev(win)
end
def Tk.strictMotif(bool=None)
- bool(tk_call('set', 'tk_strictMotif', bool))
+ bool(tk_call_without_enc('set', 'tk_strictMotif', bool))
end
def Tk.show_kinsoku(mode='both')
@@ -788,207 +1793,210 @@ module Tk
end
end
- def Tk.toUTF8(str,encoding)
- INTERP._toUTF8(str,encoding)
+ def Tk.toUTF8(str, encoding = nil)
+ _toUTF8(str, encoding)
end
- def Tk.fromUTF8(str,encoding)
- INTERP._fromUTF8(str,encoding)
+ def Tk.fromUTF8(str, encoding = nil)
+ _fromUTF8(str, encoding)
end
+end
- module Scrollable
- def xscrollcommand(cmd=Proc.new)
- configure_cmd 'xscrollcommand', cmd
- end
- def yscrollcommand(cmd=Proc.new)
- configure_cmd 'yscrollcommand', cmd
- end
- def xview(*index)
- v = tk_send('xview', *index)
- list(v) if index.size == 0
- end
- def yview(*index)
- v = tk_send('yview', *index)
- list(v) if index.size == 0
- end
- def xscrollbar(bar=nil)
- if bar
- @xscrollbar = bar
- @xscrollbar.orient 'horizontal'
- self.xscrollcommand {|arg| @xscrollbar.set *arg}
- @xscrollbar.command {|arg| self.xview *arg}
- end
- @xscrollbar
- end
- def yscrollbar(bar=nil)
- if bar
- @yscrollbar = bar
- @yscrollbar.orient 'vertical'
- self.yscrollcommand {|arg| @yscrollbar.set *arg}
- @yscrollbar.command {|arg| self.yview *arg}
- end
- @yscrollbar
- end
+###########################################
+# string with Tcl's encoding
+###########################################
+module Tk
+ def Tk.subst_utf_backslash(str)
+ Tk::EncodedString.subst_utf_backslash(str)
+ end
+ def Tk.subst_tk_backslash(str)
+ Tk::EncodedString.subst_tk_backslash(str)
end
+ def Tk.utf_to_backslash_sequence(str)
+ Tk::EncodedString.utf_to_backslash_sequence(str)
+ end
+ def Tk.utf_to_backslash(str)
+ Tk::EncodedString.utf_to_backslash_sequence(str)
+ end
+ def Tk.to_backslash_sequence(str)
+ Tk::EncodedString.to_backslash_sequence(str)
+ end
+end
- module Wm
- include TkComm
- def aspect(*args)
- w = tk_call('wm', 'aspect', path, *args)
- list(w) if args.length == 0
- end
- def client(name=None)
- tk_call 'wm', 'client', path, name
- end
- def colormapwindows(*args)
- list(tk_call('wm', 'colormapwindows', path, *args))
- end
- def wm_command(value=None)
- string(tk_call('wm', 'command', path, value))
- end
- def deiconify
- tk_call 'wm', 'deiconify', path
- end
- def focusmodel(*args)
- tk_call 'wm', 'focusmodel', path, *args
- end
- def frame
- tk_call('wm', 'frame', path)
- end
- def geometry(*args)
- tk_call('wm', 'geometry', path, *args)
- end
- def grid(*args)
- w = tk_call('wm', 'grid', path, *args)
- list(w) if args.size == 0
- end
- def group(*args)
- w = tk_call 'wm', 'group', path, *args
- window(w) if args.size == 0
- end
- def iconbitmap(*args)
- tk_call 'wm', 'iconbitmap', path, *args
- end
- def iconify
- tk_call 'wm', 'iconify', path
- end
- def iconmask(*args)
- tk_call 'wm', 'iconmask', path, *args
- end
- def iconname(*args)
- tk_call 'wm', 'iconname', path, *args
- end
- def iconposition(*args)
- w = tk_call('wm', 'iconposition', path, *args)
- list(w) if args.size == 0
- end
- def iconwindow(*args)
- w = tk_call('wm', 'iconwindow', path, *args)
- window(w) if args.size == 0
- end
- def maxsize(*args)
- w = tk_call('wm', 'maxsize', path, *args)
- list(w) if args.size == 0
- end
- def minsize(*args)
- w = tk_call('wm', 'minsize', path, *args)
- list(w) if args.size == 0
- end
- def overrideredirect(bool=None)
- if bool == None
- bool(tk_call('wm', 'overrideredirect', path))
+
+###########################################
+# convert kanji string to/from utf-8
+###########################################
+if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
+ class TclTkIp
+ # from tkencoding.rb by ttate@jaist.ac.jp
+ attr_accessor :encoding
+
+ alias __eval _eval
+ alias __invoke _invoke
+
+ alias __toUTF8 _toUTF8
+ alias __fromUTF8 _fromUTF8
+
+=begin
+ #### --> definition is moved to TclTkIp module
+
+ def _toUTF8(str, encoding = nil)
+ # decide encoding
+ if encoding
+ encoding = encoding.to_s
+ elsif str.kind_of?(Tk::EncodedString) && str.encoding != nil
+ encoding = str.encoding.to_s
+ elsif str.instance_variable_get(:@encoding)
+ encoding = str.instance_variable_get(:@encoding).to_s
+ elsif defined?(@encoding) && @encoding != nil
+ encoding = @encoding.to_s
else
- tk_call 'wm', 'overrideredirect', path, bool
+ encoding = __invoke('encoding', 'system')
end
- end
- def positionfrom(*args)
- tk_call 'wm', 'positionfrom', path, *args
- end
- def protocol(name=nil, cmd=nil)
- if cmd
- tk_call('wm', 'protocol', path, name, cmd)
- elsif name
- result = tk_call('wm', 'protocol', path, name)
- (result == "")? nil : tk_tcl2ruby(result)
+
+ # convert
+ case encoding
+ when 'utf-8', 'binary'
+ str
else
- tk_split_simplelist(tk_call('wm', 'protocol', path))
+ __toUTF8(str, encoding)
end
end
- def resizable(*args)
- w = tk_call('wm', 'resizable', path, *args)
- if args.length == 0
- list(w).collect{|e| bool(e)}
+
+ def _fromUTF8(str, encoding = nil)
+ unless encoding
+ if defined?(@encoding) && @encoding != nil
+ encoding = @encoding.to_s
+ else
+ encoding = __invoke('encoding', 'system')
+ end
+ end
+
+ if str.kind_of?(Tk::EncodedString)
+ if str.encoding == 'binary'
+ str
+ else
+ __fromUTF8(str, encoding)
+ end
+ elsif str.instance_variable_get(:@encoding).to_s == 'binary'
+ str
+ else
+ __fromUTF8(str, encoding)
end
end
- def sizefrom(*args)
- tk_call('wm', 'sizefrom', path, *args)
- end
- def state
- tk_call 'wm', 'state', path
- end
- def title(*args)
- tk_call 'wm', 'title', path, *args
- end
- def transient(*args)
- window(tk_call 'wm', 'transient', path, *args)
+=end
+
+ def _eval(cmd)
+ _fromUTF8(__eval(_toUTF8(cmd)))
end
- def withdraw
- tk_call 'wm', 'withdraw', path
+
+ def _invoke(*cmds)
+ _fromUTF8(__invoke(*(cmds.collect{|cmd| _toUTF8(cmd)})))
end
- end
-end
-###########################################
-# convert kanji string to/from utf-8
-###########################################
-if /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
- class TclTkIp
- # from tkencoding.rb by ttate@jaist.ac.jp
- alias __eval _eval
- alias __invoke _invoke
- private :__eval
- private :__invoke
-
- attr_accessor :encoding
-
+ alias _eval_with_enc _eval
+ alias _invoke_with_enc _invoke
+
+=begin
def _eval(cmd)
- if @encoding
- _fromUTF8(__eval(_toUTF8(cmd, @encoding)), @encoding)
+ if defined?(@encoding) && @encoding != 'utf-8'
+ ret = if cmd.kind_of?(Tk::EncodedString)
+ case cmd.encoding
+ when 'utf-8', 'binary'
+ __eval(cmd)
+ else
+ __eval(_toUTF8(cmd, cmd.encoding))
+ end
+ elsif cmd.instance_variable_get(:@encoding) == 'binary'
+ __eval(cmd)
+ else
+ __eval(_toUTF8(cmd, @encoding))
+ end
+ if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
+ ret
+ else
+ _fromUTF8(ret, @encoding)
+ end
else
- __eval(cmd)
+ __eval(cmd)
end
end
-
+
def _invoke(*cmds)
- if @encoding
- cmds = cmds.collect{|cmd| _toUTF8(cmd, @encoding)}
- _fromUTF8(__invoke(*cmds), @encoding)
+ if defined?(@encoding) && @encoding != 'utf-8'
+ cmds = cmds.collect{|cmd|
+ if cmd.kind_of?(Tk::EncodedString)
+ case cmd.encoding
+ when 'utf-8', 'binary'
+ cmd
+ else
+ _toUTF8(cmd, cmd.encoding)
+ end
+ elsif cmd.instance_variable_get(:@encoding) == 'binary'
+ cmd
+ else
+ _toUTF8(cmd, @encoding)
+ end
+ }
+ ret = __invoke(*cmds)
+ if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
+ ret
+ else
+ _fromUTF8(ret, @encoding)
+ end
else
- __invoke(*cmds)
- end
+ __invoke(*cmds)
+ end
end
+=end
end
module Tk
- def encoding=(name)
- INTERP.encoding = name
- end
+ module Encoding
+ extend Encoding
- def encoding
- INTERP.encoding
- end
+ TkCommandNames = ['encoding'.freeze].freeze
- def encoding_names
- tk_split_simplelist(tk_call('encoding', 'names'))
- end
+ def encoding=(name)
+ TkCore::INTERP.encoding = name
+ end
- def encoding_system
- tk_call('encoding', 'system')
- end
+ def encoding
+ TkCore::INTERP.encoding
+ end
+
+ def encoding_names
+ tk_split_simplelist(tk_call('encoding', 'names'))
+ end
- def encoding_system=(enc)
- tk_call('encoding', 'system', enc)
+ def encoding_system
+ tk_call('encoding', 'system')
+ end
+
+ def encoding_system=(enc)
+ tk_call('encoding', 'system', enc)
+ end
+
+ def encoding_convertfrom(str, enc=nil)
+ # str must be a Tcl's internal string expression in enc.
+ # the return value is a UTF-8 string.
+ enc = encoding_system unless enc
+ TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str)
+ end
+ alias encoding_convert_from encoding_convertfrom
+
+ def encoding_convertto(str, enc=nil)
+ # str must be a UTF-8 string.
+ # The return value is a Tcl's internal string expression in enc.
+ # To get an usual enc string, use Tk.fromUTF8(ret_val, enc).
+ enc = encoding_system unless enc
+ TkCore::INTERP.__invoke('encoding', 'convertto', enc, str)
+ end
+ alias encoding_convert_to encoding_convertto
end
+
+ extend Encoding
end
# estimate encoding
@@ -1009,1177 +2017,1145 @@ if /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
else
# dummy methods
+ class TclTkIp
+ alias __eval _eval
+ alias __invoke _invoke
+
+ alias _eval_with_enc _eval
+ alias _invoke_with_enc _invoke
+ end
+
module Tk
- def encoding=(name)
- nil
- end
- def encoding
- nil
- end
- def encoding_names
- nil
- end
- def encoding_system
- nil
- end
- def encoding_system=(enc)
- nil
+ module Encoding
+ extend Encoding
+
+ def encoding=(name)
+ nil
+ end
+ def encoding
+ nil
+ end
+ def encoding_names
+ nil
+ end
+ def encoding_system
+ nil
+ end
+ def encoding_system=(enc)
+ nil
+ end
+
+ def encoding_convertfrom(str, enc=None)
+ str
+ end
+ alias encoding_convert_from encoding_convertfrom
+
+ def encoding_convertto(str, enc=None)
+ str
+ end
+ alias encoding_convert_to encoding_convertto
end
end
end
+
module TkBindCore
def bind(context, cmd=Proc.new, args=nil)
- Tk.bind(to_eval, context, cmd, args)
+ Tk.bind(self, context, cmd, args)
end
def bind_append(context, cmd=Proc.new, args=nil)
- Tk.bind_append(to_eval, context, cmd, args)
+ Tk.bind_append(self, context, cmd, args)
end
def bind_remove(context)
- Tk.bind_remove(to_eval, context)
+ Tk.bind_remove(self, context)
end
def bindinfo(context=nil)
- Tk.bindinfo(to_eval, context)
+ Tk.bindinfo(self, context)
end
end
-class TkBindTag
- include TkBindCore
- BTagID_TBL = {}
- Tk_BINDTAG_ID = ["btag00000"]
+module TkTreatFont
+ def __font_optkeys
+ ['font']
+ end
+ private :__font_optkeys
- def TkBindTag.id2obj(id)
- BTagID_TBL[id]? BTagID_TBL[id]: id
+ def __pathname
+ self.path
end
+ private :__pathname
- ALL = self.new
- ALL.instance_eval {
- @id = 'all'
- BTagID_TBL[@id] = self
- }
+ ################################
- def initialize(*args)
- @id = Tk_BINDTAG_ID[0]
- Tk_BINDTAG_ID[0] = Tk_BINDTAG_ID[0].succ
- BTagID_TBL[@id] = self
- bind(*args) if args != []
- end
+ def font_configinfo(key = nil)
+ optkeys = __font_optkeys
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
- def to_eval
- @id
- end
+ win, tag = __pathname.split(':')
- def inspect
- format "#<TkBindTag: %s>", @id
+ if key
+ pathname = [win, tag, key].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *__confinfo_cmd)
+ elsif optkeys.size == 1
+ pathname = [win, tag, optkeys[0]].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *__confinfo_cmd)
+ else
+ fonts = {}
+ optkeys.each{|key|
+ key = key.to_s
+ pathname = [win, tag, key].join(';')
+ fonts[key] =
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *__confinfo_cmd)
+ }
+ fonts
+ end
end
-end
+ alias fontobj font_configinfo
-class TkBindTagAll<TkBindTag
- def TkBindTagAll.new(*args)
- $stderr.puts "Warning: TkBindTagALL is obsolete. Use TkBindTag::ALL\n"
+ def font_configure(slot)
+ pathname = __pathname
- TkBindTag::ALL.bind(*args) if args != []
- TkBindTag::ALL
- end
-end
+ slot = _symbolkey2str(slot)
-class TkVariable
- include Tk
- extend TkCore
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ l_optkey = 'latin' << optkey
+ a_optkey = 'ascii' << optkey
+ k_optkey = 'kanji' << optkey
- TkVar_CB_TBL = {}
- Tk_VARIABLE_ID = ["v00000"]
+ if slot.key?(optkey)
+ fnt = slot.delete(optkey)
+ if fnt.kind_of?(TkFont)
+ slot.delete(l_optkey)
+ slot.delete(a_optkey)
+ slot.delete(k_optkey)
- INTERP._invoke("proc", "rb_var", "args", "ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
+ fnt.call_font_configure([pathname, optkey], *(__config_cmd << {}))
+ next
+ else
+ if fnt
+ if (slot.key?(l_optkey) ||
+ slot.key?(a_optkey) ||
+ slot.key?(k_optkey))
+ fnt = TkFont.new(fnt)
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ fnt.latin_replace(lfnt) if lfnt
+ fnt.kanji_replace(kfnt) if kfnt
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__config_cmd << {}))
+ next
+ else
+ fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ end
+ end
+ next
+ end
+ end
- def TkVariable.callback(args)
- name1,name2,op = tk_split_list(args)
- if TkVar_CB_TBL[name1]
- _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
- else
- ''
- end
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ if lfnt && kfnt
+ TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
+ *(__config_cmd << {}))
+ elsif lfnt
+ latinfont_configure([lfnt, optkey])
+ elsif kfnt
+ kanjifont_configure([kfnt, optkey])
+ end
+ }
+
+ # configure other (without font) options
+ tk_call(*(__config_cmd.concat(hash_kv(slot)))) if slot != {}
+ self
end
- def initialize(val="")
- @id = Tk_VARIABLE_ID[0]
- Tk_VARIABLE_ID[0] = Tk_VARIABLE_ID[0].succ
- if val == []
- INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)',
- @id, @id, @id))
- elsif val.kind_of?(Array)
- a = []
- val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
- s = '"' + a.join(" ").gsub(/[][$"]/, '\\\\\&') + '"'
- INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
- elsif val.kind_of?(Hash)
- s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
- .gsub(/[][$"]/, '\\\\\&') + '"'
- INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
+ def latinfont_configure(ltn, keys=nil)
+ if ltn.kind_of?(Array)
+ key = ltn[1]
+ ltn = ltn[0]
else
- s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"'
- INTERP._eval(format('global %s; set %s %s', @id, @id, s))
+ key = nil
end
- end
- def wait
- INTERP._eval("tkwait variable #{@id}")
- end
+ optkeys = __font_optkeys
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
- def id
- @id
- end
+ win, tag = __pathname.split(':')
- def value
- begin
- INTERP._eval(format('global %s; set %s', @id, @id))
- rescue
- if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1"
- fail
+ optkeys = [key] if key
+
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
+
+ pathname = [win, tag, optkey].join(';')
+
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
else
- Hash[*tk_split_simplelist(INTERP._eval(format('global %s; array get %s',
- @id, @id)))]
+ ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
+ tk_call(*(__config_cmd << "-#{optkey}" << ltn))
+ next
end
- end
- end
- def value=(val)
- begin
- s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"'
- INTERP._eval(format('global %s; set %s %s', @id, @id, s))
- rescue
- if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1"
- fail
- else
- if val == []
- INTERP._eval(format('global %s; unset %s; set %s(0) 0; unset %s(0)',
- @id, @id, @id, @id))
- elsif val.kind_of?(Array)
- a = []
- val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
- s = '"' + a.join(" ").gsub(/[][$"]/, '\\\\\&') + '"'
- INTERP._eval(format('global %s; unset %s; array set %s %s',
- @id, @id, @id, s))
- elsif val.kind_of?(Hash)
- s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
- .gsub(/[][$"]/, '\\\\\&') + '"'
- INTERP._eval(format('global %s; unset %s; array set %s %s',
- @id, @id, @id, s))
- else
- fail
- end
+ if fobj.kind_of?(TkFont)
+ if ltn.kind_of?(TkFont)
+ conf = {}
+ ltn.latin_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.latin_configure(conf.update(keys))
+ else
+ fobj.latin_configure(conf)
+ end
+ else
+ fobj.latin_replace(ltn)
+ end
end
- end
- end
- def [](index)
- INTERP._eval(format('global %s; set %s(%s)',
- @id, @id, _get_eval_string(index)))
+ fobj.call_font_configure([pathname, optkey], *(__config_cmd << {}))
+ }
+ self
end
+ alias asciifont_configure latinfont_configure
- def []=(index,val)
- INTERP._eval(format('global %s; set %s(%s) %s', @id, @id,
- _get_eval_string(index), _get_eval_string(val)))
- end
+ def kanjifont_configure(knj, keys=nil)
+ if knj.kind_of?(Array)
+ key = knj[1]
+ knj = knj[0]
+ else
+ key = nil
+ end
- def to_i
- Integer(number(value))
- end
+ optkeys = __font_optkeys
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
- def to_f
- Float(number(value))
- end
+ win, tag = __pathname.split(':')
- def to_s
- String(string(value))
- end
+ optkeys = [key] if key
- def inspect
- format "#<TkVariable: %s>", @id
- end
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
- def ==(other)
- case other
- when TkVariable
- self.equal(self)
- when String
- self.to_s == other
- when Integer
- self.to_i == other
- when Float
- self.to_f == other
- when Array
- self.to_a == other
- else
- false
- end
- end
+ pathname = [win, tag, optkey].join(';')
- def to_a
- list(value)
- end
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
+ else
+ knj = hash_kv(knj) if knj.kind_of?(Hash)
+ tk_call(*(__config_cmd << "-#{optkey}" << knj))
+ next
+ end
- def to_eval
- @id
- end
+ if fobj.kind_of?(TkFont)
+ if knj.kind_of?(TkFont)
+ conf = {}
+ knj.kanji_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.kanji_configure(conf.update(keys))
+ else
+ fobj.kanji_configure(conf)
+ end
+ else
+ fobj.kanji_replace(knj)
+ end
+ end
- def unset(elem=nil)
- if elem
- INTERP._eval(format('global %s; unset %s(%s)',
- @id, @id, tk_tcl2ruby(elem)))
- else
- INTERP._eval(format('global %s; unset %s', @id, @id))
- end
+ fobj.call_font_configure([pathname, optkey], *(__config_cmd << {}))
+ }
+ self
end
- alias remove unset
- def trace_callback(elem, op)
- if @trace_var.kind_of? Array
- @trace_var.each{|m,e| e.call(self,elem,op) if m.index(op)}
- end
- if elem.kind_of? String
- if @trace_elem[elem].kind_of? Array
- @trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)}
+ def font_copy(window, wintag=nil, winkey=nil, targetkey=nil)
+ if wintag
+ if winkey
+ fnt = window.tagfontobj(wintag, winkey).dup
+ else
+ fnt = window.tagfontobj(wintag).dup
end
- end
- end
-
- def trace(opts, cmd)
- @trace_var = [] if @trace_var == nil
- opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
- @trace_var.unshift([opts,cmd])
- if @trace_opts == nil
- TkVar_CB_TBL[@id] = self
- @trace_opts = opts
- Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
else
- newopts = @trace_opts.dup
- opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
- if newopts != @trace_opts
- Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var')
- @trace_opts.replace(newopts)
- Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
+ if winkey
+ fnt = window.fontobj(winkey).dup
+ else
+ fnt = window.fontobj.dup
end
end
- end
- def trace_element(elem, opts, cmd)
- @trace_elem = {} if @trace_elem == nil
- @trace_elem[elem] = [] if @trace_elem[elem] == nil
- opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
- @trace_elem[elem].unshift([opts,cmd])
- if @trace_opts == nil
- TkVar_CB_TBL[@id] = self
- @trace_opts = opts
- Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
+ if targetkey
+ fnt.call_font_configure([__pathname, targetkey], *(__config_cmd << {}))
else
- newopts = @trace_opts.dup
- opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
- if newopts != @trace_opts
- Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var')
- @trace_opts.replace(newopts)
- Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
- end
+ fnt.call_font_configure(__pathname, *(__config_cmd << {}))
end
+ self
end
- def trace_vinfo
- return [] unless @trace_var
- @trace_var.dup
- end
- def trace_vinfo_for_element(elem)
- return [] unless @trace_elem
- return [] unless @trace_elem[elem]
- @trace_elem[elem].dup
- end
-
- def trace_vdelete(opts,cmd)
- return unless @trace_var.kind_of? Array
- opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
- idx = -1
- newopts = ''
- @trace_var.each_with_index{|i,e|
- if idx < 0 && e[0] == opts && e[1] == cmd
- idx = i
- next
- end
- e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
- }
- if idx >= 0
- @trace_var.delete_at(idx)
+ def latinfont_copy(window, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__pathname, targetkey],
+ *(__config_cmd << {}))
else
- return
+ fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {}))
end
- @trace_elem.each{|elem|
- @trace_elem[elem].each{|e|
- e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
- }
- }
-
- newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('')
- if newopts != @trace_opts
- Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var')
- @trace_opts.replace(newopts)
- if @trace_opts != ''
- Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
+ if wintag
+ if winkey
+ fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
+ else
+ fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
+ end
+ else
+ if winkey
+ fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
+ else
+ fontobj.latin_replace(window.fontobj.latin_font_id)
end
end
+ self
end
+ alias asciifont_copy latinfont_copy
- def trace_vdelete_for_element(elem,opts,cmd)
- return unless @trace_elem.kind_of? Hash
- return unless @trace_elem[elem].kind_of? Array
- opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
- idx = -1
- @trace_elem[elem].each_with_index{|i,e|
- if idx < 0 && e[0] == opts && e[1] == cmd
- idx = i
- next
- end
- }
- if idx >= 0
- @trace_elem[elem].delete_at(idx)
+ def kanjifont_copy(window, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__pathname, targetkey],
+ *(__config_cmd << {}))
else
- return
+ fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {}))
end
- newopts = ''
- @trace_var.each{|e|
- e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
- }
- @trace_elem.each{|elem|
- @trace_elem[elem].each{|e|
- e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
- }
- }
-
- newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('')
- if newopts != @trace_opts
- Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var')
- @trace_opts.replace(newopts)
- if @trace_opts != ''
- Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var')
+ if wintag
+ if winkey
+ fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
+ end
+ else
+ if winkey
+ fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(window.fontobj.kanji_font_id)
end
end
+ self
end
end
-class TkVarAccess<TkVariable
- def initialize(varname, val=nil)
- @id = varname
- if val
- s = '"' + _get_eval_string(val).gsub(/[][$"]/, '\\\\\&') + '"' #"
- INTERP._eval(format('global %s; set %s %s', @id, @id, s))
- end
- end
-end
-
-module TkSelection
- include Tk
- extend Tk
- def clear(win=Tk.root)
- tk_call 'selection', 'clear', win.path
- end
- def get(type=None)
- tk_call 'selection', 'get', type
- end
- def TkSelection.handle(win, func, type=None, format=None)
- tk_call 'selection', 'handle', win.path, func, type, format
- end
- def handle(func, type=None, format=None)
- TkSelection.handle self, func, type, format
- end
- def TkSelection.own(win=None, func=None)
- window(tk_call 'selection', 'own', win, func)
- end
- def own(func=None)
- TkSelection.own self, func
- end
-
- module_function :clear, :get
-end
-module TkKinput
- include Tk
- extend Tk
+module TkConfigMethod
+ include TkUtil
+ include TkTreatFont
- def TkKinput.start(window, style=None)
- tk_call 'kinput_start', window.path, style
- end
- def kinput_start(style=None)
- TkKinput.start(self, style)
+ def __cget_cmd
+ [self.path, 'cget']
end
+ private :__cget_cmd
- def TkKinput.send_spot(window)
- tk_call 'kinput_send_spot', window.path
- end
- def kinput_send_spot
- TkKinput.send_spot(self)
+ def __config_cmd
+ [self.path, 'configure']
end
+ private :__config_cmd
- def TkKinput.input_start(window, keys=nil)
- tk_call 'kanjiInput', 'start', window.path, *hash_kv(keys)
- end
- def kanji_input_start(keys=nil)
- TkKinput.input_start(self, keys)
+ def __confinfo_cmd
+ __config_cmd
end
+ private :__config_cmd
- def TkKinput.attribute_config(window, slot, value=None)
- if slot.kind_of? Hash
- tk_call 'kanjiInput', 'attribute', window.path, *hash_kv(slot)
- else
- tk_call 'kanjiInput', 'attribute', window.path, "-#{slot}", value
- end
+ def __configinfo_struct
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
+ :default_value=>3, :current_value=>4}
end
- def kinput_attribute_config(slot, value=None)
- TkKinput.attribute_config(self, slot, value)
+ private :__configinfo_struct
+
+ def __numval_optkeys
+ []
end
+ private :__numval_optkeys
- def TkKinput.attribute_info(window, slot=nil)
- if slot
- conf = tk_split_list(tk_call('kanjiInput', 'attribute',
- window.path, "-#{slot}"))
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_list(tk_call('kanjiInput', 'attribute',
- window.path)).collect{|conf|
- conf[0] = conf[0][1..-1]
- conf
- }
- end
+ def __numstrval_optkeys
+ []
end
- def kinput_attribute_info(slot=nil)
- TkKinput.attribute_info(self, slot)
+ private :__numstrval_optkeys
+
+ def __boolval_optkeys
+ []
end
+ private :__boolval_optkeys
- def TkKinput.input_end(window)
- tk_call 'kanjiInput', 'end', window.path
+ def __strval_optkeys
+ ['text', 'label', 'show', 'data', 'file']
end
- def kanji_input_end
- TkKinput.input_end(self)
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ []
end
-end
+ private :__listval_optkeys
-module TkXIM
- include Tk
- extend Tk
+ def __numlistval_optkeys
+ []
+ end
+ private :__numlistval_optkeys
- def TkXIM.useinputmethods(window=nil, value=nil)
- if window
- if value
- tk_call 'tk', 'useinputmethods', '-displayof', window.path, value
- else
- tk_call 'tk', 'useinputmethods', '-displayof', window.path
- end
- else
- if value
- tk_call 'tk', 'useinputmethods', value
- else
- tk_call 'tk', 'useinputmethods'
- end
- end
+ def __methodcall_optkeys # { key=>method, ... }
+ {}
end
+ private :__methodcall_optkeys
- def TkXIM.configure(window, slot, value=None)
- begin
- if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
- if slot.kind_of? Hash
- tk_call 'imconfigure', window.path, *hash_kv(slot)
- else
- tk_call 'imconfigure', window.path, "-#{slot}", value
- end
- end
- rescue
- end
+ def __keyonly_optkeys # { def_key=>undef_key or nil, ... }
+ {}
end
+ private :__keyonly_optkeys
- def TkXIM.configinfo(window, slot=nil)
- begin
- if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
- if slot
- conf = tk_split_list(tk_call('imconfigure', window.path, "-#{slot}"))
- conf[0] = conf[0][1..-1]
- conf
+ def __conv_keyonly_opts(keys)
+ return keys unless keys.kind_of?(Hash)
+ keyonly = __keyonly_optkeys
+ keys2 = {}
+ keys.each{|k, v|
+ optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s}
+ if optkey
+ defkey, undefkey = optkey
+ if v
+ keys2[defkey.to_s] = None
+ elsif undefkey
+ keys2[undefkey.to_s] = None
else
- tk_split_list(tk_call('imconfigure', window.path)).collect{|conf|
- conf[0] = conf[0][1..-1]
- conf
- }
+ # remove key
end
else
- []
+ keys2[k.to_s] = v
end
- rescue
- []
- end
- end
-
- def useinputmethods(value=nil)
- TkXIM.useinputmethods(self, value)
- end
-
- def imconfigure(window, slot, value=None)
- TkXIM.configinfo(window, slot, value)
+ }
+ keys2
end
- def imconfiginfo(slot=nil)
- TkXIM.configinfo(window, slot)
+ def config_hash_kv(keys, enc_mode = nil, conf = nil)
+ hash_kv(__conv_keyonly_opts(keys), enc_mode, conf)
end
-end
-module TkXIM
- include Tk
- extend Tk
+ ################################
- def TkXIM.useinputmethods(window=nil,value=nil)
- if window
- if value
- tk_call 'tk', 'useinputmethods', '-displayof', window.path, value
- else
- tk_call 'tk', 'useinputmethods', '-displayof', window.path
- end
- else
- if value
- tk_call 'tk', 'useinputmethods', value
- else
- tk_call 'tk', 'useinputmethods'
- end
- end
+ def [](id)
+ cget(id)
end
- def useinputmethods(value=nil)
- TkXIM.useinputmethods(self,value)
+ def []=(id, val)
+ configure(id, val)
+ val
end
-end
-module TkWinfo
- include Tk
- extend Tk
- def TkWinfo.atom(name)
- number(tk_call 'winfo', 'atom', name)
- end
- def winfo_atom(name)
- TkWinfo.atom name
- end
- def TkWinfo.atomname(id)
- tk_call 'winfo', 'atomname', id
- end
- def winfo_atomname(id)
- TkWinfo.atomname id
- end
- def TkWinfo.cells(window)
- number(tk_call('winfo', 'cells', window.path))
- end
- def winfo_cells
- TkWinfo.cells self
- end
- def TkWinfo.children(window)
- c = tk_call('winfo', 'children', window.path)
- list(c)
- end
- def winfo_children
- TkWinfo.children self
- end
- def TkWinfo.classname(window)
- tk_call 'winfo', 'class', window.path
- end
- def winfo_classname
- TkWinfo.classname self
- end
- def TkWinfo.colormapfull(window)
- bool(tk_call('winfo', 'colormapfull', window.path))
- end
- def winfo_colormapfull
- TkWinfo.colormapfull self
- end
- def TkWinfo.containing(rootX, rootY)
- path = tk_call('winfo', 'containing', rootX, rootY)
- window(path)
- end
- def winfo_containing(x, y)
- TkWinfo.containing x, y
- end
- def TkWinfo.depth(window)
- number(tk_call('winfo', 'depth', window.path))
- end
- def winfo_depth
- TkWinfo.depth self
- end
- def TkWinfo.exist?(window)
- bool(tk_call('winfo', 'exists', window.path))
- end
- def winfo_exist?
- TkWinfo.exist? self
- end
- def TkWinfo.fpixels(window, number)
- number(tk_call('winfo', 'fpixels', window.path, number))
- end
- def winfo_fpixels(number)
- TkWinfo.fpixels self, number
- end
- def TkWinfo.geometry(window)
- tk_call('winfo', 'geometry', window.path)
- end
- def winfo_geometry
- TkWinfo.geometry self
- end
- def TkWinfo.height(window)
- number(tk_call('winfo', 'height', window.path))
- end
- def winfo_height
- TkWinfo.height self
- end
- def TkWinfo.id(window)
- tk_call('winfo', 'id', window.path)
- end
- def winfo_id
- TkWinfo.id self
- end
- def TkWinfo.interps(window=nil)
- if window
- tk_split_simplelist(tk_call('winfo', 'interps',
- '-displayof', window.path))
- else
- tk_split_simplelist(tk_call('winfo', 'interps'))
- end
- end
- def winfo_interps
- TkWinfo.interps self
- end
- def TkWinfo.mapped?(window)
- bool(tk_call('winfo', 'ismapped', window.path))
- end
- def winfo_mapped?
- TkWinfo.mapped? self
- end
- def TkWinfo.manager(window)
- tk_call('winfo', 'manager', window.path)
- end
- def winfo_manager
- TkWinfo.manager self
- end
- def TkWinfo.appname(window)
- tk_call('winfo', 'name', window.path)
- end
- def winfo_appname
- TkWinfo.appname self
- end
- def TkWinfo.parent(window)
- window(tk_call('winfo', 'parent', window.path))
- end
- def winfo_parent
- TkWinfo.parent self
- end
- def TkWinfo.widget(id)
- window(tk_call('winfo', 'pathname', id))
- end
- def winfo_widget(id)
- TkWinfo.widget id
- end
- def TkWinfo.pixels(window, number)
- number(tk_call('winfo', 'pixels', window.path, number))
- end
- def winfo_pixels(number)
- TkWinfo.pixels self, number
- end
- def TkWinfo.reqheight(window)
- number(tk_call('winfo', 'reqheight', window.path))
- end
- def winfo_reqheight
- TkWinfo.reqheight self
- end
- def TkWinfo.reqwidth(window)
- number(tk_call('winfo', 'reqwidth', window.path))
- end
- def winfo_reqwidth
- TkWinfo.reqwidth self
- end
- def TkWinfo.rgb(window, color)
- list(tk_call('winfo', 'rgb', window.path, color))
- end
- def winfo_rgb(color)
- TkWinfo.rgb self, color
- end
- def TkWinfo.rootx(window)
- number(tk_call('winfo', 'rootx', window.path))
- end
- def winfo_rootx
- TkWinfo.rootx self
- end
- def TkWinfo.rooty(window)
- number(tk_call('winfo', 'rooty', window.path))
- end
- def winfo_rooty
- TkWinfo.rooty self
- end
- def TkWinfo.screen(window)
- tk_call 'winfo', 'screen', window.path
- end
- def winfo_screen
- TkWinfo.screen self
- end
- def TkWinfo.screencells(window)
- number(tk_call('winfo', 'screencells', window.path))
- end
- def winfo_screencells
- TkWinfo.screencells self
- end
- def TkWinfo.screendepth(window)
- number(tk_call('winfo', 'screendepth', window.path))
- end
- def winfo_screendepth
- TkWinfo.screendepth self
- end
- def TkWinfo.screenheight (window)
- number(tk_call('winfo', 'screenheight', window.path))
- end
- def winfo_screenheight
- TkWinfo.screenheight self
- end
- def TkWinfo.screenmmheight(window)
- number(tk_call('winfo', 'screenmmheight', window.path))
- end
- def winfo_screenmmheight
- TkWinfo.screenmmheight self
- end
- def TkWinfo.screenmmwidth(window)
- number(tk_call('winfo', 'screenmmwidth', window.path))
- end
- def winfo_screenmmwidth
- TkWinfo.screenmmwidth self
- end
- def TkWinfo.screenvisual(window)
- tk_call 'winfo', 'screenvisual', window.path
- end
- def winfo_screenvisual
- TkWinfo.screenvisual self
- end
- def TkWinfo.screenwidth(window)
- number(tk_call('winfo', 'screenwidth', window.path))
- end
- def winfo_screenwidth
- TkWinfo.screenwidth self
- end
- def TkWinfo.server(window)
- tk_call 'winfo', 'server', window.path
- end
- def winfo_server
- TkWinfo.server self
- end
- def TkWinfo.toplevel(window)
- window(tk_call('winfo', 'toplevel', window.path))
- end
- def winfo_toplevel
- TkWinfo.toplevel self
- end
- def TkWinfo.visual(window)
- tk_call 'winfo', 'visual', window.path
- end
- def winfo_visual
- TkWinfo.visual self
- end
- def TkWinfo.visualid(window)
- tk_call 'winfo', 'visualid', window.path
- end
- def winfo_visualid
- TkWinfo.visualid self
- end
- def TkWinfo.visualsavailable(window, includeids=false)
- if includeids
- v = tk_call('winfo', 'visualsavailable', window.path, "includeids")
- else
- v = tk_call('winfo', 'visualsavailable', window.path)
- end
- list(v)
- end
- def winfo_visualsavailable(includeids=false)
- TkWinfo.visualsavailable self, includeids
- end
- def TkWinfo.vrootheight(window)
- number(tk_call('winfo', 'vrootheight', window.path))
- end
- def winfo_vrootheight
- TkWinfo.vrootheight self
- end
- def TkWinfo.vrootwidth(window)
- number(tk_call('winfo', 'vrootwidth', window.path))
- end
- def winfo_vrootwidth
- TkWinfo.vrootwidth self
- end
- def TkWinfo.vrootx(window)
- number(tk_call('winfo', 'vrootx', window.path))
- end
- def winfo_vrootx
- TkWinfo.vrootx self
- end
- def TkWinfo.vrooty(window)
- number(tk_call('winfo', 'vrooty', window.path))
- end
- def winfo_vrooty
- TkWinfo.vrooty self
- end
- def TkWinfo.width(window)
- number(tk_call('winfo', 'width', window.path))
- end
- def winfo_width
- TkWinfo.width self
- end
- def TkWinfo.x(window)
- number(tk_call('winfo', 'x', window.path))
- end
- def winfo_x
- TkWinfo.x self
- end
- def TkWinfo.y(window)
- number(tk_call('winfo', 'y', window.path))
- end
- def winfo_y
- TkWinfo.y self
- end
- def TkWinfo.viewable(window)
- bool(tk_call 'winfo', 'viewable', window.path)
- end
- def winfo_viewable
- TkWinfo.viewable self
- end
- def TkWinfo.pointerx(window)
- number(tk_call('winfo', 'pointerx', window.path))
- end
- def winfo_pointerx
- TkWinfo.pointerx self
- end
- def TkWinfo.pointery(window)
- number(tk_call('winfo', 'pointery', window.path))
- end
- def winfo_pointery
- TkWinfo.pointery self
- end
- def TkWinfo.pointerxy(window)
- list(tk_call('winfo', 'pointerxy', window.path))
- end
- def winfo_pointerxy
- TkWinfo.pointerxy self
- end
-end
+ def cget(slot)
+ slot = slot.to_s
-module TkPack
- include Tk
- extend Tk
- def configure(win, *args)
- if args[-1].kind_of?(Hash)
- keys = args.pop
- end
- wins = [win.epath]
- for i in args
- wins.push i.epath
+ if ( method = _symbolkey2str(__methodcall_optkeys)[slot] )
+ return self.__send__(method)
end
- tk_call "pack", 'configure', *(wins+hash_kv(keys))
- end
- def forget(*args)
- tk_call 'pack', 'forget' *args
- end
+ case slot
+ when /^(#{__numval_optkeys.join('|')})$/
+ begin
+ number(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+ rescue
+ nil
+ end
- def info(slave)
- ilist = list(tk_call('pack', 'info', slave.epath))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
- end
- return info
- end
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ num_or_str(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
- def propagate(master, bool=None)
- if bool == None
- bool(tk_call('pack', 'propagate', master.epath))
- else
- tk_call('pack', 'propagate', master.epath, bool)
- end
- end
+ when /^(#{__boolval_optkeys.join('|')})$/
+ begin
+ bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+ rescue
+ nil
+ end
- def slaves(master)
- list(tk_call('pack', 'slaves', master.epath))
- end
+ when /^(#{__listval_optkeys.join('|')})$/
+ simplelist(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
- module_function :configure, :forget, :info, :propagate, :slaves
-end
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ conf = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))
+ if conf =~ /^[0-9+-]/
+ list(conf)
+ else
+ conf
+ end
-module TkGrid
- include Tk
- extend Tk
+ when /^(#{__strval_optkeys.join('|')})$/
+ _fromUTF8(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
- def bbox(*args)
- list(tk_call('grid', 'bbox', *args))
- end
+ when /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/
+ fontcode = $1
+ fontkey = $2
+ fnt = tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{fontkey}")), true)
+ unless fnt.kind_of?(TkFont)
+ fnt = fontobj(fontkey)
+ end
+ if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
- def configure(widget, *args)
- if args[-1].kind_of?(Hash)
- keys = args.pop
- end
- wins = [widget.epath]
- for i in args
- wins.push i.epath
+ else
+ tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{slot}")), true)
end
- tk_call "grid", 'configure', *(wins+hash_kv(keys))
end
- def columnconfigure(master, index, args)
- tk_call "grid", 'columnconfigure', master, index, *hash_kv(args)
- end
+ def configure(slot, value=None)
+ if slot.kind_of? Hash
+ slot = _symbolkey2str(slot)
- def rowconfigure(master, index, args)
- tk_call "grid", 'rowconfigure', master, index, *hash_kv(args)
- end
+ __methodcall_optkeys.each{|key, method|
+ value = slot.delete(key.to_s)
+ self.__send__(method, value) if value
+ }
- def columnconfiginfo(master, index, slot=nil)
- if slot
- tk_call 'grid', 'columnconfigure', master, index, "-#{slot}"
- else
- ilist = list(tk_call('grid', 'columnconfigure', master, index))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
+ __keyonly_optkeys.each{|defkey, undefkey|
+ conf = slot.find{|kk, vv| kk == defkey.to_s}
+ if conf
+ k, v = conf
+ if v
+ slot[k] = None
+ else
+ slot[undefkey.to_s] = None if undefkey
+ slot.delete(k)
+ end
+ end
+ }
+
+ if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/})
+ font_configure(slot)
+ elsif slot.size > 0
+ tk_call(*(__config_cmd.concat(hash_kv(slot))))
end
- info
- end
- end
- def rowconfiginfo(master, index, slot=nil)
- if slot
- tk_call 'grid', 'rowconfigure', master, index, "-#{slot}"
else
- ilist = list(tk_call('grid', 'rowconfigure', master, index))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
+ slot = slot.to_s
+ if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} )
+ defkey, undefkey = conf
+ if value
+ tk_call(*(__config_cmd << "-#{defkey}"))
+ elsif undefkey
+ tk_call(*(__config_cmd << "-#{undefkey}"))
+ end
+ elsif ( method = _symbolkey2str(__methodcall_optkeys)[slot] )
+ self.__send__(method, value)
+ elsif (slot =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
+ if value == None
+ fontobj($2)
+ else
+ font_configure({slot=>value})
+ end
+ else
+ tk_call(*(__config_cmd << "-#{slot}" << value))
end
- info
end
+ self
end
- def add(widget, *args)
- configure(widget, *args)
+ def configure_cmd(slot, value)
+ configure(slot, install_cmd(value))
end
- def forget(*args)
- tk_call 'grid', 'forget', *args
- end
+ def configinfo(slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}"))))
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
+ elsif ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ conf
+ else
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__methodcall_optkeys.keys.join('|')})$/
+ method = _symbolkey2str(__methodcall_optkeys)[slot]
+ return [slot, '', '', '', self.__send__(method)]
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ else
+ conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ end
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
- def info(slave)
- list(tk_call('grid', 'info', slave))
- end
+ conf
- def location(master, x, y)
- list(tk_call('grid', 'location', master, x, y))
- end
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__confinfo_cmd))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ case conf[__configinfo_struct[:key]]
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
- def propagate(master, bool=None)
- if bool == None
- bool(tk_call('grid', 'propagate', master.epath))
- else
- tk_call('grid', 'propagate', master.epath, bool)
- end
- end
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
- def remove(*args)
- tk_call 'grid', 'remove', *args
- end
+ when /^(#{__boolval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
- def size(master)
- tk_call 'grid', 'size', master
- end
+ when /^(#{__listval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
- def slaves(master, args)
- list(tk_call('grid', 'slaves', master, *hash_kv(args)))
- end
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
- module_function :bbox, :forget, :propagate, :info
- module_function :remove, :size, :slaves, :location
- module_function :configure, :columnconfigure, :rowconfigure
- module_function :columnconfiginfo, :rowconfiginfo
-end
+ else
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ if conf[__configinfo_struct[:default_value]].index('{')
+ conf[__configinfo_struct[:default_value]] =
+ tk_split_list(conf[__configinfo_struct[:default_value]])
+ else
+ conf[__configinfo_struct[:default_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
+ end
+ end
+ if conf[__configinfo_struct[:current_value]]
+ if conf[__configinfo_struct[:current_value]].index('{')
+ conf[__configinfo_struct[:current_value]] =
+ tk_split_list(conf[__configinfo_struct[:current_value]])
+ else
+ conf[__configinfo_struct[:current_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
+ end
+ end
+ end
-module TkPlace
- include Tk
- extend Tk
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
- def configure(win, slot, value=None)
- if slot.kind_of? Hash
- tk_call 'place', 'configure', win.epath, *hash_kv(slot)
- else
- tk_call 'place', 'configure', win.epath, "-#{slot}", value
- end
- end
+ conf
+ }
- def configinfo(win, slot = nil)
- # for >= Tk8.4a2 ?
- if slot
- conf = tk_split_list(tk_call('place', 'configure',
- win.epath, "-#{slot}") )
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_call('place', 'configure',
- win.epath)).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- conf
- }
- end
- end
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf && fontconf.size > 2
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
+ ret.push(fontconf)
+ end
+ }
- def forget(win)
- tk_call 'place', 'forget', win
- end
+ __methodcall_optkeys.each{|optkey, method|
+ ret << [optkey.to_s, '', '', '', self.__send__(method)]
+ }
- def info(win)
- ilist = list(tk_call('place', 'info', win.epath))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
- end
- return info
- end
+ ret
+ end
+ end
- def slaves(master)
- list(tk_call('place', 'slaves', master.epath))
- end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}"))))
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
+ { conf.shift => conf }
+ elsif ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+ else
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__methodcall_optkeys.keys.join('|')})$/
+ method = _symbolkey2str(__methodcall_optkeys)[slot]
+ return {slot => ['', '', '', self.__send__(method)]}
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ end
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
- module_function :configure, :configinfo, :forget, :info, :slaves
-end
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__confinfo_cmd))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ case conf[__configinfo_struct[:key]]
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
-module TkOption
- include Tk
- extend Tk
- def add pat, value, pri=None
- tk_call 'option', 'add', pat, value, pri
- end
- def clear
- tk_call 'option', 'clear'
- end
- def get win, name, klass
- tk_call 'option', 'get', win ,name, klass
- end
- def readfile file, pri=None
- tk_call 'option', 'readfile', file, pri
- end
- module_function :add, :clear, :get, :readfile
-end
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
-module TkTreatFont
- def font_configinfo
- ret = TkFont.used_on(self.path)
- if ret == nil
- ret = TkFont.init_widget_font(self.path, self.path, 'configure')
- end
- ret
- end
- alias fontobj font_configinfo
+ when /^(#{__boolval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
- def font_configure(slot)
- if (fnt = slot.delete('font'))
- if fnt.kind_of? TkFont
- return fnt.call_font_configure(self.path, self.path,'configure',slot)
- else
- latinfont_configure(fnt) if fnt
- end
- end
- if (ltn = slot.delete('latinfont'))
- latinfont_configure(ltn) if ltn
- end
- if (ltn = slot.delete('asciifont'))
- latinfont_configure(ltn) if ltn
- end
- if (knj = slot.delete('kanjifont'))
- kanjifont_configure(knj) if knj
- end
+ when /^(#{__listval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
- tk_call(self.path, 'configure', *hash_kv(slot)) if slot != {}
- self
- end
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
- def latinfont_configure(ltn, keys=nil)
- fobj = fontobj
- if ltn.kind_of? TkFont
- conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val}
- if keys
- fobj.latin_configure(conf.update(keys))
- else
- fobj.latin_configure(conf)
+ else
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ if conf[__configinfo_struct[:default_value]].index('{')
+ conf[__configinfo_struct[:default_value]] =
+ tk_split_list(conf[__configinfo_struct[:default_value]])
+ else
+ conf[__configinfo_struct[:default_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
+ end
+ end
+ if conf[__configinfo_struct[:current_value]]
+ if conf[__configinfo_struct[:current_value]].index('{')
+ conf[__configinfo_struct[:current_value]] =
+ tk_split_list(conf[__configinfo_struct[:current_value]])
+ else
+ conf[__configinfo_struct[:current_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
+ end
+ end
+ end
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ ret[conf[0]] = conf[1]
+ else
+ ret[conf.shift] = conf
+ end
+ }
+
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __methodcall_optkeys.each{|optkey, method|
+ ret[optkey.to_s] = ['', '', '', self.__send__(method)]
+ }
+
+ ret
+ end
end
- else
- fobj.latin_replace(ltn)
end
end
- alias asciifont_configure latinfont_configure
- def kanjifont_configure(knj, keys=nil)
- fobj = fontobj
- if knj.kind_of? TkFont
- conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val}
- if keys
- fobj.kanji_configure(conf.update(keys))
+ def current_configinfo(slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ org_slot = slot
+ begin
+ conf = configinfo(slot)
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__configinfo_struct[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
else
- fobj.kanji_configure(cond)
+ ret = {}
+ configinfo().each{|conf|
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ ret[conf[0]] = conf[-1]
+ end
+ }
+ ret
end
- else
- fobj.kanji_replace(knj)
- end
- end
-
- def font_copy(window, tag=nil)
- if tag
- window.tagfontobj(tag).configinfo.each{|key,value|
- fontobj.configure(key,value)
- }
- fontobj.replace(window.tagfontobj(tag).latin_font,
- window.tagfontobj(tag).kanji_font)
- else
- window.fontobj.configinfo.each{|key,value|
- fontobj.configure(key,value)
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ configinfo(slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
}
- fontobj.replace(window.fontobj.latin_font, window.fontobj.kanji_font)
- end
- end
-
- def latinfont_copy(window, tag=nil)
- if tag
- fontobj.latin_replace(window.tagfontobj(tag).latin_font)
- else
- fontobj.latin_replace(window.fontobj.latin_font)
- end
- end
- alias asciifont_copy latinfont_copy
-
- def kanjifont_copy(window, tag=nil)
- if tag
- fontobj.kanji_replace(window.tagfontobj(tag).kanji_font)
- else
- fontobj.kanji_replace(window.fontobj.kanji_font)
+ ret
end
end
end
class TkObject<TkKernel
+ extend TkCore
include Tk
- include TkTreatFont
+ include TkConfigMethod
include TkBindCore
- def path
- return @path
- end
+### --> definition is moved to TkUtil module
+# def path
+# @path
+# end
def epath
- return @path
+ @path
end
def to_eval
@@ -2187,1241 +3163,709 @@ class TkObject<TkKernel
end
def tk_send(cmd, *rest)
- tk_call path, cmd, *rest
+ tk_call(path, cmd, *rest)
+ end
+ def tk_send_without_enc(cmd, *rest)
+ tk_call_without_enc(path, cmd, *rest)
end
- private :tk_send
+ def tk_send_with_enc(cmd, *rest)
+ tk_call_with_enc(path, cmd, *rest)
+ end
+ # private :tk_send, :tk_send_without_enc, :tk_send_with_enc
def method_missing(id, *args)
name = id.id2name
case args.length
when 1
- configure name, args[0]
+ if name[-1] == ?=
+ configure name[0..-2], args[0]
+ else
+ configure name, args[0]
+ end
when 0
begin
- cget name
+ cget(name)
rescue
- fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
+ fail NameError,
+ "undefined local variable or method `#{name}' for #{self.to_s}",
+ error_at
end
else
fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
end
end
+=begin
def [](id)
- cget id
+ cget(id)
end
def []=(id, val)
- configure id, val
+ configure(id, val)
+ val
end
+=end
- def cget(slot)
- case slot
- when 'text', 'label', 'show', 'data', 'flie'
- tk_call path, 'cget', "-#{slot}"
+ def event_generate(context, keys=nil)
+ if keys
+ #tk_call('event', 'generate', path,
+ # "<#{tk_event_sequence(context)}>", *hash_kv(keys))
+ tk_call_without_enc('event', 'generate', path,
+ "<#{tk_event_sequence(context)}>",
+ *hash_kv(keys, true))
else
- tk_tcl2ruby tk_call path, 'cget', "-#{slot}"
+ #tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>")
+ tk_call_without_enc('event', 'generate', path,
+ "<#{tk_event_sequence(context)}>")
end
end
- def configure(slot, value=None)
- if slot.kind_of? Hash
- if (slot['font'] || slot['kanjifont'] ||
- slot['latinfont'] || slot['asciifont'] )
- font_configure(slot.dup)
- else
- tk_call path, 'configure', *hash_kv(slot)
- end
+ def tk_trace_variable(v)
+ #unless v.kind_of?(TkVariable)
+ # fail(ArgumentError, "type error (#{v.class}); must be TkVariable object")
+ #end
+ v
+ end
+ private :tk_trace_variable
- else
- if (slot == 'font' || slot == 'kanjifont' ||
- slot == 'latinfont' || slot == 'asciifont')
- if value == None
- fontobj
- else
- font_configure({slot=>value})
- end
- else
- tk_call path, 'configure', "-#{slot}", value
- end
- end
+ def destroy
+ #tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id
end
+end
- def configure_cmd(slot, value)
- configure slot, install_cmd(value)
+
+class TkWindow<TkObject
+ include TkWinfo
+ extend TkBindCore
+
+ TkCommandNames = [].freeze
+ ## ==> If TkCommandNames[0] is a string (not a null string),
+ ## assume the string is a Tcl/Tk's create command of the widget class.
+ WidgetClassName = ''.freeze
+ # WidgetClassNames[WidgetClassName] = self
+ ## ==> If self is a widget class, entry to the WidgetClassNames table.
+ def self.to_eval
+ self::WidgetClassName
end
- def configinfo(slot = nil)
- if slot == 'font' || slot == 'kanjifont'
- fontobj
+ def initialize(parent=nil, keys=nil)
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ widgetname = keys.delete('widgetname')
+ install_win(if parent then parent.path end, widgetname)
+ without_creating = keys.delete('without_creating')
+ if without_creating && !widgetname
+ fail ArgumentError,
+ "if set 'without_creating' to true, need to define 'widgetname'"
+ end
+ elsif keys
+ keys = _symbolkey2str(keys)
+ widgetname = keys.delete('widgetname')
+ install_win(if parent then parent.path end, widgetname)
+ without_creating = keys.delete('without_creating')
+ if without_creating && !widgetname
+ fail ArgumentError,
+ "if set 'without_creating' to true, need to define 'widgetname'"
+ end
else
- if slot
- case slot
- when 'text', 'label', 'show', 'data', 'flie'
- conf = tk_split_simplelist(tk_send('configure', "-#{slot}") )
- else
- conf = tk_split_list(tk_send('configure', "-#{slot}") )
- end
- conf[0] = conf[0][1..-1]
- conf
+ install_win(if parent then parent.path end)
+ end
+ if self.method(:create_self).arity == 0
+ p 'create_self has no arg' if $DEBUG
+ create_self unless without_creating
+ if keys
+ # tk_call @path, 'configure', *hash_kv(keys)
+ configure(keys)
+ end
+ else
+ p 'create_self has args' if $DEBUG
+ fontkeys = {}
+ methodkeys = {}
+ if keys
+ #['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
+ # fontkeys[key] = keys.delete(key) if keys.key?(key)
+ #}
+ __font_optkeys.each{|key|
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ }
+
+ __methodcall_optkeys.each{|key|
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
+ }
+ end
+ if without_creating && keys
+ #configure(keys)
+ configure(__conv_keyonly_opts(keys))
else
- ret = tk_split_simplelist(tk_send('configure') ).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show', 'data', 'flie'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf
- }
- fontconf = ret.assoc('font')
- if fontconf
- ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
- fontconf[4] = fontobj
- ret.push(fontconf)
- else
- ret
- end
+ #create_self(keys)
+ create_self(__conv_keyonly_opts(keys))
end
+ font_configure(fontkeys) unless fontkeys.empty?
+ configure(methodkeys) unless methodkeys.empty?
end
end
- def event_generate(context, keys=nil)
- if keys
- tk_call('event', 'generate', path,
- "<#{tk_event_sequence(context)}>", *hash_kv(keys))
- else
- tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>")
+ def create_self(keys)
+ # may need to override
+ begin
+ cmd = self.class::TkCommandNames[0]
+ fail unless (cmd.kind_of?(String) && cmd.length > 0)
+ rescue
+ fail RuntimeError, "class #{self.class} may be an abstract class"
end
- end
- def tk_trace_variable(v)
- unless v.kind_of?(TkVariable)
- fail ArgumentError, format("requires TkVariable given %s", v.type)
+ if keys and keys != None
+ tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc(cmd, @path)
end
- v
end
- private :tk_trace_variable
+ private :create_self
- def destroy
- tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id
+ def exist?
+ TkWinfo.exist?(self)
end
-end
-class TkWindow<TkObject
- extend TkBindCore
+ def bind_class
+ @db_class || self.class()
+ end
- def initialize(parent=nil, keys=nil)
- install_win(if parent then parent.path end)
- create_self
- if keys
- # tk_call @path, 'configure', *hash_kv(keys)
- configure(keys)
+ def database_classname
+ TkWinfo.classname(self)
+ end
+ def database_class
+ name = database_classname()
+ if WidgetClassNames[name]
+ WidgetClassNames[name]
+ else
+ TkDatabaseClass.new(name)
end
end
-
- def create_self
+ def self.database_classname
+ self::WidgetClassName
+ end
+ def self.database_class
+ WidgetClassNames[self::WidgetClassName]
end
- private :create_self
def pack(keys = nil)
- tk_call 'pack', epath, *hash_kv(keys)
+ #tk_call_without_enc('pack', epath, *hash_kv(keys, true))
+ if keys
+ TkPack.configure(self, keys)
+ else
+ TkPack.configure(self)
+ end
+ self
+ end
+
+ def pack_in(target, keys = nil)
+ if keys
+ keys = keys.dup
+ keys['in'] = target
+ else
+ keys = {'in'=>target}
+ end
+ #tk_call 'pack', epath, *hash_kv(keys)
+ TkPack.configure(self, keys)
self
end
- def unpack
- tk_call 'pack', 'forget', epath
+ def pack_forget
+ #tk_call_without_enc('pack', 'forget', epath)
+ TkPack.forget(self)
self
end
- alias pack_forget unpack
+ alias unpack pack_forget
def pack_config(slot, value=None)
+ #if slot.kind_of? Hash
+ # tk_call 'pack', 'configure', epath, *hash_kv(slot)
+ #else
+ # tk_call 'pack', 'configure', epath, "-#{slot}", value
+ #end
if slot.kind_of? Hash
- tk_call 'pack', 'configure', epath, *hash_kv(slot)
+ TkPack.configure(self, slot)
else
- tk_call 'pack', 'configure', epath, "-#{slot}", value
+ TkPack.configure(self, slot=>value)
end
end
+ alias pack_configure pack_config
def pack_info()
- ilist = list(tk_call('pack', 'info', epath))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
- end
- return info
+ #ilist = list(tk_call('pack', 'info', epath))
+ #info = {}
+ #while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ #end
+ #return info
+ TkPack.info(self)
end
- def pack_propagate(mode = nil)
- if mode
- tk_call('pack', 'propagate', epath, mode)
+ def pack_propagate(mode=None)
+ #if mode == None
+ # bool(tk_call('pack', 'propagate', epath))
+ #else
+ # tk_call('pack', 'propagate', epath, mode)
+ # self
+ #end
+ if mode == None
+ TkPack.propagate(self)
else
- bool(tk_call('pack', 'propagate', epath))
+ TkPack.propagate(self, mode)
+ self
end
end
def pack_slaves()
- list(tk_call('pack', 'slaves', epath))
+ #list(tk_call('pack', 'slaves', epath))
+ TkPack.slaves(self)
end
def grid(keys = nil)
- tk_call 'grid', epath, *hash_kv(keys)
+ #tk_call 'grid', epath, *hash_kv(keys)
+ if keys
+ TkGrid.configure(self, keys)
+ else
+ TkGrid.configure(self)
+ end
+ self
+ end
+
+ def grid_in(target, keys = nil)
+ if keys
+ keys = keys.dup
+ keys['in'] = target
+ else
+ keys = {'in'=>target}
+ end
+ #tk_call 'grid', epath, *hash_kv(keys)
+ TkGrid.configure(self, keys)
self
end
- def ungrid
- tk_call 'grid', 'forget', epath
+ def grid_forget
+ #tk_call('grid', 'forget', epath)
+ TkGrid.forget(self)
self
end
- alias grid_forget ungrid
+ alias ungrid grid_forget
def grid_bbox(*args)
- list(tk_call('grid', 'bbox', epath, *args))
+ #list(tk_call('grid', 'bbox', epath, *args))
+ TkGrid.bbox(self, *args)
end
def grid_config(slot, value=None)
+ #if slot.kind_of? Hash
+ # tk_call 'grid', 'configure', epath, *hash_kv(slot)
+ #else
+ # tk_call 'grid', 'configure', epath, "-#{slot}", value
+ #end
if slot.kind_of? Hash
- tk_call 'grid', 'configure', epath, *hash_kv(slot)
+ TkGrid.configure(self, slot)
else
- tk_call 'grid', 'configure', epath, "-#{slot}", value
+ TkGrid.configure(self, slot=>value)
end
end
+ alias grid_configure grid_config
def grid_columnconfig(index, keys)
- tk_call('grid', 'columnconfigure', epath, index, hash_kv(keys))
+ #tk_call('grid', 'columnconfigure', epath, index, *hash_kv(keys))
+ TkGrid.columnconfigure(self, index, keys)
end
+ alias grid_columnconfigure grid_columnconfig
def grid_rowconfig(index, keys)
- tk_call('grid', 'rowconfigure', epath, index, hash_kv(keys))
+ #tk_call('grid', 'rowconfigure', epath, index, *hash_kv(keys))
+ TkGrid.rowconfigure(self, index, keys)
end
+ alias grid_rowconfigure grid_rowconfig
def grid_columnconfiginfo(index, slot=nil)
- if slot
- tk_call('grid', 'columnconfigure', epath, index, "-#{slot}")
- else
- ilist = list(tk_call('grid', 'columnconfigure', epath, index))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
- end
- info
- end
+ #if slot
+ # tk_call('grid', 'columnconfigure', epath, index, "-#{slot}").to_i
+ #else
+ # ilist = list(tk_call('grid', 'columnconfigure', epath, index))
+ # info = {}
+ # while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ # end
+ # info
+ #end
+ TkGrid.columnconfiginfo(self, index, slot)
end
def grid_rowconfiginfo(index, slot=nil)
- if slot
- tk_call('grid', 'rowconfigure', epath, index, "-#{slot}")
- else
- ilist = list(tk_call('grid', 'rowconfigure', epath, index))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
- end
- info
- end
+ #if slot
+ # tk_call('grid', 'rowconfigure', epath, index, "-#{slot}").to_i
+ #else
+ # ilist = list(tk_call('grid', 'rowconfigure', epath, index))
+ # info = {}
+ # while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ # end
+ # info
+ #end
+ TkGrid.rowconfiginfo(self, index, slot)
end
def grid_info()
- list(tk_call('grid', 'info', epath))
+ #list(tk_call('grid', 'info', epath))
+ TkGrid.info(self)
end
def grid_location(x, y)
- list(tk_call('grid', 'location', epath, x, y))
+ #list(tk_call('grid', 'location', epath, x, y))
+ TkGrid.location(self, x, y)
end
- def grid_propagate(mode=nil)
- if mode
- tk_call('grid', 'propagate', epath, mode)
+ def grid_propagate(mode=None)
+ #if mode == None
+ # bool(tk_call('grid', 'propagate', epath))
+ #else
+ # tk_call('grid', 'propagate', epath, mode)
+ # self
+ #end
+ if mode == None
+ TkGrid.propagete(self)
else
- bool(tk_call('grid', 'propagate', epath))
+ TkGrid.propagete(self, mode)
+ self
end
end
def grid_remove()
- tk_call 'grid', 'remove', epath
+ #tk_call 'grid', 'remove', epath
+ TkGrid.remove(self)
+ self
end
def grid_size()
- tk_call 'grid', 'size', epath
+ #list(tk_call('grid', 'size', epath))
+ TkGrid.size(self)
end
def grid_slaves(args)
- list(tk_call('grid', 'slaves', epath, *hash_kv(args)))
+ #list(tk_call('grid', 'slaves', epath, *hash_kv(args)))
+ TkGrid.slaves(self, args)
+ end
+
+ def place(keys)
+ #tk_call 'place', epath, *hash_kv(keys)
+ TkPlace.configure(self, keys)
+ self
end
- def place(keys = nil)
- tk_call 'place', epath, *hash_kv(keys)
+ def place_in(target, keys = nil)
+ if keys
+ keys = keys.dup
+ keys['in'] = target
+ else
+ keys = {'in'=>target}
+ end
+ #tk_call 'place', epath, *hash_kv(keys)
+ TkPlace.configure(self, keys)
self
end
- def unplace
- tk_call 'place', 'forget', epath
+ def place_forget
+ #tk_call 'place', 'forget', epath
+ TkPlace.forget(self)
self
end
- alias place_forget unplace
+ alias unplace place_forget
def place_config(slot, value=None)
- if slot.kind_of? Hash
- tk_call 'place', 'configure', epath, *hash_kv(slot)
- else
- tk_call 'place', 'configure', epath, "-#{slot}", value
- end
+ #if slot.kind_of? Hash
+ # tk_call 'place', 'configure', epath, *hash_kv(slot)
+ #else
+ # tk_call 'place', 'configure', epath, "-#{slot}", value
+ #end
+ TkPlace.configure(self, slot, value)
end
+ alias place_configure place_config
def place_configinfo(slot = nil)
# for >= Tk8.4a2 ?
- if slot
- conf = tk_split_list(tk_call('place', 'configure', epath, "-#{slot}") )
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_call('place',
- 'configure', epath)).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- conf
- }
- end
+ #if slot
+ # conf = tk_split_list(tk_call('place', 'configure', epath, "-#{slot}") )
+ # conf[0] = conf[0][1..-1]
+ # conf
+ #else
+ # tk_split_simplelist(tk_call('place',
+ # 'configure', epath)).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ # conf[0] = conf[0][1..-1]
+ # conf
+ # }
+ #end
+ TkPlace.configinfo(self, slot)
end
def place_info()
- ilist = list(tk_call('place', 'info', epath))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
- end
- return info
+ #ilist = list(tk_call('place', 'info', epath))
+ #info = {}
+ #while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ #end
+ #return info
+ TkPlace.info(self)
end
def place_slaves()
- list(tk_call('place', 'slaves', epath))
+ #list(tk_call('place', 'slaves', epath))
+ TkPlace.slaves(self)
end
- def focus(force=false)
+ def set_focus(force=false)
if force
- tk_call 'focus', '-force', path
- else
- tk_call 'focus', path
- end
- self
- end
-
- def grab(*args)
- if !args or args.length == 0
- tk_call 'grab', 'set', path
- elsif args.length == 1
- case args[0]
- when 'global'
- return(tk_call 'grab', 'set', '-global', path)
- when 'release'
- return(tk_call 'grab', 'release', path)
- else
- val = tk_call('grab', args[0], path)
- end
- case args[0]
- when 'current'
- return window(val)
- when 'status'
- return val
- end
+ tk_call_without_enc('focus', '-force', path)
else
- fail ArgumentError, 'wrong # of args'
+ tk_call_without_enc('focus', path)
end
- end
-
- def lower(below=None)
- tk_call 'lower', epath, below
self
end
- def raise(above=None)
- tk_call 'raise', epath, above
- self
- end
-
- def command(cmd=Proc.new)
- configure_cmd 'command', cmd
- end
-
- def colormodel model=None
- tk_call 'tk', 'colormodel', path, model
- self
- end
-
- def destroy
- tk_call 'destroy', epath
- if @cmdtbl
- for id in @cmdtbl
- uninstall_cmd id
- end
- end
- uninstall_win
- end
+ alias focus set_focus
- def wait_visibility
- tk_call 'tkwait', 'visibility', path
- end
- alias wait wait_visibility
-
- def wait_destroy
- tk_call 'tkwait', 'window', epath
- end
-
- def bindtags(taglist=nil)
- if taglist
- fail ArgumentError unless taglist.kind_of? Array
- tk_call('bindtags', path, taglist)
- else
- list(tk_call('bindtags', path)).collect{|tag|
- if tag.kind_of?(String)
- if cls = WidgetClassNames[tag]
- cls
- elsif btag = TkBindTag.id2obj(tag)
- btag
- else
- tag
- end
- else
- tag
- end
- }
+ def grab(opt = nil)
+ unless opt
+ tk_call_without_enc('grab', 'set', path)
+ return self
end
- end
-end
-
-class TkRoot<TkWindow
- include Wm
- ROOT = []
- def TkRoot.new
- return ROOT[0] if ROOT[0]
- new = super
- ROOT[0] = new
- Tk_WINDOWS["."] = new
- end
-
- WidgetClassName = 'Tk'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- def create_self
- @path = '.'
- end
- def path
- "."
- end
-end
-
-class TkToplevel<TkWindow
- include Wm
- WidgetClassName = 'Toplevel'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
- if screen.kind_of? Hash
- keys = screen.dup
+ case opt
+ when 'set', :set
+ tk_call_without_enc('grab', 'set', path)
+ return self
+ when 'global', :global
+ #return(tk_call('grab', 'set', '-global', path))
+ tk_call_without_enc('grab', 'set', '-global', path)
+ return self
+ when 'release', :release
+ #return tk_call('grab', 'release', path)
+ tk_call_without_enc('grab', 'release', path)
+ return self
+ when 'current', :current
+ return window(tk_call_without_enc('grab', 'current', path))
+ when 'status', :status
+ return tk_call_without_enc('grab', 'status', path)
else
- @screen = screen
- end
- @classname = classname
- if keys.kind_of? Hash
- keys = keys.dup
- @classname = keys.delete('classname') if keys.key?('classname')
- @colormap = keys.delete('colormap') if keys.key?('colormap')
- @container = keys.delete('container') if keys.key?('container')
- @screen = keys.delete('screen') if keys.key?('screen')
- @use = keys.delete('use') if keys.key?('use')
- @visual = keys.delete('visual') if keys.key?('visual')
- end
- super(parent, keys)
- end
-
- def create_self
- s = []
- s << "-class" << @classname if @classname
- s << "-colormap" << @colormap if @colormap
- s << "-container" << @container if @container
- s << "-screen" << @screen if @screen
- s << "-use" << @use if @use
- s << "-visual" << @visual if @visual
- tk_call 'toplevel', @path, *s
- end
-
- def specific_class
- @classname
- end
-end
-
-class TkFrame<TkWindow
- WidgetClassName = 'Frame'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- def initialize(parent=nil, keys=nil)
- if keys.kind_of? Hash
- keys = keys.dup
- @classname = keys.delete('classname') if keys.key?('classname')
- @colormap = keys.delete('colormap') if keys.key?('colormap')
- @container = keys.delete('container') if keys.key?('container')
- @visual = keys.delete('visual') if keys.key?('visual')
- end
- super(parent, keys)
- end
-
- def create_self
- s = []
- s << "-class" << @classname if @classname
- s << "-colormap" << @colormap if @colormap
- s << "-container" << @container if @container
- s << "-visual" << @visual if @visual
- tk_call 'frame', @path, *s
- end
-end
-
-class TkLabel<TkWindow
- WidgetClassName = 'Label'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
- def create_self
- tk_call 'label', @path
- end
- def textvariable(v)
- configure 'textvariable', tk_trace_variable(v)
- end
-end
-
-class TkButton<TkLabel
- WidgetClassNames['Button'] = self
- def TkButton.to_eval
- 'Button'
- end
- def create_self
- tk_call 'button', @path
- end
- def invoke
- tk_send 'invoke'
- end
- def flash
- tk_send 'flash'
- end
-end
-
-class TkRadioButton<TkButton
- WidgetClassNames['Radiobutton'] = self
- def TkRadioButton.to_eval
- 'Radiobutton'
- end
- def create_self
- tk_call 'radiobutton', @path
- end
- def deselect
- tk_send 'deselect'
- end
- def select
- tk_send 'select'
- end
- def variable(v)
- configure 'variable', tk_trace_variable(v)
- end
-end
-TkRadiobutton = TkRadioButton
-
-class TkCheckButton<TkRadioButton
- WidgetClassNames['Checkbutton'] = self
- def TkCheckButton.to_eval
- 'Checkbutton'
- end
- def create_self
- tk_call 'checkbutton', @path
- end
- def toggle
- tk_send 'toggle'
- end
-end
-TkCheckbutton = TkCheckButton
-
-class TkMessage<TkLabel
- WidgetClassNames['Message'] = self
- def TkMessage.to_eval
- 'Message'
- end
- def create_self
- tk_call 'message', @path
- end
-end
-
-class TkScale<TkWindow
- WidgetClassName = 'Scale'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- def create_self
- tk_call 'scale', path
- end
-
- def get(x=None, y=None)
- number(tk_send('get', x, y))
- end
-
- def coords(val=None)
- tk_split_list(tk_send('coords', val))
- end
-
- def identify(x, y)
- tk_send('identify', x, y)
- end
-
- def set(val)
- tk_send "set", val
- end
-
- def value
- get
- end
-
- def value= (val)
- set val
- end
-end
-
-class TkScrollbar<TkWindow
- WidgetClassName = 'Scrollbar'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- def create_self
- tk_call 'scrollbar', path
- end
-
- def delta(deltax=None, deltay=None)
- number(tk_send('delta', deltax, deltay))
- end
-
- def fraction(x=None, y=None)
- number(tk_send('fraction', x, y))
- end
-
- def identify(x, y)
- tk_send('identify', x, y)
- end
-
- def get
- ary1 = tk_send('get').split
- ary2 = []
- for i in ary1
- ary2.push number(i)
+ return tk_call_without_enc('grab', opt, path)
end
- ary2
- end
-
- def set(first, last)
- tk_send "set", first, last
- end
-
- def activate(element=None)
- tk_send('activate', element)
- end
-end
-
-class TkTextWin<TkWindow
- def create_self
- fail TypeError, "TkTextWin is abstract class"
end
- def bbox(index)
- tk_send 'bbox', index
- end
- def delete(first, last=None)
- tk_send 'delete', first, last
- end
- def get(*index)
- tk_send 'get', *index
- end
- def index(index)
- tk_send 'index', index
- end
- def insert(index, chars, *args)
- tk_send 'insert', index, chars, *args
- end
- def scan_mark(x, y)
- tk_send 'scan', 'mark', x, y
+ def grab_current
+ grab('current')
end
- def scan_dragto(x, y)
- tk_send 'scan', 'dragto', x, y
+ alias current_grab grab_current
+ def grab_release
+ grab('release')
end
- def see(index)
- tk_send 'see', index
+ alias release_grab grab_release
+ def grab_set
+ grab('set')
end
-end
-
-class TkListbox<TkTextWin
- include Scrollable
-
- WidgetClassNames['Listbox'] = self
- def TkListbox.to_eval
- 'Listbox'
+ alias set_grab grab_set
+ def grab_set_global
+ grab('global')
end
- def create_self
- tk_call 'listbox', path
+ alias set_global_grab grab_set_global
+ def grab_status
+ grab('status')
end
- def activate(y)
- tk_send 'activate', y
- end
- def curselection
- list(tk_send('curselection'))
- end
- def get(*index)
- v = tk_send('get', *index)
- if index.size == 1
- v
- else
- tk_split_simplelist(v)
- end
- end
- def nearest(y)
- tk_send('nearest', y).to_i
- end
- def size
- tk_send('size').to_i
- end
- def selection_anchor(index)
- tk_send 'selection', 'anchor', index
- end
- def selection_clear(first, last=None)
- tk_send 'selection', 'clear', first, last
- end
- def selection_includes(index)
- bool(tk_send('selection', 'includes', index))
- end
- def selection_set(first, last=None)
- tk_send 'selection', 'set', first, last
+ def lower(below=None)
+ # below = below.epath if below.kind_of?(TkObject)
+ below = _epath(below)
+ tk_call 'lower', epath, below
+ self
end
-
- def itemcget(index, key)
- case key
- when 'text', 'label', 'show'
- tk_send 'itemcget', index, "-#{key}"
- else
- tk_tcl2ruby tk_send 'itemcget', index, "-#{key}"
- end
+ def raise(above=None)
+ #above = above.epath if above.kind_of?(TkObject)
+ above = _epath(above)
+ tk_call 'raise', epath, above
+ self
end
- def itemconfigure(index, key, val=None)
- if key.kind_of? Hash
- if (key['font'] || key['kanjifont'] ||
- key['latinfont'] || key['asciifont'])
- tagfont_configure(index, key.dup)
- else
- tk_send 'itemconfigure', index, *hash_kv(key)
- end
+ def command(cmd=nil, &b)
+ if cmd
+ configure_cmd('command', cmd)
+ elsif b
+ configure_cmd('command', Proc.new(&b))
else
- if (key == 'font' || key == 'kanjifont' ||
- key == 'latinfont' || key == 'asciifont' )
- tagfont_configure({key=>val})
- else
- tk_call 'itemconfigure', index, "-#{key}", val
- end
+ cget('command')
end
end
- def itemconfiginfo(index, key=nil)
- if key
- case key
- when 'text', 'label', 'show'
- conf = tk_split_simplelist(tk_send('itemconfigure',index,"-#{key}"))
- else
- conf = tk_split_list(tk_send('itemconfigure',index,"-#{key}"))
- end
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_send('itemconfigure', index)).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf
- }
- end
- end
-end
-
-module TkTreatMenuEntryFont
- def tagfont_configinfo(index)
- pathname = self.path + ';' + index
- ret = TkFont.used_on(pathname)
- if ret == nil
- ret = TkFont.init_widget_font(pathname,
- self.path, 'entryconfigure', index)
- end
- ret
+ def colormodel(model=None)
+ tk_call('tk', 'colormodel', path, model)
+ self
end
- alias tagfontobj tagfont_configinfo
- def tagfont_configure(index, slot)
- pathname = self.path + ';' + index
- if (fnt = slot.delete('font'))
- if fnt.kind_of? TkFont
- return fnt.call_font_configure(pathname,
- self.path,'entryconfigure',index,slot)
- else
- latintagfont_configure(index, fnt) if fnt
- end
- end
- if (ltn = slot.delete('latinfont'))
- latintagfont_configure(index, ltn) if ltn
- end
- if (ltn = slot.delete('asciifont'))
- latintagfont_configure(index, ltn) if ltn
- end
- if (knj = slot.delete('kanjifont'))
- kanjitagfont_configure(index, knj) if knj
- end
-
- tk_call(self.path, 'entryconfigure', index, *hash_kv(slot)) if slot != {}
- self
+ def caret(keys=nil)
+ TkXIM.caret(path, keys)
end
- def latintagfont_configure(index, ltn, keys=nil)
- fobj = tagfontobj(index)
- if ltn.kind_of? TkFont
- conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []}
- if conf == {}
- fobj.latin_replace(ltn)
- fobj.latin_configure(keys) if keys
- elsif keys
- fobj.latin_configure(conf.update(keys))
- else
- fobj.latin_configure(conf)
+ def destroy
+ super
+ children = []
+ rexp = /^#{self.path}\.[^.]+$/
+ TkCore::INTERP.tk_windows.each{|path, obj|
+ children << [path, obj] if path =~ rexp
+ }
+ if defined?(@cmdtbl)
+ for id in @cmdtbl
+ uninstall_cmd id
end
- else
- fobj.latin_replace(ltn)
end
- end
- alias asciitagfont_configure latintagfont_configure
- def kanjitagfont_configure(index, knj, keys=nil)
- fobj = tagfontobj(index)
- if knj.kind_of? TkFont
- conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []}
- if conf == {}
- fobj.kanji_replace(knj)
- fobj.kanji_configure(keys) if keys
- elsif keys
- fobj.kanji_configure(conf.update(keys))
- else
- fobj.kanji_configure(conf)
+ children.each{|path, obj|
+ if defined?(@cmdtbl)
+ for id in @cmdtbl
+ uninstall_cmd id
+ end
end
- else
- fobj.kanji_replace(knj)
- end
- end
+ TkCore::INTERP.tk_windows.delete(path)
+ }
- def tagfont_copy(index, window, wintag=nil)
- if wintag
- window.tagfontobj(wintag).configinfo.each{|key,value|
- tagfontobj(index).configure(key,value)
- }
- tagfontobj(index).replace(window.tagfontobj(wintag).latin_font,
- window.tagfontobj(wintag).kanji_font)
- else
- window.tagfont(wintag).configinfo.each{|key,value|
- tagfontobj(index).configure(key,value)
- }
- tagfontobj(index).replace(window.fontobj.latin_font,
- window.fontobj.kanji_font)
+ begin
+ tk_call_without_enc('destroy', epath)
+ rescue
end
+ uninstall_win
end
- def latintagfont_copy(index, window, wintag=nil)
- if wintag
- tagfontobj(index).latin_replace(window.tagfontobj(wintag).latin_font)
- else
- tagfontobj(index).latin_replace(window.fontobj.latin_font)
+ def wait_visibility(on_thread = true)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait visibility at $SAFE >= 4"
end
- end
- alias asciitagfont_copy latintagfont_copy
-
- def kanjitagfont_copy(index, window, wintag=nil)
- if wintag
- tagfontobj(index).kanji_replace(window.tagfontobj(wintag).kanji_font)
+ on_thread &= (Thread.list.size != 1)
+ if on_thread
+ INTERP._thread_tkwait('visibility', path)
else
- tagfontobj(index).kanji_replace(window.fontobj.kanji_font)
+ INTERP._invoke('tkwait', 'visibility', path)
end
end
-end
-
-class TkMenu<TkWindow
- include TkTreatMenuEntryFont
-
- WidgetClassName = 'Menu'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
- def create_self
- tk_call 'menu', path
- end
- def activate(index)
- tk_send 'activate', index
- end
- def add(type, keys=nil)
- tk_send 'add', type, *hash_kv(keys)
- end
- def index(index)
- tk_send 'index', index
- end
- def invoke(index)
- tk_send 'invoke', index
- end
- def insert(index, type, keys=nil)
- tk_send 'insert', index, type, *hash_kv(keys)
+ def eventloop_wait_visibility
+ wait_visibility(false)
end
- def delete(index, last=None)
- tk_send 'delete', index, last
+ def thread_wait_visibility
+ wait_visibility(true)
end
- def popup(x, y, index=None)
- tk_call 'tk_popup', path, x, y, index
- end
- def post(x, y)
- tk_send 'post', x, y
- end
- def postcascade(index)
- tk_send 'postcascade', index
- end
- def postcommand(cmd=Proc.new)
- configure_cmd 'postcommand', cmd
- end
- def tearoffcommand(cmd=Proc.new)
- configure_cmd 'tearoffcommand', cmd
- end
- def menutype(index)
- tk_send 'type', index
- end
- def unpost
- tk_send 'unpost'
- end
- def yposition(index)
- number(tk_send('yposition', index))
- end
- def entrycget(index, key)
- case key
- when 'text', 'label', 'show'
- tk_send 'entrycget', index, "-#{key}"
- else
- tk_tcl2ruby tk_send 'entrycget', index, "-#{key}"
- end
- end
- def entryconfigure(index, key, val=None)
- if key.kind_of? Hash
- if (key['font'] || key['kanjifont'] ||
- key['latinfont'] || key['asciifont'])
- tagfont_configure(index, key.dup)
- else
- tk_send 'entryconfigure', index, *hash_kv(key)
- end
+ alias wait wait_visibility
+ alias tkwait wait_visibility
+ alias eventloop_wait eventloop_wait_visibility
+ alias eventloop_tkwait eventloop_wait_visibility
+ alias eventloop_tkwait_visibility eventloop_wait_visibility
+ alias thread_wait thread_wait_visibility
+ alias thread_tkwait thread_wait_visibility
+ alias thread_tkwait_visibility thread_wait_visibility
- else
- if (key == 'font' || key == 'kanjifont' ||
- key == 'latinfont' || key == 'asciifont' )
- tagfont_configure({key=>val})
- else
- tk_call 'entryconfigure', index, "-#{key}", val
- end
+ def wait_destroy(on_thread = true)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait destroy at $SAFE >= 4"
end
- end
-
- def entryconfiginfo(index, key=nil)
- if key
- case key
- when 'text', 'label', 'show'
- conf = tk_split_simplelist(tk_send('entryconfigure',index,"-#{key}"))
- else
- conf = tk_split_list(tk_send('entryconfigure',index,"-#{key}"))
- end
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_send('entryconfigure', index)).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf
- }
+ on_thread &= (Thread.list.size != 1)
+ if on_thread
+ INTERP._thread_tkwait('window', epath)
+ else
+ INTERP._invoke('tkwait', 'window', epath)
end
end
-end
-
-class TkMenuClone<TkMenu
- def initialize(parent, type=None)
- unless parent.kind_of?(TkMenu)
- fail ArgumentError, "parent must be TkMenu"
- end
- @parent = parent
- install_win(@parent.path)
- tk_call @parent.path, 'clone', @path, type
+ alias wait_window wait_destroy
+ def eventloop_wait_destroy
+ wait_destroy(false)
end
-end
-
-module TkSystemMenu
- def initialize(parent, keys=nil)
- fail unless parent.kind_of? TkMenu
- @path = format("%s.%s", parent.path, self.type::SYSMENU_NAME)
- TkComm::Tk_WINDOWS[@path] = self
- create_self
- configure(keys) if keys
+ alias eventloop_wait_window eventloop_wait_destroy
+ def thread_wait_destroy
+ wait_destroy(true)
end
-end
+ alias thread_wait_window thread_wait_destroy
-class TkSysMenu_Help<TkMenu
- # for all platform
- include TkSystemMenu
- SYSMENU_NAME = 'help'
-end
+ alias tkwait_destroy wait_destroy
+ alias tkwait_window wait_destroy
-class TkSysMenu_System<TkMenu
- # for Windows
- include TkSystemMenu
- SYSMENU_NAME = 'system'
-end
-
-class TkSysMenu_Apple<TkMenu
- # for Machintosh
- include TkSystemMenu
- SYSMENU_NAME = 'apple'
-end
+ alias eventloop_tkwait_destroy eventloop_wait_destroy
+ alias eventloop_tkwait_window eventloop_wait_destroy
-class TkMenubutton<TkLabel
- WidgetClassNames['Menubutton'] = self
- def TkMenubutton.to_eval
- 'Menubutton'
- end
- def create_self
- tk_call 'menubutton', path
- end
-end
+ alias thread_tkwait_destroy thread_wait_destroy
+ alias thread_tkwait_window thread_wait_destroy
-class TkOptionMenubutton<TkMenubutton
- class OptionMenu<TkMenu
- def initialize(parent)
- @path = parent.path + '.menu'
- TkComm::Tk_WINDOWS[@path] = self
+ def bindtags(taglist=nil)
+ if taglist
+ fail ArgumentError, "taglist must be Array" unless taglist.kind_of? Array
+ tk_call('bindtags', path, taglist)
+ taglist
+ else
+ list(tk_call('bindtags', path)).collect{|tag|
+ if tag.kind_of?(String)
+ if cls = WidgetClassNames[tag]
+ cls
+ elsif btag = TkBindTag.id2obj(tag)
+ btag
+ else
+ tag
+ end
+ else
+ tag
+ end
+ }
end
end
- def initialize(parent=nil, var=TkVariable.new, firstval=nil, *vals)
- fail unless var.kind_of? TkVariable
- @variable = var
- firstval = @variable.value unless firstval
- @variable.value = firstval
- install_win(if parent then parent.path end)
- @menu = OptionMenu.new(self)
- tk_call 'tk_optionMenu', @path, @variable.id, firstval, *vals
+ def bindtags=(taglist)
+ bindtags(taglist)
+ taglist
end
- def value
- @variable.value
+ def bindtags_shift
+ taglist = bindtags
+ tag = taglist.shift
+ bindtags(taglist)
+ tag
end
- def activate(index)
- @menu.activate(index)
- end
- def add(value)
- @menu.add('radiobutton', 'variable'=>@variable,
- 'label'=>value, 'value'=>value)
- end
- def index(index)
- @menu.index(index)
- end
- def invoke(index)
- @menu.invoke(index)
- end
- def insert(index, value)
- @menu.add(index, 'radiobutton', 'variable'=>@variable,
- 'label'=>value, 'value'=>value)
- end
- def delete(index, last=None)
- @menu.delete(index, last)
- end
- def yposition(index)
- @menu.yposition(index)
- end
- def menucget(index, key)
- @menu.cget(index, key)
- end
- def menuconfigure(index, key, val=None)
- @menu.configure(index, key, val)
- end
- def menuconfiginfo(index, key=nil)
- @menu.configinfo(index, key)
- end
- def entrycget(index, key)
- @menu.entrycget(index, key)
- end
- def entryconfigure(index, key, val=None)
- @menu.entryconfigure(index, key, val)
- end
- def entryconfiginfo(index, key=nil)
- @menu.entryconfiginfo(index, key)
+ def bindtags_unshift(tag)
+ bindtags(bindtags().unshift(tag))
end
end
-module TkComposite
- include Tk
- extend Tk
-
- def initialize(parent=nil, *args)
- @frame = TkFrame.new(parent)
- @path = @epath = @frame.path
- initialize_composite(*args)
- end
- def epath
- @epath
- end
-
- def initialize_composite(*args) end
- private :initialize_composite
-
- def delegate(option, *wins)
- unless @delegates
- @delegates = {}
- @delegates['DEFAULT'] = @frame
- end
- if @delegates[option].kind_of?(Array)
- for i in wins
- @delegates[option].push(i)
- end
- else
- @delegates[option] = wins
- end
- end
+# freeze core modules
+#TclTkLib.freeze
+#TclTkIp.freeze
+#TkUtil.freeze
+#TkKernel.freeze
+#TkComm.freeze
+#TkComm::Event.freeze
+#TkCore.freeze
+#Tk.freeze
- def configure(slot, value=None)
- if slot.kind_of? Hash
- slot.each{|slot,value| configure slot, value}
- else
- if @delegates and @delegates[slot]
- for i in @delegates[slot]
- if not i
- i = @delegates['DEFALUT']
- redo
- else
- last = i.configure(slot, value)
- end
- end
- last
- else
- super
- end
- end
- end
+module Tk
+ autoload :AUTO_PATH, 'tk/variable'
+ autoload :TCL_PACKAGE_PATH, 'tk/variable'
+ autoload :PACKAGE_PATH, 'tk/variable'
+ autoload :TCL_LIBRARY_PATH, 'tk/variable'
+ autoload :LIBRARY_PATH, 'tk/variable'
+ autoload :TCL_PRECISION, 'tk/variable'
end
-module TkClipboard
- include Tk
- extend Tk
-
- def clear
- tk_call 'clipboard', 'clear'
- end
- def get
- begin
- tk_call 'selection', 'get', '-selection', 'CLIPBOARD'
- rescue
- ''
- end
- end
- def set(data)
- clear
- append(data)
- end
- def append(data)
- tk_call 'clipboard', 'append', data
- end
- module_function :clear, :set, :get, :append
+# call setup script for Tk extension libraries (base configuration)
+begin
+ require 'tkextlib/setup.rb'
+rescue LoadError
+ # ignore
end
-
-autoload :TkCanvas, 'tkcanvas'
-autoload :TkImage, 'tkcanvas'
-autoload :TkBitmapImage, 'tkcanvas'
-autoload :TkPhotoImage, 'tkcanvas'
-autoload :TkEntry, 'tkentry'
-autoload :TkSpinbox, 'tkentry'
-autoload :TkText, 'tktext'
-autoload :TkDialog, 'tkdialog'
-autoload :TkWarning, 'tkdialog'
-autoload :TkMenubar, 'tkmenubar'
-autoload :TkAfter, 'tkafter'
-autoload :TkPalette, 'tkpalette'
-autoload :TkFont, 'tkfont'
-autoload :TkVirtualEvent, 'tkvirtevent'
-autoload :TkBgError, 'tkbgerror'
-autoload :TkManageFocus, 'tkmngfocus'
-autoload :TkPalette, 'tkpalette'
-autoload :TkWinDDE, 'tkwinpkg'
-autoload :TkWinRegistry, 'tkwinpkg'
-autoload :TkMacResource, 'tkmacpkg'
diff --git a/ext/tk/lib/tk/after.rb b/ext/tk/lib/tk/after.rb
new file mode 100644
index 0000000000..8c58210331
--- /dev/null
+++ b/ext/tk/lib/tk/after.rb
@@ -0,0 +1,6 @@
+#
+# tk/after.rb : methods for Tcl/Tk after command
+#
+# $Id$
+#
+require 'tk/timer'
diff --git a/ext/tk/lib/tk/autoload.rb b/ext/tk/lib/tk/autoload.rb
new file mode 100644
index 0000000000..3006b559d6
--- /dev/null
+++ b/ext/tk/lib/tk/autoload.rb
@@ -0,0 +1,192 @@
+#
+# autoload
+#
+
+#######################
+# geometry manager
+autoload :TkGrid, 'tk/grid'
+def TkGrid(*args); TkGrid.configure(*args); end
+
+autoload :TkPack, 'tk/pack'
+def TkPack(*args); TkPack.configure(*args); end
+
+autoload :TkPlace, 'tk/place'
+def TkPlace(*args); TkPlace.configure(*args); end
+
+
+#######################
+# others
+autoload :TkBgError, 'tk/bgerror'
+
+autoload :TkBindTag, 'tk/bindtag'
+autoload :TkBindTagAll, 'tk/bindtag'
+autoload :TkDatabaseClass, 'tk/bindtag'
+
+autoload :TkButton, 'tk/button'
+
+autoload :TkConsole, 'tk/console'
+
+autoload :TkCanvas, 'tk/canvas'
+
+autoload :TkcTagAccess, 'tk/canvastag'
+autoload :TkcTag, 'tk/canvastag'
+autoload :TkcTagString, 'tk/canvastag'
+autoload :TkcNamedTag, 'tk/canvastag'
+autoload :TkcTagAll, 'tk/canvastag'
+autoload :TkcTagCurrent, 'tk/canvastag'
+autoload :TkcTagGroup, 'tk/canvastag'
+
+autoload :TkCheckButton, 'tk/checkbutton'
+autoload :TkCheckbutton, 'tk/checkbutton'
+
+autoload :TkClipboard, 'tk/clipboard'
+
+autoload :TkComposite, 'tk/composite'
+
+autoload :TkConsole, 'tk/console'
+
+autoload :TkDialog, 'tk/dialog'
+autoload :TkDialog2, 'tk/dialog'
+autoload :TkWarning, 'tk/dialog'
+autoload :TkWarning2, 'tk/dialog'
+
+autoload :TkEntry, 'tk/entry'
+
+autoload :TkEvent, 'tk/event'
+
+autoload :TkFont, 'tk/font'
+autoload :TkTreatTagFont, 'tk/font'
+
+autoload :TkFrame, 'tk/frame'
+
+autoload :TkImage, 'tk/image'
+autoload :TkBitmapImage, 'tk/image'
+autoload :TkPhotoImage, 'tk/image'
+
+autoload :TkItemConfigMethod, 'tk/itemconfig'
+
+autoload :TkTreatItemFont, 'tk/itemfont'
+
+autoload :TkKinput, 'tk/kinput'
+
+autoload :TkLabel, 'tk/label'
+
+autoload :TkLabelFrame, 'tk/labelframe'
+autoload :TkLabelframe, 'tk/labelframe'
+
+autoload :TkListbox, 'tk/listbox'
+
+autoload :TkMacResource, 'tk/macpkg'
+
+autoload :TkMenu, 'tk/menu'
+autoload :TkMenuClone, 'tk/menu'
+autoload :TkSystemMenu, 'tk/menu'
+autoload :TkSysMenu_Help, 'tk/menu'
+autoload :TkSysMenu_System, 'tk/menu'
+autoload :TkSysMenu_Apple, 'tk/menu'
+autoload :TkMenubutton, 'tk/menu'
+autoload :TkOptionMenubutton, 'tk/menu'
+
+autoload :TkMenubar, 'tk/menubar'
+
+autoload :TkMenuSpec, 'tk/menuspec'
+
+autoload :TkMessage, 'tk/message'
+
+autoload :TkManageFocus, 'tk/mngfocus'
+
+autoload :TkMsgCatalog, 'tk/msgcat'
+autoload :TkMsgCat, 'tk/msgcat'
+
+autoload :TkNamespace, 'tk/namespace'
+
+autoload :TkOptionDB, 'tk/optiondb'
+autoload :TkOption, 'tk/optiondb'
+autoload :TkResourceDB, 'tk/optiondb'
+
+autoload :TkPackage, 'tk/package'
+
+autoload :TkPalette, 'tk/palette'
+
+autoload :TkPanedWindow, 'tk/panedwindow'
+autoload :TkPanedwindow, 'tk/panedwindow'
+
+autoload :TkRadioButton, 'tk/radiobutton'
+autoload :TkRadiobutton, 'tk/radiobutton'
+
+autoload :TkRoot, 'tk/root'
+
+autoload :TkScale, 'tk/scale'
+
+autoload :TkScrollbar, 'tk/scrollbar'
+autoload :TkXScrollbar, 'tk/scrollbar'
+autoload :TkYScrollbar, 'tk/scrollbar'
+
+autoload :TkScrollbox, 'tk/scrollbox'
+
+autoload :TkSelection, 'tk/selection'
+
+autoload :TkSpinbox, 'tk/spinbox'
+
+autoload :TkTreatTagFont, 'tk/tagfont'
+
+autoload :TkText, 'tk/text'
+
+autoload :TkTextImage, 'tk/textimage'
+
+autoload :TkTextMark, 'tk/textmark'
+autoload :TkTextNamedMark, 'tk/textmark'
+autoload :TkTextMarkInsert, 'tk/textmark'
+autoload :TkTextMarkCurrent, 'tk/textmark'
+autoload :TkTextMarkAnchor, 'tk/textmark'
+
+autoload :TkTextTag, 'tk/texttag'
+autoload :TkTextNamedTag, 'tk/texttag'
+autoload :TkTextTagSel, 'tk/texttag'
+
+autoload :TkTextWindow, 'tk/textwindow'
+
+autoload :TkAfter, 'tk/timer'
+autoload :TkTimer, 'tk/timer'
+
+autoload :TkToplevel, 'tk/toplevel'
+
+autoload :TkTextWin, 'tk/txtwin_abst'
+
+autoload :TkValidation, 'tk/validation'
+
+autoload :TkVariable, 'tk/variable'
+autoload :TkVarAccess, 'tk/variable'
+
+autoload :TkVirtualEvent, 'tk/virtevent'
+
+autoload :TkWinfo, 'tk/winfo'
+
+autoload :TkWinDDE, 'tk/winpkg'
+autoload :TkWinRegistry, 'tk/winpkg'
+
+autoload :TkXIM, 'tk/xim'
+
+
+#######################
+# sub-module of Tk
+module Tk
+ autoload :Clock, 'tk/clock'
+ autoload :OptionObj, 'tk/optionobj'
+ autoload :X_Scrollable, 'tk/scrollable'
+ autoload :Y_Scrollable, 'tk/scrollable'
+ autoload :Scrollable, 'tk/scrollable'
+ autoload :Wm, 'tk/wm'
+
+ autoload :ValidateConfigure, 'tk/validation'
+ autoload :ItemValidateConfigure, 'tk/validation'
+
+ autoload :EncodedString, 'tk/encodedstr'
+ def Tk.EncodedString(str, enc = nil); Tk::EncodedString.new(str, enc); end
+
+ autoload :BinaryString, 'tk/encodedstr'
+ def Tk.BinaryString(str); Tk::BinaryString.new(str); end
+
+ autoload :UTF8_String, 'tk/encodedstr'
+ def Tk.UTF8_String(str); Tk::UTF8_String.new(str); end
+end
diff --git a/ext/tk/lib/tk/bgerror.rb b/ext/tk/lib/tk/bgerror.rb
new file mode 100644
index 0000000000..c82a8e046b
--- /dev/null
+++ b/ext/tk/lib/tk/bgerror.rb
@@ -0,0 +1,29 @@
+#
+# tkbgerror -- bgerror ( tkerror ) module
+# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+module TkBgError
+ extend Tk
+
+ TkCommandNames = ['bgerror'.freeze].freeze
+
+ def bgerror(message)
+ tk_call('bgerror', message)
+ end
+ alias tkerror bgerror
+ alias show bgerror
+ module_function :bgerror, :tkerror, :show
+
+ def set_handler(hdlr = Proc.new) #==> handler :: proc{|msg| ...body... }
+ tk_call('proc', 'bgerror', 'msg', install_cmd(hdlr) + ' $msg')
+ end
+ def set_default
+ begin
+ tk_call('rename', 'bgerror', '')
+ rescue RuntimeError
+ end
+ end
+ module_function :set_handler, :set_default
+end
diff --git a/ext/tk/lib/tk/bindtag.rb b/ext/tk/lib/tk/bindtag.rb
new file mode 100644
index 0000000000..adf96b9e3d
--- /dev/null
+++ b/ext/tk/lib/tk/bindtag.rb
@@ -0,0 +1,79 @@
+#
+# tk/bind.rb : control event binding
+#
+require 'tk'
+
+class TkBindTag
+ include TkBindCore
+
+ #BTagID_TBL = {}
+ BTagID_TBL = TkCore::INTERP.create_table
+ Tk_BINDTAG_ID = ["btag".freeze, "00000".taint].freeze
+
+ TkCore::INTERP.init_ip_env{ BTagID_TBL.clear }
+
+ def TkBindTag.id2obj(id)
+ BTagID_TBL[id]? BTagID_TBL[id]: id
+ end
+
+ def TkBindTag.new_by_name(name, *args, &b)
+ return BTagID_TBL[name] if BTagID_TBL[name]
+ self.new(*args, &b).instance_eval{
+ BTagID_TBL.delete @id
+ @id = name
+ BTagID_TBL[@id] = self
+ }
+ end
+
+ def initialize(*args, &b)
+ # @id = Tk_BINDTAG_ID.join('')
+ @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_)
+ Tk_BINDTAG_ID[1].succ!
+ BTagID_TBL[@id] = self
+ bind(*args, &b) if args != []
+ end
+
+ ALL = self.new_by_name('all')
+
+ def name
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def inspect
+ #Kernel.format "#<TkBindTag: %s>", @id
+ '#<TkBindTag: ' + @id + '>'
+ end
+end
+
+
+class TkBindTagAll<TkBindTag
+ def TkBindTagAll.new(*args, &b)
+ $stderr.puts "Warning: TkBindTagALL is obsolete. Use TkBindTag::ALL\n"
+
+ TkBindTag::ALL.bind(*args, &b) if args != []
+ TkBindTag::ALL
+ end
+end
+
+
+class TkDatabaseClass<TkBindTag
+ def self.new(name, *args, &b)
+ return BTagID_TBL[name] if BTagID_TBL[name]
+ super(name, *args, &b)
+ end
+
+ def initialize(name, *args, &b)
+ @id = name
+ BTagID_TBL[@id] = self
+ bind(*args, &b) if args != []
+ end
+
+ def inspect
+ #Kernel.format "#<TkDatabaseClass: %s>", @id
+ '#<TkDatabaseClass: ' + @id + '>'
+ end
+end
diff --git a/ext/tk/lib/tk/button.rb b/ext/tk/lib/tk/button.rb
new file mode 100644
index 0000000000..407a47c400
--- /dev/null
+++ b/ext/tk/lib/tk/button.rb
@@ -0,0 +1,27 @@
+#
+# tk/button.rb : treat button widget
+#
+require 'tk'
+require 'tk/label'
+
+class TkButton<TkLabel
+ TkCommandNames = ['button'.freeze].freeze
+ WidgetClassName = 'Button'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('button', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('button', @path)
+ # end
+ #end
+ #private :create_self
+
+ def invoke
+ _fromUTF8(tk_send_without_enc('invoke'))
+ end
+ def flash
+ tk_send_without_enc('flash')
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb
new file mode 100644
index 0000000000..1a8a7927d3
--- /dev/null
+++ b/ext/tk/lib/tk/canvas.rb
@@ -0,0 +1,701 @@
+#
+# tk/canvas.rb - Tk canvas classes
+# $Date$
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+#
+require 'tk'
+require 'tk/canvastag'
+require 'tk/itemconfig'
+require 'tk/scrollable'
+
+module TkCanvasItemConfig
+ include TkItemConfigMethod
+
+ def __item_methodcall_optkeys(id)
+ {'coords'=>'coords'}
+ end
+ private :__item_methodcall_optkeys
+
+ def __item_pathname(tagOrId)
+ if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag)
+ self.path + ';' + tagOrId.id.to_s
+ else
+ self.path + ';' + tagOrId.to_s
+ end
+ end
+ private :__item_pathname
+end
+
+class TkCanvas<TkWindow
+ include TkCanvasItemConfig
+ include Scrollable
+
+ TkCommandNames = ['canvas'.freeze].freeze
+ WidgetClassName = 'Canvas'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def __destroy_hook__
+ TkcItem::CItemID_TBL.delete(@path)
+ end
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('canvas', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('canvas', @path)
+ # end
+ #end
+ #private :create_self
+
+ def tagid(tag)
+ if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
+ tag.id
+ else
+ tag # maybe an Array of configure paramters
+ end
+ end
+ private :tagid
+
+
+ # create a canvas item without creating a TkcItem object
+ def create(type, *args)
+ type.create(self, *args)
+ end
+
+
+ def addtag(tag, mode, *args)
+ tk_send_without_enc('addtag', tagid(tag), mode, *args)
+ self
+ end
+ def addtag_above(tagOrId, target)
+ addtag(tagOrId, 'above', tagid(target))
+ end
+ def addtag_all(tagOrId)
+ addtag(tagOrId, 'all')
+ end
+ def addtag_below(tagOrId, target)
+ addtag(tagOrId, 'below', tagid(target))
+ end
+ def addtag_closest(tagOrId, x, y, halo=None, start=None)
+ addtag(tagOrId, 'closest', x, y, halo, start)
+ end
+ def addtag_enclosed(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
+ end
+ def addtag_overlapping(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
+ end
+ def addtag_withtag(tagOrId, tag)
+ addtag(tagOrId, 'withtag', tagid(tag))
+ end
+
+ def bbox(tagOrId, *tags)
+ list(tk_send_without_enc('bbox', tagid(tagOrId),
+ *tags.collect{|t| tagid(t)}))
+ end
+
+ def itembind(tag, context, cmd=Proc.new, args=nil)
+ _bind([path, "bind", tagid(tag)], context, cmd, args)
+ self
+ end
+
+ def itembind_append(tag, context, cmd=Proc.new, args=nil)
+ _bind_append([path, "bind", tagid(tag)], context, cmd, args)
+ self
+ end
+
+ def itembind_remove(tag, context)
+ _bind_remove([path, "bind", tagid(tag)], context)
+ self
+ end
+
+ def itembindinfo(tag, context=nil)
+ _bindinfo([path, "bind", tagid(tag)], context)
+ end
+
+ def canvasx(screen_x, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args))
+ number(tk_send_without_enc('canvasx', screen_x, *args))
+ end
+ def canvasy(screen_y, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
+ number(tk_send_without_enc('canvasy', screen_y, *args))
+ end
+
+ def coords(tag, *args)
+ if args == []
+ tk_split_list(tk_send_without_enc('coords', tagid(tag)))
+ else
+ tk_send_without_enc('coords', tagid(tag), *(args.flatten))
+ self
+ end
+ end
+
+ def dchars(tag, first, last=None)
+ tk_send_without_enc('dchars', tagid(tag),
+ _get_eval_enc_str(first), _get_eval_enc_str(last))
+ self
+ end
+
+ def delete(*args)
+ if TkcItem::CItemID_TBL[self.path]
+ find('withtag', *args).each{|item|
+ TkcItem::CItemID_TBL[self.path].delete(item.id)
+ }
+ end
+ tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
+ self
+ end
+ alias remove delete
+
+ def dtag(tag, tag_to_del=None)
+ tk_send_without_enc('dtag', tagid(tag), tag_to_del)
+ self
+ end
+
+ def find(mode, *args)
+ list(tk_send_without_enc('find', mode, *args)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+ def find_above(target)
+ find('above', tagid(target))
+ end
+ def find_all
+ find('all')
+ end
+ def find_below(target)
+ find('below', tagid(target))
+ end
+ def find_closest(x, y, halo=None, start=None)
+ find('closest', x, y, halo, start)
+ end
+ def find_enclosed(x1, y1, x2, y2)
+ find('enclosed', x1, y1, x2, y2)
+ end
+ def find_overlapping(x1, y1, x2, y2)
+ find('overlapping', x1, y1, x2, y2)
+ end
+ def find_withtag(tag)
+ find('withtag', tag)
+ end
+
+ def itemfocus(tagOrId=nil)
+ if tagOrId
+ tk_send_without_enc('focus', tagid(tagOrId))
+ self
+ else
+ ret = tk_send_without_enc('focus')
+ if ret == ""
+ nil
+ else
+ TkcItem.id2obj(self, ret)
+ end
+ end
+ end
+
+ def gettags(tagOrId)
+ list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag|
+ TkcTag.id2obj(self, tag)
+ }
+ end
+
+ def icursor(tagOrId, index)
+ tk_send_without_enc('icursor', tagid(tagOrId), index)
+ self
+ end
+
+ def index(tagOrId, index)
+ number(tk_send_without_enc('index', tagid(tagOrId), index))
+ end
+
+ def insert(tagOrId, index, string)
+ tk_send_without_enc('insert', tagid(tagOrId), index,
+ _get_eval_enc_str(string))
+ self
+ end
+
+=begin
+ def itemcget(tagOrId, option)
+ case option.to_s
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}")
+ if conf =~ /^[0-9]/
+ list(conf)
+ else
+ conf
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ _fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('itemcget', tagid(tagOrId), "-#{option}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_with_enc('itemcget', tagid(tagOrId), '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(tagid(tagOrId), fnt)
+ end
+ if option.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
+ "-#{option}")))
+ end
+ end
+
+ def itemconfigure(tagOrId, key, value=None)
+ if key.kind_of? Hash
+ key = _symbolkey2str(key)
+ coords = key.delete('coords')
+ self.coords(tagOrId, coords) if coords
+
+ if ( key['font'] || key['kanjifont'] \
+ || key['latinfont'] || key['asciifont'] )
+ tagfont_configure(tagid(tagOrId), key.dup)
+ else
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
+ *hash_kv(key, true)))
+ end
+
+ else
+ if ( key == 'coords' || key == :coords )
+ self.coords(tagOrId, value)
+ elsif ( key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont )
+ if value == None
+ tagfontobj(tagid(tagOrId))
+ else
+ tagfont_configure(tagid(tagOrId), {key=>value})
+ end
+ else
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
+ "-#{key}", _get_eval_enc_str(value)))
+ end
+ end
+ self
+ end
+# def itemconfigure(tagOrId, key, value=None)
+# if key.kind_of? Hash
+# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(key)
+# else
+# tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
+# end
+# end
+# def itemconfigure(tagOrId, keys)
+# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(keys)
+# end
+
+ def itemconfiginfo(tagOrId, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'coords'
+ return ['coords', '', '', '', self.coords(tagOrId)]
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ when 'dash', 'activedash', 'disableddash'
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4])
+ ret.push(fontconf)
+ end
+
+ ret << ['coords', '', '', '', self.coords(tagOrId)]
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'coords'
+ {'coords' => ['', '', '', self.coords(tagOrId)]}
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
+ tagid(tagOrId),
+ "-#{key}"))
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ when 'dash', 'activedash', 'disableddash'
+ if conf[2] && conf[2] =~ /^[0-9]/
+ conf[2] = list(conf[2])
+ end
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3])
+ ret['font'] = fontconf
+ end
+
+ ret['coords'] = ['', '', '', self.coords(tagOrId)]
+
+ ret
+ end
+ end
+ end
+
+ def current_itemconfiginfo(tagOrId, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = itemconfiginfo(tagOrId, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ itemconfiginfo(tagOrId).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ itemconfiginfo(tagOrId, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+
+ def lower(tag, below=nil)
+ if below
+ tk_send_without_enc('lower', tagid(tag), tagid(below))
+ else
+ tk_send_without_enc('lower', tagid(tag))
+ end
+ self
+ end
+
+ def move(tag, x, y)
+ tk_send_without_enc('move', tagid(tag), x, y)
+ self
+ end
+
+ def postscript(keys)
+ tk_send("postscript", *hash_kv(keys))
+ end
+
+ def raise(tag, above=nil)
+ if above
+ tk_send_without_enc('raise', tagid(tag), tagid(above))
+ else
+ tk_send_without_enc('raise', tagid(tag))
+ end
+ self
+ end
+
+ def scale(tag, x, y, xs, ys)
+ tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def select(mode, *args)
+ r = tk_send_without_enc('select', mode, *args)
+ (mode == 'item')? TkcItem.id2obj(self, r): self
+ end
+ def select_adjust(tagOrId, index)
+ select('adjust', tagid(tagOrId), index)
+ end
+ def select_clear
+ select('clear')
+ end
+ def select_from(tagOrId, index)
+ select('from', tagid(tagOrId), index)
+ end
+ def select_item
+ select('item')
+ end
+ def select_to(tagOrId, index)
+ select('to', tagid(tagOrId), index)
+ end
+
+ def itemtype(tag)
+ TkcItem.type2class(tk_send('type', tagid(tag)))
+ end
+end
+
+class TkcItem<TkObject
+ extend Tk
+ include TkcTagAccess
+ extend TkItemFontOptkeys
+ extend TkItemConfigOptkeys
+
+ CItemTypeName = nil
+ CItemTypeToClass = {}
+ CItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{ CItemID_TBL.clear }
+
+ def TkcItem.type2class(type)
+ CItemTypeToClass[type]
+ end
+
+ def TkcItem.id2obj(canvas, id)
+ cpath = canvas.path
+ return id unless CItemID_TBL[cpath]
+ CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
+ end
+
+ ########################################
+ def self._parse_create_args(args)
+ fontkeys = {}
+ methodkeys = {}
+ if args[-1].kind_of? Hash
+ keys = _symbolkey2str(args.pop)
+ if args.size == 0
+ args = keys.delete('coords')
+ unless args.kind_of?(Array)
+ fail "coords parameter must be given by an Array"
+ end
+ end
+
+ #['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
+ # fontkeys[key] = keys.delete(key) if keys.key?(key)
+ #}
+ __item_font_optkeys(nil).each{|key|
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ }
+
+ __item_methodcall_optkeys(nil).each{|key|
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
+ }
+
+ #args = args.flatten.concat(hash_kv(keys))
+ args = args.flatten.concat(itemconfig_hash_kv(nil, keys))
+ else
+ args = args.flatten
+ end
+
+ [args, fontkeys]
+ end
+ private_class_method :_parse_create_args
+
+ def self.create(canvas, *args)
+ unless self::CItemTypeName
+ fail RuntimeError, "#{self} is an abstract class"
+ end
+ args, fontkeys = _parse_create_args(args)
+ idnum = tk_call_without_enc(canvas.path, 'create',
+ self::CItemTypeName, *args)
+ canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
+ idnum.to_i # 'canvas item id' is an integer number
+ end
+ ########################################
+
+ def initialize(parent, *args)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArguemntError, "expect TkCanvas for 1st argument"
+ #end
+ @parent = @c = parent
+ @path = parent.path
+
+ @id = create_self(*args) # an integer number as 'canvas item id'
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ end
+ def create_self(*args)
+ self.class.create(@c, *args) # return an integer number as 'canvas item id'
+ end
+ private :create_self
+
+ def id
+ @id
+ end
+
+ def exist?
+ if @c.find_withtag(@id)
+ true
+ else
+ false
+ end
+ end
+
+ def delete
+ @c.delete @id
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ self
+ end
+ alias remove delete
+ alias destroy delete
+end
+
+class TkcArc<TkcItem
+ CItemTypeName = 'arc'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcBitmap<TkcItem
+ CItemTypeName = 'bitmap'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcImage<TkcItem
+ CItemTypeName = 'image'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcLine<TkcItem
+ CItemTypeName = 'line'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcOval<TkcItem
+ CItemTypeName = 'oval'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcPolygon<TkcItem
+ CItemTypeName = 'polygon'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcRectangle<TkcItem
+ CItemTypeName = 'rectangle'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcText<TkcItem
+ CItemTypeName = 'text'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ def self.create(canvas, *args)
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ txt = keys['text']
+ keys['text'] = _get_eval_enc_str(txt) if txt
+ args.push(keys)
+ end
+ super(canvas, *args)
+ end
+end
+
+class TkcWindow<TkcItem
+ CItemTypeName = 'window'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ def self.create(canvas, *args)
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ win = keys['window']
+ # keys['window'] = win.epath if win.kind_of?(TkWindow)
+ keys['window'] = _epath(win) if win
+ args.push(keys)
+ end
+ super(canvas, *args)
+ end
+end
diff --git a/ext/tk/lib/tk/canvastag.rb b/ext/tk/lib/tk/canvastag.rb
new file mode 100644
index 0000000000..f27111bd84
--- /dev/null
+++ b/ext/tk/lib/tk/canvastag.rb
@@ -0,0 +1,351 @@
+#
+# tk/canvastag.rb - methods for treating canvas tags
+#
+require 'tk'
+require 'tk/tagfont'
+
+module TkcTagAccess
+ include TkComm
+ include TkTreatTagFont
+end
+
+require 'tk/canvas'
+
+module TkcTagAccess
+ def addtag(tag)
+ @c.addtag(tag, 'with', @id)
+ self
+ end
+
+ def bbox
+ @c.bbox(@id)
+ end
+
+ def bind(seq, cmd=Proc.new, args=nil)
+ @c.itembind @id, seq, cmd, args
+ self
+ end
+
+ def bind_append(seq, cmd=Proc.new, args=nil)
+ @c.itembind_append @id, seq, cmd, args
+ self
+ end
+
+ def bind_remove(seq)
+ @c.itembind_remove @id, seq
+ self
+ end
+
+ def bindinfo(seq=nil)
+ @c.itembindinfo @id, seq
+ end
+
+ def cget(option)
+ @c.itemcget @id, option
+ end
+
+ def configure(key, value=None)
+ @c.itemconfigure @id, key, value
+ self
+ end
+# def configure(keys)
+# @c.itemconfigure @id, keys
+# end
+
+ def configinfo(key=nil)
+ @c.itemconfiginfo @id, key
+ end
+
+ def current_configinfo(key=nil)
+ @c.current_itemconfiginfo @id, key
+ end
+
+ def coords(*args)
+ @c.coords @id, *args
+ end
+
+ def dchars(first, last=None)
+ @c.dchars @id, first, last
+ self
+ end
+
+ def dtag(tag_to_del=None)
+ @c.dtag @id, tag_to_del
+ self
+ end
+
+ def find
+ @c.find 'withtag', @id
+ end
+ alias list find
+
+ def focus
+ @c.itemfocus @id
+ end
+
+ def gettags
+ @c.gettags @id
+ end
+
+ def icursor(index)
+ @c.icursor @id, index
+ self
+ end
+
+ def index(index)
+ @c.index @id, index
+ end
+
+ def insert(beforethis, string)
+ @c.insert @id, beforethis, string
+ self
+ end
+
+ def lower(belowthis=None)
+ @c.lower @id, belowthis
+ self
+ end
+
+ def move(xamount, yamount)
+ @c.move @id, xamount, yamount
+ self
+ end
+
+ def raise(abovethis=None)
+ @c.raise @id, abovethis
+ self
+ end
+
+ def scale(xorigin, yorigin, xscale, yscale)
+ @c.scale @id, xorigin, yorigin, xscale, yscale
+ self
+ end
+
+ def select_adjust(index)
+ @c.select('adjust', @id, index)
+ self
+ end
+ def select_from(index)
+ @c.select('from', @id, index)
+ self
+ end
+ def select_to(index)
+ @c.select('to', @id, index)
+ self
+ end
+
+ def itemtype
+ @c.itemtype @id
+ end
+
+ # Following operators support logical expressions of canvas tags
+ # (for Tk8.3+).
+ # If tag1.path is 't1' and tag2.path is 't2', then
+ # ltag = tag1 & tag2; ltag.path => "(t1)&&(t2)"
+ # ltag = tag1 | tag2; ltag.path => "(t1)||(t2)"
+ # ltag = tag1 ^ tag2; ltag.path => "(t1)^(t2)"
+ # ltag = - tag1; ltag.path => "!(t1)"
+ def & (tag)
+ if tag.kind_of? TkObject
+ TkcTagString.new(@c, '(' + @id + ')&&(' + tag.path + ')')
+ else
+ TkcTagString.new(@c, '(' + @id + ')&&(' + tag.to_s + ')')
+ end
+ end
+
+ def | (tag)
+ if tag.kind_of? TkObject
+ TkcTagString.new(@c, '(' + @id + ')||(' + tag.path + ')')
+ else
+ TkcTagString.new(@c, '(' + @id + ')||(' + tag.to_s + ')')
+ end
+ end
+
+ def ^ (tag)
+ if tag.kind_of? TkObject
+ TkcTagString.new(@c, '(' + @id + ')^(' + tag.path + ')')
+ else
+ TkcTagString.new(@c, '(' + @id + ')^(' + tag.to_s + ')')
+ end
+ end
+
+ def -@
+ TkcTagString.new(@c, '!(' + @id + ')')
+ end
+end
+
+class TkcTag<TkObject
+ include TkcTagAccess
+
+ CTagID_TBL = TkCore::INTERP.create_table
+ Tk_CanvasTag_ID = ['ctag'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ CTagID_TBL.clear }
+
+ def TkcTag.id2obj(canvas, id)
+ cpath = canvas.path
+ return id unless CTagID_TBL[cpath]
+ CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
+ end
+
+ def initialize(parent, mode=nil, *args)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArguemntError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ # @path = @id = Tk_CanvasTag_ID.join('')
+ @path = @id = Tk_CanvasTag_ID.join(TkCore::INTERP._ip_id_)
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ Tk_CanvasTag_ID[1].succ!
+ if mode
+ tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
+ end
+ end
+ def id
+ @id
+ end
+
+ def exist?
+ if @c.find_withtag(@id)
+ true
+ else
+ false
+ end
+ end
+
+ def delete
+ @c.delete @id
+ CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
+ self
+ end
+ alias remove delete
+ alias destroy delete
+
+ def set_to_above(target)
+ @c.addtag_above(@id, target)
+ self
+ end
+ alias above set_to_above
+
+ def set_to_all
+ @c.addtag_all(@id)
+ self
+ end
+ alias all set_to_all
+
+ def set_to_below(target)
+ @c.addtag_below(@id, target)
+ self
+ end
+ alias below set_to_below
+
+ def set_to_closest(x, y, halo=None, start=None)
+ @c.addtag_closest(@id, x, y, halo, start)
+ self
+ end
+ alias closest set_to_closest
+
+ def set_to_enclosed(x1, y1, x2, y2)
+ @c.addtag_enclosed(@id, x1, y1, x2, y2)
+ self
+ end
+ alias enclosed set_to_enclosed
+
+ def set_to_overlapping(x1, y1, x2, y2)
+ @c.addtag_overlapping(@id, x1, y1, x2, y2)
+ self
+ end
+ alias overlapping set_to_overlapping
+
+ def set_to_withtag(target)
+ @c.addtag_withtag(@id, target)
+ self
+ end
+ alias withtag set_to_withtag
+end
+
+class TkcTagString<TkcTag
+ def self.new(parent, name, *args)
+ if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name]
+ return CTagID_TBL[parent.path][name]
+ else
+ super(parent, name, *args)
+ end
+ end
+
+ def initialize(parent, name, mode=nil, *args)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArguemntError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ @path = @id = name
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ if mode
+ tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
+ end
+ end
+end
+TkcNamedTag = TkcTagString
+
+class TkcTagAll<TkcTag
+ def initialize(parent)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArguemntError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ @path = @id = 'all'
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ end
+end
+
+class TkcTagCurrent<TkcTag
+ def initialize(parent)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArguemntError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ @path = @id = 'current'
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ end
+end
+
+class TkcGroup<TkcTag
+ Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint].freeze
+ #def create_self(parent, *args)
+ def initialize(parent, *args)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArguemntError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ # @path = @id = Tk_cGroup_ID.join('')
+ @path = @id = Tk_cGroup_ID.join(TkCore::INTERP._ip_id_)
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ Tk_cGroup_ID[1].succ!
+ add(*args) if args != []
+ end
+ #private :create_self
+
+ def include(*tags)
+ for i in tags
+ i.addtag @id
+ end
+ self
+ end
+
+ def exclude(*tags)
+ for i in tags
+ i.delete @id
+ end
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/checkbutton.rb b/ext/tk/lib/tk/checkbutton.rb
new file mode 100644
index 0000000000..d76d99c0f2
--- /dev/null
+++ b/ext/tk/lib/tk/checkbutton.rb
@@ -0,0 +1,25 @@
+#
+# tk/checkbutton.rb : treat checkbutton widget
+#
+require 'tk'
+require 'tk/radiobutton'
+
+class TkCheckButton<TkRadioButton
+ TkCommandNames = ['checkbutton'.freeze].freeze
+ WidgetClassName = 'Checkbutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('checkbutton', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('checkbutton', @path)
+ # end
+ #end
+ #private :create_self
+
+ def toggle
+ tk_send_without_enc('toggle')
+ self
+ end
+end
+TkCheckbutton = TkCheckButton
diff --git a/ext/tk/lib/tk/clipboard.rb b/ext/tk/lib/tk/clipboard.rb
new file mode 100644
index 0000000000..d4205a5c28
--- /dev/null
+++ b/ext/tk/lib/tk/clipboard.rb
@@ -0,0 +1,75 @@
+#
+# tk/clipboard.rb : methods to treat clipboard
+#
+require 'tk'
+
+module TkClipboard
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['clipboard'.freeze].freeze
+
+ def self.clear(win=nil)
+ if win
+ tk_call_without_enc('clipboard', 'clear', '-displayof', win)
+ else
+ tk_call_without_enc('clipboard', 'clear')
+ end
+ end
+ def self.clear_on_display(win)
+ tk_call_without_enc('clipboard', 'clear', '-displayof', win)
+ end
+
+ def self.get(type=nil)
+ if type
+ tk_call_without_enc('clipboard', 'get', '-type', type)
+ else
+ tk_call_without_enc('clipboard', 'get')
+ end
+ end
+ def self.get_on_display(win, type=nil)
+ if type
+ tk_call_without_enc('clipboard', 'get', '-displayof', win, '-type', type)
+ else
+ tk_call_without_enc('clipboard', 'get', '-displayof', win)
+ end
+ end
+
+ def self.set(data, keys=nil)
+ clear
+ append(data, keys)
+ end
+ def self.set_on_display(win, data, keys=nil)
+ clear(win)
+ append_on_display(win, data, keys)
+ end
+
+ def self.append(data, keys=nil)
+ args = ['clipboard', 'append']
+ args.concat(hash_kv(keys))
+ args.concat(['--', data])
+ tk_call(*args)
+ end
+ def self.append_on_display(win, data, keys=nil)
+ args = ['clipboard', 'append', '-displayof', win]
+ args.concat(hash_kv(keys))
+ args.concat(['--', data])
+ tk_call(*args)
+ end
+
+ def clear
+ TkClipboard.clear_on_display(self)
+ self
+ end
+ def get(type=nil)
+ TkClipboard.get_on_display(self, type)
+ end
+ def set(data, keys=nil)
+ TkClipboard.set_on_display(self, data, keys)
+ self
+ end
+ def append(data, keys=nil)
+ TkClipboard.append_on_display(self, data, keys)
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/clock.rb b/ext/tk/lib/tk/clock.rb
new file mode 100644
index 0000000000..823b8a6341
--- /dev/null
+++ b/ext/tk/lib/tk/clock.rb
@@ -0,0 +1,57 @@
+#
+# tk/clock.rb : methods for clock command
+#
+require 'tk'
+
+module Tk
+ module Clock
+ def self.clicks(ms=nil)
+ case ms
+ when nil
+ tk_call_without_enc('clock','clicks').to_i
+ when /^mic/
+ tk_call_without_enc('clock','clicks','-microseconds').to_i
+ when /^mil/
+ tk_call_without_enc('clock','clicks','-milliseconds').to_i
+ else
+ tk_call_without_enc('clock','clicks','-milliseconds').to_i
+ end
+ end
+
+ def self.format(clk, form=nil)
+ if form
+ tk_call('clock','format',clk,'-format',form)
+ else
+ tk_call('clock','format',clk)
+ end
+ end
+
+ def self.formatGMT(clk, form=nil)
+ if form
+ tk_call('clock','format',clk,'-format',form,'-gmt','1')
+ else
+ tk_call('clock','format',clk,'-gmt','1')
+ end
+ end
+
+ def self.scan(str, base=nil)
+ if base
+ tk_call('clock','scan',str,'-base',base).to_i
+ else
+ tk_call('clock','scan',str).to_i
+ end
+ end
+
+ def self.scanGMT(str, base=nil)
+ if base
+ tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
+ else
+ tk_call('clock','scan',str,'-gmt','1').to_i
+ end
+ end
+
+ def self.seconds
+ tk_call_without_enc('clock','seconds').to_i
+ end
+ end
+end
diff --git a/ext/tk/lib/tk/composite.rb b/ext/tk/lib/tk/composite.rb
new file mode 100644
index 0000000000..d85b815dd7
--- /dev/null
+++ b/ext/tk/lib/tk/composite.rb
@@ -0,0 +1,293 @@
+#
+# tk/composite.rb :
+#
+require 'tk'
+
+module TkComposite
+ include Tk
+ extend Tk
+
+ def initialize(parent=nil, *args)
+ @delegates = {}
+ @option_methods = {}
+ @option_setting = {}
+
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ @frame = TkFrame.new(parent)
+ @path = @epath = @frame.path
+ initialize_composite(keys)
+ else
+ @frame = TkFrame.new(parent)
+ @path = @epath = @frame.path
+ initialize_composite(*args)
+ end
+ end
+
+ def epath
+ @epath
+ end
+
+ def initialize_composite(*args) end
+ private :initialize_composite
+
+ def option_methods(*opts)
+ opts.each{|m_set, m_cget, m_info|
+ m_set = m_set.to_s
+ m_cget = m_set if !m_cget && self.method(m_set).arity == -1
+ m_cget = m_cget.to_s if m_cget
+ m_info = m_info.to_s if m_info
+ @option_methods[m_set] = {
+ :set => m_set, :cget => m_cget, :info => m_info
+ }
+ }
+ end
+
+ def delegate_alias(alias_opt, option, *wins)
+ if wins.length == 0
+ fail ArgumentError, "target widgets are not given"
+ end
+ if alias_opt != option && (alias_opt == 'DEFAULT' || option == 'DEFAULT')
+ fail ArgumentError, "cannot alias 'DEFAULT' option"
+ end
+ alias_opt = alias_opt.to_s
+ option = option.to_s
+ if @delegates[alias_opt].kind_of?(Array)
+ if (elem = @delegates[alias_opt].assoc(option))
+ wins.each{|w| elem[1].push(w)}
+ else
+ @delegates[alias_opt] << [option, wins]
+ end
+ else
+ @delegates[alias_opt] = [ [option, wins] ]
+ end
+ end
+
+ def delegate(option, *wins)
+ delegate_alias(option, option, *wins)
+ end
+
+ def cget(slot)
+ slot = slot.to_s
+
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:cget]
+ return self.__send__(@option_methods[slot][:cget])
+ else
+ if @option_setting[slot]
+ return @option_setting[slot]
+ else
+ return ''
+ end
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ opt, wins = tbl[-1]
+ opt = slot if opt == 'DEFAULT'
+ if wins && wins[-1]
+ return wins[-1].cget(opt)
+ end
+ end
+ rescue
+ end
+
+ super
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of? Hash
+ slot.each{|slot,value| configure slot, value}
+ return self
+ end
+
+ slot = slot.to_s
+
+ if @option_methods.include?(slot)
+ unless @option_methods[slot][:cget]
+ if value.kind_of?(Symbol)
+ @option_setting[slot] = value.to_s
+ else
+ @option_setting[slot] = value
+ end
+ end
+ return self.__send__(@option_methods[slot][:set], value)
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ last = nil
+ tbl.each{|opt, wins|
+ opt = slot if opt == 'DEFAULT'
+ wins.each{|w| last = w.configure(opt, value)}
+ }
+ return last
+ end
+ rescue
+ end
+
+ super
+ end
+
+ def configinfo(slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ slot = slot.to_s
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:info]
+ return self.__send__(@option_methods[slot][:info])
+ else
+ return [slot, '', '', '', self.cget(slot)]
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ if slot == opt || opt == 'DEFAULT'
+ return wins[-1].configinfo(slot)
+ else
+ info = wins[-1].configinfo(opt)
+ info[0] = slot
+ return info
+ end
+ else
+ opt, wins = tbl[-1]
+ return [slot, '', '', '', wins[-1].cget(opt)]
+ end
+ end
+ rescue
+ end
+
+ super
+
+ else # slot == nil
+ info_list = super
+
+ tbl = @delegates['DEFAULT']
+ if tbl
+ wins = tbl[0][1]
+ if wins && wins[-1]
+ wins[-1].configinfo.each{|info|
+ slot = info[0]
+ info_list.delete_if{|i| i[0] == slot} << info
+ }
+ end
+ end
+
+ @delegates.each{|slot, tbl|
+ next if slot == 'DEFAULT'
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ next unless wins && wins[-1]
+ if slot == opt
+ info_list.delete_if{|i| i[0] == slot} <<
+ wins[-1].configinfo(slot)
+ else
+ info = wins[-1].configinfo(opt)
+ info[0] = slot
+ info_list.delete_if{|i| i[0] == slot} << info
+ end
+ else
+ opt, wins = tbl[-1]
+ info_list.delete_if{|i| i[0] == slot} <<
+ [slot, '', '', '', wins[-1].cget(opt)]
+ end
+ }
+
+ @option_methods.each{|slot, m|
+ if m[:info]
+ info = self.__send__(m[:info])
+ else
+ info = [slot, '', '', '', self.cget(slot)]
+ end
+ info_list.delete_if{|i| i[0] == slot} << info
+ }
+
+ info_list
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ slot = slot.to_s
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:info]
+ return self.__send__(@option_methods[slot][:info])
+ else
+ return {slot => ['', '', '', self.cget(slot)]}
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ if slot == opt || opt == 'DEFAULT'
+ return wins[-1].configinfo(slot)
+ else
+ return {slot => wins[-1].configinfo(opt)[opt]}
+ end
+ else
+ opt, wins = tbl[-1]
+ return {slot => ['', '', '', wins[-1].cget(opt)]}
+ end
+ end
+ rescue
+ end
+
+ super
+
+ else # slot == nil
+ info_list = super
+
+ tbl = @delegates['DEFAULT']
+ if tbl
+ wins = tbl[0][1]
+ info_list.update(wins[-1].configinfo) if wins && wins[-1]
+ end
+
+ @delegates.each{|slot, tbl|
+ next if slot == 'DEFAULT'
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ next unless wins && wins[-1]
+ if slot == opt
+ info_list.update(wins[-1].configinfo(slot))
+ else
+ info_list.update({slot => wins[-1].configinfo(opt)[opt]})
+ end
+ else
+ opt, wins = tbl[-1]
+ info_list.update({slot => ['', '', '', wins[-1].cget(opt)]})
+ end
+ }
+
+ @option_methods.each{|slot, m|
+ if m[:info]
+ info = self.__send__(m[:info])
+ else
+ info = {slot => ['', '', '', self.cget(slot)]}
+ end
+ info_list.update(info)
+ }
+
+ info_list
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tk/console.rb b/ext/tk/lib/tk/console.rb
new file mode 100644
index 0000000000..f0d2c7aa87
--- /dev/null
+++ b/ext/tk/lib/tk/console.rb
@@ -0,0 +1,29 @@
+#
+# tk/console.rb : control the console on system without a real console
+#
+require 'tk'
+
+module TkConsole
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['console'.freeze].freeze
+
+ def self.title(str=None)
+ tk_call 'console', str
+ end
+ def self.hide
+ tk_call_without_enc('console', 'hide')
+ end
+ def self.show
+ tk_call_without_enc('console', 'show')
+ end
+ def self.eval(tcl_script)
+ #
+ # supports a Tcl script only
+ # I have no idea to support a Ruby script seamlessly.
+ #
+ _fromUTF8(tk_call_without_enc('console', 'eval',
+ _get_eval_enc_str(tcl_script)))
+ end
+end
diff --git a/ext/tk/lib/tk/dialog.rb b/ext/tk/lib/tk/dialog.rb
new file mode 100644
index 0000000000..2ced26b193
--- /dev/null
+++ b/ext/tk/lib/tk/dialog.rb
@@ -0,0 +1,293 @@
+#
+# tk/dialog.rb : create dialog boxes
+#
+require 'tk'
+
+class TkDialog2 < TkWindow
+ extend Tk
+
+ TkCommandNames = ['tk_dialog'.freeze].freeze
+
+ def self.show(*args)
+ dlog = self.new(*args)
+ dlog.show
+ dlog
+ end
+
+ def _set_button_config(configs)
+ set_config = proc{|c,i|
+ if $VERBOSE && (c.has_key?('command') || c.has_key?(:command))
+ STDERR.print("Warning: cannot give a command option " +
+ "to the dialog button#{i}. It was removed.\n")
+ end
+ c.delete('command'); c.delete(:command)
+ # @config << Kernel.format("%s.button%s configure %s; ",
+ # @path, i, hash_kv(c).join(' '))
+ @config << @path+'.button'+i.to_s+'configure '+hash_kv(c).join(' ')+'; '
+ }
+ case configs
+ when Proc
+ @buttons.each_index{|i|
+ if (c = configs.call(i)).kind_of? Hash
+ set_config.call(c,i)
+ end
+ }
+
+ when Array
+ @buttons.each_index{|i|
+ if (c = configs[i]).kind_of? Hash
+ set_config.call(c,i)
+ end
+ }
+
+ when Hash
+ @buttons.each_with_index{|s,i|
+ if (c = configs[s]).kind_of? Hash
+ set_config.call(c,i)
+ end
+ }
+ end
+ @config = 'after idle {' + @config + '};' if @config != ""
+ end
+ private :_set_button_config
+
+ # initialize tk_dialog
+ def create_self(keys)
+ #@var = TkVariable.new
+ @val = nil
+
+ @title = title
+
+ @message = message
+ @message_config = message_config
+ @msgframe_config = msgframe_config
+
+ @bitmap = bitmap
+ @bitmap_config = message_config
+
+ @default_button = default_button
+
+ @buttons = buttons
+ @button_configs = proc{|num| button_configs(num)}
+ @btnframe_config = btnframe_config
+
+ #@config = "puts [winfo children .w0000];"
+ @config = ""
+
+ @command = nil
+
+ if keys.kind_of? Hash
+ @title = keys['title'] if keys.key? 'title'
+ @message = keys['message'] if keys.key? 'message'
+ @bitmap = keys['bitmap'] if keys.key? 'bitmap'
+ @bitmap = '{}' if @bitmap == nil || @bitmap == ""
+ @default_button = keys['default'] if keys.key? 'default'
+ @buttons = keys['buttons'] if keys.key? 'buttons'
+
+ @command = keys['prev_command']
+
+ @message_config = keys['message_config'] if keys.key? 'message_config'
+ @msgframe_config = keys['msgframe_config'] if keys.key? 'msgframe_config'
+ @bitmap_config = keys['bitmap_config'] if keys.key? 'bitmap_config'
+ @button_configs = keys['button_configs'] if keys.key? 'button_configs'
+ @btnframe_config = keys['btnframe_config'] if keys.key? 'btnframe_config'
+ end
+
+ if @title.include? ?\s
+ @title = '{' + @title + '}'
+ end
+
+ if @buttons.kind_of? Array
+ _set_button_config(@buttons.collect{|cfg|
+ (cfg.kind_of? Array)? cfg[1]: nil})
+ @buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg}
+ end
+ if @buttons.kind_of? Hash
+ _set_button_config(@buttons)
+ @buttons = @buttons.keys
+ end
+ @buttons = tk_split_simplelist(@buttons) if @buttons.kind_of? String
+ @buttons = @buttons.collect{|s|
+ if s.kind_of? Array
+ s = s.join(' ')
+ end
+ if s.include? ?\s
+ '{' + s + '}'
+ else
+ s
+ end
+ }
+
+ if @message_config.kind_of? Hash
+ # @config << Kernel.format("%s.msg configure %s;",
+ # @path, hash_kv(@message_config).join(' '))
+ @config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';'
+ end
+
+ if @msgframe_config.kind_of? Hash
+ # @config << Kernel.format("%s.top configure %s;",
+ # @path, hash_kv(@msgframe_config).join(' '))
+ @config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';'
+ end
+
+ if @btnframe_config.kind_of? Hash
+ # @config << Kernel.format("%s.bot configure %s;",
+ # @path, hash_kv(@btnframe_config).join(' '))
+ @config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';'
+ end
+
+ if @bitmap_config.kind_of? Hash
+ # @config << Kernel.format("%s.bitmap configure %s;",
+ # @path, hash_kv(@bitmap_config).join(' '))
+ @config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';'
+ end
+
+ _set_button_config(@button_configs) if @button_configs
+
+ if @command.kind_of? Proc
+ @command.call(self)
+ end
+ end
+ private :create_self
+
+ def show
+ if @default_button.kind_of? String
+ default_button = @buttons.index(@default_button)
+ else
+ default_button = @default_button
+ end
+ default_button = '{}' if default_button == nil
+ #Tk.ip_eval('eval {global '+@var.id+';'+@config+
+ # 'set '+@var.id+' [tk_dialog '+
+ # @path+" "+@title+" {#{@message}} "+@bitmap+" "+
+ # String(default_button)+" "+@buttons.join(' ')+']}')
+ Tk.ip_eval(@config)
+ # @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
+ # ' {' + @message + '} ' + @bitmap + ' ' +
+ # String(default_button) + ' ' + @buttons.join(' ')).to_i
+ @val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
+ @title + ' {' + @message + '} ' + @bitmap + ' ' +
+ String(default_button) + ' ' + @buttons.join(' ')).to_i
+ end
+
+ def value
+ # @var.value.to_i
+ @val
+ end
+ ######################################################
+ # #
+ # these methods must be overridden for each dialog #
+ # #
+ ######################################################
+ private
+
+ def title
+ # returns a title string of the dialog window
+ return "DIALOG"
+ end
+ def message
+ # returns a message text to display on the dialog
+ return "MESSAGE"
+ end
+ def message_config
+ # returns a Hash {option=>value, ...} for the message text
+ return nil
+ end
+ def msgframe_config
+ # returns a Hash {option=>value, ...} for the message text frame
+ return nil
+ end
+ def bitmap
+ # returns a bitmap name or a bitmap file path
+ # (@ + path ; e.g. '@/usr/share/bitmap/sample.xbm')
+ return "info"
+ end
+ def bitmap_config
+ # returns nil or a Hash {option=>value, ...} for the bitmap
+ return nil
+ end
+ def default_button
+ # returns a default button's number or name
+ # if nil or null string, set no-default
+ return 0
+ end
+ def buttons
+ #return "BUTTON1 BUTTON2"
+ return ["BUTTON1", "BUTTON2"]
+ end
+ def button_configs(num)
+ # returns nil / Proc / Array or Hash (see _set_button_config)
+ return nil
+ end
+ def btnframe_config
+ # returns nil or a Hash {option=>value, ...} for the button frame
+ return nil
+ end
+end
+
+
+#
+# TkDialog : with showing at initialize
+#
+class TkDialog < TkDialog2
+ def self.show(*args)
+ self.new(*args)
+ end
+
+ def initialize(*args)
+ super(*args)
+ show
+ end
+end
+
+
+#
+# dialog for warning
+#
+class TkWarning2 < TkDialog2
+ def initialize(parent = nil, mes = nil)
+ if !mes
+ if parent.kind_of? TkWindow
+ mes = ""
+ else
+ mes = parent.to_s
+ parent = nil
+ end
+ end
+ super(parent, :message=>mes)
+ end
+
+ def show(mes = nil)
+ mes_bup = @message
+ @message = mes if mes
+ ret = super()
+ @message = mes_bup
+ ret
+ end
+
+ #######
+ private
+
+ def title
+ return "WARNING";
+ end
+ def bitmap
+ return "warning";
+ end
+ def default_button
+ return 0;
+ end
+ def buttons
+ return "OK";
+ end
+end
+
+class TkWarning < TkWarning2
+ def self.show(*args)
+ self.new(*args)
+ end
+ def initialize(*args)
+ super(*args)
+ show
+ end
+end
diff --git a/ext/tk/lib/tk/encodedstr.rb b/ext/tk/lib/tk/encodedstr.rb
new file mode 100644
index 0000000000..aed0e7524e
--- /dev/null
+++ b/ext/tk/lib/tk/encodedstr.rb
@@ -0,0 +1,107 @@
+#
+# tk/encodedstr.rb : Tk::EncodedString class
+#
+require 'tk'
+
+###########################################
+# string with Tcl's encoding
+###########################################
+module Tk
+ class EncodedString < String
+ Encoding = nil
+
+ def self.subst_utf_backslash(str)
+ # str.gsub(/\\u([0-9A-Fa-f]{1,4})/){[$1.hex].pack('U')}
+ TclTkLib._subst_UTF_backslash(str)
+ end
+ def self.utf_backslash(str)
+ self.subst_utf_backslash(str)
+ end
+
+ def self.subst_tk_backslash(str)
+ TclTkLib._subst_Tcl_backslash(str)
+ end
+
+ def self.utf_to_backslash_sequence(str)
+ str.unpack('U*').collect{|c|
+ if c <= 0xFF # ascii character
+ c.chr
+ else
+ format('\u%X', c)
+ end
+ }.join('')
+ end
+ def self.utf_to_backslash(str)
+ self.utf_to_backslash_sequence(str)
+ end
+
+ def self.to_backslash_sequence(str)
+ str.unpack('U*').collect{|c|
+ if c <= 0x1F # control character
+ case c
+ when 0x07; '\a'
+ when 0x08; '\b'
+ when 0x09; '\t'
+ when 0x0a; '\n'
+ when 0x0b; '\v'
+ when 0x0c; '\f'
+ when 0x0d; '\r'
+ else
+ format('\x%02X', c)
+ end
+ elsif c <= 0xFF # ascii character
+ c.chr
+ else
+ format('\u%X', c)
+ end
+ }.join('')
+ end
+
+ def self.new_with_utf_backslash(str, enc = nil)
+ self.new('', enc).replace(self.subst_utf_backslash(str))
+ end
+
+ def self.new_without_utf_backslash(str, enc = nil)
+ self.new('', enc).replace(str)
+ end
+
+ def initialize(str, enc = nil)
+ super(str)
+ @encoding = ( enc ||
+ ((self.class::Encoding)?
+ self.class::Encoding : Tk.encoding_system) )
+ end
+
+ attr_reader :encoding
+ end
+ # def Tk.EncodedString(str, enc = nil)
+ # Tk::EncodedString.new(str, enc)
+ # end
+
+ ##################################
+
+ class BinaryString < EncodedString
+ Encoding = 'binary'.freeze
+ end
+ # def Tk.BinaryString(str)
+ # Tk::BinaryString.new(str)
+ # end
+
+ ##################################
+
+ class UTF8_String < EncodedString
+ Encoding = 'utf-8'.freeze
+ def self.new(str)
+ super(self.subst_utf_backslash(str))
+ end
+
+ def to_backslash_sequence
+ Tk::EncodedString.utf_to_backslash_sequence(self)
+ end
+ alias to_backslash to_backslash_sequence
+ end
+ # def Tk.UTF8_String(str)
+ # Tk::UTF8_String.new(str)
+ # end
+
+end
diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb
new file mode 100644
index 0000000000..a3c0e51cdd
--- /dev/null
+++ b/ext/tk/lib/tk/entry.rb
@@ -0,0 +1,110 @@
+#
+# tk/entry.rb - Tk entry classes
+# $Date$
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+
+require 'tk'
+require 'tk/label'
+require 'tk/scrollable'
+require 'tk/validation'
+
+class TkEntry<TkLabel
+ include X_Scrollable
+ include TkValidation
+
+ TkCommandNames = ['entry'.freeze].freeze
+ WidgetClassName = 'Entry'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ #def create_self(keys)
+ # super(__conv_vcmd_on_hash_kv(keys))
+ #end
+ #private :create_self
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', index))
+ end
+ def cursor
+ number(tk_send_without_enc('index', 'insert'))
+ end
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ def index(index)
+ number(tk_send_without_enc('index', index))
+ end
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ def invoke_validate
+ bool(tk_send_without_enc('validate'))
+ end
+ def validate(mode = nil)
+ if mode
+ configure 'validate', mode
+ else
+ invoke_validate
+ end
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def [](*args)
+ self.value[*args]
+ end
+ def []=(*args)
+ val = args.pop
+ str = self.value
+ str[*args] = val
+ self.value = str
+ val
+ end
+end
diff --git a/ext/tk/lib/tk/event.rb b/ext/tk/lib/tk/event.rb
new file mode 100644
index 0000000000..16adeedc6c
--- /dev/null
+++ b/ext/tk/lib/tk/event.rb
@@ -0,0 +1,180 @@
+#
+# tk/event.rb - module for event
+#
+
+unless $LOADED_FEATURES.member?('tk.rb')
+ # change loading order
+
+ $LOADED_FEATURES.delete('tk/event.rb')
+
+ require 'tkutil'
+ require 'tk'
+
+else
+################################################
+
+module TkEvent
+ class Event < TkUtil::CallbackSubst
+ module TypeNum
+ KeyPress = 2
+ KeyRelease = 3
+ ButtonPress = 4
+ ButtonRelease = 5
+ MotionNotify = 6
+ EnterNotify = 7
+ LeaveNotify = 8
+ FocusIn = 9
+ FocusOut = 10
+ KeymapNotify = 11
+ Expose = 12
+ GraphicsExpose = 13
+ NoExpose = 14
+ VisibilityNotify = 15
+ CreateNotify = 16
+ DestroyNotify = 17
+ UnmapNotify = 18
+ MapNotify = 19
+ MapRequest = 20
+ ReparentNotify = 21
+ ConfigureNotify = 22
+ ConfigureRequest = 23
+ GravityNotify = 24
+ ResizeRequest = 25
+ CirculateNotify = 26
+ CirculateRequest = 27
+ PropertyNotify = 28
+ SelectionClear = 29
+ SelectionRequest = 30
+ SelectionNotify = 31
+ ColormapNotify = 32
+ ClientMessage = 33
+ MappingNotify = 34
+ end
+
+ # [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>]
+ KEY_TBL = [
+ [ ?#, ?n, :serial ],
+ [ ?a, ?s, :above ],
+ [ ?b, ?n, :num ],
+ [ ?c, ?n, :count ],
+ [ ?d, ?s, :detail ],
+ [ ?f, ?b, :focus ],
+ [ ?h, ?n, :height ],
+ [ ?i, ?s, :win_hex ],
+ [ ?k, ?n, :keycode ],
+ [ ?m, ?s, :mode ],
+ [ ?o, ?b, :override ],
+ [ ?p, ?s, :place ],
+ [ ?s, ?x, :state ],
+ [ ?t, ?n, :time ],
+ [ ?w, ?n, :width ],
+ [ ?x, ?n, :x ],
+ [ ?y, ?n, :y ],
+ [ ?A, ?s, :char ],
+ [ ?B, ?n, :borderwidth ],
+ [ ?D, ?n, :wheel_delta ],
+ [ ?E, ?b, :send_event ],
+ [ ?K, ?s, :keysym ],
+ [ ?N, ?n, :keysym_num ],
+ [ ?R, ?s, :rootwin_id ],
+ [ ?S, ?s, :subwindow ],
+ [ ?T, ?n, :type ],
+ [ ?W, ?w, :widget ],
+ [ ?X, ?n, :x_root ],
+ [ ?Y, ?n, :y_root ],
+ nil
+ ]
+
+ # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?b, TkComm.method(:bool) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?x, proc{|val|
+ begin
+ TkComm::number(val)
+ rescue ArgumentError
+ val
+ end
+ }
+ ],
+
+ nil
+ ]
+
+ # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
+ #
+ # _get_subst_key() and _get_all_subst_keys() generates key-string
+ # which describe how to convert callback arguments to ruby objects.
+ # When binding parameters are given, use _get_subst_key().
+ # But when no parameters are given, use _get_all_subst_keys() to
+ # create a Event class object as a callback parameter.
+ #
+ # scan_args() is used when doing callback. It convert arguments
+ # ( which are Tcl strings ) to ruby objects based on the key string
+ # that is generated by _get_subst_key() or _get_all_subst_keys().
+ #
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ #
+ # NOTE: The order of parameters which passed to callback procedure is
+ # <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
+ #
+
+ # If you need support extra arguments given by Tcl/Tk,
+ # please override _get_extra_args_tbl
+ #
+ #def self._get_extra_args_tbl
+ # # return an array of convert procs
+ # []
+ #end
+
+ end
+
+ def install_bind_for_event_class(klass, cmd, *args)
+ extra_args_tbl = klass._get_extra_args_tbl
+
+ if args.compact.size > 0
+ args = args.join(' ')
+ keys = klass._get_subst_key(args)
+
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ id = install_cmd(cmd)
+ else
+ id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg))))
+ })
+ end
+ id + ' ' + args
+ else
+ keys, args = klass._get_all_subst_keys
+
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ id = install_cmd(cmd)
+ else
+ id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ TkUtil.eval_cmd(cmd,
+ *(ex_args << klass.new(*klass.scan_args(keys, arg))))
+ })
+ end
+ id + ' ' + args
+ end
+ end
+
+ def install_bind(cmd, *args)
+ install_bind_for_event_class(TkEvent::Event, cmd, *args)
+ end
+end
+
+################################################
+end
diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb
new file mode 100644
index 0000000000..02e09c6066
--- /dev/null
+++ b/ext/tk/lib/tk/font.rb
@@ -0,0 +1,1464 @@
+#
+# tk/font.rb - the class to treat fonts on Ruby/Tk
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkFont
+ include Tk
+ extend TkCore
+
+ TkCommandNames = ['font'.freeze].freeze
+
+ Tk_FontID = ["@font".freeze, "00000".taint].freeze
+ Tk_FontNameTBL = TkCore::INTERP.create_table
+ Tk_FontUseTBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ Tk_FontNameTBL.clear
+ Tk_FontUseTBL.clear
+ }
+
+ # set default font
+ case Tk::TK_VERSION
+ when /^4\.*/
+ DEFAULT_LATIN_FONT_NAME = 'a14'.freeze
+ DEFAULT_KANJI_FONT_NAME = 'k14'.freeze
+
+ when /^8\.*/
+ if JAPANIZED_TK
+ begin
+ fontnames = tk_call('font', 'names')
+ case fontnames
+ when /defaultgui/
+ # Tcl/Tk-JP for Windows
+ ltn = 'defaultgui'
+ knj = 'defaultgui'
+ when /Mincho:Helvetica-Bold-12/
+ # Tcl/Tk-JP for UNIX/X
+ ltn, knj = tk_split_simplelist(tk_call('font', 'configure',
+ 'Mincho:Helvetica-Bold-12',
+ '-compound'))
+ else
+ # unknown Tcl/Tk-JP
+ platform = tk_call('set', 'tcl_platform(platform)')
+ case platform
+ when 'unix'
+ ltn = {'family'=>'Helvetica'.freeze,
+ 'size'=>-12, 'weight'=>'bold'.freeze}
+ #knj = 'k14'
+ #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0'
+ knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0'
+ when 'windows'
+ ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
+ knj = 'mincho'
+ when 'macintosh'
+ ltn = 'system'
+ knj = 'mincho'
+ else # unknown
+ ltn = 'Helvetica'
+ knj = 'mincho'
+ end
+ end
+ rescue
+ ltn = 'Helvetica'
+ knj = 'mincho'
+ end
+
+ else # not JAPANIZED_TK
+ begin
+ platform = tk_call('set', 'tcl_platform(platform)')
+ case platform
+ when 'unix'
+ ltn = {'family'=>'Helvetica'.freeze,
+ 'size'=>-12, 'weight'=>'bold'.freeze}
+ when 'windows'
+ ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
+ when 'macintosh'
+ ltn = 'system'
+ else # unknown
+ ltn = 'Helvetica'
+ end
+ rescue
+ ltn = 'Helvetica'
+ end
+
+ knj = ltn.dup
+ end
+
+ DEFAULT_LATIN_FONT_NAME = ltn.freeze
+ DEFAULT_KANJI_FONT_NAME = knj.freeze
+
+ else # unknown version
+ DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
+ DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
+
+ end
+
+ if $DEBUG
+ print "default latin font = "; p DEFAULT_LATIN_FONT_NAME
+ print "default kanji font = "; p DEFAULT_KANJI_FONT_NAME
+ end
+
+
+ ###################################
+ class DescendantFont
+ def initialize(compound, type)
+ unless compound.kind_of?(TkFont)
+ fail ArgumentError, "a TkFont object is expected for the 1st argument"
+ end
+ @compound = compound
+ case type
+ when 'kanji', 'latin', 'ascii'
+ @type = type
+ else
+ fail ArgumentError, "unknown type '#{type}'"
+ end
+ end
+
+ def dup
+ fail RuntimeError, "cannot dupulicate a descendant font"
+ end
+ def clone
+ fail RuntimeError, "cannot clone a descendant font"
+ end
+
+ def to_eval
+ @compound.__send__(@type + '_font_id')
+ end
+ def font
+ @compound.__send__(@type + '_font_id')
+ end
+
+ def [](slot)
+ @compound.__send__(@type + '_configinfo', slot)
+ end
+ def []=(slot, value)
+ @compound.__send__(@type + '_configure', slot, value)
+ value
+ end
+
+ def method_missing(id, *args)
+ @compound.__send__(@type + '_' + id.id2name, *args)
+ end
+ end
+
+
+ ###################################
+ # class methods
+ ###################################
+ def TkFont.families(window=nil)
+ case (Tk::TK_VERSION)
+ when /^4\.*/
+ ['fixed']
+
+ when /^8\.*/
+ if window
+ tk_split_simplelist(tk_call('font', 'families', '-displayof', window))
+ else
+ tk_split_simplelist(tk_call('font', 'families'))
+ end
+ end
+ end
+
+ def TkFont.names
+ case (Tk::TK_VERSION)
+ when /^4\.*/
+ r = ['fixed']
+ r += ['a14', 'k14'] if JAPANIZED_TK
+ Tk_FontNameTBL.each_value{|obj| r.push(obj)}
+ r | []
+
+ when /^8\.*/
+ tk_split_simplelist(tk_call('font', 'names'))
+
+ end
+ end
+
+ def TkFont.create_copy(font)
+ fail 'source-font must be a TkFont object' unless font.kind_of? TkFont
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ keys = {}
+ font.configinfo.each{|key,value| keys[key] = value }
+ TkFont.new(font.latin_font_id, font.kanji_font_id, keys)
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ TkFont.new(font.latin_font_id, font.kanji_font_id, font.configinfo)
+ end
+ end
+
+ def TkFont.get_obj(name)
+ if name =~ /^(@font[0-9]+)(|c|l|k)$/
+ Tk_FontNameTBL[$1]
+ else
+ nil
+ end
+ end
+
+ def TkFont.init_widget_font(pathname, *args)
+ win, tag, key = pathname.split(';')
+ key = 'font' if key == nil || key == ''
+ path = [win, tag, key].join(';')
+
+ case (Tk::TK_VERSION)
+ when /^4\.*/
+ regexp = /^-(|kanji)#{key} /
+
+ conf_list = tk_split_simplelist(tk_call(*args)).
+ find_all{|prop| prop =~ regexp}.
+ collect{|prop| tk_split_simplelist(prop)}
+
+ if conf_list.size == 0
+ raise RuntimeError, "the widget may not support 'font' option"
+ end
+
+ args << {}
+
+ ltn_key = "-#{key}"
+ knj_key = "-kanji#{key}"
+
+ ltn_info = conf_list.find{|conf| conf[0] == ltn_key}
+ ltn = ltn_info[-1]
+ ltn = nil if ltn == [] || ltn == ""
+
+ knj_info = conf_list.find{|conf| conf[0] == knj_key}
+ knj = knj_info[-1]
+ knj = nil if knj == [] || knj == ""
+
+ TkFont.new(ltn, knj).call_font_configure([path, key], *args)
+
+ when /^8\.*/
+ regexp = /^-#{key} /
+
+ conf_list = tk_split_simplelist(tk_call(*args)).
+ find_all{|prop| prop =~ regexp}.
+ collect{|prop| tk_split_simplelist(prop)}
+
+ if conf_list.size == 0
+ raise RuntimeError, "the widget may not support 'font' option"
+ end
+
+ args << {}
+
+ optkey = "-#{key}"
+
+ info = conf_list.find{|conf| conf[0] == optkey}
+ fnt = info[-1]
+ fnt = nil if fnt == [] || fnt == ""
+
+ unless fnt
+ TkFont.new(nil, nil).call_font_configure([path, key], *args)
+ else
+ begin
+ compound = tk_split_simplelist(
+ Hash[*tk_split_simplelist(tk_call('font', 'configure',
+ fnt))].collect{|key,value|
+ [key[1..-1], value]
+ }.assoc('compound')[1])
+ rescue
+ compound = []
+ end
+ if compound == []
+ TkFont.new(fnt).call_font_configure([path, key], *args)
+ else
+ TkFont.new(compound[0],
+ compound[1]).call_font_configure([path, key], *args)
+ end
+ end
+ end
+ end
+
+ def TkFont.used_on(path=nil)
+ if path
+ Tk_FontUseTBL[path]
+ else
+ Tk_FontUseTBL.values | []
+ end
+ end
+
+ def TkFont.failsafe(font)
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ tk_call('font', 'failsafe', font)
+ end
+ rescue
+ end
+ end
+
+ ###################################
+ # instance methods
+ ###################################
+ private
+ ###################################
+ def initialize(ltn=nil, knj=nil, keys=nil)
+ # @id = Tk_FontID.join('')
+ @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
+ Tk_FontID[1].succ!
+ Tk_FontNameTBL[@id] = self
+
+ @latin_desscendant = nil
+ @kanji_desscendant = nil
+
+ if knj.kind_of?(Hash) && !keys
+ keys = knj
+ knj = nil
+ end
+
+ # compound font check
+ if Tk::TK_VERSION == '8.0' && JAPANIZED_TK
+ begin
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ ltn, '-compound'))
+ if knj == nil
+ if compound != []
+ ltn, knj = compound
+ end
+ else
+ if compound != []
+ ltn = compound[0]
+ end
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ knj, '-compound'))
+ if compound != []
+ knj = compound[1]
+ end
+ end
+ rescue
+ end
+ end
+
+ if ltn
+ if JAPANIZED_TK && !knj
+ if Tk::TK_VERSION =~ /^4.*/
+ knj = DEFAULT_KANJI_FONT_NAME
+ else
+ knj = ltn
+ end
+ end
+ else
+ ltn = DEFAULT_LATIN_FONT_NAME
+ knj = DEFAULT_KANJI_FONT_NAME if JAPANIZED_TK && !knj
+ end
+
+ create_compoundfont(ltn, knj, keys)
+ end
+
+ def _get_font_info_from_hash(font)
+ font = _symbolkey2str(font)
+ foundry = (info = font['foundry'] .to_s)? info: '*'
+ family = (info = font['family'] .to_s)? info: '*'
+ weight = (info = font['weight'] .to_s)? info: '*'
+ slant = (info = font['slant'] .to_s)? info: '*'
+ swidth = (info = font['swidth'] .to_s)? info: '*'
+ adstyle = (info = font['adstyle'] .to_s)? info: '*'
+ pixels = (info = font['pixels'] .to_s)? info: '*'
+ points = (info = font['points'] .to_s)? info: '*'
+ resx = (info = font['resx'] .to_s)? info: '*'
+ resy = (info = font['resy'] .to_s)? info: '*'
+ space = (info = font['space'] .to_s)? info: '*'
+ avgWidth = (info = font['avgWidth'].to_s)? info: '*'
+ charset = (info = font['charset'] .to_s)? info: '*'
+ encoding = (info = font['encoding'].to_s)? info: '*'
+
+ [foundry, family, weight, slant, swidth, adstyle,
+ pixels, points, resx, resy, space, avgWidth, charset, encoding]
+ end
+
+ def create_latinfont_tk4x(font)
+ if font.kind_of? Hash
+ @latinfont = '-' + _get_font_info_from_hash(font).join('-') + '-'
+
+ elsif font.kind_of? Array
+ finfo = {}
+ finfo['family'] = font[0].to_s
+ if font[1]
+ fsize = font[1].to_s
+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
+ if $1 == '-'
+ finfo['pixels'] = $2
+ else
+ finfo['points'] = $2
+ end
+ else
+ finfo['points'] = '13'
+ end
+ end
+ font[2..-1].each{|style|
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
+ when 'bold'
+ finfo['weight'] = style
+ when 'roman'
+ finfo['slant'] = 'r'
+ when 'italic'
+ finfo['slant'] = 'i'
+ end
+ }
+
+ @latinfont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
+
+ elsif font.kind_of? TkFont
+ @latinfont = font.latin_font
+
+ else
+ if font
+ @latinfont = font
+ else
+ @latinfont = DEFAULT_LATIN_FONT_NAME
+ end
+
+ end
+ end
+
+ def create_kanjifont_tk4x(font)
+ unless JAPANIZED_TK
+ @kanjifont = ""
+ return
+ end
+
+ if font.kind_of? Hash
+ @kanjifont = '-' + _get_font_info_from_hash(font).join('-') + '-'
+
+ elsif font.kind_of? Array
+ finfo = {}
+ finfo['family'] = font[0].to_s
+ if font[1]
+ fsize = font[1].to_s
+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
+ if $1 == '-'
+ finfo['pixels'] = $2
+ else
+ finfo['points'] = $2
+ end
+ else
+ finfo['points'] = '13'
+ end
+ end
+ font[2..-1].each{|style|
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
+ when 'bold'
+ finfo['weight'] = style
+ when 'roman'
+ finfo['slant'] = 'r'
+ when 'italic'
+ finfo['slant'] = 'i'
+ end
+ }
+
+ @kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
+ elsif font.kind_of? TkFont
+ @kanjifont = font.kanji_font_id
+ else
+ if font
+ @kanjifont = font
+ else
+ @kanjifont = DEFAULT_KANJI_FONT_NAME
+ end
+ end
+ end
+
+ def create_compoundfont_tk4x(ltn, knj, keys)
+ create_latinfont(ltn)
+ create_kanjifont(knj)
+
+ if JAPANIZED_TK
+ @compoundfont = [[@latinfont], [@kanjifont]]
+ @fontslot = {'font'=>@latinfont, 'kanjifont'=>@kanjifont}
+ else
+ @compoundfont = @latinfont
+ @fontslot = {'font'=>@latinfont}
+ end
+ end
+
+ def create_latinfont_tk8x(font)
+ @latinfont = @id + 'l'
+
+ if JAPANIZED_TK
+ if font.kind_of? Hash
+ if font[:charset] || font['charset']
+ tk_call('font', 'create', @latinfont, *hash_kv(font))
+ else
+ tk_call('font', 'create', @latinfont,
+ '-charset', 'iso8859', *hash_kv(font))
+ end
+ elsif font.kind_of? Array
+ tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font))
+ tk_call('font', 'configure', @latinfont, '-charset', 'iso8859')
+ elsif font.kind_of? TkFont
+ tk_call('font', 'create', @latinfont, '-copy', font.latin_font)
+ elsif font
+ tk_call('font', 'create', @latinfont, '-copy', font,
+ '-charset', 'iso8859')
+ else
+ tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
+ end
+ else
+ if font.kind_of? Hash
+ tk_call('font', 'create', @latinfont, *hash_kv(font))
+ else
+ keys = {}
+ if font.kind_of? Array
+ actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
+ elsif font.kind_of? TkFont
+ actual_core(font.latin_font).each{|key,val| keys[key] = val}
+ elsif font
+ actual_core(font).each{|key,val| keys[key] = val}
+ end
+ tk_call('font', 'create', @latinfont, *hash_kv(keys))
+ end
+
+ if font && @compoundfont
+ keys = {}
+ actual_core(@latinfont).each{|key,val| keys[key] = val}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
+ end
+ end
+ end
+
+ def create_kanjifont_tk8x(font)
+ @kanjifont = @id + 'k'
+
+ if JAPANIZED_TK
+ if font.kind_of? Hash
+ if font[:charset] || font['charset']
+ tk_call('font', 'create', @kanjifont, *hash_kv(font))
+ else
+ tk_call('font', 'create', @kanjifont,
+ '-charset', 'jisx0208.1983', *hash_kv(font))
+ end
+ elsif font.kind_of? Array
+ tk_call('font', 'create', @kanjifont, '-copy', array2tk_list(font))
+ tk_call('font', 'configure', @kanjifont, '-charset', 'jisx0208.1983')
+ elsif font.kind_of? TkFont
+ tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id)
+ elsif font
+ tk_call('font', 'create', @kanjifont, '-copy', font,
+ '-charset', 'jisx0208.1983')
+ else
+ tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
+ end
+ # end of JAPANIZED_TK
+
+ else
+ if font.kind_of? Hash
+ tk_call('font', 'create', @kanjifont, *hash_kv(font))
+ else
+ keys = {}
+ if font.kind_of? Array
+ actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
+ elsif font.kind_of? TkFont
+ actual_core(font.kanji_font_id).each{|key,val| keys[key] = val}
+ elsif font
+ actual_core(font).each{|key,val| keys[key] = val}
+ end
+ tk_call('font', 'create', @kanjifont, *hash_kv(keys))
+ end
+
+ if font && @compoundfont
+ keys = {}
+ actual_core(@kanjifont).each{|key,val| keys[key] = val}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
+ end
+ end
+ end
+
+ def create_compoundfont_tk8x(ltn, knj, keys)
+ create_latinfont(ltn)
+ create_kanjifont(knj)
+
+ @compoundfont = @id + 'c'
+ if JAPANIZED_TK
+ unless keys
+ keys = {}
+ else
+ keys = keys.dup
+ end
+ if (tk_call('font', 'configure', @latinfont, '-underline') == '1' &&
+ tk_call('font', 'configure', @kanjifont, '-underline') == '1' &&
+ !keys.key?('underline'))
+ keys['underline'] = true
+ end
+ if (tk_call('font', 'configure', @latinfont, '-overstrike') == '1' &&
+ tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' &&
+ !keys.key?('overstrike'))
+ keys['overstrike'] = true
+ end
+
+ @fontslot = {'font'=>@compoundfont}
+ begin
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ rescue RuntimeError => e
+ if ltn == knj
+ if e.message =~ /kanji font .* specified/
+ tk_call('font', 'delete', @latinfont)
+ create_latinfont(DEFAULT_LATIN_FONT_NAME)
+ opts = []
+ Hash[*(tk_split_simplelist(tk_call('font', 'configure',
+ @kanjifont)))].each{|k,v|
+ case k
+ when '-size', '-weight', '-slant', '-underline', '-overstrike'
+ opts << k << v
+ end
+ }
+ tk_call('font', 'configure', @latinfont, *opts)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+
+ elsif e.message =~ /ascii font .* specified/
+ tk_call('font', 'delete', @kanjifont)
+ create_kanjifont(DEFAULT_KANJI_FONT_NAME)
+ opts = []
+ Hash[*(tk_split_simplelist(tk_call('font', 'configure',
+ @latinfont)))].each{|k,v|
+ case k
+ when '-size', '-weight', '-slant', '-underline', '-overstrike'
+ opts << k << v
+ end
+ }
+ tk_call('font', 'configure', @kanjifont, *opts)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+
+ else
+ raise e
+ end
+ else
+ raise e
+ end
+ end
+ else
+ tk_call('font', 'create', @compoundfont)
+
+ latinkeys = {}
+ begin
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys {}
+ end
+ if latinkeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ end
+
+ if knj
+ kanjikeys = {}
+ begin
+ actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val}
+ rescue
+ kanjikeys {}
+ end
+ if kanjikeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys))
+ end
+ end
+
+ @fontslot = {'font'=>@compoundfont}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
+ end
+ end
+
+ def actual_core_tk4x(font, window=nil, option=nil)
+ # dummy
+ if option
+ ""
+ else
+ [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
+ ['underline',[]], ['overstrike',[]], ['charset',[]],
+ ['pointadjust',[]]]
+ end
+ end
+
+ def actual_core_tk8x(font, window=nil, option=nil)
+ if option == 'compound'
+ ""
+ elsif option
+ if window
+ tk_call('font', 'actual', font, "-displayof", window, "-#{option}")
+ else
+ tk_call('font', 'actual', font, "-#{option}")
+ end
+ else
+ l = tk_split_simplelist(if window
+ tk_call('font', 'actual', font,
+ "-displayof", window)
+ else
+ tk_call('font', 'actual', font)
+ end)
+ r = []
+ while key=l.shift
+ if key == '-compound'
+ l.shift
+ else
+ r.push [key[1..-1], l.shift]
+ end
+ end
+ r
+ end
+ end
+
+ def configure_core_tk4x(font, slot, value=None)
+ #""
+ self
+ end
+
+ def configinfo_core_tk4x(font, option=nil)
+ # dummy
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ if option
+ ""
+ else
+ [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
+ ['underline',[]], ['overstrike',[]], ['charset',[]],
+ ['pointadjust',[]]]
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ current_configinfo_core_tk4x(font, option)
+ end
+ end
+
+ def current_configinfo_core_tk4x(font, option=nil)
+ if option
+ ""
+ else
+ {'family'=>'', 'size'=>'', 'weight'=>'', 'slant'=>'',
+ 'underline'=>'', 'overstrike'=>'', 'charset'=>'', 'pointadjust'=>''}
+ end
+ end
+
+ def configure_core_tk8x(font, slot, value=None)
+ if JAPANIZED_TK
+ begin
+ padjust = tk_call('font', 'configure', font, '-pointadjust')
+ rescue
+ padjust = nil
+ end
+ else
+ padjust = nil
+ end
+ if slot.kind_of? Hash
+ if JAPANIZED_TK && (slot.key?('family') || slot.key?(:family))
+ slot = _symbolkey2str(slot)
+ configure_core_tk8x(font, 'family', slot.delete('family'))
+ end
+
+ if ((slot.key?('size') || slot.key?(:size)) &&
+ padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust))
+ tk_call('font', 'configure', font,
+ '-pointadjust', padjust, *hash_kv(slot))
+ else
+ tk_call('font', 'configure', font, *hash_kv(slot))
+ end
+ elsif (slot == 'size' || slot == :size) && padjust != nil
+ tk_call('font', 'configure', font,
+ "-#{slot}", value, '-pointadjust', padjust)
+ elsif JAPANIZED_TK && (slot == 'family' || slot == :family)
+ # coumpund font?
+ begin
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ font, '-compound'))
+ rescue
+ tk_call('font', 'configure', font, '-family', value)
+ return self
+ end
+ if compound == []
+ tk_call('font', 'configure', font, '-family', value)
+ return self
+ end
+ ltn, knj = compound
+
+ lfnt = tk_call('font', 'create', '-copy', ltn)
+ begin
+ tk_call('font', 'configure', lfnt, '-family', value)
+ latin_replace_core_tk8x(lfnt)
+ rescue RuntimeError => e
+ fail e if $DEBUG
+ ensure
+ tk_call('font', 'delete', lfnt) if lfnt != ''
+ end
+
+ kfnt = tk_call('font', 'create', '-copy', knj)
+ begin
+ tk_call('font', 'configure', kfnt, '-family', value)
+ kanji_replace_core_tk8x(lfnt)
+ rescue RuntimeError => e
+ fail e if $DEBUG
+ ensure
+ tk_call('font', 'delete', kfnt) if kfnt != ''
+ end
+
+ else
+ tk_call('font', 'configure', font, "-#{slot}", value)
+ end
+ self
+ end
+
+ def configinfo_core_tk8x(font, option=nil)
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ if option == 'compound'
+ ""
+ elsif option
+ tk_call('font', 'configure', font, "-#{option}")
+ else
+ l = tk_split_simplelist(tk_call('font', 'configure', font))
+ r = []
+ while key=l.shift
+ if key == '-compound'
+ l.shift
+ else
+ r.push [key[1..-1], l.shift]
+ end
+ end
+ r
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ current_configinfo_core_tk8x(font, option)
+ end
+ end
+
+ def current_configinfo_core_tk8x(font, option=nil)
+ if option == 'compound'
+ ""
+ elsif option
+ tk_call('font', 'configure', font, "-#{option}")
+ else
+ l = tk_split_simplelist(tk_call('font', 'configure', font))
+ r = {}
+ while key=l.shift
+ if key == '-compound'
+ l.shift
+ else
+ r[key[1..-1]] = l.shift
+ end
+ end
+ r
+ end
+ end
+
+ def delete_core_tk4x
+ Tk_FontNameTBL.delete(@id)
+ Tk_FontUseTBL.delete_if{|key,value| value == self}
+ end
+
+ def delete_core_tk8x
+ begin
+ tk_call('font', 'delete', @latinfont)
+ rescue
+ end
+ begin
+ tk_call('font', 'delete', @kanjifont)
+ rescue
+ end
+ begin
+ tk_call('font', 'delete', @compoundfont)
+ rescue
+ end
+ Tk_FontNameTBL.delete(@id)
+ Tk_FontUseTBL.delete_if{|key,value| value == self}
+ end
+
+ def latin_replace_core_tk4x(ltn)
+ create_latinfont_tk4x(ltn)
+ @compoundfont[0] = [@latinfont] if JAPANIZED_TK
+ @fontslot['font'] = @latinfont
+ Tk_FontUseTBL.dup.each{|w, fobj|
+ if self == fobj
+ begin
+ if w.include?(';')
+ win, tag, optkey = w.split(';')
+ optkey = 'font' if optkey == nil || optkey == ''
+ winobj = tk_tcl2ruby(win)
+# winobj.tagfont_configure(tag, {'font'=>@latinfont})
+ if winobj.kind_of? TkText
+ tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont)
+ elsif winobj.kind_of? TkCanvas
+ tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont)
+ elsif winobj.kind_of? TkMenu
+ tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
+ else
+# tk_tcl2ruby(w).font_configure('font'=>@latinfont)
+ tk_call(w, 'configure', '-font', @latinfont)
+ end
+ rescue
+ Tk_FontUseTBL.delete(w)
+ end
+ end
+ }
+ self
+ end
+
+ def kanji_replace_core_tk4x(knj)
+ return self unless JAPANIZED_TK
+
+ create_kanjifont_tk4x(knj)
+ @compoundfont[1] = [@kanjifont]
+ @fontslot['kanjifont'] = @kanjifont
+ Tk_FontUseTBL.dup.each{|w, fobj|
+ if self == fobj
+ begin
+ if w.include?(';')
+ win, tag, optkey = w.split(';')
+ optkey = 'kanjifont' unless optkey
+ winobj = tk_tcl2ruby(win)
+# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
+ if winobj.kind_of? TkText
+ tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont)
+ elsif winobj.kind_of? TkCanvas
+ tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont)
+ elsif winobj.kind_of? TkMenu
+ tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
+ else
+# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont)
+ tk_call(w, 'configure', '-kanjifont', @kanjifont)
+ end
+ rescue
+ Tk_FontUseTBL.delete(w)
+ end
+ end
+ }
+ self
+ end
+
+ def latin_replace_core_tk8x(ltn)
+ if JAPANIZED_TK
+ begin
+ tk_call('font', 'delete', '@font_tmp')
+ rescue
+ end
+ begin
+ fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont)
+ rescue
+ #fnt_bup = ''
+ fnt_bup = DEFAULT_LATIN_FONT_NAME
+ end
+ end
+
+ begin
+ tk_call('font', 'delete', @latinfont)
+ rescue
+ end
+ create_latinfont(ltn)
+
+ if JAPANIZED_TK
+ keys = self.configinfo
+ tk_call('font', 'delete', @compoundfont)
+ begin
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+=begin
+ latinkeys = {}
+ begin
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys {}
+ end
+ if latinkeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ end
+=end
+ rescue RuntimeError => e
+ tk_call('font', 'delete', @latinfont)
+ if fnt_bup && fnt_bup != ''
+ tk_call('font', 'create', @latinfont, '-copy', fnt_bup)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'delete', fnt_bup)
+ else
+ fail e
+ end
+ end
+
+ else
+ latinkeys = {}
+ begin
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys {}
+ end
+ if latinkeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ end
+ end
+ self
+ end
+
+ def kanji_replace_core_tk8x(knj)
+ if JAPANIZED_TK
+ begin
+ tk_call('font', 'delete', '@font_tmp')
+ rescue
+ end
+ begin
+ fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont)
+ rescue
+ #fnt_bup = ''
+ fnt_bup = DEFAULT_KANJI_FONT_NAME
+ end
+ end
+
+ begin
+ tk_call('font', 'delete', @kanjifont)
+ rescue
+ end
+ create_kanjifont(knj)
+
+ if JAPANIZED_TK
+ keys = self.configinfo
+ tk_call('font', 'delete', @compoundfont)
+ begin
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ rescue RuntimeError => e
+ tk_call('font', 'delete', @kanjifont)
+ if fnt_bup && fnt_bup != ''
+ tk_call('font', 'create', @kanjifont, '-copy', fnt_bup)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'delete', fnt_bup)
+ else
+ fail e
+ end
+ end
+ end
+ self
+ end
+
+ def measure_core_tk4x(window, text)
+ 0
+ end
+
+ def measure_core_tk8x(window, text)
+ if window
+ number(tk_call('font', 'measure', @compoundfont,
+ '-displayof', window, text))
+ else
+ number(tk_call('font', 'measure', @compoundfont, text))
+ end
+ end
+
+ def metrics_core_tk4x(font, window, option=nil)
+ # dummy
+ if option
+ ""
+ else
+ [['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]]]
+ end
+ end
+
+ def metrics_core_tk8x(font, window, option=nil)
+ if option
+ if window
+ number(tk_call('font', 'metrics', font,
+ "-displayof", window, "-#{option}"))
+ else
+ number(tk_call('font', 'metrics', font, "-#{option}"))
+ end
+ else
+ l = tk_split_list(if window
+ tk_call('font','metrics',font,"-displayof",window)
+ else
+ tk_call('font','metrics',font)
+ end)
+ r = []
+ while key=l.shift
+ r.push [key[1..-1], l.shift.to_i]
+ end
+ r
+ end
+ end
+
+ ###################################
+ # private alias
+ ###################################
+ case (Tk::TK_VERSION)
+ when /^4\.*/
+ alias create_latinfont create_latinfont_tk4x
+ alias create_kanjifont create_kanjifont_tk4x
+ alias create_compoundfont create_compoundfont_tk4x
+ alias actual_core actual_core_tk4x
+ alias configure_core configure_core_tk4x
+ alias configinfo_core configinfo_core_tk4x
+ alias current_configinfo_core current_configinfo_core_tk4x
+ alias delete_core delete_core_tk4x
+ alias latin_replace_core latin_replace_core_tk4x
+ alias kanji_replace_core kanji_replace_core_tk4x
+ alias measure_core measure_core_tk4x
+ alias metrics_core metrics_core_tk4x
+
+ when /^8\.[0-5]/
+ alias create_latinfont create_latinfont_tk8x
+ alias create_kanjifont create_kanjifont_tk8x
+ alias create_compoundfont create_compoundfont_tk8x
+ alias actual_core actual_core_tk8x
+ alias configure_core configure_core_tk8x
+ alias configinfo_core configinfo_core_tk8x
+ alias current_configinfo_core current_configinfo_core_tk8x
+ alias delete_core delete_core_tk8x
+ alias latin_replace_core latin_replace_core_tk8x
+ alias kanji_replace_core kanji_replace_core_tk8x
+ alias measure_core measure_core_tk8x
+ alias metrics_core metrics_core_tk8x
+
+ else
+ alias create_latinfont create_latinfont_tk8x
+ alias create_kanjifont create_kanjifont_tk8x
+ alias create_compoundfont create_compoundfont_tk8x
+ alias actual_core actual_core_tk8x
+ alias configure_core configure_core_tk8x
+ alias configinfo_core configinfo_core_tk8x
+ alias current_configinfo_core current_configinfo_core_tk8x
+ alias delete_core delete_core_tk8x
+ alias latin_replace_core latin_replace_core_tk8x
+ alias kanji_replace_core kanji_replace_core_tk8x
+ alias measure_core measure_core_tk8x
+ alias metrics_core metrics_core_tk8x
+
+ end
+
+ ###################################
+ public
+ ###################################
+ def method_missing(id, *args)
+ name = id.id2name
+ case args.length
+ when 1
+ configure name, args[0]
+ when 0
+ begin
+ configinfo name
+ rescue
+ fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
+ end
+ else
+ fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
+ end
+ end
+
+ def call_font_configure(path, *args)
+ if path.kind_of?(Array)
+ # [path, optkey]
+ win, tag = path[0].split(';')
+ optkey = path[1].to_s
+ else
+ win, tag, optkey = path.split(';')
+ end
+
+ fontslot = _symbolkey2str(@fontslot)
+ if optkey && optkey != ""
+ ltn = fontslot.delete('font')
+ knj = fontslot.delete('kanjifont')
+ fontslot[optkey] = ltn if ltn
+ fontslot["kanji#{optkey}"] = knj if knj
+ end
+
+ keys = _symbolkey2str(args.pop).update(fontslot)
+ args.concat(hash_kv(keys))
+ tk_call(*args)
+ Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
+ self
+ end
+
+ def used
+ ret = []
+ Tk_FontUseTBL.each{|key,value|
+ next unless self == value
+ if key.include?(';')
+ win, tag, optkey = key.split(';')
+ winobj = tk_tcl2ruby(win)
+ if winobj.kind_of? TkText
+ if optkey
+ ret.push([winobj, winobj.tagid2obj(tag), optkey])
+ else
+ ret.push([winobj, winobj.tagid2obj(tag)])
+ end
+ elsif winobj.kind_of? TkCanvas
+ if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
+ if optkey
+ ret.push([winobj, tagobj, optkey])
+ else
+ ret.push([winobj, tagobj])
+ end
+ elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem
+ if optkey
+ ret.push([winobj, tagobj, optkey])
+ else
+ ret.push([winobj, tagobj])
+ end
+ else
+ if optkey
+ ret.push([winobj, tag, optkey])
+ else
+ ret.push([winobj, tag])
+ end
+ end
+ elsif winobj.kind_of? TkMenu
+ if optkey
+ ret.push([winobj, tag, optkey])
+ else
+ ret.push([winobj, tag])
+ end
+ else
+ if optkey
+ ret.push([win, tag, optkey])
+ else
+ ret.push([win, tag])
+ end
+ end
+ else
+ ret.push(tk_tcl2ruby(key))
+ end
+ }
+ ret
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ font
+ end
+
+ def font
+ @compoundfont
+ end
+ alias font_id font
+
+ def latin_font_id
+ @latinfont
+ end
+
+ def latin_font
+ # @latinfont
+ if @latin_descendant
+ @latin_descendant
+ else
+ @latin_descendant = DescendantFont.new(self, 'latin')
+ end
+ end
+ alias latinfont latin_font
+
+ def kanji_font_id
+ @kanjifont
+ end
+
+ def kanji_font
+ # @kanjifont
+ if @kanji_descendant
+ @kanji_descendant
+ else
+ @kanji_descendant = DescendantFont.new(self, 'kanji')
+ end
+ end
+ alias kanjifont kanji_font
+
+ def actual(option=nil)
+ actual_core(@compoundfont, nil, option)
+ end
+
+ def actual_displayof(window, option=nil)
+ window = '.' unless window
+ actual_core(@compoundfont, window, option)
+ end
+
+ def latin_actual(option=nil)
+ actual_core(@latinfont, nil, option)
+ end
+
+ def latin_actual_displayof(window, option=nil)
+ window = '.' unless window
+ actual_core(@latinfont, window, option)
+ end
+
+ def kanji_actual(option=nil)
+ #if JAPANIZED_TK
+ if @kanjifont != ""
+ actual_core(@kanjifont, nil, option)
+ else
+ actual_core_tk4x(nil, nil, option)
+ end
+ end
+
+ def kanji_actual_displayof(window, option=nil)
+ #if JAPANIZED_TK
+ if @kanjifont != ""
+ window = '.' unless window
+ actual_core(@kanjifont, window, option)
+ else
+ actual_core_tk4x(nil, window, option)
+ end
+ end
+
+ def [](slot)
+ configinfo slot
+ end
+
+ def []=(slot, val)
+ configure slot, val
+ val
+ end
+
+ def configure(slot, value=None)
+ configure_core(@compoundfont, slot, value)
+ self
+ end
+
+ def configinfo(slot=nil)
+ configinfo_core(@compoundfont, slot)
+ end
+
+ def current_configinfo(slot=nil)
+ current_configinfo_core(@compoundfont, slot)
+ end
+
+ def delete
+ delete_core
+ end
+
+ def latin_configure(slot, value=None)
+ if JAPANIZED_TK
+ configure_core(@latinfont, slot, value)
+ else
+ configure(slot, value)
+ end
+ self
+ end
+
+ def latin_configinfo(slot=nil)
+ if JAPANIZED_TK
+ configinfo_core(@latinfont, slot)
+ else
+ configinfo(slot)
+ end
+ end
+
+ def kanji_configure(slot, value=None)
+ #if JAPANIZED_TK
+ if @kanjifont != ""
+ configure_core(@kanjifont, slot, value)
+ configure('size'=>configinfo('size')) # to reflect new configuration
+ else
+ #""
+ configure(slot, value)
+ end
+ self
+ end
+
+ def kanji_configinfo(slot=nil)
+ #if JAPANIZED_TK
+ if @kanjifont != ""
+ configinfo_core(@kanjifont, slot)
+ else
+ #[]
+ configinfo(slot)
+ end
+ end
+
+ def replace(ltn, knj)
+ latin_replace(ltn)
+ kanji_replace(knj)
+ self
+ end
+
+ def latin_replace(ltn)
+ latin_replace_core(ltn)
+ reset_pointadjust
+ self
+ end
+
+ def kanji_replace(knj)
+ kanji_replace_core(knj)
+ reset_pointadjust
+ self
+ end
+
+ def measure(text)
+ measure_core(nil, text)
+ end
+
+ def measure_displayof(window, text)
+ window = '.' unless window
+ measure_core(window, text)
+ end
+
+ def metrics(option=nil)
+ metrics_core(@compoundfont, nil, option)
+ end
+
+ def metrics_displayof(window, option=nil)
+ window = '.' unless window
+ metrics_core(@compoundfont, window, option)
+ end
+
+ def latin_metrics(option=nil)
+ metrics_core(@latinfont, nil, option)
+ end
+
+ def latin_metrics_displayof(window, option=nil)
+ window = '.' unless window
+ metrics_core(@latinfont, window, option)
+ end
+
+ def kanji_metrics(option=nil)
+ if JAPANIZED_TK
+ metrics_core(@kanjifont, nil, option)
+ else
+ metrics_core_tk4x(nil, nil, option)
+ end
+ end
+
+ def kanji_metrics_displayof(window, option=nil)
+ if JAPANIZED_TK
+ window = '.' unless window
+ metrics_core(@kanjifont, window, option)
+ else
+ metrics_core_tk4x(nil, window, option)
+ end
+ end
+
+ def reset_pointadjust
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
+ kanji_actual.assoc('size')[1].to_f )
+ end
+ rescue
+ end
+ self
+ end
+
+ ###################################
+ # public alias
+ ###################################
+ alias ascii_font latin_font
+ alias asciifont latinfont
+ alias create_asciifont create_latinfont
+ alias ascii_actual latin_actual
+ alias ascii_actual_displayof latin_actual_displayof
+ alias ascii_configure latin_configure
+ alias ascii_configinfo latin_configinfo
+ alias ascii_replace latin_replace
+ alias ascii_metrics latin_metrics
+
+ ###################################
+ def dup
+ src = self
+ obj = super()
+ obj.instance_eval{ initialize(src) }
+ obj
+ end
+ def clone
+ src = self
+ obj = super()
+ obj.instance_eval{ initialize(src) }
+ obj
+ end
+end
diff --git a/ext/tk/lib/tk/frame.rb b/ext/tk/lib/tk/frame.rb
new file mode 100644
index 0000000000..4f01825da9
--- /dev/null
+++ b/ext/tk/lib/tk/frame.rb
@@ -0,0 +1,123 @@
+#
+# tk/frame.rb : treat frame widget
+#
+require 'tk'
+
+class TkFrame<TkWindow
+ TkCommandNames = ['frame'.freeze].freeze
+ WidgetClassName = 'Frame'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+################# old version
+# def initialize(parent=nil, keys=nil)
+# if keys.kind_of? Hash
+# keys = keys.dup
+# @classname = keys.delete('classname') if keys.key?('classname')
+# @colormap = keys.delete('colormap') if keys.key?('colormap')
+# @container = keys.delete('container') if keys.key?('container')
+# @visual = keys.delete('visual') if keys.key?('visual')
+# end
+# super(parent, keys)
+# end
+#
+# def create_self
+# s = []
+# s << "-class" << @classname if @classname
+# s << "-colormap" << @colormap if @colormap
+# s << "-container" << @container if @container
+# s << "-visual" << @visual if @visual
+# tk_call 'frame', @path, *s
+# end
+#################
+
+ def initialize(parent=nil, keys=nil)
+ my_class_name = nil
+ if self.class < WidgetClassNames[self.class::WidgetClassName]
+ my_class_name = self.class.name
+ my_class_name = nil if my_class_name == ''
+ end
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ else
+ if keys
+ keys = _symbolkey2str(keys)
+ keys['parent'] = parent
+ else
+ keys = {'parent'=>parent}
+ end
+ end
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ @classname = keys['class']
+ @colormap = keys['colormap']
+ @container = keys['container']
+ @visual = keys['visual']
+ if !@classname && my_class_name
+ keys['class'] = @classname = my_class_name
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+ super(keys)
+ end
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('frame', @path, *hash_kv(keys))
+ # else
+ # tk_call_without_enc( 'frame', @path)
+ # end
+ #end
+ #private :create_self
+
+ def database_classname
+ @classname
+ end
+
+ def self.database_class
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ self
+ else
+ TkDatabaseClass.new(self.name)
+ end
+ end
+ def self.database_classname
+ self.database_class.name
+ end
+
+ def self.bind(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind(*args)
+ end
+ end
+ def self.bind_append(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind_append(*args)
+ end
+ end
+ def self.bind_remove(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind_remove(*args)
+ end
+ end
+ def self.bindinfo(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bindinfo(*args)
+ end
+ end
+end
diff --git a/ext/tk/lib/tk/grid.rb b/ext/tk/lib/tk/grid.rb
new file mode 100644
index 0000000000..74287d43bd
--- /dev/null
+++ b/ext/tk/lib/tk/grid.rb
@@ -0,0 +1,211 @@
+#
+# tk/grid.rb : control grid geometry manager
+#
+require 'tk'
+
+module TkGrid
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['grid'.freeze].freeze
+
+ def anchor(master, anchor=None)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ tk_call_without_enc('grid', 'anchor', master, anchor)
+ end
+
+ def bbox(master, *args)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ args.unshift(master)
+ list(tk_call_without_enc('grid', 'bbox', *args))
+ end
+
+ def configure(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ params.push(_epath(win))
+ args.each{|win|
+ case win
+ when '-', 'x', '^' # RELATIVE PLACEMENT
+ params.push(win)
+ else
+ params.push(_epath(win))
+ end
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ tk_call_without_enc("grid", 'configure', *params)
+ end
+ alias grid configure
+
+ def columnconfigure(master, index, args)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ tk_call_without_enc("grid", 'columnconfigure',
+ master, index, *hash_kv(args))
+ end
+
+ def rowconfigure(master, index, args)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ tk_call_without_enc("grid", 'rowconfigure', master, index, *hash_kv(args))
+ end
+
+ def columnconfiginfo(master, index, slot=nil)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if slot
+ case slot
+ when 'uniform', :uniform
+ tk_call_without_enc('grid', 'columnconfigure',
+ master, index, "-#{slot}")
+ else
+ num_or_str(tk_call_without_enc('grid', 'columnconfigure',
+ master, index, "-#{slot}"))
+ end
+ else
+ #ilist = list(tk_call_without_enc('grid','columnconfigure',master,index))
+ ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure',
+ master, index))
+ info = {}
+ while key = ilist.shift
+ case key
+ when 'uniform'
+ info[key[1..-1]] = ilist.shift
+ else
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ end
+ info
+ end
+ end
+
+ def rowconfiginfo(master, index, slot=nil)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if slot
+ case slot
+ when 'uniform', :uniform
+ tk_call_without_enc('grid', 'rowconfigure',
+ master, index, "-#{slot}")
+ else
+ num_or_str(tk_call_without_enc('grid', 'rowconfigure',
+ master, index, "-#{slot}"))
+ end
+ else
+ #ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index))
+ ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure',
+ master, index))
+ info = {}
+ while key = ilist.shift
+ case key
+ when 'uniform'
+ info[key[1..-1]] = ilist.shift
+ else
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ end
+ info
+ end
+ end
+
+ def add(widget, *args)
+ configure(widget, *args)
+ end
+
+ def forget(*args)
+ return '' if args.size == 0
+ wins = args.collect{|win|
+ # (win.kind_of?(TkObject))? win.epath: win
+ _epath(win)
+ }
+ tk_call_without_enc('grid', 'forget', *wins)
+ end
+
+ def info(slave)
+ # slave = slave.epath if slave.kind_of?(TkObject)
+ slave = _epath(slave)
+ #ilist = list(tk_call_without_enc('grid', 'info', slave))
+ ilist = simplelist(tk_call_without_enc('grid', 'info', slave))
+ info = {}
+ while key = ilist.shift
+ #info[key[1..-1]] = ilist.shift
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ return info
+ end
+
+ def location(master, x, y)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('grid', 'location', master, x, y))
+ end
+
+ def propagate(master, bool=None)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if bool == None
+ bool(tk_call_without_enc('grid', 'propagate', master))
+ else
+ tk_call_without_enc('grid', 'propagate', master, bool)
+ end
+ end
+
+ def remove(*args)
+ return '' if args.size == 0
+ wins = args.collect{|win|
+ # (win.kind_of?(TkObject))? win.epath: win
+ _epath(win)
+ }
+ tk_call_without_enc('grid', 'remove', *wins)
+ end
+
+ def size(master)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('grid', 'size', master))
+ end
+
+ def slaves(master, args)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('grid', 'slaves', master, *hash_kv(args)))
+ end
+
+ module_function :bbox, :forget, :propagate, :info
+ module_function :remove, :size, :slaves, :location
+ module_function :grid, :configure, :columnconfigure, :rowconfigure
+ module_function :columnconfiginfo, :rowconfiginfo
+end
+=begin
+def TkGrid(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ args.each{|win|
+ case win
+ when '-', 'x', '^' # RELATIVE PLACEMENT
+ params.push(win)
+ else
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ end
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ tk_call_without_enc("grid", *params)
+end
+=end
diff --git a/ext/tk/lib/tk/image.rb b/ext/tk/lib/tk/image.rb
new file mode 100644
index 0000000000..7fd61eff5d
--- /dev/null
+++ b/ext/tk/lib/tk/image.rb
@@ -0,0 +1,186 @@
+#
+# tk/image.rb : treat Tk image objects
+#
+
+require 'tk'
+
+class TkImage<TkObject
+ include Tk
+
+ TkCommandNames = ['image'.freeze].freeze
+
+ Tk_IMGTBL = TkCore::INTERP.create_table
+ Tk_Image_ID = ['i'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
+
+ def initialize(keys=nil)
+ # @path = Tk_Image_ID.join('')
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ tk_call_without_enc('image', 'create', @type, @path, *hash_kv(keys, true))
+ Tk_IMGTBL[@path] = self
+ end
+
+ def delete
+ Tk_IMGTBL.delete(@id) if @id
+ tk_call_without_enc('image', 'delete', @path)
+ self
+ end
+ def height
+ number(tk_call_without_enc('image', 'height', @path))
+ end
+ def inuse
+ bool(tk_call_without_enc('image', 'inuse', @path))
+ end
+ def itemtype
+ tk_call_without_enc('image', 'type', @path)
+ end
+ def width
+ number(tk_call_without_enc('image', 'width', @path))
+ end
+
+ def TkImage.names
+ Tk.tk_call_without_enc('image', 'names').split.collect!{|id|
+ (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
+ }
+ end
+
+ def TkImage.types
+ Tk.tk_call_without_enc('image', 'types').split
+ end
+end
+
+class TkBitmapImage<TkImage
+ def initialize(*args)
+ @type = 'bitmap'
+ super
+ end
+end
+
+class TkPhotoImage<TkImage
+ NullArgOptionKeys = [ "shrink", "grayscale" ]
+
+ def _photo_hash_kv(keys)
+ keys = _symbolkey2str(keys)
+ NullArgOptionKeys.collect{|opt|
+ if keys[opt]
+ keys[opt] = None
+ else
+ keys.delete(opt)
+ end
+ }
+ hash_kv(keys).flatten
+ end
+ private :_photo_hash_kv
+
+ def initialize(*args)
+ @type = 'photo'
+ super
+ end
+
+ def blank
+ tk_send_without_enc('blank')
+ self
+ end
+
+ def cget(option)
+ case option.to_s
+ when 'data', 'file'
+ tk_send 'cget', option
+ else
+ tk_tcl2ruby(tk_send('cget', option))
+ end
+ end
+
+ def copy(src, *opts)
+ if opts.size == 0
+ tk_send('copy', src)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('copy', src, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ args = opts.collect{|term|
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
+ }.flatten
+ tk_send('copy', src, *args)
+ end
+ self
+ end
+
+ def data(keys={})
+ #tk_send('data', *_photo_hash_kv(keys))
+ tk_split_list(tk_send('data', *_photo_hash_kv(keys)))
+ end
+
+ def get(x, y)
+ tk_send('get', x, y).split.collect{|n| n.to_i}
+ end
+
+ def put(data, *opts)
+ if opts == []
+ tk_send('put', data)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('put', data, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ tk_send('put', data, '-to', *opts)
+ end
+ self
+ end
+
+ def read(file, *opts)
+ if opts.size == 0
+ tk_send('read', file)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('read', file, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ args = opts.collect{|term|
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
+ }.flatten
+ tk_send('read', file, *args)
+ end
+ self
+ end
+
+ def redither
+ tk_send 'redither'
+ self
+ end
+
+ def get_transparency(x, y)
+ bool(tk_send('transparency', 'get', x, y))
+ end
+ def set_transparency(x, y, st)
+ tk_send('transparency', 'set', x, y, st)
+ self
+ end
+
+ def write(file, *opts)
+ if opts.size == 0
+ tk_send('write', file)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('write', file, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ args = opts.collect{|term|
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
+ }.flatten
+ tk_send('write', file, *args)
+ end
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/itemconfig.rb b/ext/tk/lib/tk/itemconfig.rb
new file mode 100644
index 0000000000..f0f13e63bd
--- /dev/null
+++ b/ext/tk/lib/tk/itemconfig.rb
@@ -0,0 +1,794 @@
+#
+# tk/itemconfig.rb : control item/tag configuration of widget
+#
+require 'tk'
+require 'tkutil'
+require 'tk/itemfont.rb'
+
+module TkItemConfigOptkeys
+ def __item_numval_optkeys(id)
+ []
+ end
+ private :__item_numval_optkeys
+
+ def __item_numstrval_optkeys(id)
+ []
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_boolval_optkeys(id)
+ []
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ # maybe need to override
+ ['text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile']
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+
+ def __item_numlistval_optkeys(id)
+ # maybe need to override
+ ['dash', 'activedash', 'disableddash']
+ end
+ private :__item_numlistval_optkeys
+
+ def __item_methodcall_optkeys(id) # { key=>method, ... }
+ # maybe need to override
+ # {'coords'=>'coords'}
+ {}
+ end
+ private :__item_methodcall_optkeys
+
+ ################################################
+
+ def __item_keyonly_optkeys(id) # { def_key=>(undef_key|nil), ... }
+ # maybe need to override
+ {}
+ end
+ private :__item_keyonly_optkeys
+
+
+ def __conv_item_keyonly_opts(id, keys)
+ return keys unless keys.kind_of?(Hash)
+ keyonly = __item_keyonly_optkeys(id)
+ keys2 = {}
+ keys.each{|k, v|
+ optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s}
+ if optkey
+ defkey, undefkey = optkey
+ if v
+ keys2[defkey.to_s] = None
+ else
+ keys2[undefkey.to_s] = None
+ end
+ else
+ keys2[k.to_s] = v
+ end
+ }
+ keys2
+ end
+
+ def itemconfig_hash_kv(id, keys, enc_mode = nil, conf = nil)
+ hash_kv(__conv_item_keyonly_opts(id, keys), enc_mode, conf)
+ end
+end
+
+module TkItemConfigMethod
+ include TkUtil
+ include TkTreatItemFont
+ include TkItemConfigOptkeys
+
+ def __item_cget_cmd(id)
+ # maybe need to override
+ [self.path, 'itemcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ # maybe need to override
+ [self.path, 'itemconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_confinfo_cmd(id)
+ # maybe need to override
+ __item_config_cmd(id)
+ end
+ private :__item_confinfo_cmd
+
+ def __item_configinfo_struct(id)
+ # maybe need to override
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
+ :default_value=>3, :current_value=>4}
+ end
+ private :__item_configinfo_struct
+
+ ################################################
+
+ def tagid(tagOrId)
+ # maybe need to override
+ tagOrId
+ end
+
+ ################################################
+
+ def itemcget(tagOrId, option)
+ option = option.to_s
+
+ if ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[option] )
+ return self.__send__(method, tagOrId)
+ end
+
+ case option
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ number(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+ rescue
+ nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ num_or_str(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ bool(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+ rescue
+ nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ simplelist(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
+ if conf =~ /^[0-9]/
+ list(conf)
+ else
+ conf
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ _fromUTF8(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+
+ when /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/
+ fontcode = $1
+ fontkey = $2
+ fnt = tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{fontkey}")), true)
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(tagid(tagOrId), fontkey)
+ end
+ if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true)
+ end
+ end
+
+ def itemconfigure(tagOrId, slot, value=None)
+ if slot.kind_of? Hash
+ slot = _symbolkey2str(slot)
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|key, method|
+ value = slot.delete(key.to_s)
+ self.__send__(method, tagOrId, value) if value
+ }
+
+ __item_keyonly_optkeys(tagid(tagOrId)).each{|defkey, undefkey|
+ conf = slot.find{|kk, vv| kk == defkey.to_s}
+ if conf
+ k, v = conf
+ if v
+ slot[k] = None
+ else
+ slot[undefkey.to_s] = None if undefkey
+ slot.delete(k)
+ end
+ end
+ }
+
+ if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/})
+ tagfont_configure(tagid(tagOrId), slot)
+ elsif slot.size > 0
+ tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot))))
+ end
+
+ else
+ slot = slot.to_s
+ if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } )
+ defkey, undefkey = conf
+ if value
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}"))
+ elsif undefkey
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}"))
+ end
+ elsif ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] )
+ self.__send__(method, tagOrId, value)
+ elsif (slot =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ if value == None
+ tagfontobj(tagid(tagOrId), $2)
+ else
+ tagfont_configure(tagid(tagOrId), {slot=>value})
+ end
+ else
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value))
+ end
+ end
+ self
+ end
+
+ def itemconfiginfo(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey)
+ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ conf
+ else
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return [slot, '', '', '', self.__send__(method, tagOrId)]
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ else
+ conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+
+ conf
+
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ case conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ else
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ end
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+ end
+ end
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+
+ conf
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf && fontconf.size > 2
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
+ ret.push(fontconf)
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey)
+ { conf.shift => conf }
+ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+ else
+ if slot
+ slot = slot.to_s
+ case slot
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return {slot => ['', '', '', self.__send__(method, tagOrId)]}
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+
+ else
+ conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ case conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ else
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ end
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+ end
+ end
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ ret[conf[0]] = conf[1]
+ else
+ ret[conf.shift] = conf
+ end
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
+ end
+ end
+ end
+
+ def current_itemconfiginfo(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ org_slot = slot
+ begin
+ conf = itemconfiginfo(tagOrId, slot)
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
+ else
+ ret = {}
+ itemconfiginfo(tagOrId).each{|conf|
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ ret[conf[0]] = conf[-1]
+ end
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ itemconfiginfo(slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+end
diff --git a/ext/tk/lib/tk/itemfont.rb b/ext/tk/lib/tk/itemfont.rb
new file mode 100644
index 0000000000..e4a1a50912
--- /dev/null
+++ b/ext/tk/lib/tk/itemfont.rb
@@ -0,0 +1,300 @@
+#
+# tk/itemfont.rb : control font of widget items
+#
+require 'tk'
+
+module TkItemFontOptkeys
+ def __item_font_optkeys(id)
+ # maybe need to override
+ ['font']
+ end
+ private :__item_font_optkeys
+end
+
+module TkTreatItemFont
+ include TkItemFontOptkeys
+
+ def __item_pathname(id)
+ # maybe need to override
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ ################################################
+
+ def tagfont_configinfo(tagOrId, key = nil)
+ optkeys = __item_font_optkeys(tagid(tagOrId))
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __item_pathname(tagid(tagOrId)).split(';')
+
+ if key
+ pathname = [win, tag, key].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname,
+ *(__item_confinfo_cmd(tagid(tagOrId))))
+ elsif optkeys.size == 1
+ pathname = [win, tag, optkeys[0]].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname,
+ *(__item_confinfo_cmd(tagid(tagOrId))))
+ else
+ fonts = {}
+ optkeys.each{|key|
+ key = key.to_s
+ pathname = [win, tag, key].join(';')
+ fonts[key] =
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname,
+ *(__item_confinfo_cmd(tagid(tagOrId))))
+ }
+ fonts
+ end
+ end
+ alias tagfontobj tagfont_configinfo
+
+ def tagfont_configure(tagOrId, slot)
+ pathname = __item_pathname(tagid(tagOrId))
+
+ slot = _symbolkey2str(slot)
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ l_optkey = 'latin' << optkey
+ a_optkey = 'ascii' << optkey
+ k_optkey = 'kanji' << optkey
+
+ if slot.key?(optkey)
+ fnt = slot.delete(optkey)
+ if fnt.kind_of?(TkFont)
+ slot.delete(l_optkey)
+ slot.delete(a_optkey)
+ slot.delete(k_optkey)
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ next
+ else
+ if fnt
+ if (slot.key?(l_optkey) ||
+ slot.key?(a_optkey) ||
+ slot.key?(k_optkey))
+ fnt = TkFont.new(fnt)
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ fnt.latin_replace(lfnt) if lfnt
+ fnt.kanji_replace(kfnt) if kfnt
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ next
+ else
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
+ end
+ end
+ next
+ end
+ end
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ if lfnt && kfnt
+ TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ elsif lfnt
+ latintagfont_configure([lfnt, optkey])
+ elsif kfnt
+ kanjitagfont_configure([kfnt, optkey])
+ end
+ }
+
+ # configure other (without font) options
+ tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot)))) if slot != {}
+ self
+ end
+
+ def latintagfont_configure(tagOrId, ltn, keys=nil)
+ if ltn.kind_of?(Array)
+ key = ltn[1]
+ ltn = ltn[0]
+ else
+ key = nil
+ end
+
+ optkeys = __item_font_optkeys(tagid(tagOrId))
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __item_pathname(tagid(tagOrId)).split(';')
+
+ optkeys = [key] if key
+
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
+
+ pathname = [win, tag, optkey].join(';')
+
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
+ else
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
+ next
+ end
+
+ if fobj.kind_of?(TkFont)
+ if ltn.kind_of?(TkFont)
+ conf = {}
+ ltn.latin_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.latin_configure(conf.update(keys))
+ else
+ fobj.latin_configure(conf)
+ end
+ else
+ fobj.latin_replace(ltn)
+ end
+ end
+
+ fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
+ }
+ self
+ end
+ alias asciitagfont_configure latintagfont_configure
+
+ def kanjitagfont_configure(tagOrId, knj, keys=nil)
+ if knj.kind_of?(Array)
+ key = knj[1]
+ knj = knj[0]
+ else
+ key = nil
+ end
+
+ optkeys = __item_font_optkeys(tagid(tagOrId))
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __item_pathname(tagid(tagOrId)).split(';')
+
+ optkeys = [key] if key
+
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
+
+ pathname = [win, tag, optkey].join(';')
+
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
+ else
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
+ next
+ end
+
+ if fobj.kind_of?(TkFont)
+ if knj.kind_of?(TkFont)
+ conf = {}
+ knj.kanji_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.kanji_configure(conf.update(keys))
+ else
+ fobj.kanji_configure(conf)
+ end
+ else
+ fobj.kanji_replace(knj)
+ end
+ end
+
+ fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
+ }
+ self
+ end
+
+ def tagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
+ if wintag
+ if winkey
+ fnt = window.tagfontobj(wintag, winkey).dup
+ else
+ fnt = window.tagfontobj(wintag).dup
+ end
+ else
+ if winkey
+ fnt = window.fontobj(winkey).dup
+ else
+ fnt = window.fontobj.dup
+ end
+ end
+
+ if targetkey
+ fnt.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ else
+ fnt.call_font_configure(__item_pathname(tagid(tagOrId)),
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ end
+ self
+ end
+
+
+ def latintagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ else
+ fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ end
+
+ if wintag
+ if winkey
+ fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id)
+ else
+ fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id)
+ end
+ else
+ if winkey
+ fontobj.latin_replace(window.fontobj(winkey).latin_font_id)
+ else
+ fontobj.latin_replace(window.fontobj.latin_font_id)
+ end
+ end
+ self
+ end
+ alias asciitagfont_copy latintagfont_copy
+
+ def kanjifont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ else
+ fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ end
+
+ if wintag
+ if winkey
+ fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id)
+ end
+ else
+ if winkey
+ fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(window.fontobj.kanji_font_id)
+ end
+ end
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/kinput.rb b/ext/tk/lib/tk/kinput.rb
new file mode 100644
index 0000000000..fc731b6569
--- /dev/null
+++ b/ext/tk/lib/tk/kinput.rb
@@ -0,0 +1,71 @@
+#
+# tk/kinput.rb : control kinput
+#
+require 'tk'
+
+module TkKinput
+ include Tk
+ extend Tk
+
+ TkCommandNames = [
+ 'kinput_start'.freeze,
+ 'kinput_send_spot'.freeze,
+ 'kanjiInput'.freeze
+ ].freeze
+
+ def TkKinput.start(window, style=None)
+ tk_call('kinput_start', window, style)
+ end
+ def kinput_start(style=None)
+ TkKinput.start(self, style)
+ end
+
+ def TkKinput.send_spot(window)
+ tk_call('kinput_send_spot', window)
+ end
+ def kinput_send_spot
+ TkKinput.send_spot(self)
+ end
+
+ def TkKinput.input_start(window, keys=nil)
+ tk_call('kanjiInput', 'start', window, *hash_kv(keys))
+ end
+ def kanji_input_start(keys=nil)
+ TkKinput.input_start(self, keys)
+ end
+
+ def TkKinput.attribute_config(window, slot, value=None)
+ if slot.kind_of? Hash
+ tk_call('kanjiInput', 'attribute', window, *hash_kv(slot))
+ else
+ tk_call('kanjiInput', 'attribute', window, "-#{slot}", value)
+ end
+ end
+ def kinput_attribute_config(slot, value=None)
+ TkKinput.attribute_config(self, slot, value)
+ end
+
+ def TkKinput.attribute_info(window, slot=nil)
+ if slot
+ conf = tk_split_list(tk_call('kanjiInput', 'attribute',
+ window, "-#{slot}"))
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_list(tk_call('kanjiInput', 'attribute', window)).collect{|conf|
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
+ end
+ def kinput_attribute_info(slot=nil)
+ TkKinput.attribute_info(self, slot)
+ end
+
+ def TkKinput.input_end(window)
+ tk_call('kanjiInput', 'end', window)
+ end
+ def kanji_input_end
+ TkKinput.input_end(self)
+ end
+end
diff --git a/ext/tk/lib/tk/label.rb b/ext/tk/lib/tk/label.rb
new file mode 100644
index 0000000000..ea669d576e
--- /dev/null
+++ b/ext/tk/lib/tk/label.rb
@@ -0,0 +1,22 @@
+#
+# tk/label.rb : treat label widget
+#
+require 'tk'
+
+class TkLabel<TkWindow
+ TkCommandNames = ['label'.freeze].freeze
+ WidgetClassName = 'Label'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('label', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('label', @path)
+ # end
+ #end
+ #private :create_self
+
+ def textvariable(v)
+ configure 'textvariable', tk_trace_variable(v)
+ end
+end
diff --git a/ext/tk/lib/tk/labelframe.rb b/ext/tk/lib/tk/labelframe.rb
new file mode 100644
index 0000000000..fd16d3419d
--- /dev/null
+++ b/ext/tk/lib/tk/labelframe.rb
@@ -0,0 +1,20 @@
+#
+# tk/labelframe.rb : treat labelframe widget
+#
+require 'tk'
+require 'tk/frame'
+
+class TkLabelFrame<TkFrame
+ TkCommandNames = ['labelframe'.freeze].freeze
+ WidgetClassName = 'Labelframe'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('labelframe', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('labelframe', @path)
+ # end
+ #end
+ #private :create_self
+end
+TkLabelframe = TkLabelFrame
diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb
new file mode 100644
index 0000000000..f00db19239
--- /dev/null
+++ b/ext/tk/lib/tk/listbox.rb
@@ -0,0 +1,273 @@
+#
+# tk/listbox.rb : treat listbox widget
+#
+require 'tk'
+require 'tk/itemconfig'
+require 'tk/scrollable'
+require 'tk/txtwin_abst'
+
+module TkListItemConfig
+ include TkItemConfigMethod
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+end
+
+class TkListbox<TkTextWin
+ include TkListItemConfig
+ include Scrollable
+
+ TkCommandNames = ['listbox'.freeze].freeze
+ WidgetClassName = 'Listbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('listbox', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('listbox', @path)
+ # end
+ #end
+ #private :create_self
+
+ def tagid(id)
+ #id.to_s
+ _get_eval_string(id)
+ end
+
+ def activate(y)
+ tk_send_without_enc('activate', y)
+ self
+ end
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def get(first, last=nil)
+ if last
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
+ else
+ _fromUTF8(tk_send_without_enc('get', first))
+ end
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ def index(index)
+ tk_send_without_enc('index', index).to_i
+ end
+
+ def value
+ get('0', 'end')
+ end
+
+ def value= (vals)
+ unless vals.kind_of?(Array)
+ fail ArgumentError, 'an Array is expected'
+ end
+ tk_send_without_enc('delete', '0', 'end')
+ tk_send_without_enc('insert', '0',
+ *(vals.collect{|v| _get_eval_enc_str(v)}))
+ vals
+ end
+
+ def clear
+ tk_send_without_enc('delete', '0', 'end')
+ self
+ end
+ alias erase clear
+
+=begin
+ def itemcget(index, key)
+ case key.to_s
+ when 'text', 'label', 'show'
+ _fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index,
+ '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(index, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}")))
+ end
+ end
+ def itemconfigure(index, key, val=None)
+ if key.kind_of? Hash
+ if (key['font'] || key[:font] ||
+ key['kanjifont'] || key[:kanjifont] ||
+ key['latinfont'] || key[:latinfont] ||
+ key['asciifont'] || key[:asciifont] )
+ tagfont_configure(index, _symbolkey2str(key))
+ else
+ tk_send_without_enc('itemconfigure', index, *hash_kv(key, true))
+ end
+
+ else
+ if (key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont )
+ if val == None
+ tagfontobj(index)
+ else
+ tagfont_configure(index, {key=>val})
+ end
+ else
+ tk_call('itemconfigure', index, "-#{key}", val)
+ end
+ end
+ self
+ end
+
+ def itemconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
+ end
+ end
+ end
+
+ def current_itemconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = itemconfiginfo(index, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ itemconfiginfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ itemconfiginfo(index, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+end
diff --git a/ext/tk/lib/tk/macpkg.rb b/ext/tk/lib/tk/macpkg.rb
new file mode 100644
index 0000000000..d67a19745b
--- /dev/null
+++ b/ext/tk/lib/tk/macpkg.rb
@@ -0,0 +1,68 @@
+#
+# tk/macpkg.rb : methods for Tcl/Tk packages for Macintosh
+# 2000/11/22 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+# ATTENTION !!
+# This is NOT TESTED. Because I have no test-environment.
+#
+#
+require 'tk'
+
+module Tk
+ def Tk.load_tclscript_rsrc(resource_name, file=None)
+ # Mac only
+ tk_call('source', '-rsrc', resource_name, file)
+ end
+
+ def Tk.load_tclscript_rsrcid(resource_id, file=None)
+ # Mac only
+ tk_call('source', '-rsrcid', resource_id, file)
+ end
+end
+
+module TkMacResource
+ extend Tk
+ extend TkMacResource
+
+ TkCommandNames = ['resource'.freeze].freeze
+
+ tk_call_without_enc('package', 'require', 'resource')
+
+ def close(rsrcRef)
+ tk_call('resource', 'close', rsrcRef)
+ end
+
+ def delete(rsrcType, opts=nil)
+ tk_call('resource', 'delete', *(hash_kv(opts) << rsrcType))
+ end
+
+ def files(rsrcRef=nil)
+ if rsrcRef
+ tk_call('resource', 'files', rsrcRef)
+ else
+ tk_split_simplelist(tk_call('resource', 'files'))
+ end
+ end
+
+ def list(rsrcType, rsrcRef=nil)
+ tk_split_simplelist(tk_call('resource', 'list', rsrcType, rsrcRef))
+ end
+
+ def open(fname, access=nil)
+ tk_call('resource', 'open', fname, access)
+ end
+
+ def read(rsrcType, rsrcID, rsrcRef=nil)
+ tk_call('resource', 'read', rsrcType, rsrcID, rsrcRef)
+ end
+
+ def types(rsrcRef=nil)
+ tk_split_simplelist(tk_call('resource', 'types', rsrcRef))
+ end
+
+ def write(rsrcType, data, opts=nil)
+ tk_call('resource', 'write', *(hash_kv(opts) << rsrcType << data))
+ end
+
+ module_function :close, :delete, :files, :list, :open, :read, :types, :write
+end
diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb
new file mode 100644
index 0000000000..5014dea603
--- /dev/null
+++ b/ext/tk/lib/tk/menu.rb
@@ -0,0 +1,488 @@
+#
+# tk/menu.rb : treat menu and menubutton
+#
+require 'tk'
+require 'tk/itemconfig'
+
+module TkMenuEntryConfig
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'entrycget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'entryconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+
+ alias entrycget itemcget
+ alias entryconfigure itemconfigure
+ alias entryconfiginfo itemconfiginfo
+ alias current_entryconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+end
+
+class TkMenu<TkWindow
+ include TkMenuEntryConfig
+
+ TkCommandNames = ['menu'.freeze].freeze
+ WidgetClassName = 'Menu'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('menu', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('menu', @path)
+ # end
+ #end
+ #private :create_self
+
+ def tagid(id)
+ #id.to_s
+ _get_eval_string(id)
+ end
+
+ def activate(index)
+ tk_send_without_enc('activate', _get_eval_enc_str(index))
+ self
+ end
+ def add(type, keys=nil)
+ tk_send_without_enc('add', type, *hash_kv(keys, true))
+ self
+ end
+ def add_cascade(keys=nil)
+ add('cascade', keys)
+ end
+ def add_checkbutton(keys=nil)
+ add('checkbutton', keys)
+ end
+ def add_command(keys=nil)
+ add('command', keys)
+ end
+ def add_radiobutton(keys=nil)
+ add('radiobutton', keys)
+ end
+ def add_separator(keys=nil)
+ add('separator', keys)
+ end
+ def index(index)
+ ret = tk_send_without_enc('index', _get_eval_enc_str(index))
+ (ret == 'none')? nil: number(ret)
+ end
+ def invoke(index)
+ _fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index)))
+ end
+ def insert(index, type, keys=nil)
+ tk_send_without_enc('insert', _get_eval_enc_str(index),
+ type, *hash_kv(keys, true))
+ self
+ end
+ def delete(first, last=nil)
+ if last
+ tk_send_without_enc('delete', _get_eval_enc_str(first),
+ _get_eval_enc_str(last))
+ else
+ tk_send_without_enc('delete', _get_eval_enc_str(first))
+ end
+ self
+ end
+ def popup(x, y, index=nil)
+ if index
+ tk_call_without_enc('tk_popup', path, x, y,
+ _get_eval_enc_str(index))
+ else
+ tk_call_without_enc('tk_popup', path, x, y)
+ end
+ self
+ end
+ def post(x, y)
+ _fromUTF8(tk_send_without_enc('post', x, y))
+ end
+ def postcascade(index)
+ tk_send_without_enc('postcascade', _get_eval_enc_str(index))
+ self
+ end
+ def postcommand(cmd=Proc.new)
+ configure_cmd 'postcommand', cmd
+ self
+ end
+ def set_focus
+ tk_call_without_enc('tk_menuSetFocus', path)
+ self
+ end
+ def tearoffcommand(cmd=Proc.new)
+ configure_cmd 'tearoffcommand', cmd
+ self
+ end
+ def menutype(index)
+ tk_send_without_enc('type', _get_eval_enc_str(index))
+ end
+ def unpost
+ tk_send_without_enc('unpost')
+ self
+ end
+ def yposition(index)
+ number(tk_send_without_enc('yposition', _get_eval_enc_str(index)))
+ end
+
+=begin
+ def entrycget(index, key)
+ case key.to_s
+ when 'text', 'label', 'show'
+ _fromUTF8(tk_send_without_enc('entrycget',
+ _get_eval_enc_str(index), "-#{key}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(index, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), "-#{key}")))
+ end
+ end
+ def entryconfigure(index, key, val=None)
+ if key.kind_of? Hash
+ if (key['font'] || key[:font] ||
+ key['kanjifont'] || key[:kanjifont] ||
+ key['latinfont'] || key[:latinfont] ||
+ key['asciifont'] || key[:asciifont])
+ tagfont_configure(index, _symbolkey2str(key))
+ else
+ tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
+ *hash_kv(key, true))
+ end
+
+ else
+ if (key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont )
+ if val == None
+ tagfontobj(index)
+ else
+ tagfont_configure(index, {key=>val})
+ end
+ else
+ tk_call('entryconfigure', index, "-#{key}", val)
+ end
+ end
+ self
+ end
+
+ def entryconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
+ end
+ end
+ end
+
+ def current_entryconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = entryconfiginfo(index, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ entryconfiginfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ entryconfiginfo(index, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+end
+
+
+class TkMenuClone<TkMenu
+ def initialize(parent, type=None)
+ widgetname = nil
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ widgetname = keys.delete('widgetname')
+ type = keys.delete('type'); type = None unless type
+ end
+ #unless parent.kind_of?(TkMenu)
+ # fail ArgumentError, "parent must be TkMenu"
+ #end
+ @parent = parent
+ install_win(@parent.path, widgetname)
+ tk_call_without_enc(@parent.path, 'clone', @path, type)
+ end
+end
+
+
+module TkSystemMenu
+ def initialize(parent, keys=nil)
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ end
+ #unless parent.kind_of? TkMenu
+ # fail ArgumentError, "parent must be a TkMenu object"
+ #end
+ # @path = Kernel.format("%s.%s", parent.path, self.class::SYSMENU_NAME)
+ @path = parent.path + '.' + self.class::SYSMENU_NAME
+ #TkComm::Tk_WINDOWS[@path] = self
+ TkCore::INTERP.tk_windows[@path] = self
+ if self.method(:create_self).arity == 0
+ p 'create_self has no arg' if $DEBUG
+ create_self
+ configure(keys) if keys
+ else
+ p 'create_self has an arg' if $DEBUG
+ create_self(keys)
+ end
+ end
+end
+
+
+class TkSysMenu_Help<TkMenu
+ # for all platform
+ include TkSystemMenu
+ SYSMENU_NAME = 'help'
+end
+
+
+class TkSysMenu_System<TkMenu
+ # for Windows
+ include TkSystemMenu
+ SYSMENU_NAME = 'system'
+end
+
+
+class TkSysMenu_Apple<TkMenu
+ # for Machintosh
+ include TkSystemMenu
+ SYSMENU_NAME = 'apple'
+end
+
+
+class TkMenubutton<TkLabel
+ TkCommandNames = ['menubutton'.freeze].freeze
+ WidgetClassName = 'Menubutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('menubutton', @path)
+ end
+ end
+ private :create_self
+end
+
+
+class TkOptionMenubutton<TkMenubutton
+ TkCommandNames = ['tk_optionMenu'.freeze].freeze
+
+ class OptionMenu<TkMenu
+ def initialize(path) #==> return value of tk_optionMenu
+ @path = path
+ #TkComm::Tk_WINDOWS[@path] = self
+ TkCore::INTERP.tk_windows[@path] = self
+ end
+ end
+
+ def initialize(parent=nil, var=nil, firstval=nil, *vals)
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys['parent']
+ var = keys['variable'] if keys['variable']
+ firstval, *vals = keys['values']
+ end
+ if parent.kind_of? TkVariable
+ vals.unshift(firstval) if firstval
+ firstval = var
+ var = parent
+ parent = nil
+ end
+ var = TkVariable.new unless var
+ fail 'variable option must be TkVariable' unless var.kind_of? TkVariable
+ @variable = var
+ firstval = @variable.value unless firstval
+ @variable.value = firstval
+ install_win(if parent then parent.path end)
+ @menu = OptionMenu.new(tk_call('tk_optionMenu', @path, @variable.id,
+ firstval, *vals))
+ end
+
+ def value
+ @variable.value
+ end
+
+ def activate(index)
+ @menu.activate(index)
+ self
+ end
+ def add(value)
+ @menu.add('radiobutton', 'variable'=>@variable,
+ 'label'=>value, 'value'=>value)
+ self
+ end
+ def index(index)
+ @menu.index(index)
+ end
+ def invoke(index)
+ @menu.invoke(index)
+ end
+ def insert(index, value)
+ @menu.insert(index, 'radiobutton', 'variable'=>@variable,
+ 'label'=>value, 'value'=>value)
+ self
+ end
+ def delete(index, last=None)
+ @menu.delete(index, last)
+ self
+ end
+ def yposition(index)
+ @menu.yposition(index)
+ end
+ def menu
+ @menu
+ end
+ def menucget(key)
+ @menu.cget(key)
+ end
+ def menuconfigure(key, val=None)
+ @menu.configure(key, val)
+ self
+ end
+ def menuconfiginfo(key=nil)
+ @menu.configinfo(key)
+ end
+ def current_menuconfiginfo(key=nil)
+ @menu.current_configinfo(key)
+ end
+ def entrycget(index, key)
+ @menu.entrycget(index, key)
+ end
+ def entryconfigure(index, key, val=None)
+ @menu.entryconfigure(index, key, val)
+ self
+ end
+ def entryconfiginfo(index, key=nil)
+ @menu.entryconfiginfo(index, key)
+ end
+ def current_entryconfiginfo(index, key=nil)
+ @menu.current_entryconfiginfo(index, key)
+ end
+end
diff --git a/ext/tk/lib/tk/menubar.rb b/ext/tk/lib/tk/menubar.rb
new file mode 100644
index 0000000000..392b6fbd4e
--- /dev/null
+++ b/ext/tk/lib/tk/menubar.rb
@@ -0,0 +1,131 @@
+#
+# tk/menubar.rb
+#
+# Original version:
+# Copyright (C) 1998 maeda shugo. All rights reserved.
+# This file can be distributed under the terms of the Ruby.
+
+# Usage:
+#
+# menu_spec = [
+# [['File', 0],
+# ['Open', proc{puts('Open clicked')}, 0],
+# '---',
+# ['Quit', proc{exit}, 0]],
+# [['Edit', 0],
+# ['Cut', proc{puts('Cut clicked')}, 2],
+# ['Copy', proc{puts('Copy clicked')}, 0],
+# ['Paste', proc{puts('Paste clicked')}, 0]]
+# ]
+# menubar = TkMenubar.new(nil, menu_spec,
+# 'tearoff'=>false,
+# 'foreground'=>'grey40',
+# 'activeforeground'=>'red',
+# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1')
+# menubar.pack('side'=>'top', 'fill'=>'x')
+#
+#
+# OR
+#
+#
+# menubar = TkMenubar.new
+# menubar.add_menu([['File', 0],
+# ['Open', proc{puts('Open clicked')}, 0],
+# '---',
+# ['Quit', proc{exit}, 0]])
+# menubar.add_menu([['Edit', 0],
+# ['Cut', proc{puts('Cut clicked')}, 2],
+# ['Copy', proc{puts('Copy clicked')}, 0],
+# ['Paste', proc{puts('Paste clicked')}, 0]])
+# menubar.configure('tearoff', false)
+# menubar.configure('foreground', 'grey40')
+# menubar.configure('activeforeground', 'red')
+# menubar.configure('font', '-adobe-helvetica-bold-r-*--12-*-iso8859-1')
+# menubar.pack('side'=>'top', 'fill'=>'x')
+#
+#
+# OR
+#
+# radio_var = TkVariable.new('y')
+# menu_spec = [
+# [['File', 0],
+# {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
+# '---',
+# ['Check_A', TkVariable.new(true), 6],
+# {:type=>'checkbutton', :label=>'Check_B',
+# :variable=>TkVariable.new, :underline=>6},
+# '---',
+# ['Radio_X', [radio_var, 'x'], 6],
+# ['Radio_Y', [radio_var, 'y'], 6],
+# ['Radio_Z', [radio_var, 'z'], 6],
+# '---',
+# ['cascade', [
+# ['sss', proc{p 'sss'}, 0],
+# ['ttt', proc{p 'ttt'}, 0],
+# ['uuu', proc{p 'uuu'}, 0],
+# ['vvv', proc{p 'vvv'}, 0],
+# ], 0],
+# '---',
+# ['Quit', proc{exit}, 0]],
+# [['Edit', 0],
+# ['Cut', proc{puts('Cut clicked')}, 2],
+# ['Copy', proc{puts('Copy clicked')}, 0],
+# ['Paste', proc{puts('Paste clicked')}, 0]]
+# ]
+# menubar = TkMenubar.new(nil, menu_spec,
+# 'tearoff'=>false,
+# 'foreground'=>'grey40',
+# 'activeforeground'=>'red',
+# 'font'=>'Helvetia 12 bold')
+# menubar.pack('side'=>'top', 'fill'=>'x')
+
+# See tk/menuspce.rb about the format of the menu_spec
+
+# To use add_menu, configuration must be done by calling configure after
+# adding all menus by add_menu, not by the constructor arguments.
+
+require 'tk'
+require 'tk/frame'
+require 'tk/composite'
+require 'tk/menuspec'
+
+class TkMenubar<TkFrame
+ include TkComposite
+ include TkMenuSpec
+
+ def initialize(parent = nil, spec = nil, options = nil)
+ if parent.kind_of? Hash
+ options = _symbolkey2str(parent)
+ spec = options.delete('spec')
+ super(options)
+ else
+ super(parent, options)
+ end
+
+ @menus = []
+
+ spec.each{|info| add_menu(info)} if spec
+
+ options.each{|key, value| configure(key, value)} if options
+ end
+
+ def add_menu(menu_info)
+ mbtn, menu = _create_menubutton(@frame, menu_info)
+
+ submenus = _get_cascade_menus(menu).flatten
+
+ @menus.push([mbtn, menu])
+ delegate('tearoff', menu, *submenus)
+ delegate('foreground', mbtn, menu, *submenus)
+ delegate('background', mbtn, menu, *submenus)
+ delegate('disabledforeground', mbtn, menu, *submenus)
+ delegate('activeforeground', mbtn, menu, *submenus)
+ delegate('activebackground', mbtn, menu, *submenus)
+ delegate('font', mbtn, menu, *submenus)
+ delegate('kanjifont', mbtn, menu, *submenus)
+ end
+
+ def [](index)
+ return @menus[index]
+ end
+end
diff --git a/ext/tk/lib/tk/menuspec.rb b/ext/tk/lib/tk/menuspec.rb
new file mode 100644
index 0000000000..c8819f8e41
--- /dev/null
+++ b/ext/tk/lib/tk/menuspec.rb
@@ -0,0 +1,265 @@
+#
+# tk/menuspec.rb
+# Hidethoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# based on tkmenubar.rb :
+# Copyright (C) 1998 maeda shugo. All rights reserved.
+# This file can be distributed under the terms of the Ruby.
+#
+# The format of the menu_spec is:
+# [ menu_info, menu_info, ... ]
+#
+# And the format of the menu_info is:
+# [
+# [text, underline, configs], # menu button/entry (*1)
+# [label, command, underline, accelerator, configs], # command entry
+# [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry
+# [label, [TkVar_obj, value],
+# underline, accelerator, configs], # radiobutton entry
+# [label, [[...menu_info...], [...menu_info...], ...],
+# underline, accelerator, configs], # cascade entry
+# '---', # separator
+# ...
+# ]
+#
+# underline, accelerator, and configs are optional pearameters.
+# Hashes are OK instead of Arrays. Then the entry type ('command',
+# 'checkbutton', 'radiobutton' or 'cascade') is given by 'type' key
+# (e.g. :type=>'cascade'). When type is 'cascade', an array of menu_info
+# is acceptable for 'menu' key (then, create sub-menu).
+#
+# NOTE: (*1)
+# If you want to make special menus (*.help for UNIX, *.system for Win,
+# and *.apple for Mac), append 'menu_name'=>name (name is 'help' for UNIX,
+# 'system' for Win, and 'apple' for Mac) option to the configs hash of
+# menu button/entry information.
+
+module TkMenuSpec
+ def _create_menu(parent, menu_info, menu_name = nil,
+ tearoff = false, default_opts = nil)
+ if tearoff.kind_of?(Hash)
+ default_opts = tearoff
+ tearoff = false
+ end
+
+ if menu_name.kind_of?(Hash)
+ default_opts = menu_name
+ menu_name = nil
+ tearoff = false
+ end
+
+ if default_opts.kind_of?(Hash)
+ orig_opts = _symbolkey2str(default_opts)
+ else
+ orig_opts = {}
+ end
+
+ tearoff = orig_opts.delete('tearoff') if orig_opts.key?('tearoff')
+
+ if menu_name
+ menu = TkMenu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff)
+ else
+ menu = TkMenu.new(parent, :tearoff=>tearoff)
+ end
+
+ for item_info in menu_info
+ if item_info.kind_of?(Hash)
+ options = orig_opts.dup
+ options.update(_symbolkey2str(item_info))
+ item_type = (options.delete('type') || 'command').to_s
+ menu_name = options.delete('menu_name')
+ menu_opts = orig_opts.dup
+ menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
+ if item_type == 'cascade' && options['menu'].kind_of?(Array)
+ # create cascade menu
+ submenu = _create_menu(menu, options['menu'], menu_name,
+ tearoff, menu_opts)
+ options['menu'] = submenu
+ end
+ menu.add(item_type, options)
+
+ elsif item_info.kind_of?(Array)
+ options = orig_opts.dup
+
+ options['label'] = item_info[0] if item_info[0]
+
+ case item_info[1]
+ when TkVariable
+ # checkbutton
+ item_type = 'checkbutton'
+ options['variable'] = item_info[1]
+ options['onvalue'] = true
+ options['offvalue'] = false
+
+ when Array
+ # radiobutton or cascade
+ if item_info[1][0].kind_of?(TkVariable)
+ # radiobutton
+ item_type = 'radiobutton'
+ options['variable'] = item_info[1][0]
+ options['value'] = item_info[1][1] if item_info[1][1]
+
+ else
+ # cascade
+ item_type = 'cascade'
+ menu_opts = orig_opts.dup
+ if item_info[4] && item_info[4].kind_of?(Hash)
+ opts = _symbolkey2str(item_info[4])
+ menu_name = opts.delete('menu_name')
+ menu_config = opts.delete('menu_config') || {}
+ menu_opts.update(_symbolkey2str(menu_config))
+ end
+ submenu = _create_menu(menu, item_info[1], menu_name,
+ tearoff, menu_opts)
+ options['menu'] = submenu
+ end
+
+ else
+ # command
+ item_type = 'command'
+ options['command'] = item_info[1] if item_info[1]
+ end
+
+ options['underline'] = item_info[2] if item_info[2]
+ options['accelerator'] = item_info[3] if item_info[3]
+ if item_info[4] && item_info[4].kind_of?(Hash)
+ opts = _symbolkey2str(item_info[4])
+ if item_type == 'cascade'
+ opts.delete('menu_name')
+ opts.delete('menu_config')
+ end
+ options.update(opts)
+ end
+ menu.add(item_type, options)
+
+ elsif /^-+$/ =~ item_info
+ menu.add('separator')
+
+ else
+ menu.add('command', 'label' => item_info)
+ end
+ end
+
+ menu
+ end
+ private :_create_menu
+
+ def _use_menubar?(parent)
+ use_menubar = false
+ if parent.kind_of?(TkRoot) || parent.kind_of?(TkToplevel)
+ return true
+ else
+ begin
+ parent.cget('menu')
+ return true
+ rescue
+ end
+ end
+ false
+ end
+ private :_use_menubar?
+
+ def _create_menu_for_menubar(parent)
+ unless (mbar = parent.menu).kind_of?(TkMenu)
+ mbar = TkMenu.new(parent, :tearoff=>false)
+ parent.menu(mbar)
+ end
+ mbar
+ end
+ private :_create_menu_for_menubar
+
+ def _create_menubutton(parent, menu_info, tearoff=false, default_opts = nil)
+ btn_info = menu_info[0]
+
+ if tearoff.kind_of?(Hash)
+ default_opts = tearoff
+ tearoff = false
+ end
+
+ if default_opts.kind_of?(Hash)
+ keys = _symbolkey2str(default_opts)
+ else
+ keys = {}
+ end
+
+ tearoff = keys.delete('tearoff') if keys.key?('tearoff')
+
+ if _use_menubar?(parent)
+ # menubar by menu entries
+
+ mbar = _create_menu_for_menubar(parent)
+
+ menu_name = nil
+
+ if btn_info.kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info))
+ menu_name = keys.delete('menu_name')
+ keys['label'] = keys.delete('text') if keys.key?('text')
+ elsif btn_info.kind_of?(Array)
+ keys['label'] = btn_info[0] if btn_info[0]
+ keys['underline'] = btn_info[1] if btn_info[1]
+ if btn_info[2]&&btn_info[2].kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info[2]))
+ menu_name = keys.delete('menu_name')
+ end
+ else
+ keys = {:label=>btn_info}
+ end
+
+ menu = _create_menu(mbar, menu_info[1..-1], menu_name,
+ tearoff, default_opts)
+ menu.tearoff(tearoff)
+
+ keys['menu'] = menu
+ mbar.add('cascade', keys)
+
+ [mbar, menu]
+
+ else
+ # menubar by menubuttons
+ mbtn = TkMenubutton.new(parent)
+
+ menu_name = nil
+
+ if btn_info.kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info))
+ menu_name = keys.delete('menu_name')
+ keys['text'] = keys.delete('label') if keys.key?('label')
+ mbtn.configure(keys)
+ elsif btn_info.kind_of?(Array)
+ mbtn.configure('text', btn_info[0]) if btn_info[0]
+ mbtn.configure('underline', btn_info[1]) if btn_info[1]
+ # mbtn.configure('accelerator', btn_info[2]) if btn_info[2]
+ if btn_info[2]&&btn_info[2].kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info[2]))
+ menu_name = keys.delete('menu_name')
+ mbtn.configure(keys)
+ end
+ else
+ mbtn.configure('text', btn_info)
+ end
+
+ mbtn.pack('side' => 'left')
+
+ menu = _create_menu(mbtn, menu_info[1..-1], menu_name,
+ tearoff, default_opts)
+
+ mbtn.menu(menu)
+
+ [mbtn, menu]
+ end
+ end
+ private :_create_menubutton
+
+ def _get_cascade_menus(menu)
+ menus = []
+ (0..(menu.index('last'))).each{|idx|
+ if menu.menutype(idx) == 'cascade'
+ submenu = menu.entrycget(idx, 'menu')
+ menus << [submenu, _get_cascade_menus(submenu)]
+ end
+ }
+ menus
+ end
+ private :_get_cascade_menus
+end
diff --git a/ext/tk/lib/tk/message.rb b/ext/tk/lib/tk/message.rb
new file mode 100644
index 0000000000..79121bebb3
--- /dev/null
+++ b/ext/tk/lib/tk/message.rb
@@ -0,0 +1,19 @@
+#
+# tk/message.rb : treat message widget
+#
+require 'tk'
+require 'tk/label'
+
+class TkMessage<TkLabel
+ TkCommandNames = ['message'.freeze].freeze
+ WidgetClassName = 'Message'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('message', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('message', @path)
+ # end
+ #end
+ private :create_self
+end
diff --git a/ext/tk/lib/tk/mngfocus.rb b/ext/tk/lib/tk/mngfocus.rb
new file mode 100644
index 0000000000..a0f18233be
--- /dev/null
+++ b/ext/tk/lib/tk/mngfocus.rb
@@ -0,0 +1,33 @@
+#
+# tk/mngfocus.rb : methods for Tcl/Tk standard library 'focus.tcl'
+# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+module TkManageFocus
+ extend Tk
+
+ TkCommandNames = [
+ 'tk_focusFollowMouse'.freeze,
+ 'tk_focusNext'.freeze,
+ 'tk_focusPrev'.freeze
+ ].freeze
+
+ def TkManageFocus.followsMouse
+ tk_call_without_enc('tk_focusFollowsMouse')
+ end
+
+ def TkManageFocus.next(window)
+ tk_tcl2ruby(tk_call('tk_focusNext', window))
+ end
+ def focusNext
+ TkManageFocus.next(self)
+ end
+
+ def TkManageFocus.prev(window)
+ tk_tcl2ruby(tk_call('tk_focusPrev', window))
+ end
+ def focusPrev
+ TkManageFocus.prev(self)
+ end
+end
diff --git a/ext/tk/lib/tk/msgcat.rb b/ext/tk/lib/tk/msgcat.rb
new file mode 100644
index 0000000000..4e095c6fc0
--- /dev/null
+++ b/ext/tk/lib/tk/msgcat.rb
@@ -0,0 +1,286 @@
+#
+# tk/msgcat.rb : methods for Tcl message catalog
+# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+#class TkMsgCatalog
+class TkMsgCatalog < TkObject
+ include TkCore
+ extend Tk
+ #extend TkMsgCatalog
+
+ TkCommandNames = [
+ '::msgcat::mc'.freeze,
+ '::msgcat::mcmax'.freeze,
+ '::msgcat::mclocale'.freeze,
+ '::msgcat::mcpreferences'.freeze,
+ '::msgcat::mcload'.freeze,
+ '::msgcat::mcset'.freeze,
+ '::msgcat::mcmset'.freeze,
+ '::msgcat::mcunknown'.freeze
+ ].freeze
+
+ tk_call_without_enc('package', 'require', 'Tcl', '8.2')
+
+ if self.const_defined? :FORCE_VERSION
+ tk_call_without_enc('package', 'require', 'msgcat', FORCE_VERSION)
+ else
+ tk_call_without_enc('package', 'require', 'msgcat')
+ end
+
+ MSGCAT_EXT = '.msg'
+
+ UNKNOWN_CBTBL = Hash.new{|hash,key| hash[key] = {}}.taint
+
+ TkCore::INTERP.add_tk_procs('::msgcat::mcunknown', 'args', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkMsgCatalog callback} [namespace current] $args} ret]] != 0} {
+ #return -code $st $ret
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ return -code $st \
+ -errorinfo [string range $ret [expr $idx + 2] \
+ [string length $ret]] \
+ [string range $ret 0 [expr $idx - 1]]
+ } else {
+ return -code $st $ret
+ }
+ } else {
+ return $ret
+ }
+ EOL
+
+ def self.callback(namespace, locale, src_str, *args)
+ src_str = sprintf(src_str, *args) unless args.empty?
+ cmd_tbl = TkMsgCatalog::UNKNOWN_CBTBL[TkCore::INTERP.__getip]
+ cmd = cmd_tbl[namespace]
+ cmd = cmd_tbl['::'] unless cmd # use global scope as interp default
+ return src_str unless cmd # no cmd -> return src-str (default action)
+ begin
+ cmd.call(locale, src_str)
+ rescue SystemExit
+ exit(0)
+ rescue Interrupt
+ exit!(1)
+ rescue Exception => e
+ begin
+ msg = _toUTF8(e.class.inspect) + ': ' +
+ _toUTF8(e.message) + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ _toUTF8(e.backtrace.join("\n")) +
+ "\n---< backtrace of Tk side >-------"
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ rescue Exception
+ msg = e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------"
+ end
+ fail(e, msg)
+ end
+ end
+
+ def initialize(namespace = nil)
+ if namespace.kind_of?(TkNamespace)
+ @namespace = namespace
+ elsif namespace == nil
+ @namespace = TkNamespace.new('::') # global namespace
+ else
+ @namespace = TkNamespace.new(namespace)
+ end
+ @path = @namespace.path
+
+ @msgcat_ext = '.msg'
+ end
+ attr_accessor :msgcat_ext
+
+ def method_missing(id, *args)
+ # locale(src, trans) ==> set_translation(locale, src, trans)
+ loc = id.id2name
+ case args.length
+ when 0 # set locale
+ self.locale=(loc)
+
+ when 1 # src only, or trans_list
+ if args[0].kind_of?(Array)
+ # trans_list
+ #list = args[0].collect{|src, trans|
+ # [ Tk::UTF8_String.new(src), Tk::UTF8_String.new(trans) ]
+ #}
+ self.set_translation_list(loc, args[0])
+ else
+ # src
+ #self.set_translation(loc, Tk::UTF8_String.new(args[0]))
+ self.set_translation(loc, args[0])
+ end
+
+ when 2 # src and trans, or, trans_list and enc
+ if args[0].kind_of?(Array)
+ else
+ #self.set_translation(loc, args[0], Tk::UTF8_String.new(args[1]))
+ self.set_translation(loc, *args)
+ end
+
+ when 3 # src and trans and enc
+ self.set_translation(loc, *args)
+
+ else
+ fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
+
+ end
+ end
+
+ # *args ::= form, arg, arg, ...
+ def self.translate(*args)
+ dst = args.collect{|src|
+ tk_call_without_enc('::msgcat::mc', _get_eval_string(src, true))
+ }
+ Tk.UTF8_String(sprintf(*dst))
+ end
+ class << self
+ alias mc translate
+ alias [] translate
+ end
+ def translate(*args)
+ dst = args.collect{|src|
+ @namespace.eval{tk_call_without_enc('::msgcat::mc',
+ _get_eval_string(src, true))}
+ }
+ Tk.UTF8_String(sprintf(*dst))
+ end
+ alias mc translate
+ alias [] translate
+
+ def self.maxlen(*src_strings)
+ tk_call('::msgcat::mcmax', *src_strings).to_i
+ end
+ def maxlen(*src_strings)
+ @namespace.eval{tk_call('::msgcat::mcmax', *src_strings).to_i}
+ end
+
+ def self.locale
+ tk_call('::msgcat::mclocale')
+ end
+ def locale
+ @namespace.eval{tk_call('::msgcat::mclocale')}
+ end
+
+ def self.locale=(locale)
+ tk_call('::msgcat::mclocale', locale)
+ end
+ def locale=(locale)
+ @namespace.eval{tk_call('::msgcat::mclocale', locale)}
+ end
+
+ def self.preferences
+ tk_split_simplelist(tk_call('::msgcat::mcpreferences'))
+ end
+ def preferences
+ tk_split_simplelist(@namespace.eval{tk_call('::msgcat::mcpreferences')})
+ end
+
+ def self.load_tk(dir)
+ number(tk_call('::msgcat::mcload', dir))
+ end
+
+ def self.load_rb(dir)
+ count = 0
+ preferences().each{|loc|
+ file = File.join(dir, loc + self::MSGCAT_EXT)
+ if File.readable?(file)
+ count += 1
+ eval(open(file){|f| f.read})
+ end
+ }
+ count
+ end
+
+ def load_tk(dir)
+ number(@namespace.eval{tk_call('::msgcat::mcload', dir)})
+ end
+
+ def load_rb(dir)
+ count = 0
+ preferences().each{|loc|
+ file = File.join(dir, loc + @msgcat_ext)
+ if File.readable?(file)
+ count += 1
+ @namespace.eval(open(file){|f| f.read})
+ end
+ }
+ count
+ end
+
+ def self.load(dir)
+ self.load_rb(dir)
+ end
+ alias load load_rb
+
+ def self.set_translation(locale, src_str, trans_str=None, enc='utf-8')
+ if trans_str && trans_str != None
+ trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
+ Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
+ locale,
+ _get_eval_string(src_str, true),
+ trans_str))
+ else
+ Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
+ locale,
+ _get_eval_string(src_str, true)))
+ end
+ end
+ def set_translation(locale, src_str, trans_str=None, enc='utf-8')
+ if trans_str && trans_str != None
+ trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
+ Tk.UTF8_String(@namespace.eval{
+ tk_call_without_enc('::msgcat::mcset',
+ locale,
+ _get_eval_string(src_str, true),
+ trans_str)
+ })
+ else
+ Tk.UTF8_String(@namespace.eval{
+ tk_call_without_enc('::msgcat::mcset',
+ locale,
+ _get_eval_string(src_str, true))})
+ end
+ end
+
+ def self.set_translation_list(locale, trans_list, enc='utf-8')
+ # trans_list ::= [ [src, trans], [src, trans], ... ]
+ list = []
+ trans_list.each{|src, trans|
+ if trans && trans != None
+ list << _get_eval_string(src, true)
+ list << Tk.UTF8_Stirng(_toUTF8(trans, enc))
+ else
+ list << _get_eval_string(src, true) << ''
+ end
+ }
+ number(tk_call_without_enc('::msgcat::mcmset', locale, list))
+ end
+ def set_translation_list(locale, trans_list, enc='utf-8')
+ # trans_list ::= [ [src, trans], [src, trans], ... ]
+ list = []
+ trans_list.each{|src, trans|
+ if trans && trans != None
+ list << _get_eval_string(src, true)
+ list << Tk.UTF8_String(_toUTF8(trans, enc))
+ else
+ list << _get_eval_string(src, true) << ''
+ end
+ }
+ number(@namespace.eval{
+ tk_call_without_enc('::msgcat::mcmset', locale, list)
+ })
+ end
+
+ def self.def_unknown_proc(cmd=Proc.new)
+ TkMsgCatalog::UNKNOWN_CBTBL[TkCore::INTERP.__getip]['::'] = cmd
+ end
+ def def_unknown_proc(cmd=Proc.new)
+ TkMsgCatalog::UNKNOWN_CBTBL[TkCore::INTERP.__getip][@namespace.path] = cmd
+ end
+end
+
+TkMsgCat = TkMsgCatalog
diff --git a/ext/tk/lib/tk/namespace.rb b/ext/tk/lib/tk/namespace.rb
new file mode 100644
index 0000000000..a236fb6a99
--- /dev/null
+++ b/ext/tk/lib/tk/namespace.rb
@@ -0,0 +1,294 @@
+#
+# tk/namespace.rb : methods to manipulate Tcl/Tk namespace
+# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+class TkNamespace < TkObject
+ extend Tk
+
+ TkCommandNames = [
+ 'namespace'.freeze,
+ ].freeze
+
+ Tk_Namespace_ID_TBL = TkCore::INTERP.create_table
+ Tk_Namespace_ID = ["ns".freeze, "00000".taint].freeze
+
+ class ScopeArgs < Array
+ include Tk
+
+ # alias __tk_call tk_call
+ # alias __tk_call_without_enc tk_call_without_enc
+ # alias __tk_call_with_enc tk_call_with_enc
+ def tk_call(*args)
+ #super('namespace', 'eval', @namespace, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ super('namespace', 'eval', @namespace,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_without_enc(*args)
+ #super('namespace', 'eval', @namespace, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ super('namespace', 'eval', @namespace,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_with_enc(*args)
+ #super('namespace', 'eval', @namespace, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ super('namespace', 'eval', @namespace,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+
+ def initialize(namespace, *args)
+ @namespace = namespace
+ super(args.size)
+ self.replace(args)
+ end
+ end
+
+ class NsCode < TkObject
+ def initialize(scope)
+ @scope = scope + ' '
+ end
+ def path
+ @scope
+ end
+ def to_eval
+ @scope
+ end
+ def call(*args)
+ TkCore::INTERP._eval_without_enc(@scope + array2tk_list(args))
+ end
+ end
+
+ alias __tk_call tk_call
+ alias __tk_call_without_enc tk_call_without_enc
+ alias __tk_call_with_enc tk_call_with_enc
+ def tk_call(*args)
+ #super('namespace', 'eval', @fullname, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ super('namespace', 'eval', @fullname,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_without_enc(*args)
+ #super('namespace', 'eval', @fullname, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ super('namespace', 'eval', @fullname,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_with_enc(*args)
+ #super('namespace', 'eval', @fullname, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''}
+ super('namespace', 'eval', @fullname,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ alias ns_tk_call tk_call
+ alias ns_tk_call_without_enc tk_call_without_enc
+ alias ns_tk_call_with_enc tk_call_with_enc
+
+ def initialize(name = nil, parent = nil)
+ unless name
+ # name = Tk_Namespace_ID.join('')
+ name = Tk_Namespace_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Namespace_ID[1].succ!
+ end
+ name = __tk_call('namespace', 'current') if name == ''
+ if parent
+ if parent =~ /^::/
+ if name =~ /^::/
+ @fullname = parent + name
+ else
+ @fullname = parent +'::'+ name
+ end
+ else
+ ancestor = __tk_call('namespace', 'current')
+ ancestor = '' if ancestor == '::'
+ if name =~ /^::/
+ @fullname = ancestor + '::' + parent + name
+ else
+ @fullname = ancestor + '::'+ parent +'::'+ name
+ end
+ end
+ else # parent == nil
+ ancestor = __tk_call('namespace', 'current')
+ ancestor = '' if ancestor == '::'
+ if name =~ /^::/
+ @fullname = name
+ else
+ @fullname = ancestor + '::' + name
+ end
+ end
+ @path = @fullname
+ @parent = __tk_call('namespace', 'qualifiers', @fullname)
+ @name = __tk_call('namespace', 'tail', @fullname)
+
+ # create namespace
+ __tk_call('namespace', 'eval', @fullname, '')
+
+ Tk_Namespace_ID_TBL[@fullname] = self
+ end
+
+ def self.children(*args)
+ # args ::= [<namespace>] [<pattern>]
+ # <pattern> must be glob-style pattern
+ tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns|
+ # ns is fullname
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
+ end
+ def children(pattern=None)
+ TkNamespace.children(@fullname, pattern)
+ end
+
+ def self.code(script = Proc.new)
+ TkNamespace.new('').code(script)
+ end
+ def code(script = Proc.new)
+ if script.kind_of?(String)
+ cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(script)}
+ elsif script.kind_of?(Proc)
+ cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(&script)}
+ else
+ fail ArgumentError, "String or Proc is expected"
+ end
+ TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
+ _get_eval_string(cmd, false)))
+ end
+
+ def self.current
+ tk_call('namespace', 'current')
+ end
+ def current_namespace
+ # ns_tk_call('namespace', 'current')
+ @fullname
+ end
+ alias current current_namespace
+
+ def self.delete(*ns_list)
+ tk_call('namespace', 'delete', *ns_list)
+ end
+ def delete
+ TkNamespece.delete(@fullname)
+ end
+
+ def self.ensemble_create(*keys)
+ tk_call('namespace', 'ensemble', 'create', *hash_kv(keys))
+ end
+ def self.ensemble_configure(cmd, slot, value=None)
+ if slot.kind_of?(Hash)
+ tk_call('namespace', 'ensemble', 'configure', cmd, *hash_kv(slot))
+ else
+ tk_call('namespace', 'ensemble', 'configure', cmd, '-'+slot.to_s, value)
+ end
+ end
+ def self.ensemble_configinfo(cmd, slot = nil)
+ if slot
+ tk_call('namespace', 'ensemble', 'configure', cmd, '-' + slot.to_s)
+ else
+ inf = {}
+ Hash(*tk_split_simplelist(tk_call('namespace', 'ensemble', 'configure', cmd))).each{|k, v| inf[k[1..-1]] = v}
+ inf
+ end
+ end
+ def self.ensemble_exist?(cmd)
+ bool(tk_call('namespace', 'ensemble', 'exists', cmd))
+ end
+
+ def self.eval(namespace, cmd = Proc.new, *args)
+ #tk_call('namespace', 'eval', namespace, cmd, *args)
+ TkNamespace.new(namespece).eval(cmd, *args)
+ end
+ def eval(cmd = Proc.new, *args)
+ #TkNamespace.eval(@fullname, cmd, *args)
+ #ns_tk_call(cmd, *args)
+ code_obj = code(cmd)
+ ret = code_obj.call(*args)
+ uninstall_cmd(TkCore::INTERP._split_tklist(code_obj.path)[-1])
+ ret
+ end
+
+ def self.exist?(ns)
+ bool(tk_call('namespace', 'exists', ns))
+ end
+ def exist?
+ TkNamespece.delete(@fullname)
+ end
+
+ def self.export(*patterns)
+ tk_call('namespace', 'export', *patterns)
+ end
+ def self.export_with_clear(*patterns)
+ tk_call('namespace', 'export', '-clear', *patterns)
+ end
+ def export
+ TkNamespace.export(@fullname)
+ end
+ def export_with_clear
+ TkNamespace.export_with_clear(@fullname)
+ end
+
+ def self.forget(*patterns)
+ tk_call('namespace', 'forget', *patterns)
+ end
+ def forget
+ TkNamespace.forget(@fullname)
+ end
+
+ def self.import(*patterns)
+ tk_call('namespace', 'import', *patterns)
+ end
+ def self.force_import(*patterns)
+ tk_call('namespace', 'import', '-force', *patterns)
+ end
+ def import
+ TkNamespace.import(@fullname)
+ end
+ def force_import
+ TkNamespace.force_import(@fullname)
+ end
+
+ def self.inscope(namespace, script, *args)
+ tk_call('namespace', 'inscope', namespace, script, *args)
+ end
+ def inscope(script, *args)
+ TkNamespace(@fullname, script, *args)
+ end
+
+ def self.origin(cmd)
+ tk_call('namespace', 'origin', cmd)
+ end
+
+ def self.parent(namespace=None)
+ ns = tk_call('namespace', 'parent', namespace)
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ end
+ def parent
+ tk_call('namespace', 'parent', @fullname)
+ end
+
+ def self.qualifiers(str)
+ tk_call('namespace', 'qualifiers', str)
+ end
+
+ def self.tail(str)
+ tk_call('namespace', 'tail', str)
+ end
+
+ def self.which(name)
+ tk_call('namespace', 'which', name)
+ end
+ def self.which_command(name)
+ tk_call('namespace', 'which', '-command', name)
+ end
+ def self.which_variable(name)
+ tk_call('namespace', 'which', '-variable', name)
+ end
+end
diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb
new file mode 100644
index 0000000000..1484671920
--- /dev/null
+++ b/ext/tk/lib/tk/optiondb.rb
@@ -0,0 +1,370 @@
+#
+# tk/optiondb.rb : treat option database
+#
+require 'tk'
+
+module TkOptionDB
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['option'.freeze].freeze
+ CmdClassID = ['CMD_CLASS'.freeze, '00000'.taint].freeze
+
+ module Priority
+ WidgetDefault = 20
+ StartupFile = 40
+ UserDefault = 60
+ Interactive = 80
+ end
+
+ def add(pat, value, pri=None)
+ # if $SAFE >= 4
+ # fail SecurityError, "can't call 'TkOptionDB.add' at $SAFE >= 4"
+ # end
+ tk_call('option', 'add', pat, value, pri)
+ end
+ def clear
+ # if $SAFE >= 4
+ # fail SecurityError, "can't call 'TkOptionDB.crear' at $SAFE >= 4"
+ # end
+ tk_call_without_enc('option', 'clear')
+ end
+ def get(win, name, klass)
+ tk_call('option', 'get', win ,name, klass)
+ end
+ def readfile(file, pri=None)
+ tk_call('option', 'readfile', file, pri)
+ end
+ alias read_file readfile
+ module_function :add, :clear, :get, :readfile, :read_file
+
+ def read_entries(file, f_enc=nil)
+ if TkCore::INTERP.safe?
+ fail SecurityError,
+ "can't call 'TkOptionDB.read_entries' on a safe interpreter"
+ end
+
+ i_enc = Tk.encoding()
+
+ unless f_enc
+ f_enc = i_enc
+ end
+
+ ent = []
+ cline = ''
+ open(file, 'r') {|f|
+ while line = f.gets
+ #cline += line.chomp!
+ cline.concat(line.chomp!)
+ case cline
+ when /\\$/ # continue
+ cline.chop!
+ next
+ when /^\s*(!|#)/ # coment
+ cline = ''
+ next
+ when /^([^:]+):(.*)$/
+ pat = $1.strip
+ val = $2.lstrip
+ p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
+ pat = TkCore::INTERP._toUTF8(pat, f_enc)
+ pat = TkCore::INTERP._fromUTF8(pat, i_enc)
+ val = TkCore::INTERP._toUTF8(val, f_enc)
+ val = TkCore::INTERP._fromUTF8(val, i_enc)
+ ent << [pat, val]
+ cline = ''
+ else # unknown --> ignore
+ cline = ''
+ next
+ end
+ end
+ }
+ ent
+ end
+ module_function :read_entries
+
+ def read_with_encoding(file, f_enc=nil, pri=None)
+ # try to read the file as an OptionDB file
+ read_entries(file, f_enc).each{|pat, val|
+ add(pat, val, pri)
+ }
+
+=begin
+ i_enc = Tk.encoding()
+
+ unless f_enc
+ f_enc = i_enc
+ end
+
+ cline = ''
+ open(file, 'r') {|f|
+ while line = f.gets
+ cline += line.chomp!
+ case cline
+ when /\\$/ # continue
+ cline.chop!
+ next
+ when /^\s*!/ # coment
+ cline = ''
+ next
+ when /^([^:]+):\s(.*)$/
+ pat = $1
+ val = $2
+ p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
+ pat = TkCore::INTERP._toUTF8(pat, f_enc)
+ pat = TkCore::INTERP._fromUTF8(pat, i_enc)
+ val = TkCore::INTERP._toUTF8(val, f_enc)
+ val = TkCore::INTERP._fromUTF8(val, i_enc)
+ add(pat, val, pri)
+ cline = ''
+ else # unknown --> ignore
+ cline = ''
+ next
+ end
+ end
+ }
+=end
+ end
+ module_function :read_with_encoding
+
+ # support procs on the resource database
+ @@resource_proc_class = Class.new
+
+ @@resource_proc_class.const_set(:CARRIER, '.'.freeze)
+
+ @@resource_proc_class.instance_variable_set('@method_tbl',
+ TkCore::INTERP.create_table)
+ @@resource_proc_class.instance_variable_set('@add_method', false)
+ @@resource_proc_class.instance_variable_set('@safe_mode', 4)
+
+ class << @@resource_proc_class
+ private :new
+
+=begin
+ CARRIER = '.'.freeze
+ METHOD_TBL = TkCore::INTERP.create_table
+ ADD_METHOD = false
+ SAFE_MODE = 4
+=end
+
+=begin
+ def __closed_block_check__(str)
+ depth = 0
+ str.scan(/[{}]/){|x|
+ if x == "{"
+ depth += 1
+ elsif x == "}"
+ depth -= 1
+ end
+ if depth <= 0 && !($' =~ /\A\s*\Z/)
+ fail RuntimeError, "bad string for procedure : #{str.inspect}"
+ end
+ }
+ str
+ end
+ private :__closed_block_check__
+=end
+
+ def __check_proc_string__(str)
+ # If you want to check the proc_string, do it in this method.
+ # Please define this in the block given to 'new_proc_class' method.
+ str
+ end
+
+ def method_missing(id, *args)
+ #res_proc, proc_str = self::METHOD_TBL[id]
+ res_proc, proc_str = @method_tbl[id]
+
+ proc_source = TkOptionDB.get(self::CARRIER, id.id2name, '').strip
+ res_proc = nil if proc_str != proc_source # resource is changed
+
+ unless res_proc.kind_of? Proc
+ #if id == :new || !(self::METHOD_TBL.has_key?(id) || self::ADD_METHOD)
+ if id == :new || !(@method_tbl.has_key?(id) || @add_method)
+ raise NoMethodError,
+ "not support resource-proc '#{id.id2name}' for #{self.name}"
+ end
+ proc_str = proc_source
+ proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
+ #proc_str = __closed_block_check__(proc_str)
+ proc_str = __check_proc_string__(proc_str)
+ res_proc = proc{
+ begin
+ #eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str)
+ eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str)
+ rescue SyntaxError=>err
+ raise SyntaxError,
+ TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/,
+ "(#{id.id2name}):"))
+ end
+ }.call
+ #self::METHOD_TBL[id] = [res_proc, proc_source]
+ @method_tbl[id] = [res_proc, proc_source]
+ end
+ res_proc.call(*args)
+ end
+
+ private :__check_proc_string__, :method_missing
+ end
+ @@resource_proc_class.freeze
+
+=begin
+ def __create_new_class(klass, func, safe = 4, add = false, parent = nil)
+ klass = klass.to_s if klass.kind_of? Symbol
+ unless (?A..?Z) === klass[0]
+ fail ArgumentError, "bad string '#{klass}' for class name"
+ end
+ unless func.kind_of? Array
+ fail ArgumentError, "method-list must be Array"
+ end
+ func_str = func.join(' ')
+ if parent == nil
+ install_win(parent)
+ elsif parent <= @@resource_proc_class
+ install_win(parent::CARRIER)
+ else
+ fail ArgumentError, "parent must be Resource-Proc class"
+ end
+ carrier = Tk.tk_call_without_enc('frame', @path, '-class', klass)
+
+ body = <<-"EOD"
+ class #{klass} < TkOptionDB.module_eval('@@resource_proc_class')
+ CARRIER = '#{carrier}'.freeze
+ METHOD_TBL = TkCore::INTERP.create_table
+ ADD_METHOD = #{add}
+ SAFE_MODE = #{safe}
+ %w(#{func_str}).each{|f| METHOD_TBL[f.intern] = nil }
+ end
+ EOD
+
+ if parent.kind_of?(Class) && parent <= @@resource_proc_class
+ parent.class_eval(body)
+ eval(parent.name + '::' + klass)
+ else
+ eval(body)
+ eval('TkOptionDB::' + klass)
+ end
+ end
+=end
+ def __create_new_class(klass, func, safe = 4, add = false, parent = nil)
+ if klass.kind_of?(TkWindow)
+ carrier = klass.path
+ klass = CmdClassID.join(TkCore::INTERP._ip_id_)
+ CmdClassID[1].succ!
+ parent = nil # ignore parent
+ else
+ klass = klass.to_s if klass.kind_of? Symbol
+ unless (?A..?Z) === klass[0]
+ fail ArgumentError, "bad string '#{klass}' for class name"
+ end
+ if parent == nil
+ install_win(nil)
+ elsif parent.kind_of?(TkWindow)
+ install_win(parent.path)
+ elsif parent <= @@resource_proc_class
+ install_win(parent::CARRIER)
+ else
+ fail ArgumentError, "parent must be Resource-Proc class"
+ end
+ carrier = Tk.tk_call_without_enc('frame', @path, '-class', klass)
+ end
+
+ unless func.kind_of? Array
+ fail ArgumentError, "method-list must be Array"
+ end
+ func_str = func.join(' ')
+
+ if parent.kind_of?(Class) && parent <= @@resource_proc_class
+ cmd_klass = Class.new(parent)
+ else
+ cmd_klass = Class.new(TkOptionDB.module_eval('@@resource_proc_class'))
+ end
+ cmd_klass.const_set(:CARRIER, carrier.dup.freeze)
+
+ cmd_klass.instance_variable_set('@method_tbl', TkCore::INTERP.create_table)
+ cmd_klass.instance_variable_set('@add_method', add)
+ cmd_klass.instance_variable_set('@safe_mode', safe)
+ func.each{|f|
+ cmd_klass.instance_variable_get('@method_tbl')[f.to_s.intern] = nil
+ }
+=begin
+ cmd_klass.const_set(:METHOD_TBL, TkCore::INTERP.create_table)
+ cmd_klass.const_set(:ADD_METHOD, add)
+ cmd_klass.const_set(:SAFE_MODE, safe)
+ func.each{|f| cmd_klass::METHOD_TBL[f.to_s.intern] = nil }
+=end
+
+ cmd_klass
+ end
+ module_function :__create_new_class
+ private_class_method :__create_new_class
+
+ def __remove_methods_of_proc_class(klass)
+ # for security, make these methods invalid
+ class << klass
+ def __null_method(*args); nil; end
+ [ :class_eval, :name, :superclass, :clone, :dup, :autoload, :autoload?,
+ :ancestors, :const_defined?, :const_get, :const_set, :const_missing,
+ :class_variables, :constants, :included_modules, :instance_methods,
+ :method_defined?, :module_eval, :private_instance_methods,
+ :protected_instance_methods, :public_instance_methods,
+ :singleton_methods, :remove_const, :remove_method, :undef_method,
+ :to_s, :inspect, :display, :method, :methods, :respond_to?,
+ :instance_variable_get, :instance_variable_set, :instance_method,
+ :instance_eval, :instance_variables, :kind_of?, :is_a?,
+ :private_methods, :protected_methods, :public_methods ].each{|m|
+ alias_method(m, :__null_method)
+ }
+ end
+ end
+ module_function :__remove_methods_of_proc_class
+ private_class_method :__remove_methods_of_proc_class
+
+ RAND_BASE_CNT = [0]
+ RAND_BASE_HEAD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ RAND_BASE_CHAR = RAND_BASE_HEAD + 'abcdefghijklmnopqrstuvwxyz0123456789_'
+ def __get_random_basename
+ name = '%s%03d' % [RAND_BASE_HEAD[rand(RAND_BASE_HEAD.size),1],
+ RAND_BASE_CNT[0]]
+ len = RAND_BASE_CHAR.size
+ (6+rand(10)).times{
+ name << RAND_BASE_CHAR[rand(len),1]
+ }
+ RAND_BASE_CNT[0] = RAND_BASE_CNT[0] + 1
+ name
+ end
+ module_function :__get_random_basename
+ private_class_method :__get_random_basename
+
+ # define new proc class :
+ # If you want to modify the new class or create a new subclass,
+ # you must do such operation in the block parameter.
+ # Because the created class is flozen after evaluating the block.
+ def new_proc_class(klass, func, safe = 4, add = false, parent = nil, &b)
+ new_klass = __create_new_class(klass, func, safe, add, parent)
+ new_klass.class_eval(&b) if block_given?
+ __remove_methods_of_proc_class(new_klass)
+ new_klass.freeze
+ new_klass
+ end
+ module_function :new_proc_class
+
+ def eval_under_random_base(parent = nil, &b)
+ new_klass = __create_new_class(__get_random_basename(),
+ [], 4, false, parent)
+ ret = new_klass.class_eval(&b) if block_given?
+ __remove_methods_of_proc_class(new_klass)
+ new_klass.freeze
+ ret
+ end
+ module_function :eval_under_random_base
+
+ def new_proc_class_random(klass, func, safe = 4, add = false, &b)
+ eval_under_random_base(){
+ TkOption.new_proc_class(klass, func, safe, add, self, &b)
+ }
+ end
+ module_function :new_proc_class_random
+end
+TkOption = TkOptionDB
+TkResourceDB = TkOptionDB
diff --git a/ext/tk/lib/tk/optionobj.rb b/ext/tk/lib/tk/optionobj.rb
new file mode 100644
index 0000000000..8fe7e0ee5a
--- /dev/null
+++ b/ext/tk/lib/tk/optionobj.rb
@@ -0,0 +1,212 @@
+#
+# tk/optionobj.rb : control options for a group of widgets
+#
+# NOTE: If you want to use key-only option (no value),
+# use Tk::None for the value of the key-only option.
+#
+# e.g. hash_kv({'aaa'=>1, 'bbb'=>Tk::None, 'ccc'=>3})
+# => ["-aaa", 1, "-bbb", "-ccc", 3]
+#
+require 'tk'
+
+module Tk
+ class OptionObj < Hash
+ include TkUtil
+
+ def initialize(hash = nil)
+ super()
+ @observ = []
+ update_without_notify(_symbolkey2str(hash)) if hash
+ end
+
+ def observ_info
+ @observ.dup
+ end
+
+ def observs
+ @observ.collect{|win|
+ if win.kind_of?(Array)
+ win[0]
+ else
+ win
+ end
+ }
+ end
+
+ def _remove_win(win)
+ if win.kind_of?(Array)
+ widget, method = win
+ @observ.delete_if{|x|
+ if x.kind_of?(Array)
+ x[0] == widget
+ else
+ x == widget
+ end
+ }
+ else
+ @observ.delete_if{|x|
+ if x.kind_of?(Array)
+ x[0] == win
+ else
+ x == win
+ end
+ }
+ end
+ end
+ private :_remove_win
+
+ def assign(*wins)
+ # win :=
+ # widget #==> call widget.configure(hash)
+ # [widget] #==> call widget.configure(hash)
+ # [widget, nil, {src=>target, ... }]
+ # #==> call widget.configure(hash)
+ # with converting hash-key
+ # [widget, method] #==> call widget.method(hash)
+ # [widget, method, {src=>target, ... }]
+ # #==> call widget.method(hash)
+ # with converting hash-key
+ # [widget [receiver, method, arg, ... ]]
+ # #==> call receiver.method(arg, ... , hash)
+ # [widget [receiver, method, arg, ... ], {src=>target, ... }]
+ # #==> call receiver.method(arg, ... , hash)
+ # with onverting hash-key
+ #
+ # src := option_name_on_optobj
+ #
+ # target :=
+ # nil #==> not use the src
+ # option_name_on_target_widget
+ # [ option_name_on_target_widget, ... ]
+ # #==> set all of them
+ #
+ wins.each{|win|
+ _remove_win(win)
+ @observ << win
+ notify(win)
+ }
+ self
+ end
+
+ def unassign(*wins)
+ wins.each{|win|
+ _remove_win(win)
+ }
+ self
+ end
+
+ def notify(target = nil)
+ if target
+ targets = [target]
+ elsif @observ.empty?
+ return self
+ else
+ targets = @observ.dup
+ end
+
+ return self if empty?
+
+ org_hash = _symbolkey2str(self)
+
+ targets.each{|win|
+ widget = receiver = win
+ hash = org_hash
+ begin
+ if win.kind_of?(Array)
+ widget, method, conv_tbl = win
+ receiver = widget
+
+ if conv_tbl
+ hash = {}
+ org_hash.each{|key, val|
+ key = conv_tbl[key] if conv_tbl.key?(key)
+ next unless key
+ if key.kind_of?(Array)
+ key.each{|k| hash[k] = val}
+ else
+ hash[key] = val
+ end
+ }
+ end
+
+ if method.kind_of?(Array)
+ receiver, method, *args = method
+ receiver.__send__(method, *(args << hash))
+ elsif method
+ widget.__send__(method, hash)
+ else
+ widget.configure(hash)
+ end
+
+ else
+ widget.configure(self)
+ end
+ rescue => e
+ if ( ( widget.kind_of?(TkObject) \
+ && widget.respond_to?('exist?') \
+ && ! receiver.exist? ) \
+ || ( receiver.kind_of?(TkObject) \
+ && receiver.respond_to?('exist?') \
+ && ! receiver.exist? ) )
+ @observ.delete(win)
+ else
+ fail e
+ end
+ end
+ }
+
+ self
+ end
+ alias apply notify
+
+ def +(hash)
+ unless hash.kind_of?(Hash)
+ fail ArgumentError, "expect a Hash"
+ end
+ new_obj = self.dup
+ new_obj.update_without_notify(_symbolkey2str(hash))
+ new_obj
+ end
+
+ alias update_without_notify update
+
+ def update(hash)
+ update_without_notify(_symbolkey2str(hash))
+ notify
+ end
+
+ def configure(key, value=nil)
+ if key.kind_of?(Hash)
+ update(key)
+ else
+ store(key,value)
+ end
+ end
+
+ def [](key)
+ super(key.to_s)
+ end
+ alias cget []
+
+ def store(key, val)
+ key = key.to_s
+ super(key, val)
+ notify
+ end
+ def []=(key, val)
+ store(key,val)
+ end
+
+ def replace(hash)
+ super(_symbolkey2str(hash))
+ notify
+ end
+
+ def default(opt)
+ fail RuntimeError, "unknown option `#{opt}'"
+ end
+ private :default
+
+ undef :default=
+ end
+end
diff --git a/ext/tk/lib/tk/pack.rb b/ext/tk/lib/tk/pack.rb
new file mode 100644
index 0000000000..d592fa1c80
--- /dev/null
+++ b/ext/tk/lib/tk/pack.rb
@@ -0,0 +1,90 @@
+#
+# tk/pack.rb : control pack geometry manager
+#
+require 'tk'
+
+module TkPack
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['pack'.freeze].freeze
+
+ def configure(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ # params.push((win.kind_of?(TkObject))? win.epath: win)
+ params.push(_epath(win))
+ args.each{|win|
+ # params.push((win.kind_of?(TkObject))? win.epath: win)
+ params.push(_epath(win))
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_call_without_enc("pack", 'configure', *params)
+ end
+ alias pack configure
+
+ def forget(*args)
+ return '' if args.size == 0
+ wins = args.collect{|win|
+ # (win.kind_of?(TkObject))? win.epath: win
+ _epath(win)
+ }
+ tk_call_without_enc('pack', 'forget', *wins)
+ end
+
+ def info(slave)
+ # slave = slave.epath if slave.kind_of?(TkObject)
+ slave = _epath(slave)
+ ilist = list(tk_call_without_enc('pack', 'info', slave))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ return info
+ end
+
+ def propagate(master, bool=None)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if bool == None
+ bool(tk_call_without_enc('pack', 'propagate', master))
+ else
+ tk_call_without_enc('pack', 'propagate', master, bool)
+ end
+ end
+
+ def slaves(master)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('pack', 'slaves', master))
+ end
+
+ module_function :pack, :configure, :forget, :info, :propagate, :slaves
+end
+=begin
+def TkPack(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ args.each{|win|
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ tk_call_without_enc("pack", *params)
+end
+=end
diff --git a/ext/tk/lib/tk/package.rb b/ext/tk/lib/tk/package.rb
new file mode 100644
index 0000000000..d1eb27674d
--- /dev/null
+++ b/ext/tk/lib/tk/package.rb
@@ -0,0 +1,139 @@
+#
+# tk/package.rb : package command
+#
+require 'tk'
+
+module TkPackage
+ include TkCore
+ extend TkPackage
+
+ TkCommandNames = ['package'.freeze].freeze
+
+ def add_path(path)
+ Tk::AUTO_PATH.value = Tk::AUTO_PATH.to_a << path
+ end
+
+ def forget(package)
+ tk_call('package', 'forget', package)
+ nil
+ end
+
+ def if_needed(pkg, ver, *arg, &b)
+ size = arg.size
+
+ if size==0 && !b
+ # proc info
+ procedure(tk_call('package', 'ifneeded', pkg, ver))
+
+ elsif size==0 && b
+ # set proc
+ cmd = proc(&b)
+ tk_call('package', 'ifneeded', pkg, ver, cmd)
+ cmd
+
+ elsif size==1 && !b
+ # set proc
+ cmd = arg[0]
+ if cmd
+ tk_call('package', 'ifneeded', pkg, ver, cmd)
+ cmd
+ else
+ # remove proc
+ tk_call('package', 'ifneeded', pkg, ver, '')
+ nil
+ end
+
+ else
+ fail ArgumentError, 'too many arguments'
+ end
+ end
+
+ def names
+ tk_split_simplelist(tk_call('package', 'names'))
+ end
+
+ def provide(package, version=nil)
+ if version
+ tk_call('package', 'provide', package, version)
+ end
+ if (ret = tk_call('package', 'provide', package)) == ''
+ nil
+ else
+ ret
+ end
+ end
+
+ def present(package, version=None)
+ begin
+ tk_call('package', 'present', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def present_exact(package, version)
+ begin
+ tk_call('package', 'present', '-exact', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def require(package, version=None)
+ begin
+ tk_call('package', 'require', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def require_exact(package, version)
+ begin
+ tk_call('package', 'require', '-exact', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def unknown_proc(*arg, &b)
+ size = arg.size
+
+ if size==0 && !b
+ # proc info
+ procedure(tk_call('package', 'unknown'))
+
+ elsif size==0 && b
+ # set proc
+ cmd = proc(&b)
+ tk_call('package', 'unknown', cmd)
+ cmd
+
+ elsif size==1 && !b
+ # set proc
+ cmd = arg[0]
+ if cmd
+ tk_call('package', 'unknown', cmd)
+ cmd
+ else
+ # remove proc
+ tk_call('package', 'unknown', '')
+ nil
+ end
+
+ else
+ fail ArgumentError, 'too many arguments'
+ end
+ end
+
+ def versions(package)
+ tk_split_simplelist(tk_call('package', 'versions', package))
+ end
+
+ def vcompare(version1, version2)
+ number(tk_call('package', 'vcompare', version1, version2))
+ end
+
+ def vsatisfies(version1, version2)
+ bool(tk_call('package', 'vsatisfies', version1, version2))
+ end
+end
diff --git a/ext/tk/lib/tk/palette.rb b/ext/tk/lib/tk/palette.rb
new file mode 100644
index 0000000000..dfe46940f3
--- /dev/null
+++ b/ext/tk/lib/tk/palette.rb
@@ -0,0 +1,54 @@
+#
+# tk/palette.rb : methods for Tcl/Tk standard library 'palette.tcl'
+# 1998/06/21 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+module TkPalette
+ include Tk
+ extend Tk
+
+ TkCommandNames = [
+ 'tk_setPalette'.freeze,
+ 'tk_bisque'.freeze,
+ 'tkDarken'.freeze
+ ].freeze
+
+ def TkPalette.set(*args)
+ args = args.to_a.flatten if args.kind_of? Hash
+ tk_call('tk_setPalette', *args)
+ end
+ def TkPalette.setPalette(*args)
+ TkPalette.set(*args)
+ end
+
+ def TkPalette.bisque
+ tk_call('tk_bisque')
+ end
+
+ def TkPalette.darken(color, percent)
+ tk_call('tkDarken', color, percent)
+ end
+
+ def TkPalette.recolorTree(window, colors)
+ if not colors.kind_of?(Hash)
+ fail "2nd arg need to be Hash"
+ end
+
+ colors.each{|key, value|
+ begin
+ if window.cget(key) == tk_call('set', "tkPalette(#{key})")
+ window[key] = colors[key]
+ end
+ rescue
+ # ignore
+ end
+ }
+
+ TkWinfo.children(window).each{|w| TkPalette.recolorTree(w, colors)}
+ end
+
+ def recolorTree(colors)
+ TkPalette.recolorTree(self, colors)
+ end
+end
diff --git a/ext/tk/lib/tk/panedwindow.rb b/ext/tk/lib/tk/panedwindow.rb
new file mode 100644
index 0000000000..37be77508f
--- /dev/null
+++ b/ext/tk/lib/tk/panedwindow.rb
@@ -0,0 +1,204 @@
+#
+# tk/panedwindow.rb : treat panedwindow
+#
+require 'tk'
+
+class TkPanedWindow<TkWindow
+ TkCommandNames = ['panedwindow'.freeze].freeze
+ WidgetClassName = 'Panedwindow'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('panedwindow', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('panedwindow', @path)
+ # end
+ #end
+ #private :create_self
+
+ def add(*args)
+ keys = args.pop
+ fail ArgumentError, "no window in arguments" unless keys
+ if keys && keys.kind_of?(Hash)
+ fail ArgumentError, "no window in arguments" if args == []
+ # args = args.collect{|w| (w.kind_of?(TkObject))? w.epath: w }
+ args = args.collect{|w| _epath(w) }
+ #args.push(hash_kv(keys))
+ args.concat(hash_kv(keys))
+ else
+ args.push(keys) if keys
+ # args = args.collect{|w| (w.kind_of?(TkObject))? w.epath: w }
+ args = args.collect{|w| _epath(w) }
+ end
+ tk_send_without_enc('add', *args)
+ self
+ end
+
+ def forget(win, *wins)
+ wins.unshift(win)
+ # tk_send_without_enc('forget', *((w.kind_of?(TkObject))? w.epath: w))
+ tk_send_without_enc('forget', *(wins.collect{|w| _epath(w)}))
+ self
+ end
+ alias del forget
+ alias delete forget
+ alias remove forget
+
+ def identify(x, y)
+ list(tk_send_without_enc('identify', x, y))
+ end
+
+ def proxy_coord
+ list(tk_send_without_enc('proxy', 'coord'))
+ end
+ def proxy_forget
+ tk_send_without_enc('proxy', 'forget')
+ self
+ end
+ def proxy_place(x, y)
+ tk_send_without_enc('proxy', 'place', x, y)
+ self
+ end
+
+ def sash_coord(index)
+ list(tk_send('sash', 'coord', index))
+ end
+ def sash_dragto(index)
+ tk_send('sash', 'dragto', index, x, y)
+ self
+ end
+ def sash_mark(index, x, y)
+ tk_send('sash', 'mark', index, x, y)
+ self
+ end
+ def sash_place(index, x, y)
+ tk_send('sash', 'place', index, x, y)
+ self
+ end
+
+ def panecget(win, key)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ tk_tcl2ruby(tk_send_without_enc('panecget', win, "-#{key}"))
+ end
+
+ def paneconfigure(win, key, value=nil)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if key.kind_of? Hash
+ params = []
+ key.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_send_without_enc('paneconfigure', win, *params)
+ else
+ # value = value.epath if value.kind_of?(TkObject)
+ value = _epath(value)
+ tk_send_without_enc('paneconfigure', win, "-#{key}", value)
+ end
+ self
+ end
+ alias pane_config paneconfigure
+
+ def paneconfiginfo(win, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if key
+ conf = tk_split_list(tk_send_without_enc('paneconfigure',
+ win, "-#{key}"))
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_simplelist(tk_send_without_enc('paneconfigure',
+ win)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if key
+ conf = tk_split_list(tk_send_without_enc('paneconfigure',
+ win, "-#{key}"))
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(tk_send_without_enc('paneconfigure',
+ win)).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ if key
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+ alias pane_configinfo paneconfiginfo
+
+ def current_paneconfiginfo(win, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = paneconfiginfo(win, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ paneconfiginfo(win).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ paneconfiginfo(win, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ alias current_pane_configinfo current_paneconfiginfo
+
+ def panes
+ list(tk_send_without_enc('panes'))
+ end
+end
+TkPanedwindow = TkPanedWindow
diff --git a/ext/tk/lib/tk/place.rb b/ext/tk/lib/tk/place.rb
new file mode 100644
index 0000000000..f7ebdfcbd6
--- /dev/null
+++ b/ext/tk/lib/tk/place.rb
@@ -0,0 +1,128 @@
+#
+# tk/place.rb : control place geometry manager
+#
+require 'tk'
+
+module TkPlace
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['place'.freeze].freeze
+
+ def configure(win, slot, value=None)
+ # for >= Tk8.4a2 ?
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if slot.kind_of? Hash
+ params = []
+ slot.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_call_without_enc('place', 'configure', win, *params)
+ else
+ # value = value.epath if value.kind_of?(TkObject)
+ value = _epath(value)
+ tk_call_without_enc('place', 'configure', win, "-#{slot}", value)
+ end
+ end
+ alias place configure
+
+ def configinfo(win, slot = nil)
+ # for >= Tk8.4a2 ?
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if slot
+ #conf = tk_split_list(tk_call_without_enc('place', 'configure',
+ # win, "-#{slot}") )
+ conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win, "-#{slot}") )
+ conf[0] = conf[0][1..-1]
+ conf[1] = tk_tcl2ruby(conf[1])
+ conf[2] = tk_tcl2ruby(conf[1])
+ conf[3] = tk_tcl2ruby(conf[1])
+ conf[4] = tk_tcl2ruby(conf[1])
+ conf
+ else
+ tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win)).collect{|conflist|
+ #conf = list(conflist)
+ conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)}
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ current_configinfo(win, slot)
+ end
+ end
+
+ def current_configinfo(win, slot = nil)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if slot
+ #conf = tk_split_list(tk_call_without_enc('place', 'configure',
+ # win, "-#{slot}") )
+ conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win, "-#{slot}") )
+ # { conf[0][1..-1] => conf[1] }
+ { conf[0][1..-1] => tk_tcl2ruby(conf[4]) }
+ else
+ ret = {}
+ #tk_split_list(tk_call_without_enc('place','configure',win)).each{|conf|
+ tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win)).each{|conf_list|
+ #ret[conf[0][1..-1]] = conf[1]
+ conf = simplelist(conf_list)
+ ret[conf[0][1..-1]] = tk_tcl2ruby(conf[4])
+ }
+ ret
+ end
+ end
+
+ def forget(win)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ tk_call_without_enc('place', 'forget', win)
+ end
+
+ def info(win)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ #ilist = list(tk_call_without_enc('place', 'info', win))
+ ilist = simplelist(tk_call_without_enc('place', 'info', win))
+ info = {}
+ while key = ilist.shift
+ #info[key[1..-1]] = ilist.shift
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ return info
+ end
+
+ def slaves(master)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call('place', 'slaves', master))
+ end
+
+ module_function :place, :configure, :configinfo, :current_configinfo
+ module_function :forget, :info, :slaves
+end
+=begin
+def TkPlace(win, slot, value=None)
+ win = win.epath if win.kind_of?(TkObject)
+ if slot.kind_of? Hash
+ params = []
+ slot.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ tk_call_without_enc('place', win, *params)
+ else
+ value = value.epath if value.kind_of?(TkObject)
+ tk_call_without_enc('place', win, "-#{slot}", value)
+ end
+end
+=end
diff --git a/ext/tk/lib/tk/radiobutton.rb b/ext/tk/lib/tk/radiobutton.rb
new file mode 100644
index 0000000000..697c021283
--- /dev/null
+++ b/ext/tk/lib/tk/radiobutton.rb
@@ -0,0 +1,32 @@
+#
+# tk/radiobutton.rb : treat radiobutton widget
+#
+require 'tk'
+require 'tk/button'
+
+class TkRadioButton<TkButton
+ TkCommandNames = ['radiobutton'.freeze].freeze
+ WidgetClassName = 'Radiobutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('radiobutton', @path)
+ # end
+ #end
+ #private :create_self
+
+ def deselect
+ tk_send_without_enc('deselect')
+ self
+ end
+ def select
+ tk_send_without_enc('select')
+ self
+ end
+ def variable(v)
+ configure 'variable', tk_trace_variable(v)
+ end
+end
+TkRadiobutton = TkRadioButton
diff --git a/ext/tk/lib/tk/root.rb b/ext/tk/lib/tk/root.rb
new file mode 100644
index 0000000000..24a5cf1ea0
--- /dev/null
+++ b/ext/tk/lib/tk/root.rb
@@ -0,0 +1,86 @@
+#
+# tk/root.rb : treat root widget
+#
+require 'tk'
+require 'tk/wm'
+require 'tk/menuspec'
+
+class TkRoot<TkWindow
+ include Wm
+ include TkMenuSpec
+
+=begin
+ ROOT = []
+ def TkRoot.new(keys=nil)
+ if ROOT[0]
+ Tk_WINDOWS["."] = ROOT[0]
+ return ROOT[0]
+ end
+ new = super(:without_creating=>true, :widgetname=>'.')
+ if keys # wm commands
+ keys.each{|k,v|
+ if v.kind_of? Array
+ new.send(k,*v)
+ else
+ new.send(k,v)
+ end
+ }
+ end
+ ROOT[0] = new
+ Tk_WINDOWS["."] = new
+ end
+=end
+ def TkRoot.new(keys=nil, &b)
+ unless TkCore::INTERP.tk_windows['.']
+ TkCore::INTERP.tk_windows['.'] =
+ super(:without_creating=>true, :widgetname=>'.'){}
+ end
+ root = TkCore::INTERP.tk_windows['.']
+ if keys # wm commands
+ keys.each{|k,v|
+ if v.kind_of? Array
+ root.__send__(k,*v)
+ else
+ root.__send__(k,v)
+ end
+ }
+ end
+ root.instance_eval(&b) if block_given?
+ root
+ end
+
+ WidgetClassName = 'Tk'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self
+ @path = '.'
+ end
+ private :create_self
+
+ def path
+ "."
+ end
+
+ def add_menu(menu_info, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_info.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_info can override it.
+ if tearoff.kind_of?(Hash)
+ opts = tearoff
+ tearoff = false
+ end
+ _create_menubutton(self, menu_info, tearoff, opts)
+ end
+
+ def add_menubar(menu_spec, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_spec.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_spec can override it.
+ menu_spec.each{|info| add_menu(info, tearoff, opts)}
+ self.menu
+ end
+
+ def TkRoot.destroy
+ TkCore::INTERP._invoke('destroy', '.')
+ end
+end
diff --git a/ext/tk/lib/tk/scale.rb b/ext/tk/lib/tk/scale.rb
new file mode 100644
index 0000000000..7214c46f5e
--- /dev/null
+++ b/ext/tk/lib/tk/scale.rb
@@ -0,0 +1,81 @@
+#
+# tk/scale.rb : treat scale widget
+#
+require 'tk'
+
+class TkScale<TkWindow
+ TkCommandNames = ['scale'.freeze].freeze
+ WidgetClassName = 'Scale'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ if keys.key?('command') && ! keys['command'].kind_of?(String)
+ cmd = keys.delete('command')
+ keys['command'] = proc{|val| cmd.call(val.to_f)}
+ end
+ #tk_call_without_enc('scale', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ #tk_call_without_enc('scale', @path)
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def _wrap_command_arg(cmd)
+ proc{|val|
+ if val.kind_of?(String)
+ cmd.call(number(val))
+ else
+ cmd.call(val)
+ end
+ }
+ end
+ private :_wrap_command_arg
+
+ def configure_cmd(slot, value)
+ configure(slot=>value)
+ end
+
+ def configure(slot, value=None)
+ if (slot == 'command' || slot == :command)
+ configure('command'=>value)
+ elsif slot.kind_of?(Hash) &&
+ (slot.key?('command') || slot.key?(:command))
+ slot = _symbolkey2str(slot)
+ slot['command'] = _wrap_command_arg(slot.delete('command'))
+ end
+ super(slot, value)
+ end
+
+ def command(cmd=Proc.new)
+ configure('command'=>cmd)
+ end
+
+ def get(x=None, y=None)
+ number(tk_send_without_enc('get', x, y))
+ end
+
+ def coords(val=None)
+ tk_split_list(tk_send_without_enc('coords', val))
+ end
+
+ def identify(x, y)
+ tk_send_without_enc('identify', x, y)
+ end
+
+ def set(val)
+ tk_send_without_enc('set', val)
+ end
+
+ def value
+ get
+ end
+
+ def value= (val)
+ set(val)
+ val
+ end
+end
diff --git a/ext/tk/lib/tk/scrollable.rb b/ext/tk/lib/tk/scrollable.rb
new file mode 100644
index 0000000000..ec27b76467
--- /dev/null
+++ b/ext/tk/lib/tk/scrollable.rb
@@ -0,0 +1,79 @@
+#
+# tk/scrollable.rb : module for scrollable widget
+#
+require 'tk'
+
+module Tk
+ module X_Scrollable
+ def xscrollcommand(cmd=Proc.new)
+ configure_cmd 'xscrollcommand', cmd
+ # Tk.update # avoid scrollbar trouble
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def xscrollbar(bar=nil)
+ if bar
+ @xscrollbar = bar
+ @xscrollbar.orient 'horizontal'
+ self.xscrollcommand {|*arg| @xscrollbar.set(*arg)}
+ @xscrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @xscrollbar
+ end
+ end
+
+ module Y_Scrollable
+ def yscrollcommand(cmd=Proc.new)
+ configure_cmd 'yscrollcommand', cmd
+ # Tk.update # avoid scrollbar trouble
+ self
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+
+ def yscrollbar(bar=nil)
+ if bar
+ @yscrollbar = bar
+ @yscrollbar.orient 'vertical'
+ self.yscrollcommand {|*arg| @yscrollbar.set(*arg)}
+ @yscrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @yscrollbar
+ end
+ end
+
+ module Scrollable
+ include X_Scrollable
+ include Y_Scrollable
+ end
+end
diff --git a/ext/tk/lib/tk/scrollbar.rb b/ext/tk/lib/tk/scrollbar.rb
new file mode 100644
index 0000000000..70aadfdd4c
--- /dev/null
+++ b/ext/tk/lib/tk/scrollbar.rb
@@ -0,0 +1,124 @@
+#
+# tk/scrollbar.rb : treat scrollbar widget
+#
+require 'tk'
+
+class TkScrollbar<TkWindow
+ TkCommandNames = ['scrollbar'.freeze].freeze
+ WidgetClassName = 'Scrollbar'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ @assigned = []
+ @scroll_proc = proc{|*args|
+ if self.orient == 'horizontal'
+ @assigned.each{|w| w.xview(*args)}
+ else # 'vertical'
+ @assigned.each{|w| w.yview(*args)}
+ end
+ }
+
+ if keys and keys != None
+ #tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ #tk_call_without_enc('scrollbar', @path)
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def propagate_set(src_win, first, last)
+ self.set(first, last)
+ if self.orient == 'horizontal'
+ @assigned.each{|w| w.xview('moveto', first) if w != src_win}
+ else # 'vertical'
+ @assigned.each{|w| w.yview('moveto', first) if w != src_win}
+ end
+ end
+
+ def assign(*wins)
+ begin
+ self.command(@scroll_proc) if self.cget('command').cmd != @scroll_proc
+ rescue Exception
+ self.command(@scroll_proc)
+ end
+ orient = self.orient
+ wins.each{|w|
+ @assigned << w unless @assigned.index(w)
+ if orient == 'horizontal'
+ w.xscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
+ else # 'vertical'
+ w.yscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
+ end
+ }
+ Tk.update # avoid scrollbar trouble
+ self
+ end
+
+ def assigned_list
+ begin
+ return @assigned.dup if self.cget('command').cmd == @scroll_proc
+ rescue Exception
+ end
+ fail RuntimeError, "not depend on the assigned_list"
+ end
+
+ def configure(*args)
+ ret = super(*args)
+ # Tk.update # avoid scrollbar trouble
+ ret
+ end
+
+ #def delta(deltax=None, deltay=None)
+ def delta(deltax, deltay)
+ number(tk_send_without_enc('delta', deltax, deltay))
+ end
+
+ #def fraction(x=None, y=None)
+ def fraction(x, y)
+ number(tk_send_without_enc('fraction', x, y))
+ end
+
+ def identify(x, y)
+ tk_send_without_enc('identify', x, y)
+ end
+
+ def get
+ #ary1 = tk_send('get').split
+ #ary2 = []
+ #for i in ary1
+ # ary2.push number(i)
+ #end
+ #ary2
+ list(tk_send_without_enc('get'))
+ end
+
+ def set(first, last)
+ tk_send_without_enc('set', first, last)
+ self
+ end
+
+ def activate(element=None)
+ tk_send_without_enc('activate', element)
+ end
+end
+
+class TkXScrollbar<TkScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'horizontal'
+ super(keys)
+ end
+ private :create_self
+end
+
+class TkYScrollbar<TkScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'vertical'
+ super(keys)
+ end
+ private :create_self
+end
diff --git a/ext/tk/lib/tk/scrollbox.rb b/ext/tk/lib/tk/scrollbox.rb
new file mode 100644
index 0000000000..fd04057fb6
--- /dev/null
+++ b/ext/tk/lib/tk/scrollbox.rb
@@ -0,0 +1,36 @@
+#
+# tk/scrollbox.rb - Tk Listbox with Scrollbar
+# as an example of Composite Widget
+# $Date$
+# by Yukihiro Matsumoto <matz@netlab.co.jp>
+#
+require 'tk'
+require 'tk/listbox'
+
+class TkScrollbox<TkListbox
+ include TkComposite
+ def initialize_composite(keys=nil)
+ list = TkListbox.new(@frame)
+ scroll = TkScrollbar.new(@frame)
+ @path = list.path
+
+=begin
+ list.configure 'yscroll', scroll.path+" set"
+ list.pack 'side'=>'left','fill'=>'both','expand'=>'yes'
+ scroll.configure 'command', list.path+" yview"
+ scroll.pack 'side'=>'right','fill'=>'y'
+=end
+ list.yscrollbar(scroll)
+ list.pack('side'=>'left','fill'=>'both','expand'=>'yes')
+ scroll.pack('side'=>'right','fill'=>'y')
+
+ delegate('DEFAULT', list)
+ delegate('foreground', list)
+ delegate('background', list, scroll)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ configure keys if keys
+ end
+ private :initialize_composite
+end
diff --git a/ext/tk/lib/tk/selection.rb b/ext/tk/lib/tk/selection.rb
new file mode 100644
index 0000000000..5caa6ef8ef
--- /dev/null
+++ b/ext/tk/lib/tk/selection.rb
@@ -0,0 +1,86 @@
+#
+# tk/selection.rb : control selection
+#
+require 'tk'
+
+module TkSelection
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['selection'.freeze].freeze
+
+ def self.clear(sel=nil)
+ if sel
+ tk_call_without_enc('selection', 'clear', '-selection', sel)
+ else
+ tk_call_without_enc('selection', 'clear')
+ end
+ end
+ def self.clear_on_display(win, sel=nil)
+ if sel
+ tk_call_without_enc('selection', 'clear',
+ '-displayof', win, '-selection', sel)
+ else
+ tk_call_without_enc('selection', 'clear', '-displayof', win)
+ end
+ end
+ def clear(sel=nil)
+ TkSelection.clear_on_display(self, sel)
+ self
+ end
+
+ def self.get(keys=nil)
+ #tk_call('selection', 'get', *hash_kv(keys))
+ _fromUTF8(tk_call_without_enc('selection', 'get', *hash_kv(keys)))
+ end
+ def self.get_on_display(win, keys=nil)
+ #tk_call('selection', 'get', '-displayof', win, *hash_kv(keys))
+ _fromUTF8(tk_call_without_enc('selection', 'get', '-displayof',
+ win, *hash_kv(keys)))
+ end
+ def get(keys=nil)
+ TkSelection.get_on_display(self, sel)
+ end
+
+ def self.handle(win, func=Proc.new, keys=nil, &b)
+ if func.kind_of?(Hash) && keys == nil
+ keys = func
+ func = Proc.new(&b)
+ end
+ args = ['selection', 'handle']
+ args.concat(hash_kv(keys))
+ args.concat([win, func])
+ tk_call_without_enc(*args)
+ end
+ def handle(func=Proc.new, keys=nil, &b)
+ TkSelection.handle(self, func, keys, &b)
+ end
+
+ def self.get_owner(sel=nil)
+ if sel
+ window(tk_call_without_enc('selection', 'own', '-selection', sel))
+ else
+ window(tk_call_without_enc('selection', 'own'))
+ end
+ end
+ def self.get_owner_on_display(win, sel=nil)
+ if sel
+ window(tk_call_without_enc('selection', 'own',
+ '-displayof', win, '-selection', sel))
+ else
+ window(tk_call_without_enc('selection', 'own', '-displayof', win))
+ end
+ end
+ def get_owner(sel=nil)
+ TkSelection.get_owner_on_display(self, sel)
+ self
+ end
+
+ def self.set_owner(win, keys=nil)
+ tk_call_without_enc('selection', 'own', *(hash_kv(keys) << win))
+ end
+ def set_owner(keys=nil)
+ TkSelection.set_owner(self, keys)
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb
new file mode 100644
index 0000000000..f4febb05b1
--- /dev/null
+++ b/ext/tk/lib/tk/spinbox.rb
@@ -0,0 +1,39 @@
+#
+# tk/spinbox.rb - Tk spinbox classes
+# $Date$
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+#
+require 'tk'
+require 'tk/entry'
+
+class TkSpinbox<TkEntry
+ TkCommandNames = ['spinbox'.freeze].freeze
+ WidgetClassName = 'Spinbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ #def create_self(keys)
+ # tk_call_without_enc('spinbox', @path)
+ # if keys and keys != None
+ # configure(keys)
+ # end
+ #end
+ #private :create_self
+
+ def identify(x, y)
+ tk_send_without_enc('identify', x, y)
+ end
+
+ def spinup
+ tk_send_without_enc('invoke', 'spinup')
+ self
+ end
+
+ def spindown
+ tk_send_without_enc('invoke', 'spindown')
+ self
+ end
+
+ def set(str)
+ _fromUTF8(tk_send_without_enc('set', _get_eval_enc_str(str)))
+ end
+end
diff --git a/ext/tk/lib/tk/tagfont.rb b/ext/tk/lib/tk/tagfont.rb
new file mode 100644
index 0000000000..a106f814be
--- /dev/null
+++ b/ext/tk/lib/tk/tagfont.rb
@@ -0,0 +1,43 @@
+#
+# tk/tagfont.rb : control font of tags
+#
+require 'tk'
+
+module TkTreatTagFont
+ def font_configinfo
+ @parent.tagfont_configinfo(@id)
+ end
+# alias font font_configinfo
+
+ def font_configure(slot)
+ @parent.tagfont_configure(@id, slot)
+ self
+ end
+
+ def latinfont_configure(ltn, keys=nil)
+ @parent.latintagfont_configure(@id, ltn, keys)
+ self
+ end
+ alias asciifont_configure latinfont_configure
+
+ def kanjifont_configure(knj, keys=nil)
+ @parent.kanjitagfont_configure(@id, ltn, keys)
+ self
+ end
+
+ def font_copy(window, wintag=nil)
+ @parent.tagfont_copy(@id, window, wintag)
+ self
+ end
+
+ def latinfont_copy(window, wintag=nil)
+ @parent.latintagfont_copy(@id, window, wintag)
+ self
+ end
+ alias asciifont_copy latinfont_copy
+
+ def kanjifont_copy(window, wintag=nil)
+ @parent.kanjitagfont_copy(@id, window, wintag)
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb
new file mode 100644
index 0000000000..efede9861f
--- /dev/null
+++ b/ext/tk/lib/tk/text.rb
@@ -0,0 +1,1285 @@
+#
+# tk/text.rb - Tk text classes
+# $Date$
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+require 'tk'
+require 'tk/itemfont'
+require 'tk/itemconfig'
+require 'tk/scrollable'
+require 'tk/txtwin_abst'
+
+module TkTextTagConfig
+ include TkTreatItemFont
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'cget', id[1]]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'configure', id[1]]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def tag_cget(tagOrId, option)
+ itemcget(['tag', tagOrId], option)
+ end
+ def tag_configure(tagOrId, slot, value=None)
+ itemconfigure(['tag', tagOrId], slot, value)
+ end
+ def tag_configinfo(tagOrId, slot=nil)
+ itemconfigure(['tag', tagOrId], slot)
+ end
+ def current_tag_configinfo(tagOrId, slot=nil)
+ itemconfigure(['tag', tagOrId], slot)
+ end
+
+ def window_cget(tagOrId, option)
+ itemcget(['window', tagOrId], option)
+ end
+ def window_configure(tagOrId, slot, value=None)
+ itemconfigure(['window', tagOrId], slot, value)
+ end
+ def window_configinfo(tagOrId, slot=nil)
+ itemconfigure(['window', tagOrId], slot)
+ end
+ def current_window_configinfo(tagOrId, slot=nil)
+ itemconfigure(['window', tagOrId], slot)
+ end
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+end
+
+class TkText<TkTextWin
+ ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze
+ #include TkTreatTextTagFont
+ include TkTextTagConfig
+ include Scrollable
+
+ TkCommandNames = ['text'.freeze].freeze
+ WidgetClassName = 'Text'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def self.new(*args, &block)
+ obj = super(*args){}
+ obj.init_instance_variable
+ obj.instance_eval(&block) if defined? yield
+ obj
+ end
+
+ def init_instance_variable
+ @cmdtbl = []
+ @tags = {}
+ end
+
+ def __destroy_hook__
+ TkTextTag::TTagID_TBL.delete(@path)
+ TkTextMark::TMarkID_TBL.delete(@path)
+ end
+
+ def create_self(keys)
+ #if keys and keys != None
+ # #tk_call_without_enc('text', @path, *hash_kv(keys, true))
+ # tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ # *hash_kv(keys, true))
+ #else
+ # #tk_call_without_enc('text', @path)
+ # tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ #end
+ super(keys)
+ init_instance_variable
+ end
+ private :create_self
+
+ def index(index)
+ tk_send_without_enc('index', _get_eval_enc_str(index))
+ end
+
+ def get_displaychars(*index)
+ # Tk8.5 feature
+ get('-displaychars', *index)
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get', "1.0", "end - 1 char"))
+ end
+
+ def value= (val)
+ tk_send_without_enc('delete', "1.0", 'end')
+ tk_send_without_enc('insert', "1.0", _get_eval_enc_str(val))
+ val
+ end
+
+ def clear
+ tk_send_without_enc('delete', "1.0", 'end')
+ self
+ end
+ alias erase clear
+
+ def _addcmd(cmd)
+ @cmdtbl.push cmd
+ end
+
+ def _addtag(name, obj)
+ @tags[name] = obj
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(TkTextTag) \
+ || tag.kind_of?(TkTextMark) \
+ || tag.kind_of?(TkTextImage) \
+ || tag.kind_of?(TkTextWindow)
+ tag.id
+ else
+ tag # maybe an Array of configure paramters
+ end
+ end
+ private :tagid
+
+ def tagid2obj(tagid)
+ if @tags[tagid]
+ @tags[tagid]
+ else
+ tagid
+ end
+ end
+
+ def tag_names(index=None)
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag', 'names', _get_eval_enc_str(index)))).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def mark_names
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def mark_gravity(mark, direction=nil)
+ if direction
+ tk_send_without_enc('mark', 'gravity',
+ _get_eval_enc_str(mark), direction)
+ self
+ else
+ tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
+ end
+ end
+
+ def mark_set(mark, index)
+ tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
+ _get_eval_enc_str(index))
+ self
+ end
+ alias set_mark mark_set
+
+ def mark_unset(*marks)
+ tk_send_without_enc('mark', 'unset',
+ *(marks.collect{|mark| _get_eval_enc_str(mark)}))
+ self
+ end
+ alias unset_mark mark_unset
+
+ def mark_next(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
+ _get_eval_enc_str(index))))
+ end
+ alias next_mark mark_next
+
+ def mark_previous(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
+ _get_eval_enc_str(index))))
+ end
+ alias previous_mark mark_previous
+
+ def image_cget(index, slot)
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index), "-#{slot}"))
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index),
+ "-#{slot}")))
+ end
+ end
+
+ def image_configure(index, slot, value=None)
+ if slot.kind_of? Hash
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ *hash_kv(slot, true)))
+ else
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ "-#{slot}",
+ _get_eval_enc_str(value)))
+ end
+ self
+ end
+
+ def image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+
+ def current_image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ conf = image_configinfo(index, slot)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ image_configinfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ image_configinfo(index, slot).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ def image_names
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def set_insert(index)
+ tk_send_without_enc('mark','set','insert', _get_eval_enc_str(index))
+ self
+ end
+
+ def set_current(index)
+ tk_send_without_enc('mark','set','current', _get_eval_enc_str(index))
+ self
+ end
+
+ def insert(index, chars, *tags)
+ if tags[0].kind_of? Array
+ # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ...
+ args = [chars]
+ while tags.size > 0
+ args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist
+ args << tags.shift if tags.size > 0 # chars
+ end
+ super index, *args
+ else
+ # single chars-taglist argument :: str, tag, tag, ...
+ if tags.size == 0
+ super index, chars
+ else
+ super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')
+ end
+ end
+ end
+
+ def destroy
+ @tags = {} unless @tags
+ @tags.each_value do |t|
+ t.destroy
+ end
+ super
+ end
+
+ def backspace
+ self.delete 'insert'
+ end
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', _get_eval_enc_str(index)))
+ end
+
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def count(idx1, idx2, *opts)
+ # opts are Tk8.5 feature
+ cnt = 0
+ args = opts.collect{|opt|
+ str = opt.to_s
+ cnt += 1 if str != 'update'
+ '-' + str
+ }
+ args << _get_eval_enc_str(idx1) << _get_eval_enc_str(idx2)
+ if cnt <= 1
+ number(tk_send_without_enc('count', *opts))
+ else
+ list(tk_send_without_enc('count', *opts))
+ end
+ end
+
+ def count_info(idx1, idx2, update=true)
+ # Tk8.5 feature
+ opts = [
+ :chars, :displaychars, :displayindices, :displaylines,
+ :indices, :lines, :xpixels, :ypixels
+ ]
+ if update
+ lst = count(idx1, idx2, :update, *opts)
+ else
+ lst = count(idx1, idx2, *opts)
+ end
+ info = {}
+ opts.each_with_index{|key, idx| info[key] = lst[idx]}
+ info
+ end
+
+ def replace(idx1, idx2, *opts)
+ tk_send('replace', idx1, idx2, *opts)
+ self
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def modified?
+ bool(tk_send_without_enc('edit', 'modified'))
+ end
+ def modified(mode)
+ tk_send_without_enc('edit', 'modified', mode)
+ self
+ end
+ def modified=(mode)
+ modified(mode)
+ mode
+ end
+
+ def edit_redo
+ tk_send_without_enc('edit', 'redo')
+ self
+ end
+ def edit_reset
+ tk_send_without_enc('edit', 'reset')
+ self
+ end
+ def edit_separator
+ tk_send_without_enc('edit', 'separator')
+ self
+ end
+ def edit_undo
+ tk_send_without_enc('edit', 'undo')
+ self
+ end
+
+ def xview_pickplace(index)
+ tk_send_without_enc('xview', '-pickplace', _get_eval_enc_str(index))
+ self
+ end
+
+ def yview_pickplace(index)
+ tk_send_without_enc('yview', '-pickplace', _get_eval_enc_str(index))
+ self
+ end
+
+ def text_copy
+ # Tk8.4 feature
+ tk_call_without_enc('tk_textCopy', @path)
+ self
+ end
+
+ def text_cut
+ # Tk8.4 feature
+ tk_call_without_enc('tk_textCut', @path)
+ self
+ end
+
+ def text_paste
+ # Tk8.4 feature
+ tk_call_without_enc('tk_textPaste', @path)
+ self
+ end
+
+ def tag_add(tag, index1, index2=None)
+ tk_send_without_enc('tag', 'add', _get_eval_enc_str(tag),
+ _get_eval_enc_str(index1),
+ _get_eval_enc_str(index2))
+ self
+ end
+ alias addtag tag_add
+ alias add_tag tag_add
+
+ def tag_delete(*tags)
+ tk_send_without_enc('tag', 'delete',
+ *(tags.collect{|tag| _get_eval_enc_str(tag)}))
+ if TkTextTag::TTagID_TBL[@path]
+ tags.each{|tag|
+ if tag.kind_of? TkTextTag
+ TkTextTag::TTagID_TBL[@path].delete(tag.id)
+ else
+ TkTextTag::TTagID_TBL[@path].delete(tag)
+ end
+ }
+ end
+ self
+ end
+ alias deltag tag_delete
+ alias delete_tag tag_delete
+
+ def tag_bind(tag, seq, cmd=Proc.new, args=nil)
+ _bind([@path, 'tag', 'bind', tag], seq, cmd, args)
+ self
+ end
+
+ def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
+ _bind_append([@path, 'tag', 'bind', tag], seq, cmd, args)
+ self
+ end
+
+ def tag_bind_remove(tag, seq)
+ _bind_remove([@path, 'tag', 'bind', tag], seq)
+ self
+ end
+
+ def tag_bindinfo(tag, context=nil)
+ _bindinfo([@path, 'tag', 'bind', tag], context)
+ end
+
+=begin
+ def tag_cget(tag, key)
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ tk_call_without_enc(@path, 'tag', 'cget',
+ _get_eval_enc_str(tag), "-#{key}")
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('tag', 'cget', tag, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('tag','cget',_get_eval_enc_str(tag),'-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(tag, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@path,'tag','cget',_get_eval_enc_str(tag),"-#{key}")))
+ end
+ end
+
+ def tag_configure(tag, key, val=None)
+ if key.kind_of? Hash
+ key = _symbolkey2str(key)
+ if ( key['font'] || key['kanjifont'] \
+ || key['latinfont'] || key['asciifont'] )
+ tagfont_configure(tag, key)
+ else
+ tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag),
+ *hash_kv(key, true))
+ end
+
+ else
+ if key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont
+ if val == None
+ tagfontobj(tag)
+ else
+ tagfont_configure(tag, {key=>val})
+ end
+ else
+ tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag),
+ "-#{key}", _get_eval_enc_str(val))
+ end
+ end
+ self
+ end
+
+ def tag_configinfo(tag, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ conf[4] = tagfont_configinfo(tag, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(tag, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ conf[4] = tagfont_configinfo(tag, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(tag, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
+ end
+ end
+ end
+
+ def current_tag_configinfo(tag, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = tag_configinfo(tag, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ tag_configinfo(tag).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ tag_configinfo(tag, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+
+ def tag_raise(tag, above=None)
+ tk_send_without_enc('tag', 'raise', _get_eval_enc_str(tag),
+ _get_eval_enc_str(above))
+ self
+ end
+
+ def tag_lower(tag, below=None)
+ tk_send_without_enc('tag', 'lower', _get_eval_enc_str(tag),
+ _get_eval_enc_str(below))
+ self
+ end
+
+ def tag_remove(tag, *indices)
+ tk_send_without_enc('tag', 'remove', _get_eval_enc_str(tag),
+ *(indices.collect{|idx| _get_eval_enc_str(idx)}))
+ self
+ end
+
+ def tag_ranges(tag)
+ l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges',
+ _get_eval_enc_str(tag)))
+ r = []
+ while key=l.shift
+ r.push [key, l.shift]
+ end
+ r
+ end
+
+ def tag_nextrange(tag, first, last=None)
+ tk_split_list(tk_send_without_enc('tag', 'nextrange',
+ _get_eval_enc_str(tag),
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last)))
+ end
+
+ def tag_prevrange(tag, first, last=None)
+ tk_split_list(tk_send_without_enc('tag', 'prevrange',
+ _get_eval_enc_str(tag),
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last)))
+ end
+
+=begin
+ def window_cget(index, slot)
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_send_without_enc('window', 'cget',
+ _get_eval_enc_str(index), "-#{slot}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('window', 'cget', _get_eval_enc_str(index), '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(index, fnt)
+ end
+ if slot.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('window', 'cget', _get_eval_enc_str(index), "-#{slot}")))
+ end
+ end
+
+ def window_configure(index, slot, value=None)
+ if index.kind_of? TkTextWindow
+ index.configure(slot, value)
+ else
+ if slot.kind_of? Hash
+ slot = _symbolkey2str(slot)
+ win = slot['window']
+ # slot['window'] = win.epath if win.kind_of?(TkWindow)
+ slot['window'] = _epath(win) if win
+ if slot['create']
+ p_create = slot['create']
+ if p_create.kind_of? Proc
+#=begin
+ slot['create'] = install_cmd(proc{
+ id = p_create.call
+ if id.kind_of?(TkWindow)
+ id.epath
+ else
+ id
+ end
+ })
+#=end
+ slot['create'] = install_cmd(proc{_epath(p_create.call)})
+ end
+ end
+ tk_send_without_enc('window', 'configure',
+ _get_eval_enc_str(index),
+ *hash_kv(slot, true))
+ else
+ if slot == 'window' || slot == :window
+ # id = value
+ # value = id.epath if id.kind_of?(TkWindow)
+ value = _epath(value)
+ end
+ if slot == 'create' || slot == :create
+ p_create = value
+ if p_create.kind_of? Proc
+#=begin
+ value = install_cmd(proc{
+ id = p_create.call
+ if id.kind_of?(TkWindow)
+ id.epath
+ else
+ id
+ end
+ })
+#=end
+ value = install_cmd(proc{_epath(p_create.call)})
+ end
+ end
+ tk_send_without_enc('window', 'configure',
+ _get_eval_enc_str(index),
+ "-#{slot}", _get_eval_enc_str(value))
+ end
+ end
+ self
+ end
+
+ def window_configinfo(win, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+
+ def current_window_configinfo(win, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ conf = window_configinfo(win, slot)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ window_configinfo(win).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ window_configinfo(win, slot).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+
+ def window_names
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('window', 'names'))).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def _ktext_length(txt)
+ if $KCODE !~ /n/i
+ return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
+ end
+
+ # $KCODE == 'NONE'
+ if JAPANIZED_TK
+ tk_call_without_enc('kstring', 'length',
+ _get_eval_enc_str(txt)).to_i
+ else
+ begin
+ tk_call_without_enc('encoding', 'convertto', 'ascii',
+ _get_eval_enc_str(txt)).length
+ rescue StandardError, NameError
+ # sorry, I have no plan
+ txt.length
+ end
+ end
+ end
+ private :_ktext_length
+
+ def tksearch(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ nocase = false
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt|
+ s_opt = opt.to_s
+ nocase = true if s_opt == 'nocase'
+ '-' + s_opt
+ }
+ else
+ opts = []
+ end
+
+ if args[0].kind_of?(Regexp)
+ regexp = args.shift
+ if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
+ opts << '-nocase'
+ end
+ args.unshift(regexp.source)
+ end
+
+ opts << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def tksearch_with_count(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ nocase = false
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt|
+ s_opt = opt.to_s
+ nocase = true if s_opt == 'nocase'
+ '-' + s_opt
+ }
+ else
+ opts = []
+ end
+
+ opts << '-count' << args.shift
+
+ if args[0].kind_of?(Regexp)
+ regexp = args.shift
+ if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
+ opts << '-nocase'
+ end
+ args.unshift(regexp.source)
+ end
+
+ opts << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def search_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'>=',stop)
+ txt = get(start,stop)
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get(start,'end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def search(pat,start,stop=None)
+ search_with_length(pat,start,stop)[0]
+ end
+
+ def rsearch_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'<=',stop)
+ txt = get(stop,start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(stop + " + #{pos} chars"), pat.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index(stop + " + #{pos} chars"), $&.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get('1.0',start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def rsearch(pat,start,stop=None)
+ rsearch_with_length(pat,start,stop)[0]
+ end
+
+ def dump(type_info, *index, &block)
+ args = type_info.collect{|inf| '-' + inf}
+ args << '-command' << block if block
+ str = tk_send('dump', *(args + index))
+ result = []
+ sel = nil
+ i = 0
+ while i < str.size
+ # retrieve key
+ idx = str.index(/ /, i)
+ result.push str[i..(idx-1)]
+ i = idx + 1
+
+ # retrieve value
+ case result[-1]
+ when 'text'
+ if str[i] == ?{
+ # text formed as {...}
+ val, i = _retrieve_braced_text(str, i)
+ result.push val
+ else
+ # text which may contain backslahes
+ val, i = _retrieve_backslashed_text(str, i)
+ result.push val
+ end
+ else
+ idx = str.index(/ /, i)
+ val = str[i..(idx-1)]
+ case result[-1]
+ when 'mark'
+ case val
+ when 'insert'
+ result.push TkTextMarkInsert.new(self)
+ when 'current'
+ result.push TkTextMarkCurrent.new(self)
+ when 'anchor'
+ result.push TkTextMarkAnchor.new(self)
+ else
+ result.push tk_tcl2ruby(val)
+ end
+ when 'tagon'
+ if val == 'sel'
+ if sel
+ result.push sel
+ else
+ result.push TkTextTagSel.new(self)
+ end
+ else
+ result.push tk_tcl2ruby(val)
+ end
+ when 'tagoff'
+ result.push tk_tcl2ruby(val)
+ when 'window'
+ result.push tk_tcl2ruby(val)
+ end
+ i = idx + 1
+ end
+
+ # retrieve index
+ idx = str.index(/ /, i)
+ if idx
+ result.push str[i..(idx-1)]
+ i = idx + 1
+ else
+ result.push str[i..-1]
+ break
+ end
+ end
+
+ kvis = []
+ until result.empty?
+ kvis.push [result.shift, result.shift, result.shift]
+ end
+ kvis # result is [[key1, value1, index1], [key2, value2, index2], ...]
+ end
+
+ def _retrieve_braced_text(str, i)
+ cnt = 0
+ idx = i
+ while idx < str.size
+ case str[idx]
+ when ?{
+ cnt += 1
+ when ?}
+ cnt -= 1
+ if cnt == 0
+ break
+ end
+ end
+ idx += 1
+ end
+ return str[i+1..idx-1], idx + 2
+ end
+ private :_retrieve_braced_text
+
+ def _retrieve_backslashed_text(str, i)
+ j = i
+ idx = nil
+ loop {
+ idx = str.index(/ /, j)
+ if str[idx-1] == ?\\
+ j += 1
+ else
+ break
+ end
+ }
+ val = str[i..(idx-1)]
+ val.gsub!(/\\( |\{|\})/, '\1')
+ return val, idx + 1
+ end
+ private :_retrieve_backslashed_text
+
+ def dump_all(*index, &block)
+ dump(['all'], *index, &block)
+ end
+ def dump_mark(*index, &block)
+ dump(['mark'], *index, &block)
+ end
+ def dump_tag(*index, &block)
+ dump(['tag'], *index, &block)
+ end
+ def dump_text(*index, &block)
+ dump(['text'], *index, &block)
+ end
+ def dump_window(*index, &block)
+ dump(['window'], *index, &block)
+ end
+ def dump_image(*index, &block)
+ dump(['image'], *index, &block)
+ end
+end
diff --git a/ext/tk/lib/tk/textimage.rb b/ext/tk/lib/tk/textimage.rb
new file mode 100644
index 0000000000..bd92387e3c
--- /dev/null
+++ b/ext/tk/lib/tk/textimage.rb
@@ -0,0 +1,72 @@
+#
+# tk/textimage.rb - treat Tk text image object
+#
+require 'tk'
+require 'tk/text'
+
+class TkTextImage<TkObject
+ def initialize(parent, index, keys)
+ #unless parent.kind_of?(TkText)
+ # fail ArguemntError, "expect TkText for 1st argument"
+ #end
+ @t = parent
+ if index == 'end'
+ @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
+ elsif index.kind_of? TkTextMark
+ if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ 'end - 1 chars'))
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ index.path))
+ end
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ _get_eval_enc_str(index)))
+ end
+ @path.gravity = 'left'
+ @index = @path.path
+ @id = tk_call_without_enc(@t.path, 'image', 'create', @index,
+ *hash_kv(keys, true))
+ end
+
+ def [](slot)
+ cget(slot)
+ end
+ def []=(slot, value)
+ configure(slot, value)
+ value
+ end
+
+ def cget(slot)
+ @t.image_cget(@index, slot)
+ end
+
+ def configure(slot, value=None)
+ @t.image_configure(@index, slot, value)
+ self
+ end
+# def configure(slot, value)
+# tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
+# end
+
+ def configinfo(slot = nil)
+ @t.image_configinfo(@index, slot)
+ end
+
+ def current_configinfo(slot = nil)
+ @t.current_image_configinfo(@index, slot)
+ end
+
+ def image
+ img = tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image')
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
+ end
+
+ def image=(value)
+ tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image',
+ _get_eval_enc_str(value))
+ #self
+ value
+ end
+end
diff --git a/ext/tk/lib/tk/textmark.rb b/ext/tk/lib/tk/textmark.rb
new file mode 100644
index 0000000000..6004b86028
--- /dev/null
+++ b/ext/tk/lib/tk/textmark.rb
@@ -0,0 +1,135 @@
+#
+# tk/textmark.rb - methods for treating text marks
+#
+require 'tk'
+require 'tk/text'
+
+class TkTextMark<TkObject
+ TMarkID_TBL = TkCore::INTERP.create_table
+ Tk_TextMark_ID = ['mark'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ TMarkID_TBL.clear }
+
+ def TkTextMark.id2obj(text, id)
+ tpath = text.path
+ return id unless TMarkID_TBL[tpath]
+ TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
+ end
+
+ def initialize(parent, index)
+ #unless parent.kind_of?(TkText)
+ # fail ArguemntError, "expect TkText for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ # @path = @id = Tk_TextMark_ID.join('')
+ @path = @id = Tk_TextMark_ID.join(TkCore::INTERP._ip_id_)
+ TMarkID_TBL[@id] = self
+ TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
+ TMarkID_TBL[@tpath][@id] = self
+ Tk_TextMark_ID[1].succ!
+ tk_call_without_enc(@t.path, 'mark', 'set', @id,
+ _get_eval_enc_str(index))
+ @t._addtag id, self
+ end
+
+ def id
+ @id
+ end
+
+ def exist?
+ if ( tk_split_simplelist(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'names'))).find{|id| id == @id } )
+ true
+ else
+ false
+ end
+ end
+
+ def +(mod)
+ @id + ' + ' + mod
+ end
+ def -(mod)
+ @id + ' - ' + mod
+ end
+
+ def set(where)
+ tk_call_without_enc(@t.path, 'mark', 'set', @id,
+ _get_eval_enc_str(where))
+ self
+ end
+
+ def unset
+ tk_call_without_enc(@t.path, 'mark', 'unset', @id)
+ self
+ end
+ alias destroy unset
+
+ def gravity
+ tk_call_without_enc(@t.path, 'mark', 'gravity', @id)
+ end
+
+ def gravity=(direction)
+ tk_call_without_enc(@t.path, 'mark', 'gravity', @id, direction)
+ #self
+ direction
+ end
+
+ def next(index = nil)
+ if index
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'next', _get_eval_enc_str(index))))
+ else
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'next', @id)))
+ end
+ end
+
+ def previous(index = nil)
+ if index
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'previous', _get_eval_enc_str(index))))
+ else
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'previous', @id)))
+ end
+ end
+end
+
+class TkTextNamedMark<TkTextMark
+ def self.new(parent, name, *args)
+ if TMarkID_TBL[parent.path] && TMarkID_TBL[parent.path][name]
+ return TMarkID_TBL[parent.path][name]
+ else
+ super(parent, name, *args)
+ end
+ end
+
+ def initialize(parent, name, index=nil)
+ #unless parent.kind_of?(TkText)
+ # fail ArguemntError, "expect TkText for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ TMarkID_TBL[@id] = self
+ TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
+ TMarkID_TBL[@tpath][@id] = self unless TMarkID_TBL[@tpath][@id]
+ tk_call_without_enc(@t.path, 'mark', 'set', @id,
+ _get_eval_enc_str(index)) if index
+ @t._addtag id, self
+ end
+end
+
+class TkTextMarkInsert<TkTextNamedMark
+ def self.new(parent,*args)
+ super(parent, 'insert', *args)
+ end
+end
+
+class TkTextMarkCurrent<TkTextMark
+ def self.new(parent,*args)
+ super(parent, 'current', *args)
+ end
+end
+
+class TkTextMarkAnchor<TkTextMark
+ def self.new(parent,*args)
+ super(parent, 'anchor', *args)
+ end
+end
diff --git a/ext/tk/lib/tk/texttag.rb b/ext/tk/lib/tk/texttag.rb
new file mode 100644
index 0000000000..d2611509a4
--- /dev/null
+++ b/ext/tk/lib/tk/texttag.rb
@@ -0,0 +1,253 @@
+#
+# tk/texttag.rb - methods for treating text tags
+#
+require 'tk'
+require 'tk/text'
+require 'tk/tagfont'
+
+class TkTextTag<TkObject
+ include TkTreatTagFont
+
+ TTagID_TBL = TkCore::INTERP.create_table
+ Tk_TextTag_ID = ['tag'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ TTagID_TBL.clear }
+
+ def TkTextTag.id2obj(text, id)
+ tpath = text.path
+ return id unless TTagID_TBL[tpath]
+ TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
+ end
+
+ def initialize(parent, *args)
+ #unless parent.kind_of?(TkText)
+ # fail ArguemntError, "expect TkText for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ # @path = @id = Tk_TextTag_ID.join('')
+ @path = @id = Tk_TextTag_ID.join(TkCore::INTERP._ip_id_)
+ # TTagID_TBL[@id] = self
+ TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
+ TTagID_TBL[@tpath][@id] = self
+ Tk_TextTag_ID[1].succ!
+ #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys)
+ if args != [] then
+ keys = args.pop
+ if keys.kind_of? Hash then
+ add(*args) if args != []
+ configure(keys)
+ else
+ args.push keys
+ add(*args)
+ end
+ end
+ @t._addtag id, self
+ end
+
+ def id
+ @id
+ end
+
+ def exist?
+ if ( tk_split_simplelist(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'names'))).find{|id| id == @id } )
+ true
+ else
+ false
+ end
+ end
+
+ def first
+ @id + '.first'
+ end
+
+ def last
+ @id + '.last'
+ end
+
+ def add(*indices)
+ tk_call_without_enc(@t.path, 'tag', 'add', @id,
+ *(indices.collect{|idx| _get_eval_enc_str(idx)}))
+ self
+ end
+
+ def remove(*indices)
+ tk_call_without_enc(@t.path, 'tag', 'remove', @id,
+ *(indices.collect{|idx| _get_eval_enc_str(idx)}))
+ self
+ end
+
+ def ranges
+ l = tk_split_simplelist(tk_call_without_enc(@t.path, 'tag', 'ranges', @id))
+ r = []
+ while key=l.shift
+ r.push [key, l.shift]
+ end
+ r
+ end
+
+ def nextrange(first, last=None)
+ tk_split_list(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last)))
+ end
+
+ def prevrange(first, last=None)
+ tk_split_list(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last)))
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget(key)
+ @t.tag_cget @id, key
+ end
+=begin
+ def cget(key)
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget', @id, "-#{key}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
+ @id, '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(@id, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
+ @id, "-#{key}")))
+ end
+ end
+=end
+
+ def configure(key, val=None)
+ @t.tag_configure @id, key, val
+ end
+# def configure(key, val=None)
+# if key.kind_of? Hash
+# tk_call @t.path, 'tag', 'configure', @id, *hash_kv(key)
+# else
+# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", val
+# end
+# end
+# def configure(key, value)
+# if value == FALSE
+# value = "0"
+# elsif value.kind_of? Proc
+# value = install_cmd(value)
+# end
+# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value
+# end
+
+ def configinfo(key=nil)
+ @t.tag_configinfo @id, key
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_tag_configinfo @id, key
+ end
+
+ def bind(seq, cmd=Proc.new, args=nil)
+ _bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
+ self
+ end
+
+ def bind_append(seq, cmd=Proc.new, args=nil)
+ _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
+ self
+ end
+
+ def bind_remove(seq)
+ _bind_remove([@t.path, 'tag', 'bind', @id], seq)
+ self
+ end
+
+ def bindinfo(context=nil)
+ _bindinfo([@t.path, 'tag', 'bind', @id], context)
+ end
+
+ def raise(above=None)
+ tk_call_without_enc(@t.path, 'tag', 'raise', @id,
+ _get_eval_enc_str(above))
+ self
+ end
+
+ def lower(below=None)
+ tk_call_without_enc(@t.path, 'tag', 'lower', @id,
+ _get_eval_enc_str(below))
+ self
+ end
+
+ def destroy
+ tk_call_without_enc(@t.path, 'tag', 'delete', @id)
+ TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath]
+ self
+ end
+end
+
+class TkTextNamedTag<TkTextTag
+ def self.new(parent, name, *args)
+ if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name]
+ tagobj = TTagID_TBL[parent.path][name]
+ if args != [] then
+ keys = args.pop
+ if keys.kind_of? Hash then
+ tagobj.add(*args) if args != []
+ tagobj.configure(keys)
+ else
+ args.push keys
+ tagobj.add(*args)
+ end
+ end
+ return tagobj
+ else
+ super(parent, name, *args)
+ end
+ end
+
+ def initialize(parent, name, *args)
+ #unless parent.kind_of?(TkText)
+ # fail ArguemntError, "expect TkText for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
+ TTagID_TBL[@tpath][@id] = self unless TTagID_TBL[@tpath][@id]
+ #if mode
+ # tk_call @t.path, "addtag", @id, *args
+ #end
+ if args != [] then
+ keys = args.pop
+ if keys.kind_of? Hash then
+ add(*args) if args != []
+ configure(keys)
+ else
+ args.push keys
+ add(*args)
+ end
+ end
+ @t._addtag id, self
+ end
+end
+
+class TkTextTagSel<TkTextNamedTag
+ def self.new(parent, *args)
+ super(parent, 'sel', *args)
+ end
+end
diff --git a/ext/tk/lib/tk/textwindow.rb b/ext/tk/lib/tk/textwindow.rb
new file mode 100644
index 0000000000..59fafff181
--- /dev/null
+++ b/ext/tk/lib/tk/textwindow.rb
@@ -0,0 +1,137 @@
+#
+# tk/textwindow.rb - treat Tk text window object
+#
+require 'tk'
+require 'tk/text'
+
+class TkTextWindow<TkObject
+ def initialize(parent, index, keys)
+ #unless parent.kind_of?(TkText)
+ # fail ArguemntError, "expect TkText for 1st argument"
+ #end
+ @t = parent
+ if index == 'end'
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ 'end - 1 chars'))
+ elsif index.kind_of? TkTextMark
+ if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ 'end - 1 chars'))
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ index.path))
+ end
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', _get_eval_enc_str(index)))
+ end
+ @path.gravity = 'left'
+ @index = @path.path
+ keys = _symbolkey2str(keys)
+ @id = keys['window']
+ # keys['window'] = @id.epath if @id.kind_of?(TkWindow)
+ keys['window'] = _epath(@id) if @id
+ if keys['create']
+ @p_create = keys['create']
+ if @p_create.kind_of? Proc
+=begin
+ keys['create'] = install_cmd(proc{
+ @id = @p_create.call
+ if @id.kind_of?(TkWindow)
+ @id.epath
+ else
+ @id
+ end
+ })
+=end
+ keys['create'] = install_cmd(proc{@id = @p_create.call; _epath(@id)})
+ end
+ end
+ tk_call_without_enc(@t.path, 'window', 'create', @index,
+ *hash_kv(keys, true))
+ end
+
+ def [](slot)
+ cget(slot)
+ end
+ def []=(slot, value)
+ configure(slot, value)
+ value
+ end
+
+ def cget(slot)
+ @t.window_cget(@index, slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of? Hash
+ slot = _symbolkey2str(slot)
+ if slot['window']
+ @id = slot['window']
+ # slot['window'] = @id.epath if @id.kind_of?(TkWindow)
+ slot['window'] = _epath(@id) if @id
+ end
+ if slot['create']
+ self.create=slot.delete('create')
+ end
+ if slot.size > 0
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ *hash_kv(slot, true))
+ end
+ else
+ if slot == 'window' || slot == :window
+ @id = value
+ # value = @id.epath if @id.kind_of?(TkWindow)
+ value = _epath(@id) if @id
+ end
+ if slot == 'create' || slot == :create
+ self.create=value
+ else
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ "-#{slot}", _get_eval_enc_str(value))
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ @t.window_configinfo(@index, slot)
+ end
+
+ def current_configinfo(slot = nil)
+ @t.current_window_configinfo(@index, slot)
+ end
+
+ def window
+ @id
+ end
+
+ def window=(value)
+ @id = value
+ # value = @id.epath if @id.kind_of?(TkWindow)
+ value = _epath(@id) if @id
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ '-window', _get_eval_enc_str(value))
+ value
+ end
+
+ def create
+ @p_create
+ end
+
+ def create=(value)
+ @p_create = value
+ if @p_create.kind_of? Proc
+ value = install_cmd(proc{
+ @id = @p_create.call
+ if @id.kind_of?(TkWindow)
+ @id.epath
+ else
+ @id
+ end
+ })
+ end
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ '-create', _get_eval_enc_str(value))
+ value
+ end
+end
diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb
new file mode 100644
index 0000000000..f3b6465f78
--- /dev/null
+++ b/ext/tk/lib/tk/timer.rb
@@ -0,0 +1,490 @@
+#
+# tk/timer.rb : methods for Tcl/Tk after command
+#
+# $Id$
+#
+require 'tk'
+
+class TkTimer
+ include TkCore
+ extend TkCore
+
+ TkCommandNames = ['after'.freeze].freeze
+
+ Tk_CBID = ['a'.freeze, '00000'.taint].freeze
+ Tk_CBTBL = {}.taint
+
+ TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkTimer callback} $id} ret]] != 0} {
+ return -code $st $ret
+ } {
+ return $ret
+ }
+ EOL
+
+ DEFAULT_IGNORE_EXCEPTIONS = [ NameError, RuntimeError ].freeze
+
+ ###############################
+ # class methods
+ ###############################
+ def self.start(*args, &b)
+ self.new(*args, &b).start
+ end
+
+ def self.callback(obj_id)
+ ex_obj = Tk_CBTBL[obj_id]
+ return "" if ex_obj == nil; # canceled
+ ex_obj.cb_call
+ end
+
+ def self.info(obj = nil)
+ if obj
+ if obj.kind_of?(TkTimer)
+ if obj.after_id
+ inf = tk_split_list(tk_call_without_enc('after','info',obj.after_id))
+ [Tk_CBTBL[inf[0][1]], inf[1]]
+ else
+ nil
+ end
+ else
+ fail ArgumentError, "TkTimer object is expected"
+ end
+ else
+ tk_call_without_enc('after', 'info').split(' ').collect!{|id|
+ ret = Tk_CBTBL.find{|key,val| val.after_id == id}
+ (ret == nil)? id: ret[1]
+ }
+ end
+ end
+
+
+ ###############################
+ # instance methods
+ ###############################
+ def do_callback
+ @in_callback = true
+ @after_id = nil
+ begin
+ @return_value = @current_proc.call(self)
+ rescue SystemExit
+ exit(0)
+ rescue Interrupt
+ exit!(1)
+ rescue Exception => e
+ if @cancel_on_exception &&
+ @cancel_on_exception.find{|exc| e.kind_of?(exc)}
+ cancel
+ @return_value = e
+ @in_callback = false
+ return e
+ else
+ fail e
+ end
+ end
+ if @set_next
+ set_next_callback(@current_args)
+ else
+ @set_next = true
+ end
+ @in_callback = false
+ @return_value
+ end
+
+ def set_callback(sleep, args=nil)
+ if TkCore::INTERP.deleted?
+ self.cancel
+ return self
+ end
+ @after_script = "rb_after #{@id}"
+ @after_id = tk_call_without_enc('after', sleep, @after_script)
+ @current_args = args
+ @current_script = [sleep, @after_script]
+ self
+ end
+
+ def set_next_callback(args)
+ if @running == false || @proc_max == 0 || @do_loop == 0
+ Tk_CBTBL.delete(@id) ;# for GC
+ @running = false
+ @wait_var.value = 0
+ return
+ end
+ if @current_pos >= @proc_max
+ if @do_loop < 0 || (@do_loop -= 1) > 0
+ @current_pos = 0
+ else
+ Tk_CBTBL.delete(@id) ;# for GC
+ @running = false
+ @wait_var.value = 0
+ return
+ end
+ end
+
+ @current_args = args
+
+ if @sleep_time.kind_of? Proc
+ sleep = @sleep_time.call(self)
+ else
+ sleep = @sleep_time
+ end
+ @current_sleep = sleep
+
+ cmd, *cmd_args = @loop_proc[@current_pos]
+ @current_pos += 1
+ @current_proc = cmd
+
+ set_callback(sleep, cmd_args)
+ end
+
+ def initialize(*args, &b)
+ # @id = Tk_CBID.join('')
+ @id = Tk_CBID.join(TkCore::INTERP._ip_id_)
+ Tk_CBID[1].succ!
+
+ @wait_var = TkVariable.new(0)
+
+ @cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
+
+ @set_next = true
+
+ @init_sleep = 0
+ @init_proc = nil
+ @init_args = []
+
+ @current_script = []
+ @current_proc = nil
+ @current_args = nil
+ @return_value = nil
+
+ @sleep_time = 0
+ @current_sleep = 0
+ @loop_exec = 0
+ @do_loop = 0
+ @loop_proc = []
+ @proc_max = 0
+ @current_pos = 0
+
+ @after_id = nil
+ @after_script = nil
+
+ @cancel_on_exception = DEFAULT_IGNORE_EXCEPTIONS
+ # Unless @cancel_on_exception, Ruby/Tk shows an error dialog box when
+ # an excepsion is raised on TkTimer callback procedure.
+ # If @cancel_on_exception is an array of exception classes and the raised
+ # exception is included in the array, Ruby/Tk cancels executing TkTimer
+ # callback procedures silently (TkTimer#cancel is called and no dialog is
+ # shown).
+
+ if b
+ case args.size
+ when 0
+ add_procs(b)
+ when 1
+ args << -1 << b
+ else
+ args << b
+ end
+ end
+
+ set_procs(*args) if args != []
+
+ @running = false
+ @in_callback = false
+ end
+
+ attr :after_id
+ attr :after_script
+ attr :current_proc
+ attr :current_args
+ attr :current_sleep
+ alias :current_interval :current_sleep
+ attr :return_value
+
+ attr_accessor :loop_exec
+
+ def cb_call
+ @cb_cmd.call
+ end
+
+ def get_procs
+ [@init_sleep, @init_proc, @init_args, @sleep_time, @loop_exec, @loop_proc]
+ end
+
+ def current_status
+ [@running, @current_sleep, @current_proc, @current_args,
+ @do_loop, @cancel_on_exception]
+ end
+
+ def cancel_on_exception?
+ @cancel_on_exception
+ end
+
+ def cancel_on_exception=(mode)
+ if mode.kind_of?(Array)
+ @cancel_on_exception = mode
+ elsif mode
+ @cancel_on_exception = DEFAULT_IGNORE_EXCEPTIONS
+ else
+ @cancel_on_exception = false
+ end
+ #self
+ end
+
+ def running?
+ @running
+ end
+
+ def loop_rest
+ @do_loop
+ end
+
+ def loop_rest=(rest)
+ @do_loop = rest
+ #self
+ end
+
+ def set_interval(interval)
+ if interval != 'idle' \
+ && !interval.kind_of?(Integer) && !interval.kind_of?(Proc)
+ fail ArguemntError, "expect Integer or Proc"
+ end
+ @sleep_time = interval
+ end
+
+ def set_procs(interval, loop_exec, *procs)
+ if interval != 'idle' \
+ && !interval.kind_of?(Integer) && !interval.kind_of?(Proc)
+ fail ArguemntError, "expect Integer or Proc for 1st argument"
+ end
+ @sleep_time = interval
+
+ @loop_proc = []
+ procs.each{|e|
+ if e.kind_of? Proc
+ @loop_proc.push([e])
+ else
+ @loop_proc.push(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+ @current_pos = 0
+
+ if loop_exec.kind_of?(Integer) && loop_exec < 0
+ @loop_exec = -1
+ elsif loop_exec == true
+ @loop_exec = -1
+ elsif loop_exec == nil || loop_exec == false || loop_exec == 0
+ @loop_exec = 0
+ else
+ if not loop_exec.kind_of?(Integer)
+ fail ArguemntError, "expect Integer for 2nd argument"
+ end
+ @loop_exec = loop_exec
+ end
+ @do_loop = @loop_exec
+
+ self
+ end
+
+ def add_procs(*procs)
+ procs.each{|e|
+ if e.kind_of? Proc
+ @loop_proc.push([e])
+ else
+ @loop_proc.push(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+
+ self
+ end
+
+ def delete_procs(*procs)
+ procs.each{|e|
+ if e.kind_of? Proc
+ @loop_proc.delete([e])
+ else
+ @loop_proc.delete(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+
+ cancel if @proc_max == 0
+
+ self
+ end
+
+ def delete_at(n)
+ @loop_proc.delete_at(n)
+ @proc_max = @loop_proc.size
+ cancel if @proc_max == 0
+ self
+ end
+
+ def set_start_proc(sleep=nil, init_proc=nil, *init_args, &b)
+ # set parameters for 'restart'
+ sleep = @init_sleep unless sleep
+
+ if !sleep == 'idle' && !sleep.kind_of?(Integer)
+ fail ArguemntError, "expect Integer or 'idle' for 1st argument"
+ end
+
+ @init_sleep = sleep
+ @init_proc = init_proc
+ @init_args = init_args
+
+ @init_proc = b if !@init_proc && b
+ @init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
+
+ self
+ end
+
+ def start(*init_args, &b)
+ return nil if @running
+
+ Tk_CBTBL[@id] = self
+ @do_loop = @loop_exec
+ @current_pos = 0
+ @after_id = nil
+
+ @init_sleep = 0
+ @init_proc = nil
+ @init_args = nil
+
+ argc = init_args.size
+ if argc > 0
+ sleep = init_args.shift
+ if !sleep == 'idle' && !sleep.kind_of?(Integer)
+ fail ArguemntError, "expect Integer or 'idle' for 1st argument"
+ end
+ @init_sleep = sleep
+ end
+ @init_proc = init_args.shift if argc > 1
+ @init_args = init_args if argc > 2
+
+ @init_proc = b if !@init_proc && b
+ @init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
+
+ @current_sleep = @init_sleep
+ @running = true
+ if @init_proc
+ if not @init_proc.kind_of? Proc
+ fail ArgumentError, "Argument '#{@init_proc}' need to be Proc"
+ end
+ @current_proc = @init_proc
+ set_callback(@init_sleep, @init_args)
+ @set_next = false if @in_callback
+ else
+ set_next_callback(@init_args)
+ end
+
+ self
+ end
+
+ def reset(*reset_args)
+ restart() if @running
+
+ if @init_proc
+ @return_value = @init_proc.call(self)
+ else
+ @return_value = nil
+ end
+
+ @current_pos = 0
+ @current_args = @init_args
+ @set_next = false if @in_callback
+
+ self
+ end
+
+ def restart(*restart_args, &b)
+ cancel if @running
+ if restart_args == [] && !b
+ start(@init_sleep, @init_proc, *@init_args)
+ else
+ start(*restart_args, &b)
+ end
+ end
+
+ def cancel
+ @running = false
+ @wait_var.value = 0
+ tk_call 'after', 'cancel', @after_id if @after_id
+ @after_id = nil
+ Tk_CBTBL.delete(@id) ;# for GC
+ self
+ end
+ alias stop cancel
+
+ def continue(wait=nil)
+ fail RuntimeError, "is already running" if @running
+ sleep, cmd = @current_script
+ fail RuntimeError, "no procedure to continue" unless cmd
+ if wait
+ unless wait.kind_of? Integer
+ fail ArguemntError, "expect Integer for 1st argument"
+ end
+ sleep = wait
+ end
+ Tk_CBTBL[@id] = self
+ @running = true
+ @after_id = tk_call_without_enc('after', sleep, cmd)
+ self
+ end
+
+ def skip
+ fail RuntimeError, "is not running now" unless @running
+ cancel
+ Tk_CBTBL[@id] = self
+ @running = true
+ set_next_callback(@current_args)
+ self
+ end
+
+ def info
+ if @after_id
+ inf = tk_split_list(tk_call_without_enc('after', 'info', @after_id))
+ [Tk_CBTBL[inf[0][1]], inf[1]]
+ else
+ nil
+ end
+ end
+
+ def wait(on_thread = true, check_root = false)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait timer at $SAFE >= 4"
+ end
+
+ unless @running
+ if @return_value.kind_of?(Exception)
+ fail @return_value
+ else
+ return @return_value
+ end
+ end
+
+ @wait_var.wait(on_thread, check_root)
+ if @return_value.kind_of?(Exception)
+ fail @return_value
+ else
+ @return_value
+ end
+ end
+ def eventloop_wait(check_root = false)
+ wait(false, check_root)
+ end
+ def thread_wait(check_root = false)
+ wait(true, check_root)
+ end
+ def tkwait(on_thread = true)
+ wait(on_thread, true)
+ end
+ def eventloop_tkwait
+ wait(false, true)
+ end
+ def thread_tkwait
+ wait(true, true)
+ end
+end
+
+TkAfter = TkTimer
diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb
new file mode 100644
index 0000000000..b96e184aab
--- /dev/null
+++ b/ext/tk/lib/tk/toplevel.rb
@@ -0,0 +1,232 @@
+#
+# tk/toplevel.rb : treat toplevel widget
+#
+require 'tk'
+require 'tk/wm'
+require 'tk/menuspec'
+
+class TkToplevel<TkWindow
+ include Wm
+ include TkMenuSpec
+
+ TkCommandNames = ['toplevel'.freeze].freeze
+ WidgetClassName = 'Toplevel'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+################# old version
+# def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
+# if screen.kind_of? Hash
+# keys = screen.dup
+# else
+# @screen = screen
+# end
+# @classname = classname
+# if keys.kind_of? Hash
+# keys = keys.dup
+# @classname = keys.delete('classname') if keys.key?('classname')
+# @colormap = keys.delete('colormap') if keys.key?('colormap')
+# @container = keys.delete('container') if keys.key?('container')
+# @screen = keys.delete('screen') if keys.key?('screen')
+# @use = keys.delete('use') if keys.key?('use')
+# @visual = keys.delete('visual') if keys.key?('visual')
+# end
+# super(parent, keys)
+# end
+#
+# def create_self
+# s = []
+# s << "-class" << @classname if @classname
+# s << "-colormap" << @colormap if @colormap
+# s << "-container" << @container if @container
+# s << "-screen" << @screen if @screen
+# s << "-use" << @use if @use
+# s << "-visual" << @visual if @visual
+# tk_call 'toplevel', @path, *s
+# end
+#################
+
+ def _wm_command_option_chk(keys)
+ keys = {} unless keys
+ new_keys = {}
+ wm_cmds = {}
+ keys.each{|k,v|
+ if Wm.method_defined?(k)
+ case k
+ when 'screen','class','colormap','container','use','visual'
+ new_keys[k] = v
+ else
+ case self.method(k).arity
+ when -1,1
+ wm_cmds[k] = v
+ else
+ new_keys[k] = v
+ end
+ end
+ else
+ new_keys[k] = v
+ end
+ }
+ [new_keys, wm_cmds]
+ end
+ private :_wm_command_option_chk
+
+ def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
+ my_class_name = nil
+ if self.class < WidgetClassNames[WidgetClassName]
+ my_class_name = self.class.name
+ my_class_name = nil if my_class_name == ''
+ end
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ @classname = keys['class']
+ @colormap = keys['colormap']
+ @container = keys['container']
+ @screen = keys['screen']
+ @use = keys['use']
+ @visual = keys['visual']
+ if !@classname && my_class_name
+ keys['class'] = @classname = my_class_name
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+ keys, cmds = _wm_command_option_chk(keys)
+ super(keys)
+ cmds.each{|k,v|
+ if v.kind_of? Array
+ self.__send__(k,*v)
+ else
+ self.__send__(k,v)
+ end
+ }
+ return
+ end
+
+ if screen.kind_of? Hash
+ keys = screen
+ else
+ @screen = screen
+ if classname.kind_of? Hash
+ keys = classname
+ else
+ @classname = classname
+ end
+ end
+ if keys.kind_of? Hash
+ keys = _symbolkey2str(keys)
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ @classname = keys['class'] unless @classname
+ @colormap = keys['colormap']
+ @container = keys['container']
+ @screen = keys['screen'] unless @screen
+ @use = keys['use']
+ @visual = keys['visual']
+ else
+ keys = {}
+ end
+ if !@classname && my_class_name
+ keys['class'] = @classname = my_class_name
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+ keys, cmds = _wm_command_option_chk(keys)
+ super(parent, keys)
+ cmds.each{|k,v|
+ if v.kind_of? Array
+ self.send(k,*v)
+ else
+ self.send(k,v)
+ end
+ }
+ end
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('toplevel', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('toplevel', @path)
+ # end
+ #end
+ #private :create_self
+
+ def specific_class
+ @classname
+ end
+
+ def add_menu(menu_info, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_info.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_info can override it.
+ if tearoff.kind_of?(Hash)
+ opts = tearoff
+ tearoff = false
+ end
+ _create_menubutton(self, menu_info, tearoff, opts)
+ end
+
+ def add_menubar(menu_spec, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_spec.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_spec can override it.
+ menu_spec.each{|info| add_menu(info, tearoff, opts)}
+ self.menu
+ end
+
+ def self.database_class
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ self
+ else
+ TkDatabaseClass.new(self.name)
+ end
+ end
+ def self.database_classname
+ self.database_class.name
+ end
+
+ def self.bind(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind(*args)
+ end
+ end
+ def self.bind_append(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind_append(*args)
+ end
+ end
+ def self.bind_remove(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind_remove(*args)
+ end
+ end
+ def self.bindinfo(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bindinfo(*args)
+ end
+ end
+end
diff --git a/ext/tk/lib/tk/txtwin_abst.rb b/ext/tk/lib/tk/txtwin_abst.rb
new file mode 100644
index 0000000000..5520360eab
--- /dev/null
+++ b/ext/tk/lib/tk/txtwin_abst.rb
@@ -0,0 +1,39 @@
+#
+# tk/txtwin_abst.rb : TkTextWin abstruct class
+#
+require 'tk'
+
+class TkTextWin<TkWindow
+ TkCommnadNames = [].freeze
+ #def create_self
+ # fail RuntimeError, "TkTextWin is an abstract class"
+ #end
+ #private :create_self
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', index))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+end
diff --git a/ext/tk/lib/tk/validation.rb b/ext/tk/lib/tk/validation.rb
new file mode 100644
index 0000000000..5a50de456d
--- /dev/null
+++ b/ext/tk/lib/tk/validation.rb
@@ -0,0 +1,373 @@
+#
+# tk/validation.rb - validation support module for entry, spinbox, and so on
+#
+require 'tk'
+
+module Tk
+ module ValidateConfigure
+ def self.__def_validcmd(scope, klass, keys=nil)
+ keys = klass._config_keys unless keys
+ keys.each{|key|
+ eval("def #{key}(*args, &b)
+ __validcmd_call(#{klass.name}, '#{key}', *args, &b)
+ end", scope)
+ }
+ end
+
+ def __validcmd_call(klass, key, *args, &b)
+ return cget(key) if args.empty? && !b
+
+ cmd = (b)? proc(&b) : args.shift
+
+ if cmd.kind_of?(klass)
+ configure(key, cmd)
+ elsif !args.empty?
+ configure(key, [cmd, args])
+ else
+ configure(key, cmd)
+ end
+ end
+
+ def __validation_class_list
+ # maybe need to override
+ []
+ end
+
+ def __get_validate_key2class
+ k2c = {}
+ __validation_class_list.each{|klass|
+ klass._config_keys.each{|key|
+ k2c[key.to_s] = klass
+ }
+ }
+ k2c
+ end
+
+ def __conv_vcmd_on_hash_kv(keys)
+ key2class = __get_validate_key2class
+
+ keys = _symbolkey2str(keys)
+ key2class.each{|key, klass|
+ if keys[key].kind_of?(Array)
+ cmd, *args = keys[key]
+ keys[key] = klass.new(cmd, args.join(' '))
+ elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
+ keys[key] = klass.new(keys[key])
+ end
+ }
+ keys
+ end
+
+ def create_self(keys)
+ super(__conv_vcmd_on_hash_kv(keys))
+ end
+ private :create_self
+
+ def configure(slot, value=TkComm::None)
+ if slot.kind_of?(Hash)
+ super(__conv_vcmd_on_hash_kv(slot))
+ else
+ super(__conv_vcmd_on_hash_kv(slot=>value))
+ end
+ self
+ end
+=begin
+ def configure(slot, value=TkComm::None)
+ key2class = __get_validate_key2class
+
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ key2class.each{|key, klass|
+ if slot[key].kind_of?(Array)
+ cmd, *args = slot[key]
+ slot[key] = klass.new(cmd, args.join(' '))
+ elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
+ slot[key] = klass.new(slot[key])
+ end
+ }
+ super(slot)
+
+ else
+ slot = slot.to_s
+ if (klass = key2class[slot])
+ if value.kind_of?(Array)
+ cmd, *args = value
+ value = klass.new(cmd, args.join(' '))
+ elsif value.kind_of?(Proc) || value.kind_of?(Method)
+ value = klass.new(value)
+ end
+ end
+ super(slot, value)
+ end
+
+ self
+ end
+=end
+ end
+
+ module ItemValidateConfigure
+ def self.__def_validcmd(scope, klass, keys=nil)
+ keys = klass._config_keys unless keys
+ keys.each{|key|
+ eval("def item_#{key}(id, *args, &b)
+ __item_validcmd_call(#{klass.name}, '#{key}', id, *args, &b)
+ end", scope)
+ }
+ end
+
+ def __item_validcmd_call(tagOrId, klass, key, *args, &b)
+ return itemcget(tagid(tagOrId), key) if args.empty? && !b
+
+ cmd = (b)? proc(&b) : args.shift
+
+ if cmd.kind_of?(klass)
+ itemconfigure(tagid(tagOrId), key, cmd)
+ elsif !args.empty?
+ itemconfigure(tagid(tagOrId), key, [cmd, args])
+ else
+ itemconfigure(tagid(tagOrId), key, cmd)
+ end
+ end
+
+ def __item_validation_class_list(id)
+ # maybe need to override
+ []
+ end
+
+ def __get_item_validate_key2class(id)
+ k2c = {}
+ __item_validation_class_list(id).each{|klass|
+ klass._config_keys.each{|key|
+ k2c[key.to_s] = klass
+ }
+ }
+ end
+
+ def __conv_item_vcmd_on_hash_kv(keys)
+ key2class = __get_item_validate_key2class(tagid(tagOrId))
+
+ keys = _symbolkey2str(keys)
+ key2class.each{|key, klass|
+ if keys[key].kind_of?(Array)
+ cmd, *args = keys[key]
+ keys[key] = klass.new(cmd, args.join(' '))
+ elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
+ keys[key] = klass.new(keys[key])
+ end
+ }
+ keys
+ end
+
+ def itemconfigure(tagOrId, slot, value=TkComm::None)
+ if slot.kind_of?(Hash)
+ super(__conv_item_vcmd_on_hash_kv(slot))
+ else
+ super(__conv_item_vcmd_on_hash_kv(slot=>value))
+ end
+ self
+ end
+=begin
+ def itemconfigure(tagOrId, slot, value=TkComm::None)
+ key2class = __get_item_validate_key2class(tagid(tagOrId))
+
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ key2class.each{|key, klass|
+ if slot[key].kind_of?(Array)
+ cmd, *args = slot[key]
+ slot[key] = klass.new(cmd, args.join(' '))
+ elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
+ slot[key] = klass.new(slot[key])
+ end
+ }
+ super(slot)
+
+ else
+ slot = slot.to_s
+ if (klass = key2class[slot])
+ if value.kind_of?(Array)
+ cmd, *args = value
+ value = klass.new(cmd, args.join(' '))
+ elsif value.kind_of?(Proc) || value.kind_of?(Method)
+ value = klass.new(value)
+ end
+ end
+ super(slot, value)
+ end
+
+ self
+ end
+=end
+ end
+end
+
+class TkValidateCommand
+ include TkComm
+ extend TkComm
+
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?d, ?n, :action ],
+ [ ?i, ?x, :index ],
+ [ ?s, ?e, :current ],
+ [ ?v, ?s, :type ],
+ [ ?P, ?e, :value ],
+ [ ?S, ?e, :string ],
+ [ ?V, ?s, :triggered ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?e, proc{|val|
+ enc = Tk.encoding
+ if enc
+ Tk.fromUTF8(TkComm::string(val), enc)
+ else
+ TkComm::string(val)
+ end
+ }
+ ],
+
+ [ ?x, proc{|val|
+ idx = TkComm::number(val)
+ if idx < 0
+ nil
+ else
+ idx
+ end
+ }
+ ],
+
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ #
+ # NOTE: The order of parameters which passed to callback procedure is
+ # <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
+ #
+
+ #def self._get_extra_args_tbl
+ # # return an array of convert procs
+ # []
+ #end
+
+ def self.ret_val(val)
+ (val)? '1': '0'
+ end
+ end
+
+ ###############################################
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['vcmd', 'validatecommand', 'invcmd', 'invalidcommand']
+ end
+
+ def _initialize_for_cb_class(klass, cmd = Proc.new, *args)
+ extra_args_tbl = klass._get_extra_args_tbl
+
+ if args.compact.size > 0
+ args = args.join(' ')
+ keys = klass._get_subst_key(args)
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ @id = install_cmd(cmd)
+ else
+ @id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ klass.ret_val(cmd.call(
+ *(ex_args.concat(klass.scan_args(keys, arg)))
+ ))
+ }) + ' ' + args
+ end
+ else
+ keys, args = klass._get_all_subst_keys
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ @id = install_cmd(cmd)
+ else
+ @id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ klass.ret_val(cmd.call(
+ *(ex_args << klass.new(*klass.scan_args(keys, arg)))
+ ))
+ }) + ' ' + args
+ end
+ end
+ end
+
+ def initialize(cmd = Proc.new, *args)
+ _initialize_for_cb_class(self.class::ValidateArgs, cmd, *args)
+ end
+
+ def to_eval
+ @id
+ end
+end
+
+module TkValidation
+ include Tk::ValidateConfigure
+
+ class ValidateCmd < TkValidateCommand
+ module Action
+ Insert = 1
+ Delete = 0
+ Others = -1
+ Focus = -1
+ Forced = -1
+ Textvariable = -1
+ TextVariable = -1
+ end
+ end
+
+ #####################################
+
+ def __validation_class_list
+ super << ValidateCmd
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, ValidateCmd)
+
+=begin
+ def validatecommand(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('validatecommand', cmd)
+ elsif args
+ configure('validatecommand', [cmd, args])
+ else
+ configure('validatecommand', cmd)
+ end
+ end
+=end
+# def validatecommand(*args, &b)
+# __validcmd_call(ValidateCmd, 'validatecommand', *args, &b)
+# end
+# alias vcmd validatecommand
+
+=begin
+ def invalidcommand(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('invalidcommand', cmd)
+ elsif args
+ configure('invalidcommand', [cmd, args])
+ else
+ configure('invalidcommand', cmd)
+ end
+ end
+=end
+# def invalidcommand(*args, &b)
+# __validcmd_call(ValidateCmd, 'invalidcommand', *args, &b)
+# end
+# alias invcmd invalidcommand
+end
diff --git a/ext/tk/lib/tk/variable.rb b/ext/tk/lib/tk/variable.rb
new file mode 100644
index 0000000000..62d4ec29ae
--- /dev/null
+++ b/ext/tk/lib/tk/variable.rb
@@ -0,0 +1,1016 @@
+#
+# tk/variable.rb : treat Tk variable object
+#
+require 'tk'
+
+class TkVariable
+ include Tk
+ extend TkCore
+
+ include Comparable
+
+ #TkCommandNames = ['tkwait'.freeze].freeze
+ TkCommandNames = ['vwait'.freeze].freeze
+
+ #TkVar_CB_TBL = {}
+ #TkVar_ID_TBL = {}
+ TkVar_CB_TBL = TkCore::INTERP.create_table
+ TkVar_ID_TBL = TkCore::INTERP.create_table
+ Tk_VARIABLE_ID = ["v".freeze, "00000".taint].freeze
+
+ #TkCore::INTERP.add_tk_procs('rb_var', 'args',
+ # "ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
+TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkVariable callback} $args} ret]] != 0} {
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ global errorInfo
+ set tcl_backtrace $errorInfo
+ set errorInfo [string range $ret [expr $idx + 2] \
+ [string length $ret]]
+ append errorInfo "\n" $tcl_backtrace
+ bgerror [string range $ret 0 [expr $idx - 1]]
+ } else {
+ bgerror $ret
+ }
+ return ""
+ #return -code $st $ret
+ } else {
+ return $ret
+ }
+ EOL
+
+ #def TkVariable.callback(args)
+ def TkVariable.callback(name1, name2, op)
+ #name1,name2,op = tk_split_list(args)
+ #name1,name2,op = tk_split_simplelist(args)
+ if TkVar_CB_TBL[name1]
+ #_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
+ begin
+ _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2, op))
+ rescue SystemExit
+ exit(0)
+ rescue Interrupt
+ exit!(1)
+ rescue Exception => e
+ begin
+ msg = _toUTF8(e.class.inspect) + ': ' +
+ _toUTF8(e.message) + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ _toUTF8(e.backtrace.join("\n")) +
+ "\n---< backtrace of Tk side >-------"
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ rescue Exception
+ msg = e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------"
+ end
+ fail(e, msg)
+ end
+=begin
+ begin
+ raise 'check backtrace'
+ rescue
+ # ignore backtrace before 'callback'
+ pos = -($!.backtrace.size)
+ end
+ begin
+ _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
+ rescue
+ trace = $!.backtrace
+ raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
+ "\tfrom #{trace[1..pos].join("\n\tfrom ")}"
+ end
+=end
+ else
+ ''
+ end
+ end
+
+ def self.new_hash(val = {})
+ if val.kind_of?(Hash)
+ self.new(val)
+ else
+ fail ArgumentError, 'Hash is expected'
+ end
+ end
+
+ #
+ # default_value is available only when the variable is an assoc array.
+ #
+ def default_value(val=nil, &b)
+ if b
+ @def_default = :proc
+ @default_val = proc(&b)
+ else
+ @def_default = :val
+ @default_val = val
+ end
+ self
+ end
+ def default_value=(val)
+ @def_default = :val
+ @default_val = val
+ self
+ end
+ def default_proc(cmd = Proc.new)
+ @def_default = :proc
+ @default_val = cmd
+ self
+ end
+
+ def undef_default
+ @default_val = nil
+ @def_default = false
+ self
+ end
+
+ def initialize(val="")
+ # @id = Tk_VARIABLE_ID.join('')
+ @id = Tk_VARIABLE_ID.join(TkCore::INTERP._ip_id_)
+ Tk_VARIABLE_ID[1].succ!
+ TkVar_ID_TBL[@id] = self
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ begin
+ INTERP._unset_global_var(@id)
+ rescue
+ end
+
+ # teach Tk-ip that @id is global var
+ INTERP._invoke_without_enc('global', @id)
+ #INTERP._invoke('global', @id)
+
+ # create and init
+ if val.kind_of?(Hash)
+ # assoc-array variable
+ self[''] = 0
+ self.clear
+ end
+ self.value = val
+
+=begin
+ if val == []
+ # INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)',
+ # @id, @id, @id))
+ elsif val.kind_of?(Array)
+ a = []
+ # val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
+ # s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ val.each_with_index{|e,i| a.push(i); a.push(e)}
+ #s = '"' + array2tk_list(a).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + array2tk_list(a).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
+ elsif val.kind_of?(Hash)
+ #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ # .gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ .gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
+ else
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(format('global %s; set %s %s', @id, @id, s))
+ end
+=end
+=begin
+ if val.kind_of?(Hash)
+ #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ # .gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ .gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; array set %s %s', @id, @id, s))
+ else
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s))
+ end
+=end
+ end
+
+ def wait(on_thread = false, check_root = false)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait variable at $SAFE >= 4"
+ end
+ on_thread &= (Thread.list.size != 1)
+ if on_thread
+ if check_root
+ INTERP._thread_tkwait('variable', @id)
+ else
+ INTERP._thread_vwait(@id)
+ end
+ else
+ if check_root
+ INTERP._invoke_without_enc('tkwait', 'variable', @id)
+ else
+ INTERP._invoke_without_enc('vwait', @id)
+ end
+ end
+ end
+ def eventloop_wait(check_root = false)
+ wait(false, check_root)
+ end
+ def thread_wait(check_root = false)
+ wait(true, check_root)
+ end
+ def tkwait(on_thread = true)
+ wait(on_thread, true)
+ end
+ def eventloop_tkwait
+ wait(false, true)
+ end
+ def thread_tkwait
+ wait(true, true)
+ end
+
+ def id
+ @id
+ end
+
+ def ref(*idxs)
+ # "#{@id}(#{idxs.collect{|idx| _get_eval_string(idx)}.join(',')})"
+ TkVarAccess.new("#{@id}(#{idxs.collect{|idx| _get_eval_string(idx)}.join(',')})")
+ end
+
+ def is_hash?
+ #ITNERP._eval("global #{@id}; array exist #{@id}") == '1'
+ INTERP._invoke_without_enc('global', @id)
+ INTERP._invoke_without_enc('array', 'exist', @id) == '1'
+ end
+
+ def is_scalar?
+ ! is_hash?
+ end
+
+ def keys
+ if (is_scalar?)
+ fail RuntimeError, 'cannot get keys from a scalar variable'
+ end
+ #tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))
+ INTERP._invoke_without_enc('global', @id)
+ tk_split_simplelist(INTERP._fromUTF8(INTERP._invoke_without_enc('array', 'names', @id)))
+ end
+
+ def clear
+ if (is_scalar?)
+ fail RuntimeError, 'cannot clear a scalar variable'
+ end
+ keys.each{|k| unset(k)}
+ self
+ end
+
+ def update(hash)
+ if (is_scalar?)
+ fail RuntimeError, 'cannot update a scalar variable'
+ end
+ hash.each{|k,v| self[k] = v}
+ self
+ end
+
+
+unless const_defined?(:USE_TCLs_SET_VARIABLE_FUNCTIONS)
+ USE_TCLs_SET_VARIABLE_FUNCTIONS = true
+end
+
+if USE_TCLs_SET_VARIABLE_FUNCTIONS
+ ###########################################################################
+ # use Tcl function version of set tkvariable
+ ###########################################################################
+
+ def value
+ #if INTERP._eval("global #{@id}; array exist #{@id}") == '1'
+ INTERP._invoke_without_enc('global', @id)
+ if INTERP._invoke('array', 'exist', @id) == '1'
+ #Hash[*tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))]
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', @id))]
+ else
+ _fromUTF8(INTERP._get_global_var(@id))
+ end
+ end
+
+ def value=(val)
+ if val.kind_of?(Hash)
+ self.clear
+ val.each{|k, v|
+ #INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)),
+ # _toUTF8(_get_eval_string(v)))
+ INTERP._set_global_var2(@id, _get_eval_string(k, true),
+ _get_eval_string(v, true))
+ }
+ self.value
+ elsif val.kind_of?(Array)
+ INTERP._set_global_var(@id, '')
+ val.each{|v|
+ #INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)),
+ INTERP._set_variable(@id, _get_eval_string(v, true),
+ TclTkLib::VarAccessFlag::GLOBAL_ONLY |
+ TclTkLib::VarAccessFlag::LEAVE_ERR_MSG |
+ TclTkLib::VarAccessFlag::APPEND_VALUE |
+ TclTkLib::VarAccessFlag::LIST_ELEMENT)
+ }
+ self.value
+ else
+ #_fromUTF8(INTERP._set_global_var(@id, _toUTF8(_get_eval_string(val))))
+ _fromUTF8(INTERP._set_global_var(@id, _get_eval_string(val, true)))
+ end
+ end
+
+ def [](*idxs)
+ index = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ begin
+ _fromUTF8(INTERP._get_global_var2(@id, index))
+ rescue => e
+ case @def_default
+ when :proc
+ @default_val.call(self, *idxs)
+ when :val
+ @default_val
+ else
+ fail e
+ end
+ end
+ #_fromUTF8(INTERP._get_global_var2(@id, index))
+ #_fromUTF8(INTERP._get_global_var2(@id, _toUTF8(_get_eval_string(index))))
+ #_fromUTF8(INTERP._get_global_var2(@id, _get_eval_string(index, true)))
+ end
+
+ def []=(*args)
+ val = args.pop
+ index = args.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ _fromUTF8(INTERP._set_global_var2(@id, index, _get_eval_string(val, true)))
+ #_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)),
+ # _toUTF8(_get_eval_string(val))))
+ #_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true),
+ # _get_eval_string(val, true)))
+ end
+
+ def unset(elem=nil)
+ if elem
+ INTERP._unset_global_var2(@id, _get_eval_string(elem, true))
+ else
+ INTERP._unset_global_var(@id)
+ end
+ end
+ alias remove unset
+
+else
+ ###########################################################################
+ # use Ruby script version of set tkvariable (traditional methods)
+ ###########################################################################
+
+ def value
+ begin
+ INTERP._eval(Kernel.format('global %s; set %s', @id, @id))
+ #INTERP._eval(Kernel.format('set %s', @id))
+ #INTERP._invoke_without_enc('set', @id)
+ rescue
+ if INTERP._eval(Kernel.format('global %s; array exists %s',
+ @id, @id)) != "1"
+ #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
+ #if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
+ fail
+ else
+ Hash[*tk_split_simplelist(INTERP._eval(Kernel.format('global %s; array get %s', @id, @id)))]
+ #Hash[*tk_split_simplelist(_fromUTF8(INTERP._invoke_without_enc('array', 'get', @id)))]
+ end
+ end
+ end
+
+ def value=(val)
+ begin
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s))
+ #INTERP._eval(Kernel.format('set %s %s', @id, s))
+ #_fromUTF8(INTERP._invoke_without_enc('set', @id, _toUTF8(s)))
+ rescue
+ if INTERP._eval(Kernel.format('global %s; array exists %s',
+ @id, @id)) != "1"
+ #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
+ #if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
+ fail
+ else
+ if val == []
+ INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id))
+ #INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)',
+ # @id, @id, @id))
+ #INTERP._invoke_without_enc('unset', @id)
+ #INTERP._invoke_without_enc('set', @id+'(0)', 0)
+ #INTERP._invoke_without_enc('unset', @id+'(0)')
+ elsif val.kind_of?(Array)
+ a = []
+ val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
+ #s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
+ @id, @id, @id, s))
+ #INTERP._eval(Kernel.format('unset %s; array set %s %s',
+ # @id, @id, s))
+ #INTERP._invoke_without_enc('unset', @id)
+ #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
+ elsif val.kind_of?(Hash)
+ #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ # .gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ .gsub(/[\[\]$\\"]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
+ @id, @id, @id, s))
+ #INTERP._eval(Kernel.format('unset %s; array set %s %s',
+ # @id, @id, s))
+ #INTERP._invoke_without_enc('unset', @id)
+ #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
+ else
+ fail
+ end
+ end
+ end
+ end
+
+ def [](*idxs)
+ index = idxs.collect{|idx| _get_eval_string(idx)}.join(',')
+ begin
+ INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
+ rescue => e
+ case @def_default
+ when :proc
+ @default_val.call(self, *idxs)
+ when :val
+ @default_val
+ else
+ fail e
+ end
+ end
+ #INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
+ #INTERP._eval(Kernel.format('global %s; set %s(%s)',
+ # @id, @id, _get_eval_string(index)))
+ #INTERP._eval(Kernel.format('set %s(%s)', @id, _get_eval_string(index)))
+ #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ')')
+ end
+
+ def []=(*args)
+ val = args.pop
+ index = args.collect{|idx| _get_eval_string(idx)}.join(',')
+ INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
+ index, _get_eval_string(val)))
+ #INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
+ # _get_eval_string(index), _get_eval_string(val)))
+ #INTERP._eval(Kernel.format('set %s(%s) %s', @id,
+ # _get_eval_string(index), _get_eval_string(val)))
+ #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' +
+ # _get_eval_string(val))
+ end
+
+ def unset(elem=nil)
+ if elem
+ INTERP._eval(Kernel.format('global %s; unset %s(%s)',
+ @id, @id, _get_eval_string(elem)))
+ #INTERP._eval(Kernel.format('unset %s(%s)', @id, tk_tcl2ruby(elem)))
+ #INTERP._eval('unset ' + @id + '(' + _get_eval_string(elem) + ')')
+ else
+ INTERP._eval(Kernel.format('global %s; unset %s', @id, @id))
+ #INTERP._eval(Kernel.format('unset %s', @id))
+ #INTERP._eval('unset ' + @id)
+ end
+ end
+ alias remove unset
+
+end
+
+ def numeric
+ number(value)
+ end
+ def numeric=(val)
+ case val
+ when Numeric
+ self.value=(val)
+ when TkVariable
+ self.value=(val.numeric)
+ else
+ raise ArgumentError, "Numeric is expected"
+ end
+ val
+ end
+
+ def bool
+ # see Tcl_GetBoolean man-page
+ case value.downcase
+ when '0', 'false', 'no', 'off'
+ false
+ else
+ true
+ end
+ end
+
+ def bool=(val)
+ if ! val
+ self.value = '0'
+ else
+ case val.to_s.downcase
+ when 'false', '0', 'no', 'off'
+ self.value = '0'
+ else
+ self.value = '1'
+ end
+ end
+ end
+
+ def to_i
+ number(value).to_i
+ end
+
+ def to_f
+ number(value).to_f
+ end
+
+ def to_s
+ #string(value).to_s
+ value
+ end
+
+ def to_sym
+ value.intern
+ end
+
+ def list
+ #tk_split_list(value)
+ tk_split_simplelist(value)
+ end
+ alias to_a list
+
+ def list=(val)
+ case val
+ when Array
+ self.value=(val)
+ when TkVariable
+ self.value=(val.list)
+ else
+ raise ArgumentError, "Array is expected"
+ end
+ val
+ end
+
+ def inspect
+ #Kernel.format "#<TkVariable: %s>", @id
+ '#<TkVariable: ' + @id + '>'
+ end
+
+ def coerce(other)
+ case other
+ when TkVariable
+ [other.value, self.value]
+ when String
+ [other, self.to_s]
+ when Symbol
+ [other, self.to_sym]
+ when Integer
+ [other, self.to_i]
+ when Float
+ [other, self.to_f]
+ when Array
+ [other, self.to_a]
+ else
+ [other, self.value]
+ end
+ end
+
+ def &(other)
+ if other.kind_of?(Array)
+ self.to_a & other.to_a
+ else
+ self.to_i & other.to_i
+ end
+ end
+ def |(other)
+ if other.kind_of?(Array)
+ self.to_a | other.to_a
+ else
+ self.to_i | other.to_i
+ end
+ end
+ def +(other)
+ case other
+ when Array
+ self.to_a + other
+ when String
+ self.value + other
+ else
+ begin
+ number(self.value) + other
+ rescue
+ self.value + other.to_s
+ end
+ end
+ end
+ def -(other)
+ if other.kind_of?(Array)
+ self.to_a - other
+ else
+ number(self.value) - other
+ end
+ end
+ def *(other)
+ begin
+ number(self.value) * other
+ rescue
+ self.value * other
+ end
+ end
+ def /(other)
+ number(self.value) / other
+ end
+ def %(other)
+ begin
+ number(self.value) % other
+ rescue
+ self.value % other
+ end
+ end
+ def **(other)
+ number(self.value) ** other
+ end
+ def =~(other)
+ self.value =~ other
+ end
+
+ def ==(other)
+ case other
+ when TkVariable
+ self.equal?(other)
+ when String
+ self.to_s == other
+ when Symbol
+ self.to_sym == other
+ when Integer
+ self.to_i == other
+ when Float
+ self.to_f == other
+ when Array
+ self.to_a == other
+ when Hash
+ self.value == other
+ else
+ false
+ end
+ end
+
+ def zero?
+ numeric.zero?
+ end
+ def nonzero?
+ !(numeric.zero?)
+ end
+
+ def <=>(other)
+ if other.kind_of?(TkVariable)
+ begin
+ val = other.numeric
+ other = val
+ rescue
+ other = other.value
+ end
+ end
+ if other.kind_of?(Numeric)
+ begin
+ return self.numeric <=> other
+ rescue
+ return self.value <=> other.to_s
+ end
+ else
+ return self.value <=> other
+ end
+ end
+
+ def to_eval
+ @id
+ end
+
+ def trace_callback(elem, op)
+ if @trace_var.kind_of? Array
+ @trace_var.each{|m,e| e.call(self,elem,op) if m.index(op)}
+ end
+ if elem.kind_of?(String) && elem != ''
+ if @trace_elem.kind_of?(Hash) && @trace_elem[elem].kind_of?(Array)
+ @trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)}
+ end
+ end
+ end
+
+ def trace(opts, cmd = Proc.new)
+ @trace_var = [] if @trace_var == nil
+ #opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+ opts = ['r','w','u'].find_all{|c| opts.to_s.index(c)}.join('')
+ @trace_var.unshift([opts,cmd])
+ if @trace_opts == nil
+ TkVar_CB_TBL[@id] = self
+ @trace_opts = opts.dup
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+ end
+=end
+ else
+ newopts = @trace_opts.dup
+ #opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var')
+ end
+=end
+ end
+ end
+ self
+ end
+
+ def trace_element(elem, opts, cmd = Proc.new)
+ @trace_elem = {} if @trace_elem == nil
+ @trace_elem[elem] = [] if @trace_elem[elem] == nil
+ #opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+ opts = ['r','w','u'].find_all{|c| opts.to_s.index(c)}.join('')
+ @trace_elem[elem].unshift([opts,cmd])
+ if @trace_opts == nil
+ TkVar_CB_TBL[@id] = self
+ @trace_opts = opts.dup
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var')
+ end
+=end
+ else
+ newopts = @trace_opts.dup
+ # opts.each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var')
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var')
+ end
+=end
+ end
+ end
+ self
+ end
+
+ def trace_vinfo
+ return [] unless @trace_var
+ @trace_var.dup
+ end
+ def trace_vinfo_for_element(elem)
+ return [] unless @trace_elem
+ return [] unless @trace_elem[elem]
+ @trace_elem[elem].dup
+ end
+
+ def trace_vdelete(opts,cmd)
+ return self unless @trace_var.kind_of? Array
+ #opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+ opts = ['r','w','u'].find_all{|c| opts.to_s.index(c)}.join('')
+ idx = -1
+ newopts = ''
+ @trace_var.each_with_index{|e,i|
+ if idx < 0 && e[0] == opts && e[1] == cmd
+ idx = i
+ next
+ end
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ }
+ if idx >= 0
+ @trace_var.delete_at(idx)
+ else
+ return self
+ end
+
+ @trace_elem.each{|elem|
+ @trace_elem[elem].each{|e|
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ }
+ }
+
+ #newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('')
+ newopts = ['r','w','u'].find_all{|c| newopts.to_s.index(c)}.join('')
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var')
+ end
+=end
+ @trace_opts.replace(newopts)
+ if @trace_opts != ''
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var')
+ end
+=end
+ end
+ end
+
+ self
+ end
+
+ def trace_vdelete_for_element(elem,opts,cmd)
+ return self unless @trace_elem.kind_of? Hash
+ return self unless @trace_elem[elem].kind_of? Array
+ # opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
+ opts = ['r','w','u'].find_all{|c| opts.to_s.index(c)}.join('')
+ idx = -1
+ @trace_elem[elem].each_with_index{|e,i|
+ if idx < 0 && e[0] == opts && e[1] == cmd
+ idx = i
+ next
+ end
+ }
+ if idx >= 0
+ @trace_elem[elem].delete_at(idx)
+ else
+ return self
+ end
+
+ newopts = ''
+ @trace_var.each{|e|
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ }
+ @trace_elem.each{|elem|
+ @trace_elem[elem].each{|e|
+ # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)}
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)}
+ }
+ }
+
+ #newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('')
+ newopts = ['r','w','u'].find_all{|c| newopts.to_s.index(c)}.join('')
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var')
+ end
+=end
+ @trace_opts.replace(newopts)
+ if @trace_opts != ''
+ Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var')
+=begin
+ if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION
+ # TCL_VERSION >= 8.4
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var')
+ else
+ # TCL_VERSION <= 8.3
+ Tk.tk_call_without_enc('trace', 'variable', @id,
+ @trace_opts, 'rb_var')
+ end
+=end
+ end
+ end
+
+ self
+ end
+end
+
+
+class TkVarAccess<TkVariable
+ def self.new(name, *args)
+ return TkVar_ID_TBL[name] if TkVar_ID_TBL[name]
+ super(name, *args)
+ end
+
+ def self.new_hash(name, *args)
+ return TkVar_ID_TBL[name] if TkVar_ID_TBL[name]
+ INTERP._invoke_without_enc('global', name)
+ if args.empty? && INTERP._invoke_without_enc('array', 'exist', name) == '0'
+ self.new(name, {}) # force creating
+ else
+ self.new(name, *args)
+ end
+ end
+
+ def initialize(varname, val=nil)
+ @id = varname
+ TkVar_ID_TBL[@id] = self
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ # teach Tk-ip that @id is global var
+ INTERP._invoke_without_enc('global', @id)
+
+ if val
+ if val.kind_of?(Hash)
+ # assoc-array variable
+ self[''] = 0
+ self.clear
+ end
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"' #"
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"' #"
+ #INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s))
+ #INTERP._set_global_var(@id, _toUTF8(_get_eval_string(val)))
+ self.value = val
+ end
+ end
+end
+
+
+module Tk
+ begin
+ auto_path = INTERP._invoke('set', 'auto_path')
+ rescue
+ begin
+ auto_path = INTERP._invoke('set', 'env(TCLLIBPATH)')
+ rescue
+ auto_path = Tk::LIBRARY
+ end
+ end
+
+ AUTO_PATH = TkVarAccess.new('auto_path', auto_path)
+
+=begin
+ AUTO_OLDPATH = tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath'))
+ AUTO_OLDPATH.each{|s| s.freeze}
+ AUTO_OLDPATH.freeze
+=end
+
+ TCL_PACKAGE_PATH = TkVarAccess.new('tcl_pkgPath')
+ PACKAGE_PATH = TCL_PACKAGE_PATH
+
+ TCL_LIBRARY_PATH = TkVarAccess.new('tcl_libPath')
+ LIBRARY_PATH = TCL_LIBRARY_PATH
+
+ TCL_PRECISION = TkVarAccess.new('tcl_precision')
+end
diff --git a/ext/tk/lib/tk/virtevent.rb b/ext/tk/lib/tk/virtevent.rb
new file mode 100644
index 0000000000..c82cfe46e8
--- /dev/null
+++ b/ext/tk/lib/tk/virtevent.rb
@@ -0,0 +1,90 @@
+#
+# tk/virtevent.rb : treats virtual events
+# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+class TkVirtualEvent<TkObject
+ extend Tk
+
+ TkCommandNames = ['event'.freeze].freeze
+
+ TkVirtualEventID = ["VirtEvent".freeze, "00000".taint].freeze
+ TkVirtualEventTBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{ TkVirtualEventTBL.clear }
+
+ class PreDefVirtEvent<self
+ def initialize(event)
+ @path = @id = event
+ TkVirtualEvent::TkVirtualEventTBL[@id] = self
+ end
+ end
+
+ def TkVirtualEvent.getobj(event)
+ obj = TkVirtualEventTBL[event]
+ if obj
+ obj
+ else
+ if tk_call_without_enc('event', 'info').index("<#{event}>")
+ PreDefVirtEvent.new(event)
+ else
+ fail ArgumentError, "undefined virtual event '<#{event}>'"
+ end
+ end
+ end
+
+ def TkVirtualEvent.info
+ tk_call_without_enc('event', 'info').split(/\s+/).collect!{|seq|
+ TkVirtualEvent.getobj(seq[1..-2])
+ }
+ end
+
+ def initialize(*sequences)
+ # @path = @id = '<' + TkVirtualEventID.join('') + '>'
+ @path = @id = '<' + TkVirtualEventID.join(TkCore::INTERP._ip_id_) + '>'
+ TkVirtualEventID[1].succ!
+ add(*sequences)
+ end
+
+ def add(*sequences)
+ if sequences != []
+ tk_call_without_enc('event', 'add', "<#{@id}>",
+ *(sequences.collect{|seq|
+ "<#{tk_event_sequence(seq)}>"
+ }) )
+ TkVirtualEventTBL[@id] = self
+ end
+ self
+ end
+
+ def delete(*sequences)
+ if sequences == []
+ tk_call_without_enc('event', 'delete', "<#{@id}>")
+ TkVirtualEventTBL.delete(@id)
+ else
+ tk_call_without_enc('event', 'delete', "<#{@id}>",
+ *(sequences.collect{|seq|
+ "<#{tk_event_sequence(seq)}>"
+ }) )
+ TkVirtualEventTBL.delete(@id) if info == []
+ end
+ self
+ end
+
+ def info
+ tk_call_without_enc('event','info',"<#{@id}>").split(/\s+/).collect!{|seq|
+ l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
+ case (subseq)
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(subseq[1..-2])
+ when /^<[^<>]+>$/
+ subseq[1..-2]
+ else
+ subseq.split('')
+ end
+ }.flatten
+ (l.size == 1) ? l[0] : l
+ }
+ end
+end
diff --git a/ext/tk/lib/tk/winfo.rb b/ext/tk/lib/tk/winfo.rb
new file mode 100644
index 0000000000..948042558d
--- /dev/null
+++ b/ext/tk/lib/tk/winfo.rb
@@ -0,0 +1,387 @@
+#
+# tk/winfo.rb : methods for winfo command
+#
+module TkWinfo
+end
+
+require 'tk'
+
+module TkWinfo
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['winfo'.freeze].freeze
+
+ def TkWinfo.atom(name, win=nil)
+ if win
+ number(tk_call_without_enc('winfo', 'atom', '-displayof', win,
+ _get_eval_enc_str(name)))
+ else
+ number(tk_call_without_enc('winfo', 'atom', _get_eval_enc_str(name)))
+ end
+ end
+ def winfo_atom(name)
+ TkWinfo.atom(name, self)
+ end
+
+ def TkWinfo.atomname(id, win=nil)
+ if win
+ _fromUTF8(tk_call_without_enc('winfo', 'atomname',
+ '-displayof', win, id))
+ else
+ _fromUTF8(tk_call_without_enc('winfo', 'atomname', id))
+ end
+ end
+ def winfo_atomname(id)
+ TkWinfo.atomname(id, self)
+ end
+
+ def TkWinfo.cells(window)
+ number(tk_call_without_enc('winfo', 'cells', window))
+ end
+ def winfo_cells
+ TkWinfo.cells self
+ end
+
+ def TkWinfo.children(window)
+ list(tk_call_without_enc('winfo', 'children', window))
+ end
+ def winfo_children
+ TkWinfo.children self
+ end
+
+ def TkWinfo.classname(window)
+ tk_call_without_enc('winfo', 'class', window)
+ end
+ def winfo_classname
+ TkWinfo.classname self
+ end
+ alias winfo_class winfo_classname
+
+ def TkWinfo.colormapfull(window)
+ bool(tk_call_without_enc('winfo', 'colormapfull', window))
+ end
+ def winfo_colormapfull
+ TkWinfo.colormapfull self
+ end
+
+ def TkWinfo.containing(rootX, rootY, win=nil)
+ if win
+ window(tk_call_without_enc('winfo', 'containing',
+ '-displayof', win, rootX, rootY))
+ else
+ window(tk_call_without_enc('winfo', 'containing', rootX, rootY))
+ end
+ end
+ def winfo_containing(x, y)
+ TkWinfo.containing(x, y, self)
+ end
+
+ def TkWinfo.depth(window)
+ number(tk_call_without_enc('winfo', 'depth', window))
+ end
+ def winfo_depth
+ TkWinfo.depth self
+ end
+
+ def TkWinfo.exist?(window)
+ bool(tk_call_without_enc('winfo', 'exists', window))
+ end
+ def winfo_exist?
+ TkWinfo.exist? self
+ end
+
+ def TkWinfo.fpixels(window, dist)
+ number(tk_call_without_enc('winfo', 'fpixels', window, dist))
+ end
+ def winfo_fpixels(dist)
+ TkWinfo.fpixels self, dist
+ end
+
+ def TkWinfo.geometry(window)
+ tk_call_without_enc('winfo', 'geometry', window)
+ end
+ def winfo_geometry
+ TkWinfo.geometry self
+ end
+
+ def TkWinfo.height(window)
+ number(tk_call_without_enc('winfo', 'height', window))
+ end
+ def winfo_height
+ TkWinfo.height self
+ end
+
+ def TkWinfo.id(window)
+ tk_call_without_enc('winfo', 'id', window)
+ end
+ def winfo_id
+ TkWinfo.id self
+ end
+
+ def TkWinfo.interps(window=nil)
+ if window
+ tk_split_simplelist(tk_call_without_enc('winfo', 'interps',
+ '-displayof', window))
+ else
+ tk_split_simplelist(tk_call_without_enc('winfo', 'interps'))
+ end
+ end
+ def winfo_interps
+ TkWinfo.interps self
+ end
+
+ def TkWinfo.mapped?(window)
+ bool(tk_call_without_enc('winfo', 'ismapped', window))
+ end
+ def winfo_mapped?
+ TkWinfo.mapped? self
+ end
+
+ def TkWinfo.manager(window)
+ tk_call_without_enc('winfo', 'manager', window)
+ end
+ def winfo_manager
+ TkWinfo.manager self
+ end
+
+ def TkWinfo.appname(window)
+ tk_call('winfo', 'name', window)
+ end
+ def winfo_appname
+ TkWinfo.appname self
+ end
+
+ def TkWinfo.parent(window)
+ window(tk_call_without_enc('winfo', 'parent', window))
+ end
+ def winfo_parent
+ TkWinfo.parent self
+ end
+
+ def TkWinfo.widget(id, win=nil)
+ if win
+ window(tk_call_without_enc('winfo', 'pathname', '-displayof', win, id))
+ else
+ window(tk_call_without_enc('winfo', 'pathname', id))
+ end
+ end
+ def winfo_widget(id)
+ TkWinfo.widget id, self
+ end
+
+ def TkWinfo.pixels(window, dist)
+ number(tk_call_without_enc('winfo', 'pixels', window, dist))
+ end
+ def winfo_pixels(dist)
+ TkWinfo.pixels self, dist
+ end
+
+ def TkWinfo.reqheight(window)
+ number(tk_call_without_enc('winfo', 'reqheight', window))
+ end
+ def winfo_reqheight
+ TkWinfo.reqheight self
+ end
+
+ def TkWinfo.reqwidth(window)
+ number(tk_call_without_enc('winfo', 'reqwidth', window))
+ end
+ def winfo_reqwidth
+ TkWinfo.reqwidth self
+ end
+
+ def TkWinfo.rgb(window, color)
+ list(tk_call_without_enc('winfo', 'rgb', window, color))
+ end
+ def winfo_rgb(color)
+ TkWinfo.rgb self, color
+ end
+
+ def TkWinfo.rootx(window)
+ number(tk_call_without_enc('winfo', 'rootx', window))
+ end
+ def winfo_rootx
+ TkWinfo.rootx self
+ end
+
+ def TkWinfo.rooty(window)
+ number(tk_call_without_enc('winfo', 'rooty', window))
+ end
+ def winfo_rooty
+ TkWinfo.rooty self
+ end
+
+ def TkWinfo.screen(window)
+ tk_call('winfo', 'screen', window)
+ end
+ def winfo_screen
+ TkWinfo.screen self
+ end
+
+ def TkWinfo.screencells(window)
+ number(tk_call_without_enc('winfo', 'screencells', window))
+ end
+ def winfo_screencells
+ TkWinfo.screencells self
+ end
+
+ def TkWinfo.screendepth(window)
+ number(tk_call_without_enc('winfo', 'screendepth', window))
+ end
+ def winfo_screendepth
+ TkWinfo.screendepth self
+ end
+
+ def TkWinfo.screenheight (window)
+ number(tk_call_without_enc('winfo', 'screenheight', window))
+ end
+ def winfo_screenheight
+ TkWinfo.screenheight self
+ end
+
+ def TkWinfo.screenmmheight(window)
+ number(tk_call_without_enc('winfo', 'screenmmheight', window))
+ end
+ def winfo_screenmmheight
+ TkWinfo.screenmmheight self
+ end
+
+ def TkWinfo.screenmmwidth(window)
+ number(tk_call_without_enc('winfo', 'screenmmwidth', window))
+ end
+ def winfo_screenmmwidth
+ TkWinfo.screenmmwidth self
+ end
+
+ def TkWinfo.screenvisual(window)
+ tk_call_without_enc('winfo', 'screenvisual', window)
+ end
+ def winfo_screenvisual
+ TkWinfo.screenvisual self
+ end
+
+ def TkWinfo.screenwidth(window)
+ number(tk_call_without_enc('winfo', 'screenwidth', window))
+ end
+ def winfo_screenwidth
+ TkWinfo.screenwidth self
+ end
+
+ def TkWinfo.server(window)
+ tk_call('winfo', 'server', window)
+ end
+ def winfo_server
+ TkWinfo.server self
+ end
+
+ def TkWinfo.toplevel(window)
+ window(tk_call_without_enc('winfo', 'toplevel', window))
+ end
+ def winfo_toplevel
+ TkWinfo.toplevel self
+ end
+
+ def TkWinfo.visual(window)
+ tk_call_without_enc('winfo', 'visual', window)
+ end
+ def winfo_visual
+ TkWinfo.visual self
+ end
+
+ def TkWinfo.visualid(window)
+ tk_call_without_enc('winfo', 'visualid', window)
+ end
+ def winfo_visualid
+ TkWinfo.visualid self
+ end
+
+ def TkWinfo.visualsavailable(window, includeids=false)
+ if includeids
+ list(tk_call_without_enc('winfo', 'visualsavailable',
+ window, "includeids"))
+ else
+ list(tk_call_without_enc('winfo', 'visualsavailable', window))
+ end
+ end
+ def winfo_visualsavailable(includeids=false)
+ TkWinfo.visualsavailable self, includeids
+ end
+
+ def TkWinfo.vrootheight(window)
+ number(tk_call_without_enc('winfo', 'vrootheight', window))
+ end
+ def winfo_vrootheight
+ TkWinfo.vrootheight self
+ end
+
+ def TkWinfo.vrootwidth(window)
+ number(tk_call_without_enc('winfo', 'vrootwidth', window))
+ end
+ def winfo_vrootwidth
+ TkWinfo.vrootwidth self
+ end
+
+ def TkWinfo.vrootx(window)
+ number(tk_call_without_enc('winfo', 'vrootx', window))
+ end
+ def winfo_vrootx
+ TkWinfo.vrootx self
+ end
+
+ def TkWinfo.vrooty(window)
+ number(tk_call_without_enc('winfo', 'vrooty', window))
+ end
+ def winfo_vrooty
+ TkWinfo.vrooty self
+ end
+
+ def TkWinfo.width(window)
+ number(tk_call_without_enc('winfo', 'width', window))
+ end
+ def winfo_width
+ TkWinfo.width self
+ end
+
+ def TkWinfo.x(window)
+ number(tk_call_without_enc('winfo', 'x', window))
+ end
+ def winfo_x
+ TkWinfo.x self
+ end
+
+ def TkWinfo.y(window)
+ number(tk_call_without_enc('winfo', 'y', window))
+ end
+ def winfo_y
+ TkWinfo.y self
+ end
+
+ def TkWinfo.viewable(window)
+ bool(tk_call_without_enc('winfo', 'viewable', window))
+ end
+ def winfo_viewable
+ TkWinfo.viewable self
+ end
+
+ def TkWinfo.pointerx(window)
+ number(tk_call_without_enc('winfo', 'pointerx', window))
+ end
+ def winfo_pointerx
+ TkWinfo.pointerx self
+ end
+
+ def TkWinfo.pointery(window)
+ number(tk_call_without_enc('winfo', 'pointery', window))
+ end
+ def winfo_pointery
+ TkWinfo.pointery self
+ end
+
+ def TkWinfo.pointerxy(window)
+ list(tk_call_without_enc('winfo', 'pointerxy', window))
+ end
+ def winfo_pointerxy
+ TkWinfo.pointerxy self
+ end
+end
diff --git a/ext/tk/lib/tk/winpkg.rb b/ext/tk/lib/tk/winpkg.rb
new file mode 100644
index 0000000000..d6f7a0e9d4
--- /dev/null
+++ b/ext/tk/lib/tk/winpkg.rb
@@ -0,0 +1,138 @@
+#
+# tk/winpkg.rb : methods for Tcl/Tk packages for Microsoft Windows
+# 2000/11/22 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+# ATTENTION !!
+# This is NOT TESTED. Because I have no test-environment.
+#
+require 'tk'
+
+module TkWinDDE
+ extend Tk
+ extend TkWinDDE
+
+ TkCommandNames = ['dde'.freeze].freeze
+
+ if self.const_defined? :FORCE_VERSION
+ tk_call_without_enc('package', 'require', 'dde', FORCE_VERSION)
+ else
+ tk_call_without_enc('package', 'require', 'dde')
+ end
+
+ #def servername(topic=None)
+ # tk_call('dde', 'servername', topic)
+ #end
+ def servername(*args)
+ if args.size == 0
+ tk_call('dde', 'servername')
+ else
+ if args[-1].kind_of?(Hash) # dde 1.2 +
+ keys = _symbolkey2str(args.pop)
+ force = (keys.delete('force'))? '-force': None
+ exact = (keys.delete('exact'))? '-exact': None
+ if keys.size == 0
+ tk_call('dde', 'servername', force, exact)
+ elsif args.size == 0
+ tk_call('dde', 'servername', force, exact, *hash_kv(keys))
+ else
+ tk_call('dde', 'servername', force, exact,
+ *((hash_kv(keys) << '--') + args))
+ end
+ else
+ tk_call('dde', 'servername', *args)
+ end
+ end
+ end
+
+ def execute(service, topic, data)
+ tk_call('dde', 'execute', service, topic, data)
+ end
+
+ def async_execute(service, topic, data)
+ tk_call('dde', '-async', 'execute', service, topic, data)
+ end
+
+ def poke(service, topic, item, data)
+ tk_call('dde', 'poke', service, topic, item, data)
+ end
+
+ def request(service, topic, item)
+ tk_call('dde', 'request', service, topic, item)
+ end
+
+ def binary_request(service, topic, item)
+ tk_call('dde', 'request', '-binary', service, topic, item)
+ end
+
+ def services(service, topic)
+ tk_call('dde', 'services', service, topic)
+ end
+
+ def eval(topic, cmd, *args)
+ tk_call('dde', 'eval', topic, cmd, *args)
+ end
+
+ def async_eval(topic, cmd, *args)
+ tk_call('dde', 'eval', -async, topic, cmd, *args)
+ end
+
+ module_function :servername, :execute, :async_execute,
+ :poke, :request, :services, :eval
+end
+
+module TkWinRegistry
+ extend Tk
+ extend TkWinRegistry
+
+ TkCommandNames = ['registry'.freeze].freeze
+
+ if self.const_defined? :FORCE_VERSION
+ tk_call('package', 'require', 'registry', FORCE_VERSION)
+ else
+ tk_call('package', 'require', 'registry')
+ end
+
+ def broadcast(keynam, timeout=nil)
+ if timeout
+ tk_call('registry', 'broadcast', keynam, '-timeout', timeout)
+ else
+ tk_call('registry', 'broadcast', keynam)
+ end
+ end
+
+ def delete(keynam, valnam=None)
+ tk_call('registry', 'delete', keynam, valnam)
+ end
+
+ def get(keynam, valnam)
+ tk_call('registry', 'get', keynam, valnam)
+ end
+
+ def keys(keynam, pattern=nil)
+ lst = tk_split_simplelist(tk_call('registry', 'keys', keynam))
+ if pattern
+ lst.find_all{|key| key =~ pattern}
+ else
+ lst
+ end
+ end
+
+ def set(keynam, valnam=None, data=None, dattype=None)
+ tk_call('registry', 'set', keynam, valnam, data, dattype)
+ end
+
+ def type(keynam, valnam)
+ tk_call('registry', 'type', keynam, valnam)
+ end
+
+ def values(keynam, pattern=nil)
+ lst = tk_split_simplelist(tk_call('registry', 'values', keynam))
+ if pattern
+ lst.find_all{|val| val =~ pattern}
+ else
+ lst
+ end
+ end
+
+ module_function :delete, :get, :keys, :set, :type, :values
+end
diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb
new file mode 100644
index 0000000000..a1002f7b96
--- /dev/null
+++ b/ext/tk/lib/tk/wm.rb
@@ -0,0 +1,280 @@
+#
+# tk/wm.rb : methods for wm command
+#
+require 'tk'
+
+module Tk
+ module Wm
+ include TkComm
+
+ TkCommandNames = ['wm'.freeze].freeze
+
+ def aspect(*args)
+ if args.length == 0
+ list(tk_call_without_enc('wm', 'aspect', path))
+ else
+ tk_call('wm', 'aspect', path, *args)
+ self
+ end
+ end
+
+ def attributes(slot=nil,value=None)
+ if slot == nil
+ lst = tk_split_list(tk_call('wm', 'attributes', path))
+ info = {}
+ while key = lst.shift
+ info[key[1..-1]] = lst.shift
+ end
+ info
+ elsif slot.kind_of? Hash
+ tk_call('wm', 'attributes', path, *hash_kv(slot))
+ self
+ elsif value == None
+ tk_call('wm', 'attributes', path, "-#{slot}")
+ else
+ tk_call('wm', 'attributes', path, "-#{slot}", value)
+ self
+ end
+ end
+
+ def client(name=None)
+ if name == None
+ tk_call('wm', 'client', path)
+ else
+ name = '' if name == nil
+ tk_call('wm', 'client', path, name)
+ self
+ end
+ end
+
+ def colormapwindows(*args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'colormapwindows', path))
+ else
+ tk_call_without_enc('wm', 'colormapwindows', path, *args)
+ self
+ end
+ end
+
+ def wm_command(value=nil)
+ if value
+ tk_call('wm', 'command', path, value)
+ self
+ else
+ #procedure(tk_call('wm', 'command', path))
+ tk_call('wm', 'command', path)
+ end
+ end
+
+ def deiconify(ex = true)
+ tk_call_without_enc('wm', 'deiconify', path) if ex
+ self
+ end
+
+ def focusmodel(mode = nil)
+ if mode
+ tk_call_without_enc('wm', 'focusmodel', path, mode)
+ self
+ else
+ tk_call_without_enc('wm', 'focusmodel', path)
+ end
+ end
+
+ def frame
+ tk_call_without_enc('wm', 'frame', path)
+ end
+
+ def geometry(geom=nil)
+ if geom
+ tk_call_without_enc('wm', 'geometry', path, geom)
+ self
+ else
+ tk_call_without_enc('wm', 'geometry', path)
+ end
+ end
+
+ def wm_grid(*args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'grid', path))
+ else
+ tk_call_without_enc('wm', 'grid', path, *args)
+ self
+ end
+ end
+
+ def group(leader = nil)
+ if leader
+ tk_call('wm', 'group', path, leader)
+ self
+ else
+ window(tk_call('wm', 'group', path))
+ end
+ end
+
+ def iconbitmap(bmp=nil)
+ if bmp
+ tk_call_without_enc('wm', 'iconbitmap', path, bmp)
+ self
+ else
+ image_obj(tk_call_without_enc('wm', 'iconbitmap', path))
+ end
+ end
+
+ def iconify(ex = true)
+ tk_call_without_enc('wm', 'iconify', path) if ex
+ self
+ end
+
+ def iconmask(bmp=nil)
+ if bmp
+ tk_call_without_enc('wm', 'iconmask', path, bmp)
+ self
+ else
+ image_obj(tk_call_without_enc('wm', 'iconmask', path))
+ end
+ end
+
+ def iconname(name=nil)
+ if name
+ tk_call('wm', 'iconname', path, name)
+ self
+ else
+ tk_call('wm', 'iconname', path)
+ end
+ end
+
+ def iconposition(*args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'iconposition', path))
+ else
+ tk_call_without_enc('wm', 'iconposition', path, *args)
+ self
+ end
+ end
+
+ def iconwindow(win = nil)
+ if win
+ tk_call_without_enc('wm', 'iconwindow', path, win)
+ self
+ else
+ w = tk_call_without_enc('wm', 'iconwindow', path)
+ (w == '')? nil: window(w)
+ end
+ end
+
+ def maxsize(*args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'maxsize', path))
+ else
+ tk_call_without_enc('wm', 'maxsize', path, *args)
+ self
+ end
+ end
+
+ def minsize(*args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'minsize', path))
+ else
+ tk_call_without_enc('wm', 'minsize', path, *args)
+ self
+ end
+ end
+
+ def overrideredirect(bool=None)
+ if bool == None
+ bool(tk_call_without_enc('wm', 'overrideredirect', path))
+ else
+ tk_call_without_enc('wm', 'overrideredirect', path, bool)
+ self
+ end
+ end
+
+ def positionfrom(who=None)
+ if who == None
+ r = tk_call_without_enc('wm', 'positionfrom', path)
+ (r == "")? nil: r
+ else
+ tk_call_without_enc('wm', 'positionfrom', path, who)
+ self
+ end
+ end
+
+ def protocol(name=nil, cmd=nil, &b)
+ if cmd
+ tk_call_without_enc('wm', 'protocol', path, name, cmd)
+ self
+ elsif b
+ tk_call_without_enc('wm', 'protocol', path, name, proc(&b))
+ self
+ elsif name
+ result = tk_call_without_enc('wm', 'protocol', path, name)
+ (result == "")? nil : tk_tcl2ruby(result)
+ else
+ tk_split_simplelist(tk_call_without_enc('wm', 'protocol', path))
+ end
+ end
+
+ def resizable(*args)
+ if args.length == 0
+ list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)}
+ else
+ tk_call_without_enc('wm', 'resizable', path, *args)
+ self
+ end
+ end
+
+ def sizefrom(who=None)
+ if who == None
+ r = tk_call_without_enc('wm', 'sizefrom', path)
+ (r == "")? nil: r
+ else
+ tk_call_without_enc('wm', 'sizefrom', path, who)
+ self
+ end
+ end
+
+ def stackorder
+ list(tk_call('wm', 'stackorder', path))
+ end
+
+ def stackorder_isabove(win)
+ bool(tk_call('wm', 'stackorder', path, 'isabove', win))
+ end
+
+ def stackorder_isbelow(win)
+ bool(tk_call('wm', 'stackorder', path, 'isbelow', win))
+ end
+
+ def state(state=nil)
+ if state
+ tk_call_without_enc('wm', 'state', path, state)
+ self
+ else
+ tk_call_without_enc('wm', 'state', path)
+ end
+ end
+
+ def title(str=nil)
+ if str
+ tk_call('wm', 'title', path, str)
+ self
+ else
+ tk_call('wm', 'title', path)
+ end
+ end
+
+ def transient(master=nil)
+ if master
+ tk_call_without_enc('wm', 'transient', path, master)
+ self
+ else
+ window(tk_call_without_enc('wm', 'transient', path))
+ end
+ end
+
+ def withdraw(ex = true)
+ tk_call_without_enc('wm', 'withdraw', path) if ex
+ self
+ end
+ end
+end
diff --git a/ext/tk/lib/tk/xim.rb b/ext/tk/lib/tk/xim.rb
new file mode 100644
index 0000000000..701cd7531c
--- /dev/null
+++ b/ext/tk/lib/tk/xim.rb
@@ -0,0 +1,122 @@
+#
+# tk/xim.rb : control imput_method
+#
+require 'tk'
+
+module TkXIM
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['imconfigure'.freeze].freeze
+
+ def TkXIM.useinputmethods(value = None, window = nil)
+ if value == None
+ if window
+ bool(tk_call_without_enc('tk', 'useinputmethods',
+ '-displayof', window))
+ else
+ bool(tk_call_without_enc('tk', 'useinputmethods'))
+ end
+ else
+ if window
+ bool(tk_call_without_enc('tk', 'useinputmethods',
+ '-displayof', window, value))
+ else
+ bool(tk_call_without_enc('tk', 'useinputmethods', value))
+ end
+ end
+ end
+
+ def TkXIM.useinputmethods_displayof(window, value = None)
+ TkXIM.useinputmethods(value, window)
+ end
+
+ def TkXIM.caret(window, keys=nil)
+ if keys
+ tk_call_without_enc('tk', 'caret', window, *hash_kv(keys))
+ self
+ else
+ lst = tk_split_list(tk_call_without_enc('tk', 'caret', window))
+ info = {}
+ while key = lst.shift
+ info[key[1..-1]] = lst.shift
+ end
+ info
+ end
+ end
+
+ def TkXIM.configure(window, slot, value=None)
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if slot.kind_of? Hash
+ tk_call('imconfigure', window, *hash_kv(slot))
+ else
+ tk_call('imconfigure', window, "-#{slot}", value)
+ end
+ end
+ rescue
+ end
+ end
+
+ def TkXIM.configinfo(window, slot=nil)
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if slot
+ conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_list(tk_call('imconfigure', window)).collect{|conf|
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
+ else
+ []
+ end
+ rescue
+ []
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ TkXIM.current_configinfo(window, slot)
+ end
+ end
+
+ def TkXIM.current_configinfo(window, slot=nil)
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if slot
+ conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}"))
+ { conf[0][1..-1] => conf[1] }
+ else
+ ret = {}
+ tk_split_list(tk_call('imconfigure', window)).each{|conf|
+ ret[conf[0][1..-1]] = conf[1]
+ }
+ ret
+ end
+ else
+ {}
+ end
+ rescue
+ {}
+ end
+ end
+
+ def useinputmethods(value=None)
+ TkXIM.useinputmethods(value, self)
+ end
+
+ def caret(keys=nil)
+ TkXIM.caret(self, keys=nil)
+ end
+
+ def imconfigure(slot, value=None)
+ TkXIM.configure(self, slot, value)
+ end
+
+ def imconfiginfo(slot=nil)
+ TkXIM.configinfo(self, slot)
+ end
+end
diff --git a/ext/tk/lib/tkafter.rb b/ext/tk/lib/tkafter.rb
index fe3ee38740..f65945884c 100644
--- a/ext/tk/lib/tkafter.rb
+++ b/ext/tk/lib/tkafter.rb
@@ -1,316 +1,4 @@
#
-# tkafter.rb : methods for Tcl/Tk after command
-# 2000/08/01 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+# tkafter.rb - load tk/after.rb
#
-require 'tk'
-
-class TkAfter
- include TkCore
- extend TkCore
-
- Tk_CBID = [0]
- Tk_CBTBL = {}
-
- INTERP._invoke("proc", "rb_after", "args", "ruby [format \"TkAfter.callback %%Q!%s!\" $args]")
-
- ###############################
- # class methods
- ###############################
- def TkAfter.callback(arg)
- @after_id = nil
- arg = Array(tk_split_list(arg))
- obj_id = arg.shift
- ex_obj = Tk_CBTBL[obj_id]
- return nil if ex_obj == nil; # canceled
- _get_eval_string(ex_obj.do_callback(*arg))
- end
-
- def TkAfter.info
- tk_call('after', 'info').split(' ').collect!{|id|
- ret = Tk_CBTBL.find{|key,val| val.after_id == id}
- (ret == nil)? id: ret[1]
- }
- end
-
- ###############################
- # instance methods
- ###############################
- def do_callback(*args)
- @in_callback = true
- begin
- ret = @current_proc.call(*args)
- rescue StandardError, NameError
- if @cancel_on_exception
- cancel
- return nil
- else
- fail $!
- end
- end
- if @set_next
- set_next_callback(*args)
- else
- @set_next = true
- end
- @in_callback = false
- ret
- end
-
- def set_callback(sleep, args=nil)
- @after_script = "rb_after #{@id} #{_get_eval_string(args)}"
- @after_id = tk_call('after', sleep, @after_script)
- @current_script = [sleep, @after_script]
- end
-
- def set_next_callback(*args)
- if @running == false || @proc_max == 0 || @do_loop == 0
- Tk_CBTBL[@id] = nil ;# for GC
- @running = false
- return
- end
- if @current_pos >= @proc_max
- if @do_loop < 0 || (@do_loop -= 1) > 0
- @current_pos = 0
- else
- Tk_CBTBL[@id] = nil ;# for GC
- @running = false
- return
- end
- end
-
- @current_args = args
-
- if @sleep_time.kind_of? Proc
- sleep = @sleep_time.call(*args)
- else
- sleep = @sleep_time
- end
- @current_sleep = sleep
-
- cmd, *cmd_args = @loop_proc[@current_pos]
- @current_pos += 1
- @current_proc = cmd
-
- if cmd_args[0].kind_of? Proc
- #c = cmd_args.shift
- #cb_args = c.call(*(cmd_args + args))
- cb_args = cmd_args[0].call(*args)
- else
- cb_args = cmd_args
- end
-
- set_callback(sleep, cb_args)
- end
-
- def initialize(*args)
- @id = format("a%.4d", Tk_CBID[0])
- Tk_CBID[0] += 1
-
- @set_next = true
-
- @init_sleep = 0
- @init_proc = nil
- @init_args = []
-
- @current_script = []
- @current_proc = nil
- @current_args = nil
-
- @sleep_time = 0
- @current_sleep = 0
- @loop_exec = 0
- @do_loop = 0
- @loop_proc = []
- @proc_max = 0
- @current_pos = 0
-
- @after_id = nil
- @after_script = nil
-
- @cancel_on_exception = true
-
- set_procs(*args) if args != []
-
- @running = false
- end
-
- attr :after_id
- attr :after_script
- attr :current_proc
- attr :current_sleep
-
- attr_accessor :loop_exec
-
- def get_procs
- [@init_sleep, @init_proc, @init_args, @sleep_time, @loop_exec, @loop_proc]
- end
-
- def current_status
- [@running, @current_sleep, @current_proc, @current_args,
- @do_loop, @cancel_on_exception]
- end
-
- def cancel_on_exception?
- @cancel_on_exception
- end
-
- def cancel_on_exception=(mode)
- @cancel_on_exception = mode
- end
-
- def running?
- @running
- end
-
- def loop_rest
- @do_loop
- end
-
- def loop_rest=(rest)
- @do_loop = rest
- end
-
- def set_procs(interval, loop_exec, *procs)
- if !interval == 'idle' \
- && !interval.kind_of?(Integer) && !interval.kind_of?(Proc)
- fail format("%s need to be Integer or Proc", interval.inspect)
- end
- @sleep_time = interval
-
- @loop_proc = []
- procs.each{|e|
- if e.kind_of? Proc
- @loop_proc.push([e])
- else
- @loop_proc.push(e)
- end
- }
- @proc_max = @loop_proc.size
- @current_pos = 0
-
- @do_loop = 0
- if loop_exec
- if loop_exec.kind_of?(Integer) && loop_exec < 0
- @loop_exec = -1
- elsif loop_exec == nil || loop_exec == false || loop_exec == 0
- @loop_exec = 1
- else
- if not loop_exec.kind_of?(Integer)
- fail format("%s need to be Integer", loop_exec.inspect)
- end
- @loop_exec = loop_exec
- end
- @do_loop = @loop_exec
- end
-
- self
- end
-
- def add_procs(*procs)
- procs.each{|e|
- if e.kind_of? Proc
- @loop_proc.push([e])
- else
- @loop_proc.push(e)
- end
- }
- @proc_max = @loop_proc.size
-
- self
- end
-
- def set_start_proc(sleep, init_proc, *init_args)
- if !sleep == 'idle' && !sleep.kind_of?(Integer)
- fail format("%s need to be Integer", sleep.inspect)
- end
- @init_sleep = sleep
- @init_proc = init_proc
- @init_args = init_args
- self
- end
-
- def start(*init_args)
- return nil if @running
-
- Tk_CBTBL[@id] = self
- @do_loop = @loop_exec
- @current_pos = 0
-
- argc = init_args.size
- if argc > 0
- sleep = init_args.shift
- if !sleep == 'idle' && !sleep.kind_of?(Integer)
- fail format("%s need to be Integer", sleep.inspect)
- end
- @init_sleep = sleep
- end
- @init_proc = init_args.shift if argc > 1
- @init_args = init_args if argc > 0
-
- @current_sleep = @init_sleep
- @running = true
- if @init_proc
- if not @init_proc.kind_of? Proc
- fail format("%s need to be Proc", @init_proc.inspect)
- end
- @current_proc = @init_proc
- set_callback(sleep, @init_args)
- @set_next = false if @in_callback
- else
- set_next_callback(*@init_args)
- end
-
- self
- end
-
- def restart(*restart_args)
- cancel if @running
- if restart_args == []
- start(@init_sleep, @init_proc, *@init_args)
- else
- start(*restart_args)
- end
- end
-
- def cancel
- @running = false
- tk_call 'after', 'cancel', @after_id if @after_id
- @after_id = nil
- Tk_CBTBL[@id] = nil ;# for GC
- self
- end
- alias stop cancel
-
- def continue(wait=nil)
- sleep, cmd = @current_script
- return nil if cmd == nil || @running == true
- if wait
- if not wait.kind_of? Integer
- fail format("%s need to be Integer", wait.inspect)
- end
- sleep = wait
- end
- Tk_CBTBL[@id] = self
- @running = true
- @after_id = tk_call('after', sleep, cmd)
- self
- end
-
- def skip
- return nil if @running == false
- cancel
- Tk_CBTBL[@id] = self
- @running = true
- set_next_callback(@current_args)
- self
- end
-
- def info
- if @after_id
- inf = tk_split_list(tk_call('after', 'info', @after_id))
- [Tk_CBTBL[inf[0][1]], inf[1]]
- else
- nil
- end
- end
-end
+require 'tk/timer'
diff --git a/ext/tk/lib/tkbgerror.rb b/ext/tk/lib/tkbgerror.rb
index 8022077a3f..deba7a57fa 100644
--- a/ext/tk/lib/tkbgerror.rb
+++ b/ext/tk/lib/tkbgerror.rb
@@ -1,17 +1,4 @@
#
-# tkbgerror -- bgerror ( tkerror ) module
-# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+# tkbgerror.rb - load tk/bgerror.rb
#
-require 'tk'
-
-module TkBgError
- extend Tk
-
- def bgerror(message)
- tk_call 'bgerror', message
- end
- alias tkerror bgerror
- alias show bgerror
-
- module_function :bgerror, :tkerror, :show
-end
+require 'tk/bgerror'
diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb
index 9b323e9cbb..9524614291 100644
--- a/ext/tk/lib/tkcanvas.rb
+++ b/ext/tk/lib/tkcanvas.rb
@@ -1,941 +1,4 @@
#
-# tkcanvas.rb - Tk canvas classes
-# $Date$
-# by Yukihiro Matsumoto <matz@caelum.co.jp>
-# $Date$
-# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
-
-require "tk"
-require 'tkfont'
-
-module TkTreatCItemFont
- def tagfont_configinfo(tagOrId)
- if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag)
- pathname = self.path + ';' + tagOrId.id.to_s
- else
- pathname = self.path + ';' + tagOrId.to_s
- end
- ret = TkFont.used_on(pathname)
- if ret == nil
- ret = TkFont.init_widget_font(pathname,
- self.path, 'itemconfigure', tagOrId)
- end
- ret
- end
- alias tagfontobj tagfont_configinfo
-
- def tagfont_configure(tagOrId, slot)
- if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag)
- pathname = self.path + ';' + tagOrId.id.to_s
- else
- pathname = self.path + ';' + tagOrId.to_s
- end
- if (fnt = slot.delete('font'))
- if fnt.kind_of? TkFont
- return fnt.call_font_configure(pathname,
- self.path,'itemconfigure',tagOrId,slot)
- else
- latintagfont_configure(tagOrId, fnt) if fnt
- end
- end
- if (ltn = slot.delete('latinfont'))
- latintagfont_configure(tagOrId, ltn) if ltn
- end
- if (ltn = slot.delete('asciifont'))
- latintagfont_configure(tagOrId, ltn) if ltn
- end
- if (knj = slot.delete('kanjifont'))
- kanjitagfont_configure(tagOrId, knj) if knj
- end
-
- tk_call(self.path, 'itemconfigure', tagOrId, *hash_kv(slot)) if slot != {}
- self
- end
-
- def latintagfont_configure(tagOrId, ltn, keys=nil)
- fobj = tagfontobj(tagOrId)
- if ltn.kind_of? TkFont
- conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []}
- if conf == {}
- fobj.latin_replace(ltn)
- fobj.latin_configure(keys) if keys
- elsif keys
- fobj.latin_configure(conf.update(keys))
- else
- fobj.latin_configure(conf)
- end
- else
- fobj.latin_replace(ltn)
- end
- end
- alias asciitagfont_configure latintagfont_configure
-
- def kanjitagfont_configure(tagOrId, knj, keys=nil)
- fobj = tagfontobj(tagOrId)
- if knj.kind_of? TkFont
- conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []}
- if conf == {}
- fobj.kanji_replace(knj)
- fobj.kanji_configure(keys) if keys
- elsif keys
- fobj.kanji_configure(conf.update(keys))
- else
- fobj.kanji_configure(conf)
- end
- else
- fobj.kanji_replace(knj)
- end
- end
-
- def tagfont_copy(tagOrId, window, wintag=nil)
- if wintag
- window.tagfontobj(wintag).configinfo.each{|key,value|
- tagfontobj(tagOrId).configure(key,value)
- }
- tagfontobj(tagOrId).replace(window.tagfontobj(wintag).latin_font,
- window.tagfontobj(wintag).kanji_font)
- else
- window.tagfont(tagOrId).configinfo.each{|key,value|
- tagfontobj(tagOrId).configure(key,value)
- }
- tagfontobj(tagOrId).replace(window.fontobj.latin_font,
- window.fontobj.kanji_font)
- end
- end
-
- def latintagfont_copy(tagOrId, window, wintag=nil)
- if wintag
- tagfontobj(tagOrId).latin_replace(window.tagfontobj(wintag).latin_font)
- else
- tagfontobj(tagOrId).latin_replace(window.fontobj.latin_font)
- end
- end
- alias asciitagfont_copy latintagfont_copy
-
- def kanjitagfont_copy(tagOrId, window, wintag=nil)
- if wintag
- tagfontobj(tagOrId).kanji_replace(window.tagfontobj(wintag).kanji_font)
- else
- tagfontobj(tagOrId).kanji_replace(window.fontobj.kanji_font)
- end
- end
-end
-
-class TkCanvas<TkWindow
- include TkTreatCItemFont
- include Scrollable
-
- WidgetClassName = 'Canvas'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- def create_self
- tk_call 'canvas', path
- end
-
- def tagid(tag)
- if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
- tag.id
- else
- tag
- end
- end
- private :tagid
-
- def addtag(tag, mode, *args)
- tk_send 'addtag', tagid(tag), mode, *args
- end
- def addtag_above(tagOrId, target)
- addtag(tagOrId, 'above', tagid(target))
- end
- def addtag_all(tagOrId)
- addtag(tagOrId, 'all')
- end
- def addtag_below(tagOrId, target)
- addtag(tagOrId, 'below', tagid(target))
- end
- def addtag_closest(tagOrId, x, y, halo=None, start=None)
- addtag(tagOrId, 'closest', x, y, halo, start)
- end
- def addtag_enclosed(tagOrId, x1, y1, x2, y2)
- addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
- end
- def addtag_overlapping(tagOrId, x1, y1, x2, y2)
- addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
- end
- def addtag_withtag(tagOrId, tag)
- addtag(tagOrId, 'withtag', tagid(tag))
- end
-
- def bbox(tagOrId, *tags)
- list(tk_send('bbox', tagid(tagOrId), *tags.collect{|t| tagid(t)}))
- end
-
- def itembind(tag, context, cmd=Proc.new, args=nil)
- _bind([path, "bind", tagid(tag)], context, cmd, args)
- end
-
- def itembind_append(tag, context, cmd=Proc.new, args=nil)
- _bind_append([path, "bind", tagid(tag)], context, cmd, args)
- end
-
- def itembindinfo(tag, context=nil)
- _bindinfo([path, "bind", tagid(tag)], context)
- end
-
- def canvasx(x, *args)
- tk_tcl2ruby(tk_send 'canvasx', x, *args)
- end
- def canvasy(y, *args)
- tk_tcl2ruby(tk_send 'canvasy', y, *args)
- end
-
- def coords(tag, *args)
- if args == []
- tk_split_list(tk_send('coords', tagid(tag)))
- else
- tk_send('coords', tagid(tag), *args)
- end
- end
-
- def dchars(tag, first, last=None)
- tk_send 'dchars', tagid(tag), first, last
- end
-
- def delete(*args)
- tk_send 'delete', *args.collect{|t| tagid(t)}
- end
- alias remove delete
-
- def dtag(tag, tag_to_del=None)
- tk_send 'dtag', tagid(tag), tag_to_del
- end
-
- def find(mode, *args)
- list(tk_send 'find', mode, *args).collect!{|id|
- TkcItem.id2obj(self, id)
- }
- end
- def find_above(target)
- find('above', tagid(target))
- end
- def find_all
- find('all')
- end
- def find_below(target)
- find('below', tagid(target))
- end
- def find_closest(x, y, halo=None, start=None)
- find('closest', x, y, halo, start)
- end
- def find_enclosed(x1, y1, x2, y2)
- find('enclosed', x1, y1, x2, y2)
- end
- def find_overlapping(x1, y1, x2, y2)
- find('overlapping', x1, y1, x2, y2)
- end
- def find_withtag(tag)
- find('withtag', tag)
- end
-
- def itemfocus(tagOrId=nil)
- if tagOrId
- tk_send 'focus', tagid(tagOrId)
- else
- ret = tk_send('focus')
- if ret == ""
- nil
- else
- TkcItem.id2obj(self, ret)
- end
- end
- end
-
- def gettags(tagOrId)
- list(tk_send('gettags', tagid(tagOrId))).collect{|tag|
- TkcTag.id2obj(self, tag)
- }
- end
-
- def icursor(tagOrId, index)
- tk_send 'icursor', tagid(tagOrId), index
- end
-
- def index(tagOrId, index)
- tk_send 'index', tagid(tagOrId), index
- end
-
- def insert(tagOrId, index, string)
- tk_send 'insert', tagid(tagOrId), index, string
- end
-
- def itemcget(tagOrId, option)
- case option
- when 'dash', 'activedash', 'disableddash'
- conf = tk_send('itemcget', tagid(tagOrId), "-#{option}")
- if conf =~ /^[0-9]/
- list(conf)
- else
- conf
- end
- when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
- tk_send 'itemcget', tagid(tagOrId), "-#{option}"
- else
- tk_tcl2ruby tk_send 'itemcget', tagid(tagOrId), "-#{option}"
- end
- end
-
- def itemconfigure(tagOrId, key, value=None)
- if key.kind_of? Hash
- if ( key['font'] || key['kanjifont'] \
- || key['latinfont'] || key['asciifont'] )
- tagfont_configure(tagOrId, key.dup)
- else
- tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(key)
- end
-
- else
- if ( key == 'font' || key == 'kanjifont' \
- || key == 'latinfont' || key == 'asciifont' )
- tagfont_configure(tagid(tagOrId), {key=>value})
- else
- tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
- end
- end
- end
-# def itemconfigure(tagOrId, key, value=None)
-# if key.kind_of? Hash
-# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(key)
-# else
-# tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
-# end
-# end
-# def itemconfigure(tagOrId, keys)
-# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(keys)
-# end
-
- def itemconfiginfo(tagOrId, key=nil)
- if key
- case key
- when 'dash', 'activedash', 'disableddash'
- conf = tk_split_simplelist(tk_send 'itemconfigure',
- tagid(tagOrId), "-#{key}")
- if conf[3] && conf[3] =~ /^[0-9]/
- conf[3] = list(conf[3])
- end
- if conf[4] && conf[4] =~ /^[0-9]/
- conf[4] = list(conf[4])
- end
- when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
- conf = tk_split_simplelist(tk_send 'itemconfigure',
- tagid(tagOrId), "-#{key}")
- else
- conf = tk_split_list(tk_send 'itemconfigure',
- tagid(tagOrId), "-#{key}")
- end
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_send 'itemconfigure',
- tagid(tagOrId)).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
- when 'dash', 'activedash', 'disableddash'
- if conf[3] && conf[3] =~ /^[0-9]/
- conf[3] = list(conf[3])
- end
- if conf[4] && conf[4] =~ /^[0-9]/
- conf[4] = list(conf[4])
- end
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf
- }
- end
- end
-
- def lower(tag, below=None)
- tk_send 'lower', tagid(tag), tagid(below)
- end
-
- def move(tag, x, y)
- tk_send 'move', tagid(tag), x, y
- end
-
- def postscript(keys)
- tk_send "postscript", *hash_kv(keys)
- end
-
- def raise(tag, above=None)
- tk_send 'raise', tagid(tag), tagid(above)
- end
-
- def scale(tag, x, y, xs, ys)
- tk_send 'scale', tagid(tag), x, y, xs, ys
- end
-
- def scan_mark(x, y)
- tk_send 'scan', 'mark', x, y
- end
- def scan_dragto(x, y)
- tk_send 'scan', 'dragto', x, y
- end
-
- def select(mode, *args)
- tk_send 'select', mode, *args
- end
- def select_adjust(tagOrId, index)
- select('adjust', tagid(tagOrId), index)
- end
- def select_clear
- select('clear')
- end
- def select_from(tagOrId, index)
- select('from', tagid(tagOrId), index)
- end
- def select_item
- select('item')
- end
- def select_to(tagOrId, index)
- select('to', tagid(tagOrId), index)
- end
-
- def itemtype(tag)
- TkcItem.type2class(tk_send 'type', tagid(tag))
- end
-end
-
-module TkcTagAccess
- include TkComm
- include TkTreatTagFont
-
- def addtag(tag)
- @c.addtag(tag, 'with', @id)
- end
-
- def bbox
- @c.bbox(@id)
- end
-
- def bind(seq, cmd=Proc.new, args=nil)
- @c.itembind @id, seq, cmd, args
- end
-
- def bindinfo(seq=nil)
- @c.itembindinfo @id, seq
- end
-
- def cget(option)
- @c.itemcget @id, option
- end
-
- def configure(key, value=None)
- @c.itemconfigure @id, key, value
- end
-# def configure(keys)
-# @c.itemconfigure @id, keys
-# end
-
- def configinfo(key=nil)
- @c.itemconfiginfo @id, key
- end
-
- def coords(*args)
- @c.coords @id, *args
- end
-
- def dchars(first, last=None)
- @c.dchars @id, first, last
- end
-
- def dtag(tag_to_del=None)
- @c.dtag @id, tag_to_del
- end
-
- def find
- @c.find 'withtag', @id
- end
- alias list find
-
- def focus
- @c.itemfocus @id
- end
-
- def gettags
- @c.gettags @id
- end
-
- def icursor(index)
- @c.icursor @id, index
- end
-
- def index(index)
- @c.index @id, index
- end
-
- def insert(beforethis, string)
- @c.insert @id, beforethis, string
- end
-
- def lower(belowthis=None)
- @c.lower @id, belowthis
- end
-
- def move(xamount, yamount)
- @c.move @id, xamount, yamount
- end
-
- def raise(abovethis=None)
- @c.raise @id, abovethis
- end
-
- def scale(xorigin, yorigin, xscale, yscale)
- @c.scale @id, xorigin, yorigin, xscale, yscale
- end
-
- def select_adjust(index)
- @c.select('adjust', @id, index)
- end
- def select_from(index)
- @c.select('from', @id, index)
- end
- def select_to(index)
- @c.select('to', @id, index)
- end
-
- def itemtype
- @c.itemtype @id
- end
-
- # Followings operators supports logical expressions of canvas tags
- # (for Tk8.3+).
- # If tag1.path is 't1' and tag2.path is 't2', then
- # ltag = tag1 & tag2; ltag.path => "(t1)&&(t2)"
- # ltag = tag1 | tag2; ltag.path => "(t1)||(t2)"
- # ltag = tag1 ^ tag2; ltag.path => "(t1)^(t2)"
- # ltag = - tag1; ltag.path => "!(t1)"
- def & (tag)
- if tag.kind_of? TkObject
- TkcTagString.new(@c, '(' + @id + ')&&(' + tag.path + ')')
- else
- TkcTagString.new(@c, '(' + @id + ')&&(' + tag.to_s + ')')
- end
- end
-
- def | (tag)
- if tag.kind_of? TkObject
- TkcTagString.new(@c, '(' + @id + ')||(' + tag.path + ')')
- else
- TkcTagString.new(@c, '(' + @id + ')||(' + tag.to_s + ')')
- end
- end
-
- def ^ (tag)
- if tag.kind_of? TkObject
- TkcTagString.new(@c, '(' + @id + ')^(' + tag.path + ')')
- else
- TkcTagString.new(@c, '(' + @id + ')^(' + tag.to_s + ')')
- end
- end
-
- def -@
- TkcTagString.new(@c, '!(' + @id + ')')
- end
-end
-
-class TkcTag<TkObject
- include TkcTagAccess
-
- CTagID_TBL = {}
-
- def TkcTag.id2obj(canvas, id)
- cpath = canvas.path
- return id unless CTagID_TBL[cpath]
- CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
- end
-
- Tk_CanvasTag_ID = ['ctag0000']
- def initialize(parent, mode=nil, *args)
- if not parent.kind_of?(TkCanvas)
- fail format("%s need to be TkCanvas", parent.inspect)
- end
- @c = parent
- @cpath = parent.path
- @path = @id = Tk_CanvasTag_ID[0]
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- Tk_CanvasTag_ID[0] = Tk_CanvasTag_ID[0].succ
- if mode
- tk_call @c.path, "addtag", @id, mode, *args
- end
- end
- def id
- return @id
- end
-
- def delete
- @c.delete @id
- CTagID_TBL[@path][@id] = nil if CTagID_TBL[@path]
- end
- alias remove delete
- alias destroy delete
-
- def set_to_above(target)
- @c.addtag_above(@id, target)
- end
- alias above set_to_above
-
- def set_to_all
- @c.addtag_all(@id)
- end
- alias all set_to_all
-
- def set_to_below(target)
- @c.addtag_below(@id, target)
- end
- alias below set_to_below
-
- def set_to_closest(x, y, halo=None, start=None)
- @c.addtag_closest(@id, x, y, halo, start)
- end
- alias closest set_to_closest
-
- def set_to_enclosed(x1, y1, x2, y2)
- @c.addtag_enclosed(@id, x1, y1, x2, y2)
- end
- alias enclosed set_to_enclosed
-
- def set_to_overlapping(x1, y1, x2, y2)
- @c.addtag_overlapping(@id, x1, y1, x2, y2)
- end
- alias overlapping set_to_overlapping
-
- def set_to_withtag(target)
- @c.addtag_withtag(@id, target)
- end
- alias withtag set_to_withtag
-end
-
-class TkcTagString<TkcTag
- def self.new(parent, name, *args)
- if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name]
- return CTagID_TBL[parent.path][name]
- else
- super(parent, name, *args)
- end
- end
-
- def initialize(parent, name, mode=nil, *args)
- if not parent.kind_of?(TkCanvas)
- fail format("%s need to be TkCanvas", parent.inspect)
- end
- @c = parent
- @cpath = parent.path
- @path = @id = name
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- if mode
- tk_call @c.path, "addtag", @id, mode, *args
- end
- end
-end
-
-class TkcTagAll<TkcTag
- def initialize(parent)
- if not parent.kind_of?(TkCanvas)
- fail format("%s need to be TkCanvas", parent.inspect)
- end
- @c = parent
- @cpath = parent.path
- @path = @id = 'all'
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- end
-end
-
-class TkcTagCurrent<TkcTag
- def initialize(parent)
- if not parent.kind_of?(TkCanvas)
- fail format("%s need to be TkCanvas", parent.inspect)
- end
- @c = parent
- @cpath = parent.path
- @path = @id = 'current'
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- end
-end
-
-class TkcGroup<TkcTag
- Tk_cGroup_ID = ['tkcg00000']
- def create_self(parent, *args)
- if not parent.kind_of?(TkCanvas)
- fail format("%s need to be TkCanvas", parent.inspect)
- end
- @c = parent
- @cpath = parent.path
- @path = @id = Tk_cGroup_ID[0]
- CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
- CTagID_TBL[@cpath][@id] = self
- Tk_cGroup_ID[0] = Tk_cGroup_ID[0].succ
- add(*args) if args != []
- end
-
- def include(*tags)
- for i in tags
- i.addtag @id
- end
- end
-
- def exclude(*tags)
- for i in tags
- i.delete @id
- end
- end
-end
-
-class TkcItem<TkObject
- include TkcTagAccess
-
- CItemTypeToClass = {}
- CItemID_TBL = {}
-
- def TkcItem.type2class(type)
- CItemTypeToClass[type]
- end
-
- def TkcItem.id2obj(canvas, id)
- cpath = canvas.path
- return id unless CItemID_TBL[cpath]
- CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
- end
-
- def initialize(parent, *args)
- if not parent.kind_of?(TkCanvas)
- fail format("%s need to be TkCanvas", parent.inspect)
- end
- @parent = @c = parent
- @path = parent.path
- if args[-1].kind_of? Hash
- keys = args.pop
- end
- @id = create_self(*args).to_i ;# 'canvas item id' is integer number
- CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
- CItemID_TBL[@path][@id] = self
- if keys
- # tk_call @path, 'itemconfigure', @id, *hash_kv(keys)
- configure(keys) if keys
- end
- end
- def create_self(*args); end
- private :create_self
- def id
- return @id
- end
-
- def delete
- @c.delete @id
- CItemID_TBL[@path][@id] = nil if CItemID_TBL[@path]
- end
- alias remove delete
- alias destroy delete
-end
-
-class TkcArc<TkcItem
- CItemTypeToClass['arc'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'arc', *args)
- end
-end
-class TkcBitmap<TkcItem
- CItemTypeToClass['bitmap'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'bitmap', *args)
- end
-end
-class TkcImage<TkcItem
- CItemTypeToClass['image'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'image', *args)
- end
-end
-class TkcLine<TkcItem
- CItemTypeToClass['line'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'line', *args)
- end
-end
-class TkcOval<TkcItem
- CItemTypeToClass['oval'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'oval', *args)
- end
-end
-class TkcPolygon<TkcItem
- CItemTypeToClass['polygon'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'polygon', *args)
- end
-end
-class TkcRectangle<TkcItem
- CItemTypeToClass['rectangle'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'rectangle', *args)
- end
-end
-class TkcText<TkcItem
- CItemTypeToClass['text'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'text', *args)
- end
-end
-class TkcWindow<TkcItem
- CItemTypeToClass['window'] = self
- def create_self(*args)
- tk_call(@path, 'create', 'window', *args)
- end
-end
-
-class TkImage<TkObject
- include Tk
-
- Tk_IMGTBL = {}
-
- Tk_Image_ID = ['i00000']
- def initialize(keys=nil)
- @path = Tk_Image_ID[0]
- Tk_Image_ID[0] = Tk_Image_ID[0].succ
- tk_call 'image', 'create', @type, @path, *hash_kv(keys)
- Tk_IMGTBL[@path] = self
- end
-
- def delete
- Tk_IMGTBL[@id] = nil if @id
- tk_call('image', 'delete', @path)
- end
- def height
- number(tk_call('image', 'height', @path))
- end
- def inuse
- bool(tk_call('image', 'inuse', @path))
- end
- def itemtype
- tk_call('image', 'type', @path)
- end
- def width
- number(tk_call('image', 'width', @path))
- end
-
- def TkImage.names
- Tk.tk_call('image', 'names').split.collect!{|id|
- (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
- }
- end
-
- def TkImage.types
- Tk.tk_call('image', 'types').split
- end
-end
-
-class TkBitmapImage<TkImage
- def initialize(*args)
- @type = 'bitmap'
- super
- end
-end
-
-class TkPhotoImage<TkImage
- def initialize(*args)
- @type = 'photo'
- super
- end
-
- def blank
- tk_send 'blank'
- end
-
- def cget(option)
- case option
- when 'data', 'flie'
- tk_send 'cget', option
- else
- tk_tcl2ruby tk_send 'cget', option
- end
- end
-
- def copy(source, *opts)
- args = opts.collect{|term|
- if term.kind_of?(String) && term.include?(?\s)
- term.split
- else
- term
- end
- }.flatten
-
- tk_send 'copy', source, *args
- end
-
- def data(keys=nil)
- tk_send 'data', *hash_kv(keys)
- end
-
- def get(x, y)
- tk_send 'get', x, y
- end
-
- def put(data, *to)
- if to == []
- tk_send 'put', data
- else
- tk_send 'put', data, '-to', *to
- end
- end
-
- def read(file, *opts)
- args = opts.collect{|term|
- if term.kind_of?(String) && term.include?(?\s)
- term.split
- else
- term
- end
- }.flatten
-
- tk_send 'read', file, *args
- end
-
- def redither
- tk_send 'redither'
- end
-
- def write(file, *opts)
- args = opts.collect{|term|
- if term.kind_of?(String) && term.include?(?\s)
- term.split
- else
- term
- end
- }.flatten
-
- tk_send 'write', file, *args
- end
-end
+# tkcanvas.rb - load tk/canvas.rb
+#
+require 'tk/canvas'
diff --git a/ext/tk/lib/tkclass.rb b/ext/tk/lib/tkclass.rb
index 0b33d4ec8b..87f5acc453 100644
--- a/ext/tk/lib/tkclass.rb
+++ b/ext/tk/lib/tkclass.rb
@@ -1,7 +1,9 @@
#
-# tkclass.rb - Tk classes
-# $Date$
-# by Yukihiro Matsumoto <matz@caelum.co.jp>
+# tkclass.rb - Tk classes
+# Date: 2000/11/27 09:23:36
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+#
+# $Id$
require "tk"
@@ -13,6 +15,7 @@ Radiobutton = TkRadioButton
Checkbutton = TkCheckButton
Message = TkMessage
Entry = TkEntry
+Spinbox = TkSpinbox
Text = TkText
Scale = TkScale
Scrollbar = TkScrollbar
@@ -28,10 +31,16 @@ Polygon = TkcPolygon
Rectangle = TkcRectangle
TextItem = TkcText
WindowItem = TkcWindow
+BitmapImage = TkBitmapImage
+PhotoImage = TkPhotoImage
Selection = TkSelection
Winfo = TkWinfo
Pack = TkPack
+Grid = TkGrid
+Place = TkPlace
Variable = TkVariable
+Font = TkFont
+VirtualEvent = TkVirtualEvent
def Mainloop
Tk.mainloop
diff --git a/ext/tk/lib/tkconsole.rb b/ext/tk/lib/tkconsole.rb
new file mode 100644
index 0000000000..9960ddb8ac
--- /dev/null
+++ b/ext/tk/lib/tkconsole.rb
@@ -0,0 +1,4 @@
+#
+# tkconsole.rb - load tk/console.rb
+#
+require 'tk/console'
diff --git a/ext/tk/lib/tkdialog.rb b/ext/tk/lib/tkdialog.rb
index 1133db6ae9..bec5e5d29a 100644
--- a/ext/tk/lib/tkdialog.rb
+++ b/ext/tk/lib/tkdialog.rb
@@ -1,141 +1,4 @@
-require "tk"
-
-class TkDialog < TkWindow
- extend Tk
-
- # initialize tk_dialog
- def initialize(keys = nil)
- super()
- @var = TkVariable.new
- id = @var.id
-
- @title = title
-
- @message = message
- @message_config = message_config
-
- @bitmap = bitmap
- @bitmap_config = message_config
-
- @default_button = default_button
-
- @buttons = buttons
- @button_configs = proc{|num| button_configs num}
-
- if keys.kind_of? Hash
- @title = keys['title'] if keys['title']
- @message = keys['message'] if keys['message']
- @bitmap = keys['bitmap'] if keys['bitmap']
- @default_button = keys['default'] if keys['default']
- @buttons = keys['buttons'] if keys['buttons']
-
- @command = keys['prev_command']
-
- @message_config = keys['message_config'] if keys['message_config']
- @bitmap_config = keys['bitmap_config'] if keys['bitmap_config']
- @button_configs = keys['button_configs'] if keys['button_configs']
- end
-
- if @title.include? ?\s
- @title = '{' + @title + '}'
- end
-
- @buttons = tk_split_list(@buttons) if @buttons.kind_of? String
- @buttons = @buttons.collect{|s|
- if s.kind_of? Array
- s = s.join(' ')
- end
- if s.include? ?\s
- '{' + s + '}'
- else
- s
- end
- }
-
- config = ""
- if @message_config.kind_of? Hash
- config << format("%s.msg configure %s\n",
- @path, hash_kv(@message_config).join(' '))
- end
- if @bitmap_config.kind_of? Hash
- config << format("%s.msg configure %s\n",
- @path, hash_kv(@bitmap_config).join(' '))
- end
- if @button_configs.kind_of? Proc
- @buttons.each_index{|i|
- if (c = @button_configs.call(i)).kind_of? Hash
- config << format("%s.button%s configure %s\n",
- @path, i, hash_kv(c).join(' '))
- end
- }
- end
- config = 'after idle {' + config + '};' if config != ""
-
- if @command.kind_of? Proc
- @command.call(self)
- end
-
- INTERP._eval('eval {global '+id+';'+config+
- 'set '+id+' [tk_dialog '+
- @path+" "+@title+" {#{@message}} "+@bitmap+" "+
- String(@default_button)+" "+@buttons.join(' ')+']}')
- end
- def value
- return @var.value.to_i
- end
- ######################################################
- # #
- # these methods must be overridden for each dialog #
- # #
- ######################################################
- def title
- return "DIALOG"
- end
- def message
- return "MESSAGE"
- end
- def message_config
- return nil
- end
- def bitmap
- return "info"
- end
- def bitmap_config
- return nil
- end
- def default_button
- return 0
- end
- def buttons
- #return "BUTTON1 BUTTON2"
- return ["BUTTON1", "BUTTON2"]
- end
- def button_configs(num)
- return nil
- end
-end
-
#
-# dialog for warning
+# tkdialog.rb - load tk/dialog.rb
#
-class TkWarning < TkDialog
- def initialize(mes)
- @mes = mes
- super()
- end
- def message
- return @mes
- end
- def title
- return "WARNING";
- end
- def bitmap
- return "warning";
- end
- def default_button
- return 0;
- end
- def buttons
- return "OK";
- end
-end
+require 'tk/dialog'
diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb
index 7af3f26748..2dcfcab5da 100644
--- a/ext/tk/lib/tkentry.rb
+++ b/ext/tk/lib/tkentry.rb
@@ -1,213 +1,4 @@
#
-# tkentry.rb - Tk entry classes
-# $Date$
-# by Yukihiro Matsumoto <matz@caelum.co.jp>
-
-require 'tk.rb'
-
-class TkEntry<TkLabel
- include Scrollable
-
- WidgetClassName = 'Entry'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- class ValidateCmd
- include TkComm
-
- class ValidateArgs
- def initialize(d,i,s,v,pp,ss,vv,ww)
- @action = d
- @index = i
- @current = s
- @type = v
- @value = pp
- @string = ss
- @triggered = vv
- @widget = ww
- end
- attr :action
- attr :index
- attr :current
- attr :type
- attr :value
- attr :string
- attr :triggered
- attr :widget
- end
-
- def initialize(cmd = Proc.new, args=nil)
- if args
- @id = install_cmd(proc{|*arg|
- TkUtil.eval_cmd cmd, *arg
- }) + " " + args
- else
- @id = install_cmd(proc{|arg|
- TkUtil.eval_cmd cmd, ValidateArgs.new(*arg)
- }) + ' %d %i %s %v %P %S %V %W'
- end
- end
-
- def to_eval
- @id
- end
- end
-
- def create_self
- tk_call 'entry', @path
- end
-
- def bbox(index)
- tk_send 'bbox', index
- end
-
- def delete(s, e=None)
- tk_send 'delete', s, e
- end
-
- def configure(slot, value=None)
- if slot.kind_of? Hash
- if slot['vcmd'].kind_of? Array
- cmd, *args = slot['vcmd']
- slot['vcmd'] = ValidateCmd.new(cmd, args.join(' '))
- elsif slot['vcmd'].kind_of? Proc
- slot['vcmd'] = ValidateCmd.new(slot['vcmd'])
- end
- if slot['validatecommand'].kind_of? Array
- cmd, *args = slot['validatecommand']
- slot['validatecommand'] = ValidateCmd.new(cmd, args.join(' '))
- elsif slot['validatecommand'].kind_of? Proc
- slot['validatecommand'] = ValidateCmd.new(slot['validatecommand'])
- end
- if slot['invcmd'].kind_of? Array
- cmd, *args = slot['invcmd']
- slot['invcmd'] = ValidateCmd.new(cmd, args.join(' '))
- elsif slot['invcmd'].kind_of? Proc
- slot['invcmd'] = ValidateCmd.new(slot['invcmd'])
- end
- if slot['invalidcommand'].kind_of? Array
- cmd, *args = slot['invalidcommand']
- slot['invalidcommand'] = ValidateCmd.new(cmd, args.join(' '))
- elsif slot['invalidcommand'].kind_of? Proc
- slot['invalidcommand'] = ValidateCmd.new(slot['invalidcommand'])
- end
- super(slot)
- else
- if (slot == 'vcmd' || slot == 'validatecommand' ||
- slot == 'invcmd' || slot == 'invalidcommand')
- if value.kind_of? Array
- cmd, *args = value
- value = ValidateCmd.new(cmd, args.join(' '))
- elsif value.kind_of? Proc
- value = ValidateCmd.new(value)
- end
- end
- super(slot, value)
- end
- end
-
- def cursor
- tk_send 'index', 'insert'
- end
- def cursor=(index)
- tk_send 'icursor', index
- end
- def index(index)
- number(tk_send('index', index))
- end
- def insert(pos,text)
- tk_send 'insert', pos, text
- end
- def mark(pos)
- tk_send 'scan', 'mark', pos
- end
- def dragto(pos)
- tk_send 'scan', 'dragto', pos
- end
- def selection_adjust(index)
- tk_send 'selection', 'adjust', index
- end
- def selection_clear
- tk_send 'selection', 'clear'
- end
- def selection_from(index)
- tk_send 'selection', 'from', index
- end
- def selection_present()
- bool(tk_send('selection', 'present'))
- end
- def selection_range(s, e)
- tk_send 'selection', 'range', s, e
- end
- def selection_to(index)
- tk_send 'selection', 'to', index
- end
-
- def validate(mode = nil)
- if mode
- configure 'validate', mode
- else
- if tk_send('validate') == '0'
- false
- else
- true
- end
- end
- end
-
- def validatecommand(cmd = ValidateCmd.new, args = nil)
- if cmd.kind_of?(ValidateCmd)
- configure('validatecommand', cmd)
- else
- configure('validatecommand', ValidateCmd.new(cmd, args))
- end
- end
- alias vcmd validatecommand
-
- def invalidcommand(cmd = ValidateCmd.new, args = nil)
- if cmd.kind_of?(ValidateCmd)
- configure('invalidcommand', cmd)
- else
- configure('invalidcommand', ValidateCmd.new(cmd, args))
- end
- end
- alias invcmd invalidcommand
-
- def value
- tk_send 'get'
- end
- def value= (val)
- tk_send 'delete', 0, 'end'
- tk_send 'insert', 0, val
- end
-end
-
-class TkSpinbox<TkEntry
- WidgetClassName = 'Spinbox'.freeze
- WidgetClassNames[WidgetClassName] = self
- def self.to_eval
- WidgetClassName
- end
-
- def create_self
- tk_call 'spinbox', @path
- end
-
- def identify(x, y)
- tk_send 'identify', x, y
- end
-
- def spinup
- tk_send 'invoke', 'spinup'
- end
-
- def spindown
- tk_send 'invoke', 'spindown'
- end
-
- def set(str)
- tk_send 'set', str
- end
-end
+# tkentry.rb - load tk/entry.rb
+#
+require 'tk/entry'
diff --git a/ext/tk/lib/tkextlib/ICONS.rb b/ext/tk/lib/tkextlib/ICONS.rb
new file mode 100644
index 0000000000..18d84c05e9
--- /dev/null
+++ b/ext/tk/lib/tkextlib/ICONS.rb
@@ -0,0 +1,13 @@
+#
+# ICONS support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/ICONS/setup.rb'
+
+# load library
+require 'tkextlib/ICONS/icons'
diff --git a/ext/tk/lib/tkextlib/ICONS/icons.rb b/ext/tk/lib/tkextlib/ICONS/icons.rb
new file mode 100644
index 0000000000..20d706df65
--- /dev/null
+++ b/ext/tk/lib/tkextlib/ICONS/icons.rb
@@ -0,0 +1,108 @@
+#
+# tkextlib/ICONS/icons.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/ICONS/setup.rb'
+
+# TkPackage.require('icons', '1.0')
+TkPackage.require('icons')
+
+module Tk
+ class ICONS < TkImage
+ extend Tk
+
+ def self.package_version
+ begin
+ TkPackage.require('icons')
+ rescue
+ ''
+ end
+ end
+
+ def self.create(*args) # icon, icon, ..., ?option=>value, ...?
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ icons = simplelist(tk_call('::icons::icons', 'create',
+ *(hash_kv(keys) << (args.flatten))))
+ else
+ icons = simplelist(tk_call('::icons::icons', 'create',
+ args.flatten))
+ end
+
+ icons.collect{|icon| self.new(icon, :without_creating=>true)}
+ end
+
+ def self.delete(*icons) # icon, icon, ...
+ icons = icons.flatten
+ return if icons.empty?
+ icons.map!{|icon|
+ if icon.kind_of?(Tk::ICONS)
+ Tk_IMGTBL.delete(icon.path)
+ icon.name
+ elsif icon.to_s =~ /^::icon::(.*)/
+ name = $1
+ Tk_IMGTBL.delete(icon)
+ name
+ else
+ Tk_IMGTBL.delete("::icon::#{icon}")
+ icon
+ end
+ }
+ tk_call('::icons::icons', 'delete', icons)
+ end
+
+ def self.query(*args) # icon, icon, ..., ?option=>value, ...?
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ simplelist(tk_call('::icons::icons', 'query',
+ *(hash_kv(keys) << (args.flatten))))
+ else
+ simplelist(tk_call('::icons::icons', 'query', args.flatten))
+ end . map{|inf| list(inf) }
+ end
+
+ ##########################################
+
+ def self.new(name, keys=nil)
+ Tk_IMGTBL["::icon::#{name}"] || super
+ end
+
+ def initialize(name, keys=nil)
+ if name.kind_of?(String) && name =~ /^::icon::(.+)$/
+ @name = $1
+ @path = name
+ else
+ @name = name.to_s
+ @path = "::icon::#{@name}"
+ end
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name))
+ end
+ Tk_IMGTBL[@path] = self
+ end
+
+ def name
+ @name
+ end
+
+ def delete
+ Tk_IMGTBL.delete(@path)
+ tk_call('::icons::icons', 'delete', @name)
+ self
+ end
+
+ def query(keys={})
+ list(simplelist(tk_call('::icons::icons', 'query',
+ *(hash_kv(keys) << @name))
+ )[0])
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/ICONS/setup.rb b/ext/tk/lib/tkextlib/ICONS/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/ICONS/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS
new file mode 100644
index 0000000000..6bc87bab98
--- /dev/null
+++ b/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -0,0 +1,173 @@
+
+ [ current support status of Tcl/Tk extensions ]
+
+The following list shows *CURRENT* status when this file was modifyed
+at last. If you want to add other Tcl/Tk extensions to the planed list
+(or change its status position), please request them at the ruby-talk,
+ruby-list, or ruby-dev ML. Although we cannot promise to support your
+requests, we'll try to do.
+
+If you want to check that wrapper libraries are ready to use on your
+environment, please execute 'pkg_checker.rb' with no arguments. The
+script may give you some hints about that.
+
+
+ ***** IMPORTANT NOTE **********************************************
+
+ 'support' means that Ruby/Tk's wrapper libraries are released.
+ 'not support' does *NOT* mean that the extension doesn't work
+ on Ruby/Tk.
+
+ Even if the status of the extension is 'not support', you can
+ control the functions/widgets of the extension without wrapper
+ libraries by Tk.tk_call(), Tk.ip_eval(), and so on.
+
+ If you cannot use installed Tcl/Tk extension, please check the
+ followings.
+
+ (1) On your Tcl/Tk, does the extention work?
+
+ (2) Do DLL libraries of the extension exist on DLL load-path?
+ (See also "<ruby archive>/ext/tcltklib/README.ActiveTcl")
+
+ (3) Is the Tcl library directory of the extension included in
+ library search-path of the Tcl interpreter linked Ruby/Tk?
+
+ The check results may request you to do some setup operations
+ before using the extension. If so, then please write the step
+ of setup oprations into the "setup.rb" file in the directory
+ of the wrapper libraries for the extention (It is the wrapper
+ libraries have the standard structure of the libraries in this
+ directory). The "setup" file is required before requiring the
+ Tcl library package (TkPackage.require(<libname>)).
+
+ *******************************************************************
+
+
+===< support with some examples (may be beta quality) >=======================
+
+Tcllib http://sf.net/projects/tcllib
+ ==> tcllib (partial support; Tklib part only)
+
+IWidgets http://sf.net/projects/incrTcl ==> iwidgets
+
+BWidgets http://sf.net/projects/tcllib ==> bwidget
+
+TkTable http://sf.net/projects/tktable ==> tktable
+ [ * see also <http://www.korus.hu/~fery/ruby/tktable.rb>
+ written by Ferenc Engard (ferenc@engard.hu) ]
+
+vu http://tktable.sourceforge.net ==> vu
+
+TkHTML http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML
+
+ICONS http://www.satisoft.com/tcltk/icons/ ==> ICONS
+
+
+
+===< support (may be alpha or beta quality) >=================================
+
+IncrTcl http://sf.net/projects/incrTcl ==> itcl, itk
+
+TclX http://sf.net/projects/tclx
+ ==> tclx (partial support; infox command and
+ XPG/3 message catalogs only)
+
+TkImg http://sf.net/projects/tkimg ==> tkimg
+
+TkTreeCtrl http://tktreectrl.sourceforge.net/ ==> treectrl
+
+Tile http://tktable.sourceforge.net/tile/ ==> tile
+
+
+
+===< possibly available (not tested; alpha quality) >=========================
+
+winico http://tktable.sourceforge.net
+ ==> winico (win32 only)
+
+TkTrans http://www2.cmp.uea.ac.uk/~fuzz/tktrans/default.html
+ ==> tktrans (win32 only)
+
+TkDND http://sourceforge.net/projects/tkdnd ==> tkDND
+
+
+
+===< plan to support (alpha quality libraries may be included) >==============
+
+BLT http://sourceforge.net/projects/blt
+ * see tcltk-ext library on RAA (http://raa.ruby-lang.org/)
+
+GraphViz http://www.graphviz.org/
+
+Tkgeomap http://tkgeomap.sourceforge.net/index.html
+
+
+
+===< not determined to supprt or not >========================================
+
+Tix http://tixlibrary.sourceforge.net/
+ * see tcltk-ext library on RAA (http://raa.ruby-lang.org/)
+
+TkZinc http://www.tkzinc.org/
+
+Wbc http://home.t-online.de/home/csaba.nemethi/
+
+Mentry http://home.t-online.de/home/csaba.nemethi/
+
+Tablelist http://home.t-online.de/home/csaba.nemethi/
+
+ANIGIF http://cardtable.sourceforge.net/tcltk/
+
+IMG_ROTATE http://cardtable.sourceforge.net/tcltk/
+
+TclVfs http://sourceforge.net/projects/tclvfs/
+
+vfwtcl http://sourceforge.net/projects/avicaptcl
+ * Win32 only
+
+multicast http://sourceforge.net/projects/avicaptcl
+ * Win32 only
+
+XBit http://www.geocities.com/~chengye/
+ * current implementation is for Windows only
+
+QuickTimeTcl http://hem.fyristorg.com/matben/qt/
+ * works under Mac OS (8,9,X) or Windows
+
+
+
+===< may not support (already exist, out of Ruby/Tk scope, and so on) >=======
+
+TkCon http://sf.net/projects/tkcon
+
+Expect http://sf.net/projects/expect
+
+TclXML http://sf.net/projects/tclxml
+
+TclXSLT http://sf.net/projects/tclxml
+
+TclDOM http://sf.net/projects/tclxml
+
+TclSOAP http://sf.net/projects/tclsoap
+
+Snack http://www.speech.kth.se/~kare/snack2.2.tar.gz
+ * use Snack for Ruby (see http://rbsnack.sourceforge.net/)
+
+Tcom http://www.vex.net/~cthuang/tcom/
+
+tDOM http://www.tdom.org
+
+Mk4tcl http://www.equi4.com/metakit/tcl.html
+
+Memchan http://memchan.sourceforge.net/
+
+
+
+===< tool (may not supprt) >==================================================
+
+tbcload/tclcompiler http://www.tcl.tk/software/tclpro/
+
+
+
+(End of List) \ No newline at end of file
diff --git a/ext/tk/lib/tkextlib/bwidget.rb b/ext/tk/lib/tkextlib/bwidget.rb
new file mode 100644
index 0000000000..56009f4694
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget.rb
@@ -0,0 +1,146 @@
+#
+# BWidget extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/bwidget/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('BWidget', '1.7')
+TkPackage.require('BWidget')
+
+module Tk
+ module BWidget
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ extend TkCore
+
+ LIBRARY = tk_call('set', '::BWIDGET::LIBRARY')
+
+ def self.package_version
+ begin
+ TkPackage.require('BWidget')
+ rescue
+ ''
+ end
+ end
+
+ def self.XLFDfont(cmd, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ args.concat(hash_kv(keys))
+ end
+ tk_call('BWidget::XLFDfont', cmd, *args)
+ end
+
+ def self.assert(exp, msg=None)
+ tk_call('BWidget::assert', exp, msg)
+ end
+
+ def self.badOptionString(type, value, list)
+ tk_call('BWidget::badOptionString', type, value, list)
+ end
+
+ def self.bindMouseWheel(widget)
+ tk_call('BWidget::bindMouseWheel', widget)
+ end
+
+ def self.classes(klass)
+ list(tk_call('BWidget::classes', klass))
+ end
+
+ def self.clonename(menu)
+ tk_call('BWidget::clonename', menu)
+ end
+
+ def self.focus(opt, path)
+ tk_call('BWidget::focus', opt, path)
+ end
+
+ def self.get3dcolor(path, bgcolor)
+ tk_call('BWidget::get3dcolor', path, bgcolor)
+ end
+
+ def self.getname(name)
+ tk_call('BWidget::getname', name)
+ end
+
+ def self.grab(opt, path)
+ tk_call('BWidget::grab', opt, path)
+ end
+
+ def self.inuse(klass)
+ bool(tk_call('BWidget::inuse', klass))
+ end
+
+ def self.library(klass, *klasses)
+ tk_call('BWidget::library', klass, *klasses)
+ end
+
+ def self.lreorder(list, neworder)
+ tk_call('BWidget::lreorder', list, neworder)
+ end
+
+ def self.parsetext(text)
+ tk_call('BWidget::parsetext', text)
+ end
+
+ def self.place(path, w, h, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ args.concat(hash_kv(keys))
+ end
+ tk_call('BWidget::place', path, w, h, *(args.flatten))
+ end
+
+ def self.write(file, mode=None)
+ tk_call('BWidget::write', file, mode)
+ end
+
+ def self.wrongNumArgsString(str)
+ tk_call('BWidget::wrongNumArgsString', str)
+ end
+
+ ####################################################
+
+ autoload :ArrowButton, 'tkextlib/bwidget/arrowbutton'
+ autoload :Bitmap, 'tkextlib/bwidget/bitmap'
+ autoload :Button, 'tkextlib/bwidget/button'
+ autoload :ButtonBox, 'tkextlib/bwidget/buttonbox'
+ autoload :ComboBox, 'tkextlib/bwidget/combobox'
+ autoload :Dialog, 'tkextlib/bwidget/dialog'
+ autoload :DragSite, 'tkextlib/bwidget/dragsite'
+ autoload :DropSite, 'tkextlib/bwidget/dropsite'
+ autoload :DynamicHelp, 'tkextlib/bwidget/dynamichelp'
+ autoload :Entry, 'tkextlib/bwidget/entry'
+ autoload :Label, 'tkextlib/bwidget/label'
+ autoload :LabelEntry, 'tkextlib/bwidget/labelentry'
+ autoload :LabelFrame, 'tkextlib/bwidget/labelframe'
+ autoload :ListBox, 'tkextlib/bwidget/listbox'
+ autoload :MainFrame, 'tkextlib/bwidget/mainframe'
+ autoload :MessageDlg, 'tkextlib/bwidget/messagedlg'
+ autoload :NoteBook, 'tkextlib/bwidget/notebook'
+ autoload :PagesManager, 'tkextlib/bwidget/pagesmanager'
+ autoload :PanedWindow, 'tkextlib/bwidget/panedwindow'
+ autoload :PasswdDlg, 'tkextlib/bwidget/passwddlg'
+ autoload :ProgressBar, 'tkextlib/bwidget/progressbar'
+ autoload :ProgressDlg, 'tkextlib/bwidget/progressdlg'
+ autoload :ScrollableFrame, 'tkextlib/bwidget/scrollableframe'
+ autoload :ScrolledWindow, 'tkextlib/bwidget/scrolledwindow'
+ autoload :ScrollView, 'tkextlib/bwidget/scrollview'
+ autoload :SelectColor, 'tkextlib/bwidget/selectcolor'
+ autoload :SelectFont, 'tkextlib/bwidget/selectfont'
+ autoload :Separator, 'tkextlib/bwidget/separator'
+ autoload :SpinBox, 'tkextlib/bwidget/spinbox'
+ autoload :TitleFrame, 'tkextlib/bwidget/titleframe'
+ autoload :Tree, 'tkextlib/bwidget/tree'
+ autoload :Widget, 'tkextlib/bwidget/widget'
+
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb b/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb
new file mode 100644
index 0000000000..770e5e9ef1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/bwidget/arrowbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/button'
+
+module Tk
+ module BWidget
+ class ArrowButton < Tk::BWidget::Button
+ end
+ end
+end
+
+class Tk::BWidget::ArrowButton
+ TkCommandNames = ['ArrowButton'.freeze].freeze
+ WidgetClassName = 'ArrowButton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/bitmap.rb b/ext/tk/lib/tkextlib/bwidget/bitmap.rb
new file mode 100644
index 0000000000..6cfde203e8
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/bitmap.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/bwidget/bitmap.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tk/image'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Bitmap < TkPhotoImage
+ end
+ end
+end
+
+class Tk::BWidget::Bitmap
+ def initialize(name)
+ @path = tk_call_without_enc('Bitmap::get', name)
+ Tk_IMGTBL[@path] = self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/button.rb b/ext/tk/lib/tkextlib/bwidget/button.rb
new file mode 100644
index 0000000000..246afebe29
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/button.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/bwidget/button.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/button'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Button < TkButton
+ end
+ end
+end
+
+class Tk::BWidget::Button
+ TkCommandNames = ['Button'.freeze].freeze
+ WidgetClassName = 'Button'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
new file mode 100644
index 0000000000..477de8a61f
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/bwidget/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/button'
+
+module Tk
+ module BWidget
+ class ButtonBox < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ButtonBox
+ TkCommandNames = ['ButtonBox'.freeze].freeze
+ WidgetClassName = 'ButtonBox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ include TkItemConfigMethod
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::BWidget::Button)
+ name = tagOrId[:name]
+ return index(name) unless name.empty?
+ end
+ if tagOrId.kind_of?(TkButton)
+ return index(tagOrId[:text])
+ end
+ # index(tagOrId.to_s)
+ index(_get_eval_string(tagOrId))
+ end
+
+ def add(keys={}, &b)
+ win = window(tk_send('add', *hash_kv(keys)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def delete(idx)
+ tk_send('delete', tagid(idx))
+ self
+ end
+
+ def index(idx)
+ if idx.kind_of?(Tk::BWidget::Button)
+ name = idx[:name]
+ idx = name unless name.empty?
+ end
+ if idx.kind_of?(TkButton)
+ idx = idx[:text]
+ end
+ number(tk_send('index', idx.to_s))
+ end
+
+ def insert(idx, keys={}, &b)
+ win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def invoke(idx)
+ tk_send('invoke', tagid(idx))
+ self
+ end
+
+ def set_focus(idx)
+ tk_send('setfocus', tagid(idx))
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/combobox.rb b/ext/tk/lib/tkextlib/bwidget/combobox.rb
new file mode 100644
index 0000000000..31f71c3aaf
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/combobox.rb
@@ -0,0 +1,45 @@
+#
+# tkextlib/bwidget/combobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/listbox'
+require 'tkextlib/bwidget/spinbox'
+
+module Tk
+ module BWidget
+ class ComboBox < Tk::BWidget::SpinBox
+ end
+ end
+end
+
+class Tk::BWidget::ComboBox
+ include Scrollable
+
+ TkCommandNames = ['ComboBox'.freeze].freeze
+ WidgetClassName = 'ComboBox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_listbox(&b)
+ win = window(tk_send_without_enc('getlistbox'))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def icursor(idx)
+ tk_send_without_enc('icursor', idx)
+ end
+
+ def post
+ tk_send_without_enc('post')
+ self
+ end
+
+ def unpost
+ tk_send_without_enc('unpost')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb
new file mode 100644
index 0000000000..d175a2d8bb
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb
@@ -0,0 +1,147 @@
+#
+# tkextlib/bwidget/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/buttonbox'
+
+module Tk
+ module BWidget
+ class Dialog < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::Dialog
+ TkCommandNames = ['Dialog'.freeze].freeze
+ WidgetClassName = 'Dialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ include TkItemConfigMethod
+
+ def initialize(parent=nil, keys=nil)
+ @relative = ''
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ @relative = keys['parent'] if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(keys)
+ elsif keys
+ keys = _symbolkey2str(keys)
+ @relative = keys.delete('parent') if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(parent, keys)
+ else
+ super(parent)
+ end
+ end
+
+ def create_self(keys)
+ cmd = self.class::TkCommandNames[0]
+ if keys and keys != None
+ tk_call_without_enc(cmd, @path, '-parent', @relative,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(cmd, @path, '-parent', @relative)
+ end
+ end
+
+ def cget(slot)
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ slot['parent'] = slot.delete('relative') if slot.key?('relative')
+ super(slot)
+ else
+ if slot.to_s == 'relative'
+ super('parent', value)
+ else
+ super(slot, value)
+ end
+ end
+ end
+
+ def configinfo(slot=nil)
+ if slot
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ else
+ ret = super()
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret << ['relative', 'parent']
+ else
+ ret['relative'] = 'parent'
+ end
+ end
+ end
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::BWidget::Button)
+ name = tagOrId[:name]
+ return index(name) unless name.empty?
+ end
+ if tagOrId.kind_of?(TkButton)
+ return index(tagOrId[:text])
+ end
+ # index(tagOrId.to_s)
+ index(_get_eval_string(tagOrId))
+ end
+
+ def add(keys={}, &b)
+ win = window(tk_send('add', *hash_kv(keys)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def get_frame(&b)
+ win = window(tk_send('getframe'))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def get_buttonbox(&b)
+ win = window(@path + '.bbox')
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def draw(focus_win=None)
+ tk_send('draw', focus_win)
+ end
+
+ def enddialog(ret)
+ tk_send('enddialog', ret)
+ end
+
+ def index(idx)
+ get_buttonbox.index(idx)
+ end
+
+ def invoke(idx)
+ tk_send('invoke', tagid(idx))
+ self
+ end
+
+ def set_focus(idx)
+ tk_send('setfocus', tagid(idx))
+ self
+ end
+
+ def withdraw
+ tk_send('withdraw')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/dragsite.rb b/ext/tk/lib/tkextlib/bwidget/dragsite.rb
new file mode 100644
index 0000000000..4d4de1780c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/dragsite.rb
@@ -0,0 +1,31 @@
+#
+# tkextlib/bwidget/dragsite.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DragSite
+ end
+ end
+end
+
+module Tk::BWidget::DragSite
+ include Tk
+ extend Tk
+
+ def self.include(klass, type, event)
+ tk_call('DragSite::include', klass, type, event)
+ end
+
+ def self.register(path, keys={})
+ tk_call('DragSite::register', path, *hash_kv(keys))
+ end
+
+ def self.set_drag(path, subpath, initcmd, endcmd, force=None)
+ tk_call('DragSite::setdrag', path, subpath, initcmd, endcmd, force)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/dropsite.rb b/ext/tk/lib/tkextlib/bwidget/dropsite.rb
new file mode 100644
index 0000000000..e5e98fbc51
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/dropsite.rb
@@ -0,0 +1,39 @@
+#
+# tkextlib/bwidget/dropsite.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DropSite
+ end
+ end
+end
+
+module Tk::BWidget::DropSite
+ include Tk
+ extend Tk
+
+ def self.include(klass, type)
+ tk_call('DropSite::include', klass, type)
+ end
+
+ def self.register(path, keys={})
+ tk_call('DropSite::register', path, *hash_kv(keys))
+ end
+
+ def self.set_cursor(cursor)
+ tk_call('DropSite::setcursor', cursor)
+ end
+
+ def self.set_drop(path, subpath, dropover, drop, force=None)
+ tk_call('DropSite::setdrop', path, subpath, dropover, drop, force)
+ end
+
+ def self.set_operation(op)
+ tk_call('DropSite::setoperation', op)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
new file mode 100644
index 0000000000..4766a1ec6d
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
@@ -0,0 +1,51 @@
+#
+# tkextlib/bwidget/dynamichelp.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DynamicHelp
+ end
+ end
+end
+
+module Tk::BWidget::DynamicHelp
+ include Tk
+ extend Tk
+
+ def self.__pathname
+ 'DynamicHelp::configure'
+ end
+
+ def self.__cget_cmd
+ ['DynamicHelp::configure']
+ end
+
+ def self.__config_cmd
+ ['DynamicHelp::configure']
+ end
+
+ def self.cget(slot)
+ self.current_configinfo(slot).values[0]
+ end
+
+ def self.add(widget, keys={})
+ tk_call('DynamicHelp::add', widget, *hash_kv(keys))
+ end
+
+ def self.delete(widget)
+ tk_call('DynamicHelp::delete', widget)
+ end
+
+ def self.include(klass, type)
+ tk_call('DynamicHelp::include', klass, type)
+ end
+
+ def self.sethelp(path, subpath, force=None)
+ tk_call('DynamicHelp::sethelp', path, subpath, force)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/entry.rb b/ext/tk/lib/tkextlib/bwidget/entry.rb
new file mode 100644
index 0000000000..9867a1ac36
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/entry.rb
@@ -0,0 +1,28 @@
+#
+# tkextlib/bwidget/entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Entry < TkEntry
+ end
+ end
+end
+
+class Tk::BWidget::Entry
+ include Scrollable
+
+ TkCommandNames = ['Entry'.freeze].freeze
+ WidgetClassName = 'Entry'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def invoke
+ tk_send_without_enc('invoke')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/label.rb b/ext/tk/lib/tkextlib/bwidget/label.rb
new file mode 100644
index 0000000000..1d4c638705
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/label.rb
@@ -0,0 +1,26 @@
+#
+# tkextlib/bwidget/label.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/label'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Label < TkLabel
+ end
+ end
+end
+
+class Tk::BWidget::Label
+ TkCommandNames = ['Label'.freeze].freeze
+ WidgetClassName = 'Label'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def set_focus
+ tk_send_without_enc('setfocus')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ext/tk/lib/tkextlib/bwidget/labelentry.rb
new file mode 100644
index 0000000000..7a6a7f01d6
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/labelentry.rb
@@ -0,0 +1,45 @@
+#
+# tkextlib/bwidget/labelentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/labelframe'
+require 'tkextlib/bwidget/entry'
+
+module Tk
+ module BWidget
+ class LabelEntry < TkEntry
+ end
+ end
+end
+
+class Tk::BWidget::LabelEntry
+ include Scrollable
+
+ TkCommandNames = ['LabelEntry'.freeze].freeze
+ WidgetClassName = 'LabelEntry'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def entrybind(*args)
+ _bind([path, 'bind'], *args)
+ self
+ end
+
+ def entrybind_append(*args)
+ _bind_append([path, 'bind'], *args)
+ self
+ end
+
+ def entrybind_remove(*args)
+ _bind_remove([path, 'bind'], *args)
+ self
+ end
+
+ def entrybindinfo(*args)
+ _bindinfo([path, 'bind'], *args)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/labelframe.rb b/ext/tk/lib/tkextlib/bwidget/labelframe.rb
new file mode 100644
index 0000000000..453756a163
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/labelframe.rb
@@ -0,0 +1,30 @@
+#
+# tkextlib/bwidget/labelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class LabelFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::LabelFrame
+ TkCommandNames = ['LabelFrame'.freeze].freeze
+ WidgetClassName = 'LabelFrame'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def self.align(*args)
+ tk_call('LabelFrame::align', *args)
+ end
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ win.instance_eval(&b) if b
+ win
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb
new file mode 100644
index 0000000000..9f505703f2
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb
@@ -0,0 +1,290 @@
+#
+# tkextlib/bwidget/listbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ListBox < TkWindow
+ # is NOT a subclass of a listbox widget class.
+ # because it constructed on a canvas widget.
+
+ class Item < TkObject
+ end
+ end
+ end
+end
+
+class Tk::BWidget::ListBox
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['ListBox'.freeze].freeze
+ WidgetClassName = 'ListBox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ class Event_for_Items < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # item idenfier
+ ]
+ end
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BWidget::ListBox::Item)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ def imagebind(*args)
+ _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebind_append(*args)
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ end
+
+ def textbind(*args)
+ _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbind_append(*args)
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ end
+
+ def delete(*args)
+ tk_send('delete', *args)
+ self
+ end
+
+ def edit(item, text, *args)
+ tk_send('edit', tagid(item), text, *args)
+ self
+ end
+
+ def exist?(item)
+ bool(tk_send('exists', tagid(item)))
+ end
+
+ def index(item)
+ num_or_str(tk_send('index', tagid(item)))
+ end
+
+ def insert(idx, item, keys={})
+ tk_send('insert', idx, tagid(item), *hash_kv(keys))
+ self
+ end
+
+ def get_item(idx)
+ tk_send('items', idx)
+ end
+
+ def items(first=None, last=None)
+ list(tk_send('items', first, last))
+ end
+
+ def move(item, idx)
+ tk_send('move', tagid(item), idx)
+ self
+ end
+
+ def reorder(neworder)
+ tk_send('reorder', neworder)
+ self
+ end
+
+ def see(item)
+ tk_send('see', tagid(item))
+ self
+ end
+
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+
+ def selection_set(*args)
+ tk_send_without_enc('selection', 'set',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_add(*args)
+ tk_send_without_enc('selection', 'add',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_remove(*args)
+ tk_send_without_enc('selection', 'remove',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_get(*args)
+ simplelist(tk_send_without_enc('selection', 'get')).collect{|item|
+ Tk::BWidget::ListBox::Item.id2obj(self, item)
+ }
+ end
+end
+
+class Tk::BWidget::ListBox::Item
+ include TkTreatTagFont
+
+ ListItem_TBL = TkCore::INTERP.create_table
+ ListItem_ID = ['bw:item'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ ListItem_TBL.clear }
+
+ def self.id2obj(lbox, id)
+ lpath = lbox.path
+ return id unless ListItem_TBL[lpath]
+ ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
+ end
+
+ def initialize(lbox, *args)
+ if lbox.kind_of?(Tk::BWidget::ListBox)
+ @listbox = lbox
+ else
+ fail RuntimeError,
+ "expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument"
+ end
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = {}
+ end
+
+ index = keys.delete('index')
+ unless args.empty?
+ index = args.shift
+ end
+ index = 'end' unless index
+
+ unless args.empty?
+ fail RuntimeError, 'too much arguments'
+ end
+
+ @lpath = @listbox.path
+
+ if keys.key?('itemname')
+ @path = @id = keys.delete('itemname')
+ else
+ @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
+ ListItem_ID[1].succ!
+ end
+
+ ListItem_TBL[@id] = self
+ ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
+ ListItem_TBL[@lpath][@id] = self
+
+ @listbox.insert(index, @id, keys)
+ end
+
+ def listbox
+ @listbox
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget(key)
+ end
+
+ def []=(key, val)
+ configure(key, val)
+ val
+ end
+
+ def cget(key)
+ @listbox.itemcget(@id, key)
+ end
+
+ def configure(key, val=None)
+ @listbox.itemconfigure(@id, key, val)
+ end
+
+ def configinfo(key=nil)
+ @listbox.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @listbox.current_itemconfiginfo(@id, key)
+ end
+
+ def delete
+ @listbox.delete(@id)
+ self
+ end
+
+ def edit(*args)
+ @listbox.edit(@id, *args)
+ self
+ end
+
+ def exist?
+ @listbox.exist?(@id)
+ end
+
+ def index
+ @listbox.index(@id)
+ end
+
+ def move(index)
+ @listbox.move(@id, index)
+ end
+
+ def see
+ @listbox.see(@id)
+ end
+
+ def selection_add
+ @listbox.selection_add(@id)
+ end
+
+ def selection_remove
+ @listbox.selection_remove(@id)
+ end
+
+ def selection_set
+ @listbox.selection_set(@id)
+ end
+
+ def selection_toggle
+ @listbox.selection_toggle(@id)
+ end
+end
+
diff --git a/ext/tk/lib/tkextlib/bwidget/mainframe.rb b/ext/tk/lib/tkextlib/bwidget/mainframe.rb
new file mode 100644
index 0000000000..e52f4b2f4c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/mainframe.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/bwidget/mainframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/progressbar'
+
+module Tk
+ module BWidget
+ class MainFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::MainFrame
+ TkCommandNames = ['MainFrame'.freeze].freeze
+ WidgetClassName = 'MainFrame'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def add_indicator(keys={}, &b)
+ win = window(tk_send('addindicator', *hash_kv(keys)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def add_toolbar(&b)
+ win = window(tk_send('addtoolbar'))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def get_frame(&b)
+ win = window(tk_send('getframe'))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def get_indicator(idx, &b)
+ win = window(tk_send('getindicator', idx))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def get_menu(menu_id, &b)
+ win = window(tk_send('getmenu', menu_id))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def get_toolbar(idx, &b)
+ win = window(tk_send('gettoolbar', idx))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def set_menustate(tag, state)
+ tk_send('setmenustate', tag, state)
+ self
+ end
+
+ def show_statusbar(name)
+ tk_send('showstatusbar', name)
+ self
+ end
+
+ def show_toolbar(idx, mode)
+ tk_send('showtoolbar', idx, mode)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
new file mode 100644
index 0000000000..d7b2bbc32b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
@@ -0,0 +1,167 @@
+#
+# tkextlib/bwidget/messagedlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class MessageDlg < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::MessageDlg
+ TkCommandNames = ['MessageDlg'.freeze].freeze
+ WidgetClassName = 'MessageDlg'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def initialize(parent=nil, keys=nil)
+ @relative = ''
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ @relative = keys['parent'] if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(keys)
+ elsif keys
+ keys = _symbolkey2str(keys)
+ @relative = keys.delete('parent') if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(parent, keys)
+ else
+ super(parent)
+ end
+ end
+
+ def create_self(keys)
+ # NOT create widget.
+ # Because the widget no longer exist when returning from creation.
+ @keys = _symbolkey2str(keys).update('parent'=>@relative)
+ @info = nil
+ end
+ private :create_self
+
+ def cget(slot)
+ slot = slot.to_s
+ if slot == 'relative'
+ slot = 'parent'
+ end
+ if winfo_exist?
+ val = super(slot)
+ @keys[slot] = val
+ end
+ @keys[slot]
+ end
+
+ def configure(slot, value=None)
+ if winfo_exist?
+ super(slot, value)
+ end
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ slot['parent'] = slot.delete('relative') if slot.key?('relative')
+ @keys.update(slot)
+
+ if @info
+ # update @info
+ slot.each{|k, v|
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = @info.assoc(k))
+ inf[-1] = v
+ else
+ @info << [k, '', '', '', v]
+ end
+ else
+ if (inf = @info[k])
+ inf[-1] = v
+ else
+ @info[k] = ['', '', '', v]
+ end
+ end
+ }
+ end
+
+ else # ! Hash
+ slot = slot.to_s
+ slot = 'parent' if slot == 'relative'
+ @keys[slot] = value
+
+ if @info
+ # update @info
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = @info.assoc(slot))
+ inf[-1] = value
+ else
+ @info << [slot, '', '', '', value]
+ end
+ else
+ if (inf = @info[slot])
+ inf[-1] = value
+ else
+ @info[slot] = ['', '', '', value]
+ end
+ end
+ end
+ end
+
+ self
+ end
+
+ def configinfo(slot=nil)
+ if winfo_exist?
+ @info = super()
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ @info << ['relative', 'parent']
+ else
+ @info['relative'] = 'parent'
+ end
+ end
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if @info
+ if winfo_exist?
+ # update @keys
+ @info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 }
+ end
+ else
+ @info = []
+ @keys.each{|k, v|
+ @info << [k, '', '', '', v]
+ }
+ @info << ['relative', 'parent']
+ end
+
+ if slot
+ @info.asoc(slot.to_s).dup
+ else
+ @info.dup
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if @info
+ if winfo_exist?
+ # update @keys
+ @info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 }
+ end
+ else
+ @info = {}
+ @keys.each{|k, v|
+ @info[k] = ['', '', '', v]
+ }
+ @info['relative'] = 'parent'
+ end
+
+ if slot
+ @info[slot.to_s].dup
+ else
+ @info.dup
+ end
+ end
+ end
+
+ def create
+ num_or_str(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb
new file mode 100644
index 0000000000..e0cc04d30e
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb
@@ -0,0 +1,116 @@
+#
+# tkextlib/bwidget/notebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class NoteBook < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::NoteBook
+ include TkItemConfigMethod
+
+ TkCommandNames = ['NoteBook'.freeze].freeze
+ WidgetClassName = 'NoteBook'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ class Event_for_Tabs < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # page idenfier
+ ]
+ end
+ end
+
+ def tagid(id)
+ if id.kind_of?(TkWindow)
+ id.path
+ elsif id.kind_of?(TkObject)
+ id.to_eval
+ else
+ # id.to_s
+ _get_eval_string(id)
+ end
+ end
+
+ def tabbind(*args)
+ _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ self
+ end
+
+ def tabbind_append(*args)
+ _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ self
+ end
+
+ def tabbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ self
+ end
+
+ def tabbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ end
+
+ def add(page, &b)
+ win = window(tk_send('add', tagid(page)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def compute_size
+ tk_send('compute_size')
+ self
+ end
+
+ def delete(page, destroyframe=None)
+ tk_send('delete', tagid(page), destroyframe)
+ self
+ end
+
+ def get_frame(page, &b)
+ win = window(tk_send('getframe', tagid(page)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def index(page)
+ num_or_str(tk_send('index', tagid(page)))
+ end
+
+ def insert(index, page, keys={}, &b)
+ win = window(tk_send('insert', index, tagid(page), *hash_kv(keys)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def move(page, index)
+ tk_send('move', tagid(page), index)
+ self
+ end
+
+ def get_page(page)
+ tk_send('pages', page)
+ end
+
+ def pages(first=None, last=None)
+ list(tk_send('pages', first, last))
+ end
+
+ def raise(page=None)
+ tk_send('raise', page)
+ self
+ end
+
+ def see(page)
+ tk_send('see', page)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
new file mode 100644
index 0000000000..fc01284be6
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/bwidget/pagesmanager.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PagesManager < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PagesManager
+ TkCommandNames = ['PagesManager'.freeze].freeze
+ WidgetClassName = 'PagesManager'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def tagid(id)
+ # id.to_s
+ _get_eval_string(id)
+ end
+
+ def add(page, &b)
+ win = window(tk_send('add', tagid(page)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def compute_size
+ tk_send('compute_size')
+ self
+ end
+
+ def delete(page)
+ tk_send('delete', tagid(page))
+ self
+ end
+
+ def get_frame(page, &b)
+ win = window(tk_send('getframe', tagid(page)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def get_page(page)
+ tk_send('pages', page)
+ end
+
+ def pages(first=None, last=None)
+ list(tk_send('pages', first, last))
+ end
+
+ def raise(page=None)
+ tk_send('raise', page)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/panedwindow.rb b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
new file mode 100644
index 0000000000..19982c6095
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
@@ -0,0 +1,31 @@
+#
+# tkextlib/bwidget/panedwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PanedWindow < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PanedWindow
+ TkCommandNames = ['PanedWindow'.freeze].freeze
+ WidgetClassName = 'PanedWindow'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def add(keys={})
+ window(tk_send('add', *hash_kv(keys)))
+ end
+
+ def get_frame(idx, &b)
+ win = window(tk_send_without_enc('getframe', idx))
+ win.instance_eval(&b) if b
+ win
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/passwddlg.rb b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb
new file mode 100644
index 0000000000..7136ae8d72
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb
@@ -0,0 +1,27 @@
+#
+# tkextlib/bwidget/passwddlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class PasswdDlg < Tk::BWidget::MessageDlg
+ end
+ end
+end
+
+class Tk::BWidget::PasswdDlg
+ TkCommandNames = ['PasswdDlg'.freeze].freeze
+ WidgetClassName = 'PasswdDlg'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create
+ login, passwd = simplelist(tk_call(self.class::TkCommandNames[0],
+ @path, *hash_kv(@keys)))
+ [login, passwd]
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/progressbar.rb b/ext/tk/lib/tkextlib/bwidget/progressbar.rb
new file mode 100644
index 0000000000..0253ce2ada
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/progressbar.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/bwidget/progressbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ProgressBar < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ProgressBar
+ TkCommandNames = ['ProgressBar'.freeze].freeze
+ WidgetClassName = 'ProgressBar'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/progressdlg.rb b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
new file mode 100644
index 0000000000..fbf00f3b00
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
@@ -0,0 +1,54 @@
+#
+# tkextlib/bwidget/progressdlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/variable'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/progressbar'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class ProgressDlg < Tk::BWidget::MessageDlg
+ end
+ end
+end
+
+class Tk::BWidget::ProgressDlg
+ TkCommandNames = ['ProgressDlg'.freeze].freeze
+ WidgetClassName = 'ProgressDlg'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ # NOT create widget for reusing the object
+ super(keys)
+ @keys['textvariable'] = TkVariable.new unless @keys.key?('textvariable')
+ @keys['variable'] = TkVariable.new unless @keys.key?('variable')
+ end
+
+ def textvariable
+ @keys['textvariable']
+ end
+
+ def text
+ @keys['textvariable'].value
+ end
+
+ def text= (txt)
+ @keys['textvariable'].value = txt
+ end
+
+ def variable
+ @keys['variable']
+ end
+
+ def value
+ @keys['variable'].value
+ end
+
+ def value= (val)
+ @keys['variable'].value = val
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
new file mode 100644
index 0000000000..a3986681a5
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
@@ -0,0 +1,34 @@
+#
+# tkextlib/bwidget/scrollableframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrollableFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrollableFrame
+ include Scrollable
+
+ TkCommandNames = ['ScrollableFrame'.freeze].freeze
+ WidgetClassName = 'ScrollableFrame'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def see(win, vert=None, horiz=None)
+ tk_send_without_enc('see', win, vert, horiz)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
new file mode 100644
index 0000000000..e9e53235b7
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
@@ -0,0 +1,32 @@
+#
+# tkextlib/bwidget/scrolledwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrolledWindow < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrolledWindow
+ TkCommandNames = ['ScrolledWindow'.freeze].freeze
+ WidgetClassName = 'ScrolledWindow'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def set_widget(win)
+ tk_send_without_enc('setwidget', win)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/scrollview.rb b/ext/tk/lib/tkextlib/bwidget/scrollview.rb
new file mode 100644
index 0000000000..5da528bd49
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/scrollview.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/bwidget/scrollview.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrollView < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrollView
+ TkCommandNames = ['ScrollView'.freeze].freeze
+ WidgetClassName = 'ScrollView'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/selectcolor.rb b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
new file mode 100644
index 0000000000..742a84cd84
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
@@ -0,0 +1,45 @@
+#
+# tkextlib/bwidget/selectcolor.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class SelectColor < Tk::BWidget::MessageDlg
+ end
+ end
+end
+
+class Tk::BWidget::SelectColor
+ extend Tk
+
+ TkCommandNames = ['SelectColor'.freeze].freeze
+ WidgetClassName = 'SelectColor'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def dialog(keys={})
+ newkeys = @keys.dup
+ newkeys.update(_symbolkey2str(keys))
+ tk_call('SelectColor::dialog', @path, *hash_kv(newkeys))
+ end
+
+ def menu(*args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ else
+ keys = {}
+ end
+ place = args.flatten
+ newkeys = @keys.dup
+ newkeys.update(_symbolkey2str(keys))
+ tk_call('SelectColor::menu', @path, place, *hash_kv(newkeys))
+ end
+
+ def self.set_color(idx, color)
+ tk_call('SelectColor::setcolor', idx, color)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/selectfont.rb b/ext/tk/lib/tkextlib/bwidget/selectfont.rb
new file mode 100644
index 0000000000..46ca0dbca8
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/selectfont.rb
@@ -0,0 +1,79 @@
+#
+# tkextlib/bwidget/selectfont.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class SelectFont < Tk::BWidget::MessageDlg
+ class Dialog < Tk::BWidget::SelectFont
+ end
+ class Toolbar < TkWindow
+ end
+ end
+ end
+end
+
+class Tk::BWidget::SelectFont
+ extend Tk
+
+ TkCommandNames = ['SelectFont'.freeze].freeze
+ WidgetClassName = 'SelectFont'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+
+ def create
+ tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+
+ def self.load_font
+ tk_call('SelectFont::loadfont')
+ end
+end
+
+class Tk::BWidget::SelectFont::Dialog
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+
+ def create_self(keys)
+ super(keys)
+ @keys['type'] = 'dialog'
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.delete['type']
+ slot.delete[:type]
+ return self if slot.empty?
+ else
+ return self if slot == 'type' || slot == :type
+ end
+ super(slot, value)
+ end
+
+ def create
+ @keys['type'] = 'dialog'
+ tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+end
+
+class Tk::BWidget::SelectFont::Toolbar
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+
+ def create_self(keys)
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+ keys['type'] = 'toolbar'
+ tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(keys))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/separator.rb b/ext/tk/lib/tkextlib/bwidget/separator.rb
new file mode 100644
index 0000000000..d9c3458e51
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/separator.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/bwidget/separator.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Separator < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::Separator
+ TkCommandNames = ['Separator'.freeze].freeze
+ WidgetClassName = 'Separator'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/setup.rb b/ext/tk/lib/tkextlib/bwidget/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ext/tk/lib/tkextlib/bwidget/spinbox.rb
new file mode 100644
index 0000000000..4380e38355
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/spinbox.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/bwidget/entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/arrowbutton'
+require 'tkextlib/bwidget/entry'
+
+module Tk
+ module BWidget
+ class SpinBox < TkEntry
+ end
+ end
+end
+
+class Tk::BWidget::SpinBox
+ include Scrollable
+
+ TkCommandNames = ['SpinBox'.freeze].freeze
+ WidgetClassName = 'SpinBox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def entrybind(*args)
+ _bind([path, 'bind'], *args)
+ self
+ end
+
+ def entrybind_append(*args)
+ _bind_append([path, 'bind'], *args)
+ self
+ end
+
+ def entrybind_remove(*args)
+ _bind_remove([path, 'bind'], *args)
+ self
+ end
+
+ def entrybindinfo(*args)
+ _bindinfo([path, 'bind'], *args)
+ self
+ end
+
+ def get_index_of_value
+ number(tk_send_without_enc('getvalue'))
+ end
+ alias get_value get_index_of_value
+ alias get_value_index get_index_of_value
+
+ def set_value_by_index(idx)
+ idx = "@#{idx}" if idx.kind_of?(Integer)
+ tk_send_without_enc('setvalue', idx)
+ self
+ end
+ alias set_value set_value_by_index
+ alias set_index_value set_value_by_index
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/titleframe.rb b/ext/tk/lib/tkextlib/bwidget/titleframe.rb
new file mode 100644
index 0000000000..f519490430
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/titleframe.rb
@@ -0,0 +1,27 @@
+#
+# tkextlib/bwidget/titleframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class TitleFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::TitleFrame
+ TkCommandNames = ['TitleFrame'.freeze].freeze
+ WidgetClassName = 'TitleFrame'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ win.instance_eval(&b) if b
+ win
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb
new file mode 100644
index 0000000000..9a49a96bb7
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/tree.rb
@@ -0,0 +1,374 @@
+#
+# tkextlib/bwidget/tree.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Tree < TkWindow
+ class Node < TkObject
+ end
+ end
+ end
+end
+
+class Tk::BWidget::Tree
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['Tree'.freeze].freeze
+ WidgetClassName = 'Tree'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ class Event_for_Items < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # item idenfier
+ ]
+ end
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BWidget::Tree::Node)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ def imagebind(*args)
+ _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebind_append(*args)
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ end
+
+ def textbind(*args)
+ _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbind_append(*args)
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ end
+
+ def close_tree(node, recurse=None)
+ tk_send('closetree', tagid(node), recurse)
+ self
+ end
+
+ def delete(*args)
+ tk_send('delete', *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def edit(node, text, *args)
+ tk_send('edit', tagid(node), text, *args)
+ self
+ end
+
+ def exist?(node)
+ bool(tk_send('exists', tagid(node)))
+ end
+
+ def index(node)
+ num_or_str(tk_send('index', tagid(node)))
+ end
+
+ def insert(idx, parent, node, keys={})
+ tk_send('insert', idx, tagid(parent), tagid(node), *hash_kv(keys))
+ self
+ end
+
+ def move(parent, node, idx)
+ tk_send('move', tagid(parent), tagid(node), idx)
+ self
+ end
+
+ def get_node(node, idx)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send('nodes', tagid(node), idx))
+ end
+
+ def nodes(node, first=None, last=None)
+ simplelist(tk_send('nodes', tagid(node), first, last)).collect{|node|
+ Tk::BWidget::Tree::Node.id2obj(self, node)
+ }
+ end
+
+ def open?(node)
+ bool(@tree.itemcget(tagid(node), 'open'))
+ end
+
+ def open_tree(node, recurse=None)
+ tk_send('opentree', tagid(node), recurse)
+ self
+ end
+
+ def parent(node)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send('parent', tagid(node)))
+ end
+
+ def reorder(node, neworder)
+ tk_send('reorder', tagid(node), neworder)
+ self
+ end
+
+ def see(node)
+ tk_send('see', tagid(node))
+ self
+ end
+
+ def selection_add(*args)
+ tk_send_without_enc('selection', 'add',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+
+ def selection_get
+ list(tk_send_without_enc('selection', 'get'))
+ end
+
+ def selection_include?(*args)
+ bool(tk_send_without_enc('selection', 'get',
+ *(args.collect{|node| tagid(node)})))
+ end
+
+ def selection_range(*args)
+ tk_send_without_enc('selection', 'range',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_remove(*args)
+ tk_send_without_enc('selection', 'remove',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_set(*args)
+ tk_send_without_enc('selection', 'set',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_toggle(*args)
+ tk_send_without_enc('selection', 'toggle',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def toggle(node)
+ tk_send_without_enc('toggle', tagid(node))
+ self
+ end
+
+ def visible(node)
+ bool(tk_send_without_enc('visible', tagid(node)))
+ end
+end
+
+class Tk::BWidget::Tree::Node
+ include TkTreatTagFont
+
+ TreeNode_TBL = TkCore::INTERP.create_table
+ TreeNode_ID = ['bw:node'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ TreeNode_TBL.clear }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ return id unless TreeNode_TBL[tpath]
+ TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
+ end
+
+ def initialize(tree, *args)
+ if tree.kind_of?(Tk::BWidget::Tree)
+ @tree = tree
+ parent = args.shift
+ if parent.kind_of?(Tk::BWidget::Tree::Node)
+ if parent.tree.path != @tree.path
+ fail RuntimeError, 'tree of parent node is not match'
+ end
+ end
+ elsif tree.kind_of?(Tk::BWidget::Tree::Node)
+ @tree = tree.tree
+ parent = tree.parent
+ else
+ fail RuntimeError,
+ "expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument"
+ end
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = {}
+ end
+
+ index = keys.delete('index')
+ unless args.empty?
+ index = args.shift
+ end
+ index = 'end' unless index
+
+ unless args.empty?
+ fail RuntimeError, 'too much arguments'
+ end
+
+ @tpath = @tree.path
+
+ if keys.key?('nodename')
+ @path = @id = keys.delete('nodename')
+ else
+ @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
+ TreeNode_ID[1].succ!
+ end
+
+ TreeNode_TBL[@id] = self
+ TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
+ TreeNode_TBL[@tpath][@id] = self
+
+ @tree.insert(index, parent, @id, keys)
+ end
+
+ def tree
+ @tree
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget(key)
+ end
+
+ def []=(key, val)
+ configure(key, val)
+ val
+ end
+
+ def cget(key)
+ @tree.itemcget(@id, key)
+ end
+
+ def configure(key, val=None)
+ @tree.itemconfigure(@id, key, val)
+ end
+
+ def configinfo(key=nil)
+ @tree.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @tree.current_itemconfiginfo(@id, key)
+ end
+
+ def close_tree(recurse=None)
+ @tree.close_tree(@id, recurse)
+ self
+ end
+
+ def delete
+ @tree.delete(@id)
+ self
+ end
+
+ def edit(*args)
+ @tree.edit(@id, *args)
+ self
+ end
+
+ def exist?
+ @tree.exist?(@id)
+ end
+
+ def index
+ @tree.index(@id)
+ end
+
+ def move(index, parent=nil)
+ if parent
+ @tree.move(parent, @id, index)
+ else
+ @tree.move(self.parent, @id, index)
+ end
+ end
+
+ def open_tree(recurse=None)
+ @tree.open_tree(@id, recurse)
+ self
+ end
+
+ def open?
+ bool(@tree.itemcget(@id, 'open'))
+ end
+
+ def parent
+ @tree.parent(@id)
+ end
+
+ def reorder(neworder)
+ @tree.reorder(@id, neworder)
+ end
+
+ def see
+ @tree.see(@id)
+ end
+
+ def selection_add
+ @tree.selection_add(@id)
+ end
+
+ def selection_remove
+ @tree.selection_remove(@id)
+ end
+
+ def selection_set
+ @tree.selection_set(@id)
+ end
+
+ def selection_toggle
+ @tree.selection_toggle(@id)
+ end
+
+ def toggle
+ @tree.toggle(@id)
+ end
+
+ def visible
+ @tree.visible(@id)
+ end
+end
+
diff --git a/ext/tk/lib/tkextlib/bwidget/widget.rb b/ext/tk/lib/tkextlib/bwidget/widget.rb
new file mode 100644
index 0000000000..eadf59c11c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/widget.rb
@@ -0,0 +1,113 @@
+#
+# tkextlib/bwidget/widget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module Widget
+ end
+ end
+end
+
+module Tk::BWidget::Widget
+ include Tk
+ extend Tk
+
+ def self.__pathname
+ 'Widget::configure'
+ end
+
+ def self.__cget_cmd
+ ['Widget::cget']
+ end
+
+ def self.__config_cmd
+ ['Widget::configure']
+ end
+
+ def self.cget(slot)
+ self.current_configinfo(slot).values[0]
+ end
+
+ def self.add_map(klass, subclass, subpath, opts)
+ tk_call('Widget::addmap', klass, subclass, subpath, opts)
+ end
+
+ def self.bwinclude(klass, subclass, subpath, *args)
+ tk_call('Widget::bwinclude', klass, subclass, subpath, *args)
+ end
+
+ def self.create(klass, path, rename=None, &b)
+ win = window(tk_call('Widget::create', klass, path, rename))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def self.declare(klass, optlist)
+ tk_call('Widget::declare', klass, optlist)
+ end
+
+ def self.define(klass, filename, *args)
+ tk_call('Widget::define', klass, filename, *args)
+ end
+
+ def self.destroy(win)
+ tk_call('Widget::destroy', win)
+ end
+
+ def self.focus_next(win)
+ tk_call('Widget::focusNext', win)
+ end
+
+ def self.focus_ok(win)
+ tk_call('Widget::focusOk', win)
+ end
+
+ def self.focus_prev(win)
+ tk_call('Widget::focusPrev', win)
+ end
+
+ def self.generate_doc(dir, widgetlist)
+ tk_call('Widget::generate-doc', dir, widgetlist)
+ end
+
+ def self.generate_widget_doc(klass, iscmd, file)
+ tk_call('Widget::generate-widget-doc', klass, iscmd, file)
+ end
+
+ def self.get_option(win, option)
+ tk_call('Widget::getoption', win, option)
+ end
+
+ def self.get_variable(win, varname, my_varname=None)
+ tk_call('Widget::getVariable', win, varname, my_varname)
+ end
+
+ def self.has_changed(win, option, pvalue)
+ tk_call('Widget::hasChanged', win, option, pvalue)
+ end
+
+ def self.init(klass, win, options)
+ tk_call('Widget::init', klass, win, options)
+ end
+
+ def self.set_option(win, option, value)
+ tk_call('Widget::setoption', win, option, value)
+ end
+
+ def self.sub_cget(win, subwidget)
+ tk_call('Widget::subcget', win, subwidget)
+ end
+
+ def self.sync_options(klass, subclass, subpath, options)
+ tk_call('Widget::syncoptions', klass, subclass, subpath, options)
+ end
+
+ def self.tkinclude(klass, tkwidget, subpath, *args)
+ tk_call('Widget::tkinclude', klass, tkwidget, subpath, *args)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/itcl.rb b/ext/tk/lib/tkextlib/itcl.rb
new file mode 100644
index 0000000000..1d6ecf04f2
--- /dev/null
+++ b/ext/tk/lib/tkextlib/itcl.rb
@@ -0,0 +1,13 @@
+#
+# [incr Tcl] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/itcl/setup.rb'
+
+# load library
+require 'tkextlib/itcl/incr_tcl.rb'
diff --git a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
new file mode 100644
index 0000000000..c03f3c36cb
--- /dev/null
+++ b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
@@ -0,0 +1,167 @@
+#
+# tkextlib/itk/incr_tcl.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script
+require 'tkextlib/itcl.rb'
+
+# TkPackage.require('Itcl', '3.2')
+TkPackage.require('Itcl')
+
+module Tk
+ module Itcl
+ include Tk
+ extend Tk
+
+ LIBRARY = TkVarAccess.new('::itcl::library')
+ PURIST = TkVarAccess.new('::itcl::purist')
+
+ VERSION = TkCore::INTERP._invoke("set", "::itcl::version").freeze
+ PATCHLEVEL = TkCore::INTERP._invoke("set", "::itcl::patchLevel").freeze
+
+ def self.package_version
+ begin
+ TkPackage.require('Itcl')
+ rescue
+ ''
+ end
+ end
+
+ ##############################################
+
+ class ItclObject < TkObject
+ ITCL_CLASSNAME = ''.freeze
+
+ ITCL_OBJ_ID = ['itclobj'.freeze, '00000'.taint].freeze
+ ITCL_OBJ_TBL = {}.taint
+
+ def initialize(*args)
+ if (@klass = self.class::ITCL_CLASSNAME).empty?
+ fail RuntimeError, 'unknown itcl class (abstract class?)'
+ end
+ @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
+ @path = @id
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
+ end
+
+ def self.call_proc(name, *args)
+ tk_call("#{ITCL_CLASSNAME}::#{cmd}", *args)
+ end
+
+ def call_method(name, *args)
+ tk_call(@path, name, *args)
+ end
+
+ def isa(klass)
+ bool(tk_call(@path, 'isa', klass))
+ end
+ alias itcl_kind_of? isa
+
+ def info_class
+ tk_call(@path, 'info', 'class')
+ end
+
+ def info_inherit
+ simplelist(tk_call(@path, 'info', 'inherit'))
+ end
+
+ def info_heritage
+ list(tk_call(@path, 'info', 'heritage'))
+ end
+
+ def info_function(*args)
+ if args[-1].kind_of?(Array)
+ params = args.pop
+ params.each{|param|
+ param = param.to_s
+ args << ( (param[0] == ?-)? param: "-#{param}" )
+ }
+ end
+ list(tk_call(@path, 'info', 'function', *args))
+ end
+
+ def info_variable(*args)
+ if args[-1].kind_of?(Array)
+ params = args.pop
+ params.each{|param|
+ param = param.to_s
+ args << ( (param[0] == ?-)? param: "-#{param}" )
+ }
+ end
+ list(tk_call(@path, 'info', 'variable', *args))
+ end
+ end
+
+ ##############################################
+
+ def self.body(klass, func, args, body)
+ tk_call('::itcl::body', "#{klass}::#{func}", args, body)
+ end
+
+ def self.code(cmd, *args)
+ tk_call('::itcl::code', cmd, *args)
+ end
+
+ def self.code_in_namespace(namespace, cmd, *args)
+ tk_call('::itcl::code', '-namespace', namespace, cmd, *args)
+ end
+
+ def self.configbody(klass, var, body)
+ tk_call('::itcl::configbody', "#{klass}::#{var}", body)
+ end
+
+ def self.create_itcl_class(name, body)
+ TkCore::INTERP._invoke('::itcl::class', name, body)
+ klass = Class.new(Tk::Itcl::ItclObject)
+ klass.const_set('ITCL_CLASSNAME', name.dup.freeze)
+ klass
+ end
+
+ def self.delete_itcl_class(*names)
+ tk_call('::itcl::delete', 'class', *names)
+ end
+
+ def self.delete_itcl_object(*names)
+ tk_call('::itcl::delete', 'object', *names)
+ end
+
+ def self.delete_namespace(*names)
+ tk_call('::itcl::delete', 'namespace', *names)
+ end
+
+ def self.ensemble(name, *args)
+ tk_call('::itcl::ensemble', name, *args)
+ end
+
+ def self.find_classes(pat=None)
+ simplelist(tk_call('::itcl::find', 'classes', pat))
+ end
+
+ def self.find_objects(*args)
+ simplelist(tk_call('::itcl::find', 'objects', *args))
+ end
+
+ def self.is_itcl_class(target)
+ bool(tk_call('::itcl::is', 'class', target))
+ end
+
+ def self.is_itcl_object(target)
+ bool(tk_call('::itcl::is', 'object', target))
+ end
+
+ def self.create_local_obj(klass, name, *args)
+ tk_call('::itcl::local', klass, name, *args)
+ end
+
+ def self.is_itcl_instance(klass, target)
+ bool(tk_call('::itcl::is', 'object', '-class', klass, target))
+ end
+
+ def self.scope(var)
+ tk_call('::itcl::scope', var)
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/itcl/setup.rb b/ext/tk/lib/tkextlib/itcl/setup.rb
new file mode 100644
index 0000000000..5be0588703
--- /dev/null
+++ b/ext/tk/lib/tkextlib/itcl/setup.rb
@@ -0,0 +1,13 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
+
+
+# set [incr Tcl] library directory
+
+# ENV['ITCL_LIBRARY'] = '/usr/local/ActiveTcl/lib/itcl3.2/'
diff --git a/ext/tk/lib/tkextlib/itk.rb b/ext/tk/lib/tkextlib/itk.rb
new file mode 100644
index 0000000000..7492bd3eb4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/itk.rb
@@ -0,0 +1,13 @@
+#
+# [incr Tk] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/itk/setup.rb'
+
+# load library
+require 'tkextlib/itk/incr_tk.rb'
diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb
new file mode 100644
index 0000000000..f11d9d7913
--- /dev/null
+++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb
@@ -0,0 +1,383 @@
+#
+# tkextlib/itk/incr_tk.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/menuspec'
+require 'tkextlib/itcl.rb'
+
+# call setup script
+require 'tkextlib/itk.rb'
+
+#TkPackage.require('Itk', '3.2')
+TkPackage.require('Itk')
+
+module Tk
+ module Itk
+ include Tk
+ extend Tk
+
+ LIBRARY = TkVarAccess.new('::itk::library')
+
+ def self.package_version
+ begin
+ TkPackage.require('Itk')
+ rescue
+ ''
+ end
+ end
+
+ def self.usual(arg, *args)
+ tk_call('::itk::usual', arg, *args)
+ end
+
+ def self.usual_names
+ list(tk_call('::itk::usual'))
+ end
+
+ ############################
+
+ class Archetype < TkWindow
+ TkCommandNames = [].freeze
+ # WidgetClassName = 'Archetype'.freeze
+ # WidgetClassNames[WidgetClassName] = self
+
+ def self.to_eval
+ '::itk::' << self::WidgetClassName
+ end
+
+ def __destroy_hook__
+ Tk::Itk::Component::ComponentID_TBL.delete(self.path)
+ end
+
+ #### [incr Tk] public methods
+ def component
+ simplelist(tk_send('component'))
+ end
+
+ def component_path(name)
+ window(tk_send('component', name))
+ end
+ alias component_widget component_path
+
+ def component_invoke(name, cmd, *args)
+ window(tk_send('component', name, cmd, *args))
+ end
+
+ def component_obj(*names)
+ names = component if names.empty?
+ names.collect{|name| Tk::Itk::Component.new(self.path, name) }
+ end
+
+ #### [incr Tk] protected methods
+=begin
+ def itk_component_add(visibility, name, create_cmds, option_cmds=None)
+ args = []
+ visibility.each{|v| v = v.to_s; args << ( (v[0] == ?-)? v: "-#{v}" )}
+ args << '--' << name << create_cmd << option_cmds
+ tk_call('itk_component', 'add', *args)
+ end
+
+ def itk_component_delete(*names)
+ tk_call('itk_component', 'delete', *names)
+ end
+
+ def itk_initialize(keys={})
+ tk_call('itk_initialize', keys)
+ end
+
+ def itk_option_add(*args)
+ tk_call('itk_option', 'add', *args)
+ end
+
+ def itk_option_define(name, resource, klass, init, config=None)
+ tk_call('itk_option', 'define', name, resource, klass, init, config)
+ end
+
+ def itk_option_remove(*args)
+ tk_call('itk_option', 'remove', *args)
+ end
+=end
+ end
+
+ ############################
+
+ class Toplevel < Archetype
+ TkCommandNames = ['::itk::Toplevel'].freeze
+ WidgetClassName = 'Toplevel'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ include Wm
+ include TkMenuSpec
+ end
+
+ ############################
+
+ class Widget < Archetype
+ TkCommandNames = ['::itk::Widget'].freeze
+ WidgetClassName = 'Widget'.freeze
+ WidgetClassNames[WidgetClassName] = self
+ end
+
+
+ ############################
+
+ class Component < TkObject
+ def __cget_cmd
+ [self.master, 'component', self.name, 'cget']
+ end
+ private :__cget_cmd
+
+ def __config_cmd
+ [self.master, 'component', self.name, 'configure']
+ end
+ private :__config_cmd
+
+ ComponentID_TBL = TkCore::INTERP.create_table
+ Itk_Component_ID = ['itk:component'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ ComponentID_TBL.clear }
+
+ def self.id2obj(master, id)
+ if master.kind_of?(TkObject)
+ master = master.path
+ else
+ master = master.to_s
+ end
+ return id unless ComponentID_TBL.key?(master)
+ (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id
+ end
+
+ def self.new(master, component=nil)
+ if master.kind_of?(TkObject)
+ master = master.path
+ else
+ master = master.to_s
+ end
+
+ if component.kind_of?(Tk::Itk::Component)
+ component = component.name
+ elsif component
+ component = component.to_s
+ else
+ component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
+ Itk_Component_ID[1].succ!
+ end
+
+ if ComponentID_TBL.key?(master)
+ if ComponentID_TBL[master].key?(component)
+ return ComponentID_TBL[master][component]
+ end
+ else
+ ComponentID_TBL[master] = {}
+ end
+
+ super(master, component)
+ end
+
+ def initialize(master, component)
+ @master = master
+ @component = component
+
+ ComponentID_TBL[@master][@component] = self
+
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ @widget = nil
+ @path = nil
+ end
+ end
+
+ def path
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @path
+ end
+
+ def epath
+ path()
+ end
+
+ def to_eval
+ path()
+ end
+
+ def master
+ @master
+ end
+
+ def name
+ @component
+ end
+
+ def widget
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget
+ end
+
+ def widget_class
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ @widget.classname
+ rescue
+ nil
+ end
+ end
+ end
+
+ def method_missing(id, *args)
+ name = id.id2name
+
+ # try 1 : component command
+ begin
+ return tk_call(@master, 'component', @component, name, *args)
+ rescue
+ end
+
+ # try 2 : component configure
+ len = args.length
+ begin
+ case len
+ when 1
+ if name[-1] == ?=
+ return configure(name[0..-2], args[0])
+ else
+ return configure(name, args[0])
+ end
+ when 0
+ return cget(name)
+ end
+ rescue
+ end
+
+ # try 3 : widget method or widget configure
+ begin
+ unless @widget
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ end
+ @widget.__send__(id, *args)
+ rescue
+ end
+
+ # unknown method
+ fail RuntimeError, "unknown method '#{name}' for #{self.inspect}"
+ end
+
+ def tk_send(cmd, *rest)
+ begin
+ tk_call(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call(@path, cmd, *rest)
+ end
+ end
+
+ def tk_send_without_enc(cmd, *rest)
+ begin
+ tk_call_without_enc(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call_without_enc(@path, cmd, *rest)
+ end
+ end
+
+ def tk_send_with_enc(cmd, *rest)
+ begin
+ tk_call_with_enc(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call_with_enc(@path, cmd, *rest)
+ end
+ end
+
+ def bind(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bind(*args)
+ end
+
+ def bind_append(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bind_append(*args)
+ end
+
+ def bind_remove(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bind_remove(*args)
+ end
+
+ def bindinfo(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bindinfo(*args)
+ end
+
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/itk/setup.rb b/ext/tk/lib/tkextlib/itk/setup.rb
new file mode 100644
index 0000000000..e47b64adae
--- /dev/null
+++ b/ext/tk/lib/tkextlib/itk/setup.rb
@@ -0,0 +1,13 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
+
+
+# set [incr Tk] library directory
+
+# ENV['ITK_LIBRARY'] = '/usr/local/ActiveTcl/lib/itk3.2/'
diff --git a/ext/tk/lib/tkextlib/iwidgets.rb b/ext/tk/lib/tkextlib/iwidgets.rb
new file mode 100644
index 0000000000..5ef82f68ca
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets.rb
@@ -0,0 +1,89 @@
+#
+# [incr Widgets] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/itcl'
+require 'tkextlib/itk'
+
+# call setup script for general 'tkextlib' libraries
+#require 'tkextlib/setup.rb'
+
+# call setup script
+#require 'tkextlib/iwidgets/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('Iwidgets', '4.0')
+TkPackage.require('Iwidgets')
+
+module Tk
+ module Iwidgets
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ extend TkCore
+
+ def self.package_version
+ begin
+ TkPackage.require('Iwidgets')
+ rescue
+ ''
+ end
+ end
+
+ ####################################################
+
+ autoload :Buttonbox, 'tkextlib/iwidgets/buttonbox'
+ autoload :Calendar, 'tkextlib/iwidgets/calendar'
+ autoload :Canvasprintbox, 'tkextlib/iwidgets/canvasprintbox'
+ autoload :Canvasprintdialog, 'tkextlib/iwidgets/canvasprintdialog'
+ autoload :Checkbox, 'tkextlib/iwidgets/checkbox'
+ autoload :Combobox, 'tkextlib/iwidgets/combobox'
+ autoload :Dateentry, 'tkextlib/iwidgets/dateentry'
+ autoload :Datefield, 'tkextlib/iwidgets/datefield'
+ autoload :Dialog, 'tkextlib/iwidgets/dialog'
+ autoload :Dialogshell, 'tkextlib/iwidgets/dialogshell'
+ autoload :Disjointlistbox, 'tkextlib/iwidgets/disjointlistbox'
+ autoload :Entryfield, 'tkextlib/iwidgets/entryfield'
+ autoload :Extbutton, 'tkextlib/iwidgets/extbutton'
+ autoload :Extfileselectionbox, 'tkextlib/iwidgets/extfileselectionbox'
+ autoload :Extfileselectiondialog,'tkextlib/iwidgets/extfileselectiondialog'
+ autoload :Feedback, 'tkextlib/iwidgets/feedback'
+ autoload :Fileselectionbox, 'tkextlib/iwidgets/fileselectionbox'
+ autoload :Fileselectiondialog, 'tkextlib/iwidgets/fileselectiondialog'
+ autoload :Finddialog, 'tkextlib/iwidgets/finddialog'
+ autoload :Hierarchy, 'tkextlib/iwidgets/hierarchy'
+ autoload :Hyperhelp, 'tkextlib/iwidgets/hyperhelp'
+ autoload :Labeledframe, 'tkextlib/iwidgets/labeledframe'
+ autoload :Labeledwidget, 'tkextlib/iwidgets/labeledwidget'
+ autoload :Mainwindow, 'tkextlib/iwidgets/mainwindow'
+ autoload :Menubar, 'tkextlib/iwidgets/menubar'
+ autoload :Messagebox, 'tkextlib/iwidgets/messagebox'
+ autoload :Messagedialog, 'tkextlib/iwidgets/messagedialog'
+ autoload :Notebook, 'tkextlib/iwidgets/notebook'
+ autoload :Optionmenu, 'tkextlib/iwidgets/optionmenu'
+ autoload :Panedwindow, 'tkextlib/iwidgets/panedwindow'
+ autoload :Pushbutton, 'tkextlib/iwidgets/pushbutton'
+ autoload :Promptdialog, 'tkextlib/iwidgets/promptdialog'
+ autoload :Radiobox, 'tkextlib/iwidgets/radiobox'
+ autoload :Scrolledcanvas, 'tkextlib/iwidgets/scrolledcanvas'
+ autoload :Scrolledframe, 'tkextlib/iwidgets/scrolledframe'
+ autoload :Scrolledhtml, 'tkextlib/iwidgets/scrolledhtml'
+ autoload :Scrolledlistbox, 'tkextlib/iwidgets/scrolledlistbox'
+ autoload :Scrolledtext, 'tkextlib/iwidgets/scrolledtext'
+ autoload :Scrolledwidget, 'tkextlib/iwidgets/scrolledwidget'
+ autoload :Selectionbox, 'tkextlib/iwidgets/selectionbox'
+ autoload :Selectiondialog, 'tkextlib/iwidgets/selectiondialog'
+ autoload :Shell, 'tkextlib/iwidgets/shell'
+ autoload :Spindate, 'tkextlib/iwidgets/spindate'
+ autoload :Spinint, 'tkextlib/iwidgets/spinint'
+ autoload :Spinner, 'tkextlib/iwidgets/spinner'
+ autoload :Spintime, 'tkextlib/iwidgets/spintime'
+ autoload :Tabnotebook, 'tkextlib/iwidgets/tabnotebook'
+ autoload :Tabset, 'tkextlib/iwidgets/tabset'
+ autoload :Timeentry, 'tkextlib/iwidgets/timeentry'
+ autoload :Timefield, 'tkextlib/iwidgets/timefield'
+ autoload :Toolbar, 'tkextlib/iwidgets/toolbar'
+ autoload :Watch, 'tkextlib/iwidgets/watch'
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
new file mode 100644
index 0000000000..1ff190b9ff
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
@@ -0,0 +1,114 @@
+#
+# tkextlib/iwidgets/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Buttonbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Buttonbox
+ TkCommandNames = ['::iwidgets::buttonbox'.freeze].freeze
+ WidgetClassName = 'Buttonbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget itemcget
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def default(idx)
+ tk_call(@path, 'default', index(idx))
+ self
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ext/tk/lib/tkextlib/iwidgets/calendar.rb
new file mode 100644
index 0000000000..f382cfd143
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/calendar.rb
@@ -0,0 +1,88 @@
+#
+# tkextlib/iwidgets/calendar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Calendar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Calendar
+ TkCommandNames = ['::iwidgets::calendar'.freeze].freeze
+ WidgetClassName = 'Calendar'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class CalendarCommand < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [ [?d, ?s, :date], nil ]
+ PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['command']
+ end
+
+ #def initialize(cmd = Proc.new, *args)
+ # _initialize_for_cb_class(CalCmdArgs, cmd, *args)
+ #end
+ end
+
+ def __validation_class_list
+ super << CalendarCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, CalendarCommand)
+=begin
+ def command(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(CalendarCommand)
+ configure('command', cmd)
+ elsif args
+ configure('command', [cmd, args])
+ else
+ configure('command', cmd)
+ end
+ end
+=end
+
+ ####################################
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def select(date)
+ tk_call(@path, 'select', date)
+ self
+ end
+
+ def show(date)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb b/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
new file mode 100644
index 0000000000..1e2a476591
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/iwidgets/canvasprintbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Canvasprintbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Canvasprintbox
+ TkCommandNames = ['::iwidgets::canvasprintbox'.freeze].freeze
+ WidgetClassName = 'Canvasprintbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_output
+ tk_call(@path, 'getoutput')
+ end
+
+ def print
+ bool(tk_call(@path, 'print'))
+ end
+
+ def refresh
+ tk_call(@path, 'refresh')
+ self
+ end
+
+ def set_canvas(win)
+ tk_call(@path, 'setcanvas', win)
+ self
+ end
+
+ def stop
+ tk_call(@path, 'stop')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb b/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
new file mode 100644
index 0000000000..bbf507677c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/canvasprintdialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Canvasprintdialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Canvasprintdialog
+ TkCommandNames = ['::iwidgets::canvasprintdialog'.freeze].freeze
+ WidgetClassName = 'Canvasprintdialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_output
+ tk_call(@path, 'getoutput')
+ end
+
+ def print
+ bool(tk_call(@path, 'print'))
+ end
+
+ def refresh
+ tk_call(@path, 'refresh')
+ self
+ end
+
+ def set_canvas(win)
+ tk_call(@path, 'setcanvas', win)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
new file mode 100644
index 0000000000..05d0e1d813
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
@@ -0,0 +1,111 @@
+#
+# tkextlib/iwidgets/checkbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Checkbox < Tk::Iwidgets::Labeledframe
+ end
+ end
+end
+
+class Tk::Iwidgets::Checkbox
+ TkCommandNames = ['::iwidgets::checkbox'.freeze].freeze
+ WidgetClassName = 'Checkbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget itemcget
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def deselect(idx)
+ tk_call(@path, 'deselect', index(idx))
+ self
+ end
+
+ def flash(idx)
+ tk_call(@path, 'flash', index(idx))
+ self
+ end
+
+ def get(idx)
+ simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
+ Tk::Itk::Component.id2obj(id)
+ }
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/combobox.rb b/ext/tk/lib/tkextlib/iwidgets/combobox.rb
new file mode 100644
index 0000000000..1cf10b4004
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/combobox.rb
@@ -0,0 +1,99 @@
+#
+# tkextlib/iwidgets/combobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Combobox < Tk::Iwidgets::Entryfield
+ end
+ end
+end
+
+class Tk::Iwidgets::Combobox
+ TkCommandNames = ['::iwidgets::combobox'.freeze].freeze
+ WidgetClassName = 'Combobox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def clear(component=None)
+ tk_call(@path, 'clear', component)
+ self
+ end
+
+ def delete_list(first, last=None)
+ tk_call(@path, 'delete', 'list', first, last)
+ self
+ end
+
+ def delete_entry(first, last=None)
+ tk_call(@path, 'delete', 'entry', first, last)
+ self
+ end
+
+ def get_list_contents(index)
+ tk_call(@path, 'get', index)
+ end
+
+ def insert_list(idx, *elems)
+ tk_call(@path, 'insert', 'list', idx, *elems)
+ self
+ end
+
+ def insert_entry(idx, *elems)
+ tk_call(@path, 'insert', 'entry', idx, *elems)
+ self
+ end
+
+ # listbox methods
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ # scrolledlistbox methods
+ def get_curselection
+ tk_call(@path, 'getcurselection')
+ end
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/dateentry.rb b/ext/tk/lib/tkextlib/iwidgets/dateentry.rb
new file mode 100644
index 0000000000..0a8897f50d
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/dateentry.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/dateentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dateentry < Tk::Iwidgets::Datefield
+ end
+ end
+end
+
+class Tk::Iwidgets::Dateentry
+ TkCommandNames = ['::iwidgets::dateentry'.freeze].freeze
+ WidgetClassName = 'Dateentry'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/datefield.rb b/ext/tk/lib/tkextlib/iwidgets/datefield.rb
new file mode 100644
index 0000000000..924aef9c4d
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/datefield.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/iwidgets/datefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Datefield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Datefield
+ TkCommandNames = ['::iwidgets::datefield'.freeze].freeze
+ WidgetClassName = 'Datefield'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def valid?
+ bool(tk_call(@path, 'isvalid'))
+ end
+ alias isvalid? valid?
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/dialog.rb b/ext/tk/lib/tkextlib/iwidgets/dialog.rb
new file mode 100644
index 0000000000..8540eae1b5
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/dialog.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dialog < Tk::Iwidgets::Dialogshell
+ end
+ end
+end
+
+class Tk::Iwidgets::Dialog
+ TkCommandNames = ['::iwidgets::dialog'.freeze].freeze
+ WidgetClassName = 'Dialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
new file mode 100644
index 0000000000..88b9a97094
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
@@ -0,0 +1,114 @@
+#
+# tkextlib/iwidgets/dialogshell.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dialogshell < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Dialogshell
+ TkCommandNames = ['::iwidgets::dialogshell'.freeze].freeze
+ WidgetClassName = 'Dialogshell'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget itemcget
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def default(idx)
+ tk_call(@path, 'default', index(idx))
+ self
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb b/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
new file mode 100644
index 0000000000..8418467925
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
@@ -0,0 +1,45 @@
+#
+# tkextlib/iwidgets/disjointlistbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Disjointlistbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Disjointlistbox
+ TkCommandNames = ['::iwidgets::disjointlistbox'.freeze].freeze
+ WidgetClassName = 'Disjointlistbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def set_lhs(*items)
+ tk_call(@path, 'setlhs', items)
+ self
+ end
+ def set_rhs(*items)
+ tk_call(@path, 'setrhs', items)
+ self
+ end
+
+ def get_lhs
+ simplelist(tk_call(@path, 'getlhs'))
+ end
+ def get_rhs
+ simplelist(tk_call(@path, 'getrhs'))
+ end
+
+ def insert_lhs(*items)
+ tk_call(@path, 'insertlhs', items)
+ self
+ end
+ def insert_rhs(*items)
+ tk_call(@path, 'insertrhs', items)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
new file mode 100644
index 0000000000..ae7d63f3f3
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
@@ -0,0 +1,161 @@
+#
+# tkextlib/iwidgets/entryfield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Entryfield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Entryfield
+ TkCommandNames = ['::iwidgets::entryfield'.freeze].freeze
+ WidgetClassName = 'Entryfield'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class EntryfieldValidate < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?s, :char ],
+ [ ?P, ?s, :post ],
+ [ ?S, ?s, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['validate', 'invalid']
+ end
+ end
+
+ def __validation_class_list
+ super << EntryfieldValidate
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
+=begin
+ def validate(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('validate', cmd)
+ elsif args
+ configure('validate', [cmd, args])
+ else
+ configure('validate', cmd)
+ end
+ end
+
+ def invalid(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('invalid', cmd)
+ elsif args
+ configure('invalid', [cmd, args])
+ else
+ configure('invalid', cmd)
+ end
+ end
+=end
+
+ ####################################
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(index)
+ number(tk_send_without_enc('index', index))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/extbutton.rb b/ext/tk/lib/tkextlib/iwidgets/extbutton.rb
new file mode 100644
index 0000000000..7b1e35aa2d
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/extbutton.rb
@@ -0,0 +1,30 @@
+#
+# tkextlib/iwidgets/extbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extbutton < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Extbutton
+ TkCommandNames = ['::iwidgets::extbutton'.freeze].freeze
+ WidgetClassName = 'Extbutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def invoke
+ tk_call(@path, 'invoke')
+ self
+ end
+
+ def flash
+ tk_call(@path, 'flash')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
new file mode 100644
index 0000000000..282647893c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/extfileselectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extfileselectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Extfileselectionbox
+ TkCommandNames = ['::iwidgets::extfileselectionbox'.freeze].freeze
+ WidgetClassName = 'Extfileselectionbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
new file mode 100644
index 0000000000..14388be7c4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/extfileselectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extfileselectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Extfileselectiondialog
+ TkCommandNames = ['::iwidgets::extfileselectiondialog'.freeze].freeze
+ WidgetClassName = 'Extfileselectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/feedback.rb b/ext/tk/lib/tkextlib/iwidgets/feedback.rb
new file mode 100644
index 0000000000..d7439d818a
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/feedback.rb
@@ -0,0 +1,30 @@
+#
+# tkextlib/iwidgets/feedback.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Feedback < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Feedback
+ TkCommandNames = ['::iwidgets::feedback'.freeze].freeze
+ WidgetClassName = 'Feedback'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def reset
+ tk_call(@path, 'reset')
+ self
+ end
+
+ def step(inc=1)
+ tk_call(@path, 'step', inc)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
new file mode 100644
index 0000000000..46de13d1b2
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/fileselectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Fileselectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Fileselectionbox
+ TkCommandNames = ['::iwidgets::fileselectionbox'.freeze].freeze
+ WidgetClassName = 'Fileselectionbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
new file mode 100644
index 0000000000..50f459e56d
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/fileselectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Fileselectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Fileselectiondialog
+ TkCommandNames = ['::iwidgets::fileselectiondialog'.freeze].freeze
+ WidgetClassName = 'Fileselectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/finddialog.rb b/ext/tk/lib/tkextlib/iwidgets/finddialog.rb
new file mode 100644
index 0000000000..a161c3c2a4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/finddialog.rb
@@ -0,0 +1,29 @@
+#
+# tkextlib/iwidgets/finddialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Finddialog < Tk::Iwidgets::Dialogshell
+ end
+ end
+end
+
+class Tk::Iwidgets::Finddialog
+ TkCommandNames = ['::iwidgets::finddialog'.freeze].freeze
+ WidgetClassName = 'Finddialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def find
+ tk_call(@path, 'find')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
new file mode 100644
index 0000000000..077d84c7a4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
@@ -0,0 +1,294 @@
+#
+# tkextlib/iwidgets/hierarchy.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Hierarchy < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Hierarchy
+ ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze
+ include TkTextTagConfig
+
+ TkCommandNames = ['::iwidgets::hierarchy'.freeze].freeze
+ WidgetClassName = 'Hierarchy'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class QueryCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [ [?n, ?s, :node], nil ]
+ PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['querycommand']
+ end
+ end
+
+ class IndicatorCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?n, ?s, :node ],
+ [ ?s, ?b, :status ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?b, TkComm.method(:bool) ],
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['iconcommand', 'icondblcommand', 'imagedblcommand']
+ end
+ end
+
+ class IconCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?n, ?s, :node ],
+ [ ?i, ?s, :icon ],
+ nil
+ ]
+ PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ]
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['dblclickcommand', 'imagecommand', 'selectcommand']
+ end
+ end
+
+ def __validation_class_list
+ super << QueryCommand << IndicatorCommand << IconCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, QueryCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, IndicatorCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, IconCommand)
+
+ ####################################
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def collapse(node)
+ tk_call(@path, 'collapse')
+ self
+ end
+
+ def current
+ tk_call(@path, 'current')
+ end
+
+ def draw(mode=None)
+ case mode
+ when None
+ # do nothing
+ when 'now', :now
+ mode = '-now'
+ when 'eventually', :eventually
+ mode = '-eventually'
+ when String, Symbol
+ mode = mode.to_s
+ mode = '-' << mode if mode[0] != ?-
+ end
+ tk_call(@path, 'draw', mode)
+ end
+
+ def expand(node)
+ tk_call(@path, 'expand', node)
+ self
+ end
+
+ def expanded?(node)
+ bool(tk_call(@path, 'expanded', node))
+ end
+
+ def exp_state
+ list(tk_call(@path, 'expState'))
+ end
+ alias expand_state exp_state
+ alias expanded_list exp_state
+
+ def mark_clear
+ tk_call(@path, 'mark', 'clear')
+ self
+ end
+ def mark_add(*nodes)
+ tk_call(@path, 'mark', 'add', *nodes)
+ self
+ end
+ def mark_remove(*nodes)
+ tk_call(@path, 'mark', 'remove', *nodes)
+ self
+ end
+ def mark_get
+ list(tk_call(@path, 'mark', 'get'))
+ end
+
+ def refresh(node)
+ tk_call(@path, 'refresh', node)
+ self
+ end
+
+ def prune(node)
+ tk_call(@path, 'prune', node)
+ self
+ end
+
+ def selection_clear
+ tk_call(@path, 'selection', 'clear')
+ self
+ end
+ def selection_add(*nodes)
+ tk_call(@path, 'selection', 'add', *nodes)
+ self
+ end
+ def selection_remove(*nodes)
+ tk_call(@path, 'selection', 'remove', *nodes)
+ self
+ end
+ def selection_get
+ list(tk_call(@path, 'selection', 'get'))
+ end
+
+ def toggle(node)
+ tk_call(@path, 'toggle', node)
+ self
+ end
+
+ # based on TkText widget
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', _get_eval_enc_str(index)))
+ end
+
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+
+ def index(index)
+ tk_send_without_enc('index', _get_eval_enc_str(index))
+ end
+
+ def insert(index, chars, *tags)
+ if tags[0].kind_of? Array
+ # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ...
+ args = [chars]
+ while tags.size > 0
+ args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist
+ args << tags.shift if tags.size > 0 # chars
+ end
+ super index, *args
+ else
+ # single chars-taglist argument :: str, tag, tag, ...
+ if tags.size == 0
+ super index, chars
+ else
+ super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')
+ end
+ end
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb b/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
new file mode 100644
index 0000000000..22e86339a6
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
@@ -0,0 +1,40 @@
+#
+# tkextlib/iwidgets/hyperhelp.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Hyperhelp < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Hyperhelp
+ TkCommandNames = ['::iwidgets::hyperhelp'.freeze].freeze
+ WidgetClassName = 'Hyperhelp'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def show_topic(topic)
+ tk_call(@path, 'showtopic', topic)
+ self
+ end
+
+ def follow_link(href)
+ tk_call(@path, 'followlink', href)
+ self
+ end
+
+ def forward
+ tk_call(@path, 'forward')
+ self
+ end
+
+ def back
+ tk_call(@path, 'back')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb b/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
new file mode 100644
index 0000000000..89669ea815
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
@@ -0,0 +1,24 @@
+#
+# tkextlib/iwidgets/labeledframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Labeledframe < Tk::Itk::Archetype
+ end
+ end
+end
+
+class Tk::Iwidgets::Labeledframe
+ TkCommandNames = ['::iwidgets::labeledframe'.freeze].freeze
+ WidgetClassName = 'Labeledframe'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb b/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
new file mode 100644
index 0000000000..f847922386
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
@@ -0,0 +1,30 @@
+#
+# tkextlib/iwidgets/labeledwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Labeledwidget < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Labeledwidget
+ extend TkCore
+
+ TkCommandNames = ['::iwidgets::labeledwidget'.freeze].freeze
+ WidgetClassName = 'Labeledwidget'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def self.alignlabels(*wins)
+ tk_call('::iwidgets::Labeledwidget::alignlabels', *wins)
+ end
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb b/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
new file mode 100644
index 0000000000..4570afc6d0
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
@@ -0,0 +1,52 @@
+#
+# tkextlib/iwidgets/mainwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Mainwindow < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Mainwindow
+ TkCommandNames = ['::iwidgets::mainwindow'.freeze].freeze
+ WidgetClassName = 'Mainwindow'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def menubar(*args)
+ unless args.empty?
+ tk_call(@path, 'menubar', *args)
+ end
+ window(tk_call(@path, 'menubar'))
+ end
+
+ def mousebar(*args)
+ unless args.empty?
+ tk_call(@path, 'mousebar', *args)
+ end
+ window(tk_call(@path, 'mousebar'))
+ end
+
+ def msgd(*args)
+ unless args.empty?
+ tk_call(@path, 'msgd', *args)
+ end
+ window(tk_call(@path, 'msgd'))
+ end
+
+ def toolbar(*args)
+ unless args.empty?
+ tk_call(@path, 'toolbar', *args)
+ end
+ window(tk_call(@path, 'toolbar'))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/ext/tk/lib/tkextlib/iwidgets/menubar.rb
new file mode 100644
index 0000000000..b60349be17
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/menubar.rb
@@ -0,0 +1,190 @@
+#
+# tkextlib/iwidgets/menubar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Menubar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Menubar
+ TkCommandNames = ['::iwidgets::menubar'.freeze].freeze
+ WidgetClassName = 'Menubar'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'menucget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'menuconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias menucget itemcget
+ alias menuconfigure itemconfigure
+ alias menuconfiginfo itemconfiginfo
+ alias current_menuconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __methodcall_optkeys
+ {'menubuttons'=>'menubuttons'}
+ end
+
+ def menubuttons(val = nil)
+ unless val
+ return tk_call(@path, 'cget', '-menubuttons')
+ end
+
+ tk_call(@path, 'configure', '-menubuttons', _parse_menu_spec(val))
+ self
+ end
+
+ def _parse_menu_spec(menu_spec)
+ ret = ''
+ menu_spec.each{|spec|
+ next unless spec
+
+ if spec.kind_of?(Hash)
+ args = [spec]
+ type = 'options'
+ else
+ type, *args = spec
+ end
+
+ type = type.to_s
+ case type
+ when 'options'
+ keys = args[0]
+ ary = [type]
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+
+ when 'menubutton', 'cascade'
+ name, keys = args
+ if keys
+ ary = [type, name]
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+ else
+ ret << array2tk_list([type, name]) << "\n"
+ end
+
+ else
+ name, keys = args
+ if keys
+ ary = [type, name]
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+ else
+ ret << array2tk_list([type, name]) << "\n"
+ end
+ end
+ }
+ ret
+ end
+
+ ####################################
+
+ def add(type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(path1, path2=nil)
+ if path2
+ else
+ tk_call(@path, 'delete', index(idx))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ tk_call(@path, 'insert', index(idx), type, tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx)
+ tk_call(@path, 'invoke', index(idx))
+ self
+ end
+
+ def menupath(pat)
+ if (win = tk_call(@path, 'path', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+ def menupath_glob(pat)
+ if (win = tk_call(@path, 'path', '-glob', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+ def menupath_tclregexp(pat)
+ if (win = tk_call(@path, 'path', '-regexp', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+
+ def type(path)
+ tk_call(@path, 'type', path)
+ end
+
+ def yposition(path)
+ number(tk_call(@path, 'yposition', path))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
new file mode 100644
index 0000000000..608f6f7adb
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
@@ -0,0 +1,81 @@
+#
+# tkextlib/iwidgets/messagebox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Messagebox < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Messagebox
+ TkCommandNames = ['::iwidgets::messagebox'.freeze].freeze
+ WidgetClassName = 'Messagebox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'type', 'cget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'type', 'configure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias typecget itemcget
+ alias typeconfigure itemconfigure
+ alias typeconfiginfo itemconfiginfo
+ alias current_typeconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def type_add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ unless tag
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'type', 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def export(file)
+ tk_call(@path, 'export', file)
+ self
+ end
+
+ def issue(string, type=None, *args)
+ tk_call(@path, 'issue', string, tagid(type), *args)
+ self
+ end
+
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb b/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
new file mode 100644
index 0000000000..c19b83e517
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/messagedialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Messagedialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Messagedialog
+ TkCommandNames = ['::iwidgets::messagedialog'.freeze].freeze
+ WidgetClassName = 'Messagedialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
new file mode 100644
index 0000000000..d9abf1b02b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
@@ -0,0 +1,163 @@
+#
+# tkextlib/iwidgets/notebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Notebook < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Notebook
+ TkCommandNames = ['::iwidgets::notebook'.freeze].freeze
+ WidgetClassName = 'Notebook'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tabcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tabconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias pagecget itemcget
+ alias pageconfigure itemconfigure
+ alias pageconfiginfo itemconfiginfo
+ alias current_pageconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ window(tk_call(@path, 'childsite', new_idx))
+ end
+
+ def delete(idx1, idx2=nil)
+ if (new_idx1 = self.index(idx1)) < 0
+ new_idx1 = tagid(idx1)
+ end
+ if idx2
+ if (new_idx2 = self.index(idx2)) < 0
+ new_idx2 = tagid(idx2)
+ end
+ tk_call(@path, 'delete', new_idx1, new_idx2)
+ else
+ tk_call(@path, 'delete', new_idx1)
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, keys={})
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ window(tk_call(@path, 'insert', new_idx, *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ tk_call(@path, 'select', new_idx)
+ self
+ end
+
+ def scrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias xscrollcommand scrollcommand
+ alias yscrollcommand scrollcommand
+
+ def xscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'horizontal'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ def yscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'vertical'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ alias scrollbar yscrollbar
+
+ def view(*index)
+ if index.size == 0
+ window(tk_send_without_enc('view'))
+ else
+ tk_send_without_enc('view', *index)
+ self
+ end
+ end
+ alias xview view
+ alias yview view
+
+ def view_moveto(*index)
+ view('moveto', *index)
+ end
+ alias xview_moveto view_moveto
+ alias yview_moveto view_moveto
+ def view_scroll(*index)
+ view('scroll', *index)
+ end
+ alias xview_scroll view_scroll
+ alias yview_scroll view_scroll
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb b/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
new file mode 100644
index 0000000000..226163a150
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
@@ -0,0 +1,87 @@
+#
+# tkextlib/iwidgets/optionmenu.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Optionmenu < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Optionmenu
+ TkCommandNames = ['::iwidgets::optionmenu'.freeze].freeze
+ WidgetClassName = 'Optionmenu'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def delete(first, last=nil)
+ if last
+ tk_call(@path, 'delete', first, last)
+ else
+ tk_call(@path, 'delete', first)
+ end
+ self
+ end
+
+ def disable(idx)
+ tk_call(@path, 'disable', idx)
+ self
+ end
+
+ def enable(idx)
+ tk_call(@path, 'enable', idx)
+ self
+ end
+
+ def get(first=nil, last=nil)
+ if last
+ simplelist(tk_call(@path, 'get', first, last))
+ elsif first
+ tk_call(@path, 'get', first)
+ else
+ tk_call(@path, 'get')
+ end
+ end
+ def get_range(first, last)
+ get(first, last)
+ end
+ def get_selected
+ get()
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', idx))
+ end
+
+ def insert(idx, *args)
+ tk_call(@path, 'insert', idx, *args)
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', idx)
+ self
+ end
+
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb b/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
new file mode 100644
index 0000000000..a205036239
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
@@ -0,0 +1,127 @@
+#
+# tkextlib/iwidgets/panedwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Panedwindow < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Panedwindow
+ TkCommandNames = ['::iwidgets::panedwindow'.freeze].freeze
+ WidgetClassName = 'Panedwindow'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'panecget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'paneconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias panecget itemcget
+ alias paneconfigure itemconfigure
+ alias paneconfiginfo itemconfiginfo
+ alias current_paneconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'add', tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ window(tk_call(@path, 'childsite', index(idx)))
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def fraction(*percentages)
+ tk_call(@path, 'fraction', *percentages)
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def reset
+ tk_call(@path, 'reset')
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb b/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
new file mode 100644
index 0000000000..ec18647511
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
@@ -0,0 +1,131 @@
+#
+# tkextlib/iwidgets/promptdialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Promptdialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Promptdialog
+ TkCommandNames = ['::iwidgets::promptdialog'.freeze].freeze
+ WidgetClassName = 'Promptdialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ # index method is not available, because it shows index of the entry field
+ def default(name)
+ tk_call(@path, 'default', tagid(name))
+ self
+ end
+
+ def hide(name)
+ tk_call(@path, 'hide', tagid(name))
+ self
+ end
+
+ def invoke(name=nil)
+ if name
+ tk_call(@path, 'invoke', tagid(name))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(name)
+ tk_call(@path, 'show', tagid(name))
+ self
+ end
+
+
+ # based on Tk::Iwidgets::Entryfield
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(index)
+ number(tk_send_without_enc('index', index))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb b/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
new file mode 100644
index 0000000000..25d3633507
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
@@ -0,0 +1,30 @@
+#
+# tkextlib/iwidgets/pushbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Pushbutton < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Pushbutton
+ TkCommandNames = ['::iwidgets::pushbutton'.freeze].freeze
+ WidgetClassName = 'Pushbutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def invoke
+ tk_call_without_enc(@path, 'invoke')
+ self
+ end
+
+ def flash
+ tk_call_without_enc(@path, 'flash')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
new file mode 100644
index 0000000000..84c15082d6
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
@@ -0,0 +1,111 @@
+#
+# tkextlib/iwidgets/radiobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Radiobox < Tk::Iwidgets::Labeledframe
+ end
+ end
+end
+
+class Tk::Iwidgets::Radiobox
+ TkCommandNames = ['::iwidgets::radiobox'.freeze].freeze
+ WidgetClassName = 'Radiobox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget itemcget
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def deselect(idx)
+ tk_call(@path, 'deselect', index(idx))
+ self
+ end
+
+ def flash(idx)
+ tk_call(@path, 'flash', index(idx))
+ self
+ end
+
+ def get(idx)
+ simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
+ Tk::Itk::Component.id2obj(id)
+ }
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb b/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
new file mode 100644
index 0000000000..bddef50841
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
@@ -0,0 +1,24 @@
+#
+# tkextlib/iwidgets/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scopedobject < TkObject
+ end
+ end
+end
+
+class Tk::Iwidgets::Scopedobject
+ TkCommandNames = ['::iwidgets::scopedobject'.freeze].freeze
+ WidgetClassName = 'Scopedobject'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def initialize(obj_name, keys={})
+ @path = tk_call(self.class::TkCommandNames[0], obj_name, *hash_kv(keys))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
new file mode 100644
index 0000000000..c26eda1586
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
@@ -0,0 +1,315 @@
+#
+# tkextlib/iwidgets/scrolledcanvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledcanvas < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledcanvas
+ TkCommandNames = ['::iwidgets::scrolledcanvas'.freeze].freeze
+ WidgetClassName = 'Scrolledcanvas'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ################################
+
+ def initialize(*args)
+ super(*args)
+ @canvas = component_widget('canvas')
+ end
+
+ def method_missing(id, *args)
+ if @canvas.methods.include?(id.id2name)
+ @canvas.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ ##########################
+ include TkCanvasItemConfig
+
+ def tagid(tag)
+ if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
+ tag.id
+ elsif tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ tag # maybe an Array of configure paramters
+ end
+ end
+ private :tagid
+
+ # create a canvas item without creating a TkcItem object
+ def create(type, *args)
+ type.create(self, *args)
+ end
+
+ #######################
+
+ def addtag(tag, mode, *args)
+ tk_send_without_enc('addtag', tagid(tag), mode, *args)
+ self
+ end
+ def addtag_above(tagOrId, target)
+ addtag(tagOrId, 'above', tagid(target))
+ end
+ def addtag_all(tagOrId)
+ addtag(tagOrId, 'all')
+ end
+ def addtag_below(tagOrId, target)
+ addtag(tagOrId, 'below', tagid(target))
+ end
+ def addtag_closest(tagOrId, x, y, halo=None, start=None)
+ addtag(tagOrId, 'closest', x, y, halo, start)
+ end
+ def addtag_enclosed(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
+ end
+ def addtag_overlapping(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
+ end
+ def addtag_withtag(tagOrId, tag)
+ addtag(tagOrId, 'withtag', tagid(tag))
+ end
+
+ def bbox(tagOrId, *tags)
+ list(tk_send_without_enc('bbox', tagid(tagOrId),
+ *tags.collect{|t| tagid(t)}))
+ end
+
+ def itembind(tag, context, cmd=Proc.new, args=nil)
+ _bind([path, "bind", tagid(tag)], context, cmd, args)
+ self
+ end
+
+ def itembind_append(tag, context, cmd=Proc.new, args=nil)
+ _bind_append([path, "bind", tagid(tag)], context, cmd, args)
+ self
+ end
+
+ def itembind_remove(tag, context)
+ _bind_remove([path, "bind", tagid(tag)], context)
+ self
+ end
+
+ def itembindinfo(tag, context=nil)
+ _bindinfo([path, "bind", tagid(tag)], context)
+ end
+
+ def canvasx(screen_x, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args))
+ number(tk_send_without_enc('canvasx', screen_x, *args))
+ end
+ def canvasy(screen_y, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
+ number(tk_send_without_enc('canvasy', screen_y, *args))
+ end
+
+ def coords(tag, *args)
+ if args == []
+ tk_split_list(tk_send_without_enc('coords', tagid(tag)))
+ else
+ tk_send_without_enc('coords', tagid(tag), *(args.flatten))
+ self
+ end
+ end
+
+ def dchars(tag, first, last=None)
+ tk_send_without_enc('dchars', tagid(tag),
+ _get_eval_enc_str(first), _get_eval_enc_str(last))
+ self
+ end
+
+ def delete(*args)
+ if TkcItem::CItemID_TBL[self.path]
+ find('withtag', *args).each{|item|
+ TkcItem::CItemID_TBL[self.path].delete(item.id)
+ }
+ end
+ tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
+ self
+ end
+ alias remove delete
+
+ def dtag(tag, tag_to_del=None)
+ tk_send_without_enc('dtag', tagid(tag), tag_to_del)
+ self
+ end
+
+ def find(mode, *args)
+ list(tk_send_without_enc('find', mode, *args)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+ def find_above(target)
+ find('above', tagid(target))
+ end
+ def find_all
+ find('all')
+ end
+ def find_below(target)
+ find('below', tagid(target))
+ end
+ def find_closest(x, y, halo=None, start=None)
+ find('closest', x, y, halo, start)
+ end
+ def find_enclosed(x1, y1, x2, y2)
+ find('enclosed', x1, y1, x2, y2)
+ end
+ def find_overlapping(x1, y1, x2, y2)
+ find('overlapping', x1, y1, x2, y2)
+ end
+ def find_withtag(tag)
+ find('withtag', tag)
+ end
+
+ def itemfocus(tagOrId=nil)
+ if tagOrId
+ tk_send_without_enc('focus', tagid(tagOrId))
+ self
+ else
+ ret = tk_send_without_enc('focus')
+ if ret == ""
+ nil
+ else
+ TkcItem.id2obj(self, ret)
+ end
+ end
+ end
+
+ def gettags(tagOrId)
+ list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag|
+ TkcTag.id2obj(self, tag)
+ }
+ end
+
+ def icursor(tagOrId, index)
+ tk_send_without_enc('icursor', tagid(tagOrId), index)
+ self
+ end
+
+ def index(tagOrId, index)
+ number(tk_send_without_enc('index', tagid(tagOrId), index))
+ end
+
+ def insert(tagOrId, index, string)
+ tk_send_without_enc('insert', tagid(tagOrId), index,
+ _get_eval_enc_str(string))
+ self
+ end
+
+ def lower(tag, below=nil)
+ if below
+ tk_send_without_enc('lower', tagid(tag), tagid(below))
+ else
+ tk_send_without_enc('lower', tagid(tag))
+ end
+ self
+ end
+
+ def move(tag, x, y)
+ tk_send_without_enc('move', tagid(tag), x, y)
+ self
+ end
+
+ def postscript(keys)
+ tk_send("postscript", *hash_kv(keys))
+ end
+
+ def raise(tag, above=nil)
+ if above
+ tk_send_without_enc('raise', tagid(tag), tagid(above))
+ else
+ tk_send_without_enc('raise', tagid(tag))
+ end
+ self
+ end
+
+ def scale(tag, x, y, xs, ys)
+ tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def select(mode, *args)
+ r = tk_send_without_enc('select', mode, *args)
+ (mode == 'item')? TkcItem.id2obj(self, r): self
+ end
+ def select_adjust(tagOrId, index)
+ select('adjust', tagid(tagOrId), index)
+ end
+ def select_clear
+ select('clear')
+ end
+ def select_from(tagOrId, index)
+ select('from', tagid(tagOrId), index)
+ end
+ def select_item
+ select('item')
+ end
+ def select_to(tagOrId, index)
+ select('to', tagid(tagOrId), index)
+ end
+
+ def itemtype(tag)
+ TkcItem.type2class(tk_send('type', tagid(tag)))
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
new file mode 100644
index 0000000000..8b47460357
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
@@ -0,0 +1,59 @@
+#
+# tkextlib/iwidgets/scrolledframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledframe < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledframe
+ TkCommandNames = ['::iwidgets::scrolledframe'.freeze].freeze
+ WidgetClassName = 'Scrolledframe'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
new file mode 100644
index 0000000000..7023d889d1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/iwidgets/scrolledhtml.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledhtml < Tk::Iwidgets::Scrolledtext
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledhtml
+ TkCommandNames = ['::iwidgets::scrolledhtml'.freeze].freeze
+ WidgetClassName = 'Scrolledhtml'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def import(href)
+ tk_call(@path, 'import', href)
+ self
+ end
+
+ def import_link(href)
+ tk_call(@path, 'import', '-link', href)
+ self
+ end
+
+ def pwd
+ tk_call(@path, 'pwd')
+ end
+
+ def render(htmltext, workdir=None)
+ tk_call(@path, 'render', htmltext, workdir)
+ self
+ end
+
+ def title
+ tk_call(@path, 'title')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
new file mode 100644
index 0000000000..9fe23b4edc
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
@@ -0,0 +1,190 @@
+#
+# tkextlib/iwidgets/scrolledlistbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/listbox'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledlistbox < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledlistbox
+ TkCommandNames = ['::iwidgets::scrolledlistbox'.freeze].freeze
+ WidgetClassName = 'Scrolledlistbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ################################
+
+ def initialize(*args)
+ super(*args)
+ @listbox = component_widget('listbox')
+ end
+
+ def method_missing(id, *args)
+ if @listbox.methods.include?(id.id2name)
+ @listbox.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def get_curselection
+ tk_call(@path, 'getcurselection')
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ def selected_item_count
+ number(tk_call(@path, 'selecteditemcount'))
+ end
+
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+
+ #####################################
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', index))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ #####################################
+
+ include TkListItemConfig
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ super(tag)
+ end
+ end
+ private :tagid
+
+ #####################################
+
+ def activate(y)
+ tk_send_without_enc('activate', y)
+ self
+ end
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def get(first, last=nil)
+ if last
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
+ else
+ _fromUTF8(tk_send_without_enc('get', first))
+ end
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ def index(index)
+ tk_send_without_enc('index', index).to_i
+ end
+
+ #####################################
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
new file mode 100644
index 0000000000..39a9ed63c8
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
@@ -0,0 +1,518 @@
+#
+# tkextlib/iwidgets/scrolledtext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledtext < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledtext
+ TkCommandNames = ['::iwidgets::scrolledtext'.freeze].freeze
+ WidgetClassName = 'Scrolledtext'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ################################
+
+ def initialize(*args)
+ super(*args)
+ @text = component_widget('text')
+ end
+
+ def method_missing(id, *args)
+ if @text.methods.include?(id.id2name)
+ @text.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def import(file, idx=nil)
+ if idx
+ tk_call(@path, 'import', file, index(idx))
+ else
+ tk_call(@path, 'import', file)
+ end
+ self
+ end
+
+ def export(file)
+ tk_call(@path, 'export', file)
+ self
+ end
+
+ #####################################
+
+ include TkTextTagConfig
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ super(tag)
+ end
+ end
+ private :tagid
+
+ def bbox(index)
+ list(tk_send('bbox', index))
+ end
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def get_displaychars(*index)
+ # Tk8.5 feature
+ get('-displaychars', *index)
+ end
+
+ def image_cget(index, slot)
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index), "-#{slot}"))
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index),
+ "-#{slot}")))
+ end
+ end
+
+ def image_configure(index, slot, value=None)
+ if slot.kind_of? Hash
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ *hash_kv(slot, true)))
+ else
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ "-#{slot}",
+ _get_eval_enc_str(value)))
+ end
+ self
+ end
+
+ def image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+
+ def current_image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ conf = image_configinfo(index, slot)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ image_configinfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ image_configinfo(index, slot).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ def image_names
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def index(index)
+ tk_send_without_enc('index', _get_eval_enc_str(index))
+ end
+
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+
+ def mark_names
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def mark_gravity(mark, direction=nil)
+ if direction
+ tk_send_without_enc('mark', 'gravity',
+ _get_eval_enc_str(mark), direction)
+ self
+ else
+ tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
+ end
+ end
+
+ def mark_set(mark, index)
+ tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
+ _get_eval_enc_str(index))
+ self
+ end
+ alias set_mark mark_set
+
+ def mark_unset(*marks)
+ tk_send_without_enc('mark', 'unset',
+ *(marks.collect{|mark| _get_eval_enc_str(mark)}))
+ self
+ end
+ alias unset_mark mark_unset
+
+ def mark_next(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
+ _get_eval_enc_str(index))))
+ end
+ alias next_mark mark_next
+
+ def mark_previous(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
+ _get_eval_enc_str(index))))
+ end
+ alias previous_mark mark_previous
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+
+ def _ktext_length(txt)
+ if $KCODE !~ /n/i
+ return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
+ end
+
+ # $KCODE == 'NONE'
+ if JAPANIZED_TK
+ tk_call_without_enc('kstring', 'length',
+ _get_eval_enc_str(txt)).to_i
+ else
+ begin
+ tk_call_without_enc('encoding', 'convertto', 'ascii',
+ _get_eval_enc_str(txt)).length
+ rescue StandardError, NameError
+ # sorry, I have no plan
+ txt.length
+ end
+ end
+ end
+ private :_ktext_length
+
+ def tksearch(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
+ else
+ opts = []
+ end
+
+ opts << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def tksearch_with_count(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
+ else
+ opts = []
+ end
+
+ opts << '-count' << args.shift << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def search_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'>=',stop)
+ txt = get(start,stop)
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get(start,'end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def search(pat,start,stop=None)
+ search_with_length(pat,start,stop)[0]
+ end
+
+ def rsearch_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'<=',stop)
+ txt = get(stop,start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(stop + " + #{pos} chars"), pat.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index(stop + " + #{pos} chars"), $&.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get('1.0',start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def rsearch(pat,start,stop=None)
+ rsearch_with_length(pat,start,stop)[0]
+ end
+
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ ###############################
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
new file mode 100644
index 0000000000..eef093d314
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/scrolledwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledwidget < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledwidget
+ TkCommandNames = ['::iwidgets::scrolledwidget'.freeze].freeze
+ WidgetClassName = 'Scrolledwidget'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
new file mode 100644
index 0000000000..91ba9248e1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
@@ -0,0 +1,92 @@
+#
+# tkextlib/iwidgets/selectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Selectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Selectionbox
+ TkCommandNames = ['::iwidgets::selectionbox'.freeze].freeze
+ WidgetClassName = 'Selectionbox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear_items
+ tk_call(@path, 'clear', 'items')
+ self
+ end
+
+ def clear_selection
+ tk_call(@path, 'clear', 'selection')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+
+ def insert_items(idx, *args)
+ tk_call(@path, 'insert', 'items', idx, *args)
+ end
+
+ def insert_selection(pos, text)
+ tk_call(@path, 'insert', 'selection', pos, text)
+ end
+
+ def select_item
+ tk_call(@path, 'selectitem')
+ self
+ end
+
+ # based on TkListbox ( and TkTextWin )
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def index(index)
+ tk_send_without_enc('index', index).to_i
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
new file mode 100644
index 0000000000..794da5d61c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
@@ -0,0 +1,92 @@
+#
+# tkextlib/iwidgets/selectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Selectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Selectiondialog
+ TkCommandNames = ['::iwidgets::selectiondialog'.freeze].freeze
+ WidgetClassName = 'Selectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear_items
+ tk_call(@path, 'clear', 'items')
+ self
+ end
+
+ def clear_selection
+ tk_call(@path, 'clear', 'selection')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+
+ def insert_items(idx, *args)
+ tk_call(@path, 'insert', 'items', idx, *args)
+ end
+
+ def insert_selection(pos, text)
+ tk_call(@path, 'insert', 'selection', pos, text)
+ end
+
+ def select_item
+ tk_call(@path, 'selectitem')
+ self
+ end
+
+ # based on TkListbox ( and TkTextWin )
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def index(index)
+ tk_send_without_enc('index', index).to_i
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/setup.rb b/ext/tk/lib/tkextlib/iwidgets/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/iwidgets/shell.rb b/ext/tk/lib/tkextlib/iwidgets/shell.rb
new file mode 100644
index 0000000000..dabf2e6f25
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/shell.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/shell.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Shell < Tk::Itk::Toplevel
+ end
+ end
+end
+
+class Tk::Iwidgets::Shell
+ TkCommandNames = ['::iwidgets::shell'.freeze].freeze
+ WidgetClassName = 'Shell'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def activate
+ tk_call(@path, 'activate') # may return val of deactibate method
+ end
+
+ def center(win=None)
+ tk_call(@path, 'center', win)
+ self
+ end
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def deactivate(val=None)
+ tk_call(@path, 'deactivate', val)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/spindate.rb b/ext/tk/lib/tkextlib/iwidgets/spindate.rb
new file mode 100644
index 0000000000..6099ba77b9
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spindate.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/spindate.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spindate < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spindate
+ TkCommandNames = ['::iwidgets::spindate'.freeze].freeze
+ WidgetClassName = 'Spindate'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/spinint.rb b/ext/tk/lib/tkextlib/iwidgets/spinint.rb
new file mode 100644
index 0000000000..071b6ab8f7
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spinint.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/spinint.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spinint < Tk::Iwidgets::Spinner
+ end
+ end
+end
+
+class Tk::Iwidgets::Spinint
+ TkCommandNames = ['::iwidgets::spinint'.freeze].freeze
+ WidgetClassName = 'Spinint'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
new file mode 100644
index 0000000000..b5c72b4df8
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
@@ -0,0 +1,150 @@
+#
+# tkextlib/iwidgets/spinner.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spinner < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spinner
+ TkCommandNames = ['::iwidgets::spinner'.freeze].freeze
+ WidgetClassName = 'Spinner'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class EntryfieldValidate < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?s, :char ],
+ [ ?P, ?s, :post ],
+ [ ?S, ?s, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['validate', 'invalid']
+ end
+ end
+
+ def __validation_class_list
+ super << EntryfieldValidate
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
+
+ ####################################
+
+ def up
+ tk_call_without_enc(@path, 'up')
+ self
+ end
+
+ def down
+ tk_call_without_enc(@path, 'down')
+ self
+ end
+
+ def clear
+ tk_call_without_enc(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(index)
+ number(tk_send_without_enc('index', index))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/spintime.rb b/ext/tk/lib/tkextlib/iwidgets/spintime.rb
new file mode 100644
index 0000000000..c1e1f5e5f1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/spintime.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/spintime.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spintime < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spintime
+ TkCommandNames = ['::iwidgets::spintime'.freeze].freeze
+ WidgetClassName = 'Spintime'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
new file mode 100644
index 0000000000..5321331551
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
@@ -0,0 +1,154 @@
+#
+# tkextlib/iwidgets/tabnotebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Tabnotebook < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Tabnotebook
+ TkCommandNames = ['::iwidgets::tabnotebook'.freeze].freeze
+ WidgetClassName = 'Tabnotebook'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tabcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tabconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias pagecget itemcget
+ alias pageconfigure itemconfigure
+ alias pageconfiginfo itemconfiginfo
+ alias current_pageconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def initialize(*args)
+ super(*args)
+ @tabset = self.component_widget('tabset')
+ end
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ window(tk_call(@path, 'childsite', index(idx)))
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ #number(tk_call(@path, 'index', tagid(idx)))
+ @tabset.index(tagid(idx))
+ end
+
+ def insert(idx, keys={})
+ window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+
+ def scrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias xscrollcommand scrollcommand
+ alias yscrollcommand scrollcommand
+
+ def xscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'horizontal'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ def yscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'vertical'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ alias scrollbar yscrollbar
+
+ def view(*index)
+ if index.size == 0
+ window(tk_send_without_enc('view'))
+ else
+ tk_send_without_enc('view', *index)
+ self
+ end
+ end
+ alias xview view
+ alias yview view
+
+ def view_moveto(*index)
+ view('moveto', *index)
+ end
+ alias xview_moveto view_moveto
+ alias yview_moveto view_moveto
+ def view_scroll(*index)
+ view('scroll', *index)
+ end
+ alias xview_scroll view_scroll
+ alias yview_scroll view_scroll
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
new file mode 100644
index 0000000000..1b76916ab7
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
@@ -0,0 +1,89 @@
+#
+# tkextlib/iwidgets/tabset.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Tabset < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Tabset
+ TkCommandNames = ['::iwidgets::tabset'.freeze].freeze
+ WidgetClassName = 'Tabset'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tabcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tabconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias tabcget itemcget
+ alias tabconfigure itemconfigure
+ alias tabconfiginfo itemconfiginfo
+ alias current_tabconfiginfo current_itemconfiginfo
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, keys={})
+ window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/timeentry.rb b/ext/tk/lib/tkextlib/iwidgets/timeentry.rb
new file mode 100644
index 0000000000..987cddc1e0
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/timeentry.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/timeentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Timeentry < Tk::Iwidgets::Timefield
+ end
+ end
+end
+
+class Tk::Iwidgets::Timeentry
+ TkCommandNames = ['::iwidgets::timeentry'.freeze].freeze
+ WidgetClassName = 'Timeentry'.freeze
+ WidgetClassNames[WidgetClassName] = self
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/timefield.rb b/ext/tk/lib/tkextlib/iwidgets/timefield.rb
new file mode 100644
index 0000000000..602093eb7e
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/timefield.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/iwidgets/timefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Timefield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Timefield
+ TkCommandNames = ['::iwidgets::timefield'.freeze].freeze
+ WidgetClassName = 'Timefield'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def valid?
+ bool(tk_call(@path, 'isvalid'))
+ end
+ alias isvalid? valid?
+
+ def show(time=None)
+ tk_call(@path, 'show', time)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
new file mode 100644
index 0000000000..a2a7f31627
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
@@ -0,0 +1,87 @@
+#
+# tkextlib/iwidgets/toolbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Toolbar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Toolbar
+ TkCommandNames = ['::iwidgets::toolbar'.freeze].freeze
+ WidgetClassName = 'Toolbar'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'itemcget', self.index(id)]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'itemconfigure', self.index(id)]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ ####################################
+
+ def add(type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'insert', index(idx), type,
+ tagid(tag), *hash_kv(keys)))
+ tag
+ end
+end
diff --git a/ext/tk/lib/tkextlib/iwidgets/watch.rb b/ext/tk/lib/tkextlib/iwidgets/watch.rb
new file mode 100644
index 0000000000..f62c0b931e
--- /dev/null
+++ b/ext/tk/lib/tkextlib/iwidgets/watch.rb
@@ -0,0 +1,45 @@
+#
+# tkextlib/iwidgets/watch.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Watch < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Watch
+ TkCommandNames = ['::iwidgets::watch'.freeze].freeze
+ WidgetClassName = 'Watch'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(time=None)
+ tk_call(@path, 'show', time)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+
+ def watch(*args)
+ unless args.empty?
+ tk_call(@path, 'watch', *args)
+ end
+ component_path('canvas')
+ end
+end
diff --git a/ext/tk/lib/tkextlib/pkg_checker.rb b/ext/tk/lib/tkextlib/pkg_checker.rb
new file mode 100755
index 0000000000..5002ed7ff8
--- /dev/null
+++ b/ext/tk/lib/tkextlib/pkg_checker.rb
@@ -0,0 +1,184 @@
+#!/usr/bin/env ruby
+#
+# Ruby/Tk extension library checker
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+TkRoot.new.withdraw # hide root window
+
+name = File.basename(__FILE__)
+
+add_path = false
+verbose = false
+
+def help_msg
+ print "Usage: #{$0} [-l] [-v] [-h] [--] [dir]\n"
+ print "\tIf dir is omitted, check the directry that this command exists.\n"
+ print "\tAvailable options are \n"
+ print "\t -l : Add dir to $LOAD_PATH\n"
+ print "\t (If dir == '<parent>/tkextlib', add <parent> also.)\n"
+ print "\t -v : Verbose mode (show reason of fail)\n"
+ print "\t -h : Show this message\n"
+ print "\t -- : End of options\n"
+end
+
+while(ARGV[0] && ARGV[0][0] == ?-)
+ case ARGV[0]
+ when '--'
+ ARGV.shift
+ break;
+ when '-l'
+ ARGV.shift
+ add_path = true
+ when '-v'
+ ARGV.shift
+ verbose = true
+ when '-h'
+ help_msg
+ exit(0)
+ else
+ print "Argument Error!! : unknown option '#{ARGV[0]}'\n"
+ help_msg
+ exit(1)
+ end
+end
+
+if ARGV[0]
+ dir = File.expand_path(ARGV[0])
+else
+ dir = File.dirname(File.expand_path(__FILE__))
+end
+
+if add_path
+ $LOAD_PATH.unshift(dir)
+ if File.basename(dir) == 'tkextlib'
+ $LOAD_PATH.unshift(File.dirname(dir))
+ end
+end
+
+print "\nRuby/Tk extension library checker\n"
+print "( Note:: This check is very simple one. Shown status may be wrong. )\n"
+print "\n check directory :: #{dir}"
+print "\n $LOAD_PATH :: #{$LOAD_PATH.inspect}\n"
+
+def get_pkg_list(file)
+ pkg_list = []
+
+ File.foreach(file){|l|
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)TkPackage\s*\.\s*require\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :package]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tcllibrary\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :library]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tclscript\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :script]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)require\s*\(?\s*(["'])((\w|\/|:)+)\1/
+ pkg = [$2, :require_ruby_lib]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ }
+
+ pkg_list
+end
+
+def check_pkg(file, verbose=false)
+ pkg_list = get_pkg_list(file)
+
+ error_list = []
+ success_list = {}
+
+ pkg_list.each{|name, type|
+ next if success_list[name]
+
+ begin
+ case type
+ when :package
+ ver = TkPackage.require(name)
+ success_list[name] = ver
+ error_list.delete_if{|n, t| n == name}
+
+ when :library
+ Tk.load_tcllibrary(name)
+ success_list[name] = :library
+ error_list.delete_if{|n, t| n == name}
+
+ when :script
+ Tk.load_tclscript(name)
+ success_list[name] = :script
+ error_list.delete_if{|n, t| n == name}
+
+ when :require_ruby_lib
+ require name
+
+ end
+ rescue => e
+ if verbose
+ error_list << [name, type, e.message]
+ else
+ error_list << [name, type]
+ end
+ end
+ }
+
+ success_list.dup.each{|name, ver|
+ unless ver.kind_of?(String)
+ begin
+ ver = TkPackage.require(name)
+ sccess_list[name] = ver
+ rescue
+ end
+ end
+ }
+
+ [success_list, error_list]
+end
+
+def subdir_check(dir, verbose=false)
+ Dir.foreach(dir){|f|
+ next if f == '.' || f == '..'
+ if File.directory?(f)
+ subdir_check(File.join(dir, f))
+ elsif File.extname(f) == '.rb'
+ path = File.join(dir, f)
+ suc, err = check_pkg(path, verbose)
+ if err.empty?
+ print 'Ready : ', path, ' : require->', suc.inspect, "\n"
+ else
+ print '*LACK : ', path, ' : require->', suc.inspect,
+ ' FAIL->', err.inspect, "\n"
+ end
+ end
+ }
+end
+
+Dir.chdir(dir)
+
+(Dir['*.rb'] - ['setup.rb', name]).each{|f|
+ subdir = File.basename(f, '.*')
+=begin
+ begin
+ # read 'setup.rb' as if the library has standard structure
+ require File.join(subdir, 'setup.rb')
+ rescue LoadError
+ # ignore error
+ end
+=end
+ print "\n"
+
+ suc, err = check_pkg(f, verbose)
+ if err.empty?
+ print 'Ready : ', f, ' : require->', suc.inspect, "\n"
+ else
+ print '*LACK : ', f, ' : require->', suc.inspect,
+ ' FAIL->', err.inspect, "\n"
+ end
+
+ subdir_check(subdir, verbose) if File.directory?(subdir)
+}
diff --git a/ext/tk/lib/tkextlib/setup.rb b/ext/tk/lib/tkextlib/setup.rb
new file mode 100644
index 0000000000..12867e8f9c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before using Tk extension libraries
+#
+# If you need some setup operations for Tk extensions (for example,
+# modify the dynamic library path) required, please write the setup
+# operations in this file. This file is required at the last of
+# "require 'tk'".
+#
diff --git a/ext/tk/lib/tkextlib/tcllib.rb b/ext/tk/lib/tkextlib/tcllib.rb
new file mode 100644
index 0000000000..f238a975a4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib.rb
@@ -0,0 +1,69 @@
+#
+# tcllib extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tcllib/setup.rb'
+
+err = ''
+
+# package:: autoscroll
+target = 'tkextlib/tcllib/autoscroll'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# package:: cursor
+target = 'tkextlib/tcllib/cursor'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# package:: style
+target = 'tkextlib/tcllib/style'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# autoload
+module Tk
+ module Tcllib
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ # package:: ctext
+ autoload :CText, 'tkextlib/tcllib/ctext'
+
+ # package:: datefield
+ autoload :Datefield, 'tkextlib/tcllib/datefield'
+ autoload :DateField, 'tkextlib/tcllib/datefield'
+
+ # package:: ico
+ autoload :ICO, 'tkextlib/tcllib/ico'
+
+ # package:: ipentry
+ autoload :IP_Entry, 'tkextlib/tcllib/ip_entry'
+ autoload :IPEntry, 'tkextlib/tcllib/ip_entry'
+
+ # package:: Plotchart
+ autoload :Plotchart, 'tkextlib/tcllib/plotchart'
+
+ # package:: tkpiechart
+ autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart'
+ end
+end
+
+if $VERBOSE && !err.empty?
+ warn("Warning: some sub-packages are failed to require : " + err)
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/README b/ext/tk/lib/tkextlib/tcllib/README
new file mode 100644
index 0000000000..953239befa
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/README
@@ -0,0 +1,135 @@
+
+ [ tcllib extension support files ]
+
+Tcllib includes many utilities. But currently, supports TKLib part
+only (see the following 'tcllib contents').
+
+If you request to support others, please send your message to one of
+ruby-talk/ruby-list/ruby-dev/ruby-ext mailing lists.
+
+-----<from "What is tcllib?">----------------------------
+Tcllib is a collection of utility modules for Tcl. These modules provide
+a wide variety of functionality, from implementations of standard data
+structures to implementations of common networking protocols. The intent
+is to collect commonly used function into a single library, which users
+can rely on to be available and stable.
+---------------------------------------------------------
+
+-----< tcllib contents (based on tcllib-1.6.1) >---------
+Programming tools
+ * cmdline - Procedures to process command lines and options.
+ * comm - A remote communications facility for Tcl (7.6, 8.0, and later)
+ * control - Procedures for control flow structures.
+ * fileutil - Procedures implementing some file utilities
+ * log - Procedures to log messages of libraries and applications.
+ * logger - System to control logging of events.
+ * multiplexer - One-to-many communication with sockets.
+ * snit - Snit's Not Incr Tcl
+ * snitfaq - Snit Frequently Asked Questions
+ * stooop - Object oriented extension.
+ * stoop - Simple Tcl Only Object Oriented Programming
+ * switched - stooop switched class
+ * profiler - Tcl source code profiler
+
+Mathematics
+ * math::statistics - Basic statistical functions and procedures
+ * math::calculus - Integration and ordinary differential equations
+ * math::optimize - Optimisation routines
+ * math::fuzzy - Fuzzy comparison of floating-point numbers
+ * counter - Procedures for counters and histograms
+ * combinatorics - Combinatorial functions in the Tcl Math Library
+
+Data structures
+ * struct::list - Procedures for manipulating lists
+ * struct::set - Procedures for manipulating sets
+ * struct::stack - Create and manipulate stack objects
+ * struct::queue - Create and manipulate queue objects
+ * struct::prioqueue - Create and manipulate prioqueue objects
+ * struct::skiplist - Create and manipulate skiplists
+ * struct::tree - Create and manipulate tree objects
+ * struct::graph - Create and manipulate directed graph objects
+ * struct::record - Define and create records (similar to 'C' structures)
+ * struct::matrix - Create and manipulate matrix objects
+ * struct::pool - Create and manipulate pool objects (of discrete items)
+ * report - Create and manipulate report objects
+
+Text processing
+ * expander - Procedures to process templates and expand text.
+ * base64 - Procedures to encode and decode base64
+ * yencode - encode/decoding a binary file
+ * uuencode - encode/decoding a binary file
+ * csv - Procedures to handle CSV data.
+ * inifile - Parsing of Windows INI files
+ * htmlparse - Procedures to parse HTML strings
+ * mime - Manipulation of MIME body parts
+ * Tcl MIME - generates and parses MIME body parts
+ * textutil - Procedures to manipulate texts and strings.
+ * exif - Tcl EXIF extracts and parses EXIF fields from digital images
+ * EXIF - extract and parse EXIF fields from digital images
+
+Hashes, checksums, and encryption
+ * cksum - calculate a cksum(1) compatible checksum
+ * crc16 - Perform a 16bit Cyclic Redundancy Check
+ * crc32 - Perform a 32bit Cyclic Redundancy Check
+ * des - Perform DES encryption of Tcl data
+ * md4 - MD4 Message-Digest Algorithm
+ * md5 - MD5 Message-Digest Algorithm
+ * ripemd160 - RIPEMD-160 Message-Digest Algorithm
+ * ripemd128 - RIPEMD-128 Message-Digest Algorithm
+ * md5crypt - MD5-based password encryption
+ * sha1 - Perform sha1 hashing
+ * sum - calculate a sum(1) compatible checksum
+ * soundex - Soundex
+
+Documentation tools
+ * mpexpand - Markup processor
+ * doctools - Create and manipulate doctools converter object
+ * doctoc_fmt - Specification of simple tcl markup for table of contents
+ * doctools_api - Interface specification for formatter code
+ * doctools_fmt - Specification of simple tcl markup for manpages
+ * docidx - Create and manipulate docidx converter objects
+ * docidx_api - Interface specification for index formatting code
+ * docidx_fmt - Specification of simple tcl markup for an index
+ * doctoc - Create and manipulate doctoc converter objects
+ * doctoc_api - Interface specification for toc formatting code
+ * doctools::changelog - Handle text in Emacs ChangeLog format
+ * doctools::cvs - Handle text in 'cvs log' format
+
+Networking
+ * uri - URI utilities
+ * dns - Tcl Domain Name Service Client
+ * ntp_time - Tcl Time Service Client
+ * nntp - Tcl client for the NNTP protocol
+ * pop3 - Tcl client for POP3 email protocol
+ * pop3d - Tcl POP3 server implementation
+ * pop3d::udb - Simple user database for pop3d
+ * pop3d::dbox - Simple mailbox database for pop3d
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftpd - Tcl FTP server implementation
+ * smtp - Client-side tcl implementation of the smtp protocol
+ * smtpd - Tcl SMTP server implementation
+ * irc - Create IRC connection and interface.
+
+CGI programming
+ * ncgi - Procedures to manipulate CGI values.
+ * html - Procedures to generate HTML structures
+ * javascript - Procedures to generate HTML and Java Script structures.
+
+Grammars and finite automata
+ * grammar::fa - Create and manipulate finite automatons
+ * grammar::fa::op - Operations on finite automatons
+ * grammar::dacceptor - Create and use deterministic acceptors
+ * grammar::dexec - Execute deterministic finite automatons
+
+TKLib
+ * Plotchart - Simple plotting and charting package
+ * autoscroll - Provides for a scrollbar to automatically mapped and
+ unmapped as needed
+ * ctext - An extended text widget with customizable Syntax highlighting
+ * cursor - Procedures to handle CURSOR data
+ * datefield - Tk datefield widget
+ * style - Changes default Tk look&feel
+ * ipentry - An IP address entry widget
+ * tkpiechart - Creates and dynamically updates 2D or 3D pie charts
+---------------------------------------------------------
diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
new file mode 100644
index 0000000000..256b01ba87
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
@@ -0,0 +1,143 @@
+#
+# tkextlib/tcllib/autoscroll.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides for a scrollbar to automatically mapped and unmapped as needed
+#
+# (The following is the original description of the library.)
+#
+# This package allows scrollbars to be mapped and unmapped as needed
+# depending on the size and content of the scrollbars scrolled widget.
+# The scrollbar must be managed by either pack or grid, other geometry
+# managers are not supported.
+#
+# When managed by pack, any geometry changes made in the scrollbars parent
+# between the time a scrollbar is unmapped, and when it is mapped will be
+# lost. It is an error to destroy any of the scrollbars siblings while the
+# scrollbar is unmapped. When managed by grid, if anything becomes gridded
+# in the same row and column the scrollbar occupied it will be replaced by
+# the scrollbar when remapped.
+#
+# This package may be used on any scrollbar-like widget as long as it
+# supports the set subcommand in the same style as scrollbar. If the set
+# subcommand is not used then this package will have no effect.
+#
+
+require 'tk'
+require 'tk/scrollbar'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Autoscroll
+ def self.package_version
+ begin
+ TkPackage.require('autoscroll')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment."
+ end
+
+ def self.autoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+
+ def self.unautoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+ end
+ end
+end
+
+module Tk
+ module Scrollable
+ def autoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ def unautoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ end
+end
+
+class TkScrollbar
+ def autoscroll
+ # Arranges for the already existing scrollbar to be mapped
+ # and unmapped as needed.
+ #tk_call_without_enc('::autoscroll::autoscroll', @path)
+ Tk::Tcllib::Autoscroll.autoscroll(self)
+ self
+ end
+ def unautoscroll
+ # Returns the scrollbar to its original static state.
+ #tk_call_without_enc('::autoscroll::unautoscroll', @path)
+ Tk::Tcllib::Autoscroll.unautoscroll(self)
+ self
+ end
+end
+
+# TkPackage.require('autoscroll', '1.0')
+TkPackage.require('autoscroll')
+
+module Tk
+ module Tcllib
+ class << Autoscroll
+ undef not_available
+ end
+
+ module Autoscroll
+ extend TkCore
+ def self.autoscroll(win)
+ tk_call_without_enc('::autoscroll::autoscroll', win.path)
+ end
+
+ def self.unautoscroll(win)
+ tk_call_without_enc('::autoscroll::unautoscroll', win.path)
+ end
+ end
+ end
+end
+
diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb
new file mode 100644
index 0000000000..89bfeff0f3
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb
@@ -0,0 +1,143 @@
+#
+# tkextlib/tcllib/ctext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Overloads the text widget and provides new commands
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ctext', '3.1')
+TkPackage.require('ctext')
+
+module Tk
+ module Tcllib
+ class CText < TkText
+ def self.package_version
+ begin
+ TkPackage.require('ctext')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::CText
+ TkCommandNames = ['ctext'.freeze].freeze
+ WidgetClassName = 'Ctext'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('ctext', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('ctext', @path)
+ end
+ end
+ private :create_self
+
+ def append(*args)
+ tk_send('append', *args)
+ end
+
+ def copy
+ tk_send('copy')
+ end
+
+ def cut
+ tk_send('cut')
+ end
+
+ def fast_delete(*args)
+ tk_send('fastdelete', *args)
+ end
+
+ def fast_insert(*args)
+ tk_send('fastinsert', *args)
+ end
+
+ def highlight(*args)
+ tk_send('highlight', *args)
+ end
+
+ def paste
+ tk_send('paste')
+ end
+
+ def edit(*args)
+ tk_send('edit', *args)
+ end
+
+ def add_highlight_class(klass, col, *keywords)
+ tk_call('ctext::addHighlightClass', @path, klass, col, keywords.flatten)
+ self
+ end
+
+ def add_highlight_class_for_special_chars(klass, col, *chrs)
+ tk_call('ctext::addHighlightClassForSpecialChars',
+ @path, klass, col, chrs.join(''))
+ self
+ end
+
+ def add_highlight_class_for_regexp(klass, col, tcl_regexp)
+ tk_call('ctext::addHighlightClassForRegexp',
+ @path, klass, col, tcl_regexp)
+ self
+ end
+
+ def add_highlight_class_with_only_char_start(klass, col, chr)
+ tk_call('ctext::addHighlightClassWithOnlyCharStart',
+ @path, klass, col, chr)
+ self
+ end
+
+ def clear_highlight_classes
+ tk_call('ctext::clearHighlightClasses', @path)
+ self
+ end
+
+ def get_highlight_classes
+ tk_split_simplelist(tk_call('ctext::getHighlightClasses', @path))
+ end
+
+ def delete_highlight_class(klass)
+ tk_call('ctext::deleteHighlightClass', @path, klass)
+ self
+ end
+
+ def enable_C_comments
+ tk_call('ctext::enableComments', @path)
+ self
+ end
+
+ def disable_C_comments
+ tk_call('ctext::disableComments', @path)
+ self
+ end
+
+ def find_next_char(idx, chr)
+ tk_call('ctext::findNextChar', @path, idx, chr)
+ end
+
+ def find_next_space(idx)
+ tk_call('ctext::findNextSpace', @path, idx)
+ end
+
+ def find_previous_space(idx)
+ tk_call('ctext::findPreviousSpace', @path, idx)
+ end
+
+ def set_update_proc(cmd=Proc.new)
+ tk_call('proc', 'ctext::update', '', cmd)
+ self
+ end
+
+ def modified?(mode)
+ bool(tk_call('ctext::modified', @path, mode))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/cursor.rb b/ext/tk/lib/tkextlib/tcllib/cursor.rb
new file mode 100644
index 0000000000..92fd7a62b5
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/cursor.rb
@@ -0,0 +1,90 @@
+#
+# tkextlib/tcllib/cursor.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Procedures to handle CURSOR data
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Cursor
+ def self.package_version
+ begin
+ TkPackage.require('cursor')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment."
+ end
+
+ def self.cursor_display(win=None)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_propagate(win, cursor)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ Tk::Tcllib::Cursor.not_available
+ end
+ end
+ end
+
+ def self.cursor_display(parent=None)
+ # Pops up a dialog with a listbox containing all the cursor names.
+ # Selecting a cursor name will display it in that dialog.
+ # This is simply for viewing any available cursors on the platform .
+ #tk_call_without_enc('::cursor::display', parent)
+ Tk::Tcllib::Cursor.cursor_display(parent)
+ end
+end
+
+class TkWindow
+ def cursor_propagate(cursor)
+ # Sets the cursor for self and all its descendants to cursor.
+ #tk_call_without_enc('::cursor::propagate', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_propagate(cursor)
+ end
+ def cursor_restore(cursor = None)
+ # Restore the original or previously set cursor for self and all its
+ # descendants. If cursor is specified, that will be used if on any
+ # widget that did not have a preset cursor (set by a previous call
+ # to TkWindow#cursor_propagate).
+ #tk_call_without_enc('::cursor::restore', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_restore(cursor)
+ end
+end
+
+# TkPackage.require('cursor', '0.1')
+TkPackage.require('cursor')
+
+module Tk
+ module Tcllib
+ class << Cursor
+ undef not_available
+ end
+
+ module Cursor
+ extend TkCore
+ def self.cursor_display(win=None)
+ tk_call_without_enc('::cursor::display', win)
+ end
+
+ def self.cursor_propagate(win, cursor)
+ tk_call_without_enc('::cursor::propagate', win.path, cursor)
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ tk_call_without_enc('::cursor::restore', win.path, cursor)
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb
new file mode 100644
index 0000000000..1d029e4569
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb
@@ -0,0 +1,52 @@
+#
+# tkextlib/tcllib/datefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Tk datefield widget
+#
+# (The following is the original description of the library.)
+#
+# The datefield package provides the datefield widget which is an enhanced
+# text entry widget for the purpose of date entry. Only valid dates of the
+# form MM/DD/YYYY can be entered.
+#
+# The datefield widget is, in fact, just an entry widget with specialized
+# bindings. This means all the command and options for an entry widget apply
+# equally here.
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('datefield', '0.1')
+TkPackage.require('datefield')
+
+module Tk
+ module Tcllib
+ class Datefield < TkEntry
+ def self.package_version
+ begin
+ TkPackage.require('datefield')
+ rescue
+ ''
+ end
+ end
+ end
+ DateField = Datefield
+ end
+end
+
+class Tk::Tcllib::Datefield
+ TkCommandNames = ['::datefield::datefield'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('::datefield::datefield', @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc('::datefield::datefield', @path)
+ end
+ end
+ private :create_self
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/ico.rb b/ext/tk/lib/tkextlib/tcllib/ico.rb
new file mode 100644
index 0000000000..c87275126e
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/ico.rb
@@ -0,0 +1,109 @@
+#
+# tkextlib/tcllib/ico.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Reading and writing windows icons
+#
+
+require 'tk'
+require 'tk/image'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ico', '0.3')
+TkPackage.require('ico')
+
+module Tk
+ module Tcllib
+ class ICO < TkImage
+ def self.package_version
+ begin
+ TkPackage.require('ico')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::ICO
+ def self.list(file, keys=nil)
+ tk_split_list(tk_call_without_enc('::ico::getIconList', file,
+ *hash_kv(keys, true)))
+ end
+
+ def self.get(file, index, keys=nil)
+ tk_call_without_enc('::ico::getIcon', file, index, *hash_kv(keys, true))
+ end
+
+ def self.get_image(file, index, keys={})
+ keys = _symbolkey2str(keys)
+ keys.delete('format')
+ self.new(file, index, keys)
+ end
+
+ def self.get_data(file, index, keys={})
+ keys['format'] = 'data'
+ tk_split_list(tk_call_without_enc('::ico::getIcon', file, index,
+ *hash_kv(keys, true)))
+ end
+
+ def self.write(file, index, depth, data, keys=nil)
+ tk_call_without_enc('::ico::writeIcon', file, index, depth, data,
+ *hash_kv(keys, true))
+ end
+
+ def self.copy(from_file, from_index, to_file, to_index, keys=nil)
+ tk_call_without_enc('::ico::copyIcon',
+ from_file, from_index, to_file, to_index,
+ *hash_kv(keys, true))
+ end
+
+ def self.exe_to_ico(exe_file, ico_file, keys=nil)
+ tk_call_without_enc('::ico::copyIcon', exe_file, ico_file,
+ *hash_kv(keys, true))
+ end
+
+ def self.clear_cache(file=None)
+ tk_call_without_enc('::ico::clearCache', file)
+ end
+
+ def self.transparent_color(image, color)
+ if image.kind_of?(Array)
+ tk_split_list(tk_call_without_enc('::ico::transparentColor',
+ image, color))
+ else
+ tk_call_without_enc('::ico::transparentColor', image, color)
+ end
+ end
+
+ def self.show(file, keys=nil)
+ tk_call_without_enc('::ico::Show', file, *hash_kv(keys, true))
+ end
+
+ ###########################
+
+ def initialize(file, index, keys=nil)
+ keys = _symbolkey2str(keys)
+ if keys.key?('name')
+ @path = keys['name'].to_s
+ else
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ end
+ tk_call_without_enc('::ico::getIcon', file, index, '-name', @path,
+ '-format', 'image', *hash_kv(keys, true))
+ Tk_IMGTBL[@path] = self
+ end
+
+ def write(file, index, depth, keys=nil)
+ Tk::Tcllib::ICO.write(file, index, depth, @path, keys=nil)
+ self
+ end
+
+ def transparent_color(color)
+ tk_call_without_enc('::ico::transparentColor', @path, color)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
new file mode 100644
index 0000000000..da9f1eb3a8
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
@@ -0,0 +1,55 @@
+#
+# tkextlib/tcllib/ip_entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * An IP address entry widget
+#
+# (The following is the original description of the library.)
+#
+# This package provides a widget for the entering of a IP address.
+# It guarantees a valid address at all times.
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ipentry', '0.1')
+TkPackage.require('ipentry')
+
+module Tk
+ module Tcllib
+ class IP_Entry < TkEntry
+ def self.package_version
+ begin
+ TkPackage.require('ipentry')
+ rescue
+ ''
+ end
+ end
+ end
+ IPEntry = IP_Entry
+ end
+end
+
+class Tk::Tcllib::IP_Entry
+ TkCommandNames = ['::ipentry::ipentry'.freeze].freeze
+ WidgetClassName = 'IPEntry'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('::ipentry::ipentry', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('::ipentry::ipentry', @path)
+ end
+ end
+ private :create_self
+
+ def complete?
+ bool(tk_send_without_enc('complete'))
+ end
+
+ def insert(*ip)
+ tk_send_without_enc('insert', array2tk_list(ip.flatten))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb
new file mode 100644
index 0000000000..5603ce1283
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb
@@ -0,0 +1,708 @@
+#
+# tkextlib/tcllib/plotchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Simple plotting and charting package
+#
+# (The following is the original description of the library.)
+#
+# Plotchart is a Tcl-only package that focuses on the easy creation of
+# xy-plots, barcharts and other common types of graphical presentations.
+# The emphasis is on ease of use, rather than flexibility. The procedures
+# that create a plot use the entire canvas window, making the layout of the
+# plot completely automatic.
+#
+# This results in the creation of an xy-plot in, say, ten lines of code:
+# --------------------------------------------------------------------
+# package require Plotchart
+#
+# canvas .c -background white -width 400 -height 200
+# pack .c -fill both
+#
+# #
+# # Create the plot with its x- and y-axes
+# #
+# set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
+#
+# foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } {
+# $s plot series1 $x $y
+# }
+#
+# $s title "Data series"
+# --------------------------------------------------------------------
+#
+# A drawback of the package might be that it does not do any data management.
+# So if the canvas that holds the plot is to be resized, the whole plot must
+# be redrawn. The advantage, though, is that it offers a number of plot and
+# chart types:
+#
+# * XY-plots like the one shown above with any number of data series.
+# * Stripcharts, a kind of XY-plots where the horizontal axis is adjusted
+# automatically. The result is a kind of sliding window on the data
+# series.
+# * Polar plots, where the coordinates are polar instead of cartesian.
+# * Isometric plots, where the scale of the coordinates in the two
+# directions is always the same, i.e. a circle in world coordinates
+# appears as a circle on the screen.
+# You can zoom in and out, as well as pan with these plots (Note: this
+# works best if no axes are drawn, the zooming and panning routines do
+# not distinguish the axes), using the mouse buttons with the control
+# key and the arrow keys with the control key.
+# * Piecharts, with automatic scaling to indicate the proportions.
+# * Barcharts, with either vertical or horizontal bars, stacked bars or
+# bars side by side.
+# * Timecharts, where bars indicate a time period and milestones or other
+# important moments in time are represented by triangles.
+# * 3D plots (both for displaying surfaces and 3D bars)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('Plotchart', '0.9')
+TkPackage.require('Plotchart')
+
+module Tk
+ module Tcllib
+ module Plotchart
+ def self.package_version
+ begin
+ TkPackage.require('Plotchart')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Plotchart
+ extend TkCore
+ ############################
+ def self.view_port(w, *args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', w.path, *(args.flatten))
+ end
+
+ def self.world_coordinates(w, *args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.world_3D_coordinates(w, *args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.coords_to_pixel(w, x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', w.path, x, y))
+ end
+
+ def self.coords_3D_to_pixel(w, x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', w.path, x, y, z))
+ end
+
+ def self.polar_coordinates(w, radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', w.path, radmax)
+ end
+
+ def self.polar_to_pixel(w, rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', w.path, rad, phi))
+ end
+
+ def self.pixel_to_coords(w, x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', w.path, x, y))
+ end
+
+ def self.determine_scale(w, xmax, ymax)
+ tk_call_without_enc('::Plotchart::determineScale', w.path, xmax, ymax)
+ end
+
+ def self.set_zoom_pan(w)
+ tk_call_without_enc('::Plotchart::setZoomPan', w.path)
+ end
+
+ ############################
+ module ChartMethod
+ include TkCore
+
+ def title(str)
+ tk_call_without_enc(@chart, 'title', _get_eval_enc_str(str))
+ self
+ end
+
+ def save_plot(filename)
+ tk_call_without_enc(@chart, 'saveplot', filename)
+ self
+ end
+
+ def xtext(str)
+ tk_call_without_enc(@chart, 'xtext', _get_eval_enc_str(str))
+ self
+ end
+
+ def ytext(str)
+ tk_call_without_enc(@chart, 'ytext', _get_eval_enc_str(str))
+ self
+ end
+
+ def xconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true))
+ else
+ tk_call_without_enc(@chart, 'xconfig',
+ "-#{key}", _get_eval_enc_str(value))
+ end
+ self
+ end
+
+ def yconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true))
+ else
+ tk_call_without_enc(@chart, 'yconfig',
+ "-#{key}", _get_eval_enc_str(value))
+ end
+ self
+ end
+
+ ############################
+ def view_port(*args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', @path, *(args.flatten))
+ self
+ end
+
+ def world_coordinates(*args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def world_3D_coordinates(*args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def coords_to_pixel(x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', @path, x, y))
+ end
+
+ def coords_3D_to_pixel(x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', @path, x, y, z))
+ end
+
+ def polar_coordinates(radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', @path, radmax)
+ self
+ end
+
+ def polar_to_pixel(rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', @path, rad, phi))
+ end
+
+ def pixel_to_coords(x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', @path, x, y))
+ end
+
+ def determine_scale(xmax, ymax)
+ tk_call_without_enc('::Plotchart::determineScale', @path, xmax, ymax)
+ self
+ end
+
+ def set_zoom_pan()
+ tk_call_without_enc('::Plotchart::setZoomPan', @path)
+ self
+ end
+ end
+
+ ############################
+ class XYPlot < TkCanvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createXYPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if parent.kind_of?(TkCanvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ end
+
+ def plot(series, x, y)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series), x, y)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
+ else
+ tk_call_without_enc(@chart, 'dataconfig', series,
+ "-#{key}", _get_eval_enc_str(value))
+ end
+ end
+ end
+
+ ############################
+ class Stripchart < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createStripchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class PolarPlot < TkCanvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPolarplot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] radius_data [, keys])
+ # radius_data := Array of [maximum_radius, stepsize]
+ if args[0].kind_of?(Array)
+ @radius_data = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @radius_data = args.shift
+
+ if parent.kind_of?(TkCanvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@radius_data))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ end
+
+ def plot(series, radius, angle)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series),
+ radius, angle)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
+ else
+ tk_call_without_enc(@chart, 'dataconfig', series,
+ "-#{key}", _get_eval_enc_str(value))
+ end
+ end
+ end
+ Polarplot = PolarPlot
+
+ ############################
+ class IsometricPlot < TkCanvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createIsometricPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, [, step] [, keys])
+ # xaxis := Array of [minimum, maximum]
+ # yaxis := Array of [minimum, maximum]
+ # step := Float of stepsize | "noaxes" | :noaxes
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ if parent.kind_of?(TkCanvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis),
+ @stepsize)
+ end
+ private :_create_chart
+
+ def plot(type, *args)
+ self.__send__("plot_#{type.to_s.tr('-', '_')}", *args)
+ end
+
+ def plot_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'filled-rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'circle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'filled-circle', *(args.flatten))
+ self
+ end
+ end
+ Isometricplot = IsometricPlot
+
+ ############################
+ class Plot3D < TkCanvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, zaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # zaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ if parent.kind_of?(TkCanvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis),
+ array2tk_list(@yaxis),
+ array2tk_list(@zaxis))
+ end
+ private :_create_chart
+
+ def plot_function(cmd=Proc.new)
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
+ tk_call_without_enc(@chart, 'plotfunc', "#{@path}_#{@chart}")
+ self
+ end
+
+ def grid_size(nxcells, nycells)
+ tk_call_without_enc(@chart, 'gridsize', nxcells, nycells)
+ self
+ end
+
+ def plot_data(dat)
+ # dat has to be provided as a 2 level array.
+ # 1st level contains rows, drawn in y-direction,
+ # and each row is an array whose elements are drawn in x-direction,
+ # for the columns.
+ tk_call_without_enc(@chart, 'plotdata', dat)
+ self
+ end
+
+ def colour(fill, border)
+ # configure the colours to use for polygon borders and inner area
+ tk_call_without_enc(@chart, 'colour', fill, border)
+ self
+ end
+ alias colours colour
+ alias colors colour
+ alias color colour
+ end
+
+ ############################
+ class Piechart < TkCanvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPiechart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent] [, keys])
+ if args[0].kind_of?(TkCanvas)
+ parent = args.shift
+ @path = parent.path
+ else
+ super(*args) # create canvas widget
+ end
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path)
+ end
+ private :_create_chart
+
+ def plot(*dat) # argument is a list of [label, value]
+ tk_call_without_enc(@chart, 'plot', dat.flatten)
+ self
+ end
+ end
+
+ ############################
+ class Barchart < TkCanvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createBarchart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] xlabels, ylabels [, series] [, keys])
+ # xlabels, ylabels := labels | axis ( depend on normal or horizontal )
+ # labels := Array of [label, label, ...]
+ # (It determines the number of bars that will be plotted per series.)
+ # axis := Array of [minimum, maximum, stepsize]
+ # series := Integer number of data series | 'stacked' | :stacked
+ if args[0].kind_of?(Array)
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ if parent.kind_of?(TkCanvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xlabels), array2tk_list(@ylabels),
+ @series_size)
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ end
+
+ def plot(series, dat, col=None)
+ tk_call_without_enc(@chart, 'plot', series, dat, col)
+ self
+ end
+
+ def colours(*cols)
+ # set the colours to be used
+ tk_call_without_enc(@chart, 'colours', *cols)
+ self
+ end
+ alias colour colours
+ alias colors colours
+ alias color colours
+ end
+
+ ############################
+ class HorizontalBarchart < Barchart
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createHorizontalBarchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class Timechart < TkCanvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createTimechart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] time_begin, time_end, items [, keys])
+ # time_begin := String of time format (e.g. "1 january 2004")
+ # time_end := String of time format (e.g. "1 january 2004")
+ # items := Expected/maximum number of items
+ # ( This determines the vertical spacing. )
+ if args[0].kind_of?(Array)
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ if parent.kind_of?(TkCanvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ @time_begin, @time_end, @items)
+ end
+ private :_create_chart
+
+ def period(txt, time_begin, time_end, col=None)
+ tk_call_without_enc(@chart, 'period', txt, time_begin, time_end, col)
+ self
+ end
+
+ def milestone(txt, time, col=None)
+ tk_call_without_enc(@chart, 'milestone', txt, time, col)
+ self
+ end
+
+ def vertline(txt, time)
+ tk_call_without_enc(@chart, 'vertline', txt, time)
+ self
+ end
+ end
+
+ ############################
+ class PlotSeries < TkObject
+ SeriesID_TBL = TkCore::INTERP.create_table
+ Series_ID = ['series'.freeze, '00000'.taint].freeze
+ TkCore::INTERP.init_ip_env{ SeriesID_TBL.clear }
+
+ def self.id2obj(chart, id)
+ path = chart.path
+ return id unless SeriesID_TBL[path]
+ SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ end
+
+ def initialize(chart, keys=nil)
+ @parent = @chart_obj = chart
+ @ppath = @chart_obj.path
+ @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
+ # SeriesID_TBL[@id] = self
+ SeriesID_TBL[@ppath] = {} unless SeriesID_TBL[@ppath]
+ SeriesID_TBL[@ppath][@id] = self
+ Series_ID[1].succ!
+ dataconfig(keys) if keys.kind_of?(Hash)
+ end
+
+ def plot(*args)
+ @chart_obj.plot(@series, *args)
+ end
+
+ def dataconfig(key, value=None)
+ @chart_obj.dataconfig(@series, key, value)
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/setup.rb b/ext/tk/lib/tkextlib/tcllib/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tcllib/style.rb b/ext/tk/lib/tkextlib/tcllib/style.rb
new file mode 100644
index 0000000000..72a99d80fc
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/style.rb
@@ -0,0 +1,55 @@
+#
+# tkextlib/tcllib/style.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * select and use some 'style' of option (resource) DB
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk::Tcllib
+ module Style
+ def self.package_version
+ begin
+ TkPackage.require('style')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/style' extension is not available on your current environment."
+ end
+
+ def self.names
+ Tk::Tcllib::Style.not_available
+ end
+
+ def self.use(style)
+ Tk::Tcllib::Style.not_available
+ end
+ end
+end
+
+# TkPackage.require('style', '0.1')
+TkPackage.require('style')
+
+module Tk::Tcllib
+ class << Style
+ undef not_available
+ end
+
+ module Style
+ extend TkCore
+
+ def self.names
+ tk_split_simplelist(tk_call('style::names'))
+ end
+
+ def self.use(style)
+ tk_call('style::use', style)
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
new file mode 100644
index 0000000000..4e6008bb3b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
@@ -0,0 +1,287 @@
+#
+# tkextlib/tcllib/tkpiechart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Create 2D or 3D pies with labels in Tcl canvases
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tkpiechart', '6.6')
+TkPackage.require('tkpiechart')
+
+module Tk
+ module Tcllib
+ module Tkpiechart
+ end
+ end
+end
+
+module Tk::Tcllib::Tkpiechart
+ def self.package_version
+ begin
+ TkPackage.require('tkpiechart')
+ rescue
+ ''
+ end
+ end
+
+ module ConfigMethod
+ include TkConfigMethod
+
+ def __pathname
+ self.path + ';' + self.tag
+ end
+ private :__pathname
+
+ def __cget_cmd
+ ['::switched::cget', self.tag]
+ end
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ def __configinfo_struct
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>1, :current_value=>2}
+ end
+ private :__configinfo_struct
+ end
+
+ ####################################
+ class PieChartObj < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['titlefont']
+ end
+ private :__font_optkeys
+ end
+
+ ####################################
+ class Pie < TkcItem
+ include ConfigMethod
+
+ def create_self(x, y, width, height, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie',
+ @c, x, y, *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y)
+ end
+
+ @slice_tbl = {}
+
+ id = "pie(#{@tag_key})"
+
+ @tag = @tag_pie = TkcNamedTag(@c, id)
+ @tag_slices = TkcNamedTag(@c, "pieSlices(#{@tag_key})")
+
+ id
+ end
+ private :create_self
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def canvas
+ @c
+ end
+ def _entry_slice(slice)
+ @slice_tbl[slice.to_eval] = slice
+ end
+ def _delete_slice(slice)
+ @slice_tbl.delete(slice.to_eval)
+ end
+
+ def delete
+ tk_call_without_enc('::stooop::delete', @tag_key)
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ self
+ end
+
+ def new_slice(text=None)
+ Slice.new(self, text)
+ end
+
+ def delete_slice(slice)
+ unless slice.kind_of?(Slice)
+ unless (slice = @slice_tbl[slice])
+ return tk_call_without_enc('pie::deleteSlice', @tag_key, slice)
+ end
+ end
+ unless slice.kind_of?(Slice) && slice.pie == self
+ fail ArgumentError, "argument is not a slice of self"
+ end
+ slice.delete
+ end
+
+ def selected_slices
+ tk_split_simplelist(tk_call_without_enc('pie::selectedSlices',
+ @tag_key)).collect{|slice|
+ @slice_tbl[slice] || Slice.new(:no_create, self, slice)
+ }
+ end
+ end
+
+ ####################################
+ class Slice < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def initialize(pie, *args)
+ unless pie.kind_of?(Pie) && pie != :no_create
+ fail ArgumentError, "expects TkPiechart::Pie for 1st argument"
+ end
+
+ if pie == :no_create
+ @pie, @tag_key = args
+ else
+ text = args[0] || None
+ @pie = pie
+ @tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text)
+ end
+ @parent = @c = @pie.canvas
+ @path = @parent.path
+
+ @pie._entry_slice(self)
+
+ @id = "slices(#{@tag_key})"
+ @tag = TkcNamedTag.new(@pie.canvas, @id)
+
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ end
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def pie
+ @pie
+ end
+
+ def delete
+ tk_call_without_enc('pie::deleteSlice', @pie.tag_key, @tag_key)
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ @pie._delete_slice(self)
+ self
+ end
+
+ def size(share, disp=None)
+ tk_call_without_enc('pie::sizeSlice',
+ @pie.tag_key, @tag_key, share, disp)
+ self
+ end
+
+ def label(text)
+ tk_call_without_enc('pie::labelSlice', @pie.tag_key, @tag_key, text)
+ self
+ end
+ end
+
+ ####################################
+ class BoxLabeler < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler')
+ end
+
+ id = "pieBoxLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class PeripheralLabeler < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['font', 'smallfont']
+ end
+ private :__font_optkeys
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new',
+ 'piePeripheralLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler')
+ end
+
+ id = "piePeripheralLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class Label < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(x, y, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height,
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height)
+ end
+
+ id = "canvasLabel(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tclx.rb b/ext/tk/lib/tkextlib/tclx.rb
new file mode 100644
index 0000000000..3a4ff27644
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tclx.rb
@@ -0,0 +1,13 @@
+#
+# TclX support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tclx/setup.rb'
+
+# load library
+require 'tkextlib/tclx/tclx'
diff --git a/ext/tk/lib/tkextlib/tclx/setup.rb b/ext/tk/lib/tkextlib/tclx/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tclx/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tclx/tclx.rb b/ext/tk/lib/tkextlib/tclx/tclx.rb
new file mode 100644
index 0000000000..760ebd92b1
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tclx/tclx.rb
@@ -0,0 +1,59 @@
+#
+# tclx/tclx.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tclx/setup.rb'
+
+# TkPackage.require('Tclx', '8.0')
+TkPackage.require('Tclx')
+
+module Tk
+ module TclX
+ def self.package_version
+ begin
+ TkPackage.require('Tclx')
+ rescue
+ ''
+ end
+ end
+
+ def self.infox(*args)
+ Tk.tk_call('infox', *args)
+ end
+
+ ##############################
+
+ class XPG3_MsgCat
+ class << self
+ alias open new
+ end
+
+ def initialize(catname, fail_mode=false)
+ if fail_mode
+ @msgcat_id = Tk.tk_call('catopen', '-fail', catname)
+ else
+ @msgcat_id = Tk.tk_call('catopen', '-nofail', catname)
+ end
+ end
+
+ def close(fail_mode=false)
+ if fail_mode
+ Tk.tk_call('catclose', '-fail', @msgcat_id)
+ else
+ Tk.tk_call('catclose', '-nofail', @msgcat_id)
+ end
+ self
+ end
+
+ def get(setnum, msgnum, defaultstr)
+ Tk.tk_call('catgets', @msgcat_id, setnum, msgnum, defaultstr)
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb
new file mode 100644
index 0000000000..80a9083694
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile.rb
@@ -0,0 +1,69 @@
+#
+# Tile theme engin (tile widget set) support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# library directory
+require 'tkextlib/tile/setup.rb'
+
+# load package
+# TkPackage.require('tile', '0.4')
+TkPackage.require('tile')
+
+# autoload
+module Tk
+ module Tile
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ def self.package_version
+ begin
+ TkPackage.require('tile')
+ rescue
+ ''
+ end
+ end
+
+ module TileWidget
+ def instate(state, script=nil, &b)
+ if script
+ tk_send('instate', state, script)
+ elsif b
+ tk_send('instate', state, Proc.new(&b))
+ else
+ bool(tk_send('instate', state))
+ end
+ end
+
+ def state(state=nil)
+ if state
+ tk_send('state', state)
+ else
+ list(tk_send('state'))
+ end
+ end
+ end
+
+ ######################################
+
+ autoload :TButton, 'tkextlib/tile/tbutton'
+
+ autoload :TCheckButton, 'tkextlib/tile/tcheckbutton'
+ autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton'
+
+ autoload :TLabel, 'tkextlib/tile/tlabel'
+
+ autoload :TMenubutton, 'tkextlib/tile/tmenubutton'
+
+ autoload :TNotebook, 'tkextlib/tile/tnotebook'
+
+ autoload :TRadioButton, 'tkextlib/tile/tradiobutton'
+ autoload :TRadiobutton, 'tkextlib/tile/tradiobutton'
+
+ autoload :Style, 'tkextlib/tile/style'
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tile/setup.rb b/ext/tk/lib/tkextlib/tile/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb
new file mode 100644
index 0000000000..1e399182da
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/style.rb
@@ -0,0 +1,70 @@
+#
+# style commands
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ module Style
+ end
+ end
+end
+
+module Tk::Tile::Style
+ extend TkCore
+end
+
+class << Tk::Tile::Style
+ def default(style, keys=nil)
+ if keys && keys != None
+ tk_call('style', 'default', style, *hash_kv(keys))
+ else
+ tk_call('style', 'default', style)
+ end
+ end
+
+ def map(style, keys=nil)
+ if keys && keys != None
+ tk_call('style', 'map', style, *hash_kv(keys))
+ else
+ tk_call('style', 'map', style)
+ end
+ end
+
+ def layout(style, spec=nil)
+ if spec
+ tk_call('style', 'layout', style, spec)
+ else
+ tk_call('style', 'layout', style)
+ end
+ end
+
+ def element_create(name, type, *args)
+ tk_call('style', 'element', 'create', name, type, *args)
+ end
+
+ def element_names()
+ list(tk_call('style', 'element', 'names'))
+ end
+
+ def theme_create(name, keys=nil)
+ if keys && keys != None
+ tk_call('style', 'theme', 'create', name, type, *hash_kv(keys))
+ else
+ tk_call('style', 'theme', 'create', name, type)
+ end
+ end
+
+ def theme_settings(name, cmd=nil, &b)
+ end
+
+ def theme_names()
+ list(tk_call('style', 'theme', 'names'))
+ end
+
+ def theme_use(name)
+ tk_call('style', 'use', name)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tile/tbutton.rb b/ext/tk/lib/tkextlib/tile/tbutton.rb
new file mode 100644
index 0000000000..b5c3475692
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/tbutton.rb
@@ -0,0 +1,30 @@
+#
+# tbutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TButton < TkButton
+ end
+ end
+end
+
+class Tk::Tile::TButton < TkButton
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['tbutton'.freeze].freeze
+ WidgetClassName = 'TButton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('tbutton', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('tbutton', @path)
+ end
+ end
+ private :create_self
+end
diff --git a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
new file mode 100644
index 0000000000..4ba77d95d3
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
@@ -0,0 +1,31 @@
+#
+# tcheckbutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TCheckButton < TkCheckButton
+ end
+ TCheckbutton = TCheckButton
+ end
+end
+
+class Tk::Tile::TCheckButton < TkCheckButton
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['tcheckbutton'.freeze].freeze
+ WidgetClassName = 'TCheckbutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('tcheckbutton', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('tcheckbutton', @path)
+ end
+ end
+ private :create_self
+end
diff --git a/ext/tk/lib/tkextlib/tile/tlabel.rb b/ext/tk/lib/tkextlib/tile/tlabel.rb
new file mode 100644
index 0000000000..d2eaf45273
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/tlabel.rb
@@ -0,0 +1,30 @@
+#
+# tlabel widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TLabel < TkLabel
+ end
+ end
+end
+
+class Tk::Tile::TLabel < TkLabel
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['tlabel'.freeze].freeze
+ WidgetClassName = 'TLabel'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('tlabel', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('tlabel', @path)
+ end
+ end
+ private :create_self
+end
diff --git a/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/ext/tk/lib/tkextlib/tile/tmenubutton.rb
new file mode 100644
index 0000000000..332db2b74e
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/tmenubutton.rb
@@ -0,0 +1,30 @@
+#
+# tmenubutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TMenubutton < TkMenubutton
+ end
+ end
+end
+
+class Tk::Tile::TMenubutton < TkMenubutton
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['tmenubutton'.freeze].freeze
+ WidgetClassName = 'TMenubutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('tmenubutton', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('tmenubutton', @path)
+ end
+ end
+ private :create_self
+end
diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb
new file mode 100644
index 0000000000..c693d5ce2b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb
@@ -0,0 +1,92 @@
+#
+# tnotebook widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TNotebook < TkWindow
+ end
+ end
+end
+
+class Tk::Tile::TNotebook < TkWindow
+ ################################
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tabcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tabconfigure', id]
+ end
+ private :__item_config_cmd
+
+
+ def __item_listval_optkeys
+ []
+ end
+ private :__item_listval_optkeys
+
+ def __item_methodcall_optkeys # { key=>method, ... }
+ {}
+ end
+ private :__item_listval_optkeys
+
+ alias tabcget itemcget
+ alias tabconfigure itemconfigure
+ alias tabconfiginfo itemconfiginfo
+ alias current_tabconfiginfo current_itemconfiginfo
+ ################################
+
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['tnotebook'.freeze].freeze
+ WidgetClassName = 'TNotebook'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('tnotebook', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('tnotebook', @path)
+ end
+ end
+ private :create_self
+
+ def enable_traversal()
+ tk_call_without_end('tile::enableNotebookTraversal', @path)
+ self
+ end
+
+ def add(child, keys=nil)
+ if keys && keys != None
+ tk_send_without_enc('add', _epath(child), *hash_kv(keys))
+ else
+ tk_send_without_enc('add', _epath(child))
+ end
+ self
+ end
+
+ def forget(idx)
+ tk_send('forget', idx)
+ self
+ end
+
+ def index(idx)
+ number(tk_send('index', idx))
+ end
+
+ def select(idx)
+ tk_send('select', idx)
+ self
+ end
+
+ def tabs
+ list(tk_send('tabs'))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/ext/tk/lib/tkextlib/tile/tradiobutton.rb
new file mode 100644
index 0000000000..66cba62960
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tile/tradiobutton.rb
@@ -0,0 +1,31 @@
+#
+# tradiobutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TRadioButton < TkRadioButton
+ end
+ TRadiobutton = TRadioButton
+ end
+end
+
+class Tk::Tile::TRadioButton < TkRadioButton
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['tradiobutton'.freeze].freeze
+ WidgetClassName = 'TRadiobutton'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('tradiobutton', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('tradiobutton', @path)
+ end
+ end
+ private :create_self
+end
diff --git a/ext/tk/lib/tkextlib/tkDND.rb b/ext/tk/lib/tkextlib/tkDND.rb
new file mode 100644
index 0000000000..5d52e34418
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkDND.rb
@@ -0,0 +1,18 @@
+#
+# TkDND (Tk Drag & Drop Extension) support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+module Tk
+ module TkDND
+ autoload :DND, 'tkextlib/tkDND/tkdnd'
+ autoload :Shape, 'tkextlib/tkDND/shape'
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkDND/setup.rb b/ext/tk/lib/tkextlib/tkDND/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkDND/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tkDND/shape.rb b/ext/tk/lib/tkextlib/tkDND/shape.rb
new file mode 100644
index 0000000000..0f6a5f0a30
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkDND/shape.rb
@@ -0,0 +1,117 @@
+#
+# tkextlib/tkDND/shape.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+# TkPackage.require('shape', '0.3')
+TkPackage.require('shape')
+
+module Tk
+ module TkDND
+ module Shape
+ extend TkCore
+=begin
+ def self.package_version
+ begin
+ TkPackage.require('shape')
+ rescue
+ ''
+ end
+ end
+=end
+ def self.package_version
+ Tk.tk_call('set', 'shape_version')
+ end
+ alias shape_version package_version
+
+ def self.package_patchlevel
+ Tk.tk_call('set', 'shape_patchlevel')
+ end
+ alias shape_patchlevel package_patchlevel
+
+ def self.version
+ tk_call('shape', 'version')
+ end
+ alias xshape_version version
+
+ ############################
+
+ def shape_bounds(kind=nil)
+ if kind
+ ret = tk_call('shape', 'bounds', @path, "-#{kind}")
+ else
+ ret = tk_call('shape', 'bounds', @path)
+ end
+ if ret == ""
+ nil
+ else
+ list(ret)
+ end
+ end
+
+ def shape_get(kind=nil)
+ if kind
+ list(tk_call('shape', 'get', @path, "-#{kind}"))
+ else
+ list(tk_call('shape', 'get', @path))
+ end
+ end
+
+ def shape_offset(x, y, kind=nil)
+ if kind
+ tk_call('shape', 'get', @path, "-#{kind}", x, y)
+ else
+ tk_call('shape', 'get', @path, x, y)
+ end
+ self
+ end
+
+ def _parse_shapespec_param(args)
+ cmd = []
+
+ kind_keys = ['bounding', 'clip', 'both']
+ offset_keys = ['offset']
+ srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window']
+
+ cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s)
+
+ if offset_keys.member?(args[0].to_s)
+ cmd << "-#{args.shift}"
+ cmd << args.shift # xOffset
+ cmd << args.shift # yOffset
+ end
+
+ if srckind_keys.member?(args[0].to_s)
+ cmd << "-#{args.shift}"
+ end
+
+ cmd.concat(args)
+
+ cmd
+ end
+ private :_parse_shapespec_param
+
+ def shape_set(*args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
+ tk_call('shape', 'set', @path, *(_parse_shapespec_param(args)))
+ self
+ end
+
+ def shape_update(op, *args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
+ tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args)))
+ self
+ end
+ end
+ end
+end
+
+class TkWindow
+ include Tk::TkDND::Shape
+end
diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
new file mode 100644
index 0000000000..78381f8df0
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
@@ -0,0 +1,124 @@
+#
+# tkextlib/tkDND/tkdnd.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+TkPackage.require('tkdnd')
+
+module Tk
+ module TkDND
+ def self.package_version
+ begin
+ TkPackage.require('tkdnd')
+ rescue
+ ''
+ end
+ end
+
+ class DND_Subst < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?a, ?l, :actions ],
+ [ ?A, ?s, :action ],
+ [ ?b, ?L, :codes ],
+ [ ?c, ?s, :code ],
+ [ ?d, ?l, :descriptions ],
+ [ ?D, ?l, :data ],
+ [ ?L, ?l, :source_types ],
+ [ ?m, ?l, :modifiers ],
+ [ ?t, ?l, :types ],
+ [ ?T, ?s, :type ],
+ [ ?W, ?w, :widget ],
+ [ ?x, ?n, :x ],
+ [ ?X, ?n, :x_root ],
+ [ ?y, ?n, :y ],
+ [ ?Y, ?n, :y_root ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?l, TkComm.method(:list) ],
+ [ ?L, TkComm.method(:simplelist) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+ # setup tables
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ module DND
+ def self.version
+ begin
+ TkPackage.require('tkdnd')
+ rescue
+ ''
+ end
+ end
+
+ def dnd_bindtarget_info(type=nil, event=nil)
+ if event
+ procedure(tk_call('dnd', 'bindtarget', @path, type, event))
+ elsif type
+ procedure(tk_call('dnd', 'bindtarget', @path, type))
+ else
+ simplelist(tk_call('dnd', 'bindtarget', @path))
+ end
+ end
+
+ def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args)
+ event = tk_event_sequence(event)
+ if prior.kind_of?(Numeric)
+ tk_call('dnd', 'bindtarget', @path, type, event,
+ install_bind_for_event_class(DND_Subst, cmd, *args),
+ prior)
+ else
+ tk_call('dnd', 'bindtarget', @path, type, event,
+ install_bind_for_event_class(DND_Subst, cmd, prior, *args))
+ end
+ self
+ end
+
+ def dnd_cleartarget
+ tk_call('dnd', 'cleartarget', @path)
+ self
+ end
+
+ def dnd_bindsource_info(type=nil)
+ if type
+ procedure(tk_call('dnd', 'bindsource', @path, type))
+ else
+ simplelist(tk_call('dnd', 'bindsource', @path))
+ end
+ end
+
+ def dnd_bindsource(type, cmd=Proc.new, prior=None)
+ tk_call('dnd', 'bindsource', @path, type, cmd, prior)
+ self
+ end
+
+ def dnd_clearsource()
+ tk_call('dnd', 'clearsource', @path)
+ self
+ end
+
+ def dnd_drag(keys=nil)
+ tk_call('dnd', 'drag', @path, *hash_kv(keys))
+ self
+ end
+ end
+ end
+end
+
+class TkWindow
+ include Tk::TkDND::DND
+end
diff --git a/ext/tk/lib/tkextlib/tkHTML.rb b/ext/tk/lib/tkextlib/tkHTML.rb
new file mode 100644
index 0000000000..5fddde72ff
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkHTML.rb
@@ -0,0 +1,13 @@
+#
+# TkHtml support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkHTML/setup.rb'
+
+# load library
+require 'tkextlib/tkHTML/htmlwidget'
diff --git a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
new file mode 100644
index 0000000000..b9a203575a
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
@@ -0,0 +1,433 @@
+#
+# tkextlib/tkHTML/htmlwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkHTML/setup.rb'
+
+# TkPackage.require('Tkhtml', '2.0')
+TkPackage.require('Tkhtml')
+
+module Tk
+ class HTML_Widget < TkWindow
+ def self.package_version
+ begin
+ TkPackage.require('Tkhtml')
+ rescue
+ ''
+ end
+ end
+
+ class ClippingWindow < TkWindow
+ end
+ end
+end
+
+class Tk::HTML_Widget::ClippingWindow
+ WidgetClassName = 'HtmlClip'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ HtmlClip_TBL = TkCore::INTERP.create_table
+ TkCore::INTERP.init_ip_env{ HtmlClip_TBL.clear }
+
+ def self.new(parent, keys={})
+ if parent.kind_of?(Hash)
+ keys = TkComm._symbolkey2str(parent)
+ parent = keys.delete('parent')
+ end
+
+ if parent.kind_of?(String)
+ ppath = parent.path
+ elsif parent
+ ppath = parent
+ else
+ ppath = ''
+ end
+ return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath]
+
+ widgetname = keys.delete('widgetname')
+ if widgetname =~ /^(.*)\.[^.]+$/
+ ppath2 = $1
+ if ppath2[0] != ?.
+ ppath2 = ppath + '.' + ppath2
+ end
+ return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
+
+ ppath = ppath2
+ end
+
+ parent = TkComm._genobj_for_tkwidget(ppath)
+ unless parent.kind_of?(Tk::HTML_Widget)
+ fail ArgumentError, "parent must be a Tk::HTML_Widget instance"
+ end
+
+ super(parent)
+ end
+
+ def initialize(parent)
+ @parent = parent
+ @ppath = parent.path
+ @path = @id = @ppath + '.x'
+ HtmlClip_TBL[@ppath] = self
+ end
+
+ def method_missing(m, *args, &b)
+ @parent.__send__(m, *args, &b)
+ end
+end
+
+class Tk::HTML_Widget
+ include Scrollable
+
+ TkCommandNames = ['html'.freeze].freeze
+ WidgetClassName = 'Html'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('html', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('html', @path)
+ end
+ end
+ private :create_self
+
+ ###################################
+ # class methods
+ ###################################
+ def self.reformat(src, dst, txt)
+ tk_call('html', 'reformat', src, dst, txt)
+ end
+
+ def self.url_join(*args) # args := sheme authority path query fragment
+ tk_call('html', 'urljoin', *args)
+ end
+
+ def self.url_split(uri)
+ tk_call('html', 'urlsplit', uri)
+ end
+
+ def self.lockcopy(src, dst)
+ tk_call('html', 'lockcopy', src, dst)
+ end
+
+ def self.gzip_file(file, dat)
+ tk_call('html', 'gzip', 'file', file, dat)
+ end
+
+ def self.gunzip_file(file, dat)
+ tk_call('html', 'gunzip', 'file', filet)
+ end
+
+ def self.gzip_data(dat)
+ tk_call('html', 'gzip', 'data', file, dat)
+ end
+
+ def self.gunzip_data(dat)
+ tk_call('html', 'gunzip', 'data', filet)
+ end
+
+ def self.base64_encode(dat)
+ tk_call('html', 'base64', 'encode', dat)
+ end
+
+ def self.base64_decode(dat)
+ tk_call('html', 'base64', 'encode', dat)
+ end
+
+ def self.text_format(dat, len)
+ tk_call('html', 'text', 'format', dat, len)
+ end
+
+ def self.xor(cmd, *args)
+ tk_call('html', 'xor', cmd, *args)
+ end
+
+ def self.stdchan(cmd, channel)
+ tk_call('html', 'stdchan', cmd, channel)
+ end
+
+ def self.crc32(data)
+ tk_call('html', 'crc32', data)
+ end
+
+ ###################################
+ # instance methods
+ ###################################
+ def clipping_window
+ ClippingWindow.new(self)
+ end
+ alias clipwin clipping_window
+ alias htmlclip clipping_window
+
+ def bgimage(image, tid=None)
+ tk_send('bgimage', image, tid)
+ self
+ end
+
+ def clear()
+ tk_send('clear')
+ self
+ end
+
+ def coords(index=None, percent=None)
+ tk_send('coords', index, percent)
+ end
+
+ def forminfo(*args)
+ tk_send('forminfo', *args)
+ end
+ alias form_info forminfo
+
+ def href(x, y)
+ simplelist(tk_send('href', x, y))
+ end
+
+ def image_add(id, img)
+ tk_send('imageadd', id, img)
+ self
+ end
+
+ def image_at(x, y)
+ tk_send('imageat', x, y)
+ end
+
+ def images()
+ list(tk_send('images'))
+ end
+
+ def image_set(id, num)
+ tk_send('imageset', id, num)
+ self
+ end
+
+ def image_update(id, imgs)
+ tk_send('imageupdate', id, imgs)
+ self
+ end
+
+ def index(idx, count=None, unit=None)
+ tk_send('index', idx, count, unit)
+ end
+
+ def insert_cursor(idx)
+ tk_send('insert', idx)
+ end
+
+ def names()
+ simple_list(tk_send('names'))
+ end
+
+ def on_screen(id, x, y)
+ bool(tk_send('onscreen', id, x, y))
+ end
+
+ def over(x, y)
+ list(tk_send('over', x, y))
+ end
+
+ def over_markup(x, y)
+ list(tk_send('over', x, y, '-muponly'))
+ end
+
+ def over_attr(x, y, attrs)
+ list(tk_send('overattr', x, y, attrs))
+ end
+
+ def parse(txt)
+ tk_send('parse', txt)
+ self
+ end
+
+ def resolver(*uri_args)
+ tk_send('resolver', *uri_args)
+ end
+
+ def selection_clear()
+ tk_send('selection', 'clear')
+ self
+ end
+
+ def selection_set(first, last)
+ tk_send('selection', 'set', first, last)
+ self
+ end
+
+ def refresh(*opts)
+ tk_send('refresh', *opts)
+ end
+
+ def layout()
+ tk_send('layout')
+ end
+
+ def sizewindow(*args)
+ tk_send('sizewindow', *args)
+ end
+
+ def postscript(*args)
+ tk_send('postscript', *args)
+ end
+
+ def source()
+ tk_send('source')
+ end
+
+ def plain_text(first, last)
+ tk_send('text', 'ascii', first, last)
+ end
+ alias ascii_text plain_text
+ alias text_ascii plain_text
+
+ def text_delete(first, last)
+ tk_send('text', 'delete', first, last)
+ self
+ end
+
+ def html_text(first, last)
+ tk_send('text', 'html', first, last)
+ end
+ alias text_html html_text
+
+ def text_insert(idx, txt)
+ tk_send('text', 'insert', idx, txt)
+ self
+ end
+
+ def break_text(idx)
+ tk_send('text', 'break', idx)
+ end
+ alias text_break break_text
+
+ def text_find(txt, *args)
+ tk_send('text', 'find', txt, *args)
+ end
+
+ def text_table(idx, imgs=None, attrs=None)
+ tk_send('text', 'table', idx, imgs, attrs)
+ end
+
+ def token_append(tag, *args)
+ tk_send('token', 'append', tag, *args)
+ self
+ end
+
+ def token_delete(first, last=None)
+ tk_send('token', 'delete', first, last)
+ self
+ end
+
+ def token_define(*args)
+ tk_send('token', 'defile', *args)
+ self
+ end
+
+ def token_find(tag, *args)
+ list(tk_send('token', 'find', tag, *args))
+ end
+
+ def token_get(first, last=None)
+ list(tk_send('token', 'get', first, last))
+ end
+
+ def token_list(first, last=None)
+ list(tk_send('token', 'list', first, last))
+ end
+
+ def token_markup(first, last=None)
+ list(tk_send('token', 'markup', first, last))
+ end
+
+ def token_DOM(first, last=None)
+ list(tk_send('token', 'domtokens', first, last))
+ end
+ alias token_dom token_DOM
+ alias token_domtokens token_DOM
+ alias token_dom_tokens token_DOM
+
+ def token_get_end(idx)
+ tk_send('token', 'getend', idx)
+ end
+ alias token_getend token_get_end
+
+ def token_offset(start, num1, num2)
+ list(tk_send('token', 'offset', start, num1, num2))
+ end
+
+ def token_get_attr(idx, name=None)
+ list(tk_send('token', 'attr', idx, name))
+ end
+
+ def token_set_attr(idx, name=None, val=None)
+ tk_send('token', 'attr', idx, name, val)
+ self
+ end
+
+ def token_handler(tag, cmd=nil, &b)
+ cmd = Proc.new(&b) if !cmd && b
+ if cmd
+ tk_send('token', 'handler', tag, cmd)
+ return self
+ else
+ return tk_send('token', 'handler', tag)
+ end
+ end
+
+ def token_insert(idx, tag, *args)
+ tk_send('token', 'insert', idx, tag, *args)
+ self
+ end
+
+ def token_attrs(*args)
+ list(tk_send('token', 'attrs', *args))
+ end
+
+ def token_unique(*args)
+ list(tk_send('token', 'unique', *args))
+ end
+
+ def token_on_events(*args)
+ list(tk_send('token', 'onEvents', *args))
+ end
+
+ def dom_nameidx(tag, name)
+ number(tk_send('dom', 'nameidx', tag, name))
+ end
+ alias dom_name_index dom_nameidx
+
+ def dom_radioidx(tag, name)
+ number(tk_send('dom', 'radioidx', tag, name))
+ end
+ alias dom_radio_index dom_radioidx
+
+ def dom_id(*spec)
+ tk_send('dom', 'id', *spec)
+ end
+
+ def dom_ids(*spec)
+ list(tk_send('dom', 'ids', *spec))
+ end
+
+ def dom_value(*spec)
+ list(tk_send('dom', 'value', *spec))
+ end
+
+ def dom_attr(idx)
+ tk_send('dom', 'attr', idx)
+ end
+
+ def dom_formel(name)
+ tk_send('dom', 'formel', name)
+ end
+ alias dom_form_element dom_formel
+
+ def dom_tree(idx, val)
+ list(tk_send('dom', 'tree', idx, val))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkHTML/setup.rb b/ext/tk/lib/tkextlib/tkHTML/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkHTML/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tkimg.rb b/ext/tk/lib/tkextlib/tkimg.rb
new file mode 100644
index 0000000000..ffeafbb58e
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg.rb
@@ -0,0 +1,31 @@
+#
+# TkImg extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('Img', '1.3')
+TkPackage.require('Img')
+
+module Tk
+ module Img
+ def self.package_version
+ begin
+ TkPackage.require('Img')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+# autoload
+autoload :TkPixmapImage, 'tkextlib/tkimg/pixmap'
diff --git a/ext/tk/lib/tkextlib/tkimg/README b/ext/tk/lib/tkextlib/tkimg/README
new file mode 100644
index 0000000000..65d36365d0
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/README
@@ -0,0 +1,26 @@
+
+ [ Tcl/Tk Image formats (TkImg) support ]
+
+TkImg contains a collection of format handlers for the Tk photo
+image type, and a new image type, pixmaps.
+
+Supported formats of TkImg version 1.3 are
+-------------------------------------------------------
+ bmp : Windows Bitmap Format
+ gif : Graphics Interchange Format
+ ico : Windows Icon Format
+ jpeg : Joint Picture Expert Group format
+ pcx : Paintbrush Format
+ pixmap : Pixmap Image type
+ png : Portable Network Graphics format
+ ppm : Portable Pixmap format
+ ps : Adobe PostScript Format
+ sgi : SGI Native Format
+ sun : Sun Raster Format
+ tga : Truevision Targa Format
+ tiff : Tagged Image File Format
+ window : Tk Windows
+ xbm : X Window Bitmap Format
+ xpm : X Window Pixmap Format
+-------------------------------------------------------
+
diff --git a/ext/tk/lib/tkextlib/tkimg/bmp.rb b/ext/tk/lib/tkextlib/tkimg/bmp.rb
new file mode 100644
index 0000000000..581483f8f4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/bmp.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'bmp'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+#TkPackage.require('img::bmp', '1.3')
+TkPackage.require('img::bmp')
+
+module Tk
+ module Img
+ module BMP
+ def self.package_version
+ begin
+ TkPackage.require('img::bmp')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/gif.rb b/ext/tk/lib/tkextlib/tkimg/gif.rb
new file mode 100644
index 0000000000..6ef18f8e90
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/gif.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'gif'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::gif', '1.3')
+TkPackage.require('img::gif')
+
+module Tk
+ module Img
+ module GIF
+ def self.package_version
+ begin
+ TkPackage.require('img::gif')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/ico.rb b/ext/tk/lib/tkextlib/tkimg/ico.rb
new file mode 100644
index 0000000000..1e3cb5f497
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/ico.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'ico'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ico', '1.3')
+TkPackage.require('img::ico')
+
+module Tk
+ module Img
+ module ICO
+ def self.package_version
+ begin
+ TkPackage.require('img::ico')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/jpeg.rb b/ext/tk/lib/tkextlib/tkimg/jpeg.rb
new file mode 100644
index 0000000000..017c93ee0e
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/jpeg.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'jpeg'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::jpeg', '1.3')
+TkPackage.require('img::jpeg')
+
+module Tk
+ module Img
+ module JPEG
+ def self.package_version
+ begin
+ TkPackage.require('img::jpeg')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/pcx.rb b/ext/tk/lib/tkextlib/tkimg/pcx.rb
new file mode 100644
index 0000000000..e924d48869
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/pcx.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'pcx'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::pcx', '1.3')
+TkPackage.require('img::pcx')
+
+module Tk
+ module Img
+ module PCX
+ def self.package_version
+ begin
+ TkPackage.require('img::pcx')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/ext/tk/lib/tkextlib/tkimg/pixmap.rb
new file mode 100644
index 0000000000..f9aaa65a9b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/pixmap.rb
@@ -0,0 +1,39 @@
+#
+# TkImg - format 'pixmap'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::pixmap', '1.3')
+TkPackage.require('img::pixmap')
+
+module Tk
+ module Img
+ module PIXMAP
+ def self.package_version
+ begin
+ TkPackage.require('img::pixmap')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class TkPixmapImage<TkImage
+ def self.version
+ Tk::Img::PIXMAP.version
+ end
+
+ def initialize(*args)
+ @type = 'pixmap'
+ super
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/png.rb b/ext/tk/lib/tkextlib/tkimg/png.rb
new file mode 100644
index 0000000000..b155836395
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/png.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'png'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::png', '1.3')
+TkPackage.require('img::png')
+
+module Tk
+ module Img
+ module PNG
+ def self.package_version
+ begin
+ TkPackage.require('img::png')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/ppm.rb b/ext/tk/lib/tkextlib/tkimg/ppm.rb
new file mode 100644
index 0000000000..df56baee4a
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/ppm.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'ppm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ppm', '1.3')
+TkPackage.require('img::ppm')
+
+module Tk
+ module Img
+ module PPM
+ def self.package_version
+ begin
+ TkPackage.require('img::ppm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/ps.rb b/ext/tk/lib/tkextlib/tkimg/ps.rb
new file mode 100644
index 0000000000..3025066eb4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/ps.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'ps'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ps', '1.3')
+TkPackage.require('img::ps')
+
+module Tk
+ module Img
+ module PS
+ def self.package_version
+ begin
+ TkPackage.require('img::ps')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/setup.rb b/ext/tk/lib/tkextlib/tkimg/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tkimg/sgi.rb b/ext/tk/lib/tkextlib/tkimg/sgi.rb
new file mode 100644
index 0000000000..e505c87e8b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/sgi.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'sgi'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::sgi', '1.3')
+TkPackage.require('img::sgi')
+
+module Tk
+ module Img
+ module SGI
+ def self.package_version
+ begin
+ TkPackage.require('img::sgi')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/sun.rb b/ext/tk/lib/tkextlib/tkimg/sun.rb
new file mode 100644
index 0000000000..25bfea8fb7
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/sun.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'sun'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::sun', '1.3')
+TkPackage.require('img::sun')
+
+module Tk
+ module Img
+ module SUN
+ def self.package_version
+ begin
+ TkPackage.require('img::sun')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/tga.rb b/ext/tk/lib/tkextlib/tkimg/tga.rb
new file mode 100644
index 0000000000..e3f84c3714
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/tga.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'tga'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::tga', '1.3')
+TkPackage.require('img::tga')
+
+module Tk
+ module Img
+ module TGA
+ def self.package_version
+ begin
+ TkPackage.require('img::tga')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/tiff.rb b/ext/tk/lib/tkextlib/tkimg/tiff.rb
new file mode 100644
index 0000000000..e7e12406ac
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/tiff.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'tiff'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::tiff', '1.3')
+TkPackage.require('img::tiff')
+
+module Tk
+ module Img
+ module TIFF
+ def self.package_version
+ begin
+ TkPackage.require('img::tiff')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/window.rb b/ext/tk/lib/tkextlib/tkimg/window.rb
new file mode 100644
index 0000000000..00ed7d1b86
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/window.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'window'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::window', '1.3')
+TkPackage.require('img::window')
+
+module Tk
+ module Img
+ module WINDOW
+ def self.package_version
+ begin
+ TkPackage.require('img::window')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/xbm.rb b/ext/tk/lib/tkextlib/tkimg/xbm.rb
new file mode 100644
index 0000000000..08b1b9876b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/xbm.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'xbm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::xbm', '1.3')
+TkPackage.require('img::xbm')
+
+module Tk
+ module Img
+ module XBM
+ def self.package_version
+ begin
+ TkPackage.require('img::xbm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tkimg/xpm.rb b/ext/tk/lib/tkextlib/tkimg/xpm.rb
new file mode 100644
index 0000000000..e29c1d554f
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tkimg/xpm.rb
@@ -0,0 +1,28 @@
+#
+# TkImg - format 'xpm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::xpm', '1.3')
+TkPackage.require('img::xpm')
+
+module Tk
+ module Img
+ module XPM
+ def self.package_version
+ begin
+ TkPackage.require('img::xpm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tktable.rb b/ext/tk/lib/tkextlib/tktable.rb
new file mode 100644
index 0000000000..385eb13497
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tktable.rb
@@ -0,0 +1,14 @@
+#
+# TkTable support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# load library
+require 'tkextlib/tktable/tktable'
diff --git a/ext/tk/lib/tkextlib/tktable/setup.rb b/ext/tk/lib/tkextlib/tktable/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tktable/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tktable/tktable.rb b/ext/tk/lib/tkextlib/tktable/tktable.rb
new file mode 100644
index 0000000000..2f2b14a69f
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tktable/tktable.rb
@@ -0,0 +1,796 @@
+#
+# tkextlib/tktable/tktable.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/validation'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# TkPackage.require('Tktable', '2.8')
+TkPackage.require('Tktable')
+
+module Tk
+ class TkTable < TkWindow
+ def self.package_version
+ begin
+ TkPackage.require('Tktable')
+ rescue
+ ''
+ end
+ end
+
+ class CellTag < TkObject
+ end
+
+ module ConfigMethod
+ end
+ end
+end
+
+module Tk::TkTable::ConfigMethod
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'cget', id[1]]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'configure', id[1]]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def tag_cget(tagOrId, option)
+ itemcget(['tag', tagid(tagOrId)], option)
+ end
+ def tag_configure(tagOrId, slot, value=None)
+ itemconfigure(['tag', tagid(tagOrId)], slot, value)
+ end
+ def tag_configinfo(tagOrId, slot=nil)
+ itemconfigure(['tag', tagid(tagOrId)], slot)
+ end
+ def current_tag_configinfo(tagOrId, slot=nil)
+ itemconfigure(['tag', tagid(tagOrId)], slot)
+ end
+
+ def window_cget(tagOrId, option)
+ itemcget(['window', tagid(tagOrId)], option)
+ end
+ def window_configure(tagOrId, slot, value=None)
+ itemconfigure(['window', tagid(tagOrId)], slot, value)
+ end
+ def window_configinfo(tagOrId, slot=nil)
+ itemconfigure(['window', tagid(tagOrId)], slot)
+ end
+ def current_window_configinfo(tagOrId, slot=nil)
+ itemconfigure(['window', tagid(tagOrId)], slot)
+ end
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+end
+
+#####################################################
+
+class Tk::TkTable::CellTag
+ include TkTreatTagFont
+
+ CellTagID_TBL = TkCore::INTERP.create_table
+ CellTag_ID = ['tktbl:celltag'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{ CellTagID_TBL.clear }
+
+ def self.id2obj(table, id)
+ tpath = table.path
+ return id unless CellTagID_TBL[tpath]
+ CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
+ end
+
+ def initialize(parent, keys=nil)
+ @parent = @t = parent
+ @tpath - parent.path
+ @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ CellTag_ID[1].succ!
+ configure(keys) if keys
+ end
+
+ def id
+ @id
+ end
+
+ def destroy
+ tk_call(@tpath, 'tag', 'delete', @id)
+ CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
+ self
+ end
+ alias delete destroy
+
+ def exist?
+ @t.tag_exist?(@id)
+ end
+ def include?(idx)
+ @t.tag_include?(@id, idx)
+ end
+
+ def add_cell(*args)
+ @t.tag_cell(@id, *args)
+ end
+ def add_col(*args)
+ @t.tag_col(@id, *args)
+ end
+ def add_row(*args)
+ @t.tag_row(@id, *args)
+ end
+
+ def raise(target=None)
+ @t.tag_raise(@id, target)
+ end
+ def lower(target=None)
+ @t.tag_lower(@id, target)
+ end
+
+ def cget(key)
+ @t.tag_cget(@id, key)
+ end
+ def configure(key, val=None)
+ @t.tag_configure(@id, key, val)
+ end
+ def configinfo(key=nil)
+ @t.tag_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @t.current_tag_configinfo(@id, key)
+ end
+end
+
+class Tk::TkTable::NamedCellTag < Tk::TkTable::CellTag
+ def self.new(parent, name, keys=nil)
+ if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
+ cell = CellTagID_TBL[parent.path][name]
+ cell.configure(keys) if keys
+ return cell
+ else
+ super(parent, name, keys)
+ end
+ end
+
+ def initialize(parent, name, keys=nil)
+ @parent = @t = parent
+ @tpath - parent.path
+ @path = @id = name
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ configure(keys) if keys
+ end
+end
+
+#####################################################
+
+class Tk::TkTable
+ TkCommandNames = ['table'.freeze].freeze
+ WidgetClassName = 'Table'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ include Scrollable
+ include Tk::TkTable::ConfigMethod
+ include Tk::ValidateConfigure
+
+ def __destroy_hook__
+ Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
+ end
+
+ #################################
+
+ class BrowseCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?x, :cursor ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?s, :last_index ],
+ [ ?S, ?s, :new_index ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['browsecommand', 'browsecmd']
+ end
+ end
+ #--------------------------------
+ class CellCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?m, :rw_mode ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?v, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ [ ?m, proc{|val| (val == '0')? (:r) : (:w)} ],
+ [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ TkComm._get_eval_string(val)
+ end
+ end
+
+ def self._config_keys
+ ['command']
+ end
+ end
+ #--------------------------------
+ class SelectionCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :sel_columns ],
+ [ ?C, ?s, :sel_area ],
+ [ ?i, ?n, :total ],
+ [ ?r, ?n, :sel_rows ],
+ [ ?s, ?s, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val.to_s
+ end
+ end
+
+ def self._config_keys
+ ['selectioncommand', 'selcmd']
+ end
+ end
+ #--------------------------------
+ class ValidateCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?x, :cursor ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?v, :current_value ],
+ [ ?S, ?v, :new_value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['vcmd', 'validatecommand']
+ end
+ end
+
+ #################################
+
+ def __validation_class_list
+ super <<
+ BrowseCommand << CellCommand << SelectionCommand << ValidateCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, BrowseCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, CellCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, SelectionCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, ValidateCommand)
+
+ #################################
+
+ def activate(idx)
+ tk_send('activate', tagid(idx))
+ end
+
+ def bbox(idx)
+ list(tk_send('bbox', tagid(idx)))
+ end
+
+ def border_mark(x, y)
+ simplelist(tk_send('scan', 'mark', x, y))
+ end
+ def border_mark_row(x, y)
+ tk_send('scan', 'mark', x, y, 'row')
+ end
+ def border_mark_col(x, y)
+ tk_send('scan', 'mark', x, y, 'col')
+ end
+ def border_dragto(x, y)
+ tk_send('scan', 'dragto', x, y)
+ end
+
+ def clear_cache(first=None, last=None)
+ tk_send('clear', 'cache', tagid(first), tagid(last))
+ self
+ end
+ def clear_sizes(first=None, last=None)
+ tk_send('clear', 'sizes', tagid(first), tagid(last))
+ self
+ end
+ def clear_tags(first=None, last=None)
+ tk_send('clear', 'tags', tagid(first), tagid(last))
+ self
+ end
+ def clear_all(first=None, last=None)
+ tk_send('clear', 'all', tagid(first), tagid(last))
+ self
+ end
+
+ def curselection
+ simplelist(tk_send('curselection'))
+ end
+ def curselection=(val)
+ tk_send('curselection', val)
+ val
+ end
+
+ def curvalue
+ tk_tcl2ruby(tk_send('curvalue'), true, false)
+ end
+ def curvalue=(val)
+ tk_send('curvalue', val)
+ val
+ end
+
+ def delete_active(idx1, idx2=None)
+ tk_send('delete', 'active', tagid(idx1), tagid(idx2))
+ self
+ end
+ def delete_cols(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('delete', 'cols', *params)
+ self
+ end
+ def delete_rows(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('delete', 'rows', *params)
+ self
+ end
+
+ def get(idx)
+ tk_tcl2ruby(tk_send('get', tagid(idx)), true, false)
+ end
+ def get_area(idx1, idx2)
+ simplelist(tk_send('get', tagid(idx1), tagid(idx2))).collect{|v|
+ tk_tcl2ruby(v, true, false)
+ }
+ end
+
+ def height_list
+ list(tk_send('height'))
+ end
+ def height(row)
+ number(tk_send('height', row))
+ end
+ def set_height(*pairs)
+ tk_send('height', *(pairs.flatten))
+ self
+ end
+
+ def hidden_list
+ simplelist(tk_send('hidden'))
+ end
+ def hidden?(idx, *args)
+ if args.empty?
+ if (ret = tk_send('hidden', tagid(idx))) == ''
+ false
+ else
+ ret
+ end
+ else
+ bool(tk_send('hidden', tagid(idx), *(args.collect{|i| tagid(i)})))
+ end
+ end
+
+ def icursor
+ number(tk_send('icursor'))
+ end
+ def icursor_set(idx)
+ number(tk_send('icursor', tagid(idx)))
+ end
+
+ def index(idx)
+ tk_send('index', tagid(idx))
+ end
+ def row_index(idx)
+ number(tk_send('index', tagid(idx), 'row'))
+ end
+ def col_index(idx)
+ number(tk_send('index', tagid(idx), 'col'))
+ end
+
+ def insert_active(idx, val)
+ tk_send('insert', 'active', tagid(idx), val)
+ self
+ end
+ def insert_cols(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params.concat(args)
+ params << tagid(args.shift)
+ tk_send('insert', 'cols', *params)
+ self
+ end
+ def insert_rows(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('insert', 'rows', *params)
+ self
+ end
+
+ # def postscript(*args)
+ # tk_send('postscript', *args)
+ # end
+
+ def reread
+ tk_send('reread')
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(idx)
+ tk_send('see', tagid(idx))
+ self
+ end
+
+ def selection_anchor(idx)
+ tk_send('selection', 'anchor', tagid(idx))
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send('selection', 'clear', tagid(first), tagid(last))
+ self
+ end
+ def selection_clear_all
+ selection_clear('all')
+ end
+ def selection_include?(idx)
+ bool(tk_send('selection', 'includes', tagid(idx)))
+ end
+ def selection_set(first, last=None)
+ tk_send('selection', 'set', tagid(first), tagid(last))
+ self
+ end
+
+ def set(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', *args)
+ self
+ end
+ def set_row(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'row', *args)
+ self
+ end
+ def set_col(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'col', *args)
+ self
+ end
+=begin
+ def set(*pairs) # idx, val, idx, val, ... OR [idx, val], [idx, val], ...
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << tagid(idx) << val }
+ tk_send('set', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', *args)
+ end
+ self
+ end
+ def set_row(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << tagid(idx) << val }
+ tk_send('set', 'row', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'row', *args)
+ end
+ self
+ end
+ def set_col(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << idx << val }
+ tk_send('set', 'col', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'col', *args)
+ end
+ self
+ end
+=end
+
+ def spans
+ simplelist(tk_send('spans')).collect{|inf|
+ lst = simplelist(inf)
+ idx = lst[0]
+ rows, cols = lst[1].split(',').map!{|n| Integer(n)}
+ [idx [rows, cols]]
+ }
+ end
+ alias span_list spans
+ def span(idx)
+ lst = simplelist(tk_send('spans', tagid(idx)))
+ idx = lst[0]
+ rows, cols = lst[1].split(',').map!{|n| Integer(n)}
+ [idx [rows, cols]]
+ end
+ def set_spans(*pairs)
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ val = pairs[i+1]
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ self
+ end
+=begin
+ def set_spans(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val|
+ args << tagid(idx)
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ val = pairs[i+1]
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ end
+ self
+ end
+=end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::TkTable::CellTag)
+ tag.id
+ elsif tag.kind_of?(Array)
+ if tag[0].kind_of?(Integer) && tag[1].kind_of?(Integer)
+ # [row, col]
+ tag.join(',')
+ else
+ tag
+ end
+ else
+ tag
+ end
+ end
+
+ def tagid2obj(tagid)
+ if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
+ Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
+ else
+ tagid
+ end
+ else
+ tagid
+ end
+ end
+
+ def tag_cell(tag, *cells)
+ tk_send('tag', 'cell', tagid(tag), *(cells.collect{|idx| tagid(idx)}))
+ self
+ end
+ def tag_reset(*cells)
+ tk_send('tag', 'cell', '', *(cells.collect{|idx| tagid(idx)}))
+ self
+ end
+ def tag_col(tag, *cols)
+ tk_send('tag', 'col', tagid(tag), *cols)
+ self
+ end
+ def tag_col_reset(*cols)
+ tk_send('tag', 'col', '', *cols)
+ self
+ end
+ def tag_delete(tag)
+ tk_send('tag', 'delete', tagid(tag))
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path]
+ if tag.kind_of? Tk::TkTable::CellTag
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
+ else
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
+ end
+ end
+ self
+ end
+ def tag_exist?(tag)
+ bool(tk_send('tag', 'exists', tagid(tag)))
+ end
+ def tag_include?(tag, idx)
+ bool(tk_send('tag', 'includes', tagid(tag), tagid(idx)))
+ end
+ def tag_lower(tag, target=None)
+ tk_send('tag', 'lower', tagid(tag), tagid(target))
+ self
+ end
+ def tag_names(pat=None)
+ simplelist(tk_send('tag', 'names', pat)).collect{|tag| tagid2obj(tag)}
+ end
+ def tag_raise(tag, target=None)
+ tk_send('tag', 'raise', tagid(tag), tagid(target))
+ self
+ end
+ def tag_row(tag, *rows)
+ tk_send('tag', 'row', tagid(tag), *rows)
+ self
+ end
+ def tag_row_reset(*rows)
+ tk_send('tag', 'row', '', *rows)
+ self
+ end
+
+ def validate(idx)
+ bool(tk_send('validate', tagid(idx)))
+ end
+
+ def width_list
+ list(tk_send('width'))
+ end
+ def width(row)
+ number(tk_send('width', row))
+ end
+ def set_width(*pairs)
+ tk_send('width', *(pairs.flatten))
+ self
+ end
+
+ def window_delete(*args)
+ tk_send('window', 'delete', *(args.collect{|idx| tagid(idx)}))
+ self
+ end
+ def window_move(from_idx, to_idx)
+ tk_send('window', 'move', tagid(from_idx), tagid(to_idx))
+ self
+ end
+ def window_names(pat=None)
+ simplelist(tk_send('window', 'names', pat))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/tktrans.rb b/ext/tk/lib/tkextlib/tktrans.rb
new file mode 100644
index 0000000000..c5de5be5e6
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tktrans.rb
@@ -0,0 +1,14 @@
+#
+# TkTrans support (win32 only)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktrans/setup.rb'
+
+# load library
+require 'tkextlib/tktrans/tktrans'
diff --git a/ext/tk/lib/tkextlib/tktrans/setup.rb b/ext/tk/lib/tkextlib/tktrans/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tktrans/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ext/tk/lib/tkextlib/tktrans/tktrans.rb
new file mode 100644
index 0000000000..55ac03e563
--- /dev/null
+++ b/ext/tk/lib/tkextlib/tktrans/tktrans.rb
@@ -0,0 +1,59 @@
+#
+# TkTrans support (win32 only)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktrans/setup.rb'
+
+TkPackage.require('tktrans') rescue Tk.load_tcllibrary('tktrans')
+
+module Tk
+ module TkTrans
+ def self.package_version
+ begin
+ TkPackage.require('tktrans')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class TkWindow
+ def tktrans_set_image(img)
+ tk_send('tktrans::setwidget', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::setwidget', @path)
+ end
+end
+
+class TkRoot
+ undef tktrans_set_image, tktrans_get_image
+
+ def tktrans_set_image(img)
+ tk_send('tktrans::settoplevel', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::settoplevel', @path)
+ end
+end
+
+class TkToplevel
+ undef tktrans_set_image, tktrans_get_image
+
+ def tktrans_set_image(img)
+ tk_send('tktrans::settoplevel', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::settoplevel', @path)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/treectrl.rb b/ext/tk/lib/tkextlib/treectrl.rb
new file mode 100644
index 0000000000..1944fb83e3
--- /dev/null
+++ b/ext/tk/lib/tkextlib/treectrl.rb
@@ -0,0 +1,13 @@
+#
+# TkTreeCtrl support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/treectrl/setup.rb'
+
+# load library
+require 'tkextlib/treectrl/tktreectrl'
diff --git a/ext/tk/lib/tkextlib/treectrl/setup.rb b/ext/tk/lib/tkextlib/treectrl/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/treectrl/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
new file mode 100644
index 0000000000..cc23857c5f
--- /dev/null
+++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
@@ -0,0 +1,923 @@
+#
+# tkextlib/treectrl/tktreectrl.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/treectrl/setup.rb'
+
+# TkPackage.require('treectrl', '1.0')
+TkPackage.require('treectrl')
+
+module Tk
+ class TreeCtrl < TkWindow
+ def self.package_version
+ begin
+ TkPackage.require('treectrl')
+ rescue
+ ''
+ end
+ end
+
+ # dummy ::
+ # pkgIndex.tcl of TreeCtrl-1.0 doesn't support auto_load for
+ # 'loupe' command (probably it is bug, I think).
+ # So, calling a 'treectrl' command for loading the dll with
+ # the auto_load facility.
+ begin
+ tk_call('treectrl')
+ rescue
+ end
+ def self.loupe(img, x, y, w, h, zoom)
+ # NOTE: platform == 'unix' only
+
+ # img => TkPhotoImage
+ # x, y => screen coords
+ # w, h => magnifier width and height
+ # zoom => zooming rate
+ Tk.tk_call_without_enc('loupe', img, x, y, w, h, zoom)
+ end
+
+ class NotifyEvent < TkUtil::CallbackSubst
+ end
+
+ module ConfigMethod
+ end
+ end
+ TreeCtrl_Widget = TreeCtrl
+end
+
+##############################################
+
+class Tk::TreeCtrl::NotifyEvent
+ # [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>]
+ KEY_TBL = [
+ [ ?c, ?n, :item_num ],
+ [ ?d, ?s, :detail ],
+ [ ?D, ?l, :items ],
+ [ ?e, ?e, :event ],
+ [ ?I, ?n, :id ],
+ [ ?l, ?b, :lower_bound ],
+ [ ?p, ?n, :active_id ],
+ [ ?S, ?l, :sel_items ],
+ [ ?T, ?w, :widget ],
+ [ ?U, ?b, :upper_bound ],
+ [ ?W, ?o, :object ],
+ nil
+ ]
+
+ # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?l, TkComm.method(:list) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?b, proc{|val| list(val)} ],
+
+ [ ?e, proc{|val|
+ case val
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(val[1..-2])
+ when /^<[^<>]+>$/
+ val[1..-2]
+ else
+ val
+ end
+ }
+ ],
+
+ [ ?o, proc{|val| tk_tcl2ruby(val)} ],
+
+ nil
+ ]
+
+ # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
+ #
+ # _get_subst_key() and _get_all_subst_keys() generates key-string
+ # which describe how to convert callback arguments to ruby objects.
+ # When binding parameters are given, use _get_subst_key().
+ # But when no parameters are given, use _get_all_subst_keys() to
+ # create a Event class object as a callback parameter.
+ #
+ # scan_args() is used when doing callback. It convert arguments
+ # ( which are Tcl strings ) to ruby objects based on the key string
+ # that is generated by _get_subst_key() or _get_all_subst_keys().
+ #
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+end
+
+##############################################
+
+module Tk::TreeCtrl::ConfigMethod
+ include TkItemConfigMethod
+
+ def treectrl_tagid(key, obj)
+ if key.kind_of?(Array)
+ key = key.join(' ')
+ else
+ key = key.to_s
+ end
+
+ case key
+ when 'column'
+ obj
+
+ when 'dragimage'
+ obj
+
+ when 'element'
+ obj
+
+ when 'item element'
+ obj
+
+ when 'marquee'
+ obj
+
+ when 'notify'
+ obj
+
+ when 'style'
+ obj
+
+ else
+ obj
+ end
+ end
+
+ def tagid(mixed_id)
+ if mixed_id.kind_of?(Array)
+ [mixed_id[0], treectrl_tagid(*mixed_id)]
+ else
+ tagid(mixed_id.split(':'))
+ end
+ fail ArgumentError, "unknown id format"
+ end
+
+ def __item_cget_cmd(mixed_id)
+ if mixed_id[1].kind_of?(Array)
+ id = mixed_id[1]
+ else
+ id = [mixed_id[1]]
+ end
+
+ if mixed_id[0].kind_of?(Array)
+ ([self.path].concat(mixed_id[0]) << 'cget').concat(id)
+ else
+ [self.path, mixed_id[0], 'cget'].concat(id)
+ end
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(mixed_id)
+ if mixed_id[1].kind_of?(Array)
+ id = mixed_id[1]
+ else
+ id = [mixed_id[1]]
+ end
+
+ if mixed_id[0].kind_of?(Array)
+ ([self.path].concat(mixed_id[0]) << 'configure').concat(id)
+ else
+ [self.path, mixed_id[0], 'configure'].concat(id)
+ end
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ key = id[0]
+ if key.kind_of?(Array)
+ key = key.join(' ')
+ end
+
+ tag = id[1]
+ if tag.kind_of?(Array)
+ tag = tag.join(' ')
+ end
+
+ id = [key, tag].join(':')
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def __item_configinfo_struct(id)
+ if id.kind_of?(Array) && id[0].to_s == 'notify'
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>nil, :current_value=>1}
+ else
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
+ :default_value=>3, :current_value=>4}
+ end
+ end
+ private :__item_configinfo_struct
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+
+ def __item_keyonly_optkeys(id) # { def_key=>(undef_key|nil), ... }
+ {
+ 'notreally'=>nil,
+ 'increasing'=>'decreasing',
+ 'decreasing'=>'increasing',
+ 'ascii'=>nil,
+ 'dictionary'=>nil,
+ 'integer'=>nil,
+ 'real'=>nil
+ }
+ end
+ private :__item_keyonly_optkeys
+
+ def column_cget(tagOrId, option)
+ itemcget(['column', tagOrId], option)
+ end
+ def column_configure(tagOrId, slot, value=None)
+ itemconfigure(['column', tagOrId], slot, value)
+ end
+ def column_configinfo(tagOrId, slot=nil)
+ itemconfigure(['column', tagOrId], slot)
+ end
+ def current_column_configinfo(tagOrId, slot=nil)
+ itemconfigure(['column', tagOrId], slot)
+ end
+
+ def dragimage_cget(tagOrId, option)
+ itemcget(['dragimage', tagOrId], option)
+ end
+ def dragimage_configure(tagOrId, slot, value=None)
+ itemconfigure(['dragimage', tagOrId], slot, value)
+ end
+ def dragimage_configinfo(tagOrId, slot=nil)
+ itemconfigure(['dragimage', tagOrId], slot)
+ end
+ def current_dragimage_configinfo(tagOrId, slot=nil)
+ itemconfigure(['dragimage', tagOrId], slot)
+ end
+
+ def element_cget(tagOrId, option)
+ itemcget(['element', tagOrId], option)
+ end
+ def element_configure(tagOrId, slot, value=None)
+ itemconfigure(['element', tagOrId], slot, value)
+ end
+ def element_configinfo(tagOrId, slot=nil)
+ itemconfigure(['element', tagOrId], slot)
+ end
+ def current_element_configinfo(tagOrId, slot=nil)
+ itemconfigure(['element', tagOrId], slot)
+ end
+
+ def item_element_cget(tagOrId, option)
+ itemcget([['item', 'element'], tagOrId], option)
+ end
+ def item_element_configure(tagOrId, slot, value=None)
+ itemconfigure([['item', 'element'], tagOrId], slot, value)
+ end
+ def item_element_configinfo(tagOrId, slot=nil)
+ itemconfigure([['item', 'element'], tagOrId], slot)
+ end
+ def current_item_element_configinfo(tagOrId, slot=nil)
+ itemconfigure([['item', 'element'], tagOrId], slot)
+ end
+
+ def marquee_cget(tagOrId, option)
+ itemcget(['marquee', tagOrId], option)
+ end
+ def marquee_configure(tagOrId, slot, value=None)
+ itemconfigure(['marquee', tagOrId], slot, value)
+ end
+ def marquee_configinfo(tagOrId, slot=nil)
+ itemconfigure(['marquee', tagOrId], slot)
+ end
+ def current_marquee_configinfo(tagOrId, slot=nil)
+ itemconfigure(['marquee', tagOrId], slot)
+ end
+
+ def notify_cget(win, pattern, option)
+ itemconfigure(['notify', [win, pattern]], option)
+ end
+ def notify_configure(win, pattern, slot, value=None)
+ itemconfigure(['notify', [win, pattern]], slot, value)
+ end
+ def notify_configinfo(win, pattern, slot=nil)
+ itemconfigure(['notify', [win, pattern]], slot)
+ end
+ alias current_notify_configinfo notify_configinfo
+
+ def style_cget(tagOrId, option)
+ itemcget(['style', tagOrId], option)
+ end
+ def style_configure(tagOrId, slot, value=None)
+ itemconfigure(['style', tagOrId], slot, value)
+ end
+ def style_configinfo(tagOrId, slot=nil)
+ itemconfigure(['style', tagOrId], slot)
+ end
+ def current_style_configinfo(tagOrId, slot=nil)
+ itemconfigure(['style', tagOrId], slot)
+ end
+
+ private :itemcget, :itemconfigure
+ private :itemconfiginfo, :current_itemconfiginfo
+end
+
+##############################################
+
+class Tk::TreeCtrl
+ include Tk::TreeCtrl::ConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['treectrl'.freeze].freeze
+ WidgetClassName = ''.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def install_bind(cmd, *args)
+ install_bind_for_event_class(Tk::TreeCtrl::NotifyEvent, cmd, *args)
+ end
+
+ #########################
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc('treectrl', @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc('treectrl', @path)
+ end
+ end
+ private :create_self
+
+ #########################
+
+ def activate(desc)
+ tk_send('activate', desc)
+ self
+ end
+
+ def canvasx(x)
+ number(tk_send('canvasx', x))
+ end
+
+ def canvasy(y)
+ number(tk_send('canvasy', y))
+ end
+
+ def collapse(*dsc)
+ tk_send('collapse', *dsc)
+ self
+ end
+
+ def collapse_recurse(*dsc)
+ tk_send('collapse', '-recurse', *dsc)
+ self
+ end
+
+ def column_bbox(idx)
+ list(tk_send('column', 'bbox', idx))
+ end
+
+ def column_delete(idx)
+ tk_send('column', 'delete', idx)
+ self
+ end
+
+ def column_index(idx)
+ num_or_str(tk_send('column', 'index', idx))
+ end
+
+ def column_move(idx, to)
+ tk_send('column', 'move', idx, to)
+ self
+ end
+
+ def column_needed_width(idx)
+ num_or_str(tk_send('column', 'neededwidth', idx))
+ end
+ alias column_neededwidth column_needed_width
+
+ def column_width(idx)
+ num_or_str(tk_send('column', 'width', idx))
+ end
+
+ def compare(item1, op, item2)
+ number(tk_send('compare', item1, op, item2))
+ end
+
+ def contentbox()
+ list(tk_send('contentbox'))
+ end
+
+ def depth(item=None)
+ num_or_str(tk_send('depth', item))
+ end
+
+ def dragimage_add(item, *args)
+ tk_send('dragimage', 'add', item, *args)
+ self
+ end
+
+ def dragimage_clear()
+ tk_send('dragimage', 'clear')
+ self
+ end
+
+ def dragimage_offset(*args) # x, y
+ if args.empty?
+ list(tk_send('dragimage', 'offset'))
+ else
+ tk_send('dragimage', 'offset', *args)
+ self
+ end
+ end
+
+ def dragimage_visible(*args) # mode
+ if args..empty?
+ bool(tk_send('dragimage', 'visible'))
+ else
+ tk_send('dragimage', 'visible', *args)
+ self
+ end
+ end
+ def dragimage_visible?
+ dragimage_visible()
+ end
+
+ def element_create(elem, type, keys=nil)
+ if keys && keys.kind_of?(Hash)
+ tk_send('element', 'create', elem, type, *hash_kv(keys))
+ else
+ tk_send('element', 'create', elem, type)
+ end
+ end
+
+ def element_delete(*elems)
+ tk_send('element', 'delete', *elems)
+ self
+ end
+
+ def element_names()
+ list(tk_send('element', 'names'))
+ end
+
+ def element_type(elem)
+ tk_send('element', 'type', elem)
+ end
+
+ def expand(*dsc)
+ tk_send('expand', *dsc)
+ self
+ end
+
+ def expand_recurse(*dsc)
+ tk_send('expand', '-recurse', *dsc)
+ self
+ end
+
+ def identify(x, y)
+ list(tk_send('identify', x, y))
+ end
+
+ def index(idx)
+ num_or_str(tk_send('index', idx))
+ end
+
+ def item_ancestors(item)
+ list(tk_send('item', 'ancestors', item))
+ end
+
+ def item_bbox(item, *args)
+ list(tk_send('item', 'bbox', item, *args))
+ end
+
+ def item_children(item)
+ list(tk_send('item', 'children', item))
+ end
+
+ def item_complex(item, *args)
+ tk_send('item', 'complex', item, *args)
+ self
+ end
+
+ def item_create()
+ num_or_str(tk_send('item', 'create'))
+ end
+
+ def item_delete(first, last=None)
+ tk_send('item', 'delete', first, last)
+ self
+ end
+
+ def item_dump(item)
+ list(tk_send('item', 'dump', item))
+ end
+
+ def item_element_actual(item, column, elem, key)
+ tk_send('item', 'element', 'actual', item, column, elem, "-#{key}")
+ end
+
+ def item_firstchild(parent, child=nil)
+ if child
+ tk_send('item', 'firstchild', parent, child)
+ self
+ else
+ num_or_str(tk_send('item', 'firstchild', parent))
+ end
+ end
+ alias item_first_child item_firstchild
+
+ def item_hashbutton(item, st=None)
+ if st == None
+ bool(tk_send('item', 'hashbutton'))
+ else
+ tk_send('item', 'hashbutton', st)
+ self
+ end
+ end
+ def item_hashbutton?(item)
+ item_hashbutton(item)
+ end
+
+ def item_index(item)
+ list(tk_send('item', 'index', item))
+ end
+
+ def item_isancestor(item, des)
+ bool(tk_send('item', 'isancestor', item, des))
+ end
+ alias item_is_ancestor item_isancestor
+ alias item_isancestor? item_isancestor
+ alias item_is_ancestor? item_isancestor
+
+ def item_isopen(item)
+ bool(tk_send('item', 'isopen', item))
+ end
+ alias item_is_open item_isopen
+ alias item_isopen? item_isopen
+ alias item_is_open? item_isopen
+ alias item_isopened? item_isopen
+ alias item_is_opened? item_isopen
+
+ def item_lastchild(parent, child=nil)
+ if child
+ tk_send('item', 'lastchild', parent, child)
+ self
+ else
+ num_or_str(tk_send('item', 'lastchild', parent))
+ end
+ end
+ alias item_last_child item_lastchild
+
+ def item_nextsibling(sibling, nxt=nil)
+ if nxt
+ tk_send('item', 'nextsibling', sibling, nxt)
+ self
+ else
+ num_or_str(tk_send('item', 'nextsibling', sibling))
+ end
+ end
+ alias item_next_sibling item_nextsibling
+
+ def item_numchildren()
+ number(tk_send('item', 'numchildren'))
+ end
+ alias item_num_children item_numchildren
+ alias item_children_size item_numchildren
+
+ def item_parent(item)
+ num_or_str(tk_send('item', 'parent', item))
+ end
+
+ def item_prevsibling(sibling, prev=nil)
+ if prev
+ tk_send('item', 'prevsibling', sibling, prev)
+ self
+ else
+ num_or_str(tk_send('item', 'prevsibling', sibling))
+ end
+ end
+ alias item_prev_sibling item_prevsibling
+
+ def item_remove(item)
+ list(tk_send('item', 'remove', item))
+ end
+
+ def item_rnc(item)
+ list(tk_send('item', 'rnc', item))
+ end
+
+ def item_sort(item, *opts)
+ flag = false
+ if opts[-1].kind_of?(Hash)
+ opts[-1,1] = __conv_item_keyonly_opts(item, opts[-1]).to_a
+ end
+
+ opts = opts.collect{|opt|
+ if opt.kind_of?(Array)
+ key = "-#{opt[0]}"
+ flag = true if key == '-notreally'
+ ["-#{opt[0]}", opt[1]]
+ else
+ key = "-#{opt}"
+ flag = true if key == '-notreally'
+ key
+ end
+ }.flatten
+
+ ret = tk_send('item', 'sort', item, *opts)
+ if flag
+ list(ret)
+ else
+ ret
+ end
+ end
+
+ def item_state_get(item, *args)
+ if args.empty?
+ list(tk_send('item', 'state', 'get', item *args))
+ else
+ bool(tk_send('item', 'state', 'get', item))
+ end
+ end
+
+ def item_state_set(item, *args)
+ tk_send('item', 'state', 'set', *args)
+ self
+ end
+
+ def item_style_elements(item, colun)
+ list(tk_send('item', 'style', 'elements', item, column))
+ end
+
+ def item_style_map(item, column, style, map)
+ tk_send('item', 'style', 'map', item, column, style, map)
+ self
+ end
+
+ def item_style_set(item, column=nil, *args)
+ if args.empty?
+ if column
+ tk_send('item', 'style', 'set', item, column)
+ else
+ list(tk_send('item', 'style', 'set', item))
+ end
+ else
+ tk_send('item', 'style', 'set', item, *(args.flatten))
+ self
+ end
+ end
+
+ def item_text(item, column, txt=nil, *args)
+ if args.empty?
+ if txt
+ tk_send('item', 'text', item, column, txt)
+ self
+ else
+ tk_send('item', 'text', item, column)
+ end
+ else
+ tk_send('item', 'text', item, txt, *args)
+ self
+ end
+ end
+
+ def item_visible(item, st=None)
+ if st == None
+ bool(tk_send('item', 'visible', item))
+ else
+ tk_send('item', 'visible', item, st)
+ self
+ end
+ end
+ def item_visible?(item)
+ item_visible(item)
+ end
+
+ def marquee_anchor(*args)
+ if args.empty?
+ list(tk_send('marquee', 'anchor'))
+ else
+ tk_send('marquee', 'anchor', *args)
+ self
+ end
+ end
+
+ def marquee_coords(*args)
+ if args.empty?
+ list(tk_send('marquee', 'coords'))
+ else
+ tk_send('marquee', 'coords', *args)
+ self
+ end
+ end
+
+ def marquee_corner(*args)
+ if args.empty?
+ tk_send('marquee', 'corner')
+ else
+ tk_send('marquee', 'corner', *args)
+ self
+ end
+ end
+
+ def marquee_identify()
+ list(tk_send('marquee', 'identify'))
+ end
+
+ def marquee_visible(st=None)
+ if st == None
+ bool(tk_send('marquee', 'visible'))
+ else
+ tk_send('marquee', 'visible', st)
+ self
+ end
+ end
+ def marquee_visible?()
+ marquee_visible()
+ end
+
+ def notify_bind(obj, event, cmd=Proc.new, args=nil)
+ _bind([@path, 'notify', 'bind', obj], event, cmd, args)
+ self
+ end
+
+ def notify_bind_append(obj, event, cmd=Proc.new, args=nil)
+ _bind([@path, 'notify', 'bind', obj], event, cmd, args)
+ self
+ end
+
+ def notify_bindinfo(obj, event=nil)
+ _bindinfo([@path, 'notify', 'bind', obj], event)
+ end
+
+ def notify_detailnames(event)
+ list(tk_send('notify', 'detailnames', event))
+ end
+
+ def notify_eventnames()
+ list(tk_send('notify', 'eventnames'))
+ end
+
+ def notify_generate(pattern, char_map=None)
+ tk_send('notify', 'generate', pattern, char_map)
+ self
+ end
+
+ def notify_install_detail(event, detail, percents_cmd=nil, &b)
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ tk_send('notify', 'install', 'detail', event, detail, percents_cmd)
+ else
+ tk_send('notify', 'install', 'detail', event, detail)
+ end
+ end
+
+ def notify_install_event(event, percents_cmd=nil, &b)
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ tk_send('notify', 'install', 'event', event, percents_cmd)
+ else
+ tk_send('notify', 'install', 'event', event)
+ end
+ end
+
+ def notify_linkage(event, detail=None)
+ tk_send('notify', 'linkage', event, detail)
+ end
+
+ def notify_uninstall_detail(event, detail)
+ tk_send('notify', 'uninstall', 'detail', event, detail)
+ self
+ end
+
+ def notify_uninstall_event(event)
+ tk_send('notify', 'uninstall', 'event', event)
+ self
+ end
+
+ def numcolumns()
+ num_or_str(tk_send('numcolumns'))
+ end
+
+ def numitems()
+ num_or_str(tk_send('numitems'))
+ end
+
+ def orphans()
+ list(tk_send('orphans'))
+ end
+
+ def range(first, last)
+ list(tk_send('range', first, last))
+ end
+
+ def state_define(name)
+ tk_send('state', 'define', name)
+ self
+ end
+
+ def state_linkage(name)
+ tk_send('state', 'linkage', name)
+ end
+
+ def state_names()
+ list(tk_send('state', 'names'))
+ end
+
+ def state_undefine(*names)
+ tk_send('state', 'undefine', *names)
+ self
+ end
+
+ def see(item)
+ tk_send('see', item)
+ self
+ end
+
+ def selection_add(first, last=None)
+ tk_send('selection', 'add', first, last)
+ self
+ end
+
+ def selection_anchor(item=None)
+ num_or_str(tk_send('selection', 'anchor', item))
+ end
+
+ def selection_clear(*args) # first, last
+ tk_send('selection', 'clear' *args)
+ self
+ end
+
+ def selection_count()
+ number(tk_send('selection', 'count'))
+ end
+
+ def selection_get()
+ list(tk_send('selection', 'get'))
+ end
+
+ def selection_includes(item)
+ bool(tk_send('selection', 'includes', item))
+ end
+
+ def selection_modify(sel, desel)
+ tk_send('selection', 'modify', sel, desel)
+ self
+ end
+
+ def style_create(style, keys=None)
+ if keys && keys != None
+ tk_send('style', 'create', style, *hash_kv(keys))
+ else
+ tk_send('style', 'create', style)
+ end
+ end
+
+ def style_delete(*args)
+ tk_send('style', 'delete', *args)
+ self
+ end
+
+ def style_elements(style, *elems)
+ if elems.empty?
+ list(tk_send('style', 'elements', style))
+ else
+ tk_send('style', 'elements', style, elems.flatten)
+ self
+ end
+ end
+
+ def style_layout(style, elem, keys=None)
+ if keys && keys != None
+ if keys.kind_of?(Hash)
+ tk_send('style', 'layout', style, elem, *hash_kv(keys))
+ self
+ else
+ tk_send('style', 'layout', style, elem, "-#{keys}")
+ end
+ else
+ list(tk_send('style', 'layout', style, elem))
+ end
+ end
+
+ def style_names()
+ list(tk_send('style', 'names'))
+ end
+
+ def toggle(*items)
+ tk_send('toggle', *items)
+ self
+ end
+
+ def toggle_recurse()
+ tk_send('toggle', '-recurse', *items)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/vu.rb b/ext/tk/lib/tkextlib/vu.rb
new file mode 100644
index 0000000000..c4ea1b86e6
--- /dev/null
+++ b/ext/tk/lib/tkextlib/vu.rb
@@ -0,0 +1,43 @@
+#
+# The vu widget set support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/vu/setup.rb'
+
+# load package
+# TkPackage.require('vu', '2.1')
+TkPackage.require('vu')
+
+# autoload
+module Tk
+ module Vu
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ def self.package_version
+ begin
+ TkPackage.require('vu')
+ rescue
+ ''
+ end
+ end
+
+ ##########################################
+
+ autoload :Dial, 'tkextlib/vu/dial'
+
+ autoload :Pie, 'tkextlib/vu/pie'
+ autoload :PieSlice, 'tkextlib/vu/pie'
+ autoload :NamedPieSlice, 'tkextlib/vu/pie'
+
+ autoload :Spinbox, 'tkextlib/vu/spinbox'
+
+ autoload :Bargraph, 'tkextlib/vu/bargraph'
+ end
+end
diff --git a/ext/tk/lib/tkextlib/vu/bargraph.rb b/ext/tk/lib/tkextlib/vu/bargraph.rb
new file mode 100644
index 0000000000..3ac08a26a5
--- /dev/null
+++ b/ext/tk/lib/tkextlib/vu/bargraph.rb
@@ -0,0 +1,51 @@
+#
+# ::vu::bargraph widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ class Bargraph < TkWindow
+ end
+ end
+end
+
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+class Tk::Vu::Bargraph < TkWindow
+ TkCommandNames = ['::vu::bargraph'.freeze].freeze
+ WidgetClassName = 'Bargraph'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ###############################
+
+ def __boolval_optkeys
+ ['showminmax', 'showvalue']
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ ['alabels', 'blabels']
+ end
+ private :__listval_optkeys
+
+ def __font_optkeys
+ ['alabfont', 'blabfont']
+ end
+ private :__font_optkeys
+
+ ###############################
+
+ def set(val = None)
+ tk_call_without_enc(@path, 'set', val)
+ self
+ end
+
+ def get()
+ num_or_str(tk_call_without_enc(@path, 'get'))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/vu/charts.rb b/ext/tk/lib/tkextlib/vu/charts.rb
new file mode 100644
index 0000000000..a578c6979b
--- /dev/null
+++ b/ext/tk/lib/tkextlib/vu/charts.rb
@@ -0,0 +1,47 @@
+#
+# charts -- Create and manipulate canvas Add-On Items
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tk/canvas'
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+module Tk
+ module Vu
+ module ChartsConfig
+ include TkItemConfigOptkeys
+ def __item_boolval_optkeys(id)
+ super(id) << 'lefttrunc' << 'autocolor'
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ super(id) << 'values' << 'tags'
+ end
+ private :__item_listval_optkeys
+ end
+
+ class TkcSticker < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'sticker'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+
+ class TkcStripchart < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'stripchart'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+
+ class TkcBarchart < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'barchart'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+ end
+end
diff --git a/ext/tk/lib/tkextlib/vu/dial.rb b/ext/tk/lib/tkextlib/vu/dial.rb
new file mode 100644
index 0000000000..e27a38ae42
--- /dev/null
+++ b/ext/tk/lib/tkextlib/vu/dial.rb
@@ -0,0 +1,102 @@
+#
+# ::vu::dial widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ class Dial < TkWindow
+ end
+ end
+end
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+# define module/class
+class Tk::Vu::Dial < TkWindow
+ TkCommandNames = ['::vu::dial'.freeze].freeze
+ WidgetClassName = 'Dial'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ ###############################
+
+ def __methodcall_optkeys # { key=>method, ... }
+ {'coords'=>'coords'}
+ end
+ private :__methodcall_optkeys
+
+ ###############################
+
+ def coords(val = nil)
+ if val
+ tk_split_list(tk_send_without_enc('coords'))
+ else
+ tk_send_without_enc('coords', val)
+ self
+ end
+ end
+
+ def constrain(val = None)
+ num_or_str(tk_call(@path, 'constrain', val))
+ end
+
+ def get(*args)
+ num_or_str(tk_call(@path, 'get', *args))
+ end
+
+ def identify(x, y)
+ tk_call(@path, 'identify', x, y)
+ end
+
+ def get_label(val=nil)
+ if val
+ tk_call(@path, 'label', val)
+ else
+ ret = []
+ lst = simplelist(tk_call(@path, 'label'))
+ while lst.size > 0
+ ret << ([num_or_str(lst.shift)] << lst.shift)
+ end
+ end
+ end
+
+ def set_label(val, str, *args)
+ tk_call(@path, 'label', val, str, *args)
+ self
+ end
+
+ def set_label_constrain(val, str, *args)
+ tk_call(@path, 'label', '-constrain', val, str, *args)
+ self
+ end
+
+ def get_tag(val=nil)
+ if val
+ tk_call(@path, 'tag', val)
+ else
+ ret = []
+ lst = simplelist(tk_call(@path, 'tag'))
+ while lst.size > 0
+ ret << ([num_or_str(lst.shift)] << lst.shift)
+ end
+ end
+ end
+
+ def set_tag(val, str, *args)
+ tk_call(@path, 'tag', val, str, *args)
+ self
+ end
+
+ def set_tag_constrain(val, str, *args)
+ tk_call(@path, 'tag', '-constrain', val, str, *args)
+ self
+ end
+
+ def set(val = None)
+ tk_call_without_enc(@path, 'set', val)
+ self
+ end
+end
diff --git a/ext/tk/lib/tkextlib/vu/pie.rb b/ext/tk/lib/tkextlib/vu/pie.rb
new file mode 100644
index 0000000000..dc676ad765
--- /dev/null
+++ b/ext/tk/lib/tkextlib/vu/pie.rb
@@ -0,0 +1,235 @@
+#
+# ::vu::pie widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ module PieSliceConfigMethod
+ end
+ class Pie < TkWindow
+ end
+ class PieSlice < TkObject
+ end
+ class NamedPieSlice < PieSlice
+ end
+ end
+end
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+module Tk::Vu::PieSliceConfigMethod
+ include TkItemConfigMethod
+
+ def __item_pathname(tagOrId)
+ if tagOrId.kind_of?(Tk::Vu::PieSlice)
+ self.path + ';' + tagOrId.id.to_s
+ else
+ self.path + ';' + tagOrId.to_s
+ end
+ end
+ private :__item_pathname
+end
+
+class Tk::Vu::Pie < TkWindow
+ TkCommandNames = ['::vu::pie'.freeze].freeze
+ WidgetClassName = 'Pie'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ def __destroy_hook__
+ Tk::Vu::PieSlice::SliceID_TBL.delete(@path)
+ end
+
+ ###############################
+
+ include Tk::Vu::PieSliceConfigMethod
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Vu::PieSlice)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ ###############################
+
+ def delete(*glob_pats)
+ tk_call(@path, 'delete', *glob_pats)
+ self
+ end
+
+ def explode(slice, *args)
+ tk_call(@path, 'explode', slice, *args)
+ self
+ end
+
+ def explode_value(slice)
+ num_or_str(tk_call(@path, 'explode', slice))
+ end
+
+ def lower(slice, below=None)
+ tk_call(@path, 'lower', slice, below)
+ self
+ end
+
+ def names(*glob_pats)
+ simplelist(tk_call(@path, 'names', *glob_pats))
+ end
+ alias slices names
+
+ def order(*args)
+ tk_call(@path, 'order', *args)
+ self
+ end
+
+ def raise(slice, above=None)
+ tk_call(@path, 'raise', slice, above)
+ self
+ end
+
+ def swap(slice1, slice2)
+ tk_call(@path, 'swap', slice1, slice2)
+ self
+ end
+
+ def set(slice, *args)
+ num_or_str(tk_call(@path, 'set', slice, *args))
+ end
+ alias set_value set
+ alias set_values set
+ alias create set
+
+ def slice_value(slice)
+ num_or_str(tk_call(@path, 'set', slice))
+ end
+
+ def value(val = None)
+ num_or_str(tk_call_without_enc(@path, 'value'))
+ end
+ alias sum_value value
+end
+
+class Tk::Vu::PieSlice
+ SliceID_TBL = TkCore::INTERP.create_table
+ Pie_Slice_ID = ['vu:pie'.freeze, '00000'.taint].freeze
+ TkCore::INTERP.init_ip_env{ SliceID_TBL.clear }
+
+ def self.id2obj(pie, id)
+ pie_path = pie.path
+ return id unless SliceID_TBL[pie_path]
+ SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id
+ end
+
+ def initialize(parent, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArguemntError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_)
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ Pie_Slice_ID[1].succ!
+
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget(slot)
+ @pie.itemcget(@id, slot)
+ end
+
+ def configure(*args)
+ @pie.itemconfigure(@id, *args)
+ self
+ end
+
+ def configinfo(*args)
+ @pie.itemconfiginfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @pie.current_itemconfiginfo(@id, *args)
+ end
+
+ def delete
+ @pie.delete(@id)
+ end
+
+ def explode(value)
+ @pie.explode(@id, value)
+ self
+ end
+
+ def explode_value
+ @pie.explode_value(@id)
+ end
+
+ def lower(other=None)
+ @pie.lower(@id, other)
+ self
+ end
+
+ def raise(other=None)
+ @pie.raise(@id, other)
+ self
+ end
+
+ def set(value)
+ @pie.set(@id, value)
+ self
+ end
+ alias set_value set
+
+ def value
+ @pie.set(@id)
+ end
+end
+
+class Tk::Vu::NamedPieSlice
+ def self.new(parent, name, *args)
+ if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name]
+ return SliceID_TBL[parent.path][name]
+ else
+ super(parent, name, *args)
+ end
+ end
+
+ def initialize(parent, name, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArguemntError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = name.to_s
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ end
+end
diff --git a/ext/tk/lib/tkextlib/vu/setup.rb b/ext/tk/lib/tkextlib/vu/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/vu/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/vu/spinbox.rb b/ext/tk/lib/tkextlib/vu/spinbox.rb
new file mode 100644
index 0000000000..b6499645a3
--- /dev/null
+++ b/ext/tk/lib/tkextlib/vu/spinbox.rb
@@ -0,0 +1,22 @@
+#
+# ::vu::spinbox widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# a standard spinbox (<= 8.3)
+# This is the same as the 8.4 core spinbox widget.
+#
+require 'tk'
+
+if (Tk::TK_MAJOR_VERSION < 8 ||
+ (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION < 4))
+ # call setup script -- <libdir>/tkextlib/vu.rb
+ require 'tkextlib/vu.rb'
+
+ Tk.tk_call('namespace', 'import', '::vu::spinbox')
+end
+
+module Tk
+ module Vu
+ Spinbox = TkSpinbox
+ end
+end
diff --git a/ext/tk/lib/tkextlib/winico.rb b/ext/tk/lib/tkextlib/winico.rb
new file mode 100644
index 0000000000..ce7b8eac5c
--- /dev/null
+++ b/ext/tk/lib/tkextlib/winico.rb
@@ -0,0 +1,14 @@
+#
+# winico -- Windows Icon extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# load library
+require 'tkextlib/winico/winico'
diff --git a/ext/tk/lib/tkextlib/winico/setup.rb b/ext/tk/lib/tkextlib/winico/setup.rb
new file mode 100644
index 0000000000..ce0f0bd4d4
--- /dev/null
+++ b/ext/tk/lib/tkextlib/winico/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/ext/tk/lib/tkextlib/winico/winico.rb b/ext/tk/lib/tkextlib/winico/winico.rb
new file mode 100644
index 0000000000..8a71cbb401
--- /dev/null
+++ b/ext/tk/lib/tkextlib/winico/winico.rb
@@ -0,0 +1,181 @@
+#
+# tkextlib/winico/winico.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/winico/setup.rb'
+
+# TkPackage.require('winico', '0.5')
+TkPackage.require('winico')
+
+module Tk
+ class Winico < TkObject
+ def self.package_version
+ begin
+ TkPackage.require('winico')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Winico
+ WinicoID_TBL = TkCore::INTERP.create_table
+ TkCore::INTERP.init_ip_env{ WinicoID_TBL.clear }
+
+ def self.id2obj(id)
+ (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id
+ end
+
+ def self.info
+ simplelist(Tk.tk_call('winico', 'info')).collect{|id|
+ Tk::Winico.id2obj(id)
+ }
+ end
+
+ def self.icon_info(id)
+ simplelist(Tk.tk_call('winico', 'info', id)).collect{|inf|
+ h = Hash[*list(inf)]
+ h.keys.each{|k| h[k[1..-1]] = h.delete(k)}
+ }
+ end
+
+ #################################
+
+ def self.new_from_file(file_name)
+ self.new(file_name)
+ end
+
+ def self.new_from_resource(resource_name, file_name = nil)
+ self.new(file_name, resource_name)
+ end
+
+ def initialize(file_name, resource_name=nil, winico_id=nil)
+ if resource_name
+ # from resource
+ if file_name
+ @id = Tk.tk_call('winico', 'load', resource_name, file_name)
+ else
+ @id = Tk.tk_call('winico', 'load', resource_name)
+ end
+ elsif file_name
+ # from .ico file
+ @id = Tk.tk_call('winico', 'createfrom', file_name)
+ elsif winico_id
+ @id = winico_id
+ else
+ fail ArgumentError,
+ "must be given proper information from where loading icons"
+ end
+ @path = @id
+ WinicoID_TBL[@id] = self
+ end
+
+ def id
+ @id
+ end
+
+ def set_window(win_id, *opts) # opts := ?'big'|'small'?, ?pos?
+ # NOTE:: the window, which is denoted by win_id, MUST BE MAPPED.
+ # If not, then this may fail or crash.
+ tk_call('winico', 'setwindow', win_id, @id, *opts)
+ end
+
+ def delete
+ tk_call('winico', 'delete', @id)
+ WinicoID_TBL.delete(@id)
+ self
+ end
+ alias destroy delete
+
+ def info
+ Tk::Winico.icon_info(@id)
+ end
+
+ #################################
+
+ class Winico_callback < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?m, ?s, :message ],
+ [ ?i, ?x, :icon ],
+ [ ?x, ?n, :x ],
+ [ ?y, ?n, :y ],
+ [ ?X, ?n, :last_x ],
+ [ ?Y, ?n, :last_y ],
+ [ ?t, ?n, :tickcount ],
+ [ ?w, ?n, :icon_idnum ],
+ [ ?l, ?n, :msg_idnum ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?x, proc{|id|
+ if Tk::Winico::WinicoID_TBL.key?(id)
+ Tk::Winico::WinicoID_TBL[id]
+ else
+ Tk::Winico.new(nil, nil, id)
+ end
+ } ],
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['callback']
+ end
+ end
+
+ #################################
+
+ def add_to_taskbar(keys = {})
+ keys = _symbolkey2str(keys)
+ Winico_callback._config_keys.each{|k|
+ if keys[k].kind_of?(Array)
+ cmd, *args = keys[k]
+ keys[k] = Winico_callback.new(cmd, args.join(' '))
+ elsif keys[k].kind_of?(Proc)
+ keys[k] = Winico_callback.new(keys[k])
+ end
+ }
+ tk_call('winico', 'taskbar', 'add', @id, *(hash_kv(keys)))
+ self
+ end
+ alias taskbar_add add_to_taskbar
+
+ def modify_taskbar(keys = {})
+ keys = _symbolkey2str(keys)
+ Winico_callback._config_keys.each{|k|
+ if keys[k].kind_of?(Array)
+ cmd, *args = keys[k]
+ keys[k] = Winico_callback.new(cmd, args.join(' '))
+ elsif keys[k].kind_of?(Proc)
+ keys[k] = Winico_callback.new(keys[k])
+ end
+ }
+ tk_call('winico', 'taskbar', 'modify', @id, *(hash_kv(keys)))
+ self
+ end
+ alias taskbar_modify modify_taskbar
+
+ def delete_from_taskbar
+ tk_call('winico', 'taskbar', 'delete', @id)
+ self
+ end
+ alias taskbar_delete delete_from_taskbar
+end
diff --git a/ext/tk/lib/tkfont.rb b/ext/tk/lib/tkfont.rb
index 65842e0188..38a96633de 100644
--- a/ext/tk/lib/tkfont.rb
+++ b/ext/tk/lib/tkfont.rb
@@ -1,1026 +1,4 @@
#
-# tkfont.rb - the class to treat fonts on Ruby/Tk
+# tkfont.rb - load tk/font.rb
#
-# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
-#
-require 'tk'
-
-class TkFont
- include Tk
- extend TkCore
-
- Tk_FontID = [0]
- Tk_FontNameTBL = {}
- Tk_FontUseTBL = {}
-
- # set default font
- case Tk::TK_VERSION
- when /^4\.*/
- DEFAULT_LATIN_FONT_NAME = 'a14'.freeze
- DEFAULT_KANJI_FONT_NAME = 'k14'.freeze
- when /^8\.*/
- if JAPANIZED_TK
- begin
- fontnames = tk_call('font', 'names')
- case fontnames
- when /defaultgui/
- # Tcl/Tk-JP for Windows
- ltn = 'defaultgui'
- knj = 'defaultgui'
- when /Mincho:Helvetica-12/
- # Tcl/Tk-JP for UNIX/X
- ltn, knj = tk_split_simplelist(tk_call('font', 'configure',
- 'Mincho:Helvetica-12',
- '-compound'))
- else
- # unknown Tcl/Tk-JP
- platform = tk_call('set', 'tcl_platform(platform)')
- case platform
- when 'unix'
- ltn = {'family'=>'Helvetica'.freeze, 'size'=>-12}
- knj = 'k14'
- #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0'
- when 'windows'
- ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
- knj = 'mincho'
- when 'macintosh'
- ltn = 'system'
- knj = 'mincho'
- else # unknown
- ltn = 'Helvetica'
- knj = 'mincho'
- end
- end
- rescue
- ltn = 'Helvetica'
- knj = 'mincho'
- end
-
- else # not JAPANIZED_TK
- begin
- platform = tk_call('set', 'tcl_platform(platform)')
- case platform
- when 'unix'
- ltn = {'family'=>'Helvetica'.freeze, 'size'=>-12}
- knj = 'k14'
- #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0'
- when 'windows'
- ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
- knj = 'mincho'
- when 'macintosh'
- ltn = 'system'
- knj = 'mincho'
- else # unknown
- ltn = 'Helvetica'
- knj = 'mincho'
- end
- rescue
- ltn = 'Helvetica'
- knj = 'mincho'
- end
- end
-
- DEFAULT_LATIN_FONT_NAME = ltn.freeze
- DEFAULT_KANJI_FONT_NAME = knj.freeze
-
- else # unknown version
- DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
- DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
-
- end
-
- if $DEBUG
- print "default latin font = "; p DEFAULT_LATIN_FONT_NAME
- print "default kanji font = "; p DEFAULT_KANJI_FONT_NAME
- end
-
- ###################################
- # class methods
- ###################################
- def TkFont.families(window=nil)
- case (Tk::TK_VERSION)
- when /^4\.*/
- ['fixed']
-
- when /^8\.*/
- if window
- tk_split_simplelist(tk_call('font', 'families', '-displayof', window))
- else
- tk_split_simplelist(tk_call('font', 'families'))
- end
- end
- end
-
- def TkFont.names
- case (Tk::TK_VERSION)
- when /^4\.*/
- r = ['fixed']
- r += ['a14', 'k14'] if JAPANIZED_TK
- Tk_FontNameTBL.each_value{|obj| r.push(obj)}
- r | []
-
- when /^8\.*/
- tk_split_simplelist(tk_call('font', 'names'))
-
- end
- end
-
- def TkFont.create_copy(font)
- fail 'source-font need to be TkFont' unless font.kind_of? TkFont
- keys = {}
- font.configinfo.each{|key,value| keys[key] = value }
- TkFont.new(font.latin_font, font.kanji_font, keys)
- end
-
- def TkFont.get_obj(name)
- if name =~ /^(@font[0-9]+)(|c|l|k)$/
- Tk_FontNameTBL[$1]
- else
- nil
- end
- end
-
- def TkFont.init_widget_font(path, *args)
- case (Tk::TK_VERSION)
- when /^4\.*/
- conf = tk_split_simplelist(tk_call(*args)).
- find_all{|prop| prop[0..5]=='-font ' || prop[0..10]=='-kanjifont '}.
- collect{|prop| tk_split_simplelist(prop)}
- if font_inf = conf.assoc('-font')
- ltn = font_inf[4]
- ltn = nil if ltn == []
- else
- #ltn = nil
- raise RuntimeError, "unknown option '-font'"
- end
- if font_inf = conf.assoc('-kanjifont')
- knj = font_inf[4]
- knj = nil if knj == []
- else
- knj = nil
- end
- TkFont.new(ltn, knj).call_font_configure(path, *(args + [{}]))
-
- when /^8\.*/
- font_prop = tk_split_simplelist(tk_call(*args)).find{|prop|
- prop[0..5] == '-font '
- }
- unless font_prop
- raise RuntimeError, "unknown option '-font'"
- end
- fnt = tk_split_simplelist(font_prop)[4]
- if fnt == ""
- TkFont.new(nil, nil).call_font_configure(path, *(args + [{}]))
- else
- begin
- compound = Hash[*list(tk_call('font', 'configure',
- fnt))].collect{|key,value|
- [key[1..-1], value]
- }.assoc('compound')[1]
- rescue
- compound = []
- end
- if compound == []
- TkFont.new(fnt, DEFAULT_KANJI_FONT_NAME) \
- .call_font_configure(path, *(args + [{}]))
- else
- TkFont.new(compound[0], compound[1]) \
- .call_font_configure(path, *(args + [{}]))
- end
- end
- end
- end
-
- def TkFont.used_on(path=nil)
- if path
- Tk_FontUseTBL[path]
- else
- Tk_FontUseTBL.values | []
- end
- end
-
- def TkFont.failsafe(font)
- begin
- if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
- tk_call('font', 'failsafe', font)
- end
- rescue
- end
- end
-
- ###################################
- private
- ###################################
- def initialize(ltn=DEFAULT_LATIN_FONT_NAME, knj=nil, keys=nil)
- @id = format("@font%.4d", Tk_FontID[0])
- Tk_FontID[0] += 1
- Tk_FontNameTBL[@id] = self
- knj = DEFAULT_KANJI_FONT_NAME if JAPANIZED_TK && !knj
- create_compoundfont(ltn, knj, keys)
- end
-
- def _get_font_info_from_hash(font)
- foundry = (info = font['foundry'] .to_s)? info: '*'
- family = (info = font['family'] .to_s)? info: '*'
- weight = (info = font['weight'] .to_s)? info: '*'
- slant = (info = font['slant'] .to_s)? info: '*'
- swidth = (info = font['swidth'] .to_s)? info: '*'
- adstyle = (info = font['adstyle'] .to_s)? info: '*'
- pixels = (info = font['pixels'] .to_s)? info: '*'
- points = (info = font['points'] .to_s)? info: '*'
- resx = (info = font['resx'] .to_s)? info: '*'
- resy = (info = font['resy'] .to_s)? info: '*'
- space = (info = font['space'] .to_s)? info: '*'
- avgWidth = (info = font['avgWidth'].to_s)? info: '*'
- charset = (info = font['charset'] .to_s)? info: '*'
- encoding = (info = font['encoding'].to_s)? info: '*'
-
- [foundry, family, weight, slant, swidth, adstyle,
- pixels, points, resx, resy, space, avgWidth, charset, encoding]
- end
-
- def create_latinfont_tk4x(font)
- if font.kind_of? Hash
- @latinfont = '-' + _get_font_info_from_hash(font).join('-') + '-'
-
- elsif font.kind_of? Array
- finfo = {}
- finfo['family'] = font[0].to_s
- if font[1]
- fsize = font[1].to_s
- if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
- if $1 == '-'
- finfo['pixels'] = $2
- else
- finfo['points'] = $2
- end
- else
- finfo['points'] = '13'
- end
- end
- font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
- when 'bold'
- finfo['weight'] = style
- when 'roman'
- finfo['slant'] = 'r'
- when 'italic'
- finfo['slant'] = 'i'
- end
- }
-
- @latinfont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
-
- elsif font.kind_of? TkFont
- @latinfont = font.latin_font
-
- else
- if font
- @latinfont = font
- else
- @latinfont = DEFAULT_LATIN_FONT_NAME
- end
-
- end
- end
-
- def create_kanjifont_tk4x(font)
- unless JAPANIZED_TK
- @kanjifont = ""
- return
- end
-
- if font.kind_of? Hash
- @kanjifont = '-' + _get_font_info_from_hash(font).join('-') + '-'
-
- elsif font.kind_of? Array
- finfo = {}
- finfo['family'] = font[0].to_s
- if font[1]
- fsize = font[1].to_s
- if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
- if $1 == '-'
- finfo['pixels'] = $2
- else
- finfo['points'] = $2
- end
- else
- finfo['points'] = '13'
- end
- end
- font[2..-1].each{|style|
- case (style)
- when 'normal'
- finfo['weight'] = style
- when 'bold'
- finfo['weight'] = style
- when 'roman'
- finfo['slant'] = 'r'
- when 'italic'
- finfo['slant'] = 'i'
- end
- }
-
- @kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
- elsif font.kind_of? TkFont
- @kanjifont = font.kanji_font
- else
- if font
- @kanjifont = font
- else
- @kanjifont = DEFAULT_KANJI_FONT_NAME
- end
- end
- end
-
- def create_compoundfont_tk4x(ltn, knj, keys)
- create_latinfont(ltn)
- create_kanjifont(knj)
-
- if JAPANIZED_TK
- @compoundfont = [[@latinfont], [@kanjifont]]
- @fontslot = {'font'=>@latinfont, 'kanjifont'=>@kanjifont}
- else
- @compoundfont = @latinfont
- @fontslot = {'font'=>@latinfont}
- end
- end
-
- def create_latinfont_tk8x(font)
- @latinfont = @id + 'l'
-
- if JAPANIZED_TK
- if font.kind_of? Hash
- if font['charset']
- tk_call('font', 'create', @latinfont, *hash_kv(font))
- else
- tk_call('font', 'create', @latinfont,
- '-charset', 'iso8859', *hash_kv(font))
- end
- elsif font.kind_of? Array
- tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font))
- tk_call('font', 'configure', @latinfont, '-charset', 'iso8859')
- elsif font.kind_of? TkFont
- tk_call('font', 'create', @latinfont, '-copy', font.latin_font)
- elsif font
- tk_call('font', 'create', @latinfont, '-copy', font,
- '-charset', 'iso8859')
- else
- tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
- end
- else
- if font.kind_of? Hash
- tk_call('font', 'create', @latinfont, *hash_kv(font))
- else
- keys = {}
- if font.kind_of? Array
- actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
- elsif font.kind_of? TkFont
- actual_core(font.latin_font).each{|key,val| keys[key] = val}
- elsif font
- actual_core(font).each{|key,val| keys[key] = val}
- end
- tk_call('font', 'create', @latinfont, *hash_kv(keys))
- end
-
- if font && @compoundfont
- keys = {}
- actual_core(@latinfont).each{|key,val| keys[key] = val}
- tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
- end
- end
- end
-
- def create_kanjifont_tk8x(font)
- @kanjifont = @id + 'k'
-
- if JAPANIZED_TK
- if font.kind_of? Hash
- if font['charset']
- tk_call('font', 'create', @kanjifont, *hash_kv(font))
- else
- tk_call('font', 'create', @kanjifont,
- '-charset', 'jisx0208.1983', *hash_kv(font))
- end
- elsif font.kind_of? Array
- tk_call('font', 'create', @kanjifont, '-copy', array2tk_list(font))
- tk_call('font', 'configure', @kanjifont, '-charset', 'jisx0208.1983')
- elsif font.kind_of? TkFont
- tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font)
- elsif font
- tk_call('font', 'create', @kanjifont, '-copy', font,
- '-charset', 'jisx0208.1983')
- else
- tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
- end
- # end of JAPANIZED_TK
-
- else
- if font.kind_of? Hash
- tk_call('font', 'create', @kanjifont, *hash_kv(font))
- else
- keys = {}
- if font.kind_of? Array
- actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
- elsif font.kind_of? TkFont
- actual_core(font.kanji_font).each{|key,val| keys[key] = val}
- elsif font
- actual_core(font).each{|key,val| keys[key] = val}
- end
- tk_call('font', 'create', @kanjifont, *hash_kv(keys))
- end
-
- if font && @compoundfont
- keys = {}
- actual_core(@kanjifont).each{|key,val| keys[key] = val}
- tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
- end
- end
- end
-
- def create_compoundfont_tk8x(ltn, knj, keys)
- create_latinfont(ltn)
- create_kanjifont(knj)
-
- @compoundfont = @id + 'c'
- if JAPANIZED_TK
- @fontslot = {'font'=>@compoundfont}
- tk_call('font', 'create', @compoundfont,
- '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
- else
- tk_call('font', 'create', @compoundfont)
-
- latinkeys = {}
- begin
- actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
- rescue
- latinkeys {}
- end
- if latinkeys != {}
- tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
- end
-
- if knj
- kanjikeys = {}
- begin
- actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val}
- rescue
- kanjikeys {}
- end
- if kanjikeys != {}
- tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys))
- end
- end
-
- @fontslot = {'font'=>@compoundfont}
- tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
- end
- end
-
- def actual_core_tk4x(font, window=nil, option=nil)
- # dummy
- if option
- ""
- else
- [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
- ['underline',[]], ['overstrike',[]], ['charset',[]],
- ['pointadjust',[]]]
- end
- end
-
- def actual_core_tk8x(font, window=nil, option=nil)
- if option == 'compound'
- ""
- elsif option
- if window
- tk_call('font', 'actual', font, "-displayof", window, "-#{option}")
- else
- tk_call('font', 'actual', font, "-#{option}")
- end
- else
- l = tk_split_simplelist(if window
- tk_call('font', 'actual', font,
- "-displayof", window)
- else
- tk_call('font', 'actual', font)
- end)
- r = []
- while key=l.shift
- if key == '-compound'
- l.shift
- else
- r.push [key[1..-1], l.shift]
- end
- end
- r
- end
- end
-
- def configure_core_tk4x(font, slot, value=None)
- ""
- end
-
- def configinfo_core_tk4x(font, option=nil)
- # dummy
- if option
- ""
- else
- [['family',[]], ['size',[]], ['weight',[]], ['slant',[]],
- ['underline',[]], ['overstrike',[]], ['charset',[]],
- ['pointadjust',[]]]
- end
- end
-
- def configure_core_tk8x(font, slot, value=None)
- if slot.kind_of? Hash
- tk_call 'font', 'configure', font, *hash_kv(slot)
- else
- tk_call 'font', 'configure', font, "-#{slot}", value
- end
- end
-
- def configinfo_core_tk8x(font, option=nil)
- if option == 'compound'
- ""
- elsif option
- tk_call('font', 'configure', font, "-#{option}")
- else
- l = tk_split_simplelist(tk_call('font', 'configure', font))
- r = []
- while key=l.shift
- if key == '-compound'
- l.shift
- else
- r.push [key[1..-1], l.shift]
- end
- end
- r
- end
- end
-
- def delete_core_tk4x
- Tk_FontNameTBL[@id] = nil
- Tk_FontUseTBL.delete_if{|key,value| value == self}
- end
-
- def delete_core_tk8x
- begin
- tk_call('font', 'delete', @latinfont)
- rescue
- end
- begin
- tk_call('font', 'delete', @kanjifont)
- rescue
- end
- begin
- tk_call('font', 'delete', @compoundfont)
- rescue
- end
- Tk_FontNameTBL[@id] = nil
- Tk_FontUseTBL.delete_if{|key,value| value == self}
- end
-
- def latin_replace_core_tk4x(ltn)
- create_latinfont_tk4x(ltn)
- @compoundfont[0] = [@latinfont] if JAPANIZED_TK
- @fontslot['font'] = @latinfont
- Tk_FontUseTBL.dup.each{|w, fobj|
- if self == fobj
- begin
- if w.include?(';')
- win, tag = w.split(';')
- winobj = tk_tcl2ruby(win)
-# winobj.tagfont_configure(tag, {'font'=>@latinfont})
- if winobj.kind_of? TkText
- tk_call(win, 'tag', 'configure', tag, '-font', @latinfont)
- elsif winobj.kind_of? TkCanvas
- tk_call(win, 'itemconfigure', tag, '-font', @latinfont)
- elsif winobj.kind_of? TkMenu
- tk_call(win, 'entryconfigure', tag, '-font', @latinfont)
- else
- raise RuntimeError, "unknown widget type"
- end
- else
-# tk_tcl2ruby(w).font_configure('font'=>@latinfont)
- tk_call(w, 'configure', '-font', @latinfont)
- end
- rescue
- Tk_FontUseTBL[w] = nil
- end
- end
- }
- self
- end
-
- def kanji_replace_core_tk4x(knj)
- return self unless JAPANIZED_TK
-
- create_kanjifont_tk4x(knj)
- @compoundfont[1] = [@kanjifont]
- @fontslot['kanjifont'] = @kanjifont
- Tk_FontUseTBL.dup.each{|w, fobj|
- if self == fobj
- begin
- if w.include?(';')
- win, tag = w.split(';')
- winobj = tk_tcl2ruby(win)
-# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
- if winobj.kind_of? TkText
- tk_call(win, 'tag', 'configure', tag, '-kanjifont', @kanjifont)
- elsif winobj.kind_of? TkCanvas
- tk_call(win, 'itemconfigure', tag, '-kanjifont', @kanjifont)
- elsif winobj.kind_of? TkMenu
- tk_call(win, 'entryconfigure', tag, '-kanjifont', @latinfont)
- else
- raise RuntimeError, "unknown widget type"
- end
- else
-# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont)
- tk_call(w, 'configure', '-kanjifont', @kanjifont)
- end
- rescue
- Tk_FontUseTBL[w] = nil
- end
- end
- }
- self
- end
-
- def latin_replace_core_tk8x(ltn)
- begin
- tk_call('font', 'delete', @latinfont)
- rescue
- end
- create_latinfont(ltn)
- self
- end
-
- def kanji_replace_core_tk8x(knj)
- begin
- tk_call('font', 'delete', @kanjifont)
- rescue
- end
- create_kanjifont(knj)
- self
- end
-
- def measure_core_tk4x(window, text)
- 0
- end
-
- def measure_core_tk8x(window, text)
- if window
- number(tk_call('font', 'measure', @compoundfont,
- '-displayof', window, text))
- else
- number(tk_call('font', 'measure', @compoundfont, text))
- end
- end
-
- def metrics_core_tk4x(font, window, option=nil)
- # dummy
- if option
- ""
- else
- [['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]]]
- end
- end
-
- def metrics_core_tk8x(font, window, option=nil)
- if option
- if window
- number(tk_call('font', 'metrics', font, "-#{option}"))
- else
- number(tk_call('font', 'metrics', font,
- "-displayof", window, "-#{option}"))
- end
- else
- l = tk_split_list(if window
- tk_call('font','metrics',font,"-displayof",window)
- else
- tk_call('font','metrics',font)
- end)
- r = []
- while key=l.shift
- r.push [key[1..-1], l.shift.to_i]
- end
- r
- end
- end
-
- ###################################
- # private alias
- ###################################
- case (Tk::TK_VERSION)
- when /^4\.*/
- alias create_latinfont create_latinfont_tk4x
- alias create_kanjifont create_kanjifont_tk4x
- alias create_compoundfont create_compoundfont_tk4x
- alias actual_core actual_core_tk4x
- alias configure_core configure_core_tk4x
- alias configinfo_core configinfo_core_tk4x
- alias delete_core delete_core_tk4x
- alias latin_replace_core latin_replace_core_tk4x
- alias kanji_replace_core kanji_replace_core_tk4x
- alias measure_core measure_core_tk4x
- alias metrics_core metrics_core_tk4x
-
- when /^8\.[0123]/
- alias create_latinfont create_latinfont_tk8x
- alias create_kanjifont create_kanjifont_tk8x
- alias create_compoundfont create_compoundfont_tk8x
- alias actual_core actual_core_tk8x
- alias configure_core configure_core_tk8x
- alias configinfo_core configinfo_core_tk8x
- alias delete_core delete_core_tk8x
- alias latin_replace_core latin_replace_core_tk8x
- alias kanji_replace_core kanji_replace_core_tk8x
- alias measure_core measure_core_tk8x
- alias metrics_core metrics_core_tk8x
-
- when /^8\.*/
- alias create_latinfont create_latinfont_tk8x
- alias create_kanjifont create_kanjifont_tk8x
- alias create_compoundfont create_compoundfont_tk8x
- alias actual_core actual_core_tk8x
- alias configure_core configure_core_tk8x
- alias configinfo_core configinfo_core_tk8x
- alias delete_core delete_core_tk8x
- alias latin_replace_core latin_replace_core_tk8x
- alias kanji_replace_core kanji_replace_core_tk8x
- alias measure_core measure_core_tk8x
- alias metrics_core metrics_core_tk8x
-
- end
-
- ###################################
- public
- ###################################
- def call_font_configure(path, *args)
- args += hash_kv(args.pop.update(@fontslot))
- tk_call *args
- Tk_FontUseTBL[path] = self
- self
- end
-
- def used
- ret = []
- Tk_FontUseTBL.each{|key,value|
- if key.include?(';')
- win, tag = key.split(';')
- winobj = tk_tcl2ruby(win)
- if winobj.kind_of? TkText
- ret.push([winobj, winobj.tagid2obj(tag)])
- elsif winobj.kind_of? TkCanvas
- if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
- ret.push([winobj, tagobj])
- elsif (tagobj = TkcItem.id2obj(tag)).kind_of? TkcItem
- ret.push([winobj, tagobj])
- else
- ret.push([winobj, tag])
- end
- elsif winobj.kind_of? TkMenu
- ret.push([winobj, tag])
- else
- ret.push([win, tag])
- end
- else
- ret.push(tk_tcl2ruby(key)) if value == self
- end
- }
- ret
- end
-
- def id
- @id
- end
-
- def to_eval
- font
- end
-
- def font
- @compoundfont
- end
-
- def latin_font
- @latinfont
- end
-
- def kanji_font
- @kanjifont
- end
-
- def actual(option=nil)
- actual_core(@compoundfont, nil, option)
- end
-
- def actual_displayof(window, option=nil)
- window = '.' unless window
- actual_core(@compoundfont, window, option)
- end
-
- def latin_actual(option=nil)
- actual_core(@latinfont, nil, option)
- end
-
- def latin_actual_displayof(window, option=nil)
- window = '.' unless window
- actual_core(@latinfont, window, option)
- end
-
- def kanji_actual(option=nil)
- #if JAPANIZED_TK
- if @kanjifont != ""
- actual_core(@kanjifont, nil, option)
- else
- actual_core_tk4x(nil, nil, option)
- end
- end
-
- def kanji_actual_displayof(window, option=nil)
- #if JAPANIZED_TK
- if @kanjifont != ""
- window = '.' unless window
- actual_core(@kanjifont, window, option)
- else
- actual_core_tk4x(nil, window, option)
- end
- end
-
- def [](slot)
- configinfo slot
- end
-
- def []=(slot, val)
- configure slot, val
- end
-
- def configure(slot, value=None)
- configure_core(@compoundfont, slot, value)
- end
-
- def configinfo(slot=nil)
- configinfo_core(@compoundfont, slot)
- end
-
- def delete
- delete_core
- end
-
- def latin_configure(slot, value=None)
- if JAPANIZED_TK
- configure_core(@latinfont, slot, value)
- else
- configure(slot, value)
- end
- end
-
- def latin_configinfo(slot=nil)
- if JAPANIZED_TK
- configinfo_core(@latinfont, slot)
- else
- configinfo(slot)
- end
- end
-
- def kanji_configure(slot, value=None)
- #if JAPANIZED_TK
- if @kanjifont != ""
- configure_core(@kanjifont, slot, value)
- configure('size'=>configinfo('size')) # to reflect new configuration
- else
- #""
- configure(slot, value)
- end
- end
-
- def kanji_configinfo(slot=nil)
- #if JAPANIZED_TK
- if @kanjifont != ""
- configinfo_core(@kanjifont, slot)
- else
- #[]
- configinfo(slot)
- end
- end
-
- def replace(ltn, knj)
- latin_replace(ltn)
- kanji_replace(knj)
- self
- end
-
- def latin_replace(ltn)
- latin_replace_core(ltn)
- reset_pointadjust
- end
-
- def kanji_replace(knj)
- kanji_replace_core(knj)
- reset_pointadjust
- end
-
- def measure(text)
- measure_core(nil, text)
- end
-
- def measure_displayof(window, text)
- window = '.' unless window
- measure_core(window, text)
- end
-
- def metrics(option=nil)
- metrics_core(@compoundfont, nil, option)
- end
-
- def metrics_displayof(window, option=nil)
- window = '.' unless window
- metrics_core(@compoundfont, window, option)
- end
-
- def latin_metrics(option=nil)
- metrics_core(@latinfont, nil, option)
- end
-
- def latin_metrics_displayof(window, option=nil)
- window = '.' unless window
- metrics_core(@latinfont, window, option)
- end
-
- def kanji_metrics(option=nil)
- if JAPANIZED_TK
- metrics_core(@kanjifont, nil, option)
- else
- metrics_core_tk4x(nil, nil, option)
- end
- end
-
- def kanji_metrics_displayof(window, option=nil)
- if JAPANIZED_TK
- window = '.' unless window
- metrics_core(@kanjifont, window, option)
- else
- metrics_core_tk4x(nil, window, option)
- end
- end
-
- def reset_pointadjust
- begin
- if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
- configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
- kanji_actual.assoc('size')[1].to_f )
- end
- rescue
- end
- self
- end
-
- ###################################
- # public alias
- ###################################
- alias ascii_font latin_font
- alias create_asciifont create_latinfont
- alias ascii_actual latin_actual
- alias ascii_actual_displayof latin_actual_displayof
- alias ascii_configure latin_configure
- alias ascii_configinfo latin_configinfo
- alias ascii_replace latin_replace
- alias ascii_metrics latin_metrics
-
-end
-
-module TkTreatTagFont
- def font_configinfo
- @parent.tagfont_configinfo(@id)
- end
- alias font font_configinfo
-
- def font_configure(slot)
- @parent.tagfont_configure(@id, slot)
- end
-
- def latinfont_configure(ltn, keys=nil)
- @parent.latintagfont_configure(@id, ltn, keys)
- end
- alias asciifont_configure latinfont_configure
-
- def kanjifont_configure(knj, keys=nil)
- @parent.kanjitagfont_configure(@id, ltn, keys)
- end
-
- def font_copy(window, wintag=nil)
- @parent.tagfont_copy(@id, window, wintag)
- end
-
- def latinfont_copy(window, wintag=nil)
- @parent.latintagfont_copy(@id, window, wintag)
- end
- alias asciifont_copy latinfont_copy
-
- def kanjifont_copy(window, wintag=nil)
- @parent.kanjitagfont_copy(@id, window, wintag)
- end
-end
+require 'tk/font'
diff --git a/ext/tk/lib/tkmacpkg.rb b/ext/tk/lib/tkmacpkg.rb
new file mode 100644
index 0000000000..35560e78ce
--- /dev/null
+++ b/ext/tk/lib/tkmacpkg.rb
@@ -0,0 +1,4 @@
+#
+# tkmacpkg.rb - load tk/macpkg.rb
+#
+require 'tk/macpkg'
diff --git a/ext/tk/lib/tkmenubar.rb b/ext/tk/lib/tkmenubar.rb
index 441f3f5c03..70214fda1a 100644
--- a/ext/tk/lib/tkmenubar.rb
+++ b/ext/tk/lib/tkmenubar.rb
@@ -1,137 +1,4 @@
#
-# tkmenubar.rb
+# tkmenubar.rb - load tk/menubar.rb
#
-# Copyright (C) 1998 maeda shugo. All rights reserved.
-# This file can be distributed under the terms of the Ruby.
-
-# Usage:
-#
-# menu_spec = [
-# [['File', 0],
-# ['Open', proc{puts('Open clicked')}, 0],
-# '---',
-# ['Quit', proc{exit}, 0]],
-# [['Edit', 0],
-# ['Cut', proc{puts('Cut clicked')}, 2],
-# ['Copy', proc{puts('Copy clicked')}, 0],
-# ['Paste', proc{puts('Paste clicked')}, 0]]
-# ]
-# menubar = TkMenubar.new(nil, menu_spec,
-# 'tearoff'=>false,
-# 'foreground'=>'grey40',
-# 'activeforeground'=>'red',
-# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1')
-# menubar.pack('side'=>'top', 'fill'=>'x')
-#
-#
-# OR
-#
-#
-# menubar = TkMenubar.new
-# menubar.add_menu([['File', 0],
-# ['Open', proc{puts('Open clicked')}, 0],
-# '---',
-# ['Quit', proc{exit}, 0]])
-# menubar.add_menu([['Edit', 0],
-# ['Cut', proc{puts('Cut clicked')}, 2],
-# ['Copy', proc{puts('Copy clicked')}, 0],
-# ['Paste', proc{puts('Paste clicked')}, 0]])
-# menubar.configure('tearoff', false)
-# menubar.configure('foreground', 'grey40')
-# menubar.configure('activeforeground', 'red')
-# menubar.configure('font', '-adobe-helvetica-bold-r-*--12-*-iso8859-1')
-# menubar.pack('side'=>'top', 'fill'=>'x')
-
-# The format of the menu_spec is:
-# [
-# [
-# [button text, underline, accelerator],
-# [menu label, command, underline, accelerator],
-# '---', # separator
-# ...
-# ],
-# ...
-# ]
-
-# underline and accelerator are optional parameters.
-# Hashes are OK instead of Arrays.
-
-# To use add_menu, configuration must be done by calling configure after
-# adding all menus by add_menu, not by the constructor arguments.
-
-require "tk"
-
-class TkMenubar<TkFrame
-
- include TkComposite
-
- def initialize(parent = nil, spec = nil, options = nil)
- super(parent, options)
-
- @menus = []
-
- if spec
- for menu_info in spec
- add_menu(menu_info)
- end
- end
-
- if options
- for key, value in options
- configure(key, value)
- end
- end
- end
-
- def add_menu(menu_info)
- btn_info = menu_info.shift
- mbtn = TkMenubutton.new(@frame)
-
- if btn_info.kind_of?(Hash)
- for key, value in btn_info
- mbtn.configure(key, value)
- end
- elsif btn_info.kind_of?(Array)
- mbtn.configure('text', btn_info[0]) if btn_info[0]
- mbtn.configure('underline', btn_info[1]) if btn_info[1]
- mbtn.configure('accelerator', btn_info[2]) if btn_info[2]
- else
- mbtn.configure('text', btn_info)
- end
-
- menu = TkMenu.new(mbtn)
-
- for item_info in menu_info
- if item_info.kind_of?(Hash)
- menu.add('command', item_info)
- elsif item_info.kind_of?(Array)
- options = {}
- options['label'] = item_info[0] if item_info[0]
- options['command'] = item_info[1] if item_info[1]
- options['underline'] = item_info[2] if item_info[2]
- options['accelerator'] = item_info[3] if item_info[3]
- menu.add('command', options)
- elsif /^-+$/ =~ item_info
- menu.add('sep')
- else
- menu.add('command', 'label' => item_info)
- end
- end
-
- mbtn.menu(menu)
- @menus.push([mbtn, menu])
- delegate('tearoff', menu)
- delegate('foreground', mbtn, menu)
- delegate('background', mbtn, menu)
- delegate('disabledforeground', mbtn, menu)
- delegate('activeforeground', mbtn, menu)
- delegate('activebackground', mbtn, menu)
- delegate('font', mbtn, menu)
- delegate('kanjifont', mbtn, menu)
- mbtn.pack('side' => 'left')
- end
-
- def [](index)
- return @menus[index]
- end
-end
+require 'tk/menubar'
diff --git a/ext/tk/lib/tkmngfocus.rb b/ext/tk/lib/tkmngfocus.rb
index 921fb646e7..fe70950e8e 100644
--- a/ext/tk/lib/tkmngfocus.rb
+++ b/ext/tk/lib/tkmngfocus.rb
@@ -1,27 +1,4 @@
#
-# tkmngfocus.rb : methods for Tcl/Tk standard library 'focus.tcl'
-# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+# tkmngfocus.rb - load tk/mngfocus.rb
#
-require 'tk'
-
-module TkManageFocus
- extend Tk
-
- def TkManageFocus.followsMouse
- tk_call 'tk_focusFollowsMouse'
- end
-
- def TkManageFocus.next(window)
- tk_call 'tk_focusNext', window
- end
- def focusNext
- TkManageFocus.next(self)
- end
-
- def TkManageFocus.prev(window)
- tk_call 'tk_focusPrev', window
- end
- def focusPrev
- TkManageFocus.prev(self)
- end
-end
+require 'tk/mngfocus'
diff --git a/ext/tk/lib/tkpalette.rb b/ext/tk/lib/tkpalette.rb
index a2dc7c87cb..56b203bbb9 100644
--- a/ext/tk/lib/tkpalette.rb
+++ b/ext/tk/lib/tkpalette.rb
@@ -1,48 +1,4 @@
#
-# tkpalette.rb : methods for Tcl/Tk standard library 'palette.tcl'
-# 1998/06/21 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+# tkpalette.rb - load tk/palette.rb
#
-require 'tk'
-
-module TkPalette
- include Tk
- extend Tk
-
- def TkPalette.set(*args)
- args = args.to_a.flatten if args.kind_of? Hash
- tk_call 'tk_setPalette', *args
- end
- def TkPalette.setPalette(*args)
- TkPalette.set(*args)
- end
-
- def TkPalette.bisque
- tk_call 'tk_bisque'
- end
-
- def TkPalette.darken(color, percent)
- tk_call 'tkDarken', color, percent
- end
-
- def TkPalette.recolorTree(window, colors)
- if not colors.kind_of?(Hash)
- fail "2nd arg need to be Hash"
- end
-
- colors.each{|key, value|
- begin
- if window.cget(key) == tk_call('set', "tkPalette(#{key})")
- window[key] = colors[key]
- end
- rescue
- # ignore
- end
- }
-
- TkWinfo.children(window).each{|w| TkPalette.recolorTree(w, colors)}
- end
-
- def recolorTree(colors)
- TkPalette.recolorTree(self, colors)
- end
-end
+require 'tk/palette'
diff --git a/ext/tk/lib/tkscrollbox.rb b/ext/tk/lib/tkscrollbox.rb
index 6236430491..6093b2e4e7 100644
--- a/ext/tk/lib/tkscrollbox.rb
+++ b/ext/tk/lib/tkscrollbox.rb
@@ -1,29 +1,4 @@
#
-# tkscrollbox.rb - Tk Listbox with Scrollbar
-# as an example of Composite Widget
-# $Date$
-# by Yukihiro Matsumoto <matz@netlab.co.jp>
-
-require 'tk.rb'
-
-class TkScrollbox<TkListbox
- include TkComposite
- def initialize_composite(keys=nil)
- list = TkListbox.new(@frame)
- scroll = TkScrollbar.new(@frame)
- @path = list.path
-
- list.configure 'yscroll', scroll.path+" set"
- list.pack 'side'=>'left','fill'=>'both','expand'=>'yes'
- scroll.configure 'command', list.path+" yview"
- scroll.pack 'side'=>'right','fill'=>'y'
-
- delegate('DEFAULT', list)
- delegate('foreground', list)
- delegate('background', list, scroll)
- delegate('borderwidth', @frame)
- delegate('relief', @frame)
-
- configure keys if keys
- end
-end
+# tkscrollbox.rb - load tk/scrollbox.rb
+#
+require 'tk/scrollbox'
diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb
index 51b5d82b60..97ad62a3ea 100644
--- a/ext/tk/lib/tktext.rb
+++ b/ext/tk/lib/tktext.rb
@@ -1,1085 +1,4 @@
#
-# tktext.rb - Tk text classes
-# $Date$
-# by Yukihiro Matsumoto <matz@caelum.co.jp>
-
-require 'tk.rb'
-require 'tkfont'
-
-module TkTreatTextTagFont
- def tagfont_configinfo(tag)
- if tag.kind_of? TkTextTag
- pathname = self.path + ';' + tag.id
- else
- pathname = self.path + ';' + tag
- end
- ret = TkFont.used_on(pathname)
- if ret == nil
- ret = TkFont.init_widget_font(pathname,
- self.path, 'tag', 'configure', tag)
- end
- ret
- end
- alias tagfontobj tagfont_configinfo
-
- def tagfont_configure(tag, slot)
- if tag.kind_of? TkTextTag
- pathname = self.path + ';' + tag.id
- else
- pathname = self.path + ';' + tag
- end
- if (fnt = slot.delete('font'))
- if fnt.kind_of? TkFont
- return fnt.call_font_configure(pathname,
- self.path,'tag','configure',tag,slot)
- else
- latintagfont_configure(tag, fnt) if fnt
- end
- end
- if (ltn = slot.delete('latinfont'))
- latintagfont_configure(tag, ltn) if ltn
- end
- if (ltn = slot.delete('asciifont'))
- latintagfont_configure(tag, ltn) if ltn
- end
- if (knj = slot.delete('kanjifont'))
- kanjitagfont_configure(tag, knj) if knj
- end
-
- tk_call(self.path, 'tag', 'configure', tag, *hash_kv(slot)) if slot != {}
- self
- end
-
- def latintagfont_configure(tag, ltn, keys=nil)
- fobj = tagfontobj(tag)
- if ltn.kind_of? TkFont
- conf = {}
- ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []}
- if conf == {}
- fobj.latin_replace(ltn)
- fobj.latin_configure(keys) if keys
- elsif keys
- fobj.latin_configure(conf.update(keys))
- else
- fobj.latin_configure(conf)
- end
- else
- fobj.latin_replace(ltn)
- end
- end
- alias asciitagfont_configure latintagfont_configure
-
- def kanjitagfont_configure(tag, knj, keys=nil)
- fobj = tagfontobj(tag)
- if knj.kind_of? TkFont
- conf = {}
- knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []}
- if conf == {}
- fobj.kanji_replace(knj)
- fobj.kanji_configure(keys) if keys
- elsif keys
- fobj.kanji_configure(conf.update(keys))
- else
- fobj.kanji_configure(conf)
- end
- else
- fobj.kanji_replace(knj)
- end
- end
-
- def tagfont_copy(tag, window, wintag=nil)
- if wintag
- window.tagfontobj(wintag).configinfo.each{|key,value|
- tagfontobj(tag).configure(key,value)
- }
- tagfontobj(tag).replace(window.tagfontobj(wintag).latin_font,
- window.tagfontobj(wintag).kanji_font)
- else
- window.tagfont(wintag).configinfo.each{|key,value|
- tagfontobj(tag).configure(key,value)
- }
- tagfontobj(tag).replace(window.fontobj.latin_font,
- window.fontobj.kanji_font)
- end
- end
-
- def latintagfont_copy(tag, window, wintag=nil)
- if wintag
- tagfontobj(tag).latin_replace(window.tagfontobj(wintag).latin_font)
- else
- tagfontobj(tag).latin_replace(window.fontobj.latin_font)
- end
- end
- alias asciitagfont_copy latintagfont_copy
-
- def kanjitagfont_copy(tag, window, wintag=nil)
- if wintag
- tagfontobj(tag).kanji_replace(window.tagfontobj(wintag).kanji_font)
- else
- tagfontobj(tag).kanji_replace(window.fontobj.kanji_font)
- end
- end
-end
-
-class TkText<TkTextWin
- include TkTreatTextTagFont
- include Scrollable
-
- WidgetClassName = 'Text'.freeze
- WidgetClassNames[WidgetClassName] = self
-
- def self.to_eval
- WidgetClassName
- end
-
- def self.new(*args, &block)
- obj = super(*args){}
- obj.init_instance_variable
- obj.instance_eval &block if defined? yield
- obj
- end
-
- def init_instance_variable
- @tags = {}
- end
-
- def create_self
- tk_call 'text', @path
- init_instance_variable
- end
-
- def index(index)
- tk_send 'index', index
- end
-
- def value
- tk_send 'get', "1.0", "end - 1 char"
- end
-
- def value= (val)
- tk_send 'delete', "1.0", 'end'
- tk_send 'insert', "1.0", val
- end
-
- def _addcmd(cmd)
- @cmdtbl.push cmd
- end
-
- def _addtag(name, obj)
- @tags[name] = obj
- end
-
- def tagid2obj(tagid)
- if not @tags[tagid]
- tagid
- else
- @tags[tagid]
- end
- end
-
- def tag_names(index=None)
- tk_split_list(tk_send('tag', 'names', index)).collect{|elt|
- tagid2obj(elt)
- }
- end
-
- def mark_names
- tk_split_list(tk_send('mark', 'names')).collect{|elt|
- tagid2obj(elt)
- }
- end
-
- def mark_next(index)
- tagid2obj(tk_send('mark', 'next', index))
- end
-
- def mark_previous(index)
- tagid2obj(tk_send('mark', 'previous', index))
- end
-
- def window_names
- tk_send('window', 'names').collect{|elt|
- tagid2obj(elt)
- }
- end
-
- def image_names
- tk_send('image', 'names').collect{|elt|
- tagid2obj(elt)
- }
- end
-
- def set_insert(index)
- tk_send 'mark', 'set', 'insert', index
- end
-
- def set_current(index)
- tk_send 'mark', 'set', 'current', index
- end
-
- def insert(index, chars, *tags)
- super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')
- end
-
- def destroy
- @tags = {} unless @tags
- @tags.each_value do |t|
- t.destroy
- end
- super
- end
-
- def backspace
- self.delete 'insert'
- end
-
- def compare(idx1, op, idx2)
- bool(tk_send('compare', idx1, op, idx2))
- end
-
- def debug
- bool(tk_send('debug'))
- end
- def debug=(boolean)
- tk_send 'debug', boolean
- end
-
- def bbox(index)
- inf = tk_send('bbox', index)
- (inf == "")? [0,0,0,0]: inf
- end
- def dlineinfo(index)
- inf = tk_send('dlineinfo', index)
- (inf == "")? [0,0,0,0,0]: inf
- end
-
- def yview_pickplace(*what)
- tk_send 'yview', '-pickplace', *what
- end
-
- def xview_pickplace(*what)
- tk_send 'xview', '-pickplace', *what
- end
-
- def tag_add(tag, index1, index2=None)
- tk_send 'tag', 'add', tag, index1, index2
- end
-
- def tag_bind(tag, seq, cmd=Proc.new, args=nil)
- _bind(['tag', 'bind', tag], seq, cmd, args)
- end
-
- def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
- _bind_append(['tag', 'bind', tag], seq, cmd, args)
- end
-
- def tag_bindinfo(tag, context=nil)
- _bindinfo(['tag', 'bind', tag], context)
- end
-
- def tag_cget(tag, key)
- case key
- when 'text', 'label', 'show', 'data', 'flie'
- tk_call @path, 'tag', 'cget', tag, "-#{key}"
- else
- tk_tcl2ruby tk_call @path, 'tag', 'cget', tag, "-#{key}"
- end
- end
-
- def tag_configure(tag, key, val=None)
- if key.kind_of? Hash
- if ( key['font'] || key['kanjifont'] \
- || key['latinfont'] || key['asciifont'] )
- tagfont_configure(tag, key.dup)
- else
- tk_send 'tag', 'configure', tag, *hash_kv(key)
- end
-
- else
- if key == 'font' || key == 'kanjifont' ||
- key == 'latinfont' || key == 'asciifont'
- tagfont_configure({key=>val})
- else
- tk_send 'tag', 'configure', tag, "-#{key}", val
- end
- end
- end
-
- def tag_configinfo(tag, key=nil)
- if key
- case key
- when 'text', 'label', 'show', 'data', 'flie'
- conf = tk_split_simplelist(tk_send('tag','configure',tag,"-#{key}"))
- else
- conf = tk_split_list(tk_send('tag','configure',tag,"-#{key}"))
- end
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_send('tag', 'configure', tag)).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show', 'data', 'flie'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf
- }
- end
- end
-
- def tag_raise(tag, above=None)
- tk_send 'tag', 'raise', tag, above
- end
-
- def tag_lower(tag, below=None)
- tk_send 'tag', 'lower', tag, below
- end
-
- def tag_remove(tag, *index)
- tk_send 'tag', 'remove', tag, *index
- end
-
- def tag_ranges(tag)
- l = tk_split_simplelist(tk_send('tag', 'ranges', tag))
- r = []
- while key=l.shift
- r.push [key, l.shift]
- end
- r
- end
-
- def tag_nextrange(tag, first, last=None)
- tk_split_simplelist(tk_send('tag', 'nextrange', tag, first, last))
- end
-
- def tag_prevrange(tag, first, last=None)
- tk_split_simplelist(tk_send('tag', 'prevrange', tag, first, last))
- end
-
- def _ktext_length(txt)
- if $KCODE !~ /n/i
- return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
- end
-
- # $KCODE == 'NONE'
- if JAPANIZED_TK
- tk_call('kstring', 'length', txt).to_i
- else
- begin
- tk_call('encoding', 'convertto', 'ascii', txt).length
- rescue StandardError, NameError
- # sorry, I have no plan
- txt.length
- end
- end
- end
- private :_ktext_length
-
- def search_with_length(pat,start,stop=None)
- pat = pat.chr if pat.kind_of? Integer
- if stop != None
- return ["", 0] if compare(start,'>=',stop)
- txt = get(start,stop)
- if (pos = txt.index(pat))
- match = $&
- #pos = txt[0..(pos-1)].split('').length if pos > 0
- pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
- if pat.kind_of? String
- #return [index(start + " + #{pos} chars"), pat.split('').length]
- return [index(start + " + #{pos} chars"),
- _ktext_length(pat), pat.dup]
- else
- #return [index(start + " + #{pos} chars"), $&.split('').length]
- return [index(start + " + #{pos} chars"),
- _ktext_length(match), match]
- end
- else
- return ["", 0]
- end
- else
- txt = get(start,'end - 1 char')
- if (pos = txt.index(pat))
- match = $&
- #pos = txt[0..(pos-1)].split('').length if pos > 0
- pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
- if pat.kind_of? String
- #return [index(start + " + #{pos} chars"), pat.split('').length]
- return [index(start + " + #{pos} chars"),
- _ktext_length(pat), pat.dup]
- else
- #return [index(start + " + #{pos} chars"), $&.split('').length]
- return [index(start + " + #{pos} chars"),
- _ktext_length(match), match]
- end
- else
- txt = get('1.0','end - 1 char')
- if (pos = txt.index(pat))
- match = $&
- #pos = txt[0..(pos-1)].split('').length if pos > 0
- pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
- if pat.kind_of? String
- #return [index("1.0 + #{pos} chars"), pat.split('').length]
- return [index("1.0 + #{pos} chars"),
- _ktext_length(pat), pat.dup]
- else
- #return [index("1.0 + #{pos} chars"), $&.split('').length]
- return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
- end
- else
- return ["", 0]
- end
- end
- end
- end
-
- def search(pat,start,stop=None)
- search_with_length(pat,start,stop)[0]
- end
-
- def rsearch_with_length(pat,start,stop=None)
- pat = pat.chr if pat.kind_of? Integer
- if stop != None
- return ["", 0] if compare(start,'<=',stop)
- txt = get(stop,start)
- if (pos = txt.rindex(pat))
- match = $&
- #pos = txt[0..(pos-1)].split('').length if pos > 0
- pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
- if pat.kind_of? String
- #return [index(stop + " + #{pos} chars"), pat.split('').length]
- return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
- else
- #return [index(stop + " + #{pos} chars"), $&.split('').length]
- return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
- end
- else
- return ["", 0]
- end
- else
- txt = get('1.0',start)
- if (pos = txt.rindex(pat))
- match = $&
- #pos = txt[0..(pos-1)].split('').length if pos > 0
- pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
- if pat.kind_of? String
- #return [index("1.0 + #{pos} chars"), pat.split('').length]
- return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
- else
- #return [index("1.0 + #{pos} chars"), $&.split('').length]
- return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
- end
- else
- txt = get('1.0','end - 1 char')
- if (pos = txt.rindex(pat))
- match = $&
- #pos = txt[0..(pos-1)].split('').length if pos > 0
- pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
- if pat.kind_of? String
- #return [index("1.0 + #{pos} chars"), pat.split('').length]
- return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
- else
- #return [index("1.0 + #{pos} chars"), $&.split('').length]
- return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
- end
- else
- return ["", 0]
- end
- end
- end
- end
-
- def rsearch(pat,start,stop=None)
- rsearch_with_length(pat,start,stop)[0]
- end
-
- def dump(type_info, *index, &block)
- args = type_info.collect{|inf| '-' + inf}
- args << '-command' << Proc.new(&block) if iterator?
- str = tk_send('dump', *(args + index))
- result = []
- sel = nil
- i = 0
- while i < str.size
- # retrieve key
- idx = str.index(/ /, i)
- result.push str[i..(idx-1)]
- i = idx + 1
-
- # retrieve value
- case result[-1]
- when 'text'
- if str[i] == ?{
- # text formed as {...}
- val, i = _retrieve_braced_text(str, i)
- result.push val
- else
- # text which may contain backslahes
- val, i = _retrieve_backslashed_text(str, i)
- result.push val
- end
- else
- idx = str.index(/ /, i)
- val = str[i..(idx-1)]
- case result[-1]
- when 'mark'
- case val
- when 'insert'
- result.push TkTextMarkInsert.new(self)
- when 'current'
- result.push TkTextMarkCurrent.new(self)
- when 'anchor'
- result.push TkTextMarkAnchor.new(self)
- else
- result.push tk_tcl2ruby(val)
- end
- when 'tagon'
- if val == 'sel'
- if sel
- result.push sel
- else
- result.push TkTextTagSel.new(self)
- end
- else
- result.push tk_tcl2ruby(val)
- end
- when 'tagoff'
- result.push tk_tcl2ruby(sel)
- when 'window'
- result.push tk_tcl2ruby(val)
- end
- i = idx + 1
- end
-
- # retrieve index
- idx = str.index(/ /, i)
- if idx
- result.push str[i..(idx-1)]
- i = idx + 1
- else
- result.push str[i..-1]
- break
- end
- end
-
- kvis = []
- until result.empty?
- kvis.push [result.shift, result.shift, result.shift]
- end
- kvis # result is [[key1, value1, index1], [key2, value2, index2], ...]
- end
-
- def _retrieve_braced_text(str, i)
- cnt = 0
- idx = i
- while idx < str.size
- case str[idx]
- when ?{
- cnt += 1
- when ?}
- cnt -= 1
- if cnt == 0
- break
- end
- end
- idx += 1
- end
- return str[i+1..idx-1], idx + 2
- end
- private :_retrieve_braced_text
-
- def _retrieve_backslashed_text(str, i)
- j = i
- idx = nil
- loop {
- idx = str.index(/ /, j)
- if str[idx-1] == ?\\
- j += 1
- else
- break
- end
- }
- val = str[i..(idx-1)]
- val.gsub!(/\\( |\{|\})/, '\1')
- return val, idx + 1
- end
- private :_retrieve_backslashed_text
-
- def dump_all(*index, &block)
- dump(['all'], *index, &block)
- end
- def dump_mark(*index, &block)
- dump(['mark'], *index, &block)
- end
- def dump_tag(*index, &block)
- dump(['tag'], *index, &block)
- end
- def dump_text(*index, &block)
- dump(['text'], *index, &block)
- end
- def dump_window(*index, &block)
- dump(['window'], *index, &block)
- end
- def dump_image(*index, &block)
- dump(['image'], *index, &block)
- end
-end
-
-class TkTextTag<TkObject
- include TkTreatTagFont
-
- Tk_TextTag_ID = ['tag0000']
-
- def initialize(parent, *args)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @parent = @t = parent
- @path = @id = Tk_TextTag_ID[0]
- Tk_TextTag_ID[0] = Tk_TextTag_ID[0].succ
- #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys)
- if args != [] then
- keys = args.pop
- if keys.kind_of? Hash then
- add(*args) if args != []
- configure(keys)
- else
- args.push keys
- add(*args)
- end
- end
- @t._addtag id, self
- end
-
- def id
- return @id
- end
-
- def first
- @id + '.first'
- end
-
- def last
- @id + '.last'
- end
-
- def add(*index)
- tk_call @t.path, 'tag', 'add', @id, *index
- end
-
- def remove(*index)
- tk_call @t.path, 'tag', 'remove', @id, *index
- end
-
- def ranges
- l = tk_split_simplelist(tk_call(@t.path, 'tag', 'ranges', @id))
- r = []
- while key=l.shift
- r.push [key, l.shift]
- end
- r
- end
-
- def nextrange(first, last=None)
- tk_split_simplelist(tk_call(@t.path, 'tag', 'nextrange', @id, first, last))
- end
-
- def prevrange(first, last=None)
- tk_split_simplelist(tk_call(@t.path, 'tag', 'prevrange', @id, first, last))
- end
-
- def [](key)
- cget key
- end
-
- def []=(key,val)
- configure key, val
- end
-
- def cget(key)
- case key
- when 'text', 'label', 'show', 'data', 'flie'
- tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
- else
- tk_tcl2ruby tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
- end
- end
-
- def configure(key, val=None)
- @t.tag_configure @id, key, val
- end
-# def configure(key, val=None)
-# if key.kind_of? Hash
-# tk_call @t.path, 'tag', 'configure', @id, *hash_kv(key)
-# else
-# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", val
-# end
-# end
-# def configure(key, value)
-# if value == FALSE
-# value = "0"
-# elsif value.kind_of? Proc
-# value = install_cmd(value)
-# end
-# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value
-# end
-
- def configinfo(key=nil)
- @t.tag_configinfo @id, key
- end
-
- def bind(seq, cmd=Proc.new, args=nil)
- _bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
- end
-
- def bind_append(seq, cmd=Proc.new, args=nil)
- _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
- end
-
- def bindinfo(context=nil)
- _bindinfo([@t.path, 'tag', 'bind', @id], context)
- end
-
- def raise(above=None)
- tk_call @t.path, 'tag', 'raise', @id, above
- end
-
- def lower(below=None)
- tk_call @t.path, 'tag', 'lower', @id, below
- end
-
- def destroy
- tk_call @t.path, 'tag', 'delete', @id
- end
-end
-
-class TkTextTagSel<TkTextTag
- def initialize(parent, keys=nil)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @t = parent
- @path = @id = 'sel'
- #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys)
- configure(keys) if keys
- @t._addtag id, self
- end
-end
-
-class TkTextMark<TkObject
- Tk_TextMark_ID = ['mark0000']
- def initialize(parent, index)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @t = parent
- @path = @id = Tk_TextMark_ID[0]
- Tk_TextMark_ID[0] = Tk_TextMark_ID[0].succ
- tk_call @t.path, 'mark', 'set', @id, index
- @t._addtag id, self
- end
- def id
- return @id
- end
-
- def set(where)
- tk_call @t.path, 'mark', 'set', @id, where
- end
-
- def unset
- tk_call @t.path, 'mark', 'unset', @id
- end
- alias destroy unset
-
- def gravity
- tk_call @t.path, 'mark', 'gravity', @id
- end
-
- def gravity=(direction)
- tk_call @t.path, 'mark', 'gravity', @id, direction
- end
-
- def next(index)
- @t.tagid2obj(tk_call(@t.path, 'mark', 'next', index))
- end
-
- def previous(index)
- @t.tagid2obj(tk_call(@t.path, 'mark', 'previous', index))
- end
-end
-
-class TkTextMarkInsert<TkTextMark
- def initialize(parent, index=nil)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @t = parent
- @path = @id = 'insert'
- tk_call @t.path, 'mark', 'set', @id, index if index
- @t._addtag id, self
- end
-end
-
-class TkTextMarkCurrent<TkTextMark
- def initialize(parent,index=nil)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @t = parent
- @path = @id = 'current'
- tk_call @t.path, 'mark', 'set', @id, index if index
- @t._addtag id, self
- end
-end
-
-class TkTextMarkAnchor<TkTextMark
- def initialize(parent,index=nil)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @t = parent
- @path = @id = 'anchor'
- tk_call @t.path, 'mark', 'set', @id, index if index
- @t._addtag id, self
- end
-end
-
-class TkTextWindow<TkObject
- def initialize(parent, index, keys)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @t = parent
- if index == 'end'
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
- elsif index.kind_of? TkTextMark
- if tk_call(@t.path,'index',index.path) == tk_call(@t.path,'index','end')
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
- else
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index.path))
- end
- else
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index))
- end
- @path.gravity = 'left'
- @index = @path.path
- @id = keys['window']
- if keys['create']
- @p_create = keys['create']
- if @p_create.kind_of? Proc
- keys['create'] = install_cmd(proc{@id = @p_create.call; @id.path})
- end
- end
- tk_call @t.path, 'window', 'create', @index, *hash_kv(keys)
- end
-
- def [](slot)
- cget(slot)
- end
- def []=(slot, value)
- configure(slot, value)
- end
-
- def cget(slot)
- case slot
- when 'text', 'label', 'show', 'data', 'flie'
- tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
- else
- tk_tcl2ruby tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
- end
- end
-
- def configure(slot, value=None)
- if slot.kind_of? Hash
- @id = slot['window'] if slot['window']
- if slot['create']
- self.create=value
- slot['create']=nil
- end
- if slot.size > 0
- tk_call @t.path, 'window', 'configure', @index, *hash_kv(slot)
- end
- else
- @id = value if slot == 'window'
- if slot == 'create'
- self.create=value
- else
- tk_call @t.path, 'window', 'configure', @index, "-#{slot}", value
- end
- end
- end
-
- def window
- @id
- end
-
- def window=(value)
- tk_call @t.path, 'window', 'configure', @index, '-window', value
- @id = value
- end
-
- def create
- @p_create
- end
-
- def create=(value)
- @p_create = value
- if @p_create.kind_of? Proc
- value = install_cmd(proc{@id = @p_create.call})
- end
- tk_call @t.path, 'window', 'configure', @index, '-create', value
- end
-
- def configinfo(slot = nil)
- if slot
- case slot
- when 'text', 'label', 'show', 'data', 'flie'
- conf = tk_split_simplelist(tk_call @t.path, 'window', 'configure',
- @index, "-#{slot}")
- else
- conf = tk_split_list(tk_call @t.path, 'window', 'configure',
- @index, "-#{slot}")
- end
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_call @t.path, 'window', 'configure',
- @index).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show', 'data', 'flie'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf
- }
- end
- end
-
-end
-
-class TkTextImage<TkObject
- def initialize(parent, index, keys)
- if not parent.kind_of?(TkText)
- fail format("%s need to be TkText", parent.inspect)
- end
- @t = parent
- if index == 'end'
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
- elsif index.kind_of? TkTextMark
- if tk_call(@t.path,'index',index.path) == tk_call(@t.path,'index','end')
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
- else
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index.path))
- end
- else
- @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index))
- end
- @path.gravity = 'left'
- @index = @path.path
- @id = tk_call(@t.path, 'image', 'create', @index, *hash_kv(keys))
- end
-
- def [](slot)
- cget(slot)
- end
- def []=(slot, value)
- configure(slot, value)
- end
-
- def cget(slot)
- case slot
- when 'text', 'label', 'show', 'data', 'flie'
- tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
- else
- tk_tcl2ruby tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
- end
- end
-
- def configure(slot, value=None)
- if slot.kind_of? Hash
- tk_call @t.path, 'image', 'configure', @index, *hash_kv(slot)
- else
- tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
- end
- end
-# def configure(slot, value)
-# tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
-# end
-
- def image
- tk_call @t.path, 'image', 'configure', @index, '-image'
- end
-
- def image=(value)
- tk_call @t.path, 'image', 'configure', @index, '-image', value
- end
-
- def configinfo(slot = nil)
- if slot
- case slot
- when 'text', 'label', 'show', 'data', 'flie'
- conf = tk_split_simplelist(tk_call @t.path, 'image', 'configure',
- @index, "-#{slot}")
- else
- conf = tk_split_list(tk_call @t.path, 'image', 'configure',
- @index, "-#{slot}")
- end
- conf[0] = conf[0][1..-1]
- conf
- else
- tk_split_simplelist(tk_call @t.path, 'image', 'configure',
- @index).collect{|conflist|
- conf = tk_split_simplelist(conflist)
- conf[0] = conf[0][1..-1]
- case conf[0]
- when 'text', 'label', 'show', 'data', 'flie'
- else
- if conf[3]
- if conf[3].index('{')
- conf[3] = tk_split_list(conf[3])
- else
- conf[3] = tk_tcl2ruby(conf[3])
- end
- end
- if conf[4]
- if conf[4].index('{')
- conf[4] = tk_split_list(conf[4])
- else
- conf[4] = tk_tcl2ruby(conf[4])
- end
- end
- end
- conf
- }
- end
- end
-end
+# tktext.rb - load tk/text.rb
+#
+require 'tk/text'
diff --git a/ext/tk/lib/tkvirtevent.rb b/ext/tk/lib/tkvirtevent.rb
index d3721e362e..f4fae19a0a 100644
--- a/ext/tk/lib/tkvirtevent.rb
+++ b/ext/tk/lib/tkvirtevent.rb
@@ -1,81 +1,4 @@
#
-# tkvirtevent.rb : treats virtual events
-# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+# tkvirtevent.rb - load tk/virtevent.rb
#
-require 'tk'
-
-class TkVirtualEvent<TkObject
- extend Tk
-
- TkVirtualEventID = [0]
- TkVirtualEventTBL = {}
-
- class PreDefVirtEvent<self
- def initialize(event)
- @path = @id = event
- TkVirtualEvent::TkVirtualEventTBL[@id] = self
- end
- end
-
- def TkVirtualEvent.getobj(event)
- obj = TkVirtualEventTBL[event]
- if obj
- obj
- else
- if tk_call('event', 'info').index("<#{event}>")
- PreDefVirtEvent.new(event)
- else
- fail ArgumentError, "undefined virtual event '<#{event}>'"
- end
- end
- end
-
- def TkVirtualEvent.info
- tk_call('event', 'info').split(/\s+/).collect!{|seq|
- TkVirtualEvent.getobj(seq[1..-2])
- }
- end
-
- def initialize(*sequences)
- @path = @id = format("<VirtEvent%.4d>", TkVirtualEventID[0])
- TkVirtualEventID[0] += 1
- add(*sequences)
- end
-
- def add(*sequences)
- if sequences != []
- tk_call('event', 'add', "<#{@id}>",
- *(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) )
- TkVirtualEventTBL[@id] = self
- end
- self
- end
-
- def delete(*sequences)
- if sequences == []
- tk_call('event', 'delete', "<#{@id}>")
- TkVirtualEventTBL[@id] = nil
- else
- tk_call('event', 'delete', "<#{@id}>",
- *(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) )
- TkVirtualEventTBL[@id] = nil if info == []
- end
- self
- end
-
- def info
- tk_call('event', 'info', "<#{@id}>").split(/\s+/).collect!{|seq|
- l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
- case (subseq)
- when /^<<[^<>]+>>$/
- TkVirtualEvent.getobj(subseq[1..-2])
- when /^<[^<>]+>$/
- subseq[1..-2]
- else
- subseq.split('')
- end
- }.flatten
- (l.size == 1) ? l[0] : l
- }
- end
-end
+require 'tk/virtevent'
diff --git a/ext/tk/lib/tkwinpkg.rb b/ext/tk/lib/tkwinpkg.rb
new file mode 100644
index 0000000000..83371c546d
--- /dev/null
+++ b/ext/tk/lib/tkwinpkg.rb
@@ -0,0 +1,4 @@
+#
+# tkwinpkg.rb - load tk/winpkg.rb
+#
+require 'tk/winpkg'
diff --git a/ext/tk/sample/binding_sample.rb b/ext/tk/sample/binding_sample.rb
new file mode 100644
index 0000000000..693cc7de2f
--- /dev/null
+++ b/ext/tk/sample/binding_sample.rb
@@ -0,0 +1,87 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+class Button_clone < TkLabel
+ def initialize(*args)
+ @command = nil
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ @command = keys.delete('command')
+
+ keys['highlightthickness'] = 1 unless keys.key?('highlightthickness')
+ keys['padx'] = '3m' unless keys.key?('padx')
+ keys['pady'] = '1m' unless keys.key?('pady')
+ keys['relief'] = 'raised' unless keys.key?('relief')
+
+ args.push(keys)
+ end
+
+ super(*args)
+
+ @press = false
+
+ self.bind('Enter', proc{self.background(self.activebackground)})
+ self.bind('Leave', proc{
+ @press = false
+ self.background(self.highlightbackground)
+ self.relief('raised')
+ })
+
+ self.bind('ButtonPress-1', proc{@press = true; self.relief('sunken')})
+ self.bind('ButtonRelease-1', proc{
+ self.relief('raised')
+ @command.call if @press && @command
+ @press = false
+ })
+ end
+
+ def command(cmd = Proc.new)
+ @command = cmd
+ end
+
+ def invoke
+ if @command
+ @command.call
+ else
+ ''
+ end
+ end
+end
+
+TkLabel.new(:text=><<EOT).pack
+This is a sample of 'event binding'.
+The first button is a normal button widget.
+And the second one is a normal label widget
+but with some bindings like a button widget.
+EOT
+
+lbl = TkLabel.new(:foreground=>'red').pack(:pady=>3)
+
+v = TkVariable.new(0)
+
+TkFrame.new{|f|
+ TkLabel.new(f, :text=>'click count : ').pack(:side=>:left)
+ TkLabel.new(f, :textvariable=>v).pack(:side=>:left)
+}.pack
+
+TkButton.new(:text=>'normal Button widget',
+ :command=>proc{
+ puts 'button is clicked!!'
+ lbl.text 'button is clicked!!'
+ v.numeric += 1
+ }){
+ pack(:fill=>:x, :expand=>true)
+}
+
+Button_clone.new(:text=>'Label with Button binding',
+ :command=>proc{
+ puts 'label is clicked!!'
+ lbl.text 'label is clicked!!'
+ v.numeric += 1
+ }){
+ pack(:fill=>:x, :expand=>true)
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/bindtag_sample.rb b/ext/tk/sample/bindtag_sample.rb
new file mode 100644
index 0000000000..8c93b4a260
--- /dev/null
+++ b/ext/tk/sample/bindtag_sample.rb
@@ -0,0 +1,127 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+TkLabel.new(:text=><<EOT, :justify=>:left).pack
+This is a sample of bindtags and usage of
+Tk.callback_break/Tk.callback_continue.
+Please check the work of following buttons
+(attend the difference between before/after
+ pressing the bottom button), and see the
+source code.
+EOT
+
+def set_class_bind
+ TkButton.bind('ButtonPress-1',
+ proc{puts 'bind "ButtonPress-1" of TkButton class'})
+ TkButton.bind('ButtonRelease-1',
+ proc{puts 'bind "ButtonRelease-1" of TkButton class'})
+end
+
+# set root binding
+r = TkRoot.new
+r.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of root widget'})
+r.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of root widget'})
+
+# set 'all' binding
+TkBindTag::ALL.bind('ButtonPress-1',
+ proc{puts 'bind "ButtonPress-1" of the tag "all"'})
+TkBindTag::ALL.bind('ButtonRelease-1',
+ proc{puts 'bind "ButtonRelease-1" of the tag "all"'})
+
+# create buttons
+b1 = TkButton.new(:text=>'button-1',
+ :command=>proc{puts "command of button-1"}).pack
+b2 = TkButton.new(:text=>'button-2',
+ :command=>proc{puts "command of button-2"}).pack
+b3 = TkButton.new(:text=>'button-3',
+ :command=>proc{puts "command of button-3"}).pack
+b4 = TkButton.new(:text=>'button-4',
+ :command=>proc{puts "command of button-4"}).pack
+b5 = TkButton.new(:text=>'button-5',
+ :command=>proc{puts "command of button-5"}).pack
+
+# set button binding
+b1.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-1'})
+b1.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-1'})
+
+b2.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-2'})
+b2.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-2'})
+
+b3.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-3'})
+b3.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-3'})
+
+b4.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-4'})
+b4.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-4'})
+
+b5.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-5'})
+b5.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-5'})
+
+# create bindtag and set binding
+tag1 = TkBindTag.new
+tag1.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of tag1'})
+tag1.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of tag1'})
+
+tag2 = TkBindTag.new
+tag2.bind('ButtonPress-1',
+ proc{
+ puts 'bind "ButtonPress-1" of tag2'
+ puts 'call Tk.callback_continue'
+ Tk.callback_continue
+ puts 'never see this message'
+ })
+tag2.bind('ButtonRelease-1',
+ proc{
+ puts 'bind "ButtonRelease-1" of tag2'
+ puts 'call Tk.callback_continue'
+ Tk.callback_continue
+ puts 'never see this message'
+ })
+
+tag3 = TkBindTag.new
+tag3.bind('ButtonPress-1',
+ proc{
+ puts 'bind "ButtonPress-1" of tag3'
+ puts 'call Tk.callback_break'
+ Tk.callback_break
+ puts 'never see this message'
+ })
+tag3.bind('ButtonRelease-1',
+ proc{
+ puts 'bind "ButtonRelease-1" of tag3'
+ puts 'call Tk.callback_break'
+ Tk.callback_break
+ puts 'never see this message'
+ })
+
+# set bindtags
+p b1.bindtags
+
+tags = b2.bindtags
+tags[2,0] = tag1
+tags[0,0] = tag1
+b2.bindtags(tags)
+p b2.bindtags
+
+tags = b3.bindtags
+tags[2,0] = tag2
+tags[0,0] = tag2
+b3.bindtags(tags)
+p b3.bindtags
+
+tags = b4.bindtags
+tags[2,0] = tag3
+tags[0,0] = tag3
+b4.bindtags(tags)
+p b4.bindtags
+
+b5.bindtags([tag1, TkButton, tag2, b5])
+
+# create button to set button class binding
+TkButton.new(:text=>'set binding to TkButton class',
+ :command=>proc{
+ puts 'call "set_class_bind"'
+ set_class_bind
+ }).pack(:pady=>7)
+
+# start event-loop
+Tk.mainloop
diff --git a/ext/tk/sample/binstr_usage.rb b/ext/tk/sample/binstr_usage.rb
new file mode 100644
index 0000000000..91692856f9
--- /dev/null
+++ b/ext/tk/sample/binstr_usage.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+
+require "tk"
+
+TkMessage.new(:width=>360, :text=><<EOM).pack
+This sample shows how to use a binary sequence between Ruby and Tk. \
+This reads the image data from the file as the binary sequence.
+
+To treat the difference of encodings between on Ruby and on Tk seamlessly, \
+Ruby/Tk converts the encoding of string arguments automatically. \
+I think it is comfortable for users on almost all situations. \
+However, when treats a binary sequence, the convert process makes troubles.
+
+Tk::BinaryString class (subclass of Tk::EncodedString class) is the class \
+to avoid such troubles. Please see the source code of this sample. \
+A Tk::BinaryString instance is used to create the image for the center button.
+EOM
+
+ImgFile=['images','tcllogo.gif'].join(File::Separator)
+
+ph1 = TkPhotoImage.new(:file=>ImgFile)
+p ph1.configinfo
+
+b_str = Tk::BinaryString(IO.read(ImgFile))
+p [b_str, b_str.encoding]
+
+ph2 = TkPhotoImage.new(:data=>b_str)
+p ph2.configinfo
+p ph2.data(:grayscale=>true)
+
+ph3 = TkPhotoImage.new()
+ph3.put(ph2.data(:grayscale=>true))
+
+f = TkFrame.new.pack
+TkButton.new(:parent=>f, :image=>ph1, :command=>proc{exit}).pack(:side=>:left)
+TkButton.new(:parent=>f, :image=>ph2, :command=>proc{exit}).pack(:side=>:left)
+TkButton.new(:parent=>f, :image=>ph3, :command=>proc{exit}).pack(:side=>:left)
+
+Tk.mainloop
diff --git a/ext/tk/sample/btn_with_frame.rb b/ext/tk/sample/btn_with_frame.rb
new file mode 100644
index 0000000000..d04c95a289
--- /dev/null
+++ b/ext/tk/sample/btn_with_frame.rb
@@ -0,0 +1,20 @@
+require 'tk'
+
+class Button_with_Frame < TkButton
+ def create_self(keys)
+ @frame = TkFrame.new('widgetname'=>@path, 'background'=>'yellow')
+ install_win(@path) # create new @path which is a daughter of old @path
+ super(keys)
+ TkPack(@path, :padx=>7, :pady=>7)
+ @epath = @frame.path
+ end
+ def epath
+ @epath
+ end
+end
+
+Button_with_Frame.new(:text=>'QUIT', :command=>proc{exit}) {
+ pack(:padx=>15, :pady=>5)
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/cmd_res_test.rb b/ext/tk/sample/cmd_res_test.rb
new file mode 100644
index 0000000000..6e954f26ee
--- /dev/null
+++ b/ext/tk/sample/cmd_res_test.rb
@@ -0,0 +1,17 @@
+require 'tk'
+TkOptionDB.readfile(File.expand_path('cmd_resource',
+ File.dirname(__FILE__)))
+f = TkFrame.new(:class=>'BtnFrame').pack
+b = TkButton.new(:parent=>f, :widgetname=>'hello').pack
+cmd1 = TkOptionDB.new_proc_class(b, [:show_msg, :bye_msg], 3)
+cmd2 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, cmd1)
+cmd3 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, b)
+cmd4 = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3){
+ def self.__check_proc_string__(str)
+ "{|arg| print [arg, $SAFE].inspect, ': '; Proc.new#{str}.call(arg)}"
+ end
+}
+cmd1.show_msg('cmd1')
+cmd2.show_msg('cmd2')
+cmd3.show_msg('cmd3')
+cmd4.show_msg('cmd4')
diff --git a/ext/tk/sample/cmd_resource b/ext/tk/sample/cmd_resource
new file mode 100644
index 0000000000..9cc4915546
--- /dev/null
+++ b/ext/tk/sample/cmd_resource
@@ -0,0 +1,5 @@
+*BtnFrame.hello.text: HELLO
+*BtnFrame.hello.command: ruby {puts "Hello World!!"}
+*BTN_CMD.show_msg: {|arg| print "Hello, #{arg}!!\n"}
+*hello.show_msg: {|arg| print "Hello, Hello, #{arg}!!\n"}
+*hello.ZZZ.show_msg: {|arg| print "Hello, Hello, ZZZ:#{arg}!!\n"}
diff --git a/ext/tk/sample/demos-en/ChangeLog b/ext/tk/sample/demos-en/ChangeLog
new file mode 100644
index 0000000000..c3f66cf409
--- /dev/null
+++ b/ext/tk/sample/demos-en/ChangeLog
@@ -0,0 +1,64 @@
+2002-08-29 16:30 matt
+
+ * ChangeLog: ChangeLog is auto-generated *from* CVS log.
+
+2002-08-29 16:27 matt
+
+ * ChangeLog.prev: [no log message]
+
+2002-08-28 18:07 matt
+
+ * browse1, browse2, hello, ixset, rmt, rolodex, rolodex-j, square,
+ tcolor, timer, widget: Changed #! lines to the slightly more
+ portable '#!/usr/bin/env ruby'.
+
+2002-08-28 17:56 matt
+
+ * icon.rb, items.rb, label.rb, menu.rb, ruler.rb: Changed bitmap
+ file extensions from .bmp to .xbm.
+
+2002-08-28 17:55 matt
+
+ * images/: face.bmp, face.xbm, flagdown.bmp, flagdown.xbm,
+ flagup.bmp, flagup.xbm, gray25.bmp, gray25.xbm, letters.bmp,
+ letters.xbm, noletter.bmp, noletter.xbm, pattern.bmp, pattern.xbm:
+ Changed X bitmap file extensions from .bmp to the more intuitive
+ .xbm.
+
+2002-08-28 17:35 matt
+
+ * bitmap.rb, colors.rb, cscroll.rb, ctext.rb, hello, ixset,
+ menubu.rb, patch_1.1c1, rmt, style.rb, timer, ChangeLog, README,
+ README.tkencoding, arrow.rb, bind.rb, browse1, browse2, button.rb,
+ check.rb, clrpick.rb, dialog1.rb, dialog2.rb, entry1.rb, entry2.rb,
+ filebox.rb, floor.rb, form.rb, hscale.rb, icon.rb, image1.rb,
+ image2.rb, items.rb, label.rb, menu.rb, msgbox.rb, plot.rb,
+ puzzle.rb, radio.rb, rolodex, rolodex-j, ruler.rb, sayings.rb,
+ search.rb, square, states.rb, tcolor, text.rb, tkencoding.rb,
+ twind.rb, vscale.rb, widget, doc.org/README, doc.org/README.JP,
+ doc.org/README.tk80, doc.org/license.terms,
+ doc.org/license.terms.tk80, images/earth.gif, images/earthris.gif,
+ images/face.bmp, images/flagdown.bmp, images/flagup.bmp,
+ images/gray25.bmp, images/grey.25, images/grey.5,
+ images/letters.bmp, images/noletter.bmp, images/pattern.bmp,
+ images/tcllogo.gif, images/teapot.ppm: Initial revision
+
+2002-08-28 17:35 matt
+
+ * bitmap.rb, colors.rb, cscroll.rb, ctext.rb, hello, ixset,
+ menubu.rb, patch_1.1c1, rmt, style.rb, timer, ChangeLog, README,
+ README.tkencoding, arrow.rb, bind.rb, browse1, browse2, button.rb,
+ check.rb, clrpick.rb, dialog1.rb, dialog2.rb, entry1.rb, entry2.rb,
+ filebox.rb, floor.rb, form.rb, hscale.rb, icon.rb, image1.rb,
+ image2.rb, items.rb, label.rb, menu.rb, msgbox.rb, plot.rb,
+ puzzle.rb, radio.rb, rolodex, rolodex-j, ruler.rb, sayings.rb,
+ search.rb, square, states.rb, tcolor, text.rb, tkencoding.rb,
+ twind.rb, vscale.rb, widget, doc.org/README, doc.org/README.JP,
+ doc.org/README.tk80, doc.org/license.terms,
+ doc.org/license.terms.tk80, images/earth.gif, images/earthris.gif,
+ images/face.bmp, images/flagdown.bmp, images/flagup.bmp,
+ images/gray25.bmp, images/grey.25, images/grey.5,
+ images/letters.bmp, images/noletter.bmp, images/pattern.bmp,
+ images/tcllogo.gif, images/teapot.ppm: Taking over demo package
+ from Jonathan Conway.
+
diff --git a/ext/tk/sample/demos-en/ChangeLog.prev b/ext/tk/sample/demos-en/ChangeLog.prev
new file mode 100644
index 0000000000..536ce30abe
--- /dev/null
+++ b/ext/tk/sample/demos-en/ChangeLog.prev
@@ -0,0 +1,9 @@
+2001-07-26 <rise@leannan.knavery.net>
+
+ * Moved files to directory ruby-tk81-demos-english in tarball.
+
+2001-07-26 <rise@knavery.net>
+
+ * Added test to widget and hello versus Tk::TCL_VERSION & Tk::JAPANIZED_TK (per Guy Decoux in [ruby-talk:18559]) before requiring tkencoding.rb.
+
+ \ No newline at end of file
diff --git a/ext/tk/sample/demos-en/README b/ext/tk/sample/demos-en/README
new file mode 100644
index 0000000000..2908aa38e4
--- /dev/null
+++ b/ext/tk/sample/demos-en/README
@@ -0,0 +1,138 @@
+Current Maintainer:
+ Jonathan Conway
+ rise@knavery.net
+
+ Please direct all bug reports/requests/suggestions to the above
+ address.
+
+
+Notes:
+
+* The files hello and widget have been changed to test Tk::TCL_VERSION
+ and Tk::JAPANIZED_TK before requiring tkencoding.rb to prevent an
+ infinite loop. This test was taken from a message in
+ [ruby-talk:18559] by Guy Decoux.
+
+* The .bmp files in the images directory are X bitmaps (i.e. XBM to many
+ graphics packages), not Windows bitmaps (.bmp). You will not be
+ able to use images exported by a graphics program as Windows
+ bitmaps with this demo collection nor will you be able to edit the
+ included images without setting the file type correctly.
+
+-- Jonathan Conway, 2001-07-26
+
+
+#------------------------------------------------------------------------------
+# ==== Introduction. ====
+#
+# To create this version of the Ruby/Tk widget demo, I took the
+# ruby-tk81-demos and removed all the Kanji strings and comments. I
+# have tried to restore the original English strings and comments
+# using the Tcl/Tk8.2.2 version of the widget demo.
+#
+# When I tried running the Kanji version, all I got was a mostly blank
+# panel with a non-functional "File" button. I disovered that if all
+# non-ASCII characters were replaced with blanks, then I could get the
+# gutted stuff running.
+#
+# Since English Ruby/Tk documentation is lacking and I needed this
+# code to see how it worked and to use as the basis of my try-it
+# prototype (The Ruby Yielding Interactive Toolkit), plus the fact
+# that no help was forthcoming for making the Kanji version work (plus
+# the fact that I can't read Kanji anyway), I decided to embark on
+# this English restoration project.
+#
+# Thanks to everyone who worked on the original Ruby/Tk widget demo
+# (and the preceding Tcl/Tk version for that matter). The
+# comparatively simple task of changing text strings and comments has
+# made me appreciate the great amount of original work that went into
+# this.
+#
+# -- Conrad Schneiker, 2000-07-23.
+#------------------------------------------------------------------------------
+
+#------------------------------------------------------------------------------
+# ==== Known bugs. ====
+#
+# ^C-ing the demo gives Ruby interrupt and stack message; clean exit needed.
+# Font settings don't work correctly.
+# Dismissing the embedded windows demo (tkwind.rb) kills the widget demo.
+# Rerunning the canvas item demo from the code widow get errors.
+# The "press me" button in the canvas item demo doesn't time out.
+# The simple 2 d plot starts up extremely slow compared to the Tcl version.
+# The first item message on the icon menu on the menu and cascades demo doesn't work.
+#------------------------------------------------------------------------------
+
+
+###################### Original README ########################################
+
+ Ruby/Tk81 widget-demo 1999/08/13
+
+ ËÌΦÀèüÂç¾ðÊó²Ê³Ø¸¦µæ²Ê
+ ΩÀÐ <ttate@jaist.ac.jp>
+
+Tcl/Tk8.1¤Ç¤Ïunicode(UTF8)¤¬ºÎÍѤµ¤ì¡¢unicode¤ËÊÑ´¹¤µ¤ì¤¿ÆüËܸì¤Ç¤¢¤ì¤Ð
+Widget¤Ëɽ¼¨¤µ¤»¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡£ËÜ¥¢¡¼¥«¥¤¥Ö¤Ë¤Ï°ÊÁ°¤Ë±Ê°æ¤µ¤ó¤¬Ãæ¿´¤È
+¤Ê¤é¤ì¤ÆºîÀ®¤µ¤ì¤¿Ruby/Tk¤Î¥µ¥ó¥×¥ë¤Ë½¤Àµ¤ò²Ã¤¨¡¢°Ê²¼¤Î´Ä¶­¤Ë¤ª¤¤¤Æ¤Çưºî
+¤ò³Îǧ¤·¤¿¤â¤Î¤Ç¤¹¡£
+
+* ruby-1.3.7,ruby-1.4.0
+* tcl8.1, tk8.1
+* linux-2.2
+
+Windows(Cygwin)¤Ë¤ª¤¤¤Æ¡¢¥µ¥ó¥×¥ë¤òư¤«¤¹¤Ë¤Ïruby¤ò-Ke¤È¤¤¤¦¥ª¥×¥·¥ç¥ó¤òÉÕ
+¤±¤Æµ¯Æ°¤µ¤»¤ë¤ÈÎɤ¤¤½¤¦¤Ç¤¹¡£
+ ¾ðÊóÄó¶¡¡§ÅÏÊÕ¤µ¤ó
+ <eban@os.rim.or.jp>
+
+----------------------------------------------------------------------------
+ Ruby/Tk widget-demo
+ version 1.1 ( 1998/07/24 )
+ ±Ê°æ¡÷ÃÎǽ¡¥¶å¹©Âç (nagai@ai.kyutech.ac.jp)
+
+ɸ½àÇÛÉۤΠTcl/Tk ³ÈÄ¥¥Ñ¥Ã¥±¡¼¥¸¤ò¼è¤ê¹þ¤ó¤À Ruby (°Ê²¼ Ruby/Tk ¤È¸Æ¤Ó¤Þ¤¹)
+¤Ç¤Ï¡¤Tk widget ¤òÍѤ¤¤¿ GUI ¤ÎºîÀ®¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¥¼ÂºÝ¤Ë GUI ¤òºîÀ®
+¤·¤Æ¤¤¤¯¾ì¹ç¤Ë¤ÏÍÍ¡¹¤Ê¼ÂÎ㤬¥µ¥ó¥×¥ë¤È¤·¤ÆÂ¸ºß¤¹¤ë¤ÈÊØÍø¤Ê¤Î¤Ç¤¹¤¬¡¤Ruby/Tk
+¤Ë¤Ï¤½¤Î¤è¤¦¤ÊŬÅö¤Ê¥µ¥ó¥×¥ë¥¹¥¯¥ê¥×¥È½¸¹ç¤Ï¸ºß¤·¤Þ¤»¤ó¤Ç¤·¤¿¡¥¤½¤ì¤ËÂФ·¡¤
+³ÈÄ¥¥Ñ¥Ã¥±¡¼¥¸¤Î¸µ¤Ç¤¢¤ë Tcl/Tk ¤Ë¤Ï¡¤Tk widget ¤òÍѤ¤¤Æ¤É¤Î¤è¤¦¤Ê¤³¤È¤¬¤Ç
+¤­¤ë¤«¤ò¼¨¤¹¤â¤Î¤È¤·¤Æ widget-demo ¤¬Â¸ºß¤·¤ª¤ê¡¤Tcl/Tk ¤òÍѤ¤¤¿ GUI ¤ÎºîÀ®
+¤ò½¬ÆÀ¤¹¤ëºÝ¤ÎÂåɽŪ¥µ¥ó¥×¥ë¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥ËÜ¥¢¡¼¥«¥¤¥Ö¤Ï¡¤Ruby/Tk ¤Î½¬ÆÀ¤Î
+¤¿¤á¤ÎÂåɽŪ¤Ê¥µ¥ó¥×¥ë¥¹¥¯¥ê¥×¥È¤È¤¹¤Ù¤¯¡¤Tcl/Tk ¤Î widget-demo ¤ò°Ü¿¢¤·¤¿¤â
+¤Î¤Ç¤¹¡¥
+
+ËÜ¥¢¡¼¥«¥¤¥Ö¤Ë´Þ¤Þ¤ì¤ë¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤¹¤ë¤¿¤á¤Ë¤Ï¡¤ruby-1.1c2 °Ê¾å¤Ç¤¢¤ë¤³
+¤È¤¬É¬ÍפǤ¹¡¥1.1c1 ¤Î¾ì¹ç¤Ï¡¤ËÜ¥¢¡¼¥«¥¤¥Ö¤Ë´Þ¤Þ¤ì¤ë patck_1.1c1 ¤ò Ruby ¤Î
+¥é¥¤¥Ö¥é¥ê¤Ë¤¢¤Æ¤Æ¤¯¤À¤µ¤¤¡¥ÁȤ߹þ¤à Tk ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ï¡¤4.2 ¤Ç¤â 8.0 ¤Ç¤â½¤
+Àµ¤Ê¤¯Æ°¤«¤»¤ë¤Ï¤º¤Ç¤¹¡¥¤¿¤À¤·¡¤ÆüËܸìÈǤǤΰܿ¢¤È¤Ê¤Ã¤Æ¤¤¤ë¤¿¤á¡¤ÆüËܸ첽¤µ
+¤ì¤¿ Tk ¤ò¤´ÍøÍѤ¯¤À¤µ¤¤¡¥¥¹¥¯¥ê¥×¥È¤Î¥Æ¥¹¥È¤Ï¡¤Tk4.2jp ¤È Tk8.0jp ¤Î¾å¤Ç¹Ô
+¤¤¤Þ¤·¤¿ (´°àú¤Ë¤Ç¤Ï¤Ê¤¤¤Ç¤¹¤¬)¡¥
+
+ËÜ¥¢¡¼¥«¥¤¥Ö¤Ë´Þ¤Þ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¿¤¯¤Ï¡¤¸µ¤È¤Ê¤Ã¤Æ¤¤¤ë Tcl/Tk ÈǤËÈæ³ÓŪ¶á
+¤¤¥¹¥¯¥ê¥×¥Èµ­½Ò¤È¤Ê¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡¥¤½¤Î¤¿¤á¡¤Ruby/Tk ¤Î¥µ¥ó¥×¥ë¤È¸À¤¦¤Ë
+¤Ï¡¤¤¢¤Þ¤ê Ruby ¤é¤·¤¯¤Ê¤¤¤È¤â¸À¤¨¤ë¤Ç¤·¤ç¤¦¡¥¤Ë¤â¤«¤«¤ï¤é¤º¡¤¤½¤Î¤è¤¦¤Êµ­½Ò
+¤ò¼è¤Ã¤Æ¤¤¤ëÍýͳ¤Ï¡¤Ruby/Tk ¤Î¥É¥­¥å¥á¥ó¥ÈÉÔ­¤Ë¤¢¤ê¤Þ¤¹¡¥
+
+Tcl/Tk ¤Ë¤ÏŬÅö¤Ê»²¹Í½ñ¤¬²¿ºý¤«Â¸ºß¤·¤Æ¤¤¤Þ¤¹¤«¤é¡¤Ruby/Tk ¥¹¥¯¥ê¥×¥È¤òºîÀ®
+¤¹¤ëºÝ¤Ï¡¤¤½¤Î¤è¤¦¤Ê Tcl/Tk ¤Î»²¹Í½ñ¤Ç¾ðÊó¤òÊ䤤¤Ê¤¬¤éºîÀ®¤¹¤ë¤³¤È¤Ë¤Ê¤ë¤È»×
+¤¤¤Þ¤¹¡¥³Æ widget ¤Î»ÈÍÑÎã¤È¤·¤Æ¡¤Tcl/Tk ¤Î widget-demo ¤ò»²¾È¤¹¤ë¤³¤È¤â¤¢¤ë
+¤Ç¤·¤ç¤¦¡¥Ruby/Tk ÈǤε­½Ò¤ò widget-demo ¤ò Tcl/Tk ÈǤε­½Ò¤Ë¶á¤¤¤â¤Î¤Ë¤·¤Æ
+¤ª¤±¤Ð¡¤¤½¤ÎÂÐÈæ¤Ë¤è¤Ã¤Æ¡¤Ruby/Tk ¤ÎÍý²ò¤òÁá¤á¤ë¤³¤È¤¬¤Ç¤­¤ë¤È¹Í¤¨¤é¤ì¤Þ¤¹¡¥
+°ìö Ruby/Tk ¤Ç¤Î ³Æ widget ¤Î»ÈÍÑÊýË¡¤ò½¬ÆÀ¤·¤Æ¤·¤Þ¤¨¤Ð¡¤Ruby ¤é¤·¤¤¥¹¥¯¥ê
+¥×¥È¤òºîÀ®¤¹¤ë¤³¤È¤ÏÆñ¤·¤¯¤Ê¤¤¤Ç¤·¤ç¤¦¡¥ËÜ¥¢¡¼¥«¥¤¥Ö¤Î¥¹¥¯¥ê¥×¥È¤Ï¡¤Ruby/Tk
+¤òºÇ½é¤Ë½¬ÆÀ¤¹¤ë¤Þ¤Ç¤ÎÆ§Âæ¤È¤·¤ÆÍøÍѤ·¤Æ¤¤¤¿¤À¤±¤ì¤Ð¹¬¤¤¤Ç¤¹¡¥
+
+widget-demo ¤Î°Ü¿¢¤Ë¤¢¤¿¤Ã¤Æ¤Ï¡¤¼¡¤ÎÊý¤Ë¤â°Ü¿¢¤·¤¿¥¹¥¯¥ê¥×¥È¤òÄ󶡤·¤Æ¤¤¤¿¤À
+¤­¤Þ¤·¤¿¡¥¤³¤³¤Ë´¶¼Õ¤Î°Õ¤òɽ¤·¤Þ¤¹¡¥
+
+ ΩÀС÷JAIST (ttate@jaist.ac.jp) ¤µ¤ó
+ Ê¿¾¾¾Í»Ë (hiramatu@cdrom.co.jp) ¤µ¤ó
+
+Ê¿¾¾¤µ¤ó¤Ë¤è¤ë Ruby/Tk ÆþÌç¤Î Web page (http://www.cdrom.co.jp/~hiramatu/)
+¤â Ruby/Tk ¤Î½¬ÆÀ¤ËÍ­ÍѤȻפ¨¤Þ¤¹¤Î¤Ç¡¤¤¼¤Ò¤´»²¾È¤¯¤À¤µ¤¤¡¥
+
+¤Þ¤¿¡¤Á°¶¶ (maebashi@iij.ad.jp) ¤µ¤ó¤ò¤Ï¤¸¤á¤È¤·¤Æ¡¤widget-demo ¤Î°Ü¿¢¤ËºÝ¤·
+¤ÆÉ¬ÍפȤʤä¿ Ruby ¤Î Tk ´ØÏ¢¥é¥¤¥Ö¥é¥ê½¤Àµ¤Ë¤Ä¤¤¤Æ¡¤ÌäÂêÅÀ¡¤¥Ð¥°¤Î»ØÅ¦¤ò¤·
+¤Æ¤¤¤¿¤À¤¤¤¿Êý¡¹¤Ë¤â´¶¼ÕÃפ·¤Þ¤¹¡¥
+
+¤½¤·¤ÆºÇ¸å¤ËºÇÂç¤Î´¶¼Õ¤ò Ruby À߷׼ԤΠ¤Þ¤Ä¤â¤È ¤æ¤­¤Ò¤í (matz@netlab.co.jp)
+¤µ¤ó¤ËÊû¤²¤¿¤¤¤È»×¤¤¤Þ¤¹¡¥
diff --git a/ext/tk/sample/demos-en/README.1st b/ext/tk/sample/demos-en/README.1st
new file mode 100644
index 0000000000..e031f123d2
--- /dev/null
+++ b/ext/tk/sample/demos-en/README.1st
@@ -0,0 +1,18 @@
+There are Ruby/Tk demo scripts.
+
+Files with '.rb' extension are sub-scripts which are launched 'widget'
+script. Those files don't work independently. Please call them from
+'widget' script.
+
+If you want start some sub-scripts at same time when the launcher
+script tarts, please give the sub-script names as arguments.
+(e.g. /usr/local/bin/ruby widget button.rb entry1.rb text.rb )
+You can ommit '.rb' of the sub-scripts
+(e.g. /usr/local/bin/ruby widget button entry1 text )
+
+If you don't need launcher's main window, give -n option.
+(e.g. /usr/local/bin/ruby widget -n button.rb entry1.rb text.rb )
+
+Others (browse1, hello, and so on) are standalone scripts.
+
+ 2004/04/14 Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/ext/tk/sample/demos-en/README.tkencoding b/ext/tk/sample/demos-en/README.tkencoding
new file mode 100644
index 0000000000..f576bc593e
--- /dev/null
+++ b/ext/tk/sample/demos-en/README.tkencoding
@@ -0,0 +1,29 @@
+This is a original document of 'tkencoding.rb'.
+The library 'tkencoding.rb' is obsolete.
+Functions of tkencoding.rb is already included into Ruby/Tk.
+
+-------------------------------------------------
+tkencoding.rb¤òÍѤ¤¤¿ÆüËܸì¤Îɽ¼¨¤Ë¤Ä¤¤¤Æ
+
+Copyright (C) 1999/07, Takaaki Tateishi <ttate@jaist.ac.jp>
+
+
+1. tkencoding.rb¤È¤Ï¡©
+
+tkencoding.rb¤ÏTcl/Tk8.1¤òÍøÍѤ·¤¿Ruby/Tk¤Î¤¿¤á¤Î¥é¥¤¥Ö¥é¥ê
+¤Ç¤¹¡£tkencoding.rb¤òrequire¤¹¤ë¤³¤È¤Ë¤è¤Ã¤ÆWedget¤Ëɽ¼¨¤µ
+¤ì¤ë¥Æ¥­¥¹¥È¤ÏÁ´¤Æunicode(UTF8)¤ØÊÑ´¹¤µ¤ì¤Þ¤¹¡£
+
+
+2. »È¤¤Êý
+
+tkencoding.rb¤òrequire¤·¤ÆTk.encoding¤Ç»ÈÍѤ·¤Æ¤¤¤ëʸ»ú¥³¡¼¥É
+¤ò»ØÄꤷ¤Æ²¼¤µ¤¤¡£Î㤨¤Ð°Ê²¼¤Î¤è¤¦¤Ê´¶¤¸¤Ë¤Ê¤ê¤Þ¤¹¡£
+
+----
+require 'tk'
+require 'tkencoding'
+
+Tk.encoding = "euc-jp"
+# Tk.encoding = "shiftjis"
+---
diff --git a/ext/tk/sample/demos-en/arrow.rb b/ext/tk/sample/demos-en/arrow.rb
new file mode 100644
index 0000000000..b62e1966eb
--- /dev/null
+++ b/ext/tk/sample/demos-en/arrow.rb
@@ -0,0 +1,239 @@
+# arrow.rb
+#
+# This demonstration script creates a canvas widget that displays a
+# large line with an arrowhead whose shape can be edited interactively.
+#
+# arrowhead widget demo (called by 'widget')
+#
+
+# arrowSetup --
+# This method regenerates all the text and graphics in the canvas
+# window. It's called when the canvas is initially created, and also
+# whenever any of the parameters of the arrow head are changed
+# interactively.
+#
+# Arguments:
+# c - Name of the canvas widget.
+
+def arrowSetup(c)
+ v = $demo_arrowInfo
+
+ # Remember the current box, if there is one.
+ tags = c.gettags('current')
+ if tags != []
+ cur = tags.find{|t| t.kind_of?(String) && t =~ /^box[1-3]$/ }
+ else
+ cur = nil
+ end
+
+ # Create the arrow and outline.
+ c.delete('all')
+ TkcLine.new(c, v.x1, v.y, v.x2, v.y,
+ { 'width'=>10 * v.width,
+ 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c],
+ 'arrow'=>'last'
+ }.update(v.bigLineStyle) )
+ xtip = v.x2 - 10*v.b
+ deltaY = 10*v.c + 5*v.width
+ TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY,
+ v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y,
+ 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round')
+
+ # Create the boxes for reshaping the line and arrowhead.
+ TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5,
+ {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5,
+ {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5,
+ {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) )
+ c.itemconfigure cur, v.activeStyle if cur
+
+ # Create three arrows in actual size with the same parameters
+ TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2)
+ tmp = v.x2+100
+ TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+
+ # Create a bunch of other arrows and text items showing the
+ # current dimensions.
+ tmp = v.x2+10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w')
+ tmp = v.x1-10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e')
+ tmp = v.y+5*v.width+10*v.c+10
+ TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n')
+ tmp = tmp+25
+ TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')
+
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+
+ v.count += 1
+end
+
+# toplevel widget
+if defined?($arrow_demo) && $arrow_demo
+ $arrow_demo.destroy
+ $arrow_demo = nil
+end
+
+# demo toplevel widget
+$arrow_demo = TkToplevel.new {|w|
+ title("Arrowhead Editor Demonstration")
+ iconname("arrow")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."){
+ pack('side'=>'top')
+}
+
+# frame
+$arrow_buttons = TkFrame.new($arrow_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $arrow_demo
+ $arrow_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'arrow'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas
+$arrow_canvas = TkCanvas.new($arrow_demo, 'width'=>500, 'height'=>350,
+ 'relief'=>'sunken', 'borderwidth'=>2)
+$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+#
+unless Struct.const_defined?("ArrowInfo")
+ $demo_arrowInfo = Struct.new("ArrowInfo", :a, :b, :c, :width, :motionProc,
+ :x1, :x2, :y, :smallTips, :count,
+ :bigLineStyle, :boxStyle, :activeStyle).new
+end
+$demo_arrowInfo.a = 8
+$demo_arrowInfo.b = 10
+$demo_arrowInfo.c = 3
+$demo_arrowInfo.width = 2
+$demo_arrowInfo.motionProc = proc{}
+$demo_arrowInfo.x1 = 40
+$demo_arrowInfo.x2 = 350
+$demo_arrowInfo.y = 150
+$demo_arrowInfo.smallTips = [5, 5, 2]
+$demo_arrowInfo.count = 0
+if TkWinfo.depth($arrow_canvas) > 1
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'SkyBlue1'}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'red', 'outline'=>'black', 'width'=>1}
+else
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir,'..','images','grey.25'].join(File::Separator)}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'black','outline'=>'black','width'=>1}
+end
+$arrowTag_box = TkcTag.new($arrow_canvas)
+arrowSetup $arrow_canvas
+$arrowTag_box.bind('Enter', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.activeStyle)})
+$arrowTag_box.bind('Leave', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.boxStyle)})
+$arrowTag_box.bind('B1-Enter', proc{})
+$arrowTag_box.bind('B1-Leave', proc{})
+$arrow_canvas.itembind('box1', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove1 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box2', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove2 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box3', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove3 $arrow_canvas, x, y}})
+$arrowTag_box.bind('B1-Motion',
+ proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y")
+$arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas})
+
+# arrowMove1 --
+# This method is called for each mouse motion event on box1 (the
+# one at the vertex of the arrow). It updates the controlling parameters
+# for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove1(c,x,y)
+ v = $demo_arrowInfo
+ newA = (v.x2+5-c.canvasx(x).round)/10
+ newA = 0 if newA < 0
+ newA = 25 if newA > 25
+ if newA != v.a
+ c.move('box1', 10*(v.a-newA), 0)
+ v.a = newA
+ end
+end
+
+# arrowMove2 --
+# This method is called for each mouse motion event on box2 (the
+# one at the trailing tip of the arrowhead). It updates the controlling
+# parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove2(c,x,y)
+ v = $demo_arrowInfo
+ newB = (v.x2+5-c.canvasx(x).round)/10
+ newB = 0 if newB < 0
+ newB = 25 if newB > 25
+ newC = (v.y+5-c.canvasy(y).round-5*v.width)/10
+ newC = 0 if newC < 0
+ newC = 20 if newC > 20
+ if newB != v.b || newC != v.c
+ c.move('box2', 10*(v.b-newB), 10*(v.c-newC))
+ v.b = newB
+ v.c = newC
+ end
+end
+
+# arrowMove3 --
+# This method is called for each mouse motion event on box3 (the
+# one that controls the thickness of the line). It updates the
+# controlling parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove3(c,x,y)
+ v = $demo_arrowInfo
+ newWidth = (v.y+2-c.canvasy(y).round)/5
+ newWidth = 0 if newWidth < 0
+ newWidth = 20 if newWidth > 20
+ if newWidth != v.width
+ c.move('box3', 0, 5*(v.width-newWidth))
+ v.width = newWidth
+ end
+end
+
diff --git a/ext/tk/sample/demos-en/bind.rb b/ext/tk/sample/demos-en/bind.rb
new file mode 100644
index 0000000000..0bd1f0ca6f
--- /dev/null
+++ b/ext/tk/sample/demos-en/bind.rb
@@ -0,0 +1,110 @@
+# bind.rb
+#
+# This demonstration script creates a text widget with bindings set
+# up for hypertext-like effects.
+#
+# text (tag bindings) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($bind_demo) && $bind_demo
+ $bind_demo.destroy
+ $bind_demo = nil
+end
+
+# demo toplevel widget
+$bind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Tag Bindings")
+ iconname("bind")
+ positionWindow(w)
+}
+
+# frame
+TkFrame.new($bind_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $bind_demo
+ $bind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'bind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# bind
+def tag_binding_for_bind_demo(tag, enter_style, leave_style)
+ tag.bind('Any-Enter', proc{tag.configure enter_style})
+ tag.bind('Any-Leave', proc{tag.configure leave_style})
+end
+
+# text
+TkText.new($bind_demo){|t|
+ #
+ setgrid 'true'
+ width 60
+ height 24
+ font $font
+ wrap 'word'
+ TkScrollbar.new($bind_demo) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ #
+ if TkWinfo.depth($root).to_i > 1
+ tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised',
+ 'borderwidth'=>1}
+ tagstyle_normal = {'background'=>'', 'relief'=>'flat'}
+ else
+ tagstyle_bold = {'foreground'=>'white', 'background'=>'black'}
+ tagstyle_normal = {'foreground'=>'', 'background'=>''}
+ end
+
+ # insert text
+ insert 'insert', "The same tag mechanism that controls display styles in text widgets can also be used to associate Tcl commands with regions of text, so that mouse or keyboard actions on the text cause particular Tcl commands to be invoked. For example, in the text below the descriptions of the canvas demonstrations have been tagged. When you move the mouse over a demo description the description lights up, and when you press button 1 over a description then that particular demonstration is invoked.
+
+"
+ insert('end', '1. Samples of all the different types of items that can be created in canvas widgets.', (d1 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '2. A simple two-dimensional plot that allows you to adjust the positions of the data points.', (d2 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '3. Anchoring and justification modes for text items.',
+ (d3 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '4. An editor for arrow-head shapes for line items.',
+ (d4 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '5. A ruler with facilities for editing tab stops.',
+ (d5 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end',
+ '6. A grid that demonstrates how canvases can be scrolled.',
+ (d6 = TkTextTag.new(t)) )
+
+ # binding
+ [d1, d2, d3, d4, d5, d6].each{|tag|
+ tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal)
+ }
+ d1.bind('1',
+ proc{eval `cat #{[$demo_dir,'items.rb'].join(File::Separator)}`})
+ d2.bind('1',
+ proc{eval `cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`})
+ d3.bind('1',
+ proc{eval `cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`})
+ d4.bind('1',
+ proc{eval `cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`})
+ d5.bind('1',
+ proc{eval `cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`})
+ d6.bind('1',
+ proc{eval `cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`})
+
+ TkTextMarkInsert.new(t, '0.0')
+ configure('state','disabled')
+}
diff --git a/ext/tk/sample/demos-en/bitmap.rb b/ext/tk/sample/demos-en/bitmap.rb
new file mode 100644
index 0000000000..7fd551c7a5
--- /dev/null
+++ b/ext/tk/sample/demos-en/bitmap.rb
@@ -0,0 +1,73 @@
+# bitmap.rb
+#
+# This demonstration script creates a toplevel window that displays
+# all of Tk's built-in bitmaps.#
+# bitmap widget demo (called by 'widget')
+#
+
+# bitmapRow --
+# Create a row of bitmap items in a window.
+#
+# Arguments:
+# w - The parent window that is to contain the row.
+# args - The names of one or more bitmaps, which will be displayed
+# in a new row across the bottom of w along with their
+# names.
+
+def bitmapRow(w,*args)
+ TkFrame.new(w){|row|
+ pack('side'=>'top', 'fill'=>'both')
+ for bitmap in args
+ TkFrame.new(row){|base|
+ pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
+ TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
+ TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
+ }
+ end
+ }
+end
+
+# toplevel widget
+if defined?($bitmap_demo) && $bitmap_demo
+ $bitmap_demo.destroy
+ $bitmap_demo = nil
+end
+
+# demo toplevel widget
+$bitmap_demo = TkToplevel.new {|w|
+ title("Bitmap Demonstration")
+ iconname("bitmap")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."){
+ pack('side'=>'top')
+}
+
+# frame
+$bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $bitmap_demo
+ $bitmap_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'bitmap'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+TkFrame.new($bitmap_demo){|f|
+ bitmapRow(f,'error','gray25','gray50','hourglass')
+ bitmapRow(f,'info','question','questhead','warning')
+ pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+}
+
diff --git a/ext/tk/sample/demos-en/browse1 b/ext/tk/sample/demos-en/browse1
new file mode 100644
index 0000000000..03e251035a
--- /dev/null
+++ b/ext/tk/sample/demos-en/browse1
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+# Create a scrollbar on the right side of the main window and a listbox
+# on the left side.
+
+listbox = TkListbox.new(nil, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(nil, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+}
+
+root = TkRoot.new
+root.minsize(1,1)
+
+# The procedure below is invoked to open a browser on a given file; if the
+# file is a directory then another instance of this program is invoked; if
+# the file is a regular file then the Mx editor is invoked to display
+# the file.
+
+def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ system($0 + ' ' + file + ' &')
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+end
+
+# Fill the listbox with a list of all the files in the directory (run
+# the "ls" command to get that information).
+
+dir = ARGV[0] ? ARGV[0] : '.'
+open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ listbox.insert('end', fname.chomp)
+}
+
+# Set up bindings for the browser.
+
+Tk.bind_all('Control-c', proc{root.destroy})
+listbox.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| browse dir, f}})
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/browse2 b/ext/tk/sample/demos-en/browse2
new file mode 100644
index 0000000000..edad04dbcb
--- /dev/null
+++ b/ext/tk/sample/demos-en/browse2
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+class Browse
+ BROWSE_WIN_COUNTER = TkVariable.new(0)
+
+ def initialize(dir)
+ BROWSE_WIN_COUNTER.value = BROWSE_WIN_COUNTER.to_i + 1
+
+ # create base frame
+ base = TkToplevel.new {
+ minsize(1,1)
+ title('Browse : ' + dir)
+ }
+
+ # Create a scrollbar on the right side of the main window and a listbox
+ # on the left side.
+ list = TkListbox.new(base, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(base, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+
+ # Fill the listbox with a list of all the files in the directory (run
+ # the "ls" command to get that information).
+ open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ l.insert('end', fname.chomp)
+ }
+
+ }
+
+ # Set up bindings for the browser.
+ base.bind('Destroy', proc{
+ Browse::BROWSE_WIN_COUNTER.value = \
+ Browse::BROWSE_WIN_COUNTER.to_i - 1
+ })
+ base.bind('Control-c', proc{base.destroy})
+ list.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| self.browse dir, f}})
+ end
+
+ # The method below is invoked to open a browser on a given file; if the
+ # file is a directory then another instance of this program is invoked; if
+ # the file is a regular file then the Mx editor is invoked to display
+ # the file.
+ def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ Browse.new(file)
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+ end
+
+end
+
+Browse.new(ARGV[0] ? ARGV[0] : '.')
+
+TkRoot.new {
+ withdraw
+ Browse::BROWSE_WIN_COUNTER.trace('w', proc{exit if Browse::BROWSE_WIN_COUNTER.to_i == 0})
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/button.rb b/ext/tk/sample/demos-en/button.rb
new file mode 100644
index 0000000000..6614d99c92
--- /dev/null
+++ b/ext/tk/sample/demos-en/button.rb
@@ -0,0 +1,84 @@
+# button.rb
+#
+# This demonstration script creates a toplevel window containing
+# several button widgets.
+#
+# button widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($button_demo) && $button_demo
+ $button_demo.destroy
+ $button_demo = nil
+end
+
+# demo toplevel widget
+$button_demo = TkToplevel.new {|w|
+ title("Button Demonstration")
+ iconname("button")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($button_demo) {
+ font $kanji_font
+ wraplength '4i'
+ justify 'left'
+ text "If you click on any of the four buttons below, the background of the button area will change to the color indicated in the button. You can press Tab to move among the buttons, then press Space to invoke the current button."
+}
+msg.pack('side'=>'top')
+
+# frame
+$button_buttons = TkFrame.new($button_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $button_demo
+ $button_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'button'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button
+TkButton.new($button_demo){
+ text "Peach Puff"
+ width 10
+ command proc{
+ $button_demo.configure('bg','PeachPuff1')
+ $button_buttons.configure('bg','PeachPuff1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Light Blue"
+ width 10
+ command proc{
+ $button_demo.configure('bg','LightBlue1')
+ $button_buttons.configure('bg','LightBlue1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Sea Green"
+ width 10
+ command proc{
+ $button_demo.configure('bg','SeaGreen2')
+ $button_buttons.configure('bg','SeaGreen2')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Yellow"
+ width 10
+ command proc{
+ $button_demo.configure('bg','Yellow1')
+ $button_buttons.configure('bg','Yellow1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
diff --git a/ext/tk/sample/demos-en/check.rb b/ext/tk/sample/demos-en/check.rb
new file mode 100644
index 0000000000..971a8fea73
--- /dev/null
+++ b/ext/tk/sample/demos-en/check.rb
@@ -0,0 +1,70 @@
+# check.rb
+#
+# This demonstration script creates a toplevel window containing
+# several checkbuttons.
+#
+# checkbutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($check_demo) && $check_demo
+ $check_demo.destroy
+ $check_demo = nil
+end
+
+# demo toplevel widget
+$check_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration")
+ iconname("check")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($check_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Three checkbuttons are displayed below. If you click on a button, it will toggle the button's selection state and set a Tcl variable to a value indicating the state of the checkbutton. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+#
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame
+TkFrame.new($check_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $check_demo
+ $check_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'check'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+
+ TkButton.new(frame) {
+ text 'See Variables'
+ command proc{
+ showVars($check_demo,
+ ['wipers', wipers], ['brakes', brakes], ['sober', sober])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# checkbutton
+[ TkCheckButton.new($check_demo, 'text'=>'Wipers OK', 'variable'=>wipers),
+ TkCheckButton.new($check_demo, 'text'=>'Brakes OK', 'variable'=>brakes),
+ TkCheckButton.new($check_demo, 'text'=>'Driver Sober', 'variable'=>sober)
+].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')}
+
diff --git a/ext/tk/sample/demos-en/check2.rb b/ext/tk/sample/demos-en/check2.rb
new file mode 100644
index 0000000000..e2d5982d2d
--- /dev/null
+++ b/ext/tk/sample/demos-en/check2.rb
@@ -0,0 +1,107 @@
+#
+# checkbutton widget demo2 (called by 'widget')
+#
+
+# delete old toplevel widget
+if defined?($check2_demo) && $check2_demo
+ $check2_demo.destroy
+ $check2_demo = nil
+end
+
+# create demo toplevel widget
+$check2_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration 2")
+ iconname("check2")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($check2_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Four checkbuttons are displayed below. If you click on a button, it will toggle the button's selection state and set a Tcl variable to a value indicating the state of the checkbutton. The first button also follows the state of the other three. If only some of the three are checked, the first button will display the tri-state mode. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+# variable
+safety = TkVariable.new(0)
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame
+TkFrame.new($check2_demo) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars($check2_demo,
+ ['safety', safety], ['wipers', wipers],
+ ['brakes', brakes], ['sober', sober])
+ }),
+ TkButton.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'check2'}),
+ TkButton.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $check2_demo
+ $check2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}.pack('side'=>'bottom', 'fill'=>'x')
+
+
+# checkbutton
+TkCheckButton.new($check2_demo, :text=>'Safety Check', :variable=>safety,
+ :relief=>:flat, :onvalue=>'all', :offvalue=>'none',
+ :tristatevalue=>'partial'){
+ pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+[ TkCheckButton.new($check2_demo, 'text'=>'Wipers OK', 'variable'=>wipers),
+ TkCheckButton.new($check2_demo, 'text'=>'Brakes OK', 'variable'=>brakes),
+ TkCheckButton.new($check2_demo, 'text'=>'Driver Sober', 'variable'=>sober)
+].each{|w|
+ w.relief('flat')
+ w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w')
+}
+
+# tristate check
+in_check = false
+tristate_check = proc{|n1,n2,op|
+ return if in_check
+
+ in_check = true
+ begin
+ if n1 == safety
+ if safety == 'none'
+ wipers.value = 0
+ brakes.value = 0
+ sober.value = 0
+ elsif safety == 'all'
+ wipers.value = 1
+ brakes.value = 1
+ sober.value = 1
+ end
+ else
+ if wipers == 1 && brakes == 1 && sober == 1
+ safety.value = 'all'
+ elsif wipers == 1 || brakes == 1 || sober == 1
+ safety.value = 'partial'
+ else
+ safety.value = 'none'
+ end
+ end
+ ensure
+ in_check = false
+ end
+}
+
+[wipers, brakes, sober, safety].each{|v| v.trace('w', tristate_check)}
diff --git a/ext/tk/sample/demos-en/clrpick.rb b/ext/tk/sample/demos-en/clrpick.rb
new file mode 100644
index 0000000000..9486fde314
--- /dev/null
+++ b/ext/tk/sample/demos-en/clrpick.rb
@@ -0,0 +1,77 @@
+# clrpick.rb
+#
+# This demonstration script prompts the user to select a color.
+#
+# widget demo prompts the user to select a color (called by 'widget')
+#
+
+# toplevel widget
+if defined?($clrpick_demo) && $clrpick_demo
+ $clrpick_demo.destroy
+ $clrpick_demo = nil
+end
+
+# demo toplevel widget
+$clrpick_demo = TkToplevel.new {|w|
+ title("Color Selection Dialogs")
+ iconname("colors")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"Press the buttons below to choose the foreground and background colors for the widgets in this window.").pack('side'=>'top')
+
+# frame
+TkFrame.new($clrpick_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $clrpick_demo
+ $clrpick_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'clrpick'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button
+TkButton.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'background',
+ ['background', 'highlightbackground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+TkButton.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+def setColor(w,button,name,options)
+ w.grab
+ initialColor = button[name]
+ color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w,
+ 'initialcolor'=>initialColor)
+ if color != ""
+ setColor_helper(w,options,color)
+ end
+
+ w.grab('release')
+end
+
+def setColor_helper(w, options, color)
+ options.each{|opt|
+ begin
+ w[opt] = color
+ rescue
+ end
+ }
+ TkWinfo.children(w).each{|child|
+ setColor_helper child, options, color
+ }
+end
+
diff --git a/ext/tk/sample/demos-en/colors.rb b/ext/tk/sample/demos-en/colors.rb
new file mode 100644
index 0000000000..66fb0afa36
--- /dev/null
+++ b/ext/tk/sample/demos-en/colors.rb
@@ -0,0 +1,148 @@
+# colors.rb
+#
+# This demonstration script creates a listbox widget that displays
+# many of the colors from the X color database. You can click on
+# a color to change the application's palette.
+#
+# listbox widget demo 'colors' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($colors_demo) && $colors_demo
+ $colors_demo.destroy
+ $colors_demo = nil
+end
+
+# demo toplevel widget
+$colors_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (colors)")
+ iconname("colors")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($colors_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "A listbox containing several color names is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by dragging in the listbox window with button 2 pressed. If you double-click button 1 on a color, then the application's color palette will be set to match that color"
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($colors_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $colors_demo
+ $colors_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'colors'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+colors_lbox = nil
+TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
+ s = TkScrollbar.new(w)
+ colors_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 10
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| colors_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+
+ins_data = [
+ 'gray60','gray70','gray80','gray85','gray90','gray95',
+ 'snow1','snow2','snow3','snow4','seashell1','seashell2',
+ 'seashell3','seashell4','AntiqueWhite1','AntiqueWhite2',
+ 'AntiqueWhite3','AntiqueWhite4','bisque1','bisque2',
+ 'bisque3','bisque4','PeachPuff1','PeachPuff2',
+ 'PeachPuff3','PeachPuff4','NavajoWhite1','NavajoWhite2',
+ 'NavajoWhite3','NavajoWhite4','LemonChiffon1',
+ 'LemonChiffon2','LemonChiffon3','LemonChiffon4',
+ 'cornsilk1','cornsilk2','cornsilk3','cornsilk4',
+ 'ivory1','ivory2','ivory3','ivory4','honeydew1',
+ 'honeydew2','honeydew3','honeydew4','LavenderBlush1',
+ 'LavenderBlush2','LavenderBlush3','LavenderBlush4',
+ 'MistyRose1','MistyRose2','MistyRose3','MistyRose4',
+ 'azure1','azure2','azure3','azure4','SlateBlue1',
+ 'SlateBlue2','SlateBlue3','SlateBlue4','RoyalBlue1',
+ 'RoyalBlue2','RoyalBlue3','RoyalBlue4','blue1','blue2',
+ 'blue3','blue4','DodgerBlue1','DodgerBlue2',
+ 'DodgerBlue3','DodgerBlue4','SteelBlue1','SteelBlue2',
+ 'SteelBlue3','SteelBlue4','DeepSkyBlue1','DeepSkyBlue2',
+ 'DeepSkyBlue3','DeepSkyBlue4','SkyBlue1','SkyBlue2',
+ 'SkyBlue3','SkyBlue4','LightSkyBlue1','LightSkyBlue2',
+ 'LightSkyBlue3','LightSkyBlue4','SlateGray1',
+ 'SlateGray2','SlateGray3','SlateGray4',
+ 'LightSteelBlue1','LightSteelBlue2','LightSteelBlue3',
+ 'LightSteelBlue4','LightBlue1','LightBlue2',
+ 'LightBlue3','LightBlue4','LightCyan1','LightCyan2',
+ 'LightCyan3','LightCyan4','PaleTurquoise1',
+ 'PaleTurquoise2','PaleTurquoise3','PaleTurquoise4',
+ 'CadetBlue1','CadetBlue2','CadetBlue3','CadetBlue4',
+ 'turquoise1','turquoise2','turquoise3','turquoise4',
+ 'cyan1','cyan2','cyan3','cyan4','DarkSlateGray1',
+ 'DarkSlateGray2','DarkSlateGray3','DarkSlateGray4',
+ 'aquamarine1','aquamarine2','aquamarine3','aquamarine4',
+ 'DarkSeaGreen1','DarkSeaGreen2','DarkSeaGreen3',
+ 'DarkSeaGreen4','SeaGreen1','SeaGreen2','SeaGreen3',
+ 'SeaGreen4','PaleGreen1','PaleGreen2','PaleGreen3',
+ 'PaleGreen4','SpringGreen1','SpringGreen2',
+ 'SpringGreen3','SpringGreen4','green1','green2',
+ 'green3','green4','chartreuse1','chartreuse2',
+ 'chartreuse3','chartreuse4','OliveDrab1','OliveDrab2',
+ 'OliveDrab3','OliveDrab4','DarkOliveGreen1',
+ 'DarkOliveGreen2','DarkOliveGreen3','DarkOliveGreen4',
+ 'khaki1','khaki2','khaki3','khaki4','LightGoldenrod1',
+ 'LightGoldenrod2','LightGoldenrod3','LightGoldenrod4',
+ 'LightYellow1','LightYellow2','LightYellow3',
+ 'LightYellow4','yellow1','yellow2','yellow3','yellow4',
+ 'gold1','gold2','gold3','gold4','goldenrod1',
+ 'goldenrod2','goldenrod3','goldenrod4','DarkGoldenrod1',
+ 'DarkGoldenrod2','DarkGoldenrod3','DarkGoldenrod4',
+ 'RosyBrown1','RosyBrown2','RosyBrown3','RosyBrown4',
+ 'IndianRed1','IndianRed2','IndianRed3','IndianRed4',
+ 'sienna1','sienna2','sienna3','sienna4','burlywood1',
+ 'burlywood2','burlywood3','burlywood4','wheat1',
+ 'wheat2','wheat3','wheat4','tan1','tan2','tan3','tan4',
+ 'chocolate1','chocolate2','chocolate3','chocolate4',
+ 'firebrick1','firebrick2','firebrick3','firebrick4',
+ 'brown1','brown2','brown3','brown4','salmon1','salmon2',
+ 'salmon3','salmon4','LightSalmon1','LightSalmon2',
+ 'LightSalmon3','LightSalmon4','orange1','orange2',
+ 'orange3','orange4','DarkOrange1','DarkOrange2',
+ 'DarkOrange3','DarkOrange4','coral1','coral2','coral3',
+ 'coral4','tomato1','tomato2','tomato3','tomato4',
+ 'OrangeRed1','OrangeRed2','OrangeRed3','OrangeRed4',
+ 'red1','red2','red3','red4','DeepPink1','DeepPink2',
+ 'DeepPink3','DeepPink4','HotPink1','HotPink2',
+ 'HotPink3','HotPink4','pink1','pink2','pink3','pink4',
+ 'LightPink1','LightPink2','LightPink3','LightPink4',
+ 'PaleVioletRed1','PaleVioletRed2','PaleVioletRed3',
+ 'PaleVioletRed4','maroon1','maroon2','maroon3',
+ 'maroon4','VioletRed1','VioletRed2','VioletRed3',
+ 'VioletRed4','magenta1','magenta2','magenta3',
+ 'magenta4','orchid1','orchid2','orchid3','orchid4',
+ 'plum1','plum2','plum3','plum4','MediumOrchid1',
+ 'MediumOrchid2','MediumOrchid3','MediumOrchid4',
+ 'DarkOrchid1','DarkOrchid2','DarkOrchid3',
+ 'DarkOrchid4','purple1','purple2','purple3','purple4',
+ 'MediumPurple1','MediumPurple2','MediumPurple3',
+ 'MediumPurple4','thistle1','thistle2','thistle3', 'thistle4'
+]
+
+colors_lbox.insert(0, *ins_data)
diff --git a/ext/tk/sample/demos-en/cscroll.rb b/ext/tk/sample/demos-en/cscroll.rb
new file mode 100644
index 0000000000..0838dfbe08
--- /dev/null
+++ b/ext/tk/sample/demos-en/cscroll.rb
@@ -0,0 +1,134 @@
+# cscroll.rb
+#
+# This demonstration script creates a simple canvas that can be
+# scrolled in two dimensions.
+#
+# simple scrollable canvas widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($cscroll_demo) && $cscroll_demo
+ $cscroll_demo.destroy
+ $cscroll_demo = nil
+end
+
+# demo toplevel widget
+$cscroll_demo = TkToplevel.new {|w|
+ title("Scrollable Canvas Demonstration")
+ iconname("cscroll")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i',
+ 'justify'=>'left', 'text'=>"This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."){
+ pack('side'=>'top')
+}
+
+# frame
+$cscroll_buttons = TkFrame.new($cscroll_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $cscroll_demo
+ $cscroll_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'cscroll'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+unless $tk_version =~ /^4\.[01]/
+ $cscroll_grid = TkFrame.new($cscroll_demo) {
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+ }
+ TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+end
+
+# canvas
+$cscroll_canvas = TkCanvas.new($cscroll_demo,
+ 'relief'=>'sunken', 'borderwidth'=>2,
+ 'scrollregion'=>['-11c', '-11c', '50c', '20c']
+ ) {|c|
+ if $tk_version =~ /^4\.[01]/
+ pack('expand'=>'yes', 'fill'=>'both')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+
+ TkScrollbar.new($cscroll_demo, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'right', 'fill'=>'y')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+
+ TkScrollbar.new($cscroll_demo, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}) {|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'bottom', 'fill'=>'x')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+}
+
+bg = $cscroll_canvas.configinfo('bg')[4]
+(0..19).each{|i|
+ x = -10+3*i
+ y = -10
+ (0..9).each{|j|
+ TkcRectangle.new($cscroll_canvas, "#{x}c", "#{y}c", "#{x+2}c", "#{y+2}c",
+ 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect')
+ TkcText.new($cscroll_canvas, "#{x+1}c", "#{y+1}c",
+ 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text')
+ y += 3
+ }
+}
+
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Leave', proc{scrollLeave $cscroll_canvas})
+$cscroll_canvas.itembind('all', '1', proc{scrollButton $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.bind('2', proc{|x,y| $cscroll_canvas.scan_mark(x,y)}, '%x %y')
+$cscroll_canvas.bind('B2-Motion',
+ proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y')
+
+def scrollEnter(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ $oldFill = c.itemconfiginfo(id, 'fill')[4]
+ if TkWinfo.depth(c) > 1
+ c.itemconfigure(id, 'fill'=>'SeaGreen1')
+ else
+ c.itemconfigure(id, 'fill'=>'black')
+ c.itemconfigure(id+1, 'fill'=>'white')
+ end
+end
+
+def scrollLeave(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ c.itemconfigure(id, 'fill'=>$oldFill)
+ c.itemconfigure(id+1, 'fill'=>'black')
+end
+
+def scrollButton(c)
+ id = c.find_withtag('current')[0].id
+ id += 1 unless c.gettags('current').include?('text')
+ print "You buttoned at #{c.itemconfiginfo(id,'text')[4]}\n"
+end
+
diff --git a/ext/tk/sample/demos-en/ctext.rb b/ext/tk/sample/demos-en/ctext.rb
new file mode 100644
index 0000000000..dbb5e32638
--- /dev/null
+++ b/ext/tk/sample/demos-en/ctext.rb
@@ -0,0 +1,186 @@
+# ctext.rb
+#
+# This demonstration script creates a canvas widget with a text
+# item that can be edited and reconfigured in various ways.
+#
+# Canvas Text widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($ctext_demo) && $ctext_demo
+ $ctext_demo.destroy
+ $ctext_demo = nil
+end
+
+# demo toplevel widget
+$ctext_demo = TkToplevel.new {|w|
+ title("Canvas Text Demonstration")
+ iconname("Text")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification. The text also supports the following simple bindings for editing:
+ 1. You can point, click, and type.
+ 2. You can also select with button 1.
+ 3. You can copy the selection to the mouse position with button 2.
+ 4. Backspace and Control+h delete the selection if there is one;
+ otherwise they delete the character just before the insertion cursor.
+ 5. Delete deletes the selection if there is one; otherwise it deletes
+ the character just after the insertion cursor."){
+ pack('side'=>'top')
+}
+
+# frame
+$ctext_buttons = TkFrame.new($ctext_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $ctext_demo
+ $ctext_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'ctext'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas
+$ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat',
+ 'borderwidth'=>0, 'width'=>500, 'height'=>350)
+$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+
+# font
+textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+
+# canvas
+TkcRectangle.new($ctext_canvas, 245, 195, 255, 205,
+ 'outline'=>'black', 'fill'=>'red')
+
+$ctag_text = TkcTag.new($ctext_canvas)
+$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200,
+ 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).",
+ 'width'=>440, 'anchor'=>'n',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*',
+ 'kanjifont'=>'-*--24-*-jisx0208.1983-0',
+ 'justify'=>'left') )
+
+$ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('Shift-1',
+ proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"},
+ "%x %y")
+$ctag_text.bind('Shift-B1-Motion',
+ proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('KeyPress', proc{|a| textInsert $ctext_canvas,a}, "%A")
+$ctag_text.bind('Return', proc{textInsert $ctext_canvas,"\n"})
+$ctag_text.bind('Control-h', proc{textBs $ctext_canvas})
+$ctag_text.bind('BackSpace', proc{textBs $ctext_canvas})
+$ctag_text.bind('Delete', proc{textDel $ctext_canvas})
+$ctag_text.bind('2', proc{|x,y| textPaste $ctext_canvas, "@#{x},#{y}"},
+ "%x %y")
+
+# Next, create some items that allow the text's anchor position
+# to be edited.
+
+def mkTextConfig(w,x,y,option,value,color)
+ item = TkcRectangle.new(w, x, y, x+30, y+30,
+ 'outline'=>'black', 'fill'=>color, 'width'=>1)
+ item.bind('1', proc{$ctag_text.configure option, value})
+ w.addtag_withtag('config', item)
+end
+
+x = 50
+y = 50
+color = 'LightSkyBlue1'
+mkTextConfig $ctext_canvas, x, y, 'anchor', 'se', color
+mkTextConfig $ctext_canvas, x+30, y, 'anchor', 's', color
+mkTextConfig $ctext_canvas, x+60, y, 'anchor', 'sw', color
+mkTextConfig $ctext_canvas, x, y+30, 'anchor', 'e', color
+mkTextConfig $ctext_canvas, x+30, y+30, 'anchor', 'center', color
+mkTextConfig $ctext_canvas, x+60, y+30, 'anchor', 'w', color
+mkTextConfig $ctext_canvas, x, y+60, 'anchor', 'ne', color
+mkTextConfig $ctext_canvas, x+30, y+60, 'anchor', 'n', color
+mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color
+item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50,
+ 'outline'=>'black', 'fill'=>'red')
+item.bind('1', proc{$ctag_text.configure 'anchor', 'center'})
+TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'fill'=>'brown')
+
+# Lastly, create some items that allow the text's justification to be
+# changed.
+
+x = 350
+y = 50
+color = 'SeaGreen2'
+mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color
+mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color
+mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color
+TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'fill'=>'brown')
+
+$ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas})
+$ctext_canvas.itembind('config', 'Leave',
+ proc{$ctext_canvas\
+ .itemconfigure('current',
+ 'fill'=>$textConfigFill)})
+
+$textConfigFill = ''
+
+def textEnter(w)
+ $textConfigFill = (w.itemconfiginfo 'current', 'fill')[4]
+ w.itemconfigure 'current', 'fill', 'black'
+end
+
+def textInsert(w, string)
+ return if string == ""
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ end
+ $ctag_text.insert 'insert', string
+end
+
+def textPaste(w, pos)
+ begin
+ $ctag_text.insert pos, TkSelection.get
+ rescue
+ end
+end
+
+def textB1Press(w,x,y)
+ w.icursor 'current', "@#{x},#{y}"
+ w.itemfocus 'current'
+ w.focus
+ w.select_from 'current', "@#{x},#{y}"
+end
+
+def textB1Move(w,x,y)
+ w.select_to 'current', "@#{x},#{y}"
+end
+
+def textBs(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ char = $ctag_text.index('insert').to_i - 1
+ $ctag_text.dchars(char) if char >= 0
+ end
+end
+
+def textDel(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ $ctag_text.dchars 'insert'
+ end
+end
+
diff --git a/ext/tk/sample/demos-en/dialog1.rb b/ext/tk/sample/demos-en/dialog1.rb
new file mode 100644
index 0000000000..af476ecd05
--- /dev/null
+++ b/ext/tk/sample/demos-en/dialog1.rb
@@ -0,0 +1,38 @@
+#
+# a dialog box with a local grab (called by 'widget')
+#
+class TkDialog_Demo1 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with local grab"
+ end
+
+ def message
+ 'This is a modal dialog box. It uses Tk\'s "grab" command to create a "local grab" on the dialog box. The grab prevents any pointer-related events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications.'
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+ # ["Dismiss", "", "Show Code"]
+ ["OK", "Cancel", "Show Code"]
+ end
+end
+
+ret = TkDialog_Demo1.new('message_config'=>{'wraplength'=>'4i'}).value
+case ret
+when 0
+ print "You pressed OK\n"
+when 1
+ print "You pressed Cancel\n"
+when 2
+ showCode 'dialog1'
+end
diff --git a/ext/tk/sample/demos-en/dialog2.rb b/ext/tk/sample/demos-en/dialog2.rb
new file mode 100644
index 0000000000..efc4b714da
--- /dev/null
+++ b/ext/tk/sample/demos-en/dialog2.rb
@@ -0,0 +1,41 @@
+#
+# a dialog box with a global grab (called by 'widget')
+#
+class TkDialog_Demo2 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with global grab"
+ end
+
+ def message
+ "This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate."
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+ ["OK", "Cancel", "Show Code"]
+ end
+end
+
+ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'},
+ 'prev_command'=>proc{|dialog|
+ Tk.after 100, proc{dialog.grab('global')}
+ }).value
+case ret
+when 0
+ print "\You pressed OK\n"
+when 1
+ print "You pressed Cancel\n"
+when 2
+ showCode 'dialog2'
+end
+
diff --git a/ext/tk/sample/demos-en/doc.org/README b/ext/tk/sample/demos-en/doc.org/README
new file mode 100644
index 0000000000..90677d3316
--- /dev/null
+++ b/ext/tk/sample/demos-en/doc.org/README
@@ -0,0 +1,7 @@
+This directory contains a collection of demonstration programs that
+are translated into Japanese. You need to use a Japanized "wish" to
+see these Japanese-translated demonstration programs. You also need
+to put this directory ("demos.jp") at the next to "demos" since some
+of the programs refer to the image files at "demos".
+
+Please refer to the README file at "demos" for more detail.
diff --git a/ext/tk/sample/demos-en/doc.org/README.JP b/ext/tk/sample/demos-en/doc.org/README.JP
new file mode 100644
index 0000000000..42b4929378
--- /dev/null
+++ b/ext/tk/sample/demos-en/doc.org/README.JP
@@ -0,0 +1,14 @@
+This directory contains "widget" demo for the Japanized Tcl7.6/Tk4.2.
+Most of the messages in the original are translated to Japanese.
+But other tools in this directory are not translated.
+
+Following 2 kanji fonts are defined at the beginning of the file "widget."
+
+ -*--24-*-jisx0208.1983-0
+ -*--16-*-jisx0208.1983-0
+
+These fonts are all part of the core distribution of X11R5, so
+if you are running X11R5, you don't have to modify the file.
+
+But if you don't have these fonts, replace them with appropriate ones.
+"-*--14-*-jisx0208.1983-0" will be a good choice.
diff --git a/ext/tk/sample/demos-en/doc.org/README.tk80 b/ext/tk/sample/demos-en/doc.org/README.tk80
new file mode 100644
index 0000000000..c71f977d74
--- /dev/null
+++ b/ext/tk/sample/demos-en/doc.org/README.tk80
@@ -0,0 +1,46 @@
+This directory contains a collection of programs to demonstrate
+the features of the Tk toolkit. The programs are all scripts for
+"wish", a windowing shell. If wish has been installed in /usr/local
+then you can invoke any of the programs in this directory just
+by typing its file name to your command shell. Otherwise invoke
+wish with the file as its first argument, e.g., "wish hello".
+The rest of this file contains a brief description of each program.
+Files with names ending in ".tcl" are procedure packages used by one
+or more of the demo programs; they can't be used as programs by
+themselves so they aren't described below.
+
+hello - Creates a single button; if you click on it, a message
+ is typed and the application terminates.
+
+widget - Contains a collection of demonstrations of the widgets
+ currently available in the Tk library. Most of the .tcl
+ files are scripts for individual demos available through
+ the "widget" program.
+
+ixset - A simple Tk-based wrapper for the "xset" program, which
+ allows you to interactively query and set various X options
+ such as mouse acceleration and bell volume. Thanks to
+ Pierre David for contributing this example.
+
+rolodex - A mock-up of a simple rolodex application. It has much of
+ the user interface for such an application but no back-end
+ database. This program was written in response to Tom
+ LaStrange's toolkit benchmark challenge.
+
+tcolor - A color editor. Allows you to edit colors in several
+ different ways, and will also perform automatic updates
+ using "send".
+
+rmt - Allows you to "hook-up" remotely to any Tk application
+ on the display. Select an application with the menu,
+ then just type commands: they'll go to that application.
+
+timer - Displays a seconds timer with start and stop buttons.
+ Control-c and control-q cause it to exit.
+
+browse - A simple directory browser. Invoke it with and argument
+ giving the name of the directory you'd like to browse.
+ Double-click on files or subdirectories to browse them.
+ Control-c and control-q cause the program to exit.
+
+sccs id = SCCS: @(#) README 1.3 96/02/16 10:49:14
diff --git a/ext/tk/sample/demos-en/doc.org/license.terms b/ext/tk/sample/demos-en/doc.org/license.terms
new file mode 100644
index 0000000000..03ca6fcb31
--- /dev/null
+++ b/ext/tk/sample/demos-en/doc.org/license.terms
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/demos-en/doc.org/license.terms.tk80 b/ext/tk/sample/demos-en/doc.org/license.terms.tk80
new file mode 100644
index 0000000000..03ca6fcb31
--- /dev/null
+++ b/ext/tk/sample/demos-en/doc.org/license.terms.tk80
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/demos-en/entry1.rb b/ext/tk/sample/demos-en/entry1.rb
new file mode 100644
index 0000000000..29bc693395
--- /dev/null
+++ b/ext/tk/sample/demos-en/entry1.rb
@@ -0,0 +1,56 @@
+#
+# entry (no scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($entry1_demo) && $entry1_demo
+ $entry1_demo.destroy
+ $entry1_demo = nil
+end
+
+# demo toplevel widget
+$entry1_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (no scrollbars)")
+ iconname("entry1")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($entry1_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse button2 pressed."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($entry1_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $entry1_demo
+ $entry1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'entry1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+#
+e1 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+e2 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+e3 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')}
+
+#
+e1.insert(0, 'Initial value')
+e2.insert('end', "This entry contains a long value, much too long ")
+e2.insert('end', "to fit in the window at one time, so long in fact ")
+e2.insert('end', "that you'll have to scan or scroll to see the end.")
+e2.insert('end', "")
+
diff --git a/ext/tk/sample/demos-en/entry2.rb b/ext/tk/sample/demos-en/entry2.rb
new file mode 100644
index 0000000000..d4e58d7dd5
--- /dev/null
+++ b/ext/tk/sample/demos-en/entry2.rb
@@ -0,0 +1,91 @@
+# entry2.rb
+#
+# This demonstration script is the same as the entry1.tcl script
+# except that it creates scrollbars for the entries.
+#
+# entry (with scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($entry2_demo) && $entry2_demo
+ $entry2_demo.destroy
+ $entry2_demo = nil
+end
+
+# demo toplevel widget
+$entry2_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (with scrollbars)")
+ iconname("entry2")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($entry2_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with mouse button2 pressed."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($entry2_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $entry2_demo
+ $entry2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'entry2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+TkFrame.new($entry2_demo, 'borderwidth'=>10) {|w|
+ # entry 1
+ s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e1 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s1.set first,last}
+ }
+ s1.command(proc{|*args| e1.xview(*args)})
+ e1.pack('side'=>'top', 'fill'=>'x')
+ s1.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 2
+ s2 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e2 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s2.set first,last}
+ }
+ s2.command(proc{|*args| e2.xview(*args)})
+ e2.pack('side'=>'top', 'fill'=>'x')
+ s2.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 3
+ s3 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e3 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s3.set first,last}
+ }
+ s3.command(proc{|*args| e3.xview(*args)})
+ e3.pack('side'=>'top', 'fill'=>'x')
+ s3.pack('side'=>'top', 'fill'=>'x')
+
+ #
+ e1.insert(0, 'Initial value')
+ e2.insert('end', "This entry contains a long value, much too long ")
+ e2.insert('end', "to fit in the window at one time, so long in fact ")
+ e2.insert('end', "that you'll have to scan or scroll to see the end.")
+ e2.insert('end', "")
+
+}.pack('side'=>'top', 'fill'=>'x', 'expand'=>'yes')
+
diff --git a/ext/tk/sample/demos-en/entry3.rb b/ext/tk/sample/demos-en/entry3.rb
new file mode 100644
index 0000000000..415b45f86c
--- /dev/null
+++ b/ext/tk/sample/demos-en/entry3.rb
@@ -0,0 +1,200 @@
+# entry3.rb --
+#
+# This demonstration script creates several entry widgets whose
+# permitted input is constrained in some way. It also shows off a
+# password entry.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($entry3_demo) && $entry3_demo
+ $entry3_demo.destroy
+ $entry3_demo = nil
+end
+
+$entry3_demo = TkToplevel.new {|w|
+ title("Constrained Entry Demonstration")
+ iconname("entry3")
+ positionWindow(w)
+}
+
+TkLabel.new($entry3_demo,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+Four different entries are displayed below. You can add characters \
+by pointing, clicking and typing, though each is constrained in what \
+it will accept. The first only accepts integers or the empty string \
+(checking when focus leaves it) and will flash to indicate any \
+problem. The second only accepts strings with fewer than ten \
+characters and sounds the bell when an attempt to go over the limit \
+is made. The third accepts US phone numbers, mapping letters to \
+their digit equivalent and sounding the bell on encountering an \
+illegal character or if trying to type over a character that is not \
+a digit. The fourth is a password field that accepts up to eight \
+characters (silently ignoring further ones), and displaying them as \
+asterisk characters.
+EOL
+
+TkFrame.new($entry3_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $entry3_demo.destroy
+ $entry3_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'entry3'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# focusAndFlash --
+# Error handler for entry widgets that forces the focus onto the
+# widget and makes the widget flash by exchanging the foreground and
+# background colours at intervals of 200ms (i.e. at approximately
+# 2.5Hz).
+#
+# Arguments:
+# widget - entry widget to flash
+# fg - Initial foreground colour
+# bg - Initial background colour
+# count - Counter to control the number of times flashed
+def focusAndFlash(widget, fg, bg, count=5)
+ return if count <= 0
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>bg, :background=>fg)},
+ proc{widget.configure(:foreground=>fg, :background=>bg)}
+ ).start
+ widget.focus(true)
+end
+
+l1 = TkLabelFrame.new($entry3_demo, :text=>"Integer Entry")
+TkEntry.new(l1, :validate=>:focus,
+ :vcmd=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]) {|e|
+ invalidcommand [proc{|w| focusAndFlash(w, e.fg, e.bg)}, '%W']
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l2 = TkLabelFrame.new($entry3_demo, :text=>"Length-Constrained Entry")
+TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :vcmd=>[proc{|s| s.length < 10}, '%P']
+ ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+### PHONE NUMBER ENTRY ###
+# Note that the source to this is quite a bit longer as the behaviour
+# demonstrated is a lot more ambitious than with the others.
+
+# Initial content for the third entry widget
+entry3content = TkVariable.new("1-(000)-000-0000")
+
+# Mapping from alphabetic characters to numbers.
+$phoneNumberMap = {}
+Hash[*(%w(abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9))].each{|chars, n|
+ chars.split('').each{|c|
+ $phoneNumberMap[c] = n
+ $phoneNumberMap[c.upcase] = n
+ }
+}
+
+# phoneSkipLeft --
+# Skip over fixed characters in a phone-number string when moving left.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+def phoneSkipLeft(widget)
+ idx = widget.index('insert')
+ if idx == 8
+ # Skip back two extra characters
+ widget.cursor = idx - 2
+ elsif idx == 7 || idx == 12
+ # Skip back one extra character
+ widget.cursor = idx - 1
+ elsif idx <= 3
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# phoneSkipRight --
+# Skip over fixed characters in a phone-number string when moving right.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+# add - Offset to add to index before calculation (used by validation.)
+def phoneSkipRight(widget, add = 0)
+ idx = widget.index('insert')
+ if (idx + add == 5)
+ # Skip forward two extra characters
+ widget.cursor = idx + 2
+ elsif (idx + add == 6 || idx + add == 10)
+ # Skip forward one extra character
+ widget.cursor = idx + 1
+ elsif (idx + add == 15 && add == 0)
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# validatePhoneChange --
+# Checks that the replacement (mapped to a digit) of the given
+# character in an entry widget at the given position will leave a
+# valid phone number in the widget.
+#
+# widget - entry widget to validate
+# vmode - The widget's validation mode
+# idx - The index where replacement is to occur
+# char - The character (or string, though that will always be
+# refused) to be overwritten at that point.
+
+def validatePhoneChange(widget, vmode, idx, char)
+ return true if idx == nil
+ Tk.after_idle(proc{widget.configure(:validate=>vmode,
+ :invcmd=>proc{Tk.bell})})
+ if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/
+ widget.delete(idx)
+ widget.insert(idx, $phoneNumberMap[char] || char)
+ Tk.after_idle(proc{phoneSkipRight(widget, -1)})
+ return true
+ # Tk.update(true) # Don't work 'update' inter validation callback.
+ # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
+ end
+ return false
+end
+
+
+l3 = TkLabelFrame.new($entry3_demo, :text=>"US Phone-Number Entry")
+TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :textvariable=>entry3content,
+ :vcmd=>[
+ proc{|w,v,i,s| validatePhoneChange(w,v,i,s)},
+ "%W %v %i %S"
+ ]){|e|
+ # Click to focus goes to the first editable character...
+ bind('FocusIn', proc{|d,w|
+ if d != "NotifyAncestor"
+ w.cursor = 3
+ Tk.after_idle(proc{w.selection_clear})
+ end
+ }, '%d %W')
+ bind('Left', proc{|w| phoneSkipLeft(w)}, '%W')
+ bind('Right', proc{|w| phoneSkipRight(w)}, '%W')
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l4 = TkLabelFrame.new($entry3_demo, :text=>"Password Entry")
+TkEntry.new(l4, :validate=>:key, :show=>'*',
+ :vcmd=>[
+ proc{|s| s.length <= 8},
+ '%P'
+ ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+TkFrame.new($entry3_demo){|f|
+ lower
+ TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.columnconfigure(f, [0,1], :uniform=>1)
+ pack(:fill=>:both, :expand=>true)
+}
diff --git a/ext/tk/sample/demos-en/filebox.rb b/ext/tk/sample/demos-en/filebox.rb
new file mode 100644
index 0000000000..36b19de557
--- /dev/null
+++ b/ext/tk/sample/demos-en/filebox.rb
@@ -0,0 +1,97 @@
+# filebox.rb
+#
+# This demonstration script prompts the user to select a file.#
+# widget demo prompts the user to select a file (called by 'widget')
+#
+
+# toplevel widget
+if defined?($filebox_demo) && $filebox_demo
+ $filebox_demo.destroy
+ $filebox_demo = nil
+end
+
+# demo toplevel widget
+$filebox_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("filebox")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog.").pack('side'=>'top')
+
+# frame
+TkFrame.new($filebox_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $filebox_demo
+ $filebox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'filebox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+['open', 'save'].each{|type|
+ TkFrame.new($filebox_demo) {|f|
+ TkLabel.new(f, 'text'=>"Select a file to #{type}: ", 'anchor'=>'e')\
+ .pack('side'=>'left')
+
+ TkEntry.new(f, 'width'=>20) {|e|
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+
+ TkButton.new(f, 'text'=>'Browse ...',
+ 'command'=>proc{fileDialog $filebox_demo,e,type})\
+ .pack('side'=>'left')
+ }
+
+ pack('fill'=>'x', 'padx'=>'1c', 'pady'=>3)
+ }
+}
+
+$tk_strictMotif = TkVarAccess.new('tk_strictMotif')
+if ($tk_platform['platform'] == 'unix')
+ TkCheckButton.new($filebox_demo,
+ 'text'=>'Use Motif Style Dialog',
+ 'variable'=>$tk_strictMotif,
+ 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c')
+end
+
+def fileDialog(w,ent,operation)
+ # Type names Extension(s) Mac File Type(s)
+ #
+ #--------------------------------------------------------
+ types = [
+ ['Text files', ['.txt','.doc'] ],
+ ['Text files', [], 'TEXT' ],
+ ['Ruby Scripts', ['.rb'], 'TEXT' ],
+ ['Tcl Scripts', ['.tcl'], 'TEXT' ],
+ ['C Source Files', ['.c','.h'] ],
+ ['All Source Files', ['.rb','.tcl','.c','.h'] ],
+ ['Image Files', ['.gif'] ],
+ ['Image Files', ['.jpeg','.jpg'] ],
+ ['Image Files', [], ['GIFF','JPEG']],
+ ['All files', '*' ]
+ ]
+
+ if operation == 'open'
+ file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w)
+ else
+ file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w,
+ 'initialfile'=>'Untitled',
+ 'defaultextension'=>'.txt')
+ end
+ if file != ""
+ ent.delete 0, 'end'
+ ent.insert 0, file
+ ent.xview 'end'
+ end
+end
+
diff --git a/ext/tk/sample/demos-en/floor.rb b/ext/tk/sample/demos-en/floor.rb
new file mode 100644
index 0000000000..15c56a154e
--- /dev/null
+++ b/ext/tk/sample/demos-en/floor.rb
@@ -0,0 +1,1721 @@
+# floor.rb
+#
+# This demonstration script creates a canvas widet that displays the
+# floorplan for DEC's Western Research Laboratory.
+#
+# floorDisplay widget demo (called by 'widget')
+#
+
+# floorDisplay --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay(w,active)
+ return if $activeFloor == active
+
+ w.delete('all')
+ $activeFloor = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor_bg1(w,$floor_colors['bg1'],$floor_colors['outline1'])
+ floor_bg2(w,$floor_colors['bg2'],$floor_colors['outline2'])
+ floor_bg3(w,$floor_colors['bg3'],$floor_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ TkcRectangle.new(w,0,100,1,101, 'fill'=>'', 'outline'=>'', 'tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels.clear
+ $floorItems.clear
+ send("floor_fg#{active}", w, $floor_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ TkcWindow.new(w, 600, 100, 'anchor'=>'w', 'window'=>$floor_entry)
+ TkcText.new(w, 600, 100, 'anchor'=>'e', 'text'=>"Room: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom.value = $floorLabels[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged(w,*args)
+ w.delete('highlight')
+ item = $floorItems[$currentRoom.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg1(w,fill,outline)
+ TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg2(w,fill,outline)
+ TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg3(w,fill,outline)
+ TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '101'
+ $floorItems['101'] = i
+ TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Pub Lift1'
+ $floorItems['Pub Lift1'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Priv Lift1'
+ $floorItems['Priv Lift1'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '110'
+ $floorItems['110'] = i
+ TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '109'
+ $floorItems['109'] = i
+ TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '111'
+ $floorItems['111'] = i
+ TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117B'
+ $floorItems['117B'] = i
+ TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '112'
+ $floorItems['112'] = i
+ TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '113'
+ $floorItems['113'] = i
+ TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117A'
+ $floorItems['117A'] = i
+ TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117'
+ $floorItems['117'] = i
+ TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '114'
+ $floorItems['114'] = i
+ TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '115'
+ $floorItems['115'] = i
+ TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '116'
+ $floorItems['116'] = i
+ TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '118'
+ $floorItems['118'] = i
+ TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '120'
+ $floorItems['120'] = i
+ TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '122'
+ $floorItems['122'] = i
+ TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '121'
+ $floorItems['121'] = i
+ TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106A'
+ $floorItems['106A'] = i
+ TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '105'
+ $floorItems['105'] = i
+ TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106B'
+ $floorItems['106B'] = i
+ TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '104'
+ $floorItems['104'] = i
+ TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '108'
+ $floorItems['108'] = i
+ TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '107'
+ $floorItems['107'] = i
+ TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Smoking'
+ $floorItems['Smoking'] = i
+ TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '123'
+ $floorItems['123'] = i
+ TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '103'
+ $floorItems['103'] = i
+ TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '124'
+ $floorItems['124'] = i
+ TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '125'
+ $floorItems['125'] = i
+ TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '126'
+ $floorItems['126'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '127'
+ $floorItems['127'] = i
+ TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'MShower'
+ $floorItems['MShower'] = i
+ TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Closet'
+ $floorItems['Closet'] = i
+ TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'WShower'
+ $floorItems['WShower'] = i
+ TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '130'
+ $floorItems['130'] = i
+ TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '102'
+ $floorItems['102'] = i
+ TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '128'
+ $floorItems['128'] = i
+ TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '129'
+ $floorItems['129'] = i
+ TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '133'
+ $floorItems['133'] = i
+ TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '132'
+ $floorItems['132'] = i
+ TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '134'
+ $floorItems['134'] = i
+ TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '135'
+ $floorItems['135'] = i
+ TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Ramona Stair'
+ $floorItems['Ramona Stair'] = i
+ TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'University Stair'
+ $floorItems['University Stair'] = i
+ TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Stair'
+ $floorItems['Plaza Stair'] = i
+ TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Deck'
+ $floorItems['Plaza Deck'] = i
+ TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106'
+ $floorItems['106'] = i
+ TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '119'
+ $floorItems['119'] = i
+ TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '238'
+ $floorItems['238'] = i
+ TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '237'
+ $floorItems['237'] = i
+ TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '246'
+ $floorItems['246'] = i
+ TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '247'
+ $floorItems['247'] = i
+ TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '202'
+ $floorItems['202'] = i
+ TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '206'
+ $floorItems['206'] = i
+ TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '212'
+ $floorItems['212'] = i
+ TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '245'
+ $floorItems['245'] = i
+ TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '244'
+ $floorItems['244'] = i
+ TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '243'
+ $floorItems['243'] = i
+ TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '242'
+ $floorItems['242'] = i
+ TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Barbecue Deck'
+ $floorItems['Barbecue Deck'] = i
+ TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '240'
+ $floorItems['240'] = i
+ TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '241'
+ $floorItems['241'] = i
+ TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '239'
+ $floorItems['239'] = i
+ TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '248'
+ $floorItems['248'] = i
+ TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '236'
+ $floorItems['236'] = i
+ TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '235'
+ $floorItems['235'] = i
+ TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '234'
+ $floorItems['234'] = i
+ TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '233'
+ $floorItems['233'] = i
+ TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '230'
+ $floorItems['230'] = i
+ TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '232'
+ $floorItems['232'] = i
+ TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '229'
+ $floorItems['229'] = i
+ TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '227'
+ $floorItems['227'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '228'
+ $floorItems['228'] = i
+ TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '226'
+ $floorItems['226'] = i
+ TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '225'
+ $floorItems['225'] = i
+ TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '224'
+ $floorItems['224'] = i
+ TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '223'
+ $floorItems['223'] = i
+ TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '222'
+ $floorItems['222'] = i
+ TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '221'
+ $floorItems['221'] = i
+ TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '204'
+ $floorItems['204'] = i
+ TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '205'
+ $floorItems['205'] = i
+ TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '207'
+ $floorItems['207'] = i
+ TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '208'
+ $floorItems['208'] = i
+ TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '209'
+ $floorItems['209'] = i
+ TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217'
+ $floorItems['217'] = i
+ TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217A'
+ $floorItems['217A'] = i
+ TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '216'
+ $floorItems['216'] = i
+ TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '215'
+ $floorItems['215'] = i
+ TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '214'
+ $floorItems['214'] = i
+ TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '213'
+ $floorItems['213'] = i
+ TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '210'
+ $floorItems['210'] = i
+ TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '211'
+ $floorItems['211'] = i
+ TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '203'
+ $floorItems['203'] = i
+ TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '220'
+ $floorItems['220'] = i
+ TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Priv Lift2'
+ $floorItems['Priv Lift2'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Pub Lift 2'
+ $floorItems['Pub Lift 2'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '218'
+ $floorItems['218'] = i
+ TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '219'
+ $floorItems['219'] = i
+ TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '201'
+ $floorItems['201'] = i
+ TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316'
+ $floorItems['316'] = i
+ TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '309'
+ $floorItems['309'] = i
+ TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '308'
+ $floorItems['308'] = i
+ TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '307'
+ $floorItems['307'] = i
+ TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '305'
+ $floorItems['305'] = i
+ TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324B'
+ $floorItems['324B'] = i
+ TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324A'
+ $floorItems['324A'] = i
+ TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '320'
+ $floorItems['320'] = i
+ TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '310'
+ $floorItems['310'] = i
+ TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '312'
+ $floorItems['312'] = i
+ TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '313'
+ $floorItems['313'] = i
+ TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '314'
+ $floorItems['314'] = i
+ TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '315'
+ $floorItems['315'] = i
+ TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316B'
+ $floorItems['316B'] = i
+ TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316A'
+ $floorItems['316A'] = i
+ TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '319'
+ $floorItems['319'] = i
+ TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '311'
+ $floorItems['311'] = i
+ TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '318'
+ $floorItems['318'] = i
+ TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '317'
+ $floorItems['317'] = i
+ TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '323'
+ $floorItems['323'] = i
+ TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '325'
+ $floorItems['325'] = i
+ TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '321'
+ $floorItems['321'] = i
+ TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '322'
+ $floorItems['322'] = i
+ TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Pub Lift3'
+ $floorItems['Pub Lift3'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Priv Lift3'
+ $floorItems['Priv Lift3'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '303'
+ $floorItems['303'] = i
+ TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324'
+ $floorItems['324'] = i
+ TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '304'
+ $floorItems['304'] = i
+ TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '301'
+ $floorItems['301'] = i
+ TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '327'
+ $floorItems['327'] = i
+ TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '326'
+ $floorItems['326'] = i
+ TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '302'
+ $floorItems['302'] = i
+ TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '306'
+ $floorItems['306'] = i
+ TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget
+if defined?($floor_demo) && $floor_demo
+ $floor_demo.destroy
+ $floor_demo = nil
+end
+
+# demo toplevel widget
+$floor_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration")
+ iconname("Floorplan")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+# label
+TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){
+ pack('side'=>'top')
+}
+
+# frame
+$floor_buttons = TkFrame.new($floor_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $floor_demo
+ $floor_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'floor'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+#
+$floorLabels = {}
+$floorItems = {}
+
+# canvas
+if $tk_version =~ /^4\.[01]/
+ $floor_canvas_frame = TkFrame.new($floor_demo,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor_canvas = TkCanvas.new($floor_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new($floor_demo, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new($floor_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new($floor_demo) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| c.yview(*args)})
+ h.command(proc{|*args| c.xview(*args)})
+ }
+end
+
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom = TkVariable.new
+$floor_entry = TkEntry.new($floor_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom)
+
+# Choose colors, then fill in the floorplan.
+
+$floor_colors = {}
+if TkWinfo.depth($floor_canvas) > 1
+ $floor_colors['bg1'] = '#a9c1da'
+ $floor_colors['outline1'] = '#77889a'
+ $floor_colors['bg2'] = '#9ab0c6'
+ $floor_colors['outline2'] = '#687786'
+ $floor_colors['bg3'] = '#8ba0b3'
+ $floor_colors['outline3'] = '#596673'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = '#c4d1df'
+else
+ $floor_colors['bg1'] = 'white'
+ $floor_colors['outline1'] = 'black'
+ $floor_colors['bg2'] = 'white'
+ $floor_colors['outline2'] = 'black'
+ $floor_colors['bg3'] = 'white'
+ $floor_colors['outline3'] = 'black'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = 'black'
+end
+
+$activeFloor = ''
+floorDisplay $floor_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor_canvas.itembind('floor1', '1', proc{floorDisplay $floor_canvas,1})
+$floor_canvas.itembind('floor2', '1', proc{floorDisplay $floor_canvas,2})
+$floor_canvas.itembind('floor3', '1', proc{floorDisplay $floor_canvas,3})
+$floor_canvas.itembind('room', 'Enter', proc{newRoom $floor_canvas})
+$floor_canvas.itembind('room', 'Leave', proc{$currentRoom.value = ''})
+$floor_canvas.bind('2', proc{|x,y| $floor_canvas.scan_mark x,y}, '%x %y')
+$floor_canvas.bind('B2-Motion',
+ proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y')
+$floor_canvas.bind('Destroy', proc{$currentRoom.unset})
+$currentRoom.value = ''
+$currentRoom.trace('w',proc{roomChanged $floor_canvas})
+
diff --git a/ext/tk/sample/demos-en/floor2.rb b/ext/tk/sample/demos-en/floor2.rb
new file mode 100644
index 0000000000..ab8659a628
--- /dev/null
+++ b/ext/tk/sample/demos-en/floor2.rb
@@ -0,0 +1,1720 @@
+%# floor2.rb
+#
+# This demonstration script creates a canvas widet that displays the
+# floorplan for DEC's Western Research Laboratory.
+#
+# floorDisplay widget demo (called by 'widget')
+#
+
+# floorDisplay2 --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay2(w,active)
+ return if $activeFloor2 == active
+
+ w.delete('all')
+ $activeFloor2 = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor2_bg1(w,$floor2_colors['bg1'],$floor2_colors['outline1'])
+ floor2_bg2(w,$floor2_colors['bg2'],$floor2_colors['outline2'])
+ floor2_bg3(w,$floor2_colors['bg3'],$floor2_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ w.create(TkcRectangle,0,100,1,101,'fill'=>'','outline'=>'','tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels2.clear
+ $floorItems2.clear
+ send("floor2_fg#{active}", w, $floor2_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ w.create(TkcWindow, 600, 100, 'anchor'=>'w', 'window'=>$floor2_entry)
+ w.create(TkcText, 600, 100, 'anchor'=>'e', 'text'=>"Room: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom2 --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom2(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom2.value = $floorLabels2[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged2 --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged2(w,*args)
+ w.delete('highlight')
+ item = $floorItems2[$currentRoom2.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor2_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor2_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg1(w,fill,outline)
+ w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor2_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg2(w,fill,outline)
+ w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor2_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg3(w,fill,outline)
+ w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor2_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '101'
+ $floorItems2['101'] = i
+ w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Pub Lift1'
+ $floorItems2['Pub Lift1'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Priv Lift1'
+ $floorItems2['Priv Lift1'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '110'
+ $floorItems2['110'] = i
+ w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '109'
+ $floorItems2['109'] = i
+ w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '111'
+ $floorItems2['111'] = i
+ w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117B'
+ $floorItems2['117B'] = i
+ w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '112'
+ $floorItems2['112'] = i
+ w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '113'
+ $floorItems2['113'] = i
+ w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117A'
+ $floorItems2['117A'] = i
+ w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117'
+ $floorItems2['117'] = i
+ w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '114'
+ $floorItems2['114'] = i
+ w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '115'
+ $floorItems2['115'] = i
+ w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '116'
+ $floorItems2['116'] = i
+ w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '118'
+ $floorItems2['118'] = i
+ w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '120'
+ $floorItems2['120'] = i
+ w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '122'
+ $floorItems2['122'] = i
+ w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '121'
+ $floorItems2['121'] = i
+ w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106A'
+ $floorItems2['106A'] = i
+ w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '105'
+ $floorItems2['105'] = i
+ w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106B'
+ $floorItems2['106B'] = i
+ w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '104'
+ $floorItems2['104'] = i
+ w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '108'
+ $floorItems2['108'] = i
+ w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '107'
+ $floorItems2['107'] = i
+ w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Smoking'
+ $floorItems2['Smoking'] = i
+ w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '123'
+ $floorItems2['123'] = i
+ w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '103'
+ $floorItems2['103'] = i
+ w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '124'
+ $floorItems2['124'] = i
+ w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '125'
+ $floorItems2['125'] = i
+ w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '126'
+ $floorItems2['126'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '127'
+ $floorItems2['127'] = i
+ w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'MShower'
+ $floorItems2['MShower'] = i
+ w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Closet'
+ $floorItems2['Closet'] = i
+ w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'WShower'
+ $floorItems2['WShower'] = i
+ w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '130'
+ $floorItems2['130'] = i
+ w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '102'
+ $floorItems2['102'] = i
+ w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '128'
+ $floorItems2['128'] = i
+ w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '129'
+ $floorItems2['129'] = i
+ w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '133'
+ $floorItems2['133'] = i
+ w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '132'
+ $floorItems2['132'] = i
+ w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '134'
+ $floorItems2['134'] = i
+ w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '135'
+ $floorItems2['135'] = i
+ w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Ramona Stair'
+ $floorItems2['Ramona Stair'] = i
+ w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'University Stair'
+ $floorItems2['University Stair'] = i
+ w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Stair'
+ $floorItems2['Plaza Stair'] = i
+ w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Deck'
+ $floorItems2['Plaza Deck'] = i
+ w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106'
+ $floorItems2['106'] = i
+ w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '119'
+ $floorItems2['119'] = i
+ w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor2_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '238'
+ $floorItems2['238'] = i
+ w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '237'
+ $floorItems2['237'] = i
+ w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '246'
+ $floorItems2['246'] = i
+ w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '247'
+ $floorItems2['247'] = i
+ w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '202'
+ $floorItems2['202'] = i
+ w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '206'
+ $floorItems2['206'] = i
+ w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '212'
+ $floorItems2['212'] = i
+ w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '245'
+ $floorItems2['245'] = i
+ w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '244'
+ $floorItems2['244'] = i
+ w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '243'
+ $floorItems2['243'] = i
+ w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '242'
+ $floorItems2['242'] = i
+ w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Barbecue Deck'
+ $floorItems2['Barbecue Deck'] = i
+ w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '240'
+ $floorItems2['240'] = i
+ w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '241'
+ $floorItems2['241'] = i
+ w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '239'
+ $floorItems2['239'] = i
+ w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '248'
+ $floorItems2['248'] = i
+ w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '236'
+ $floorItems2['236'] = i
+ w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '235'
+ $floorItems2['235'] = i
+ w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '234'
+ $floorItems2['234'] = i
+ w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '233'
+ $floorItems2['233'] = i
+ w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '230'
+ $floorItems2['230'] = i
+ w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '232'
+ $floorItems2['232'] = i
+ w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '229'
+ $floorItems2['229'] = i
+ w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '227'
+ $floorItems2['227'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '228'
+ $floorItems2['228'] = i
+ w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '226'
+ $floorItems2['226'] = i
+ w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '225'
+ $floorItems2['225'] = i
+ w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '224'
+ $floorItems2['224'] = i
+ w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '223'
+ $floorItems2['223'] = i
+ w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '222'
+ $floorItems2['222'] = i
+ w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '221'
+ $floorItems2['221'] = i
+ w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '204'
+ $floorItems2['204'] = i
+ w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '205'
+ $floorItems2['205'] = i
+ w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '207'
+ $floorItems2['207'] = i
+ w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '208'
+ $floorItems2['208'] = i
+ w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '209'
+ $floorItems2['209'] = i
+ w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217'
+ $floorItems2['217'] = i
+ w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217A'
+ $floorItems2['217A'] = i
+ w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '216'
+ $floorItems2['216'] = i
+ w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '215'
+ $floorItems2['215'] = i
+ w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '214'
+ $floorItems2['214'] = i
+ w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '213'
+ $floorItems2['213'] = i
+ w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '210'
+ $floorItems2['210'] = i
+ w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '211'
+ $floorItems2['211'] = i
+ w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '203'
+ $floorItems2['203'] = i
+ w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '220'
+ $floorItems2['220'] = i
+ w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Priv Lift2'
+ $floorItems2['Priv Lift2'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Pub Lift 2'
+ $floorItems2['Pub Lift 2'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '218'
+ $floorItems2['218'] = i
+ w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '219'
+ $floorItems2['219'] = i
+ w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '201'
+ $floorItems2['201'] = i
+ w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor2_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316'
+ $floorItems2['316'] = i
+ w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '309'
+ $floorItems2['309'] = i
+ w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '308'
+ $floorItems2['308'] = i
+ w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '307'
+ $floorItems2['307'] = i
+ w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '305'
+ $floorItems2['305'] = i
+ w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324B'
+ $floorItems2['324B'] = i
+ w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324A'
+ $floorItems2['324A'] = i
+ w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '320'
+ $floorItems2['320'] = i
+ w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '310'
+ $floorItems2['310'] = i
+ w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '312'
+ $floorItems2['312'] = i
+ w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '313'
+ $floorItems2['313'] = i
+ w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '314'
+ $floorItems2['314'] = i
+ w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '315'
+ $floorItems2['315'] = i
+ w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316B'
+ $floorItems2['316B'] = i
+ w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316A'
+ $floorItems2['316A'] = i
+ w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '319'
+ $floorItems2['319'] = i
+ w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '311'
+ $floorItems2['311'] = i
+ w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '318'
+ $floorItems2['318'] = i
+ w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '317'
+ $floorItems2['317'] = i
+ w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '323'
+ $floorItems2['323'] = i
+ w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '325'
+ $floorItems2['325'] = i
+ w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '321'
+ $floorItems2['321'] = i
+ w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '322'
+ $floorItems2['322'] = i
+ w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Pub Lift3'
+ $floorItems2['Pub Lift3'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Priv Lift3'
+ $floorItems2['Priv Lift3'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '303'
+ $floorItems2['303'] = i
+ w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324'
+ $floorItems2['324'] = i
+ w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '304'
+ $floorItems2['304'] = i
+ w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '301'
+ $floorItems2['301'] = i
+ w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '327'
+ $floorItems2['327'] = i
+ w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '326'
+ $floorItems2['326'] = i
+ w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '302'
+ $floorItems2['302'] = i
+ w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '306'
+ $floorItems2['306'] = i
+ w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget
+if defined?($floor2_demo) && $floor2_demo
+ $floor2_demo.destroy
+ $floor2_demo = nil
+end
+
+# demo toplevel widget
+$floor2_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration 2")
+ iconname("Floorplan2")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+# label
+TkLabel.new($floor2_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){
+ pack('side'=>'top')
+}
+
+# frame
+$floor2_buttons = TkFrame.new($floor2_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $floor2_demo
+ $floor2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'floor2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+#
+$floorLabels2 = {}
+$floorItems2 = {}
+
+# canvas
+if $tk_version =~ /^4\.[01]/
+ $floor2_canvas_frame = TkFrame.new($floor2_demo,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor2_canvas = TkCanvas.new($floor2_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new($floor2_demo, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new($floor2_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor2_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor2_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new($floor2_demo) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor2_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| c.yview(*args)})
+ h.command(proc{|*args| c.xview(*args)})
+ }
+end
+
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom2 = TkVariable.new
+$floor2_entry = TkEntry.new($floor2_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom2)
+
+# Choose colors, then fill in the floorplan.
+
+$floor2_colors = {}
+if TkWinfo.depth($floor2_canvas) > 1
+ $floor2_colors['bg1'] = '#a9c1da'
+ $floor2_colors['outline1'] = '#77889a'
+ $floor2_colors['bg2'] = '#9ab0c6'
+ $floor2_colors['outline2'] = '#687786'
+ $floor2_colors['bg3'] = '#8ba0b3'
+ $floor2_colors['outline3'] = '#596673'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = '#c4d1df'
+else
+ $floor2_colors['bg1'] = 'white'
+ $floor2_colors['outline1'] = 'black'
+ $floor2_colors['bg2'] = 'white'
+ $floor2_colors['outline2'] = 'black'
+ $floor2_colors['bg3'] = 'white'
+ $floor2_colors['outline3'] = 'black'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = 'black'
+end
+
+$activeFloor2 = ''
+floorDisplay2 $floor2_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor2_canvas.itembind('floor1', '1', proc{floorDisplay2 $floor2_canvas,1})
+$floor2_canvas.itembind('floor2', '1', proc{floorDisplay2 $floor2_canvas,2})
+$floor2_canvas.itembind('floor3', '1', proc{floorDisplay2 $floor2_canvas,3})
+$floor2_canvas.itembind('room', 'Enter', proc{newRoom2 $floor2_canvas})
+$floor2_canvas.itembind('room', 'Leave', proc{$currentRoom2.value = ''})
+$floor2_canvas.bind('2', proc{|x,y| $floor2_canvas.scan_mark x,y}, '%x %y')
+$floor2_canvas.bind('B2-Motion',
+ proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y')
+$floor2_canvas.bind('Destroy', proc{$currentRoom2.unset})
+$currentRoom2.value = ''
+$currentRoom2.trace('w',proc{roomChanged2 $floor2_canvas})
diff --git a/ext/tk/sample/demos-en/form.rb b/ext/tk/sample/demos-en/form.rb
new file mode 100644
index 0000000000..dbb14302dc
--- /dev/null
+++ b/ext/tk/sample/demos-en/form.rb
@@ -0,0 +1,62 @@
+#
+# form widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($form_demo) && $form_demo
+ $form_demo.destroy
+ $form_demo = nil
+end
+
+# demo toplevel widget
+$form_demo = TkToplevel.new {|w|
+ title("Form Demonstration")
+ iconname("form")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($form_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This window contains a simple form where you can type in the various entries and use tabs to move circularly between the entries."
+}
+msg.pack('side'=>'top', 'fill'=>'x')
+
+# frame
+TkFrame.new($form_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $form_demo
+ $form_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'form'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# entry
+form_data = []
+(1..5).each{|i|
+ f = TkFrame.new($form_demo, 'bd'=>2)
+ e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
+ l = TkLabel.new(f)
+ e.pack('side'=>'right')
+ l.pack('side'=>'left')
+ form_data[i] = {'frame'=>f, 'entry'=>e, 'label'=>l}
+}
+
+#
+form_data[1]['label'].text('Name:')
+form_data[2]['label'].text('Address:')
+form_data[5]['label'].text('Phone:')
+
+# pack
+(1..5).each{|i| form_data[i]['frame'].pack('side'=>'top', 'fill'=>'x')}
+
diff --git a/ext/tk/sample/demos-en/hello b/ext/tk/sample/demos-en/hello
new file mode 100644
index 0000000000..f06eabe518
--- /dev/null
+++ b/ext/tk/sample/demos-en/hello
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
+ require 'tkencoding'
+end
+
+TkButton.new(nil,
+ 'text'=>"Hello Ruby world!",
+ 'font'=>TkFont.new('k14'),
+ 'command'=>proc{print "Hello Ruby world!\n"; exit}
+).pack
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/hscale.rb b/ext/tk/sample/demos-en/hscale.rb
new file mode 100644
index 0000000000..14e395b61a
--- /dev/null
+++ b/ext/tk/sample/demos-en/hscale.rb
@@ -0,0 +1,74 @@
+require "tkcanvas"
+
+if defined?($hscale_demo) && $hscale_demo
+ $hscale_demo.destroy
+ $hscale_demo = nil
+end
+
+$hscale_demo = TkToplevel.new {|w|
+ title("Horizontal Scale Demonstration")
+ iconname("hscale")
+}
+positionWindow($hscale_demo)
+
+
+msg = TkLabel.new($hscale_demo) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+ text "An arrow and a horizontal scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the length of the arrow."
+}
+msg.pack('side'=>'top')
+
+TkFrame.new($hscale_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc {
+ tmppath = $hscale_demo
+ $hscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc { showCode 'hscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+TkFrame.new($hscale_demo) {|frame|
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, '0', '0', '1', '1', '2', '2') {
+ fill 'DeepSkyBlue'
+ tags 'poly'
+ }
+ TkcLine.new(c, '0', '0', '1', '1', '2', '2', '0', '0') {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'top', 'expand'=>'yes', 'anchor'=>'s', 'fill'=>'x', 'padx'=>'15')
+ scale = TkScale.new(frame) {
+ orient 'horizontal'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setWidth(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'bottom', 'expand'=>'yes', 'anchor'=>'n')
+ scale.set 75
+}.pack('side'=>'top', 'fill'=>'x')
+
+
+def setWidth(w, width)
+ width = width + 21
+ x2 = width - 30
+ if x2 < 21
+ x2 = 21
+ end
+ w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+ w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+end
diff --git a/ext/tk/sample/demos-en/icon.rb b/ext/tk/sample/demos-en/icon.rb
new file mode 100644
index 0000000000..58aca2df07
--- /dev/null
+++ b/ext/tk/sample/demos-en/icon.rb
@@ -0,0 +1,99 @@
+# icon.rb
+#
+# This demonstration script creates a toplevel window containing
+# buttons that display bitmaps instead of text.
+#
+# iconic button widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($icon_demo) && $icon_demo
+ $icon_demo.destroy
+ $icon_demo = nil
+end
+
+# demo toplevel widget
+$icon_demo = TkToplevel.new {|w|
+ title("Iconic Button Demonstration")
+ iconname("icon")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($icon_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "This window shows three ways of using bitmaps or images in radiobuttons and checkbuttons. On the left are two radiobuttons, each of which displays a bitmap and an indicator. In the middle is a checkbutton that displays a different image depending on whether it is selected or not. On the right is a checkbutton that displays a single bitmap but changes its background color to indicate whether or not it is selected. (This change is visible when the mouse pointer is not directy over the button.)"
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($icon_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $icon_demo
+ $icon_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'icon'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image
+flagup = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagup.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..','images','flagup.xbm'].join(File::Separator))
+flagdown = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator))
+
+# create variable
+letters = TkVariable.new
+
+# frame
+TkFrame.new($icon_demo, 'borderwidth'=>10){|w|
+ TkFrame.new(w) {|f|
+ TkRadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ variable letters
+ value 'full'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ TkRadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','noletter.xbm'].join(File::Separator)
+ variable letters
+ value 'empty'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ TkCheckButton.new(w) {
+ image flagdown
+ selectimage flagup
+ indicatoron 0
+ selectcolor self['background']
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ TkCheckButton.new(w) {
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ indicatoron 0
+ selectcolor 'SeaGreen1'
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+}.pack('side'=>'top')
+
diff --git a/ext/tk/sample/demos-en/image1.rb b/ext/tk/sample/demos-en/image1.rb
new file mode 100644
index 0000000000..05c9705c9c
--- /dev/null
+++ b/ext/tk/sample/demos-en/image1.rb
@@ -0,0 +1,60 @@
+## image1.rb
+#
+# This demonstration script displays two image widgets.
+#
+# two image widgets demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image1_demo) && $image1_demo
+ $image1_demo.destroy
+ $image1_demo = nil
+end
+
+# demo toplevel widget
+$image1_demo = TkToplevel.new {|w|
+ title('Image Demonstration #1')
+ iconname("Image1")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($image1_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This demonstration displays two images, each in a separate label widget."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($image1_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $image1_demo
+ $image1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'image1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image
+image1a = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earth.gif'].join(File::Separator))
+image1b = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earthris.gif'].join(File::Separator))
+
+# label
+[ TkLabel.new($image1_demo, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+ TkLabel.new($image1_demo, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+
diff --git a/ext/tk/sample/demos-en/image2.rb b/ext/tk/sample/demos-en/image2.rb
new file mode 100644
index 0000000000..1aff7173be
--- /dev/null
+++ b/ext/tk/sample/demos-en/image2.rb
@@ -0,0 +1,105 @@
+# image2.rb
+#
+# This demonstration script creates a simple collection of widgets
+# that allow you to select and view images in a Tk label.
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image2_demo) && $image2_demo
+ $image2_demo.destroy
+ $image2_demo = nil
+end
+
+# demo toplevel widget
+$image2_demo = TkToplevel.new {|w|
+ title('Image Demonstration #2')
+ iconname("Image2")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($image2_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This demonstration allows you to view images using a Tk \"photo\" image. First type a directory name in the listbox, then press Enter to load the directory into the listbox. Then double-click on a file name in the listbox to see that image."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($image2_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $image2_demo
+ $image2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'image2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# create variable
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image
+$image2a = TkPhotoImage.new
+
+#
+TkLabel.new($image2_demo, 'text'=>'Directory:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+image2_e = TkEntry.new($image2_demo) {
+ width 30
+ textvariable $dirName
+}.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20)\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkLabel.new($image2_demo, 'text'=>'File:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new($image2_demo){|w|
+ s = TkScrollbar.new(w)
+ l = TkListbox.new(w) {
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| l.yview(*args)})
+ l.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ s.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ #l.insert(0,'earth.gif', 'earthris.gif', 'mickey.gif', 'teapot.ppm')
+ l.insert(0,'earth.gif', 'earthris.gif', 'teapot.ppm')
+ l.bind('Double-1', proc{|x,y| loadImage $image2a,l,x,y}, '%x %y')
+
+ image2_e.bind 'Return', proc{loadDir l}
+
+}.pack('side'=>'top', 'anchor'=>'w')
+
+# image
+[ TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20),
+ TkLabel.new($image2_demo, 'text'=>'Image:'),
+ TkLabel.new($image2_demo, 'image'=>$image2a)
+].each{|w| w.pack('side'=>'top', 'anchor'=>'w')}
+
+#
+def loadDir(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+def loadImage(img,w,x,y)
+ img.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
diff --git a/ext/tk/sample/demos-en/image3.rb b/ext/tk/sample/demos-en/image3.rb
new file mode 100644
index 0000000000..d77cc0f99c
--- /dev/null
+++ b/ext/tk/sample/demos-en/image3.rb
@@ -0,0 +1,121 @@
+# image3.rb
+#
+# This demonstration script creates a simple collection of widgets
+# that allow you to select and view images in a Tk label.
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image3_demo) && $image3_demo
+ $image3_demo.destroy
+ $image3_demo = nil
+end
+
+# demo toplevel widget
+$image3_demo = TkToplevel.new {|w|
+ title('Image Demonstration #3')
+ iconname("Image3")
+ positionWindow(w)
+}
+
+#
+def loadDir(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+# selectAndLoadDir --
+# This procedure pops up a dialog to ask for a directory to load into
+# the listobx and (if the user presses OK) reloads the directory
+# listbox from the directory named in the demo's entry.
+#
+# Arguments:
+# w - Name of the toplevel window of the demo.
+def selectAndLoadDir(w, lbox)
+ dir = Tk.chooseDirectory(:initialdir=>$dirName, :parent=>w, :mustexist=>true)
+ if dir.length > 0
+ $dirName.value = dir
+ loadDir(lbox)
+ end
+end
+
+def loadImage(w,x,y)
+ $image3a.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
+
+# label
+msg = TkLabel.new($image3_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This demonstration allows you to view images using a Tk \"photo\" image. First type a directory name in the listbox, then type Return to load the directory into the listbox. Then double-click on a file name in the listbox to see that image."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($image3_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $image3_demo
+ $image3_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'image3'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# variable
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image
+begin
+ $image3a.delete
+rescue
+end
+$image3a = TkPhotoImage.new
+
+#
+image3_f = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+
+image3_df = TkLabelFrame.new($image3_demo, :text=>'Directory:')
+
+image3_ff = TkLabelFrame.new($image3_demo, :text=>'File:',
+ :padx=>'2m', :pady=>'2m')
+image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) {
+ pack(:side=>:left, :fill=>:y, :expand=>true)
+ yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y,
+ :expand=>true))
+ insert(0, *(%w(earth.gif earthris.gif teapot.ppm)))
+ bind('Double-1', proc{|x,y| loadImage(self, x, y)}, '%x %y')
+}
+
+image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){
+ pack(:side=>:left, :fill=>:both, :padx=>'2m', :pady=>'2m', :expand=>true)
+ bind('Return', proc{loadDir(image3_lbx)})
+}
+
+TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"Select Dir.",
+ :command=>proc{selectAndLoadDir(image3_ent, image3_lbx)}) {
+ pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m')
+}
+
+image3_if = TkLabelFrame.new($image3_demo, :text=>'Image:') {|f|
+ TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+}
+
+Tk.grid(image3_df, '-',
+ :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+Tk.grid(image3_ff, image3_if,
+ :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+TkGrid.columnconfigure(image3_f, 1, :weight=>1)
+
diff --git a/ext/tk/sample/demos-en/items.rb b/ext/tk/sample/demos-en/items.rb
new file mode 100644
index 0000000000..8ab7668a07
--- /dev/null
+++ b/ext/tk/sample/demos-en/items.rb
@@ -0,0 +1,374 @@
+# items.rb
+#
+# This demonstration script creates a canvas that displays the
+# canvas item types.
+#
+# canvas item types widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($items_demo) && $items_demo
+ $items_demo.destroy
+ $items_demo = nil
+end
+
+# demo toplevel widget
+$items_demo = TkToplevel.new {|w|
+ title("Canvas Item Demonstration")
+ iconname("Items")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($items_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "This window contains a canvas widget with examples of the various kinds of items supported by canvases. The following operations are supported:\n Button-1 drag:\tmoves item under pointer.\n Button-2 drag:\trepositions view.\n Button-3 drag:\tstrokes out area.\n Ctrl+f:\t\tprints items under area."
+}.pack('side'=>'top')
+
+# frame
+TkFrame.new($items_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $items_demo
+ $items_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'items'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+cvs = nil
+TkFrame.new($items_demo) {|cf|
+ # canvas
+ cvs = TkCanvas.new(cf) {|c|
+ focus
+ scrollregion '0c 0c 30c 24c'
+ width '15c'
+ height '10c'
+ relief 'sunken'
+ borderwidth 2
+
+ hs = TkScrollbar.new(cf) {|s|
+ orient 'horizontal'
+ command proc{|*args| c.xview(*args)}
+ c.xscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ vs = TkScrollbar.new(cf) {|s|
+ command proc{|*args| c.yview(*args)}
+ c.yscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ if $tk_version =~ /^4\.[01]/
+ hs.pack('side'=>'bottom', 'fill'=>'x')
+ vs.pack('side'=>'right', 'fill'=>'y')
+ c.pack('in'=>cf, 'expand'=>'yes', 'fill'=>'both')
+
+ else
+ c.grid('in'=>cf, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ hs.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+
+ end
+
+ }
+}.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+# Display a 3x3 rectangular grid
+TkcRectangle.new(cvs, '0c', '0c', '30c', '24c', 'width'=>2)
+TkcLine.new(cvs, '0c', '8c', '30c', '8c', 'width'=>2)
+TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2)
+TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2)
+TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2)
+
+font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+if TkWinfo.depth($root).to_i > 1
+ blue = 'DeepSkyBlue3'
+ red = 'red'
+ bisque = 'bisque3'
+ green = 'SeaGreen3'
+else
+ blue = 'black'
+ red = 'black'
+ bisque = 'black'
+ green = 'black'
+end
+
+# tag
+$tag_item = TkcGroup.new(cvs)
+
+# Set up demos within each of the areas of the grid.
+TkcText.new(cvs, '5c', '.2c', 'text'=>'Lines', 'anchor'=>'n')
+TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c',
+ 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt',
+ 'join'=>'miter', 'tags'=>$tag_item )
+TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item)
+TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item)
+TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c',
+ '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c',
+ '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c',
+ 'width'=>3, 'fill'=>red, 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c',
+ 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round',
+ 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '.2c',
+ 'text'=>'Curves (smoothed lines)', 'anchor'=>'n')
+TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c',
+ 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item )
+TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c',
+ 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item )
+TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c',
+ '16.5c','4.5c','13.5c','7.5c','12c','6c',
+ 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'fill'=>red, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '.2c', 'text'=>'Polygons', 'anchor'=>'n')
+TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c',
+ '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c',
+ 'fill'=>'green', 'outline'=>'black', 'width'=>4,
+ 'tags'=>$tag_item )
+TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c',
+ '28c','1c','29c','1c','29c','4c','29c','4c',
+ 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item)
+TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c',
+ '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c',
+ '7.5c','22c','7.5c',
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'outline'=>'black', 'tags'=>$tag_item )
+
+TkcText.new(cvs, '5c', '8.2c', 'text'=>'Rectangles', 'anchor'=>'n')
+TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '8.2c', 'text'=>'Ovals', 'anchor'=>'n')
+TkcOval.new(cvs, '11c','9.5c','14c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '8.2c', 'text'=>'Text', 'anchor'=>'n')
+TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c')
+TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c',
+ 'text'=>'A short string of text, word-wrapped, justified left, and anchored north (at the top). The rectangles show the anchor points for each piece of text.', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c')
+TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue,
+ 'text'=>"Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge.", 'justify'=>'center', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c')
+if $tk_version =~ /^4\.[01]/
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'grey.5'].join(File::Separator),
+ 'text'=>'Stippled characters', 'tags'=>$tag_item )
+else
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'gray50', 'text'=>'Stippled characters',
+ 'tags'=>$tag_item )
+end
+
+TkcText.new(cvs, '5c', '16.2c', 'text'=>'Arcs', 'anchor'=>'n')
+TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black',
+ 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item)
+#TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+# 'outline'=>blue, 'start'=>135, 'extent'=>270,
+# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+ 'outline'=>blue, 'start'=>135, 'extent'=>270,
+ 'outlinestipple'=>'@'+[$demo_dir, '..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice',
+ 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90,
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord',
+ 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270,
+ 'tags'=>$tag_item)
+
+TkcText.new(cvs, '15c', '16.2c', 'text'=>'Bitmaps', 'anchor'=>'n')
+#TkcBitmap.new(cvs, '13c','20c',
+# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '13c','20c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'face.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','18.5c',
+# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '17c','18.5c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'noletter.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','21.5c',
+# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator),
+# 'tags'=>$tag_item)
+#
+TkcBitmap.new(cvs, '17c','21.5c') {
+ bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator)
+ tags $tag_item
+}
+#TkcBitmap.new(cvs, '17c','21.5c') {
+# bitmap '@' + ['images', 'letters'].join(File::Separator)
+# tags $tag_item
+#}
+
+TkcText.new(cvs, '25c', '16.2c', 'text'=>'Windows', 'anchor'=>'n')
+TkButton.new(cvs) {|b|
+ text 'Press Me'
+ command proc{butPress cvs, red}
+ TkcWindow.new(cvs, '21c','18c',
+ 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e|
+ insert 'end', 'Edit this text'
+ TkcWindow.new(cvs, '21c','21c',
+ 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c',
+ 'width'=>'.5c', 'tickinterval'=>0 ) {|scl|
+ TkcWindow.new(cvs, '28.5c','17.5c',
+ 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item)
+}
+TkcText.new(cvs, '21c', '17.9c', 'text'=>'Button:', 'anchor'=>'sw')
+TkcText.new(cvs, '21c', '20.9c', 'text'=>'Entry:', 'anchor'=>'sw')
+TkcText.new(cvs, '28.5c', '17.4c', 'text'=>'Scale:', 'anchor'=>'s')
+
+# Set up event bindings for canvas:
+cvs.itembind($tag_item, 'Any-Enter', proc{itemEnter cvs})
+cvs.itembind($tag_item, 'Any-Leave', proc{itemLeave cvs})
+cvs.bind('2', proc{|x,y| cvs.scan_mark x,y}, '%x %y')
+cvs.bind('B2-Motion', proc{|x,y| cvs.scan_dragto x,y}, '%x %y')
+cvs.bind('3', proc{|x,y| itemMark cvs,x,y}, '%x %y')
+cvs.bind('B3-Motion', proc{|x,y| itemStroke cvs,x,y}, '%x %y')
+cvs.bind('Control-f', proc{itemsUnderArea cvs})
+cvs.bind('1', proc{|x,y| itemStartDrag cvs,x,y}, '%x %y')
+cvs.bind('B1-Motion', proc{|x,y| itemDrag cvs,x,y}, '%x %y')
+# Utility methods for highlighting the item under the pointer
+
+$restoreCmd = nil
+def itemEnter (c)
+ if TkWinfo.depth(c).to_i == 1
+ $restoreCmd = nil
+ return
+ end
+ type = c.itemtype('current')
+ if type == TkcWindow
+ $restoreCmd = nil
+ return
+ end
+ if type == TkcBitmap
+ bg = (c.itemconfiginfo('current', 'background'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'background', bg}
+ c.itemconfigure 'current', 'background', 'SteelBlue2'
+ return
+ end
+ fill = (c.itemconfiginfo('current', 'fill'))[4]
+ if (type == TkcRectangle || type == TkcOval || type == TkcArc) && fill == []
+ outline = (c.itemconfiginfo('current', 'outline'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'outline', outline}
+ c.itemconfigure 'current', 'outline', 'SteelBlue2'
+ else
+ $restoreCmd = proc{c.itemconfigure 'current', 'fill', fill}
+ c.itemconfigure 'current', 'fill', 'SteelBlue2'
+ end
+end
+
+def itemLeave(c)
+ $restoreCmd.call if $restoreCmd
+end
+
+# Utility methods for stroking out a rectangle and printing what's
+# underneath the rectangle's area.
+
+def itemMark(c,x,y)
+ $areaX1 = c.canvasx(x)
+ $areaY1 = c.canvasy(y)
+ c.delete 'area'
+end
+
+def itemStroke(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ if $areaX1 != x && $areaY1 != y
+ c.delete 'area'
+ c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y,
+ '-outline', 'black')
+ $areaX2 = x
+ $areaY2 = y
+ end
+end
+
+def itemsUnderArea(c)
+ area = c.find_withtag('area')
+ items = []
+ c.find_enclosed($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items enclosed by area: #{items.inspect}\n"; STDOUT.flush
+ items.clear
+ c.find_overlapping($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items overlapping area: #{items.inspect}\n"; STDOUT.flush
+end
+
+$areaX1 = 0
+$areaY1 = 0
+$areaX2 = 0
+$areaY2 = 0
+
+# Utility methods to support dragging of items.
+
+def itemStartDrag(c,x,y)
+ $lastX = c.canvasx(x)
+ $lastY = c.canvasy(y)
+end
+
+def itemDrag(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ c.move 'current', x - $lastX, y - $lastY
+ $lastX = x
+ $lastY = y
+end
+
+# Method that's invoked when the button embedded in the canvas
+# is invoked.
+
+def butPress(w,color)
+ i = TkcText.new(w, '25c', '18.1c',
+ 'text'=>'Ouch!!', 'fill'=>color, 'anchor'=>'n')
+ Tk.after(500, proc{w.delete i})
+end
diff --git a/ext/tk/sample/demos-en/ixset b/ext/tk/sample/demos-en/ixset
new file mode 100644
index 0000000000..979894fcb8
--- /dev/null
+++ b/ext/tk/sample/demos-en/ixset
@@ -0,0 +1,333 @@
+#!/usr/bin/env ruby
+
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ end
+
+ # apply is just "writesettings"
+
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length)
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left','expand'=>'y')
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken') {
+ pack('side'=>'left','expand'=>'y')
+ }
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ buttons = TkFrame.new(@root) {|f|
+ [ TkButton.new(f, 'command'=>proc{win.ok}, 'text'=>'Ok'),
+ TkButton.new(f, 'command'=>proc{win.writesettings}, 'text'=>'Apply'),
+ TkButton.new(f, 'command'=>proc{win.cancel}, 'text'=>'Cancel'),
+ TkButton.new(f, 'command'=>proc{win.quit}, 'text'=>'Quit') ].each{|b|
+ b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5)
+ }
+ }
+
+ #
+ # Bell settings
+ #
+ bell = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(bell, 'text'=>'Bell Settings')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"Volume (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6)
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "Duration (ms)", 6)
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ l.pack('side'=>'top', 'expand'=>'yes')
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(kbd, 'text'=>'Keyboard Repeat Settings')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'On', 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'Click Volume (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes')
+ l.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(mouse, 'text'=>'Mouse Settings')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, 'Acceleration', 3)
+ @w_mouseacc.pack('side'=>'left')
+ @w_mousethr = LabelEntry.new(f, 'Threshold (pixels)', 3)
+ @w_mousethr.pack('side'=>'right')
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(screen, 'text'=>'Screen-saver Settings')
+ f = TkFrame.new(screen)
+ ff1 = TkFrame.new(f)
+ [ @w_screenblank = TkRadioButton.new(ff1, 'text'=>'Blank',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ },
+ @w_screenpat = TkRadioButton.new(ff1, 'text'=>'Pattern',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+ ].each {|w| w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') }
+
+ ff2 = TkFrame.new(f)
+ [ @w_screentim = LabelEntry.new(ff2, 'Timeout (s)', 5),
+ @w_screencyc = LabelEntry.new(ff2, 'Cycle (s)', 5) ].each{|w|
+ w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'e')
+ }
+
+ ff1.pack('side'=>'left')
+ ff2.pack('side'=>'left')
+
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Main window
+ #
+ buttons.pack('side'=>'top', 'fill'=>'both')
+ bell.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ kbd.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ mouse.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ screen.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize
+ @root = TkRoot.new
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/ixset2 b/ext/tk/sample/demos-en/ixset2
new file mode 100644
index 0000000000..ce8472abe0
--- /dev/null
+++ b/ext/tk/sample/demos-en/ixset2
@@ -0,0 +1,367 @@
+#!/usr/bin/env ruby
+#
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ # apply is just "writesettings"
+ def apply
+ writesettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length, range=[])
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left')
+ if range.size > 0
+ @entry = TkSpinbox.new(@frame, 'width'=>length, 'relief'=>'sunken',
+ 'from'=>range[0], 'to'=>range[1])
+ else
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken')
+ end
+ @entry.pack('side'=>'right','expand'=>'y', 'fill'=>'x')
+ end
+ def epath
+ @frame
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ btn_frame = TkFrame.new(@root)
+ buttons = [
+ @btn_OK = TkButton.new(btn_frame, 'command'=>proc{win.ok},
+ 'default'=>'active', 'text'=>'Ok'),
+ @btn_APPLY = TkButton.new(btn_frame, 'command'=>proc{win.writesettings},
+ 'default'=>'normal', 'text'=>'Apply',
+ 'state'=>'disabled'),
+ @btn_CANCEL = TkButton.new(btn_frame, 'command'=>proc{win.cancel},
+ 'default'=>'normal', 'text'=>'Cancel',
+ 'state'=>'disabled'),
+ @btn_QUIT = TkButton.new(btn_frame, 'command'=>proc{win.quit},
+ 'default'=>'normal', 'text'=>'Quit')
+ ]
+ buttons.each{|b| b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5) }
+
+ @root.bind('Return', proc{@btn_OK.flash; @btn_OK.invoke})
+ @root.bind('Escape', proc{@btn_QUIT.flash; @btn_QUIT.invoke})
+ @root.bind('1', proc{|w|
+ unless buttons.index(w)
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ }, '%W')
+ @root.bind('Key', proc{|w, k|
+ unless buttons.index(w)
+ case k
+ when 'Return', 'Escape', 'Tab', /.*Shift.*/
+ # do nothing
+ else
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ end
+ }, '%W %K')
+
+ #
+ # Bell settings
+ #
+ bell = TkLabelframe.new(@root, 'text'=>'Bell Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"Volume (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6, [25, 20000])
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "Duration (ms)", 6, [1, 10000])
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkLabelframe.new(@root, 'text'=>'Keyboard Repeat Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'On', 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x', 'padx'=>[0, '1m'])
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'Click Volume (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes',
+ 'fill'=>'x', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkLabelframe.new(@root, 'text'=>'Mouse Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, 'Acceleration', 5)
+ @w_mouseacc.pack('side'=>'left', 'padx'=>[0, '1m'])
+ @w_mousethr = LabelEntry.new(f, 'Threshold (pixels)', 3, [1, 2000])
+ @w_mousethr.pack('side'=>'right', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkLabelframe.new(@root, 'text'=>'Screen-saver Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_screenblank = TkRadioButton.new(screen, 'text'=>'Blank',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screenpat = TkRadioButton.new(screen, 'text'=>'Pattern',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screentim = LabelEntry.new(screen, 'Timeout (s)', 5, [1, 100000])
+ @w_screencyc = LabelEntry.new(screen, 'Cycle (s)', 5, [1, 100000])
+
+ Tk.grid(@w_screenblank, @w_screentim, 'sticky'=>'e')
+ Tk.grid(@w_screenpat, @w_screencyc, 'sticky'=>'e')
+ TkGrid.configure(@w_screenblank, @w_screenpat, 'sticky'=>'ew')
+
+ #
+ # Main window
+ #
+ param = {
+ 'side'=>'top', 'fill'=>'both', 'expand'=>'yes',
+ 'padx'=>'1m', 'pady'=>'1m'
+ }
+ btn_frame.pack('side'=>'top', 'fill'=>'both')
+ bell.pack(param)
+ kbd.pack(param)
+ mouse.pack(param)
+ screen.pack(param)
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize(title)
+ @root = TkRoot.new('title'=>title)
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new(File.basename($0,'.rb'))
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/label.rb b/ext/tk/sample/demos-en/label.rb
new file mode 100644
index 0000000000..55e07a5ebc
--- /dev/null
+++ b/ext/tk/sample/demos-en/label.rb
@@ -0,0 +1,69 @@
+# label.rb
+#
+# This demonstration script creates a toplevel window containing
+# several label widgets.
+#
+# label widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($label_demo) && $label_demo
+ $label_demo.destroy
+ $label_demo = nil
+end
+
+# demo toplevel widget
+$label_demo = TkToplevel.new {|w|
+ title("Label Demonstration")
+ iconname("label")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($label_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Five labels are displayed below: three textual ones on the left, and a bitmap label and a text label on the right. Labels are pretty boring because you can't do anything with them."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($label_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $label_demo
+ $label_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'label'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# label demo
+f_left = TkFrame.new($label_demo)
+f_right = TkFrame.new($label_demo)
+[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes',
+ 'padx'=>10, 'pady'=>10, 'fill'=>'both')}
+
+# label
+[ TkLabel.new(f_left, 'text'=>'First label'),
+ TkLabel.new(f_left, 'text'=>'Second label, raised',
+ 'relief'=>'raised'),
+ TkLabel.new(f_left, 'text'=>'Third label, sunken', 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')}
+
+TkLabel.new(f_right) {
+ bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator))
+ borderwidth 2
+ relief 'sunken'
+}.pack('side'=>'top')
+
+TkLabel.new(f_right) { text 'Tcl/Tk Proprietor' }.pack('side'=>'top')
+
diff --git a/ext/tk/sample/demos-en/labelframe.rb b/ext/tk/sample/demos-en/labelframe.rb
new file mode 100644
index 0000000000..842a4f6c04
--- /dev/null
+++ b/ext/tk/sample/demos-en/labelframe.rb
@@ -0,0 +1,93 @@
+# labelframe.rb
+#
+# This demonstration script creates a toplevel window containing
+# several labelframe widgets.
+#
+# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp"
+
+
+if defined?($labelframe_demo) && $labelframe_demo
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+end
+
+$labelframe_demo = TkToplevel.new {|w|
+ title("Labelframe Demonstration")
+ iconname("labelframe")
+ positionWindow(w)
+}
+
+# Some information
+TkLabel.new($labelframe_demo,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+Labelframes are used to group related widgets together. \
+The label may be either plain text or another widget. \
+If your Tk library linked to Ruby doesn't include a 'labelframe' widget, \
+this demo doesn't work. Please use later version of Tk \
+which supports a 'labelframe' widget.
+EOL
+
+# The bottom buttons
+TkFrame.new($labelframe_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'labelframe'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# Demo area
+w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both,
+ :expand=>true)
+
+# A group of radiobuttons in a labelframe
+TkLabelFrame.new(w, :text=>'Value',
+ :padx=>2, :pady=>2) {|f|
+ grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m')
+
+ v = TkVariable.new
+ (1..4).each{|i|
+ TkRadiobutton.new(f, :text=>"This is value #{i}",
+ :variable=>v, :value=>i) {
+ pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+ }
+}
+
+
+# Using a label window to control a group of options.
+$lfdummy = TkVariable.new(0)
+
+def lfEnableButtons(w)
+ TkWinfo.children(w).each{|child|
+ next if child.path =~ /\.cb$/
+ if $lfdummy == 1
+ child.state(:normal)
+ else
+ child.state(:disabled)
+ end
+ }
+end
+
+TkLabelFrame.new(w, :pady=>2, :padx=>2){|f|
+ TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy,
+ :text=>"Use this option.", :padx=>0) {|cb|
+ command proc{lfEnableButtons(f)}
+ f.labelwidget(cb)
+ }
+ grid(:row=>0, :column=>1, :pady=>'2m', :padx=>'2m')
+
+ %w(Option1 Option2 Option3).each{|str|
+ TkCheckbutton.new(f, :text=>str).pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+
+ lfEnableButtons(f)
+}
+
+TkGrid.columnconfigure(w, [0,1], :weight=>1)
diff --git a/ext/tk/sample/demos-en/menu.rb b/ext/tk/sample/demos-en/menu.rb
new file mode 100644
index 0000000000..d835d145eb
--- /dev/null
+++ b/ext/tk/sample/demos-en/menu.rb
@@ -0,0 +1,186 @@
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($menu_demo) && $menu_demo
+ $menu_demo.destroy
+ $menu_demo = nil
+end
+
+# demo toplevel widget
+$menu_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu")
+ positionWindow(w)
+}
+
+# menu frame
+$menu_frame = TkFrame.new($menu_demo, 'relief'=>'raised', 'bd'=>2)
+$menu_frame.pack('side'=>'top', 'fill'=>'x')
+
+# label
+TkLabel.new($menu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh'
+ text("This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse.")
+ else
+ text("This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu.")
+ end
+}.pack('side'=>'top')
+
+# frame
+TkFrame.new($menu_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $menu_demo
+ $menu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'menu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# menu
+TkMenubutton.new($menu_frame, 'text'=>'File', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|file_menu|
+ m.configure('menu'=>file_menu)
+ add('command', 'label'=>'Open...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Open..." entry'})
+ add('command', 'label'=>'New', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "New" entry'})
+ add('command', 'label'=>'Save', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save" entry'})
+ add('command', 'label'=>'Save As...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save As..." entry'})
+ add('separator')
+ add('command', 'label'=>'Print Setup...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print Setup..." entry'})
+ add('command', 'label'=>'Print...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print..." entry'})
+ add('separator')
+ add('command', 'label'=>'Dismiss Menus Demo', 'command'=>proc{$menu_demo.destroy})
+ }
+}
+
+if $tk_platform['platform'] == 'macintosh'
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenubutton.new($menu_frame, 'text'=>'Basic', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|basic_menu|
+ m.configure('menu'=>basic_menu)
+ add('command', 'label'=>'Long entry that does nothing')
+ ['A','B','C','D','E','F','G'].each{|c|
+ add('command', 'label'=>"Print letter \"#{c}\"",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_menu|
+ m.configure('menu'=>cascade_menu)
+ add('command', 'label'=>'Print hello',
+ 'command'=>proc{print "Hello\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-h", proc{print "Hello\n"})
+ add('command', 'label'=>'Print goodbye',
+ 'command'=>proc{print "Goodbye\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-g", proc{print "Goodbye\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ cascade_menu.add('cascade', 'label'=>'Check buttons',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'Oil checked', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'Transmission checked', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'Brakes checked', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'Lights checked', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu_demo,
+ ['oil', oil],
+ ['trans', trans],
+ ['brakes', brakes],
+ ['lights', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ cascade_menu.add('cascade', 'label'=>'Radio buttons',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 point', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 point', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 point', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'Roman', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'Bold', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu_demo,
+ ['pointSize', pointSize],
+ ['style', style])} )
+ invoke 1
+ invoke 7
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
+ m.configure('menu'=>icon_menu)
+ add('command',
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'Dismiss')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'More', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|more_menu|
+ m.configure('menu'=>more_menu)
+ [ 'An entry','Another entry','Does nothing','Does almost nothing',
+ 'Make life meaningful' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Colors', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m) {|colors_menu|
+ m.configure('menu'=>colors_menu)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+ }
+}
diff --git a/ext/tk/sample/demos-en/menu84.rb b/ext/tk/sample/demos-en/menu84.rb
new file mode 100644
index 0000000000..cb616d8461
--- /dev/null
+++ b/ext/tk/sample/demos-en/menu84.rb
@@ -0,0 +1,213 @@
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($menu84_demo) && $menu84_demo
+ $menu84_demo.destroy
+ $menu84_demo = nil
+end
+
+# demo toplevel widget
+$menu84_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu84")
+ positionWindow(w)
+}
+
+begin
+ windowingsystem = Tk.windowingsystem()
+rescue
+ windowingsystem = ""
+end
+
+# label
+TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ text("This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse.")
+ else
+ text("This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu.")
+ end
+}.pack('side'=>'top')
+
+
+menustatus = TkVariable.new(" ")
+TkFrame.new($menu84_demo) {|frame|
+ TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken',
+ 'bd'=>1, 'font'=>['Helvetica', '10'],
+ 'anchor'=>'w').pack('side'=>'left', 'padx'=>2,
+ 'expand'=>true, 'fill'=>'both')
+ pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+}
+
+
+# frame
+TkFrame.new($menu84_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $menu84_demo
+ $menu84_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'menu84'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# create menu frame
+$menu84_frame = TkMenu.new($menu84_demo, 'tearoff'=>false)
+
+# menu
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'File', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Open...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Open..." entry'})
+ add('command', 'label'=>'New', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "New" entry'})
+ add('command', 'label'=>'Save', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save" entry'})
+ add('command', 'label'=>'Save As...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save As..." entry'})
+ add('separator')
+ add('command', 'label'=>'Print Setup...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print Setup..." entry'})
+ add('command', 'label'=>'Print...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print..." entry'})
+ add('separator')
+ add('command', 'label'=>'Dismiss Menus Demo', 'command'=>proc{$menu84_demo.destroy})
+}
+
+if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem = "classic" || windowingsystem = "aqua"
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Basic', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Long entry that does nothing')
+ ['A','B','C','D','E','F','G'].each{|c|
+ add('command', 'label'=>"Print letter \"#{c}\"",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu84_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Cascades', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Print hello',
+ 'command'=>proc{print "Hello\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-h", proc{print "Hello\n"})
+ add('command', 'label'=>'Print goodbye',
+ 'command'=>proc{print "Goodbye\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-g", proc{print "Goodbye\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ m.add('cascade', 'label'=>'Check buttons',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'Oil checked', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'Transmission checked', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'Brakes checked', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'Lights checked', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu84_demo,
+ ['oil', oil],
+ ['trans', trans],
+ ['brakes', brakes],
+ ['lights', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ m.add('cascade', 'label'=>'Radio buttons',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 point', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 point', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 point', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'Roman', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'Bold', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu84_demo,
+ ['pointSize', pointSize],
+ ['style', style])} )
+ invoke 1
+ invoke 7
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0)
+ add('command', 'hidemargin'=>1,
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'Dismiss')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon, 'hidemargin'=>1,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+
+ entryconfigure(2, :columnbreak=>true)
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'More', 'menu'=>m, 'underline'=>0)
+ [ 'An entry','Another entry','Does nothing','Does almost nothing',
+ 'Make life meaningful' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+
+ m.entryconfigure('Does almost nothing',
+ 'bitmap'=>'questhead', 'compound'=>'left',
+ 'command'=>proc{
+ TkDialog.new('title'=>'Compound Menu Entry',
+ 'message'=>'The menu entry you invoked'+
+ 'displays both a bitmap and '+
+ 'a text string. Other than '+
+ 'this, it isjust like any '+
+ 'other menu entry.',
+ 'buttons'=>['OK'], 'bitmap'=>'')
+ })
+}
+
+TkMenu.new($menu84_frame) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Colors', 'menu'=>m, 'underline'=>0)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+}
+
+$menu84_demo.menu($menu84_frame)
+
+TkMenu.bind('<MenuSelect>', proc{|w|
+ begin
+ label = w.entrycget('active', 'label')
+ rescue
+ label = " "
+ end
+ menustatus.value = label
+ Tk.update(true)
+ }, '%W')
diff --git a/ext/tk/sample/demos-en/menubu.rb b/ext/tk/sample/demos-en/menubu.rb
new file mode 100644
index 0000000000..e2ddd07bc6
--- /dev/null
+++ b/ext/tk/sample/demos-en/menubu.rb
@@ -0,0 +1,235 @@
+# menubutton.rb
+#
+# This demonstration script creates a window with a bunch of menus
+# and cascaded menus using menubuttons.
+
+require "tkcanvas"
+
+def optionMenu(menubutton, varName, firstValue, *rest)
+ varName.value = firstValue
+ configoptions = {'textvariable'=>varName,'indicatoron'=>'on',
+ 'relief'=>'raised','borderwidth'=>2,'highlightthickness'=>2,
+ 'anchor'=>'c','direction'=>'flush'}
+ configoptions.each {|key, value|
+ menubutton.configure(key, value)
+ }
+ menu = TkMenu.new(menubutton) {
+ tearoff 'off'
+ add 'radio', 'label'=>firstValue, 'variable'=>varName
+ }
+ menubutton.menu(menu)
+ for i in rest
+ menu.add 'radio', 'label'=>i, 'variable'=>varName
+ end
+
+ return menu
+end
+
+if defined?($menubu_demo) && $menubu_demo
+ $menubu_demo.destroy
+ $menubu_demo = nil
+end
+
+$menubu_demo = TkToplevel.new {|w|
+ title("Menu Button Demonstration")
+ iconname("menubutton")
+}
+
+positionWindow($menubu_demo)
+
+# version check
+if $tk_version.to_f < 8.0
+
+# label
+TkLabel.new($menubu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ text("This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette.")
+}.pack('side'=>'top')
+
+# frame
+TkFrame.new($menubu_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'menubu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+else ; # Tk8.x
+
+body = TkFrame.new($menubu_demo)
+body.pack('expand'=>'yes', 'fill'=>'both')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+right = TkMenubutton.new(body) {
+ text "Right"
+ underline 0
+ direction 'right'
+ relief 'raised'
+}
+rightMenu = TkMenu.new(right) {
+ tearoff 0
+ add 'command', 'label'=>"Right menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Right menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Right menu.\""}
+}
+right.menu(rightMenu)
+right.grid('row'=>1, 'column'=>0, 'sticky'=>'w')
+
+left = TkMenubutton.new(body) {
+ text "Left"
+ underline 0
+ direction 'left'
+ relief 'raised'
+}
+leftMenu = TkMenu.new(left) {
+ tearoff 0
+ add 'command', 'label'=>"Left menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Left menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Left menu.\""}
+}
+left.menu(leftMenu)
+left.grid('row'=>1, 'column'=>2, 'sticky'=>'e')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+above = TkMenubutton.new(body) {
+ text "Above"
+ underline 0
+ direction 'above'
+ relief 'raised'
+}
+aboveMenu = TkMenu.new(above) {
+ tearoff 0
+ add 'command', 'label'=>"Above menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Above menu.\""}
+ add 'command', 'label'=>"Above menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Above menu.\""}
+}
+above.menu(aboveMenu)
+above.grid('row'=>2, 'column'=>1, 'sticky'=>'s')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+TkFrame.new($menubu_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc {
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc { showCode 'menubu' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x', 'pady'=>'2m')
+
+msg = TkLabel.new(center) {
+# font $font
+ wraplength '4i'
+ justify 'left'
+ text "This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette."
+}
+msg.pack('side'=>'top', 'padx'=>25, 'pady'=>25)
+
+TkFrame.new(center) {|f|
+ menubuttonoptions = TkVariable.new
+ mbutton = TkMenubutton.new(f)
+ options = optionMenu(mbutton, menubuttonoptions,
+ 'one', 'two', 'three')
+ mbutton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ paletteColor = TkVariable.new
+ colors = ['Black','red4','DarkGreen','NavyBlue', 'gray75',
+ 'Red','Green','Blue','gray50','Yellow','Cyan','Magenta',
+ 'White','Brown','DarkSeaGreen','DarkViolet']
+ colorMenuButton = TkMenubutton.new(f)
+ m = optionMenu(colorMenuButton, paletteColor, *colors)
+ begin
+ windowingsystem = Tk.windowingsystem()
+ rescue
+ windowingsystem = ""
+ end
+ if windowingsystem == "classic" || windowingsystem == "aqua"
+ topBorderColor = 'Black'
+ bottomBorderColor = 'Black'
+ else
+ topBorderColor = 'gray50'
+ bottomBorderColor = 'gray75'
+ end
+ for i in 0..15
+ image = TkPhotoImage.new('height'=>16, 'width'=>16)
+ image.put(topBorderColor, 0, 0, 16, 1)
+ image.put(topBorderColor, 0, 1, 1, 16)
+ image.put(bottomBorderColor, 0, 15, 16, 16)
+ image.put(bottomBorderColor, 15, 1, 16, 16)
+ image.put(colors[i], 1, 1, 15, 15)
+
+ selectimage = TkPhotoImage.new('height'=>16, 'width'=>16)
+ selectimage.put('Black', 0, 0, 16, 2)
+ selectimage.put('Black', 0, 2, 2, 16)
+ selectimage.put('Black', 2, 14, 16, 16)
+ selectimage.put('Black', 14, 2, 16, 14)
+ selectimage.put(colors[i], 2, 2, 14, 14)
+
+ m.entryconfigure(i, 'image'=>image, 'selectimage'=>selectimage, 'hidemargin'=>'on')
+ end
+ m.configure('tearoff', 'on')
+ for c in ['Black', 'gray75', 'gray50', 'White']
+ m.entryconfigure(c, 'columnbreak'=>1)
+ end
+ colorMenuButton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ pack 'padx'=>25, 'pady'=>25
+}
+
+end ; # Tk8.x
diff --git a/ext/tk/sample/demos-en/msgbox.rb b/ext/tk/sample/demos-en/msgbox.rb
new file mode 100644
index 0000000000..aab1b619cf
--- /dev/null
+++ b/ext/tk/sample/demos-en/msgbox.rb
@@ -0,0 +1,88 @@
+# msgbox.rb
+#
+# This demonstration script creates message boxes of various type
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($msgbox_demo) && $msgbox_demo
+ $msgbox_demo.destroy
+ $msgbox_demo = nil
+end
+
+# demo toplevel widget
+$msgbox_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($msgbox_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box.").pack('side'=>'top')
+
+# frame
+TkFrame.new($msgbox_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $msgbox_demo
+ $msgbox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'msgbox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Message Box'
+ command proc{showMessageBox $msgbox_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$msgbox_leftframe = TkFrame.new($msgbox_demo)
+$msgbox_rightframe = TkFrame.new($msgbox_demo)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'Icon').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'Type').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"This is a \"#{$msgboxType.value}\" type messagebox with the \"#{$msgboxIcon.value}\" icon")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"You have selected \"#{button}\"")
+end
+
diff --git a/ext/tk/sample/demos-en/paned1.rb b/ext/tk/sample/demos-en/paned1.rb
new file mode 100644
index 0000000000..48ba86de02
--- /dev/null
+++ b/ext/tk/sample/demos-en/paned1.rb
@@ -0,0 +1,45 @@
+# paned1.rb
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows horizontally.
+#
+# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned1_demo) && $paned1_demo
+ $paned1_demo.destroy
+ $paned1_demo = nil
+end
+
+$paned1_demo = TkToplevel.new {|w|
+ title("Horizontal Paned Window Demonstration")
+ iconname("paned1")
+ positionWindow(w)
+}
+
+TkLabel.new($paned1_demo,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
+If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'.
+EOL
+
+# The bottom buttons
+TkFrame.new($paned1_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $paned1_demo.destroy
+ $paned1_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'paned1'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+TkPanedwindow.new($paned1_demo){|f|
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+
+ add(TkLabel.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
+ TkLabel.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
+}
diff --git a/ext/tk/sample/demos-en/paned2.rb b/ext/tk/sample/demos-en/paned2.rb
new file mode 100644
index 0000000000..5911cadab6
--- /dev/null
+++ b/ext/tk/sample/demos-en/paned2.rb
@@ -0,0 +1,92 @@
+# paned2.rb --
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows vertically.
+#
+# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned2_demo) && $paned2_demo
+ $paned2_demo.destroy
+ $paned2_demo = nil
+end
+
+$paned2_demo = TkToplevel.new {|w|
+ title("Vertical Paned Window Demonstration")
+ iconname("paned2")
+ positionWindow(w)
+}
+
+TkLabel.new($paned2_demo,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
+If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'.
+EOL
+
+# The bottom buttons
+TkFrame.new($paned2_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $paned2_demo.destroy
+ $paned2_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'paned2'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+paneList = TkVariable.new # define as normal variable (not array)
+paneList.value = [ # ruby's array --> tcl's list
+ 'List of Ruby/Tk Widgets',
+ 'TkButton',
+ 'TkCanvas',
+ 'TkCheckbutton',
+ 'TkEntry',
+ 'TkFrame',
+ 'TkLabel',
+ 'TkLabelframe',
+ 'TkListbox',
+ 'TkMenu',
+ 'TkMenubutton',
+ 'TkMessage',
+ 'TkPanedwindow',
+ 'TkRadiobutton',
+ 'TkScale',
+ 'TkScrollbar',
+ 'TkSpinbox',
+ 'TkText',
+ 'TkToplevel'
+]
+
+# Create the pane itself
+TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+
+ add(TkFrame.new(f){|paned2_top|
+ TkListbox.new(paned2_top, :listvariable=>paneList) {
+ # Invert the first item to highlight it
+ itemconfigure(0, :background=>self.cget(:foreground),
+ :foreground=>self.cget(:background) )
+ yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right,
+ :fill=>:y))
+ pack(:fill=>:both, :expand=>true)
+ }
+ },
+
+ TkFrame.new(f, :height=>120) {|paned2_bottom|
+ # The bottom window is a text widget with scrollbar
+ paned2_xscr = TkScrollbar.new(paned2_bottom)
+ paned2_yscr = TkScrollbar.new(paned2_bottom)
+ paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
+ insert('1.0', "This is just a normal text widget")
+ xscrollbar(paned2_xscr)
+ yscrollbar(paned2_yscr)
+ }
+ Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
+ Tk.grid(paned2_xscr, :sticky=>'nsew')
+ TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
+ TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
+ } )
+}
diff --git a/ext/tk/sample/demos-en/patch_1.1c1 b/ext/tk/sample/demos-en/patch_1.1c1
new file mode 100644
index 0000000000..d3952e71eb
--- /dev/null
+++ b/ext/tk/sample/demos-en/patch_1.1c1
@@ -0,0 +1,93 @@
+--- /usr/src/ruby-1.1c1/lib/tkcanvas.rb Tue Jul 21 18:18:02 1998
++++ tkcanvas.rb Fri Jul 24 20:38:24 1998
+@@ -310,7 +310,7 @@
+ || key == 'latinfont' || key == 'asciifont' )
+ tagfont_configure(tagid(tagOrId), {key=>value})
+ else
+- tk_call 'itemconfigure', tagid(tagOrId), "-#{key}", value
++ tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
+ end
+ end
+ end
+--- /usr/src/ruby-1.1c1/lib/tkfont.rb Fri Jul 17 23:43:28 1998
++++ tkfont.rb Fri Jul 24 17:46:22 1998
+@@ -42,7 +42,7 @@
+ r | []
+
+ when /^8\.*/
+- list(tk_call('font', 'names'))
++ tk_split_simplelist(tk_call('font', 'names'))
+
+ end
+ end
+@@ -89,10 +89,14 @@
+ if fnt == []
+ TkFont.new(nil, nil).call_font_configure(path, *(args + [{}]))
+ else
+- compound = Hash[*list(tk_call('font', 'configure',
+- fnt))].collect{|key,value|
+- [key[1..-1], value]
+- }.assoc('compound')[1]
++ begin
++ compound = Hash[*list(tk_call('font', 'configure',
++ fnt))].collect{|key,value|
++ [key[1..-1], value]
++ }.assoc('compound')[1]
++ rescue
++ compound = []
++ end
+ if compound == []
+ TkFont.new(fnt, DEFAULT_KANJI_FONT_NAME) \
+ .call_font_configure(path, *(args + [{}]))
+@@ -156,14 +160,19 @@
+ elsif font.kind_of? Array
+ finfo = {}
+ finfo['family'] = font[0].to_s
+- if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/
+- if $1 == '-'
+- finfo['pixels'] = font[1].to_s
++ if font[1]
++ fsize = font[1].to_s
++ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
++ if $1 == '-'
++ finfo['pixels'] = $2
++ else
++ finfo['points'] = $2
++ end
+ else
+- finfo['points'] = font[1].to_s
++ finfo['points'] = '13'
+ end
+ end
+- finfo[2..-1].each{|style|
++ font[2..-1].each{|style|
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
+@@ -199,16 +208,19 @@
+ elsif font.kind_of? Array
+ finfo = {}
+ finfo['family'] = font[0].to_s
+- if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/
+- if $1 == '-'
+- finfo['pixels'] = $2
++ if font[1]
++ fsize = font[1].to_s
++ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
++ if $1 == '-'
++ finfo['pixels'] = $2
++ else
++ finfo['points'] = $2
++ end
+ else
+- finfo['points'] = $2
++ finfo['points'] = '13'
+ end
+- else
+- finfo['points'] = '13'
+ end
+- finfo[2..-1].each{|style|
++ font[2..-1].each{|style|
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
diff --git a/ext/tk/sample/demos-en/plot.rb b/ext/tk/sample/demos-en/plot.rb
new file mode 100644
index 0000000000..6d01deeef5
--- /dev/null
+++ b/ext/tk/sample/demos-en/plot.rb
@@ -0,0 +1,122 @@
+# plot.rb
+#
+# This demonstration script creates a canvas widget showing a 2-D
+# plot with data points that can be dragged with the mouse.
+#
+# 2-D plot widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($plot_demo) && $plot_demo
+ $plot_demo.destroy
+ $plot_demo = nil
+end
+
+# demo toplevel widget
+$plot_demo = TkToplevel.new {|w|
+ title("Plot Demonstration")
+ iconname("Plot")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($plot_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"This window displays a canvas widget containing a simple 2-dimensional plot. You can doctor the data by dragging any of the points with mouse button 1."){
+ pack('side'=>'top')
+}
+
+# frame
+$plot_buttons = TkFrame.new($plot_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $plot_demo
+ $plot_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'plot'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$plot_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# font
+plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+
+# canvas
+$plot_canvas = TkCanvas.new($plot_demo,'relief'=>'raised','width'=>450,'height'=>300)
+$plot_canvas.pack('side'=>'top', 'fill'=>'x')
+
+# plot
+TkcLine.new($plot_canvas, 100, 250, 400, 250, 'width'=>2)
+TkcLine.new($plot_canvas, 100, 250, 100, 50, 'width'=>2)
+TkcText.new($plot_canvas, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>plotFont, 'fill'=>'brown')
+
+(0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($plot_canvas, x, 250, x, 245, 'width'=>2)
+ TkcText.new($plot_canvas, x, 254,
+ 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n')
+}
+(0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($plot_canvas, 100, y, 105, y, 'width'=>2)
+ TkcText.new($plot_canvas, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e')
+}
+
+for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($plot_canvas, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+end
+
+$plot_canvas.itembind('point', 'Any-Enter',
+ proc{$plot_canvas.itemconfigure 'current','fill','red'})
+$plot_canvas.itembind('point', 'Any-Leave',
+ proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'})
+$plot_canvas.itembind('point', '1',
+ proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y")
+$plot_canvas.itembind('point', 'ButtonRelease-1',
+ proc{$plot_canvas.dtag 'selected'})
+$plot_canvas.bind('B1-Motion',
+ proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y")
+
+$plot = {'lastX'=>0, 'lastY'=>0}
+
+# plotDown --
+# This method is invoked when the mouse is pressed over one of the
+# data points. It sets up state to allow the point to be dragged.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse press.
+
+def plotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
+# plotMove --
+# This method is invoked during mouse motion events. It drags the
+# current item.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse.
+
+def plotMove (w, x, y)
+ w.move 'selected', x - $plot['lastX'], y - $plot['lastY']
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
diff --git a/ext/tk/sample/demos-en/puzzle.rb b/ext/tk/sample/demos-en/puzzle.rb
new file mode 100644
index 0000000000..0885cf2975
--- /dev/null
+++ b/ext/tk/sample/demos-en/puzzle.rb
@@ -0,0 +1,120 @@
+# puzzle.rb
+#
+# This demonstration script creates a 15-puzzle game using a collection
+# of buttons.
+#
+# widet demo 'puzzle' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($puzzle_demo) && $puzzle_demo
+ $puzzle_demo.destroy
+ $puzzle_demo = nil
+end
+
+# demo toplevel widget
+$puzzle_demo = TkToplevel.new {|w|
+ title("15-Puzzle Demonstration")
+ iconname("15-Puzzle")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($puzzle_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "A 15-puzzle appears below as a collection of buttons. Click on any of the pieces next to the space, and that piece will slide over the space. Continue this until the pieces are arranged in numerical order from upper-left to lower-right."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($puzzle_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $puzzle_demo
+ $puzzle_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'puzzle'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+
+# Special trick: select a darker color for the space by creating a
+# scrollbar widget and using its trough color.
+begin
+ if Tk.windowingsystem() == 'aqua'
+ frameSize = 160
+ else
+ frameSize = 120
+ end
+rescue
+ frameSize = 120
+end
+
+s = TkScrollbar.new($puzzle_demo)
+base = TkFrame.new($puzzle_demo) {
+ width frameSize
+ height frameSize
+ borderwidth 2
+ relief 'sunken'
+ bg s['troughcolor']
+}
+s.destroy
+base.pack('side'=>'top', 'padx'=>'1c', 'pady'=>'1c')
+
+def def_puzzleswitch_proc(w, num)
+ proc{puzzleSwitch w, num}
+end
+
+$xpos = {}
+$ypos = {}
+order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12]
+(0..14).each{|i|
+ num = order[i]
+ $xpos[num] = (i % 4) * 0.25
+ $ypos[num] = (i / 4) * 0.25
+ TkButton.new(base) {|w|
+ relief 'raised'
+ text num
+ highlightthickness 0
+ command def_puzzleswitch_proc(w, num)
+ }.place('relx'=>$xpos[num], 'rely'=>$ypos[num],
+ 'relwidth'=>0.25, 'relheight'=>0.25)
+}
+$xpos['space'] = 0.75
+$ypos['space'] = 0.75
+
+
+# puzzleSwitch --
+# This procedure is invoked when the user clicks on a particular button;
+# if the button is next to the empty space, it moves the button into the
+# empty space.
+
+def puzzleSwitch(w, num)
+ if ( ($ypos[num] >= ($ypos['space'] - 0.01)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.01)) \
+ && ($xpos[num] >= ($xpos['space'] - 0.26)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.26))) \
+ || (($xpos[num] >= ($xpos['space'] - 0.01)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.01)) \
+ && ($ypos[num] >= ($ypos['space'] - 0.26)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.26)))
+ tmp = $xpos['space']
+ $xpos['space'] = $xpos[num]
+ $xpos[num] = tmp
+ tmp = $ypos['space']
+ $ypos['space'] = $ypos[num]
+ $ypos[num] = tmp
+ w.place('relx'=>$xpos[num], 'rely'=>$ypos[num])
+ end
+end
+
diff --git a/ext/tk/sample/demos-en/radio.rb b/ext/tk/sample/demos-en/radio.rb
new file mode 100644
index 0000000000..96cdc4c54a
--- /dev/null
+++ b/ext/tk/sample/demos-en/radio.rb
@@ -0,0 +1,84 @@
+# radio.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio_demo) && $radio_demo
+ $radio_demo.destroy
+ $radio_demo = nil
+end
+
+# demo toplevel widget
+$radio_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration")
+ iconname("radio")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($radio_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Two groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+#
+size = TkVariable.new
+color = TkVariable.new
+
+# frame
+TkFrame.new($radio_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $radio_demo
+ $radio_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'radio'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Variables'
+ command proc{
+ showVars($radio_demo, ['size', size], ['color', color])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+f_left = TkFrame.new($radio_demo)
+f_right = TkFrame.new($radio_demo)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "Point Size #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_right) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
diff --git a/ext/tk/sample/demos-en/radio2.rb b/ext/tk/sample/demos-en/radio2.rb
new file mode 100644
index 0000000000..2b56ccc9b1
--- /dev/null
+++ b/ext/tk/sample/demos-en/radio2.rb
@@ -0,0 +1,106 @@
+# radio2.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio2_demo) && $radio2_demo
+ $radio2_demo.destroy
+ $radio2_demo = nil
+end
+
+# demo toplevel widget
+$radio2_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 2")
+ iconname("radio2")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($radio2_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+#
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new($radio2_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $radio2_demo
+ $radio2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'radio2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Variables'
+ command proc{
+ showVars($radio2_demo,
+ ['size', size], ['color', color], ['compound', align])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+f_left = TkLabelFrame.new($radio2_demo, 'text'=>'Point Size',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new($radio2_demo, 'text'=>'Color',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new($radio2_demo, 'text'=>'Alignment',
+ 'pady'=>2, 'padx'=>2)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "Point Size #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ lower = a.downcase
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>lower, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', abtn[0])
+Tk.grid(abtn[1], label, abtn[2])
+Tk.grid('x', abtn[3])
diff --git a/ext/tk/sample/demos-en/radio3.rb b/ext/tk/sample/demos-en/radio3.rb
new file mode 100644
index 0000000000..70c4abb3b5
--- /dev/null
+++ b/ext/tk/sample/demos-en/radio3.rb
@@ -0,0 +1,114 @@
+# radio3.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio3_demo) && $radio3_demo
+ $radio3_demo.destroy
+ $radio3_demo = nil
+end
+
+# demo toplevel widget
+$radio3_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 3")
+ iconname("radio3")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($radio3_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. When the 'Tristate' button is pressed, the radio buttons will display the tri-state mode. Selecting any radio button will return the buttons to their respective on/off state. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.grid(:row=>0, :column=>0, :columnspan=>3, :sticky=>'nsew')
+
+# variable
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new($radio3_demo) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars($radio3_demo, ['size', size],
+ ['color', color], ['compound', align])
+ }),
+ TkButton.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'radio3'}),
+ TkButton.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $radio3_demo
+ $radio3_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew')
+}
+
+# frame
+f_left = TkLabelFrame.new($radio3_demo, 'text'=>'Point Size',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new($radio3_demo, 'text'=>'Color',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new($radio3_demo, 'text'=>'Alignment',
+ 'pady'=>2, 'padx'=>2)
+f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkButton.new($radio3_demo, 'text'=>'Tristate',
+ 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){
+ grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c')
+}
+
+# radiobutton
+[10, 12, 14, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "Point Size #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ tristatevalue 'multi'
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ tristatevalue 'multi'
+ command proc{f_mid.fg(color.value)}
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', a_btn[0])
+Tk.grid(a_btn[1], label, a_btn[2])
+Tk.grid('x', a_btn[3])
diff --git a/ext/tk/sample/demos-en/rmt b/ext/tk/sample/demos-en/rmt
new file mode 100644
index 0000000000..73f631180a
--- /dev/null
+++ b/ext/tk/sample/demos-en/rmt
@@ -0,0 +1,268 @@
+#!/usr/bin/env ruby
+
+# rmt --
+# This script implements a simple remote-control mechanism for
+# Tk applications. It allows you to select an application and
+# then type commands to that application.
+
+require 'tk'
+
+class Rmt
+ def initialize(parent=nil)
+ win = self
+
+ unless parent
+ parent = TkRoot.new
+ end
+ root = TkWinfo.toplevel(parent)
+ root.minsize(1,1)
+
+ # The instance variable below keeps track of the remote application
+ # that we're sending to. If it's an empty string then we execute
+ # the commands locally.
+ @app = 'local'
+ @mode = 'Ruby'
+
+ # The instance variable below keeps track of whether we're in the
+ # middle of executing a command entered via the text.
+ @executing = 0
+
+ # The instance variable below keeps track of the last command executed,
+ # so it can be re-executed in response to !! commands.
+ @lastCommand = ""
+
+ # Create menu bar. Arrange to recreate all the information in the
+ # applications sub-menu whenever it is cascaded to.
+
+ TkFrame.new(root, 'relief'=>'raised', 'bd'=>2) {|f|
+ pack('side'=>'top', 'fill'=>'x')
+ TkMenubutton.new(f, 'text'=>'File', 'underline'=>0) {|mb|
+ TkMenu.new(mb) {|mf|
+ mb.menu(mf)
+ TkMenu.new(mf) {|ma|
+ postcommand proc{win.fillAppsMenu ma}
+ mf.add('cascade', 'label'=>'Select Application',
+ 'menu'=>ma, 'underline'=>0)
+ }
+ add('command', 'label'=>'Quit',
+ 'command'=>proc{root.destroy}, 'underline'=>0)
+ }
+ pack('side'=>'left')
+ }
+ }
+
+ # Create text window and scrollbar.
+
+ @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {
+ yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')})
+ pack('side'=>'left')
+ }
+
+ @promptEnd = TkTextMark.new(@txt, 'insert')
+
+ # Create a binding to forward commands to the target application,
+ # plus modify many of the built-in bindings so that only information
+ # in the current command can be deleted (can still set the cursor
+ # earlier in the text and select and insert; just can't delete).
+
+ @txt.bindtags([@txt, TkText, root, 'all'])
+ @txt.bind('Return', proc{
+ @txt.set_insert('end - 1c')
+ @txt.insert('insert', "\n")
+ win.invoke
+ Tk.callback_break
+ })
+ @txt.bind('Delete', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('BackSpace', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('Control-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-k', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ @txt.set_insert(@promptEnd)
+ end
+ })
+ @txt.bind('Control-t', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-BackSpace', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-h', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+
+ @txt.tag_configure('bold', 'font'=>['Courier', 12, 'bold'])
+
+ @app = Tk.appname('rmt')
+ if (@app =~ /^rmt(.*)$/)
+ root.title("Tk Remote Controller#{$1}")
+ root.iconname("Tk Remote#{$1}")
+ end
+ prompt
+ @txt.focus
+ #@app = TkWinfo.appname(TkRoot.new)
+ end
+
+ def tkTextInsert(w,s)
+ return if s == ""
+ begin
+ if w.compare('sel.first','<=','insert') \
+ && w.compare('sel.last','>=','insert')
+ w.tag_remove('sel', 'sel.first', @promptEnd)
+ w.delete('sel.first', 'sel.last')
+ end
+ rescue
+ end
+ w.insert('insert', s)
+ w.see('insert')
+ end
+
+ # The method below is used to print out a prompt at the
+ # insertion point (which should be at the beginning of a line
+ # right now).
+
+ def prompt
+ @txt.insert('insert', "#{@app}: ")
+ @promptEnd.set('insert')
+ @promptEnd.gravity = 'left'
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ end
+
+ # The method below executes a command (it takes everything on the
+ # current line after the prompt and either sends it to the remote
+ # application or executes it locally, depending on "app".
+
+ def invoke
+ cmd = @txt.get(@promptEnd, 'insert')
+ @executing += 1
+ case (@mode)
+ when 'Tcl'
+ if Tk.info('complete', cmd)
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ else
+ @lastCommand = cmd
+ end
+ begin
+ msg = Tk.appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+
+ when 'Ruby'
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ end
+ complete = true
+ begin
+ eval("proc{#{cmd}}")
+ rescue
+ complete = false
+ end
+ if complete
+ @lastCommand = cmd
+ begin
+# msg = Tk.appsend(@app, false,
+# 'ruby',
+# '"(' + cmd.gsub(/[][$"]/, '\\\\\&') + ').to_s"')
+ msg = Tk.rb_appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+ end
+
+ @executing -= 1
+ @txt.yview_pickplace('insert')
+ end
+
+ # The following method is invoked to change the application that
+ # we're talking to. It also updates the prompt for the current
+ # command, unless we're in the middle of executing a command from
+ # the text item (in which case a new prompt is about to be output
+ # so there's no need to change the old one).
+
+ def newApp(appName, mode)
+ @app = appName
+ @mode = mode
+ if @executing == 0
+ @promptEnd.gravity = 'right'
+ @txt.delete("#{@promptEnd.path} linestart", @promptEnd)
+ @txt.insert(@promptEnd, "#{appName}: ")
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ @promptEnd.gravity = 'left'
+ end
+ end
+
+ # The method below will fill in the applications sub-menu with a list
+ # of all the applications that currently exist.
+
+ def fillAppsMenu(menu)
+ win = self
+ begin
+ menu.delete(0,'last')
+ rescue
+ end
+ TkWinfo.interps.sort.each{|ip|
+ begin
+ if Tk.appsend(ip, false, 'info commands ruby') == ""
+ mode = 'Tcl'
+ else
+ mode = 'Ruby'
+ end
+ menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode})
+ rescue
+ menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled')
+ end
+ }
+ menu.add('command', 'label'=>format("local (Ruby/Tk)"),
+ 'command'=>proc{win.newApp 'local', 'Ruby'})
+ end
+end
+
+Rmt.new
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/rolodex b/ext/tk/sample/demos-en/rolodex
new file mode 100644
index 0000000000..9a4030e902
--- /dev/null
+++ b/ext/tk/sample/demos-en/rolodex
@@ -0,0 +1,320 @@
+#!/usr/bin/env ruby
+#
+# rolodex --
+# This script is a part of Tom LaStrange's rolodex
+#
+# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
+# Time-stamp: "03/08/02 06:23:06 nagai"
+#
+
+require "tk"
+
+
+def show_help(topic,x=0,y=0)
+ if( topic.is_a?(TkWindow) )
+ w = TkWinfo.containing(x,y)
+ if( TkWinfo.exist?(w) )
+ topic = w
+ end
+ end
+
+ if( $helpTopics.include?(topic) )
+ msg = $helpTopics[topic]
+ else
+ msg = "Sorry, but no help is available for this topic"
+ end
+ TkDialog.new("title"=>"Rolodex Help",
+ "message"=>"Information on #{topic}:\n\n#{msg}",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+end
+
+def fillCard
+ clearAction
+ $root.frame.entry[1].insert(0,"Takaaki Tateishi")
+ $root.frame.entry[2].insert(0,"Japan Advanced Institute of Science and Techonology")
+ $root.frame.entry[3].insert(0,"1-1 Asahidai, Tatsunokuchi")
+ $root.frame.entry[4].insert(0,"Ishikawa 923-1292, Japan")
+ $root.frame.entry[5].insert(0,"private")
+ $root.frame.entry[6].insert(0,"***-***-****")
+ $root.frame.entry[7].insert(0,"***-***-****")
+end
+
+def addAction
+ for i in 1..7
+ STDERR.print format("%-12s %s\n",
+ RolodexFrame::LABEL[i],
+ $root.frame.entry[i].value)
+ end
+end
+
+def clearAction
+ for i in 1..7
+ $root.frame.entry[i].delete(0,"end")
+ end
+end
+
+def fileAction
+ TkDialog.new("title"=>"File Selection",
+ "message"=>"This is a dummy file selection dialog box.\n",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+ STDERR.print "dummy file name\n"
+end
+
+def deleteAction
+ result = TkDialog.new("title"=>"Confirm Action",
+ "message"=>"Are you sure?",
+ "default_button"=>0,
+ "buttons"=>["Cancel"])
+ if( result.value == 0 )
+ clearAction
+ end
+end
+
+
+class RolodexFrame < TkFrame
+ attr_reader :entry, :label
+
+ LABEL = ["","Name:","Address:","","","Home Phone:","Work Phone:","Fax:"]
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ self["relief"] = "flat"
+
+ @i = []
+ @label = []
+ @entry = []
+ for i in 1..7
+ @i[i] = TkFrame.new(self)
+ @i[i].pack("side"=>"top",
+ "pady"=>2,
+ "anchor"=>"e")
+ @label[i] = TkLabel.new(@i[i],
+ "text"=>LABEL[i],
+ "anchor"=>"e")
+ @entry[i] = TkEntry.new(@i[i],
+ "width"=>30,
+ "relief"=>"sunken")
+ @entry[i].pack("side"=>"right")
+ @label[i].pack("side"=>"right")
+ end
+ end
+end
+
+class RolodexButtons < TkFrame
+ attr_reader :clear, :add, :search, :delete
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ @clear = TkButton.new(self,
+ "text" => "Clear")
+ @add = TkButton.new(self,
+ "text" => "Add")
+ @search = TkButton.new(self,
+ "text" => "Search")
+ @delete = TkButton.new(self,
+ "text" => "Delete")
+ for w in [@clear,@add,@search,@delete]
+ w.pack("side"=>"left", "padx"=>2)
+ end
+ end
+end
+
+class RolodexMenuFrame < TkFrame
+ attr_reader :file_menu, :help_menu, :file, :help
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ configure("relief"=>"raised",
+ "borderwidth"=>1)
+
+ @file = TkMenubutton.new(self,
+ "text"=>"File",
+ "underline"=>0)
+ @file_menu = TkMenu.new(@file)
+ @file_menu.add("command",
+ "label" => "Load ...",
+ "command" => proc{fileAction},
+ "underline" => 0)
+ @file_menu.add("command",
+ "label" => "Exit",
+ "command" => proc{$root.destroy},
+ "underline" => 0)
+ @file.menu(@file_menu)
+ @file.pack("side"=>"left")
+
+ @help = TkMenubutton.new(self,
+ "text"=>"Help",
+ "underline"=>0)
+ @help_menu = TkMenu.new(@help)
+ @help_menu.add("command",
+ "label"=>"On Context...",
+ "command"=>proc{show_help("context")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Help...",
+ "command"=>proc{show_help("help")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Window...",
+ "command"=>proc{show_help("window")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Keys...",
+ "command"=>proc{show_help("keys")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On version...",
+ "command"=>proc{show_help("version")},
+ "underline"=>3)
+ @help.menu(@help_menu)
+ @help.pack("side"=>"right")
+ end
+end
+
+class Rolodex < TkRoot
+ attr_reader :frame, :buttons, :menu
+
+ def initialize(*args)
+ super(*args)
+ @frame = RolodexFrame.new(self)
+ @frame.pack("side"=>"top",
+ "fill"=>"y",
+ "anchor"=>"center")
+ @buttons = RolodexButtons.new(self)
+ @buttons.pack("side"=>"bottom",
+ "pady"=>2,
+ "anchor"=>"center")
+ @menu = RolodexMenuFrame.new(self)
+ @menu.pack("before"=>@frame,
+ "side"=>"top",
+ "fill"=>"x")
+ end
+end
+
+$root = Rolodex.new
+
+$root.buttons.delete.configure("command"=>proc{deleteAction})
+$root.buttons.add.configure("command"=>proc{addAction})
+$root.buttons.clear.configure("command"=>proc{clearAction})
+$root.buttons.search.configure("command"=>proc{addAction; fillCard})
+
+$root.buttons.clear.configure("text"=>"Clear Ctrl+C")
+$root.bind("Control-c",proc{clearAction})
+
+$root.buttons.add.configure("text"=>"Add Ctrl+A")
+$root.bind("Control-a",proc{addAction})
+
+$root.buttons.search.configure("text"=>"Search Ctrl+S")
+$root.bind("Control-s",proc{addAction; fillCard})
+
+$root.buttons.delete.configure("text"=>"Delete... Ctrl+D")
+$root.bind("Control-d",proc{deleteAction})
+
+$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
+$root.bind("Control-f",proc{fileAction})
+
+$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
+$root.bind("Control-q",proc{$root.destroy})
+
+$root.frame.entry[1].focus
+
+$root.bind("Any-F1",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+$root.bind("Any-Help",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+
+
+$helpTopics = {}
+
+$helpTopics[$root.menu.file] = <<EOF
+This is the "file" menu. It can be used to invoke\
+some overall operations on the rolodex applications,\
+such as loading a file or exiting.
+EOF
+
+$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
+The "Load" entry in the "File" menu posts a dialog box\
+that you can use to select a rolodex file
+EOF
+
+$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
+The "Exit" entry in the "File" menu causes the rolodex\
+application to terminate
+EOF
+
+$helpTopics[$root.frame.entry[1]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's name
+EOF
+
+$helpTopics[$root.frame.entry[2]] = <<EOF
+In this field of the rolodex entry you should\
+type the first line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[3]] = <<EOF
+In this field of the rolodex entry you should\
+type the second line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[4]] = <<EOF
+In this field of the rolodex entry you should\
+type the third line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[5]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's home phone number, or "private"\
+if the person doesn't want his or he number publicized
+EOF
+
+$helpTopics[$root.frame.entry[6]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's work phone number
+EOF
+
+$helpTopics[$root.frame.entry[7]] = <<EOF
+In this field of the rolodex entry you should\
+type the phone number for the person's FAX machine
+EOF
+
+$helpTopics["context"] = <<EOF
+Unfortunately, this application doesn't support context-sensitive\
+help in the usual way, because when this demo was written Ruby/Tk\
+didn't have a grab mechanism and this is needed for context-sensitive\
+help. Instead, you can achive much the same effect by simply moving\
+the mouse over the window you're curious about and pressing the\
+Help or F1 keys. You can do this anytime.
+EOF
+
+$helpTopics["help"] = <<EOF
+This application provides only very crude help. Besides the\
+entries in this menu, you can get help on individual windows\
+by moving the mouse cursor over the window and pressing the\
+Help or F1 keys.
+EOF
+
+$helpTopics["window"] = <<EOF
+This window is a dummy rolodex application created as part of\
+Tom LaStrange's toolkit benchmark. It doesn't really do anything\
+useful except to demonstrate a few features of the Ruby/Tk.
+EOF
+
+$helpTopics["keys"] = <<EOF
+The following accelerator keys are defined for this application\
+(in addition to those already available for the entry windows):
+Ctrl+A: Add
+Ctrl+C: Clear
+Ctrl+D: Delete
+Ctrl+F: Enter file name
+Ctrl+Q: Exit application (quit)
+Ctrl+S: Search (dummy operation)
+EOF
+
+$helpTopics["version"] = <<EOF
+This is version 1.0.1.
+EOF
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/rolodex-j b/ext/tk/sample/demos-en/rolodex-j
new file mode 100644
index 0000000000..27e2bc9da0
--- /dev/null
+++ b/ext/tk/sample/demos-en/rolodex-j
@@ -0,0 +1,323 @@
+#!/usr/bin/env ruby
+#
+# rolodex --
+# ¤³¤Î¥¹¥¯¥ê¥×¥È¤Ï Tom LaStrange ¤Î rolodex ¤Î°ìÉô¤Ç¤¹¡£
+#
+# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
+# Time-stamp: "03/08/02 14:02:04 nagai"
+#
+
+require "tk"
+
+Tk.encoding = "euc-jp"
+$font = TkFont.new('k14')
+
+def show_help(topic,x=0,y=0)
+ if( topic.is_a?(TkWindow) )
+ w = TkWinfo.containing(x,y)
+ if( w.is_a?(TkWindow) )
+ if( TkWinfo.exist?(w) )
+ topic = w
+ end
+ end
+ end
+
+ if( $helpTopics.include?(topic) )
+ msg = $helpTopics[topic]
+ else
+ msg = "¤³¤Î¥È¥Ô¥Ã¥¯¤Ë¤Ä¤¤¤Æ¤Î¥Ø¥ë¥×¤Ï¤Þ¤À»ÈÍѤǤ­¤Þ¤»¤ó"
+ end
+ TkDialog.new("title"=>"Rolodex Help",
+ "message"=>"¡Ö#{topic}¡×\n\n#{msg}",
+ "font"=>$font,
+ "default_button"=>0,
+ "buttons"=>["OK"])
+end
+
+def fillCard
+ clearAction
+ $root.frame.entry[1].insert(0, "ΩÀÐ ¹§¾´")
+ $root.frame.entry[2].insert(0, "923-1292 ÀÐÀ")
+ $root.frame.entry[3].insert(0, "ä¸ýÄ® °°Âæ 1-1")
+ $root.frame.entry[4].insert(0, "ËÌΦÀèü²Ê³Øµ»½ÑÂç³Ø±¡Âç³Ø")
+ $root.frame.entry[5].insert(0,"private")
+ $root.frame.entry[6].insert(0,"***-***-****")
+ $root.frame.entry[7].insert(0,"***-***-****")
+end
+
+def addAction
+ for i in 1..7
+ STDERR.print format("%-12s %s\n",
+ RolodexFrame::LABEL[i],
+ $root.frame.entry[i].value)
+ end
+end
+
+def clearAction
+ for i in 1..7
+ $root.frame.entry[i].delete(0,"end")
+ end
+end
+
+def fileAction
+ TkDialog.new("title"=>"File Selection",
+ "message"=>"¤³¤ì¤Ï¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°¤Î¥À¥ß¡¼¤Ç¤¹¡£\n",
+ "font"=>$font,
+ "default_button"=>0,
+ "buttons"=>["OK"])
+ STDERR.print "dummy file name\n"
+end
+
+def deleteAction
+ result = TkDialog.new("title"=>"Confirm Action",
+ "message"=>"¤è¤í¤·¤¤¤Ç¤¹¤«¡©",
+ "font"=>$font,
+ "default_button"=>0,
+ "buttons"=>["¥­¥ã¥ó¥»¥ë"])
+ if( result.value == 0 )
+ clearAction
+ end
+end
+
+
+class RolodexFrame < TkFrame
+ attr_reader :entry, :label
+
+ LABEL = ["","̾Á°:","½»½ê","","","ÅÅÏÃ(¼«Âð):","ÅÅÏÃ(²ñ¼Ò):","Fax:"]
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ self["relief"] = "flat"
+ @i = []
+ @label = []
+ @entry = []
+ for i in 1..7
+ @i[i] = TkFrame.new(self)
+ @i[i].pack("side"=>"top",
+ "pady"=>2,
+ "anchor"=>"e")
+ @label[i] = TkLabel.new(@i[i],
+ "text"=>LABEL[i],
+ "anchor"=>"e",
+ "font" => $font)
+ @entry[i] = TkEntry.new(@i[i],
+ "width"=>30,
+ "relief"=>"sunken",
+ "font" => $font)
+ @entry[i].pack("side"=>"right")
+ @label[i].pack("side"=>"right")
+ end
+ end
+end
+
+class RolodexButtons < TkFrame
+ attr_reader :clear, :add, :search, :delete
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ @clear = TkButton.new(self,
+ "text" => "¥¯¥ê¥¢¡¼",
+ "font" => $font)
+ @add = TkButton.new(self,
+ "text" => "ÄɲÃ",
+ "font" => $font)
+ @search = TkButton.new(self,
+ "text" => "¸¡º÷",
+ "font" => $font)
+ @delete = TkButton.new(self,
+ "text" => "¾Ãµî",
+ "font" => $font)
+ for w in [@clear,@add,@search,@delete]
+ w.pack("side"=>"left", "padx"=>2)
+ end
+ end
+end
+
+class RolodexMenuFrame < TkFrame
+ attr_reader :file_menu, :help_menu, :file, :help
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ configure("relief"=>"raised",
+ "borderwidth"=>1)
+
+ @file = TkMenubutton.new(self,
+ "text"=> "¥Õ¥¡¥¤¥ë",
+ "font"=> $font,
+ "underline"=>0)
+ @file_menu = TkMenu.new(@file)
+ @file_menu.add("command",
+ "label" => "ÆÉ¤ß¹þ¤ß ...",
+ "font" => $font,
+ "command" => proc{fileAction},
+ "underline" => 0)
+ @file_menu.add("command",
+ "label" => "½ªÎ»",
+ "font" => $font,
+ "command" => proc{$root.destroy},
+ "underline" => 0)
+ @file.menu(@file_menu)
+ @file.pack("side"=>"left")
+
+ @help = TkMenubutton.new(self,
+ "text"=> "¥Ø¥ë¥×",
+ "font"=> $font,
+ "underline"=>0)
+ @help_menu = TkMenu.new(@help)
+ @help_menu.add("command",
+ "label"=> "¥³¥ó¥Æ¥­¥¹¥È¤Ë¤Ä¤¤¤Æ",
+ "font" => $font,
+ "command"=>proc{show_help("¥³¥ó¥Æ¥­¥¹¥È")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥Ø¥ë¥×¤Ë¤Ä¤¤¤Æ",
+ "font" => $font,
+ "command"=>proc{show_help("¥Ø¥ë¥×")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥¦¥£¥ó¥É¥¦¤Ë¤Ä¤¤¤Æ",
+ "font" => $font,
+ "command"=>proc{show_help("¥¦¥£¥ó¥É¥¦")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥­¡¼Áàºî¤Ë¤Ä¤¤¤Æ",
+ "font" => $font,
+ "command"=>proc{show_help("¥­¡¼Áàºî")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥Ð¡¼¥¸¥ç¥ó¾ðÊó",
+ "font" => $font,
+ "command"=>proc{show_help("¥Ð¡¼¥¸¥ç¥ó¾ðÊó")},
+ "underline"=>3)
+ @help.menu(@help_menu)
+ @help.pack("side"=>"right")
+ end
+end
+
+class Rolodex < TkRoot
+ attr_reader :frame, :buttons, :menu
+
+ def initialize(*args)
+ super(*args)
+ @frame = RolodexFrame.new(self)
+ @frame.pack("side"=>"top",
+ "fill"=>"y",
+ "anchor"=>"center")
+ @buttons = RolodexButtons.new(self)
+ @buttons.pack("side"=>"bottom",
+ "pady"=>2,
+ "anchor"=>"center")
+ @menu = RolodexMenuFrame.new(self)
+ @menu.pack("before"=>@frame,
+ "side"=>"top",
+ "fill"=>"x")
+ end
+end
+
+$root = Rolodex.new
+
+$root.buttons.delete.configure("command"=>proc{deleteAction})
+$root.buttons.add.configure("command"=>proc{addAction})
+$root.buttons.clear.configure("command"=>proc{clearAction})
+$root.buttons.search.configure("command"=>proc{addAction; fillCard})
+
+$root.buttons.clear.configure("text"=> "¥¯¥ê¥¢¡¼ Ctrl+C", "font" => $font)
+$root.bind("Control-c",proc{clearAction})
+
+$root.buttons.add.configure("text"=> "Äɲà Ctrl+A", "font" => $font)
+$root.bind("Control-a",proc{addAction})
+
+$root.buttons.search.configure("text"=> "¸¡º÷ Ctrl+S", "font" => $font)
+$root.bind("Control-s",proc{addAction; fillCard})
+
+$root.buttons.delete.configure("text"=> "¾Ãµî Ctrl+D", "font" => $font)
+$root.bind("Control-d",proc{deleteAction})
+
+$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
+$root.bind("Control-f",proc{fileAction})
+
+$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
+$root.bind("Control-q",proc{$root.destroy})
+
+$root.frame.entry[1].focus
+
+$root.bind("Any-F1",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+$root.bind("Any-Help",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+
+
+$helpTopics = {}
+
+$helpTopics[$root.menu.file] = <<EOF
+¤³¤ì¤Ï¡Ö¥Õ¥¡¥¤¥ë¡×¥á¥Ë¥å¡¼¤Ç¤¹¡£¡ÖÆÉ¤ß¹þ¤ß¡×¤ä¡Ö½ªÎ»¡×¤Ê¤É¤ò
+¹Ô¤Ê¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
+¥Õ¥¡¥¤¥ë¤ÎÆÉ¤ß¹þ¤ß¤ò¹Ô¤Ê¤¦¤È¤­¤Ë»È¤¤¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
+¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë¤È¤­¤Ë»È¤¤¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[1]] = <<EOF
+̾Á°¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[2]] = <<EOF
+½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[3]] = <<EOF
+½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[4]] = <<EOF
+½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[5]] = <<EOF
+¼«Âð¤ÎÅÅÏÃÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£¸ø³«\
+¤·¤¿¤¯¤Ê¤¤¤È¤­¤Ï private ¤Èµ­Æþ¤·¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[6]] = <<EOF
+²ñ¼Ò¤ÎÅÅÏÃÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[7]] = <<EOF
+FAXÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics["¥³¥ó¥Æ¥­¥¹¥È"] = <<EOF
+Ruby/Tk¤Ç¤Ïgrab¤Îµ¡¹½¤¬¤Ê¤¤¤¿¤á¤³¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï\
+¥³¥ó¥Æ¥­¥¹¥È¥Ø¥ë¥×¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£
+¤·¤«¤·Æ±¤¸¤è¤¦¤Ê¸ú²Ì¤òbind¤È¥Þ¥¦¥¹¤Î°ÌÃÖ¤ÎWedget¤òÃΤë\
+¤³¤È¤ÇÆÀ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+EOF
+
+$helpTopics["¥Ø¥ë¥×"] = <<EOF
+¥Þ¥¦¥¹¤ò¥¦¥£¥ó¥É¥¦¤Ë¤¢¤ï¤»¤ÆF1¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ\
+¤½¤Î¥Ø¥ë¥×¤ò¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+EOF
+
+$helpTopics["¥¦¥£¥ó¥É¥¦"] = <<EOF
+¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï¥À¥ß¡¼¤Ç¤¹¡£
+EOF
+
+$helpTopics["¥­¡¼Áàºî"] = <<EOF
+Ctrl+A: ÄɲÃ
+Ctrl+C: ¥¯¥ê¥¢¡¼
+Ctrl+D: ¾Ãµî
+Ctrl+F: ¥Õ¥¡¥¤¥ëÁªÂò
+Ctrl+Q: ½ªÎ»
+Ctrl+S: ¸¡º÷
+EOF
+
+$helpTopics["¥Ð¡¼¥¸¥ç¥ó¾ðÊó"] = <<EOF
+¥Ð¡¼¥¸¥ç¥ó¤Ï 1.0.1e ¤Ç¤¹¡£
+EOF
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/ruler.rb b/ext/tk/sample/demos-en/ruler.rb
new file mode 100644
index 0000000000..4299d57b4f
--- /dev/null
+++ b/ext/tk/sample/demos-en/ruler.rb
@@ -0,0 +1,203 @@
+# ruler.rb
+#
+# This demonstration script creates a canvas widget that displays a ruler
+# with tab stops that can be set, moved, and deleted.
+#
+# ruler widget demo (called by 'widget')
+#
+
+# rulerMkTab --
+# This method creates a new triangular polygon in a canvas to
+# represent a tab stop.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - Coordinates at which to create the tab stop.
+
+def rulerMkTab(c,x,y)
+ v = $demo_rulerInfo
+ TkcPolygon.new(c, x, y, x+v.size, y+v.size, x-v.size, y+v.size)
+end
+
+# toplevel widget
+if defined?($ruler_demo) && $ruler_demo
+ $ruler_demo.destroy
+ $ruler_demo = nil
+end
+
+# demo toplevel widget
+$ruler_demo = TkToplevel.new {|w|
+ title("Ruler Demonstration")
+ iconname("ruler")
+ positionWindow(w)
+}
+
+# label
+TkLabel.new($ruler_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."){
+ pack('side'=>'top')
+}
+
+# frame
+$ruler_buttons = TkFrame.new($ruler_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $ruler_demo
+ $ruler_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'ruler'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas
+$ruler_canvas = TkCanvas.new($ruler_demo, 'width'=>'14.8c', 'height'=>'2.5c')
+$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
+
+#
+unless Struct.const_defined?("RulerInfo")
+ $demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y,
+ :top, :bottom, :size, :normalStyle,
+ :activeStyle, :deleteStyle).new
+end
+$demo_rulerInfo.grid = '.25c'
+$demo_rulerInfo.left = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.right = TkWinfo.fpixels($ruler_canvas, '13c')
+$demo_rulerInfo.top = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.bottom = TkWinfo.fpixels($ruler_canvas, '1.5c')
+$demo_rulerInfo.size = TkWinfo.fpixels($ruler_canvas, '.2c')
+$demo_rulerInfo.normalStyle = {'fill'=>'black'}
+if TkWinfo.depth($ruler_canvas) > 1
+ $demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'red',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+else
+ $demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+end
+
+TkcLine.new($ruler_canvas,
+ '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1)
+(0..11).each{|i|
+ x = i+1
+ TkcLine.new($ruler_canvas, "#{x}c", '1c', "#{x}c", '0.6c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.25c", '1c', "#{x}.25c", '0.8c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.5c", '1c', "#{x}.5c", '0.7c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.75c", '1c', "#{x}.75c", '0.8c', 'width'=>1)
+ TkcText.new($ruler_canvas, "#{x}.15c", '0.75c', 'text'=>i, 'anchor'=>'sw')
+}
+
+$rulerTag_well = TkcTag.new($ruler_canvas)
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ TkcRectangle.new($ruler_canvas,
+ '13.2c', '1c', '13.8c', '0.5c',
+ 'outline'=>'black',
+ 'fill'=>($ruler_canvas\
+ .configinfo('background'))[4]) )
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ rulerMkTab($ruler_canvas,
+ TkWinfo.pixels($ruler_canvas, '13.5c'),
+ TkWinfo.pixels($ruler_canvas, '.65c') ) )
+
+$rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.itembind('tab', '1',
+ proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('B1-Motion',
+ proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)})
+
+# rulerNewTab --
+# Does all the work of creating a tab stop, including creating the
+# triangle object and adding tags to it to give it tab behavior.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - The coordinates of the tab stop.
+
+def rulerNewTab(c,x,y)
+ v = $demo_rulerInfo
+ c.addtag_withtag('active', rulerMkTab(c,x,y))
+ c.addtag_withtag('tab', 'active')
+ v.x = x
+ v.y = y
+ rulerMoveTab(c,x,y)
+end
+
+# rulerSelectTab --
+# This method is invoked when mouse button 1 is pressed over
+# a tab. It remembers information about the tab so that it can
+# be dragged interactively.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse (identifies the point by
+# which the tab was picked up for dragging).
+
+def rulerSelectTab(c,x,y)
+ v = $demo_rulerInfo
+ v.x = c.canvasx(x, v.grid)
+ v.y = v.top+2
+ c.addtag_withtag('active', 'current')
+ c.itemconfigure('active', v.activeStyle)
+ c.raise('active')
+end
+
+# rulerMoveTab --
+# This method is invoked during mouse motion events to drag a tab.
+# It adjusts the position of the tab, and changes its appearance if
+# it is about to be dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerMoveTab(c,x,y)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ cx = c.canvasx(x,v.grid)
+ cy = c.canvasy(y)
+ cx = v.left if cx < v.left
+ cx = v.right if cx > v.right
+ if (cy >= v.top && cy <= v.bottom)
+ cy = v.top+2
+ c.itemconfigure('active', v.activeStyle)
+ else
+ cy = cy-v.size-2
+ c.itemconfigure('active', v.deleteStyle)
+ end
+ c.move('active', cx-v.x, cy-v.y)
+ v.x = cx
+ v.y = cy
+end
+
+# rulerReleaseTab --
+# This method is invoked during button release events that end
+# a tab drag operation. It deselects the tab and deletes the tab if
+# it was dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerReleaseTab(c)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ if v.y != v.top+2
+ c.delete('active')
+ else
+ c.itemconfigure('active', v.normalStyle)
+ c.dtag('active')
+ end
+end
+
diff --git a/ext/tk/sample/demos-en/sayings.rb b/ext/tk/sample/demos-en/sayings.rb
new file mode 100644
index 0000000000..cef0f4ecf4
--- /dev/null
+++ b/ext/tk/sample/demos-en/sayings.rb
@@ -0,0 +1,104 @@
+# sayings.rb
+#
+# This demonstration script creates a listbox that can be scrolled
+# both horizontally and vertically. It displays a collection of
+# well-known sayings.
+#
+# listbox widget demo 'sayings' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($sayings_demo) && $sayings_demo
+ $sayings_demo.destroy
+ $sayings_demo = nil
+end
+
+# demo toplevel widget
+$sayings_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (well-known sayings)")
+ iconname("sayings")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($sayings_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "The listbox below contains a collection of well-known sayings. You can scan the list using either of the scrollbars or by dragging in the listbox window with button 2 pressed."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($sayings_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $sayings_demo
+ $sayings_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'sayings'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+sayings_lbox = nil
+TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w|
+ sv = TkScrollbar.new(w)
+ sh = TkScrollbar.new(w, 'orient'=>'horizontal')
+ sayings_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| sv.set first,last}
+ xscrollcommand proc{|first,last| sh.set first,last}
+ }
+ sv.command(proc{|*args| sayings_lbox.yview(*args)})
+ sh.command(proc{|*args| sayings_lbox.xview(*args)})
+
+ if $tk_version =~ /^4\.[01]/
+ sv.pack('side'=>'right', 'fill'=>'y')
+ sh.pack('side'=>'bottom', 'fill'=>'x')
+ sayings_lbox.pack('expand'=>'yes', 'fill'=>'y')
+
+ else
+ sayings_lbox.grid('row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sv.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sh.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ end
+
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+sayings_lbox.insert(0,
+"Waste not, want not",
+"Early to bed and early to rise makes a man healthy, wealthy, and wise",
+"Ask not what your country can do for you, ask what you can do for your country",
+"I shall return",
+"NOT",
+"A picture is worth a thousand words",
+"User interfaces are hard to build",
+"Thou shalt not steal",
+"A penny for your thoughts",
+"Fool me once, shame on you; fool me twice, shame on me",
+"Every cloud has a silver lining",
+"Where there's smoke there's fire",
+"It takes one to know one",
+"Curiosity killed the cat; but satisfaction brought it back",
+"Take this job and shove it",
+"Up a creek without a paddle",
+"I'm mad as hell and I'm not going to take it any more",
+"An apple a day keeps the doctor away",
+"Don't look a gift horse in the mouth"
+)
+
diff --git a/ext/tk/sample/demos-en/search.rb b/ext/tk/sample/demos-en/search.rb
new file mode 100644
index 0000000000..3d3b4aecc8
--- /dev/null
+++ b/ext/tk/sample/demos-en/search.rb
@@ -0,0 +1,180 @@
+# search.rb
+#
+# This demonstration script creates a collection of widgets that
+# allow you to load a file into a text widget, then perform searches
+# on that file.
+#
+# Text Search widget demo (called by 'widget')
+#
+
+# textLoadFile --
+# This method below loads a file into a text widget, discarding
+# the previous contents of the widget. Tags for the old widget are
+# not affected, however.
+#
+# Arguments:
+# w - The window into which to load the file. Must be a
+# text widget.
+# file - The name of the file to load. Must be readable.
+
+def textLoadFile(w,file)
+ w.delete('1.0', 'end')
+ f = open(file, 'r')
+ while(!f.eof?)
+ w.insert('end', f.read(1000))
+ end
+ f.close
+end
+
+# textSearch --
+# Search for all instances of a given string in a text widget and
+# apply a given tag to each instance found.
+#
+# Arguments:
+# w - The window in which to search. Must be a text widget.
+# string - The string to search for. The search is done using
+# exact matching only; no special characters.
+# tag - Tag to apply to each instance of a matching string.
+
+def textSearch(w, string, tag)
+ tag.remove('0.0', 'end')
+ return if string == ""
+ cur = '1.0'
+ loop {
+ cur, len = w.search_with_length(string, cur, 'end')
+ break if cur == ""
+ tag.add(cur, "#{cur} + #{len} char")
+ cur = w.index("#{cur} + #{len} char")
+ }
+end
+
+# textToggle --
+# This method is invoked repeatedly to invoke two commands at
+# periodic intervals. It normally reschedules itself after each
+# execution but if an error occurs (e.g. because the window was
+# deleted) then it doesn't reschedule itself.
+#
+# Arguments:
+# cmd1 - Command to execute when method is called.
+# sleep1 - Ms to sleep after executing cmd1 before executing cmd2.
+# cmd2 - Command to execute in the *next* invocation of this method.
+# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again.
+
+def textToggle(cmd1,sleep1,cmd2,sleep2)
+ sleep_list = [sleep2, sleep1]
+ TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep},
+ -1, cmd1, cmd2).start(sleep1)
+end
+
+# toplevel widget
+if defined?($search_demo) && $search_demo
+ $search_demo.destroy
+ $search_demo = nil
+end
+
+# demo toplevel widget
+$search_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Search and Highlight")
+ iconname("search")
+ positionWindow(w)
+}
+
+# frame
+$search_buttons = TkFrame.new($search_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $search_demo
+ $search_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'search'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+TkFrame.new($search_demo) {|f|
+ TkLabel.new(f, 'text'=>'File name:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_fileName = TkVariable.new
+ TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_fileName) {
+ pack('side'=>'left')
+ bind('Return', proc{textLoadFile($search_text, $search_fileName.value)
+ $search_string_entry.focus})
+ focus
+ }
+ TkButton.new(f, 'text'=>'Load File',
+ 'command'=>proc{textLoadFile($search_text,
+ $search_fileName.value)})\
+ .pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+}.pack('side'=>'top', 'fill'=>'x')
+
+TkFrame.new($search_demo) {|f|
+ TkLabel.new(f, 'text'=>'Search string:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_searchString = TkVariable.new
+ $search_string_entry = TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_searchString) {
+ pack('side'=>'left')
+ bind('Return', proc{textSearch($search_text, $search_searchString.value,
+ $search_Tag)})
+ }
+ TkButton.new(f, 'text'=>'Highlight',
+ 'command'=>proc{textSearch($search_text,
+ $search_searchString.value,
+ $search_Tag)}) {
+ pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+ }
+}.pack('side'=>'top', 'fill'=>'x')
+
+$search_text = TkText.new($search_demo, 'setgrid'=>true, 'wrap'=>'word') {|t|
+ $search_Tag = TkTextTag.new(t)
+ TkScrollbar.new($search_demo, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
+ t.yscrollcommand(proc{|first,last| sc.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+}
+
+# Set up display styles for text highlighting.
+
+if TkWinfo.depth($search_demo) > 1
+ textToggle(proc{
+ $search_Tag.configure('background'=>'#ce5555',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+else
+ textToggle(proc{
+ $search_Tag.configure('background'=>'black',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+end
+$search_text.insert('1.0', "\
+This window demonstrates how to use the tagging facilities in text \
+widgets to implement a searching mechanism. First, type a file name \
+in the top entry, then type <Return> or click on \"Load File\". Then \
+type a string in the lower entry and type <Return> or click on \
+\"Load File\". This will cause all of the instances of the string to \
+be tagged with the tag \"search\", and it will arrange for the tag\'s \
+display attributes to change to make all of the strings blink.")
+$search_text.set_insert '0.0'
+
+$search_fileName.value = ''
+$search_searchString.value = ''
+
diff --git a/ext/tk/sample/demos-en/spin.rb b/ext/tk/sample/demos-en/spin.rb
new file mode 100644
index 0000000000..58616b1e02
--- /dev/null
+++ b/ext/tk/sample/demos-en/spin.rb
@@ -0,0 +1,63 @@
+# spin.rb --
+#
+# This demonstration script creates several spinbox widgets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($spin_demo) && $spin_demo
+ $spin_demo.destroy
+ $spin_demo = nil
+end
+
+$spin_demo = TkToplevel.new {|w|
+ title("Spinbox Demonstration")
+ iconname("spin")
+ positionWindow(w)
+}
+
+TkLabel.new($spin_demo,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+Three different spin-boxes are displayed below. \
+You can add characters by pointing, clicking and typing. \
+The normal Motif editing characters are supported, along with \
+many Emacs bindings. For example, Backspace and Control-h \
+delete the character to the left of the insertion cursor and \
+Delete and Control-d delete the chararacter to the right of the \
+insertion cursor. For values that are too large to fit in the \
+window all at once, you can scan through the value by dragging \
+with mouse button2 pressed. Note that the first spin-box will \
+only permit you to type in integers, and the third selects from \
+a list of Australian cities.
+If your Tk library linked to Ruby doesn't include a 'spinbox' widget, \
+this demo doesn't work. Please use later version of Tk \
+which supports a 'spinbox' widget.
+EOL
+
+TkFrame.new($spin_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $spin_demo.destroy
+ $spin_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'spin'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+australianCities = [
+ 'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide',
+ 'Brisbane', 'Hobart', 'Darwin', 'Alice Springs'
+]
+
+[
+ TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key,
+ :validatecommand=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]),
+ TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5,
+ :format=>'%05.2f', :width=>10),
+ TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10)
+].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}
diff --git a/ext/tk/sample/demos-en/square b/ext/tk/sample/demos-en/square
new file mode 100644
index 0000000000..00bfde59ff
--- /dev/null
+++ b/ext/tk/sample/demos-en/square
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+# square --
+# This script generates a demo application containing only
+# a "square" widget. It's only usable if Tk has been compiled
+# with tkSquare.c and with the -DSQUARE_DEMO compiler switch.
+# This demo arranges the following bindings for the widget:
+#
+# Button-1 press/drag: moves square to mouse
+# "a": toggle size animation on/off
+#
+
+require 'tk'
+require 'tkafter'
+
+class TkSquare<TkWindow
+ def create_self
+ begin
+ tk_call 'square', path
+ rescue
+ STDERR.print "\nSorry. Your Tk interpreter does not contain " +
+ 'a "square" demonstration widget.' +
+ "\n ( See documents included the Tcl/Tk source archive. )\n\n"
+ exit
+ end
+ end
+ def size(amount=nil)
+ if amount
+ tk_send 'size', amount
+ else
+ number(tk_send('size'))
+ end
+ end
+ def position(x,y)
+ tk_send 'position', x, y
+ end
+end
+
+$s = TkSquare.new{
+ pack('expand'=>'yes', 'fill'=>'both')
+ bind('1', proc{|x,y| center(x,y)}, '%s %y')
+ bind('B1-Motion', proc{|x,y| center(x,y)}, '%s %y')
+ bind('a', proc{animate})
+ focus
+}
+TkRoot.new.minsize(1,1)
+
+# The procedure below centers the square on a given position.
+
+def center(x,y)
+ a = $s.size
+ $s.position(x-(a/2), y-(a/2))
+end
+
+# The procedures below provide a simple form of animation where
+# the box changes size in a pulsing pattern: larger, smaller, larger,
+# and so on.
+
+$inc = 0
+
+def timer_proc
+ a = $s.size
+ return if $inc == 0
+ $inc = -3 if a >= 40
+ $inc = 3 if a <= 10
+ $s.size(a+$inc)
+end
+
+$timer = TkAfter.new(30, -1, proc{timer_proc})
+
+def animate
+ if $inc == 0
+ $inc = 3
+ $timer.start
+ else
+ $inc = 0
+ $timer.stop
+ end
+end
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/states.rb b/ext/tk/sample/demos-en/states.rb
new file mode 100644
index 0000000000..d38c1245af
--- /dev/null
+++ b/ext/tk/sample/demos-en/states.rb
@@ -0,0 +1,78 @@
+# states.rb
+#
+# This demonstration script creates a listbox widget that displays
+# the names of the 50 states in the United States of America.
+#
+# listbox widget demo 'states' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($states_demo) && $states_demo
+ $states_demo.destroy
+ $states_demo = nil
+end
+
+# demo toplevel widget
+$states_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (states)")
+ iconname("states")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($states_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($states_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $states_demo
+ $states_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'states'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+states_lbox = nil
+TkFrame.new($states_demo, 'borderwidth'=>'.5c') {|w|
+ s = TkScrollbar.new(w)
+ states_lbox = TkListbox.new(w) {
+ setgrid 1
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| states_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ states_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+ins_data = [
+ 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
+ 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia',
+ 'Hawaii', 'Idaho', 'Illinois',
+ 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland',
+ 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri',
+ 'Montana', 'Nebraska', 'Nevada', 'New_Hampshire', 'New_Jersey', 'New_Mexico',
+ 'New_York', 'North_Carolina', 'North_Dakota',
+ 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode_Island',
+ 'South_Carolina', 'South_Dakota',
+ 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington',
+ 'West_Virginia', 'Wisconsin', 'Wyoming'
+]
+
+states_lbox.insert(0, *ins_data)
+
diff --git a/ext/tk/sample/demos-en/style.rb b/ext/tk/sample/demos-en/style.rb
new file mode 100644
index 0000000000..5ed11aa459
--- /dev/null
+++ b/ext/tk/sample/demos-en/style.rb
@@ -0,0 +1,211 @@
+# style.rb
+#
+# This demonstration script creates a text widget that illustrates the
+# various display styles that may be set for tags.
+#
+# text (display styles) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($style_demo) && $style_demo
+ $style_demo.destroy
+ $style_demo = nil
+end
+
+# demo toplevel widget
+$style_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Display Styles")
+ iconname("style")
+ positionWindow(w)
+}
+
+# frame
+TkFrame.new($style_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $style_demo
+ $style_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'style'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# text
+TkText.new($style_demo){|t|
+ #
+ setgrid 'true'
+ width 70
+ height 32
+ wrap 'word'
+ TkScrollbar.new($style_demo) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ #
+ style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
+ style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+ style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
+# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+ style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+###
+# case($tk_version)
+# when /^4.*/
+# style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+# when /^8.*/
+# unless $style_demo_do_first
+# $style_demo_do_first = true
+# Tk.tk_call('font', 'create', '@bigascii',
+# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*')
+# Tk.tk_call('font', 'create', '@smallascii',
+# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+# Tk.tk_call('font', 'create', '@cBigFont',
+# '-compound', '@bigascii @msg_knj')
+# Tk.tk_call('font', 'create', '@cSmallFont',
+# '-compound', '@smallascii @kanji')
+# end
+# style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont')
+# style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont')
+# end
+
+ #
+ if TkWinfo.depth($root).to_i > 1
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'#a0b7ce')
+ style_tag_color2 = TkTextTag.new(t, 'foreground'=>'red')
+ style_tag_raised = TkTextTag.new(t, 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1)
+ else
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_color2 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_raised = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'sunken', 'borderwidth'=>1)
+ end
+
+ #
+ if $tk_version =~ /^4\.[01]/
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray25')
+ else
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray12')
+ end
+ style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50')
+ style_tag_underline = TkTextTag.new(t, 'underline'=>'on')
+ style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
+ style_tag_right = TkTextTag.new(t, 'justify'=>'right')
+ style_tag_center = TkTextTag.new(t, 'justify'=>'center')
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+ style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
+ 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+
+ #
+ insert('end', 'Text widgets like this one allow you to display information in a
+variety of styles. Display styles are controlled using a mechanism
+called ')
+ insert('end', 'tags', style_tag_big)
+ insert('end', '. Tags are just textual names that you can apply to one
+or more ranges of characters within a text widget. You can configure
+tags with various display styles. If you do this, then the tagged
+characters will be displayed with the styles you chose. The
+available display styles are:
+')
+ insert('end', "\n1. Font.", style_tag_big)
+ insert('end', " You can choose any X font, ")
+ insert('end', "large", style_tag_verybig)
+ insert('end', " or ")
+ insert('end', "small.\n")
+ insert('end', "\n2. Color.", style_tag_big)
+ insert('end', " You can change either the ")
+ insert('end', "background", style_tag_color1)
+ insert('end', " or ")
+ insert('end', "foreground", style_tag_color2)
+ insert('end', "\ncolor, or ")
+ insert('end', "both", style_tag_color1, style_tag_color2)
+ insert('end', ".\n")
+ insert('end', "\n3. Stippling.", style_tag_big)
+ insert('end', " You can cause either the ")
+ insert('end', "background", style_tag_bgstipple)
+ insert('end', " or ")
+ insert('end', "foreground", style_tag_fgstipple)
+ insert('end', "\ninformation to be drawn with a stipple fill instead of a solid fill.\n")
+ insert('end', "\n4. Underlining.", style_tag_big)
+ insert('end', " You can ")
+ insert('end', "underline", style_tag_underline)
+ insert('end', " ranges of text.\n")
+ insert('end', "\n5. Overstrikes.", style_tag_big)
+ insert('end', " You can ")
+ insert('end', "draw lines through", style_tag_overstrike)
+ insert('end', " ranges of text.\n")
+ insert('end', "\n6. 3-D effects.", style_tag_big)
+ insert('end', " You can arrange for the background to be drawn\nwith a border that makes characters appear either\n")
+ insert('end', "raised", style_tag_raised)
+ insert('end', " or ")
+ insert('end', "sunken", style_tag_sunken)
+ insert('end', ".\n")
+ insert('end', "\n7. Justification.", style_tag_big)
+ insert('end', " You can arrange for lines to be displayed\n")
+ insert('end', "left-justified,\n")
+ insert('end', "right-justified, or\n", style_tag_right)
+ insert('end', "centered.\n", style_tag_center)
+ insert('end', "\n8. Superscripts and subscripts.", style_tag_big)
+ insert('end', " You can control the vertical\n")
+ insert('end', "position of text to generate superscript effects like 10")
+ insert('end', "n", style_tag_super)
+ insert('end', " or\nsubscript effects like X")
+ insert('end', "i", style_tag_sub)
+ insert('end', ".\n")
+ insert('end', "\n9. Margins.", style_tag_big)
+ insert('end', " You can control the amount of extra space left")
+ insert('end', " on\neach side of the text:\n")
+ insert('end', "This paragraph is an example of the use of ", style_tag_margins)
+ insert('end', "margins. It consists of a single line of text ", style_tag_margins)
+ insert('end', "that wraps around on the screen. There are two ", style_tag_margins)
+ insert('end', "separate left margin values, one for the first ", style_tag_margins)
+ insert('end', "display line associated with the text line, ", style_tag_margins)
+ insert('end', "and one for the subsequent display lines, which ", style_tag_margins)
+ insert('end', "occur because of wrapping. There is also a ", style_tag_margins)
+ insert('end', "separate specification for the right margin, ", style_tag_margins)
+ insert('end', "which is used to choose wrap points for lines.\n", style_tag_margins)
+ insert('end', "\n10. Spacing.", style_tag_big)
+ insert('end', " You can control the spacing of lines with three\n")
+ insert('end', "separate parameters. \"Spacing1\" tells how much ")
+ insert('end', "extra space to leave\nabove a line, \"spacing3\" ")
+ insert('end', "tells how much space to leave below a line,\nand ")
+ insert('end', "if a text line wraps, \"spacing2\" tells how much ")
+ insert('end', "space to leave\nbetween the display lines that ")
+ insert('end', "make up the text line.\n")
+ insert('end', "These indented paragraphs illustrate how spacing ", style_tag_spacing)
+ insert('end', "can be used. Each paragraph is actually a ", style_tag_spacing)
+ insert('end', "single line in the text widget, which is ", style_tag_spacing)
+ insert('end', "word-wrapped by the widget.\n", style_tag_spacing)
+ insert('end', "Spacing1 is set to 10 points for this text, ", style_tag_spacing)
+ insert('end', "which results in relatively large gaps between ", style_tag_spacing)
+ insert('end', "the paragraphs. Spacing2 is set to 2 points, ", style_tag_spacing)
+ insert('end', "which results in just a bit of extra space ", style_tag_spacing)
+ insert('end', "within a pararaph. Spacing3 isn't used ", style_tag_spacing)
+ insert('end', "in this example.\n", style_tag_spacing)
+ insert('end', "To see where the space is, select ranges of ", style_tag_spacing)
+ insert('end', "text within these paragraphs. The selection ", style_tag_spacing)
+ insert('end', "highlight will cover the extra space.", style_tag_spacing)
+
+}
+
diff --git a/ext/tk/sample/demos-en/tcolor b/ext/tk/sample/demos-en/tcolor
new file mode 100644
index 0000000000..5b29797906
--- /dev/null
+++ b/ext/tk/sample/demos-en/tcolor
@@ -0,0 +1,521 @@
+#!/usr/bin/env ruby
+#
+# tcolor --
+# simple color editor which supports RGB, HSB and CYM color space
+#
+# Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp)
+# last update: Thu Jun 18 06:32:35 JST 1998
+#
+
+require "tk"
+
+
+# use TkVariable instance for the variable which is changed by Tk interpreter
+
+$colorSpace = TkVariable.new(:rgb)
+$master = nil
+$red = 65535
+$green = 0
+$blue = 0
+$color = "#ffff00000000"
+$updating = TkVariable.new(0)
+$autoUpdate = TkVariable.new(1)
+$name = TkVariable.new($color)
+$command = TkVariable.new("print(%%,\"\n\")")
+# $command = TkVariable.new("")
+$label1 = TkVariable.new("label1")
+$label2 = TkVariable.new("label2")
+$label3 = TkVariable.new("label3")
+
+
+# setup the entry of the resourc database
+if (TkVarAccess.new('tcl_platform')['platform'] == 'unix')
+ TkOptionDB.add('*Entry.background', 'white')
+end
+
+
+# methods for events
+
+def rgbToHsv(red,green,blue)
+
+ if ( red > green )
+ max = red
+ min = green
+ else
+ max = green
+ min = red
+ end
+
+ if ( blue > max )
+ max = blue
+ else
+ if ( blue < min )
+ min = blue
+ end
+ end
+
+ range = max - min
+
+ if ( max == 0 )
+ sat = 0.0
+ else
+ sat = (max-min)/max
+ end
+
+ if ( sat == 0 )
+ hue = 0.0
+ else
+ rc = (max-red)/range
+ gc = (max-green)/range
+ bc = (max-blue)/range
+ if ( red == max )
+ hue = 0.166667 * (bc - gc)
+ else
+ if ( green == max )
+ hue = 0.166667 * (2.0 + rc - bc)
+ else
+ hue = 0.166667 * (4.0 + gc - rc)
+ end
+ end
+ if ( hue < 0.0 )
+ hue = hue + 1.0
+ end
+ end
+
+ [hue,sat,max/65535]
+end
+
+
+def hsbToRgb(hue,sat,value)
+ v = 65535.0 * value
+ if( sat == 0 )
+ ans = [v,v,v]
+ else
+ hue = hue*6.0
+ if ( hue >= 6 )
+ hue = 0.0
+ end
+ i = hue.to_i
+ f = hue - i
+ p = 65535.0 * value * (1.0 - sat)
+ q = 65535.0 * value * (1.0 - (sat * f))
+ t = 65535.0 * value * (1.0 - (sat * (1.0 - f)))
+ case i
+ when 0
+ ans = [v,t,p]
+ when 1
+ ans = [q,v,p]
+ when 2
+ ans = [p,v,t]
+ when 3
+ ans = [p,q,v]
+ when 4
+ ans = [t,p,v]
+ when 5
+ ans = [v,p,q]
+ else
+ raise(eException,"i value #{i} is out of range")
+ end
+ end
+ return ans
+end
+
+
+def doUpdate
+ newCmd = $command.to_s.gsub("%%","\"#{$color}\"")
+ eval(newCmd)
+end
+
+
+def tc_scaleChanged
+ if( $updating.to_i == 1 )
+ return
+ end
+
+ $master = :scale if $master == nil
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ $red = (scale1.get * 65.535).to_i
+ $green = (scale2.get * 65.535).to_i
+ $blue = (scale3.get * 65.535).to_i
+ when :cmy
+ $red = (65535 - scale1.get * 65.535).to_i
+ $green = (65535 - scale2.get * 65.535).to_i
+ $blue = (65535 - scale3.get * 65.535).to_i
+ when :hsb
+ list = hsbToRgb(scale1.get / 1000.0,
+ scale2.get / 1000.0,
+ scale3.get / 1000.0)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+ $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i)
+ $name.value = $color if $master == :scale
+ $root.middle.right.set_color($color)
+ if( $autoUpdate.to_i == 1 )
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :scale
+end
+
+
+def tc_setScales
+ $updating.value = 1
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ scale1.set($red / 65.535)
+ scale2.set($green / 65.535)
+ scale3.set($blue / 65.535)
+ when :cmy
+ scale1.set((65535 - $red) / 65.535)
+ scale2.set((65535 - $green) / 65.535)
+ scale3.set((65535 - $blue) / 65.535)
+ when :hsb
+ list = rgbToHsv($red,$green,$blue)
+ scale1.set( list[0] * 1000.0 )
+ scale2.set( list[1] * 1000.0 )
+ scale3.set( list[2] * 1000.0 )
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+
+ $updating.value = 0
+end
+
+
+def tc_loadNamedColor(name)
+ $name.value = name
+ $master = :name if $master == nil
+ if name[0,1] != "#"
+ list = TkWinfo.rgb($root.middle.right.swatch,name)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ case name.length
+ when 4
+ format = /#(.{1})(.{1})(.{1})/
+ shift = 12
+ when 7
+ format = /#(.{2})(.{2})(.{2})/
+ shift = 8
+ when 10
+ format = /#(.{3})(.{3})(.{3})/
+ shift = 4
+ when 13
+ format = /#(.{4})(.{4})(.{4})/
+ shift = 0
+ else
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ name.scan(format){|strlist|
+ if strlist.length != 3
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ $red = strlist[0].hex
+ $green = strlist[1].hex
+ $blue = strlist[2].hex
+ }
+ $red = $red << shift
+ $green = $green << shift
+ $blue = $blue << shift
+ end
+
+ tc_setScales
+ $color = format("#%04x%04x%04x",$red,$green,$blue)
+ $root.middle.right.set_color($color)
+ if $autoUpdate.to_i == 1
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :name
+end
+
+
+def changeColorSpace(space)
+ case space
+ when :rgb
+ $label1.value = "Red"
+ $label2.value = "Green"
+ $label3.value = "Blue"
+ when :cmy
+ $label1.value = "Cyan"
+ $label2.value = "Magenta"
+ $label3.value = "Yellow"
+ when :hsb
+ $label1.value = "Hue"
+ $label2.value = "Saturation"
+ $label3.value = "Brightness"
+ end
+ tc_setScales
+end
+
+
+# menu
+
+class TkColorMenuFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=>"raised",
+ "borderwidth"=>"2")
+
+ # File menubutton
+ @file = TkMenubutton.new(self){|button|
+
+ # File menu
+ @file_menu = TkMenu.new(button){
+ add "radio",
+ "label" => "RGB color space",
+ "variable" => $colorSpace,
+ "value" => :rgb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:rgb)}
+ add "radio",
+ "label" => "CMY color space",
+ "variable" => $colorSpace,
+ "value" => :cmy,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:cmy)}
+ add "radio",
+ "label" => "HSB color space",
+ "variable" => $colorSpace,
+ "value" => :hsb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:hsb)}
+ add "separator"
+ add "radio",
+ "label" => "Automatic updates",
+ "variable" => $autoUpdate,
+ "value" => "1",
+ "underline" => "0"
+ add "radio",
+ "label" => "Manual updates",
+ "variable" => $autoUpdate,
+ "value" => "0",
+ "underline" => "0"
+ add "separator"
+ add "command",
+ "label" => "Exit program",
+ "underline" => "0",
+ "command" => proc{exit}
+ }
+
+ # assign File menu to File button
+ menu @file_menu
+
+ text "File"
+ underline "0"
+ }.pack("side"=>"left")
+
+ self
+ end
+end
+
+
+# bottom frame
+class TkColorBotFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> 2)
+
+ @commandLabel = TkLabel.new(self,
+ "text"=> "Command:")
+ @command = TkEntry.new(self,
+ "relief"=> "sunken",
+ "borderwidth"=> "2",
+ "textvariable"=> $command,
+ "font"=> "-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @update = TkButton.new(self,
+ "text"=> "Update",
+ "command"=> proc{doUpdate})
+ @commandLabel.pack("side"=>"left")
+ @update.pack("side"=>"right","pady"=>".1c","padx"=>".25c")
+ @command.pack("expand"=>"yes","fill"=>"x","ipadx"=>".25c")
+
+ self
+ end
+end
+
+
+# left side frame of middle level
+class TkColorMiddleLeftFrame<TkFrame
+ def initialize(parent)
+ super(parent)
+
+ for i in ["/usr/local/lib/X11rgb.txt","/usr/lib/X11/rgb.txt",
+ "/X11/R5/lib/X11/rgb.txt","/X11/R4/lib/rgb/rgb.txt",
+ "/usr/openwin/lib/X11/rgb.txt"]
+ if !File.readable?(i)
+ next
+ end
+ f = File.open(i)
+ @scroll = TkScrollbar.new(self,
+ "orient"=>"vertical",
+ "relief"=>"sunken",
+ "borderwidth"=>"2")
+ @scroll.pack("side"=>"right","fill"=>"y")
+ @names = TkListbox.new(self,
+ "width"=>"20",
+ "height"=>"12",
+ "yscrollcommand"=> proc{|first,last| @scroll.set first,last},
+ "relief"=>"sunken",
+ "borderwidth"=>"2",
+ "exportselection"=>"false")
+ @scroll.command(proc{|*args| @names.yview(*args)})
+ @names.bind("Double-1",proc{
+ tc_loadNamedColor(@names.get(@names.curselection))})
+ @names.pack("side"=>"left")
+ while (line = f.gets)
+ line.chop!
+ linelist = line.split(/[ \t]+/)
+ if linelist.length == 4
+ @names.insert("end",linelist[3])
+ end
+ end
+ f.close
+ break
+ end
+
+ self
+ end
+end
+
+
+# middle frame of middle level
+class TkColorMiddleMiddleFrame<TkFrame
+ attr_reader :scale1, :scale2, :scale3
+
+ def initialize(parent)
+ super(parent)
+
+ @f1 = TkFrame.new(self)
+ @f2 = TkFrame.new(self)
+ @f3 = TkFrame.new(self)
+ @f4 = TkFrame.new(self)
+
+ for f in [@f1,@f2,@f3]
+ f.pack("side"=>"top","expand"=>"yes")
+ end
+ @f4.pack("side"=>"top","expand"=>"yes","fill"=>"x")
+
+ @label1 = TkLabel.new(self,"textvariable"=>$label1)
+ @scale1 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale1.pack("side"=>"top","anchor"=>"w")
+ @label1.pack("side"=>"top","anchor"=>"w")
+
+ @label2 = TkLabel.new(self,"textvariable"=>$label2)
+ @scale2 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale2.pack("side"=>"top","anchor"=>"w")
+ @label2.pack("side"=>"top","anchor"=>"w")
+
+ @label3 = TkLabel.new(self,"textvariable"=>$label3)
+ @scale3 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale3.pack("side"=>"top","anchor"=>"w")
+ @label3.pack("side"=>"top","anchor"=>"w")
+
+ @nameLabel = TkLabel.new(self,"text"=>"Name:")
+ @name = TkEntry.new(self,"relief"=>"sunken","borderwidth"=>"2",
+ "textvariable"=>$name,"width"=>"10",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @nameLabel.pack("side"=>"left")
+ @name.pack("side"=>"right", "expand"=>"1", "fill"=>"x")
+ @name.bind("Return",proc{tc_loadNamedColor $name.to_s})
+
+ self
+ end
+end
+
+
+class TkColorMiddleRightFrame<TkFrame
+ attr_reader :swatch
+
+ def initialize(parent)
+ super(parent)
+ @swatch = TkFrame.new(self, "width"=>"2c", "height"=>"5c",
+ "background"=>$color)
+ @value = TkLabel.new(self,
+ "text"=>$color,
+ "width"=>"13",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @swatch.pack("side"=>"top","expand"=>"yes","fill"=>"both")
+ @value.pack("side"=>"bottom","pady"=>".25c")
+
+ self
+ end
+
+ def set_color(color)
+ @swatch["background"] = color
+ @value["text"] = color
+ end
+end
+
+
+
+# middle level frame
+class TkColorMiddleFrame<TkFrame
+ attr_reader :left, :middle, :right
+
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> "2")
+
+ @left = TkColorMiddleLeftFrame.new(self)
+ @left.pack("side"=>"left","padx"=>".25c","pady"=>".25c")
+
+ @middle = TkColorMiddleMiddleFrame.new(self)
+ @middle.pack("side"=>"left","expand"=>"yes","fill"=>"y")
+
+ @right = TkColorMiddleRightFrame.new(self)
+ @right.pack("side"=>"left","padx"=>".25c","pady"=>".25c","anchor"=>"s")
+
+ self
+ end
+end
+
+
+class TkColor<TkRoot
+ attr_reader :menu, :bottom, :middle
+
+ def initialize(*args)
+ super(*args)
+ @menu = TkColorMenuFrame.new(self)
+ @menu.pack("side"=>"top", "fill"=>"x")
+
+ @bottom = TkColorBotFrame.new(self)
+ @bottom.pack("side"=>"bottom","fill"=>"x")
+
+ @middle = TkColorMiddleFrame.new(self)
+ @middle.pack("side"=>"top","fill"=>"both")
+
+ self
+ end
+end
+
+
+$root = TkColor.new
+changeColorSpace :rgb
+
+# start eventloop
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/tcolor.bak b/ext/tk/sample/demos-en/tcolor.bak
new file mode 100644
index 0000000000..5464aebae2
--- /dev/null
+++ b/ext/tk/sample/demos-en/tcolor.bak
@@ -0,0 +1,513 @@
+#!/usr/local/bin/ruby
+#
+# tcolor --
+# ¤³¤Î¥¹¥¯¥ê¥×¥È¤ÏRGB,HSB,CYM·Á¼°¤ò¥µ¥Ý¡¼¥È¤¹¤ë
+# ´Ê°×¥«¥é¡¼¥¨¥Ç¥£¥¿¤Ç¤¹¡£
+#
+# Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp)
+# last update: Thu Jun 18 06:32:35 JST 1998
+#
+
+# ¤Þ¤º¤Ïtk.rb¤òÆÉ¤ß¹þ¤à¡£
+
+require "tk"
+
+
+# Tk¤Ë¤è¤Ã¤ÆÊѹ¹¤µ¤ì¤ëÊÑ¿ô¤ÏTkVariable¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ò»È¤¦¡£
+
+$colorSpace = TkVariable.new(:rgb)
+$red = 65535
+$green = 0
+$blue = 0
+$color = "#ffff00000000"
+$updating = TkVariable.new(0)
+$autoUpdate = TkVariable.new(1)
+$name = TkVariable.new("")
+# $command = TkVariable.new("print(%%,\"\n\")")
+$command = TkVariable.new("")
+$label1 = TkVariable.new("label1")
+$label2 = TkVariable.new("label2")
+$label3 = TkVariable.new("label3")
+
+
+# ³Æ¥¤¥Ù¥ó¥ÈÍѤΥ᥽¥Ã¥É
+
+def rgbToHsv(red,green,blue)
+
+ if ( red > green )
+ max = red
+ min = green
+ else
+ max = green
+ min = red
+ end
+
+ if ( blue > max )
+ max = blue
+ else
+ if ( blue < min )
+ min = blue
+ end
+ end
+
+ range = max - min
+
+ if ( max == 0 )
+ sat = 0.0
+ else
+ sat = (max-min)/max
+ end
+
+ if ( sat == 0 )
+ hue = 0.0
+ else
+ rc = (max-red)/range
+ gc = (max-green)/range
+ bc = (max-blue)/range
+ if ( red == max )
+ hue = 0.166667 * (bc - gc)
+ else
+ if ( green == max )
+ hue = 0.166667 * (2.0 + rc - bc)
+ else
+ hue = 0.166667 * (4.0 + gc - rc)
+ end
+ end
+ if ( hue < 0.0 )
+ hue = hue + 1.0
+ end
+ end
+
+ [hue,sat,max/65535]
+end
+
+
+def hsbToRgb(hue,sat,value)
+ v = 65535.0 * value
+ if( sat == 0 )
+ ans = [v,v,v]
+ else
+ hue = hue*6.0
+ if ( hue >= 6 )
+ hue = 0.0
+ end
+ i = hue.to_i
+ f = hue - i
+ p = 65535.0 * value * (1.0 - sat)
+ q = 65535.0 * value * (1.0 - (sat * f))
+ t = 65535.0 * value * (1.0 - (sat * (1.0 - f)))
+ case i
+ when 0
+ ans = [v,t,p]
+ when 1
+ ans = [q,v,p]
+ when 2
+ ans = [p,v,t]
+ when 3
+ ans = [p,q,v]
+ when 4
+ ans = [t,p,v]
+ when 5
+ ans = [v,p,q]
+ else
+ raise(eException,"i value #{i} is out of range")
+ end
+ end
+ return ans
+end
+
+
+def doUpdate
+ newCmd = $command.to_s.gsub("%%","\"#{$color}\"")
+ eval(newCmd)
+end
+
+
+def tc_scaleChanged
+ if( $updating.to_i == 1 )
+ return
+ end
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.to_i
+ when :rgb
+ $red = (scale1.get * 65.535).to_i
+ $green = (scale2.get * 65.535).to_i
+ $blue = (scale3.get * 65.535).to_i
+ when :cmy
+ $red = (65535 - scale1.get * 65.535).to_i
+ $green = (65535 - scale2.get * 65.535).to_i
+ $blue = (65535 - scale3.get * 65.535).to_i
+ when :hsb
+ list = hsbToRgb(scale1.get / 1000.0,
+ scale2.get / 1000.0,
+ scale3.get / 1000.0)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+ $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i)
+ $root.middle.right.set_color($color)
+ if( $autoUpdate.to_i == 1 )
+ doUpdate
+ end
+ Tk.update(TRUE)
+end
+
+
+def tc_setScales
+ $updating.value = 1
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.to_i
+ when :rgb
+ scale1.set($red / 65.535)
+ scale2.set($green / 65.535)
+ scale3.set($blue / 65.535)
+ when :cmy
+ scale1.set((65535 - $red) / 65.535)
+ scale2.set((65535 - $green) / 65.535)
+ scale3.set((65535 - $blue) / 65.535)
+ when :hsb
+ list = rgbToHsv($red,$green,$blue)
+ scale1.set( list[0] * 1000.0 )
+ scale2.set( list[1] * 1000.0 )
+ scale3.set( list[2] * 1000.0 )
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+
+ $updating.value = 0
+end
+
+
+def tc_loadNamedColor(name)
+ if name[0,1] != "#"
+ list = TkWinfo.rgb($root.middle.right.swatch,name)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ case name.length
+ when 4
+ format = /#(.{1})(.{1})(.{1})/
+ shift = 12
+ when 7
+ format = /#(.{2})(.{2})(.{2})/
+ shift = 8
+ when 10
+ format = /#(.{3})(.{3})(.{3})/
+ shift = 4
+ when 13
+ format = /#(.{4})(.{4})(.{4})/
+ shift = 0
+ else
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ name.scan(format){|strlist|
+ if strlist.length != 3
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ $red = strlist[0].to_i
+ $green = strlist[1].to_i
+ $blue = strlist[2].to_i
+ }
+ $red = $red << shift
+ $green = $green << shift
+ $blue = $blue << shift
+ end
+
+ tc_setScales
+ $color = format("#%04x%04x%04x",$red,$green,$blue)
+ $root.middle.right.set_color($color)
+ if $autoUpdate.to_i == 1
+ doUpdate
+ end
+end
+
+
+def changeColorSpace(space)
+ case space
+ when :rgb
+ $label1.value = "Red"
+ $label2.value = "Green"
+ $label3.value = "Blue"
+ when :cmy
+ $label1.value = "Cyan"
+ $label2.value = "Magenta"
+ $label3.value = "Yellow"
+ when :hsb
+ $label1.value = "Hue"
+ $label2.value = "Saturation"
+ $label3.value = "Brightness"
+ end
+ tc_setScales
+end
+
+
+
+
+
+# tcolorÍѤΥá¥Ë¥å¡¼
+
+class TkColorMenuFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=>"raised",
+ "borderwidth"=>"2")
+
+ # File¥á¥Ë¥å¡¼¥Ü¥¿¥ó¤ÎÀ¸À®
+ @file = TkMenubutton.new(self){|button|
+
+ # File¥á¥Ë¥å¡¼¤ÎºîÀ®
+ @file_menu = TkMenu.new(button){
+ add "radio",
+ "label" => "RGB color space",
+ "variable" => $colorSpace,
+ "value" => :rgb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:rgb)}
+ add "radio",
+ "label" => "CMY color space",
+ "variable" => $colorSpace,
+ "value" => :cmy,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:cmy)}
+ add "radio",
+ "label" => "HSB color space",
+ "variable" => $colorSpace,
+ "value" => :hsb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:hsb)}
+ add "separator"
+ add "radio",
+ "label" => "Qutomatic updates",
+ "variable" => $autoUpdate,
+ "value" => "1",
+ "underline" => "0"
+ add "radio",
+ "label" => "Manual updates",
+ "variable" => $autoUpdate,
+ "value" => "0",
+ "underline" => "0"
+ add "separator"
+ add "command",
+ "label" => "Exit program",
+ "underline" => "0",
+ "command" => proc{exit}
+ }
+
+ # File¥á¥Ë¥å¡¼¤ÈFile¥Ü¥¿¥ó¤ò´ØÏ¢ÉÕ¤±¤ë
+ menu @file_menu
+
+ text "File"
+ underline "0"
+ }.pack("side"=>"left")
+
+ self
+ end
+end
+
+
+# ²¼Éô¤Î¥Õ¥ì¡¼¥à¤Î¤¿¤á¤Î¥¯¥é¥¹
+class TkColorBotFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> 2)
+
+ @commandLabel = TkLabel.new(self,
+ "text"=> "Command:")
+ @command = TkEntry.new(self,
+ "relief"=> "sunken",
+ "borderwidth"=> "2",
+ "textvariable"=> $command,
+ "font"=> "-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @update = TkButton.new(self,
+ "text"=> "Update",
+ "command"=> proc{doUpdate})
+ @commandLabel.pack("side"=>"left")
+ @update.pack("side"=>"right","pady"=>".1c","padx"=>".25c")
+ @command.pack("expand"=>"yes","fill"=>"x","ipadx"=>".25c")
+
+ self
+ end
+end
+
+
+# ÃæÃʺ¸¤Î¥Õ¥ì¡¼¥à
+class TkColorMiddleLeftFrame<TkFrame
+ def initialize(parent)
+ super(parent)
+
+ for i in ["/usr/local/lib/X11rgb.txt","/usr/lib/X11/rgb.txt",
+ "/X11/R5/lib/X11/rgb.txt","/X11/R4/lib/rgb/rgb.txt",
+ "/usr/openwin/lib/X11/rgb.txt"]
+ if !File.readable?(i)
+ next
+ end
+ f = File.open(i)
+ @scroll = TkScrollbar.new(self,
+ "orient"=>"vertical",
+ "relief"=>"sunken",
+ "borderwidth"=>"2")
+ @scroll.pack("side"=>"right","fill"=>"y")
+ @names = TkListbox.new(self,
+ "width"=>"20",
+ "height"=>"12",
+ "yscrollcommand"=> proc{|first,last| @scroll.set first,last},
+ "relief"=>"sunken",
+ "borderwidth"=>"2",
+ "exportselection"=>"false")
+ @scroll.command(proc{|*args| @names.yview *args})
+ @names.bind("Double-1",proc{
+ tc_loadNamedColor(@names.get(@names.curselection))})
+ @names.pack("side"=>"left")
+ while (line = f.gets)
+ line.chop!
+ linelist = line.split(/[ \t]+/)
+ if linelist.length == 4
+ @names.insert("end",linelist[3])
+ end
+ end
+ f.close
+ break
+ end
+
+ self
+ end
+end
+
+
+# ÃæÃÊÃæ±û¤Î¥Õ¥ì¡¼¥à
+class TkColorMiddleMiddleFrame<TkFrame
+ # @scale1,@scale2,@scale3¤ò³°Éô¤«¤é»²¾È¤Î¤ßµö²Ä¤¹¤ë¡£(Êѹ¹ÉÔ²Ä)
+ attr_reader :scale1, :scale2, :scale3
+
+ def initialize(parent)
+ super(parent)
+
+ @f1 = TkFrame.new(self)
+ @f2 = TkFrame.new(self)
+ @f3 = TkFrame.new(self)
+ @f4 = TkFrame.new(self)
+
+ for f in [@f1,@f2,@f3]
+ f.pack("side"=>"top","expand"=>"yes")
+ end
+ @f4.pack("side"=>"top","expand"=>"yes","fill"=>"x")
+
+ @label1 = TkLabel.new(self,"textvariable"=>$label1)
+ @scale1 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale1.pack("side"=>"top","anchor"=>"w")
+ @label1.pack("side"=>"top","anchor"=>"w")
+
+ @label2 = TkLabel.new(self,"textvariable"=>$label2)
+ @scale2 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale2.pack("side"=>"top","anchor"=>"w")
+ @label2.pack("side"=>"top","anchor"=>"w")
+
+ @label3 = TkLabel.new(self,"textvariable"=>$label3)
+ @scale3 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale3.pack("side"=>"top","anchor"=>"w")
+ @label3.pack("side"=>"top","anchor"=>"w")
+
+ @nameLabel = TkLabel.new(self,"text"=>"Name:")
+ @name = TkEntry.new(self,"relief"=>"sunken","borderwidth"=>"2",
+ "textvariable"=>$name,"width"=>"10",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @nameLabel.pack("side"=>"left")
+ @name.pack("side"=>"right", "expand"=>"1", "fill"=>"x")
+ @name.bind("Return",proc{tc_loadNamedColor $name.to_s})
+
+ self
+ end
+end
+
+
+class TkColorMiddleRightFrame<TkFrame
+ attr_reader :swatch
+
+ def initialize(parent)
+ super(parent)
+ @swatch = TkFrame.new(self, "width"=>"2c", "height"=>"5c",
+ "background"=>$color)
+ @value = TkLabel.new(self,
+ "text"=>$color,
+ "width"=>"13",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @swatch.pack("side"=>"top","expand"=>"yes","fill"=>"both")
+ @value.pack("side"=>"bottom","pady"=>".25c")
+
+ self
+ end
+
+ def set_color(color)
+ @swatch["background"] = color
+ @value["text"] = color
+ end
+end
+
+
+
+# ÃæÃʤΥե졼¥à
+class TkColorMiddleFrame<TkFrame
+ attr_reader :left, :middle, :right
+
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> "2")
+
+ @left = TkColorMiddleLeftFrame.new(self)
+ @left.pack("side"=>"left","padx"=>".25c","pady"=>".25c")
+
+ @middle = TkColorMiddleMiddleFrame.new(self)
+ @middle.pack("side"=>"left","expand"=>"yes","fill"=>"y")
+
+ @right = TkColorMiddleRightFrame.new(self)
+ @right.pack("side"=>"left","padx"=>".25c","pady"=>".25c","anchor"=>"s")
+
+ self
+ end
+end
+
+
+class TkColor<TkRoot
+ attr_reader :menu, :bottom, :middle
+
+ def initialize
+ super
+ @menu = TkColorMenuFrame.new(self)
+ @menu.pack("side"=>"top", "fill"=>"x")
+
+ @bottom = TkColorBotFrame.new(self)
+ @bottom.pack("side"=>"bottom","fill"=>"x")
+
+ @middle = TkColorMiddleFrame.new(self)
+ @middle.pack("side"=>"top","fill"=>"both")
+
+ self
+ end
+end
+
+
+$root = TkColor.new
+
+# ¥¤¥Ù¥ó¥È¤òÂԤİ٤˥롼¥×¤ËÆþ¤ë¡£
+changeColorSpace :rgb
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/text.rb b/ext/tk/sample/demos-en/text.rb
new file mode 100644
index 0000000000..4bb4b6bc7e
--- /dev/null
+++ b/ext/tk/sample/demos-en/text.rb
@@ -0,0 +1,126 @@
+# text.rb
+#
+# This demonstration script creates a text widget that describes
+# the basic editing functions.
+#
+# text (basic facilities) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($text_demo) && $text_demo
+ $text_demo.destroy
+ $text_demo = nil
+end
+
+# demo toplevel widget
+$text_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Basic Facilities")
+ iconname("text")
+ positionWindow(w)
+}
+
+# version check
+if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0)
+ undo_support = false
+else
+ undo_support = true
+end
+
+# frame
+TkFrame.new($text_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $text_demo
+ $text_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'text'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# text
+TkText.new($text_demo){|t|
+ relief 'sunken'
+ bd 2
+ setgrid 1
+ height 30
+ if undo_support
+ undo true
+ autoseparators true
+ end
+ TkScrollbar.new($text_demo) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ #
+ insert('0.0', <<EOT)
+This window is a text widget. It displays one or more lines of text
+and allows you to edit the text. Here is a summary of the things you
+can do to a text widget:
+
+1. Scrolling. Use the scrollbar to adjust the view in the text window.
+
+2. Scanning. Press mouse button 2 in the text window and drag up or down.
+This will drag the text at high speed to allow you to scan its contents.
+
+3. Insert text. Press mouse button 1 to set the insertion cursor, then
+type text. What you type will be added to the widget.
+
+4. Select. Press mouse button 1 and drag to select a range of characters.
+Once you've released the button, you can adjust the selection by pressing
+button 1 with the shift key down. This will reset the end of the
+selection nearest the mouse cursor and you can drag that end of the
+selection by dragging the mouse before releasing the mouse button.
+You can double-click to select whole words or triple-click to select
+whole lines.
+
+5. Delete and replace. To delete text, select the characters you'd like
+to delete and type Backspace or Delete. Alternatively, you can type new
+text, in which case it will replace the selected text.
+
+6. Copy the selection. To copy the selection into this window, select
+what you want to copy (either here or in another application), then
+click button 2 to copy the selection to the point of the mouse cursor.
+
+7. Edit. Text widgets support the standard Motif editing characters
+plus many Emacs editing characters. Backspace and Control-h erase the
+character to the left of the insertion cursor. Delete and Control-d
+erase the character to the right of the insertion cursor. Meta-backspace
+deletes the word to the left of the insertion cursor, and Meta-d deletes
+the word to the right of the insertion cursor. Control-k deletes from
+the insertion cursor to the end of the line, or it deletes the newline
+character if that is the only thing left on the line. Control-o opens
+a new line by inserting a newline character to the right of the insertion
+cursor. Control-t transposes the two characters on either side of the
+insertion cursor. #{
+ if undo_support
+ undo_text = "Control-z undoes the last editing action performed,\nand "
+ case $tk_platform['platform']
+ when "unix", "macintosh"
+ undo_text << "Control-Shift-z"
+ else # 'windows'
+ undo_text << "Control-y"
+ end
+ undo_text << "redoes undone edits."
+ else
+ ""
+ end
+}
+
+7. Resize the window. This widget has been configured with the "setGrid"
+option on, so that if you resize the window it will always resize to an
+even number of characters high and wide. Also, if you make the window
+narrow you can see that long lines automatically wrap around onto
+additional lines so that all the information is always visible.
+EOT
+
+ set_insert('0.0')
+}
diff --git a/ext/tk/sample/demos-en/timer b/ext/tk/sample/demos-en/timer
new file mode 100644
index 0000000000..58a41d00c0
--- /dev/null
+++ b/ext/tk/sample/demos-en/timer
@@ -0,0 +1,136 @@
+#!/usr/bin/env ruby
+#
+# timer --
+# This script generates a counter with start,stop and reset buttons.
+#
+# Copyright (C) 1998 Takaaki Tateishi (ttate@jaist.ac.jp)
+# last update: Sat Jun 27 12:24:14 JST 1998
+#
+
+require "tk"
+require "thread"
+require "tkafter"
+
+$time = "0.00"
+$m = Mutex.new
+$loop = false
+
+def timer_stop
+ $loop = false
+ $m.lock
+end
+
+def timer_start
+ $loop = true
+ $m.unlock
+end
+
+def timer_reset
+ $time = "0.00"
+ $root.countframe.counter['text'] = $time
+end
+
+def timer_loop
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+ Tk.after(10,proc{timer_loop})
+end
+
+
+#
+# thread version
+#
+def timer_loop2
+ while true
+ $m.lock
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ sleep(0.01)
+ $m.unlock
+ end
+end
+
+#
+# TkAfter
+#
+def timer_loop3
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+end
+
+
+class CountFrame < TkFrame
+ attr_reader :counter
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ @counter = TkLabel.new(self,
+ 'text'=>$time,
+ 'relief'=>'raised')
+ @counter.pack('fill'=>'both')
+ self
+ end
+end
+
+
+class ButtonFrame < TkFrame
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+=begin
+ @stop = TkButton.new(self,
+ 'text'=>'Stop',
+ 'command'=>proc{timer_stop})
+ @start = TkButton.new(self,
+ 'text'=>'Start',
+ 'command'=>proc{timer_start})
+=end
+ @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled)
+ @start = TkButton.new(self, :text=>'Start', :state=>:normal)
+
+ @stop.command proc{
+ timer_stop
+ @start.state(:normal)
+ @stop.state(:disabled)
+ }
+ @start.command proc{
+ timer_start
+ @stop.state(:normal)
+ @start.state(:disabled)
+ }
+
+ @reset = TkButton.new(self,
+ 'text'=>'Reset',
+ 'command'=>proc{timer_reset})
+ for b in [@stop,@start,@reset]
+ b.pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+ end
+ end
+end
+
+
+class Timer < TkRoot
+ attr_reader :countframe
+
+ def initialize(*args)
+ super(*args)
+ @countframe = CountFrame.new(self)
+ @buttonframe = ButtonFrame.new(self)
+ for f in [@buttonframe,@countframe]
+ f.pack('side'=>'top', 'fill'=>'both')
+ end
+ self
+ end
+end
+
+
+$root = Timer.new
+
+#$thread = Thread.start{timer_loop2}
+#timer_loop
+TkAfter.new(10,-1,proc{timer_loop3}).start
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-en/tkencoding.rb b/ext/tk/sample/demos-en/tkencoding.rb
new file mode 100644
index 0000000000..727491a6ad
--- /dev/null
+++ b/ext/tk/sample/demos-en/tkencoding.rb
@@ -0,0 +1,42 @@
+# -*- ruby -*-
+#
+# tkencoding.rb
+# written by ttate@jaist.ac.jp
+
+class TclTkIp
+ alias __eval _eval
+ alias __invoke _invoke
+ private :__eval
+ private :__invoke
+
+ attr_accessor :encoding
+
+ def _eval(cmd)
+ if( @encoding )
+ _fromUTF8(__eval(_toUTF8(cmd,@encoding)),@encoding)
+ else
+ __eval(cmd)
+ end
+ end
+
+ def _invoke(*cmds)
+ if( @encoding )
+ cmds = cmds.collect{|cmd| _toUTF8(cmd,@encoding)}
+ _fromUTF8(__invoke(*cmds),@encoding)
+ else
+ __invoke(*cmds)
+ end
+ end
+end
+
+module Tk
+ INTERP = TkCore::INTERP
+
+ def encoding=(name)
+ INTERP.encoding = name
+ end
+
+ def encoding
+ INTERP.encoding
+ end
+end
diff --git a/ext/tk/sample/demos-en/twind.rb b/ext/tk/sample/demos-en/twind.rb
new file mode 100644
index 0000000000..24a4bcf706
--- /dev/null
+++ b/ext/tk/sample/demos-en/twind.rb
@@ -0,0 +1,285 @@
+# twind.rb
+#
+# This demonstration script creates a text widget with a bunch of
+# embedded windows.
+#
+# text (embedded windows) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($twind_demo) && $twind_demo
+ $twind_demo.destroy
+ $twind_demo = nil
+end
+
+# demo toplevel widget
+$twind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+# frame
+$twind_buttons = TkFrame.new($twind_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $twind_demo
+ $twind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'twind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$twind_text = nil
+TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font,
+ 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+#
+$tag_center = TkTextTag.new($twind_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag_buttons = TkTextTag.new($twind_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+$twind_text.insert('end', "A text widget can contain other widgets embedded ")
+$twind_text.insert('end', "it. These are called \"embedded windows\", ")
+$twind_text.insert('end', "and they can consist of arbitrary widgets. ")
+$twind_text.insert('end', "For example, here are two embedded button ")
+$twind_text.insert('end', "widgets. You can click on the first button to ")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'ON'
+ text 'Turn On'
+ command proc{textWindOn $twind_text,$twind_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', " horizontal scrolling, which also turns off ")
+$twind_text.insert('end', "word wrapping. Or, you can click on the second ")
+$twind_text.insert('end', "button to\n")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'OFF'
+ text 'Turn Off'
+ command proc{textWindOff $twind_text}
+ cursor 'top_left_arrow'
+ })
+
+$twind_text.insert('end', " horizontal scrolling and turn back on word wrapping.\n\n")
+$twind_text.insert('end', "Or, here is another example. If you ")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text 'Click Here'
+ command proc{textWindPlot $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', " a canvas displaying an x-y plot will appear right here.")
+$mark_plot = TkTextMark.new($twind_text, 'insert')
+$mark_plot.gravity='left'
+$twind_text.insert('end', " You can drag the data points around with the mouse, ")
+$twind_text.insert('end', "or you can click here to ")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text 'Delete'
+ command proc{textWindDel $twind_text}
+ cursor 'top_left_arrow'
+ })
+
+$twind_text.insert('end', " the plot again.\n\n")
+$twind_text.insert('end', "You may also find it useful to put embedded windows in ")
+$twind_text.insert('end', "a text without any actual text. In this case the ")
+$twind_text.insert('end', "text widget acts like a geometry manager. For ")
+$twind_text.insert('end', "example, here is a collection of buttons laid out ")
+$twind_text.insert('end', "neatly into rows by the text widget. These buttons ")
+$twind_text.insert('end', "can be used to change the background color of the ")
+$twind_text.insert('end', "text widget (\"Default\" restores the color to ")
+$twind_text.insert('end', "its default). If you click on the button labeled ")
+$twind_text.insert('end', "\"Short\", it changes to a longer string so that ")
+$twind_text.insert('end', "you can see how the text widget automatically ")
+$twind_text.insert('end', "changes the layout. Click on the button again ")
+$twind_text.insert('end', "to restore the short string.\n")
+
+
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {|b|
+ text 'Default'
+ command proc{embDefBg $twind_text}
+ cursor 'top_left_arrow'
+ $tag_buttons.add('end')
+ },
+ 'padx'=>3 )
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkCheckButton.new($twind_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+#
+def textWindOn (w,f)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff (w)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+ w.xscrollcommand ''
+ w.wrap 'word'
+end
+
+def textWindPlot (t)
+ if (defined? $twind_plot) && TkWinfo.exist?($twind_plot)
+ return
+ end
+
+ $twind_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+
+ TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind_plot.itembind('point', 'Any-Enter',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind_plot.itembind('point', 'Any-Leave',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y")
+ $twind_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind_plot.dtag 'selected'})
+ $twind_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y")
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot,"\n"
+ TkTextWindow.new($twind_text, $mark_plot, 'window'=>$twind_plot)
+ $tag_center.add $mark_plot
+ $twind_text.insert $mark_plot,"\n"
+end
+
+$embPlot = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def embPlotMove (w, x, y)
+ w.move 'selected', x - $embPlot['lastX'], y - $embPlot['lastY']
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def textWindDel (w)
+ if (defined? $twind_text) && TkWinfo.exist?($twind_plot)
+ $twind_text.delete $twind_plot
+ $twind_plot = nil
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot," "
+ end
+end
+
+def embDefBg (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/ext/tk/sample/demos-en/twind2.rb b/ext/tk/sample/demos-en/twind2.rb
new file mode 100644
index 0000000000..c42e0999d7
--- /dev/null
+++ b/ext/tk/sample/demos-en/twind2.rb
@@ -0,0 +1,382 @@
+#
+# text (embedded windows) widget demo 2 (called by 'widget')
+#
+
+# delete toplevel widget
+if defined?($twind2_demo) && $twind2_demo
+ $twind2_demo.destroy
+ $twind2_demo = nil
+end
+
+# demo toplevel widget
+$twind2_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows 2")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+# frame
+$twind2_buttons = TkFrame.new($twind2_demo) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'twind2'}),
+ TkButton.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $twind2_demo
+ $twind2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}
+$twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$twind2_text = nil
+TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
+ # 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'width'=>'70', 'height'=>35, 'wrap'=>'char',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+# text tags
+$tag2_center = TkTextTag.new($twind2_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag2_buttons = TkTextTag.new($twind2_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+# insert text
+$twind2_text.insert('end',
+ 'A text widget can contain many different kinds of items, ')
+$twind2_text.insert('end',
+ "both active and passive. It can lay these out in various ")
+$twind2_text.insert('end',
+ "ways, with wrapping, tabs, centering, etc. In addition, ")
+$twind2_text.insert('end',
+ "when the contents are too big for the window, smooth ")
+$twind2_text.insert('end', "scrolling in all directions is provided.\n\n")
+
+$twind2_text.insert('end', "A text widget can contain other widgets embedded ")
+$twind2_text.insert('end', "it. These are called \"embedded windows\", ")
+$twind2_text.insert('end', "and they can consist of arbitrary widgets. ")
+$twind2_text.insert('end', "For example, here are two embedded button ")
+$twind2_text.insert('end', "widgets. You can click on the first button to ")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'ON'
+ command proc{textWindOn2 $twind2_text,$twind2_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', " horizontal scrolling, which also turns off ")
+$twind2_text.insert('end', "word wrapping. Or, you can click on the second ")
+$twind2_text.insert('end', "button to\n")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'OFF'
+ command proc{textWindOff2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end',
+ " horizontal scrolling and turn back on word wrapping.\n\n")
+
+$twind2_text.insert('end', "Or, here is another example. If you ")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'Click Here'
+ command proc{textWindPlot2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end',
+ " a canvas displaying an x-y plot will appear right here.")
+$mark2_plot = TkTextMark.new($twind2_text, 'insert')
+$mark2_plot.gravity='left'
+$twind2_text.insert('end',
+ " You can drag the data points around with the mouse, ")
+$twind2_text.insert('end', "or you can click here to ")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'Delete'
+ command proc{textWindDel2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', " the plot again.\n\n")
+
+$twind2_text.insert('end',
+ "You may also find it useful to put embedded windows in ")
+$twind2_text.insert('end',
+ "a text without any actual text. In this case the ")
+$twind2_text.insert('end', "text widget acts like a geometry manager. For ")
+$twind2_text.insert('end',
+ "example, here is a collection of buttons laid out ")
+$twind2_text.insert('end',
+ "neatly into rows by the text widget. These buttons ")
+$twind2_text.insert('end',
+ "can be used to change the background color of the ")
+$twind2_text.insert('end', "text widget (\"Default\" restores the color to ")
+$twind2_text.insert('end',
+ "its default). If you click on the button labeled ")
+$twind2_text.insert('end', "\"Short\", it changes to a longer string so that ")
+$twind2_text.insert('end', "you can see how the text widget automatically ")
+$twind2_text.insert('end', "changes the layout. Click on the button again ")
+$twind2_text.insert('end', "to restore the short string.\n")
+
+btn_default = TkButton.new($twind2_text) {|b|
+ text 'Default'
+ command proc{embDefBg2 $twind2_text}
+ cursor 'top_left_arrow'
+}
+TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3)
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkCheckButton.new($twind2_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind2_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+$tag2_buttons.add(btn_default, 'end')
+
+$text_normal2 = {}
+$text_normal2['border'] = $twind2_text.cget('borderwidth')
+$text_normal2['highlight'] = $twind2_text.cget('highlightthickness')
+$text_normal2['pad'] = $twind2_text.cget('padx')
+
+$twind2_text.insert('end', "\nYou can also change the usual border width and ")
+$twind2_text.insert('end', "highlightthickness and padding.\n")
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigP2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallP2 $twind2_text
+ }))
+
+$twind2_text.insert('end',
+ "\n\nFinally, images fit comfortably in text widgets too:")
+
+TkTextImage.new($twind2_text, 'end',
+ 'image'=>TkBitmapImage.new(:file=>[
+ $demo_dir, '..',
+ 'images', 'face.xbm'
+ ].join(File::Separator)))
+
+# methods
+def textWinBigB2(w)
+ w.borderwidth 15
+end
+def textWinSmallB2(w)
+ w.borderwidth $text_normal2['border']
+end
+def textWinBigH2(w)
+ w.highlightthickness 15
+end
+def textWinSmallH2(w)
+ w.highlightthickness $text_normal2['highlight']
+end
+def textWinBigP2(w)
+ w.configure(:padx=>15, :pady=>15)
+end
+def textWinSmallP2(w)
+ w.configure(:padx=>$text_normal2['pad'], :pady=>$text_normal2['pad'])
+end
+
+def textWindOn2 (w,f)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind2_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff2 (w)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+ w.xscrollcommand ''
+ #w.wrap 'word'
+ w.wrap 'char'
+end
+
+def textWindPlot2 (t)
+ if (defined? $twind2_plot) && (TkWinfo.exist?($twind2_plot))
+ return
+ end
+
+ $twind2_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ #font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ font = 'Helvetica 18'
+
+ TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind2_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind2_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind2_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind2_plot.itembind('point', 'Any-Enter',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind2_plot.itembind('point', 'Any-Leave',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind2_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y")
+ $twind2_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind2_plot.dtag 'selected'})
+ $twind2_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y")
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot,"\n"
+ TkTextWindow.new($twind2_text, $mark2_plot, 'window'=>$twind2_plot)
+ $tag2_center.add $mark2_plot
+ $twind2_text.insert $mark2_plot,"\n"
+end
+
+$embPlot2 = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown2 (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def embPlotMove2 (w, x, y)
+ w.move 'selected', x - $embPlot2['lastX'], y - $embPlot2['lastY']
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def textWindDel2 (w)
+ if (defined? $twind2_text) && TkWinfo.exist?($twind2_plot)
+ $twind2_text.delete $twind2_plot
+ $twind2_plot = nil
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot," "
+ end
+end
+
+def embDefBg2 (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/ext/tk/sample/demos-en/unicodeout.rb b/ext/tk/sample/demos-en/unicodeout.rb
new file mode 100644
index 0000000000..07e3bf52b5
--- /dev/null
+++ b/ext/tk/sample/demos-en/unicodeout.rb
@@ -0,0 +1,112 @@
+# unicodeout.rb --
+#
+# This demonstration script shows how you can produce output (in label
+# widgets) using many different alphabets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($unicodeout_demo) && $unicodeout_demo
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+end
+
+$unicodeout_demo = TkToplevel.new {|w|
+ title("Unicode Label Demonstration")
+ iconname("unicodeout")
+ positionWindow(w)
+}
+
+TkLabel.new($unicodeout_demo,
+ :font=>$font, :wraplength=>'5.4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+This is a sample of Tk's support for languages that use non-Western \
+character sets. However, what you will actually see below depends \
+largely on what character sets you have installed, and what you see \
+for characters that are not present varies greatly between platforms as well. \
+Please try to click the 'See Code' button, \
+and click the 'Rerun Demo' button after editing \
+(the source file is not changed) \
+the definition of @@font on the Unicodeout_SampleFrame class.
+The strings are written in Tcl using UNICODE characters \
+using the \\uXXXX escape so as to do so in a portable fashion.
+
+ATTENTION:
+The strings are converted to the encoded string objects \
+(completed to rewrite Tcl's escapes) by Tk::UTF8_String method. \
+And the Tk::UTF8_String objects are passed to the label widgets.
+EOL
+
+TkFrame.new($unicodeout_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'unicodeout'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+wait_msg = TkLabel.new($unicodeout_demo,
+ :text=>"Please wait while loading fonts...",
+ :font=>"Helvetica 12 italic").pack
+
+class Unicodeout_SampleFrame < TkFrame
+ @@font = $font
+ # @@font = 'Helvetica 14'
+ # @@font = 'Courier 12'
+ # @@font = 'clearlyu 16'
+ # @@font = 'fixed 12'
+ # @@font = 'Times 12'
+ # @@font = 'Newspaper 12'
+ # @@font = '{New century schoolbook} 12'
+
+ def initialize()
+ super($unicodeout_demo)
+ grid_columnconfig(1, :weight=>1)
+ end
+
+ def add_sample(lang, *args)
+ sample_txt = Tk::UTF8_String(args.join(''))
+ l = TkLabel.new(self, :font=>@@font, :text=>lang+':',
+ :anchor=>:nw, :pady=>0)
+ #s = TkLabel.new(self, :font=>@@font, :text=>sample_txt,
+ s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt,
+ :anchor=>:nw, :width=>30, :pady=>0)
+ Tk.grid(l, s, :sticky=>:ew, :pady=>0)
+ l.grid_config(:padx, '1m')
+ end
+end
+f = Unicodeout_SampleFrame.new
+f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
+
+# Processing when some characters are missing might take a while, so make
+# sure we're displaying something in the meantime...
+
+oldCursor = $unicodeout_demo.cursor
+$unicodeout_demo.cursor('watch')
+Tk.update
+
+f.add_sample('Arabic',
+ '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94',
+ '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D')
+f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57')
+f.add_sample('Simpl. Chinese', '\u6C49\u8BED')
+f.add_sample('Greek',
+ '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ',
+ '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1')
+f.add_sample('Hebrew',
+ '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ',
+ '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9')
+f.add_sample('Japanese',
+ '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ',
+ '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA')
+f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00')
+f.add_sample('Russian',
+ '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ',
+ '\u044F\u0437\u044B\u043A')
+
+wait_msg.destroy
+$unicodeout_demo.cursor(oldCursor)
diff --git a/ext/tk/sample/demos-en/vscale.rb b/ext/tk/sample/demos-en/vscale.rb
new file mode 100644
index 0000000000..636b85813b
--- /dev/null
+++ b/ext/tk/sample/demos-en/vscale.rb
@@ -0,0 +1,78 @@
+# vscale.rb
+#
+# This demonstration script shows an example with a vertical scale.
+
+require "tkcanvas"
+
+if defined?($vscale_demo) && $vscale_demo
+ $vscale_demo.destroy
+ $vscale_demo = nil
+end
+
+$vscale_demo = TkToplevel.new {|w|
+ title("Vertical Scale Demonstration")
+ iconname("vscale")
+}
+positionWindow($vscale_demo)
+
+msg = TkLabel.new($vscale_demo) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+ text "An arrow and a vertical scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the size of the arrow."
+}
+msg.pack('side'=>'top', 'padx'=>'.5c')
+
+TkFrame.new($vscale_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc {
+ tmppath = $vscale_demo
+ $vscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc { showCode 'vscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+TkFrame.new($vscale_demo) {|frame|
+ borderwidth 10
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, 0, 0, 1, 1, 2, 2) {
+ fill 'SeaGreen3'
+ tags 'poly'
+ }
+ TkcLine.new(c, 0, 0, 1, 1, 2, 2, 0, 0) {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'left', 'anchor'=>'nw', 'fill'=>'y')
+ scale = TkScale.new(frame) {
+ orient 'vertical'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setHeight(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'left', 'anchor'=>'ne')
+ scale.set 75
+}.pack
+
+
+def setHeight(w, height)
+ height = height + 21
+ y2 = height - 30
+ if y2 < 21
+ y2 = 21
+ end
+ w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+ w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+end
diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget
new file mode 100644
index 0000000000..133d151d46
--- /dev/null
+++ b/ext/tk/sample/demos-en/widget
@@ -0,0 +1,822 @@
+#!/usr/bin/env ruby
+
+# widget --
+# This script demonstrates the various widgets provided by Tk,
+# along with many of the features of the Tk toolkit. This file
+# only contains code to generate the main window for the
+# application, which invokes individual demonstrations. The
+# code for the actual demonstrations is contained in separate
+# ".rb" files is this directory, which are sourced by this script
+# as needed.
+
+require 'tk'
+# require 'tkafter'
+
+### $DEBUG=1 ##########
+
+#----------------------------------------------------------------
+# The code below create the main window, consisting of a menu bar
+# and a text widget that explains how to use the program, plus lists
+# all of the demos as hypertext items.
+#----------------------------------------------------------------
+
+# widget demo directory
+$demo_dir = File.dirname($0)
+
+# root
+$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"}
+
+# tk
+$tk_version = Tk::TK_VERSION
+$tk_major_ver, $tk_minor_ver = $tk_version.split('.').map{|n| n.to_i}
+$tk_patchlevel = Tk::TK_PATCHLEVEL
+
+# tcl_platform
+$tk_platform = TkVarAccess.new('tcl_platform')
+
+#
+case($tk_version)
+when /^4.*/
+ $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil)
+else
+ $font = TkFont.new('Helvetica -12')
+end
+
+# images
+$image = {}
+
+if $tk_major_ver >= 8
+$image['refresh'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zCpnKdb/1z9mPypbKBtLGy9NMPL/9Or+6+P+4j1Y
+ PwQKBP7//xMLFAYBCAEBASH5BAEAAAAALAAAAAAQABAAAwR0EAD3Gn0Vyw0e
+ ++CncU7IIAezMA/nhUqSLJizvSdCEEjy2ZIV46AwDAoDHwPYGSoEiUJAAGJ6
+ EDHBNCFINW5OqABKSFk/B9lUa94IDwIFgewFMwQDQwCZQCztTgM9Sl8SOEMG
+ KSAthiaOjBMPDhQONBiXABEAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['view'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zP///8DAwICAgH9/fwAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAwRIcMhJB7h3hM33
+ KFjWdQQYap1QrCaGBmrRrS4nj5b53jOgbwXBKGACoYLDIuAoHCmZyYvR1rT5
+ RMAq8LqcIYGsrjPsW1XOmFUEADs=
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['delete'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAOAKEAAIQAAO/n3v///////yH5BAEKAAIALAAAAAAQAA4AAAIm
+ lI9pAKHbIHNoVhYhTdjlJ2AWKG2g+CldmB6rxo2uybYhbS80eRQAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['print'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK
+ UlpChFpCjFpGkFpSc1paa2NKc2NKnGNja2tapWtjc29KnHNanHNjc3NjrXNr
+ jHNrnHNzc3tjpXtrtXtzhICAgIRzvYSEjIZzqox7tYyEnIyMjJSEtZSEvZSM
+ lJyMtZyMvZyUlJyUrZyUvZycnKWctaWlpa2czq2lzrWtvbWtzrW1tb21xr21
+ 1sa9zs693s7OztbO3tbO597W1t7W7+fe7+fn5////+/n7+/v7+/v9////wAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAEEALAAAAAAaABMAQAj/AIMIHBhkg0GC
+ CBMGIQEiQgseQT4oeCBBAokgRYYQ0JBixg8hRIiUUEBBYYmTByBwiCBCRYwH
+ CxY8cKFw4AogRXLqLAJkQ80gCBBg3BkxZswTNGh4MGqgQQUMJRHCwMkTSE+D
+ Pn8eCKBhxIMhO3ei2OHDBw6sWSlMMMoWgwwfMDZI8GBjx44NARZwEGGi5MkS
+ PcIWKRGz5YgLbAco+KkQBQoJIRgjdGEVq+SaJajqtNrzMgsPCmoIzqmDgmWE
+ KOBuUKAAwYabYTfs4OHjY0giGyhk4MAWRI4eKyRQqPgggYUXPH4A+XBAgwoK
+ DiIsCFxjA9sFEVQQCRJCAYAFDJxiKhAxvMTonEFimrhhYinTBgWiCvxLNX3M
+ DkkpsKV5OYhjBxCMYAICAigUEAA7
+EOD
+end
+
+#
+TkMenubar.new($root,
+ [[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Meta-Q']
+ ]]).pack('side'=>'top', 'fill'=>'x')
+$root.bind('F1', proc{aboutBox})
+$root.bind('Meta-q', proc{exit})
+
+=begin
+TkFrame.new($root){|frame|
+ TkMenubutton.new(frame){|button|
+ m = TkMenu.new(button) {
+ add 'command', 'label'=>'Quit', 'command'=>proc{exit}, 'underline'=>0
+ }
+ menu m
+ text 'File'
+ underline 0
+ }.pack('side'=>'left')
+}.pack('side'=>'top', 'fill'=>'x')
+=end
+
+#
+if $tk_version =~ /^4\.[01]/
+ scr = TkScrollbar.new($root, 'orient'=>'vertical')
+ txt = TkText.new($root) {
+ wrap 'word'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+ scr.pack('side'=>'right', 'fill'=>'y')
+ txt.pack('expand'=>'yes', 'fill'=>'both')
+else
+ textFrame = TkFrame.new($root)
+ scr = TkScrollbar.new($root, 'orient'=>'vertical',
+ 'highlightthickness'=>0, 'takefocus'=>1) {
+ pack('in'=>textFrame, 'side'=>'right', 'fill'=>'y', 'padx'=>1)
+ }
+ txt = TkText.new($root) {
+ wrap 'word'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ highlightthickness 0
+ padx 4
+ pady 2
+ takefocus 0
+ bd 1
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both', 'padx'=>1)
+ txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both')
+# textFrame.pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>2)
+ textFrame.pack('expand'=>'yes', 'fill'=>'both')
+
+ statusBar = TkFrame.new($root) {|f|
+ $statusBarLabel = \
+ TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
+ TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ .pack('side'=>'left', 'padx'=>2)
+ }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+end
+
+# Create a bunch of tags to use in the text widget, such as those for
+# section titles and demo descriptions. Also define the bindings for
+# tags.
+
+tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+
+# We put some "space" characters to the left and right of each demo description
+# so that the descriptions are highlighted only when the mouse cursor
+# is right over them (but not when the cursor is to their left or right)
+
+tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c')
+
+if TkWinfo.depth($root) == 1
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ tag_hot = TkTextTag.new(txt, 'background'=>'black', 'foreground'=>'white')
+else
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'blue', 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'#303080', 'underline'=>1)
+# tag_hot = TkTextTag.new(txt, 'relief'=>'raised', 'borderwidth'=>1,
+# 'background'=>'SeaGreen3')
+ tag_hot = TkTextTag.new(txt, 'borderwidth'=>1, 'foreground'=>'red')
+end
+
+#tag_demo.bind('Button-1', proc{invoke txt, txt.index('current')})
+tag_demo.bind('ButtonRelease-1',
+ proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y')
+
+lastLine = TkVariable.new("")
+newLine = TkVariable.new("")
+tag_demo.bind('Enter', proc{|x,y|
+ lastLine.value = txt.index("@#{x},#{y} linestart")
+ tag_hot.add(lastLine.value, "#{lastLine.value} lineend")
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+tag_demo.bind('Leave',
+ proc{
+ tag_hot.remove('1.0','end')
+ txt.configure('cursor','xterm')
+ $statusBarLabel.configure('text'=>"")
+ })
+tag_demo.bind('Motion', proc{|x, y|
+ newLine.value = txt.index("@#{x},#{y} linestart")
+ if newLine.value != lastLine.value
+ tag_hot.remove('1.0','end')
+ lastLine.value = newLine.value
+ if ( txt.tag_names("@#{x},#{y}").find{|t|
+ t.kind_of?(String) && t =~ /^demo-/
+ } )
+ tag_hot.add(lastLine.value,
+ "#{lastLine.value} lineend -1 chars")
+ end
+ end
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+
+# Create the text for the text widget.
+
+txt.insert('end', "Ruby/Tk Widget Demonstrations\n\n", tag_title)
+txt.insert('end', <<EOT)
+This application provides a front end for several short scripts that \
+demonstrate what you can do with Tk widgets. Each of the numbered \
+lines below describes a demonstration; you can click on it to invoke \
+the demonstration. Once the demonstration window appears, you can \
+click the "See Code" button to see the Ruby/Tk code that created the \
+demonstration. If you wish, you can edit the code and click the \
+"Rerun Demo" button in the code window to reinvoke the demonstration \
+with the modified code.
+
+Some demo scripts require the recent version of Tk library \
+(e.g. Tk8.4 or later) \
+If your Tk library linked to Ruby doesn't support the functions \
+required by the demo script, the demo doesn't work. \
+In such a case, please re-compile tcltklib with the later Tk library \
+which supports the required functions.
+
+
+EOT
+
+txt.insert('end', "Labels, buttons, checkbuttons, and radiobuttons.\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Labels (text and bitmaps).\n", tag_demo, "demo-label")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Labels and UNICODE text. (if supported)\n", tag_demo, "demo-unicodeout")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Buttons.\n", tag_demo, "demo-button")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Checkbuttons (select any of a group).\n", tag_demo, "demo-check")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. Checkbuttons (if supported).\n", tag_demo, "demo-check2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. Radiobuttons (select one of a group).\n", tag_demo, "demo-radio")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. Radiobuttons (if supported 'compound' option).\n", tag_demo, "demo-radio2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. Radiobuttons (if supported).\n", tag_demo, "demo-radio3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. A 15-puzzle game made out of buttons.\n", tag_demo, "demo-puzzle")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "10. Iconic buttons that use bitmaps.\n", tag_demo, "demo-icon")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "11. Two labels displaying images.\n", tag_demo, "demo-image1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "12. A simple user interface for viewing images.\n", tag_demo, "demo-image2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "13. A simple user interface for viewing images. (if supported)\n", tag_demo, "demo-image3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "14. Labelled frames (if supported)\n", tag_demo, "demo-labelframe")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Listboxes\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. 50 states.\n", tag_demo, "demo-states")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Colors: change the color scheme for the application.\n", "#{tag_demo.id} demo-colors")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. A collection of famous sayings.\n", tag_demo, "demo-sayings")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Entries and Spin-boxes\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Without scrollbars.\n", tag_demo, "demo-entry1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. With scrollbars.\n", tag_demo, "demo-entry2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end',
+ "3. Validated entries and password fields. (if supported)\n",
+ tag_demo, "demo-entry3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Spin-boxes. (if supported)\n", tag_demo, "demo-spin")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. Simple Rolodex-like form.\n", tag_demo, "demo-form")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Text\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Basic editable text.\n", tag_demo, "demo-text")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Text display styles.\n", tag_demo, "demo-style")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Hypertext (tag bindings).\n", tag_demo, "demo-bind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. A text widget with embedded windows.\n", tag_demo, "demo-twind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. A text widget with embedded windows. (if supported)\n", tag_demo, "demo-twind2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. A search tool built with a text widget.\n", tag_demo, "demo-search")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Canvases\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. The canvas item types.\n", tag_demo, "demo-items")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. A simple 2-D plot.\n", tag_demo, "demo-plot")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Text items in canvases.\n", tag_demo, "demo-ctext")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. An editor for arrowheads on canvas lines.\n", tag_demo, "demo-arrow")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. A ruler with adjustable tab stops.\n", tag_demo, "demo-ruler")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. A building floor plan.\n", tag_demo, "demo-floor")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. A building floor plan. (another way to create canvas items)\n", tag_demo, "demo-floor2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. A simple scrollable canvas.\n", tag_demo, "demo-cscroll")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Scales\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Vertical scale.\n", tag_demo.id, "demo-vscale")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Horizontal scale.\n", tag_demo.id, "demo-hscale")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Paned Windows\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Horizontal paned window. (if supported)\n", tag_demo.id, "demo-paned1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Vertical paned window. (if supported)\n", tag_demo.id, "demo-paned2")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Menus\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Menus and cascades.\n", tag_demo, "demo-menu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Menus and cascades. (if supported)\n", tag_demo, "demo-menu84")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Menubuttons\n", tag_demo, "demo-menubu")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Common Dialogs\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Message boxes.\n", tag_demo, "demo-msgbox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. File selection dialog.\n", tag_demo, "demo-filebox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Color picker.\n", tag_demo, "demo-clrpick")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Miscellaneous\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. The built-in bitmaps.\n", tag_demo, "demo-bitmap")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. A dialog box with a local grab.\n", tag_demo, "demo-dialog1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. A dialog box with a global grab.\n", tag_demo, "demo-dialog2")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.state('disabled')
+scr.focus
+
+# positionWindow --
+# This procedure is invoked by most of the demos to position a
+# new demo window.
+#
+# Arguments:
+# w - The name of the window to position.
+
+def positionWindow(w)
+ w.geometry('+300+300')
+end
+
+# showVars --
+# Displays the values of one or more variables in a window, and
+# updates the display whenever any of the variables changes.
+#
+# Arguments:
+# w - Name of new window to create for display.
+# args - Any number of names of variables.
+
+$showVarsWin = {}
+def showVars1(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ w = TkToplevel.new(parent) {|w|
+ title "Variable values"
+ TkLabel.new(w) {
+ text "Variable values:"
+ width 20
+ anchor 'center'
+ font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ }.pack('side'=>'top', 'fill'=>'x')
+ len = 1
+ args.each{|vnam,vbody|
+ len = vnam.to_s.length if vnam.to_s.length > len
+ }
+ args.each{|vnam,vbody|
+ TkFrame.new(w){|f|
+ #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left')
+ TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left')
+ TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\
+ .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+ }.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x')
+ }
+ TkButton.new(w) {
+ text "OK"
+ command proc{w.destroy}
+ }.pack('side'=>'bottom', 'pady'=>2)
+ }
+ $showVarsWin[parent.path] = w
+end
+
+def showVars2(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ $showVarsWin[parent.path] = TkToplevel.new(parent) {|w|
+ title "Variable values"
+
+ TkLabelFrame.new(w, :text=>"Variable values:",
+ :font=>{:family=>'Helvetica', :size=>14}){|f|
+ args.each{|vnam,vbody|
+ TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'),
+ TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'),
+ :padx=>2, :pady=>2, :sticky=>'w')
+ }
+
+ f.grid(:sticky=>'news', :padx=>4)
+ f.grid_columnconfig(1, :weight=>1)
+ f.grid_rowconfig(100, :weight=>1)
+ }
+ TkButton.new(w, :text=>"OK", :width=>8, :default=>:active,
+ :command=>proc{w.destroy}){|b|
+ w.bind('Return', proc{b.invoke})
+ w.bind('Escape', proc{b.invoke})
+
+ b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4])
+ }
+ w.grid_columnconfig(0, :weight=>1)
+ w.grid_rowconfig(0, :weight=>1)
+ }
+end
+
+if $tk_major_ver < 8
+ alias showVars showVars1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 5
+ alias showVars showVars1
+else # ver >= 8.5
+ alias showVars showVars2
+end
+
+# invoke --
+# This procedure is called when the user clicks on a demo description.
+# It is responsible for invoking the demonstration.
+#
+# Arguments:
+# txt - Name of text widget
+# index - The index of the character that the user clicked on.
+
+def invoke (txt, index)
+ tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ return unless tag
+ cursor = txt.cget('cursor')
+ txt.cursor('watch')
+ Tk.update
+# eval `cat #{tag[5..-1]}.rb`
+# eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb`
+ eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join
+ Tk.update
+# txt.cursor('xterm')
+ txt.cursor(cursor)
+
+ $tag_visited.add("#{index} linestart +1 chars", "#{index} lineend +1 chars")
+end
+
+# showStatus --
+#
+# Show the name of the demo program in the status bar. This procedure
+# is called when the user moves the cursor over a demo description.
+#
+
+def showStatus (txt, index)
+ tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ cursor = txt.cget('cursor')
+ unless tag
+ $statusBarLabel.configure('text', " ")
+ newcursor = 'xterm'
+ else
+ demoname = tag[5..-1]
+ $statusBarLabel.configure('text',
+ "Run the \"#{demoname}\" sample program")
+ newcursor = 'hand2'
+ end
+ txt.configure('cursor'=>newcursor) if cursor != newcursor
+end
+
+# showCode --
+# This procedure creates a toplevel window that displays the code for
+# a demonstration and allows it to be edited and reinvoked.
+#
+# Arguments:
+# demo - The name of the demonstration's window, which can be
+# used to derive the name of the file containing its code.
+
+def showCode1(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ f = TkFrame.new($code_window)
+ TkButton.new(f) {
+ text "Dismiss"
+ command proc{
+ $code_window.destroy
+ $code_window = nil
+ }
+ }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
+ TkButton.new(f) {
+ text "Rerun Demo"
+ command proc{eval($code_text.get('1.0','end'))}
+ }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
+# f.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x')
+ f.pack('side'=>'bottom', 'fill'=>'x')
+
+ if $tk_version =~ /^4\.[01]/
+ s = TkScrollbar.new($code_window, 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {
+ height 40
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| $code_text.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ $code_text.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ else
+ TkFrame.new($code_window) {|f|
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ hs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'horizontal')
+ vs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {|t|
+ height 40
+ wrap 'word'
+ xscrollcommand proc{|first,last| hs.set first,last}
+ yscrollcommand proc{|first,last| vs.set first,last}
+ setgrid 'yes'
+ highlightthickness 0
+ pady 2
+ padx 3
+ hs.command(proc{|*args| $code_text.xview(*args)})
+ vs.command(proc{|*args| $code_text.yview(*args)})
+ }
+
+ $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+# JKC 2001-07-26: segfaults under 1.7.1 (2001-06-19) [i686-linux]
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ }
+ end
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+# fid = open(file, 'r')
+ fid = open([$demo_dir, file].join(File::Separator), 'r')
+ $code_text.delete('1.0', 'end')
+ #$code_text.insert('1.0', `cat #{file}`)
+ $code_text.insert('1.0', fid.read)
+ #$code_mark = TkTextMark.new($code_text, '1.0')
+ #$code_text.set_insert('1.0')
+ TkTextMarkInsert.new($code_text,'1.0')
+ fid.close
+end
+
+def showCode2(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ tf = TkFrame.new($code_window)
+ $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30,
+ :wrap=>'word', :bd=>1, :setgrid=>true,
+ :highlightthickness=>0, :pady=>2, :padx=>3)
+ xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ TkGrid($code_text, yscr, :sticky=>'news')
+ #TkGrid(xscr)
+ tf.grid_rowconfigure(0, :weight=>1)
+ tf.grid_columnconfigure(0, :weight=>1)
+
+ bf = TkFrame.new($code_window)
+
+ b_dis = TkButton.new(bf, :text=>'Dismiss', :default=>:active,
+ :command=>proc{
+ $code_window.destroy
+ $code_window = nil
+ },
+ :image=>$image['delete'], :compound=>:left)
+ b_prn = TkButton.new(bf, :text=>'Print Code',
+ :command=>proc{printCode($code_text, file)},
+ :image=>$image['print'], :compound=>:left)
+ b_run = TkButton.new(bf, :text=>'Rerun Demo',
+ :command=>proc{eval($code_text.get('1.0','end'))},
+ :image=>$image['refresh'], :compound=>:left)
+
+ TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
+ bf.grid_columnconfigure(0, :weight=>1)
+
+ TkGrid(tf, :sticky=>'news')
+ TkGrid(bf, :sticky=>'ew')
+ $code_window.grid_columnconfigure(0, :weight=>1)
+ $code_window.grid_rowconfigure(0, :weight=>1)
+
+ $code_window.bind('Return', proc{|win|
+ b_dis.invoke unless win.kind_of?(TkText)
+ }, '%W')
+ $code_window.bindinfo('Return').each{|cmd, arg|
+ $code_window.bind_append('Escape', cmd, arg)
+ }
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+ fid = open([$demo_dir, file].join(File::Separator), 'r')
+ $code_text.delete('1.0', 'end')
+ $code_text.insert('1.0', fid.read)
+ TkTextMarkInsert.new($code_text,'1.0')
+ fid.close
+end
+
+if $tk_major_ver < 8
+ alias showCode showCode1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 5
+ alias showCode showCode1
+else # ver >= 8.5
+ alias showCode showCode2
+end
+
+
+# printCode --
+# Prints the source code currently displayed in the See Code dialog.
+# Much thanks to Arjen Markus for this.
+#
+# Arguments:
+# txt - Name of text widget containing code to print
+# file - Name of the original file (implicitly for title)
+
+def printCode(txt, file)
+ code = txt.get('1.0', 'end - 1c')
+ dir = '.'
+ dir = ENV['HOME'] if ENV['HOME']
+ dir = ENV['TMP'] if ENV['TMP']
+ dir = ENV['TEMP'] if ENV['TEMP']
+
+ fname = [dir, 'tkdemo-' + file].join(File::Separator)
+ open(fname, 'w'){|fid| fid.print(code)}
+ begin
+ case Tk::TCL_PLATFORM('platform')
+ when 'unix'
+ msg = `lp -c #{fname}`
+ unless $?.exitstatus == 0
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'Print spooling probably failed: ' + msg)
+ end
+ when 'windows'
+ begin
+ printTextWin32(fname)
+ rescue => e
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'Print spooling probably failed: ' +
+ e.message)
+ end
+ when 'macintosh'
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'Oops, sorry: not implemented yet!')
+ else
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'Wow! Unknown platform: ' +
+ Tk::TCL_PLATFORM('platform'))
+ end
+ ensure
+ File.delete(fname)
+ end
+end
+
+# printTextWin32 --
+# Print a file under Windows
+#
+# Arguments:
+# filename - Name of the file
+#
+def printTextWin32(fname)
+ require 'win32/registry'
+ begin
+ app = Win32::Registry::HKEY_CLASSES_ROOT['.txt']
+ pcmd = nil
+ Win32::Registry::HKEY_CLASSES_ROOT.open("#{app}\\shell\\print"){|reg|
+ pcmd = reg['command']
+ }
+ rescue
+ app = Tk.tk_call('auto_execok', 'notepad.exe')
+ pcmd = "#{app} /p %1"
+ end
+
+ pcmd.gsub!('%1', fname)
+ puts pcmd
+ cmd = Tk.tk_call('auto_execok', 'start') + ' /min ' + pcmd
+
+ msg = `#{cmd}`
+ unless $?.exitstatus == 0
+ fail RuntimeError, msg
+ end
+end
+
+# aboutBox
+#
+# Pops up a message box with an "about" message
+#
+def aboutBox
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
+ 'message'=>"Ruby/Tk widget demonstration Ver.1.4.3-en\n\n" +
+ "based on demos of Tk8.1 -- 8.5 " +
+ "( Copyright:: " +
+ "(c) 1996-1997 Sun Microsystems, Inc. / " +
+ "(c) 1997-2000 Ajuba Solutions, Inc. / " +
+ "(c) 2001-2003 Donal K. Fellows )\n\n" +
+ "Your Ruby & Tk Version ::\n" +
+ "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}")
+end
+
+#########################################
+# start demos if given at command line
+no_launcher = false
+if ARGV[0] == '-n'
+ ARGV.shift
+ no_launcher = true if ARGV.size > 0
+end
+ARGV.each{|cmd|
+ if cmd =~ /(.*).rb/
+ cmd = $1
+ end
+ eval IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join
+}
+if no_launcher
+ $root.withdraw # hide root window
+ Thread.start{
+ loop do
+ count = 0
+ $root.winfo_children.each{|w|
+ count += 1 if w.kind_of?(TkToplevel)
+ }
+ $root.destroy if count == 0
+ end
+ }
+end
+
+#########################################
+# start eventloop
+Tk.mainloop
+
diff --git a/ext/tk/sample/demos-jp/README b/ext/tk/sample/demos-jp/README
new file mode 100644
index 0000000000..42bec16c60
--- /dev/null
+++ b/ext/tk/sample/demos-jp/README
@@ -0,0 +1,54 @@
+
+ Ruby/Tk widget-demo
+ version 1.2 ( 2000/04/08 )
+ ±Ê°æ¡÷ÃÎǽ¡¥¶å¹©Âç (nagai@ai.kyutech.ac.jp)
+
+ɸ½àÇÛÉۤΠTcl/Tk ³ÈÄ¥¥Ñ¥Ã¥±¡¼¥¸¤ò¼è¤ê¹þ¤ó¤À Ruby (°Ê²¼ Ruby/Tk ¤È¸Æ¤Ó¤Þ¤¹)
+¤Ç¤Ï¡¤Tk widget ¤òÍѤ¤¤¿ GUI ¤ÎºîÀ®¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡¥¼ÂºÝ¤Ë GUI ¤òºîÀ®
+¤·¤Æ¤¤¤¯¾ì¹ç¤Ë¤ÏÍÍ¡¹¤Ê¼ÂÎ㤬¥µ¥ó¥×¥ë¤È¤·¤ÆÂ¸ºß¤¹¤ë¤ÈÊØÍø¤Ê¤Î¤Ç¤¹¤¬¡¤Ruby/Tk
+¤Ë¤Ï¤½¤Î¤è¤¦¤ÊŬÅö¤Ê¥µ¥ó¥×¥ë¥¹¥¯¥ê¥×¥È½¸¹ç¤Ï¸ºß¤·¤Þ¤»¤ó¤Ç¤·¤¿¡¥¤½¤ì¤ËÂФ·¡¤
+³ÈÄ¥¥Ñ¥Ã¥±¡¼¥¸¤Î¸µ¤Ç¤¢¤ë Tcl/Tk ¤Ë¤Ï¡¤Tk widget ¤òÍѤ¤¤Æ¤É¤Î¤è¤¦¤Ê¤³¤È¤¬¤Ç
+¤­¤ë¤«¤ò¼¨¤¹¤â¤Î¤È¤·¤Æ widget-demo ¤¬Â¸ºß¤·¤ª¤ê¡¤Tcl/Tk ¤òÍѤ¤¤¿ GUI ¤ÎºîÀ®
+¤ò½¬ÆÀ¤¹¤ëºÝ¤ÎÂåɽŪ¥µ¥ó¥×¥ë¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡¥ËÜ¥¢¡¼¥«¥¤¥Ö¤Ï¡¤Ruby/Tk ¤Î½¬ÆÀ¤Î
+¤¿¤á¤ÎÂåɽŪ¤Ê¥µ¥ó¥×¥ë¥¹¥¯¥ê¥×¥È¤È¤¹¤Ù¤¯¡¤Tcl/Tk ¤Î widget-demo ¤ò°Ü¿¢¤·¤¿¤â
+¤Î¤Ç¤¹¡¥
+
+º£²ó¤Î¥Ð¡¼¥¸¥ç¥ó¤Ï ruby-1.4.x ¤ËÂбþ¤È¤·¤Æ¤ª¤­¤Þ¤¹¤¬¡¤µì¥Ð¡¼¥¸¥ç¥ó¤ËÈæ¤Ù¤Æ¡¤
+¤Û¤È¤ó¤ÉÊѹ¹¤Ï¤¢¤ê¤Þ¤»¤ó¡¥ruby-1.1c2 °Ê¾å¤Ê¤éư¤¯¤È»×¤¤¤Þ¤¹¡¥ruby-1.5.x ¤Ë¤Ä
+¤¤¤Æ¤Ï¥Æ¥¹¥È¤·¤Æ¤¤¤Þ¤»¤ó¡¥¤½¤Î¤¿¤á¡¤Èó¸ß´¹¤Î±Æ¶Á¤¬½Ð¤ë¤³¤È¤¬¤¢¤ë¤«¤â¤·¤ì¤Þ¤»
+¤ó¤¬¡¤¤½¤Î¾ì¹ç¤Ç¤â¾¯¤·¤Î½¤Àµ¤Çư¤«¤»¤ë¤È»×¤¤¤Þ¤¹¡¥ÁȤ߹þ¤à Tk ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ï¡¤
+4.2 ¤Ç¤â 8.0 ¤Ç¤â½¤Àµ¤Ê¤¯Æ°¤«¤»¤ë¤Ï¤º¤Ç¤¹¡¥¤¿¤À¤·¡¤ÆüËܸìÈǤǤΰܿ¢¤È¤Ê¤Ã¤Æ
+¤¤¤ë¤¿¤á¡¤ÆüËܸ첽¤µ¤ì¤¿ Tk ¤ò¤´ÍøÍѤ¯¤À¤µ¤¤¡¥¥¹¥¯¥ê¥×¥È¤Î¥Æ¥¹¥È¤Ï¡¤µì¥Ð¡¼¥¸¥ç
+¥ó¤ÎºÝ¤Ë Tk4.2jp ¤È Tk8.0jp ¤Î¾å¤Ç¹Ô¤Ã¤Æ¤¤¤Þ¤¹ (´°àú¤Ë¤Ç¤Ï¤Ê¤¤¤Ç¤¹¤¬)¡¥º£²ó
+¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï ruby-1.4.x + Tk8.0jp ¾å¤Ç¤Î´Êñ¤Ê¥Æ¥¹¥È¤·¤«¹Ô¤Ã¤Æ¤¤¤Þ¤»¤ó¤¬¡¤
+½¤Àµ¤È¤¤¤¦¤Û¤É¤Î½¤Àµ¤Ï¤·¤Æ¤¤¤Þ¤»¤ó¤Î¤ÇÌäÂê¤Ï¤Ê¤¤¤È¹Í¤¨¤Æ¤¤¤Þ¤¹¡¥
+
+ËÜ¥¢¡¼¥«¥¤¥Ö¤Ë´Þ¤Þ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¿¤¯¤Ï¡¤¸µ¤È¤Ê¤Ã¤Æ¤¤¤ë Tcl/Tk ÈǤËÈæ³ÓŪ¶á
+¤¤¥¹¥¯¥ê¥×¥Èµ­½Ò¤È¤Ê¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡¥¤½¤Î¤¿¤á¡¤Ruby/Tk ¤Î¥µ¥ó¥×¥ë¤È¸À¤¦¤Ë
+¤Ï¡¤¤¢¤Þ¤ê Ruby ¤é¤·¤¯¤Ê¤¤¤È¤â¸À¤¨¤ë¤Ç¤·¤ç¤¦¡¥¤Ë¤â¤«¤«¤ï¤é¤º¡¤¤½¤Î¤è¤¦¤Êµ­½Ò
+¤ò¼è¤Ã¤Æ¤¤¤ëÍýͳ¤Ï¡¤Ruby/Tk ¤Î¥É¥­¥å¥á¥ó¥ÈÉÔ­¤Ë¤¢¤ê¤Þ¤¹¡¥
+
+Tcl/Tk ¤Ë¤ÏŬÅö¤Ê»²¹Í½ñ¤¬²¿ºý¤«Â¸ºß¤·¤Æ¤¤¤Þ¤¹¤«¤é¡¤Ruby/Tk ¥¹¥¯¥ê¥×¥È¤òºîÀ®
+¤¹¤ëºÝ¤Ï¡¤¤½¤Î¤è¤¦¤Ê Tcl/Tk ¤Î»²¹Í½ñ¤Ç¾ðÊó¤òÊ䤤¤Ê¤¬¤éºîÀ®¤¹¤ë¤³¤È¤Ë¤Ê¤ë¤È»×
+¤¤¤Þ¤¹¡¥³Æ widget ¤Î»ÈÍÑÎã¤È¤·¤Æ¡¤Tcl/Tk ¤Î widget-demo ¤ò»²¾È¤¹¤ë¤³¤È¤â¤¢¤ë
+¤Ç¤·¤ç¤¦¡¥Ruby/Tk ÈǤε­½Ò¤ò widget-demo ¤ò Tcl/Tk ÈǤε­½Ò¤Ë¶á¤¤¤â¤Î¤Ë¤·¤Æ
+¤ª¤±¤Ð¡¤¤½¤ÎÂÐÈæ¤Ë¤è¤Ã¤Æ¡¤Ruby/Tk ¤ÎÍý²ò¤òÁá¤á¤ë¤³¤È¤¬¤Ç¤­¤ë¤È¹Í¤¨¤é¤ì¤Þ¤¹¡¥
+°ìö Ruby/Tk ¤Ç¤Î ³Æ widget ¤Î»ÈÍÑÊýË¡¤ò½¬ÆÀ¤·¤Æ¤·¤Þ¤¨¤Ð¡¤Ruby ¤é¤·¤¤¥¹¥¯¥ê
+¥×¥È¤òºîÀ®¤¹¤ë¤³¤È¤ÏÆñ¤·¤¯¤Ê¤¤¤Ç¤·¤ç¤¦¡¥ËÜ¥¢¡¼¥«¥¤¥Ö¤Î¥¹¥¯¥ê¥×¥È¤Ï¡¤Ruby/Tk
+¤òºÇ½é¤Ë½¬ÆÀ¤¹¤ë¤Þ¤Ç¤ÎÆ§Âæ¤È¤·¤ÆÍøÍѤ·¤Æ¤¤¤¿¤À¤±¤ì¤Ð¹¬¤¤¤Ç¤¹¡¥
+
+widget-demo ¤Î°Ü¿¢¤Ë¤¢¤¿¤Ã¤Æ¤Ï¡¤¼¡¤ÎÊý¤Ë¤â°Ü¿¢¤·¤¿¥¹¥¯¥ê¥×¥È¤òÄ󶡤·¤Æ¤¤¤¿¤À
+¤­¤Þ¤·¤¿¡¥¤³¤³¤Ë´¶¼Õ¤Î°Õ¤òɽ¤·¤Þ¤¹¡¥
+
+ ΩÀС÷JAIST (ttate@jaist.ac.jp) ¤µ¤ó
+ Ê¿¾¾¾Í»Ë (hiramatu@cdrom.co.jp) ¤µ¤ó
+
+Ê¿¾¾¤µ¤ó¤Ë¤è¤ë Ruby/Tk ÆþÌç¤Î Web page (http://www.cdrom.co.jp/~hiramatu/)
+¤â Ruby/Tk ¤Î½¬ÆÀ¤ËÍ­ÍѤȻפ¨¤Þ¤¹¤Î¤Ç¡¤¤¼¤Ò¤´»²¾È¤¯¤À¤µ¤¤¡¥
+
+¤Þ¤¿¡¤Á°¶¶ (maebashi@iij.ad.jp) ¤µ¤ó¤ò¤Ï¤¸¤á¤È¤·¤Æ¡¤widget-demo ¤Î°Ü¿¢¤ËºÝ¤·
+¤ÆÉ¬ÍפȤʤä¿ Ruby ¤Î Tk ´ØÏ¢¥é¥¤¥Ö¥é¥ê½¤Àµ¤Ë¤Ä¤¤¤Æ¡¤ÌäÂêÅÀ¡¤¥Ð¥°¤Î»ØÅ¦¤ò¤·
+¤Æ¤¤¤¿¤À¤¤¤¿Êý¡¹¤Ë¤â´¶¼ÕÃפ·¤Þ¤¹¡¥
+
+¤½¤·¤ÆºÇ¸å¤ËºÇÂç¤Î´¶¼Õ¤ò Ruby À߷׼ԤΠ¤Þ¤Ä¤â¤È ¤æ¤­¤Ò¤í (matz@netlab.co.jp)
+¤µ¤ó¤ËÊû¤²¤¿¤¤¤È»×¤¤¤Þ¤¹¡¥
diff --git a/ext/tk/sample/demos-jp/README.1st b/ext/tk/sample/demos-jp/README.1st
new file mode 100644
index 0000000000..60b278d7b6
--- /dev/null
+++ b/ext/tk/sample/demos-jp/README.1st
@@ -0,0 +1,20 @@
+¤³¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤Ï Ruby/Tk ¤Î¥Ç¥â¥¹¥¯¥ê¥×¥È¤¬¼ý¤á¤é¤ì¤Æ¤¤¤Þ¤¹¡¥
+
+'.rb' ¤È¤¤¤¦³ÈÄ¥»Ò¤ò»ý¤Ã¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Ï¡¤¥é¥ó¥Á¥ã¨¡¥¹¥¯¥ê¥×¥È¤Ç
+¤¢¤ë 'widget' ¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤ë¥µ¥Ö¥¹¥¯¥ê¥×¥È¤Ç¤¹¡¥¤½¤ì¤¾¤ìÆÈΩ¤Ë
+¤Ïư¤­¤Þ¤»¤ó¡¥'widget' ¥¹¥¯¥ê¥×¥È¤«¤é¸Æ¤Ó½Ð¤·¤Æ¤¯¤À¤µ¤¤¡¥
+
+¤â¤·¥é¥ó¥Á¥ã¨¡¥¹¥¯¥ê¥×¥È 'widget' ¤Îµ¯Æ°¤ÈƱ»þ¤Ë¤¤¤¯¤Ä¤«¤Î¥µ¥Ö¥¹
+¥¯¥ê¥×¥È¤òµ¯Æ°¤·¤¿¤±¤ì¤Ð¡¤¤½¤Î¥µ¥Ö¥¹¥¯¥ê¥×¥È¤Î̾Á°¤ò°ú¿ô¤È¤·¤ÆÍ¿
+¤¨¤Æ¤¯¤À¤µ¤¤¡¥
+( Îã: /usr/local/bin/ruby widget button.rb entry1.rb text.rb )
+¥µ¥Ö¥¹¥¯¥ê¥×¥È¤Î³ÈÄ¥»Ò '.rb' ¤Ï¾Êά¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡¥
+( Îã: /usr/local/bin/ruby widget button entry1 text )
+
+¤â¤·¥é¥ó¥Á¥ã¨¡¥¹¥¯¥ê¥×¥È¤Î¥¦¥£¥ó¥É¥¦¤¬É¬Íפʤ¤¾ì¹ç¤Ë¤Ï¡¤'-n' ¥ª
+¥×¥·¥ç¥ó¤òÍ¿¤¨¤Æ¤¯¤À¤µ¤¤¡¥
+( Îã: /usr/local/bin/ruby widget -n button.rb entry1.rb text.rb )
+
+¾¤Î¥Õ¥¡¥¤¥ë (browse1 ¤ä hello ¤Ê¤É) ¤ÏñÆÈ¤Çư¤«¤¹¤³¤È¤¬²Äǽ¤Ç¤¹¡¥
+
+ 2004/04/14 Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/ext/tk/sample/demos-jp/arrow.rb b/ext/tk/sample/demos-jp/arrow.rb
new file mode 100644
index 0000000000..477a0abf6f
--- /dev/null
+++ b/ext/tk/sample/demos-jp/arrow.rb
@@ -0,0 +1,236 @@
+#
+# arrowhead widget demo (called by 'widget')
+#
+
+# arrowSetup --
+# This method regenerates all the text and graphics in the canvas
+# window. It's called when the canvas is initially created, and also
+# whenever any of the parameters of the arrow head are changed
+# interactively.
+#
+# Arguments:
+# c - Name of the canvas widget.
+
+def arrowSetup(c)
+ v = $demo_arrowInfo
+
+ # Remember the current box, if there is one.
+ tags = c.gettags('current')
+ if tags != []
+ cur = tags.find{|t| t.kind_of?(String) && t =~ /^box[1-3]$/ }
+ else
+ cur = nil
+ end
+
+ # Create the arrow and outline.
+ c.delete('all')
+ TkcLine.new(c, v.x1, v.y, v.x2, v.y,
+ { 'width'=>10 * v.width,
+ 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c],
+ 'arrow'=>'last'
+ }.update(v.bigLineStyle) )
+ xtip = v.x2 - 10*v.b
+ deltaY = 10*v.c + 5*v.width
+ TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY,
+ v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y,
+ 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round')
+
+ # Create the boxes for reshaping the line and arrowhead.
+ TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5,
+ {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5,
+ {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5,
+ {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) )
+ c.itemconfigure cur, v.activeStyle if cur
+
+ # Create three arrows in actual size with the same parameters
+ TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2)
+ tmp = v.x2+100
+ TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+
+ # Create a bunch of other arrows and text items showing the
+ # current dimensions.
+ tmp = v.x2+10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w')
+ tmp = v.x1-10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e')
+ tmp = v.y+5*v.width+10*v.c+10
+ TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n')
+ tmp = tmp+25
+ TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')
+
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+
+ v.count += 1
+end
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($arrow_demo) && $arrow_demo
+ $arrow_demo.destroy
+ $arrow_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$arrow_demo = TkToplevel.new {|w|
+ title("Arrowhead Editor Demonstration")
+ iconname("arrow")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"¤³¤Î widget ¤Ç¡¢¥­¥ã¥ó¥Ð¥¹¤Ç»È¤ï¤ì¤ë¥é¥¤¥ó¤Ë¤Ä¤¤¤ÆÍÍ¡¹¤ÊÉý¤äÌð°õ¤ÎƬ¤Î·Á¤ò»î¤·¤Æ¤ß¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£Àþ¤ÎÉý¤äÌð°õ¤Î·Á¤òÊѤ¨¤ë¤Ë¤Ï¡¢³ÈÂ礵¤ì¤¿Ìð°õ¤Ë¤Ä¤¤¤Æ¤¤¤ë 3¤Ä¤Î»Í³Ñ¤ò¥É¥é¥Ã¥°¤·¤Æ¤¯¤À¤µ¤¤¡£±¦Â¦¤ÎÌð°õ¤ÏÉáÄ̤ÎÂ礭¤µ¤Ç¤Î¥µ¥ó¥×¥ë¤ò¼¨¤·¤Æ¤¤¤Þ¤¹¡£²¼¤Î¥Æ¥­¥¹¥È¤Ï¥é¥¤¥ó¥¢¥¤¥Æ¥à¤ËÂФ¹¤ëÀßÄꥪ¥×¥·¥ç¥ó¤Ç¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$arrow_buttons = TkFrame.new($arrow_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $arrow_demo
+ $arrow_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'arrow'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas ÀßÄê
+$arrow_canvas = TkCanvas.new($arrow_demo, 'width'=>500, 'height'=>350,
+ 'relief'=>'sunken', 'borderwidth'=>2)
+$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+# ÃÍÀßÄê
+unless Struct.const_defined?("ArrowInfo")
+ $demo_arrowInfo = Struct.new("ArrowInfo", :a, :b, :c, :width, :motionProc,
+ :x1, :x2, :y, :smallTips, :count,
+ :bigLineStyle, :boxStyle, :activeStyle).new
+end
+$demo_arrowInfo.a = 8
+$demo_arrowInfo.b = 10
+$demo_arrowInfo.c = 3
+$demo_arrowInfo.width = 2
+$demo_arrowInfo.motionProc = proc{}
+$demo_arrowInfo.x1 = 40
+$demo_arrowInfo.x2 = 350
+$demo_arrowInfo.y = 150
+$demo_arrowInfo.smallTips = [5, 5, 2]
+$demo_arrowInfo.count = 0
+if TkWinfo.depth($arrow_canvas) > 1
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'SkyBlue1'}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'red', 'outline'=>'black', 'width'=>1}
+else
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir,'..','images','grey.25'].join(File::Separator)}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'black','outline'=>'black','width'=>1}
+end
+$arrowTag_box = TkcTag.new($arrow_canvas)
+arrowSetup $arrow_canvas
+$arrowTag_box.bind('Enter', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.activeStyle)})
+$arrowTag_box.bind('Leave', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.boxStyle)})
+$arrowTag_box.bind('B1-Enter', proc{})
+$arrowTag_box.bind('B1-Leave', proc{})
+$arrow_canvas.itembind('box1', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove1 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box2', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove2 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box3', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove3 $arrow_canvas, x, y}})
+$arrowTag_box.bind('B1-Motion',
+ proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y")
+$arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas})
+
+# arrowMove1 --
+# This method is called for each mouse motion event on box1 (the
+# one at the vertex of the arrow). It updates the controlling parameters
+# for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove1(c,x,y)
+ v = $demo_arrowInfo
+ newA = (v.x2+5-c.canvasx(x).round)/10
+ newA = 0 if newA < 0
+ newA = 25 if newA > 25
+ if newA != v.a
+ c.move('box1', 10*(v.a-newA), 0)
+ v.a = newA
+ end
+end
+
+# arrowMove2 --
+# This method is called for each mouse motion event on box2 (the
+# one at the trailing tip of the arrowhead). It updates the controlling
+# parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove2(c,x,y)
+ v = $demo_arrowInfo
+ newB = (v.x2+5-c.canvasx(x).round)/10
+ newB = 0 if newB < 0
+ newB = 25 if newB > 25
+ newC = (v.y+5-c.canvasy(y).round-5*v.width)/10
+ newC = 0 if newC < 0
+ newC = 20 if newC > 20
+ if newB != v.b || newC != v.c
+ c.move('box2', 10*(v.b-newB), 10*(v.c-newC))
+ v.b = newB
+ v.c = newC
+ end
+end
+
+# arrowMove3 --
+# This method is called for each mouse motion event on box3 (the
+# one that controls the thickness of the line). It updates the
+# controlling parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove3(c,x,y)
+ v = $demo_arrowInfo
+ newWidth = (v.y+2-c.canvasy(y).round)/5
+ newWidth = 0 if newWidth < 0
+ newWidth = 20 if newWidth > 20
+ if newWidth != v.width
+ c.move('box3', 0, 5*(v.width-newWidth))
+ v.width = newWidth
+ end
+end
+
diff --git a/ext/tk/sample/demos-jp/bind.rb b/ext/tk/sample/demos-jp/bind.rb
new file mode 100644
index 0000000000..70127424c5
--- /dev/null
+++ b/ext/tk/sample/demos-jp/bind.rb
@@ -0,0 +1,107 @@
+#
+# text (tag bindings) widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($bind_demo) && $bind_demo
+ $bind_demo.destroy
+ $bind_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$bind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Tag Bindings")
+ iconname("bind")
+ positionWindow(w)
+}
+
+# frame À¸À®
+TkFrame.new($bind_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $bind_demo
+ $bind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'bind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# bind Íѥ᥽¥Ã¥É
+def tag_binding_for_bind_demo(tag, enter_style, leave_style)
+ tag.bind('Any-Enter', proc{tag.configure enter_style})
+ tag.bind('Any-Leave', proc{tag.configure leave_style})
+end
+
+# text À¸À®
+TkText.new($bind_demo){|t|
+ # À¸À®
+ setgrid 'true'
+ width 60
+ height 24
+ font $font
+ wrap 'word'
+ TkScrollbar.new($bind_demo) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ # ¥¹¥¿¥¤¥ëÀßÄê
+ if TkWinfo.depth($root).to_i > 1
+ tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised',
+ 'borderwidth'=>1}
+ tagstyle_normal = {'background'=>'', 'relief'=>'flat'}
+ else
+ tagstyle_bold = {'foreground'=>'white', 'background'=>'black'}
+ tagstyle_normal = {'foreground'=>'', 'background'=>''}
+ end
+
+ # ¥Æ¥­¥¹¥ÈÁÞÆþ
+ insert 'insert', "¥Æ¥­¥¹¥Èwidget¤Îɽ¼¨¥¹¥¿¥¤¥ë¤òÀ©¸æ¤¹¤ë¤Î¤ÈƱ¤¸¥¿¥°¤Î¥á¥«¥Ë¥º¥à¤ò»È¤Ã¤Æ¡¢¥Æ¥­¥¹¥È¤ËTcl¤Î¥³¥Þ¥ó¥É¤ò³ä¤êÅö¤Æ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤³¤ì¤Ë¤è¤ê¡¢¥Þ¥¦¥¹¤ä¥­¡¼¥Ü¡¼¥É¤Î¥¢¥¯¥·¥ç¥ó¤ÇÆÃÄê¤ÎTcl¤Î¥³¥Þ¥ó¥É¤¬¼Â¹Ô¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£Î㤨¤Ð¡¢²¼¤Î¥­¥ã¥ó¥Ð¥¹¤Î¥Ç¥â¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀʸ¤Ë¤Ï¤½¤Î¤è¤¦¤Ê¥¿¥°¤¬¤Ä¤¤¤Æ¤¤¤Þ¤¹¡£¥Þ¥¦¥¹¤òÀâÌÀʸ¤Î¾å¤Ë»ý¤Ã¤Æ¤¤¤¯¤ÈÀâÌÀʸ¤¬¸÷¤ê¡¢¥Ü¥¿¥ó1¤ò²¡¤¹¤È¤½¤ÎÀâÌÀ¤Î¥Ç¥â¤¬»Ï¤Þ¤ê¤Þ¤¹¡£
+
+"
+ insert('end', '1. ¥­¥ã¥ó¥Ð¥¹ widget ¤Ëºî¤ë¤³¤È¤Î¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤Î¼ïÎàÁ´¤Æ¤Ë´Ø¤¹¤ë¥µ¥ó¥×¥ë¡£', (d1 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '2. ´Êñ¤Ê 2¼¡¸µ¤Î¥×¥í¥Ã¥È¡£¥Ç¡¼¥¿¤òɽ¤¹ÅÀ¤òư¤«¤¹¤³¤È¤¬¤Ç¤­¤ë¡£', (d2 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '3. ¥Æ¥­¥¹¥È¥¢¥¤¥Æ¥à¤Î¥¢¥ó¥«¡¼¤È¹Ô·¤¨¡£',
+ (d3 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '4. ¥é¥¤¥ó¥¢¥¤¥Æ¥à¤Î¤¿¤á¤ÎÌð°õ¤ÎƬ¤Î·Á¤Î¥¨¥Ç¥£¥¿¡£',
+ (d4 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '5. ¥¿¥Ö¥¹¥È¥Ã¥×¤òÊѹ¹¤¹¤ë¤¿¤á¤Îµ¡Ç½¤Ä¤­¤Î¥ë¡¼¥é¡¼¡£',
+ (d5 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end',
+ '6. ¥­¥ã¥ó¥Ð¥¹¤¬¤É¤¦¤ä¤Ã¤Æ¥¹¥¯¥í¡¼¥ë¤¹¤ë¤Î¤«¤ò¼¨¤¹¥°¥ê¥Ã¥É¡£',
+ (d6 = TkTextTag.new(t)) )
+
+ # binding
+ [d1, d2, d3, d4, d5, d6].each{|tag|
+ tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal)
+ }
+ d1.bind('1',
+ proc{eval `cat #{[$demo_dir,'items.rb'].join(File::Separator)}`})
+ d2.bind('1',
+ proc{eval `cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`})
+ d3.bind('1',
+ proc{eval `cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`})
+ d4.bind('1',
+ proc{eval `cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`})
+ d5.bind('1',
+ proc{eval `cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`})
+ d6.bind('1',
+ proc{eval `cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`})
+
+ TkTextMarkInsert.new(t, '0.0')
+ configure('state','disabled')
+}
diff --git a/ext/tk/sample/demos-jp/bitmap.rb b/ext/tk/sample/demos-jp/bitmap.rb
new file mode 100644
index 0000000000..b71c67d3fd
--- /dev/null
+++ b/ext/tk/sample/demos-jp/bitmap.rb
@@ -0,0 +1,71 @@
+#
+# bitmap widget demo (called by 'widget')
+#
+
+# bitmapRow --
+# Create a row of bitmap items in a window.
+#
+# Arguments:
+# w - The parent window that is to contain the row.
+# args - The names of one or more bitmaps, which will be displayed
+# in a new row across the bottom of w along with their
+# names.
+
+def bitmapRow(w,*args)
+ TkFrame.new(w){|row|
+ pack('side'=>'top', 'fill'=>'both')
+ for bitmap in args
+ TkFrame.new(row){|base|
+ pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
+ TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
+ TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
+ }
+ end
+ }
+end
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($bitmap_demo) && $bitmap_demo
+ $bitmap_demo.destroy
+ $bitmap_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$bitmap_demo = TkToplevel.new {|w|
+ title("Bitmap Demonstration")
+ iconname("bitmap")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¡¢Tk ¤ËÁȤ߹þ¤Þ¤ì¤¿¤¹¤Ù¤Æ¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×¤¬¡¢¤½¤ì¤é¤Î̾Á°¤È¶¦¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Tcl ¤Î¥¹¥¯¥ê¥×¥ÈÃæ¤Ç¤Ï¡¢¤½¤ì¤¾¤ì¤Î̾Á°¤òÍѤ¤¤Æ»²¾È¤·¤Þ¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $bitmap_demo
+ $bitmap_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'bitmap'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame ÀßÄê
+TkFrame.new($bitmap_demo){|f|
+ bitmapRow(f,'error','gray25','gray50','hourglass')
+ bitmapRow(f,'info','question','questhead','warning')
+ pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+}
+
diff --git a/ext/tk/sample/demos-jp/browse1 b/ext/tk/sample/demos-jp/browse1
new file mode 100644
index 0000000000..03e251035a
--- /dev/null
+++ b/ext/tk/sample/demos-jp/browse1
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+# Create a scrollbar on the right side of the main window and a listbox
+# on the left side.
+
+listbox = TkListbox.new(nil, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(nil, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+}
+
+root = TkRoot.new
+root.minsize(1,1)
+
+# The procedure below is invoked to open a browser on a given file; if the
+# file is a directory then another instance of this program is invoked; if
+# the file is a regular file then the Mx editor is invoked to display
+# the file.
+
+def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ system($0 + ' ' + file + ' &')
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+end
+
+# Fill the listbox with a list of all the files in the directory (run
+# the "ls" command to get that information).
+
+dir = ARGV[0] ? ARGV[0] : '.'
+open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ listbox.insert('end', fname.chomp)
+}
+
+# Set up bindings for the browser.
+
+Tk.bind_all('Control-c', proc{root.destroy})
+listbox.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| browse dir, f}})
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/browse2 b/ext/tk/sample/demos-jp/browse2
new file mode 100644
index 0000000000..edad04dbcb
--- /dev/null
+++ b/ext/tk/sample/demos-jp/browse2
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+class Browse
+ BROWSE_WIN_COUNTER = TkVariable.new(0)
+
+ def initialize(dir)
+ BROWSE_WIN_COUNTER.value = BROWSE_WIN_COUNTER.to_i + 1
+
+ # create base frame
+ base = TkToplevel.new {
+ minsize(1,1)
+ title('Browse : ' + dir)
+ }
+
+ # Create a scrollbar on the right side of the main window and a listbox
+ # on the left side.
+ list = TkListbox.new(base, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(base, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+
+ # Fill the listbox with a list of all the files in the directory (run
+ # the "ls" command to get that information).
+ open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ l.insert('end', fname.chomp)
+ }
+
+ }
+
+ # Set up bindings for the browser.
+ base.bind('Destroy', proc{
+ Browse::BROWSE_WIN_COUNTER.value = \
+ Browse::BROWSE_WIN_COUNTER.to_i - 1
+ })
+ base.bind('Control-c', proc{base.destroy})
+ list.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| self.browse dir, f}})
+ end
+
+ # The method below is invoked to open a browser on a given file; if the
+ # file is a directory then another instance of this program is invoked; if
+ # the file is a regular file then the Mx editor is invoked to display
+ # the file.
+ def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ Browse.new(file)
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+ end
+
+end
+
+Browse.new(ARGV[0] ? ARGV[0] : '.')
+
+TkRoot.new {
+ withdraw
+ Browse::BROWSE_WIN_COUNTER.trace('w', proc{exit if Browse::BROWSE_WIN_COUNTER.to_i == 0})
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/button.rb b/ext/tk/sample/demos-jp/button.rb
new file mode 100644
index 0000000000..20f8cae299
--- /dev/null
+++ b/ext/tk/sample/demos-jp/button.rb
@@ -0,0 +1,81 @@
+#
+# button widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($button_demo) && $button_demo
+ $button_demo.destroy
+ $button_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$button_demo = TkToplevel.new {|w|
+ title("Button Demonstration")
+ iconname("button")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($button_demo) {
+ font $kanji_font
+ wraplength '4i'
+ justify 'left'
+ text "¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¥Ü¥¿¥ó¤ÎÇØ·Ê¿§¤¬¤½¤Î¥Ü¥¿¥ó¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¿§¤Ë¤Ê¤ê¤Þ¤¹¡£¥Ü¥¿¥ó¤«¤é¥Ü¥¿¥ó¤Ø¤Î°Üư¤Ï¥¿¥Ö¤ò²¡¤¹¤³¤È¤Ç¤â²Äǽ¤Ç¤¹¡£¤Þ¤¿¥¹¥Ú¡¼¥¹¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+$button_buttons = TkFrame.new($button_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $button_demo
+ $button_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'button'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button À¸À®
+TkButton.new($button_demo){
+ text "Peach Puff"
+ width 10
+ command proc{
+ $button_demo.configure('bg','PeachPuff1')
+ $button_buttons.configure('bg','PeachPuff1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Light Blue"
+ width 10
+ command proc{
+ $button_demo.configure('bg','LightBlue1')
+ $button_buttons.configure('bg','LightBlue1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Sea Green"
+ width 10
+ command proc{
+ $button_demo.configure('bg','SeaGreen2')
+ $button_buttons.configure('bg','SeaGreen2')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Yellow"
+ width 10
+ command proc{
+ $button_demo.configure('bg','Yellow1')
+ $button_buttons.configure('bg','Yellow1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
diff --git a/ext/tk/sample/demos-jp/check.rb b/ext/tk/sample/demos-jp/check.rb
new file mode 100644
index 0000000000..be675b9042
--- /dev/null
+++ b/ext/tk/sample/demos-jp/check.rb
@@ -0,0 +1,67 @@
+#
+# checkbutton widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($check_demo) && $check_demo
+ $check_demo.destroy
+ $check_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$check_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration")
+ iconname("check")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($check_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Ë¤Ï 3 ¤Ä¤Î¥Á¥§¥Ã¥¯¥Ü¥¿¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥¯¥ê¥Ã¥¯¤¹¤ë¤È¥Ü¥¿¥ó¤ÎÁªÂò¾õÂÖ¤¬ÊѤï¤ê¡¢Tcl ÊÑ¿ô ( TkVariable ¥ª¥Ö¥¸¥§¥¯¥È¤Ç¥¢¥¯¥»¥¹¤Ç¤­¤Þ¤¹ ) ¤Ë¤½¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¤ò¼¨¤¹ÃͤòÀßÄꤷ¤Þ¤¹¡£¸½ºß¤ÎÊÑ¿ô¤ÎÃͤò¸«¤ë¤Ë¤Ï¡ÖÊÑ¿ô»²¾È¡×¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£"
+}
+msg.pack('side'=>'top')
+
+# ÊÑ¿ôÀ¸À®
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame À¸À®
+TkFrame.new($check_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $check_demo
+ $check_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'check'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+
+ TkButton.new(frame) {
+ text 'ÊÑ¿ô»²¾È'
+ command proc{
+ showVars($check_demo,
+ ['wipers', wipers], ['brakes', brakes], ['sober', sober])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# checkbutton À¸À®
+[ TkCheckButton.new($check_demo, 'text'=>'¥ï¥¤¥Ñ¡¼ OK', 'variable'=>wipers),
+ TkCheckButton.new($check_demo, 'text'=>'¥Ö¥ì¡¼¥­ OK', 'variable'=>brakes),
+ TkCheckButton.new($check_demo, 'text'=>'±¿Å¾¼ê ÁÇÌÌ', 'variable'=>sober)
+].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')}
+
diff --git a/ext/tk/sample/demos-jp/check2.rb b/ext/tk/sample/demos-jp/check2.rb
new file mode 100644
index 0000000000..5d0c74a743
--- /dev/null
+++ b/ext/tk/sample/demos-jp/check2.rb
@@ -0,0 +1,107 @@
+#
+# checkbutton widget demo2 (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($check2_demo) && $check2_demo
+ $check2_demo.destroy
+ $check2_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$check2_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration 2")
+ iconname("check2")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($check2_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Ë¤Ï£´¤Ä¤Î¥Á¥§¥Ã¥¯¥Ü¥¿¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥¯¥ê¥Ã¥¯¤¹¤ë¤È¥Ü¥¿¥ó¤ÎÁªÂò¾õÂÖ¤¬ÊѤï¤ê¡¢TclÊÑ¿ô¡ÊTkVariable¥ª¥Ö¥¸¥§¥¯¥È¤Ç¥¢¥¯¥»¥¹¤Ç¤­¤Þ¤¹¡Ë¤Ë¤½¤Î¥Ü¥¿¥ó¤Î¾õÂÖ¤ò¼¨¤¹ÃͤòÀßÄꤷ¤Þ¤¹¡£ºÇ½é¤Î¥Ü¥¿¥ó¤Î¾õÂ֤Ͼ¤Î£³¤Ä¤Î¥Ü¥¿¥ó¤Î¾õÂ֤ˤâ°Í¸¤·¤ÆÊѲ½¤·¤Þ¤¹¡£¤â¤·£³¤Ä¤Î¥Ü¥¿¥ó¤Î°ìÉô¤À¤±¤Ë¥Á¥§¥Ã¥¯¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤ë¾ì¹ç¡¢ºÇ½é¤Î¥Ü¥¿¥ó¤Ï¥È¥é¥¤¥¹¥Æ¡¼¥È¡Ê£³¾õÂ֡˥⡼¥É¤Ç¤Îɽ¼¨¤ò¹Ô¤¤¤Þ¤¹¡£¸½ºß¤ÎÊÑ¿ô¤ÎÃͤò¸«¤ë¤Ë¤Ï¡ÖÊÑ¿ô»²¾È¡×¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£"
+}
+msg.pack('side'=>'top')
+
+# ÊÑ¿ôÀ¸À®
+safety = TkVariable.new(0)
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame À¸À®
+TkFrame.new($check2_demo) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'ÊÑ¿ô»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars($check2_demo,
+ ['safety', safety], ['wipers', wipers],
+ ['brakes', brakes], ['sober', sober])
+ }),
+ TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'check2'}),
+ TkButton.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $check2_demo
+ $check2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}.pack('side'=>'bottom', 'fill'=>'x')
+
+
+# checkbutton À¸À®
+TkCheckButton.new($check2_demo, :text=>'°ÂÁ´À­¸¡ºº', :variable=>safety,
+ :relief=>:flat, :onvalue=>'all', :offvalue=>'none',
+ :tristatevalue=>'partial'){
+ pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+[ TkCheckButton.new($check2_demo, 'text'=>'¥ï¥¤¥Ñ¡¼ OK', 'variable'=>wipers),
+ TkCheckButton.new($check2_demo, 'text'=>'¥Ö¥ì¡¼¥­ OK', 'variable'=>brakes),
+ TkCheckButton.new($check2_demo, 'text'=>'±¿Å¾¼ê ÁÇÌÌ', 'variable'=>sober)
+].each{|w|
+ w.relief('flat')
+ w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w')
+}
+
+# tristate check
+in_check = false
+tristate_check = proc{|n1,n2,op|
+ return if in_check
+
+ in_check = true
+ begin
+ if n1 == safety
+ if safety == 'none'
+ wipers.value = 0
+ brakes.value = 0
+ sober.value = 0
+ elsif safety == 'all'
+ wipers.value = 1
+ brakes.value = 1
+ sober.value = 1
+ end
+ else
+ if wipers == 1 && brakes == 1 && sober == 1
+ safety.value = 'all'
+ elsif wipers == 1 || brakes == 1 || sober == 1
+ safety.value = 'partial'
+ else
+ safety.value = 'none'
+ end
+ end
+ ensure
+ in_check = false
+ end
+}
+
+[wipers, brakes, sober, safety].each{|v| v.trace('w', tristate_check)}
diff --git a/ext/tk/sample/demos-jp/clrpick.rb b/ext/tk/sample/demos-jp/clrpick.rb
new file mode 100644
index 0000000000..de8cd80fcd
--- /dev/null
+++ b/ext/tk/sample/demos-jp/clrpick.rb
@@ -0,0 +1,75 @@
+#
+# widget demo prompts the user to select a color (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($clrpick_demo) && $clrpick_demo
+ $clrpick_demo.destroy
+ $clrpick_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$clrpick_demo = TkToplevel.new {|w|
+ title("Color Selection Dialogs")
+ iconname("colors")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"°Ê²¼¤Î¥Ü¥¿¥ó¤ò²¡¤·¤Æ¡¢¤³¤Î¥¦¥£¥ó¥É¥¦¾å¤Ë¤¢¤ë¥¦¥£¥¸¥§¥Ã¥È¤ÎÁ°·Ê¿§¤ÈÇØ·Ê¿§¤òÁªÂò¤·¤Æ²¼¤µ¤¤¡£").pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($clrpick_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $clrpick_demo
+ $clrpick_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'clrpick'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button À¸À®
+TkButton.new($clrpick_demo, 'text'=>'ÇØ·Ê¿§¤òÀßÄê ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'background',
+ ['background', 'highlightbackground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+TkButton.new($clrpick_demo, 'text'=>'Á°·Ê¿§¤òÀßÄê ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+def setColor(w,button,name,options)
+ w.grab
+ initialColor = button[name]
+ color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w,
+ 'initialcolor'=>initialColor)
+ if color != ""
+ setColor_helper(w,options,color)
+ end
+
+ w.grab('release')
+end
+
+def setColor_helper(w, options, color)
+ options.each{|opt|
+ begin
+ w[opt] = color
+ rescue
+ end
+ }
+ TkWinfo.children(w).each{|child|
+ setColor_helper child, options, color
+ }
+end
+
diff --git a/ext/tk/sample/demos-jp/colors.rb b/ext/tk/sample/demos-jp/colors.rb
new file mode 100644
index 0000000000..c6128f9c00
--- /dev/null
+++ b/ext/tk/sample/demos-jp/colors.rb
@@ -0,0 +1,144 @@
+#
+# listbox widget demo 'colors' (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($colors_demo) && $colors_demo
+ $colors_demo.destroy
+ $colors_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$colors_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (colors)")
+ iconname("colors")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($colors_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Ë¤Ï¿§¤Î̾Á°¤¬Æþ¤Ã¤¿¥¹¥¯¥í¡¼¥ë¥Ð¡¼ÉդΥꥹ¥È¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥ê¥¹¥È¤ò¥¹¥¯¥í¡¼¥ë¤µ¤»¤ë¤Î¤Ï¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤Ç¤â¤Ç¤­¤Þ¤¹¤·¡¢¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤ÎÃæ¤Ç¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2(Ãæ¥Ü¥¿¥ó)¤ò²¡¤·¤¿¤Þ¤Þ¥É¥é¥Ã¥°¤·¤Æ¤â¤Ç¤­¤Þ¤¹¡£¤¢¤ë¿§¤ò¥Ü¥¿¥ó1(º¸¥Ü¥¿¥ó)¤Ç¥À¥Ö¥ë¥¯¥ê¥Ã¥¯¤¹¤ë¤È¥¢¥×¥ê¥±¡¼¥·¥ç¥óÁ´ÂΤ¬¤½¤Î¿§¤Ë¤Ê¤ê¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($colors_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $colors_demo
+ $colors_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'colors'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+colors_lbox = nil
+TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
+ s = TkScrollbar.new(w)
+ colors_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 10
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| colors_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+
+ins_data = [
+ 'gray60','gray70','gray80','gray85','gray90','gray95',
+ 'snow1','snow2','snow3','snow4','seashell1','seashell2',
+ 'seashell3','seashell4','AntiqueWhite1','AntiqueWhite2',
+ 'AntiqueWhite3','AntiqueWhite4','bisque1','bisque2',
+ 'bisque3','bisque4','PeachPuff1','PeachPuff2',
+ 'PeachPuff3','PeachPuff4','NavajoWhite1','NavajoWhite2',
+ 'NavajoWhite3','NavajoWhite4','LemonChiffon1',
+ 'LemonChiffon2','LemonChiffon3','LemonChiffon4',
+ 'cornsilk1','cornsilk2','cornsilk3','cornsilk4',
+ 'ivory1','ivory2','ivory3','ivory4','honeydew1',
+ 'honeydew2','honeydew3','honeydew4','LavenderBlush1',
+ 'LavenderBlush2','LavenderBlush3','LavenderBlush4',
+ 'MistyRose1','MistyRose2','MistyRose3','MistyRose4',
+ 'azure1','azure2','azure3','azure4','SlateBlue1',
+ 'SlateBlue2','SlateBlue3','SlateBlue4','RoyalBlue1',
+ 'RoyalBlue2','RoyalBlue3','RoyalBlue4','blue1','blue2',
+ 'blue3','blue4','DodgerBlue1','DodgerBlue2',
+ 'DodgerBlue3','DodgerBlue4','SteelBlue1','SteelBlue2',
+ 'SteelBlue3','SteelBlue4','DeepSkyBlue1','DeepSkyBlue2',
+ 'DeepSkyBlue3','DeepSkyBlue4','SkyBlue1','SkyBlue2',
+ 'SkyBlue3','SkyBlue4','LightSkyBlue1','LightSkyBlue2',
+ 'LightSkyBlue3','LightSkyBlue4','SlateGray1',
+ 'SlateGray2','SlateGray3','SlateGray4',
+ 'LightSteelBlue1','LightSteelBlue2','LightSteelBlue3',
+ 'LightSteelBlue4','LightBlue1','LightBlue2',
+ 'LightBlue3','LightBlue4','LightCyan1','LightCyan2',
+ 'LightCyan3','LightCyan4','PaleTurquoise1',
+ 'PaleTurquoise2','PaleTurquoise3','PaleTurquoise4',
+ 'CadetBlue1','CadetBlue2','CadetBlue3','CadetBlue4',
+ 'turquoise1','turquoise2','turquoise3','turquoise4',
+ 'cyan1','cyan2','cyan3','cyan4','DarkSlateGray1',
+ 'DarkSlateGray2','DarkSlateGray3','DarkSlateGray4',
+ 'aquamarine1','aquamarine2','aquamarine3','aquamarine4',
+ 'DarkSeaGreen1','DarkSeaGreen2','DarkSeaGreen3',
+ 'DarkSeaGreen4','SeaGreen1','SeaGreen2','SeaGreen3',
+ 'SeaGreen4','PaleGreen1','PaleGreen2','PaleGreen3',
+ 'PaleGreen4','SpringGreen1','SpringGreen2',
+ 'SpringGreen3','SpringGreen4','green1','green2',
+ 'green3','green4','chartreuse1','chartreuse2',
+ 'chartreuse3','chartreuse4','OliveDrab1','OliveDrab2',
+ 'OliveDrab3','OliveDrab4','DarkOliveGreen1',
+ 'DarkOliveGreen2','DarkOliveGreen3','DarkOliveGreen4',
+ 'khaki1','khaki2','khaki3','khaki4','LightGoldenrod1',
+ 'LightGoldenrod2','LightGoldenrod3','LightGoldenrod4',
+ 'LightYellow1','LightYellow2','LightYellow3',
+ 'LightYellow4','yellow1','yellow2','yellow3','yellow4',
+ 'gold1','gold2','gold3','gold4','goldenrod1',
+ 'goldenrod2','goldenrod3','goldenrod4','DarkGoldenrod1',
+ 'DarkGoldenrod2','DarkGoldenrod3','DarkGoldenrod4',
+ 'RosyBrown1','RosyBrown2','RosyBrown3','RosyBrown4',
+ 'IndianRed1','IndianRed2','IndianRed3','IndianRed4',
+ 'sienna1','sienna2','sienna3','sienna4','burlywood1',
+ 'burlywood2','burlywood3','burlywood4','wheat1',
+ 'wheat2','wheat3','wheat4','tan1','tan2','tan3','tan4',
+ 'chocolate1','chocolate2','chocolate3','chocolate4',
+ 'firebrick1','firebrick2','firebrick3','firebrick4',
+ 'brown1','brown2','brown3','brown4','salmon1','salmon2',
+ 'salmon3','salmon4','LightSalmon1','LightSalmon2',
+ 'LightSalmon3','LightSalmon4','orange1','orange2',
+ 'orange3','orange4','DarkOrange1','DarkOrange2',
+ 'DarkOrange3','DarkOrange4','coral1','coral2','coral3',
+ 'coral4','tomato1','tomato2','tomato3','tomato4',
+ 'OrangeRed1','OrangeRed2','OrangeRed3','OrangeRed4',
+ 'red1','red2','red3','red4','DeepPink1','DeepPink2',
+ 'DeepPink3','DeepPink4','HotPink1','HotPink2',
+ 'HotPink3','HotPink4','pink1','pink2','pink3','pink4',
+ 'LightPink1','LightPink2','LightPink3','LightPink4',
+ 'PaleVioletRed1','PaleVioletRed2','PaleVioletRed3',
+ 'PaleVioletRed4','maroon1','maroon2','maroon3',
+ 'maroon4','VioletRed1','VioletRed2','VioletRed3',
+ 'VioletRed4','magenta1','magenta2','magenta3',
+ 'magenta4','orchid1','orchid2','orchid3','orchid4',
+ 'plum1','plum2','plum3','plum4','MediumOrchid1',
+ 'MediumOrchid2','MediumOrchid3','MediumOrchid4',
+ 'DarkOrchid1','DarkOrchid2','DarkOrchid3',
+ 'DarkOrchid4','purple1','purple2','purple3','purple4',
+ 'MediumPurple1','MediumPurple2','MediumPurple3',
+ 'MediumPurple4','thistle1','thistle2','thistle3', 'thistle4'
+]
+
+colors_lbox.insert(0, *ins_data)
diff --git a/ext/tk/sample/demos-jp/cscroll.rb b/ext/tk/sample/demos-jp/cscroll.rb
new file mode 100644
index 0000000000..0d6db69af6
--- /dev/null
+++ b/ext/tk/sample/demos-jp/cscroll.rb
@@ -0,0 +1,131 @@
+#
+# simple scrollable canvas widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($cscroll_demo) && $cscroll_demo
+ $cscroll_demo.destroy
+ $cscroll_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$cscroll_demo = TkToplevel.new {|w|
+ title("Scrollable Canvas Demonstration")
+ iconname("cscroll")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i',
+ 'justify'=>'left', 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤ä¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2 ¤Ç¥¹¥¯¥í¡¼¥ë¤Ç¤­¤ë¥­¥ã¥ó¥Ð¥¹ widget ¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£»Í³Ñ¤Î¾å¤Ç¥Ü¥¿¥ó1 ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬É¸½à½ÐÎϤ˽ÐÎϤµ¤ì¤Þ¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$cscroll_buttons = TkFrame.new($cscroll_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $cscroll_demo
+ $cscroll_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'cscroll'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame ÀßÄê
+unless $tk_version =~ /^4\.[01]/
+ $cscroll_grid = TkFrame.new($cscroll_demo) {
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+ }
+ TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+end
+
+# canvas ÀßÄê
+$cscroll_canvas = TkCanvas.new($cscroll_demo,
+ 'relief'=>'sunken', 'borderwidth'=>2,
+ 'scrollregion'=>['-11c', '-11c', '50c', '20c']
+ ) {|c|
+ if $tk_version =~ /^4\.[01]/
+ pack('expand'=>'yes', 'fill'=>'both')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+
+ TkScrollbar.new($cscroll_demo, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'right', 'fill'=>'y')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+
+ TkScrollbar.new($cscroll_demo, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}) {|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'bottom', 'fill'=>'x')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+}
+
+bg = $cscroll_canvas.configinfo('bg')[4]
+(0..19).each{|i|
+ x = -10+3*i
+ y = -10
+ (0..9).each{|j|
+ TkcRectangle.new($cscroll_canvas, "#{x}c", "#{y}c", "#{x+2}c", "#{y+2}c",
+ 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect')
+ TkcText.new($cscroll_canvas, "#{x+1}c", "#{y+1}c",
+ 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text')
+ y += 3
+ }
+}
+
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Leave', proc{scrollLeave $cscroll_canvas})
+$cscroll_canvas.itembind('all', '1', proc{scrollButton $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.bind('2', proc{|x,y| $cscroll_canvas.scan_mark(x,y)}, '%x %y')
+$cscroll_canvas.bind('B2-Motion',
+ proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y')
+
+def scrollEnter(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ $oldFill = c.itemconfiginfo(id, 'fill')[4]
+ if TkWinfo.depth(c) > 1
+ c.itemconfigure(id, 'fill'=>'SeaGreen1')
+ else
+ c.itemconfigure(id, 'fill'=>'black')
+ c.itemconfigure(id+1, 'fill'=>'white')
+ end
+end
+
+def scrollLeave(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ c.itemconfigure(id, 'fill'=>$oldFill)
+ c.itemconfigure(id+1, 'fill'=>'black')
+end
+
+def scrollButton(c)
+ id = c.find_withtag('current')[0].id
+ id += 1 unless c.gettags('current').include?('text')
+ print "You buttoned at #{c.itemconfiginfo(id,'text')[4]}\n"
+end
+
diff --git a/ext/tk/sample/demos-jp/ctext.rb b/ext/tk/sample/demos-jp/ctext.rb
new file mode 100644
index 0000000000..a71b6f2cb0
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ctext.rb
@@ -0,0 +1,182 @@
+#
+# Canvas Text widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($ctext_demo) && $ctext_demo
+ $ctext_demo.destroy
+ $ctext_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$ctext_demo = TkToplevel.new {|w|
+ title("Canvas Text Demonstration")
+ iconname("Text")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥­¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥­¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Î¥Æ¥­¥¹¥Èʸ»úÎó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥Þ¥¦¥¹¤ò»Í³Ñ¤ÎÃæ¤Ë»ý¤Ã¤Æ¤¤¤­¡¢¥¯¥ê¥Ã¥¯¤¹¤ë¤È°ÌÃÖ¤®¤áÍѤÎÅÀ¤«¤é¤ÎÁêÂаÌÃÖ¤òÊѤ¨¤¿¤ê¡¢¹Ô·¤¨¤òÊѤ¨¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤Þ¤¿°Ê²¼¤Î¤è¤¦¤ÊÊÔ½¸¤Î¤¿¤á¤Î´Êñ¤Ê¥Ð¥¤¥ó¥Ç¥£¥ó¥°¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£
+
+ 1. ¥Þ¥¦¥¹¤ò»ý¤Ã¤Æ¤¤¤­¡¢¥¯¥ê¥Ã¥¯¤·¡¢ÆþÎϤǤ­¤Þ¤¹¡£
+ 2. ¥Ü¥¿¥ó1¤ÇÁªÂò¤Ç¤­¤Þ¤¹¡£
+ 3. ¥Þ¥¦¥¹¤Î°ÌÃ֤˥ܥ¿¥ó2¤ÇÁªÂò¤·¤¿¥Æ¥­¥¹¥È¤ò¥³¥Ô¡¼¤Ç¤­¤Þ¤¹¡£
+ 4.¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹¤ò¥³¥ó¥È¥í¡¼¥ë-H¤ÇÁÞÆþ¥«¡¼¥½¥ë¤ÎľÁ°¤Îʸ»ú¤òºï½ü¤·¤Þ¤¹¡£
+ 5. Delete¥­¡¼¤ÏÁÞÆþ¥«¡¼¥½¥ë¤Îľ¸å¤Îʸ»ú¤òºï½ü¤·¤Þ¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$ctext_buttons = TkFrame.new($ctext_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $ctext_demo
+ $ctext_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'ctext'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas À¸À®
+$ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat',
+ 'borderwidth'=>0, 'width'=>500, 'height'=>350)
+$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+
+# font ÀßÄê
+textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+
+# canvas ÀßÄê
+TkcRectangle.new($ctext_canvas, 245, 195, 255, 205,
+ 'outline'=>'black', 'fill'=>'red')
+
+$ctag_text = TkcTag.new($ctext_canvas)
+$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200,
+ 'text'=>"¤³¤ì¤Ï¥­¥ã¥ó¥Ð¥¹widget¤Î¥Æ¥­¥¹¥Èµ¡Ç½¤ò¥Ç¥â¤¹¤ë¤¿¤á¤Îʸ»úÎó¤Ç¤¹¡£¥Þ¥¦¥¹¤ò»ý¤Ã¤Æ¤¤¤­¡¢¥¯¥ê¥Ã¥¯¤·¤ÆÆþÎϤǤ­¤Þ¤¹¡£ÁªÂò¤·¤Æ¥³¥ó¥È¥í¡¼¥ë-D¤Ç¾Ãµî¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£",
+ 'width'=>440, 'anchor'=>'n',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*',
+ 'kanjifont'=>'-*-r-*--24-*-jisx0208.1983-0',
+ 'justify'=>'left') )
+
+$ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('Shift-1',
+ proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"},
+ "%x %y")
+$ctag_text.bind('Shift-B1-Motion',
+ proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('KeyPress', proc{|a| textInsert $ctext_canvas,a}, "%A")
+$ctag_text.bind('Return', proc{textInsert $ctext_canvas,"\n"})
+$ctag_text.bind('Control-h', proc{textBs $ctext_canvas})
+$ctag_text.bind('BackSpace', proc{textBs $ctext_canvas})
+$ctag_text.bind('Delete', proc{textDel $ctext_canvas})
+$ctag_text.bind('2', proc{|x,y| textPaste $ctext_canvas, "@#{x},#{y}"},
+ "%x %y")
+
+# Next, create some items that allow the text's anchor position
+# to be edited.
+
+def mkTextConfig(w,x,y,option,value,color)
+ item = TkcRectangle.new(w, x, y, x+30, y+30,
+ 'outline'=>'black', 'fill'=>color, 'width'=>1)
+ item.bind('1', proc{$ctag_text.configure option, value})
+ w.addtag_withtag('config', item)
+end
+
+x = 50
+y = 50
+color = 'LightSkyBlue1'
+mkTextConfig $ctext_canvas, x, y, 'anchor', 'se', color
+mkTextConfig $ctext_canvas, x+30, y, 'anchor', 's', color
+mkTextConfig $ctext_canvas, x+60, y, 'anchor', 'sw', color
+mkTextConfig $ctext_canvas, x, y+30, 'anchor', 'e', color
+mkTextConfig $ctext_canvas, x+30, y+30, 'anchor', 'center', color
+mkTextConfig $ctext_canvas, x+60, y+30, 'anchor', 'w', color
+mkTextConfig $ctext_canvas, x, y+60, 'anchor', 'ne', color
+mkTextConfig $ctext_canvas, x+30, y+60, 'anchor', 'n', color
+mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color
+item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50,
+ 'outline'=>'black', 'fill'=>'red')
+item.bind('1', proc{$ctag_text.configure 'anchor', 'center'})
+TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'fill'=>'brown')
+
+# Lastly, create some items that allow the text's justification to be
+# changed.
+
+x = 350
+y = 50
+color = 'SeaGreen2'
+mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color
+mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color
+mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color
+TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'fill'=>'brown')
+
+$ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas})
+$ctext_canvas.itembind('config', 'Leave',
+ proc{$ctext_canvas\
+ .itemconfigure('current',
+ 'fill'=>$textConfigFill)})
+
+$textConfigFill = ''
+
+def textEnter(w)
+ $textConfigFill = (w.itemconfiginfo 'current', 'fill')[4]
+ w.itemconfigure 'current', 'fill', 'black'
+end
+
+def textInsert(w, string)
+ return if string == ""
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ end
+ $ctag_text.insert 'insert', string
+end
+
+def textPaste(w, pos)
+ begin
+ $ctag_text.insert pos, TkSelection.get
+ rescue
+ end
+end
+
+def textB1Press(w,x,y)
+ w.icursor 'current', "@#{x},#{y}"
+ w.itemfocus 'current'
+ w.focus
+ w.select_from 'current', "@#{x},#{y}"
+end
+
+def textB1Move(w,x,y)
+ w.select_to 'current', "@#{x},#{y}"
+end
+
+def textBs(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ char = $ctag_text.index('insert').to_i - 1
+ $ctag_text.dchars(char) if char >= 0
+ end
+end
+
+def textDel(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ $ctag_text.dchars 'insert'
+ end
+end
+
diff --git a/ext/tk/sample/demos-jp/dialog1.rb b/ext/tk/sample/demos-jp/dialog1.rb
new file mode 100644
index 0000000000..0d6181bfc6
--- /dev/null
+++ b/ext/tk/sample/demos-jp/dialog1.rb
@@ -0,0 +1,38 @@
+#
+# a dialog box with a local grab (called by 'widget')
+#
+class TkDialog_Demo1 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with local grab"
+ end
+
+ def message
+ '¥â¡¼¥À¥ë¥À¥¤¥¢¥í¥°¥Ü¥Ã¥¯¥¹¤Ç¤¹¡£Tk ¤Î "grab" ¥³¥Þ¥ó¥É¤ò»ÈÍѤ·¤Æ¥À¥¤¥¢¥í¥°¥Ü¥Ã¥¯¥¹¤Ç¡Ö¥í¡¼¥«¥ë¥°¥é¥Ö¡×¤·¤Æ¤¤¤Þ¤¹¡£²¼¤Î¤¤¤º¤ì¤«¤Î¥Ü¥¿¥ó¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢¤³¤Î¥À¥¤¥¢¥í¥°¤ËÅú¤¨¤ë¤Þ¤Ç¡¢¤³¤Î¥°¥é¥Ö¤Ë¤è¤Ã¤Æ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¾¤Î¥¦¥£¥ó¥É¥¦¤Ç¤Ï¡¢¥Ý¥¤¥ó¥¿´Ø·¸¤Î¥¤¥Ù¥ó¥È¤ò¼õ¤±¼è¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£'
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+# "λ²ò ¥­¥ã¥ó¥»¥ë ¥³¡¼¥É»²¾È"
+ ["λ²ò", "¥­¥ã¥ó¥»¥ë", "¥³¡¼¥É»²¾È"]
+ end
+end
+
+ret = TkDialog_Demo1.new('message_config'=>{'wraplength'=>'4i'}).value
+case ret
+when 0
+ print "¤¢¤Ê¤¿¤Ï¡Öλ²ò¡×¤ò²¡¤·¤Þ¤·¤¿¤Í¡£\n"
+when 1
+ print "¤¢¤Ê¤¿¤Ï¡Ö¥­¥ã¥ó¥»¥ë¡×¤ò²¡¤·¤Þ¤·¤¿¤Í¡£\n"
+when 2
+ showCode 'dialog1'
+end
diff --git a/ext/tk/sample/demos-jp/dialog2.rb b/ext/tk/sample/demos-jp/dialog2.rb
new file mode 100644
index 0000000000..a934378dda
--- /dev/null
+++ b/ext/tk/sample/demos-jp/dialog2.rb
@@ -0,0 +1,42 @@
+#
+# a dialog box with a global grab (called by 'widget')
+#
+class TkDialog_Demo2 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with global grab"
+ end
+
+ def message
+ '¤³¤Î¥À¥¤¥¢¥í¥°¥Ü¥Ã¥¯¥¹¤Ï¥°¥í¡¼¥Ð¥ë¥°¥é¥Ö¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£²¼¤Î¥Ü¥¿¥ó¤ò¼Â¹Ô¤¹¤ë¤Þ¤Ç¡¢¥Ç¥£¥¹¥×¥ì¥¤¾å¤Î¤¤¤«¤Ê¤ë¤â¤Î¤È¤âÂÐÏäǤ­¤Þ¤»¤ó¡£¥°¥í¡¼¥Ð¥ë¥°¥é¥Ö¤ò»ÈÍѤ¹¤ë¤³¤È¤Ï¡¢¤Þ¤ºÎɤ¤¹Í¤¨¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£¤É¤¦¤·¤Æ¤âɬÍפˤʤë¤Þ¤Ç»È¤ª¤¦¤È»×¤ï¤Ê¤¤¤Ç²¼¤µ¤¤¡£'
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+# "λ²ò ¥­¥ã¥ó¥»¥ë ¥³¡¼¥É»²¾È"
+ ["λ²ò", "¥­¥ã¥ó¥»¥ë", "¥³¡¼¥É»²¾È"]
+ end
+end
+
+ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'},
+ 'prev_command'=>proc{|dialog|
+ Tk.after 100, proc{dialog.grab('global')}
+ }).value
+case ret
+when 0
+ print "¤¢¤Ê¤¿¤Ï¡Öλ²ò¡×¤ò²¡¤·¤Þ¤·¤¿¤Í¡£\n"
+when 1
+ print "¤¢¤Ê¤¿¤Ï¡Ö¥­¥ã¥ó¥»¥ë¡×¤ò²¡¤·¤Þ¤·¤¿¤Í¡£\n"
+when 2
+ showCode 'dialog2'
+end
+
diff --git a/ext/tk/sample/demos-jp/doc.org/README b/ext/tk/sample/demos-jp/doc.org/README
new file mode 100644
index 0000000000..90677d3316
--- /dev/null
+++ b/ext/tk/sample/demos-jp/doc.org/README
@@ -0,0 +1,7 @@
+This directory contains a collection of demonstration programs that
+are translated into Japanese. You need to use a Japanized "wish" to
+see these Japanese-translated demonstration programs. You also need
+to put this directory ("demos.jp") at the next to "demos" since some
+of the programs refer to the image files at "demos".
+
+Please refer to the README file at "demos" for more detail.
diff --git a/ext/tk/sample/demos-jp/doc.org/README.JP b/ext/tk/sample/demos-jp/doc.org/README.JP
new file mode 100644
index 0000000000..42b4929378
--- /dev/null
+++ b/ext/tk/sample/demos-jp/doc.org/README.JP
@@ -0,0 +1,14 @@
+This directory contains "widget" demo for the Japanized Tcl7.6/Tk4.2.
+Most of the messages in the original are translated to Japanese.
+But other tools in this directory are not translated.
+
+Following 2 kanji fonts are defined at the beginning of the file "widget."
+
+ -*--24-*-jisx0208.1983-0
+ -*--16-*-jisx0208.1983-0
+
+These fonts are all part of the core distribution of X11R5, so
+if you are running X11R5, you don't have to modify the file.
+
+But if you don't have these fonts, replace them with appropriate ones.
+"-*--14-*-jisx0208.1983-0" will be a good choice.
diff --git a/ext/tk/sample/demos-jp/doc.org/README.tk80 b/ext/tk/sample/demos-jp/doc.org/README.tk80
new file mode 100644
index 0000000000..c71f977d74
--- /dev/null
+++ b/ext/tk/sample/demos-jp/doc.org/README.tk80
@@ -0,0 +1,46 @@
+This directory contains a collection of programs to demonstrate
+the features of the Tk toolkit. The programs are all scripts for
+"wish", a windowing shell. If wish has been installed in /usr/local
+then you can invoke any of the programs in this directory just
+by typing its file name to your command shell. Otherwise invoke
+wish with the file as its first argument, e.g., "wish hello".
+The rest of this file contains a brief description of each program.
+Files with names ending in ".tcl" are procedure packages used by one
+or more of the demo programs; they can't be used as programs by
+themselves so they aren't described below.
+
+hello - Creates a single button; if you click on it, a message
+ is typed and the application terminates.
+
+widget - Contains a collection of demonstrations of the widgets
+ currently available in the Tk library. Most of the .tcl
+ files are scripts for individual demos available through
+ the "widget" program.
+
+ixset - A simple Tk-based wrapper for the "xset" program, which
+ allows you to interactively query and set various X options
+ such as mouse acceleration and bell volume. Thanks to
+ Pierre David for contributing this example.
+
+rolodex - A mock-up of a simple rolodex application. It has much of
+ the user interface for such an application but no back-end
+ database. This program was written in response to Tom
+ LaStrange's toolkit benchmark challenge.
+
+tcolor - A color editor. Allows you to edit colors in several
+ different ways, and will also perform automatic updates
+ using "send".
+
+rmt - Allows you to "hook-up" remotely to any Tk application
+ on the display. Select an application with the menu,
+ then just type commands: they'll go to that application.
+
+timer - Displays a seconds timer with start and stop buttons.
+ Control-c and control-q cause it to exit.
+
+browse - A simple directory browser. Invoke it with and argument
+ giving the name of the directory you'd like to browse.
+ Double-click on files or subdirectories to browse them.
+ Control-c and control-q cause the program to exit.
+
+sccs id = SCCS: @(#) README 1.3 96/02/16 10:49:14
diff --git a/ext/tk/sample/demos-jp/doc.org/license.terms b/ext/tk/sample/demos-jp/doc.org/license.terms
new file mode 100644
index 0000000000..03ca6fcb31
--- /dev/null
+++ b/ext/tk/sample/demos-jp/doc.org/license.terms
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/demos-jp/doc.org/license.terms.tk80 b/ext/tk/sample/demos-jp/doc.org/license.terms.tk80
new file mode 100644
index 0000000000..03ca6fcb31
--- /dev/null
+++ b/ext/tk/sample/demos-jp/doc.org/license.terms.tk80
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/demos-jp/entry1.rb b/ext/tk/sample/demos-jp/entry1.rb
new file mode 100644
index 0000000000..edf3b5f71d
--- /dev/null
+++ b/ext/tk/sample/demos-jp/entry1.rb
@@ -0,0 +1,57 @@
+#
+# entry (no scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($entry1_demo) && $entry1_demo
+ $entry1_demo.destroy
+ $entry1_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$entry1_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (no scrollbars)")
+ iconname("entry1")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($entry1_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "3¼ïÎà¤Î°Û¤Ê¤ë¥¨¥ó¥È¥ê¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Ê¸»ú¤òÆþÎϤ¹¤ë¤Ë¤Ï¥Ý¥¤¥ó¥¿¤ò»ý¤Ã¤Æ¹Ô¤­¡¢¥¯¥ê¥Ã¥¯¤·¤Æ¤«¤é¥¿¥¤¥×¤·¤Æ¤¯¤À¤µ¤¤¡£É¸½àŪ¤ÊMotif¤ÎÊÔ½¸µ¡Ç½¤¬¡¢Emacs¤Î¥­¡¼¥Ð¥¤¥ó¥É¤È¤È¤â¤Ë¡¢¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Î㤨¤Ð¡¢¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹¤È¥³¥ó¥È¥í¡¼¥ë-H¤Ï¥«¡¼¥½¥ë¤Îº¸¤Îʸ»ú¤òºï½ü¤·¡¢¥Ç¥ê¡¼¥È¥­¡¼¤È¥³¥ó¥È¥í¡¼¥ë-D¤Ï¥«¡¼¥½¥ë¤Î±¦Â¦¤Îʸ»ú¤òºï½ü¤·¤Þ¤¹¡£Ä¹²á¤®¤Æ¥¦¥£¥ó¥É¥¦¤ËÆþ¤êÀÚ¤é¤Ê¤¤¤â¤Î¤Ï¡¢¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2¤ò²¡¤·¤¿¤Þ¤Þ¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¥¹¥¯¥í¡¼¥ë¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ÆüËܸì¤òÆþÎϤ¹¤ë¤Î¤Ï¥³¥ó¥È¥í¡¼¥ë-¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤Ç¤¹¡£kinput2¤¬Æ°¤¤¤Æ¤¤¤ì¤ÐÆþÎϤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($entry1_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $entry1_demo
+ $entry1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'entry1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# entry À¸À®
+e1 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+e2 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+e3 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
+[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')}
+
+# ½é´üÃÍÁÞÆþ
+e1.insert(0, '½é´üÃÍ')
+e2.insert('end', "¤³¤Î¥¨¥ó¥È¥ê¤Ë¤ÏŤ¤Ê¸»úÎ󤬯þ¤Ã¤Æ¤¤¤Æ¡¢")
+e2.insert('end', "Ť¹¤®¤Æ¥¦¥£¥ó¥É¥¦¤Ë¤ÏÆþ¤êÀÚ¤é¤Ê¤¤¤Î¤Ç¡¢")
+e2.insert('end', "¼ÂºÝ¤Î½ê½ª¤ê¤Þ¤Ç¸«¤ë¤Ë¤Ï¥¹¥¯¥í¡¼¥ë¤µ¤»¤Ê¤±¤ì¤Ð")
+e2.insert('end', "¤Ê¤é¤Ê¤¤¤Ç¤·¤ç¤¦¡£")
+
diff --git a/ext/tk/sample/demos-jp/entry2.rb b/ext/tk/sample/demos-jp/entry2.rb
new file mode 100644
index 0000000000..7d5740e663
--- /dev/null
+++ b/ext/tk/sample/demos-jp/entry2.rb
@@ -0,0 +1,88 @@
+#
+# entry (with scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($entry2_demo) && $entry2_demo
+ $entry2_demo.destroy
+ $entry2_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$entry2_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (with scrollbars)")
+ iconname("entry2")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($entry2_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "3¼ïÎà¤Î°Û¤Ê¤ë¥¨¥ó¥È¥ê¤¬³Æ¡¹¥¹¥¯¥í¡¼¥ë¥Ð¡¼ÉÕ¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Ê¸»ú¤òÆþÎϤ¹¤ë¤Ë¤Ï¥Ý¥¤¥ó¥¿¤ò»ý¤Ã¤Æ¹Ô¤­¡¢¥¯¥ê¥Ã¥¯¤·¤Æ¤«¤é¥¿¥¤¥×¤·¤Æ¤¯¤À¤µ¤¤¡£É¸½àŪ¤ÊMotif¤ÎÊÔ½¸µ¡Ç½¤¬¡¢Emacs¤Î¥­¡¼¥Ð¥¤¥ó¥É¤È¤È¤â¤Ë¡¢¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Î㤨¤Ð¡¢¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹¤È¥³¥ó¥È¥í¡¼¥ë-H¤Ï¥«¡¼¥½¥ë¤Îº¸¤Îʸ»ú¤òºï½ü¤·¡¢¥Ç¥ê¡¼¥È¥­¡¼¤È¥³¥ó¥È¥í¡¼¥ë-D¤Ï¥«¡¼¥½¥ë¤Î±¦Â¦¤Îʸ»ú¤òºï½ü¤·¤Þ¤¹¡£Ä¹²á¤®¤Æ¥¦¥£¥ó¥É¥¦¤ËÆþ¤êÀÚ¤é¤Ê¤¤¤â¤Î¤Ï¡¢¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2¤ò²¡¤·¤¿¤Þ¤Þ¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¥¹¥¯¥í¡¼¥ë¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ÆüËܸì¤òÆþÎϤ¹¤ë¤Î¤Ï¥³¥ó¥È¥í¡¼¥ë-¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤Ç¤¹¡£kinput2¤¬Æ°¤¤¤Æ¤¤¤ì¤ÐÆþÎϤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($entry2_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $entry2_demo
+ $entry2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'entry2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+TkFrame.new($entry2_demo, 'borderwidth'=>10) {|w|
+ # entry 1
+ s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e1 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s1.set first,last}
+ }
+ s1.command(proc{|*args| e1.xview(*args)})
+ e1.pack('side'=>'top', 'fill'=>'x')
+ s1.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 2
+ s2 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e2 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s2.set first,last}
+ }
+ s2.command(proc{|*args| e2.xview(*args)})
+ e2.pack('side'=>'top', 'fill'=>'x')
+ s2.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 3
+ s3 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e3 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s3.set first,last}
+ }
+ s3.command(proc{|*args| e3.xview(*args)})
+ e3.pack('side'=>'top', 'fill'=>'x')
+ s3.pack('side'=>'top', 'fill'=>'x')
+
+ # ½é´üÃÍÁÞÆþ
+ e1.insert(0, '½é´üÃÍ')
+ e2.insert('end', "¤³¤Î¥¨¥ó¥È¥ê¤Ë¤ÏŤ¤Ê¸»úÎ󤬯þ¤Ã¤Æ¤¤¤Æ¡¢")
+ e2.insert('end', "Ť¹¤®¤Æ¥¦¥£¥ó¥É¥¦¤Ë¤ÏÆþ¤êÀÚ¤é¤Ê¤¤¤Î¤Ç¡¢")
+ e2.insert('end', "¼ÂºÝ¤Î½ê½ª¤ê¤Þ¤Ç¸«¤ë¤Ë¤Ï¥¹¥¯¥í¡¼¥ë¤µ¤»¤Ê¤±¤ì¤Ð")
+ e2.insert('end', "¤Ê¤é¤Ê¤¤¤Ç¤·¤ç¤¦¡£")
+
+}.pack('side'=>'top', 'fill'=>'x', 'expand'=>'yes')
+
diff --git a/ext/tk/sample/demos-jp/entry3.rb b/ext/tk/sample/demos-jp/entry3.rb
new file mode 100644
index 0000000000..f57dc13553
--- /dev/null
+++ b/ext/tk/sample/demos-jp/entry3.rb
@@ -0,0 +1,204 @@
+# entry3.rb --
+#
+# This demonstration script creates several entry widgets whose
+# permitted input is constrained in some way. It also shows off a
+# password entry.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($entry3_demo) && $entry3_demo
+ $entry3_demo.destroy
+ $entry3_demo = nil
+end
+
+$entry3_demo = TkToplevel.new {|w|
+ title("Constrained Entry Demonstration")
+ iconname("entry3")
+ positionWindow(w)
+}
+
+TkLabel.new($entry3_demo,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+°Ê²¼¤Ë¤Ï£´¼ïÎà¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡¥³Æ¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤Ï¡¤\
+¥Þ¥¦¥¹¥¯¥ê¥Ã¥¯¤ÇÁªÂò¤·Ê¸»ú¤òÂǤÁ¹þ¤à¤³¤È¤¬²Äǽ¤Ç¤¹¤¬¡¤¤½¤ì¤¾¤ì¤¬¤É¤Î¤è¤¦¤Ê\
+ÆþÎϤò¼õ¤±ÉÕ¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¤«¤Ë¤ÏÀ©Ìó¤¬Àߤ±¤é¤ì¤Æ¤¤¤Þ¤¹¡¥\
+°ì¤Ä¤á¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤ÏÀ°¿ô¤È¸«¤Ê¤µ¤ì¤ëʸ»úÎ󤫯þÎÏʸ»ú¤¬¤Ê¤¤¶õ¤Î¾õÂÖ¤«\
+¤Î¾ì¹ç¤À¤±¤ò¼õ¤±ÉÕ¤±¡¤ÌäÂ꤬¤¢¤ë¾ì¹ç¤Ï¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤¬ÅÀÌǤ·¤Þ¤¹\
+¡Ê¥Õ¥©¡¼¥«¥¹¤¬µî¤ë»þ¤Ë¥Á¥§¥Ã¥¯¤µ¤ì¤Þ¤¹¡Ë¡¥\
+Æó¤Ä¤á¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤Ï¡¤ÆþÎϤµ¤ì¤¿Ê¸»úÎó¤ÎŤµ¤¬\
+£±£°Ê¸»ṳ́Ëþ¤Î¾ì¹ç¤À¤±¤ò¼õ¤±ÉÕ¤±¡¤À©¸Â¤ò±Û¤¨¤Æ½ñ¤­¹þ¤â¤¦¤È¤·¤¿¤È¤­¤Ë¤Ï\
+¥Ù¥ë¤òÌĤ餷¤ÆÃΤ餻¤Þ¤¹¡¥\
+»°¤Ä¤á¤ÏÊÆ¹ñ¤ÎÅÅÏÃÈÖ¹æ¤ò¼õ¤±ÉÕ¤±¤ë¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤Ç¤¹¡¥\
+¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ï¡¤ÅÅÏõ¡¤Î¥À¥¤¥ä¥ë¾å¤ÇÂбþ¤Å¤±¤é¤ì¤Æ¤¤¤ë¿ô»ú¤ËÊÑ´¹¤µ¤ì¤Þ¤¹¡¥\
+ÉÔŬÀÚ¤Êʸ»ú¤¬ÆþÎϤµ¤ì¤¿¤ê¿ô»ú°Ê³°¤Îʸ»ú¤Î°ÌÃ֤˿ô»ú¤òÆþÎϤ·¤è¤¦¤È¤·¤¿¤ê\
+¤·¤¿¾ì¹ç¤Ë¤Ï·Ù¹ð¤Î¥Ù¥ë¤¬ÌĤê¤Þ¤¹¡¥\
+»Í¤Ä¤á¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤Ï¡¤£¸Ê¸»ú¤Þ¤Ç¤ÎÆþÎϤò¼õ¤±ÉÕ¤±¤ë\
+¥Ñ¥¹¥ï¡¼¥É¥Õ¥£¡¼¥ë¥É¤Ç¤¹¡Ê£¸Ê¸»ú°Ê¾å¤ÏÆÃ¤Ë·Ù¹ð¤ò½Ð¤¹¤³¤È¤Ê¤¯Ìµ»ë¤µ¤ì¤Þ¤¹¡Ë¡¥\
+ÆþÎϤµ¤ì¤¿Ê¸»ú¤Ï¥¢¥¹¥¿¥ê¥¹¥¯µ­¹æ¤ËÃÖ¤­´¹¤¨¤ÆÉ½¼¨¤µ¤ì¤Þ¤¹¡¥
+EOL
+
+TkFrame.new($entry3_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
+ $entry3_demo.destroy
+ $entry3_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{
+ showCode 'entry3'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# focusAndFlash --
+# Error handler for entry widgets that forces the focus onto the
+# widget and makes the widget flash by exchanging the foreground and
+# background colours at intervals of 200ms (i.e. at approximately
+# 2.5Hz).
+#
+# Arguments:
+# widget - entry widget to flash
+# fg - Initial foreground colour
+# bg - Initial background colour
+# count - Counter to control the number of times flashed
+def focusAndFlash(widget, fg, bg, count=5)
+ return if count <= 0
+ TkTimer.new(100, count,
+ proc{widget.configure(:foreground=>bg, :background=>fg)},
+ proc{widget.configure(:foreground=>fg, :background=>bg)}
+ ).start
+ widget.focus(true)
+end
+
+l1 = TkLabelFrame.new($entry3_demo, :text=>"À°¿ô¥¨¥ó¥È¥ê")
+TkEntry.new(l1, :validate=>:focus,
+ :vcmd=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]) {|e|
+ invalidcommand [proc{|w| focusAndFlash(w, e.fg, e.bg)}, '%W']
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l2 = TkLabelFrame.new($entry3_demo, :text=>"ŤµÀ©ÌóÉÕ¤­¥¨¥ó¥È¥ê")
+TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :vcmd=>[proc{|s| s.length < 10}, '%P']
+ ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+### PHONE NUMBER ENTRY ###
+# Note that the source to this is quite a bit longer as the behaviour
+# demonstrated is a lot more ambitious than with the others.
+
+# Initial content for the third entry widget
+entry3content = TkVariable.new("1-(000)-000-0000")
+
+# Mapping from alphabetic characters to numbers.
+$phoneNumberMap = {}
+Hash[*(%w(abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9))].each{|chars, n|
+ chars.split('').each{|c|
+ $phoneNumberMap[c] = n
+ $phoneNumberMap[c.upcase] = n
+ }
+}
+
+# phoneSkipLeft --
+# Skip over fixed characters in a phone-number string when moving left.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+def phoneSkipLeft(widget)
+ idx = widget.index('insert')
+ if idx == 8
+ # Skip back two extra characters
+ widget.cursor = idx - 2
+ elsif idx == 7 || idx == 12
+ # Skip back one extra character
+ widget.cursor = idx - 1
+ elsif idx <= 3
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# phoneSkipRight --
+# Skip over fixed characters in a phone-number string when moving right.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+# add - Offset to add to index before calculation (used by validation.)
+def phoneSkipRight(widget, add = 0)
+ idx = widget.index('insert')
+ if (idx + add == 5)
+ # Skip forward two extra characters
+ widget.cursor = idx + 2
+ elsif (idx + add == 6 || idx + add == 10)
+ # Skip forward one extra character
+ widget.cursor = idx + 1
+ elsif (idx + add == 15 && add == 0)
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# validatePhoneChange --
+# Checks that the replacement (mapped to a digit) of the given
+# character in an entry widget at the given position will leave a
+# valid phone number in the widget.
+#
+# widget - entry widget to validate
+# vmode - The widget's validation mode
+# idx - The index where replacement is to occur
+# char - The character (or string, though that will always be
+# refused) to be overwritten at that point.
+
+def validatePhoneChange(widget, vmode, idx, char)
+ return true if idx == nil
+ Tk.after_idle(proc{widget.configure(:validate=>vmode,
+ :invcmd=>proc{Tk.bell})})
+ if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/
+ widget.delete(idx)
+ widget.insert(idx, $phoneNumberMap[char] || char)
+ Tk.after_idle(proc{phoneSkipRight(widget, -1)})
+ # Tk.update(true) # Don't work 'update' inter validation callback.
+ # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
+ return true
+ end
+ return false
+end
+
+
+l3 = TkLabelFrame.new($entry3_demo, :text=>"ÊÆ¹ñÅÅÏÃÈֹ楨¥ó¥È¥ê")
+TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :textvariable=>entry3content,
+ :vcmd=>[
+ proc{|w,v,i,s| validatePhoneChange(w,v,i,s)},
+ "%W %v %i %S"
+ ]){|e|
+ # Click to focus goes to the first editable character...
+ bind('FocusIn', proc{|d,w|
+ if d != "NotifyAncestor"
+ w.cursor = 3
+ Tk.after_idle(proc{w.selection_clear})
+ end
+ }, '%d %W')
+ bind('Left', proc{|w| phoneSkipLeft(w)}, '%W')
+ bind('Right', proc{|w| phoneSkipRight(w)}, '%W')
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l4 = TkLabelFrame.new($entry3_demo, :text=>"¥Ñ¥¹¥ï¡¼¥É¥¨¥ó¥È¥ê")
+TkEntry.new(l4, :validate=>:key, :show=>'*',
+ :vcmd=>[
+ proc{|s| s.length <= 8},
+ '%P'
+ ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+TkFrame.new($entry3_demo){|f|
+ lower
+ TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.columnconfigure(f, [0,1], :uniform=>1)
+ pack(:fill=>:both, :expand=>true)
+}
diff --git a/ext/tk/sample/demos-jp/filebox.rb b/ext/tk/sample/demos-jp/filebox.rb
new file mode 100644
index 0000000000..f3608ab70f
--- /dev/null
+++ b/ext/tk/sample/demos-jp/filebox.rb
@@ -0,0 +1,96 @@
+#
+# widget demo prompts the user to select a file (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($filebox_demo) && $entry2_demo
+ $filebox_demo.destroy
+ $filebox_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$filebox_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("filebox")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"¥¨¥ó¥È¥ê¤Ë¥Õ¥¡¥¤¥ë̾¤òľÀÜÆþÎϤ¹¤ë¤«¡¢\"Browse\" ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°¤«¤é¥Õ¥¡¥¤¥ë̾¤òÁª¤ó¤Ç²¼¤µ¤¤¡£").pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($filebox_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $filebox_demo
+ $filebox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'filebox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+['³«¤¯', 'Êݸ'].each{|type|
+ TkFrame.new($filebox_demo) {|f|
+ TkLabel.new(f, 'text'=>"¥Õ¥¡¥¤¥ë¤ò#{type}: ", 'anchor'=>'e')\
+ .pack('side'=>'left')
+
+ TkEntry.new(f, 'width'=>20) {|e|
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+
+ TkButton.new(f, 'text'=>'Browse ...',
+ 'command'=>proc{fileDialog $filebox_demo,e,type})\
+ .pack('side'=>'left')
+ }
+
+ pack('fill'=>'x', 'padx'=>'1c', 'pady'=>3)
+ }
+}
+
+$tk_strictMotif = TkVarAccess.new('tk_strictMotif')
+if ($tk_platform['platform'] == 'unix')
+ TkCheckButton.new($filebox_demo,
+ 'text'=>'Motif¥¹¥¿¥¤¥ë¤Î¥À¥¤¥¢¥í¥°¤òÍѤ¤¤ë',
+ 'variable'=>$tk_strictMotif,
+ 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c')
+end
+
+def fileDialog(w,ent,operation)
+ # Type names Extension(s) Mac File Type(s)
+ #
+ #--------------------------------------------------------
+ types = [
+ ['Text files', ['.txt','.doc'] ],
+ ['Text files', [], 'TEXT' ],
+ ['Ruby Scripts', ['.rb'], 'TEXT' ],
+ ['Tcl Scripts', ['.tcl'], 'TEXT' ],
+ ['C Source Files', ['.c','.h'] ],
+ ['All Source Files', ['.rb','.tcl','.c','.h'] ],
+ ['Image Files', ['.gif'] ],
+ ['Image Files', ['.jpeg','.jpg'] ],
+ ['Image Files', [], ['GIFF','JPEG']],
+ ['All files', '*' ]
+ ]
+
+ if operation == '³«¤¯'
+ file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w)
+ else
+ file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w,
+ 'initialfile'=>'Untitled',
+ 'defaultextension'=>'.txt')
+ end
+ if file != ""
+ ent.delete 0, 'end'
+ ent.insert 0, file
+ ent.xview 'end'
+ end
+end
+
diff --git a/ext/tk/sample/demos-jp/floor.rb b/ext/tk/sample/demos-jp/floor.rb
new file mode 100644
index 0000000000..517600de92
--- /dev/null
+++ b/ext/tk/sample/demos-jp/floor.rb
@@ -0,0 +1,1718 @@
+#
+# floorDisplay widget demo (called by 'widget')
+#
+
+# floorDisplay --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay(w,active)
+ return if $activeFloor == active
+
+ w.delete('all')
+ $activeFloor = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor_bg1(w,$floor_colors['bg1'],$floor_colors['outline1'])
+ floor_bg2(w,$floor_colors['bg2'],$floor_colors['outline2'])
+ floor_bg3(w,$floor_colors['bg3'],$floor_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ TkcRectangle.new(w,0,100,1,101, 'fill'=>'', 'outline'=>'', 'tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels.clear
+ $floorItems.clear
+ send("floor_fg#{active}", w, $floor_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ TkcWindow.new(w, 600, 100, 'anchor'=>'w', 'window'=>$floor_entry)
+ TkcText.new(w, 600, 100, 'anchor'=>'e', 'text'=>"Éô²°ÈÖ¹æ: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom.value = $floorLabels[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged(w,*args)
+ w.delete('highlight')
+ item = $floorItems[$currentRoom.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg1(w,fill,outline)
+ TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg2(w,fill,outline)
+ TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg3(w,fill,outline)
+ TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '101'
+ $floorItems['101'] = i
+ TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Pub Lift1'
+ $floorItems['Pub Lift1'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Priv Lift1'
+ $floorItems['Priv Lift1'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '110'
+ $floorItems['110'] = i
+ TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '109'
+ $floorItems['109'] = i
+ TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '111'
+ $floorItems['111'] = i
+ TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117B'
+ $floorItems['117B'] = i
+ TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '112'
+ $floorItems['112'] = i
+ TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '113'
+ $floorItems['113'] = i
+ TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117A'
+ $floorItems['117A'] = i
+ TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117'
+ $floorItems['117'] = i
+ TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '114'
+ $floorItems['114'] = i
+ TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '115'
+ $floorItems['115'] = i
+ TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '116'
+ $floorItems['116'] = i
+ TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '118'
+ $floorItems['118'] = i
+ TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '120'
+ $floorItems['120'] = i
+ TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '122'
+ $floorItems['122'] = i
+ TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '121'
+ $floorItems['121'] = i
+ TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106A'
+ $floorItems['106A'] = i
+ TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '105'
+ $floorItems['105'] = i
+ TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106B'
+ $floorItems['106B'] = i
+ TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '104'
+ $floorItems['104'] = i
+ TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '108'
+ $floorItems['108'] = i
+ TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '107'
+ $floorItems['107'] = i
+ TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Smoking'
+ $floorItems['Smoking'] = i
+ TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '123'
+ $floorItems['123'] = i
+ TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '103'
+ $floorItems['103'] = i
+ TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '124'
+ $floorItems['124'] = i
+ TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '125'
+ $floorItems['125'] = i
+ TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '126'
+ $floorItems['126'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '127'
+ $floorItems['127'] = i
+ TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'MShower'
+ $floorItems['MShower'] = i
+ TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Closet'
+ $floorItems['Closet'] = i
+ TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'WShower'
+ $floorItems['WShower'] = i
+ TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '130'
+ $floorItems['130'] = i
+ TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '102'
+ $floorItems['102'] = i
+ TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '128'
+ $floorItems['128'] = i
+ TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '129'
+ $floorItems['129'] = i
+ TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '133'
+ $floorItems['133'] = i
+ TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '132'
+ $floorItems['132'] = i
+ TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '134'
+ $floorItems['134'] = i
+ TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '135'
+ $floorItems['135'] = i
+ TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Ramona Stair'
+ $floorItems['Ramona Stair'] = i
+ TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'University Stair'
+ $floorItems['University Stair'] = i
+ TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Stair'
+ $floorItems['Plaza Stair'] = i
+ TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Deck'
+ $floorItems['Plaza Deck'] = i
+ TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106'
+ $floorItems['106'] = i
+ TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '119'
+ $floorItems['119'] = i
+ TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '238'
+ $floorItems['238'] = i
+ TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '237'
+ $floorItems['237'] = i
+ TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '246'
+ $floorItems['246'] = i
+ TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '247'
+ $floorItems['247'] = i
+ TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '202'
+ $floorItems['202'] = i
+ TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '206'
+ $floorItems['206'] = i
+ TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '212'
+ $floorItems['212'] = i
+ TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '245'
+ $floorItems['245'] = i
+ TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '244'
+ $floorItems['244'] = i
+ TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '243'
+ $floorItems['243'] = i
+ TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '242'
+ $floorItems['242'] = i
+ TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Barbecue Deck'
+ $floorItems['Barbecue Deck'] = i
+ TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '240'
+ $floorItems['240'] = i
+ TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '241'
+ $floorItems['241'] = i
+ TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '239'
+ $floorItems['239'] = i
+ TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '248'
+ $floorItems['248'] = i
+ TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '236'
+ $floorItems['236'] = i
+ TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '235'
+ $floorItems['235'] = i
+ TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '234'
+ $floorItems['234'] = i
+ TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '233'
+ $floorItems['233'] = i
+ TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '230'
+ $floorItems['230'] = i
+ TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '232'
+ $floorItems['232'] = i
+ TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '229'
+ $floorItems['229'] = i
+ TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '227'
+ $floorItems['227'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '228'
+ $floorItems['228'] = i
+ TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '226'
+ $floorItems['226'] = i
+ TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '225'
+ $floorItems['225'] = i
+ TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '224'
+ $floorItems['224'] = i
+ TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '223'
+ $floorItems['223'] = i
+ TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '222'
+ $floorItems['222'] = i
+ TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '221'
+ $floorItems['221'] = i
+ TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '204'
+ $floorItems['204'] = i
+ TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '205'
+ $floorItems['205'] = i
+ TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '207'
+ $floorItems['207'] = i
+ TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '208'
+ $floorItems['208'] = i
+ TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '209'
+ $floorItems['209'] = i
+ TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217'
+ $floorItems['217'] = i
+ TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217A'
+ $floorItems['217A'] = i
+ TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '216'
+ $floorItems['216'] = i
+ TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '215'
+ $floorItems['215'] = i
+ TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '214'
+ $floorItems['214'] = i
+ TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '213'
+ $floorItems['213'] = i
+ TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '210'
+ $floorItems['210'] = i
+ TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '211'
+ $floorItems['211'] = i
+ TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '203'
+ $floorItems['203'] = i
+ TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '220'
+ $floorItems['220'] = i
+ TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Priv Lift2'
+ $floorItems['Priv Lift2'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Pub Lift 2'
+ $floorItems['Pub Lift 2'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '218'
+ $floorItems['218'] = i
+ TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '219'
+ $floorItems['219'] = i
+ TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '201'
+ $floorItems['201'] = i
+ TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316'
+ $floorItems['316'] = i
+ TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '309'
+ $floorItems['309'] = i
+ TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '308'
+ $floorItems['308'] = i
+ TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '307'
+ $floorItems['307'] = i
+ TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '305'
+ $floorItems['305'] = i
+ TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324B'
+ $floorItems['324B'] = i
+ TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324A'
+ $floorItems['324A'] = i
+ TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '320'
+ $floorItems['320'] = i
+ TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '310'
+ $floorItems['310'] = i
+ TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '312'
+ $floorItems['312'] = i
+ TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '313'
+ $floorItems['313'] = i
+ TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '314'
+ $floorItems['314'] = i
+ TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '315'
+ $floorItems['315'] = i
+ TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316B'
+ $floorItems['316B'] = i
+ TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316A'
+ $floorItems['316A'] = i
+ TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '319'
+ $floorItems['319'] = i
+ TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '311'
+ $floorItems['311'] = i
+ TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '318'
+ $floorItems['318'] = i
+ TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '317'
+ $floorItems['317'] = i
+ TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '323'
+ $floorItems['323'] = i
+ TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '325'
+ $floorItems['325'] = i
+ TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '321'
+ $floorItems['321'] = i
+ TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '322'
+ $floorItems['322'] = i
+ TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Pub Lift3'
+ $floorItems['Pub Lift3'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Priv Lift3'
+ $floorItems['Priv Lift3'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '303'
+ $floorItems['303'] = i
+ TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324'
+ $floorItems['324'] = i
+ TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '304'
+ $floorItems['304'] = i
+ TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '301'
+ $floorItems['301'] = i
+ TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '327'
+ $floorItems['327'] = i
+ TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '326'
+ $floorItems['326'] = i
+ TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '302'
+ $floorItems['302'] = i
+ TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '306'
+ $floorItems['306'] = i
+ TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($floor_demo) && $floor_demo
+ $floor_demo.destroy
+ $floor_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$floor_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration")
+ iconname("Floorplan")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+# label À¸À®
+TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥­¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òư¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$floor_buttons = TkFrame.new($floor_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $floor_demo
+ $floor_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'floor'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# ÊÑ¿ôÀßÄê
+$floorLabels = {}
+$floorItems = {}
+
+# canvas ÀßÄê
+if $tk_version =~ /^4\.[01]/
+ $floor_canvas_frame = TkFrame.new($floor_demo,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor_canvas = TkCanvas.new($floor_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new($floor_demo, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new($floor_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new($floor_demo) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| c.yview(*args)})
+ h.command(proc{|*args| c.xview(*args)})
+ }
+end
+
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom = TkVariable.new
+$floor_entry = TkEntry.new($floor_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom)
+
+# Choose colors, then fill in the floorplan.
+
+$floor_colors = {}
+if TkWinfo.depth($floor_canvas) > 1
+ $floor_colors['bg1'] = '#a9c1da'
+ $floor_colors['outline1'] = '#77889a'
+ $floor_colors['bg2'] = '#9ab0c6'
+ $floor_colors['outline2'] = '#687786'
+ $floor_colors['bg3'] = '#8ba0b3'
+ $floor_colors['outline3'] = '#596673'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = '#c4d1df'
+else
+ $floor_colors['bg1'] = 'white'
+ $floor_colors['outline1'] = 'black'
+ $floor_colors['bg2'] = 'white'
+ $floor_colors['outline2'] = 'black'
+ $floor_colors['bg3'] = 'white'
+ $floor_colors['outline3'] = 'black'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = 'black'
+end
+
+$activeFloor = ''
+floorDisplay $floor_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor_canvas.itembind('floor1', '1', proc{floorDisplay $floor_canvas,1})
+$floor_canvas.itembind('floor2', '1', proc{floorDisplay $floor_canvas,2})
+$floor_canvas.itembind('floor3', '1', proc{floorDisplay $floor_canvas,3})
+$floor_canvas.itembind('room', 'Enter', proc{newRoom $floor_canvas})
+$floor_canvas.itembind('room', 'Leave', proc{$currentRoom.value = ''})
+$floor_canvas.bind('2', proc{|x,y| $floor_canvas.scan_mark x,y}, '%x %y')
+$floor_canvas.bind('B2-Motion',
+ proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y')
+$floor_canvas.bind('Destroy', proc{$currentRoom.unset})
+$currentRoom.value = ''
+$currentRoom.trace('w',proc{roomChanged $floor_canvas})
+
diff --git a/ext/tk/sample/demos-jp/floor2.rb b/ext/tk/sample/demos-jp/floor2.rb
new file mode 100644
index 0000000000..fcf208b61f
--- /dev/null
+++ b/ext/tk/sample/demos-jp/floor2.rb
@@ -0,0 +1,1716 @@
+#
+# floorDisplay widget demo 2 (called by 'widget')
+#
+
+# floorDisplay2 --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay2(w,active)
+ return if $activeFloor2 == active
+
+ w.delete('all')
+ $activeFloor2 = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor2_bg1(w,$floor2_colors['bg1'],$floor2_colors['outline1'])
+ floor2_bg2(w,$floor2_colors['bg2'],$floor2_colors['outline2'])
+ floor2_bg3(w,$floor2_colors['bg3'],$floor2_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ w.create(TkcRectangle,0,100,1,101,'fill'=>'','outline'=>'','tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels2.clear
+ $floorItems2.clear
+ send("floor2_fg#{active}", w, $floor2_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ w.create(TkcWindow, 600, 100, 'anchor'=>'w', 'window'=>$floor2_entry)
+ w.create(TkcText, 600, 100, 'anchor'=>'e', 'text'=>"Éô²°ÈÖ¹æ: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom2 --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom2(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom2.value = $floorLabels2[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged2 --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged2(w,*args)
+ w.delete('highlight')
+ item = $floorItems2[$currentRoom2.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor2_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor2_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg1(w,fill,outline)
+ w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor2_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg2(w,fill,outline)
+ w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor2_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg3(w,fill,outline)
+ w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor2_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '101'
+ $floorItems2['101'] = i
+ w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Pub Lift1'
+ $floorItems2['Pub Lift1'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Priv Lift1'
+ $floorItems2['Priv Lift1'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '110'
+ $floorItems2['110'] = i
+ w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '109'
+ $floorItems2['109'] = i
+ w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '111'
+ $floorItems2['111'] = i
+ w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117B'
+ $floorItems2['117B'] = i
+ w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '112'
+ $floorItems2['112'] = i
+ w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '113'
+ $floorItems2['113'] = i
+ w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117A'
+ $floorItems2['117A'] = i
+ w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117'
+ $floorItems2['117'] = i
+ w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '114'
+ $floorItems2['114'] = i
+ w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '115'
+ $floorItems2['115'] = i
+ w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '116'
+ $floorItems2['116'] = i
+ w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '118'
+ $floorItems2['118'] = i
+ w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '120'
+ $floorItems2['120'] = i
+ w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '122'
+ $floorItems2['122'] = i
+ w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '121'
+ $floorItems2['121'] = i
+ w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106A'
+ $floorItems2['106A'] = i
+ w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '105'
+ $floorItems2['105'] = i
+ w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106B'
+ $floorItems2['106B'] = i
+ w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '104'
+ $floorItems2['104'] = i
+ w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '108'
+ $floorItems2['108'] = i
+ w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '107'
+ $floorItems2['107'] = i
+ w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Smoking'
+ $floorItems2['Smoking'] = i
+ w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '123'
+ $floorItems2['123'] = i
+ w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '103'
+ $floorItems2['103'] = i
+ w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '124'
+ $floorItems2['124'] = i
+ w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '125'
+ $floorItems2['125'] = i
+ w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '126'
+ $floorItems2['126'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '127'
+ $floorItems2['127'] = i
+ w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'MShower'
+ $floorItems2['MShower'] = i
+ w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Closet'
+ $floorItems2['Closet'] = i
+ w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'WShower'
+ $floorItems2['WShower'] = i
+ w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '130'
+ $floorItems2['130'] = i
+ w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '102'
+ $floorItems2['102'] = i
+ w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '128'
+ $floorItems2['128'] = i
+ w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '129'
+ $floorItems2['129'] = i
+ w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '133'
+ $floorItems2['133'] = i
+ w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '132'
+ $floorItems2['132'] = i
+ w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '134'
+ $floorItems2['134'] = i
+ w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '135'
+ $floorItems2['135'] = i
+ w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Ramona Stair'
+ $floorItems2['Ramona Stair'] = i
+ w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'University Stair'
+ $floorItems2['University Stair'] = i
+ w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Stair'
+ $floorItems2['Plaza Stair'] = i
+ w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Deck'
+ $floorItems2['Plaza Deck'] = i
+ w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106'
+ $floorItems2['106'] = i
+ w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '119'
+ $floorItems2['119'] = i
+ w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor2_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '238'
+ $floorItems2['238'] = i
+ w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '237'
+ $floorItems2['237'] = i
+ w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '246'
+ $floorItems2['246'] = i
+ w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '247'
+ $floorItems2['247'] = i
+ w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '202'
+ $floorItems2['202'] = i
+ w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '206'
+ $floorItems2['206'] = i
+ w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '212'
+ $floorItems2['212'] = i
+ w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '245'
+ $floorItems2['245'] = i
+ w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '244'
+ $floorItems2['244'] = i
+ w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '243'
+ $floorItems2['243'] = i
+ w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '242'
+ $floorItems2['242'] = i
+ w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Barbecue Deck'
+ $floorItems2['Barbecue Deck'] = i
+ w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '240'
+ $floorItems2['240'] = i
+ w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '241'
+ $floorItems2['241'] = i
+ w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '239'
+ $floorItems2['239'] = i
+ w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '248'
+ $floorItems2['248'] = i
+ w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '236'
+ $floorItems2['236'] = i
+ w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '235'
+ $floorItems2['235'] = i
+ w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '234'
+ $floorItems2['234'] = i
+ w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '233'
+ $floorItems2['233'] = i
+ w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '230'
+ $floorItems2['230'] = i
+ w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '232'
+ $floorItems2['232'] = i
+ w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '229'
+ $floorItems2['229'] = i
+ w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '227'
+ $floorItems2['227'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '228'
+ $floorItems2['228'] = i
+ w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '226'
+ $floorItems2['226'] = i
+ w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '225'
+ $floorItems2['225'] = i
+ w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '224'
+ $floorItems2['224'] = i
+ w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '223'
+ $floorItems2['223'] = i
+ w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '222'
+ $floorItems2['222'] = i
+ w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '221'
+ $floorItems2['221'] = i
+ w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '204'
+ $floorItems2['204'] = i
+ w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '205'
+ $floorItems2['205'] = i
+ w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '207'
+ $floorItems2['207'] = i
+ w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '208'
+ $floorItems2['208'] = i
+ w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '209'
+ $floorItems2['209'] = i
+ w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217'
+ $floorItems2['217'] = i
+ w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217A'
+ $floorItems2['217A'] = i
+ w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '216'
+ $floorItems2['216'] = i
+ w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '215'
+ $floorItems2['215'] = i
+ w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '214'
+ $floorItems2['214'] = i
+ w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '213'
+ $floorItems2['213'] = i
+ w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '210'
+ $floorItems2['210'] = i
+ w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '211'
+ $floorItems2['211'] = i
+ w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '203'
+ $floorItems2['203'] = i
+ w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '220'
+ $floorItems2['220'] = i
+ w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Priv Lift2'
+ $floorItems2['Priv Lift2'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Pub Lift 2'
+ $floorItems2['Pub Lift 2'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '218'
+ $floorItems2['218'] = i
+ w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '219'
+ $floorItems2['219'] = i
+ w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '201'
+ $floorItems2['201'] = i
+ w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor2_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316'
+ $floorItems2['316'] = i
+ w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '309'
+ $floorItems2['309'] = i
+ w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '308'
+ $floorItems2['308'] = i
+ w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '307'
+ $floorItems2['307'] = i
+ w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '305'
+ $floorItems2['305'] = i
+ w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324B'
+ $floorItems2['324B'] = i
+ w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324A'
+ $floorItems2['324A'] = i
+ w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '320'
+ $floorItems2['320'] = i
+ w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '310'
+ $floorItems2['310'] = i
+ w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '312'
+ $floorItems2['312'] = i
+ w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '313'
+ $floorItems2['313'] = i
+ w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '314'
+ $floorItems2['314'] = i
+ w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '315'
+ $floorItems2['315'] = i
+ w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316B'
+ $floorItems2['316B'] = i
+ w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316A'
+ $floorItems2['316A'] = i
+ w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '319'
+ $floorItems2['319'] = i
+ w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '311'
+ $floorItems2['311'] = i
+ w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '318'
+ $floorItems2['318'] = i
+ w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '317'
+ $floorItems2['317'] = i
+ w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '323'
+ $floorItems2['323'] = i
+ w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '325'
+ $floorItems2['325'] = i
+ w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '321'
+ $floorItems2['321'] = i
+ w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '322'
+ $floorItems2['322'] = i
+ w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Pub Lift3'
+ $floorItems2['Pub Lift3'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Priv Lift3'
+ $floorItems2['Priv Lift3'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '303'
+ $floorItems2['303'] = i
+ w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324'
+ $floorItems2['324'] = i
+ w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '304'
+ $floorItems2['304'] = i
+ w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '301'
+ $floorItems2['301'] = i
+ w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '327'
+ $floorItems2['327'] = i
+ w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '326'
+ $floorItems2['326'] = i
+ w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '302'
+ $floorItems2['302'] = i
+ w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '306'
+ $floorItems2['306'] = i
+ w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($floor2_demo) && $floor2_demo
+ $floor2_demo.destroy
+ $floor2_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$floor2_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration 2")
+ iconname("Floorplan2")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+# label À¸À®
+TkLabel.new($floor2_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥Ç¥£¥¸¥¿¥ë¥¨¥¯¥¤¥Ã¥×¥á¥ó¥È¼Ò¤Î¥¦¥§¥¹¥¿¥ó¥ê¥µ¡¼¥Á¥é¥Ü¥é¥È¥ê (DECWRL) ¤Î´Ö¼è¤ê¤¬½ñ¤«¤ì¤¿¥­¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ï 3³¬·ú¤Æ¤Ç¡¢¾ï¤Ë¤½¤Î¤¦¤Á¤Î1³¬Ê¬¤¬ÁªÂò¡¢¤Ä¤Þ¤ê¤½¤Î´Ö¼è¤ê¤¬É½¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¤¢¤ë³¬¤òÁªÂò¤¹¤ë¤Ë¤Ï¡¢¤½¤Î¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Þ¥¦¥¹¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë³¬¤Î¾å¤òư¤¯¤È¡¢¤½¤Î²¼¤Ë¤¢¤ëÉô²°¤Î¿§¤¬ÊѤï¤ê¡¢Éô²°Èֹ椬¡ÖÉô²°ÈÖ¹æ:¡×¥¨¥ó¥È¥ê¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£¤Þ¤¿¡¢¥¨¥ó¥È¥ê¤ËÉô²°ÈÖ¹æ¤ò½ñ¤¯¤È¤½¤ÎÉô²°¤Î¿§¤¬ÊѤï¤ê¤Þ¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$floor2_buttons = TkFrame.new($floor2_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $floor2_demo
+ $floor2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'floor2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# ÊÑ¿ôÀßÄê
+$floorLabels2 = {}
+$floorItems2 = {}
+
+# canvas ÀßÄê
+if $tk_version =~ /^4\.[01]/
+ $floor2_canvas_frame = TkFrame.new($floor2_demo,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor2_canvas = TkCanvas.new($floor2_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new($floor2_demo, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new($floor2_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor2_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor2_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new($floor2_demo) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor2_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| c.yview(*args)})
+ h.command(proc{|*args| c.xview(*args)})
+ }
+end
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom2 = TkVariable.new
+$floor2_entry = TkEntry.new($floor2_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom2)
+
+# Choose colors, then fill in the floorplan.
+
+$floor2_colors = {}
+if TkWinfo.depth($floor2_canvas) > 1
+ $floor2_colors['bg1'] = '#a9c1da'
+ $floor2_colors['outline1'] = '#77889a'
+ $floor2_colors['bg2'] = '#9ab0c6'
+ $floor2_colors['outline2'] = '#687786'
+ $floor2_colors['bg3'] = '#8ba0b3'
+ $floor2_colors['outline3'] = '#596673'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = '#c4d1df'
+else
+ $floor2_colors['bg1'] = 'white'
+ $floor2_colors['outline1'] = 'black'
+ $floor2_colors['bg2'] = 'white'
+ $floor2_colors['outline2'] = 'black'
+ $floor2_colors['bg3'] = 'white'
+ $floor2_colors['outline3'] = 'black'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = 'black'
+end
+
+$activeFloor2 = ''
+floorDisplay2 $floor2_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor2_canvas.itembind('floor1', '1', proc{floorDisplay2 $floor2_canvas,1})
+$floor2_canvas.itembind('floor2', '1', proc{floorDisplay2 $floor2_canvas,2})
+$floor2_canvas.itembind('floor3', '1', proc{floorDisplay2 $floor2_canvas,3})
+$floor2_canvas.itembind('room', 'Enter', proc{newRoom2 $floor2_canvas})
+$floor2_canvas.itembind('room', 'Leave', proc{$currentRoom2.value = ''})
+$floor2_canvas.bind('2', proc{|x,y| $floor2_canvas.scan_mark x,y}, '%x %y')
+$floor2_canvas.bind('B2-Motion',
+ proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y')
+$floor2_canvas.bind('Destroy', proc{$currentRoom2.unset})
+$currentRoom2.value = ''
+$currentRoom2.trace('w',proc{roomChanged2 $floor2_canvas})
diff --git a/ext/tk/sample/demos-jp/form.rb b/ext/tk/sample/demos-jp/form.rb
new file mode 100644
index 0000000000..fe456d3943
--- /dev/null
+++ b/ext/tk/sample/demos-jp/form.rb
@@ -0,0 +1,63 @@
+#
+# form widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($form_demo) && $form_demo
+ $form_demo.destroy
+ $form_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$form_demo = TkToplevel.new {|w|
+ title("Form Demonstration")
+ iconname("form")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($form_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï´Êñ¤Ê¥Õ¥©¡¼¥àÆþÎÏÍѤˤʤäƤ¤¤Æ¡¢¤µ¤Þ¤¶¤Þ¤Ê¥¨¥ó¥È¥ê¤ËÆþÎϤ¬¤Ç¤­¤Þ¤¹¡£¥¿¥Ö¤Ç¥¨¥ó¥È¥ê¤ÎÀÚÂØ¤¨¤¬¤Ç¤­¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top', 'fill'=>'x')
+
+# frame À¸À®
+TkFrame.new($form_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $form_demo
+ $form_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'form'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# entry À¸À®
+form_data = []
+(1..5).each{|i|
+ f = TkFrame.new($form_demo, 'bd'=>2)
+ e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
+ l = TkLabel.new(f)
+ e.pack('side'=>'right')
+ l.pack('side'=>'left')
+ form_data[i] = {'frame'=>f, 'entry'=>e, 'label'=>l}
+}
+
+# ʸ»úÎóÀßÄê
+form_data[1]['label'].text('̾Á°:')
+form_data[2]['label'].text('½»½ê:')
+form_data[5]['label'].text('ÅÅÏÃ:')
+
+# pack
+(1..5).each{|i| form_data[i]['frame'].pack('side'=>'top', 'fill'=>'x')}
+
diff --git a/ext/tk/sample/demos-jp/hello b/ext/tk/sample/demos-jp/hello
new file mode 100644
index 0000000000..859ebd950e
--- /dev/null
+++ b/ext/tk/sample/demos-jp/hello
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+TkButton.new(nil,
+ 'text'=>"¤³¤ó¤Ë¤Á¤Ï¡¢À¤³¦",
+ 'command'=>proc{print "¤³¤ó¤Ë¤Á¤Ï¡¢À¤³¦\n"; exit}
+).pack
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/hscale.rb b/ext/tk/sample/demos-jp/hscale.rb
new file mode 100644
index 0000000000..37d215435c
--- /dev/null
+++ b/ext/tk/sample/demos-jp/hscale.rb
@@ -0,0 +1,77 @@
+require "tkcanvas"
+
+if defined?($hscale_demo) && $hscale_deom
+ $hscale_demo.destroy
+ $hscale_demo = nil
+end
+
+$hscale_demo = TkToplevel.new {|w|
+ title("Horizontal Scale Demonstration")
+ iconname("hscale")
+}
+positionWindow($hscale_demo)
+
+
+msg = TkLabel.new($hscale_demo) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+ text "²¼¤Ë¤ÏÌð°õ¤¬1¤Ä¤È¿åÊ¿¤Ê¥¹¥±¡¼¥ë¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\
+¥¹¥±¡¼¥ë¾å¤Ç¥Þ¥¦¥¹¥Ü¥¿¥ó1¤ò¥¯¥ê¥Ã¥¯¡¢¤Þ¤¿¤Ï¥É¥é¥Ã¥°¤¹¤ë¤È\
+Ìð°õ¤ÎŤµ¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+TkFrame.new($hscale_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc {
+ tmppath = $hscale_demo
+ $hscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc { showCode 'hscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+TkFrame.new($hscale_demo) {|frame|
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, '0', '0', '1', '1', '2', '2') {
+ fill 'DeepSkyBlue'
+ tags 'poly'
+ }
+ TkcLine.new(c, '0', '0', '1', '1', '2', '2', '0', '0') {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'top', 'expand'=>'yes', 'anchor'=>'s', 'fill'=>'x', 'padx'=>'15')
+ scale = TkScale.new(frame) {
+ orient 'horizontal'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setWidth(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'bottom', 'expand'=>'yes', 'anchor'=>'n')
+ scale.set 75
+}.pack('side'=>'top', 'fill'=>'x')
+
+
+def setWidth(w, width)
+ width = width + 21
+ x2 = width - 30
+ if x2 < 21
+ x2 = 21
+ end
+ w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+ w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+end
diff --git a/ext/tk/sample/demos-jp/icon.rb b/ext/tk/sample/demos-jp/icon.rb
new file mode 100644
index 0000000000..e4fef5cae7
--- /dev/null
+++ b/ext/tk/sample/demos-jp/icon.rb
@@ -0,0 +1,96 @@
+#
+# iconic button widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($icon_demo) && $icon_demo
+ $icon_demo.destroy
+ $icon_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$icon_demo = TkToplevel.new {|w|
+ title("Iconic Button Demonstration")
+ iconname("icon")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($icon_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥é¥¸¥ª¥Ü¥¿¥ó¤È¥Á¥§¥Ã¥¯¥Ü¥¿¥ó¾å¤Ë¥Ó¥Ã¥È¥Þ¥Ã¥×¤ä²èÁü¤òɽ¼¨¤¹¤ë 3 ¤Ä¤ÎÊýË¡¤ò¼¨¤·¤Æ¤¤¤Þ¤¹¡£º¸¤Ë¤¢¤ë¤Î¤Ï2¤Ä¤Î¥é¥¸¥ª¥Ü¥¿¥ó¤Ç¡¢¤½¤ì¤¾¤ì¤¬¡¢¥Ó¥Ã¥È¥Þ¥Ã¥×¤ÈÁªÂò¤ò¼¨¤¹¥¤¥ó¥¸¥±¡¼¥¿¤Ç¤Ç¤­¤Æ¤¤¤Þ¤¹¡£Ãæ±û¤Ë¤¢¤ë¤Î¤Ï¡¢ÁªÂòºÑ¤ß¤«¤É¤¦¤«¤Ë¤è¤Ã¤Æ°Û¤Ê¤ë²èÁü¤òɽ¼¨¤¹¤ë¥Á¥§¥Ã¥¯¥Ü¥¿¥ó¤Ç¤¹¡£±¦Â¦¤Ë¤¢¤ë¤Î¤ÏÁªÂòºÑ¤ß¤«¤É¤¦¤«¤Ë¤è¤Ã¤ÆÇØ·Ê¿§¤¬ÊѤï¤ë¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¼¨¤¹¤ë¥Á¥§¥Ã¥¯¥Ü¥¿¥ó¤Ç¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($icon_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $icon_demo
+ $icon_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'icon'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image À¸À®
+flagup = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagup.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..','images','flagup.xbm'].join(File::Separator))
+flagdown = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator))
+
+# ÊÑ¿ôÀ¸À®
+letters = TkVariable.new
+
+# frame À¸À®
+TkFrame.new($icon_demo, 'borderwidth'=>10){|w|
+ TkFrame.new(w) {|f|
+ TkRadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ variable letters
+ value 'full'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ TkRadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','noletter.xbm'].join(File::Separator)
+ variable letters
+ value 'empty'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ TkCheckButton.new(w) {
+ image flagdown
+ selectimage flagup
+ indicatoron 0
+ selectcolor self['background']
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ TkCheckButton.new(w) {
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ indicatoron 0
+ selectcolor 'SeaGreen1'
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+}.pack('side'=>'top')
+
diff --git a/ext/tk/sample/demos-jp/image1.rb b/ext/tk/sample/demos-jp/image1.rb
new file mode 100644
index 0000000000..3d47f844e5
--- /dev/null
+++ b/ext/tk/sample/demos-jp/image1.rb
@@ -0,0 +1,58 @@
+#
+# two image widgets demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($image1_demo) && $image1_demo
+ $image1_demo.destroy
+ $image1_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$image1_demo = TkToplevel.new {|w|
+ title('Image Demonstration #1')
+ iconname("Image1")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($image1_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "¤³¤Î¥Ç¥â¤Ç¤Ï2¤Ä¤Î¥é¥Ù¥ë¾å¤Ë²èÁü¤ò¤½¤ì¤¾¤ìɽ¼¨¤·¤Æ¤¤¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($image1_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $image1_demo
+ $image1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'image1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image À¸À®
+image1a = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earth.gif'].join(File::Separator))
+image1b = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earthris.gif'].join(File::Separator))
+
+# label À¸À®
+[ TkLabel.new($image1_demo, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+ TkLabel.new($image1_demo, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+
diff --git a/ext/tk/sample/demos-jp/image2.rb b/ext/tk/sample/demos-jp/image2.rb
new file mode 100644
index 0000000000..e2e2a2b036
--- /dev/null
+++ b/ext/tk/sample/demos-jp/image2.rb
@@ -0,0 +1,102 @@
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($image2_demo) && $image2_demo
+ $image2_demo.destroy
+ $image2_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$image2_demo = TkToplevel.new {|w|
+ title('Image Demonstration #2')
+ iconname("Image2")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($image2_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "¤³¤Î¥Ç¥â¤Ç¤ÏTk¤Î photo image ¤ò»ÈÍѤ·¤Æ²èÁü¤ò¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ºÇ½é¤Ë¥¨¥ó¥È¥êÆâ¤Ë¤Ë¥Ç¥£¥ì¥¯¥È¥ê̾¤òÆþ¤ì¤Æ²¼¤µ¤¤¡£¼¡¤Ë²¼¤Î¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤Ë¤³¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ò¥í¡¼¥É¤¹¤ë¤¿¤á¡¢¥ê¥¿¡¼¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£¤½¤Î¸å¡¢²èÁü¤òÁªÂò¤¹¤ë¤¿¤á¤Ë¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤ÎÃæ¤Î¥Õ¥¡¥¤¥ë̾¤ò¥À¥Ö¥ë¥¯¥ê¥Ã¥¯¤·¤Æ²¼¤µ¤¤¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($image2_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $image2_demo
+ $image2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'image2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# ÊÑ¿ôÀ¸À®
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image À¸À®
+$image2a = TkPhotoImage.new
+
+# ¥Õ¥¡¥¤¥ë̾ÆþÎÏÉô
+TkLabel.new($image2_demo, 'text'=>'¥Ç¥£¥ì¥¯¥È¥ê:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+image2_e = TkEntry.new($image2_demo) {
+ width 30
+ textvariable $dirName
+}.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20)\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkLabel.new($image2_demo, 'text'=>'¥Õ¥¡¥¤¥ë:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new($image2_demo){|w|
+ s = TkScrollbar.new(w)
+ l = TkListbox.new(w) {
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| l.yview(*args)})
+ l.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ s.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ #l.insert(0,'earth.gif', 'earthris.gif', 'mickey.gif', 'teapot.ppm')
+ l.insert(0,'earth.gif', 'earthris.gif', 'teapot.ppm')
+ l.bind('Double-1', proc{|x,y| loadImage $image2a,l,x,y}, '%x %y')
+
+ image2_e.bind 'Return', proc{loadDir l}
+
+}.pack('side'=>'top', 'anchor'=>'w')
+
+# image ÇÛÃÖ
+[ TkFrame.new($image2_demo, 'height'=>'3m', 'width'=>20),
+ TkLabel.new($image2_demo, 'text'=>'²èÁü:'),
+ TkLabel.new($image2_demo, 'image'=>$image2a)
+].each{|w| w.pack('side'=>'top', 'anchor'=>'w')}
+
+# ¥á¥½¥Ã¥ÉÄêµÁ
+def loadDir(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+def loadImage(img,w,x,y)
+ img.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
diff --git a/ext/tk/sample/demos-jp/image3.rb b/ext/tk/sample/demos-jp/image3.rb
new file mode 100644
index 0000000000..549152514b
--- /dev/null
+++ b/ext/tk/sample/demos-jp/image3.rb
@@ -0,0 +1,122 @@
+# image3.rb
+#
+# This demonstration script creates a simple collection of widgets
+# that allow you to select and view images in a Tk label.
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image3_demo) && $image3_demo
+ $image3_demo.destroy
+ $image3_demo = nil
+end
+
+# demo toplevel widget
+$image3_demo = TkToplevel.new {|w|
+ title('Image Demonstration #3')
+ iconname("Image3")
+ positionWindow(w)
+}
+
+#
+def loadDir3(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+# selectAndLoadDir3 --
+# This procedure pops up a dialog to ask for a directory to load into
+# the listobx and (if the user presses OK) reloads the directory
+# listbox from the directory named in the demo's entry.
+#
+# Arguments:
+# w - Name of the toplevel window of the demo.
+def selectAndLoadDir3(w, lbox)
+ dir = Tk.chooseDirectory(:initialdir=>$dirName, :parent=>w, :mustexist=>true)
+ if dir.length > 0
+ $dirName.value = dir
+ loadDir3(lbox)
+ end
+end
+
+def loadImage3(w,x,y)
+ $image3a.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
+
+# label
+msg = TkLabel.new($image3_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "¤³¤Î¥Ç¥â¤Ç¤ÏTk¤Î photo image ¤ò»ÈÍѤ·¤Æ²èÁü¤ò ¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ºÇ½é¤Ë¥¨¥ó¥È¥êÆâ¤Ë¤Ë¥Ç¥£¥ì¥¯¥È¥ê̾¤òÆþ¤ì¤Æ²¼¤µ¤¤¡£¼¡¤Ë²¼¤Î¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤Ë¤³¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ò¥í¡¼¥É¤¹¤ë¤¿¤á¡¢¥ê¥¿¡¼¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£¤½¤Î¸å¡¢²èÁü¤òÁªÂò¤¹¤ë¤¿¤á¤Ë¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤ÎÃæ¤Î¥Õ¥¡¥¤¥ë̾¤ò¥À¥Ö¥ë¥¯¥ê¥Ã¥¯¤·¤Æ²¼¤µ¤¤¡£"
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new($image3_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $image3_demo
+ $image3_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'image3'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# variable
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image
+begin
+ $image3a.delete
+rescue
+end
+$image3a = TkPhotoImage.new
+
+#
+image3_f = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+
+image3_df = TkLabelFrame.new($image3_demo, :text=>'¥Ç¥£¥ì¥¯¥È¥ê:')
+
+image3_ff = TkLabelFrame.new($image3_demo, :text=>'¥Õ¥¡¥¤¥ë:',
+ :padx=>'2m', :pady=>'2m')
+image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) {
+ pack(:side=>:left, :fill=>:y, :expand=>true)
+ yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y,
+ :expand=>true))
+ insert(0, *(%w(earth.gif earthris.gif teapot.ppm)))
+ bind('Double-1', proc{|x,y| loadImage3(self, x, y)}, '%x %y')
+}
+
+image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){
+ pack(:side=>:left, :fill=>:both, :padx=>'2m', :pady=>'2m', :expand=>true)
+ bind('Return', proc{loadDir3(image3_lbx)})
+}
+
+TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"¥Ç¥£¥ì¥¯¥È¥êÁªÂò",
+ :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) {
+ pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m')
+}
+
+image3_if = TkLabelFrame.new($image3_demo, :text=>'¥¤¥á¡¼¥¸:') {|f|
+ TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+}
+
+Tk.grid(image3_df, '-',
+ :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+Tk.grid(image3_ff, image3_if,
+ :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+TkGrid.columnconfigure(image3_f, 1, :weight=>1)
+
diff --git a/ext/tk/sample/demos-jp/items.rb b/ext/tk/sample/demos-jp/items.rb
new file mode 100644
index 0000000000..38774d10d2
--- /dev/null
+++ b/ext/tk/sample/demos-jp/items.rb
@@ -0,0 +1,371 @@
+#
+# canvas item types widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($items_demo) && $items_demo
+ $items_demo.destroy
+ $items_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$items_demo = TkToplevel.new {|w|
+ title("Canvas Item Demonstration")
+ iconname("Items")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($items_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥­¥ã¥ó¥Ð¥¹ widget ¤¬Æþ¤Ã¤Æ¤ª¤ê¡¢¤½¤ÎÃæ¤Ë¤Ï¥­¥ã¥ó¥Ð¥¹ widget ¤¬¥µ¥Ý¡¼¥È¤¹¤ëÍÍ¡¹¤Ê¥¿¥¤¥×¤Î¥¢¥¤¥Æ¥à¤ÎÎ㤬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¼¡¤Î¤è¤¦¤ÊÁàºî¤¬¤Ç¤­¤Þ¤¹¡£\n ¥Ü¥¿¥ó-1 ¥É¥é¥Ã¥°:\t¥¢¥¤¥Æ¥à¤òư¤«¤¹¡£\n ¥Ü¥¿¥ó-2 ¥É¥é¥Ã¥°:\t¸«¤¨¤Æ¤¤¤ëÉôʬ¤ò¤º¤é¤¹¡£\n ¥Ü¥¿¥ó-3 ¥É¥é¥Ã¥°:\tÎΰè¤ò°Ï¤¦¡£\n ¥³¥ó¥È¥í¡¼¥ë-F:\tÎΰè¤Î²¼¤Î¥¢¥¤¥Æ¥à¤òɽ¼¨¤¹¤ë¡£"
+}.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($items_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $items_demo
+ $items_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'items'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+cvs = nil
+TkFrame.new($items_demo) {|cf|
+ # canvas À¸À®
+ cvs = TkCanvas.new(cf) {|c|
+ focus
+ scrollregion '0c 0c 30c 24c'
+ width '15c'
+ height '10c'
+ relief 'sunken'
+ borderwidth 2
+
+ hs = TkScrollbar.new(cf) {|s|
+ orient 'horizontal'
+ command proc{|*args| c.xview(*args)}
+ c.xscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ vs = TkScrollbar.new(cf) {|s|
+ command proc{|*args| c.yview(*args)}
+ c.yscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ if $tk_version =~ /^4\.[01]/
+ hs.pack('side'=>'bottom', 'fill'=>'x')
+ vs.pack('side'=>'right', 'fill'=>'y')
+ c.pack('in'=>cf, 'expand'=>'yes', 'fill'=>'both')
+
+ else
+ c.grid('in'=>cf, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ hs.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+
+ end
+
+ }
+}.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+# Display a 3x3 rectangular grid
+TkcRectangle.new(cvs, '0c', '0c', '30c', '24c', 'width'=>2)
+TkcLine.new(cvs, '0c', '8c', '30c', '8c', 'width'=>2)
+TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2)
+TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2)
+TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2)
+
+font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+if TkWinfo.depth($root).to_i > 1
+ blue = 'DeepSkyBlue3'
+ red = 'red'
+ bisque = 'bisque3'
+ green = 'SeaGreen3'
+else
+ blue = 'black'
+ red = 'black'
+ bisque = 'black'
+ green = 'black'
+end
+
+# tag ¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®
+$tag_item = TkcGroup.new(cvs)
+
+# Set up demos within each of the areas of the grid.
+TkcText.new(cvs, '5c', '.2c', 'text'=>'¥é¥¤¥ó', 'anchor'=>'n')
+TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c',
+ 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt',
+ 'join'=>'miter', 'tags'=>$tag_item )
+TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item)
+TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item)
+TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c',
+ '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c',
+ '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c',
+ 'width'=>3, 'fill'=>red, 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c',
+ 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round',
+ 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '.2c',
+ 'text'=>'¶ÊÀþ (³ê¤é¤«¤Ë¤Ä¤Ê¤¤¤ÀľÀþ)', 'anchor'=>'n')
+TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c',
+ 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item )
+TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c',
+ 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item )
+TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c',
+ '16.5c','4.5c','13.5c','7.5c','12c','6c',
+ 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'fill'=>red, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '.2c', 'text'=>'¿³Ñ·Á', 'anchor'=>'n')
+TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c',
+ '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c',
+ 'fill'=>'green', 'outline'=>'black', 'width'=>4,
+ 'tags'=>$tag_item )
+TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c',
+ '28c','1c','29c','1c','29c','4c','29c','4c',
+ 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item)
+TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c',
+ '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c',
+ '7.5c','22c','7.5c',
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'outline'=>'black', 'tags'=>$tag_item )
+
+TkcText.new(cvs, '5c', '8.2c', 'text'=>'¶ë·Á', 'anchor'=>'n')
+TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '8.2c', 'text'=>'Âʱß', 'anchor'=>'n')
+TkcOval.new(cvs, '11c','9.5c','14c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '8.2c', 'text'=>'¥Æ¥­¥¹¥È', 'anchor'=>'n')
+TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c')
+TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c',
+ 'text'=>'û¤¤¥Æ¥­¥¹¥È¡£¥ï¡¼¥É¥é¥Ã¥×¡¢º¸Â·¤¨¡¢¥¢¥ó¥«¡¼¤ÏËÌ(¾å)¡£¢¢¤Ï³Æ¥Æ¥­¥¹¥È¤Î¥¢¥ó¥«¡¼¥Ý¥¤¥ó¥È¤ò¼¨¤¹¡£', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c')
+TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue,
+ 'text'=>"¤¤¤¯¤Ä¤«¤Î¹Ô¡£\n¤½¤ì¤¾¤ìÆÈΩ¤Ë\n¹Ô·¤¨¡£\nÁ´¤Æº¸Ã¼¤¬¥¢¥ó¥«¡¼¤µ¤ì¤Æ¤¤¤ë¡£", 'justify'=>'center', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c')
+if $tk_version =~ /^4\.[01]/
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'grey.5'].join(File::Separator),
+ 'text'=>'Stippled characters', 'tags'=>$tag_item )
+else
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'gray50', 'text'=>'Stippled characters',
+ 'tags'=>$tag_item )
+end
+
+TkcText.new(cvs, '5c', '16.2c', 'text'=>'¸Ì', 'anchor'=>'n')
+TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black',
+ 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item)
+#TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+# 'outline'=>blue, 'start'=>135, 'extent'=>270,
+# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+ 'outline'=>blue, 'start'=>135, 'extent'=>270,
+ 'outlinestipple'=>'@'+[$demo_dir, '..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice',
+ 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90,
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord',
+ 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270,
+ 'tags'=>$tag_item)
+
+TkcText.new(cvs, '15c', '16.2c', 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×', 'anchor'=>'n')
+#TkcBitmap.new(cvs, '13c','20c',
+# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '13c','20c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'face.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','18.5c',
+# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '17c','18.5c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'noletter.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','21.5c',
+# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator),
+# 'tags'=>$tag_item)
+# ¢­¤Î·Á¼°¤Ç¤â²Äǽ
+TkcBitmap.new(cvs, '17c','21.5c') {
+ bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator)
+ tags $tag_item
+}
+#TkcBitmap.new(cvs, '17c','21.5c') {
+# bitmap '@' + ['images', 'letters'].join(File::Separator)
+# tags $tag_item
+#}
+
+TkcText.new(cvs, '25c', '16.2c', 'text'=>'¥¦¥£¥ó¥É¥¦', 'anchor'=>'n')
+TkButton.new(cvs) {|b|
+ text '²¡¤·¤Æ¤Í'
+ command proc{butPress cvs, red}
+ TkcWindow.new(cvs, '21c','18c',
+ 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e|
+ insert 'end', 'ÊÔ½¸¤·¤Æ¤Í'
+ TkcWindow.new(cvs, '21c','21c',
+ 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c',
+ 'width'=>'.5c', 'tickinterval'=>0 ) {|scl|
+ TkcWindow.new(cvs, '28.5c','17.5c',
+ 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item)
+}
+TkcText.new(cvs, '21c', '17.9c', 'text'=>'¥Ü¥¿¥ó:', 'anchor'=>'sw')
+TkcText.new(cvs, '21c', '20.9c', 'text'=>'¥¨¥ó¥È¥ê:', 'anchor'=>'sw')
+TkcText.new(cvs, '28.5c', '17.4c', 'text'=>'¥¹¥±¡¼¥ë:', 'anchor'=>'s')
+
+# Set up event bindings for canvas:
+cvs.itembind($tag_item, 'Any-Enter', proc{itemEnter cvs})
+cvs.itembind($tag_item, 'Any-Leave', proc{itemLeave cvs})
+cvs.bind('2', proc{|x,y| cvs.scan_mark x,y}, '%x %y')
+cvs.bind('B2-Motion', proc{|x,y| cvs.scan_dragto x,y}, '%x %y')
+cvs.bind('3', proc{|x,y| itemMark cvs,x,y}, '%x %y')
+cvs.bind('B3-Motion', proc{|x,y| itemStroke cvs,x,y}, '%x %y')
+cvs.bind('Control-f', proc{itemsUnderArea cvs})
+cvs.bind('1', proc{|x,y| itemStartDrag cvs,x,y}, '%x %y')
+cvs.bind('B1-Motion', proc{|x,y| itemDrag cvs,x,y}, '%x %y')
+# Utility methods for highlighting the item under the pointer
+
+$restoreCmd = nil
+def itemEnter (c)
+ if TkWinfo.depth(c).to_i == 1
+ $restoreCmd = nil
+ return
+ end
+ type = c.itemtype('current')
+ if type == TkcWindow
+ $restoreCmd = nil
+ return
+ end
+ if type == TkcBitmap
+ bg = (c.itemconfiginfo('current', 'background'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'background', bg}
+ c.itemconfigure 'current', 'background', 'SteelBlue2'
+ return
+ end
+ fill = (c.itemconfiginfo('current', 'fill'))[4]
+ if (type == TkcRectangle || type == TkcOval || type == TkcArc) && fill == []
+ outline = (c.itemconfiginfo('current', 'outline'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'outline', outline}
+ c.itemconfigure 'current', 'outline', 'SteelBlue2'
+ else
+ $restoreCmd = proc{c.itemconfigure 'current', 'fill', fill}
+ c.itemconfigure 'current', 'fill', 'SteelBlue2'
+ end
+end
+
+def itemLeave(c)
+ $restoreCmd.call if $restoreCmd
+end
+
+# Utility methods for stroking out a rectangle and printing what's
+# underneath the rectangle's area.
+
+def itemMark(c,x,y)
+ $areaX1 = c.canvasx(x)
+ $areaY1 = c.canvasy(y)
+ c.delete 'area'
+end
+
+def itemStroke(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ if $areaX1 != x && $areaY1 != y
+ c.delete 'area'
+ c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y,
+ '-outline', 'black')
+ $areaX2 = x
+ $areaY2 = y
+ end
+end
+
+def itemsUnderArea(c)
+ area = c.find_withtag('area')
+ items = []
+ c.find_enclosed($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items enclosed by area: #{items.inspect}\n"; STDOUT.flush
+ items.clear
+ c.find_overlapping($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items overlapping area: #{items.inspect}\n"; STDOUT.flush
+end
+
+$areaX1 = 0
+$areaY1 = 0
+$areaX2 = 0
+$areaY2 = 0
+
+# Utility methods to support dragging of items.
+
+def itemStartDrag(c,x,y)
+ $lastX = c.canvasx(x)
+ $lastY = c.canvasy(y)
+end
+
+def itemDrag(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ c.move('current', x - $lastX, y - $lastY)
+ $lastX = x
+ $lastY = y
+end
+
+# Method that's invoked when the button embedded in the canvas
+# is invoked.
+
+def butPress(w,color)
+ i = TkcText.new(w, '25c', '18.1c',
+ 'text'=>'¤¤¤Æ¤Æ!!', 'fill'=>color, 'anchor'=>'n')
+ Tk.after(500, proc{w.delete i})
+end
diff --git a/ext/tk/sample/demos-jp/ixset b/ext/tk/sample/demos-jp/ixset
new file mode 100644
index 0000000000..46c2378073
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ixset
@@ -0,0 +1,333 @@
+#!/usr/bin/env ruby
+
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ end
+
+ # apply is just "writesettings"
+
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length)
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left','expand'=>'y')
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken') {
+ pack('side'=>'left','expand'=>'y')
+ }
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ buttons = TkFrame.new(@root) {|f|
+ [ TkButton.new(f, 'command'=>proc{win.ok}, 'text'=>'Ok'),
+ TkButton.new(f, 'command'=>proc{win.writesettings}, 'text'=>'Apply'),
+ TkButton.new(f, 'command'=>proc{win.cancel}, 'text'=>'Cancel'),
+ TkButton.new(f, 'command'=>proc{win.quit}, 'text'=>'Quit') ].each{|b|
+ b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5)
+ }
+ }
+
+ #
+ # Bell settings
+ #
+ bell = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(bell, 'text'=>'Bell Settings')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"Volume (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6)
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "Duration (ms)", 6)
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ l.pack('side'=>'top', 'expand'=>'yes')
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(kbd, 'text'=>'Keyboard Repeat Settings')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'On', 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'Click Volume (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes')
+ l.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(mouse, 'text'=>'Mouse Settings')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, 'Acceleration', 3)
+ @w_mouseacc.pack('side'=>'left')
+ @w_mousethr = LabelEntry.new(f, 'Threshold (pixels)', 3)
+ @w_mousethr.pack('side'=>'right')
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(screen, 'text'=>'Screen-saver Settings')
+ f = TkFrame.new(screen)
+ ff1 = TkFrame.new(f)
+ [ @w_screenblank = TkRadioButton.new(ff1, 'text'=>'Blank',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ },
+ @w_screenpat = TkRadioButton.new(ff1, 'text'=>'Pattern',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+ ].each {|w| w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') }
+
+ ff2 = TkFrame.new(f)
+ [ @w_screentim = LabelEntry.new(ff2, 'Timeout (s)', 5),
+ @w_screencyc = LabelEntry.new(ff2, 'Cycle (s)', 5) ].each{|w|
+ w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'e')
+ }
+
+ ff1.pack('side'=>'left')
+ ff2.pack('side'=>'left')
+
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Main window
+ #
+ buttons.pack('side'=>'top', 'fill'=>'both')
+ bell.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ kbd.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ mouse.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ screen.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize
+ @root = TkRoot.new
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/ixset2 b/ext/tk/sample/demos-jp/ixset2
new file mode 100644
index 0000000000..8947daa4b4
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ixset2
@@ -0,0 +1,368 @@
+#!/usr/bin/env ruby
+#
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ # apply is just "writesettings"
+ def apply
+ writesettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length, range=[])
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left')
+ if range.size > 0
+ @entry = TkSpinbox.new(@frame, 'width'=>length, 'relief'=>'sunken',
+ 'from'=>range[0], 'to'=>range[1])
+ else
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken')
+ end
+ @entry.pack('side'=>'right','expand'=>'y', 'fill'=>'x')
+ end
+ def epath
+ @frame
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ btn_frame = TkFrame.new(@root)
+ buttons = [
+ @btn_OK = TkButton.new(btn_frame, 'command'=>proc{win.ok},
+ 'default'=>'active', 'text'=>'λ²ò'),
+ @btn_APPLY = TkButton.new(btn_frame, 'command'=>proc{win.writesettings},
+ 'default'=>'normal', 'text'=>'ŬÍÑ',
+ 'state'=>'disabled'),
+ @btn_CANCEL = TkButton.new(btn_frame, 'command'=>proc{win.cancel},
+ 'default'=>'normal', 'text'=>'¼è¾Ã',
+ 'state'=>'disabled'),
+ @btn_QUIT = TkButton.new(btn_frame, 'command'=>proc{win.quit},
+ 'default'=>'normal', 'text'=>'̾ȧ')
+ ]
+ buttons.each{|b| b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5) }
+
+ @root.bind('Return', proc{@btn_OK.flash; @btn_OK.invoke})
+ @root.bind('Escape', proc{@btn_QUIT.flash; @btn_QUIT.invoke})
+ @root.bind('1', proc{|w|
+ unless buttons.index(w)
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ }, '%W')
+ @root.bind('Key', proc{|w, k|
+ unless buttons.index(w)
+ case k
+ when 'Return', 'Escape', 'Tab', /.*Shift.*/
+ # do nothing
+ else
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ end
+ }, '%W %K')
+
+ #
+ # Bell settings
+ #
+ bell = TkLabelframe.new(@root, 'text'=>'¥Ù¥ëÀßÄê',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"²»ÎÌ (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "²»Äø (Hz)", 6, [25, 20000])
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "»ý³»þ´Ö (ms)", 6, [1, 10000])
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkLabelframe.new(@root, 'text'=>'¥­¡¼¥Ü¡¼¥É¥ê¥Ô¡¼¥ÈÀßÄê',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'¥¯¥ê¥Ã¥¯²»¤¢¤ê',
+ 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x', 'padx'=>[0, '1m'])
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'¥¯¥ê¥Ã¥¯²»ÎÌ (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes',
+ 'fill'=>'x', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkLabelframe.new(@root, 'text'=>'¥Þ¥¦¥¹ÀßÄê',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, '²Ã®ÎÌ', 5)
+ @w_mouseacc.pack('side'=>'left', 'padx'=>[0, '1m'])
+ @w_mousethr = LabelEntry.new(f, 'ïçÃÍ (pixels)', 3, [1, 2000])
+ @w_mousethr.pack('side'=>'right', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkLabelframe.new(@root, 'text'=>'¥¹¥¯¥ê¡¼¥ó¥»¡¼¥ÐÀßÄê',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_screenblank = TkRadioButton.new(screen, 'text'=>'¥Ö¥é¥ó¥¯É½¼¨',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screenpat = TkRadioButton.new(screen, 'text'=>'¥Ñ¥¿¡¼¥óɽ¼¨',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screentim = LabelEntry.new(screen, '¥¿¥¤¥à¥¢¥¦¥È (s)', 5, [1, 100000])
+ @w_screencyc = LabelEntry.new(screen, '¼þ´ü (s)', 5, [1, 100000])
+
+ Tk.grid(@w_screenblank, @w_screentim, 'sticky'=>'e')
+ Tk.grid(@w_screenpat, @w_screencyc, 'sticky'=>'e')
+ TkGrid.configure(@w_screenblank, @w_screenpat, 'sticky'=>'ew')
+
+ #
+ # Main window
+ #
+ param = {
+ 'side'=>'top', 'fill'=>'both', 'expand'=>'yes',
+ 'padx'=>'1m', 'pady'=>'1m'
+ }
+ btn_frame.pack('side'=>'top', 'fill'=>'both')
+ bell.pack(param)
+ kbd.pack(param)
+ mouse.pack(param)
+ screen.pack(param)
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize(title)
+ @root = TkRoot.new('title'=>title)
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new(File.basename($0,'.rb'))
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/label.rb b/ext/tk/sample/demos-jp/label.rb
new file mode 100644
index 0000000000..59626289fc
--- /dev/null
+++ b/ext/tk/sample/demos-jp/label.rb
@@ -0,0 +1,65 @@
+#
+# label widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($label_demo) && $label_demo
+ $label_demo.destroy
+ $label_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$label_demo = TkToplevel.new {|w|
+ title("Label Demonstration")
+ iconname("label")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($label_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Ë¤Ï5¤Ä¤Î¥é¥Ù¥ë¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£º¸Â¦¤Ë¤Ï¥Æ¥­¥¹¥È¥é¥Ù¥ë¤¬3¤Ä¤¢¤ê¡¢±¦Â¦¤Ë¤Ï¥Ó¥Ã¥È¥Þ¥Ã¥×¥é¥Ù¥ë¤È¥Æ¥­¥¹¥È¥é¥Ù¥ë¤¬¤¢¤ê¤Þ¤¹¡£¥é¥Ù¥ë¤È¤¤¤¦¤Î¤Ï¤¢¤Þ¤êÌÌÇò¤¤¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£¤Ê¤¼¤Ê¤éį¤á¤ë°Ê³°²¿¤â¤Ç¤­¤Ê¤¤¤«¤é¤Ç¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($label_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $label_demo
+ $label_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'label'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# label demo Íѥե졼¥àÀ¸À®
+f_left = TkFrame.new($label_demo)
+f_right = TkFrame.new($label_demo)
+[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes',
+ 'padx'=>10, 'pady'=>10, 'fill'=>'both')}
+
+# label À¸À®
+[ TkLabel.new(f_left, 'text'=>'ºÇ½é¤Î¥é¥Ù¥ë'),
+ TkLabel.new(f_left, 'text'=>'2 ÈÖÌÜ¡£¤Á¤ç¤Ã¤ÈÉ⤭¾å¤¬¤é¤»¤Æ¤ß¤Þ¤·¤¿',
+ 'relief'=>'raised'),
+ TkLabel.new(f_left, 'text'=>'3 ÈÖÌÜ¡£ÄÀ¤ó¤Ç¤¤¤Þ¤¹ ', 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')}
+
+TkLabel.new(f_right) {
+ bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator))
+ borderwidth 2
+ relief 'sunken'
+}.pack('side'=>'top')
+
+TkLabel.new(f_right) { text 'Tcl/Tk ½êÍ­¼Ô' }.pack('side'=>'top')
diff --git a/ext/tk/sample/demos-jp/labelframe.rb b/ext/tk/sample/demos-jp/labelframe.rb
new file mode 100644
index 0000000000..23c974dcc2
--- /dev/null
+++ b/ext/tk/sample/demos-jp/labelframe.rb
@@ -0,0 +1,98 @@
+# labelframe.rb
+#
+# This demonstration script creates a toplevel window containing
+# several labelframe widgets.
+#
+# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp"
+
+
+if defined?($labelframe_demo) && $labelframe_demo
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+end
+
+$labelframe_demo = TkToplevel.new {|w|
+ title("Labelframe Demonstration")
+ iconname("labelframe")
+ positionWindow(w)
+}
+
+# Some information
+TkLabel.new($labelframe_demo,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+TkLabelFrame ¥¦¥£¥¸¥§¥Ã¥È¤Ï´ØÏ¢¤¹¤ë widget
+·²¤ò¤Þ¤È¤á¤Æ¼è¤ê°·¤¦¤¿¤á¤ËÍѤ¤¤é¤ì¤Þ¤¹¡£¥é
+¥Ù¥ë¤ÏÄ̾ï¤Îʸ»úÎó¤Ç¤â²¿¤é¤«¤Î¥¦¥£¥¸¥§¥Ã¥È
+¤Ç¤â¤«¤Þ¤¤¤Þ¤»¤ó¡£¤â¤·¤¢¤Ê¤¿¤¬»È¤Ã¤Æ¤¤¤ë
+Ruby ¤Ë¥ê¥ó¥¯¤µ¤ì¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤¬
+labelframe ¥¦¥£¥¸¥§¥Ã¥È¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤
+¾ì¹ç¡¢¤³¤Î¥Ç¥â¤Ï¤¦¤Þ¤¯Æ°¤«¤Ê¤¤¤Ï¤º¤Ç¤¹¡£
+¤½¤Î¾ì¹ç¤Ë¤Ï labelframe ¥¦¥£¥¸¥§¥Ã¥È¤¬¼ÂÁõ
+¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ê¤è¤ê¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤Î Tk
+¤òÁȤ߹ç¤ï¤»¤Æ»î¤¹¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
+EOL
+
+# The bottom buttons
+TkFrame.new($labelframe_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{
+ showCode 'labelframe'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# Demo area
+w = TkFrame.new($labelframe_demo).pack(:side=>:bottom, :fill=>:both,
+ :expand=>true)
+
+# A group of radiobuttons in a labelframe
+TkLabelFrame.new(w, :text=>'ÁªÂòÃÍ',
+ :padx=>2, :pady=>2) {|f|
+ grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m')
+
+ v = TkVariable.new
+ (1..4).each{|i|
+ TkRadiobutton.new(f, :text=>"This is value #{i}",
+ :variable=>v, :value=>i) {
+ pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+ }
+}
+
+
+# Using a label window to control a group of options.
+$lfdummy = TkVariable.new(0)
+
+def lfEnableButtons(w)
+ TkWinfo.children(w).each{|child|
+ next if child.path =~ /\.cb$/
+ if $lfdummy == 1
+ child.state(:normal)
+ else
+ child.state(:disabled)
+ end
+ }
+end
+
+TkLabelFrame.new(w, :pady=>2, :padx=>2){|f|
+ TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy,
+ :text=>"¥ª¥×¥·¥ç¥ó¤ò»ÈÍÑ", :padx=>0) {|cb|
+ command proc{lfEnableButtons(f)}
+ f.labelwidget(cb)
+ }
+ grid(:row=>0, :column=>1, :pady=>'2m', :padx=>'2m')
+
+ %w(¥ª¥×¥·¥ç¥ó1 ¥ª¥×¥·¥ç¥ó2 ¥ª¥×¥·¥ç¥ó3).each{|str|
+ TkCheckbutton.new(f, :text=>str).pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+
+ lfEnableButtons(f)
+}
+
+TkGrid.columnconfigure(w, [0,1], :weight=>1)
diff --git a/ext/tk/sample/demos-jp/menu.rb b/ext/tk/sample/demos-jp/menu.rb
new file mode 100644
index 0000000000..50152cead3
--- /dev/null
+++ b/ext/tk/sample/demos-jp/menu.rb
@@ -0,0 +1,188 @@
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($menu_demo) && $menu_demo
+ $menu_demo.destroy
+ $menu_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$menu_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu")
+ positionWindow(w)
+}
+
+# menu frame À¸À®
+$menu_frame = TkFrame.new($menu_demo, 'relief'=>'raised', 'bd'=>2)
+$menu_frame.pack('side'=>'top', 'fill'=>'x')
+
+# label À¸À®
+TkLabel.new($menu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh'
+ text("¤³¤Î¥¦¥£¥ó¥É¥¦¤ÏÍÍ¡¹¤Ê¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Command-X ¤òÆþÎϤ¹¤ë¤È¡¢X¤¬¥³¥Þ¥ó¥É¥­¡¼µ­¹æ¤Ë³¤¤¤ÆÉ½¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ê¤é¤Ð¡¢¥¢¥¯¥»¥é¥ì¡¼¥¿¤ò»È¤Ã¤¿¹àÌܵ¯Æ°¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼Í×ÁÇÃæ¡¢ºÇ¸å¤Î¤â¤Î¤Ï¡¢¤½¤Î¥á¥Ë¥å¡¼¤ÎºÇ½é¤Î¹àÌܤòÁªÂò¤¹¤ë¤³¤È¤ÇÆÈΩ¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£")
+ else
+ text("¤³¤Î¥¦¥£¥ó¥É¥¦¤ÏÍÍ¡¹¤Ê¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Alt-X ¤òÆþÎϤ¹¤ë¤È¡¢X¤¬¥á¥Ë¥å¡¼¤Ë¥¢¥ó¥À¡¼¥é¥¤¥óÉÕ¤­¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ê¤é¤Ð¡¢¥­¡¼¥Ü¡¼¥É¤«¤é¤Î»ØÄ꤬¤Ç¤­¤Þ¤¹¡£Ìð°õ¥­¡¼¤Ç¥á¥Ë¥å¡¼¤Î¥È¥é¥Ð¡¼¥¹¤â²Äǽ¤Ç¤¹¡£¥á¥Ë¥å¡¼¤¬»ØÄꤵ¤ì¤¿ºÝ¤Ë¤Ï¡¢¥¹¥Ú¡¼¥¹¥­¡¼¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤¢¤ë¤¤¤Ï¡¢¥¢¥ó¥À¡¼¥é¥¤¥óÉÕ¤­¤Îʸ»ú¤òÆþÎϤ¹¤ë¤³¤È¤Ç¤â¼Â¹Ô¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼¤Î¥¨¥ó¥È¥ê¤¬¥¢¥¯¥»¥é¥ì¡¼¥¿¤ò»ý¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¤½¤Î¥¢¥¯¥»¥é¥ì¡¼¥¿¤òÆþÎϤ¹¤ë¤³¤È¤Ç¥á¥Ë¥å¡¼¤ò»ØÄꤹ¤ë¤³¤È¤Ê¤·¤Ë¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼Í×ÁÇÃæ¡¢ºÇ¸å¤Î¤â¤Î¤Ï¡¢¤½¤Î¥á¥Ë¥å¡¼¤ÎºÇ½é¤Î¹àÌܤòÁªÂò¤¹¤ë¤³¤È¤ÇÆÈΩ¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£")
+ end
+}.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($menu_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $menu_demo
+ $menu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'menu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# menu À¸À®
+TkMenubutton.new($menu_frame, 'text'=>'File', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|file_menu|
+ m.configure('menu'=>file_menu)
+ add('command', 'label'=>'³«¤¯ ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"³«¤¯ ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'¿·µ¬', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"¿·µ¬"¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'Êݸ', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"Êݸ"¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'Êݸ(»ØÄê) ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"Êݸ(»ØÄê) ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('separator')
+ add('command', 'label'=>'¥×¥ê¥ó¥ÈÀßÄê ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"¥×¥ê¥ó¥ÈÀßÄê ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'¥×¥ê¥ó¥È ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"¥×¥ê¥ó¥È ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('separator')
+ add('command', 'label'=>'½ªÎ»', 'command'=>proc{$menu_demo.destroy})
+ }
+}
+
+if $tk_platform['platform'] == 'macintosh'
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenubutton.new($menu_frame, 'text'=>'Basic', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|basic_menu|
+ m.configure('menu'=>basic_menu)
+ add('command', 'label'=>'²¿¤â¤·¤Ê¤¤Ä¹¤¤¥¨¥ó¥È¥ê')
+ ['A','B','C','D','E','F','G'].each{|c|
+ # add('command', 'label'=>"ʸ»ú \"#{c}\" ¤ò°õ»ú", 'underline'=>4,
+ add('command', 'label'=>"Print letter \"#{c}\" (ʸ»ú \"#{c}\" ¤ò°õ»ú)",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_menu|
+ m.configure('menu'=>cascade_menu)
+ add('command', 'label'=>'Print hello(¤³¤ó¤Ë¤Á¤Ï)',
+ 'command'=>proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-h", proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"})
+ add('command', 'label'=>'Print goodbye(¤µ¤è¤¦¤Ê¤é)',
+ 'command'=>proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-g", proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ cascade_menu.add('cascade', 'label'=>'Check buttons(¥Á¥§¥Ã¥¯¥Ü¥¿¥ó)',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'¥ª¥¤¥ëÅÀ¸¡', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'¥Ö¥ì¡¼¥­ÅÀ¸¡', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'¥é¥¤¥ÈÅÀ¸¡', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨',
+ 'command'=>proc{showVars($menu_demo,
+ ['¥ª¥¤¥ëÅÀ¸¡', oil],
+ ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', trans],
+ ['¥Ö¥ì¡¼¥­ÅÀ¸¡', brakes],
+ ['¥é¥¤¥ÈÅÀ¸¡', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ cascade_menu.add('cascade', 'label'=>'Radio buttons(¥é¥¸¥ª¥Ü¥¿¥ó)',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'¥í¡¼¥Þ¥ó', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'¥Ü¡¼¥ë¥É', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'¥¤¥¿¥ê¥Ã¥¯', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨',
+ 'command'=>proc{showVars($menu_demo,
+ ['¥Ý¥¤¥ó¥È¥µ¥¤¥º', pointSize],
+ ['¥¹¥¿¥¤¥ë', style])} )
+ invoke 1
+ invoke 7
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
+ m.configure('menu'=>icon_menu)
+ add('command',
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'º£¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¤Î¹àÌܤϥƥ­¥¹¥È¤Ç¤Ï¤Ê¤¯¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¼¨¤·¤Æ¤¤¤Þ¤·¤¿¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¾¤Î¥á¥Ë¥å¡¼¹àÌܤÈÊѤï¤ê¤Þ¤»¤ó¡£',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'λ²ò')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'More', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|more_menu|
+ m.configure('menu'=>more_menu)
+ [ '¥¨¥ó¥È¥ê','Ê̤Υ¨¥ó¥È¥ê','²¿¤â¤·¤Ê¤¤','¤Û¤È¤ó¤É²¿¤â¤·¤Ê¤¤',
+ '¿ÍÀ¸¤ò°ÕµÁ¤¢¤ë¤â¤Î¤Ë' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Colors', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m) {|colors_menu|
+ m.configure('menu'=>colors_menu)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+ }
+}
diff --git a/ext/tk/sample/demos-jp/menu84.rb b/ext/tk/sample/demos-jp/menu84.rb
new file mode 100644
index 0000000000..8c2a815d78
--- /dev/null
+++ b/ext/tk/sample/demos-jp/menu84.rb
@@ -0,0 +1,210 @@
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($menu84_demo) && $menu84_demo
+ $menu84_demo.destroy
+ $menu84_demo = nil
+end
+
+# demo toplevel widget
+$menu84_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu84")
+ positionWindow(w)
+}
+
+begin
+ windowingsystem = Tk.windowingsystem()
+rescue
+ windowingsystem = ""
+end
+
+# label
+TkLabel.new($menu84_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ text("¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤ò»ý¤Ä¥á¥Ë¥å¡¼¥Ð¡¼¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤Þ¤¹¡£Command+x ('x'¤Ï¥³¥Þ¥ó¥É¥­¡¼¥·¥ó¥Ü¥ë¤Ë³¤±¤ÆÉ½¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ç¤¹) ¤È¥¿¥¤¥×¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¤â¹àÌܤε¡Ç½¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ºÇ¸å¤Î¥á¥Ë¥å¡¼¤Ï¡¢¥Þ¥¦¥¹¤Ç¥¦¥£¥ó¥É¥¦¤Î³°¤Ë¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢ÆÈΩ¤·¤¿¥Ñ¥ì¥Ã¥È¤È¤Ê¤ë¤è¤¦¤ËÀÚ¤êÊü¤¹¤³¤È¤¬²Äǽ¤Ç¤¹¡£")
+ else
+ text("¤³¤Î¥¦¥£¥ó¥É¥¦¤Ë¤Ï¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤ò»ý¤Ä¥á¥Ë¥å¡¼¥Ð¡¼¤¬ÉÕ¤±¤é¤ì¤Æ¤¤¤Þ¤¹¡£Alt+x ('x'¤Ï¥á¥Ë¥å¡¼¾å¤Ç²¼Àþ¤¬°ú¤«¤ì¤¿Ê¸»ú¤Ç¤¹) ¤È¥¿¥¤¥×¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¤â¥á¥Ë¥å¡¼¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£Ìð°õ¥­¡¼¤ò»È¤Ã¤Æ¡¢¥á¥Ë¥å¡¼´Ö¤ò°Üư¤¹¤ë¤³¤È¤â²Äǽ¤Ç¤¹¡£¥á¥Ë¥å¡¼¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë»þ¤Ë¤Ï¡¢¸½ºß°ÌÃ֤ιàÌܤò¥¹¥Ú¡¼¥¹¥­¡¼¤ÇÁªÂò¤·¤¿¤ê¡¢²¼Àþ¤¬°ú¤«¤ì¤¿Ê¸»ú¤òÆþÎϤ¹¤ë¤³¤È¤Ç¤½¤Î¹àÌܤòÁªÂò¤·¤¿¤ê¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤â¤·¹àÌܤ˥¢¥¯¥»¥é¥ì¡¼¥¿¤Î»ØÄ꤬¤Ê¤µ¤ì¤Æ¤¤¤¿¤Ê¤é¤Ð¡¢¤½¤Î»ØÄꤵ¤ì¤¿¥­¡¼ÆþÎϤò¹Ô¤¦¤³¤È¤Ç¡¢¥á¥Ë¥å¡¼¤òɽ¼¨¤µ¤»¤ë¤³¤È¤Ê¤¯Ä¾Àܤ½¤Î¹àÌܤε¡Ç½¤ò¸Æ¤Ó½Ð¤»¤Þ¤¹¡£ºÇ¸å¤Î¥á¥Ë¥å¡¼¤Ï¡¢¥á¥Ë¥å¡¼¤ÎºÇ½é¤Î¹àÌܤòÁªÂò¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢ÆÈΩ¤·¤¿¥Ñ¥ì¥Ã¥È¤È¤Ê¤ë¤è¤¦¤ËÀÚ¤êÊü¤¹¤³¤È¤¬²Äǽ¤Ç¤¹¡£")
+ end
+}.pack('side'=>'top')
+
+
+menustatus = TkVariable.new(" ")
+TkFrame.new($menu84_demo) {|frame|
+ TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken',
+ 'bd'=>1, 'font'=>['Helvetica', '10'],
+ 'anchor'=>'w').pack('side'=>'left', 'padx'=>2,
+ 'expand'=>true, 'fill'=>'both')
+ pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+}
+
+
+# frame
+TkFrame.new($menu84_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $menu84_demo
+ $menu84_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'menu84'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# create menu frame
+$menu84_frame = TkMenu.new($menu84_demo, 'tearoff'=>false)
+
+# menu
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'File', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Open...', 'command'=>proc{fail '¤³¤ì¤Ïñ¤Ê¤ë¥Ç¥â¤Ç¤¹¤«¤é¡¢"Open..." ¹àÌܤε¡Ç½¤ÏÆÃ¤ËÄêµÁ¤µ¤ì¤Æ¤Ï¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'New', 'command'=>proc{fail '¤³¤ì¤Ïñ¤Ê¤ë¥Ç¥â¤Ç¤¹¤«¤é¡¢"New" ¹àÌܤε¡Ç½¤ÏÆÃ¤ËÄêµÁ¤µ¤ì¤Æ¤Ï¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'Save', 'command'=>proc{fail '¤³¤ì¤Ïñ¤Ê¤ë¥Ç¥â¤Ç¤¹¤«¤é¡¢"Save" ¹àÌܤε¡Ç½¤ÏÆÃ¤ËÄêµÁ¤µ¤ì¤Æ¤Ï¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'Save As...', 'command'=>proc{fail '¤³¤ì¤Ïñ¤Ê¤ë¥Ç¥â¤Ç¤¹¤«¤é¡¢"Save As..." ¹àÌܤε¡Ç½¤ÏÆÃ¤ËÄêµÁ¤µ¤ì¤Æ¤Ï¤¤¤Þ¤»¤ó¡£'})
+ add('separator')
+ add('command', 'label'=>'Print Setup...', 'command'=>proc{fail '¤³¤ì¤Ïñ¤Ê¤ë¥Ç¥â¤Ç¤¹¤«¤é¡¢"Print Setup..." ¹àÌܤε¡Ç½¤ÏÆÃ¤ËÄêµÁ¤µ¤ì¤Æ¤Ï¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'Print...', 'command'=>proc{fail '¤³¤ì¤Ïñ¤Ê¤ë¥Ç¥â¤Ç¤¹¤«¤é¡¢"Print..." ¹àÌܤε¡Ç½¤ÏÆÃ¤ËÄêµÁ¤µ¤ì¤Æ¤Ï¤¤¤Þ¤»¤ó¡£'})
+ add('separator')
+ add('command', 'label'=>'Dismiss Menus Demo', 'command'=>proc{$menu84_demo.destroy})
+}
+
+if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem = "classic" || windowingsystem = "aqua"
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Basic', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Long entry that does nothing')
+ ['A','B','C','D','E','F','G'].each{|c|
+ add('command', 'label'=>"Print letter \"#{c}\"",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu84_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Cascades', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Print hello',
+ 'command'=>proc{print "Hello\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-h", proc{print "Hello\n"})
+ add('command', 'label'=>'Print goodbye',
+ 'command'=>proc{print "Goodbye\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-g", proc{print "Goodbye\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ m.add('cascade', 'label'=>'Check button',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'¥ª¥¤¥ë¸¡ºº', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥ó¸¡ºº', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'¥Ö¥ì¡¼¥­¸¡ºº', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'¥é¥¤¥È¸¡ºº', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu84_demo,
+ ['¥ª¥¤¥ë', oil],
+ ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥ó', trans],
+ ['¥Ö¥ì¡¼¥­', brakes],
+ ['¥é¥¤¥È', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ m.add('cascade', 'label'=>'Radio buttons',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 point', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 point', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 point', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'Roman', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'Bold', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'¸½ºßÃͤÎɽ¼¨',
+ 'command'=>proc{showVars($menu84_demo,
+ ['pointSize', pointSize],
+ ['style', style])} )
+ invoke 1
+ invoke 7
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0)
+ add('command', 'hidemargin'=>1,
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¹àÌܤϡ¢Ê¸»úÎó¤ÎÂå¤ï¤ê¤Ë¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤Ç¹àÌܤòɽ¼¨¤·¤¿¤â¤Î¤Ç¤¹¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¡¢¤Û¤«¤Î¥á¥Ë¥å¡¼¹àÌÜ¤È¤Î´Ö¤ÇÆÃ¤Ë°ã¤¤¤¬¤¢¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'ÊĤ¸¤ë')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon, 'hidemargin'=>1,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+
+ entryconfigure(2, :columnbreak=>true)
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'More', 'menu'=>m, 'underline'=>0)
+ [ 'An entry','Another entry','Does nothing','Does almost nothing',
+ 'Make life meaningful' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+
+ m.entryconfigure('Does almost nothing',
+ 'bitmap'=>'questhead', 'compound'=>'left',
+ 'command'=>proc{
+ TkDialog.new('title'=>'Compound Menu Entry',
+ 'message'=>'¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¹àÌܤϡ¢¥Ó¥Ã¥È¥Þ¥Ã¥×¥¤¥á¡¼¥¸¤Èʸ»úÎó¤È¤òƱ»þ¤Ë°ì¤Ä¤Î¹àÌܤËɽ¼¨¤¹¤ë¤è¤¦¤Ë¤·¤¿¤â¤Î¤Ç¤¹¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¡¢¤Û¤«¤Î¥á¥Ë¥å¡¼¹àÌÜ¤È¤Î´Ö¤ÇÆÃ¤Ë°ã¤¤¤¬¤¢¤ë¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£',
+ 'buttons'=>['λ²ò'], 'bitmap'=>'')
+ })
+}
+
+TkMenu.new($menu84_frame) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Colors', 'menu'=>m, 'underline'=>0)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+}
+
+$menu84_demo.menu($menu84_frame)
+
+TkMenu.bind('<MenuSelect>', proc{|w|
+ begin
+ label = w.entrycget('active', 'label')
+ rescue
+ label = " "
+ end
+ menustatus.value = label
+ Tk.update(true)
+ }, '%W')
diff --git a/ext/tk/sample/demos-jp/menu8x.rb b/ext/tk/sample/demos-jp/menu8x.rb
new file mode 100644
index 0000000000..ab691a42b5
--- /dev/null
+++ b/ext/tk/sample/demos-jp/menu8x.rb
@@ -0,0 +1,222 @@
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($menu8x_demo) && $menu8x_demo
+ $menu8x_demo.destroy
+ $menu8x_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$menu8x_demo = TkToplevel.new {|w|
+ title("Menu Demonstration (Tk8.x)")
+ iconname("menu")
+ positionWindow(w)
+}
+
+# version check
+if $tk_version.to_f < 8.0
+
+# label À¸À®
+TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ text("¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¥¹¥¯¥ê¥×¥È¤Ï Tk8.0 °Ê¾å¤ÇÍøÍѤǤ­¤ëµ¡Ç½¤òÍøÍѤ·¤Æ¤¤¤ë¤¿¤á¡¢¤¢¤Ê¤¿¤Î Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} ¤Ç¤ÏÀµ¾ï¤Ë¼Â¹Ô¤Ç¤­¤Þ¤»¤ó¡£¤è¤Ã¤Æ¥Ç¥â¤Î¼Â¹Ô¤òÃæ»ß¤·¤Þ¤·¤¿¡£¤¿¤À¤·¡¢²¼¤Î¥³¡¼¥É»²¾È¥Ü¥¿¥ó¤ò²¡¤¹¤³¤È¤Ç¡¢¼Â¹Ô¤¬Ãæ»ß¤µ¤ì¤¿¥¹¥¯¥ê¥×¥È¤Î¥½¡¼¥¹¤ò»²¾È¤¹¤ë¤³¤È¤Ï²Äǽ¤Ç¤¹¡£")
+}.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($menu8x_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $menu8x_demo
+ $menu8x_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'menu8x'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+else ; # Tk8.x
+
+# label À¸À®
+TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh'
+ text("¤³¤Î¥¦¥£¥ó¥É¥¦¤ÏÍÍ¡¹¤Ê¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Command-X ¤òÆþÎϤ¹¤ë¤È¡¢X¤¬¥³¥Þ¥ó¥É¥­¡¼µ­¹æ¤Ë³¤¤¤ÆÉ½¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ê¤é¤Ð¡¢¥¢¥¯¥»¥é¥ì¡¼¥¿¤ò»È¤Ã¤¿¹àÌܵ¯Æ°¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼Í×ÁÇÃæ¡¢ºÇ¸å¤Î¤â¤Î¤Ï¡¢¤½¤Î¥á¥Ë¥å¡¼¤ÎºÇ½é¤Î¹àÌܤòÁªÂò¤¹¤ë¤³¤È¤ÇÆÈΩ¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£")
+ else
+ text("¤³¤Î¥¦¥£¥ó¥É¥¦¤ÏÍÍ¡¹¤Ê¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¥á¥Ë¥å¡¼¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£Alt-X ¤òÆþÎϤ¹¤ë¤È¡¢X¤¬¥á¥Ë¥å¡¼¤Ë¥¢¥ó¥À¡¼¥é¥¤¥óÉÕ¤­¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ëʸ»ú¤Ê¤é¤Ð¡¢¥­¡¼¥Ü¡¼¥É¤«¤é¤Î»ØÄ꤬¤Ç¤­¤Þ¤¹¡£Ìð°õ¥­¡¼¤Ç¥á¥Ë¥å¡¼¤Î¥È¥é¥Ð¡¼¥¹¤â²Äǽ¤Ç¤¹¡£¥á¥Ë¥å¡¼¤¬»ØÄꤵ¤ì¤¿ºÝ¤Ë¤Ï¡¢¥¹¥Ú¡¼¥¹¥­¡¼¤Ç¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤¢¤ë¤¤¤Ï¡¢¥¢¥ó¥À¡¼¥é¥¤¥óÉÕ¤­¤Îʸ»ú¤òÆþÎϤ¹¤ë¤³¤È¤Ç¤â¼Â¹Ô¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼¤Î¥¨¥ó¥È¥ê¤¬¥¢¥¯¥»¥é¥ì¡¼¥¿¤ò»ý¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¤½¤Î¥¢¥¯¥»¥é¥ì¡¼¥¿¤òÆþÎϤ¹¤ë¤³¤È¤Ç¥á¥Ë¥å¡¼¤ò»ØÄꤹ¤ë¤³¤È¤Ê¤·¤Ë¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¥á¥Ë¥å¡¼Í×ÁÇÃæ¡¢ºÇ¸å¤Î¤â¤Î¤Ï¡¢¤½¤Î¥á¥Ë¥å¡¼¤ÎºÇ½é¤Î¹àÌܤòÁªÂò¤¹¤ë¤³¤È¤ÇÆÈΩ¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£")
+ end
+}.pack('side'=>'top')
+
+# ¾õÂÖɽ¼¨¤ÎÀ¸À®
+$menu8xstatus = TkVariable.new(" ")
+TkFrame.new($menu8x_demo) {|frame|
+ TkLabel.new(frame, 'textvariable'=>$menu8xstatus, 'relief'=>'sunken',
+ 'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\
+ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+
+# frame À¸À®
+TkFrame.new($menu8x_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $menu8x_demo
+ $menu8x_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'menu8x'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# menu À¸À®
+TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m|
+ TkMenu.new(m, 'tearoff'=>false) {|file_menu|
+ m.add('cascade', 'label'=>'File', 'menu'=>file_menu, 'underline'=>0)
+ add('command', 'label'=>'³«¤¯ ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"³«¤¯ ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'¿·µ¬', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"¿·µ¬"¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'Êݸ', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"Êݸ"¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'Êݸ(»ØÄê) ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"Êݸ(»ØÄê) ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('separator')
+ add('command', 'label'=>'¥×¥ê¥ó¥ÈÀßÄê ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"¥×¥ê¥ó¥ÈÀßÄê ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('command', 'label'=>'¥×¥ê¥ó¥È ...', 'command'=>proc{fail '¤³¤ì¤Ï¡¢¥Ç¥â¤Ç¤¹¤Î¤Ç"¥×¥ê¥ó¥È ..."¤ËÂФ¹¤ë¥¢¥¯¥·¥ç¥ó¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£'})
+ add('separator')
+ add('command', 'label'=>'½ªÎ»', 'command'=>proc{$menu8x_demo.destroy})
+ }
+
+ if $tk_platform['platform'] == 'macintosh'
+ modifier = 'Command'
+ elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+ else
+ modifier = 'Meta'
+ end
+
+ TkMenu.new(m, 'tearoff'=>false) {|basic_menu|
+ m.add('cascade', 'label'=>'Basic', 'menu'=>basic_menu, 'underline'=>0)
+ add('command', 'label'=>'²¿¤â¤·¤Ê¤¤Ä¹¤¤¥¨¥ó¥È¥ê')
+ ['A','B','C','D','E','F','G'].each{|c|
+ # add('command', 'label'=>"ʸ»ú \"#{c}\" ¤ò°õ»ú", 'underline'=>4,
+ add('command', 'label'=>"Print letter \"#{c}\" (ʸ»ú \"#{c}\" ¤ò°õ»ú)",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu8x_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_menu|
+ m.add('cascade', 'label'=>'Cascades', 'menu'=>cascade_menu, 'underline'=>0)
+ add('command', 'label'=>'Print hello(¤³¤ó¤Ë¤Á¤Ï)',
+ 'command'=>proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu8x_demo.bind("#{modifier}-h", proc{print "Hello(¤³¤ó¤Ë¤Á¤Ï)\n"})
+ add('command', 'label'=>'Print goodbye(¤µ¤è¤¦¤Ê¤é)',
+ 'command'=>proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu8x_demo.bind("#{modifier}-g", proc{print "Goodbye(¤µ¤è¤¦¤Ê¤é)\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ cascade_menu.add('cascade', 'label'=>'Check buttons(¥Á¥§¥Ã¥¯¥Ü¥¿¥ó)',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'¥ª¥¤¥ëÅÀ¸¡', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'¥Ö¥ì¡¼¥­ÅÀ¸¡', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'¥é¥¤¥ÈÅÀ¸¡', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨',
+ 'command'=>proc{showVars($menu8x_demo,
+ ['¥ª¥¤¥ëÅÀ¸¡', oil],
+ ['¥È¥é¥ó¥¹¥ß¥Ã¥·¥ç¥óÅÀ¸¡', trans],
+ ['¥Ö¥ì¡¼¥­ÅÀ¸¡', brakes],
+ ['¥é¥¤¥ÈÅÀ¸¡', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ cascade_menu.add('cascade', 'label'=>'Radio buttons(¥é¥¸¥ª¥Ü¥¿¥ó)',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 ¥Ý¥¤¥ó¥È', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'¥í¡¼¥Þ¥ó', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'¥Ü¡¼¥ë¥É', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'¥¤¥¿¥ê¥Ã¥¯', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'¸½ºß¤ÎÃͤòɽ¼¨',
+ 'command'=>proc{showVars($menu8x_demo,
+ ['¥Ý¥¤¥ó¥È¥µ¥¤¥º', pointSize],
+ ['¥¹¥¿¥¤¥ë', style])} )
+ invoke 1
+ invoke 7
+ }
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
+ m.add('cascade', 'label'=>'Icons', 'menu'=>icon_menu, 'underline'=>0)
+ add('command',
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'hidemargin'=>1,
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'º£¤¢¤Ê¤¿¤¬ÁªÂò¤·¤¿¥á¥Ë¥å¡¼¤Î¹àÌܤϥƥ­¥¹¥È¤Ç¤Ï¤Ê¤¯¥Ó¥Ã¥È¥Þ¥Ã¥×¤òɽ¼¨¤·¤Æ¤¤¤Þ¤·¤¿¡£¤½¤ì°Ê³°¤ÎÅÀ¤Ç¤Ï¾¤Î¥á¥Ë¥å¡¼¹àÌܤÈÊѤï¤ê¤Þ¤»¤ó¡£',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'λ²ò')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon, 'hidemargin'=>1,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+
+ entryconfigure(2, 'columnbreak'=>1)
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|more_menu|
+ m.add('cascade', 'label'=>'More', 'menu'=>more_menu, 'underline'=>0)
+ [ '¥¨¥ó¥È¥ê','Ê̤Υ¨¥ó¥È¥ê','²¿¤â¤·¤Ê¤¤','¤Û¤È¤ó¤É²¿¤â¤·¤Ê¤¤',
+ '¿ÍÀ¸¤ò°ÕµÁ¤¢¤ë¤â¤Î¤Ë' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+ }
+
+ TkMenu.new(m) {|colors_menu|
+ m.add('cascade', 'label'=>'Colors', 'menu'=>colors_menu, 'underline'=>1)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+ }
+
+ $menu8x_demo.configure('menu'=>m)
+}
+
+TkMenu.bind('<MenuSelect>',
+ proc{|w|
+ begin
+ label = w.entrycget('active', 'label')
+ rescue
+ label = ' '
+ end
+ $menu8xstatus.value = label
+ Tk.update('idletasks')
+ }, '%W')
+
+end ; # Tk 8.x
diff --git a/ext/tk/sample/demos-jp/menubu.rb b/ext/tk/sample/demos-jp/menubu.rb
new file mode 100644
index 0000000000..aa90a3087f
--- /dev/null
+++ b/ext/tk/sample/demos-jp/menubu.rb
@@ -0,0 +1,235 @@
+require "tkcanvas"
+
+def optionMenu(menubutton, varName, firstValue, *rest)
+ varName.value = firstValue
+ configoptions = {'textvariable'=>varName,'indicatoron'=>'on',
+ 'relief'=>'raised','borderwidth'=>2,'highlightthickness'=>2,
+ 'anchor'=>'c','direction'=>'flush'}
+ configoptions.each {|key, value|
+ menubutton.configure(key, value)
+ }
+ menu = TkMenu.new(menubutton) {
+ tearoff 'off'
+ add 'radio', 'label'=>firstValue, 'variable'=>varName
+ }
+ menubutton.menu(menu)
+ for i in rest
+ menu.add 'radio', 'label'=>i, 'variable'=>varName
+ end
+
+ return menu
+end
+
+if defined?($menubu_demo) && $menubu_demo
+ $menubu_demo.destroy
+ $menubu_demo = nil
+end
+
+$menubu_demo = TkToplevel.new {|w|
+ title("Menu Button Demonstration")
+ iconname("menubutton")
+}
+
+positionWindow($menubu_demo)
+
+# version check
+if $tk_version.to_f < 8.0
+
+# label À¸À®
+TkLabel.new($menubu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ text("¼Â¹Ô¤·¤è¤¦¤È¤·¤¿¥¹¥¯¥ê¥×¥È¤Ï Tk8.0 °Ê¾å¤ÇÍøÍѤǤ­¤ëµ¡Ç½¤òÍøÍѤ·¤Æ¤¤¤ë¤¿¤á¡¢¤¢¤Ê¤¿¤Î Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} ¤Ç¤ÏÀµ¾ï¤Ë¼Â¹Ô¤Ç¤­¤Þ¤»¤ó¡£¤è¤Ã¤Æ¥Ç¥â¤Î¼Â¹Ô¤òÃæ»ß¤·¤Þ¤·¤¿¡£¤¿¤À¤·¡¢²¼¤Î¥³¡¼¥É»²¾È¥Ü¥¿¥ó¤ò²¡¤¹¤³¤È¤Ç¡¢¼Â¹Ô¤¬Ãæ»ß¤µ¤ì¤¿¥¹¥¯¥ê¥×¥È¤Î¥½¡¼¥¹¤ò»²¾È¤¹¤ë¤³¤È¤Ï²Äǽ¤Ç¤¹¡£")
+}.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($menubu_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'menubu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+else ; # Tk8.x
+
+body = TkFrame.new($menubu_demo)
+body.pack('expand'=>'yes', 'fill'=>'both')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+right = TkMenubutton.new(body) {
+ text "Right"
+ underline 0
+ direction 'right'
+ relief 'raised'
+}
+rightMenu = TkMenu.new(right) {
+ tearoff 0
+ add 'command', 'label'=>"Right menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Right menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Right menu.\""}
+}
+right.menu(rightMenu)
+right.grid('row'=>1, 'column'=>0, 'sticky'=>'w')
+
+left = TkMenubutton.new(body) {
+ text "Left"
+ underline 0
+ direction 'left'
+ relief 'raised'
+}
+leftMenu = TkMenu.new(left) {
+ tearoff 0
+ add 'command', 'label'=>"Left menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Left menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Left menu.\""}
+}
+left.menu(leftMenu)
+left.grid('row'=>1, 'column'=>2, 'sticky'=>'e')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+above = TkMenubutton.new(body) {
+ text "Above"
+ underline 0
+ direction 'above'
+ relief 'raised'
+}
+aboveMenu = TkMenu.new(above) {
+ tearoff 0
+ add 'command', 'label'=>"Above menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Above menu.\""}
+ add 'command', 'label'=>"Above menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Above menu.\""}
+}
+above.menu(aboveMenu)
+above.grid('row'=>2, 'column'=>1, 'sticky'=>'s')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+TkFrame.new($menubu_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc {
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc { showCode 'menubu' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x', 'pady'=>'2m')
+
+msg = TkLabel.new(center) {
+# font $font
+ wraplength '4i'
+ justify 'left'
+ text "¤³¤ì¤Ï¥á¥Ë¥å¡¼¥Ü¥¿¥ó¤Î¥Ç¥â¤Ç¤¹¡£\"Below\"¤Î¥Ü¥¿¥ó¤Ï\
+²¼¤Ë¥á¥Ë¥å¡¼¤ò½Ð¤·¡¢\"Right\"¤Î¥Ü¥¿¥ó¤Ï±¦¤Ë¥á¥Ë¥å¡¼¤ò½Ð¤·¤Æ¡¢\
+¡Ä¡Ä¤È¤Ê¤ê¤Þ¤¹¡£¤³¤Îʸ¾Ï¤Î²¼¤Ë¤Ï2¤Ä¤Î¥ª¥×¥·¥ç¥ó¥á¥Ë¥å¡¼¤¬¤¢¤ê¤Þ¤¹¡£\
+1¤Ä¤ÏÉáÄ̤Υá¥Ë¥å¡¼¤Ç¡¢¤â¤¦1¤Ä¤Ï16¿§¤Î¥Ñ¥ì¥Ã¥È¤Ç¤¹¡£"
+}
+msg.pack('side'=>'top', 'padx'=>25, 'pady'=>25)
+
+TkFrame.new(center) {|f|
+ menubuttonoptions = TkVariable.new
+ mbutton = TkMenubutton.new(f)
+ options = optionMenu(mbutton, menubuttonoptions,
+ 'one', 'two', 'three')
+ mbutton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ paletteColor = TkVariable.new
+ colors = ['Black','red4','DarkGreen','NavyBlue', 'gray75',
+ 'Red','Green','Blue','gray50','Yellow','Cyan','Magenta',
+ 'White','Brown','DarkSeaGreen','DarkViolet']
+ colorMenuButton = TkMenubutton.new(f)
+ m = optionMenu(colorMenuButton, paletteColor, *colors)
+ begin
+ windowingsystem = Tk.windowingsystem()
+ rescue
+ windowingsystem = ""
+ end
+ if windowingsystem == "classic" || windowingsystem == "aqua"
+ topBorderColor = 'Black'
+ bottomBorderColor = 'Black'
+ else
+ topBorderColor = 'gray50'
+ bottomBorderColor = 'gray75'
+ end
+ for i in 0..15
+ image = TkPhotoImage.new('height'=>16, 'width'=>16)
+ image.put(topBorderColor, 0, 0, 16, 1)
+ image.put(topBorderColor, 0, 1, 1, 16)
+ image.put(bottomBorderColor, 0, 15, 16, 16)
+ image.put(bottomBorderColor, 15, 1, 16, 16)
+ image.put(colors[i], 1, 1, 15, 15)
+
+ selectimage = TkPhotoImage.new('height'=>16, 'width'=>16)
+ selectimage.put('Black', 0, 0, 16, 2)
+ selectimage.put('Black', 0, 2, 2, 16)
+ selectimage.put('Black', 2, 14, 16, 16)
+ selectimage.put('Black', 14, 2, 16, 14)
+ selectimage.put(colors[i], 2, 2, 14, 14)
+
+ m.entryconfigure(i, 'image'=>image, 'selectimage'=>selectimage, 'hidemargin'=>'on')
+ end
+ m.configure('tearoff', 'on')
+ for c in ['Black', 'gray75', 'gray50', 'White']
+ m.entryconfigure(c, 'columnbreak'=>1)
+ end
+ colorMenuButton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ pack 'padx'=>25, 'pady'=>25
+}
+
+end ; # Tk8.x
diff --git a/ext/tk/sample/demos-jp/msgbox.rb b/ext/tk/sample/demos-jp/msgbox.rb
new file mode 100644
index 0000000000..983e6b6589
--- /dev/null
+++ b/ext/tk/sample/demos-jp/msgbox.rb
@@ -0,0 +1,86 @@
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($msgbox_demo) && $msgbox_demo
+ $msgbox_demo.destroy
+ $msgbox_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$msgbox_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($msgbox_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"ɽ¼¨¤¹¤ë¥¢¥¤¥³¥ó¤È¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Î¼ïÎà¤òÁª¤ó¤Ç²¼¤µ¤¤¡£¤½¤·¤Æ \"¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\" ¥Ü¥¿¥ó¤ò²¡¤¹¤È¡¢»ØÄꤷ¤¿¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£").pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($msgbox_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $msgbox_demo
+ $msgbox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'msgbox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹'
+ command proc{showMessageBox $msgbox_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+$msgbox_leftframe = TkFrame.new($msgbox_demo)
+$msgbox_rightframe = TkFrame.new($msgbox_demo)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'¥¢¥¤¥³¥ó').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'¼ïÎà').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"¤³¤ì¤Ï \"#{$msgboxType.value}\" ¤È¤¤¤¦¼ïÎà¤Î¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹¤Ç¡¢\"#{$msgboxIcon.value}\" ¤Î¥¢¥¤¥³¥ó¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"¤¢¤Ê¤¿¤Ï \"#{button}\" ¤ò²¡¤·¤Þ¤·¤¿¤Í¡£")
+end
+
diff --git a/ext/tk/sample/demos-jp/paned1.rb b/ext/tk/sample/demos-jp/paned1.rb
new file mode 100644
index 0000000000..8d16d03c08
--- /dev/null
+++ b/ext/tk/sample/demos-jp/paned1.rb
@@ -0,0 +1,48 @@
+# paned1.rb
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows horizontally.
+#
+# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned1_demo) && $paned1_demo
+ $paned1_demo.destroy
+ $paned1_demo = nil
+end
+
+$paned1_demo = TkToplevel.new {|w|
+ title("Horizontal Paned Window Demonstration")
+ iconname("paned1")
+ positionWindow(w)
+}
+
+TkLabel.new($paned1_demo,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+²¼¤Î¿§ÉÕ¤±¤µ¤ì¤¿Æó¤Ä¤Î¥¦¥£¥ó¥É¥¦¤Î´Ö¤Î»ÅÀÚ¤êÏȤϡ¢°ì¤Ä¤ÎÎΰè¤ò¤½¤ì¤¾¤ì¤Î¥¦¥£¥ó¥É¥¦¤Î¤¿¤á¤Ëʬ³ä¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£º¸¥Ü¥¿¥ó¤Ç»ÅÀÚ¤ê¤òÁàºî¤¹¤ë¤È¡¢Ê¬³ä¥µ¥¤¥ºÊѹ¹¤ÎÁàºîÅÓÃæ¤Ç¤ÏºÆÉ½¼¨¤Ï¤Ê¤µ¤ì¤º¡¢³ÎÄꤵ¤»¤¿¤È¤­¤Ëɽ¼¨¤¬¹¹¿·¤µ¤ì¤Þ¤¹¡£¥Þ¥¦¥¹¤Ë¤è¤ë»ÅÀÚ¤ê¤ÎÁàºî¤ËÄɿ路¤Æ¥µ¥¤¥º¤òÊѹ¹¤·¤¿É½¼¨¤¬¤Ê¤ï¤ì¤ë¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Þ¥¦¥¹¤ÎÃæ±û¥Ü¥¿¥ó¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£
+¤â¤·¤¢¤Ê¤¿¤¬»È¤Ã¤Æ¤¤¤ë Ruby ¤Ë¥ê¥ó¥¯¤µ¤ì¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤¬ panedwindow ¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤
+¾ì¹ç¡¢¤³¤Î¥Ç¥â¤Ï¤¦¤Þ¤¯Æ°¤«¤Ê¤¤¤Ï¤º¤Ç¤¹¡£¤½¤Î¾ì¹ç¤Ë¤Ï panedwindow ¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ê
+¤è¤ê¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤Î Tk ¤òÁȤ߹ç¤ï¤»¤Æ»î¤¹
+¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
+EOL
+
+# The bottom buttons
+TkFrame.new($paned1_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
+ $paned1_demo.destroy
+ $paned1_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{
+ showCode 'paned1'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+TkPanedwindow.new($paned1_demo){|f|
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+
+ add(TkLabel.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
+ TkLabel.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
+}
diff --git a/ext/tk/sample/demos-jp/paned2.rb b/ext/tk/sample/demos-jp/paned2.rb
new file mode 100644
index 0000000000..1e82eddda4
--- /dev/null
+++ b/ext/tk/sample/demos-jp/paned2.rb
@@ -0,0 +1,96 @@
+# paned2.rb --
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows vertically.
+#
+# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned2_demo) && $paned2_demo
+ $paned2_demo.destroy
+ $paned2_demo = nil
+end
+
+$paned2_demo = TkToplevel.new {|w|
+ title("Vertical Paned Window Demonstration")
+ iconname("paned2")
+ positionWindow(w)
+}
+
+TkLabel.new($paned2_demo,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+²¼¤Î¥¹¥¯¥í¡¼¥ë¥Ð¡¼ÉÕ¤­¤Î¥¦¥£¥¸¥§¥Ã¥È¤¬ÃÖ¤«¤ì¤¿Æó¤Ä¤Î¥¦¥£¥ó¥É¥¦¤Î´Ö¤Î»ÅÀÚ¤êÏȤϡ¢°ì¤Ä¤ÎÎΰè¤ò¤½¤ì¤¾¤ì¤Î¥¦¥£¥ó¥É¥¦¤Î¤¿¤á¤Ëʬ³ä¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£º¸¥Ü¥¿¥ó¤Ç»ÅÀÚ¤ê¤òÁàºî¤¹¤ë¤È¡¢Ê¬³ä¥µ¥¤¥ºÊѹ¹¤ÎÁàºîÅÓÃæ¤Ç¤ÏºÆÉ½¼¨¤Ï¤Ê¤µ¤ì¤º¡¢³ÎÄꤵ¤»¤¿¤È¤­¤Ëɽ¼¨¤¬¹¹¿·¤µ¤ì¤Þ¤¹¡£¥Þ¥¦¥¹¤Ë¤è¤ë»ÅÀÚ¤ê¤ÎÁàºî¤ËÄɿ路¤Æ¥µ¥¤¥º¤òÊѹ¹¤·¤¿É½¼¨¤¬¤Ê¤ï¤ì¤ë¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢¥Þ¥¦¥¹¤ÎÃæ±û¥Ü¥¿¥ó¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤¡£
+¤â¤·¤¢¤Ê¤¿¤¬»È¤Ã¤Æ¤¤¤ë Ruby ¤Ë¥ê¥ó¥¯¤µ¤ì¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤¬ panedwindow ¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤
+¾ì¹ç¡¢¤³¤Î¥Ç¥â¤Ï¤¦¤Þ¤¯Æ°¤«¤Ê¤¤¤Ï¤º¤Ç¤¹¡£¤½¤Î¾ì¹ç¤Ë¤Ï panedwindow ¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ê
+¤è¤ê¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤Î Tk ¤òÁȤ߹ç¤ï¤»¤Æ»î¤¹
+¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
+EOL
+
+# The bottom buttons
+TkFrame.new($paned2_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
+ $paned2_demo.destroy
+ $paned2_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{
+ showCode 'paned2'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+paneList = TkVariable.new # define as normal variable (not array)
+paneList.value = [ # ruby's array --> tcl's list
+ 'Ruby/Tk ¤Î¥¦¥£¥¸¥§¥Ã¥È°ìÍ÷',
+ 'TkButton',
+ 'TkCanvas',
+ 'TkCheckbutton',
+ 'TkEntry',
+ 'TkFrame',
+ 'TkLabel',
+ 'TkLabelframe',
+ 'TkListbox',
+ 'TkMenu',
+ 'TkMenubutton',
+ 'TkMessage',
+ 'TkPanedwindow',
+ 'TkRadiobutton',
+ 'TkScale',
+ 'TkScrollbar',
+ 'TkSpinbox',
+ 'TkText',
+ 'TkToplevel'
+]
+
+# Create the pane itself
+TkPanedwindow.new($paned2_demo, :orient=>:vertical){|f|
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+
+ add(TkFrame.new(f){|paned2_top|
+ TkListbox.new(paned2_top, :listvariable=>paneList) {
+ # Invert the first item to highlight it
+ itemconfigure(0, :background=>self.cget(:foreground),
+ :foreground=>self.cget(:background) )
+ yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right,
+ :fill=>:y))
+ pack(:fill=>:both, :expand=>true)
+ }
+ },
+
+ TkFrame.new(f, :height=>120) {|paned2_bottom|
+ # The bottom window is a text widget with scrollbar
+ paned2_xscr = TkScrollbar.new(paned2_bottom)
+ paned2_yscr = TkScrollbar.new(paned2_bottom)
+ paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
+ insert('1.0', '¤³¤³¤ËÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢' +
+ '¤´¤¯ÉáÄ̤Υƥ­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ç¤¹¡£')
+ xscrollbar(paned2_xscr)
+ yscrollbar(paned2_yscr)
+ }
+ Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
+ Tk.grid(paned2_xscr, :sticky=>'nsew')
+ TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
+ TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
+ } )
+}
diff --git a/ext/tk/sample/demos-jp/plot.rb b/ext/tk/sample/demos-jp/plot.rb
new file mode 100644
index 0000000000..902b144f72
--- /dev/null
+++ b/ext/tk/sample/demos-jp/plot.rb
@@ -0,0 +1,119 @@
+#
+# 2-D plot widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($plot_demo) && $plot_demo
+ $plot_demo.destroy
+ $plot_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$plot_demo = TkToplevel.new {|w|
+ title("Plot Demonstration")
+ iconname("Plot")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($plot_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï´Êñ¤Ê2¼¡¸µ¤Î¥×¥í¥Ã¥È¤ò´Þ¤ó¤À¥­¥ã¥ó¥Ð¥¹ widget¤Ç¤¹¡£É½¼¨¤µ¤ì¤¿ÅÀ¤ò¥Þ¥¦¥¹¥Ü¥¿¥ó1¤Ç¥É¥é¥Ã¥°¤·¤Æ¥Ç¡¼¥¿¤ò¤¤¤¸¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$plot_buttons = TkFrame.new($plot_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $plot_demo
+ $plot_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'plot'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$plot_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# font ÀßÄê
+plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+
+# canvas ÀßÄê
+$plot_canvas = TkCanvas.new($plot_demo,'relief'=>'raised','width'=>450,'height'=>300)
+$plot_canvas.pack('side'=>'top', 'fill'=>'x')
+
+# plot À¸À®
+TkcLine.new($plot_canvas, 100, 250, 400, 250, 'width'=>2)
+TkcLine.new($plot_canvas, 100, 250, 100, 50, 'width'=>2)
+TkcText.new($plot_canvas, 225, 20,
+ 'text'=>"´Êñ¤Ê¥×¥í¥Ã¥È", 'font'=>plotFont, 'fill'=>'brown')
+
+(0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($plot_canvas, x, 250, x, 245, 'width'=>2)
+ TkcText.new($plot_canvas, x, 254,
+ 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n')
+}
+(0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($plot_canvas, 100, y, 105, y, 'width'=>2)
+ TkcText.new($plot_canvas, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e')
+}
+
+for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($plot_canvas, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+end
+
+$plot_canvas.itembind('point', 'Any-Enter',
+ proc{$plot_canvas.itemconfigure 'current','fill','red'})
+$plot_canvas.itembind('point', 'Any-Leave',
+ proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'})
+$plot_canvas.itembind('point', '1',
+ proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y")
+$plot_canvas.itembind('point', 'ButtonRelease-1',
+ proc{$plot_canvas.dtag 'selected'})
+$plot_canvas.bind('B1-Motion',
+ proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y")
+
+$plot = {'lastX'=>0, 'lastY'=>0}
+
+# plotDown --
+# This method is invoked when the mouse is pressed over one of the
+# data points. It sets up state to allow the point to be dragged.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse press.
+
+def plotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
+# plotMove --
+# This method is invoked during mouse motion events. It drags the
+# current item.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse.
+
+def plotMove (w, x, y)
+ w.move 'selected', x - $plot['lastX'], y - $plot['lastY']
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
diff --git a/ext/tk/sample/demos-jp/puzzle.rb b/ext/tk/sample/demos-jp/puzzle.rb
new file mode 100644
index 0000000000..ad69775aab
--- /dev/null
+++ b/ext/tk/sample/demos-jp/puzzle.rb
@@ -0,0 +1,116 @@
+#
+# widet demo 'puzzle' (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($puzzle_demo) && $puzzle_demo
+ $puzzle_demo.destroy
+ $puzzle_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$puzzle_demo = TkToplevel.new {|w|
+ title("15-Puzzle Demonstration")
+ iconname("15-Puzzle")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($puzzle_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Î15-¥Ñ¥º¥ë¤Ï¥Ü¥¿¥ó¤ò½¸¤á¤Æ¤Ç¤­¤Æ¤¤¤Þ¤¹¡£¶õ¤¤¤Æ¤¤¤ë½ê¤ÎÎ٤Υԡ¼¥¹¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥Ô¡¼¥¹¤¬¤½¤Î¶õ¤¤¤Æ¤¤¤ë¾ì½ê¤Ë¥¹¥é¥¤¥É¤·¤Þ¤¹¡£¤³¤ÎÁàºî¤ò³¤±¡¢¥Ô¡¼¥¹¤¬¤½¤Î¿ô¤Î½ç¤Ë¾å¤«¤é²¼¡¢º¸¤«¤é±¦¤Ëʤ֤褦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($puzzle_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $puzzle_demo
+ $puzzle_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'puzzle'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+#
+# Special trick: scrollbar widget ¤òÀ¸À®¤·¤Æ¤½¤Î trough color ¤òÍѤ¤¤ë¤³¤È¤Ç
+# ¶õÇòÉôʬ¤Î¤¿¤á¤Î°Å¿§¤òÁªÂò¤·¡¤ÀßÄꤹ¤ë
+#
+begin
+ if Tk.windowingsystem() == 'aqua'
+ frameSize = 160
+ else
+ frameSize = 120
+ end
+rescue
+ frameSize = 120
+end
+
+s = TkScrollbar.new($puzzle_demo)
+base = TkFrame.new($puzzle_demo) {
+ width frameSize
+ height frameSize
+ borderwidth 2
+ relief 'sunken'
+ bg s['troughcolor']
+}
+s.destroy
+base.pack('side'=>'top', 'padx'=>'1c', 'pady'=>'1c')
+
+# proc ¤Î¥¹¥³¡¼¥×¤òÊĤ¸¤ë¤¿¤á¡¤proc À¸À®¥á¥½¥Ã¥É¤òÍѰÕ
+# ¤³¤¦¤·¤Æ¤ª¤«¤Í¤Ð¡¤¥ë¡¼¥×Ãæ¤ÇÃͤ¬ÊѲ½¤¹¤ë num ¤Î±Æ¶Á¤ò¼õ¤±¤Æ
+# puzzleSwitch ¤ÎÂè 2 °ú¿ô¤¬ÊѲ½¤·¤Æ¤·¤Þ¤¤¡¤´üÂÔÄ̤ê¤Ë¤Ï¤Ê¤é¤Ê¤¤¡¥
+def def_puzzleswitch_proc(w, num)
+ proc{puzzleSwitch w, num}
+end
+
+$xpos = {}
+$ypos = {}
+order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12]
+(0..14).each{|i|
+ num = order[i]
+ $xpos[num] = (i % 4) * 0.25
+ $ypos[num] = (i / 4) * 0.25
+ TkButton.new(base) {|w|
+ relief 'raised'
+ text num
+ highlightthickness 0
+ command def_puzzleswitch_proc(w, num)
+ }.place('relx'=>$xpos[num], 'rely'=>$ypos[num],
+ 'relwidth'=>0.25, 'relheight'=>0.25)
+}
+$xpos['space'] = 0.75
+$ypos['space'] = 0.75
+
+############
+def puzzleSwitch(w, num)
+ if ( ($ypos[num] >= ($ypos['space'] - 0.01)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.01)) \
+ && ($xpos[num] >= ($xpos['space'] - 0.26)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.26))) \
+ || (($xpos[num] >= ($xpos['space'] - 0.01)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.01)) \
+ && ($ypos[num] >= ($ypos['space'] - 0.26)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.26)))
+ tmp = $xpos['space']
+ $xpos['space'] = $xpos[num]
+ $xpos[num] = tmp
+ tmp = $ypos['space']
+ $ypos['space'] = $ypos[num]
+ $ypos[num] = tmp
+ w.place('relx'=>$xpos[num], 'rely'=>$ypos[num])
+ end
+end
+
diff --git a/ext/tk/sample/demos-jp/radio.rb b/ext/tk/sample/demos-jp/radio.rb
new file mode 100644
index 0000000000..5858b4222a
--- /dev/null
+++ b/ext/tk/sample/demos-jp/radio.rb
@@ -0,0 +1,81 @@
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($radio_demo) && $radio_demo
+ $radio_demo.destroy
+ $radio_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$radio_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration")
+ iconname("radio")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($radio_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Ë¤Ï2¤Ä¤Î¥é¥¸¥ª¥Ü¥¿¥ó¥°¥ë¡¼¥×¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥Ü¥¿¥ó¤À¤±¤¬¤½¤Î¥°¥ë¡¼¥×¤ÎÃæ¤ÇÁªÂò¤µ¤ì¤Þ¤¹¡£³Æ¥°¥ë¡¼¥×¤ËÂФ·¤Æ¤½¤Î¥°¥ë¡¼¥×¤ÎÃæ¤Î¤É¤Î¥Ü¥¿¥ó¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë¤«¤ò¼¨¤¹ÊÑ¿ô¤¬³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤Þ¤¹¡£¸½ºß¤ÎÊÑ¿ô¤ÎÃͤò¸«¤ë¤Ë¤Ï¡ÖÊÑ¿ô»²¾È¡×¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£"
+}
+msg.pack('side'=>'top')
+
+# ÊÑ¿ôÀ¸À®
+size = TkVariable.new
+color = TkVariable.new
+
+# frame À¸À®
+TkFrame.new($radio_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $radio_demo
+ $radio_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'radio'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'ÊÑ¿ô»²¾È'
+ command proc{
+ showVars($radio_demo, ['size', size], ['color', color])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+f_left = TkFrame.new($radio_demo)
+f_right = TkFrame.new($radio_demo)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton À¸À®
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "¥Ý¥¤¥ó¥È¥µ¥¤¥º #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+['ÀÖ', 'ÎÐ', 'ÀÄ', '²«', 'Üô', '»ç'].each {|col|
+ TkRadioButton.new(f_right) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
diff --git a/ext/tk/sample/demos-jp/radio2.rb b/ext/tk/sample/demos-jp/radio2.rb
new file mode 100644
index 0000000000..5ac877d99a
--- /dev/null
+++ b/ext/tk/sample/demos-jp/radio2.rb
@@ -0,0 +1,107 @@
+# radio2.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio2_demo) && $radio2_demo
+ $radio2_demo.destroy
+ $radio2_demo = nil
+end
+
+# demo toplevel widget
+$radio2_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 2")
+ iconname("radio2")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($radio2_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "²¼¤Ë¤Ï3¤Ä¤Î¥é¥¸¥ª¥Ü¥¿¥ó¥°¥ë¡¼¥×¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥Ü¥¿¥ó¤À¤±¤¬¤½¤Î¥°¥ë¡¼¥×¤ÎÃæ¤ÇÁªÂò¤µ¤ì¤Þ¤¹¡£³Æ¥°¥ë¡¼¥×¤ËÂФ·¤Æ¤½¤Î¥°¥ë¡¼¥×¤ÎÃæ¤Î¤É¤Î¥Ü¥¿¥ó¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë¤«¤ò¼¨¤¹ÊÑ¿ô¤¬³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤Þ¤¹¡£¸½ºß¤ÎÊÑ¿ô¤ÎÃͤò¸«¤ë¤Ë¤Ï¡ÖÊÑ¿ô»²¾È¡×¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£"
+}
+msg.pack('side'=>'top')
+
+#
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new($radio2_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $radio2_demo
+ $radio2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'radio2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'ÊÑ¿ô»²¾È'
+ command proc{
+ showVars($radio2_demo,
+ ['size', size], ['color', color], ['compound', align])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+f_left = TkLabelFrame.new($radio2_demo, 'text'=>'ʸ»ú¥µ¥¤¥º',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new($radio2_demo, 'text'=>'¿§',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new($radio2_demo, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ',
+ 'pady'=>2, 'padx'=>2)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "¥Ý¥¤¥ó¥È¥µ¥¤¥º #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['ÀÖ', 'ÎÐ', 'ÀÄ', '²«', 'Üô', '»ç'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ lower = a.downcase
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>lower, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', abtn[0])
+Tk.grid(abtn[1], label, abtn[2])
+Tk.grid('x', abtn[3])
diff --git a/ext/tk/sample/demos-jp/radio3.rb b/ext/tk/sample/demos-jp/radio3.rb
new file mode 100644
index 0000000000..6e9a0f750b
--- /dev/null
+++ b/ext/tk/sample/demos-jp/radio3.rb
@@ -0,0 +1,114 @@
+# radio3.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio3_demo) && $radio3_demo
+ $radio3_demo.destroy
+ $radio3_demo = nil
+end
+
+# demo toplevel widget
+$radio3_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 3")
+ iconname("radio3")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($radio3_demo) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text '²¼¤Ë¤Ï3¤Ä¤Î¥é¥¸¥ª¥Ü¥¿¥ó¥°¥ë¡¼¥×¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢¤½¤Î¥°¥ë¡¼¥×¤Ë°¤¹¤ë¤¹¤Ù¤Æ¤Î¥Ü¥¿¥ó¤ÎÃæ¤Ç¥¯¥ê¥Ã¥¯¤·¤¿¥Ü¥¿¥ó¤À¤±¤¬ÁªÂò¤µ¤ì¤¿¾õÂ֤ˤʤê¤Þ¤¹¡£³Æ¥°¥ë¡¼¥×¤Ë¤Ï¡¢¤½¤Î¥°¥ë¡¼¥×¤ÎÃæ¤Î¤É¤Î¥Ü¥¿¥ó¤¬ÁªÂò¤µ¤ì¤Æ¤¤¤ë¤«¤ò¼¨¤¹ÊÑ¿ô¤¬³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤Þ¤¹¡£¡Ö¥È¥é¥¤¥¹¥Æ¡¼¥È¡×¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤È¤­¤Ë¤Ï¡¢¥é¥¸¥ª¥Ü¥¿¥ó¤Îɽ¼¨¤¬¥È¥é¥¤¥¹¥Æ¡¼¥È¥â¡¼¥É¤Ë¤Ê¤ê¤Þ¤¹¡£¤¤¤º¤ì¤«¤Î¥Ü¥¿¥ó¤òÁªÂò¤¹¤ì¤Ð¡¢¥Ü¥¿¥ó¤Î¾õÂ֤ϸµ¤Î¤è¤¦¤Ë¸Ä¡¹¤Î¥Ü¥¿¥ó¤Îon/off¾õÂÖ¤ò¼¨¤¹¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£¸½ºß¤ÎÊÑ¿ô¤ÎÃͤò¸«¤ë¤Ë¤Ï¡ÖÊÑ¿ô»²¾È¡×¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£'
+}
+msg.grid(:row=>0, :column=>0, :columnspan=>3, :sticky=>'nsew')
+
+# variable
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new($radio3_demo) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'ÊÑ¿ô»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars($radio3_demo, ['size', size],
+ ['color', color], ['compound', align])
+ }),
+ TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'radio3'}),
+ TkButton.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $radio3_demo
+ $radio3_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew')
+}
+
+# frame
+f_left = TkLabelFrame.new($radio3_demo, 'text'=>'ʸ»ú¥µ¥¤¥º',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new($radio3_demo, 'text'=>'¿§',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new($radio3_demo, 'text'=>'¥Ó¥Ã¥È¥Þ¥Ã¥×ÇÛÃÖ',
+ 'pady'=>2, 'padx'=>2)
+f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkButton.new($radio3_demo, 'text'=>'¥È¥é¥¤¥¹¥Æ¡¼¥È',
+ 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){
+ grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c')
+}
+
+# radiobutton
+[10, 12, 14, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "¥Ý¥¤¥ó¥È¥µ¥¤¥º #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ tristatevalue 'multi'
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ tristatevalue 'multi'
+ command proc{f_mid.fg(color.value)}
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+label = TkLabel.new(f_right, 'text'=>'¥é¥Ù¥ë', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', a_btn[0])
+Tk.grid(a_btn[1], label, a_btn[2])
+Tk.grid('x', a_btn[3])
diff --git a/ext/tk/sample/demos-jp/rmt b/ext/tk/sample/demos-jp/rmt
new file mode 100644
index 0000000000..73f631180a
--- /dev/null
+++ b/ext/tk/sample/demos-jp/rmt
@@ -0,0 +1,268 @@
+#!/usr/bin/env ruby
+
+# rmt --
+# This script implements a simple remote-control mechanism for
+# Tk applications. It allows you to select an application and
+# then type commands to that application.
+
+require 'tk'
+
+class Rmt
+ def initialize(parent=nil)
+ win = self
+
+ unless parent
+ parent = TkRoot.new
+ end
+ root = TkWinfo.toplevel(parent)
+ root.minsize(1,1)
+
+ # The instance variable below keeps track of the remote application
+ # that we're sending to. If it's an empty string then we execute
+ # the commands locally.
+ @app = 'local'
+ @mode = 'Ruby'
+
+ # The instance variable below keeps track of whether we're in the
+ # middle of executing a command entered via the text.
+ @executing = 0
+
+ # The instance variable below keeps track of the last command executed,
+ # so it can be re-executed in response to !! commands.
+ @lastCommand = ""
+
+ # Create menu bar. Arrange to recreate all the information in the
+ # applications sub-menu whenever it is cascaded to.
+
+ TkFrame.new(root, 'relief'=>'raised', 'bd'=>2) {|f|
+ pack('side'=>'top', 'fill'=>'x')
+ TkMenubutton.new(f, 'text'=>'File', 'underline'=>0) {|mb|
+ TkMenu.new(mb) {|mf|
+ mb.menu(mf)
+ TkMenu.new(mf) {|ma|
+ postcommand proc{win.fillAppsMenu ma}
+ mf.add('cascade', 'label'=>'Select Application',
+ 'menu'=>ma, 'underline'=>0)
+ }
+ add('command', 'label'=>'Quit',
+ 'command'=>proc{root.destroy}, 'underline'=>0)
+ }
+ pack('side'=>'left')
+ }
+ }
+
+ # Create text window and scrollbar.
+
+ @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {
+ yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')})
+ pack('side'=>'left')
+ }
+
+ @promptEnd = TkTextMark.new(@txt, 'insert')
+
+ # Create a binding to forward commands to the target application,
+ # plus modify many of the built-in bindings so that only information
+ # in the current command can be deleted (can still set the cursor
+ # earlier in the text and select and insert; just can't delete).
+
+ @txt.bindtags([@txt, TkText, root, 'all'])
+ @txt.bind('Return', proc{
+ @txt.set_insert('end - 1c')
+ @txt.insert('insert', "\n")
+ win.invoke
+ Tk.callback_break
+ })
+ @txt.bind('Delete', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('BackSpace', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('Control-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-k', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ @txt.set_insert(@promptEnd)
+ end
+ })
+ @txt.bind('Control-t', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-BackSpace', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-h', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+
+ @txt.tag_configure('bold', 'font'=>['Courier', 12, 'bold'])
+
+ @app = Tk.appname('rmt')
+ if (@app =~ /^rmt(.*)$/)
+ root.title("Tk Remote Controller#{$1}")
+ root.iconname("Tk Remote#{$1}")
+ end
+ prompt
+ @txt.focus
+ #@app = TkWinfo.appname(TkRoot.new)
+ end
+
+ def tkTextInsert(w,s)
+ return if s == ""
+ begin
+ if w.compare('sel.first','<=','insert') \
+ && w.compare('sel.last','>=','insert')
+ w.tag_remove('sel', 'sel.first', @promptEnd)
+ w.delete('sel.first', 'sel.last')
+ end
+ rescue
+ end
+ w.insert('insert', s)
+ w.see('insert')
+ end
+
+ # The method below is used to print out a prompt at the
+ # insertion point (which should be at the beginning of a line
+ # right now).
+
+ def prompt
+ @txt.insert('insert', "#{@app}: ")
+ @promptEnd.set('insert')
+ @promptEnd.gravity = 'left'
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ end
+
+ # The method below executes a command (it takes everything on the
+ # current line after the prompt and either sends it to the remote
+ # application or executes it locally, depending on "app".
+
+ def invoke
+ cmd = @txt.get(@promptEnd, 'insert')
+ @executing += 1
+ case (@mode)
+ when 'Tcl'
+ if Tk.info('complete', cmd)
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ else
+ @lastCommand = cmd
+ end
+ begin
+ msg = Tk.appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+
+ when 'Ruby'
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ end
+ complete = true
+ begin
+ eval("proc{#{cmd}}")
+ rescue
+ complete = false
+ end
+ if complete
+ @lastCommand = cmd
+ begin
+# msg = Tk.appsend(@app, false,
+# 'ruby',
+# '"(' + cmd.gsub(/[][$"]/, '\\\\\&') + ').to_s"')
+ msg = Tk.rb_appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+ end
+
+ @executing -= 1
+ @txt.yview_pickplace('insert')
+ end
+
+ # The following method is invoked to change the application that
+ # we're talking to. It also updates the prompt for the current
+ # command, unless we're in the middle of executing a command from
+ # the text item (in which case a new prompt is about to be output
+ # so there's no need to change the old one).
+
+ def newApp(appName, mode)
+ @app = appName
+ @mode = mode
+ if @executing == 0
+ @promptEnd.gravity = 'right'
+ @txt.delete("#{@promptEnd.path} linestart", @promptEnd)
+ @txt.insert(@promptEnd, "#{appName}: ")
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ @promptEnd.gravity = 'left'
+ end
+ end
+
+ # The method below will fill in the applications sub-menu with a list
+ # of all the applications that currently exist.
+
+ def fillAppsMenu(menu)
+ win = self
+ begin
+ menu.delete(0,'last')
+ rescue
+ end
+ TkWinfo.interps.sort.each{|ip|
+ begin
+ if Tk.appsend(ip, false, 'info commands ruby') == ""
+ mode = 'Tcl'
+ else
+ mode = 'Ruby'
+ end
+ menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode})
+ rescue
+ menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled')
+ end
+ }
+ menu.add('command', 'label'=>format("local (Ruby/Tk)"),
+ 'command'=>proc{win.newApp 'local', 'Ruby'})
+ end
+end
+
+Rmt.new
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/rolodex b/ext/tk/sample/demos-jp/rolodex
new file mode 100644
index 0000000000..9f87ae2829
--- /dev/null
+++ b/ext/tk/sample/demos-jp/rolodex
@@ -0,0 +1,320 @@
+#!/usr/bin/env ruby
+#
+# rolodex --
+# This script is a part of Tom LaStrange's rolodex
+#
+# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
+# Time-stamp: "03/08/02 12:45:21 nagai"
+#
+
+require "tk"
+
+
+def show_help(topic,x=0,y=0)
+ if( topic.is_a?(TkWindow) )
+ w = TkWinfo.containing(x,y)
+ if( TkWinfo.exist?(w) )
+ topic = w
+ end
+ end
+
+ if( $helpTopics.include?(topic) )
+ msg = $helpTopics[topic]
+ else
+ msg = "Sorry, but no help is available for this topic"
+ end
+ TkDialog.new("title"=>"Rolodex Help",
+ "message"=>"Information on #{topic}:\n\n#{msg}",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+end
+
+def fillCard
+ clearAction
+ $root.frame.entry[1].insert(0,"Takaaki Tateishi")
+ $root.frame.entry[2].insert(0,"Japan Advanced Institute of Science and Techonology")
+ $root.frame.entry[3].insert(0,"1-1 Asahidai, Tatsunokuchi")
+ $root.frame.entry[4].insert(0,"Ishikawa 923-1292, Japan")
+ $root.frame.entry[5].insert(0,"private")
+ $root.frame.entry[6].insert(0,"***-***-****")
+ $root.frame.entry[7].insert(0,"***-***-****")
+end
+
+def addAction
+ for i in 1..7
+ STDERR.print format("%-12s %s\n",
+ RolodexFrame::LABEL[i],
+ $root.frame.entry[i].value)
+ end
+end
+
+def clearAction
+ for i in 1..7
+ $root.frame.entry[i].delete(0,"end")
+ end
+end
+
+def fileAction
+ TkDialog.new("title"=>"File Selection",
+ "message"=>"This is a dummy file selection dialog box.\n",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+ STDERR.print "dummy file name\n"
+end
+
+def deleteAction
+ result = TkDialog.new("title"=>"Confirm Action",
+ "message"=>"Are you sure?",
+ "default_button"=>0,
+ "buttons"=>["Cancel"])
+ if( result.value == 0 )
+ clearAction
+ end
+end
+
+
+class RolodexFrame < TkFrame
+ attr_reader :entry, :label
+
+ LABEL = ["","Name:","Address:","","","Home Phone:","Work Phone:","Fax:"]
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ self["relief"] = "flat"
+
+ @i = []
+ @label = []
+ @entry = []
+ for i in 1..7
+ @i[i] = TkFrame.new(self)
+ @i[i].pack("side"=>"top",
+ "pady"=>2,
+ "anchor"=>"e")
+ @label[i] = TkLabel.new(@i[i],
+ "text"=>LABEL[i],
+ "anchor"=>"e")
+ @entry[i] = TkEntry.new(@i[i],
+ "width"=>30,
+ "relief"=>"sunken")
+ @entry[i].pack("side"=>"right")
+ @label[i].pack("side"=>"right")
+ end
+ end
+end
+
+class RolodexButtons < TkFrame
+ attr_reader :clear, :add, :search, :delete
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ @clear = TkButton.new(self,
+ "text" => "Clear")
+ @add = TkButton.new(self,
+ "text" => "Add")
+ @search = TkButton.new(self,
+ "text" => "Search")
+ @delete = TkButton.new(self,
+ "text" => "Delete")
+ for w in [@clear,@add,@search,@delete]
+ w.pack("side"=>"left", "padx"=>2)
+ end
+ end
+end
+
+class RolodexMenuFrame < TkFrame
+ attr_reader :file_menu, :help_menu, :file, :help
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ configure("relief"=>"raised",
+ "borderwidth"=>1)
+
+ @file = TkMenubutton.new(self,
+ "text"=>"File",
+ "underline"=>0)
+ @file_menu = TkMenu.new(@file)
+ @file_menu.add("command",
+ "label" => "Load ...",
+ "command" => proc{fileAction},
+ "underline" => 0)
+ @file_menu.add("command",
+ "label" => "Exit",
+ "command" => proc{$root.destroy},
+ "underline" => 0)
+ @file.menu(@file_menu)
+ @file.pack("side"=>"left")
+
+ @help = TkMenubutton.new(self,
+ "text"=>"Help",
+ "underline"=>0)
+ @help_menu = TkMenu.new(@help)
+ @help_menu.add("command",
+ "label"=>"On Context...",
+ "command"=>proc{show_help("context")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Help...",
+ "command"=>proc{show_help("help")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Window...",
+ "command"=>proc{show_help("window")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Keys...",
+ "command"=>proc{show_help("keys")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On version...",
+ "command"=>proc{show_help("version")},
+ "underline"=>3)
+ @help.menu(@help_menu)
+ @help.pack("side"=>"right")
+ end
+end
+
+class Rolodex < TkRoot
+ attr_reader :frame, :buttons, :menu
+
+ def initialize(*args)
+ super(*args)
+ @frame = RolodexFrame.new(self)
+ @frame.pack("side"=>"top",
+ "fill"=>"y",
+ "anchor"=>"center")
+ @buttons = RolodexButtons.new(self)
+ @buttons.pack("side"=>"bottom",
+ "pady"=>2,
+ "anchor"=>"center")
+ @menu = RolodexMenuFrame.new(self)
+ @menu.pack("before"=>@frame,
+ "side"=>"top",
+ "fill"=>"x")
+ end
+end
+
+$root = Rolodex.new
+
+$root.buttons.delete.configure("command"=>proc{deleteAction})
+$root.buttons.add.configure("command"=>proc{addAction})
+$root.buttons.clear.configure("command"=>proc{clearAction})
+$root.buttons.search.configure("command"=>proc{addAction; fillCard})
+
+$root.buttons.clear.configure("text"=>"Clear Ctrl+C")
+$root.bind("Control-c",proc{clearAction})
+
+$root.buttons.add.configure("text"=>"Add Ctrl+A")
+$root.bind("Control-a",proc{addAction})
+
+$root.buttons.search.configure("text"=>"Search Ctrl+S")
+$root.bind("Control-s",proc{addAction; fillCard})
+
+$root.buttons.delete.configure("text"=>"Delete... Ctrl+D")
+$root.bind("Control-d",proc{deleteAction})
+
+$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
+$root.bind("Control-f",proc{fileAction})
+
+$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
+$root.bind("Control-q",proc{$root.destroy})
+
+$root.frame.entry[1].focus
+
+$root.bind("Any-F1",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+$root.bind("Any-Help",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+
+
+$helpTopics = {}
+
+$helpTopics[$root.menu.file] = <<EOF
+This is the "file" menu. It can be used to invoke\
+some overall operations on the rolodex applications,\
+such as loading a file or exiting.
+EOF
+
+$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
+The "Load" entry in the "File" menu posts a dialog box\
+that you can use to select a rolodex file
+EOF
+
+$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
+The "Exit" entry in the "File" menu causes the rolodex\
+application to terminate
+EOF
+
+$helpTopics[$root.frame.entry[1]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's name
+EOF
+
+$helpTopics[$root.frame.entry[2]] = <<EOF
+In this field of the rolodex entry you should\
+type the first line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[3]] = <<EOF
+In this field of the rolodex entry you should\
+type the second line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[4]] = <<EOF
+In this field of the rolodex entry you should\
+type the third line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[5]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's home phone number, or "private"\
+if the person doesn't want his or he number publicized
+EOF
+
+$helpTopics[$root.frame.entry[6]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's work phone number
+EOF
+
+$helpTopics[$root.frame.entry[7]] = <<EOF
+In this field of the rolodex entry you should\
+type the phone number for the person's FAX machine
+EOF
+
+$helpTopics["context"] = <<EOF
+Unfortunately, this application doesn't support context-sensitive\
+help in the usual way, because when this demo was written Ruby/Tk\
+didn't have a grab mechanism and this is needed for context-sensitive\
+help. Instead, you can achive much the same effect by simply moving\
+the mouse over the window you're curious about and pressing the\
+Help or F1 keys. You can do this anytime.
+EOF
+
+$helpTopics["help"] = <<EOF
+This application provides only very crude help. Besides the\
+entries in this menu, you can get help on individual windows\
+by moving the mouse cursor over the window and pressing the\
+Help or F1 keys.
+EOF
+
+$helpTopics["window"] = <<EOF
+This window is a dummy rolodex application created as part of\
+Tom LaStrange's toolkit benchmark. It doesn't really do anything\
+useful except to demonstrate a few features of the Ruby/Tk.
+EOF
+
+$helpTopics["keys"] = <<EOF
+The following accelerator keys are defined for this application\
+(in addition to those already available for the entry windows):
+Ctrl+A: Add
+Ctrl+C: Clear
+Ctrl+D: Delete
+Ctrl+F: Enter file name
+Ctrl+Q: Exit application (quit)
+Ctrl+S: Search (dummy operation)
+EOF
+
+$helpTopics["version"] = <<EOF
+This is version 1.0.1.
+EOF
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/rolodex-j b/ext/tk/sample/demos-jp/rolodex-j
new file mode 100644
index 0000000000..dcc18cfa51
--- /dev/null
+++ b/ext/tk/sample/demos-jp/rolodex-j
@@ -0,0 +1,299 @@
+#!/usr/bin/env ruby
+#
+# rolodex --
+# ¤³¤Î¥¹¥¯¥ê¥×¥È¤Ï Tom LaStrange ¤Î rolodex ¤Î°ìÉô¤Ç¤¹¡£
+#
+# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
+# Time-stamp: "04/04/09 00:32:12 nagai"
+#
+
+require "tk"
+Tk.encoding = "euc-jp"
+
+def show_help(topic,x=0,y=0)
+ if( topic.is_a?(TkWindow) )
+ w = TkWinfo.containing(x,y)
+ if( w.is_a?(TkWindow) )
+ if( TkWinfo.exist?(w) )
+ topic = w
+ end
+ end
+ end
+
+ if( $helpTopics.include?(topic) )
+ msg = $helpTopics[topic]
+ else
+ msg = "¤³¤Î¥È¥Ô¥Ã¥¯¤Ë¤Ä¤¤¤Æ¤Î¥Ø¥ë¥×¤Ï¤Þ¤À»ÈÍѤǤ­¤Þ¤»¤ó"
+ end
+ TkDialog.new("title"=>"Rolodex Help",
+ "message"=>"¡Ö#{topic}¡×\n\n#{msg}",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+end
+
+def fillCard
+ clearAction
+ $root.frame.entry[1].insert(0, "ΩÀÐ ¹§¾´")
+ $root.frame.entry[2].insert(0, "923-1292 ÀÐÀ")
+ $root.frame.entry[3].insert(0, "ä¸ýÄ® °°Âæ 1-1")
+ $root.frame.entry[4].insert(0, "ËÌΦÀèü²Ê³Øµ»½ÑÂç³Ø±¡Âç³Ø")
+ $root.frame.entry[5].insert(0,"private")
+ $root.frame.entry[6].insert(0,"***-***-****")
+ $root.frame.entry[7].insert(0,"***-***-****")
+end
+
+def addAction
+ for i in 1..7
+ STDERR.print format("%-12s %s\n",
+ RolodexFrame::LABEL[i],
+ $root.frame.entry[i].value)
+ end
+end
+
+def clearAction
+ for i in 1..7
+ $root.frame.entry[i].delete(0,"end")
+ end
+end
+
+def fileAction
+ TkDialog.new("title"=>"File Selection",
+ "message"=>"¤³¤ì¤Ï¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°¤Î¥À¥ß¡¼¤Ç¤¹¡£\n",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+ STDERR.print "dummy file name\n"
+end
+
+def deleteAction
+ result = TkDialog.new("title"=>"Confirm Action",
+ "message"=>"¤è¤í¤·¤¤¤Ç¤¹¤«¡©",
+ "default_button"=>0,
+ "buttons"=>["¥­¥ã¥ó¥»¥ë"])
+ if( result.value == 0 )
+ clearAction
+ end
+end
+
+
+class RolodexFrame < TkFrame
+ attr_reader :entry, :label
+
+ LABEL = ["","̾Á°:","½»½ê","","","ÅÅÏÃ(¼«Âð):","ÅÅÏÃ(²ñ¼Ò):","Fax:"]
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ self["relief"] = "flat"
+ @i = []
+ @label = []
+ @entry = []
+ for i in 1..7
+ @i[i] = TkFrame.new(self)
+ @i[i].pack("side"=>"top",
+ "pady"=>2,
+ "anchor"=>"e")
+ @label[i] = TkLabel.new(@i[i],
+ "text"=>LABEL[i],
+ "anchor"=>"e")
+ @entry[i] = TkEntry.new(@i[i],
+ "width"=>30,
+ "relief"=>"sunken")
+ @entry[i].pack("side"=>"right")
+ @label[i].pack("side"=>"right")
+ end
+ end
+end
+
+class RolodexButtons < TkFrame
+ attr_reader :clear, :add, :search, :delete
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ @clear = TkButton.new(self,"text" => "¥¯¥ê¥¢¡¼")
+ @add = TkButton.new(self, "text" => "ÄɲÃ")
+ @search = TkButton.new(self, "text" => "¸¡º÷")
+ @delete = TkButton.new(self, "text" => "¾Ãµî")
+ for w in [@clear,@add,@search,@delete]
+ w.pack("side"=>"left", "padx"=>2)
+ end
+ end
+end
+
+class RolodexMenuFrame < TkFrame
+ attr_reader :file_menu, :help_menu, :file, :help
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ configure("relief"=>"raised",
+ "borderwidth"=>1)
+
+ @file = TkMenubutton.new(self,
+ "text"=> "¥Õ¥¡¥¤¥ë",
+ "underline"=>0)
+ @file_menu = TkMenu.new(@file)
+ @file_menu.add("command",
+ "label" => "ÆÉ¤ß¹þ¤ß ...",
+ "command" => proc{fileAction},
+ "underline" => 0)
+ @file_menu.add("command",
+ "label" => "½ªÎ»",
+ "command" => proc{$root.destroy},
+ "underline" => 0)
+ @file.menu(@file_menu)
+ @file.pack("side"=>"left")
+
+ @help = TkMenubutton.new(self,
+ "text"=> "¥Ø¥ë¥×",
+ "underline"=>0)
+ @help_menu = TkMenu.new(@help)
+ @help_menu.add("command",
+ "label"=> "¥³¥ó¥Æ¥­¥¹¥È¤Ë¤Ä¤¤¤Æ",
+ "command"=>proc{show_help("¥³¥ó¥Æ¥­¥¹¥È")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥Ø¥ë¥×¤Ë¤Ä¤¤¤Æ",
+ "command"=>proc{show_help("¥Ø¥ë¥×")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥¦¥£¥ó¥É¥¦¤Ë¤Ä¤¤¤Æ",
+ "command"=>proc{show_help("¥¦¥£¥ó¥É¥¦")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥­¡¼Áàºî¤Ë¤Ä¤¤¤Æ",
+ "command"=>proc{show_help("¥­¡¼Áàºî")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "¥Ð¡¼¥¸¥ç¥ó¾ðÊó",
+ "command"=>proc{show_help("¥Ð¡¼¥¸¥ç¥ó¾ðÊó")},
+ "underline"=>3)
+ @help.menu(@help_menu)
+ @help.pack("side"=>"right")
+ end
+end
+
+class Rolodex < TkRoot
+ attr_reader :frame, :buttons, :menu
+
+ def initialize(*args)
+ super(*args)
+ @frame = RolodexFrame.new(self)
+ @frame.pack("side"=>"top",
+ "fill"=>"y",
+ "anchor"=>"center")
+ @buttons = RolodexButtons.new(self)
+ @buttons.pack("side"=>"bottom",
+ "pady"=>2,
+ "anchor"=>"center")
+ @menu = RolodexMenuFrame.new(self)
+ @menu.pack("before"=>@frame,
+ "side"=>"top",
+ "fill"=>"x")
+ end
+end
+
+$root = Rolodex.new
+
+$root.buttons.delete.configure("command"=>proc{deleteAction})
+$root.buttons.add.configure("command"=>proc{addAction})
+$root.buttons.clear.configure("command"=>proc{clearAction})
+$root.buttons.search.configure("command"=>proc{addAction; fillCard})
+
+$root.buttons.clear.configure("text"=> "¥¯¥ê¥¢¡¼ Ctrl+C")
+$root.bind("Control-c",proc{clearAction})
+
+$root.buttons.add.configure("text"=> "Äɲà Ctrl+A")
+$root.bind("Control-a",proc{addAction})
+
+$root.buttons.search.configure("text"=> "¸¡º÷ Ctrl+S")
+$root.bind("Control-s",proc{addAction; fillCard})
+
+$root.buttons.delete.configure("text"=> "¾Ãµî Ctrl+D")
+$root.bind("Control-d",proc{deleteAction})
+
+$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
+$root.bind("Control-f",proc{fileAction})
+
+$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
+$root.bind("Control-q",proc{$root.destroy})
+
+$root.frame.entry[1].focus
+
+$root.bind("Any-F1",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+$root.bind("Any-Help",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+
+
+$helpTopics = {}
+
+$helpTopics[$root.menu.file] = <<EOF
+¤³¤ì¤Ï¡Ö¥Õ¥¡¥¤¥ë¡×¥á¥Ë¥å¡¼¤Ç¤¹¡£¡ÖÆÉ¤ß¹þ¤ß¡×¤ä¡Ö½ªÎ»¡×¤Ê¤É¤ò
+¹Ô¤Ê¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
+¥Õ¥¡¥¤¥ë¤ÎÆÉ¤ß¹þ¤ß¤ò¹Ô¤Ê¤¦¤È¤­¤Ë»È¤¤¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
+¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë¤È¤­¤Ë»È¤¤¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[1]] = <<EOF
+̾Á°¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[2]] = <<EOF
+½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[3]] = <<EOF
+½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[4]] = <<EOF
+½»½ê¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[5]] = <<EOF
+¼«Âð¤ÎÅÅÏÃÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£¸ø³«\
+¤·¤¿¤¯¤Ê¤¤¤È¤­¤Ï private ¤Èµ­Æþ¤·¤Þ¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[6]] = <<EOF
+²ñ¼Ò¤ÎÅÅÏÃÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics[$root.frame.entry[7]] = <<EOF
+FAXÈÖ¹æ¤òµ­Æþ¤¹¤ë¥¨¥ó¥È¥ê¤Ç¤¹¡£
+EOF
+
+$helpTopics["¥³¥ó¥Æ¥­¥¹¥È"] = <<EOF
+Ruby/Tk¤Ç¤Ïgrab¤Îµ¡¹½¤¬¤Ê¤¤¤¿¤á¤³¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï\
+¥³¥ó¥Æ¥­¥¹¥È¥Ø¥ë¥×¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£
+¤·¤«¤·Æ±¤¸¤è¤¦¤Ê¸ú²Ì¤òbind¤È¥Þ¥¦¥¹¤Î°ÌÃÖ¤ÎWedget¤òÃΤë\
+¤³¤È¤ÇÆÀ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+EOF
+
+$helpTopics["¥Ø¥ë¥×"] = <<EOF
+¥Þ¥¦¥¹¤ò¥¦¥£¥ó¥É¥¦¤Ë¤¢¤ï¤»¤ÆF1¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ\
+¤½¤Î¥Ø¥ë¥×¤ò¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+EOF
+
+$helpTopics["¥¦¥£¥ó¥É¥¦"] = <<EOF
+¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï¥À¥ß¡¼¤Ç¤¹¡£
+EOF
+
+$helpTopics["¥­¡¼Áàºî"] = <<EOF
+Ctrl+A: ÄɲÃ
+Ctrl+C: ¥¯¥ê¥¢¡¼
+Ctrl+D: ¾Ãµî
+Ctrl+F: ¥Õ¥¡¥¤¥ëÁªÂò
+Ctrl+Q: ½ªÎ»
+Ctrl+S: ¸¡º÷
+EOF
+
+$helpTopics["¥Ð¡¼¥¸¥ç¥ó¾ðÊó"] = <<EOF
+¥Ð¡¼¥¸¥ç¥ó¤Ï 1.0.1j ¤Ç¤¹¡£
+EOF
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/ruler.rb b/ext/tk/sample/demos-jp/ruler.rb
new file mode 100644
index 0000000000..94b4c921d3
--- /dev/null
+++ b/ext/tk/sample/demos-jp/ruler.rb
@@ -0,0 +1,200 @@
+#
+# ruler widget demo (called by 'widget')
+#
+
+# rulerMkTab --
+# This method creates a new triangular polygon in a canvas to
+# represent a tab stop.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - Coordinates at which to create the tab stop.
+
+def rulerMkTab(c,x,y)
+ v = $demo_rulerInfo
+ TkcPolygon.new(c, x, y, x+v.size, y+v.size, x-v.size, y+v.size)
+end
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($ruler_demo) && $ruler_demo
+ $ruler_demo.destroy
+ $ruler_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$ruler_demo = TkToplevel.new {|w|
+ title("Ruler Demonstration")
+ iconname("ruler")
+ positionWindow(w)
+}
+
+# label À¸À®
+TkLabel.new($ruler_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"¤³¤Î¥­¥ã¥ó¥Ð¥¹widget¤Ï¥ë¡¼¥é¡¼¤ÎÌÏ·¿¤Ç¤¹¡£¥ë¡¼¥é¡¼¤Î±¦¤Ë¤¢¤ë¤Î¤Ï¥¿¥Ö¥¹¥È¥Ã¥×¤Î°æ¸Í¤Ç¡¢¤³¤³¤«¤é°ú¤ÃÄ¥¤Ã¤Æ¤¯¤ë¤³¤È¤Ë¤è¤Ã¤Æ¥¿¥Ö¥¹¥È¥Ã¥×¤òºî¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤Þ¤¿¡¢¤¹¤Ç¤Ë¤¢¤ë¥¿¥Ö¥¹¥È¥Ã¥×¤òư¤«¤¹¤³¤È¤â¤Ç¤­¤Þ¤¹¡£¥¿¥Ö¥¹¥È¥Ã¥×¤ò¾åÊý¤Þ¤¿¤Ï²¼Êý¤Ë¤«¤¹¤ì¤ÆÉ½¼¨¤µ¤ì¤ë¤Þ¤Ç¥É¥é¥Ã¥°¤¹¤ë¤È¡¢¥Þ¥¦¥¹¥Ü¥¿¥ó¤òÎ¥¤·¤¿»þ¤Ë¤½¤Î¥¿¥Ö¥¹¥È¥Ã¥×¤Ï¾Ã¤¨¤Þ¤¹¡£"){
+ pack('side'=>'top')
+}
+
+# frame À¸À®
+$ruler_buttons = TkFrame.new($ruler_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $ruler_demo
+ $ruler_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'ruler'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas ÀßÄê
+$ruler_canvas = TkCanvas.new($ruler_demo, 'width'=>'14.8c', 'height'=>'2.5c')
+$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
+
+# ÃÍÀßÄê
+unless Struct.const_defined?("RulerInfo")
+ $demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y,
+ :top, :bottom, :size, :normalStyle,
+ :activeStyle, :deleteStyle).new
+end
+$demo_rulerInfo.grid = '.25c'
+$demo_rulerInfo.left = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.right = TkWinfo.fpixels($ruler_canvas, '13c')
+$demo_rulerInfo.top = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.bottom = TkWinfo.fpixels($ruler_canvas, '1.5c')
+$demo_rulerInfo.size = TkWinfo.fpixels($ruler_canvas, '.2c')
+$demo_rulerInfo.normalStyle = {'fill'=>'black'}
+if TkWinfo.depth($ruler_canvas) > 1
+ $demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'red',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+else
+ $demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+end
+
+TkcLine.new($ruler_canvas,
+ '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1)
+(0..11).each{|i|
+ x = i+1
+ TkcLine.new($ruler_canvas, "#{x}c", '1c', "#{x}c", '0.6c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.25c", '1c', "#{x}.25c", '0.8c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.5c", '1c', "#{x}.5c", '0.7c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.75c", '1c', "#{x}.75c", '0.8c', 'width'=>1)
+ TkcText.new($ruler_canvas, "#{x}.15c", '0.75c', 'text'=>i, 'anchor'=>'sw')
+}
+
+$rulerTag_well = TkcTag.new($ruler_canvas)
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ TkcRectangle.new($ruler_canvas,
+ '13.2c', '1c', '13.8c', '0.5c',
+ 'outline'=>'black',
+ 'fill'=>($ruler_canvas\
+ .configinfo('background'))[4]) )
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ rulerMkTab($ruler_canvas,
+ TkWinfo.pixels($ruler_canvas, '13.5c'),
+ TkWinfo.pixels($ruler_canvas, '.65c') ) )
+
+$rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.itembind('tab', '1',
+ proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('B1-Motion',
+ proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)})
+
+# rulerNewTab --
+# Does all the work of creating a tab stop, including creating the
+# triangle object and adding tags to it to give it tab behavior.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - The coordinates of the tab stop.
+
+def rulerNewTab(c,x,y)
+ v = $demo_rulerInfo
+ c.addtag_withtag('active', rulerMkTab(c,x,y))
+ c.addtag_withtag('tab', 'active')
+ v.x = x
+ v.y = y
+ rulerMoveTab(c,x,y)
+end
+
+# rulerSelectTab --
+# This method is invoked when mouse button 1 is pressed over
+# a tab. It remembers information about the tab so that it can
+# be dragged interactively.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse (identifies the point by
+# which the tab was picked up for dragging).
+
+def rulerSelectTab(c,x,y)
+ v = $demo_rulerInfo
+ v.x = c.canvasx(x, v.grid)
+ v.y = v.top+2
+ c.addtag_withtag('active', 'current')
+ c.itemconfigure('active', v.activeStyle)
+ c.raise('active')
+end
+
+# rulerMoveTab --
+# This method is invoked during mouse motion events to drag a tab.
+# It adjusts the position of the tab, and changes its appearance if
+# it is about to be dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerMoveTab(c,x,y)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ cx = c.canvasx(x,v.grid)
+ cy = c.canvasy(y)
+ cx = v.left if cx < v.left
+ cx = v.right if cx > v.right
+ if (cy >= v.top && cy <= v.bottom)
+ cy = v.top+2
+ c.itemconfigure('active', v.activeStyle)
+ else
+ cy = cy-v.size-2
+ c.itemconfigure('active', v.deleteStyle)
+ end
+ c.move('active', cx-v.x, cy-v.y)
+ v.x = cx
+ v.y = cy
+end
+
+# rulerReleaseTab --
+# This method is invoked during button release events that end
+# a tab drag operation. It deselects the tab and deletes the tab if
+# it was dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerReleaseTab(c)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ if v.y != v.top+2
+ c.delete('active')
+ else
+ c.itemconfigure('active', v.normalStyle)
+ c.dtag('active')
+ end
+end
+
diff --git a/ext/tk/sample/demos-jp/sayings.rb b/ext/tk/sample/demos-jp/sayings.rb
new file mode 100644
index 0000000000..ce195a0e53
--- /dev/null
+++ b/ext/tk/sample/demos-jp/sayings.rb
@@ -0,0 +1,100 @@
+#
+# listbox widget demo 'sayings' (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($sayings_demo) && $sayings_demo
+ $sayings_demo.destroy
+ $sayings_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$sayings_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (well-known sayings)")
+ iconname("sayings")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($sayings_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Î¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤Ë¤Ï¤¤¤í¤¤¤í¤Ê³Ê¸À¤¬Æþ¤Ã¤Æ¤¤¤Þ¤¹¡£¥ê¥¹¥È¤ò¥¹¥¯¥í¡¼¥ë¤µ¤»¤ë¤Î¤Ï¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤Ç¤â¤Ç¤­¤Þ¤¹¤·¡¢¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤ÎÃæ¤Ç¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2(Ãæ¥Ü¥¿¥ó)¤ò²¡¤·¤¿¤Þ¤Þ¥É¥é¥Ã¥°¤·¤Æ¤â¤Ç¤­¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($sayings_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $sayings_demo
+ $sayings_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'sayings'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+sayings_lbox = nil
+TkFrame.new($sayings_demo, 'borderwidth'=>10) {|w|
+ sv = TkScrollbar.new(w)
+ sh = TkScrollbar.new(w, 'orient'=>'horizontal')
+ sayings_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| sv.set first,last}
+ xscrollcommand proc{|first,last| sh.set first,last}
+ }
+ sv.command(proc{|*args| sayings_lbox.yview(*args)})
+ sh.command(proc{|*args| sayings_lbox.xview(*args)})
+
+ if $tk_version =~ /^4\.[01]/
+ sv.pack('side'=>'right', 'fill'=>'y')
+ sh.pack('side'=>'bottom', 'fill'=>'x')
+ sayings_lbox.pack('expand'=>'yes', 'fill'=>'y')
+
+ else
+ sayings_lbox.grid('row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sv.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sh.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ end
+
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+sayings_lbox.insert(0,
+"Waste not, want not",
+"Early to bed and early to rise makes a man healthy, wealthy, and wise",
+"Ask not what your country can do for you, ask what you can do for your country",
+"I shall return",
+"NOT",
+"A picture is worth a thousand words",
+"User interfaces are hard to build",
+"Thou shalt not steal",
+"A penny for your thoughts",
+"Fool me once, shame on you; fool me twice, shame on me",
+"Every cloud has a silver lining",
+"Where there's smoke there's fire",
+"It takes one to know one",
+"Curiosity killed the cat",
+"Take this job and shove it",
+"Up a creek without a paddle",
+"I'm mad as hell and I'm not going to take it any more",
+"An apple a day keeps the doctor away",
+"Don't look a gift horse in the mouth"
+)
+
diff --git a/ext/tk/sample/demos-jp/search.rb b/ext/tk/sample/demos-jp/search.rb
new file mode 100644
index 0000000000..f5268f987f
--- /dev/null
+++ b/ext/tk/sample/demos-jp/search.rb
@@ -0,0 +1,176 @@
+#
+# Text Search widget demo (called by 'widget')
+#
+
+# textLoadFile --
+# This method below loads a file into a text widget, discarding
+# the previous contents of the widget. Tags for the old widget are
+# not affected, however.
+#
+# Arguments:
+# w - The window into which to load the file. Must be a
+# text widget.
+# file - The name of the file to load. Must be readable.
+
+def textLoadFile(w,file)
+ w.delete('1.0', 'end')
+ f = open(file, 'r')
+ while(!f.eof?)
+ w.insert('end', f.read(1000))
+ end
+ f.close
+end
+
+# textSearch --
+# Search for all instances of a given string in a text widget and
+# apply a given tag to each instance found.
+#
+# Arguments:
+# w - The window in which to search. Must be a text widget.
+# string - The string to search for. The search is done using
+# exact matching only; no special characters.
+# tag - Tag to apply to each instance of a matching string.
+
+def textSearch(w, string, tag)
+ tag.remove('0.0', 'end')
+ return if string == ""
+ cur = '1.0'
+ loop {
+ cur, len = w.search_with_length(string, cur, 'end')
+ break if cur == ""
+ tag.add(cur, "#{cur} + #{len} char")
+ cur = w.index("#{cur} + #{len} char")
+ }
+end
+
+# textToggle --
+# This method is invoked repeatedly to invoke two commands at
+# periodic intervals. It normally reschedules itself after each
+# execution but if an error occurs (e.g. because the window was
+# deleted) then it doesn't reschedule itself.
+#
+# Arguments:
+# cmd1 - Command to execute when method is called.
+# sleep1 - Ms to sleep after executing cmd1 before executing cmd2.
+# cmd2 - Command to execute in the *next* invocation of this method.
+# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again.
+
+def textToggle(cmd1,sleep1,cmd2,sleep2)
+ sleep_list = [sleep2, sleep1]
+ TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep},
+ -1, cmd1, cmd2).start(sleep1)
+end
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($search_demo) && $search_demo
+ $search_demo.destroy
+ $search_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$search_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Search and Highlight")
+ iconname("search")
+ positionWindow(w)
+}
+
+# frame À¸À®
+$search_buttons = TkFrame.new($search_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $search_demo
+ $search_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'search'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+TkFrame.new($search_demo) {|f|
+ TkLabel.new(f, 'text'=>'¥Õ¥¡¥¤¥ë̾:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_fileName = TkVariable.new
+ TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_fileName) {
+ pack('side'=>'left')
+ bind('Return', proc{textLoadFile($search_text, $search_fileName.value)
+ $search_string_entry.focus})
+ focus
+ }
+ TkButton.new(f, 'text'=>'ÆÉ¤ß¹þ¤ß',
+ 'command'=>proc{textLoadFile($search_text,
+ $search_fileName.value)})\
+ .pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+}.pack('side'=>'top', 'fill'=>'x')
+
+TkFrame.new($search_demo) {|f|
+ TkLabel.new(f, 'text'=>'¸¡º÷ʸ»úÎó:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_searchString = TkVariable.new
+ $search_string_entry = TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_searchString) {
+ pack('side'=>'left')
+ bind('Return', proc{textSearch($search_text, $search_searchString.value,
+ $search_Tag)})
+ }
+ TkButton.new(f, 'text'=>'ȿž',
+ 'command'=>proc{textSearch($search_text,
+ $search_searchString.value,
+ $search_Tag)}) {
+ pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+ }
+}.pack('side'=>'top', 'fill'=>'x')
+
+$search_text = TkText.new($search_demo, 'setgrid'=>true) {|t|
+ $search_Tag = TkTextTag.new(t)
+ TkScrollbar.new($search_demo, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
+ t.yscrollcommand(proc{|first,last| sc.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+}
+
+# Set up display styles for text highlighting.
+
+if TkWinfo.depth($search_demo) > 1
+ textToggle(proc{
+ $search_Tag.configure('background'=>'#ce5555',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+else
+ textToggle(proc{
+ $search_Tag.configure('background'=>'black',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+end
+$search_text.insert('1.0', "\
+¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï¸¡º÷µ¡¹½¤ò¼Â¸½¤¹¤ë¤Î¤Ë¥Æ¥­¥¹¥È widget ¤Î¥¿¥°µ¡Ç½¤¬¤É¤Î \
+¤è¤¦¤Ë»È¤ï¤ì¤ë¤Î¤«¤ò¥Ç¥â¤¹¤ë¤â¤Î¤Ç¤¹¡£¤Þ¤º¾å¤Î¥¨¥ó¥È¥ê¤Ë¥Õ¥¡¥¤¥ë̾¤òÆþ \
+¤ì¡¢<¥ê¥¿¡¼¥ó> ¤ò²¡¤¹¤«¡Ö¥í¡¼¥É¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£¼¡¤Ë¤½¤Î²¼¤Î \
+¥¨¥ó¥È¥ê¤Ëʸ»úÎó¤òÆþÎϤ·¡¢<¥ê¥¿¡¼¥ó> ¤ò²¡¤¹¤«¡Öȿž¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯ \
+¤À¤µ¤¤¡£¤¹¤ë¤È¥Õ¥¡¥¤¥ëÃæ¤Î¡¢¸¡º÷ʸ»úÎó¤È°ìÃפ¹¤ëÉôʬ¤ËÁ´¤Æ \"search_Tag\" \
+¤È¤¤¤¦¥¿¥°¤¬¤Ä¤±¤é¤ì¡¢¥¿¥°¤Îɽ¼¨Â°À­¤È¤·¤Æ¤½¤Îʸ»úÎó¤¬ÅÀÌǤ¹¤ë¤è¤¦¤Ë \
+ÀßÄꤵ¤ì¤Þ¤¹¡£")
+$search_text.set_insert '0.0'
+
+$search_fileName.value = ''
+$search_searchString.value = ''
+
diff --git a/ext/tk/sample/demos-jp/spin.rb b/ext/tk/sample/demos-jp/spin.rb
new file mode 100644
index 0000000000..c7b8096723
--- /dev/null
+++ b/ext/tk/sample/demos-jp/spin.rb
@@ -0,0 +1,67 @@
+# spin.rb --
+#
+# This demonstration script creates several spinbox widgets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($spin_demo) && $spin_demo
+ $spin_demo.destroy
+ $spin_demo = nil
+end
+
+$spin_demo = TkToplevel.new {|w|
+ title("Spinbox Demonstration")
+ iconname("spin")
+ positionWindow(w)
+}
+
+TkLabel.new($spin_demo,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+²¼¤Ë¤Ï£³¼ïÎà¤Î¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\
+¤½¤ì¤¾¤ì¡¢¥Þ¥¦¥¹¤ÇÁªÂò¤·¤ÆÊ¸»ú¤òÆþÎϤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+ÊÔ½¸Áàºî¤È¤·¤Æ¤Ï¡¢Emacs ·Á¼°¤Î¿¤¯¤Ë²Ã¤¨¤Æ¡¢°ìÈÌŪ¤Ê
+Motif ·Á¼°¤Î¥­¡¼Áàºî¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤¿¤È¤¨¤Ð¡¢
+Backspace ¤È Control-h ¤È¤ÏÆþÎÏ¥«¡¼¥½¥ë¤Îº¸Â¦¤Îʸ»ú¤ò
+ºï½ü¤·¡¢Delete ¤È Control-d ¤È¤Ï±¦Â¦¤Îʸ»ú¤òºï½ü¤·¤Þ¤¹¡£
+ÆþÎÏÏȤÎŤµ¤ò±Û¤¨¤ë¤è¤¦¤ÊŤ¤Ê¸»úÎó¤òÆþÎϤ·¤¿¾ì¹ç¤Ë¤Ï¡¢
+¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó£²¤ò²¡¤·¤Æ¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¡¢ÆþÎÏʸ»úÎó
+¤ò¥¹¥­¥ã¥ó¤¹¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡£
+¤Ê¤ª¡¢ºÇ½é¤Î¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹¤Ï¡¢À°¿ôÃͤȤߤʤµ¤ì¤ë¤è¤¦¤Ê
+ʸ»úÎó¤·¤«ÆþÎϤ¬µö¤µ¤ì¤Ê¤¤¤³¤È¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£¤Þ¤¿¡¢
+£³ÈÖÌܤΥ¹¥Ô¥ó¥Ü¥Ã¥¯¥¹¤ÇÁªÂò¸õÊä¤Ë¸½¤ì¤ë¤Î¤Ï¥ª¡¼¥¹¥È¥é
+¥ê¥¢¤ÎÅÔ»Ô̾¤Î¥ê¥¹¥È¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
+¤â¤·¤¢¤Ê¤¿¤¬»È¤Ã¤Æ¤¤¤ë Ruby ¤Ë¥ê¥ó¥¯¤µ¤ì¤Æ¤¤¤ë Tk ¥é¥¤
+¥Ö¥é¥ê¤¬ spinbox ¥¦¥£¥¸¥§¥Ã¥È¤ò¼ÂÁõ¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¤³¤Î
+¥Ç¥â¤Ï¤¦¤Þ¤¯Æ°¤«¤Ê¤¤¤Ï¤º¤Ç¤¹¡£¤½¤Î¾ì¹ç¤Ë¤Ï spinbox ¥¦¥£
+¥¸¥§¥Ã¥È¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤è¤¦¤Ê¤è¤ê¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤Î Tk
+¤òÁȤ߹ç¤ï¤»¤Æ»î¤¹¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
+EOL
+
+TkFrame.new($spin_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
+ $spin_demo.destroy
+ $spin_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{
+ showCode 'spin'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+australianCities = [
+ 'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide',
+ 'Brisbane', 'Hobart', 'Darwin', 'Alice Springs'
+]
+
+[
+ TkSpinbox.new($spin_demo, :from=>1, :to=>10, :width=>10, :validate=>:key,
+ :validatecommand=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]),
+ TkSpinbox.new($spin_demo, :from=>0, :to=>3, :increment=>0.5,
+ :format=>'%05.2f', :width=>10),
+ TkSpinbox.new($spin_demo, :values=>australianCities, :width=>10)
+].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}
diff --git a/ext/tk/sample/demos-jp/square b/ext/tk/sample/demos-jp/square
new file mode 100644
index 0000000000..00bfde59ff
--- /dev/null
+++ b/ext/tk/sample/demos-jp/square
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+# square --
+# This script generates a demo application containing only
+# a "square" widget. It's only usable if Tk has been compiled
+# with tkSquare.c and with the -DSQUARE_DEMO compiler switch.
+# This demo arranges the following bindings for the widget:
+#
+# Button-1 press/drag: moves square to mouse
+# "a": toggle size animation on/off
+#
+
+require 'tk'
+require 'tkafter'
+
+class TkSquare<TkWindow
+ def create_self
+ begin
+ tk_call 'square', path
+ rescue
+ STDERR.print "\nSorry. Your Tk interpreter does not contain " +
+ 'a "square" demonstration widget.' +
+ "\n ( See documents included the Tcl/Tk source archive. )\n\n"
+ exit
+ end
+ end
+ def size(amount=nil)
+ if amount
+ tk_send 'size', amount
+ else
+ number(tk_send('size'))
+ end
+ end
+ def position(x,y)
+ tk_send 'position', x, y
+ end
+end
+
+$s = TkSquare.new{
+ pack('expand'=>'yes', 'fill'=>'both')
+ bind('1', proc{|x,y| center(x,y)}, '%s %y')
+ bind('B1-Motion', proc{|x,y| center(x,y)}, '%s %y')
+ bind('a', proc{animate})
+ focus
+}
+TkRoot.new.minsize(1,1)
+
+# The procedure below centers the square on a given position.
+
+def center(x,y)
+ a = $s.size
+ $s.position(x-(a/2), y-(a/2))
+end
+
+# The procedures below provide a simple form of animation where
+# the box changes size in a pulsing pattern: larger, smaller, larger,
+# and so on.
+
+$inc = 0
+
+def timer_proc
+ a = $s.size
+ return if $inc == 0
+ $inc = -3 if a >= 40
+ $inc = 3 if a <= 10
+ $s.size(a+$inc)
+end
+
+$timer = TkAfter.new(30, -1, proc{timer_proc})
+
+def animate
+ if $inc == 0
+ $inc = 3
+ $timer.start
+ else
+ $inc = 0
+ $timer.stop
+ end
+end
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/states.rb b/ext/tk/sample/demos-jp/states.rb
new file mode 100644
index 0000000000..dfae821261
--- /dev/null
+++ b/ext/tk/sample/demos-jp/states.rb
@@ -0,0 +1,71 @@
+#
+# listbox widget demo 'states' (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($states_demo) && $states_demo
+ $states_demo.destroy
+ $states_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$states_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (states)")
+ iconname("states")
+ positionWindow(w)
+}
+
+# label À¸À®
+msg = TkLabel.new($states_demo) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "²¼¤Ë¤¢¤ë¤Î¤ÏÅÔÆ»Éܸ©Ì¾¤¬Æþ¤Ã¤¿¥¹¥¯¥í¡¼¥ë¥Ð¡¼ÉդΥꥹ¥È¥Ü¥Ã¥¯¥¹¤Ç¤¹¡£¥ê¥¹¥È¤ò¥¹¥¯¥í¡¼¥ë¤µ¤»¤ë¤Î¤Ï¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤Ç¤â¤Ç¤­¤Þ¤¹¤·¡¢¥ê¥¹¥È¥Ü¥Ã¥¯¥¹¤ÎÃæ¤Ç¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó2(Ãæ¥Ü¥¿¥ó)¤ò²¡¤·¤¿¤Þ¤Þ¥É¥é¥Ã¥°¤·¤Æ¤â¤Ç¤­¤Þ¤¹¡£"
+}
+msg.pack('side'=>'top')
+
+# frame À¸À®
+TkFrame.new($states_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $states_demo
+ $states_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'states'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+states_lbox = nil
+TkFrame.new($states_demo, 'borderwidth'=>'.5c') {|w|
+ s = TkScrollbar.new(w)
+ states_lbox = TkListbox.new(w) {
+ setgrid 1
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| states_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ states_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+ins_data = [
+ '°¦ÃÎ','ÀÄ¿¹','½©ÅÄ','ÀÐÀî','°ñ¾ë','´ä¼ê','°¦É²',
+ 'Âçʬ','Âçºå','²¬»³','²­Æì','¹áÀî','¼¯»ùÅç','¿ÀÆàÀî',
+ '´ôÉì','µþÅÔ','·§ËÜ','·²ÇÏ','¹âÃÎ','ºë¶Ì','º´²ì',
+ '¼¢²ì','ÀŲ¬','Å纬','ÀéÍÕ','Åìµþ','ÆÁÅç','ÆÊÌÚ',
+ 'Ä»¼è','ÉÙ»³','Ĺºê','ĹÌî','ÆàÎÉ','¿·³ã','ʼ¸Ë',
+ '¹­Åç','Ê¡°æ','Ê¡²¬','Ê¡Åç','Ë̳¤Æ»','»°½Å','µÜ¾ë',
+ 'µÜºê','»³·Á','»³¸ý','»³Íü','ϲλ³'
+]
+
+states_lbox.insert(0, *ins_data)
+
diff --git a/ext/tk/sample/demos-jp/style.rb b/ext/tk/sample/demos-jp/style.rb
new file mode 100644
index 0000000000..59e406bc80
--- /dev/null
+++ b/ext/tk/sample/demos-jp/style.rb
@@ -0,0 +1,248 @@
+#
+# text (display styles) widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($style_demo) && $style_demo
+ $style_demo.destroy
+ $style_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$style_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Display Styles")
+ iconname("style")
+ positionWindow(w)
+}
+
+# frame À¸À®
+TkFrame.new($style_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $style_demo
+ $style_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'style'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# text À¸À®
+TkText.new($style_demo){|t|
+ # À¸À®
+ setgrid 'true'
+ width 70
+ height 32
+ wrap 'word'
+ TkScrollbar.new($style_demo) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ # ¥Æ¥­¥¹¥È¥¿¥°ÀßÄê (¥Õ¥©¥ó¥È´ØÏ¢)
+ style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
+ style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+ style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
+# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+ style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+###
+# case($tk_version)
+# when /^4.*/
+# style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+# when /^8.*/
+# unless $style_demo_do_first
+# $style_demo_do_first = true
+# Tk.tk_call('font', 'create', '@bigascii',
+# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*')
+# Tk.tk_call('font', 'create', '@smallascii',
+# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+# Tk.tk_call('font', 'create', '@cBigFont',
+# '-compound', '@bigascii @msg_knj')
+# Tk.tk_call('font', 'create', '@cSmallFont',
+# '-compound', '@smallascii @kanji')
+# end
+# style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont')
+# style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont')
+# end
+
+ # ¥Æ¥­¥¹¥È¥¿¥°ÀßÄê (¿§¡¤¥ì¥ê¡¼¥Õ´ØÏ¢)
+ if TkWinfo.depth($root).to_i > 1
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'#a0b7ce')
+ style_tag_color2 = TkTextTag.new(t, 'foreground'=>'red')
+ style_tag_raised = TkTextTag.new(t, 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1)
+ else
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_color2 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_raised = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'sunken', 'borderwidth'=>1)
+ end
+
+ # ¥Æ¥­¥¹¥È¥¿¥°ÀßÄê (¤½¤Î¾)
+ if $tk_version =~ /^4\.[01]/
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray25')
+ else
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray12')
+ end
+ style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50')
+ style_tag_underline = TkTextTag.new(t, 'underline'=>'on')
+ style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
+ style_tag_right = TkTextTag.new(t, 'justify'=>'right')
+ style_tag_center = TkTextTag.new(t, 'justify'=>'center')
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+ style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
+ 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+
+ # ¥Æ¥­¥¹¥ÈÁÞÆþ
+ insert('end', '¤³¤Î¤è¤¦¤Ë¥Æ¥­¥¹¥È widget ¤Ï¾ðÊó¤òÍÍ¡¹¤Ê¥¹¥¿¥¤¥ë¤Çɽ¼¨¤¹¤ë¤³¤È
+¤¬¤Ç¤­¤Þ¤¹¡£')
+ insert('end', '¥¿¥°', style_tag_big)
+ insert('end', '¤È¤¤¤¦¥á¥«¥Ë¥º¥à¤Ç¥³¥ó¥È¥í¡¼¥ë¤µ¤ì¤Þ¤¹¡£
+¥¿¥°¤È¤Ï¥Æ¥­¥¹¥È widget Æâ¤Î¤¢¤ëʸ»ú (¤ÎÈϰÏ)¤ËÂФ·¤ÆÅ¬ÍѤǤ­¤ë
+ñ¤Ê¤ë̾Á°¤Î¤³¤È¤Ç¤¹¡£¥¿¥°¤ÏÍÍ¡¹¤Êɽ¼¨¥¹¥¿¥¤¥ë¤ËÀßÄê¤Ç¤­¤Þ¤¹¡£
+ÀßÄꤹ¤ë¤È¡¢¤½¤Î¥¿¥°¤Î¤Ä¤¤¤¿Ê¸»ú¤Ï»ØÄꤷ¤¿¥¹¥¿¥¤¥ë¤Çɽ¼¨¤µ¤ì¤ë
+¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£»ÈÍѤǤ­¤ëɽ¼¨¥¹¥¿¥¤¥ë¤Ï¼¡¤ÎÄ̤ê¤Ç¤¹¡£
+')
+ insert('end', '
+1. ¥Õ¥©¥ó¥È', style_tag_big)
+ insert('end', ' ¤É¤ó¤Ê X ¤Î¥Õ¥©¥ó¥È¤Ç¤â»È¤¨¤Þ¤¹¡£')
+ insert('end', 'large', style_tag_verybig)
+ insert('end', '
+¤È¤«')
+# insert('end', '¾®¤µ¤¤', style_tag_small)
+ insert('end', 'small', style_tag_small)
+ insert('end', '¤È¤«¡£
+')
+ insert('end', '
+2. ¿§', style_tag_big)
+ insert('end', ' ')
+ insert('end', 'ÇØ·Ê¿§', style_tag_color1)
+ insert('end', '¤â')
+ insert('end', 'Á°·Ê¿§', style_tag_color2)
+ insert('end', '¤â')
+ insert('end', 'ξÊý', style_tag_color1, style_tag_color2)
+ insert('end', '¤È¤âÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+')
+ insert('end', '
+3. ÌÖ¤«¤±', style_tag_big)
+ insert('end', ' ¤³¤Î¤è¤¦¤ËÉÁ²è¤ÎºÝ¤Ë')
+ insert('end', 'ÇØ·Ê¤â', style_tag_bgstipple)
+ insert('end', 'ʸ»ú¤â', style_tag_fgstipple)
+ insert('end', 'ñ¤Ê¤ëÅɤê¤Ä¤Ö¤·
+¤Ç¤Ê¤¯¡¢ÌÖ¤«¤±¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+')
+ insert('end', '
+4. ²¼Àþ', style_tag_big)
+ insert('end', ' ¤³¤Î¤è¤¦¤Ë')
+ insert('end', 'ʸ»ú¤Ë²¼Àþ¤ò°ú¤¯', style_tag_underline)
+ insert('end', '¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+')
+ insert('end', '
+5. ÂǤÁ¾Ã¤·Àþ', style_tag_big)
+ insert('end', ' ¤³¤Î¤è¤¦¤Ë')
+ insert('end', 'ʸ»ú¤Ë½Å¤Í¤ÆÀþ¤ò°ú¤¯', style_tag_overstrike)
+ insert('end', '¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+')
+ insert('end', '
+6. 3D ¸ú²Ì', style_tag_big)
+ insert('end', ' ÇØ·Ê¤ËÏȤò¤Ä¤±¤Æ¡¢Ê¸»ú¤ò')
+ insert('end', 'Èô¤Ó½Ð¤¹', style_tag_raised)
+ insert('end', '¤è¤¦¤Ë¤·¤¿¤ê')
+ insert('end', 'ÄÀ¤à', style_tag_sunken)
+ insert('end', '
+¤è¤¦¤Ë¤Ç¤­¤Þ¤¹¡£
+')
+ insert('end', '
+7. ¹Ô·¤¨', style_tag_big)
+ insert('end', ' ¤³¤Î¤è¤¦¤Ë¹Ô¤ò
+')
+ insert('end', 'º¸¤Ë·¤¨¤¿¤ê
+')
+ insert('end', '±¦¤Ë·¤¨¤¿¤ê
+', style_tag_right)
+ insert('end', '¿¿Ãæ¤Ë·¤¨¤¿¤ê¤Ç¤­¤Þ¤¹¡£
+', style_tag_center)
+ insert('end', '
+8. ¸ªÉÕ¤­Ê¸»ú¤Èź»ú', style_tag_big)
+ insert('end', ' 10')
+ insert('end', 'n', style_tag_super)
+ insert('end', ' ¤Î¤è¤¦¤Ë¸ªÉÕ¤­Ê¸»ú¤Î¸ú²Ì¤ä¡¢')
+ insert('end', '
+X')
+ insert('end', 'i', style_tag_sub)
+ insert('end', '¤Î¤è¤¦¤Ëź»ú¤Î¸ú²Ì¤ò½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+')
+ insert('end', '
+9. ¥Þ¡¼¥¸¥ó', style_tag_big)
+ insert('end', '¥Æ¥­¥¹¥È¤Îº¸Â¦¤Ë;ʬ¤Ê¶õÇò¤òÃÖ¤¯¤³¤È¤¬¤Ç¤­¤Þ¤¹:
+')
+ insert('end', '¤³¤ÎÃÊÍî¤Ï¥Þ¡¼¥¸¥ó¤Î»ÈÍÑÎã¤Ç¤¹¡£¥¹¥¯¥ê¡¼¥ó',
+ style_tag_margins)
+ insert('end', '¾å¤ÇÀÞ¤êÊÖ¤µ¤ì¤ÆÉ½¼¨¤µ¤ì¤Æ¤¤¤ë1¹Ô¤Î¥Æ¥­¥¹¥È¤Ç¤¹¡£',
+ style_tag_margins)
+ insert('end', 'º¸Â¦¤Ë¤Ï2¼ïÎà¤Î¥Þ¡¼¥¸¥ó¤ò»ý¤Á¤Þ¤¹¡£', style_tag_margins)
+ insert('end', '1¹ÔÌܤËÂФ¹¤ë¤â¤Î¤È¡¢', style_tag_margins)
+ insert('end', '2¹ÔÌܰʹߤÎϢ³¤·¤¿¥Þ¡¼¥¸¥ó', style_tag_margins)
+ insert('end', '¤Ç¤¹¡£¤Þ¤¿±¦Â¦¤Ë¤â¥Þ¡¼¥¸¥ó¤¬¤¢¤ê¤Þ¤¹¡£', style_tag_margins)
+ insert('end', '¹Ô¤ÎÀÞ¤êÊÖ¤·°ÌÃÖ¤ò·è¤á¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+', style_tag_margins)
+ insert('end', '
+10. ¥¹¥Ú¡¼¥·¥ó¥°', style_tag_big)
+ insert('end', '3¤Ä¤Î¥Ñ¥é¥á¡¼¥¿¤Ç¹Ô¤Î¥¹¥Ú¡¼¥·¥ó¥°¤ò')
+ insert('end', 'À©¸æ¤¹
+¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£Spacing1¤Ç¡¢¹Ô¤Î')
+ insert('end', '¾å¤Ë¤É¤Î¤¯¤é¤¤¤Î¶õ´Ö¤òÃÖ¤¯¤«¡¢
+spacing3')
+ insert('end', '¤Ç¹Ô¤Î²¼¤Ë¤É¤Î¤¯¤é¤¤¤Î¶õ´Ö¤òÃÖ¤¯¤«¡¢')
+ insert('end', '¹Ô¤¬ÀÞ¤êÊÖ¤µ¤ì¤Æ¤¤¤ë¤Ê¤é
+¤Ð¡¢spacing2¤Ç¡¢')
+ insert('end', '¥Æ¥­¥¹¥È¹Ô¤òÀ¸À®¤·¤Æ¤¤¤ë¹Ô¤Î´Ö¤Ë¤É¤Î¤¯¤é¤¤')
+ insert('end', '¤Î¶õ´Ö¤òÃÖ
+¤¯¤«¤ò¼¨¤·¤Þ¤¹¡£
+')
+ insert('end', '¤³¤ì¤é¤Î¥¤¥ó¥Ç¥ó¥È¤µ¤ì¤¿ÃÊÍî¤Ï¤É¤Î¤è¤¦¤Ë',
+ style_tag_spacing)
+ insert('end', '¥¹¥Ú¡¼¥·¥ó¥°¤¬¤¬¹Ô¤ï¤ì¤ë¤Î¤«¤ò¼¨¤·¤Þ¤¹¡£',
+ style_tag_spacing)
+ insert('end', '³ÆÃÊÍî¤Ï¼ÂºÝ¤Ï¥Æ¥­¥¹¥Èwidget', style_tag_spacing)
+ insert('end', '¤Î1¹Ô¤Ç¡¢widget¤Ë¤è¤Ã¤ÆÀÞ¤ê¾ö¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£
+', style_tag_spacing)
+ insert('end', 'Spacing1¤Ï¤³¤Î¥Æ¥­¥¹¥È¤Ç¤Ï10point¤Ë', style_tag_spacing)
+ insert('end', 'ÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹¡£', style_tag_spacing)
+ insert('end', '¤³¤ì¤Ë¤è¤ê¡¢ÃÊÍî¤Î´Ö¤ËÂ礭¤Ê´Ö³Ö¤¬', style_tag_spacing)
+ insert('end', '¸ºß¤·¤Æ¤¤¤Þ¤¹¡£', style_tag_spacing)
+ insert('end', 'Spacing2¤Ï2point¤ËÀßÄꤵ¤ì¤Æ¤¤¤Þ¤¹¡£', style_tag_spacing)
+ insert('end', '¤³¤ì¤ÇÃÊÍî¤ÎÃæ¤Ë¤Û¤ó¤Î¾¯¤·´Ö³Ö¤¬Â¸ºß¤·¤Æ¤¤¤Þ¤¹¡£',
+ style_tag_spacing)
+ insert('end', 'Spacing3¤Ï¤³¤ÎÎã¤Ç¤Ï»ÈÍѤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£
+', style_tag_spacing)
+ insert('end', '´Ö³Ö¤¬¤É¤³¤Ë¤¢¤ë¤«¤ò¸«¤¿¤±¤ì¤Ð¡¢¤³¤ì¤é¤ÎÃÊÍî¤Î',
+ style_tag_spacing)
+ insert('end', '¤Ê¤«¤Ç¥Æ¥­¥¹¥È¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£ÁªÂò¤Î', style_tag_spacing)
+ insert('end', 'ȿž¤·¤¿Éôʬ¤Ë¤Ï;ʬ¤Ë¤È¤é¤ì¤¿´Ö³Ö¤¬', style_tag_spacing)
+ insert('end', '´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£
+', style_tag_spacing)
+
+}
+
diff --git a/ext/tk/sample/demos-jp/tcolor b/ext/tk/sample/demos-jp/tcolor
new file mode 100644
index 0000000000..fc697df63e
--- /dev/null
+++ b/ext/tk/sample/demos-jp/tcolor
@@ -0,0 +1,528 @@
+#!/usr/bin/env ruby
+#
+# tcolor --
+# ¤³¤Î¥¹¥¯¥ê¥×¥È¤ÏRGB,HSB,CYM·Á¼°¤ò¥µ¥Ý¡¼¥È¤¹¤ë
+# ´Ê°×¥«¥é¡¼¥¨¥Ç¥£¥¿¤Ç¤¹¡£
+#
+# Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp)
+# last update: Thu Jun 18 06:32:35 JST 1998
+#
+
+# ¤Þ¤º¤Ïtk.rb¤òÆÉ¤ß¹þ¤à¡£
+
+require "tk"
+
+
+# Tk¤Ë¤è¤Ã¤ÆÊѹ¹¤µ¤ì¤ëÊÑ¿ô¤ÏTkVariable¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤ò»È¤¦¡£
+
+$colorSpace = TkVariable.new(:rgb)
+$master = nil
+$red = 65535
+$green = 0
+$blue = 0
+$color = "#ffff00000000"
+$updating = TkVariable.new(0)
+$autoUpdate = TkVariable.new(1)
+$name = TkVariable.new($color)
+$command = TkVariable.new("print(%%,\"\n\")")
+# $command = TkVariable.new("")
+$label1 = TkVariable.new("label1")
+$label2 = TkVariable.new("label2")
+$label3 = TkVariable.new("label3")
+
+
+# ¥ê¥½¡¼¥¹¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÀßÄê
+if (TkVarAccess.new('tcl_platform')['platform'] == 'unix')
+ TkOptionDB.add('*Entry.background', 'white')
+end
+
+
+# ³Æ¥¤¥Ù¥ó¥ÈÍѤΥ᥽¥Ã¥É
+
+def rgbToHsv(red,green,blue)
+
+ if ( red > green )
+ max = red
+ min = green
+ else
+ max = green
+ min = red
+ end
+
+ if ( blue > max )
+ max = blue
+ else
+ if ( blue < min )
+ min = blue
+ end
+ end
+
+ range = max - min
+
+ if ( max == 0 )
+ sat = 0.0
+ else
+ sat = (max-min)/max
+ end
+
+ if ( sat == 0 )
+ hue = 0.0
+ else
+ rc = (max-red)/range
+ gc = (max-green)/range
+ bc = (max-blue)/range
+ if ( red == max )
+ hue = 0.166667 * (bc - gc)
+ else
+ if ( green == max )
+ hue = 0.166667 * (2.0 + rc - bc)
+ else
+ hue = 0.166667 * (4.0 + gc - rc)
+ end
+ end
+ if ( hue < 0.0 )
+ hue = hue + 1.0
+ end
+ end
+
+ [hue,sat,max/65535]
+end
+
+
+def hsbToRgb(hue,sat,value)
+ v = 65535.0 * value
+ if( sat == 0 )
+ ans = [v,v,v]
+ else
+ hue = hue*6.0
+ if ( hue >= 6 )
+ hue = 0.0
+ end
+ i = hue.to_i
+ f = hue - i
+ p = 65535.0 * value * (1.0 - sat)
+ q = 65535.0 * value * (1.0 - (sat * f))
+ t = 65535.0 * value * (1.0 - (sat * (1.0 - f)))
+ case i
+ when 0
+ ans = [v,t,p]
+ when 1
+ ans = [q,v,p]
+ when 2
+ ans = [p,v,t]
+ when 3
+ ans = [p,q,v]
+ when 4
+ ans = [t,p,v]
+ when 5
+ ans = [v,p,q]
+ else
+ raise(eException,"i value #{i} is out of range")
+ end
+ end
+ return ans
+end
+
+
+def doUpdate
+ newCmd = $command.to_s.gsub("%%","\"#{$color}\"")
+ eval(newCmd)
+end
+
+
+def tc_scaleChanged
+ if( $updating.to_i == 1 )
+ return
+ end
+
+ $master = :scale if $master == nil
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ $red = (scale1.get * 65.535).to_i
+ $green = (scale2.get * 65.535).to_i
+ $blue = (scale3.get * 65.535).to_i
+ when :cmy
+ $red = (65535 - scale1.get * 65.535).to_i
+ $green = (65535 - scale2.get * 65.535).to_i
+ $blue = (65535 - scale3.get * 65.535).to_i
+ when :hsb
+ list = hsbToRgb(scale1.get / 1000.0,
+ scale2.get / 1000.0,
+ scale3.get / 1000.0)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+ $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i)
+ $name.value = $color if $master == :scale
+ $root.middle.right.set_color($color)
+ if( $autoUpdate.to_i == 1 )
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :scale
+end
+
+
+def tc_setScales
+ $updating.value = 1
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ scale1.set($red / 65.535)
+ scale2.set($green / 65.535)
+ scale3.set($blue / 65.535)
+ when :cmy
+ scale1.set((65535 - $red) / 65.535)
+ scale2.set((65535 - $green) / 65.535)
+ scale3.set((65535 - $blue) / 65.535)
+ when :hsb
+ list = rgbToHsv($red,$green,$blue)
+ scale1.set( list[0] * 1000.0 )
+ scale2.set( list[1] * 1000.0 )
+ scale3.set( list[2] * 1000.0 )
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+
+ $updating.value = 0
+end
+
+
+def tc_loadNamedColor(name)
+ $name.value = name
+ $master = :name if $master == nil
+ if name[0,1] != "#"
+ list = TkWinfo.rgb($root.middle.right.swatch,name)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ case name.length
+ when 4
+ format = /#(.{1})(.{1})(.{1})/
+ shift = 12
+ when 7
+ format = /#(.{2})(.{2})(.{2})/
+ shift = 8
+ when 10
+ format = /#(.{3})(.{3})(.{3})/
+ shift = 4
+ when 13
+ format = /#(.{4})(.{4})(.{4})/
+ shift = 0
+ else
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ name.scan(format){|strlist|
+ if strlist.length != 3
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ $red = strlist[0].hex
+ $green = strlist[1].hex
+ $blue = strlist[2].hex
+ }
+ $red = $red << shift
+ $green = $green << shift
+ $blue = $blue << shift
+ end
+
+ tc_setScales
+ $color = format("#%04x%04x%04x",$red,$green,$blue)
+ $root.middle.right.set_color($color)
+ if $autoUpdate.to_i == 1
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :name
+end
+
+
+def changeColorSpace(space)
+ case space
+ when :rgb
+ $label1.value = "Red"
+ $label2.value = "Green"
+ $label3.value = "Blue"
+ when :cmy
+ $label1.value = "Cyan"
+ $label2.value = "Magenta"
+ $label3.value = "Yellow"
+ when :hsb
+ $label1.value = "Hue"
+ $label2.value = "Saturation"
+ $label3.value = "Brightness"
+ end
+ tc_setScales
+end
+
+
+
+
+
+# tcolorÍѤΥá¥Ë¥å¡¼
+
+class TkColorMenuFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=>"raised",
+ "borderwidth"=>"2")
+
+ # File¥á¥Ë¥å¡¼¥Ü¥¿¥ó¤ÎÀ¸À®
+ @file = TkMenubutton.new(self){|button|
+
+ # File¥á¥Ë¥å¡¼¤ÎºîÀ®
+ @file_menu = TkMenu.new(button){
+ add "radio",
+ "label" => "RGB color space",
+ "variable" => $colorSpace,
+ "value" => :rgb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:rgb)}
+ add "radio",
+ "label" => "CMY color space",
+ "variable" => $colorSpace,
+ "value" => :cmy,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:cmy)}
+ add "radio",
+ "label" => "HSB color space",
+ "variable" => $colorSpace,
+ "value" => :hsb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:hsb)}
+ add "separator"
+ add "radio",
+ "label" => "Automatic updates",
+ "variable" => $autoUpdate,
+ "value" => "1",
+ "underline" => "0"
+ add "radio",
+ "label" => "Manual updates",
+ "variable" => $autoUpdate,
+ "value" => "0",
+ "underline" => "0"
+ add "separator"
+ add "command",
+ "label" => "Exit program",
+ "underline" => "0",
+ "command" => proc{exit}
+ }
+
+ # File¥á¥Ë¥å¡¼¤ÈFile¥Ü¥¿¥ó¤ò´ØÏ¢ÉÕ¤±¤ë
+ menu @file_menu
+
+ text "File"
+ underline "0"
+ }.pack("side"=>"left")
+
+ self
+ end
+end
+
+
+# ²¼Éô¤Î¥Õ¥ì¡¼¥à¤Î¤¿¤á¤Î¥¯¥é¥¹
+class TkColorBotFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> 2)
+
+ @commandLabel = TkLabel.new(self,
+ "text"=> "Command:")
+ @command = TkEntry.new(self,
+ "relief"=> "sunken",
+ "borderwidth"=> "2",
+ "textvariable"=> $command,
+ "font"=> "-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @update = TkButton.new(self,
+ "text"=> "Update",
+ "command"=> proc{doUpdate})
+ @commandLabel.pack("side"=>"left")
+ @update.pack("side"=>"right","pady"=>".1c","padx"=>".25c")
+ @command.pack("expand"=>"yes","fill"=>"x","ipadx"=>".25c")
+
+ self
+ end
+end
+
+
+# ÃæÃʺ¸¤Î¥Õ¥ì¡¼¥à
+class TkColorMiddleLeftFrame<TkFrame
+ def initialize(parent)
+ super(parent)
+
+ for i in ["/usr/local/lib/X11rgb.txt","/usr/lib/X11/rgb.txt",
+ "/X11/R5/lib/X11/rgb.txt","/X11/R4/lib/rgb/rgb.txt",
+ "/usr/openwin/lib/X11/rgb.txt"]
+ if !File.readable?(i)
+ next
+ end
+ f = File.open(i)
+ @scroll = TkScrollbar.new(self,
+ "orient"=>"vertical",
+ "relief"=>"sunken",
+ "borderwidth"=>"2")
+ @scroll.pack("side"=>"right","fill"=>"y")
+ @names = TkListbox.new(self,
+ "width"=>"20",
+ "height"=>"12",
+ "yscrollcommand"=> proc{|first,last| @scroll.set first,last},
+ "relief"=>"sunken",
+ "borderwidth"=>"2",
+ "exportselection"=>"false")
+ @scroll.command(proc{|*args| @names.yview(*args)})
+ @names.bind("Double-1",proc{
+ tc_loadNamedColor(@names.get(@names.curselection))})
+ @names.pack("side"=>"left")
+ while (line = f.gets)
+ line.chop!
+ linelist = line.split(/[ \t]+/)
+ if linelist.length == 4
+ @names.insert("end",linelist[3])
+ end
+ end
+ f.close
+ break
+ end
+
+ self
+ end
+end
+
+
+# ÃæÃÊÃæ±û¤Î¥Õ¥ì¡¼¥à
+class TkColorMiddleMiddleFrame<TkFrame
+ # @scale1,@scale2,@scale3¤ò³°Éô¤«¤é»²¾È¤Î¤ßµö²Ä¤¹¤ë¡£(Êѹ¹ÉÔ²Ä)
+ attr_reader :scale1, :scale2, :scale3
+
+ def initialize(parent)
+ super(parent)
+
+ @f1 = TkFrame.new(self)
+ @f2 = TkFrame.new(self)
+ @f3 = TkFrame.new(self)
+ @f4 = TkFrame.new(self)
+
+ for f in [@f1,@f2,@f3]
+ f.pack("side"=>"top","expand"=>"yes")
+ end
+ @f4.pack("side"=>"top","expand"=>"yes","fill"=>"x")
+
+ @label1 = TkLabel.new(self,"textvariable"=>$label1)
+ @scale1 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale1.pack("side"=>"top","anchor"=>"w")
+ @label1.pack("side"=>"top","anchor"=>"w")
+
+ @label2 = TkLabel.new(self,"textvariable"=>$label2)
+ @scale2 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale2.pack("side"=>"top","anchor"=>"w")
+ @label2.pack("side"=>"top","anchor"=>"w")
+
+ @label3 = TkLabel.new(self,"textvariable"=>$label3)
+ @scale3 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale3.pack("side"=>"top","anchor"=>"w")
+ @label3.pack("side"=>"top","anchor"=>"w")
+
+ @nameLabel = TkLabel.new(self,"text"=>"Name:")
+ @name = TkEntry.new(self,"relief"=>"sunken","borderwidth"=>"2",
+ "textvariable"=>$name,"width"=>"10",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @nameLabel.pack("side"=>"left")
+ @name.pack("side"=>"right", "expand"=>"1", "fill"=>"x")
+ @name.bind("Return",proc{tc_loadNamedColor $name.to_s})
+
+ self
+ end
+end
+
+
+class TkColorMiddleRightFrame<TkFrame
+ attr_reader :swatch
+
+ def initialize(parent)
+ super(parent)
+ @swatch = TkFrame.new(self, "width"=>"2c", "height"=>"5c",
+ "background"=>$color)
+ @value = TkLabel.new(self,
+ "text"=>$color,
+ "width"=>"13",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @swatch.pack("side"=>"top","expand"=>"yes","fill"=>"both")
+ @value.pack("side"=>"bottom","pady"=>".25c")
+
+ self
+ end
+
+ def set_color(color)
+ @swatch["background"] = color
+ @value["text"] = color
+ end
+end
+
+
+
+# ÃæÃʤΥե졼¥à
+class TkColorMiddleFrame<TkFrame
+ attr_reader :left, :middle, :right
+
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> "2")
+
+ @left = TkColorMiddleLeftFrame.new(self)
+ @left.pack("side"=>"left","padx"=>".25c","pady"=>".25c")
+
+ @middle = TkColorMiddleMiddleFrame.new(self)
+ @middle.pack("side"=>"left","expand"=>"yes","fill"=>"y")
+
+ @right = TkColorMiddleRightFrame.new(self)
+ @right.pack("side"=>"left","padx"=>".25c","pady"=>".25c","anchor"=>"s")
+
+ self
+ end
+end
+
+
+class TkColor<TkRoot
+ attr_reader :menu, :bottom, :middle
+
+ def initialize(*args)
+ super(*args)
+ @menu = TkColorMenuFrame.new(self)
+ @menu.pack("side"=>"top", "fill"=>"x")
+
+ @bottom = TkColorBotFrame.new(self)
+ @bottom.pack("side"=>"bottom","fill"=>"x")
+
+ @middle = TkColorMiddleFrame.new(self)
+ @middle.pack("side"=>"top","fill"=>"both")
+
+ self
+ end
+end
+
+
+$root = TkColor.new
+
+# ¥¤¥Ù¥ó¥È¤òÂԤİ٤˥롼¥×¤ËÆþ¤ë¡£
+changeColorSpace :rgb
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/text.rb b/ext/tk/sample/demos-jp/text.rb
new file mode 100644
index 0000000000..0057d5dbdc
--- /dev/null
+++ b/ext/tk/sample/demos-jp/text.rb
@@ -0,0 +1,117 @@
+#
+# text (basic facilities) widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($text_demo) && $text_demo
+ $text_demo.destroy
+ $text_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$text_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Basic Facilities")
+ iconname("text")
+ positionWindow(w)
+}
+
+# version check
+if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0)
+ undo_support = false
+else
+ undo_support = true
+end
+
+# frame À¸À®
+TkFrame.new($text_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $text_demo
+ $text_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'text'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# text À¸À®
+TkText.new($text_demo){|t|
+ # À¸À®
+ relief 'sunken'
+ bd 2
+ setgrid 1
+ height 30
+ TkScrollbar.new($text_demo) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ # ¥Æ¥­¥¹¥ÈÁÞÆþ
+ insert('0.0', <<EOT)
+¤³¤Î¥¦¥£¥ó¥É¥¦¤Ï¥Æ¥­¥¹¥È widget ¤Ç¤¹¡£1¹Ô¤Þ¤¿¤Ï¤½¤ì°Ê¾å¤Î¥Æ¥­¥¹¥È¤òɽ
+¼¨¡¦ÊÔ½¸¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£°Ê²¼¤Ï¥Æ¥­¥¹¥È widget ¤Ç¤Ç¤­¤ëÁàºî¤Ë¤Ä¤¤¤Æ
+¤Þ¤È¤á¤¿¤â¤Î¤Ç¤¹¡£
+
+1. ¥¹¥¯¥í¡¼¥ë¡£¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤Ç¥Æ¥­¥¹¥È¤Îɽ¼¨Éôʬ¤òư¤«¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+
+2. ¥¹¥­¥ã¥Ë¥ó¥°¡£¥Æ¥­¥¹¥È¤Î¥¦¥£¥ó¥É¥¦¤Ç¥Þ¥¦¥¹¥Ü¥¿¥ó2 (Ãæ¥Ü¥¿¥ó¤ò) ¤ò²¡
+¤·¤Æ¾å²¼¤Ë¥É¥é¥Ã¥°¤·¤Æ¤¯¤À¤µ¤¤¡£¤½¤¦¤¹¤ë¤È¥Æ¥­¥¹¥È¤¬¹â®¤Ç¥É¥é¥Ã¥°¤µ¤ì¡¢
+ÆâÍÆ¤ò¤¶¤Ã¤Èį¤á¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+
+3. ¥Æ¥­¥¹¥È¤ÎÁÞÆþ¡£¥Þ¥¦¥¹¥Ü¥¿¥ó1 (º¸¥Ü¥¿¥ó) ¤ò²¡¤·¡¢ÁÞÆþ¥«¡¼¥½¥ë¤ò¥»¥Ã
+¥È¤·¤Æ¤«¤é¥Æ¥­¥¹¥È¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£ÆþÎϤ·¤¿¤â¤Î¤¬ widget ¤ËÆþ¤ê¤Þ¤¹¡£
+
+4. ÁªÂò¡£¤¢¤ëÈϰϤÎʸ»ú¤òÁªÂò¤¹¤ë¤Ë¤Ï¥Þ¥¦¥¹¥Ü¥¿¥ó1 ¤ò²¡¤·¡¢¥É¥é¥Ã¥°¤·
+¤Æ¤¯¤À¤µ¤¤¡£°ìÅ٥ܥ¿¥ó¤òÎ¥¤·¤¿¤é¡¢¥·¥Õ¥È¥­¡¼¤ò²¡¤·¤Ê¤¬¤é¥Ü¥¿¥ó1 ¤ò²¡¤¹
+¤³¤È¤ÇÁªÂòÈϰϤÎÄ´À°¤¬¤Ç¤­¤Þ¤¹¡£¤³¤ì¤ÏÁªÂòÈϰϤκǸå¤ò¥Þ¥¦¥¹¥«¡¼¥½¥ë¤Ë
+ºÇ¤â¶á¤¤°ÌÃ֤˥ꥻ¥Ã¥È¤·¡¢¥Ü¥¿¥ó¤òÎ¥¤¹Á°¤Ë¥Þ¥¦¥¹¤ò¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¤µ
+¤é¤ËÁªÂòÈϰϤòÄ´À°¤Ç¤­¤Þ¤¹¡£¥À¥Ö¥ë¥¯¥ê¥Ã¥¯¤Ç¥ï¡¼¥É¤ò¡¢¤Þ¤¿¥È¥ê¥×¥ë¥¯¥ê¥Ã
+¥¯¤Ç¹ÔÁ´ÂΤòÁªÂò¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
+
+5. ¾Ãµî¤ÈÃÖ´¹¡£¥Æ¥­¥¹¥È¤ò¾Ãµî¤¹¤ë¤Ë¤Ï¡¢¾Ãµî¤·¤¿¤¤Ê¸»ú¤òÁªÂò¤·¤Æ¥Ð¥Ã¥¯
+¥¹¥Ú¡¼¥¹¤«¥Ç¥ê¡¼¥È¥­¡¼¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£¤¢¤ë¤¤¤Ï¡¢¿·¤·¤¤¥Æ¥­¥¹¥È¤ò
+ÆþÎϤ¹¤ë¤ÈÁªÂò¤µ¤ì¤¿¥Æ¥­¥¹¥È¤ÈÃÖ´¹¤µ¤ì¤Þ¤¹¡£
+
+6. ÁªÂòÉôʬ¤Î¥³¥Ô¡¼¡£ÁªÂòÉôʬ¤ò¤³¤Î¥¦¥£¥ó¥É¥¦¤ÎÃæ¤Î¤É¤³¤«¤Ë¥³¥Ô¡¼¤¹¤ë
+¤Ë¤Ï¡¢¤Þ¤º¥³¥Ô¡¼¤·¤¿¤¤½ê¤òÁªÂò(¤³¤³¤Ç¡¢¤¢¤ë¤¤¤ÏÊ̤Υ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç)
+¤·¡¢¥Ü¥¿¥ó 2 ¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¡¢ÁÞÆþ¥«¡¼¥½¥ë¤Î°ÌÃ֤˥³¥Ô¡¼¤·¤Æ¤¯¤À¤µ¤¤¡£
+
+7. ÊÔ½¸¡£¥Æ¥­¥¹¥È widget ¤Ï Emacs ¤Î¥­¡¼¥Ð¥¤¥ó¥É¤Ë²Ã¤¨¤ÆÉ¸½àŪ¤Ê¤Î Motif
+¤ÎÊÔ½¸µ¡Ç½¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹¤È¥³¥ó¥È¥í¡¼¥ë-H ¤ÏÁÞÆþ
+¥«¡¼¥½¥ë¤Îº¸Â¦¤Îʸ»ú¤òºï½ü¤·¤Þ¤¹¡£¥Ç¥ê¡¼¥È¥­¡¼¤È¥³¥ó¥È¥í¡¼¥ë-D ¤ÏÁÞÆþ
+¥«¡¼¥½¥ë¤Î±¦Â¦¤Îʸ»ú¤òºï½ü¤·¤Þ¤¹¡£Meta-¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹¤ÏÁÞÆþ¥«¡¼¥½¥ë¤Î
+±¦Â¦¤Îñ¸ì¤òºï½ü¤·¡¢Meta-D ¤ÏÁÞÆþ¥«¡¼¥½¥ë¤Îº¸Â¦¤Îñ¸ì¤òºï½ü¤·¤Þ¤¹¡£
+¥³¥ó¥È¥í¡¼¥ë-K ¤ÏÁÞÆþ¥«¡¼¥½¥ë¤«¤é¹ÔËö¤Þ¤Ç¤òºï½ü¤·¡¢¤½¤Î°ÌÃ֤˲þ¹Ô
+¤·¤«¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢²þ¹Ô¤òºï½ü¤·¤Þ¤¹¡£#{
+ if undo_support
+ undo_text = "Control-z ¤ÏºÇ¸å¤Ë¹Ô¤Ã¤¿Êѹ¹¤Î¼è¤ê¾Ã¤·(undo)¤ò¹Ô¤¤¡¢"
+ case $tk_platform['platform']
+ when "unix", "macintosh"
+ undo_text << "Control-Shift-z"
+ else # 'windows'
+ undo_text << "Control-y"
+ end
+ undo_text << "¤Ïundo¤·¤¿Êѹ¹¤ÎºÆÅ¬ÍÑ(redo)¤ò¹Ô¤¤¤Þ¤¹¡£"
+ else
+ ""
+ end
+}
+
+
+8. ¥¦¥£¥ó¥É¥¦¤Î¥ê¥µ¥¤¥º¡£¤³¤Î widget ¤Ï "setGrid" ¥ª¥×¥·¥ç¥ó¤ò¥ª¥ó¤Ë¤·
+¤Æ¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢¥¦¥£¥ó¥É¥¦¤ò¥ê¥µ¥¤¥º¤¹¤ë»þ¤Ë¤Ï¹â¤µ¤ÈÉý¤Ï¾ï¤Ëʸ»ú¹â¤Èʸ
+»úÉý¤ÎÀ°¿ôÇܤˤʤê¤Þ¤¹¡£¤Þ¤¿¡¢¥¦¥£¥ó¥É¥¦¤ò¶¹¤¯¤·¤¿¾ì¹ç¤Ë¤ÏŤ¤¹Ô¤¬¼«Æ°
+Ū¤ËÀÞ¤êÊÖ¤µ¤ì¡¢¾ï¤ËÁ´¤Æ¤ÎÆâÍÆ¤¬¸«¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
+EOT
+
+ set_insert('0.0')
+}
+
diff --git a/ext/tk/sample/demos-jp/timer b/ext/tk/sample/demos-jp/timer
new file mode 100644
index 0000000000..58a41d00c0
--- /dev/null
+++ b/ext/tk/sample/demos-jp/timer
@@ -0,0 +1,136 @@
+#!/usr/bin/env ruby
+#
+# timer --
+# This script generates a counter with start,stop and reset buttons.
+#
+# Copyright (C) 1998 Takaaki Tateishi (ttate@jaist.ac.jp)
+# last update: Sat Jun 27 12:24:14 JST 1998
+#
+
+require "tk"
+require "thread"
+require "tkafter"
+
+$time = "0.00"
+$m = Mutex.new
+$loop = false
+
+def timer_stop
+ $loop = false
+ $m.lock
+end
+
+def timer_start
+ $loop = true
+ $m.unlock
+end
+
+def timer_reset
+ $time = "0.00"
+ $root.countframe.counter['text'] = $time
+end
+
+def timer_loop
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+ Tk.after(10,proc{timer_loop})
+end
+
+
+#
+# thread version
+#
+def timer_loop2
+ while true
+ $m.lock
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ sleep(0.01)
+ $m.unlock
+ end
+end
+
+#
+# TkAfter
+#
+def timer_loop3
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+end
+
+
+class CountFrame < TkFrame
+ attr_reader :counter
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ @counter = TkLabel.new(self,
+ 'text'=>$time,
+ 'relief'=>'raised')
+ @counter.pack('fill'=>'both')
+ self
+ end
+end
+
+
+class ButtonFrame < TkFrame
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+=begin
+ @stop = TkButton.new(self,
+ 'text'=>'Stop',
+ 'command'=>proc{timer_stop})
+ @start = TkButton.new(self,
+ 'text'=>'Start',
+ 'command'=>proc{timer_start})
+=end
+ @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled)
+ @start = TkButton.new(self, :text=>'Start', :state=>:normal)
+
+ @stop.command proc{
+ timer_stop
+ @start.state(:normal)
+ @stop.state(:disabled)
+ }
+ @start.command proc{
+ timer_start
+ @stop.state(:normal)
+ @start.state(:disabled)
+ }
+
+ @reset = TkButton.new(self,
+ 'text'=>'Reset',
+ 'command'=>proc{timer_reset})
+ for b in [@stop,@start,@reset]
+ b.pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+ end
+ end
+end
+
+
+class Timer < TkRoot
+ attr_reader :countframe
+
+ def initialize(*args)
+ super(*args)
+ @countframe = CountFrame.new(self)
+ @buttonframe = ButtonFrame.new(self)
+ for f in [@buttonframe,@countframe]
+ f.pack('side'=>'top', 'fill'=>'both')
+ end
+ self
+ end
+end
+
+
+$root = Timer.new
+
+#$thread = Thread.start{timer_loop2}
+#timer_loop
+TkAfter.new(10,-1,proc{timer_loop3}).start
+
+Tk.mainloop
diff --git a/ext/tk/sample/demos-jp/twind.rb b/ext/tk/sample/demos-jp/twind.rb
new file mode 100644
index 0000000000..2b228e4acd
--- /dev/null
+++ b/ext/tk/sample/demos-jp/twind.rb
@@ -0,0 +1,285 @@
+#
+# text (embedded windows) widget demo (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($twind_demo) && $twind_demo
+ $twind_demo.destroy
+ $twind_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$twind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+# frame À¸À®
+$twind_buttons = TkFrame.new($twind_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc{
+ tmppath = $twind_demo
+ $twind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc{showCode 'twind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+$twind_text = nil
+TkFrame.new($twind_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font,
+ 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+# ¥¿¥°À¸À®
+$tag_center = TkTextTag.new($twind_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag_buttons = TkTextTag.new($twind_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+# ¥Æ¥­¥¹¥È¤ÎÀ¸À®
+$twind_text.insert('end',
+ '¥Æ¥­¥¹¥Èwidget¾å¤Ë¾¤Îwidget¤òÁȤ߹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£')
+$twind_text.insert('end',
+ 'ÁȤ߹þ¤ß¥¦¥£¥ó¥É¥¦¤È¸Æ¤Ð¤ì¡¢Ç¤°Õ¤Îwidget¤¬²Äǽ¤Ç¤¹¡£')
+$twind_text.insert('end',
+ 'Î㤨¤Ð¡¢¤³¤³¤Ë2¤Ä¤Î¥Ü¥¿¥ówidget¤¬ÁȤ߹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£')
+$twind_text.insert('end', 'ºÇ½é¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤È¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'ON'
+ text '¥ª¥ó'
+ command proc{textWindOn $twind_text,$twind_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', "¤Ë¤·¤Þ¤¹¡£¤Þ¤¿2¤Ä¤á¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È\n")
+$twind_text.insert('end', '¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'OFF'
+ text '¥ª¥Õ'
+ command proc{textWindOff $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', '¤Ë¤·¤Þ¤¹¡£')
+
+$twind_text.insert('end', '¤â¤¦¤Ò¤È¤Ä¤ÎÎã¤Ç¤¹¡£')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text '¤³¤³¤ò¥¯¥ê¥Ã¥¯'
+ command proc{textWindPlot $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', '¤¹¤ë¤È¡¢x-y¥×¥í¥Ã¥È¤¬¤³¤³¤Ë¸½¤ì¤Þ¤¹¡£')
+$mark_plot = TkTextMark.new($twind_text, 'insert')
+$mark_plot.gravity='left'
+$twind_text.insert('end', '¥Þ¥¦¥¹¤Ç¥Ç¡¼¥¿¤òÉÁ²è¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text '¾Ãµî'
+ command proc{textWindDel $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', '¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¸µ¤ËÌá¤ê¤Þ¤¹¡£
+
+')
+
+$twind_text.insert('end', 'ÁȤ߹þ¤ß¥¦¥£¥ó¥É¥¦¤À¤±¤ò¥Æ¥­¥¹¥Èwidget¾å¤Ë¡¢¼ÂºÝ¤Î')
+$twind_text.insert('end', '¥Æ¥­¥¹¥È¤Ï¤Ê¤·¤ÇÁȤ߹þ¤à¤³¤È¤ÏÊØÍø¤Ç¤¹¡£')
+$twind_text.insert('end', '¤³¤Î¾ì¹ç¤Ï¡¢¥Æ¥­¥¹¥Èwidget¤Ï¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¤Î')
+$twind_text.insert('end', '¤è¤¦¤Ëưºî¤·¤Þ¤¹¡£Î㤨¤Ð¡¢¤³¤³¤Ë¤Ï¥Æ¥­¥¹¥Èwidget¤Ë')
+$twind_text.insert('end', '¤è¤Ã¤Æ¥Ü¥¿¥ó¤¬¤­¤ì¤¤¤Ëʤ٤é¤ì¤Æ¤¤¤Þ¤¹¡£')
+$twind_text.insert('end', '¤³¤ì¤é¤Î¥Ü¥¿¥ó¤ÇÇØ·Ê¿§¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹')
+$twind_text.insert('end', '("Default"¤Ç¸µ¤Î¿§¤ËÌ᤹¤³¤È¤¬¤Ç¤­¤Þ¤¹)¡£')
+$twind_text.insert('end', '"Short"¤È¤¤¤¦¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤Èʸ»úÎó¤ÎŤµ¤¬')
+$twind_text.insert('end', 'ÊѤï¤ê¤Þ¤¹¡£¤¹¤ë¤È¼«Æ°Åª¤Ë¥Æ¥­¥¹¥Èwidget¤¬')
+$twind_text.insert('end', '¥ì¥¤¥¢¥¦¥È¤òÀ°¤¨¤Æ¤¯¤ì¤Þ¤¹¡£')
+$twind_text.insert('end', '¤â¤¦°ìÅÙÆ±¤¸¥Ü¥¿¥ó¤ò²¡¤¹¤È¸µ¤ËÌá¤ê¤Þ¤¹¡£
+
+')
+
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {|b|
+ text '¥Ç¥Õ¥©¥ë¥È'
+ command proc{embDefBg $twind_text}
+ cursor 'top_left_arrow'
+ $tag_buttons.add('end')
+ },
+ 'padx'=>3 )
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkCheckButton.new($twind_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+# ¥á¥½¥Ã¥ÉÄêµÁ
+def textWindOn (w,f)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff (w)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+ w.xscrollcommand ''
+ w.wrap 'word'
+end
+
+def textWindPlot (t)
+ if (defined? $twind_plot) && (TkWinfo.exist?($twind_plot))
+ return
+ end
+
+ $twind_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+
+ TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind_plot.itembind('point', 'Any-Enter',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind_plot.itembind('point', 'Any-Leave',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y")
+ $twind_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind_plot.dtag 'selected'})
+ $twind_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y")
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot,"\n"
+ TkTextWindow.new($twind_text, $mark_plot, 'window'=>$twind_plot)
+ $tag_center.add $mark_plot
+ $twind_text.insert $mark_plot,"\n"
+end
+
+$embPlot = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def embPlotMove (w, x, y)
+ w.move 'selected', x - $embPlot['lastX'], y - $embPlot['lastY']
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def textWindDel (w)
+ if (defined? $twind_text) && TkWinfo.exist?($twind_plot)
+ $twind_text.delete $twind_plot
+ $twind_plot = nil
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot," "
+ end
+end
+
+def embDefBg (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/ext/tk/sample/demos-jp/twind2.rb b/ext/tk/sample/demos-jp/twind2.rb
new file mode 100644
index 0000000000..b634f07b4b
--- /dev/null
+++ b/ext/tk/sample/demos-jp/twind2.rb
@@ -0,0 +1,381 @@
+#
+# text (embedded windows) widget demo 2 (called by 'widget')
+#
+
+# toplevel widget ¤¬Â¸ºß¤¹¤ì¤Ðºï½ü¤¹¤ë
+if defined?($twind2_demo) && $twind2_demo
+ $twind2_demo.destroy
+ $twind2_demo = nil
+end
+
+# demo ÍѤΠtoplevel widget ¤òÀ¸À®
+$twind2_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows 2")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+# frame À¸À®
+$twind2_buttons = TkFrame.new($twind2_demo) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'¥³¡¼¥É»²¾È',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'twind2'}),
+ TkButton.new(frame, :text=>'ÊĤ¸¤ë',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $twind2_demo
+ $twind2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}
+$twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame À¸À®
+$twind2_text = nil
+TkFrame.new($twind2_demo, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
+ # 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'width'=>'70', 'height'=>35, 'wrap'=>'char',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+# ¥¿¥°À¸À®
+$tag2_center = TkTextTag.new($twind2_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag2_buttons = TkTextTag.new($twind2_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+# ¥Æ¥­¥¹¥È¤ÎÀ¸À®
+$twind2_text.insert('end', '¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ë¤Ï¿§¡¹¤Ê¼ïÎà¤Î¥¢¥¤¥Æ¥à')
+$twind2_text.insert('end', '¡ÊưŪ¤Ê¤â¤Î¤äÀÅŪ¤Ê¤â¤Î¤ÎξÊý¤¬¤¢¤ê¤Þ¤¹¡Ë¤ò')
+$twind2_text.insert('end', '¿ô¿¤¯´Þ¤á¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤½¤¦¤·¤¿¥¢¥¤¥Æ¥à¤Ï')
+$twind2_text.insert('end', '¹ÔÂØ¤¨¡¢¥¿¥Ö¡¢Ãæ±û·¤¨¤Ê¤É¤ÎÍÍ¡¹¤ÊÊýË¡¤Ç')
+$twind2_text.insert('end', 'ÇÛÃÖ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£')
+$twind2_text.insert('end', '²Ã¤¨¤Æ¡¢¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤ÎÆâÍÆÊª¤¬')
+$twind2_text.insert('end', '¥¦¥£¥ó¥É¥¦¥µ¥¤¥º¤ËÈæ¤Ù¤ÆÂ礭¤¹¤®¤ë¾ì¹ç¤Ç¤â')
+$twind2_text.insert('end', '¤¹¤Ù¤Æ¤ÎÊý¸þ¤Ë¥¹¥à¡¼¥º¤Ë¥¹¥¯¥í¡¼¥ë¤µ¤»¤Æ')
+$twind2_text.insert('end', '³Îǧ¤¹¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡£')
+$twind2_text.insert('end', "\n\n")
+$twind2_text.insert('end', '¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¾å¤Ë¤Ï¾¤Î¥¦¥£¥¸¥§¥Ã¥È¤ò')
+$twind2_text.insert('end', '´Þ¤á¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£¤³¤¦¤·¤¿¤â¤Î¤Ï')
+$twind2_text.insert('end', '¡ÖËä¤á¹þ¤ß¥¦¥£¥ó¥É¥¦¡×¤È¸Æ¤Ð¤ì¡¢¤½¤ÎÃæ¤Ë')
+$twind2_text.insert('end', '¤¤¤«¤Ê¤ë¥¦¥£¥¸¥§¥Ã¥È¤Ç¤âµÍ¤á¹þ¤à¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£')
+$twind2_text.insert('end', 'Î㤨¤Ð¡¤¤³¤³¤Ë¤Ï£²¤Ä¤Î')
+$twind2_text.insert('end', '¥Ü¥¿¥ó¥¦¥£¥¸¥§¥Ã¥È¤¬Ëä¤á¹þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£')
+$twind2_text.insert('end', 'ºÇ½é¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡¢')
+$twind2_text.insert('end', '¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò ')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ #text 'ON'
+ text '¥ª¥ó'
+ command proc{textWindOn2 $twind2_text,$twind2_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', "¤Ë¤·¤Þ¤¹¡£¤Þ¤¿¡¢£²¤Ä¤á¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È\n")
+$twind2_text.insert('end', '¿åÊ¿Êý¸þ¤Î¥¹¥¯¥í¡¼¥ë¤ò')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ #text 'OFF'
+ text '¥ª¥Õ'
+ command proc{textWindOff2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', "¤Ë¤·¤Þ¤¹¡£\n\n")
+
+$twind2_text.insert('end', '¼¡¤Ï¤â¤¦¤Ò¤È¤Ä¤ÎÎã¤Ç¤¹¡£')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text '¤³¤³¤ò¥¯¥ê¥Ã¥¯'
+ command proc{textWindPlot2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', '¤¹¤ë¤È¡¢x-y¥×¥í¥Ã¥È¤¬¤³¤³¤Ë¸½¤ì¤Þ¤¹¡£')
+$mark2_plot = TkTextMark.new($twind2_text, 'insert')
+$mark2_plot.gravity='left'
+$twind2_text.insert('end', '¥Þ¥¦¥¹¤Ç¥É¥é¥Ã¥°¤¹¤ë¤³¤È¤Ç¡¢')
+$twind2_text.insert('end', '¥×¥í¥Ã¥È¾å¤Î¥Ç¡¼¥¿ÅÀ¤ò°Üư¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text '¾Ãµî'
+ command proc{textWindDel2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', '¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¸µ¤ËÌá¤ê¤Þ¤¹¡£')
+$twind2_text.insert('end', "\n\n")
+
+$twind2_text.insert('end', 'ɽ¼¨¤¹¤ë¥Æ¥­¥¹¥È¤Ê¤·¤ËËä¤á¹þ¤ß¥¦¥£¥ó¥É¥¦¤À¤±¤ò')
+$twind2_text.insert('end', '¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ë´Þ¤á¤ë¤³¤È¤âÍ­ÍѤǤ·¤ç¤¦¡£')
+$twind2_text.insert('end', '¤³¤Î¾ì¹ç¡¢¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ï')
+$twind2_text.insert('end', '¥¸¥ª¥á¥È¥ê¥Þ¥Í¡¼¥¸¥ã¤Î¤è¤¦¤ËƯ¤­¤Þ¤¹¡£')
+$twind2_text.insert('end', 'Î㤨¤Ð¡¢¤³¤³¤Ë¤Ï¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ë')
+$twind2_text.insert('end', '¤è¤Ã¤Æ¥Ü¥¿¥ó¤¬¤­¤ì¤¤¤ËÀ°Îó¤·¤ÆÇÛÃÖ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£')
+$twind2_text.insert('end', '¤³¤ì¤é¤Î¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤Ç¡¢')
+$twind2_text.insert('end', '¤³¤Î¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤ÎÇØ·Ê¿§¤ò')
+$twind2_text.insert('end', 'ÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹("¥Ç¥Õ¥©¥ë¥È"¥Ü¥¿¥ó¤Ç')
+$twind2_text.insert('end', '¸µ¤Î¿§¤ËÌ᤹¤³¤È¤¬¤Ç¤­¤Þ¤¹)¡£')
+$twind2_text.insert('end', '"Short"¤È¤¤¤¦¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤Èʸ»úÎó¤ÎŤµ¤¬')
+$twind2_text.insert('end', 'ÊѤï¤ê¡¢¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤¬¼«Æ°Åª¤Ë')
+$twind2_text.insert('end', '¥ì¥¤¥¢¥¦¥È¤òÀ°¤¨¤ëÍͻҤò¸«¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£')
+$twind2_text.insert('end', '¤â¤¦°ìÅÙÆ±¤¸¥Ü¥¿¥ó¤ò²¡¤¹¤È¸µ¤ËÌá¤ê¤Þ¤¹¡£')
+$twind2_text.insert('end', "\n")
+
+btn_default = TkButton.new($twind2_text) {|b|
+ text '¥Ç¥Õ¥©¥ë¥È'
+ command proc{embDefBg2 $twind2_text}
+ cursor 'top_left_arrow'
+}
+TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3)
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkCheckButton.new($twind2_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind2_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+$tag2_buttons.add(btn_default, 'end')
+
+$text_normal2 = {}
+$text_normal2['border'] = $twind2_text.cget('borderwidth')
+$text_normal2['highlight'] = $twind2_text.cget('highlightthickness')
+$text_normal2['pad'] = $twind2_text.cget('padx')
+
+$twind2_text.insert('end', "\nborder width ¤ä highlightthickness, ")
+$twind2_text.insert('end', "padding ¤òÄ̾ï¤ÎÃͤ«¤éÊѹ¹¤¹¤ë¤³¤È¤â²Äǽ¤Ç¤¹¡£\n")
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigP2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallP2 $twind2_text
+ }))
+
+$twind2_text.insert('end', "\n\n¹¹¤Ë¥¤¥á¡¼¥¸¤â¥Æ¥­¥¹¥È¥¦¥£¥¸¥§¥Ã¥È¤Ë")
+$twind2_text.insert('end', "¤¦¤Þ¤¯ÇÛÃ֤Ǥ­¤Þ¤¹¡§")
+
+TkTextImage.new($twind2_text, 'end',
+ 'image'=>TkBitmapImage.new(:file=>[
+ $demo_dir, '..',
+ 'images', 'face.xbm'
+ ].join(File::Separator)))
+
+# ¥á¥½¥Ã¥ÉÄêµÁ
+def textWinBigB2(w)
+ w.borderwidth 15
+end
+def textWinSmallB2(w)
+ w.borderwidth $text_normal2['border']
+end
+def textWinBigH2(w)
+ w.highlightthickness 15
+end
+def textWinSmallH2(w)
+ w.highlightthickness $text_normal2['highlight']
+end
+def textWinBigP2(w)
+ w.configure(:padx=>15, :pady=>15)
+end
+def textWinSmallP2(w)
+ w.configure(:padx=>$text_normal2['pad'], :pady=>$text_normal2['pad'])
+end
+
+def textWindOn2 (w,f)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind2_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff2 (w)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+ w.xscrollcommand ''
+ #w.wrap 'word'
+ w.wrap 'char'
+end
+
+def textWindPlot2 (t)
+ if (defined? $twind2_plot) && (TkWinfo.exist?($twind2_plot))
+ return
+ end
+
+ $twind2_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ #font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ font = 'Helvetica 18'
+
+ TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind2_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind2_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind2_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind2_plot.itembind('point', 'Any-Enter',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind2_plot.itembind('point', 'Any-Leave',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind2_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y")
+ $twind2_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind2_plot.dtag 'selected'})
+ $twind2_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y")
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot,"\n"
+ TkTextWindow.new($twind2_text, $mark2_plot, 'window'=>$twind2_plot)
+ $tag2_center.add $mark2_plot
+ $twind2_text.insert $mark2_plot,"\n"
+end
+
+$embPlot2 = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown2 (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def embPlotMove2 (w, x, y)
+ w.move 'selected', x - $embPlot2['lastX'], y - $embPlot2['lastY']
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def textWindDel2 (w)
+ if (defined? $twind2_text) && TkWinfo.exist?($twind2_plot)
+ $twind2_text.delete $twind2_plot
+ $twind2_plot = nil
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot," "
+ end
+end
+
+def embDefBg2 (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/ext/tk/sample/demos-jp/unicodeout.rb b/ext/tk/sample/demos-jp/unicodeout.rb
new file mode 100644
index 0000000000..090cdf3059
--- /dev/null
+++ b/ext/tk/sample/demos-jp/unicodeout.rb
@@ -0,0 +1,115 @@
+# unicodeout.rb --
+#
+# This demonstration script shows how you can produce output (in label
+# widgets) using many different alphabets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($unicodeout_demo) && $unicodeout_demo
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+end
+
+$unicodeout_demo = TkToplevel.new {|w|
+ title("Unicode Label Demonstration")
+ iconname("unicodeout")
+ positionWindow(w)
+}
+
+TkLabel.new($unicodeout_demo,
+ :font=>$font, :wraplength=>'5.4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+¤³¤ì¤Ï¡¤Tk¤Ë¤ª¤±¤ëÈó²¤ÊÆÊ¸»ú½¸¹ç¤òÍѤ¤¤ë¸À¸ì¤ËÂФ¹¤ë¥µ¥Ý¡¼¥È¤Ë¤Ä¤¤¤Æ¤Î\
+¥µ¥ó¥×¥ë¤Ç¤¹¡¥¤¿¤À¤·¡¤²¼¤Îɽ¼¨¤Ë¤ª¤¤¤Æ¤¢¤Ê¤¿¤¬¼ÂºÝ¤Ë¤É¤Î¤è¤¦¤Êɽ¼¨¤ò\
+Ìܤˤ¹¤ë¤«¤Ï¡¤¤¢¤Ê¤¿¤Î´Ä¶­¤Ë¤É¤Î¤è¤¦¤Êʸ»ú½¸¹ç¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¤«¤Ë\
+Â礭¤¯°Í¸¤·¤Þ¤¹¡¥¤Þ¤¿¡¤ÂоݤȤʤëʸ»ú½¸¹ç¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë\
+¤É¤Î¤è¤¦¤Êɽ¼¨¤¬¤Ê¤µ¤ì¤ë¤«¤â¤¢¤Ê¤¿¤Î´Ä¶­¼¡Âè¤Ç¤¹¡¥\
+¡Ö¥³¡¼¥É»²¾È¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¥½¡¼¥¹¤òɽ¼¨¤·¡¤\
+Unicodeout_SampleFrame¥¯¥é¥¹¤Î@@font¤ÎÄêµÁ¤ò½ñ¤­´¹¤¨¤Æ\
+(¥Õ¥¡¥¤¥ë¤ÎÆâÍÆ¤ÏÊѹ¹¤µ¤ì¤Þ¤»¤ó)\
+¡ÖºÆ¼Â¹Ô¡×¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ò»î¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡¥
+¥¹¥¯¥ê¥×¥È¤¬²ÄÈÂÀ­¤ò»ý¤Ä¤è¤¦¤Ë¡¤Ê¸»úÎó¤Ï\\uXXXX¤È¤¤¤¦\
+Tcl¤Î¥¨¥¹¥±¡¼¥×ɽ¸½¤òÍѤ¤¤¿UNICODEʸ»úÎó¤Ç½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡¥\
+ʸ»úÎó¤Ï¡¤Tk::UTF8_String¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ¡¤\
+¡ÖUTF8·Á¼°¤Îʸ»úÎó¤Ç¤¢¤ë¡×¤È¤¤¤¦\
+¥¨¥ó¥³¡¼¥É¾ðÊóÉÕ¤­¤Îʸ»úÎ󥪥֥¸¥§¥¯¥È\
+(Tcl¤Î¥¨¥¹¥±¡¼¥×ɽ¸½¤ÎÊÑ´¹ºÑ¤ß)¤ËÊÑ´¹¤·¤Æ\
+¥é¥Ù¥ë¥¦¥£¥¸¥§¥Ã¥È¤ËÅϤ·¤Æ¤¤¤ëÅÀ¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡¥
+EOL
+#'
+
+TkFrame.new($unicodeout_demo){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'ÊĤ¸¤ë', :width=>15, :command=>proc{
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'¥³¡¼¥É»²¾È', :width=>15, :command=>proc{
+ showCode 'unicodeout'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+wait_msg = TkLabel.new($unicodeout_demo,
+ :text=>"¥Õ¥©¥ó¥ÈÆÉ¤ß¹þ¤ß¤Î´°Î»¤Þ¤Ç" +
+ "¤·¤Ð¤é¤¯¤ªÂÔ¤Á²¼¤µ¤¤¡¥¡¥¡¥",
+ :font=>"Helvetica 12 italic").pack
+
+class Unicodeout_SampleFrame < TkFrame
+ @@font = $font
+ # @@font = 'Helvetica 14'
+ # @@font = 'Courier 12'
+ # @@font = 'clearlyu 16'
+ # @@font = 'fixed 12'
+ # @@font = 'Times 12'
+ # @@font = 'Newspaper 12'
+ # @@font = '{New century schoolbook} 12'
+
+ def initialize()
+ super($unicodeout_demo)
+ grid_columnconfig(1, :weight=>1)
+ end
+
+ def add_sample(lang, *args)
+ sample_txt = Tk::UTF8_String(args.join(''))
+ l = TkLabel.new(self, :font=>@@font, :text=>lang+':',
+ :anchor=>:nw, :pady=>0)
+ #s = TkLabel.new(self, :font=>@@font, :text=>sample_txt,
+ s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt,
+ :anchor=>:nw, :width=>30, :pady=>0)
+ Tk.grid(l, s, :sticky=>:ew, :pady=>0)
+ l.grid_config(:padx, '1m')
+ end
+end
+f = Unicodeout_SampleFrame.new
+f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
+
+# Processing when some characters are missing might take a while, so make
+# sure we're displaying something in the meantime...
+
+oldCursor = $unicodeout_demo.cursor
+$unicodeout_demo.cursor('watch')
+Tk.update
+
+f.add_sample('Arabic',
+ '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94',
+ '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D')
+f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57')
+f.add_sample('Simpl. Chinese', '\u6C49\u8BED')
+f.add_sample('Greek',
+ '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ',
+ '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1')
+f.add_sample('Hebrew',
+ '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ',
+ '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9')
+f.add_sample('Japanese',
+ '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ',
+ '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA')
+f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00')
+f.add_sample('Russian',
+ '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ',
+ '\u044F\u0437\u044B\u043A')
+
+wait_msg.destroy
+$unicodeout_demo.cursor(oldCursor)
diff --git a/ext/tk/sample/demos-jp/vscale.rb b/ext/tk/sample/demos-jp/vscale.rb
new file mode 100644
index 0000000000..86f6f7cdee
--- /dev/null
+++ b/ext/tk/sample/demos-jp/vscale.rb
@@ -0,0 +1,78 @@
+require "tkcanvas"
+
+if defined?($vscale_demo) && $vscale_demo
+ $vscale_demo.destroy
+ $vscale_demo = nil
+end
+
+$vscale_demo = TkToplevel.new {|w|
+ title("Vertical Scale Demonstration")
+ iconname("vscale")
+}
+positionWindow($vscale_demo)
+
+msg = TkLabel.new($vscale_demo) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+# text "²¼¤Ë¤ÏÌð°õ¤¬1¤Ä¤È¾èľ¤Ê¥¹¥±¡¼¥ë¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\
+#¥¹¥±¡¼¥ë¾å¤Ç¥Þ¥¦¥¹¥Ü¥¿¥ó1¤ò¥¯¥ê¥Ã¥¯¡¢¤Þ¤¿¤Ï¥É¥é¥Ã¥°¤¹¤ë¤È\
+#Ìð°õ¤ÎŤµ¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£"
+ text "¤Ë¤Ï¥Ð¡¼¤È½Ä·¿¤Î¥¹¥±¡¼¥ë¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥¹¥±¡¼¥ë¤Ç¥Þ¥¦¥¹¤Î¥Ü¥¿¥ó1 ¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤«¥É¥é¥Ã¥°¤·¤Æ¥Ð¡¼¤Î¹â¤µ¤òÊѤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£½ª¤Ã¤¿¤é¡Öλ²ò¡×¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£"
+}
+msg.pack('side'=>'top', 'padx'=>'.5c')
+
+TkFrame.new($vscale_demo) {|frame|
+ TkButton.new(frame) {
+ #text 'λ²ò'
+ text 'ÊĤ¸¤ë'
+ command proc {
+ tmppath = $vscale_demo
+ $vscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '¥³¡¼¥É»²¾È'
+ command proc { showCode 'vscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+TkFrame.new($vscale_demo) {|frame|
+ borderwidth 10
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, 0, 0, 1, 1, 2, 2) {
+ fill 'SeaGreen3'
+ tags 'poly'
+ }
+ TkcLine.new(c, 0, 0, 1, 1, 2, 2, 0, 0) {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'left', 'anchor'=>'nw', 'fill'=>'y')
+ scale = TkScale.new(frame) {
+ orient 'vertical'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setHeight(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'left', 'anchor'=>'ne')
+ scale.set 75
+}.pack
+
+
+def setHeight(w, height)
+ height = height + 21
+ y2 = height - 30
+ if y2 < 21
+ y2 = 21
+ end
+ w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+ w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+end
diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget
new file mode 100644
index 0000000000..e8196aec8f
--- /dev/null
+++ b/ext/tk/sample/demos-jp/widget
@@ -0,0 +1,848 @@
+#!/usr/bin/env ruby
+
+# ´Á»ú¥³¡¼¥ÉÀßÄê ( tk.rb ¤Î¥í¡¼¥É»þ¤Î encoding ¿äÄê/ÀßÄê¤Ë»È¤ï¤ì¤ë )
+$KCODE = 'euc'
+
+# tk ´Ø·¸¥é¥¤¥Ö¥é¥ê¤ÎÆÉ¤ß¹þ¤ß
+require 'tk'
+# require 'tkafter'
+
+# widget demo directory °ÌÃÖ¤Î³ÍÆÀ
+$demo_dir = File.dirname($0)
+
+# root ¤ÎÀ¸À®
+$root = TkRoot.new{title "Widget Demonstration"}
+
+# tk ¥Ð¡¼¥¸¥ç¥ó¤Î¼èÆÀ
+$tk_version = Tk::TK_VERSION
+$tk_major_ver, $tk_minor_ver = $tk_version.split('.').map{|n| n.to_i}
+$tk_patchlevel = Tk::TK_PATCHLEVEL
+
+# tcl_platform ¾ðÊó¤Ø¤Î¥¢¥¯¥»¥¹¥ª¥Ö¥¸¥§¥¯¥È
+$tk_platform = TkVarAccess.new('tcl_platform')
+
+# ¥Õ¥©¥ó¥ÈÀßÄê
+#######
+case($tk_version)
+when /^4.*/
+ $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil)
+ knjfont = '-*--16-*-jisx0208.1983-0'
+ $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
+ knjfont)
+ TkOption.add('*kanjiFont', knjfont, 'startupFile')
+ $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
+ '-*--24-*-jisx0208.1983-0')
+
+#when '8.0'
+# $font = TkFont.new('Helvetica -12')
+# $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12')
+# TkOption.add('*kanjiFont', knjfont, 'startupFile')
+# $msg_kanji_font=TkFont.new('Helvetica 16', 'Gothic 16 bold')
+
+when /^8.*/
+ $font = TkFont.new('Helvetica -12')
+ $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12')
+ TkOption.add('*kanjiFont', knjfont, 'startupFile')
+ $msg_kanji_font=TkFont.new('Helvetica 16', 'Gothic 16 bold')
+
+else
+ $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil)
+ knjfont = '-*--16-*-jisx0208.1983-0'
+ $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
+ knjfont)
+ TkOption.add('*kanjiFont', knjfont, 'startupFile')
+ $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
+ '-*--24-*-jisx0208.1983-0')
+end
+#######
+
+# ¥¤¥á¡¼¥¸ÀßÄê
+$image = {}
+
+if $tk_major_ver >= 8
+$image['refresh'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zCpnKdb/1z9mPypbKBtLGy9NMPL/9Or+6+P+4j1Y
+ PwQKBP7//xMLFAYBCAEBASH5BAEAAAAALAAAAAAQABAAAwR0EAD3Gn0Vyw0e
+ ++CncU7IIAezMA/nhUqSLJizvSdCEEjy2ZIV46AwDAoDHwPYGSoEiUJAAGJ6
+ EDHBNCFINW5OqABKSFk/B9lUa94IDwIFgewFMwQDQwCZQCztTgM9Sl8SOEMG
+ KSAthiaOjBMPDhQONBiXABEAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['view'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zP///8DAwICAgH9/fwAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAwRIcMhJB7h3hM33
+ KFjWdQQYap1QrCaGBmrRrS4nj5b53jOgbwXBKGACoYLDIuAoHCmZyYvR1rT5
+ RMAq8LqcIYGsrjPsW1XOmFUEADs=
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['delete'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAOAKEAAIQAAO/n3v///////yH5BAEKAAIALAAAAAAQAA4AAAIm
+ lI9pAKHbIHNoVhYhTdjlJ2AWKG2g+CldmB6rxo2uybYhbS80eRQAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['print'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK
+ UlpChFpCjFpGkFpSc1paa2NKc2NKnGNja2tapWtjc29KnHNanHNjc3NjrXNr
+ jHNrnHNzc3tjpXtrtXtzhICAgIRzvYSEjIZzqox7tYyEnIyMjJSEtZSEvZSM
+ lJyMtZyMvZyUlJyUrZyUvZycnKWctaWlpa2czq2lzrWtvbWtzrW1tb21xr21
+ 1sa9zs693s7OztbO3tbO597W1t7W7+fe7+fn5////+/n7+/v7+/v9////wAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAEEALAAAAAAaABMAQAj/AIMIHBhkg0GC
+ CBMGIQEiQgseQT4oeCBBAokgRYYQ0JBixg8hRIiUUEBBYYmTByBwiCBCRYwH
+ CxY8cKFw4AogRXLqLAJkQ80gCBBg3BkxZswTNGh4MGqgQQUMJRHCwMkTSE+D
+ Pn8eCKBhxIMhO3ei2OHDBw6sWSlMMMoWgwwfMDZI8GBjx44NARZwEGGi5MkS
+ PcIWKRGz5YgLbAco+KkQBQoJIRgjdGEVq+SaJajqtNrzMgsPCmoIzqmDgmWE
+ KOBuUKAAwYabYTfs4OHjY0giGyhk4MAWRI4eKyRQqPgggYUXPH4A+XBAgwoK
+ DiIsCFxjA9sFEVQQCRJCAYAFDJxiKhAxvMTonEFimrhhYinTBgWiCvxLNX3M
+ DkkpsKV5OYhjBxCMYAICAigUEAA7
+EOD
+end
+
+# ¥á¥Ë¥å¡¼ÀßÄê
+TkMenubar.new($root,
+ [[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Meta-Q']
+ ]]).pack('side'=>'top', 'fill'=>'x')
+$root.bind('F1', proc{aboutBox})
+$root.bind('Meta-q', proc{exit})
+
+=begin
+TkFrame.new($root){|frame|
+ TkMenubutton.new(frame){|button|
+ m = TkMenu.new(button) {
+ add 'command', 'label'=>'Quit', 'command'=>proc{exit}, 'underline'=>0
+ }
+ menu m
+ text 'File'
+ underline 0
+ }.pack('side'=>'left')
+}.pack('side'=>'top', 'fill'=>'x')
+=end
+
+# ¥Æ¥­¥¹¥È¥Ü¥Ã¥¯¥¹¤ÎÀ¸À®
+if $tk_version =~ /^4\.[01]/
+ scr = TkScrollbar.new($root, 'orient'=>'vertical')
+ txt = TkText.new($root) {
+ #wrap 'word'
+ wrap 'char'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+ scr.pack('side'=>'right', 'fill'=>'y')
+ txt.pack('expand'=>'yes', 'fill'=>'both')
+else
+ textFrame = TkFrame.new($root)
+ scr = TkScrollbar.new($root, 'orient'=>'vertical',
+ 'highlightthickness'=>0, 'takefocus'=>1) {
+ pack('in'=>textFrame, 'side'=>'right', 'fill'=>'y', 'padx'=>1)
+ }
+ txt = TkText.new($root) {
+ #wrap 'word'
+ wrap 'char'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ highlightthickness 0
+ padx 4
+ pady 2
+ takefocus 0
+ bd 1
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both', 'padx'=>1)
+ txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both')
+# textFrame.pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>2)
+ textFrame.pack('expand'=>'yes', 'fill'=>'both')
+
+ statusBar = TkFrame.new($root) {|f|
+ $statusBarLabel = \
+ TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
+ TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') \
+ .pack('side'=>'left', 'padx'=>2)
+ }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+end
+
+# ¥Æ¥­¥¹¥È¥¿¥°ÀßÄê
+tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+#tag_kanji_title = TkTextTag.new(txt, 'kanjifont'=>$msg_kanji_font)
+#tag_middle = TkTextTag.new(txt, 'kanjifont'=>$kanji_font)
+tag_kanji_title = TkTextTag.new(txt, 'font'=>$msg_kanji_font)
+tag_middle = TkTextTag.new(txt, 'font'=>$kanji_font)
+tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c')
+
+if TkWinfo.depth($root) == 1
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ tag_hot = TkTextTag.new(txt, 'background'=>'black', 'foreground'=>'white')
+else
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'blue', 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'#303080', 'underline'=>1)
+# tag_hot = TkTextTag.new(txt, 'relief'=>'raised', 'borderwidth'=>1,
+# 'background'=>'SeaGreen3')
+ tag_hot = TkTextTag.new(txt, 'borderwidth'=>1, 'foreground'=>'red')
+end
+
+#tag_demo.bind('Button-1', proc{invoke txt, txt.index('current')})
+tag_demo.bind('ButtonRelease-1',
+ proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y')
+
+lastLine = TkVariable.new("")
+newLine = TkVariable.new("")
+tag_demo.bind('Enter', proc{|x,y|
+ lastLine.value = txt.index("@#{x},#{y} linestart")
+ tag_hot.add(lastLine.value, "#{lastLine.value} lineend")
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+tag_demo.bind('Leave',
+ proc{
+ tag_hot.remove('1.0','end')
+ txt.configure('cursor','xterm')
+ $statusBarLabel.configure('text'=>"")
+ })
+tag_demo.bind('Motion', proc{|x, y|
+ newLine.value = txt.index("@#{x},#{y} linestart")
+ if newLine.value != lastLine.value
+ tag_hot.remove('1.0','end')
+ lastLine.value = newLine.value
+ if ( txt.tag_names("@#{x},#{y}").find{|t|
+ t.kind_of?(String) && t =~ /^demo-/
+ } )
+ tag_hot.add(lastLine.value,
+ "#{lastLine.value} lineend -1 chars")
+ end
+ end
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+
+# ¥Æ¥­¥¹¥ÈÀ¸À®
+txt.insert('end', 'Ruby/Tk : Widget', tag_title)
+#txt.insert('end', " ¥Ç¥â¥ó¥¹¥È¥ì¡¼¥·¥ç¥ó\n", tag_middle)
+txt.insert('end', " ¥Ç¥â¥ó¥¹¥È¥ì¡¼¥·¥ç¥ó\n", tag_kanji_title)
+txt.insert('end', <<"EOT")
+
+¤³¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢Tk Widget ¤òÍѤ¤¤Æ¤É¤Î¤è¤¦¤Ê¤³¤È¤¬¤Ç¤­¤ë¤«\
+¤ò¼¨¤¹¤¿¤á¤Î¡¢¤¤¤¯¤Ä¤«¤Î¾®¤µ¤Ê¥¹¥¯¥ê¥×¥È¤ËÂФ¹¤ë¥Õ¥í¥ó¥È¥¨¥ó¥É¤òÄó\
+¶¡¤·¤Æ¤¤¤Þ¤¹¡£°Ê²¼¤Ë½çÈ֤˵󤲤é¤ì¤Æ¤¤¤ë¥Ç¥â¥ó¥¹¥È¥ì¡¼¥·¥ç¥ó¤ò¼Â¹Ô\
+¤¹¤ë¤Ë¤Ï¥Þ¥¦¥¹¤Ç¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£¥Ç¥â¥ó¥¹¥È¥ì¡¼¥·¥ç¥ó¤Î¥¦¥£¥ó\
+¥É¥¦¤¬¸½¤ì¤ë¤È¡¢¥Ç¥â¥ó¥¹¥È¥ì¡¼¥·¥ç¥ó¤òÀ¸À®¤·¤¿ Ruby/Tk ¤Î¥³¡¼¥É¤ò¸«\
+¤ë¤¿¤á¤Ë¡¢"¥³¡¼¥É»²¾È"¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤¢¤Ê¤¿¤¬\
+˾¤à¤Ê¤é¡¢¤½¤Î¥³¡¼¥É¤ò½¤Àµ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£½¤Àµ¤·¤¿¥³¡¼¥É¤Ç¥Ç¥â\
+¥ó¥¹¥È¥ì¡¼¥·¥ç¥ó¤òºÆ¼Â¹Ô¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¥³¡¼¥É¤¬½ñ¤«¤ì¤¿¥¦¥£¥ó¥É¥¦¤Ë\
+¤¢¤ë"¥Ç¥âºÆ¼Â¹Ô" ¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£
+
+°ìÉô¤Î¥Ç¥â¤Ç¤Ï¡¤Èæ³ÓŪºÇ¶á¤Î¥Ð¡¼¥¸¥ç¥ó¤Î Tk ¤Ç¤Ê¤±¤ì¤Ð¥µ¥Ý¡¼¥È¤·¤Æ\
+¤¤¤Ê¤¤µ¡Ç½¤ò»È¤Ã¤Æ¼ÂÁõ¤·¤Æ¤¤¤Þ¤¹(Î㤨¤Ð Tk8.4 °Ê¾å¤Ê¤É)¡¥¤½¤Î¤¿¤á¡¤\
+¤½¤¦¤·¤¿µ¡Ç½¤ò»ý¤¿¤Ê¤¤ Tk ¥é¥¤¥Ö¥é¥ê¤ò»È¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¤¤½¤¦¤·¤¿\
+¥Ç¥â¤ÏÀµ¤·¤¯Æ°¤­¤Þ¤»¤ó¡¥¤½¤Î¤è¤¦¤Êµ¡Ç½¤¬É¬ÍפǤ¢¤ì¤Ð¡¤¤½¤ì¤ò¥µ¥Ý¡¼¥È\
+¤·¤Æ¤¤¤ë Tk ¥é¥¤¥Ö¥é¥ê¤ò»È¤¦¤è¤¦¤Ë¡¤tcltklib ¤ò¥³¥ó¥Ñ¥¤¥ë¤·¤Ê¤ª¤·¤Æ\
+¤¯¤À¤µ¤¤¡¥
+
+
+EOT
+
+#txt.insert('end',"¥é¥Ù¥ë, ¥Ü¥¿¥ó, ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó, ¥é¥¸¥ª¥Ü¥¿¥ó\n",tag_middle)
+txt.insert('end', "¥é¥Ù¥ë, ¥Ü¥¿¥ó, ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó, ¥é¥¸¥ª¥Ü¥¿¥ó\n",
+ tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ¥é¥Ù¥ë (¥Æ¥­¥¹¥È, ¥Ó¥Ã¥È¥Þ¥Ã¥×)\n",
+ tag_demo, "demo-label")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¥é¥Ù¥ë¤ÈUNICODE¥Æ¥­¥¹¥È (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n", tag_demo, "demo-unicodeout")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¥Ü¥¿¥ó \n", tag_demo, "demo-button")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó (Ê£¿ô¤òÁªÂò²Äǽ)\n",
+ tag_demo, "demo-check")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. £³¾õÂÖ¥Á¥§¥Ã¥¯¥Ü¥¿¥ó (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-check2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. ¥é¥¸¥ª¥Ü¥¿¥ó (Ǥ°Õ¤Î°ì¤Ä¤òÁªÂò²Äǽ)\n",
+ tag_demo, "demo-radio")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. ¥é¥¸¥ª¥Ü¥¿¥ó (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-radio2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. £³¾õÂ֥饸¥ª¥Ü¥¿¥ó (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-radio3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. ¥Ü¥¿¥ó¤Çºî¤é¤ì¤¿15-¥Ñ¥º¥ë¥²¡¼¥à\n",
+ tag_demo, "demo-puzzle")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "10. ¥Ó¥Ã¥È¥Þ¥Ã¥×¤ò»ÈÍѤ·¤¿¥¢¥¤¥³¥ó¥Ü¥¿¥ó\n",
+ tag_demo, "demo-icon")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "11. ²èÁü¤òɽ¼¨¤¹¤ëÆó¤Ä¤Î¥é¥Ù¥ë\n",
+ tag_demo, "demo-image1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "12. ²èÁü¤ò¸«¤ë¤¿¤á¤Î´Êñ¤Ê¥æ¡¼¥¶¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹\n",
+ tag_demo, "demo-image2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "13. ²èÁü¤ò¸«¤ë¤¿¤á¤Î´Êñ¤Ê¥æ¡¼¥¶¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-image3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "14. ¥é¥Ù¥ëÉÕ¤­¥Õ¥ì¡¼¥à (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-labelframe")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¥ê¥¹¥È¥Ü¥Ã¥¯¥¹\n", tag_middle)
+txt.insert('end', "¥ê¥¹¥È¥Ü¥Ã¥¯¥¹\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ÅÔÆ»Éܸ©.\n", tag_demo, "demo-states")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¿§: ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¤¿¤á¤ÎÇÛ¿§¤òÊѤ¨¤ë\n",
+ "#{tag_demo.id} demo-colors")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ³Ê¸À½¸\n", tag_demo, "demo-sayings")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¥¨¥ó¥È¥ê¤È¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹\n", tag_middle)
+txt.insert('end', "¥¨¥ó¥È¥ê\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤Ê¤·\n", tag_demo, "demo-entry1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤¢¤ê\n", tag_demo, "demo-entry2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ǧ¾Ú½èÍýÉÕ¤­¤Î¥¨¥ó¥È¥ê¥Ü¥Ã¥¯¥¹¤È¥Ñ¥¹¥ï¡¼¥É¥Õ¥£¡¼¥ë¥É (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-entry3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ¥¹¥Ô¥ó¥Ü¥Ã¥¯¥¹ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-spin")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ´Êñ¤Ê¥Õ¥©¡¼¥à\n", tag_demo, "demo-form")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¥Æ¥­¥¹¥È\n", tag_middle)
+txt.insert('end', "¥Æ¥­¥¹¥È\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ´ðËÜŪ¤Ê¥Æ¥­¥¹¥È\n", tag_demo, "demo-text")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ɽ¼¨¥¹¥¿¥¤¥ë.\n", tag_demo, "demo-style")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¥Ï¥¤¥Ñ¡¼¥Æ¥­¥¹¥È(¥¿¥°¥Ð¥¤¥ó¥É).\n",
+ tag_demo, "demo-bind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ¥¦¥£¥ó¥É¥¦¤òËä¤á¹þ¤ó¤À¥Æ¥­¥¹¥È\n",
+ tag_demo, "demo-twind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ¥¦¥£¥ó¥É¥¦¤òËä¤á¹þ¤ó¤À¥Æ¥­¥¹¥È (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-twind2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. ¸¡º÷\n", tag_demo, "demo-search")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¥­¥ã¥ó¥Ð¥¹\n", tag_middle)
+txt.insert('end', "¥­¥ã¥ó¥Ð¥¹\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ¥¢¥¤¥Æ¥à¤Î·¿\n", tag_demo, "demo-items")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. 2 ¼¡¸µ¤Î¥×¥í¥Ã¥È\n", tag_demo, "demo-plot")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¥Æ¥­¥¹¥È\n", tag_demo, "demo-ctext")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Ìð°õ¤Î·Á\n", tag_demo, "demo-arrow")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ¥ë¡¼¥é¡¼\n", tag_demo, "demo-ruler")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. ¥Õ¥í¥¢¥×¥é¥ó\n", tag_demo, "demo-floor")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. ¥Õ¥í¥¢¥×¥é¥ó (°Û¤Ê¤ë¥­¥ã¥ó¥Ð¥¹¥¢¥¤¥Æ¥àºîÀ®ÊýË¡¤ò»ÈÍÑ)\n", tag_demo, "demo-floor2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. ¥¹¥¯¥í¡¼¥ë²Äǽ¤Ê¥­¥ã¥ó¥Ð¥¹\n",
+ tag_demo, "demo-cscroll")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¥¹¥±¡¼¥ë\n", tag_middle)
+txt.insert('end', "¥¹¥±¡¼¥ë\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ¿âľ\n", tag_demo.id, "demo-vscale")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¿åÊ¿\n", tag_demo.id, "demo-hscale")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "¥Ú¥¤¥ó¥É¥¦¥£¥ó¥É¥¦\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ¿åÊ¿Êý¸þ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo.id, "demo-paned1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¿âľÊý¸þ (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo.id, "demo-paned2")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¥á¥Ë¥å¡¼\n", tag_middle)
+txt.insert('end', "¥á¥Ë¥å¡¼\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¤ò´Þ¤ó¤À¥¦¥£¥ó¥É¥¦\n",
+ tag_demo, "demo-menu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¥á¥Ë¥å¡¼¤È¥«¥¹¥±¡¼¥É¤ò´Þ¤ó¤À¥¦¥£¥ó¥É¥¦ (Tk8.x ÀìÍÑ)\n",
+ tag_demo, "demo-menu8x")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¡· (µ¡Ç½¤ËÂбþ¤·¤¿¥Ð¡¼¥¸¥ç¥ó¤ÎTk¤¬É¬Í×)\n",
+ tag_demo, "demo-menu84")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ¥á¥Ë¥å¡¼¥Ü¥¿¥ó (Tk8.x ÀìÍÑ)\n",
+ tag_demo, "demo-menubu")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¥À¥¤¥¢¥í¥°¥¦¥£¥ó¥É¥¦\n", tag_middle)
+txt.insert('end', "¥À¥¤¥¢¥í¥°¥¦¥£¥ó¥É¥¦\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ¥á¥Ã¥»¡¼¥¸¥Ü¥Ã¥¯¥¹\n", tag_demo, "demo-msgbox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¥Õ¥¡¥¤¥ëÁªÂò¥À¥¤¥¢¥í¥°\n", tag_demo, "demo-filebox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¿§ÁªÂò¥À¥¤¥¢¥í¥°\n", tag_demo, "demo-clrpick")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "¤½¤Î¾\n", tag_middle)
+txt.insert('end', "¤½¤Î¾\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ÁȤ߹þ¤ß¤Î¥Ó¥Ã¥È¥Þ¥Ã¥×\n", tag_demo, "demo-bitmap")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ¥â¡¼¥À¥ë¥À¥¤¥¢¥í¥°(¥í¡¼¥«¥ë¥°¥é¥Ö)\n",
+ tag_demo, "demo-dialog1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ¥â¡¼¥À¥ë¥À¥¤¥¢¥í¥°(¥°¥í¡¼¥Ð¥ë¥°¥é¥Ö)\n",
+ tag_demo, "demo-dialog2")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.state('disabled')
+scr.focus
+
+################################
+# method ÄêµÁ
+################################
+def positionWindow(w)
+ w.geometry('+300+300')
+end
+
+# ¿Æ¥¦¥£¥¸¥§¥Ã¥È¤È¡¤ÊÑ¿ô̾¤È TkVariable ¤È¤ÎÁÈ(ÇÛÎó)¤ÎʤӤòÅϤ¹
+$showVarsWin = {}
+def showVars1(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ top = TkToplevel.new(parent) {|w|
+ title "Variable values"
+ TkLabel.new(w) {
+ text "ÊÑ¿ôÃÍ:"
+ width 20
+ anchor 'center'
+ font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ }.pack('side'=>'top', 'fill'=>'x')
+ len = 1
+ args.each{|vnam,vbody|
+ len = vnam.to_s.length if vnam.to_s.length > len
+ }
+ args.each{|vnam,vbody|
+ TkFrame.new(w){|f|
+ #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left')
+ TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left')
+ TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\
+ .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+ }.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x')
+ }
+ TkButton.new(w) {
+ text "λ²ò"
+ command proc{w.destroy}
+ }.pack('side'=>'bottom', 'pady'=>2)
+ }
+ $showVarsWin[parent.path] = top
+end
+
+def showVars2(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ $showVarsWin[parent.path] = TkToplevel.new(parent) {|w|
+ title "Variable values"
+
+ TkLabelFrame.new(w, :text=>"ÊÑ¿ôÃÍ:",
+ :font=>{:family=>'Helvetica', :size=>14}){|f|
+ args.each{|vnam,vbody|
+ TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'),
+ TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'),
+ :padx=>2, :pady=>2, :sticky=>'w')
+ }
+
+ f.grid(:sticky=>'news', :padx=>4)
+ f.grid_columnconfig(1, :weight=>1)
+ f.grid_rowconfig(100, :weight=>1)
+ }
+ TkButton.new(w, :text=>"λ²ò", :width=>8, :default=>:active,
+ :command=>proc{w.destroy}){|b|
+ w.bind('Return', proc{b.invoke})
+ w.bind('Escape', proc{b.invoke})
+
+ b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4])
+ }
+ w.grid_columnconfig(0, :weight=>1)
+ w.grid_rowconfig(0, :weight=>1)
+ }
+end
+
+if $tk_major_ver < 8
+ alias showVars showVars1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 4
+ alias showVars showVars1
+else # ver >= 8.4
+ alias showVars showVars2
+end
+
+# ¥Æ¥­¥¹¥È¾å¤Ç¤Î click ¤ËÂФ¹¤ëưºî
+def invoke (txt, index)
+ tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ return unless tag
+ cursor = txt.cget('cursor')
+ txt.cursor('watch')
+ Tk.update
+# eval `cat #{tag[5..-1]}.rb`
+# eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb`
+ eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join
+ Tk.update
+# txt.cursor('xterm')
+ txt.cursor(cursor)
+
+ $tag_visited.add("#{index} linestart +1 chars", "#{index} lineend +1 chars")
+end
+
+# ¾õÂÖɽ¼¨
+def showStatus (txt, index)
+ tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ cursor = txt.cget('cursor')
+ unless tag
+ $statusBarLabel.configure('text', " ")
+ newcursor = 'xterm'
+ else
+ demoname = tag[5..-1]
+ $statusBarLabel.configure('text',
+ "¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à \"#{demoname}\" ¤Î¼Â¹Ô ")
+ newcursor = 'hand2'
+ end
+ txt.configure('cursor'=>newcursor) if cursor != newcursor
+end
+
+# ¥½¡¼¥¹¥³¡¼¥É¤Îɽ¼¨
+def showCode1(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ f = TkFrame.new($code_window)
+ TkButton.new(f) {
+ #text "λ²ò"
+ text "ÊĤ¸¤ë"
+ command proc{
+ $code_window.destroy
+ $code_window = nil
+ }
+ }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
+ TkButton.new(f) {
+ text "ºÆ¼Â¹Ô"
+ command proc{eval($code_text.get('1.0','end'))}
+ }.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
+# f.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x')
+ f.pack('side'=>'bottom', 'fill'=>'x')
+
+ if $tk_version =~ /^4\.[01]/
+ s = TkScrollbar.new($code_window, 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {
+ height 40
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| $code_text.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ $code_text.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ else
+ TkFrame.new($code_window) {|f|
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ hs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'horizontal')
+ vs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {|t|
+ height 40
+ #wrap 'word'
+ wrap 'char'
+ xscrollcommand proc{|first,last| hs.set first,last}
+ yscrollcommand proc{|first,last| vs.set first,last}
+ setgrid 'yes'
+ highlightthickness 0
+ pady 2
+ padx 3
+ hs.command(proc{|*args| $code_text.xview(*args)})
+ vs.command(proc{|*args| $code_text.yview(*args)})
+ }
+
+ $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ }
+ end
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+# fid = open(file, 'r')
+ fid = open([$demo_dir, file].join(File::Separator), 'r')
+ $code_text.delete('1.0', 'end')
+ #$code_text.insert('1.0', `cat #{file}`)
+ $code_text.insert('1.0', fid.read)
+ #$code_mark = TkTextMark.new($code_text, '1.0')
+ #$code_text.set_insert('1.0')
+ TkTextMarkInsert.new($code_text,'1.0')
+ fid.close
+end
+
+def showCode2(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ tf = TkFrame.new($code_window)
+ $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30,
+ :wrap=>'word', :bd=>1, :setgrid=>true,
+ :highlightthickness=>0, :pady=>2, :padx=>3)
+ xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ TkGrid($code_text, yscr, :sticky=>'news')
+ #TkGrid(xscr)
+ tf.grid_rowconfigure(0, :weight=>1)
+ tf.grid_columnconfigure(0, :weight=>1)
+
+ bf = TkFrame.new($code_window)
+
+ #b_dis = TkButton.new(bf, :text=>'λ²ò', :default=>:active,
+ b_dis = TkButton.new(bf, :text=>'ÊĤ¸¤ë', :default=>:active,
+ :command=>proc{
+ $code_window.destroy
+ $code_window = nil
+ },
+ :image=>$image['delete'], :compound=>:left)
+ b_prn = TkButton.new(bf, :text=>'°õºþ',
+ :command=>proc{printCode($code_text, file)},
+ :image=>$image['print'], :compound=>:left)
+ b_run = TkButton.new(bf, :text=>'ºÆ¼Â¹Ô',
+ :command=>proc{eval($code_text.get('1.0','end'))},
+ :image=>$image['refresh'], :compound=>:left)
+
+ TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
+ bf.grid_columnconfigure(0, :weight=>1)
+
+ TkGrid(tf, :sticky=>'news')
+ TkGrid(bf, :sticky=>'ew')
+ $code_window.grid_columnconfigure(0, :weight=>1)
+ $code_window.grid_rowconfigure(0, :weight=>1)
+
+ $code_window.bind('Return', proc{|win|
+ b_dis.invoke unless win.kind_of?(TkText)
+ }, '%W')
+ $code_window.bindinfo('Return').each{|cmd, arg|
+ $code_window.bind_append('Escape', cmd, arg)
+ }
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+ fid = open([$demo_dir, file].join(File::Separator), 'r')
+ $code_text.delete('1.0', 'end')
+ $code_text.insert('1.0', fid.read)
+ TkTextMarkInsert.new($code_text,'1.0')
+ fid.close
+end
+
+if $tk_major_ver < 8
+ alias showCode showCode1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 4
+ alias showCode showCode1
+else # ver >= 8.4
+ alias showCode showCode2
+end
+
+
+# printCode --
+# Prints the source code currently displayed in the See Code dialog.
+# Much thanks to Arjen Markus for this.
+#
+# Arguments:
+# txt - Name of text widget containing code to print
+# file - Name of the original file (implicitly for title)
+
+def printCode(txt, file)
+ code = txt.get('1.0', 'end - 1c')
+ dir = '.'
+ dir = ENV['HOME'] if ENV['HOME']
+ dir = ENV['TMP'] if ENV['TMP']
+ dir = ENV['TEMP'] if ENV['TEMP']
+
+ fname = [dir, 'tkdemo-' + file].join(File::Separator)
+ open(fname, 'w'){|fid| fid.print(code)}
+ begin
+ case Tk::TCL_PLATFORM('platform')
+ when 'unix'
+ msg = `lp -c #{fname}`
+ unless $?.exitstatus == 0
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡¥' +
+ '°õºþ¤Ë¼ºÇÔ¤·¤¿¤â¤Î¤È»×¤ï¤ì¤Þ¤¹ : ' + msg)
+ end
+ when 'windows'
+ begin
+ printTextWin32(fname)
+ rescue => e
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡¥' +
+ '°õºþ¤Ë¼ºÇÔ¤·¤¿¤â¤Î¤È»×¤ï¤ì¤Þ¤¹ : ' +
+ e.message)
+ end
+ when 'macintosh'
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'°õºþµ¡Ç½¤Ï¤Þ¤À¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó')
+ else
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'¸¡½Ð¤µ¤ì¤¿´Ä¶­ ' +
+ Tk::TCL_PLATFORM('platform') +
+ ' ¤Ï̤ÃΤδĶ­¤Ç¤¢¤ë¤¿¤á¡¤' +
+ '°õºþµ¡Ç½¤Ï¼ÂÁõ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó: ')
+ end
+ ensure
+ File.delete(fname)
+ end
+end
+
+# printTextWin32 --
+# Print a file under Windows
+#
+# Arguments:
+# filename - Name of the file
+#
+def printTextWin32(fname)
+ require 'win32/registry'
+ begin
+ app = Win32::Registry::HKEY_CLASSES_ROOT['.txt']
+ pcmd = nil
+ Win32::Registry::HKEY_CLASSES_ROOT.open("#{app}\\shell\\print"){|reg|
+ pcmd = reg['command']
+ }
+ rescue
+ app = Tk.tk_call('auto_execok', 'notepad.exe')
+ pcmd = "#{app} /p %1"
+ end
+
+ pcmd.gsub!('%1', fname)
+ puts pcmd
+ cmd = Tk.tk_call('auto_execok', 'start') + ' /min ' + pcmd
+
+ msg = `#{cmd}`
+ unless $?.exitstatus == 0
+ fail RuntimeError, msg
+ end
+end
+
+# aboutBox
+#
+# Pops up a message box with an "about" message
+#
+def aboutBox
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
+ 'message'=>"Ruby/Tk ¥¦¥£¥¸¥§¥Ã¥È¥Ç¥â Ver.1.4.3-jp\n\n" +
+ "based on demos of Tk8.1 -- 8.5 " +
+ "( Copyright:: " +
+ "(c) 1996-1997 Sun Microsystems, Inc. / " +
+ "(c) 1997-2000 Ajuba Solutions, Inc. / " +
+ "(c) 2001-2003 Donal K. Fellows )\n\n" +
+ "Your Ruby & Tk Version ::\n" +
+ "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}")
+end
+
+####################################
+# °ú¿ô¤Ç»ØÄꤵ¤ì¤¿¥Ç¥â¤òµ¯Æ°¤¹¤ë
+no_launcher = false
+if ARGV[0] == '-n'
+ ARGV.shift
+ no_launcher = true if ARGV.size > 0
+end
+ARGV.each{|cmd|
+ if cmd =~ /(.*).rb/
+ cmd = $1
+ end
+ eval IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join
+}
+if no_launcher
+ $root.withdraw # hide root window
+ Thread.start{
+ loop do
+ count = 0
+ $root.winfo_children.each{|w|
+ count += 1 if w.kind_of?(TkToplevel)
+ }
+ $root.destroy if count == 0
+ end
+ }
+end
+
+################################
+# ¥¤¥Ù¥ó¥ÈÂÔ¤Á¤ËÆþ¤ë
+Tk.mainloop
diff --git a/ext/tk/sample/encstr_usage.rb b/ext/tk/sample/encstr_usage.rb
new file mode 100644
index 0000000000..4285ec861c
--- /dev/null
+++ b/ext/tk/sample/encstr_usage.rb
@@ -0,0 +1,29 @@
+require 'tk'
+
+TkMessage.new(:width=>400, :text=><<EOM).pack
+This sample shows how to use Tk::EncodedString class. \
+This reads 'iso2022-kr' text (from discription of \
+Korean language environment of GNU Emacs 20.7.2) \
+and inserts the text into the text widget.
+EOM
+
+t1 = TkText.new(:height=>5).pack
+t2 = TkText.new(:height=>5).pack
+t3 = TkText.new(:height=>5).pack
+
+src_str = IO.readlines('iso2022-kr.txt').join
+
+t1.insert('end',
+ "use neither Tk::EncodedString class nor Tk.encoding= method\n\n")
+t1.insert('end', src_str)
+
+enc_str = Tk::EncodedString(src_str, 'iso2022-kr')
+t2.insert('end',
+ "use Tk::EncodedString class (Tk.encoding => '#{Tk.encoding}')\n\n")
+t2.insert('end', enc_str)
+
+Tk.encoding = 'iso2022-kr'
+t3.insert('end', "use Tk.encoding = 'iso2022-kr'\n\n")
+t3.insert('end', src_str)
+
+Tk.mainloop
diff --git a/ext/tk/sample/images/earth.gif b/ext/tk/sample/images/earth.gif
new file mode 100644
index 0000000000..2c229eb110
--- /dev/null
+++ b/ext/tk/sample/images/earth.gif
Binary files differ
diff --git a/ext/tk/sample/images/earthris.gif b/ext/tk/sample/images/earthris.gif
new file mode 100644
index 0000000000..c4ee473727
--- /dev/null
+++ b/ext/tk/sample/images/earthris.gif
Binary files differ
diff --git a/ext/tk/sample/images/face.xbm b/ext/tk/sample/images/face.xbm
new file mode 100644
index 0000000000..03d829f4d1
--- /dev/null
+++ b/ext/tk/sample/images/face.xbm
@@ -0,0 +1,173 @@
+#define face_width 108
+#define face_height 144
+#define face_x_hot 48
+#define face_y_hot 80
+static char face_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x09,
+ 0x20, 0x80, 0x24, 0x05, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x88,
+ 0x24, 0x20, 0x80, 0x24, 0x00, 0x00, 0x00, 0x10, 0x80, 0x04, 0x00, 0x01,
+ 0x00, 0x01, 0x40, 0x0a, 0x09, 0x00, 0x92, 0x04, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x40, 0x12, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x84,
+ 0x24, 0x40, 0x22, 0xa8, 0x02, 0x14, 0x84, 0x92, 0x40, 0x42, 0x12, 0x04,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x52, 0x11, 0x00, 0x12, 0x00,
+ 0x40, 0x02, 0x00, 0x20, 0x00, 0x08, 0x00, 0xaa, 0x02, 0x54, 0x85, 0x24,
+ 0x00, 0x10, 0x12, 0x00, 0x00, 0x81, 0x44, 0x00, 0x90, 0x5a, 0x00, 0xea,
+ 0x1b, 0x00, 0x80, 0x40, 0x40, 0x02, 0x00, 0x08, 0x00, 0x20, 0xa2, 0x05,
+ 0x8a, 0xb4, 0x6e, 0x45, 0x12, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10, 0x02,
+ 0xa8, 0x92, 0x00, 0xda, 0x5f, 0x10, 0x00, 0x10, 0xa1, 0x04, 0x20, 0x41,
+ 0x02, 0x00, 0x5a, 0x25, 0xa0, 0xff, 0xfb, 0x05, 0x41, 0x02, 0x04, 0x00,
+ 0x00, 0x08, 0x40, 0x80, 0xec, 0x9b, 0xec, 0xfe, 0x7f, 0x01, 0x04, 0x20,
+ 0x90, 0x02, 0x04, 0x00, 0x08, 0x20, 0xfb, 0x2e, 0xf5, 0xff, 0xff, 0x57,
+ 0x00, 0x04, 0x02, 0x00, 0x00, 0x20, 0x01, 0xc1, 0x6e, 0xab, 0xfa, 0xff,
+ 0xff, 0x05, 0x90, 0x20, 0x48, 0x02, 0x00, 0x04, 0x20, 0xa8, 0xdf, 0xb5,
+ 0xfe, 0xff, 0xff, 0x0b, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x04, 0xe0,
+ 0xbb, 0xef, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x04, 0x48, 0x02, 0x00, 0x20,
+ 0x80, 0xf4, 0x6f, 0xfb, 0xff, 0xff, 0xff, 0x20, 0x90, 0x40, 0x02, 0x00,
+ 0x00, 0x04, 0x08, 0xb8, 0xf6, 0xff, 0xff, 0xdf, 0xbe, 0x12, 0x45, 0x10,
+ 0x90, 0x04, 0x90, 0x00, 0x22, 0xfa, 0xff, 0xff, 0xff, 0xbb, 0xd7, 0xe9,
+ 0x3a, 0x02, 0x02, 0x00, 0x04, 0x90, 0x80, 0xfe, 0xdf, 0xf6, 0xb7, 0xef,
+ 0xbe, 0x56, 0x57, 0x40, 0x48, 0x09, 0x00, 0x04, 0x00, 0xfa, 0xf5, 0xdf,
+ 0xed, 0x5a, 0xd5, 0xea, 0xbd, 0x09, 0x00, 0x00, 0x40, 0x00, 0x92, 0xfe,
+ 0xbf, 0x7d, 0xb7, 0x6a, 0x55, 0xbf, 0xf7, 0x02, 0x11, 0x01, 0x00, 0x91,
+ 0x00, 0xff, 0xff, 0xaf, 0x55, 0x55, 0x5b, 0xeb, 0xef, 0x22, 0x04, 0x04,
+ 0x04, 0x00, 0xa4, 0xff, 0xf7, 0xad, 0xaa, 0xaa, 0xaa, 0xbe, 0xfe, 0x03,
+ 0x20, 0x00, 0x10, 0x44, 0x80, 0xff, 0x7f, 0x55, 0x12, 0x91, 0x2a, 0xeb,
+ 0xbf, 0x0b, 0x82, 0x02, 0x00, 0x00, 0xd1, 0x7f, 0xdf, 0xa2, 0xa4, 0x54,
+ 0x55, 0xfd, 0xfd, 0x47, 0x08, 0x08, 0x00, 0x21, 0xe4, 0xff, 0x37, 0x11,
+ 0x09, 0xa5, 0xaa, 0xb6, 0xff, 0x0d, 0x80, 0x00, 0x00, 0x04, 0xd0, 0xff,
+ 0x4f, 0x44, 0x20, 0x48, 0x55, 0xfb, 0xff, 0x27, 0x11, 0x02, 0x40, 0x40,
+ 0xe2, 0xfb, 0x15, 0x11, 0x4a, 0x55, 0x4a, 0x7d, 0xf7, 0x0f, 0x00, 0x00,
+ 0x04, 0x08, 0xf8, 0xdf, 0x52, 0x44, 0x01, 0x52, 0xb5, 0xfa, 0xff, 0x0f,
+ 0x49, 0x02, 0x00, 0x02, 0xe9, 0xf6, 0x0a, 0x11, 0xa4, 0x88, 0x4a, 0x6d,
+ 0xff, 0x5f, 0x00, 0x00, 0x10, 0x20, 0xf0, 0x2f, 0x21, 0x44, 0x10, 0x52,
+ 0xb5, 0xfa, 0xff, 0x0f, 0x44, 0x04, 0x80, 0x08, 0xf8, 0xab, 0x8a, 0x00,
+ 0x81, 0xa4, 0xd4, 0xd6, 0xfe, 0x2f, 0x00, 0x00, 0x04, 0x40, 0xb5, 0x2d,
+ 0x21, 0x08, 0x04, 0x90, 0xaa, 0xfa, 0xff, 0x1f, 0x11, 0x01, 0x00, 0x04,
+ 0xf0, 0x57, 0x0a, 0x22, 0x40, 0x4a, 0xda, 0x5e, 0xfb, 0x1f, 0x40, 0x00,
+ 0x40, 0x20, 0xba, 0x95, 0x90, 0x00, 0x01, 0xa0, 0xaa, 0xea, 0xff, 0x5f,
+ 0x02, 0x02, 0x00, 0x01, 0xe8, 0x57, 0x05, 0x00, 0x00, 0x12, 0xd5, 0xfe,
+ 0xfd, 0x1f, 0x48, 0x00, 0x04, 0x48, 0x7a, 0x95, 0x08, 0x02, 0x10, 0x40,
+ 0xaa, 0x55, 0xf7, 0x1f, 0x00, 0x09, 0x20, 0x00, 0xf8, 0x57, 0x22, 0x10,
+ 0x00, 0x28, 0xa9, 0xfa, 0xff, 0x5f, 0x02, 0x00, 0x00, 0x49, 0xdd, 0x29,
+ 0x01, 0x00, 0x80, 0x80, 0xaa, 0xd7, 0xff, 0x0f, 0x10, 0x00, 0x08, 0x00,
+ 0xf8, 0x96, 0x08, 0x00, 0x00, 0x20, 0x54, 0xfa, 0xee, 0x3f, 0x81, 0x04,
+ 0x40, 0x24, 0xfe, 0x55, 0x82, 0x00, 0x00, 0x82, 0xd2, 0xad, 0xff, 0x0f,
+ 0x08, 0x00, 0x04, 0x80, 0x6c, 0x97, 0x00, 0x00, 0x02, 0x20, 0xa9, 0xf6,
+ 0xdf, 0x5f, 0x00, 0x02, 0x20, 0x09, 0xfa, 0x49, 0x12, 0x00, 0x20, 0x84,
+ 0x54, 0xdb, 0xfe, 0x1f, 0x91, 0x00, 0x00, 0x00, 0xf8, 0x2b, 0x00, 0x20,
+ 0x00, 0x40, 0xa4, 0xf6, 0xbb, 0x1f, 0x04, 0x00, 0x44, 0x92, 0x7e, 0x95,
+ 0x02, 0x00, 0x00, 0x89, 0xaa, 0xdd, 0xff, 0x1f, 0x20, 0x09, 0x10, 0x00,
+ 0xf4, 0x57, 0x20, 0x01, 0x08, 0x20, 0xa9, 0x76, 0xff, 0x5f, 0x02, 0x00,
+ 0x00, 0x21, 0xfc, 0x4a, 0x05, 0x00, 0x01, 0x80, 0x54, 0xdb, 0xff, 0x1e,
+ 0x08, 0x02, 0x04, 0x08, 0xf9, 0x2b, 0x00, 0x00, 0x40, 0x28, 0xd2, 0xf6,
+ 0xff, 0xbf, 0x80, 0x00, 0x90, 0x00, 0xbc, 0x92, 0x08, 0x10, 0x00, 0x82,
+ 0x54, 0xdb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x44, 0xf9, 0x55, 0x02, 0x01,
+ 0x00, 0x20, 0xaa, 0xbd, 0xfd, 0x3f, 0x08, 0x04, 0x04, 0x10, 0xf4, 0x2a,
+ 0x01, 0x00, 0x22, 0x80, 0xd4, 0xf6, 0xff, 0x5f, 0x82, 0x00, 0x40, 0x02,
+ 0xf8, 0x55, 0x20, 0x00, 0x00, 0x50, 0x6a, 0xdf, 0xfe, 0x3f, 0x00, 0x00,
+ 0x00, 0x48, 0xe9, 0x4a, 0x05, 0x08, 0x00, 0xa5, 0xd5, 0xf5, 0xff, 0x3f,
+ 0x10, 0x01, 0x10, 0x01, 0xb0, 0xab, 0x92, 0x02, 0x40, 0xf8, 0xbf, 0xde,
+ 0xfe, 0x5f, 0x02, 0x04, 0x04, 0x48, 0xfa, 0xd4, 0x6f, 0x20, 0x84, 0xef,
+ 0xff, 0xfb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x00, 0xe0, 0xed, 0xbf, 0x0b,
+ 0xa1, 0x7e, 0xff, 0xbf, 0xfd, 0x5f, 0x04, 0x01, 0x20, 0x49, 0xd2, 0xfb,
+ 0xfe, 0x55, 0xd4, 0xff, 0xff, 0xf6, 0xff, 0x07, 0x00, 0x04, 0x00, 0x00,
+ 0xc0, 0xaa, 0xfb, 0x2b, 0xa2, 0xfe, 0xff, 0xdf, 0xee, 0x1f, 0x91, 0x00,
+ 0x82, 0xa4, 0xa4, 0xf5, 0xff, 0x57, 0xd5, 0xff, 0xbf, 0xfd, 0xff, 0x4d,
+ 0x00, 0x00, 0x20, 0x00, 0x88, 0x5b, 0xff, 0x2f, 0x69, 0xff, 0xff, 0xdb,
+ 0xfe, 0x1f, 0x24, 0x02, 0x00, 0x49, 0xa2, 0xd6, 0xff, 0x5f, 0xea, 0xff,
+ 0x7f, 0x7f, 0x7f, 0x0d, 0x00, 0x00, 0x10, 0x00, 0x40, 0xab, 0xf7, 0xbb,
+ 0xf0, 0xdf, 0xff, 0xd5, 0xff, 0xbf, 0x82, 0x04, 0x42, 0x24, 0x91, 0xd5,
+ 0xaa, 0xae, 0xd4, 0xaa, 0x52, 0x7b, 0xff, 0x15, 0x08, 0x00, 0x00, 0x01,
+ 0x04, 0x55, 0xd5, 0x55, 0x70, 0x5b, 0x75, 0xdd, 0xdf, 0x1f, 0x40, 0x00,
+ 0x08, 0x48, 0xa0, 0x4a, 0xa9, 0x56, 0xea, 0x56, 0xad, 0x6a, 0x7d, 0x9b,
+ 0x04, 0x01, 0x00, 0x02, 0x42, 0x2a, 0xd5, 0xaa, 0xa8, 0xaa, 0xaa, 0xfa,
+ 0xdf, 0x2f, 0x10, 0x04, 0x22, 0x48, 0x08, 0x45, 0x2a, 0x15, 0x68, 0x55,
+ 0x55, 0xd7, 0x76, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x40, 0x2a, 0x80, 0xa0,
+ 0xb2, 0x09, 0x48, 0xb9, 0xdf, 0x17, 0x22, 0x01, 0x00, 0x24, 0x45, 0x8a,
+ 0x24, 0x4a, 0x54, 0x51, 0x91, 0xf6, 0x6e, 0x4b, 0x00, 0x04, 0x90, 0x00,
+ 0x80, 0x52, 0x00, 0x20, 0x69, 0x05, 0xa4, 0xaa, 0xff, 0x1e, 0x48, 0x00,
+ 0x02, 0x92, 0x08, 0x05, 0x81, 0x94, 0xd4, 0x92, 0x40, 0xfd, 0xb6, 0x8b,
+ 0x00, 0x01, 0x40, 0x00, 0x82, 0x54, 0x00, 0x48, 0x68, 0x05, 0x90, 0xa4,
+ 0xef, 0x06, 0x24, 0x00, 0x08, 0x12, 0x10, 0x05, 0x00, 0x10, 0xb5, 0x01,
+ 0x42, 0xfb, 0xbf, 0x43, 0x00, 0x09, 0x00, 0x40, 0x81, 0xa8, 0x08, 0x4a,
+ 0xaa, 0x96, 0x90, 0xac, 0x6d, 0x15, 0x22, 0x00, 0x20, 0x09, 0x04, 0x15,
+ 0x80, 0x28, 0xdc, 0x01, 0x24, 0xfb, 0xbf, 0x01, 0x80, 0x04, 0x09, 0x00,
+ 0x40, 0x48, 0x02, 0x45, 0xb2, 0x2e, 0x41, 0x6d, 0xef, 0x05, 0x11, 0x00,
+ 0x40, 0x52, 0x02, 0x15, 0x29, 0x2a, 0xac, 0x42, 0x54, 0xfb, 0x3b, 0x51,
+ 0x84, 0x00, 0x08, 0x00, 0x20, 0x54, 0x80, 0x05, 0xb5, 0x3d, 0xa2, 0xb6,
+ 0xdf, 0x00, 0x20, 0x04, 0x20, 0x49, 0x89, 0xa8, 0x6a, 0x29, 0xac, 0xd6,
+ 0x54, 0xff, 0x3f, 0x84, 0x00, 0x01, 0x04, 0x10, 0x00, 0x94, 0xa8, 0x56,
+ 0xda, 0x5f, 0xab, 0xd5, 0x1e, 0x10, 0x48, 0x00, 0x90, 0x82, 0x48, 0xa8,
+ 0xb2, 0xac, 0xfd, 0x55, 0xd5, 0xfe, 0x9f, 0x80, 0x00, 0x0a, 0x02, 0x08,
+ 0x02, 0x55, 0x5a, 0x75, 0xff, 0xaf, 0xb6, 0xf7, 0x2d, 0x12, 0x92, 0x00,
+ 0x10, 0x20, 0x10, 0xa8, 0x54, 0xd5, 0xbf, 0x5d, 0xad, 0xdd, 0x0f, 0x00,
+ 0x00, 0x04, 0x40, 0x09, 0x84, 0xa8, 0xaa, 0x5a, 0xed, 0xeb, 0x6a, 0xff,
+ 0x9f, 0xa4, 0x24, 0x01, 0x02, 0xa0, 0x20, 0x50, 0x55, 0xd5, 0xbe, 0xae,
+ 0xad, 0xfd, 0x16, 0x00, 0x10, 0x04, 0x20, 0x0a, 0x08, 0xb4, 0xaa, 0x95,
+ 0xaa, 0x7b, 0xb7, 0xdb, 0x5f, 0x92, 0x04, 0x01, 0x84, 0x20, 0x21, 0x51,
+ 0xd5, 0x2a, 0xa9, 0xee, 0xd5, 0xfe, 0x0d, 0x00, 0x20, 0x04, 0x10, 0x00,
+ 0x08, 0x50, 0xe9, 0xd7, 0xd4, 0xfb, 0xb5, 0xff, 0x9f, 0x24, 0x09, 0x01,
+ 0x42, 0x4a, 0xa2, 0x64, 0xd5, 0x55, 0x7b, 0x7f, 0xda, 0x7d, 0x4f, 0x00,
+ 0x20, 0x04, 0x00, 0x80, 0x00, 0xa0, 0x2a, 0x13, 0x84, 0x6a, 0x55, 0xff,
+ 0x1d, 0x48, 0x8a, 0x00, 0x94, 0x24, 0x8a, 0xc8, 0xaa, 0x42, 0x20, 0x5d,
+ 0xf5, 0xff, 0x5f, 0x01, 0x00, 0x02, 0x01, 0x00, 0x20, 0xa2, 0x4a, 0x1a,
+ 0x82, 0x56, 0xda, 0xbd, 0x3f, 0x92, 0x92, 0x00, 0x90, 0x92, 0x00, 0x40,
+ 0x95, 0x6a, 0xf4, 0x55, 0x6d, 0xff, 0xd6, 0x00, 0x00, 0x0a, 0x04, 0x20,
+ 0x14, 0x49, 0x4b, 0xaa, 0xaa, 0x56, 0xf5, 0xff, 0xbf, 0xab, 0xa4, 0x00,
+ 0x20, 0x89, 0x40, 0x80, 0xaa, 0xaa, 0xaa, 0xaa, 0xde, 0xbf, 0xeb, 0x03,
+ 0x00, 0x02, 0x04, 0x02, 0x0a, 0x10, 0x2b, 0x2a, 0x55, 0x5b, 0xf5, 0xff,
+ 0xd7, 0x2f, 0x92, 0x00, 0x10, 0x28, 0x21, 0x01, 0x56, 0x95, 0xa0, 0x56,
+ 0xdf, 0xef, 0xea, 0x87, 0x40, 0x0a, 0x42, 0x41, 0x00, 0x90, 0xaa, 0x52,
+ 0xb6, 0xad, 0xfa, 0xff, 0xd5, 0x2f, 0x14, 0x00, 0x00, 0x04, 0x95, 0x04,
+ 0xaa, 0xac, 0x55, 0x6b, 0xff, 0xb7, 0xea, 0x9f, 0x40, 0x02, 0x28, 0x51,
+ 0x00, 0x40, 0x58, 0xd5, 0xda, 0xd6, 0x6e, 0x7f, 0xf9, 0x3f, 0x12, 0x04,
+ 0x02, 0x04, 0x49, 0x25, 0x55, 0xaa, 0x77, 0xab, 0xff, 0x2b, 0xfd, 0x3f,
+ 0x48, 0x01, 0x20, 0x41, 0x00, 0x00, 0x58, 0xa9, 0xda, 0xea, 0xfd, 0xaf,
+ 0xfa, 0xff, 0x02, 0x04, 0x08, 0x14, 0x29, 0x49, 0x52, 0x55, 0x55, 0x55,
+ 0xff, 0x8d, 0xfe, 0x3f, 0xa8, 0x00, 0x02, 0x41, 0x00, 0x02, 0xa0, 0xa2,
+ 0xaa, 0xea, 0xff, 0x53, 0xfd, 0xff, 0x02, 0x04, 0x50, 0x04, 0x25, 0xa8,
+ 0x54, 0x49, 0x52, 0xb5, 0xbf, 0x8a, 0xfe, 0xff, 0xa9, 0x08, 0x04, 0x50,
+ 0x80, 0x02, 0xa1, 0x2a, 0x95, 0xea, 0xff, 0xa1, 0xff, 0xff, 0x03, 0x02,
+ 0x90, 0x02, 0x09, 0x08, 0x44, 0x49, 0x52, 0xbd, 0x7f, 0xca, 0xff, 0xff,
+ 0x2b, 0x09, 0x04, 0x48, 0x40, 0x82, 0x90, 0x56, 0xa9, 0xf6, 0xbf, 0xd0,
+ 0xff, 0xff, 0x47, 0x00, 0x50, 0x02, 0x15, 0x11, 0x40, 0x95, 0xaa, 0xfd,
+ 0x2f, 0xe9, 0xff, 0xff, 0x8f, 0x0a, 0x84, 0x50, 0x40, 0x84, 0x14, 0xaa,
+ 0x6a, 0xff, 0x5f, 0xf2, 0xff, 0xff, 0x7f, 0x00, 0x10, 0x02, 0x09, 0x10,
+ 0x40, 0x7d, 0xf7, 0xff, 0x0b, 0xfc, 0xff, 0xff, 0xaf, 0x02, 0x84, 0x50,
+ 0x42, 0x85, 0x12, 0xd0, 0xdd, 0xff, 0xa7, 0xf2, 0xff, 0xff, 0xff, 0x04,
+ 0x00, 0x0a, 0x08, 0x10, 0x48, 0xf8, 0xff, 0xff, 0x0a, 0xfe, 0xff, 0xff,
+ 0x7f, 0x03, 0xa4, 0x80, 0xa2, 0x8a, 0x02, 0x68, 0xff, 0xff, 0x52, 0xfd,
+ 0xff, 0xff, 0xff, 0x07, 0x00, 0x2a, 0x08, 0x20, 0x28, 0xdc, 0xff, 0x5f,
+ 0x05, 0xff, 0xff, 0xff, 0xff, 0x0d, 0x92, 0x40, 0x22, 0x09, 0x02, 0xea,
+ 0xfb, 0xaf, 0x48, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x12, 0x81, 0xa0,
+ 0x48, 0x9c, 0x6e, 0x93, 0xa2, 0xff, 0xff, 0xff, 0xff, 0x07, 0xa8, 0x40,
+ 0x28, 0x0a, 0x02, 0x74, 0xb5, 0x45, 0x81, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x02, 0x0a, 0x81, 0x20, 0x08, 0xae, 0xaa, 0x90, 0xe8, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0x90, 0x40, 0x28, 0x88, 0x12, 0x58, 0x15, 0x50, 0xd0, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x44, 0x0a, 0x41, 0x21, 0x08, 0xae, 0x04, 0x14,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, 0x14, 0x88, 0x04, 0xba,
+ 0x02, 0x28, 0xe8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x42, 0x15, 0x41, 0x21,
+ 0x05, 0xad, 0x00, 0x05, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40,
+ 0x24, 0x8a, 0x0e, 0x36, 0x00, 0x0a, 0xf4, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x42, 0x25, 0x90, 0xd0, 0x8b, 0xc2, 0x41, 0x05, 0xfc, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0x10, 0x08, 0x05, 0xe8, 0x8e, 0x58, 0x80, 0x02, 0xfa, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x4a, 0x20, 0xa8, 0xba, 0x0b, 0x2b, 0x51, 0x01,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x8a, 0x02, 0xe8, 0xaf, 0x84,
+ 0x90, 0x04, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x52, 0x21, 0x54, 0xbf,
+ 0x1f, 0x15, 0xa5, 0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x08,
+ 0x01, 0xfa, 0xb6, 0xa4, 0x52, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x4a, 0xa2, 0x54, 0xef, 0x5f, 0x4b, 0xa4, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0x80, 0x10, 0x82, 0xfe, 0xbf, 0x92, 0x52, 0x42, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x12, 0x42, 0xa8, 0xbf, 0x1f, 0x24, 0x80, 0xa0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, 0x8a, 0xf7, 0x37, 0x80,
+ 0x52, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x82, 0xe0, 0xff,
+ 0x1f, 0x00, 0x20, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28,
+ 0xca, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x10, 0x42, 0xf0, 0xfd, 0x1b, 0x00, 0x50, 0xf0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0xa4, 0x10, 0xc5, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x00, 0x22, 0xf8, 0xff, 0x0e, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xaa, 0x88, 0xe2, 0xff, 0x0f, 0x10,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x25, 0xfa, 0xff,
+ 0x0f, 0x01, 0x11, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xfb,
+ 0xfb, 0xff, 0x7f, 0x5d, 0xd5, 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f};
diff --git a/ext/tk/sample/images/flagdown.xbm b/ext/tk/sample/images/flagdown.xbm
new file mode 100644
index 0000000000..55abc51825
--- /dev/null
+++ b/ext/tk/sample/images/flagdown.xbm
@@ -0,0 +1,27 @@
+#define flagdown_width 48
+#define flagdown_height 48
+static char flagdown_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe1, 0x00, 0x00,
+ 0x00, 0x00, 0x70, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04,
+ 0x00, 0x00, 0x03, 0x00, 0x06, 0x06, 0x00, 0x80, 0x01, 0x00, 0x06, 0x07,
+ 0x00, 0xc0, 0x1f, 0x00, 0x87, 0x07, 0x00, 0xe0, 0x7f, 0x80, 0xc7, 0x07,
+ 0x00, 0x70, 0xe0, 0xc0, 0xe5, 0x07, 0x00, 0x38, 0x80, 0xe1, 0x74, 0x07,
+ 0x00, 0x18, 0x80, 0x71, 0x3c, 0x07, 0x00, 0x0c, 0x00, 0x3b, 0x1e, 0x03,
+ 0x00, 0x0c, 0x00, 0x1f, 0x0f, 0x00, 0x00, 0x86, 0x1f, 0x8e, 0x07, 0x00,
+ 0x00, 0x06, 0x06, 0xc6, 0x05, 0x00, 0x00, 0x06, 0x00, 0xc6, 0x05, 0x00,
+ 0x00, 0x06, 0x00, 0xc6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00,
+ 0x7f, 0x06, 0x00, 0x06, 0xe4, 0xff, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00,
+ 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x06, 0x00,
+ 0x00, 0x06, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00,
+ 0x00, 0x06, 0x00, 0xc6, 0x00, 0x00, 0x00, 0x06, 0x00, 0x66, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x36, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3e, 0x00, 0x00,
+ 0x00, 0xfe, 0xff, 0x2f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x27, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0xf7, 0xbf, 0x8e, 0xfc, 0xdf, 0xf8, 0x9d, 0xeb, 0x9b, 0x76, 0xd2, 0x7a,
+ 0x46, 0x30, 0xe2, 0x0f, 0xe1, 0x47, 0x55, 0x84, 0x48, 0x11, 0x84, 0x19};
diff --git a/ext/tk/sample/images/flagup.xbm b/ext/tk/sample/images/flagup.xbm
new file mode 100644
index 0000000000..6eb0d846a3
--- /dev/null
+++ b/ext/tk/sample/images/flagup.xbm
@@ -0,0 +1,27 @@
+#define flagup_width 48
+#define flagup_height 48
+static char flagup_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xef, 0x6a, 0x00,
+ 0x00, 0x00, 0xc0, 0x7b, 0x75, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x6a, 0x00,
+ 0x00, 0x00, 0x30, 0x60, 0x75, 0x00, 0x00, 0x00, 0x18, 0xe0, 0x7f, 0x00,
+ 0x00, 0x00, 0x0c, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x06, 0xe0, 0x04, 0x00,
+ 0x00, 0x00, 0x03, 0xe0, 0x04, 0x00, 0x00, 0x80, 0x01, 0xe0, 0x06, 0x00,
+ 0x00, 0xc0, 0x1f, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0xe0, 0x07, 0x00,
+ 0x00, 0x70, 0xe0, 0xe0, 0x05, 0x00, 0x00, 0x38, 0x80, 0xe1, 0x04, 0x00,
+ 0x00, 0x18, 0x80, 0xf1, 0x04, 0x00, 0x00, 0x0c, 0x00, 0xfb, 0x04, 0x00,
+ 0x00, 0x0c, 0x00, 0xff, 0x04, 0x00, 0x00, 0x86, 0x1f, 0xee, 0x04, 0x00,
+ 0x00, 0x06, 0x06, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00,
+ 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x66, 0x04, 0x00,
+ 0x7f, 0x56, 0x52, 0x06, 0xe4, 0xff, 0x00, 0x76, 0x55, 0x06, 0x04, 0x00,
+ 0x00, 0x56, 0x57, 0x06, 0x04, 0x00, 0x00, 0x56, 0x55, 0x06, 0x06, 0x00,
+ 0x00, 0x56, 0xd5, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00,
+ 0x54, 0x06, 0x00, 0xc6, 0x54, 0x55, 0xaa, 0x06, 0x00, 0x66, 0xaa, 0x2a,
+ 0x54, 0x06, 0x00, 0x36, 0x55, 0x55, 0xaa, 0x06, 0x00, 0xbe, 0xaa, 0x2a,
+ 0x54, 0xfe, 0xff, 0x6f, 0x55, 0x55, 0xaa, 0xfc, 0xff, 0xa7, 0xaa, 0x2a,
+ 0x54, 0x01, 0x88, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x50, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa8, 0xaa, 0x2a,
+ 0x54, 0x55, 0x95, 0x54, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2a,
+ 0x54, 0x55, 0x55, 0x55, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/ext/tk/sample/images/gray25.xbm b/ext/tk/sample/images/gray25.xbm
new file mode 100644
index 0000000000..b234b3cb0b
--- /dev/null
+++ b/ext/tk/sample/images/gray25.xbm
@@ -0,0 +1,6 @@
+#define grey_width 16
+#define grey_height 16
+static char grey_bits[] = {
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44};
diff --git a/ext/tk/sample/images/grey.25 b/ext/tk/sample/images/grey.25
new file mode 100644
index 0000000000..b234b3cb0b
--- /dev/null
+++ b/ext/tk/sample/images/grey.25
@@ -0,0 +1,6 @@
+#define grey_width 16
+#define grey_height 16
+static char grey_bits[] = {
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44};
diff --git a/ext/tk/sample/images/grey.5 b/ext/tk/sample/images/grey.5
new file mode 100644
index 0000000000..37688893f0
--- /dev/null
+++ b/ext/tk/sample/images/grey.5
@@ -0,0 +1,6 @@
+#define grey_width 16
+#define grey_height 16
+static char grey_bits[] = {
+ 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
+ 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
+ 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa};
diff --git a/ext/tk/sample/images/letters.xbm b/ext/tk/sample/images/letters.xbm
new file mode 100644
index 0000000000..0f12568d1a
--- /dev/null
+++ b/ext/tk/sample/images/letters.xbm
@@ -0,0 +1,27 @@
+#define letters_width 48
+#define letters_height 48
+static char letters_bits[] = {
+ 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, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0xfa, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a,
+ 0x00, 0x3a, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2e,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x21,
+ 0xa0, 0x03, 0x00, 0x00, 0x70, 0x21, 0x20, 0x00, 0x00, 0x00, 0x50, 0x21,
+ 0xa0, 0x1f, 0x00, 0x00, 0x50, 0x21, 0x20, 0x00, 0x00, 0x00, 0x70, 0x21,
+ 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21,
+ 0xfa, 0x01, 0x00, 0x80, 0x0b, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0a, 0x21,
+ 0xba, 0x01, 0x00, 0x80, 0x0a, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0b, 0x21,
+ 0x3a, 0x00, 0x00, 0x00, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21,
+ 0x02, 0xc0, 0xfb, 0x03, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3f,
+ 0x02, 0xc0, 0xbd, 0x0f, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
+ 0x02, 0xc0, 0x7f, 0x7b, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
+ 0x02, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0xfe, 0xff, 0xff, 0xff, 0x0f, 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};
diff --git a/ext/tk/sample/images/noletter.xbm b/ext/tk/sample/images/noletter.xbm
new file mode 100644
index 0000000000..5774124efe
--- /dev/null
+++ b/ext/tk/sample/images/noletter.xbm
@@ -0,0 +1,27 @@
+#define noletters_width 48
+#define noletters_height 48
+static char noletters_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00,
+ 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01,
+ 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x07,
+ 0xe0, 0x01, 0x00, 0x00, 0xf0, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x78, 0x0e,
+ 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x1e, 0x70, 0x00, 0x00, 0x00, 0x1e, 0x1c,
+ 0x38, 0x00, 0x00, 0x00, 0x0f, 0x38, 0x38, 0x00, 0x00, 0x80, 0x07, 0x38,
+ 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x1c, 0x04, 0x00, 0xe0, 0x41, 0x70,
+ 0x1c, 0x04, 0x00, 0xf0, 0x40, 0x70, 0x1c, 0x74, 0x00, 0x78, 0x4e, 0x70,
+ 0x0e, 0x04, 0x00, 0x3c, 0x4a, 0xe0, 0x0e, 0x74, 0x03, 0x1e, 0x4a, 0xe0,
+ 0x0e, 0x04, 0x00, 0x0f, 0x4e, 0xe0, 0x0e, 0x04, 0x80, 0x07, 0x40, 0xe0,
+ 0x0e, 0x04, 0xf8, 0x0f, 0x40, 0xe0, 0x0e, 0x04, 0xe0, 0x01, 0x40, 0xe0,
+ 0x0e, 0x04, 0xf8, 0x00, 0x40, 0xe0, 0x0e, 0x04, 0x78, 0x00, 0x40, 0xe0,
+ 0x0e, 0x04, 0xfc, 0xf3, 0x40, 0xe0, 0x1c, 0x04, 0x1e, 0x00, 0x40, 0x70,
+ 0x1c, 0x04, 0x0f, 0x00, 0x40, 0x70, 0x1c, 0x84, 0x07, 0x00, 0x40, 0x70,
+ 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x38, 0xe0, 0x01, 0x00, 0x00, 0x38,
+ 0x38, 0xf0, 0x00, 0x00, 0x00, 0x38, 0x70, 0x78, 0x00, 0x00, 0x00, 0x1c,
+ 0xf0, 0x3c, 0x00, 0x00, 0x00, 0x1e, 0xe0, 0x1e, 0x00, 0x00, 0x00, 0x0e,
+ 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x80, 0x07,
+ 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01,
+ 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00,
+ 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00};
diff --git a/ext/tk/sample/images/pattern.xbm b/ext/tk/sample/images/pattern.xbm
new file mode 100644
index 0000000000..df31baf789
--- /dev/null
+++ b/ext/tk/sample/images/pattern.xbm
@@ -0,0 +1,6 @@
+#define foo_width 16
+#define foo_height 16
+static char foo_bits[] = {
+ 0x60, 0x06, 0x90, 0x09, 0x90, 0x09, 0xb0, 0x0d, 0x4e, 0x72, 0x49, 0x92,
+ 0x71, 0x8e, 0x8e, 0x71, 0x8e, 0x71, 0x71, 0x8e, 0x49, 0x92, 0x4e, 0x72,
+ 0xb0, 0x0d, 0x90, 0x09, 0x90, 0x09, 0x60, 0x06};
diff --git a/ext/tk/sample/images/tcllogo.gif b/ext/tk/sample/images/tcllogo.gif
new file mode 100644
index 0000000000..4603d4ff41
--- /dev/null
+++ b/ext/tk/sample/images/tcllogo.gif
Binary files differ
diff --git a/ext/tk/sample/images/teapot.ppm b/ext/tk/sample/images/teapot.ppm
new file mode 100644
index 0000000000..78afefbf82
--- /dev/null
+++ b/ext/tk/sample/images/teapot.ppm
@@ -0,0 +1,56 @@
+P6
+256 256
+255
+\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À[7 eOLjQLmSMoTMnSMlRMhPL_9 \À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀnSMtVMzYN~[N~[N\N\O€\O€]O€]O€]O€]O€\O€\O}[NyYNtVM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀG-wXN}[N€]O„^O†_O†`O‡`Oˆ`Oˆ`OˆaO‰aO‰aO‰aO‰aO‰aO‰aOˆaOˆ`O†_Oƒ^O\N \À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀaMLyYN…_O‰aP‹bPcPŽcPŽdPŽdPdPdPdPdPdPdPdPeP‘eP’eP’eP‘ePdPcP…_OpUM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀwXN…_OdP“fP•gQ–hQ˜hQ˜iQ™iQ™iQšiQšiQšjQ›jQ›jQœjQœjQœjQœjQœjQ›jQœjQ™iQ“fP‡`O\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀNCJiQL‹bP—hQkQ¡mR¤nR¥oR¥oR¥oR¥oR¥oR¥oR¦oR¦oR¦pR¨pS©qSªqS«rS¬rS«rS©qS¤oRœjQ€]O\KK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀfOLrUMcPŸlR©qS¯tS²uTµwT·xT¸xT¹yTºyT»zT»zU¼zU¼zU¼zU»zUºyT¸xT¶wT¯tS¡mR‰aOhPL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\Àa0 cNLqUM€\O”fQ¦pS²wVºzV¿|VÂ}VÄVÆVÇ€VÉ‚WÌ…[Õeæ w÷³‹êª…Ĉg§qT“fQ{ZNYIK9\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀO1{G#‘JkRMqUMtVN–iS¨v\·€d¹bµzZ±vU°uT®sSªqS¤nRœjQ’eP„^OrUMHh>!T4\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀG-V5wE"~I#†M%U+¥e7²l:°g2®b*­a(­`(©^(¥])¡^-›]1ŠS,qC$`9 R3G-\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À@)J/i>!pA"tD"wF$yH&xH&tE$wE#yG%}M+ƒT4S5mE*Z7!K/B*;'\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À‰aO¦oR½{UÇ€VÏ…X<(F-a: e<!h>!j@#k@$h>"d<!c=$hD-fF2[<)K0@);'5$Ë‚VÇ€V¿|U_LKYIK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À…_O·xTÉ‚Wó«€ûµ‹Ö’k¼|X×>µf-¨^(¡Z'šW&–T&œN>)F-J/b; g>#nD(jB&c<!b=%jH2_A/I0!<(8&5$”J¥Y’S%8&;'?)E,<:HA=HE?IJAISFJYIKXIK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À£nRÁ}UܘqÊŠe±vU²e,™V&¥V†C
+€@ |> y< u: r9 o7 l6
+j5
+h4
+g3
+5$D,K/b; h>"wM1tK.e="a<#cA,U8&E-<(9&.!a0 b1 c1    
+
++3#@)46G<:HMCIXHK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀU*´vT¿~X¸{YÃk+›W&‰N$|> u: p8 k5
+f3
+a0 _/ ]. [- I¡\*ª_(‘LkRMmSMmSMnSMnSMD,R3W5mA"|O0|P1j?"c<!a=%Y7"N1F,;'NCJNCJNDJODJODJODJh>!a: X/K%
+g3
+a0 Z- \/ T*Q(ŠHµm8kRMmSMnTMoTMpTMpUM15G15G05G04G04GpUMpTM5^9 d<!yF#O+€N,rC#qB"pB#k?"a: Z7 6ODJPDJPEJQEJQEJREJREJREJRFJSFJSFJSFJSFJe<!X/
+^/ V+Q(L&I$r9  TlRMnSM46G47G47G46G46G46G46G46G36G36G25G25G15G04G/4F.3F
+ˆ`O~[NqUM[- ‰HUGJUGJVGJVGJVHJWHJWHJWHKWHKXHKXHKXHKXHKXHKXIKXIKXIKXIKXIKh>!Y0
+
+L&C!:4
+X&pUMuWMwXNxXN<:H<:H<:H<:H<;H<;H<;H<;H=;H=;H=;H=;H>;H>;H?<H@<HA=HC>HG@ILBIREJ[JKcNLjQL§pR±uTºzUÃ~VÈWË‚XÖŽcäsÒŽe¼{V²vT¨pSžkR•gQŒbP†_O‚^O]O€\O€\O€\O€\O€]O]O]O]O]O]O]O]O]O]O]O€\O€\O~\N}[N|ZNxXN•T%H$
+›W&rVMvWNyYNzYN|ZN}[N}[N><H?<H?<H?<H?<H?<H@<H@<H@<HA=HA=HB=HC>HE?IG@IIAIKBIODJSFJWHK—hQŸlR§pR°b(¾i*Én+Ù|7Û|6Ïr,Íq+Êp-Ãl+»g)±b(®sS§pS lRšiQ•gQePcPŠaPˆaO‡`O‡`O†_O†_O…_O…_O…_O…_O…_O…_O…_O„_O„^O„^Oƒ^Oƒ^O‚]O]O€\O~[N{ZN•T%
+
+
+
+ 
+@%<-$G?@…pfdNLuWM\NdNL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀTFJvWN‰aP./01„E}[N]O…_Oˆ`O‰aP‹bPŒbPcPcPŽcPdPdPdPeP‘eP’eP’eP“fP“fQ”fQ•gQ•gQ–gQ–hQ—hQ˜hQ™iQšiQ›jQœjQkQkRžlRŸlRžY&¤\'¨^'µ^½bÀcÃeÇi ÄgÀc½b¼a¹`µ^´]¯X¢[' Z'žY&¢mR¡mR¡mR lRŸlRŸlRžkRkQœkQœjQ›jQšjQšiQ™iQ™iQ˜iQ˜hQ—hQ—hQ—hQ–gQ–gQ•gQ•gQ•gQ”fQ”fQ“fQ“fP’eP‘ePdPcP‰aP—O
+ B\À\À\À\À\À\À\À\À\À\À%7!!C*F#P) {dYœze»p€\OgPL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀSFJ`LKvWNŠaPm6
+ 
+\À\À\À\À\À\À\À\À\À B B
+$5 ¬`(¶e)£nRœjQƒ^OJAI\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀXIK^KKdNLhPLuWM‚]OŒbP”fQeP
+m6
+†`OŽcP“fQ—hQ˜hQ™iQšiQšjQ›jQ›jQ›jQœjQœjQœjQœkQkQkQkRžkRžkRžkRžlRŸlRŸlRŸlR lR lR lR¡mR¡mR¡mR¡mRºg)³c(²c(±b(­V¿cÂeÅi!Åi!Àd¼bº`¹`·_·_¶^¢Q§]'ª_(­`(¹f)£nR£nR£nR£nR£nR£nR£nR¢nR¢nR¢nR¢nR¢nR¢nR¢mR¢mR¢mR¢mR¢mR¢mR¢mR¢mR¢mR¢nR¢mR¢mR£nR¢mR¢mR¡mR mRkR—hQˆGa0 ŠbP mRœjQ“fQ‰aP}[NrUMmSM…L$\À\À\À\À\À\À\À\À B B
+#C, 8&H.Z7 §pR›jQ{ZN\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀQEJ[JK`LKdNLhQLqUM{ZN…_OŽcP–gQ—hQ
+‹bP‘eP–hQšiQ›jQœjQkQkQkRžkRžkRžlRžlRŸlRŸlRŸlRŸlRŸlR lR lR lR mR¡mR¡mR¡mR¡mR¡mR¢mR¢mR¢mR¢nR£nRÀj*ºg)·e)¶d)Âd°XÅgÅhÂe¿c½b½b¾bªU­`(®a(¯a(³c(¾i*¤oR¤oR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤oR¤oR¥oR¥oR¥oR¥oR¥oR¥oR¦oR¦oR¥oR¥oR¤nR¡mR›jQŽQ%Z- œjQ£nRŸlR—hQŽdP…_OuWMpTMnSMkRLa: \À\À\À\À\À\À\À B B&D2
+@*S6#G@IPDJ˜hQmSM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀVGJ]KKbMLeOLiQLlRMvWN\OˆaO‘eP—hQœjQ•gQ
+\À\À\À\À\À B'D+E$(1 J/jH1NCJUGJYIKUGJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀXHK]KKbNLfOLiQLkRMmSMoTMqUMxXN\N†_OŒbP’fP˜hQkQ¡mR¥oR§pS¦pR˜hQ¢mR¥oR¨pSªqS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rSªrSªrSªrS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS«rS¬rS¬rS¬rS¬rS¬rS¬rS¬rS¬sS¬sS­sS­sS­sS­sS­sS­sS®sS®sS®sS®sS®tS¯tS°tS°uS±uS±uT±uT²uT²uT²uT´vTµwT´vT³vT²uT¯tS¢mR¯tS±uT±uS®tS«rS§pR¢mRkQ—hQ‘ePŠaPƒ^O\N{ZNvXNqUMpTMnSMlRMP%\À\À\À\À B#C*E$.E- .!G$Y:%d<"SFJYIKZIKNCJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀPDJZIK_LKdNLgPLjQLlRMnSMpTMqUMuWMyYN€\O†`OcP’fP—hQœjQ¡mR¥oR¨qS«rS«rSªrS mR
+!C+E'0F.4F7%8%U/lG.SFJZIK]KKZIKB=H\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀREJZJK`LKdNLgPLjQLlRMnSMpTMqUMtWMxXN{ZN~[N]O„^O†`O‰aO‹bPdP•gQ™iQœkQ lR¤nR§pSªrS­sS¯tT²uT´vT¶wT·xT¹yT¹yTºyTºyT¹yT¶xT´vT¬rS¢nR—hQ¿|U¿|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ}UÀ}UÁ}UÁ}UÁ}UÁ}UÂ}UÂ~UÃ~UÃ~VÃ~VÄVÅ€WÆX®a(ŸlRªrS´vT¸yT¼zU¾|UÁ~VÃXÆ‚[Ɇ_΋dÓ‘jÔ“mÔ“nБlÊŒhĆd½_¶{[°vWªsU¦pS¢nRžkRšiQ˜hQ•gQ“fQ‘ePdPŒbP‰aO†_Oƒ^O€\O|ZNxXNsVMpTMnTMmSMjQL€C B)D&/F-3F47G6%>" Y7 kA$YIK]KK^KKSFJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀVGJ\KKbMLeOLhPLkRLmSMnTMpTMrUMuWNyYN|ZN\N‚]O„_O‡`OŠaPŒbPŽcPeP“fP—hQ›jQžlR¢nR¥oS©qT¬sT¯uU²vU´wV¶xV¸yV¹yUºzU»zU¼{U½{U¾{U¾|U¿|U¿|U¿|U¿|U¾{U½{U¼{U¼zU»zTºyT¹yT¸xTµwT³vT´vT´vT´vT´wT´wTµwT·xT¹yTºzT¼zU½{U¾{U¿|UÀ|UÂ}UÄVÅ€WÇ‚YÉ„\͈_ÑŒdÙ”láuç£|쩂ſt명æ¦ÞŸ{Õ—sËŽl†d¹^³yZ­uW¨qU¤oSŸlRžkRœjQšiQ˜hQ–gQ”fQ‘ePdPcPŠaP‡`O„^O]O}[NyYNuWMpTMoTMmSMkRLgPL&D#.E,3F46G;'<(D"iB(VGJ]KK`LK[JKB>H\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀNCJYIK^LKcNLfOLiQLkRMmSMoTMqUMsVMvXNzYN}[N€\O‚^O…_Oˆ`OŠaPŒcPdP‘eP“fQ•gQ—hQ™iQkR mS¤oT¨rU¬tW°wY´zZ¸}\»]¾€^À^Á‚^‚^Â\Á€ZÁYÁXÁ~WÁ~WÂ~VÂ~VÂ~VÃ~VÃ~UÃ~UÄ~UÄ~UÄUÄUÅVÅVÅVÅVÆVÆ€VÆ€VÇ€WÇWÈ‚XɃZË…[͇^ЊaÓdØ’iÜ—nâtè£zî©ó¯‡ø´û¸‘üº“û¹“÷¶ñ±Œé©…à¡~Ö˜vËmÇf»€`´z[®vX©rU¥pT£oS¢nS lRžkRœkRšjQ˜iQ–hQ”fQ’ePdPcP‹bPˆ`O…_O‚]O~[NzYNvWNpTMoTMnSMkRMhQLo7 ,2F36G99HC+@ ]8 nA"\JK`ML_LKSFJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀSFJ[JK`LKdNLgPLjQLlRMnSMpTMqUMtVMwXNzZN}[N€]Oƒ^O†_OˆaO‹bPcPdP‘eP“fQ•gQ—hQ™iQ›jRžlR mS£oU§rW¬vZ²{]¹€a¿…fÅŠjËnГqÓ•sÕ–sÕ–rÕ–qÕ”oÓ’mÑjÏgÍŠcˈaɆ^È„\Ç‚[ÆYÅ€XÅ€WÅWÅWÅVÅVÅWÅ€WÆ€WÇXÈ‚YɃ[Ê…\͇_ÏŠaÒeÕ‘hÙ•mÝ™qávä¡zç¤}꧀멃몄騃奀ߠ|Ù›wÓ•rÌmƉh¿„c¸~^²yZ®vX¬tWªsV¨qU¦pT¤oS¢nS mRžlRœkR›jQ™iQ—hQ•gQ“fPePŽcP‹bPˆaO…_O‚^O\N{ZNwXNsVMoTMnSMlRMiQL~I#26G99G?<HA*E$ i@$ZIKaMLbML[JK;:H\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀWHJ]KKbMLeOLhPLjRLlSMnTMpTMrUMuWMxXN{ZN~\N]O„^O†`O‰aO‹bPŽcPdP’eP”fQ–gQ˜hQšiQœkRžlS mT£oU¦rWªuZ¯y]´~aºƒfŠlË’sÔšzÜ¡€ã§†è«‰ë®‹í¯Œí®‹ë¬ˆè¨„ã£~ßžyÚ™tÖ•oÒjÎŒfˈbÈ…_ƃ\ÅZÄ€YÃXÂWÂ~WÂ~WÂ~WÃXÀXÄ€YÅZƃ\Ç…^Ɇ`ˈbÌŠdÍ‹fÎgÎŽiÎŽjÎŽjÍŽjËŒiljgÆd¿ƒaº^¸}]¶|\´{[²yZ°xY®vX¬tWªsV¨qU¦pT¤oS¢nS mRžlRkR›jQ™iQ—hQ•gQ“fP‘ePŽdPŒbP‰aO†_Oƒ^O€\O|ZNxXNtVMpTMnSMmSMjQLgPL99G?<HG-E&b;!YIK`MLdOM`LKNCJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀŸlRºyTÄ~UÊ‚XʃYÄXº{W­tUšW'¢[(—hQ lRcP€\OhQL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀNCJYIK^LKcNLfOLiQLkRLmSMoTMqUMrVMvWNyYN|ZN\N‚]O„_O‡`O‰aPŒbPŽcPdP’fP”gQ–hQ˜iQšjRœkRžlS¡nT¤pU§sW«vZ°z]µb»„gŠlÉ‘sИyØžÞ¤…㩊è­ì±ï³‘ﳑ뭊穅⣀ݞzؘtÒ“nÎiɉdÆ…`Â]Á€[¿~Y¾}X½|W½|V¼{V¼{V¼{V¼{V¼{V¼|W¼|W½}X½}Y½~Z½~Z¼~Z»}[º}[º}[º~\º~\º~]º~]¹~]¸~]·}]¶|\´z[²yZ°wY®vX¬tWªsV¨rU¦pT¤oS¢nS mRŸlRkR›jQšiQ˜hQ–gQ“fQ‘ePdPŒcPŠaP‡`O„^O]O}[NyYNuWNpTMnTMmSMkRLhPL|H$D>IQ2P+XHK_LLfQOcNLXIK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À©qSºyTÃ~VΈ`遲ޜv¾€]ªqS–LŽG|> g3
+S)?*%.—hQ—hQ‘eP‡`OuWM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀSFJ[JK`LKdNLgPLjQLlRMnSMoTMqUMsVMwXNzYN}[N€\O‚^O…_O‡`OŠaPŒbPŽdP‘eP“fP•gQ—hQ˜iQšjRœkRŸlS¡nT¤pV§sX«vZ°z^¶b¼…gËmÊ’sјzØŸ€Þ¤…㩊è­ê¯ë°ê¯Žè¬‹å¨‡à¤‚Ûž|Ö™wÑ“qÌŽlljgÃ…bÀ‚_½\»}Zº{X¹zW¸yV·yU·xU·xU·xT·xT·xU·xU·xU·yV·yV·yW¸zW¸{X¹{Y¹|Zº}[º}[º}\º~\¹~]¹~]¸}]·|\µ{\´z[²yZ°wY®vX¬tWªsV¨rU¦pT¤oS¢nS¡mRŸlRkRœjQšiQ˜hQ–gQ”fQ’ePdPcPŠbP‡`O…_O‚]O~[NzZNvWNrUMoTMmSMlRMiQLeOLJAIJ(h>!]KKfQOgQN_LKD>I\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À™iQ°tS¸yT¼{UÂYÎŒeï­ˆô´Õ—u¶|\ Z'™LˆD
+|>
+
++,!.! "`E6†iYŒlZo\“q]•s^^J™va›wbycŸzd {e¤}foTMqUMsVMuWNwXNyYN{ZN|ZN~[N\O]O‚]Oƒ^O…_O†_O‡`Oˆ`O‰aOŠaP‹bPŒbPŒcPcPŽcPŽdPdPdPdPeP‘eP‘eP‘eP’eP’eP’eP’eP’fP’fP’fP“fP’fP’fP’fP’eP’eP’eP‘eP‘eP‘ePePdPdPdPŽdPŽcPcPŒcPŒbP‹bPŠaP‰aOˆ`O‡`O†_O…_Oƒ^O‚]O]O\O~[N|[N{ZNyYNwXN®ƒi¬ƒiª‚i¨i¦€hŒhR‰fQ†dQ‚bP•wfx]Oˆpdkbtd_m`]OEDG?A;:@.S….S….S….S….S…/S…/S…/S…/S…/S…/S…/S…/S…TxªTxªTxªTxªTxªTx«Tx«Tx«Ty«/S†GlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlž…ªÜ…ªÜ…ªÜHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlž…ªÜ…ªÜ£Ö£Ö£Ö£Ö¤Ö¤Ö¤Ö¤Ö¤ÖEi›€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤×€¤×€¤×€¤×€¥×€¥×€¥×Bg™Bg™Bg™Bg™Bg™&J|&J|&J|&J|&J|&J|&J|&J|&J|&J|&J|&J|&J|Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Af˜Af˜%J|%J|%J|%J|%J|%J|%J|%J|%J|%J|%I|%I|%I|%I|%I|%I|
++,YA5jPBpSD‹l[o]’q^–t`‚_Kšwbœycžze {f¡}g¤h¨i”lSrVMtWMvWNxXNyYN{ZN|[N~[N\O]O‚]Oƒ^O„_O…_O†`O‡`Oˆ`O‰aPŠaP‹bP‹bPŒbPcPcPŽcPŽcPdPdPdPdPdPdPdPdPePePePePePdPdPdPdPdPdPdPŽcPŽcPcPcPŒbP‹bP‹bPŠaP‰aOˆ`O‡`O†`O…_O„^Oƒ^O‚]O€]O\O~[N|[N{ZNyYNxXN°…j®„j¬„jªƒj¨‚j¦€jŒhSŠgS†eRƒcR|`QŒsf…oe}jcrd`k_]LCDC=@,,3(4F(4F.S….S…/S…/S…/S…/S…/S…/S…/S…TxªTxªTxªTxªTxªTxªTx«Tx«Tx«Ty«Ty«Ty«…ªÜHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlž†ªÜHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžChšChš¤Ö€¤Ö€¤Ö€¤Ö€¤ÖEi›Ei›Ei›€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤Ö€¤×€¤×€¤×€¤×Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Bg™Bg™&J|&J|&J|&J|&J|&J|&J|&J|&J|&J|Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜&J|%J|%J|%J|%J|%J|%J|%J|%J|%J|%J|%J|%I|%I|%I|%I|%I|#5H71O;3V?4iOBoSDsVFo]{[I^Kƒ`L…bN‡dOŸ{f }g¢~h¥€j’kT•mU˜oVšqWrWwXNxXNzYN{ZN}[N~[N\O€]O‚]Oƒ^O„^O…_O…_O†`O‡`Oˆ`O‰aO‰aPŠaP‹bP‹bPŒbPŒbPŒcPcPcPcPŽcPŽcPŽcPŽcPŽcPŽcPŽcPŽcPŽcPŽcPcPcPcPŒcPŒbP‹bP‹bP‹bPŠaP‰aP‰aOˆ`O‡`O†_O…_O„_O„^Oƒ^O]O€\O\N~[N|ZN{ZNyYN›oTšoT™oT—nT¬„lªƒl¨‚ljUŒiTŠhT†fT€cSvi‰rgnfyidqdah^^HBD?<@)+3OZkMYk(5F(5F(5F/S…/S…/S…/S…/S…TxªTxªTxªTxªTxªTxªTx«Tx«Ty«Ty«Ty«Ty«Uy«†ªÜ†ªÜ†ªÜ†ªÜHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlž†ªÜ†ªÜ†ªÜ†ªÜ†ªÜHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžHlžDhšDhšDhšChš&K}&K}&K}&K}&K}&K}ChšChšCgšCgšCgšCgšCgšCgšCg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™&J|&J|&J|&J|&J|&J|Bg™Bg™Bg™Bf™Bf™Bf™Bf™Bf™Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜&J|&J|&J|&J|%J|%J|%J|%J|%J|%J|%J|%J|%J|%J|%J|%I|%I|A99N?;L:2T>4gNBlRD‡k\‹n^z[J~^LaN…cO‡dP‰fQŠgRŒhTjU’lV•nW˜pXšrXsY¶‹q¸qºŽr¼r½r¿s©z[©z[ªz[«{[¬{[¬{ZÅ“rÅ’qÅ’qÅ’pÅ’pÅ‘o­yV­xV¬xU¬wT¬wTŠaPŠbP‹bP‹bP‹bP‹bP‹bP‹bP‹bP‹bP‹bP‹bP‹bP‹bPŠaPŠaPŠaP‰aP‰aOˆaOˆ`O‡`O‡`O†_O…_O„^Oƒ^O‚^O‚]O]O€\O~\N}[N|ZNzYNpTœpU›pUšpU˜oV—oV•nV“mV‘lVkVŒjVˆhVƒfU~cUuj†qh~mfugdkaad\^E@D98?$(2minffm^blV^lMYk(5F(5F/S…TxªTxªTxªTxªTxªTxªTxªTx«Tx«Ty«Ty«Ty«Uy«Uy«†ªÜ†ªÜ†ªÜ†ªÜ†ªÜ†ªÜ†ªÜ†ªÜHlžHlžHlžHlžHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸ†ªÝ†ªÝ†ªÝ†ªÝ†ªÝ†ªÝ†ªÝ†ªÝ†ªÝ†ªÝHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸHlŸ'K}'K}'K}'K}'K}'K}'K}'K}'K}&K}&K}ChšChšChšChšChšChšChšCgšCgšCgšCgšCgšCgšCg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™&J|Cg™Cg™Cg™Cg™Cg™Bg™Bg™Bg™Bg™Bg™Bg™Bf™Bf™Bf™Bf™Bf™Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜Bf˜&J|&J|&J|&J|&J|&J|&J|%J|%J|%J|%J|%J|%J|%J|Ae˜Ae˜;GY<68I=:I82Q=4XA6~fZ„j\‰m^p`|]L€`NƒcP†eQˆgS¡j£€l¦‚m©„n•oX˜qYšrZt[¶Œr¸sºs¼t½t¾‘t¨z]©{]ª{]«{\«{\¬{\¬{[Ä“sÄ“rÄ’rÄ’qÄ’pÄ‘p¬yWÄoÃnÃmÃlÂŽlÂŽkÁkˆaOˆaOˆaOˆaOˆaOˆaOˆaOˆ`Oˆ`O‡`O‡`O‡`O†`O†_O…_O…_O„_O„^Oƒ^O‚]O]O€]O\O~\N}[N|ZN¶‰l¶‰lµˆmœqV›qVšqV™pW˜pW–oW¬…nª…n§„n¤‚nŸ€n›~n€eW‘xlŠtk‚piykfodcf_`JDG@>C*,5$1MYktr~tstmolinadmX_lNZkMZkTxªTxªTxªTxªTx«Tx«Tx«Ty«Ty«Ty«Uy«Uy«Uy«†ªÝ†ªÝ†ªÝ†ªÝ†ªÝ†ªÝ†«Ý†«Ý†«Ý†«ÝHlŸHlŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸ†«Ý†«Ý†«Ý‡«Ý‡«Ý‡«Ý‡«Ý‡«Ý‡«Ý‡«Ý‡«Ý‡«Ý‡«ÝHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸHmŸ'K}'K}'K}'K}'K}'K}'K}'K}'K}'K}'K}'K}DhšDhšDhšDhšChšChšChšChšChšChšChšCgšCgšCgšCgšCgšCgšCg™Cg™Cg™Cg™Cg™&J}&J}&J}Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Cg™Bg™Bg™Bg™Bg™Bg™Bg™Bf™Bf™Bf™Bf™Bf˜Bf˜Bf˜Bf˜Bf˜&J|&J|&J|&J|&J|&J|&J|&J|&J|&J|Af˜Af˜Af˜Af˜;GY;GY;GY1'!D:9N?;N;3]I?zdY€h[†l^‹oasc“ue€bQ„dR‡fT l¢m¦ƒn©…o«‡p®ˆq±Šr³‹sžv] w]¹u»u¼‘u¾‘u¿’v¨{^©{^ª|^«|]«|]«{\¬{\¬{[¬{[¬zZ«zZ«yY«yX«xXÂoÂnÂnÁŽmÁŽm¨uT¨uS§tS§tS§tR¦sR¦sQ…_O…_O…_O„^O„^Oƒ^Oƒ^O‚^O‚]O]O€]O¢rS¡rS¡rS¸‰k·‰l·‰l¶‰m¶‰mµ‰m´‰n³‰n›qWšqX™qX®‡o­‡o«†p¨…p¤ƒp pœp—}o{cXv`Vp]U}nishfhaba\_DAF::B$)4
+., 7(8'A1&F4(L8*oXIw]Jpdasfcvhexkg{mi~oj€qll\Xn^Yp`Zpa[qa\rb]rc^sc^sd_ue`wf`xgayhayhayhbxy‘y‘y‘y‘yy~ywgbvfateasd`qd`pc`nb_la_€ut|ssxqrunpZUXVRWROUMMSHIRIC@967-/3'+0(*-ACF?AD;=@#%(
+.+>1(B3)B2&F4'E4)gTGlXJs^OzcTzaPqfethgvjhbVTcWUdXVeYWfZXg[Yh\Zi]Zi][j^\€us€ususts~tt~tt}tt|st{stut~tt|sszrsyqrwpquoqsmpqloXTXTQWPOULLSSJEA<:=99757335./2113)+.'),)+.8:="(
+"6*#5*">2)>0&A2'C3(I8-^OFbRHfUJjXMq^RwcVzfYfRDfQCdN@zdTqijrjksklrklrklrklqjmpjmpjmojmojmnimmimkhliflscYm`Xg\VbYT^VRE>;A<:>98:77645:873220/0,-/)+.*,/#%( &
+
+&3#.$-% .% .& /&!,#,#@70A71XNHXNHWNHWNHZRLYQLYQLXQLWQLWPLUOLSNLQMKOLJMJJ0//.-.,,-&(+"(!'
+
+ %' %$#" ! !$
+
+
+ 
+
+
+*  
+  ;?E7CU;HY=I[ 
diff --git a/ext/tk/sample/iso2022-kr.txt b/ext/tk/sample/iso2022-kr.txt
new file mode 100644
index 0000000000..2e3fe6ea2a
--- /dev/null
+++ b/ext/tk/sample/iso2022-kr.txt
@@ -0,0 +1,2 @@
+Sample text:
+$)C Hangul (GQ1[) >H3gGO<<?d, >H3gGO=J4O1n
diff --git a/ext/tk/sample/menubar1.rb b/ext/tk/sample/menubar1.rb
new file mode 100644
index 0000000000..9fa1201d41
--- /dev/null
+++ b/ext/tk/sample/menubar1.rb
@@ -0,0 +1,51 @@
+#
+# menubar sample 1 : use frame and menubuttons
+#
+
+require 'tk'
+
+radio_var = TkVariable.new('y')
+
+menu_spec = [
+ [['File', 0],
+ {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
+ '---',
+ ['Check_A', TkVariable.new(true), 6],
+ {:type=>'checkbutton', :label=>'Check_B',
+ :variable=>TkVariable.new, :underline=>6},
+ '---',
+ ['Radio_X', [radio_var, 'x'], 6, '', {:foreground=>'black'}],
+ ['Radio_Y', [radio_var, 'y'], 6],
+ ['Radio_Z', [radio_var, 'z'], 6],
+ '---',
+ ['cascade', [
+ ['sss', proc{p 'sss'}, 0],
+ ['ttt', proc{p 'ttt'}, 0],
+ ['uuu', proc{p 'uuu'}, 0],
+ ['vvv', proc{p 'vvv'}, 0],
+ ],
+ 0, '',
+ {:font=>'Courier 16 italic',
+ :menu_config=>{:font=>'Times -18 bold', :foreground=>'black'}}],
+ '---',
+ ['Quit', proc{exit}, 0]],
+
+ [['Edit', 0],
+ ['Cut', proc{puts('Cut clicked')}, 2],
+ ['Copy', proc{puts('Copy clicked')}, 0],
+ ['Paste', proc{puts('Paste clicked')}, 0]],
+
+ [['Help', 0, {:menu_name=>'help'}],
+ ['About This', proc{puts('Ruby/Tk menubar sample 1')}, 6]]
+]
+
+menubar = TkMenubar.new(nil, menu_spec,
+ 'tearoff'=>false,
+ 'foreground'=>'grey40',
+ 'activeforeground'=>'red',
+ 'font'=>'Helvetia 12 bold')
+menubar.pack('side'=>'top', 'fill'=>'x')
+
+TkText.new(:wrap=>'word').pack.insert('1.0', 'Please read the sample source, and check how to override default configure options of menu entries on a menu_spec. Maybe, on windows, this menubar does not work properly about keyboard shortcuts. Then, please use "menu" option of root/toplevel widget (see sample/menubar2.rb).')
+
+Tk.mainloop
diff --git a/ext/tk/sample/menubar2.rb b/ext/tk/sample/menubar2.rb
new file mode 100644
index 0000000000..4507d8b2fe
--- /dev/null
+++ b/ext/tk/sample/menubar2.rb
@@ -0,0 +1,56 @@
+#
+# menubar sample 2 : use 'menu' option of root/toplevel widget
+#
+
+require 'tk'
+
+radio_var = TkVariable.new('y')
+
+menu_spec = [
+ [['File', 0],
+ {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
+ '---',
+ ['Check_A', TkVariable.new(true), 6],
+ {:type=>'checkbutton', :label=>'Check_B',
+ :variable=>TkVariable.new, :underline=>6},
+ '---',
+ ['Radio_X', [radio_var, 'x'], 6, '', {:foreground=>'black'}],
+ ['Radio_Y', [radio_var, 'y'], 6],
+ ['Radio_Z', [radio_var, 'z'], 6],
+ '---',
+ ['cascade', [
+ ['sss', proc{p 'sss'}, 0],
+ ['ttt', proc{p 'ttt'}, 0],
+ ['uuu', proc{p 'uuu'}, 0],
+ ['vvv', proc{p 'vvv'}, 0],
+ ],
+ 0, '',
+ {:font=>'Courier 16 italic',
+ :menu_config=>{:font=>'Times -18 bold', :foreground=>'black'}}],
+ '---',
+ ['Quit', proc{exit}, 0]],
+
+ [['Edit', 0],
+ ['Cut', proc{puts('Cut clicked')}, 2],
+ ['Copy', proc{puts('Copy clicked')}, 0],
+ ['Paste', proc{puts('Paste clicked')}, 0]],
+
+ [['Help', 0, {:menu_name=>'help'}],
+ ['About This', proc{puts('Ruby/Tk menubar sample 2')}, 6]]
+]
+
+mbar = Tk.root.add_menubar(menu_spec,
+ # followings are default configure options
+ 'tearoff'=>'false',
+ 'foreground'=>'grey40',
+ 'activeforeground'=>'red',
+ 'font'=>'Helvetia 12 bold')
+# This (default configure options) is NOT same the following.
+#
+# mbar = Tk.root.add_menubar(menu_spec)
+# mbar.configure('foreground'=>'grey40', 'activeforeground'=>'red',
+# 'font'=>'Helvetia 12 bold')
+
+TkText.new(:wrap=>'word').pack.insert('1.0', 'Please read the sample source, and check how to override default configure options of menu entries on a menu_spec.')
+
+Tk.mainloop
diff --git a/ext/tk/sample/msgs_rb/README b/ext/tk/sample/msgs_rb/README
new file mode 100644
index 0000000000..2e3ff2a9c4
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/README
@@ -0,0 +1,3 @@
+Message catalogs in this directory depend on Tcl/Tk's message catalogs.
+Texts of each locale are copied from Tcl/Tk8.5a1 widget demos.
+Please refer '../msgs_tk/README'.
diff --git a/ext/tk/sample/msgs_rb/cs.msg b/ext/tk/sample/msgs_rb/cs.msg
new file mode 100644
index 0000000000..199f2a73bd
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/cs.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ cs "Application Error", "Chyba programu"
+ cs "Blue", "Modr\341"
+ cs "Color", "Barva"
+ cs "Delete", "Smazat"
+ cs "Error", "Chyba"
+ cs "Exit", "Konec"
+ cs "Green", "Zelen\341"
+ cs "Red", "\\u010cerven\341"
+ cs "blue", "modr\341"
+ cs "green", "zelen\341"
+ cs "red", "\\u010derven\341"
+}
+
+TkMsgCatalog.new('::tk') {
+ cs "&Abort", "&P\\u0159eru\\u0161it"
+ cs "About...", "O programu..."
+ cs "All Files", "V\\u0161echny soubory"
+ cs "Application Error", "Chyba programu"
+ cs "&Blue", "&Modr\341"
+ cs "&Cancel", "&Zru\\u0161it"
+ cs "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Nemohu zm\\u011bnit atku\341ln\355 adres\341\\u0159 na \"%1\$s\".\nP\\u0159\355stup odm\355tnut."
+ cs "Choose Directory", "V\375b\\u011br adres\341\\u0159e"
+ cs "Clear", "Smazat"
+ cs "Color", "Barva"
+ cs "Console", "Konzole"
+ cs "Copy", "Kop\355rovat"
+ cs "Cut", "Vy\\u0159\355znout"
+ cs "Delete", "Smazat"
+ cs "Details >>", "Detaily >>"
+ cs "Directory \"%1\$s\" does not exist.", "Adres\341\\u0159 \"%1\$s\" neexistuje."
+ cs "&Directory:", "&Adres\341\\u0159:"
+ cs "Error: %1\$s", "Chyba: %1\$s"
+ cs "Exit", "Konec"
+ cs "File \"%1\$s\" already exists.\n\n", "Soubor \"%1\$s\" ji\\u017e existuje.\n\n"
+ cs "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Soubor \"%1\$s\" ji\\u017e existuje.\nChcete jej p\\u0159epsat?"
+ cs "File \"%1\$s\" does not exist.", "Soubor \"%1\$s\" neexistuje."
+ cs "File &name:", "&Jm\351no souboru:"
+ cs "File &names:", "&Jm\351na soubor\\u016f:"
+ cs "Files of &type:", "&Typy soubor\\u016f:"
+ cs "Fi&les:", "Sou&bory:"
+ cs "&Filter", "&Filtr"
+ cs "Fil&ter:", "Fil&tr:"
+ cs "&Green", "Ze&len\341"
+ cs "Hi"
+ cs "Hide Console", "Skr\375t konsolu"
+ cs "&Ignore", "&Ignorovat"
+ cs "Invalid file name \"%1\$s\".", "\\u0160patn\351 jm\351no souboru \"%1\$s\"."
+ cs "Log Files", "Log soubory"
+ cs "&No", "&Ne"
+ cs "&OK"
+ cs "Ok"
+ cs "Open", "Otev\\u0159\355t"
+ cs "&Open", "&Otev\\u0159\355t"
+ cs "Open Multiple Files", "Otev\\u0159\355t v\355ce soubor\\u016f"
+ cs "Paste", "Vlo\\u017eit"
+ cs "Quit", "Skon\\u010dit"
+ cs "&Red", " \\u010ce&rven\341"
+ cs "Replace existing file?", "Nahradit st\341vaj\355c\355 soubor?"
+ cs "&Retry", "Z&novu"
+ cs "&Save", "&Ulo\\u017eit"
+ cs "Save As", "Ulo\\u017eit jako"
+ cs "Save To Log", "Ulo\\u017eit do logu"
+ cs "Select Log File", "Vybrat log soubor"
+ cs "Select a file to source", "Vybrat soubor k nahr\341n\355"
+ cs "&Selection:", "&V\375b\\u011br:"
+ cs "Skip Messages", "P\\u0159esko\\u010dit zpr\341vy"
+ cs "Source...", "Nahr\341t..."
+ cs "Tcl Scripts", "Tcl skripty"
+ cs "Tcl for Windows", "Tcl pro Windows"
+ cs "Text Files", "Textov\351 soubory"
+ cs "&Yes", "&Ano"
+ cs "abort", "p\\u0159eru\\u0161it"
+ cs "blue", "modr\341"
+ cs "cancel", "zru\\u0161it"
+ cs "extension", "p\\u0159\355pona"
+ cs "extensions", "p\\u0159\355pony"
+ cs "green", "zelen\341"
+ cs "ignore", "ignorovat"
+ cs "ok"
+ cs "red", "\\u010derven\341"
+ cs "retry", "znovu"
+ cs "yes", "ano"
+}
diff --git a/ext/tk/sample/msgs_rb/de.msg b/ext/tk/sample/msgs_rb/de.msg
new file mode 100644
index 0000000000..283874df42
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/de.msg
@@ -0,0 +1,88 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ de "Application Error", "Applikationsfehler"
+ de "Blue", "Blau"
+ de "Color", "Farbe"
+ de "Delete", "L\\u00f6schen"
+ de "Error", "Fehler"
+ de "Exit", "Ende"
+ de "Green", "Gr\\u00fcn"
+ de "Red", "Rot"
+ de "blue", "blau"
+ de "green", "gr\\u00fcn"
+ de "red", "rot"
+}
+
+TkMsgCatalog.new('::tk') {
+ de "&Abort", "&Abbruch"
+ de "&About...", "&\\u00dcber..."
+ de "All Files", "Alle Dateien"
+ de "Application Error", "Applikationsfehler"
+ de "&Blue", "&Blau"
+ de "&Cancel", "&Abbruch"
+ de "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Kann nicht in das Verzeichnis \"%1\$s\" wechseln.\nKeine Rechte vorhanden."
+ de "Choose Directory", "W\\u00e4hle Verzeichnis"
+ de "&Clear", "&R\\u00fccksetzen"
+ de "&Clear Console", "&Konsole l\\u00f6schen"
+ de "Color", "Farbe"
+ de "Console", "Konsole"
+ de "&Copy", "&Kopieren"
+ de "Cu&t", "Aus&schneiden"
+ de "&Delete", "&L\\u00f6schen"
+ de "Details >>"
+ de "Directory \"%1\$s\" does not exist.", "Das Verzeichnis \"%1\$s\" existiert nicht."
+ de "&Directory:", "&Verzeichnis:"
+ de "&Edit", "&Bearbieten"
+ de "Error: %1\$s", "Fehler: %1\$s"
+ de "E&xit", "&Ende"
+ de "&File", "&Datei"
+ de "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Die Datei \"%1\$s\" ist bereits vorhanden.\nWollen sie diese Datei \\u00fcberschreiben ?"
+ de "File \"%1\$s\" already exists.\n\n", "Die Datei \"%1\$s\" ist bereits vorhanden.\n\n"
+ de "File \"%1\$s\" does not exist.", "Die Datei \"%1\$s\" existiert nicht."
+ de "File &name:", "Datei&name:"
+ de "File &names:", "Datei&namen:"
+ de "Files of &type:", "Dateien des &Typs:"
+ de "Fi&les:", "Dat&eien:"
+ de "&Filter"
+ de "Fil&ter:"
+ de "&Green", "&Gr\\u00fcn"
+ de "&Help", "&Hilfe"
+ de "Hi", "Hallo"
+ de "&Hide Console", "&Konsole unsichtbar machen"
+ de "&Ignore", "&Ignorieren"
+ de "Invalid file name \"%1\$s\".", "Ung\\u00fcltiger Dateiname \"%1\$s\"."
+ de "Log Files", "Protokolldatei"
+ de "&No", "&Nein"
+ de "OK"
+ de "Ok"
+ de "Open", "\\u00d6ffnen"
+ de "&Open", "\\u00d6&ffnen"
+ de "Open Multiple Files"
+ de "P&aste", "E&inf\\u00fcgen"
+ de "&Quit", "&Beenden"
+ de "&Red", "&Rot"
+ de "Replace existing file?", "Existierende Datei ersetzen?"
+ de "&Retry", "&Wiederholen"
+ de "&Save", "&Speichern"
+ de "Save As", "Speichern unter"
+ de "Save To Log", "In Protokoll speichern"
+ de "Select Log File", "Protokolldatei ausw\\u00e4hlen"
+ de "Select a file to source", "Auszuf\\u00fchrende Datei ausw\\u00e4hlen"
+ de "&Selection:", "Auswah&l:"
+ de "Skip Messages", "Weitere Nachrichten \\u00fcberspringen"
+ de "&Source...", "&Ausf\\u00fchren..."
+ de "Tcl Scripts", "Tcl-Skripte"
+ de "Tcl for Windows", "Tcl f\\u00fcr Windows"
+ de "Text Files", "Textdateien"
+ de "&Yes", "&Ja"
+ de "abort", "abbrechen"
+ de "blue", "blau"
+ de "cancel", "abbrechen"
+ de "extension", "Erweiterung"
+ de "extensions", "Erweiterungen"
+ de "green", "gr\\u00fcn"
+ de "ignore", "ignorieren"
+ de "ok"
+ de "red", "rot"
+ de "retry", "wiederholen"
+ de "yes", "ja"
+}
diff --git a/ext/tk/sample/msgs_rb/el.msg b/ext/tk/sample/msgs_rb/el.msg
new file mode 100644
index 0000000000..f314ae03eb
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/el.msg
@@ -0,0 +1,98 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ el 'Application Error', '\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2'
+ el 'Blue', '\u039c\u03c0\u03bb\u03b5'
+ el 'Color', '\u03a7\u03c1\u03ce\u03bc\u03b1'
+ el 'Delete', '\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae'
+ el 'Error', '\u039b\u03ac\u03b8\u03bf\u03c2'
+ el 'Exit', '\u0388\u03be\u03bf\u03b4\u03bf\u03c2'
+ el 'Green', '\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'Red', '\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+ el 'blue', '\u03bc\u03c0\u03bb\u03b5'
+ el 'green', '\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'red', '\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+}
+
+TkMsgCatalog.new('::tk') {
+ el '&Abort', '\u03a4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2'
+ el 'About...', '\u03a3\u03c7\u03b5\u03c4\u03b9\u03ba\u03ac...'
+ el 'All Files', '\u038c\u03bb\u03b1 \u03c4\u03b1 \u0391\u03c1\u03c7\u03b5\u03af\u03b1'
+ el 'Application Error', '\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2'
+ el '&Blue', '\u039c\u03c0\u03bb\u03b5'
+ el '&Cancel', '\u0391\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7'
+ el 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', \
+ '\u0394\u03b5\u03bd \u03b5\u03af\u03bd\u03b1\u03b9 \u03b4\u03c5\u03bd\u03b1\u03c4\u03ae \u03b7 \u03b1\u03bb\u03bb\u03b1\u03b3\u03ae \u03ba\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5 \u03c3\u03b5 "%1\$s".' \
+ "\n" \
+ '\u0397 \u03c0\u03c1\u03cc\u03c3\u03b2\u03b1\u03c3\u03b7 \u03b4\u03b5\u03bd \u03b5\u03c0\u03b9\u03c4\u03c1\u03ad\u03c0\u03b5\u03c4\u03b1\u03b9.'
+ el 'Choose Directory', '\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u039a\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5'
+ el 'Clear', '\u039a\u03b1\u03b8\u03b1\u03c1\u03b9\u03c3\u03bc\u03cc\u03c2'
+ el 'Color', '\u03a7\u03c1\u03ce\u03bc\u03b1'
+ el 'Console', '\u039a\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1'
+ el 'Copy', '\u0391\u03bd\u03c4\u03b9\u03b3\u03c1\u03b1\u03c6\u03ae'
+ el 'Cut', '\u0391\u03c0\u03bf\u03ba\u03bf\u03c0\u03ae'
+ el 'Delete', '\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae'
+ el 'Details >>', '\u039b\u03b5\u03c0\u03c4\u03bf\u03bc\u03ad\u03c1\u03b5\u03b9\u03b5\u03c2 >>'
+ el 'Directory "%1\$s", does not exist.', \
+ '\u039f \u03ba\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2 \'%1\$s\' \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.'
+ el '&Directory:', '&\u039a\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2:'
+ el 'Error: %1\$s', '\u039b\u03ac\u03b8\u03bf\u03c2: %1\$s'
+ el 'Exit', '\u0388\u03be\u03bf\u03b4\u03bf\u03c2'
+ el 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', \
+ '\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf "%1\$s" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.' \
+ "\n" \
+ '\u0398\u03ad\u03bb\u03b5\u03c4\u03b5 \u03bd\u03b1 \u03b5\u03c0\u03b9\u03ba\u03b1\u03bb\u03c5\u03c6\u03b8\u03b5\u03af;'
+ el 'File "%1\$s" already exists.' "\n\n", \
+ '\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf "%1\$s" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.' "\n\n"
+ el 'File "%1\$s" does not exist.', \
+ '\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf "%1\$s" \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.'
+ el 'File &name:', '\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5:'
+ el 'File &names:', '\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd:'
+ el 'Files of &type:', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u03c4\u03bf\u03c5 &\u03c4\u03cd\u03c0\u03bf\u03c5:'
+ el 'Fi&les:', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1:'
+ el '&Filter', '\u03a6\u03af\u03bb\u03c4\u03c1\u03bf'
+ el 'Fil&ter:', '\u03a6\u03af\u03bb\u03c4\u03c1\u03bf:'
+ el '&Green', '\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'Hi', '\u0393\u03b5\u03b9\u03b1'
+ el 'Hide Console', '\u0391\u03c0\u03cc\u03ba\u03c1\u03c5\u03c8\u03b7 \u03ba\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1\u03c2'
+ el '&Ignore', '\u0391\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7'
+ el 'Invalid file name "%1\$s".', \
+ '\u0386\u03ba\u03c5\u03c1\u03bf \u03cc\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 "%1\$s".'
+ el 'Log Files', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2'
+ el '&No', '\u038c\u03c7\u03b9'
+ el '&OK', '\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9'
+ el '&Ok', '\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9'
+ el 'Open', '\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1'
+ el '&Open', '\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1'
+ el 'Open Multiple Files', \
+ '\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1 \u03c0\u03bf\u03bb\u03bb\u03b1\u03c0\u03bb\u03ce\u03bd \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd'
+ el 'Paste', '\u0395\u03c0\u03b9\u03ba\u03cc\u03bb\u03bb\u03b7\u03c3\u03b7'
+ el 'Quit', '\u0388\u03be\u03bf\u03b4\u03bf\u03c2'
+ el '&Red', '\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+ el 'Replace existing file?', \
+ '\u0395\u03c0\u03b9\u03ba\u03ac\u03bb\u03c5\u03c8\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03bf\u03bd\u03c4\u03bf\u03c2 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5;'
+ el '&Retry', '\u03a0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac'
+ el '&Save', '\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7'
+ el 'Save As', '\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03b1\u03bd'
+ el 'Save To Log', '\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03c4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2'
+ el 'Select Log File', '\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2'
+ el 'Select a file to source', \
+ '\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03b3\u03b9\u03b1 \u03b5\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7'
+ el '&Selection:', '\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae:'
+ el 'Skip Messages', '\u0391\u03c0\u03bf\u03c6\u03c5\u03b3\u03ae \u03bc\u03c5\u03bd\u03b7\u03bc\u03ac\u03c4\u03c9\u03bd'
+ el 'Source...', '\u0395\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7...'
+ el 'Tcl Scripts', 'Tcl Scripts'
+ el 'Tcl for Windows', 'Tcl \u03b3\u03b9\u03b1 Windows'
+ el 'Text Files', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b5\u03b9\u03bc\u03ad\u03bd\u03bf\u03c5'
+ el '&Yes', '\u039d\u03b1\u03b9'
+ el 'abort', '\u03c4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2'
+ el 'blue', '\u03bc\u03c0\u03bb\u03b5'
+ el 'cancel', '\u03b1\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7'
+ el 'extension', '\u03b5\u03c0\u03ad\u03ba\u03c4\u03b1\u03c3\u03b7'
+ el 'extensions', '\u03b5\u03c0\u03b5\u03ba\u03c4\u03ac\u03c3\u03b5\u03b9\u03c2'
+ el 'green', '\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'ignore', '\u03b1\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7'
+ el 'ok', '\u03b5\u03bd\u03c4\u03ac\u03be\u03b5\u03b9'
+ el 'red', '\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+ el 'retry', '\u03c0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac'
+ el 'yes', '\u03bd\u03b1\u03b9'
+}
+
diff --git a/ext/tk/sample/msgs_rb/en.msg b/ext/tk/sample/msgs_rb/en.msg
new file mode 100644
index 0000000000..9b70239511
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/en.msg
@@ -0,0 +1,83 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ en "Application Error"
+ en "Blue"
+ en "Color"
+ en "Delete"
+ en "Error"
+ en "Green"
+ en "Red"
+ en "blue"
+ en "green"
+ en "red"
+}
+
+TkMsgCatalog.new('::tk') {
+ en "&Abort"
+ en "About..."
+ en "All Files"
+ en "Application Error"
+ en "&Blue"
+ en "&Cancel"
+ en "Cannot change to the directory \"%1\$s\".\nPermission denied."
+ en "Choose Directory"
+ en "Clear"
+ en "Color"
+ en "Console"
+ en "Copy"
+ en "Cut"
+ en "Delete"
+ en "Details >>"
+ en "Directory \"%1\$s\" does not exist."
+ en "&Directory:"
+ en "Error: %1\$s"
+ en "Exit"
+ en "File \"%1\$s\" already exists.\nDo you want to overwrite it?"
+ en "File \"%1\$s\" already exists.\n\n"
+ en "File \"%1\$s\" does not exist."
+ en "File &name:"
+ en "File &names:"
+ en "Files of &type:"
+ en "Fi&les:"
+ en "&Filter"
+ en "Fil&ter:"
+ en "&Green"
+ en "Hi"
+ en "Hide Console"
+ en "&Ignore"
+ en "Invalid file name \"%1\$s\"."
+ en "Log Files"
+ en "&No"
+ en "&OK"
+ en "Ok"
+ en "Open"
+ en "&Open"
+ en "Open Multiple Files"
+ en "Paste"
+ en "Quit"
+ en "&Red"
+ en "Replace existing file?"
+ en "&Retry"
+ en "&Save"
+ en "Save As"
+ en "Save To Log"
+ en "Select Log File"
+ en "Select a file to source"
+ en "&Selection:"
+ en "Skip Messages"
+ en "Source..."
+ en "Tcl Scripts"
+ en "Tcl for Windows"
+ en "Text Files"
+ en "&Yes"
+ en "abort"
+ en "blue"
+ en "cancel"
+ en "extension"
+ en "extensions"
+ en "green"
+ en "ignore"
+ en "ok"
+ en "red"
+ en "retry"
+ en "yes"
+}
diff --git a/ext/tk/sample/msgs_rb/en_gb.msg b/ext/tk/sample/msgs_rb/en_gb.msg
new file mode 100644
index 0000000000..97c58959b1
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/en_gb.msg
@@ -0,0 +1,7 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ en_gb 'Color', 'Colour'
+}
+
+TkMsgCatalog.new('::tk') {
+ en_gb 'Color', 'Colour'
+}
diff --git a/ext/tk/sample/msgs_rb/eo.msg b/ext/tk/sample/msgs_rb/eo.msg
new file mode 100644
index 0000000000..1630df5e83
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/eo.msg
@@ -0,0 +1,87 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ eo 'Application Error', 'Aplikoerraro'
+ eo 'Blue', 'Blua'
+ eo 'Color', 'Farbo'
+ eo 'Delete', 'Forprenu'
+ eo 'Error', 'Eraro'
+ eo 'Exit', 'Eliru'
+ eo 'Green', 'Verda'
+ eo 'Red', 'Rosa'
+ eo 'blue', 'blua'
+ eo 'green', 'verda'
+ eo 'red', 'ru\u011da'
+}
+
+TkMsgCatalog.new('::tk') {
+ eo '&Abort', '&\u0108esigo'
+ eo '&About...', 'Pri...'
+ eo 'All Files', '\u0108ioj dosieroj'
+ eo 'Application Error', 'Aplikoerraro'
+ eo '&Blue', '&Blua'
+ eo '&Cancel', '&Rezignu'
+ eo 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', 'Neeble \u0109angi al dosierulon "%1\$s".' "\n" 'Vi ne rajtas tion.'
+ eo 'Choose Directory', 'Elektu Dosierujo'
+ eo '&Clear', '&Klaru'
+ eo '&Clear Console', '&Klaru konzolon'
+ eo 'Color', 'Farbo'
+ eo 'Console', 'Konzolo'
+ eo '&Copy', '&Kopiu'
+ eo 'Cu&t', '&Enpo\u015digu'
+ eo '&Delete', '&Forprenu'
+ eo 'Details >>', 'Detaloj >>'
+ eo 'Directory "%1\$s" does not exist.', 'La dosierujo "%1\$s" ne ekzistas.'
+ eo '&Directory:', '&Dosierujo:'
+ eo '&Edit', '&Redaktu'
+ eo 'Error: %1\$s', 'Eraro: %1\$s'
+ eo 'E&xit', '&Eliru'
+ eo '&File', '&Dosiero'
+ eo 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', 'La dosiero "%1\$s" jam ekzistas.' "\n" '\u0108u vi volas anstata\u00fbigi la dosieron?'
+ eo 'File "%1\$s" already exists.' "\n\n", 'La dosiero "%1\$s" jam egzistas.' "\n\n"
+ eo 'File "%1\$s" does not exist.', 'La dosierp "%1\$s" ne estas.'
+ eo 'File &name:', 'Dosiero&nomo:'
+ eo 'File &names:', 'Dosiero&nomoj:'
+ eo 'Files of &type:', 'Dosieroj de &Typo:'
+ eo 'Fi&les:', 'Do&sieroj:'
+ eo '&Filter', '&Filtrilo'
+ eo 'Fil&ter:', '&Filtrilo:'
+ eo '&Green', '&Verda'
+ eo '&Help', '&Helpu'
+ eo 'Hi', 'Saluton'
+ eo '&Hide Console', '&Ka\u015du konzolon'
+ eo '&Ignore', '&Ignoru'
+ eo 'Invalid file name "%1\$s".', 'Malvalida dosieronomo "%1\$s".'
+ eo 'Log Files', 'Protokolo'
+ eo '&No', '&Ne'
+ eo 'OK'
+ eo 'Ok'
+ eo 'Open', 'Malfermu'
+ eo '&Open', '&Malfermu'
+ eo 'Open Multiple Files', 'Melfermu multan dosierojn'
+ eo 'P&aste', '&Elpo\u015digi'
+ eo '&Quit', '&Finigu'
+ eo '&Red', '&Rosa'
+ eo 'Replace existing file?', '\u0108u anstata\u00fbu ekzistantan dosieron?'
+ eo '&Retry', '&Ripetu'
+ eo '&Save', '&Savu'
+ eo 'Save As', 'Savu kiel'
+ eo 'Save To Log', 'Savu en protokolon'
+ eo 'Select Log File', 'Elektu prokolodosieron'
+ eo 'Select a file to source', 'Elektu dosieron por interpreti'
+ eo '&Selection:', '&Elekto:'
+ eo 'Skip Messages', 'transsaltu pluajn mesa\u011dojn'
+ eo '&Source...', '&Fontoprogramo...'
+ eo 'Tcl Scripts', 'Tcl-skriptoj'
+ eo 'Tcl for Windows', 'Tcl por vindoso'
+ eo 'Text Files', 'Tekstodosierojn'
+ eo '&Yes', '&Jes'
+ eo 'abort', '\u0109esigo'
+ eo 'blue', 'blua'
+ eo 'cancel', 'rezignu'
+ eo 'extension', 'ekspansio'
+ eo 'extensions', 'ekspansioj'
+ eo 'green', 'verda'
+ eo 'ignore', 'ignorieren'
+ eo 'red', 'ru\u011da'
+ eo 'retry', 'ripetu'
+ eo 'yes', 'jes'
+}
diff --git a/ext/tk/sample/msgs_rb/es.msg b/ext/tk/sample/msgs_rb/es.msg
new file mode 100644
index 0000000000..460dbe848c
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/es.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ es "Application Error", "Error de la aplicaci\\u00f3n"
+ es "Blue", "Azul"
+ es "Color", "Color"
+ es "Delete", "Borrar"
+ es "Error", "Error"
+ es "Exit", "Salir"
+ es "Green", "Verde"
+ es "Red", "Rojo"
+ es "blue", "azul"
+ es "green", "verde"
+ es "red", "rojo"
+}
+
+TkMsgCatalog.new('::tk') {
+ es "&Abort", "&Abortar"
+ es "About...", "Acerca de ..."
+ es "All Files", "Todos los archivos"
+ es "Application Error", "Error de la aplicaci\\u00f3n"
+ es "&Blue", "&Azul"
+ es "&Cancel", "&Cancelar"
+ es "Cannot change to the directory \"%1\$s\".\nPermission denied.", "No es posible acceder al directorio \"%1\$s\".\nPermiso denegado."
+ es "Choose Directory", "Elegir directorio"
+ es "Clear", "Borrar"
+ es "Color", "Color"
+ es "Console", "Consola"
+ es "Copy", "Copiar"
+ es "Cut", "Cortar"
+ es "Delete", "Borrar"
+ es "Details >>", "Detalles >>"
+ es "Directory \"%1\$s\" does not exist.", "El directorio \"%1\$s\" no existe."
+ es "&Directory:", "&Directorio:"
+ es "Error: %1\$s", "Error: %1\$s"
+ es "Exit", "Salir"
+ es "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "El archivo \"%1\$s\" ya existe.\nDesea sobreescribirlo?"
+ es "File \"%1\$s\" already exists.\n\n", "El archivo \"%1\$s\" ya existe.\n\n"
+ es "File \"%1\$s\" does not exist.", "El archivo \"%1\$s\" no existe."
+ es "File &name:", "&Nombre de archivo:"
+ es "File &names:", "&Nombres de archivo:"
+ es "Files of &type:", "Archivos de &tipo:"
+ es "Fi&les:", "&Archivos:"
+ es "&Filter", "&Filtro"
+ es "Fil&ter:", "Fil&tro:"
+ es "&Green", "&Verde"
+ es "Hi", "Hola"
+ es "Hide Console", "Esconder la consola"
+ es "&Ignore", "&Ignorar"
+ es "Invalid file name \"%1\$s\".", "Nombre de archivo inv\\u00e1lido \"%1\$s\"."
+ es "Log Files", "Ficheros de traza"
+ es "&No", "&No"
+ es "&OK", "&OK"
+ es "Ok", "Ok"
+ es "Open", "Abrir"
+ es "&Open", "&Abrir"
+ es "Open Multiple Files", "Abrir m\\u00faltiples archivos"
+ es "Paste", "Pegar"
+ es "Quit", "Abandonar"
+ es "&Red", "&Rojo"
+ es "Replace existing file?", "Reemplazar el archivo existente?"
+ es "&Retry", "&Reintentar"
+ es "&Save", "&Salvar"
+ es "Save As", "Salvar como"
+ es "Save To Log", "Salvar al archivo de traza"
+ es "Select Log File", "Elegir un archivo de traza"
+ es "Select a file to source", "Seleccionar un archivo a evaluar"
+ es "&Selection:", "&Selecci\\u00f3n:"
+ es "Skip Messages", "Omitir los mensajes"
+ es "Source...", "Evaluar..."
+ es "Tcl Scripts", "Scripts Tcl"
+ es "Tcl for Windows", "Tcl para Windows"
+ es "Text Files", "Archivos de texto"
+ es "&Yes", "&S\\u00ed"
+ es "abort", "abortar"
+ es "blue", "azul"
+ es "cancel", "cancelar"
+ es "extension", "extensi\\u00f3n"
+ es "extensions", "extensiones"
+ es "green", "verde"
+ es "ignore", "ignorar"
+ es "ok", "ok"
+ es "red", "rojo"
+ es "retry", "reintentar"
+ es "yes", "s\\u00ed"
+}
diff --git a/ext/tk/sample/msgs_rb/fr.msg b/ext/tk/sample/msgs_rb/fr.msg
new file mode 100644
index 0000000000..ea85cf1a39
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/fr.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ fr 'Application Error', "Erreur d'application"
+ fr 'Blue', 'Bleu'
+ fr 'Color', 'Couleur'
+ fr 'Delete', 'Effacer'
+ fr 'Error', 'Erreur'
+ fr 'Exit', 'Quitter'
+ fr 'Green', 'Vert'
+ fr 'Red', 'Rouge'
+ fr 'blue', 'bleu'
+ fr 'green', 'vert'
+ fr 'red', 'rouge'
+}
+
+TkMsgCatalog.new('::tk') {
+ fr '&Abort', '&Annuler'
+ fr 'About...', '\u00c0 propos...'
+ fr 'All Files', 'Tous les fichiers'
+ fr 'Application Error', "Erreur d'application"
+ fr '&Blue', '&Bleu'
+ fr '&Cancel', '&Annuler'
+ fr 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', 'Impossible d\'acc\u00e9der au r\u00e9pertoire "%1\$s".' "\n" 'Permission refus\u00e9e.'
+ fr 'Choose Directory', 'Choisir r\u00e9pertoire'
+ fr 'Clear', 'Effacer'
+ fr 'Color', 'Couleur'
+ fr 'Console'
+ fr 'Copy', 'Copier'
+ fr 'Cut', 'Couper'
+ fr 'Delete', 'Effacer'
+ fr 'Details >>', 'D\u00e9tails >>'
+ fr 'Directory "%1\$s" does not exist.', 'Le r\u00e9pertoire "%1\$s" n\'existe pas.'
+ fr '&Directory:', '&R\u00e9pertoire:'
+ fr 'Error: %1\$s', 'Erreur: %1\$s'
+ fr 'Exit', 'Quitter'
+ fr 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', 'Le fichier "%1\$s" existe d\u00e9j\u00e0.' "\n" 'Voulez-vous l\'\u00e9craser?'
+ fr 'File "%1\$s" already exists.' "\n\n", 'Le fichier "%1\$s" existe d\u00e9j\u00e0.' "\n\n"
+ fr 'File "%1\$s" does not exist.', 'Le fichier "%1\$s" n\'existe pas.'
+ fr 'File &name:', '&Nom de fichier:'
+ fr 'File &names:', '&Noms de fichiers:'
+ fr 'Files of &type:', '&Type de fichiers:'
+ fr 'Fi&les:', 'Fich&iers:'
+ fr '&Filter', '&Filtre'
+ fr 'Fil&ter:', 'Fil&tre:'
+ fr '&Green', '&Vert'
+ fr 'Hi', 'Salut'
+ fr 'Hide Console', 'Cacher la Console'
+ fr '&Ignore', '&Ignorer'
+ fr 'Invalid file name "%1\$s".', 'Nom de fichier invalide "%1\$s".'
+ fr 'Log Files', 'Fichiers de trace'
+ fr '&No', '&Non'
+ fr '&OK'
+ fr 'Ok'
+ fr 'Open', 'Ouvrir'
+ fr '&Open', '&Ouvrir'
+ fr 'Open Multiple Files', 'Ouvrir plusieurs fichiers'
+ fr 'Paste', 'Coller'
+ fr 'Quit', 'Quitter'
+ fr '&Red', '&Rouge'
+ fr 'Replace existing file?', 'Remplacer le fichier existant?'
+ fr '&Retry', '&R\u00e9-essayer'
+ fr '&Save', '&Sauvegarder'
+ fr 'Save As', 'Sauvegarder sous'
+ fr 'Save To Log', 'Sauvegarde au fichier de trace'
+ fr 'Select Log File', 'Choisir un fichier de trace'
+ fr 'Select a file to source', 'Choisir un fichier \u00e0 \u00e9valuer'
+ fr '&Selection:', '&S\u00e9lection:'
+ fr 'Skip Messages', 'Omettre les messages'
+ fr 'Source...', '\u00c9valuer...'
+ fr 'Tcl Scripts', 'Scripts Tcl'
+ fr 'Tcl for Windows', 'Tcl pour Windows'
+ fr 'Text Files', 'Fichiers texte'
+ fr '&Yes', '&Oui'
+ fr 'abort', 'abandonner'
+ fr 'blue', 'bleu'
+ fr 'cancel', 'annuler'
+ fr 'extension'
+ fr 'extensions'
+ fr 'green', 'vert'
+ fr 'ignore', 'ignorer'
+ fr 'ok'
+ fr 'red', 'rouge'
+ fr 'retry', 'r\u00e9essayer'
+ fr 'yes', 'oui'
+}
diff --git a/ext/tk/sample/msgs_rb/it.msg b/ext/tk/sample/msgs_rb/it.msg
new file mode 100644
index 0000000000..a180bdbd99
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/it.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ it "Application Error", "Errore dell' applicazione"
+ it "Blue", "Blu"
+ it "Color", "Colore"
+ it "Delete", "Incolla"
+ it "Error", "Errore"
+ it "Exit", "Esci"
+ it "Green", "Verde"
+ it "Red", "Rosso"
+ it "blue", "blu"
+ it "green", "verde"
+ it "red", "rosso"
+}
+
+TkMsgCatalog.new('::tk') {
+ it "&Abort", "&Interrompi"
+ it "About...", "Informazioni ..."
+ it "All Files", "Tutti i file"
+ it "Application Error", "Errore dell' applicazione"
+ it "&Blue", "&Blu"
+ it "&Cancel", "&Annulla"
+ it "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Impossibile accedere alla directory \"%1\$s\".\nPermesso negato."
+ it "Choose Directory", "Scegli directory"
+ it "Clear", "Azzera"
+ it "Color", "Colore"
+ it "Console"
+ it "Copy", "Copia"
+ it "Cut", "Taglia"
+ it "Delete", "Incolla"
+ it "Details >>", "Dettagli >>"
+ it "Directory \"%1\$s\" does not exist.", "La directory \"%1\$s\" non esiste."
+ it "&Directory:"
+ it "Error: %1\$s", "Errore: %1\$s"
+ it "Exit", "Esci"
+ it "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Il file \"%1\$s\" esiste gi\\u00e0.\nVuoi sovrascriverlo?"
+ it "File \"%1\$s\" already exists.\n\n", "Il file \"%1\$s\" esiste gi\\u00e0.\n\n"
+ it "File \"%1\$s\" does not exist.", "Il file \"%1\$s\" non esiste."
+ it "File &name:", "&Nome del file:"
+ it "File &names:", "&Nomi dei file:"
+ it "Files of &type:", "File di &tipo:"
+ it "Fi&les:", "Fi&le:"
+ it "&Filter", "&Filtro"
+ it "Fil&ter:", "Fil&tro:"
+ it "&Green", "&Verde"
+ it "Hi", "Salve"
+ it "Hide Console", "Nascondi la console"
+ it "&Ignore", "&Ignora"
+ it "Invalid file name \"%1\$s\".", "Nome di file non valido \"%1\$s\"."
+ it "Log Files", "File di log"
+ it "&No"
+ it "&OK"
+ it "Ok"
+ it "&Open", "A&pri"
+ it "Open", "Apri"
+ it "Open Multiple Files", "Apri file multipli"
+ it "Paste", "Incolla"
+ it "Quit", "Esci"
+ it "&Red", "&Rosso"
+ it "Replace existing file?", "Sostituisci il file esistente?"
+ it "&Retry", "&Riprova"
+ it "&Save", "&Salva"
+ it "Save As", "Salva come"
+ it "Save To Log", "Salva il log"
+ it "Select Log File", "Scegli un file di log"
+ it "Select a file to source", "Scegli un file da eseguire"
+ it "&Selection:", "&Selezione:"
+ it "Skip Messages", "Salta i messaggi"
+ it "Source...", "Esegui..."
+ it "Tcl Scripts", "Scripts Tcl"
+ it "Tcl for Windows", "Tcl per Windows"
+ it "Text Files", "File di testo"
+ it "&Yes", "&Si"
+ it "abort", "interrompi"
+ it "blue", "blu"
+ it "cancel", "annulla"
+ it "extension", "estensione"
+ it "extensions", "estensioni"
+ it "green", "verde"
+ it "ignore", "ignora"
+ it "ok"
+ it "red", "rosso"
+ it "retry", "riprova"
+ it "yes", "si"
+}
diff --git a/ext/tk/sample/msgs_rb/ja.msg b/ext/tk/sample/msgs_rb/ja.msg
new file mode 100644
index 0000000000..40587c1f1d
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/ja.msg
@@ -0,0 +1,13 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ ja 'Application Error', '\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30A8\u30E9\u30FC'
+ ja 'Blue', '\u9752'
+ ja 'Color', '\u80CC\u666F\u8272'
+ ja 'Delete', '\u6D88\u53BB'
+ ja 'Error', '\u30A8\u30E9\u30FC'
+ ja 'Exit', '\u7D42\u4E86'
+ ja 'Green', '\u7DD1'
+ ja 'Red', '\u8D64'
+ ja 'blue', '\u9752'
+ ja 'green', '\u7DD1'
+ ja 'red', '\u8D64'
+}
diff --git a/ext/tk/sample/msgs_rb/nl.msg b/ext/tk/sample/msgs_rb/nl.msg
new file mode 100644
index 0000000000..24e41dae86
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/nl.msg
@@ -0,0 +1,123 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ nl "Application Error", "Toepassingsfout"
+ nl "Blue", "Blauw"
+ nl "Color", "Kleur"
+ nl "Delete", "Wissen"
+ nl "Error", "Fout"
+ nl "Exit", "Be\\u00ebindigen"
+ nl "Green", "Groen"
+ nl "Red", "Rood"
+ nl "blue", "blauw"
+ nl "green", "groen"
+ nl "red", "rood"
+}
+
+TkMsgCatalog.new('::tk') {
+ nl "\"%1\$s\" must be an absolute pathname", "\"%1\$s\" moet een absolute pad-naam zijn"
+ nl "%1\$s is not a toplevel window", "%1\$s is geen toplevel window"
+ nl ", or", ", of"
+ nl "-default, -icon, -message, -parent, -title, or -type", "-default, -icon, -message, -parent, -title, of -type"
+ nl "-initialdir, -mustexist, -parent, or -title", "-initialdir, -mustexist, -parent, of -title"
+ nl "&Abort", "&Afbreken"
+ nl "About...", "Over..."
+ nl "All Files", "Alle Bestanden"
+ nl "Application Error", "Toepassingsfout"
+ nl "&Blue", "&Blauw"
+ nl "&Cancel", "&Annuleren"
+ nl "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Kan niet naar map \"%1\$s\" gaan.\nU heeft hiervoor geen toestemming."
+ nl "Choose Directory", "Kies map"
+ nl "Clear", "Wissen"
+ nl "Clear entry, Press OK; Enter %1\$s, press OK", "Wis veld, Druk op OK; typ %1\$s in, druk op OK"
+ nl "&Clear Console", "&Wis Console"
+ nl "Color", "Kleur"
+ nl "Console"
+ nl "Copy", "Kopi\\u00ebren"
+ nl "Cut", "Knippen"
+ nl "Delete", "Wissen"
+ nl "Details"
+ nl "Details >>"
+ nl "Directory \"%1\$s\" does not exist.", "Map \"%1\$s\" bestaat niet."
+ nl "&Directory:", "&Map:"
+ nl "Edit", "Bewerken"
+ nl "Enter \"%1\$s\", press OK", "Typ \"%1\$s\", druk op OK"
+ nl "Enter \"%1\$s\", press OK, enter \"%2\$s\", press OK", "Typ \"%1\$s\", druk op OK, typ \"%2\$s\", druk op OK"
+ nl "Error: %1\$s", "Fout: %1\$s"
+ nl "Exit", "Be\\u00ebindigen"
+ nl "File", "Bestand"
+ nl "File \"%1\$s\" already exists.\n\n", "Bestand \"%1\$s\" bestaat al.\n\n"
+ nl "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Bestand \"%1\$s\" bestaat al.\nWilt u het overschrijven?"
+ nl "File \"%1\$s\" does not exist.", "Bestand \"%1\$s\" bestaat niet."
+ nl "File &name:", "Bestands&naam:"
+ nl "File &names:", "Bestands&namen:"
+ nl "Files of &type:", "Bestanden van het &type:"
+ nl "Fi&les:", "&Bestanden:"
+ nl "&Filter"
+ nl "Fil&ter:"
+ nl "&Green", "&Groen"
+ nl "Hi", "H\\u00e9"
+ nl "Hide Console", "Verberg Console"
+ nl "&Ignore", "&Negeren"
+ nl "Invalid file name \"%1\$s\".", "Ongeldige bestandsnaam \"%1\$s\"."
+ nl "Log Files", "Log Bestanden"
+ nl "&No", "&Nee"
+ nl "&OK"
+ nl "Ok"
+ nl "&Open", "&Openen"
+ nl "Open", "Openen"
+ nl "Open Multiple Files", "Open meerdere bestanden"
+ nl "Paste", "Plakken"
+ nl "Please press %1\$s", "Druk op %1\$s, A.U.B."
+ nl "Please press ok", "Druk op ok, A.U.B."
+ nl "Press Cancel", "Druk op Annuleren"
+ nl "Press Ok", "Druk op Ok"
+ nl "Quit", "Stoppen"
+ nl "&Red", "&Rood"
+ nl "Replace existing file?", "Vervang bestaand bestand?"
+ nl "&Retry", "&Herhalen"
+ nl "&Save", "Op&slaan"
+ nl "Save As", "Opslaan als"
+ nl "Save To Log", "Opslaan naar Log"
+ nl "Select Log File", "Selecteer Log bestand"
+ nl "Select a file to source", "Selecteer bronbestand"
+ nl "&Selection:", "&Selectie:"
+ nl "Skip Messages", "Berichten overslaan"
+ nl "Source...", "Bron..."
+ nl "Tcl Scripts"
+ nl "Tcl for Windows", "Tcl voor Windows"
+ nl "Text Files", "Tekstbestanden"
+ nl "&Yes", "&Ja"
+ nl "abort", "afbreken"
+ nl "abort, retry, ignore, ok, cancel, no, or yes", "afbreken, opnieuw, negeren, ok, annuleren, nee, of ja"
+ nl "abortretryignore, ok, okcancel, retrycancel, yesno, or yesnocancel", "abortretryignore, ok, okcancel, retrycancel, yesno, of yesnocancel"
+ nl "bad %1\$s value \"%2\$s\": must be %3\$s", "verkeerde %1\$s waarde \"%2\$s\": moet zijn %3\$s"
+ nl "bad file type \"%1\$s\", should be", "verkeerd bestandstype \"%1\$s\", moet zijn"
+ nl "bad option \"%1\$s\": should be %2\$s", "verkeerde optie \"%1\$s\": moet zijn %2\$s"
+ nl "bad window path name \"%1\$s\"", "verkeerde window-padnaam \"%1\$s\""
+ nl "blue", "blauw"
+ nl "can't post %1\$s: it isn't a descendant of %2\$s (this is a new requirement in Tk versions 3.0 and later)", "kan %1\$s niet verzenden: het is geen afstammeling van %2\$s (dit is een nieuwe eis in Tk versies 3.0 en later)"
+ nl "cancel", "annuleren"
+ nl "default button index greater than number of buttons specified for tk_dialog", "default knop index is groter dan het aantal knoppen beschikbaar voor tk_dialog"
+ nl "display name to use (current one otherwise)", "te gebruiken schermnaam (anders huidige scherm)"
+ nl "error, info, question, or warning", "error, info, question, of warning"
+ nl "extension"
+ nl "extensions"
+ nl "focus group \"%1\$s\" doesn't exist", "focusgroep \"%1\$s\" bestaat niet"
+ nl "green", "groen"
+ nl "history event %1\$s"
+ nl "ignore", "negeren"
+ nl "invalid default button \"%1\$s\"", "ongeldige default knop \"%1\$s\""
+ nl "macType"
+ nl "macTypes"
+ nl "must specify a background color", "een achtergrondkleur is verplicht"
+ nl "name of the slave interpreter", "naam van de slaaf-interpreter"
+ nl "no winfo screen . nor env(DISPLAY)", "geen winfo scherm . noch env(DISPLAY)"
+ nl "ok"
+ nl "red", "rood"
+ nl "retry", "opnieuw"
+ nl "should contain 5 or 4 elements", "moet 4 of 5 elementen bevatten"
+ nl "spec"
+ nl "tk_chooseDirectory command", "tk_chooseDirectory opdracht"
+ nl "tk_chooseDirectory command, cancel gives null", "tk_chooseDirectory opdracht, annuleren geeft lege waarde"
+ nl "tk_chooseDirectory command, initialdir", "tk_chooseDirectory opdracht, initi\\u00eble map"
+ nl "yes", "ja"
+}
diff --git a/ext/tk/sample/msgs_rb/pl.msg b/ext/tk/sample/msgs_rb/pl.msg
new file mode 100644
index 0000000000..0b3b4445c2
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/pl.msg
@@ -0,0 +1,87 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ pl 'Application Error', 'Bl\u0105d w Programie'
+ pl 'Blue', 'Niebieski'
+ pl 'Color', 'Kolor'
+ pl 'Delete', 'Usu\u0144'
+ pl 'Error', 'B\u0142\u0105d'
+ pl 'Exit', 'Zako\u0144cz'
+ pl 'Green', 'Zielony'
+ pl 'Red', 'Czerwonz'
+ pl 'blue', 'niebieski'
+ pl 'green', 'zielony'
+ pl 'red', 'czerwony'
+}
+
+TkMsgCatalog.new('::tk') {
+ pl '&Abort', '&Anuluj'
+ pl '&About...', 'O Programie...'
+ pl 'All Files', 'Wszystkie pliki'
+ pl 'Application Error', 'Bl\u0105d w Programie'
+ pl '&Blue', '&Niebieski'
+ pl '&Cancel', '&Anuluj'
+ pl 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', 'Katalog "%1\$s" nie mo\u017ce zosta\u0107 odczytany lub nie istnieje.'
+ pl 'Choose Directory', 'Wybierz katalog'
+ pl '&Clear', '&Wyczy\u015b\u0107'
+ pl '&Clear Console', '&Wyczy\u015b\u0107 konsol\u0119'
+ pl 'Color', 'Kolor'
+ pl 'Console', 'Konsola'
+ pl '&Copy', '&Kopiuj'
+ pl 'Cu&t', '&Wytnij'
+ pl '&Delete', '&Usu\u0144'
+ pl 'Details >>', 'Detale >>'
+ pl 'Directory "%1\$s" does not exist.', 'Katalog "%1\$s" nie istniej.'
+ pl '&Directory:', '&Katalog:'
+ pl '&Edit', '&Edytuj'
+ pl 'Error: %1\$s', 'B\u0142\u0105d: %1\$s'
+ pl 'E&xit', '&Zako\u0144cz'
+ pl '&File', '&Plik'
+ pl 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', 'Plik "%1\$s" ju\u017c istnieje.' "\n" 'Czy chcesz go zast\u0105pi\u0107?'
+ pl 'File "%1\$s" already exists.' "\n\n", 'Plik "%1\$s" ju\u017c istnieje. ' "\n\n"
+ pl 'File "%1\$s" does not exist.', 'Plik "%1\$s" nie istnieje.'
+ pl 'File &name:', 'Nazwa &pliku:'
+ pl 'File &names:', 'Nazwy &plik\u00f3w:'
+ pl 'Files of &type:', 'Pliki &typu:'
+ pl 'Fi&les:', 'Pli&ki:'
+ pl '&Filter', '&Filter'
+ pl 'Fil&ter:', '&Filter:'
+ pl '&Green', '&Zielony'
+ pl '&Help', '&Pomoc'
+ pl 'Hi', 'Witaj'
+ pl '&Hide Console', '&Schowaj konsol\u0119'
+ pl '&Ignore', '&Ignoruj'
+ pl 'Invalid file name "%1\$s".', 'Niew\u0142a\u015bciwa nazwa pliku "%1\$s".'
+ pl 'Log Files', 'Protoko\u0142uj'
+ pl '&No', '&Nie'
+ pl 'OK'
+ pl 'Ok'
+ pl 'Open', 'Wczytaj'
+ pl '&Open', '&Wczytaj'
+ pl 'Open Multiple Files', 'Wczytuj wiele plik\u00f3w'
+ pl 'P&aste', '&Wklej'
+ pl '&Quit', '&Zako\u0144cz'
+ pl '&Red', '&Czerwonz'
+ pl 'Replace existing file?', 'Czy zost\u0105pi\u0107 instniej\u0105cy plik?'
+ pl '&Retry', '&Powt\u00f3rz'
+ pl '&Save', '&Zapisz'
+ pl 'Save As', 'Zapisz jako'
+ pl 'Save To Log', 'Wpisz do protoko\u0142u'
+ pl 'Select Log File', 'Wybierz plik proko\u0142u'
+ pl 'Select a file to source', 'Wybierz plik do wykonania'
+ pl '&Selection:', '&Wyb\u00f3r:'
+ pl 'Skip Messages', 'Omi\u0144 pozosta\u0142e komunikaty'
+ pl '&Source...', '&Kod \u017ar\u00f3d\u0142owy...'
+ pl 'Tcl Scripts', 'Tcl-skrypty'
+ pl 'Tcl for Windows', 'Tcl dla Okienek (Windows)'
+ pl 'Text Files', 'Pliki Tekstowe'
+ pl '&Yes', '&Tak'
+ pl 'abort', 'zako\u0144cz'
+ pl 'blue', 'niebieski'
+ pl 'cancel', 'anuluj'
+ pl 'extension', 'rozszerzenie'
+ pl 'extensions', 'rozszerzenia'
+ pl 'green', 'zielony'
+ pl 'ignore', 'ignoruj'
+ pl 'red', 'czerwony'
+ pl 'retry', 'potw\u00f3rz'
+ pl 'yes', 'tak'
+}
diff --git a/ext/tk/sample/msgs_rb/ru.msg b/ext/tk/sample/msgs_rb/ru.msg
new file mode 100644
index 0000000000..f389dff0b6
--- /dev/null
+++ b/ext/tk/sample/msgs_rb/ru.msg
@@ -0,0 +1,87 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ ru 'Application Error', '\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435'
+ ru 'Blue', ' \u0413\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru 'Color', '\u0426\u0432\u0435\u0442'
+ ru 'Delete', '\u0423\u0434\u0430\u043b\u0438\u0442\u044c'
+ ru 'Error', '\u041e\u0448\u0438\u0431\u043a\u0430'
+ ru 'Exit', '\u0412\u044b\u0445\u043e\u0434'
+ ru 'Green', '\u0417\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'Red', '\u041a\u0440\u0430\u0441\u043d\u044b\u0439'
+ ru 'blue', ' \u0433\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru 'green', ' \u0437\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'red', ' \u043a\u0440\u0430\u0441\u043d\u044b\u0439'
+}
+
+TkMsgCatalog.new('::tk') {
+ ru '&Abort', '&\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c'
+ ru 'About...', '\u041f\u0440\u043e...'
+ ru 'All Files', '\u0412\u0441\u0435 \u0444\u0430\u0439\u043b\u044b'
+ ru 'Application Error', '\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435'
+ ru '&Blue', ' &\u0413\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru '&Cancel', '\u041e\u0442&\u043c\u0435\u043d\u0430'
+ ru 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.' \
+ '\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 "%1\$s".' "\n" '\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430'
+ ru 'Choose Directory', '\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433'
+ ru 'Clear', '\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c'
+ ru 'Color', '\u0426\u0432\u0435\u0442'
+ ru 'Console', '\u041a\u043e\u043d\u0441\u043e\u043b\u044c'
+ ru 'Copy', '\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c'
+ ru 'Cut', '\u0412\u044b\u0440\u0435\u0437\u0430\u0442\u044c'
+ ru 'Delete', '\u0423\u0434\u0430\u043b\u0438\u0442\u044c'
+ ru 'Details >>', '\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 >>'
+ ru 'Directory "%1\$s" does not exist.', '\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 "%1\$s" \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.'
+ ru '&Directory:', '&\u041a\u0430\u0442\u0430\u043b\u043e\u0433:'
+ ru 'Error: %1\$s', '\u041e\u0448\u0438\u0431\u043a\u0430: %1\$s'
+ ru 'Exit', '\u0412\u044b\u0445\u043e\u0434'
+ ru 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?' \
+ '\u0424\u0430\u0439\u043b "%1\$s" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.' "\n" '\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e?'
+ ru 'File "%1\$s" already exists.' "\n\n", '\u0424\u0430\u0439\u043b "%1\$s" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.' "\n\n"
+ ru 'File "%1\$s" does not exist.', '\u0424\u0430\u0439\u043b "%1\$s" \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'
+ ru 'File &name:', '&\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430:'
+ ru 'File &names:', '&\u0418\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432:'
+ ru 'Files of &type:', '&\u0422\u0438\u043f \u0444\u0430\u0439\u043b\u043e\u0432:'
+ ru 'Fi&les:', '\u0424\u0430\u0439&\u043b\u044b:'
+ ru '&Filter', '&\u0424\u0438\u043b\u044c\u0442\u0440'
+ ru 'Fil&ter:', '\u0424\u0438\u043b\u044c&\u0442\u0440:'
+ ru '&Green', ' &\u0417\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'Hi', '\u041f\u0440\u0438\u0432\u0435\u0442'
+ ru 'Hide Console', '\u0421\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c'
+ ru '&Ignore', '&\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c'
+ ru 'Invalid file name "%1\$s".', '\u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 "%1\$s".'
+ ru 'Log Files', '\u0424\u0430\u0439\u043b\u044b \u0436\u0443\u0440\u043d\u0430\u043b\u0430'
+ ru '&No', '&\u041d\u0435\u0442'
+ ru '&OK', '&\u041e\u041a'
+ ru 'Ok', '\u0414\u0430'
+ ru 'Open', '\u041e\u0442\u043a\u0440\u044b\u0442\u044c'
+ ru '&Open', '&\u041e\u0442\u043a\u0440\u044b\u0442\u044c'
+ ru 'Open Multiple Files', '\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432'
+ ru 'Paste', '\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c'
+ ru 'Quit', '\u0412\u044b\u0445\u043e\u0434'
+ ru '&Red', ' &\u041a\u0440\u0430\u0441\u043d\u044b\u0439'
+ ru 'Replace existing file?', '\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b?'
+ ru '&Retry', '&\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c'
+ ru '&Save', '&\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c'
+ ru 'Save As', '\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a'
+ ru 'Save To Log', '\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0436\u0443\u0440\u043d\u0430\u043b'
+ ru 'Select Log File', '\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b'
+ ru 'Select a file to source', '\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438'
+ ru '&Selection:', '&Selection:'
+ ru 'Skip Messages', '\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f'
+ ru 'Source...', '\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b...'
+ ru 'Tcl Scripts', '\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 TCL'
+ ru 'Tcl for Windows', 'TCL \u0434\u043b\u044f Windows'
+ ru 'Text Files', '\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b'
+ ru '&Yes', '&\u0414\u0430'
+ ru 'abort', '\u043e\u0442\u043c\u0435\u043d\u0430'
+ ru 'blue', ' \u0433\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru 'cancel', '\u043e\u0442\u043c\u0435\u043d\u0430'
+ ru 'extension', '\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435'
+ ru 'extensions', '\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f'
+ ru 'green', ' \u0437\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'ignore', '\u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c'
+ ru 'ok', '\u043e\u043a'
+ ru 'red', ' \u043a\u0440\u0430\u0441\u043d\u044b\u0439'
+ ru 'retry', '\u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c'
+ ru 'yes', '\u0434\u0430'
+}
+
diff --git a/ext/tk/sample/msgs_rb2/README b/ext/tk/sample/msgs_rb2/README
new file mode 100644
index 0000000000..b8aa114e1b
--- /dev/null
+++ b/ext/tk/sample/msgs_rb2/README
@@ -0,0 +1,5 @@
+Message catalogs in this directory are written in encodings except
+UTF-8. As if you have a trouble to edit UTF-8 text, you can write
+message catalogs in your familier encoding.
+
+Please see '../msgs_rb/README' too.
diff --git a/ext/tk/sample/msgs_rb2/de.msg b/ext/tk/sample/msgs_rb2/de.msg
new file mode 100644
index 0000000000..0d6c82d9e5
--- /dev/null
+++ b/ext/tk/sample/msgs_rb2/de.msg
@@ -0,0 +1,88 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ de 'Application Error', 'Applikationsfehler'
+ de 'Blue', 'Blau'
+ de 'Color', 'Farbe'
+ de 'Delete', 'Löschen', 'iso8859-1'
+ de 'Error', 'Fehler'
+ de 'Exit', 'Ende'
+ de 'Green', 'Grün', 'iso8859-1'
+ de 'Red', 'Rot'
+ de 'blue', 'blau'
+ de 'green', 'grün', 'iso8859-1'
+ de 'red', 'rot'
+}
+
+TkMsgCatalog.new('::tk') {
+ de "&Abort", "&Abbruch"
+ de "&About...", "&Über...", 'iso8859-1'
+ de "All Files", "Alle Dateien"
+ de "Application Error", "Applikationsfehler"
+ de "&Blue", "&Blau"
+ de "&Cancel", "&Abbruch"
+ de "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Kann nicht in das Verzeichnis \"%1\$s\" wechseln.\nKeine Rechte vorhanden."
+ de "Choose Directory", "Wähle Verzeichnis", 'iso8859-1'
+ de "&Clear", "&Rücksetzen", 'iso8859-1'
+ de "&Clear Console", "&Konsole löschen", 'iso8859-1'
+ de "Color", "Farbe"
+ de "Console", "Konsole"
+ de "&Copy", "&Kopieren"
+ de "Cu&t", "Aus&schneiden"
+ de '&Delete', '&Löschen', 'iso8859-1'
+ de "Details >>"
+ de "Directory \"%1\$s\" does not exist.", "Das Verzeichnis \"%1\$s\" existiert nicht."
+ de "&Directory:", "&Verzeichnis:"
+ de "&Edit", "&Bearbieten"
+ de "Error: %1\$s", "Fehler: %1\$s"
+ de "E&xit", "&Ende"
+ de "&File", "&Datei"
+ de "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Die Datei \"%1\$s\" ist bereits vorhanden.\nWollen sie diese Datei überschreiben ?", 'iso8859-1'
+ de "File \"%1\$s\" already exists.\n\n", "Die Datei \"%1\$s\" ist bereits vorhanden.\n\n"
+ de "File \"%1\$s\" does not exist.", "Die Datei \"%1\$s\" existiert nicht."
+ de "File &name:", "Datei&name:"
+ de "File &names:", "Datei&namen:"
+ de "Files of &type:", "Dateien des &Typs:"
+ de "Fi&les:", "Dat&eien:"
+ de "&Filter"
+ de "Fil&ter:"
+ de '&Green', '&Grün', 'iso8859-1'
+ de "&Help", "&Hilfe"
+ de "Hi", "Hallo"
+ de "&Hide Console", "&Konsole unsichtbar machen"
+ de "&Ignore", "&Ignorieren"
+ de "Invalid file name \"%1\$s\".", "Ungültiger Dateiname \"%1\$s\".", 'iso8859-1'
+ de "Log Files", "Protokolldatei"
+ de "&No", "&Nein"
+ de "OK"
+ de "Ok"
+ de "Open", "Öffnen", 'iso8859-1'
+ de "&Open", "Ö&ffnen", 'iso8859-1'
+ de "Open Multiple Files"
+ de "P&aste", "E&infügen", 'iso8859-1'
+ de "&Quit", "&Beenden"
+ de "&Red", "&Rot"
+ de "Replace existing file?", "Existierende Datei ersetzen?"
+ de "&Retry", "&Wiederholen"
+ de "&Save", "&Speichern"
+ de "Save As", "Speichern unter"
+ de "Save To Log", "In Protokoll speichern"
+ de "Select Log File", "Protokolldatei auswählen", 'iso8859-1'
+ de "Select a file to source", "Auszuführende Datei auswählen", 'iso8859-1'
+ de "&Selection:", "Auswah&l:"
+ de "Skip Messages", "Weitere Nachrichten überspringen", 'iso8859-1'
+ de "&Source...", "&Ausführen...", 'iso8859-1'
+ de "Tcl Scripts", "Tcl-Skripte"
+ de "Tcl for Windows", "Tcl für Windows", 'iso8859-1'
+ de "Text Files", "Textdateien"
+ de "&Yes", "&Ja"
+ de "abort", "abbrechen"
+ de "blue", "blau"
+ de "cancel", "abbrechen"
+ de "extension", "Erweiterung"
+ de "extensions", "Erweiterungen"
+ de 'green', 'grün', 'iso8859-1'
+ de "ignore", "ignorieren"
+ de "ok"
+ de "red", "rot"
+ de "retry", "wiederholen"
+ de "yes", "ja"
+}
diff --git a/ext/tk/sample/msgs_rb2/ja.msg b/ext/tk/sample/msgs_rb2/ja.msg
new file mode 100644
index 0000000000..84e89aa6ef
--- /dev/null
+++ b/ext/tk/sample/msgs_rb2/ja.msg
@@ -0,0 +1,85 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ ja 'Application Error', '¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¨¥é¡¼', 'euc-jp'
+ ja 'Blue', 'ÀÄ', 'euc-jp'
+ ja 'Color', '¿§ÁªÂò', 'euc-jp'
+ ja 'Delete', '¾Ãµî', 'euc-jp'
+ ja 'Error', '¥¨¥é¡¼', 'euc-jp'
+ ja 'Exit', '½ªÎ»', 'euc-jp'
+ ja 'Green', 'ÎÐ', 'euc-jp'
+ ja 'Red', 'ÀÖ', 'euc-jp'
+ ja 'blue', 'ÀÄ', 'euc-jp'
+ ja 'green', 'ÎÐ', 'euc-jp'
+ ja 'red', 'ÀÖ', 'euc-jp'
+}
+
+TkMsgCatalog.new('::tk') {
+ ja "&Abort", '̾ȧ', 'euc-jp'
+ ja "About..."
+ ja "All Files", '¤¹¤Ù¤Æ¤Î¥Õ¥¡¥¤¥ë', 'euc-jp'
+ ja "Application Error", '¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¨¥é¡¼', 'euc-jp'
+ ja "&Blue", 'ÀÄ', 'euc-jp'
+ ja "&Cancel", '¼è¤ê¾Ã¤·', 'euc-jp'
+ ja "Cannot change to the directory \"%1\$s\".\nPermission denied.", "¥Ç¥£¥ì¥¯¥È¥ê \"%1\$s\" ¤ËÊѹ¹¤Ç¤­¤Þ¤»¤ó¡¥\nµö²Ä¤¬¤¢¤ê¤Þ¤»¤ó¡¥", 'euc-jp'
+ ja "Choose Directory", '¥Ç¥£¥ì¥¯¥È¥ê¤òÁªÂò', 'euc-jp'
+ ja "Clear", '¾Ãµî', 'euc-jp'
+ ja "Color", '¿§', 'euc-jp'
+ ja "Console", '¥³¥ó¥½¡¼¥ë', 'euc-jp'
+ ja "Copy", '¥³¥Ô¡¼', 'euc-jp'
+ ja "Cut", 'ÀÚ¤ê¼è¤ê', 'euc-jp'
+ ja "Delete", '¾Ãµî', 'euc-jp'
+ ja "Details >>", '¾ÜºÙ >>', 'euc-jp'
+ ja "Directory \"%1\$s\" does not exist.", '"%1$s" ¤È¤¤¤¦¥Ç¥£¥ì¥¯¥È¥ê¤Ï¸ºß¤·¤Þ¤»¤ó¡¥', 'euc-jp'
+ ja "&Directory:", '¥Ç¥£¥ì¥¯¥È¥ê', 'euc-jp'
+ ja "Error: %1\$s"
+ ja "Exit", '½ªÎ»', 'euc-jp'
+ ja "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "\"%1\$s\" ¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤Ï´û¤Ë¸ºß¤·¤Æ¤¤¤Þ¤¹¡¥\n½ñ¤­´¹¤¨¤Þ¤¹¤«¡©", 'euc-jp'
+ ja "File \"%1\$s\" already exists.\n\n", "\"%1\$s\" ¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤Ï´û¤Ë¸ºß¤·¤Æ¤¤¤Þ¤¹¡¥\n\n", 'euc-jp'
+ ja "File \"%1\$s\" does not exist.", '"%1$s" ¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤Ï¸ºß¤·¤Þ¤»¤ó¡¥', 'euc-jp'
+ ja "File &name:", '¥Õ¥¡¥¤¥ë̾', 'euc-jp'
+ ja "File &names:", '¥Õ¥¡¥¤¥ë̾', 'euc-jp'
+ ja "Files of &type:", '¥Õ¥¡¥¤¥ë·Á¼°', 'euc-jp'
+ ja "Fi&les:", '¥Õ¥¡¥¤¥ë', 'euc-jp'
+ ja "&Filter", '¥Õ¥£¥ë¥¿¡¼', 'euc-jp'
+ ja "Fil&ter:", '¥Õ¥£¥ë¥¿¡¼', 'euc-jp'
+ ja "&Green", 'ÎÐ', 'euc-jp'
+ ja "Hi", '¤³¤ó¤Ë¤Á¤Ï', 'euc-jp'
+ ja "Hide Console", '¥³¥ó¥½¡¼¥ë¤ò±£¤¹', 'euc-jp'
+ ja "&Ignore", '̵»ë', 'euc-jp'
+ ja "Invalid file name \"%1\$s\".", '"%1$s" ¤ÏÉÔÀµ¤Ê¥Õ¥¡¥¤¥ë̾¤Ç¤¹¡¥', 'euc-jp'
+ ja "Log Files", '¥í¥°¥Õ¥¡¥¤¥ë', 'euc-jp'
+ ja "&No", '¤¤¤¤¤¨', 'euc-jp'
+ ja "&OK", 'λ²ò', 'euc-jp'
+ ja "OK", 'λ²ò', 'euc-jp'
+ ja "Ok", 'λ²ò', 'euc-jp'
+ ja "Open", '³«¤¯', 'euc-jp'
+ ja "&Open", '³«¤¯', 'euc-jp'
+ ja "Open Multiple Files", 'Ê£¿ô¤Î¥Õ¥¡¥¤¥ë¤ò³«¤¯', 'euc-jp'
+ ja "Paste", 'ޤêÉÕ¤±', 'euc-jp'
+ ja "Quit", '½ªÎ»', 'euc-jp'
+ ja "&Red", 'ÀÖ', 'euc-jp'
+ ja "Replace existing file?", '´û¸¤Î¥Õ¥¡¥¤¥ë¤òÃÖ¤­´¹¤¨¤Þ¤¹¤«¡©', 'euc-jp'
+ ja "&Retry", 'ºÆ¼Â¹Ô', 'euc-jp'
+ ja "&Save", 'Êݸ', 'euc-jp'
+ ja "Save As", '̾Á°¤òÉÕ¤±¤ÆÊݸ', 'euc-jp'
+ ja "Save To Log", '¥í¥°¤òÊݸ', 'euc-jp'
+ ja "Select Log File", '¥í¥°¥Õ¥¡¥¤¥ë¤òÁªÂò', 'euc-jp'
+ ja "Select a file to source", '¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤òÁªÂò', 'euc-jp'
+ ja "&Selection:", 'ÁªÂò', 'euc-jp'
+ ja "Skip Messages", '¥á¥Ã¥»¡¼¥¸¤ò¤È¤Ð¤¹', 'euc-jp'
+ ja "Source...", '¥½¡¼¥¹...', 'euc-jp'
+ ja "Tcl Scripts", 'Tcl ¥¹¥¯¥ê¥×¥È', 'euc-jp'
+ ja "Tcl for Windows"
+ ja "Text Files", '¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë', 'euc-jp'
+ ja "&Yes", '¤Ï¤¤', 'euc-jp'
+ ja "abort", '̾ȧ', 'euc-jp'
+ ja "blue", 'ÀÄ', 'euc-jp'
+ ja "cancel", '¼è¤ê¾Ã¤·', 'euc-jp'
+ ja "extension", '³ÈÄ¥»Ò', 'euc-jp'
+ ja "extensions", '³ÈÄ¥»Ò', 'euc-jp'
+ ja "green", 'ÎÐ', 'euc-jp'
+ ja "ignore", '̵»ë', 'euc-jp'
+ ja "ok", 'λ²ò', 'euc-jp'
+ ja "red", 'ÀÖ', 'euc-jp'
+ ja "retry", 'ºÆ¼Â¹Ô', 'euc-jp'
+ ja "yes", '¤Ï¤¤', 'euc-jp'
+}
diff --git a/ext/tk/sample/msgs_tk/README b/ext/tk/sample/msgs_tk/README
new file mode 100644
index 0000000000..c7422e3a9b
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/README
@@ -0,0 +1,4 @@
+Almost all of Message-Catalog files in this directory are quoted
+from Tcl/Tk8.5a1 source archive (only a little are modified for
+'tkmsgcat-load_tk.rb'). Please read the file 'license.terms' in
+this directry (That was included in demo directory of Tcl/Tk8.5a1).
diff --git a/ext/tk/sample/msgs_tk/cs.msg b/ext/tk/sample/msgs_tk/cs.msg
new file mode 100644
index 0000000000..697070985e
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/cs.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset cs "Application Error" "Chyba programu"
+ ::msgcat::mcset cs "Blue" "Modr\341"
+ ::msgcat::mcset cs "Color" "Barva"
+ ::msgcat::mcset cs "Delete" "Smazat"
+ ::msgcat::mcset cs "Error" "Chyba"
+ ::msgcat::mcset cs "Exit" "Konec"
+ ::msgcat::mcset cs "Green" "Zelen\341"
+ ::msgcat::mcset cs "Red" "\u010cerven\341"
+ ::msgcat::mcset cs "blue" "modr\341"
+ ::msgcat::mcset cs "green" "zelen\341"
+ ::msgcat::mcset cs "red" "\u010derven\341"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset cs "&Abort" "&P\u0159eru\u0161it"
+ ::msgcat::mcset cs "About..." "O programu..."
+ ::msgcat::mcset cs "All Files" "V\u0161echny soubory"
+ ::msgcat::mcset cs "Application Error" "Chyba programu"
+ ::msgcat::mcset cs "&Blue" "&Modr\341"
+ ::msgcat::mcset cs "&Cancel" "&Zru\u0161it"
+ ::msgcat::mcset cs "Cannot change to the directory \"%1\$s\".\nPermission denied." "Nemohu zm\u011bnit atku\341ln\355 adres\341\u0159 na \"%1\$s\".\nP\u0159\355stup odm\355tnut."
+ ::msgcat::mcset cs "Choose Directory" "V\375b\u011br adres\341\u0159e"
+ ::msgcat::mcset cs "Clear" "Smazat"
+ ::msgcat::mcset cs "Color" "Barva"
+ ::msgcat::mcset cs "Console" "Konzole"
+ ::msgcat::mcset cs "Copy" "Kop\355rovat"
+ ::msgcat::mcset cs "Cut" "Vy\u0159\355znout"
+ ::msgcat::mcset cs "Delete" "Smazat"
+ ::msgcat::mcset cs "Details >>" "Detaily >>"
+ ::msgcat::mcset cs "Directory \"%1\$s\" does not exist." "Adres\341\u0159 \"%1\$s\" neexistuje."
+ ::msgcat::mcset cs "&Directory:" "&Adres\341\u0159:"
+ ::msgcat::mcset cs "Error: %1\$s" "Chyba: %1\$s"
+ ::msgcat::mcset cs "Exit" "Konec"
+ ::msgcat::mcset cs "File \"%1\$s\" already exists.\n\n" "Soubor \"%1\$s\" ji\u017e existuje.\n\n"
+ ::msgcat::mcset cs "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Soubor \"%1\$s\" ji\u017e existuje.\nChcete jej p\u0159epsat?"
+ ::msgcat::mcset cs "File \"%1\$s\" does not exist." "Soubor \"%1\$s\" neexistuje."
+ ::msgcat::mcset cs "File &name:" "&Jm\351no souboru:"
+ ::msgcat::mcset cs "File &names:" "&Jm\351na soubor\u016f:"
+ ::msgcat::mcset cs "Files of &type:" "&Typy soubor\u016f:"
+ ::msgcat::mcset cs "Fi&les:" "Sou&bory:"
+ ::msgcat::mcset cs "&Filter" "&Filtr"
+ ::msgcat::mcset cs "Fil&ter:" "Fil&tr:"
+ ::msgcat::mcset cs "&Green" "Ze&len\341"
+ ::msgcat::mcset cs "Hi"
+ ::msgcat::mcset cs "Hide Console" "Skr\375t konsolu"
+ ::msgcat::mcset cs "&Ignore" "&Ignorovat"
+ ::msgcat::mcset cs "Invalid file name \"%1\$s\"." "\u0160patn\351 jm\351no souboru \"%1\$s\"."
+ ::msgcat::mcset cs "Log Files" "Log soubory"
+ ::msgcat::mcset cs "&No" "&Ne"
+ ::msgcat::mcset cs "&OK"
+ ::msgcat::mcset cs "Ok"
+ ::msgcat::mcset cs "Open" "Otev\u0159\355t"
+ ::msgcat::mcset cs "&Open" "&Otev\u0159\355t"
+ ::msgcat::mcset cs "Open Multiple Files" "Otev\u0159\355t v\355ce soubor\u016f"
+ ::msgcat::mcset cs "Paste" "Vlo\u017eit"
+ ::msgcat::mcset cs "Quit" "Skon\u010dit"
+ ::msgcat::mcset cs "&Red" " \u010ce&rven\341"
+ ::msgcat::mcset cs "Replace existing file?" "Nahradit st\341vaj\355c\355 soubor?"
+ ::msgcat::mcset cs "&Retry" "Z&novu"
+ ::msgcat::mcset cs "&Save" "&Ulo\u017eit"
+ ::msgcat::mcset cs "Save As" "Ulo\u017eit jako"
+ ::msgcat::mcset cs "Save To Log" "Ulo\u017eit do logu"
+ ::msgcat::mcset cs "Select Log File" "Vybrat log soubor"
+ ::msgcat::mcset cs "Select a file to source" "Vybrat soubor k nahr\341n\355"
+ ::msgcat::mcset cs "&Selection:" "&V\375b\u011br:"
+ ::msgcat::mcset cs "Skip Messages" "P\u0159esko\u010dit zpr\341vy"
+ ::msgcat::mcset cs "Source..." "Nahr\341t..."
+ ::msgcat::mcset cs "Tcl Scripts" "Tcl skripty"
+ ::msgcat::mcset cs "Tcl for Windows" "Tcl pro Windows"
+ ::msgcat::mcset cs "Text Files" "Textov\351 soubory"
+ ::msgcat::mcset cs "&Yes" "&Ano"
+ ::msgcat::mcset cs "abort" "p\u0159eru\u0161it"
+ ::msgcat::mcset cs "blue" "modr\341"
+ ::msgcat::mcset cs "cancel" "zru\u0161it"
+ ::msgcat::mcset cs "extension" "p\u0159\355pona"
+ ::msgcat::mcset cs "extensions" "p\u0159\355pony"
+ ::msgcat::mcset cs "green" "zelen\341"
+ ::msgcat::mcset cs "ignore" "ignorovat"
+ ::msgcat::mcset cs "ok"
+ ::msgcat::mcset cs "red" "\u010derven\341"
+ ::msgcat::mcset cs "retry" "znovu"
+ ::msgcat::mcset cs "yes" "ano"
+}
diff --git a/ext/tk/sample/msgs_tk/de.msg b/ext/tk/sample/msgs_tk/de.msg
new file mode 100644
index 0000000000..437f2ed9e7
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/de.msg
@@ -0,0 +1,88 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset de "Application Error" "Applikationsfehler"
+ ::msgcat::mcset de "Blue" "Blau"
+ ::msgcat::mcset de "Color" "Farbe"
+ ::msgcat::mcset de "Delete" "L\u00f6schen"
+ ::msgcat::mcset de "Error" "Fehler"
+ ::msgcat::mcset de "Exit" "Ende"
+ ::msgcat::mcset de "Green" "Gr\u00fcn"
+ ::msgcat::mcset de "Red" "Rot"
+ ::msgcat::mcset de "blue" "blau"
+ ::msgcat::mcset de "green" "gr\u00fcn"
+ ::msgcat::mcset de "red" "rot"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset de "&Abort" "&Abbruch"
+ ::msgcat::mcset de "&About..." "&\u00dcber..."
+ ::msgcat::mcset de "All Files" "Alle Dateien"
+ ::msgcat::mcset de "Application Error" "Applikationsfehler"
+ ::msgcat::mcset de "&Blue" "&Blau"
+ ::msgcat::mcset de "&Cancel" "&Abbruch"
+ ::msgcat::mcset de "Cannot change to the directory \"%1\$s\".\nPermission denied." "Kann nicht in das Verzeichnis \"%1\$s\" wechseln.\nKeine Rechte vorhanden."
+ ::msgcat::mcset de "Choose Directory" "W\u00e4hle Verzeichnis"
+ ::msgcat::mcset de "&Clear" "&R\u00fccksetzen"
+ ::msgcat::mcset de "&Clear Console" "&Konsole l\u00f6schen"
+ ::msgcat::mcset de "Color" "Farbe"
+ ::msgcat::mcset de "Console" "Konsole"
+ ::msgcat::mcset de "&Copy" "&Kopieren"
+ ::msgcat::mcset de "Cu&t" "Aus&schneiden"
+ ::msgcat::mcset de "&Delete" "&L\u00f6schen"
+ ::msgcat::mcset de "Details >>"
+ ::msgcat::mcset de "Directory \"%1\$s\" does not exist." "Das Verzeichnis \"%1\$s\" existiert nicht."
+ ::msgcat::mcset de "&Directory:" "&Verzeichnis:"
+ ::msgcat::mcset de "&Edit" "&Bearbieten"
+ ::msgcat::mcset de "Error: %1\$s" "Fehler: %1\$s"
+ ::msgcat::mcset de "E&xit" "&Ende"
+ ::msgcat::mcset de "&File" "&Datei"
+ ::msgcat::mcset de "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Die Datei \"%1\$s\" ist bereits vorhanden.\nWollen sie diese Datei \u00fcberschreiben ?"
+ ::msgcat::mcset de "File \"%1\$s\" already exists.\n\n" "Die Datei \"%1\$s\" ist bereits vorhanden.\n\n"
+ ::msgcat::mcset de "File \"%1\$s\" does not exist." "Die Datei \"%1\$s\" existiert nicht."
+ ::msgcat::mcset de "File &name:" "Datei&name:"
+ ::msgcat::mcset de "File &names:" "Datei&namen:"
+ ::msgcat::mcset de "Files of &type:" "Dateien des &Typs:"
+ ::msgcat::mcset de "Fi&les:" "Dat&eien:"
+ ::msgcat::mcset de "&Filter"
+ ::msgcat::mcset de "Fil&ter:"
+ ::msgcat::mcset de "&Green" "&Gr\u00fcn"
+ ::msgcat::mcset de "&Help" "&Hilfe"
+ ::msgcat::mcset de "Hi" "Hallo"
+ ::msgcat::mcset de "&Hide Console" "&Konsole unsichtbar machen"
+ ::msgcat::mcset de "&Ignore" "&Ignorieren"
+ ::msgcat::mcset de "Invalid file name \"%1\$s\"." "Ung\u00fcltiger Dateiname \"%1\$s\"."
+ ::msgcat::mcset de "Log Files" "Protokolldatei"
+ ::msgcat::mcset de "&No" "&Nein"
+ ::msgcat::mcset de "OK"
+ ::msgcat::mcset de "Ok"
+ ::msgcat::mcset de "Open" "\u00d6ffnen"
+ ::msgcat::mcset de "&Open" "\u00d6&ffnen"
+ ::msgcat::mcset de "Open Multiple Files"
+ ::msgcat::mcset de "P&aste" "E&inf\u00fcgen"
+ ::msgcat::mcset de "&Quit" "&Beenden"
+ ::msgcat::mcset de "&Red" "&Rot"
+ ::msgcat::mcset de "Replace existing file?" "Existierende Datei ersetzen?"
+ ::msgcat::mcset de "&Retry" "&Wiederholen"
+ ::msgcat::mcset de "&Save" "&Speichern"
+ ::msgcat::mcset de "Save As" "Speichern unter"
+ ::msgcat::mcset de "Save To Log" "In Protokoll speichern"
+ ::msgcat::mcset de "Select Log File" "Protokolldatei ausw\u00e4hlen"
+ ::msgcat::mcset de "Select a file to source" "Auszuf\u00fchrende Datei ausw\u00e4hlen"
+ ::msgcat::mcset de "&Selection:" "Auswah&l:"
+ ::msgcat::mcset de "Skip Messages" "Weitere Nachrichten \u00fcberspringen"
+ ::msgcat::mcset de "&Source..." "&Ausf\u00fchren..."
+ ::msgcat::mcset de "Tcl Scripts" "Tcl-Skripte"
+ ::msgcat::mcset de "Tcl for Windows" "Tcl f\u00fcr Windows"
+ ::msgcat::mcset de "Text Files" "Textdateien"
+ ::msgcat::mcset de "&Yes" "&Ja"
+ ::msgcat::mcset de "abort" "abbrechen"
+ ::msgcat::mcset de "blue" "blau"
+ ::msgcat::mcset de "cancel" "abbrechen"
+ ::msgcat::mcset de "extension" "Erweiterung"
+ ::msgcat::mcset de "extensions" "Erweiterungen"
+ ::msgcat::mcset de "green" "gr\u00fcn"
+ ::msgcat::mcset de "ignore" "ignorieren"
+ ::msgcat::mcset de "ok"
+ ::msgcat::mcset de "red" "rot"
+ ::msgcat::mcset de "retry" "wiederholen"
+ ::msgcat::mcset de "yes" "ja"
+}
diff --git a/ext/tk/sample/msgs_tk/el.msg b/ext/tk/sample/msgs_tk/el.msg
new file mode 100644
index 0000000000..1e3a539647
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/el.msg
@@ -0,0 +1,103 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset el "Application Error" "\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2"
+ ::msgcat::mcset el "Blue" "\u039c\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "Color" "\u03a7\u03c1\u03ce\u03bc\u03b1"
+ ::msgcat::mcset el "Delete" "\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae"
+ ::msgcat::mcset el "Error" "\u039b\u03ac\u03b8\u03bf\u03c2"
+ ::msgcat::mcset el "Exit" "\u0388\u03be\u03bf\u03b4\u03bf\u03c2"
+ ::msgcat::mcset el "Green" "\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "Red" "\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "blue" "\u03bc\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "green" "\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "red" "\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+}
+
+
+# followings are same to original file included into Tk8.5a1's widget demos.
+
+## Messages for the Greek (Hellenic - "el") language.
+## Please report any changes/suggestions to:
+## petasis@iit.demokritos.gr
+
+namespace eval ::tk {
+ ::msgcat::mcset el "&Abort" "\u03a4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2"
+ ::msgcat::mcset el "About..." "\u03a3\u03c7\u03b5\u03c4\u03b9\u03ba\u03ac..."
+ ::msgcat::mcset el "All Files" "\u038c\u03bb\u03b1 \u03c4\u03b1 \u0391\u03c1\u03c7\u03b5\u03af\u03b1"
+ ::msgcat::mcset el "Application Error" "\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2"
+ ::msgcat::mcset el "&Blue" "\u039c\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "&Cancel" "\u0391\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7"
+ ::msgcat::mcset el \
+"Cannot change to the directory \"%1\$s\".\nPermission denied." \
+"\u0394\u03b5\u03bd \u03b5\u03af\u03bd\u03b1\u03b9 \u03b4\u03c5\u03bd\u03b1\u03c4\u03ae \u03b7 \u03b1\u03bb\u03bb\u03b1\u03b3\u03ae \u03ba\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5 \u03c3\u03b5 \"%1\$s\".\n\u0397 \u03c0\u03c1\u03cc\u03c3\u03b2\u03b1\u03c3\u03b7 \u03b4\u03b5\u03bd \u03b5\u03c0\u03b9\u03c4\u03c1\u03ad\u03c0\u03b5\u03c4\u03b1\u03b9."
+ ::msgcat::mcset el "Choose Directory" "\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u039a\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5"
+ ::msgcat::mcset el "Clear" "\u039a\u03b1\u03b8\u03b1\u03c1\u03b9\u03c3\u03bc\u03cc\u03c2"
+ ::msgcat::mcset el "Color" "\u03a7\u03c1\u03ce\u03bc\u03b1"
+ ::msgcat::mcset el "Console" "\u039a\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1"
+ ::msgcat::mcset el "Copy" "\u0391\u03bd\u03c4\u03b9\u03b3\u03c1\u03b1\u03c6\u03ae"
+ ::msgcat::mcset el "Cut" "\u0391\u03c0\u03bf\u03ba\u03bf\u03c0\u03ae"
+ ::msgcat::mcset el "Delete" "\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae"
+ ::msgcat::mcset el "Details >>" "\u039b\u03b5\u03c0\u03c4\u03bf\u03bc\u03ad\u03c1\u03b5\u03b9\u03b5\u03c2 >>"
+ ::msgcat::mcset el "Directory \"%1\$s\" does not exist." \
+ "\u039f \u03ba\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2 \"%1\$s\" \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9."
+ ::msgcat::mcset el "&Directory:" "&\u039a\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2:"
+ ::msgcat::mcset el "Error: %1\$s" "\u039b\u03ac\u03b8\u03bf\u03c2: %1\$s"
+ ::msgcat::mcset el "Exit" "\u0388\u03be\u03bf\u03b4\u03bf\u03c2"
+ ::msgcat::mcset el \
+ "File \"%1\$s\" already exists.\nDo you want to overwrite it?" \
+ "\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \"%1\$s\" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.\n\u0398\u03ad\u03bb\u03b5\u03c4\u03b5 \u03bd\u03b1 \u03b5\u03c0\u03b9\u03ba\u03b1\u03bb\u03c5\u03c6\u03b8\u03b5\u03af;"
+ ::msgcat::mcset el "File \"%1\$s\" already exists.\n\n" \
+ "\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \"%1\$s\" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.\n\n"
+ ::msgcat::mcset el "File \"%1\$s\" does not exist." \
+ "\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \"%1\$s\" \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9."
+ ::msgcat::mcset el "File &name:" "\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5:"
+ ::msgcat::mcset el "File &names:" "\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd:"
+ ::msgcat::mcset el "Files of &type:" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u03c4\u03bf\u03c5 &\u03c4\u03cd\u03c0\u03bf\u03c5:"
+ ::msgcat::mcset el "Fi&les:" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1:"
+ ::msgcat::mcset el "&Filter" "\u03a6\u03af\u03bb\u03c4\u03c1\u03bf"
+ ::msgcat::mcset el "Fil&ter:" "\u03a6\u03af\u03bb\u03c4\u03c1\u03bf:"
+ ::msgcat::mcset el "&Green" "\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "Hi" "\u0393\u03b5\u03b9\u03b1"
+ ::msgcat::mcset el "Hide Console" "\u0391\u03c0\u03cc\u03ba\u03c1\u03c5\u03c8\u03b7 \u03ba\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1\u03c2"
+ ::msgcat::mcset el "&Ignore" "\u0391\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7"
+ ::msgcat::mcset el "Invalid file name \"%1\$s\"." \
+ "\u0386\u03ba\u03c5\u03c1\u03bf \u03cc\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 \"%1\$s\"."
+ ::msgcat::mcset el "Log Files" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2"
+ ::msgcat::mcset el "&No" "\u038c\u03c7\u03b9"
+ ::msgcat::mcset el "&OK" "\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9"
+ ::msgcat::mcset el "&Ok" "\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9"
+ ::msgcat::mcset el "Open" "\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1"
+ ::msgcat::mcset el "&Open" "\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1"
+ ::msgcat::mcset el "Open Multiple Files" \
+ "\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1 \u03c0\u03bf\u03bb\u03bb\u03b1\u03c0\u03bb\u03ce\u03bd \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd"
+ ::msgcat::mcset el "Paste" "\u0395\u03c0\u03b9\u03ba\u03cc\u03bb\u03bb\u03b7\u03c3\u03b7"
+ ::msgcat::mcset el "Quit" "\u0388\u03be\u03bf\u03b4\u03bf\u03c2"
+ ::msgcat::mcset el "&Red" "\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "Replace existing file?" \
+ "\u0395\u03c0\u03b9\u03ba\u03ac\u03bb\u03c5\u03c8\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03bf\u03bd\u03c4\u03bf\u03c2 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5;"
+ ::msgcat::mcset el "&Retry" "\u03a0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac"
+ ::msgcat::mcset el "&Save" "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7"
+ ::msgcat::mcset el "Save As" "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03b1\u03bd"
+ ::msgcat::mcset el "Save To Log" "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03c4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2"
+ ::msgcat::mcset el "Select Log File" "\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2"
+ ::msgcat::mcset el "Select a file to source" \
+ "\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03b3\u03b9\u03b1 \u03b5\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7"
+ ::msgcat::mcset el "&Selection:" "\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae:"
+ ::msgcat::mcset el "Skip Messages" "\u0391\u03c0\u03bf\u03c6\u03c5\u03b3\u03ae \u03bc\u03c5\u03bd\u03b7\u03bc\u03ac\u03c4\u03c9\u03bd"
+ ::msgcat::mcset el "Source..." "\u0395\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7..."
+ ::msgcat::mcset el "Tcl Scripts" "Tcl Scripts"
+ ::msgcat::mcset el "Tcl for Windows" "Tcl \u03b3\u03b9\u03b1 Windows"
+ ::msgcat::mcset el "Text Files" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b5\u03b9\u03bc\u03ad\u03bd\u03bf\u03c5"
+ ::msgcat::mcset el "&Yes" "\u039d\u03b1\u03b9"
+ ::msgcat::mcset el "abort" "\u03c4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2"
+ ::msgcat::mcset el "blue" "\u03bc\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "cancel" "\u03b1\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7"
+ ::msgcat::mcset el "extension" "\u03b5\u03c0\u03ad\u03ba\u03c4\u03b1\u03c3\u03b7"
+ ::msgcat::mcset el "extensions" "\u03b5\u03c0\u03b5\u03ba\u03c4\u03ac\u03c3\u03b5\u03b9\u03c2"
+ ::msgcat::mcset el "green" "\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "ignore" "\u03b1\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7"
+ ::msgcat::mcset el "ok" "\u03b5\u03bd\u03c4\u03ac\u03be\u03b5\u03b9"
+ ::msgcat::mcset el "red" "\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "retry" "\u03c0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac"
+ ::msgcat::mcset el "yes" "\u03bd\u03b1\u03b9"
+}
+
diff --git a/ext/tk/sample/msgs_tk/en.msg b/ext/tk/sample/msgs_tk/en.msg
new file mode 100644
index 0000000000..de586d195e
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/en.msg
@@ -0,0 +1,83 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset en "Application Error"
+ ::msgcat::mcset en "Blue"
+ ::msgcat::mcset en "Color"
+ ::msgcat::mcset en "Delete"
+ ::msgcat::mcset en "Error"
+ ::msgcat::mcset en "Green"
+ ::msgcat::mcset en "Red"
+ ::msgcat::mcset en "blue"
+ ::msgcat::mcset en "green"
+ ::msgcat::mcset en "red"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset en "&Abort"
+ ::msgcat::mcset en "About..."
+ ::msgcat::mcset en "All Files"
+ ::msgcat::mcset en "Application Error"
+ ::msgcat::mcset en "&Blue"
+ ::msgcat::mcset en "&Cancel"
+ ::msgcat::mcset en "Cannot change to the directory \"%1\$s\".\nPermission denied."
+ ::msgcat::mcset en "Choose Directory"
+ ::msgcat::mcset en "Clear"
+ ::msgcat::mcset en "Color"
+ ::msgcat::mcset en "Console"
+ ::msgcat::mcset en "Copy"
+ ::msgcat::mcset en "Cut"
+ ::msgcat::mcset en "Delete"
+ ::msgcat::mcset en "Details >>"
+ ::msgcat::mcset en "Directory \"%1\$s\" does not exist."
+ ::msgcat::mcset en "&Directory:"
+ ::msgcat::mcset en "Error: %1\$s"
+ ::msgcat::mcset en "Exit"
+ ::msgcat::mcset en "File \"%1\$s\" already exists.\nDo you want to overwrite it?"
+ ::msgcat::mcset en "File \"%1\$s\" already exists.\n\n"
+ ::msgcat::mcset en "File \"%1\$s\" does not exist."
+ ::msgcat::mcset en "File &name:"
+ ::msgcat::mcset en "File &names:"
+ ::msgcat::mcset en "Files of &type:"
+ ::msgcat::mcset en "Fi&les:"
+ ::msgcat::mcset en "&Filter"
+ ::msgcat::mcset en "Fil&ter:"
+ ::msgcat::mcset en "&Green"
+ ::msgcat::mcset en "Hi"
+ ::msgcat::mcset en "Hide Console"
+ ::msgcat::mcset en "&Ignore"
+ ::msgcat::mcset en "Invalid file name \"%1\$s\"."
+ ::msgcat::mcset en "Log Files"
+ ::msgcat::mcset en "&No"
+ ::msgcat::mcset en "&OK"
+ ::msgcat::mcset en "Ok"
+ ::msgcat::mcset en "Open"
+ ::msgcat::mcset en "&Open"
+ ::msgcat::mcset en "Open Multiple Files"
+ ::msgcat::mcset en "Paste"
+ ::msgcat::mcset en "Quit"
+ ::msgcat::mcset en "&Red"
+ ::msgcat::mcset en "Replace existing file?"
+ ::msgcat::mcset en "&Retry"
+ ::msgcat::mcset en "&Save"
+ ::msgcat::mcset en "Save As"
+ ::msgcat::mcset en "Save To Log"
+ ::msgcat::mcset en "Select Log File"
+ ::msgcat::mcset en "Select a file to source"
+ ::msgcat::mcset en "&Selection:"
+ ::msgcat::mcset en "Skip Messages"
+ ::msgcat::mcset en "Source..."
+ ::msgcat::mcset en "Tcl Scripts"
+ ::msgcat::mcset en "Tcl for Windows"
+ ::msgcat::mcset en "Text Files"
+ ::msgcat::mcset en "&Yes"
+ ::msgcat::mcset en "abort"
+ ::msgcat::mcset en "blue"
+ ::msgcat::mcset en "cancel"
+ ::msgcat::mcset en "extension"
+ ::msgcat::mcset en "extensions"
+ ::msgcat::mcset en "green"
+ ::msgcat::mcset en "ignore"
+ ::msgcat::mcset en "ok"
+ ::msgcat::mcset en "red"
+ ::msgcat::mcset en "retry"
+ ::msgcat::mcset en "yes"
+}
diff --git a/ext/tk/sample/msgs_tk/en_gb.msg b/ext/tk/sample/msgs_tk/en_gb.msg
new file mode 100644
index 0000000000..1aa5b49380
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/en_gb.msg
@@ -0,0 +1,7 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset en_gb Color Colour
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset en_gb Color Colour
+}
diff --git a/ext/tk/sample/msgs_tk/eo.msg b/ext/tk/sample/msgs_tk/eo.msg
new file mode 100644
index 0000000000..e683cef297
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/eo.msg
@@ -0,0 +1,87 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset eo "Application Error" "Aplikoerraro"
+ ::msgcat::mcset eo "Blue" "Blua"
+ ::msgcat::mcset eo "Color" "Farbo"
+ ::msgcat::mcset eo "Delete" "Forprenu"
+ ::msgcat::mcset eo "Error" "Eraro"
+ ::msgcat::mcset eo "Exit" "Eliru"
+ ::msgcat::mcset eo "Green" "Verda"
+ ::msgcat::mcset eo "Red" "Rosa"
+ ::msgcat::mcset eo "blue" "blua"
+ ::msgcat::mcset eo "green" "verda"
+ ::msgcat::mcset eo "red" "ru\u011da"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset eo "&Abort" "&\u0108esigo"
+ ::msgcat::mcset eo "&About..." "Pri..."
+ ::msgcat::mcset eo "All Files" "\u0108ioj dosieroj"
+ ::msgcat::mcset eo "Application Error" "Aplikoerraro"
+ ::msgcat::mcset eo "&Blue" "&Blua"
+ ::msgcat::mcset eo "&Cancel" "&Rezignu"
+ ::msgcat::mcset eo "Cannot change to the directory \"%1\$s\".\nPermission denied." "Neeble \u0109angi al dosierulon \"%1\$s\".\nVi ne rajtas tion."
+ ::msgcat::mcset eo "Choose Directory" "Elektu Dosierujo"
+ ::msgcat::mcset eo "&Clear" "&Klaru"
+ ::msgcat::mcset eo "&Clear Console" "&Klaru konzolon"
+ ::msgcat::mcset eo "Color" "Farbo"
+ ::msgcat::mcset eo "Console" "Konzolo"
+ ::msgcat::mcset eo "&Copy" "&Kopiu"
+ ::msgcat::mcset eo "Cu&t" "&Enpo\u015digu"
+ ::msgcat::mcset eo "&Delete" "&Forprenu"
+ ::msgcat::mcset eo "Details >>" "Detaloj >>"
+ ::msgcat::mcset eo "Directory \"%1\$s\" does not exist." "La dosierujo \"%1\$s\" ne ekzistas."
+ ::msgcat::mcset eo "&Directory:" "&Dosierujo:"
+ ::msgcat::mcset eo "&Edit" "&Redaktu"
+ ::msgcat::mcset eo "Error: %1\$s" "Eraro: %1\$s"
+ ::msgcat::mcset eo "E&xit" "&Eliru"
+ ::msgcat::mcset eo "&File" "&Dosiero"
+ ::msgcat::mcset eo "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "La dosiero \"%1\$s\" jam ekzistas.\n\u0108u vi volas anstata\u00fbigi la dosieron?"
+ ::msgcat::mcset eo "File \"%1\$s\" already exists.\n\n" "La dosiero \"%1\$s\" jam egzistas. \n\n"
+ ::msgcat::mcset eo "File \"%1\$s\" does not exist." "La dosierp \"%1\$s\" ne estas."
+ ::msgcat::mcset eo "File &name:" "Dosiero&nomo:"
+ ::msgcat::mcset eo "File &names:" "Dosiero&nomoj:"
+ ::msgcat::mcset eo "Files of &type:" "Dosieroj de &Typo:"
+ ::msgcat::mcset eo "Fi&les:" "Do&sieroj:"
+ ::msgcat::mcset eo "&Filter" "&Filtrilo"
+ ::msgcat::mcset eo "Fil&ter:" "&Filtrilo:"
+ ::msgcat::mcset eo "&Green" "&Verda"
+ ::msgcat::mcset eo "&Help" "&Helpu"
+ ::msgcat::mcset eo "Hi" "Saluton"
+ ::msgcat::mcset eo "&Hide Console" "&Ka\u015du konzolon"
+ ::msgcat::mcset eo "&Ignore" "&Ignoru"
+ ::msgcat::mcset eo "Invalid file name \"%1\$s\"." "Malvalida dosieronomo \"%1\$s\"."
+ ::msgcat::mcset eo "Log Files" "Protokolo"
+ ::msgcat::mcset eo "&No" "&Ne"
+ ::msgcat::mcset eo "OK"
+ ::msgcat::mcset eo "Ok"
+ ::msgcat::mcset eo "Open" "Malfermu"
+ ::msgcat::mcset eo "&Open" "&Malfermu"
+ ::msgcat::mcset eo "Open Multiple Files" "Melfermu multan dosierojn"
+ ::msgcat::mcset eo "P&aste" "&Elpo\u015digi"
+ ::msgcat::mcset eo "&Quit" "&Finigu"
+ ::msgcat::mcset eo "&Red" "&Rosa"
+ ::msgcat::mcset eo "Replace existing file?" "\u0108u anstata\u00fbu ekzistantan dosieron?"
+ ::msgcat::mcset eo "&Retry" "&Ripetu"
+ ::msgcat::mcset eo "&Save" "&Savu"
+ ::msgcat::mcset eo "Save As" "Savu kiel"
+ ::msgcat::mcset eo "Save To Log" "Savu en protokolon"
+ ::msgcat::mcset eo "Select Log File" "Elektu prokolodosieron"
+ ::msgcat::mcset eo "Select a file to source" "Elektu dosieron por interpreti"
+ ::msgcat::mcset eo "&Selection:" "&Elekto:"
+ ::msgcat::mcset eo "Skip Messages" "transsaltu pluajn mesa\u011dojn"
+ ::msgcat::mcset eo "&Source..." "&Fontoprogramo..."
+ ::msgcat::mcset eo "Tcl Scripts" "Tcl-skriptoj"
+ ::msgcat::mcset eo "Tcl for Windows" "Tcl por vindoso"
+ ::msgcat::mcset eo "Text Files" "Tekstodosierojn"
+ ::msgcat::mcset eo "&Yes" "&Jes"
+ ::msgcat::mcset eo "abort" "\u0109esigo"
+ ::msgcat::mcset eo "blue" "blua"
+ ::msgcat::mcset eo "cancel" "rezignu"
+ ::msgcat::mcset eo "extension" "ekspansio"
+ ::msgcat::mcset eo "extensions" "ekspansioj"
+ ::msgcat::mcset eo "green" "verda"
+ ::msgcat::mcset eo "ignore" "ignorieren"
+ ::msgcat::mcset eo "red" "ru\u011da"
+ ::msgcat::mcset eo "retry" "ripetu"
+ ::msgcat::mcset eo "yes" "jes"
+}
diff --git a/ext/tk/sample/msgs_tk/es.msg b/ext/tk/sample/msgs_tk/es.msg
new file mode 100644
index 0000000000..ba981236a3
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/es.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset es "Application Error" "Error de la aplicaci\u00f3n"
+ ::msgcat::mcset es "Blue" "Azul"
+ ::msgcat::mcset es "Color" "Color"
+ ::msgcat::mcset es "Delete" "Borrar"
+ ::msgcat::mcset es "Error" "Error"
+ ::msgcat::mcset es "Exit" "Salir"
+ ::msgcat::mcset es "Green" "Verde"
+ ::msgcat::mcset es "Red" "Rojo"
+ ::msgcat::mcset es "blue" "azul"
+ ::msgcat::mcset es "green" "verde"
+ ::msgcat::mcset es "red" "rojo"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset es "&Abort" "&Abortar"
+ ::msgcat::mcset es "About..." "Acerca de ..."
+ ::msgcat::mcset es "All Files" "Todos los archivos"
+ ::msgcat::mcset es "Application Error" "Error de la aplicaci\u00f3n"
+ ::msgcat::mcset es "&Blue" "&Azul"
+ ::msgcat::mcset es "&Cancel" "&Cancelar"
+ ::msgcat::mcset es "Cannot change to the directory \"%1\$s\".\nPermission denied." "No es posible acceder al directorio \"%1\$s\".\nPermiso denegado."
+ ::msgcat::mcset es "Choose Directory" "Elegir directorio"
+ ::msgcat::mcset es "Clear" "Borrar"
+ ::msgcat::mcset es "Color" "Color"
+ ::msgcat::mcset es "Console" "Consola"
+ ::msgcat::mcset es "Copy" "Copiar"
+ ::msgcat::mcset es "Cut" "Cortar"
+ ::msgcat::mcset es "Delete" "Borrar"
+ ::msgcat::mcset es "Details >>" "Detalles >>"
+ ::msgcat::mcset es "Directory \"%1\$s\" does not exist." "El directorio \"%1\$s\" no existe."
+ ::msgcat::mcset es "&Directory:" "&Directorio:"
+ ::msgcat::mcset es "Error: %1\$s" "Error: %1\$s"
+ ::msgcat::mcset es "Exit" "Salir"
+ ::msgcat::mcset es "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "El archivo \"%1\$s\" ya existe.\nDesea sobreescribirlo?"
+ ::msgcat::mcset es "File \"%1\$s\" already exists.\n\n" "El archivo \"%1\$s\" ya existe.\n\n"
+ ::msgcat::mcset es "File \"%1\$s\" does not exist." "El archivo \"%1\$s\" no existe."
+ ::msgcat::mcset es "File &name:" "&Nombre de archivo:"
+ ::msgcat::mcset es "File &names:" "&Nombres de archivo:"
+ ::msgcat::mcset es "Files of &type:" "Archivos de &tipo:"
+ ::msgcat::mcset es "Fi&les:" "&Archivos:"
+ ::msgcat::mcset es "&Filter" "&Filtro"
+ ::msgcat::mcset es "Fil&ter:" "Fil&tro:"
+ ::msgcat::mcset es "&Green" "&Verde"
+ ::msgcat::mcset es "Hi" "Hola"
+ ::msgcat::mcset es "Hide Console" "Esconder la consola"
+ ::msgcat::mcset es "&Ignore" "&Ignorar"
+ ::msgcat::mcset es "Invalid file name \"%1\$s\"." "Nombre de archivo inv\u00e1lido \"%1\$s\"."
+ ::msgcat::mcset es "Log Files" "Ficheros de traza"
+ ::msgcat::mcset es "&No" "&No"
+ ::msgcat::mcset es "&OK" "&OK"
+ ::msgcat::mcset es "Ok" "Ok"
+ ::msgcat::mcset es "Open" "Abrir"
+ ::msgcat::mcset es "&Open" "&Abrir"
+ ::msgcat::mcset es "Open Multiple Files" "Abrir m\u00faltiples archivos"
+ ::msgcat::mcset es "Paste" "Pegar"
+ ::msgcat::mcset es "Quit" "Abandonar"
+ ::msgcat::mcset es "&Red" "&Rojo"
+ ::msgcat::mcset es "Replace existing file?" "Reemplazar el archivo existente?"
+ ::msgcat::mcset es "&Retry" "&Reintentar"
+ ::msgcat::mcset es "&Save" "&Salvar"
+ ::msgcat::mcset es "Save As" "Salvar como"
+ ::msgcat::mcset es "Save To Log" "Salvar al archivo de traza"
+ ::msgcat::mcset es "Select Log File" "Elegir un archivo de traza"
+ ::msgcat::mcset es "Select a file to source" "Seleccionar un archivo a evaluar"
+ ::msgcat::mcset es "&Selection:" "&Selecci\u00f3n:"
+ ::msgcat::mcset es "Skip Messages" "Omitir los mensajes"
+ ::msgcat::mcset es "Source..." "Evaluar..."
+ ::msgcat::mcset es "Tcl Scripts" "Scripts Tcl"
+ ::msgcat::mcset es "Tcl for Windows" "Tcl para Windows"
+ ::msgcat::mcset es "Text Files" "Archivos de texto"
+ ::msgcat::mcset es "&Yes" "&S\u00ed"
+ ::msgcat::mcset es "abort" "abortar"
+ ::msgcat::mcset es "blue" "azul"
+ ::msgcat::mcset es "cancel" "cancelar"
+ ::msgcat::mcset es "extension" "extensi\u00f3n"
+ ::msgcat::mcset es "extensions" "extensiones"
+ ::msgcat::mcset es "green" "verde"
+ ::msgcat::mcset es "ignore" "ignorar"
+ ::msgcat::mcset es "ok" "ok"
+ ::msgcat::mcset es "red" "rojo"
+ ::msgcat::mcset es "retry" "reintentar"
+ ::msgcat::mcset es "yes" "s\u00ed"
+}
diff --git a/ext/tk/sample/msgs_tk/fr.msg b/ext/tk/sample/msgs_tk/fr.msg
new file mode 100644
index 0000000000..ebbba48ca1
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/fr.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset fr "Application Error" "Erreur d'application"
+ ::msgcat::mcset fr "Blue" "Bleu"
+ ::msgcat::mcset fr "Color" "Couleur"
+ ::msgcat::mcset fr "Delete" "Effacer"
+ ::msgcat::mcset fr "Error" "Erreur"
+ ::msgcat::mcset fr "Exit" "Quitter"
+ ::msgcat::mcset fr "Green" "Vert"
+ ::msgcat::mcset fr "Red" "Rouge"
+ ::msgcat::mcset fr "blue" "bleu"
+ ::msgcat::mcset fr "green" "vert"
+ ::msgcat::mcset fr "red" "rouge"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset fr "&Abort" "&Annuler"
+ ::msgcat::mcset fr "About..." "\u00c0 propos..."
+ ::msgcat::mcset fr "All Files" "Tous les fichiers"
+ ::msgcat::mcset fr "Application Error" "Erreur d'application"
+ ::msgcat::mcset fr "&Blue" "&Bleu"
+ ::msgcat::mcset fr "&Cancel" "&Annuler"
+ ::msgcat::mcset fr "Cannot change to the directory \"%1\$s\".\nPermission denied." "Impossible d'acc\u00e9der au r\u00e9pertoire \"%1\$s\".\nPermission refus\u00e9e."
+ ::msgcat::mcset fr "Choose Directory" "Choisir r\u00e9pertoire"
+ ::msgcat::mcset fr "Clear" "Effacer"
+ ::msgcat::mcset fr "Color" "Couleur"
+ ::msgcat::mcset fr "Console"
+ ::msgcat::mcset fr "Copy" "Copier"
+ ::msgcat::mcset fr "Cut" "Couper"
+ ::msgcat::mcset fr "Delete" "Effacer"
+ ::msgcat::mcset fr "Details >>" "D\u00e9tails >>"
+ ::msgcat::mcset fr "Directory \"%1\$s\" does not exist." "Le r\u00e9pertoire \"%1\$s\" n'existe pas."
+ ::msgcat::mcset fr "&Directory:" "&R\u00e9pertoire:"
+ ::msgcat::mcset fr "Error: %1\$s" "Erreur: %1\$s"
+ ::msgcat::mcset fr "Exit" "Quitter"
+ ::msgcat::mcset fr "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Le fichier \"%1\$s\" existe d\u00e9j\u00e0.\nVoulez-vous l'\u00e9craser?"
+ ::msgcat::mcset fr "File \"%1\$s\" already exists.\n\n" "Le fichier \"%1\$s\" existe d\u00e9j\u00e0.\n\n"
+ ::msgcat::mcset fr "File \"%1\$s\" does not exist." "Le fichier \"%1\$s\" n'existe pas."
+ ::msgcat::mcset fr "File &name:" "&Nom de fichier:"
+ ::msgcat::mcset fr "File &names:" "&Noms de fichiers:"
+ ::msgcat::mcset fr "Files of &type:" "&Type de fichiers:"
+ ::msgcat::mcset fr "Fi&les:" "Fich&iers:"
+ ::msgcat::mcset fr "&Filter" "&Filtre"
+ ::msgcat::mcset fr "Fil&ter:" "Fil&tre:"
+ ::msgcat::mcset fr "&Green" "&Vert"
+ ::msgcat::mcset fr "Hi" "Salut"
+ ::msgcat::mcset fr "Hide Console" "Cacher la Console"
+ ::msgcat::mcset fr "&Ignore" "&Ignorer"
+ ::msgcat::mcset fr "Invalid file name \"%1\$s\"." "Nom de fichier invalide \"%1\$s\"."
+ ::msgcat::mcset fr "Log Files" "Fichiers de trace"
+ ::msgcat::mcset fr "&No" "&Non"
+ ::msgcat::mcset fr "&OK"
+ ::msgcat::mcset fr "Ok"
+ ::msgcat::mcset fr "Open" "Ouvrir"
+ ::msgcat::mcset fr "&Open" "&Ouvrir"
+ ::msgcat::mcset fr "Open Multiple Files" "Ouvrir plusieurs fichiers"
+ ::msgcat::mcset fr "Paste" "Coller"
+ ::msgcat::mcset fr "Quit" "Quitter"
+ ::msgcat::mcset fr "&Red" "&Rouge"
+ ::msgcat::mcset fr "Replace existing file?" "Remplacer le fichier existant?"
+ ::msgcat::mcset fr "&Retry" "&R\u00e9-essayer"
+ ::msgcat::mcset fr "&Save" "&Sauvegarder"
+ ::msgcat::mcset fr "Save As" "Sauvegarder sous"
+ ::msgcat::mcset fr "Save To Log" "Sauvegarde au fichier de trace"
+ ::msgcat::mcset fr "Select Log File" "Choisir un fichier de trace"
+ ::msgcat::mcset fr "Select a file to source" "Choisir un fichier \u00e0 \u00e9valuer"
+ ::msgcat::mcset fr "&Selection:" "&S\u00e9lection:"
+ ::msgcat::mcset fr "Skip Messages" "Omettre les messages"
+ ::msgcat::mcset fr "Source..." "\u00c9valuer..."
+ ::msgcat::mcset fr "Tcl Scripts" "Scripts Tcl"
+ ::msgcat::mcset fr "Tcl for Windows" "Tcl pour Windows"
+ ::msgcat::mcset fr "Text Files" "Fichiers texte"
+ ::msgcat::mcset fr "&Yes" "&Oui"
+ ::msgcat::mcset fr "abort" "abandonner"
+ ::msgcat::mcset fr "blue" "bleu"
+ ::msgcat::mcset fr "cancel" "annuler"
+ ::msgcat::mcset fr "extension"
+ ::msgcat::mcset fr "extensions"
+ ::msgcat::mcset fr "green" "vert"
+ ::msgcat::mcset fr "ignore" "ignorer"
+ ::msgcat::mcset fr "ok"
+ ::msgcat::mcset fr "red" "rouge"
+ ::msgcat::mcset fr "retry" "r\u00e9essayer"
+ ::msgcat::mcset fr "yes" "oui"
+}
diff --git a/ext/tk/sample/msgs_tk/it.msg b/ext/tk/sample/msgs_tk/it.msg
new file mode 100644
index 0000000000..b144fcc073
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/it.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset it "Application Error" "Errore dell' applicazione"
+ ::msgcat::mcset it "Blue" "Blu"
+ ::msgcat::mcset it "Color" "Colore"
+ ::msgcat::mcset it "Delete" "Incolla"
+ ::msgcat::mcset it "Error" "Errore"
+ ::msgcat::mcset it "Exit" "Esci"
+ ::msgcat::mcset it "Green" "Verde"
+ ::msgcat::mcset it "Red" "Rosso"
+ ::msgcat::mcset it "blue" "blu"
+ ::msgcat::mcset it "green" "verde"
+ ::msgcat::mcset it "red" "rosso"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset it "&Abort" "&Interrompi"
+ ::msgcat::mcset it "About..." "Informazioni ..."
+ ::msgcat::mcset it "All Files" "Tutti i file"
+ ::msgcat::mcset it "Application Error" "Errore dell' applicazione"
+ ::msgcat::mcset it "&Blue" "&Blu"
+ ::msgcat::mcset it "&Cancel" "&Annulla"
+ ::msgcat::mcset it "Cannot change to the directory \"%1\$s\".\nPermission denied." "Impossibile accedere alla directory \"%1\$s\".\nPermesso negato."
+ ::msgcat::mcset it "Choose Directory" "Scegli directory"
+ ::msgcat::mcset it "Clear" "Azzera"
+ ::msgcat::mcset it "Color" "Colore"
+ ::msgcat::mcset it "Console"
+ ::msgcat::mcset it "Copy" "Copia"
+ ::msgcat::mcset it "Cut" "Taglia"
+ ::msgcat::mcset it "Delete" "Incolla"
+ ::msgcat::mcset it "Details >>" "Dettagli >>"
+ ::msgcat::mcset it "Directory \"%1\$s\" does not exist." "La directory \"%1\$s\" non esiste."
+ ::msgcat::mcset it "&Directory:"
+ ::msgcat::mcset it "Error: %1\$s" "Errore: %1\$s"
+ ::msgcat::mcset it "Exit" "Esci"
+ ::msgcat::mcset it "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Il file \"%1\$s\" esiste gi\u00e0.\nVuoi sovrascriverlo?"
+ ::msgcat::mcset it "File \"%1\$s\" already exists.\n\n" "Il file \"%1\$s\" esiste gi\u00e0.\n\n"
+ ::msgcat::mcset it "File \"%1\$s\" does not exist." "Il file \"%1\$s\" non esiste."
+ ::msgcat::mcset it "File &name:" "&Nome del file:"
+ ::msgcat::mcset it "File &names:" "&Nomi dei file:"
+ ::msgcat::mcset it "Files of &type:" "File di &tipo:"
+ ::msgcat::mcset it "Fi&les:" "Fi&le:"
+ ::msgcat::mcset it "&Filter" "&Filtro"
+ ::msgcat::mcset it "Fil&ter:" "Fil&tro:"
+ ::msgcat::mcset it "&Green" "&Verde"
+ ::msgcat::mcset it "Hi" "Salve"
+ ::msgcat::mcset it "Hide Console" "Nascondi la console"
+ ::msgcat::mcset it "&Ignore" "&Ignora"
+ ::msgcat::mcset it "Invalid file name \"%1\$s\"." "Nome di file non valido \"%1\$s\"."
+ ::msgcat::mcset it "Log Files" "File di log"
+ ::msgcat::mcset it "&No"
+ ::msgcat::mcset it "&OK"
+ ::msgcat::mcset it "Ok"
+ ::msgcat::mcset it "&Open" "A&pri"
+ ::msgcat::mcset it "Open" "Apri"
+ ::msgcat::mcset it "Open Multiple Files" "Apri file multipli"
+ ::msgcat::mcset it "Paste" "Incolla"
+ ::msgcat::mcset it "Quit" "Esci"
+ ::msgcat::mcset it "&Red" "&Rosso"
+ ::msgcat::mcset it "Replace existing file?" "Sostituisci il file esistente?"
+ ::msgcat::mcset it "&Retry" "&Riprova"
+ ::msgcat::mcset it "&Save" "&Salva"
+ ::msgcat::mcset it "Save As" "Salva come"
+ ::msgcat::mcset it "Save To Log" "Salva il log"
+ ::msgcat::mcset it "Select Log File" "Scegli un file di log"
+ ::msgcat::mcset it "Select a file to source" "Scegli un file da eseguire"
+ ::msgcat::mcset it "&Selection:" "&Selezione:"
+ ::msgcat::mcset it "Skip Messages" "Salta i messaggi"
+ ::msgcat::mcset it "Source..." "Esegui..."
+ ::msgcat::mcset it "Tcl Scripts" "Scripts Tcl"
+ ::msgcat::mcset it "Tcl for Windows" "Tcl per Windows"
+ ::msgcat::mcset it "Text Files" "File di testo"
+ ::msgcat::mcset it "&Yes" "&Si"
+ ::msgcat::mcset it "abort" "interrompi"
+ ::msgcat::mcset it "blue" "blu"
+ ::msgcat::mcset it "cancel" "annulla"
+ ::msgcat::mcset it "extension" "estensione"
+ ::msgcat::mcset it "extensions" "estensioni"
+ ::msgcat::mcset it "green" "verde"
+ ::msgcat::mcset it "ignore" "ignora"
+ ::msgcat::mcset it "ok"
+ ::msgcat::mcset it "red" "rosso"
+ ::msgcat::mcset it "retry" "riprova"
+ ::msgcat::mcset it "yes" "si"
+}
diff --git a/ext/tk/sample/msgs_tk/ja.msg b/ext/tk/sample/msgs_tk/ja.msg
new file mode 100644
index 0000000000..44a25839db
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/ja.msg
@@ -0,0 +1,13 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset ja "Application Error" "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30A8\u30E9\u30FC"
+ ::msgcat::mcset ja "Blue" "\u9752"
+ ::msgcat::mcset ja "Color" "\u80CC\u666F\u8272"
+ ::msgcat::mcset ja "Delete" "\u6D88\u53BB"
+ ::msgcat::mcset ja "Error" "\u30A8\u30E9\u30FC"
+ ::msgcat::mcset ja "Exit" "\u7D42\u4E86"
+ ::msgcat::mcset ja "Green" "\u7DD1"
+ ::msgcat::mcset ja "Red" "\u8D64"
+ ::msgcat::mcset ja "blue" "\u9752"
+ ::msgcat::mcset ja "green" "\u7DD1"
+ ::msgcat::mcset ja "red" "\u8D64"
+}
diff --git a/ext/tk/sample/msgs_tk/license.terms b/ext/tk/sample/msgs_tk/license.terms
new file mode 100644
index 0000000000..03ca6fcb31
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/license.terms
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/msgs_tk/nl.msg b/ext/tk/sample/msgs_tk/nl.msg
new file mode 100644
index 0000000000..d9642e808c
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/nl.msg
@@ -0,0 +1,123 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset nl "Application Error" "Toepassingsfout"
+ ::msgcat::mcset nl "Blue" "Blauw"
+ ::msgcat::mcset nl "Color" "Kleur"
+ ::msgcat::mcset nl "Delete" "Wissen"
+ ::msgcat::mcset nl "Error" "Fout"
+ ::msgcat::mcset nl "Exit" "Be\u00ebindigen"
+ ::msgcat::mcset nl "Green" "Groen"
+ ::msgcat::mcset nl "Red" "Rood"
+ ::msgcat::mcset nl "blue" "blauw"
+ ::msgcat::mcset nl "green" "groen"
+ ::msgcat::mcset nl "red" "rood"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset nl "\"%1\$s\" must be an absolute pathname" "\"%1\$s\" moet een absolute pad-naam zijn"
+ ::msgcat::mcset nl "%1\$s is not a toplevel window" "%1\$s is geen toplevel window"
+ ::msgcat::mcset nl ", or" ", of"
+ ::msgcat::mcset nl "-default, -icon, -message, -parent, -title, or -type" "-default, -icon, -message, -parent, -title, of -type"
+ ::msgcat::mcset nl "-initialdir, -mustexist, -parent, or -title" "-initialdir, -mustexist, -parent, of -title"
+ ::msgcat::mcset nl "&Abort" "&Afbreken"
+ ::msgcat::mcset nl "About..." "Over..."
+ ::msgcat::mcset nl "All Files" "Alle Bestanden"
+ ::msgcat::mcset nl "Application Error" "Toepassingsfout"
+ ::msgcat::mcset nl "&Blue" "&Blauw"
+ ::msgcat::mcset nl "&Cancel" "&Annuleren"
+ ::msgcat::mcset nl "Cannot change to the directory \"%1\$s\".\nPermission denied." "Kan niet naar map \"%1\$s\" gaan.\nU heeft hiervoor geen toestemming."
+ ::msgcat::mcset nl "Choose Directory" "Kies map"
+ ::msgcat::mcset nl "Clear" "Wissen"
+ ::msgcat::mcset nl "Clear entry, Press OK; Enter %1\$s, press OK" "Wis veld, Druk op OK; typ %1\$s in, druk op OK"
+ ::msgcat::mcset nl "&Clear Console" "&Wis Console"
+ ::msgcat::mcset nl "Color" "Kleur"
+ ::msgcat::mcset nl "Console"
+ ::msgcat::mcset nl "Copy" "Kopi\u00ebren"
+ ::msgcat::mcset nl "Cut" "Knippen"
+ ::msgcat::mcset nl "Delete" "Wissen"
+ ::msgcat::mcset nl "Details"
+ ::msgcat::mcset nl "Details >>"
+ ::msgcat::mcset nl "Directory \"%1\$s\" does not exist." "Map \"%1\$s\" bestaat niet."
+ ::msgcat::mcset nl "&Directory:" "&Map:"
+ ::msgcat::mcset nl "Edit" "Bewerken"
+ ::msgcat::mcset nl "Enter \"%1\$s\", press OK" "Typ \"%1\$s\", druk op OK"
+ ::msgcat::mcset nl "Enter \"%1\$s\", press OK, enter \"%2\$s\", press OK" "Typ \"%1\$s\", druk op OK, typ \"%2\$s\", druk op OK"
+ ::msgcat::mcset nl "Error: %1\$s" "Fout: %1\$s"
+ ::msgcat::mcset nl "Exit" "Be\u00ebindigen"
+ ::msgcat::mcset nl "File" "Bestand"
+ ::msgcat::mcset nl "File \"%1\$s\" already exists.\n\n" "Bestand \"%1\$s\" bestaat al.\n\n"
+ ::msgcat::mcset nl "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Bestand \"%1\$s\" bestaat al.\nWilt u het overschrijven?"
+ ::msgcat::mcset nl "File \"%1\$s\" does not exist." "Bestand \"%1\$s\" bestaat niet."
+ ::msgcat::mcset nl "File &name:" "Bestands&naam:"
+ ::msgcat::mcset nl "File &names:" "Bestands&namen:"
+ ::msgcat::mcset nl "Files of &type:" "Bestanden van het &type:"
+ ::msgcat::mcset nl "Fi&les:" "&Bestanden:"
+ ::msgcat::mcset nl "&Filter"
+ ::msgcat::mcset nl "Fil&ter:"
+ ::msgcat::mcset nl "&Green" "&Groen"
+ ::msgcat::mcset nl "Hi" "H\u00e9"
+ ::msgcat::mcset nl "Hide Console" "Verberg Console"
+ ::msgcat::mcset nl "&Ignore" "&Negeren"
+ ::msgcat::mcset nl "Invalid file name \"%1\$s\"." "Ongeldige bestandsnaam \"%1\$s\"."
+ ::msgcat::mcset nl "Log Files" "Log Bestanden"
+ ::msgcat::mcset nl "&No" "&Nee"
+ ::msgcat::mcset nl "&OK"
+ ::msgcat::mcset nl "Ok"
+ ::msgcat::mcset nl "&Open" "&Openen"
+ ::msgcat::mcset nl "Open" "Openen"
+ ::msgcat::mcset nl "Open Multiple Files" "Open meerdere bestanden"
+ ::msgcat::mcset nl "Paste" "Plakken"
+ ::msgcat::mcset nl "Please press %1\$s" "Druk op %1\$s, A.U.B."
+ ::msgcat::mcset nl "Please press ok" "Druk op ok, A.U.B."
+ ::msgcat::mcset nl "Press Cancel" "Druk op Annuleren"
+ ::msgcat::mcset nl "Press Ok" "Druk op Ok"
+ ::msgcat::mcset nl "Quit" "Stoppen"
+ ::msgcat::mcset nl "&Red" "&Rood"
+ ::msgcat::mcset nl "Replace existing file?" "Vervang bestaand bestand?"
+ ::msgcat::mcset nl "&Retry" "&Herhalen"
+ ::msgcat::mcset nl "&Save" "Op&slaan"
+ ::msgcat::mcset nl "Save As" "Opslaan als"
+ ::msgcat::mcset nl "Save To Log" "Opslaan naar Log"
+ ::msgcat::mcset nl "Select Log File" "Selecteer Log bestand"
+ ::msgcat::mcset nl "Select a file to source" "Selecteer bronbestand"
+ ::msgcat::mcset nl "&Selection:" "&Selectie:"
+ ::msgcat::mcset nl "Skip Messages" "Berichten overslaan"
+ ::msgcat::mcset nl "Source..." "Bron..."
+ ::msgcat::mcset nl "Tcl Scripts"
+ ::msgcat::mcset nl "Tcl for Windows" "Tcl voor Windows"
+ ::msgcat::mcset nl "Text Files" "Tekstbestanden"
+ ::msgcat::mcset nl "&Yes" "&Ja"
+ ::msgcat::mcset nl "abort" "afbreken"
+ ::msgcat::mcset nl "abort, retry, ignore, ok, cancel, no, or yes" "afbreken, opnieuw, negeren, ok, annuleren, nee, of ja"
+ ::msgcat::mcset nl "abortretryignore, ok, okcancel, retrycancel, yesno, or yesnocancel" "abortretryignore, ok, okcancel, retrycancel, yesno, of yesnocancel"
+ ::msgcat::mcset nl "bad %1\$s value \"%2\$s\": must be %3\$s" "verkeerde %1\$s waarde \"%2\$s\": moet zijn %3\$s"
+ ::msgcat::mcset nl "bad file type \"%1\$s\", should be" "verkeerd bestandstype \"%1\$s\", moet zijn"
+ ::msgcat::mcset nl "bad option \"%1\$s\": should be %2\$s" "verkeerde optie \"%1\$s\": moet zijn %2\$s"
+ ::msgcat::mcset nl "bad window path name \"%1\$s\"" "verkeerde window-padnaam \"%1\$s\""
+ ::msgcat::mcset nl "blue" "blauw"
+ ::msgcat::mcset nl "can't post %1\$s: it isn't a descendant of %2\$s (this is a new requirement in Tk versions 3.0 and later)" "kan %1\$s niet verzenden: het is geen afstammeling van %2\$s (dit is een nieuwe eis in Tk versies 3.0 en later)"
+ ::msgcat::mcset nl "cancel" "annuleren"
+ ::msgcat::mcset nl "default button index greater than number of buttons specified for tk_dialog" "default knop index is groter dan het aantal knoppen beschikbaar voor tk_dialog"
+ ::msgcat::mcset nl "display name to use (current one otherwise)" "te gebruiken schermnaam (anders huidige scherm)"
+ ::msgcat::mcset nl "error, info, question, or warning" "error, info, question, of warning"
+ ::msgcat::mcset nl "extension"
+ ::msgcat::mcset nl "extensions"
+ ::msgcat::mcset nl "focus group \"%1\$s\" doesn't exist" "focusgroep \"%1\$s\" bestaat niet"
+ ::msgcat::mcset nl "green" "groen"
+ ::msgcat::mcset nl "history event %1\$s"
+ ::msgcat::mcset nl "ignore" "negeren"
+ ::msgcat::mcset nl "invalid default button \"%1\$s\"" "ongeldige default knop \"%1\$s\""
+ ::msgcat::mcset nl "macType"
+ ::msgcat::mcset nl "macTypes"
+ ::msgcat::mcset nl "must specify a background color" "een achtergrondkleur is verplicht"
+ ::msgcat::mcset nl "name of the slave interpreter" "naam van de slaaf-interpreter"
+ ::msgcat::mcset nl "no winfo screen . nor env(DISPLAY)" "geen winfo scherm . noch env(DISPLAY)"
+ ::msgcat::mcset nl "ok"
+ ::msgcat::mcset nl "red" "rood"
+ ::msgcat::mcset nl "retry" "opnieuw"
+ ::msgcat::mcset nl "should contain 5 or 4 elements" "moet 4 of 5 elementen bevatten"
+ ::msgcat::mcset nl "spec"
+ ::msgcat::mcset nl "tk_chooseDirectory command" "tk_chooseDirectory opdracht"
+ ::msgcat::mcset nl "tk_chooseDirectory command, cancel gives null" "tk_chooseDirectory opdracht, annuleren geeft lege waarde"
+ ::msgcat::mcset nl "tk_chooseDirectory command, initialdir" "tk_chooseDirectory opdracht, initi\u00eble map"
+ ::msgcat::mcset nl "yes" "ja"
+}
diff --git a/ext/tk/sample/msgs_tk/pl.msg b/ext/tk/sample/msgs_tk/pl.msg
new file mode 100644
index 0000000000..2699e42bdf
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/pl.msg
@@ -0,0 +1,87 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset pl "Application Error" "Bl\u0105d w Programie"
+ ::msgcat::mcset pl "Blue" "Niebieski"
+ ::msgcat::mcset pl "Color" "Kolor"
+ ::msgcat::mcset pl "Delete" "Usu\u0144"
+ ::msgcat::mcset pl "Error" "B\u0142\u0105d"
+ ::msgcat::mcset pl "Exit" "Zako\u0144cz"
+ ::msgcat::mcset pl "Green" "Zielony"
+ ::msgcat::mcset pl "Red" "Czerwonz"
+ ::msgcat::mcset pl "blue" "niebieski"
+ ::msgcat::mcset pl "green" "zielony"
+ ::msgcat::mcset pl "red" "czerwony"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset pl "&Abort" "&Anuluj"
+ ::msgcat::mcset pl "&About..." "O Programie..."
+ ::msgcat::mcset pl "All Files" "Wszystkie pliki"
+ ::msgcat::mcset pl "Application Error" "Bl\u0105d w Programie"
+ ::msgcat::mcset pl "&Blue" "&Niebieski"
+ ::msgcat::mcset pl "&Cancel" "&Anuluj"
+ ::msgcat::mcset pl "Cannot change to the directory \"%1\$s\".\nPermission denied." "Katalog \"%1\$s\" nie mo\u017ce zosta\u0107 odczytany lub nie istnieje."
+ ::msgcat::mcset pl "Choose Directory" "Wybierz katalog"
+ ::msgcat::mcset pl "&Clear" "&Wyczy\u015b\u0107"
+ ::msgcat::mcset pl "&Clear Console" "&Wyczy\u015b\u0107 konsol\u0119"
+ ::msgcat::mcset pl "Color" "Kolor"
+ ::msgcat::mcset pl "Console" "Konsola"
+ ::msgcat::mcset pl "&Copy" "&Kopiuj"
+ ::msgcat::mcset pl "Cu&t" "&Wytnij"
+ ::msgcat::mcset pl "&Delete" "&Usu\u0144"
+ ::msgcat::mcset pl "Details >>" "Detale >>"
+ ::msgcat::mcset pl "Directory \"%1\$s\" does not exist." "Katalog \"%1\$s\" nie istniej."
+ ::msgcat::mcset pl "&Directory:" "&Katalog:"
+ ::msgcat::mcset pl "&Edit" "&Edytuj"
+ ::msgcat::mcset pl "Error: %1\$s" "B\u0142\u0105d: %1\$s"
+ ::msgcat::mcset pl "E&xit" "&Zako\u0144cz"
+ ::msgcat::mcset pl "&File" "&Plik"
+ ::msgcat::mcset pl "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Plik \"%1\$s\" ju\u017c istnieje.\nCzy chcesz go zast\u0105pi\u0107?"
+ ::msgcat::mcset pl "File \"%1\$s\" already exists.\n\n" "Plik \"%1\$s\" ju\u017c istnieje. \n\n"
+ ::msgcat::mcset pl "File \"%1\$s\" does not exist." "Plik \"%1\$s\" nie istnieje."
+ ::msgcat::mcset pl "File &name:" "Nazwa &pliku:"
+ ::msgcat::mcset pl "File &names:" "Nazwy &plik\u00f3w:"
+ ::msgcat::mcset pl "Files of &type:" "Pliki &typu:"
+ ::msgcat::mcset pl "Fi&les:" "Pli&ki:"
+ ::msgcat::mcset pl "&Filter" "&Filter"
+ ::msgcat::mcset pl "Fil&ter:" "&Filter:"
+ ::msgcat::mcset pl "&Green" "&Zielony"
+ ::msgcat::mcset pl "&Help" "&Pomoc"
+ ::msgcat::mcset pl "Hi" "Witaj"
+ ::msgcat::mcset pl "&Hide Console" "&Schowaj konsol\u0119"
+ ::msgcat::mcset pl "&Ignore" "&Ignoruj"
+ ::msgcat::mcset pl "Invalid file name \"%1\$s\"." "Niew\u0142a\u015bciwa nazwa pliku \"%1\$s\"."
+ ::msgcat::mcset pl "Log Files" "Protoko\u0142uj"
+ ::msgcat::mcset pl "&No" "&Nie"
+ ::msgcat::mcset pl "OK"
+ ::msgcat::mcset pl "Ok"
+ ::msgcat::mcset pl "Open" "Wczytaj"
+ ::msgcat::mcset pl "&Open" "&Wczytaj"
+ ::msgcat::mcset pl "Open Multiple Files" "Wczytuj wiele plik\u00f3w"
+ ::msgcat::mcset pl "P&aste" "&Wklej"
+ ::msgcat::mcset pl "&Quit" "&Zako\u0144cz"
+ ::msgcat::mcset pl "&Red" "&Czerwonz"
+ ::msgcat::mcset pl "Replace existing file?" "Czy zost\u0105pi\u0107 instniej\u0105cy plik?"
+ ::msgcat::mcset pl "&Retry" "&Powt\u00f3rz"
+ ::msgcat::mcset pl "&Save" "&Zapisz"
+ ::msgcat::mcset pl "Save As" "Zapisz jako"
+ ::msgcat::mcset pl "Save To Log" "Wpisz do protoko\u0142u"
+ ::msgcat::mcset pl "Select Log File" "Wybierz plik proko\u0142u"
+ ::msgcat::mcset pl "Select a file to source" "Wybierz plik do wykonania"
+ ::msgcat::mcset pl "&Selection:" "&Wyb\u00f3r:"
+ ::msgcat::mcset pl "Skip Messages" "Omi\u0144 pozosta\u0142e komunikaty"
+ ::msgcat::mcset pl "&Source..." "&Kod \u017ar\u00f3d\u0142owy..."
+ ::msgcat::mcset pl "Tcl Scripts" "Tcl-skrypty"
+ ::msgcat::mcset pl "Tcl for Windows" "Tcl dla Okienek (Windows)"
+ ::msgcat::mcset pl "Text Files" "Pliki Tekstowe"
+ ::msgcat::mcset pl "&Yes" "&Tak"
+ ::msgcat::mcset pl "abort" "zako\u0144cz"
+ ::msgcat::mcset pl "blue" "niebieski"
+ ::msgcat::mcset pl "cancel" "anuluj"
+ ::msgcat::mcset pl "extension" "rozszerzenie"
+ ::msgcat::mcset pl "extensions" "rozszerzenia"
+ ::msgcat::mcset pl "green" "zielony"
+ ::msgcat::mcset pl "ignore" "ignoruj"
+ ::msgcat::mcset pl "red" "czerwony"
+ ::msgcat::mcset pl "retry" "potw\u00f3rz"
+ ::msgcat::mcset pl "yes" "tak"
+}
diff --git a/ext/tk/sample/msgs_tk/ru.msg b/ext/tk/sample/msgs_tk/ru.msg
new file mode 100644
index 0000000000..a1192b7095
--- /dev/null
+++ b/ext/tk/sample/msgs_tk/ru.msg
@@ -0,0 +1,87 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset ru "Application Error" "\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435"
+ ::msgcat::mcset ru "Blue" " \u0413\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "Color" "\u0426\u0432\u0435\u0442"
+ ::msgcat::mcset ru "Delete" "\u0423\u0434\u0430\u043b\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Error" "\u041e\u0448\u0438\u0431\u043a\u0430"
+ ::msgcat::mcset ru "Exit" "\u0412\u044b\u0445\u043e\u0434"
+ ::msgcat::mcset ru "Green" "\u0417\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "Red" "\u041a\u0440\u0430\u0441\u043d\u044b\u0439"
+ ::msgcat::mcset ru "blue" " \u0433\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "green" " \u0437\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "red" " \u043a\u0440\u0430\u0441\u043d\u044b\u0439"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset ru "&Abort" "&\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c"
+ ::msgcat::mcset ru "About..." "\u041f\u0440\u043e..."
+ ::msgcat::mcset ru "All Files" "\u0412\u0441\u0435 \u0444\u0430\u0439\u043b\u044b"
+ ::msgcat::mcset ru "Application Error" "\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435"
+ ::msgcat::mcset ru "&Blue" " &\u0413\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "&Cancel" "\u041e\u0442&\u043c\u0435\u043d\u0430"
+ ::msgcat::mcset ru "Cannot change to the directory \"%1\$s\".\nPermission denied." \
+ "\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \"%1\$s\".\n\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430"
+ ::msgcat::mcset ru "Choose Directory" "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433"
+ ::msgcat::mcset ru "Clear" "\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Color" "\u0426\u0432\u0435\u0442"
+ ::msgcat::mcset ru "Console" "\u041a\u043e\u043d\u0441\u043e\u043b\u044c"
+ ::msgcat::mcset ru "Copy" "\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c"
+ ::msgcat::mcset ru "Cut" "\u0412\u044b\u0440\u0435\u0437\u0430\u0442\u044c"
+ ::msgcat::mcset ru "Delete" "\u0423\u0434\u0430\u043b\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Details >>" "\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 >>"
+ ::msgcat::mcset ru "Directory \"%1\$s\" does not exist." "\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \"%1\$s\" \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442."
+ ::msgcat::mcset ru "&Directory:" "&\u041a\u0430\u0442\u0430\u043b\u043e\u0433:"
+ ::msgcat::mcset ru "Error: %1\$s" "\u041e\u0448\u0438\u0431\u043a\u0430: %1\$s"
+ ::msgcat::mcset ru "Exit" "\u0412\u044b\u0445\u043e\u0434"
+ ::msgcat::mcset ru "File \"%1\$s\" already exists.\nDo you want to overwrite it?" \
+ "\u0424\u0430\u0439\u043b \"%1\$s\" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.\n\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e?"
+ ::msgcat::mcset ru "File \"%1\$s\" already exists.\n\n" "\u0424\u0430\u0439\u043b \"%1\$s\" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.\n\n"
+ ::msgcat::mcset ru "File \"%1\$s\" does not exist." "\u0424\u0430\u0439\u043b \"%1\$s\" \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d."
+ ::msgcat::mcset ru "File &name:" "&\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430:"
+ ::msgcat::mcset ru "File &names:" "&\u0418\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432:"
+ ::msgcat::mcset ru "Files of &type:" "&\u0422\u0438\u043f \u0444\u0430\u0439\u043b\u043e\u0432:"
+ ::msgcat::mcset ru "Fi&les:" "\u0424\u0430\u0439&\u043b\u044b:"
+ ::msgcat::mcset ru "&Filter" "&\u0424\u0438\u043b\u044c\u0442\u0440"
+ ::msgcat::mcset ru "Fil&ter:" "\u0424\u0438\u043b\u044c&\u0442\u0440:"
+ ::msgcat::mcset ru "&Green" " &\u0417\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "Hi" "\u041f\u0440\u0438\u0432\u0435\u0442"
+ ::msgcat::mcset ru "Hide Console" "\u0421\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c"
+ ::msgcat::mcset ru "&Ignore" "&\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c"
+ ::msgcat::mcset ru "Invalid file name \"%1\$s\"." "\u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \"%1\$s\"."
+ ::msgcat::mcset ru "Log Files" "\u0424\u0430\u0439\u043b\u044b \u0436\u0443\u0440\u043d\u0430\u043b\u0430"
+ ::msgcat::mcset ru "&No" "&\u041d\u0435\u0442"
+ ::msgcat::mcset ru "&OK" "&\u041e\u041a"
+ ::msgcat::mcset ru "Ok" "\u0414\u0430"
+ ::msgcat::mcset ru "Open" "\u041e\u0442\u043a\u0440\u044b\u0442\u044c"
+ ::msgcat::mcset ru "&Open" "&\u041e\u0442\u043a\u0440\u044b\u0442\u044c"
+ ::msgcat::mcset ru "Open Multiple Files" "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432"
+ ::msgcat::mcset ru "Paste" "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Quit" "\u0412\u044b\u0445\u043e\u0434"
+ ::msgcat::mcset ru "&Red" " &\u041a\u0440\u0430\u0441\u043d\u044b\u0439"
+ ::msgcat::mcset ru "Replace existing file?" "\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b?"
+ ::msgcat::mcset ru "&Retry" "&\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c"
+ ::msgcat::mcset ru "&Save" "&\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Save As" "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a"
+ ::msgcat::mcset ru "Save To Log" "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0436\u0443\u0440\u043d\u0430\u043b"
+ ::msgcat::mcset ru "Select Log File" "\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b"
+ ::msgcat::mcset ru "Select a file to source" "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438"
+ ::msgcat::mcset ru "&Selection:" "&Selection:"
+ ::msgcat::mcset ru "Skip Messages" "\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f"
+ ::msgcat::mcset ru "Source..." "\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b..."
+ ::msgcat::mcset ru "Tcl Scripts" "\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 TCL"
+ ::msgcat::mcset ru "Tcl for Windows" "TCL \u0434\u043b\u044f Windows"
+ ::msgcat::mcset ru "Text Files" "\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b"
+ ::msgcat::mcset ru "&Yes" "&\u0414\u0430"
+ ::msgcat::mcset ru "abort" "\u043e\u0442\u043c\u0435\u043d\u0430"
+ ::msgcat::mcset ru "blue" " \u0433\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "cancel" "\u043e\u0442\u043c\u0435\u043d\u0430"
+ ::msgcat::mcset ru "extension" "\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435"
+ ::msgcat::mcset ru "extensions" "\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f"
+ ::msgcat::mcset ru "green" " \u0437\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "ignore" "\u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c"
+ ::msgcat::mcset ru "ok" "\u043e\u043a"
+ ::msgcat::mcset ru "red" " \u043a\u0440\u0430\u0441\u043d\u044b\u0439"
+ ::msgcat::mcset ru "retry" "\u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c"
+ ::msgcat::mcset ru "yes" "\u0434\u0430"
+}
+
diff --git a/ext/tk/sample/multi-ip_sample.rb b/ext/tk/sample/multi-ip_sample.rb
new file mode 100644
index 0000000000..8d6e1bc626
--- /dev/null
+++ b/ext/tk/sample/multi-ip_sample.rb
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+# This script is a sample of MultiTkIp class
+
+require "multi-tk"
+
+# create slave interpreters
+trusted_slave = MultiTkIp.new_slave
+safe_slave1 = MultiTkIp.new_safeTk
+safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none, 'expand'=>false)
+#safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none)
+#safe_slave2 = MultiTkIp.new_safeTk('expand'=>false)
+
+cmd = Proc.new{|txt|
+ #####################
+ ## from TkTimer2.rb
+
+ if TkCore::INTERP.safe?
+ # safeTk doesn't have permission to call 'wm' command
+ else
+ root = TkRoot.new(:title=>'timer sample')
+ end
+
+ label = TkLabel.new(:parent=>root, :relief=>:raised, :width=>10) \
+ .pack(:side=>:bottom, :fill=>:both)
+
+ tick = proc{|aobj|
+ cnt = aobj.return_value + 5
+ label.text format("%d.%02d", *(cnt.divmod(100)))
+ cnt
+ }
+
+ timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
+
+=begin
+ TkButton.new(:text=>'Start') {
+ command proc{ timer.continue unless timer.running? }
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+ }
+ TkButton.new(:text=>'Restart') {
+ command proc{ timer.restart(0, proc{ label.text('0.00'); 0 }) }
+ pack('side'=>'right','fill'=>'both','expand'=>'yes')
+ }
+ TkButton.new(:text=>'Stop') {
+ command proc{ timer.stop if timer.running? }
+ pack('side'=>'right','fill'=>'both','expand'=>'yes')
+ }
+=end
+ b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+ }
+ b_stop = TkButton.new(:text=>'Stop', :state=>:normal) {
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+ }
+
+ b_start.command {
+ timer.continue
+ b_stop.state(:normal)
+ b_start.state(:disabled)
+ }
+
+ b_stop.command {
+ timer.stop
+ b_start.state(:normal)
+ b_stop.state(:disabled)
+ }
+
+ TkButton.new(:text=>'Reset', :state=>:normal) {
+ command { timer.reset }
+ pack('side'=>'right', 'fill'=>'both', 'expand'=>'yes')
+ }
+
+ ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
+ Tk.root.bind(ev_quit, proc{Tk.exit}).focus
+}
+
+# call on the default master interpreter
+trusted_slave.eval_proc(cmd, 'trusted') # label -> .w00012
+safe_slave1.eval_proc(cmd, 'safe1') # label -> .w00016
+safe_slave2.eval_proc(cmd, 'safe2') # label -> .w00020
+cmd.call('master') # label -> .w00024
+
+#second_master = MultiTkIp.new(&cmd)
+
+TkTimer.new(2000, -1, proc{p ['safe1', safe_slave1.deleted?]}).start
+TkTimer.new(2000, -1, proc{p ['safe2', safe_slave2.deleted?]}).start
+TkTimer.new(2000, -1, proc{p ['trusted', trusted_slave.deleted?]}).start
+
+TkTimer.new(5000, 1,
+ proc{
+ safe_slave1.eval_proc{Tk.root.destroy}
+ safe_slave1.delete
+ print "*** The safe_slave1 is deleted by the timer.\n"
+ }).start
+
+TkTimer.new(10000, 1,
+ proc{
+ trusted_slave.eval_proc{Tk.root.destroy}
+ trusted_slave.delete
+ print "*** The trusted_slave is deleted by the timer.\n"
+ }).start
+
+Tk.mainloop
diff --git a/ext/tk/sample/multi-ip_sample2.rb b/ext/tk/sample/multi-ip_sample2.rb
new file mode 100644
index 0000000000..f4a45d8d9a
--- /dev/null
+++ b/ext/tk/sample/multi-ip_sample2.rb
@@ -0,0 +1,29 @@
+require 'multi-tk.rb'
+
+th = Thread.new{Tk.mainloop}
+
+TkLabel.new(:text=>'this is a primary master').pack
+
+ip1 = MultiTkIp.new_slave(:safe=>1)
+ip2 = MultiTkIp.new_slave(:safe=>2)
+
+cmd = proc{|s|
+ require 'tk'
+
+ TkButton.new(:text=>'b1: p self', :command=>proc{p self}).pack(:fill=>:x)
+ sleep s
+ TkButton.new(:text=>'b2: p $SAFE', :command=>proc{p $SAFE}).pack(:fill=>:x)
+ sleep s
+ TkButton.new(:text=>'b3: p MultiTkIp.ip_name',
+ :command=>proc{p MultiTkIp.ip_name}).pack(:fill=>:x)
+ sleep s
+ TkButton.new(:text=>'EXIT', :command=>proc{exit}).pack(:fill=>:x)
+
+ Tk.mainloop
+}
+
+Thread.new{ip1.eval_proc(cmd, 1.1)}
+Thread.new{ip2.eval_proc(cmd, 0.3)}
+cmd.call(0.7)
+
+th.join
diff --git a/ext/tk/sample/optobj_sample.rb b/ext/tk/sample/optobj_sample.rb
new file mode 100644
index 0000000000..cafacbdd17
--- /dev/null
+++ b/ext/tk/sample/optobj_sample.rb
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+#
+# sample script of Tk::OptionObj
+#
+require "tk"
+
+optobj = Tk::OptionObj.new('foreground'=>'red', 'background'=>'black')
+
+f = TkFrame.new.pack(:side=>:left, :anchor=>:n, :padx=>5, :pady=>30)
+
+b1 = TkButton.new(f, :text=>'AAA').pack(:fill=>:x)
+b2 = TkButton.new(f, :text=>'BBB').pack(:fill=>:x)
+b3 = TkButton.new(f, :text=>'CCC').pack(:fill=>:x)
+
+optobj.assign( b1,
+ [ b2, 'configure',
+ { 'foreground'=>'background',
+ 'background'=>'foreground' } ],
+ [ b3, nil,
+ { 'foreground'=>'background',
+ 'activeforeground'=>nil,
+ 'background'=>['foreground', 'activeforeground'] } ] )
+
+optobj.update('activeforeground'=>'yellow')
+
+TkButton.new(f){
+ configure( optobj.assign(self) + {:text=>'DDD'} )
+ pack(:fill=>:x)
+}
+
+TkButton.new(f){
+ configure( optobj.assign([self, nil,
+ {'foreground'=>'activeforeground',
+ 'background'=>'foreground',
+ 'activeforeground'=>'background'}]) \
+ + {:text=>'EEE', :relief=>:groove, :borderwidth=>5} )
+ pack(:fill=>:x)
+}
+
+optobj.notify # To apply the convert_key ( 3rd element of widget info
+ # (that is, {'foreground'=>'activeforeground', ,,, } )
+ # of the 'EEE' button
+
+TkButton.new(f, :text=>'toggle',
+ :command=>proc{
+ fg = optobj['foreground']
+ bg = optobj['background']
+ optobj.configure('foreground'=>bg, 'background'=>fg)
+ }).pack(:fill=>:x, :pady=>10)
+
+TkButton.new(f, :text=>'exit',
+ :command=>proc{exit}).pack(:fill=>:x, :pady=>10)
+
+TkFrame.new{|f|
+ pack(:side=>:right, :expand=>true, :fill=>:both)
+ TkLabel.new(f, :text=>'source::').pack(:anchor=>:w)
+ TkFrame.new(f){|ff|
+ TkText.new(ff){
+ yscrollbar(TkScrollbar.new(ff){pack(:fill=>:y, :side=>:right)})
+ insert('end', File.read(__FILE__))
+ pack(:side=>:left, :expand=>true, :fill=>:both)
+ }
+ pack(:expand=>true, :fill=>:both)
+ }
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/propagate.rb b/ext/tk/sample/propagate.rb
new file mode 100644
index 0000000000..800cef553d
--- /dev/null
+++ b/ext/tk/sample/propagate.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+TkLabel.new(:text=>"Please click the bottom frame").pack
+
+f = TkFrame.new(:width=>400, :height=>100, :background=>'yellow',
+ :relief=>'ridge', :borderwidth=>5).pack
+
+# TkPack.propagate(f, false) # <== important!!
+f.pack_propagate(false) # <== important!!
+
+list = (1..3).collect{|n|
+ TkButton.new(f, :text=>"button#{'-X'*n}"){
+ command proc{
+ puts "button#{'-X'*n}"
+ self.unpack
+ }
+ }
+}
+
+list.unshift(nil)
+
+f.bind('1', proc{
+ w = list.shift
+ w.unpack if w
+ list.push(w)
+ list[0].pack(:expand=>true, :anchor=>:center) if list[0]
+ })
+
+Tk.mainloop
diff --git a/ext/tk/sample/remote-ip_sample.rb b/ext/tk/sample/remote-ip_sample.rb
new file mode 100644
index 0000000000..3696a20852
--- /dev/null
+++ b/ext/tk/sample/remote-ip_sample.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require 'remote-tk'
+
+puts <<EOM
+This sample controls the other Tk interpreter (Ruby/Tk, Tcl/Tk, and so on)
+which running on the other process. For this purpose, Ruby/Tk uses Tcl/Tk's
+'send' command. Availability of the command depends on your GUI environment.
+If this script doesn't work, please check your environment (see Tcl/Tk FAQ).
+EOM
+#'
+
+unless (wish = TkWinfo.interps.find{|ip| ip =~ /^wish/})
+ puts ''
+ puts 'Please start "wish" (Tcl/Tk shell) before running this sample script.'
+ exit 1
+end
+
+ip = RemoteTkIp.new(wish)
+ip.eval_proc{TkButton.new(:command=>proc{puts 'This procesure is on the controller-ip (Ruby/Tk)'}, :text=>'print on Ruby/Tk (controller-ip)').pack(:fill=>:x)}
+ip.eval_proc{TkButton.new(:command=>'puts {This procesure is on the remote-ip (wish)}', :text=>'print on wish (remote-ip)').pack(:fill=>:x)}
+
+# If your remote-ip is Ruby/Tk, you can control the remote Ruby by
+# 'ruby' or 'ruby_eval' or 'ruby_cmd' on the Tk interpreter.
+if ip.is_rubytk?
+ ip.eval_proc{TkButton.new(:command=>'ruby {p 111; p Array.new(3,"ruby")}', :text=>'ruby cmd on the remote-ip').pack(:fill=>:x)}
+end
+
+ip.eval_proc{TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x)}
+
+TkButton.new(:command=>proc{exit}, :text=>'QUIT',
+ :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7)
+
+Tk.mainloop
diff --git a/ext/tk/sample/remote-ip_sample2.rb b/ext/tk/sample/remote-ip_sample2.rb
new file mode 100644
index 0000000000..e12b2a96c9
--- /dev/null
+++ b/ext/tk/sample/remote-ip_sample2.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+
+require 'remote-tk'
+
+# start sub-process
+ip_name = 'remote_ip'
+ip_list = TkWinfo.interps
+fork{
+ exec "/usr/bin/env ruby -r tk -e \"Tk.appname('#{ip_name}');Tk.mainloop\""
+}
+sleep 1 until (app = (TkWinfo.interps - ip_list)[0]) && app =~ /^#{ip_name}/
+p TkWinfo.interps
+
+# create RemoteTkIp object
+ip = RemoteTkIp.new(app)
+
+# setup remote-ip window
+btns = []
+ip.eval_proc{
+ btns <<
+ TkButton.new(:command=>proc{
+ puts 'This procesure is on the controller-ip (Ruby-side)'
+ },
+ :text=>'print on controller-ip (Ruby-side)').pack(:fill=>:x)
+
+ btns <<
+ TkButton.new(:command=>
+ 'puts {This procesure is on the remote-ip (Tk-side)}',
+ :text=>'print on remote-ip (Tk-side)').pack(:fill=>:x)
+
+ btns <<
+ TkButton.new(:command=>
+ 'ruby {
+ puts "This procedure is on the remote-ip (Ruby-side)"
+ p Array.new(3,"ruby")
+ }',
+ :text=>'ruby cmd on the remote-ip').pack(:fill=>:x)
+
+ TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x)
+}
+
+# setup controller-ip window
+btns.each_with_index{|btn, idx|
+ # The scope of the eval-block of 'eval_proc' method is different from
+ # the enternal. If you want to pass local values to the eval-block,
+ # use arguments of eval_proc method. They are passed to block-arguments.
+ TkButton.new(:command=>proc{ip.eval_proc(btn){|b| b.flash}},
+ :text=>"flash button-#{idx}",
+ :padx=>10).pack(:padx=>10, :pady=>2)
+}
+
+TkButton.new(:command=>proc{exit}, :text=>'QUIT',
+ :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7)
+
+# start eventloop
+Tk.mainloop
diff --git a/ext/tk/sample/resource.en b/ext/tk/sample/resource.en
new file mode 100644
index 0000000000..39b4013971
--- /dev/null
+++ b/ext/tk/sample/resource.en
@@ -0,0 +1,13 @@
+!
+! see Tcl/Tk's "options" manual for "Database Name" and "Database Class"
+!
+*BtnFrame.borderWidth: 5
+*BtnFrame.relief: ridge
+*BtnFrame.Button.background: wheat
+*BtnFrame.Button.foreground: red
+*hello.text: HELLO
+*quit.text: QUIT
+*BTN_CMD.show_msg: {|arg| print "($SAFE=#{$SAFE}) ";\
+ print "Hello!! This is a sample of #{arg}.";\
+ print "(<<< $SAFE=#{$SAFE})\n"}
+*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE} >>>) Good-bye¡¥(<<< $SAFE=#{$SAFE})\n"}
diff --git a/ext/tk/sample/resource.ja b/ext/tk/sample/resource.ja
new file mode 100644
index 0000000000..a61390f95d
--- /dev/null
+++ b/ext/tk/sample/resource.ja
@@ -0,0 +1,13 @@
+!
+! see Tcl/Tk's "options" manual for "Database Name" and "Database Class"
+!
+*BtnFrame.borderWidth: 5
+*BtnFrame.relief: ridge
+*BtnFrame.Button.background: wheat
+*BtnFrame.Button.foreground: red
+*hello.text: ¤³¤ó¤Ë¤Á¤Ï
+*quit.text: ½ªÎ»
+*BTN_CMD.show_msg: {|arg| print "($SAFE=#{$SAFE} >>>) ";\
+ print "¤³¤ó¤Ë¤Á¤Ï¡ª¡ª #{arg} ¤Î¥µ¥ó¥×¥ë¤Ç¤¹¡¥";\
+ print "(<<< $SAFE=#{$SAFE})\n"}
+*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE} >>>) ¤µ¤è¤¦¤Ê¤é¡¥(<<< $SAFE=#{$SAFE})\n"}
diff --git a/ext/tk/sample/safe-tk.rb b/ext/tk/sample/safe-tk.rb
new file mode 100644
index 0000000000..e2289697e0
--- /dev/null
+++ b/ext/tk/sample/safe-tk.rb
@@ -0,0 +1,115 @@
+#!/usr/bin/env ruby
+# This script is a sample of MultiTkIp class
+
+require "multi-tk"
+
+###############################
+
+TkLabel.new(:text=>'This is the Default Master Ipnterpreter').pack(:padx=>5, :pady=>3)
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack(:pady=>3)
+TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+
+###############################
+
+puts "---- create a safe slave IP with Ruby's safe-level == 1 ----------"
+ip = MultiTkIp.new_safe_slave(1)
+
+puts "\n---- create procs ----------"
+puts 'x = proc{p [\'proc x\', "$SAFE==#{$SAFE}"]; exit}'
+x = proc{p ['proc x', "$SAFE==#{$SAFE}"]; exit}
+TkLabel.new(:text=>'x = proc{p [\'proc x\', "$SAFE==#{$SAFE}"]; exit}',
+ :anchor=>:w).pack(:fill=>:x)
+
+puts 'y = proc{|label| p [\'proc y\', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}'
+y = proc{|label| p ['proc y', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}
+TkLabel.new(:text=>'y = proc{|label| p [\'proc y\', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}',
+ :anchor=>:w).pack(:fill=>:x)
+
+puts 'z = proc{p [\'proc z\', "$SAFE==#{$SAFE}"]; exit}'
+z = proc{p ['proc z', "$SAFE==#{$SAFE}"]; exit}
+TkLabel.new(:text=>'z = proc{p [\'proc z\', "$SAFE==#{$SAFE}"]; exit}',
+ :anchor=>:w).pack(:fill=>:x)
+
+puts "\n---- call 1st eval_proc ----------"
+print 'lbl = '
+p lbl = ip.eval_proc{
+ TkLabel.new(:text=>"1st eval_proc : $SAFE == #{$SAFE}").pack
+
+ f = TkFrame.new.pack
+ TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left)
+ # TkLabel.new(f, :text=>" (<-- 'lbl' widget is here)").pack(:side=>:right)
+ l = TkLabel.new(f).pack(:side=>:right)
+
+ TkButton.new(:text=>':command=>proc{l.text($SAFE)}',
+ :command=>proc{l.text($SAFE)}).pack(:fill=>:x, :padx=>5)
+ TkButton.new(:text=>':command=>x', :command=>x).pack(:fill=>:x, :padx=>5)
+ TkButton.new(:text=>':command=>proc{exit}',
+ :command=>proc{exit}).pack(:fill=>:x, :padx=>5)
+ TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+ l # return the label widget
+}
+
+puts "\n---- change the safe slave IP's safe-level ==> 3 ----------"
+ip.safe_level = 3
+
+puts "\n---- call 2nd eval_proc ----------"
+p ip.eval_proc(proc{
+ TkLabel.new(:text=>"2nd eval_proc : $SAFE == #{$SAFE}").pack
+ f = TkFrame.new.pack
+ TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left)
+ l = TkLabel.new(f, :text=>$SAFE).pack(:side=>:right)
+ TkButton.new(:text=>':command=>proc{l.text($SAFE)}',
+ :command=>proc{l.text($SAFE)}).pack(:fill=>:x,
+ :padx=>5)
+ TkButton.new(:text=>':command=>proc{y.call(l)}',
+ :command=>proc{y.call(l)}).pack(:fill=>:x,
+ :padx=>5)
+ TkButton.new(:text=>':command=>proc{Thread.new(l, &y).value}',
+ :command=>proc{
+ Thread.new(l, &y).value
+ }).pack(:fill=>:x, :padx=>5)
+ TkButton.new(:text=>':command=>proc{z.call}',
+ :command=>proc{z.call}).pack(:fill=>:x, :padx=>5)
+ TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+ })
+
+puts "\n---- call 1st and 2nd eval_str ----------"
+p bind = ip.eval_str('
+ TkLabel.new(:text=>"1st and 2nd eval_str : $SAFE == #{$SAFE}").pack
+ f = TkFrame.new.pack
+ TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left)
+ l = TkLabel.new(f, :text=>$SAFE).pack(:side=>:right)
+ TkButton.new(:text=>":command=>proc{y.call(l)}",
+ :command=>proc{y.call(l)}).pack(:fill=>:x, :padx=>5)
+ binding
+', binding)
+
+p ip.eval_str("
+ TkButton.new(:text=>':command=>proc{ l.text = $SAFE }',
+ :command=>proc{ l.text = $SAFE }).pack(:fill=>:x, :padx=>5)
+ TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+", bind)
+
+puts "\n---- change the safe slave IP's safe-level ==> 4 ----------"
+ip.safe_level = 4
+
+puts "\n---- call 3rd and 4th eval_proc ----------"
+p ip.eval_proc{
+ TkLabel.new(:text=>"3rd and 4th eval_proc : $SAFE == #{$SAFE}").pack
+}
+p ip.eval_proc{
+ TkButton.new(:text=>':command=>proc{ lbl.text = $SAFE }',
+ :command=>proc{ lbl.text = $SAFE }).pack(:fill=>:x, :padx=>5)
+}
+
+puts "\n---- start event-loop ( current $SAFE == #{$SAFE} ) ----------"
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkalignbox.rb b/ext/tk/sample/tkalignbox.rb
new file mode 100644
index 0000000000..32915a5e69
--- /dev/null
+++ b/ext/tk/sample/tkalignbox.rb
@@ -0,0 +1,225 @@
+#
+# tkalignbox.rb : align widgets with same width/height
+#
+# by Hidetoshi NAGAI
+#
+# The box size depends on 'reqheight' and 'reqwidth' of contained widgets.
+# If you want to give the box size when those requested sizes are 0,
+# please set box.propagate = false (See the test routine at the tail of
+# this file).
+
+require 'tk'
+
+class TkAlignBox < TkFrame
+ def initialize(*args)
+ if self.class == TkAlignBox
+ fail RuntimeError, "TkAlignBox is an abstract class"
+ end
+ @padx = 0
+ @pady = 0
+ if args[-1].kind_of? Hash
+ keys = _symbolkey2str(args.pop)
+ @padx = keys.delete('padx') || 0
+ @pady = keys.delete('pady') || 0
+ args.push(keys)
+ end
+ super(*args)
+ @max_width = 0
+ @max_height = 0
+ @propagate = true
+ @widgets = []
+ end
+
+ def _set_framesize
+ fail RuntimeError, "TkAlignBox is an abstract class"
+ end
+ private :_set_framesize
+
+ def _place_config(widget, idx, cnt)
+ fail RuntimeError, "TkAlignBox is an abstract class"
+ end
+ private :_place_config
+
+ def align
+ widgets = []
+ @widgets.each{|w| widgets << w if w.winfo_exist?}
+ @widgets = widgets
+ cnt = @widgets.size.to_f
+ @widgets.each_with_index{|w, idx| _place_config(w, idx, cnt)}
+ @widgets = widgets
+ _set_framesize if @propagate
+ self
+ end
+
+ def add(*widgets)
+ widgets.each{|w|
+ unless w.kind_of? TkWindow
+ fail RuntimeError, "#{w.inspect} is not a widget instance."
+ end
+ @widgets.delete(w)
+ @widgets << w
+ sz = w.winfo_reqwidth
+ @max_width = sz if @max_width < sz
+ sz = w.winfo_reqheight
+ @max_height = sz if @max_height < sz
+ }
+ align
+ end
+
+ def <<(widget)
+ add(widget)
+ end
+
+ def insert(idx, widget)
+ unless widget.kind_of? TkWindow
+ fail RuntimeError, "#{widget.inspect} is not a widget instance."
+ end
+ @widgets.delete(widget)
+ @widgets[idx,0] = widget
+ sz = widget.winfo_reqwidth
+ @max_width = sz if @max_width < sz
+ sz = widget.winfo_reqheight
+ @max_height = sz if @max_height < sz
+ align
+ end
+
+ def delete(idx)
+ ret = @widgets.delete_at(idx)
+ @req_size = 0
+ @widget.each{|w|
+ sz = w.winfo_reqwidth
+ @max_width = sz if @max_width < sz
+ sz = w.winfo_reqheight
+ @max_height = sz if @max_height < sz
+ }
+ align
+ ret
+ end
+
+ def padx(size = nil)
+ if size
+ @padx = size
+ align
+ else
+ @padx
+ end
+ end
+
+ def pady(size = nil)
+ if size
+ @pady = size
+ align
+ else
+ @pady
+ end
+ end
+
+ attr_accessor :propagate
+end
+
+class TkHBox < TkAlignBox
+ def _set_framesize
+ bd = self.borderwidth
+ self.width((@max_width + 2*@padx) * @widgets.size + 2*bd)
+ self.height(@max_height + 2*@pady + 2*bd)
+ end
+ private :_set_framesize
+
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>idx/cnt, 'x'=>@padx,
+ 'rely'=>0, 'y'=>@pady,
+ 'relwidth'=>1.0/cnt, 'width'=>-2*@padx,
+ 'relheight'=>1.0, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+TkHLBox = TkHBox
+
+class TkHRBox < TkHBox
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>(cnt - idx - 1)/cnt, 'x'=>@padx,
+ 'rely'=>0, 'y'=>@pady,
+ 'relwidth'=>1.0/cnt, 'width'=>-2*@padx,
+ 'relheight'=>1.0, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+
+class TkVBox < TkAlignBox
+ def _set_framesize
+ bd = self.borderwidth
+ self.width(@max_width + 2*@padx + 2*bd)
+ self.height((@max_height + 2*@pady) * @widgets.size + 2*bd)
+ end
+ private :_set_framesize
+
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>0, 'x'=>@padx,
+ 'rely'=>idx/cnt, 'y'=>@pady,
+ 'relwidth'=>1.0, 'width'=>-2*@padx,
+ 'relheight'=>1.0/cnt, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+TkVTBox = TkVBox
+
+class TkVBBox < TkVBox
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>0, 'x'=>@padx,
+ 'rely'=>(cnt - idx - 1)/cnt, 'y'=>@pady,
+ 'relwidth'=>1.0, 'width'=>-2*@padx,
+ 'relheight'=>1.0/cnt, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ f = TkHBox.new(:borderwidth=>3, :relief=>'ridge').pack
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'),
+ TkButton.new(f, :text=>'aaa'),
+ TkButton.new(f, :text=>'aaaa'))
+
+ f = TkHBox.new(:borderwidth=>3, :relief=>'ridge',
+ :padx=>7, :pady=>3, :background=>'yellow').pack
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'),
+ TkButton.new(f, :text=>'aaa'),
+ TkButton.new(f, :text=>'aaaa'))
+
+ f = TkVBox.new(:borderwidth=>5, :relief=>'groove').pack
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa', :font=>'Helvetica 30'),
+ TkButton.new(f, :text=>'aaa'),
+ TkButton.new(f, :text=>'aaaa'))
+
+ f = TkHRBox.new(:borderwidth=>3, :relief=>'raised').pack(:fill=>:x)
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa'),
+ TkButton.new(f, :text=>'aaa'))
+
+ f = TkVBBox.new(:borderwidth=>3, :relief=>'ridge').pack(:fill=>:x)
+ f.propagate = false
+ f.height 100
+ f.add(TkFrame.new(f){|ff|
+ TkButton.new(ff, :text=>'a').pack(:pady=>4, :padx=>6,
+ :fill=>:both, :expand=>true)
+ },
+ TkFrame.new(f){|ff|
+ TkButton.new(ff, :text=>'aa').pack(:pady=>4, :padx=>6,
+ :fill=>:both, :expand=>true)
+ },
+ TkFrame.new(f){|ff|
+ TkButton.new(ff, :text=>'aaaa').pack(:pady=>4, :padx=>6,
+ :fill=>:both, :expand=>true)
+ })
+
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tkballoonhelp.rb b/ext/tk/sample/tkballoonhelp.rb
new file mode 100644
index 0000000000..d66bc35a88
--- /dev/null
+++ b/ext/tk/sample/tkballoonhelp.rb
@@ -0,0 +1,99 @@
+#
+# tkballoonhelp.rb : simple balloon help widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# Add a balloon help to a widget.
+# This widget has only poor featureas. If you need more useful features,
+# please try to use the Tix extension of Tcl/Tk under Ruby/Tk.
+#
+# The interval time to display a balloon help is defined 'interval' option
+# (default is 1000ms).
+#
+require 'tk'
+
+class TkBalloonHelp<TkLabel
+ def _balloon_binding(interval)
+ @timer = TkAfter.new(interval, 1, proc{show})
+ def @timer.interval(val)
+ @sleep_time = val
+ end
+ @bindtag = TkBindTag.new
+ @bindtag.bind('Enter', proc{@timer.start})
+ @bindtag.bind('Motion', proc{@timer.restart; erase})
+ @bindtag.bind('Any-ButtonPress', proc{@timer.restart; erase})
+ @bindtag.bind('Leave', proc{@timer.stop; erase})
+ tags = @parent.bindtags
+ idx = tags.index(@parent)
+ tags[idx,0] = @bindtag
+ @parent.bindtags(tags)
+ end
+ private :_balloon_binding
+
+ def initialize(parent=nil, keys={})
+ @parent = parent
+
+ @frame = TkToplevel.new(@parent)
+ @frame.withdraw
+ @frame.overrideredirect(true)
+ @frame.transient(TkWinfo.toplevel(@parent))
+ @epath = @frame.path
+
+ keys = {} unless keys
+
+ @interval = keys.delete('interval'){1000}
+ _balloon_binding(@interval)
+
+ @label = TkLabel.new(@frame, 'background'=>'bisque').pack
+ @label.configure(_symbolkey2str(keys)) unless keys.empty?
+ @path = @label
+ end
+
+ def epath
+ @epath
+ end
+
+ def interval(val)
+ if val
+ @timer.interval(val)
+ else
+ @interval
+ end
+ end
+
+ def show
+ x = TkWinfo.pointerx(@parent)
+ y = TkWinfo.pointery(@parent)
+ @frame.geometry("+#{x+1}+#{y+1}")
+ @frame.deiconify
+ @frame.raise
+
+ @org_cursor = @parent['cursor']
+ @parent.cursor('crosshair')
+ end
+
+ def erase
+ @parent.cursor(@org_cursor)
+ @frame.withdraw
+ end
+
+ def destroy
+ @frame.destroy
+ end
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ TkButton.new('text'=>'This button has a balloon help') {|b|
+ pack('fill'=>'x')
+ TkBalloonHelp.new(b, 'text'=>' Message ')
+ }
+ TkButton.new('text'=>'This button has another balloon help') {|b|
+ pack('fill'=>'x')
+ TkBalloonHelp.new(b, 'text'=>'configured message',
+ 'interval'=>200, 'font'=>'courier',
+ 'background'=>'gray', 'foreground'=>'red')
+ }
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tkbiff.rb b/ext/tk/sample/tkbiff.rb
index d2d7bf7beb..c6699629cc 100644
--- a/ext/tk/sample/tkbiff.rb
+++ b/ext/tk/sample/tkbiff.rb
@@ -1,4 +1,4 @@
-#! /usr/local/bin/ruby
+#!/usr/bin/env ruby
if ARGV[0] != '-d'
unless $DEBUG
@@ -12,7 +12,7 @@ if ARGV.length == 0
if ENV['MAIL']
$spool = ENV['MAIL']
else
- $spool = '/usr/spool/mail/' + ENV['USER']
+ $spool = '/var/spool/mail/' + ENV['USER']
end
else
$spool = ARGV[0]
@@ -38,22 +38,22 @@ class Mail
def initialize(f)
@header = {}
@body = []
- while f.gets()
- $_.chop!
- next if /^From / # skip From-line
- break if /^$/ # end of header
- if /^(\S+):\s*(.*)/
- @header[attr = $1.capitalize] = $2
+ while line = f.gets()
+ line.chop!
+ next if /^From / =~ line # skip From-line
+ break if /^$/ =~ line # end of header
+ if /^(\S+):\s*(.*)/ =~ line
+ @header[attr = $1.capitalize] = $2
elsif attr
- sub(/^\s*/, '')
- @header[attr] += "\n" + $_
+ sub(/^\s*/, '')
+ @header[attr] += "\n" + $_
end
end
- return if ! $_
+ return unless $_
- while f.gets()
- break if /^From /
+ while line = f.gets()
+ break if /^From / =~ line
@body.push($_)
end
end
@@ -70,7 +70,13 @@ end
require "tkscrollbox"
+my_appname = Tk.appname('tkbiff')
$top = TkRoot.new
+if ((TkWinfo.interps($top) - [my_appname]).find{|ip| ip =~ /^tkbiff/})
+ STDERR.print("Probably other 'tkbiff's are running. Bye.\n")
+ exit
+end
+
$top.withdraw
$list = TkScrollbox.new($top) {
relief 'raised'
@@ -106,7 +112,7 @@ if defined? Thread
loop do
sleep 600
if Time.now - $check_time > 200
- Tk.after 5000, proc{check}
+ Tk.after 5000, proc{check}
end
end
end
@@ -136,12 +142,12 @@ def pop_up
$list.see 'end'
end
$top.deiconify
- Tk.after 2000, proc{$top.withdraw}
+ Tk.after 2000, proc{$top.iconify}
end
$list.insert 'end', "You have no mail."
check
-Tk.after 2000, proc{$top.withdraw}
+Tk.after 2000, proc{$top.iconify}
begin
Tk.mainloop
rescue
diff --git a/ext/tk/sample/tkbrowse.rb b/ext/tk/sample/tkbrowse.rb
index 882f0a489b..4893f57f95 100644
--- a/ext/tk/sample/tkbrowse.rb
+++ b/ext/tk/sample/tkbrowse.rb
@@ -1,4 +1,4 @@
-#!/usr/local/bin/ruby
+#!/usr/bin/env ruby
#
# This script generates a directory browser, which lists the working
# directory and allows you to open files or subdirectories by
@@ -41,8 +41,8 @@ def browsedir (dir)
list.bind "Double-Button-1", proc{
for i in TkSelection.get.split
- print "clicked ", i, "\n"
- browse dir, i
+ print "clicked ", i, "\n"
+ browse dir, i
end
}
$dirlist[dir] = list
@@ -56,9 +56,9 @@ def browse (dir, file)
else
if File.file? file
if ENV['EDITOR']
- system format("%s %s&", ENV['EDITOR'], file)
+ system format("%s %s&", ENV['EDITOR'], file)
else
- system "xedit #{file}&"
+ system "xedit #{file}&"
end
else
STDERR.print "\"#{file}\" isn't a directory or regular file"
diff --git a/ext/tk/sample/tkcombobox.rb b/ext/tk/sample/tkcombobox.rb
new file mode 100644
index 0000000000..1840270951
--- /dev/null
+++ b/ext/tk/sample/tkcombobox.rb
@@ -0,0 +1,426 @@
+#
+# tkcombobox.rb : TkAutoScrollbox & TkCombobox
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkAutoScrollbox < TkListbox
+ include TkComposite
+
+ @@up_bmp = TkBitmapImage.new(:data=><<EOD)
+#define up_arrow_width 9
+#define up_arrow_height 9
+static unsigned char up_arrow_bits[] = {
+ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x38, 0x00, 0x38, 0x00, 0x7c, 0x00,
+ 0x7c, 0x00, 0xfe, 0x00, 0x00, 0x00};
+EOD
+
+ @@down_bmp = TkBitmapImage.new(:data=><<EOD)
+#define up_arrow_width 9
+#define up_arrow_height 9
+static unsigned char down_arrow_bits[] = {
+ 0x00, 0x00, 0xfe, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x38, 0x00,
+ 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
+EOD
+
+ ############################
+ private
+ ############################
+ def initialize_composite(keys={})
+ keys = _symbolkey2str(keys)
+
+ @initwait = keys.delete('startwait'){300}
+ @interval = keys.delete('interval'){150}
+ @initwait -= @interval
+ @initwait = 0 if @initwait < 0
+
+ @lbox = TkListbox.new(@frame, :borderwidth=>0)
+ @path = @lbox.path
+ TkPack.propagate(@lbox, false)
+
+ @scr = TkScrollbar.new(@frame, :width=>10)
+
+ @lbox.yscrollcommand(proc{|*args| @scr.set(*args); _config_proc})
+ @scr.command(proc{|*args| @lbox.yview(*args); _config_proc})
+
+ @up_arrow = TkLabel.new(@lbox, :image=>@@up_bmp,
+ :relief=>:raised, :borderwidth=>1)
+ @down_arrow = TkLabel.new(@lbox, :image=>@@down_bmp,
+ :relief=>:raised, :borderwidth=>1)
+
+ _init_binding
+
+ @lbox.pack(:side=>:left, :fill=>:both, :expand=>:true)
+
+ delegate('DEFAULT', @lbox)
+ delegate('background', @frame, @scr)
+ delegate('activebackground', @scr)
+ delegate('troughcolor', @scr)
+ delegate('repeatdelay', @scr)
+ delegate('repeatinterval', @scr)
+ delegate('relief', @frame)
+ delegate('borderwidth', @frame)
+
+ delegate_alias('arrowrelief', 'relief', @up_arrow, @down_arrow)
+ delegate_alias('arrowborderwidth', 'borderwidth', @up_arrow, @down_arrow)
+
+ scrollbar(keys.delete('scrollbar')){false}
+
+ configure keys unless keys.empty?
+ end
+
+ def _show_up_arrow
+ unless @up_arrow.winfo_mapped?
+ @up_arrow.pack(:side=>:top, :fill=>:x)
+ end
+ end
+
+ def _show_down_arrow
+ unless @down_arrow.winfo_mapped?
+ @down_arrow.pack(:side=>:bottom, :fill=>:x)
+ end
+ end
+
+ def _set_sel(idx)
+ @lbox.activate(idx)
+ @lbox.selection_clear(0, 'end')
+ @lbox.selection_set(idx)
+ end
+
+ def _check_sel(cidx, tidx = nil, bidx = nil)
+ _set_sel(cidx)
+ unless tidx
+ tidx = @lbox.nearest(0)
+ tidx += 1 if tidx > 0
+ end
+ unless bidx
+ bidx = @lbox.nearest(10000)
+ bidx -= 1 if bidx < @lbox.index('end') - 1
+ end
+ if cidx > bidx
+ _set_sel(bidx)
+ end
+ if cidx < tidx
+ _set_sel(tidx)
+ end
+ end
+
+ def _up_proc
+ cidx = @lbox.curselection[0]
+ idx = @lbox.nearest(0)
+ if idx >= 0
+ @lbox.see(idx - 1)
+ _set_sel(idx)
+ @up_arrow.pack_forget if idx == 1
+ @up_timer.stop if idx == 0
+ _show_down_arrow if @lbox.bbox('end') == []
+ end
+ if cidx && cidx > 0 && (idx == 0 || cidx == @lbox.nearest(10000))
+ _set_sel(cidx - 1)
+ end
+ end
+
+ def _down_proc
+ cidx = @lbox.curselection[0]
+ eidx = @lbox.index('end') - 1
+ idx = @lbox.nearest(10000)
+ if idx <= eidx
+ @lbox.see(idx + 1)
+ _set_sel(cidx + 1) if cidx < eidx
+ @down_arrow.pack_forget if idx + 1 == eidx
+ @down_timer.stop if idx == eidx
+ _show_up_arrow if @lbox.bbox(0) == []
+ end
+ if cidx && cidx < eidx && (eidx == idx || cidx == @lbox.nearest(0))
+ _set_sel(cidx + 1)
+ end
+ end
+
+ def _key_UP_proc
+ cidx = @lbox.curselection[0]
+ _set_sel(cidx = @lbox.index('activate')) unless cidx
+ cidx -= 1
+ if cidx == 0
+ @up_arrow.pack_forget
+ elsif cidx == @lbox.nearest(0)
+ @lbox.see(cidx - 1)
+ end
+ end
+
+ def _key_DOWN_proc
+ cidx = @lbox.curselection[0]
+ _set_sel(cidx = @lbox.index('activate')) unless cidx
+ cidx += 1
+ if cidx == @lbox.index('end') - 1
+ @down_arrow.pack_forget
+ elsif cidx == @lbox.nearest(10000)
+ @lbox.see(cidx + 1)
+ end
+ end
+
+ def _config_proc
+ if @lbox.size == 0
+ @up_arrow.pack_forget
+ @down_arrow.pack_forget
+ return
+ end
+ tidx = @lbox.nearest(0)
+ bidx = @lbox.nearest(10000)
+ if tidx > 0
+ _show_up_arrow
+ tidx += 1
+ else
+ @up_arrow.pack_forget unless @up_timer.running?
+ end
+ if bidx < @lbox.index('end') - 1
+ _show_down_arrow
+ bidx -= 1
+ else
+ @down_arrow.pack_forget unless @down_timer.running?
+ end
+ cidx = @lbox.curselection[0]
+ _check_sel(cidx, tidx, bidx) if cidx
+ end
+
+ def _init_binding
+ @up_timer = TkAfter.new(@interval, -1, proc{_up_proc})
+ @down_timer = TkAfter.new(@interval, -1, proc{_down_proc})
+
+ @up_timer.set_start_proc(@initwait, proc{})
+ @down_timer.set_start_proc(@initwait, proc{})
+
+ @up_arrow.bind('Enter', proc{@up_timer.start})
+ @up_arrow.bind('Leave', proc{@up_timer.stop if @up_arrow.winfo_mapped?})
+ @down_arrow.bind('Enter', proc{@down_timer.start})
+ @down_arrow.bind('Leave', proc{@down_timer.stop if @down_arrow.winfo_mapped?})
+
+ @lbox.bind('Configure', proc{_config_proc})
+ @lbox.bind('Enter', proc{|y| _set_sel(@lbox.nearest(y))}, '%y')
+ @lbox.bind('Motion', proc{|y|
+ @up_timer.stop if @up_timer.running?
+ @down_timer.stop if @down_timer.running?
+ _check_sel(@lbox.nearest(y))
+ }, '%y')
+
+ @lbox.bind('Up', proc{_key_UP_proc})
+ @lbox.bind('Down', proc{_key_DOWN_proc})
+ end
+
+ ############################
+ public
+ ############################
+ def scrollbar(mode)
+ if mode
+ @scr.pack(:side=>:right, :fill=>:y)
+ else
+ @scr.pack_forget
+ end
+ end
+end
+
+################################################
+
+class TkCombobox < TkEntry
+ include TkComposite
+
+ @@down_btn_bmp = TkBitmapImage.new(:data=><<EOD)
+#define down_arrow_width 11
+#define down_arrow_height 11
+static unsigned char down_arrow_bits[] = {
+ 0x00, 0x00, 0xfe, 0x03, 0xfc, 0x01, 0xfc, 0x01, 0xf8, 0x00, 0xf8, 0x00,
+ 0x70, 0x00, 0x70, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00};
+EOD
+
+ @@up_btn_bmp = TkBitmapImage.new(:data=><<EOD)
+#define up_arrow_width 11
+#define up_arrow_height 11
+static unsigned char up_arrow_bits[] = {
+ 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x70, 0x00, 0x70, 0x00, 0xf8, 0x00,
+ 0xf8, 0x00, 0xfc, 0x01, 0xfc, 0x01, 0xfe, 0x03, 0x00, 0x00};
+EOD
+
+ def _button_proc(dir = true)
+ @btn.relief(:sunken)
+ x = @frame.winfo_rootx
+ y = @frame.winfo_rooty
+ if dir
+ @top.geometry("+#{x}+#{y + @frame.winfo_height}")
+ else
+ @btn.image(@@up_btn_bmp)
+ @top.geometry("+#{x}+#{y - @top.winfo_reqheight}")
+ end
+ @top.deiconify
+ @lst.focus
+
+ if (idx = values.index(@ent.value))
+ @lst.see(idx - 1)
+ @lst.activate(idx)
+ @lst.selection_set(idx)
+ elsif @lst.size > 0
+ @lst.see(0)
+ @lst.activate(0)
+ @lst.selection_set(0)
+ end
+ @top.grab
+
+ begin
+ @var.tkwait
+ if (idx = @var.to_i) >= 0
+ @ent.value = @lst.get(idx)
+ end
+ @top.withdraw
+ @btn.relief(:raised)
+ @btn.image(@@down_btn_bmp)
+ rescue
+ ensure
+ begin
+ @top.grab(:release)
+ @ent.focus
+ rescue
+ end
+ end
+ end
+ private :_button_proc
+
+ def _init_bindings
+ @btn.bind('1', proc{_button_proc(true)})
+ @btn.bind('3', proc{_button_proc(false)})
+
+ @lst.bind('1', proc{|y| @var.value = @lst.nearest(y)}, '%y')
+ @lst.bind('Return', proc{@var.value = @lst.curselection[0]})
+
+ cancel = TkVirtualEvent.new('2', '3', 'Escape')
+ @lst.bind(cancel, proc{@var.value = -1})
+ end
+ private :_init_bindings
+
+ def initialize_composite(keys={})
+ keys = _symbolkey2str(keys)
+
+ @btn = TkLabel.new(@frame, :relief=>:raised, :borderwidth=>3,
+ :image=>@@down_btn_bmp).pack(:side=>:right,
+ :ipadx=>2, :fill=>:y)
+ @ent = TkEntry.new(@frame).pack(:side=>:left)
+ @path = @ent.path
+
+ @top = TkToplevel.new(@btn, :borderwidth=>1, :relief=>:raised) {
+ withdraw
+ transient
+ overrideredirect(true)
+ }
+
+ startwait = keys.delete('startwait'){300}
+ interval = keys.delete('interval'){150}
+ @lst = TkAutoScrollbox.new(@top,
+ :startwait=>startwait,
+ :interval=>interval).pack(:fill=>:both,
+ :expand=>true)
+ @ent_list = []
+
+ @var = TkVariable.new
+
+ _init_bindings
+
+ delegate('DEFAULT', @ent)
+ delegate('height', @lst)
+ delegate('relief', @frame)
+ delegate('borderwidth', @frame)
+
+ delegate('arrowrelief', @lst)
+ delegate('arrowborderwidth', @lst)
+
+ if mode = keys.delete('scrollbar')
+ scrollbar(mode)
+ end
+
+ configure keys unless keys.empty?
+ end
+ private :initialize_composite
+
+ def scrollbar(mode)
+ @lst.scrollbar(mode)
+ end
+
+ def _reset_width
+ len = @ent.width
+ @lst.get(0, 'end').each{|l| len = l.length if l.length > len}
+ @lst.width(len + 1)
+ end
+ private :_reset_width
+
+ def add(ent)
+ ent = ent.to_s
+ unless @ent_list.index(ent)
+ @ent_list << ent
+ @lst.insert('end', ent)
+ end
+ _reset_width
+ self
+ end
+
+ def remove(ent)
+ ent = ent.to_s
+ @ent_list.delete(ent)
+ if idx = @lst.get(0, 'end').index(ent)
+ @lst.delete(idx)
+ end
+ _reset_width
+ self
+ end
+
+ def values(ary = nil)
+ if ary
+ @lst.delete(0, 'end')
+ @ent_list.clear
+ ary.each{|ent| add(ent)}
+ _reset_width
+ self
+ else
+ @lst.get(0, 'end')
+ end
+ end
+
+ def see(idx)
+ @lst.see(@lst.index(idx) - 1)
+ end
+
+ def list_index(idx)
+ @lst.index(idx)
+ end
+end
+
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ v = TkVariable.new
+ e = TkCombobox.new(:height=>7, :scrollbar=>true, :textvariable=>v,
+ :arrowrelief=>:flat, :arrowborderwidth=>0,
+ :startwait=>400, :interval=>200).pack
+ e.values(%w(aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu))
+ #e.see(e.list_index('end') - 2)
+ e.value = 'cc'
+ TkFrame.new{|f|
+ fnt = TkFont.new('Helvetica 10')
+ TkLabel.new(f, :font=>fnt, :text=>'TkCombobox value :').pack(:side=>:left)
+ TkLabel.new(f, :font=>fnt, :textvariable=>v).pack(:side=>:left)
+ }.pack
+
+ TkFrame.new(:relief=>:raised, :borderwidth=>2,
+ :height=>3).pack(:fill=>:x, :expand=>true, :padx=>5, :pady=>3)
+
+ l = TkAutoScrollbox.new(nil, :relief=>:groove, :borderwidth=>4,
+ :width=>20).pack(:fill=>:both, :expand=>true)
+ (0..20).each{|i| l.insert('end', "line #{i}")}
+
+ TkFrame.new(:relief=>:ridge, :borderwidth=>3){
+ TkButton.new(self, :text=>'ON',
+ :command=>proc{l.scrollbar(true)}).pack(:side=>:left)
+ TkButton.new(self, :text=>'OFF',
+ :command=>proc{l.scrollbar(false)}).pack(:side=>:right)
+ pack(:fill=>:x)
+ }
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tkdialog.rb b/ext/tk/sample/tkdialog.rb
index e83e16d0a8..00cc12ab11 100644
--- a/ext/tk/sample/tkdialog.rb
+++ b/ext/tk/sample/tkdialog.rb
@@ -1,4 +1,4 @@
-#! /usr/local/bin/ruby
+#!/usr/bin/env ruby
require "tk"
root = TkFrame.new
@@ -54,7 +54,6 @@ bot.pack
root.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
def quit(button)
- print "aaa\n"
print "You pressed the \"#{button}\" button; bye-bye!\n"
exit
end
diff --git a/ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt b/ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt
new file mode 100644
index 0000000000..71e359559a
--- /dev/null
+++ b/ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt
@@ -0,0 +1,61 @@
+
+ #########################################################################
+ ### The following text is the original file of the Tcl/Tk extension. ###
+ ### Icon data files ( those are 'tkIcons', 'tkIcons-sample.kde', and ###
+ ### 'tkIcons.kde' ) are quoted from the source archive of ICONS ###
+ ### extension. As the following document describes, those icon images ###
+ ### are not applied the license. ###
+ #########################################################################
+
+
+IMPORTANT LICENSE INFORMATION
+=============================
+
+The following terms (based on the standard TCL/TK license) apply to all files
+contained in this package, <b>except</b> the icon images.
+
+The icon images can be freely distributed. If you require clarification of
+copyright/license details for the images, please contact the appropriate
+creator/maintainer.
+
+ICONS: LICENSE TERMS
+====================
+
+This software (ICONS) is Copyright 2002 by Adrian Davis (adrian@satisoft.com).
+The following terms apply to all files associated with the software except
+where noted above.
+
+The author hereby grants permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that
+this notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file
+where they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
+OR MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense,
+the software shall be classified as "Commercial Computer Software"
+and the Government shall have only "Restricted Rights" as defined in
+Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing,
+the authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/tkextlib/ICONS/tkIcons b/ext/tk/sample/tkextlib/ICONS/tkIcons
new file mode 100644
index 0000000000..0d5b2c8695
--- /dev/null
+++ b/ext/tk/sample/tkextlib/ICONS/tkIcons
@@ -0,0 +1,195 @@
+actattach16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBPz+/AQCBAAAACH5BAEAAAAALAAAAAAQABAAAAI2hAOCxg2h0nJHyEshi9HpxU1GOCLdZoKpQ15nibUoprKp9lh2oucUxsBRXsJh4Hjs/QTMpr8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmark16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actbookmarknew16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQyNKSipAQCBMTGxKyurISChJSSlJyanHR2dIyKjPz+xISGhPz+BGxubMTCBHx+fPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVfICACwWieY1CibCCsrBkMb0zchTEcNYsIiYHiwIOdEAvigdFQGE0Ix4NBbSAgsWjk+jBIAlcUYrJASChnSXZSoUDelKfoKpFALJA61ueGI2IAZmhogGFmCGGAgXsifiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actcheck16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBMT+xATCBASCBARCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAM2CLrc/itAF8RkdVyVye4FpzUgJwijORCGUhDDOZbLG6Nd2xjwibIQ2y80sRGIl4IBuWk6Af4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actcross16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBMQCBEQCBIQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMuCLrc/hCGFyYLQjQsquLDQ2ScEEJjZkYfyQKlJa2j7AQnMM7NfucLze1FLD78CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBDQyNHR2dCH5BAEAAAAALAAAAAAQABAAAAI4hI+pFrHb3nEg1iWiDiINCwYDko0V9XUTda6I1TIsUMpGinyzbB6ZeGuoEr+GUDL4CXqSphPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+acthelp16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQ6XAQCBCyCvARSjAQ+ZGSm1ARCbEyWzESOxIy63ARalAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EEgQqhUz00GEJx2WFUY3BZw5HYh4cu6mSkEy06B72LHkiYFST0NRLIaa4I0oQyZhTKInSq2eAlaaMAuYEv0RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actitemadd16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBARCZPz+/Mzq9BTC3ITC1HSyzGSivAw+XBSStIS6zHy2zAQCDFyatAQOHFSStEyOtAQSJBSq1DR2nCxunCRmlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICCOQTmeaCAMRIC+AVu47xkTBl2Ld16XQNYBQTQBVIOkMHFQJBeMI4tAbSSu2IRDSnhAvFfI97sFRM6RwOMacbjLKckVvgvIJ5EdSU7J648VgXQ7Dmd/hyJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actitemdelete16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBARCZPz+/Mzq9BTC3AQCDAQOHFSStAQSJAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQwEMhJq704681n+GAISoEwnGg6EAUQrEQsz4ThEkeu77kNIAagMEj0dY7IpHI58UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actredo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxOHBxSHBRGHKzCtNzu3MTSzBQ2FLzSxIzCjCSKFCyeHDzCLAxGHAwuFDSCNBxKLES+NHSmfBQ6FBxWJAQaDAQWFAw+HDSyLJzOnISyjMTexAQOBAwmDAw+FMzizAQODDymNKzWrAQKDAwaDEy6TFTGTFSyXDyKTAQCBAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ2QIBwSCwaj0hAICBICgcDQsEgaB4PiIRiW0AEiE3sdsFgcK2CBsCheEAcjgYjoigwJRM2pUK0XDAKGRobDRwKHUcegAsfExUdIEcVCgshImojfEUkCiUmJygHACkqHEQpqKkpogAgK5FOQywtprFDKRwptrZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actreload16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCRaJBxWJBxOHBRGBCxeLLTatCSKFCymJBQ6BAwmBNzu3AQCBAQOBCRSJKzWrGy+ZDy+NBxSHFSmTBxWHLTWtCyaHCSSFCx6PETKNBQ+FBwaHCRKJMTixLy6vExOTKyqrFxaXDQyNDw+PBQSFHx6fCwuLJyenDQ2NISChLSytJSSlFxeXAwODCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIBQGBAMBALCcCksGA4IQkJBUDIDC6gVwGhshY5HlMn9DiCRL1MyYE8iiapaSKlALBdMRiPckDkdeXt9HgxkGhWDXB4fH4ZMGnxcICEiI45kQiQkDCUmJZskmUIiJyiPQgyoQwwpH35LqqgMKiEjq5obqh8rLCMtowAkLqovuH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actrun16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChKSipMTCxLS2tLy+vMzOzMTGxNTS1AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJQqDYyiDGrR8oWJxnCcQXDMU4GEYqFN4UEHB+FEhtv7EBIYEohkjBkwJBqggEMB+ncHhaBsDUZmbAXq67EecQ02x2CMWzkAs504gCO3qcDZjkl11FMJVIN0cqHSpuGYYSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actstop16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/Gw6NGQuLHQ6NGQmJFweHFQaFPTm5PTa3PTW1Oy+vOS6tNSinKReVDQWFPz+/Nx6fNyCfNyGhNR+dMxybMRiXLxGRIwWFNx2dNx+fNx2bMxuZLQWFBwWFPTu7Pzy9NRqZNRuZMRSVLwmJGwWFNR2dMQiHPTKxMxmXMQyLMxmZNx6dMxiXMRSRMRaVKxybMxaVEQWFMQuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaaQIAQEBAMCAWDYcgkHhAJxYLRcDQBggckIplQKpaLdRh4YDIaSWa94Vw6woAHgv6AMKGPaMQhwQMJJRkfhHmEJhdvRCcgGSCEkCgpbnAECiorGYYfLCItlAAFCygQj5AfbYlwBQwVE5AukG6KBi8tMC0fLi0pHxyzcAAxFxwmMny/wEwOxMm/qlcdJCSJ1H5XQh3a28HY3kx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actundo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxSHBxOHMTSzNzu3KzCtBRGHCSKFIzCjLzSxBQ2FAxGHDzCLCyeHBQ+FHSmfAwuFBxKLDSCNMzizISyjJzOnDSyLAw+FAQSDAQeDBxWJAwmDAQOBKzWrDymNAQaDAQODAwaDDyKTFSyXFTGTEy6TAQCBAQKDAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ1QIBwSCwaj0hiQCBICpcDQsFgGAaIguhhi0gohIsrQEDYMhiNrRfgeAQC5fMCAolIDhD2hFI5WC4YRBkaBxsOE2l/RxsHHA4dHmkfRyAbIQ4iIyQlB5NFGCAACiakpSZEJyinTgAcKSesACorgU4mJ6uxR35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbook16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBDyKhDSChGSinFSWlEySjCx+fHSqrGSipESOjCR6dKTGxISytIy6vFSalBxydAQeHHyurAxubARmZCR+fBx2dDyKjPz+/MzKzLTS1IyOjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOZGmKQXCWqTCoa0oUxnDAZIrsSaEMCxwgwGggHI3E47eA4AKRogQxcy0mFFhgEW3MCoOKBZsdUrhFxSUMyT7P3bAlhcnk4BoHvb4RBuABGHwpJn+BGX1CLAGJKzmKjpF+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appbookopen16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExCNGSenHRmVCwqJPTq1GxeTHRqXPz+/DwyJPTq3Ny+lOzexPzy5HRuVFSWlNzClPTexIR2ZOzevPz29AxqbPz6/IR+ZDyKjPTy5IyCZPz27ESOjJySfDSGhPTm1PTizJSKdDSChNzWxMS2nIR6ZKyijNzOrOzWtIx+bLSifNTGrMy6lIx+ZCRWRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQEAAQCwWBYJiYEAoGAFIw0E5QCScAIVikUgQqNargtFwdB9KSDhxiEjMiUlgHlB3E48IpdKdLCxzEAQJFxUTblwJGH9zGQgVGhUbbhxdG4wBHQQaCwaTb10emB8EBiAhInp8CSKYIw8kDRSfDiUmJ4xCIxMoKSoRJRMrJyy5uhMtLisTLCQkC8bHGBMj1daARgEjLyN03kPZc09FfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appboxes16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbox16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECKoR6ys2IVqokF08yMTA1gwkYX5WQK5ma4VceTYPxXnBWdtY6+0834/Bowgzm6APWRQcH4TiMhPK2WYRiZWW7XK7/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbrowser16:app app16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxONCROfCRKfKx6LNy+bNTOpGSS1DRupAwyXBRSnPTSjPTqvOzqzMzSvHSSlKy6ZDxutAxCpBQ2XBxepLTKvPzqzPzy5OTShLS2dLSqRFR2jBRerBQ+jOTixOzetNS2XHx6XDR2tCRexBwyTDyKzOTavPzq1OzKdCx23BRKtCQ6VCQmHFSa7IyirOzSnGSGpIR+bFSO1DyK7DR+5CRixBw2VDQuHFye7IS27NzGXISuhEyS5DR25BRWxBQ+lBQyXCQqPCxSfGyu7GyerKy2ZFR+rERqfCRmxBROtBQ+fBwuTBwmNDSW9JyabLyqRIx+TExSXBQ6bAQCBBQ6ZBxapDR+zBxq3LyaLJySRHxqPGxeNBxGbCRmrHRyRERONDRKNDQ2JCQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhgABAQIDh4MBBAUGBwgDCYcKCwwNDg8QERIThRQVFhcNGBkaGxwdoYMDHhcXHxggISIjEiSvJSYXJwsoISkpIyorLIIDLS4WLzAxMjM0NSo2N8o4OS46OzwzPSk+P0BBgkI8Q0NERUZHCEhJSktMgwk4Qy1NTk9QUVJLphCiUsWKlStYsmjZQiJgIS4KuijQ4iXAFxYCDVFJwGUFmDBhMjYSw0KMyEYoBfkJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appcalc16:app app16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChPz+/AQCBCH5BAEAAAAALAAAAAAQABAAAAI4hI9pwe0Ogpi00hHF2LzzzFlTsIHD45SSx6oCeW4wjK2tl83y7t64pIsJaxrfh2bEAJIlhRPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appclock16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAALy+vAQCBPwCBMQCBIQCBISChPz+/MTCxCH5BAAAAAAALAAAAAAQABAAAANbCLHcrSLKOZcYmDSCsR1aUABAsXDDJwJGa5SBFwgaWxbCG3CWaBwG3C8Y67FawpYiNQscg65fsVkYuoAmJs1pBR522lQB6ILJLqHRwQQOZzYdZnw+dzruDIA/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appdate16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQCBMQCBPzCxAQCBPz+/MTCxISChDQyNKSipEQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARDEMhJZRBD1H2z3lMnjKCFjUJQimOgcmcbELCXzjXq0hV785WCQYcDFQjDXeloMByKG6YTAdwIDAlqSZJSVFeKLcUfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appsheet16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPz+BAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANFCBDc7iqIKUW98WkWpx1DAIphR41ouWya+YVpoBAaCKtMoRfsyue8WGC3YxBii5+RtiEWmASFdDVs6GRTKfCa7UK6AH8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+apptool16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptools16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTERCRAQCBOzu7Nze3MzKzLy+vCxqZBQ2NJyanKyqrGRiZDRydKza3FRWVPT29LSytDw6PMTm5EySjCxaXGRaJFSanCRSVGxqbPTmvMSqVJTW1GSurHS6vOzq7KSipISChFRKHJSGNPz23GxKFBQ6PKyurCwqLMyufJx2RAQGBJSWlEwyDIRiLNy+lLSKVDwmDJRuNOTOrLyabGRCFDx2dKSCVOzWtHzCxOTGnNSyhAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwCAgIBAOiUiggFAyHASKxDAwUC8Zg0HAglA9IZPGQABoTSqJCFTIOEIsFgHBcEhhHUpKJFCwaGxYYHB0VEx4IEh8gIQwiIyQbJRMcHokmEicfDygAkCkqJQgIGG0rLElCLS4vMCWqQwMCQg0UMTIzNDVLQjaIGDE3ODQlS785CEkxKjowvEOHybG4O6JDCdNKuDUxRAmxRDHeveUAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appuser16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxISChMT+/ATCxASChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMg5gw00yyDGIAR1YUDggeFWFIZhnSBZrsZxdIOFEGTA2oeBAHeyuGwvzxBlYdUOLROMFzDQntJPrNoqAKUBaqnV+k57ZORruykHDj2LqIzUVKp1u0iuB/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appusers16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxISChAT+BMRaBPyqXARCBPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEIRJa5Ui673nsGAgeKE1Bl9AUEXbiqTlFlZaGUZoszm4BzhDAVf5BYbAXI+TAR6CS2ZGSZSEiIIqYIsSIEaJ7GRrlY7J1lKA7I8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appwp16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBKSinJyOfPz27Pzy7AwKDExOTJyWlERCRKSelPz69LyyrKymnPz+/MS2fDQyJAQCBOTazLSiXOzivMS2jKSSVOzmxPz25NzSpPTu5KyebOzixNTGjOTWpMSydMSybCwqFGReVKyaXNzSnGxeNJSCVMS2nPz23MSuZIR+bJyShLyqnOTOtGxiXIR6XOTSvIx6RMSubIyCdKSalMS6pOTWxMzKvKSabJyKTOzezHxuPGRmZKyurMTCvPTq3AAAACH5BAEAAAAALAAAAAAQABAAAAajQIBwCAgIiEhiYEA4FgwHRDKhIBAWz4OhgGQ0FAPHA7qFEBONb0Qy0ULeQ2+aUrFcMI+3GYBOZzQbHB0eHyAhIQByDREiEwMjFRIkJQImAgJ+jScjHigkKSorLC0AKg2NFSMoki4qCy+IQgITKDAxkjIzNDWkQxQoJaskMgk2Eb1DNzgoOCoHDDY5yEIwJToAOzw9ET7TQiREAhkZ3kmy5QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal1day16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANOCLrMEUDIOUS9AFLLhx8LIRZjKYZmMRCkaChFLHty/AIiS3y6q+QtT49wq8VotRtQJGwRf6Zmrlj7DJLQXsupTJmeEIN4TB5nII20wp8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal5days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANMCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiIdMmcec7jy53q81qP9OO5VMAj8RXTFWzOZW95HDLdEEM4LA4nIE0zgp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal7days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANPCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiwcp0fucsj873qvGMv5Jw2FIACUsW4WakGW1O046I05qmGYBhTC6TM5CGWuFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calappointment16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxPz+BISCBISChKSipAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARbEMhJaQhA6D1E/wDGeeRgDhOhFoTBEi+REgdrIHScSEVvAD9Xr7cDqGSGpFEnQSqTv2NxCFQOiU1VEAiTZmstHFg1vQKuw+LxxfYaV/AuOQRI2O/4ewhT6Uv8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calbell16:cal cal16 16:photo:16 16:R0lGODlhDwAOAIIAAPwCBISCBPz+BIQCBMTCxISChPz+/AQCBCH5BAEAAAAALAAAAAAPAA4AAAM+CLrR+zCIAWsgLVRGRBhOVQiG94WPVAbHaZHYAWqRYLbge88RsbInGuBCEhRYrZYm4xk4nYdoKzKIbiKHawIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+callist16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/KSipPzerMRaBEQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARDEMhJaQhA6D1E/wDGeeRgDhOhruyatjBRSIRxxOsMEAdC0BUZDcfSEYvDo3Bn++2Cxt7RqFxWhZiCdsvdhjCVsMQfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calmonth16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANSCLrMEUDIOUS9AFLLhx8LIRZjKYbiRxLFIBpK0Q6z7MkwkJIe8b0KEeuWchFysuStVsjtfMbeMQitWpG25YfmNK1WU53XNIUYzug0OgNpuBX+BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+caltoday16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxKSipPyCBMRaBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARTEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyIQhFfiBIAfuFzaAioBIJBCummRYPCaDPh3vhwsOZdihNfa8Ub/AJXemFZPPNBvGwG672yFMZS7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+caltodo16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBAT+BAQC/AQCjPz+/MTCxPzCxKSipPwCBMQCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARaEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyMYhFXiuFwZiA6qZYbbqJX5BIw2RAPxwAAWCyWMCCsiXFGEEErKz6LQZfOqiTR1YJiGq1rFyyHmo2+/1EKbCl/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connecting16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZbihUiz60FPnfaA0iBpBVGdHEYWxToEoSHBRHHM9AgSEQRcj+AYkYAJxIPKQFUJiOdTJQFIDU6dYzKKFhTCM+E5g4mXaDAyrlogEG+DGTecA7wsP8EcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBAQCBERCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEMhJq704axBEHoPUEdhQGMNYFuwxkKInDYjBniEnwMCQIIebSzXx/WwsFK+YMABZikWuYlrUCtZpEYv4WRPaHhb064YB41kCfJFSQBh/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connectyes16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipDQyNMTCxMTGxISChFxaXMzGzAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZxCjgsAtDtUlCOA1gJQ4kl/IDatAoF7xxkS6GgEBr6jAobCyBX42SQBxMOx6A8MhiGASR8YDgrYsNEeJ0zaEGZY7uoH2oB6nOUwtbdLaVOeTUwo/8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devdiskmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKROzSrOzKpOTGnLSafLySZKxuLMSOVPTWvPzixLSehNyibOzOrGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTOpHxOJKyKXFw+HKSipISChMTCxFxaXIRiPNSWXExOTOS2hLR+PLRyLPTWtMyOTASCBARCBPz+/DTSJIyKjIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwrA3HQ7scQAqFAcEQOUi0zAkFUSFYLghMBloUCDQNGxwdHhwHekcfICEhICIfIxkLJBABJUYCICABIhAOBiYnKJaXmH4CGSkYCCqkSAEfTKenrkOwsrQll0IrS7G5uwArLLaxLbXCLsTFLyDBKy4wZEVHvCwsRn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devdiskunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKRPTWtOzKpOTGnLSafLySZKxuLMSOVOzOrPzm1LSehNyibGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTWvHxOJKyKXFw+HPTOpKSipISChMTCxFxaXIRiPHxaNLRyLNSWXExOTPzixOS2hLR+PMyOTPz+/IyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwGgiD46FdDiCFwoDQAEe0TMkEQSFULIcLBloUCDIaDRscHRsNHhhHHyAhISAiHyMkJSYQASdGAiAgASIQKA0pKguXmJl+AiQGFwgrpUgBH0yoqK9DsbO1J5hbsrq8SrgstlJFHy0gwMVFR1J+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devfloppymount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVrICCOQBCQKBkIw5mqLFG47zoQ+FwbN57TosDhgPD5dMEEIqE04kwlBWKBUEiNVYFpyqAyGEUCgqEtERiNNMLhQKzLQYJg7n7Y4aMAwbCUPvAQeWNgfzQQETAIhSMQEogwgBITQEGGEREmfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devfloppyunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVCH5BAEAAAAALAAAAAAQABAAAARcEMgJQqCYBjFu1hxReN82EOhYGieaklJwHIjrqnGCJLqNWhUFYoFQCG1FgWXIIDIYNQKCoawQGI0swuFAbKsxgmDsfZjBkwDBsNM90Jot9A3DbBD0Dwiur9QnfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devnetwork16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBISChPz+/Nza3ARaZESanCyKlARudARGTLy+vNzq7ARmbMTCxARufAROVMzOzKSipARyfOzq7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVmICAGZFmKQiACweCSBImq41AYB5IodLq2hwWO0ejRWDac48Gb/QKNqNRoqspmrVcAUuIJBANS8sBIFCORUgooPEh4J8B67NgdsVBp9C5XWfl9LRMTCyReX19hARNojWlWLH+AAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devpc16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBISChHx+fPz+/AQCBAQC/AT+/AQCxAQChAT+BLy+vAR+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEIAgqK1YzsG754QUDERpmkEpkkXrtoK6EcVgHIibhnNx564Yb0TDvQq7FQ34EiqPOhnREqhWSUPsyZSQAbbg7GcMEgwUiYVivTa1R+y4XEGoWO/4AMAfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscanner16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MT+/ASChARCRATCxMTCxFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJgqWBVivEldkUdKSXhVjZfenommglDERh3Tc4E4ZRHAGgkEPr9X6H5AHBERSMRyWzkug8jQXFEhWoOo8dRYxqLXSmGjIJnVaz29Q3fAP3RwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devscreen16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devspeaker16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXAT+/DQyNATCxMTCxPz+/AQCBKSipASChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgJQqCXziDG2JoUEENhZBkmHIWJVptAmqcIW/Js1MiF56TBzkckAAcHoa9nMRKeA4TyJk0knsHhTeK5khBaH2VwLYVh40TJhQ6RzeIQV32Quz8hfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXPwCBNze3GxubERCRPz+/Pz29Pzy5OTe3LS2tAQCBPTq3PTizLyulKyqrOzexLymhLy+vPTy9OzWvLyifMTCxHRydOzSrLyihPz6/OTKpLyabOzu7OTm5MS2nMSqjKSipDQyNJyenLSytOTi5NTS1JyanNTW1JSWlLy6vKyurAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAaUQIBwCAgYj0eAYLkcEJBIZWFaGBie0ICUOnBiowKq4YBIKIbJcGG8YDQUDoHTKGU/HhBFpHrVIiQHbQ8TFAoVBRZeSoEIgxcYhhkSAmZKghcXGht6EhwdDmcRHh4NHxgbmwkcCwIgZwqwsbAhCR0CCiIKWQAOCQkjJAolJrpQShK2wicoxVEJKSMqDiAizLuysiF+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcut16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIwhI9pwaHrGFRBNDdPlYB3bWHQ1YXPtYln+iCpmqCDp6El7Ylsp6ssR1uYSKuW0V8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editdelete16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPT29GxubMzOzDQyNIyKjHRydERCROTi3IyKhPz29Ox6bPzCxPzy7PTm3NS6rIQCBMxCNPTq3PTi1PTezMyynPTm1PTaxOzWvMyulOzGrMymhPTq5OzOtNTKxNTOzNTCtNS+rMSehAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaKQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhSEQkFgrBAcr1URiPhKAsDD3QB8RhA3FM0IlLHnyUTVBMSFBUWfl0XGBMTGBcZGodmcQWKjpAbHIgIBY2LHRoempOdjooTGx8giIOPFYofISJ+DyMXI6AfFySyfiUmJSUnKBYcICIpfgELzM3OZX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVMR+RPzKjNze3AQCBMR6RPzGjPyODPz+/MzOzPyKDPyKBPz29OTWzPyGDPyGBOx6BOza1OR2BKROBNSOXKRKBBwOBOzu7PTWxPzizOySZPyCDFxaXOy2lNRyRMxmJCQOBPTm1OzStPTKrMR+XIRWLFxGNCQSBDQyNIRSNDQuJERGRLyqlNzSvIx6ZKRuVEw6LLSyrLymhKSShBwaFFROTJyWjMS+vNzW1OTazNzKrHRqXOzezOTOpPTq3OzWvOTStLyedMS+rLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAewgAAAAYSFhoQCA4IBBI2OjgUGBwiLBAmXlpcKkgsMlZcJBA0JDpIPEBGVjwkSBgOnExSfmBIVBxAMExYXswkYGRobHLq8gh2PHhoeHyAWIYKzIiMkJSYnKCnQg5YNHtQqKywtK9qMBC4vMDEBMjIz2dCMDTQ1Njc4OToz5PEEOzw3ZPToMcLHO23HfogQ0QMIkCA+hPBbhAPHECJFjMyYIUQIvEUpUqwQOXKkSEF+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQiFHRqNIx+LFxSBDw6PKSaRPz+/NTOjKyiZDw+POTe3AQCBIR2HPT23Ly2dIR2FMTCxLS2tCQmJKSipExGLHx+fHR2dJyenJyanJSSlERCRGRmZNTW1ERGRNze3GxubBweHMzOzJSWlIyOjHRydPz29MzKzIyKjPTq3Ly2rLy+vISGhPzy5LymhISChPTizOzWvKyurPTexOzSrDQyNHx6fCwuLGxqbOzKpMSabAQGBMS2nLyulMSidAAAACH5BAEAAAAALAAAAAAQABAAAAa7QIBQGBAMCMMkoMAsGA6IBKFZECoWDEbDgXgYIIRIRDJZMigUMKHCrlgul7KCgcloNJu8fsMpFzoZgRoeHx0fHwsgGyEACiIjIxokhAeVByUmG0snkpIbC5YHF4obBREkJCgon5YmKQsqDAUrqiwsrAcmLSkpLrISLC/CrCYOKTAxvgUywhYvGx+6xzM0vjUSNhdvn7zIMdUMNxw4IByKH8fINDk6DABZWTsbYzw9Li4+7UoAHvD+4X6CAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbGxubMzOzPz69DQyNIyKjERCRPz29PT29OTi3IyKhPz27PTu5PTy5Pz6/Pzy7PTq3OzexLyqlPTm1PTizOzavLyqjOzWvOzaxLyifOzizOTOpAQCBOzezAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaEQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhWEQkFYYHkeqkMxKFBFpq9jgdkEGlPqwrJhCIY2N8FFRYUFxcYGX9dgRKEGhiHiYEOhBcbGBwdiQEOARcBGwEeAZllAgEUnQEfoQEgmp4hrCKtrwEYsrRlTiMBJAG8syN/IyMAxMXHSH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edittrash16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipFxaXPz+/MTCxISChDQyNCH5BAEAAAAALAAAAAAQABAAAANQCKrRsZA5EYZ7K5BdugkdlQVCsRHdoGLMRwqw8UWvIKvGwTICQdmGgY7W+92GEJKPdNwBlMYgMlNkSp3QgOxKXAKFWE0UHHlObI3yyFH2JwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileclose16:file file16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCQiJBwaHAQCBDQyNDw6PFxaXFRSVERGRCwqLAwODGRiZHx6fPz+/GxqbAwKDCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVaICCOZGmeqBgEwjCkRGEcSKK4JrEcBrMgAdeLVDg0GguGsYEbBQyGYyN6FDoPDIf0+LCKBIgetQERDgGDBGIpNY8GioAU0m6KXFw883w3+/l9f4AkfimGIn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filedocument16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJSWjPz+/Ozq7GxqbJyanPT29HRydMzOzDQyNIyKjERCROTi3Pz69PTy7Pzy7PTu5Ozm3LyqlJyWlJSSjJSOhOzi1LyulPz27PTq3PTm1OzezLyqjIyKhJSKfOzaxPz29OzizLyidIyGdIyCdOTOpLymhOzavOTStMTCtMS+rMS6pMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaQQIAQECgajcNkQMBkDgKEQFK4LFgLhkMBIVUKroWEYlEgMLxbBKLQUBwc52HgAQ4LBo049atWQyIPA3pEdFcQEhMUFYNVagQWFxgZGoxfYRsTHB0eH5UJCJAYICEinUoPIxIcHCQkIiIllQYEGCEhJicoKYwPmiQeKisrKLFKLCwtLi8wHyUlMYwM0tPUDH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filefind16:file file16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBCQmJDw+PBQSFAQCBMza3NTm5MTW1HyChOT29Ozq7MTq7Kze5Kzm7Oz6/NTy9Iza5GzGzKzS1Nzy9Nz29Kzq9HTGzHTK1Lza3AwKDLzu9JTi7HTW5GTCzITO1Mzq7Hza5FTK1ESyvHzKzKzW3DQyNDyqtDw6PIzW5HzGzAT+/Dw+RKyurNTOzMTGxMS+tJSGdATCxHRydLSqpLymnLSijBweHERCRNze3Pz69PTy9Oze1OTSxOTGrMSqlLy+vPTu5OzSvMymjNTGvNS+tMy2pMyunMSefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCAAECA4OIiAIEBQYHBAKJgwIICQoLDA0IkZIECQ4PCxARCwSSAxITFA8VEBYXGBmJAQYLGhUbHB0eH7KIGRIMEBAgISIjJKaIJQQLFxERIialkieUGigpKRoIBCqJKyyLBwvJAioEyoICLS4v6QQwMQQyLuqLli8zNDU2BCf1lN3AkUPHDh49fAQAAEnGD1MCCALZEaSHkIUMBQS8wWMIkSJGhBzBmFEGgRsBUqpMiSgdAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filenew16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz6/GxubNTKxDQyNIyKhHRydERCROTi3PT29Pz29Pzy7PTq3My2pPzu5PTi1NS+rPTq5PTezMyynPTm1Pz69OzWvMyqjPTu5PTm3OzOtOzGrMSehNTCtNS+tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ/QAAgQCwWhUhhQMBkDgKEQFIpKFgLhgMiOl1eC4iEYrtIer+MxsFRRgYe3wLkMWC0qXE5/T6sfiMSExR8Z1YRFRMWF4RwYIcYFhkahH6AGBuRk2YCCBwSFZgdHR6UgB8gkR0hpJsSGCAZoiEiI4QKtyQlFBQeHrVmC8HCw21+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBOSmZPzSnPzChPzGhPyuZEwyHExOTFROTFxaVFRSTMSGTPT29Ozu7Nze3NTS1MzKzMTGxLy6vLS2tLSytDQyNOTm5OTi5Ly+vKyqrKSmpIyOjLR+RNTW1MzOzJyenGxqZBweHKSinJSWlExKTMTCxKyurGxubBQSFAwKDJyanERCRERGRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaRQIBwGCgGhkhkEWA8HpNPojFJFU6ryitTiw0IBgRBkxsYFAiGtDodDZwPCERCEV8sEk0CI9FoOB4BEBESExQVFgEEBw8PFxcYEBIZGhscCEwdCxAPGA8eHxkUGyAhIkwHEREQqxEZExUjJCVWCBAZJhEmGRUnoygpQioZGxsnxsQrHByzQiJxz3EsLSwWpkJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileprint16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPT29PTu7PTy7NzClOzm1PTu5LSabJyanPTm3FxaXOzCjOTKrOzi1OzaxOTSvJyenGRmZLyyTKSipDQyNERCROTi5Hx+fMzKzJSSlIyOjISChLS2tAT+BDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaYQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAoEAuGIdGITgWOq4LxcCQgZkEkIHksHgYJOR6ZQCgVFhYJFxgTBVMZihoCfxUYDWUbUBGKGREcjBoQEB2TAB4CAx+Vl5WMhyACHiEhH6IfIiMktCQgE0cZJQStr6O2t6EARxO6vK6iEx4dZsMCxbsmBB4nzUTEutVSSUdmfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRSVMTCxKyurPz+/JSWlFRWVJyenKSipJSSlOzu7ISChISGhIyOjHR2dJyanIyKjHx6fMzOzGRiZAQGBFxeXGRmZHRydGxqbAwODOTm5ExOTERGRExKTHx+fGxubNza3Dw+PDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaAQIAQECgOj0jBgFAoBpBHpaFAbRqRh0F1a30ClAhuNZHwZhViqgFhJizSjIZXQCAoHOKHYw5xRBiAElQTFAoVQgINFBYXGBkZFxYHGRqIDBQbmRwdHgKeH2YgHpmkIR0HAhFeTqSZIhwCFIdIrBsjAgcPXlBERZ4Gu7xCRZVDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderhtml16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBERGRBQWFMzKzOzq7CwqLDw6NARqnAQ+XHR2dKyqrOTm5ExKTERCRHRydMTi7NTu9HS+1KSmpBweHDy67DyixHS61ITG3AxypByu7DxinBw+ZERmdIySjITC3ARypExOTDRurIR2RPTSdJyulEyGvBw+bFSyzJTK3LzKvPzivOTixNTChLSybGyCfCRSnBQqRASGtFyuzDw+PCRShPzy5OzerOTShKyaTEx6pCxerGRufBR+rOTezPTShNy6bER+1BxCfBQuRAxelFSixBw2VISq3GySrPTWlHyanIyitFSO3IymtCRujAxWhCRqlCQ6XGyWvNS2bFyGvDxuvCRSpLy+vMS+vGxqbFyO1GSi3EyO1FRaVCQuPLS2tDxyzKyWNFxaNCQyPGxubCxajERSVExKNJyenAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAECg4eIAAMEBQICBomDBwgJCgsEDA0BDg8BhwYQERKUDxOYDAyeghQVFhehGBmVlwwOqxobHB0eH6EfIAkPIYIiIyQlJhsnKBcpvrYiKissLS4vMDEyFjOvNAA1LDY3ODk6Oyc8PTIyFzQ1Jj42P0A6QTtCQ0REIEUORkdIkihZwsSekBhNnDyBciCKiSNSplDRUcWKkRhXCGDJYgiGli1cpuTocsILjytfFmRpACAGRTBhRogZgzHlAjKGWnIoY+bMgRgBDHRBo/LAIZoxuhwKatRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folderlocked16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQSFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpOzm5GxqbCQiJMTi7NTu9HS+1HRydOTm1Ozq7Dy67DyixHS61ITC3AxypERGRBweHByu7ASGtFyy1DSOtDRmfExOTBSazBR+rCwqLAxWhAxelByGtDSaxAwODHy+1Dw+PPT29IyqvCxujOzu7NTW1Nza3ExGJJyebKyqfMTCpFRSPOTi5DQqHOTezDw2NMTGxKyqhMTGrGxmXDQ2NMTCxMTGpHx6bHx2bBQWFIyOXDQuDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomDBwgJCgsEDAKFDQGHDg8QEZQSlxMUDJ2CDhUWF6AYGZWXFBqCGxwdFh4XGK8fIAohtiIIIx25EZwBDREHgiQjJSYmGScoKSoRKQ8rggIsDC0uJS4oGygoAyjdAAcsLxQUMDEyMzQ1EzapBy8MDDc36tFwgONFjlQ6dgCEEZBHDx8+ctRIRehHAyAwZASZIGRIEBoUBwUwIGMCiwFEaBQJichIjo9FZLBsacRIAB0A/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+foldernew16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBPz+hPz+BOSmZPzSnPzChFxaXMTCBPyuZPz+xPzGhEwyHExOTPz+/MSGTFROTPT29OTm5KyurDQyNNza3Ozq5Nze3LR+RLy+vJyenMzKzNTS1Ly6vJSWlFRSTMzOzMTGxLS2tKSmpGxubBQSFAwKDKSinJyanIyOjCQiJERCRERGRBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaNQIBwSCwaj8ikcokMCIqBaEDoBAQG1meAUDAQpIcBQoy1dg2JdBqhECgQ1IWB0WgcBIOBwIHXBwwPEBEREhIBbG4IExR/DBUVFhIXV2NjDVYYDY8SFU4ZVxpVAQwbGxynGxkdTh6XVh8gGSGzGSITIxokJUImGSMTwLcnKCkprgAqDSt1zCssKxQtQ35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderopen16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailforward16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRydHxubHxmZGxiXHRmZFxOTFxGPFxKTPwCBLymlMy+pOze3PTq3PTu5Pzy7LSmnOTaxOzm5LyqlNzOtPz69Pz27MzCtLyqrPT27IRubPzuzNTGvNTCxLSelPz25Bw+ZFxKPPzy1Pz65LyupBxKdCxWfPTm1Pz23LyinBxGbGzO5DRafBxWfBxajCymxHTS5BxSdBxKbFTK3EzG1CSGvCyKvCSSxCSavGTO5GRaVPzqzFzK5EzG3BSCtAwiPGxaVPTivPzy3NzKpBxObCRefBxqlPTmzJR2bKyahAwyRPzmvOTOpKyObNS+nPz21AQOFKyOfPzuxAQCBGRORLSadPzyzLymjMy2lOzetDwuJFRCPEw6NEQ6LEQyLEQ6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAQABAAAAfhgAABAgIDBAQFBgcIBwmOCQIKCwwNDg8OEBESjY8CDBMUFRYVFxgZDJyOGhsPChwVHR4fFSAhjwkaIiMOJBQQDRUVJSa3GicoHw4pEA8SGSorLI8tLtQu19gqLzDECTEyMzQ14zY1Njc3ODkqCTo7MjIxNCs5PD03PjctPwlAQUIihhBpQbCIihtG+CUocASFkAhIkogQ8kFJwkcFlogIkoRJEydPnkBR6GiAxiQLgiiIIkXElFQJqESoMsRKkAhXqkhhApNKFSxZggTJ4nHIEJhaDhzYwoVLFy1avHyB6ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAxKdBRSfCyGvFSm1BxKfCSWzCyWzBRCXCRKfBwuRAQGDDw6PHy23Cym1CSSxByCxBxunBQSFKyurMTCxExihNza3NTW1JSSlMzKzFxaXLS2tNze3KSipCQmJGxmbNTS1KSepLy2vISGhJSWlHx+fERGRPz6/IyKjDw+POzq7JyenMzOzKSmpCwuLDQyNIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwGBAIAsOkUjAgFJRQQMHgjC4PBIEVgAh4D4aEYrGAMhINxwPyiCgYSsmEUmk82grLRZJkYCgXaAEKFxYZcEISGhsZFxwFeY0WHR5CDB8dGCAXG5shGxQicBIMpSMUGxgTGSQlpQwSJicnEwwdI7gdKAwTsykpKiobr8QMKxeHDBcsGRvOzxsT0i0uL9HSHdkT2ZkoMJXF4a8AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGxaVOTe1Oze3OTWxOTWvNzStNzKpEQ6LOTezPz+/Pzy7Pz69Pz27Pz25Pz21PzuzPzuxEQyLLyinLSmnPz67Pz23LSafKyObDwuJMzCtLSelPzy1My6nLymjNTCxLyqnPzq1LyihKyOfOzavOzetEQ6NPTq3NzOtLymnNTGxJR2bOTOpPTivNTGvLymlKSShKyahEw+NOTe3PTm1Pzu1Pzy3FRCPPz65LSadFxGPOzm3PzqzPTmzPzmvEw6NCH5BAEAAAAALAAAAAAQABAAAAaqQIBwSCwaj8ikMhloOp/QpmAgqAoIhELBUDgcEIGEYrFgNBoLx+IBiRwkgQnFoWAwKhWLhX3BZAILGhsCDXgODhwdGB5vgAofICBlDiEiIx4kJSYBJ2UoEykqHSMrLC0nLWAnFS4UCycvMAcEMR0RLTIBMwaSahw0NTYtFwclNwEdLws4eoc2DxwQOR06ASk7PBAhIRE9Pj0tLSUY1T8I5gjn6Qgy7D8SfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreplyall16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBLymlMy6pOTa1PTq3PTu5Pz27Dw+POzi3PTm1OTWvPz25FRSVERCRLympPzuzPTu7NTGvFxaXKSmpPzu1Pz65Hx6fHxqZPzq1Pz23HR2dBw+ZHx+fISChJSWlDQmJHRydCxWfBxGbJyenExKTHRiXPzqzPzy3CQmJDRafGTO5ExOTERKTGxWVCRSfHTS5CymxBxajBxWfPTmvPzy1CyixCSaxCySxDSaxDSWxDSSvDyaxGS21PTmzPz21AwiPBRejCSavByGtCSezEzG3FzK5FzG3GzO5FTK3CQ2bPTixBxqlCRefBxSdBxSfBx2nCQ+dHxmXPzmvLSafAwmRAwyRPzyzDw6POzavNzKpAQOFPzuxBwWTBw2ZGRORLyWdMy2lOzetPTivAQCBKyObOTOpAweNBwWVEQyLEw2LEQ2LDwuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAf4gAABAgMEBQUGBwgJCguOCwEMDQ4PEBESDA4TjY8DFAwVERYXGBkRm4+QGhsMHB0eGB8bDpyOARogEBceIRgXv8COIiMkGB4lJSYnIcwoKb/DGyoXKywtKS4pHinMLzAxJDIzNDUtNjcv6B0hLzgfMh85OjstPDw99zwd7T4/LTVAgggZQqSIECNHevSAgSSJkiVMmjh5AiWKlClAiFARUeVHFSVWmLS40gNLlh5agGzh0kWDlwZfrIDREKaCAjEqrFA5MMYLmTAxlJTxYoZMozNozqRRs4ZNmy5s3LwhA0dBnDNn5MxBoAABnTp17IitowDrmQV+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTEw+NFxKTFxGPPwCBLymnMy6pOTa1PTm1Pzy7LymlOzi3HxqZOTWvPz69Pz25My+tLympFRGRHxuZPzu1LymjNTGvNTCxBw+ZPz23PzuzPz65PTu5NzOtCxWfBxKbPzq1DRafGTO5BxGbPzy9HTS5CymxBxajHRiXPzqzCyixCSaxCySxDSaxDSSvGS21GxWVAwmRBRejCSavByGtCSezEzG3FzK5FzG3CQ2bPzuxAwiPBxqlBxKdCRefBxWfBxSdBxSfBx2nCQ+dPzy1CRqlAwyRDQmJPTmvPTixLSafOTOpAQOFPz21BwWTBw2ZPzmvNS6nPTivAQCBAweNBwWVNzKpPzyzLyihGRORLyWdMy2lOzetKyObEQyLEw6NEw2LDwuJEQ2LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfqgAABAgMEBQUGBwgJCguOCwEMDQ4PEJYRDhKNjxMPDBQVFhAXGBUSGY8LGhsQHB0VHh8gFQ6bjgEhIiMMJCUmFbS2CwMnG6IoKSorI7WpEycWFiUsLSou1yXXji8wFiopMTIzNDUz4zbZNxsbODk6Ozw9Pj8pPzEzQDdB60JDOkRFjBw5giRJDCWdlmxwIIRJExAWKDRyMgTIiydLoESRImQKlSUSF1SxUoXAlSBRsGSJoCVICIlbqlThcoBClC5eYFD4EiVIFwUyqywAE0ZMlqNjpJDpIkUBl0dlFChAYOZMmTJoyqQR5icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailsend16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBHxqZLyqlMy6pOze3PTq3PTu5Pz27Pzy7LyinOTaxOzi3Ozq3LymlOTOtPz69Pzy5My+tLympPzqzNTGvLSelPzy3BxGbBQ6VPzuzPz65LyupNzOtPz+/GzO5BRejPzq1Pz23LymjHTS5CyixCSavBxqlPz25LymnGTO5CymxCSaxByGtHRiXPzy1CySxCSezGxWVPzuxKyOhMy6nDSaxEzG3PTivNzKpKyOfPzu1FzK5PTmzJR2ZLyihLSWfKyObOzmzPzmvDyaxOzavLSafGRORMy2lOzetDwuJEw6NEw2LEQyLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfUgAABAgMEBQUGBwgJCguOCwwNDg8QERITFBUWjY8DFxgZGhsaHB0aD5yODB4TGB+kICEaIiOPCwEkJRcmJyYPKCIpKrWqKywTmC0SIi4vMDHEDCsyMg8zEyI0NTY3z7U4Hhs5Mx+0IyI6OyPrIzw9Gys+PxIy2EBBxAs8Qjk5Q0RFWFxAZySfgSMsilRAkiRECHQ08hHgJ0TJkCU/mECU2ISEkowUlpAQ4QTfowNPoAzJIeRJCyjm8kVRIkWIzSkXhwxJtYAKgp9VrFi5QoWKFZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PUZi0zmTtypflV0VdRJbm6fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav1leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAP///wAAACH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxqdwoNGTmgvy9px/IEWBWRkKZ2oWrKu4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxCtwoNHTmpvy3rxnnwQh1mUI52o6rCu6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PWwhxzmetzFpxnnxfRJbmufgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+pq+EPXYpxUckoO3AjbF3dJwahllXe6AFgC8d+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pyxf5VohmSlsxmpjTzAHeN5ak6UHpqKRi2GpwvH3Q3eT64RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pq5HOAjQyVnqfhHue7oAaKH5kiW0AmnLqaHomkj02g+e6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIghI+pyxfR0HsRzNnuXVqn3mVQZWFRyIDjp65Ga5Ly4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navback16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TBxObISevAQCBNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAwSHBRafBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnBRWfAwmPBRWdByixAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZiQIBwSCwah4HjUTBQFgkFg3MoKBykU0QhoUAIAuAksbpgNByPxQMSGVsVDYlkIqdUiJYLJqORbDgcHRseRR8gISIaEyMkGCVYRBEmeyAnlgaQkSgpmU4RAZ1OKqFOpFNGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navdown16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZeQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KJ6hokN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwahYGjUjBQGgWEpHNYMBCaT4G2UDggos+EwmBYMBpf6VBgYDgeEMgjIpmoAQVKxXLBPDIXGhscRB0eHyAgDSGBGyJFASMiIiMkJYImUwAnmJqbjp4AKCmhAKSlTn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navhome16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navup16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObAwSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixAQSHCQ2TAQCBBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZfQIBwSCwaj8hhQJAkDggFQxMQIBwQhUSyqlgwsFpjg6BwPCARySSstC4eFAqEURlYhoMLBpPRUDYcHXt7RgUeFB8gIU0BIoiKjAcUIwiLSQUkJRsmGIwJJwmEU6OkfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+py+0R3IFQUtruXVqn3kkWyIARR4rqKvoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playend16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+py8Eb3ENRggrxjRnrVIWcIoYd91FaenysMU6wTNeLXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playpause16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+py+1vgoxzyUCxrZd18ClfmIyVyJ1lqkHuC0N+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstart16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pyxudwlNyguqkqRZh3h0gl43hpoElqlHt9UKw7NG27BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playstop16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+1vgpySUWpvXXqrHmSaeJEYhKYq6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textblock16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py40Bo5SOzRvrwlgrfnkJOIkPaaaJXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+py70BowPQ1HZpwNv212Vg9IGHmIjoWa4ey5DSRNd+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textbottom16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIVhI+py+0Po5y0hYtzrkB7zH0fN/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textcenter16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsnRkqtDnhu1zHfFSpjaY4PavgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textitalic16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+0BgztwUmmjBXX3jE0auHHhM5Yq4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsgRoqr3Vnt102fFSJjUC6nlPoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textmiddle16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIXhI+py+0PT5i01pisphjt3UmfFZYm5hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textmove16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsg2kfZvblXbwTg10WlA4rjyvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textright16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+pm+EPIZstSrqsDhhv1ylfFE5jiYwX6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textsortdec16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BPwCBAQCBAQC/FxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CBDM+uKp8KiMsmaAs82dtnGeCHnNp4TjNQ4jq8CbDNOroIe3ROyEx2A4vOgkOBzgFxQ6Xa0owJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textsortinc16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BAQC/AQCBPwCBFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM4CAqxLm61CGBs81FMrQxgpnhKJlaXFJHUGg0w7DrDUmvtPQo8qyuEHoHW6hEVv+DQFvuhWtCFPwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIlhI8Jwe2/AmpTynqPTXSqrnBM+I0kdmpmGmUp+K4nPMvhYx9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+texttop16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIWhI9pwe2uYnq0yQtqxbz7D4biSIZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textunder16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pu+FxXoOIKpds1oBH7hlYxYxRCaIZ01lhJbHy9tTv7BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcGlAs6UAYgwLdLtEcI4ygQo7VVp2oupGpG4vmaUVTemX523qlFcw0a4RqNlkx5k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewdetailed16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMmCLrc/i1IAVkYg1Z1iRYUKCqitp1oikqBWV3ZOnhkWNagqu+qnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrcG1AwGOQbw6qANeCEB3pCSZpO6pgowJZqLKuUGE0dnuEhf8IL1kz1shSHDX8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag-16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ+QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7Kmpl0CtLGLvbW2Zn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ8QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7GLArS5Q7O1tmZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag+16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6cAsLECrqeys7WxpqZdtK9Ct8C0fsHAZn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmulticolumn16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrc/ixI0WSgKoyBl+beQFACpo1AqXbKCr1wLAMWS08hGG3dSZqin4sxnBmPD38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtext16:view view16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIchI+py40BTQSwuovp3DXkv1ia1IHmIXLiyWJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewtree16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBDQyNPz+/PzerAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAMuCLHcri4yGISlj4kxcANgNRBQCIbL6U1Su7bB62rXvGydG25kqpwfIGxILBr9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actattach22:act act22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTCxPz+/DQyNKSipAQCBISChFxaXDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARrEMgJgqA4zzus/gLhFd5HCcZAXqsphYPUdhcYFNRcZnvdtpnDqPTbUWgAJKBYwzBlw+bRo3xmkNWoBgm0OrVLn3GC9RgCk8DhUw7c0rHPr4CDu5SYQNyEt7uSY3p/UAKFhYKDSQOLiwgFdhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actbookmark22:act act22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBCQmJCwqLMTGxAQCBBwaHMTCxLSytERGRFRWVLy+vKyqrKSmpHR2dJSSlJyanISGhGxubIyOjKyurGxqbFxeXGRmZHx+fKSipLy6vGRiZLS2tFRSVHRydJSWlHx6fCH5BAEAAAAALAAAAAAWABYAAAWWICCOZGmewamaQrq+wUC8azHINGocOI38iIRAceDNaISFYklkGHOEhoNBfUAOhuOLEJE8HoPiRKFdESiQBqViuTDIUAsEcyAeGJmyiqC5RCwJGg0YcEh9D0V3Dxt6JwQVDRYVHBUdi40mjw0PTgwQHgeYJQQJfxUXFxAOoTkFpQ0fsRSimQkWEQ0VtI62HLt7vjl7JQYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmarknew22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCwqLCQiJCQmJMTGxAQCBLy+vLSytERGRFRWVKyurKyqrLS2tKSmpHR2dJSWlKSipISGhGxubIyOjGxqbIyKjFxaXGRmZHx+fPz+NGRiZPz+ZPz+HMTCBKSiHPz+jFxeXPz+XPz+tPz+zPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAamQIBwSCwaj4Gj0hgQLJ+AAaEAVQoI06pRYDhkoYgwIhEgKBTfZ2FhaBsYDS8VWnA8Go0FJIKeqyUTDw8EDHBpSwUUFQ4UFhcYDQYFfkoFFxEQDG8KEAUZlEeWGBIakw4FG1STiBoYBRwdBR4fHgUdHKBEBSCnIR8iIyIfIblFu6ceIyQjtcXGCbLKzAUKzrq+wMLEVa+xs7W31kOTk6nkWuOf6Ea5QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit22:act act22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBHR2dDQyNCH5BAEAAAAALAAAAAAWABYAAAJOhI+py90RnIMyRUOxhDfzJkACdoXBuEDDkQFDi5go0MrKx16kns80b7qdELCgBYaEGWwL5nG1ePFiKp9A6kuYRNuho8vxVrrZivmMRtMLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+acthelp22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBCQuNBwiJAwiLAwaJAwSHAwSFIy+3ERynCw2PCQuPAwmPCxOZCxWdJzG3FSazBwmNAQKDAQGBDRmhBQyTDxujDR2rIy21AwWJDyGxCxmjAwmNDRihAQOFDxmhCxunBQWFAwaLCRahDR6rESGvDQ2PCRWdDRunDSGvCRSdAwWHCwuLDSOzHSmxDyKxBxCZBwqNHSu1DyOzAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAahQIBwCAgIBAPCoGAgOoeBAyKhWCwYDUf0CX1AIhLiJEGpBLiAAaRxdgYsl7Ybk8igBZoN5xmAdDxoanp8HyANISF8EBsiXBMjJBolBEQmGHFoRScbKHIKDykqK5lFAZRCnyknTaROLA8tq61OChgtKqyzQgEYEJi6UC4vI3LAASkbMBPARAEBdszR0sACEaPSMTIQM8W6KzNl3bo0NOJDdEEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiF4gQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actredo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3Pz+/JTWbHy+VHTCTMTivPT69BxGDESuJDyiHESiHEymJIzKZAQCBFS2LFzKNGzWPDRqHCxqDFSqLHy2XESCHAwaBAQOBBQqBDyWJHyqZDyKFGSiVESeJBQ6BAwSBGTGPFyWPFSSLEyOLESGJBQiDAwiBBQmDCRGFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8hkMcBkKpcBwYAwEDif0YLhwEUkFItFMkAwMBoOR+PxgHwjRDggamhIJpQ8ZbKGKOQLcgEFdhUWEYgRF3sNfhELBHALAhgZFhobRBwREhQdEAIEHpIKHwsaSJwUDQgQIJINARxKESESDQ0dgCIjSpAkDAwPco+ZSJAlJicnKHIAIrNHidOIQxunT0kpCyrZSCss0d5Fj6jjRonn6uvs2QZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actreload22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBCRSFCRSHBw+DBxCFCQ6FBwyDBQWBBxGFCxyLGTChMzqzLzmvHzKjDyOTER+RERyNDSqXNzy3LzivFS+fCyCPBQmBCQiBBxKFBQqDOTy3LTitES2dDR+PCxuJOT25KTarCx+PESSTCxKHDSeVCyKRNT21ESWVDSGPBQyDAQCBBQSFDRuLDSyZDySTGzChCRiJKSmpExKTDS2ZGzGhLy+vGxqbISChDSKRMzKzGxubDQ2NIyOjCQiJCwqLBQWFCwuLKSipERCRERGRHR2dAwKDDw6PFRWVIyKjCQmJFRSVBwaHKyurAQGBExOTBweHFxeXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf9gACCg4IBAgMEBQYHhI2ECAkKCwwNDg8QBAOOhAQREhMUFQgWBxcHGBmbggkaGxwPB4yDB6SbBJIKHQaqtY0eHyAhsqrDgx4aCiKpqoQHAyMjJBMKJaSxzAAHIRsmJgonKA0LHSmDKiuOBywRLSQuLyEwwyoxMuiN6iUzNBXy5jU2bsgoJugABBz95uXQsUMGD3vpPPgTpKIGwx4+HMr4kW4YkCA2hAzxAQSIECI+imBTwVIFESNHerRUgc0cEiFHkjiiyYzeDiVLdvLcySSkkKGEWiZVweSGkIHMmvQosoQlkaZOjvhosvKJjIAxoOAsgpRZkQNLnvSoqspAIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actrun22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAwKDAwKBCQiHNze3AQCBBwWFDw6NPTy9PTy/Dw2NKyytOTi3LS2tMTKzMzOxLy+tLy+vBQODNze5NTS1JyalIyCbIx6VIRyVISGfJyelOTq7EQ+NMTGxKyurGxeRLyKPOSmROSuVOy2XOSiTLzCzNTOzDw+NCwqLHxuVOy6bPzGfOSuXNTW1LSyrMSWRNymTOSmTKSCTPTGjPzSnPzWnMyaVBQSDMTCxPz+/KyahNSeRHxeLJRyTPzmtPzarOy6fJyajNza1Ly6vLyulFRCJPzirPTOlMS2pNTSzMTCvJyenBQWFNzKtPz6vPzyvPzqtOzGlOTe1AwGBFxWTLy6tPTm1PzSpPzutPz2xPTSnOTSxOy2dPzapPzerOzm5IR+dPzu5Pzu1PzqxPzy5Pz+9GRiXGxuZKympHR2bOTm5Pz6/MzSzBwaFJSSjCQmHPz2/AwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeEAQKIjIIDBAQDjYMFBoMHCAkKgwYFhwULDAUKCg0ODxCkBQgRnoUSExMUDxUWFxgZGpAbFIuGHB0eHyAhIiMkIB8lJieIKCUpJCTGIyorLCktKIUDpC4YLzAxIjIyMzQ1NhgdpJI3ODktJTowOyM8Ejc9Pj9AQUIEclAocCMIBQhDiOwgoaKIoCI+jBxBkkSJkCWemIyq0GSHCBVHihRx8gRKFCmpKhGaQqWKFYZXsGR5kkXLFgRUXBUqkCGCFS5AjnTx0sXKlyA6CRVgAAHMAilhxIwhU6ZFkBY5kgKYUoXBAzMKzixZ4AJNGgVm1KxhM0WpmQpUMtooaOPGxAM3Nw60oYLGjNYCbzYJOgAnRzNBJ95oPYQCgpJtkwzFoULlRuRPiy9fNhAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actstop22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/CQKDBwKDCwODNyKjPzq7My+vIxiXAQCBOSOjPz6/OSelNySjNyGhMR+fLRaTGQ2LPz+/Nx+dNR2bNRybMxuZMxeXMxiZLQSFJQaHFwqJNyKhOSCfNyCfNR6dMxmXMxWVMRORLQODOR+fOSSjNR2dMQ2LJQWFMRWTLwWDNSCfMxeVLwaFKQODNR+fNx+fMxiXKQSDOSWlMRSTMxaVMQ6NMxORMQyJOTS1MxqXLwWFLRORMxKPMQaHMxKTLQWFCH5BAEAAAAALAAAAAAWABYAAAb2QIBwSCwajwGBcikIHIsDQmFKNRwQT2EgoVgsGOCG4wHBIgmRhWRCqVQsF0xGYyYGNgoGh9PpeCQfICEic3UAAWgLIxwRJBsbHSUREyYYJ3RDAQULexGejhueESgpl3WaCxsqJKKsChEUKywtmFoFDC4vCayikzCyMbWHt38NCTKiHhUfMyzBdQIFKsodob0VNDWzwppuKxMRrx6iNjcitNA4bh+iEzkwojc66JkOOxcf7G35PBE9KS1MEUGgIQOIFfk++KjRw9wJgUUIZvhRoyLDFCliQDQisUWLGCJOeNx4hKCGkyhPGnqCoKVLl1liypyZxUAQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actundo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3PT69MTivHy+VJTWbIzKZEymJESmFESiHDyiHESqLAQCBFzKNGzWPFS2LNTmzCxqDDRqHPz+/KTGnBQqBAQOBAwaBESCHHy2XBxGDOzy7HTCTEyyJDSqFHzWTAwSBBQ6BIy+dESKJFySPFSSNAwiBCRGFBQmDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMsBkKotMwYAwEDiXgYLhwD0gCFZiQKxNKBYMRqPh+D6G16y5AYnYIxBJAyF4AwITTAUJdBESD4gPFBV6Fn6ABBcJDIYPGEQZGhQbHAIdfx4JHw2VSBodGwWfAR4LDSALfkgYAQurBiAhICKfSSMkvQElGyYnGyi9Rxkdj4nOskUYyU9FpxnURikdGtjRKivdRKfQ2Inh5+jpRwZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBGxqbFxaXExOTEQ+RAQCBPz+/PTy9Ozq7Nza3NTS1KSipFRSVOTi5Hx2fJSSlKyqrJyenJyWnDw6PMzKzKyurDQyNFxWXMTCxJyanHRuLHxuLGReJFxSLFROJFxWJExCHERCHBQODISChHxyLHRqNIRyNHRmLLSqbKyiZLy6fOTarPz67Pzy3OzitKymZFxSJJySTNTSnPTy3NzSpMTChLSydKyqbKSaXJySVIyGRGReLPz23NTOnMzCjHxuPLy2vKSmpOTe5LS2tLSutHxuNHRuPMS+xFxWLIR+RDw2HFRKJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SDAQIDBAUChY2EAQYHCAkKCwyOjZANDgIEAQoPjJiDAg2iggQQp5gMBwmrDBESl6MTFKuoFQSjABYRF40CGAW8BRm7hQwNxBobHB0eHx4gISIjBdiEAhYFJBslHOHSHh4hBSHlxIUmJygpKissBiwtLi8pGjDqhBoxMjMuaNSwcSMFjhw6dnjYRyrGCh4ueviw4Q5HDB0/PjAUJCBCAwMIGiiggAEIBFk/FgYLIgRkggQkhxAJkqGExkYMFnxsIGRkSQgLHhRRWUjAggQgG8AsSWRBBiP6VrYMOfKIyaBDNwLo+HHSUplOSyDRqiEHjRkretRQkcLgxayNF0wksQGQxsSKMTIq0QpgCba/gAE7IhMIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbook22:app app22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBDyGhCyCfFSWlESOjDyKjDSGhCx+fGSinGSenFyanEySjHSqpHSqrGympEySlBx2dISytHyyrCR6dKTGxHyurHSurHyytGSipCR6fARmZFSalEyWlBRubAxubBRydDyKhDSChLSytPz+/MzKzIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbFQIBwSCwaj8ikMhBQIpmCQdM5ZBIKhgNiugwkFAsCI7pNMhuOxkNBgBgEiAi3GkBLJpJHYgEpaClyREwVFhcSEhgOGQoMfgMaERtcARQBFRMYExZ6HB0FUYAekkIBHxqWFmlrC1haESAfG6MBGx+VFRgKYH0hInGRklO0ppYXCwwMWQiQHkwjgrWnFRdYZHIBJCTP0LaWGAcDW9jZ2nMAw9IWTOQkJSZMRsOV49nu8E+19PbmR7TY+1TovONH5V7Ag0QMBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbookopen22:app app22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBHSurIS2tBx2dBweHPz+/Ozm1GxiTGyqpPz6/Pz69GSqpOzaxPzy5HxuVLSmlOTazPz27PT29NzClPTexHxuXLSmjAxqbFSinPTy9KyehNy+lPTy5Pz29HxyXNzWxKSahOzexPzy7IR2ZOTWtESenPTy7KSWfIyCbKyijAQGBDyalPTu3KSSdDSOjJyOdCSGhPzu3OzizJSGdPTq1PTq3JySdMy6lAyKhOzWtOzi1OTOrJyKbMS2nJySfMS+rAwCBNzOrNTCpNzKpJSGZKyafLSifLyylIx+ZHx6ZDSChAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IAAQFjI6EAAaJkQeTjwAICYkKBQcLm5WdBwyfhgChB66bp64HCQC1lQ2irqQCAA4PowsLEBESE4wAuLIHFAAVFr+uDBcYxRm1GrmuGxwdFh4Mrh8gGCET1gDYyhsiFSMkDAsMDCUYJhvnJ9kHKCnODwwfPlBQsULCPRYAWogK9sHFiwoOPEyQh0JFPXO1YBSYwBEFghjdHkwQOYGgwQwIZRR44GHGDBogabhAsYEEihrUMAIoUMCEDRs3HODIYQHFA6MPcJA7KICFjgw7eIzo4cOfiwc/gKwIUm2SkKdDdlDt4AABDaU/iIRwwbTSUyJFOow4S3Hkx9oNDDZgXPU0h1wcSIgEGUw4ibVET5WoWMKksePHpdxmyKADAEIWly9HJtQkQJMmlAgZCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil22:app app22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/IQCBPwCBPyChMQCBPzCxAQCBPz+/MzKzISChKyqrDQyNEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARYEMhJ6wxiEMtpIAWxddwXiqRlikSQeiAbuC+wirNR322gv7zcLobzDU+9XypoBBKTR1lz+RTWDgip8nUwZK1XLyIx5XoVicX2RUAo1DVKi7GOBxjxfNwQAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptool22:app app22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBISChFxaXNze3NTS1Ly6vKSipNTO1Ly2vNza3Pz+/MzOzOTe5DQyNOzu7MTCxGRmZMTGxPTy9Ozm7Hx6fPTu9MzGzGxmbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAW1ICCOZGmeaEoGbBsI6joMRGEcbQwESDIrtVtAF1gwDLNaAmfKiVgLBJKgwB1KxQZrBHU0FAXmavFoQLYiB6TxFXMj5AZBwnJI2I3wcNWALyYEcgoKXxRhOHs7XxEVCwsWFgoUDRYUFwwQB25ZCxiNjo6GkwUXN2NsCxEYqhUHoQ0MEglYRQQXErcHrI55FycuB2YSmoyOBTEtB2sXuhU6XAENC2a6z9AKCwq+1tAN3E2J3ySkIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connecting22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxOTi5AQGBNze3Ly6vISChNza3FxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAAR4EMhJqwzY6omD+MNGdR8YilNZnug0qGzrqrL1lnV1fyJBVB6VQEMoGH4ADGwQkxQPBwMiKGA2J8VEAnq0tgiKg5aL/C7C2gTjKCM0zowDQ8tuNQznNL7cKzjOUQsNfER+gguIg19+Pm6ChBZFDmWNi5M5FIyYFHQRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBERCBAQCBPz+/MTCxOTi5Nze3OTm5Ly6vNza3ISChFxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAARiEMhJq7046827/+AVCKE0Dh9BAGdaGISAToFGFMcBU+11I4hDYseSZQiKwwKoI/QwBIYiuFDCZseGdIlYEjUNg1SpY6w2N4cUIW6cjwW1lsFwo+MqgtZuw0/ydw5vH34lBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+connectyes22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBKyirPz+/KymrOTi5KSipMzCzNza3OTe5Ozi7MzGzPTq9OTm5ISChMS+xFxaXNze3GReZIyCjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWLICCOZGmeaBkAQpoGg7C6JizTQT7CxPwOwFWgYPChYIXkIHC4uQKGAiKRKCyNpxxUUVViVYNFLkqtLo+DAkMMLXQPXwAy2WCTF4544FGtKuwPDhB6DnxuUmyCcXIQhV1uYoMuEAcOBxEKCHg6TzGFCJUSizuejROKOAM9OY2SnUU7nD89NCcDsLUnIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscreen22:dev dev22 22:photo:22 22:R0lGODlhFgAWAIcAAPwCBAQCBPTy9PTu9Ozq7OTi5Nze3OTe5Nza3NzW3NTS1MzOzMzKzMzGzMTCxMTGxOzm7AwGDBQOFBQSFCQeHCwmLCwuLDQyNDw6PERCRFROVEQ+RDQ2NLy+vKSipISChGxqbExKTOzu7OTm5Pz+/GRiZMS+xLy6vBQWFLy2vCwiHFQ+NMSmfNSyhIxmTDwuLJx+bLS2tCwmHMyyhMyqfPTqpPzyvLSWbLSWfPzitIx+ZDw2PAwKDCQiJGxWRPTmrPTerMyuhPzqtPz63PTWnPz6zNy+nIRiVDQuLKyWbOTanPz21NS2jNS6lDQqJHRaTPzmrPTSnPzyxOTClPz2xNSuhPTqxPzuvOzSpAQGDOTKnMy2jOzSrPTu1NzKnOzOnBwWHJRuXLSWdPTatPzqvNzClCwmJOzSnOTOnPTuxOzKlOzerOzarOzitJR6ZNTO1IxmXPTWrNSyjPzOjPTSpLSehHRqZOzirOTCjPS+fPzGhOy6bOzKhGROPMy2lPz+1PzmtKRyRHRiNNTCdPz+zNzCjEQ2NKySdDQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAj/AAEIHEiwoMGBARIqXMhQIUIBAwYQIFCggIEDCBIoULBgAYMGDgIIDEBAwMSKBRBk3NjxAciQIwdACBBBwgQKFSxcwJBBwwYMHBx0EAmA5EwPH0CEsCChoYgOQ0cSGCHhA4kSS5syJGDiBNEAFVGUKKEBAwWFFM6SNJHi64gDFEKE4FBBggoKK1i0cPECxokYXw0gsECYggQZM2jAqGHjBo4cOtqOxLhDAg8ePXz8ABJEyBAWRIoYOfJipEoMCZEkuaFkSAslS5jUGJKkSRAnRREo0JDwCZQoTKQAmUKlihQrVa5gKZ1lI+oAK7QM2cJlSZMuU4Z4+TJEx0iNOwKAggkjZkyOFmS8kClzpcUQLRRGbjRD4MgZNEzSqKG+ZgobI2248dUbDDDwABzcxSEHEFpgEcUcdMRRhx1fFejAAx0cgcYdSxiBRx566LEHH0d8QFRRNC3Uhx985CHEH0MAEkhCBxWkgiCDFEFIEYUYUmONMhyCRxVH/PgjBYioYJAdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxaXMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyylPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbYQIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBscAY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4gKIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATyVoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editcut22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkcpkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editdelete22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzKxIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwCBMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyynOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMNEqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqzkBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0SF+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsygsVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDYCKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBISGhISChHx+fHx6fHR2dGxqbGxubGRmZGRiZFxeXFxaXFRSVIxSLPyuXMzKzMzKxMTCtExOTPzqrPz+/NTS1MS+tOSaVPyWNPz6/IxeNPzavPyKBNTW1PyCBPyGBJxmNPzOpLx6PNRqBMSCRNySTPyCDPSGBMxiBKROBHRydPSylOyydMxmBJxKBAwODPS2lPTq3OyabJxGBPTy5PTGrOyOXPR+DPz69PzmzPzevNxuPORqLMReFPzy7MyCXKxiNIRKHBQWFNTOxPzixJRaPFxONHRqVPz27PTy7PzStCwqJDQyLJSGdIx6ZPz29PTu5HRmTLSKbMSGZHROPFxKPJSKfJyShKyehMyuhDQmHEQuJJyOfLSijMSynMS6pLSefDQyNHx2bKSahLyqhLymhOzi1FRGNIR+bNzKtOTOtOTKrOTKpLyedAQCBFRWVPTq5NzOvLyunLSmlNTCrOTOrNzGrLyidMS+rLyynKyijLymjLyqjAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gAAAAQECAwQFBQYHBggJCgsLDAwADQ6CAQ8QD5ydEJ+gERKWE4ICDxSpqhWqqhYNFxMYphCtqaytGRoXGxgcggSoth25u70eH8APFR0VzMzNziAXIRjIvwAFwq3EqSLUGB/iI4LathS4JCXVJh8nKCmCKrXDFCss1eIfLS4v8ssdmgWsAGNDDBnt3s3wJ+jAtlUhaNSwccNEi4WCBBl4SAHHihw6ZOzg0QNjRgAG6KXK4CNEjBU/gDQI8kLISQAIADobAoMIzCINjLw4YvNkAno4kCRRUuNHESNLmDRxUjSjAlRPfECJImUKlSpMrFzBIqWqoKtJaWSJomULAy5XXrp4+QKGYcYFoCBEWRImi5gmY7CQyVLGriAGD2jEMHMmCxc0Xb6kUbOGTRs3N988gLM4jpw5Y+iwqcOGjZ07mE8yiGABz5c8c/Ts4cOnDJkybS7fdMO7t+/fvDMaCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6/NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz27Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTStNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4FDxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wrLS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCNDiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LAQOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpgweLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBFRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanOze1Pz+/Ozu7BQSFCwqLDw+POTi5MzKxPTu7LyyrIR+fCQmJPz6/Pz69Pzy7Pz29OzaxPTu5PTq3PTm3My6pPzu5PTq5NS+rPTm1PTi1PTezOzWxPz27MyynOzSvMyulOzOtOzKrMymhOzGpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbpQIAwIBgMCAXDAZFQLBbCqJTRqFobjgdkEYFKowPJZEyeUBqVR/crHDTKZYplovZKCW84+YKZZNZSBXl6EwEEBhVPXxZihGMaGRscdkIdg4QeEnVfCH2OHyAhIhuUAAiXZSEhIyQlJqWnjiEnKCWupRWoYyEgJK0SKaUKjam0JCorLMFfC6iqx8giLa/MGAsT1wsuCyULKwssC9RSzdkfCyALKuALLQsvpeXYIQso3gsiCzALMfENC+dGcMNHUAY/f+jq3ctncMYCGggFrsvHcEGNh/EyPFmg8cmrJxAVkVO0EUDJklHoBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+edittrash22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBERGRExOTDQyNISChBQSFCQiJCwuLPT29Nze3GxqbDw6PGxubHR2dJyanLSytJSWlJSSlOzq7Pz6/Nza3Ly6vFRWVBQWFIyKjMTCxHx6fIyOjLS2tOTi5PTy9OTm5Hx+fNTW1KyurKSmpJyenExKTMzKzKSipFxeXCwqLMzOzKyqrMTGxLy+vHRydBwaHNTS1DQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb8QIBwSCwaj8KAMoA8LgUDQsFwQByay4RiwWg4GA9IRGk0SCYJSsUCsVwwGQ1EsmESD5xOp+L5gDwhBRIZDhcDdkMGDgEiIxAkJQ8Ok5MmAohDAQ1xJxUlKCUlEg0pKpiZJRoLCxmtCw1eURhOcR4rbQ8cGRwLAwgGtBYTDywtGRKjvQTARgEZLhMcKC0OrQMvAirMRc7CHCTU1g2+20TO0NIn1RwDCya/wdHT1Rnt5LToKOq79trx0tR02YPX7Jm8fRxMOIhSLhOJE/LCJSTlr5kFEBQsWDiR4UGGBgsuHDg1BEYAfTE6oEBR4AIBAiS5yWBAAAGBAyaPGAgCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fileclose22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBERGRERCRDw6PCwqLExOTFRWVHRydGxqbGRiZCQiJISChIyKjHx6fDQyNBwaHJSWlKSipBQWFJyanPz+/JSSlCQmJAwKDCwuLBweHBQSFGxubExKTISGhDQ2NFxeXFRSVDw+PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbZQIBwSCwaj8jkMSAYDAgEJbFgOBwQCUOAoJAaFgvGonHIBhyP5BcSgUAYDWxggD4WFmx3e3HQngkSRgYMEBMUFG4MCId0BGlEAQeEhocVDYcUdBYKF0QCB3gRlJgUAQEYBBkaRAMbDZMMpAYcT46rQwMJrgsdC6QcfwoPnUMOBgkIV6SHHg6bw0QEAQYfBpggBZjPGsRD0gEchxwCIR6HChnQRQ8DIU4DTR4Em+ncRw8O+fmoXPXdRg+gQLFgIYM/KRIkoDP4QMKFf0o0aBAh4qGUixgzCrETBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filefind22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJyanLS6vLzCxISChNTe3OTu9Oz6/Nzy9Nzy/NTy/OT2/Nzi5Mzu9Lzq9KTe7LTq9PT+/Pz+/Nz2/Mzu/Kzm9Jza5HzK1LTi9PTu9IzW5ITO3FxaXNT2/KTi7Iza7GzC1LzW3FRSVMzO1MTq7HTS3Fy6zFS2vKzm7Lze5MTGzHzS5FTG1Ey2xEyyvJze7JzW3ITa5FTK3EymrGS+zFxWXKymrMzi7ESirEyqvLSyrKze7MzOzMTCxKSepAz+/NzW3MzKzBwWHLzS3ERCRAzi3KyurNze3MzGzLy2vLSutCQiJAyytHRydOTe5MTGxLy6tLyqpKyelJSCdOze3NS+tLyupLSmnKSOhCwuLPzy9Pzu7Oze1OzazOTOvMyihOTi5PTm3Pzi1PTazPTWxOzOtNSunDQyNPzy7Pzu5OzKrNzSzNzGvNS6rMyynMymjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwGFhYOIiYQBAgMEAwKHiokBBQYHCAkKCwwFAZOEBQ0IDAsODxARCZ6gAAEGEhMSFBUWFxgZCJ+TjBoMEpkRERscGBGRih0BBAgeFBQOER8gISEfIruIIwEkCCUVwhcgJicoKSrZg9srCRkRGdMsLS4vMNiK2wIKMRsbMiwzXtCocSydIBs3AuCIwIFDiBMucugAoWvSiB2VNPDg0ELHwA0MkCXr4aNSggg8NoDIQOFHgBtAkgURMiDAEAFEVBCJFKCIkSMGOyDRkETJEkOFmABoUsRJQkQdnkzQACWKlBtTplBR6qopxkFRJ0ytYuWKFCxZtBBq+hRA2AlbRrh08fLlCxi1a51g+dQhDFwuYsaQKWPmDBpKXgNETaNGjJgyhNfcVdTTiWI2XpK0cePmzRk4YA5T5otGixY0qFOXbgXAQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filenew22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBExOTERCRDw6PCwuLBwaHAwODAQCBOze1NTW1OTi5Nze3MTGxLS2tJyanPz+/Ozu7OTi3BQSFCwqLDw+PDQyNFRSVPTu7MzKxLyyrIR+fCQmJPz6/NTOxPz69Pzy7PTu5Pz29Pzu5PTq5PTm1My6pBQWFPTq3PTm3NS+rAwKDPTi1PTezOzWxMy2pPz27PTazOzSvMyynOzaxOzOtPTaxOzKrMyqjOzGpMymhPTizOTCpNzSzNTGvMymjMSihCH5BAEAAAAALAAAAAAWABYAAAboQIBwSCwaiYGAYEAgFAqGg/Q4DCASCsTiymgcHAcqQLB4mM+QiIQBppLPcMjkwQ4bB2X4maKgt4sVCHpnFhQTElNFE3mDDxcYGRp2RBuMgxwIHX9EBZZwHh8gCBmTQ52NISEiIyQlpUImng8hHyInKAgprwAqgnC0IKwrLLpGB4wctLYkwy0uuwd9Z8AnJywsLcVFx2YcL7UnJCwwLTEy0GXJoSgrCCwzNDTnxgjeH9UrKzXwNDY36LRGhEOwLx4NHDmgJbh3QoeOgv127EhojEeHDj16pEhRQoZHHzl+QJNCsqTJSXaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQWDCwaDDwmFPSubPzGhPzCfPy2dOSmZPzKlPzSnPzOlPzKjBQODPzChPzWnPy2bPSmXPyuZOyeXIRSLEQuFEwyHEQqFDQiFCweDKRuPFRSTPT29PTy9Ozq7OTi3Nze3NTW1MzOzMTGxMTCxLy6tLSytKyurDQyNMzKxOTm5OTi5Nza1NTS1MTCvLS2tLSyrKSmpJyenJSWlIyKjHx+fFxeXBwaHKxuPMzKzLy6vIyOjHx6fDw6NPy6dGxubLy+vISChCQmJNza3KyqrBQSFLR2RKSinJyanGxqZAwGBJSSlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeDAYqKiIeLj4wBjQCMhY+NkoiLk5qbhQIDoJyGBAUGBwgEo4MECQoLDA2pDrS1tKQPEAwHERITE77AvxKqhAQNDA8UFRYXFs8YBAQZGqGPxw0RGxwdHR4eHyAhIiMkJSYnKCgpBAYPEhcqHyssLS4kLzAxMjM0NTY3cBA4UCAHBw8gVnhgEcKFjhc7UPDj0cMHAAI/KFgY4YLFio/jRpTYsW8GDyCSCEQw2DChOHIqgsCQSEPIEEEEJFhAoUNECCJEyOk4d6KIyRtGcB7hIJKjixEjHu4oimSGEIs4d8IIUoKECnNB0ElMwkNJJgBLlJBAcQKGiR07KGAURVGViY0mhIwwSTKjr99+THjUoIg0r48hTRIrRtxkiOMhDgrZCQQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileprint22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTy7PTu9OzezPzu5OzavAQCBPzy7PTm3OzazOzKrPTu5FxSRERCRGReXPTq5Pzu7ExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzOtOzSvLyyTMTCxKSipGRiZFROLPz+/KyurJyenJyWnGxmbLSabOzClOzm7LSutJSWlJSSlJyanGxqbNze3OTm5IyGjNTO1Nza3NzW3OTe5IyKjHx6fMzGzMTGxMzOzNTW1IR+hISGhKymrLy6vLSytERGRGxubKyqrLy2vLS2tDQ2NEQ+RASKBAT+BFxeXHRudAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4ODxARApKUCaGYEAsSCRMUnQysCwoVEhYXGLOLCBCgDqK5GQUXGooCAhscBB0euBUZEAUJvQgIgx8gIR8iCSPiHuIFEREDJCXaANwhJhsnKCnWERcRKiopFCvsBywhQrRwQWGAPAz5EhpQ9wIABRgKYsiYMTEEDQocatiwkUIEP18fbkCAAcMBjhwzdOyQwYNCgBMfKJSgMItBjxs+btwgCSGGjhw/ZoRgQKGZCRMUPgABEgSIkCE3SZok8qNqkR85NtDUEcPIkaVAkCR5SrJBDCVKlmzQ6pCCiRlMTJo4YUH3K5AeMBYYWctW0BOaUH60cBJFypQmII6wyEpFQBVFMSm4UAI3hJUrOGh8oOJrklYKWIromJGDR99Ogz5j4ZGlM+pEnwmBCwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBGxqbAQCBLy+vERCRExKTHRydIyKjMTCxFxaXGRiZFRSVFRWVPz6/Nze3Nzm5Pz+/JyanDw+PExOTHR2dMTGxBQWFLSytHx+fISChOzy9Ly6vAQGBJSWlMzKzAwODJSSlHx6fIyOjOTi5DQ2NISGhGxubCwuLOzq7ERGRFxeXNTW1CwqLPT29Dw6PGRmZKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBQGBAMj8ikUDAgFAzKKCBwQCQUCcICKh0SEAhGw5EIZAmBrgCxeDQgcDJWyz0GIggJfL+XGwQJRxNgC3yGDwwUFUZDFhdthnwMGAZNQwEZFwQakXANBBQbHIIdERIBnRAOiR4ERx8gsSEMBBmGCyEGG3YGBwcgIr8UCwQHECOgG4xCtRkEJAvBJRklJgkSFBQeJ68hJiEoESkFKiEZIbkGARsLlwEGExENGhorGSkpFAYm66NDLAECpGiBYsUIFA8wLHBBQMWLVkdUCFCwaYVFBOymkVCgYEMgOykEpICBccMBAhhELFigTEqAAgIIwCiQ4eRKDyS6EAlJIAI0EpaudF4iIKDAAn9CkRT5eMROEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+foldernew22:folder folder22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBNzaTPT2FISCBCQaDPz+BExKBDwmFPSubPzChPzCfPy2dPz6BMzOTAQCBOSmZPzKlPzSnPzOlPzKjBQODPz+rPz+3PzWnPyuZPSmXNyaXPTyhISCLIRSLEQuFEwyHPy2bKRuPFRSTPT29PTy9Ozq7Pz+xJyanDQyNPzGhMzKzOTi3Nza3OTiVBQWFDwqFKxuPOTi5JSSjISChHR2dGRmZFxeXPS2dNTSzNTS1OTm5KSipLS2tLSytKyqpIyKhGRiZNze3NTW1MTGxMTCvLy6tIyKjCQmJMTCxMzOzMzKxJyenHx6fLR2RLy6vJSSlHx+fDw6NLy+vIyOjAwGBGxqZKyurCwuLBQSFJSWlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLjI2MAY6HAgOHBJYEhJCDBQaDmgcICQoLB4MGDA0OAQUBDg2cAAcPEBESE6QUuQasFRYVq5SxCRcSCggYGRjIGgYbFs8bHIMHExIJGR0eHx7cB83PFhsDDuTUEyAhIiMjJCQluwEmvsAnKAcp1x4qKyUrLLupWrByxcnFiwQIYIggEaNEiRgBZMyYQaNADRs2REA6cCODBxw5+OnQgWMHjx4+BND4MQOIg1gI0gUREkTHiplDhhApEoCGkRlHBL3I8MEHEhz+WAhJogTJySVMfthwIehAExE5jubAkYQpESc8fOx4AiXKNA8+ekhBgqSpzh5hPHcsmVLjpSAqVZBY6VGkiJMiPQKLnTvjCiEsWU4o3nGC8YksMmT8YCmC6iAXKLRc2cz5yGYtR0JjKWQgEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mailforward22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBJR2dLyijPTixPz69Pzq3Pzy3Pzu5PTu7Ozi1LyelOzavPz+/DwqLLyafPTmvPz67Pz29Pzy7LSWlPzmzPz6/LyajPTitOTSzMyurPz25PTatPTi3KyOjPzuxAwqVDQiJHxiZPTetKySlPzqvPz27BQ6bAwmTPTexLyinNzGxDRunPzy5KySjCQ+ZNzq9KTO7JzC3Nzq/Ozu/LzW7FSm1BR6vGSWvFyq1AyGxAxytAx6vBSKxAxSjMyujLSunES+5BSi1ByGvAQCBNzCrOTaxNTOvMS6rKyelCx6rBx6tBQKDOTWvPzu1PTq1OzezAQOHAxGdBROhAQGFPzy1NzOvIRqXLyynOzarPz21Jx2XPTWrLSShAw2XKSCbPzuzAwePAQCDPzyzPzqzPTmxOzWtAwGBKyObOTSrNzGrKyGbOzatEQyNKyCZOzWrOTGpNS2lCweHCQaHCQWFBwSFBQODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBhBwgQKFSpY0HgBQwYNGzh0mDhRAAUPHziACEGBpYgRJDiUGEkSwoCQJk6opNASRQoOFETQJDkggwoOJlYApcCihQuVL2DUhBDjhIqjJmRwwDCDhswaNm5MjYHjKggOOU7o0CGTA9gdYknG2KCCBw8VJVL0uBgihAUfP+CSNGCjsI/DiBPbAMJBsEQbQYQM+UG5smUiRYw0jlvYxhEkSYyIHm1EyRLTTH40EZvAyZPOR4pAmU07ipIkUKQ0mQIhAZUqVq5gKXzkSBYtyLVEyd1ki8QFXLp4+WJFQowbYLJnD5NbzJiJCjaQnhnvpYwZM0/OPFlvQ/f3iQvQpBlvQc0aCWy4VKnCpY0Y5yQxgEYXZFjghgwZUOHGCW90YQEccUwloBwGyjAHHXUoSAMZb0xhx1QOoMHDHSfIwSEOdTjhAQ1d4MFbTQ6Q4MYacrzxhhx04JCHHhvQsMeLJPHRBxpr+LHCGnusgccfgKixQR1ATtTBlDDAEIggggxCCCGFbLGFHVFKZEdAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQ6bCQ+ZAwePKTC5Ozu/NTi9GSWvAwSJGSu3JS+5CR+rAQOHPTy/AyKzES23AwOHCw+bOTq/BR6xES+5AwmTBw6ZMTW9Ax6tByi1BRGdAw2XAQCBDQuNDRupKzS9FSm1BR2vBym3EzC7CSGxBROhNTW1Pz+/OTm5NTO1AQGFNzW3Ozq7Ozm7IyKjJyWnMzOzNzq9Nze3OTa5Ly6vCQiJGReZISChKyqrAwqVBRWlOTi5MS6xJSWlNza3OTe5Ly2vGxmbKymrIyGjMzGzISGhKSepCQmJDw6PHR2dJSOlPTy9MTGxLy+vLS2tMzKzLSutMTCxLSytKSipJyenKyurJyanCwqLCwmLCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBhgIBA4SLjAABBAUGBwiNlY4FCQoLDJaNAQ0ODwsQnYwREhMUE5ylFYYRFhcYGRgaGxsDHJUdFR4SHyAhEyIjJCUcuo0cJr0nExihxgwoyYscKSnMHicOIw4lKissLdWDHC4vMCu9McYqMjMyNOUANTY3OPEoOTolDCszdrSgwaMcBxs9TMxYOCMHBx8zfPj48QNINQ5BbMBIIUShDIUoTAhR94PHPEEHbQwZckOGjBQviMxYUWQIDCMmdXE4gqRnkiFETAxR8iKFjJU2evZEdmLJkgJIbqS4wXJIUapImj5FtuSEVyRVV1IVi4RIChhEkLVAgcJHEqVwVJUmYdKkiRNkALMRecKECRG/ff8CEQJFCA5kMKJEoUHDCQ/HkB9LmWKECpUeyKoIMSLEyosen0OD7iH2xg1dV7BkqXGlBpbWNTq4Zn2khu0aAAwEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBDQyNCwqLCQiJBwaHBQSFAwKDAQCBDw6PPz+/Pz69Pz27PTy7PTy5PTu5PTu3PTu1PTq1PTqzOzmzPzuvOzitPTmvOzivAQGBDw+POzevPz67Pz25Pz23Pzy1PzyzPzqvOTavERCRKSilPz21OTevIR+ZExKTOTi3JyanLS2tPz6/Pz65KyihJSKbMS6lExOTNTW1JSWlJSKZMSylNTOrNTKpFRSVPz29MTCxPTmzKymjIyCdOTWxOzexOTWrBQWFFRWVOzu7MzKxJyalOzatLSulMzKtOzmxOTarFxaXKyqnPTmtIyGdIR+bOzetOzixBweHGRiZOzm3NzWzNzSrOTetGRmZOzizOTexOzm1JSKdGxqbHRydJySdHR2dOzapHx6fKyijOTixCwuLHx+fFxeXERGRDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLAQECjwORAwSUBZYFBpkHmwgJCgsMDA0OD6UQERITFBMVFhcVGBkangq1ChsLGxwcHQ0dHR4fICEGIiMSCbS3uLq8wCQUJSYGJygpKhQJKyvLLM4Nwi0uLwUwDQsxMtmeuQveHR8UMzQ1NgU3Dgo41jk6ns0cKOzgYaOHjx9AgjTAUUvIECLZNmxoUISHkSM9KiBJQkCJA4kKEoBQoWJJAiYtmjh5AmVCsCJRpHzckKCCySlUUvBYUqUHDysSPnxIEuXKA5pPRiRwxwFLFhRaIEDYUoEChCcDuECoOWKFuwW7nHkg4WELkw8/BHRRwESpt10dU8SSHevlRxIBX6C0WBE27q8GZMkKbTADjIAwYlb4GLMYShYoPTRo6FGiSJEKPyzMIFMmzJcvXbhwkSLFjJkbQW6cOHNGhAgEAdAsmk27tm0ABgIBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailreplyall22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBLyejPTixPz29PTu3Pzu5Pzy7Ozi1LyelPTavPz+/DwqLPz67PTetPz69ERCRLSWlPTmzPz6/OzexLyajPzqvDw+PDQ2NMyurDQiJPz23PTatJyenAQCBPTevPz25LSajOzq7HxiZPTexPz65JyanBQ6bKSmpBwuTOTi5OzaxBRCdHySvGRiZHx6fBQSFERGRNzq9IyOjHx+fGxqbPzu3BwaHFSq3Aw6XAxKfPzy3Gy63ByWzJzO7Mzi9OzavBRytAx6vCSazGRKTPzy1AQKHBRGdBRyrDy63ES+3Cym1CR6rBwWVAQSLAx+xCyCtBRmnPzuzAQWLAwePPzyzKSCbAQOJByGvOTWvPTmxBQODFQ6PPTWrPzqzOzatAwGBKyObLSWfPTivKyCZEQyNKyGZOzWrOzWtOTSrOTGpNS2lJx2XDQmJCweHCQaHCQWFBwSFBQKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpkzGjhAoYMGjZMpMghQgcNFjh4mODhA4gQGkSIHAmBwAgNJEpo8KDSxAkUGjhMSEGz5gUVIiKs2PmBRQudHiwQpUnAxYsXImB0aBqjBcuoU0fKmPGChgUNH2qIqGHjg9u3bicWIFs2rYgbNnDkyGFhb8cccQ3ouJqWQo0dPFr0WMy4h48LFj4gsKriB5AeNngEaSGks+chPnwQOXFAh4oXRYxk9nAEyY7XO2wksWHDx5ATCDIoUXEBsYclTJo4cWJhuIjhSXacSPBEiZLMQY4wgRKluvXqUpyIsDElAxUqVaxcwcGCPQuWLOixaNHCZAsXBU+oqKDSxQqULF6ifNmyn/8VMOtxwcAK36kQRhdJQIFFEmKM4eCDYGyhhYAEkqFEGSuYYcUZLaDxXRpqSNRCEu6twYaFZXTQhgRd2NCCG9918AYELTjoXgNuKAFHB2RQEUYHVbQQRwlUpPHGGFwkyQUEDsgxx4lh9BhCBy2U8UQJcrSg5JIQ0FEHG3bc0QGYK+CRhx57PEGlkhM9sAEffKTQhx9+/AEIIIGoEUgLLRRFR0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBMSihPTixPz69PTq5Pzy1Pzu5PTq1Pzy7Pzu7Ozi1LyelPTavPz+/DwqLLSajPTetPz27LSWlPzmzPz6/PTexPz67Pz29OTSzMyurPz25LyajBRCdPzuvDQmJOzexPTevOzq5BQ6bBwuTDQiJHxiZPz23Pz65LyinPzmvBxCbHySvAQCBOTi3OTq9CweHOzaxFSq3Aw6XGy63ByWzJzO7Mzi9OzavNzq9BRytAx6vBR6tPzy3AwOHDy63Ax+xCSazCym1CR6rBwWVOzizAQSLES+3CyCtBRyrBRmnGRKTPzu1MzGtAxKfAQWLAwePPTizMy6nByGvNzWxOzWrNzOtBQKDJR2ZNS2lPTmvBQODPTatKSCbOTaxLyqlAQKHFQ6PPzyzPzqzPTu1PTivOzWtKyObPzuzOTOtLSWfPzqvAwGBKyCZPTWrPTmxNzKrEQyNOzatOTGpJx2XCQaHCQWFBwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYuIDBQgYNGzh08DCR4oQPIDqEmDBhJQYRIzqQIFkSAoESJCKkDGFiwgkUKTpMwECz5IASKjqsSMlSA4sWQjG4qGnzhYoQSmF0iCFjBgmWGWhQrVHCxg2sOHLo2MGjB0sLYmsWQHq1p4wdPtqemGDhB1UDQFSouKHi7oQgQmSwUMyYxcQDZQWz2EFiCJEiRoyQyLzZyGIIB47YKLwDSRAiSZSoXq1kCRHNLBK8YGKjCYskTp4ogeKkt+8oUaBImZKAAxMmVKrctqL7ihTnz7FkAT5FC4cKFbZwadIFdxcvX8KLss8iJcoUBUcq2KgAJoxyMTy4jCFTxoxEHl2GLyCDncmWM2hUIQMPY2CXhhoTfTEcA2tgVwEba7Thxhs88FdBD/ZB8MUUHMJBRhw2sAGCHBKU4UaFc1RAhxnhcdhhHUzYAUIcFdxRAh4R5KGHinu4OIVEDqTBRx81xhGHHzD8wQYQetDRI4cTAcIHGWT0EQgZa1ApCBqDcBAID1Q94IEHLtBAAyGEFGKIIWqYYQYPYNZkQEAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailsend22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAIR6fIRydHxubHRqbHRmZGxeXGxaXGRWVFxSVFxOTFRGRExCREw+PEQ6PDw2NDwuLPwCBLSijOzixPz69PTq3PTu5PTu3PTu7OTi1KyelOzavPz+/DQqLPz67LSafOzetPz27Pz29KyajPTmzPz6/NzSzLyurCwiJPz25Ozi3JyOjPzuxBRGbAwSHOzexPz23KSSlPzqvBROdISavBxSdAwaLHRiZLSinNTGxMy+vBxGZNzu9BSGrAwWJMSyrKSSjFy61ETO3BRWfPz65PTqzHTK3ByqzBSWxEzW5AQWJOTWxBRCXOTu9BSOvDzO3ByavBRKbOzaxOzizKSWlCQ2TAQCBJza7BRWdNzSxJSCbMzq9BSOtCSKrAwiPOTavPzy3LymlCySrAwmPFRKTPzy1NTGrPzu1JR+bOzatPzyzCy61ByGpOzWtJyCbPTmvPzuzIS+3FymxCSuzBR6nJyCZOTWvKSObMSujOzivAwKDOTSrNzKrJyGbDwyNOzWrMy2lIx2XBwWFBQSFBQODAwGBAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYqMDxAoYMGjZwmEixg4cPGzqA6BBiAggRIzaQGEkSwgAMJCKgnNBhQogSJlKGOFHTpgYUG0TsnJBCxQoSE1i0KErAxYsOJJRuuAAjhkwZM2jUqGnDBQoUHTbciIEjx4YNOmbs4CGjB8kCZlGAALHBx4+YcTcACcJDyFSJBo6iGNIhhQkiG8BOKGLkCBK6SSQisHoWhZIbG5bMYALECI8mTZw8gTL1QJQXZ6VMiUylSpUlVpoYaXLFtm0EGmCjwJLlA2O9MrRsccKlC8kEXr7AdgEmwtkhX2SQ2BIkjBiSYzSQr/nyhUKZLIrJJOcexvlEBV7IvCBjRkmAMzHOaufhxDvJBWiQISAFxUUQQRovJNeEGmu4JxEDbKQhXxsfuFDGGW68IQMcccgxRxUkNRDhC3R8QMQIdZwXQ11JJGFbiB+QYccHaaTxhgt13OFBDGTgkUdRDrhAhx5k2JjGCB/swYcXMXwAYk190OGHHx/4wUaVepTxByAaoPEkSQ5wwMEJZAZipiCDDJIHIYV8OZEdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBBQSFAQGBDQyNExKTHx6fGxqbFxeXGRiZFRWVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFxaXDw6PPz+/MTCxLS2tIyKjKSmpKSipJyanAwODDQ2NHRydERCRFRSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZzQIBwSCwaj8ikcslsOp/OgHRKlQoCgymRUDAcEIkwYgxWFBYERpHQcDwgEclEQmk8DhWL2kiIXDBwExMNGRoJaUkEEH8bEQ0cGgcWAksEHX8QHBKSHk1sfxMHH5ROBBsOICGkT2wiq1CIULKztLW2t0h2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ5QIBwSCwaj8ikchgQLJGBgfNZDBAKBirRekBMtYGEYsHIgsWNhOO7tCrShDU18Hg/CJAIG0o4wCUQcksTFBUSCRYSEnpUFxgIGQkJGYyNGggbHBaVjR2QCxEeWkITHQ4IH3tPFwEMA2ajAKUgqlQTTbFEE7W5vUgGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNGReZAQCBMTCxGRiZMzGzOTm5LSytPTy9Pz+/CwqLOTi5Ly6vCwmLMzKzJyanJSSlBQWFKymrIyGjCQeJJyWnISChISGhHx2fKyurDw6PAwODHx6fHRydDw2PERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ2QIBwSCwaj8hkMRBQKgOCgRMZIBSk06XhEM0SA4iE4uoVLhCMhqLrdSAekMgYO5VM4BQ521mxIC4UFxBWdEkSERYYFxETGQGFSBKCGBEaGRuQSBwdeZaPXpsQCB6YZQMdEI6ZSgMepKusHh+wrCC0rLdlursGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBFxeXDw+PMTGxHRudPz+/JSSlLSytIyKjHR2dISChIyGjIyOjLSutLy6vKSepJyanISGhJSOlOzm7Ozu7MzGzKyurJyenDQyNGReZKSmpIR+hCwuLCQiJBwaHBQSFAwKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZtQIBwSCwaj8ikcslsOp9QYyAQFQYEAyr0Sihkn1fDAeHVLsOJNELxVaITC0bDUU6GH5AIQ8KYrNtFVxQVFBYWFxgRCREYdUQZGhYEDwgIGxAHCQocCgWOQhmhGR0epR8gqCFTq1Wtrq+wsUt0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAQGBBwaHDQyNExKTHx6fGxqbFxeXGRiZFRSVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFRWVDw6PPz+/MTCxLS2tGRmZDQ2NAwODJyanKSmpKSipIyKjHRydBQSFERCRExOTFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAasQIBwSCwah4FkQKBsDpoBIqFgOCASCYRWm1AUFgRGkdBwPCARiWRCaTwOFYvYSIhcMOiJpJGZaDYcR0IEHXceEQ0fICEWIoJDhHcQHxIHgI9SEHeVG46YUh8OISOen1INCqWmUnOYTUxQAU9NUlRWWFtbCiRgrYNlZ2lriG8lYUd1khETE24gCZeCkRgeFBAQIAeNn9OTlXKrBJoYnKrcoaPmpmSpq3S+7u50QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAavQIBwSCwaj8gkMiBYNpeDZzEQXRIKBmPgmtUSDgipcAsWjxOKBaN7Tq+n6EbCIQ3E5+KtQk6gjwl7CX11D3sPBBARTQGFDYeJT2R8EhB0koKUfgATFBUSCRYSEoqcnqCiikMXGAgZCQkZqautr7FiFxoIGxwWqQC4ury+qh2tCxEexMbIRhMdDggfYs7Q0kcXAQwDbELY2txEziBmmx3jSRNMR+nk4e2b70ry80QGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTGxOzm7CwqLLy2vPTy9Pz+/Ly6vCQiJLSytLS2tLSutOTi5MzGzKSepIyKjJSOlKSmpMzKzJyanIyOjBwaHIyGjISGhJSSlISChBQSFJyenIR+hGxubDw+PHRydHR2dEQ+RHx6fERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8hkIIBcJgEBweAYnTYJUmMAa9USClniFtwlGg6IRFhoUKTXwwWj0FB3F46Hwl6UQyISfAB+EROCQgsUFRYSF3yJEIyBaxgWDBkaGRtclQwSHBIbEGEdGx4fGhcOICEDGBsWHBmqIq1CHRIWGRMMIyRTHRy6Er22tyONq8YdJRe0xkIDwr2/QwMfliMmZQADIxasZd4e4UYDIr7c59rc0eVFA+/m0EQD9PDt0flP/P3+BkEAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBGReZDQyNMTCxHx6fPz+/JyWnKyurHx2fDw6PJSSlISGhIyKjIyGjISChLy6vJyanOTm5PTy9OTi5MzKzLSytKSepMTGxMzGzLS2tLSutKymrHRydCQiJCwmLBwWHAwODLy2vHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAajQIBwSCwaj8RAAMkUBgSDZdP4JBSi06TAcEAkFNLp07BgLLzY5njRcDzO3zB1C4lEGI83Wj58SiYUFRUWdg0XEXFFAwIYGRoWGxwRZQUFHZdgRAObmx4fHiChISFKpVlKWUdPaalOAlasp1sHG4myZGZ7Yltsbgu1mUhjdRF5egmxfQJ/gYOFdrZDi40iFgiSCw8jBQmYcpydn6Ego6WorUwGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navback22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XAQCBDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihAQKFCTO3BS+1AyixBSWvBSOtBSStAQWJBSixDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdCH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMqBcMpvHgGAANQYIhWdVGDAcENQtIJBQLBgNx0MQaDuQXcghIplQDhBIxXKJYiAZGhscHR4VHyAhIiNWJBklGhIbJoQnFCcTKIxFKSgbKissJi0mJi4vLiYoMEcXKDEyMzQ1Nje2NisoOEg4KDU5K6g6OwwoKAN9SCOeMmgwz884PEq9PT4NYkPLP9jZQikN3d4AKVrjKePp3gZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navdown22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaRQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHVQrMX9PU1Uh0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrETa5ByixBRmjCTC1ETS3BTC3Bx2nAyWvEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaYQIBwSCwaj8hkMqBsBgTN5IAAjRoDBaq1aDggtMuAWDzoJhTgY+CwYLgZDccDwkgXI5IJZVGxXDAZGnR2QxsLHB0PHRgeHyAZDyFfVUQDCyIgIyCPIB+QJCUmlEMBEiInKCQnKSkeKSQeomoqJrUmKiArKSwZsmoCwMEBGCyxo1EGHr3HUQEEvltCBtDRAAbMW0zV29xDBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navhome22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQiJNze3ERCROTi5MzGzLy6vDw6PKyqrKyurBQSFGRiZGxqbGRmZISChEQ+RExKTExOTHRydDQyNOTe5FROVLSurCwqLMTCxPT29Pz6/LSutFxeXLyytLSytPz+/JSWlKympPTq7KSipNzW3BwaHHx6fKx2VJRWNHQmBFweDOzq7Ly+vNTW1JxWNLSajPTe1Ny6pKxWJNTS1IyOjJRmbPTi3OzKrNSSXMSGVHQiBHx+fJSSlPzy9IxOVOzWxOSyjNSCPLxeDJyWnIRGTOTGtMxmDLRWBHwqBIxGTLRSDDQuNNSunKxKBGwyNMSafMxqHMReDKRGDPTu9LxuPLxaDJQ+DIR+hGQqNIQyBGQiBNTO1EQKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAYSIiYQCAwQCiokEhwACBQYHBAiQhAiHlQYJCgkEC5uCkp8MDQ4NDwylmwgQlgQRERIEBBOkmxQVBgQWFwUFFxEEDLyJGAUZtQoFGhsFHLYdyoOVHsEf0SAbIAUex8mwlAUhtSIFG+3uIyTWvAIGJMEkJe76GyXbEeWUBJg4USKaBhQpVKzYoIFFiwYUBBJa8MAFCw0vYMSQMWOhBhoTKCQSUKMEiw02buDIoWOHBg0GeIhEFKAHDR8afgAJImSIioYliMws1MPkhiJGchxBkmTDCBo1hg4KQMTiBiUyhBxZ8pNFiR5MEtU0WqSJVidJNDyNKraHC5xPNKBEkTLlJ5WvUgWNvfikyhArV34+7ZEXQAAsB2iUyHLlihYtW0pwOYAFgyJDmDNr7jIIWiAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navup22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBHSWtBRmjAQOHISmxNzu9BSmxBRihHyatPz6/Lze7CTO3BSixHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7ByixGyavKzO3FzC3AyWvBS+1BR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSOtBRSdAw+XAxCZDyexDSyzCTC1JzO5JTa7DSuzETW3BRqlAQWJDRWbOT2/Mzq9HzG3JzS5Kzi7BSStGS21CxSdCRmjAQOFAQSHAAAACH5BAEAAAAALAAAAAAWABYAAAaeQIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbUGFAtGw0GFfheHByQi4S6/E8pDUoFYLm5kAEPJaBAVGxIcER0JHlEfICEiIxUkGyUmIgknKIhXASkonCorgSwmKQGcKE9IAi0uLxUwMTJWMzQ1NiYwBLBQHws1N7avXgs4NjkcCblMATU6KhvGyG87PAnUKV1MAj0+2zIFp1bg4eJJdkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAwKDJSWlFRSVBQSFKymrOzq7HRydERCRPz+/MzGzISGhJyenKSmpGxqbJyWnJSOlKSepLy2vIyOjGRiZPTu9IyGjLSutFxaXExOTHx2fGReZAQCBAQGBBwaHCQiJLSytKyurJSSlFxeXNze3LS2tIyKjFxWXHRudAwGDBQOFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbVKFQsGItBdBhpgh4PxIJvRC8cA4oiMy8bvQhJhMAYTFBVOURAWEw0QFxcMERAYCBluVxobDxkVHJocmBwEGgmEQx0dHh0CpKmkH6odVlanBR8FtAIFtiCkSB0LISEiGCIGIxAPDySuRwIOBwrOzwoHJRHJRh0jJgMj2gMnERQUCNVFHQQoCBvo6CkICATjRB0qp7b1K6qv+foyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playend22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTCxGReZBQSFOzm7AwKDKymrJSSlFRSVCwqLLy6vPTy9OTe5Ozq7CQiJLSytOTi5BwaHPz+/HRydMzKzKSepJSOlKSipJyanIyGjIyKjKyurISGhMzGzJyWnHR2dISChIyOjLSutDw+PERCRHx6fJSWlIR+hJyenGRmZHx2fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8ikMBBQKgOCgRMZIBSkxYHWoDVWD9EigpBQLLBERsPxCA8NDUhjgTBGJJNGG02RVBQWdUV3FxgZe0IGfoAGdhoXGxwdiAYef4FGFBoeHB8dGSBRihUhIo1FBhkbIyMkJRYmAwYal4JEBh2RChIWJ1IIGxUZFqdECCgkHR6wWAYpFR2YWSobvL5vFgfDaEMDIivMRBEsD9HcQgMWvecDLB0tZ0btsfJa9vLXU/X6/P3+b0EAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playpause22:play play22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwODMTCxKSmpJSWlFRSVAQGBBwaHLSutOzq7Ly6vCQeJPz+/Hx2fBQWFGxubLSytJSOlBQOFAwKDJSSlJyWnIyOjHRydNze3GRiZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWBICCOZGmeaKqubOumQSDEgRjPMSoMRGEcol3vh0IkFAtDDWBEKlGMRKPgEIii0yrqIS1ArADu9KuLNCSOSdCMVp8ohEZFC4DL6SaBpXGh6/l4JX8XZACDhXkYCn1LAoqMUBAZEhBLDJKUSyYBGmhPAJyemiU0NDaloy+qq6ytI8whACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playstart22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExOTAwKDAQGBJSSlHx+fBQSFMTCxKymrFRSVOzu7GxqbLSytLy6vJyanPz+/GReZBwaHHRydKSepKSipGRiZJyWnAwODLSutKSmpISChPTu9ISGhFxaXJSWlIyGjJSOlERCRIyKjDw2PIyOjLy2vOzm7Dw6PLS2tCQmJOTe5GxmbDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa7QIBwSCwaj8ik0hgQLJGBgbMoqBIKU2LAcMgOEQmFYeEFbBmNMgDhYDwWBC0k4pCoJ46IgRIXBioRCRYXamwRGBQIfgaBFhiERhkaenxmCoEbBhyQRYaIGVsdghgem4UWegcEBB8UHhsgIaZGBBgRIpUIIxQhChginEQIIBEklWslFyYnBsFfFCi4WQgpFBwqFxNGKxcsxl4IAS0NZEYCF3vlwgEfUuZV8JEuI2pPAARN9kcE9fr+SwaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstop22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAwKDBQSFBwaHCQmJJSSlISChJSOlJSWlGxqbGRiZNTS1PTy9Pz+/Ozm7OTi5FRSVIyKjOTe5MTCxIR+hExOTHR2dLy6vLSytLy2vHRydFxWXIyGjIyOjPz2/FRWVHx6fExKTMzOzJyanKSmpKyqrKSipAQGBLSutHx2fDw6PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcslsAgKCAWEQjQ4KgSwyYDAcugZEQqFYYJECA6PhaLcfEEUkgJZAGJB8fkKpWOhHAxcOGBQZGBoaGQgbHIBGAhUOGR0SBxISBh4Xf0iCHxQSlRIIXhsgj0UCIaCXmJgHGyKpRJ+hmB5dHQqOaCENIx0epBIkBhdzngoPGCQlJifQJBvJRygRKRcKGxcXGypys1srEREc5SLnICLiR1koLFVUWfRO9vf4+UwyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textblock22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUWzvNzo33GfFl5jVlonlTrr1DbvFi9vjeeNUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIxhI+py+0Powm0VnknjVkH2AEhE45LZ55Wqn6e65TsMc5eYosbksswubJIhsSiccgvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textcenter22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUbz3Sh7yIWfFHKjVl4nmFrr1Lpr7LwkjeeIUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textitalic22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py+0P4wqUSlQvttrkDnyaOHIdeaGRupplAIauVM3xjeeOUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+pyw0Bo5zB2UXz3Sp7yG2fFJajVjonmIor2TJvfL0wjecIXQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textright22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUfz3SZ7yIXdF4kWqZkbCqoMO7kXLC+wVOe6YRQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text22:text text22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRSVCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmKQSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bst9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textunder22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIvhI+py+0PowmUnhpeVVnb1DkbCI1I2JhX+Z0sOr2cTHpwK7a4rUr+hAnufsTirwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz69PTq5Pz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq70466Cl+AMxBVwnFIVRAmQHCIeBrC1L3tQgJ/SaEbeeC1PLBHE2ybFI9A1HzstHEIK6YCmhDTmBybQaHYJn7QC5zKeytIQe1+pKNE6P2yMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewdetailed22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAQ+EMhJq7046817+MLQUQFRGMc4lQaSAkcMx3QltMmrDrSu/sCgEPgJhIiFk89DaL1qPRnlhsgBebWhdstVESIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz69PTq5AQCBPz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARWEMhJq7046z2DF0PlBeAVEERhiKhqHgWyUgEsX0KczFOO7JeBYciTCImc5ITIXDKHyqhU9AnRqq9UEVDTvmLbGhin2/qAliOUot5OLc81IO5+2+8WewQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag-22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/avno2BBf/MCClSob4iBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbIQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/cunr9S8gAIRFhTCLAgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag+22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbQQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/4zT766vRI+fvHD4CPgwcJ9qg0UB85JA0dDjEQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmulticolumn22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq7046813+MJQfUF4BURhHGO6noSBsEcNoDJtS4KcsJQe4ncZ1HYT47HDbDqfUAnJRJmKLIGCCjjJbmE5wBI3EyOFxKCPS1EiJW52dE6vZyIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewtext22:view view22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIkhI+py+0Po2ShBlOxzbP7n2yaJoLm+ZTcxqHuC6hXzML2HVEFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtree22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz+/Pz69Pzu5PTq5OzaxBQOFOzKpFRWVFxWXOzexPTexCH5BAEAAAAALAAAAAAWABYAAARPEMhJq704g6A779kHCORAgNskFMYhakE8FkjyBcoWv+JwJItXaELYCTFHlCSpZKKcoB5jYHpOGgUadLKbIRw3jhEzQDyCSuI4zW673yhDBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
diff --git a/ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde b/ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde
new file mode 100644
index 0000000000..51f76a0488
--- /dev/null
+++ b/ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde
@@ -0,0 +1,658 @@
+1downarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PUZi0zmTtypflV0VdRJbm6fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+1leftarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAP///wAAACH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxqdwoNGTmgvy9px/IEWBWRkKZ2oWrKu4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+1rightarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxCtwoNHTmpvy3rxnnwQh1mUI52o6rCu6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+1uparrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PWwhxzmetzFpxnnxfRJbmufgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+2downarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+pq+EPXYpxUckoO3AjbF3dJwahllXe6AFgC8d+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2leftarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pyxf5VohmSlsxmpjTzAHeN5ak6UHpqKRi2GpwvH3Q3eT64RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+2rightarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pq5HOAjQyVnqfhHue7oAaKH5kiW0AmnLqaHomkj02g+e6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+2uparrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIghI+pyxfR0HsRzNnuXVqn3mVQZWFRyIDjp65Ga5Ly4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+abs-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAIwhI95ocn2GlySTiME1iC+DIKdNWxANl4HaqWr055cy6Bs6dahmJsyXVFFJJ7gyF8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+airbrush-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPzCxMQCBIQCBPz+/MTCxKSipFxaXDQyNISChAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARUEMhJZxCjanBH3hY2EFJgVt0YcEW7liLxBoVxzPHL2msqUzSeT2c5HBC5jQmROKgAhCgKEVBQo6YAqVQIHBQ93ZbmBWt+nDJRgiYMvmuoThWXT/wRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+attach-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBPz+/AQCBAAAACH5BAEAAAAALAAAAAAQABAAAAI2hAOCxg2h0nJHyEshi9HpxU1GOCLdZoKpQ15nibUoprKp9lh2oucUxsBRXsJh4Hjs/QTMpr8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+back-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TBxObISevAQCBNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAwSHBRafBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnBRWfAwmPBRWdByixAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZiQIBwSCwah4HjUTBQFgkFg3MoKBykU0QhoUAIAuAksbpgNByPxQMSGVsVDYlkIqdUiJYLJqORbDgcHRseRR8gISIaEyMkGCVYRBEmeyAnlgaQkSgpmU4RAZ1OKqFOpFNGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+blend-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBARCRAQCBASChATCxATCBASCBAAAACH5BAEAAAAALAAAAAAQABAAAANHCLrc/izISauYI5NduvlXMIjEQBSnUYCYxnmsSJrouhqh6J4wLo0mWuqWy5heN58seBrGdEdeMgQsNW0ggXbL7Qog4HDDnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bookmark_add-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQyNKSipAQCBMTGxKyurISChJSSlJyanHR2dIyKjPz+xISGhPz+BGxubMTCBHx+fPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVfICACwWieY1CibCCsrBkMb0zchTEcNYsIiYHiwIOdEAvigdFQGE0Ix4NBbSAgsWjk+jBIAlcUYrJASChnSXZSoUDelKfoKpFALJA61ueGI2IAZmhogGFmCGGAgXsifiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bookmark_folder-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBQWFOTi5OTm5CwqLPz+/PTy9Ozu7FRSVNza3PT29KSmpAQ6XARqnNTS1JyenGRiZJTa9Mzq9JzO5MTGxIyOjKSipFxeXMzOzDw+PDy65FTC7HS2zMzm7MzKzKSenASq5Bx+rBSGrFyqzLSytDw6NAR+zBRejBxqnLSyrERCRIyqvDRujKyurMTCvOzq7AQ2VDQ2NNze3KyqrGxqbLS2tLy6vCwuLDw6PAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAawQIAQEBAMh4GjcEAoCAQGYSCpDBwQiQJBEVhQj1YGo1DoNqZTx8PhODAWZUik0ZAkHRNKZe0IWC4RGBkBGhsOHB0eFR97bBdcICEbAA4iIyQlioxrGhEmJ5QoKSoqJCOZiw4rGixEYi0uo6WYDi8wkwAsCTFksLIuMi+tADMLNAsLEBAgLSMpMjW4RCc2MCAgFjA3MA4R0kgzGS84Ny8vDqBKSDkKETUOOurqAQagfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bookmark-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+bookmark_toolbar-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQ2NKSipAQCBKyqrMTCxKyurISGhJSSlJyanHR2dIyKjGxubIyOjISChHx+fPz+/MTGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVpICACwWieY1CibCCsrBkMb0zchTEcNYskCsXiwIOdEAzioeFIGE2IB6RBbT5HiAhEIpk6Y9kJBMJoHK6iLIU8kZxFlXhlIp/XJ4BKUIGoWIJ9f3x5e32FeoB5goGAfokTCJEIFJKTlX4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+bottom-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZhQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KFAcoqOknkh+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+brace-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAI2hI9pEXq8mnsNzggsEMJwbHGimFXS4HUfpKUIq3QJ036vuakyWvbjCJLYbL2WgyW5WIw3g78AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+brackets-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAIzhI8JwXocllMxTlSREGY/2W2iJ1nAEAJklpCfeXAJG8sY6JGowY7jW0sBL0NiqTGBAPwFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+charset-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAInhI+pqxH8kFsvsgtm1vvEaoBZSH6j5FSaRY4me4pyq1ochuf6fvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+colorize-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BAQCBPz+/MTCxISC/AQChMTC/ERCBPyqXMRaBATCxASChPzerKSipMT+/MQCBATCBASCBARCRISChMT+xDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVnICAGgWieZyCQKGuqZPkGgwyv60gONRDvNlqt9Pv5BgRCYVj8IQ3L4qE4KFiZzRiP90MgEj+FYtGLIRiJQaMxUDjIxFoi8YBAIo3FQjIJ7iAUERNqDTI6PBGJfT0oFVpsMSgzkSh+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+colorpicker-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBARCBDQyNMT+xATCBASCBPz+/FxaXISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EMhJZRCjahBIMdlmeV8gBl3xCabWGarBihwBz+eB2O0WHIFEp1f5BU1EilFI4wCZtGWy+JwWj00OynrNTvwRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+completion-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/Ly+vHx+fAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM/CLrcGjBKCYK4+NoMs+jWIBIdZ50QuWGgMASD+oGnO5beR+x7UE3AyGKV0wxnpeSxyDoGN74Hszl8QhxYhj8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+configure-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connect_creating-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZbihUiz60FPnfaA0iBpBVGdHEYWxToEoSHBRHHM9AgSEQRcj+AYkYAJxIPKQFUJiOdTJQFIDU6dYzKKFhTCM+E5g4mXaDAyrlogEG+DGTecA7wsP8EcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connect_established-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipDQyNMTCxMTGxISChFxaXMzGzAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZxCjgsAtDtUlCOA1gJQ4kl/IDatAoF7xxkS6GgEBr6jAobCyBX42SQBxMOx6A8MhiGASR8YDgrYsNEeJ0zaEGZY7uoH2oB6nOUwtbdLaVOeTUwo/8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connect_no-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBAQCBERCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEMhJq704axBEHoPUEdhQGMNYFuwxkKInDYjBniEnwMCQIIebSzXx/WwsFK+YMABZikWuYlrUCtZpEYv4WRPaHhb064YB41kCfJFSQBh/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+contents2-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBDyKhDSChGSinFSWlEySjCx+fHSqrGSipESOjCR6dKTGxISytIy6vFSalBxydAQeHHyurAxubARmZCR+fBx2dDyKjPz+/MzKzLTS1IyOjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOZGmKQXCWqTCoa0oUxnDAZIrsSaEMCxwgwGggHI3E47eA4AKRogQxcy0mFFhgEW3MCoOKBZsdUrhFxSUMyT7P3bAlhcnk4BoHvb4RBuABGHwpJn+BGX1CLAGJKzmKjpF+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+contents-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExCNGSenHRmVCwqJPTq1GxeTHRqXPz+/DwyJPTq3Ny+lOzexPzy5HRuVFSWlNzClPTexIR2ZOzevPz29AxqbPz6/IR+ZDyKjPTy5IyCZPz27ESOjJySfDSGhPTm1PTizJSKdDSChNzWxMS2nIR6ZKyijNzOrOzWtIx+bLSifNTGrMy6lIx+ZCRWRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQEAAQCwWBYJiYEAoGAFIw0E5QCScAIVikUgQqNargtFwdB9KSDhxiEjMiUlgHlB3E48IpdKdLCxzEAQJFxUTblwJGH9zGQgVGhUbbhxdG4wBHQQaCwaTb10emB8EBiAhInp8CSKYIw8kDRSfDiUmJ4xCIxMoKSoRJRMrJyy5uhMtLisTLCQkC8bHGBMj1daARgEjLyN03kPZc09FfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contexthelp-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIzhH+hIeiwVmtOUcjENaxqjVjhByaBSZZVl24Y1V6iEVMzkD4bqD700bshgh1fzwd0IfwFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+crop-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMT+xATCBASCBISChPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAM0CLrc/iG+FsQgYapKbp7c4IFCZ2FQOQQE6oSl9Koxabrz/eVDDXat3atAlEEMSKFmyfAnAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+decrypted-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+down-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZeQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KJ6hokN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editclear-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIuhI+pm+EPnwmi2msDoLgLzQWDV4HlSJof6qki+W0n7LKdCpdyrm/Rr2EIhwp/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcopy-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXPwCBNze3GxubERCRPz+/Pz29Pzy5OTe3LS2tAQCBPTq3PTizLyulKyqrOzexLymhLy+vPTy9OzWvLyifMTCxHRydOzSrLyihPz6/OTKpLyabOzu7OTm5MS2nMSqjKSipDQyNJyenLSytOTi5NTS1JyanNTW1JSWlLy6vKyurAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAaUQIBwCAgYj0eAYLkcEJBIZWFaGBie0ICUOnBiowKq4YBIKIbJcGG8YDQUDoHTKGU/HhBFpHrVIiQHbQ8TFAoVBRZeSoEIgxcYhhkSAmZKghcXGht6EhwdDmcRHh4NHxgbmwkcCwIgZwqwsbAhCR0CCiIKWQAOCQkjJAolJrpQShK2wicoxVEJKSMqDiAizLuysiF+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcut-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIwhI9pwaHrGFRBNDdPlYB3bWHQ1YXPtYln+iCpmqCDp6El7Ylsp6ssR1uYSKuW0V8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editdelete-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPT29GxubMzOzDQyNIyKjHRydERCROTi3IyKhPz29Ox6bPzCxPzy7PTm3NS6rIQCBMxCNPTq3PTi1PTezMyynPTm1PTaxOzWvMyulOzGrMymhPTq5OzOtNTKxNTOzNTCtNS+rMSehAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaKQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhSEQkFgrBAcr1URiPhKAsDD3QB8RhA3FM0IlLHnyUTVBMSFBUWfl0XGBMTGBcZGodmcQWKjpAbHIgIBY2LHRoempOdjooTGx8giIOPFYofISJ+DyMXI6AfFySyfiUmJSUnKBYcICIpfgELzM3OZX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVMR+RPzKjNze3AQCBMR6RPzGjPyODPz+/MzOzPyKDPyKBPz29OTWzPyGDPyGBOx6BOza1OR2BKROBNSOXKRKBBwOBOzu7PTWxPzizOySZPyCDFxaXOy2lNRyRMxmJCQOBPTm1OzStPTKrMR+XIRWLFxGNCQSBDQyNIRSNDQuJERGRLyqlNzSvIx6ZKRuVEw6LLSyrLymhKSShBwaFFROTJyWjMS+vNzW1OTazNzKrHRqXOzezOTOpPTq3OzWvOTStLyedMS+rLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAewgAAAAYSFhoQCA4IBBI2OjgUGBwiLBAmXlpcKkgsMlZcJBA0JDpIPEBGVjwkSBgOnExSfmBIVBxAMExYXswkYGRobHLq8gh2PHhoeHyAWIYKzIiMkJSYnKCnQg5YNHtQqKywtK9qMBC4vMDEBMjIz2dCMDTQ1Njc4OToz5PEEOzw3ZPToMcLHO23HfogQ0QMIkCA+hPBbhAPHECJFjMyYIUQIvEUpUqwQOXKkSEF+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQiFHRqNIx+LFxSBDw6PKSaRPz+/NTOjKyiZDw+POTe3AQCBIR2HPT23Ly2dIR2FMTCxLS2tCQmJKSipExGLHx+fHR2dJyenJyanJSSlERCRGRmZNTW1ERGRNze3GxubBweHMzOzJSWlIyOjHRydPz29MzKzIyKjPTq3Ly2rLy+vISGhPzy5LymhISChPTizOzWvKyurPTexOzSrDQyNHx6fCwuLGxqbOzKpMSabAQGBMS2nLyulMSidAAAACH5BAEAAAAALAAAAAAQABAAAAa7QIBQGBAMCMMkoMAsGA6IBKFZECoWDEbDgXgYIIRIRDJZMigUMKHCrlgul7KCgcloNJu8fsMpFzoZgRoeHx0fHwsgGyEACiIjIxokhAeVByUmG0snkpIbC5YHF4obBREkJCgon5YmKQsqDAUrqiwsrAcmLSkpLrISLC/CrCYOKTAxvgUywhYvGx+6xzM0vjUSNhdvn7zIMdUMNxw4IByKH8fINDk6DABZWTsbYzw9Li4+7UoAHvD+4X6CAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbGxubMzOzPz69DQyNIyKjERCRPz29PT29OTi3IyKhPz27PTu5PTy5Pz6/Pzy7PTq3OzexLyqlPTm1PTizOzavLyqjOzWvOzaxLyifOzizOTOpAQCBOzezAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaEQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhWEQkFYYHkeqkMxKFBFpq9jgdkEGlPqwrJhCIY2N8FFRYUFxcYGX9dgRKEGhiHiYEOhBcbGBwdiQEOARcBGwEeAZllAgEUnQEfoQEgmp4hrCKtrwEYsrRlTiMBJAG8syN/IyMAxMXHSH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edittrash-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipFxaXPz+/MTCxISChDQyNCH5BAEAAAAALAAAAAAQABAAAANQCKrRsZA5EYZ7K5BdugkdlQVCsRHdoGLMRwqw8UWvIKvGwTICQdmGgY7W+92GEJKPdNwBlMYgMlNkSp3QgOxKXAKFWE0UHHlObI3yyFH2JwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+encrypted-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+eraser-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAAT+BMTC/AQCBISC/AQChPzCxPz+/MQCBIQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EMhJZRA120GwnsEgdh8QiqKXnSi5oqNKsbFWGEYrT8Vx4JydpOf7uSrEIkIISPqWtkIS+pH2qCUptgTYavwRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+exec-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBEQ+PBwaHLy+vMzOzGxqZHx+dKyqnKymnIR+dNTW1MTCxJyOfLySVMSaVMSeVMSebJyWhOSmTOSuVNyubPS+dKSWhHR2dDw+PIyKhNymTNSaTEw+JOy+fPzSnLSyrISChDQyNDw6NMzKzLy2rMyiXGxWLAQCBHRqTPzerNy+lMzGvCwuLAwKDDQyLJyWlNy6jPTGhGxaRGxiRPz2vOTStLy2tFRSTMS+tOzGlPzmtPTixGRiXCwqJLy6tOTWxPTq1MzKxMzOxISCfHRybLS2tHR2bCQmJExORMTCvMTGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeogACCg4SFhoIBAYeDAogDA4oAjYQCBAEFBgcICQUBCpODAQsMDQ4PEBGWhgUMDxITFBUUFheDGAYZCA0aGxwcHR4QHwwgISILIyQlGiYnJygpKisEIywALS4vMBoxMjM0KTU2LC2ENzg5wDo6Owo8hT0+Lx8/OztAQR9C1oInQz4FMBAp8sEIhgIEMpwYdASJCwAYkihR5OLGkUUAMmTACK8Hx4+C/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+exit-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBDQyNHR2dCH5BAEAAAAALAAAAAAQABAAAAI4hI+pFrHb3nEg1iWiDiINCwYDko0V9XUTda6I1TIsUMpGinyzbB6ZeGuoEr+GUDL4CXqSphPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileclose-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCQiJBwaHAQCBDQyNDw6PFxaXFRSVERGRCwqLAwODGRiZHx6fPz+/GxqbAwKDCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVaICCOZGmeqBgEwjCkRGEcSKK4JrEcBrMgAdeLVDg0GguGsYEbBQyGYyN6FDoPDIf0+LCKBIgetQERDgGDBGIpNY8GioAU0m6KXFw883w3+/l9f4AkfimGIn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filefind-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBCQmJDw+PBQSFAQCBMza3NTm5MTW1HyChOT29Ozq7MTq7Kze5Kzm7Oz6/NTy9Iza5GzGzKzS1Nzy9Nz29Kzq9HTGzHTK1Lza3AwKDLzu9JTi7HTW5GTCzITO1Mzq7Hza5FTK1ESyvHzKzKzW3DQyNDyqtDw6PIzW5HzGzAT+/Dw+RKyurNTOzMTGxMS+tJSGdATCxHRydLSqpLymnLSijBweHERCRNze3Pz69PTy9Oze1OTSxOTGrMSqlLy+vPTu5OzSvMymjNTGvNS+tMy2pMyunMSefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCAAECA4OIiAIEBQYHBAKJgwIICQoLDA0IkZIECQ4PCxARCwSSAxITFA8VEBYXGBmJAQYLGhUbHB0eH7KIGRIMEBAgISIjJKaIJQQLFxERIialkieUGigpKRoIBCqJKyyLBwvJAioEyoICLS4v6QQwMQQyLuqLli8zNDU2BCf1lN3AkUPHDh49fAQAAEnGD1MCCALZEaSHkIUMBQS8wWMIkSJGhBzBmFEGgRsBUqpMiSgdAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filenew-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz6/GxubNTKxDQyNIyKhHRydERCROTi3PT29Pz29Pzy7PTq3My2pPzu5PTi1NS+rPTq5PTezMyynPTm1Pz69OzWvMyqjPTu5PTm3OzOtOzGrMSehNTCtNS+tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ/QAAgQCwWhUhhQMBkDgKEQFIpKFgLhgMiOl1eC4iEYrtIer+MxsFRRgYe3wLkMWC0qXE5/T6sfiMSExR8Z1YRFRMWF4RwYIcYFhkahH6AGBuRk2YCCBwSFZgdHR6UgB8gkR0hpJsSGCAZoiEiI4QKtyQlFBQeHrVmC8HCw21+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBOSmZPzSnPzChPzGhPyuZEwyHExOTFROTFxaVFRSTMSGTPT29Ozu7Nze3NTS1MzKzMTGxLy6vLS2tLSytDQyNOTm5OTi5Ly+vKyqrKSmpIyOjLR+RNTW1MzOzJyenGxqZBweHKSinJSWlExKTMTCxKyurGxubBQSFAwKDJyanERCRERGRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaRQIBwGCgGhkhkEWA8HpNPojFJFU6ryitTiw0IBgRBkxsYFAiGtDodDZwPCERCEV8sEk0CI9FoOB4BEBESExQVFgEEBw8PFxcYEBIZGhscCEwdCxAPGA8eHxkUGyAhIkwHEREQqxEZExUjJCVWCBAZJhEmGRUnoygpQioZGxsnxsQrHByzQiJxz3EsLSwWpkJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileprint-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPT29PTu7PTy7NzClOzm1PTu5LSabJyanPTm3FxaXOzCjOTKrOzi1OzaxOTSvJyenGRmZLyyTKSipDQyNERCROTi5Hx+fMzKzJSSlIyOjISChLS2tAT+BDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaYQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAoEAuGIdGITgWOq4LxcCQgZkEkIHksHgYJOR6ZQCgVFhYJFxgTBVMZihoCfxUYDWUbUBGKGREcjBoQEB2TAB4CAx+Vl5WMhyACHiEhH6IfIiMktCQgE0cZJQStr6O2t6EARxO6vK6iEx4dZsMCxbsmBB4nzUTEutVSSUdmfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filequickprint-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+/ISChERCBDQyNPz+xPz+BFxaXPwCBMTCxAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMhAq5UYBME7D9kkBMNGjqHmeWBoDhwsEIS7coVx1NhbCrmdzROk9SyU4GEJ2twECISOUNokEopsVrobKCgCrZa73IHFYy4VyZ5WNIO4vBhvse8gfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRSVMTCxKyurPz+/JSWlFRWVJyenKSipJSSlOzu7ISChISGhIyOjHR2dJyanIyKjHx6fMzOzGRiZAQGBFxeXGRmZHRydGxqbAwODOTm5ExOTERGRExKTHx+fGxubNza3Dw+PDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaAQIAQECgOj0jBgFAoBpBHpaFAbRqRh0F1a30ClAhuNZHwZhViqgFhJizSjIZXQCAoHOKHYw5xRBiAElQTFAoVQgINFBYXGBkZFxYHGRqIDBQbmRwdHgKeH2YgHpmkIR0HAhFeTqSZIhwCFIdIrBsjAgcPXlBERZ4Gu7xCRZVDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fill-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBMT+xASCBMQCBATCBPwCBIQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARSEMhJq50hXBvE0JsUEMXwhYFBmOeVDsVqgpS6luRc32RR6hLCTSCQ/VqEwwDhK5Z+Ao3wEPAViL6BR6PSZKyCa6uLAbcAZEznLDHQ1BZDiOKPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filter-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipMTCxISChMTGxAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM3CLrcDiGGt6IQQ7pI8PjSVHUeqFVBNxRfFjXSZYqwENoUNFx4rve+wI6WEwKLQ5/CSCw2lQ9/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+find-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1ISChOTy9Mzq7Kze5Kzm7HyChOT29Oz6/Nzy9Lzu7JTW3GTCzERCRLza3NTy9Nz29Mzu9Kzq9Ize7HTGzHzK1AwKDMTq7JTi7HTW5HzGzKzS1IzW5Hza5FTK1ESyvLTa3HTK1GzG1DyqtLzu9IzK1AT+/Dw+RAQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaSQIAQEBAMhkjBUEAoGA4EJXKJSCQUC0ZDCmg0hATHAxKRTCIEYYMiMFYsF0xGs+FUOl0BJRAweCIRHyATIRhpRAEAHSILIyQgJSYhJ4dIBBEoISkmKiuVSQgRIyEsEQgELVNCLgQVCiJRLQSfli9pMAQxMrRcQ1G6tAC9AL+7al+qxALACG1Kw8oxBGt7yWBpfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+finish-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nAQCBCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZtQIBwSCwahYGjUjBQGgWE5LCgNBwITSFVKOgKDAZEIqodChSLw4HRcIyTW4Dg0HhAIhGIZEIJxA0VFhcYGRAaGBscHXEeHyAhIQ4iiBwjAHEBJCMjJCUmiSdlRyigU0oolURxRSmrTpevsUN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+flag-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBMTCxPz+/MQCBPzCxPwCBAAAACH5BAEAAAAALAAAAAAQABAAAAM5CLrcruG9QCULokqKR44NJQykQGgXSRaEcYJLsLLu6wSFoRMvCuk1kO9ni8GMt6MForQMl89NxJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_new-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBPz+hPz+BOSmZPzSnPzChFxaXMTCBPyuZPz+xPzGhEwyHExOTPz+/MSGTFROTPT29OTm5KyurDQyNNza3Ozq5Nze3LR+RLy+vJyenMzKzNTS1Ly6vJSWlFRSTMzOzMTGxLS2tKSmpGxubBQSFAwKDKSinJyanIyOjCQiJERCRERGRBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaNQIBwSCwaj8ikcokMCIqBaEDoBAQG1meAUDAQpIcBQoy1dg2JdBqhECgQ1IWB0WgcBIOBwIHXBwwPEBEREhIBbG4IExR/DBUVFhIXV2NjDVYYDY8SFU4ZVxpVAQwbGxynGxkdTh6XVh8gGSGzGSITIxokJUImGSMTwLcnKCkprgAqDSt1zCssKxQtQ35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+forward-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwahYGjUjBQGgWEpHNYMBCaT4G2UDggos+EwmBYMBpf6VBgYDgeEMgjIpmoAQVKxXLBPDIXGhscRB0eHyAgDSGBGyJFASMiIiMkJYImUwAnmJqbjp4AKCmhAKSlTn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+frac-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBAQGBIQChCH5BAEAAAAALAAAAAAQABAAAAInhA9hig0SAmQOxeouPrFTzHzbCAzmiZ4k2S1ryHKsoo3tptXg3fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+frameprint-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPTy7PT29NzClPTu7PTu5PTm3LSabJyanOzi1FxaXOzCjOTKrOTSvJyenGRmZLyyTKSipDQyNERCROTi5MzKzIyOjLS2tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaPQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAsEAqFIcGITqnWRcPxSEDMgkhAonA4DO3yMD6BUCoSCYIWEwVTF4gYAhAMFRUMZRlQEYgXERqKGBAQG5IAHAIDHYiUEUcDpwIcHh4doR0fH02zqAIXIASsrqi0TQBHE7e5HqG0Zr8CwSC9qFJHxbRSU7W1fkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gear-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChMTCxDQyNFxaXKSipPz+/CH5BAEAAAAALAAAAAAQABAAAANdCLobwbAFMciLwBFSihBEFHSG8QnmpQQEBX6loI5G5QTlcMgrZSmEmsGxKqRWNV3hMrFlBtDoA1eTEaKHJdMYhR6+gxkF++UMGbiDzvDVioyHAJSHcchuGLQq4k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+gohome-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+goto-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIohI8RyKciVnMwTlrlDfkm5QFgaHBWMo0lp22dZ57wO8vpGrLk2iJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+help-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQ6XAQCBCyCvARSjAQ+ZGSm1ARCbEyWzESOxIy63ARalAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EEgQqhUz00GEJx2WFUY3BZw5HYh4cu6mSkEy06B72LHkiYFST0NRLIaa4I0oQyZhTKInSq2eAlaaMAuYEv0RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+history-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBEQ2LEw6POTSrOzWtNS2lAQCBOzatPTm3PTq3MyyjEw+NOzm1Pz29Pz+/Pz6/Pz27FRGPFxKRPTu3Pzy7Pz69Pz67KSGbPzy3Pzu3PTizPzu1Pzq1PTmzOzaxPTixPTmxOzWvOTOtKyWdOTGpOTStNS+nIRmVLymhNzCnOzavLyefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIBwGCgOj0jBgFAwGJDJAyJBUDihwgWj4XhAqhEJNDKhVLwUSUDyPJIrlgYlLSG0hYELhgLJTBJOd1kaGxgYHB0egkQfHBwgHyEigkUBIwMkBwcEJSZ3ARYWJCcnKCYpJJ5HAQUqFhSjJysoKItOCgehJBISI4tCtyERa79HTrx2WEiBUH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+idea-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+BPzerPz+xPyqXPz+/ISChFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARMEEgZap14BjG6CJkmEMVQCF+4mQPBpthWtuYJxkJJGK6dbQRCgMBB3XCDzQamMhpDGlvuCFUyoQDLBUsJHBDUKuKQCKsUCIVZtc34IwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+int-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBIQChAQCBAwODAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCKqx/iw0CNukzuJ8d1yCAAziIyliCKjck1ZuaV4igZ1r+raongE4j8YT6QiJC38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+locationbar_erase-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIshI+py40Bo1SywgSFiDq+oG3hZHDhVpUmagFrl7pgN3oqPNuqpe+8Awwi/AUAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+lock-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+lsub-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAQABAAAAImhI+pFu2+QpxKVppsxkh3fnhh9DyGcC6IwLbqir4HK58tLcfx6xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+lsup-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIlhI95YawYonwp0uoukFO7rCXCSJKPcKYKuqqii7BvS892XJZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail_forward-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRydHxubHxmZGxiXHRmZFxOTFxGPFxKTPwCBLymlMy+pOze3PTq3PTu5Pzy7LSmnOTaxOzm5LyqlNzOtPz69Pz27MzCtLyqrPT27IRubPzuzNTGvNTCxLSelPz25Bw+ZFxKPPzy1Pz65LyupBxKdCxWfPTm1Pz23LyinBxGbGzO5DRafBxWfBxajCymxHTS5BxSdBxKbFTK3EzG1CSGvCyKvCSSxCSavGTO5GRaVPzqzFzK5EzG3BSCtAwiPGxaVPTivPzy3NzKpBxObCRefBxqlPTmzJR2bKyahAwyRPzmvOTOpKyObNS+nPz21AQOFKyOfPzuxAQCBGRORLSadPzyzLymjMy2lOzetDwuJFRCPEw6NEQ6LEQyLEQ6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAQABAAAAfhgAABAgIDBAQFBgcIBwmOCQIKCwwNDg8OEBESjY8CDBMUFRYVFxgZDJyOGhsPChwVHR4fFSAhjwkaIiMOJBQQDRUVJSa3GicoHw4pEA8SGSorLI8tLtQu19gqLzDECTEyMzQ14zY1Njc3ODkqCTo7MjIxNCs5PD03PjctPwlAQUIihhBpQbCIihtG+CUocASFkAhIkogQ8kFJwkcFlogIkoRJEydPnkBR6GiAxiQLgiiIIkXElFQJqESoMsRKkAhXqkhhApNKFSxZggTJ4nHIEJhaDhzYwoVLFy1avHyB6ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_generic-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGxaVOTe1Oze3OTWxOTWvNzStNzKpEQ6LOTezPz+/Pzy7Pz69Pz27Pz25Pz21PzuzPzuxEQyLLyinLSmnPz67Pz23LSafKyObDwuJMzCtLSelPzy1My6nLymjNTCxLyqnPzq1LyihKyOfOzavOzetEQ6NPTq3NzOtLymnNTGxJR2bOTOpPTivNTGvLymlKSShKyahEw+NOTe3PTm1Pzu1Pzy3FRCPPz65LSadFxGPOzm3PzqzPTmzPzmvEw6NCH5BAEAAAAALAAAAAAQABAAAAaqQIBwSCwaj8ikMhloOp/QpmAgqAoIhELBUDgcEIGEYrFgNBoLx+IBiRwkgQnFoWAwKhWLhX3BZAILGhsCDXgODhwdGB5vgAofICBlDiEiIx4kJSYBJ2UoEykqHSMrLC0nLWAnFS4UCycvMAcEMR0RLTIBMwaSahw0NTYtFwclNwEdLws4eoc2DxwQOR06ASk7PBAhIRE9Pj0tLSUY1T8I5gjn6Qgy7D8SfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_get-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAxKdBRSfCyGvFSm1BxKfCSWzCyWzBRCXCRKfBwuRAQGDDw6PHy23Cym1CSSxByCxBxunBQSFKyurMTCxExihNza3NTW1JSSlMzKzFxaXLS2tNze3KSipCQmJGxmbNTS1KSepLy2vISGhJSWlHx+fERGRPz6/IyKjDw+POzq7JyenMzOzKSmpCwuLDQyNIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwGBAIAsOkUjAgFJRQQMHgjC4PBIEVgAh4D4aEYrGAMhINxwPyiCgYSsmEUmk82grLRZJkYCgXaAEKFxYZcEISGhsZFxwFeY0WHR5CDB8dGCAXG5shGxQicBIMpSMUGxgTGSQlpQwSJicnEwwdI7gdKAwTsykpKiobr8QMKxeHDBcsGRvOzxsT0i0uL9HSHdkT2ZkoMJXF4a8AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_replyall-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBLymlMy6pOTa1PTq3PTu5Pz27Dw+POzi3PTm1OTWvPz25FRSVERCRLympPzuzPTu7NTGvFxaXKSmpPzu1Pz65Hx6fHxqZPzq1Pz23HR2dBw+ZHx+fISChJSWlDQmJHRydCxWfBxGbJyenExKTHRiXPzqzPzy3CQmJDRafGTO5ExOTERKTGxWVCRSfHTS5CymxBxajBxWfPTmvPzy1CyixCSaxCySxDSaxDSWxDSSvDyaxGS21PTmzPz21AwiPBRejCSavByGtCSezEzG3FzK5FzG3GzO5FTK3CQ2bPTixBxqlCRefBxSdBxSfBx2nCQ+dHxmXPzmvLSafAwmRAwyRPzyzDw6POzavNzKpAQOFPzuxBwWTBw2ZGRORLyWdMy2lOzetPTivAQCBKyObOTOpAweNBwWVEQyLEw2LEQ2LDwuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAf4gAABAgMEBQUGBwgJCguOCwEMDQ4PEBESDA4TjY8DFAwVERYXGBkRm4+QGhsMHB0eGB8bDpyOARogEBceIRgXv8COIiMkGB4lJSYnIcwoKb/DGyoXKywtKS4pHinMLzAxJDIzNDUtNjcv6B0hLzgfMh85OjstPDw99zwd7T4/LTVAgggZQqSIECNHevSAgSSJkiVMmjh5AiWKlClAiFARUeVHFSVWmLS40gNLlh5agGzh0kWDlwZfrIDREKaCAjEqrFA5MMYLmTAxlJTxYoZMozNozqRRs4ZNmy5s3LwhA0dBnDNn5MxBoAABnTp17IitowDrmQV+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_reply-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTEw+NFxKTFxGPPwCBLymnMy6pOTa1PTm1Pzy7LymlOzi3HxqZOTWvPz69Pz25My+tLympFRGRHxuZPzu1LymjNTGvNTCxBw+ZPz23PzuzPz65PTu5NzOtCxWfBxKbPzq1DRafGTO5BxGbPzy9HTS5CymxBxajHRiXPzqzCyixCSaxCySxDSaxDSSvGS21GxWVAwmRBRejCSavByGtCSezEzG3FzK5FzG3CQ2bPzuxAwiPBxqlBxKdCRefBxWfBxSdBxSfBx2nCQ+dPzy1CRqlAwyRDQmJPTmvPTixLSafOTOpAQOFPz21BwWTBw2ZPzmvNS6nPTivAQCBAweNBwWVNzKpPzyzLyihGRORLyWdMy2lOzetKyObEQyLEw6NEw2LDwuJEQ2LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfqgAABAgMEBQUGBwgJCguOCwEMDQ4PEJYRDhKNjxMPDBQVFhAXGBUSGY8LGhsQHB0VHh8gFQ6bjgEhIiMMJCUmFbS2CwMnG6IoKSorI7WpEycWFiUsLSou1yXXji8wFiopMTIzNDUz4zbZNxsbODk6Ozw9Pj8pPzEzQDdB60JDOkRFjBw5giRJDCWdlmxwIIRJExAWKDRyMgTIiydLoESRImQKlSUSF1SxUoXAlSBRsGSJoCVICIlbqlThcoBClC5eYFD4EiVIFwUyqywAE0ZMlqNjpJDpIkUBl0dlFChAYOZMmTJoyqQR5icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_send-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBHxqZLyqlMy6pOze3PTq3PTu5Pz27Pzy7LyinOTaxOzi3Ozq3LymlOTOtPz69Pzy5My+tLympPzqzNTGvLSelPzy3BxGbBQ6VPzuzPz65LyupNzOtPz+/GzO5BRejPzq1Pz23LymjHTS5CyixCSavBxqlPz25LymnGTO5CymxCSaxByGtHRiXPzy1CySxCSezGxWVPzuxKyOhMy6nDSaxEzG3PTivNzKpKyOfPzu1FzK5PTmzJR2ZLyihLSWfKyObOzmzPzmvDyaxOzavLSafGRORMy2lOzetDwuJEw6NEw2LEQyLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfUgAABAgMEBQUGBwgJCguOCwwNDg8QERITFBUWjY8DFxgZGhsaHB0aD5yODB4TGB+kICEaIiOPCwEkJRcmJyYPKCIpKrWqKywTmC0SIi4vMDHEDCsyMg8zEyI0NTY3z7U4Hhs5Mx+0IyI6OyPrIzw9Gys+PxIy2EBBxAs8Qjk5Q0RFWFxAZySfgSMsilRAkiRECHQ08hHgJ0TJkCU/mECU2ISEkowUlpAQ4QTfowNPoAzJIeRJCyjm8kVRIkWIzSkXhwxJtYAKgp9VrFi5QoWKFZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+matrix-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBIQChCH5BAEAAAAALAAAAAAQABAAAAIrhI9pwQHt4Jru2Vsjna919lXKeEimh6UZp1lrCEvkfILyirOby3q1OEv4CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+misc-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChMTCxDQyNFxaXKSipPz+/CH5BAEAAAAALAAAAAAQABAAAANdCLobwbAFMciLwBFSihBEFHSG8QnmpQQEBX6loI5G5QTlcMgrZSmEmsGxKqRWNV3hMrFlBtDoA1eTEaKHJdMYhR6+gxkF++UMGbiDzvDVioyHAJSHcchuGLQq4k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+move-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhA8RyKja2HtRrmrxNfDszm3JMpXmiULg6Hyto4kYO49Tfdc04xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+news_subscribe-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/ERCBDQyNAQCBPz+/FxaXIQCBMQCBKSipMTCxATCBMT+xISChASCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARsEEgZxLxYDlJsvsJGDN0nFQRhpKR3DSJxrGMphYQgpDI9WLhdTtjjAFApXZI30m2UQwICVigcEzzolKAYIAIFBAKbQjQX3YGGISZvFtzFQr1uDxT4PH0yYE8FCg0/Jn0MAwsNOiY3IQMBEn4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+news_unsubscribe-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/ERCBDQyNAQCBPz+/FxaXIQCBMQCBMTCxPzCxKSipAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARiEEgZxLxYDlJsvsJGDN0nFQRhpKR3DSJxrGMphYQgpDI9WLhdTtjjAFApXZI30m2UwxjsiOApB4kNLFtQKKopxeCQxR4GAJIXPCInzmhN9zvCljNq8ZvswmzhZHEfOhpofhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+next-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFwyXAQCBOze9BwCHNx21LQCvPSi5NRi7AAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ3EMhJqwUhAMG7DQOxdVwFFuI1nYZIethwIK0aFwjtwrfh15cAYUjcvWyvkm1Z4TGfkyN0avFHAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ok-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBMT+xATCBASCBARCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAM2CLrc/itAF8RkdVyVye4FpzUgJwijORCGUhDDOZbLG6Nd2xjwibIQ2y80sRGIl4IBuWk6Af4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+openterm-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paintbrush-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTC/AQChPz+/MTCxKSipDQyNCH5BAEAAAAALAAAAAAQABAAAAM7CLrMIS2qN2Sj1U4xugaYZxFE1wUaURQnKpFBYQTuFRiyXDsCd8y7RYhmCQ2IkiHywmkFN84ibfrxJwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paren-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAI3hI+JEQq8mnvyzSOhEWJ3CgLcOILV4IlfUx1cwirfYiEvXL83arANSer5UipM5tIzXjRCh8ZfAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+pencil-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQCBMQCBPzCxAQCBPz+/MTCxISChDQyNKSipEQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARDEMhJZRBD1H2z3lMnjKCFjUJQimOgcmcbELCXzjXq0hV785WCQYcDFQjDXeloMByKG6YTAdwIDAlqSZJSVFeKLcUfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_eject-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+py+0R3IFQUtruXVqn3kkWyIARR4rqKvoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_end-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+py8Eb3ENRggrxjRnrVIWcIoYd91FaenysMU6wTNeLXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+player_pause-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+py+1vgoxzyUCxrZd18ClfmIyVyJ1lqkHuC0N+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_start-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pyxudwlNyguqkqRZh3h0gl43hpoElqlHt9UKw7NG27BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+player_stop-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+1vgpySUWpvXXqrHmSaeJEYhKYq6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+previous-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFwyXOzC7PTq9OTK7IQyhBwCHNRi7LQCzPSi5IQ6jLwKzORy7AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ8EMhJKwg4W5o1EGAIbt8wEERhHJ0mIEmiLAH5IYxi1JcnvTOeTdDYcVo1gfHY+hxs0IkvSpV2qtgswB8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+prod-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBIQChCH5BAEAAAAALAAAAAAQABAAAAIihI+py50Bo4SKHlsDwk9fn21gJzIcV37miKpuZ0nOTBt+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+queue-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBMTC/Pz+/CH5BAEAAAAALAAAAAAQABAAAAI5hI+pFrEahGgPtCinS2GMlknU0Xkflm2l6YEiw8aRGssTXLe3lZsznvuRViwholEcLZCfynGT8BcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+redo-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxOHBxSHBRGHKzCtNzu3MTSzBQ2FLzSxIzCjCSKFCyeHDzCLAxGHAwuFDSCNBxKLES+NHSmfBQ6FBxWJAQaDAQWFAw+HDSyLJzOnISyjMTexAQOBAwmDAw+FMzizAQODDymNKzWrAQKDAwaDEy6TFTGTFSyXDyKTAQCBAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ2QIBwSCwaj0hAICBICgcDQsEgaB4PiIRiW0AEiE3sdsFgcK2CBsCheEAcjgYjoigwJRM2pUK0XDAKGRobDRwKHUcegAsfExUdIEcVCgshImojfEUkCiUmJygHACkqHEQpqKkpogAgK5FOQywtprFDKRwptrZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+reload-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCRaJBxWJBxOHBRGBCxeLLTatCSKFCymJBQ6BAwmBNzu3AQCBAQOBCRSJKzWrGy+ZDy+NBxSHFSmTBxWHLTWtCyaHCSSFCx6PETKNBQ+FBwaHCRKJMTixLy6vExOTKyqrFxaXDQyNDw+PBQSFHx6fCwuLJyenDQ2NISChLSytJSSlFxeXAwODCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIBQGBAMBALCcCksGA4IQkJBUDIDC6gVwGhshY5HlMn9DiCRL1MyYE8iiapaSKlALBdMRiPckDkdeXt9HgxkGhWDXB4fH4ZMGnxcICEiI45kQiQkDCUmJZskmUIiJyiPQgyoQwwpH35LqqgMKiEjq5obqh8rLCMtowAkLqovuH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+remove-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBMQCBEQCBIQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMuCLrc/hCGFyYLQjQsquLDQ2ScEEJjZkYfyQKlJa2j7AQnMM7NfucLze1FLD78CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+revert-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAAQCBPwCBPz+/PTizCQeHDQyNBweHAQGBAwKBDQ2NPzu5PTi3ERGRCQiJHR2dPTi1CwqLPz6/Mya/Mxm/GQCzFRWVGRmZAwODFxeXExOTExKTERCRBQWFMTCxKSipMzKzCH5BAEAAAEALAAAAAAQABAAAAV9ICCOQWkGIiqsQloCKCqy7UC8MC4URSsMhsDBNWOJEK4TYJfoGU8vmmJBGI5SyyYj0XDQjMvVQwBxRCQTilowFGwrjG5kTo+0x4OdpcLvV0YXIhcGGH0ZFRobOSccfB2PHR4FiyYAGQwdAI8eEAdQKBsZmR+RBpSVVyMHfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+rotate_ccw-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXIQChEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM0CLrcHjA6JcK4ET68MrNDoIgjOYbdJ4IXagIa3IqVFAMEOqpfn067ErBxG0qGsCJyyQT4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rotate_cw-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBIQChFxaXEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcHjA6FaG4YbS6At5BR31UKI4mADGhd31rpbmCuZ6qQLA8XvqT2+QhHLKKxqSy4U8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+rotate-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXIQChEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM0CLrcHjA6JcK4ET68MrNDoIgjOYbdJ4IXagIa3IqVFAMEOqpfn067ErBxG0qGsCJyyQT4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rsub-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAQABAAAAInhI8Jwd26YJBUTVvT1Rlt3x2f6DjQeQiGigLCC7crK7+yC9sty/oFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+rsup-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAImhI+pGtZ7gpwQyWofnnQ7I4SiuAjlqZgpmqgti7gxfMh1OY6LXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+run-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChKSipMTCxLS2tLy+vMzOzMTGxNTS1AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJQqDYyiDGrR8oWJxnCcQXDMU4GEYqFN4UEHB+FEhtv7EBIYEohkjBkwJBqggEMB+ncHhaBsDUZmbAXq67EecQ02x2CMWzkAs504gCO3qcDZjkl11FMJVIN0cqHSpuGYYSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+signature-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAFxaXPwCBAQCBDQyNPz+/KSipERCBAQChISCBMTCBPz+xMTC/AQC/MTCxPzerAAAACH5BAEAAAEALAAAAAAQABAAAARwEMhJZwgCiM17DoMkEGRpAmGhmSxhAOrakim6DgeLJApRhCPCgJRT8AhGEVFIQigAxgSQsBgwms8oIrDKDZNGxJY7GuYQULHhQj4shAmAuNAQsFc9xY4uUNgvMiQOBIMOfncjeUhICocXAx6RfwF+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+spellcheck-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPzCxPwCBMQCBIQCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrcGuHBNZ+NIOJ9O4MTaH2e1nDoiFYZJjgwIAzwy8yEgy84RhWDQa4HCwAHxJgxSPApC83YyQnwJwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+sqrt-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBIQChAQCBAwODAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMyCLrcDiHK6eIL9WmsmwWCAAyiwkGKGILihzLq8p1s9onE9a48Iy28ko/WgRCLyGTDnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+stamp-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xMTCBISCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLrR+zAIMQKMguh6GR2g1QEBCBLiGGjo+DSpS3IqXNqxNAnwzisSk3BowRltM8IAZVMqi84lLNoqUVfLrOhoVPgTACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+start-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TAQCBBxObISevNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAQSHBRWfBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnAwmPBRWdByixAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZrQIBwSCwah4HjUTBQEogFw/M4BQgMh2pxijAkFAhBYJwUPq8LRsPxWDwgkSHhelA0JJIJnlKRWy4YGRoSGxwcHRsecgAfICEiGhMjJBglVVMRgBkgJp0El0MRJyhaRFqipUoAFqmqrapHfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+stop-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/Gw6NGQuLHQ6NGQmJFweHFQaFPTm5PTa3PTW1Oy+vOS6tNSinKReVDQWFPz+/Nx6fNyCfNyGhNR+dMxybMRiXLxGRIwWFNx2dNx+fNx2bMxuZLQWFBwWFPTu7Pzy9NRqZNRuZMRSVLwmJGwWFNR2dMQiHPTKxMxmXMQyLMxmZNx6dMxiXMRSRMRaVKxybMxaVEQWFMQuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaaQIAQEBAMCAWDYcgkHhAJxYLRcDQBggckIplQKpaLdRh4YDIaSWa94Vw6woAHgv6AMKGPaMQhwQMJJRkfhHmEJhdvRCcgGSCEkCgpbnAECiorGYYfLCItlAAFCygQj5AfbYlwBQwVE5AukG6KBi8tMC0fLi0pHxyzcAAxFxwmMny/wEwOxMm/qlcdJCSJ1H5XQh3a28HY3kx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+sum-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBIQChCH5BAEAAAAALAAAAAAQABAAAAIdhI+py60BowyPJriwQ3qb7oGNyJCZtZHixHpu4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_block-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py40Bo5SOzRvrwlgrfnkJOIkPaaaJXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_bold-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+py70BowPQ1HZpwNv212Vg9IGHmIjoWa4ey5DSRNd+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+text-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIlhI8Jwe2/AmpTynqPTXSqrnBM+I0kdmpmGmUp+K4nPMvhYx9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+text_italic-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+0BgztwUmmjBXX3jE0auHHhM5Yq4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_under-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pu+FxXoOIKpds1oBH7hlYxYxRCaIZ01lhJbHy9tTv7BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+toggle_log-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBATCxMTCBPz+xPz+/ERCBASChISCBARCRAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEIQJqpXBBjFI1oGncYU4EUXxSWQZlum6DXDQpeo0tR6KqqgdLXiLBWepHgyYIxF/TKHv9XvtDDfb0So5YHuTgThYCXgH4Q6hqvEGEIm4PLGSyHX4OkZv8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+top-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBBRObAQSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixCQ2TBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwSA8ik0kgUDJhGQsFwgA4FBUTCoLBiF4zGtmt0FBYPSEQyoZCvWQakUok0LISnkHBBYjIVGhscS0UGHRUeHyBWAAIhiYuNAggVIgmMVgYjJBolAZMKJgpIjaanRH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+transform-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCBPz+/Pz+xFxaXAQChAAAACH5BAEAAAAALAAAAAAQABAAAANOCLrcEDAGt4K4F46wmcVCQIzE4F1DukksehVkiUlDYcdfCAyEGI+D2aP3G+UmPF/MAJpwnpuNgMmcKHKgabWSvRi+ums3a32wzmWKw58AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+undo-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxSHBxOHMTSzNzu3KzCtBRGHCSKFIzCjLzSxBQ2FAxGHDzCLCyeHBQ+FHSmfAwuFBxKLDSCNMzizISyjJzOnDSyLAw+FAQSDAQeDBxWJAwmDAQOBKzWrDymNAQaDAQODAwaDDyKTFSyXFTGTEy6TAQCBAQKDAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ1QIBwSCwaj0hiQCBICpcDQsFgGAaIguhhi0gohIsrQEDYMhiNrRfgeAQC5fMCAolIDhD2hFI5WC4YRBkaBxsOE2l/RxsHHA4dHmkfRyAbIQ4iIyQlB5NFGCAACiakpSZEJyinTgAcKSesACorgU4mJ6uxR35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+unlock-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+up-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObAwSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixAQSHCQ2TAQCBBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZfQIBwSCwaj8hhQJAkDggFQxMQIBwQhUSyqlgwsFpjg6BwPCARySSstC4eFAqEURlYhoMLBpPRUDYcHXt7RgUeFB8gIU0BIoiKjAcUIwiLSQUkJRsmGIwJJwmEU6OkfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_choose-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcGlAs6UAYgwLdLtEcI4ygQo7VVp2oupGpG4vmaUVTemX523qlFcw0a4RqNlkx5k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_detailed-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMmCLrc/i1IAVkYg1Z1iRYUKCqitp1oikqBWV3ZOnhkWNagqu+qnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_icon-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrcG1AwGOQbw6qANeCEB3pCSZpO6pgowJZqLKuUGE0dnuEhf8IL1kz1shSHDX8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag--16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ+QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7Kmpl0CtLGLvbW2Zn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ8QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7GLArS5Q7O1tmZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag+-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6cAsLECrqeys7WxpqZdtK9Ct8C0fsHAZn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_multicolumn-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrc/ixI0WSgKoyBl+beQFACpo1AqXbKCr1wLAMWS08hGG3dSZqin4sxnBmPD38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_text-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIchI+py40BTQSwuovp3DXkv1ia1IHmIXLiyWJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+view_tree-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBDQyNPz+/PzerAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAMuCLHcri4yGISlj4kxcANgNRBQCIbL6U1Su7bB62rXvGydG25kqpwfIGxILBr9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+window_fullscreen-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBNTW1MzOzMTGxLy6vKyurJyenHR2dOTm5Pz+/IQCBOTm1Pz+9Pz+7Pz+5OTmzOTmxOTm3Pz+3OTmvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVuICCOZAkEaKquqzAQRWEYR32gSK7vO5oowKAQmPAtjkPFccEwLoaNhuPYDCSeT2B0+lhAfMHF1kF+PL5W7ZhrjqAk4gW53J0s3AG4nP6Y2BcUKAxLZn1+S4EBDAwQEIsUDBQRFJSJLJcoJpojfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+window_new-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXGRmZFRWVGQmhFwmfFxeXOTm5MTCxLyWzLySzKyCvKSCvJxyrJRmrIxipIxWpNze3AQCBMTGxJRWtJRatIxOrIRCpHw+pHw6nHQ2lGwulOzu7Pz+/Pz+9Ozu5Pz+7NzexPz+5Pz+hPz+3NzevPz+BMTCBNzetMTCDPz+xNze1NzezPwCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACwALAAAAAAQABAAAAaVQEBAMCAUj0aCYFkwHBAJhWLBYDQcD8ghIjhIJhRKxXLBZDQaiYQLABDe8PiSu+HY7/dOh+PhQvB4eh8fIH6Adh2DHyGFAn+BiQAiISMkhnmSIQAlI5KXHIkfAiUmpCUnhoKLISgpIikmAlwqtCArkiUlIhwiuSKyEcHCESausMEsycrJEaaly9ARIizN1NPQ0dfJfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+window_nofullscreen-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBNTW1MzOzMTGxLy6vKyurJyenHR2dIQCBPz+/OTm5Pz+9OTm1Pz+7OTmzPz+5OTmxPz+3OTmvOTm3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVsICCOZAkEaKquqzAQRWEYR32gSK7vO5oowKAQmEAtfr9hgpFoGBWJpDDqcAaOUSHDEU08nkOG2AGBfK/aMYQMiRi7Ywe5674yE3I2JCqZoChLeGwSEgmFfgFNDQ8NjQ0TEROSRSyVKSaYI34hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wizard-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+xPz+BMTCBPz+/MTCxISChDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAREEMhJg6BYWhAGv5k2EKMXToSgEqc1DEIhvGAWpOvJFSXZyoXOxxY0BDahQDGg4xgOxmbgiWDqpoeqlGrVcZuSbLfpjwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+abbrowser-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipMTCxISChPyqXPzerPz+xPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARhEMgJQqC4Xms1tkIgDEMYXpMYEEJRCIT6Ea5R2DHFtQZBG6dNoHQrsAyH14DDWiENBsQhBtskEs4Dohe4oiqE5So2zElECEKCrCYgQmcRVnRKnFIdC0L4/az7GXiBg4N+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+access-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGRufLzi7PT6/NTq9OTy9MTm7LTW5LTS5LTO5KzC1FyGrExSXHzG3Gy+3FSStPz+/ESGpFSmxEySvEyKrER6nERylExqjFSSrKze7EyCrDxulKzG3GSuzGSitEyWvER2nEx6pKzO5DxmhLze7DxqjExihERadLS6xERulEyOrLTC1KzK3ERWbERujFRefGR+nKTO3LS6zLS+zFRmbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAa1QEBgSCwWhYIBocA0CA6IhEKwYAQKDccDAolIJpSK5aKwFhyYDGSQoWgqm4uFYyV0PAeIIPIeayZlVw4OFV19FxoSGoFnH1tcayASIRciVgYfEWoQIxcLk4gHlxQCnJBcJBUSdAEHhQediSV5ExWBBxYQGSZelLkHJyhWsHmSISkHKpsrViwWJ1xPXCAtesIBCiUaGHm6LiYvLybXMAQCMQosBwcoMjIzMTQMAC0M9vf49wB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+acroread-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAASC/PwCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIlhI+pELshmkOhzmTvyZrFDglRxVEiGUoUualtx7gOC36gDGt+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+agent-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipISChPz+BMTCBISCBERCBCH5BAEAAAAALAAAAAAQABAAAANLCLrcHkFBt4IY8EYKYCAT9xVBYRhbM5KFeaRVy56oSsgQ/TLrB567ym10ChiCnRIRaJx8lDdd86UkEWjHaURZwlKRHpM0xPOYGf4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+aktion-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAI5hG+hIuigAmMvLTlfnJiePQndt4SMFFioeaagaEbvySlQF6I2BLPRwYntDLlaylH8VXLDpaiJ8BcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+alevt-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/Pz+/AQCBAT+BPwCBAT+/Pz+BMTCxCH5BAEAAAAALAAAAAAQABAAAANFCLrc/i3ISadQYQhSehFecAGiYJ6oiJmaZrymSrKCJhinXLYmHo+l2skn0KGOPwyBUHPhOrqKVIWsmhqHyqhhPUG+Cn8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+applixware-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBKSipAAAACH5BAEAAAAALAAAAAAQABAAAAIyhI+pGbsBHYtHCGARbMhms1HVB0TieJhcl23liXkinAmhy7732UL9GnsZeixczChB+AsAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+ark-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBAQCBPyCBPzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLoQwTBK6dy8WNQgptAbB33DQGzlx3xE65RpBwgtCw9sR7e1gO8EGYs3DMoUH5rPqFylSrzaygcjHqdQVUYL8ScAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+arts-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPz+/KSipPwCBISChAT+BARCBMTCxDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAAQABAAAARTEIQ5xbgYAwJksFhhaFTVdeLpURYwAOL7cp6gpmcZHEQPGyIOLRAkiI4GTqmIDG5QwGihuRIBU8boasLzZbEd082QK7VkrvTwo2pvP5m4GxHP+CMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+background-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAAQCBJx6NJR2LIxyNJR6NKSORKyaTJyGRJyORKSWTJyKRKSWRKyOPKSKPHRKLEwiFDwSDEQeDGxGJLSeTKSSRKyaVLyaPLyaTGQqFFwyHGwyFEQWFDQKDDQKFEwmFMSiTMyiVJRuNLx+LOS2VOy2ZNSKTFQeFGRGJLyqXMymVOSiVOy6ZOymZKxyTEQODDQOFLymVKxuNMRyJOSeNMx2FLxiJLRiHFQaDDwOFDQODFw+HLSiVHxSLFQiFIQ+HKxmNJxOLJRSLIxGHDwODGw+HNSSPOSWNNRyFOyyVOSOPARihNSORKRSFLR6TPz+/MTCxKTi9JTW7GSy1Lx2THw+FNSOXJRWNISChASq3ASWxARynEQaFMx+JJRSJFRWVARafARSdHxeLFw6HPz+7Pz+5GxKJDwSFIRSNHxGNPz+3MSCPNSWTMyGNPz+9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAfXgACCg4SFggECAgMEBQYHBwgJCAoLggsMDA0ODxAREg0TCxQVghYWFxgZGhscHR4LE7GCHyAhIiMkJSatJyi+giApGCokKywtLhwvBzAwgiMxGDIzNDU2Nzg5OjsTghc8PT4/QEFC2EMeCZUARKpFRkdISUr09YIYET0qS0wqTUpOnkCJIkWQhxsbpsigUsWKkidXsGTRIkjHgy0YuMjoYkKJFy9KvoARFEZMBAg3UkIA6MTJGDKCBpQ5aebMGTQsx4xJU/FBBIxq1rAB4KTNS56Gkg7yEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bell-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBEwuFLR6PLRqJHQ6DNyuhLx6LKxiHDwiDMSOXLx2NKxaHAQCBHxSLGw+FKRyLFRSHLR6NIRKFExGHNTStOzm1KyqfIRmNHx6PIyGRFxeJNzavOzq1MTGpKymfKyqhKSmdGxqNDw+FPTy7KyuhNzevISGTJSSXLy6jOzq3Ly+lJyabHRyNCQmDKSifAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ6QIBwGCgOj8iAYEAIIJ+BguGAeCYTigXDegw0DI4tl/gQj4WB8hkAgUQeEsaEC6FULBdMRjN/QjYcHR4fICEiVn8jFCAkHxiHfiUjHRYfHyZmR4kdICAeJ5lCECgVKSorJysrLC1IEBgVFSgunSAaoWwTIi28DL5HfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+blender-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBDwiDPSyNOyKLDweBFQuDFQyDPSeNEQmDIxSHFQ2DEQqDARWjARGdASO5AR6xAQiPOymNAQ2XARqtAQKHOSmNEQiDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVqICCOQBCQKBkIA5G+63C+RW3UrIsSQt8fA+CMREAQgIkaUEdSsBK6hZBUeJ4YjRLQIKoOBgVAw/GAAAqRk+EJBkgmDQrAUDGxTAMBAgCR89oFOgF5YQAWdy8EeTeILyV5jY5nBAGFkpJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+clock-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+colors-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBAQC/MQCxATCxATCBPyqXPwCBPzerAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgZ6rwYBCFsvtXWeWA1DBU3ggRhomJQBm14dlJYFFXrbjKNwVDZ9Vw4TWWoKyCDgcNhyXQClVLpMmANIRAhLdGa+36j07GrfM4GiKTAGfsOlmYZfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+cookie-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBNzeDJR+BOzmVNSqPOSmBNSCBKRCJFwuBOSOjMRSTLRaXFQODMxiXOS6vIwiJGwKDHx6fKyqrMSOjNRWVLRaVFwCBJyanJSKhHRydPTy9PT29OyytIQSFPz+/JSSlOTGxIQyLMTGxNTW1Nze3Ozq7OTe3FxSTGxqZNza3Ozu7OTm5MzKzLy6vLS2tNTS1FRKPGxWRMSypJyOhKSOfPTu7LyupFQ6HMzOzEw+NJR2XKyOdFxGNHRSNJx6XGRCLHRCDMy+tGxONDwaBHRiVDwyLEQuHJRyVJyCZLSilIxiPIRePHxOJIRWJFwyFEwqDCwWBBQOBDweBKSCbHRKLHRKHIROHGQyBFwyDDQaBIxqTHxOLGQ2DDwiDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCgwABAoSIiAMEiY0ABQaHjoQHCJOECQoLDJeCDQ4PEJMRERITFBUWFxgZhKQaGhsKHB0WHrcfEQARGxu3HiAKIRgiIyQlJicoGym+KissLRIuIi8jJTAwJjEyGzIYKxszNDU2Nzg5MDY6OyQ8PT4jP0BBQkNERUZHOkhJSktMZDQBcsTJEyhRpOybcuSIEipVrFxBgEVKFigATkiRgkSLki1UgFzh8kRKFEQbN3aR0qULIT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+date-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+dlgedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxFxaXKSipPz+/AQChAAAACH5BAEAAAAALAAAAAAQABAAAANLCLHcrSLKOVccAuvMLf2Rlw0bYRKFGBGZWQioRc4kPKfB+qFFL9ODF+EmKxh6vZOreETCbLiMESkcxnIgATXK2XgFqmxI4SgvAP4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+emacs-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBDQyNKSipPz+/FxaXISChMTCxCH5BAEAAAAALAAAAAAQABAAAANJCBASoXCFoVi8VdL6HHQeB4YjSAxnYQygSLzoSTjbEs9vMF86cbyH34NX+AELQ4zO+Nopm6cBC1PBEQwG6gd3SGo7Xa1STIb4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+email-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGRWVAQCBOTWvKSShDwyLOTazOTaxPTuzLSilOzi1OzezPzy7Pzu1NTKtKySfPzy5Ozm3Pzy3PTq1NTCrMS2rNzWvNzOvMy+rLSmlPz69LSejIx2bPz29ISChPz6/Oze1HR2dOTi5Pz+/EQyLJyanKSipOTm5MTCxHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaGQIBwSAQEAoJi8RgYEApK49FgOCAS0CFTsVAwEA2CIysMJB6QCEQyoVQsZOMFk3loJoeNAk4MGBQOFAQcDw8IfFoLDB0cEBMICIRxAV6NEB4aHwICk4wLIBYhIiObSxwLBSQkJaOlfQUFpCYnIyMoSVGbtQK3UQCbKCYprkq8m8S+uL4AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+energy-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBBQSFASiBHS2/JzK/KzW/JzO/ASWBATCBASKBHy+/Hy6/ByuHASCBAR+BATOBARyBIzC/MS+BASeBASOBARaBFym/Pz6BASuBEyW5AR2BJS+7Gyq7PT2BARKBDyC1FSS3IR+BJyaBLy2BPz+BCxuxAQ+BDw+BOzmBARiBCxyxBxetPTyBAQCPAxOpAQ6BAQ6jAQ2fAQ2hLy6BAQubAQydAQmXAQmVAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwSCwaj0hAYBkQBJDLAaFgOBCWxcAAkVAsGIyG4/EUBh4ICCIicUAgkwTZjKBULISL3oHJzAMaDhscHYEODhMeExEfSyAhGxsgICIYHiMWJCUYSyYYJw8kIigoKSomKxgmSywYfC0YGCJ8rSwuS7EYJBYYLi+xE5tkARMoMCoYEzEiJDIzMjQiSzExMxGkNTY2NTc4NTNPTOLjWElHfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+enhanced_browsing-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBOTWzIyCrFRSTMy+tCQmVOzi3ExKhAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARFEMhJq6UhyHy3GNmnAeNEFAZwpuRRBiIMkkOBjKuKTsHtgbISybTLYX6hGc+lSxk3tVtMVOkFck9MMNjB7jqkEQdMlvgjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filetypes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+/ISChKSipPz+/PyqXMTCxFxaXPzerPz+xAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARfEEgZqg0zV8EHF5XWEUMxkBwGBB9REIZLfBgrkEaen+l6F4cYgpA4vEC+ASIYSxQRnlrncEgoFFQP0laCHpSmnk+AEJQ8ZeRkw0mDVJT3JZQZw+trC77Ouu8pfn8AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fonts-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+/KSipMTCxPwCBFxaXMQCBCH5BAEAAAAALAAAAAAQABAAAANBCLoQ/C+I4GAMY1ZGN80UJ2jA0BFbUxhjF6BWsQroawEyWhN37vKxQo0ChPhOPaGDIhhADr5FinE4TG5PrBbiTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gimp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/FxaXMTCxAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM6CLrc/izAJVWoD4MgtL2R0F2k6HFiOgjDSRBq0FLUKxYDTmKBnf6gGqz3egWFhEvSQ9kxJ9CotOFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+go-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBERGRFRSVDw6PDQ2NDw+PPz+/ERCROTi5Pz6/AQCBKyurERGPOzq7ISGhNTS1DQyNLSytExKTLy+vKx+RGRiZPTipEQ6LOzu7PT29JSOjOzWlEw+LIyKjIx+dLy6vOy6ZEwuFHQ+DCwqLGQ6HNSWPMymfIxmPMyqjKSipCwuLMzKzHx+fBweHOTm5GxubJSSlAQGBHR2dAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAadQIBwGAgIiMXhgAAoGAwH4QCRKAgVCwSB8AwwCo2n9ZpwMMSFhyEBGQoLEa5BMnkO3G/Kef2sMIdfCxYXT2oGGAIHCk0ZCBobHE8dHk8MFR+LgSAhXSIRdmNCBxScBiObCAYZI25wJE8SJSYECVVDCg8dERchJygPKSqsQgQNKwQFCw8fLC0KLi+LxH9YMDFX0ngAzzLZ2m4K3kN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+gv-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIxhI+pwaHZ2jNMWMFmvXk1GznHF4DhWF4cJlKpynpwB73ms3Etiq00EAr+hJGJ0eAvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+gvim-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+BPz+/ASCBMTCxISChAQChCH5BAEAAAAALAAAAAAQABAAAANUCBDMEqupNWoNJNgBV/mfwYCFqASgmA1h57VaO71lXLtPytZEBggZ0E7Vy2BQJEaRcDghP6iGb/IsNKBWKghZzb5EUau4g1KFz1QId+ydRRZwiD8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+help_index-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPwCBAQC/IQCBATCxMT+/Pz+/ISChAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEIRJJZ1ACjF3GGAYaKNFDNfXldLJqmQWcKhcW6tkl1NhFJhdRmIwHIq8m8R3LAIlykCxiZQNl8XsU3eVZg0Y2LD3CyAQlassbEaz1N32Gz5m+SMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+hwinfo-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBBQ+XBRCZAw+XAw6XBRCXCRObCxihCxqjCRijBRSfAwyVCxehDx6nER+pPz+/BxKZAwmPFyWtGyevCRSbBxWfAxGbHSqxGSatCxulBxahBRKbAQiNEyKrBRKdAw6ZAwiNESSLCyCDBxWBDRulBwyRHS6ZDSWHCyKFDQyNCxqlAQmRAwiPMzalPyCBMQCBCx+DAwuRBQqPITCdFxaXCyOFAQeNAwmRAxKdPz6/GyyVMTCxKSirAQCBGzKZAwqTAweNFyuRDyeJFzCTITOdAQiPAQaNHzCbES6NEy6PESyNDyqLDymJPz+xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfBgACCAAECAwSDiYMFBgcICQoLC4qCBQwNDg8PEJERlAYNEhOaFBUWnokBBw4SFxgOGRobCxyJBQkNHZoPpR4fICEiIiMBCSSYmgoKFgslJicoKQQKCSoZmgW+KywtLi8pMDEbFRqaAcwyMyc0NSkiNjc4ObsrKyU6Ozw97j4lNhGSfsgAEkQIDxr7YAwh0qKIDSM2jgRpgbDHPhFIMiZRsoTJkhMgobUDMKKkySYjUKockYJSypcrWypKQbOmTT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+icons-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPz+/ISChIQChFxaXKSipPzCxPzC/MQCBISCBPyqXMT+/MTCxPwCBMQCxMT+xPz+xMTCBPzerPz+BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV+IBCMZBkAqCgMa8uyJxoMRFHUtz3Eqk0MBhxBwJsRaqTcLhUQ3AyHAMI0EtEI0pGrpU38SANFQazYGY+LqUChYDQUxCbB8YjOFJAIpGEePOpZAhITIxJxAg8JDwQPMxISERESfXSVTRIQAZKHLyuOFI8US1RNnTApqCJUAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+iconthemes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPz+xISCBPz+/ISChPz+BIQChFxaXMRaBPyqXIQCBPzC/MT+/MTCxMQCxPzCxMT+xMTCBPzerMQCBPwCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWLIBCMwhgMJqCKRBEIpWAMBRGsQXG8sIAiLpwNZpAFEAcbjlc0OI9BVcAWSDgHT9MtF1AsZrmamNpNBAyjwgCxpo0U5h1jOhg0HAMbPHB4QNIDEQIRDi5xfgFzBBITIxJUBQ8UD305EhIwEi45FQ+dFVMSES+PIy2nLgUSBpcGQVomqKc3K7WwIwB+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+input_devices_settings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxHx+fISChKSipKSirATCxAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARQEMgQpL03iEEx1gOxdR5YbCJXZUbqjusUhGitZkFri0VFUodXoTfjWCi6oY8Skxl6k4FhxZRRRxMC1TBdWn0CAbcZQFAH4WnGjDPiPICYPwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kab-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChFxaXKSipDQyNAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANICLocHiyqIMQYUE5Ses8S1V0FGInFIJTalKpsS5FxKDxB/EzV4GUBQsXR87BQnRtNtxphfJ9FAAqbRqUXVfPaMH5MDRx44U8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kappfinder-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExOTDw+PExKTPz+/ISChAQCBPz6/FRSVIyKjJSSlIyOjGRmZNTS1Ozq7Ozu7AxyzPTy9ERCRBQWFIyqxPT29AQ2vOTi5IzG7DR2zNze3Nza3BQSFISy5CRyvBQenISmvBQitMzOzAQGBAw6rDR61Hx6fMzKzAz+/IzW7ASyvCwuLMTGxMTCxBwWFDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQAAgEBAYj0ahckAoEJ5QgkE5fBYO0SeCOigkFE2DeEFgUAUNBwGBeBAcCMHirF4gnhBCBCE5PydqBBQVFhdTSgJPBk8YGRQaG4dCiQQcDh0eHyAhIiN+BHYXJCUNIggmfhUOAQgbJ6YCKGcVKSUaChwGHCYqCyuIDhkhGyIsLcccCL6TFxsNJ8fRLS7KvyNi2GIrAQwK1AsvVOJULi4AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+karm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPz+/ISChMTC/MTCxPzCxMQCBPwCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEIRJa5Ui66H3FETHdcTwdcIofkVbUIJbmAEoZl95aoXxUrNdpnAIDFomgRA3yxxhIdxAlaKhAgUNYshyYVGxnMZInS6VzVSQPG0bkWaJZT4B+CMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcalc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBATCxARCRASChAT+BMTCxFxaXEQCBPzCxPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEIBAq5U4iM17wJMwjORIfJkYFCs7nKA2rJQLp0Su66ikGcAg8OYTGA6BA/KAIIYsFudPGJQal8uAFVqxUg2JxBYbUGh7k5J6BppwKyB/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcharselect-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/MTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANBCLrR+zCIGWCcI1cLpNCa5YHZsCmj2QTlxrZmmRFVSs4E7X13TqMTXsl36gSHuSIQQ+QYP0kncPCTokzWh3LhTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kchart-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+/ATCBAS6BPyqXPzerPz6/Pz+BPwC/MQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARcEMgJQqB4WiFulhvXfaEwiJ4mEgExFCMVcENgBEXepdVhG7dcABGr/IJCQ8ICAt4IUIuSKAW2XMOD0qC42AIHV4277YIqKHKCy5txbIoyDy2Nr80yjyVwn5OYfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmdevices-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPyCBPyqXPzerPz+xPz+/AAAACH5BAEAAAAALAAAAAAQABAAAANMCLrcHjA6BcW4Q8AWLL7EFSwdOIRoOAKBiZ5EPJYvBMeDba5BQfg52ik4KPgKOVYqZiwYjLzb7/c0JCnSo3VFasFEXE5kMymbzwp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcmdf-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmdrkonqi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPzerPz+/PyqXMTCxPz+xAAAACH5BAEAAAAALAAAAAAQABAAAANKCAoRy+6pIESkVuLaKl8b53lOaA3EyIXBUBjpWHKDYNhxNrWv/aaRiWBwKwoIDZCH2EN+TMQjyzR0yhgqiyo4vT4wl48E8g0C/AkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmkicker-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFxaXPz+/ISChMTCxPzerPyqXDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgQqr11AjG6/4FGDEVZBOapWSXbToFhoKkZUjJGEEJvyUDDYQaKATElBOJklB0OgY5SWgnmpFJm4PkMjDxLFYXFGSCyN8mocDaD0xsSO6wUS6K1FBzDD/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmkwm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCRiXCRaVPz+/CRmZFRWVISGhMTCxESSjPT29DR6dDyOhDyCfPTy9CxqZOzu7Ozq7ERubOTm5ARehAxefPz6/ByaxBSOvBSGrAxynAxqlBR6nBRylAxmhARWdFxaXCH5BAEAAAAALAAAAAAQABAAAAWHICCKQTCeqCgMhJCihXEYSPuKRWIoC6PYsEZikHA4FA4CEJdoJh4QgXRwiOAeQudDIpEZIpPwhCImhyGGAmBSOVgumExG055w1ZPZhpPpUDwzExBqAAUDhxUVTQ0QEgWOOIcDiU1QjoSFFYiKDZYFmAWJlE9bkCM5iouWpiIfBa6frrKYAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmmemory-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChAQCBMTCxCH5BAEAAAAALAAAAAAQABAAAAI6hA+Bu+HCmgiiRuNoHZBRXQlc84TmcHzm2WVryE1YvMaZIdbVd2zw7lj4bDKGbxK8hHgX3K2JUDD8BQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcmmidi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXKSipMTCxPz+/AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLEL/pDJAONs1V2W1ebWJ46kKJxomi5D2QZEwRSyVMNyngf7Eg8FYHAIZMRoyCSNMSA0n85oszTxJwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmpartitions-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmpci-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAADQyNATCBASCBKSipFxaXAQCBMTC/ISChAQC/IQCBPyCBPz+xPwCBMTCxPz+/AAAACH5BAEAAAwALAAAAAAQABAAAARVEMhJqww4a33F+EL4jUI3EEXoEWzaFbAKzyUQeLihDqrpHQhBQkHyqY49iWCxbDKfJQbASYUCpJbslcHter+NQ3gsLo8bBYd6zWYf0u24GjWr22f+CAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcmprocessor-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipMTCxISChFxaXDQyNAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrc/jDGQCWgIleH88jCdgXgB4JVQJxsVgQXIQvrWdwwJc/0jcOG0Y7gqwQVQR3R+EgyJcGjZUoF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmscsi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxKSipISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLoQwZAFIV6UYgxi79Qa52WDE3bKV6YOpFpO3L5pJcckLBB8/wQEDezWAQpZqIWxFNAUkqkg6HmJOqGuArUqwfoTACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmsound-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQC/AQCxFxaXAQChAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrcDiE+F4SQU4UBLH6VoHjT1okQR6mnuTYuJMWaGlkXW2u4QOipRYDws82AjJsHKez9MgrigAkF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmsystem-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBGxqFAQCBPz+/PTqtOTOfMSyPNze3Ozi5KyeLMTCxMzGzKSipOTe5MTGxAAAACH5BAEAAAAALAAAAAAQABAAAARfEMhJQah4ihFunsFAEIVXCVJACIJhoBK6CerawsA8HAhbuAnYZrBDKBYMWpCy4S2QSRazyBIwrrjcoNFQzK4KR1bQcHhZjGM2BgWLMYJ2enForHPJtNj+kfHvcB8AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmx-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIAAAASC/PwCBCH5BAEAAAAALAAAAAAQABAAAAIlhI+pm+HB4HkS1flszOCq7C2Qw0wdJ2Lk16BGeK5dSZX2jS9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcontrol-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/CRyBBxSBExOTNzipOTijOz67NT21LzutJTmlGzaXPz+/OTi5AQCBLy+JKSiJES2NES2LESyLDQyNLy+vLzWhLzWjLS2tGRiZDymJASChIQCBDyuLLzShDyiJMQ2LATCxMQKDDSaHDSWFCQ6tMT+/PzCxLzuvCyKDDSSFKyqrMTCxGzabDw+PISChASSBAT+BDzOPNTW3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAacQEBgSAwIBsikkFAwHBAJhWBBpTIaAccDAolEJIKJWEzBMiuWCyYjaLjd5exDIsE02A1NY9OIMzkcHRkebW99WFoVahkfbSANIYdCBh52IiOFb2VCByIWIh0kbSUNJpIBJ6CgKJlwDUIJKSooswIUt7crrwEsKC2+rC7CLzAuuzEoycmtbgAAAtDR0DLGztYALbm426/Wht9vzn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcron-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAADxePARCBAQuBNTS1OTi3LSytAQeBMTC/Pz+/AQCBOTi5MTCtISCZAQiBISCfKSipFRWZGRiZERCRHRyZMTOxDxOPMTCxIyCjCQiJAQOBLS2tAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAWFIBCMpCCQpDgQLFusLVEYAXEgOJIQOXIkNF5v19MFWQrCgsFYxIC1InEYvOWmuF9QKrw2aoSkYtksOBwEaBeXeEAiiIdD8rUNJw8EBUGobIcQFggXLglgCohLGA95CQMOGVFDEQ4YGhERdAEWCZ2dDwsSEHMOEA0ABqmqGRkGDQ2pDRV+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kdevelop-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBGSKXEx6RFR+RFSORISidJzCjJS+hISydHSqZDxuNIyuhKzOpLTSrKTGlHyybGyqVDx2LHyedKzKpLzWtMzexLzavIS2fFyWTDyCLCxiHNTmzPT29PT69NTm1GSWVESKNCRmFOz27Pz69PT27MTKxJymnIS6dESGNDR6HFyCTIy2fNzm1Ozy5JyenISKhISOhMTKvESGLBxaFOzy7JSWlIySjCx2FBxGDIyOjOTu5BQ+DFSGRDR+JCx6FBxODDx2NGyaXCRyFCx2HCRqFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAexgACCg4SFhgABAgMEh4MFBQYHCAkCCocLDA0MDgcPEAQRhRITFBUWDAcXEBgZGoQIFBscHRweBgkfICGDAQcUIiMdJCUmJxgoKbsAKissLSQuLzAxFgQyKTOCKgk0NS/fNiQtBBk3OIIEEC0cMDkvJiQ6ICk3O4M8FCQcNjAcJBM9fPwgBCQICxI0XtBgQeCGEHuEFGCYwILFBAJCHh7SEGJIRiI/IDaagSNko5OF/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kdisknav-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBERCBBQWFPz+xPz+BISCBERCRPz+/OTm5HRydAQ+XHR2dKSmpNTS1Hy+1AxypNTu9ITC3ARypExOTFSyzHS61JTK3MTi7CwqLBR+rASGtDyixFyuzDw+PAxWhAxmnBRypISitCRujAxelAxmlFSixMzKzCRqlMzOzMTGxMS+vGxubLy+vLy6vKyurCwuLGRiZLSytFxaXJyenGxqbDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAafQIAQEBAYh0jkQEAoFAxJ5EGAaAoSh8BBEUBSrQtGw5EodwHfgsBgeEAWijGW2XTaDRHJJExBrwl1AhUWFxgRDwdCGWkCGhsbHB0WGB5CjB8fICGOGxaJaWwGIiMfJCUTJh50dk4ODiejHyiff2oGDikqK7osiUIGai0pJyouxi+9v2pEMDEyLTIyDckCy0gBMDM0DTU2flFDARk3AH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kdmconfig-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxISChMT+/ATCxASChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMg5gw00yyDGIAR1YUDggeFWFIZhnSBZrsZxdIOFEGTA2oeBAHeyuGwvzxBlYdUOLROMFzDQntJPrNoqAKUBaqnV+k57ZORruykHDj2LqIzUVKp1u0iuB/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kdvi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/MTCxCH5BAEAAAAALAAAAAAQABAAAAJCRI4ZwCYPo1gsiIHHxY86KXmWdiGkCA1Wp6Htc07NOsEv2oVyldLHbuBgEhORJhOxGEkkiLJybCZ3iqrD08hmF/4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+keditbookmarks-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBASCBPz+xPyqXERCBARCBISChMTCxPz+/FxaXAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARXEMgpQ6B4WnGzDgJHWWMYdkAwEF1QFKe2oqDZztr7GpfKjrvAAeFDpQq8ISIRYBotSoTUkiC2ostqYps49BSKIVfaBbcC4MMWcTAbU+iw21NBk+gjuj8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+key_bindings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/MTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANMCAoRy2IEuYIQDsrBld0NN4XaJF5iCppWxBGtCscEAbkDfH2wh+ogiudD5AhvoZWoJEFtckBTE1dzKKfQjMtUjfQUzizjeBN7HgB/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+keyboard-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/MTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANBCLrR+zCIGWCcI1cLpNCa5YHZsCmj2QTlxrZmmRFVSs4E7X13TqMTXsl36gSHuSIQQ+QYP0kncPCTokzWh3LhTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+keyboard_layout-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPwCBMT+/AQC/Pz+/PzCxKSipISChAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARSEEgZqr1hUjFIEQXBZVogDt/XYWxgoEVFzEUt3MGNm7SND4aarPfBFQYCQmtpiTErh+ahMK1SqVHoYcvtUptX67SWDXTPXWltva5q0WfEs+WPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+keystone-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxISChPz+/MT+/AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM/CBDcHkoFQasVUIrBe8fRNDwMAWpjUThmtmxk0IYwOaPx/V6XG3hAjmsRa0Qkg6NSOVo6F0nG88g4TUNDpT8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kfax-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+/MTCxISChERCBFxaXPwCBAT+BARCRAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARVEMhJQ6C4imEzDkLIXR4ADqFAThYRoFu4ti6YbhfdFm+aEzWgAWhB5QyGAMEwWA4PlpyFCWwOkAhCgla1EqxXKbD7vSJnyuUXyV5JuOxtqZV0z+3+CAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kfind-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExOTDw+PExKTPz+/ISChAQCBPz6/FRSVIyKjJSSlIyOjGRmZNTS1Ozq7Ozu7AxyzPTy9ERCRBQWFIyqxPT29AQ2vOTi5IzG7DR2zNze3Nza3BQSFISy5CRyvBQenISmvBQitMzOzAQGBAw6rDR61Hx6fMzKzAz+/IzW7ASyvCwuLMTGxMTCxBwWFDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQAAgEBAYj0ahckAoEJ5QgkE5fBYO0SeCOigkFE2DeEFgUAUNBwGBeBAcCMHirF4gnhBCBCE5PydqBBQVFhdTSgJPBk8YGRQaG4dCiQQcDh0eHyAhIiN+BHYXJCUNIggmfhUOAQgbJ6YCKGcVKSUaChwGHCYqCyuIDhkhGyIsLcccCL6TFxsNJ8fRLS7KvyNi2GIrAQwK1AsvVOJULi4AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kfloppy-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBISChKSipFxaXPyCBAQChMQCBPz+/AQC/MTCxATCxAQCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgZgggz5zAIBp9GFV8oSqRkikFanapBVgccGAiJBDWL74jd4UUxGBI/IcJQMigSimPSsMDcEFCFVkptKhCDgSBB7m4sA2y5eqqMF2YYKMBgys8nfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kfm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBGRiZERGRPz+/MTCxAQCBMTGxPzerLy+vLy6vPyqXLS2tLSytKyurKyqrKSmpKSipJyenISChJyanJSWlJSSlIyOjIyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV+IBCMZCAIQKoGw0C8MFEUqmgYrTwXL50GhtegcCgedr4AIpEYHhQKopEWSCwYw1fUeBQxGo3hiBCIUR2OxyAwG8OoD0hkICFABMiZKBKZ0GNkPiIUFBUuEoiIMisVFRZ/MWwqAheVfxICdZIpmZZ1kYIAMxcuJWWhKXl5Kn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kfm_home-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kfract-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBAQCxAAAACH5BAEAAAAALAAAAAAQABAAAAInhI+pyxudwoNACiFbuBzHt3XeEYbiBF5mN5HpyayqVrY0hdj4vvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kghostview-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/MTCxCH5BAEAAAAALAAAAAAQABAAAAJCRI4ZwCYPo1gsiIHHxY86KXmWdiGkCA1Wp6Htc07NOsEv2oVyldLHbuBgEhORJhOxGEkkiLJybCZ3iqrD08hmF/4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+khelpcenter-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/FRWVExOTKwCBJQCBIwaHFRSVPz6/LxSVOSqrNyanIQKDHwKDHwCBPz+/OTm5Ozu7JwCBMRKTMxubLxCRNTW1IyOjDQyNEwCBGQCBJyanMRaXNyOjKQODIRydKQqLOzCxEQCBNze3Ly6vJQKDDQ2NIQCBCwCBGwCBFwCBDw6PNyipDwCBKSipEQ6PDw+PJR2dMRiZHwSFPz29BQSFIwODJwuLMTGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAabQIBwSCwaAQHBgFA4Cg2BwwGRUCwYxobD8YBEBpLJoEGMUA4VywWTaUQOmstww+l45MKM5/DAf0AIDSFFBiIHI3IEHCSDRgEOFSUAJhQNJ0coYikAKpB4RQwrJiycWy0uRQ2AKKQAL3wwKEMCMDEdGEMvWxIKDTICIzMQKZdDKQ0dMSAxBzMPGjRGGCkoNTYaNzTRThgnJ9pFfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+khexedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTC/Pz+/MTCxFxaXPz+xPyCBKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARZEEgZ6rw4CB3wrJUggt03nANIoCUQoDDcvqJAaHXqunBxywFDZWArDHy4lOEwTBEKgYJRyeQJEIEnYrQsvU63abBKIYq2m+4s5mTeTLVRSFdmyy6kvGXijwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kicker-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/FxaXMTCxDQyNAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECLrcEDDKGYQV4+qbie9eGIJEVxTe+QmjUFgnXLLr615oF8x2v0I8DWpF2GV6slkLKSMdYT4nS0WgSkXYAWUbcXgX/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kiconedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwC/AQCBMRaBPyqXPzerPyCBPzCxPwCBPz+xMTCBPz+BISCBMT+xATCBAT+BASCBMTC/AQCxAQC/AQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOpBicZQoEwjAE6hgQQwvH81AU8OnfuR3QYDgcgAKhjGj8+UgzQkHHw+2mQlQpgEAkFInEYnGDhr/h8VPGYDQcjcZj/iiv4u84vQ6FQCISERETgxN2AX6AgoQThlBOkCR+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+killustrator-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPzerPyqXAAAACH5BAEAAAAALAAAAAAQABAAAANHCLrcGzBK+YK4OAcAx4AXIURj4J2fJYhWh35pOHKoG8+mFxS5HimmXU8HBH4MQyJD+FI+kM3Ug9eENALQk9VhDW4c1y/YnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCxCH5BAEAAAAALAAAAAAQABAAAAIghI+pFrHbXmpRMmoBxXB75IWcKIKk022ZunJtdlSw5BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kjots-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPzerISChPz+/MTCxMTC/AAAACH5BAEAAAAALAAAAAAQABAAAAM8CAHc7kGsR1mc9d1Md/icIgXDB1YXMZQnZBJEIbdKABPGTbSfnuc8mw8W1OlotYER2fgod5iMKRqiNvwJACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+klaptopdaemon-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipAT+BISChFxaXPz+BMRaBPyCBMTCBDQyNAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARtEIBAq5w1TBGEGIM2ESTlVUNhaAFJUAcXgAXCZkFyJEoiIArWYQjj+Xi2yfBA0SU6CuAts4MCk4EdcxbznFhOCsjrWUxRhbRBBk48Z6kCZ2GeuN9xucF8FqcEBnt1OW4saSp7IoRPEjgiGBV+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+klipper-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFQyDEwuFEQuDISGhFRSVEQqFEQuFPz+/PTy7Nze3PT29Ozu7DQyNJx6VIxuRIRiLEwuDIxSFHxSHKSipLSytGRiZGRCHDwmFOzm3HxOHIRWHOTazHRCFHxOFEwyFNTKvHROHFxeXJRqLIxWFFw6DFQ2DNTCrIRaJJxuPMSynHRKHIxqRMSqjGRGHMSifJxeFKyGXHxKFLyaXKyObGxGFEwyDKyOXIxeHKSOdFQ6FIx2THRKFFw+FKx6NKRmFKxuFLyCPLyOTLyabLSefLyijFw6FJRmJIxWHHRGFFQ2FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfFgAAAAQIDBAWIiAMGA4IABwgJCgUICwwKDQ4PEBGCEQsSEwUUFQQWDRepGJ4ZEggIDbENrxobAZ4cHa+7uxAeH4IGICEIIsbGFggjJCWCJicovLwpIcAAGCorCBbc3AoILB2rgy2u0q8OLrcAJS8wr8nJrzEy6yUz79sivDQ1jQA2buB4tU8eghw6xgnYwePcqxcdbAjq4eMHECA+ggiZMYRIESPjShyBgQPJBB48OsiokaTDOoACItgwYULJhw8BbIzzEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kljettool-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxKSipISChFxaXATCBDQyNATCxASChAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMg5Q6CYBiFsxhvXXZklimRlDWenBQNRzKJRXCsxHPFcIDGcILYbGHqzAY41NCQSiuNgMLPAmNTElFoFWKecqe8mCRAIq6nt5imb0TC2wZByny3zdslMr3+8fgB+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+klpq-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxFxaXISChPz+/ISCBPz+BKSipAT+BAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJqwUh3xqEz8EWDKT3aVNAFAVBDqYQYitbjARhGDJt34Nc4SBAZAomoDAhKAwyTZZp5XE+O0lp9QVFeLNWUpflJXheTww2ijiLKSBPW/C+xOmzjQRU8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmail-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPyqXPz+/PzerMTCxFxaXIQCBPyCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMgJgrWU4iAGIUFWFYMldF+okUPJeeAUDEY7FFzXqnNdkIGDgHAKzWgsDuJAFBhbtd1peTAWDFjpaZg6skonYfOZzC3HlduuMj1UZUDZ6RMblTTDokylQYsyFwB+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kmenuedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxAT+/ATCxASChPyqXPz+xMRaBISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEMhAq5UY2B3yFGDIYcFgnuNErGwQCl1VzHSJBsbBUSxBIbnEC0YrxICHhFKZCiATlldn8gSlNE7YEurRQHdd19Aa3m6nmV0F448AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmid-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBKSipISChMTCxPz+BAT+BFxaXPwCBATCxARCRAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARUEMgJgqVYWsFv3lwoeFMwEIQYkkFhouoQlIFhHvCgz9oxjoeDblc6+Q4B4ZBXCSBQx+GIZhNAOURaACsYypq0kNeSSLC2uxm5fGZqAgqFO0OjT/wRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmidi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/Lz+/CH5BAEAAAAALAAAAAAQABAAAAIzhI+By7oBo5RH2GvDRRhre0xiVHXZVpqfEI5iKkQxalzQIIPGhI+pSAN4cjqA68VIHvwFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmix-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXAT+/DQyNATCxMTCxPz+/AQCBKSipASChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgJQqCXziDG2JoUEENhZBkmHIWJVptAmqcIW/Js1MiF56TBzkckAAcHoa9nMRKeA4TyJk0knsHhTeK5khBaH2VwLYVh40TJhQ6RzeIQV32Quz8hfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+knewsticker-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBMTCBPz+xPzCxISCBKSipISChCH5BAEAAAEALAAAAAAQABAAAANTCBCsysEpseQDI08KSPdYNmwUYSraUDRC64iAMbIuLGtOS423BhKFmgj2C+5EhsOoWEsOnB0FsKl0jnLUp3IG0O2sMNpRVHBAJpjyA8KOmNsMfwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+knode-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAABwaDAQCBPwCBDw6NERCFJSWJAwGBLy+rPz+7IyOJJyeLBQWDIRqZIxydPzCxDQuHPTWzOSypBweDKyqLJyWJKySjPTOxKSCfOyCfOyKhJSSJJSSLFRWTDw+NOSqnOR+dOyWjOzGvNza1ERGFJSWLLy+ZPTGvOTOxOSSjOy6rLSypJSWjKSinAwODHR2HISCJOTWtPTe1Pz+9Ozu5IyKfNzazPy6tExCHMzKfPTy7KyupKSmnEQ2HHx+HKSiLKSiJPz65OzuzOTmrKSmLIyKJLS2TPTyxOzuvNTSlLy6fHx6RLy+RJyaNLS2NNTSnLy6lLy6dMzKpGxqXCQiDKyuNMS+PLy6VMTGPMzKrOzq1CwmDLy+PMzGTNTWxMzOxERCPKSiNCQmJERCRERCHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAQABAAAAffgAABAoQBhoOEAgOGBAUEAocBBoOLBwgBBAkKBAsMAQ0ODwOWEBEBEhMUFAQVFhejCBYYGRCGGhsKFBwdlh4fICEIIoMjBRQkJSYnKCkWCCorLIMtLgUvCjAxMjIzNCw1KoY2NxovFDjbMjk6OjuHNjw9Pj8lMggIQEFCATaDBD4JhhApgsDIESFIkigxJGDEkiJFmDQB4uQJFBxPokgRMIVKkypFrFxBgCVjlnuXtARQUGTLFS4yunipgRLBF0I3moChgsQeAg5hxDBMNCUAlyAcOCBKxJTQmKVNBfgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+knotes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBISChMTCxPz+xPwCBPz+/ISCBPz+BMTCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARIEMhJZQg1z6vzxR0VCKE4gCE2lhcRnF1LuAInBjNRfDMn64WCQRCcHS6IRE6nyB0Sx0ACkcwloFiflKp8Pm2bbRblkYJZHX8EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+knotify-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/Pz+BPyqXMRaBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMyCLoQznAFIUKE09krZ+VS9XBaMBBbZKIBUaSYa40kTIPNhyvazje+G2gFI8l8jaLCnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+konqueror-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxONCROfCRKfKx6LNy+bNTOpGSS1DRupAwyXBRSnPTSjPTqvOzqzMzSvHSSlKy6ZDxutAxCpBQ2XBxepLTKvPzqzPzy5OTShLS2dLSqRFR2jBRerBQ+jOTixOzetNS2XHx6XDR2tCRexBwyTDyKzOTavPzq1OzKdCx23BRKtCQ6VCQmHFSa7IyirOzSnGSGpIR+bFSO1DyK7DR+5CRixBw2VDQuHFye7IS27NzGXISuhEyS5DR25BRWxBQ+lBQyXCQqPCxSfGyu7GyerKy2ZFR+rERqfCRmxBROtBQ+fBwuTBwmNDSW9JyabLyqRIx+TExSXBQ6bAQCBBQ6ZBxapDR+zBxq3LyaLJySRHxqPGxeNBxGbCRmrHRyRERONDRKNDQ2JCQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhgABAQIDh4MBBAUGBwgDCYcKCwwNDg8QERIThRQVFhcNGBkaGxwdoYMDHhcXHxggISIjEiSvJSYXJwsoISkpIyorLIIDLS4WLzAxMjM0NSo2N8o4OS46OzwzPSk+P0BBgkI8Q0NERUZHCEhJSktMgwk4Qy1NTk9QUVJLphCiUsWKlStYsmjZQiJgIS4KuijQ4iXAFxYCDVFJwGUFmDBhMjYSw0KMyEYoBfkJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+konsole-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+korganizer-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBASCBISChFxaXPz+/Pz+vKSipLy+/MTCxPz+BPyqXLxaBAQ+BPy+vAAAACH5BAEAAAAALAAAAAAQABAAAARmEIRJqw1ikM37FsFQjMZ4lAVKBESBjCYsFiuBkkk5KG1dJL+CZjBYMES+l2x3RCBqtxHBOFD6DkHmAQj0yXgzmFdIhY2erBJBwTiczDSWq0Eg1gvYrvyHxcMdUEojYWIYHocbDX4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+korn-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBMTCxPz+/PwCBMQCBFxaXISChKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARSEMgQpL03CEExDkO4dR6ghSFBkJa2CSlRcNX0voNQ5Ebn3pvdAWHo/W6IHUJwGFCAm+SrSTm+ZgcY6XnDhlim3wwxKNYymiX17HmCSxO4/OKPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kpackage-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xERCBMTCBISCBDQyNAAAACH5BAEAAAAALAAAAAAQABAAAANPCLoR+7AJ0SALYkxd79za12FgOTlAQBDhRxUFqrKEG8PyOqwEfMeKwGDI8zVGul0vFsAFdaxB43ecKZfUKm1lZD6ERZgBZWn0OpYvGeJPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kpager-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBFxaXISChASChATCxKSipMTCxDQyNERCBPz+/MTC/AAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARWEMhJZ7hADFI4+RpwBYBxFJ1HmMiYJUgiJPI8Bwmp7HyvyBOfMCHR+QwzhAAhMvZKSFgRIOwtJczqboFoBasGGVNUKVNGaEyTlEYL1sX2pYXOyO8XfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kpaint-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BAQCBMTCxPz+/PwCBPzCxPz+xPyqXASCBMQCxAQC/AQChPyCBATCBMT+/ATCxASChIQCBKSipISChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV1ICCOYxCI5kmigTCYBKGW7WAH8QyYrn3LNFesYDgEjCVXIRYzGgWqgA2BICQUx9pMSkUssgsbFOWighW+7c24KDAKDccjCjVCHAEGo/GYl+wPLwwRfF8oT2mDAwuGWVJiARERAxITJkhaJhMSlJY7NDQpAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kpixmap2bitmap-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwC/AQCBMRaBPyqXPzerPyCBPzCxPwCBPz+xMTCBPz+BISCBMT+xATCBAT+BASCBMTC/AQCxAQC/AQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOpBicZQoEwjAE6hgQQwvH81AU8OnfuR3QYDgcgAKhjGj8+UgzQkHHw+2mQlQpgEAkFInEYnGDhr/h8VPGYDQcjcZj/iiv4u84vQ6FQCISERETgxN2AX6AgoQThlBOkCR+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kpm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxKSipPz+/ISChAQChMTCBATCBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARbEIBAa5BYUsHF+FQ2EUTHfUOoFQVpeuAVGAbrnmg603U7FD8UxXDgGQgoYMyAIBoSyI9Sx2seoj/lRlDFTmUBDs0L0gg2CGwFs93oWJdMOwCPiybhguout2f8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kppp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAAT+BGSOhERadDxKbDRKZExWXKzG/KzO9KS+tER+lBQyNERaVOTu5PT6/OTy9Lza5LTatISylHSilCQ6LNzq9MTa/LzevKzKzIS6dBwuZISi9MzizLTW3Iyy1IymjHyGbCwuLDRGXHya3HSe9Jy+/MTe5Pz+nPzmhOTSbGyGXGx+XCwyLHyinISe/NzifFRKTFRqXCQmJExSVFyafFyC9MTCvAQCBMTCxExKTDw+PMTGxLy+vNTS1Ly6vMzOzNza3MzKzHRybERCPDQyNPzCxPQODHR6dAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAengACCggECAwQBg4qDBQIGBwgJCouDCwwNDg8QERITlIUUDhUWFxgBC4mKGRoGFQcbHB0eHyCLISIjJCUmJygpKiuLEywjLRYuLy8pMDGLATIzNMk1Nck2lCDJN9TcLziKOTg63DvcPD0ygjk+P9zcQDVBQekAQkMgPjzcPfLy1wAgiBQBAYIHkH5BbPwTBGKIQBBBjAQBsXCRDYJGZFSkJOhIM45+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kpresenter-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwC/AQCBMQCxPwCBAT+/MTCBASChATCxPz+BPz+/ASCBAT+BKSipAQC/AQChARCBCH5BAEAAAAALAAAAAAQABAAAARhEMhJq70YhM2D5UIYDARHBUWxEcRgHKgncWyLuPEc1MOAJLfBRsNSEBYbH8kw3BEUyABjZHzJdsiGI6AYLBQG5qykDSy+jwdLpimj1aVhe7tIr00a6Q4uP02dfRVygRZ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kruler-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFRGDPTijPzmnKSGDOzWdPTahOTGXOzOZOTKXNzCTNy6RNS2NMyqHNSuJCH5BAEAAAAALAAAAAAQABAAAARkEMhJKwg4643FEIQHimHRfaiYmoFxvMLhwi5r3IaA37rBIomgABhEDBM/hHLJVCBYCwFjYVxQBdYFi8GQertSLqshaJgFZbK5wXI4BO63W/Bwt+HzON7BKvj/gIAcgxoWhhN+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kscd-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBKSipFxaXARCRPyqXPwCBAT+BMTCxMT+/AT+/PzCxASCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARbEIRJa5Ui672nsNYgegFhFoRhCuJAEgcsE+wYfHIc0y3JbT2QsOJCGG+/zyShMCICregEsUgEnNCe6/rsPkPTY2LxZLEOh4DEqbBmRQyGen0kjgB4ySSPp+D9EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kscreensaver-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXAQCBOzu7Ozq7OTi5Pz+7Pz+xISChHx+fMTCBARWlARepOTm5ISCBNze3ARalARanKSmpARSlHzC9ARGfLy+vKSipARKhAROhARKfJyenNTW1AROjARSjMTCxJyanNTS1JSWlMzOzNza3MzKzJSSlMTGxLy6vLSytKyqrAT+BIyOjPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAalQEBgOBQYj0fhYEAoCAyHqPRgDAyIggPikOAeFFVCYMHImqnfaiPAKH8VcLij+ghAGJFFlnuUCAJ1ExR5AnACFRUWF39/CxETXQoYGRoaFht/HAEdE2AeGRgVFBUfIH8hmx4doBihGokifyMPAiQcISEjJR+7HyZ/JScfFigpKSoSFxsiKywCAEjR0QDU1AIJFi0tFgnP1dYJ4QgJ4+Xe1tLTAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+ksirc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAAT+BMROTPz+/KQGBFxaXAQCBDQyNGSGzDRivAw6lAQmbCRGlAw2jHSS1BxGpAwiVGyO1CRWvBRKtJSq3AxCrEx2xAxGtAw+pAw6nDRmxAQmZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVYICCOQBCQKCoMaRsMbCvPNE3cRA0QRWEciIQigQLyfAtGqtFwPI6GFgQReex60WJEYr36UpOtQgQlUQAVieUyLoskY8Bhi3liEZJ6MaOmWCgJGjYGhCl+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ksnapshot-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBATCBFxaXISChAT+BASCBAT+/PwCBPzCxAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEMhJKw3YViw6HkRgBUVnCkG4GUV5otthsO6A3KJEHm6R3AOYTtAy2QqzHCDwMpiSk8DsxIFGpc6T9YJ9GpSb7laDSYI1yzNa448AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kspreadcalc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBATCxARCRASChAT+BMTCxFxaXEQCBPzCxPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEIBAq5U4iM17wJMwjORIfJkYFCs7nKA2rJQLp0Su66ikGcAg8OYTGA6BA/KAIIYsFudPGJQal8uAFVqxUg2JxBYbUGh7k5J6BppwKyB/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kspread-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPz+BAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANFCBDc7iqIKUW98WkWpx1DAIphR41ouWya+YVpoBAaCKtMoRfsyue8WGC3YxBii5+RtiEWmASFdDVs6GRTKfCa7UK6AH8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+ksysctrl-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBISChHx+fPz+/AQCBAQC/AT+/AQCxAQChAT+BLy+vAR+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEIAgqK1YzsG754QUDERpmkEpkkXrtoK6EcVgHIibhnNx564Yb0TDvQq7FQ34EiqPOhnREqhWSUPsyZSQAbbg7GcMEgwUiYVivTa1R+y4XEGoWO/4AMAfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ksysguard-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBExKTERCRERGRAQCBFxeXKSinIyOjJSWlKyurKyqrKSqxPTy9LSmxNzS1Nzm7JyitJyipMzOzLS2tOz6/OzW1Ozy9Oy6vNyCjNRydMR+lNza3LSurFReZMTG3Pz29OSmrMx6hDw6PKS2zMTCvOyytOSWnMzi5MTa3NTS1LzCvNTe5Pzm7PTK1PS6vOSapMyKjNTy9KzCzMzS1GxqbISKxOzq7Ozm5Oza3MyytLzS1Nz29OTy9LTS5GyGtOTe3MzKzOT29OTm5KS2vKSurNzy9LTW5OTi5Mza7NTm5KS61KyytOT2/HyChHSChHx6fNTy/LzKzMTCxLS+vMze5KSmpLzS3Ky61JSSlLTGzLTa5FRSVJyanKSipJSWnJyWlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfagACCggECAQEDBIOLAAEFBgcHCAgJAYqLAQoICwwNDg8QERKXjQYTFBUWFxgZGhsJHJcdHB4fHxUgrCEiIyQCjRwWthUlJiG7IycoKQQBKisfLC0uLzACJzExMjMBNBI1Njc4FTkBOjs8PT4/3UBBQjc8FkNEQTtFRUZHhyQySEkHOAyxgOCcEhkSLC1ZwSRGEx1OnBx4EgNKFCmKAkyh0uNADBpDOpyQ0YNEAEJVIFjBZg/bFRIRSAXAwiFLDyNaesiYEJMRgS1cupDg4OXLFlI+DwkQgBSAn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+ksysv-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxISChIQCBAT+BAAAACH5BAEAAAAALAAAAAAQABAAAANWCLoQzlA5IVyIK1S9L7PDsFHBIJXDFFaViYYEUQpy6orEqq12Aw+FmkjQQxEKwQCBSCz5BrGYkuc06nKU4s8gW4q0UAN3+q3CZJfJRhJ6fDwZOGbhTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+ktalkd-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipMTCxARCRFxaXASChDQyNATCxISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEMgZqqXU6gCuDIJQDQTBBQX3hUFpmN2hFaxhIPCJDrRo46dPglf7BTvDXsB2OwaSCd8tZ0kWgZ3Uk+hDvHRV5bfyybACPNmkY2EVZKpM5UBPre8fD94fAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kthememgr-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBASCBATCBAQCBDQyNPz+/MTCBPz+xISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhJaw1V6Bs0HgIWYFMnhSERkiU6ekM1FO9IGMcxIFK3jgGDzRADhAypQipI7A0OId1IaGhKntHDjWogTLCB3JbpvULD2ir5i0SPDYjy9ZgWDuQUwqBLLFq+ehZ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ktimemon-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPz+BHSG5PxSVDRW9PwuLPQKDFze1AQi7CH5BAEAAAAALAAAAAAQABAAAANDCLrc/lCFGeKi1YktAH5c92mcR4HloA4P4RLAyjovLLdvvD5FX+gqgGFoUPh+N2IRcAQcngch0ehzQqVDas/6xBb9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ktip-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBGxubFxeXAQCBOzu7OTi5NTS1PT29Pz6/Ozq7Nza3PTy9Pz+/Nze3MzKzMzOzOTm5MTCxLS2tKSipNTW1Ly+vKyqrMTGxJyenISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVwICCOQRkIY0oORFEYqCoGw4EcSaHEarAgDESu4RioBIMfA1doPIwpZGJBhTQMEWh04GoqDBLtCKkYNL5hGUAwoZQfFYs46lBQLnK1SICJUCR5egMZGBgZcyoDGAwTh3oiAxMMhogpioyOjwADnIh+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kuser-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxISChAT+BMRaBPyqXARCBPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEIRJa5Ui673nsGAgeKE1Bl9AUEXbiqTlFlZaGUZoszm4BzhDAVf5BYbAXI+TAR6CS2ZGSZSEiIIqYIsSIEaJ7GRrlY7J1lKA7I8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kview-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BAQCBPz+/PzCxFxaXPwCBPyCBPzerPz+xASCBMTC/PyqXATCxMT+/ATCBASChIQCBAQChISChMTCxKSipARCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV0ICCOYxCQaBkIwpmKJsu6qDkIREDMZFwUAYNwRVuxgLfDAUGEsRIJo2LRapUE0ABDsa1aAcZoo+stsnIMwcDQcDQUV9MjF4Q4GJFiQJJuGSYOFHkwezJ+ExUUEicmYDITARATAoomLiuQJhKTlTRgepYBfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kwin-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBFxaXISChASChATCxKSipMTCxDQyNERCBPz+/MTC/AAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARWEMhJZ7hADFI4+RpwBYBxFJ1HmMiYJUgiJPI8Bwmp7HyvyBOfMCHR+QwzhAAhMvZKSFgRIOwtJczqboFoBasGGVNUKVNGaEyTlEYL1sX2pYXOyO8XfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kword-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPz+/FxaXISChPwCBEQCBIQCBMQCBMTC/ASChARCRAQC/AQChMTCxAAAACH5BAEAAAAALAAAAAAQABAAAARiEMgpQ6B4WnGzDkLIeVs4DAIBWFcpnKJVzCUcz8ZxVOKN/AWNKRQo5HQYELHwQxQSHR7HqDuwMIRisxBQLBbRFdUaYCwYjUZHywIxGI53K0jolRkJdLkhtKwaeWpJYW0AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kwrite-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBKSinJyOfPz27Pzy7AwKDExOTJyWlERCRKSelPz69LyyrKymnPz+/MS2fDQyJAQCBOTazLSiXOzivMS2jKSSVOzmxPz25NzSpPTu5KyebOzixNTGjOTWpMSydMSybCwqFGReVKyaXNzSnGxeNJSCVMS2nPz23MSuZIR+bJyShLyqnOTOtGxiXIR6XOTSvIx6RMSubIyCdKSalMS6pOTWxMzKvKSabJyKTOzezHxuPGRmZKyurMTCvPTq3AAAACH5BAEAAAAALAAAAAAQABAAAAajQIBwCAgIiEhiYEA4FgwHRDKhIBAWz4OhgGQ0FAPHA7qFEBONb0Qy0ULeQ2+aUrFcMI+3GYBOZzQbHB0eHyAhIQByDREiEwMjFRIkJQImAgJ+jScjHigkKSorLC0AKg2NFSMoki4qCy+IQgITKDAxkjIzNDWkQxQoJaskMgk2Eb1DNzgoOCoHDDY5yEIwJToAOzw9ET7TQiREAhkZ3kmy5QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+laptop_battery-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipAT+BISChFxaXPz+BMRaBPyCBMTCBDQyNAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARtEIBAq5w1TBGEGIM2ESTlVUNhaAFJUAcXgAXCZkFyJEoiIArWYQjj+Xi2yfBA0SU6CuAts4MCk4EdcxbznFhOCsjrWUxRhbRBBk48Z6kCZ2GeuN9xucF8FqcEBnt1OW4saSp7IoRPEjgiGBV+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+laptop_pcmcia-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwC/AQCBMRaBMTCxPyqXKSipFxaXASChISChMTCBPz+BPz+/PwCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARfEMhJaw3Y2iDGyJoUEIVRfIHGEcaBHCc4jcWbGG2cAuuhKIZE4mX68EgI3M/wORgQGAHr4HICD4NCKoBIJqsv7w6DKDgNi0VuN+O+GIxFl00hlxjakIhbo4cwfnoWfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+locale-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/AQCBPz+/MTCxISChMxKTKSipFxaXERGRGxqbCQiJDQ2NJQaHMwmJDQyNFRSVOR6fGwSFNxSVKQqLFQODJwaHOyGhOySlNRCRMSuBPz65PzupPyCBJyOLMxyJOTKRLSiNIR6JExCFGxaHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaPQEBgGAAYhcWjUMAUEAMDQtIIZRauBaZhKhwIsFjBgFu9HgKHrHNI9QYQCQQarWB313D5Ik68BxgIDQwOCgcJD2wBWwENEBANEQwMEBITFEIOQhWNkhENFhcYl0l/GRobHB0MGBAeo1QdHxsaICEfpyAiQlQhICMiHyMgs8FKASMjRiK/yLrGStDRXNFGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+looknfeel-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/ERGRExKTLy+vKSmpAQCBPTy9Pz+/IwKFLQWNPT29GwOFExOTIyKPHx2NPz2pIQSHLwWNMzGXFxaLLSytERCHCQmJNze3GxubLS2tHR2dAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWNICCKgVCWYwoEwUAMhXEQhhocRuHCMpIgiJVBptC9DojDIrFYwRS4wgGJZAIYuwL00Ej6FjOGEXZwPByQCNjAyrnKj4NkAqYUBIIoXC5pVGYUFgIXU2Z8fgdGFhgZiRqHf1EDFgCJGAcafX9aUSIFlxoFBX8vMYmemKJSY6Ijn6oHF26tKbAEGCaUKX4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+lyx-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBAQChARCRKSipASChFxaXISChPyCBATCxPyqXMT+/Pz+xPzerPz+/AAAACH5BAEAAAAALAAAAAAQABAAAARZEMg5Q6C4BnGzHsRgeVZRGIbYaekxuAFijUGRBOqMKPxlJQsLQxjoVWyWBsMxNEp+iRuj2VvVCklHLCZjiRrawGFmNQUajQ129RwYyCMSau2pcNh1AB7jjwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mathematica-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChPwC/FxaXIQCBAQCxAQC/KSipAQChPyqXPyCBEQCBARCBASCBDQyNCH5BAEAAAAALAAAAAAQABAAAARlEMhJ6wxChiFFCBUhENtQGIcBUghWDsHxWck7wMpKfXz/ZYBAYeCpKRQLWwkjMCpQJQ3TE8gdUgxPUMDlflINhzfocJB6BNEDqLnKpgRLTJZjBuIUAf1TExR0EyRASWmAFocAfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mouse-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBDQyNKSipPz+/MTCxISChPzCxATCBISC/MTC/AAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARSEIRJqw0Sg32rAANBFNwlhIQhGkNGAaSaouW0iYUBEIdYgzsUIqHAuWAoQlGEE9gMJKaU8IPupqLWy3qVkioAFqkLc9nCg3G5oxFr2ecavOOPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mozilla-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/JxqBHRKBGw6BHwuBHQuBKwmBKQmBIRWBGRGBMQeBKwaBHxSBFQ6BDwaBEwqBEQuBGQuBFQOBGwSBGxGBHQ+BOQiBPQmBLQaBKQaBCQGBIwWBLQeBDwKBHQSBGQ+BIRaBHweBIQWBNQiBKQeBJw6BPxGBNQuBLwiBPwmBKweBIQiBJQmBHwyBIxeBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZzQIBwSCwahYHA8SgYLI2EwpMoMBwQU2FCsRAYGQ3HwwGJSCYPCNnRoAgrlgsmo8hkLJpNpEjhbBYdHhYZEh9HICEiGRMjJAxPJSYmJxkoSocjKSorExYNSwMXLAwgDhYVSwUtRAMORwGfRR8uRpdGWEJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+multimedia-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBIR+hKSipPz+/MTCxMRaBMTGxOTe5MzGzNyytPyqrPyurLz+tKzqrPTy9LSytNTS1Pz6/Nze3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWAICCKQWmOKFAKQ9uWacAOJcEWQjDKrxHYJZxONRAQaL+c76DjyY4D4A+RC9B8xkPiQKCySsjAQZAojHMva9pk8iGrCsWC0Wg4HCvT4wApyO0FEAcRJhKGhzUEioolDw8TgYQBEYITCIQqE4IRCnQOEXyYJAFxCwt1dzAxbCcjfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAAQChPwCBAQCBPz+/MTCxKSipFxaXAAAACH5BAEAAAEALAAAAAAQABAAAANDCBoK8TAC8Vy8QUyGr9BaFwmDZonZp66sIhBwLBMFlRl4rhv1IxiDoHDYuw1yw2Dxl0wugTqnjdkUPmezJWv7QXX8CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+netscape-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAEyStPwCBNTKrHRqPAxSfLR6VNzWvAQCBEyOrFxGPMSWdKx6XPz69Ozm1PTy7NTOtOTOxKRqRGxCJPz6/MzGnMS6jDwmHEyGpPz+/Hx2bGxiPOTexFxWNLSmhMy6jLyGXNSqjHxSLLyuhMSyhLSqhDQeDJyWdJyOVNTKtPTu5KSONMS+rLyqdMy+lFxSNOTezKySPEw+FEQ6JKSOPDw6LNSylHxSNKyWPLSeXExGLDQuFIRiRCRCVEwyJAwODLyyjIx+TNzaxMy+jBwaHNzGvMS2hMS2jKSWXGw+JFw6LKR2XCQ6TDw2HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAfVgAABg4QCA4SIBAQFiAYHiIQICQoLAQwNDg0PgxARg4oSChMOBg0UAgYVBRaDFxcIGA4ZGhscHB0eHISKoxkfARsHICEiI7oBrg0kGiUfpCEBJiIngygbKQ0bG5kjKisbFSwtAi4HLx0cBwYiMDEyJh4zMjSKKBQuNTY3Mb8vODk6kLky0GEHjxUyeiigMMPHJ0UCKvw4sQFIECEqhgQUSCSChRFFWhg5MkMjkk9JlJRY4uIEixk5fOhAsuOkqyFLXF1oQYOJTiQIAigaqohCD6JD/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+noatun-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBCQ2PARehAwODASCtASi5ASq7JTK5PT29MzS1JyipISGjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJgrg3zDHkCEQoEhrnVYXBDUVRdmagHjT7AnExHPtg3LldzYXr4FA6juHnMXZkqaiGMpEtOdOmETpAIEy473fV9Xphq7P6DEgMFIpFWm1sJ+4JBec8SFAnd3pveH+AeHcSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_applications-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXGRmZFRWVARehAxehFxeXOTm5MTGxKze7JzO3ITC1HSyzGSmvFSWtESKpCx6nBxulNze3MTCxAQCBByezByWxBSOtBSGrAx2nAxqlARijARafARWdARSdARKbARGZARCXOzu7Pz+/Pz+9Ozu5Nza3Pz+7NzexPz+5NzivGxqbGxubNze1NS+vPTCvMzKzLz6vLzevPwCBNzevAwOBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADIALAAAAAAQABAAAAamQEBAMCAMikfjQMAsGA6IhGLBaDgeEEJEMhFIJBRKxXLBYDKajeTQBQAGG05n7vl8QABBNyTq+/8iIyRdJSJrgCMjJiYnhCIHEn+JiygpXQaGB32JKgErKiuNAoV+iQIGLBItLhOOgYkrmAYvLikwl6+Lo5gTtjFdLMHCKy8vEyITxV2tzBMFMTCWIgYlEzLX2NcwMy4vstngAS4tLyUGNODprdl+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_development-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/GxKFAQCBNSyhFQ2FOTGnJRuNOzWtPz23FRWVERGRJSGNMyyZHRydOzu7PTy9Ly6vOzq7Nza3JyanMTCxHQCBLxWVKQaHOTm5NyOjMxqbJQSFHwGBDw+POTi5LQiJJwWFPz+/Pz6/PT29NyWlMReXNyenLQqLIwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ9QIBwSCQGBMWkMDAgKIuBgsH5FBIO0+oSka0mFAsGtdpwLMbPxONBgCDJEQkEMnkn1RLKRGF3+CtCDRJ7AoUSEgAWFw+AChB8hYUYGRobHIwAHZGbHh8gayEhIqGiIw9+GBgSJBoliiGUrhcOJq0WJyAbKBUhnrocDr4ofkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_editors-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBLS2tHx6fOTm5Ozq7OTi5Hx+fPTy9Ozu7PT29Ly+vMTCxPz6/IRuPHROLPz+/LyOdLSCTNSmnOS6vPzmzISGhExOTJSCZPTSxPTKtPS6jPSujNyKZGxqbDQyNDw+PHRaTKRqVLRqRLxqTMxmPOR6NKyurDQqLExCRFxKLKRSFNza3KyqrKSmpDQ6PGwyBNze3NTS1LSytAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaWQIBwSCwahwFA8kgMOAVLpjMgGBCixamgECAYsELtoUAuXJtPRCCRMBu44ecBoVC0F2aC8qkIKBAICQx5X3INh3UMbQMOD05/AQ0QDQoMERITFBUVThZ1Cg0XFxgZGhobHB1KHp4NCR8gISIjJCQlJmGsCAULAicoKSoqDytIrAkGBCwMLS4vKTBNrAUJCzEBMjMuM35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+package_favourite-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+xISCBMTCBPyCBMQCBIQCBPwCBPzCxAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEEgZwrQzVyFq6Bj1gQOxgcBYDSzhnl7Azm7tpWT7VhdHmoFXzweqmYZE4I5C5AQKhkMAYbCMfM9EIWBAIKzNLNRbTRHCBUT6ewn6TOlyJuX2sOftS8YfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_games-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+xISCBMTCBPwCBMTCxMQCBPz+/KSipISChAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrQzVyFq6Bj1gQMxgsBYDSxhqunKtu5bpSQdFDfFkS9DgHD5cTwBIdFnFLiSw2IzGGX+AocDNHQ6GhCJQCJsGRqThm/CoMBUCNc1W9HWmD2Jdsh+CfkjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+package-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECKoR6ys2IVqokF08yMTA1gwkYX5WQK5ma4VceTYPxXnBWdtY6+0834/Bowgzm6APWRQcH4TiMhPK2WYRiZWW7XK7/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_graphics-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/MQmJPz+/LwuLLw2NLQiJNTKVNTOZOyydNRaXMxGRJQmJFQuXFRypFySdHS+VLTOfNzWhJQeHFwCBGyGtHyqlIzKdPTapAQCBGRCbKTSjOzqxLzG3MzmxJyanBQSFJSSlBwaHCQmJGxqbFxaXNzmxPzmzOSenExKTLSytAwKDAQGBMTS5LzerOSaTFRWVHR2dJzOhLTKdNyiNDw6PFxeXDw+PLSmvKS2zIyynLzSjNTKXNSGNIx2lIx6tISavNzSbLwmJHRWfNzWfIRurIyexOSmPJweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAejgACCg4SFAYWIgwECAQMEA4mCBYwGBwgICQoFhowLDA0ODxARCAQSkp0TgwwUFRYHFxeLARITGIUZFBobEgUBC7aRHB0eBcC3iRgfGAIgISKRGCMeIhgkJSYniBkoKSgqKywtES6bgy8iMCgYyhwxMjOb7Bg0NTYr7Dc4OTo7PPIrQoRgJ6iHjx8xgMwIEgmAkIMxhsw4lYgBkSI5LEQwcsRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_multimedia-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXHx+fHR2dGxubISChNTS1MzKzLS2tLSmpNSytAQCBOzu7Ozm1Nza3MTGxNS+vOy6vPy2tOTStOzq7Pz6/Nze3MTCxOzOvNTqvLT2tDw+BOTm5MzOzPy+tLz+tLz2tOTi5LSynLz6tPz+/NTW1KSipMy6THx6fMTKxKyOLNTGVPTmbLTOtBQOBBQSBKySLHReFLzKvLzavAQGBCQiDNzKVOTSXLSWLNzGVLyiPNTCTOTaZLymPMSqROzebOzeZMSuPBwaDMyyRFRKHAwKBOzibMSmPMy6RLSaNLyaNDwyFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfKgACCgwECAwQBg4qCBQUGBwgJCgsLiwAFDA0OBg8QERITlYMFFBUMFgYXEBIYGRoboxwMFRQdCAoeGR8glAABBgshFA8BCxsiI5QklY4lJQYbJiQbypQnACgpB5ALy92UKissAAQXDyktlBUuLzALMeG+MjPKNDU2LDc47yqC1Qs5dODYwYJHj3f/Yrxb4QPHiR9Aqr0I4kNFDCExdgxRQaSItyA8jJw4YvFFjBdCGtCotECFjhssVgRR8W8QkgVJlOBb8k3UID+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_network-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBPz+/CRKfERCRAQCBFxONKx6LDw+PDR2rAwyXMzOzOzq7AwKDHSSlKy2ZDxutAxCpExOTBRavBQ+fBQ2XOTi5OzWhFRSVBw2VGRmZDw6POzKdCQ6ZBRKrCQmHAwODIyirGSGpIR+bCRixBRKtCQ6VDQ2JBw2XIS27DRKNISuhESK5DR+5BQ+jCQqPCxSfFSa5Gyu7GyerOzetBw+XBwuTBwmNFSa7Eye7DSW9JyabLyqRBQ+dBRerDR+zDx+3Bxq3LyaLJySRHxqPGxeNBRSnCRmrHRyRERONDw+NCQuLCwqHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhoeEAQGJigIChQEDBIIFBgEHBAgCCYMBCgQBCwyhDA0ODxCcAAqRihGXiooSExSCsYoVDBYEFwEEEBiCrBmgGgUbigMcHRgeth8gAR8hIgQECyMkJSaCAicoICkqASssvi0YLoIvMDExMg4zrjQTNTaDCTcxODk6OwQYJmCYNIhHDx8/gAQRMoRIDRcEBwkoYqTIkSMFkNiISCjBCR40UiQxwdGQEg9LSvoJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_settings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_system-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBGxqFAQCBPz+/PTqtOTOfMSyPNze3Ozi5KyeLMTCxMzGzKSipOTe5MTGxAAAACH5BAEAAAAALAAAAAAQABAAAARfEMhJQah4ihFunsFAEIVXCVJACIJhoBK6CerawsA8HAhbuAnYZrBDKBYMWpCy4S2QSRazyBIwrrjcoNFQzK4KR1bQcHhZjGM2BgWLMYJ2enForHPJtNj+kfHvcB8AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_toys-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBJxyLJRqJGxKFIReHKR6NJx2NMSmbEwyFKyGTMSibFw6FMSqdCQWDIxeHNS6hAQCBDQiDNS+jOzexCwiDCQiHLyeXFxGHLSWXJwuJGweFHQiFMx2bLRGNGQeFNTClOzSrLxKPLQ+LLxOPGxOHIxmLEwWDOzatNS+lKyKTIRiJJx2PIRmPJRuNKyGRIReJJxuLKyKRMSqbKSCPEw6HNzKnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAauQIAQEBAMhITCcTg0CA6IhGJwICyYwgWjEQg4HIgHBCuMBCCSM6FBHiIOk4cg0hYiKAFFxUJBtC8YGQgBFhAaBVdMAw8bHB0eHh0cGh9LAAMgAxAhHiKPIxAkH1cXEiVjJiQnKCljECoWCAgEFGUrKBYsYwARKnQIRxG0Ky0QtAAIvwcuAwQpLxDCGDAIMTKyMSczs7sQATQz2mMIMyAXu0IQNDUu6AgQ6EPwu35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+package_utilities-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTERCRAQCBOzu7Nze3MzKzLy+vCxqZBQ2NJyanKyqrGRiZDRydKza3FRWVPT29LSytDw6PMTm5EySjCxaXGRaJFSanCRSVGxqbPTmvMSqVJTW1GSurHS6vOzq7KSipISChFRKHJSGNPz23GxKFBQ6PKyurCwqLMyufJx2RAQGBJSWlEwyDIRiLNy+lLSKVDwmDJRuNOTOrLyabGRCFDx2dKSCVOzWtHzCxOTGnNSyhAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwCAgIBAOiUiggFAyHASKxDAwUC8Zg0HAglA9IZPGQABoTSqJCFTIOEIsFgHBcEhhHUpKJFCwaGxYYHB0VEx4IEh8gIQwiIyQbJRMcHokmEicfDygAkCkqJQgIGG0rLElCLS4vMCWqQwMCQg0UMTIzNDVLQjaIGDE3ODQlS785CEkxKjowvEOHybG4O6JDCdNKuDUxRAmxRDHeveUAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_wordprocessing-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBHx6fPT29FxaXPTy9AQCBHRydPT25Pz6/ERGRIR6PJyORHR2LDQyNLy+vNTW1Ozq7Ozu7LSiVKSiTIyKJJyenMTCxMTGxNTGlNTSjLyyRExGTExKTBwaHOzivMy+XBQWFExOTNzOhIyKjFxeXDQuNMSyjNzOnBQSFNTGjDQuLCQiJAwODCwqLGRmZHR2dAwKDCwmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAafQIAwQCwWhcihYMkUDJLIAKG5fEILhoOAgGAmCgXFgsEoNByOxwMCiTTAEsmEAq5ULJbLxQEuYCQZGn0JGwkcCR1gCUIeHyCJfX2JIUIHIiANCQMGIwYkCSUgi0KPHSYdJyAnKCkdHQ1IrhgdGCC1s7UqSCsdKLi0wL2xHY/FxMcssS0JIS4vIy8uIQktHUkgKygsMNwwKCAxUOLjAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+panel-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/FxaXMTCxDQyNAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECLrcEDDKGYQV4+qbie9eGIJEVxTe+QmjUFgnXLLr615oF8x2v0I8DWpF2GV6slkLKSMdYT4nS0WgSkXYAWUbcXgX/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+panel_settings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxPz+/PzerISChPyqXAAAACH5BAEAAAAALAAAAAAQABAAAANKCLobwRAG4SJw7w5BswoEkQXbRn0h5ggF14FhbIhb68SiOgnbLRsPEovjwwVLRIdhCfwMiR/VZ1A7WS4tntWyynquq+01+h1//AkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+password-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCBPz+BISCBPz+xAAAACH5BAEAAAAALAAAAAAQABAAAANECLrcGi6CIAKUKwxSb/ZasXWPMFwBQRQiZwlqAVnEGbRwKz/ndMep3QNUqKV6kpQh6HFoCIaBMDmQTpOsJsaC6XoZ/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+penguin-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/ISChPz+BMTCBISCBAAAACH5BAEAAAAALAAAAAAQABAAAANHCLrRsTC6F6UId1TYiNtMQRQNqARDOlAgJrzlhr7vqlUufbHMoMO8k+8XY4yGtc9pREIORKRTYVoYDgxUVmBqmGCLJzDYnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+pixie-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXPz+/DQyNAQCBKSipPz+xPzerPyqXPyCBERCBISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARdEMg5Q6C4BjEGyZIlCEFHfJQonEERnB8sE6RxIMkAnGtPBzacjqBQLBiMxS+Y2xmRx+WtSTgmkwQLcwhNKqRCz3VRBOeGvh5wqpPMzO3JQFBguWAYxeiNwnRAEn4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+plan-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxPz+/Pz+xMTCBISChASCBMRaBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEIRJKwU4iD23FwEmDeAwBGYaZiehWutEFK6JqtlM7KZhHhOJbuizIUKBHVGFOOaUPgPlGEsSDNjbKWBgcT0oX5CV2qakIg24OTGA0sxjeSWpUC2ivESf90cAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+proxy-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/KSipFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANGCAHcziuIuFy44045WxhZpkxCB4GEKA1lpIAiVG7XB1bjPMHxqds3y++S6nGOL1ikpYlkbBSZM/oYfXBVaS8LuXCr2IY/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+pybliographic-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBMTG5OTi7Nze/NTS5LSuxOTm/MTCxGxaFIRmFJR6JLy+zOzq9IRqJJR2HLSaNKSirNTOxKySLIR6VLS2vOzu/LSqhNzOXHxqNMzK1KSGJHxmFKSabLy2pIx2JJyCJIRyNNS+VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZhQIBwSCwaj8WAEplULpkAZ0AQgEaVA4K0alQWDAdEQrHgNguMRsHxgJiJgcEg0pA4Jk84ZVCoWC4TGG9CAQkZGnUIG3lDAQocCh0eFB+MjRsgIAsLIYNwASKCnk2WVkR+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+realplayer-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAAwWVBwC7BwC9BQC3BQOvBQCtBQCrBQCvBQO1AwKPAwOVBwC/AwGnAwCXAQGNAQCJAQCHAQGLAQGTAwKjBwG7AQCNAQKRAQGDAQCBAQGJAQGPAQGFAQKVAQGBGRiZBweHFxaXDw+PExKRBQSFERGPFxeXCQqJLy+vAwCjJSanFRSVLzCxJSSjIyGhGxubNTW1KyurAQGHAwODKyqrHR2dBwO7AwSZCwqRDQyLCwuLAQKFAwSjAQCLAQCFAQCDAwSbAwGbBQKvBQCzBQC1AQSNBQKtAwOdBQKnBQCxAQabCwOLDQSNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAe/gAABAgGFAwQFBgcIgwEJCguRDA0ODxCXERITFBUWCwMNDxcYpKUYGRobFQEcFx0dGLCxrx6kFQcYHyAhIiIhIyQlJiekESgYHikqKywtLi0vIDCkMQQbLiQyMzQgLDQzJSCkMjU2NzIYOCYyOSYmH+gYOjUBOzw9PT6mGD4P/AORahj4IaECBFI9gAQhJSSSw0g2fGggsEAIw4eRhhBhEGBBgCKkjAgZSRLFESFIRibZx5KlkpYtlbyEuW+Jn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+remote-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBDQyNISChJyGPGReLAQCBMy+hERCHKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARFEEgZqp0Y1KxD9twEapg1kqhwBgKFvqIIjgMRdy4wFIaNbiiCYXDIAUcH328EQsxiIBXAqWn9MtTSTZLNybizEweY8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+samba-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAAQCBDQyNFRWVASC/Pz+/PTW1OyytNTW9LSy7PTGxOSenNx2dMTG9Jye5OSKjNxiZMw6PIyK5GRi3AwODMwmJLQCBCQmzPS+DPTejPTaJLR+DPT21OzqtNT21MTCxPTyxOTmnNzedMTyxPz6/ISChOTijNzaZMzOPIzijMzKJLS2BPT29Nza3PTmxKSipOzu7LyGJPTKRNSeDFxaXERCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAAQABAAAAacQIBwCAgIBsjkAEAoGJgHxFC5TCgWAEajyFUCHA8IICJhTggAr4NSGVsAF8wlnSQWBYLMRUNHMjccTB0AGh5dfh8gIQAiAAJCIyRCfiUmJwEokARok0slKSqPApukAZNDRpqbkZMjSROOI5srLAGwS34tGgEuBCMvAjCBA64ALRgxuyzAMnItQmgaMRcypjMByNR9QjQ0adzeaX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+scsi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxKSipISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLoQwZAFIV6UYgxi79Qa52WDE3bKV6YOpFpO3L5pJcckLBB8/wQEDezWAQpZqIWxFNAUkqkg6HmJOqGuArUqwfoTACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+style-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBOzqBLS2BPz+HPz+rPz+BPz+lPz+zPz+9Pz+1Pz+nPz+hNyuhPz+pIQCBMTCBIQyBPz+/MTCxFwmfCQiJIxOrHw6nJRWtJxmvJxuvJxyvAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVvICACwWieYiCUwVCiKVEEhjHA6YEcxooHBURCsXihaAYGglEzngKBhsMmMDhH0YcBAu16SY2IKiApm81RMXTCblPelDCrXJlI6hSL5SJOSewVdRMUGHtGZICChHsmZHeAgxkaG41/bWxnjV6bUH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+terminal-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxISChPz+/MT+/AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM/CBDcHkoFQasVUIrBe8fRNDwMAWpjUThmtmxk0IYwOaPx/V6XG3hAjmsRa0Qkg6NSOVo6F0nG88g4TUNDpT8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wabi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChPz+xAQC/AQCxPz+BFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARUEMhJgw20XsHxvIEwcKQHBESaDkShmqhKsMb7tW1RHPwOH4ZdYcBDGH+8A2JgLH2MzZHAJgmRBAgZAabNqg7cJMGb5BKSZF4Yfb5Uzmp3piqfS/wRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+window_list-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCRiXCRaVPz+/CRmZFRWVISGhMTCxESSjPT29DR6dDyOhDyCfPTy9CxqZOzu7Ozq7ERubOTm5ARehAxefPz6/ByaxBSOvBSGrAxynAxqlBR6nBRylAxmhARWdFxaXCH5BAEAAAAALAAAAAAQABAAAAWHICCKQTCeqCgMhJCihXEYSPuKRWIoC6PYsEZikHA4FA4CEJdoJh4QgXRwiOAeQudDIpEZIpPwhCImhyGGAmBSOVgumExG055w1ZPZhpPpUDwzExBqAAUDhxUVTQ0QEgWOOIcDiU1QjoSFFYiKDZYFmAWJlE9bkCM5iouWpiIfBa6frrKYAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+winprops-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPz+/ASChATCxISChFxaXKSipPz+xMTCxMTCBPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAoALAAAAAAQABAAAARXEMhJqwxAjM23wBMhjGQJEFKhriwrGUcsE3JsvPWBFAAiT7BaIYAA/HAxWk9CO9wAwd0SkJA9g8NiomnDoYqnHDAGroqRyVy3F2i7326LnKKo2+94hT8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBAQCxAQChKSipPz+xPz+/ARCRFxaXEQCBMTCxPyqXDQyNPzerISChISCBASCBERCBMTC/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV1ICCOZDkGgSgMg0AUZWAExyHc7YCQclLYtxtieAoUEApFUIBgnRYMhUHRCDYcDoUIRUhOlYLkYwcIDLvSpAsBiYx0CPQUgXNv4V0ZWEByDBgRcTMGDislTX+CMgISJk1+AQ4zWiYiCCiRDmRbmJ2eKZWhAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xapp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIyhI9pIa0nYAtPUGlTRszJ10UA8xiNRZZmJKoA25boqW7npeHvlKRHyIn9aKYaz6XwFwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xcalc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChPz+/AQCBCH5BAEAAAAALAAAAAAQABAAAAI4hI9pwe0Ogpi00hHF2LzzzFlTsIHD45SSx6oCeW4wjK2tl83y7t64pIsJaxrfh2bEAJIlhRPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xclipboard-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxPz+xPzerMRaBISChCH5BAEAAAAALAAAAAAQABAAAANICLoQwdBJIaRjgYbBR66Lo1nfowTER61aWGRd1y5GyrLm+QrxMJ81FQ4T2MV+jUPwBgpVdrdcQ6AUIj8Ha/N06Hq/UpLY5E8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xclock-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAALy+vAQCBPwCBMQCBIQCBISChPz+/MTCxCH5BAAAAAAALAAAAAAQABAAAANbCLHcrSLKOZcYmDSCsR1aUABAsXDDJwJGa5SBFwgaWxbCG3CWaBwG3C8Y67FawpYiNQscg65fsVkYuoAmJs1pBR522lQB6ILJLqHRwQQOZzYdZnw+dzruDIA/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xconsole-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/ISChMTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrcGjBKCYK4OGcohv/gxw2aRgyjYJXCmVpr5loke82dfaO03vI5Ha5mwxGOyOSRF2qKKpMoxEFl+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBMRaBPyCBMQCBMTCxPz+BPz+/KSipFxaXPzerPyqXIQCBARCRDQyNISChCH5BAEAAAAALAAAAAAQABAAAARnEMg5gw00yyDGIJi2FUHhDWEWeEXrgaphHEOBJF8KBLKyLINEIAHbyA6/hbDACDSMBt9PIBA6n4HfIElFXTeKg2LbtTSeu7BiPegIvuA1mwrfOB5r4PusCjimZmgUF4F8IhJnhiJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xemacs-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBDQyNKSipPz+/FxaXISChMTCxCH5BAEAAAAALAAAAAAQABAAAANJCBASoXCFoVi8VdL6HHQeB4YjSAxnYQygSLzoSTjbEs9vMF86cbyH34NX+AELQ4zO+Nopm6cBC1PBEQwG6gd3SGo7Xa1STIb4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xeyes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAI4hI+py50Bw4lyBiEggFjvi2VcqIFhdnaDSabZKrbjS3W1OHz2CkJD/vHlKD/Er2g4Ah3MptPgLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xfig-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+BMTCBISCBARCBATCBASCBCH5BAEAAAAALAAAAAAQABAAAANQCLocwbAJ8SIMYgwHHO9Opk2V5xGEplZK0alaui0eDLOB8QTykOKGQ6mnKQWFPILDN8sdng7l69c5CjuKAHNnZb2KnUOhcG3MsmMv7aK2+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xfmail-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPyqXMRaBPz+/AAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANACLHcAVCJSWcYLwaxSPAXBj2bswyiIlUWSr5muGhbdaZjTd1ZzvKMFaOFcbCIpiOnGGs2FM5gLkLrTalQLMCfAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xload-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+py+3hEoxnUmBpyBjNzWXfJnkGKJ4dBlbjS7Jni9Zsjec66hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xmag-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipMTCxPz+/IQCBPyCBMRaBCH5BAEAAAAALAAAAAAQABAAAANICKrR+6+JIRxkc4RBww1TQBBNB21io2rRRKpltaDvis4hvJmzBmuslo+zkZ0yu0rBcwJ1AgXD8gJQMaJTaqRwyGqvzO9M4U8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xosview-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwC/AQCBPz+/MTCxAQChPyCBAT+BPz+BAT+/PwCBAQC/AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARFEIRJa5Ui663HFEQojqEXCAVhrCxLmGB4kCJM03aIHEdC5rfaJ6UotlavT3AEIxaNLuAyd2wlT0thYMDter0BiWU8AfgjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xpaint-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBPzerMQCBPz+/AQCxPz+BMTCBASCBPyCBPzC/PyqXMQCxIQChKSipMRaBDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVtICCOYmCaZGoKLBuMbykMA1EURFwCgWAQwKBAxxMQDocgAjEkrYAsoS6QGEYJCgWhWVq4tgJGY+iAVbcBB5jLq/aMbzJsYXK0Arky7JFY+BcJDyckDgEPh4d1aUSFJ2l6ARApDpSUKkQpmSJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xv-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPyqXPz+xPyCBPwCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM8CLrc/jC+oIK9Lgg7RuietWhCSWkkVZUbEBBnWxXFSVP1eLt7kPM3X86nEhJrtx/P0tuNilCVZEqtNvwJACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+3floppy_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVrICCOQBCQKBkIw5mqLFG47zoQ+FwbN57TosDhgPD5dMEEIqE04kwlBWKBUEiNVYFpyqAyGEUCgqEtERiNNMLhQKzLQYJg7n7Y4aMAwbCUPvAQeWNgfzQQETAIhSMQEogwgBITQEGGEREmfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+3floppy_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVCH5BAEAAAAALAAAAAAQABAAAARcEMgJQqCYBjFu1hxReN82EOhYGieaklJwHIjrqnGCJLqNWhUFYoFQCG1FgWXIIDIYNQKCoawQGI0swuFAbKsxgmDsfZjBkwDBsNM90Jot9A3DbBD0Dwiur9QnfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+5floppy_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFxaXPz+/DQyNISChASCBARCBMT+xAT+BAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARMEMgJQqCYBiFu1sIwdJ+0hSKZnZw4ehPLoW88c0Q7X7JABLlbp+eT/UyzgpADqwgKxKYpeIMZQNWJ4YBhWRHcrgpgQCSkJu3hYPFHAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+5floppy_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXPz+/DQyNISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM+CLoQwZAFIV6UYox61cwaF32UtlkLSYFnulJEuT6qQATxW9W2enurgo6CaggKvKIn91K6mh0gMepydqwAfwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+cdaudio_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cdaudio_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cdrom_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cdrom_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cdwriter_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBFxaXISChERCBMTCxKSipAQCBMTCBPzCxPz+xPzerMT+xDQyNMTC/ASCBPyqXPz+BARCBAT+BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWIICCKgWAGYyoKA+EWhGGogOAaB6Lr8ygUCYWCkEMoEovBSHZUFI8LGYloODJkhWijMbMdiAwBQEbYxmpExFlkgN3QrliXAcvNAuVt4coYKtQ9BlwLCQQFMAlVSmwEUX8IB1UJiQAObEE6BA9VEDMOEUsDDzoHkZ4LoCkyqyIOCxI9NCOfETJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cdwriter_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXISChERCBMTCxKSipAQCBMTCBPzCxPz+xPzerMT+xDQyNMTC/PyqXPz+BCH5BAEAAAAALAAAAAAQABAAAAR3EEgZhA0zSzGIL4RhaIDgGQeiquMkFImiECmiJMswibdS3wsRhWa4MUSFYKMxMh1oDAFARFiGSjTEVWIAnbCeUJMBSo0C1WXhyJgptC0Dc5EgFECJoo5LCL4RB0UJeRkGMSoEDkUPLYUDDioHgY0kIpYkmJkAfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+dvd_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+dvd_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+hdd_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKROzSrOzKpOTGnLSafLySZKxuLMSOVPTWvPzixLSehNyibOzOrGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTOpHxOJKyKXFw+HKSipISChMTCxFxaXIRiPNSWXExOTOS2hLR+PLRyLPTWtMyOTASCBARCBPz+/DTSJIyKjIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwrA3HQ7scQAqFAcEQOUi0zAkFUSFYLghMBloUCDQNGxwdHhwHekcfICEhICIfIxkLJBABJUYCICABIhAOBiYnKJaXmH4CGSkYCCqkSAEfTKenrkOwsrQll0IrS7G5uwArLLaxLbXCLsTFLyDBKy4wZEVHvCwsRn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+hdd_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKRPTWtOzKpOTGnLSafLySZKxuLMSOVOzOrPzm1LSehNyibGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTWvHxOJKyKXFw+HPTOpKSipISChMTCxFxaXIRiPHxaNLRyLNSWXExOTPzixOS2hLR+PMyOTPz+/IyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwGgiD46FdDiCFwoDQAEe0TMkEQSFULIcLBloUCDIaDRscHRsNHhhHHyAhISAiHyMkJSYQASdGAiAgASIQKA0pKguXmJl+AiQGFwgrpUgBH0yoqK9DsbO1J5hbsrq8SrgstlJFHy0gwMVFR1J+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+memory-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChAQCBMTCxCH5BAEAAAAALAAAAAAQABAAAAI6hA+Bu+HCmgiiRuNoHZBRXQlc84TmcHzm2WVryE1YvMaZIdbVd2zw7lj4bDKGbxK8hHgX3K2JUDD8BQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mo_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipDQyNPz+/MTC/PzC/ISChASCBARCBMT+xAT+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJQqCYBjFu1hxBeN82iCIJDgWaYhtntC4ZCzItdhWOD7mdwHLrAAczoKViIh6Vto5lcDjglppp9UpCTALULRaASGS5E4TCnB2rFyqJO5Gw+CMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mo_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipDQyNPz+/MTC/PzC/ISChCH5BAEAAAAALAAAAAAQABAAAANHCLoQwZAFMV6UlBB759Aahw0FGEITZZQmlwoqq1UNDA/xLDhvhQ8rnKPh4f2EropjcDjAhpJl8ylaBJhTaCelvRC7XqLXnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nfs_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBExKTGRmZPz+/ExOTMTCxAQCBDw6PCwqLIyCRHxyNCQiJOzmxMSybFxSHHRmLIx+NFROHERCRFxaXASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVWICCOZGmeaEoGKiCwwUAI5zsUBnAUQ0CLNhxLFEDwDAnFzTAsBRYJRsORSwUeDUiEWYtJIhFj7+eKCUdPHmxyNj0nFABXRam0RBSLvZW/VFN1FQYGfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nfs_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBExKTGRmZPz+/ExOTMTCxAQCBDw6PCwqLIyCRHxyNCQiJOzmxMSybFxSHHRmLIx+NFROHERCRFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVLICCOZGmeaEoGKiCwwUAI5zsUBnAUQ0CLNhxLFEDwDAnFzTAsBRYJRsORSwUeDUiEWYtJIhFj7+eKCUdPHmxyNj0nOa6q2qrbW/4QACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+printer1-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRWVPz+/Ly+vISChMTCxFxaXPT29DQyNJSSlHR2dERCRFRSVERGRBSmnExOTExKTAT+/NTW1MzOzMzKzMTGxLy6vLS2tGRiZFxeXOTm5IyKjISGhLSytKyqrGRmZNTS1Nze3Nza3Hx6fKSmpKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaUQIBwSCwaA0ikkRgQDJCE5LFgOAicUKUwUCAgBuDE9RkFcL3ggbgQUCwYyIIA8VU32ASDwoEcIAoHCQkHbA8EBBARSX0DXQEPEgQCDYpJExQVAWCHBwcNDUkKChQWBBcYARkanaABExsbHB0FGB4fIKoHAWYhpCIBIyQLJSAJGbtbULUTISa4yEVJJSbO0EtmUkR+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+printer2-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBKSipAQCBPz+xPz+/MTCBISCBISChMTCxFxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMggqrwYVDGGzRLXEZ0HhgMpFIXxZZzRBsHxXquAUHqCCBgB6YcoFhNAXMWISCQOv6Dt6DMmQwQntHjwXTVL6mH83Ry31qBO8CSQSmVg2GM74aAVij2UTPojACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+scanner-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MT+/ASChARCRATCxMTCxFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJgqWBVivEldkUdKSXhVjZfenommglDERh3Tc4E4ZRHAGgkEPr9X6H5AHBERSMRyWzkug8jQXFEhWoOo8dRYxqLXSmGjIJnVaz29Q3fAP3RwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+tablet-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTC/Pz+/MTCxFxaXKSipAAAACH5BAEAAAAALAAAAAAQABAAAANECLrc/iosCUEQlEYdRp6dZ4lgKBBEp1kmmpLRMBQu6qWLEdYBn+81F0wnC8oCK+LAQDgGDIaG0vOMPnRIaEUBtW6//gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+zip_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBFxaXMTCxPz+/ASChPwCBKSipASCBARCBMT+xAT+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJQqCYBiFs1lwwdF8VEsR4YVuXoirYFcWbkmY31wPqma2ZwReqBEODQutwEY04oeWqMniGOEzW4HAVZAEImVSCSLDGYIX5/EMoFtNSOWHxRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+zip_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPz+BAQCBFxaXMTCxPz+/ASChPwCBKSipCH5BAEAAAAALAAAAAAQABAAAANICLoQwZAFIVyUNIx6WybE9kBTFYIiVhXFGXJetbYDaHnlathZk2eDQunw0GwomeGoMThmKETS4PAURCMlZccHXXYct60Y4E8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+blockdevice-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBMT+/ATCBAT+/ARCRPz+xARCBPz+BATCxISCBDQyNMTCBCH5BAEAAAAALAAAAAAQABAAAARhEMgZwrwYBCFsvhs3eF8wDMJAVBVmnupazKRmGDFxzMVBBjcDQXfYHRA/QmKpKBYRSMoysVgwGEeoJ1ClLhpXhlbiqJobjcA1Sn48qug06+JwP+I1UMCNzmcqaR8lghN+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+chardevice-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBMTCxISChPz+/MQCBPwCBAAAACH5BAEAAAAALAAAAAAQABAAAANCCBDcHkoFQasVUIrBe8fRNDwMAWojMTZmtmzByp6v7LQhTOLadbkxj3AUWZAcxcUgyYwQm8wYoOCCLgoGK5Nq9ScAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+desktop-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTDQyNHRydFRWVKyqpGxubExOTERCRLy6vFxaXBweHFRKPFxeXAQCBIyKjCwqLMS+tKyurDw+PNze3ERGPPTu5Pz+/Pz6/Nza3MzOzKSipISChOzq7NTW1Ly+vHx2ZOzm3Ix2XJx2XIyOjKyqrJSSlPTexPTixKR2VKxyPCQiJPTy9JSWlHRmTOzSrMzKzJyCbKR+XCwuLOTi5CQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwKAwIiEjkgJBsAgoGwcE5RCQUgAWj0WwcHA8FRLhAcIcKhyIiMSwcwglc2ABTDA2Eo9KQoy0PFxgYGRobDxwBDHRgF44YHQ4bHgkfHBUMHQ8gFp2dISIjEQwfBwIkJR0mICcoJycpKgweCisAEAcPGSwtLi8vsQkNtkMrBxswCQ8uMTINY0kzBCQwNB/DVAArBC0NNdlDM9BDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+file_broken-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/KSipPz+xPzerAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEEgQahVijMmD/oRAbBw1FCgaFFrppeo5didsZTSMDoRBSi/dgfUz6Va7HPIQGB6KnpW0EEB4Oshp5ZlTFRBfFs3ZLDihtTAYwZ14nGbzoS3JfO4ffwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+file_important-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBExGTKQqLPz+/KQqNAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLoQwZAFIV6Es15Jqd2ZtzXUMIhXZqJYaZ5aK7zwp6h0zc05i+c6Eg8oCnWOR0eHQGEKnEWHdDoF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+file_locked-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/KSipPz+xISCBERCBAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEEgQahVijMmD/oRAbBw1FCgaFFrppeo5didsZTSMDoRBSi/dgfUz6Sq7XGp1CByKQZUUWjsgrtcENYXNUodWhAahVRa65G9hmGgnnpzMZ/7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_blue-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_blue_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_cyan-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHNTKzOzq7ExGTCwqLERCRBSKjBRSVGxubKymrNTS1Hx2fCQiJMzq7NTy7IzKxHR2dFTW1Ey2rITKzNzy9JTSzBySlHRydKSipDTW1ByelGzCvIzOzByOjFRSVCy2rCSalGS+tJzSzBxudCR6hCSCjITGxMTm5Pz+/JSutDyChBxydCyOlITKxPz6/PTy9Nza3ISqrGSyrOzm7MzKzDQyNMzGzNze3OTi5MTCxNTO1Ly6vLSutGRiZKyurHRudDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe2gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNjYUOAYcPEBESlBMMjAUFnIIPFBUWEBcYGQoaG5gGggMcHRUeFh+fGCCVIakiICMduiQWJa4fCKkdJicoCcjJKSrPAAIrBSwtLtMv1jDaCDEyMgUzNC3SKCA12gYFMjY2KzMzN98uLdo4cujYoa9BAx4IeSywJSgAjgU8evTIgdDHj4WJHAL54cPiDyAMIzkMsSGIkCGREAU4gAOAn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_cyan_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFNze3Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fIyCdMzGxAxOTBSGhIx6XJSKfMzKzERGRAxOVKTq5Mzy7KTW1Ozi1OzizEzSxGTWzHzCvNTq5OTSvNTCnIRyVNTS1BzKvCSalGy6tAQ6XMyyjMzOzDw+PByqtCR6fCyGjHRmTMS+vJSytDyChCyWlGReVOTi5AxGRKyurDQ2NNza3NTW1AxKTJyenGxqbMTCxMTGxLy6vLS2tLSurKyqrCwuLFxaXKSmpDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfEgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBZcQnRESEREIDwoPExSipBUWFxgZGhIXFwkbHBQToQQGFx0eHxoguhEXHCEiIyQGABclJiYnycsSKCkjKisAESwtLi7Y2soXLzDUAaMxMuYuM9kXNDDiAAYFBTU15NGTYeMGNQA4ahAgkEMHiQoxZrTYwWMfIRw9fKio8MMHECAReByUhIPGDSBBhAyJYDFRACJFeBi5cCSSpwM4APgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_green-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHNTK1Ozq7ExGTCwqLERCRByGRBROLGxubKymrNTS1Hx2fCQiJMzm1NTy3ITGnKSipFzShFSydIzKnMzq1Nzy5JzSrByKTBweHDzOdCSaTGy+jJTOrFRSVDSuZCySVMzq3IzKpBxuRCR+TCSCVGy6hPz+/JSunDyCXCSOTCyWVCyeVPz6/PTy9IyqlCSCTGSuhPTu9Ozm7Nza3Dx+VBxyRDQyNMzGzNze3OTi5MTGxMTCxLy6vLSutGRiZLSytDQuNKyqrHRudDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe+gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNjYUOAYcPEBESlA4TjAUFnIIPFBUWFxgZGpWXjYIbHB0VHhKtER+UCyC1ISIdxbkSGSMYJAiCByIlJicaxbgoEhDNAAYpBSorJScnLC0uHRLaCC8wMAUNMeAnMgkz2gY0NDUFKTYNBDE3cKzQlkPHDh42djRo0KNhjwUGBgXIscAHgQY6fPz4AQRioolBhGwUIiRIxEiEhoCYQKSIEZSHAhzIAcBPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_green_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFNze3Ozq7ERCRCwqLPz+/PTy9PT29FRSVHRydIR+fISCfOzu7OTm5OTi5MzGxAxOLByCRJSKfIRyVERGRKTmvNTu3KTWvOzi1OzizIx6XIyCdFTOfGzSjITClAxGJOTSvNTCnNTW1Dw+PAxKJCTCVCyWVGy2jAQ6XMyyjMzKzByuZCR+TCyGVNTm3HRmTLy6vJSypESCXGReVLSurDQ2NNTS1MzOzKSipGRiZMTGxMTCxJyanDQyNLSytKyqrCwuLDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCowLAQYMAYiTDQ4FCgoPEBESnBMUExMIoBUWFaEKBRIXExgZGqoTChscFR0epQYTHyAhGrkUIhMcIyQWJSYAJygpKSrIyissFi0GABMuLzAv19kaMRMyM+ABojQ15ObYEzYz0wAGBQUbBPHkYNQQcQMcABwEEhLIkUMHjRQvTuzIRwgHjx45evTwMWPGiR8GJQGxcWNGkBtCTlBMFGDIgh9CJhCJ1OkADgB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_grey-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLHx2fKyqrNTS1PTy9CQiJNza3OTi5GxubJSSlISChLSytFxWXDQuNKSipBweHISGhFxaXIR+hLSutFROVHR2dFRSVGReZKymrLy6vFxeXNTW1Pz+/KSepERGRPz6/PTu9Ozm7DQyNMzGzMTCxMTGxGxqbNTO1Ly2vHRydKyurHRudDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAawQIAQEBAMj0jAgFAwHBDJoUGASCgWDEMxETg2HA8FFaJgFgpdYSMiUYAnlErCsmgKL5iMJqJwPzYcCB0eahAZH4gSESAhYAoGQggiBh4eFB8iehEWI5AABiQFFpMeHCIiiCWeJicMDAUOEZMcHBkSngYMKCkpJA4OBCWTk0IqKw8PvwsLLCwtLBCeRCouLC8vK80wGzEHSQEqHxMhMBMyLtLfKh4WCjM0UUgBCCoAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_grey_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExOTBQWFNze3Ozq7ERGRCwqLPz+/PTy9Ozu7OTi5HRydIR+fISCfPT29Pz6/PTy7MTCxCwuLJSKfIx6XMzKzDQyNOzizJSOhIyCdOTm5Dw+PJSSlKSipLy+vOzi1OTSvNTCnIRyVNTW1GRiZFxaXAQ6XMyyjNTS1GRmZFxeXHRmTFRWVKSmpKyurMzOzGxqbMTGxLS2tJyenKyqrDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAauQIAQEBAMj0jAgFAwCA7JYwCRUCwWgoCBEUBOG47CAxJhSrqT5wERplQoC8ijYDEcJASJ4HKIYDAZFRoFGxwXHR4eH3lqICEiIyQcAAcMJSaIeHonKCMpkxMqAismKyuIixMsH5MBDw8eJS0mJpcdByYSkwAcEQUEBC4lo7UHL7sXwMAkKTAeogceu0QXMRIwFjISMxITNNNDARcmLx8zNTUH4F64NDUTNlHsk35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_home-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tKx6XGQqBNy6pIyKjDwGBOzOvJSWlDQyNIRaLNRiBGwmBNyidLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbKiQrLB4XEltDrhcaKi0utbcJra8bLzDAGrcxrTIXHi8zNCypEsO6EzU2IzQ3ONoTzK0BCAkDMQkIOTFlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_html-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBERGRBQWFMzKzOzq7CwqLDw6NARqnAQ+XHR2dKyqrOTm5ExKTERCRHRydMTi7NTu9HS+1KSmpBweHDy67DyixHS61ITG3AxypByu7DxinBw+ZERmdIySjITC3ARypExOTDRurIR2RPTSdJyulEyGvBw+bFSyzJTK3LzKvPzivOTixNTChLSybGyCfCRSnBQqRASGtFyuzDw+PCRShPzy5OzerOTShKyaTEx6pCxerGRufBR+rOTezPTShNy6bER+1BxCfBQuRAxelFSixBw2VISq3GySrPTWlHyanIyitFSO3IymtCRujAxWhCRqlCQ6XGyWvNS2bFyGvDxuvCRSpLy+vMS+vGxqbFyO1GSi3EyO1FRaVCQuPLS2tDxyzKyWNFxaNCQyPGxubCxajERSVExKNJyenAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAECg4eIAAMEBQICBomDBwgJCgsEDA0BDg8BhwYQERKUDxOYDAyeghQVFhehGBmVlwwOqxobHB0eH6EfIAkPIYIiIyQlJhsnKBcpvrYiKissLS4vMDEyFjOvNAA1LDY3ODk6Oyc8PTIyFzQ1Jj42P0A6QTtCQ0REIEUORkdIkihZwsSekBhNnDyBciCKiSNSplDRUcWKkRhXCGDJYgiGli1cpuTocsILjytfFmRpACAGRTBhRogZgzHlAjKGWnIoY+bMgRgBDHRBo/LAIZoxuhwKatRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_image-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPz+BAQCBExKTBQWFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9HS+1Dy67DyixITC3BR2pBweHByu7ASGtFSyzHS61AxypExOTBSazBRupJQOFBSCtDxKfKTa9AxelNz61MTaxDw+PPzGpLweHJTO3ESu3DRilFymXCxKRBRypBR+rDwCBNxmVORiRKQWFCyKvJTWhDSOPCRONFSixDQaHNROPNQ2JLRubHTC5DR6rHx6fFSqRCRyLGRmXGxqbIymtCRujAxWhMySjMQ2JMyqrKTW5ERijJSenFSGXGRmZLy+vMTGxMTCvERGRMxCNOzq7NTe5LSurISKhHR2fLy6vLS2tKyurGxubCwqLOSKfOzy9Nza3KSmrIyGjGxmZKyqrIRqZIyKjFxaXJyenDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAffgACCAAECg4eIAAMEBQICBomDBwgJCguMAoUMAYcNDg8QlAyXBaWcgg0REhCfExSVpIYAFRYXEhgZE60aCQwbghUcHRQXtri6DxMHgh4fICEiIyTFtxkOJQAeJicoKSojKywtLsUZJS8wMTIpMyA0NTYKIiIaNwc4OTo7PD0+P0BBhAwhUkTFAQNGjiBJomQJExsMmjh5AkVIFANQpEyhsqSKlStXmmDJomVLFC5Gunj5QiALmDAKxGSpMsYiAC5kqjhZUOaKmUdmzoAJgkaQgQYCmogJEmRQAC5pAPgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_important-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBExGTKQqLPz+/KQqNAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLoQwZAFIV6Es15Jqd2ZtzXUMIhXZqJYaZ5aK7zwp6h0zc05i+c6Eg8oCnWOR0eHQGEKnEWHdDoF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_locked-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQSFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpOzm5GxqbCQiJMTi7NTu9HS+1HRydOTm1Ozq7Dy67DyixHS61ITC3AxypERGRBweHByu7ASGtFyy1DSOtDRmfExOTBSazBR+rCwqLAxWhAxelByGtDSaxAwODHy+1Dw+PPT29IyqvCxujOzu7NTW1Nza3ExGJJyebKyqfMTCpFRSPOTi5DQqHOTezDw2NMTGxKyqhMTGrGxmXDQ2NMTCxMTGpHx6bHx2bBQWFIyOXDQuDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomDBwgJCgsEDAKFDQGHDg8QEZQSlxMUDJ2CDhUWF6AYGZWXFBqCGxwdFh4XGK8fIAohtiIIIx25EZwBDREHgiQjJSYmGScoKSoRKQ8rggIsDC0uJS4oGygoAyjdAAcsLxQUMDEyMzQ1EzapBy8MDDc36tFwgONFjlQ6dgCEEZBHDx8+ctRIRehHAyAwZASZIGRIEBoUBwUwIGMCiwFEaBQJichIjo9FZLBsacRIAB0A/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_man-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFMzKzOzq5ERCRCwqLARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9HS+1KyqrMzOzOTi5Ozu5Dy67DyixHS61ITC3ARypOzq7ERGRFRWVJyanByu7ASGtFyy1Hy+1FRSVOzu7BSazBR+rFSyzJTK3Dw+PFxaXPTy7LSyrAxWhAxelLy6vMTGxNTS1Ly6tFyuzMS+vPz69NTW1MTCvIyOjPT29OTm5HRybFSixLy+tLS2tISGhGxubIymtCRujCRqlHx6fNza1GRiZMTCxGxqZLy+vFxeXLSytKyurGxqbISChFxeZDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAffgACCAAECg4eIAAMEBQYCB4mDBggJCguMBgEGDAGHDQ4PEJQKERITFBOdgg0VFhegGBmVlxobABwdHh8WIBchsLIKIiIjCyQZJR+7JhcnoBAoKSoqKywtLi8wMbsyrwYpGhowHTMqNCqkyR8XKBwTNTY3KjgFOTopLS0ZO98wPD0+JhR490MAkCAshHyTsCLCEAlEYEgoIsCIjRlHDNzy0UFBDBtIbBzZ4KJHBB0aAQhIoqCHESQ9dAjooWQJE1uCBBRpkoSDExEcUnRYwOTJIQECNmwQwEFQgANQAPgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_orange-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHNTO1Ozq7ExGTDQuNERCRJxmDFw6DGxubKymrMzOzOzu7Hx2fCwqLOzaxPTm1NSyfKSipBweHOSmRMSKRNy2jJxuFFw+DKyqrOSeJKxqFMyaXNSyhNSufFRSVMSCJKRyHLRuFMSORNy6nPTezHxaFIxmFJxqDJxyHPz+/LyqjJR2NPz6/NTS1KyehIxqNJRmDLyWXPTu9PTy9Ozm7Nza3MzKzMzK1OTi5MTCxMTGxDQ2NMzGzLy+vLy2vKyurGRiZLSytLy6vFxaXHRudDw6PDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe/gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNDgYBBg8BhxAREhOUDxSMBQWeghUWFxOhGBkaCxuMBqscHRceHyCwCbMhqyIZIx0kJR4gJicSIAiCECMoKSorKyS6yhHQAAYsBS0uKSkZHSsdHc+CCC8vqDAxMtQzJDTdBjU2NwUsODg5Wsxz0e2ADhw7/sEgwKOHwwW3BAXwsYAHARg/eAAJIgRiogAHhhApEoSIkCERI4E0QmHDESSREAWAkASAn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_orange_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOTm5ERCRCwqLPz+/PTy9PTy7OTi5FRSVHRydISCfIR+fPT29Ozu7MTCxFw+BJxqBFQ+BJSOhIRyVMTGxPzSlPzmxOTGnOzizIx6XIyCdOyeLPSuTNSubOTSvNTCnNza3Dw+POSGBLRyDMyeXAQ6XMyyjMzKzMyWBKx6FJx2FHRmTLy+xDw6PLyqjJR2LJRyDFxaXOzq7JRuLEw2BKyurDQyNNze3NTW1NTS1MzOzJyenDQ2NGxqbLy6vJyanGRiZLS2tKyqrCwuLKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfEgACCAAECg4eIAAMEBAUCBomHAQcICQoECwEFDAGIkw0OBA8PEIwRnRITFBIHDRAVFhWipBcFEhgZGhMSEg8bGxUcHQQKth4fIBoburwbISIWIyQAEiUmJicnyrooKRYqBdQrEywt1yfJGxQuLzCEozEyM+XnEjQv4QAFEDUKCjE2JrRoYeMGjmkAchAYoWPEDh49YrBQ5SMfoR9AXvRQcSFCkBcUhFgcFCDHEBxBiOAoQgFhpABGaPg4IiFHJE8GbPoJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_red-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBwWHMzKzOzm7ERCRExGTCwqLIw6FFQiDHx2fKyqrOzu7CQiJOzOxPTe1MySfKymrOzq7Nx2TLxmTNSelJQ+FMzOzNxiNKw+HMR6ZMyWhNSajHRydFRSVLxSLJRKJKRKJKQ+HNSWhNSmnHQ6FIRGHJRCHPz6/LSajIRONPTu9Nza3KyShLR6ZPz+/DQyNOTi5NTS1MTCxGxubGxqbMzGzLy6vLSytGRiZHRudDw6PAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIAQEBAMj0jAgFAwHBDJoSGhWDAIDUHgsAgcHQ9IhLqQMAsTr9BBqUTClktVgmkYhIOMprLhdOBUHh9rICEiIyN8JCVwdwAOIiYnJyiHiRtvjgYpBSorJgknIpYRmikpLAUtLp+hIy+aLKkFMC0tGJ4mK44xBDKqLTMEBDTFNY5EMTY0MzM3NDg4OR7IQwExOjnROTk6B1FC1x8SEjs84EcBCDEAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_red_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOTi5OTm5CwqLPz+/PTy9Ozu7Nze3Ozq7HRydISCfPT29PTy7MTGxFQiDIw6FJSKfIx6XPz6/MzKzERGRNyypPTWzOzi1OzizIyCdDw+PNRuTNyCZMSSfOzW1OTSvNTCnIRyVNTS1ERCRMxGFJxGJIRKJLyCbAQ6XMyyjLRWFHRmTLy+xLSelIxWPEQeBGReVIxOJIRSPKyurDQyNNTW1JxOLEwiDKSipGRiZMTCxLy6vJyenLS2tCwuLFxaXKSmpDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe+gACCAAECg4eIAAMEBQICBomHAQcICQoLAoUMAYiTDQ0LDg4PCgQQnBESEREHoBMUEwUVDgsWFxEYGRiqEQ8aG68cBQQdER4fIBghu6saIiMkJSYAEScoKSrJyxIrLNEd1C0p1ygo2coRLi/gAaIwMSnx5SoyM+uCHQ8LChrv8TQ1ZNiYBuCGgoMKcJSwACNHCh07wAkK0IFHj4UQevjwEeGHREk3ZtjwAcSGjQgfEwUIIuTHEJSROhkgAsBPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_sound-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFMzOzOTm5ERCRCwqLARqnAQ+XHR2dKyqrMzKzHRydCQiJMTi7NTu9HS61KSmpDy67DyexExSVITC3AxypBweHByu7FRiZDRiZHy+1ARypExaXBy2xGRqZFSyzJTK3AQ+RByqtASCtASGtFyuzDw+PATC1ByGlFxeXISGhJSWlFRWVAxmlBR2pBR+rAQ2PAS2xHS2vMTCxJyenLS2tCRujAxWhAxelFSixAQaHARibARudAR2hEySnPTy9Nza3GRiZNTS1IymtCRqlARWXDyCjPz6/MTGxLy+vMS+vGxqbAQiJARaZEx+hLy6vKyurERGRBQuNCw6PISanFxaXDw6PCQ2NDRGRDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfYgACCAAECg4eIAAMEBQYCB4mDBggJCgsMBQIBBg0Bhw4PEBGUDRKMBQWegg4TFBUVEBYXlZeNghgZGhsCFRyhFh0JDRWCAx4fGg0gCiERIqEcBoIjHyQeDcMlJhQnEQ8oANQpKissLS4vMDEmJhEoMjPxNDU2Ny44OTo6FzsGPD0+fgABEUTIECIMiuAzIk3GkR5IbgRJMoSAkiVKmDSRBsDJEyg1hBQYUqNGlBtSGkwZRGUDEyILWCxYcmPBgiYrB1WxEsBTgANXbCwYggVRFi2Ifm4B4CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_tar-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFMzKzOTm5ERCRCwqLARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9Hy+1ARypDy67DyixHS61ITC3Ozq7BweHJySbJyWbAxypExOTPz21KyqjPz67OzmxFSyzJTK3LSujASGtDw+PKSehPz69Pz23OzitPTqvOzerKSaZBR2pBR+rKSefMy+dKyeTIR2NAxWhAxelFSixJyadOzirLyubLyqVJySPHRmJIymtCRujCRqlPTqzOzW5OzSzNzSrLyqXLSeTJSGNMTGxMS+vLy6vGxqbJSKZOzOxNzGtNzOhKSSRIR+LGReHLy+vKyurOTWlHxyJFxSFLS2tKyqrERGRHRuRNzKfNTGdGxeJGxiNFxaXJyenDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAECg4eIAAMEBQYCB4mDBggJCguMAgEGDAGHDQ4PEBEJDJcFp52CDRITFKAVo6UEFgaCFxgZGRgUFa8apBsAuhwdHh+5IBQhrwYZIh3PHdAdGSMTyQ4kJR4mJycdKCkqKywtIyMUJC4cKR7EKC8wMTIzMxE0BjUmJjY2NzgwcuggsIOHjB7NfPwAEkTIkBxEdBQxUuQIEgNJgihZwgRGEyJOnhyBciTKxSRSpDBh0iRGjClUjlSJYgXJFQBYbmTREmOLDi4BDnTxsgDJl0E5uXBBFBQMAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_txt-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAMR6RPwCBAQCBExKTPzGjBQWFMzOzOTm5ERCRCwqLPyGBPzKjARqnAQ+XHR2dKSmpMzKzHRydPyGDNTu9Hy+1OR2BNSOXHS+1MTi7ITC3AxypOzq7KRKBPyCDOySZPzizPTWxFSyzHS61ITG3FROTCQSBMxmJNRyROy2lOy2nASGtDyixJTK3FxGNIRWLMR+XPzStPTKrBRupBR+tFyuzDw+PDQuJIRSNAxWhAxmnBR2pBR+rPT29FxaVEw6LKRuVIx6ZISitCRujAxelAxmlFSixOzu7JyWjBwaFKSShNTW1MTGxDQ2NMTCxNze3Nza3HRqXMS+vGxubGRiZLSytCwuLERGRJyenGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAfLgAABgwIDg4eIAQSCBQYHCAMJiYMKCwAMDQ4PEAcDAggRApQSlhMUmJqOBweiFQoKBBYXGBMZGpkPBhsIHBUdHh8gISIjtCOoJCUcJicoHykqK8MstBQIASUtLi8wMTIzKtE0Ihg1gwg2Ny8xKDg5OjvhItcBCDw9Pj9AQUI4Q0QMipirZ2TDERJIkihZwg+HEHpMmjg58OQIFANLomSUQi+AACZTohiAkDEKFSocJwmoMoWKSSoPpFiZdEhAgh5XHmBhQjORTZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_video-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExOTBQWFMzKzOTm5ERCRCwqLARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9Hy+1Hx6dJyenLy6vIyOjDy67DyixHS61ITC3ARypOzq7ERGRFxaPKyqrBweHByu7ASGtFSyzITG3KSOPKyurBSazBR+rJTK3HS+1Hx6ZNzObAxWhAxelAxmlBRupBR+tFyuzDw+POzibNzOZIyqvCRujLyiPJyCPJSWlNTS1ISitFSixHxiFGxeJFxWLExKNCRqlDw2BFROHHxqPMSqVISChMzOzGxqZISCbLSaRKSWTFxWPNzGZNTCZLy+vLSytGxubJSSfGRiTMyyVLymTLyiRMSqTEQ+JGxqbNS+XNzKZOTWbLy2ZFxaXDw6PIyGbOzidOzifMy6XCwmFGxmXDw6LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfigACCAAECg4eIAAMEBQYCB4mDBggJCguMAgEGDAGHDQ4PEJQREowFBZ0TFA0VFhegGBkJEZcaGxwdHh8gFiEXGKAiowIjHCQlCCYgvL4noCgGKSoGCyssLS4vyxYwrzEyM9MSNDUrK9jKIBcGNiMjNwY4Gjk65dcIOwY8PT0+PwYUAuTIQaDeCiAGgggZMoQDEQNFchghMIHiEQNIkihZwoRJkx8RCDhxMuEJFAMGokiZQoRKFStXjpQk0QHLBgDRrEzJomULlwFHukhYgMWLIANfwIAJw+WKmDFkAjQoA8BPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_violet-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLHQWhEQOVHR2dKyqrNTS1PTy9Hx2fCQiJOTK7OzW9LyKzGxubLRW1JxOtLyCzMSS1HwijKSipLQ61HwinKxuvHQajFRSVJQytIQqlKRqvMSe1GQebHQihLSCxNzG5Pz+/KyStHQ6hPz6/PTu9Nza3KSGrJxmrOzm7MzOzDw6PDQyNOTi5MzGzMTCxGxqbLy6vLSytHRudGRiZLy2vDQuNFxaXDQ6NCH5BAEAAAAALAAAAAAQABAAAAaoQIAQEBAMj0jAgFAwHBDJoSGhWDAaDkPxEThCIpIJlcJgFgpdIaRiuYAxGcVD02gKBxuOpXPBvD1VH2ogISEceiIXI2ATBmohJAklGYaIJieOAAIoBSkqJCUlHJUmmQYrDiwFLS6foRwvpqkwMCstDTGtJCoyQjMELTQttw01Nsc3B0MBMxQ2DSfGNjg5OplHzDs5ODw5DMlRQgE9PhoMOjPh2BA/AH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_violet_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOTi5OTm5CwqLPz+/PTy7Ozu7HRydISCfPT29Ozq7Nze3MTGxEQOTGwahDwKRJSKfIx6XOzi1Pz6/MTKxNSi5OTS7Mym1OzizJSOhIyCdDw+PKxSzLRq1LSCxOTSvNTCnIRyVNTW1JwixHwqlKRutOTS5AQ6XMyyjNTS1JwerHQmfIQylHRmTLzCvKyWtHRChHwuhFxaXERCRHQ+fLSytDQ2NKSmpGxqbLy6vDwOTJyenDQyNKyqrCwuLDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomHAQcICYwChQoBiJMLCwUMBw0NDg+bEBESEAcLDRMUExUMFggXAhAYGRoREBAIGxscFB0EBB4QHyAhGrq8EBsiIyQlHgAQJicnKMspuyorJCzVEi0uLy7Z2xopEDAx1QEMDDIzLjTZ2hI174I2CQ0EHMi4ge7EDQk4qgHI4aChAxYsLsg4J0GHQkI5dsSIeCFGDB49fFwcFOBHDRw8cOAAAmEkpyA1fOjoISQSJwPV/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_wordprocessing-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExOTBQSFMzKzOTm5ERCRDQuLARqnAQ+XHRydKSmpExKTCQiHMTi7NTu9HS+1HR2dCQiJDy67DyixHS61ITC3AxypKyqrBweHGxqbGRmZFxaXFRSVERGRPz+/ITG3JyalOze1PTm3Ozi1PTm1Hx2bJTK3IyOjPTy9CQqJFyuzDw+PNTGnDQyNPTq3Ozq7MS2hASGtKyaXCwqHBwaHFxWTKyahLSijKyehHRmXHRqNFSixHxyNAwKDERCPAQGBCwqLIymtCRujAxWhCRqlMS+vMTGxIyCVJSSfLy6vLS2tLSytGxubCwqJExGJEQ+JBQWFJyanDw6NDQ2NBQaFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfUgACCAAECg4eIAAMEBQIGB4mDBggJCguMDAEGCgGHDQ4PEJQRlwWmnYISExQVoBYXCREYjAaCGREaGxwdHh8PIJQKhgAhIiMkJSQkJhUnrrUGKCkf1B8pGyoUK60sLSouIS8vMCUhBw0xMjIVBjM0NTY3ODk5Og0NOwgXPCw9AD4BBvwwMABIgCBChhApUqtBhgw1INaIWMPIESMaGiIRsbFjkhpKlmDQYKgGx5MdDyxhgqFJLSdPoMiU+YRGFA5SRk4RRCWDix9TnFRxISiAE6J+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_yellow-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ExGTCwqLERCRJSSDFxWDGxubKyqrNTS1Hx2fCQiJOzqzPTy1NTKfHRydOTWTMSyTNTKjNzOjJyWFHR2dKymrOTaLKyaFLyyRMS6ZFRSVLy2JKSeHNTOnNTKhHR2FISGHIyKHKyeFOzmxPz+/LS2lIyCNJSWJMzKfPz6/PTy9Nze3KyqhLS2XPTu9Ozm7Nza3MzK1LSyjIyONDQyNOTi5NTO1MTGxMTCxMzGzLy6vLSutGRiZLy2vKyurKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe0gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNjYUOAYcPEBESlBMMjAUFnIIPFBUWnxcYChkajAaCAxscHR4SrREWlBkfqSAYIRy5uyKfIwipISQlJhgnx7oSKM0ABikFKivQCSwn1C3ZCC4vLwUwMd/RGDLZBjPqNCk1NTY33zjZOQQ1dOBrsIMHjx49FtQSFCDHgh47GvhA+AOIwkQNgwARUnHIxUiEcnwgwmBBDpCHAjw46ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_yellow_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFNze3Ozq7ERCRCwqLPz+/PTy9PT29FRSVHRydIR+fISCfOzu7OTm5MTCxFRWBIyOFFRSBJSKfIRyVOzqnPTuzNzapOzi1OzizIx6XIyCdNzORNzSZMTCfOzqzOTSvNTCnNTW1NTGFKSaHLy6ZAQ6XMyyjMzKzDw+PLS+DHyGHIySJHRmTLy+xLS2lIyKPISGJGReVOTi5ISGNExKBKyqrDQyNNza3NTS1JyeJKSipGxqbMzOzLS2tJyanKyurLy6vKyutCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYCB4mHAQgJCowLAQYMAYiTDQ4FCgoPEBARnBITFBIIoBUWFaEKBREGFBcYGaoUChobFRwdBRAGEh4fIBkhuqsbIiMWJAYAFCUmJifJG7ooKRYqK9QsLS4T19kZGxIvMNMBojEyMy4u5xQ0EeEABgUFBDUxbJBzYeMGjmkAchBYqGPHjggxeMy40UMfoRw+IvxQoSICEBgUgiCUlIOGkCFAiOCgYDFRgCILgqxsGYnQgRwA/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+ftp-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3LSyrJyanPz+/Ozq7GxqbDxinBw+ZERmdIySjHRydMzOzPT29CwuNDRurIR2RPTSdJyulEyGvBw+bLzCxIyKhGxubERCRLzKvPzivPTmxNTChLSybGyCfCRSnBQqPLy6vLy2rCRShOTixPzy5OzerOTShLyaVEx6nCxerGRyhOTi3OzaxPTShNy6bEx6rER6zDRitBxCfPTq3LyulBw2VISq3GySrPTWlHyanIyitFSO3PTm1Ozi1LyqjDQyNCQ6XHSq3GyWvDxuvCRSpLSqpOzezAQCBCxGZCRKZExGLDQuHAwaLBQWHKymnOzexARCBJzOnGy2bDyePCxKJOzWvLymhAx6DAyGDDROLOTOpHRmVLyidLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfRgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICQoLlwwNDgQPghAREhMUCBUWBRcMGBmnEBobHB0eHyAhIg4CIxenJCUmJygpKisVLAIGLSMPJBQuJi8wMTIzNCEWJjU2Dzc4OTo7PD0yK94DPj9AQUIUQ0QwFDFFRjchRz5IbARJEkLJkiVMmDRx8uQBlCgbgDyQMmUKlYpTqlSsYsXFFSwTK2bRMmWkyCxbuICkmKVlySwvpXTh4mWilJs4c3bB8uXLqUEBHggdSvSBn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+link-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBFxaXPz+/AQCBKSipAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMgCLrc/jDKSau9OL/AuwxCKAzfOIwlcZIRKLJQMMyz5CcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+network-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBISChPz+/Nza3ARaZESanCyKlARudARGTLy+vNzq7ARmbMTCxARufAROVMzOzKSipARyfOzq7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVmICAGZFmKQiACweCSBImq41AYB5IodLq2hwWO0ejRWDac48Gb/QKNqNRoqspmrVcAUuIJBANS8sBIFCORUgooPEh4J8B67NgdsVBp9C5XWfl9LRMTCyReX19hARNojWlWLH+AAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+pipe-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChMTCxPz+/ARCBFxaXASChCH5BAEAAAAALAAAAAAQABAAAAM2CLoazpAFIV6UYZB6Yd5BtwRbEYqkYIqAQRir6KpnN8cdCddXivcbAy+S2qEOAuPx8MtZRP4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+shredder-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBERCBAQCBMTCBPz+xFxaXPz+/AQChISCBISC/DQyNPz+BARCRAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARcEMgZhBUzgzuIH4G2FYThnZUlCab5Ed0hC6nZ3Yh8JIKyLjCYboeZKIK6BDHTGwyViopEoWAkdwfqoKhIKLFUwXY79coUtLG4CFAcOOstWyNWyEXMO57p2/vxfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+socket-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+xMTCBFxaXKSipDQyNPz+/MTCxISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARKEMgZpr1SjFqx1QHoTaA4AuV2EmmHEUUxsKoHB7FMGPbhI7gCgnchII6+AyJBtBhjx0KC2TsIp9QXcpm1HafNEQF8mhAOCdfEHwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+trashcan_empty-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipERCBARCRPz+/MTCxISChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARREEgZapiYWjGIvVNQjEZ5BKUAApVgjEWJzCtAnIGgC8eZ5bre7ICosQQFVY9Y/CGVwiYmlwwsac7qVRp6WqNGKpQZ9m7DojH2t+lVMtMP3B8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+trashcan_full-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/Pz+xATCxMTCxMTCBKSipPyqXISCBFxaXISChAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARbEIAQJJU4BzEoIdSFbcNQnIVhBJ02GAeFIGxZjUl8KoHRagfeYqgo3kaxQOEwXPAyk4Mgtgg6jxYp1foETgPEKzSgBXOx0W9VIfZu2d3R5t3WhA5BEdQSQgP8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+www-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3LSyrJyanPz+/Ozq7GxqbDxinBw+ZERmdIySjHRydMzOzPT29CwuNDRurIR2RPTSdJyulEyGvBw+bLzCxIyKhGxubERCPLzKvPzivOTixNTChLSybGyCfCRSnBQqPLy6vOTi3Ly2rCRShPzy5OzerLyaVEx6nCxerGRyhOTezPTShNy6bEx6rER6zDRitBxCfPTu5PTq3LyqjBw2VISq3GySrPTWlHyanIyitFSO3LSqpPTm1DQyNCQ6XHSq3GyWvDxuvCRSpKyurOzizAQCBCxGZCRKZExGLDQuHAwaLBQWHKymnPTmxOzaxHx+fMTCvOzWvLymhHRmVExGPOTOpExOTERCRLyedBwaHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICQoLlwwNDgQPghAREhMUCBUWBRcMGBmnEBobHB0eHyAhIg4jJBenJRwmJxIoKSoVKwIGwg8lFCwmLS4vMDEyIRYzNDUPNjc4OTo7PDAq3T0+Pj0/QBRBQi4UL0NENiFFPkbijoRAkiSJEiVLmDR54OQJFHEPREQRIWWihYlRMkCZQuXBgyIBihSpIjLAowBWroj7gaUIlpYvXWLJUuWKlgdbHvz44XHnzgdVami5qUinR50/efoJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+zip-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBIQChPzC/AQCBMQCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMeCBCh/i+IAesShNo4+v5gKI5kaZ7oxzCilLVvq/kJACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal1day-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANOCLrMEUDIOUS9AFLLhx8LIRZjKYZmMRCkaChFLHty/AIiS3y6q+QtT49wq8VotRtQJGwRf6Zmrlj7DJLQXsupTJmeEIN4TB5nII20wp8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal5days-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANMCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiIdMmcec7jy53q81qP9OO5VMAj8RXTFWzOZW95HDLdEEM4LA4nIE0zgp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal7days-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANPCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiwcp0fucsj873qvGMv5Jw2FIACUsW4WakGW1O046I05qmGYBhTC6TM5CGWuFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calappointment-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxPz+BISCBISChKSipAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARbEMhJaQhA6D1E/wDGeeRgDhOhFoTBEi+REgdrIHScSEVvAD9Xr7cDqGSGpFEnQSqTv2NxCFQOiU1VEAiTZmstHFg1vQKuw+LxxfYaV/AuOQRI2O/4ewhT6Uv8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calbell-16:korganizer korganizer16 16:photo:16 16:R0lGODlhDwAOAIIAAPwCBISCBPz+BIQCBMTCxISChPz+/AQCBCH5BAEAAAAALAAAAAAPAA4AAAM+CLrR+zCIAWsgLVRGRBhOVQiG94WPVAbHaZHYAWqRYLbge88RsbInGuBCEhRYrZYm4xk4nYdoKzKIbiKHawIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+callist-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/KSipPzerMRaBEQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARDEMhJaQhA6D1E/wDGeeRgDhOhruyatjBRSIRxxOsMEAdC0BUZDcfSEYvDo3Bn++2Cxt7RqFxWhZiCdsvdhjCVsMQfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calmonth-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANSCLrMEUDIOUS9AFLLhx8LIRZjKYbiRxLFIBpK0Q6z7MkwkJIe8b0KEeuWchFysuStVsjtfMbeMQitWpG25YfmNK1WU53XNIUYzug0OgNpuBX+BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+caltoday-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxKSipPyCBMRaBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARTEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyIQhFfiBIAfuFzaAioBIJBCummRYPCaDPh3vhwsOZdihNfa8Ub/AJXemFZPPNBvGwG672yFMZS7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+caltodo-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBAT+BAQC/AQCjPz+/MTCxPzCxKSipPwCBMQCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARaEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyMYhFXiuFwZiA6qZYbbqJX5BIw2RAPxwAAWCyWMCCsiXFGEEErKz6LQZfOqiTR1YJiGq1rFyyHmo2+/1EKbCl/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+adjustcol-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBGRiZAQCBPz+/CH5BAEAAAAALAAAAAAQABAAAAI7hI8JAWL+IgvwUSSY2Lz7VTXXkS2NdJ6TwiSaB3PNQNdCbc/4cO9OjwPmhDQiTxfcHY1MpE35g0IB/gIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+adjustrow-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBGRiZAQCBPz+/CH5BAEAAAAALAAAAAAQABAAAAI5hI8JEcItooxG1oEzBoJ7oWlHd4VbNZpbx3LqUFGuajTPhI8kSLfsO0rRUCXT5wPkyHhGhsOJs/gLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+black_sum-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+py60BY2QwhVYdytpw/WFXF1LjcW6S1LVu6xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_all-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIjhI+pq+FuHjwyRInqfRkDTXkgQ5YLOH6it00pyqqcPJk26RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_bottom-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAInRIynGe0PFTQz2kdxzHf72iSiRDpc2F1niaafBroYQNe2fdx6HfgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_fall-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrRIyneRYP4wPUKWmr3E5b+DVh9GkYuFALiqnsJp6nObYZB5ow2a3Jvwv6CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_horizontal-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAImRIynGe0PFTQz2kdxzHf7CoTiSB7kKUpa1Vlc86rtSjvxnOSL4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_inside-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrRIygxxYPF4zzyenqxfVk2m0g9lnKiabqqoYl43YwGcqiFWv22zRnD/AXAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_left-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAInBHKJmxYPY3TyVCozsjMbrk3gM27KyZDlioVQS3qwO7Nl6KC6q/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_outline-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrhI8ZybgQYoTy2YqtwVTunVVfN3HQsaTnc5Kp2Ibw5Zm0PHJ2w7O8I5P5CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_remove-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIjRIynGe0PFTQz2kdxzHf72iSiRDpc2F1niaafBrraSMuQXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_right-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAInRIynaOEPH5hRRVrzbJBLn32g1TXJuWBdpYYiy47hBl+yRqH6HfoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_top-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAImhI8ZyRgPo3xgVnmnprbvnUEhx1XmgpLRmH7e+rowFssleuaBXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_up-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAItRIynwOEPH0vRuGkjnFKjpmgX2FVkuBwNhapZKZ3VyMKcGJPv5eJmAkz5RP4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_vertical-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrRIygxxYPF4zzyenqxfVk2m0g9llmsiCmVjJh65Jh59GtGMuzqqQNDQz4CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cell_edit-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIshI+pm+EPnwmi2msDoLgLzQWDV4HlSJof6qki+W0nrMKlbN9bxGvMDwwG/QUAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+cell_layout-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/PzerMTCxPyqXHx+fAAAACH5BAEAAAAALAAAAAAQABAAAANCCLrc/i3ISacKIuutA8ACxWUeJg0DqBHhd6ZiRpQBag9F2n13FRis0q1QUAmCvFuKRTAYWhIi0bhz+SqQrHbL9ScAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+chart-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAQCxAQC/AT+/MTC/Pz+BAAAACH5BAEAAAAALAAAAAAQABAAAANMCLocHiyuIASU6lE7Xx7DdgEBQVwBKE4mqlZjeT4vl7VFkYZUjOuGkMFiuJ1yKUNAWTQGkEKDknUESpdXkkYjnWIWzOVX0SyPJwx/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+comment-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+BPz+/Hx+BAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CLrc/i3ISacKYuStuwhAMBATKRHkAGJeu60qagqmuHK4B6Pn3N0u147Ha8FyOVCowlRCntAo1J8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+deletecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+/PwCBMQCBISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANICLrc/i3ISacKIuutA8BcKAwfNwwmQYDZoJ6tWrBZoRKuXIb2XRS7UG4wC25yOIGHFvu9PJ8KcRbQOVzAheoxbRCyDOKj4E8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+delete_table-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+/PwCBMQCBISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANPCLHcDDCIOSUVAaqLeY5O+G2XRQVDdA0DNxCEwrwEu9AFORVw3ee6Cu8HFKFgA2AQQ6uNTJNXYZgCNZKFBay4IhQuMBUFW/LKZlkHoOBPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+dissociatecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAASC/AQCBPz+/PwCBCH5BAEAAAAALAAAAAAQABAAAAI0hI+pm+EPoQlC0GqxnfV2HUzR6HDWgA5Bqppr+qIhcMUqO5Oki+M87KN1ejCRTsJIKhP+AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+first_letter_upper-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIohI+py72RIJOHRmBt3QaGz2GVBGJfKW4aiXhX2sHxbKKneDv6zht+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fontsizedown-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAInhI+pELHqmIkQNZrwfXYvzE1fBUrWoZniOjWdp0agjLL2i7rhDvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fontsizeup-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pEeoNIFyIzXStw3q/T4VVhJHHlDGjgZ6n1bLyCrqPyuJe4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+funct-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+py60R3IkRVHQzo9BwD1qhqGneRU4gSqlVJ8Zy0mKPhOe6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+insertcell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBPz+/Pz+BATCBAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAM7CLoa/k7IKQCEdNobc+UOMCijCD5jGjAMOowrIc/Wm77ATIe2leuETcrEYpSOJ88HpNxwmqdi40Tl+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+inserttable-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIuRI6JwCH/HBSBmUlxbarvO0nQJ0aa5XWodjZsiKbJGrbgaMuzW8M87jPoDgx/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+lower-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIqhI+pELHqmIkQNZrwfXYvzE0QKGniQWmNhbYSeqXn6zJOBJLTuuuh4i8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mergecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ATCBCH5BAEAAAAALAAAAAAQABAAAAIyhI+pm+EPoQlC0GqxnfV2HUzR6HDWgKZpCFyBCrMurMoPvZovPsgd39MBbaQI44hU+AsAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+money-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+BPwCBASCBATCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM+CLrcHMHJIEaUD16sqIUcQAne5pQaBglkZS6lxb6dRoIAQTzuphcFXWeW0xl/utIPGDQOSUdnA7IUhoocfwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+oscilloscope-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBOTm5Hx+fLy+vAQCfAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANKCLrcGjDK+IS9494AgrbEJ3CeUBRWpp2daaHhhZKuq75jh8pxTRaEQbAgFAIHv1VvR/vsdrnSCmdpagYnjfXS27Q+N29nQuYA/AkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+percent-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIkhI+py70RUHxxQmosu6BOdWkNR35PVm1etqEsaKXnwTn2DfgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+precminus-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIthH8RiJvrmHogVoXNtFRDpjUf6JWkeUoXlpGBAMfC+cowbd+uwL54/rMFZf4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+precplus-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAI2hG8Rp4y9IGgszqhyspLueYHih43hiX7Iui5XprGTQNeCPNNBje86L9vBdr2a7xY0AllHm78AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+removecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAAQCBASC/Pz+/PwCBCH5BAEAAAEALAAAAAAQABAAAAI5hG+hq+IvAGPwydlqxAohvnjHMChkR6YDcKaougZqCMdyGYqSG+jXKQtoNkGTUHPBDJMTH+jJ8RcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+removecomment-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+BPz+/Hx+BPwCBMQCBISChCH5BAEAAAAALAAAAAAQABAAAANVCLrc/i3ISacKYuStuwhAMBATKRHkUIScUBSeahhigBbzK+HGgXmHmYHXC41MqKDwcGDFMryCz4gi3YQwkKiFY+ZAoYrUF5g1HV3G7DFuFBvSx8GfAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+resizecol-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBFxaXAQCBDQyNPz+/AAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMyCLrcG0A4CZ90saohuv+XEgxYxkDhQp2lyIBwKhB0bct2TuB6zfe7F5D26xV1x9zFnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+resizerow-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBFxaXAQCBPz+/CH5BAEAAAAALAAAAAAQABAAAAIyhI+pmxHinph0GnqH3hoIDwocd3zZ2F0lmoInWq5s/I60xw5hmF8WPnNAhJUK44hM+AsAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+series-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBGRiZAAAACH5BAEAAAAALAAAAAAQABAAAAIjhI+py+0fUGRhGrswVtr1FgiGsGlhZVWAuarr9byyB8f24hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+sort_decrease-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BPwCBAQCBAQC/FxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CBDM+uKp8KiMsmaAs82dtnGeCHnNp4TjNQ4jq8CbDNOroIe3ROyEx2A4vOgkOBzgFxQ6Xa0owJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+sort_incr-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BAQC/AQCBPwCBFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM4CAqxLm61CGBs81FMrQxgpnhKJlaXFJHUGg0w7DrDUmvtPQo8qyuEHoHW6hEVv+DQFvuhWtCFPwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+special_paste-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+xPz+BNTS1MzGLMRaBMzOzPz+rPyqXPz+/MzGNDQyNKSipAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARoEMgJQhBySGx7IEQwFKMWGKgRHNZRIAJSVAm6usIwCEo+BDWVJ/CKzYAplWJZItGSgSVPZBEgU9EFQyGyWoK25XJ4DTO2iob6CxVLe2ys4rw9e8HKd8ybVJ7ndgEVQz09e1YUEmQefhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+strike_out-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBGRiZAAAACH5BAEAAAAALAAAAAAQABAAAAIghI+py+0BgwOS1gXnuS/b6ClCpCUcclJMmKIGWcby5BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_bottom-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIVhI+py+0Po5y0hYtzrkB7zH0fN/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_center-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsnRkqtDnhu1zHfFSpjaY4PavgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_left-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsgRoqr3Vnt102fFSJjUC6nlPoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_middle-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIXhI+py+0PT5i01pisphjt3UmfFZYm5hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_multirow-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsg2kfZvblXbwTg10WlA4rjyvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_right-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+pm+EPIZstSrqsDhhv1ylfFE5jiYwX6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_top-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIWhI9pwe2uYnq0yQtqxbz7D4biSIZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+upper-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pEeoNIFyIzXStw3q/dR2hhEVcJqamuq6Z9brlNtKMeHuKXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+vertical_text-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+pFrHqQHynTRrvyxQ12YWQWJGMpC0f2E1psr4eaj5+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+applix-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRSVFxaXFxeXNze3Ly2rJyanOTi3Pz+/Ozq7HRydFxaVISGhGxubMzOzDQuLExKTCwqLIyKjGxqbERCRCwuLJSSlOTi5BQSFPT29IyKhDQyNISChDw6PBweHMS6pPz69Pz29PTq3Ozm3MSynMTGxAwKDPTu5Ozi1LyulExOTCQiJPTm1OzezLyqlLSyrDw2NOTazOzizOzaxLyqjKSipBwaHOTStLymhLymfGRmXNzKtOTOpLyidMTCtMS+rCH5BAEAAAAALAAAAAAQABAAAAa9QIAQEBAMikfjcCkgOJ2FgCGwFAYOiCwioUAYFtUrgtFFNBzeB5OAgESyEsWEUjFYAJYJ4hLBoDMHBRobAAaGehwdHnoZCQcfEUKHCBQBAxsgISIjJIRCeSUmHAYmJSInKCmRkgYqGw4ZKxMiLC0unoUvFBQQMBQRMTIzNBVDFjUrGwO9Nh8zNzi4BhM2LyIvGhgLNzc5akM6DsEyMjsfPDw9uAALPj4/HyQ0ND31q0ICFRv6FTAb/xE2+AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+binary2-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxeXFRWVNze3Ly2tJyalHR2dISCfLSyrPTy9Pz+/Ozq7GxubJyanKSmpMTCxMzKzLy6vNTS1JSSlCwuLLy6tMzGxOTi3KSipKyurHx6fOTi5IyKjGxqbERGRDQyNMzOzOzu7GxmZIyKhHRydLS2tNTW1ERCROzm5MS6pIyOjDw+PPTu5PTq3LSqnOTazOzi1GRmZJSWlCQeHPTm1OzizLyqjISGhExOTGxqZDw6PNzSxOzaxGRiZExKTCQiHEQ+NLyulOzavOzWvLymhHRybLyypNTGtOTOpOzexLyidMTCtMS+rMSynLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfqgACCAAECAwQCiIiDjAIFj48GAgcBjIIICQoLDAwNDgwPA4MIBhAREgkTmw4UDBUWAxcYFAUZGggbHB0eDh8gIQkiHSMeFRoUDyQRIxkGJRYmFScTKCcHCCkgJyoNGSsWHCwKCCgIASAgLQoZLi8wISUbEyQUJAEDKQEKMS8yMBYeZmCgMcEcghog9tm4gSNEjgEPdEDYEQJEDR4aetzwgcPCjw8VfiAAwqNFECFDehApYiSEoCMQBVjQkQBJkpVKjFhgNGBGzSRLVhZRwsTloAFNmjhZ8WQIDiZQoOwcFMCCVQshrmYN4ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+binary-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz69HRydMzOzDQyNIyKhERCRPT29GxubPTy7Pzy7PTu5Ozm3LyulPTq3Ozi1OzezLyqjPz27OzaxLymhPz29OTStLyifPTm1OzavOTOpLyedMS+rMS6pMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaJQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOq0WDgVEQrFdKAXfhJWRODTMQ6+64BAMGHAq+pB4hCF2eURoVwgREhMUgl5/EBUWimdWB4cVDxcYiwJiGQcVfBobmhwPEgkWFg8dmWcQEgcWFw99HpoVFR8XGiAhISKLI8EkJRgYGyK/SgvLzM0LfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+colorscm-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIcAAPz+BFxaXNze3Ly2rJyanPz+/Ozq7GxqbJxaLLxOFLQ+HLQ6NMSOnOzi5GxubMzOzDQyNMx6JOSSXOSedNx+ZMxaXLQ6ZKRalNzW3IyKjERCRNSWPPTKnNReNMRGVLxalJRGpHRanNTS3PTy9OTi3ISGfLySNOzCfPTatOy2dNxuFMw6DJxGrHROvEROnHyKrMSmTOzanNzShOSqRNyCFMxCHJxGnFxavDxqxCRmrCxijPTq3Ozm3LyulLyyZOTenNTGZMS6VISKbCyCzASGxAR6rBxmhKyqpOzi1JyuXLTShJzKdHS+XES2XCy6pDSy3Bym3AySxAR2pBxadKyinPTm1OzezLyqjGSWTHS6ZFy+ZCyyVCS2dDy61Dyq1CSOtBRqjExqZKyilOzaxLymhDyeTCSuVByyZCS6hDS2vDSatCx2lCxabIR+dBSKTByeZCSmhCymnCyanCR6hNTCrOTOpLyedCxmVCR+bCR2bCRmZExqbMy+pOTStKSelKyejMSynLyqlLymfLyifAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAjqAAEIBBCgoEGDAxMGEMCQ4YAABAIkFLiwgMUCBg4UiJgQQQIFCxg0sOjgwUYIAiNImEChgoULGApkcHBAA8oNHDhI6ODhA4gQIkaQGFACgokTKFKoWGGBRQsXLwQIHQABRgwZM2jUsHEDRw4dA3bw6AHBxw8ZQIIIGUKESBEjR3YgIZtEyRImTZw8gRJFyhQqVaxcgYAli5YtXJx08fIFTBgxVsaQQVnGzBk0TtKoWcOmzZExklECcPMGThw5czqLoYOijh3RAO7gyaNnTxsxfOr0cQ2boBg/f44AChRI0KDXCiEoX84cgp+AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+core-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/PzuBFxaVNza3Ly2tJyanPyuBPQCBPz+/Ozq7GxqbFRSVHx6dKSmpHRybMzOzDQyNGRiZHRydHx2fExKRCwqLPTy9ISGhERCRCwuLERGTIyOjBQSFGReXJSSlFRSTDQ2NAwKDNze3OTi3Ly2rFxaXAQCBFxeXMzKxOzm3LyqlDw6NCQiJFROTLy2pDw+PGRiXMS2pOzi1CwqJBwaHAwODAQGDJSOhOzWvLymhKSajNTGrJyWhOTOpLSyrKymlKSelMS+rLyidMTCtMS6tMS6pMSynLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgAAAAQAChoeHgoqCAgOOjgQCBQKCBoMABwMImwgJCggFC4sGDAQNDZoIDg+gEAcABhESEwoUFQsWFw4KGBmCGhsFGwoLEBwYCRYEFxCEHRceFwofIBwhDSIjJBCCCxISDiUaGRwmJygpKr4AGAIl4issISYtLuncgi8YLxAs5SYwYshQgQ8AixksaNSwYYLDDRc4chS0USMEQxMhHOjYEbEggBUWTQhwwANiD4mLBPj4AYTHjyA9cPQQsq7bkCFEihhRkSPHkSMeBUDIAGFo0aMZ/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+deb-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/FxaXNza3Nze3Ly2rJyanPz+/Ozu7GxqbPz6/JwCBMw+PMQCBLQCBNx6fPT29GxubMzOzIyKhDQyNLwqLLRWVLxaXNyurERCRMzKxOzq5Ozq7MQ2NMRmZLwCDOTi3Ly2tMReXOS2tMTCvPTu5Ozm3LyulMSSlNTOxPTq3Ozi1OSytPTm1OzezLyqjNyqpLxaVNzSxOzaxPTy9Ozm1OzexOzavLymhOzWvOTOpOTStLyidMyShMSulLyifLyedCH5BAEAAAAALAAAAAAQABAAAAa0QIAQECgajcNkQDAYCASEQCGQFC4NWMMBkZhWFQtGw/EwQCIGyWSoaFAqFgblIkEgMGthQ5HRbAQcFAcaBGp6DQEJCx0XFx4ZGx8geQ1ECyECByIMIyQlJnkMRBwnBwYODSgpKqB6RCIcK6gEKiwtLpQKiS8WMAQxKi0yuEOICTM0LSo0NTY2N3kAbhoHBzQ0zjg50EkKHC80LCo2ODo5O9FEBCE8Pe49Pj8/6QET9vf4E35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+document2-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJSWjPz+/Ozq7GxqbJyanPT29HRydMzOzDQyNIyKjERCROTi3Pz69PTy7Pzy7PTu5Ozm3LyqlJyWlJSSjJSOhOzi1LyulPz27PTq3PTm1OzezLyqjIyKhJSKfOzaxPz29OzizLyidIyGdIyCdOTOpLymhOzavOTStMTCtMS+rMS6pMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaQQIAQECgajcNkQMBkDgKEQFK4LFgLhkMBIVUKroWEYlEgMLxbBKLQUBwc52HgAQ4LBo049atWQyIPA3pEdFcQEhMUFYNVagQWFxgZGoxfYRsTHB0eH5UJCJAYICEinUoPIxIcHCQkIiIllQYEGCEhJicoKYwPmiQeKisrKLFKLCwtLi8wHyUlMYwM0tPUDH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+document-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz69HRydMzOzDQyNIyKhERCRFQ6LJSKfNTOxJSOhPT29PTy7PTu5Ozm3LyulOzi1PTq3OzezLyqjOzavPz29Pzy7OzWvLymhOTOpOzaxOTStLyedMS+rMTCtMS6pMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaLQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOq0WCAREQrFdKAVXKyNxaJgBjgck4khLBAPGm4r+ghETeHtEfVaAFBUWg15gjReKZ4YTFBgYGRpvcQoPDggRnwwMG5hnHB2UFxcbHh+LAh0YDA+zDyCtZ5UXIRsiIiAjiyQlJCYnGhofI8BKC83Ozwt+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+dvi-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FxaXNze3Ly2pJyanKyijPz+/Ozq7GxubIx+RIRyLHRyVGxqbMzOzDQyNHxyTHRqNGxiJHRiLJySVIyKhERCRGQmLMy6ZNS+TMSuPLSePIRaNGReLHRuTPT29FxOFKymdIRmLHRiHGxKLDQuDPTy7Ly2tHQqLLwyPIxqVGw6LIx2LGRSHDwyDDwyFNTOxOzm3LyqlIQuNLy+zKSGdKSSfJRSRKSSNExKJLSmnOzi1LyulIyCZIxiPJyGLExGFOTSvOzezLyqjLyyXAQCBNzGRLyeREw+DFRONNzSvOzaxGxqVKSelJSCNEQ6DFRKFKSajMS2pNzOtOTStLyidEQ+FLSunOTOpIyKdMSulLymhLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECjIwDAQQBiYIBBQUGmAcIBpGTCQqgC5gMDZwOgw8KEBESEwkGFAgMFacAFhcYGRobEBwdHgIDFKcWHwYgBiEhIiMkAyUCJg4nKCgp1SorLC0uBC8wMQ4yMzQnNTM2Nx84LTkNOjunNjY88z0+Hz8kOUBBQqdDiHQoYiREhBZHkORIouSfIAghjCiI8IHEEiYDgAApUAtAEwgfnDzBASWKFCBTqHQE8ONIFRwErFxRcuWKSkU8sBTIkSWLFi1btqwM4KCo0aMO/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+font_bitmap-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FRWVFxaXNze3Ly2tJyanPz+/Ozq7GxubGxqbNTS1DQyNPS+vPw2NNQeHFw6PPTy9IyKjERCRPzi5PyGhHRWVOTi5PT29OTi3IyKhPza3LySlLQGBGQCBNza3Pz69PTy7MS6pKRubPy6vGQ2NKRSVIxmZPTq3LyqjLQqLHRydPxydHwCBNTSzPTu5Ozi1MSynKQCBOQ+PKwCBIReXJwCBExOTMzGtOzezOzWvEQeHLSytOR+fIxaTOzexLymhEwCBDweHNTOzPTm1LRORIQ6PJyOfOTOpOTe1OTSvLyedMTCtMS+rLyulLyifAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe6gACCAAEChYeGg4oCA42NBAEFAYqCAQMGmAYHCAaSlJaZmAkKnQuKAQwNDg8QBhEJCRKmgwITFA4VFgYXGAQZs5UaGxwdHgYfIAMhwAAiIyQlHCYgECcnKMwpKSoKKywtLicvMMwcHDEyMjM0L+3YgzUsNgH0HCw3ODnvgjU6OwMvBvCQ0cNHjh+zOgAJIqTaECJFOhg5gvAUEmsvksBAAeOIEmYBbixhEgJGExROlHw8taCly5cL/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+font_truetype-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSTFxaXFxeXNze3Ly6vJyanPz+/Ozq7GxubHx6fCwuLDQyNIyKjKSmpPTy9PT29HRydMzOzCQmJAQCBKyqrFRSVLy+vGRiZNTS1GxqbERCRMzKzJyenOTm5JSWlLy2rIyKhMzK9KSm1Kyq3OTi3OTi5JyezBQSJExOTLy6/CwuXLy+5LyulMTC3LSytHx+7Ly2pLSyxLyqlNza3Gxq1OTWxMS6pLyqjPzy7OzexPTq3LyynOzWvLymhPTy7DQ2bOTOpGRmhERCfNzGpLyedMTCtMy+rAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfIgACCAAECA4WHhoOLAgSOjgUBBgGLggEEB5kHCAkHBgKCCgsKBgwNDg8HEBESngwAExQVBhYXGBmZDREaGwuDHB0CHh+4qgQgIa+CBMEiIyQiJNAlIMoAJgYDJygpKisWLAMtvoIe2S4pLzArMTIBM9YHBRUeNAQ1KwU2NzjWFAwDDEDIgS+GDh39Fl3ykGMHPh46evggJ2gAgR87HAKZYSOID2uECGQUMkRIAiJBioAUYMTIkRs8cODwUUSlQgY4GSzQuVOnn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+font_type1-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FxaXNze3Ly2rJyanExKRPz+/Ozq7GRmZPz6/HRydMzOzDQyNJRmZPSmpIQuLGwWFKxeXPTy7IyKhNxSVGxCRLy6vPQ+PPT29GQ2LPTCxOROTPz69KQ2NPSGhPTq3Ozm5LyqlGwODPxiZOzi1LyulLwKDORydBQSDOx+fNw+PNS2tOzi3PTm1OzezLyqjNQaHPRubJx+fMS6rOzizOzaxMwuLKQWFHRaXOQuLJSShNzOvOzavOzWvLymfCwiHHx6dOzexOTOpOTStLyedMTCtMS+rMS6pMSulLymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfFgACCAAGFhoaDiQECjIwDAQQBiYIFAgaXBgcIBgQFk4uYBgkKC5wMiQ0ODxAOERITCggFp4MUFRYCFxUCGAIDE7QAFBkWCRobChIcEr60HR0IHAYeHQQYEh8gIbQbIgjGIw8WEtgkJacmJyjfKSoFKywfLS4vpzAxEAgnHSYyJjMkaNSoB0CEChs3cMjIYULHDho8evig9aPiAQFAHAap0UPIREXYPpAIEnGIECLBABQoYmTGESRIfCQhglIRg5s4czLwEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gf-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BFxaXDQyNAQCBMTCxPz+/ISChKSipERCBMTC/Pz+xPzerMQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARwEEgQahVijMmD/oRAbBw1FCgaFFrppeo5UtILWxlAGNWZHocA4bAxGAnDg9GA8LQCxGTQoHwVNYYEMEHtKYrEA0tctVIOo0Fl2Ct8AQLlKMnzLFg1KIHBCGoUbiR5VSd3C28TThpubgqIEhkfkh9+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+html-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRaVNze3Ly2tJyanPz+/Ozq7GxqbDxinBw+ZERmdIySjMzOzPT29DQyNDRurIR2RPTSdJyulFSGxLzCxIyKjHRydERCRLzKvPzivPTmxNTChLSybGyCfCRSpBQqRLy6vPTy7OTi3IyKhCRShOTixPzy5OzerOTShLyaVEx6nCxerGRyhOzi1LSyrEyGvOzaxPTShNy6bEx6rDxyzDRitCRCfPTq3LyulBw2VISq3GySrPTWlHyanIyitEyO1ER6zBxCfLSqnCQ6XHSq3GyWvFyGvDxuvLSqpPTm1OzezLyqjCxajFyO1GSi3NS2bKyaTCQuPGRufOzexLSmlER2vKyWNFxaNHx6dLyunOzWvLymfERSVExKNDRCNKyilMy+pOTOpLyifFxaVLyidMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfYgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICQoLlwcMDQQOgg8QERITnhQFFRYHF6cPGBkaGxwdHh8gISIDI6ckJSYnKCkqKwksAiEtLg4kLzAhMTIzNDU2HxQ3NzgOOTo7PD0+P0A1QR8uNy1CDkMvREUyRjNHHjkfSElKlpxi0sTJjydQAiSIIkXIFBhUTn14UIWGFQhXHHzAkgWGli2nAHxIwIRLFy8bv4DREkZMSEEfYo4hQAVMGJZkXhIaIERImTJmlogRc0ZnAAdIkyp14CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+image-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPz+BFxaXNze3Nza3Nza1LS2tJyanPz+/PTu5GRqZOTi3HRydMzOzDQyNJQOFDxKfKTW5OTy/OT23MTaxISKhGxmZERCRCwuLJQSFPzGpLweHJTO3ESu3DRilNz61FymXCxKRMTCxPTy7Ly2rIyKhDwCBORiRKQWFEy23CyKvJTWhDSOPCRONDQaHNROPNQ2JLRubHTC5DR6rHR+jFSqRCRyLGxqbOzm3LyulCwqLMySjMQ2JMyqrERijJSenFSGXGRmXMS6tPTq3Ozi1MS+vMxCNKyqrHR2dPTm1OzezOSKfNTe5KSmpIyGjLy2pOzWvLyqjIRqZIyKjHR2fExKTHx2bLyynOzexLymhERGRGRmZKSWhMS6pOTOpLyedMTCtMS6rMSulLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAGFhoaDiQECAwICBAUBBgGJggEEB5kHCAkHk5UBCpqZCwyeDYIOAA8QERITmRQLFRYXABgZGhscHR4fICEiAiMkDSUmJicoKQ8qKywLAwgKIxctLi8wMTIzNDUJNiEINzgNOTo7PBA9Pj/QQEFCQzg5F0RFEQQ+RhRHswVIkpS7oEMJgiUhCjBpcqSCkyFPoNjKEYVJCCNSpgSgUsXKlSdYUAG4kCOLlgpAgFTZwuVJFyy2Bi0gEsSJzZYuvYi09OULGC44wmAR48VLDkU5zClt0OACUz+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+info-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanDROXHSSpISetPz+/Nzm7GxqbGyGnMTS3MzW3JyuvERujLzG1HRydMzOzPT29DQyNMze5Iy2zLTS3Cx+pCRijLS+zIyKhGxubERCRFR6lGSivFyavISuxAxajBRejAxGdDxihJyyvCR6pBRqnAxelAxOfPTu5OTi3IyqvFSOtJy+1IyyzFxyhOzm3LyqlGySrAxejAQ6ZFxqfMzKxPTq3Ozi1LyulCxulAQuVISKjMzGvPTm1OzezLyqjBwmLBROdExOTKSinNTOvOzexBQeLAw2XAQmTCwyPLy2pOzaxOTWxLyedCQmJAQKFAQWJKSalOzavOzWvOTOpLymhKyqpMS+rOTStMSulLymfLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECjIwDAQQBiYIFBgcImAkKCJGJCwwNDg8QmBESEwQUgg4VFhcYGBkaCBsRHB2qHgwfIAghIiMkAhMCAxsUJSYhJygiKc4qCysrLAPILS4oLwgwKcExEisyMxQFNBg1Nb7ONjc4OTo7yAU8IiIIDiIqPT4/QEFCVA0hooJBAg0eehQxciQIEnKCktiYqGQJEwJNnCB5AkWVoChSpkwpQmXAkypWrmDxKAhSlixaTlrZcqWjIi0/BmjhsgNLFy82BwWgQDQK0aNE/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmultiple-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXPz+/AQCBISChPz+xMTCxPzerKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEIRJgb04iLEJwaAmjMTwgVbAjeaESmNcGMGrxmOhDqE8HAOVJ7MSFH4qhOmiOQIPNIGB4JJwnIaDaFaTUL4iYxc0MJidQVvROc4Yfz+a+g3V2sAVfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+log-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanPz+/OTm5GxqbMTCxARiTARSPARCNAQ6LAQyJGx+fGxubMzOzDQyNCxGPARyVARqTARaRLSyBCRGHFRuZIyKhERCRDRuXAx+ZPz+BIyOBFRybOTi3AyGbAx2XExaDBROLOzm3PTy7DRORDyeXBx2VEymVHyuJGRyDPTu5LyqlFyGTBxaNAxqVDR6PARKNPTq3Ozi1LyulCRuTCxeNBSCZDxmJEx6bOzWvPTm1OzezLyqjCSSdCSmhBySdBR+ZARqVEx+bNzSxOzizESCdAQCBNzOvOzexLymhOTStOTOpMS6pLyedMS+rAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfIgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkYIICQkKCgsLDA0ODxCbEQASExQJFRYXpBgZDwcaqxscrgkdHqMfBiADGasIIRwiHSMdJB0YJSYCA6snKCkqFgorHSwdIC0lLqsvvx0wMTIWMxgCNDU2xzcdOBw5EzoKOzw9Pj/WgAQRIiTEkAlEihg5wgMgACRBkpwQIpGDRCVLeDCJACGJx48gAzRxspHQoZNPRkJZNSjAkygDntiwwYQJlJWKIujcyTOCn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+make-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxWVFxaVOTi3Nza3LS2tJyalGRmZMTCxPTy9Pz69Pz+/Ozq7GxubJyWnFRWVHx6fHRydMzKzDQyNHx2bHx+dIyKjERCRGRiZKyilLSifMTCtLy+tISGhOS2bPzerPzuvOzetJSSjFxaXOzu7PTy7MS6pGxqbKSWdPS+dMSidOTerPzqtISCfKyurOzq5LSqnMzKxPS6ZEw6HJSKbOTStHR2dMzGvPTq3OzizLyulFRSTOyyVNymXOy+dKyqpPTm1OzezLyqjJyCTOSqTOSmRLSupNzSxOzaxOzexOzWvOTOpKyinMS6rNTGrLyedMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfagACCAAEChoeGg4oCAwQEjQUCBgGKggcICQoKCwwNCg4CiwQPCBAFmRESCwYTghQCEgYHDBUSChYNDRetGAQZGhscHAIFDAoDHB2tAQYeHyAhIiMIJAolBCYTAicoKSorLBItGC4DLy8wExExKjIzNB81CBI2Nzg5Oq07KDw9Ph4mdgj4IQFIECGtHrgYQqRIjQoPjBzJkQMJQgANkrngYGFAhB8UkyjR0EpQAAkUKkQQkCGHEiVLLg6y8IDJhiZOXsJ8UtLkhpsmoAgRouIJT0UPJihdynSCn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+man-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXFRWVNze3OTi3Ly2tJyanNza1Pz+/Ozq7GxubMzOzDQyNOzq5KSmpNTS1IyKjGxqbERCRPTy7PT29LSytOTi5MTCvMTCxLy6vMS6rISChLy+vPz69HR2dLSyrLy2rNTW1IyOjOzu7OTm5HRybHx2ZNTOxLyulLS2tIyKhHRuVMS+tHx6fGRmZLyqjISGhJyenMTCtGxqZGxmVMS2pFxeZGxiTMSynLymhHx6dGRiZFxeXFRSVLyifGxmTKSSfLyidMS+rLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAEChYeGg4oBAwMEjQUCBgGKggEHCJkICQoIBgKKkgSamQoLngyWDQ4PpAgQChESqQACExQVFgkXGA8ZBBobtAENDQsGHB0dEx4fBCC0AhYhGCIjFA0kJSYnKMMPHCkqFg0DIQorLN6WCx8OLQsHIQsuKxovtIQwMR4ZHDIYZtCogU+RjQAeUmDAkELBDRw58hHSsWMDjx4XV6DwIZGYCRc/aNz4AeRFkI4sZAipgePFCx9BhkgUwKCmzZsM/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+metafont-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJSWlPz+/Ozq7GxqbKSajPT29GxubNTS1DQyNIyKjERCROzi5Ly+vKyqrKSipKSmpKyurISChKyinHRybISGhGRiXJyanIyOjFxeXJyenJSSjMzGxMzOzMTGxLS2tISGjExOTLyulMTCxISWpGx6jExifFxufJyepJymrFRSVLSupLyqjERKROza1OTKzNS6vGRmZLy6vPz29Hx6dMTCvHRydJSKfOTStLymhNTCxLSOjKx6fMS6pLyifLSytHx+fOzWvOTOpLyedMSulLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFCJKKApcFCQoLBQQMnqAFDQoHDqeDAQ8QERITBhQVFhWnF4IVsxgKGRobHB0DrxUeHyAhIiMeGCQVFCWvACYCJygWKSoTFxcD1oMJGissJiwjFC0ZLi+nMBoLMTIPFDMzDS00FvEAYlyQUMNGiBs4OuQgoWMHj2sDe/j44aNCBh1AdgS5BoCGBhNChlxAQGRHESMcYXCI5sHCkRdIkKBUxKCmzZsM/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+midi-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Nza3Ly2tJyanPz69Pz+/ISChOzm3GxqbKSipAQCBHRydMzOzDQyNIyKhERCRPT29OTi3PTu5PTy7LyqjOzi1OzezOzWvLyidOzaxOTOpMS6pMSynLymhLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaOQIAQECgajcOjUTAYEAKFgDBgOFQNiMHhkFAYosQFg2HNbg0Nx/dB3W7NW0hDEWEjxm+BWzIhINhVbnBUFH12eAeDFRQUFoBuiVoGRRQXjgGQiQQLCwELBZaHZJGMARgLGZeZCARRUKgaom8DCAEZGwscqm5YrZyfHLFKRQQdHhYWHxogD0NED9DR0g9+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mime_empty-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz69HRydMzOzDQyNIyKhERCRPT29PTy7Pzy7PTu5Ozm3LyulPTq3Ozi1PTm1OzezLyqjOzexOzavPz29OzWvLymhOzizOTOpOTStLyedMS+rMTCtMSynLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOq1eEQnFdqEUXK2MxKFBHnqvDsGA0aaaz4iHvE68WxEQERITfG+ADxQVhGV/DxEWFBcYhQIIgBEUFBkak2UbgYkZHBwdlIgUHh4aHB+lZZkVF6sgHyGFIiMiAyQYGCUhtkoLw8TFC35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+misc_doc-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxeXFRWVOTi3NzW1Nze3Ly2rJyanPz+/Ozq7GxqbMzOzDQyNHRydExKRERGRExKTERCRCQiJIyKjCwuLGxubDw+PDw6PDQ2NBweHAQCBPT29IyKhNz+3HzmfDTCNASaBBxaHCQmJPz69PTu5JTqlGTOZCSmJAR+BBxSHOzm3LyqlFTKVASCBARmBBxGHNTSzPTq3Ozi1MSynAyeDAROBCQ+JBQSFNTOxPTm1OzezLyqjCwuNAQyBCQ2JMzGtOzexAwODOzaxOzWvLymhMzCrOTOpNTKvMS+rLyifMTCtLyulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAECAwQCiIiDjAMFBgeRCAMJAYyCAQUKmwoLDAoJA5eZnJsMDaAOAA8BEBESExETFAsVDwwTFgAXAhgOGBkaGhscHQUIHqoDAR8gISIjJBQGJSbHugMSJygpKisU0x0mLC2qAhEuKS8wMRsbMiYzNDW6ARM26zc4ORQ6Mzs8evgAACGDChg3fgDhF6SAECE9VEXQYKGiDwtDKAQRQqSIEV25KGzIQZIDhSNFiiAxomoQAwM6kgRRgiQlkiW6BgVIwkQJghpNeixx4qQlJiAWHCh1kFSpBT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+netscape_doc-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNTW1Nze3Ly2rJyanPz+/Ozq7GxubPz6/OTi1Ozq3GxiTMzOzCwuLMSijGROLLSqjGRiZOze1LSOdIyKjEw+NHxGJNSqjMTGxPTy7Ozm1NzWxLSSfFw+LMzKvHRuVKyeZHxybOTazOTi3Ly2tDQyNOzm3MS6jFxaRPTu5LyulOzi1KSehMTCxKSOdHxuRMzCpJSGXOTStLyqlHRqRIR2TFRKLLyedLyqdGxWLIR6XOzezJyCZJySbEQqHKyKdFRONJSKfOzaxNTCpKSWbJSSjExKNHxuNOzWvLymhIyKhOTOpHRydHx6bIR+dOTOrLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECA40CBAEFAYmCAQMGmAYHCAmSlAEKCwyZCA2dDoIPEIsREgkTFBUICBaoABcYGRobHAodHhkDBBW2AB8fIBwMESEiIxokJSaDJxAUKAwQESkaKicrqBssLS4vBzAfMTIRMwo00zU2LTc4OToQOzU3DDwr04Ixeljw8QNIiCBCYgyJUIxIESMfjuxAwoDDkCRK/j244CNHjhBIPDxYMoPJA1sXIDRxkuOIkycXHsyAEqUYoRk7GDAh8uJFDhw4/lUy4aCo0aJE/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+news-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBERCBPz+/FxaXIQCBMQCBMTCxISChKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARXEEgZwrxYikFsvtUwBN0nEWIhkh4YiIOhjiX1hqIsHlb4jr8VwoJa/XCCBG4ZZA2bRxEi0QkgeLAloUZKYGEDhLgG6H5JBEFrYg4ItmsMCaGomFyEiz8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+pdf-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FxaXNze3Nza3LyypJSSlPz+/Pz69Pzq5Ozq7GxqbJyanNyGhNx6dGxubMzOzDQyNERCRPz6/My+vLxaVJxeXKSmpNTGxIyKjNTS1OTi5OzCxLRSVMTCxKyWjOTi3Ly2tIyKhLxmZLSWlOTe3MzKzOza3MyytNyOjAQCBKyqrOzm3LyulPSajMRWXOSGhOyGhKxiXOzi1OxyXKRORIxSTNTKzMy6vLyenLRubLwqLMxiZNSurJRybOzezLyqjJxCRGxSTLy6vGQiJMw+LJR+dMzCrOzaxIyOjKyurHxydNxWPNTCrOTStLymhIR2dKyKhIxuZIR+dJyShOTOpHRmZKSKhJyCdKyilMSulNTCpLyedMS+rMS6pLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfQgACCAAGFhoaDiQECAwKMBAEFAYmCAQMGBwgHCQoGC5OKAgYMDZcODwYFEIkREhMUFRYXGA4OEauCGRkaGxwZHR4ZHyAhuAAdCQgiFR8aHSMkHwS4JRomIicoJykqHh0rLKstLhQcFC8wMR0FHgQy4TM0HDU2Nzg5Ojs8PQQ+P6tAggjRVaLEjiFEihg58k+QBSQdQCTpoITIkhBMmjgxVsBCxydQokiZYoTKxkRVrFy5EgJLFi1NqGwxRohLBy5dsmT54cXLTEUQggodCsFPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+pk-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQChFxaXDQyNAQCBPzC/MTCxMQCxPz+/ISChKSipERCBMTC/Pz+xPzerMQCBCH5BAEAAAAALAAAAAAQABAAAAR6EIAQhLVjECJlKISwjcZgcFNxhATiugKyTaP4wu0JiOyNXBqAIWFpvRQKgUHBSTgNS4UzseBxBMxoMiG1NTcJBpLBLTaaTIVM3fXuFKeQMmk7AwbSU5QocsgkFnAPD0kbFBQdO1hELQ4fK4lWLQ0IASsoEhojIwEjfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+postscript-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxWVFRWVFxaXOTi3Nze3LS2tKSajPT29Pz+/Ozq7GxqbJyanISChPz6/HRydNTS1CwqLMTCxISGhOzu7ERCRDQyNERGRLy2rIyKhExOTAQCBKyqrOTm5KSmpHR2dNza3AQGBNzSxOzm3LyulBweHBQSFKSilOzaxAwKDOzezDw6PJSSlDw+PKSelNzOvLymhAwODNzGrOTStLyqjExKRHRqZLymfMTCvMS+tMS6rLyynMS6pOTOpLyifMTCtMS+rMS2pMSynLyidLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfPgACCAAECA4aIA4OLAgSOBQQGAgcBi4KNCAmaCgsJDAKWjQkNCA4JDxCeEYwSDQ4TFKMPCxUWAA0BEQ0GDggQDxcIBBgZthobExwICB0eFRsSHcOrER8QCwYIIA8bIRwiIyS2JSYVHgsQzhsbJygEJKsl6ykeH9zrJyIq4gAp6xsrWLT45+IFChi2YqwLwcLEvxgHZMygsarBOgsCBGioUcNGxBk3bA0SgCOHjh0oeczo4WPVoAA/fgAJIoQGjSFEiIgUNCCCBZ8Wggq14CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+readme-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanDROXHSSpISetPz+/Nzm7GxqbGyGnMTS3MzW3JyuvERujLzG1HRydMzOzPT29DQyNMze5Iy2zLTS3Cx+pCRijLS+zIyKhGxubERCRFR6lGSivFyavISuxAxajBRejAxGdDxihJyyvCR6pBRqnAxelAxOfPTu5OTi3IyqvFSOtJy+1IyyzFxyhOzm3LyqlGySrAxejAQ6ZFxqfMzKxPTq3Ozi1LyulCxulAQuVISKjMzGvPTm1OzezLyqjBwmLBROdExOTKSinNTOvOzexBQeLAw2XAQmTCwyPLy2pOzaxOTWxLyedCQmJAQKFAQWJKSalOzavOzWvOTOpLymhKyqpMS+rOTStMSulLymfLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECjIwDAQQBiYIFBgcImAkKCJGJCwwNDg8QmBESEwQUgg4VFhcYGBkaCBsRHB2qHgwfIAghIiMkAhMCAxsUJSYhJygiKc4qCysrLAPILS4oLwgwKcExEisyMxQFNBg1Nb7ONjc4OTo7yAU8IiIIDiIqPT4/QEFCVA0hooJBAg0eehQxciQIEnKCktiYqGQJEwJNnCB5AkWVoChSpkwpQmXAkypWrmDxKAhSlixaTlrZcqWjIi0/BmjhsgNLFy82BwWgQDQK0aNE/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+recycled-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanGRmZKyqrMTGxPz+/Ozq7KSinOTi3LzatLTGpJSSlMzKzGxubMzWzPT29DQyNMS+rOTy5KzWlEymLDSSDKTClIyKjGxqbERCRGx+bNzu1Hy+ZESeHDSWDCyKDCyGFMTKxHx6fOTi5ISCfFRuVKzGnJzKjDSOFJy2lNTSzJSSjPTy7Ozm3FR6RJzChGSqRFSePHyqdMzOzLSytNTOvLyulExyREyWPESSJMS+vKyurMzKxPTq3Ozi1BxeDDSCHNTS1Ly+vHx+dIyOfPTm1OzezLyqjBw6FBxmDFSKRMzGxERONOzavBQ6DBROBHSOdCxeLDRCJKSelOzexOzWvLymfCw6LBxGHFRiTOTOpERGRKyqpMy+rLyedMTCtLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAGFhoaDiQECjIwDAQQBiYIFBgcImAkFCJGJCgsMDQ4PmBAREgQTghQVFhcYGZYIGhAbHKodHh8gISIjJCUCEiYDJxMoKSogGCsjLC0GLgkvMAMTMTIzIjQ1LDYHNxo4CTA5Ezo7PDstEQ8HPT4nP0BB5jpCQxFE7kU3RkcHkCRRomoJkyYHnBQZ0OEJARxJoBAUFEWKjilUolSxMiDJFSxZVAnSEmVLFC4EBnzE0iVkIi8EvnwBs5JlGJGCAogRQ2EMmTJZsoS5qWiC0aNIJ/gJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+resource-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxeXFRWVOTi3NzW1Nze3Ly2rJyanPz+/Ozq7GxqbMzOzDQyNHRydExKRERGRExKTERCRCQiJIyKjCwuLGxubDw+PDw6PDQ2NBweHAQCBPT29IyKhNz+3HzmfDTCNASaBBxaHCQmJPz69PTu5JTqlGTOZCSmJAR+BBxSHOzm3LyqlFTKVASCBARmBBxGHNTSzPTq3Ozi1MSynAyeDAROBCQ+JBQSFNTOxPTm1OzezLyqjCwuNAQyBCQ2JMzGtOzexAwODOzaxOzWvLymhMzCrOTOpNTKvMS+rLyifMTCtLyulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAECAwQCiIiDjAMFBgeRCAMJAYyCAQUKmwoLDAoJA5eZnJsMDaAOAA8BEBESExETFAsVDwwTFgAXAhgOGBkaGhscHQUIHqoDAR8gISIjJBQGJSbHugMSJygpKisU0x0mLC2qAhEuKS8wMRsbMiYzNDW6ARM26zc4ORQ6Mzs8evgAACGDChg3fgDhF6SAECE9VEXQYKGiDwtDKAQRQqSIEV25KGzIQZIDhSNFiiAxomoQAwM6kgRRgiQlkiW6BgVIwkQJghpNeixx4qQlJiAWHCh1kFSpBT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rpm-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/FRaVNze3Ly2tJyanFRSVOTi3PT29Pz+/Ozq7GxqbFxaXHRydNzazDQyNIyKjERCRGRmZExOTLyipOSytLy6vIyCfBweHMzOzNS+vMRqZMRSTNzGxAQCBLxCPMzGvLyulCQmJPz69IxKRIwWFLSGfLyynAwODERGRMTGxGRiXLyqjHR6dIyOjBQWFLSqnNTCpNTKtLyidPTm1OzezOzavOzWvOTOpMTCtMy+rMSynLymfLyedAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAazQIAQECgajcNkQMBkDgKEQFJYMBwQ2ITiEJ0uDFjsgdHgOpIFQRj7UCggZyEksIgoJBPKwVCxnBUXEgwYBgkGGRobHAYDDgUdFx1fawceHh8gDiEdnEthIgcjJCUmDh0nKJwdCCmcKh0WJiumQh0sFR0tFyYuLycwK5u1nBYsFwMuJicTs0MdEhUpDRkxMRkwMDJxQl8zBjM0NTY3N9poKTg5JjorKzsyPNtEDvT19CH0fkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+shellscript2-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3LyypJyanPz+/Ozq7GxqbPT29HRydMzOzPz69DQyNHRaJKyONJR2LJyCJKyCHKSCHMSqZNTOvIyKjGxubERCRGxSFIxyRKR+HMyeHOTCLMSOHLyWFMzGtIyKhHx2bKSGZNyiFHxeDOTi3Ly2rMyudOTCpOTKxLyqjJR2VJxuDLSGHLSunPTu5Ozm3LyulJx6NNSyXOTCjOzWvPzi3MyqhGxSLFQ2DLSKLNSqTPTWtPzq7NS2nIxyVIx6ZOzezFxCFOy2POSyROTGlPTazPTWxLSiZLSSVMy+rOzaxKyCJMyeNOSyTNy+dLymXLyePNyqPKSWfOTStLymfKR6HMyaPMyaNJR6TMy6pFxKLHxWFKR2FIxiDOTOpLyedMTCtIyCbMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfQgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZOVlwgJCgsEDIINDg8QERITFAUVFgcXpYIYGRobHB0eHwgCAyC0giEiIg8bIyQCCCUmtCInKCkpKissLS4vMDGlMjM0NQsINjc4OQ0U26U6OzQ8CAg9Pj8uQBRBKgxCQ0QzRUY2jiDRkURJkCX5ADBp4uQJjRNQokhpMSUIlSqlcFjpQOQKESlYWmTRQuUirS1cumy04qWBlhpUvoARRihMGDFaBoxRUQXMTEUMggodysBPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+shellscript-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRWVFxaXNza3OTi3Nze3Ly2tJyanPz+/Ozq7GxubNzSxMzOzMTGxHRybDQyNLy+vHRydHx6fKSipISChIyKjGxqbERCRCwuLLy6vGRiZExKTCQiJAwKDLSytLy2rJSSlHx+fDw6PKyqrBQWFPTu5Ozm3LyulLS2tCQmJAQCBPTq3Ozi1MSynCwqLAQGBOTazOzizOzezLyqjBweHNzSvOzaxKyurHRuZNzOtLymhDw+PIyCdOzWvOTOpLyidNzKtOTStLyifMTCtMS+rLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAEChYeGg4oCAwQFjgYBBwGKggEECJkICQoIkwADCwwNDY2mDA4Lng8QDhESsLARExQVDhYXGBkWExIaGw8cHR4SCQQfFQ8eFgUgIQEiwiMSBMYfGB4atwEXDyQd0wQlJicPKAHoFyIpJCoeDgMrLC0YKBsX6i4kL+4OMDEyZijr5oLGNxUqUCioEcPGDAwjPNyI6MEDChQjcOSwsUDHgw07RIgI4KCkAgs8cvTw8eOBogAxQtXIASTISiEuBwUYMoRIixYnZggpUgTDywdIkWJIitRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+sound-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXFRWVExSVNze3Ozi1Ly2rJSWlPz+/Gx6dNTS1Ozq7GxubGxqbDRmbDQyNFRiXBy6xFRmZLy6vIyKjERCRAQ+RBy2xByqtHRydIyOjPT29PTy9OTi3ISGhAQ2PATC1ByGlPz6/MS2pAS2xHS2vMTCxJyenLS2tPTq3Ozm3LSmnAQaHARibARudAR2hEySnOTm5MzGvLyulARKTARWXDyCjOzaxAQiJEx+hNza3MzCtOzexOzavLymhBQuNCxqdLy+vKSelOzWvLymfDxOVISipAQCBNzOtOTOpFRybKSejMS6pOTStLyedMS+rAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfLgACCAAEChYeGg4oDBAUEjwYBBwGKggEICQkKCAsMCJOVAw0OA4wIDZsHD4oQERINDRMIFA0MFauCFhcYARkJGhscHRMeuB8RICEQHgcaBCIcBSOrHyTWJSYnKB4KHCkqK6ssLS4vMA0LMRoyKe0zuDQ1LTYoHBwU7Ck374M4NTkmdHDIsKMAjx4+cAn6ASSIAhRCdvDgMYSIQkJFjBzJsALJjSFJLCoSUKCIkiVMegxpksTJxQATnjwZMWMGER9OXI58wLOnzwd+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+source_c-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1LyqlPTm1OzizOzWvLymhGxudGRmdFxedFRWdERKdDQ+dHR2dFxidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBQVFheEVWEYFRkaG40RXw2JGX6MaIiRHGCccQKAkRodHh4fjQ+tICEiIyQkJY0mJg8FJwWzJbVKD7gnI7K+v3EOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_cpp-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHR2bERCROTi3IyKhIyOjPTy7Pz29PTq3Ozm3LyqlPTu5Ozi1LyulPzy7LyqjPTm1OzizOzWvLymhHRydHR2ZHR2XHRyTHRyRHRyPHR2dAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBUWFxiEVWEVGRYaG40RXw0ckV8djYaZFh5gnGgKnx4fICAhjSIPrSMkJCUmJ6woBQ8FJAUlJ7VKDygPD7G9vo0OycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_f-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNGR2ZERCROTi3IyKhIyOjPTy7PTm1LyqlPzy7PTq3LyulLyqjPTu5OzexOzWvLymhHRydHR2bFx2XFx2VFR2TEx2RHR2dFR2VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGo4MJHCq4FuYJBQUdnlEaVZgCgYVFoNVYRcYGBEZjBFfDRePEgkajIUXGxgVYJxoCp+hHBwdHowfIK4PDyEiIyStJSUFDwUmJiS2Sq8PILG+v4wOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMS+rPT29GxubMzOzPz69DQyNMTCtHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1MSynPz27PTm1OzizOzaxOzWvLymhLyifOzexLyedLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaJQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJSCx7WAgBwi52FAsi4oBINJnCpAqCkPChUSA3tEEmoFahUWFxiGSwphGRYaGxyQEn4NHZVfj2iLlR5qoHICGYyWHyAhIpB9Dxp+IYAjsGokaiFqJZAJDwkDHBwYJiW+Sg7LzM0OfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+source_h-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxubPT29IyKjMTCtMzOzDQyNHRydERCROTi3IyChIyOjPzy7Pz27PTu5Ozm3LyulPz29PTq3Ozi1Pz69LymhOzizLyqjPTm1OzWvIyGhIR6dIRubIRmZHxaVHxSTHxCPIRydIReXHxWVHxKRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOl0mFFbEYVEgMJQC8DXRODjOw8DjGhYMIHCq4FuIKBASDwN5RGlWYBMUFRaEVWEXFBgZjEoPXxoSkX4bjYaZGBxgHZ2AkR4cHx+cSiAJCRAhIiMkJSaNCREgBScFKCkqtkq4sLK0JsFxDMrLzAx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_java-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRWVFxaXNza3OTi3Nze3Ly2tJyanPz+/Ozq7GxubFRWXHRydMzOzDQyLIyKjGxqbERCRCwuLHx6dKSinKymnLyyrNza1PTy9Ly2rIyKhDQyNGReXKyejKSWhIx+bJSCdIRuZCQiJISCfGxaPJSKdHxuVHReRHxiVHxeVGRGPKSajMS+tMSynAQCBFxeXGROLFxCLFxCNFw6LGxiXFxiZMTCtOzi1ERGRLSytJSWlERKTNzSxOzaxKymlOTi5JSSjISChBwaFNzGrLyqjKSmpDw+PMS+rOTStLyqlLyifGRmZKyqpLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAEChYeGg4oCAwQFjgYBBwGKggEECJkICQoIk5ULmJoIDA2eDoqXowgPDBAREoIRExQVFhYEBA0XGBkaGwAcHR4dHx4gIRMGDBcEFg4iIyQlJicoISkqISssBC0OLi8lMDAxMiozNDUUNjctEjg5OjklDCEcOy4OFDw9Pg4QfuQAEgTCDglCHAQYMaQHEVRFBhRhIACHAyMLIHg4guShIAg6KDwYMYHBhBVJhiBRgmrQkhxMKlBo0ULlkCYtLbGwYYNmCyJNguYk5KBoUQlGi/oJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_l-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1LyqlPTm1OzizOzWvLymhGxudGRmdFxedFRWdERKdDQ+dHR2dFxidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBQVFheEVWEYFRkaG40RXw2JGX6MaIiRHGCccQKAkRodHh4fjQ+tICEiIyQkJY0mJg8FJwWzJbVKD7gnI7K+v3EOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_moc-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BKSipISChERCBPz+/AQCBMTC/MTCxISC/FxaXDQyNASChARCRPzCxAQC/PzerMRaBPyCBPyqXISCBPwC/MQCxIQChATCxMT+xATCBASCBIQCBARCBPwCBMQCBMTCBCH5BAEAAAAALAAAAAAQABAAAAWOICACQRkI6DCuJOG+JysGL1wIMm0YNHEUBNwqsDMgEL5AIqEYIhZPxqtwUI0CzwRDSih4E6KGeLl1vB4FMAASkTC1icmjmxZBKBXL4YLJaAoPgWoQEBsbGX4JHHR1Ih0eChkTGoqADQ9qMwR+GhwcXlSZAAJzDQNogZeiAUBeaAcNHw2iAygocQkCuQN+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_o-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNGR2ZERCROTi3IyKhIyOjPTy7PTm1LyqlPzy7PTq3LyulLyqjPTu5OzexOzWvLymhHRydHR2bFx2XFx2VFR2TEx2RHR2dFR2VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGo4MJHCq4FuYJBQUdnlEaVZgCgYVFoNVYRcYGBEZjBFfDRePEgkajIUXGxgVYJxoCp+hHBwdHowfIK4PDyEiIyStJSUFDwUmJiS2Sq8PILG+v4wOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_p-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxDQyNPz+/FxaXKSipPz+xPzerISChATCBARCBASCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARVEEgQqrUz3yqGCJlUESRZEFVooWZAfJpbEkU9gNMqo4KBi7vSAfWjyFxIUnEkJAwPy9EugEDFSE+nMzojVKvLREGsKCgWjMVybDaj0eH2OZ2Objb+CAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_pl-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMS+rPT29GxubMzOzPz69DQyNMTCtHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1MSynPz27PTm1OzizOzaxOzWvLymhLyifOzexLyedLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaJQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJSCx7WAgBwi52FAsi4oBINJnCpAqCkPChUSA3tEEmoFahUWFxiGSwphGRYaGxyQEn4NHZVfj2iLlR5qoHICGYyWHyAhIpB9Dxp+IYAjsGokaiFqJZAJDwkDHBwYJiW+Sg7LzM0OfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+source_py-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNza1Nze3Ly2rJyanPz+/Ozq7GxqbPz6/NTSzDQyNKSujIyKhHRydERCRGR2PHyaLLzObIyqNKzCZIymRKy6jPTy7OTi3ISChFx+HISaNKyuPJyaBKTCRKS+VISiVGyKJHSGPLzWdKS+TMzefISCJHRiBGySJJSyNLTGbKzKRHSaHJSWhLyulHSKNJy6RKzCXISWRLTOZJSuVIyuJGyOHHyWLOzaxJSqTGyGJJSmXHySPJS+JHSOHIy2JHR2XLyqlERaHGSGHFRqJHSOJGR+JFxmPNTOxIySbHyORHSWJPTm1ISiHHyiJFRuHMSqjPTu5OzexFx6LMTCtMS+rJyidISqJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfKgACCAAGFhoaDiQECAwMCAgQBBQGJggEDBpkGBwgJk5WXmgYJCAqeC4kFAwysCQYNDggPqIMQERITFBUWFxgEGagaGhsVHB0eH8ggvQQLISIjJCUmJygpKissLRcuCy8wMSMqMhszMzQ1Njc43QA5Njo0Ozw9Pig/LCxAQbRCOkM2iBQxgsLGjyJH+CXKoEABkiRKWCxhQYQBLUsYLhxgwkRJEydPoFwkhCEKRylKbNSYIlIRASpVCFj5UeMKhJaDAizYybPnAj+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_s-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1LyqlPTm1OzizOzWvLymhGxudGRmdFxedFRWdERKdDQ+dHR2dFxidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBQVFheEVWEYFRkaG40RXw2JGX6MaIiRHGCccQKAkRodHh4fjQ+tICEiIyQkJY0mJg8FJwWzJbVKD7gnI7K+v3EOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_y-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxubPT29IyKjMTCtMzOzDQyNHRydERCROTi3IyChIyOjPzy7Pz27PTu5Ozm3LyulPz29PTq3Ozi1Pz69LymhOzizLyqjPTm1OzWvIyGhIR6dIRubIRmZHxaVHxSTHxCPIRydIReXHxWVHxKRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOl0mFFbEYVEgMJQC8DXRODjOw8DjGhYMIHCq4FuIKBASDwN5RGlWYBMUFRaEVWEXFBgZjEoPXxoSkX4bjYaZGBxgHZ2AkR4cHx+cSiAJCRAhIiMkJSaNCREgBScFKCkqtkq4sLK0JsFxDMrLzAx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+tar-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2tJyanPz+/Ozq7GxqbJySbJyadPT29Pz69GxubMzOzDQyNPz21LSujPz25OzmxNTS1IyKhERCRKyqjLy2rKSehPz67Pz23OzerKSaZMzGxPTy7PTqvOzirMy+dKyeTIR2NPTq3LyubLyqVJySPHxyJOzi1LyunPTqzOzW5OzSzNzOrJSGNGxiNLy2pPTm1OzezLyqjJSKZOTStOzOxNzGtOTSjKSSRIR+LGReHLyynOzexLymhOTWlNzOhFxSFHRuRNzKfNTGdHxuLGxeJIyCbMy6pLyifLyqlNS+pOTOpLyedHRydJySfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfLgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICAkICgULDA0LBA6Cnw8QERKgExQHDBWpCBAQFrm4EAkKAhcUqRgRGRqsGxIbHB0eAgOpCRofCw8WICEiIwMkJBDRCwsgICUmIico3CkqtissLS7mJy8wMTIzNKk1Njc4OSI6Xuzg0WOGjx/6gOQIEkTHiB0ohKjwYQOhoCEliBQxcuQIDCRJbNhQkmoQRhgflzAR2cRJSUFPekDpQbMHjR9OXCpywLOnTwd+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+tex-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxDQyNPz+/FxaXAQChKSipPz+xPzerAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARgEEgQqrUz3yqGCJlUESRZEFU4lkQREJ/2skU9BEaezzmRCwccwDCc+XwIFGhI0ZEMxiURxzIQkghp0+qjJlDDHdRnQPSyGu4oEfguRTrs9fqmWAjfPHpSkWMReyIbg34RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+tgz-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBIQChFxaXMQCxNze3Ly2tJyanPzC/Pz+/OTi3GxubJySbJyWbPT29MzOzPz69DQyNPz21LSujPz67OzmxJyadNTS1IyKjGxqbERCRKyqjLymhLy2rIyKhKSehPz23Pz+9OTevOzmtKSaZMzGxPTu5PTqzMy+dKyeTIR2NPTq3LyulOzirLyubLyqVJySPHxyJOzi1OzW5OzOxNzOrJSGNHRmJOzezJSKZOTSjGReHLyunOzaxOTWlNzOhKSSRIR+LFxSFLyynOzWvHRuRNzKfNTGdGxeJGxiNIyCbMy6pNS+pNzSrAQCBHRydLSunMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfYgACCAQKFhoaCiQOEBI2NBQIGAooHjAiXCAkKCJIAAZ8BCwsMCw2XCg4PBhCCohESExQVCxYXChgZrAsSvBIaGxIbDA0JHB2sHh8gHx8SISIiIyQlBBysFR8mzBIiJygpBSUqK9cPEywiLS4oLzAFKjHkAAwmMjM06y81NgUmNxuscNCYQSIHuxopdOy4wQMgABw9cvjw8SMFEBhBhPAY4hAAkRZFjKQ4cgRJEiWgAiTy2AKJSSFLmAQ4MKDJSidPFggRAmXFhgADNthMJACC0aMQAjRZ6icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+txt-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVPzKjMR6RNze3Ly2tJyanPyODPz+/Ozq7GxqbPyKBPyGDPzGjPT29HRydMzOzDQuJOx6BPyGBPyKDOTWzIyKjERGRDQyNKROBOR2BOzezIyKhBwOBKRKBNSOXOza1CQOBPyCDOySZPzizPTWxPTy7Pz69Pz29PTq3LyqlMxmJNRyROy2lPTu5OTi3MSulFxGNIRWLMR+XPTKrOzStPTm3IRSNOzizOzavLymhLSyrEw6LKRuVIx6ZNzSvOzexNzWxNzW1FROTBwaFKSShOzWvOTOpOTazJyWjHRqXNzKrOTStLyifMS+vMS+rMS6pLymfLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfOgACCAAGFhoaDAgOCAQSOjgUBBgGCB4qEBAiaCAkKCJMACwwNA42bCA4PEA4GERITFKQVpwgWDwoXGBkaE6MDG6cOBAUcGB0eGgsTDR8gmw4OGwURACHIIiMkJSYIJygpKSoYgtYrLC0kLdAuKS8w1IIdMTIzNDUbLjYpG+KDABcRbtRrYWMDjhw6xg0KsCMAjx4+fmwAEiShvwBCChgYQqSIkRpHdMBjZCIFkh1JlCxhcqSJQkZOnjyBAgOGjihSpLwkhAFDBJ9Ae0bwEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+unknown-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXIyKjNTW1Nze3LS2tJyanER2RGS+VPz+/PTu5GxqbPz69BQ6BCxeLFSqRPT29HRydMzOzDQyNERmPKSypCRWHIyKhERCRDyGPKz2nESiLBxGHCyCHGxubPz6/PTy7Ozi1Ly2rKSipOzm3LyqlKSWhCRyFOzizLymhNTKtNzOvOzaxOTStPz27OzWvOTOpLSupLyedMS+rMS6pMSulLyqjLymfLyifAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAamQIAQECgajcOkYEBoDgoBQyAJOCCuiENCsWBIh9aGw9F4HCARiXciRDQoBUnlYRlcIgsMG5CxXAgMGhscBRAEBRd7AB0eBBoIgxUfICEiikSPgyMMIAokJZcBkBybJgomIaBJAZoMpyCmqkMBFCcVCrgKKAwpoSorKqchKCwtvasIFBIhLiYvLzDHsxQNMcMKLDAwMqEz3jQ1NTY3ONyrE+jp6hN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+vcalendar-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/ISChAQChKSipAQC/Pz+xPzerPyqXMRaBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARyEEgQahVijMmD/oRAbBw1FCgaFFrpEbB6jt1g3OpFAscxwATUiIAgBRKJXiqIYJEMBQNSWSAYgptrMDo9FJqKrHArTR4WLGisSkbebE12gXFFGRBFyd3eaFSvbx1xCDBXC2E1e1EECo07ABkaBh4fGn4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+vcard-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/ISChKSipISC/ERCBMTC/Pz+xPzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARvEEgQahVijMmD/oRAbBw1FCgaFFrppeo5drKhXqQUEIfREyweqWIoHo4GDYtkGxwQ0CjitEkUrCyfYjtdbJoFW/agmLJWWZSY3B0EbGJ4uAwcHlK2HpTg7YgHBgQjDH0THoGBCwULjDkAGR+RH34RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+video-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaTFxaXIxuHJyCLHx6ZLy6vJSSlNze3Ly2rMy2RNS+TKyqrMzKzPz+/Ozq7GxubJyanLSePKySNKSSPNTS1JSWlDQyNMSqPLSmVNzKZJyenIyKjHRydGxqbERCROTWXNS6XOzidNzOZPT29MS6rISChLSulMy2TLyeNKSOPJyCPOTi3JSSfHxiFGxaJFxWLFROLPTu5Ozm3ISCdDw2BFRKHHxqPFxWPLymTMzCvPTq3OzezKSWTMzCbNzGZExKNHx6dLyqjMy6XMSqTMSmTEQ+JHRybMSynISCbMyyVOTWbLy2ZBQWFGxqZOzifDw6LCwiDISCZJR6LIRqJBwWDExKRHRuXHxmJGxeJFxSHCQiFFRGFGRSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfhgACCAAECAoWHhoMDBAUGBwiRkQkCBwGCCgsLBQwNDp8ODxAOEQIAChITFJwVoA4QnhYXEhgZBRoFG62fHB0eHxcgIQUiIyO5uyQIJSYXJwUoKSoUKwEWniQkLCUXHy0DLi8vMDEfBw0kMjMnFwAfNDU2Nzc4OTgmOjs87ILvEj04NPj4ASRICR5C2vVrEWAIEQwSihg5giThIHdJiCgJMWIJkyZOLA4K8CHJkycimEAJEcWJQkECEHyQEqIHFAJTqFSxcjGAjhIfrlzAkkWLDS1bel5Y+mELly5YCEyQ4CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wordprocessing-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxWTNze3Ly2rJyanPz+/Ozq7GxqbHR2dHRydGRmZERGRMzOzCwqLJyWjOzi1Oze1PTm1PTm3IyKjDQyNERCPPTy7HRmXCwqJPT29DQ2NNTGnOzm3PTq3CQqJMS2hDQuLKyaXCQmHBwaHKyahLSijKyehBQaFCQiHHRqNPTu5LyulCwuLHxyNAQGBBQSFERCRBweHOzezIyCVJSSfOzavLyqjOzexOzWvLymhExGJEQ+JExCJExGLCwqHOTOpDw6POTStLyifMTCtMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAECAwIChYeDjAIEj48FAgYBjIIBBAeaBwgJBwYDjAoLDIkNmgsOnw+CEBESExQSEgsHFQsJDRYAFxWbmhgZGhsEBRUcHQ8cEB4fzhAWICEYxSIjJCUDJicnKBkpKissFC0uLwAwMDEyFzHpDxgfES27DyozMyX6+TMTEzQtWJWoIYGgQRsl/t3AsStFQRoGIYrIkUPHDhcANPDo0cMHxx9AUtzQEWQHKwAcSDy4IAQbh5FDghDZNShAkZsFjBzBgaQnh0YcHojgIMIFBwtBXfgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1downarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBBQSFAQGBDQyNExKTHx6fGxqbFxeXGRiZFRWVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFxaXDw6PPz+/MTCxLS2tIyKjKSmpKSipJyanAwODDQ2NHRydERCRFRSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZzQIBwSCwaj8ikcslsOp/OgHRKlQoCgymRUDAcEIkwYgxWFBYERpHQcDwgEclEQmk8DhWL2kiIXDBwExMNGRoJaUkEEH8bEQ0cGgcWAksEHX8QHBKSHk1sfxMHH5ROBBsOICGkT2wiq1CIULKztLW2t0h2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1leftarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ5QIBwSCwaj8ikchgQLJGBgfNZDBAKBirRekBMtYGEYsHIgsWNhOO7tCrShDU18Hg/CJAIG0o4wCUQcksTFBUSCRYSEnpUFxgIGQkJGYyNGggbHBaVjR2QCxEeWkITHQ4IH3tPFwEMA2ajAKUgqlQTTbFEE7W5vUgGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1rightarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNGReZAQCBMTCxGRiZMzGzOTm5LSytPTy9Pz+/CwqLOTi5Ly6vCwmLMzKzJyanJSSlBQWFKymrIyGjCQeJJyWnISChISGhHx2fKyurDw6PAwODHx6fHRydDw2PERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ2QIBwSCwaj8hkMRBQKgOCgRMZIBSk06XhEM0SA4iE4uoVLhCMhqLrdSAekMgYO5VM4BQ521mxIC4UFxBWdEkSERYYFxETGQGFSBKCGBEaGRuQSBwdeZaPXpsQCB6YZQMdEI6ZSgMepKusHh+wrCC0rLdlursGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1uparrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBFxeXDw+PMTGxHRudPz+/JSSlLSytIyKjHR2dISChIyGjIyOjLSutLy6vKSepJyanISGhJSOlOzm7Ozu7MzGzKyurJyenDQyNGReZKSmpIR+hCwuLCQiJBwaHBQSFAwKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZtQIBwSCwaj8ikcslsOp9QYyAQFQYEAyr0Sihkn1fDAeHVLsOJNELxVaITC0bDUU6GH5AIQ8KYrNtFVxQVFBYWFxgRCREYdUQZGhYEDwgIGxAHCQocCgWOQhmhGR0epR8gqCFTq1Wtrq+wsUt0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2downarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAQGBBwaHDQyNExKTHx6fGxqbFxeXGRiZFRSVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFRWVDw6PPz+/MTCxLS2tGRmZDQ2NAwODJyanKSmpKSipIyKjHRydBQSFERCRExOTFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAasQIBwSCwah4FkQKBsDpoBIqFgOCASCYRWm1AUFgRGkdBwPCARiWRCaTwOFYvYSIhcMOiJpJGZaDYcR0IEHXceEQ0fICEWIoJDhHcQHxIHgI9SEHeVG46YUh8OISOen1INCqWmUnOYTUxQAU9NUlRWWFtbCiRgrYNlZ2lriG8lYUd1khETE24gCZeCkRgeFBAQIAeNn9OTlXKrBJoYnKrcoaPmpmSpq3S+7u50QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2leftarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAavQIBwSCwaj8gkMiBYNpeDZzEQXRIKBmPgmtUSDgipcAsWjxOKBaN7Tq+n6EbCIQ3E5+KtQk6gjwl7CX11D3sPBBARTQGFDYeJT2R8EhB0koKUfgATFBUSCRYSEoqcnqCiikMXGAgZCQkZqautr7FiFxoIGxwWqQC4ury+qh2tCxEexMbIRhMdDggfYs7Q0kcXAQwDbELY2txEziBmmx3jSRNMR+nk4e2b70ry80QGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2rightarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTGxOzm7CwqLLy2vPTy9Pz+/Ly6vCQiJLSytLS2tLSutOTi5MzGzKSepIyKjJSOlKSmpMzKzJyanIyOjBwaHIyGjISGhJSSlISChBQSFJyenIR+hGxubDw+PHRydHR2dEQ+RHx6fERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8hkIIBcJgEBweAYnTYJUmMAa9USClniFtwlGg6IRFhoUKTXwwWj0FB3F46Hwl6UQyISfAB+EROCQgsUFRYSF3yJEIyBaxgWDBkaGRtclQwSHBIbEGEdGx4fGhcOICEDGBsWHBmqIq1CHRIWGRMMIyRTHRy6Er22tyONq8YdJRe0xkIDwr2/QwMfliMmZQADIxasZd4e4UYDIr7c59rc0eVFA+/m0EQD9PDt0flP/P3+BkEAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+2uparrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBGReZDQyNMTCxHx6fPz+/JyWnKyurHx2fDw6PJSSlISGhIyKjIyGjISChLy6vJyanOTm5PTy9OTi5MzKzLSytKSepMTGxMzGzLS2tLSutKymrHRydCQiJCwmLBwWHAwODLy2vHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAajQIBwSCwaj8RAAMkUBgSDZdP4JBSi06TAcEAkFNLp07BgLLzY5njRcDzO3zB1C4lEGI83Wj58SiYUFRUWdg0XEXFFAwIYGRoWGxwRZQUFHZdgRAObmx4fHiChISFKpVlKWUdPaalOAlasp1sHG4myZGZ7Yltsbgu1mUhjdRF5egmxfQJ/gYOFdrZDi40iFgiSCw8jBQmYcpydn6Ego6WorUwGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+abs-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJLhI+pF+vW4HMR1InqxbJzBiLCeIxCaIkneQJk6rkl+2qlONzeNi+2YvKhEIOW4iczvJSoSDDIbCpbq2oGBXUtd59r7IPshsHdB70AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+airbrush-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/AQCBPyChMwCBIQCBPz+/MzKzKyqrISChDQyNPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAR8EMhJKw3BahvEyNvWDV+ojQMBAhgmeukaFHSxTqh6FYZx3CyYbtf7XYRAFs8nQ56WxiBpyOEdjLkkrnA9IAKGqXbnTYAP1NDMe0Z8JYR4nPP1seEqTHpWZMupVHx2by03Q4JXbxuBfYoaaVZ3i4YKbo4WaQAKBCxjcEAGEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appearance-22:actions actions22 22:photo:22 22:R0lGODlhFwAWAIYAAPz+BAQCBBweHPTy7Ozq5ExKRPTu5NzStLy2lCQmJAQGBOTezNTKrLyylNTKpOzm3NzWvOzm1MTCpNzaxISuvBSGvLy+pKSehOTexISutKTa7IzS7GSarJTW9HTK7CyazBRypMzGpDw2LOTaxEyKpCSSxARGbERCROTizMS6nDx2jARajIR+bOzi1OTi1MzCnLy6lOSupNx6dGS2rJS6pMy+pOS2pNxGTKwaLDSmpHTOzES2tIyuhLSmjPyqrMw6RLSOhLzSrGyqbFSmXJSyhNTOtGTCvLzm5CyOjEQ+NPRqbOxOVKyKfMzizKzepFyuZJSqlBR6fCRmZJSKdDw6NLxqZLQiNIwyNLSejDSCRJzWnEyiVHySbBRiZDQyJMSijGS6ZHSCZJyafDRmPISKbJyifDw6LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAXABYAAAf/gACCg4SFhoYBAgGHjIQBAwQEBYwBlYiQAwYGi4UBBwcInIIJA6WRBAqdCwcMDA2pggEEDpUODwSiAAEQnwwHnI8RwBIGsLoLExQVFg4XiwEPD6IKGBjAExkaGxUcocfSgwHV1uITFR0eHyAhIroRERLAC/PVIxMkJSUgJvHH1RAKTixAgQzZhAkpVKwwwYKWrgnzFrRY4IIgBoMTRryQAGPjs4zzYsgYQdIgsgMzaNRw0CCBLgn2bNzAceMgSZITcujYwaNGj2sjcPjw8QNIECFDiEgoYuSIDiQOkoSTMAGHkiU4mAhp4uQJDyhRjOSQMiUXFQdVrOC4giWLFidbRri8QBKlyxQviIp8udKjRhYwYLKEedFAjJgvucI5cFBEgoMxkMm82PjFmCERix1wLCNmcg8viRGZ6aHZcQ8zoRtVWp16UCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+attach-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTCxPz+/DQyNKSipAQCBISChFxaXDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARrEMgJgqA4zzus/gLhFd5HCcZAXqsphYPUdhcYFNRcZnvdtpnDqPTbUWgAJKBYwzBlw+bRo3xmkNWoBgm0OrVLn3GC9RgCk8DhUw7c0rHPr4CDu5SYQNyEt7uSY3p/UAKFhYKDSQOLiwgFdhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+back-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XAQCBDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihAQKFCTO3BS+1AyixBSWvBSOtBSStAQWJBSixDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdCH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMqBcMpvHgGAANQYIhWdVGDAcENQtIJBQLBgNx0MQaDuQXcghIplQDhBIxXKJYiAZGhscHR4VHyAhIiNWJBklGhIbJoQnFCcTKIxFKSgbKissJi0mJi4vLiYoMEcXKDEyMzQ1Nje2NisoOEg4KDU5K6g6OwwoKAN9SCOeMmgwz884PEq9PT4NYkPLP9jZQikN3d4AKVrjKePp3gZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+blend-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQmJAQyNAQ6PARGRARSVARmZARubARuXARmTARiPAReLARaHARKBAROBAQCBERydESChESOjESanESmpESytES+vETKzETKtETCpES+lES2fESybESqXESiRAQ+PARiZARybASGhASWlASmpAS6tASynASqhASiZASaTASSNASKHAR+BARiBARydAR+fAS2tARKTDRaXARaXASOjASKdASCZAR+TAR2PARuJARqFAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa3QIBwSCwaj8ikcslcBp6CAaFQMBwOiIRiwWg4HA9hAAKJSCaUiuVywWQ0G07H4wkDxp8CKCQakUolJicoKSorLC12eHouL34lMIKEhoiKEFMgLn0kMIGDhSyVYhADjJuAkoWHiaMEMXuOnJ6Tq5alBpp+nSeflKx3l6a6s6CiwKWZm52pvpaue8rEzaPIubLMta2Mscu9ob8BMgIfBDPJNDQ1Njc4OTotDXYP8/T19vZN+fr7SXRBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+bookmark_add-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCwqLCQiJCQmJMTGxAQCBLy+vLSytERGRFRWVKyurKyqrLS2tKSmpHR2dJSWlKSipISGhGxubIyOjGxqbIyKjFxaXGRmZHx+fPz+NGRiZPz+ZPz+HMTCBKSiHPz+jFxeXPz+XPz+tPz+zPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAamQIBwSCwaj4Gj0hgQLJ+AAaEAVQoI06pRYDhkoYgwIhEgKBTfZ2FhaBsYDS8VWnA8Go0FJIKeqyUTDw8EDHBpSwUUFQ4UFhcYDQYFfkoFFxEQDG8KEAUZlEeWGBIakw4FG1STiBoYBRwdBR4fHgUdHKBEBSCnIR8iIyIfIblFu6ceIyQjtcXGCbLKzAUKzrq+wMLEVa+xs7W31kOTk6nkWuOf6Ea5QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+bookmark-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBCQmJCwqLMTGxAQCBBwaHMTCxLSytERGRFRWVLy+vKyqrKSmpHR2dJSSlJyanISGhGxubIyOjKyurGxqbFxeXGRmZHx+fKSipLy6vGRiZLS2tFRSVHRydJSWlHx6fCH5BAEAAAAALAAAAAAWABYAAAWWICCOZGmewamaQrq+wUC8azHINGocOI38iIRAceDNaISFYklkGHOEhoNBfUAOhuOLEJE8HoPiRKFdESiQBqViuTDIUAsEcyAeGJmyiqC5RCwJGg0YcEh9D0V3Dxt6JwQVDRYVHBUdi40mjw0PTgwQHgeYJQQJfxUXFxAOoTkFpQ0fsRSimQkWEQ0VtI62HLt7vjl7JQYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_all-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI+hI+pyw0Bo5wR0TttUJDv0yWhRopfaYzguaKt6aasrGFYbVPxM/O7Snv9WEAfTIgMKpNGWU63emYc1GrVUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_bottom-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIyhI+pyw3xIpwyOgOv1dvl+2lhMzIlyZ1KQLUVm8Zch4ozbcq6l7L+D4QhgsTf7Xi0FwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_fall-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI/hI+pyw3xIpwypgBRdg/v9h2eyBnZCIKYxX2oEsJruVKjHS8vk3duKZnpHKjeRSTU0HYpTcxWgRqB1KrVYC8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_horizontal-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIyhI+pyw3xIpwyOgOv1dvl+2lhMzIlyZ1KwLbuyybw7KY216Einpv377FRhhUV78igFwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_inside-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI7hI+pyw3xIgxTRvcg1oku3njbBx4liV3dqYbsSsXyLBr0Pad1iCovsmOwgjbdz9TrGHWWSeWZikoXhgIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_left-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI6hI+pyw0Rnox0ygNXdG9z43Xal30gUiYhk5LoenJQRVtti5FwE+Kx4+O9RrIda6gwDmvMi+kJjTIMBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_outline-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI8hI+pyw0Bo5ww0SttcKci/ymgMTZl+Yjbt3Jn26lautX0A+OizHJkjsrper7XbkZ0ATEYDZPii0qnU3sBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_remove-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIthI+pyw3xIpwyOgOv1dvl+2lhMzIlyZ1KQLUVm8Zch4ozbcq6F7s+fgsKb4YCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_right-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI7hI+pyw3xIpzyQRdVuIZj+3nHhogOiZng+I1qoqIdRVfbWy5y1u5M7MFphB1dsDULGXO15goJjUoRhgIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_top-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIyhI+pyw0Bo5ww0SvdCdrw7oGfNnZlczIpKorc+8RwZbZgXOc2uevOqpjJhrCb8QgwFAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_up-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI/hI+pyw3xIpwyOgNRyPq+zTkcuIQKaV3T1pgHinmfm7AUedMa64Vw3bLJMr9TiZcSFUsnkw54q0Rl1KrVYSgAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_vertical-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI6hI+pyw3xIgxTRvcg1oku3njbBx4liV3dqYbsalFeJTp1iCovcjNsb9iZhMFcJwXUxTJLYuoJjR7sBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+bottom-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaXQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHvArR0tPSSNTX1V/a20J2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+brace-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJRhI+pGbHYVHzQnUnrtXn7/gEYIJRHKRgYZraGuXLp28LcNL/Dqd4cYmJYRqegsKcY5DRIUhHYFDlQJGMuVn1ljdhqjhoiZrogKbMjFh/LHUMBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+brackets-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJRhI+pyw0Bg3vxwImu0Zha2XkbaAjmYQrjh6qnCpwcB8evTGp1PKDrnzglZqTWDsg5DI5IUE1Yatpc0BrRFr2xfiljJlecXEPjDjG5iIRDCHsBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+centrejust-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIhhI+py+1vgpy0TogztlT7j3CiBJbZWJlqg4rry7jw/BoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+charset-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBAQCBAQGBFxaXAwKDBQWFAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANLCLrc/jDKuQK1zmKo3/YVJSpBSZYmKaTkAAwYoQwFELjvpisyaTM7H6AH+3lQMZQwExrOOiBh7/cJGokaXHGpQVaUo7B4TC6bw4AEACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+colorize-22:actions actions22 22:photo:22 22:R0lGODlhFwAWAIYAAPz+BAQCBBweHPTy7Ozq5ExKRPTu5NzStLy2lCQmJAQGBOTezNTKrLyylNTKpOzm3NzWvOzm1MTCpNzaxISuvBSGvLy+pKSehOTexISutKTa7IzS7GSarJTW9HTK7CyazBRypMzGpDw2LOTaxEyKpCSSxARGbERCROTizMS6nDx2jARajIR+bOzi1OTi1MzCnLy6lOSupNx6dGS2rJS6pMy+pOS2pNxGTKwaLDSmpHTOzES2tIyuhLSmjPyqrMw6RLSOhLzSrGyqbFSmXJSyhNTOtGTCvLzm5CyOjEQ+NPRqbOxOVKyKfMzizKzepFyuZJSqlBR6fCRmZJSKdDw6NLxqZLQiNIwyNLSejDSCRJzWnEyiVHySbBRiZDQyJMSijGS6ZHSCZJyafDRmPISKbJyifDw6LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAXABYAAAf/gACCg4SFhoYBAgGHjIQBAwQEBYwBlYiQAwYGi4UBBwcInIIJA6WRBAqdCwcMDA2pggEEDpUODwSiAAEQnwwHnI8RwBIGsLoLExQVFg4XiwEPD6IKGBjAExkaGxUcocfSgwHV1uITFR0eHyAhIroRERLAC/PVIxMkJSUgJvHH1RAKTixAgQzZhAkpVKwwwYKWrgnzFrRY4IIgBoMTRryQAGPjs4zzYsgYQdIgsgMzaNRw0CCBLgn2bNzAceMgSZITcujYwaNGj2sjcPjw8QNIECFDiEgoYuSIDiQOkoSTMAGHkiU4mAhp4uQJDyhRjOSQMiUXFQdVrOC4giWLFidbRri8QBKlyxQviIp8udKjRhYwYLKEedFAjJgvucI5cFBEgoMxkMm82PjFmCERix1wLCNmcg8viRGZ6aHZcQ8zoRtVWp16UCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+colorpicker-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBMT+xASaBASyBASCBARCBPz+/KyqrISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARZEMhJ6wzBahvEyNvWEcMXcgJBFuApjavRhlgaz6J9u5dQDAUZ73VA+FhDQOAQQCQEQt6ymcjgREznlZatJpXdLZYq1ky137M3qS5zwl8lOR5IIDBx5TpviAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+configure-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBISChFxaXNze3NTS1Ly6vKSipNTO1Ly2vNza3Pz+/MzOzOTe5DQyNOzu7MTCxGRmZMTGxPTy9Ozm7Hx6fPTu9MzGzGxmbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAW1ICCOZGmeaEoGbBsI6joMRGEcbQwESDIrtVtAF1gwDLNaAmfKiVgLBJKgwB1KxQZrBHU0FAXmavFoQLYiB6TxFXMj5AZBwnJI2I3wcNWALyYEcgoKXxRhOHs7XxEVCwsWFgoUDRYUFwwQB25ZCxiNjo6GkwUXN2NsCxEYqhUHoQ0MEglYRQQXErcHrI55FycuB2YSmoyOBTEtB2sXuhU6XAENC2a6z9AKCwq+1tAN3E2J3ySkIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connect_creating-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxOTi5AQGBNze3Ly6vISChNza3FxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAAR4EMhJqwzY6omD+MNGdR8YilNZnug0qGzrqrL1lnV1fyJBVB6VQEMoGH4ADGwQkxQPBwMiKGA2J8VEAnq0tgiKg5aL/C7C2gTjKCM0zowDQ8tuNQznNL7cKzjOUQsNfER+gguIg19+Pm6ChBZFDmWNi5M5FIyYFHQRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connect_established-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBKyirPz+/KymrOTi5KSipMzCzNza3OTe5Ozi7MzGzPTq9OTm5ISChMS+xFxaXNze3GReZIyCjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWLICCOZGmeaBkAQpoGg7C6JizTQT7CxPwOwFWgYPChYIXkIHC4uQKGAiKRKCyNpxxUUVViVYNFLkqtLo+DAkMMLXQPXwAy2WCTF4544FGtKuwPDhB6DnxuUmyCcXIQhV1uYoMuEAcOBxEKCHg6TzGFCJUSizuejROKOAM9OY2SnUU7nD89NCcDsLUnIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connect_no-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBERCBAQCBPz+/MTCxOTi5Nze3OTm5Ly6vNza3ISChFxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAARiEMhJq7046827/+AVCKE0Dh9BAGdaGISAToFGFMcBU+11I4hDYseSZQiKwwKoI/QwBIYiuFDCZseGdIlYEjUNg1SpY6w2N4cUIW6cjwW1lsFwo+MqgtZuw0/ydw5vH34lBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contents2-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBDyGhCyCfFSWlESOjDyKjDSGhCx+fGSinGSenFyanEySjHSqpHSqrGympEySlBx2dISytHyyrCR6dKTGxHyurHSurHyytGSipCR6fARmZFSalEyWlBRubAxubBRydDyKhDSChLSytPz+/MzKzIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbFQIBwSCwaj8ikMhBQIpmCQdM5ZBIKhgNiugwkFAsCI7pNMhuOxkNBgBgEiAi3GkBLJpJHYgEpaClyREwVFhcSEhgOGQoMfgMaERtcARQBFRMYExZ6HB0FUYAekkIBHxqWFmlrC1haESAfG6MBGx+VFRgKYH0hInGRklO0ppYXCwwMWQiQHkwjgrWnFRdYZHIBJCTP0LaWGAcDW9jZ2nMAw9IWTOQkJSZMRsOV49nu8E+19PbmR7TY+1TovONH5V7Ag0QMBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contents-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBHSurIS2tBx2dBweHPz+/Ozm1GxiTGyqpPz6/Pz69GSqpOzaxPzy5HxuVLSmlOTazPz27PT29NzClPTexHxuXLSmjAxqbFSinPTy9KyehNy+lPTy5Pz29HxyXNzWxKSahOzexPzy7IR2ZOTWtESenPTy7KSWfIyCbKyijAQGBDyalPTu3KSSdDSOjJyOdCSGhPzu3OzizJSGdPTq1PTq3JySdMy6lAyKhOzWtOzi1OTOrJyKbMS2nJySfMS+rAwCBNzOrNTCpNzKpJSGZKyafLSifLyylIx+ZHx6ZDSChAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IAAQFjI6EAAaJkQeTjwAICYkKBQcLm5WdBwyfhgChB66bp64HCQC1lQ2irqQCAA4PowsLEBESE4wAuLIHFAAVFr+uDBcYxRm1GrmuGxwdFh4Mrh8gGCET1gDYyhsiFSMkDAsMDCUYJhvnJ9kHKCnODwwfPlBQsULCPRYAWogK9sHFiwoOPEyQh0JFPXO1YBSYwBEFghjdHkwQOYGgwQwIZRR44GHGDBogabhAsYEEihrUMAIoUMCEDRs3HODIYQHFA6MPcJA7KICFjgw7eIzo4cOfiwc/gKwIUm2SkKdDdlDt4AABDaU/iIRwwbTSUyJFOow4S3Hkx9oNDDZgXPU0h1wcSIgEGUw4ibVET5WoWMKksePHpdxmyKADAEIWly9HJtQkQJMmlAgZCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contexthelp-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBAQChAAAACH5BAEAAAAALAAAAAAWABYAAAJQhI8Qy5F/ghBsLuOgpHHy+0hZ94HINiqWwoQrtjYpNqJ0A8Hcjbs73yPNZEHVDygTJohJWqiZe0JPM5ajtXxFMkXnklqNgsPiWzmHPatzhgIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+crop-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBMT+xASyBASCBASaBISChMTCxPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARUEMhJq704681r+EFHBcIwEKFImmfKkURhoh1cyO0rxEWZa7bezIUJ7gg04O62A22MyeeyF1XymrUSs5pZmbA61u+FLBOBhrThozq4D2cgYo6IawwRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+decrypted-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBGxqbFxaXExOTEQ+RAQCBPz+/PTy9Ozq7Nza3NTS1KSipFRSVOTi5Hx2fJSSlKyqrJyenJyWnDw6PMzKzKyurDQyNFxWXMTCxJyanHRuLHxuLGReJFxSLFROJFxWJExCHERCHBQODISChHxyLHRqNIRyNHRmLLSqbKyiZLy6fOTarPz67Pzy3OzitKymZFxSJJySTNTSnPTy3NzSpMTChLSydKyqbKSaXJySVIyGRGReLPz23NTOnMzCjHxuPLy2vKSmpOTe5LS2tLSutHxuNHRuPMS+xFxWLIR+RDw2HFRKJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SDAQIDBAUChY2EAQYHCAkKCwyOjZANDgIEAQoPjJiDAg2iggQQp5gMBwmrDBESl6MTFKuoFQSjABYRF40CGAW8BRm7hQwNxBobHB0eHx4gISIjBdiEAhYFJBslHOHSHh4hBSHlxIUmJygpKissBiwtLi8pGjDqhBoxMjMuaNSwcSMFjhw6dnjYRyrGCh4ueviw4Q5HDB0/PjAUJCBCAwMIGiiggAEIBFk/FgYLIgRkggQkhxAJkqGExkYMFnxsIGRkSQgLHhRRWUjAggQgG8AsSWRBBiP6VrYMOfKIyaBDNwLo+HHSUplOSyDRqiEHjRkretRQkcLgxayNF0wksQGQxsSKMTIq0QpgCba/gAE7whEIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+down-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaRQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHVQrMX9PU1Uh0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editclear-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAWABYAAAJBhI+py+0PYZi0WnqC2Lx7HhjaR3YhMArBUHpnuramCLLy9tY3TuP2nfPtVD3VTxY0DpNDHqo5E12mlYj1is1e7QUAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxaXMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyylPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbYQIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBscAY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4gKIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATyVoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editcut-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkcpkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editdelete-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzKxIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwCBMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyynOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMNEqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqzkBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0SF+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsygsVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDYCKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBISGhISChHx+fHx6fHR2dGxqbGxubGRmZGRiZFxeXFxaXFRSVIxSLPyuXMzKzMzKxMTCtExOTPzqrPz+/NTS1MS+tOSaVPyWNPz6/IxeNPzavPyKBNTW1PyCBPyGBJxmNPzOpLx6PNRqBMSCRNySTPyCDPSGBMxiBKROBHRydPSylOyydMxmBJxKBAwODPS2lPTq3OyabJxGBPTy5PTGrOyOXPR+DPz69PzmzPzevNxuPORqLMReFPzy7MyCXKxiNIRKHBQWFNTOxPzixJRaPFxONHRqVPz27PTy7PzStCwqJDQyLJSGdIx6ZPz29PTu5HRmTLSKbMSGZHROPFxKPJSKfJyShKyehMyuhDQmHEQuJJyOfLSijMSynMS6pLSefDQyNHx2bKSahLyqhLymhOzi1FRGNIR+bNzKtOTOtOTKrOTKpLyedAQCBFRWVPTq5NzOvLyunLSmlNTCrOTOrNzGrLyidMS+rLyynKyijLymjLyqjAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gAAAAQECAwQFBQYHBggJCgsLDAwADQ6CAQ8QD5ydEJ+gERKWE4ICDxSpqhWqqhYNFxMYphCtqaytGRoXGxgcggSoth25u70eH8APFR0VzMzNziAXIRjIvwAFwq3EqSLUGB/iI4LathS4JCXVJh8nKCmCKrXDFCss1eIfLS4v8ssdmgWsAGNDDBnt3s3wJ+jAtlUhaNSwccNEi4WCBBl4SAHHihw6ZOzg0QNjRgAG6KXK4CNEjBU/gDQI8kLISQAIADobAoMIzCINjLw4YvNkAno4kCRRUuNHESNLmDRxUjSjAlRPfECJImUKlSpMrFzBIqWqoKtJaWSJomULAy5XXrp4+QKGYcYFoCBEWRImi5gmY7CQyVLGriAGD2jEMHMmCxc0Xb6kUbOGTRs3N988gLM4jpw5Y+iwqcOGjZ07mE8yiGABz5c8c/Ts4cOnDJkybS7fdMO7t+/fvDMaCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6/NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz27Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTStNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4FDxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wrLS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCNDiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LAQOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpgweLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBFRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanOze1Pz+/Ozu7BQSFCwqLDw+POTi5MzKxPTu7LyyrIR+fCQmJPz6/Pz69Pzy7Pz29OzaxPTu5PTq3PTm3My6pPzu5PTq5NS+rPTm1PTi1PTezOzWxPz27MyynOzSvMyulOzOtOzKrMymhOzGpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbpQIAwIBgMCAXDAZFQLBbCqJTRqFobjgdkEYFKowPJZEyeUBqVR/crHDTKZYplovZKCW84+YKZZNZSBXl6EwEEBhVPXxZihGMaGRscdkIdg4QeEnVfCH2OHyAhIhuUAAiXZSEhIyQlJqWnjiEnKCWupRWoYyEgJK0SKaUKjam0JCorLMFfC6iqx8giLa/MGAsT1wsuCyULKwssC9RSzdkfCyALKuALLQsvpeXYIQso3gsiCzALMfENC+dGcMNHUAY/f+jq3ctncMYCGggFrsvHcEGNh/EyPFmg8cmrJxAVkVO0EUDJklHoBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+edittrash-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBERGRExOTDQyNISChBQSFCQiJCwuLPT29Nze3GxqbDw6PGxubHR2dJyanLSytJSWlJSSlOzq7Pz6/Nza3Ly6vFRWVBQWFIyKjMTCxHx6fIyOjLS2tOTi5PTy9OTm5Hx+fNTW1KyurKSmpJyenExKTMzKzKSipFxeXCwqLMzOzKyqrMTGxLy+vHRydBwaHNTS1DQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb8QIBwSCwaj8KAMoA8LgUDQsFwQByay4RiwWg4GA9IRGk0SCYJSsUCsVwwGQ1EsmESD5xOp+L5gDwhBRIZDhcDdkMGDgEiIxAkJQ8Ok5MmAohDAQ1xJxUlKCUlEg0pKpiZJRoLCxmtCw1eURhOcR4rbQ8cGRwLAwgGtBYTDywtGRKjvQTARgEZLhMcKC0OrQMvAirMRc7CHCTU1g2+20TO0NIn1RwDCya/wdHT1Rnt5LToKOq79trx0tR02YPX7Jm8fRxMOIhSLhOJE/LCJSTlr5kFEBQsWDiR4UGGBgsuHDg1BEYAfTE6oEBR4AIBAiS5yWBAAAGBAyaPGAgCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+encrypted-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiEsgQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+eraser-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTC/AQChAQCBISC/PzCxPz+/MQCBIQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARfEMhJKwhi2F0DIRnHeR+oiRRZmqikrmD7wgI6r+EI4+d2l7lNwWDYsTiFw4FI61mSymXxE3xGo8xqBXpVGrQUbveAcG7H0bKowEar12wx2SyMp+lI+7s1ie/5fX8tBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+exec-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAwKDAwKBCQiHNze3AQCBBwWFDw6NPTy9PTy/Dw2NKyytOTi3LS2tMTKzMzOxLy+tLy+vBQODNze5NTS1JyalIyCbIx6VIRyVISGfJyelOTq7EQ+NMTGxKyurGxeRLyKPOSmROSuVOy2XOSiTLzCzNTOzDw+NCwqLHxuVOy6bPzGfOSuXNTW1LSyrMSWRNymTOSmTKSCTPTGjPzSnPzWnMyaVBQSDMTCxPz+/KyahNSeRHxeLJRyTPzmtPzarOy6fJyajNza1Ly6vLyulFRCJPzirPTOlMS2pNTSzMTCvJyenBQWFNzKtPz6vPzyvPzqtOzGlOTe1AwGBFxWTLy6tPTm1PzSpPzutPz2xPTSnOTSxOy2dPzapPzerOzm5IR+dPzu5Pzu1PzqxPzy5Pz+9GRiXGxuZKympHR2bOTm5Pz6/MzSzBwaFJSSjCQmHPz2/AwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeEAQKIjIIDBAQDjYMFBoMHCAkKgwYFhwULDAUKCg0ODxCkBQgRnoUSExMUDxUWFxgZGpAbFIuGHB0eHyAhIiMkIB8lJieIKCUpJCTGIyorLCktKIUDpC4YLzAxIjIyMzQ1NhgdpJI3ODktJTowOyM8Ejc9Pj9AQUIEclAocCMIBQhDiOwgoaKIoCI+jBxBkkSJkCWemIyq0GSHCBVHihRx8gRKFCmpKhGaQqWKFYZXsGR5kkXLFgRUXBUqkCGCFS5AjnTx0sXKlyA6CRVgAAHMAilhxIwhU6ZFkBY5kgKYUoXBAzMKzixZ4AJNGgVm1KxhM0WpmQpUMtooaOPGxAM3Nw60oYLGjNYCbzYJOgAnRzNBJ95oPYQCgpJtkwzFoULlRuRPiy9fNhAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+exit-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBHR2dDQyNCH5BAEAAAAALAAAAAAWABYAAAJOhI+py90RnIMyRUOxhDfzJkACdoXBuEDDkQFDi5go0MrKx16kns80b7qdELCgBYaEGWwL5nG1ePFiKp9A6kuYRNuho8vxVrrZivmMRtMLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fileclose-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBERGRERCRDw6PCwqLExOTFRWVHRydGxqbGRiZCQiJISChIyKjHx6fDQyNBwaHJSWlKSipBQWFJyanPz+/JSSlCQmJAwKDCwuLBweHBQSFGxubExKTISGhDQ2NFxeXFRSVDw+PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbZQIBwSCwaj8jkMSAYDAgEJbFgOBwQCUOAoJAaFgvGonHIBhyP5BcSgUAYDWxggD4WFmx3e3HQngkSRgYMEBMUFG4MCId0BGlEAQeEhocVDYcUdBYKF0QCB3gRlJgUAQEYBBkaRAMbDZMMpAYcT46rQwMJrgsdC6QcfwoPnUMOBgkIV6SHHg6bw0QEAQYfBpggBZjPGsRD0gEchxwCIR6HChnQRQ8DIU4DTR4Em+ncRw8O+fmoXPXdRg+gQLFgIYM/KRIkoDP4QMKFf0o0aBAh4qGUixgzCrETBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filefind-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJyanLS6vLzCxISChNTe3OTu9Oz6/Nzy9Nzy/NTy/OT2/Nzi5Mzu9Lzq9KTe7LTq9PT+/Pz+/Nz2/Mzu/Kzm9Jza5HzK1LTi9PTu9IzW5ITO3FxaXNT2/KTi7Iza7GzC1LzW3FRSVMzO1MTq7HTS3Fy6zFS2vKzm7Lze5MTGzHzS5FTG1Ey2xEyyvJze7JzW3ITa5FTK3EymrGS+zFxWXKymrMzi7ESirEyqvLSyrKze7MzOzMTCxKSepAz+/NzW3MzKzBwWHLzS3ERCRAzi3KyurNze3MzGzLy2vLSutCQiJAyytHRydOTe5MTGxLy6tLyqpKyelJSCdOze3NS+tLyupLSmnKSOhCwuLPzy9Pzu7Oze1OzazOTOvMyihOTi5PTm3Pzi1PTazPTWxOzOtNSunDQyNPzy7Pzu5OzKrNzSzNzGvNS6rMyynMymjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwGFhYOIiYQBAgMEAwKHiokBBQYHCAkKCwwFAZOEBQ0IDAsODxARCZ6gAAEGEhMSFBUWFxgZCJ+TjBoMEpkRERscGBGRih0BBAgeFBQOER8gISEfIruIIwEkCCUVwhcgJicoKSrZg9srCRkRGdMsLS4vMNiK2wIKMRsbMiwzXtCocSydIBs3AuCIwIFDiBMucugAoWvSiB2VNPDg0ELHwA0MkCXr4aNSggg8NoDIQOFHgBtAkgURMiDAEAFEVBCJFKCIkSMGOyDRkETJEkOFmABoUsRJQkQdnkzQACWKlBtTplBR6qopxkFRJ0ytYuWKFCxZtBBq+hRA2AlbRrh08fLlCxi1a51g+dQhDFwuYsaQKWPmDBpKXgNETaNGjJgyhNfcVdTTiWI2XpK0cePmzRk4YA5T5otGixY0qFOXbgXAQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filenew-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBExOTERCRDw6PCwuLBwaHAwODAQCBOze1NTW1OTi5Nze3MTGxLS2tJyanPz+/Ozu7OTi3BQSFCwqLDw+PDQyNFRSVPTu7MzKxLyyrIR+fCQmJPz6/NTOxPz69Pzy7PTu5Pz29Pzu5PTq5PTm1My6pBQWFPTq3PTm3NS+rAwKDPTi1PTezOzWxMy2pPz27PTazOzSvMyynOzaxOzOtPTaxOzKrMyqjOzGpMymhPTizOTCpNzSzNTGvMymjMSihCH5BAEAAAAALAAAAAAWABYAAAboQIBwSCwaiYGAYEAgFAqGg/Q4DCASCsTiymgcHAcqQLB4mM+QiIQBppLPcMjkwQ4bB2X4maKgt4sVCHpnFhQTElNFE3mDDxcYGRp2RBuMgxwIHX9EBZZwHh8gCBmTQ52NISEiIyQlpUImng8hHyInKAgprwAqgnC0IKwrLLpGB4wctLYkwy0uuwd9Z8AnJywsLcVFx2YcL7UnJCwwLTEy0GXJoSgrCCwzNDTnxgjeH9UrKzXwNDY36LRGhEOwLx4NHDmgJbh3QoeOgv127EhojEeHDj16pEhRQoZHHzl+QJNCsqTJSXaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQWDCwaDDwmFPSubPzGhPzCfPy2dOSmZPzKlPzSnPzOlPzKjBQODPzChPzWnPy2bPSmXPyuZOyeXIRSLEQuFEwyHEQqFDQiFCweDKRuPFRSTPT29PTy9Ozq7OTi3Nze3NTW1MzOzMTGxMTCxLy6tLSytKyurDQyNMzKxOTm5OTi5Nza1NTS1MTCvLS2tLSyrKSmpJyenJSWlIyKjHx+fFxeXBwaHKxuPMzKzLy6vIyOjHx6fDw6NPy6dGxubLy+vISChCQmJNza3KyqrBQSFLR2RKSinJyanGxqZAwGBJSSlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeDAYqKiIeLj4wBjQCMhY+NkoiLk5qbhQIDoJyGBAUGBwgEo4MECQoLDA2pDrS1tKQPEAwHERITE77AvxKqhAQNDA8UFRYXFs8YBAQZGqGPxw0RGxwdHR4eHyAhIiMkJSYnKCgpBAYPEhcqHyssLS4kLzAxMjM0NTY3cBA4UCAHBw8gVnhgEcKFjhc7UPDj0cMHAAI/KFgY4YLFio/jRpTYsW8GDyCSCEQw2DChOHIqgsCQSEPIEEEEJFhAoUNECCJEyOk4d6KIyRtGcB7hIJKjixEjHu4oimSGEIs4d8IIUoKECnNB0ElMwkNJJgBLlJBAcQKGiR07KGAURVGViY0mhIwwSTKjr99+THjUoIg0r48hTRIrRtxkiOMhDgrZCQQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileprint-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTy7PTu9OzezPzu5OzavAQCBPzy7PTm3OzazOzKrPTu5FxSRERCRGReXPTq5Pzu7ExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzOtOzSvLyyTMTCxKSipGRiZFROLPz+/KyurJyenJyWnGxmbLSabOzClOzm7LSutJSWlJSSlJyanGxqbNze3OTm5IyGjNTO1Nza3NzW3OTe5IyKjHx6fMzGzMTGxMzOzNTW1IR+hISGhKymrLy6vLSytERGRGxubKyqrLy2vLS2tDQ2NEQ+RASKBAT+BFxeXHRudAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4ODxARApKUCaGYEAsSCRMUnQysCwoVEhYXGLOLCBCgDqK5GQUXGooCAhscBB0euBUZEAUJvQgIgx8gIR8iCSPiHuIFEREDJCXaANwhJhsnKCnWERcRKiopFCvsBywhQrRwQWGAPAz5EhpQ9wIABRgKYsiYMTEEDQocatiwkUIEP18fbkCAAcMBjhwzdOyQwYNCgBMfKJSgMItBjxs+btwgCSGGjhw/ZoRgQKGZCRMUPgABEgSIkCE3SZok8qNqkR85NtDUEcPIkaVAkCR5SrJBDCVKlmzQ6pCCiRlMTJo4YUH3K5AeMBYYWctW0BOaUH60cBJFypQmII6wyEpFQBVFMSm4UAI3hJUrOGh8oOJrklYKWIromJGDR99Ogz5j4ZGlM+pEnwmBCwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBGxqbAQCBLy+vERCRExKTHRydIyKjMTCxFxaXGRiZFRSVFRWVPz6/Nze3Nzm5Pz+/JyanDw+PExOTHR2dMTGxBQWFLSytHx+fISChOzy9Ly6vAQGBJSWlMzKzAwODJSSlHx6fIyOjOTi5DQ2NISGhGxubCwuLOzq7ERGRFxeXNTW1CwqLPT29Dw6PGRmZKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBQGBAMj8ikUDAgFAzKKCBwQCQUCcICKh0SEAhGw5EIZAmBrgCxeDQgcDJWyz0GIggJfL+XGwQJRxNgC3yGDwwUFUZDFhdthnwMGAZNQwEZFwQakXANBBQbHIIdERIBnRAOiR4ERx8gsSEMBBmGCyEGG3YGBwcgIr8UCwQHECOgG4xCtRkEJAvBJRklJgkSFBQeJ68hJiEoESkFKiEZIbkGARsLlwEGExENGhorGSkpFAYm66NDLAECpGiBYsUIFA8wLHBBQMWLVkdUCFCwaYVFBOymkVCgYEMgOykEpICBccMBAhhELFigTEqAAgIIwCiQ4eRKDyS6EAlJIAI0EpaudF4iIKDAAn9CkRT5eMROEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fill-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/AQCBMT+xASCBMQCBASaBPyChASyBATCBPwCBARmBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAASCEMhJq704axB2DkLnVeAwiCNHDMWZcsbaul5ZyCaKBcZwFDcgDRNbHX7AmW4SMx2MSOFQQlitEAhosrVcDQQE7NMXzVGqA6xAgCUckabQpJoIYBFsxBspUKBiHQEHaoNvBQJTgBIBdnh5B4hLihONeJBTc0uMaphMS4uRGQYfny9EEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filter-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwKDMzKzMTGxNTS1MzOzAQGBLS2tLy+vKyqrLSytLy6vMTCxBQWFKyurCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAV7ICCOZGmeaHoGbKuOAjsQhVG764EgyT7YhaCBVQogFMhFImEABoUBknFxRDAazac2Kg00djystkA0sQ4BgzgYK6+Ch/bBseOmAmMD4gF5ifBCDwoRfiOABgyEhYYFCA6LUo19kH+Nj5QAaQh2kHibmJkFBJydpKCnfnYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+find-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJSWlFxaXJyanKy2tLzCxDw+PHyChNTa3Nzq7Nz29NTy9Mzu9OT29Nzi5Oz6/Mzy9Kzi7Jze5Lze5Nzy9JyenIyKjHR2dMTu9Kzm7JzW3ITW3ISChGxubERGROz+/Lzq9IzW5HzK1LTm7FRSVHTS3GS+zLTS1DQ2NMzOzMTq7Lzq7ITW5FS2vMTi5ExOTKTm7EzCzEy2vEyutJTa5FTK1ESirGy+zMzi5ESerESmtITa5OTy9KTe5KyqrAz+/Azi3ASutERCRExKTFRWVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCggGFhYOIAAIDiYUEBQYFAoeJAweKhAgJCgsLDA0OCAGJg4wBCA8QDhENEhMUFaKDFhcYgwEJCxAQDBkaGxwSFaMAFh0eAx8AAQIKECAODCEaIiMjJJMAtQMlygEGEBkVva4mJycTKKMYJd0pyyoOKyssGhMtIycuGi/EMB/vlhmoQEFDjHsmZMygUUMdqWUCGgCbYMKEjRk3cEjI9jBADg3Wzs3QsYOHA2IdO1SQkI/GjRMtFhBA2RFBDwk+OASrMPMHkIe3AhBA8QLFzAAHgvyg2dEQMSEHPCwltQgooSFSmVpSxKjjh6wPtwINgHVqsVpWESEFeywZ17RkED2s40YEgFirlIq4SwvUQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+finish-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrEze7BRmjCTC1ETS3ETa5BTC3Bx2nAyWvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAakQIBwSCwaj8hkMqBsBgTN5IAAJQqqykCBasUmDQcEV3gtBs7oATihGJeJgcOCQWc0HA8Ig/seRiQTFAsVFhcYGRp6VH1CGwscHQ8dGB4fIBkPIWKMAAMLIiAjIJcgH5gkGSWcARIiJicoJikpHikoHqqrKiW8JSogKymoqgCrV8cCARgkuFWcRwYeqVjPRgEExEPVRQbZ2l5IBuBRQ0zk5+hRBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_new-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBNzaTPT2FISCBCQaDPz+BExKBDwmFPSubPzChPzCfPy2dPz6BMzOTAQCBOSmZPzKlPzSnPzOlPzKjBQODPz+rPz+3PzWnPyuZPSmXNyaXPTyhISCLIRSLEQuFEwyHPy2bKRuPFRSTPT29PTy9Ozq7Pz+xJyanDQyNPzGhMzKzOTi3Nza3OTiVBQWFDwqFKxuPOTi5JSSjISChHR2dGRmZFxeXPS2dNTSzNTS1OTm5KSipLS2tLSytKyqpIyKhGRiZNze3NTW1MTGxMTCvLy6tIyKjCQmJMTCxMzOzMzKxJyenHx6fLR2RLy6vJSSlHx+fDw6NLy+vIyOjAwGBGxqZKyurCwuLBQSFJSWlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLjI2MAY6HAgOHBJYEhJCDBQaDmgcICQoLB4MGDA0OAQUBDg2cAAcPEBESE6QUuQasFRYVq5SxCRcSCggYGRjIGgYbFs8bHIMHExIJGR0eHx7cB83PFhsDDuTUEyAhIiMjJCQluwEmvsAnKAcp1x4qKyUrLLupWrByxcnFiwQIYIggEaNEiRgBZMyYQaNADRs2REA6cCODBxw5+OnQgWMHjx4+BND4MQOIg1gI0gUREkTHiplDhhApEoCGkRlHBL3I8MEHEhz+WAhJogTJySVMfthwIehAExE5jubAkYQpESc8fOx4AiXKNA8+ekhBgqSpzh5hPHcsmVLjpSAqVZBY6VGkiJMiPQKLnTvjCiEsWU4o3nGC8YksMmT8YCmC6iAXKLRc2cz5yGYtR0JjKWQgEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+forward-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrETa5ByixBRmjCTC1ETS3BTC3Bx2nAyWvEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaYQIBwSCwaj8hkMqBsBgTN5IAAjRoDBaq1aDggtMuAWDzoJhTgY+CwYLgZDccDwkgXI5IJZVGxXDAZGnR2QxsLHB0PHRgeHyAZDyFfVUQDCyIgIyCPIB+QJCUmlEMBEiInKCQnKSkeKSQeomoqJrUmKiArKSwZsmoCwMEBGCyxo1EGHr3HUQEEvltCBtDRAAbMW0zV29xDBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+frac-22:actions actions22 22:photo:22 22:R0lGODlhFwAWAIIAAPwCBAQCBAwODAwKDAQGBIQChAAAAAAAACH5BAEAAAAALAAAAAAXABYAAANICLrc/iwEJSEUQA45LcOKMHWeU5XWiUYZsZClOIjj+naqrS9F7/9A326YCYBypREOpMPBVifjkBRw7SpIG+eJIg2IWC5UikoAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+frameprint-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTu9PTu5OzezPzu5OzavAQCBPzy7PTm3OzazOzOtPTu7ERCRGReXPzu7PTq5OzKrExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzSvLyyTMTCxKSipGxmbOzClFROLPz+/LSutJSWlJyWnOzm7JSSlJyenOTe5OTi5MzKzASKBAT+BNzW3OTm5KyurMzGzMTGxMzOzNTW1KyqrLy2vERGRGxubIyGjLSytGRiZISChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4LDxARApKUCaGYDwsSCRMUnQysCxUKEhYXGLOLCBCgow4VEhkFF6mMAhobBRAcChUVGR0FCR4UCAiDHyAhHyIJCRAjHOUJEREDJCXcAN4hJhonKBjXESn5Kdkq7wcrQoRg0YLCgBMuRFxIwTCFgXYvAFCA0SCGjBkYQxQMUE8EBhEUVPj6QOMBDBgLLM6oYYMFhYkvYcSkwOAGDho3TyqIUaPGyZ9AKXzIoWMHDx44bvQ4+WAi0KA1fPwAEiTIjyBCkDp9KlMiBRMzhhAhsqLsD64/fQEo8tLIERZIH8Ru5arow8skSmTMDdpJQ0y0XTsJ2gtU8GCZMBMbCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+funct-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI+hI+py+0PIwhUohpMXfl6103h1nTUNproEU6am62v1pLsPX/siO9Jiou9TD2XyHfMGUs65aVmiUqn1CrCUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gear-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFCQiJERGRBwaHFxeXHx+fDw+PGRmZExOTGxubKSipDQyNHx6fIyKjJSSlJyanISGhISChLS2tIyOjHR2dAwKDAQGBJyenAQCBCwqLLy+vKyqrAwODMTGxKyurFRWVLSytLy6vMTCxMzOzGRiZNTW1CwuLMzKzFxaXJSWlOTm5Nze3Ozu7OTi5Ozq7GxqbDw6PHRydAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBwSBwGBMVkMjAgFAwHBFJpPB4SiQJCsWAQqEJB4prdNhQNx7QYIFwLD0ikQZdMHgelOPGYULQVDg4QEAVfRAEBBwUTEE0WFwcYhAuNF0QDBQULDwwZGUIaEAuVGxgBRAIFEhwHHUQMCxwTHAVrAAwFFRwKFkQZsxseDqBDGXMSHwfFQiAhIiMeJApEBwcOcahDJcLSJCYcGkQKcRAnQhkF0SgmEykHXkObox8q1iEjKN8rENqYD7MmeBCmzwSLFS1I3AqzYIPDESS+sWCxgQMLEgOSJKjozeAKFyskCDigQFwSBhJMjDDhAlyLFyVA+dIzAUUKEi0eaNhAIg8YGiEMenkwASNDDBkLqRQAEEAkup9KDkEFgC4IACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+gohome-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQiJNze3ERCROTi5MzGzLy6vDw6PKyqrKyurBQSFGRiZGxqbGRmZISChEQ+RExKTExOTHRydDQyNOTe5FROVLSurCwqLMTCxPT29Pz6/LSutFxeXLyytLSytPz+/JSWlKympPTq7KSipNzW3BwaHHx6fKx2VJRWNHQmBFweDOzq7Ly+vNTW1JxWNLSajPTe1Ny6pKxWJNTS1IyOjJRmbPTi3OzKrNSSXMSGVHQiBHx+fJSSlPzy9IxOVOzWxOSyjNSCPLxeDJyWnIRGTOTGtMxmDLRWBHwqBIxGTLRSDDQuNNSunKxKBGwyNMSafMxqHMReDKRGDPTu9LxuPLxaDJQ+DIR+hGQqNIQyBGQiBNTO1EQKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAYSIiYQCAwQCiokEhwACBQYHBAiQhAiHlQYJCgkEC5uCkp8MDQ4NDwylmwgQlgQRERIEBBOkmxQVBgQWFwUFFxEEDLyJGAUZtQoFGhsFHLYdyoOVHsEf0SAbIAUex8mwlAUhtSIFG+3uIyTWvAIGJMEkJe76GyXbEeWUBJg4USKaBhQpVKzYoIFFiwYUBBJa8MAFCw0vYMSQMWOhBhoTKCQSUKMEiw02buDIoWOHBg0GeIhEFKAHDR8afgAJImSIioYliMws1MPkhiJGchxBkmTDCBo1hg4KQMTiBiUyhBxZ8pNFiR5MEtU0WqSJVidJNDyNKraHC5xPNKBEkTLlJ5WvUgWNvfikyhArV34+7ZEXQAAsB2iUyHLlihYtW0pwOYAFgyJDmDNr7jIIWiAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+goto-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBBQSDAwODAQCBCwiHDQuJExCNFRCNAwGBDwuJEw+NFxKPBQODEQ6LFxOPEw6NCwmHDQmJBwaFCQaFEQ2LCQeFDwyJBwWFDwyLDQqJAwKBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWSICCOJBkEQqmWA1EYR4Gsq5Aoy2EYKU0yDcPCkSP4SgShw2FoDI6jQeNxYD6MUBFCEXxAelkRgxCRhEWQiW/wXE2CataAUmiXKo+Fwg6YWxQWfCQEAxckUgoYDRSCR4gKB4ZnFVwUCgUMZ30KCRQUhJpzBRQQjUcSnmyaM32mPgQNmZpRBwmSsxAZBBqzUa4iBiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+help-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBCQuNBwiJAwiLAwaJAwSHAwSFIy+3ERynCw2PCQuPAwmPCxOZCxWdJzG3FSazBwmNAQKDAQGBDRmhBQyTDxujDR2rIy21AwWJDyGxCxmjAwmNDRihAQOFDxmhCxunBQWFAwaLCRahDR6rESGvDQ2PCRWdDRunDSGvCRSdAwWHCwuLDSOzHSmxDyKxBxCZBwqNHSu1DyOzAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAahQIBwCAgIBAPCoGAgOoeBAyKhWCwYDUf0CX1AIhLiJEGpBLiAAaRxdgYsl7Ybk8igBZoN5xmAdDxoanp8HyANISF8EBsiXBMjJBolBEQmGHFoRScbKHIKDykqK5lFAZRCnyknTaROLA8tq61OChgtKqyzQgEYEJi6UC4vI3LAASkbMBPARAEBdszR0sACEaPSMTIQM8W6KzNl3bo0NOJDdEEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+int-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBIQChAQCBBwaHAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANJCLrc/iDAuYKlU0r8NHfXB24iEyrCIAjAynakQLQuDS+vrTcnI1M9HyaIykFOKwUhZ6zEWC5oU9GrRY+kkqdUiXCdWW74SzYkAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+leftjust-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIihI+py+1vgpy0Tohzs1T7z3CiBJbQWJnqg4rre7jwTBtGAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+locationbar_erase-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAWABYAAAJChI+py+0PX5i0VmbzVboHPgmCJVoJJY5haR5VGsCa+6ZqZ2Sy95E2n0OVdi2A8EacIIS+YpC3WUIpi6kygs1qsYYCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+lock-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiF4gQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+lsub-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAWABYAAAI9hI+pe+EPHTNhgjox04srn4CI2FgkZaaZurGd+5nRfAiCYVuJzfN6jbvdfrshEZE7ApNGXa+nZDaVVIOhAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+lsup-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAI5hI+pF2G9YpszKgcgtgtyuX2I44UcRYkM5qmWAMcyzAn1/eKRnfe7vuD9fEGgQlgkHo2JmRPpStgLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_forward-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBJR2dLyijPTixPz69Pzq3Pzy3Pzu5PTu7Ozi1LyelOzavPz+/DwqLLyafPTmvPz67Pz29Pzy7LSWlPzmzPz6/LyajPTitOTSzMyurPz25PTatPTi3KyOjPzuxAwqVDQiJHxiZPTetKySlPzqvPz27BQ6bAwmTPTexLyinNzGxDRunPzy5KySjCQ+ZNzq9KTO7JzC3Nzq/Ozu/LzW7FSm1BR6vGSWvFyq1AyGxAxytAx6vBSKxAxSjMyujLSunES+5BSi1ByGvAQCBNzCrOTaxNTOvMS6rKyelCx6rBx6tBQKDOTWvPzu1PTq1OzezAQOHAxGdBROhAQGFPzy1NzOvIRqXLyynOzarPz21Jx2XPTWrLSShAw2XKSCbPzuzAwePAQCDPzyzPzqzPTmxOzWtAwGBKyObOTSrNzGrKyGbOzatEQyNKyCZOzWrOTGpNS2lCweHCQaHCQWFBwSFBQODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBhBwgQKFSpY0HgBQwYNGzh0mDhRAAUPHziACEGBpYgRJDiUGEkSwoCQJk6opNASRQoOFETQJDkggwoOJlYApcCihQuVL2DUhBDjhIqjJmRwwDCDhswaNm5MjYHjKggOOU7o0CGTA9gdYknG2KCCBw8VJVL0uBgihAUfP+CSNGCjsI/DiBPbAMJBsEQbQYQM+UG5smUiRYw0jlvYxhEkSYyIHm1EyRLTTH40EZvAyZPOR4pAmU07ipIkUKQ0mQIhAZUqVq5gKXzkSBYtyLVEyd1ki8QFXLp4+WJFQowbYLJnD5NbzJiJCjaQnhnvpYwZM0/OPFlvQ/f3iQvQpBlvQc0aCWy4VKnCpY0Y5yQxgEYXZFjghgwZUOHGCW90YQEccUwloBwGyjAHHXUoSAMZb0xhx1QOoMHDHSfIwSEOdTjhAQ1d4MFbTQ6Q4MYacrzxhhx04JCHHhvQsMeLJPHRBxpr+LHCGnusgccfgKixQR1ATtTBlDDAEIggggxCCCGFbLGFHVFKZEdAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_generic-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBDQyNCwqLCQiJBwaHBQSFAwKDAQCBDw6PPz+/Pz69Pz27PTy7PTy5PTu5PTu3PTu1PTq1PTqzOzmzPzuvOzitPTmvOzivAQGBDw+POzevPz67Pz25Pz23Pzy1PzyzPzqvOTavERCRKSilPz21OTevIR+ZExKTOTi3JyanLS2tPz6/Pz65KyihJSKbMS6lExOTNTW1JSWlJSKZMSylNTOrNTKpFRSVPz29MTCxPTmzKymjIyCdOTWxOzexOTWrBQWFFRWVOzu7MzKxJyalOzatLSulMzKtOzmxOTarFxaXKyqnPTmtIyGdIR+bOzetOzixBweHGRiZOzm3NzWzNzSrOTetGRmZOzizOTexOzm1JSKdGxqbHRydJySdHR2dOzapHx6fKyijOTixCwuLHx+fFxeXERGRDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLAQECjwORAwSUBZYFBpkHmwgJCgsMDA0OD6UQERITFBMVFhcVGBkangq1ChsLGxwcHQ0dHR4fICEGIiMSCbS3uLq8wCQUJSYGJygpKhQJKyvLLM4Nwi0uLwUwDQsxMtmeuQveHR8UMzQ1NgU3Dgo41jk6ns0cKOzgYaOHjx9AgjTAUUvIECLZNmxoUISHkSM9KiBJQkCJA4kKEoBQoWJJAiYtmjh5AmVCsCJRpHzckKCCySlUUvBYUqUHDysSPnxIEuXKA5pPRiRwxwFLFhRaIEDYUoEChCcDuECoOWKFuwW7nHkg4WELkw8/BHRRwESpt10dU8SSHevlRxIBX6C0WBE27q8GZMkKbTADjIAwYlb4GLMYShYoPTRo6FGiSJEKPyzMIFMmzJcvXbhwkSLFjJkbQW6cOHNGhAgEAdAsmk27tm0ABgIBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_get-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQ6bCQ+ZAwePKTC5Ozu/NTi9GSWvAwSJGSu3JS+5CR+rAQOHPTy/AyKzES23AwOHCw+bOTq/BR6xES+5AwmTBw6ZMTW9Ax6tByi1BRGdAw2XAQCBDQuNDRupKzS9FSm1BR2vBym3EzC7CSGxBROhNTW1Pz+/OTm5NTO1AQGFNzW3Ozq7Ozm7IyKjJyWnMzOzNzq9Nze3OTa5Ly6vCQiJGReZISChKyqrAwqVBRWlOTi5MS6xJSWlNza3OTe5Ly2vGxmbKymrIyGjMzGzISGhKSepCQmJDw6PHR2dJSOlPTy9MTGxLy+vLS2tMzKzLSutMTCxLSytKSipJyenKyurJyanCwqLCwmLCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBhgIBA4SLjAABBAUGBwiNlY4FCQoLDJaNAQ0ODwsQnYwREhMUE5ylFYYRFhcYGRgaGxsDHJUdFR4SHyAhEyIjJCUcuo0cJr0nExihxgwoyYscKSnMHicOIw4lKissLdWDHC4vMCu9McYqMjMyNOUANTY3OPEoOTolDCszdrSgwaMcBxs9TMxYOCMHBx8zfPj48QNINQ5BbMBIIUShDIUoTAhR94PHPEEHbQwZckOGjBQviMxYUWQIDCMmdXE4gqRnkiFETAxR8iKFjJU2evZEdmLJkgJIbqS4wXJIUapImj5FtuSEVyRVV1IVi4RIChhEkLVAgcJHEqVwVJUmYdKkiRNkALMRecKECRG/ff8CEQJFCA5kMKJEoUHDCQ/HkB9LmWKECpUeyKoIMSLEyosen0OD7iH2xg1dV7BkqXGlBpbWNTq4Zn2khu0aAAwEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail_replyall-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBLyejPTixPz29PTu3Pzu5Pzy7Ozi1LyelPTavPz+/DwqLPz67PTetPz69ERCRLSWlPTmzPz6/OzexLyajPzqvDw+PDQ2NMyurDQiJPz23PTatJyenAQCBPTevPz25LSajOzq7HxiZPTexPz65JyanBQ6bKSmpBwuTOTi5OzaxBRCdHySvGRiZHx6fBQSFERGRNzq9IyOjHx+fGxqbPzu3BwaHFSq3Aw6XAxKfPzy3Gy63ByWzJzO7Mzi9OzavBRytAx6vCSazGRKTPzy1AQKHBRGdBRyrDy63ES+3Cym1CR6rBwWVAQSLAx+xCyCtBRmnPzuzAQWLAwePPzyzKSCbAQOJByGvOTWvPTmxBQODFQ6PPTWrPzqzOzatAwGBKyObLSWfPTivKyCZEQyNKyGZOzWrOzWtOTSrOTGpNS2lJx2XDQmJCweHCQaHCQWFBwSFBQKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpkzGjhAoYMGjZMpMghQgcNFjh4mODhA4gQGkSIHAmBwAgNJEpo8KDSxAkUGjhMSEGz5gUVIiKs2PmBRQudHiwQpUnAxYsXImB0aBqjBcuoU0fKmPGChgUNH2qIqGHjg9u3bicWIFs2rYgbNnDkyGFhb8cccQ3ouJqWQo0dPFr0WMy4h48LFj4gsKriB5AeNngEaSGks+chPnwQOXFAh4oXRYxk9nAEyY7XO2wksWHDx5ATCDIoUXEBsYclTJo4cWJhuIjhSXacSPBEiZLMQY4wgRKluvXqUpyIsDElAxUqVaxcwcGCPQuWLOixaNHCZAsXBU+oqKDSxQqULF6ifNmyn/8VMOtxwcAK36kQRhdJQIFFEmKM4eCDYGyhhYAEkqFEGSuYYcUZLaDxXRpqSNRCEu6twYaFZXTQhgRd2NCCG9918AYELTjoXgNuKAFHB2RQEUYHVbQQRwlUpPHGGFwkyQUEDsgxx4lh9BhCBy2U8UQJcrSg5JIQ0FEHG3bc0QGYK+CRhx57PEGlkhM9sAEffKTQhx9+/AEIIIGoEUgLLRRFR0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_reply-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBMSihPTixPz69PTq5Pzy1Pzu5PTq1Pzy7Pzu7Ozi1LyelPTavPz+/DwqLLSajPTetPz27LSWlPzmzPz6/PTexPz67Pz29OTSzMyurPz25LyajBRCdPzuvDQmJOzexPTevOzq5BQ6bBwuTDQiJHxiZPz23Pz65LyinPzmvBxCbHySvAQCBOTi3OTq9CweHOzaxFSq3Aw6XGy63ByWzJzO7Mzi9OzavNzq9BRytAx6vBR6tPzy3AwOHDy63Ax+xCSazCym1CR6rBwWVOzizAQSLES+3CyCtBRyrBRmnGRKTPzu1MzGtAxKfAQWLAwePPTizMy6nByGvNzWxOzWrNzOtBQKDJR2ZNS2lPTmvBQODPTatKSCbOTaxLyqlAQKHFQ6PPzyzPzqzPTu1PTivOzWtKyObPzuzOTOtLSWfPzqvAwGBKyCZPTWrPTmxNzKrEQyNOzatOTGpJx2XCQaHCQWFBwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYuIDBQgYNGzh08DCR4oQPIDqEmDBhJQYRIzqQIFkSAoESJCKkDGFiwgkUKTpMwECz5IASKjqsSMlSA4sWQjG4qGnzhYoQSmF0iCFjBgmWGWhQrVHCxg2sOHLo2MGjB0sLYmsWQHq1p4wdPtqemGDhB1UDQFSouKHi7oQgQmSwUMyYxcQDZQWz2EFiCJEiRoyQyLzZyGIIB47YKLwDSRAiSZSoXq1kCRHNLBK8YGKjCYskTp4ogeKkt+8oUaBImZKAAxMmVKrctqL7ihTnz7FkAT5FC4cKFbZwadIFdxcvX8KLss8iJcoUBUcq2KgAJoxyMTy4jCFTxoxEHl2GLyCDncmWM2hUIQMPY2CXhhoTfTEcA2tgVwEba7Thxhs88FdBD/ZB8MUUHMJBRhw2sAGCHBKU4UaFc1RAhxnhcdhhHUzYAUIcFdxRAh4R5KGHinu4OIVEDqTBRx81xhGHHzD8wQYQetDRI4cTAcIHGWT0EQgZa1ApCBqDcBAID1Q94IEHLtBAAyGEFGKIIWqYYQYPYNZkQEAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_send-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAIR6fIRydHxubHRqbHRmZGxeXGxaXGRWVFxSVFxOTFRGRExCREw+PEQ6PDw2NDwuLPwCBLSijOzixPz69PTq3PTu5PTu3PTu7OTi1KyelOzavPz+/DQqLPz67LSafOzetPz27Pz29KyajPTmzPz6/NzSzLyurCwiJPz25Ozi3JyOjPzuxBRGbAwSHOzexPz23KSSlPzqvBROdISavBxSdAwaLHRiZLSinNTGxMy+vBxGZNzu9BSGrAwWJMSyrKSSjFy61ETO3BRWfPz65PTqzHTK3ByqzBSWxEzW5AQWJOTWxBRCXOTu9BSOvDzO3ByavBRKbOzaxOzizKSWlCQ2TAQCBJza7BRWdNzSxJSCbMzq9BSOtCSKrAwiPOTavPzy3LymlCySrAwmPFRKTPzy1NTGrPzu1JR+bOzatPzyzCy61ByGpOzWtJyCbPTmvPzuzIS+3FymxCSuzBR6nJyCZOTWvKSObMSujOzivAwKDOTSrNzKrJyGbDwyNOzWrMy2lIx2XBwWFBQSFBQODAwGBAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYqMDxAoYMGjZwmEixg4cPGzqA6BBiAggRIzaQGEkSwgAMJCKgnNBhQogSJlKGOFHTpgYUG0TsnJBCxQoSE1i0KErAxYsOJJRuuAAjhkwZM2jUqGnDBQoUHTbciIEjx4YNOmbs4CGjB8kCZlGAALHBx4+YcTcACcJDyFSJBo6iGNIhhQkiG8BOKGLkCBK6SSQisHoWhZIbG5bMYALECI8mTZw8gTL1QJQXZ6VMiUylSpUlVpoYaXLFtm0EGmCjwJLlA2O9MrRsccKlC8kEXr7AdgEmwtkhX2SQ2BIkjBiSYzSQr/nyhUKZLIrJJOcexvlEBV7IvCBjRkmAMzHOaufhxDvJBWiQISAFxUUQQRovJNeEGmu4JxEDbKQhXxsfuFDGGW68IQMcccgxRxUkNRDhC3R8QMQIdZwXQ11JJGFbiB+QYccHaaTxhgt13OFBDGTgkUdRDrhAhx5k2JjGCB/swYcXMXwAYk190OGHHx/4wUaVepTxByAaoPEkSQ5wwMEJZAZipiCDDJIHIYV8OZEdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+matrix-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBIQChCH5BAEAAAAALAAAAAAWABYAAAJHhI+pyw0Bw4sTVmmw1C/3/20ex2VUtJ2Uwx7oBb9eR45ziNfgy6tW2+pZhJicjXbTiZA7X2q4AjqIsajSuDsuty5n9SddGAoAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+message_get-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxatHx+/Hx69GRixFRWtHR29FxaxHx6/Gxq9ExKxGRm/FRW9Dw+xFxavFxazFRS1ExO9ERC/DQy5CQmzBwaxBQSpCwqLMS+xBwatExK/DQy9CQm/BQW3AQCjJyavAQCBMzGzAwOtDQ21DQy/Cwq/BQW9AwK5JSStOTi5AwKDKyurMTGxLS2xISGpNTS1IyKjJyanMTCxAQC1MzKzNza3MzOzCQiJGxqbHx6fKyqrLy61NTO1JSSlNTW1NzW3Nze3HRydKSipISChDw6PLy+vFxaXPTy9ISGhPz+/Ly6vLSytJSWlHx+fCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgIDBISLjIWHiY2RggWHBgeSkYYICQqYjQUICwwNnoMFDg8QDBESExQVFpgXGBkQERoSGxwdHh8gkiAhGCIjJCUmJx4oKb+NKissIS0iHcgeLi8pzI0gMDEyLzIiM9c0NTU2zYQ3ODk6L/A7yvDnPBjqgiA5PTYvPvU+fvh4AeQFDXwgggTBwEIIOB8sakB0iO7gIH05hvToIeQFBo4eNwoJEaIZiAtEUgbhWGQjRxk9hhhJSeQXiCM4jxBxyXMjEiI5bR5JQnRnT5dDiNCgIcNmCiBAfAShSZVmECVKltgc+MIGCxlgw4pdskKHEJtMZRTJuqStW7dCImLEYGLTrJC4PeYy0asXxpAhTZpdGHzBSWHDiBPfWCzIQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+misc-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFCQiJERGRBwaHFxeXHx+fDw+PGRmZExOTGxubKSipDQyNHx6fIyKjJSSlJyanISGhISChLS2tIyOjHR2dAwKDAQGBJyenAQCBCwqLLy+vKyqrAwODMTGxKyurFRWVLSytLy6vMTCxMzOzGRiZNTW1CwuLMzKzFxaXJSWlOTm5Nze3Ozu7OTi5Ozq7GxqbDw6PHRydAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBwSBwGBMVkMjAgFAwHBFJpPB4SiQJCsWAQqEJB4prdNhQNx7QYIFwLD0ikQZdMHgelOPGYULQVDg4QEAVfRAEBBwUTEE0WFwcYhAuNF0QDBQULDwwZGUIaEAuVGxgBRAIFEhwHHUQMCxwTHAVrAAwFFRwKFkQZsxseDqBDGXMSHwfFQiAhIiMeJApEBwcOcahDJcLSJCYcGkQKcRAnQhkF0SgmEykHXkObox8q1iEjKN8rENqYD7MmeBCmzwSLFS1I3AqzYIPDESS+sWCxgQMLEgOSJKjozeAKFyskCDigQFwSBhJMjDDhAlyLFyVA+dIzAUUKEi0eaNhAIg8YGiEMenkwASNDDBkLqRQAEEAkup9KDkEFACUIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+move-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI6hI8RyJ26nAQQzlbrdWrP7nHRNh5gwpxmaZxWylJdRtf2fcux2rr7n8LsQrxQzyhE9mhIplKjPE5wBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+news_subscribe-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/Dw6PAQCBHRydPT29GxqbCQiJPz+9PTy9JwCBKwqLPz6/GRiZERCRPz+/FRSVDQyNBQSFBwaHDQ2NKSipJyanHx+fMzOzNza3FTCFGRmZCwqLAwODLzqpCwuLExOTLzqrFTGFAQGBES+BETCBEzCDDSqBBQ+BLTqnBRCBFRWVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb0QIBwCAgIiMgkckAoHJVQgEFAOCCc0WThcEgoDgvGMztFJLiJ83Ws3C4ODIY1jUCIlQ0Bd+FwMLZmCXV3Qw8CCAICfW9wBQhddVgAEIcCCwuJDlxWBQx1AhFPjlyJlwISj1ZWBJQTAImIerGqVwgEiAwUR46ysAeJcKoEoYkTVLGPvrWVDBUWEwEXF1aziMGfAhhiAhAVFdKPyMux2YkAEc3fF3WcdQTAGYkQQxAF3uAIGggbCBwCHfEEeEBiIB0+BB8cgHAQogMIKPXurRMxgkQJExjZELT3jUGDEyhMpDhxIouUOB8qqAhZ0iS9CJMStTQQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+next-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBOze9ORy7Pzy/PSi5LQCvNSG1JQ2nNx21LQCzMRGzNRy3KQCpLwKzAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq704axC671WAfR8VCOKUbudApCBHksVgHO+5agFiHwVBAuYZ+RQLBmLHatgMS8mMyREsDI7oRipEeLWsKVG8Fce26EspzeaR2vDQNE7PGCIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+openterm-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAPwCBAQCBPTy9PTu9Ozq7OTi5Nze3OTe5Nza3NzW3NTS1MzOzMzKzMzGzMTCxMTGxOzm7AwGDBQOFBQSFCQeHCwmLCwuLDQyNDw6PERCRFROVEQ+RDQ2NLy+vKSipISChGxqbExKTOzu7OTm5Pz+/GRiZMS+xLy6vBQWFLy2vCwiHFQ+NMSmfNSyhIxmTDwuLJx+bLS2tCwmHMyyhMyqfPTqpPzyvLSWbLSWfPzitIx+ZDw2PAwKDCQiJGxWRPTmrPTerMyuhPzqtPz63PTWnPz6zNy+nIRiVDQuLKyWbOTanPz21NS2jNS6lDQqJHRaTPzmrPTSnPzyxOTClPz2xNSuhPTqxPzuvOzSpAQGDOTKnMy2jOzSrPTu1NzKnOzOnBwWHJRuXLSWdPTatPzqvNzClCwmJOzSnOTOnPTuxOzKlOzerOzarOzitJR6ZNTO1IxmXPTWrNSyjPzOjPTSpLSehHRqZOzirOTCjPS+fPzGhOy6bOzKhGROPMy2lPz+1PzmtKRyRHRiNNTCdPz+zNzCjEQ2NKySdDQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAj/AAEIHEiwoMGBARIqXMhQIUIBAwYQIFCggIEDCBIoULBgAYMGDgIIDEBAwMSKBRBk3NjxAciQIwdACBBBwgQKFSxcwJBBwwYMHBx0EAmA5EwPH0CEsCChoYgOQ0cSGCHhA4kSS5syJGDiBNEAFVGUKKEBAwWFFM6SNJHi64gDFEKE4FBBggoKK1i0cPECxokYXw0gsECYggQZM2jAqGHjBo4cOtqOxLhDAg8ePXz8ABJEyBAWRIoYOfJipEoMCZEkuaFkSAslS5jUGJKkSRAnRREo0JDwCZQoTKQAmUKlihQrVa5gKZ1lI+oAK7QM2cJlSZMuU4Z4+TJEx0iNOwKAggkjZkyOFmS8kClzpcUQLRRGbjRD4MgZNEzSqKG+ZgobI2248dUbDDDwABzcxSEHEFpgEcUcdMRRhx1fFejAAx0cgcYdSxiBRx566LEHH0d8QFRRNC3Uhx985CHEH0MAEkhCBxWkgiCDFEFIEYUYUmONMhyCRxVH/PgjBYioYJAdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paintbrush-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBMTC/AQCtAQCdPz+/MzKzOzu7KyqrCwuLAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARZEMhJ6wxiDMsp1lvHfRohWuRAmOeVlUTQSukqz3U8A/nd9rtCAWTbAQoGg0q3OyANCOYPA0UgfCdMJnHFimre72sZ7pBWiTLqRUirK5hV7A0P2O3GvD5PjwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paren-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJThI+pGou9oDuS1hlqnkxu/niVQB6kYHzAiJYoUK7paLrxpr6GMJjWeqlFGirEaQhcDHQJnEQX2/1kMBv08Yu1ttNkFRr1ikHjIiYYjDjSWLIbUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+pencil-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/IQCBPwCBPyChMQCBPzCxAQCBPz+/MzKzISChKyqrDQyNEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARYEMhJ6wxiEMtpIAWxddwXiqRlikSQeiAbuC+wirNR322gv7zcLobzDU+9XypoBBKTR1lz+RTWDgip8nUwZK1XLyIx5XoVicX2RUAo1DVKi7GOBxjxfNwQAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+percent-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIzhI+py+0P4wkU1XfDhBdo/zndF4qh1pkGKYFk2XpTqoJr9G5YfmOz3hixfBZa7IhMJg0FACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_eject-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAwKDJSWlFRSVBQSFKymrOzq7HRydERCRPz+/MzGzISGhJyenKSmpGxqbJyWnJSOlKSepLy2vIyOjGRiZPTu9IyGjLSutFxaXExOTHx2fGReZAQCBAQGBBwaHCQiJLSytKyurJSSlFxeXNze3LS2tIyKjFxWXHRudAwGDBQOFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbVKFQsGItBdBhpgh4PxIJvRC8cA4oiMy8bvQhJhMAYTFBVOURAWEw0QFxcMERAYCBluVxobDxkVHJocmBwEGgmEQx0dHh0CpKmkH6odVlanBR8FtAIFtiCkSB0LISEiGCIGIxAPDySuRwIOBwrOzwoHJRHJRh0jJgMj2gMnERQUCNVFHQQoCBvo6CkICATjRB0qp7b1K6qv+foyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_end-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTCxGReZBQSFOzm7AwKDKymrJSSlFRSVCwqLLy6vPTy9OTe5Ozq7CQiJLSytOTi5BwaHPz+/HRydMzKzKSepJSOlKSipJyanIyGjIyKjKyurISGhMzGzJyWnHR2dISChIyOjLSutDw+PERCRHx6fJSWlIR+hJyenGRmZHx2fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8ikMBBQKgOCgRMZIBSkxYHWoDVWD9EigpBQLLBERsPxCA8NDUhjgTBGJJNGG02RVBQWdUV3FxgZe0IGfoAGdhoXGxwdiAYef4FGFBoeHB8dGSBRihUhIo1FBhkbIyMkJRYmAwYal4JEBh2RChIWJ1IIGxUZFqdECCgkHR6wWAYpFR2YWSobvL5vFgfDaEMDIivMRBEsD9HcQgMWvecDLB0tZ0btsfJa9vLXU/X6/P3+b0EAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_pause-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwODMTCxKSmpJSWlFRSVAQGBBwaHLSutOzq7Ly6vCQeJPz+/Hx2fBQWFGxubLSytJSOlBQOFAwKDJSSlJyWnIyOjHRydNze3GRiZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWBICCOZGmeaKqubOumQSDEgRjPMSoMRGEcol3vh0IkFAtDDWBEKlGMRKPgEIii0yrqIS1ArADu9KuLNCSOSdCMVp8ohEZFC4DL6SaBpXGh6/l4JX8XZACDhXkYCn1LAoqMUBAZEhBLDJKUSyYBGmhPAJyemiU0NDaloy+qq6ytI8whACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_start-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExOTAwKDAQGBJSSlHx+fBQSFMTCxKymrFRSVOzu7GxqbLSytLy6vJyanPz+/GReZBwaHHRydKSepKSipGRiZJyWnAwODLSutKSmpISChPTu9ISGhFxaXJSWlIyGjJSOlERCRIyKjDw2PIyOjLy2vOzm7Dw6PLS2tCQmJOTe5GxmbDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa7QIBwSCwaj8ik0hgQLJGBgbMoqBIKU2LAcMgOEQmFYeEFbBmNMgDhYDwWBC0k4pCoJ46IgRIXBioRCRYXamwRGBQIfgaBFhiERhkaenxmCoEbBhyQRYaIGVsdghgem4UWegcEBB8UHhsgIaZGBBgRIpUIIxQhChginEQIIBEklWslFyYnBsFfFCi4WQgpFBwqFxNGKxcsxl4IAS0NZEYCF3vlwgEfUuZV8JEuI2pPAARN9kcE9fr+SwaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_stop-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAwKDBQSFBwaHCQmJJSSlISChJSOlJSWlGxqbGRiZNTS1PTy9Pz+/Ozm7OTi5FRSVIyKjOTe5MTCxIR+hExOTHR2dLy6vLSytLy2vHRydFxWXIyGjIyOjPz2/FRWVHx6fExKTMzOzJyanKSmpKyqrKSipAQGBLSutHx2fDw6PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcslsAgKCAWEQjQ4KgSwyYDAcugZEQqFYYJECA6PhaLcfEEUkgJZAGJB8fkKpWOhHAxcOGBQZGBoaGQgbHIBGAhUOGR0SBxISBh4Xf0iCHxQSlRIIXhsgj0UCIaCXmJgHGyKpRJ+hmB5dHQqOaCENIx0epBIkBhdzngoPGCQlJifQJBvJRygRKRcKGxcXGypys1srEREc5SLnICLiR1koLFVUWfRO9vf4+UwyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+prec_minus-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBKSipPz+/CH5BAEAAAAALAAAAAAWABYAAAJAhI+py62RgnRnGguZ3BlTYIHdl13jh3goFpIleggvTK8ctw76Pswav/MtAkCd8NHj9HLFY6S4JEGdqdumtjAUAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+prec_plus-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBKSipPz+/CH5BAEAAAAALAAAAAAWABYAAAJHhI+py22hgjwSonktxBZU7GnhkyXc6JmmeDpnG2lg1YCOInT3zrvfxwsMhsSBrkYUDo8MpTEZNH6M0SV058xWi1Tsj9ZjGAoAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+previous-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBOzC7PTq9NSG1MxW3LQCzNRi7MRGzLQCvPz2/NRq3ORy7HQCdJwClAAAACH5BAEAAAAALAAAAAAWABYAAARUEMhJq70Yh813rl1HheInBYIwrEJwktxJFEbRmuOBJIXivp5LQLcj+HCnBaPBMBhdMBBjw0w8ccEA0/EzdQHaHywmnIyDyDSIrG4LQ+64OSqvx+kRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+prod-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBIQChCH5BAEAAAAALAAAAAAWABYAAAI7hI+py+1/gpy0hlVRZlP19mmSE0YjeIoXuqpkarYYbJQeDdiJrrs77gvOZDVg7Eb8JXtFSpMJiUoB9AIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+queue-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBAQCBKSipMTC/Pz+/AAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANfCLrc/jDKEGQMQlDLKM5aZQXDQIHZ9nhleaLqEhAE1bofKCozXZO3l0bmK9qCQ2LRCDQlAb3lkoTZQaVS6jOKpWmt3O5X2fU6wWXfuBM2mmINCpbKkavho56VI9s7DAkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+redo-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3Pz+/JTWbHy+VHTCTMTivPT69BxGDESuJDyiHESiHEymJIzKZAQCBFS2LFzKNGzWPDRqHCxqDFSqLHy2XESCHAwaBAQOBBQqBDyWJHyqZDyKFGSiVESeJBQ6BAwSBGTGPFyWPFSSLEyOLESGJBQiDAwiBBQmDCRGFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8hkMcBkKpcBwYAwEDif0YLhwEUkFItFMkAwMBoOR+PxgHwjRDggamhIJpQ8ZbKGKOQLcgEFdhUWEYgRF3sNfhELBHALAhgZFhobRBwREhQdEAIEHpIKHwsaSJwUDQgQIJINARxKESESDQ0dgCIjSpAkDAwPco+ZSJAlJicnKHIAIrNHidOIQxunT0kpCyrZSCss0d5Fj6jjRonn6uvs2QZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+reload-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBCRSFCRSHBw+DBxCFCQ6FBwyDBQWBBxGFCxyLGTChMzqzLzmvHzKjDyOTER+RERyNDSqXNzy3LzivFS+fCyCPBQmBCQiBBxKFBQqDOTy3LTitES2dDR+PCxuJOT25KTarCx+PESSTCxKHDSeVCyKRNT21ESWVDSGPBQyDAQCBBQSFDRuLDSyZDySTGzChCRiJKSmpExKTDS2ZGzGhLy+vGxqbISChDSKRMzKzGxubDQ2NIyOjCQiJCwqLBQWFCwuLKSipERCRERGRHR2dAwKDDw6PFRWVIyKjCQmJFRSVBwaHKyurAQGBExOTBweHFxeXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf9gACCg4IBAgMEBQYHhI2ECAkKCwwNDg8QBAOOhAQREhMUFQgWBxcHGBmbggkaGxwPB4yDB6SbBJIKHQaqtY0eHyAhsqrDgx4aCiKpqoQHAyMjJBMKJaSxzAAHIRsmJgonKA0LHSmDKiuOBywRLSQuLyEwwyoxMuiN6iUzNBXy5jU2bsgoJugABBz95uXQsUMGD3vpPPgTpKIGwx4+HMr4kW4YkCA2hAzxAQSIECI+imBTwVIFESNHerRUgc0cEiFHkjiiyYzeDiVLdvLcySSkkKGEWiZVweSGkIHMmvQosoQlkaZOjvhosvKJjIAxoOAsgpRZkQNLnvSoqspAIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+revert-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAAQCBPwCBPz+/BQSFPTy9CQiJNTW1ERCRLSytAQGBISChMzKzFRWVDQyNCwqLMTCxFxeXOTm1KSipPz69BweHHR2dJSWlMya/Mxm/GQCzOzWxGRmZPzOzMzOzMzOnExOTDw6PNze3Ozq7OTi5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAWABYAAAbrQIBwSAwYAwDjUCloOgUDQlJJFCKfzoLAMF0ih9jmASGQfq3IBECgYC8YCsah4Rgc7+Bw2fCY4pNrCg8QboIIEX5HXXoEjWZ3eAIMgxITcRRVmVdOE50TBRV6TkJsD3EWDBUOoRcXGBmwsAJqT44aoKJNtAoVDAwWFRUFGwKxxhkCQhMEyxEcGrfEuWoGBgsdDwseHhQQvt++Hx8HmUQU4OHiICAJkHcDDB8hBCIj1QYfDomQAOIiHwxCPBiYr507JeNGAOQz8IC+g0YKrAtxAMQDBBgPFDB4EACIAwIHDkQAAhNEKuUStDMQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rightjust-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIhhI+py+1vgpy0Toizjvbur3WiBJbhSJnqgorri7nwDBoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+rsub-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAWABYAAAI+hI+pFu3f1gmSVUBrlnt19SUhMk5XaWnnqrYc+2rQfNWHIBi4feP+zssBdkJez5gAIodDYbH2+yGBymXCUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+rsup-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAI6hI+pyxBhXlOv1omggxon6VFdGG1laFmkyQLCC8fvJNB2U+M3k/P70gP+FEHiMFFEHhFJJk0GXUkNBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+run-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBOzq5MzOzPTy9KyurNze3PTy7IyOjOTi5MTGxNza3MTCxMzKzHx+fOTm5NTSzNTS1NTW1FxaXAQGBLy+vJSWlGxqbGRmZIyKhDw6PAQGDJyenAwKDLy6vLSytBQSFLy6tKyqrHR2dLS2tJyanJSSlISGhKSmpCQiJISGjCwqLBwaHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbcQIBwSCwaj8RAAMkUBgSDZdMpBQQIharyGDAclsoDYhtIKKrDwMEgUBMWiwSj3HCg0w+DfgGJQAYSDRMUTAELBhJ8fw0KFXdJBwkLEhYXGAUNDBUZj0pXkxYaARsIDRUMHJ5pAgQHkxEYUh0JFR4fHAVZTgMFCAt+sUIgBB4hIggOI1pKCQO8CB0gAgYkJGNbRQEKEYwNCa7VIhOPaRAKCpoV1QUl5E5mDJrFJAW4JuRlCuMnKB+94yVQ2DGi7QSYABcQgACTDF+VFChULJsiZIUCiRS5sMjIsQidIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+showmenu-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBBwaHERCRIyKjBQi/ERO7HR+1Ly+1Pz+/Ozq7MTCxOzu7NTS1AAAAAAAACH5BAEAAAAALAAAAAAWABYAAARkEMhJq7046z2D/2AoDAQVFGiqqsaBmGH8jWWX3Hiu3+YdKglPMIDrDXc+Is92zAmFi5pECWIkjySj0EkUZplb3JP4nV65WCmAqhR3yeo2Emmc0zsyGc3U6Pv/gAAKHISFhoQGEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+signature-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAISGhISChHx+fHx6fHR2dHRydGxubGxqbGRmZGRiZFxeXFxaXFRWVFRSVExOTPwCBAQCBMzKzMzOzMTCtMS2dJSCTCwqLPz+/PTu1MzCtERCRMSydPTqxPz+9Pz6/MS+rNzKlKSSVOTarPz69ISCtGxurJyaxPT29MS6pOzmvNzSnHRyrPz29OTi5LyqXOzavMy6fFxanHR2rOzq5JyKTOzizPTqzKyWVGxqpPTy7LymZGRipLSy1PTu5KSSZFRKLExKTGRaNPz27PTq3LSiXPTq1GRWNDQ2NMTC3FxSNLymXGxqrPzy7IRyPDQyNCQmJGRinJSCdHxuVBQSDPTy5PTm1IR2RJyOfKSSfBweHGRenFxepNzGrKyejNS+pNTCnNzCpLyedBwaFBQWFNzOrOTOtOTOrBQSFOzStOTKpAwKBMS+tMS6rMS2nMSylMSulLymhLymfAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAA8ALAAAAAAWABYAAAf/gAAAAQIDBAUGBwgJCgsMDQ4OD5MPEAEREpmYmJqaE5IPFBUWAxEXp6ipqJ+TFRgVBaaqsxcZGhUVGxwdBrK0qB4fFSAhIiMYCLIkJSa0JygVKSIhKSoJvhcrqh4sLRUuKR4vITAL2DGpMiMzNBs1FzYiKjcMER6oOKglLDkVOinwRMCAAcKBrx33eMTwkKPHPx8/RGxwEaICkIMXcOBgMaJfCgw/fMCgWCGIhoMlSOQQkmMIkSJGUoysGOTBEVlIZMTg16NHhSJJZCqhOenmqSU5cDDB0JJIzJlNak5yYoqHDBY7hmgN8aPGhhslKU16EgHJDiY9oGz9EcJFkChSaKaIfUC2I5UhMarU+GElyJUrWHzIFZslAtqWVbRs4dIFi5cvYMKImTsmQs8qVVrUePGCDJcyZkCEGUzpTAQMmGts5ozGTJo0XEbPVTNhDRsUbdy82Q0HTpwwwNXMlQOhuPHjyIWLNRAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+spellcheck-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAASC/AQCBFxaXBQWFAwKDPzCxPwaHPwiJNQGBOxKTPQ6PNQCBGwCBPQ+POwCBPwqLMwCBHwCBBwCBFQCBLQCBPwCBBQCBCQCBPQCBOQCBDQCBFwCBJQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWGICCOZGmeaAoErMi+4xuQgQAI8yoKw2rfOZ1LRIgJh0hhDncsyXKypNMIKAKbNGpwFjxukcza7jt8xmCAgkpVMKxRhQOCnTAVFAtGqtBwLEgFDxAREigBExQVFRAibYNdJhaIigmODBdvF4gYDwoZDBpvIhKIGYOFoi4bHBGQogESqKlvBiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+sqrt-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBIQChAQCBBwaHAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANPCLrc/jDCQKutkcqQJeCP5k3g6IjCIAjAynYt0brzUn7gW++i0i8CGcNiuyl0NlyysYKhXgQdUvmcNZtDTo/mmvo+ptMvjDOSzWey+mFIAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+start-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihCTO3BS+1AyixBSWvBSOtBSStAQWJDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdAQKFAAAACH5BAEAAAAALAAAAAAWABYAAAa0QIBwSCwaj8ikMqBcMpsCQTEwIDQBUWKgYHgqs8LAAZGwQqWAgGLBaDgEj0Fgjh5mxRBERDKhICAQFRYXRVEBGBAZGhscHR4VHyAhIiOFAiQZJRoSGyaNJxQnEyiVRFEoGykqKyYsJiYtLi0mKC+WFygrMDEyMzQ1wDQqKDaWADYoMzcqsjg5DSgoBISmaCOoMG4v29s2OsZCyDs8DldgQtc95WdFPg7rV0Y+XvHt9ff4SXRBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+stop-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/CQKDBwKDCwODNyKjPzq7My+vIxiXAQCBOSOjPz6/OSelNySjNyGhMR+fLRaTGQ2LPz+/Nx+dNR2bNRybMxuZMxeXMxiZLQSFJQaHFwqJNyKhOSCfNyCfNR6dMxmXMxWVMRORLQODOR+fOSSjNR2dMQ2LJQWFMRWTLwWDNSCfMxeVLwaFKQODNR+fNx+fMxiXKQSDOSWlMRSTMxaVMQ6NMxORMQyJOTS1MxqXLwWFLRORMxKPMQaHMxKTLQWFCH5BAEAAAAALAAAAAAWABYAAAb2QIBwSCwajwGBcikIHIsDQmFKNRwQT2EgoVgsGOCG4wHBIgmRhWRCqVQsF0xGYyYGNgoGh9PpeCQfICEic3UAAWgLIxwRJBsbHSUREyYYJ3RDAQULexGejhueESgpl3WaCxsqJKKsChEUKywtmFoFDC4vCayikzCyMbWHt38NCTKiHhUfMyzBdQIFKsodob0VNDWzwppuKxMRrx6iNjcitNA4bh+iEzkwojc66JkOOxcf7G35PBE9KS1MEUGgIQOIFfk++KjRw9wJgUUIZvhRoyLDFCliQDQisUWLGCJOeNx4hKCGkyhPGnqCoKVLl1liypyZxUAQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+sum-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBIQChCH5BAEAAAAALAAAAAAWABYAAAIyhI+py+1/gpyUMrvm1bdhFTgfhIykYZ4pyZ2o5EZwDLSurc7ZFnqZDgLKKsQe7QihFwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_block-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUWzvNzo33GfFl5jVlonlTrr1DbvFi9vjeeNUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_bold-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIxhI+py+0Powm0VnknjVkH2AEhE45LZ55Wqn6e65TsMc5eYosbksswubJIhsSiccgvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+text_center-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUbz3Sh7yIWfFHKjVl4nmFrr1Lpr7LwkjeeIUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRSVCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmKQSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bst9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_italic-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py+0P4wqUSlQvttrkDnyaOHIdeaGRupplAIauVM3xjeeOUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_left-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+pyw0Bo5zB2UXz3Sp7yG2fFJajVjonmIor2TJvfL0wjecIXQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_right-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUfz3SZ7yIXdF4kWqZkbCqoMO7kXLC+wVOe6YRQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_under-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIvhI+py+0PowmUnhpeVVnb1DkbCI1I2JhX+Z0sOr2cTHpwK7a4rUr+hAnufsTirwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+toggle_log-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBATW1KSWfBweHATS1Pz+/Ozm1GxiTATOzPz6/Pz69ATGxKSahOzaxPzy5HxuVLSmlOTazPz27AS+vPT29NzClPTexHxuXLSmjAyKhPTy9KyehNy+lPTy5Pz29HxyXNzWxAS2tOzexPzy7IR6ZASytPTy7ASurPTu3KSSdIx+bASqrJyOdIyCbASmpJySfPzu3OzizJyKbKyijASipJSGdOTWtPTq1PTq3NS+lJySdOzWtOzi1My6lMS+rOTOrMS2nNTGrNTCpNzKpJSGZKyafLSifIx+ZHx6ZFR6bFR+dAQyNAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IigSMjoQABYkGBAeSjwAICYkKmQublJ0HDJ+GAA0OB66bpq4HCQC1lA2ZrqMCAA8QBwvBERITFIwAFa2yFgAXGL+uDBkaxRu1FQQLshwdHhgfDK4gIRoiFNYAI8quHA4XJCUMCwwMJhLm6Ce5rigEzhAMQICwYKLcuVopWgUDoWLFhQcfKNCjwOLeQQAtCFDYiAKBC28QKITk8MIgOhgxIHyQIWOGi4cfIHAogYJGjWq1bNzAkSOHjgc0dmBAgQKCUR43S1jjVeFGDx8PcNAAKePDjxg1gOCThOxFEBxBgpJQMQGpkCETEIBYSqkpkSJGOYTyOCJkgg4OIDaybXvjh5ELLpAMUYEAgQ7COPbyTWJEiY3HkCOTaruESYVamDPbQtTESedJhOgEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+top-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAw2VHSWtBRihAQOHISmxNzu9BSmxHyatPz6/Lze7CTO3AyixAQSHHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7GyavKzO3FzC3AyWvBSqzBR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSStBRSdAw+XAxCZDyexDSuzCTC1BSOtJzO5JTa7ETW3BRqlAQWJDRWbOT2/Mzq9HzG3BRmjJzS5Kzi7GS21BS+1CxSdCRmjAQOFAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8jkMMBsOp3Ip7SpHAoGhELVKDAcENmtNaFYMBoEh1hAPjwgEUlYyZ5QHpIKxALWIgUXFBgZCBUaG3AcBB1HAh4fICEiFRUjJCUhBCYnjEQCAignoikqhissKAKiJwFJAS0uKhovMDFiADIzNDUsLza2Yh4KNDcsEbW3Ago4NSUrBMBbAjQ5KRo60Mk7PATdKH5bAT0xDg4xPa236uvsShRBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+undo-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3PT69MTivHy+VJTWbIzKZEymJESmFESiHDyiHESqLAQCBFzKNGzWPFS2LNTmzCxqDDRqHPz+/KTGnBQqBAQOBAwaBESCHHy2XBxGDOzy7HTCTEyyJDSqFHzWTAwSBBQ6BIy+dESKJFySPFSSNAwiBCRGFBQmDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMsBkKotMwYAwEDiXgYLhwD0gCFZiQKxNKBYMRqPh+D6G16y5AYnYIxBJAyF4AwITTAUJdBESD4gPFBV6Fn6ABBcJDIYPGEQZGhQbHAIdfx4JHw2VSBodGwWfAR4LDSALfkgYAQurBiAhICKfSSMkvQElGyYnGyi9Rxkdj4nOskUYyU9FpxnURikdGtjRKivdRKfQ2Inh5+jpRwZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+up-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBHSWtBRmjAQOHISmxNzu9BSmxBRihHyatPz6/Lze7CTO3BSixHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7ByixGyavKzO3FzC3AyWvBS+1BR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSOtBRSdAw+XAxCZDyexDSyzCTC1JzO5JTa7DSuzETW3BRqlAQWJDRWbOT2/Mzq9HzG3JzS5Kzi7BSStGS21CxSdCRmjAQOFAQSHAAAACH5BAEAAAAALAAAAAAWABYAAAaeQIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbUGFAtGw0GFfheHByQi4S6/E8pDUoFYLm5kAEPJaBAVGxIcER0JHlEfICEiIxUkGyUmIgknKIhXASkonCorgSwmKQGcKE9IAi0uLxUwMTJWMzQ1NiYwBLBQHws1N7avXgs4NjkcCblMATU6KhvGyG87PAnUKV1MAj0+2zIFp1bg4eJJdkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_choose-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz69PTq5Pz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq70466Cl+AMxBVwnFIVRAmQHCIeBrC1L3tQgJ/SaEbeeC1PLBHE2ybFI9A1HzstHEIK6YCmhDTmBybQaHYJn7QC5zKeytIQe1+pKNE6P2yMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_detailed-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAQ+EMhJq7046817+MLQUQFRGMc4lQaSAkcMx3QltMmrDrSu/sCgEPgJhIiFk89DaL1qPRnlhsgBebWhdstVESIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_icon-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz69PTq5AQCBPz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARWEMhJq7046z2DF0PlBeAVEERhiKhqHgWyUgEsX0KczFOO7JeBYciTCImc5ITIXDKHyqhU9AnRqq9UEVDTvmLbGhin2/qAliOUot5OLc81IO5+2+8WewQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag--22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/avno2BBf/MCClSob4iBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbIQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/cunr9S8gAIRFhTCLAgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag+-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbQQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/4zT766vRI+fvHD4CPgwcJ9qg0UB85JA0dDjEQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+view_multicolumn-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq7046813+MJQfUF4BURhHGO6noSBsEcNoDJtS4KcsJQe4ncZ1HYT47HDbDqfUAnJRJmKLIGCCjjJbmE5wBI3EyOFxKCPS1EiJW52dE6vZyIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_sidetree-22:actions actions22 22:photo:22 22:R0lGODlhFgAVAIUAAPwCBFRWVFxWXFxaXExKTNTO1NTS1Nze3Hx6fLSutMzGzLy6vMTCxDQyNMzOzPT29Pz6/Pz+/PTu9Ozq7OTi5Pz2/Ozm7MzKzGxmbIyKjAQCBPTy9FROVFRSVPTq5OzOpMS+xPzu5OTKpExOTJSOlOzu7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABUAAAb/QIBwSCwaAQFBcqlsLgcBAnFQqBqqhwIiUVB4F4wGMeB4QMyPSCFQkEwmlMlCPKRC7pCKmjpxTyxzUwVmEBF6FxiDbxZyUnUFdxERhQUZbX4TDBlEAgUVkQ8DogEDAqYBTwEaAw54eQNusRMPs319Gp0PFZ8PAhMRGpLCwxOrFw/IFRuwwMICHAIEkhK4lxK0A7/Bkh0RHtvFAwp9D27MGugRAh4f29TithIW2c2SBOjgqwxv/AIS9cOEvQPBiBEFetsidOhAQFqEcCDgWLBAwR9AARFCuMPFAMwCEAsQpuMQQkS+EQ1SNkBAwuKwe+kiUDuSzU0JPyUm5HSj4Qi+Bp9A8QEIAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+view_text-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIkhI+py+0Po2ShBlOxzbP7n2yaJoLm+ZTcxqHuC6hXzML2HVEFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_tree-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz+/Pz69Pzu5PTq5OzaxBQOFOzKpFRWVFxWXOzexPTexCH5BAEAAAAALAAAAAAWABYAAARPEMhJq704g6A779kHCORAgNskFMYhakE8FkjyBcoWv+JwJItXaELYCTFHlCSpZKKcoB5jYHpOGgUadLKbIRw3jhEzQDyCSuI4zW673yhDBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+window_fullscreen-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBNTW1NTS1MzOzMTGxLy+vLy6vLS2tKyurKyqrKSmpKSipJyenMzKzMTCxLSytFxaXPz+/Pz+9Pz+7IQCBMzOvMzOtPz+1MzOrPz+5Pz+3MzOpMzOnMzOxAAAACH5BAEAAAAALAAAAAAWABYAAAWxICCOZGmeKBqsbOu+rjAQRFEYxoEkibIwjUZMRnAUHjkEpPcLriLQqHQ6XRUk2Kw2O+lSKIUVoUKubLflikVcPnO75cvKkXZL4HG2pK31lilqc1lmfRNfgBQYGBlidl5fGhobGxqMAQNnXYaQkZOLjVgVmpsUkRoVnpZje2SkphtlGBUcbH+br5NptAF0rYe4G4plHSseaaW4irLDcxYOFtDRFhnU1B3X1zDa2indIwYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+window_nofullscreen-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBNTW1NTS1MzOzMTGxLy+vLy6vLS2tKyurKyqrKSmpKSipJyenMzKzMTCxLSytFxaXPz+/Pz+9Pz+7IQCBMzOvMzOtPz+5Pz+3MzOrPz+1Pz+zMzOpPz+xMzOxMzOnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBwSCwaj0hkYMlsOp9OwYBAKBQMhgMikVAsGI1GVEpwFB5ZBKT7DS8j8Lh8Pl8WJPiJfr/PTygUBUsEEhV4h4h+ExUUFoMVkIWJhxWLkBeDhZCGiXqbFRiYAYSanId7mxihSwOlphJ6gJ8ZGksOiqd/gKoYGRmipIh7gBSqvhkbtaOuw7sYn8mseJuxxcabGxwdmZ/EvL6f2o+Qz869yBUem9sBH4sYf7znG/Qb6h4gSx8fDh8W/wA1CBTYoSCIfFASQknCcIiBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+wizard-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBNzaTPz6BAQCBPz+BExKBMzOTPz+rPz+3ISCBPTyhISCLISChPz+xOTiVPz+/MTCxKSipKyqrExOTDw+PDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAV+ICCOZAkEZqoKqoqKAzHAb1sIxhAQwWAQhRaJd0AcdgkhqaBAOBUL5WjAaD6TUqog0DAildqcg+cDtgaPACTCiM0AOhV6sG4DWOAHnf2uyfV1b1lsgVIwEgwTFHaGA2yKFYJgiJCSQo6JFJGGcJSalkKPn5wimZukAJWoIgYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
diff --git a/ext/tk/sample/tkextlib/ICONS/tkIcons.kde b/ext/tk/sample/tkextlib/ICONS/tkIcons.kde
new file mode 100644
index 0000000000..0d5b2c8695
--- /dev/null
+++ b/ext/tk/sample/tkextlib/ICONS/tkIcons.kde
@@ -0,0 +1,195 @@
+actattach16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBPz+/AQCBAAAACH5BAEAAAAALAAAAAAQABAAAAI2hAOCxg2h0nJHyEshi9HpxU1GOCLdZoKpQ15nibUoprKp9lh2oucUxsBRXsJh4Hjs/QTMpr8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmark16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actbookmarknew16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQyNKSipAQCBMTGxKyurISChJSSlJyanHR2dIyKjPz+xISGhPz+BGxubMTCBHx+fPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVfICACwWieY1CibCCsrBkMb0zchTEcNYsIiYHiwIOdEAvigdFQGE0Ix4NBbSAgsWjk+jBIAlcUYrJASChnSXZSoUDelKfoKpFALJA61ueGI2IAZmhogGFmCGGAgXsifiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actcheck16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBMT+xATCBASCBARCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAM2CLrc/itAF8RkdVyVye4FpzUgJwijORCGUhDDOZbLG6Nd2xjwibIQ2y80sRGIl4IBuWk6Af4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actcross16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBMQCBEQCBIQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMuCLrc/hCGFyYLQjQsquLDQ2ScEEJjZkYfyQKlJa2j7AQnMM7NfucLze1FLD78CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBDQyNHR2dCH5BAEAAAAALAAAAAAQABAAAAI4hI+pFrHb3nEg1iWiDiINCwYDko0V9XUTda6I1TIsUMpGinyzbB6ZeGuoEr+GUDL4CXqSphPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+acthelp16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQ6XAQCBCyCvARSjAQ+ZGSm1ARCbEyWzESOxIy63ARalAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EEgQqhUz00GEJx2WFUY3BZw5HYh4cu6mSkEy06B72LHkiYFST0NRLIaa4I0oQyZhTKInSq2eAlaaMAuYEv0RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actitemadd16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBARCZPz+/Mzq9BTC3ITC1HSyzGSivAw+XBSStIS6zHy2zAQCDFyatAQOHFSStEyOtAQSJBSq1DR2nCxunCRmlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICCOQTmeaCAMRIC+AVu47xkTBl2Ld16XQNYBQTQBVIOkMHFQJBeMI4tAbSSu2IRDSnhAvFfI97sFRM6RwOMacbjLKckVvgvIJ5EdSU7J648VgXQ7Dmd/hyJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actitemdelete16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBARCZPz+/Mzq9BTC3AQCDAQOHFSStAQSJAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQwEMhJq704681n+GAISoEwnGg6EAUQrEQsz4ThEkeu77kNIAagMEj0dY7IpHI58UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actredo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxOHBxSHBRGHKzCtNzu3MTSzBQ2FLzSxIzCjCSKFCyeHDzCLAxGHAwuFDSCNBxKLES+NHSmfBQ6FBxWJAQaDAQWFAw+HDSyLJzOnISyjMTexAQOBAwmDAw+FMzizAQODDymNKzWrAQKDAwaDEy6TFTGTFSyXDyKTAQCBAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ2QIBwSCwaj0hAICBICgcDQsEgaB4PiIRiW0AEiE3sdsFgcK2CBsCheEAcjgYjoigwJRM2pUK0XDAKGRobDRwKHUcegAsfExUdIEcVCgshImojfEUkCiUmJygHACkqHEQpqKkpogAgK5FOQywtprFDKRwptrZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actreload16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCRaJBxWJBxOHBRGBCxeLLTatCSKFCymJBQ6BAwmBNzu3AQCBAQOBCRSJKzWrGy+ZDy+NBxSHFSmTBxWHLTWtCyaHCSSFCx6PETKNBQ+FBwaHCRKJMTixLy6vExOTKyqrFxaXDQyNDw+PBQSFHx6fCwuLJyenDQ2NISChLSytJSSlFxeXAwODCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIBQGBAMBALCcCksGA4IQkJBUDIDC6gVwGhshY5HlMn9DiCRL1MyYE8iiapaSKlALBdMRiPckDkdeXt9HgxkGhWDXB4fH4ZMGnxcICEiI45kQiQkDCUmJZskmUIiJyiPQgyoQwwpH35LqqgMKiEjq5obqh8rLCMtowAkLqovuH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actrun16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChKSipMTCxLS2tLy+vMzOzMTGxNTS1AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJQqDYyiDGrR8oWJxnCcQXDMU4GEYqFN4UEHB+FEhtv7EBIYEohkjBkwJBqggEMB+ncHhaBsDUZmbAXq67EecQ02x2CMWzkAs504gCO3qcDZjkl11FMJVIN0cqHSpuGYYSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actstop16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/Gw6NGQuLHQ6NGQmJFweHFQaFPTm5PTa3PTW1Oy+vOS6tNSinKReVDQWFPz+/Nx6fNyCfNyGhNR+dMxybMRiXLxGRIwWFNx2dNx+fNx2bMxuZLQWFBwWFPTu7Pzy9NRqZNRuZMRSVLwmJGwWFNR2dMQiHPTKxMxmXMQyLMxmZNx6dMxiXMRSRMRaVKxybMxaVEQWFMQuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaaQIAQEBAMCAWDYcgkHhAJxYLRcDQBggckIplQKpaLdRh4YDIaSWa94Vw6woAHgv6AMKGPaMQhwQMJJRkfhHmEJhdvRCcgGSCEkCgpbnAECiorGYYfLCItlAAFCygQj5AfbYlwBQwVE5AukG6KBi8tMC0fLi0pHxyzcAAxFxwmMny/wEwOxMm/qlcdJCSJ1H5XQh3a28HY3kx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actundo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxSHBxOHMTSzNzu3KzCtBRGHCSKFIzCjLzSxBQ2FAxGHDzCLCyeHBQ+FHSmfAwuFBxKLDSCNMzizISyjJzOnDSyLAw+FAQSDAQeDBxWJAwmDAQOBKzWrDymNAQaDAQODAwaDDyKTFSyXFTGTEy6TAQCBAQKDAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ1QIBwSCwaj0hiQCBICpcDQsFgGAaIguhhi0gohIsrQEDYMhiNrRfgeAQC5fMCAolIDhD2hFI5WC4YRBkaBxsOE2l/RxsHHA4dHmkfRyAbIQ4iIyQlB5NFGCAACiakpSZEJyinTgAcKSesACorgU4mJ6uxR35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbook16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBDyKhDSChGSinFSWlEySjCx+fHSqrGSipESOjCR6dKTGxISytIy6vFSalBxydAQeHHyurAxubARmZCR+fBx2dDyKjPz+/MzKzLTS1IyOjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOZGmKQXCWqTCoa0oUxnDAZIrsSaEMCxwgwGggHI3E47eA4AKRogQxcy0mFFhgEW3MCoOKBZsdUrhFxSUMyT7P3bAlhcnk4BoHvb4RBuABGHwpJn+BGX1CLAGJKzmKjpF+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appbookopen16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExCNGSenHRmVCwqJPTq1GxeTHRqXPz+/DwyJPTq3Ny+lOzexPzy5HRuVFSWlNzClPTexIR2ZOzevPz29AxqbPz6/IR+ZDyKjPTy5IyCZPz27ESOjJySfDSGhPTm1PTizJSKdDSChNzWxMS2nIR6ZKyijNzOrOzWtIx+bLSifNTGrMy6lIx+ZCRWRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQEAAQCwWBYJiYEAoGAFIw0E5QCScAIVikUgQqNargtFwdB9KSDhxiEjMiUlgHlB3E48IpdKdLCxzEAQJFxUTblwJGH9zGQgVGhUbbhxdG4wBHQQaCwaTb10emB8EBiAhInp8CSKYIw8kDRSfDiUmJ4xCIxMoKSoRJRMrJyy5uhMtLisTLCQkC8bHGBMj1daARgEjLyN03kPZc09FfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appboxes16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbox16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECKoR6ys2IVqokF08yMTA1gwkYX5WQK5ma4VceTYPxXnBWdtY6+0834/Bowgzm6APWRQcH4TiMhPK2WYRiZWW7XK7/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbrowser16:app app16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxONCROfCRKfKx6LNy+bNTOpGSS1DRupAwyXBRSnPTSjPTqvOzqzMzSvHSSlKy6ZDxutAxCpBQ2XBxepLTKvPzqzPzy5OTShLS2dLSqRFR2jBRerBQ+jOTixOzetNS2XHx6XDR2tCRexBwyTDyKzOTavPzq1OzKdCx23BRKtCQ6VCQmHFSa7IyirOzSnGSGpIR+bFSO1DyK7DR+5CRixBw2VDQuHFye7IS27NzGXISuhEyS5DR25BRWxBQ+lBQyXCQqPCxSfGyu7GyerKy2ZFR+rERqfCRmxBROtBQ+fBwuTBwmNDSW9JyabLyqRIx+TExSXBQ6bAQCBBQ6ZBxapDR+zBxq3LyaLJySRHxqPGxeNBxGbCRmrHRyRERONDRKNDQ2JCQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhgABAQIDh4MBBAUGBwgDCYcKCwwNDg8QERIThRQVFhcNGBkaGxwdoYMDHhcXHxggISIjEiSvJSYXJwsoISkpIyorLIIDLS4WLzAxMjM0NSo2N8o4OS46OzwzPSk+P0BBgkI8Q0NERUZHCEhJSktMgwk4Qy1NTk9QUVJLphCiUsWKlStYsmjZQiJgIS4KuijQ4iXAFxYCDVFJwGUFmDBhMjYSw0KMyEYoBfkJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appcalc16:app app16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChPz+/AQCBCH5BAEAAAAALAAAAAAQABAAAAI4hI9pwe0Ogpi00hHF2LzzzFlTsIHD45SSx6oCeW4wjK2tl83y7t64pIsJaxrfh2bEAJIlhRPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appclock16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAALy+vAQCBPwCBMQCBIQCBISChPz+/MTCxCH5BAAAAAAALAAAAAAQABAAAANbCLHcrSLKOZcYmDSCsR1aUABAsXDDJwJGa5SBFwgaWxbCG3CWaBwG3C8Y67FawpYiNQscg65fsVkYuoAmJs1pBR522lQB6ILJLqHRwQQOZzYdZnw+dzruDIA/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appdate16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQCBMQCBPzCxAQCBPz+/MTCxISChDQyNKSipEQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARDEMhJZRBD1H2z3lMnjKCFjUJQimOgcmcbELCXzjXq0hV785WCQYcDFQjDXeloMByKG6YTAdwIDAlqSZJSVFeKLcUfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appsheet16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPz+BAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANFCBDc7iqIKUW98WkWpx1DAIphR41ouWya+YVpoBAaCKtMoRfsyue8WGC3YxBii5+RtiEWmASFdDVs6GRTKfCa7UK6AH8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+apptool16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptools16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTERCRAQCBOzu7Nze3MzKzLy+vCxqZBQ2NJyanKyqrGRiZDRydKza3FRWVPT29LSytDw6PMTm5EySjCxaXGRaJFSanCRSVGxqbPTmvMSqVJTW1GSurHS6vOzq7KSipISChFRKHJSGNPz23GxKFBQ6PKyurCwqLMyufJx2RAQGBJSWlEwyDIRiLNy+lLSKVDwmDJRuNOTOrLyabGRCFDx2dKSCVOzWtHzCxOTGnNSyhAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwCAgIBAOiUiggFAyHASKxDAwUC8Zg0HAglA9IZPGQABoTSqJCFTIOEIsFgHBcEhhHUpKJFCwaGxYYHB0VEx4IEh8gIQwiIyQbJRMcHokmEicfDygAkCkqJQgIGG0rLElCLS4vMCWqQwMCQg0UMTIzNDVLQjaIGDE3ODQlS785CEkxKjowvEOHybG4O6JDCdNKuDUxRAmxRDHeveUAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appuser16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxISChMT+/ATCxASChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMg5gw00yyDGIAR1YUDggeFWFIZhnSBZrsZxdIOFEGTA2oeBAHeyuGwvzxBlYdUOLROMFzDQntJPrNoqAKUBaqnV+k57ZORruykHDj2LqIzUVKp1u0iuB/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appusers16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxISChAT+BMRaBPyqXARCBPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEIRJa5Ui673nsGAgeKE1Bl9AUEXbiqTlFlZaGUZoszm4BzhDAVf5BYbAXI+TAR6CS2ZGSZSEiIIqYIsSIEaJ7GRrlY7J1lKA7I8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appwp16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBKSinJyOfPz27Pzy7AwKDExOTJyWlERCRKSelPz69LyyrKymnPz+/MS2fDQyJAQCBOTazLSiXOzivMS2jKSSVOzmxPz25NzSpPTu5KyebOzixNTGjOTWpMSydMSybCwqFGReVKyaXNzSnGxeNJSCVMS2nPz23MSuZIR+bJyShLyqnOTOtGxiXIR6XOTSvIx6RMSubIyCdKSalMS6pOTWxMzKvKSabJyKTOzezHxuPGRmZKyurMTCvPTq3AAAACH5BAEAAAAALAAAAAAQABAAAAajQIBwCAgIiEhiYEA4FgwHRDKhIBAWz4OhgGQ0FAPHA7qFEBONb0Qy0ULeQ2+aUrFcMI+3GYBOZzQbHB0eHyAhIQByDREiEwMjFRIkJQImAgJ+jScjHigkKSorLC0AKg2NFSMoki4qCy+IQgITKDAxkjIzNDWkQxQoJaskMgk2Eb1DNzgoOCoHDDY5yEIwJToAOzw9ET7TQiREAhkZ3kmy5QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal1day16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANOCLrMEUDIOUS9AFLLhx8LIRZjKYZmMRCkaChFLHty/AIiS3y6q+QtT49wq8VotRtQJGwRf6Zmrlj7DJLQXsupTJmeEIN4TB5nII20wp8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal5days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANMCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiIdMmcec7jy53q81qP9OO5VMAj8RXTFWzOZW95HDLdEEM4LA4nIE0zgp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal7days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANPCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiwcp0fucsj873qvGMv5Jw2FIACUsW4WakGW1O046I05qmGYBhTC6TM5CGWuFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calappointment16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxPz+BISCBISChKSipAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARbEMhJaQhA6D1E/wDGeeRgDhOhFoTBEi+REgdrIHScSEVvAD9Xr7cDqGSGpFEnQSqTv2NxCFQOiU1VEAiTZmstHFg1vQKuw+LxxfYaV/AuOQRI2O/4ewhT6Uv8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calbell16:cal cal16 16:photo:16 16:R0lGODlhDwAOAIIAAPwCBISCBPz+BIQCBMTCxISChPz+/AQCBCH5BAEAAAAALAAAAAAPAA4AAAM+CLrR+zCIAWsgLVRGRBhOVQiG94WPVAbHaZHYAWqRYLbge88RsbInGuBCEhRYrZYm4xk4nYdoKzKIbiKHawIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+callist16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/KSipPzerMRaBEQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARDEMhJaQhA6D1E/wDGeeRgDhOhruyatjBRSIRxxOsMEAdC0BUZDcfSEYvDo3Bn++2Cxt7RqFxWhZiCdsvdhjCVsMQfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calmonth16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANSCLrMEUDIOUS9AFLLhx8LIRZjKYbiRxLFIBpK0Q6z7MkwkJIe8b0KEeuWchFysuStVsjtfMbeMQitWpG25YfmNK1WU53XNIUYzug0OgNpuBX+BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+caltoday16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxKSipPyCBMRaBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARTEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyIQhFfiBIAfuFzaAioBIJBCummRYPCaDPh3vhwsOZdihNfa8Ub/AJXemFZPPNBvGwG672yFMZS7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+caltodo16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBAT+BAQC/AQCjPz+/MTCxPzCxKSipPwCBMQCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARaEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyMYhFXiuFwZiA6qZYbbqJX5BIw2RAPxwAAWCyWMCCsiXFGEEErKz6LQZfOqiTR1YJiGq1rFyyHmo2+/1EKbCl/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connecting16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZbihUiz60FPnfaA0iBpBVGdHEYWxToEoSHBRHHM9AgSEQRcj+AYkYAJxIPKQFUJiOdTJQFIDU6dYzKKFhTCM+E5g4mXaDAyrlogEG+DGTecA7wsP8EcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBAQCBERCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEMhJq704axBEHoPUEdhQGMNYFuwxkKInDYjBniEnwMCQIIebSzXx/WwsFK+YMABZikWuYlrUCtZpEYv4WRPaHhb064YB41kCfJFSQBh/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connectyes16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipDQyNMTCxMTGxISChFxaXMzGzAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZxCjgsAtDtUlCOA1gJQ4kl/IDatAoF7xxkS6GgEBr6jAobCyBX42SQBxMOx6A8MhiGASR8YDgrYsNEeJ0zaEGZY7uoH2oB6nOUwtbdLaVOeTUwo/8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devdiskmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKROzSrOzKpOTGnLSafLySZKxuLMSOVPTWvPzixLSehNyibOzOrGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTOpHxOJKyKXFw+HKSipISChMTCxFxaXIRiPNSWXExOTOS2hLR+PLRyLPTWtMyOTASCBARCBPz+/DTSJIyKjIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwrA3HQ7scQAqFAcEQOUi0zAkFUSFYLghMBloUCDQNGxwdHhwHekcfICEhICIfIxkLJBABJUYCICABIhAOBiYnKJaXmH4CGSkYCCqkSAEfTKenrkOwsrQll0IrS7G5uwArLLaxLbXCLsTFLyDBKy4wZEVHvCwsRn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devdiskunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKRPTWtOzKpOTGnLSafLySZKxuLMSOVOzOrPzm1LSehNyibGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTWvHxOJKyKXFw+HPTOpKSipISChMTCxFxaXIRiPHxaNLRyLNSWXExOTPzixOS2hLR+PMyOTPz+/IyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwGgiD46FdDiCFwoDQAEe0TMkEQSFULIcLBloUCDIaDRscHRsNHhhHHyAhISAiHyMkJSYQASdGAiAgASIQKA0pKguXmJl+AiQGFwgrpUgBH0yoqK9DsbO1J5hbsrq8SrgstlJFHy0gwMVFR1J+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devfloppymount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVrICCOQBCQKBkIw5mqLFG47zoQ+FwbN57TosDhgPD5dMEEIqE04kwlBWKBUEiNVYFpyqAyGEUCgqEtERiNNMLhQKzLQYJg7n7Y4aMAwbCUPvAQeWNgfzQQETAIhSMQEogwgBITQEGGEREmfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devfloppyunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVCH5BAEAAAAALAAAAAAQABAAAARcEMgJQqCYBjFu1hxReN82EOhYGieaklJwHIjrqnGCJLqNWhUFYoFQCG1FgWXIIDIYNQKCoawQGI0swuFAbKsxgmDsfZjBkwDBsNM90Jot9A3DbBD0Dwiur9QnfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devnetwork16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBISChPz+/Nza3ARaZESanCyKlARudARGTLy+vNzq7ARmbMTCxARufAROVMzOzKSipARyfOzq7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVmICAGZFmKQiACweCSBImq41AYB5IodLq2hwWO0ejRWDac48Gb/QKNqNRoqspmrVcAUuIJBANS8sBIFCORUgooPEh4J8B67NgdsVBp9C5XWfl9LRMTCyReX19hARNojWlWLH+AAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devpc16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBISChHx+fPz+/AQCBAQC/AT+/AQCxAQChAT+BLy+vAR+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEIAgqK1YzsG754QUDERpmkEpkkXrtoK6EcVgHIibhnNx564Yb0TDvQq7FQ34EiqPOhnREqhWSUPsyZSQAbbg7GcMEgwUiYVivTa1R+y4XEGoWO/4AMAfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscanner16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MT+/ASChARCRATCxMTCxFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJgqWBVivEldkUdKSXhVjZfenommglDERh3Tc4E4ZRHAGgkEPr9X6H5AHBERSMRyWzkug8jQXFEhWoOo8dRYxqLXSmGjIJnVaz29Q3fAP3RwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devscreen16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devspeaker16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXAT+/DQyNATCxMTCxPz+/AQCBKSipASChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgJQqCXziDG2JoUEENhZBkmHIWJVptAmqcIW/Js1MiF56TBzkckAAcHoa9nMRKeA4TyJk0knsHhTeK5khBaH2VwLYVh40TJhQ6RzeIQV32Quz8hfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXPwCBNze3GxubERCRPz+/Pz29Pzy5OTe3LS2tAQCBPTq3PTizLyulKyqrOzexLymhLy+vPTy9OzWvLyifMTCxHRydOzSrLyihPz6/OTKpLyabOzu7OTm5MS2nMSqjKSipDQyNJyenLSytOTi5NTS1JyanNTW1JSWlLy6vKyurAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAaUQIBwCAgYj0eAYLkcEJBIZWFaGBie0ICUOnBiowKq4YBIKIbJcGG8YDQUDoHTKGU/HhBFpHrVIiQHbQ8TFAoVBRZeSoEIgxcYhhkSAmZKghcXGht6EhwdDmcRHh4NHxgbmwkcCwIgZwqwsbAhCR0CCiIKWQAOCQkjJAolJrpQShK2wicoxVEJKSMqDiAizLuysiF+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcut16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIwhI9pwaHrGFRBNDdPlYB3bWHQ1YXPtYln+iCpmqCDp6El7Ylsp6ssR1uYSKuW0V8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editdelete16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPT29GxubMzOzDQyNIyKjHRydERCROTi3IyKhPz29Ox6bPzCxPzy7PTm3NS6rIQCBMxCNPTq3PTi1PTezMyynPTm1PTaxOzWvMyulOzGrMymhPTq5OzOtNTKxNTOzNTCtNS+rMSehAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaKQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhSEQkFgrBAcr1URiPhKAsDD3QB8RhA3FM0IlLHnyUTVBMSFBUWfl0XGBMTGBcZGodmcQWKjpAbHIgIBY2LHRoempOdjooTGx8giIOPFYofISJ+DyMXI6AfFySyfiUmJSUnKBYcICIpfgELzM3OZX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVMR+RPzKjNze3AQCBMR6RPzGjPyODPz+/MzOzPyKDPyKBPz29OTWzPyGDPyGBOx6BOza1OR2BKROBNSOXKRKBBwOBOzu7PTWxPzizOySZPyCDFxaXOy2lNRyRMxmJCQOBPTm1OzStPTKrMR+XIRWLFxGNCQSBDQyNIRSNDQuJERGRLyqlNzSvIx6ZKRuVEw6LLSyrLymhKSShBwaFFROTJyWjMS+vNzW1OTazNzKrHRqXOzezOTOpPTq3OzWvOTStLyedMS+rLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAewgAAAAYSFhoQCA4IBBI2OjgUGBwiLBAmXlpcKkgsMlZcJBA0JDpIPEBGVjwkSBgOnExSfmBIVBxAMExYXswkYGRobHLq8gh2PHhoeHyAWIYKzIiMkJSYnKCnQg5YNHtQqKywtK9qMBC4vMDEBMjIz2dCMDTQ1Njc4OToz5PEEOzw3ZPToMcLHO23HfogQ0QMIkCA+hPBbhAPHECJFjMyYIUQIvEUpUqwQOXKkSEF+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQiFHRqNIx+LFxSBDw6PKSaRPz+/NTOjKyiZDw+POTe3AQCBIR2HPT23Ly2dIR2FMTCxLS2tCQmJKSipExGLHx+fHR2dJyenJyanJSSlERCRGRmZNTW1ERGRNze3GxubBweHMzOzJSWlIyOjHRydPz29MzKzIyKjPTq3Ly2rLy+vISGhPzy5LymhISChPTizOzWvKyurPTexOzSrDQyNHx6fCwuLGxqbOzKpMSabAQGBMS2nLyulMSidAAAACH5BAEAAAAALAAAAAAQABAAAAa7QIBQGBAMCMMkoMAsGA6IBKFZECoWDEbDgXgYIIRIRDJZMigUMKHCrlgul7KCgcloNJu8fsMpFzoZgRoeHx0fHwsgGyEACiIjIxokhAeVByUmG0snkpIbC5YHF4obBREkJCgon5YmKQsqDAUrqiwsrAcmLSkpLrISLC/CrCYOKTAxvgUywhYvGx+6xzM0vjUSNhdvn7zIMdUMNxw4IByKH8fINDk6DABZWTsbYzw9Li4+7UoAHvD+4X6CAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbGxubMzOzPz69DQyNIyKjERCRPz29PT29OTi3IyKhPz27PTu5PTy5Pz6/Pzy7PTq3OzexLyqlPTm1PTizOzavLyqjOzWvOzaxLyifOzizOTOpAQCBOzezAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaEQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhWEQkFYYHkeqkMxKFBFpq9jgdkEGlPqwrJhCIY2N8FFRYUFxcYGX9dgRKEGhiHiYEOhBcbGBwdiQEOARcBGwEeAZllAgEUnQEfoQEgmp4hrCKtrwEYsrRlTiMBJAG8syN/IyMAxMXHSH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edittrash16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipFxaXPz+/MTCxISChDQyNCH5BAEAAAAALAAAAAAQABAAAANQCKrRsZA5EYZ7K5BdugkdlQVCsRHdoGLMRwqw8UWvIKvGwTICQdmGgY7W+92GEJKPdNwBlMYgMlNkSp3QgOxKXAKFWE0UHHlObI3yyFH2JwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileclose16:file file16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCQiJBwaHAQCBDQyNDw6PFxaXFRSVERGRCwqLAwODGRiZHx6fPz+/GxqbAwKDCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVaICCOZGmeqBgEwjCkRGEcSKK4JrEcBrMgAdeLVDg0GguGsYEbBQyGYyN6FDoPDIf0+LCKBIgetQERDgGDBGIpNY8GioAU0m6KXFw883w3+/l9f4AkfimGIn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filedocument16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJSWjPz+/Ozq7GxqbJyanPT29HRydMzOzDQyNIyKjERCROTi3Pz69PTy7Pzy7PTu5Ozm3LyqlJyWlJSSjJSOhOzi1LyulPz27PTq3PTm1OzezLyqjIyKhJSKfOzaxPz29OzizLyidIyGdIyCdOTOpLymhOzavOTStMTCtMS+rMS6pMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaQQIAQECgajcNkQMBkDgKEQFK4LFgLhkMBIVUKroWEYlEgMLxbBKLQUBwc52HgAQ4LBo049atWQyIPA3pEdFcQEhMUFYNVagQWFxgZGoxfYRsTHB0eH5UJCJAYICEinUoPIxIcHCQkIiIllQYEGCEhJicoKYwPmiQeKisrKLFKLCwtLi8wHyUlMYwM0tPUDH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filefind16:file file16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBCQmJDw+PBQSFAQCBMza3NTm5MTW1HyChOT29Ozq7MTq7Kze5Kzm7Oz6/NTy9Iza5GzGzKzS1Nzy9Nz29Kzq9HTGzHTK1Lza3AwKDLzu9JTi7HTW5GTCzITO1Mzq7Hza5FTK1ESyvHzKzKzW3DQyNDyqtDw6PIzW5HzGzAT+/Dw+RKyurNTOzMTGxMS+tJSGdATCxHRydLSqpLymnLSijBweHERCRNze3Pz69PTy9Oze1OTSxOTGrMSqlLy+vPTu5OzSvMymjNTGvNS+tMy2pMyunMSefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCAAECA4OIiAIEBQYHBAKJgwIICQoLDA0IkZIECQ4PCxARCwSSAxITFA8VEBYXGBmJAQYLGhUbHB0eH7KIGRIMEBAgISIjJKaIJQQLFxERIialkieUGigpKRoIBCqJKyyLBwvJAioEyoICLS4v6QQwMQQyLuqLli8zNDU2BCf1lN3AkUPHDh49fAQAAEnGD1MCCALZEaSHkIUMBQS8wWMIkSJGhBzBmFEGgRsBUqpMiSgdAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filenew16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz6/GxubNTKxDQyNIyKhHRydERCROTi3PT29Pz29Pzy7PTq3My2pPzu5PTi1NS+rPTq5PTezMyynPTm1Pz69OzWvMyqjPTu5PTm3OzOtOzGrMSehNTCtNS+tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ/QAAgQCwWhUhhQMBkDgKEQFIpKFgLhgMiOl1eC4iEYrtIer+MxsFRRgYe3wLkMWC0qXE5/T6sfiMSExR8Z1YRFRMWF4RwYIcYFhkahH6AGBuRk2YCCBwSFZgdHR6UgB8gkR0hpJsSGCAZoiEiI4QKtyQlFBQeHrVmC8HCw21+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBOSmZPzSnPzChPzGhPyuZEwyHExOTFROTFxaVFRSTMSGTPT29Ozu7Nze3NTS1MzKzMTGxLy6vLS2tLSytDQyNOTm5OTi5Ly+vKyqrKSmpIyOjLR+RNTW1MzOzJyenGxqZBweHKSinJSWlExKTMTCxKyurGxubBQSFAwKDJyanERCRERGRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaRQIBwGCgGhkhkEWA8HpNPojFJFU6ryitTiw0IBgRBkxsYFAiGtDodDZwPCERCEV8sEk0CI9FoOB4BEBESExQVFgEEBw8PFxcYEBIZGhscCEwdCxAPGA8eHxkUGyAhIkwHEREQqxEZExUjJCVWCBAZJhEmGRUnoygpQioZGxsnxsQrHByzQiJxz3EsLSwWpkJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileprint16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPT29PTu7PTy7NzClOzm1PTu5LSabJyanPTm3FxaXOzCjOTKrOzi1OzaxOTSvJyenGRmZLyyTKSipDQyNERCROTi5Hx+fMzKzJSSlIyOjISChLS2tAT+BDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaYQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAoEAuGIdGITgWOq4LxcCQgZkEkIHksHgYJOR6ZQCgVFhYJFxgTBVMZihoCfxUYDWUbUBGKGREcjBoQEB2TAB4CAx+Vl5WMhyACHiEhH6IfIiMktCQgE0cZJQStr6O2t6EARxO6vK6iEx4dZsMCxbsmBB4nzUTEutVSSUdmfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRSVMTCxKyurPz+/JSWlFRWVJyenKSipJSSlOzu7ISChISGhIyOjHR2dJyanIyKjHx6fMzOzGRiZAQGBFxeXGRmZHRydGxqbAwODOTm5ExOTERGRExKTHx+fGxubNza3Dw+PDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaAQIAQECgOj0jBgFAoBpBHpaFAbRqRh0F1a30ClAhuNZHwZhViqgFhJizSjIZXQCAoHOKHYw5xRBiAElQTFAoVQgINFBYXGBkZFxYHGRqIDBQbmRwdHgKeH2YgHpmkIR0HAhFeTqSZIhwCFIdIrBsjAgcPXlBERZ4Gu7xCRZVDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderhtml16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBERGRBQWFMzKzOzq7CwqLDw6NARqnAQ+XHR2dKyqrOTm5ExKTERCRHRydMTi7NTu9HS+1KSmpBweHDy67DyixHS61ITG3AxypByu7DxinBw+ZERmdIySjITC3ARypExOTDRurIR2RPTSdJyulEyGvBw+bFSyzJTK3LzKvPzivOTixNTChLSybGyCfCRSnBQqRASGtFyuzDw+PCRShPzy5OzerOTShKyaTEx6pCxerGRufBR+rOTezPTShNy6bER+1BxCfBQuRAxelFSixBw2VISq3GySrPTWlHyanIyitFSO3IymtCRujAxWhCRqlCQ6XGyWvNS2bFyGvDxuvCRSpLy+vMS+vGxqbFyO1GSi3EyO1FRaVCQuPLS2tDxyzKyWNFxaNCQyPGxubCxajERSVExKNJyenAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAECg4eIAAMEBQICBomDBwgJCgsEDA0BDg8BhwYQERKUDxOYDAyeghQVFhehGBmVlwwOqxobHB0eH6EfIAkPIYIiIyQlJhsnKBcpvrYiKissLS4vMDEyFjOvNAA1LDY3ODk6Oyc8PTIyFzQ1Jj42P0A6QTtCQ0REIEUORkdIkihZwsSekBhNnDyBciCKiSNSplDRUcWKkRhXCGDJYgiGli1cpuTocsILjytfFmRpACAGRTBhRogZgzHlAjKGWnIoY+bMgRgBDHRBo/LAIZoxuhwKatRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folderlocked16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQSFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpOzm5GxqbCQiJMTi7NTu9HS+1HRydOTm1Ozq7Dy67DyixHS61ITC3AxypERGRBweHByu7ASGtFyy1DSOtDRmfExOTBSazBR+rCwqLAxWhAxelByGtDSaxAwODHy+1Dw+PPT29IyqvCxujOzu7NTW1Nza3ExGJJyebKyqfMTCpFRSPOTi5DQqHOTezDw2NMTGxKyqhMTGrGxmXDQ2NMTCxMTGpHx6bHx2bBQWFIyOXDQuDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomDBwgJCgsEDAKFDQGHDg8QEZQSlxMUDJ2CDhUWF6AYGZWXFBqCGxwdFh4XGK8fIAohtiIIIx25EZwBDREHgiQjJSYmGScoKSoRKQ8rggIsDC0uJS4oGygoAyjdAAcsLxQUMDEyMzQ1EzapBy8MDDc36tFwgONFjlQ6dgCEEZBHDx8+ctRIRehHAyAwZASZIGRIEBoUBwUwIGMCiwFEaBQJichIjo9FZLBsacRIAB0A/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+foldernew16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBPz+hPz+BOSmZPzSnPzChFxaXMTCBPyuZPz+xPzGhEwyHExOTPz+/MSGTFROTPT29OTm5KyurDQyNNza3Ozq5Nze3LR+RLy+vJyenMzKzNTS1Ly6vJSWlFRSTMzOzMTGxLS2tKSmpGxubBQSFAwKDKSinJyanIyOjCQiJERCRERGRBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaNQIBwSCwaj8ikcokMCIqBaEDoBAQG1meAUDAQpIcBQoy1dg2JdBqhECgQ1IWB0WgcBIOBwIHXBwwPEBEREhIBbG4IExR/DBUVFhIXV2NjDVYYDY8SFU4ZVxpVAQwbGxynGxkdTh6XVh8gGSGzGSITIxokJUImGSMTwLcnKCkprgAqDSt1zCssKxQtQ35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderopen16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailforward16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRydHxubHxmZGxiXHRmZFxOTFxGPFxKTPwCBLymlMy+pOze3PTq3PTu5Pzy7LSmnOTaxOzm5LyqlNzOtPz69Pz27MzCtLyqrPT27IRubPzuzNTGvNTCxLSelPz25Bw+ZFxKPPzy1Pz65LyupBxKdCxWfPTm1Pz23LyinBxGbGzO5DRafBxWfBxajCymxHTS5BxSdBxKbFTK3EzG1CSGvCyKvCSSxCSavGTO5GRaVPzqzFzK5EzG3BSCtAwiPGxaVPTivPzy3NzKpBxObCRefBxqlPTmzJR2bKyahAwyRPzmvOTOpKyObNS+nPz21AQOFKyOfPzuxAQCBGRORLSadPzyzLymjMy2lOzetDwuJFRCPEw6NEQ6LEQyLEQ6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAQABAAAAfhgAABAgIDBAQFBgcIBwmOCQIKCwwNDg8OEBESjY8CDBMUFRYVFxgZDJyOGhsPChwVHR4fFSAhjwkaIiMOJBQQDRUVJSa3GicoHw4pEA8SGSorLI8tLtQu19gqLzDECTEyMzQ14zY1Njc3ODkqCTo7MjIxNCs5PD03PjctPwlAQUIihhBpQbCIihtG+CUocASFkAhIkogQ8kFJwkcFlogIkoRJEydPnkBR6GiAxiQLgiiIIkXElFQJqESoMsRKkAhXqkhhApNKFSxZggTJ4nHIEJhaDhzYwoVLFy1avHyB6ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAxKdBRSfCyGvFSm1BxKfCSWzCyWzBRCXCRKfBwuRAQGDDw6PHy23Cym1CSSxByCxBxunBQSFKyurMTCxExihNza3NTW1JSSlMzKzFxaXLS2tNze3KSipCQmJGxmbNTS1KSepLy2vISGhJSWlHx+fERGRPz6/IyKjDw+POzq7JyenMzOzKSmpCwuLDQyNIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwGBAIAsOkUjAgFJRQQMHgjC4PBIEVgAh4D4aEYrGAMhINxwPyiCgYSsmEUmk82grLRZJkYCgXaAEKFxYZcEISGhsZFxwFeY0WHR5CDB8dGCAXG5shGxQicBIMpSMUGxgTGSQlpQwSJicnEwwdI7gdKAwTsykpKiobr8QMKxeHDBcsGRvOzxsT0i0uL9HSHdkT2ZkoMJXF4a8AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGxaVOTe1Oze3OTWxOTWvNzStNzKpEQ6LOTezPz+/Pzy7Pz69Pz27Pz25Pz21PzuzPzuxEQyLLyinLSmnPz67Pz23LSafKyObDwuJMzCtLSelPzy1My6nLymjNTCxLyqnPzq1LyihKyOfOzavOzetEQ6NPTq3NzOtLymnNTGxJR2bOTOpPTivNTGvLymlKSShKyahEw+NOTe3PTm1Pzu1Pzy3FRCPPz65LSadFxGPOzm3PzqzPTmzPzmvEw6NCH5BAEAAAAALAAAAAAQABAAAAaqQIBwSCwaj8ikMhloOp/QpmAgqAoIhELBUDgcEIGEYrFgNBoLx+IBiRwkgQnFoWAwKhWLhX3BZAILGhsCDXgODhwdGB5vgAofICBlDiEiIx4kJSYBJ2UoEykqHSMrLC0nLWAnFS4UCycvMAcEMR0RLTIBMwaSahw0NTYtFwclNwEdLws4eoc2DxwQOR06ASk7PBAhIRE9Pj0tLSUY1T8I5gjn6Qgy7D8SfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreplyall16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBLymlMy6pOTa1PTq3PTu5Pz27Dw+POzi3PTm1OTWvPz25FRSVERCRLympPzuzPTu7NTGvFxaXKSmpPzu1Pz65Hx6fHxqZPzq1Pz23HR2dBw+ZHx+fISChJSWlDQmJHRydCxWfBxGbJyenExKTHRiXPzqzPzy3CQmJDRafGTO5ExOTERKTGxWVCRSfHTS5CymxBxajBxWfPTmvPzy1CyixCSaxCySxDSaxDSWxDSSvDyaxGS21PTmzPz21AwiPBRejCSavByGtCSezEzG3FzK5FzG3GzO5FTK3CQ2bPTixBxqlCRefBxSdBxSfBx2nCQ+dHxmXPzmvLSafAwmRAwyRPzyzDw6POzavNzKpAQOFPzuxBwWTBw2ZGRORLyWdMy2lOzetPTivAQCBKyObOTOpAweNBwWVEQyLEw2LEQ2LDwuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAf4gAABAgMEBQUGBwgJCguOCwEMDQ4PEBESDA4TjY8DFAwVERYXGBkRm4+QGhsMHB0eGB8bDpyOARogEBceIRgXv8COIiMkGB4lJSYnIcwoKb/DGyoXKywtKS4pHinMLzAxJDIzNDUtNjcv6B0hLzgfMh85OjstPDw99zwd7T4/LTVAgggZQqSIECNHevSAgSSJkiVMmjh5AiWKlClAiFARUeVHFSVWmLS40gNLlh5agGzh0kWDlwZfrIDREKaCAjEqrFA5MMYLmTAxlJTxYoZMozNozqRRs4ZNmy5s3LwhA0dBnDNn5MxBoAABnTp17IitowDrmQV+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTEw+NFxKTFxGPPwCBLymnMy6pOTa1PTm1Pzy7LymlOzi3HxqZOTWvPz69Pz25My+tLympFRGRHxuZPzu1LymjNTGvNTCxBw+ZPz23PzuzPz65PTu5NzOtCxWfBxKbPzq1DRafGTO5BxGbPzy9HTS5CymxBxajHRiXPzqzCyixCSaxCySxDSaxDSSvGS21GxWVAwmRBRejCSavByGtCSezEzG3FzK5FzG3CQ2bPzuxAwiPBxqlBxKdCRefBxWfBxSdBxSfBx2nCQ+dPzy1CRqlAwyRDQmJPTmvPTixLSafOTOpAQOFPz21BwWTBw2ZPzmvNS6nPTivAQCBAweNBwWVNzKpPzyzLyihGRORLyWdMy2lOzetKyObEQyLEw6NEw2LDwuJEQ2LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfqgAABAgMEBQUGBwgJCguOCwEMDQ4PEJYRDhKNjxMPDBQVFhAXGBUSGY8LGhsQHB0VHh8gFQ6bjgEhIiMMJCUmFbS2CwMnG6IoKSorI7WpEycWFiUsLSou1yXXji8wFiopMTIzNDUz4zbZNxsbODk6Ozw9Pj8pPzEzQDdB60JDOkRFjBw5giRJDCWdlmxwIIRJExAWKDRyMgTIiydLoESRImQKlSUSF1SxUoXAlSBRsGSJoCVICIlbqlThcoBClC5eYFD4EiVIFwUyqywAE0ZMlqNjpJDpIkUBl0dlFChAYOZMmTJoyqQR5icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailsend16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBHxqZLyqlMy6pOze3PTq3PTu5Pz27Pzy7LyinOTaxOzi3Ozq3LymlOTOtPz69Pzy5My+tLympPzqzNTGvLSelPzy3BxGbBQ6VPzuzPz65LyupNzOtPz+/GzO5BRejPzq1Pz23LymjHTS5CyixCSavBxqlPz25LymnGTO5CymxCSaxByGtHRiXPzy1CySxCSezGxWVPzuxKyOhMy6nDSaxEzG3PTivNzKpKyOfPzu1FzK5PTmzJR2ZLyihLSWfKyObOzmzPzmvDyaxOzavLSafGRORMy2lOzetDwuJEw6NEw2LEQyLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfUgAABAgMEBQUGBwgJCguOCwwNDg8QERITFBUWjY8DFxgZGhsaHB0aD5yODB4TGB+kICEaIiOPCwEkJRcmJyYPKCIpKrWqKywTmC0SIi4vMDHEDCsyMg8zEyI0NTY3z7U4Hhs5Mx+0IyI6OyPrIzw9Gys+PxIy2EBBxAs8Qjk5Q0RFWFxAZySfgSMsilRAkiRECHQ08hHgJ0TJkCU/mECU2ISEkowUlpAQ4QTfowNPoAzJIeRJCyjm8kVRIkWIzSkXhwxJtYAKgp9VrFi5QoWKFZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PUZi0zmTtypflV0VdRJbm6fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav1leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAP///wAAACH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxqdwoNGTmgvy9px/IEWBWRkKZ2oWrKu4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxCtwoNHTmpvy3rxnnwQh1mUI52o6rCu6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PWwhxzmetzFpxnnxfRJbmufgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+pq+EPXYpxUckoO3AjbF3dJwahllXe6AFgC8d+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pyxf5VohmSlsxmpjTzAHeN5ak6UHpqKRi2GpwvH3Q3eT64RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pq5HOAjQyVnqfhHue7oAaKH5kiW0AmnLqaHomkj02g+e6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIghI+pyxfR0HsRzNnuXVqn3mVQZWFRyIDjp65Ga5Ly4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navback16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TBxObISevAQCBNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAwSHBRafBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnBRWfAwmPBRWdByixAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZiQIBwSCwah4HjUTBQFgkFg3MoKBykU0QhoUAIAuAksbpgNByPxQMSGVsVDYlkIqdUiJYLJqORbDgcHRseRR8gISIaEyMkGCVYRBEmeyAnlgaQkSgpmU4RAZ1OKqFOpFNGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navdown16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZeQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KJ6hokN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwahYGjUjBQGgWEpHNYMBCaT4G2UDggos+EwmBYMBpf6VBgYDgeEMgjIpmoAQVKxXLBPDIXGhscRB0eHyAgDSGBGyJFASMiIiMkJYImUwAnmJqbjp4AKCmhAKSlTn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navhome16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navup16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObAwSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixAQSHCQ2TAQCBBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZfQIBwSCwaj8hhQJAkDggFQxMQIBwQhUSyqlgwsFpjg6BwPCARySSstC4eFAqEURlYhoMLBpPRUDYcHXt7RgUeFB8gIU0BIoiKjAcUIwiLSQUkJRsmGIwJJwmEU6OkfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+py+0R3IFQUtruXVqn3kkWyIARR4rqKvoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playend16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+py8Eb3ENRggrxjRnrVIWcIoYd91FaenysMU6wTNeLXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playpause16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+py+1vgoxzyUCxrZd18ClfmIyVyJ1lqkHuC0N+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstart16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pyxudwlNyguqkqRZh3h0gl43hpoElqlHt9UKw7NG27BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playstop16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+1vgpySUWpvXXqrHmSaeJEYhKYq6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textblock16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py40Bo5SOzRvrwlgrfnkJOIkPaaaJXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+py70BowPQ1HZpwNv212Vg9IGHmIjoWa4ey5DSRNd+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textbottom16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIVhI+py+0Po5y0hYtzrkB7zH0fN/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textcenter16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsnRkqtDnhu1zHfFSpjaY4PavgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textitalic16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+0BgztwUmmjBXX3jE0auHHhM5Yq4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsgRoqr3Vnt102fFSJjUC6nlPoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textmiddle16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIXhI+py+0PT5i01pisphjt3UmfFZYm5hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textmove16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsg2kfZvblXbwTg10WlA4rjyvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textright16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+pm+EPIZstSrqsDhhv1ylfFE5jiYwX6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textsortdec16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BPwCBAQCBAQC/FxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CBDM+uKp8KiMsmaAs82dtnGeCHnNp4TjNQ4jq8CbDNOroIe3ROyEx2A4vOgkOBzgFxQ6Xa0owJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textsortinc16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BAQC/AQCBPwCBFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM4CAqxLm61CGBs81FMrQxgpnhKJlaXFJHUGg0w7DrDUmvtPQo8qyuEHoHW6hEVv+DQFvuhWtCFPwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIlhI8Jwe2/AmpTynqPTXSqrnBM+I0kdmpmGmUp+K4nPMvhYx9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+texttop16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIWhI9pwe2uYnq0yQtqxbz7D4biSIZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textunder16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pu+FxXoOIKpds1oBH7hlYxYxRCaIZ01lhJbHy9tTv7BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcGlAs6UAYgwLdLtEcI4ygQo7VVp2oupGpG4vmaUVTemX523qlFcw0a4RqNlkx5k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewdetailed16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMmCLrc/i1IAVkYg1Z1iRYUKCqitp1oikqBWV3ZOnhkWNagqu+qnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrcG1AwGOQbw6qANeCEB3pCSZpO6pgowJZqLKuUGE0dnuEhf8IL1kz1shSHDX8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag-16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ+QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7Kmpl0CtLGLvbW2Zn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ8QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7GLArS5Q7O1tmZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag+16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6cAsLECrqeys7WxpqZdtK9Ct8C0fsHAZn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmulticolumn16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrc/ixI0WSgKoyBl+beQFACpo1AqXbKCr1wLAMWS08hGG3dSZqin4sxnBmPD38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtext16:view view16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIchI+py40BTQSwuovp3DXkv1ia1IHmIXLiyWJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewtree16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBDQyNPz+/PzerAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAMuCLHcri4yGISlj4kxcANgNRBQCIbL6U1Su7bB62rXvGydG25kqpwfIGxILBr9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actattach22:act act22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTCxPz+/DQyNKSipAQCBISChFxaXDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARrEMgJgqA4zzus/gLhFd5HCcZAXqsphYPUdhcYFNRcZnvdtpnDqPTbUWgAJKBYwzBlw+bRo3xmkNWoBgm0OrVLn3GC9RgCk8DhUw7c0rHPr4CDu5SYQNyEt7uSY3p/UAKFhYKDSQOLiwgFdhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actbookmark22:act act22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBCQmJCwqLMTGxAQCBBwaHMTCxLSytERGRFRWVLy+vKyqrKSmpHR2dJSSlJyanISGhGxubIyOjKyurGxqbFxeXGRmZHx+fKSipLy6vGRiZLS2tFRSVHRydJSWlHx6fCH5BAEAAAAALAAAAAAWABYAAAWWICCOZGmewamaQrq+wUC8azHINGocOI38iIRAceDNaISFYklkGHOEhoNBfUAOhuOLEJE8HoPiRKFdESiQBqViuTDIUAsEcyAeGJmyiqC5RCwJGg0YcEh9D0V3Dxt6JwQVDRYVHBUdi40mjw0PTgwQHgeYJQQJfxUXFxAOoTkFpQ0fsRSimQkWEQ0VtI62HLt7vjl7JQYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmarknew22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCwqLCQiJCQmJMTGxAQCBLy+vLSytERGRFRWVKyurKyqrLS2tKSmpHR2dJSWlKSipISGhGxubIyOjGxqbIyKjFxaXGRmZHx+fPz+NGRiZPz+ZPz+HMTCBKSiHPz+jFxeXPz+XPz+tPz+zPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAamQIBwSCwaj4Gj0hgQLJ+AAaEAVQoI06pRYDhkoYgwIhEgKBTfZ2FhaBsYDS8VWnA8Go0FJIKeqyUTDw8EDHBpSwUUFQ4UFhcYDQYFfkoFFxEQDG8KEAUZlEeWGBIakw4FG1STiBoYBRwdBR4fHgUdHKBEBSCnIR8iIyIfIblFu6ceIyQjtcXGCbLKzAUKzrq+wMLEVa+xs7W31kOTk6nkWuOf6Ea5QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit22:act act22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBHR2dDQyNCH5BAEAAAAALAAAAAAWABYAAAJOhI+py90RnIMyRUOxhDfzJkACdoXBuEDDkQFDi5go0MrKx16kns80b7qdELCgBYaEGWwL5nG1ePFiKp9A6kuYRNuho8vxVrrZivmMRtMLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+acthelp22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBCQuNBwiJAwiLAwaJAwSHAwSFIy+3ERynCw2PCQuPAwmPCxOZCxWdJzG3FSazBwmNAQKDAQGBDRmhBQyTDxujDR2rIy21AwWJDyGxCxmjAwmNDRihAQOFDxmhCxunBQWFAwaLCRahDR6rESGvDQ2PCRWdDRunDSGvCRSdAwWHCwuLDSOzHSmxDyKxBxCZBwqNHSu1DyOzAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAahQIBwCAgIBAPCoGAgOoeBAyKhWCwYDUf0CX1AIhLiJEGpBLiAAaRxdgYsl7Ybk8igBZoN5xmAdDxoanp8HyANISF8EBsiXBMjJBolBEQmGHFoRScbKHIKDykqK5lFAZRCnyknTaROLA8tq61OChgtKqyzQgEYEJi6UC4vI3LAASkbMBPARAEBdszR0sACEaPSMTIQM8W6KzNl3bo0NOJDdEEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiF4gQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actredo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3Pz+/JTWbHy+VHTCTMTivPT69BxGDESuJDyiHESiHEymJIzKZAQCBFS2LFzKNGzWPDRqHCxqDFSqLHy2XESCHAwaBAQOBBQqBDyWJHyqZDyKFGSiVESeJBQ6BAwSBGTGPFyWPFSSLEyOLESGJBQiDAwiBBQmDCRGFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8hkMcBkKpcBwYAwEDif0YLhwEUkFItFMkAwMBoOR+PxgHwjRDggamhIJpQ8ZbKGKOQLcgEFdhUWEYgRF3sNfhELBHALAhgZFhobRBwREhQdEAIEHpIKHwsaSJwUDQgQIJINARxKESESDQ0dgCIjSpAkDAwPco+ZSJAlJicnKHIAIrNHidOIQxunT0kpCyrZSCss0d5Fj6jjRonn6uvs2QZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actreload22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBCRSFCRSHBw+DBxCFCQ6FBwyDBQWBBxGFCxyLGTChMzqzLzmvHzKjDyOTER+RERyNDSqXNzy3LzivFS+fCyCPBQmBCQiBBxKFBQqDOTy3LTitES2dDR+PCxuJOT25KTarCx+PESSTCxKHDSeVCyKRNT21ESWVDSGPBQyDAQCBBQSFDRuLDSyZDySTGzChCRiJKSmpExKTDS2ZGzGhLy+vGxqbISChDSKRMzKzGxubDQ2NIyOjCQiJCwqLBQWFCwuLKSipERCRERGRHR2dAwKDDw6PFRWVIyKjCQmJFRSVBwaHKyurAQGBExOTBweHFxeXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf9gACCg4IBAgMEBQYHhI2ECAkKCwwNDg8QBAOOhAQREhMUFQgWBxcHGBmbggkaGxwPB4yDB6SbBJIKHQaqtY0eHyAhsqrDgx4aCiKpqoQHAyMjJBMKJaSxzAAHIRsmJgonKA0LHSmDKiuOBywRLSQuLyEwwyoxMuiN6iUzNBXy5jU2bsgoJugABBz95uXQsUMGD3vpPPgTpKIGwx4+HMr4kW4YkCA2hAzxAQSIECI+imBTwVIFESNHerRUgc0cEiFHkjiiyYzeDiVLdvLcySSkkKGEWiZVweSGkIHMmvQosoQlkaZOjvhosvKJjIAxoOAsgpRZkQNLnvSoqspAIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actrun22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAwKDAwKBCQiHNze3AQCBBwWFDw6NPTy9PTy/Dw2NKyytOTi3LS2tMTKzMzOxLy+tLy+vBQODNze5NTS1JyalIyCbIx6VIRyVISGfJyelOTq7EQ+NMTGxKyurGxeRLyKPOSmROSuVOy2XOSiTLzCzNTOzDw+NCwqLHxuVOy6bPzGfOSuXNTW1LSyrMSWRNymTOSmTKSCTPTGjPzSnPzWnMyaVBQSDMTCxPz+/KyahNSeRHxeLJRyTPzmtPzarOy6fJyajNza1Ly6vLyulFRCJPzirPTOlMS2pNTSzMTCvJyenBQWFNzKtPz6vPzyvPzqtOzGlOTe1AwGBFxWTLy6tPTm1PzSpPzutPz2xPTSnOTSxOy2dPzapPzerOzm5IR+dPzu5Pzu1PzqxPzy5Pz+9GRiXGxuZKympHR2bOTm5Pz6/MzSzBwaFJSSjCQmHPz2/AwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeEAQKIjIIDBAQDjYMFBoMHCAkKgwYFhwULDAUKCg0ODxCkBQgRnoUSExMUDxUWFxgZGpAbFIuGHB0eHyAhIiMkIB8lJieIKCUpJCTGIyorLCktKIUDpC4YLzAxIjIyMzQ1NhgdpJI3ODktJTowOyM8Ejc9Pj9AQUIEclAocCMIBQhDiOwgoaKIoCI+jBxBkkSJkCWemIyq0GSHCBVHihRx8gRKFCmpKhGaQqWKFYZXsGR5kkXLFgRUXBUqkCGCFS5AjnTx0sXKlyA6CRVgAAHMAilhxIwhU6ZFkBY5kgKYUoXBAzMKzixZ4AJNGgVm1KxhM0WpmQpUMtooaOPGxAM3Nw60oYLGjNYCbzYJOgAnRzNBJ95oPYQCgpJtkwzFoULlRuRPiy9fNhAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actstop22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/CQKDBwKDCwODNyKjPzq7My+vIxiXAQCBOSOjPz6/OSelNySjNyGhMR+fLRaTGQ2LPz+/Nx+dNR2bNRybMxuZMxeXMxiZLQSFJQaHFwqJNyKhOSCfNyCfNR6dMxmXMxWVMRORLQODOR+fOSSjNR2dMQ2LJQWFMRWTLwWDNSCfMxeVLwaFKQODNR+fNx+fMxiXKQSDOSWlMRSTMxaVMQ6NMxORMQyJOTS1MxqXLwWFLRORMxKPMQaHMxKTLQWFCH5BAEAAAAALAAAAAAWABYAAAb2QIBwSCwajwGBcikIHIsDQmFKNRwQT2EgoVgsGOCG4wHBIgmRhWRCqVQsF0xGYyYGNgoGh9PpeCQfICEic3UAAWgLIxwRJBsbHSUREyYYJ3RDAQULexGejhueESgpl3WaCxsqJKKsChEUKywtmFoFDC4vCayikzCyMbWHt38NCTKiHhUfMyzBdQIFKsodob0VNDWzwppuKxMRrx6iNjcitNA4bh+iEzkwojc66JkOOxcf7G35PBE9KS1MEUGgIQOIFfk++KjRw9wJgUUIZvhRoyLDFCliQDQisUWLGCJOeNx4hKCGkyhPGnqCoKVLl1liypyZxUAQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actundo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3PT69MTivHy+VJTWbIzKZEymJESmFESiHDyiHESqLAQCBFzKNGzWPFS2LNTmzCxqDDRqHPz+/KTGnBQqBAQOBAwaBESCHHy2XBxGDOzy7HTCTEyyJDSqFHzWTAwSBBQ6BIy+dESKJFySPFSSNAwiBCRGFBQmDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMsBkKotMwYAwEDiXgYLhwD0gCFZiQKxNKBYMRqPh+D6G16y5AYnYIxBJAyF4AwITTAUJdBESD4gPFBV6Fn6ABBcJDIYPGEQZGhQbHAIdfx4JHw2VSBodGwWfAR4LDSALfkgYAQurBiAhICKfSSMkvQElGyYnGyi9Rxkdj4nOskUYyU9FpxnURikdGtjRKivdRKfQ2Inh5+jpRwZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBGxqbFxaXExOTEQ+RAQCBPz+/PTy9Ozq7Nza3NTS1KSipFRSVOTi5Hx2fJSSlKyqrJyenJyWnDw6PMzKzKyurDQyNFxWXMTCxJyanHRuLHxuLGReJFxSLFROJFxWJExCHERCHBQODISChHxyLHRqNIRyNHRmLLSqbKyiZLy6fOTarPz67Pzy3OzitKymZFxSJJySTNTSnPTy3NzSpMTChLSydKyqbKSaXJySVIyGRGReLPz23NTOnMzCjHxuPLy2vKSmpOTe5LS2tLSutHxuNHRuPMS+xFxWLIR+RDw2HFRKJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SDAQIDBAUChY2EAQYHCAkKCwyOjZANDgIEAQoPjJiDAg2iggQQp5gMBwmrDBESl6MTFKuoFQSjABYRF40CGAW8BRm7hQwNxBobHB0eHx4gISIjBdiEAhYFJBslHOHSHh4hBSHlxIUmJygpKissBiwtLi8pGjDqhBoxMjMuaNSwcSMFjhw6dnjYRyrGCh4ueviw4Q5HDB0/PjAUJCBCAwMIGiiggAEIBFk/FgYLIgRkggQkhxAJkqGExkYMFnxsIGRkSQgLHhRRWUjAggQgG8AsSWRBBiP6VrYMOfKIyaBDNwLo+HHSUplOSyDRqiEHjRkretRQkcLgxayNF0wksQGQxsSKMTIq0QpgCba/gAE7IhMIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbook22:app app22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBDyGhCyCfFSWlESOjDyKjDSGhCx+fGSinGSenFyanEySjHSqpHSqrGympEySlBx2dISytHyyrCR6dKTGxHyurHSurHyytGSipCR6fARmZFSalEyWlBRubAxubBRydDyKhDSChLSytPz+/MzKzIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbFQIBwSCwaj8ikMhBQIpmCQdM5ZBIKhgNiugwkFAsCI7pNMhuOxkNBgBgEiAi3GkBLJpJHYgEpaClyREwVFhcSEhgOGQoMfgMaERtcARQBFRMYExZ6HB0FUYAekkIBHxqWFmlrC1haESAfG6MBGx+VFRgKYH0hInGRklO0ppYXCwwMWQiQHkwjgrWnFRdYZHIBJCTP0LaWGAcDW9jZ2nMAw9IWTOQkJSZMRsOV49nu8E+19PbmR7TY+1TovONH5V7Ag0QMBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbookopen22:app app22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBHSurIS2tBx2dBweHPz+/Ozm1GxiTGyqpPz6/Pz69GSqpOzaxPzy5HxuVLSmlOTazPz27PT29NzClPTexHxuXLSmjAxqbFSinPTy9KyehNy+lPTy5Pz29HxyXNzWxKSahOzexPzy7IR2ZOTWtESenPTy7KSWfIyCbKyijAQGBDyalPTu3KSSdDSOjJyOdCSGhPzu3OzizJSGdPTq1PTq3JySdMy6lAyKhOzWtOzi1OTOrJyKbMS2nJySfMS+rAwCBNzOrNTCpNzKpJSGZKyafLSifLyylIx+ZHx6ZDSChAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IAAQFjI6EAAaJkQeTjwAICYkKBQcLm5WdBwyfhgChB66bp64HCQC1lQ2irqQCAA4PowsLEBESE4wAuLIHFAAVFr+uDBcYxRm1GrmuGxwdFh4Mrh8gGCET1gDYyhsiFSMkDAsMDCUYJhvnJ9kHKCnODwwfPlBQsULCPRYAWogK9sHFiwoOPEyQh0JFPXO1YBSYwBEFghjdHkwQOYGgwQwIZRR44GHGDBogabhAsYEEihrUMAIoUMCEDRs3HODIYQHFA6MPcJA7KICFjgw7eIzo4cOfiwc/gKwIUm2SkKdDdlDt4AABDaU/iIRwwbTSUyJFOow4S3Hkx9oNDDZgXPU0h1wcSIgEGUw4ibVET5WoWMKksePHpdxmyKADAEIWly9HJtQkQJMmlAgZCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil22:app app22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/IQCBPwCBPyChMQCBPzCxAQCBPz+/MzKzISChKyqrDQyNEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARYEMhJ6wxiEMtpIAWxddwXiqRlikSQeiAbuC+wirNR322gv7zcLobzDU+9XypoBBKTR1lz+RTWDgip8nUwZK1XLyIx5XoVicX2RUAo1DVKi7GOBxjxfNwQAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptool22:app app22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBISChFxaXNze3NTS1Ly6vKSipNTO1Ly2vNza3Pz+/MzOzOTe5DQyNOzu7MTCxGRmZMTGxPTy9Ozm7Hx6fPTu9MzGzGxmbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAW1ICCOZGmeaEoGbBsI6joMRGEcbQwESDIrtVtAF1gwDLNaAmfKiVgLBJKgwB1KxQZrBHU0FAXmavFoQLYiB6TxFXMj5AZBwnJI2I3wcNWALyYEcgoKXxRhOHs7XxEVCwsWFgoUDRYUFwwQB25ZCxiNjo6GkwUXN2NsCxEYqhUHoQ0MEglYRQQXErcHrI55FycuB2YSmoyOBTEtB2sXuhU6XAENC2a6z9AKCwq+1tAN3E2J3ySkIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connecting22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxOTi5AQGBNze3Ly6vISChNza3FxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAAR4EMhJqwzY6omD+MNGdR8YilNZnug0qGzrqrL1lnV1fyJBVB6VQEMoGH4ADGwQkxQPBwMiKGA2J8VEAnq0tgiKg5aL/C7C2gTjKCM0zowDQ8tuNQznNL7cKzjOUQsNfER+gguIg19+Pm6ChBZFDmWNi5M5FIyYFHQRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBERCBAQCBPz+/MTCxOTi5Nze3OTm5Ly6vNza3ISChFxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAARiEMhJq7046827/+AVCKE0Dh9BAGdaGISAToFGFMcBU+11I4hDYseSZQiKwwKoI/QwBIYiuFDCZseGdIlYEjUNg1SpY6w2N4cUIW6cjwW1lsFwo+MqgtZuw0/ydw5vH34lBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+connectyes22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBKyirPz+/KymrOTi5KSipMzCzNza3OTe5Ozi7MzGzPTq9OTm5ISChMS+xFxaXNze3GReZIyCjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWLICCOZGmeaBkAQpoGg7C6JizTQT7CxPwOwFWgYPChYIXkIHC4uQKGAiKRKCyNpxxUUVViVYNFLkqtLo+DAkMMLXQPXwAy2WCTF4544FGtKuwPDhB6DnxuUmyCcXIQhV1uYoMuEAcOBxEKCHg6TzGFCJUSizuejROKOAM9OY2SnUU7nD89NCcDsLUnIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscreen22:dev dev22 22:photo:22 22:R0lGODlhFgAWAIcAAPwCBAQCBPTy9PTu9Ozq7OTi5Nze3OTe5Nza3NzW3NTS1MzOzMzKzMzGzMTCxMTGxOzm7AwGDBQOFBQSFCQeHCwmLCwuLDQyNDw6PERCRFROVEQ+RDQ2NLy+vKSipISChGxqbExKTOzu7OTm5Pz+/GRiZMS+xLy6vBQWFLy2vCwiHFQ+NMSmfNSyhIxmTDwuLJx+bLS2tCwmHMyyhMyqfPTqpPzyvLSWbLSWfPzitIx+ZDw2PAwKDCQiJGxWRPTmrPTerMyuhPzqtPz63PTWnPz6zNy+nIRiVDQuLKyWbOTanPz21NS2jNS6lDQqJHRaTPzmrPTSnPzyxOTClPz2xNSuhPTqxPzuvOzSpAQGDOTKnMy2jOzSrPTu1NzKnOzOnBwWHJRuXLSWdPTatPzqvNzClCwmJOzSnOTOnPTuxOzKlOzerOzarOzitJR6ZNTO1IxmXPTWrNSyjPzOjPTSpLSehHRqZOzirOTCjPS+fPzGhOy6bOzKhGROPMy2lPz+1PzmtKRyRHRiNNTCdPz+zNzCjEQ2NKySdDQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAj/AAEIHEiwoMGBARIqXMhQIUIBAwYQIFCggIEDCBIoULBgAYMGDgIIDEBAwMSKBRBk3NjxAciQIwdACBBBwgQKFSxcwJBBwwYMHBx0EAmA5EwPH0CEsCChoYgOQ0cSGCHhA4kSS5syJGDiBNEAFVGUKKEBAwWFFM6SNJHi64gDFEKE4FBBggoKK1i0cPECxokYXw0gsECYggQZM2jAqGHjBo4cOtqOxLhDAg8ePXz8ABJEyBAWRIoYOfJipEoMCZEkuaFkSAslS5jUGJKkSRAnRREo0JDwCZQoTKQAmUKlihQrVa5gKZ1lI+oAK7QM2cJlSZMuU4Z4+TJEx0iNOwKAggkjZkyOFmS8kClzpcUQLRRGbjRD4MgZNEzSqKG+ZgobI2248dUbDDDwABzcxSEHEFpgEcUcdMRRhx1fFejAAx0cgcYdSxiBRx566LEHH0d8QFRRNC3Uhx985CHEH0MAEkhCBxWkgiCDFEFIEYUYUmONMhyCRxVH/PgjBYioYJAdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxaXMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyylPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbYQIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBscAY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4gKIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATyVoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editcut22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkcpkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editdelete22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzKxIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwCBMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyynOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMNEqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqzkBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0SF+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsygsVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDYCKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBISGhISChHx+fHx6fHR2dGxqbGxubGRmZGRiZFxeXFxaXFRSVIxSLPyuXMzKzMzKxMTCtExOTPzqrPz+/NTS1MS+tOSaVPyWNPz6/IxeNPzavPyKBNTW1PyCBPyGBJxmNPzOpLx6PNRqBMSCRNySTPyCDPSGBMxiBKROBHRydPSylOyydMxmBJxKBAwODPS2lPTq3OyabJxGBPTy5PTGrOyOXPR+DPz69PzmzPzevNxuPORqLMReFPzy7MyCXKxiNIRKHBQWFNTOxPzixJRaPFxONHRqVPz27PTy7PzStCwqJDQyLJSGdIx6ZPz29PTu5HRmTLSKbMSGZHROPFxKPJSKfJyShKyehMyuhDQmHEQuJJyOfLSijMSynMS6pLSefDQyNHx2bKSahLyqhLymhOzi1FRGNIR+bNzKtOTOtOTKrOTKpLyedAQCBFRWVPTq5NzOvLyunLSmlNTCrOTOrNzGrLyidMS+rLyynKyijLymjLyqjAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gAAAAQECAwQFBQYHBggJCgsLDAwADQ6CAQ8QD5ydEJ+gERKWE4ICDxSpqhWqqhYNFxMYphCtqaytGRoXGxgcggSoth25u70eH8APFR0VzMzNziAXIRjIvwAFwq3EqSLUGB/iI4LathS4JCXVJh8nKCmCKrXDFCss1eIfLS4v8ssdmgWsAGNDDBnt3s3wJ+jAtlUhaNSwccNEi4WCBBl4SAHHihw6ZOzg0QNjRgAG6KXK4CNEjBU/gDQI8kLISQAIADobAoMIzCINjLw4YvNkAno4kCRRUuNHESNLmDRxUjSjAlRPfECJImUKlSpMrFzBIqWqoKtJaWSJomULAy5XXrp4+QKGYcYFoCBEWRImi5gmY7CQyVLGriAGD2jEMHMmCxc0Xb6kUbOGTRs3N988gLM4jpw5Y+iwqcOGjZ07mE8yiGABz5c8c/Ts4cOnDJkybS7fdMO7t+/fvDMaCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6/NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz27Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTStNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4FDxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wrLS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCNDiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LAQOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpgweLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBFRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanOze1Pz+/Ozu7BQSFCwqLDw+POTi5MzKxPTu7LyyrIR+fCQmJPz6/Pz69Pzy7Pz29OzaxPTu5PTq3PTm3My6pPzu5PTq5NS+rPTm1PTi1PTezOzWxPz27MyynOzSvMyulOzOtOzKrMymhOzGpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbpQIAwIBgMCAXDAZFQLBbCqJTRqFobjgdkEYFKowPJZEyeUBqVR/crHDTKZYplovZKCW84+YKZZNZSBXl6EwEEBhVPXxZihGMaGRscdkIdg4QeEnVfCH2OHyAhIhuUAAiXZSEhIyQlJqWnjiEnKCWupRWoYyEgJK0SKaUKjam0JCorLMFfC6iqx8giLa/MGAsT1wsuCyULKwssC9RSzdkfCyALKuALLQsvpeXYIQso3gsiCzALMfENC+dGcMNHUAY/f+jq3ctncMYCGggFrsvHcEGNh/EyPFmg8cmrJxAVkVO0EUDJklHoBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+edittrash22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBERGRExOTDQyNISChBQSFCQiJCwuLPT29Nze3GxqbDw6PGxubHR2dJyanLSytJSWlJSSlOzq7Pz6/Nza3Ly6vFRWVBQWFIyKjMTCxHx6fIyOjLS2tOTi5PTy9OTm5Hx+fNTW1KyurKSmpJyenExKTMzKzKSipFxeXCwqLMzOzKyqrMTGxLy+vHRydBwaHNTS1DQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb8QIBwSCwaj8KAMoA8LgUDQsFwQByay4RiwWg4GA9IRGk0SCYJSsUCsVwwGQ1EsmESD5xOp+L5gDwhBRIZDhcDdkMGDgEiIxAkJQ8Ok5MmAohDAQ1xJxUlKCUlEg0pKpiZJRoLCxmtCw1eURhOcR4rbQ8cGRwLAwgGtBYTDywtGRKjvQTARgEZLhMcKC0OrQMvAirMRc7CHCTU1g2+20TO0NIn1RwDCya/wdHT1Rnt5LToKOq79trx0tR02YPX7Jm8fRxMOIhSLhOJE/LCJSTlr5kFEBQsWDiR4UGGBgsuHDg1BEYAfTE6oEBR4AIBAiS5yWBAAAGBAyaPGAgCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fileclose22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBERGRERCRDw6PCwqLExOTFRWVHRydGxqbGRiZCQiJISChIyKjHx6fDQyNBwaHJSWlKSipBQWFJyanPz+/JSSlCQmJAwKDCwuLBweHBQSFGxubExKTISGhDQ2NFxeXFRSVDw+PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbZQIBwSCwaj8jkMSAYDAgEJbFgOBwQCUOAoJAaFgvGonHIBhyP5BcSgUAYDWxggD4WFmx3e3HQngkSRgYMEBMUFG4MCId0BGlEAQeEhocVDYcUdBYKF0QCB3gRlJgUAQEYBBkaRAMbDZMMpAYcT46rQwMJrgsdC6QcfwoPnUMOBgkIV6SHHg6bw0QEAQYfBpggBZjPGsRD0gEchxwCIR6HChnQRQ8DIU4DTR4Em+ncRw8O+fmoXPXdRg+gQLFgIYM/KRIkoDP4QMKFf0o0aBAh4qGUixgzCrETBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filefind22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJyanLS6vLzCxISChNTe3OTu9Oz6/Nzy9Nzy/NTy/OT2/Nzi5Mzu9Lzq9KTe7LTq9PT+/Pz+/Nz2/Mzu/Kzm9Jza5HzK1LTi9PTu9IzW5ITO3FxaXNT2/KTi7Iza7GzC1LzW3FRSVMzO1MTq7HTS3Fy6zFS2vKzm7Lze5MTGzHzS5FTG1Ey2xEyyvJze7JzW3ITa5FTK3EymrGS+zFxWXKymrMzi7ESirEyqvLSyrKze7MzOzMTCxKSepAz+/NzW3MzKzBwWHLzS3ERCRAzi3KyurNze3MzGzLy2vLSutCQiJAyytHRydOTe5MTGxLy6tLyqpKyelJSCdOze3NS+tLyupLSmnKSOhCwuLPzy9Pzu7Oze1OzazOTOvMyihOTi5PTm3Pzi1PTazPTWxOzOtNSunDQyNPzy7Pzu5OzKrNzSzNzGvNS6rMyynMymjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwGFhYOIiYQBAgMEAwKHiokBBQYHCAkKCwwFAZOEBQ0IDAsODxARCZ6gAAEGEhMSFBUWFxgZCJ+TjBoMEpkRERscGBGRih0BBAgeFBQOER8gISEfIruIIwEkCCUVwhcgJicoKSrZg9srCRkRGdMsLS4vMNiK2wIKMRsbMiwzXtCocSydIBs3AuCIwIFDiBMucugAoWvSiB2VNPDg0ELHwA0MkCXr4aNSggg8NoDIQOFHgBtAkgURMiDAEAFEVBCJFKCIkSMGOyDRkETJEkOFmABoUsRJQkQdnkzQACWKlBtTplBR6qopxkFRJ0ytYuWKFCxZtBBq+hRA2AlbRrh08fLlCxi1a51g+dQhDFwuYsaQKWPmDBpKXgNETaNGjJgyhNfcVdTTiWI2XpK0cePmzRk4YA5T5otGixY0qFOXbgXAQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filenew22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBExOTERCRDw6PCwuLBwaHAwODAQCBOze1NTW1OTi5Nze3MTGxLS2tJyanPz+/Ozu7OTi3BQSFCwqLDw+PDQyNFRSVPTu7MzKxLyyrIR+fCQmJPz6/NTOxPz69Pzy7PTu5Pz29Pzu5PTq5PTm1My6pBQWFPTq3PTm3NS+rAwKDPTi1PTezOzWxMy2pPz27PTazOzSvMyynOzaxOzOtPTaxOzKrMyqjOzGpMymhPTizOTCpNzSzNTGvMymjMSihCH5BAEAAAAALAAAAAAWABYAAAboQIBwSCwaiYGAYEAgFAqGg/Q4DCASCsTiymgcHAcqQLB4mM+QiIQBppLPcMjkwQ4bB2X4maKgt4sVCHpnFhQTElNFE3mDDxcYGRp2RBuMgxwIHX9EBZZwHh8gCBmTQ52NISEiIyQlpUImng8hHyInKAgprwAqgnC0IKwrLLpGB4wctLYkwy0uuwd9Z8AnJywsLcVFx2YcL7UnJCwwLTEy0GXJoSgrCCwzNDTnxgjeH9UrKzXwNDY36LRGhEOwLx4NHDmgJbh3QoeOgv127EhojEeHDj16pEhRQoZHHzl+QJNCsqTJSXaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQWDCwaDDwmFPSubPzGhPzCfPy2dOSmZPzKlPzSnPzOlPzKjBQODPzChPzWnPy2bPSmXPyuZOyeXIRSLEQuFEwyHEQqFDQiFCweDKRuPFRSTPT29PTy9Ozq7OTi3Nze3NTW1MzOzMTGxMTCxLy6tLSytKyurDQyNMzKxOTm5OTi5Nza1NTS1MTCvLS2tLSyrKSmpJyenJSWlIyKjHx+fFxeXBwaHKxuPMzKzLy6vIyOjHx6fDw6NPy6dGxubLy+vISChCQmJNza3KyqrBQSFLR2RKSinJyanGxqZAwGBJSSlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeDAYqKiIeLj4wBjQCMhY+NkoiLk5qbhQIDoJyGBAUGBwgEo4MECQoLDA2pDrS1tKQPEAwHERITE77AvxKqhAQNDA8UFRYXFs8YBAQZGqGPxw0RGxwdHR4eHyAhIiMkJSYnKCgpBAYPEhcqHyssLS4kLzAxMjM0NTY3cBA4UCAHBw8gVnhgEcKFjhc7UPDj0cMHAAI/KFgY4YLFio/jRpTYsW8GDyCSCEQw2DChOHIqgsCQSEPIEEEEJFhAoUNECCJEyOk4d6KIyRtGcB7hIJKjixEjHu4oimSGEIs4d8IIUoKECnNB0ElMwkNJJgBLlJBAcQKGiR07KGAURVGViY0mhIwwSTKjr99+THjUoIg0r48hTRIrRtxkiOMhDgrZCQQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileprint22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTy7PTu9OzezPzu5OzavAQCBPzy7PTm3OzazOzKrPTu5FxSRERCRGReXPTq5Pzu7ExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzOtOzSvLyyTMTCxKSipGRiZFROLPz+/KyurJyenJyWnGxmbLSabOzClOzm7LSutJSWlJSSlJyanGxqbNze3OTm5IyGjNTO1Nza3NzW3OTe5IyKjHx6fMzGzMTGxMzOzNTW1IR+hISGhKymrLy6vLSytERGRGxubKyqrLy2vLS2tDQ2NEQ+RASKBAT+BFxeXHRudAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4ODxARApKUCaGYEAsSCRMUnQysCwoVEhYXGLOLCBCgDqK5GQUXGooCAhscBB0euBUZEAUJvQgIgx8gIR8iCSPiHuIFEREDJCXaANwhJhsnKCnWERcRKiopFCvsBywhQrRwQWGAPAz5EhpQ9wIABRgKYsiYMTEEDQocatiwkUIEP18fbkCAAcMBjhwzdOyQwYNCgBMfKJSgMItBjxs+btwgCSGGjhw/ZoRgQKGZCRMUPgABEgSIkCE3SZok8qNqkR85NtDUEcPIkaVAkCR5SrJBDCVKlmzQ6pCCiRlMTJo4YUH3K5AeMBYYWctW0BOaUH60cBJFypQmII6wyEpFQBVFMSm4UAI3hJUrOGh8oOJrklYKWIromJGDR99Ogz5j4ZGlM+pEnwmBCwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBGxqbAQCBLy+vERCRExKTHRydIyKjMTCxFxaXGRiZFRSVFRWVPz6/Nze3Nzm5Pz+/JyanDw+PExOTHR2dMTGxBQWFLSytHx+fISChOzy9Ly6vAQGBJSWlMzKzAwODJSSlHx6fIyOjOTi5DQ2NISGhGxubCwuLOzq7ERGRFxeXNTW1CwqLPT29Dw6PGRmZKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBQGBAMj8ikUDAgFAzKKCBwQCQUCcICKh0SEAhGw5EIZAmBrgCxeDQgcDJWyz0GIggJfL+XGwQJRxNgC3yGDwwUFUZDFhdthnwMGAZNQwEZFwQakXANBBQbHIIdERIBnRAOiR4ERx8gsSEMBBmGCyEGG3YGBwcgIr8UCwQHECOgG4xCtRkEJAvBJRklJgkSFBQeJ68hJiEoESkFKiEZIbkGARsLlwEGExENGhorGSkpFAYm66NDLAECpGiBYsUIFA8wLHBBQMWLVkdUCFCwaYVFBOymkVCgYEMgOykEpICBccMBAhhELFigTEqAAgIIwCiQ4eRKDyS6EAlJIAI0EpaudF4iIKDAAn9CkRT5eMROEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+foldernew22:folder folder22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBNzaTPT2FISCBCQaDPz+BExKBDwmFPSubPzChPzCfPy2dPz6BMzOTAQCBOSmZPzKlPzSnPzOlPzKjBQODPz+rPz+3PzWnPyuZPSmXNyaXPTyhISCLIRSLEQuFEwyHPy2bKRuPFRSTPT29PTy9Ozq7Pz+xJyanDQyNPzGhMzKzOTi3Nza3OTiVBQWFDwqFKxuPOTi5JSSjISChHR2dGRmZFxeXPS2dNTSzNTS1OTm5KSipLS2tLSytKyqpIyKhGRiZNze3NTW1MTGxMTCvLy6tIyKjCQmJMTCxMzOzMzKxJyenHx6fLR2RLy6vJSSlHx+fDw6NLy+vIyOjAwGBGxqZKyurCwuLBQSFJSWlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLjI2MAY6HAgOHBJYEhJCDBQaDmgcICQoLB4MGDA0OAQUBDg2cAAcPEBESE6QUuQasFRYVq5SxCRcSCggYGRjIGgYbFs8bHIMHExIJGR0eHx7cB83PFhsDDuTUEyAhIiMjJCQluwEmvsAnKAcp1x4qKyUrLLupWrByxcnFiwQIYIggEaNEiRgBZMyYQaNADRs2REA6cCODBxw5+OnQgWMHjx4+BND4MQOIg1gI0gUREkTHiplDhhApEoCGkRlHBL3I8MEHEhz+WAhJogTJySVMfthwIehAExE5jubAkYQpESc8fOx4AiXKNA8+ekhBgqSpzh5hPHcsmVLjpSAqVZBY6VGkiJMiPQKLnTvjCiEsWU4o3nGC8YksMmT8YCmC6iAXKLRc2cz5yGYtR0JjKWQgEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mailforward22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBJR2dLyijPTixPz69Pzq3Pzy3Pzu5PTu7Ozi1LyelOzavPz+/DwqLLyafPTmvPz67Pz29Pzy7LSWlPzmzPz6/LyajPTitOTSzMyurPz25PTatPTi3KyOjPzuxAwqVDQiJHxiZPTetKySlPzqvPz27BQ6bAwmTPTexLyinNzGxDRunPzy5KySjCQ+ZNzq9KTO7JzC3Nzq/Ozu/LzW7FSm1BR6vGSWvFyq1AyGxAxytAx6vBSKxAxSjMyujLSunES+5BSi1ByGvAQCBNzCrOTaxNTOvMS6rKyelCx6rBx6tBQKDOTWvPzu1PTq1OzezAQOHAxGdBROhAQGFPzy1NzOvIRqXLyynOzarPz21Jx2XPTWrLSShAw2XKSCbPzuzAwePAQCDPzyzPzqzPTmxOzWtAwGBKyObOTSrNzGrKyGbOzatEQyNKyCZOzWrOTGpNS2lCweHCQaHCQWFBwSFBQODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBhBwgQKFSpY0HgBQwYNGzh0mDhRAAUPHziACEGBpYgRJDiUGEkSwoCQJk6opNASRQoOFETQJDkggwoOJlYApcCihQuVL2DUhBDjhIqjJmRwwDCDhswaNm5MjYHjKggOOU7o0CGTA9gdYknG2KCCBw8VJVL0uBgihAUfP+CSNGCjsI/DiBPbAMJBsEQbQYQM+UG5smUiRYw0jlvYxhEkSYyIHm1EyRLTTH40EZvAyZPOR4pAmU07ipIkUKQ0mQIhAZUqVq5gKXzkSBYtyLVEyd1ki8QFXLp4+WJFQowbYLJnD5NbzJiJCjaQnhnvpYwZM0/OPFlvQ/f3iQvQpBlvQc0aCWy4VKnCpY0Y5yQxgEYXZFjghgwZUOHGCW90YQEccUwloBwGyjAHHXUoSAMZb0xhx1QOoMHDHSfIwSEOdTjhAQ1d4MFbTQ6Q4MYacrzxhhx04JCHHhvQsMeLJPHRBxpr+LHCGnusgccfgKixQR1ATtTBlDDAEIggggxCCCGFbLGFHVFKZEdAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQ6bCQ+ZAwePKTC5Ozu/NTi9GSWvAwSJGSu3JS+5CR+rAQOHPTy/AyKzES23AwOHCw+bOTq/BR6xES+5AwmTBw6ZMTW9Ax6tByi1BRGdAw2XAQCBDQuNDRupKzS9FSm1BR2vBym3EzC7CSGxBROhNTW1Pz+/OTm5NTO1AQGFNzW3Ozq7Ozm7IyKjJyWnMzOzNzq9Nze3OTa5Ly6vCQiJGReZISChKyqrAwqVBRWlOTi5MS6xJSWlNza3OTe5Ly2vGxmbKymrIyGjMzGzISGhKSepCQmJDw6PHR2dJSOlPTy9MTGxLy+vLS2tMzKzLSutMTCxLSytKSipJyenKyurJyanCwqLCwmLCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBhgIBA4SLjAABBAUGBwiNlY4FCQoLDJaNAQ0ODwsQnYwREhMUE5ylFYYRFhcYGRgaGxsDHJUdFR4SHyAhEyIjJCUcuo0cJr0nExihxgwoyYscKSnMHicOIw4lKissLdWDHC4vMCu9McYqMjMyNOUANTY3OPEoOTolDCszdrSgwaMcBxs9TMxYOCMHBx8zfPj48QNINQ5BbMBIIUShDIUoTAhR94PHPEEHbQwZckOGjBQviMxYUWQIDCMmdXE4gqRnkiFETAxR8iKFjJU2evZEdmLJkgJIbqS4wXJIUapImj5FtuSEVyRVV1IVi4RIChhEkLVAgcJHEqVwVJUmYdKkiRNkALMRecKECRG/ff8CEQJFCA5kMKJEoUHDCQ/HkB9LmWKECpUeyKoIMSLEyosen0OD7iH2xg1dV7BkqXGlBpbWNTq4Zn2khu0aAAwEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBDQyNCwqLCQiJBwaHBQSFAwKDAQCBDw6PPz+/Pz69Pz27PTy7PTy5PTu5PTu3PTu1PTq1PTqzOzmzPzuvOzitPTmvOzivAQGBDw+POzevPz67Pz25Pz23Pzy1PzyzPzqvOTavERCRKSilPz21OTevIR+ZExKTOTi3JyanLS2tPz6/Pz65KyihJSKbMS6lExOTNTW1JSWlJSKZMSylNTOrNTKpFRSVPz29MTCxPTmzKymjIyCdOTWxOzexOTWrBQWFFRWVOzu7MzKxJyalOzatLSulMzKtOzmxOTarFxaXKyqnPTmtIyGdIR+bOzetOzixBweHGRiZOzm3NzWzNzSrOTetGRmZOzizOTexOzm1JSKdGxqbHRydJySdHR2dOzapHx6fKyijOTixCwuLHx+fFxeXERGRDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLAQECjwORAwSUBZYFBpkHmwgJCgsMDA0OD6UQERITFBMVFhcVGBkangq1ChsLGxwcHQ0dHR4fICEGIiMSCbS3uLq8wCQUJSYGJygpKhQJKyvLLM4Nwi0uLwUwDQsxMtmeuQveHR8UMzQ1NgU3Dgo41jk6ns0cKOzgYaOHjx9AgjTAUUvIECLZNmxoUISHkSM9KiBJQkCJA4kKEoBQoWJJAiYtmjh5AmVCsCJRpHzckKCCySlUUvBYUqUHDysSPnxIEuXKA5pPRiRwxwFLFhRaIEDYUoEChCcDuECoOWKFuwW7nHkg4WELkw8/BHRRwESpt10dU8SSHevlRxIBX6C0WBE27q8GZMkKbTADjIAwYlb4GLMYShYoPTRo6FGiSJEKPyzMIFMmzJcvXbhwkSLFjJkbQW6cOHNGhAgEAdAsmk27tm0ABgIBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailreplyall22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBLyejPTixPz29PTu3Pzu5Pzy7Ozi1LyelPTavPz+/DwqLPz67PTetPz69ERCRLSWlPTmzPz6/OzexLyajPzqvDw+PDQ2NMyurDQiJPz23PTatJyenAQCBPTevPz25LSajOzq7HxiZPTexPz65JyanBQ6bKSmpBwuTOTi5OzaxBRCdHySvGRiZHx6fBQSFERGRNzq9IyOjHx+fGxqbPzu3BwaHFSq3Aw6XAxKfPzy3Gy63ByWzJzO7Mzi9OzavBRytAx6vCSazGRKTPzy1AQKHBRGdBRyrDy63ES+3Cym1CR6rBwWVAQSLAx+xCyCtBRmnPzuzAQWLAwePPzyzKSCbAQOJByGvOTWvPTmxBQODFQ6PPTWrPzqzOzatAwGBKyObLSWfPTivKyCZEQyNKyGZOzWrOzWtOTSrOTGpNS2lJx2XDQmJCweHCQaHCQWFBwSFBQKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpkzGjhAoYMGjZMpMghQgcNFjh4mODhA4gQGkSIHAmBwAgNJEpo8KDSxAkUGjhMSEGz5gUVIiKs2PmBRQudHiwQpUnAxYsXImB0aBqjBcuoU0fKmPGChgUNH2qIqGHjg9u3bicWIFs2rYgbNnDkyGFhb8cccQ3ouJqWQo0dPFr0WMy4h48LFj4gsKriB5AeNngEaSGks+chPnwQOXFAh4oXRYxk9nAEyY7XO2wksWHDx5ATCDIoUXEBsYclTJo4cWJhuIjhSXacSPBEiZLMQY4wgRKluvXqUpyIsDElAxUqVaxcwcGCPQuWLOixaNHCZAsXBU+oqKDSxQqULF6ifNmyn/8VMOtxwcAK36kQRhdJQIFFEmKM4eCDYGyhhYAEkqFEGSuYYcUZLaDxXRpqSNRCEu6twYaFZXTQhgRd2NCCG9918AYELTjoXgNuKAFHB2RQEUYHVbQQRwlUpPHGGFwkyQUEDsgxx4lh9BhCBy2U8UQJcrSg5JIQ0FEHG3bc0QGYK+CRhx57PEGlkhM9sAEffKTQhx9+/AEIIIGoEUgLLRRFR0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBMSihPTixPz69PTq5Pzy1Pzu5PTq1Pzy7Pzu7Ozi1LyelPTavPz+/DwqLLSajPTetPz27LSWlPzmzPz6/PTexPz67Pz29OTSzMyurPz25LyajBRCdPzuvDQmJOzexPTevOzq5BQ6bBwuTDQiJHxiZPz23Pz65LyinPzmvBxCbHySvAQCBOTi3OTq9CweHOzaxFSq3Aw6XGy63ByWzJzO7Mzi9OzavNzq9BRytAx6vBR6tPzy3AwOHDy63Ax+xCSazCym1CR6rBwWVOzizAQSLES+3CyCtBRyrBRmnGRKTPzu1MzGtAxKfAQWLAwePPTizMy6nByGvNzWxOzWrNzOtBQKDJR2ZNS2lPTmvBQODPTatKSCbOTaxLyqlAQKHFQ6PPzyzPzqzPTu1PTivOzWtKyObPzuzOTOtLSWfPzqvAwGBKyCZPTWrPTmxNzKrEQyNOzatOTGpJx2XCQaHCQWFBwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYuIDBQgYNGzh08DCR4oQPIDqEmDBhJQYRIzqQIFkSAoESJCKkDGFiwgkUKTpMwECz5IASKjqsSMlSA4sWQjG4qGnzhYoQSmF0iCFjBgmWGWhQrVHCxg2sOHLo2MGjB0sLYmsWQHq1p4wdPtqemGDhB1UDQFSouKHi7oQgQmSwUMyYxcQDZQWz2EFiCJEiRoyQyLzZyGIIB47YKLwDSRAiSZSoXq1kCRHNLBK8YGKjCYskTp4ogeKkt+8oUaBImZKAAxMmVKrctqL7ihTnz7FkAT5FC4cKFbZwadIFdxcvX8KLss8iJcoUBUcq2KgAJoxyMTy4jCFTxoxEHl2GLyCDncmWM2hUIQMPY2CXhhoTfTEcA2tgVwEba7Thxhs88FdBD/ZB8MUUHMJBRhw2sAGCHBKU4UaFc1RAhxnhcdhhHUzYAUIcFdxRAh4R5KGHinu4OIVEDqTBRx81xhGHHzD8wQYQetDRI4cTAcIHGWT0EQgZa1ApCBqDcBAID1Q94IEHLtBAAyGEFGKIIWqYYQYPYNZkQEAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailsend22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAIR6fIRydHxubHRqbHRmZGxeXGxaXGRWVFxSVFxOTFRGRExCREw+PEQ6PDw2NDwuLPwCBLSijOzixPz69PTq3PTu5PTu3PTu7OTi1KyelOzavPz+/DQqLPz67LSafOzetPz27Pz29KyajPTmzPz6/NzSzLyurCwiJPz25Ozi3JyOjPzuxBRGbAwSHOzexPz23KSSlPzqvBROdISavBxSdAwaLHRiZLSinNTGxMy+vBxGZNzu9BSGrAwWJMSyrKSSjFy61ETO3BRWfPz65PTqzHTK3ByqzBSWxEzW5AQWJOTWxBRCXOTu9BSOvDzO3ByavBRKbOzaxOzizKSWlCQ2TAQCBJza7BRWdNzSxJSCbMzq9BSOtCSKrAwiPOTavPzy3LymlCySrAwmPFRKTPzy1NTGrPzu1JR+bOzatPzyzCy61ByGpOzWtJyCbPTmvPzuzIS+3FymxCSuzBR6nJyCZOTWvKSObMSujOzivAwKDOTSrNzKrJyGbDwyNOzWrMy2lIx2XBwWFBQSFBQODAwGBAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYqMDxAoYMGjZwmEixg4cPGzqA6BBiAggRIzaQGEkSwgAMJCKgnNBhQogSJlKGOFHTpgYUG0TsnJBCxQoSE1i0KErAxYsOJJRuuAAjhkwZM2jUqGnDBQoUHTbciIEjx4YNOmbs4CGjB8kCZlGAALHBx4+YcTcACcJDyFSJBo6iGNIhhQkiG8BOKGLkCBK6SSQisHoWhZIbG5bMYALECI8mTZw8gTL1QJQXZ6VMiUylSpUlVpoYaXLFtm0EGmCjwJLlA2O9MrRsccKlC8kEXr7AdgEmwtkhX2SQ2BIkjBiSYzSQr/nyhUKZLIrJJOcexvlEBV7IvCBjRkmAMzHOaufhxDvJBWiQISAFxUUQQRovJNeEGmu4JxEDbKQhXxsfuFDGGW68IQMcccgxRxUkNRDhC3R8QMQIdZwXQ11JJGFbiB+QYccHaaTxhgt13OFBDGTgkUdRDrhAhx5k2JjGCB/swYcXMXwAYk190OGHHx/4wUaVepTxByAaoPEkSQ5wwMEJZAZipiCDDJIHIYV8OZEdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBBQSFAQGBDQyNExKTHx6fGxqbFxeXGRiZFRWVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFxaXDw6PPz+/MTCxLS2tIyKjKSmpKSipJyanAwODDQ2NHRydERCRFRSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZzQIBwSCwaj8ikcslsOp/OgHRKlQoCgymRUDAcEIkwYgxWFBYERpHQcDwgEclEQmk8DhWL2kiIXDBwExMNGRoJaUkEEH8bEQ0cGgcWAksEHX8QHBKSHk1sfxMHH5ROBBsOICGkT2wiq1CIULKztLW2t0h2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ5QIBwSCwaj8ikchgQLJGBgfNZDBAKBirRekBMtYGEYsHIgsWNhOO7tCrShDU18Hg/CJAIG0o4wCUQcksTFBUSCRYSEnpUFxgIGQkJGYyNGggbHBaVjR2QCxEeWkITHQ4IH3tPFwEMA2ajAKUgqlQTTbFEE7W5vUgGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNGReZAQCBMTCxGRiZMzGzOTm5LSytPTy9Pz+/CwqLOTi5Ly6vCwmLMzKzJyanJSSlBQWFKymrIyGjCQeJJyWnISChISGhHx2fKyurDw6PAwODHx6fHRydDw2PERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ2QIBwSCwaj8hkMRBQKgOCgRMZIBSk06XhEM0SA4iE4uoVLhCMhqLrdSAekMgYO5VM4BQ521mxIC4UFxBWdEkSERYYFxETGQGFSBKCGBEaGRuQSBwdeZaPXpsQCB6YZQMdEI6ZSgMepKusHh+wrCC0rLdlursGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBFxeXDw+PMTGxHRudPz+/JSSlLSytIyKjHR2dISChIyGjIyOjLSutLy6vKSepJyanISGhJSOlOzm7Ozu7MzGzKyurJyenDQyNGReZKSmpIR+hCwuLCQiJBwaHBQSFAwKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZtQIBwSCwaj8ikcslsOp9QYyAQFQYEAyr0Sihkn1fDAeHVLsOJNELxVaITC0bDUU6GH5AIQ8KYrNtFVxQVFBYWFxgRCREYdUQZGhYEDwgIGxAHCQocCgWOQhmhGR0epR8gqCFTq1Wtrq+wsUt0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAQGBBwaHDQyNExKTHx6fGxqbFxeXGRiZFRSVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFRWVDw6PPz+/MTCxLS2tGRmZDQ2NAwODJyanKSmpKSipIyKjHRydBQSFERCRExOTFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAasQIBwSCwah4FkQKBsDpoBIqFgOCASCYRWm1AUFgRGkdBwPCARiWRCaTwOFYvYSIhcMOiJpJGZaDYcR0IEHXceEQ0fICEWIoJDhHcQHxIHgI9SEHeVG46YUh8OISOen1INCqWmUnOYTUxQAU9NUlRWWFtbCiRgrYNlZ2lriG8lYUd1khETE24gCZeCkRgeFBAQIAeNn9OTlXKrBJoYnKrcoaPmpmSpq3S+7u50QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAavQIBwSCwaj8gkMiBYNpeDZzEQXRIKBmPgmtUSDgipcAsWjxOKBaN7Tq+n6EbCIQ3E5+KtQk6gjwl7CX11D3sPBBARTQGFDYeJT2R8EhB0koKUfgATFBUSCRYSEoqcnqCiikMXGAgZCQkZqautr7FiFxoIGxwWqQC4ury+qh2tCxEexMbIRhMdDggfYs7Q0kcXAQwDbELY2txEziBmmx3jSRNMR+nk4e2b70ry80QGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTGxOzm7CwqLLy2vPTy9Pz+/Ly6vCQiJLSytLS2tLSutOTi5MzGzKSepIyKjJSOlKSmpMzKzJyanIyOjBwaHIyGjISGhJSSlISChBQSFJyenIR+hGxubDw+PHRydHR2dEQ+RHx6fERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8hkIIBcJgEBweAYnTYJUmMAa9USClniFtwlGg6IRFhoUKTXwwWj0FB3F46Hwl6UQyISfAB+EROCQgsUFRYSF3yJEIyBaxgWDBkaGRtclQwSHBIbEGEdGx4fGhcOICEDGBsWHBmqIq1CHRIWGRMMIyRTHRy6Er22tyONq8YdJRe0xkIDwr2/QwMfliMmZQADIxasZd4e4UYDIr7c59rc0eVFA+/m0EQD9PDt0flP/P3+BkEAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBGReZDQyNMTCxHx6fPz+/JyWnKyurHx2fDw6PJSSlISGhIyKjIyGjISChLy6vJyanOTm5PTy9OTi5MzKzLSytKSepMTGxMzGzLS2tLSutKymrHRydCQiJCwmLBwWHAwODLy2vHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAajQIBwSCwaj8RAAMkUBgSDZdP4JBSi06TAcEAkFNLp07BgLLzY5njRcDzO3zB1C4lEGI83Wj58SiYUFRUWdg0XEXFFAwIYGRoWGxwRZQUFHZdgRAObmx4fHiChISFKpVlKWUdPaalOAlasp1sHG4myZGZ7Yltsbgu1mUhjdRF5egmxfQJ/gYOFdrZDi40iFgiSCw8jBQmYcpydn6Ego6WorUwGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navback22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XAQCBDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihAQKFCTO3BS+1AyixBSWvBSOtBSStAQWJBSixDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdCH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMqBcMpvHgGAANQYIhWdVGDAcENQtIJBQLBgNx0MQaDuQXcghIplQDhBIxXKJYiAZGhscHR4VHyAhIiNWJBklGhIbJoQnFCcTKIxFKSgbKissJi0mJi4vLiYoMEcXKDEyMzQ1Nje2NisoOEg4KDU5K6g6OwwoKAN9SCOeMmgwz884PEq9PT4NYkPLP9jZQikN3d4AKVrjKePp3gZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navdown22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaRQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHVQrMX9PU1Uh0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrETa5ByixBRmjCTC1ETS3BTC3Bx2nAyWvEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaYQIBwSCwaj8hkMqBsBgTN5IAAjRoDBaq1aDggtMuAWDzoJhTgY+CwYLgZDccDwkgXI5IJZVGxXDAZGnR2QxsLHB0PHRgeHyAZDyFfVUQDCyIgIyCPIB+QJCUmlEMBEiInKCQnKSkeKSQeomoqJrUmKiArKSwZsmoCwMEBGCyxo1EGHr3HUQEEvltCBtDRAAbMW0zV29xDBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navhome22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQiJNze3ERCROTi5MzGzLy6vDw6PKyqrKyurBQSFGRiZGxqbGRmZISChEQ+RExKTExOTHRydDQyNOTe5FROVLSurCwqLMTCxPT29Pz6/LSutFxeXLyytLSytPz+/JSWlKympPTq7KSipNzW3BwaHHx6fKx2VJRWNHQmBFweDOzq7Ly+vNTW1JxWNLSajPTe1Ny6pKxWJNTS1IyOjJRmbPTi3OzKrNSSXMSGVHQiBHx+fJSSlPzy9IxOVOzWxOSyjNSCPLxeDJyWnIRGTOTGtMxmDLRWBHwqBIxGTLRSDDQuNNSunKxKBGwyNMSafMxqHMReDKRGDPTu9LxuPLxaDJQ+DIR+hGQqNIQyBGQiBNTO1EQKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAYSIiYQCAwQCiokEhwACBQYHBAiQhAiHlQYJCgkEC5uCkp8MDQ4NDwylmwgQlgQRERIEBBOkmxQVBgQWFwUFFxEEDLyJGAUZtQoFGhsFHLYdyoOVHsEf0SAbIAUex8mwlAUhtSIFG+3uIyTWvAIGJMEkJe76GyXbEeWUBJg4USKaBhQpVKzYoIFFiwYUBBJa8MAFCw0vYMSQMWOhBhoTKCQSUKMEiw02buDIoWOHBg0GeIhEFKAHDR8afgAJImSIioYliMws1MPkhiJGchxBkmTDCBo1hg4KQMTiBiUyhBxZ8pNFiR5MEtU0WqSJVidJNDyNKraHC5xPNKBEkTLlJ5WvUgWNvfikyhArV34+7ZEXQAAsB2iUyHLlihYtW0pwOYAFgyJDmDNr7jIIWiAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navup22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBHSWtBRmjAQOHISmxNzu9BSmxBRihHyatPz6/Lze7CTO3BSixHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7ByixGyavKzO3FzC3AyWvBS+1BR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSOtBRSdAw+XAxCZDyexDSyzCTC1JzO5JTa7DSuzETW3BRqlAQWJDRWbOT2/Mzq9HzG3JzS5Kzi7BSStGS21CxSdCRmjAQOFAQSHAAAACH5BAEAAAAALAAAAAAWABYAAAaeQIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbUGFAtGw0GFfheHByQi4S6/E8pDUoFYLm5kAEPJaBAVGxIcER0JHlEfICEiIxUkGyUmIgknKIhXASkonCorgSwmKQGcKE9IAi0uLxUwMTJWMzQ1NiYwBLBQHws1N7avXgs4NjkcCblMATU6KhvGyG87PAnUKV1MAj0+2zIFp1bg4eJJdkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAwKDJSWlFRSVBQSFKymrOzq7HRydERCRPz+/MzGzISGhJyenKSmpGxqbJyWnJSOlKSepLy2vIyOjGRiZPTu9IyGjLSutFxaXExOTHx2fGReZAQCBAQGBBwaHCQiJLSytKyurJSSlFxeXNze3LS2tIyKjFxWXHRudAwGDBQOFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbVKFQsGItBdBhpgh4PxIJvRC8cA4oiMy8bvQhJhMAYTFBVOURAWEw0QFxcMERAYCBluVxobDxkVHJocmBwEGgmEQx0dHh0CpKmkH6odVlanBR8FtAIFtiCkSB0LISEiGCIGIxAPDySuRwIOBwrOzwoHJRHJRh0jJgMj2gMnERQUCNVFHQQoCBvo6CkICATjRB0qp7b1K6qv+foyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playend22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTCxGReZBQSFOzm7AwKDKymrJSSlFRSVCwqLLy6vPTy9OTe5Ozq7CQiJLSytOTi5BwaHPz+/HRydMzKzKSepJSOlKSipJyanIyGjIyKjKyurISGhMzGzJyWnHR2dISChIyOjLSutDw+PERCRHx6fJSWlIR+hJyenGRmZHx2fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8ikMBBQKgOCgRMZIBSkxYHWoDVWD9EigpBQLLBERsPxCA8NDUhjgTBGJJNGG02RVBQWdUV3FxgZe0IGfoAGdhoXGxwdiAYef4FGFBoeHB8dGSBRihUhIo1FBhkbIyMkJRYmAwYal4JEBh2RChIWJ1IIGxUZFqdECCgkHR6wWAYpFR2YWSobvL5vFgfDaEMDIivMRBEsD9HcQgMWvecDLB0tZ0btsfJa9vLXU/X6/P3+b0EAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playpause22:play play22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwODMTCxKSmpJSWlFRSVAQGBBwaHLSutOzq7Ly6vCQeJPz+/Hx2fBQWFGxubLSytJSOlBQOFAwKDJSSlJyWnIyOjHRydNze3GRiZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWBICCOZGmeaKqubOumQSDEgRjPMSoMRGEcol3vh0IkFAtDDWBEKlGMRKPgEIii0yrqIS1ArADu9KuLNCSOSdCMVp8ohEZFC4DL6SaBpXGh6/l4JX8XZACDhXkYCn1LAoqMUBAZEhBLDJKUSyYBGmhPAJyemiU0NDaloy+qq6ytI8whACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playstart22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExOTAwKDAQGBJSSlHx+fBQSFMTCxKymrFRSVOzu7GxqbLSytLy6vJyanPz+/GReZBwaHHRydKSepKSipGRiZJyWnAwODLSutKSmpISChPTu9ISGhFxaXJSWlIyGjJSOlERCRIyKjDw2PIyOjLy2vOzm7Dw6PLS2tCQmJOTe5GxmbDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa7QIBwSCwaj8ik0hgQLJGBgbMoqBIKU2LAcMgOEQmFYeEFbBmNMgDhYDwWBC0k4pCoJ46IgRIXBioRCRYXamwRGBQIfgaBFhiERhkaenxmCoEbBhyQRYaIGVsdghgem4UWegcEBB8UHhsgIaZGBBgRIpUIIxQhChginEQIIBEklWslFyYnBsFfFCi4WQgpFBwqFxNGKxcsxl4IAS0NZEYCF3vlwgEfUuZV8JEuI2pPAARN9kcE9fr+SwaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstop22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAwKDBQSFBwaHCQmJJSSlISChJSOlJSWlGxqbGRiZNTS1PTy9Pz+/Ozm7OTi5FRSVIyKjOTe5MTCxIR+hExOTHR2dLy6vLSytLy2vHRydFxWXIyGjIyOjPz2/FRWVHx6fExKTMzOzJyanKSmpKyqrKSipAQGBLSutHx2fDw6PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcslsAgKCAWEQjQ4KgSwyYDAcugZEQqFYYJECA6PhaLcfEEUkgJZAGJB8fkKpWOhHAxcOGBQZGBoaGQgbHIBGAhUOGR0SBxISBh4Xf0iCHxQSlRIIXhsgj0UCIaCXmJgHGyKpRJ+hmB5dHQqOaCENIx0epBIkBhdzngoPGCQlJifQJBvJRygRKRcKGxcXGypys1srEREc5SLnICLiR1koLFVUWfRO9vf4+UwyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textblock22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUWzvNzo33GfFl5jVlonlTrr1DbvFi9vjeeNUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIxhI+py+0Powm0VnknjVkH2AEhE45LZ55Wqn6e65TsMc5eYosbksswubJIhsSiccgvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textcenter22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUbz3Sh7yIWfFHKjVl4nmFrr1Lpr7LwkjeeIUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textitalic22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py+0P4wqUSlQvttrkDnyaOHIdeaGRupplAIauVM3xjeeOUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+pyw0Bo5zB2UXz3Sp7yG2fFJajVjonmIor2TJvfL0wjecIXQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textright22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUfz3SZ7yIXdF4kWqZkbCqoMO7kXLC+wVOe6YRQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text22:text text22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRSVCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmKQSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bst9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textunder22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIvhI+py+0PowmUnhpeVVnb1DkbCI1I2JhX+Z0sOr2cTHpwK7a4rUr+hAnufsTirwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz69PTq5Pz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq70466Cl+AMxBVwnFIVRAmQHCIeBrC1L3tQgJ/SaEbeeC1PLBHE2ybFI9A1HzstHEIK6YCmhDTmBybQaHYJn7QC5zKeytIQe1+pKNE6P2yMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewdetailed22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAQ+EMhJq7046817+MLQUQFRGMc4lQaSAkcMx3QltMmrDrSu/sCgEPgJhIiFk89DaL1qPRnlhsgBebWhdstVESIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz69PTq5AQCBPz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARWEMhJq7046z2DF0PlBeAVEERhiKhqHgWyUgEsX0KczFOO7JeBYciTCImc5ITIXDKHyqhU9AnRqq9UEVDTvmLbGhin2/qAliOUot5OLc81IO5+2+8WewQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag-22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/avno2BBf/MCClSob4iBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbIQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/cunr9S8gAIRFhTCLAgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag+22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbQQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/4zT766vRI+fvHD4CPgwcJ9qg0UB85JA0dDjEQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmulticolumn22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq7046813+MJQfUF4BURhHGO6noSBsEcNoDJtS4KcsJQe4ncZ1HYT47HDbDqfUAnJRJmKLIGCCjjJbmE5wBI3EyOFxKCPS1EiJW52dE6vZyIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewtext22:view view22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIkhI+py+0Po2ShBlOxzbP7n2yaJoLm+ZTcxqHuC6hXzML2HVEFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtree22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz+/Pz69Pzu5PTq5OzaxBQOFOzKpFRWVFxWXOzexPTexCH5BAEAAAAALAAAAAAWABYAAARPEMhJq704g6A779kHCORAgNskFMYhakE8FkjyBcoWv+JwJItXaELYCTFHlCSpZKKcoB5jYHpOGgUadLKbIRw3jhEzQDyCSuI4zW673yhDBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
diff --git a/ext/tk/sample/tkextlib/ICONS/viewIcons.rb b/ext/tk/sample/tkextlib/ICONS/viewIcons.rb
new file mode 100644
index 0000000000..fc88eb5c85
--- /dev/null
+++ b/ext/tk/sample/tkextlib/ICONS/viewIcons.rb
@@ -0,0 +1,329 @@
+#!/usr/bin/env ruby
+#
+# viewIcons.rb
+#
+# -- Display icons from icon library.
+#
+# -- Copy the clicked icon data (command string of creating
+# a TkPhotoImage instance) to the clipboard.
+#
+require 'tk'
+require 'tkextlib/ICONS'
+
+class ViewIcons
+ #####################################
+ private
+ #####################################
+ def _create_controls
+ @controls = base = TkFrame.new
+ columns = TkFrame.new(base)
+ line1 = TkFrame.new(base, :height=>2, :borderwidth=>1, :relief=>:sunken)
+ line2 = TkFrame.new(base, :height=>2, :borderwidth=>1, :relief=>:sunken)
+
+ lbl_library = TkLabel.new(base, :font=>@boldfont, :text=>'Library')
+ lbl_groups = TkLabel.new(base, :font=>@boldfont, :text=>'Groups')
+ lbl_columns = TkLabel.new(base, :font=>@boldfont, :text=>'Columns')
+
+ ent_library = TkEntry.new(base, :width=>50, :textvariable=>@library)
+ ent_groups = TkEntry.new(base, :width=>50, :textvariable=>@groups)
+
+ btn_browse = TkButton.new(base, :text=>'Browse',
+ :command=>method(:select_icons))
+ btn_view = TkButton.new(base, :text=>'View',
+ :command=>method(:display_icons))
+ btn_exit = TkButton.new(base, :text=>'Exit', :command=>proc{exit})
+
+ @column_btns = {}
+ 6.step(20, 2){|i|
+ @column_btns[i] = TkButton.new(columns,
+ :text=>i.to_s, :width=>2,
+ :command=>proc{set_columns(i)}
+ ).pack(:side=>:left)
+ }
+ @column_btns[@columns][:relief] = :sunken
+
+ lbl_library.grid(:row=>0, :column=>0, :padx=>4)
+ ent_library.grid(:row=>0, :column=>1)
+ btn_browse.grid(:row=>0, :column=>2, :padx=>4, :pady=>2, :sticky=>:ew)
+
+ line1.grid(:row=>1, :column=>0, :pady=>2, :columnspan=>3, :sticky=>:ew)
+
+ lbl_groups.grid(:row=>2, :column=>0, :padx=>4)
+ ent_groups.grid(:row=>2, :column=>1)
+ btn_view.grid(:row=>2, :column=>2, :padx=>4, :pady=>2, :sticky=>:ew)
+
+ line1.grid(:row=>3, :column=>0, :pady=>2, :columnspan=>3, :sticky=>:ew)
+
+ lbl_columns.grid(:row=>4, :column=>0, :padx=>4)
+ columns.grid(:row=>4, :column=>1, :padx=>2, :sticky=>:ew)
+ btn_exit.grid(:row=>4, :column=>2, :padx=>4, :pady=>2, :sticky=>:ew)
+
+ base.pack
+
+ ent_library.bind('Return', method(:display_icons), '')
+ ent_groups.bind('Return', method(:display_icons), '')
+ end
+
+ def _create_display
+ base = TkFrame.new(:borderwidth=>2, :relief=>:sunken)
+
+ @icons_window = icons = TkCanvas.new(base)
+ xscr = icons.xscrollbar(TkScrollbar.new(base))
+ yscr = icons.yscrollbar(TkScrollbar.new(base))
+
+ icons.grid(:row=>0, :column=>0, :sticky=>:news)
+ yscr.grid(:row=>0, :column=>1, :sticky=>:ns)
+ xscr.grid(:row=>1, :column=>0, :sticky=>:ew)
+ base.grid_columnconfigure(0, :weight=>1)
+ base.grid_columnconfigure(1, :weight=>0)
+ base.grid_rowconfigure(0, :weight=>1)
+ base.grid_rowconfigure(1, :weight=>0)
+ # yscr.pack(:side=>:right, :fill=>:y)
+ # xscr.pack(:side=>:bottom, :fill=>:x)
+ # icons.pack(:side=>:left, :fill=>:both, :expand=>true)
+
+ @icons_layout = TkFrame.new(icons).pack
+ TkcWindow.create(icons, 0, 0, :anchor=>:nw, :window=>@icons_layout)
+ @icons_layout.bind('Configure', method(:layout_resize), '')
+
+ base.pack(:expand=>true, :fill=>:both)
+ end
+
+ def _create_info_window
+ @info_window = TkToplevel.new(:background=>'lightyellow', :borderwidth=>1,
+ :relief=>:solid){|w|
+ lbl_name = TkLabel.new(w, :text=>'Name', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+ lbl_grps = TkLabel.new(w, :text=>'Groups', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+ lbl_type = TkLabel.new(w, :text=>'Type', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+ lbl_size = TkLabel.new(w, :text=>'Size', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+
+ lbl_name.grid(:row=>0, :column=>0, :sticky=>:w)
+ lbl_grps.grid(:row=>1, :column=>0, :sticky=>:w)
+ lbl_type.grid(:row=>2, :column=>0, :sticky=>:w)
+ lbl_size.grid(:row=>3, :column=>0, :sticky=>:w)
+
+ @name = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+ @grps = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+ @type = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+ @size = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+
+ @name.grid(:row=>0, :column=>1, :sticky=>:w)
+ @grps.grid(:row=>1, :column=>1, :sticky=>:w)
+ @type.grid(:row=>2, :column=>1, :sticky=>:w)
+ @size.grid(:row=>3, :column=>1, :sticky=>:w)
+
+ def name(txt)
+ @name['text'] = txt
+ end
+ def groups(txt)
+ @grps['text'] = txt
+ end
+ def type(txt)
+ @type['text'] = txt
+ end
+ def size(txt)
+ @size['text'] = txt
+ end
+
+ overrideredirect(true)
+ withdraw
+ }
+ end
+
+ def initialize(init_path = Tk::LIBRARY)
+ init_path = Tk::LIBRARY unless init_path
+ init_path = File.expand_path(init_path)
+ if File.directory?(init_path)
+ @initial_dir = init_path
+ @initial_file = 'tkIcons'
+ else
+ @initial_dir = File.dirname(init_path)
+ @initial_file = File.basename(init_path)
+ end
+
+ if Tk::PLATFORM['platform'] == 'unix'
+ TkOption.add('*HighlightThickness', 0)
+ end
+
+ @columns = 14
+ @command = ""
+
+ @delay_timer = nil
+
+ dummy = TkLabel.new
+ @font = dummy.font
+ @boldfont = TkFont.new(@font, :weight=>:bold)
+ @icons = {}
+ @icon_name = {}
+ @icon_info = {}
+
+ @library = TkVariable.new(File.join(@initial_dir, @initial_file))
+ @groups = TkVariable.new('*')
+
+ _create_controls
+
+ _create_display
+
+ _create_info_window
+
+ Tk.root.title('viewIcons')
+ layout_resize
+ Tk.root.resizable(false, true)
+
+ display_icons
+ end
+
+ def init_info(item, name)
+ @icon_name[item] = name
+
+ item.bind('Button-1', method(:clip_info), '%W')
+ item.bind('Enter', method(:delay_info), '%W')
+ item.bind('Leave', method(:cancel_info), '')
+ end
+
+ def delay_info(item)
+ cancel_info
+ @delay_timer = TkTimer.new(200, 1, proc{ show_info(item) }).start
+ end
+
+ def cancel_info
+ if @delay_timer
+ @delay_timer.cancel
+ @delay_timer = nil
+ end
+ @info_window.withdraw
+ end
+
+ def show_info(item)
+ name, groups, type, size = @icon_info[@icon_name[item]]
+ @info_window.name(name)
+ @info_window.groups(groups)
+ @info_window.type(type)
+ @info_window.size(size)
+
+ info_x = item.winfo_rootx + 10
+ info_y = item.winfo_rooty + item.winfo_height
+
+ @info_window.geometry("+#{info_x}+#{info_y}")
+ @info_window.deiconify
+
+ @info_window.raise
+
+ @delay_timer = nil
+ end
+
+ def primary_transfer(offset, max_chars)
+ @command
+ end
+
+ def lost_selection
+ @command = ""
+ end
+
+ def clip_info(item)
+ name = @icon_name[item]
+ data_width = 60
+
+ cmd = "#{name} = TkPhotoImage.new(:data=><<'EOD')\n"
+
+ icon_data = Tk::ICONS.query(name, :file=>@library.value, :items=>'d')[0][0]
+
+ icon_data.scan(/.{1,#{data_width}}/m){|s| cmd << ' ' << s << "\n"}
+
+ cmd << "EOD\n"
+
+ @command = cmd
+
+ TkClipboard.clear
+ TkClipboard.append(@command)
+
+ if Tk::PLATFORM['platform'] == 'unix'
+ TkSelection.handle(Tk.root, method(:primary_transfer),
+ :selection=>'PRIMARY')
+ TkSelection.set_owner(Tk.root, :selection=>'PRIMARY',
+ :command=>method(:lost_selection))
+ end
+
+ Tk.bell
+ end
+
+ def layout_resize
+ Tk.update
+ bbox = @icons_window.bbox('all')
+ width = @controls.winfo_width - @icons_window.yscrollbar.winfo_width - 8
+
+ @icons_window.configure(:width=>width, :scrollregion=>bbox,
+ :xscrollincrement=>'0.1i',
+ :yscrollincrement=>'0.1i')
+ end
+
+ def select_icons
+ new_lib = Tk.getOpenFile(:initialdir=>@initial_dir,
+ :initialfile=>'tkIcons',
+ :title=>'Select Icon Library',
+ :filetypes=>[
+ ['Icon Libraries', ['tkIcons*']],
+ ['All Files', ['*']]
+ ])
+
+ @library.value = new_lib if new_lib.length != 0
+ display_icons
+ end
+
+ def display_icons
+ column = 0
+ limit = @columns - 1
+ row = 0
+
+ unless File.exist?(@library.value)
+ Tk.messageBox(:icon=>'warning', :message=>'File does not exist',
+ :title=>'viewIcons')
+ return
+ end
+
+ cursor = Tk.root[:cursor]
+ Tk.root[:cursor] = 'watch'
+
+ Tk::ICONS.delete(@icons)
+
+ @icons_frame.destroy if @icons_frame
+ @icons_frame = TkFrame.new(@icons_layout).pack
+
+ @icons = Tk::ICONS.create(:file=>@library.value, :group=>@groups.value)
+
+ Tk::ICONS.query(:file=>@library.value, :group=>@groups.value).each{|inf|
+ name = inf[0]
+ @icon_info[name] = inf
+
+ lbl = TkLabel.new(@icons_frame, :image=>"::icon::#{name}")
+ lbl.grid(:column=>column, :row=>row, :padx=>3, :pady=>3)
+ # lbl.grid_columnconfigure column
+
+ init_info(lbl, name)
+
+ if column == limit
+ column = 0
+ row += 1
+ else
+ column += 1
+ end
+ }
+
+ Tk.root[:cursor] = cursor
+ end
+
+ def set_columns(columns)
+ @columns = columns
+ 6.step(20, 2){|i| @column_btns[i][:relief] = :raised }
+ @column_btns[@columns][:relief] = :sunken
+ display_icons
+ end
+end
+
+ViewIcons.new(ARGV[0])
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt b/ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt
new file mode 100644
index 0000000000..0c4c16fe47
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt
@@ -0,0 +1,53 @@
+
+ ######################################################################
+ ### The following text is the original 'LICENSE.txt' of BWidget ###
+ ### extension. ###
+ ### Original Tcl source files are not include in this directry, ###
+ ### because of all of them are rewrited to Ruby files. ###
+ ### However, the bitmap data files ('bwidgtet.xbm' and 'x1.xbm') ###
+ ### included in this directory are quoted from BWidget source ###
+ ### archive. So, those bitmaps are under the following license. ###
+ ######################################################################
+
+
+BWidget ToolKit
+Copyright (c) 1998-1999 UNIFIX.
+Copyright (c) 2001-2002 ActiveState Corp.
+
+The following terms apply to all files associated with the software
+unless explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/tkextlib/bwidget/basic.rb b/ext/tk/sample/tkextlib/bwidget/basic.rb
new file mode 100644
index 0000000000..c1521651fd
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/basic.rb
@@ -0,0 +1,198 @@
+#
+# basic demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoBasic
+ @@var = TkVariable.new_hash
+ @@after = nil
+ @@count = 0
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoBasic', :text=>'Basic')
+ topf = TkFrame.new(frame)
+
+ titf1 = Tk::BWidget::TitleFrame.new(topf, :text=>'Label')
+ titf2 = Tk::BWidget::TitleFrame.new(topf, :text=>'Entry')
+
+ titf3 = Tk::BWidget::TitleFrame.new(frame, :text=>'Button and ArrowButton')
+
+ _label(titf1.get_frame)
+ _entry(titf2.get_frame)
+ _button(titf3.get_frame)
+
+ Tk.pack(titf1, titf2, :side=>:left, :fill=>:both, :padx=>4, :expand=>true)
+ topf.pack(:pady=>2, :fill=>:x)
+ titf3.pack(:pady=>2, :padx=>4, :fill=>:x)
+ end
+
+ def self._label(parent)
+ lab = Tk::BWidget::Label.new(parent, :text=>'This is a Label widget',
+ :helptext=>'Label widget')
+ chk = TkCheckbutton.new(parent, :text=>'Disabled',
+ :variable=>@@var.ref(lab, 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{lab[:state] = @@var[lab, 'state']})
+ lab.pack(:anchor=>:w, :pady=>4)
+ chk.pack(:anchor=>:w)
+ end
+
+ def self._entry(parent)
+ ent = Tk::BWidget::Entry.new(parent, :text=>'Press enter',
+ :helptext=>'Entry widtet',
+ :command=>proc{
+ @@var['entcmd'] = 'command called'
+ Tk.after(500, proc{@@var['entcmd'] = ''})
+ })
+
+ chk1 = TkCheckbutton.new(parent, :text=>'Disabled',
+ :variable=>@@var.ref(ent, 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{ent.state = @@var[ent, 'state']})
+
+ chk2 = TkCheckbutton.new(parent, :text=>'Non editable',
+ :variable=>@@var.ref(ent, 'editable'),
+ :onvalue=>false, :offvalue=>true,
+ :command=>proc{
+ ent.editable = @@var[ent, 'editable']
+ })
+
+ lab = TkLabel.new(parent, :textvariable=>@@var.ref('entcmd'),
+ :foreground=>'red')
+
+ ent.pack(:pady=>4, :anchor=>:w)
+ Tk.pack(chk1, chk2, :anchor=>:w)
+ lab.pack(:pady=>4)
+ end
+
+ def self._button(parent)
+ frame = TkFrame.new(parent)
+ but = Tk::BWidget::Button.new(frame, :text=>'Press me!',
+ :repeatdelay=>300,
+ :command=>proc{_butcmd('command')},
+ :helptext=>'This is a Button widget')
+
+ sep1 = Tk::BWidget::Separator.new(frame, :orient=>:vertical)
+ arr1 = Tk::BWidget::ArrowButton.new(frame, :type=>:button,
+ :width=>25, :height=>25, :repeatdelay=>300,
+ :command=>proc{_butcmd('command')},
+ :helptext=>"This is an ArrowButton widget\nof type button")
+
+ sep2 = Tk::BWidget::Separator.new(frame, :orient=>:vertical)
+ arr2 = Tk::BWidget::ArrowButton.new(frame, :type=>:arrow,
+ :width=>25, :height=>25, :relief=>:sunken,
+ :ipadx=>0, :ipady=>0, :repeatdelay=>300,
+ :command=>proc{_butcmd('command')},
+ :helptext=>"This is an ArrowButton widget\nof type arrow")
+
+ but.pack(:side=>:left, :padx=>4)
+ sep1.pack(:side=>:left, :padx=>4, :fill=>:y)
+ arr1.pack(:side=>:left, :padx=>4)
+ sep2.pack(:side=>:left, :padx=>4, :fill=>:y)
+ arr2.pack(:side=>:left, :padx=>4)
+ frame.pack
+
+ Tk::BWidget::Separator.new(parent,
+ :orient=>:horizontal).pack(:fill=>:x, :pady=>10)
+
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Command',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf1.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'Disabled',
+ :variable=>@@var.ref('bstate'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{_bstate(@@var['bstate'],
+ but, arr1, arr2)})
+ chk2 = TkCheckbutton.new(subf, :text=>"Use armcommand/\ndisarmcommand",
+ :variable=>@@var.ref('barmcmd'),
+ :command=>proc{_barmcmd(@@var['barmcmd'],
+ but, arr1, arr2)})
+ Tk.pack(chk1, chk2, :anchor=>:w)
+
+ label = TkLabel.new(parent, :textvariable=>@@var.ref('butcmd'),
+ :foreground=>'red').pack(:side=>:bottom, :pady=>4)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Direction',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf2.get_frame
+ @@var['bside'] = :top
+ [:top, :left, :bottom, :right].each{|dir|
+ TkRadiobutton.new(subf, :text=>"#{dir} arrow",
+ :variable=>@@var.ref('bside'), :value=>dir,
+ :command=>proc{_bside(@@var['bside'], arr1, arr2)}
+ ).pack(:anchor=>:w)
+ }
+
+ labf3 = Tk::BWidget::LabelFrame.new(parent, :text=>'Relief',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf3.get_frame
+ @@var['brelief'] = :raised
+ [ %w(raised sunken ridge groove), %w(flat solid link)].each{|lrelief|
+ f = TkFrame.new(subf)
+ lrelief.each{|relief|
+ TkRadiobutton.new(f, :text=>relief,
+ :variable=>@@var.ref('brelief'), :value=>relief,
+ :command=>proc{
+ _brelief(@@var['brelief'], but, arr1, arr2)
+ }).pack(:anchor=>:w)
+ }
+ f.pack(:side=>:left, :padx=>2, :anchor=>:n)
+ }
+ Tk.pack(labf1, labf2, labf3, :side=>:left, :fill=>:y, :padx=>4)
+ end
+
+ def self._bstate(state, but, arr1, arr2)
+ [but, arr1, arr2].each{|b| b[:state] = state}
+ end
+
+ def self._brelief(relief, but, arr1, arr2)
+ but[:relief] = relief
+ if relief.to_s != 'link'
+ [arr1, arr2].each{|arr| arr[:relief] = relief}
+ end
+ end
+
+ def self._bside(side, *args)
+ args.each{|arr| arr[:dir] = side}
+ end
+
+ def self._barmcmd(value, but, arr1, arr2)
+ if TkComm.bool(value)
+ but.configure(:armcommand=>proc{_butcmd('arm')},
+ :disarmcommand=>proc{_butcmd('disarm')},
+ :command=>'')
+ [arr1, arr2].each{|arr|
+ arr.configure(:armcommand=>proc{_butcmd('arm')},
+ :disarmcommand=>proc{_butcmd('disarm')},
+ :command=>'')
+ }
+ else
+ but.configure(:armcommand=>'', :disarmcommand=>'',
+ :command=>proc{_butcmd('command')})
+ [arr1, arr2].each{|arr|
+ arr.configure(:armcommand=>'', :disarmcommand=>'',
+ :command=>proc{_butcmd('command')})
+ }
+ end
+ end
+
+ def self._butcmd(reason)
+ unless @@after
+ @@after = TkTimer.new(500, 1, proc{@@var['butcmd'] = ''})
+ end
+ @@after.stop
+ if (reason == 'arm')
+ @@count += 1
+ @@var['butcmd'] = "#{reason} command called (#{@@count})"
+ else
+ @@count = 0
+ @@var['butcmd'] = "#{reason} command called"
+ end
+ @@after.start
+ end
+end
diff --git a/ext/tk/sample/tkextlib/bwidget/bwidget.xbm b/ext/tk/sample/tkextlib/bwidget/bwidget.xbm
new file mode 100644
index 0000000000..5451ebb9c0
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/bwidget.xbm
@@ -0,0 +1,46 @@
+#define bwidget_width 76
+#define bwidget_height 64
+static char bwidget_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0xb6,0x6d,0xdb,0x16,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0xdb,0xb6,0x6d,0xab,0x00,0x00,0x00,0x00,0xf0,0x00,0x55,0x55,0x55,0x75,
+ 0x01,0x00,0x00,0x00,0xf0,0x00,0x6d,0xdb,0xb6,0xad,0x02,0x00,0x00,0x00,0xf0,
+ 0x00,0xb6,0x6d,0xdb,0xb6,0x05,0x00,0x00,0x00,0xf0,0x00,0x55,0x55,0x55,0x55,
+ 0x05,0x00,0x00,0x00,0xf0,0x00,0xda,0xb6,0xad,0x6d,0x0b,0x00,0x00,0x00,0xf0,
+ 0x00,0x6b,0x03,0xc0,0xb6,0x05,0x00,0x00,0x00,0xf0,0x00,0x56,0x05,0x00,0x55,
+ 0x0d,0x00,0x00,0x00,0xf0,0x00,0xbb,0x05,0x80,0xdb,0x06,0x00,0x00,0x00,0xf0,
+ 0x00,0xca,0x06,0x00,0x6c,0x0b,0x00,0x00,0x00,0xf0,0x00,0xb6,0x02,0x00,0xaa,
+ 0x0a,0x00,0x00,0x00,0xf0,0x00,0xab,0x05,0x00,0x6c,0x0b,0x00,0x00,0x00,0xf0,
+ 0x00,0xdd,0x06,0x00,0xb6,0x05,0x00,0x00,0x00,0xf0,0x00,0xaa,0x02,0x00,0x55,
+ 0x05,0x00,0x00,0x00,0xf0,0x00,0xb7,0x05,0xc0,0xda,0x02,0x00,0x00,0x00,0xf0,
+ 0x00,0xd9,0x06,0x50,0x6b,0x01,0x00,0x00,0x00,0xf0,0x00,0x56,0xb5,0xad,0xad,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0xdb,0xd6,0x76,0x15,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x6a,0xab,0xaa,0x2d,0x00,0x00,0x00,0x00,0xf0,0x00,0x56,0x75,0xad,0xb6,
+ 0x02,0x00,0x00,0x00,0xf0,0x00,0xbb,0xad,0xd6,0xaa,0x05,0x00,0x00,0x00,0xf0,
+ 0x00,0xca,0xb6,0x6b,0xdb,0x2a,0x00,0x00,0x00,0xf0,0x00,0x77,0xd5,0x5c,0x6d,
+ 0x2d,0x00,0x00,0x00,0xf0,0x00,0x99,0x05,0x00,0xaa,0x56,0x00,0x00,0x00,0xf0,
+ 0x00,0xee,0x06,0x00,0x6c,0xbb,0x00,0x00,0x00,0xf0,0x00,0xaa,0x02,0x00,0xb0,
+ 0x55,0x00,0x00,0x00,0xf0,0x00,0x55,0x05,0x00,0xa8,0xd6,0x00,0x00,0x00,0xf0,
+ 0x00,0xee,0x06,0x00,0xd0,0x6a,0x00,0x00,0x00,0xf0,0x00,0x55,0x03,0x00,0x68,
+ 0xb7,0xfc,0x00,0x7e,0xf0,0x00,0x6d,0x05,0x00,0xa8,0xaa,0xfc,0x80,0x7e,0xf0,
+ 0x00,0xb6,0x05,0x00,0x50,0xbb,0xfe,0x01,0x7e,0xf0,0x00,0x55,0x05,0x00,0x78,
+ 0xad,0xfe,0x81,0x1f,0xf0,0x00,0xb6,0x05,0x00,0xa4,0xb5,0xfe,0x81,0x1f,0xf0,
+ 0x00,0x5b,0x05,0x80,0xba,0x56,0xfe,0x83,0x1f,0xf0,0x00,0xaa,0x6b,0x5b,0xd5,
+ 0x5a,0xff,0x85,0x1f,0xf0,0x00,0xdb,0x5a,0xad,0x57,0x2b,0xff,0xc7,0x0f,0xf0,
+ 0x00,0x6d,0xad,0xd5,0x6a,0x0d,0xff,0xc7,0x0f,0xf0,0x00,0xaa,0xd6,0xb6,0xba,
+ 0x05,0xdf,0xc7,0x0f,0xf0,0x00,0xb7,0xb5,0x5a,0xab,0x8a,0xdf,0xcf,0x0f,0xf0,
+ 0x00,0xd9,0x5a,0xab,0x6d,0x8f,0xcf,0xef,0x07,0xf0,0x00,0x56,0xad,0x75,0xb5,
+ 0xaf,0x8f,0xef,0x07,0xf0,0x00,0xb5,0xeb,0x5a,0x00,0x9f,0xcf,0xef,0x07,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0x8f,0xff,0x07,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0x87,0xff,0x03,0xf0,0x00,0x00,0x00,0x00,0x00,0xff,0x03,0xff,0x03,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0x03,0xff,0x03,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0x03,0xff,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0xfc,0x01,0xff,0x03,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0x01,0xfe,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x01,0xfe,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0};
diff --git a/ext/tk/sample/tkextlib/bwidget/demo.rb b/ext/tk/sample/tkextlib/bwidget/demo.rb
new file mode 100644
index 0000000000..785d2681a8
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/demo.rb
@@ -0,0 +1,243 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/bwidget'
+
+module DemoVar
+ @_wfont = nil
+ @notebook = nil
+ @mainframe = nil
+ @status = TkVariable.new
+ @prgtext = TkVariable.new
+ @prgindic = TkVariable.new
+ @font = nil
+ @font_name = nil
+ @toolbar1 = TkVariable.new(true)
+ @toolbar2 = TkVariable.new(true)
+end
+class << DemoVar
+ attr_accessor :_wfont, :notebook, :mainframe, :font, :font_name
+ attr_reader :status, :prgtext, :prgindic, :toolbar1, :toolbar2
+end
+
+class BWidget_Demo
+ DEMODIR = File.dirname(File.expand_path(__FILE__))
+
+ %w(manager basic select dnd tree tmpldlg).each{|f|
+ require File.join(DEMODIR, f << '.rb')
+ }
+
+ def initialize
+ TkOption.add('*TitleFrame.l.font', 'helvetica 11 bold italic')
+
+ root = TkRoot.new(:title=>'BWidget demo')
+ root.withdraw
+
+ _create
+
+ Tk::BWidget.place(root, 0, 0, :center)
+ root.deiconify
+ root.raise
+ root.focus(true)
+
+ root.geometry(root.geometry)
+ end
+
+ def _create
+ DemoVar.prgtext.value = 'Please wait while loading font...'
+ DemoVar.prgindic.value = -1
+
+ intro = _create_intro
+
+ Tk.update
+
+ Tk::BWidget::SelectFont.load_font
+
+ descmenu = [
+ '&File', 'all', 'file', 0, [
+ ['command', 'E&xit', [], 'Exit BWidget demo', [],
+ {:command=>proc{exit}}]
+ ],
+ '&Options', 'all', 'options', 0, [
+ ['checkbutton', 'Toolbar &1', ['all', 'option'],
+ 'Show/hide toolbar 1', [],
+ { :variable=>DemoVar.toolbar1,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(0, DemoVar.toolbar1.value)
+ }
+ }
+ ],
+ ['checkbutton', 'Toolbar &2', ['all', 'option'],
+ 'Show/hide toolbar 2', [],
+ { :variable=>DemoVar.toolbar2,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(1, DemoVar.toolbar2.value)
+ }
+ }
+ ]
+ ]
+ ]
+
+ DemoVar.prgtext.value = 'Creating MainFrame...'
+ DemoVar.prgindic.value = 0
+
+ DemoVar.mainframe = Tk::BWidget::MainFrame.new(
+ :menu=>descmenu,
+ :textvariable=>DemoVar.status,
+ :progressvar=>DemoVar.prgindic
+ )
+
+ # toobar 1 creation
+ DemoVar.prgindic.numeric += 1
+
+ DemoVar.mainframe.add_toolbar{|tb1|
+ Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox|
+ add(:image=>Tk::BWidget::Bitmap.new('new'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Create a new file" icon'},
+ :helptext=>"Create a new file")
+
+ add(:image=>Tk::BWidget::Bitmap.new('open'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Open an existing file" icon'},
+ :helptext=>"Open an existing file")
+
+ add(:image=>Tk::BWidget::Bitmap.new('save'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Save file" icon'},
+ :helptext=>"Save file")
+
+ pack(:side=>:left, :anchor=>:w)
+ }
+
+ Tk::BWidget::Separator.new(tb1, :orient=>:vertical){
+ pack(:side=>:left, :fill=>:y, :padx=>4, :anchor=>:w)
+ }
+
+ DemoVar.prgindic.numeric += 1
+
+ Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox|
+ add(:image=>Tk::BWidget::Bitmap.new('cut'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Cut selection" icon'},
+ :helptext=>"Cut selection")
+
+ add(:image=>Tk::BWidget::Bitmap.new('copy'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Copy selection" icon'},
+ :helptext=>"Copy selection")
+
+ add(:image=>Tk::BWidget::Bitmap.new('paste'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Paste selection" icon'},
+ :helptext=>"Paste selection")
+
+ pack(:side=>:left, :anchor=>:w)
+ }
+ }
+
+ # toolbar 2 creation
+ DemoVar.prgindic.numeric += 1
+
+ tb2 = DemoVar.mainframe.add_toolbar
+ DemoVar._wfont = Tk::BWidget::SelectFont::Toolbar.new(tb2,
+ :command=>proc{update_font(DemoVar._wfont[:font])}
+ )
+ DemoVar.font = DemoVar._wfont[:font]
+ DemoVar._wfont.pack(:side=>:left, :anchor=>:w)
+
+ DemoVar.mainframe.add_indicator(
+ :text=>"BWidget #{Tk::BWidget.package_version}"
+ )
+ DemoVar.mainframe.add_indicator(:textvariable=>'tk_patchLevel')
+
+ # NoteBook creation
+ DemoVar.notebook = Tk::BWidget::NoteBook.new(DemoVar.mainframe.get_frame)
+
+ DemoVar.prgtext.value = "Creating Manager..."
+ DemoVar.prgindic.numeric += 1
+ DemoManager.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Basic..."
+ DemoVar.prgindic.numeric += 1
+ DemoBasic.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Select..."
+ DemoVar.prgindic.numeric += 1
+ DemoSelect.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Dialog..."
+ DemoVar.prgindic.numeric += 1
+ DemoDialog.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Drag and Drop..."
+ DemoVar.prgindic.numeric += 1
+ DemoDnD.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Tree..."
+ DemoVar.prgindic.numeric += 1
+ DemoTree.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Done"
+ DemoVar.prgindic.numeric += 1
+
+ DemoVar.notebook.compute_size
+ DemoVar.notebook.pack(:fill=>:both, :expand=>true, :padx=>4, :pady=>4)
+ DemoVar.notebook.raise(DemoVar.notebook.get_page(0))
+
+ DemoVar.mainframe.pack(:fill=>:both, :expand=>true)
+
+ Tk.update_idletasks
+
+ intro.destroy
+ end
+
+ def update_font(newfont)
+ root = Tk.root
+ root[:cursor] = 'watch'
+ if newfont != '' && DemoVar.font != newfont
+ DemoVar._wfont[:font] = newfont
+ DemoVar.notebook[:font] = newfont
+ DemoVar.font = newfont
+ end
+ root[:cursor] = ''
+ end
+
+ def _create_intro
+ top = TkToplevel.new(:relief=>:raised, :borderwidth=>2)
+ top.withdraw
+ top.overrideredirect(true)
+
+ ximg = TkLabel.new(top, :bitmap=>"@#{File.join(DEMODIR,'x1.xbm')}",
+ :foreground=>'grey90', :background=>'white')
+ bwimg = TkLabel.new(ximg, :bitmap=>"@#{File.join(DEMODIR,'bwidget.xbm')}",
+ :foreground=>'grey90', :background=>'white')
+ frame = TkFrame.new(ximg, :background=>'white')
+ TkLabel.new(frame, :text=>'Loading demo',
+ :background=>'white', :font=>'times 8').pack
+ TkLabel.new(frame, :textvariable=>DemoVar.prgtext,
+ :background=>'white', :font=>'times 8', :width=>35).pack
+ Tk::BWidget::ProgressBar.new(frame, :width=>50, :height=>10,
+ :background=>'white',
+ :variable=>DemoVar.prgindic,
+ :maximum=>10).pack
+ frame.place(:x=>0, :y=>0, :anchor=>:nw)
+ bwimg.place(:relx=>1, :rely=>1, :anchor=>:se)
+ ximg.pack
+ Tk::BWidget.place(top, 0, 0, :center)
+ top.deiconify
+
+ top
+ end
+end
+
+module DemoVar
+ Demo = BWidget_Demo.new
+end
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/bwidget/dnd.rb b/ext/tk/sample/tkextlib/bwidget/dnd.rb
new file mode 100644
index 0000000000..1c8b036530
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/dnd.rb
@@ -0,0 +1,46 @@
+#
+# dnd demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoDnD
+ def self.create(nb)
+ frame = nb.insert('end', 'demoDnD', :text=>'Drag and Drop')
+
+ titf1 = Tk::BWidget::TitleFrame.new(frame, :text=>'Drag source')
+ subf = titf1.get_frame
+
+ ent1 = Tk::BWidget::LabelEntry.new(subf, :label=>'Entry',
+ :labelwidth=>14, :dragenabled=>true,
+ :dragevent=>3)
+ labf1 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label (text)',
+ :width=>14)
+ f = labf1.get_frame
+ lab = Tk::BWidget::Label.new(f, :text=>'Drag this text',
+ :dragenabled=>true, :dragevent=>3).pack
+
+ labf2 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label (bitmap)',
+ :width=>14)
+ f = labf2.get_frame
+ lab = Tk::BWidget::Label.new(f, :bitmap=>'info',
+ :dragenabled=>true, :dragevent=>3).pack
+
+ Tk.pack(ent1, labf1, labf2, :side=>:top, :fill=>:x, :pady=>4)
+
+ titf2 = Tk::BWidget::TitleFrame.new(frame, :text=>'Drop targets')
+ subf = titf2.get_frame
+
+ ent1 = Tk::BWidget::LabelEntry.new(subf, :label=>'Entry',
+ :labelwidth=>14, :dropenabled=>true)
+ labf1 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label', :width=>14)
+ f = labf1.get_frame
+ lab = Tk::BWidget::Label.new(f, :dropenabled=>true,
+ :highlightthickness=>1).pack(:fill=>:x)
+ Tk.pack(ent1, labf1, :side=>:top, :fill=>:x, :pady=>4)
+ Tk.pack(titf1, titf2, :pady=>4)
+
+ frame
+ end
+end
diff --git a/ext/tk/sample/tkextlib/bwidget/manager.rb b/ext/tk/sample/tkextlib/bwidget/manager.rb
new file mode 100644
index 0000000000..776cb3065b
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/manager.rb
@@ -0,0 +1,150 @@
+#
+# manager demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoManager
+ @@progress = TkVariable.new(false)
+ @@status = TkVariable.new('Compute in progress...')
+ @@homogeneous = TkVariable.new(false)
+ @@constw = TkVariable.new
+ @@afterobj = nil
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoManager', :text=>'Manager')
+
+ topf = TkFrame.new(frame)
+ titf1 = Tk::BWidget::TitleFrame.new(topf, :text=>"MainFrame")
+ titf2 = Tk::BWidget::TitleFrame.new(topf, :text=>"NoteBook")
+ titf3 = Tk::BWidget::TitleFrame.new(frame, :text=>"Paned & ScrolledWindow")
+
+ _mainframe(titf1.get_frame)
+ _notebook(titf2.get_frame)
+ _paned(titf3.get_frame)
+
+ Tk.pack(titf1, titf2, :padx=>4, :side=>:left, :fill=>:both, :expand=>true)
+ Tk.pack(topf, :fill=>:x, :pady=>2)
+ Tk.pack(titf3, :pady=>2, :padx=>4, :fill=>:both, :expand=>true)
+
+ frame
+ end
+
+ def self._mainframe(parent)
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Toolbar',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>2)
+ subf = labf1.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'View toolbar 1',
+ :variable=>DemoVar.toolbar1,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(
+ 0, DemoVar.toolbar1.value
+ )
+ })
+ chk2 = TkCheckbutton.new(subf, :text=>'View toolbar 2',
+ :variable=>DemoVar.toolbar2,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(
+ 1, DemoVar.toolbar2.value
+ )
+ })
+
+ Tk.pack(chk1, chk2, :anchor=>:w, :fill=>:x)
+ labf1.pack(:fill=>:both)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Status bar',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>2)
+ subf = labf2.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>"Show Progress\nindicator",
+ :justify=>:left, :variable=>@@progress,
+ :command=>proc{ _show_progress })
+ chk1.pack(:anchor=>:w, :fill=>:x)
+
+ Tk.pack(labf1, labf2, :side=>:left, :padx=>4, :fill=>:both)
+ end
+
+ def self._notebook(parent)
+ TkCheckbutton.new(parent, :text=>'Homogeneous label',
+ :variable=>@@homogeneous,
+ :command=>proc{
+ DemoVar.notebook[:homogeneous] = @@homogeneous.value
+ }).pack(:side=>:left, :anchor=>:n, :fill=>:x)
+ end
+
+ def self._paned(parent)
+ pw1 = Tk::BWidget::PanedWindow.new(parent, :side=>:top)
+ pane = pw1.add(:minsize=>100)
+
+ pw2 = Tk::BWidget::PanedWindow.new(pane, :side=>:left)
+ pane1 = pw2.add(:minsize=>100)
+ pane2 = pw2.add(:minsize=>100)
+
+ pane3 = pw1.add(:minsize=>100)
+
+ [pane1, pane2].each{|pane|
+ sw = Tk::BWidget::ScrolledWindow.new(pane)
+ lb = TkListbox.new(sw, :height=>8, :width=>20, :highlightthickness=>0)
+ (1..8).each{|i| lb.insert('end', "Valur #{i}") }
+ sw.set_widget(lb)
+ sw.pack(:fill=>:both, :expand=>true)
+ }
+
+ sw = Tk::BWidget::ScrolledWindow.new(pane3, :relief=>:sunken,
+ :borderwidth=>2)
+ sf = Tk::BWidget::ScrollableFrame.new(sw)
+ sw.set_widget(sf)
+ subf = sf.get_frame
+ lab = TkLabel.new(subf, :text=>'This is a ScrollableFrame')
+ chk = TkCheckbutton.new(subf, :text=>'Constrained with',
+ :variable=>@@constw, :command=>proc{
+ sf['constrainedwidth'] = @@constw.value
+ })
+ lab.pack
+ chk.pack(:anchor=>:w)
+ chk.bind('FocusIn', proc{sf.see(chk)})
+ (0..20).each{|i|
+ ent = TkEntry.new(subf, :width=>50).pack(:fill=>:x, :pady=>4)
+ ent.bind('FocusIn', proc{sf.see(ent)})
+ ent.insert('end', "Text field #{i}")
+ }
+
+ Tk.pack(sw, pw2, pw1, :fill=>:both, :expand=>true)
+ end
+
+ def self._show_progress
+ unless @@afterobj
+ @@afterobj = TkTimer.new(30, -1, proc{_update_progress})
+ end
+ if @@progress.bool
+ DemoVar.status.value = 'Compute in progress...'
+ DemoVar.prgindic.value = 0
+ DemoVar.mainframe.show_statusbar(:progression)
+ @@afterobj.start unless @@afterobj.running?
+ else
+ DemoVar.status.value = ''
+ DemoVar.mainframe.show_statusbar(:status)
+ @@afterobj.stop
+ end
+ end
+
+ def self._update_progress
+ if @@progress.bool
+ if DemoVar.prgindic.numeric < 100
+ DemoVar.prgindic.numeric += 5
+ else
+ @@progress.value = false
+ DemoVar.mainframe.show_statusbar(:status)
+ DemoVar.status.value = 'Done'
+ @@afterobj.stop
+ Tk.after(500, proc{ DemoVar.status.value = '' })
+ end
+ else
+ @@afterobj.stop
+ end
+ end
+
+end
+
diff --git a/ext/tk/sample/tkextlib/bwidget/select.rb b/ext/tk/sample/tkextlib/bwidget/select.rb
new file mode 100644
index 0000000000..ea24b47e2e
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/select.rb
@@ -0,0 +1,82 @@
+#
+# select demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoSelect
+ @@var = TkVariable.new_hash
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoSelect', :text=>'Spin & Combo')
+
+ titf1 = Tk::BWidget::TitleFrame.new(frame, :text=>'SpinBox')
+ subf = titf1.get_frame
+ spin = Tk::BWidget::SpinBox.new(subf, :range=>[1, 100, 1],
+ :textvariable=>@@var.ref('spin', 'var'),
+ :helptext=>'This is the SpinBox')
+ ent = Tk::BWidget::LabelEntry.new(subf, :label=>'Linked var',
+ :labelwidth=>10, :labelanchor=>:w,
+ :textvariable=>@@var.ref('spin', 'var'),
+ :editable=>0,
+ :helptext=>"This is an Entry reflecting\nthe linked var of SpinBox")
+ labf = Tk::BWidget::LabelFrame.new(subf, :text=>'Options',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1,
+ :helptext=>'Modify some options of SpinBox')
+ subf = labf.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'Non editable',
+ :variable=>@@var.ref('spin', 'editable'),
+ :onvalue=>false, :offvalue=>true,
+ :command=>proc{
+ spin.editable(@@var['spin', 'editable'])
+ })
+ chk2 = TkCheckbutton.new(subf, :text=>'Disabled',
+ :variable=>@@var.ref('spin', 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{
+ spin.state(@@var['spin', 'state'])
+ })
+ Tk.pack(chk1, chk2, :side=>:left, :anchor=>:w)
+ Tk.pack(spin, ent, labf, :pady=>4, :fill=>:x)
+ titf1.pack
+
+ titf2 = Tk::BWidget::TitleFrame.new(frame, :text=>'ComboBox')
+ subf = titf2.get_frame
+ combo = Tk::BWidget::ComboBox.new(subf,
+ :textvariable=>@@var.ref('combo', 'var'),
+ :values=>[
+ 'first value', 'second value',
+ 'third value', 'fourth value',
+ 'fifth value'
+ ],
+ :helptext=>'This is the ComboBox')
+ ent = Tk::BWidget::LabelEntry.new(subf, :label=>'Linked var',
+ :labelwidth=>10, :labelanchor=>:w,
+ :textvariable=>@@var.ref('combo', 'var'),
+ :editable=>0, :helptext=>"This is an Entry reflecting\nthe linked var of ComboBox")
+ labf = Tk::BWidget::LabelFrame.new(subf, :text=>'Options', :side=>:top,
+ :anchor=>:w, :relief=>:sunken,
+ :borderwidth=>1, :helptext=>'Modify some options of ComboBox')
+ subf = labf.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'Non editable',
+ :variable=>@@var.ref('combo', 'editable'),
+ :onvalue=>false, :offvalue=>true,
+ :command=>proc{
+ combo.editable(@@var['combo', 'editable'])
+ })
+ chk2 = TkCheckbutton.new(subf, :text=>'Disabled',
+ :variable=>@@var.ref('combo', 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{
+ combo.state(@@var['combo', 'state'])
+ })
+
+ Tk.pack(chk1, chk2, :side=>:left, :anchor=>:w)
+ Tk.pack(combo, ent, labf, :pady=>4, :fill=>:x)
+ Tk.pack(titf1, titf2, :pady=>4)
+
+ frame
+ end
+end
diff --git a/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb b/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb
new file mode 100644
index 0000000000..3d19c8d092
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb
@@ -0,0 +1,221 @@
+#
+# templdlg demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoDialog
+ @@tmpl = TkVariable.new_hash
+ @@msg = TkVariable.new_hash
+ @@msgdlg = nil
+ @@progmsg = TkVariable.new
+ @@progval = TkVariable.new
+ @@progdlg = nil
+ @@resources = TkVariable.new('en')
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoDlg', :text=>'Dialog')
+
+ titf1 = Tk::BWidget::TitleFrame.new(frame, :text=>'Resources')
+ titf2 = Tk::BWidget::TitleFrame.new(frame, :text=>'Template Dialog')
+ titf3 = Tk::BWidget::TitleFrame.new(frame, :text=>'Message Dialog')
+ titf4 = Tk::BWidget::TitleFrame.new(frame, :text=>'Other dialog')
+
+ subf = titf1.get_frame
+ cmd = proc{ TkOption.read_file(File.join(Tk::BWidget::LIBRARY, 'lang',
+ @@resources.value + '.rc')) }
+ Tk.pack(TkRadiobutton.new(subf, :text=>'English', :value=>'en',
+ :variable=>@@resources, :command=>cmd),
+ TkRadiobutton.new(subf, :text=>'French', :value=>'fr',
+ :variable=>@@resources, :command=>cmd),
+ TkRadiobutton.new(subf, :text=>'German', :value=>'de',
+ :variable=>@@resources, :command=>cmd),
+ :side=>:left)
+
+ _tmpldlg(titf2.get_frame)
+ _msgdlg(titf3.get_frame)
+ _stddlg(titf4.get_frame)
+
+ titf1.pack(:fill=>:x, :pady=>2, :padx=>2)
+ titf4.pack(:side=>:bottom, :fill=>:x, :pady=>2, :padx=>2)
+ Tk.pack(titf2, titf3, :side=>:left, :padx=>2, :fill=>:both, :expand=>true)
+ end
+
+ def self._tmpldlg(parent)
+ @@tmpl['side'] = :bottom
+ @@tmpl['anchor'] = :c
+
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Button side',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf1.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'Bottom', :value=>:bottom,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Left', :value=>:left,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Right', :value=>:right,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Top', :value=>:top,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Button anchor',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf2.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'North', :value=>:n,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'West', :value=>:w,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'East', :value=>:e,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'South', :value=>:s,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Center', :value=>:c,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ sep = Tk::BWidget::Separator.new(parent, :orient=>:horizontal)
+ button = TkButton.new(parent, :text=>'Show', :command=>proc{_show_tmpldlg})
+
+ button.pack(:side=>:bottom)
+ sep.pack(:side=>:bottom, :fill=>:x, :pady=>10)
+ Tk.pack(labf1, labf2, :side=>:left, :padx=>4, :anchor=>:n)
+ end
+
+ def self._msgdlg(parent)
+ @@msg['type'] = 'ok'
+ @@msg['icon'] = 'info'
+
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Type', :side=>:top,
+ :anchor=>:w, :relief=>:sunken,
+ :borderwidth=>1)
+ subf = labf1.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'Ok', :value=>'ok',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Ok, Cancel', :value=>'okcancel',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Retry, Cancel',
+ :value=>'retrycancel',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Yes, No', :value=>'yesno',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Yes, No, Cancel',
+ :value=>'yesnocancel',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Abort, Retry, Ignore',
+ :value=>'abortretryignore',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ Tk.pack(TkRadiobutton.new(subf, :text=>'User', :value=>'user',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ Tk::BWidget::Entry.new(subf, :textvariable=>@@msg.ref('buttons')),
+ :side=>:left)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Icon', :side=>:top,
+ :anchor=>:w, :relief=>:sunken,
+ :borderwidth=>1)
+ subf = labf2.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'Information', :value=>'info',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Question', :value=>'question',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Warning', :value=>'warning',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Error', :value=>'error',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ sep = Tk::BWidget::Separator.new(parent, :orient=>:horizontal)
+ button = TkButton.new(parent, :text=>'Show', :command=>proc{_show_msgdlg})
+
+ button.pack(:side=>:bottom)
+ sep.pack(:side=>:bottom, :fill=>:x, :pady=>10)
+ Tk.pack(labf1, labf2, :side=>:left, :padx=>4, :anchor=>:n)
+ end
+
+ def self._stddlg(parent)
+ Tk.pack(TkButton.new(parent, :text=>'Select a color '){|w|
+ command(proc{DemoDialog._show_color(w)})
+ },
+ TkButton.new(parent, :text=>'Font selector dialog',
+ :command=>proc{_show_fontdlg}),
+ TkButton.new(parent, :text=>'Progression dialog',
+ :command=>proc{_show_progdlg}),
+ TkButton.new(parent, :text=>'Password dialog',
+ :command=>proc{_show_passdlg}),
+ :side=>:left, :padx=>5, :anchor=>:w)
+ end
+
+ def self._show_color(w)
+ dlg = Tk::BWidget::SelectColor.new(w, :color=>w.background)
+ color = dlg.menu([:below, w])
+ unless color.empty?
+ w.background(color)
+ end
+ end
+
+ def self._show_tmpldlg
+ dlg = Tk::BWidget::Dialog.new(:relative=>Tk.root, :modal=>:local,
+ :separator=>true, :title=>'Template dialog',
+ :side=>@@tmpl['side'],
+ :anchor=>@@tmpl['anchor'],
+ :default=>0, :cancel=>1)
+ dlg.add('name'=>'ok')
+ dlg.add('name'=>'cancel')
+ TkMessage.new(dlg.get_frame, :text=>"Template\nDialog", :justify=>:center,
+ :anchor=>:c, :width=>80).pack(:fill=>:both, :expand=>true,
+ :padx=>100, :pady=>100)
+ dlg.draw
+ dlg.destroy
+ end
+
+ def self._show_msgdlg
+ @@msgdlg.destroy if @@msgdlg
+ @@msgdlg = Tk::BWidget::MessageDlg.new(:relative=>Tk.root,
+ :message=>'Message for MessageBox',
+ :type=>@@msg['type'],
+ :icon=>@@msg['icon'],
+ :buttons=>@@msg['buttons'])
+ @@msgdlg.create
+ end
+
+ def self._show_fontdlg
+ font = Tk::BWidget::SelectFont.new(:relative=>Tk.root,
+ :font=>DemoVar.font).create
+ DemoVar::Demo.update_font(font)
+ end
+
+ def self._show_progdlg
+ @@progmsg.value = "Compute in progress..."
+ @@progval.value = 0
+
+ @@progdlg = Tk::BWidget::ProgressDlg.new(:relative=>Tk.root,
+ :title=>'Wait...',
+ :type=>'infinite', :width=>20,
+ :textvariable=>@@progmsg,
+ :variable=>@@progval,
+ :stop=>'Stop') {
+ command(proc{self.destroy})
+ create
+ }
+ _update_progdlg
+ end
+
+ def self._update_progdlg
+ TkTimer.new(20, -1, proc{
+ if @@progdlg && @@progdlg.winfo_exist?
+ @@progval.value = 2
+ else
+ stop
+ end
+ }).start
+ end
+
+ def self._show_passdlg
+ Tk::BWidget::PasswdDlg.new(:relative=>Tk.root).create
+ end
+end
+
diff --git a/ext/tk/sample/tkextlib/bwidget/tree.rb b/ext/tk/sample/tkextlib/bwidget/tree.rb
new file mode 100644
index 0000000000..2b33962fa6
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/tree.rb
@@ -0,0 +1,289 @@
+#
+# templdlg demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoTree
+ @@count = 0
+ @@dblclick = false
+ @@top = nil
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoTree', :text=>'Tree')
+ pw = Tk::BWidget::PanedWindow.new(frame, :side=>:top)
+
+ pane = pw.add(:weight=>1)
+ title = Tk::BWidget::TitleFrame.new(pane, :text=>'Directory tree')
+ sw = Tk::BWidget::ScrolledWindow.new(title.get_frame,
+ :relief=>:sunken, :borderwidth=>2)
+ tree = Tk::BWidget::Tree.new(sw, :relief=>:flat, :borderwidth=>0,
+ :width=>15, :highlightthickness=>0,
+ :redraw=>false, :dropenabled=>true,
+ :dragenabled=>true, :dragevent=>3,
+ :droptypes=>[
+ 'TREE_NODE', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ],
+ 'LISTBOX_ITEM', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ]
+ ],
+ :opencmd=>proc{|node|
+ moddir(1, tree, node)
+ },
+ :closecmd=>proc{|node|
+ moddir(0, tree, node)
+ })
+ sw.set_widget(tree)
+
+ sw.pack(:side=>:top, :expand=>true, :fill=>:both)
+ title.pack(:fill=>:both, :expand=>true)
+
+ pane = pw.add(:weight=>2)
+ lf = Tk::BWidget::TitleFrame.new(pane, :text=>'Content')
+ sw = Tk::BWidget::ScrolledWindow.new(lf.get_frame,
+ :scrollbar=>:horizontal,
+ :auto=>:none, :relief=>:sunken,
+ :borderwidth=>2)
+
+ list = Tk::BWidget::ListBox.new(sw, :relief=>:flat, :borderwidth=>0,
+ :highlightthickness=>0, :width=>20,
+ :multicolumn=>true, :redraw=>false,
+ :dragevent=>3, :dropenabled=>true,
+ :dragenabled=>true,
+ :droptypes=>[
+ 'TREE_NODE', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ],
+ 'LISTBOX_ITEM', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ]
+ ])
+ sw.set_widget(list)
+
+ Tk.pack(sw, lf, :fill=>:both, :expand=>true)
+
+ pw.pack(:fill=>:both, :expand=>true)
+
+ tree.textbind('ButtonPress-1',
+ proc{|node, ev| select('tree', 1, tree, list, node)})
+ tree.textbind('Double-ButtonPress-1',
+ proc{|node, ev| select('tree', 2, tree, list, node)})
+
+ list.textbind('ButtonPress-1',
+ proc{|node, ev| select('list', 1, tree, list, node)})
+ list.textbind('Double-ButtonPress-1',
+ proc{|node, ev| select('list', 2, tree, list, node)})
+
+ list.imagebind('Double-ButtonPress-1',
+ proc{|node, ev| select('list', 2, tree, list, node)})
+
+ nb.itemconfigure('demoTree',
+ :createcmd=>proc{|*args| init(tree, list, *args)},
+ :raisecmd=>proc{
+ Tk.root.geometry =~
+ /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/
+ global_w = ($1 || 0).to_i
+ global_h = ($2 || 0).to_i
+ if @@top
+ Tk::BWidget.place(@@top, 0, 0, :at,
+ global_w - Tk.root.winfo_screenwidth, global_h)
+ @@top.deiconify
+ Tk.root.bind('Unmap', proc{@@top.withdraw})
+ Tk.root.bind('Map', proc{@@top.deiconify})
+ Tk.root.bind('Configure', proc{|w|
+ if w == Tk.root
+ Tk.root.geometry =~
+ /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/
+ global_w = ($1 || 0).to_i
+ global_h = ($2 || 0).to_i
+ Tk::BWidget.place(@@top, 0, 0, :at,
+ global_w - Tk.root.winfo_screenwidth,
+ global_h)
+ end
+ }, '%W')
+ end
+ },
+ :leavecmd=>proc{
+ @@top.withdraw if @@top
+ Tk.root.bind_remove('Unmap')
+ Tk.root.bind_remove('Map')
+ Tk.root.bind_remove('Configure')
+ return true
+ })
+ end
+
+ def self.init(tree, list, *args)
+ @@count = 0
+ if Tk::PLATFORM['platform'] == 'unix'
+ rootdir = File.expand_path('~')
+ else
+ rootdir = 'c:'
+ end
+
+ tree.insert('end', 'root', 'home',
+ :text=>rootdir, :data=>rootdir, :open=>true,
+ :image=>Tk::BWidget::Bitmap.new('openfold'))
+ getdir(tree, 'home', rootdir)
+ select('tree', 1, tree, list, 'home')
+ tree.redraw(true)
+ list.redraw(true)
+
+ @@top = TkToplevel.new
+ @@top.withdraw
+ @@top.protocol('WM_DELETE_WINDOW'){
+ # don't kill me
+ }
+ @@top.resizable(false, false)
+ @@top.title('Drag rectangle to scroll directory tree')
+ @@top.transient(Tk.root)
+ Tk::BWidget::ScrollView.new(@@top, :window=>tree, :fill=>'white',
+ :width=>300, :height=>300, :relief=>:sunken,
+ :bd=>1).pack(:fill=>:both, :expand=>true)
+ end
+
+ def self.getdir(tree, node, path)
+ lentries = Dir.glob(File.join(path, '*')).sort
+ lfiles = []
+ lentries.each{|f|
+ basename = File.basename(f)
+ if File.directory?(f)
+ Tk::BWidget::Tree::Node.new(tree, node,
+ :index=>'end', :text=>basename,
+ :image=>Tk::BWidget::Bitmap.new('folder'),
+ :drawcross=>:allways, :data=>f)
+ @@count += 1
+ else
+ lfiles << basename
+ end
+ }
+ tree.itemconfigure(node, :drawcross=>:auto, :data=>lfiles)
+ end
+
+ def self.moddir(idx, tree, node)
+ if (idx != 0 && tree.itemcget(node, :drawcross).to_s == 'allways')
+ getdir(tree, node, tree.itemcget(node, :data))
+ if tree.nodes(node).empty?
+ tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('folder'))
+ else
+ tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('openfold'))
+ end
+ else
+ img = %w(folder openfold)[idx] || 'openfold'
+ tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new(img))
+ end
+ end
+
+ def self.select(where, num, tree, list, node)
+ @@dblclick = true
+ if num == 1
+ if (where == 'tree' &&
+ tree.selection_get.find{|x|
+ TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node)
+ })
+ @@dblclick = false
+ Tk.after(500, proc{edit('tree', tree, list, node)})
+ return
+ end
+ if (where == 'list' &&
+ list.selection_get.find{|x|
+ TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node)
+ })
+ @@dblclick = false
+ Tk.after(500, proc{edit('list', tree, list, node)})
+ return
+ end
+ if where == 'tree'
+ select_node(tree, list, node)
+ else
+ list.selection_set(node)
+ end
+ elsif (where == 'list' && tree.exist?(node))
+ parent = tree.parent(node)
+ while TkUtil._get_eval_string(parent) != 'root'
+ tree.itemconfigure(parent, :open=>true)
+ parent = tree.parent(parent)
+ end
+ select_node(tree, list, node)
+ end
+ end
+
+ def self.select_node(tree, list, node)
+ tree.selection_set(node)
+ Tk.update
+ list.delete(*(list.items(0, 'end')))
+
+ dir = tree.itemcget(node, :data)
+ if tree.itemcget(node, :drawcross).to_s == 'allways'
+ getdir(tree, node, dir)
+ dir = tree.itemcget(node, :data)
+ end
+
+ tree.nodes(node).each{|subnode|
+ list.insert('end', subnode,
+ :text=>tree.itemcget(subnode, :text),
+ :image=>Tk::BWidget::Bitmap.new('folder'))
+ }
+
+ TkComm.simplelist(dir).each{|f|
+ Tk::BWidget::ListBox::Item.new(list, 'end', :text=>f,
+ :image=>Tk::BWidget::Bitmap.new('file'))
+ }
+ end
+
+ def self.edit(where, tree, list, node)
+ return if @@dblclick
+
+ if (where == 'tree' &&
+ tree.selection_get.find{|x|
+ TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node)
+ })
+ res = tree.edit(node, tree.itemcget(node, :text))
+ if res != ''
+ tree.itemconfigure(node, :text=>res)
+ if list.exist?(node)
+ list.itemconfigure(node, :text=>res)
+ end
+ tree.selection_set(node)
+ end
+ return
+ end
+
+ if (where == 'list')
+ res = list.edit(node, list.igemcget(node, :text))
+ if res != ''
+ list.itemconfigure(node, :text=>res)
+ if tree.exist?(node)
+ tree.itemconfigure(node, :text=>res)
+ else
+ cursel = tree.selection_get[0]
+ index = list.index(node) - tree.nodes(cursel).size
+ data = TkComm.simplelist(tree.itemcget(cursel, :data))
+ data[index] = res
+ tree.itemconfigure(cursel, :date=>data)
+ end
+ list.selection_set(node)
+ end
+ end
+ end
+
+ def self.expand(tree, but)
+ unless (cur = tree.selection_get).empty?
+ if TkComm.bool(but)
+ tree.opentree(cur)
+ else
+ tree.closetree(cur)
+ end
+ end
+ end
+end
diff --git a/ext/tk/sample/tkextlib/bwidget/x1.xbm b/ext/tk/sample/tkextlib/bwidget/x1.xbm
new file mode 100644
index 0000000000..6137a118f8
--- /dev/null
+++ b/ext/tk/sample/tkextlib/bwidget/x1.xbm
@@ -0,0 +1,2258 @@
+#define x1_width 626
+#define x1_height 428
+static char x1_bits[] = {
+ 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,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,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,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,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,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,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,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,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,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,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,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,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,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 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,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,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,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,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,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,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,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,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,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,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,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,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,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 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,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,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,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,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,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,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,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0x80,0xff,0x03,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0x20,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,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,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,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,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,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,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 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,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,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,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0xfc,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,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,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,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,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,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0xfc,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,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0xfc,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,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0xfc,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,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xfc,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,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfc,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,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0xfc,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,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0xfc,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,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfc,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,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0xf8,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0x3f,0x00,0x00,0x00,0xc0,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0xfc,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0xfe,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x80,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xc0,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xfc,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfe,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x80,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xc0,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0x01,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x01,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0x7f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x3f,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x1f,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0x1f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x07,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x07,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0x03,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0x01,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x01,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0x7f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x7f,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x06,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xfd,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0xfc,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xfc,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0xfc,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0xfc,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0xfc,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0xfc,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0xfc,0x00,0x00,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+ 0x00,0xfc,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0xfc,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0xfc,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xfc,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xfc,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0xfc,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0xfc,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0xfc,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xfc,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xfc,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0xfc,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0xfc,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0xfc,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0xfc,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xfc,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xfc,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfc,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0xfc,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0xfc,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xfc,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfc,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfc,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0xfc,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0xc0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xc0,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xe0,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xf8,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xfc,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0xfc,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0xfe,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0xc0,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xe0,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x3f,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0x1f,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0x7f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0x7f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0x1f,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x01,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,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,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,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,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,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,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,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,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,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,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x30,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x80,0x0f,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,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x80,
+ 0xff,0x01,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,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,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,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,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,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,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,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,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,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,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,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,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,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,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,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,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,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,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,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,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,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,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,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,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,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,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,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,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,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,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,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,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,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,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,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,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,0xfc};
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt
new file mode 100644
index 0000000000..22f787609d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt
@@ -0,0 +1,42 @@
+
+ #######################################################################
+ ### The following text is the original 'license.terms' of iwidges ###
+ ### extension. ###
+ ### Original Tcl source files are not include in this directry, ###
+ ### because of all of them are rewrited to Ruby files. ###
+ ### However, the image data files in the 'images' directory are ###
+ ### quoted from iwidgets source archive. ###
+ #######################################################################
+
+
+This software is copyrighted by DSC Technologies and private individual
+contributors. The copyright holder is specifically listed in the header
+of each file. The following terms apply to all files associated with the
+software unless explicitly disclaimed in individual files by private
+contributors.
+
+Copyright 1997 DSC Technologies Corporation
+
+Permission to use, copy, modify, distribute and license this software and
+its documentation for any purpose, and without fee or written agreement
+with DSC, is hereby granted, provided that the above copyright notice
+appears in all copies and that both the copyright notice and warranty
+disclaimer below appear in supporting documentation, and that the names of
+DSC Technologies Corporation or DSC Communications Corporation not be used
+in advertising or publicity pertaining to the software without specific,
+written prior permission.
+
+DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-INFRINGEMENT.
+THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND
+DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL DSC BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+RESTRICTED RIGHTS: Use, duplication or disclosure by the government
+is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
+of the Rights in Technical Data and Computer Software Clause as DFARS
+252.227-7013 and FAR 52.227-19.
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm
new file mode 100644
index 0000000000..7498e15de2
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm
@@ -0,0 +1,14 @@
+#define Tool_32_box_width 32
+#define Tool_32_box_height 32
+static unsigned char Tool_32_box_bits[] = {
+ 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, 0xe0, 0xff, 0xff, 0x0f, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0xe0, 0xff, 0xff, 0x0f, 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, };
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gif
new file mode 100644
index 0000000000..bd45628aa7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif
new file mode 100644
index 0000000000..f91b9e9d1e
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif
new file mode 100644
index 0000000000..7319f1dcb0
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif
new file mode 100644
index 0000000000..4258b17591
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif
new file mode 100644
index 0000000000..e462be033f
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif
new file mode 100644
index 0000000000..dddcb8044b
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif
new file mode 100644
index 0000000000..bc8f18c00d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm
new file mode 100644
index 0000000000..4622ae978b
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm
@@ -0,0 +1,14 @@
+#define lineOp_width 32
+#define lineOp_height 32
+static unsigned char lineOp_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+ 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00,
+ 0x80, 0x07, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
+ 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
+ 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00,
+ 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3c, 0x00,
+ 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01,
+ 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x0f,
+ 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif
new file mode 100644
index 0000000000..4a5be66e76
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif
new file mode 100644
index 0000000000..9c68ad35f5
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif
new file mode 100644
index 0000000000..bed862c8c4
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm
new file mode 100644
index 0000000000..856bd43785
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm
@@ -0,0 +1,14 @@
+#define ovalOp_width 32
+#define ovalOp_height 32
+static unsigned char ovalOp_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
+ 0x00, 0x1c, 0x70, 0x00, 0x00, 0x03, 0x80, 0x01, 0x80, 0x00, 0x00, 0x02,
+ 0x40, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x10,
+ 0x10, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20,
+ 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x10,
+ 0x10, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x04,
+ 0x80, 0x00, 0x00, 0x02, 0x00, 0x03, 0x80, 0x01, 0x00, 0x1c, 0x70, 0x00,
+ 0x00, 0xe0, 0x0f, 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};
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif
new file mode 100644
index 0000000000..9974f23bf5
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm
new file mode 100644
index 0000000000..c50aa4c5f3
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm
@@ -0,0 +1,14 @@
+#define dotPencilOp_width 32
+#define dotPencilOp_height 32
+static unsigned char dotPencilOp_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x12, 0x00,
+ 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x80, 0x04, 0x00,
+ 0x00, 0x80, 0x04, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x20, 0x01, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00,
+ 0x00, 0x90, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00,
+ 0x00, 0x24, 0x00, 0x18, 0x00, 0x24, 0x00, 0x18, 0x00, 0x12, 0x00, 0x00,
+ 0x00, 0x12, 0x00, 0x30, 0x00, 0x0e, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00,
+ 0x00, 0x06, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x30, 0xa0, 0x01,
+ 0x00, 0x60, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif
new file mode 100644
index 0000000000..2b595bb9b7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif
new file mode 100644
index 0000000000..d321f17457
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif
new file mode 100644
index 0000000000..00d26febf6
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif
new file mode 100644
index 0000000000..d1ceb1a5c4
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif
new file mode 100644
index 0000000000..f885c9ca5f
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm
new file mode 100644
index 0000000000..ffb0686303
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm
@@ -0,0 +1,14 @@
+#define font_edit_width 32
+#define font_edit_height 32
+static unsigned char font_edit_bits[] = {
+ 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1c,
+ 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x80, 0x7b,
+ 0x00, 0x00, 0x80, 0x7e, 0x00, 0x00, 0xc0, 0xfd, 0x00, 0x00, 0x60, 0xfb,
+ 0x00, 0x00, 0xb0, 0xf7, 0x00, 0x00, 0xd0, 0xef, 0x00, 0x00, 0xf8, 0xdf,
+ 0x00, 0x00, 0xd4, 0x7f, 0x00, 0x00, 0xaa, 0x1f, 0x00, 0x00, 0x15, 0x0f,
+ 0x00, 0x80, 0x82, 0x06, 0x03, 0x40, 0x01, 0x01, 0x07, 0xa0, 0x80, 0x00,
+ 0x0f, 0x10, 0x40, 0x00, 0x1f, 0x08, 0x20, 0x00, 0x3b, 0xe4, 0x1f, 0x00,
+ 0x73, 0x1a, 0x00, 0x00, 0xe3, 0x07, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x00,
+ 0xe3, 0x03, 0x00, 0x00, 0x7b, 0x07, 0x00, 0x00, 0x1f, 0x06, 0x00, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb
new file mode 100644
index 0000000000..2b7cd45205
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# sample 1
+p bb1 = Tk::Iwidgets::Buttonbox.new
+p bb1.add('Yes', :text=>'Yes', :command=>proc{puts 'Yes'})
+p bb1.add('No', :text=>'No', :command=>proc{puts 'No'})
+p bb1.add('Maybe', :text=>'Maybe', :command=>proc{puts 'Maybe'})
+bb1.default('Yes')
+bb1.pack(:expand=>true, :fill=>:both, :pady=>5)
+print "\n"
+
+# sample 2
+p bb2 = Tk::Iwidgets::Buttonbox.new
+p btn1 = bb2.add(:text=>'Yes', :command=>proc{puts 'Yes'})
+p btn2 = bb2.add(:text=>'No', :command=>proc{puts 'No'})
+p btn3 = bb2.add(:text=>'Maybe', :command=>proc{puts 'Maybe'})
+bb2.default(btn1)
+bb2.pack(:expand=>true, :fill=>:both, :pady=>5)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb
new file mode 100644
index 0000000000..4dd929c035
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Calendar.new(:command=>proc{|arg| puts(arg.date)},
+ :weekendbackground=>'mistyrose',
+ :weekdaybackground=>'ghostwhite',
+ :outline=>'black', :startday=>'wednesday',
+ :days=>%w(We Th Fr Sa Su Mo Tu)).pack
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb
new file mode 100644
index 0000000000..c7c043000a
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Canvasprintbox.new(:orient=>:landscape, :stretch=>1) \
+ .pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb
new file mode 100644
index 0000000000..ea8d63e6eb
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Canvasprintdialog.new.activate
+
+Tk.mainloop
+
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb
new file mode 100644
index 0000000000..bae0eba73a
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+cb = Tk::Iwidgets::Checkbox.new
+cb.add('bold', :text=>'Bold')
+cb.add('italic', :text=>'Italic')
+cb.add('underline', :text=>'Underline')
+cb.select('underline')
+cb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb
new file mode 100644
index 0000000000..ec9c7a1df3
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+#
+# Non-editable Dropdown Combobox
+#
+cb1 = Tk::Iwidgets::Combobox.new(:labeltext=>'Month:',
+ :selectioncommand=>proc{
+ puts(cb1.get_curselection)
+ },
+ :editable=>false, :listheight=>185,
+ :popupcursor=>'hand1')
+
+cb1.insert_list('end', *%w(Jan Feb Mar Apr May June Jul Aug Sept Oct Nov Dec))
+
+
+#
+# Editable Dropdown Combobox
+#
+cb2 = Tk::Iwidgets::Combobox.new(:labeltext=>'Operating System:',
+ :selectioncommand=>proc{
+ puts(cb2.get_curselection)
+ })
+
+cb2.insert_list('end', *%w(Linux HP-UX SunOS Solaris Irix))
+cb2.insert_entry('end', 'L')
+
+cb1.pack(:padx=>10, :pady=>10, :fill=>:x)
+cb2.pack(:padx=>10, :pady=>10, :fill=>:x)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb b/ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb
new file mode 100644
index 0000000000..5727879217
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Dateentry.new.pack
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb b/ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb
new file mode 100644
index 0000000000..12d498245d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+df = Tk::Iwidgets::Datefield.new(:command=>proc{puts(df.get)})
+df.pack(:fill=>:x, :expand=>true, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb
new file mode 100644
index 0000000000..3449cd4b3d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Thread.new{Tk.mainloop}
+
+d = Tk::Iwidgets::Dialog.new(:modality=>:application)
+
+d.buttonconfigure('OK', :command=>proc{puts 'OK'; d.deactivate true})
+d.buttonconfigure('Apply', :command=>proc{puts 'Apply'})
+d.buttonconfigure('Cancel', :command=>proc{puts 'Cancel'; d.deactivate false})
+d.buttonconfigure('Help', :command=>proc{puts 'Help'})
+
+TkListbox.new(d.child_site, :relief=>:sunken).pack(:expand=>true, :fill=>:both)
+
+if TkComm.bool(d.activate)
+ puts "Exit via OK button"
+else
+ puts "Exit via Cancel button"
+end
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb b/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb
new file mode 100644
index 0000000000..197521e0a4
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+ds = Tk::Iwidgets::Dialogshell.new(:modality=>:none)
+
+ds.add('OK', :text=>'OK', :command=>proc{puts 'OK'; ds.deactivate})
+ds.add('Cancel', :text=>'Cancel', :command=>proc{puts 'Cancel'; ds.deactivate})
+ds.default('OK')
+
+TkButton.new(:text=>'ACTIVATE', :padx=>7, :pady=>7,
+ :command=>proc{puts ds.activate}).pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb
new file mode 100644
index 0000000000..85c5d03d17
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+djl = Tk::Iwidgets::Disjointlistbox.new.pack(:fill=>:both, :expand=>true,
+ :padx=>10, :pady=>10)
+djl.set_lhs(*[0,2,4,5])
+djl.set_rhs(3,6)
+
+djl.insert_lhs(1,7,8)
+djl.insert_rhs(9)
+
+p djl.get_lhs
+p djl.get_rhs
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb
new file mode 100644
index 0000000000..856d883a92
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+#########################################################
+#
+# use Tk::UTF8_String() for a utf8 charecter
+#
+#########################################################
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"})
+
+fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:',
+ :fixed=>10, :width=>12)
+
+nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:',
+ :validate=>:numeric, :width=>12)
+
+aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:',
+ :validate=>:alphabetic, :width=>12,
+ :invalid=>proc{
+ puts "Alphabetic contents invalid"
+ })
+
+pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12,
+ :show=>Tk::UTF8_String("\267"),
+ ## <=== utf8 character
+ :command=>proc{puts "Return Pressed"})
+
+Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef)
+
+ef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+fef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+nef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+aef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+pef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb
new file mode 100644
index 0000000000..4a4c2e7eb7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#########################################################
+#
+# set $KCODE to 'utf' for a utf8 charecter
+#
+#########################################################
+$KCODE='utf'
+
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"})
+
+fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:',
+ :fixed=>10, :width=>12)
+
+nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:',
+ :validate=>:numeric, :width=>12)
+
+aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:',
+ :validate=>:alphabetic, :width=>12,
+ :invalid=>proc{
+ puts "Alphabetic contents invalid"
+ })
+
+pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12,
+ :show=>"\267", ## <=== utf8 character
+ :command=>proc{puts "Return Pressed"})
+
+Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef)
+
+ef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+fef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+nef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+aef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+pef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb
new file mode 100644
index 0000000000..bddd542f64
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#########################################################
+#
+# set Tk.encoding = 'utf-8' for a utf8 charecter
+#
+#########################################################
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk.encoding = 'utf-8'
+
+TkOption.add('*textBackground', 'white')
+
+ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"})
+
+fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:',
+ :fixed=>10, :width=>12)
+
+nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:',
+ :validate=>:numeric, :width=>12)
+
+aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:',
+ :validate=>:alphabetic, :width=>12,
+ :invalid=>proc{
+ puts "Alphabetic contents invalid"
+ })
+
+pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12,
+ :show=>"\267", ## <=== utf8 character
+ :command=>proc{puts "Return Pressed"})
+
+Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef)
+
+ef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+fef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+nef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+aef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+pef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb b/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb
new file mode 100644
index 0000000000..6971052b60
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Extbutton.new(:text=>'Bitmap example', :bitmap=>'info',
+ :background=>'bisque', :activeforeground=>'red',
+ :bitmapforeground=>'blue', :defaultring=>true,
+ :command=>proc{
+ puts "Bisque is beautiful"
+ }).pack(:expand=>true)
+
+#img = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), '../../../images/earthris.gif'))
+img = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/clear.gif'))
+
+Tk::Iwidgets::Extbutton.new(:text=>'Image example', :relief=>:ridge,
+ :image=>img, :imagepos=>:e, :font=>'9x15bold',
+ :activebackground=>'lightyellow',
+ :background=>'lightgreen').pack(:expand=>true)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb
new file mode 100644
index 0000000000..4738084d9d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Extfileselectionbox.new.pack(:padx=>10, :pady=>10,
+ :fill=>:both, :expand=>true)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb
new file mode 100644
index 0000000000..c1a9b3defd
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+#
+# Non-modal example
+#
+nmfsd = Tk::Iwidgets::Extfileselectiondialog.new(:title=>'Non-Modal')
+nmfsd.buttonconfigure('OK', :command=>proc{
+ puts "You selected #{nmfsd.get}"
+ nmfsd.deactivate
+ })
+nmfsd.activate
+
+#
+# Modal example
+#
+mfsd = Tk::Iwidgets::Extfileselectiondialog.new(:modality=>:application)
+mfsd.center
+if TkComm.bool(mfsd.activate)
+ puts "You selected #{mfsd.get}"
+else
+ puts "You cancelled the dialog"
+end
+
+
+mainloop.join
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb b/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb
new file mode 100644
index 0000000000..7b87a029ed
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Feedback.new(:labeltext=>'Status', :steps=>20){|fb|
+ pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true)
+ TkTimer.new(500, 20, proc{fb.step}).start(2500)
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb
new file mode 100644
index 0000000000..2ad3adb974
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Fileselectionbox.new.pack(:padx=>10, :pady=>10,
+ :fill=>:both, :expand=>true)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb
new file mode 100644
index 0000000000..ff22b2f643
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+#
+# Non-modal example
+#
+nmfsd = Tk::Iwidgets::Fileselectiondialog.new(:title=>'Non-Modal')
+nmfsd.buttonconfigure('OK', :command=>proc{
+ puts "You selected #{nmfsd.get}"
+ nmfsd.deactivate
+ })
+nmfsd.activate
+
+#
+# Modal example
+#
+mfsd = Tk::Iwidgets::Fileselectiondialog.new(:modality=>:application)
+mfsd.center
+if TkComm.bool(mfsd.activate)
+ puts "You selected #{mfsd.get}"
+else
+ puts "You cancelled the dialog"
+end
+
+mainloop.join
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb
new file mode 100644
index 0000000000..110efb9b96
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+st = Tk::Iwidgets::Scrolledtext.new.pack
+st.insert('end', "Now is the time for all good men\n")
+st.insert('end', "to come to the aid of their country")
+
+fd = Tk::Iwidgets::Finddialog.new(:textwidget=>st)
+fd.center(st)
+fd.activate
+
+mainloop.join
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb b/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb
new file mode 100644
index 0000000000..c83ae37248
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+def get_files(file)
+ dir = (file.empty?)? ENV['HOME'] : file
+ Dir.chdir(dir) rescue return ''
+ rlist = []
+ Dir['*'].sort.each{|f| rlist << File.join(dir, f) }
+ rlist
+end
+
+Tk::Iwidgets::Hierarchy.new(:querycommand=>proc{|arg| get_files(arg.node)},
+ :visibleitems=>'30x15',
+ :labeltext=>ENV['HOME']).pack(:side=>:left,
+ :expand=>true,
+ :fill=>:both)
+
+# Tk::Iwidgets::Hierarchy.new(:querycommand=>[proc{|n| get_files(n)}, '%n'],
+# :visibleitems=>'30x15',
+# :labeltext=>ENV['HOME']).pack(:side=>:left,
+# :expand=>true,
+# :fill=>:both)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb b/ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb
new file mode 100644
index 0000000000..f9c92bf6dc
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+dir = '/usr/local/ActiveTcl/demos/IWidgets/html/'
+href = [ 'hyperhelp.n', 'buttonbox.n', 'calendar.n' ]
+
+hh = Tk::Iwidgets::Hyperhelp.new(:topics=>href, :helpdir=>dir)
+hh.show_topic('hyperhelp.n')
+hh.activate
+
+mainloop.join
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb b/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb
new file mode 100644
index 0000000000..4e2e21e727
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+lf = Tk::Iwidgets::Labeledframe.new(:labeltext=>'Entry Frame', :labelpos=>:n)
+lf.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10)
+
+cs = lf.child_site
+
+Tk::Iwidgets::Entryfield.new(cs, :labeltext=>'Name:').pack(:side=>:top, :fill=>:x)
+Tk::Iwidgets::Spinint.new(cs, :labeltext=>'Number:').pack(:side=>:top, :fill=>:x)
+Tk::Iwidgets::Pushbutton.new(cs, :text=>'Details:').pack(:side=>:top, :fill=>:x)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb b/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb
new file mode 100644
index 0000000000..1d2e0a98a3
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+lw = Tk::Iwidgets::Labeledwidget.new(:labeltext=>'Canvas Widget',
+ :labelpos=>:s)
+lw.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10)
+
+cw = TkCanvas.new(lw.child_site, :relief=>:raised, :width=>200, :height=>200,
+ :borderwidth=>3, :background=>:white)
+cw.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb b/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb
new file mode 100644
index 0000000000..b87a6d27f9
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb
@@ -0,0 +1,64 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mw = Tk::Iwidgets::Mainwindow.new
+
+mw.menubar.add(:menubutton, 'file', :text=>'File', :underline=>0,
+ :padx=>8, :pady=>2, :menu=>[
+ [:options, {:tearoff=>false}],
+
+ [:command, 'new', {
+ :label=>'New', :underline=>0,
+ :helpstr=>'Create a new file'
+ }
+ ],
+
+ [:command, 'open', {
+ :label=>'Open ...', :underline=>0,
+ :helpstr=>'Open an existing file'
+ }
+ ],
+
+ [:command, 'save', {
+ :label=>'Save', :underline=>0,
+ :helpstr=>'Save the current file'
+ }
+ ],
+
+ [:command, 'saveas', {
+ :label=>'Save As', :underline=>5,
+ :helpstr=>'Save the file as a different name'
+ }
+ ],
+
+ [:command, 'print', {
+ :label=>'Print', :underline=>0,
+ :helpstr=>'Print the file'
+ }
+ ],
+
+ [:separator, 'sep1'],
+
+ [:command, 'close', {
+ :label=>'Close', :underline=>0,
+ :helpstr=>'Close the file'
+ }
+ ],
+
+ [:separator, 'sep2'],
+
+ [:command, 'exit', {
+ :label=>'Exit', :underline=>1,
+ :helpstr=>'Exit this application'
+ }
+ ],
+
+ nil
+ ])
+
+Tk::Iwidgets::Scrolledtext.new(mw.child_site).pack(:fill=>:both, :expand=>true)
+
+mw.activate
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb
new file mode 100644
index 0000000000..891761adc1
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb
@@ -0,0 +1,124 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+helpvar = TkVariable.new
+viewmode = TkVariable.new
+
+menu_spec = [
+ [:menubutton, 'file', {
+ :text=>'File', :menu=>[
+ [:options, {:tearoff=>false}],
+
+ [:command, 'new', {
+ :label=>'New', :helpstr=>'Open new document',
+ :command=>proc{puts 'NEW'}
+ }
+ ],
+
+ [:command, 'close', {
+ :label=>'Close', :helpstr=>'Close current document',
+ :command=>proc{puts 'CLOSE'}
+ }
+ ],
+
+ [:separator, 'sep1'],
+
+ [:command, 'exit', {
+ :label=>'Exit', :helpstr=>'Exit application',
+ :command=>proc{exit}
+ }
+ ]
+ ]
+ }
+ ],
+
+ [:menubutton, 'edit', {
+ :text=>'Edit', :menu=>[
+ [:options, {:tearoff=>false}],
+
+ [:command, 'undo', {
+ :label=>'Undo', :underline=>0,
+ :helpstr=>'Undo last command',
+ :command=>proc{puts 'UNDO'}
+ }
+ ],
+
+ [:separator, 'sep2'],
+
+ [:command, 'cut', {
+ :label=>'Cut', :underline=>1,
+ :helpstr=>'Cut selection to clipboard',
+ :command=>proc{puts 'CUT'}
+ }
+ ],
+
+ [:command, 'copy', {
+ :label=>'Copy', :underline=>1,
+ :helpstr=>'Copy selection to clipboard',
+ :command=>proc{puts 'COPY'}
+ }
+ ],
+
+ [:command, 'paste', {
+ :label=>'Paste', :underline=>0,
+ :helpstr=>'Paste clipboard contents',
+ :command=>proc{puts 'PASTE'}
+ }
+ ]
+ ]
+ }
+ ],
+
+ [:menubutton, 'options', {
+ :text=>'Options', :menu=>[
+ [:options, {:tearoff=>false, :selectcolor=>'blue'}],
+
+ [:radiobutton, 'byName', {
+ :variable=>viewmode, :value=>'NAME',
+ :label=>'by Name', :helpstr=>'View files by name order',
+ :command=>proc{puts 'NAME'}
+ }
+ ],
+
+ [:radiobutton, 'byDate', {
+ :variable=>viewmode, :value=>'DATE',
+ :label=>'by Date', :helpstr=>'View files by date order',
+ :command=>proc{puts 'DATE'}
+ }
+ ],
+
+ [:cascade, 'prefs', {
+ :label=>'Preferences', :menu=>[
+ [:command, 'colors', {
+ :label=>'Colors...', :helpstr=>'Change text colors',
+ :command=>proc{puts 'COLORS'}
+ }
+ ],
+
+ [:command, 'fonts', {
+ :label=>'Fonts...', :helpstr=>'Change text font',
+ :command=>proc{puts 'COLORS'}
+ }
+ ]
+ ]
+ }
+ ]
+ ]
+ }
+ ]
+]
+
+#mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar,
+# :menubuttons=>menu_spec)
+mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar)
+mb.configure(:menubuttons=>menu_spec)
+
+fr = TkFrame.new(:width=>300, :height=>300)
+ef = TkEntry.new(:textvariable=>helpvar)
+
+mb.pack(:anchor=>:nw, :fill=>:x, :expand=>true)
+fr.pack(:fill=>:both, :expand=>true)
+ef.pack(:anchor=>:sw, :fill=>:x, :expand=>true)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb
new file mode 100644
index 0000000000..d6f2292650
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+helpvar = TkVariable.new
+viewmode = TkVariable.new
+
+mb = Tk::Iwidgets::Menubar.new
+mb.menubuttons = [
+ [:menubutton, 'file', {
+ :text=>'File', :menu=>[
+ [:command, 'new', {:label=>'New'}],
+ [:command, 'close', {:label=>'Close'}],
+ [:separator, 'sep1'],
+ [:command, 'quit', {:label=>'Quit'}]
+ ]
+ }
+ ],
+ [:menubutton, 'edit', {:text=>'Edit'}]
+]
+
+mb.add(:command, '.edit.undo', :label=>'Undo', :underline=>0)
+mb.add(:separator, '.edit.sep2')
+mb.add(:command, '.edit.cut', :label=>'Cut', :underline=>1)
+mb.add(:command, '.edit.copy', :label=>'Copy', :underline=>1)
+mb.add(:command, '.edit.paste', :label=>'Paste', :underline=>0)
+
+mb.add(:menubutton, '.options', :text=>'Options', :menu=>[
+ [:radiobutton, 'byName', {
+ :variable=>viewmode, :value=>'NAME', :label=>'by Name'}
+ ],
+ [:radiobutton, 'byDate', {
+ :variable=>viewmode, :value=>'DATE', :label=>'by Date'}
+ ]
+ ])
+
+mb.add(:cascade, '.options.prefs', :label=>'Preferences', :menu=>[
+ [:command, 'colors', {:label=>'Colors...'}],
+ [:command, 'fonts', {:label=>'Fonts...'}]
+ ])
+
+mb.pack(:side=>:left, :anchor=>:nw, :fill=>:x, :expand=>true)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb
new file mode 100644
index 0000000000..3221dbc30c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic,
+ :labeltext=>'Messages', :labelpos=>:n,
+ :height=>120, :width=>550,
+ :savedir=>'/tmp', :textbackground=>'#d9d9d9')
+mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true)
+
+mb.type_add('ERROR', :background=>'red', :foreground=>'white', :bell=>true)
+mb.type_add('WARNING', :background=>'yellow', :foreground=>'black')
+mb.type_add('INFO', :background=>'white', :foreground=>'black')
+
+mb.issue('This is an error message in red with a beep', 'ERROR')
+mb.issue('This warning message in yellow', 'WARNING')
+mb.issue('This is an informational message', 'INFO')
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb
new file mode 100644
index 0000000000..2f0e3648a6
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic,
+ :labeltext=>'Messages', :labelpos=>:n,
+ :height=>120, :width=>550,
+ :savedir=>'/tmp', :textbackground=>'#d9d9d9')
+mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true)
+
+error = mb.type_add(:background=>'red', :foreground=>'white', :bell=>true)
+warning = mb.type_add(:background=>'yellow', :foreground=>'black')
+info = mb.type_add(:background=>'white', :foreground=>'black')
+
+mb.issue('This is an error message in red with a beep', error)
+mb.issue('This warning message in yellow', warning)
+mb.issue('This is an informational message', info)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb
new file mode 100644
index 0000000000..6c6bfbca3f
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+#
+# Standard question message dialog used for confirmation.
+#
+md = Tk::Iwidgets::Messagedialog.new(:title=>'Message Dialog',
+ :text=>'Are you sure ? ',
+ :bitmap=>'questhead', :modality=>:global)
+
+md.buttonconfigure('OK', :text=>'Yes')
+md.buttonconfigure('Cancel', :text=>'No')
+
+if TkComm.bool(md.activate)
+ md.text('Are you really sure ? ')
+ if TkComm.bool(md.activate)
+ puts 'Yes'
+ else
+ puts 'No'
+ end
+else
+ puts 'No'
+end
+
+md.destroy
+
+#
+# Copyright notice with automatic deactivation.
+#
+bmp = '@' + File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/text.xbm')
+
+cr = Tk::Iwidgets::Messagedialog.new(:title=>'Copyright',
+ :bitmap=>bmp, :imagepos=>:n,
+ :text=>"Copyright 200x XXX Corporation\nAll rights reserved")
+
+cr.hide('Cancel')
+
+cr.activate
+Tk.after(7000, proc{cr.deactivate; Tk.root.destroy})
+
+mainloop.join
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb b/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb
new file mode 100644
index 0000000000..e33b81eb6f
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100)
+nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:left, :padx=>10, :pady=>10)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+nb.add(:label=>'Page One')
+nb.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = nb.child_site(0)
+page2CS = nb.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+nb.select(0)
+
+# Create the scrollbar and associate teh scrollbar
+# and the notebook together, then pack the scrollbar
+nb.scrollbar(TkScrollbar.new).pack(:fill=>:y, :expand=>true, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb
new file mode 100644
index 0000000000..649de4f024
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100)
+nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:top, :padx=>10, :pady=>0)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+nb.add(:label=>'Page One')
+nb.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = nb.child_site(0)
+page2CS = nb.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+nb.select(0)
+
+# Create the scrollbar and associate teh scrollbar
+# and the notebook together, then pack the scrollbar
+nb.xscrollbar(TkScrollbar.new).pack(:fill=>:x, :expand=>true, :padx=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb b/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb
new file mode 100644
index 0000000000..1fd7a5bc05
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+om = Tk::Iwidgets::Optionmenu.new(:labelmargin=>5, :labelpos=>:w,
+ :labeltext=>"Operating System :")
+
+om.insert('end', 'Unix', 'VMS', 'Linux', 'OS/2', 'Windows NT', 'DOS')
+om.sort_ascending
+om.select('Linux')
+
+om.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb
new file mode 100644
index 0000000000..6e4458e508
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300)
+
+pw.add('top')
+pw.add('middle', :margin=>10)
+pw.add('bottom', :margin=>10, :minimum=>10)
+
+pw.pack(:fill=>:both, :expand=>true)
+
+pw.child_site_list.each{|pane|
+ TkButton.new(pane, :text=>pane.path, :relief=>:raised,
+ :borderwidth=>2).pack(:fill=>:both, :expand=>true)
+}
+
+pw.fraction(50,30,20)
+pw.paneconfigure(0, :minimum=>20)
+pw.paneconfigure('bottom', :margin=>15)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb
new file mode 100644
index 0000000000..6779cb57db
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300)
+
+top = pw.add
+middle = pw.add(:margin=>10)
+bottom = pw.add(:margin=>10, :minimum=>10)
+
+pw.pack(:fill=>:both, :expand=>true)
+
+pw.child_site_list.each{|pane|
+ TkButton.new(pane, :text=>pane.path, :relief=>:raised,
+ :borderwidth=>2).pack(:fill=>:both, :expand=>true)
+}
+
+pw.fraction(50,30,20)
+pw.paneconfigure(0, :minimum=>20) # 0 == pw.index(top)
+pw.paneconfigure(bottom, :margin=>15)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb
new file mode 100644
index 0000000000..2c643e56f7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+TkOption.add('*textBackground', 'white')
+
+pd = Tk::Iwidgets::Promptdialog.new(:modality=>:global, :title=>'Password',
+ :labeltext=>'Password:', :show=>'*')
+pd.hide('Apply')
+
+if TkComm.bool(pd.activate)
+ puts "Password entered: #{pd.get}"
+else
+ puts "Password prompt cancelled"
+end
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb b/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb
new file mode 100644
index 0000000000..6e1c3fffe3
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Pushbutton.new(:text=>'Hello',
+ :command=>proc{puts 'Hello World'},
+ :defaultring=>true).pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb
new file mode 100644
index 0000000000..9cd6a002b0
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+rb = Tk::Iwidgets::Radiobox.new(:labeltext=>'Fonts')
+rb.add('times', :text=>'Times')
+rb.add('helvetica', :text=>'Helvetica')
+rb.add('courier', :text=>'Courier')
+rb.add('symbol', :text=>'Symbol')
+rb.select('courier')
+rb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb
new file mode 100644
index 0000000000..92c94b96bb
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+sc = Tk::Iwidgets::Scrolledcanvas.new
+
+sc.create(TkcRectangle, 100, 100, 400, 400, :fill=>'red')
+TkcRectangle.new(sc, 300, 300, 600, 600, :fill=>'green')
+TkcRectangle.new(sc, [[200, 200], [500, 500]], :fill=>'blue')
+
+sc.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb
new file mode 100644
index 0000000000..5219847c9c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+sf = Tk::Iwidgets::Scrolledframe.new(:width=>150, :height=>180,
+ :labeltext=>'scrolledframe')
+cs = sf.child_site
+
+TkButton.new(cs, :text=>'Hello').pack(:pady=>10)
+TkButton.new(cs, :text=>'World').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is a test').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is a really big button').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is another really big button').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is the last really big button').pack(:pady=>10)
+
+sf.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb
new file mode 100644
index 0000000000..04334b8da8
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+sh = Tk::Iwidgets::Scrolledhtml.new(:fontname=>'helvetica',
+ :linkcommand=>proc{|href|
+ sh.import_link(href)
+ })
+sh.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+sh.import(Tk.getOpenFile(:title=>'select HTML document'))
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb
new file mode 100644
index 0000000000..0b69751911
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+slb = Tk::Iwidgets::Scrolledlistbox.new(:selectmode=>:single,
+ :vscrollmode=>:static,
+ :hscrollmode=>:dynamic,
+ :labeltext=>'List',
+ :selectioncommand=>proc{
+ puts(slb.get_curselection)
+ },
+ :dblclickcommand=>proc{
+ puts('Double Click')
+ puts(slb.get_curselection)
+ })
+slb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+slb.insert('end', *['Hello', 'Out There', 'World'])
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb
new file mode 100644
index 0000000000..dd1a99a829
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+st = Tk::Iwidgets::Scrolledtext.new(:hscrollmode=>:dynamic, :wrap=>:none,
+ :labeltext=>'Password File')
+st.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+st.import('/etc/passwd')
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb b/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb
new file mode 100644
index 0000000000..a5d623ae80
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+sb = Tk::Iwidgets::Selectionbox.new.pack(:padx=>10, :pady=>10,
+ :fill=>:both, :expand=>true)
+
+sb.insert_items('end', *['Hello', 'Out There', 'World'])
+
+TkLabel.new(sb.child_site,
+ :text=>'Child Site is Here').pack(:fill=>:x, :padx=>10, :pady=>10)
+
+sb.insert_items(2, 'Cruel Cruel')
+
+sb.selection_set(1)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb b/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb
new file mode 100644
index 0000000000..f40b419180
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+TkButton.new(:text=>'QUIT',
+ :command=>proc{Tk.root.destroy}).pack(:padx=>10, :pady=>10)
+
+Tk::Iwidgets::Selectiondialog.new.activate
+
+mainloop.join
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb b/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb
new file mode 100644
index 0000000000..c44b5554a6
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+sh = Tk::Iwidgets::Shell.new(:modality=>:application,
+ :padx=>20, :pady=>20, :title=>'Shell')
+
+TkButton.new(:text=>'ACTIVATE', :padx=>7, :pady=>7,
+ :command=>proc{puts sh.activate}).pack(:padx=>10, :pady=>10)
+
+TkLabel.new(sh.child_site, :text=>'SHELL').pack
+TkButton.new(sh.child_site, :text=>'YES',
+ :command=>proc{sh.deactivate 'press YES'}).pack(:fill=>:x)
+TkButton.new(sh.child_site, :text=>'NO',
+ :command=>proc{sh.deactivate 'press NO'}).pack(:fill=>:x)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb
new file mode 100644
index 0000000000..17197a66b7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Spindate.new.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb
new file mode 100644
index 0000000000..0bcdefb763
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+Tk::Iwidgets::Spinint.new(:labeltext=>'Temperature', :labelpos=>:w, :width=>5,
+ :fixed=>true, :range=>[32, 212]).pack(:pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb
new file mode 100644
index 0000000000..295d38ee96
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+class Spinner_demo < TkWindow
+ Months = %w(January February March April May June July August September October November December)
+
+ def block_input(c)
+ false
+ end
+
+ def spin_month(step)
+ index = Months.index(@spinner.get) + step
+ index = 11 if index < 0
+ index = 0 if index > 11
+
+ @spinner.value = Months[index]
+ end
+
+ def initialize(parent=nil)
+ @spinner = Tk::Iwidgets::Spinner.new(parent, :labeltext=>'Month : ',
+ :width=>10, :fixed=>10,
+ :validate=>proc{|c| block_input},
+ :decrement=>proc{spin_month -1},
+ :increment=>proc{spin_month 1})
+ @path = @spinner
+ @spinner.insert(0, Months[0])
+ end
+end
+
+Spinner_demo.new.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb b/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb
new file mode 100644
index 0000000000..2c13884b94
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Spintime.new.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb
new file mode 100644
index 0000000000..6f1ecc4fa4
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100)
+tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:left, :padx=>10, :pady=>10)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+tn.add(:label=>'Page One')
+tn.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = tn.child_site(0)
+page2CS = tn.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+tn.select(0)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb
new file mode 100644
index 0000000000..4a5eef5a8f
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100)
+tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:top, :padx=>10, :pady=>0)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+tn.add(:label=>'Page One')
+tn.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = tn.child_site(0)
+page2CS = tn.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+tn.select(0)
+
+# Create the scrollbar
+# and the notebook together, then pack the scrollbar
+tn.xscrollbar(TkScrollbar.new).pack(:fill=>:x, :expand=>true, :padx=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb b/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb
new file mode 100644
index 0000000000..90be46b40b
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create a listbox with two items (one and two)
+l = TkListbox.new(:selectmode=>:single, :exportselection=>false).pack
+l.insert('end', 'one')
+l.insert('end', 'two')
+l.selection_set(0)
+
+# Define a proc that knows how to select an item
+# from a list given an index from the tabset -command callback.
+selectItem = proc{|item|
+ l.selection_clear(l.curselection)
+ l.selection_set(item)
+ l.see(item)
+}
+
+# Create a tabset, set its -command to call selectItem
+# Add two labels to the tabset (one and two).
+ts = Tk::Iwidgets::Tabset.new(:command=>selectItem)
+ts.add(:label=>1)
+ts.add(:label=>2)
+ts.select(0)
+ts.pack(:fill=>:x, :expand=>true)
+
+# Define a proc that knows how to select a tab
+# given a y pixel coordinate from the list..
+selectTab = proc{|y| ts.select(l.nearest(y)) }
+
+# bind button 1 press to the selectTab procedure.
+l.bind('ButtonPress-1', proc{|y| selectTab.call(y) }, '%y')
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb b/ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb
new file mode 100644
index 0000000000..465939947b
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Timeentry.new.pack
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb b/ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb
new file mode 100644
index 0000000000..bb5945048d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+tf = Tk::Iwidgets::Timefield.new(:command=>proc{puts(tf.get)})
+tf.pack(:fill=>:x, :expand=>true, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb b/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb
new file mode 100644
index 0000000000..355466eb1a
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb
@@ -0,0 +1,152 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+##########################################
+# icon images
+editcopy22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxa
+ XMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy
+ 7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyy
+ lPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbY
+ QIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6
+ GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBsc
+ AY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4g
+ KIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATy
+ VoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0
+ ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5
+ OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2
+ ZWxjb3IuY29tADs=
+EOD
+
+editcut22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE
+ 0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkc
+ pkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVh
+ dGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAx
+ OTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRl
+ dmVsY29yLmNvbQA7
+EOD
+
+editpaste22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6
+ /NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS
+ 1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2
+ tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq
+ 7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6
+ PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz2
+ 7Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTS
+ tNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA
+ LAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4F
+ DxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wr
+ LS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCN
+ DiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LA
+ QOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4
+ wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4
+ oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpg
+ weLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5
+ OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5
+ IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5
+ OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29y
+ LmNvbQA7
+EOD
+
+editdelete22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwK
+ DAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzK
+ xIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwC
+ BMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyy
+ nOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA
+ LAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMN
+ EqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqz
+ kBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0S
+ F+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsyg
+ sVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDY
+ CKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENy
+ ZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29y
+ IDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cu
+ ZGV2ZWxjb3IuY29tADs=
+EOD
+
+text22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRS
+ VCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmK
+ QSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bs
+ t9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5o
+ Q3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxD
+ b3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3
+ dy5kZXZlbGNvci5jb20AOw==
+EOD
+
+##########################################
+
+bmp_dir = File.join(File.dirname(File.expand_path(__FILE__)),
+ '../catalog_demo/images')
+
+##########################################
+
+status_var = TkVariable.new
+radio_var = TkVariable.new
+check_var1 = TkVariable.new
+check_var2 = TkVariable.new
+
+tb = Tk::Iwidgets::Toolbar.new(:helpvariable=>status_var)
+
+##########################################
+
+tb.add(:button, :helpstr=>'Copy It', :image=>editcopy22,
+ :balloonstr=>'Copy', :command=>proc{puts 'Copy It'})
+
+tb.add(:button, :helpstr=>'Cut It', :image=>editcut22,
+ :balloonstr=>'Cut', :command=>proc{puts 'Cut It'})
+
+tb.add(:button, :helpstr=>'Paste It', :image=>editpaste22,
+ :balloonstr=>'Paste', :command=>proc{puts 'Paste It'})
+
+tb.add(:button, :helpstr=>'Delete It', :image=>editdelete22,
+ :balloonstr=>'Delete', :command=>proc{puts 'Delete It'})
+
+#--------------------------------
+
+tb.add(:frame, :borderwidth=>1, :width=>10, :height=>10)
+
+#--------------------------------
+
+tb.add(:radiobutton, :variable=>radio_var, :value=>'Box',
+ :bitmap=>"@#{bmp_dir}/box.xbm",
+ :helpstr=>'Radio Button #1', :balloonstr=>'Radio',
+ :command=>proc{puts 'Radio Button "Box"'})
+
+tb.add(:radiobutton, :variable=>radio_var, :value=>'Line',
+ :bitmap=>"@#{bmp_dir}/line.xbm",
+ :helpstr=>'Radio Button #2', :balloonstr=>'Radio',
+ :command=>proc{puts 'Radio Button "Line"'})
+
+tb.add(:radiobutton, :variable=>radio_var, :value=>'Oval',
+ :bitmap=>"@#{bmp_dir}/oval.xbm",
+ :helpstr=>'Radio Button #3', :balloonstr=>'Radio',
+ :command=>proc{puts 'Radio Button "Oval"'})
+
+#--------------------------------
+
+tb.add(:frame, :borderwidth=>1, :width=>10, :height=>10)
+
+#--------------------------------
+
+tb.add(:checkbutton, :variable=>check_var1, :onvalue=>'yes', :offvalue=>'no',
+ :image=>text22, :command=>proc{puts 'Checkbutton 1'})
+
+tb.add(:checkbutton, :variable=>check_var2, :onvalue=>'yes', :offvalue=>'no',
+ :bitmap=>"@#{bmp_dir}/points.xbm", :command=>proc{puts 'Checkbutton 2'})
+
+tb.pack(:side=>:top, :anchor=>:nw)
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb b/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb
new file mode 100644
index 0000000000..808c798aec
--- /dev/null
+++ b/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Thread.new{
+ trap('INT') {puts 'catch SIGINT'}
+ sleep 5
+ trap('INT', 'DEFAULT')
+}
+
+Tk::Iwidgets::Watch.new(:state=>:disabled, :showampm=>:no,
+ :width=>155, :height=>155){|w|
+ w.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true)
+ # TkTimer.new(1000, -1, proc{w.show; Tk.update}).start
+ TkTimer.new(25, -1, proc{w.show; Tk.update}).start
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt b/ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt
new file mode 100644
index 0000000000..272853870c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt
@@ -0,0 +1,46 @@
+
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ >>> The following text is the original 'license.term' of tklib <<<
+ >>> extension. <<<
+ >>> Original Tcl files are not include in this directry, because <<<
+ >>> of all of them are rewrited to Ruby files. <<<
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+This software is copyrighted by Ajuba Solutions and other parties.
+The following terms apply to all files associated with the software unless
+explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/ext/tk/sample/tkextlib/tcllib/datefield.rb b/ext/tk/sample/tkextlib/tcllib/datefield.rb
new file mode 100644
index 0000000000..cfeca0c6de
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tcllib/datefield.rb
@@ -0,0 +1,29 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/datefield'
+require 'parsedate'
+
+Tk.root.title('Datefield example')
+
+
+my_date1 = TkVariable.new
+my_date2 = TkVariable.new
+my_date1.trace('w'){
+ begin
+ t = Time.local(*(ParseDate.parsedate(my_date1.value)))
+ my_date2.value = t.strftime('%A')
+ rescue
+ # ignore error
+ end
+}
+
+df = Tk::Tcllib::Datefield.new(:textvariable=>my_date1)
+Tk.grid(TkLabel.new(:text=>'Enter a date:', :anchor=>:e), df, :sticky=>:ew)
+Tk.grid(TkLabel.new(:text=>'That date ia a:', :anchor=>:e),
+ TkLabel.new(:textvariable=>my_date2, :relief=>:sunken, :width=>12),
+ :sticky=>:ew)
+
+df.set_focus
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb b/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb
new file mode 100644
index 0000000000..053b0de085
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb
@@ -0,0 +1,158 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+###############################
+
+c1 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+c2 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+c3 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+Tk.pack(c1,c2,c3, :fill=>:both, :side=>:top)
+
+h = TkToplevel.new(:title=>'h')
+hc1 = TkCanvas.new(h, :background=>'white', :width=>400, :height=>200)
+hc2 = TkCanvas.new(h, :background=>'white', :width=>400, :height=>200)
+Tk.pack(hc1,hc2, :fill=>:both, :side=>:top)
+
+v = TkToplevel.new(:title=>'v')
+vc1 = TkCanvas.new(v, :background=>'white', :width=>400, :height=>200)
+vc2 = TkCanvas.new(v, :background=>'white', :width=>400, :height=>200)
+vc3 = TkCanvas.new(v, :background=>'white', :width=>400, :height=>200)
+Tk.pack(vc1,vc2,vc3, :fill=>:both, :side=>:top)
+
+###############################
+
+s = Tk::Tcllib::Plotchart::XYPlot.new(c1, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0])
+
+
+xd = 5.0
+yd = 20.0
+xold = 0.0
+yold = 50.0
+
+s.dataconfig('series1', :color=>'red')
+
+(0..19).each{|i|
+ xnew = xold + xd
+ ynew = yold + (rand() - 0.5) * yd
+ ynew2 = yold + (rand() - 0.5) * 2.0 * yd
+ s.plot('series1', xnew, ynew)
+ s.plot('series2', xnew, ynew2)
+ xold = xnew
+ yold = ynew
+}
+
+s.xtext "X-coordinate"
+s.ytext "Y-data"
+s.title "Aha!"
+
+c1.wait_visibility
+
+s.save_plot "aha.ps"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Piechart.new(c2)
+
+s.plot([ ["Long names", 10], ["Short names", 30],
+ ["Average", 40], ["Ultra-short names", 5] ])
+
+#
+# Note: title should be shifted up
+# - distinguish a separate title area
+#
+s.title "Okay - this works"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::PolarPlot.new(c3, [3.0, 1.0])
+
+0.step(359, 10){|angle|
+ rad = 1.0+Math.cos(angle*Math::PI/180.0)
+ s.plot('cardioid', rad, angle)
+}
+
+s.title "Cardioid"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Barchart.new(hc1, %w(A B C D E),
+ [0.0, 10.0, 2.0], 2)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Arbitrary data"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Barchart.new(hc2, %w(A B C D E),
+ [0.0, 20.0, 5.0], :stacked)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Stacked diagram"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::HorizontalBarchart.new(vc1, [0.0, 10.0, 2.0],
+ %w(A B C D E), 2)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Arbitrary data"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::HorizontalBarchart.new(vc2, [0.0, 20.0, 5.0],
+ %w(A B C D E), :stacked)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Stacked diagram"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Timechart.new(vc3, "1 january 2004",
+ "31 december 2004", 4)
+
+s.period("Spring", "1 march 2004", "1 june 2004", 'green')
+s.period("Summer", "1 june 2004", "1 september 2004", 'yellow')
+s.vertline("1 jan", "1 january 2004")
+s.vertline("1 apr", "1 april 2004")
+s.vertline("1 jul", "1 july 2004")
+s.vertline("1 oct", "1 october 2004")
+s.milestone("Longest day", "21 july 2004")
+s.title "Seasons (northern hemisphere)"
+
+###############################
+
+z = TkToplevel.new(:title=>'3D')
+
+zc1 = TkCanvas.new(z, :background=>'white', :width=>400, :height=>300)
+zc2 = TkCanvas.new(z, :background=>'white', :width=>400, :height=>250)
+Tk.pack(zc1,zc2)
+
+s = Tk::Tcllib::Plotchart::Plot3D.new(zc1,
+ [0, 10, 3], [-10, 10, 10], [0, 10, 2.5])
+
+s.title "3D Plot"
+s.plot_function{|x, y|
+ # cowboyhat
+ x1 = x.to_f/9.0
+ y1 = y.to_f/9.0
+ 3.0 * (1.0-(x1*x1+y1*y1))*(1.0-(x1*x1+y1*y1))
+}
+
+s = Tk::Tcllib::Plotchart::Plot3D.new(zc2,
+ [0, 10, 3], [-10, 10, 10], [0, 10, 2.5])
+s.title "3D Plot - data "
+s.colour("green", "black")
+s.plot_data([ [1.0, 2.0, 1.0, 0.0],
+ [1.1, 3.0, 1.1, -0.5],
+ [3.0, 1.0, 4.0, 5.0] ])
+
+###############################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb b/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb
new file mode 100644
index 0000000000..33a6f29940
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb
@@ -0,0 +1,71 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+###############################
+
+c1 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+c2 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+Tk.pack(c1,c2, :fill=>:both, :side=>:top)
+
+###############################
+# Set up a strip chart
+###############################
+slipchart = Tk::Tcllib::Plotchart::Stripchart.new(c1, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0])
+
+TkTimer.new(500, -1, proc{|obj| # obj --> TkTimer object
+ slipchart, xold, xd, yold, yd = obj.return_value
+ xnew = xold + xd
+ ynew = yold + (rand() - 0.5) * yd
+ ynew2 = yold + (rand() - 0.5) * 2.0 * yd
+ slipchart.plot('series1', xnew, ynew)
+ slipchart.plot('series2', xnew, ynew2)
+ obj.stop if xnew >= 200
+ [slipchart, xnew, xd, ynew, yd] # return_value
+ }).start(100, proc{
+ # init return_value
+ [slipchart, 0.0, 15.0, 50.0, 30.0]
+ })
+
+slipchart.title "Aha!"
+
+###############################
+# Set up an isometric plot
+###############################
+s = Tk::Tcllib::Plotchart::IsometricPlot.new(c2, [0.0, 100.0], [0.0, 200.0],
+ :noaxes)
+
+s.set_zoom_pan
+
+s.plot('rectangle', [10.0, 10.0, 50.0, 50.0], 'green')
+s.plot('filled-rectangle', [20.0, 20.0, 40.0, 40.0], 'red')
+s.plot('filled-circle', [70.0, 70.0, 40.0], 'yellow')
+s.plot('circle', [70.0, 70.0, 42.0])
+
+###############################
+# Check the symbols
+###############################
+h = TkToplevel.new(:title=>'h')
+c = TkCanvas.new(h, :bg=>'white', :width=>400, :height=>200).pack(:fill=>:both)
+
+s = Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0])
+s.dataconfig('series1', :colour=>'red', :type=>:symbol)
+s.dataconfig('series2', :colour=>'green', :type=>:both)
+
+s.yconfig(:format=>"%12.2e")
+
+x = 5.0
+%w(plus cross circle up down dot upfilled downfilled).each{|sym|
+ s.dataconfig('series1', :symbol=>sym)
+ s.dataconfig('series2', :symbol=>sym)
+ s.plot('series1', x, 50.0)
+ s.plot('series2', x, 20)
+ x += 10
+}
+
+##############################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb b/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb
new file mode 100644
index 0000000000..2b5c7642bb
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb
@@ -0,0 +1,83 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+###############################
+# Set up a strip chart
+###############################
+
+Tk::Tcllib::Plotchart::Stripchart.new([0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0],
+ :background=>'white',
+ :width=>400, :height=>200){|chart|
+ title "Aha!"
+ pack(:fill=>:both, :side=>:top)
+
+ series1 = Tk::Tcllib::Plotchart::PlotSeries.new(chart)
+ series2 = Tk::Tcllib::Plotchart::PlotSeries.new(chart)
+
+ xd = 15.0
+ yd = 30.0
+
+ TkTimer.new(500, -1, proc{|obj| # obj --> TkTimer object
+ xold, yold = obj.return_value
+ xnew = xold + xd
+ ynew = yold + (rand() - 0.5) * yd
+ ynew2 = yold + (rand() - 0.5) * 2.0 * yd
+
+ series1.plot(xnew, ynew)
+ series2.plot(xnew, ynew2)
+
+ obj.stop if xnew >= 200
+
+ [xnew, ynew] # return_value
+ }).start(100, proc{ [0.0, 50.0] }) # init return_value
+}
+
+###############################
+# Set up an isometric plot
+###############################
+Tk::Tcllib::Plotchart::IsometricPlot.new([0.0, 100.0], [0.0, 200.0], :noaxes,
+ :background=>'white',
+ :width=>400, :height=>200){|chart|
+ pack(:fill=>:both, :side=>:top)
+ set_zoom_pan
+
+ chart.plot('rectangle', [10.0, 10.0, 50.0, 50.0], 'green')
+ chart.plot('filled-rectangle', [20.0, 20.0, 40.0, 40.0], 'red')
+ chart.plot('filled-circle', [70.0, 70.0, 40.0], 'yellow')
+ chart.plot('circle', [70.0, 70.0, 42.0])
+}
+
+###############################
+# Check the symbols
+###############################
+TkToplevel.new(:title=>'h'){|h|
+ Tk::Tcllib::Plotchart::XYPlot.new(h, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0],
+ :bg=>'white',
+ :width=>400, :height=>200){|chart|
+ pack(:fill=>:both)
+
+ yconfig(:format=>"%12.2e")
+
+ series1 = Tk::Tcllib::Plotchart::PlotSeries.new(chart, :colour=>'red',
+ :type=>:symbol)
+ series2 = Tk::Tcllib::Plotchart::PlotSeries.new(chart, :colour=>'green',
+ :type=>:both)
+
+ x = 5.0
+ %w(plus cross circle up down dot upfilled downfilled).each{|sym|
+ series1.dataconfig(:symbol=>sym)
+ series2.dataconfig(:symbol=>sym)
+ series1.plot(x, 50.0)
+ series2.plot(x, 20)
+ x += 10
+ }
+ }
+}
+
+##############################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tcllib/xyplot.rb b/ext/tk/sample/tkextlib/tcllib/xyplot.rb
new file mode 100644
index 0000000000..8f8c3eb880
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tcllib/xyplot.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+TkCanvas.new(:background=>'white', :width=>400, :height=>200){|c|
+ pack(:fill=>:both)
+ Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0]){
+ [ [0.0, 32.0], [10.0, 50.0], [25.0, 60.0], [78.0, 11.0] ].each{|x, y|
+ plot('series1', x, y)
+ }
+ title("Data series")
+ }
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt b/ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt
new file mode 100644
index 0000000000..2b3757bb23
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt
@@ -0,0 +1,12 @@
+
+The following text is the original 'COPYRIGHT' file of tkHTML.
+
+-----------------------------------------------------------------------
+Most of the source code for the Tk Html widget has been place in the
+public domain. You can do with it whatever you want. However, some
+files have been copied from other sources and contain copyrights.
+A copyright notice appears separately at the top of each source file.
+-----------------------------------------------------------------------
+
+In this sample, HTML documents are quoted in the 'tests' directory of
+tkHTML source tree. There were no copyright notice in the directory.
diff --git a/ext/tk/sample/tkextlib/tkHTML/README b/ext/tk/sample/tkextlib/tkHTML/README
new file mode 100644
index 0000000000..1208e270b4
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/README
@@ -0,0 +1,12 @@
+
+ [ TkHtml widget example ]
+
+The directory page1 -- page4 are referd from "test" directory of
+original TkHtml extension's source archive.
+( see http://www.hwaci.com/sw/tkhtml/index.html )
+
+You can see the HTML documents on the 'hv.rb' or 'ss.rb' sample script.
+
+ e.g.
+ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH /usr/local/bin/ruby ./hv.rb page1/index.html
+
diff --git a/ext/tk/sample/tkextlib/tkHTML/hv.rb b/ext/tk/sample/tkextlib/tkHTML/hv.rb
new file mode 100644
index 0000000000..d9f3ea7d7c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/hv.rb
@@ -0,0 +1,306 @@
+#!/usr/bin/env ruby
+#
+# This script implements the "hv" application. Type "hv FILE" to
+# view FILE as HTML.
+#
+# This application is used for testing the HTML widget. It can
+# also server as an example of how to use the HTML widget.
+#
+require 'tk'
+require 'tkextlib/tkHTML'
+
+root = TkRoot.new(:title=>'HTML File Viewer', :iconname=>'HV')
+
+file = ARGV[0]
+
+#
+# These images are used in place of GIFs or of form elements
+#
+biggray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhPAA+APAAALi4uAAAACwAAAAAPAA+AAACQISPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNFgsAO///
+EOD
+
+smgray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhOAAYAPAAALi4uAAAACwAAAAAOAAYAAACI4SPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9m0VADv/
+EOD
+
+nogifbig = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhJAAkAPEAAACQkADQ0PgAAAAAACwAAAAAJAAkAAACmISPqcsQD6OcdJqKM71PeK15
+ AsSJH0iZY1CqqKSurfsGsex08XuTuU7L9HywHWZILAaVJssvgoREk5PolFo1XrHZ29IZ8oo0
+ HKEYVDYbyc/jFhz2otvdcyZdF68qeKh2DZd3AtS0QWcDSDgWKJXY+MXS9qY4+JA2+Vho+YPp
+ FzSjiTIEWslDQ1rDhPOY2sXVOgeb2kBbu1AAADv/
+EOD
+
+nogifsm = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhEAAQAPEAAACQkADQ0PgAAAAAACwAAAAAEAAQAAACNISPacHtD4IQz80QJ60as25d
+ 3idKZdR0IIOm2ta0Lhw/Lz2S1JqvK8ozbTKlEIVYceWSjwIAO///
+EOD
+
+#
+# define variables
+#
+ul_hyper = TkVariable.new(0)
+show_tbl = TkVariable.new(0)
+show_img = TkVariable.new(1)
+
+#
+# A font chooser routine.
+#
+# html[:fontcommand] = pick_font
+pick_font = proc{|size, attrs|
+ puts "FontCmd: #{size} #{attrs}"
+ [ ((attrs =~ /fixed/)? 'courier': 'charter'),
+ (12 * (1.2**(size.to_f - 4.0))).to_i,
+ ((attrs =~ /italic/)? 'italic': 'roman'),
+ ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ')
+}
+
+#
+# This routine is called for each form element
+#
+form_cmd = proc{|n, cmd, style, *args|
+ # puts "FormCmd: $n $cmd $args"
+ case cmd
+ when 'select', 'textarea', 'input'
+ TkLabel.new(:widgetname=>args[0], :image=>nogifsm)
+ end
+}
+
+#
+# This routine is called for every <IMG> markup
+#
+images = {}
+old_imgs = {}
+big_imgs = {}
+
+hotkey = {}
+
+move_big_image = proc{|b|
+ return unless big_imgs.key?(b)
+ b.copy(big_imgs[b])
+ big_imgs[b].delete
+ big_imgs.delete(b)
+ Tk.update
+}
+
+image_cmd = proc{|*args|
+ return smgray unless show_img.bool
+ fn = args[0]
+ if old_imgs.key?(fn)
+ images[fn] = old_imgs[fn]
+ old_imgs.delete(fn)
+ return images[fn]
+ end
+
+ begin
+ img = TkPhotoImage.new(:file=>fn)
+ rescue
+ return smgray
+ end
+
+ if img.width * img.height > 20000
+ b = TkPhotoImage.new(:width=>img.width, :height=>img.height)
+ big_imgs[b] = img
+ img = b
+ Tk.after_idle(proc{ move_big_image.call(b) })
+ end
+
+ images[fn] = img
+
+ img
+}
+
+#
+# This routine is called for every <SCRIPT> markup
+#
+script_cmd = proc{|*args|
+ # puts "ScriptCmd: #{args.inspect}"
+}
+
+# This routine is called for every <APPLET> markup
+#
+applet_cmd = proc{|w, arglist|
+ # puts "AppletCmd: w=#{w} arglist=#{arglist}"
+ TkLabel.new(w, :text=>"The Applet #{w}", :bd=>2, :relief=>raised)
+}
+
+#
+# Construct the main HTML viewer
+#
+html = Tk::HTML_Widget.new(:padx=>5, :pady=>9,
+ :formcommand=>form_cmd,
+ :imagecommand=>image_cmd,
+ :scriptcommand=>script_cmd,
+ :appletcommand=>applet_cmd,
+ :underlinehyperlinks=>0,
+ :bg=>'white', :tablerelief=>:raised)
+vscr = html.yscrollbar(TkScrollbar.new)
+hscr = html.xscrollbar(TkScrollbar.new)
+
+Tk.grid(html, vscr, :sticky=>:news)
+Tk.grid(hscr, :sticky=>:ew)
+Tk.root.grid_columnconfigure(0, :weight=>1)
+Tk.root.grid_columnconfigure(1, :weight=>0)
+Tk.root.grid_rowconfigure(0, :weight=>1)
+Tk.root.grid_rowconfigure(1, :weight=>0)
+
+#
+# This procedure is called when the user clicks on a hyperlink.
+#
+priv = {}
+last_file = ''
+
+# Read a file
+#
+read_file = proc{|name|
+ begin
+ fp = open(name, 'r')
+ ret = fp.read(File.size(name))
+ rescue
+ ret = nil
+ fp = nil
+ Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'",
+ :type=>:ok)
+ ensure
+ fp.close if fp
+ end
+ ret
+}
+
+# Clear the screen.
+#
+clear_screen = proc{
+ html.clear
+ old_imgs.clear
+ big_imgs.clear
+ hotkey.clear
+ images.each{|k, v| old_imgs[k] = v }
+ images.clear
+}
+
+# Load a file into the HTML widget
+#
+load_file = proc{|name|
+ return unless (doc = read_file.call(name))
+ clear_screen.call
+ last_file = name
+ html.configure(:base=>name)
+ html.parse(doc)
+ old_imgs.clear
+}
+
+href_binding = proc{|x, y|
+ # koba & dg marking text
+ html.selection_clear
+ priv['mark'] = "@#{x},#{y}"
+ lst = html.href(x, y)
+ return if lst.size.zero?
+
+ lnk, target = lst
+
+ if lnk != ""
+ if lnk =~ /^#{last_file}#(.*)$/
+ html.yview($1)
+ else
+ load_file.call(lnk)
+ end
+ end
+}
+html.clipping_window.bind('1', href_binding, '%x %y')
+
+# marking text with the mouse and copying to the clipboard just with tkhtml2.0 working
+html.clipping_window.bind('B1-Motion', proc{|w, x, y|
+ w.selection_set(priv['mark'], "@#{x},#{y}")
+ TkClipboard.clear
+ # avoid tkhtml0.0 errors
+ # anyone can fix this for tkhtml0.0
+ begin
+ TkClipboard.append(TkSelection.get)
+ rescue
+ end
+ }, '%W %x %y')
+
+# This procedure is called when the user selects the File/Open
+# menu option.
+#
+last_dir = Dir.pwd
+sel_load = proc{
+ filetypes = [
+ ['Html Files', ['.html', '.htm']],
+ ['All Files', '*']
+ ]
+
+ f = Tk.getOpenFile(:initialdir=>last_dir, :filetypes=>filetypes)
+ if f != ''
+ load_file.call(f)
+ last_dir = File.dirname(f)
+ end
+}
+
+# Refresh the current file.
+#
+refresh = proc{|*args|
+ load_file.call(last_file)
+}
+
+# This binding changes the cursor when the mouse move over
+# top of a hyperlink.
+#
+Tk::HTML_Widget::ClippingWindow.bind('Motion', proc{|w, x, y|
+ parent = w.winfo_parent
+ url = parent.href(x, y)
+ unless url.empty?
+ parent[:cursor] = 'hand2'
+ else
+ parent[:cursor] = ''
+ end
+ }, '%W %x %y')
+#
+# Setup menu
+#
+menu_spec = [
+ [['File', 0],
+ ['Open', sel_load, 0],
+ ['Refresh', refresh, 0],
+ '---',
+ ['Exit', proc{exit}, 1]],
+
+ [['View', 0],
+ ['Underline Hyperlinks', ul_hyper],
+ ['Show Table Structure', show_tbl],
+ ['Show Images', show_img]]
+]
+
+mbar = Tk.root.add_menubar(menu_spec)
+
+#
+# Setup trace
+#
+ul_hyper.trace('w', proc{
+ html[:underlinehyperlinks] = ul_hyper.value
+ refresh.call
+ })
+
+show_tbl.trace('w', proc{
+ if show_tbl.bool
+ html[:tablerelief] = :flat
+ else
+ html[:tablerelief] = :raised
+ end
+ refresh.call
+ })
+
+show_img.trace('w', refresh)
+
+# If an arguent was specified, read it into the HTML widget.
+#
+Tk.update
+if file && file != ""
+ load_file.call(file)
+end
+
+#####################################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image1 b/ext/tk/sample/tkextlib/tkHTML/page1/image1
new file mode 100644
index 0000000000..31e96b6797
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image1
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image10 b/ext/tk/sample/tkextlib/tkHTML/page1/image10
new file mode 100644
index 0000000000..80a8f81686
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image10
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image11 b/ext/tk/sample/tkextlib/tkHTML/page1/image11
new file mode 100644
index 0000000000..e8cb01d450
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image11
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image12 b/ext/tk/sample/tkextlib/tkHTML/page1/image12
new file mode 100644
index 0000000000..c317bbd5cc
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image12
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image13 b/ext/tk/sample/tkextlib/tkHTML/page1/image13
new file mode 100644
index 0000000000..ac4b3cd594
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image13
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image14 b/ext/tk/sample/tkextlib/tkHTML/page1/image14
new file mode 100644
index 0000000000..c3b02558e3
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image14
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image2 b/ext/tk/sample/tkextlib/tkHTML/page1/image2
new file mode 100644
index 0000000000..da26d7092e
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image2
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image3 b/ext/tk/sample/tkextlib/tkHTML/page1/image3
new file mode 100644
index 0000000000..d91cdfafab
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image3
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image4 b/ext/tk/sample/tkextlib/tkHTML/page1/image4
new file mode 100644
index 0000000000..5fdf70c0e5
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image4
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image5 b/ext/tk/sample/tkextlib/tkHTML/page1/image5
new file mode 100644
index 0000000000..67cd14d78d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image5
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image6 b/ext/tk/sample/tkextlib/tkHTML/page1/image6
new file mode 100644
index 0000000000..9e05aa0f36
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image6
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image7 b/ext/tk/sample/tkextlib/tkHTML/page1/image7
new file mode 100644
index 0000000000..879656d45c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image7
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image8 b/ext/tk/sample/tkextlib/tkHTML/page1/image8
new file mode 100644
index 0000000000..8c647c4f00
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image8
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/image9 b/ext/tk/sample/tkextlib/tkHTML/page1/image9
new file mode 100644
index 0000000000..3a7707589b
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/image9
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page1/index.html b/ext/tk/sample/tkextlib/tkHTML/page1/index.html
new file mode 100644
index 0000000000..9efac7f7af
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page1/index.html
@@ -0,0 +1,115 @@
+<HTML><HEAD><TITLE>Slashdot:News for Nerds. Stuff that Matters.</TITLE> </HEAD>
+<BODY bgcolor="#000000" text="#000000" link="#006666" vlink="#000000">
+<center><a href="http://209.207.224.220/redir.pl?1463" target="_top"><img src="image1" alt="Click Here to enter the Sweepstakes" border="2" width="468" height="60"></a></center> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD WIDTH="1"><SCRIPT LANGUAGE="JAVASCRIPT">
+<!-- now="now" ="" new="new" Date();="Date();" tail="tail" ="" now.getTime();="now.getTime();" document.write("<IMG="document.write("<IMG" SRC="http://209.207.224.245/Slashdot/pc.gif?/slashhead.inc,"+" tail="tail" +="+" "=""" WIDTH="1" HEIGHT="1><BR>");" -->
+</SCRIPT>
+<NOSCRIPT>
+<IMG SRC="image2" WIDTH="1" HEIGHT="1">
+</NOSCRIPT></TD></TR></TABLE><P>
+<TABLE bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" border="0" width="99%" align="center">
+ <TR>
+ <TD valign="top" align="left" valign="top"><A href="http://slashdot.org/"><IMG src="image3" width="275" height="72" border="0" alt="Welcome to Slashdot"></A></TD>
+ <TD><A href="http://slashdot.org/search.pl?topic=linux"><IMG SRC="image4" width="60" height="70" border="0" alt="Linux"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=news"><IMG SRC="image5" width="34" height="44" border="0" alt="News"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=usa"><IMG SRC="image6" width="80" height="61" border="0" alt="United States"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=ed"><IMG SRC="image7" width="87" height="64" border="0" alt="Education"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=space"><IMG SRC="image8" width="73" height="59" border="0" alt="Space"></A></TD>
+
+</TR></TABLE>
+<TABLE width="99%" align="center" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF"><TR>
+<TD valign="top" rowspan="5"><NOBR><FONT size="2"><B>
+&nbsp;<A href="/faq.shtml">faq</A> <BR>
+&nbsp;<A href="/code.shtml">code</A> <BR>
+&nbsp;<A href="/awards.shtml">awards</A> <BR>
+&nbsp;<A href="http://Andover.Net/privacy.html">privacy</A> <BR>
+&nbsp;<A href="http://slashnet.org">slashNET</A> <BR>
+&nbsp;<A href="/search.pl">older stuff</A> <BR>
+&nbsp;<A href="http://cmdrtaco.net">rob's page</A> <BR>
+&nbsp;<A href="/users.pl?op=preferences">preferences</A> <BR>
+&nbsp;<A href="http://Andover.Net">andover.net</A> <BR>
+&nbsp;<A href="/submit.pl">submit story</A> <BR>
+&nbsp;<A href="/advertising.shtml">advertising</A> <BR>
+&nbsp;<A href="/supporters.shtml">supporters</A> <BR>
+&nbsp;<A href="/pollBooth.pl">past polls</A> <BR>
+&nbsp;<A href="/topics.shtml">topics</A> <BR>
+&nbsp;<A href="/about.shtml">about</A> <BR>
+&nbsp;<A href="/jobs.shtml">jobs</A> <BR>
+&nbsp;<A href="/hof.shtml">hof</A>
+
+</B></FONT></NOBR>
+ <P><TABLE border="0" cellpadding="1" cellspacing="0" align="center" bgcolor="#CCCCCC"><TR>
+ <TD><FONT size="2" color="#000000"><B> Sections</B></FONT></TD></TR>
+ <TR><TD><TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF" width="100%"><TR><TD><FONT color="#000000" size="2"><NOBR>
+1/23<BR>
+<B><A href="http://slashdot.org/index.pl?section=apache">apache</A></B><BR>
+1/29 (3)<BR>
+<B><A href="http://slashdot.org/index.pl?section=askslashdot">askslashdot</A></B><BR>
+1/27<BR>
+<B><A href="http://slashdot.org/index.pl?section=awards">awards</A></B><BR>
+1/29 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=books">books</A></B><BR>
+1/27<BR>
+<B><A href="http://slashdot.org/index.pl?section=bsd">bsd</A></B><BR>
+1/28 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=features">features</A></B><BR>
+1/28 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=interviews">interviews</A></B><BR>
+1/19<BR>
+<B><A href="http://slashdot.org/index.pl?section=radio">radio</A></B><BR>
+1/27 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=science">science</A></B><BR>
+1/28 (3)<BR>
+<B><A href="http://slashdot.org/index.pl?section=yro">yro</A></B><BR> </NOBR></FONT></TD></TR></TABLE><TR>
+ <TD><A href="http://andover.net"><FONT size="2" color="#000000"><B>Andover.Net</B></FONT></A></TD></TR>
+ <TR><TD><TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"><TR><TD>
+<FONT color="#000000" size="2"><NOBR><A href="http://www.andovernews.com">AndoverNews</A><BR><A href="http://www.askreggie.com">Ask Reggie</A><BR><A href="http://www.davecentral.com">DaveCentral</A><BR><A href="http://www.freecode.com">FreeCode</A><BR><A href="http://www.mediabuilder.com">MediaBuilder</A><BR> </NOBR></FONT></TD></TR></TABLE></TD></TR></TABLE></P>
+ <P></P>
+</TD><TD valign="top" align="left"><FONT color="#000000"> <TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Who Bought Linux.Net?</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=linux"><IMG src="image4" width="60" height="70" border="0" align="right" hspace="20" vspace="10" alt="Linux"></A> <B>Posted by <A href="http://CmdrTaco.net">CmdrTaco</A> on Saturday January 29, @10:52AM</B><BR> <FONT size="2"><B>from the this-game-again dept.</B></FONT><BR> So Fred VanKampen (who has to hold the record for most money made by reselling two domain names) e-mailed us to say that the Domain Name for 'Linux.Net' has been sold. He won't say to whom, but it supposedly will be announced at LinuxWorld next week. Of course we have no idea what he got for the entry, but the rumors were that he made several million when he sold <A href="http://www.linux.com">Linux.com</A> to <A href="http://www.valinux.com">VA Linux</A>. Hopefully he'll take me for a ride in his yacht. ;) <P><B>( </B><A href="http://slashdot.org/articles/00/01/29/0837235.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/29/0837235&mode=thread&threshold=0">58</A> of <A href="http://slashdot.org/article.pl?sid=00/01/29/0837235&mode=thread&threshold=-1">62</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Book Reviews: E-Mails from (Over?) The Edge</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=news"><IMG src="image5" width="34" height="44" border="0" align="right" hspace="20" vspace="10" alt="News"></A> <B>Posted by <A href="http://hemos.net">Hemos</A> on Saturday January 29, @10:43AM</B><BR> <FONT size="2"><B>from the touching-story dept.</B></FONT><BR> I'd like to thank the author of this book for sending it to me. Nick's written a book that's touching and endearing, and one that's well worth reading for everyone who's ever had social struggles to deal with. As well, his involvement with the fine folks of <a href="http://www.thevenue.org">TheVenue</a>. I'll warn you - it's not a tech text. But it's still worth reading. Click below to read more. <P><B>( </B><A href="http://slashdot.org/books/00/01/24/1146250.shtml"><B>Read More...</B></A> | <A href="http://slashdot.org/article.pl?sid=00/01/24/1146250&mode=nocomment">6197 bytes in body</A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/24/1146250&mode=thread&threshold=0">6</A> of <A href="http://slashdot.org/article.pl?sid=00/01/24/1146250&mode=thread&threshold=-1">22</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Linux Kernel 2.3.41</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=linux"><IMG src="image4" width="60" height="70" border="0" align="right" hspace="20" vspace="10" alt="Linux"></A> <B>Posted by <A href="http://CmdrTaco.net">CmdrTaco</A> on Saturday January 29, @10:21AM</B><BR> <FONT size="2"><B>from the download-compile-reboot-repeat dept.</B></FONT><BR> <A href="mailto:bwhitehead@nospam.acm.org">sdriver</A> writes <I>"For those of us who enjoy *panic*, *oops*, and suddenly seeing their video BIOS... the newest version is out! Be the first on your block to submit a new patch! ;) "</I> If you don't know where to get it, you probably should stick to your warm and cuddly 2.2.x kernel *grin*. Now outta my way, I wanna crash my laptop! <P><B>( </B><A href="http://slashdot.org/articles/00/01/29/0834223.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/29/0834223&mode=thread&threshold=0">52</A> of <A href="http://slashdot.org/article.pl?sid=00/01/29/0834223&mode=thread&threshold=-1">57</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Congress Still Figuring Out E-Mail</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=usa"><IMG src="image6" width="80" height="61" border="0" align="right" hspace="20" vspace="10" alt="United States"></A> <B>Posted by <A href="mailto:roblimo@slashdot.org">Roblimo</A> on Saturday January 29, @07:28AM</B><BR> <FONT size="2"><B>from the voice-of-the-people-can-get-awfully-loud dept.</B></FONT><BR> Jett writes <I>" <A href="http://www.vote.com/">Vote.com</A> has <A href="http://www.vote.com/magazine/editorials/editorial1843752.phtml">an interesting article</A> in their Webmag Fifth Estate about how congressmen have responded to the popularity of e-mail in their daily operations. Quote: 'Of the 440 voting and non-voting House of Representatives members, 22 have no e-mail at all. Even House Speaker Dennis Hastert is wired only halfway -- his office receives e-mail, but does not respond to it. And while all U.S. senators have e-mail, they, like their House counterparts, routinely shun non-constituent mail -- even though they chair committees whose decisions affect the entire country.'"</I> <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/2311232.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/2311232&mode=thread&threshold=0">66</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/2311232&mode=thread&threshold=-1">66</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Ask Slashdot: Sci Fi Literature 101?</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=ed"><IMG src="image7" width="87" height="64" border="0" align="right" hspace="20" vspace="10" alt="Education"></A> <B>Posted by <A href="http://exit118.com/">Cliff</A> on Saturday January 29, @06:56AM</B><BR> <FONT size="2"><B>from the recommendations-wanted dept.</B></FONT><BR> ohlaadee asks: <I>"My niece (she's 13) wants to start reading science fiction. I do too. I gave us both Asimov's </I>_The Foundation_<I>&nbsp; for Christmas. We'll read it together. I suppose we could spend the rest of our lives just reading Asimov, but I'm wondering what books and movies you folks would come up with? What does the /. recommended Science Fiction 101 list include?"</I> <P><B>( </B><A href="http://slashdot.org/askslashdot/00/01/22/1946244.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/22/1946244&mode=thread&threshold=0">345</A> of <A href="http://slashdot.org/article.pl?sid=00/01/22/1946244&mode=thread&threshold=-1">345</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Could Distributed.Net Help the Mars Polar Lander?</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=space"><IMG src="image8" width="73" height="59" border="0" align="right" hspace="20" vspace="10" alt="Space"></A> <B>Posted by <A href="mailto:roblimo@slashdot.org">Roblimo</A> on Saturday January 29, @03:35AM</B><BR> <FONT size="2"><B>from the food-for-thought dept.</B></FONT><BR> Anonymous Coward writes <I>"This official JPL <A href="http://mpfwww.jpl.nasa.gov/msp98/news/mpl000127.html">press release</A> describes the current attempt to listen for faint signals from the Mars Lander. They get three windows a day, and it takes 18 hours to process data because the signal is so weak (if it's really there). Too bad they don't have a deal with <A href="http://www.distributed.net"> distributed.net</A>."</I> Interesting thought. Is anyone at distributed.net or JPL interested in pursuing it? <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/2318246.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/2318246&mode=thread&threshold=0">99</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/2318246&mode=thread&threshold=-1">102</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>iCrave TV Loses Battle against U.S. Broadcasters</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=tv"><IMG src="image10" width="50" height="50" border="0" align="right" hspace="20" vspace="10" alt="Television"></A> <B>Posted by <A href="mailto:roblimo@slashdot.org">Roblimo</A> on Saturday January 29, @12:21AM</B><BR> <FONT size="2"><B>from the shut-down-just-before-the-super-bowl dept.</B></FONT><BR> <A href="mailto:doran@brandx.net">Doran</A> writes <I>"C|Net has <a href="http://news.cnet.com/news/0-1004-200-1535528.html">this story</a> about how the Canadian company <a href="http://www.icravetv.com">iCraveTV.com</a> has lost its latest battle in U.S. courts over whether it can rebroadcast TV signals over the Web. The broadcasters say it's theft, while iCraveTV sez it's just doing what's legal for other cable TV companies in Canada (ie. rebroadcasting TV). Of course, by framing the streaming video iCraveTV is doing more than just rebroadcasting, they're also adding more commercial content, which the broadcasters feel dilutes their TV commercials. "</I> <P><B>( </B><A href="http://slashdot.org/articles/00/01/29/0010203.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/29/0010203&mode=thread&threshold=0">152</A> of <A href="http://slashdot.org/article.pl?sid=00/01/29/0010203&mode=thread&threshold=-1">170</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Win2k Security holes found</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=microsoft"><IMG src="image11" width="75" height="55" border="0" align="right" hspace="20" vspace="10" alt="Microsoft"></A> <B>Posted by <A href="mailto:heunique@slashdot.org">HeUnique</A> on Friday January 28, @04:58PM</B><BR> <FONT size="2"><B>from the and-it's-not-even-out-yet dept.</B></FONT><BR> According to a story posted by <a href="http://www.zdnn.com">ZDNN</a>, <a href="http://www.zdnet.com/zdnn/stories/news/0,4586,2429334,00.html?chkpt=zdnntop">two security holes</a> have been found on Windows 2000, and that's even before the official release of Windows 2000! Administrators who rush to incorporate the patch from MS beware - according to one of the talkback posts on ZDNN, the patch creates a new problem with Windows 2000 news server service. <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/1653228.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/1653228&mode=thread&threshold=0">510</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/1653228&mode=thread&threshold=-1">534</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Encryption Debate at Mitnick Trial</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=encryption"><IMG src="image12" width="80" height="70" border="0" align="right" hspace="20" vspace="10" alt="Encryption"></A> <B>Posted by <A href="http://hemos.net">Hemos</A> on Friday January 28, @03:33PM</B><BR> <FONT size="2"><B>from the gimmie-the-data dept.</B></FONT><BR> A number of people have written about <A HREF="http://nytimes.com/library/tech/00/01/cyber/cyberlaw/28law.html">the latest twist</a> in the Mitnick case. Kevin wants to get his data back, but the government is refusing to do so until he gives them the key. Apparently, the government is unable to crack the encryption that he's got on it - you'd think after having the data for five years, they'd be able to brute-force the darn thing. It's a NYT article - free login required. <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/1320253.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/1320253&mode=thread&threshold=0">504</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/1320253&mode=thread&threshold=-1">521</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Forum: Future Ports of Games to Linux</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=games"><IMG src="image13" width="80" height="56" border="0" align="right" hspace="20" vspace="10" alt="Games"></A> <B>Posted by <A href="http://CmdrTaco.net">CmdrTaco</A> on Friday January 28, @02:26PM</B><BR> <FONT size="2"><B>from the it's-been-awhile dept.</B></FONT><BR> It's been a long time since I posted an open forum like this, but I'm curious what people think on this one. What games do you most want to see ported to Linux in the next few months? Of course, for me personally it's StarCraft and Diablo 2, but I'm curious what games have come out or are due soon that people would most like to see a port of (and note that WINE doesn't count. ;) <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/1257211.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/1257211&mode=thread&threshold=0">648</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/1257211&mode=thread&threshold=-1">652</A> </B>comments <B>)</B> <P></TD><TD width="210" align="center" valign="top"><TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="/index.pl?section=features"><FONT COLOR="#FFFFFF">Features</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><A href="/vote.pl">Voting has begun</A> for the $100k <A href="/index.pl?section=awards">Slashdot Beanie Awards</A>. Talk amongst yourselves and choose who deserves the cash. <P>The latest installment of <A href="http://www.thesync.com/geeks">Geeks in Space</A> is up at <A href="http://www.thesync.com">The Sync</A>. Listen to CmdrTaco, Hemos, and Nate talk about the latest events to happen - or not happen in the computer world. <P>Perhaps you are seeking Jon Katz's series of articles related to recent events in Colorado. These articles include <A href="/article.pl?sid=99/04/25/1438249">Voices from the Hellmouth</A>, <A href="/article.pl?sid=99/04/27/0310247">More Stories from the Hellmouth</A> or <A href="/article.pl?sid=99/04/29/0124247">The Price of Being Different</A>, <P>For something different, try reading a little essay <A href="/article.pl?sid=99/03/31/0137221">Thoughts from the Furnace</A> about the internet, and flame. <p> And for a bit of an amusing take on the Open Source world, check out <a href="/article.pl?sid=99/08/24/1327256&mode=thread">Open Source as an Ant Farm</a> <P><B>Update: 01/03 03:10</B> by <B><A href="http://cowboyneal.org">CowboyNeal</a></B>: <P align="right"><B><A href="/features/">Past Features</A></B> <!-- end="end" features="features" block="block" --></FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="http://slashdot.org/index.pl?section=askslashdot"><FONT COLOR="#FFFFFF">Ask Slashdot</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1946244">Sci Fi Literature 101?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/192226">Linux and Satellite Internet Services</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1843258">Open Defensive Patents?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1825252">Technologies That Shaped the Last Century?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1958212">Disk Repair Tools for Linux?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1955215">Why Can't the Command-Line be More Standardized?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1928235">Packet Radio Networking with PalmOS?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1817211">Cheap Rackmount Enclosures/Systems?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1950249">Open Source Software and Tax Breaks?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1917207">Building an Upgradable Dual Processor System</A> <P> if you have a question for Ask Slashdot, send it to <A href="mailto:askslashdot@slashdot.org">askslashdot@slashdot.org</A></FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="/users.pl"><FONT COLOR="#FFFFFF">Slashdot Login</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><FORM action="/users.pl" METHOD="POST"> <B>Nickname:</B><BR> <INPUT type="text" name="unickname" size="20" value=""><BR> <B>Password:</B><BR> <INPUT type="hidden" name="returnto" value="index.pl"> <INPUT type="password" name="upasswd" size="20"><BR> <INPUT type="submit" name="op" value="userlogin"> </FORM> Don't have an account yet? <A href="/users.pl">Go Create One</A>. A user account will allow you to customize all these <A href="/cheesyportal.shtml">nutty little boxes</A>, tailor the stories you see, as well as remember your comment viewing preferences.</FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Slashdot Poll</B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><FORM action="http://slashdot.org/pollBooth.pl"> <INPUT type="hidden" name="qid" value="techadvance"> <B>The Tech Advance I Most Want Is:</B><BR><INPUT type="radio" name="aid" value="1">Nanotechnology<BR><INPUT type="radio" name="aid" value="2">Cold Fusion<BR><INPUT type="radio" name="aid" value="3">Powerful Fuel Cells<BR><INPUT type="radio" name="aid" value="4">Hard Wiring my Body<BR><INPUT type="radio" name="aid" value="5">Universal Strong Crypto<BR><INPUT type="radio" name="aid" value="6">Interstellar Travel<BR><INPUT type="radio" name="aid" value="7">Cybernetic Body Armor<BR><INPUT type="radio" name="aid" value="8">ColecoVision<BR><INPUT type="submit" value="Vote"> [ <A href="http://slashdot.org/pollBooth.pl?qid=techadvance&aid=-1"><B>Results</B></A> | <A href="http://slashdot.org/pollBooth.pl?"><B>Polls</B></A> ] <BR>Comments:<B>656</B> | Votes:<B>29121</B></FORM> </FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Older Stuff</B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><P><B><A href="http://slashdot.org/index.pl?section=&issue=730512&mode=thread"><FONT size="4">Friday</FONT></A> January 28</B> <LI><A href="http://slashdot.org/articles/00/01/28/1110258.shtml">Abstract Programming and GPL Enforcement</A> (235) <LI><A href="http://slashdot.org/interviews/00/01/28/1225206.shtml">Interview: FreeDOS Leader Jim Hall Answers</A> (86) <LI><A href="http://slashdot.org/articles/00/01/28/116240.shtml">Open Source's Achilles Heel</A> (466) <LI><A href="http://slashdot.org/features/00/01/26/1915230.shtml">The Virtue of Communal Instincts</A> (237) <LI><A href="http://slashdot.org/articles/00/01/28/0723223.shtml">Gartner Group Debunking Open Source Myths</A> (165) <LI><A href="http://slashdot.org/yro/00/01/28/0917229.shtml">DoubleClick Taken to Court</A> (310) <LI><A href="http://slashdot.org/articles/00/01/28/0718209.shtml">Updated Slash & Server 51</A> (81) <LI><A href="http://slashdot.org/articles/00/01/28/089230.shtml">XMMS 1.0.0 Released</A> (128) <LI><A href="http://slashdot.org/askslashdot/00/01/22/192226.shtml">Linux and Satellite Internet Services</A> (138) <LI><A href="http://slashdot.org/articles/00/01/27/1811221.shtml">UN Wants to Combat Online Racism</A> (531) <P><B><A href="http://slashdot.org/index.pl?section=&issue=730511&mode=thread"><FONT size="4">Thursday</FONT></A> January 27</B> <LI><A href="http://slashdot.org/yro/00/01/27/2330205.shtml">Crackdowns, Fools and the MPAA</A> (351) <LI><A href="http://slashdot.org/articles/00/01/27/0832215.shtml">Heroes of Might and Magic III Demo Released</A> (157) <LI><A href="http://slashdot.org/science/00/01/27/1345241.shtml">Sandia Labs Venture Into Nanotechnology</A> (117) <LI><A href="http://slashdot.org/articles/00/01/27/0931237.shtml">CA Announces Program Ports to Linux</A> (195) <LI><A href="http://slashdot.org/interviews/00/01/27/1118251.shtml">Interview: Larry Augustin Finally Answers</A> (210) <LI><A href="http://slashdot.org/awards/00/01/27/0855252.shtml">Final Call for Voting in Slashdot's Beanie Awards</A> (178) <LI><A href="http://slashdot.org/features/00/01/26/197211.shtml">Transmeta Code Morphing != Just In Time</A> (449) <LI><A href="http://slashdot.org/books/00/01/24/1150256.shtml">Intrusion Detection</A> (65) <LI><A href="http://slashdot.org/science/00/01/27/0824239.shtml">Using Enzymes to Help Fight CO2 Build-Up</A> (165) <LI><A href="http://slashdot.org/articles/00/01/27/0712217.shtml">Jon Johansen on ABC World News Tonight</A> (415) <P align="right"><BR><A href="http://slashdot.org/search.pl?section=&min=30"><B>Older Articles</B></A><BR><A href="http://slashdot.org/index.pl?section=&mode=thread&issue=730512"><B>Yesterday's Edition</B></A> </FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="/index.pl?section=books"><FONT COLOR="#FFFFFF">Book Reviews</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><p>Jon Katz, Resident Gasbag, has a new, very appropriate book coming out soon, <a href="http://www.thinkgeek.com">Geeks</a>. Preorder now and receive the book early. <p>For probably the best fiction read around, check out Neal Stephenson's <cite><a href="/article.pl?sid=99/06/23/139229&mode=thread">Cryptonomicon</a></cite>, an engaging read about WWII, cryptography and buried treasure. And data vaults. <p>If you've been doing a lot of work in Perl, you've probably figured out you really need <cite><a href="/article.pl?sid=99/05/10/2238254&mode=thread">Perl in a Nutshell</a></cite> or <cite><a href="/article.pl?sid=99/01/29/1035246&mode=thread">The Perl Cookbook</a></cite>. If you're still learning, grab <cite><a href="/books/older/980526096229.shtml">Programming Perl</a></cite>. <p>And if you want to learn more about how to become a better coder, grab <cite><a href="/article.pl?sid=99/06/28/1417229&mode=thread">The Unified Software Development Process</a></cite> or <cite><a href="/article.pl?sid=99/04/08/1512209&mode=thread">The Practice of Programming</cite></a> Additionally, check out <cite><a href="http://slashdot.org/article.pl?sid=99/09/16/1333202&mode=thread">Refactoring: Improving the Design of Existing Code</a></cite> . <p>Developing a large application? Grab Eric Greenberg's excellent <cite><a href="/article.pl?sid=99/07/13/1943258&mode=thread">Network Application Frameworks</cite></a>. <P>Visit <A href="/index.pl?section=books">Our Book Reviews Section</A> for more. <br> <B>Update: 11/12 05:19</B> by <B><A href="mailto:hemos@slashdot.org">H</A></B>:</FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Quick Links</B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><B>Cool Sites:</B> <LI><A href="http://www.linux.com">Linux.com</A> (What <B>is</B> Linux?) <LI><A href="http://everything.blockstackers.com">Everything</A> (Blow your Mind) <LI><A href="http://www.geekculture.com/geekycomics/Aftery2k/aftery2kmain.html">After Y2k</A> (<I>This</I> is Post-Apocalyptic?) <LI><A href="http://www.userfriendly.org">User Friendly</A> (Laugh) <LI><A href="http://themes.org">Themes.org</A> (Make X Perty) <P><B>Support Slashdot:</B> <LI><A href="http://www.thinkgeek.com">ThinkGeek</A> (Clothe Yourself in Slashdot) <LI><A href="http://cdnow.com/from=sr-302791">CDnow</A> (Support <A href="http://www.cdnow.com/gift/malda@slashdot.org">Rob's Who Habit</A>) <LI><A href="http://adfu.slashdot.org">Slashdot Advertiser Index</A></FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="http://freshmeat.net"><FONT COLOR="#FFFFFF">Freshmeat</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><P><FONT size="4" color="#006666"><B>January</B></FONT><BR> <LI><A href="http://freshmeat.net/news/2000/01/29/949208399.html">We should get this out of the door now</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949159642.html">Is Linux for Crazies?</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949156343.html">SQN Linux 1.6</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949156277.html">Limo 0.3.2</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949156237.html">Fusion GS 1.3</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949145887.html">MMR 1.5.4</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949142835.html">KUPS 0.3.4</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949142815.html">3DSE patch for XMMS 4</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949139763.html">Linux 2.3.41</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949139751.html">Free Code for Linux S/390</A> <FORM METHOD="post" ACTION="http://core.freshmeat.net/search.php3"> <FONT size="3" color="#006666"><B>Search Freshmeat:</B></FONT><BR> <INPUT TYPE="hidden" NAME="link" VALUE="freshmeat.net"> <INPUT TYPE="text" NAME="query"> </FORM> <P align="right"><A href="http://freshmeat.net"><B>More Meat...</B></A></FONT></TD> </TR> </TABLE><P> </FONT></TD>
+ </TR>
+ </TABLE><TABLE cellpadding="0" cellspacing="0" border="0" width="99%" align="center" bgcolor="ffffff">
+ <TR>
+ <TD colspan="4" align="center"><IMG src="image14" alt="" width="80%" height="1" hspace="10" vspace="30"></TD>
+ </TR><TR>
+ <TD align="center"><FONT size="2" face="arial,helvetica">
+ <FORM method="GET" action="http://slashdot.org/search.pl">
+ <INPUT type="name" name="query" value="" width="20" size="20" length="20">
+ <INPUT type="submit" value="Search">
+ </FORM>
+ </FONT>
+ </TD>
+ <TD bgcolor="#ffffff" width="25"> &nbsp; </TD>
+ <TD align="center">
+ <FONT size="2" face="arial,helvetica"><I>Wasn't there something about a PASCAL programmer knowing the value of
+everything and the Wirth of nothing?
+<TD>&nbsp;</TD></I></FONT>
+ </FONT>
+ </TD></TR>
+ <TR><TD colspan="4" align="center">
+ <FONT size="1" color="#006666" face="arial,helvetica">
+
+ All trademarks and copyrights on this
+ page are owned by their respective owners. Comments
+ are owned by the Poster.
+ The Rest © 1997-2000 <A href="http://Andover.Net">Andover.Net</A>.
+</FONT></CENTER>
+ </TD>
+ </TR>
+ </TABLE>
+ <CENTER>
+ <FONT size="2" color="#006666">
+
+ [ <A href="http://slashdot.org/"><Font color="#ffffff">home</FONT></A> |
+ <A href="http://slashdot.org/awards.shtml"><Font color="#ffffff">awards</FONT></A> |
+ <A href="http://slashdot.org/supporters.shtml"><FONT color="#ffffff">supporters</FONT></A> |
+ <A href="http://CmdrTaco.net"><FONT color="#ffffff">rob's homepage</FONT></A> |
+ <A href="http://slashdot.org/submit.pl"><FONT color="#ffffff">contribute story</FONT></A> |
+ <A href="http://slashdot.org/search.pl"><FONT color="#ffffff">older articles</FONT></A> |
+ <A href="http://Andover.Net"><FONT color="#ffffff">Andover.Net</FONT></A> |
+ <A href="http://slashdot.org/advertising.shtml"><FONT color="#ffffff">advertising</FONT></A> |
+ <A href="http://slashdot.org/pollBooth.pl"><FONT color="#ffffff">past polls</FONT></A> |
+ <A href="http://slashdot.org/about.shtml"><FONT color="#ffffff">about</FONT></A> |
+ <A href="http://slashdot.org/faq.shtml"><FONT color="#ffffff">faq</FONT></A> ]
+ </FONT>
+ </CENTER>
+</BODY>
+</HTML>
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image1 b/ext/tk/sample/tkextlib/tkHTML/page2/image1
new file mode 100644
index 0000000000..2ed6ddcfe1
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image1
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image10 b/ext/tk/sample/tkextlib/tkHTML/page2/image10
new file mode 100644
index 0000000000..3021b68990
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image10
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image11 b/ext/tk/sample/tkextlib/tkHTML/page2/image11
new file mode 100644
index 0000000000..41d1fe3666
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image11
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image12 b/ext/tk/sample/tkextlib/tkHTML/page2/image12
new file mode 100644
index 0000000000..655a686541
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image12
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image13 b/ext/tk/sample/tkextlib/tkHTML/page2/image13
new file mode 100644
index 0000000000..97d5950e8c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image13
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image14 b/ext/tk/sample/tkextlib/tkHTML/page2/image14
new file mode 100644
index 0000000000..6d73ad833c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image14
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image15 b/ext/tk/sample/tkextlib/tkHTML/page2/image15
new file mode 100644
index 0000000000..90cc3b2b16
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image15
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image16 b/ext/tk/sample/tkextlib/tkHTML/page2/image16
new file mode 100644
index 0000000000..93aa853cf1
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image16
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image17 b/ext/tk/sample/tkextlib/tkHTML/page2/image17
new file mode 100644
index 0000000000..f46f0308cd
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image17
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image18 b/ext/tk/sample/tkextlib/tkHTML/page2/image18
new file mode 100644
index 0000000000..3badd5e909
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image18
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image19 b/ext/tk/sample/tkextlib/tkHTML/page2/image19
new file mode 100644
index 0000000000..bd4f6d9677
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image19
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image2 b/ext/tk/sample/tkextlib/tkHTML/page2/image2
new file mode 100644
index 0000000000..7566dda25d
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image2
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image20 b/ext/tk/sample/tkextlib/tkHTML/page2/image20
new file mode 100644
index 0000000000..358fa95f63
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image20
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image21 b/ext/tk/sample/tkextlib/tkHTML/page2/image21
new file mode 100644
index 0000000000..c81aa52588
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image21
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image22 b/ext/tk/sample/tkextlib/tkHTML/page2/image22
new file mode 100644
index 0000000000..6cbd63022a
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image22
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image23 b/ext/tk/sample/tkextlib/tkHTML/page2/image23
new file mode 100644
index 0000000000..e8173a7456
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image23
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image24 b/ext/tk/sample/tkextlib/tkHTML/page2/image24
new file mode 100644
index 0000000000..bffd4b4956
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image24
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image25 b/ext/tk/sample/tkextlib/tkHTML/page2/image25
new file mode 100644
index 0000000000..c656fa4f30
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image25
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image26 b/ext/tk/sample/tkextlib/tkHTML/page2/image26
new file mode 100644
index 0000000000..bc93fdb259
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image26
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image27 b/ext/tk/sample/tkextlib/tkHTML/page2/image27
new file mode 100644
index 0000000000..6ad0eff1e7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image27
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image28 b/ext/tk/sample/tkextlib/tkHTML/page2/image28
new file mode 100644
index 0000000000..88f0d7cea6
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image28
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image29 b/ext/tk/sample/tkextlib/tkHTML/page2/image29
new file mode 100644
index 0000000000..e0704183b3
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image29
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image3 b/ext/tk/sample/tkextlib/tkHTML/page2/image3
new file mode 100644
index 0000000000..ac3fa33e6f
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image3
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image30 b/ext/tk/sample/tkextlib/tkHTML/page2/image30
new file mode 100644
index 0000000000..4a41950434
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image30
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image31 b/ext/tk/sample/tkextlib/tkHTML/page2/image31
new file mode 100644
index 0000000000..60f13ed564
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image31
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image32 b/ext/tk/sample/tkextlib/tkHTML/page2/image32
new file mode 100644
index 0000000000..04ddc4e8d7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image32
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image33 b/ext/tk/sample/tkextlib/tkHTML/page2/image33
new file mode 100644
index 0000000000..c1ecfff6c4
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image33
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image34 b/ext/tk/sample/tkextlib/tkHTML/page2/image34
new file mode 100644
index 0000000000..3dfd5d76e2
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image34
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image35 b/ext/tk/sample/tkextlib/tkHTML/page2/image35
new file mode 100644
index 0000000000..aea44f3017
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image35
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image36 b/ext/tk/sample/tkextlib/tkHTML/page2/image36
new file mode 100644
index 0000000000..baef0e0380
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image36
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image37 b/ext/tk/sample/tkextlib/tkHTML/page2/image37
new file mode 100644
index 0000000000..6c6ba52b45
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image37
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image38 b/ext/tk/sample/tkextlib/tkHTML/page2/image38
new file mode 100644
index 0000000000..e298e04b29
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image38
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image39 b/ext/tk/sample/tkextlib/tkHTML/page2/image39
new file mode 100644
index 0000000000..e16e2f10d5
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image39
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image4 b/ext/tk/sample/tkextlib/tkHTML/page2/image4
new file mode 100644
index 0000000000..9e5e46b7e5
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image4
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image5 b/ext/tk/sample/tkextlib/tkHTML/page2/image5
new file mode 100644
index 0000000000..646a6d9a51
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image5
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image6 b/ext/tk/sample/tkextlib/tkHTML/page2/image6
new file mode 100644
index 0000000000..7df417c710
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image6
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image7 b/ext/tk/sample/tkextlib/tkHTML/page2/image7
new file mode 100644
index 0000000000..0e6ac10aff
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image7
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image8 b/ext/tk/sample/tkextlib/tkHTML/page2/image8
new file mode 100644
index 0000000000..ba7fb476b9
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image8
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/image9 b/ext/tk/sample/tkextlib/tkHTML/page2/image9
new file mode 100644
index 0000000000..b1cad73ae9
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/image9
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page2/index.html b/ext/tk/sample/tkextlib/tkHTML/page2/index.html
new file mode 100644
index 0000000000..7eaf2d2cc9
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page2/index.html
@@ -0,0 +1,433 @@
+<html>
+<head>
+ <title>Tcl Resource Center</title>
+</head>
+
+<body bgcolor="white" text="black">
+
+ <!-- MenuTopLevel Resource Software Extensions -->
+ <table border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="120" valign="TOP"><a href="/"><img src="image1" width="120" height="79" alt="Scriptics" border="0"></a></td>
+ <td valign="top" width="548">
+
+ <!-- Table to hold tabs -->
+ <table cellpadding="0" cellspacing="0" border="0" width="548">
+ <tr>
+ <td valign="top" align="right" colspan="15" width="548"><a name="TOP"><img src="image2" width="548" height="9" alt="Tcl/Tk" border="0"></a></td>
+ </tr>
+ <tr>
+ <td valign="top" align="right" colspan="15" width="548"><img src="image3" width="482" height="34" alt="Scripting Solutions for eBusiness Integration" border="0"></td>
+ </tr>
+ <tr>
+ <td width="18" valign="TOP"><img src="image4" width="18" height="36" alt="" border="0"></td>
+ <td width="58"><a href="/products/" onMouseOver="msover(4, 'http://images.scriptics.com/images/ProductsMouseOff.gif') ; return true ;" onMouseOut="msover(4, 'http://images.scriptics.com/images/ProductsOff.gif') ; return true ;"><img src="image5" width="58" height="36" alt="Products" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image6" width="14" height="36" alt="" border="0"></td>
+ <td width="69"><a href="/customers/" onMouseOver="msover(6, 'http://images.scriptics.com/images/CustomersMouseOff.gif') ; return true ;" onMouseOut="msover(6, 'http://images.scriptics.com/images/CustomersOff.gif') ; return true ;"><img src="image7" width="69" height="36" alt="Customers" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image6" width="14" height="36" alt="" border="0"></td>
+ <td width="60"><a href="/partners/" onMouseOver="msover(8, 'http://images.scriptics.com/images/PartnersMouseOff.gif') ; return true ;" onMouseOut="msover(8, 'http://images.scriptics.com/images/PartnersOff.gif') ; return true ;"><img src="image8" width="60" height="36" alt="Partners" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image6" width="14" height="36" alt="" border="0"></td>
+ <td width="56"><a href="/services/" onMouseOver="msover(10, 'http://images.scriptics.com/images/ServicesMouseOff.gif') ; return true ;" onMouseOut="msover(10, 'http://images.scriptics.com/images/ServicesOff.gif') ; return true ;"><img src="image9" width="56" height="36" alt="Services" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image10" width="14" height="36" alt="" border="0"></td>
+ <td width="88"><a href="/resource/" onMouseOver="msover(12, 'http://images.scriptics.com/images/ResourceMouseOn.gif') ; return true ;" onMouseOut="msover(12, 'http://images.scriptics.com/images/ResourceOn.gif') ; return true ;"><img src="image11" width="88" height="36" alt="Tcl Resources" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image12" width="14" height="36" alt="" border="0"></td>
+ <td width="57"><a href="/company/" onMouseOver="msover(14, 'http://images.scriptics.com/images/CompanyMouseOff.gif') ; return true ;" onMouseOut="msover(14, 'http://images.scriptics.com/images/CompanyOff.gif') ; return true ;"><img src="image13" width="57" height="36" alt="Company" border="0"></a></td>
+ <td width="8" valign="TOP"><img src="image14" width="8" height="36" alt="" border="0"></td>
+ <td width="50" valign="TOP"><img src="image15" width="50" height="36" alt="" border="0"></td>
+ <td width="14" valign="TOP"><img src="image16" width="14" height="36" alt="" border="0"></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table> <script language="Javascript">
+ <!--
+ function msover(num, file )
+ {
+ old = (((navigator.appName=='Netscape') &&
+ (parseInt(navigator.appVersion)<=3.0 )))
+ if ( !old ) {
+ document.images[num].src=file
+ }
+ }
+ //-->
+ </SCRIPT>
+
+<!-- MenuSubLevel Resource Software Extensions Tk -->
+
+<table cellpadding="0" cellspacing="0" border="0">
+
+<!-- Left Hand Column-->
+
+<tr><td valign="top" width="120"><table cellpadding="0" cellspacing="0" border="0" width="120">
+ <tr>
+ <td width="120" valign="TOP"><img src="image17" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/"><img src="image18" width="120" height="11" alt="Software" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/tcltk/"><img src="image20" width="120" height="11" alt="Tcl/Tk Core" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/applications/"><img src="image21" width="120" height="11" alt="Applications" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image22" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/extensions/"><img src="image23" width="120" height="11" alt="Extensions" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image24" width="120" height="6" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/patches/"><img src="image25" width="120" height="11" alt="Patches" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/java/"><img src="image26" width="120" height="11" alt="Tcl &amp; Java" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/ports/"><img src="image27" width="120" height="11" alt="Tcl/Tk Ports" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/tools/"><img src="image28" width="120" height="11" alt="Tools" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image29" width="120" height="6" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/doc/"><img src="image30" width="120" height="11" alt="Documentation" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/community/"><img src="image32" width="120" height="11" alt="Community" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/live/bydate"><img src="image33" width="120" height="11" alt="What's New" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/forms/urlnote.html"><img src="image34" width="120" height="11" alt="Add URL" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/live/keyword"><img src="image35" width="120" height="11" alt="Keyword Search" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/live/sitemap"><img src="image36" width="120" height="11" alt="Index" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image37" width="120" height="6" alt="" border="0"></td>
+ </tr>
+</table><!-- End Left Column --></td><!-- Right Hand Column --><td valign="top" width="548" align="left"><table cellpadding="0" cellspacing="0" border="0" width="548">
+ <tr>
+ <td width="295" valign="TOP"><img src="image38" width="295" height="42" alt="Resource" border="0"></td>
+ <td width="187" valign="bottom" align="right"><FORM action="/live/keyword"><img src="image39" width="46" height="24" alt="" border="0"><INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="35" NAME="keywords"><INPUT type="IMAGE" border="0" img="img" src="http://images.scriptics.com/images/Go.gif" value="submit" width="33" height="24"></FORM>
+ </tr>
+ </table>
+ <!-- 2 Columns for spacer -->
+ <table cellpadding="0" cellspacing="0" border="0" width="548">
+ <tr>
+ <!-- Spacer Column -->
+ <td valign="top" width="10">
+ &nbsp;
+ </td>
+
+
+ <td valign="top" width="548"><font face="Geneva, Helvetica, Arial" size="2"><h1>Tcl Resource Center</h1>
+<font size="+1"><a href="/resource/">Top</a>&gt;<a href="/resource/software/" ="">Software Central</a>&gt;<a href="/resource/software/extensions/" ="">Extensions</a>&gt;Tk Widgets</font><font size="-1"><br>Viewed by name (<a href="/resource/software/extensions/tk/?sortby=date">By date</a>)</font><br>
+<p>Tk is a toolkit for building graphical user interfaces with Tcl.
+ Your Tcl/Tk scripts run on UNIX, Windows, and Macintosh.<p>
+<font face="Geneva, Helvetica, Arial"><ul></ul></font><dl>
+<dt><b><a href="http://marge.phys.washington.edu/%7Ezager/blt80-unoff-exe.zip" ="">BLT 8.0 Unofficial zip and DLL</a></b>
+<dd>This is a compiled version of BLT 8.0 "unofficial" for
+the Windows platform. <a href="/live/annotate?url=http%3a%2f%2fmarge%2ephys%2ewashington%2eedu%2f%257Ezager%2fblt80%2dunoff%2dexe%2ezip">Edit</a>
+ <i><font size="-1">(September 24, 1999 06:31)</font></i><dt><b><a href="ftp://ftp.neosoft.com/languages/tcl/sorted/unknown/blt8.0p2-unoff.tgz" ="">BLT 8.0p2 Unofficial tar file</a><a name="bltunoff"></a></b>
+<dd>This is a contributed patch to make BLT compatible with Tcl/Tk 8.0p2. While still "unofficial", it is widely used.
+ Make sure you get the 8.0p2 version because the 8.0 version does
+ not compile under windows.
+ There is also a <a href="ftp://ftp.neosoft.com/languages/sorted/devel/blt2.3-8.1.tar.gz">2.3-8.1 version</a> that has been patched to work with 8.1.
+ <a href="ftp://ftp.neosoft.com/languages/tcl/sorted/unknown/blt8.0p2-unoff.README">README file</a>. <a href="/live/annotate?url=ftp%3a%2f%2fftp%2eneosoft%2ecom%2flanguages%2ftcl%2fsorted%2funknown%2fblt8%2e0p2%2dunoff%2etgz">Edit</a>
+ <i><font size="-1">(August 30, 1999 06:38)</font></i><dt><b><a href="http://www.tcltk.com/blt/" ="">BLT Home Page</a></b>
+<dd>
+ Author <b>George Howlett</b>, Version <b>2.3</b>,
+ Works with <b>Tk 4.1 through Tk 8.1</b>
+<br><a href="ftp://ftp.tcltk.com/pub/blt/">Download</a>, <a href="ftp://ftp.tcltk.com/pub/blt/BLT2.3.tar.gz">BLT2.3.tar.gz</a>, <a href="ftp://ftp.tcltk.com/pub/blt/BLT2.4h.tar.gz">BLT2.4h.tar.gz</a>, <a href="ftp://ftp.tcltk.com/pub/blt/BLT2.4i.tar.gz">BLT2.4i.tar.gz</a>, <a href="ftp://ftp.tcltk.com/pub/blt/blt2.4i-for-8.0.exe">blt2.4i-for-8.0.exe</a>, <a href="ftp://ftp.tcltk.com/pub/blt/blt2.4i-for-8.1.exe">blt2.4i-for-8.1.exe</a><br>BLT is a set of widgets for Tk, including a graph widget,
+bar chart, drag&drop, a simple command tracer, and much more.
+The 2.4 release, which is still under development, works with 8.0
+or higher.
+There are also an "<a href="#bltunoff">unofficial</a>" release for 8.0p2
+and 8.1a2 that were not done by the author. <a href="/live/annotate?url=http%3a%2f%2fwww%2etcltk%2ecom%2fblt%2f">Edit</a>
+ <i><font size="-1">(October 26, 1999 09:43)</font></i><dt><b><a href="http://www.unifix-online.com/BWidget/index.html" ="">BWidget</a></b>
+<dd>A set of native Tk 8.x Widgets using Tcl8.x namespaces.
+The ToolKit is available under Unix/X11 and Windows.
+The BWidget(s) have a professional look&feel as in other
+well known Toolkits (Tix or Incr Widget) but the concept is
+radically different because everything is native
+so no platform compilation, no compiled extension
+library are needed. The code is 100 Pure Tcl/Tk.
+More 30 components : Notebook, PageManager, Tree, PanedWindow, ButtonBox,
+ScrollView, ComboBox, SpinBox, ListBox, SelectFont, SelectColor,
+ProgressBare ... <a href="/live/annotate?url=http%3a%2f%2fwww%2eunifix%2donline%2ecom%2fBWidget%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(September 06, 1999 09:58)</font></i><dt><b><a href="http://purl.oclc.org/net/nijtmans/dash.html" ="">Dash Patch for Tk</a></b>
+<dd>This patch has many enhancements to the Tk and its canvas
+widget, including dashed lines, smoothed polygons,
+and performance enhancements. <a href="/live/annotate?url=http%3a%2f%2fpurl%2eoclc%2eorg%2fnet%2fnijtmans%2fdash%2ehtml">Edit</a>
+ <i><font size="-1">(November 21, 1999 06:33)</font></i><dt><b><a href="http://www.hwaci.com/sw/et" ="">Embedded Tk (et)</a></b>
+<dd>
+ Author <b><a href="mailto:drh@acm.org" ="">Richard Hipp</a></b>, Version <b>8.0b5</b>,
+ Works with <b>Tk 4.0, 4.1, 4.2, 8.0</b>
+<br>Download: <a href="http://www.hwaci.com/sw/et/et80b5.tar.gz">et80b5.tar.gz</a><br>Embedded Tk or ``ET'' is tool for making stand-alone executables out of a mixture of C or C++ and Tcl/Tk.
+Using ET you can invoke a short Tcl/Tk script in the middle of a C routine, or you can invoke a C routine in the
+middle of a Tcl/Tk script. ET also bundles external Tcl/Tk scripts (including the standard Tcl/Tk startup scripts)
+into the executable so that the executable can be run on another binary-compatible computer that doesn't have
+Tcl/Tk installed. <a href="/live/annotate?url=http%3a%2f%2fwww%2ehwaci%2ecom%2fsw%2fet">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:35)</font></i><dt><b><a href="http://www.purl.org/net/hobbs/tcl/script/tkcon/" ="">Enhanced Tk Console (TkCon)</a></b>
+<dd>
+ Author <b><a href="mailto:jeffrey.hobbs@oen.siemens.de" ="">Jeff Hobbs</a></b>, Version <b>1.3</b>,
+ Works with <b>Tk 4.1 through Tk 8.1</b>
+<br>Download: <a href="http://www.purl.org/net/hobbs/tcl/script/tkcon/tkcon.tar.gz">tkcon.tar.gz</a><br>TkCon is a replacement for the standard console that comes with Tk (on Windows/Mac, but also works on
+
+Unix). The console itself provides many more features than the standard console. <a href="/live/annotate?url=http%3a%2f%2fwww%2epurl%2eorg%2fnet%2fhobbs%2ftcl%2fscript%2ftkcon%2f">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:06)</font></i><dt><b><a href="http://www.scriptmeridian.org/projects/tk/" ="">Frontier-Tk ScriptMeridian project</a></b>
+<dd>This project seeks to integrate the Tk toolkit
+with the Frontier scripting language. <a href="/live/annotate?url=http%3a%2f%2fwww%2escriptmeridian%2eorg%2fprojects%2ftk%2f">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:36)</font></i><dt><b><a href="http://purl.oclc.org/net/nijtmans/img.html" ="">Img image format extension</a></b>
+<dd>This package enhances Tk, adding support for many other Image formats:
+BMP, XBM, XPM, GIF (with transparency), PNG,
+JPEG, TIFF and postscript.
+This is implemented as a shared library that can be dynamically loaded into
+Tcl/Tk.
+ <a href="/live/annotate?url=http%3a%2f%2fpurl%2eoclc%2eorg%2fnet%2fnijtmans%2fimg%2ehtml">Edit</a>
+ <i><font size="-1">(November 21, 1999 06:35)</font></i><dt><b><a href="http://purl.oclc.org/net/oakley/tcl/mclistbox/index.html" ="">mclistbox - a multi-column listbox widget</a></b>
+<dd>mclistbox is a multi-column listbox that is
+written in pure tcl and runs on all platforms
+that support tcl/tk 8.0 or higher. This widget
+requires no other extensions; it is completely
+standalone. <a href="/live/annotate?url=http%3a%2f%2fpurl%2eoclc%2eorg%2fnet%2foakley%2ftcl%2fmclistbox%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:37)</font></i><dt><b><a href="http://home.t-online.de/home/dshepherd/tkview.htm" ="">MFC views C++ class for embedding Tk</a></b>
+<dd>The idea of embedding Tk in MFC windows always seemed very enticing but information was sparse and contradictory - on a
+ scale between "very easy" and "not yet possible". The only thing for it was to have a go and lo, it wasn't that hard after all.
+ CTkView is a C++ class which can be used in MFC SDI or MDI applications. An instance of CTkView hosts an embedded Tk
+ toplevel widget and performs some management chores for the widget so that it can size, update and react correctly to Windows
+ events. <a href="/live/annotate?url=http%3a%2f%2fhome%2et%2donline%2ede%2fhome%2fdshepherd%2ftkview%2ehtm">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:38)</font></i><dt><b><a href="http://www.cs.umd.edu/hcil/pad++" ="">Pad++</a></b>
+<dd>
+ Author <b><a href="mailto:pad-info@cs.umd.edu" ="">Ben Bederson et al</a></b>, Version <b>0.9p1</b>,
+ Works with <b>8.0</b>
+<br>Download: <a href="http://www.cs.umd.edu/hcil/pad++/download.html">download.html</a><br>Pad++ is a Tk widget that provides a Zoomable User Interface (ZUI) that supports real-time interactive zoomable graphics in a fashion similar to the Tk Canvas widget. Pad++ supports tens of thousands of objects which include text, images, graphics, portals, lenses, simple html (and more), including transparency and rotation. <a href="/live/annotate?url=http%3a%2f%2fwww%2ecs%2eumd%2eedu%2fhcil%2fpad%2b%2b">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:39)</font></i><dt><b><a href="http://home.t-online.de/home/sesam.com/freeware.htm" ="">Progressbar</a></b>
+<dd>Progressbar is a megawidget written in pure tcl (ie: no compiling required - runs on all platforms Macintosh, Unix, Windows).
+Its primary purpose is to show the progress of any action in percent. <a href="/live/annotate?url=http%3a%2f%2fhome%2et%2donline%2ede%2fhome%2fsesam%2ecom%2ffreeware%2ehtm">Edit</a>
+ <i><font size="-1">(January 24, 2000 09:19)</font></i><dt><b><a href="http://jfontain.free.fr/" ="">scwoop (Simple Composite Widget Object Oriented Package)</a></b>
+<dd>Scwoop is a composite widget (also known as mega widget) extension to the great Tk widget library. Scwoop is
+entirely written in Tcl using the stooop (Simple Tcl Only Object Oriented Programming) extension. <a href="/live/annotate?url=http%3a%2f%2fjfontain%2efree%2efr%2f">Edit</a>
+ <i><font size="-1">(January 09, 2000 02:10)</font></i><dt><b><a href="http://www2.clearlight.com/~oakley/tcl/supertext.html" ="">Supertext - tk text widget with unlimited undo</a></b>
+<dd>
+ Author <b><a href="mailto:oakley@channelpoint.com" ="">Bryan Oakley</a></b>, Version <b>1.0b1</b>,
+ Works with <b>Tcl 8.0</b>
+<br>Download: <a href="http://www2.clearlight.com/~oakley/tcl/supertext.tcl">supertext.tcl</a><br>Supertext is a package that provides a tk text widget with full undo and the ability to execute procedures both before and after a text
+widget command has been processed. Supertext may be used as-is, or for the brave it may be used in place of the standard text
+widget. <a href="/live/annotate?url=http%3a%2f%2fwww2%2eclearlight%2ecom%2f%7eoakley%2ftcl%2fsupertext%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:06)</font></i><dt><b><a href="http://www.hwaci.com/sw/tk/nbpi.html" ="">Tabbed Notebook Widget</a></b>
+<dd>
+ Author <b><a href="mailto:drh@acm.org" ="">Richard Hipp</a></b>, Version <b>1.0</b>,
+ Works with <b>Tk 4.1 or later.</b>
+<br>Download: <a href="http://www.hwaci.com/sw/tk/notebook.tcl">notebook.tcl</a><br>This implements a tabbed notebook using
+a canvas widget and embedded frames.
+This is pure Tcl
+code - not a C extension. <a href="/live/annotate?url=http%3a%2f%2fwww%2ehwaci%2ecom%2fsw%2ftk%2fnbpi%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:08)</font></i><dt><b><a href="http://www.tcltk.com/ellson/ftp/Gdtclft2.0.README" ="">Tcl GD - graphics</a></b>
+<dd>
+ Author <b>John Ellson and Spencer Thomas</b>, Version <b>2.0</b>,
+ Works with <b>8.0 and higher</b>
+<br>Download: <a href="http://www.tcltk.com/ellson/ftp/Gdtclft2.0.tar.gz">Gdtclft2.0.tar.gz</a><br>
+ Thomas Boutell's Gd package provides a convenient way to generate
+ PNG images with a C program. If you prefer Tcl for CGI
+ applications, you'll want the TCL GD extension. <a href="/live/annotate?url=http%3a%2f%2fwww%2etcltk%2ecom%2fellson%2fftp%2fGdtclft2%2e0%2eREADME">Edit</a>
+ <i><font size="-1">(August 19, 1999 14:52)</font></i><dt><b><a href="http://www.stratasys.com/software/metagui" ="">The Meta-GUI Tools</a></b>
+<dd>The Meta-GUI tools provide a framework for quickly building full
+GUI applications. The GUI is rendered by a run-time engine
+based on a hierarchical set of definitions you provide. At the bottom
+of the hierarchy are abstract data types such as length, angle,
+string, etc., and these are used to progressively build up frames,
+dialogs, toolbars, menus, and operations. <a href="/live/annotate?url=http%3a%2f%2fwww%2estratasys%2ecom%2fsoftware%2fmetagui">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:10)</font></i><dt><b><a href="http://jfontain.free.fr/" ="">Tkpiechart Home Page</a></b>
+<dd>Tkpiechart is a Tcl-only extension that allows the programmer to create and dynamically update 2D or 3D pie
+charts in a Tcl/Tk application. This uses the stooop package and builds
+pie charts on a Tk canvas. <a href="/live/annotate?url=http%3a%2f%2fjfontain%2efree%2efr%2f">Edit</a>
+ <i><font size="-1">(January 09, 2000 02:12)</font></i><dt><b><a href="http://www.cygnus.com/~irox/tkprint/" ="">TkPrint</a></b>
+<dd>TkPrint is an extension that allows you to print from a
+ Tk widget. <a href="/live/annotate?url=http%3a%2f%2fwww%2ecygnus%2ecom%2f%7eirox%2ftkprint%2f">Edit</a>
+ <i><font size="-1">(October 11, 1999 09:58)</font></i><dt><b><a href="http://www.purl.org/net/hobbs/tcl/capp/" ="">TkTable Home Page</a></b>
+<dd>The TkTable widget. The <code>table</code> command creates a
+2-dimensional grid of cells. The table can use a Tcl array variable or Tcl
+
+command for data storage and retrieval. <a href="/live/annotate?url=http%3a%2f%2fwww%2epurl%2eorg%2fnet%2fhobbs%2ftcl%2fcapp%2f">Edit</a>
+ <i><font size="-1">(November 18, 1999 09:25)</font></i><dt><b><a href="http://ftp.austintx.net/users/jatucker/TkTextmatrix/default.htm" ="">TkTextMatrix (spreadsheet)</a></b>
+<dd>
+ Author <b><a href="mailto:jatucker@austin.dsccc.com" ="">John Arthur Tucker</a></b>, Version <b>4.1</b>,
+ Works with <b>Tk 4.1</b>
+<br>Download: <a href="http://ftp.austintx.net/users/jatucker/TkTextmatrix/download.htm">download.htm</a>, <a href="http://ftp.austintx.net/users/jatucker/TkTextmatrix/textmatrix4.1.tar.gz">textmatrix4.1.tar.gz</a><br>A Tcl/Tk spreadsheet widget, TkTextmatrix, which is implemented in C++ and is
+ basically a Tk Canvas widget plus extra behavior for manipulating rows and columns of cell
+ items many times faster than with a plain Tk Canvas. It actually inserts text nearly as fast
+ as the Tk Text widget. If you work with or are interested in creating your own Tcl/Tk widgets
+ in C++, you might want to take a look at the C++ widget library included with this
+ distribution. <a href="/live/annotate?url=http%3a%2f%2fftp%2eaustintx%2enet%2fusers%2fjatucker%2fTkTextmatrix%2fdefault%2ehtm">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:14)</font></i><dt><b><a href="http://www.cs.umd.edu/~bederson/Togl.html" ="">ToGL - a Tk Open GL widget</a></b>
+<dd>Togl is a Tk widget for OpenGL rendering. Togl is based on OGLTK, originally written by Benjamin Bederson at the
+University of New Mexico (who has since moved to the University of Maryland). Togl adds the new features:
+<ul>
+<li> color-index mode support including color allocation functions
+<li> support for requesting stencil, accumulation, alpha buffers, etc
+<li> multiple OpenGL drawing widgets
+<li> OpenGL extension testing from Tcl
+<li> simple, portable font support
+<li> overlay plane support
+</ul>
+Togl allows one to create and manage a special Tk/OpenGL widget with Tcl and render into it with a C program. That is,
+a typical Togl program will have Tcl code for managing the user interface and a C program for computations and
+OpenGL rendering. <a href="/live/annotate?url=http%3a%2f%2fwww%2ecs%2eumd%2eedu%2f%7ebederson%2fTogl%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:14)</font></i><dt><b><a href="http://www.hwaci.com/sw/tk/treepi.html" ="">Tree Widget</a></b>
+<dd>This implements a tree display in a canvas widget.
+It is similar in layout to that of the
+Windows explorer file viewer. This is pure Tcl
+code - not a C extension. <a href="/live/annotate?url=http%3a%2f%2fwww%2ehwaci%2ecom%2fsw%2ftk%2ftreepi%2ehtml">Edit</a>
+ <i><font size="-1">(September 29, 1999 14:37)</font></i><dt><b><a href="http://www.du.edu/~mschwart/tcl-tk.htm" ="">Windows Extensions for Tcl/Tk (Michael Schwartz)</a></b>
+<dd>This site has pointers to several extensions specific to the
+Windows platform. The extensions provide printing,
+a MAPI interface to send email, and an interface to manipulate
+.INI files, among other things. <a href="/live/annotate?url=http%3a%2f%2fwww%2edu%2eedu%2f%7emschwart%2ftcl%2dtk%2ehtm">Edit</a>
+ <i><font size="-1">(October 07, 1999 10:50)</font></i><dt><b><a href="http://www.tcltk.com/iwidgets/" ="">[incr Widgets] Home Page</a></b>
+<dd>[incr Widgets] is a set of megawidgets (combo boxes, etc.) that are
+upon the [incr Tcl] object system and the [incr Tk] megawidget
+framework. This comes bundled with the
+<a href="http://www.tcltk.com/itcl/">[incr Tcl]</a> distributions. <a href="/live/annotate?url=http%3a%2f%2fwww%2etcltk%2ecom%2fiwidgets%2f">Edit</a>
+ <i><font size="-1">(September 05, 1999 16:08)</font></i><dt><b><a href="http://www1.clearlight.com/~oakley/tcl/combobox/index.html" ="">combobox</a></b>
+<dd>
+ Author <b><a href="mailto:oakley@channelpoint.com" ="">Bryan Oakley</a></b>, Version <b>1.03</b>,
+ Works with <b>8.x</b>
+<br>Download: <a href="http://www1.clearlight.com/~oakley/tcl/combobox/combobox.tcl">combobox.tcl</a><br>combobox is a pure-tcl implementation of a combobox widget. It is
+entirely self contained and does not require any other OO or megawidget
+extension. It supports both editable and non-editable entries, and
+provides the ability to call a procedure anytime the value of the combobox
+changes. <a href="/live/annotate?url=http%3a%2f%2fwww1%2eclearlight%2ecom%2f%7eoakley%2ftcl%2fcombobox%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:15)</font></i><dt><b><a href="http://www.multimania.com/droche/rnotebook/index.html" ="">Rnotebook</a></b>
+<dd>
+ Author <b><a href="mailto:dan@lectra.com" ="">Daniel Roche</a></b>, Version <b>1.0</b>,
+ Works with <b>8.0 or higher</b>
+<br>Download: <a href="http://www.multimania.com/droche/rnotebook/index.html">index.html</a><br>This implements a resizeable notebook
+widget in pure tcl/tk <a href="/live/annotate?url=http%3a%2f%2fwww%2emultimania%2ecom%2fdroche%2frnotebook%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:39)</font></i><dt><b><a href="http://www.tregar.com/samdi.html" ="">saMDI v1.0a1 Multi-Document Interface Extension</a></b>
+<dd>A multi-document interface (MDI) extension for TCL/Tk 8.0.
+This is a common interface format in Microsoft Windows that lets a parent window contain multiple child windows.
+In effect you get a window manager inside a window!
+Uses and includes the STOOOP object-oriented extension by
+Jean-Luc Fontaine.
+saMDI v1.0a1 GPL Copyright 1998 Sam Tregar. <a href="/live/annotate?url=http%3a%2f%2fwww%2etregar%2ecom%2fsamdi%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:07)</font></i><dt><b><a href="http://tix.mne.com/htdocs/tix/index.html" ="">Tix Support Site</a></b>
+<dd>
+ Author <b><a href="mailto:tix@mne.com" ="">Ioi Lam, (adopted by Gregg Squires)</a></b>, Version <b>4.1</b>,
+ Works with <b>Tcl 7.4 through Tcl 8.0</b>
+<br><a href="ftp://ftp.tix.mne.com/pub/tix/">Download</a>, <a href="ftp://ftp.tix.mne.com/pub/tix/Tix4.1.0.006.tar.gz">Tix4.1.0.006.tar.gz</a>, <a href="ftp://ftp.tix.mne.com/pub/tix/Tix41p6.zip">Tix41p6.zip</a>, <a href="ftp://ftp.tix.mne.com/pub/tix/win41p6bin.zip">win41p6bin.zip</a><br><b>Tix has found a new home!</b>
+ <br>
+ Tix provides over 40 new Tk including the
+combo box, file selection dialogs, paned widget,
+notebook, hierarchical list, directory tree, and more.
+ <a href="/live/annotate?url=http%3a%2f%2ftix%2emne%2ecom%2fhtdocs%2ftix%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:11)</font></i><dt><b><a href="ftp://ftp.archive.eso.org/pub/tree" ="">Tk Tree Widget (C++)</a></b>
+<dd>Tk Tree widget for Tcl8.0.3.
+
+This version contains (optional) support for \[incr Tcl\] and \[incr Tk\]
+version 3.0.
+<br>
+With the tree widget, you can display a tree in a Tk canvas. The nodes
+can be made up of any number of canvas items or even other Tk widgets.
+You create the objects that make up a node and the line that connects
+it to its parent and pass them to the tree widget. After this the tree
+widget manages the positions of the nodes and end points of the tree
+lines. Operations are available for inserting, moving and removing
+nodes and subtrees and for querrying the position of a node in the
+tree. The tree can be displayed horizontally or vertically.
+ <a href="/live/annotate?url=ftp%3a%2f%2fftp%2earchive%2eeso%2eorg%2fpub%2ftree">Edit</a>
+ <i><font size="-1">(August 25, 1999 03:14)</font></i><dt><b><a href="http://www.purl.org/net/hobbs/tcl/script/widget/" ="">widget, simple megawidget package</a></b>
+<dd>
+ Author <b><a href="mailto:jeffrey.hobbs@oen.siemens.de" ="">Jeffrey Hobbs</a></b>, Version <b>0.9</b>,
+ Works with <b>Tcl/Tk 8.0 or higher</b>
+<br>Download: <a href="http://www.purl.org/net/hobbs/tcl/script/widget/widget-0.9.tar.gz">widget-0.9.tar.gz</a><br>This is a package of
+ megawidgets (i.e., compound widgets) that work almost exactly like Tk widgets.
+ You can also build your own new megawidgets.
+Includes: combobox, hierarchy, console, progressbar,
+tabnotebook, validating entry, pane geometry manager, baloon help. <a href="/live/annotate?url=http%3a%2f%2fwww%2epurl%2eorg%2fnet%2fhobbs%2ftcl%2fscript%2fwidget%2f">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:16)</font></i></dl>
+<hr><p><center><font size="-1" face="Geneva, Helvetica, Arial"><br><a href="#TOP"><b>Top</b></a><br><!-- key ResourceSoftwareExtensions --><a href="/">Home</a>
+ | <a href="/products/">Products</a>
+ | <a href="/customers/">Customers</a>
+ | <a href="/partners/">Partners</a>
+ | <a href="/services/">Services</a>
+ | <a href="/resource/">Tcl Resources</a>
+ | <a href="/company/">Company</a>
+<br><a href="/live/keyword">Search</a>
+ | <a href="/live/map">Site Map</a>
+ | <a href="/company/feedback.html?url=%2fresource%2fsoftware%2fextensions%2ftk%2f">Feedback</a>
+ | <a href="/company/contact.html">Contact Us</a>
+ | <a href="mailto:info@scriptics.com">info@scriptics.com</a>
+
+ <SCRIPT LANGUAGE="Javascript">
+<!--
+ browser = (((navigator.appName == "Netscape") &&(parseInt(navigator.appVersion) >= 3 )) || ((navigator.appName =="Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )))
+
+ if ( browser )
+ {
+ over = new MakeImageArray(10)
+ over[0].src = "http://images.scriptics.com/images/ProductsMouseOff.gif"
+ over[1].src = "http://images.scriptics.com/images/CustomersMouseOff.gif"
+ over[2].src = "http://images.scriptics.com/images/PartnersMouseOff.gif"
+ over[3].src = "http://images.scriptics.com/images/ServicesMouseOff.gif"
+ over[4].src = "http://images.scriptics.com/images/ResourceMouseOff.gif"
+ over[5].src = "http://images.scriptics.com/images/CompanyMouseOff.gif"
+ over[6].src = "http://images.scriptics.com/images/homeMainRollover1.gif"
+ over[7].src = "http://images.scriptics.com/images/homeMainRollover2.gif"
+ over[8].src = "http://images.scriptics.com/images/homeMainRollover3.gif"
+ over[9].src = "http://images.scriptics.com/images/homeMainRollover3.gif"
+
+ }
+
+ function MakeImageArray(n) {
+ this.length = n
+ for (var i = 0; i<=n; i++)="i++)" {="{" this[i]="this[i]" ="" new="new" Image()="Image()" }="}" return="return" this="this" }="}" //="//" --="--">
+ </SCRIPT><br>
+ <font size="2">
+ &copy; 1998-2000 Scriptics Corporation. All rights reserved.
+ <a href="/legal_notice.html">Legal Notice</a> | <A href="" /privacy.html="/privacy.html">
+ Privacy Statement</a>
+ </td></tr></table></td></tr></table>
+</Body>
+</Html> \ No newline at end of file
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image1 b/ext/tk/sample/tkextlib/tkHTML/page3/image1
new file mode 100644
index 0000000000..814d1e8f08
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image1
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image10 b/ext/tk/sample/tkextlib/tkHTML/page3/image10
new file mode 100644
index 0000000000..45001faf05
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image10
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image11 b/ext/tk/sample/tkextlib/tkHTML/page3/image11
new file mode 100644
index 0000000000..7c4c170f21
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image11
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image12 b/ext/tk/sample/tkextlib/tkHTML/page3/image12
new file mode 100644
index 0000000000..903e7344a6
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image12
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image13 b/ext/tk/sample/tkextlib/tkHTML/page3/image13
new file mode 100644
index 0000000000..226d4f68c2
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image13
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image14 b/ext/tk/sample/tkextlib/tkHTML/page3/image14
new file mode 100644
index 0000000000..8e8c71814c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image14
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image2 b/ext/tk/sample/tkextlib/tkHTML/page3/image2
new file mode 100644
index 0000000000..2ddeb3258c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image2
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image3 b/ext/tk/sample/tkextlib/tkHTML/page3/image3
new file mode 100644
index 0000000000..1651ba7e41
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image3
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image4 b/ext/tk/sample/tkextlib/tkHTML/page3/image4
new file mode 100644
index 0000000000..b565c8dd0e
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image4
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image5 b/ext/tk/sample/tkextlib/tkHTML/page3/image5
new file mode 100644
index 0000000000..e1268b81c0
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image5
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image6 b/ext/tk/sample/tkextlib/tkHTML/page3/image6
new file mode 100644
index 0000000000..1a6b260b40
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image6
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image7 b/ext/tk/sample/tkextlib/tkHTML/page3/image7
new file mode 100644
index 0000000000..cec7aa04d8
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image7
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image8 b/ext/tk/sample/tkextlib/tkHTML/page3/image8
new file mode 100644
index 0000000000..ad0d748d65
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image8
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/image9 b/ext/tk/sample/tkextlib/tkHTML/page3/image9
new file mode 100644
index 0000000000..46ade3018b
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/image9
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page3/index.html b/ext/tk/sample/tkextlib/tkHTML/page3/index.html
new file mode 100644
index 0000000000..ce92e8a22e
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page3/index.html
@@ -0,0 +1,2787 @@
+<html><body bgcolor="white">
+<hr>
+<h1 align="center">Embedding Tcl in C/C++ Applications</h1>
+
+ <table width="100%">
+ <tr><td valign="top" align="left" width="46%">
+ <b>Presented At:</b>
+ <blockquote>
+ The&nbsp;Tcl2K&nbsp;Conference<br>
+ Austin, Texas<br>
+ <nobr>9:00am, February 15, 2000</nobr><br>
+ </blockquote>
+ </td>
+ <td width="5%">&nbsp;</td>
+ <td valign="top" align="left" width="46%">
+ <b>Instructor:</b>
+ <blockquote>
+ D. Richard Hipp<br>
+ drh@hwaci.com<br>
+ http://www.hwaci.com/drh/<br>
+ 704.948.4565
+ </blockquote>
+ </td></tr>
+ </table><p>
+ <center><table border="2">
+ <tr><td>
+ <p align="center">
+ Copies of these notes, example source code,<br>and other
+ resources related to this tutorial<br>are available online at
+ <a href="http://www.hwaci.com/tcl2k/">
+ http://www.hwaci.com/tcl2k/</a></p>
+ <p align="center"><small>$Id$</small></p></td></tr>
+ </table>
+ </center>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Tutorial Outline</h2>
+<p><ul><li>Introduction</li>
+<li>Building It Yourself</li>
+<ul><li>"Hello, World!" using Tcl</li>
+<li>Tcl scripts as C strings</li>
+<li>Adding new Tcl commands</li>
+<li>A tour of the Tcl API</li>
+<li>Tcl initialization scripts</li>
+<li>Adding Tk</li>
+</ul><li>Tools Survey</li>
+<li>Mktclapp</li>
+<ul><li>"Hello World" using mktclapp</li>
+<li>Adding C code</li>
+<li>Other Features</li>
+<li>Invoking Tcl from C</li>
+<li>Running mktclapp directly</li>
+<li>Real-world examples</li>
+</ul><li>Summary</li>
+</ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Embedding Tcl in C/C++ Applications</h2>
+<p><ul><li>You know how to program in Tcl/Tk</li></ul><ul><li>You know how to program in C/C++</li></ul><ul><li>This tutorial is about how to do both at the same time.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Why Mix C With Tcl/Tk?</h2>
+<p><ul><li>Use C for the things C is good at and Tcl for the things
+ Tcl is good at.</li></ul><ul><li>Generate standalone executables.
+ <ul><li>Eliminate the need to install Tcl/Tk.</li>
+ <li>Prevent problems when the wrong version of Tcl/Tk is installed.</li>
+ </ul></li></ul><ul><li>Prevent end users from changing the source code.
+ <ul><li>Keeps users from creating new bugs.</li>
+ <li>Protects proprietary code.</li>
+ </ul></li></ul><ul><li>Office politics</li></ul><ul><li>Use Tcl/Tk as a portability layer for a large C program</li></ul><ul><li>Use Tcl as a testing interface</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Why Mix C With Tcl/Tk?</h2>
+<p><blockquote><big><b>
+ "Use C for the things C is good at and use Tcl/Tk for the things
+ Tcl/Tk is good at."
+ </b></blockquote></p><p>
+
+ <table width="100%">
+ <tr><td valign="top" align="left" width="46%">
+ <b>C is good at:</b>
+ <ul>
+ <li>Speed</li>
+ <li>Complex data structures</li>
+ <li>Computation</li>
+ <li>Interacting with hardware</li>
+ <li>Byte-by-byte data analysis</li>
+ </ul>
+ </td>
+ <td width="5%">&nbsp;</td>
+ <td valign="top" align="left" width="46%">
+ <b>Tcl/Tk is good at:</b>
+ <ul>
+ <li>Building a user interface</li>
+ <li>Manipulation of strings</li>
+ <li>Portability</li>
+ <li>Opening sockets</li>
+ <li>Handling events</li>
+ </ul>
+ </td></tr>
+ </table>
+<br clear="both"><p><hr></p>
+<h2 align="center">Programming Models</h2>
+<table width="100%">
+<tr><td valign="top" width="49%">
+
+ <p><b>Mainstream Tcl Programming Model:</b></p>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <p><b>Embedded Tcl Programming Model:&nbsp;&nbsp;</b></p>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <ul><li>Add bits of C code to a large Tcl program</li></ul>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <ul><li>Add bits of Tcl code to a large C program</li></ul>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <ul><li>Main Tcl script loads extensions written in C</li></ul>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <ul><li>Main C procedure invokes the Tcl interpreter</li></ul>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <ul><li>Tcl/Tk is a programming language</li></ul>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <ul><li>Tcl/Tk is a C library</li></ul>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <center><img src="image1"><br>
+ Most of the Tcl2K conference is about</center>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <center><img src="image1"><br>
+ This tutorial is about</center>
+</td></tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using The Tcl Library</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h></tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Always include &lt;tcl.h></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Create a new Tcl interpreter</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;"puts&nbsp;{Hello,&nbsp;World!}");</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute a Tcl command.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Compiling "Hello, World!"</h2>
+<p><p><b>Unix:</b></p>
+ <blockquote><tt>
+ $ gcc hello.c -ltcl -lm -ldl<br>
+ $ ./a.out<br>
+ Hello, World!</tt></blockquote>
+
+ <p><b>Windows using Cygwin:</b></p>
+ <blockquote><tt>
+ C:> gcc hello.c -ltcl80 -lm<br>
+ C:> a.exe<br>
+ Hello, World!</tt></blockquote>
+
+ <p><b>Windows using Mingw32:</b></p>
+ <blockquote><tt>
+ C:> gcc -mno-cygwin hello.c -ltcl82 -lm<br>
+ </tt></blockquote>
+<table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Also works with VC++</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Where Does <tt>-ltcl</tt> Come From On Unix?</h2>
+<p><p>Build it yourself using these steps:</p></p><p>
+<p><ul><li>Get tcl8.2.2.tar.gz from Scriptics</li></ul><ul><li><tt>zcat tcl8.2.2.tar.gz | tar vx </tt></li></ul><ul><li><tt>cd tcl8.2.2/unix</tt></li></ul><ul><li><tt>./configure --disable-shared</tt></li></ul><ul><li><tt>make</tt></li></ul><ul><li>Move <b>libtcl8.2.a</b> to your lib directory.</li></ul><ul><li>Copy <b>../generic/tcl.h</b> into /usr/include.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">What Other Libraries Are Required For Unix?</h2>
+<p><ul><li>The sequence of <b>-l</b> options after <b>-ltcl</b>
+ varies from system to system</li></ul><ul><li>Observe what libraries the TCL makefile inserts when
+ it is building <b>tclsh</b></li></ul><ul><li>Examples in this talk are for RedHat Linux 6.0 for Intel</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">How To Compile Under Unix Without Installing Tcl</h2>
+<p><p>Specify the *.a file directly:</p>
+ <blockquote><pre>
+ $ gcc -I../tcl8.2.2/generic hello.c \
+ ../tcl8.2.2/unix/libtcl8.2.a -lm -ldl
+ $ strip a.out
+ $ ./a.out
+ Hello, World!</pre></blockquote>
+
+ <p>Or, tell the C compiler where to look for *.a files:</p>
+ <blockquote><pre>
+ $ gcc -I../tcl8.2.2/generic hello.c \
+ -L../tcl8.2.2/unix -ltcl -lm -ldl
+ $ strip a.out
+ $ ./a.out
+ Hello, World!</pre></blockquote>
+<table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>The <tt>-I../tcl8.2.2</tt> argument
+ tells the compiler where to
+ find <tt>&lt;tcl.h&gt;</tt>.</p></b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">What's "Cygwin"?</h2>
+<p><ul><li>An implementation of GCC/G++ and all development tools
+ for Windows95/98/NT/2000</li></ul><ul><li>Available for free download at
+ <blockquote>
+ <tt>http://sourceware.cygnus.com/cygwin/</tt>
+ </blockquote></li></ul><ul><li>Also available shrink-wrapped at your local software retailer or
+ online at
+ <blockquote>
+ <tt>http://www.cygnus.com/cygwin/index.html</tt>
+ </blockquote></li></ul><ul><li>Programs compiled using Cygwin require a special
+ DLL (<b>cygwin1.dll</b>) that provides a POSIX system API</li></ul><ul><li>Cygwin1.dll cannot be shipped with proprietary programs
+ without purchasing a license from Cygnus.</li></ul><ul><li>Mingw32 is the same compiler as Cygwin, but generates
+ binaries that do not use cygwin1.dll</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Where Does <tt>-ltcl82</tt> Come From On Windows?</h2>
+<p><p>Build it like this:</p></p><p>
+<p><ul><li>Get <b>tcl82.lib</b> and <b>tcl82.dll</b> from Scriptics.</li></ul><ul><li><tt>echo EXPORTS >tcl82.def</tt></li></ul><ul><li><tt>nm tcl82.lib | grep 'T _' | sed 's/.* T _//' >>tcl82.def</tt></li></ul><ul><li><tt>dlltool --def tcl82.def --dllname tcl82.dll --output-lib libtcl82.a</tt></li></ul><ul><li>Move <b>libtcl82.a</b> to the lib directory and <b>tcl82.dll</b>
+ to the bin directory.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Where Does Your Code Go?</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Your&nbsp;application&nbsp;code&nbsp;goes&nbsp;here&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Insert C code here to do whatever it is your program is
+ suppose to do</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Building A Simple TCLSH</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;char&nbsp;*z;<br>
+&nbsp;&nbsp;char&nbsp;zLine[2000];<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;while(&nbsp;fgets(zLine,sizeof(zLine),stdin)&nbsp;){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Get one line of input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zLine);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute the input as Tcl.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;z&nbsp;=&nbsp;Tcl_GetStringResult(interp);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;z[0]&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("¸üÿ¿PX¶\n",&nbsp;z);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Print result if not empty</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>What if user types more than 2000 characters?</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Building A Simple TCLSH</h2>
+<p>Use TCL to handle input. Allows input lines of unlimited length.</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+/*&nbsp;Tcl&nbsp;code&nbsp;to&nbsp;implement&nbsp;the<br>
+**&nbsp;input&nbsp;loop&nbsp;*/<br>
+static&nbsp;char&nbsp;zLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;"while&nbsp;{![eof&nbsp;stdin]}&nbsp;{\n"</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"&nbsp;&nbsp;set&nbsp;line&nbsp;[gets&nbsp;stdin]\n"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Get one line of input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"&nbsp;&nbsp;set&nbsp;result&nbsp;[eval&nbsp;$line]\n"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute input as Tcl</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{$result!=\"\"}&nbsp;{puts&nbsp;$result}\n"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Print result</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"}\n"<br>
+;<br>
+&nbsp;<br>
+<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Run the Tcl input loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But what about commands that span multiple lines of input?</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Better Handling Of Command-Line Input</h2>
+<p>The file "input.tcl"</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>set&nbsp;line&nbsp;{}<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if&nbsp;{$line!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;">&nbsp;"<br>
+&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;"%&nbsp;"<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;flush&nbsp;stdout</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Prompt for user input. The prompt is normally &quot;%&quot;
+ but changes to &quot;&gt;&quot; if the current line is a continuation.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;append&nbsp;line&nbsp;[gets&nbsp;stdin]<br>
+&nbsp;&nbsp;if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">If the command is complete, execute it.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;stderr&nbsp;"Error:&nbsp;$result"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{$result!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;$result<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;line&nbsp;{}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;line&nbsp;\n<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">If the command is incomplete, append a newline and get
+ another line of text.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Better Handling Of Command-Line Input</h2>
+<p>The file "input.c"</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;"source&nbsp;input.tcl");</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Read and execute the input loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But now the program is not standalone!</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts Into C Strings</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;"set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"while&nbsp;{![eof&nbsp;stdin]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{$line!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;\">&nbsp;\"\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;\"%&nbsp;\"\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;flush&nbsp;stdout\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;append&nbsp;line&nbsp;[gets&nbsp;stdin]\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;stderr&nbsp;\"Error:&nbsp;$result\"\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{$result!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;$result\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;}\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;line&nbsp;\\n\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Compile Tcl Scripts Into C Programs</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Actual&nbsp;code&nbsp;omitted&nbsp;*/<br>
+;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Copy and paste the converted Tcl script here</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute the Tcl code</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts To Strings<br>Using SED Or TCLSH</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>sed&nbsp;-e&nbsp;'s/\\/\\\\/g'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>\</b> into <b>\\</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/"/\\"/g'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>"</b> into <b>\"</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/^/&nbsp;&nbsp;"/'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Add <b>"</b> to start of each line</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/$/\\n"/'&nbsp;input.tcl</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Add <b>\n"</b> to end of each line</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{<br>
+&nbsp;&nbsp;set&nbsp;line&nbsp;[gets&nbsp;stdin]</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{\}&nbsp;$line&nbsp;{&amp;&amp;}&nbsp;line</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>\</b> into <b>\\</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{"}&nbsp;$line&nbsp;{\"}&nbsp;line</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>"</b> into <b>\"</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;puts&nbsp;"\"$line\\n\""</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Add <b>"</b> in front and <b>\n"</b> at the end</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts Into C Strings</h2>
+<p>You may want to save space by removing comments and extra whitespace
+ from scripts.</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;"set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"while&nbsp;{![eof&nbsp;stdin]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"if&nbsp;{$line!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;-nonewline&nbsp;\">&nbsp;\"\n"<br>
+&nbsp;&nbsp;"}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;-nonewline&nbsp;\"%&nbsp;\"\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"flush&nbsp;stdout\n"<br>
+&nbsp;&nbsp;"append&nbsp;line&nbsp;[gets&nbsp;stdin]\n"<br>
+&nbsp;&nbsp;"if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"if&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;stderr&nbsp;\"Error:&nbsp;$result\"\n"<br>
+&nbsp;&nbsp;"}&nbsp;elseif&nbsp;{$result!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;$result\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"append&nbsp;line&nbsp;\\n\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts To Strings</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>sed&nbsp;-e&nbsp;'s/\\/\\\\/g'&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;-e&nbsp;'s/"/\\"/g'&nbsp;\&nbsp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'/^&nbsp;*#/d'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete lines that begin with #</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'/^&nbsp;*$/d'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete blank lines</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/^&nbsp;*/&nbsp;&nbsp;"/'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete leading spaces</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/$/\\n"/'&nbsp;input.tcl<br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{<br>
+&nbsp;&nbsp;set&nbsp;line&nbsp;[gets&nbsp;stdin]</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;set&nbsp;line&nbsp;[string&nbsp;trimleft&nbsp;$line]</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Remove leading space</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if&nbsp;{$line==""}&nbsp;continue</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete blank lines</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if&nbsp;{[string&nbsp;index&nbsp;$line&nbsp;0]=="#"}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;continue<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete lines starting with #</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{\}&nbsp;$line&nbsp;{&amp;&amp;}&nbsp;line<br>
+&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{"}&nbsp;$line&nbsp;{\"}&nbsp;line<br>
+&nbsp;&nbsp;puts&nbsp;"\"$line\\n\""<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Removing Comments Or Leading Space<br>Will Break Some Tcl Scripts!</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>image&nbsp;create&nbsp;bitmap&nbsp;smiley&nbsp;-data&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>#define&nbsp;smile_width&nbsp;15<br>
+#define&nbsp;smile_height&nbsp;15</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">These lines begin with # but are not comment</td>
+</tr>
+<tr><td valign="center">
+<small><tt>static&nbsp;unsigned&nbsp;char&nbsp;smile_bits[]&nbsp;=&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;0xc0,&nbsp;0x01,&nbsp;0x30,&nbsp;0x06,&nbsp;0x0c,&nbsp;0x18,<br>
+&nbsp;&nbsp;&nbsp;0x04,&nbsp;0x10,&nbsp;0x22,&nbsp;0x22,&nbsp;0x52,&nbsp;0x25,<br>
+&nbsp;&nbsp;&nbsp;0x01,&nbsp;0x40,&nbsp;0x01,&nbsp;0x40,&nbsp;0x01,&nbsp;0x40,<br>
+&nbsp;&nbsp;&nbsp;0x12,&nbsp;0x24,&nbsp;0xe2,&nbsp;0x23,&nbsp;0x04,&nbsp;0x10,<br>
+&nbsp;&nbsp;&nbsp;0x0c,&nbsp;0x18,&nbsp;0x30,&nbsp;0x06,&nbsp;0xc0,&nbsp;0x01};<br>
+}<br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+text&nbsp;.t<br>
+pack&nbsp;.t<br>
+.t&nbsp;insert&nbsp;end&nbsp;[string&nbsp;trim&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>She&nbsp;walks&nbsp;in&nbsp;beauty,&nbsp;like&nbsp;the&nbsp;night<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Of&nbsp;cloudless&nbsp;climes&nbsp;and&nbsp;starry&nbsp;skies;<br>
+And&nbsp;all&nbsp;that's&nbsp;best&nbsp;of&nbsp;dark&nbsp;and&nbsp;bright<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Meet&nbsp;in&nbsp;her&nbsp;aspect&nbsp;and&nbsp;her&nbsp;eyes;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Indentation is deleted on lines 2
+ and 4</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}]&nbsp;<br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Problems like these are rare</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding A "continue" Command</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>set&nbsp;line&nbsp;{}<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{<br>
+&nbsp;&nbsp;if&nbsp;{$line!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;">&nbsp;"<br>
+&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;"%&nbsp;"<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;flush&nbsp;stdout<br>
+&nbsp;&nbsp;append&nbsp;line&nbsp;[gets&nbsp;stdin]<br>
+&nbsp;&nbsp;if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{[lindex&nbsp;$line&nbsp;0]=="continue"}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Break out of the loop if the command
+ is "continue"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;stderr&nbsp;"Error:&nbsp;$result"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{$result!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;$result<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;line&nbsp;{}<br>
+&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;line&nbsp;\n<br>
+&nbsp;&nbsp;}<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Stop For Tcl Input At Various Points<br>In A C Program</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;Input&nbsp;loop&nbsp;as&nbsp;a&nbsp;C&nbsp;string&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Application&nbsp;C&nbsp;code&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Do some computation</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Stop for some Tcl input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;More&nbsp;application&nbsp;C&nbsp;code&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Do more computation</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Stop for more Tcl input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Finish&nbsp;up&nbsp;the&nbsp;application&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Finish the computation</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Using Tcl For Testing</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;Input&nbsp;loop&nbsp;as&nbsp;a&nbsp;C&nbsp;string&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+#ifdef&nbsp;TESTING<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Create interpreter only if TESTING
+ is defined</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();<br>
+#endif<br>
+&nbsp;&nbsp;/*&nbsp;Application&nbsp;C&nbsp;code&nbsp;*/</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>#ifdef&nbsp;TESTING<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+#endif</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Accept command-line input only if TESTING
+ is defined</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;More&nbsp;application&nbsp;C&nbsp;code&nbsp;*/<br>
+#ifdef&nbsp;TESTING<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+#endif<br>
+&nbsp;&nbsp;/*&nbsp;Finish&nbsp;up&nbsp;the&nbsp;application&nbsp;*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Creating A New Tcl Command In C</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;NewCmd(</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;void&nbsp;*clientData,<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,<br>
+&nbsp;&nbsp;int&nbsp;argc,<br>
+&nbsp;&nbsp;char&nbsp;**argv</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The Tcl command is implemented as
+ a C function with four arguments.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>){<br>
+&nbsp;&nbsp;printf("Hello,&nbsp;World!\n");</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Returns TCL_OK or TCL_ERROR</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_CreateCommand(interp,&nbsp;"helloworld",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCmd,&nbsp;0,&nbsp;0);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Tell the interpreter which C function to call when the
+ "helloworld" Tcl command is executed</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Linkage From Tcl To C</h2>
+<p><p align="center"><img src="image4"></p></p><p><ul><li>3rd parameter of Tcl_CreateCommand() is a pointer to the C subroutine
+ that implements the command.</li></ul><ul><li>4th parameter to Tcl_CreateCommand() becomes the 1st parameter to
+ the C routine whenever the Tcl command is executed.</li></ul><ul><li>1st parameter to Tcl_CreateCommand() must be a valid Tcl interpreter.
+ The same pointer appears as the second parameter to the C routine
+ whenever the Tcl command is executed.</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Linkage From Tcl To C</h2>
+<p><p align="center"><img src="image5"></p></p><p><ul><li>5th parameter of Tcl_CreateCommand() is a pointer to the C subroutine
+ that is called when the Tcl command is deleted.</li></ul><ul><li>4th parameter to Tcl_CreateCommand() becomes the 1st parameter to
+ the C routine.</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">When To Use A Delete Proc</h2>
+<p>Examples of where the delete proc is used in standard Tcl/Tk:</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>button&nbsp;.b&nbsp;-text&nbsp;Hello<br>
+pack&nbsp;.b</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>rename&nbsp;.b&nbsp;{}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Deleting the <b>.b</b> command causes the button to be destroyed</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>image&nbsp;create&nbsp;photo&nbsp;smiley&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;-file&nbsp;smiley.gif</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>rename&nbsp;smiley&nbsp;{}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Deleting the <b>smiley</b> command destroys the image and reclaims the
+ memory used to hold the image</td>
+</tr>
+</table>
+<p><ul><li>Always use a delete proc if the clientData is a pointer to
+ malloced memory or some other resource that needs freeing</li></ul><ul><li>Delete procs are never used in the Tcl core but are used
+ extensively in Tk</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Linkage From Tcl To C</h2>
+<p>The <tt>argc</tt> and <tt>argv</tt> parameters work just like in
+ <tt>main()</tt></p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>helloworld&nbsp;one&nbsp;{two&nbsp;three}&nbsp;four</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><tt>argc = 4<br>
+ argv[0] = "helloworld"<br>
+ argv[1] = "one"<br>
+ argv[2] = "two three"<br>
+ argv[3] = "four"<br>
+ argv[4] = NULL</tt></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">A Short-Cut</h2>
+<p>In a program with many new Tcl commands implemented in C, it becomes
+ tedious to type the same four parameters over and over again. So
+ we define a short-cut.</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#define&nbsp;TCLARGS&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;*clientData,&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;argc,&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;*argv</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Define TCLARGS once in a header file</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;<br>
+&nbsp;<br>
+&nbsp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;NewCmd(TCLARGS){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Use the TCLARGS macro to define new C functions
+ that implement Tcl commands.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;/*&nbsp;implementation...&nbsp;*/<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>For brevity, we will use the TCLARGS macro during the
+ rest of this talk.</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Returning A Value From C Back To Tcl</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;NewCmd(TCLARGS){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Note that the C function returns an "int"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Return value is TCL_OK or TCL_ERROR</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><ul><li>TCL_OK and TCL_ERROR are defined in &lt;tcl.h&gt;</li></ul><ul><li>Other valid return values TCL_RETURN, TCL_BREAK and TCL_CONTINUE
+ are rarely used</li></ul><ul><li>Common mistake: forgetting to return TCL_OK</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Returning A Value From C Back To Tcl</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;NewCmd(TCLARGS){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_SetResult(interp,"Hello!",TCL_STATIC);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Set the result to "Hello!"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><ul><li>Result should be the text of an error message if you
+ return TCL_ERROR.</li></ul><ul><li>3rd argument to Tcl_SetResult() can be TCL_STATIC,
+ TCL_DYNAMIC, TCL_VOLATILE, or a function pointer.</li></ul><ul><li>Also consider using Tcl_AppendResult().</li></ul><ul><li>Direct access to <tt>interp->result</tt> is deprecated.</li></ul><ul><li>See the man pages for details.</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The Tcl_Obj Interface</h2>
+<p><ul><li>A new way to write Tcl commands in C code</li></ul><ul><li>First introduced in Tcl8.0</li></ul><ul><li>Can be much faster, especially for lists or numeric values.</li></ul><ul><li>Able to handle arbitrary binary data.</li></ul><ul><li>More difficult to program.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The Tcl_Obj Interface</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;NewObjCmd(<br>
+&nbsp;&nbsp;void&nbsp;*clientData,<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,<br>
+&nbsp;&nbsp;int&nbsp;objc,</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Obj&nbsp;*const*&nbsp;objv</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">4th parameter is an array Tcl_Objs, not an array of strings</td>
+</tr>
+<tr><td valign="center">
+<small><tt>){<br>
+&nbsp;&nbsp;/*&nbsp;Implementation...&nbsp;*/<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}<br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_CreateObjCommand(interp,&nbsp;"newcmd",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewObjCmd,&nbsp;0,&nbsp;0);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Use a different function to register the command</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The Tcl_Obj Interface</h2>
+<p><ul><li>There are countless access methods for reading information from and
+ placing information in Tcl_Objs. Always use the access methods.</li></ul><ul><li>Details provided at Lee Bernhard's talk this afternoon.</li></ul><ul><li>Definitely use Tcl_Objs if you are writing a new Tcl extension.</li></ul><ul><li>Tcl_Objs address some of the weaknesses of Tcl relative to C/C++.
+ <ul>
+ <li> Tcl_Objs are faster </li>
+ <li> Tcl_Objs work with binary data </li>
+ </ul>
+ But C/C++ is faster still and better for working with binary data.</li></ul><ul><li>When mixing C/C++ with Tcl/Tk the benefits of Tcl_Objs are
+ less important. Using Tcl_Objs in this context may not be
+ worth the extra trouble.</li></ul><ul><li>This talk will focus on the string interface.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>Memory allocation functions</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Alloc<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Free<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Realloc<br>
+</tt></small></td>
+</table></center><p><b>Functions useful in the implementation of new Tcl commands</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_AppendElement<br>
+ Tcl_AppendResult<br>
+ Tcl_GetBoolean<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetDouble<br>
+ Tcl_GetInt<br>
+ Tcl_GetStringResult<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_ResetResult<br>
+ Tcl_SetResult<br>
+</tt></small></td>
+</table></center><p><b>Functions for controlling the Tcl interpreter</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_CreateCommand<br>
+ Tcl_CreateInterp<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_CreateObjCommand<br>
+ Tcl_DeleteCommand<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_DeleteInterp<br>
+ Tcl_Exit<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>I/O functions</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Close<br>
+ Tcl_Eof<br>
+ Tcl_Flush<br>
+ Tcl_GetChannel<br>
+ Tcl_GetChannelMode<br>
+ Tcl_GetChannelName<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Gets<br>
+ Tcl_OpenCommandChannel<br>
+ Tcl_OpenFileChannel<br>
+ Tcl_OpenTcpClient<br>
+ Tcl_OpenTcpServer<br>
+ Tcl_Read<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Seek<br>
+ Tcl_Tell<br>
+ Tcl_Ungets<br>
+ Tcl_Write<br>
+ Tcl_WriteChars<br>
+</tt></small></td>
+</table></center><p><b>Names and meanings of system error codes</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_ErrnoId<br>
+ Tcl_ErrnoMsg<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetErrno<br>
+ Tcl_SetErrno<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_SignalId<br>
+ Tcl_SignalMsg<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>General Operating System Calls</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Access<br>
+ Tcl_Chdir<br>
+ Tcl_GetCwd<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetHostName<br>
+ Tcl_GetNameOfExecutable<br>
+ Tcl_Sleep<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Stat<br>
+</tt></small></td>
+</table></center><p><b>String Manipulation And Comparison</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Concat<br>
+ Tcl_Merge<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_SplitList<br>
+ Tcl_StringCaseMatch<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_StringMatch<br>
+</tt></small></td>
+</table></center><p><b>Dynamically Resizable Strings</b></p>
+<center><table width="90%"><tr>
+<td width="49%" valign="top"><small><tt>
+ Tcl_DStringAppend<br>
+ Tcl_DStringAppendElement<br>
+ Tcl_DStringEndSublist<br>
+ Tcl_DStringInit<br>
+ Tcl_DStringLength<br>
+</tt></small></td>
+<td width="49%" valign="top"><small><tt>
+ Tcl_DStringResult<br>
+ Tcl_DStringSetLength<br>
+ Tcl_DStringStartSublist<br>
+ Tcl_DStringValue<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>Event Handlers</b></p>
+<center><table width="90%"><tr>
+<td width="49%" valign="top"><small><tt>
+ Tcl_CancelIdleCall<br>
+ Tcl_CreateChannelHandler<br>
+ Tcl_CreateTimerHandler<br>
+ Tcl_DeleteChannelHandler<br>
+</tt></small></td>
+<td width="49%" valign="top"><small><tt>
+ Tcl_DeleteTimerHandler<br>
+ Tcl_DoOneEvent<br>
+ Tcl_DoWhenIdle<br>
+</tt></small></td>
+</table></center><p><b>Functions For Reading And Writing Tcl Variables</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetVar<br>
+ Tcl_GetVar2<br>
+ Tcl_LinkVar<br>
+ Tcl_SetVar<br>
+ Tcl_SetVar2<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_TraceVar<br>
+ Tcl_TraceVar2<br>
+ Tcl_UnlinkVar<br>
+ Tcl_UnsetVar<br>
+ Tcl_UnsetVar2<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_UntraceVar<br>
+ Tcl_UntraceVar2<br>
+ Tcl_UpdateLinkedVar<br>
+</tt></small></td>
+</table></center><p><b>Functions For Executing Tcl Code</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Eval<br>
+ Tcl_EvalFile<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_EvalObj<br>
+ Tcl_GlobalEval<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GlobalEvalObj<br>
+ Tcl_VarEval<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>Functions For Dealing With Unicode</b></p>
+<center><table width="90%"><tr>
+<td width="49%" valign="top"><small><tt>
+ Tcl_NumUtfChars<br>
+ Tcl_UniCharAtIndex<br>
+ Tcl_UniCharIsAlnum<br>
+ Tcl_UniCharIsAlpha<br>
+ Tcl_UniCharIsControl<br>
+ Tcl_UniCharIsDigit<br>
+ Tcl_UniCharIsGraph<br>
+ Tcl_UniCharIsLower<br>
+ Tcl_UniCharIsPrint<br>
+ Tcl_UniCharIsPunct<br>
+ Tcl_UniCharIsSpace<br>
+ Tcl_UniCharIsUpper<br>
+ Tcl_UniCharIsWordChar<br>
+ Tcl_UniCharLen<br>
+ Tcl_UniCharNcmp<br>
+ Tcl_UniCharToLower<br>
+ Tcl_UniCharToTitle<br>
+</tt></small></td>
+<td width="49%" valign="top"><small><tt>
+ Tcl_UniCharToUpper<br>
+ Tcl_UniCharToUtf<br>
+ Tcl_UniCharToUtfDString<br>
+ Tcl_UtfAtIndex<br>
+ Tcl_UtfBackslash<br>
+ Tcl_UtfCharComplete<br>
+ Tcl_UtfFindFirst<br>
+ Tcl_UtfFindLast<br>
+ Tcl_UtfNcasecmp<br>
+ Tcl_UtfNcmp<br>
+ Tcl_UtfNext<br>
+ Tcl_UtfPrev<br>
+ Tcl_UtfToLower<br>
+ Tcl_UtfToTitle<br>
+ Tcl_UtfToUniChar<br>
+ Tcl_UtfToUniCharDString<br>
+ Tcl_UtfToUpper<br>
+</tt></small></td>
+</table></center>
+ <p><b>Functions For Dealing With Tcl_Objs</b></p>
+ <blockquote><i>Too numerous to list...</i></blockquote></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Documentation Of The Tcl API</h2>
+<p><ul><li>Tcl comes with excellent man pages</li></ul><ul><li>"Use the source, Luke"</li></ul><ul><li>See <tt>tclDecl.h</tt> for a list of API functions</li></ul><ul><li>The header comments on the implementation of API functions usually
+ gives a good description of what the function does and how it should
+ be used.</li></ul><ul><li>Most API functions are used within Tcl and Tk. Use grep to locate
+ examples.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Initialization Scripts</h2>
+<p><ul><li>Run the mini TCLSH implemented above and execute the <tt>parray</tt> command</li></ul><ul><li>It doesn't work! What's wrong? </p></li></li></ul><ul><li><tt>parray</tt> is really a Tcl proc that is read in when the
+ interpreter is initialized. </p></li></li></ul><ul><li><tt>parray</tt> (and several other commands) are stored in a
+ handful of &quot;Initialization Scripts&quot; </p></li></li></ul><ul><li>All the initialization scripts are stored in the
+ &quot;Tcl Library&quot; - a directory on the host
+ computer. </p></li></li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Invoke the Tcl_Init() function to locate and read the
+ Tcl initialization scripts.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>Tcl_Init()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Init(interp);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Locate and read the initialization scripts</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Call&nbsp;Tcl_CreateCommand()?&nbsp;*/<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But Tcl_Init() can fail. We need to check its return value...</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>Tcl_Init()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_Init(interp)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,"Tcl_Init()&nbsp;failed:&nbsp;¸üÿ¿PX¶",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tcl_GetStringResult(interp));<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Print error message if Tcl_Init() fails</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Call&nbsp;Tcl_CreateCommand()?&nbsp;*/<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But now the program is not standalone.</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">How <tt>Tcl_Init()</tt> Works</h2>
+<p><ul><li>Computes the value of variable <tt>tcl_libPath</tt>.</li></ul><ul><li>Invokes the procedure named &quot;<tt>tclInit</tt>&quot;</li></ul><ul><li>A default <tt>tclInit</tt> procedure is built into Tcl.
+ You can define an alternative <tt>tclInit</tt> procedure
+ prior to calling <tt>Tcl_Init()</tt>.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The Default <tt>initTcl</tt> Procedure</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>set&nbsp;errors&nbsp;{}<br>
+set&nbsp;dirs&nbsp;{}<br>
+if&nbsp;{[info&nbsp;exists&nbsp;tcl_library]}&nbsp;{<br>
+&nbsp;&nbsp;lappend&nbsp;dirs&nbsp;$tcl_library<br>
+}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;if&nbsp;{[info&nbsp;exists&nbsp;env(TCL_LIBRARY)]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;lappend&nbsp;dirs&nbsp;$env(TCL_LIBRARY)<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;lappend&nbsp;dirs&nbsp;$tclDefaultLibrary<br>
+&nbsp;&nbsp;unset&nbsp;tclDefaultLibrary<br>
+&nbsp;&nbsp;set&nbsp;dirs&nbsp;[concat&nbsp;$dirs&nbsp;$tcl_libPath]<br>
+}<br>
+foreach&nbsp;i&nbsp;$dirs&nbsp;{<br>
+&nbsp;&nbsp;set&nbsp;tcl_library&nbsp;$i<br>
+&nbsp;&nbsp;set&nbsp;tclfile&nbsp;[file&nbsp;join&nbsp;$i&nbsp;init.tcl]<br>
+&nbsp;&nbsp;if&nbsp;{[file&nbsp;exists&nbsp;$tclfile]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{![catch&nbsp;{uplevel&nbsp;#0&nbsp;[list&nbsp;source&nbsp;$tclfile]}&nbsp;msg]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;errors&nbsp;"$tclfile:&nbsp;$msg\n$errorInfo\n"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;}<br>
+}<br>
+error&nbsp;"Can't&nbsp;find&nbsp;a&nbsp;usable&nbsp;init.tcl&nbsp;..."</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The Default Initialization Sequence</h2>
+<p><ul><li>The <tt>tclInit</tt> procedure locates and sources the <tt>init.tcl</tt>
+ script. The directory that contains <tt>init.tcl</tt> is stored in
+ the <tt>tcl_library</tt> variable.</li></ul><ul><li>The <tt>init.tcl</tt> script creates an <tt>unknown</tt> procedure.
+ The <tt>unknown</tt> procedure will run whenever Tcl encounters an
+ unknown command.</li></ul><ul><li>The <tt>unknown</tt> procedure consults the file <tt>tclIndex</tt> in the
+ <tt>tcl_library</tt> directory to see if the command is defined by one of
+ the initialization scripts.</li></ul><ul><li>The <tt>unknown</tt> procedure sources any needed initialization scripts
+ and retries the command.</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Commands defined in the initialization scripts are loaded
+ on demand.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Standalone Initialization Techniques</h2>
+<p><p><b>Manually execute all initialization scripts</b></p>
+<ul><li>Convert all initialization scripts into C strings and
+ put them in the executable.</li></ul><ul><li>Call <tt>Tcl_Eval()</tt> on each initialization script and omit the
+ call to <tt>Tcl_Init()</tt></li></ul><ul><li>Or, redefine <tt>tclInit</tt> so that it does not attempt to source
+ <tt>init.tcl</tt> then call <tt>Tcl_Eval()</tt> on each initialization
+ script after <tt>Tcl_Init()</tt> returns.</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>This approach is not recommended</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Standalone Initialization Techniques</h2>
+<p><p><b>Redefining the builtin <tt>source</tt> command</b></p>
+<ul><li>Convert all initialization scripts into C strings and
+ put them in the executable.</li></ul><ul><li>Create a new <tt>source</tt> command that
+ calls <tt>Tcl_Eval()</tt> on the appropriate built-in string
+ instead of reading from the disk.</li></ul><ul><li>Read from disk if the named file is not one that is built in.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Redefining <tt>source</tt></h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zInitTcl[]&nbsp;=&nbsp;"...";<br>
+static&nbsp;char&nbsp;zParrayTcl[]&nbsp;=&nbsp;"...";</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Scripts <tt>init.tcl</tt> and <tt>parray.tcl</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;NewSourceCmd(TCLARGS){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;!strcmp(argv[1],"/builtin/init.tcl")&nbsp;)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;Tcl_Eval(interp,&nbsp;zInitTcl);<br>
+&nbsp;&nbsp;if(&nbsp;!strcmp(argv[1],"/builtin/parray.tcl")&nbsp;)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;Tcl_Eval(interp,&nbsp;zParrayTcl);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Call <tt>Tcl_Eval()</tt> on builtin strings if the names match</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;Tcl_EvalFile(interp,&nbsp;argv[1]);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Call <tt>Tcl_EvalFile()</tt> if no match</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;setenv("TCL_LIBRARY","/builtin");</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Causes <tt>tclInit</tt> to look for <tt>init.tcl</tt> in <tt>/builtin</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_CreateCommand(interp,&nbsp;"source",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewSourceCmd,&nbsp;0,&nbsp;0);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Redefine <tt>source</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Redefining <tt>source</tt></h2>
+<p><ul><li>This approach works for all versions of Tcl and Tk.</li></ul><ul><li>Also need to redefine the "<tt>file exists</tt>" Tcl command since it
+ too is used by <tt>tclInit</tt>.</li></ul><ul><li>To verify that the program is really standalone, remove the call
+ to <tt>Tcl_EvalFile()</tt>.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Standalone Initialization Techniques</h2>
+<p><p><b>Use the <tt>Tcl</tt>*<tt>InsertProc()</tt> functions</b></p>
+<ul><li>Three routines that overload basic file I/O operations:
+ <ul>
+ <li> <tt>TclStatInsertProc()</tt> </li>
+ <li> <tt>TclAccessInsertProc()</tt> </li>
+ <li> <tt>TclOpenFileChannelInsertProc()</tt> </li>
+ </ul></li></ul><ul><li>Allows us to implement a virtual filesystem that overlays the
+ real filesystem.</li></ul><ul><li>The virtual filesystem contains all the initialization scripts
+ as compiled-in strings. The initialization scripts look like
+ they are resident on disk even though they are built in.</li></ul><ul><li>These functions first appeared in Tcl8.0.3.
+ Presumably to support TclPro Wrapper.</li></ul><ul><li>The only documentation is comments on the code.
+ See the Tcl source file <tt>generic/tclIOUtil.c</tt></li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclStatInsertProc()</tt> Function</h2>
+<p><ul><li>Sole argument is a pointer to a function whose interface is the
+ same as <tt>stat()</tt></li></ul><ul><li>Functions are stacked. Tcl tries each <tt>stat</tt> function on the
+ list, beginning with the most recently inserted, until one succeeds.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclStatInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tclInt.h></tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Rather than <tt>&lt;tcl.h&gt;</tt>!</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+static&nbsp;int<br>
+BltinFileStat(char&nbsp;*path,struct&nbsp;stat&nbsp;*buf){<br>
+&nbsp;&nbsp;char&nbsp;*zData;<br>
+&nbsp;&nbsp;int&nbsp;nData;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;zData&nbsp;=&nbsp;FindBuiltinFile(path,&nbsp;0,&nbsp;&amp;nData);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Check if <tt>path</tt> is a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;zData==0&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;-1;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Fail if <tt>path</tt> is not a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;memset(buf,&nbsp;0,&nbsp;sizeof(*buf));<br>
+&nbsp;&nbsp;buf->st_mode&nbsp;=&nbsp;0400;<br>
+&nbsp;&nbsp;buf->st_size&nbsp;=&nbsp;nData;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Success if it is builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;TclStatInsertProc(BltinFileStat);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Register new <tt>stat</tt> function</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();<br>
+&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclAccessInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tclInt.h></tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Rather than <tt>&lt;tcl.h&gt;</tt>!</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+/*&nbsp;BltinFileStat()&nbsp;not&nbsp;shown...&nbsp;*/<br>
+&nbsp;<br>
+static&nbsp;int<br>
+BltinFileAccess(char&nbsp;*path,&nbsp;int&nbsp;mode){<br>
+&nbsp;&nbsp;char&nbsp;*zData;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;mode&nbsp;&amp;&nbsp;3&nbsp;)&nbsp;return&nbsp;-1;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">All builtins are read-only</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;zData&nbsp;=&nbsp;FindBuiltinFile(path,&nbsp;0,&nbsp;&amp;nData);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Check if <tt>path</tt> is a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;zData==0&nbsp;)&nbsp;return&nbsp;-1;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Fail if <tt>path</tt> is not a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Success if it is builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;TclStatInsertProc(BltinFileStat);<br>
+&nbsp;&nbsp;TclAccessInsertProc(BltinFileAccess);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Register new <tt>stat</tt> and <tt>access</tt> functions</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();<br>
+&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclOpenFileChannelInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;Tcl_Channel&nbsp;BuiltinFileOpen(<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,&nbsp;&nbsp;&nbsp;/*&nbsp;The&nbsp;TCL&nbsp;interpreter&nbsp;doing&nbsp;the&nbsp;open&nbsp;*/<br>
+&nbsp;&nbsp;char&nbsp;*zFilename,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Name&nbsp;of&nbsp;the&nbsp;file&nbsp;to&nbsp;open&nbsp;*/<br>
+&nbsp;&nbsp;char&nbsp;*modeString,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Mode&nbsp;string&nbsp;for&nbsp;the&nbsp;open&nbsp;(ignored)&nbsp;*/<br>
+&nbsp;&nbsp;int&nbsp;permissions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Permissions&nbsp;for&nbsp;a&nbsp;newly&nbsp;created&nbsp;file&nbsp;(ignored)&nbsp;*/<br>
+){<br>
+&nbsp;&nbsp;char&nbsp;*zData;<br>
+&nbsp;&nbsp;BuiltinFileStruct&nbsp;*p;<br>
+&nbsp;&nbsp;int&nbsp;nData;<br>
+&nbsp;&nbsp;char&nbsp;zName[50];<br>
+&nbsp;&nbsp;Tcl_Channel&nbsp;chan;<br>
+&nbsp;&nbsp;static&nbsp;int&nbsp;count&nbsp;=&nbsp;1;<br>
+&nbsp;<br>
+&nbsp;&nbsp;zData&nbsp;=&nbsp;FindBuiltinFile(zFilename,&nbsp;1,&nbsp;&amp;nData);<br>
+&nbsp;&nbsp;if(&nbsp;zData==0&nbsp;)&nbsp;return&nbsp;NULL;<br>
+&nbsp;&nbsp;p&nbsp;=&nbsp;(BuiltinFileStruct*)Tcl_Alloc(&nbsp;sizeof(BuiltinFileStruct)&nbsp;);<br>
+&nbsp;&nbsp;if(&nbsp;p==0&nbsp;)&nbsp;return&nbsp;NULL;<br>
+&nbsp;&nbsp;p->zData&nbsp;=&nbsp;zData;<br>
+&nbsp;&nbsp;p->nData&nbsp;=&nbsp;nData;<br>
+&nbsp;&nbsp;p->cursor&nbsp;=&nbsp;0;<br>
+&nbsp;&nbsp;sprintf(zName,"etbi_bffffc7c_8049b04",((int)BuiltinFileOpen)>>12,count++);<br>
+&nbsp;&nbsp;chan&nbsp;=&nbsp;Tcl_CreateChannel(&amp;builtinChannelType,&nbsp;zName,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(ClientData)p,&nbsp;TCL_READABLE);<br>
+&nbsp;&nbsp;return&nbsp;chan;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclOpenFileChannelInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;Tcl_ChannelType&nbsp;builtinChannelType&nbsp;=&nbsp;{<br>
+&nbsp;&nbsp;"builtin",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Type&nbsp;name.&nbsp;*/<br>
+&nbsp;&nbsp;NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Always&nbsp;non-blocking.*/<br>
+&nbsp;&nbsp;BuiltinFileClose,&nbsp;&nbsp;&nbsp;/*&nbsp;Close&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileInput,&nbsp;&nbsp;&nbsp;/*&nbsp;Input&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileOutput,&nbsp;&nbsp;/*&nbsp;Output&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileSeek,&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Seek&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Set&nbsp;option&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Get&nbsp;option&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileWatch,&nbsp;&nbsp;&nbsp;/*&nbsp;Watch&nbsp;for&nbsp;events&nbsp;on&nbsp;console.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileHandle,&nbsp;&nbsp;/*&nbsp;Get&nbsp;a&nbsp;handle&nbsp;from&nbsp;the&nbsp;device.&nbsp;*/<br>
+};</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p>
+ <p>For additional information see:</p>
+ <ul>
+ <li>The man page for <tt>Tcl_CreateChannel()</tt></li>
+ <li>Tk source code file <tt>generic/tkConsole.c</tt></li>
+ </ul>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Initializing Tk</h2>
+<p><ul><li>All the same initialization script issues as Tcl</li></ul><ul><li>Tk initialization scripts are in a different directory
+ than the Tcl initialization scripts - the "Tk Library"</li></ul><ul><li>Call <tt>Tk_Init()</tt> after <tt>Tcl_Init()</tt></li></ul><ul><li>Must have an event loop or Tk will not work!</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Implementing An Event Loop</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>button&nbsp;.b&nbsp;-text&nbsp;Hello&nbsp;-command&nbsp;exit<br>
+pack&nbsp;.b</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Create a Tk interface</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>bind&nbsp;.&nbsp;&lt;Destroy>&nbsp;{<br>
+&nbsp;&nbsp;if&nbsp;{![winfo&nbsp;exists&nbsp;.]}&nbsp;exit<br>
+}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Close the application when the main window
+ is destroyed</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>while&nbsp;1&nbsp;{vwait&nbsp;forever}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The event loop</td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Tk</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tk.h><br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zHello[]&nbsp;=&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The application code</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"button&nbsp;.b&nbsp;"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"-text&nbsp;{Hello,&nbsp;World}&nbsp;"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"-command&nbsp;exit\n"<br>
+&nbsp;&nbsp;"pack&nbsp;.b\n";<br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zEventLoop[]&nbsp;=</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The event loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"bind&nbsp;.&nbsp;&lt;Destroy>&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{![winfo&nbsp;exists&nbsp;.]}&nbsp;exit\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"while&nbsp;1&nbsp;{vwait&nbsp;forever}\n";<br>
+&nbsp;<br>
+<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tk_Init(interp);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">We really should check the return values of the init functions...</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zHello);</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zEventLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The event loop never returns</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*NOTREACHED*/<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Compiling "Hello, World!" For Tk</h2>
+<p><p><b>Unix:</b></p>
+ <blockquote><pre>
+ $ gcc hello.c -ltk -L/usr/X11R6/lib \
+ -lX11 -ltcl -lm -ldl
+ $ ./a.out</pre></blockquote>
+
+ <p><b>Windows using Cygwin:</b></p>
+ <blockquote><pre>
+ C:> gcc hello.c -mwindows -ltk80 -ltcl80 -lm
+ C:> a.exe</pre></blockquote>
+
+ <p><b>Windows using Mingw32:</b></p>
+ <blockquote><pre>
+ C:> gcc -mno-cygwin hello.c -mwindows \
+ -ltk82 -ltcl82 -lm
+ C:> a.exe</pre></blockquote></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Making The Program Standalone</h2>
+<p><p>To make a Tcl application standalone you have to convert the following
+ initialization scripts to C strings and compile them into the
+ executable:</p>
+ <table><tr>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;auto.tcl<br>
+ &nbsp;&nbsp;history.tcl<br>
+ &nbsp;&nbsp;init.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;ldAout.tcl<br>
+ &nbsp;&nbsp;package.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;parray.tcl<br>
+ &nbsp;&nbsp;safe.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;tclIndex<br>
+ &nbsp;&nbsp;word.tcl
+ </tt></td>
+ </tr></table>
+
+ <p>To make a Tk application standalone requires these additional
+ initialization scripts from the Tk Library:</p>
+ <table><tr>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;bgerror.tcl<br>
+ &nbsp;&nbsp;button.tcl<br>
+ &nbsp;&nbsp;clrpick.tcl<br>
+ &nbsp;&nbsp;comdlg.tcl<br>
+ &nbsp;&nbsp;console.tcl<br>
+ &nbsp;&nbsp;dialog.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;entry.tcl<br>
+ &nbsp;&nbsp;focus.tcl<br>
+ &nbsp;&nbsp;listbox.tcl<br>
+ &nbsp;&nbsp;menu.tcl<br>
+ &nbsp;&nbsp;msgbox.tcl<br>
+ &nbsp;&nbsp;optMenu.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;palette.tcl<br>
+ &nbsp;&nbsp;safetk.tcl<br>
+ &nbsp;&nbsp;scale.tcl<br>
+ &nbsp;&nbsp;scrlbar.tcl<br>
+ &nbsp;&nbsp;tclIndex<br>
+ &nbsp;&nbsp;tearoff.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;text.tcl<br>
+ &nbsp;&nbsp;tk.tcl<br>
+ &nbsp;&nbsp;tkfbox.tcl<br>
+ &nbsp;&nbsp;xmfbox.tcl
+ </tt></td>
+ </tr></table>
+
+ <p>Total of about 13K lines and 400K bytes of text or 9K lines and
+ 250K bytes if you strip comments and leading spaces</p></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">A Review Of The Features We Want</h2>
+<p><ol type="A">
+ <li value="1">
+ Combine C/C++ with Tcl/Tk into a single executable.</dd>
+ </li></ol>
+
+ <ol type="A">
+ <li value="2">
+ The executable should be standalone. It must not depend
+ on files not normally found on the system.
+ </li></ol>
+
+ <ol type="A">
+ <li value="3">
+ It should be difficult for end users to alter the program
+ (and introduce bugs).
+ </li></ol></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Available Programming Aids</h2>
+<p><p>Several tools are available. The chart below shows which tools
+ help achieve which objectives.</p>
+
+ <center><table border="2">
+ <tr>
+ <td></td>
+ <td colspan="3" align="center">
+ <b>Features The Tool Helps To Achieve</b></td>
+ </tr>
+ <tr>
+ <td align="center"><b>Tool Name</b></td>
+ <td align="center">Mix C and Tcl</td>
+ <td align="center">Standalone</td>
+ <td align="center">Hide Source</td>
+ </tr>
+ <tr>
+ <td>SWIG</td>
+ <td align="center"><img src="image6"></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td>TclPro Wrapper</td>
+ <td>&nbsp;</td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ </tr>
+ <tr>
+ <td>FreeWrap</td>
+ <td>&nbsp;</td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ </tr>
+ <tr>
+ <td>Wrap</td>
+ <td>&nbsp;</td>
+ <td align="center"><img src="image6"></td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td>mktclapp</td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ </tr>
+ </table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">SWIG</h2>
+<table><tr><td valign="top"><img src="image7"></td>
+<td valign="top"><p><ul><li>Creates an interface between an existing C/C++ library and a high-level
+ programming language. Support for:
+ <ul>
+ <li> Tcl/Tk </li>
+ <li> Perl </li>
+ <li> Python </li>
+ <li> Java </li>
+ <li> Eiffel </li>
+ <li> Guile </li>
+ </ul></li></ul><ul><li>No changes required to C/C++ code. Can be used with legacy libraries.</li></ul><ul><li>Generates an extension, not a standalone binary</li></ul><ul><li>The tutorial on SWIG was yesterday afternoon.</li></ul><ul><li>http://www.swig.org/</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Wrapper Programs</h2>
+<table><tr><td valign="top"><img src="image8"></td>
+<td valign="top"><p><ul><li>Convert a pure Tcl/Tk program into a standalone binary</li></ul><ul><li>Several wrapper programs are available:
+ <ul>
+ <li> TclPro Wrapper - http://www.scriptics.com/ </li>
+ <li> FreeWrap - http://www.albany.net/~dlabelle/freewrap/freewrap.html </li>
+ <li> Wrap - http://members1.chello.nl/~j.nijtmans/wrap.html </li>
+ </ul></li></ul><ul><li>No C compiler required!</li></ul><ul><li>TclPro will convert Tcl script into bytecode so that it cannot be
+ easily read by the end user. FreeWrap encrypts the scripts.</li></ul><ul><li>FreeWrap uses compression on its executable.
+ Wrap uses compression on both the executable and on the bundled script files.</li></ul><ul><li>Usually include extensions like winico and/or BLT</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">mktclapp</h2>
+<table><tr><td valign="top"><img src="image9"></td>
+<td valign="top"><p><ul><li>Mix C/C++ with Tcl/Tk into a standalone binary</li></ul>
+<ul><li><tt>mktclapp</tt> generates an application initialization file
+ that contains Tcl scripts as strings and makes all necessary calls
+ to <tt>Tcl_Init</tt>, <tt>Tcl_CreateCommand</tt>,
+ <tt>Tcl</tt>*<tt>InsertProc</tt>, etc.</li></ul><ul><li>Features to make it easier to write new Tcl command in C</li></ul><ul><li><tt>xmktclapp.tcl</tt> provides a GUI interface to <tt>mktclapp</tt></li></ul><ul><li>http://www.hwaci.com/sw/mktclapp/</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<p><ul><li>Download <tt>mktclapp.c</tt> and <tt>xmktclapp.tcl</tt> from
+ http://www.hwaci.com/sw/mktclapp/</li></ul><ul><li>Compile <tt>mktclapp</tt>:
+ <blockquote><pre>
+ cc -o mktclapp mktclapp.c
+ </pre></blockquote></li></ul><ul><li>Create "Hello, World!" as a Tcl script in file <tt>hw.tcl</tt>:
+ <blockquote><pre>
+ button .b -text {Hello, World!} -command exit
+ pack .b
+ </pre></blockquote></li></ul><ul><li>Launch xmktclapp:
+ <blockquote><pre>
+ wish xmktclapp.tcl
+ </pre></blockquote></li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<table width="100%"><tr><td valign="top"><p><ul><li>Set "Command Line Input?" to "None"</li></ul><ul><li>Set "Standalone?" to "Yes"</li></ul><ul><li>Enter "<tt>hw.mta</tt>" for the Configuration File</li></ul><ul><li>Enter "<tt>hw.c</tt>" for the Output C File</li></ul></p></td>
+<td valign="top" align="right"><img src="image10"></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<table width="100%"><tr><td valign="top"><p><ul><li>Go to the "Tcl Scripts" page</li></ul><ul><li>Press "Insert" and add <tt>hw.tcl</tt> to the list of
+ Tcl scripts</li></ul><ul><li>Change the "Startup Script" to be <tt>hw.tcl</tt>.</li></ul><ul><li>Select File/Build and File/Exit</li></ul></p></td>
+<td valign="top" align="right"><img src="image11"></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<p><ul><li>Mktclapp generates <tt>hw.c</tt>.
+ Compile it something like this:
+ <pre>
+ cc hw.c -ltk -L/usr/X11R6/lib -lX11 -ltcl -lm -ldl
+ </pre></li></ul><ul><li>Or, if using Cygwin:
+ <pre>
+ gcc hw.c -mwindows -ltk80 -ltcl80 -lm
+ </pre></li></ul><ul><li>Or, if using Mingw32:
+ <pre>
+ gcc -mno-cygwin hw.c -mwindows -ltk82 -ltcl82 -lm
+ </pre></li></ul><ul><li>And you're done!</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding C Code To Your Program</h2>
+<p>Put the new C code in a new source file named "<tt>add.c</tt>"</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"hw.h"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Generated by mktclapp</td>
+</tr>
+<tr><td valign="center">
+<small><tt></tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;ET_COMMAND_add(ET_TCLARGS){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><tt>ET_TCLARGS</tt> is a macro defined in <tt>hw.h</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;int&nbsp;a,&nbsp;b;<br>
+&nbsp;&nbsp;char&nbsp;zResult[30];<br>
+&nbsp;&nbsp;a&nbsp;=&nbsp;atoi(argv[1]);<br>
+&nbsp;&nbsp;b&nbsp;=&nbsp;atoi(argv[2]);<br>
+&nbsp;&nbsp;sprintf(zResult,&nbsp;"-1073742724",&nbsp;a+b);<br>
+&nbsp;&nbsp;Tcl_SetResult(interp,&nbsp;zResult,&nbsp;TCL_VOLATILE);<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding C Code To Your Program</h2>
+<table width="100%"><tr><td valign="top"><p><ul><li>Go to the "C/C++ Modules" page of xmktclapp.tcl</li></ul>
+<ul><li>Press "Insert" and add <tt>add.c</tt> to the list of
+ C/C++ modules</p></li></ul></li></ul><ul><li>Select File/Build and File/Exit</li></ul></p></td>
+<td valign="top" align="right"><img src="image12"></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding C Code To Your Program</h2>
+<p><ul><li>Compile as follows:
+ <pre>
+ cc add.c hw.c -ltk -L/usr/X11R6/lib -ltcl -lm -ldl
+ </pre></li></ul><ul><li>Or construct a Makefile that compiles <tt>add.c</tt> into <tt>add.o</tt>
+ and <tt>hw.c</tt> into <tt>hw.o</tt> and then links them.</li></ul><ul><li>Compile the same way for Windows except use the usual Windows
+ libraries and options...</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Don't have to worry with <tt>Tcl_CreateCommand()</tt> - Mktclapp takes
+ care of that automatically.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Checking Parameters In The <tt>add</tt> Command</h2>
+<p>Modify <tt>add.c</tt> to insure the <tt>add</tt> command
+ is called with exactly two integer arguments</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"hw.h"<br>
+&nbsp;<br>
+int&nbsp;ET_COMMAND_add(ET_TCLARGS){<br>
+&nbsp;&nbsp;int&nbsp;a,&nbsp;b;<br>
+&nbsp;&nbsp;char&nbsp;zResult[30];</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;argc!=3&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_AppendResult(interp,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"wrong&nbsp;#&nbsp;args:&nbsp;should&nbsp;be:&nbsp;\"",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;argv[0],&nbsp;"&nbsp;VALUE&nbsp;VALUE\"",&nbsp;0);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Report an error if there are not exactly
+ 2 arguments</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[1],&nbsp;&amp;a)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Report an error if the first argument is
+ not an integer</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[2],&nbsp;&amp;b)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Do the same for the second argument</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;sprintf(zResult,&nbsp;"-1073742724",&nbsp;a+b);<br>
+&nbsp;&nbsp;Tcl_SetResult(interp,&nbsp;zResult,&nbsp;TCL_VOLATILE);<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Using The Tcl_Obj Interface</h2>
+<p>In the file <tt>objadd.c</tt> put this code:</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"hw.h"</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;ET_OBJCOMMAND_add2(ET_OBJARGS){<br>
+&nbsp;&nbsp;int&nbsp;a,&nbsp;b;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Use "<tt>ET_OBJCOMMAND</tt>" instead of "<tt>ET_COMMAND</tt>" and
+ "<tt>ET_OBJARGS</tt>" instead of "<tt>ET_TCLARGS</tt>"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;objc!=3&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_WrongNumArgs(interp,&nbsp;1,&nbsp;objv,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"number&nbsp;number");<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">A special routine for "wrong # args" error</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_GetIntFromObj(interp,&nbsp;objv[1],&nbsp;&amp;a)&nbsp;){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Instead of <tt>Tcl_GetInt</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;if(&nbsp;Tcl_GetIntFromObj(interp,&nbsp;objv[2],&nbsp;&amp;b)&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_SetIntObj(Tcl_GetObjResult(interp),&nbsp;a+b);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Result stored as integer, not a string</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Speed Of Tcl_Obj Versus "char*" Interfaces</h2>
+<p><ul><li>Compile both <tt>add</tt> and <tt>add2</tt> into the same executable.</li></ul><ul><li>Compare their speeds:
+ <pre>
+ time {add 123456 654321} 10000
+ <font color="blue">26 microseconds per iteration</font>
+ time {add2 123456 654321} 10000
+ <font color="blue">4 microseconds per iteration</font>
+ </pre></li></ul><ul><li>The Tcl_Obj version is 650 faster!</li></ul><ul><li>Replace the addition with a "real" computation that takes
+ 10 milliseconds.</li></ul><ul><li>Now the Tcl_Obj version is only 0.2 faster!</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>In many real-world problems, the Tcl_Obj interface has no noticeable
+ speed advantage over the string interface.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">More About Built-in Tcl Scripts</h2>
+<table><tr><td valign="top"><img src="image11"></td>
+<td valign="top"><p><ul><li>Comments and leading white-space are removed from the
+ script by default. Use the "Don't Strip Comments"
+ button to change this.</li></ul><ul><li>The file name must exactly match the name that is
+ used by the <tt>source</tt> command.</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Locations Of Libraries</h2>
+<table><tr><td valign="top"><img src="image13"></td>
+<td valign="top"><p><ul><li>Tells mktclapp where to look for script libraries.</li></ul><ul><li>All Tcl scripts in the indicated directories are
+ compiled into the <tt>appinit.c</tt> file.</li></ul><ul><li>Comments and extra white-space are removed.
+ There is no way to turn this off.</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Built-in Binary Data Files</h2>
+<table><tr><td valign="top"><img src="image14"></td>
+<td valign="top"><p><ul><li>Arbitrary files become part of the virtual filesystem</li></ul><ul><li>No comment or white-space removal is attempted</li></ul><ul><li>Useful for images or other binary data</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">New Commands In Namespaces</h2>
+<p>Two underscores (__) are replaced by two colons (::) in
+ command names, thus giving the ability to define new commands
+ in a namespace</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;hw.h></tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;ET_COMMAND_adder__add(ET_TCLARGS){<br>
+&nbsp;&nbsp;int&nbsp;a,&nbsp;b;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Creates the Tcl command called "<tt>adder::add</tt>"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;char&nbsp;*zResult[30];<br>
+&nbsp;&nbsp;if(&nbsp;argc!=3&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_AppendResult(interp,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"wrong&nbsp;#&nbsp;args:&nbsp;should&nbsp;be:&nbsp;\"",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;argv[0],&nbsp;"&nbsp;VALUE&nbsp;VALUE\"",&nbsp;0);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[1],&nbsp;&amp;a)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[1],&nbsp;&amp;b)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;sprintf(zResult,&nbsp;"-1073742724",&nbsp;a+b);<br>
+&nbsp;&nbsp;Tcl_SetResult(interp,&nbsp;zResult,&nbsp;TCL_VOLATILE);<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding Your Own <tt>main()</tt></h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;/*&nbsp;Application&nbsp;specific&nbsp;initialization&nbsp;*/</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Never returns!</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*NOTREACHED*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>The "Autofork" feature is disabled if you supply your own <tt>main()</tt></b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Initializing The Tcl Interpreter</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;counter&nbsp;=&nbsp;0;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);<br>
+&nbsp;&nbsp;&nbsp;/*NOTREACHED*/<br>
+&nbsp;&nbsp;&nbsp;return&nbsp;0;<br>
+}<br>
+&nbsp;<br>
+int&nbsp;Et_AppInit(Tcl_Interp&nbsp;*interp){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Blt_Init(Interp)&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Example: Initialize an extension</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_LinkVar(interp,&nbsp;"counter",&nbsp;&amp;counter,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TCL_LINK_INT);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Or link a C variable to a Tcl variable</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Return TCL_OK if successful</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Writing Your Own Event Loop</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>void&nbsp;Et_CustomMainLoop(Tcl_Interp&nbsp;*interp){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Replaces the default event loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Ex: Return without handling any events.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">This now returns after initializing Tcl</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Application&nbsp;code&nbsp;here&nbsp;*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Writing Your Own Event Loop</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+void&nbsp;Et_CustomMainLoop(Tcl_Interp&nbsp;*interp){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;for(;;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Other&nbsp;processing...&nbsp;*/<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Intermix processing and event handling</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Never returns</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*NOTREACHED*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Mktclapp Initialization Sequence</h2>
+<p><ul><li>Initialization starts when the <tt>Et_Init()</tt>
+ function is called either by client code or by
+ the <tt>main()</tt> that mktclapp generates</li></ul><ul><li>Create the main Tcl interpreter</li></ul><ul><li>Construct the virtual filesystem overlay by redefining
+ the <tt>source</tt> command and by using the
+ <tt>Tcl</tt>*<tt>InsertProc()</tt> functions</li></ul><ul><li>Call <tt>Et_PreInit()</tt> if the client defines it</li></ul><ul><li>Call <tt>Tcl_Init()</tt> and <tt>Tk_Init()</tt></li></ul><ul><li>Call <tt>Tcl_CreateCommand()</tt> and <tt>Tcl_CreateObjCommand()</tt>
+ for every <tt>ET_COMMAND_</tt>* and <tt>ET_OBJCOMMAND_</tt>* function
+ in the client code</li></ul><ul><li>Call <tt>Et_AppInit()</tt> if the client defines it</li></ul><ul><li>Run the main Tcl script if there is one</li></ul><ul><li>Call <tt>Et_CustomMainLoop()</tt> if defined by client code or
+ else run the built-in event loop</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p><ul><li>Use one of the built-in evaluation functions:
+ <center><table width="80%">
+ <tr><td valign="top" width="50%"><ul>
+ <li> Tcl_Eval() </li>
+ <li> Tcl_VarEval() </li>
+ <li> Tcl_EvalFile() </li>
+ <li> Tcl_GlobalEval() </li>
+ </ul></td>
+ <td valign="top" width="50%"><ul>
+ <li> Tcl_EvalObj() </li>
+ <li> Tcl_GlobalEvalObj() </li>
+ </ul></td></tr>
+ </table></center></li></ul><ul><li>Mktclapp provides evaluation functions with variable argument
+ lists as in <tt>printf()</tt>:
+ <ul>
+ <li> Et_EvalF() </li>
+ <li> Et_GlobalEvalF() </li>
+ </ul></li></ul><ul><li>Mktclapp provides a global variable <tt>Et_Interp</tt> which is
+ a pointer to the main interpreter</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p>Example: A C function that pops up an error message dialog box</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"appinit.h"<br>
+&nbsp;<br>
+void&nbsp;ErrMsg(char&nbsp;*zMsg){<br>
+&nbsp;&nbsp;Tcl_SetVar(Et_Interp,&nbsp;"zMsg",&nbsp;zMsg,&nbsp;TCL_GLOBAL_ONLY);<br>
+&nbsp;&nbsp;Tcl_GlobalEval(Et_Interp,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"tk_messageBox&nbsp;-icon&nbsp;error&nbsp;-msg&nbsp;$zMsg&nbsp;-type&nbsp;ok");<br>
+&nbsp;&nbsp;Tcl_UnsetVar(Et_Interp,&nbsp;"zMsg",&nbsp;TCL_GLOBAL_ONLY);<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p>The same C function implemented using <tt>Et_EvalF()</tt> instead
+ of <tt>Tcl_GlobalEval()</tt></p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"appinit.h"<br>
+&nbsp;<br>
+void&nbsp;ErrMsg(char&nbsp;*zMsg){<br>
+&nbsp;&nbsp;Et_EvalF(Et_Interp,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"tk_messageBox&nbsp;-icon&nbsp;error&nbsp;-msg&nbsp;{¸üÿ¿PX¶}&nbsp;-type&nbsp;ok",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;zMsg);<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p>
+ <ul><li>
+ Suppose the function is called as follows:
+ <blockquote>
+ <tt>ErrMsg("Syntax error near \"}\"");</tt>
+ </blockquote>
+ </li></ul>
+
+ <ul><li>
+ The command that gets executed is:
+ <pre>
+ tk_messageBox -icon error -msg \
+ {Syntax error near "}"} -type ok
+ </pre>
+ </li></ul>
+
+ <ul><li>
+ But this is an ill-formed Tcl command!
+ </li></ul>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p>Use the "<tt></tt>" format to generate a quoted string</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"appinit.h"<br>
+&nbsp;<br>
+void&nbsp;ErrMsg(char&nbsp;*zMsg){<br>
+&nbsp;&nbsp;Et_EvalF(Et_Interp,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"tk_messageBox&nbsp;-icon&nbsp;error&nbsp;-msg&nbsp;\"%\"&nbsp;-type&nbsp;ok",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;zMsg);<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><ul><li>The <tt></tt> puts a backslash before all characters that
+ are special to Tcl</li></ul><ul><li>The Tcl command becomes:
+ <pre>
+ tk_messageBox -icon error -msg \
+ "Syntax error near \"\}\"" -type ok
+ </pre></li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Other Functions Provided By Mktclapp</h2>
+<p><ul><li><tt>void Et_ResultF(Tcl_Interp*, ...);</tt></li></ul><ul><li><tt>char *Et_DStringAppendF(Tcl_DString*, ...);</tt></li></ul><ul><li><tt>int Et_AppendObjF(Tcl_Obj*, ...);</tt></li></ul><ul><li><tt>char *mprintf(const char *format, ...);<br>
+ char *vmprintf(const char *format, va_list);</tt></li></ul><ul><li><tt>void Et_NewBuiltinFile(char *filename, char *data, int amt);</tt></li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Operating Mktclapp From The Command Line</h2>
+<p><ul><li>Generate the <tt>appinit.h</tt> header file like this:
+ <blockquote>
+ <tt>mktclapp -header &gt;appinit.h</tt>
+ </blockquote></li></ul><ul><li>Generate the <tt>appinit.c</tt> file like this:
+ <blockquote>
+ <tt>mktclapp -f appinit.mta >appinit.c</tt>
+ </blockquote></li></ul><ul><li>The <tt>*.mta</tt> file is just a list of command-line options</li></ul><ul><li>Enter
+ <blockquote>
+ <tt>mktclapp -help</tt>
+ </blockquote>
+ to get a list of available options</li></ul><ul><li>Look at MTA files generated by xmktclapp.tcl for examples</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Format Of An MTA File</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#&nbsp;Configuration&nbsp;file&nbsp;generated&nbsp;by&nbsp;xmktclapp<br>
+#&nbsp;Hand&nbsp;editing&nbsp;is&nbsp;not&nbsp;recommended<br>
+#</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Comments begin with one #</td>
+</tr>
+<tr><td valign="center">
+<small><tt>##&nbsp;Autofork&nbsp;No<br>
+##&nbsp;CFile:add.c&nbsp;1<br>
+##&nbsp;CFile:objadd.c&nbsp;1<br>
+##&nbsp;CmdLine&nbsp;Console<br>
+##&nbsp;ConfigFile&nbsp;hw.mta<br>
+##&nbsp;Data:check.gif&nbsp;1<br>
+##&nbsp;MainScript&nbsp;hw.tcl<br>
+##&nbsp;Mode&nbsp;Tcl/Tk<br>
+##&nbsp;NoSource&nbsp;No<br>
+##&nbsp;OutputFile&nbsp;hw.c<br>
+##&nbsp;Shroud&nbsp;No<br>
+##&nbsp;Standalone&nbsp;Yes<br>
+##&nbsp;TclFile:hw.tcl&nbsp;1<br>
+##&nbsp;TclLib&nbsp;/usr/lib/tcl8.0<br>
+##&nbsp;TkLib&nbsp;/usr/lib/tk8.0</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Lines beginning with two #s are used
+ by xmktclapp.tcl and ignored by mktclapp</td>
+</tr>
+<tr><td valign="center">
+<small><tt>-console<br>
+-main-script&nbsp;"hw.tcl"<br>
+-tcl-library&nbsp;"/usr/lib/tcl8.0"<br>
+-tk-library&nbsp;"/usr/lib/tk8.0"<br>
+"add.c"<br>
+"objadd.c"<br>
+-i&nbsp;"check.gif"<br>
+-strip-tcl&nbsp;"hw.tcl"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">All other lines are read by mktclapp and
+ ignored by xmktclapp.tcl</td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Summary</h2>
+<p><ul><li>Use Tcl for the things Tcl is good at and use C/C++ for the things that
+ C/C++ is good at</li></ul><ul><li>Use wrapper programs to make pure Tcl programs standalone</li></ul><ul><li>Use mktclapp to combine Tcl/Tk with C/C++ into a standalone</li></ul></p>
+<br clear="both"><p><hr></p>
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image1 b/ext/tk/sample/tkextlib/tkHTML/page4/image1
new file mode 100644
index 0000000000..da26d7092e
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image1
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image2 b/ext/tk/sample/tkextlib/tkHTML/page4/image2
new file mode 100644
index 0000000000..e176a96a55
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image2
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image3 b/ext/tk/sample/tkextlib/tkHTML/page4/image3
new file mode 100644
index 0000000000..e829d3712c
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image3
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image4 b/ext/tk/sample/tkextlib/tkHTML/page4/image4
new file mode 100644
index 0000000000..f14ea13547
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image4
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image5 b/ext/tk/sample/tkextlib/tkHTML/page4/image5
new file mode 100644
index 0000000000..4ef6277226
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image5
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image6 b/ext/tk/sample/tkextlib/tkHTML/page4/image6
new file mode 100644
index 0000000000..1adb261b40
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image6
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image7 b/ext/tk/sample/tkextlib/tkHTML/page4/image7
new file mode 100644
index 0000000000..ba0d26ec18
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image7
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image8 b/ext/tk/sample/tkextlib/tkHTML/page4/image8
new file mode 100644
index 0000000000..8b81d58e27
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image8
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/image9 b/ext/tk/sample/tkextlib/tkHTML/page4/image9
new file mode 100644
index 0000000000..f0a352f9d0
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/image9
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tkHTML/page4/index.html b/ext/tk/sample/tkextlib/tkHTML/page4/index.html
new file mode 100644
index 0000000000..c7bfde35a5
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/page4/index.html
@@ -0,0 +1,768 @@
+<!DOCTYPE HTML="HTML" PUBLIC="PUBLIC" "-//W3C//DTD=""-//W3C//DTD" HTML="HTML" 4.0="4.0" Transitional//EN"="Transitional//EN"">
+<HTML>
+<HEAD>
+<TITLE>[fm] welcome to freshmeat.net</TITLE>
+<STYLE TYPE="text/css"><!-- A:link {text-decoration: none}A:visited{text-decoration:none}A:active{text-decoration:none}--></STYLE>
+</HEAD>
+<BODY MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#336699" VLINK="#336699" ALINK="#336699">
+<BR><CENTER><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD WIDTH="1"><SCRIPT LANGUAGE="JAVASCRIPT">
+<!--
+now = new Date();
+tail = now.getTime();
+document.write("<IMG SRC='http://209.207.224.246/FreshMeat/Core/pc.gif?/index.php3," + tail + "' WIDTH=1 HEIGHT=1><BR>");
+//-->
+</SCRIPT>
+<NOSCRIPT>
+<IMG SRC="image1" WIDTH="1" HEIGHT="1"><BR>
+</NOSCRIPT></TD></TR></TABLE>
+<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD WIDTH="468"><SCRIPT LANGUAGE="JAVASCRIPT">
+<!--
+now = new Date();
+tail = now.getTime();
+AltText = "\"Please click here.\"";
+document.write("<A HREF='http://ads.freshmeat.net/cgi-bin/ad_click.pl?index,tsof0001en'>")
+document.write("<IMG SRC='http://ads.freshmeat.net/tsof0001en.gif?" + tail + "' WIDTH=468 HEIGHT=60 ALT=" + AltText + "></A><BR>");
+//-->
+</SCRIPT>
+<NOSCRIPT>
+<A HREF="http://ads.freshmeat.net/cgi-bin/ad_click.pl?index,tsof0001en"><IMG SRC="image2" WIDTH="468" HEIGHT="60" ALT="Please click here."></A><BR>
+</NOSCRIPT></TD></TR></TABLE>
+
+<TABLE CELLSPACING="0" CELLPADDING="2" BORDER="0" WIDTH="97%"><TR>
+<TD ALIGN="left" VALIGN="bottom"><A HREF="/"><IMG SRC="image3" BORDER="0" ALT="freshmeat.net" WIDTH="300" HEIGHT="65"></A></TD>
+<TD VALIGN="bottom" ALIGN="left" ROWSPAN="2"><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<FORM METHOD="get" ACTION="/search.php3">
+<SMALL>find: <INPUT TYPE="text" SIZE="15" NAME="query"></SMALL></FORM></FONT></TD>
+<TD ALIGN="right" VALIGN="bottom"><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<A HREF="http://www.linux.com"><FONT COLOR="#000000"><B><SMALL>linux.com partner</SMALL></B></FONT></A><BR>
+<TABLE CELLSPACING="0" CELLPADDING="1" BORDER="0" WIDTH="100%"><TR>
+<TD ALIGN="right"><SMALL><NOBR><FONT FACE="Lucida,Verdana,Helvetica,Arial"><B><A HREF="/">news</A> |<BR>
+<A HREF="/appindex/">appindex</A> |<BR>
+<A HREF="/editorials/">editorials</A> |</B></FONT></NOBR></SMALL></TD>
+<TD ALIGN="right"><SMALL><NOBR><FONT FACE="Lucida,Verdana,Helvetica,Arial"><B><A HREF="/lounge/">lounge</A> |<BR>
+<A HREF="/contrib.php3">contribute</A> |<BR>
+<A HREF="/feedback.php3">feedback</A> |</B></FONT></NOBR></SMALL></TD>
+<TD ALIGN="right"><SMALL><NOBR><FONT FACE="Lucida,Verdana,Helvetica,Arial"><B><A HREF="/about.php3">about</A> |<BR>
+<A HREF="/awards.php3">awards</A> |<BR>
+<A HREF="/faq.php3">FAQ</A> |</B></FONT></NOBR></SMALL></TD>
+</TR></TABLE></TD>
+</TR></TABLE>
+<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
+<TR BGCOLOR="#000000"><TD><IMG SRC="image4" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
+<TABLE CELLSPACING="0" CELLPADDING="3" BORDER="0" WIDTH="100%" BGCOLOR="#BBDDFF">
+<TR><TD ALIGN="center" VALIGN="top">
+<BR>
+<FONT FACE="Lucida,Verdana,Helvetica,Arial">
+
+
+<SMALL><B>sort by: [ <A HREF="/news/2000/01/29/">date</A> | <A HREF="/news/list.php3?day=/2000/01/29/&orderby=name">name</A> | <A HREF="/news/list.php3?day=/2000/01/29/&orderby=urgency">urgency</A> ]</B></SMALL><BR></TD><TD>&nbsp;</TD></TR><TR><TD VALIGN="top" ALIGN="center"><FONT FACE="Lucida,Verdana,Helvetica,Arial"><TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">We should get this out of the door now</FONT></B><BR>
+<SMALL><B><A HREF="mailto:scoop@freshmeat.net">scoop</A> - January 29th 2000, 23:59 EST</B></SMALL>
+<P>Everyone else is talking about it, so we should announce it ourselves
+before you start to think it's a government hoax. <A HREF="http://server51.freshmeat.net/">Server 51</A> is our new hosting service for Open Source projects, based on Super Cool Space Alien Technology(TM). We hadn't planned to announce it quite so soon, and it's still in the alpha stage as we work day and night at integrating SCSAT with our terrestrial systems, but feel free to take a look around and see what's going on. When we're out of the testing stage and ready to make room for your project, we'll send word via your implants. Be listening.
+
+
+
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949208399.html">comments (8)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>Category: freshmeat
+</SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+ <A HREF="http://server51.freshmeat.net"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Is Linux for Crazies?</FONT></B><BR>
+<SMALL><B><A HREF="mailto:jeff.covey@pobox.com">jeff covey</A> - January 29th 2000, 23:59 EST</B></SMALL>
+<P>Ray Woodcock writes: "In terms relevant to Linux, this freshmeat
+editorial glances at the tendency of mainstream viewpoints to dismiss
+other viewpoints as 'fringe,' the propensity of dissident movements to
+splinter into factions before they can effectively counter their
+primary adversaries, and the difficulty of creating stability without
+squelching curiosity."
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949208340.html">comments (2), 2065 words in body</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>Category: Editorial
+</SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+ &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">RabbIT 2.0.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:d94-rol@nada.kth.se">Ernimril</A> - January 29th 2000, 18:29 EST</B></SMALL>
+<DIV ALIGN="justify"><P>RabbIt is the mutating, caching webproxy which is used to speed up surfing over slow links like modems. It does this by removing advertising and background images and scaling down images to low quality JPEGs. RabbIT is written in Java and should be able to run on any platform. It does depend upon an image converter if imagescaleing is on. The recommended image converter is "convert" from the ImageMagick package.</DIV>
+<P><B>Changes:</B> Fixes have been made for a few bugs concerning keep alive and the HTTP response header, a bug with NT and cache directories, a bug concerning requests without a response body, a bug in GZIPHandler that caused it to not gzip already compressed (gzip or compress) streams, a bug in HTTPHeader regarding response phrases that are multiline, and a few bugs in ImageHandler and NCache. GZIPHandler has been built as an intermediate(*) to FilterHandler (this means that it is possible to gzip text/plain, etc., without filtering those streams) uuencoding has been added to the Coder, RabbIT now uses HTTP/1.1, HTMLParser now compiles cleanly with Jikes, and GeneralHeader has been created to allow for HTTPFooter (which is useful when sending chunked data).
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949188564.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: freely distributable</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/daemons/proxy.html"><FONT COLOR="#FFFFFF">Daemons/Proxy</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/902659138/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/902659138/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1998/08/09/902659138.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">nmpg 1.1.3</FONT></B><BR>
+<SMALL><B><A HREF="mailto:narkos@linuxmail.org">Joel Lindau</A> - January 29th 2000, 18:18 EST</B></SMALL>
+<DIV ALIGN="justify"><P>nmpg is a small command-driven frontend and network-jukebox for mpg123.</DIV>
+<P><B>Changes:</B> Bugfixes, better memory managment, a new .nmpgrc parser, and new options.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949187896.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: OpenSource</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/sound.html"><FONT COLOR="#FFFFFF">Console/Sound</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/935430877/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/935430877/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/935430877/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/08/23/935430877.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">mod_dtcl 0.7.3</FONT></B><BR>
+<SMALL><B><A HREF="mailto:davidw@prosa.it">David Welton</A> - January 29th 2000, 18:11 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Mod_dtcl is a free/open source implementation of server-parsed Tcl under Apache. It allows you to tightly integrate HTML with Tcl, a widely-used scripting language with many years of development invested in it. There are also many external Tcl modules that you can load into mod_dtcl, to create images, access databases, etc.</DIV>
+<P><B>Changes:</B> A major overhaul of header handling and internal buffering, and the addition of the ability to handle binary data.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949187471.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/web/development.html"><FONT COLOR="#FFFFFF">Web/Development</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/917925309/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/917925309/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/917925309/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/02/01/917925309.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">CoreLinux++ 0.4.6</FONT></B><BR>
+<SMALL><B><A HREF="mailto:frankc@users.sourceforge.net">Frank V. Castellucci</A> - January 29th 2000, 18:07 EST</B></SMALL>
+<DIV ALIGN="justify"><P>CoreLinux++ is an initiative to normalize methods and conventions for OOA/OOD/C++ development for Linux, materialized in a set of Open Source C++ class libraries (libcorelinux++ and libcoreframework++) to support common patterns and exploit the C++ standards.</DIV>
+<P><B>Changes:</B> This release adds AbstractFactory and AssociativeIterator analysis, design, implementations, test code, a CVS daily tarball, a Patch Submission facility and updated FAQ, Web Pages, and defect reporting guidelines.
+<P><B>Urgency:</B> medium
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949187233.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: LGPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/libraries.html"><FONT COLOR="#FFFFFF">Development/Libraries</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/944077775/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/944077775/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/944077775/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/12/01/944077775.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">scribe 0.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:kahlage@logoncafe.net">ChromeBob</A> - January 29th 2000, 12:12 EST</B></SMALL>
+<DIV ALIGN="justify"><P>scribe writes functions prototypes for your C code, so you don't have to. It also compares unique functions between source code files and will 'extern' when appropriate. C++ methods support is also planned.</DIV>
+<P><B>Changes:</B> A fix for an fflush() bug and better documentation.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949165962.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/tools.html"><FONT COLOR="#FFFFFF">Development/Tools</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/946661656/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/946661656/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1999/12/31/946661656.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">E theme updater 0.1</FONT></B><BR>
+<SMALL><B><A HREF="mailto:hallvar@ii.uib.no">Hallvar Helleseth</A> - January 29th 2000, 12:04 EST</B></SMALL>
+<DIV ALIGN="justify"><P>E theme Updater is a bash script to automatically update all of your Enlightenment themes from e.themes.org.</DIV>
+<P><B>Changes:</B> Initial release.
+
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949165472.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/misc.html"><FONT COLOR="#FFFFFF">Console/Misc</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/949164501/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/949164501/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/2000/01/29/949164501.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Powertweak-Linux 0.1.7</FONT></B><BR>
+<SMALL><B><A HREF="mailto:dave@denial.force9.co.uk">Dave Jones</A> - January 29th 2000, 12:03 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Powertweak-Linux is a port of the Microsoft Windows tool of the same name rewritten from the ground up. Its main function is to tune your system to its optimal performance settings. Currently, it tunes PCI chipsets and can set /proc/sys entries.</DIV>
+<P><B>Changes:</B> A major GUI overhaul, the ability to generate configuration files, extended PCI information tabs, extra information support for the Matrox G200, and numerous other bugfixes & improvements.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949165416.html">comments (2)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/system.html"><FONT COLOR="#FFFFFF">Console/System</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/930836224/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/930836224/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/930836224/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/07/01/930836224.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Pexeso Beta</FONT></B><BR>
+<SMALL><B><A HREF="mailto:pavolkrigler@pobox.sk">Pavol Krigler</A> - January 29th 2000, 11:55 EST</B></SMALL>
+<DIV ALIGN="justify"><P>pexeso is a simple graphic card game for one or two players.</DIV>
+<P><B>Changes:</B> Initial public release.
+
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164956.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Freeware</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/games.html"><FONT COLOR="#FFFFFF">Console/Games</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/949141436/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/949141436/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/2000/01/29/949141436.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">XZX 2.9.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:Erik.Kunze@fantasy.muc.de">E. Kunze</A> - January 29th 2000, 11:54 EST</B></SMALL>
+<DIV ALIGN="justify"><P>XZX is a portable emulator of ZX Spectrum 48K/128K/+3 (8-bit home computers made by Sir Clive Sinclair) and Pentagon/Scorpion (Spectrum clones made in Russia) for machines running UNIX and the X Window system. XZX is completely written in C and emulates Spectrum 48K, 128K, +2 and +3, Pentagon and Scorpion, Interface I with up to 8 microdrives, Multiface 128 and Multiface 3, BetaDisk 128 interface by Technology Research Ltd with 4 disk drives, +D interface by Miles Gordon Technology with 2 disk drives, Kempston mouse, Kempston joystick and built-in machine code monitor.</DIV>
+<P><B>Changes:</B> Lots of feature improvement and bug fixes. Most parts of the audio support has been rewritten for different UNICES.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164896.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Shareware</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/x11/emulators.html"><FONT COLOR="#FFFFFF">X11/Emulators</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/936956384/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/936956384/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/936956384/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/09/10/936956384.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">DistroLib 0.4</FONT></B><BR>
+<SMALL><B><A HREF="mailto:phir@gcu-squad.org">PhiR</A> - January 29th 2000, 11:54 EST</B></SMALL>
+<DIV ALIGN="justify"><P>DistroLib is an abstraction library designed to make the development of distributed application easier. Its main target is currently compute-bound tasks based on a one server, many clients model (much like distributed.net), but it is quite generic and could be used for any client/server app. It is lightweight, easy-to-use, and relies heavily on threads.</DIV>
+<P><B>Changes:</B> Important bug fixes and command history support.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164869.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/libraries.html"><FONT COLOR="#FFFFFF">Development/Libraries</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/942588431/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/942588431/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/942588431/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/11/14/942588431.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">ToutDoux 1.1.7</FONT></B><BR>
+<SMALL><B><A HREF="mailto:yeupou@altern.org">yeupou</A> - January 29th 2000, 11:54 EST</B></SMALL>
+<DIV ALIGN="justify"><P>ToutDoux is a project manager which lets you design a plan of action using a tree structure, with translations in French and English.</DIV>
+<P><B>Changes:</B> A new menu and XML standard for save files.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164843.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/gnome/tools.html"><FONT COLOR="#FFFFFF">GNOME/Tools</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/944433411/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/944433411/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1999/12/05/944433411.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">goMP 1.0.3</FONT></B><BR>
+<SMALL><B><A HREF="mailto:dioxine@poulet.org">Gautier</A> - January 29th 2000, 11:52 EST</B></SMALL>
+<DIV ALIGN="justify"><P>goMP is a set of CGI scripts that allows you to remotely control, via a Web browser, a computer acting as an MP3 jukebox. This program is very useful for someone who's got a dedicated computer with a lot of MP3 files but that doesn't have any output and input devices except network and sound card. It's main advantages are built-in cataloging, fast access to music, and no special software needed on the client side.</DIV>
+<P><B>Changes:</B> Bugfixes, a password-protected config page, basic search function, easier installation thanks to an install script, and relocation of HTML docs and CGIs to a subdirectory.
+<P><B>Urgency:</B> medium
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164772.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Artistic</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/web/tools.html"><FONT COLOR="#FFFFFF">Web/Tools</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/948492962/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/948492962/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/948492962/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/2000/01/21/948492962.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">APSEND 1.40</FONT></B><BR>
+<SMALL><B><A HREF="mailto:sventek@gmx.net">M.K.</A> - January 29th 2000, 11:50 EST</B></SMALL>
+<DIV ALIGN="justify"><P>APSEND is a TCP/IP packet sender to test firewalls and other network applications. It also includes a syn flood option, the land DoS attack, and a DoS attack against tcpdump running on a UNIX-based system. Future updates will include support for a scripting language to construct TCP packets and a few more options and protocols like UDP and ICMP. A port of APSEND from Perl to C is planned as well.</DIV>
+<P><B>Changes:</B> The stream attack, bugfixes, and rewrites for parts of the code.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164633.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/networking.html"><FONT COLOR="#FFFFFF">Console/Networking</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/941654429/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/941654429/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/941654429/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/11/03/941654429.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">ecasound 1.6.12r10</FONT></B><BR>
+<SMALL><B><A HREF="mailto:kaiv@wakkanet.fi">Kai Vehmanen</A> - January 29th 2000, 11:48 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Ecasound is a software package designed for multitrack audio processing. It can be used for simple tasks like audio playback, recording and format conversions, as well as for multitrack effect processing, mixing, recording and signal recycling. Ecasound supports a wide range of audio inputs, outputs and effect algorithms. Ecasound has a chain-based design that allows effects to be easily combined both in series and in parallel. Oscillators and MIDI-CCs can be used for controlling effect parameters. Includes a versatile console mode interface, a Qt-based X-interface and various command-line utils suitable for batch processing.</DIV>
+<P><B>Changes:</B> Support for 24- and 32-bit audio formats and for ALSA 0.5, multichannel noisegate, a new 2nd order lowpass filter, some ia-mode commands, and various bugfixes and low-level improvements.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164529.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/sound.html"><FONT COLOR="#FFFFFF">Console/Sound</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/931819147/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/931819147/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/931819147/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/07/12/931819147.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">SCEZ 20000129</FONT></B><BR>
+<SMALL><B><A HREF="mailto:m032@mbsks.franken.de">endergone Zwiebeltuete</A> - January 29th 2000, 11:46 EST</B></SMALL>
+<DIV ALIGN="justify"><P>SCEZ is a library that should make the handling of smart cards (not memory cards) and card readers as simple as possible and be at the same time small and easily portable. Currently supported are Dumb Mouse, CT-API and Towitoko readers and Schlumberger Cryptoflex, Gemplus GPK4000, GSM SIM and Telesec SigG cards. A PKCS#15 implementation is in the design phase. There are ports to PalmOS and MS-Windows available.</DIV>
+<P><B>Changes:</B> More card and reader drivers, and an application to read out GSM SIM card (phone book and SMS) and write it to the card.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164394.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: BSD type</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/libraries.html"><FONT COLOR="#FFFFFF">Development/Libraries</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/939677525/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/939677525/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1999/10/11/939677525.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Comicq 0.2.0</FONT></B><BR>
+<SMALL><B><A HREF="mailto:terminal6@submail.net">Terminal6</A> - January 29th 2000, 11:45 EST</B></SMALL>
+<DIV ALIGN="justify"><P>COMICQ is a command line ICQ messaging tool that allows a user to connect to ICQ using your UIN and password, then sends a message to the destination UIN.</DIV>
+<P><B>Changes:</B> Several bugfixes, icq99a compliance, and a new option --ip that allows you to get any user's IP by their UIN.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164350.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/communication.html"><FONT COLOR="#FFFFFF">Console/Communication</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/948389309/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/948389309/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/2000/01/20/948389309.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">senv 0.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:kojak@ids.pl">Zbyszek Sobiecki</A> - January 29th 2000, 11:44 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Senv allows you to run programs with a specified environment. It can set uid, gid, root directory, working directory, limits, and environment variables. It is useful in init scripts and as a shell for users for setting resource limits and environment variables. You can create sets of configurations and specify the one to use from command line.</DIV>
+<P><B>Changes:</B> Login shell limits and environment setting for users, permanent resource limits for specified groups of users and environment variables, and other minor bugfixes.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164259.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/administration.html"><FONT COLOR="#FFFFFF">Console/Administration</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/944953892/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/changelog/944953892/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/12/11/944953892.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">XZX 2.9.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:Erik.Kunze@fantasy.muc.de">E. Kunze</A> - January 29th 2000, 10:55 EST</B></SMALL>
+<DIV ALIGN="justify"><P>XZX is a portable emulator of ZX Spectrum 48K/128K/+3 (8-bit home computers made by Sir Clive Sinclair) and Pentagon/Scorpion (Spectrum clones made in Russia) for machines running UNIX and the X Window system. XZX is completely written in C and emulates Spectrum 48K, 128K, +2 and +3, Pentagon and Scorpion, Interface I with up to 8 microdrives, Multiface 128 and Multiface 3, BetaDisk 128 interface by Technology Research Ltd with 4 disk drives, +D interface by Miles Gordon Technology with 2 disk drives, Kempston mouse, Kempston joystick and built-in machine code monitor.</DIV>
+<P><B>Changes:</B> Lots of feature improvement and bug fixes. Most parts of the audio support has been rewritten for different UNICES.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949161354.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Shareware</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/x11/emulators.html"><FONT COLOR="#FFFFFF">X11/Emulators</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/936956384/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/936956384/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/936956384/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/09/10/936956384.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<P><SMALL><CENTER><B>[ <A HREF="/news/2000/01/29/">full page for today</A> | <A HREF="/news/2000/01/28/">yesterday's edition</A> ]</SMALL></B></CENTER></FONT></TD><TD WIDTH="27%" VALIGN="top" ALIGN="center"><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">navigator</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/"><FONT COLOR="#000000">full page for today</FONT></A><BR>
+- <A HREF="/news/2000/01/28/"><FONT COLOR="#000000">yesterday's edition</FONT></A><BR>
+- <A HREF="news://news.freshmeat.net/"><FONT COLOR="#000000"><B>new:</B> fm news via NNTP</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">eye catcher</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B>Free Shirts</B><BR>We give away a free freshmeat t-shirt every week for the best comment added to an application announcement or story posted on freshmeat.
+<P><B>#freshmeat</B><BR>If you want to chat about what's new on freshmeat and hang out with other fm lounge lizards and the fm staff, head over to #freshmeat on irc.freshmeat.net, part of <A HREF="http://openprojects.nu/">The Open Projects Network</A>.
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">site notes</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/949208399.html"><FONT COLOR="#000000">We should get this out of the door now (Jan 29th)</FONT></A><BR>
+- <A HREF="/news/2000/01/01/946704535.html"><FONT COLOR="#000000">freshmeat Y2K report (Jan 01st)</FONT></A><BR>
+- <A HREF="/news/1999/08/16/934862340.html"><FONT COLOR="#000000">Assorted freshmeat notes (Aug 16th)</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">recent editorials</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/949208340.html"><FONT COLOR="#000000">Is Linux for Crazies? (Jan 29th)</FONT></A><BR>
+- <A HREF="/news/2000/01/22/948603540.html"><FONT COLOR="#000000">A New Business Plan for Free Software (Jan 22nd)</FONT></A><BR>
+- <A HREF="/news/2000/01/15/947998740.html"><FONT COLOR="#000000">Is Linux Going to Reunite the UNIX Market? (Jan 15th)</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">andover.net</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<BR><CENTER><A HREF="http://andover.net"><IMG SRC="image9" BORDER="0" WIDTH="150" HEIGHT="43" ALT="Mirror Logo"></A></CENTER><P>
+- <A HREF="http://www.animfactory.com/"><FONT COLOR="#000000">Animation Factory</FONT></A><BR>
+- <A HREF="http://www.davecentral.com/"><FONT COLOR="#000000">DaveCentral</FONT></A><BR>
+- <A HREF="http://www.freecode.com/"><FONT COLOR="#000000">FreeCode</FONT></A><BR>
+- <A HREF="http://www.InternetTrafficReport.com/"><FONT COLOR="#000000">Internet Traffic Report</FONT></A><BR>
+- <A HREF="http://www.ITManagersJournal.com/"><FONT COLOR="#000000">IT Manager's Journal</FONT></A><BR>
+- <A HREF="http://www.mediabuilder.com/"><FONT COLOR="#000000">MediaBuilder</FONT></A><BR>
+- <A HREF="http://slashdot.org/"><FONT COLOR="#000000">Slashdot</FONT></A><BR>
+- <A HREF="http://www.slaughterhouse.com/"><FONT COLOR="#000000">Slaughterhouse</FONT></A><BR>
+- <A HREF="http://www.techmailings.com/"><FONT COLOR="#000000">TechMailings</FONT></A><BR>
+- <A HREF="http://www.techsightings.com/"><FONT COLOR="#000000">TechSightings</FONT></A><BR>
+<BR><CENTER><B>E-Commerce</B></CENTER><P>
+- <A HREF="http://www.thinkgeek.com"><FONT COLOR="#000000">ThinkGeek (Stuff for smart masses)</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">supported sites</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.userfriendly.org"><FONT COLOR="#000000">Userfriendly.org</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com"><FONT COLOR="#000000">SecurityFocus</FONT></A><BR>
+- <A HREF="http://copyleft.net"><FONT COLOR="#000000">copyleft</FONT></A><BR>
+- <A HREF="http://filewatcher.org"><FONT COLOR="#000000">Filewatcher</FONT></A><BR>
+- <A HREF="http://www.linux.com"><FONT COLOR="#000000">Linux.com</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org"><FONT COLOR="#000000">LinuxTelephony</FONT></A><BR>
+- <A HREF="http://www.linuxtoday.com"><FONT COLOR="#000000">LinuxToday</FONT></A><BR>
+- <A HREF="http://openprojects.nu/services/irc.html"><FONT COLOR="#000000">Openprojects</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com"><FONT COLOR="#000000">32bitsonline</FONT></A><BR>
+- <A HREF="http://www.gnu.org"><FONT COLOR="#000000">The GNU Project</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="/news/2000/01/29/"><font color="#000000">saturday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/949208399.html"><FONT COLOR="#000000">We should get this out of the door now</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949208340.html"><FONT COLOR="#000000">Is Linux for Crazies?</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949188564.html"><FONT COLOR="#000000">RabbIT 2.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949187896.html"><FONT COLOR="#000000">nmpg 1.1.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949187471.html"><FONT COLOR="#000000">mod_dtcl 0.7.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949187233.html"><FONT COLOR="#000000">CoreLinux++ 0.4.6</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949165962.html"><FONT COLOR="#000000">scribe 0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949165472.html"><FONT COLOR="#000000">E theme updater 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949165416.html"><FONT COLOR="#000000">Powertweak-Linux 0.1.7</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164956.html"><FONT COLOR="#000000">Pexeso Beta</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164896.html"><FONT COLOR="#000000">XZX 2.9.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164869.html"><FONT COLOR="#000000">DistroLib 0.4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164843.html"><FONT COLOR="#000000">ToutDoux 1.1.7</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164772.html"><FONT COLOR="#000000">goMP 1.0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164633.html"><FONT COLOR="#000000">APSEND 1.40</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164529.html"><FONT COLOR="#000000">ecasound 1.6.12r10</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164394.html"><FONT COLOR="#000000">SCEZ 20000129</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164350.html"><FONT COLOR="#000000">Comicq 0.2.0</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164259.html"><FONT COLOR="#000000">senv 0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949161354.html"><FONT COLOR="#000000">XZX 2.9.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949161036.html"><FONT COLOR="#000000">log4j 0.7.5</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949156343.html"><FONT COLOR="#000000">SQN Linux 1.6</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949156277.html"><FONT COLOR="#000000">Limo 0.3.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949156237.html"><FONT COLOR="#000000">Fusion GS 1.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949145887.html"><FONT COLOR="#000000">MMR 1.5.4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949142835.html"><FONT COLOR="#000000">KUPS 0.3.4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949142815.html"><FONT COLOR="#000000">3DSE patch for XMMS 4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949139763.html"><FONT COLOR="#000000">Linux 2.3.41</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949139751.html"><FONT COLOR="#000000">Free Code for Linux S/390</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135979.html"><FONT COLOR="#000000">CircleMUD 3.0 beta patchlevel 17</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135938.html"><FONT COLOR="#000000">NiL Isn't Liero 000128</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135913.html"><FONT COLOR="#000000">OpenSSH Unix Port 1.2.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135889.html"><FONT COLOR="#000000">KBoxes! 1.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135867.html"><FONT COLOR="#000000">phpLanParty 0.23</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135509.html"><FONT COLOR="#000000">DGen/SDL 1.20</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135482.html"><FONT COLOR="#000000">EdcomLib 1.0 alpha 5</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135309.html"><FONT COLOR="#000000">Etherboot 4.4.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135205.html"><FONT COLOR="#000000">BLADE 0.18.0</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135115.html"><FONT COLOR="#000000">Sapphire 0.13.7</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135070.html"><FONT COLOR="#000000">ippl 1.99.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134977.html"><FONT COLOR="#000000">Saint 1.5patch1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134943.html"><FONT COLOR="#000000">Zircon 1.18.232</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134927.html"><FONT COLOR="#000000">nmap 2.3BETA14</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134901.html"><FONT COLOR="#000000">xterm patch #124</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134817.html"><FONT COLOR="#000000">MyThreads-Links v0.5.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134633.html"><FONT COLOR="#000000">sudo 1.6.2p1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134552.html"><FONT COLOR="#000000">MIT Photonic-Bands 0.10</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134246.html"><FONT COLOR="#000000">Launcher 0.86</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134179.html"><FONT COLOR="#000000">nano 0.8.1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134103.html"><FONT COLOR="#000000">Gtk-- 1.1.8</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134049.html"><FONT COLOR="#000000">tkchooser 0.65</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949133420.html"><FONT COLOR="#000000">XShipWars 1.33a</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949133280.html"><FONT COLOR="#000000">Lamerpad 0.1</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="/news/2000/01/28/"><font color="#000000">friday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/28/949117833.html"><FONT COLOR="#000000">fsv 0.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949117711.html"><FONT COLOR="#000000">popsneaker 0.1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949114716.html"><FONT COLOR="#000000">eyep-updater.sh 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949113240.html"><FONT COLOR="#000000">W3Mail 0.5.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949113214.html"><FONT COLOR="#000000">The Urgent Decision 0.9.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949112269.html"><FONT COLOR="#000000">LTSP 1.02</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949112198.html"><FONT COLOR="#000000">Production BASIC 0.2.12</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949112123.html"><FONT COLOR="#000000">Postfix 19991231-pl03</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949109732.html"><FONT COLOR="#000000">Mp3 Commander 0.7</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949109324.html"><FONT COLOR="#000000">iManager 1.0.1b</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108399.html"><FONT COLOR="#000000">Eterm 0.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108308.html"><FONT COLOR="#000000">dqd_dirindex 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108087.html"><FONT COLOR="#000000">Tidings 1.0.4</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108026.html"><FONT COLOR="#000000">localscan 2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107922.html"><FONT COLOR="#000000">WMKeyboard 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107834.html"><FONT COLOR="#000000">fcmp 1.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107767.html"><FONT COLOR="#000000">Akkord 0.3.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107649.html"><FONT COLOR="#000000">HiM 0.1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949106305.html"><FONT COLOR="#000000">cdrecord 1.8</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949103400.html"><FONT COLOR="#000000">eMixer 0.05.5</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949103187.html"><FONT COLOR="#000000">FreeVSD 1.4.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949103096.html"><FONT COLOR="#000000">Common C++ Libraries 0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949095155.html"><FONT COLOR="#000000">Moonshine 1.0beta2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949095112.html"><FONT COLOR="#000000">swim 0.3.5</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949095009.html"><FONT COLOR="#000000">Xmame/xmess 0.36b15.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949094448.html"><FONT COLOR="#000000">pcmcia-cs 3.1.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949091509.html"><FONT COLOR="#000000">gPS 0.5.2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949091415.html"><FONT COLOR="#000000">Snort 1.5.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949090436.html"><FONT COLOR="#000000">Pygmy Linux 0.7 beta</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949090237.html"><FONT COLOR="#000000">Intro to Bash Programming HOWTO 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084379.html"><FONT COLOR="#000000">GNU Pth 1.3b2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084356.html"><FONT COLOR="#000000">Laonux 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084304.html"><FONT COLOR="#000000">x-wvdial 0.12</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084188.html"><FONT COLOR="#000000">Intro to Bash Programming HOWTO 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084106.html"><FONT COLOR="#000000">Catalog 1.02</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084062.html"><FONT COLOR="#000000">harvest 1.5.20-kj-0.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949068306.html"><FONT COLOR="#000000">wmseti 0.3.0a</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949057272.html"><FONT COLOR="#000000">RIG 1.02</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949057019.html"><FONT COLOR="#000000">FreeAddr 0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949056939.html"><FONT COLOR="#000000">GtkAda 1.2.5</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949056664.html"><FONT COLOR="#000000">dot.conf 0.6.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949055099.html"><FONT COLOR="#000000">dep.pl 1.28.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949054980.html"><FONT COLOR="#000000">Prae's Scripts 1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949044301.html"><FONT COLOR="#000000">Project Clock 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949044285.html"><FONT COLOR="#000000">Xtheater 0.2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949040013.html"><FONT COLOR="#000000">i-no Chart 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949039945.html"><FONT COLOR="#000000">spliff 0.8.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949038953.html"><FONT COLOR="#000000">Regexx 0.95</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949038316.html"><FONT COLOR="#000000">RBook 0.5.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949036742.html"><FONT COLOR="#000000">RIG 1.01</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949036714.html"><FONT COLOR="#000000">wchat 1.2.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949036428.html"><FONT COLOR="#000000">PCCS MySQLDatabase Admin Tool 1.2.2</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="/news/2000/01/27/"><font color="#000000">thursday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/27/949033332.html"><FONT COLOR="#000000">CADUBI 1.1b1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032987.html"><FONT COLOR="#000000">Angus' Chess Clock 0.8.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032555.html"><FONT COLOR="#000000">MP3 Report Generator 1.0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032518.html"><FONT COLOR="#000000">4DOM 0.9.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032386.html"><FONT COLOR="#000000">4XSLT 0.8.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949031346.html"><FONT COLOR="#000000">OpenNaken 1.10</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949025747.html"><FONT COLOR="#000000">iManager 1.0b</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949025168.html"><FONT COLOR="#000000">QuakeForge 0.1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949023271.html"><FONT COLOR="#000000">pylice 0.7.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949023250.html"><FONT COLOR="#000000">Solfege 0.6.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949023151.html"><FONT COLOR="#000000">xinetd 2.1.8.7p1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949022849.html"><FONT COLOR="#000000">jac 0.13</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949022803.html"><FONT COLOR="#000000">Xmms 1.0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949022319.html"><FONT COLOR="#000000">KSrnd 0.97</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021877.html"><FONT COLOR="#000000">getpg / UW-IMAP 0.54</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021849.html"><FONT COLOR="#000000">getpg 0.53</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021824.html"><FONT COLOR="#000000">setserial 2.17</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021250.html"><FONT COLOR="#000000">Pan 0.7.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021216.html"><FONT COLOR="#000000">jwhois 2.4.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021126.html"><FONT COLOR="#000000">Kmp3 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949020964.html"><FONT COLOR="#000000">xPine 0.0.12</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949019905.html"><FONT COLOR="#000000">Avenger's News System 2.1 Alpha</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949019709.html"><FONT COLOR="#000000">RIG 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949019321.html"><FONT COLOR="#000000">scroller 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949018347.html"><FONT COLOR="#000000">Perl EyeP Client 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949017796.html"><FONT COLOR="#000000">sfront 0.54</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949017631.html"><FONT COLOR="#000000">XFrisk 1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949016202.html"><FONT COLOR="#000000">Moffy 0.0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949015348.html"><FONT COLOR="#000000">Solid POP3 0.14</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949014200.html"><FONT COLOR="#000000">php3guest 1.5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949013630.html"><FONT COLOR="#000000">crUD 01.27.2000</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949013380.html"><FONT COLOR="#000000">crUD 01.27.2000</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949012979.html"><FONT COLOR="#000000">Free Pascal Compiler 0.99.14</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949012771.html"><FONT COLOR="#000000">gtk-font-hack 0.2-gtk-1.2.6</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949009233.html"><FONT COLOR="#000000">Linux 2.2.15pre5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949005620.html"><FONT COLOR="#000000">krunseti 0.2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948996446.html"><FONT COLOR="#000000">CompuPic 5.0.1036</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995905.html"><FONT COLOR="#000000">gfontview 0.3.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995819.html"><FONT COLOR="#000000">authlocal 1.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995600.html"><FONT COLOR="#000000">bigwig 1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995501.html"><FONT COLOR="#000000">CAFire 0.0.11</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995429.html"><FONT COLOR="#000000">ANVLOGIN 2.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994944.html"><FONT COLOR="#000000">sawmill.el 1.9</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994810.html"><FONT COLOR="#000000">Perlsh 20000127</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994776.html"><FONT COLOR="#000000">sitescooper 2.1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994691.html"><FONT COLOR="#000000">MHDns 1.4</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994419.html"><FONT COLOR="#000000">JChemPaint 0.5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994364.html"><FONT COLOR="#000000">Filesystems HOWTO 0.7.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994343.html"><FONT COLOR="#000000">KSnes9x 1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993513.html"><FONT COLOR="#000000">Mozilla M13</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993439.html"><FONT COLOR="#000000">edna 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993409.html"><FONT COLOR="#000000">GMasqdialer 0.99.8</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993341.html"><FONT COLOR="#000000">spliff 0.8</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948992808.html"><FONT COLOR="#000000">MultiSeti 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970667.html"><FONT COLOR="#000000">rude 0.50</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970605.html"><FONT COLOR="#000000">cgi-util++ 0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970479.html"><FONT COLOR="#000000">Cricket 0.72</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970458.html"><FONT COLOR="#000000">nuni 0.04</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970379.html"><FONT COLOR="#000000">Ksetiwatch 0.3.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970358.html"><FONT COLOR="#000000">SiteMgrYAP 0.1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970322.html"><FONT COLOR="#000000">phpLanParty 0.21</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970285.html"><FONT COLOR="#000000">Glitter Newsreader 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970263.html"><FONT COLOR="#000000">Fastresolve 2.4</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970164.html"><FONT COLOR="#000000">ColdSync 1.1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970080.html"><FONT COLOR="#000000">DDD 3.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970032.html"><FONT COLOR="#000000">X Northern Captain 4.2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969919.html"><FONT COLOR="#000000">abcde 1.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969659.html"><FONT COLOR="#000000">Gnapster 1.3.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969551.html"><FONT COLOR="#000000">xmix 1.0 Alpha</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969488.html"><FONT COLOR="#000000">gtktetcolor 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969412.html"><FONT COLOR="#000000">muttzilla 0.40</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969395.html"><FONT COLOR="#000000">muttzilla 0.40</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969337.html"><FONT COLOR="#000000">asp2php 0.73.6</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969217.html"><FONT COLOR="#000000">mod_ticket 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969078.html"><FONT COLOR="#000000">MegaHAL for Eggdrop .01</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968456.html"><FONT COLOR="#000000">Jetty 2.3.5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968386.html"><FONT COLOR="#000000">xlpotdb 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968341.html"><FONT COLOR="#000000">Koala Complete MUD Server 0.1.1a</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968255.html"><FONT COLOR="#000000">mcountd 0.4</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948967933.html"><FONT COLOR="#000000">cdbackup 0.5.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948967908.html"><FONT COLOR="#000000">The Java SSH/Telnet Application/Applet 2.0 RC1</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://slashdot.org"><font color="#000000">slashdot</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/1534255"><FONT COLOR="#000000">Petition Apple for Linux QuickTime</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/1223249"><FONT COLOR="#000000">GNUstep 0.6.5 freeze</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/28/2324203"><FONT COLOR="#000000">YETI@Home</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/1024215"><FONT COLOR="#000000">Documents Unsealed in Microsoft/Caldera Case</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/0837235"><FONT COLOR="#000000">Who Bought Linux.Net?</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/24/1146250"><FONT COLOR="#000000">E-Mails from (Over?) The Edge</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/0834223"><FONT COLOR="#000000">Linux Kernel 2.3.41</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/28/2311232"><FONT COLOR="#000000">Congress Still Figuring Out E-Mail</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/22/1946244"><FONT COLOR="#000000">Sci Fi Literature 101?</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/28/2318246"><FONT COLOR="#000000">Could Distributed.Net Help the Mars Polar Lander?</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.securityfocus.com"><font color="#000000">securityfocus</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.zdnet.com/zdnn/stories/news/0,4586,2429334,00.html?chkpt=zdnntop"><FONT COLOR="#000000">Win2000 security hole a 'major threat'</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.computerworld.com/home/print.nsf/all/000128e45a"><FONT COLOR="#000000">Visa acknowledges cracker break-ins</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.zdnet.com/sr/stories/column/0,4712,2429536,00.html"><FONT COLOR="#000000">What's Wrong With Microsoft Security?</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.zdnet.com/pcweek/stories/news/0,4153,2429334,00.html"><FONT COLOR="#000000">Microsoft posts first Win2K security patch</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=tools&id=1018"><FONT COLOR="#000000">Libnids 1.12</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.theregister.co.uk/000127-000005.html"><FONT COLOR="#000000">New hack attack is greater threat than imagined</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.mercurycenter.com/svtech/news/indepth/docs/hacker012700.htm"><FONT COLOR="#000000">Student charged with hacking</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=library&id=63"><FONT COLOR="#000000">Building and Managing Virtual Private Networks (book)</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=library&id=111"><FONT COLOR="#000000">Threats, Vulnerabilities and Real-Worl Responses: The Foundations of the TruSecure Process</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=library&id=1701"><FONT COLOR="#000000">The Hundredth Window : Protecting Your Privacy and Security in the Age of the Internet (boo</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.bebits.com"><font color="#000000">bebits</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.bebits.com/app/706/"><FONT COLOR="#000000">Pe 3.0a3</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/757/"><FONT COLOR="#000000">Rarscript 1.5</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/736/"><FONT COLOR="#000000">CD Manager 0.66a beta</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/174/"><FONT COLOR="#000000">TraX 1.1</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/785/"><FONT COLOR="#000000">BeMath 1.2.2</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/784/"><FONT COLOR="#000000">simple blackjack 1</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/758/"><FONT COLOR="#000000">HtmlTree 0.5.3</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/783/"><FONT COLOR="#000000">Yacp 0.1</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/222/"><FONT COLOR="#000000">TicTacToe 1.5</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/706/"><FONT COLOR="#000000">Pe 3.0a2</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://linuxtoday.com"><font color="#000000">linuxtoday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://linuxtoday.com/story.php3?sn=15878"><FONT COLOR="#000000">Linux Journal: KDE--The Next Generation</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15876"><FONT COLOR="#000000">Kernel Cousin gimp-devel #11 Is Out</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15875"><FONT COLOR="#000000">Infoworld: Corel Linux OS ideal for the desktop</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15874"><FONT COLOR="#000000">Technology Evaluation: IBM Jumps on the Linux Bandwagon with Both Feet, Sort Of</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15873"><FONT COLOR="#000000">Tobias Hövekamp: European Union acknowledges</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">&</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">#34;Open Source Software</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">&</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">#34;</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.linuxtelephony.org"><font color="#000000">linuxtelephony</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=208&r=0"><FONT COLOR="#000000">Traverse Technologies releases NETspider-U in US</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=207&r=0"><FONT COLOR="#000000">Quicknet releases new GPL'd Linux Drivers!</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=206&r=0"><FONT COLOR="#000000">Natural Microsystems Delivers Carrier-Class Linux</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=205&r=0"><FONT COLOR="#000000">Quicknet is hiring programmers of all kinds!</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=204&r=0"><FONT COLOR="#000000">Babylon MLPPP Software Released under GPL</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=202&r=0"><FONT COLOR="#000000">Linux Telephony Server Project?</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=203&r=0"><FONT COLOR="#000000">Vovida Networks to Hire Telephony Software Engineers</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=200&r=0"><FONT COLOR="#000000">SPIRO-Linux Introduces Web-Enabled Phone Administration</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=199&r=0"><FONT COLOR="#000000">LinuxTelephony sponsors area at LinuxFest 2000</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=198&r=0"><FONT COLOR="#000000">GSM-Mobile Switching Center (MSC) with Linux-PC</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.32bitsonline.com"><font color="#000000">32bitsonline</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.32bitsonline.com/article.php3?file=issues/200001/homeworld&page=1
+"><FONT COLOR="#000000">Game: Homeworld</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001271a&page=1
+"><FONT COLOR="#000000">DVD Lawsuit Spreads Its Own 'Trade Secrets'</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001272&page=1
+"><FONT COLOR="#000000">Register.com Adds 'One-step' Domain Registration</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/article.php3?file=issues/200001/webevent&page=1
+"><FONT COLOR="#000000">WebEvent: Keeping you organized</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001273a&page=1
+"><FONT COLOR="#000000">Y2K Officers Defend $100 Bil Investment</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/article.php3?file=issues/200001/jan2000_john_berger&page=1
+"><FONT COLOR="#000000">DON'T BE FOOLED</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001274&page=1
+"><FONT COLOR="#000000">Microsoft Scorns Think-Tank's Breakup Idea</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001275a&page=1
+"><FONT COLOR="#000000">Yahoo Accused Of Stalking Internet Users</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001276a&page=1
+"><FONT COLOR="#000000">eToys.com Settles Spat With Swiss Artist Group</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/
+"><FONT COLOR="#000000">[more articles/news]</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<BR><BR></FONT>
+</TD></TR></TABLE>
+<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
+<TR BGCOLOR="#000000"><TD><IMG SRC="image4" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
+</CENTER>
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="100%" BORDER="0"><TR>
+<TD VALIGN="top" ALIGN="center"><FONT FACE="Lucida,Verdana,Helvetica,Arial"><SMALL>copyright © 1997-2000 <A HREF="http://andover.net">Andover.Net</A> -
+icons courtesy of <A HREF="mailto:tigert@gimp.org">tigert@gimp.org</A> -
+code revision <A HREF="http://freshmeat.net/ChangeLog">20000101</A> -
+our <A HREF="http://www.andover.net/privacy.html">privacy policy</A></SMALL></FONT></TD>
+</TR></TABLE>
+</BODY>
+</HTML>
+
+
diff --git a/ext/tk/sample/tkextlib/tkHTML/ss.rb b/ext/tk/sample/tkextlib/tkHTML/ss.rb
new file mode 100644
index 0000000000..179bdc13cd
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tkHTML/ss.rb
@@ -0,0 +1,404 @@
+#!/usr/bin/env ruby
+#
+# This script implements the "ss" application. "ss" implements
+# a presentation slide-show based on HTML slides.
+#
+require 'tk'
+require 'tkextlib/tkHTML'
+
+root = TkRoot.new(:title=>'HTML File Viewer', :iconname=>'HV')
+fswin = nil
+
+html = nil
+html_fs = nil
+
+hotkey = {}
+
+file = ARGV[0]
+
+
+# These are images to use with the actual image specified in a
+# "<img>" markup can't be found.
+#
+biggray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhPAA+APAAALi4uAAAACwAAAAAPAA+AAACQISPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNFgsAO///
+EOD
+
+smgray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhOAAYAPAAALi4uAAAACwAAAAAOAAYAAACI4SPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9m0VADv/
+EOD
+
+
+#
+# A font chooser routine.
+#
+# html[:fontcommand] = pick_font
+pick_font = proc{|size, attrs|
+ # puts "FontCmd: #{size} #{attrs}"
+ [ ((attrs =~ /fixed/)? 'courier': 'charter'),
+ (12 * (1.2**(size.to_f - 4.0))).to_i,
+ ((attrs =~ /italic/)? 'italic': 'roman'),
+ ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ')
+}
+
+# This routine is called to pick fonts for the fullscreen view.
+#
+baseFontSize = 24
+pick_font_fs = proc{|size, attrs|
+ # puts "FontCmd: #{size} #{attrs}"
+ [ ((attrs =~ /fixed/)? 'courier': 'charter'),
+ (baseFontSize * (1.2**(size.to_f - 4.0))).to_i,
+ ((attrs =~ /italic/)? 'italic': 'roman'),
+ ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ')
+}
+
+#
+#
+hyper_cmd = proc{|*args|
+ puts "HyperlinkCommand: #{args.inspect}"
+}
+
+# This routine is called to run an applet
+#
+applet_arg = TkVarAccess.new_hash('AppletArg')
+run_applet = proc{|size, w, arglist|
+ applet_arg.value = Hash[*simplelist(arglist)]
+
+ return unless applet_arg.key?('src')
+
+ src = html.remove(applet_arg['src'])
+
+ applet_arg['window'] = w
+ applet_arg['fontsize'] = size
+
+ begin
+ Tk.load_tclscript(src)
+ rescue => e
+ puts "Applet error: #{e.message}"
+ end
+}
+
+#
+#
+form_cmd = proc{|n, cmd, *args|
+}
+
+#
+#
+images = {}
+old_imgs = {}
+big_imgs = {}
+
+#
+#
+move_big_image = proc{|b|
+ return unless big_imgs.key?(b)
+ b.copy(big_imgs[b])
+ big_imgs[b].delete
+ big_imgs.delete(b)
+}
+
+image_cmd = proc{|hs, *args|
+ fn = args[0]
+
+ if old_imgs.key?(fn)
+ return (images[fn] = old_imgs.delete(fn))
+ end
+
+ begin
+ img = TkPhotoImage.new(:file=>fn)
+ rescue
+ return ((hs)? smallgray: biggray)
+ end
+
+ if hs
+ img2 = TkPhotoImage.new
+ img2.copy(img, :subsample=>[2,2])
+ img.delete
+ img = img2
+ end
+
+ if img.width * img.height > 20000
+ b = TkPhotoImage.new(:width=>img.width, :height=>img.height)
+ big_imgs[b] = img
+ img = b
+ Tk.after_idle(proc{ move_big_image.call(b) })
+ end
+
+ images[fn] = img
+
+ img
+}
+
+
+#
+# This routine is called for every <SCRIPT> markup
+#
+script_cmd = proc{|*args|
+ # puts "ScriptCmd: #{args.inspect}"
+}
+
+# This routine is called for every <APPLET> markup
+#
+applet_cmd = proc{|w, arglist|
+ # puts "AppletCmd: w=#{w} arglist=#{arglist}"
+ #TkLabel.new(w, :text=>"The Applet #{w}", :bd=>2, :relief=>raised)
+}
+
+# This binding fires when there is a click on a hyperlink
+#
+href_binding = proc{|w, x, y|
+ lst = w.href(x, y)
+ unless lst.empty?
+ process_url.call(lst)
+ end
+}
+
+#
+#
+last_dir = Dir.pwd
+sel_load = proc{
+ filetypes = [
+ ['Html Files', ['.html', '.htm']],
+ ['All Files', '*']
+ ]
+
+ f = Tk.getOpenFile(:initialdir=>last_dir, :filetypes=>filetypes)
+ if f != ''
+ load_file.call(f)
+ last_dir = File.dirname(f)
+ end
+}
+
+# Clear the screen.
+#
+clear_screen = proc{
+ if html_fs && html_fs.exist?
+ w = html_fs
+ else
+ w = html
+ end
+ w.clear
+ old_imgs.clear
+ big_imgs.clear
+ hotkey.clear
+ images.each{|k, v| old_imgs[k] = v }
+ images.clear
+}
+
+# Read a file
+#
+read_file = proc{|name|
+ begin
+ fp = open(name, 'r')
+ ret = fp.read(File.size(name))
+ rescue
+ ret = nil
+ fp = nil
+ Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'",
+ :type=>:ok)
+ ensure
+ fp.close if fp
+ end
+ ret
+}
+
+# Process the given URL
+#
+process_url = proc{|url|
+ case url[0]
+ when /^file:/
+ load_file.call(url[0][5..-1])
+ when /^exec:/
+ Tk.ip_eval(url[0][5..-1].tr('\\', ' '))
+ else
+ load_file.call(url[0])
+ end
+}
+
+# Load a file into the HTML widget
+#
+last_file = ''
+
+load_file = proc{|name|
+ return unless (doc = read_file.call(name))
+ clear_screen.call
+ last_file = name
+ if html_fs && html_fs.exist?
+ w = html_fs
+ else
+ w = html
+ end
+ w.configure(:base=>name)
+ w.parse(doc)
+ w.configure(:cursor=>'top_left_arrow')
+ old_imgs.clear
+}
+
+# Refresh the current file.
+#
+refresh = proc{|*args|
+ load_file.call(last_file) if last_file
+}
+
+# This routine is called whenever a "<meta>" markup is seen.
+#
+meta = proc{|w, tag, alist|
+ v = Hash[*simplelist(alist)]
+
+ if v.kye?('key') && v.key?('href')
+ hotkey[v['key']] = w.resolve(v['href'])
+ end
+
+ if v.kye?('next')
+ hotkey['Down'] =v['next']
+ end
+
+ if v.kye?('prev')
+ hotkey['Up'] =v['prev']
+ end
+
+ if v.kye?('other')
+ hotkey['o'] =v['other']
+ end
+}
+
+# Go from full-screen mode back to window mode.
+#
+fullscreen_off = proc{
+ fswin.destroy
+ root.deiconify
+ Tk.update
+ root.raise
+ html.clipwin.focus
+ clear_screen.call
+ old_imgs.clear
+ refresh.call
+}
+
+# Go from window mode to full-screen mode.
+#
+fullscreen = proc{
+ if fswin && fswin.exist?
+ fswin.deiconify
+ Tk.update
+ fswin.raise
+ return
+ end
+
+ width = root.winfo_screenwidth
+ height = root.winfo_screenheight
+ fswin = TkToplevel.new(:overrideredirect=>true,
+ :geometry=>"#{width}x#{height}+0+0")
+
+ html_fs = Tk::HTML_Widget.new(fswin, :padx=>5, :pady=>9,
+ :formcommand=>form_cmd,
+ :imagecommand=>proc{image_cmd.call(0)},
+ :scriptcommand=>script_cmd,
+ :appletcommand=>applet_cmd,
+ :hyperlinkcommand=>hyper_cmd,
+ :bg=>'white', :tablerelief=>:raised,
+ :appletcommand=>proc{|*args|
+ run_applet('big', *args)
+ },
+ :fontcommand=>pick_font_fs,
+ :cursor=>:tcross) {
+ pack(:fill=>:both, :expand=>true)
+ token_handler('meta', proc{|*args| meta.call(self, *args)})
+ }
+
+ clear_screen.call
+ old_imgs.clear
+ refresh.call
+ Tk.update
+ html_fs.clipwin.focus
+}
+
+#
+#
+key_block = false
+
+key_press = proc{|w, keysym|
+ return if key_block
+ key_block = true
+ Tk.after(250, proc{key_block = false})
+
+ if hotkey.key?(keysym)
+ process_url.call(hotkey[keysym])
+ end
+ case keysym
+ when 'Escape'
+ if fswin && fswin.exist?
+ fullscreen_off.call
+ else
+ fullscreen.call
+ end
+ end
+}
+
+Tk::HTML_Widget::ClippingWindow.bind('1', key_press, '%W Down')
+Tk::HTML_Widget::ClippingWindow.bind('3', key_press, '%W Up')
+Tk::HTML_Widget::ClippingWindow.bind('2', key_press, '%w Down')
+
+Tk::HTML_Widget::ClippingWindow.bind('KeyPress', key_press, '%W %K')
+
+
+############################################
+#
+# Build the half-size view of the page
+#
+menu_spec = [
+ [['File', 0],
+ ['Open', sel_load, 0],
+ ['Full Screen', fullscreen, 0],
+ ['Refresh', refresh, 0],
+ '---',
+ ['Exit', proc{exit}, 1]]
+]
+
+mbar = root.add_menubar(menu_spec)
+
+html = Tk::HTML_Widget.new(:width=>512, :height=>384,
+ :padx=>5, :pady=>9,
+ :formcommand=>form_cmd,
+ :imagecommand=>proc{|*args|
+ image_cmd.call(1, *args)
+ },
+ :scriptcommand=>script_cmd,
+ :appletcommand=>applet_cmd,
+ :hyperlinkcommand=>hyper_cmd,
+ :fontcommand=>pick_font,
+ :appletcommand=>proc{|*args|
+ run_applet.call('small', *args)
+ },
+ :bg=>'white', :tablerelief=>:raised)
+
+html.token_handler('meta', proc{|*args| meta.call(html, *args)})
+
+vscr = html.yscrollbar(TkScrollbar.new)
+hscr = html.xscrollbar(TkScrollbar.new)
+
+Tk.grid(html, vscr, :sticky=>:news)
+Tk.grid(hscr, :sticky=>:ew)
+Tk.root.grid_columnconfigure(0, :weight=>1)
+Tk.root.grid_columnconfigure(1, :weight=>0)
+Tk.root.grid_rowconfigure(0, :weight=>1)
+Tk.root.grid_rowconfigure(1, :weight=>0)
+
+
+############################################
+
+html.clipwin.focus
+
+# If an arguent was specified, read it into the HTML widget.
+#
+Tk.update
+if file && file != ""
+ load_file.call(file)
+end
+
+############################################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt b/ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt
new file mode 100644
index 0000000000..dd176a7ccf
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt
@@ -0,0 +1,52 @@
+
+ #######################################################################
+ ### The following text is the original 'license.txt' of tktable ###
+ ### extension. ###
+ ### Original Tcl source files are not include in this directry, ###
+ ### because of all of them are rewrited to Ruby files. ###
+ ### However, the image data file is quoted from iwidgets source ###
+ ### archive. ###
+ #######################################################################
+
+
+ * COPYRIGHT AND LICENSE TERMS *
+
+(This file blatantly stolen from Tcl/Tk license and adapted - thus assume
+it falls under similar license terms).
+
+This software is copyrighted by Jeffrey Hobbs <jeff.hobbs@acm.org>. The
+following terms apply to all files associated with the software unless
+explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute, and
+license this software and its documentation for any purpose, provided that
+existing copyright notices are retained in all copies and that this notice
+is included verbatim in any distributions. No written agreement, license,
+or royalty fee is required for any of the authorized uses.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
+EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS
+PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
+OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+RESTRICTED RIGHTS: Use, duplication or disclosure by the U.S. government
+is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
+of the Rights in Technical Data and Computer Software Clause as DFARS
+252.227-7013 and FAR 52.227-19.
+
+SPECIAL NOTES:
+
+This software also falls under the bourbon_ware clause:
+
+ Should you find this software useful in your daily work, you should
+ feel obliged to take the author out for a drink if the opportunity
+ presents itself. The user may feel exempt from this clause if they
+ are under 21 or think the author has already partaken of too many
+ drinks.
diff --git a/ext/tk/sample/tkextlib/tktable/basic.rb b/ext/tk/sample/tkextlib/tktable/basic.rb
new file mode 100644
index 0000000000..ece46b318e
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/basic.rb
@@ -0,0 +1,60 @@
+#!/usr/bin/env ruby
+##
+## basic.rb
+##
+## This demo shows the basic use of the table widget
+##
+## ( based on 'basic.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+ary = TkVariable.new_hash
+rows = 8
+cols = 8
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ ary[x,y] = "r#{x},c#{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable v1 Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary,
+ :width=>6, :height=>6,
+ :titlerows=>1, :titlecols=>2,
+ :roworigin=>-1, :colorigin=>-2,
+ :rowstretchmode=>:last, :colstretchmode=>:last,
+ :rowtagcommand=>proc{|row|
+ row = Integer(row)
+ return 'OddRow' if row>0 && row%2 == 1
+ },
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ return 'OddCol' if col>0 && col%2 == 1
+ },
+ :selectmode=>:extended, :sparsearray=>false)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :columnspan=>2)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+table.tag_configure('OddRow', :bg=>'orange', :fg=>'purple')
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+
+table.set_width([-2, 7], [-1, 7], [1, 5], [2, 8], [4, 14])
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/buttons.rb b/ext/tk/sample/tkextlib/tktable/buttons.rb
new file mode 100644
index 0000000000..b21e8673c2
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/buttons.rb
@@ -0,0 +1,76 @@
+#!/usr/bin/env ruby
+##
+## buttons.rb
+##
+## demonstrates the simulation of a button array
+##
+## ( based on 'buttons.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+# create the table
+tab = TkVariable.new_hash
+rows = 20
+cols = 20
+
+table = Tk::TkTable.new(:rows=>rows + 1, :cols=>cols + 1,
+ :variable=>tab, :titlerows=>1, :titlecols=>1,
+ :roworigin=>-1, :colorigin=>-1,
+ :colwidth=>4, :width=>8, :height=>8,
+ :cursor=>'top_left_arrow', :borderwidth=>2,
+ :flashmode=>false, :state=>:disabled)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(0, :weight=>1)
+
+# set up tags for the various states of the buttons
+table.tag_configure('OFF', :bg=>'red', :relief=>:raised)
+table.tag_configure('ON', :bg=>'green', :relief=>:sunken)
+table.tag_configure('sel', :bg=>'gray75', :relief=>:flat)
+
+# clean up if mouse leaves the widget
+table.bind('Leave', proc{|w| w.selection_clear_all}, '%W')
+
+# highlight the cell under the mouse
+table.bind('Motion', proc{|w, x, y|
+ Tk.callback_break if w.selection_include?(TkComm._at(x,y))
+ w.selection_clear_all
+ w.selection_set(TkComm._at(x,y))
+ Tk.callback_break
+ ## "break" prevents the call to tkTableCheckBorder
+ }, '%W %x %y')
+
+# mousebutton 1 toggles the value of the cell
+# use of "selection includes" would work here
+table.bind('1', proc{|w, x, y|
+ #rc = w.curselection[0]
+ rc = w.index(TkComm._at(x,y))
+ if tab[rc] == 'ON'
+ tab[rc] = 'OFF'
+ w.tag_cell('OFF', rc)
+ else
+ tab[rc] = 'ON'
+ w.tag_cell('ON', rc)
+ end}, '%W %x %y')
+
+
+# inititialize the array, titles, and celltags
+0.step(rows){|i|
+ tab[i,-1] = i
+ 0.step(cols){|j|
+ if i == 0
+ tab[-1,j] = j
+ end
+ tab[i,j] = "OFF"
+ table.tag_cell('OFF', "#{i},#{j}")
+ }
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/command.rb b/ext/tk/sample/tkextlib/tktable/command.rb
new file mode 100644
index 0000000000..eb9ddffb78
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/command.rb
@@ -0,0 +1,89 @@
+#!/usr/bin/env ruby
+##
+## command.rb
+##
+## This demo shows the use of the table widget's -command options
+##
+## ( based on 'command.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+# create the table
+data = TkVariable.new_hash
+rows = 10
+cols = 10
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ data[x,y] = "#{x} x #{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable :command Example")
+cur_var = TkVariable.new
+current = TkLabel.new(:textvariable=>cur_var, :width=>5)
+ent_var = TkVariable.new
+entry = TkEntry.new(:textvariable=>ent_var)
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols,
+ :command=>[proc{|mode, cell, val|
+ if (mode == :w)
+ data[cell] = val
+ else
+ begin
+ data[cell] # exist
+ rescue
+ '' # not exist
+ end
+ end
+ }, '%i %C %s'],
+ :width=>6, :height=>6,
+ :titlerows=>1, :titlecols=>1,
+ :roworigin=>-1, :colorigin=>-1,
+ :rowstretchmode=>:last, :colstretchmode=>:last,
+ :rowtagcommand=>proc{|row|
+ row = Integer(row)
+ return 'OddRow' if row>0 && row%2 == 1
+ },
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ return 'OddCol' if col>0 && col%2 == 1
+ },
+ :selectmode=>:extended, :flashmode=>true,
+ :rowstretch=>:unset, :colstretch=>:unset,
+ :browsecommand=>[proc{|w, s|
+ cur_var.value = s
+ ent_var.value = w.get(s)
+ }, '%W %S'],
+ :validate=>true,
+ :validatecommand=>proc{|e|
+ ent_var.value = e.new_value; true
+ })
+=begin
+ :validatecommand=>[
+ proc{|s|
+ ent_var.value = s; true
+ }, '%S'])
+=end
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+entry.bind('Return', proc{|w| table.curvalue = w.value}, '%W')
+
+Tk.grid(lbl, '-', '-', :sticky=>:ew)
+Tk.grid(current, entry, '-', :sticky=>:ew)
+Tk.grid(table, '-', sy, :sticky=>:news)
+Tk.grid(sx, '-', :sticky=>:ew)
+
+Tk.root.grid_columnconfig(1, :weight=>1)
+Tk.root.grid_rowconfig(2, :weight=>1)
+
+table.tag_configure('OddRow', :bg=>'orange', :fg=>'purple')
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+
+puts "Table is #{table.path}"
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/debug.rb b/ext/tk/sample/tkextlib/tktable/debug.rb
new file mode 100644
index 0000000000..3200c1c77a
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/debug.rb
@@ -0,0 +1,101 @@
+#!/usr/bin/env ruby
+##
+## debug.rb
+##
+## This demo uses most features of the table widget
+##
+## ( based on 'debug.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+# create the table
+ary = TkVariable.new_hash
+rows = 25
+cols = 20
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ ary[x,y] = "r#{x},c#{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable v2 Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary,
+ :width=>6, :height=>6,
+ :titlerows=>1, :titlecols=>2,
+ :roworigin=>-5, :colorigin=>-2,
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ return 'OddCol' if col>0 && col%2 == 1
+ },
+ :selectmode=>:extended, :flashmode=>true,
+ :rowstretch=>:unset, :colstretch=>:unset,
+ :selecttitles=>false, :drawmode=>:single)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :columnspan=>2)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+table.tag_configure('title', :bg=>'red', :fg=>'green', :relief=>:sunken)
+table.tag_configure('dis', :state=>:disabled)
+
+first = table[:colorigin]
+%w(n s e w nw ne sw se c).each_with_index{|anchor, idx|
+ table.tag_configure(anchor, :anchor=>anchor)
+ table.tag_row(anchor, idx)
+ table.set([idx,first], anchor)
+}
+courier = TkFont.new(:family=>'Courier', :size=>10)
+table.tag_configure('s', :font=>courier, :justify=>:center)
+
+logo = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), 'tcllogo.gif'))
+table.tag_configure('logo', :image=>logo, :showtext=>true)
+table.tag_cell('logo', [1,2], [2,3], [4,1])
+table.tag_cell('dis', [2,1], [1,-1], [3,0])
+table.set_width([-2,8], [-1,9], [0, 12], [4, 14])
+
+table.set([1,1], "multi-line\ntext\nmight be\ninteresting",
+ [3,2], "more\nmulti-line\nplaying\n",
+ [2,2], "null\0byte")
+
+# This is in the row span
+l = TkLabel.new(table, :text=>'Window s', :bg=>'yellow')
+table.window_configure([6,0], :sticky=>:s, :window=>l)
+
+# This is in the row titles
+l = TkLabel.new(table, :text=>'Window ne', :bg=>'yellow')
+table.window_configure([4,-1], :sticky=>:ne, :window=>l)
+
+# This will get swallowed by a span
+l = TkLabel.new(table, :text=>'Window ew', :bg=>'yellow')
+table.window_configure([5,3], :sticky=>:ew, :window=>l)
+
+# This is in the col titles
+l = TkLabel.new(table, :text=>'Window news', :bg=>'yellow')
+table.window_configure([-5,1], :sticky=>:news, :window=>l)
+
+l = TkLabel.new(table.winfo_parent, :text=>'Sibling l', :bg=>'orange')
+table.window_configure([5,1], :sticky=>:news, :window=>l)
+
+if table.span_list.empty?
+ table.set_spans([-1,-2], [0,3], [1,2], [0,5], [3,2], [2,2], [6,0], [4,0])
+end
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+# table.postscript(:file=>'out.ps', :first=>:origin, :last=>[2,2])
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/dynarows.rb b/ext/tk/sample/tkextlib/tktable/dynarows.rb
new file mode 100644
index 0000000000..d083e26559
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/dynarows.rb
@@ -0,0 +1,99 @@
+#!/usr/bin/env ruby
+##
+## dynarows.rb
+##
+## This demos shows the use of the validation mechanism of the table
+## and uses the table's cache (no -command or -variable) with a cute
+## dynamic row routine.
+##
+## ( based on 'dynarows.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+def table_validate(w, idx)
+ return unless idx =~ /^(\d+),(\d+)$/
+ row = Integer($1)
+ col = Integer($2)
+ val = w.get(idx)
+
+ [w, idx]
+ nrows = w[:rows]
+ return if row == nrows - 1 && val == ''
+
+ begin
+ time = Tk.tk_call('clock', 'scan', val)
+ date = []
+ Tk.tk_call('clock', 'format', time,
+ :format=>'%m %d %Y').split(' ').each{|item|
+ date << item.sub(/^\s*0*/,'')
+ }
+ w.set(idx, date.join('/'))
+ if row == nrows - 1
+ if w.get([row,1]) != '' && w.get([row,2]) != ''
+ w.tag_row_reset(row)
+ w.set([row,0], row)
+ nrows += 1
+ row += 1
+ w.configure(:rows=>nrows)
+ w.tag_row('unset', row)
+ w.set([row,0], '*')
+ w.see([row,1])
+ w.activate([row,1])
+ end
+ end
+ rescue
+ Tk.bell
+ w.activate(idx)
+ w.selection_clear_all
+ w.selection_set(:active)
+ w.see(:active)
+ end
+end
+
+
+lbl = TkLabel.new(:text=>"Dynamic Date Validated Rows")
+
+table = Tk::TkTable.new(:rows=>2, :cols=>3, :cache=>1, :selecttype=>:row,
+ :titlerows=>1, :titlecols=>1, :height=>5,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :autoclear=>true,
+ :browsecommand=>[
+ proc{|w,s| table_validate(w, s)},
+ '%W %s'
+ ])
+table.set([0,1], 'Begin', [0,2], 'End', [1,0], '*')
+table.tag_configure('unset', :fg=>'#008811')
+table.tag_configure('title', :fg=>'red')
+table.tag_row('unset', 1)
+table.set_width(0,3)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+rtn_proc = proc{|w|
+ r = w.row_index(:active)
+ c = w.col_index(:active)
+
+ if c == 2
+ r += 1
+ w.activate([r,1])
+ else
+ c += 1
+ w.activate([r,c])
+ end
+ w.see(:active)
+ Tk.callback_break
+}
+
+table.bind('Return', rtn_proc, '%W')
+table.bind('KP_Enter', rtn_proc, '%W')
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/maxsize.rb b/ext/tk/sample/tkextlib/tktable/maxsize.rb
new file mode 100644
index 0000000000..c9ca745ee5
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/maxsize.rb
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+##
+## maxsize.rb
+##
+## This demo uses a really big table. The big startup time is in
+## filling the table's Tcl array var.
+##
+## ( based on 'maxsize.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+ary = TkVariable.new_hash
+rows = 40000
+cols = 10
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ ary[x,y] = "#{x},#{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable v2 Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary,
+ :width=>6, :height=>8,
+ :titlerows=>1, :titlecols=>1,
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ return 'OddCol' if col>0 && col%2 == 1
+ },
+ :selectmode=>:extended,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :selecttitles=>false, :drawmode=>:slow)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :columnspan=>2)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+table.tag_configure('title', :bg=>'red', :fg=>'blue', :relief=>:sunken)
+table.tag_configure('dis', :state=>:disabled)
+
+first = table[:colorigin]
+%w(n s e w nw ne sw se c).each_with_index{|anchor, idx|
+ table.tag_configure(anchor, :anchor=>anchor)
+ table.tag_row(anchor, idx)
+ table.set([idx,first], anchor)
+}
+courier = TkFont.new(:family=>'Courier', :size=>10)
+table.tag_configure('s', :font=>courier, :justify=>:center)
+
+table.set_width([-2, 8], [-1, 9], [0, 12], [4, 14])
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/spreadsheet.rb b/ext/tk/sample/tkextlib/tktable/spreadsheet.rb
new file mode 100644
index 0000000000..9da896f5a7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/spreadsheet.rb
@@ -0,0 +1,137 @@
+#!/usr/bin/env ruby
+##
+## spreadsheet.rb
+##
+## This demos shows how you can simulate a 3D table
+## and has other basic features to begin a basic spreadsheet
+##
+## ( based on 'spreadsheet.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+rows = 10
+cols = 10
+cur_var = TkVariable.new
+table_list = Hash.new{|hash, key| hash[key] = TkVariable.new_hash}
+page = TkVariable.new('AA')
+color = Hash.new('pink')
+color['AA'] = 'orange'
+color['BB'] = 'blue'
+color['CC'] = 'green'
+
+def colorize(num)
+ num = Integer(num)
+ return 'colored' if (num > 0 && num % 2 == 1)
+end
+
+def fill_table(tbl_list, page, r=10, c=10)
+ ary = tbl_list[page]
+
+ (0...r).each{|i|
+ (0...c).each{|j|
+ if i!=0 && j!=0
+ ary[i,j] = "#{page} #{i},#{j}"
+ elsif i!=0
+ ary[i,j] = i.to_s
+ else
+ ary[i,j] = (64+j).chr
+ end
+ }
+ }
+end
+
+def changepage(tbl_list, tbl, ent, col, var, elem, op)
+ if elem != ''
+ page = var[elem]
+ else
+ page = var.value
+ end
+ if tbl[:variable] != tbl_list[page].id
+ tbl.selection_clear_all
+ tbl.variable(tbl_list[page])
+ ent.textvariable(tbl_list[page].ref('active'))
+ tbl.activate('origin')
+ tbl.tag_configure('colored', :bg=>col[page])
+ tbl.see('active')
+ end
+end
+
+lbl = TkLabel.new(:text=>"TkTable v1 Spreadsheet Example")
+
+current = TkLabel.new(:textvariable=>cur_var, :width=>5)
+entry = TkEntry.new(:textvariable=>table_list[page.value].ref('active'))
+lpage = TkLabel.new(:text=>'PAGE:', :width=>6, :anchor=>:e)
+optmenu = TkOptionMenubutton.new(page, *(%w(AA BB CC DD)))
+
+fill_table(table_list, page.value)
+fill_table(table_list, 'BB', Integer(rows/2), Integer(cols/2))
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :width=>5, :height=>5,
+ :variable=>table_list[page.value],
+ :titlerows=>1, :titlecols=>1,
+ :coltagcommand=>proc{|n| colorize(n)},
+ :flashmode=>true, :selectmode=>:extended,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :browsecommand=>proc{|e| cur_var.value = e.new_index})
+
+page.trace(:w, proc{|var, elem, op|
+ changepage(table_list, table, entry, color, var, elem, op)
+ })
+
+table.tag_configure('colored', :bg=>color[page.value])
+table.tag_configure('title', :fg=>'red', :relief=>:groove)
+table.tag_configure('blue', :bg=>'blue')
+table.tag_configure('green', :bg=>'green')
+
+table.tag_cell('green', [6,3], [5,7], [4,9])
+table.tag_cell('blue', [8,8])
+table.tag_row('blue', 7)
+table.tag_col('blue', 6, 8)
+table.set_width([0, 3], [2, 7])
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', '-', '-', '-', :sticky=>:ew)
+Tk.grid(current, entry, lpage, optmenu, '-', :sticky=>:ew)
+Tk.grid(table, '-', '-', '-', sy, :sticky=>:ns)
+Tk.grid(sx, '-', '-', '-', :sticky=>:ew)
+Tk.grid(btn, '-', '-', '-', '-', :sticky=>:ew)
+
+Tk.root.grid_columnconfig(1, :weight=>1)
+Tk.root.grid_rowconfig(2, :weight=>1)
+
+table.grid_configure(:sticky=>:news)
+
+entry.bind('Return', proc{
+ r = table.row_index(:active)
+ c = table.col_index(:active)
+ rmax = table[:rows]
+ cmax = table[:cols]
+
+ c += 1
+ if c == cmax
+ c = table[:titlecols]
+ r += 1
+ if r == rmax
+ r = table[:titlerows]
+ end
+ end
+ table.activate([r, c])
+ table.see('active')
+ })
+
+menu = TkMenu.new
+m_file = TkMenu.new(menu)
+Tk.root.menu(menu)
+menu.add(:cascade, :label=>'File', :underline=>0, :menu=>m_file)
+m_file.add(:command, :label=>'Fill Array',
+ :command=>proc{ fill_table(table_list, page.value) })
+m_file.add(:command, :label=>'Quit', :command=>proc{exit})
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/tktable/tcllogo.gif b/ext/tk/sample/tkextlib/tktable/tcllogo.gif
new file mode 100755
index 0000000000..4603d4ff41
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/tcllogo.gif
Binary files differ
diff --git a/ext/tk/sample/tkextlib/tktable/valid.rb b/ext/tk/sample/tkextlib/tktable/valid.rb
new file mode 100644
index 0000000000..e5d3f11d84
--- /dev/null
+++ b/ext/tk/sample/tkextlib/tktable/valid.rb
@@ -0,0 +1,88 @@
+#!/usr/bin/env ruby
+##
+## valid.rb
+##
+## This demos shows the use of the validation mechanism of the table
+## and uses the table's cache (no -command or -variable)
+##
+## ( based on 'valid.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+rows = 10
+cols = 10
+
+def colorize(num)
+ num = Integer(num)
+ return 'colored' if (num > 0 && num % 2 == 1)
+end
+
+def fill_headers(w, r=10, c=10)
+ (1..(r-1)).each{|i| w.set([i,0], i.to_s)}
+
+ (1..(c-1)).each{|j|
+ if j % 3 == 1
+ w.set([0,j], 'AlphaNum')
+ elsif j % 2 == 1
+ w.set([0,j], 'Alpha')
+ elsif j != 0
+ w.set([0,j], 'Real')
+ end
+ }
+end
+
+def validate_proc(c, val)
+ if c % 3 == 1
+ # AlphaNum
+ regexp = /^[A-Za-z0-9 ]*$/
+ elsif c % 2 == 1
+ # Alpha
+ regexp = /^[A-Za-z ]*$/
+ elsif c != 0
+ # 'Real'
+ regexp = /^[-+]?[0-9]*\.?[0-9]*([0-9]\.?e[-+]?[0-9]*)?$/
+ end
+ if val =~ regexp
+ return true
+ else
+ Tk.bell
+ return false
+ end
+end
+
+lbl = TkLabel.new(:text=>"TkTable v1 Validated Table Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :cache=>1,
+ :width=>5, :height=>5, :titlerows=>1, :titlecols=>1,
+ :coltagcommand=>proc{|n| colorize(n)},
+ :flashmode=>true, :selectmode=>:extended,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :validate=>true,
+ :validatecommand=>proc{|e|
+ unless e.widget.tag_include?('title', e.index)
+ validate_proc(e.column, e.new_value)
+ end } )
+
+fill_headers(table)
+
+table.tag_configure('colored', :bg=>'lightblue')
+table.tag_configure('title', :fg=>'red')
+table.set_width(0,3)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, '-', :sticky=>:ew)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+puts "Table is #{table.path}"
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt b/ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt
new file mode 100644
index 0000000000..f5f2f770cf
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt
@@ -0,0 +1,51 @@
+
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ >>> The following text is the original 'license.txt' of vu extension. <<<
+ >>> Original Tcl source files are not include in this directry, <<<
+ >>> because of all of them are rewrited to Ruby files. <<<
+ >>> However, the bitmap data file included in this directory is the <<<
+ >>> same file of vu extension. So, the bitmap data file is under the <<<
+ >>> following license. <<<
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+ * COPYRIGHT AND LICENSE TERMS *
+
+(This file blatantly stolen from Tcl/Tk license and adapted - thus assume
+it falls under similar license terms).
+
+This software is copyrighted by Jeffrey Hobbs <jeff.hobbs@acm.org> and
+others. The following terms apply to all files associated with the
+software unless explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute, and
+license this software and its documentation for any purpose, provided that
+existing copyright notices are retained in all copies and that this notice
+is included verbatim in any distributions. No written agreement, license,
+or royalty fee is required for any of the authorized uses.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
+EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS
+PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
+OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+RESTRICTED RIGHTS: Use, duplication or disclosure by the U.S. government
+is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
+of the Rights in Technical Data and Computer Software Clause as DFARS
+252.227-7013 and FAR 52.227-19.
+
+SPECIAL NOTES:
+
+This software also falls under the bourbon_ware clause:
+
+ Should you find this software useful in your daily work, you should
+ feel obliged to take the author out for a drink if the opportunity
+ presents itself. The user may feel exempt from this clause if they
+ are under 21 or think the author has already partaken of too many
+ drinks.
diff --git a/ext/tk/sample/tkextlib/vu/README.txt b/ext/tk/sample/tkextlib/vu/README.txt
new file mode 100644
index 0000000000..ce5f371fac
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/README.txt
@@ -0,0 +1,50 @@
+
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ >>> The following text is the original 'README.txt' of <<<
+ >>> vu extension demos. <<<
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+##
+## DESCRIPTION OF DEMOS
+##
+
+canvItems.tcl
+ old demo of all canvas chart items, useful to find memory leaks.
+ <1> prints out the additional memory usage (charts.so + script)
+
+canvSticker.tcl
+ Heribert Dahms original "demo.tcl"
+ <p> creates DEMO.ps
+
+canvSticker2.tcl
+ compares "sticker" and "text"; press <1>, <2> or <1> ...
+ <p> creates DEMO.ps
+
+dial.tcl
+ demo of variations of the dial widget.
+
+load.tcl
+ Just a utility file, not a real demo.
+
+m128_000.xbm
+ XBM pic used by sticker and canvItems demos
+
+oscilloscope.tcl
+ the heart of a Realtime Oscilloscope,where the PC´s joystick
+ port gives 4 digtal inputs and 4 analog 8 bit values with an
+ resolution of ~1 millisecond (!!!) running Realtime Linux.
+ <p> creates DEMO.ps
+
+pie.tcl
+ The magic 3D spinning pie chart!
+
+vu.tcl
+ demo fo Vu widgets
+
+canvLabel.tcl
+ 'label' is a canvas item just like 'text', but with -angle
+ rotation of the string. This is not built in by default, as
+ it requires the internal Tk headers.
+ press <1>, <2> or <1> ...
+ <p> creates DEMO.ps
+
diff --git a/ext/tk/sample/tkextlib/vu/canvItems.rb b/ext/tk/sample/tkextlib/vu/canvItems.rb
new file mode 100644
index 0000000000..33acf4f7e7
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/canvItems.rb
@@ -0,0 +1,90 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#######################################
+
+xbm = File.join(File.dirname(File.expand_path(__FILE__)), 'm128_000.xbm')
+
+sval = [ 11, 22, 33, 44, 55, 66, 77, 88, 99 ]
+
+l0 = TkLabel.new(:width=>128, :height=>128,
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+
+c0 = TkCanvas.new(:width=>80, :height=>80,
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l0, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
+
+st = Tk::Vu::TkcStripchart.new(c0, 3, 3, 80, 80,
+ :background=>"#b7c0d7", :fill=>'slategray3',
+ :jumpscroll=>1, :outline=>'black',
+ :scaleline=>'blue', :stripline=>'red',
+ :selected=>1, :values=>sval)
+
+TkcText.create(c0, 40, 40,
+ :text=>Tk::TCL_PATCHLEVEL, :fill=>'cyan', :tags=>'text')
+
+
+l1 = TkLabel.new(:width=>128, :height=>128,
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+
+c1 = TkCanvas.new(:width=>80, :height=>80,
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l1, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
+
+bar1 = Tk::Vu::TkcBarchart.new(c1, 3, 3, 80, 80,
+ :background=>"#b7c0d7", :scalevalue=>10.0,
+ :autocolor=>true, :selected=>1,
+ :outline=>'black', :barline=>'yellow',
+ :scalelinestyle=>0)
+
+bar2 = Tk::Vu::TkcBarchart.new(c1, 53, 3, 80, 80,
+ :background=>"#b7c0d7", :scalevalue=>10.0,
+ :autocolor=>true, :selected=>1,
+ :outline=>'black', :fill=>"#b7c0d7",
+ :barline=>'red', :scalelinestyle=>22)
+
+
+l2 = TkLabel.new(:width=>128, :height=>128,
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+
+c2 = TkCanvas.new(:width=>80, :height=>80,
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l2, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
+
+begin
+ stick = Tk::Vu::TkcSticker.new(c2, 3, 3, 80, 80,
+ :text=>"Tcl/Tk", :space=>0, :color=>'red',
+ :outline=>'red', :font=>'Helvetica 14 bold',
+ :fill=>'', :stipple=>'', :bar=>'blue',
+ :orient=>:vertical, :anchor=>:s,
+ :relheight=>1.0, :relwidth=>0.15,
+ :relx=>0.1, :rely=>0.0)
+rescue
+ stick = nil
+ TkcText.new(c2, 40, 10, :text=>"No Sticker Item")
+end
+
+c_do = proc{
+ st[:values] = rand() * 100
+
+ bar1[:values] = rand() * 10
+ bar2[:values] = rand() * 10
+
+ stick[:rely] = rand() * 100 * 0.01 if stick
+}
+
+c0.bind('1', c_do)
+
+TkTimer.new(100, -1, c_do).start
+
+Tk.root.bind('q', proc{exit})
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/canvSticker.rb b/ext/tk/sample/tkextlib/vu/canvSticker.rb
new file mode 100644
index 0000000000..e2cd604975
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/canvSticker.rb
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#######################################
+
+Tk.root.geometry('+30+30')
+
+delay = 2000
+
+c = TkCanvas.new.pack
+
+begin
+ st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
+rescue
+ Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
+ :message=>"This build of vu does not include the sticker item")
+ exit
+end
+#st.delete
+
+steps = []
+
+steps << proc{
+ # I used a 75dpi screen for testing, but others should make no difference!
+ puts 'You\'ll see a small upright rectangle with "He" inside.'
+ st = Tk::Vu::TkcSticker.new(c, '6m', '10m', '13m', '27m', :text=>'Hello')
+}
+
+steps << proc{
+ puts 'You\'ll see the whole "Hello" drawn rotated 90 degrees.'
+ st[:orient] = :vertical
+}
+
+steps << proc{
+ puts 'The rectangle shrinks and the text is clipped to "Hell"'
+ #st.coords('6m', '10m', '13m', '20m')
+ st.coords('6m', '10m', '13m', '17m')
+}
+
+steps << proc{
+ puts 'Now you\'ll read "ello"'
+ st[:lefttrunc] = true
+}
+
+steps << proc{
+ puts 'Enlarging the rectangle shows the complete "Hello" again'
+ st.scale(0, 0, 3, 3)
+}
+
+steps << proc{
+ puts 'This time the text is repeated: "Hello", approx. 5mm space, "Hello"'
+ st[:space] = '5m'
+}
+
+steps << proc{
+ puts 'A vertical bar appears in the lower right region and text jumps to the left.'
+ st.configure(:anchor=>:n, :relw=>0.3, :relh=>0.7,
+ :relx=>0.6, :rely=>0.3, :bar=>'red')
+}
+
+steps << proc{
+ puts 'Paint the backgound.'
+ st[:fill] = 'yellow'
+}
+
+steps << proc{
+ puts "Let's test stippling."
+ st[:stipple] = 'gray25'
+}
+
+steps << proc{
+ puts 'Finally a large outline forces a single "Hello" and shrinks the bar.'
+ st[:width] = '6m'
+}
+
+Tk.root.bind('q', proc{exit})
+
+TkTimer.new(delay, 1, *steps).start
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/canvSticker2.rb b/ext/tk/sample/tkextlib/vu/canvSticker2.rb
new file mode 100644
index 0000000000..f54e748660
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/canvSticker2.rb
@@ -0,0 +1,99 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#######################################
+
+c = TkCanvas.new.pack
+
+begin
+ st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
+rescue
+ Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
+ :message=>"This build of vu does not include the sticker item")
+ exit
+end
+
+c.destroy
+
+#---
+#--- set STRING {{x0 y0 x1 y1} {...text...} {resize point: center}
+
+#sti_conf = [ [10, 10, 180, 180], "Sticker äöüß@²³¼½¾", :center ]
+#txt_conf = [ [210, 210], "Text äöüß@²³¼½¾", :center ]
+sti_conf = [ [10, 10, 350, 350],
+ Tk::UTF8_String("Sticker äöüß@²³¼½¾"), :center ]
+txt_conf = [ [250, 250],
+ Tk::UTF8_String("Text äöüß@²³¼½¾"), :center ]
+
+p sti_conf
+
+fnt = TkFont.new('Helvetica 24 bold')
+
+#---GUI
+c = TkCanvas.new(:width=>500, :height=>500, :bg=>'aquamarine3').pack
+
+#---CRRW Use the technique of eval the coord ...
+sti = Tk::Vu::TkcSticker.new(c, sti_conf[0]){
+ anchor sti_conf[2]
+ bar 'black'
+ color 'red'
+ fill ''
+ font fnt
+ lefttrunc 0
+ outline ''
+ relheight 0.0
+ relwidth 0.0
+ relx 0.0
+ rely 0.0
+ space 0
+ stipple ''
+ tags 'sti'
+ text sti_conf[1]
+ width 0
+ orient :vertical
+ minwidth 0
+ minheight 0
+ maxwidth 32767
+ maxheight 32767
+}
+
+txt = TkcText.new(c, txt_conf[0]){
+ activefill ''
+ activestipple ''
+ anchor txt_conf[2]
+ disabledfill ''
+ disabledstipple ''
+ fill 'blue'
+ font fnt
+ justify :left
+ offset '0,0'
+ state ''
+ stipple ''
+ tags ['tex']
+ text txt_conf[1]
+ width 0
+}
+
+#---BINDINGS
+c.bind('2', proc{
+ sti[:orient] = :horizontal
+ txt[:width] = 0 # horizontal
+ })
+
+c.bind('3', proc{
+ sti[:orient] = :vertical
+ txt[:width] = 1 # top down
+ })
+
+Tk.root.bind('p', proc{
+ c.postscript(:file=>'DEMO.ps')
+ puts "DEMO.ps printed"
+ })
+
+Tk.root.bind('q', proc{exit})
+
+#####################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/dial.rb b/ext/tk/sample/tkextlib/vu/dial.rb
new file mode 100644
index 0000000000..09bd3e9186
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/dial.rb
@@ -0,0 +1,113 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/dial'
+
+#######################################
+
+v_volume = TkVariable.new
+v_speed = TkVariable.new
+v_dir = TkVariable.new
+v_rot = TkVariable.new
+v_linked = TkVariable.new
+v_needle = TkVariable.new
+
+volume = Tk::Vu::Dial.new(:label=>"Volume", :from=>-0.1, :to=>0.1,
+ :resolution=>0.001, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :beginangle=>-20,
+ :endangle=>260, :variable=>v_volume)
+
+speed = Tk::Vu::Dial.new(:label=>"Speed", :from=>2000, :to=>100,
+ :resolution=>10, :tickinterval=>100,
+ :minortickinterval=>0, :variable=>v_speed,
+ :showtags=>:label, :showvalue=>false)
+
+speed.set_tag_constrain(100, 'Fast', 2000, 'Slow')
+
+fwd = Tk::Vu::Dial.new(:from=>-10.0, :to=>-20.0, :resolution=>0.1,
+ :tickinterval=>5.0, :minortickinterval=>1.0,
+ :variable=>v_dir)
+
+rev = Tk::Vu::Dial.new(:from=>-20.0, :to=>-10.0, :resolution=>0.1,
+ :tickinterval=>5.0, :minortickinterval=>1.0,
+ :variable=>v_dir)
+
+small = Tk::Vu::Dial.new(:font=>"Helvetica -10", :from=>0, :to=>10,
+ :resolution=>0.05, :tickinterval=>2,
+ :minortickinterval=>0.5, :radius=>20,
+ :dialcolor=>'red2', :activebackground=>'red',
+ :variable=>v_rot)
+
+large = Tk::Vu::Dial.new(:font=>"Helvetica -8", :from=>0, :to=>10,
+ :resolution=>0.05, :tickinterval=>1,
+ :minortickinterval=>0.25, :radius=>40,
+ :dialcolor=>'red2', :activebackground=>'red',
+ :variable=>v_rot)
+
+turn = Tk::Vu::Dial.new(:needlecolor=>'red', :label=>"Linked",
+ :variable=>v_linked)
+
+scale = TkScale.new(:label=>"Linked", :variable=>v_linked)
+
+d1 = Tk::Vu::Dial.new(:resolution=>0.0001, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :relief=>:raised)
+
+d2 = Tk::Vu::Dial.new(:resolution=>0.01, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial 2",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :dialrelief=>:flat, :needlecolor=>'red',
+ :needletype=>:triangle, :relief=>:sunken)
+
+d3 = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial 3",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :dialrelief=>:flat, :needlecolor=>'blue',
+ :needletype=>:arc, :relief=>:ridge)
+
+f_btns = TkFrame.new
+f_sep = TkFrame.new(:height=>2, :relief=>:sunken, :bd=>1)
+
+
+v_volume.value = -0.1
+v_speed.value = 500
+
+update = TkTimer.new(proc{v_speed.numeric}, -1, proc{
+ if v_volume == volume[:to]
+ v_volume.numeric = volume[:from]
+ else
+ v_volume.numeric += volume[:resolution]
+ end
+ })
+
+b_start = TkButton.new(:text=>"Start", :command=>proc{update.start})
+b_stop = TkButton.new(:text=>"Stop", :command=>proc{update.stop})
+b_exit = TkButton.new(:text=>"Exit", :command=>proc{exit})
+
+Tk.grid(b_start, :in=>f_btns, :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.grid(b_stop, :in=>f_btns, :sticky=>:ew, :padx=>4, :pady=>4)
+f_btns.grid_columnconfigure(0, :weight=>1)
+
+Tk.grid(f_btns, speed, volume, :sticky=>:news)
+Tk.grid(f_sep, '-', '-', :sticky=>:news)
+Tk.grid(fwd, rev, d1, :sticky=>:news)
+Tk.grid(small, large, d2, :sticky=>:news)
+Tk.grid(turn, scale, d3, :sticky=>:news)
+
+Tk.grid(b_exit, '-', '-', :sticky=>:ew, :padx=>4, :pady=>4)
+
+Tk.root.grid_columnconfigure(0, :weight=>1)
+Tk.root.grid_columnconfigure(1, :weight=>1)
+Tk.root.grid_columnconfigure(2, :weight=>1)
+
+Tk.root.grid_rowconfigure(0, :weight=>1)
+Tk.root.grid_rowconfigure(2, :weight=>1)
+Tk.root.grid_rowconfigure(3, :weight=>1)
+Tk.root.grid_rowconfigure(4, :weight=>1)
+
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/m128_000.xbm b/ext/tk/sample/tkextlib/vu/m128_000.xbm
new file mode 100644
index 0000000000..455e3c5e0f
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/m128_000.xbm
@@ -0,0 +1,174 @@
+#define m128_000_width 128
+#define m128_000_height 128
+static unsigned char m128_000_bits[] = {
+ 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x03, 0xfc, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xea, 0x0f, 0xfc, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xd5, 0x0f,
+ 0xbf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3f, 0x7f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3f, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d,
+ 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e,
+ 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d,
+ 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d,
+ 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e,
+ 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d,
+ 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xbf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3f, 0x7f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3f,
+ 0xfc, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xea, 0x0f, 0xfc, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xd5, 0x0f, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 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, };
diff --git a/ext/tk/sample/tkextlib/vu/oscilloscope.rb b/ext/tk/sample/tkextlib/vu/oscilloscope.rb
new file mode 100644
index 0000000000..2015e46645
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/oscilloscope.rb
@@ -0,0 +1,68 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#---USAGE
+info = "...the heart of a Realtime Oscilloscope, where the PCIs
+joystick port gives 4 digtal inputs and 4 analog 8 bit
+values with an resolution of ~1 millisecond (!!!)
+running Realtime Linux.
+<p> creates DEMO.ps
+<B1-Motion> see what happens"
+puts info
+
+#---GEOMETRY
+geo_fr = [10, 10, 210, 180]
+geo_ch0 = [10, 10, 210, 90]
+geo_ch1 = [10, 90, 210, 180]
+geo_t1 = [15, 88]
+
+#---GUI
+c = TkCanvas.new(:width=>220, :height=>190).pack(:fill=>:both, :expand=>true)
+
+#---background
+TkcRectangle.new(c, geo_fr, :width=>4, :fill=>'aquamarine3',
+ :tags=>['osc', 'frbg'])
+
+#---channel 0
+ch0 = Tk::Vu::TkcStripchart.new(c, geo_ch0,
+ :fill=>'', :jumpscroll=>false,
+ :outline=>'', :scaleline=>'',
+ :stripline=>'cyan', :tags=>['osc', 'ch0'])
+
+#---channel 1
+ch1 = Tk::Vu::TkcStripchart.new(c, geo_ch1,
+ :fill=>'', :jumpscroll=>0,
+ :outline=>'', :scaleline=>'',
+ :stripline=>'red', :tags=>['osc', 'ch1'])
+
+#---frame
+TkcRectangle.new(c, geo_fr, :width=>4, :tags=>['osc', 'frfg'])
+
+#---position
+txt1 = TkcText.new(c, geo_t1, :text=>"B1-Motion: X:%X\tY:%Y",
+ :anchor=>:nw, :tags=>['osc', 'txt1'])
+
+#---BINDINGS
+c.bind('B1-Motion', proc{|x, y, xx, yy|
+ ch0[:values] = x
+ ch1[:values] = y
+ txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}"
+ }, '%x %y %X %Y')
+
+Tk.root.bind('v', proc{
+ puts ch0[:values].join(' ')
+ puts ch0[:values].size
+ })
+
+Tk.root.bind('p', proc{
+ c.postscript(:file=>'DEMO.ps')
+ puts "DEMO.ps printed"
+ })
+
+Tk.root.bind('q', proc{exit})
+
+#####################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/pie.rb b/ext/tk/sample/tkextlib/vu/pie.rb
new file mode 100644
index 0000000000..ed598d6233
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/pie.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/pie'
+
+pie = Tk::Vu::Pie.new(:label=>"My Revolving Budget"){
+ itemconfigure('Welfare', :value=>3.004)
+ itemconfigure('Military', :value=>7.006)
+ itemconfigure('Transport', :value=>1.6, :explode=>15)
+ itemconfigure('Parks', :value=>0.9)
+ itemconfigure('Schools', :value=>2)
+ itemconfigure('Debt', :value=>4, :explode=>10)
+
+ configure(:angle=>10, :origin=>90, :shadow=>10)
+}
+
+spin = TkTimer.new(60, -1, proc{|obj|
+ pie.configure(:origin=>pie[:origin] + 1)
+})
+
+f = TkFrame.new
+fast_btn = TkButton.new(f, :text=>"Spin Faster", :command=>proc{spin.start})
+slow_btn = TkButton.new(f, :text=>"Spin Slower", :command=>proc{spin.stop})
+quit_btn = TkButton.new(f, :text=>"Exit", :command=>proc{exit})
+
+Tk.grid(pie, :sticky=>:news)
+Tk.grid(f, :sticky=>:ew)
+
+Tk.pack(fast_btn, slow_btn, quit_btn,
+ :in=>f, :side=>:left, :fill=>:both, :expand=>true, :padx=>6, :pady=>4)
+
+Tk.root.grid_columnconfigure(0, :weight=>1)
+Tk.root.grid_rowconfigure(0, :weight=>1)
+
+priv = {
+ :x=>0, :y=>0, :pie_in=>false, :angle=>pie[:angle], :origin=>pie[:origin]
+}
+
+pie.bind('ButtonPress-1', proc{|w, x, y|
+ priv[:x] = x
+ priv[:y] = y
+ priv[:pie_in] = (w.winfo_width/1.8 > x)
+ priv[:angle] = w[:angle]
+ priv[:origin] = w[:origin]
+ }, '%W %x %y')
+
+pie.bind('B1-Motion', proc{|w, x, y|
+ if priv[:pie_in]
+ w.configure(:angle=>priv[:angle] + (priv[:y] - y)/3,
+ :origin=>(priv[:origin] +
+ ((w.winfo_height/2.2 > y)? -1: 1) *
+ (priv[:x] - x)/3) % 360)
+ end
+ }, '%W %x %y')
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkextlib/vu/vu.rb b/ext/tk/sample/tkextlib/vu/vu.rb
new file mode 100644
index 0000000000..d078ae16f2
--- /dev/null
+++ b/ext/tk/sample/tkextlib/vu/vu.rb
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu'
+
+#######################################
+
+puts "Show off barchart and dial widgets"
+
+speed = TkVariable.new(0)
+
+dial = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>50, :label=>"Dial",
+ :beginangle=>-20, :endangle=>260, :dialcolor=>'red3',
+ :active=>'red2', :variable=>speed)
+
+bar = Tk::Vu::Bargraph.new(:from=>0, :to=>100, :relief=>:groove,
+ :border=>2, :label=>"Bar Chart")
+
+#######################################
+
+green = 25
+blue = 50
+purple = 75
+current = 50
+
+def rand_bool
+
+end
+
+update = TkTimer.new(200, -1, proc{
+ if (rand() - 0.5 + speed.numeric * 3) > 0
+ current += 1
+ else
+ current -= 1
+ end
+ bar.set(current)
+ if current < green
+ current = 100 if current <= 0
+ bar[:barcolor] = 'green'
+ elsif current < blue
+ bar[:barcolor] = 'blue'
+ elsif current < purple
+ bar[:barcolor] = 'purple'
+ else
+ bar[:barcolor] = 'red'
+ current = 0 if current >= 100
+ end
+ })
+
+#######################################
+
+gobar = TkButton.new(:text=>"Start", :command=>proc{update.start})
+nobar = TkButton.new(:text=>"Stop", :command=>proc{update.stop})
+quit = TkButton.new(:text=>"Exit", :command=>proc{exit})
+
+Tk.grid('x', gobar, :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.grid(dial, bar, :sticky=>:news)
+Tk.grid('x', nobar, :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.grid(quit, '-', '-', :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.root.grid_columnconfigure(2, :weight=>1)
+Tk.root.grid_rowconfigure(1, :weight=>1)
+
+#######################################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkfrom.rb b/ext/tk/sample/tkfrom.rb
index ba0e547799..2cece7337e 100644
--- a/ext/tk/sample/tkfrom.rb
+++ b/ext/tk/sample/tkfrom.rb
@@ -1,4 +1,4 @@
-#! /usr/local/bin/ruby
+#!/usr/bin/env ruby
require "parsedate"
require "base64"
@@ -20,22 +20,22 @@ class Mail
def initialize(f)
@header = {}
@body = []
- while f.gets()
+ while line = f.gets()
$_.chop!
- next if /^From / # skip From-line
- break if /^$/ # end of header
- if /^(\S+):\s*(.*)/
- @header[attr = $1.capitalize] = $2
+ next if /^From / =~ line # skip From-line
+ break if /^$/ =~ line # end of header
+ if /^(\S+):\s*(.*)/ =~ line
+ @header[attr = $1.capitalize] = $2
elsif attr
- sub(/^\s*/, '')
- @header[attr] += "\n" + $_
+ sub(/^\s*/, '')
+ @header[attr] += "\n" + $_
end
end
- return if ! $_
+ return unless $_
- while f.gets()
- break if /^From /
+ while line = f.gets()
+ break if /^From / =~ line
@body.push($_)
end
end
@@ -54,9 +54,9 @@ if ARGV.length == 0
if ENV['MAIL']
ARGV[0] = ENV['MAIL']
elsif ENV['USER']
- ARGV[0] = '/usr/spool/mail/' + ENV['USER']
+ ARGV[0] = '/var/spool/mail/' + ENV['USER']
elsif ENV['LOGNAME']
- ARGV[0] = '/usr/spool/mail/' + ENV['LOGNAME']
+ ARGV[0] = '/var/spool/mail/' + ENV['LOGNAME']
end
end
@@ -64,8 +64,8 @@ require "tk"
list = scroll = nil
TkFrame.new{|f|
list = TkListbox.new(f) {
- yscroll proc{|idx|
- scroll.set *idx
+ yscroll proc{|*idx|
+ scroll.set *idx
}
relief 'raised'
# geometry "80x5"
@@ -94,7 +94,7 @@ root.bind "space", proc{exit}
$outcount = 0;
for file in ARGV
- next if File.exist?(file)
+ next unless File.exist?(file)
atime = File.atime(file)
mtime = File.mtime(file)
f = open(file, "r")
diff --git a/ext/tk/sample/tkhello.rb b/ext/tk/sample/tkhello.rb
index 5188fe1c8c..3b505f4983 100644
--- a/ext/tk/sample/tkhello.rb
+++ b/ext/tk/sample/tkhello.rb
@@ -1,10 +1,10 @@
require "tk"
TkButton.new(nil,
- 'text' => 'hello',
- 'command' => proc{print "hello\n"}).pack('fill'=>'x')
+ :text => 'hello',
+ :command => proc{print "hello\n"}).pack(:fill=>'x')
TkButton.new(nil,
- 'text' => 'quit',
- 'command' => 'exit').pack('fill'=>'x')
+ :text => 'quit',
+ :command => proc{exit}).pack(:fill=>'x')
Tk.mainloop
diff --git a/ext/tk/sample/tkline.rb b/ext/tk/sample/tkline.rb
index 2406b0749f..3124c2fe0c 100644
--- a/ext/tk/sample/tkline.rb
+++ b/ext/tk/sample/tkline.rb
@@ -8,13 +8,15 @@ def start_random
if defined? Thread
Thread.start do
loop do
- sleep 2
- Line.new($c, rand(400), rand(200), rand(400), rand(200))
+ sleep 2
+ Line.new($c, rand(400), rand(200), rand(400), rand(200))
end
end
end
end
+Label.new('text'=>'Please press or drag button-1').pack
+
$c = Canvas.new
$c.pack
$start_x = start_y = 0
diff --git a/ext/tk/sample/tkmenubutton.rb b/ext/tk/sample/tkmenubutton.rb
new file mode 100644
index 0000000000..37f6128fd9
--- /dev/null
+++ b/ext/tk/sample/tkmenubutton.rb
@@ -0,0 +1,135 @@
+#!/usr/bin/env ruby
+#
+# menubutton sample : based on sample menubuttons on the Tcl/Tk demo script
+#
+require 'tk'
+
+TkLabel.new(:text=>'Sample of TkMenubutton').pack(:side=>:top)
+
+TkFrame.new{|f|
+ pack(:side=>:top)
+
+
+ TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0,
+ :direction=>:right, :relief=>:raised){|mb|
+ menu TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Right menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Right menu.\n"})
+ add(:command, :label=>'Right menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Right menu.\n"})
+ }
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkMenubutton.new(:parent=>f, :text=>'Below', :underline=>0,
+ :direction=>:below, :relief=>:raised){|mb|
+ menu(TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Below menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Below menu.\n"})
+ add(:command, :label=>'Below menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Below menu.\n"})
+ })
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkMenubutton.new(:parent=>f, :text=>'Above', :underline=>0,
+ :direction=>:above, :relief=>:raised){|mb|
+ menu TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Above menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Above menu.\n"})
+ add(:command, :label=>'Above menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Above menu.\n"})
+ }
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkMenubutton.new(:parent=>f, :text=>'Left', :underline=>0,
+ :direction=>:left, :relief=>:raised){|mb|
+ menu(TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Left menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Left menu.\n"})
+ add(:command, :label=>'Left menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Left menu.\n"})
+ })
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+}
+
+############################
+TkFrame.new(:borderwidth=>2, :relief=>:sunken,
+ :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
+############################
+
+TkLabel.new(:text=>'Sample of TkOptionMenu').pack(:side=>:top)
+
+colors = %w(Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50
+ Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet)
+
+TkFrame.new{|f|
+ pack(:side=>:top)
+
+ b1 = TkOptionMenubutton .
+ new(:parent=>f, :values=>%w(one two three)) .
+ pack(:side=>:left, :padx=>25, :pady=>25)
+
+ b2 = TkOptionMenubutton.new(:parent=>f, :values=>colors) {|optMB|
+ colors.each{|color|
+ no_sel = TkPhotoImage.new(:height=>16, :width=>16){
+ put 'gray50', *[ 0, 0, 16, 1]
+ put 'gray50', *[ 0, 1, 1, 16]
+ put 'gray75', *[ 0, 15, 16, 16]
+ put 'gray75', *[15, 1, 16, 16]
+ put color, *[ 1, 1, 15, 15]
+ }
+ sel = TkPhotoImage.new(:height=>16, :width=>16){
+ put 'Black', *[ 0, 0, 16, 2]
+ put 'Black', *[ 0, 2, 2, 16]
+ put 'Black', *[ 2, 14, 16, 16]
+ put 'Black', *[14, 2, 16, 14]
+ put color, *[ 2, 2, 14, 14]
+ }
+ optMB.entryconfigure(color, :hidemargin=>1,
+ :image=>no_sel, :selectimage=>sel)
+ }
+ optMB.menuconfigure(:tearoff, 1)
+ %w(Black gray75 gray50 White).each{|color|
+ optMB.entryconfigure(color, :columnbreak=>true)
+ }
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkButton.new(:parent=>f){
+ text 'show values'
+ command proc{p [b1.value, b2.value]}
+ pack(:side=>:left, :padx=>25, :pady=>5, :anchor=>:s)
+ }
+}
+
+############################
+TkFrame.new(:borderwidth=>2, :relief=>:sunken,
+ :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
+############################
+
+root = TkRoot.new(:title=>'menubutton samples')
+
+TkButton.new(root, :text=>'exit', :command=>proc{exit}){
+ pack(:side=>:top, :padx=>25, :pady=>5, :anchor=>:e)
+}
+
+# VirtualEvent <<MenuSelect>> on Tcl/Tk ==> '<MenuSelect>' on Ruby/Tk
+# ( remove the most external <, > for Ruby/Tk notation )
+TkMenu.bind('<MenuSelect>', proc{|widget|
+ p widget.entrycget('active', :label)
+ }, '%W')
+
+############################
+
+Tk.mainloop
diff --git a/ext/tk/sample/tkmsgcat-load_rb.rb b/ext/tk/sample/tkmsgcat-load_rb.rb
new file mode 100644
index 0000000000..5373e0086f
--- /dev/null
+++ b/ext/tk/sample/tkmsgcat-load_rb.rb
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+demo_dir = File.dirname($0)
+msgcat_dir = [demo_dir, 'msgs_rb'].join(File::Separator)
+top_win = nil
+#msgcat = TkMsgCatalog.new('::tk')
+msgcat = TkMsgCatalog.new('::tkmsgcat_demo')
+default_locale = msgcat.locale
+#msgcat.load_rb(msgcat_dir)
+msgcat.load(msgcat_dir)
+
+col_proc = TkComm.install_bind(proc{|w, color, frame, label|
+ TkComm.window(frame).background(color)
+ Tk.update
+ TkComm.window(label).text(
+ msgcat["%1$s:: %2$s", 'Color',
+ color.capitalize])
+ w.flash; w.flash
+ Tk.callback_break;
+ }, "%W")
+
+del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil})
+
+err_proc = TkComm.install_cmd(proc{fail(RuntimeError,
+ msgcat['Application Error'])})
+
+show_sample = proc{|loc|
+ top_win = TkToplevel.new(:title=>loc)
+
+ msgcat.locale = loc
+ #msgcat.load_rb(msgcat_dir)
+ msgcat.load(msgcat_dir)
+
+ TkLabel.new(top_win){
+ text "preferences:: #{msgcat.preferences.join(' ')}"
+ pack(:pady=>10, :padx=>10)
+ }
+
+ lbl = TkLabel.new(top_win, :text=>msgcat["%1$s:: %2$s",
+ 'Color', '']).pack(:anchor=>'w')
+
+ bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10,
+ :expand=>true, :fill=>:both)
+
+ TkFrame.new(bg){|f|
+ ['blue', 'green', 'red'].each{|col|
+ TkButton.new(f, :text=>msgcat[col]){
+ bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}")
+ }.pack(:fill=>:x)
+ }
+ }.pack(:anchor=>'center', :pady=>15)
+
+ TkFrame.new(top_win){|f|
+ TkButton.new(f, :text=>msgcat['Delete'],
+ :command=>del_proc).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat['Error'],
+ :command=>err_proc).pack(:side=>:left, :padx=>5)
+ }.pack(:side=>:bottom, :fill=>:x)
+
+ top_win
+}
+
+
+# listbox for locale list
+TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3)
+
+TkFrame.new{|f|
+ TkButton.new(f, :text=>msgcat['Exit'],
+ :command=>proc{exit}).pack(:side=>:right, :padx=>5)
+}.pack(:side=>:bottom, :fill=>:x)
+
+f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true)
+lbox = TkListbox.new(f).pack(:side=>:left, :fill=>:both, :expand=>true)
+lbox.yscrollbar(TkScrollbar.new(f, :width=>12).pack(:side=>:right, :fill=>:y))
+
+lbox.bind('ButtonRelease-1'){|ev|
+ idx = lbox.index("@#{ev.x},#{ev.y}")
+ if idx == 0
+ loc = default_locale
+ else
+ loc = lbox.get(idx)
+ end
+ if top_win != nil && top_win.exist?
+ top_win.destroy
+ end
+ top_win = show_sample.call(loc)
+}
+
+lbox.insert('end', 'default')
+
+Dir.entries(msgcat_dir).sort.each{|f|
+ if f =~ /^(.*).msg$/
+ lbox.insert('end', $1)
+ end
+}
+
+top_win = show_sample.call(default_locale)
+
+# start eventloop
+Tk.mainloop
diff --git a/ext/tk/sample/tkmsgcat-load_rb2.rb b/ext/tk/sample/tkmsgcat-load_rb2.rb
new file mode 100644
index 0000000000..55246545c8
--- /dev/null
+++ b/ext/tk/sample/tkmsgcat-load_rb2.rb
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+demo_dir = File.dirname($0)
+msgcat_dir = [demo_dir, 'msgs_rb2'].join(File::Separator)
+top_win = nil
+#msgcat = TkMsgCatalog.new('::tk')
+msgcat = TkMsgCatalog.new('::tkmsgcat_demo')
+default_locale = msgcat.locale
+#msgcat.load_rb(msgcat_dir)
+msgcat.load(msgcat_dir)
+
+col_proc = TkComm.install_bind(proc{|w, color, frame, label|
+ TkComm.window(frame).background(color)
+ Tk.update
+ TkComm.window(label).text(
+ msgcat["%1$s:: %2$s", 'Color',
+ color.capitalize])
+ w.flash; w.flash
+ Tk.callback_break;
+ }, "%W")
+
+del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil})
+
+err_proc = TkComm.install_cmd(proc{fail(RuntimeError,
+ msgcat['Application Error'])})
+
+show_sample = proc{|loc|
+ top_win = TkToplevel.new(:title=>loc)
+
+ msgcat.locale = loc
+ #msgcat.load_rb(msgcat_dir)
+ msgcat.load(msgcat_dir)
+
+ TkLabel.new(top_win){
+ text "preferences:: #{msgcat.preferences.join(' ')}"
+ pack(:pady=>10, :padx=>10)
+ }
+
+ lbl = TkLabel.new(top_win, :text=>msgcat["%1$s:: %2$s",
+ 'Color', '']).pack(:anchor=>'w')
+
+ bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10,
+ :expand=>true, :fill=>:both)
+
+ TkFrame.new(bg){|f|
+ ['blue', 'green', 'red'].each{|col|
+ TkButton.new(f, :text=>msgcat[col]){
+ bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}")
+ }.pack(:fill=>:x)
+ }
+ }.pack(:anchor=>'center', :pady=>15)
+
+ TkFrame.new(top_win){|f|
+ TkButton.new(f, :text=>msgcat['Delete'],
+ :command=>del_proc).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat['Error'],
+ :command=>err_proc).pack(:side=>:left, :padx=>5)
+ }.pack(:side=>:bottom, :fill=>:x)
+
+ top_win
+}
+
+
+# listbox for locale list
+TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3)
+
+TkFrame.new{|f|
+ TkButton.new(f, :text=>msgcat['Exit'],
+ :command=>proc{exit}).pack(:side=>:right, :padx=>5)
+}.pack(:side=>:bottom, :fill=>:x)
+
+f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true)
+lbox = TkListbox.new(f).pack(:side=>:left, :fill=>:both, :expand=>true)
+lbox.yscrollbar(TkScrollbar.new(f, :width=>12).pack(:side=>:right, :fill=>:y))
+
+lbox.bind('ButtonRelease-1'){|ev|
+ idx = lbox.index("@#{ev.x},#{ev.y}")
+ if idx == 0
+ loc = default_locale
+ else
+ loc = lbox.get(idx)
+ end
+ if top_win != nil && top_win.exist?
+ top_win.destroy
+ end
+ top_win = show_sample.call(loc)
+}
+
+lbox.insert('end', 'default')
+
+Dir.entries(msgcat_dir).sort.each{|f|
+ if f =~ /^(.*).msg$/
+ lbox.insert('end', $1)
+ end
+}
+
+top_win = show_sample.call(default_locale)
+
+# start eventloop
+Tk.mainloop
diff --git a/ext/tk/sample/tkmsgcat-load_tk.rb b/ext/tk/sample/tkmsgcat-load_tk.rb
new file mode 100644
index 0000000000..45d68e4e0b
--- /dev/null
+++ b/ext/tk/sample/tkmsgcat-load_tk.rb
@@ -0,0 +1,118 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+demo_dir = File.dirname($0)
+msgcat_dir = [demo_dir, 'msgs_tk'].join(File::Separator)
+top_win = nil
+#msgcat = TkMsgCatalog.new('::tk')
+msgcat = TkMsgCatalog.new('::tkmsgcat_demo')
+default_locale = msgcat.locale
+msgcat.load_tk(msgcat_dir)
+
+col_proc = TkComm.install_bind(proc{|w, color, frame, label|
+ TkComm.window(frame).background(color)
+ Tk.update
+ TkComm.window(label).text(
+ msgcat.mc("%1$s:: %2$s", 'Color',
+ color.capitalize))
+ w.flash; w.flash
+ Tk.callback_break;
+ }, "%W")
+
+del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil})
+
+err_proc = TkComm.install_cmd(proc{fail(RuntimeError,
+ msgcat.mc('Application Error'))})
+
+show_sample = proc{|loc|
+ top_win = TkToplevel.new(:title=>loc)
+
+ msgcat.locale = loc
+ msgcat.load_tk(msgcat_dir)
+
+ TkLabel.new(top_win){
+ text "preferences:: #{msgcat.preferences.join(' ')}"
+ pack(:pady=>10, :padx=>10)
+ }
+
+ lbl = TkLabel.new(top_win, :text=>msgcat.mc("%1$s:: %2$s",
+ 'Color', '')).pack(:anchor=>'w')
+
+ bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10,
+ :expand=>true, :fill=>:both)
+
+ TkFrame.new(bg){|f|
+ ['blue', 'green', 'red'].each{|col|
+ TkButton.new(f, :text=>msgcat.mc(col)){
+ bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}")
+ }.pack(:fill=>:x)
+=begin
+ TkButton.new(f, :text=>msgcat.mc(col),
+ :command=>proc{
+ bg.background col
+ lbl.text msgcat.mc("%1$s:: %2$s", 'Color', col.capitalize)
+ }).pack(:fill=>:x)
+=end
+ }
+ }.pack(:anchor=>'center', :pady=>15)
+
+ TkFrame.new(top_win){|f|
+ TkButton.new(f, :text=>msgcat.mc('Delete'),
+ :command=>del_proc).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat.mc('Error'),
+ :command=>err_proc).pack(:side=>:left, :padx=>5)
+=begin
+ TkButton.new(f, :text=>msgcat.mc('Delete'),
+ :command=>proc{
+ top_win.destroy
+ top_win = nil
+ }).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat.mc('Error'),
+ :command=>proc{
+ fail RuntimeError, msgcat.mc('Application Error')
+ }).pack(:side=>:left, :padx=>5)
+=end
+ }.pack(:side=>:bottom, :fill=>:x)
+
+ top_win
+}
+
+
+# listbox for locale list
+TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3)
+
+TkFrame.new{|f|
+ TkButton.new(f, :text=>msgcat.mc('Exit'),
+ :command=>proc{exit}).pack(:side=>:right, :padx=>5)
+}.pack(:side=>:bottom, :fill=>:x)
+
+f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true)
+lbox = TkListbox.new(f).pack(:side=>:left, :fill=>:both, :expand=>true)
+lbox.yscrollbar(TkScrollbar.new(f, :width=>12).pack(:side=>:right, :fill=>:y))
+
+lbox.bind('ButtonRelease-1'){|ev|
+ idx = lbox.index("@#{ev.x},#{ev.y}")
+ if idx == 0
+ loc = default_locale
+ else
+ loc = lbox.get(idx)
+ end
+ if top_win != nil && top_win.exist?
+ top_win.destroy
+ end
+ top_win = show_sample.call(loc)
+}
+
+lbox.insert('end', 'default')
+
+Dir.entries(msgcat_dir).sort.each{|f|
+ if f =~ /^(.*).msg$/
+ lbox.insert('end', $1)
+ end
+}
+
+top_win = show_sample.call(default_locale)
+
+# start eventloop
+Tk.mainloop
diff --git a/ext/tk/sample/tkmulticolumnlist.rb b/ext/tk/sample/tkmulticolumnlist.rb
new file mode 100644
index 0000000000..255eb691e5
--- /dev/null
+++ b/ext/tk/sample/tkmulticolumnlist.rb
@@ -0,0 +1,743 @@
+#
+# tkmulticolumnlist.rb : multiple column list widget on scrollable frame
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkMultiColumnList < TkText
+ include TkComposite
+
+ # lbox_height : height of listboxes (pixel)
+ # title_info : array [ [<title_string>,<init_width>], ... ]
+ # keys : hash {<option>=><value>, ... }
+ def initialize_composite(lbox_height, title_info, keys={})
+ # argument check
+ if (! title_info.kind_of? Array) or (title_info.size < 2)
+ raise
+ end
+
+ # mode
+ @keep_minsize = true
+ @show_each_hscr = true
+ @show_win_hscr = true
+
+ # init arrays
+ @base_list = []
+ @rel_list = []
+ @title_list = []
+ @title_cmd = []
+ @lbox_list = []
+ @hscr_list = []
+
+ # decide total width
+ @lbox_total = title_info.size
+ @width_total = 0
+ title_info.each{|title, width, cmd|
+ @width_total += width.to_f
+ @title_cmd << cmd
+ }
+
+ # rel-table of label=>index
+ @name_index = {}
+
+ # size definition
+ @window_width = @width_total
+ @sash = 5
+ @scrbar_width = 15
+ @scrbar_border = 3
+ @lbox_border = 1
+ @title_border = 3
+ @h_l_thick = 0
+
+ # init status
+ @mode = :title
+ @command = nil
+
+ # virtical scrollbar
+ @v_scroll = TkYScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # horizontal scrollbar
+ @h_scroll = TkXScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # create base flames
+ @c_title = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_title = TkFrame.new(@c_title, 'width'=>@width_total)
+ @w_title = TkcWindow.new(@c_title, 0, 0,
+ 'window'=>@f_title, 'anchor'=>'nw')
+
+ @c_lbox = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_lbox = TkFrame.new(@c_lbox, 'width'=>@width_total)
+ @w_lbox = TkcWindow.new(@c_lbox, 0, 0, 'window'=>@f_lbox, 'anchor'=>'nw')
+
+ @c_hscr = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_hscr = TkFrame.new(@c_hscr, 'width'=>@width_total)
+ @w_hscr = TkcWindow.new(@c_hscr, 0, 0, 'window'=>@f_hscr, 'anchor'=>'nw')
+
+ # create each listbox
+ sum = 0.0
+ @rel_list << sum/@width_total
+ title_info.each_with_index{|(label, width), idx|
+ # set relation between label and index
+ if @name_index.include?(label)
+ @name_index[label] << idx
+ else
+ @name_index[label] = [idx]
+ end
+
+ # calculate relative positioning
+ sum += width
+ @rel_list << sum/@width_total
+
+ # title field
+ f = TkFrame.new(@f_title, 'width'=>width)
+ base = [f]
+
+ title = TkLabel.new(f, 'text'=>label, 'borderwidth'=>@title_border,
+ 'relief'=>'raised', 'highlightthickness'=>@h_l_thick)
+ title_binding(title, idx)
+ title.pack('fill'=>'x')
+
+ @title_list << title
+
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relheight'=>1.0,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ # listbox field
+ f = TkFrame.new(@f_lbox, 'width'=>width)
+ base << f
+ @lbox_list << TkText.new(f, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@lbox_border,
+ 'takefocus'=>false,
+ 'wrap'=>'none') {
+
+ bindtags(bindtags - [TkText])
+
+ @seltag = TkTextTag.new(self, 'background'=>'#b3b3b3',
+ 'borderwidth'=>1, 'relief'=>'raised')
+ def self.nearest(y)
+ self.index("@1,#{y}").split('.')[0].to_i
+ end
+
+ def self.select_clear(first, last=nil)
+ first = "#{first}.0" if first.kind_of?(Integer)
+ first = self.index(first.to_s + ' linestart')
+ last = first unless last
+ last = "#{last}.0" if first.kind_of?(Integer)
+ last = self.index(last.to_s + ' + 1 lines linestart')
+ @seltag.remove(first, last)
+ end
+
+ def self.select_set(first, last=nil)
+ first = "#{first}.0" if first.kind_of?(Integer)
+ first = self.index(first.to_s + ' linestart')
+ last = first unless last
+ last = "#{last}.0" if first.kind_of?(Integer)
+ last = self.index(last.to_s + ' + 1 lines linestart')
+ @seltag.add(first, last)
+ end
+
+ def self.select_index
+ self.index(@seltag.first).split('.')[0].to_i
+ end
+
+ pack('fill'=>'both', 'expand'=>true)
+ }
+
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0)
+
+ # scrollbar field
+ f = TkFrame.new(@f_hscr, 'width'=>width)
+ base << f
+ @hscr_list << TkXScrollbar.new(f, 'width'=>@scrbar_width,
+ 'borderwidth'=>@scrbar_border,
+ 'highlightthickness'=>@h_l_thick
+ ).pack('fill'=>'x', 'anchor'=>'w')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ @lbox_list[idx].xscrollbar(@hscr_list[idx])
+
+ # add new base
+ @base_list << base
+ }
+
+ # pad
+ @f_title_pad = TkFrame.new(@frame, 'relief'=>'raised',
+ 'borderwidth'=>@title_border,
+ 'highlightthickness'=>@h_l_thick)
+
+ @f_scr_pad = TkFrame.new(@frame, 'relief'=>'sunken',
+ 'borderwidth'=>1,
+ 'highlightthickness'=>@h_l_thick)
+
+ # height check
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+
+ hscr_height = 0
+ @hscr_list.each{|w|
+ h = w.winfo_reqheight
+ hscr_height = h if hscr_height < h
+ }
+
+ @f_title.height title_height
+ @f_lbox.height lbox_height
+ @f_hscr.height hscr_height
+
+ # set control procedure for virtical scroll
+ @v_scroll.assign(*@lbox_list)
+
+ # set control procedure for horizoncal scroll
+ @h_scroll.assign(@c_title, @c_lbox, @c_hscr)
+
+ # binding for listboxes
+ @lbox_list.each_with_index{|l, idx|
+ l.bind('Button-1', proc{|w, y|
+ @frame.focus
+ select_line(w, w.nearest(y))
+ }, '%W %y')
+ l.bind('B1-Motion', proc{|w, y|
+ select_line(w, w.nearest(y))
+ }, '%W %y')
+ l.bind('Double-Button-1', proc{
+ @command.call(get_select) if @command
+ })
+
+ l.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ l.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ l.bind('Button-2', proc{|x, y|
+ @lbox_mark_x = x
+ @lbox_list.each{|lbox| lbox.scan_mark(x, y)}
+ }, '%x %y')
+ l.bind('B2-Motion', proc{|x, y|
+ @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)}
+ l.scan_dragto(x, y)
+ }, '%x %y')
+ }
+
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+
+ bbox = @w_lbox.bbox
+ @c_lbox.height(bbox[3])
+ @c_lbox.scrollregion(bbox)
+
+ if @show_each_hscr
+ bbox = @w_hscr.bbox
+ @c_hscr.height(bbox[3])
+ @c_hscr.scrollregion(bbox)
+ end
+
+ # binding
+ @frame.takefocus(true)
+ @frame.bind('Key-Up', proc{select_shift(@lbox_list[0], -1)})
+ @frame.bind('Key-Down', proc{select_shift(@lbox_list[0], 1)})
+ @frame.bind('Return', proc{@command.call(get_select) if @command})
+
+ # alignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 1, 'weight'=>1)
+ TkGrid.rowconfigure(@frame, 2, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 3, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1)
+ TkGrid.columnconfigure(@frame, 1, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 2, 'weight'=>0)
+ @v_scroll.grid('row'=>1, 'column'=>2, 'sticky'=>'ns')
+ @c_title.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @f_title_pad.grid('row'=>0, 'column'=>2, 'sticky'=>'news')
+ @c_lbox.grid('row'=>1, 'column'=>0, 'sticky'=>'news')
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew') if @show_each_hscr
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew') if @show_win_hscr
+ @f_scr_pad.grid('row'=>2, 'rowspan'=>2, 'column'=>2, 'sticky'=>'news')
+
+ # binding for 'Configure' event
+ @c_lbox.bind('Configure',
+ proc{|height, width| reconstruct(height, width)},
+ '%h %w')
+
+ # set default receiver of method calls
+ @path = @frame.path
+
+ # configure options
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+
+ # command
+ cmd = keys.delete('command')
+ command(cmd) if cmd
+
+ # 'scrollbarwidth' option == 'width' option of scrollbars
+ width = keys.delete('scrollbarwidth')
+ scrollbarwidth(width) if width
+
+ # options for listbox titles
+ title_font = keys.delete('titlefont')
+ titlefont(title_font) if title_font
+
+ title_fg = keys.delete('titleforeground')
+ titleforeground(title_fg) if title_fg
+
+ title_bg = keys.delete('titlebackground')
+ titlebackground(title_bg) if title_bg
+
+ # set receivers for configure methods
+ delegate('DEFAULT', *@lbox_list)
+ delegate('activebackground', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('troughcolor', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatdelay', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatinterval', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('borderwidth', @frame)
+ delegate('width', @c_lbox, @c_title, @c_hscr)
+ delegate('relief', @frame)
+
+ # configure
+ configure(keys) if keys.size > 0
+ end
+ private :initialize_composite
+
+ # keep_minsize?
+ def keep_minsize?
+ @keep_minsize
+ end
+ def keep_minsize(bool)
+ @keep_minsize = bool
+ end
+
+ # each hscr
+ def show_each_hscr
+ @show_each_hscr = true
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_each_hscr
+ @show_each_hscr = false
+ @c_hscr.ungrid
+ end
+
+ # window hscroll
+ def show_win_hscr
+ @show_win_hscr = true
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_win_hscr
+ @show_each_hscr = false
+ @h_scroll.ungrid
+ end
+
+ # set command
+ def command(cmd)
+ @command = cmd
+ self
+ end
+
+ # set scrollbar width
+ def scrollbarwidth(width)
+ @scrbar_width = width
+ @v_scroll['width'] = @scrbar_width
+ @h_scroll['width'] = @scrbar_width
+ @hscr_list.each{|hscr| hscr['width'] = @scrbar_width}
+ self
+ end
+
+ # set scrollbar border
+ def scrollbarborder(width)
+ @scrbar_border = width
+ @v_scroll['border'] = @scrbar_border
+ @h_scroll['border'] = @scrbar_border
+ @hscr_list.each{|hscr| hscr['border'] = @scrbar_border}
+ self
+ end
+
+ # set listbox borders
+ def listboxborder(width)
+ @lbox_border = width
+ @lbox_list.each{|w| w['border'] = @lbox_border}
+ self
+ end
+
+ # set listbox relief
+ def listboxrelief(relief)
+ @lbox_list.each{|w| w['relief'] = relief}
+ self
+ end
+
+ # set title borders
+ def titleborder(width)
+ @title_border = width
+ @f_title_pad['border'] = @title_border
+ @title_list.each{|label| label['border'] = @title_border}
+ self
+ end
+
+ # set title font
+ def titlefont(font)
+ @title_list.each{|label| label['font'] = font}
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+ @f_title.height title_height
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+ self
+ end
+
+ # set title foreground color
+ def titleforeground(fg)
+ @title_list.each{|label| label['foreground'] = fg}
+ self
+ end
+
+ # set title background color
+ def titlebackground(bg)
+ @f_title_pad['background'] = bg
+ @title_list.each{|label| label['background'] = bg}
+ self
+ end
+
+ # set title cmds
+ def titlecommand(idx, cmd=Proc.new)
+ @title_cmd[idx] = cmd
+ end
+
+ # call title cmds
+ def titleinvoke(idx)
+ @title_cmd[idx].call if @title_cmd[idx]
+ end
+
+ # get label widgets of listbox titles
+ def titlelabels(*indices)
+ @title_list[*indices]
+ end
+
+ # get listbox widgets
+ def columns(*indices)
+ @lbox_list[*indices]
+ end
+
+ def delete(*idx)
+ idx = idx.collect{|i|
+ if i.kind_of?(Integer)
+ "#{i}.0"
+ else
+ i.to_s
+ end
+ }
+ @lbox_list.collect{|lbox| lbox.delete(*idx)}
+ end
+
+ def get(idx_s, idx_e=nil)
+ unless idx_e
+ if idx_s.kind_of?(Integer)
+ idx_s = "#{idx_s}.0"
+ idx_e = "#{idx_s} lineend"
+ else
+ idx_s = idx_s.to_s
+ idx_e = "#{idx_s} lineend"
+ end
+ @lbox_list.collect{|lbox|
+ lbox.get(idx_s, idx_e)
+ }
+ else
+ if idx_s.kind_of?(Integer)
+ idx_s = "#{idx_s}.0"
+ else
+ idx_s = idx_s.to_s
+ end
+ if idx_e.kind_of?(Integer)
+ idx_e = "#{idx_e}.end"
+ else
+ idx_e = "#{idx_e} lineend"
+ end
+ list = @lbox_list.collect{|lbox| lbox.get(idx_s, idx_e).split(/\n/)}
+ result = []
+ list[0].each_with_index{|line, index|
+ result << list.collect{|lines| lines[index]}
+ }
+ result
+ end
+ end
+
+ def get_select
+ get(@lbox_list[0].select_index)
+ end
+
+ def _line_array_to_hash(line)
+ result = {}
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ result[label] = line[indices[0]]
+ else
+ result[label] = indices.collect{|index| line[index]}
+ end
+ }
+ result
+ end
+ private :_line_array_to_hash
+
+ def get_by_hash(*idx)
+ get_result = get(*idx)
+ if idx.size == 1
+ _line_array_to_hash(get_result)
+ else
+ get_result.collect{|line| _line_array_to_hash(line)}
+ end
+ end
+
+ def insert(idx, *lines)
+ lbox_ins = []
+ (0..@lbox_list.size).each{lbox_ins << []}
+
+ if idx.kind_of?(Integer)
+ idx = "#{idx}.0"
+ else
+ idx = idx.to_s
+ end
+
+ if @lbox_list[0].index('1.0 + 1 char') == @lbox_list[0].index('end')
+ cr = ""
+ else
+ cr = "\n"
+ end
+
+ lines.each{|line|
+ if line.kind_of? Hash
+ array = []
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ array[indices[0]] = line[label]
+ else
+ if line[label].kind_of? Array
+ indices.each_with_index{|index, num|
+ array[index] = line[label][num]
+ }
+ else
+ array[indices[0]] = line[label]
+ end
+ end
+ }
+ line = array
+ end
+
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ lbox_ins[indices[0]] << line[indices[0]]
+ else
+ indices.each{|index| lbox_ins[index] << line[index]}
+ end
+ }
+ }
+
+ @lbox_list.each_with_index{|lbox, index|
+ lbox.insert(idx, cr + lbox_ins[index].join("\n")) if lbox_ins[index]
+ }
+ end
+
+ def select_clear(first, last=None)
+ @lbox_list.each{|lbox| lbox.sel_clear(first, last=None)}
+ end
+
+ def select_set(first, last=None)
+ @lbox_list.each{|lbox| lbox.sel_set(first, last=None)}
+ end
+
+ ###########################################
+ private
+
+ def reconstruct(height, width)
+ if @keep_minsize && width <= @width_total
+ @f_title.width(@width_total)
+ @f_lbox.width(@width_total)
+ @f_hscr.width(@width_total) if @show_each_hscr
+ @window_width = @width_total
+ else
+ @f_title.width(width)
+ @f_lbox.width(width)
+ @f_hscr.width(width) if @show_each_hscr
+ @window_width = width
+ end
+
+ @f_lbox.height(height)
+
+ @c_title.scrollregion(@w_title.bbox)
+ @c_lbox.scrollregion(@w_lbox.bbox)
+ @c_hscr.scrollregion(@w_hscr.bbox) if @show_each_hscr
+
+ (0..(@rel_list.size - 2)).each{|idx|
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ }
+ end
+
+ def resize(x)
+ idx = @sel_sash
+ return if idx == 0
+
+ # adjustment of relative positioning
+ delta = (x - @x) / @frame_width
+ if delta < @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ delta = @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ elsif delta > @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ delta = @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ end
+ @rel_list[idx] += delta
+
+ # adjustment of leftside widget of the sash
+ title, lbox, hscr = @base_list[idx - 1]
+ title.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+ lbox.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+
+ # adjustment of rightside widget of the sash
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+
+ # update reference position
+ @x = x
+ end
+
+ def motion_cb(w, x, idx)
+ if x <= @sash && idx > 0
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx
+ elsif x >= w.winfo_width - @sash && idx < @lbox_total - 1
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx + 1
+ else
+ w.cursor ""
+ @mode = :title
+ @sel_sash = 0
+ end
+ end
+
+ def title_binding(title, index)
+ title.bind('Motion', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Enter', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Leave', proc{|w| w.cursor ""}, "%W")
+
+ title.bind('Button-1',
+ proc{|w, x|
+ if @mode == :sash
+ @x = x
+ @frame_width = TkWinfo.width(@f_title).to_f
+ else
+ title.relief 'sunken'
+ end
+ },
+ '%W %X')
+
+ title.bind('ButtonRelease-1',
+ proc{|w, x, idx|
+ i = idx.to_i
+ if @mode == :title && @title_cmd[i].kind_of?(Proc)
+ @title_cmd[i].call
+ end
+ title.relief 'raised'
+ motion_cb(w,x,i)
+ },
+ "%W %x #{index}")
+
+ title.bind('B1-Motion', proc{|x| resize(x) if @mode == :sash}, "%X")
+ end
+
+ ########################
+ def select_line(w, idx)
+ @lbox_list.each{|l|
+ l.select_clear(1, 'end')
+ l.select_set(idx)
+ }
+ w.select_set(idx)
+ end
+
+ def select_shift(w, dir)
+ head = w.index('@1,1').split('.')[0].to_i
+ tail = w.index("@1,#{w.winfo_height - 1}").split('.')[0].to_i - 1
+ idx = w.select_index + dir
+ last = w.index('end - 1 char').split('.')[0].to_i
+ if idx < 1
+ idx = 1
+ elsif idx > last
+ idx = last
+ end
+ @lbox_list.each{|l|
+ l.select_clear(1, 'end')
+ l.select_set(idx)
+ }
+ if head > idx
+ @lbox_list.each{|l| l.yview('scroll', -1, 'units')}
+ elsif tail < idx
+ @lbox_list.each{|l| l.yview('scroll', 1, 'units')}
+ end
+ end
+ ########################
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ l = TkMultiColumnList.new(nil, 200,
+ [ ['L1', 200, proc{p 'click L1'}],
+ ['L2', 100],
+ ['L3', 200] ],
+ 'width'=>350,
+ #'titleforeground'=>'yellow',
+ 'titleforeground'=>'white',
+ #'titlebackground'=>'navy',
+ 'titlebackground'=>'blue',
+ 'titlefont'=>'courier'
+ ).pack('fill'=>'both', 'expand'=>true)
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
+ 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
+ 'cccccccccccccccccccccccccccccccccccccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ p l.columns(1)
+ p l.columns(1..3)
+ p l.columns(1,2)
+
+ l.command proc{|line_info| p line_info}
+
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tkmultilistbox.rb b/ext/tk/sample/tkmultilistbox.rb
new file mode 100644
index 0000000000..6f956d0edb
--- /dev/null
+++ b/ext/tk/sample/tkmultilistbox.rb
@@ -0,0 +1,654 @@
+#
+# tkmultilistbox.rb : multiple listbox widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkMultiListbox < TkListbox
+ include TkComposite
+
+ # lbox_height : height of listboxes (pixel)
+ # title_info : array [ [<title_string>,<init_width>], ... ]
+ # keys : hash {<option>=><value>, ... }
+ def initialize_composite(lbox_height, title_info, keys={})
+ # argument check
+ if (! title_info.kind_of? Array) or (title_info.size < 2)
+ raise
+ end
+
+ # decide total width
+ @width_total = 0
+ title_info.each{|title, width| @width_total += width.to_f}
+
+ # virtical scrollbar
+ @v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
+
+ # init arrays
+ @base_list = []
+ @rel_list = []
+ @title_list = []
+ @lbox_list = []
+ @hscr_list = []
+
+ # rel-table of label=>index
+ @name_index = {}
+
+ # create base flames
+ @f_title = TkFrame.new(@frame, 'width'=>@width_total)
+ @f_lbox = TkFrame.new(@frame,
+ 'width'=>@width_total, 'height'=>lbox_height)
+ @f_hscr = TkFrame.new(@frame, 'width'=>@width_total,
+ 'height'=>@v_scroll.cget('width') +
+ 2 * @v_scroll.cget('borderwidth'))
+
+ # dummy label to keep the hight of title space
+ TkLabel.new(@f_title, 'text'=>' ').pack
+
+ # create each listbox
+ sum = 0.0
+ @rel_list << sum/@width_total
+ title_info.each_with_index{|(label, width), idx|
+ # set relation between label and index
+ if @name_index.include?(label)
+ @name_index[label] << idx
+ else
+ @name_index[label] = [idx]
+ end
+
+ # calculate relative positioning
+ sum += width
+ @rel_list << sum/@width_total
+
+ # title field
+ f = TkFrame.new(@f_title, 'width'=>width)
+ base = [f]
+ @title_list << TkLabel.new(f, 'text'=>label).pack('fill'=>'x')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-6,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ # listbox field
+ f = TkFrame.new(@f_lbox, 'width'=>width)
+ base << f
+ @lbox_list << TkListbox.new(f).pack('fill'=>'both', 'expand'=>true)
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-4,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0)
+
+ # scrollbar field
+ f = TkFrame.new(@f_hscr, 'width'=>width)
+ base << f
+ @hscr_list << TkScrollbar.new(f, 'orient'=>'horizontal') .
+ pack('fill'=>'x', 'anchor'=>'w')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-4,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ @lbox_list[idx].xscrollcommand proc{|first, last|
+ @hscr_list[idx].set first, last
+ }
+ @hscr_list[idx].command proc{|*args| @lbox_list[idx].xview *args}
+
+ # add new base
+ @base_list << base
+ }
+
+ # create tab
+ @tab_list = [nil]
+ (1..(@rel_list.size - 2)).each{|idx|
+ tab = TkFrame.new(@f_title, 'cursor'=>'sb_h_double_arrow',
+ 'width'=>6, 'borderwidth'=>2, 'relief'=>'raised')
+ @tab_list << tab
+ tab.place('relx'=>@rel_list[idx], 'anchor'=>'ne', 'relheight'=>0.95)
+ tab.bind('Button-1',
+ proc{|x| @x = x; @frame_width = TkWinfo.width(@f_title).to_f},
+ '%X')
+ tab.bind('B1-Motion', proc{|x, idx| resize(x, idx.to_i)}, "%X #{idx}")
+ }
+
+ # set control procedure for virtical scroll
+ @lbox_list.each{|lbox|
+ lbox.yscrollcommand proc{|first, last|
+ @v_scroll.set first, last
+ }
+ }
+ @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} }
+
+ # binding for listboxes
+ @mode = {}
+ @mode['browse'] = browse_mode_bindtag
+ @mode['single'] = single_mode_bindtag
+ @mode['extended'] = extended_mode_bindtag
+ @mode['multiple'] = multiple_mode_bindtag
+ @current_mode = 'browse'
+ @lbox_list.each{|l|
+ l.bind('Shift-Key-Left',
+ proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W')
+ l.bind('Shift-Key-Right',
+ proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W')
+
+ l.bind('Button-2', proc{|x, y|
+ @lbox_mark_x = x
+ @lbox_list.each{|lbox| lbox.scan_mark(x, y)}
+ }, '%x %y')
+ l.bind('B2-Motion', proc{|x, y|
+ @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)}
+ l.scan_dragto(x, y)
+ }, '%x %y')
+
+ l.bindtags(l.bindtags.unshift(@mode[@current_mode]))
+ }
+
+ # alignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 1, 'weight'=>1)
+ TkGrid.rowconfigure(@frame, 2, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1)
+ TkGrid.columnconfigure(@frame, 1, 'weight'=>0)
+ @v_scroll.grid('row'=>1, 'column'=>1, 'sticky'=>'ns')
+ @f_title.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @f_lbox.grid('row'=>1, 'column'=>0, 'sticky'=>'news')
+ @f_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
+
+ # binding for 'Configure' event
+ @frame.bind('Configure', proc{reconstruct})
+
+ # set default receiver of method calls
+ @path = @lbox_list[0].path
+
+ # configure options
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+
+ # 'mode' option of listboxes
+ sel_mode = keys.delete('mode')
+ mode(sel_mode) if sel_mode
+
+ # 'scrollbarwidth' option == 'width' option of scrollbars
+ width = keys.delete('scrollbarwidth')
+ scrollbarwidth(width) if width
+
+ # options for listbox titles
+ title_font = keys.delete('titlefont')
+ title_fg = keys.delete('titleforeground')
+ title_bg = keys.delete('titlebackground')
+ if title_font or title_fg or title_bg
+ titleconfig(title_font, title_fg, title_bg)
+ end
+
+ # set receivers for configure methods
+ delegate('DEFAULT', *@lbox_list)
+ delegate('activebackground', @v_scroll, *@hscr_list)
+ delegate('troughcolor', @v_scroll, *@hscr_list)
+ delegate('repeatdelay', @v_scroll, *@hscr_list)
+ delegate('repeatinterval', @v_scroll, *@hscr_list)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ # configure
+ configure(keys) if keys.size > 0
+ end
+ private :initialize_composite
+
+ # set 'mode' option of listboxes
+ def mode(sel_mode)
+ @lbox_list.each{|l|
+ tags = l.bindtags
+ tags = tags - [ @mode[@current_mode] ]
+ l.bindtags(tags.unshift(@mode[sel_mode]))
+ @current_mode = sel_mode
+ }
+ end
+
+ # set scrollbar width
+ def scrollbarwidth(width)
+ @v_scroll['width'] = width
+ @hscr_list.each{|hscr| hscr['width'] = width}
+ @f_hscr['height'] = width + 2 * @v_scroll.cget('borderwidth')
+ end
+
+ # set options of titles
+ def titleconfig(font, fg, bg)
+ keys = {}
+ keys['font'] = font if font
+ keys['foreground'] = fg if fg
+ keys['background'] = bg if bg
+ @title_list.each{|label| label.configure(keys)}
+ end
+
+ # get label widgets of listbox titles
+ def titlelabels(*indices)
+ @title_list[*indices]
+ end
+
+ # get listbox widgets
+ def columns(*indices)
+ @lbox_list[*indices]
+ end
+
+ def activate(idx)
+ @lbox_list.each{|lbox| lbox.activate(idx)}
+ end
+
+ def bbox(idx)
+ @lbox_list.collect{|lbox| lbox.bbox(idx)}
+ end
+
+ def delete(*idx)
+ @lbox_list.collect{|lbox| lbox.delete(*idx)}
+ end
+
+ def get(*idx)
+ if idx.size == 1
+ @lbox_list.collect{|lbox| lbox.get(*idx)}
+ else
+ list = @lbox_list.collect{|lbox| lbox.get(*idx)}
+ result = []
+ list[0].each_with_index{|line, index|
+ result << list.collect{|lines| lines[index]}
+ }
+ result
+ end
+ end
+
+ def _line_array_to_hash(line)
+ result = {}
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ result[label] = line[indices[0]]
+ else
+ result[label] = indices.collect{|index| line[index]}
+ end
+ }
+ result
+ end
+ private :_line_array_to_hash
+
+ def get_by_hash(*idx)
+ get_result = get(*idx)
+ if idx.size == 1
+ _line_array_to_hash(get_result)
+ else
+ get_result.collect{|line| _line_array_to_hash(line)}
+ end
+ end
+
+ def insert(idx, *lines)
+ lbox_ins = []
+ (0..@lbox_list.size).each{lbox_ins << []}
+
+ lines.each{|line|
+ if line.kind_of? Hash
+ array = []
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ array[indices[0]] = line[label]
+ else
+ if line[label].kind_of? Array
+ indices.each_with_index{|index, num|
+ array[index] = line[label][num]
+ }
+ else
+ array[indices[0]] = line[label]
+ end
+ end
+ }
+ line = array
+ end
+
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ lbox_ins[indices[0]] << line[indices[0]]
+ else
+ indices.each{|index| lbox_ins[index] << line[index]}
+ end
+ }
+ }
+
+ @lbox_list.each_with_index{|lbox, index|
+ lbox.insert(idx, *lbox_ins[index]) if lbox_ins[index]
+ }
+ end
+
+ def selection_anchor(index)
+ @lbox_list.each{|lbox| lbox.selection_anchor(index)}
+ end
+
+ def selection_clear(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_clear(first, last=None)}
+ end
+
+ def selection_set(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_set(first, last=None)}
+ end
+
+ ###########################################
+ private
+
+ def reconstruct
+ (0..(@rel_list.size - 2)).each{|idx|
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ tab = @tab_list[idx]
+ tab.place('relx'=>@rel_list[idx]) if tab
+ }
+ end
+
+ def resize(x, idx)
+ # adjustment of relative positioning
+ delta = (x - @x) / @frame_width
+ if delta < @rel_list[idx-1] - @rel_list[idx] + 0.02
+ delta = @rel_list[idx-1] - @rel_list[idx] + 0.02
+ elsif delta > @rel_list[idx+1] - @rel_list[idx] - 0.02
+ delta = @rel_list[idx+1] - @rel_list[idx] - 0.02
+ end
+ @rel_list[idx] += delta
+
+ # adjustment of leftside widget of the tab
+ title, lbox, hscr = @base_list[idx - 1]
+ title.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+ lbox.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+
+ # adjustment of the tab position
+ @tab_list[idx].place('relx'=>@rel_list[idx])
+
+ # adjustment of rightside widget of the tab
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+
+ # update reference position
+ @x = x
+ end
+
+ #################################
+ def browse_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+
+ t
+ end
+
+ ########################
+ def single_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-backslash',
+ proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}})
+
+ t
+ end
+
+ ########################
+ def extended_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+ t.bind('Shift-B1-Motion',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-Button-1',
+ proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-B1-Motion',
+ proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Shift-Up', proc{|w| select_expand(w, -1)}, '%W')
+ t.bind('Shift-Down', proc{|w| select_expand(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| select_range(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| select_range(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def multiple_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| active_line(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| active_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def active_line(w, idx)
+ @lbox_list.each{|l| l.activate(idx)}
+ end
+
+ def select_only(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_range(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_set('anchor', idx)
+ }
+ end
+
+ def select_toggle(w, idx)
+ st = w.selection_includes(idx)
+ @lbox_list.each{|l|
+ l.selection_anchor(idx)
+ if st == 1
+ l.selection_clear(idx)
+ else
+ l.selection_set(idx)
+ end
+ }
+ end
+
+ def select_drag(w, idx)
+ st = w.selection_includes('anchor')
+ @lbox_list.each{|l|
+ if st == 1
+ l.selection_set('anchor', idx)
+ else
+ l.selection_clear('anchor', idx)
+ end
+ }
+ end
+
+ def select_line(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ w.selection_set('anchor')
+ end
+
+ def select_line2(w, idx)
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_line3(w, idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_active(w)
+ idx = l.activate(idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_expand(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_set(idx)
+ }
+ end
+
+ def active_shift(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ }
+ end
+
+ def select_shift(w, dir)
+ idx = w.index('anchor').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_all
+ @lbox_list.each{|l|
+ l.selection_set(0, 'end')
+ }
+ end
+
+ def clear_all
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ }
+ end
+
+ def focus_shift(w, dir)
+ idx = @lbox_list.index(w) + dir
+ return if idx < 0
+ return if idx >= @lbox_list.size
+ @lbox_list[idx].focus
+ end
+ ########################
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ f = TkFrame.new(nil, 'width'=>300,
+ 'height'=>200).pack('fill'=>'both', 'expand'=>'true')
+ #f = TkFrame.new.pack('fill'=>'both', 'expand'=>'true')
+ l = TkMultiListbox.new(f, 150,
+ [ ['L1', 100],
+ ['L2', 200],
+ ['L3', 50] ],
+ 'titlefont'=>'courier',
+ 'titleforeground'=>'yellow',
+ 'titlebackground'=>'navy'
+ ).pack('fill'=>'both', 'expand'=>true)
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ p l.columns(1)
+ p l.columns(1..3)
+ p l.columns(1,2)
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tkmultilistframe.rb b/ext/tk/sample/tkmultilistframe.rb
new file mode 100644
index 0000000000..ef1a0a824d
--- /dev/null
+++ b/ext/tk/sample/tkmultilistframe.rb
@@ -0,0 +1,940 @@
+#
+# tkmultilistframe.rb : multiple listbox widget on scrollable frame
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkMultiListFrame < TkListbox
+ include TkComposite
+
+ # lbox_height : height of listboxes (pixel)
+ # title_info : array [ [<title_string>,<init_width>], ... ]
+ # keys : hash {<option>=><value>, ... }
+ def initialize_composite(lbox_height, title_info, keys={})
+ # argument check
+ if (! title_info.kind_of? Array) or (title_info.size < 2)
+ raise
+ end
+
+ # mode
+ @keep_minsize = true
+ @show_each_hscr = true
+ @show_win_hscr = true
+
+ # init arrays
+ @base_list = []
+ @rel_list = []
+ @title_list = []
+ @title_cmd = []
+ @lbox_list = []
+ @hscr_list = []
+
+ # decide total width
+ @lbox_total = title_info.size
+ @width_total = 0
+ title_info.each{|title, width, cmd|
+ @width_total += width.to_f
+ @title_cmd << cmd
+ }
+
+ # rel-table of label=>index
+ @name_index = {}
+
+ # size definition
+ @window_width = @width_total
+ @sash = 5
+ @scrbar_width = 15
+ @scrbar_border = 3
+ @lbox_border = 1
+ @title_border = 3
+ @h_l_thick = 0
+
+ # init status
+ @mode = :title
+
+ # virtical scrollbar
+=begin
+ @v_scroll = TkScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'orient'=>'vertical', 'width'=>@scrbar_width)
+=end
+ @v_scroll = TkYScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # horizontal scrollbar
+=begin
+ @h_scroll = TkScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'orient'=>'horizontal', 'width'=>@scrbar_width)
+=end
+ @h_scroll = TkXScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # create base flames
+ @c_title = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_title = TkFrame.new(@c_title, 'width'=>@width_total)
+ @w_title = TkcWindow.new(@c_title, 0, 0,
+ 'window'=>@f_title, 'anchor'=>'nw')
+
+ @c_lbox = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_lbox = TkFrame.new(@c_lbox, 'width'=>@width_total)
+ @w_lbox = TkcWindow.new(@c_lbox, 0, 0, 'window'=>@f_lbox, 'anchor'=>'nw')
+
+ @c_hscr = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_hscr = TkFrame.new(@c_hscr, 'width'=>@width_total)
+ @w_hscr = TkcWindow.new(@c_hscr, 0, 0, 'window'=>@f_hscr, 'anchor'=>'nw')
+
+ # create each listbox
+ sum = 0.0
+ @rel_list << sum/@width_total
+ title_info.each_with_index{|(label, width), idx|
+ # set relation between label and index
+ if @name_index.include?(label)
+ @name_index[label] << idx
+ else
+ @name_index[label] = [idx]
+ end
+
+ # calculate relative positioning
+ sum += width
+ @rel_list << sum/@width_total
+
+ # title field
+ f = TkFrame.new(@f_title, 'width'=>width)
+ base = [f]
+
+ title = TkLabel.new(f, 'text'=>label, 'borderwidth'=>@title_border,
+ 'relief'=>'raised', 'highlightthickness'=>@h_l_thick)
+ title_binding(title, idx)
+ title.pack('fill'=>'x')
+
+ @title_list << title
+
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relheight'=>1.0,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ # listbox field
+ f = TkFrame.new(@f_lbox, 'width'=>width)
+ base << f
+ @lbox_list << TkListbox.new(f, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@lbox_border
+ ).pack('fill'=>'both', 'expand'=>true)
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0)
+
+ # scrollbar field
+ f = TkFrame.new(@f_hscr, 'width'=>width)
+ base << f
+=begin
+ @hscr_list << TkScrollbar.new(f, 'orient'=>'horizontal',
+ 'width'=>@scrbar_width,
+ 'borderwidth'=>@scrbar_border,
+ 'highlightthickness'=>@h_l_thick
+ ).pack('fill'=>'x', 'anchor'=>'w')
+=end
+ @hscr_list << TkXScrollbar.new(f, 'width'=>@scrbar_width,
+ 'borderwidth'=>@scrbar_border,
+ 'highlightthickness'=>@h_l_thick
+ ).pack('fill'=>'x', 'anchor'=>'w')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+=begin
+ @lbox_list[idx].xscrollcommand proc{|first, last|
+ @hscr_list[idx].set first, last
+ }
+ @hscr_list[idx].command proc{|*args| @lbox_list[idx].xview *args}
+=end
+ @lbox_list[idx].xscrollbar(@hscr_list[idx])
+
+ # add new base
+ @base_list << base
+ }
+
+ # pad
+ # @f_title_pad = TkFrame.new(@frame)
+ @f_title_pad = TkFrame.new(@frame, 'relief'=>'raised',
+ 'borderwidth'=>@title_border,
+ 'highlightthickness'=>@h_l_thick)
+
+ @f_scr_pad = TkFrame.new(@frame, 'relief'=>'sunken',
+ 'borderwidth'=>1,
+ 'highlightthickness'=>@h_l_thick)
+
+ # height check
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+
+ hscr_height = 0
+ @hscr_list.each{|w|
+ h = w.winfo_reqheight
+ hscr_height = h if hscr_height < h
+ }
+
+ @f_title.height title_height
+ @f_lbox.height lbox_height
+ @f_hscr.height hscr_height
+
+ # set control procedure for virtical scroll
+=begin
+ @lbox_list.each{|lbox|
+ lbox.yscrollcommand proc{|first, last|
+ @v_scroll.set first, last
+ }
+ }
+ @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} }
+=end
+ @v_scroll.assign(*@lbox_list)
+
+ # set control procedure for horizoncal scroll
+=begin
+ @c_title.xscrollcommand proc{|first, last|
+ @h_scroll.set first, last
+ }
+ @c_lbox.xscrollcommand proc{|first, last|
+ @h_scroll.set first, last
+ }
+ @c_hscr.xscrollcommand proc{|first, last|
+ @h_scroll.set first, last
+ }
+ @h_scroll.command proc{|*args|
+ @c_title.xview *args
+ @c_lbox.xview *args
+ @c_hscr.xview *args if @show_each_hscr
+ }
+=end
+ @h_scroll.assign(@c_title, @c_lbox, @c_hscr)
+
+ # binding for listboxes
+ @lbox_mode = {}
+ @lbox_mode['browse'] = browse_mode_bindtag
+ @lbox_mode['single'] = single_mode_bindtag
+ @lbox_mode['extended'] = extended_mode_bindtag
+ @lbox_mode['multiple'] = multiple_mode_bindtag
+ @current_mode = 'browse'
+ @lbox_list.each_with_index{|l, idx|
+ l.bind('Shift-Key-Left',
+ proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W')
+ l.bind('Shift-Key-Right',
+ proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W')
+
+ l.bind('Button-2', proc{|x, y|
+ @lbox_mark_x = x
+ @lbox_list.each{|lbox| lbox.scan_mark(x, y)}
+ }, '%x %y')
+ l.bind('B2-Motion', proc{|x, y|
+ @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)}
+ l.scan_dragto(x, y)
+ }, '%x %y')
+
+ l.bindtags(l.bindtags.unshift(@lbox_mode[@current_mode]))
+ }
+
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+
+ bbox = @w_lbox.bbox
+ @c_lbox.height(bbox[3])
+ @c_lbox.scrollregion(bbox)
+
+ if @show_each_hscr
+ bbox = @w_hscr.bbox
+ @c_hscr.height(bbox[3])
+ @c_hscr.scrollregion(bbox)
+ end
+
+ # alignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 1, 'weight'=>1)
+ TkGrid.rowconfigure(@frame, 2, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 3, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1)
+ TkGrid.columnconfigure(@frame, 1, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 2, 'weight'=>0)
+ @v_scroll.grid('row'=>1, 'column'=>2, 'sticky'=>'ns')
+ @c_title.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @f_title_pad.grid('row'=>0, 'column'=>2, 'sticky'=>'news')
+ @c_lbox.grid('row'=>1, 'column'=>0, 'sticky'=>'news')
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew') if @show_each_hscr
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew') if @show_win_hscr
+ @f_scr_pad.grid('row'=>2, 'rowspan'=>2, 'column'=>2, 'sticky'=>'news')
+
+ # binding for 'Configure' event
+ @c_lbox.bind('Configure',
+ proc{|height, width| reconstruct(height, width)},
+ '%h %w')
+
+ # set default receiver of method calls
+ @path = @lbox_list[0].path
+
+ # configure options
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+
+ # 'mode' option of listboxes
+ sel_mode = keys.delete('mode')
+ mode(sel_mode) if sel_mode
+
+ # 'scrollbarwidth' option == 'width' option of scrollbars
+ width = keys.delete('scrollbarwidth')
+ scrollbarwidth(width) if width
+
+ # options for listbox titles
+ title_font = keys.delete('titlefont')
+ titlefont(title_font) if title_font
+
+ title_fg = keys.delete('titleforeground')
+ titleforeground(title_fg) if title_fg
+
+ title_bg = keys.delete('titlebackground')
+ titlebackground(title_bg) if title_bg
+
+ # set receivers for configure methods
+ delegate('DEFAULT', *@lbox_list)
+ delegate('activebackground', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('troughcolor', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatdelay', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatinterval', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('borderwidth', @frame)
+ delegate('width', @c_lbox, @c_title, @c_hscr)
+ delegate('relief', @frame)
+
+ # configure
+ configure(keys) if keys.size > 0
+ end
+ private :initialize_composite
+
+ # set 'mode' option of listboxes
+ def mode(sel_mode)
+ @lbox_list.each{|l|
+ tags = l.bindtags
+ tags = tags - [ @lbox_mode[@current_mode] ]
+ l.bindtags(tags.unshift(@lbox_mode[sel_mode]))
+ @current_mode = sel_mode
+ }
+ end
+
+ # keep_minsize?
+ def keep_minsize?
+ @keep_minsize
+ end
+ def keep_minsize(bool)
+ @keep_minsize = bool
+ end
+
+ # each hscr
+ def show_each_hscr
+ @show_each_hscr = true
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_each_hscr
+ @show_each_hscr = false
+ @c_hscr.ungrid
+ end
+
+ # window hscroll
+ def show_win_hscr
+ @show_win_hscr = true
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_win_hscr
+ @show_each_hscr = false
+ @h_scroll.ungrid
+ end
+
+ # set scrollbar width
+ def scrollbarwidth(width)
+ @scrbar_width = width
+ @v_scroll['width'] = @scrbar_width
+ @h_scroll['width'] = @scrbar_width
+ @hscr_list.each{|hscr| hscr['width'] = @scrbar_width}
+ self
+ end
+
+ # set scrollbar border
+ def scrollbarborder(width)
+ @scrbar_border = width
+ @v_scroll['border'] = @scrbar_border
+ @h_scroll['border'] = @scrbar_border
+ @hscr_list.each{|hscr| hscr['border'] = @scrbar_border}
+ self
+ end
+
+ # set listbox borders
+ def listboxborder(width)
+ @lbox_border = width
+ @lbox_list.each{|w| w['border'] = @lbox_border}
+ self
+ end
+
+ # set listbox relief
+ def listboxrelief(relief)
+ @lbox_list.each{|w| w['relief'] = relief}
+ self
+ end
+
+ # set title borders
+ def titleborder(width)
+ @title_border = width
+ @f_title_pad['border'] = @title_border
+ @title_list.each{|label| label['border'] = @title_border}
+ self
+ end
+
+ # set title font
+ def titlefont(font)
+ @title_list.each{|label| label['font'] = font}
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+ @f_title.height title_height
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+ self
+ end
+
+ # set title foreground color
+ def titleforeground(fg)
+ @title_list.each{|label| label['foreground'] = fg}
+ self
+ end
+
+ # set title background color
+ def titlebackground(bg)
+ @f_title_pad['background'] = bg
+ @title_list.each{|label| label['background'] = bg}
+ self
+ end
+
+ # set title cmds
+ def titlecommand(idx, cmd=Proc.new)
+ @title_cmd[idx] = cmd
+ end
+
+ # call title cmds
+ def titleinvoke(idx)
+ @title_cmd[idx].call if @title_cmd[idx]
+ end
+
+ # get label widgets of listbox titles
+ def titlelabels(*indices)
+ @title_list[*indices]
+ end
+
+ # get listbox widgets
+ def columns(*indices)
+ @lbox_list[*indices]
+ end
+
+ def activate(idx)
+ @lbox_list.each{|lbox| lbox.activate(idx)}
+ end
+
+ def bbox(idx)
+ @lbox_list.collect{|lbox| lbox.bbox(idx)}
+ end
+
+ def delete(*idx)
+ @lbox_list.collect{|lbox| lbox.delete(*idx)}
+ end
+
+ def get(*idx)
+ if idx.size == 1
+ @lbox_list.collect{|lbox| lbox.get(*idx)}
+ else
+ list = @lbox_list.collect{|lbox| lbox.get(*idx)}
+ result = []
+ list[0].each_with_index{|line, index|
+ result << list.collect{|lines| lines[index]}
+ }
+ result
+ end
+ end
+
+ def _line_array_to_hash(line)
+ result = {}
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ result[label] = line[indices[0]]
+ else
+ result[label] = indices.collect{|index| line[index]}
+ end
+ }
+ result
+ end
+ private :_line_array_to_hash
+
+ def get_by_hash(*idx)
+ get_result = get(*idx)
+ if idx.size == 1
+ _line_array_to_hash(get_result)
+ else
+ get_result.collect{|line| _line_array_to_hash(line)}
+ end
+ end
+
+ def insert(idx, *lines)
+ lbox_ins = []
+ (0..@lbox_list.size).each{lbox_ins << []}
+
+ lines.each{|line|
+ if line.kind_of? Hash
+ array = []
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ array[indices[0]] = line[label]
+ else
+ if line[label].kind_of? Array
+ indices.each_with_index{|index, num|
+ array[index] = line[label][num]
+ }
+ else
+ array[indices[0]] = line[label]
+ end
+ end
+ }
+ line = array
+ end
+
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ lbox_ins[indices[0]] << line[indices[0]]
+ else
+ indices.each{|index| lbox_ins[index] << line[index]}
+ end
+ }
+ }
+
+ @lbox_list.each_with_index{|lbox, index|
+ lbox.insert(idx, *lbox_ins[index]) if lbox_ins[index]
+ }
+ end
+
+ def selection_anchor(index)
+ @lbox_list.each{|lbox| lbox.selection_anchor(index)}
+ end
+
+ def selection_clear(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_clear(first, last=None)}
+ end
+
+ def selection_set(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_set(first, last=None)}
+ end
+
+ ###########################################
+ private
+
+ def reconstruct(height, width)
+ if @keep_minsize && width <= @width_total
+ @f_title.width(@width_total)
+ @f_lbox.width(@width_total)
+ @f_hscr.width(@width_total) if @show_each_hscr
+ @window_width = @width_total
+ else
+ @f_title.width(width)
+ @f_lbox.width(width)
+ @f_hscr.width(width) if @show_each_hscr
+ @window_width = width
+ end
+
+ @f_lbox.height(height)
+
+ @c_title.scrollregion(@w_title.bbox)
+ @c_lbox.scrollregion(@w_lbox.bbox)
+ @c_hscr.scrollregion(@w_hscr.bbox) if @show_each_hscr
+
+ (0..(@rel_list.size - 2)).each{|idx|
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ }
+ end
+
+ def resize(x)
+ idx = @sel_sash
+ return if idx == 0
+
+ # adjustment of relative positioning
+ delta = (x - @x) / @frame_width
+ if delta < @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ delta = @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ elsif delta > @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ delta = @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ end
+ @rel_list[idx] += delta
+
+ # adjustment of leftside widget of the sash
+ title, lbox, hscr = @base_list[idx - 1]
+ title.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+ lbox.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+
+ # adjustment of rightside widget of the sash
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+
+ # update reference position
+ @x = x
+ end
+
+ def motion_cb(w, x, idx)
+ if x <= @sash && idx > 0
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx
+ elsif x >= w.winfo_width - @sash && idx < @lbox_total - 1
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx + 1
+ else
+ w.cursor ""
+ @mode = :title
+ @sel_sash = 0
+ end
+ end
+
+ def title_binding(title, index)
+ title.bind('Motion', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Enter', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Leave', proc{|w| w.cursor ""}, "%W")
+
+ title.bind('Button-1',
+ proc{|w, x|
+ if @mode == :sash
+ @x = x
+ @frame_width = TkWinfo.width(@f_title).to_f
+ else
+ title.relief 'sunken'
+ end
+ },
+ '%W %X')
+
+ title.bind('ButtonRelease-1',
+ proc{|w, x, idx|
+ i = idx.to_i
+ if @mode == :title && @title_cmd[i].kind_of?(Proc)
+ @title_cmd[i].call
+ end
+ title.relief 'raised'
+ motion_cb(w,x,i)
+ },
+ "%W %x #{index}")
+
+ title.bind('B1-Motion', proc{|x| resize(x) if @mode == :sash}, "%X")
+ end
+
+ #################################
+ def browse_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+
+ t
+ end
+
+ ########################
+ def single_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-backslash',
+ proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}})
+
+ t
+ end
+
+ ########################
+ def extended_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+ t.bind('Shift-B1-Motion',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-Button-1',
+ proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-B1-Motion',
+ proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Shift-Up', proc{|w| select_expand(w, -1)}, '%W')
+ t.bind('Shift-Down', proc{|w| select_expand(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| select_range(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| select_range(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def multiple_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| active_line(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| active_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def active_line(w, idx)
+ @lbox_list.each{|l| l.activate(idx)}
+ end
+
+ def select_only(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_range(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_set('anchor', idx)
+ }
+ end
+
+ def select_toggle(w, idx)
+ st = w.selection_includes(idx)
+ @lbox_list.each{|l|
+ l.selection_anchor(idx)
+ if st == 1
+ l.selection_clear(idx)
+ else
+ l.selection_set(idx)
+ end
+ }
+ end
+
+ def select_drag(w, idx)
+ st = w.selection_includes('anchor')
+ @lbox_list.each{|l|
+ if st == 1
+ l.selection_set('anchor', idx)
+ else
+ l.selection_clear('anchor', idx)
+ end
+ }
+ end
+
+ def select_line(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ w.selection_set('anchor')
+ end
+
+ def select_line2(w, idx)
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_line3(w, idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_active(w)
+ idx = l.activate(idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_expand(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_set(idx)
+ }
+ end
+
+ def active_shift(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ }
+ end
+
+ def select_shift(w, dir)
+ idx = w.index('anchor').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_all
+ @lbox_list.each{|l|
+ l.selection_set(0, 'end')
+ }
+ end
+
+ def clear_all
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ }
+ end
+
+ def focus_shift(w, dir)
+ idx = @lbox_list.index(w) + dir
+ return if idx < 0
+ return if idx >= @lbox_list.size
+ @lbox_list[idx].focus
+ end
+ ########################
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ l = TkMultiListFrame.new(nil, 200,
+ [ ['L1', 200, proc{p 'click L1'}],
+ ['L2', 100],
+ ['L3', 200] ],
+ 'width'=>350,
+ #'titleforeground'=>'yellow',
+ 'titleforeground'=>'white',
+ #'titlebackground'=>'navy',
+ 'titlebackground'=>'blue',
+ 'titlefont'=>'courier'
+ ).pack('fill'=>'both', 'expand'=>true)
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
+ 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
+ 'cccccccccccccccccccccccccccccccccccccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ p l.columns(1)
+ p l.columns(1..3)
+ p l.columns(1,2)
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tkoptdb-safeTk.rb b/ext/tk/sample/tkoptdb-safeTk.rb
new file mode 100644
index 0000000000..a06098323f
--- /dev/null
+++ b/ext/tk/sample/tkoptdb-safeTk.rb
@@ -0,0 +1,73 @@
+#!/usr/bin/env ruby
+
+require 'multi-tk'
+
+TkMessage.new(:text => <<EOM).pack
+This is a sample of the safe-Tk slave interpreter. \
+On the slave interpreter, 'tkoptdb.rb' demo is running.
+( NOTE:: a safe-Tk interpreter can't read options \
+from a file. Options are given by the master interpreter \
+in this script. )
+The window shown this message is a root widget of \
+the default master interpreter. The other window \
+is a toplevel widget of the master interpreter, and it \
+has a container frame of the safe-Tk slave interpreter.
+'exit' on the slave interpreter exits the slave only. \
+You can also delete the slave by the button on the toplevel widget.
+EOM
+
+if ENV['LANG'] =~ /^ja/
+ # read Japanese resource
+ ent = TkOptionDB.read_entries(File.expand_path('resource.ja',
+ File.dirname(__FILE__)),
+ 'euc-jp')
+else
+ # read English resource
+ ent = TkOptionDB.read_entries(File.expand_path('resource.en',
+ File.dirname(__FILE__)))
+end
+
+file = File.expand_path('tkoptdb.rb', File.dirname(__FILE__))
+
+ip = MultiTkIp.new_safeTk{
+ # When a block is given to 'new_safeTk' method,
+ # the block is evaluated on $SAFE==4.
+ ent.each{|pat, val| Tk.tk_call('option', 'add', pat, val)}
+}
+
+print "ip.eval_proc{$SAFE} ==> ", ip.eval_proc{$SAFE}, "\n"
+
+print "\ncall 'ip.wait_on_mainloop = false'\n"
+print "If 'ip.wait_on_mainloop? == true', ",
+ "when 'mainloop' is called on 'ip.eval_proc', ",
+ "'ip.eval_proc' does't return while the root window exists.\n",
+ "If you want to avoid that, set wait_on_mainloop to false. ",
+ "Then the mainloop in the eval_proc returns soon ",
+ "and the following steps are evaluated. \n",
+ "If you hate the both of them, use 'ip.bg_eval_proc' or ",
+ "wrap 'ip.eval_proc' by a thread.\n"
+
+ip.wait_on_mainloop = false
+
+ret = ip.eval_proc{
+ # When a block is given to 'eval_proc' method,
+ # the block is evaluated on the IP's current safe level.
+ # So, the followings raises an exception.
+ # An Exception object of the exception is returned as a
+ # return value of this method.
+
+ load file
+}
+print "\nip.eval_proc{}, which includes insecure operiation in the given block, returns an exception object: ", ret.inspect, "\n"
+
+print "If a proc object is given, the proc is evaluated on the safe-level which is kept on the proc :: ip.eval_proc( proc{$SAFE} ) ==> ", ip.eval_proc(proc{$SAFE}), "\n"
+
+safe0_cmd = Proc.new{
+ print 'safe0_cmd safe-level == ', $SAFE, "\n"
+ # This proc object keeps current safe-level ($SAFE==0).
+ load file
+}
+ip.eval_proc{safe0_cmd.call}
+
+# Tk.mainloop is ignored on the slave-IP
+Tk.mainloop
diff --git a/ext/tk/sample/tkoptdb.rb b/ext/tk/sample/tkoptdb.rb
new file mode 100644
index 0000000000..47784ea238
--- /dev/null
+++ b/ext/tk/sample/tkoptdb.rb
@@ -0,0 +1,106 @@
+#!/usr/bin/env ruby
+#
+# sample script of TkOptionDB
+#
+# If 'LANG' environment variable's value is started by 'ja',
+# then read Japanese resource data and display Japanese button text.
+# In other case, read English resource data and display English text.
+#
+require "tk"
+
+if __FILE__ == $0 || !TkCore::INTERP.safe?
+ if ENV['LANG'] =~ /^ja/
+ # read Japanese resource
+ TkOptionDB.read_with_encoding(File.expand_path('resource.ja',
+ File.dirname(__FILE__)),
+ 'euc-jp')
+ else
+ # read English resource
+ TkOptionDB.readfile(File.expand_path('resource.en',
+ File.dirname(__FILE__)))
+ end
+end
+
+# 'show_msg' and 'bye_msg' procedures can be defined on BTN_CMD resource.
+# Those procedures are called under $SAFE==2
+cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3) {
+ # If you want to check resource string (str),
+ # please define __check_proc_string__(str) like this.
+ class << self
+ def __check_proc_string__(str)
+ print "($SAFE=#{$SAFE} >>>) check!! str.tainted?::#{str.tainted?}"
+ str.untaint
+ print "==>#{str.tainted?} (<<< $SAFE=#{$SAFE}): "
+ str
+ end
+ private :__check_proc_string__
+ end
+}
+
+# following two frame widgets use same database entry
+TkFrame.new(:class=>'BtnFrame'){|f|
+ pack(:padx=>5, :pady=>5)
+ TkButton.new(:parent=>f, :widgetname=>'hello'){
+ command proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.show_msg(TkOptionDB.inspect)
+ print "(<<< $SAFE=#{$SAFE})"
+ }
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+ TkButton.new(:command=>proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.bye_msg
+ print "(<<< $SAFE=#{$SAFE} ) : "
+ exit
+ },
+ :parent=>f, :widgetname=>'quit'){
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+}
+
+class BtnFrame < TkFrame; end
+BtnFrame.new{|f|
+ pack(:padx=>5, :pady=>5)
+ TkButton.new(:parent=>f, :widgetname=>'hello'){
+ command proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.show_msg(TkOptionDB.inspect)
+ print "(<<< $SAFE=#{$SAFE})"
+ }
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+ TkButton.new(:command=>proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.bye_msg
+ print "(<<< $SAFE=#{$SAFE})"
+ exit
+ },
+ :parent=>f, :widgetname=>'quit'){
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+}
+
+# if unknown class, use default option values
+TkFrame.new(:class=>'BtnFrame2'){|f|
+ pack(:padx=>5, :pady=>5)
+ TkButton.new(:parent=>f, :widgetname=>'hello'){
+ command proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.show_msg(TkOptionDB.inspect)
+ print "(<<< $SAFE=#{$SAFE})"
+ }
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+ TkButton.new(:command=>proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.bye_msg
+ print "(<<< $SAFE=#{$SAFE})"
+ exit
+ },
+ :parent=>f, :widgetname=>'quit'){
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+}
+
+Tk.mainloop
diff --git a/ext/tk/sample/tktextframe.rb b/ext/tk/sample/tktextframe.rb
new file mode 100644
index 0000000000..bdab057d34
--- /dev/null
+++ b/ext/tk/sample/tktextframe.rb
@@ -0,0 +1,162 @@
+#
+# tktextframe.rb : a sample of TkComposite
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkTextFrame < TkText
+ include TkComposite
+
+ def initialize_composite(keys={})
+ keys = _symbolkey2str(keys)
+
+ # create scrollbars
+ @v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
+ @h_scroll = TkScrollbar.new(@frame, 'orient'=>'horizontal')
+
+ # create a text widget
+ @text = TkText.new(@frame, 'wrap'=>'none')
+
+ # set default receiver of method calls
+ @path = @text.path
+
+ # assign scrollbars
+ @text.xscrollbar(@h_scroll)
+ @text.yscrollbar(@v_scroll)
+
+ # allignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ @text.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+
+ # scrollbars ON
+ vscroll(keys.delete('vscroll'){true})
+ hscroll(keys.delete('hscroll'){true})
+
+ # set background of the text widget
+=begin
+ color = keys.delete('textbackground')
+ textbackground(color) if color
+=end
+ # please check the differences of the following definitions
+ option_methods(
+ [:scrollbarwidth, :get_scrollbarwidth],
+ [:textbackground, nil, :textbg_info],
+ :textborderwidth,
+ :textrelief
+ )
+
+ # set receiver widgets for configure methods (with alias)
+ delegate_alias('scrollbarrelief', 'relief', @h_scroll, @v_scroll)
+
+ # set receiver widgets for configure methods
+ delegate('DEFAULT', @text)
+ delegate('background', @frame, @h_scroll, @v_scroll)
+ delegate('activebackground', @h_scroll, @v_scroll)
+ delegate('troughcolor', @h_scroll, @v_scroll)
+ delegate('repeatdelay', @h_scroll, @v_scroll)
+ delegate('repeatinterval', @h_scroll, @v_scroll)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ # do configure
+ configure keys unless keys.empty?
+ end
+ private :initialize_composite
+
+ # set background color of text widget
+ def textbackground(color = nil)
+ if color
+ @text.background(color)
+ else
+ @text.background
+ end
+ end
+
+ def textbg_info
+ info = @text.configinfo(:background)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ info[0] = 'textbackground'
+ info
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ {'textbackground' => info['background']}
+ end
+ end
+
+ # get/set borderwidth of text widget
+ def set_textborderwidth(width)
+ @text.borderwidth(width)
+ end
+ def get_textborderwidth
+ @text.borderwidth
+ end
+ def textborderwidth(width = nil)
+ if width
+ set_textborderwidth(width)
+ else
+ get_textborderwidth
+ end
+ end
+
+ # set relief of text widget
+ def textrelief(type)
+ @text.relief(type)
+ end
+
+ # get/set width of scrollbar
+ def get_scrollbarwidth
+ @v_scroll.width
+ end
+ def set_scrollbarwidth(width)
+ @v_scroll.width(width)
+ @h_scroll.width(width)
+ end
+ alias :scrollbarwidth :set_scrollbarwidth
+
+ # vertical scrollbar : ON/OFF
+ def vscroll(mode)
+ st = TkGrid.info(@v_scroll)
+ if mode && st.size == 0 then
+ @v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
+ elsif !mode && st.size != 0 then
+ @v_scroll.ungrid
+ end
+ self
+ end
+
+ # horizontal scrollbar : ON/OFF
+ def hscroll(mode, wrap_mode="char")
+ st = TkGrid.info(@h_scroll)
+ if mode && st.size == 0 then
+ @h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew')
+ wrap 'none' # => self.wrap('none')
+ elsif !mode && st.size != 0 then
+ @h_scroll.ungrid
+ wrap wrap_mode # => self.wrap(wrap_mode)
+ end
+ self
+ end
+end
+
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ f = TkFrame.new.pack('fill'=>'x')
+ #t = TkTextFrame.new.pack
+ t = TkTextFrame.new(:textborderwidth=>3,
+ :textrelief=>:ridge,
+ :scrollbarrelief=>:ridge).pack
+ p t.configinfo
+ TkButton.new(f, 'text'=>'vscr OFF',
+ 'command'=>proc{t.vscroll(false)}).pack('side'=>'right')
+ TkButton.new(f, 'text'=>'vscr ON',
+ 'command'=>proc{t.vscroll(true)}).pack('side'=>'right')
+ TkButton.new(f, 'text'=>'hscr ON',
+ 'command'=>proc{t.hscroll(true)}).pack('side'=>'left')
+ TkButton.new(f, 'text'=>'hscr OFF',
+ 'command'=>proc{t.hscroll(false)}).pack('side'=>'left')
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tktimer.rb b/ext/tk/sample/tktimer.rb
index 34377e2f39..b1adb5b506 100644
--- a/ext/tk/sample/tktimer.rb
+++ b/ext/tk/sample/tktimer.rb
@@ -1,4 +1,4 @@
-#!/usr/local/bin/ruby
+#!/usr/bin/env ruby
# This script generates a counter with start and stop buttons.
require "tk"
diff --git a/ext/tk/sample/tktimer2.rb b/ext/tk/sample/tktimer2.rb
new file mode 100644
index 0000000000..dd31bb098e
--- /dev/null
+++ b/ext/tk/sample/tktimer2.rb
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
+
+require "tk"
+
+# new notation :
+# * symbols are acceptable as keys or values of the option hash
+# * the parent widget can be given by :parent key on the option hash
+root = TkRoot.new(:title=>'timer sample')
+label = TkLabel.new(:parent=>root, :relief=>:raised, :width=>10) \
+ .pack(:side=>:bottom, :fill=>:both)
+
+# define the procedure repeated by the TkTimer object
+tick = proc{|aobj| #<== TkTimer object
+ cnt = aobj.return_value + 5 # return_value keeps a result of the last proc
+ label.text format("%d.%02d", *(cnt.divmod(100)))
+ cnt #==> return value is kept by TkTimer object
+ # (so, can be send to the next repeat-proc)
+}
+
+timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
+ # ==> repeat-interval : (about) 50 ms,
+ # repeat : infinite (-1) times,
+ # repeat-procedure : tick (only one, in this case)
+ #
+ # ==> wait-before-call-init-proc : 0 ms,
+ # init_proc : proc{ label.text('0.00'); 0 }
+ #
+ # (0ms)-> init_proc ->(50ms)-> tick ->(50ms)-> tick ->....
+
+TkButton.new(:text=>'Start') {
+ command proc{ timer.continue unless timer.running? }
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+}
+TkButton.new(:text=>'Restart') {
+ command proc{ timer.restart(0, proc{ label.text('0.00'); 0 }) }
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+}
+TkButton.new(:text=>'Stop') {
+ command proc{ timer.stop if timer.running? }
+ pack('side'=>'right','fill'=>'both','expand'=>'yes')
+}
+
+ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
+Tk.root.bind(ev_quit, proc{Tk.exit}).focus
+
+Tk.mainloop
diff --git a/ext/tk/sample/tktimer3.rb b/ext/tk/sample/tktimer3.rb
new file mode 100644
index 0000000000..e3bb4c3e4a
--- /dev/null
+++ b/ext/tk/sample/tktimer3.rb
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
+
+require "tk"
+
+# new notation :
+# * symbols are acceptable as keys or values of the option hash
+# * the parent widget can be given by :parent key on the option hash
+root = TkRoot.new(:title=>'timer sample')
+label = TkLabel.new(:parent=>root, :relief=>:raised, :width=>10) \
+ .pack(:side=>:bottom, :fill=>:both)
+
+# define the procedure repeated by the TkTimer object
+tick = proc{|aobj| #<== TkTimer object
+ cnt = aobj.return_value + 5 # return_value keeps a result of the last proc
+ label.text format("%d.%02d", *(cnt.divmod(100)))
+ cnt #==> return value is kept by TkTimer object
+ # (so, can be send to the next repeat-proc)
+}
+
+timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
+ # ==> repeat-interval : (about) 50 ms,
+ # repeat : infinite (-1) times,
+ # repeat-procedure : tick (only one, in this case)
+ #
+ # ==> wait-before-call-init-proc : 0 ms,
+ # init_proc : proc{ label.text('0.00'); 0 }
+ #
+ # (0ms)-> init_proc ->(50ms)-> tick ->(50ms)-> tick ->....
+
+b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+}
+
+b_stop = TkButton.new(:text=>'Stop', :state=>:normal) {
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+}
+
+b_start.command {
+ timer.continue
+ b_stop.state(:normal)
+ b_start.state(:disabled)
+}
+
+b_stop.command {
+ timer.stop
+ b_start.state(:normal)
+ b_stop.state(:disabled)
+}
+
+TkButton.new(:text=>'Reset', :state=>:normal) {
+ command { timer.reset }
+ pack(:side=>:right, :fill=>:both, :expand=>:yes)
+}
+
+ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
+Tk.root.bind(ev_quit, proc{Tk.exit}).focus
+
+Tk.mainloop
diff --git a/ext/tk/sample/tktree.rb b/ext/tk/sample/tktree.rb
new file mode 100644
index 0000000000..d16d3344bd
--- /dev/null
+++ b/ext/tk/sample/tktree.rb
@@ -0,0 +1,103 @@
+##########################################################################
+# TkTree widget class
+#
+# see <http://wiki.tcl.tk/10615>
+#
+# Note: optional argument '-font' of the Tcl library is changed to
+# 'itemfont' on this Ruby library, because of avoiding font
+# operation trouble in 'initialize' method ( see the following
+# test script ).
+#
+##########################################################################
+require 'tk'
+
+class TkTree < TkCanvas
+ TCL_SCRIPT_PATH = File.join(File.dirname(__FILE__), 'tktree.tcl')
+
+ def create_self(keys)
+ args = [@path]
+ if keys.kind_of?(Hash)
+ font = keys.delete('itemfont')
+# font = hash_kv(font) if font.kind_of?(Hash)
+ keys['font'] = font if font
+# args.concat(hash_kv(keys))
+ args << keys
+ end
+ begin
+ tk_call('::tktree::treecreate', *args)
+ rescue NameError
+ Tk.load_tclscript(TkTree::TCL_SCRIPT_PATH)
+ tk_call('::tktree::treecreate', *args)
+ end
+ end
+
+ def newitem(itempath, keys = nil)
+ if keys.kind_of?(Hash)
+ keys = _symbolkey2str(keys)
+ font = keys.delete('itemfont')
+# font = hash_kv(font) if font.kind_of?(Hash)
+ keys['font'] = font if font
+# tk_call('::tktree::newitem', @path, itempath, *hash_kv(keys))
+ tk_call('::tktree::newitem', @path, itempath, keys)
+ else
+ tk_call('::tktree::newitem', @path, itempath)
+ end
+ end
+
+ def delitem(itempath)
+ tk_call('::tktree::delitem', @path, itempath)
+ end
+
+ def labelat(xpos, ypos)
+ tk_call('::tktree::delitem', @path, xpos, ypos)
+ end
+
+ def getselection
+ tk_call('::tktree::getselection', @path)
+ end
+
+ def setselection(itempath)
+ tk_call('::tktree::getselection', @path, itempath)
+ end
+end
+
+
+##########################################################################
+# test script
+##########################################################################
+if __FILE__ == $0
+ TkLabel.new(:text=><<EOL, :relief=>:ridge, :justify=>:left).pack
+
+ This is a sample to use a Tcl library script on Ruby/Tk.
+ This sample loads tktree.tcl (see <http://wiki.tcl.tk/10615>)
+ and calls functions of the Tcl script.
+EOL
+
+ items = %w(/group1/item1 /group1/item2 /group1/subgroup/item1 /group2/item1 /item1)
+
+ tr1 = TkTree.new.pack(:expand=>true, :fill=>:both)
+ tr1.focus
+
+ items.each{|item|
+ tr1.newitem(item,
+ :command=>proc{Tk.messageBox(:message=>"#{item} executed")})
+ }
+
+ f = TkFrame.new.pack(:expand=>true, :fill=>:both)
+ tr2 = TkTree.new(f, :bg=>'black', #:itemfont=>{:family=>'Times', :size=>14},
+ :textcolor=>'red', :bd=>4, :relief=>:ridge,
+ :selectbackground=>'darkBlue', :selectforeground=>'yellow',
+ :selectborderwidth=>3, :linecolor=>'yellow') {
+ yscrollbar(TkScrollbar.new(f, :width=>10).pack(:side=>:right, :fill=>:y))
+ xscrollbar(TkScrollbar.new(f, :width=>10).pack(:side=>:bottom, :fill=>:x))
+ pack(:expand=>true, :fill=>:both)
+ }
+
+ items.each{|item|
+ tr2.newitem(item, :textcolor=>'green', :image=>'',
+ :itemfont=>{:family=>'Times', :size=>10},
+ :command=>proc{Tk.messageBox(:message=>"#{item} executed")})
+ }
+
+ Tk.mainloop
+end
diff --git a/ext/tk/sample/tktree.tcl b/ext/tk/sample/tktree.tcl
new file mode 100644
index 0000000000..a5e47eb776
--- /dev/null
+++ b/ext/tk/sample/tktree.tcl
@@ -0,0 +1,305 @@
+#
+# This Tcl/Tk script is quoted from <http://wiki.tcl.tk/10615>.
+#
+ package require Tk
+ namespace eval ::tktree {
+
+ # Images used for open and close state of subgroups
+ set ::tktree::imgcollapse [image create photo .tktreeopenbm -data {
+ R0lGODdhCQAJAIAAAAEBAf///ywAAAAACQAJAAACEISPoRvG614D80x5ZXyogwIAOw==}]
+ set ::tktree::imgexpand [image create photo .tktreeclosebm -data {
+ R0lGODdhCQAJAIAAAAEBAf///ywAAAAACQAJAAACEYSPoRu28KCSDSJLc44s3lMAADs=}]
+ ###Default images for groups and children
+ set ::tktree::imgsubgroups [image create photo .tktreeimgfolder -data {
+ R0lGODlhEAANAKIAANnZ2Xh4eLi4uPj4APj4+AAAAP///////yH5BAEAAAAA
+ LAAAAAAQAA0AAANkCIChiqDLITgyEgi6GoIjIyMYugCBpMsaWBA0giMjIzgy
+ UYBBMjIoIyODEgVBODIygiMjE1gQJIMyMjIoI1GAQSMjODIyghMFQSgjI4My
+ MhJYEDSCIyMjODJRgKHLXAiApcsMmAA7}]
+ set ::tktree::imgchildren [image create photo .tktreeimgfile -data {
+ R0lGODlhDQAQAKIAANnZ2Xh4ePj4+Li4uAAAAP///////////yH5BAEAAAAA
+ LAAAAAANABAAAANSGLoLgACBoqsRCBAoujqCASGDojtESCEihCREIjgUKLo8
+ hCGCpCsySIGiy0MYIki6IoMUKLo8hCGCpCsySIGiy0MYKLo8hIGiy0MYOLo8
+ SLrMCQA7}]
+
+ #### Swtich all subgroups of a layer to open or close
+ proc ::tktree::switchlayer {win opn {layer /}} {
+ variable cfg
+ foreach child $cfg($win,$layer:subgroups) {
+ set cfg($win,$child:open) $opn
+ switchlayer $win $opn $child
+ }
+ buildwhenidle $win
+ }
+
+ #### will open or close the item given
+ proc ::tktree::switchstate {win item} {
+ set ::tktree::cfg($win,$item:open) [expr ! $::tktree::cfg($win,$item:open)]
+ buildwhenidle $win
+ }
+
+ #### Select the next item up or down
+ proc ::tktree::updown {win down} {
+ variable cfg
+ set index [lsearch -exact $cfg($win,sortlist) $cfg($win,selection)]
+ if {$down} {incr index} {incr index -1}
+ if {$index < 0} {set index end} elseif {$index >= [llength $cfg($win,sortlist)]} {set index 0}
+ setselection $win [lindex $cfg($win,sortlist) $index]
+ }
+
+ #### left-right button binding commands
+ proc ::tktree::leftright {win right} {
+ variable cfg
+ set item $cfg($win,selection)
+ set index [lsearch -exact $cfg($win,sortlist) $item]
+ set parentindex [lsearch -exact $cfg($win,sortlist) [file dirname $item]]
+ if {$parentindex == -1} {set parentindex [expr $index - 1]}
+ if {$cfg($win,$item:group)} {
+ if {$right} {
+ if {$cfg($win,$item:open)} {incr index} {set cfg($win,$item:open) 1}
+ } else {
+ if {$cfg($win,$item:open)} {set cfg($win,$item:open) 0} {set index $parentindex}
+ }
+ } else {
+ if {$right} {incr index} {set index $parentindex}
+ }
+ if {$index < 0} {set index end} elseif {$index >= [llength $cfg($win,sortlist)]} {set index 0}
+ setselection $win [lindex $cfg($win,sortlist) $index]
+ buildwhenidle $win
+ }
+
+ #### will return the pathname of the item at x and y cooridinates
+ proc ::tktree::labelat {win x y} {
+ set x [$win canvasx $x]; set y [$win canvasy $y]
+ foreach m [$win find overlapping $x $y $x $y] {
+ if {[info exists ::tktree::cfg($win,tag:$m)]} {return $::tktree::cfg($win,tag:$m)}
+ }
+ return ""
+ }
+
+ #### will return the path of the current selection in the given tree widget
+ proc ::tktree::getselection {win} {
+ return $::tktree::cfg($win,selection)
+ }
+
+ #### adjust the scrollview to show the selected item as needed
+ proc ::tktree::scrolladjust {win tag} {
+ update
+ set item [$win bbox $tag]
+ set region [$win cget -scrollregion]
+ foreach {axis idx1 idx2} {yview 1 3 xview 0 2} {
+ set range [expr abs([lindex $region $idx2]) - abs([lindex $region $idx1])]
+ set itemtop [lindex $item $idx1]; set itembot [lindex $item $idx2]
+ set viewtop [expr $range * [lindex [$win $axis] 0]]
+ set viewbot [expr $range * [lindex [$win $axis] 1]]
+ if {$itembot > $viewbot} {$win $axis moveto [expr ($itembot. - $viewbot + $viewtop) / $range]}
+ if {$itemtop < $viewtop} {$win $axis moveto [expr $itemtop. / $range]}
+ }
+ }
+
+ #### will set the current selection to the given item on the given tree
+ proc ::tktree::setselection {win item} {
+ variable cfg
+ if {![llength $cfg($win,sortlist)]} {return}
+ if {$item eq ""} {set item [lindex $cfg($win,sortlist) 0]}
+ if {![info exists cfg($win,$item:tag)]} {set item [lindex $cfg($win,sortlist) 0]}
+ if {[$win gettags $cfg($win,$item:tag)] ne ""} {
+ $win select from $cfg($win,$item:tag) 0
+ $win select to $cfg($win,$item:tag) end
+ set cfg($win,selection) $item
+ scrolladjust $win $cfg($win,$item:tag)
+ } {
+ setselection $win "/[lindex $cfg($win,/:sortlist) 0]"
+ }
+ }
+
+ #### will delete the item given from the tree given
+ proc ::tktree::delitem {win item} {
+ variable cfg
+ if {$item eq "/"} {
+ array unset cfg $win,* ; catch {destroy $win}
+ } {
+ set group [file dirname $item]
+ if {$cfg($win,$item:group)} {set type subgroups} {set type children}
+ set index [lsearch -exact $cfg($win,$group:$type) $item]
+ set cfg($win,$group:$type) [lreplace $cfg($win,$group:$type) $index $index]
+ array unset cfg $win,$item*
+ buildwhenidle $win
+ }
+ }
+
+ #### create a new item in the tree and rebuild the widget
+ proc ::tktree::newitem {win item args} {
+ variable cfg
+ if {[string index $item 0] ne "/"} {set item /$item}
+ if {[string index $item end] eq "/"} {
+ set subgroup 1
+ set type subgroups
+ set item [string range $item 0 end-1]
+ set cfg($win,$item:command) [list ::tktree::switchstate $win $item]
+ } {
+ set subgroup 0
+ set type children
+ set cfg($win,$item:command) {}
+ }
+ #Build parent group if needed
+ set group [file dirname $item]
+ if {![info exists cfg($win,$group:open)]} {newitem $win "$group\/"}
+ lappend cfg($win,$group:$type) $item
+ #Configure the new item
+ set cfg($win,$item:group) $subgroup
+ set cfg($win,$item:subgroups) {}
+ set cfg($win,$item:children) {}
+ set cfg($win,$item:sortlist) {}
+ set cfg($win,$item:tags) {}
+ set cfg($win,$item:open) 0
+ set cfg($win,$item:image) {}
+ set cfg($win,$item:textcolor) $cfg($win,textcolor)
+ set cfg($win,$item:font) $cfg($win,font)
+ if {$cfg($win,images)} {set cfg($win,$item:image) [eval list \$::tktree::img$type]}
+ foreach {confitem confval} $args {
+ switch -exact -- $confitem {
+ -textcolor {set cfg($win,$item:textcolor) $confval}
+ -command {set cfg($win,$item:command) $confval}
+ -image {set cfg($win,$item:image) $confval}
+ -font {set cfg($win,$item:font) $confval}
+ }
+ }
+ buildwhenidle $win
+ }
+
+ #### Draw the given layer of the tree on the canvas starting at xposition
+ proc ::tktree::buildlayer {win layer xpos} {
+ variable cfg
+ #Record y positions for vertical line later on
+ set ystart $cfg($win,y); set yend $cfg($win,y)
+ if {$layer eq "/"} {set cfg($win,sortlist) ""}
+ foreach child $cfg($win,$layer:sortlist) {
+ lappend cfg($win,sortlist) $child
+ #Check spacing required for images
+ set imgwidth 0; set imgheight 0
+ if {[string length $cfg($win,$child:image)]} {
+ set imgwidth [expr ([image width $cfg($win,$child:image)] + 2) / 2]
+ set imgheight [expr ([image height $cfg($win,$child:image)] + 2) / 2]
+ }
+ #find X-axis points for image, horiz line, and text
+ if {$imgwidth} {
+ set centerX [expr $imgwidth + $xpos + 7]
+ set rightX [expr $xpos + 7]
+ set textX [expr ($imgwidth * 2) + $xpos + 10]
+ } {
+ set centerX [expr $xpos + 10]
+ set rightX [expr $centerX + 4]
+ set textX [expr $rightX + 1]
+ }
+ #Find the proper amount to increment the y axis
+ set fontheight [lindex [font metrics $cfg($win,$child:font)] 5]
+ set yincr [expr ($fontheight + 1) / 2]
+ if {$imgheight > $yincr} {set yincr $imgheight}
+ incr cfg($win,y) $yincr
+ #Draw the horizonal line
+ $win create line $xpos $cfg($win,y) $rightX $cfg($win,y) -fill $cfg($win,linecolor)
+ set yend $cfg($win,y)
+ #Draw the image, if it exists
+ if {$imgwidth} {
+ set it [$win create image $centerX $cfg($win,y) -image $cfg($win,$child:image)]
+ $win bind $it <1> [list ::tktree::setselection $win $child]
+ }
+ #Draw text and store tags for reference
+ set cfg($win,$child:tag) [$win create text $textX $cfg($win,y) \
+ -text [file tail $child] -font $cfg($win,$child:font) -anchor w -tags x -fill $cfg($win,$child:textcolor)]
+ set cfg($win,tag:$cfg($win,$child:tag)) $child
+ #Command binding
+ $win bind $cfg($win,$child:tag) <1> [list ::tktree::setselection $win $child]
+ $win bind $cfg($win,$child:tag) <Double-1> $cfg($win,$child:command)
+ #next step up on the y axis
+ incr cfg($win,y) $yincr
+ #If its a group, add open-close functionality
+ if {$cfg($win,$child:group)} {
+ if {$cfg($win,$child:open)} {set img collapse} {set img expand}
+ set ocimg [$win create image $xpos [expr $cfg($win,y) - $yincr] -image [eval list \$::tktree::img$img]]
+ $win bind $ocimg <1> [list ::tktree::switchstate $win $child]
+ if {$cfg($win,$child:open)} {buildlayer $win $child $centerX}
+ }
+ }
+ #Vertical line
+ $win lower [$win create line $xpos [expr $ystart - 7] $xpos $yend -fill $cfg($win,linecolor)]
+ }
+
+ #### sort the layer by subgroups then children
+ proc ::tktree::sortlayer {win {layer /}} {
+ variable cfg
+ set cfg($win,$layer:subgroups) [lsort -dictionary $cfg($win,$layer:subgroups)]
+ set cfg($win,$layer:children) [lsort -dictionary $cfg($win,$layer:children)]
+ set cfg($win,$layer:sortlist) [join [list $cfg($win,$layer:subgroups) $cfg($win,$layer:children)]]
+ foreach group $cfg($win,$layer:subgroups) {sortlayer $win $group}
+ }
+
+ #### build the tree at the given path
+ proc ::tktree::buildtree {win} {
+ variable cfg
+ $win delete all
+ sortlayer $win
+ set xpos 5
+ set cfg($win,y) 5
+ #Draw global expand/contract button, if needed
+ if {[string length $cfg($win,/:subgroups)] && $cfg($win,expandall)} {
+ set exp 0
+ foreach subgroup $cfg($win,/:subgroups) {incr exp $cfg($win,$subgroup:open)}
+ if {$exp} {set type collapse} {set type expand}
+ set ocimg [$win create image 1 1 -image [eval list \$::tktree::img$type] -anchor w]
+ $win bind $ocimg <1> [list ::tktree::switchlayer $win [expr ! $exp]]
+ }
+ #Build the layers and set initial selection
+ buildlayer $win / $xpos
+ $win config -scrollregion [$win bbox all]
+ setselection $win $cfg($win,selection)
+ }
+
+ #### internal use - set up a handle to build the tree when everything is idle
+ proc ::tktree::buildwhenidle {win} {
+ catch {after cancel $::tktree::cfg($win,buildHandle)}
+ set ::tktree::cfg($win,buildHandle) [after idle [list ::tktree::buildtree $win]]
+ }
+
+ #### will create a new tree widget at the given path
+ proc ::tktree::treecreate {win args} {
+ variable cfg
+ #Default configuration for new tree
+ set cfg($win,selection) {}
+ set cfg($win,selidx) {}
+ set cfg($win,/:subgroups) {}
+ set cfg($win,/:children) {}
+ set cfg($win,/:open) 1
+ set cfg($win,images) 1
+ set cfg($win,expandall) 1
+ set cfg($win,linecolor) black
+ set cfg($win,textcolor) black
+ set cfg($win,font) {-family Helvetica -size 10}
+ #Parse and setup custom configuration options
+ set canvascfg ""
+ foreach {item val} $args {
+ switch -- $item {
+ -linecolor {set cfg($win,linecolor) $val}
+ -textcolor {set cfg($win,textcolor) $val}
+ -font {set cfg($win,font) $val}
+ -images {set cfg($win,images) $val}
+ -expandall {set cfg($win,expandall) $val}
+ default {lappend canvascfg $item $val}
+ }
+ }
+ #Build the canvas
+ eval {canvas $win -takefocus 1} $canvascfg
+ bind $win <Destroy> [list ::tktree::delitem $win /]
+ bind $win <1> [list focus $win]
+ bind $win <Return> {eval $::tktree::cfg(%W,[::tktree::getselection %W]:command)}
+ bind $win <space> {eval $::tktree::cfg(%W,[::tktree::getselection %W]:command)}
+ bind $win <Up> [list ::tktree::updown $win 0]
+ bind $win <Down> [list ::tktree::updown $win 1]
+ bind $win <Left> [list ::tktree::leftright $win 0]
+ bind $win <Right> [list ::tktree::leftright $win 1]
+
+ #Build the tree when idle
+ buildwhenidle $win
+ }
+ }
+
diff --git a/ext/tk/tkutil.c b/ext/tk/tkutil.c
index 6cfdad973b..04d276cca2 100644
--- a/ext/tk/tkutil.c
+++ b/ext/tk/tkutil.c
@@ -1,6 +1,6 @@
/************************************************
- tk.c -
+ tkutil.c -
$Author$
$Date$
@@ -9,37 +9,1344 @@
************************************************/
#include "ruby.h"
+#include "rubysig.h"
+#include "st.h"
+
+static VALUE cMethod;
+
+static VALUE cTclTkLib;
+
+static VALUE cTkObject;
+static VALUE cTkCallbackEntry;
+
+static VALUE TK_None;
+
+static VALUE cCB_SUBST;
+static VALUE cSUBST_INFO;
+
+static ID ID_split_tklist;
+static ID ID_toUTF8;
+static ID ID_fromUTF8;
+static ID ID_path;
+static ID ID_at_path;
+static ID ID_to_eval;
+static ID ID_to_s;
+static ID ID_source;
+static ID ID_downcase;
+static ID ID_install_cmd;
+static ID ID_merge_tklist;
+static ID ID_call;
+
+static ID ID_SUBST_INFO;
+
+static VALUE CALLBACK_TABLE;
+static unsigned long CALLBACK_ID_NUM = 0;
+
+/*************************************/
static VALUE
-tk_eval_cmd(argc, argv)
+tk_s_new(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE obj = rb_class_new_instance(argc, argv, klass);
+
+ if (rb_block_given_p()) rb_obj_instance_eval(0, 0, obj);
+ return obj;
+}
+
+/*************************************/
+
+static VALUE
+tkNone_to_s(self)
+ VALUE self;
+{
+ return rb_str_new2("None");
+}
+
+/*************************************/
+
+static VALUE
+tk_eval_cmd(argc, argv, self)
int argc;
VALUE argv[];
+ VALUE self;
{
- VALUE cmd, rest;
+ volatile VALUE cmd, rest, arg;
+ volatile VALUE ret;
+ int status;
rb_scan_args(argc, argv, "1*", &cmd, &rest);
- return rb_eval_cmd(cmd, rest);
+ return rb_eval_cmd(cmd, rest, 0);
}
static VALUE
-tk_s_new(argc, argv, klass)
- int argc;
+tk_do_callback(argc, argv, self)
+ int argc;
VALUE *argv;
- VALUE klass;
+ VALUE self;
{
- VALUE obj = rb_class_new_instance(argc, argv, klass);
+#if 0
+ volatile VALUE id;
+ volatile VALUE rest;
+
+ rb_scan_args(argc, argv, "1*", &id, &rest);
+ return rb_apply(rb_hash_aref(CALLBACK_TABLE, id), ID_call, rest);
+#endif
+ return rb_funcall2(rb_hash_aref(CALLBACK_TABLE, argv[0]),
+ ID_call, argc - 1, argv + 1);
+}
+
+static char *cmd_id_head = "ruby_cmd TkUtil callback ";
+static char *cmd_id_prefix = "cmd";
+
+static VALUE
+tk_install_cmd_core(cmd)
+ VALUE cmd;
+{
+ volatile VALUE id_num;
+
+ id_num = ULONG2NUM(CALLBACK_ID_NUM++);
+ id_num = rb_funcall(id_num, ID_to_s, 0, 0);
+ id_num = rb_str_append(rb_str_new2(cmd_id_prefix), id_num);
+ rb_hash_aset(CALLBACK_TABLE, id_num, cmd);
+ return rb_str_append(rb_str_new2(cmd_id_head), id_num);
+}
+
+static VALUE
+tk_install_cmd(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE cmd;
+
+#if 0
+ if (rb_scan_args(argc, argv, "01", &cmd) == 0) {
+ cmd = rb_block_proc();
+ }
+ return tk_install_cmd_core(cmd);
+#endif
+ if (argc == 0) {
+ cmd = rb_block_proc();
+ } else {
+ cmd = argv[0];
+ }
+ return tk_install_cmd_core(cmd);
+}
+
+static VALUE
+tk_uninstall_cmd(self, cmd_id)
+ VALUE self;
+ VALUE cmd_id;
+{
+ int head_len = strlen(cmd_id_head);
+ int prefix_len = strlen(cmd_id_prefix);
+
+ StringValue(cmd_id);
+ if (strncmp(cmd_id_head, RSTRING(cmd_id)->ptr, head_len) != 0) {
+ return Qnil;
+ }
+ if (strncmp(cmd_id_prefix,
+ RSTRING(cmd_id)->ptr + head_len, prefix_len) != 0) {
+ return Qnil;
+ }
+
+ return rb_hash_delete(CALLBACK_TABLE,
+ rb_str_new2(RSTRING(cmd_id)->ptr + head_len));
+}
+
+static VALUE
+tk_toUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return rb_funcall2(cTclTkLib, ID_toUTF8, argc, argv);
+}
+
+static VALUE
+tk_fromUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return rb_funcall2(cTclTkLib, ID_fromUTF8, argc, argv);
+}
+
+static VALUE
+fromDefaultEnc_toUTF8(str, self)
+ VALUE str;
+ VALUE self;
+{
+ VALUE argv[1];
+
+ argv[0] = str;
+ return tk_toUTF8(1, argv, self);
+}
+
+static VALUE
+fromUTF8_toDefaultEnc(str, self)
+ VALUE str;
+ VALUE self;
+{
+ VALUE argv[1];
+
+ argv[0] = str;
+ return tk_fromUTF8(1, argv, self);
+}
+
+
+static void
+hash_check(err)
+ int err;
+{
+ if (err) {
+ rb_raise(rb_eRuntimeError, "hash modified");
+ }
+}
+
+static int
+to_strkey(key, value, hash, err)
+ VALUE key;
+ VALUE value;
+ VALUE hash;
+ int err;
+{
+ hash_check(err);
+ if (key == Qundef) return ST_CONTINUE;
+ rb_hash_aset(hash, rb_funcall(key, ID_to_s, 0, 0), value);
+ return ST_CHECK;
+}
+
+static VALUE
+tk_symbolkey2str(self, keys)
+ VALUE self;
+ VALUE keys;
+{
+ volatile VALUE new_keys = rb_hash_new();
+
+ if NIL_P(keys) return new_keys;
+ keys = rb_convert_type(keys, T_HASH, "Hash", "to_hash");
+ st_foreach(RHASH(keys)->tbl, to_strkey, new_keys);
+ return new_keys;
+}
+
+static VALUE get_eval_string_core _((VALUE, VALUE, VALUE));
+static VALUE ary2list _((VALUE, VALUE));
+static VALUE ary2list2 _((VALUE, VALUE));
+static VALUE hash2list _((VALUE, VALUE));
+static VALUE hash2kv _((VALUE, VALUE, VALUE));
+
+static VALUE
+ary2list(ary, self)
+ VALUE ary;
+ VALUE self;
+{
+ int idx, idx2, size, size2;
+ volatile VALUE val, val2;
+ volatile VALUE dst;
+
+ /* size = RARRAY(ary)->len; */
+ size = 0;
+ for(idx = 0; idx < RARRAY(ary)->len; idx++) {
+ if (TYPE(RARRAY(ary)->ptr[idx]) == T_HASH) {
+ size += 2 * RHASH(RARRAY(ary)->ptr[idx])->tbl->num_entries;
+ } else {
+ size++;
+ }
+ }
+
+ dst = rb_ary_new2(size);
+ RARRAY(dst)->len = 0;
+ for(idx = 0; idx < RARRAY(ary)->len; idx++) {
+ val = RARRAY(ary)->ptr[idx];
+ switch(TYPE(val)) {
+ case T_ARRAY:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = ary2list(val, self);
+ break;
+
+ case T_HASH:
+ /* RARRAY(dst)->ptr[RARRAY(dst)->len++] = hash2list(val, self); */
+ val = hash2kv(val, Qnil, self);
+ size2 = RARRAY(val)->len;
+ for(idx2 = 0; idx2 < size2; idx2++) {
+ val2 = RARRAY(val)->ptr[idx2];
+ switch(TYPE(val2)) {
+ case T_ARRAY:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = ary2list(val2, self);
+ break;
+
+ case T_HASH:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = hash2list(val2, self);
+
+ default:
+ if (val2 != TK_None) {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = get_eval_string_core(val2, Qnil, self);
+ }
+ }
+ }
+ break;
+
+ default:
+ if (val != TK_None) {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = get_eval_string_core(val, Qnil, self);
+ }
+ }
+ }
+ return rb_apply(cTclTkLib, ID_merge_tklist, dst);
+}
+
+static VALUE
+ary2list2(ary, self)
+ VALUE ary;
+ VALUE self;
+{
+ int idx, size;
+ volatile VALUE val;
+ volatile VALUE dst;
+
+ size = RARRAY(ary)->len;
+ dst = rb_ary_new2(size);
+ RARRAY(dst)->len = 0;
+ for(idx = 0; idx < RARRAY(ary)->len; idx++) {
+ val = RARRAY(ary)->ptr[idx];
+ switch(TYPE(val)) {
+ case T_ARRAY:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = ary2list(val, self);
+ break;
+
+ case T_HASH:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = hash2list(val, self);
+ break;
+
+ default:
+ if (val != TK_None) {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = get_eval_string_core(val, Qnil, self);
+ }
+ }
+ }
+ return rb_apply(cTclTkLib, ID_merge_tklist, dst);
+}
+
+static VALUE
+key2keyname(key)
+ VALUE key;
+{
+ return rb_str_append(rb_str_new2("-"), rb_funcall(key, ID_to_s, 0, 0));
+}
+
+static VALUE
+assoc2kv(assoc, ary, self)
+ VALUE assoc;
+ VALUE ary;
+ VALUE self;
+{
+ int i, j, len;
+ volatile VALUE pair;
+ volatile VALUE val;
+ volatile VALUE dst = rb_ary_new2(2 * RARRAY(assoc)->len);
+
+ len = RARRAY(assoc)->len;
+
+ for(i = 0; i < len; i++) {
+ pair = RARRAY(assoc)->ptr[i];
+ if (TYPE(pair) != T_ARRAY) {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair);
+ continue;
+ }
+ switch(RARRAY(assoc)->len) {
+ case 2:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(pair)->ptr[2];
+
+ case 1:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = key2keyname(RARRAY(pair)->ptr[0]);
+
+ case 0:
+ continue;
+
+ default:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = key2keyname(RARRAY(pair)->ptr[0]);
+
+ val = rb_ary_new2(RARRAY(pair)->len - 1);
+ RARRAY(val)->len = 0;
+ for(j = 1; j < RARRAY(pair)->len; j++) {
+ RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j];
+ }
+
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = val;
+ }
+ }
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_plus(ary, dst);
+ }
+}
+
+static VALUE
+assoc2kv_enc(assoc, ary, self)
+ VALUE assoc;
+ VALUE ary;
+ VALUE self;
+{
+ int i, j, len;
+ volatile VALUE pair;
+ volatile VALUE val;
+ volatile VALUE dst = rb_ary_new2(2 * RARRAY(assoc)->len);
+
+ len = RARRAY(assoc)->len;
+
+ for(i = 0; i < len; i++) {
+ pair = RARRAY(assoc)->ptr[i];
+ if (TYPE(pair) != T_ARRAY) {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair);
+ continue;
+ }
+ switch(RARRAY(assoc)->len) {
+ case 2:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = get_eval_string_core(RARRAY(pair)->ptr[2], Qtrue, self);
+
+ case 1:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = key2keyname(RARRAY(pair)->ptr[0]);
+
+ case 0:
+ continue;
+
+ default:
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = key2keyname(RARRAY(pair)->ptr[0]);
+
+ val = rb_ary_new2(RARRAY(pair)->len - 1);
+ RARRAY(val)->len = 0;
+ for(j = 1; j < RARRAY(pair)->len; j++) {
+ RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j];
+ }
+
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = get_eval_string_core(val, Qtrue, self);
+ }
+ }
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_plus(ary, dst);
+ }
+}
+
+static int
+push_kv(key, val, args, err)
+ VALUE key;
+ VALUE val;
+ VALUE args;
+ int err;
+{
+ volatile VALUE ary;
+
+ hash_check(err);
+ ary = RARRAY(args)->ptr[0];
+
+ if (key == Qundef) return ST_CONTINUE;
+#if 0
+ rb_ary_push(ary, key2keyname(key));
+ if (val != TK_None) rb_ary_push(ary, val);
+#endif
+ RARRAY(ary)->ptr[RARRAY(ary)->len++] = key2keyname(key);
+
+ if (val == TK_None) return ST_CHECK;
+
+ RARRAY(ary)->ptr[RARRAY(ary)->len++]
+ = get_eval_string_core(val, Qnil, RARRAY(args)->ptr[1]);
+
+ return ST_CHECK;
+}
+
+static VALUE
+hash2kv(hash, ary, self)
+ VALUE hash;
+ VALUE ary;
+ VALUE self;
+{
+ volatile VALUE args = rb_ary_new2(2);
+ volatile VALUE dst = rb_ary_new2(2 * RHASH(hash)->tbl->num_entries);
+
+ RARRAY(dst)->len = 0;
+
+ RARRAY(args)->ptr[0] = dst;
+ RARRAY(args)->ptr[1] = self;
+ RARRAY(args)->len = 2;
+ st_foreach(RHASH(hash)->tbl, push_kv, args);
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_concat(ary, dst);
+ }
+}
+
+static int
+push_kv_enc(key, val, args, err)
+ VALUE key;
+ VALUE val;
+ VALUE args;
+ int err;
+{
+ volatile VALUE ary;
+
+ hash_check(err);
+ ary = RARRAY(args)->ptr[0];
+
+ if (key == Qundef) return ST_CONTINUE;
+#if 0
+ rb_ary_push(ary, key2keyname(key));
+ if (val != TK_None) {
+ rb_ary_push(ary, get_eval_string_core(val, Qtrue,
+ RARRAY(args)->ptr[1]));
+ }
+#endif
+ RARRAY(ary)->ptr[RARRAY(ary)->len++] = key2keyname(key);
+
+ if (val == TK_None) return ST_CHECK;
+
+ RARRAY(ary)->ptr[RARRAY(ary)->len++]
+ = get_eval_string_core(val, Qtrue, RARRAY(args)->ptr[1]);
+
+ return ST_CHECK;
+}
+
+static VALUE
+hash2kv_enc(hash, ary, self)
+ VALUE hash;
+ VALUE ary;
+ VALUE self;
+{
+ volatile VALUE args = rb_ary_new2(2);
+ volatile VALUE dst = rb_ary_new2(2 * RHASH(hash)->tbl->num_entries);
+
+ RARRAY(dst)->len = 0;
+
+ RARRAY(args)->ptr[0] = dst;
+ RARRAY(args)->ptr[1] = self;
+ RARRAY(args)->len = 2;
+ st_foreach(RHASH(hash)->tbl, push_kv_enc, args);
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_concat(ary, dst);
+ }
+}
+
+static VALUE
+hash2list(hash, self)
+ VALUE hash;
+ VALUE self;
+{
+ return ary2list2(hash2kv(hash, Qnil, self), self);
+}
+
+
+static VALUE
+hash2list_enc(hash, self)
+ VALUE hash;
+ VALUE self;
+{
+ return ary2list2(hash2kv_enc(hash, Qnil, self), self);
+}
+
+static VALUE
+tk_hash_kv(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE hash, enc_flag, ary;
+
+ ary = Qnil;
+ enc_flag = Qnil;
+ switch(argc) {
+ case 3:
+ ary = argv[2];
+ case 2:
+ enc_flag = argv[1];
+ case 1:
+ hash = argv[0];
+ break;
+ case 0:
+ rb_raise(rb_eArgError, "too few arguments");
+ default: /* >= 3 */
+ rb_raise(rb_eArgError, "too many arguments");
+ }
+
+ switch(TYPE(hash)) {
+ case T_ARRAY:
+ if (RTEST(enc_flag)) {
+ return assoc2kv_enc(hash, ary, self);
+ } else {
+ return assoc2kv(hash, ary, self);
+ }
+
+ case T_HASH:
+ if (RTEST(enc_flag)) {
+ return hash2kv_enc(hash, ary, self);
+ } else {
+ return hash2kv(hash, ary, self);
+ }
+
+ case T_NIL:
+ if (NIL_P(ary)) {
+ return rb_ary_new();
+ } else {
+ return ary;
+ }
+
+ default:
+ if (hash == TK_None) {
+ if (NIL_P(ary)) {
+ return rb_ary_new();
+ } else {
+ return ary;
+ }
+ }
+ rb_raise(rb_eArgError, "Hash is expected for 1st argument");
+ }
+}
+
+static VALUE
+get_eval_string_core(obj, enc_flag, self)
+ VALUE obj;
+ VALUE enc_flag;
+ VALUE self;
+{
+ switch(TYPE(obj)) {
+ case T_FLOAT:
+ case T_FIXNUM:
+ case T_BIGNUM:
+ return rb_funcall(obj, ID_to_s, 0, 0);
+
+ case T_STRING:
+ if (RTEST(enc_flag)) {
+ if (rb_respond_to(self, ID_toUTF8)) {
+ return rb_funcall(self, ID_toUTF8, 1, obj);
+ } else {
+ return fromDefaultEnc_toUTF8(obj, self);
+ }
+ } else {
+ return obj;
+ }
+
+ case T_SYMBOL:
+ if (RTEST(enc_flag)) {
+ if (rb_respond_to(self, ID_toUTF8)) {
+ return rb_funcall(self, ID_toUTF8, 1,
+ rb_str_new2(rb_id2name(SYM2ID(obj))));
+ } else {
+ return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self);
+ }
+ } else {
+ return rb_str_new2(rb_id2name(SYM2ID(obj)));
+ }
+
+ case T_HASH:
+ if (RTEST(enc_flag)) {
+ return hash2list_enc(obj, self);
+ } else {
+ return hash2list(obj, self);
+ }
+
+ case T_ARRAY:
+ if (RTEST(enc_flag)) {
+ return fromDefaultEnc_toUTF8(ary2list(obj, self), self);
+ } else {
+ return ary2list(obj, self);
+ }
+
+ case T_FALSE:
+ return rb_str_new2("0");
+
+ case T_TRUE:
+ return rb_str_new2("1");
+
+ case T_NIL:
+ return rb_str_new2("");
+
+ case T_REGEXP:
+ return rb_funcall(obj, ID_source, 0, 0);
+
+ default:
+ if (rb_obj_is_kind_of(obj, cTkObject)) {
+ /* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */
+ return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0),
+ enc_flag, self);
+ }
+
+ if (rb_obj_is_kind_of(obj, rb_cProc)
+ || rb_obj_is_kind_of(obj, cMethod)
+ || rb_obj_is_kind_of(obj, cTkCallbackEntry)) {
+ if (rb_respond_to(self, ID_install_cmd)) {
+ return rb_funcall(self, ID_install_cmd, 1, obj);
+ } else {
+ return tk_install_cmd_core(obj);
+ }
+ }
+
+ if (obj == TK_None) return Qnil;
+
+ if (rb_respond_to(obj, ID_to_eval)) {
+ /* return rb_funcall(obj, ID_to_eval, 0, 0); */
+ return get_eval_string_core(rb_funcall(obj, ID_to_eval, 0, 0),
+ enc_flag, self);
+ } else if (rb_respond_to(obj, ID_path)) {
+ /* return rb_funcall(obj, ID_path, 0, 0); */
+ return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0),
+ enc_flag, self);
+ } else if (rb_respond_to(obj, ID_to_s)) {
+ return rb_funcall(obj, ID_to_s, 0, 0);
+ }
+ }
+
+ rb_warning("fail to convert '%s' to string for Tk",
+ RSTRING(rb_funcall(obj, rb_intern("inspect"), 0, 0))->ptr);
- if (rb_block_given_p()) rb_obj_instance_eval(0, 0, obj);
return obj;
}
+static VALUE
+tk_get_eval_string(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE obj, enc_flag;
+
+ if (rb_scan_args(argc, argv, "11", &obj, &enc_flag) == 1) {
+ enc_flag = Qnil;
+ }
+
+ return get_eval_string_core(obj, enc_flag, self);
+}
+
+static VALUE
+tk_get_eval_enc_str(self, obj)
+ VALUE self;
+ VALUE obj;
+{
+ if (obj == TK_None) {
+ return obj;
+ } else {
+ return get_eval_string_core(obj, Qtrue, self);
+ }
+}
+
+static VALUE
+tk_conv_args(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ int idx, size;
+ volatile VALUE dst;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ old_gc = rb_gc_disable();
+
+ if (argc < 2) {
+ rb_raise(rb_eArgError, "too few arguments");
+ }
+ for(size = 0, idx = 2; idx < argc; idx++) {
+ if (TYPE(argv[idx]) == T_HASH) {
+ size += 2 * RHASH(argv[idx])->tbl->num_entries;
+ } else {
+ size++;
+ }
+ }
+ /* dst = rb_ary_new2(argc - 2); */
+ dst = rb_ary_new2(size);
+ RARRAY(dst)->len = 0;
+ for(idx = 2; idx < argc; idx++) {
+ if (TYPE(argv[idx]) == T_HASH) {
+ if (RTEST(argv[1])) {
+ hash2kv_enc(argv[idx], dst, self);
+ } else {
+ hash2kv(argv[idx], dst, self);
+ }
+ } else if (argv[idx] != TK_None) {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = get_eval_string_core(argv[idx], argv[1], self);
+ }
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ return rb_ary_plus(argv[0], dst);
+}
+
+
+/*************************************/
+
+static VALUE
+tcl2rb_bool(self, value)
+ VALUE self;
+ VALUE value;
+{
+ if (TYPE(value) == T_FIXNUM) {
+ if (NUM2INT(value) == 0) {
+ return Qfalse;
+ } else {
+ return Qtrue;
+ }
+ }
+
+ if (TYPE(value) == T_TRUE || TYPE(value) == T_FALSE) {
+ return value;
+ }
+
+ rb_check_type(value, T_STRING);
+
+ value = rb_funcall(value, ID_downcase, 0);
+
+ if (RSTRING(value)->ptr[0] == '\0'
+ || strcmp(RSTRING(value)->ptr, "0") == 0
+ || strcmp(RSTRING(value)->ptr, "no") == 0
+ || strcmp(RSTRING(value)->ptr, "off") == 0
+ || strcmp(RSTRING(value)->ptr, "false") == 0) {
+ return Qfalse;
+ } else {
+ return Qtrue;
+ }
+}
+
+static VALUE
+tkstr_to_dec(value)
+ VALUE value;
+{
+ return rb_cstr_to_inum(RSTRING(value)->ptr, 10, 1);
+}
+
+static VALUE
+tkstr_to_int(value)
+ VALUE value;
+{
+ return rb_cstr_to_inum(RSTRING(value)->ptr, 0, 1);
+}
+
+static VALUE
+tkstr_to_float(value)
+ VALUE value;
+{
+ return rb_float_new(rb_cstr_to_dbl(RSTRING(value)->ptr, 1));
+}
+
+static VALUE
+tkstr_invalid_numstr(value)
+ VALUE value;
+{
+ rb_raise(rb_eArgError,
+ "invalid value for Number: '%s'", RSTRING(value)->ptr);
+ return Qnil; /*dummy*/
+}
+
+static VALUE
+tkstr_rescue_float(value)
+ VALUE value;
+{
+ return rb_rescue2(tkstr_to_float, value,
+ tkstr_invalid_numstr, value,
+ rb_eArgError, 0);
+}
+
+static VALUE
+tkstr_to_number(value)
+ VALUE value;
+{
+ rb_check_type(value, T_STRING);
+
+ return rb_rescue2(tkstr_to_int, value,
+ tkstr_rescue_float, value,
+ rb_eArgError, 0);
+}
+
+static VALUE
+tcl2rb_number(self, value)
+ VALUE self;
+ VALUE value;
+{
+ return tkstr_to_number(value);
+}
+
+static VALUE
+tkstr_to_str(value)
+ VALUE value;
+{
+ char * ptr;
+ int len;
+
+ ptr = RSTRING(value)->ptr;
+ len = RSTRING(value)->len;
+
+ if (len > 1 && *ptr == '{' && *(ptr + len - 1) == '}') {
+ return rb_str_new(ptr + 1, len - 2);
+ }
+ return value;
+}
+
+static VALUE
+tcl2rb_string(self, value)
+ VALUE self;
+ VALUE value;
+{
+ rb_check_type(value, T_STRING);
+
+ return tkstr_to_str(value);
+}
+
+static VALUE
+tcl2rb_num_or_str(self, value)
+ VALUE self;
+ VALUE value;
+{
+ rb_check_type(value, T_STRING);
+
+ return rb_rescue2(tkstr_to_number, value,
+ tkstr_to_str, value,
+ rb_eArgError, 0);
+}
+
+
+/*************************************/
+
+struct cbsubst_info {
+ int size;
+ char *key;
+ char *type;
+ ID *ivar;
+ VALUE proc;
+};
+
+static void
+subst_mark(ptr)
+ struct cbsubst_info *ptr;
+{
+ rb_gc_mark(ptr->proc);
+}
+
+static void
+subst_free(ptr)
+ struct cbsubst_info *ptr;
+{
+ if (ptr) {
+ if (ptr->key != (char*)NULL) free(ptr->key);
+ if (ptr->type != (char*)NULL) free(ptr->type);
+ if (ptr->ivar != (ID*)NULL) free(ptr->ivar);
+ free(ptr);
+ }
+}
+
+static void
+cbsubst_init()
+{
+ struct cbsubst_info *inf;
+ ID *ivar;
+ volatile VALUE proc;
+
+ inf = ALLOC(struct cbsubst_info);
+
+ inf->size = 0;
+
+ inf->key = ALLOC_N(char, 1);
+ inf->key[0] = '\0';
+
+ inf->type = ALLOC_N(char, 1);
+ inf->type[0] = '\0';
+
+ ivar = ALLOC_N(ID, 1);
+ inf->ivar = ivar;
+
+ proc = rb_hash_new();
+ inf->proc = proc;
+
+ rb_const_set(cCB_SUBST, ID_SUBST_INFO,
+ Data_Wrap_Struct(cSUBST_INFO, subst_mark, subst_free, inf));
+}
+
+static VALUE
+cbsubst_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct cbsubst_info *inf;
+ volatile VALUE proc;
+ int idx;
+
+ Data_Get_Struct(rb_const_get(rb_obj_class(self), ID_SUBST_INFO),
+ struct cbsubst_info, inf);
+
+ for(idx = 0; idx < argc; idx++) {
+ rb_ivar_set(self, inf->ivar[idx], argv[idx]);
+ }
+
+ return self;
+}
+
+
+static VALUE
+cbsubst_ret_val(self, val)
+ VALUE self;
+ VALUE val;
+{
+ return val;
+}
+
+
+static VALUE
+cbsubst_get_subst_key(self, str)
+ VALUE self;
+ VALUE str;
+{
+ volatile VALUE list;
+ volatile VALUE ret;
+ int i, len;
+ char *buf, *ptr;
+
+ list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str);
+
+ len = RARRAY(list)->len;
+ buf = ALLOC_N(char, len + 1);
+
+ for(i = 0; i < len; i++) {
+ ptr = RSTRING(RARRAY(list)->ptr[i])->ptr;
+ if (*ptr == '%' && *(ptr + 2) == '\0') {
+ *(buf + i) = *(ptr + 1);
+ } else {
+ *(buf + i) = ' ';
+ }
+ }
+ *(buf + len) = '\0';
+
+ ret = rb_str_new2(buf);
+ free(buf);
+ return ret;
+}
+
+static VALUE
+cbsubst_get_all_subst_keys(self)
+ VALUE self;
+{
+ struct cbsubst_info *inf;
+ char *buf, *ptr;
+ int i, len;
+ volatile VALUE ret;
+
+ Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
+ struct cbsubst_info, inf);
+
+ len = strlen(inf->key);
+ buf = ALLOC_N(char, 3*len + 1);
+ ptr = buf;
+ for(i = 0; i < len; i++) {
+ *(ptr++) = '%';
+ *(ptr++) = *(inf->key + i);
+ *(ptr++) = ' ';
+ }
+ *(buf + 3*len) = '\0';
+
+ ret = rb_ary_new3(2, rb_str_new2(inf->key), rb_str_new2(buf));
+
+ free(buf);
+
+ return ret;
+}
+
+static VALUE
+cbsubst_table_setup(self, key_inf, proc_inf)
+ VALUE self;
+ VALUE key_inf;
+ VALUE proc_inf;
+{
+ struct cbsubst_info *subst_inf;
+ int idx;
+ int len = RARRAY(key_inf)->len;
+ int real_len = 0;
+ char *key = ALLOC_N(char, len + 1);
+ char *type = ALLOC_N(char, len + 1);
+ ID *ivar = ALLOC_N(ID, len + 1);
+ volatile VALUE proc = rb_hash_new();
+ volatile VALUE inf;
+
+ /* init */
+ subst_inf = ALLOC(struct cbsubst_info);
+ /* subst_inf->size = len; */
+ subst_inf->key = key;
+ subst_inf->type = type;
+ subst_inf->ivar = ivar;
+ subst_inf->proc = proc;
+
+ /*
+ * keys : array of [subst, type, ivar]
+ * subst ==> char code
+ * type ==> char code
+ * ivar ==> symbol
+ */
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY(key_inf)->ptr[idx];
+ if (TYPE(inf) != T_ARRAY) continue;
+ *(key + real_len) = (char)NUM2INT(RARRAY(inf)->ptr[0]);
+ *(type + real_len) = (char)NUM2INT(RARRAY(inf)->ptr[1]);
+
+ *(ivar + real_len)
+ = rb_intern(
+ RSTRING(
+ rb_str_cat2(rb_str_new2("@"),
+ rb_id2name(SYM2ID(RARRAY(inf)->ptr[2])))
+ )->ptr
+ );
+
+ rb_attr(self, SYM2ID(RARRAY(inf)->ptr[2]), 1, 0, Qtrue);
+ real_len++;
+ }
+ *(key + real_len) = '\0';
+ *(type + real_len) = '\0';
+ subst_inf->size = real_len;
+
+ /*
+ * procs : array of [type, proc]
+ * type ==> char code
+ * proc ==> proc/method/obj (must respond to 'call')
+ */
+ len = RARRAY(proc_inf)->len;
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY(proc_inf)->ptr[idx];
+ if (TYPE(inf) != T_ARRAY) continue;
+ rb_hash_aset(proc, RARRAY(inf)->ptr[0], RARRAY(inf)->ptr[1]);
+ }
+
+ rb_const_set(self, ID_SUBST_INFO,
+ Data_Wrap_Struct(cSUBST_INFO, subst_mark,
+ subst_free, subst_inf));
+
+ return self;
+}
+
+static VALUE
+cbsubst_get_extra_args_tbl(self)
+ VALUE self;
+{
+ return rb_ary_new();
+}
+
+static VALUE
+cbsubst_scan_args(self, arg_key, val_ary)
+ VALUE self;
+ VALUE arg_key;
+ VALUE val_ary;
+{
+ struct cbsubst_info *inf;
+ int idx;
+ int len = RARRAY(val_ary)->len;
+ char c;
+ char *ptr;
+ volatile VALUE dst = rb_ary_new2(len);
+ volatile VALUE proc;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ old_gc = rb_gc_disable();
+
+ Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO),
+ struct cbsubst_info, inf);
+
+ RARRAY(dst)->len = 0;
+ for(idx = 0; idx < len; idx++) {
+ if (idx >= RSTRING(arg_key)->len) {
+ proc = Qnil;
+ } else if (*(RSTRING(arg_key)->ptr + idx) == ' ') {
+ proc = Qnil;
+ } else {
+ ptr = strchr(inf->key, *(RSTRING(arg_key)->ptr + idx));
+ if (ptr == (char*)NULL) {
+ proc = Qnil;
+ } else {
+ c = *(inf->type + (ptr - inf->key));
+ proc = rb_hash_aref(inf->proc, INT2FIX(c));
+ }
+ }
+
+ if (NIL_P(proc)) {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(val_ary)->ptr[idx];
+ } else {
+ RARRAY(dst)->ptr[RARRAY(dst)->len++]
+ = rb_funcall(proc, ID_call, 1, RARRAY(val_ary)->ptr[idx]);
+ }
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ return dst;
+}
+
+static VALUE
+cbsubst_inspect(self)
+ VALUE self;
+{
+ return rb_str_new2("CallbackSubst");
+}
+
+static VALUE
+substinfo_inspect(self)
+ VALUE self;
+{
+ return rb_str_new2("SubstInfo");
+}
+
+/*************************************/
+
+static VALUE
+tk_cbe_inspect(self)
+ VALUE self;
+{
+ return rb_str_new2("TkCallbackEntry");
+}
+
+/*************************************/
+
+static VALUE
+tkobj_path(self)
+ VALUE self;
+{
+ return rb_ivar_get(self, ID_at_path);
+}
+
+/*************************************/
+
void
Init_tkutil()
{
- VALUE mTK = rb_define_module("TkUtil");
+ volatile VALUE tmp;
+
VALUE cTK = rb_define_class("TkKernel", rb_cObject);
+ VALUE mTK = rb_define_module("TkUtil");
- rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1);
+ /* --------------------- */
+ rb_global_variable(&cMethod);
+ cMethod = rb_const_get(rb_cObject, rb_intern("Method"));
+
+ ID_path = rb_intern("path");
+ ID_at_path = rb_intern("@path");
+ ID_to_eval = rb_intern("to_eval");
+ ID_to_s = rb_intern("to_s");
+ ID_source = rb_intern("source");
+ ID_downcase = rb_intern("downcase");
+ ID_install_cmd = rb_intern("install_cmd");
+ ID_merge_tklist = rb_intern("_merge_tklist");
+ ID_call = rb_intern("call");
+
+ /* --------------------- */
+ cCB_SUBST = rb_define_class_under(mTK, "CallbackSubst", rb_cObject);
+ rb_define_singleton_method(cCB_SUBST, "inspect", cbsubst_inspect, 0);
+
+ cSUBST_INFO = rb_define_class_under(cCB_SUBST, "Info", rb_cObject);
+ rb_define_singleton_method(cSUBST_INFO, "inspect", substinfo_inspect, 0);
+
+ ID_SUBST_INFO = rb_intern("SUBST_INFO");
+ rb_define_singleton_method(cCB_SUBST, "ret_val", cbsubst_ret_val, 1);
+ rb_define_singleton_method(cCB_SUBST, "scan_args", cbsubst_scan_args, 2);
+ rb_define_singleton_method(cCB_SUBST, "_get_subst_key",
+ cbsubst_get_subst_key, 1);
+ rb_define_singleton_method(cCB_SUBST, "_get_all_subst_keys",
+ cbsubst_get_all_subst_keys, 0);
+ rb_define_singleton_method(cCB_SUBST, "_setup_subst_table",
+ cbsubst_table_setup, 2);
+ rb_define_singleton_method(cCB_SUBST, "_get_extra_args_tbl",
+ cbsubst_get_extra_args_tbl, 0);
+
+ rb_define_method(cCB_SUBST, "initialize", cbsubst_initialize, -1);
+ cbsubst_init();
+
+ /* --------------------- */
+ rb_global_variable(&cTkCallbackEntry);
+ cTkCallbackEntry = rb_define_class("TkCallbackEntry", cTK);
+ rb_define_singleton_method(cTkCallbackEntry, "inspect", tk_cbe_inspect, 0);
+
+ /* --------------------- */
+ rb_global_variable(&cTkObject);
+ cTkObject = rb_define_class("TkObject", cTK);
+ rb_define_method(cTkObject, "path", tkobj_path, 0);
+
+ /* --------------------- */
+ rb_require("tcltklib");
+ rb_global_variable(&cTclTkLib);
+ cTclTkLib = rb_const_get(rb_cObject, rb_intern("TclTkLib"));
+ ID_split_tklist = rb_intern("_split_tklist");
+ ID_toUTF8 = rb_intern("_toUTF8");
+ ID_fromUTF8 = rb_intern("_fromUTF8");
+
+ /* --------------------- */
rb_define_singleton_method(cTK, "new", tk_s_new, -1);
+
+ /* --------------------- */
+ rb_global_variable(&TK_None);
+ TK_None = rb_obj_alloc(rb_cObject);
+ rb_define_const(mTK, "None", TK_None);
+ rb_define_singleton_method(TK_None, "to_s", tkNone_to_s, 0);
+ rb_define_singleton_method(TK_None, "inspect", tkNone_to_s, 0);
+ OBJ_FREEZE(TK_None);
+
+ /* --------------------- */
+ rb_global_variable(&CALLBACK_TABLE);
+ CALLBACK_TABLE = rb_hash_new();
+
+ /* --------------------- */
+ rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1);
+ rb_define_singleton_method(mTK, "callback", tk_do_callback, -1);
+ rb_define_singleton_method(mTK, "install_cmd", tk_install_cmd, -1);
+ rb_define_singleton_method(mTK, "uninstall_cmd", tk_uninstall_cmd, 1);
+ rb_define_singleton_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1);
+ rb_define_singleton_method(mTK, "hash_kv", tk_hash_kv, -1);
+ rb_define_singleton_method(mTK, "_get_eval_string",
+ tk_get_eval_string, -1);
+ rb_define_singleton_method(mTK, "_get_eval_enc_str",
+ tk_get_eval_enc_str, 1);
+
+ rb_define_singleton_method(mTK, "bool", tcl2rb_bool, 1);
+ rb_define_singleton_method(mTK, "number", tcl2rb_number, 1);
+ rb_define_singleton_method(mTK, "string", tcl2rb_string, 1);
+ rb_define_singleton_method(mTK, "num_or_str", tcl2rb_num_or_str, 1);
+
+ rb_define_method(mTK, "_toUTF8", tk_toUTF8, -1);
+ rb_define_method(mTK, "_fromUTF8", tk_fromUTF8, -1);
+ rb_define_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1);
+ rb_define_method(mTK, "hash_kv", tk_hash_kv, -1);
+ rb_define_method(mTK, "_get_eval_string", tk_get_eval_string, -1);
+ rb_define_method(mTK, "_get_eval_enc_str", tk_get_eval_enc_str, 1);
+ rb_define_method(mTK, "_conv_args", tk_conv_args, -1);
+
+ rb_define_method(mTK, "bool", tcl2rb_bool, 1);
+ rb_define_method(mTK, "number", tcl2rb_number, 1);
+ rb_define_method(mTK, "string", tcl2rb_string, 1);
+ rb_define_method(mTK, "num_or_str", tcl2rb_num_or_str, 1);
+
+ /* --------------------- */
}
diff --git a/ext/win32ole/.cvsignore b/ext/win32ole/.cvsignore
new file mode 100644
index 0000000000..44e7f262dc
--- /dev/null
+++ b/ext/win32ole/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.log
diff --git a/ext/win32ole/depend b/ext/win32ole/depend
new file mode 100644
index 0000000000..4bf5ab5b94
--- /dev/null
+++ b/ext/win32ole/depend
@@ -0,0 +1 @@
+win32ole.o : win32ole.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h
diff --git a/ext/win32ole/doc/win32ole.rd b/ext/win32ole/doc/win32ole.rd
new file mode 100644
index 0000000000..c563ce5d5b
--- /dev/null
+++ b/ext/win32ole/doc/win32ole.rd
@@ -0,0 +1,294 @@
+=begin
+= Win32OLE extension module
+
+== WIN32OLE
+=== Constants
+: VERSION
+ The version number of WIN32OLE.
+
+: ARGV
+ The argument of the method invoked recently.
+ This constant is used to get value of argument
+ when the argument is passed by reference.
+
+=== Class Method
+: connect(oleserver)
+ returns running OLE automation object or WIN32OLE object from moniker.
+
+: const_load(ole [,obj])
+ defines the constants of OLE automation
+ server as 'obj' class constants. If 'obj' omitted, the default
+ is WIN32OLE.
+
+: new(oleserver)
+ returns OLE Automation object.
+
+: ole_free(obj)
+ invokes Release method of Dispatch interface of WIN32OLE object.
+ This method should not be used because this method exists for debugging WIN32OLE.
+
+: ole_reference_count(obj)
+ returns reference counter of Dispatch interface.
+ This method should not be used because this method exists for debugging WIN32OLE.
+
+: ole_show_help(info [,helpcontext])
+ displays helpfile.
+ The first argument specifies WIN32OLE_TYPE object or WIN32OLE_METHOD object
+ or helpfile.
+
+=== Method
+: self[property]
+ gets property of OLE object.
+
+: self[property]=
+ sets property of OLE object.
+
+: _invoke(dispid, args, types)
+ runs the early binding method.
+ The dispid specifies Dispatch ID, args specifies the array of arguments,
+ types specifies array of the type of arguments.
+
+: each {...}
+ Iterates over each item of OLE collection which has IEnumVARIANT
+ interface.
+
+: invoke(method, args,...)
+ runs OLE method.
+
+: ole_func_methods
+ returns array of WIN32OLE_METHOD object which corresponds with function.
+
+: ole_get_methods
+ returns array of WIN32OLE_METHOD object which corresponds with get properties.
+
+: ole_method(method)
+ returns WIN32OLE_METHOD object which coreesponds with method
+ which specified by argument.
+
+: ole_method_help(method)
+ alias of ole_method.
+
+: ole_methods
+ returns WIN32OLE_METHOD object which coreesponds with method.
+
+: ole_obj_help
+ returns WIN32OLE_TYPE object.
+
+: ole_put_methods
+ returns array of WIN32OLE_METHOD object which corresponds with put properties.
+
+: setproperty(property, key, val)
+ set property of OLE object.
+ This method is used when the property has argument.
+
+ For example, in VB
+ obj.item("key") = val
+ in Win32OLE
+ obj.setproperty("item", "key", val)
+
+
+== WIN32OLE_EVENT class
+
+=== Class Method
+
+: new(ole, interface)
+ The new class method creates OLE event sink object to connect ole.
+ The ole must be WIN32OLE object, and interface is the interface
+ name of event.
+
+: message_loop
+ The message_loop class method translates and dispatches Windows
+ message.
+
+=== Method
+: on_event([event]){...}
+ defines the callback of event.
+ If event omitted, defines the callback of all events.
+
+: on_event_with_outargs([event]) {...}
+ defines the callback of event.
+ If you want modify argument in callback,
+
+== WIN32OLE_METHOD
+
+=== Class Methods
+: new(win32ole_type, method)
+ creates WIN32OLE_METHOD object.
+
+=== Methods
+: dispid
+ returns Dispatch ID.
+
+: event?
+ returns true if the method is event.
+
+: event_interface
+ returns interface name of event if the method is event.
+
+: helpcontext
+ returns help context.
+
+: helpfile
+ returns help file.
+
+: invkind
+ returns invkind.
+
+: invoke_kind
+ returns invoke kind string.
+
+: name
+ returns name of method.
+
+: offset_vtbl
+ returns the offset of Vtbl.
+
+: params
+ returns array of WIN32OLE_PARAM object.
+
+: return_type
+ returns string of return value type of method.
+
+: return_vtype
+ returns number of return value type of method.
+
+: return_type_detail
+ returns detail information of return value type of method.
+
+: size_params
+ returns the size of arguments.
+
+: size_opt_params
+ returns the size of optional arguments.
+
+: visible?
+ returns true if the method is public.
+
+== WIN32OLE_PARAM
+: default
+ returns default value.
+
+: input?
+ returns true if argument is input.
+
+: optional?
+ returns true if argument is optional.
+
+: output?
+ returns true if argument is output.
+
+: name
+ returns name.
+
+: ole_type
+ returns type of argument.
+
+: ole_type_detail
+ returns detail information of type of argument.
+
+: retval?
+ returns true if argument is return value.
+
+== WIN32OLE_TYPE
+=== Class Methods
+: new(typelibrary, class)
+ returns WIN32OLE_TYPE object.
+
+: ole_classes(typelibrary)
+ returns array of WIN32OLE_TYPE objects defined by Type Library.
+
+: progids
+ returns array of ProgID.
+
+: typelibs
+ returns array of type libraries.
+
+=== Methods
+: guid
+ returns GUID.
+
+: helpfile
+ returns helpfile.
+
+: helpcontext
+ returns helpcontext.
+
+: helpstring
+ returns help string.
+
+: major_version
+ returns major version.
+
+: minor_version
+ returns minor version.
+
+: name
+ returns name.
+
+: ole_methods
+ returns array of WIN32OLE_METHOD objects.
+
+: ole_type
+ returns type of class.
+
+: progid
+ returns ProgID if it exists. If not found, then returns nil.
+
+: src_type
+ returns source class when the OLE class is 'Alias'.
+
+: typekind
+ returns number which represents type.
+
+: variables
+ returns array of variables defined in OLE class.
+
+: visible?
+ returns true if the OLE class is public.
+
+== WIN32OLE_VARIABLE
+=== Methods
+: name
+ returns the name.
+
+: ole_type
+ returns type
+
+: ole_type_detail
+ returns detail information of type.
+
+: value
+ returns value.
+
+: variable_kind
+ returns variable kind string.
+
+: varkind
+ returns the number which represents variable kind.
+
+== WIN32OLE::VARIANT
+=== Constants
+ *VT_I4
+ *VT_R4
+ *VT_R8
+ *VT_CY
+ *VT_DATE
+ *VT_BSTR
+ *VT_USERDEFINED
+ *VT_PTR
+ *VT_DISPATCH
+ *VT_ERROR
+ *VT_BOOL
+ *VT_VARIANT
+ *VT_UNKNOWN
+ *VT_I1
+ *VT_UI1
+ *VT_UI2
+ *VT_UI4
+ *VT_INT
+ *VT_UINT
+ *VT_ARRAY
+ *VT_BYREF
+
+=end
+
diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb
new file mode 100644
index 0000000000..c989267733
--- /dev/null
+++ b/ext/win32ole/extconf.rb
@@ -0,0 +1,27 @@
+#----------------------------------
+# extconf.rb
+# $Revision$
+# $Date$
+#----------------------------------
+require 'mkmf'
+
+dir_config("win32")
+def create_win32ole_makefile
+ if have_library("ole32") and
+ have_library("oleaut32") and
+ have_library("uuid") and
+ have_library("user32") and
+ have_library("kernel32") and
+ have_library("advapi32") and
+ have_header("windows.h")
+ create_makefile("win32ole")
+ end
+end
+
+case RUBY_PLATFORM
+when /mswin32/
+ $CFLAGS += ' /W3'
+when /cygwin/, /mingw/
+ $defs << '-DNONAMELESSUNION'
+end
+create_win32ole_makefile
diff --git a/ext/win32ole/lib/win32ole/property.rb b/ext/win32ole/lib/win32ole/property.rb
new file mode 100644
index 0000000000..a68bad9af8
--- /dev/null
+++ b/ext/win32ole/lib/win32ole/property.rb
@@ -0,0 +1,16 @@
+# OLEProperty
+# helper class of Property with arguments.
+class OLEProperty
+ def initialize(obj, dispid, gettypes, settypes)
+ @obj = obj
+ @dispid = dispid
+ @gettypes = gettypes
+ @settypes = settypes
+ end
+ def [](*args)
+ @obj._getproperty(@dispid, args, @gettypes)
+ end
+ def []=(*args)
+ @obj._setproperty(@dispid, args, @settypes)
+ end
+end
diff --git a/ext/win32ole/sample/excel1.rb b/ext/win32ole/sample/excel1.rb
new file mode 100644
index 0000000000..e366a52839
--- /dev/null
+++ b/ext/win32ole/sample/excel1.rb
@@ -0,0 +1,22 @@
+require 'win32ole'
+
+#application = WIN32OLE.new('Excel.Application.5')
+application = WIN32OLE.new('Excel.Application')
+
+application.visible = TRUE
+workbook = application.Workbooks.Add();
+worksheet = workbook.Worksheets(1);
+worksheet.Range("A1:D1").value = ["North","South","East","West"];
+worksheet.Range("A2:B2").value = [5.2, 10];
+worksheet.Range("C2").value = 8;
+worksheet.Range("D2").value = 20;
+
+range = worksheet.Range("A1:D2");
+range.Select
+chart = workbook.Charts.Add;
+
+workbook.saved = TRUE;
+
+application.ActiveWorkbook.Close(0);
+application.Quit();
+
diff --git a/ext/win32ole/sample/excel2.rb b/ext/win32ole/sample/excel2.rb
new file mode 100644
index 0000000000..46f459b36b
--- /dev/null
+++ b/ext/win32ole/sample/excel2.rb
@@ -0,0 +1,30 @@
+require 'win32ole'
+
+# -4100 is the value for the Excel constant xl3DColumn.
+ChartTypeVal = -4100;
+
+# Creates OLE object to Excel
+#excel = WIN32OLE.new("excel.application.5")
+excel = WIN32OLE.new("excel.application")
+
+# Create and rotate the chart
+
+excel['Visible'] = TRUE;
+excel.Workbooks.Add();
+excel.Range("a1")['Value'] = 3;
+excel.Range("a2")['Value'] = 2;
+excel.Range("a3")['Value'] = 1;
+excel.Range("a1:a3").Select();
+excelchart = excel.Charts.Add();
+excelchart['Type'] = ChartTypeVal;
+
+i = 30
+i.step(180, 10) do |rot|
+# excelchart['Rotation'] = rot;
+ excelchart.rotation=rot;
+end
+# Done, bye
+
+excel.ActiveWorkbook.Close(0);
+excel.Quit();
+
diff --git a/ext/win32ole/sample/excel3.rb b/ext/win32ole/sample/excel3.rb
new file mode 100644
index 0000000000..0f96717063
--- /dev/null
+++ b/ext/win32ole/sample/excel3.rb
@@ -0,0 +1,13 @@
+require 'win32ole'
+
+#application = WIN32OLE.new('Excel.Application.5')
+application = WIN32OLE.new('Excel.Application')
+
+application.visible = TRUE
+workbook = application.Workbooks.Add();
+sheet = workbook.Worksheets(1);
+sheetS = workbook.Worksheets
+puts "The number of sheets is #{sheetS.count}"
+puts "Now add 2 sheets after of `#{sheet.name}`"
+sheetS.add({'count'=>2, 'after'=>sheet})
+puts "The number of sheets is #{sheetS.count}"
diff --git a/ext/win32ole/sample/ie.rb b/ext/win32ole/sample/ie.rb
new file mode 100644
index 0000000000..11dc861e0b
--- /dev/null
+++ b/ext/win32ole/sample/ie.rb
@@ -0,0 +1,11 @@
+require 'win32ole'
+url = 'http://www.ruby-lang.org/'
+ie = WIN32OLE.new('InternetExplorer.Application')
+ie.visible = TRUE
+ie.gohome
+print "Now navigate Ruby home page... Please enter."
+gets
+ie.navigate(url)
+print "Now quit Internet Explorer... Please enter."
+gets
+ie.Quit()
diff --git a/ext/win32ole/sample/ieconst.rb b/ext/win32ole/sample/ieconst.rb
new file mode 100644
index 0000000000..234272c7ed
--- /dev/null
+++ b/ext/win32ole/sample/ieconst.rb
@@ -0,0 +1,32 @@
+require 'win32ole'
+
+ie = WIN32OLE.new('InternetExplorer.Application')
+=begin
+WIN32OLE.const_load(ie)
+WIN32OLE.constants.sort.each do |c|
+ puts "#{c} = #{WIN32OLE.const_get(c)}"
+end
+=end
+
+module IE_CONST
+end
+
+WIN32OLE.const_load(ie, IE_CONST)
+IE_CONST.constants.sort.each do |c|
+ puts "#{c} = #{IE_CONST.const_get(c)}"
+end
+
+#------------------------------------------------------------
+# Remark!!! CONSTANTS has not tested enoughly!!!
+# CONSTANTS is alpha release.
+# If there are constants which first letter is not [a-zA-Z],
+# like a '_Foo', then maybe you can access the value by
+# using CONSTANTS['_Foo']
+#------------------------------------------------------------
+IE_CONST::CONSTANTS.each do |k, v|
+ puts "#{k} = #{v}"
+end
+
+puts WIN32OLE::VERSION
+ie.quit
+
diff --git a/ext/win32ole/sample/ienavi.rb b/ext/win32ole/sample/ienavi.rb
new file mode 100644
index 0000000000..c7fa3f5ec2
--- /dev/null
+++ b/ext/win32ole/sample/ienavi.rb
@@ -0,0 +1,40 @@
+require 'win32ole'
+
+$urls = []
+
+def navigate(url)
+ $urls << url
+end
+
+def stop_msg_loop
+ puts "Now Stop IE..."
+ $LOOP = FALSE;
+end
+
+def default_handler(event, *args)
+ case event
+ when "BeforeNavigate"
+ puts "Now Navigate #{args[0]}..."
+ end
+end
+
+ie = WIN32OLE.new('InternetExplorer.Application')
+ie.visible = TRUE
+ie.gohome
+
+ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
+
+ev.on_event {|*args| default_handler(*args)}
+ev.on_event("NavigateComplete") {|url| navigate(url)}
+ev.on_event("Quit") {|*args| stop_msg_loop}
+
+$LOOP = TRUE
+while ($LOOP)
+ WIN32OLE_EVENT.message_loop
+end
+
+puts "You Navigated the URLs ..."
+$urls.each_with_index do |url, i|
+ puts "(#{i+1}) #{url}"
+end
+
diff --git a/ext/win32ole/sample/oledirs.rb b/ext/win32ole/sample/oledirs.rb
new file mode 100644
index 0000000000..1c77e76f14
--- /dev/null
+++ b/ext/win32ole/sample/oledirs.rb
@@ -0,0 +1,23 @@
+#
+# You need WSH(Windows Scripting Host) to run this script.
+#
+
+require "win32ole"
+
+def listup(items)
+# items.each do |i|
+ for i in items
+ puts i.name
+ end
+end
+
+fs = WIN32OLE.new("Scripting.FileSystemObject")
+
+folder = fs.GetFolder(".")
+
+puts "--- folder of #{folder.path} ---"
+listup(folder.SubFolders)
+
+puts "--- files of #{folder.path} ---"
+listup(folder.Files)
+
diff --git a/ext/win32ole/sample/olegen.rb b/ext/win32ole/sample/olegen.rb
new file mode 100644
index 0000000000..48d86893fe
--- /dev/null
+++ b/ext/win32ole/sample/olegen.rb
@@ -0,0 +1,348 @@
+#-----------------------------
+# olegen.rb
+# $Date$
+# $Revision$
+#-----------------------------
+
+require 'win32ole'
+
+class WIN32COMGen
+ def initialize(typelib)
+ @typelib = typelib
+ @reciever = ""
+ end
+ attr_reader :typelib
+
+ def ole_classes(typelib)
+ begin
+ @ole = WIN32OLE.new(typelib)
+ [@ole.ole_obj_help]
+ rescue
+ WIN32OLE_TYPE.ole_classes(typelib)
+ end
+ end
+
+ def generate_args(method)
+ args = []
+ if method.size_opt_params >= 0
+ size_required_params = method.size_params - method.size_opt_params
+ else
+ size_required_params = method.size_params - 1
+ end
+ size_required_params.times do |i|
+ if method.params[i] && method.params[i].optional?
+ args.push "arg#{i}=nil"
+ else
+ args.push "arg#{i}"
+ end
+ end
+ if method.size_opt_params >= 0
+ method.size_opt_params.times do |i|
+ args.push "arg#{i + size_required_params}=nil"
+ end
+ else
+ args.push "*arg"
+ end
+ args.join(", ")
+ end
+
+ def generate_argtype(typedetails)
+ ts = ''
+ typedetails.each do |t|
+ case t
+ when 'CARRAY', 'VOID', 'UINT', 'RESULT', 'DECIMAL', 'I8', 'UI8'
+# raise "Sorry type\"" + t + "\" not supported"
+ ts << "\"??? NOT SUPPORTED TYPE:`#{t}'\""
+ when 'USERDEFINED', 'Unknown Type 9'
+ ts << 'VT_DISPATCH'
+ break;
+ when 'SAFEARRAY'
+ ts << 'VT_ARRAY|'
+ when 'PTR'
+ ts << 'VT_BYREF|'
+ when 'INT'
+ ts << 'VT_I4'
+ else
+ if String === t
+ ts << 'VT_' + t
+ end
+ end
+ end
+ if ts.empty?
+ ts = 'VT_VARIANT'
+ elsif ts[-1] == ?|
+ ts += 'VT_VARIANT'
+ end
+ ts
+ end
+
+ def generate_argtypes(method, proptypes)
+ types = method.params.collect{|param|
+ generate_argtype(param.ole_type_detail)
+ }.join(", ")
+ if proptypes
+ types += ", " if types.size > 0
+ types += generate_argtype(proptypes)
+ end
+ types
+ end
+
+ def generate_method_body(method, disptype, types=nil)
+ " ret = #{@reciever}#{disptype}(#{method.dispid}, [" +
+ generate_args(method).gsub("=nil", "") +
+ "], [" +
+ generate_argtypes(method, types) +
+ "])\n" +
+ " @lastargs = WIN32OLE::ARGV\n" +
+ " ret"
+ end
+
+ def generate_method_help(method, type = nil)
+ str = " # "
+ if type
+ str += type
+ else
+ str += method.return_type
+ end
+ str += " #{method.name}"
+ if method.event?
+ str += " EVENT"
+ str += " in #{method.event_interface}"
+ end
+ if method.helpstring && method.helpstring != ""
+ str += "\n # "
+ str += method.helpstring
+ end
+ args_help = generate_method_args_help(method)
+ if args_help
+ str += "\n"
+ str += args_help
+ end
+ str
+ end
+
+ def generate_method_args_help(method)
+ args = []
+ method.params.each_with_index {|param, i|
+ h = " # #{param.ole_type} arg#{i} --- #{param.name}"
+ inout = []
+ inout.push "IN" if param.input?
+ inout.push "OUT" if param.output?
+ h += " [#{inout.join('/')}]"
+ h += " ( = #{param.default})" if param.default
+ args.push h
+ }
+ if args.size > 0
+ args.join("\n")
+ else
+ nil
+ end
+ end
+
+ def generate_method(method, disptype, io = STDOUT, types = nil)
+ io.puts "\n"
+ io.puts generate_method_help(method)
+ if method.invoke_kind == 'PROPERTYPUT'
+ io.print " def #{method.name}=("
+ else
+ io.print " def #{method.name}("
+ end
+ io.print generate_args(method)
+ io.puts ")"
+ io.puts generate_method_body(method, disptype, types)
+ io.puts " end"
+ end
+
+ def generate_propputref_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYPUTREF' && method.visible?
+ }.each do |method|
+ generate_method(method, io)
+ end
+ end
+
+ def generate_properties_with_args(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYGET' &&
+ method.visible? &&
+ method.size_params > 0
+ }.each do |method|
+ types = method.return_type_detail
+ io.puts "\n"
+ io.puts generate_method_help(method, types[0])
+ io.puts " def #{method.name}"
+ if klass.ole_type == "Class"
+ io.print " OLEProperty.new(@dispatch, #{method.dispid}, ["
+ else
+ io.print " OLEProperty.new(self, #{method.dispid}, ["
+ end
+ io.print generate_argtypes(method, nil)
+ io.print "], ["
+ io.print generate_argtypes(method, types)
+ io.puts "])"
+ io.puts " end"
+ end
+ end
+
+ def generate_propput_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYPUT' && method.visible? &&
+ method.size_params == 1
+ }.each do |method|
+ ms = klass.ole_methods.select {|m|
+ m.invoke_kind == 'PROPERTYGET' &&
+ m.dispid == method.dispid
+ }
+ types = []
+ if ms.size == 1
+ types = ms[0].return_type_detail
+ end
+ generate_method(method, '_setproperty', io, types)
+ end
+ end
+
+ def generate_propget_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYGET' && method.visible? &&
+ method.size_params == 0
+ }.each do |method|
+ generate_method(method, '_getproperty', io)
+ end
+ end
+
+ def generate_func_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == "FUNC" && method.visible?
+ }.each do |method|
+ generate_method(method, '_invoke', io)
+ end
+ end
+
+ def generate_methods(klass, io = STDOUT)
+ generate_propget_methods(klass, io)
+ generate_propput_methods(klass, io)
+ generate_properties_with_args(klass, io)
+ generate_func_methods(klass, io)
+# generate_propputref_methods(klass, io)
+ end
+
+ def generate_constants(klass, io = STDOUT)
+ klass.variables.select {|v|
+ v.visible? && v.variable_kind == 'CONSTANT'
+ }.each do |v|
+ io.print " "
+ io.print v.name.sub(/^./){|c| c.upcase}
+ io.print " = "
+ io.puts v.value
+ end
+ end
+
+ def class_name(klass)
+ klass_name = klass.name
+ if klass.ole_type == "Class" &&
+ klass.guid &&
+ klass.progid
+ klass_name = klass.progid.gsub(/\./, '_')
+ end
+ if /^[A-Z]/ !~ klass_name || Module.constants.include?(klass_name)
+ klass_name = 'OLE' + klass_name
+ end
+ klass_name
+ end
+
+ def define_initialize(klass)
+ <<STR
+
+ def initialize(obj = nil)
+ @clsid = "#{klass.guid}"
+ @progid = "#{klass.progid}"
+ if obj.nil?
+ @dispatch = WIN32OLE.new @progid
+ else
+ @dispatch = obj
+ end
+ end
+STR
+ end
+
+ def define_include
+ " include WIN32OLE::VARIANT"
+ end
+
+ def define_instance_variables
+ " attr_reader :lastargs"
+ end
+
+ def define_method_missing
+ <<STR
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+STR
+ end
+
+ def define_class(klass, io = STDOUT)
+ io.puts "class #{class_name(klass)} # #{klass.name}"
+ io.puts define_include
+ io.puts define_instance_variables
+ io.puts " attr_reader :dispatch"
+ io.puts " attr_reader :clsid"
+ io.puts " attr_reader :progid"
+ io.puts define_initialize(klass)
+ io.puts define_method_missing
+ end
+
+ def define_module(klass, io = STDOUT)
+ io.puts "module #{class_name(klass)}"
+ io.puts define_include
+ io.puts define_instance_variables
+ end
+
+ def generate_class(klass, io = STDOUT)
+ io.puts "\n# #{klass.helpstring}"
+ if klass.ole_type == "Class" &&
+ klass.guid &&
+ klass.progid
+ @reciever = "@dispatch."
+ define_class(klass, io)
+ else
+ @reciever = ""
+ define_module(klass, io)
+ end
+ generate_constants(klass, io)
+ generate_methods(klass, io)
+ io.puts "end"
+ end
+
+ def generate(io = STDOUT)
+ io.puts "require 'win32ole'"
+ io.puts "require 'win32ole/property'"
+
+ ole_classes(typelib).select{|klass|
+ klass.visible? &&
+ (klass.ole_type == "Class" ||
+ klass.ole_type == "Interface" ||
+ klass.ole_type == "Dispatch" ||
+ klass.ole_type == "Enum")
+ }.each do |klass|
+ generate_class(klass, io)
+ end
+ begin
+ @ole.quit if @ole
+ rescue
+ end
+ end
+end
+
+require 'win32ole'
+if __FILE__ == $0
+ if ARGV.size == 0
+ $stderr.puts "usage: #{$0} Type Library [...]"
+ exit 1
+ end
+ ARGV.each do |typelib|
+ comgen = WIN32COMGen.new(typelib)
+ comgen.generate
+ end
+end
diff --git a/ext/win32ole/sample/xml.rb b/ext/win32ole/sample/xml.rb
new file mode 100644
index 0000000000..b95d6d5275
--- /dev/null
+++ b/ext/win32ole/sample/xml.rb
@@ -0,0 +1,7306 @@
+#
+# This file created by olegen.rb as following.
+# ruby olegen.rb 'Microsoft XML, version 2.0' > xml.rb
+#
+require 'win32ole'
+require 'win32ole/property'
+
+#
+module IXMLDOMImplementation
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BOOL hasFeature
+ # BSTR arg0 --- feature [IN]
+ # BSTR arg1 --- version [IN]
+ def hasFeature(arg0, arg1)
+ ret = _invoke(145, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# Core DOM node interface
+module IXMLDOMNode
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# Constants that define a node's type
+module OLEtagDOMNodeType
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ NODE_INVALID = 0
+ NODE_ELEMENT = 1
+ NODE_ATTRIBUTE = 2
+ NODE_TEXT = 3
+ NODE_CDATA_SECTION = 4
+ NODE_ENTITY_REFERENCE = 5
+ NODE_ENTITY = 6
+ NODE_PROCESSING_INSTRUCTION = 7
+ NODE_COMMENT = 8
+ NODE_DOCUMENT = 9
+ NODE_DOCUMENT_TYPE = 10
+ NODE_DOCUMENT_FRAGMENT = 11
+ NODE_NOTATION = 12
+end
+
+#
+module IXMLDOMNodeList
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 length
+ # number of nodes in the collection
+ def length()
+ ret = _getproperty(74, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # PTR item
+ # collection of nodes
+ # I4 arg0 --- index [IN]
+ def item
+ OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH])
+ end
+
+ # IXMLDOMNode nextNode
+ # get next node from iterator
+ def nextNode()
+ ret = _invoke(76, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID reset
+ # reset the position of iterator
+ def reset()
+ ret = _invoke(77, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMNamedNodeMap
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 length
+ # number of nodes in the collection
+ def length()
+ ret = _getproperty(74, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # PTR item
+ # collection of nodes
+ # I4 arg0 --- index [IN]
+ def item
+ OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH])
+ end
+
+ # IXMLDOMNode getNamedItem
+ # lookup item by name
+ # BSTR arg0 --- name [IN]
+ def getNamedItem(arg0)
+ ret = _invoke(83, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode setNamedItem
+ # set item by name
+ # IXMLDOMNode arg0 --- newItem [IN]
+ def setNamedItem(arg0)
+ ret = _invoke(84, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeNamedItem
+ # remove item by name
+ # BSTR arg0 --- name [IN]
+ def removeNamedItem(arg0)
+ ret = _invoke(85, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode getQualifiedItem
+ # lookup the item by name and namespace
+ # BSTR arg0 --- baseName [IN]
+ # BSTR arg1 --- namespaceURI [IN]
+ def getQualifiedItem(arg0, arg1)
+ ret = _invoke(87, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeQualifiedItem
+ # remove the item by name and namespace
+ # BSTR arg0 --- baseName [IN]
+ # BSTR arg1 --- namespaceURI [IN]
+ def removeQualifiedItem(arg0, arg1)
+ ret = _invoke(88, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextNode
+ # get next node from iterator
+ def nextNode()
+ ret = _invoke(89, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID reset
+ # reset the position of iterator
+ def reset()
+ ret = _invoke(90, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentType doctype
+ # node corresponding to the DOCTYPE
+ def doctype()
+ ret = _getproperty(38, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMImplementation implementation
+ # info on this DOM implementation
+ def implementation()
+ ret = _getproperty(39, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement documentElement
+ # the root of the tree
+ def documentElement()
+ ret = _getproperty(40, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # get the state of the XML document
+ def readyState()
+ ret = _getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMParseError parseError
+ # get the last parser error
+ def parseError()
+ ret = _getproperty(59, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # get the URL for the loaded XML document
+ def url()
+ ret = _getproperty(60, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL async
+ # flag for asynchronous download
+ def async()
+ ret = _getproperty(61, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse()
+ ret = _getproperty(65, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals()
+ ret = _getproperty(66, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace()
+ ret = _getproperty(67, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID async
+ # flag for asynchronous download
+ def async=(arg0)
+ ret = _setproperty(61, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse=(arg0)
+ ret = _setproperty(65, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals=(arg0)
+ ret = _setproperty(66, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace=(arg0)
+ ret = _setproperty(67, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # register a readystatechange event handler
+ def onreadystatechange=(arg0)
+ ret = _setproperty(68, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ondataavailable
+ # register an ondataavailable event handler
+ def ondataavailable=(arg0)
+ ret = _setproperty(69, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ontransformnode
+ # register an ontransformnode event handler
+ def ontransformnode=(arg0)
+ ret = _setproperty(70, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement createElement
+ # create an Element node
+ # BSTR arg0 --- tagName [IN]
+ def createElement(arg0)
+ ret = _invoke(41, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentFragment createDocumentFragment
+ # create a DocumentFragment node
+ def createDocumentFragment()
+ ret = _invoke(42, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText createTextNode
+ # create a text node
+ # BSTR arg0 --- data [IN]
+ def createTextNode(arg0)
+ ret = _invoke(43, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMComment createComment
+ # create a comment node
+ # BSTR arg0 --- data [IN]
+ def createComment(arg0)
+ ret = _invoke(44, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMCDATASection createCDATASection
+ # create a CDATA section node
+ # BSTR arg0 --- data [IN]
+ def createCDATASection(arg0)
+ ret = _invoke(45, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMProcessingInstruction createProcessingInstruction
+ # create a processing instruction node
+ # BSTR arg0 --- target [IN]
+ # BSTR arg1 --- data [IN]
+ def createProcessingInstruction(arg0, arg1)
+ ret = _invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute createAttribute
+ # create an attribute node
+ # BSTR arg0 --- name [IN]
+ def createAttribute(arg0)
+ ret = _invoke(47, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMEntityReference createEntityReference
+ # create an entity reference node
+ # BSTR arg0 --- name [IN]
+ def createEntityReference(arg0)
+ ret = _invoke(49, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = _invoke(50, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode createNode
+ # create a node of the specified node type and name
+ # VARIANT arg0 --- type [IN]
+ # BSTR arg1 --- name [IN]
+ # BSTR arg2 --- namespaceURI [IN]
+ def createNode(arg0, arg1, arg2)
+ ret = _invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nodeFromID
+ # retrieve node from it's ID
+ # BSTR arg0 --- idString [IN]
+ def nodeFromID(arg0)
+ ret = _invoke(56, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL load
+ # load document from the specified XML source
+ # VARIANT arg0 --- xmlSource [IN]
+ def load(arg0)
+ ret = _invoke(58, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # abort an asynchronous download
+ def abort()
+ ret = _invoke(62, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL loadXML
+ # load the document from a string
+ # BSTR arg0 --- bstrXML [IN]
+ def loadXML(arg0)
+ ret = _invoke(63, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID save
+ # save the document to a specified desination
+ # VARIANT arg0 --- desination [IN]
+ def save(arg0)
+ ret = _invoke(64, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMDocumentType
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR name
+ # name of the document type (root of the tree)
+ def name()
+ ret = _getproperty(131, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap entities
+ # a list of entities in the document
+ def entities()
+ ret = _getproperty(132, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap notations
+ # a list of notations in the document
+ def notations()
+ ret = _getproperty(133, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMElement
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR tagName
+ # get the tagName of the element
+ def tagName()
+ ret = _getproperty(97, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT getAttribute
+ # look up the string value of an attribute by name
+ # BSTR arg0 --- name [IN]
+ def getAttribute(arg0)
+ ret = _invoke(99, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID setAttribute
+ # set the string value of an attribute by name
+ # BSTR arg0 --- name [IN]
+ # VARIANT arg1 --- value [IN]
+ def setAttribute(arg0, arg1)
+ ret = _invoke(100, [arg0, arg1], [VT_BSTR, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID removeAttribute
+ # remove an attribute by name
+ # BSTR arg0 --- name [IN]
+ def removeAttribute(arg0)
+ ret = _invoke(101, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute getAttributeNode
+ # look up the attribute node by name
+ # BSTR arg0 --- name [IN]
+ def getAttributeNode(arg0)
+ ret = _invoke(102, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute setAttributeNode
+ # set the specified attribute on the element
+ # IXMLDOMAttribute arg0 --- DOMAttribute [IN]
+ def setAttributeNode(arg0)
+ ret = _invoke(103, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute removeAttributeNode
+ # remove the specified attribute
+ # IXMLDOMAttribute arg0 --- DOMAttribute [IN]
+ def removeAttributeNode(arg0)
+ ret = _invoke(104, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = _invoke(105, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID normalize
+ # collapse all adjacent text nodes in sub-tree
+ def normalize()
+ ret = _invoke(106, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMAttribute
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR name
+ # get name of the attribute
+ def name()
+ ret = _getproperty(118, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT value
+ # string value of the attribute
+ def value()
+ ret = _getproperty(120, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID value
+ # string value of the attribute
+ def value=(arg0)
+ ret = _setproperty(120, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMDocumentFragment
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMText
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText splitText
+ # split the text node into two text nodes at the position specified
+ # I4 arg0 --- offset [IN]
+ def splitText(arg0)
+ ret = _invoke(123, [arg0], [VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMCharacterData
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMComment
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMCDATASection
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText splitText
+ # split the text node into two text nodes at the position specified
+ # I4 arg0 --- offset [IN]
+ def splitText(arg0)
+ ret = _invoke(123, [arg0], [VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMProcessingInstruction
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR target
+ # the target
+ def target()
+ ret = _getproperty(127, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # the data
+ def data()
+ ret = _getproperty(128, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # the data
+ def data=(arg0)
+ ret = _setproperty(128, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMEntityReference
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# structure for reporting parser errors
+module IXMLDOMParseError
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 errorCode
+ # the error code
+ def errorCode()
+ ret = _getproperty(0, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # the URL of the XML document containing the error
+ def url()
+ ret = _getproperty(179, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR reason
+ # the cause of the error
+ def reason()
+ ret = _getproperty(180, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR srcText
+ # the data where the error occurred
+ def srcText()
+ ret = _getproperty(181, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 line
+ # the line number in the XML document where the error occurred
+ def line()
+ ret = _getproperty(182, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 linepos
+ # the character position in the line containing the error
+ def linepos()
+ ret = _getproperty(183, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 filepos
+ # the absolute file position in the XML document containing the error
+ def filepos()
+ ret = _getproperty(184, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMNotation
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT publicId
+ # the public ID
+ def publicId()
+ ret = _getproperty(136, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT systemId
+ # the system ID
+ def systemId()
+ ret = _getproperty(137, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMEntity
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT publicId
+ # the public ID
+ def publicId()
+ ret = _getproperty(140, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT systemId
+ # the system ID
+ def systemId()
+ ret = _getproperty(141, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR notationName
+ # the name of the notation
+ def notationName()
+ ret = _getproperty(142, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# XTL runtime object
+module IXTLRuntime
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 uniqueID
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def uniqueID(arg0)
+ ret = _invoke(187, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 depth
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def depth(arg0)
+ ret = _invoke(188, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 childNumber
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def childNumber(arg0)
+ ret = _invoke(189, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 ancestorChildNumber
+ # BSTR arg0 --- bstrNodeName [IN]
+ # IXMLDOMNode arg1 --- pNode [IN]
+ def ancestorChildNumber(arg0, arg1)
+ ret = _invoke(190, [arg0, arg1], [VT_BSTR, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 absoluteChildNumber
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def absoluteChildNumber(arg0)
+ ret = _invoke(191, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatIndex
+ # I4 arg0 --- lIndex [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ def formatIndex(arg0, arg1)
+ ret = _invoke(192, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatNumber
+ # R8 arg0 --- dblNumber [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ def formatNumber(arg0, arg1)
+ ret = _invoke(193, [arg0, arg1], [VT_R8, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatDate
+ # VARIANT arg0 --- varDate [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ # VARIANT arg2 --- varDestLocale [IN]
+ def formatDate(arg0, arg1, arg2=nil)
+ ret = _invoke(194, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatTime
+ # VARIANT arg0 --- varTime [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ # VARIANT arg2 --- varDestLocale [IN]
+ def formatTime(arg0, arg1, arg2=nil)
+ ret = _invoke(195, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# W3C-DOM XML Document
+class Microsoft_XMLDOM_1_0 # DOMDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{2933BF90-7B36-11D2-B20E-00C04F983E60}"
+ @progid = "Microsoft.XMLDOM.1.0"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = @dispatch._getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = @dispatch._getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = @dispatch._getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = @dispatch._getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = @dispatch._getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = @dispatch._getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = @dispatch._getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = @dispatch._getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = @dispatch._getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = @dispatch._getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = @dispatch._getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = @dispatch._getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = @dispatch._getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = @dispatch._getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = @dispatch._getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = @dispatch._getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = @dispatch._getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = @dispatch._getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = @dispatch._getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = @dispatch._getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = @dispatch._getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = @dispatch._getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentType doctype
+ # node corresponding to the DOCTYPE
+ def doctype()
+ ret = @dispatch._getproperty(38, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMImplementation implementation
+ # info on this DOM implementation
+ def implementation()
+ ret = @dispatch._getproperty(39, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement documentElement
+ # the root of the tree
+ def documentElement()
+ ret = @dispatch._getproperty(40, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # get the state of the XML document
+ def readyState()
+ ret = @dispatch._getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMParseError parseError
+ # get the last parser error
+ def parseError()
+ ret = @dispatch._getproperty(59, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # get the URL for the loaded XML document
+ def url()
+ ret = @dispatch._getproperty(60, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL async
+ # flag for asynchronous download
+ def async()
+ ret = @dispatch._getproperty(61, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse()
+ ret = @dispatch._getproperty(65, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals()
+ ret = @dispatch._getproperty(66, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace()
+ ret = @dispatch._getproperty(67, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = @dispatch._setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID async
+ # flag for asynchronous download
+ def async=(arg0)
+ ret = @dispatch._setproperty(61, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse=(arg0)
+ ret = @dispatch._setproperty(65, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals=(arg0)
+ ret = @dispatch._setproperty(66, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace=(arg0)
+ ret = @dispatch._setproperty(67, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # register a readystatechange event handler
+ def onreadystatechange=(arg0)
+ ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ondataavailable
+ # register an ondataavailable event handler
+ def ondataavailable=(arg0)
+ ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ontransformnode
+ # register an ontransformnode event handler
+ def ontransformnode=(arg0)
+ ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = @dispatch._invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = @dispatch._invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = @dispatch._invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = @dispatch._invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement createElement
+ # create an Element node
+ # BSTR arg0 --- tagName [IN]
+ def createElement(arg0)
+ ret = @dispatch._invoke(41, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentFragment createDocumentFragment
+ # create a DocumentFragment node
+ def createDocumentFragment()
+ ret = @dispatch._invoke(42, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText createTextNode
+ # create a text node
+ # BSTR arg0 --- data [IN]
+ def createTextNode(arg0)
+ ret = @dispatch._invoke(43, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMComment createComment
+ # create a comment node
+ # BSTR arg0 --- data [IN]
+ def createComment(arg0)
+ ret = @dispatch._invoke(44, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMCDATASection createCDATASection
+ # create a CDATA section node
+ # BSTR arg0 --- data [IN]
+ def createCDATASection(arg0)
+ ret = @dispatch._invoke(45, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMProcessingInstruction createProcessingInstruction
+ # create a processing instruction node
+ # BSTR arg0 --- target [IN]
+ # BSTR arg1 --- data [IN]
+ def createProcessingInstruction(arg0, arg1)
+ ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute createAttribute
+ # create an attribute node
+ # BSTR arg0 --- name [IN]
+ def createAttribute(arg0)
+ ret = @dispatch._invoke(47, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMEntityReference createEntityReference
+ # create an entity reference node
+ # BSTR arg0 --- name [IN]
+ def createEntityReference(arg0)
+ ret = @dispatch._invoke(49, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = @dispatch._invoke(50, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode createNode
+ # create a node of the specified node type and name
+ # VARIANT arg0 --- type [IN]
+ # BSTR arg1 --- name [IN]
+ # BSTR arg2 --- namespaceURI [IN]
+ def createNode(arg0, arg1, arg2)
+ ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nodeFromID
+ # retrieve node from it's ID
+ # BSTR arg0 --- idString [IN]
+ def nodeFromID(arg0)
+ ret = @dispatch._invoke(56, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL load
+ # load document from the specified XML source
+ # VARIANT arg0 --- xmlSource [IN]
+ def load(arg0)
+ ret = @dispatch._invoke(58, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # abort an asynchronous download
+ def abort()
+ ret = @dispatch._invoke(62, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL loadXML
+ # load the document from a string
+ # BSTR arg0 --- bstrXML [IN]
+ def loadXML(arg0)
+ ret = @dispatch._invoke(63, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID save
+ # save the document to a specified desination
+ # VARIANT arg0 --- desination [IN]
+ def save(arg0)
+ ret = @dispatch._invoke(64, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents
+ def ondataavailable()
+ ret = @dispatch._invoke(198, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents
+ def onreadystatechange()
+ ret = @dispatch._invoke(-609, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# W3C-DOM XML Document (Apartment)
+class Microsoft_FreeThreadedXMLDOM_1_0 # DOMFreeThreadedDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{2933BF91-7B36-11D2-B20E-00C04F983E60}"
+ @progid = "Microsoft.FreeThreadedXMLDOM.1.0"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = @dispatch._getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = @dispatch._getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = @dispatch._getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = @dispatch._getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = @dispatch._getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = @dispatch._getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = @dispatch._getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = @dispatch._getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = @dispatch._getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = @dispatch._getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = @dispatch._getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = @dispatch._getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = @dispatch._getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = @dispatch._getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = @dispatch._getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = @dispatch._getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = @dispatch._getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = @dispatch._getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = @dispatch._getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = @dispatch._getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = @dispatch._getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = @dispatch._getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentType doctype
+ # node corresponding to the DOCTYPE
+ def doctype()
+ ret = @dispatch._getproperty(38, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMImplementation implementation
+ # info on this DOM implementation
+ def implementation()
+ ret = @dispatch._getproperty(39, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement documentElement
+ # the root of the tree
+ def documentElement()
+ ret = @dispatch._getproperty(40, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # get the state of the XML document
+ def readyState()
+ ret = @dispatch._getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMParseError parseError
+ # get the last parser error
+ def parseError()
+ ret = @dispatch._getproperty(59, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # get the URL for the loaded XML document
+ def url()
+ ret = @dispatch._getproperty(60, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL async
+ # flag for asynchronous download
+ def async()
+ ret = @dispatch._getproperty(61, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse()
+ ret = @dispatch._getproperty(65, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals()
+ ret = @dispatch._getproperty(66, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace()
+ ret = @dispatch._getproperty(67, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = @dispatch._setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID async
+ # flag for asynchronous download
+ def async=(arg0)
+ ret = @dispatch._setproperty(61, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse=(arg0)
+ ret = @dispatch._setproperty(65, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals=(arg0)
+ ret = @dispatch._setproperty(66, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace=(arg0)
+ ret = @dispatch._setproperty(67, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # register a readystatechange event handler
+ def onreadystatechange=(arg0)
+ ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ondataavailable
+ # register an ondataavailable event handler
+ def ondataavailable=(arg0)
+ ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ontransformnode
+ # register an ontransformnode event handler
+ def ontransformnode=(arg0)
+ ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = @dispatch._invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = @dispatch._invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = @dispatch._invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = @dispatch._invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement createElement
+ # create an Element node
+ # BSTR arg0 --- tagName [IN]
+ def createElement(arg0)
+ ret = @dispatch._invoke(41, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentFragment createDocumentFragment
+ # create a DocumentFragment node
+ def createDocumentFragment()
+ ret = @dispatch._invoke(42, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText createTextNode
+ # create a text node
+ # BSTR arg0 --- data [IN]
+ def createTextNode(arg0)
+ ret = @dispatch._invoke(43, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMComment createComment
+ # create a comment node
+ # BSTR arg0 --- data [IN]
+ def createComment(arg0)
+ ret = @dispatch._invoke(44, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMCDATASection createCDATASection
+ # create a CDATA section node
+ # BSTR arg0 --- data [IN]
+ def createCDATASection(arg0)
+ ret = @dispatch._invoke(45, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMProcessingInstruction createProcessingInstruction
+ # create a processing instruction node
+ # BSTR arg0 --- target [IN]
+ # BSTR arg1 --- data [IN]
+ def createProcessingInstruction(arg0, arg1)
+ ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute createAttribute
+ # create an attribute node
+ # BSTR arg0 --- name [IN]
+ def createAttribute(arg0)
+ ret = @dispatch._invoke(47, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMEntityReference createEntityReference
+ # create an entity reference node
+ # BSTR arg0 --- name [IN]
+ def createEntityReference(arg0)
+ ret = @dispatch._invoke(49, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = @dispatch._invoke(50, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode createNode
+ # create a node of the specified node type and name
+ # VARIANT arg0 --- type [IN]
+ # BSTR arg1 --- name [IN]
+ # BSTR arg2 --- namespaceURI [IN]
+ def createNode(arg0, arg1, arg2)
+ ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nodeFromID
+ # retrieve node from it's ID
+ # BSTR arg0 --- idString [IN]
+ def nodeFromID(arg0)
+ ret = @dispatch._invoke(56, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL load
+ # load document from the specified XML source
+ # VARIANT arg0 --- xmlSource [IN]
+ def load(arg0)
+ ret = @dispatch._invoke(58, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # abort an asynchronous download
+ def abort()
+ ret = @dispatch._invoke(62, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL loadXML
+ # load the document from a string
+ # BSTR arg0 --- bstrXML [IN]
+ def loadXML(arg0)
+ ret = @dispatch._invoke(63, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID save
+ # save the document to a specified desination
+ # VARIANT arg0 --- desination [IN]
+ def save(arg0)
+ ret = @dispatch._invoke(64, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents
+ def ondataavailable()
+ ret = @dispatch._invoke(198, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents
+ def onreadystatechange()
+ ret = @dispatch._invoke(-609, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# IXMLHttpRequest Interface
+module IXMLHttpRequest
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 status
+ # Get HTTP status code
+ def status()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR statusText
+ # Get HTTP status text
+ def statusText()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DISPATCH responseXML
+ # Get response body
+ def responseXML()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR responseText
+ # Get response body
+ def responseText()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseBody
+ # Get response body
+ def responseBody()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseStream
+ # Get response body
+ def responseStream()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # Get ready state
+ def readyState()
+ ret = _getproperty(13, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # Register a complete event handler
+ def onreadystatechange=(arg0)
+ ret = _setproperty(14, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID open
+ # Open HTTP connection
+ # BSTR arg0 --- bstrMethod [IN]
+ # BSTR arg1 --- bstrUrl [IN]
+ # VARIANT arg2 --- varAsync [IN]
+ # VARIANT arg3 --- bstrUser [IN]
+ # VARIANT arg4 --- bstrPassword [IN]
+ def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil)
+ ret = _invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID setRequestHeader
+ # Add HTTP request header
+ # BSTR arg0 --- bstrHeader [IN]
+ # BSTR arg1 --- bstrValue [IN]
+ def setRequestHeader(arg0, arg1)
+ ret = _invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getResponseHeader
+ # Get HTTP response header
+ # BSTR arg0 --- bstrHeader [IN]
+ def getResponseHeader(arg0)
+ ret = _invoke(3, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getAllResponseHeaders
+ # Get all HTTP response headers
+ def getAllResponseHeaders()
+ ret = _invoke(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID send
+ # Send HTTP request
+ # VARIANT arg0 --- varBody [IN]
+ def send(arg0=nil)
+ ret = _invoke(5, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # Abort HTTP request
+ def abort()
+ ret = _invoke(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# XML HTTP Request class.
+class Microsoft_XMLHTTP_1 # XMLHTTPRequest
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{ED8C108E-4349-11D2-91A4-00C04F7969E8}"
+ @progid = "Microsoft.XMLHTTP.1"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # I4 status
+ # Get HTTP status code
+ def status()
+ ret = @dispatch._getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR statusText
+ # Get HTTP status text
+ def statusText()
+ ret = @dispatch._getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DISPATCH responseXML
+ # Get response body
+ def responseXML()
+ ret = @dispatch._getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR responseText
+ # Get response body
+ def responseText()
+ ret = @dispatch._getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseBody
+ # Get response body
+ def responseBody()
+ ret = @dispatch._getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseStream
+ # Get response body
+ def responseStream()
+ ret = @dispatch._getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # Get ready state
+ def readyState()
+ ret = @dispatch._getproperty(13, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # Register a complete event handler
+ def onreadystatechange=(arg0)
+ ret = @dispatch._setproperty(14, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID open
+ # Open HTTP connection
+ # BSTR arg0 --- bstrMethod [IN]
+ # BSTR arg1 --- bstrUrl [IN]
+ # VARIANT arg2 --- varAsync [IN]
+ # VARIANT arg3 --- bstrUser [IN]
+ # VARIANT arg4 --- bstrPassword [IN]
+ def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil)
+ ret = @dispatch._invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID setRequestHeader
+ # Add HTTP request header
+ # BSTR arg0 --- bstrHeader [IN]
+ # BSTR arg1 --- bstrValue [IN]
+ def setRequestHeader(arg0, arg1)
+ ret = @dispatch._invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getResponseHeader
+ # Get HTTP response header
+ # BSTR arg0 --- bstrHeader [IN]
+ def getResponseHeader(arg0)
+ ret = @dispatch._invoke(3, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getAllResponseHeaders
+ # Get all HTTP response headers
+ def getAllResponseHeaders()
+ ret = @dispatch._invoke(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID send
+ # Send HTTP request
+ # VARIANT arg0 --- varBody [IN]
+ def send(arg0=nil)
+ ret = @dispatch._invoke(5, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # Abort HTTP request
+ def abort()
+ ret = @dispatch._invoke(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# XML Data Source Object
+class Microsoft_XMLDSO_1_0 # XMLDSOControl
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{550DDA30-0541-11D2-9CA9-0060B0EC3D39}"
+ @progid = "Microsoft.XMLDSO.1.0"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # IXMLDOMDocument XMLDocument
+ def XMLDocument()
+ ret = @dispatch._getproperty(65537, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 JavaDSOCompatible
+ def JavaDSOCompatible()
+ ret = @dispatch._getproperty(65538, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ def readyState()
+ ret = @dispatch._getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID XMLDocument
+ def XMLDocument=(arg0)
+ ret = @dispatch._setproperty(65537, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID JavaDSOCompatible
+ def JavaDSOCompatible=(arg0)
+ ret = @dispatch._setproperty(65538, [arg0], [VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# Constants that define types for IXMLElement.
+module OLEtagXMLEMEM_TYPE
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ XMLELEMTYPE_ELEMENT = 0
+ XMLELEMTYPE_TEXT = 1
+ XMLELEMTYPE_COMMENT = 2
+ XMLELEMTYPE_DOCUMENT = 3
+ XMLELEMTYPE_DTD = 4
+ XMLELEMTYPE_PI = 5
+ XMLELEMTYPE_OTHER = 6
+end
+
+# XMLDocument extends IXML Document. It is obsolete. You should use DOMDocument. This object should not be confused with the XMLDocument property on the XML data island.
+class Msxml # XMLDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{CFC399AF-D876-11D0-9C10-00C04FC99C8E}"
+ @progid = "Msxml"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # HRESULT url
+ # set URL to load an XML document from the URL.
+ # BSTR arg0 --- p [IN]
+ def url=(arg0)
+ ret = @dispatch._setproperty(65641, [arg0], [VT_BSTR, VT_HRESULT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT charset
+ # get encoding.
+ # BSTR arg0 --- p [IN]
+ def charset=(arg0)
+ ret = @dispatch._setproperty(65645, [arg0], [VT_BSTR, VT_HRESULT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT async
+ # get asynchronous loading flag.
+ # BOOL arg0 --- pf [IN]
+ def async=(arg0)
+ ret = @dispatch._setproperty(65649, [arg0], [VT_BOOL, VT_HRESULT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT root
+ # get root IXMLElement of the XML document.
+ # IXMLElement2,IXMLElement2 arg0 --- p [OUT]
+ def root
+ OLEProperty.new(@dispatch, 65637, [VT_BYREF|VT_BYREF|VT_DISPATCH], [VT_BYREF|VT_BYREF|VT_DISPATCH, VT_HRESULT])
+ end
+
+ # HRESULT url
+ # set URL to load an XML document from the URL.
+ # BSTR arg0 --- p [OUT]
+ def url
+ OLEProperty.new(@dispatch, 65641, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT readyState
+ # get ready state.
+ # I4 arg0 --- pl [OUT]
+ def readyState
+ OLEProperty.new(@dispatch, 65643, [VT_BYREF|VT_I4], [VT_BYREF|VT_I4, VT_HRESULT])
+ end
+
+ # HRESULT charset
+ # get encoding.
+ # BSTR arg0 --- p [OUT]
+ def charset
+ OLEProperty.new(@dispatch, 65645, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT version
+ # get XML version number.
+ # BSTR arg0 --- p [OUT]
+ def version
+ OLEProperty.new(@dispatch, 65646, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT doctype
+ # get document type.
+ # BSTR arg0 --- p [OUT]
+ def doctype
+ OLEProperty.new(@dispatch, 65647, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT async
+ # get asynchronous loading flag.
+ # BOOL arg0 --- pf [OUT]
+ def async
+ OLEProperty.new(@dispatch, 65649, [VT_BYREF|VT_BOOL], [VT_BYREF|VT_BOOL, VT_HRESULT])
+ end
+
+ # HRESULT createElement
+ # create different types of IXMLElements.
+ # VARIANT arg0 --- vType [IN]
+ # VARIANT arg1 --- var1 [IN]
+ # IXMLElement2,IXMLElement2 arg2 --- ppElem [OUT]
+ def createElement(arg0, arg1=nil, arg2=nil)
+ ret = @dispatch._invoke(65644, [arg0, arg1, arg2], [VT_VARIANT, VT_VARIANT, VT_BYREF|VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
diff --git a/ext/win32ole/tests/oleserver.rb b/ext/win32ole/tests/oleserver.rb
new file mode 100644
index 0000000000..bf721373e5
--- /dev/null
+++ b/ext/win32ole/tests/oleserver.rb
@@ -0,0 +1,10 @@
+require 'win32ole'
+def oletypelib_name(pat)
+ WIN32OLE_TYPE.typelibs.each do |lib|
+ return lib if pat =~ lib
+ end
+end
+module OLESERVER
+ MS_EXCEL_TYPELIB = oletypelib_name(/^Microsoft Excel .* Object Library$/)
+ MS_XML_TYPELIB = oletypelib_name(/^Microsoft XML/)
+end
diff --git a/ext/win32ole/tests/testOLEEVENT.rb b/ext/win32ole/tests/testOLEEVENT.rb
new file mode 100644
index 0000000000..15b7ca8413
--- /dev/null
+++ b/ext/win32ole/tests/testOLEEVENT.rb
@@ -0,0 +1,33 @@
+require 'rubyunit'
+require 'win32ole'
+
+class TestWIN32OLE_EVENT < RUNIT::TestCase
+ def setup
+ @excel = WIN32OLE.new("Excel.Application")
+ @excel.visible = true
+ end
+ def test_on_event
+ book = @excel.workbooks.Add
+ value = ""
+ begin
+ ev = WIN32OLE_EVENT.new(book, 'WorkbookEvents')
+ ev.on_event('SheetChange'){|arg1, arg2|
+ begin
+ value = arg1.value
+ rescue
+ value = $!.message
+ end
+ }
+ book.Worksheets(1).Range("A1").value = "OK"
+ ensure
+ book.saved = true
+ end
+ assert_equal("OK", value)
+ end
+ def teardown
+ @excel.quit
+ @excel = nil
+ GC.start
+ end
+end
+
diff --git a/ext/win32ole/tests/testOLEMETHOD.rb b/ext/win32ole/tests/testOLEMETHOD.rb
new file mode 100644
index 0000000000..b52052e669
--- /dev/null
+++ b/ext/win32ole/tests/testOLEMETHOD.rb
@@ -0,0 +1,87 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLEMETHOD < RUNIT::TestCase
+ include OLESERVER
+ def setup
+ @excel_app = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
+ end
+ def test_s_new
+ m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
+ assert_instance_of(WIN32OLE_METHOD, m)
+ m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
+ assert_instance_of(WIN32OLE_METHOD, m)
+ m = WIN32OLE_METHOD.new(@excel_app, 'workbookopen')
+ assert_instance_of(WIN32OLE_METHOD, m)
+ end
+ def test_name
+ m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
+ assert_equal('Quit', m.name)
+ end
+ def test_to_s
+ m = WIN32OLE_METHOD.new(@excel_app, 'Quit')
+ assert_equal('Quit', "#{m}")
+ end
+ def test_return_type
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal('Range', m.return_type)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
+ assert_equal('BSTR', m.return_type)
+ end
+ def test_return_vtype
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal(WIN32OLE::VARIANT::VT_PTR, m.return_vtype)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
+ assert_equal(WIN32OLE::VARIANT::VT_BSTR, m.return_vtype)
+ end
+ def test_return_type_detail
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal(['PTR', 'USERDEFINED', 'Range'], m.return_type_detail)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActivePrinter')
+ assert_equal(['BSTR'], m.return_type_detail)
+ end
+
+ def test_invoke_kind
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_equal('PROPERTYGET', m.invoke_kind)
+ end
+ def test_visible
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert(m.visible?)
+ m = WIN32OLE_METHOD.new(@excel_app, 'AddRef')
+ assert(!m.visible?)
+ end
+ def test_event
+ m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
+ assert(m.event?)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert(!m.event?)
+ end
+ def test_event_interface
+ m = WIN32OLE_METHOD.new(@excel_app, 'WorkbookOpen')
+ assert_equal('AppEvents', m.event_interface)
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_nil(m.event_interface)
+ end
+ def test_helpstring
+ domdoc = WIN32OLE_TYPE.new(MS_XML_TYPELIB, 'DOMDocument')
+ m = WIN32OLE_METHOD.new(domdoc, 'abort')
+ assert_equal('abort an asynchronous download', m.helpstring)
+ end
+ def test_helpfile
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert_match(/VBAXL.*\.(HLP|CHM)$/i, m.helpfile)
+ end
+ def test_helpcontext
+ m = WIN32OLE_METHOD.new(@excel_app, 'ActiveCell')
+ assert(m.helpcontext > 0)
+ end
+ def test_offset_vtbl
+ m = WIN32OLE_METHOD.new(@excel_app, 'QueryInterface')
+ assert_equal(0, m.offset_vtbl)
+ end
+end
diff --git a/ext/win32ole/tests/testOLEPARAM.rb b/ext/win32ole/tests/testOLEPARAM.rb
new file mode 100644
index 0000000000..685b548aa5
--- /dev/null
+++ b/ext/win32ole/tests/testOLEPARAM.rb
@@ -0,0 +1,74 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLEPARAM < RUNIT::TestCase
+ include OLESERVER
+ def test_name
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ sh = classes.find {|c| c.name == 'Worksheet'}
+ saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'}
+ param_names = saveas.params.collect{|p| p.name}
+ assert(param_names.size > 0)
+ assert(param_names.include?('Filename'))
+ end
+ def test_to_s
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ sh = classes.find {|c| c.name == 'Worksheet'}
+ saveas = sh.ole_methods.find {|m| m.name == 'SaveAs'}
+ param_names = saveas.params.collect{|p| "#{p}"}
+ assert(param_names.include?('Filename'))
+ end
+ def test_ole_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal('BSTR', f.params[0].ole_type)
+ methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal('XlSaveAsAccessMode', f.params[6].ole_type)
+ end
+ def test_ole_type_detail
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal(['BSTR'], f.params[0].ole_type_detail)
+ methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal(['USERDEFINED', 'XlSaveAsAccessMode'], f.params[6].ole_type_detail)
+ end
+ def test_input
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(f.params[0].input?)
+ end
+
+ def test_output
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(!f.params[0].output?)
+ end
+ def test_optional
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(!f.params[0].optional?)
+ methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert(f.params[0].optional?)
+ end
+ def test_ole_type_detail
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal(nil, f.params[0].default)
+ methods = classes.find {|c| c.name == 'Workbook'}.ole_methods
+ f = methods.find {|m| m.name == 'SaveAs'}
+ assert_equal(1, f.params[6].default)
+ end
+end
diff --git a/ext/win32ole/tests/testOLETYPE.rb b/ext/win32ole/tests/testOLETYPE.rb
new file mode 100644
index 0000000000..d4eb1146e1
--- /dev/null
+++ b/ext/win32ole/tests/testOLETYPE.rb
@@ -0,0 +1,96 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLETYPE < RUNIT::TestCase
+ include OLESERVER
+ def test_s_new
+ type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
+ assert_instance_of(WIN32OLE_TYPE, type)
+ end
+ def test_s_ole_classes
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ assert(classes.size > 0)
+ end
+ def test_s_typelibs
+ libs = WIN32OLE_TYPE.typelibs
+ assert(libs.include?(MS_EXCEL_TYPELIB))
+ assert(libs.include?(MS_XML_TYPELIB))
+ end
+ def test_s_progids
+ progids = WIN32OLE_TYPE.progids
+ assert(progids.include?('Excel.Application'))
+ end
+ def test_name
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ class_names = classes.collect{|c|
+ c.name
+ }
+ assert(class_names.include?('Application'))
+ end
+
+ def test_class_to_s
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ class_names = classes.collect{|c|
+ "#{c}"
+ }
+ assert(class_names.include?('Application'))
+ end
+
+ def test_ole_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ app = classes.find {|c| c.name == 'Application'}
+ assert_equal('Class', app.ole_type)
+ app = classes.find {|c| c.name == '_Application'}
+ assert_equal('Dispatch', app.ole_type)
+ end
+ def test_typekind
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ app = classes.find {|c| c.name == 'Application'}
+ assert_equal(5, app.typekind)
+ end
+ def test_visible
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ app = classes.find {|c| c.name == 'Application'}
+ assert(app.visible?)
+ app = classes.find {|c| c.name == 'IAppEvents'}
+ assert(!app.visible?)
+ end
+ def test_src_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
+ domnode = classes.find {|c| c.name == 'DOMNodeType'}
+ assert_equal('tagDOMNodeType', domnode.src_type)
+ end
+ def test_helpstring
+ classes = WIN32OLE_TYPE.ole_classes(MS_XML_TYPELIB)
+ domdoc = classes.find {|c| c.name == 'DOMDocument'}
+ assert_equal('W3C-DOM XML Document', domdoc.helpstring)
+ end
+ def test_variables
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ xlchart = classes.find {|c| c.name == 'XlChartType'}
+ assert(xlchart.variables.size > 0)
+ end
+ def test_ole_methods
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ worksheet = classes.find {|c| c.name == 'Worksheet'}
+ assert(worksheet.ole_methods.size > 0)
+ end
+ def test_helpfile
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ worksheet = classes.find {|c| c.name == 'Worksheet'}
+ assert_match(/VBAXL.*\.(CHM|HLP)$/, worksheet.helpfile)
+ end
+ def test_helpcontext
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ worksheet = classes.find {|c| c.name == 'Worksheet'}
+ assert_equal(131088, worksheet.helpcontext)
+ end
+ def test_to_s
+ type = WIN32OLE_TYPE.new(MS_EXCEL_TYPELIB, 'Application')
+ assert_equal("Application", "#{type}");
+ end
+end
diff --git a/ext/win32ole/tests/testOLEVARIABLE.rb b/ext/win32ole/tests/testOLEVARIABLE.rb
new file mode 100644
index 0000000000..b4bb0b57d9
--- /dev/null
+++ b/ext/win32ole/tests/testOLEVARIABLE.rb
@@ -0,0 +1,49 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+require 'oleserver'
+
+class TestOLEVARIABLE < RUNIT::TestCase
+ include OLESERVER
+ def test_name
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var_names = chart.variables.collect {|m| m.name}
+ assert(var_names.size > 0)
+ assert(var_names.include?('xl3DColumn'))
+ end
+ def test_to_s
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var_names = chart.variables.collect {|m| "#{m}"}
+ assert(var_names.size > 0)
+ assert(var_names.include?('xl3DColumn'))
+ end
+ def test_ole_type
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert_equal('INT', var.ole_type)
+ end
+ def test_ole_type_detail
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert_equal(['INT'], var.ole_type_detail)
+ end
+
+ def test_value
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert_equal(-4100, var.value)
+ end
+ def test_visible
+ classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
+ chart = classes.find {|c| c.name == 'XlChartType'}
+ var = chart.variables.find {|m| m.name == 'xl3DColumn'}
+ assert(var.visible?)
+ end
+end
diff --git a/ext/win32ole/tests/testVARIANT.rb b/ext/win32ole/tests/testVARIANT.rb
new file mode 100644
index 0000000000..f274778f27
--- /dev/null
+++ b/ext/win32ole/tests/testVARIANT.rb
@@ -0,0 +1,32 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'rubyunit'
+
+require 'win32ole'
+
+class TestWin32OLE_VARIANT < RUNIT::TestCase
+ include WIN32OLE::VARIANT
+ def test_variant
+ assert_equal(2, VT_I2)
+ assert_equal(3, VT_I4)
+ assert_equal(4, VT_R4)
+ assert_equal(5, VT_R8)
+ assert_equal(6, VT_CY)
+ assert_equal(7, VT_DATE)
+ assert_equal(8, VT_BSTR)
+ assert_equal(9, VT_DISPATCH)
+ assert_equal(10, VT_ERROR)
+ assert_equal(11, VT_BOOL)
+ assert_equal(12, VT_VARIANT)
+ assert_equal(13, VT_UNKNOWN)
+ assert_equal(16, VT_I1)
+ assert_equal(17, VT_UI1)
+ assert_equal(18, VT_UI2)
+ assert_equal(19, VT_UI4)
+ assert_equal(22, VT_INT)
+ assert_equal(23, VT_UINT)
+ assert_equal(0x2000, VT_ARRAY)
+ assert_equal(0x4000, VT_BYREF)
+ end
+end
+
diff --git a/ext/win32ole/tests/testWIN32OLE.rb b/ext/win32ole/tests/testWIN32OLE.rb
new file mode 100644
index 0000000000..d8c3b6e6ba
--- /dev/null
+++ b/ext/win32ole/tests/testWIN32OLE.rb
@@ -0,0 +1,312 @@
+# You need RubyUnit and MS Excel and MSI to run this test script
+
+require 'runit/testcase'
+require 'runit/cui/testrunner'
+
+require 'win32ole'
+require 'oleserver'
+
+module EXCEL_CONST
+end
+
+module CONST1
+end
+
+module CONST2
+end
+
+module CONST3
+end
+
+class TestWin32OLE < RUNIT::TestCase
+ include OLESERVER
+ def setup
+ @excel = WIN32OLE.new("Excel.Application")
+ @excel.visible = true
+ end
+ def test_s_new
+ assert_instance_of(WIN32OLE, @excel)
+ end
+ def test_s_new_DCOM
+ rexcel = WIN32OLE.new("Excel.Application", "localhost")
+ assert_instance_of(WIN32OLE, rexcel)
+ rexcel.visible = true
+ rexcel.quit
+ end
+ def test_s_new_from_clsid
+ excel = WIN32OLE.new("{00024500-0000-0000-C000-000000000046}")
+ assert_instance_of(WIN32OLE, excel)
+ excel.quit
+ exc = assert_exception(WIN32OLERuntimeError) {
+ WIN32OLE.new("{000}")
+ }
+ assert_match(/Unknown OLE server: `\{000\}'/, exc.message)
+ end
+ def test_s_connect
+ excel2 = WIN32OLE.connect('Excel.Application')
+ assert_instance_of(WIN32OLE, excel2)
+ end
+
+ def test_s_const_load
+ assert(!defined?(EXCEL_CONST::XlTop))
+ WIN32OLE.const_load(@excel, EXCEL_CONST)
+ assert_equal(-4160, EXCEL_CONST::XlTop)
+
+ assert(!defined?(CONST1::XlTop))
+ WIN32OLE.const_load(MS_EXCEL_TYPELIB, CONST1)
+ assert_equal(-4160, CONST1::XlTop)
+ end
+
+ def test_get_win32ole_object
+ workbooks = @excel.Workbooks;
+ assert_instance_of(WIN32OLE, workbooks)
+ end
+ def test_each
+ workbooks = @excel.Workbooks
+ assert_no_exception {
+ i = 0;
+ workbooks.each do |workbook|
+ print i += 1
+ end
+ }
+ workbooks.add
+ workbooks.add
+ i = 0
+ workbooks.each do |workbook|
+ i+=1
+ end
+ assert_equal(2, i)
+ workbooks.each do |workbook|
+ workbook.saved = true
+ end
+ end
+ def test_setproperty_bracket
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.range("A1")['Value'] = 10
+ assert_equal(10, sheet.range("A1").value)
+ sheet['Cells', 1, 2] = 10
+ assert_equal(10, sheet.range("B1").value)
+ ensure
+ book.saved = true
+ end
+ end
+ def test_convert_bignum
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.range("A1").value = 999999999
+ sheet.range("A2").value = 9999999999
+ sheet.range("A3").value = "=A1*10 + 9"
+ assert_equal(9999999999, sheet.range("A2").value)
+ assert_equal(9999999999, sheet.range("A3").value)
+
+ ensure
+ book.saved = true
+ end
+ end
+
+ def test_ole_invoke_with_named_arg
+ book = @excel.workbooks.add
+ sheets = book.worksheets
+ sheet = book.worksheets(1)
+ num = sheets.count
+ begin
+ sheets.add({'count' => 2, 'after'=>sheet})
+ assert_equal(2, sheets.count - num);
+ ensure
+ book.saved = true
+ end
+ end
+
+ def test_ole_invoke_with_named_arg_last
+ book = @excel.workbooks.add
+ sheets = book.worksheets
+ sheet = book.worksheets(1)
+ num = sheets.count
+ begin
+ sheets.add(sheet, {'count' => 2})
+ assert_equal(2, sheets.count - num);
+ ensure
+ book.saved = true
+ end
+ end
+
+ def test_setproperty
+ @excel.setproperty('Visible', false)
+ assert_equal(false, @excel.Visible)
+ @excel.setproperty('Visible', true)
+ assert_equal(true, @excel.Visible)
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.setproperty('Cells', 1, 2, 10)
+ assert_equal(10, sheet.range("B1").value)
+ ensure
+ book.saved = true
+ end
+ end
+ def test_no_exist_property
+ isok = false
+ begin
+ @excel.unknown_prop = 1
+ rescue WIN32OLERuntimeError
+ isok = true
+ end
+ assert(isok)
+
+ isok = false
+ begin
+ @excel['unknown_prop'] = 2
+ rescue WIN32OLERuntimeError
+ isok = true
+ end
+ assert(isok)
+ end
+
+ def test_setproperty_with_equal
+ book = @excel.workbooks.add
+ sheet = book.worksheets(1)
+ begin
+ sheet.range("B1").value = 10
+ assert_equal(10, sheet.range("B1").value)
+ sheet.range("C1:D1").value = [11, 12]
+ assert_equal(11, sheet.range("C1").value)
+ assert_equal(12, sheet.range("D1").value)
+ ensure
+ book.saved = true
+ end
+ end
+ def test_invoke
+ workbooks = @excel.invoke( 'workbooks' )
+ assert_instance_of(WIN32OLE, workbooks)
+ book = workbooks.invoke( 'add' )
+ assert_instance_of(WIN32OLE, book)
+ end
+ def test_ole_methods
+ methods = @excel.ole_methods
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Quit"))
+ end
+ def test_ole_func_methods
+ methods = @excel.ole_func_methods
+ assert(methods.size > 0)
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Quit"))
+ end
+ def test_ole_put_methods
+ methods = @excel.ole_put_methods
+ assert(methods.size > 0)
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Visible"))
+ end
+ def test_ole_get_methods
+ methods = @excel.ole_get_methods
+ assert(methods.size > 0)
+ method_names = methods.collect{|m| m.name}
+ assert(method_names.include?("Visible"))
+ end
+ def test_ole_method_help
+ quit_info = @excel.ole_method_help("Quit")
+ assert_equal(0, quit_info.size_params)
+ assert_equal(0, quit_info.size_opt_params)
+
+ workbooks = @excel.Workbooks
+ add_info = workbooks.ole_method_help("Add")
+ assert_equal(1, add_info.size_params)
+ assert_equal(1, add_info.size_opt_params)
+ assert(add_info.params[0].input?)
+ assert(add_info.params[0].optional?)
+ assert_equal('VARIANT', add_info.params[0].ole_type)
+ end
+ def teardown
+ @excel.quit
+ @excel = nil
+ GC.start
+ end
+end
+
+class TestWin32OLE_WITH_MSI < RUNIT::TestCase
+ def setup
+ installer = WIN32OLE.new("WindowsInstaller.Installer")
+ @record = installer.CreateRecord(2)
+ end
+
+ # Sorry, this test fails.
+ # Win32OLE does not support this style to set property.
+ # Use Win32OLE#setproperty or Win32OLE#[]= .
+ # def test_invoke
+ # @record.invoke("StringData", 1, 'cccc')
+ # assert_equal('cccc', @record.StringData(1))
+ # end
+
+ def test_setproperty
+ @record.setproperty( "StringData", 1, 'dddd')
+ assert_equal('dddd', @record.StringData(1))
+ end
+ def test_bracket_equal_with_arg
+ @record[ "StringData", 1 ] = 'ffff'
+ assert_equal('ffff', @record.StringData(1))
+ end
+end
+
+# ---------------------
+#
+# a subclass of Win32OLE
+# override new() and connect()
+class MyExcel<WIN32OLE
+ def MyExcel.new
+ super "Excel.Application"
+ end
+ def MyExcel.connect
+ super "Excel.Application"
+ end
+end
+
+class TestMyExcel < TestWin32OLE
+#
+# because we overrided new() and connect()
+# we need to change the test.
+# also, because the class will be different
+#
+ def setup
+ @excel = MyExcel.new
+ @excel.visible = true
+ end
+ def test_s_new
+ assert_instance_of(MyExcel, @excel)
+ end
+ def test_s_connect
+ excel2 = MyExcel.connect
+ assert_instance_of(MyExcel, excel2)
+ end
+#
+# const_load didn't like to be called twice,
+# and I don't know how to undefine something in Ruby yet
+# so, hide the test.
+#
+ private :test_s_const_load
+end
+
+if $0 == __FILE__
+ puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
+ if ARGV.size == 0
+ suite = RUNIT::TestSuite.new
+ suite.add_test(TestWin32OLE.suite)
+ suite.add_test(TestMyExcel.suite)
+ begin
+ installer = WIN32OLE.new("WindowsInstaller.Installer")
+ suite.add_test(TestWin32OLE_WITH_MSI.suite)
+ rescue
+ puts "Skip some test with MSI"
+ end
+ else
+ suite = RUNIT::TestSuite.new
+ ARGV.each do |testmethod|
+ suite.add_test(TestWin32OLE.new(testmethod))
+ end
+ end
+ RUNIT::CUI::TestRunner.quiet_mode = true
+ RUNIT::CUI::TestRunner.run(suite)
+end
diff --git a/ext/win32ole/tests/testall.rb b/ext/win32ole/tests/testall.rb
new file mode 100644
index 0000000000..17bae2c810
--- /dev/null
+++ b/ext/win32ole/tests/testall.rb
@@ -0,0 +1,11 @@
+require 'rubyunit'
+require 'win32ole'
+puts "Now Test Win32OLE version #{WIN32OLE::VERSION}"
+# RUNIT::CUI::TestRunner.quiet_mode = true
+require "testWIN32OLE"
+require "testOLETYPE"
+require "testOLEPARAM"
+require "testOLEMETHOD"
+require "testOLEVARIABLE"
+require "testVARIANT"
+# require "testOLEEVENT"
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
new file mode 100644
index 0000000000..7a800986b5
--- /dev/null
+++ b/ext/win32ole/win32ole.c
@@ -0,0 +1,5565 @@
+/*
+ * (c) 1995 Microsoft Corporation. All rights reserved.
+ * Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
+ *
+ * Other modifications Copyright (c) 1997, 1998 by Gurusamy Sarathy
+ * <gsar@umich.edu> and Jan Dubois <jan.dubois@ibm.net>
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Artistic License, as specified in the README file
+ * of the Perl distribution.
+ *
+ */
+
+/*
+ $Date$
+ modified for win32ole (ruby) by Masaki.Suketa <masaki.suketa@nifty.ne.jp>
+ */
+
+#include "ruby.h"
+#include "st.h"
+#include <windows.h>
+#include <ocidl.h>
+#include <olectl.h>
+#include <ole2.h>
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
+
+#define DOUT fprintf(stderr,"[%d]\n",__LINE__)
+#define DOUTS(x) fprintf(stderr,"[%d]:" #x "=%s\n",__LINE__,x)
+#define DOUTMSG(x) fprintf(stderr, "[%d]:" #x "\n",__LINE__)
+#define DOUTI(x) fprintf(stderr, "[%ld]:" #x "=%d\n",__LINE__,x)
+#define DOUTD(x) fprintf(stderr, "[%d]:" #x "=%f\n",__LINE__,x)
+
+#if defined NONAMELESSUNION && __GNUC__
+#define V_UNION1(X, Y) ((X)->u.Y)
+#else
+#define V_UNION1(X, Y) ((X)->Y)
+#endif
+
+#if defined NONAMELESSUNION && __GNUC__
+#undef V_UNION
+#define V_UNION(X,Y) ((X)->n1.n2.n3.Y)
+
+#undef V_VT
+#define V_VT(X) ((X)->n1.n2.vt)
+
+#undef V_BOOL
+#define V_BOOL(X) V_UNION(X,boolVal)
+#endif
+
+#define OLE_RELEASE(X) (X) ? ((X)->lpVtbl->Release(X)) : 0
+
+#define OLE_ADDREF(X) (X) ? ((X)->lpVtbl->AddRef(X)) : 0
+
+#define OLE_GET_TYPEATTR(X, Y) ((X)->lpVtbl->GetTypeAttr((X), (Y)))
+#define OLE_RELEASE_TYPEATTR(X, Y) ((X)->lpVtbl->ReleaseTypeAttr((X), (Y)))
+
+#define OLE_FREE(x) {\
+ if(gOLEInitialized == Qtrue) {\
+ if(x) {\
+ OLE_RELEASE(x);\
+ (x) = 0;\
+ }\
+ }\
+}
+
+#define OLEData_Get_Struct(obj, pole) {\
+ Data_Get_Struct(obj, struct oledata, pole);\
+ if(!pole->pDispatch) {\
+ rb_raise(rb_eRuntimeError, "Failed to get Dispatch Interface");\
+ }\
+}
+
+#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
+
+#define WIN32OLE_VERSION "0.5.9"
+
+typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
+ (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
+
+typedef HWND (WINAPI FNHTMLHELP)(HWND hwndCaller, LPCSTR pszFile,
+ UINT uCommand, DWORD dwData);
+typedef struct {
+ struct IEventSinkVtbl * lpVtbl;
+} IEventSink, *PEVENTSINK;
+
+typedef struct IEventSinkVtbl IEventSinkVtbl;
+
+struct IEventSinkVtbl {
+ STDMETHOD(QueryInterface)(
+ PEVENTSINK,
+ REFIID,
+ LPVOID *);
+ STDMETHOD_(ULONG, AddRef)(PEVENTSINK);
+ STDMETHOD_(ULONG, Release)(PEVENTSINK);
+
+ STDMETHOD(GetTypeInfoCount)(
+ PEVENTSINK,
+ UINT *);
+ STDMETHOD(GetTypeInfo)(
+ PEVENTSINK,
+ UINT,
+ LCID,
+ ITypeInfo **);
+ STDMETHOD(GetIDsOfNames)(
+ PEVENTSINK,
+ REFIID,
+ OLECHAR **,
+ UINT,
+ LCID,
+ DISPID *);
+ STDMETHOD(Invoke)(
+ PEVENTSINK,
+ DISPID,
+ REFIID,
+ LCID,
+ WORD,
+ DISPPARAMS *,
+ VARIANT *,
+ EXCEPINFO *,
+ UINT *);
+};
+
+typedef struct tagIEVENTSINKOBJ {
+ IEventSinkVtbl *lpVtbl;
+ DWORD m_cRef;
+ IID m_iid;
+ int m_event_id;
+ DWORD m_dwCookie;
+ IConnectionPoint *pConnectionPoint;
+ ITypeInfo *pTypeInfo;
+}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
+
+VALUE cWIN32OLE;
+VALUE cWIN32OLE_TYPE;
+VALUE cWIN32OLE_VARIABLE;
+VALUE cWIN32OLE_METHOD;
+VALUE cWIN32OLE_PARAM;
+VALUE cWIN32OLE_EVENT;
+VALUE eWIN32OLE_RUNTIME_ERROR;
+VALUE mWIN32OLE_VARIANT;
+
+static VALUE ary_ole_event;
+static ID id_events;
+static BOOL gOLEInitialized = Qfalse;
+static HINSTANCE ghhctrl = NULL;
+static HINSTANCE gole32 = NULL;
+static FNCOCREATEINSTANCEEX *gCoCreateInstanceEx = NULL;
+static VALUE com_hash;
+static IDispatchVtbl com_vtbl;
+
+struct oledata {
+ IDispatch *pDispatch;
+};
+
+struct oletypedata {
+ ITypeInfo *pTypeInfo;
+};
+
+struct olemethoddata {
+ ITypeInfo *pOwnerTypeInfo;
+ ITypeInfo *pTypeInfo;
+ UINT index;
+};
+
+struct olevariabledata {
+ ITypeInfo *pTypeInfo;
+ UINT index;
+};
+
+struct oleparamdata {
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
+};
+
+struct oleeventdata {
+ IEVENTSINKOBJ *pEvent;
+};
+
+struct oleparam {
+ DISPPARAMS dp;
+ OLECHAR** pNamedArgs;
+};
+
+static VALUE folemethod_s_allocate _((VALUE));
+static VALUE olemethod_set_member _((VALUE, ITypeInfo *, ITypeInfo *, int, VALUE));
+static VALUE foletype_s_allocate _((VALUE));
+static VALUE oletype_set_member _((VALUE, ITypeInfo *, VALUE));
+static VALUE olemethod_from_typeinfo _((VALUE, ITypeInfo *, VALUE));
+static HRESULT ole_docinfo_from_type _((ITypeInfo *, BSTR *, BSTR *, DWORD *, BSTR *));
+static char *ole_wc2mb(LPWSTR);
+static VALUE ole_variant2val(VARIANT*);
+static void ole_val2variant(VALUE, VARIANT*);
+
+typedef struct _Win32OLEIDispatch
+{
+ IDispatch dispatch;
+ ULONG refcount;
+ VALUE obj;
+} Win32OLEIDispatch;
+
+static HRESULT ( STDMETHODCALLTYPE QueryInterface )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ if (MEMCMP(riid, &IID_IUnknown, GUID, 1) == 0
+ || MEMCMP(riid, &IID_IDispatch, GUID, 1) == 0)
+ {
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ p->refcount++;
+ *ppvObject = This;
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+
+static ULONG ( STDMETHODCALLTYPE AddRef )(
+ IDispatch __RPC_FAR * This)
+{
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ return ++(p->refcount);
+}
+
+static ULONG ( STDMETHODCALLTYPE Release )(
+ IDispatch __RPC_FAR * This)
+{
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ ULONG u = --(p->refcount);
+ if (u == 0) {
+ st_data_t key = p->obj;
+ st_delete(DATA_PTR(com_hash), &key, 0);
+ free(p);
+ }
+ return u;
+}
+
+static HRESULT ( STDMETHODCALLTYPE GetTypeInfoCount )(
+ IDispatch __RPC_FAR * This,
+ /* [out] */ UINT __RPC_FAR *pctinfo)
+{
+ return E_NOTIMPL;
+}
+
+static HRESULT ( STDMETHODCALLTYPE GetTypeInfo )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ UINT iTInfo,
+ /* [in] */ LCID lcid,
+ /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo)
+{
+ return E_NOTIMPL;
+}
+
+
+static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ REFIID riid,
+ /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
+ /* [in] */ UINT cNames,
+ /* [in] */ LCID lcid,
+ /* [size_is][out] */ DISPID __RPC_FAR *rgDispId)
+{
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ char* psz = ole_wc2mb(*rgszNames); // support only one method
+ *rgDispId = rb_intern(psz);
+ free(psz);
+ return S_OK;
+}
+
+static /* [local] */ HRESULT ( STDMETHODCALLTYPE Invoke )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ DISPID dispIdMember,
+ /* [in] */ REFIID riid,
+ /* [in] */ LCID lcid,
+ /* [in] */ WORD wFlags,
+ /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
+ /* [out] */ VARIANT __RPC_FAR *pVarResult,
+ /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
+ /* [out] */ UINT __RPC_FAR *puArgErr)
+{
+ VALUE v;
+ int i;
+ int args = pDispParams->cArgs;
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ VALUE* parg = ALLOCA_N(VALUE, args);
+ for (i = 0; i < args; i++) {
+ *(parg + i) = ole_variant2val(&pDispParams->rgvarg[args - i - 1]);
+ }
+ if (dispIdMember == DISPID_VALUE) {
+ if (wFlags == DISPATCH_METHOD) {
+ dispIdMember = rb_intern("call");
+ } else if (wFlags & DISPATCH_PROPERTYGET) {
+ dispIdMember = rb_intern("value");
+ }
+ }
+ v = rb_funcall2(p->obj, dispIdMember, args, parg);
+ ole_val2variant(v, pVarResult);
+ return S_OK;
+}
+
+static IDispatch*
+val2dispatch(val)
+ VALUE val;
+{
+ struct st_table *tbl = DATA_PTR(com_hash);
+ Win32OLEIDispatch* pdisp;
+ st_data_t data;
+
+ if (st_lookup(tbl, val, &data)) {
+ pdisp = (Win32OLEIDispatch *)(data & ~FIXNUM_FLAG);
+ pdisp->refcount++;
+ }
+ else {
+ pdisp = ALLOC(Win32OLEIDispatch);
+ pdisp->dispatch.lpVtbl = &com_vtbl;
+ pdisp->refcount = 1;
+ pdisp->obj = val;
+ st_insert(tbl, val, (VALUE)pdisp | FIXNUM_FLAG);
+ }
+ return &pdisp->dispatch;
+}
+
+static void
+time2d(hh, mm, ss, pv)
+ int hh, mm, ss;
+ double *pv;
+{
+ *pv = (hh * 60.0 * 60.0 + mm * 60.0 + ss) / 86400.0;
+}
+
+static void
+d2time(v, hh, mm, ss)
+ double v;
+ int *hh, *mm, *ss;
+{
+ double d_hh, d_mm, d_ss;
+ int i_hh, i_mm, i_ss;
+
+ double d = v * 86400.0;
+
+ d_hh = d / 3600.0;
+ i_hh = (int)d_hh;
+
+ d = d - i_hh * 3600.0;
+
+ d_mm = d / 60.0;
+ i_mm = (int)d_mm;
+
+ d = d - i_mm * 60.0;
+
+ d_ss = d * 10.0 + 5;
+
+ i_ss = (int)d_ss / 10;
+
+ if(i_ss == 60) {
+ i_mm += 1;
+ i_ss = 0;
+ }
+
+ if (i_mm == 60) {
+ i_hh += 1;
+ i_mm = 0;
+ }
+ if (i_hh == 24) {
+ i_hh = 0;
+ }
+
+ *hh = i_hh;
+ *mm = i_mm;
+ *ss = i_ss;
+}
+
+static void
+civil2jd(y, m, d, jd)
+ int y, m, d;
+ long *jd;
+{
+ long a, b;
+ if (m <= 2) {
+ y -= 1;
+ m += 12;
+ }
+ a = (long)(y / 100.0);
+ b = 2 - a + (long)(a / 4.0);
+ *jd = (long)(365.25 * (double)(y + 4716))
+ + (long)(30.6001 * (m + 1))
+ + d + b - 1524;
+}
+
+static void
+jd2civil(day, yy, mm, dd)
+ long day;
+ int *yy, *mm, *dd;
+{
+ long x, a, b, c, d, e;
+ x = (long)(((double)day - 1867216.25) / 36524.25);
+ a = day + 1 + x - (long)(x / 4.0);
+ b = a + 1524;
+ c = (long)(((double)b -122.1) /365.25);
+ d = (long)(365.25 * c);
+ e = (long)((double)(b - d) / 30.6001);
+ *dd = b - d - (long)(30.6001 * e);
+ if (e <= 13) {
+ *mm = e - 1;
+ *yy = c - 4716;
+ }
+ else {
+ *mm = e - 13;
+ *yy = c - 4715;
+ }
+}
+
+static void
+double2time(v, y, m, d, hh, mm, ss)
+ double v;
+ int *y, *m, *d, *hh, *mm, *ss;
+{
+ long day;
+ double t;
+
+ day = (long)v;
+ t = v - day;
+ jd2civil(2415019 + day, y, m, d);
+
+ d2time(t, hh, mm, ss);
+}
+
+static double
+time_object2date(tmobj)
+ VALUE tmobj;
+{
+ long y, m, d, hh, mm, ss;
+ long day;
+ double t;
+ y = FIX2INT(rb_funcall(tmobj, rb_intern("year"), 0));
+ m = FIX2INT(rb_funcall(tmobj, rb_intern("month"), 0));
+ d = FIX2INT(rb_funcall(tmobj, rb_intern("mday"), 0));
+ hh = FIX2INT(rb_funcall(tmobj, rb_intern("hour"), 0));
+ mm = FIX2INT(rb_funcall(tmobj, rb_intern("min"), 0));
+ ss = FIX2INT(rb_funcall(tmobj, rb_intern("sec"), 0));
+ civil2jd(y, m, d, &day);
+ time2d(hh, mm, ss, &t);
+ return t + day - 2415019;
+}
+
+static VALUE
+date2time_str(date)
+ double date;
+{
+ int y, m, d, hh, mm, ss;
+ char szTime[20];
+ double2time(date, &y, &m, &d, &hh, &mm, &ss);
+ sprintf(szTime,
+ "%4.4d/%02.2d/%02.2d %02.2d:%02.2d:%02.2d",
+ y, m, d, hh, mm, ss);
+ return rb_str_new2(szTime);
+}
+
+static void ole_val2variant();
+
+static char *
+ole_wc2mb(pw)
+ LPWSTR pw;
+{
+ int size;
+ LPSTR pm;
+ size = WideCharToMultiByte(CP_ACP, 0, pw, -1, NULL, 0, NULL, NULL);
+ if (size) {
+ pm = ALLOC_N(char, size);
+ WideCharToMultiByte(CP_ACP, 0, pw, -1, pm, size, NULL, NULL);
+ }
+ else {
+ pm = ALLOC_N(char, 1);
+ *pm = '\0';
+ }
+ return pm;
+}
+
+static VALUE
+ole_hresult2msg(hr)
+ HRESULT hr;
+{
+ VALUE msg = Qnil;
+ char *p_msg = NULL;
+ char *term = NULL;
+ DWORD dwCount;
+
+ char strhr[100];
+ sprintf(strhr, " HRESULT error code:0x%08x\n ", hr);
+ msg = rb_str_new2(strhr);
+
+ dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, hr, LOCALE_SYSTEM_DEFAULT,
+ (LPTSTR)&p_msg, 0, NULL);
+ if (dwCount > 0) {
+ term = p_msg + strlen(p_msg);
+ while (p_msg < term) {
+ term--;
+ if (*term == '\r' || *term == '\n')
+ *term = '\0';
+ else break;
+ }
+ if (p_msg[0] != '\0') {
+ rb_str_cat2(msg, p_msg);
+ }
+ }
+ LocalFree(p_msg);
+ return msg;
+}
+
+static VALUE
+ole_excepinfo2msg(pExInfo)
+ EXCEPINFO *pExInfo;
+{
+ char error_code[40];
+ char *pSource = NULL;
+ char *pDescription = NULL;
+ VALUE error_msg;
+ if(pExInfo->pfnDeferredFillIn != NULL) {
+ (*pExInfo->pfnDeferredFillIn)(pExInfo);
+ }
+ if (pExInfo->bstrSource != NULL) {
+ pSource = ole_wc2mb(pExInfo->bstrSource);
+ }
+ if (pExInfo->bstrDescription != NULL) {
+ pDescription = ole_wc2mb(pExInfo->bstrDescription);
+ }
+ if(pExInfo->wCode == 0) {
+ sprintf(error_code, "\n OLE error code:%lX in ", pExInfo->scode);
+ }
+ else{
+ sprintf(error_code, "\n OLE error code:%u in ", pExInfo->wCode);
+ }
+ error_msg = rb_str_new2(error_code);
+ if(pSource != NULL) {
+ rb_str_cat(error_msg, pSource, strlen(pSource));
+ }
+ else {
+ rb_str_cat(error_msg, "<Unknown>", 9);
+ }
+ rb_str_cat2(error_msg, "\n ");
+ if(pDescription != NULL) {
+ rb_str_cat2(error_msg, pDescription);
+ }
+ else {
+ rb_str_cat2(error_msg, "<No Description>");
+ }
+ if(pSource) free(pSource);
+ if(pDescription) free(pDescription);
+ SysFreeString(pExInfo->bstrDescription);
+ SysFreeString(pExInfo->bstrSource);
+ SysFreeString(pExInfo->bstrHelpFile);
+ return error_msg;
+}
+
+static void
+#ifdef HAVE_STDARG_PROTOTYPES
+ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...)
+#else
+ole_raise(hr, exc, fmt, va_alist)
+ HRESULT hr;
+ VALUE exc;
+ const char *fmt;
+ va_dcl
+#endif
+{
+ va_list args;
+ char buf[BUFSIZ];
+ VALUE err_msg;
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+
+ err_msg = ole_hresult2msg(hr);
+ if(err_msg != Qnil) {
+ rb_raise(ecs, "%s\n%s", buf, StringValuePtr(err_msg));
+ }
+ else {
+ rb_raise(ecs, "%s", buf);
+ }
+}
+
+void
+ole_uninitialize()
+{
+ OleUninitialize();
+ gOLEInitialized = Qfalse;
+}
+
+static void
+ole_initialize()
+{
+ HRESULT hr;
+
+ if(gOLEInitialized == Qfalse) {
+ hr = OleInitialize(NULL);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "Fail: OLE initialize");
+ }
+ gOLEInitialized = Qtrue;
+ /*
+ * In some situation, OleUninitialize does not work fine. ;-<
+ */
+ /*
+ atexit((void (*)(void))ole_uninitialize);
+ */
+ }
+}
+
+static void
+ole_msg_loop() {
+ MSG msg;
+ while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+static void
+ole_free(pole)
+ struct oledata *pole;
+{
+ OLE_FREE(pole->pDispatch);
+}
+
+static void
+oletype_free(poletype)
+ struct oletypedata *poletype;
+{
+ OLE_FREE(poletype->pTypeInfo);
+}
+
+static void
+olemethod_free(polemethod)
+ struct olemethoddata *polemethod;
+{
+ OLE_FREE(polemethod->pTypeInfo);
+ OLE_FREE(polemethod->pOwnerTypeInfo);
+}
+
+static void
+olevariable_free(polevar)
+ struct olevariabledata *polevar;
+{
+ OLE_FREE(polevar->pTypeInfo);
+}
+
+static void
+oleparam_free(pole)
+ struct oleparamdata *pole;
+{
+ OLE_FREE(pole->pTypeInfo);
+}
+
+static LPWSTR
+ole_mb2wc(pm, len)
+ char *pm;
+ int len;
+{
+ int size;
+ LPWSTR pw;
+ size = MultiByteToWideChar(CP_ACP, 0, pm, len, NULL, 0);
+ pw = SysAllocStringLen(NULL, size - 1);
+ MultiByteToWideChar(CP_ACP, 0, pm, len, pw, size);
+ return pw;
+}
+
+static VALUE
+ole_wc2vstr(pw, isfree)
+ LPWSTR pw;
+ BOOL isfree;
+{
+ char *p = ole_wc2mb(pw);
+ VALUE vstr = rb_str_new2(p);
+ if(isfree)
+ SysFreeString(pw);
+ free(p);
+ return vstr;
+}
+
+static VALUE
+ole_ary_m_entry(val, pid)
+ VALUE val;
+ long *pid;
+{
+ VALUE obj = Qnil;
+ int i = 0;
+ obj = val;
+ while(TYPE(obj) == T_ARRAY) {
+ obj = rb_ary_entry(obj, pid[i]);
+ i++;
+ }
+ return obj;
+}
+
+static void
+ole_set_safe_array(n, psa, pid, pub, val, dim)
+ long n;
+ SAFEARRAY *psa;
+ long *pid;
+ long *pub;
+ VALUE val;
+ long dim;
+{
+ VALUE val1;
+ VARIANT var;
+ VariantInit(&var);
+ if(n < 0) return;
+ if(n == dim) {
+ val1 = ole_ary_m_entry(val, pid);
+ ole_val2variant(val1, &var);
+ SafeArrayPutElement(psa, pid, &var);
+ }
+ pid[n] += 1;
+ if (pid[n] < pub[n]) {
+ ole_set_safe_array(dim, psa, pid, pub, val, dim);
+ }
+ else {
+ pid[n] = 0;
+ ole_set_safe_array(n-1, psa, pid, pub, val, dim);
+ }
+}
+
+static void
+ole_val2variant(val, var)
+ VALUE val;
+ VARIANT *var;
+{
+ struct oledata *pole;
+ if(rb_obj_is_kind_of(val, cWIN32OLE)) {
+ Data_Get_Struct(val, struct oledata, pole);
+ OLE_ADDREF(pole->pDispatch);
+ V_VT(var) = VT_DISPATCH;
+ V_DISPATCH(var) = pole->pDispatch;
+ return;
+ }
+ if (rb_obj_is_kind_of(val, rb_cTime)) {
+ V_VT(var) = VT_DATE;
+ V_DATE(var) = time_object2date(val);
+ return;
+ }
+ switch (TYPE(val)) {
+ case T_ARRAY:
+ {
+ VALUE val1;
+ long dim = 0;
+ int i = 0;
+
+ HRESULT hr;
+ SAFEARRAYBOUND *psab;
+ SAFEARRAY *psa;
+ long *pub, *pid;
+
+ val1 = val;
+ while(TYPE(val1) == T_ARRAY) {
+ val1 = rb_ary_entry(val1, 0);
+ dim += 1;
+ }
+ psab = ALLOC_N(SAFEARRAYBOUND, dim);
+ pub = ALLOC_N(long, dim);
+ pid = ALLOC_N(long, dim);
+
+ if(!psab || !pub || !pid) {
+ if(pub) free(pub);
+ if(psab) free(psab);
+ if(pid) free(pid);
+ rb_raise(rb_eRuntimeError, "memory allocation error");
+ }
+ val1 = val;
+ i = 0;
+ while(TYPE(val1) == T_ARRAY) {
+ psab[i].cElements = RARRAY(val1)->len;
+ psab[i].lLbound = 0;
+ pub[i] = psab[i].cElements;
+ pid[i] = 0;
+ i ++;
+ val1 = rb_ary_entry(val1, 0);
+ }
+ /* Create and fill VARIANT array */
+ psa = SafeArrayCreate(VT_VARIANT, dim, psab);
+ if (psa == NULL)
+ hr = E_OUTOFMEMORY;
+ else
+ hr = SafeArrayLock(psa);
+ if (SUCCEEDED(hr)) {
+ ole_set_safe_array(dim-1, psa, pid, pub, val, dim-1);
+ hr = SafeArrayUnlock(psa);
+ }
+ if(pub) free(pub);
+ if(psab) free(psab);
+ if(pid) free(pid);
+
+ if (SUCCEEDED(hr)) {
+ V_VT(var) = VT_VARIANT | VT_ARRAY;
+ V_ARRAY(var) = psa;
+ }
+ else if (psa != NULL)
+ SafeArrayDestroy(psa);
+ break;
+ }
+ case T_STRING:
+ V_VT(var) = VT_BSTR;
+ V_BSTR(var) = ole_mb2wc(StringValuePtr(val), -1);
+ break;
+ case T_FIXNUM:
+ V_VT(var) = VT_I4;
+ V_I4(var) = NUM2INT(val);
+ break;
+ case T_BIGNUM:
+ V_VT(var) = VT_R8;
+ V_R8(var) = rb_big2dbl(val);
+ break;
+ case T_FLOAT:
+ V_VT(var) = VT_R8;
+ V_R8(var) = NUM2DBL(val);
+ break;
+ case T_TRUE:
+ V_VT(var) = VT_BOOL;
+ V_BOOL(var) = VARIANT_TRUE;
+ break;
+ case T_FALSE:
+ V_VT(var) = VT_BOOL;
+ V_BOOL(var) = VARIANT_FALSE;
+ break;
+ case T_NIL:
+ V_VT(var) = VT_ERROR;
+ V_ERROR(var) = DISP_E_PARAMNOTFOUND;
+ break;
+ default:
+ V_VT(var) = VT_DISPATCH;
+ V_DISPATCH(var) = val2dispatch(val);
+ break;
+ }
+}
+
+static VALUE
+ole_set_member(self, dispatch)
+ VALUE self;
+ IDispatch * dispatch;
+{
+ struct oledata *pole;
+ Data_Get_Struct(self, struct oledata, pole);
+ if (pole->pDispatch) {
+ OLE_RELEASE(pole->pDispatch);
+ pole->pDispatch = NULL;
+ }
+ pole->pDispatch = dispatch;
+ return self;
+}
+
+static VALUE fole_s_allocate _((VALUE));
+static VALUE
+fole_s_allocate(klass)
+ VALUE klass;
+{
+ struct oledata *pole;
+ VALUE obj;
+ ole_initialize();
+ obj = Data_Make_Struct(klass,struct oledata,0,ole_free,pole);
+ pole->pDispatch = NULL;
+ return obj;
+}
+
+static VALUE
+create_win32ole_object(klass, pDispatch, argc, argv)
+ VALUE klass;
+ IDispatch *pDispatch;
+ int argc;
+ VALUE *argv;
+{
+ VALUE obj = fole_s_allocate(klass);
+ ole_set_member(obj, pDispatch);
+ return obj;
+}
+
+static VALUE
+ole_variant2val(pvar)
+ VARIANT *pvar;
+{
+ VALUE obj = Qnil;
+ HRESULT hr;
+ while ( V_VT(pvar) == (VT_BYREF | VT_VARIANT) )
+ pvar = V_VARIANTREF(pvar);
+
+ if(V_ISARRAY(pvar)) {
+ SAFEARRAY *psa = V_ISBYREF(pvar) ? *V_ARRAYREF(pvar) : V_ARRAY(pvar);
+ long i;
+ long *pID, *pLB, *pUB;
+ VARIANT variant;
+ VALUE val;
+ VALUE val2;
+
+ int dim = SafeArrayGetDim(psa);
+ VariantInit(&variant);
+ V_VT(&variant) = (V_VT(pvar) & ~VT_ARRAY) | VT_BYREF;
+
+ pID = ALLOC_N(long, dim);
+ pLB = ALLOC_N(long, dim);
+ pUB = ALLOC_N(long, dim);
+
+ if(!pID || !pLB || !pUB) {
+ if(pID) free(pID);
+ if(pLB) free(pLB);
+ if(pUB) free(pUB);
+ rb_raise(rb_eRuntimeError, "memory allocation error");
+ }
+
+ obj = Qnil;
+
+ for(i = 0; i < dim; ++i) {
+ SafeArrayGetLBound(psa, i+1, &pLB[i]);
+ SafeArrayGetLBound(psa, i+1, &pID[i]);
+ SafeArrayGetUBound(psa, i+1, &pUB[i]);
+ }
+
+ hr = SafeArrayLock(psa);
+ if (SUCCEEDED(hr)) {
+ val2 = rb_ary_new();
+ while (i >= 0) {
+ hr = SafeArrayPtrOfIndex(psa, pID, &V_BYREF(&variant));
+ if (FAILED(hr))
+ break;
+
+ val = ole_variant2val(&variant);
+ rb_ary_push(val2, val);
+ for (i = dim-1 ; i >= 0 ; --i) {
+ if (++pID[i] <= pUB[i])
+ break;
+
+ pID[i] = pLB[i];
+ if (i > 0) {
+ if (obj == Qnil)
+ obj = rb_ary_new();
+ rb_ary_push(obj, val2);
+ val2 = rb_ary_new();
+ }
+ }
+ }
+ SafeArrayUnlock(psa);
+ }
+ if(pID) free(pID);
+ if(pLB) free(pLB);
+ if(pUB) free(pUB);
+ return (obj == Qnil) ? val2 : obj;
+ }
+ switch(V_VT(pvar) & ~VT_BYREF){
+ case VT_EMPTY:
+ break;
+ case VT_NULL:
+ break;
+ case VT_UI1:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_UI1REF(pvar));
+ else
+ obj = INT2NUM((long)V_UI1(pvar));
+ break;
+
+ case VT_I2:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_I2REF(pvar));
+ else
+ obj = INT2NUM((long)V_I2(pvar));
+ break;
+
+ case VT_I4:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_I4REF(pvar));
+ else
+ obj = INT2NUM((long)V_I4(pvar));
+ break;
+
+ case VT_R4:
+ if(V_ISBYREF(pvar))
+ obj = rb_float_new(*V_R4REF(pvar));
+ else
+ obj = rb_float_new(V_R4(pvar));
+ break;
+
+ case VT_R8:
+ if(V_ISBYREF(pvar))
+ obj = rb_float_new(*V_R8REF(pvar));
+ else
+ obj = rb_float_new(V_R8(pvar));
+ break;
+
+ case VT_BSTR:
+ {
+ char *p;
+ if(V_ISBYREF(pvar))
+ p = ole_wc2mb(*V_BSTRREF(pvar));
+ else
+ p = ole_wc2mb(V_BSTR(pvar));
+ obj = rb_str_new2(p);
+ if(p) free(p);
+ break;
+ }
+
+ case VT_ERROR:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM(*V_ERRORREF(pvar));
+ else
+ obj = INT2NUM(V_ERROR(pvar));
+ break;
+
+ case VT_BOOL:
+ if (V_ISBYREF(pvar))
+ obj = (*V_BOOLREF(pvar) ? Qtrue : Qfalse);
+ else
+ obj = (V_BOOL(pvar) ? Qtrue : Qfalse);
+ break;
+
+ case VT_DISPATCH:
+ {
+ IDispatch *pDispatch;
+
+ if (V_ISBYREF(pvar))
+ pDispatch = *V_DISPATCHREF(pvar);
+ else
+ pDispatch = V_DISPATCH(pvar);
+
+ if (pDispatch != NULL ) {
+ OLE_ADDREF(pDispatch);
+ obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
+ }
+ break;
+ }
+
+ case VT_UNKNOWN:
+ {
+
+ /* get IDispatch interface from IUnknown interface */
+ IUnknown *punk;
+ IDispatch *pDispatch;
+ HRESULT hr;
+
+ if (V_ISBYREF(pvar))
+ punk = *V_UNKNOWNREF(pvar);
+ else
+ punk = V_UNKNOWN(pvar);
+
+ if(punk != NULL) {
+ hr = punk->lpVtbl->QueryInterface(punk, &IID_IDispatch,
+ (void **)&pDispatch);
+ if(SUCCEEDED(hr)) {
+ obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
+ }
+ }
+ break;
+ }
+
+ case VT_DATE:
+ {
+ DATE date;
+ if(V_ISBYREF(pvar))
+ date = *V_DATEREF(pvar);
+ else
+ date = V_DATE(pvar);
+
+ obj = date2time_str(date);
+ break;
+ }
+ case VT_CY:
+ default:
+ {
+ HRESULT hr;
+ VARIANT variant;
+ VariantInit(&variant);
+ hr = VariantChangeTypeEx(&variant, pvar,
+ LOCALE_SYSTEM_DEFAULT, 0, VT_BSTR);
+ if (SUCCEEDED(hr) && V_VT(&variant) == VT_BSTR) {
+ char *p = ole_wc2mb(V_BSTR(&variant));
+ obj = rb_str_new2(p);
+ if(p) free(p);
+ }
+ VariantClear(&variant);
+ break;
+ }
+ }
+ return obj;
+}
+
+static LONG reg_open_key(hkey, name, phkey)
+ HKEY hkey;
+ const char *name;
+ HKEY *phkey;
+{
+ return RegOpenKeyEx(hkey, name, 0, KEY_READ, phkey);
+}
+
+static LONG reg_open_vkey(hkey, key, phkey)
+ HKEY hkey;
+ VALUE key;
+ HKEY *phkey;
+{
+ return reg_open_key(hkey, StringValuePtr(key), phkey);
+}
+
+static VALUE
+reg_enum_key(hkey, i)
+ HKEY hkey;
+ DWORD i;
+{
+ char buf[BUFSIZ];
+ DWORD size_buf = sizeof(buf);
+ FILETIME ft;
+ LONG err = RegEnumKeyEx(hkey, i, buf, &size_buf,
+ NULL, NULL, NULL, &ft);
+ if(err == ERROR_SUCCESS) {
+ return rb_str_new2(buf);
+ }
+ return Qnil;
+}
+
+static VALUE
+reg_get_val(hkey, subkey)
+ HKEY hkey;
+ const char *subkey;
+{
+ char buf[BUFSIZ];
+ LONG size_buf = sizeof(buf);
+ LONG err = RegQueryValue(hkey, subkey, buf, &size_buf);
+ if (err == ERROR_SUCCESS) {
+ return rb_str_new2(buf);
+ }
+ return Qnil;
+}
+
+static VALUE
+typelib_file_from_clsid(ole)
+ VALUE ole;
+{
+ OLECHAR *pbuf;
+ CLSID clsid;
+ HRESULT hr;
+ HKEY hroot, hclsid;
+ LONG err;
+ VALUE typelib;
+ VALUE vclsid;
+ char *pclsid = NULL;
+
+ pbuf = ole_mb2wc(StringValuePtr(ole), -1);
+ hr = CLSIDFromProgID(pbuf, &clsid);
+ SysFreeString(pbuf);
+ if (FAILED(hr)) {
+ return Qnil;
+ }
+ StringFromCLSID(&clsid, &pbuf);
+ vclsid = WC2VSTR(pbuf);
+ err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hroot);
+ if (err != ERROR_SUCCESS) {
+ return Qnil;
+ }
+ err = reg_open_key(hroot, StringValuePtr(vclsid), &hclsid);
+ if (err != ERROR_SUCCESS) {
+ RegCloseKey(hroot);
+ return Qnil;
+ }
+ typelib = reg_get_val(hclsid, "InprocServer32");
+ RegCloseKey(hroot);
+ RegCloseKey(hclsid);
+ return typelib;
+}
+
+static VALUE
+typelib_file_from_typelib(ole)
+ VALUE ole;
+{
+ HKEY htypelib, hclsid, hversion, hlang;
+ double fver;
+ DWORD i, j, k;
+ LONG err;
+ BOOL found = FALSE;
+ VALUE typelib;
+ VALUE file = Qnil;
+ VALUE clsid;
+ VALUE ver;
+ VALUE lang;
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
+ if(err != ERROR_SUCCESS) {
+ return Qnil;
+ }
+ for(i = 0; !found; i++) {
+ clsid = reg_enum_key(htypelib, i);
+ if (clsid == Qnil)
+ break;
+ err = reg_open_vkey(htypelib, clsid, &hclsid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ fver = 0;
+ for(j = 0; !found; j++) {
+ ver = reg_enum_key(hclsid, j);
+ if (ver == Qnil)
+ break;
+ err = reg_open_vkey(hclsid, ver, &hversion);
+ if (err != ERROR_SUCCESS || fver > atof(StringValuePtr(ver)))
+ continue;
+ fver = atof(StringValuePtr(ver));
+ typelib = reg_get_val(hversion, NULL);
+ if (typelib == Qnil)
+ continue;
+ if (rb_str_cmp(typelib, ole) == 0) {
+ for(k = 0; !found; k++) {
+ lang = reg_enum_key(hversion, k);
+ if (lang == Qnil)
+ break;
+ err = reg_open_vkey(hversion, lang, &hlang);
+ if (err == ERROR_SUCCESS) {
+ if ((file = reg_get_val(hlang, "win32")) != Qnil)
+ found = TRUE;
+ RegCloseKey(hlang);
+ }
+ }
+ }
+ RegCloseKey(hversion);
+ }
+ RegCloseKey(hclsid);
+ }
+ RegCloseKey(htypelib);
+ return file;
+}
+
+static VALUE
+typelib_file(ole)
+ VALUE ole;
+{
+ VALUE file = typelib_file_from_clsid(ole);
+ if (file != Qnil) {
+ return file;
+ }
+ return typelib_file_from_typelib(ole);
+}
+
+static void
+ole_const_load(pTypeLib, klass, self)
+ ITypeLib *pTypeLib;
+ VALUE klass;
+ VALUE self;
+{
+ unsigned int count;
+ unsigned int index;
+ int iVar;
+ ITypeInfo *pTypeInfo;
+ TYPEATTR *pTypeAttr;
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ unsigned int len;
+ BSTR bstr;
+ char *pName = NULL;
+ VALUE val;
+ VALUE constant;
+ ID id;
+ constant = rb_hash_new();
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (index = 0; index < count; index++) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, index, &pTypeInfo);
+ if (FAILED(hr))
+ continue;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ continue;
+ }
+ for(iVar = 0; iVar < pTypeAttr->cVars; iVar++) {
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, iVar, &pVarDesc);
+ if(FAILED(hr))
+ continue;
+ if(pVarDesc->varkind == VAR_CONST &&
+ !(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN |
+ VARFLAG_FRESTRICTED |
+ VARFLAG_FNONBROWSABLE))) {
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr,
+ 1, &len);
+ if(FAILED(hr) || len == 0 || !bstr)
+ continue;
+ pName = ole_wc2mb(bstr);
+ val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue));
+ *pName = toupper(*pName);
+ id = rb_intern(pName);
+ if (rb_is_const_id(id)) {
+ rb_define_const(klass, pName, val);
+ }
+ else {
+ rb_hash_aset(constant, rb_str_new2(pName), val);
+ }
+ SysFreeString(bstr);
+ if(pName) {
+ free(pName);
+ pName = NULL;
+ }
+ }
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ }
+ pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
+ OLE_RELEASE(pTypeInfo);
+ }
+ rb_define_const(klass, "CONSTANTS", constant);
+}
+
+static HRESULT
+clsid_from_remote(host, com, pclsid)
+ VALUE host;
+ VALUE com;
+ CLSID *pclsid;
+{
+ HKEY hlm;
+ HKEY hpid;
+ VALUE subkey;
+ LONG err;
+ char clsid[100];
+ OLECHAR *pbuf;
+ DWORD len;
+ DWORD dwtype;
+ HRESULT hr = S_OK;
+ err = RegConnectRegistry(StringValuePtr(host), HKEY_LOCAL_MACHINE, &hlm);
+ if (err != ERROR_SUCCESS)
+ return HRESULT_FROM_WIN32(err);
+ subkey = rb_str_new2("SOFTWARE\\Classes\\");
+ rb_str_concat(subkey, com);
+ rb_str_cat2(subkey, "\\CLSID");
+ err = RegOpenKeyEx(hlm, StringValuePtr(subkey), 0, KEY_READ, &hpid);
+ if (err != ERROR_SUCCESS)
+ hr = HRESULT_FROM_WIN32(err);
+ else {
+ len = sizeof(clsid);
+ err = RegQueryValueEx(hpid, "", NULL, &dwtype, clsid, &len);
+ if (err == ERROR_SUCCESS && dwtype == REG_SZ) {
+ pbuf = ole_mb2wc(clsid, -1);
+ hr = CLSIDFromString(pbuf, pclsid);
+ SysFreeString(pbuf);
+ }
+ else {
+ hr = HRESULT_FROM_WIN32(err);
+ }
+ RegCloseKey(hpid);
+ }
+ RegCloseKey(hlm);
+ return hr;
+}
+
+static VALUE
+ole_create_dcom(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE ole, host, others;
+ HRESULT hr;
+ CLSID clsid;
+ OLECHAR *pbuf;
+
+ COSERVERINFO serverinfo;
+ MULTI_QI multi_qi;
+ DWORD clsctx = CLSCTX_REMOTE_SERVER;
+
+ if (!gole32)
+ gole32 = LoadLibrary("OLE32");
+ if (!gole32)
+ rb_raise(rb_eRuntimeError, "Failed to load OLE32");
+ if (!gCoCreateInstanceEx)
+ gCoCreateInstanceEx = (FNCOCREATEINSTANCEEX*)
+ GetProcAddress(gole32, "CoCreateInstanceEx");
+ if (!gCoCreateInstanceEx)
+ rb_raise(rb_eRuntimeError, "CoCreateInstanceEx is not supported in this environment.");
+ rb_scan_args(argc, argv, "2*", &ole, &host, &others);
+
+ pbuf = ole_mb2wc(StringValuePtr(ole), -1);
+ hr = CLSIDFromProgID(pbuf, &clsid);
+ if (FAILED(hr))
+ hr = clsid_from_remote(host, ole, &clsid);
+ if (FAILED(hr))
+ hr = CLSIDFromString(pbuf, &clsid);
+ SysFreeString(pbuf);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Unknown OLE server: `%s'",
+ StringValuePtr(ole));
+ memset(&serverinfo, 0, sizeof(COSERVERINFO));
+ serverinfo.pwszName = ole_mb2wc(StringValuePtr(host), -1);
+ memset(&multi_qi, 0, sizeof(MULTI_QI));
+ multi_qi.pIID = &IID_IDispatch;
+ hr = gCoCreateInstanceEx(&clsid, NULL, clsctx, &serverinfo, 1, &multi_qi);
+ SysFreeString(serverinfo.pwszName);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Failed to create DCOM server `%s' in `%s'",
+ StringValuePtr(ole),
+ StringValuePtr(host));
+
+ ole_set_member(self, (IDispatch*)multi_qi.pItf);
+ return self;
+}
+
+static VALUE
+ole_bind_obj(moniker, argc, argv, self)
+ VALUE moniker;
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ IBindCtx *pBindCtx;
+ IMoniker *pMoniker;
+ IDispatch *pDispatch;
+ HRESULT hr;
+ OLECHAR *pbuf;
+ ULONG eaten = 0;
+
+ ole_initialize();
+
+ hr = CreateBindCtx(0, &pBindCtx);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Failed to create bind context");
+ }
+
+ pbuf = ole_mb2wc(StringValuePtr(moniker), -1);
+ hr = MkParseDisplayName(pBindCtx, pbuf, &eaten, &pMoniker);
+ SysFreeString(pbuf);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pBindCtx);
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Failed to parse display name of moniker `%s'",
+ StringValuePtr(moniker));
+ }
+ hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL,
+ &IID_IDispatch,
+ (void**)&pDispatch);
+ OLE_RELEASE(pMoniker);
+ OLE_RELEASE(pBindCtx);
+
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Failed to bind moniker `%s'",
+ StringValuePtr(moniker));
+ }
+ return create_win32ole_object(self, pDispatch, argc, argv);
+}
+
+/*
+ * WIN32OLE.connect( ole ) --> aWIN32OLE
+ * ----
+ * Returns running OLE Automation object or WIN32OLE object from moniker.
+ * 1st argument should be OLE program id or class id or moniker.
+ */
+static VALUE
+fole_s_connect(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE svr_name;
+ VALUE others;
+ HRESULT hr;
+ CLSID clsid;
+ OLECHAR *pBuf;
+ IDispatch *pDispatch;
+ IUnknown *pUnknown;
+
+ rb_secure(4);
+ /* initialize to use OLE */
+ ole_initialize();
+
+ rb_scan_args(argc, argv, "1*", &svr_name, &others);
+ if (ruby_safe_level > 0 && OBJ_TAINTED(svr_name)) {
+ rb_raise(rb_eSecurityError, "Insecure Object Connection - %s",
+ StringValuePtr(svr_name));
+ }
+
+ /* get CLSID from OLE server name */
+ pBuf = ole_mb2wc(StringValuePtr(svr_name), -1);
+ hr = CLSIDFromProgID(pBuf, &clsid);
+ if(FAILED(hr)) {
+ hr = CLSIDFromString(pBuf, &clsid);
+ }
+ SysFreeString(pBuf);
+ if(FAILED(hr)) {
+ return ole_bind_obj(svr_name, argc, argv, self);
+ }
+
+ hr = GetActiveObject(&clsid, 0, &pUnknown);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "OLE server `%s' not running", StringValuePtr(svr_name));
+ }
+ hr = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IDispatch,
+ (void **)&pDispatch);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pUnknown);
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Failed to create WIN32OLE server `%s'",
+ StringValuePtr(svr_name));
+ }
+
+ OLE_RELEASE(pUnknown);
+
+ return create_win32ole_object(self, pDispatch, argc, argv);
+}
+
+/*
+ * WIN32OLE.const_load( ole, mod = WIN32OLE)
+ * ----
+ * Defines the constants of OLE Automation server as mod's constants.
+ * If 2nd argument is omitted, the default is WIN32OLE.
+ */
+static VALUE
+fole_s_const_load(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE ole;
+ VALUE klass;
+ struct oledata *pole;
+ ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
+ unsigned int index;
+ HRESULT hr;
+ OLECHAR *pBuf;
+ VALUE file;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+
+ rb_secure(4);
+ rb_scan_args(argc, argv, "11", &ole, &klass);
+ if (TYPE(klass) != T_CLASS &&
+ TYPE(klass) != T_MODULE &&
+ TYPE(klass) != T_NIL) {
+ rb_raise(rb_eTypeError, "2nd paramator must be Class or Module.");
+ }
+ if (rb_obj_is_kind_of(ole, cWIN32OLE)) {
+ OLEData_Get_Struct(ole, pole);
+ hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
+ 0, lcid, &pTypeInfo);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "Failed to GetTypeInfo");
+ }
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError, "Failed to GetContainingTypeLib");
+ }
+ OLE_RELEASE(pTypeInfo);
+ if(TYPE(klass) != T_NIL) {
+ ole_const_load(pTypeLib, klass, self);
+ }
+ else {
+ ole_const_load(pTypeLib, cWIN32OLE, self);
+ }
+ OLE_RELEASE(pTypeLib);
+ }
+ else if(TYPE(ole) == T_STRING) {
+ file = typelib_file(ole);
+ if (file == Qnil) {
+ file = ole;
+ }
+ pBuf = ole_mb2wc(StringValuePtr(file), -1);
+ hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib);
+ SysFreeString(pBuf);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to LoadTypeLibEx");
+ if(TYPE(klass) != T_NIL) {
+ ole_const_load(pTypeLib, klass, self);
+ }
+ else {
+ ole_const_load(pTypeLib, cWIN32OLE, self);
+ }
+ OLE_RELEASE(pTypeLib);
+ }
+ else {
+ rb_raise(rb_eTypeError, "1st paramator must be WIN32OLE instance");
+ }
+ return Qnil;
+}
+
+static VALUE
+ole_classes_from_typelib(pTypeLib, classes)
+ ITypeLib *pTypeLib;
+ VALUE classes;
+{
+
+ long count;
+ int i;
+ HRESULT hr;
+ BSTR bstr;
+ ITypeInfo *pTypeInfo;
+ VALUE type;
+
+ rb_secure(4);
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count; i++) {
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
+ if (FAILED(hr))
+ continue;
+
+ type = foletype_s_allocate(cWIN32OLE_TYPE);
+ oletype_set_member(type, pTypeInfo, WC2VSTR(bstr));
+
+ rb_ary_push(classes, type);
+ OLE_RELEASE(pTypeInfo);
+ }
+ return classes;
+}
+
+static ULONG
+reference_count(pole)
+ struct oledata * pole;
+{
+ ULONG n = 0;
+ if(pole->pDispatch) {
+ OLE_ADDREF(pole->pDispatch);
+ n = OLE_RELEASE(pole->pDispatch);
+ }
+ return n;
+}
+
+/*
+ * WIN32OLE.ole_reference_count(aWIN32OLE) --> number
+ * ----
+ * Returns reference counter of Dispatch interface of WIN32OLE object.
+ * You should not use this method because this method
+ * exists only for debugging WIN32OLE.
+ */
+static VALUE
+fole_s_reference_count(self, obj)
+ VALUE self;
+ VALUE obj;
+{
+ struct oledata * pole;
+ OLEData_Get_Struct(obj, pole);
+ return INT2NUM(reference_count(pole));
+}
+
+/*
+ * WIN32OLE.ole_free(aWIN32OLE) --> number
+ * ----
+ * Invokes Release method of Dispatch interface of WIN32OLE object.
+ * You should not use this method because this method
+ * exists only for debugging WIN32OLE.
+ * The return value is reference counter of OLE object.
+ */
+static VALUE
+fole_s_free(self, obj)
+ VALUE self;
+ VALUE obj;
+{
+ ULONG n = 0;
+ struct oledata * pole;
+ OLEData_Get_Struct(obj, pole);
+ if(pole->pDispatch) {
+ if (reference_count(pole) > 0) {
+ n = OLE_RELEASE(pole->pDispatch);
+ }
+ }
+ return INT2NUM(n);
+}
+
+static HWND
+ole_show_help(helpfile, helpcontext)
+ VALUE helpfile;
+ VALUE helpcontext;
+{
+ FNHTMLHELP *pfnHtmlHelp;
+ HWND hwnd = 0;
+
+ if(!ghhctrl)
+ ghhctrl = LoadLibrary("HHCTRL.OCX");
+ if (!ghhctrl)
+ return hwnd;
+ pfnHtmlHelp = (FNHTMLHELP*)GetProcAddress(ghhctrl, "HtmlHelpA");
+ if (!pfnHtmlHelp)
+ return hwnd;
+ hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile),
+ 0x0f, NUM2INT(helpcontext));
+ if (hwnd == 0)
+ hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile),
+ 0, NUM2INT(helpcontext));
+ return hwnd;
+}
+
+/*
+ * WIN32OLE.ole_show_help(obj [,helpcontext])
+ * ----
+ * Displays helpfile. The 1st argument specifies WIN32OLE_TYPE
+ * object or WIN32OLE_METHOD object or helpfile.
+ */
+static VALUE
+fole_s_show_help(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE target;
+ VALUE helpcontext;
+ VALUE helpfile;
+ VALUE name;
+ HWND hwnd;
+ rb_scan_args(argc, argv, "11", &target, &helpcontext);
+ if (rb_obj_is_kind_of(target, cWIN32OLE_TYPE) ||
+ rb_obj_is_kind_of(target, cWIN32OLE_METHOD)) {
+ helpfile = rb_funcall(target, rb_intern("helpfile"), 0);
+ if(strlen(StringValuePtr(helpfile)) == 0) {
+ name = rb_ivar_get(target, rb_intern("name"));
+ rb_raise(rb_eRuntimeError, "no helpfile of `%s'",
+ StringValuePtr(name));
+ }
+ helpcontext = rb_funcall(target, rb_intern("helpcontext"), 0);
+ } else {
+ helpfile = target;
+ }
+ if (TYPE(helpfile) != T_STRING) {
+ rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD).");
+ }
+ hwnd = ole_show_help(helpfile, helpcontext);
+ if(hwnd == 0) {
+ rb_raise(rb_eRuntimeError, "Failed to open help file `%s'",
+ StringValuePtr(helpfile));
+ }
+ return Qnil;
+}
+
+static VALUE
+fole_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE svr_name;
+ VALUE host;
+ VALUE others;
+ HRESULT hr;
+ CLSID clsid;
+ OLECHAR *pBuf;
+ IDispatch *pDispatch;
+
+ rb_secure(4);
+ rb_call_super(0, 0);
+ rb_scan_args(argc, argv, "11*", &svr_name, &host, &others);
+
+ if (ruby_safe_level > 0 && OBJ_TAINTED(svr_name)) {
+ rb_raise(rb_eSecurityError, "Insecure Object Creation - %s",
+ StringValuePtr(svr_name));
+ }
+ if (!NIL_P(host)) {
+ if (ruby_safe_level > 0 && OBJ_TAINTED(host)) {
+ rb_raise(rb_eSecurityError, "Insecure Object Creation - %s",
+ StringValuePtr(svr_name));
+ }
+ return ole_create_dcom(argc, argv, self);
+ }
+
+ /* get CLSID from OLE server name */
+ pBuf = ole_mb2wc(StringValuePtr(svr_name), -1);
+ hr = CLSIDFromProgID(pBuf, &clsid);
+ if(FAILED(hr)) {
+ hr = CLSIDFromString(pBuf, &clsid);
+ }
+ SysFreeString(pBuf);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Unknown OLE server: `%s'",
+ StringValuePtr(svr_name));
+ }
+
+ /* get IDispatch interface */
+ hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
+ &IID_IDispatch, (void**)&pDispatch);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Failed to create WIN32OLE object from `%s'",
+ StringValuePtr(svr_name));
+ }
+
+ ole_set_member(self, pDispatch);
+ return self;
+}
+
+static VALUE
+hash2named_arg(pair, pOp)
+ VALUE pair;
+ struct oleparam* pOp;
+{
+ unsigned int index, i;
+ VALUE key, value;
+ index = pOp->dp.cNamedArgs;
+
+ /*-------------------------------------
+ the data-type of key must be String
+ ---------------------------------------*/
+ key = rb_ary_entry(pair, 0);
+ if(TYPE(key) != T_STRING) {
+ /* clear name of dispatch parameters */
+ for(i = 1; i < index + 1; i++) {
+ SysFreeString(pOp->pNamedArgs[i]);
+ }
+ /* clear dispatch parameters */
+ for(i = 0; i < index; i++ ) {
+ VariantClear(&(pOp->dp.rgvarg[i]));
+ }
+ /* raise an exception */
+ Check_Type(key, T_STRING);
+ }
+
+ /* pNamedArgs[0] is <method name>, so "index + 1" */
+ pOp->pNamedArgs[index + 1] = ole_mb2wc(StringValuePtr(key), -1);
+
+ value = rb_ary_entry(pair, 1);
+ VariantInit(&(pOp->dp.rgvarg[index]));
+ ole_val2variant(value, &(pOp->dp.rgvarg[index]));
+
+ pOp->dp.cNamedArgs += 1;
+ return Qnil;
+}
+
+static VALUE
+set_argv(realargs, beg, end)
+ VARIANTARG* realargs;
+ unsigned int beg, end;
+{
+ VALUE argv = rb_const_get(cWIN32OLE, rb_intern("ARGV"));
+
+ Check_Type(argv, T_ARRAY);
+ rb_ary_clear(argv);
+ while (end-- > beg) {
+ rb_ary_push(argv, ole_variant2val(&realargs[end]));
+ VariantClear(&realargs[end]);
+ }
+ return argv;
+}
+
+static VALUE
+ole_invoke(argc, argv, self, wFlags)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+ USHORT wFlags;
+{
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+ struct oledata *pole;
+ HRESULT hr;
+ VALUE cmd;
+ VALUE paramS;
+ VALUE param;
+ VALUE obj;
+ VALUE v;
+
+ BSTR wcmdname;
+
+ DISPID DispID;
+ DISPID* pDispID;
+ EXCEPINFO excepinfo;
+ VARIANT result;
+ VARIANTARG* realargs = NULL;
+ unsigned int argErr = 0;
+ unsigned int i;
+ unsigned int cNamedArgs;
+ int n;
+ struct oleparam op;
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+
+ VariantInit(&result);
+
+ op.dp.rgvarg = NULL;
+ op.dp.rgdispidNamedArgs = NULL;
+ op.dp.cNamedArgs = 0;
+ op.dp.cArgs = 0;
+
+ rb_scan_args(argc, argv, "1*", &cmd, &paramS);
+ OLEData_Get_Struct(self, pole);
+ if(!pole->pDispatch) {
+ rb_raise(rb_eRuntimeError, "Failed to get dispatch interface");
+ }
+ wcmdname = ole_mb2wc(StringValuePtr(cmd), -1);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
+ &wcmdname, 1, lcid, &DispID);
+ SysFreeString(wcmdname);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Unknown property or method `%s'",
+ StringValuePtr(cmd));
+ }
+
+ /* pick up last argument of method */
+ param = rb_ary_entry(paramS, argc-2);
+
+ op.dp.cNamedArgs = 0;
+
+ /* if last arg is hash object */
+ if(TYPE(param) == T_HASH) {
+ /*------------------------------------------
+ hash object ==> named dispatch parameters
+ --------------------------------------------*/
+ cNamedArgs = NUM2INT(rb_funcall(param, rb_intern("length"), 0));
+ op.dp.cArgs = cNamedArgs + argc - 2;
+ op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
+ op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
+ rb_iterate(rb_each, param, hash2named_arg, (VALUE)&op);
+
+ pDispID = ALLOCA_N(DISPID, cNamedArgs + 1);
+ op.pNamedArgs[0] = ole_mb2wc(StringValuePtr(cmd), -1);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch,
+ &IID_NULL,
+ op.pNamedArgs,
+ op.dp.cNamedArgs + 1,
+ lcid, pDispID);
+ for(i = 0; i < op.dp.cNamedArgs + 1; i++) {
+ SysFreeString(op.pNamedArgs[i]);
+ op.pNamedArgs[i] = NULL;
+ }
+ if(FAILED(hr)) {
+ /* clear dispatch parameters */
+ for(i = 0; i < op.dp.cArgs; i++ ) {
+ VariantClear(&op.dp.rgvarg[i]);
+ }
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Failed to get named argument info: `%s'",
+ StringValuePtr(cmd));
+ }
+ op.dp.rgdispidNamedArgs = &(pDispID[1]);
+ }
+ else {
+ cNamedArgs = 0;
+ op.dp.cArgs = argc - 1;
+ op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
+ if (op.dp.cArgs > 0) {
+ op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
+ }
+ }
+ /*--------------------------------------
+ non hash args ==> dispatch parameters
+ ----------------------------------------*/
+ if(op.dp.cArgs > cNamedArgs) {
+ realargs = ALLOCA_N(VARIANTARG, op.dp.cArgs-cNamedArgs+1);
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ VariantInit(&realargs[n]);
+ VariantInit(&op.dp.rgvarg[n]);
+ param = rb_ary_entry(paramS, i-cNamedArgs);
+
+ ole_val2variant(param, &realargs[n]);
+ V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF;
+ V_VARIANTREF(&op.dp.rgvarg[n]) = &realargs[n];
+
+ }
+ }
+ /* apparent you need to call propput, you need this */
+ if (wFlags & DISPATCH_PROPERTYPUT) {
+ if (op.dp.cArgs == 0)
+ return ResultFromScode(E_INVALIDARG);
+
+ op.dp.cNamedArgs = 1;
+ op.dp.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
+ op.dp.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT;
+ }
+
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags, &op.dp,
+ &result, &excepinfo, &argErr);
+ if (FAILED(hr)) {
+ /* retry to call args by value */
+ if(op.dp.cArgs > cNamedArgs) {
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ param = rb_ary_entry(paramS, i-cNamedArgs);
+ ole_val2variant(param, &op.dp.rgvarg[n]);
+ }
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ VariantInit(&result);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags,
+ &op.dp, &result,
+ &excepinfo, &argErr);
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ VariantClear(&op.dp.rgvarg[n]);
+ }
+ }
+ /* mega kludge. if a method in WORD is called and we ask
+ * for a result when one is not returned then
+ * hResult == DISP_E_EXCEPTION. this only happens on
+ * functions whose DISPID > 0x8000 */
+ if (hr == DISP_E_EXCEPTION && DispID > 0x8000) {
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ VariantInit(&result);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags,
+ &op.dp, &result,
+ &excepinfo, &argErr);
+
+ }
+ }
+ /* clear dispatch parameter */
+ if(op.dp.cArgs > cNamedArgs) {
+ set_argv(realargs, cNamedArgs, op.dp.cArgs);
+ }
+ else {
+ for(i = 0; i < op.dp.cArgs; i++) {
+ VariantClear(&op.dp.rgvarg[i]);
+ }
+ }
+
+ if (FAILED(hr)) {
+ v = ole_excepinfo2msg(&excepinfo);
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "%s%s",
+ StringValuePtr(cmd), StringValuePtr(v));
+ }
+ obj = ole_variant2val(&result);
+ VariantClear(&result);
+ return obj;
+}
+
+static VALUE
+fole_invoke(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET);
+}
+
+static VALUE
+ole_invoke2(self, dispid, args, types, dispkind)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
+ USHORT dispkind;
+{
+ HRESULT hr;
+ struct oledata *pole;
+ unsigned int argErr = 0;
+ EXCEPINFO excepinfo;
+ VARIANT result;
+ DISPPARAMS dispParams;
+ VARIANTARG* realargs = NULL;
+ int i, j;
+ VALUE obj = Qnil;
+ VALUE tp, param;
+ VALUE v;
+ VARTYPE vt;
+
+ Check_Type(args, T_ARRAY);
+ Check_Type(types, T_ARRAY);
+
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ memset(&dispParams, 0, sizeof(DISPPARAMS));
+ VariantInit(&result);
+ OLEData_Get_Struct(self, pole);
+
+ dispParams.cArgs = RARRAY(args)->len;
+ dispParams.rgvarg = ALLOCA_N(VARIANTARG, dispParams.cArgs);
+ realargs = ALLOCA_N(VARIANTARG, dispParams.cArgs);
+ for (i = 0, j = dispParams.cArgs - 1; i < (int)dispParams.cArgs; i++, j--)
+ {
+ VariantInit(&realargs[i]);
+ VariantInit(&dispParams.rgvarg[i]);
+ tp = rb_ary_entry(types, j);
+ vt = (VARTYPE)FIX2INT(tp);
+ V_VT(&dispParams.rgvarg[i]) = vt;
+ param = rb_ary_entry(args, j);
+ if (param == Qnil)
+ {
+
+ V_VT(&dispParams.rgvarg[i]) = V_VT(&realargs[i]) = VT_ERROR;
+ V_ERROR(&dispParams.rgvarg[i]) = V_ERROR(&realargs[i]) = DISP_E_PARAMNOTFOUND;
+ }
+ else
+ {
+ if (vt & VT_ARRAY)
+ {
+ int ent;
+ LPBYTE pb;
+ short* ps;
+ LPLONG pl;
+ VARIANT* pv;
+ CY *py;
+ VARTYPE v;
+ SAFEARRAYBOUND rgsabound[1];
+ Check_Type(param, T_ARRAY);
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = RARRAY(param)->len;
+ v = vt & ~(VT_ARRAY | VT_BYREF);
+ V_ARRAY(&realargs[i]) = SafeArrayCreate(v, 1, rgsabound);
+ V_VT(&realargs[i]) = VT_ARRAY | v;
+ SafeArrayLock(V_ARRAY(&realargs[i]));
+ pb = V_ARRAY(&realargs[i])->pvData;
+ ps = V_ARRAY(&realargs[i])->pvData;
+ pl = V_ARRAY(&realargs[i])->pvData;
+ py = V_ARRAY(&realargs[i])->pvData;
+ pv = V_ARRAY(&realargs[i])->pvData;
+ for (ent = 0; ent < (int)rgsabound[0].cElements; ent++)
+ {
+ VARIANT velem;
+ VALUE elem = rb_ary_entry(param, ent);
+ ole_val2variant(elem, &velem);
+ if (v != VT_VARIANT)
+ {
+ VariantChangeTypeEx(&velem, &velem,
+ LOCALE_SYSTEM_DEFAULT, 0, v);
+ }
+ switch (v)
+ {
+ /* 128 bits */
+ case VT_VARIANT:
+ *pv++ = velem;
+ break;
+ /* 64 bits */
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ *py++ = V_CY(&velem);
+ break;
+ /* 16 bits */
+ case VT_BOOL:
+ case VT_I2:
+ case VT_UI2:
+ *ps++ = V_I2(&velem);
+ break;
+ /* 8 bites */
+ case VT_UI1:
+ case VT_I1:
+ *pb++ = V_UI1(&velem);
+ break;
+ /* 32 bits */
+ default:
+ *pl++ = V_I4(&velem);
+ break;
+ }
+ }
+ SafeArrayUnlock(V_ARRAY(&realargs[i]));
+ }
+ else
+ {
+ ole_val2variant(param, &realargs[i]);
+ if ((vt & (~VT_BYREF)) != VT_VARIANT)
+ {
+ hr = VariantChangeTypeEx(&realargs[i], &realargs[i],
+ LOCALE_SYSTEM_DEFAULT, 0,
+ (VARTYPE)(vt & (~VT_BYREF)));
+ if (hr != S_OK)
+ {
+ rb_raise(rb_eTypeError, "not valid value");
+ }
+ }
+ }
+ if ((vt & VT_BYREF) || vt == VT_VARIANT)
+ {
+ if (vt == VT_VARIANT)
+ V_VT(&dispParams.rgvarg[i]) = VT_VARIANT | VT_BYREF;
+ switch (vt & (~VT_BYREF))
+ {
+ /* 128 bits */
+ case VT_VARIANT:
+ V_VARIANTREF(&dispParams.rgvarg[i]) = &realargs[i];
+ break;
+ /* 64 bits */
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ V_CYREF(&dispParams.rgvarg[i]) = &V_CY(&realargs[i]);
+ break;
+ /* 16 bits */
+ case VT_BOOL:
+ case VT_I2:
+ case VT_UI2:
+ V_I2REF(&dispParams.rgvarg[i]) = &V_I2(&realargs[i]);
+ break;
+ /* 8 bites */
+ case VT_UI1:
+ case VT_I1:
+ V_UI1REF(&dispParams.rgvarg[i]) = &V_UI1(&realargs[i]);
+ break;
+ /* 32 bits */
+ default:
+ V_I4REF(&dispParams.rgvarg[i]) = &V_I4(&realargs[i]);
+ break;
+ }
+ }
+ else
+ {
+ /* copy 64 bits of data */
+ V_CY(&dispParams.rgvarg[i]) = V_CY(&realargs[i]);
+ }
+ }
+ }
+
+ if (dispkind & DISPATCH_PROPERTYPUT) {
+ dispParams.cNamedArgs = 1;
+ dispParams.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
+ dispParams.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT;
+ }
+
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, FIX2INT(dispid),
+ &IID_NULL, LOCALE_SYSTEM_DEFAULT,
+ dispkind,
+ &dispParams, &result,
+ &excepinfo, &argErr);
+
+ if (FAILED(hr)) {
+ v = ole_excepinfo2msg(&excepinfo);
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "_invoke %s",
+ StringValuePtr(v));
+ }
+
+ /* clear dispatch parameter */
+ if(dispParams.cArgs > 0) {
+ set_argv(realargs, 0, dispParams.cArgs);
+ }
+
+ obj = ole_variant2val(&result);
+ VariantClear(&result);
+ return obj;
+}
+
+/*
+ * WIN32OLE#_invoke(dispid, args, types)
+ * ----
+ * Runs the early binding method.
+ * The 1st argument specifies dispatch ID,
+ * the 2nd argument specifies the array of arguments,
+ * the 3rd argument specifies the array of the type of arguments.
+ */
+static VALUE
+fole_invoke2(self, dispid, args, types)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
+{
+ return ole_invoke2(self, dispid, args, types, DISPATCH_METHOD);
+}
+
+/*
+ * WIN32OLE#_getproperty(dispid, args, types)
+ * ----
+ * Runs the early binding method to get property.
+ * The 1st argument specifies dispatch ID,
+ * the 2nd argument specifies the array of arguments,
+ * the 3rd argument specifies the array of the type of arguments.
+ */
+static VALUE
+fole_getproperty2(self, dispid, args, types)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
+{
+ return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYGET);
+}
+
+/*
+ * WIN32OLE#_setproperty(dispid, args, types)
+ * ----
+ * Runs the early binding method to set property.
+ * The 1st argument specifies dispatch ID,
+ * the 2nd argument specifies the array of arguments,
+ * the 3rd argument specifies the array of the type of arguments.
+ */
+static VALUE
+fole_setproperty2(self, dispid, args, types)
+ VALUE self;
+ VALUE dispid;
+ VALUE args;
+ VALUE types;
+{
+ return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYPUT);
+}
+
+/*
+ * WIN32OLE['property']=val
+ *
+ * WIN32OLE.setproperty('property', [arg1, arg2,] val)
+ * -----
+ * Sets property of OLE object.
+ * When you want to set property with argument, you can use setproperty method.
+ */
+static VALUE
+fole_setproperty(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT);
+}
+
+/*
+ * WIN32OLE['property']
+ * -----
+ * Returns property of OLE object.
+ */
+static VALUE
+fole_getproperty(self, property)
+ VALUE self, property;
+{
+ return ole_invoke(1, &property, self, DISPATCH_PROPERTYGET);
+}
+
+static VALUE
+ole_propertyput(self, property, value)
+ VALUE self, property, value;
+{
+ struct oledata *pole;
+ unsigned argErr;
+ unsigned int index;
+ HRESULT hr;
+ EXCEPINFO excepinfo;
+ DISPID dispID = DISPID_VALUE;
+ DISPID dispIDParam = DISPID_PROPERTYPUT;
+ USHORT wFlags = DISPATCH_PROPERTYPUT;
+ DISPPARAMS dispParams;
+ VARIANTARG propertyValue[2];
+ OLECHAR* pBuf[1];
+ VALUE v;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+ dispParams.rgdispidNamedArgs = &dispIDParam;
+ dispParams.rgvarg = propertyValue;
+ dispParams.cNamedArgs = 1;
+ dispParams.cArgs = 1;
+
+ VariantInit(&propertyValue[0]);
+ VariantInit(&propertyValue[1]);
+ memset(&excepinfo, 0, sizeof(excepinfo));
+
+ OLEData_Get_Struct(self, pole);
+
+ /* get ID from property name */
+ pBuf[0] = ole_mb2wc(StringValuePtr(property), -1);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch, &IID_NULL,
+ pBuf, 1, lcid, &dispID);
+ SysFreeString(pBuf[0]);
+ pBuf[0] = NULL;
+
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR,
+ "Unknown property or method: `%s'",
+ StringValuePtr(property));
+ }
+ /* set property value */
+ ole_val2variant(value, &propertyValue[0]);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, dispID, &IID_NULL,
+ lcid, wFlags, &dispParams,
+ NULL, &excepinfo, &argErr);
+
+ for(index = 0; index < dispParams.cArgs; ++index) {
+ VariantClear(&propertyValue[index]);
+ }
+ if (FAILED(hr)) {
+ v = ole_excepinfo2msg(&excepinfo);
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, StringValuePtr(v));
+ }
+ return Qnil;
+}
+
+static VALUE
+fole_free(self)
+ VALUE self;
+{
+ struct oledata *pole;
+ rb_secure(4);
+ OLEData_Get_Struct(self, pole);
+ OLE_FREE(pole->pDispatch);
+ pole->pDispatch = NULL;
+ return Qnil;
+}
+
+static VALUE
+ole_each_sub(pEnumV)
+ VALUE pEnumV;
+{
+ VARIANT variant;
+ VALUE obj = Qnil;
+ IEnumVARIANT *pEnum = (IEnumVARIANT *)pEnumV;
+ VariantInit(&variant);
+ while(pEnum->lpVtbl->Next(pEnum, 1, &variant, NULL) == S_OK) {
+ obj = ole_variant2val(&variant);
+ VariantClear(&variant);
+ VariantInit(&variant);
+ rb_yield(obj);
+ }
+ return Qnil;
+}
+
+static VALUE
+ole_ienum_free(pEnumV)
+ VALUE pEnumV;
+{
+ IEnumVARIANT *pEnum = (IEnumVARIANT *)pEnumV;
+ OLE_RELEASE(pEnum);
+ return Qnil;
+}
+
+/*
+ * WIN32OLE#each {|i|...}
+ * -----
+ * Iterates over each item of OLE collection which has IEnumVARIANT interface.
+ */
+static VALUE
+fole_each(self)
+ VALUE self;
+{
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+
+ struct oledata *pole;
+
+ unsigned int argErr;
+ EXCEPINFO excepinfo;
+ DISPPARAMS dispParams;
+ VARIANT result;
+ HRESULT hr;
+ IEnumVARIANT *pEnum = NULL;
+
+ VariantInit(&result);
+ dispParams.rgvarg = NULL;
+ dispParams.rgdispidNamedArgs = NULL;
+ dispParams.cNamedArgs = 0;
+ dispParams.cArgs = 0;
+ memset(&excepinfo, 0, sizeof(excepinfo));
+
+ OLEData_Get_Struct(self, pole);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DISPID_NEWENUM,
+ &IID_NULL, lcid,
+ DISPATCH_METHOD | DISPATCH_PROPERTYGET,
+ &dispParams, &result,
+ &excepinfo, &argErr);
+
+ if (FAILED(hr)) {
+ VariantClear(&result);
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to get IEnum Interface");
+ }
+
+ if (V_VT(&result) == VT_UNKNOWN)
+ hr = V_UNKNOWN(&result)->lpVtbl->QueryInterface(V_UNKNOWN(&result),
+ &IID_IEnumVARIANT,
+ (void**)&pEnum);
+ else if (V_VT(&result) == VT_DISPATCH)
+ hr = V_DISPATCH(&result)->lpVtbl->QueryInterface(V_DISPATCH(&result),
+ &IID_IEnumVARIANT,
+ (void**)&pEnum);
+ if (FAILED(hr) || !pEnum) {
+ VariantClear(&result);
+ ole_raise(hr, rb_eRuntimeError, "Failed to get IEnum Interface");
+ }
+
+ VariantClear(&result);
+ rb_ensure(ole_each_sub, (VALUE)pEnum, ole_ienum_free, (VALUE)pEnum);
+ return Qnil;
+}
+
+/*
+ * WIN32OLE#method_missing(id [,arg1, arg2, ...])
+ * ----
+ * Calls WIN32OLE#invoke method.
+ */
+static VALUE
+fole_missing(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ ID id;
+ char* mname;
+ int n;
+ id = rb_to_id(argv[0]);
+ mname = rb_id2name(id);
+ if(!mname) {
+ rb_raise(rb_eRuntimeError, "Fail: unknown method or property");
+ }
+ n = strlen(mname);
+ if(mname[n-1] == '=') {
+ argv[0] = rb_str_new(mname, n-1);
+
+ return ole_propertyput(self, argv[0], argv[1]);
+ }
+ else {
+ argv[0] = rb_str_new2(mname);
+ return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET);
+ }
+}
+
+static VALUE
+ole_method_sub(self, pOwnerTypeInfo, pTypeInfo, name)
+ VALUE self;
+ ITypeInfo *pOwnerTypeInfo;
+ ITypeInfo *pTypeInfo;
+ VALUE name;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ BSTR bstr;
+ FUNCDESC *pFuncDesc;
+ WORD i;
+ VALUE fname;
+ VALUE method = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ }
+ for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) {
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ continue;
+ }
+ fname = WC2VSTR(bstr);
+ if (strcasecmp(StringValuePtr(name), StringValuePtr(fname)) == 0) {
+ olemethod_set_member(self, pTypeInfo, pOwnerTypeInfo, i, fname);
+ method = self;
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ pFuncDesc=NULL;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return method;
+}
+
+static VALUE
+olemethod_from_typeinfo(self, pTypeInfo, name)
+ VALUE self;
+ ITypeInfo *pTypeInfo;
+ VALUE name;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ WORD i;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ VALUE method = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ }
+ method = ole_method_sub(self, 0, pTypeInfo, name);
+ if (method != Qnil) {
+ return method;
+ }
+ for(i=0; i < pTypeAttr->cImplTypes && method == Qnil; i++){
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
+ if(FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ method = ole_method_sub(self, pTypeInfo, pRefTypeInfo, name);
+ OLE_RELEASE(pRefTypeInfo);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return method;
+}
+
+static VALUE
+ole_methods_sub(pOwnerTypeInfo, pTypeInfo, methods, mask)
+ ITypeInfo *pOwnerTypeInfo;
+ ITypeInfo *pTypeInfo;
+ VALUE methods;
+ int mask;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ BSTR bstr;
+ char *pstr;
+ FUNCDESC *pFuncDesc;
+ VALUE method;
+ WORD i;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ }
+ for(i = 0; i < pTypeAttr->cFuncs; i++) {
+ pstr = NULL;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ continue;
+ }
+ if(pFuncDesc->invkind & mask) {
+ method = folemethod_s_allocate(cWIN32OLE_METHOD);
+ olemethod_set_member(method, pTypeInfo, pOwnerTypeInfo,
+ i, WC2VSTR(bstr));
+ rb_ary_push(methods, method);
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ pFuncDesc=NULL;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+
+ return methods;
+}
+
+static VALUE
+ole_methods_from_typeinfo(pTypeInfo, mask)
+ ITypeInfo *pTypeInfo;
+ int mask;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ WORD i;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ VALUE methods = rb_ary_new();
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ }
+
+ ole_methods_sub(0, pTypeInfo, methods, mask);
+ for(i=0; i < pTypeAttr->cImplTypes; i++){
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
+ if(FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ ole_methods_sub(pTypeInfo, pRefTypeInfo, methods, mask);
+ OLE_RELEASE(pRefTypeInfo);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return methods;
+}
+
+static HRESULT
+typeinfo_from_ole(pole, ppti)
+ struct oledata *pole;
+ ITypeInfo **ppti;
+{
+ ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
+ BSTR bstr;
+ VALUE type;
+ UINT i;
+ UINT count;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+ HRESULT hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
+ 0, lcid, &pTypeInfo);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "Failed to GetTypeInfo");
+ }
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo,
+ -1,
+ &bstr,
+ NULL, NULL, NULL);
+ type = WC2VSTR(bstr);
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
+ OLE_RELEASE(pTypeInfo);
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "Failed to GetContainingTypeLib");
+ }
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count; i++) {
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ &bstr, NULL, NULL, NULL);
+ if (SUCCEEDED(hr) && rb_str_cmp(WC2VSTR(bstr), type) == 0) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
+ if (SUCCEEDED(hr)) {
+ *ppti = pTypeInfo;
+ break;
+ }
+ }
+ }
+ OLE_RELEASE(pTypeLib);
+ return hr;
+}
+
+static VALUE
+ole_methods(self,mask)
+ VALUE self;
+ int mask;
+{
+ ITypeInfo *pTypeInfo;
+ HRESULT hr;
+ VALUE methods;
+ struct oledata *pole;
+
+ OLEData_Get_Struct(self, pole);
+ methods = rb_ary_new();
+
+ hr = typeinfo_from_ole(pole, &pTypeInfo);
+ if(FAILED(hr))
+ return methods;
+ rb_ary_concat(methods, ole_methods_from_typeinfo(pTypeInfo, mask));
+ OLE_RELEASE(pTypeInfo);
+ return methods;
+}
+
+/*
+ * WIN32OLE#ole_methods
+ * ----
+ * Returns OLE methods
+ */
+static VALUE
+fole_methods( self )
+ VALUE self;
+{
+ return ole_methods( self, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT);
+}
+
+/*
+ * WIN32OLE#ole_get_methods
+ * ----
+ * Returns get properties.
+ */
+static VALUE
+fole_get_methods( self )
+ VALUE self;
+{
+ return ole_methods( self, INVOKE_PROPERTYGET);
+}
+
+/*
+ * WIN32OLE#ole_put_methods
+ * ----
+ * Returns put properties.
+ */
+static VALUE
+fole_put_methods( self )
+ VALUE self;
+{
+ return ole_methods( self, INVOKE_PROPERTYPUT);
+}
+
+/*
+ * WIN32OLE#ole_func_methods
+ * ---
+ * Returns OLE func methods.
+ */
+static VALUE
+fole_func_methods( self )
+ VALUE self;
+{
+ return ole_methods( self, INVOKE_FUNC);
+}
+
+/*
+ * WIN32OLE#ole_obj_help
+ * ----
+ * Returns WIN32OLE_TYPE object.
+ */
+static VALUE
+fole_obj_help( self )
+ VALUE self;
+{
+ unsigned int index;
+ ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
+ HRESULT hr;
+ struct oledata *pole;
+ BSTR bstr;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+ VALUE type = Qnil;
+
+ OLEData_Get_Struct(self, pole);
+
+ hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo );
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "Failed to GetTypeInfo");
+ }
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index );
+ if(FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError, "Failed to GetContainingTypeLib");
+ }
+ hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index,
+ &bstr, NULL, NULL, NULL);
+ if (SUCCEEDED(hr)) {
+ type = foletype_s_allocate(cWIN32OLE_TYPE);
+ oletype_set_member(type, pTypeInfo, WC2VSTR(bstr));
+ }
+ OLE_RELEASE(pTypeLib);
+ OLE_RELEASE(pTypeInfo);
+
+ return type;
+}
+
+static HRESULT
+ole_docinfo_from_type(pTypeInfo, name, helpstr, helpcontext, helpfile)
+ ITypeInfo *pTypeInfo;
+ BSTR *name;
+ BSTR *helpstr;
+ DWORD *helpcontext;
+ BSTR *helpfile;
+{
+ HRESULT hr;
+ ITypeLib *pTypeLib;
+ UINT i;
+
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ name, helpstr,
+ helpcontext, helpfile);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeLib);
+ return hr;
+ }
+ OLE_RELEASE(pTypeLib);
+ return hr;
+}
+
+static VALUE
+ole_usertype2val(pTypeInfo, pTypeDesc, typedetails)
+ ITypeInfo *pTypeInfo;
+ TYPEDESC *pTypeDesc;
+ VALUE typedetails;
+{
+ HRESULT hr;
+ BSTR bstr;
+ ITypeInfo *pRefTypeInfo;
+ VALUE type = Qnil;
+
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ V_UNION1(pTypeDesc, hreftype),
+ &pRefTypeInfo);
+ if(FAILED(hr))
+ return Qnil;
+ hr = ole_docinfo_from_type(pRefTypeInfo, &bstr, NULL, NULL, NULL);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pRefTypeInfo);
+ return Qnil;
+ }
+ OLE_RELEASE(pRefTypeInfo);
+ type = WC2VSTR(bstr);
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, type);
+ return type;
+}
+
+static VALUE ole_typedesc2val();
+static VALUE
+ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails)
+ ITypeInfo *pTypeInfo;
+ TYPEDESC *pTypeDesc;
+ VALUE typedetails;
+{
+ TYPEDESC *p = pTypeDesc;
+ VALUE type = rb_str_new2("");
+ while(p->vt == VT_PTR || p->vt == VT_SAFEARRAY) {
+ p = V_UNION1(p, lptdesc);
+ if(strlen(StringValuePtr(type)) == 0) {
+ type = ole_typedesc2val(pTypeInfo, p, typedetails);
+ } else {
+ rb_str_cat(type, ",", 1);
+ rb_str_concat(type, ole_typedesc2val(pTypeInfo, p, typedetails));
+ }
+ }
+ return type;
+}
+
+static VALUE
+ole_typedesc2val(pTypeInfo, pTypeDesc, typedetails)
+ ITypeInfo *pTypeInfo;
+ TYPEDESC *pTypeDesc;
+ VALUE typedetails;
+{
+ VALUE str;
+ switch(pTypeDesc->vt) {
+ case VT_I2:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I2"));
+ return rb_str_new2("I2");
+ case VT_I4:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I4"));
+ return rb_str_new2("I4");
+ case VT_R4:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("R4"));
+ return rb_str_new2("R4");
+ case VT_R8:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("R8"));
+ return rb_str_new2("R8");
+ case VT_CY:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("CY"));
+ return rb_str_new2("CY");
+ case VT_DATE:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("DATE"));
+ return rb_str_new2("DATE");
+ case VT_BSTR:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("BSTR"));
+ return rb_str_new2("BSTR");
+ case VT_BOOL:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("BOOL"));
+ return rb_str_new2("BOOL");
+ case VT_VARIANT:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("VARIANT"));
+ return rb_str_new2("VARIANT");
+ case VT_DECIMAL:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("DECIMAL"));
+ return rb_str_new2("DECIMAL");
+ case VT_I1:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I1"));
+ return rb_str_new2("I1");
+ case VT_UI1:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI1"));
+ return rb_str_new2("UI1");
+ case VT_UI2:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI2"));
+ return rb_str_new2("UI2");
+ case VT_UI4:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI4"));
+ return rb_str_new2("UI4");
+ case VT_I8:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("I8"));
+ return rb_str_new2("I8");
+ case VT_UI8:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UI8"));
+ return rb_str_new2("UI8");
+ case VT_INT:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("INT"));
+ return rb_str_new2("INT");
+ case VT_UINT:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("UINT"));
+ return rb_str_new2("UINT");
+ case VT_VOID:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("VOID"));
+ return rb_str_new2("VOID");
+ case VT_HRESULT:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("HRESULT"));
+ return rb_str_new2("HRESULT");
+ case VT_PTR:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("PTR"));
+ return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
+ case VT_SAFEARRAY:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("SAFEARRAY"));
+ return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
+ case VT_CARRAY:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("CARRAY"));
+ return rb_str_new2("CARRAY");
+ case VT_USERDEFINED:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("USERDEFINED"));
+ str = ole_usertype2val(pTypeInfo, pTypeDesc, typedetails);
+ if (str != Qnil) {
+ return str;
+ }
+ return rb_str_new2("USERDEFINED");
+ case VT_UNKNOWN:
+ return rb_str_new2("UNKNOWN");
+ case VT_DISPATCH:
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, rb_str_new2("DISPATCH"));
+ return rb_str_new2("DISPATCH");
+ default:
+ str = rb_str_new2("Unknown Type ");
+ rb_str_concat(str, rb_fix2str(INT2FIX(pTypeDesc->vt), 10));
+ return str;
+ }
+}
+
+/*
+ * WIN32OLE#ole_method_help(method)
+ * -----
+ * Returns WIN32OLE_METHOD object corresponding with method
+ * specified by 1st argument.
+ */
+static VALUE
+fole_method_help( self, cmdname )
+ VALUE self;
+ VALUE cmdname;
+{
+ ITypeInfo *pTypeInfo;
+ HRESULT hr;
+ struct oledata *pole;
+ VALUE method, obj;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+
+ Check_SafeStr(cmdname);
+ OLEData_Get_Struct(self, pole);
+ hr = typeinfo_from_ole(pole, &pTypeInfo);
+ if(FAILED(hr))
+ ole_raise(hr, rb_eRuntimeError, "Failed to get ITypeInfo");
+ method = folemethod_s_allocate(cWIN32OLE_METHOD);
+ obj = olemethod_from_typeinfo(method, pTypeInfo, cmdname);
+ OLE_RELEASE(pTypeInfo);
+ if (obj == Qnil)
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found %s",
+ StringValuePtr(cmdname));
+ return obj;
+}
+
+/*
+ * WIN32OLE.ole_classes(typelibrary)
+ * ----
+ * Returns array of WIN32OLE_TYPE objects defined by type library.
+ */
+static VALUE
+foletype_s_ole_classes(self, typelib)
+ VALUE self;
+ VALUE typelib;
+{
+ VALUE file, classes;
+ OLECHAR * pbuf;
+ ITypeLib *pTypeLib;
+ HRESULT hr;
+
+ rb_secure(4);
+ classes = rb_ary_new();
+ if(TYPE(typelib) == T_STRING) {
+ file = typelib_file(typelib);
+ if (file == Qnil) {
+ file = typelib;
+ }
+ pbuf = ole_mb2wc(StringValuePtr(file), -1);
+ hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to LoadTypeLibEx");
+ SysFreeString(pbuf);
+ ole_classes_from_typelib(pTypeLib, classes);
+ OLE_RELEASE(pTypeLib);
+ } else {
+ rb_raise(rb_eTypeError, "1st argument should be TypeLib string");
+ }
+ return classes;
+}
+
+/*
+ * WIN32OLE_TYPE.typelibs
+ * ----
+ * Returns array of type libraries.
+ */
+static VALUE
+foletype_s_typelibs(self)
+ VALUE self;
+{
+ HKEY htypelib, hclsid;
+ double fversion;
+ DWORD i, j;
+ LONG err;
+ VALUE clsid;
+ VALUE ver;
+ VALUE v = Qnil;
+ VALUE typelibs = rb_ary_new();
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
+ if(err != ERROR_SUCCESS) {
+ return typelibs;
+ }
+ for(i = 0; ; i++) {
+ clsid = reg_enum_key(htypelib, i);
+ if (clsid == Qnil)
+ break;
+ err = reg_open_vkey(htypelib, clsid, &hclsid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ fversion = 0;
+ for(j = 0; ; j++) {
+ ver = reg_enum_key(hclsid, j);
+ if (ver == Qnil)
+ break;
+ if (fversion > atof(StringValuePtr(ver)))
+ continue;
+ fversion = atof(StringValuePtr(ver));
+ if ( (v = reg_get_val(hclsid, StringValuePtr(ver))) != Qnil ) {
+ rb_ary_push(typelibs, v);
+ }
+ }
+ RegCloseKey(hclsid);
+ }
+ RegCloseKey(htypelib);
+ return typelibs;
+}
+
+/*
+ * WIN32OLE_TYPE.progids
+ * ---
+ * Returns array of ProgID.
+ */
+static VALUE
+foletype_s_progids(self)
+ VALUE self;
+{
+ HKEY hclsids, hclsid;
+ DWORD i;
+ LONG err;
+ VALUE clsid;
+ VALUE v = rb_str_new2("");
+ VALUE progids = rb_ary_new();
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hclsids);
+ if(err != ERROR_SUCCESS) {
+ return progids;
+ }
+ for(i = 0; ; i++) {
+ clsid = reg_enum_key(hclsids, i);
+ if (clsid == Qnil)
+ break;
+ err = reg_open_vkey(hclsids, clsid, &hclsid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ if ((v = reg_get_val(hclsid, "ProgID")) != Qnil)
+ rb_ary_push(progids, v);
+ if ((v = reg_get_val(hclsid, "VersionIndependentProgID")) != Qnil)
+ rb_ary_push(progids, v);
+ RegCloseKey(hclsid);
+ }
+ RegCloseKey(hclsids);
+ return progids;
+}
+
+static VALUE
+foletype_s_allocate(klass)
+ VALUE klass;
+{
+ struct oletypedata *poletype;
+ VALUE obj;
+ ole_initialize();
+ obj = Data_Make_Struct(klass,struct oletypedata,0,oletype_free,poletype);
+ poletype->pTypeInfo = NULL;
+ return obj;
+}
+
+static VALUE
+oletype_set_member(self, pTypeInfo, name)
+ VALUE self;
+ ITypeInfo *pTypeInfo;
+ VALUE name;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ rb_ivar_set(self, rb_intern("name"), name);
+ ptype->pTypeInfo = pTypeInfo;
+ if(pTypeInfo) OLE_ADDREF(pTypeInfo);
+ return self;
+}
+
+static VALUE
+oleclass_from_typelib(self, pTypeLib, oleclass)
+ VALUE self;
+ ITypeLib *pTypeLib;
+ VALUE oleclass;
+{
+
+ long count;
+ int i;
+ HRESULT hr;
+ BSTR bstr;
+ VALUE typelib;
+ ITypeInfo *pTypeInfo;
+
+ VALUE found = Qfalse;
+
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count && found == Qfalse; i++) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr))
+ continue;
+ typelib = WC2VSTR(bstr);
+ if (rb_str_cmp(oleclass, typelib) == 0) {
+ oletype_set_member(self, pTypeInfo, typelib);
+ found = Qtrue;
+ }
+ OLE_RELEASE(pTypeInfo);
+ }
+ return found;
+}
+
+static VALUE
+foletype_initialize(self, typelib, oleclass)
+ VALUE self;
+ VALUE typelib;
+ VALUE oleclass;
+{
+ VALUE file;
+ OLECHAR * pbuf;
+ ITypeLib *pTypeLib;
+ HRESULT hr;
+
+ Check_SafeStr(oleclass);
+ Check_SafeStr(typelib);
+ file = typelib_file(typelib);
+ if (file == Qnil) {
+ file = typelib;
+ }
+ pbuf = ole_mb2wc(StringValuePtr(file), -1);
+ hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to LoadTypeLibEx");
+ SysFreeString(pbuf);
+ if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) {
+ OLE_RELEASE(pTypeLib);
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found `%s` in `%s`",
+ StringValuePtr(oleclass), StringValuePtr(typelib));
+ }
+ OLE_RELEASE(pTypeLib);
+ return self;
+}
+
+/*
+ * WIN32OLE_TYPE#name
+ * ---
+ * Returns name.
+ */
+static VALUE
+foletype_name(self)
+ VALUE self;
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static VALUE
+ole_ole_type(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ VALUE type = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if(FAILED(hr)){
+ return type;
+ }
+ switch(pTypeAttr->typekind) {
+ case TKIND_ENUM:
+ type = rb_str_new2("Enum");
+ break;
+ case TKIND_RECORD:
+ type = rb_str_new2("Record");
+ break;
+ case TKIND_MODULE:
+ type = rb_str_new2("Module");
+ break;
+ case TKIND_INTERFACE:
+ type = rb_str_new2("Interface");
+ break;
+ case TKIND_DISPATCH:
+ type = rb_str_new2("Dispatch");
+ break;
+ case TKIND_COCLASS:
+ type = rb_str_new2("Class");
+ break;
+ case TKIND_ALIAS:
+ type = rb_str_new2("Alias");
+ break;
+ case TKIND_UNION:
+ type = rb_str_new2("Union");
+ break;
+ case TKIND_MAX:
+ type = rb_str_new2("Max");
+ break;
+ default:
+ type = Qnil;
+ break;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return type;
+}
+
+/*
+ * WIN32OLE_TYPE#ole_type
+ * ----
+ * returns type of class.
+ */
+static VALUE
+foletype_ole_type(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_ole_type(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_guid(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ int len;
+ OLECHAR bstr[80];
+ VALUE guid = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return guid;
+ len = StringFromGUID2(&pTypeAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
+ if (len > 3) {
+ guid = ole_wc2vstr(bstr, FALSE);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return guid;
+}
+
+/*
+ * WIN32OLE_TYPE#guid
+ * ----
+ * Returns GUID.
+ */
+static VALUE
+foletype_guid(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_guid(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_progid(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ OLECHAR *pbuf;
+ VALUE progid = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return progid;
+ hr = ProgIDFromCLSID(&pTypeAttr->guid, &pbuf);
+ if (SUCCEEDED(hr))
+ progid = WC2VSTR(pbuf);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return progid;
+}
+
+/*
+ * WIN32OLE_TYPE#progid
+ * ----
+ * Returns ProgID if it exists. If not found, then returns nil.
+ */
+static VALUE
+foletype_progid(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_progid(ptype->pTypeInfo);
+}
+
+
+static VALUE
+ole_type_visible(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ VALUE visible;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return Qtrue;
+ if (pTypeAttr->wTypeFlags & (TYPEFLAG_FHIDDEN | TYPEFLAG_FRESTRICTED)) {
+ visible = Qfalse;
+ } else {
+ visible = Qtrue;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return visible;
+}
+
+/*
+ * WIN32OLE_TYPE#visible
+ * ----
+ * returns true if the OLE class is public.
+ */
+static VALUE
+foletype_visible(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_visible(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_major_version(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ VALUE ver;
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ver = INT2FIX(pTypeAttr->wMajorVerNum);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return ver;
+}
+
+/*
+ * WIN32OLE_TYPE#major_version
+ * ----
+ * Returns major version.
+ */
+static VALUE
+foletype_major_version(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_major_version(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_minor_version(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ VALUE ver;
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ ver = INT2FIX(pTypeAttr->wMinorVerNum);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return ver;
+}
+
+/*
+ * WIN32OLE_TYPE#minor_version
+ * ----
+ * Returns minor version.
+ */
+static VALUE
+foletype_minor_version(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_minor_version(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_typekind(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ VALUE typekind;
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ typekind = INT2FIX(pTypeAttr->typekind);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return typekind;
+}
+
+/*
+ * WIN32OLE_TYPE#typekind
+ * ----
+ * Returns number which represents type.
+ */
+static VALUE
+foletype_typekind(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_typekind(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_helpstring(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ BSTR bhelpstr;
+ hr = ole_docinfo_from_type(pTypeInfo, NULL, &bhelpstr, NULL, NULL);
+ if(FAILED(hr)) {
+ return Qnil;
+ }
+ return WC2VSTR(bhelpstr);
+}
+
+/*
+ * WIN32OLE_TYPE#helpstring
+ * ---
+ * Returns help string.
+ */
+static VALUE
+foletype_helpstring(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_helpstring(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_src_type(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ VALUE alias = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return alias;
+ if(pTypeAttr->typekind != TKIND_ALIAS) {
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return alias;
+ }
+ alias = ole_typedesc2val(pTypeInfo, &(pTypeAttr->tdescAlias), Qnil);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return alias;
+}
+
+/*
+ * WIN32OLE_TYPE#src_type
+ * ----
+ * Returns source class when the OLE class is 'Alias'.
+ */
+static VALUE
+foletype_src_type(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_src_type(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_helpfile(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ BSTR bhelpfile;
+ hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL, NULL, &bhelpfile);
+ if(FAILED(hr)) {
+ return Qnil;
+ }
+ return WC2VSTR(bhelpfile);
+}
+
+/*
+ * WIN32OLE_TYPE#helpfile
+ * ----
+ * Returns helpfile
+ */
+static VALUE
+foletype_helpfile(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_helpfile(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_type_helpcontext(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ DWORD helpcontext;
+ hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL,
+ &helpcontext, NULL);
+ if(FAILED(hr))
+ return Qnil;
+ return INT2FIX(helpcontext);
+}
+
+/*
+ * WIN32OLE_TYPE#helpcontext
+ * ---
+ * Returns helpcontext.
+ */
+static VALUE
+foletype_helpcontext(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_type_helpcontext(ptype->pTypeInfo);
+}
+
+static VALUE
+ole_variables(pTypeInfo)
+ ITypeInfo *pTypeInfo;
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ WORD i;
+ UINT len;
+ BSTR bstr;
+ char *pstr;
+ VARDESC *pVarDesc;
+ struct olevariabledata *pvar;
+ VALUE var;
+ VALUE variables = rb_ary_new();
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetTypeAttr");
+ }
+
+ for(i = 0; i < pTypeAttr->cVars; i++) {
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, i, &pVarDesc);
+ if(FAILED(hr))
+ continue;
+ len = 0;
+ pstr = NULL;
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr,
+ 1, &len);
+ if(FAILED(hr) || len == 0 || !bstr)
+ continue;
+
+ var = Data_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata,
+ 0,olevariable_free,pvar);
+ pvar->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ pvar->index = i;
+ rb_ivar_set(var, rb_intern("name"), WC2VSTR(bstr));
+ rb_ary_push(variables, var);
+
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ pVarDesc = NULL;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return variables;
+}
+
+/*
+ * WIN32OLE_TYPE#variables
+ * ----
+ * Returns array of variables defined in OLE class.
+ */
+static VALUE
+foletype_variables(self)
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_variables(ptype->pTypeInfo);
+}
+
+/*
+ * WIN32OLE_TYPE#ole_methods
+ * ----
+ * Returns array of WIN32OLE_METHOD objects.
+ */
+static VALUE
+foletype_methods(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct oletypedata *ptype;
+ Data_Get_Struct(self, struct oletypedata, ptype);
+ return ole_methods_from_typeinfo(ptype->pTypeInfo, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
+}
+
+/*
+ * WIN32OLE_VARIABLE#name
+ * ---
+ * Returns the name.
+ */
+static VALUE
+folevariable_name(self)
+ VALUE self;
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static ole_variable_ole_type(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE type;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetVarDesc");
+ type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil);
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return type;
+}
+
+/*
+ * WIN32OLE_VARIABLE#ole_type
+ * ----
+ * Returns type.
+ */
+static VALUE
+folevariable_ole_type(self)
+ VALUE self;
+{
+ struct olevariabledata *pvar;
+ Data_Get_Struct(self, struct olevariabledata, pvar);
+ return ole_variable_ole_type(pvar->pTypeInfo, pvar->index);
+}
+
+static ole_variable_ole_type_detail(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE type = rb_ary_new();
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetVarDesc");
+ ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type);
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return type;
+}
+
+/*
+ * WIN32OLE_VARIABLE#ole_type_detail
+ * ---
+ * Returns detail information of type. The information is array of type.
+ */
+static VALUE
+folevariable_ole_type_detail(self)
+ VALUE self;
+{
+ struct olevariabledata *pvar;
+ Data_Get_Struct(self, struct olevariabledata, pvar);
+ return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index);
+}
+
+static ole_variable_value(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE val = Qnil;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return Qnil;
+ if(pVarDesc->varkind == VAR_CONST)
+ val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue));
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return val;
+}
+
+/*
+ * WIN32OLE_VARIABLE#value
+ * ----
+ * Returns value if value is exists. If the value does not exist,
+ * this method returns nil.
+ */
+static VALUE
+folevariable_value(self)
+ VALUE self;
+{
+ struct olevariabledata *pvar;
+ Data_Get_Struct(self, struct olevariabledata, pvar);
+ return ole_variable_value(pvar->pTypeInfo, pvar->index);
+}
+
+static ole_variable_visible(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE visible = Qfalse;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return visible;
+ if (!(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN |
+ VARFLAG_FRESTRICTED |
+ VARFLAG_FNONBROWSABLE))) {
+ visible = Qtrue;
+ }
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return visible;
+}
+
+/*
+ * WIN32OLE_VARIABLE#visible?
+ * ----
+ * Returns true if the variable is public.
+ */
+static VALUE
+folevariable_visible(self)
+ VALUE self;
+{
+ struct olevariabledata *pvar;
+ Data_Get_Struct(self, struct olevariabledata, pvar);
+ return ole_variable_visible(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+ole_variable_kind(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE kind = rb_str_new2("UNKNOWN");
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return kind;
+ switch(pVarDesc->varkind) {
+ case VAR_PERINSTANCE:
+ kind = rb_str_new2("PERINSTANCE");
+ break;
+ case VAR_STATIC:
+ kind = rb_str_new2("STATIC");
+ break;
+ case VAR_CONST:
+ kind = rb_str_new2("CONSTANT");
+ break;
+ case VAR_DISPATCH:
+ kind = rb_str_new2("DISPATCH");
+ break;
+ default:
+ break;
+ }
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return kind;
+}
+
+/*
+ * WIN32OLE_VARIABLE#variable_kind
+ * ----
+ * Returns variable kind string.
+ */
+static VALUE
+folevariable_variable_kind(self)
+ VALUE self;
+{
+ struct olevariabledata *pvar;
+ Data_Get_Struct(self, struct olevariabledata, pvar);
+ return ole_variable_kind(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+ole_variable_varkind(pTypeInfo, var_index)
+ ITypeInfo *pTypeInfo;
+ UINT var_index;
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE kind = Qnil;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return kind;
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ kind = INT2FIX(pVarDesc->varkind);
+ return kind;
+}
+
+/*
+ * WIN32OLE_VARIABLE#varkind
+ * ----
+ * Returns the number which represents variable kind.
+ */
+static VALUE
+folevariable_varkind(self)
+ VALUE self;
+{
+ struct olevariabledata *pvar;
+ Data_Get_Struct(self, struct olevariabledata, pvar);
+ return ole_variable_varkind(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+olemethod_set_member(self, pTypeInfo, pOwnerTypeInfo, index, name)
+ VALUE self;
+ ITypeInfo *pTypeInfo;
+ ITypeInfo *pOwnerTypeInfo;
+ int index;
+ VALUE name;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ pmethod->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ pmethod->pOwnerTypeInfo = pOwnerTypeInfo;
+ if(pOwnerTypeInfo) OLE_ADDREF(pOwnerTypeInfo);
+ pmethod->index = index;
+ rb_ivar_set(self, rb_intern("name"), name);
+ return self;
+}
+
+static VALUE
+folemethod_s_allocate(klass)
+ VALUE klass;
+{
+ struct olemethoddata *pmethod;
+ VALUE obj;
+ obj = Data_Make_Struct(klass,
+ struct olemethoddata,
+ 0, olemethod_free, pmethod);
+ pmethod->pTypeInfo = NULL;
+ pmethod->pOwnerTypeInfo = NULL;
+ pmethod->index = 0;
+ return obj;
+}
+
+static VALUE
+folemethod_initialize(self, oletype, method)
+ VALUE self;
+ VALUE oletype;
+ VALUE method;
+{
+ struct oletypedata *ptype;
+ VALUE obj = Qnil;
+ if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) {
+ Check_SafeStr(method);
+ Data_Get_Struct(oletype, struct oletypedata, ptype);
+ obj = olemethod_from_typeinfo(self, ptype->pTypeInfo, method);
+ if (obj == Qnil) {
+ rb_raise(eWIN32OLE_RUNTIME_ERROR, "Not found %s",
+ StringValuePtr(method));
+ }
+ }
+ else {
+ rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object.");
+ }
+ return obj;
+}
+
+/*
+ * WIN32OLE_METHOD#name
+ * ----
+ * Returns the name of the method.
+ */
+static VALUE
+folemethod_name(self)
+ VALUE self;
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static VALUE
+ole_method_return_type(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE type;
+
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetFuncDesc");
+
+ type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return type;
+}
+
+/*
+ * WIN32OLE_METHOD#return_type
+ * ----
+ * Returns string of return value type of method.
+ */
+static VALUE
+folemethod_return_type(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_return_type(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_return_vtype(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE vt;
+
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetFuncDesc");
+
+ vt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return vt;
+}
+
+/*
+ * WIN32OLE_METHOD#return_vtype
+ * ----
+ * Returns number of return value type of method.
+ */
+static VALUE
+folemethod_return_vtype(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_return_vtype(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_return_type_detail(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE type = rb_ary_new();
+
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return type;
+
+ ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), type);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return type;
+}
+
+/*
+ * WIN32OLE_METHOD#return_type_detail
+ * -----
+ * Returns detail information of return value type of method.
+ * The information is array.
+ */
+static VALUE
+folemethod_return_type_detail(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_return_type_detail(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_invkind(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE invkind;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if(FAILED(hr))
+ ole_raise(hr, eWIN32OLE_RUNTIME_ERROR, "Failed to GetFuncDesc");
+ invkind = INT2FIX(pFuncDesc->invkind);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return invkind;
+}
+
+static VALUE
+ole_method_invoke_kind(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ WORD method_index;
+{
+ VALUE type = rb_str_new2("UNKNOWN");
+ VALUE invkind = ole_method_invkind(pTypeInfo, method_index);
+ if((FIX2INT(invkind) & INVOKE_PROPERTYGET) &&
+ (FIX2INT(invkind) & INVOKE_PROPERTYPUT) ) {
+ type = rb_str_new2("PROPERTY");
+ } else if(FIX2INT(invkind) & INVOKE_PROPERTYGET) {
+ type = rb_str_new2("PROPERTYGET");
+ } else if(FIX2INT(invkind) & INVOKE_PROPERTYPUT) {
+ type = rb_str_new2("PROPERTYPUT");
+ } else if(FIX2INT(invkind) & INVOKE_PROPERTYPUTREF) {
+ type = rb_str_new2("PROPERTYPUTREF");
+ } else if(FIX2INT(invkind) & INVOKE_FUNC) {
+ type = rb_str_new2("FUNC");
+ }
+ return type;
+}
+
+/*
+ * WIN32OLE_MTHOD#invkind
+ * ----
+ * Returns invkind.
+ */
+static VALUE
+folemethod_invkind(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_invkind(pmethod->pTypeInfo, pmethod->index);
+}
+
+/*
+ * WIN32OLE_METHOD#invoke_kind
+ * ----
+ * Returns invoke kind string.
+ */
+static VALUE
+folemethod_invoke_kind(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_invoke_kind(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_visible(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE visible;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if(FAILED(hr))
+ return Qfalse;
+ if (pFuncDesc->wFuncFlags & (FUNCFLAG_FRESTRICTED |
+ FUNCFLAG_FHIDDEN |
+ FUNCFLAG_FNONBROWSABLE)) {
+ visible = Qfalse;
+ } else {
+ visible = Qtrue;
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return visible;
+}
+
+/*
+ * WIN32OLE_METHOD#visible?
+ * ----
+ * Returns true if the method is public.
+ */
+static VALUE
+folemethod_visible(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_visible(pmethod->pTypeInfo, pmethod->index);
+}
+
+static ole_method_event(pTypeInfo, method_index, method_name)
+ ITypeInfo *pTypeInfo;
+ WORD method_index;
+ VALUE method_name;
+{
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ WORD i;
+ int flags;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ FUNCDESC *pFuncDesc;
+ BSTR bstr;
+ VALUE name;
+ VALUE event = Qfalse;
+
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return event;
+ if(pTypeAttr->typekind != TKIND_COCLASS) {
+ pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
+ return event;
+ }
+ for (i = 0; i < pTypeAttr->cImplTypes; i++) {
+ hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
+ if (FAILED(hr))
+ continue;
+
+ if (flags & IMPLTYPEFLAG_FSOURCE) {
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
+ i, &href);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ hr = pRefTypeInfo->lpVtbl->GetFuncDesc(pRefTypeInfo, method_index,
+ &pFuncDesc);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pRefTypeInfo);
+ continue;
+ }
+
+ hr = pRefTypeInfo->lpVtbl->GetDocumentation(pRefTypeInfo,
+ pFuncDesc->memid,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
+ OLE_RELEASE(pRefTypeInfo);
+ continue;
+ }
+
+ name = WC2VSTR(bstr);
+ pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
+ OLE_RELEASE(pRefTypeInfo);
+ if (rb_str_cmp(method_name, name) == 0) {
+ event = Qtrue;
+ break;
+ }
+ }
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return event;
+}
+
+/*
+ * WIN32OLE_METHOD#event?
+ * ----
+ * Returns true if the method is event.
+ */
+static VALUE
+folemethod_event(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ if (!pmethod->pOwnerTypeInfo)
+ return Qfalse;
+ return ole_method_event(pmethod->pOwnerTypeInfo,
+ pmethod->index,
+ rb_ivar_get(self, rb_intern("name")));
+}
+
+static VALUE
+folemethod_event_interface(self)
+ VALUE self;
+{
+ BSTR name;
+ struct olemethoddata *pmethod;
+ HRESULT hr;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ if(folemethod_event(self) == Qtrue) {
+ hr = ole_docinfo_from_type(pmethod->pTypeInfo, &name, NULL, NULL, NULL);
+ if(SUCCEEDED(hr))
+ return WC2VSTR(name);
+ }
+ return Qnil;
+}
+
+static VALUE
+ole_method_docinfo_from_type(pTypeInfo, method_index, name, helpstr,
+ helpcontext, helpfile)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ BSTR *name;
+ BSTR *helpstr;
+ DWORD *helpcontext;
+ BSTR *helpfile;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return hr;
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
+ name, helpstr,
+ helpcontext, helpfile);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return hr;
+}
+
+static VALUE
+ole_method_helpstring(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ HRESULT hr;
+ BSTR bhelpstring;
+ hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, &bhelpstring,
+ NULL, NULL);
+ if (FAILED(hr))
+ return Qnil;
+ return WC2VSTR(bhelpstring);
+}
+
+static VALUE
+folemethod_helpstring(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_helpstring(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_helpfile(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ HRESULT hr;
+ BSTR bhelpfile;
+ hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL,
+ NULL, &bhelpfile);
+ if (FAILED(hr))
+ return Qnil;
+ return WC2VSTR(bhelpfile);
+}
+
+/*
+ * WIN32OLE_METHOD#helpfile
+ * ---
+ * Returns help file.
+ */
+static VALUE
+folemethod_helpfile(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+
+ return ole_method_helpfile(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_helpcontext(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ HRESULT hr;
+ DWORD helpcontext = 0;
+ hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL,
+ &helpcontext, NULL);
+ if (FAILED(hr))
+ return Qnil;
+ return INT2FIX(helpcontext);
+}
+
+/*
+ * WIN32OLE_METHOD#helpcontext
+ * -----
+ * Returns help context.
+ */
+static VALUE
+folemethod_helpcontext(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_helpcontext(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_dispid(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE dispid = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return dispid;
+ dispid = INT2FIX(pFuncDesc->memid);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return dispid;
+}
+
+/*
+ * WIN32OLE_METHOD#dispid
+ * ----
+ * Returns dispatch ID.
+ */
+static VALUE
+folemethod_dispid(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_dispid(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_offset_vtbl(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE offset_vtbl = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return offset_vtbl;
+ offset_vtbl = INT2FIX(pFuncDesc->oVft);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return offset_vtbl;
+}
+
+/*
+ * WIN32OLE_METHOD#offset_vtbl
+ * ----
+ * Returns the offset ov VTBL.
+ */
+static VALUE
+folemethod_offset_vtbl(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_offset_vtbl(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_size_params(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE size_params = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return size_params;
+ size_params = INT2FIX(pFuncDesc->cParams);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return size_params;
+}
+
+/*
+ * WIN32OLE_METHOD#size_params
+ * ----
+ * Returns the size of arguments.
+ */
+static VALUE
+folemethod_size_params(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_size_params(pmethod->pTypeInfo, pmethod->index);
+}
+
+/*
+ * WIN32OLE_METHOD#size_opt_params
+ * ----
+ * Returns the size of optional parameters.
+ */
+static VALUE
+ole_method_size_opt_params(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE size_opt_params = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return size_opt_params;
+ size_opt_params = INT2FIX(pFuncDesc->cParamsOpt);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return size_opt_params;
+}
+
+static VALUE
+folemethod_size_opt_params(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_size_opt_params(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_params(pTypeInfo, method_index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ BSTR *bstrs;
+ UINT len, i;
+ struct oleparamdata *pparam;
+ VALUE param;
+ VALUE params = rb_ary_new();
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return params;
+
+ len = 0;
+ bstrs = ALLOCA_N(BSTR, pFuncDesc->cParams + 1);
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pFuncDesc->memid,
+ bstrs, pFuncDesc->cParams + 1,
+ &len);
+ if (FAILED(hr)) {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return params;
+ }
+ SysFreeString(bstrs[0]);
+ if (pFuncDesc->cParams > 0) {
+ for(i = 1; i < len; i++) {
+ param = Data_Make_Struct(cWIN32OLE_PARAM, struct oleparamdata, 0,
+ oleparam_free, pparam);
+ pparam->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ pparam->method_index = method_index;
+ pparam->index = i - 1;
+ rb_ivar_set(param, rb_intern("name"), WC2VSTR(bstrs[i]));
+ rb_ary_push(params, param);
+ }
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return params;
+}
+
+/*
+ * WIN32OLE_METHOD#params
+ * ----
+ * returns array of WIN32OLE_PARAM object corresponding with method parameters.
+ */
+static VALUE
+folemethod_params(self)
+ VALUE self;
+{
+ struct olemethoddata *pmethod;
+ Data_Get_Struct(self, struct olemethoddata, pmethod);
+ return ole_method_params(pmethod->pTypeInfo, pmethod->index);
+}
+
+/*
+ * WIN32OLE_PARAM#name
+ * ----
+ * Returns name.
+ */
+static VALUE
+foleparam_name(self)
+ VALUE self;
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static VALUE
+ole_param_ole_type(pTypeInfo, method_index, index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE type = rb_str_new2("UNKNOWN");
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return type;
+ type = ole_typedesc2val(pTypeInfo,
+ &(pFuncDesc->lprgelemdescParam[index].tdesc), Qnil);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return type;
+}
+
+static VALUE
+foleparam_ole_type(self)
+ VALUE self;
+{
+ struct oleparamdata *pparam;
+ Data_Get_Struct(self, struct oleparamdata, pparam);
+ return ole_param_ole_type(pparam->pTypeInfo, pparam->method_index,
+ pparam->index);
+}
+
+static VALUE
+ole_param_ole_type_detail(pTypeInfo, method_index, index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE typedetail = rb_ary_new();
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return typedetail;
+ ole_typedesc2val(pTypeInfo,
+ &(pFuncDesc->lprgelemdescParam[index].tdesc), typedetail);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return typedetail;
+}
+
+static VALUE
+foleparam_ole_type_detail(self)
+ VALUE self;
+{
+ struct oleparamdata *pparam;
+ Data_Get_Struct(self, struct oleparamdata, pparam);
+ return ole_param_ole_type_detail(pparam->pTypeInfo, pparam->method_index,
+ pparam->index);
+}
+
+static VALUE
+ole_param_flag_mask(pTypeInfo, method_index, index, mask)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
+ USHORT mask;
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE ret = Qfalse;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if(FAILED(hr))
+ return ret;
+ if (V_UNION1((&(pFuncDesc->lprgelemdescParam[index])), paramdesc).wParamFlags &mask)
+ ret = Qtrue;
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return ret;
+}
+
+/*
+ * WIN32OLE_PARAM#input?
+ * ----
+ * Returns true if the parameter is input.
+ */
+static VALUE foleparam_input(self)
+ VALUE self;
+{
+ struct oleparamdata *pparam;
+ Data_Get_Struct(self, struct oleparamdata, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FIN);
+}
+
+/*
+ * WIN32OLE#output?
+ * ----
+ * Returns true if argument is output.
+ */
+static VALUE foleparam_output(self)
+ VALUE self;
+{
+ struct oleparamdata *pparam;
+ Data_Get_Struct(self, struct oleparamdata, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FOUT);
+}
+
+/*
+ * WIN32OLE_PARAM#optional?
+ * -----
+ * Returns true if argument is output.
+ */
+static VALUE foleparam_optional(self)
+ VALUE self;
+{
+ struct oleparamdata *pparam;
+ Data_Get_Struct(self, struct oleparamdata, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FOPT);
+}
+
+static VALUE foleparam_retval(self)
+ VALUE self;
+{
+ struct oleparamdata *pparam;
+ Data_Get_Struct(self, struct oleparamdata, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FRETVAL);
+}
+
+static VALUE
+ole_param_default(pTypeInfo, method_index, index)
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
+{
+ FUNCDESC *pFuncDesc;
+ ELEMDESC *pElemDesc;
+ PARAMDESCEX * pParamDescEx;
+ HRESULT hr;
+ USHORT wParamFlags;
+ USHORT mask = PARAMFLAG_FOPT|PARAMFLAG_FHASDEFAULT;
+ VALUE defval = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return defval;
+ pElemDesc = &pFuncDesc->lprgelemdescParam[index];
+ wParamFlags = V_UNION1(pElemDesc, paramdesc).wParamFlags;
+ if ((wParamFlags & mask) == mask) {
+ pParamDescEx = V_UNION1(pElemDesc, paramdesc).pparamdescex;
+ defval = ole_variant2val(&pParamDescEx->varDefaultValue);
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return defval;
+}
+
+/*
+ * WIN32OLE_PARAM#default
+ * ----
+ * Returns default value. If the default value does not exist,
+ * this method returns nil.
+ */
+static VALUE foleparam_default(self)
+ VALUE self;
+{
+ struct oleparamdata *pparam;
+ Data_Get_Struct(self, struct oleparamdata, pparam);
+ return ole_param_default(pparam->pTypeInfo, pparam->method_index,
+ pparam->index);
+}
+
+static IEventSinkVtbl vtEventSink;
+static BOOL g_IsEventSinkVtblInitialized = FALSE;
+
+void EVENTSINK_Destructor(PIEVENTSINKOBJ);
+
+STDMETHODIMP
+EVENTSINK_QueryInterface(
+ PEVENTSINK pEV,
+ REFIID iid,
+ LPVOID* ppv
+ ) {
+ if (IsEqualIID(iid, &IID_IUnknown) ||
+ IsEqualIID(iid, &IID_IDispatch) ||
+ IsEqualIID(iid, &((PIEVENTSINKOBJ)pEV)->m_iid)) {
+ *ppv = pEV;
+ }
+ else {
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+ ((LPUNKNOWN)*ppv)->lpVtbl->AddRef((LPUNKNOWN)*ppv);
+ return NOERROR;
+}
+
+STDMETHODIMP_(ULONG)
+EVENTSINK_AddRef(
+ PEVENTSINK pEV
+ ){
+ PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
+ return ++pEVObj->m_cRef;
+}
+
+STDMETHODIMP_(ULONG) EVENTSINK_Release(
+ PEVENTSINK pEV
+ ) {
+ PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
+ --pEVObj->m_cRef;
+ if(pEVObj->m_cRef != 0)
+ return pEVObj->m_cRef;
+ EVENTSINK_Destructor(pEVObj);
+ return 0;
+}
+
+STDMETHODIMP EVENTSINK_GetTypeInfoCount(
+ PEVENTSINK pEV,
+ UINT *pct
+ ) {
+ *pct = 0;
+ return NOERROR;
+}
+
+STDMETHODIMP EVENTSINK_GetTypeInfo(
+ PEVENTSINK pEV,
+ UINT info,
+ LCID lcid,
+ ITypeInfo **pInfo
+ ) {
+ *pInfo = NULL;
+ return DISP_E_BADINDEX;
+}
+
+STDMETHODIMP EVENTSINK_GetIDsOfNames(
+ PEVENTSINK pEV,
+ REFIID riid,
+ OLECHAR **szNames,
+ UINT cNames,
+ LCID lcid,
+ DISPID *pDispID
+ ) {
+ return DISP_E_UNKNOWNNAME;
+}
+
+static VALUE
+ole_search_event(ary, ev, is_default)
+ VALUE ary;
+ VALUE ev;
+ BOOL *is_default;
+{
+ VALUE event;
+ VALUE def_event;
+ VALUE event_name;
+ int i, len;
+ *is_default = FALSE;
+ def_event = Qnil;
+ len = RARRAY(ary)->len;
+ for(i = 0; i < len; i++) {
+ event = rb_ary_entry(ary, i);
+ event_name = rb_ary_entry(event, 1);
+ if(NIL_P(event_name)) {
+ *is_default = TRUE;
+ def_event = event;
+ }
+ else if (rb_str_cmp(ev, event_name) == 0) {
+ *is_default = FALSE;
+ return event;
+ }
+ }
+ return def_event;
+}
+
+static void
+val2ptr_variant(val, var)
+ VALUE val;
+ VARIANT *var;
+{
+ switch (TYPE(val)) {
+ case T_STRING:
+ if (V_VT(var) == (VT_BSTR | VT_BYREF)) {
+ *V_BSTRREF(var) = ole_mb2wc(StringValuePtr(val), -1);
+ }
+ break;
+ case T_FIXNUM:
+ switch(V_VT(var)) {
+ case (VT_UI1 | VT_BYREF) :
+ *V_UI1REF(var) = NUM2CHR(val);
+ break;
+ case (VT_I2 | VT_BYREF) :
+ *V_I2REF(var) = (short)NUM2INT(val);
+ break;
+ case (VT_I4 | VT_BYREF) :
+ *V_I4REF(var) = NUM2INT(val);
+ break;
+ case (VT_R4 | VT_BYREF) :
+ *V_R4REF(var) = (float)NUM2INT(val);
+ break;
+ case (VT_R8 | VT_BYREF) :
+ *V_R8REF(var) = NUM2INT(val);
+ break;
+ default:
+ break;
+ }
+ break;
+ case T_FLOAT:
+ switch(V_VT(var)) {
+ case (VT_I2 | VT_BYREF) :
+ *V_I2REF(var) = (short)NUM2INT(val);
+ break;
+ case (VT_I4 | VT_BYREF) :
+ *V_I4REF(var) = NUM2INT(val);
+ break;
+ case (VT_R4 | VT_BYREF) :
+ *V_R4REF(var) = (float)NUM2DBL(val);
+ break;
+ case (VT_R8 | VT_BYREF) :
+ *V_R8REF(var) = NUM2DBL(val);
+ break;
+ default:
+ break;
+ }
+ break;
+ case T_BIGNUM:
+ if (V_VT(var) == (VT_R8 | VT_BYREF)) {
+ *V_R8REF(var) = rb_big2dbl(val);
+ }
+ break;
+ case T_TRUE:
+ if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
+ *V_BOOLREF(var) = VARIANT_TRUE;
+ }
+ break;
+ case T_FALSE:
+ if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
+ *V_BOOLREF(var) = VARIANT_FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+ary2ptr_dispparams(ary, pdispparams)
+ VALUE ary;
+ DISPPARAMS *pdispparams;
+{
+ int i;
+ VALUE v;
+ VARIANT *pvar;
+ for(i = 0; i < RARRAY(ary)->len && (unsigned int) i < pdispparams->cArgs; i++) {
+ v = rb_ary_entry(ary, i);
+ pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
+ val2ptr_variant(v, pvar);
+ }
+}
+
+STDMETHODIMP EVENTSINK_Invoke(
+ PEVENTSINK pEventSink,
+ DISPID dispid,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS *pdispparams,
+ VARIANT *pvarResult,
+ EXCEPINFO *pexcepinfo,
+ UINT *puArgErr
+ ) {
+
+ HRESULT hr;
+ BSTR bstr;
+ unsigned int count;
+ unsigned int i;
+ ITypeInfo *pTypeInfo;
+ VARIANT *pvar;
+ VALUE ary, obj, event, handler, args, argv, ev, result;
+ BOOL is_default_handler = FALSE;
+
+ PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
+ pTypeInfo = pEV->pTypeInfo;
+
+ obj = rb_ary_entry(ary_ole_event, pEV->m_event_id);
+ if (!rb_obj_is_kind_of(obj, cWIN32OLE_EVENT)) {
+ return NOERROR;
+ }
+
+ ary = rb_ivar_get(obj, id_events);
+ if (NIL_P(ary) || TYPE(ary) != T_ARRAY) {
+ return NOERROR;
+ }
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
+ &bstr, 1, &count);
+ if (FAILED(hr)) {
+ return NOERROR;
+ }
+ ev = WC2VSTR(bstr);
+ event = ole_search_event(ary, ev, &is_default_handler);
+ if (NIL_P(event)) {
+ return NOERROR;
+ }
+ args = rb_ary_new();
+ if (is_default_handler) {
+ rb_ary_push(args, ev);
+ }
+
+ /* make argument of event handler */
+ for (i = 0; i < pdispparams->cArgs; ++i) {
+ pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
+ rb_ary_push(args, ole_variant2val(pvar));
+ }
+ handler = rb_ary_entry(event, 0);
+
+ if (rb_ary_entry(event, 3) == Qtrue) {
+ argv = rb_ary_new();
+ rb_ary_push(args, argv);
+ result = rb_apply(handler, rb_intern("call"), args);
+ ary2ptr_dispparams(argv, pdispparams);
+ }
+ else {
+ result = rb_apply(handler, rb_intern("call"), args);
+ }
+
+ if (pvarResult) {
+ ole_val2variant(result, pvarResult);
+ }
+
+ return NOERROR;
+}
+
+PIEVENTSINKOBJ
+EVENTSINK_Constructor() {
+ PIEVENTSINKOBJ pEv;
+ if (!g_IsEventSinkVtblInitialized) {
+ vtEventSink.QueryInterface=EVENTSINK_QueryInterface;
+ vtEventSink.AddRef = EVENTSINK_AddRef;
+ vtEventSink.Release = EVENTSINK_Release;
+ vtEventSink.Invoke = EVENTSINK_Invoke;
+ vtEventSink.GetIDsOfNames = EVENTSINK_GetIDsOfNames;
+ vtEventSink.GetTypeInfoCount = EVENTSINK_GetTypeInfoCount;
+ vtEventSink.GetTypeInfo = EVENTSINK_GetTypeInfo;
+
+ g_IsEventSinkVtblInitialized = TRUE;
+ }
+ pEv = ALLOC_N(IEVENTSINKOBJ, 1);
+ if(pEv == NULL) return NULL;
+ pEv->lpVtbl = &vtEventSink;
+ pEv->m_cRef = 0;
+ pEv->m_event_id = 0;
+ pEv->m_dwCookie = 0;
+ pEv->pConnectionPoint = NULL;
+ pEv->pTypeInfo = NULL;
+ return pEv;
+}
+
+void EVENTSINK_Destructor(
+ PIEVENTSINKOBJ pEVObj
+ ) {
+ if(pEVObj != NULL) {
+ free(pEVObj);
+ }
+}
+
+static HRESULT
+find_iid(ole, pitf, piid, ppTypeInfo)
+ VALUE ole;
+ char *pitf;
+ IID *piid;
+ ITypeInfo **ppTypeInfo;
+{
+ HRESULT hr;
+ IDispatch *pDispatch;
+ ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
+ TYPEATTR *pTypeAttr;
+ HREFTYPE RefType;
+ ITypeInfo *pImplTypeInfo;
+ TYPEATTR *pImplTypeAttr;
+
+ struct oledata *pole;
+ unsigned int index;
+ unsigned int count;
+ int type;
+ BSTR bstr;
+ char *pstr;
+
+ BOOL is_found = FALSE;
+ LCID lcid = LOCALE_SYSTEM_DEFAULT;
+
+ OLEData_Get_Struct(ole, pole);
+
+ pDispatch = pole->pDispatch;
+
+ hr = pDispatch->lpVtbl->GetTypeInfo(pDispatch, 0, lcid, &pTypeInfo);
+ if (FAILED(hr))
+ return hr;
+
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo,
+ &pTypeLib,
+ &index);
+ OLE_RELEASE(pTypeInfo);
+ if (FAILED(hr))
+ return hr;
+
+ if (!pitf) {
+ hr = pTypeLib->lpVtbl->GetTypeInfoOfGuid(pTypeLib,
+ piid,
+ ppTypeInfo);
+ OLE_RELEASE(pTypeLib);
+ return hr;
+ }
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (index = 0; index < count; index++) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib,
+ index,
+ &pTypeInfo);
+ if (FAILED(hr))
+ break;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+
+ if(FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ break;
+ }
+ if(pTypeAttr->typekind == TKIND_COCLASS) {
+ for (type = 0; type < pTypeAttr->cImplTypes; type++) {
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
+ type,
+ &RefType);
+ if (FAILED(hr))
+ break;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ RefType,
+ &pImplTypeInfo);
+ if (FAILED(hr))
+ break;
+
+ hr = pImplTypeInfo->lpVtbl->GetDocumentation(pImplTypeInfo,
+ -1,
+ &bstr,
+ NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pImplTypeInfo);
+ break;
+ }
+ pstr = ole_wc2mb(bstr);
+ if (strcmp(pitf, pstr) == 0) {
+ hr = pImplTypeInfo->lpVtbl->GetTypeAttr(pImplTypeInfo,
+ &pImplTypeAttr);
+ if (SUCCEEDED(hr)) {
+ is_found = TRUE;
+ *piid = pImplTypeAttr->guid;
+ if (ppTypeInfo) {
+ *ppTypeInfo = pImplTypeInfo;
+ (*ppTypeInfo)->lpVtbl->AddRef((*ppTypeInfo));
+ }
+ pImplTypeInfo->lpVtbl->ReleaseTypeAttr(pImplTypeInfo,
+ pImplTypeAttr);
+ }
+ }
+ free(pstr);
+ OLE_RELEASE(pImplTypeInfo);
+ if (is_found || FAILED(hr))
+ break;
+ }
+ }
+
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ OLE_RELEASE(pTypeInfo);
+ if (is_found || FAILED(hr))
+ break;
+ }
+ OLE_RELEASE(pTypeLib);
+ if(!is_found)
+ return E_NOINTERFACE;
+ return hr;
+}
+
+static HRESULT
+find_default_source(ole, piid, ppTypeInfo)
+ VALUE ole;
+ IID *piid;
+ ITypeInfo **ppTypeInfo;
+{
+ HRESULT hr;
+ IProvideClassInfo2 *pProvideClassInfo2;
+ IProvideClassInfo *pProvideClassInfo;
+
+ IDispatch *pDispatch;
+ ITypeInfo *pTypeInfo;
+ TYPEATTR *pTypeAttr;
+ int i;
+ int iFlags;
+ HREFTYPE hRefType;
+
+ struct oledata *pole;
+
+ OLEData_Get_Struct(ole, pole);
+ pDispatch = pole->pDispatch;
+ hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
+ &IID_IProvideClassInfo2,
+ (void**)&pProvideClassInfo2);
+ if (SUCCEEDED(hr)) {
+ hr = pProvideClassInfo2->lpVtbl->GetGUID(pProvideClassInfo2,
+ GUIDKIND_DEFAULT_SOURCE_DISP_IID,
+ piid);
+ OLE_RELEASE(pProvideClassInfo2);
+ return find_iid(ole, NULL, piid, ppTypeInfo);
+ }
+ hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
+ &IID_IProvideClassInfo,
+ (void**)&pProvideClassInfo);
+ if (FAILED(hr))
+ return hr;
+
+ hr = pProvideClassInfo->lpVtbl->GetClassInfo(pProvideClassInfo,
+ &pTypeInfo);
+ OLE_RELEASE(pProvideClassInfo);
+ if (FAILED(hr))
+ return hr;
+
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ return hr;
+ }
+ /* Enumerate all implemented types of the COCLASS */
+ for (i = 0; i < pTypeAttr->cImplTypes; i++) {
+ hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &iFlags);
+ if (FAILED(hr))
+ continue;
+
+ /*
+ looking for the [default] [source]
+ we just hope that it is a dispinterface :-)
+ */
+ if ((iFlags & IMPLTYPEFLAG_FDEFAULT) &&
+ (iFlags & IMPLTYPEFLAG_FSOURCE)) {
+
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
+ i, &hRefType);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ hRefType, ppTypeInfo);
+ if (SUCCEEDED(hr))
+ break;
+ }
+ }
+
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ OLE_RELEASE(pTypeInfo);
+
+ /* Now that would be a bad surprise, if we didn't find it, wouldn't it? */
+ if (!*ppTypeInfo) {
+ if (SUCCEEDED(hr))
+ hr = E_UNEXPECTED;
+ return hr;
+ }
+
+ /* Determine IID of default source interface */
+ hr = (*ppTypeInfo)->lpVtbl->GetTypeAttr(*ppTypeInfo, &pTypeAttr);
+ if (SUCCEEDED(hr)) {
+ *piid = pTypeAttr->guid;
+ (*ppTypeInfo)->lpVtbl->ReleaseTypeAttr(*ppTypeInfo, pTypeAttr);
+ }
+ else
+ OLE_RELEASE(*ppTypeInfo);
+
+ return hr;
+
+}
+
+static void
+ole_event_free(poleev)
+ struct oleeventdata *poleev;
+{
+ ITypeInfo *pti = NULL;
+ IConnectionPoint *pcp = NULL;
+
+ if(poleev->pEvent) {
+ pti = poleev->pEvent->pTypeInfo;
+ if(pti) OLE_RELEASE(pti);
+ pcp = poleev->pEvent->pConnectionPoint;
+ if(pcp) {
+ pcp->lpVtbl->Unadvise(pcp, poleev->pEvent->m_dwCookie);
+ OLE_RELEASE(pcp);
+ }
+ }
+}
+
+static VALUE fev_s_allocate _((VALUE));
+static VALUE
+fev_s_allocate(klass)
+ VALUE klass;
+{
+ VALUE obj;
+ struct oleeventdata *poleev;
+ obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev);
+ poleev->pEvent = NULL;
+ return obj;
+}
+
+static VALUE
+fev_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE ole, itf;
+ struct oledata *pole;
+ char *pitf;
+ HRESULT hr;
+ IID iid;
+ ITypeInfo *pTypeInfo;
+ IDispatch *pDispatch;
+ IConnectionPointContainer *pContainer;
+ IConnectionPoint *pConnectionPoint;
+ IEVENTSINKOBJ *pIEV;
+ DWORD dwCookie;
+ struct oleeventdata *poleev;
+
+ rb_secure(4);
+ rb_scan_args(argc, argv, "11", &ole, &itf);
+
+ if (!rb_obj_is_kind_of(ole, cWIN32OLE)) {
+ rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object.");
+ }
+
+ if(TYPE(itf) != T_NIL) {
+ if (ruby_safe_level > 0 && OBJ_TAINTED(itf)) {
+ rb_raise(rb_eSecurityError, "Insecure Event Creation - %s",
+ StringValuePtr(itf));
+ }
+ Check_SafeStr(itf);
+ pitf = StringValuePtr(itf);
+ hr = find_iid(ole, pitf, &iid, &pTypeInfo);
+ }
+ else {
+ hr = find_default_source(ole, &iid, &pTypeInfo);
+ }
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "interface not found");
+ }
+
+ OLEData_Get_Struct(ole, pole);
+ pDispatch = pole->pDispatch;
+ hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
+ &IID_IConnectionPointContainer,
+ (void**)&pContainer);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError,
+ "Failed to query IConnectionPointContainer");
+ }
+
+ hr = pContainer->lpVtbl->FindConnectionPoint(pContainer,
+ &iid,
+ &pConnectionPoint);
+ OLE_RELEASE(pContainer);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError, "Failed to query IConnectionPoint");
+ }
+ pIEV = EVENTSINK_Constructor();
+ pIEV->m_iid = iid;
+ hr = pConnectionPoint->lpVtbl->Advise(pConnectionPoint,
+ (IUnknown*)pIEV,
+ &dwCookie);
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "Advise Error");
+ }
+
+ Data_Get_Struct(self, struct oleeventdata, poleev);
+ poleev->pEvent = pIEV;
+ poleev->pEvent->m_event_id
+ = NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0));
+ poleev->pEvent->pConnectionPoint = pConnectionPoint;
+ poleev->pEvent->pTypeInfo = pTypeInfo;
+ poleev->pEvent->m_dwCookie = dwCookie;
+
+ rb_ary_push(ary_ole_event, self);
+ return self;
+}
+
+/*
+ * WIN32OLE_EVENT.message_loop
+ * ---
+ * Translates and dispatches Windows message.
+ */
+static VALUE
+fev_s_msg_loop(klass)
+ VALUE klass;
+{
+ ole_msg_loop();
+ return Qnil;
+}
+
+
+static void
+add_event_call_back(obj, data)
+ VALUE obj;
+ VALUE data;
+{
+ VALUE ary = rb_ivar_get(obj, id_events);
+ if (NIL_P(ary) || TYPE(ary) != T_ARRAY) {
+ ary = rb_ary_new();
+ rb_ivar_set(obj, id_events, ary);
+ }
+ rb_ary_push(ary, data);
+}
+
+static VALUE
+ev_on_event(argc, argv, self, is_ary_arg)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+ VALUE is_ary_arg;
+{
+ VALUE event, args, data;
+ rb_scan_args(argc, argv, "01*", &event, &args);
+ if(!NIL_P(event)) {
+ Check_SafeStr(event);
+ }
+ data = rb_ary_new3(4, rb_block_proc(), event, args, is_ary_arg);
+ add_event_call_back(self, data);
+ return Qnil;
+}
+
+/*
+ * WIN32OLE_EVENT#on_event([event]){...}
+ * ----
+ * defines the callback event.
+ * If argument is omitted, this method defines the callback of all events.
+ */
+static VALUE
+fev_on_event(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return ev_on_event(argc, argv, self, Qfalse);
+}
+
+/*
+ * WIN32OLE_EVENT#on_event_with_outargs([event]){...}
+ * ----
+ * defines the callback of event.
+ * If you want modify argument in callback,
+ * you should use this method instead of WIN32OLE_EVENT#on_event.
+ */
+static VALUE
+fev_on_event_with_outargs(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return ev_on_event(argc, argv, self, Qtrue);
+}
+
+
+void
+Init_win32ole()
+{
+ ary_ole_event = rb_ary_new();
+ rb_global_variable(&ary_ole_event);
+ id_events = rb_intern("events");
+
+ com_vtbl.QueryInterface = QueryInterface;
+ com_vtbl.AddRef = AddRef;
+ com_vtbl.Release = Release;
+ com_vtbl.GetTypeInfoCount = GetTypeInfoCount;
+ com_vtbl.GetTypeInfo = GetTypeInfo;
+ com_vtbl.GetIDsOfNames = GetIDsOfNames;
+ com_vtbl.Invoke = Invoke;
+ com_hash = Data_Wrap_Struct(rb_cData, rb_mark_hash, st_free_table, st_init_numtable());
+ rb_global_variable(&com_hash);
+
+ cWIN32OLE = rb_define_class("WIN32OLE", rb_cObject);
+
+ rb_define_alloc_func(cWIN32OLE, fole_s_allocate);
+
+ rb_define_method(cWIN32OLE, "initialize", fole_initialize, -1);
+
+ rb_define_singleton_method(cWIN32OLE, "connect", fole_s_connect, -1);
+ rb_define_singleton_method(cWIN32OLE, "const_load", fole_s_const_load, -1);
+
+ rb_define_singleton_method(cWIN32OLE, "ole_free", fole_s_free, 1);
+ rb_define_singleton_method(cWIN32OLE, "ole_reference_count", fole_s_reference_count, 1);
+ rb_define_singleton_method(cWIN32OLE, "ole_show_help", fole_s_show_help, -1);
+
+
+ rb_define_method(cWIN32OLE, "invoke", fole_invoke, -1);
+ rb_define_method(cWIN32OLE, "[]", fole_getproperty, 1);
+ rb_define_method(cWIN32OLE, "_invoke", fole_invoke2, 3);
+ rb_define_method(cWIN32OLE, "_getproperty", fole_getproperty2, 3);
+ rb_define_method(cWIN32OLE, "_setproperty", fole_setproperty2, 3);
+
+ /* support propput method that takes an argument */
+ rb_define_method(cWIN32OLE, "[]=", fole_setproperty, -1);
+
+ rb_define_method(cWIN32OLE, "ole_free", fole_free, 0);
+
+ rb_define_method(cWIN32OLE, "each", fole_each, 0);
+ rb_define_method(cWIN32OLE, "method_missing", fole_missing, -1);
+
+ /* support setproperty method much like Perl ;-) */
+ rb_define_method(cWIN32OLE, "setproperty", fole_setproperty, -1);
+
+ rb_define_method(cWIN32OLE, "ole_methods", fole_methods, 0);
+ rb_define_method(cWIN32OLE, "ole_get_methods", fole_get_methods, 0);
+ rb_define_method(cWIN32OLE, "ole_put_methods", fole_put_methods, 0);
+ rb_define_method(cWIN32OLE, "ole_func_methods", fole_func_methods, 0);
+
+ rb_define_method(cWIN32OLE, "ole_method", fole_method_help, 1);
+ rb_define_alias(cWIN32OLE, "ole_method_help", "ole_method");
+ rb_define_method(cWIN32OLE, "ole_obj_help", fole_obj_help, 0);
+
+ rb_define_const(cWIN32OLE, "VERSION", rb_str_new2(WIN32OLE_VERSION));
+ rb_define_const(cWIN32OLE, "ARGV", rb_ary_new());
+
+ mWIN32OLE_VARIANT = rb_define_module_under(cWIN32OLE, "VARIANT");
+ rb_define_const(mWIN32OLE_VARIANT, "VT_I2", INT2FIX(VT_I2));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_I4", INT2FIX(VT_I4));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_R4", INT2FIX(VT_R4));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_R8", INT2FIX(VT_R8));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_CY", INT2FIX(VT_CY));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_DATE", INT2FIX(VT_DATE));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_BSTR", INT2FIX(VT_BSTR));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_USERDEFINED", INT2FIX(VT_USERDEFINED));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_PTR", INT2FIX(VT_PTR));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_DISPATCH", INT2FIX(VT_DISPATCH));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_ERROR", INT2FIX(VT_ERROR));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_BOOL", INT2FIX(VT_BOOL));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_VARIANT", INT2FIX(VT_VARIANT));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UNKNOWN", INT2FIX(VT_UNKNOWN));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_I1", INT2FIX(VT_I1));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UI1", INT2FIX(VT_UI1));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UI2", INT2FIX(VT_UI2));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UI4", INT2FIX(VT_UI4));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_INT", INT2FIX(VT_INT));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UINT", INT2FIX(VT_UINT));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_ARRAY", INT2FIX(VT_ARRAY));
+ rb_define_const(mWIN32OLE_VARIANT, "VT_BYREF", INT2FIX(VT_BYREF));
+
+ cWIN32OLE_TYPE = rb_define_class("WIN32OLE_TYPE", rb_cObject);
+ rb_define_singleton_method(cWIN32OLE_TYPE, "ole_classes", foletype_s_ole_classes, 1);
+ rb_define_singleton_method(cWIN32OLE_TYPE, "typelibs", foletype_s_typelibs, 0);
+ rb_define_singleton_method(cWIN32OLE_TYPE, "progids", foletype_s_progids, 0);
+ rb_define_alloc_func(cWIN32OLE_TYPE, foletype_s_allocate);
+ rb_define_method(cWIN32OLE_TYPE, "initialize", foletype_initialize, 2);
+ rb_define_method(cWIN32OLE_TYPE, "name", foletype_name, 0);
+ rb_define_method(cWIN32OLE_TYPE, "ole_type", foletype_ole_type, 0);
+ rb_define_method(cWIN32OLE_TYPE, "guid", foletype_guid, 0);
+ rb_define_method(cWIN32OLE_TYPE, "progid", foletype_progid, 0);
+ rb_define_method(cWIN32OLE_TYPE, "visible?", foletype_visible, 0);
+ rb_define_alias(cWIN32OLE_TYPE, "to_s", "name");
+
+ rb_define_method(cWIN32OLE_TYPE, "major_version", foletype_major_version, 0);
+ rb_define_method(cWIN32OLE_TYPE, "minor_version", foletype_minor_version, 0);
+ rb_define_method(cWIN32OLE_TYPE, "typekind", foletype_typekind, 0);
+ rb_define_method(cWIN32OLE_TYPE, "helpstring", foletype_helpstring, 0);
+ rb_define_method(cWIN32OLE_TYPE, "src_type", foletype_src_type, 0);
+ rb_define_method(cWIN32OLE_TYPE, "helpfile", foletype_helpfile, 0);
+ rb_define_method(cWIN32OLE_TYPE, "helpcontext", foletype_helpcontext, 0);
+ rb_define_method(cWIN32OLE_TYPE, "variables", foletype_variables, 0);
+ rb_define_method(cWIN32OLE_TYPE, "ole_methods", foletype_methods, -1);
+
+ cWIN32OLE_VARIABLE = rb_define_class("WIN32OLE_VARIABLE", rb_cObject);
+ rb_define_method(cWIN32OLE_VARIABLE, "name", folevariable_name, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "ole_type", folevariable_ole_type, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "ole_type_detail", folevariable_ole_type_detail, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "value", folevariable_value, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "visible?", folevariable_visible, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "variable_kind", folevariable_variable_kind, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "varkind", folevariable_varkind, 0);
+ rb_define_alias(cWIN32OLE_VARIABLE, "to_s", "name");
+
+ cWIN32OLE_METHOD = rb_define_class("WIN32OLE_METHOD", rb_cObject);
+ rb_define_alloc_func(cWIN32OLE_METHOD, folemethod_s_allocate);
+ rb_define_method(cWIN32OLE_METHOD, "initialize", folemethod_initialize, 2);
+
+ rb_define_method(cWIN32OLE_METHOD, "name", folemethod_name, 0);
+ rb_define_method(cWIN32OLE_METHOD, "return_type", folemethod_return_type, 0);
+ rb_define_method(cWIN32OLE_METHOD, "return_vtype", folemethod_return_vtype, 0);
+ rb_define_method(cWIN32OLE_METHOD, "return_type_detail", folemethod_return_type_detail, 0);
+ rb_define_method(cWIN32OLE_METHOD, "invoke_kind", folemethod_invoke_kind, 0);
+ rb_define_method(cWIN32OLE_METHOD, "invkind", folemethod_invkind, 0);
+ rb_define_method(cWIN32OLE_METHOD, "visible?", folemethod_visible, 0);
+ rb_define_method(cWIN32OLE_METHOD, "event?", folemethod_event, 0);
+ rb_define_method(cWIN32OLE_METHOD, "event_interface", folemethod_event_interface, 0);
+ rb_define_method(cWIN32OLE_METHOD, "helpstring", folemethod_helpstring, 0);
+ rb_define_method(cWIN32OLE_METHOD, "helpfile", folemethod_helpfile, 0);
+ rb_define_method(cWIN32OLE_METHOD, "helpcontext", folemethod_helpcontext, 0);
+ rb_define_method(cWIN32OLE_METHOD, "dispid", folemethod_dispid, 0);
+ rb_define_method(cWIN32OLE_METHOD, "offset_vtbl", folemethod_offset_vtbl, 0);
+ rb_define_method(cWIN32OLE_METHOD, "size_params", folemethod_size_params, 0);
+ rb_define_method(cWIN32OLE_METHOD, "size_opt_params", folemethod_size_opt_params, 0);
+ rb_define_method(cWIN32OLE_METHOD, "params", folemethod_params, 0);
+ rb_define_alias(cWIN32OLE_METHOD, "to_s", "name");
+
+ cWIN32OLE_PARAM = rb_define_class("WIN32OLE_PARAM", rb_cObject);
+ rb_define_method(cWIN32OLE_PARAM, "name", foleparam_name, 0);
+ rb_define_method(cWIN32OLE_PARAM, "ole_type", foleparam_ole_type, 0);
+ rb_define_method(cWIN32OLE_PARAM, "ole_type_detail", foleparam_ole_type_detail, 0);
+ rb_define_method(cWIN32OLE_PARAM, "input?", foleparam_input, 0);
+ rb_define_method(cWIN32OLE_PARAM, "output?", foleparam_output, 0);
+ rb_define_method(cWIN32OLE_PARAM, "optional?", foleparam_optional, 0);
+ rb_define_method(cWIN32OLE_PARAM, "retval?", foleparam_retval, 0);
+ rb_define_method(cWIN32OLE_PARAM, "default", foleparam_default, 0);
+ rb_define_alias(cWIN32OLE_PARAM, "to_s", "name");
+
+ cWIN32OLE_EVENT = rb_define_class("WIN32OLE_EVENT", rb_cObject);
+
+ rb_define_alloc_func(cWIN32OLE_EVENT, fev_s_allocate);
+ rb_define_method(cWIN32OLE_EVENT, "initialize", fev_initialize, -1);
+ rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0);
+
+ rb_define_method(cWIN32OLE_EVENT, "on_event", fev_on_event, -1);
+ rb_define_method(cWIN32OLE_EVENT, "on_event_with_outargs", fev_on_event_with_outargs, -1);
+ eWIN32OLE_RUNTIME_ERROR = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError);
+}
diff --git a/ext/zlib/.cvsignore b/ext/zlib/.cvsignore
new file mode 100644
index 0000000000..4088712231
--- /dev/null
+++ b/ext/zlib/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+mkmf.log
+*.def
diff --git a/ext/zlib/doc/zlib.rd b/ext/zlib/doc/zlib.rd
new file mode 100644
index 0000000000..6a36dc7fed
--- /dev/null
+++ b/ext/zlib/doc/zlib.rd
@@ -0,0 +1,911 @@
+=begin
+#
+# zlib.rd.src
+#
+# Copyright (C) UENO Katsuhiro 2000-2003
+#
+# $Id$
+#
+
+= Ruby/zlib version 0.6.0
+
+Ruby/zlib is an extension library to use zlib from Ruby.
+Ruby/zlib also provides the features for accessing gzipped files.
+
+You can modify or redistribute Ruby/zlib in the same manner of
+Ruby interpreter. The latest version of Ruby/zlib would be found
+at ((<URL:http://www.blue.sky.or.jp/>)).
+
+Any comments and suggestions are always welcome. Please send
+them to ruby-list ML, ruby-ext ML, ruby-talk ML, or the author's
+mail address ((<URL:mailto:katsu@blue.sky.or.jp>)).
+
+This document is experimental and broken English version.
+If you find some mistakes or strange expressions (including
+kidding or unnatural ones) in this document, please let me know
+for my study.
+
+* ((<Zlib>))
+
+ * ((<Zlib::Error>))
+ * ((<Zlib::ZStream>))
+ * ((<Zlib::Deflate>))
+ * ((<Zlib::Inflate>))
+ * ((<Zlib::GzipFile>))
+ * ((<Zlib::GzipFile::Error>))
+ * ((<Zlib::GzipWriter>))
+ * ((<Zlib::GzipReader>))
+
+* ((<Changes from 0.5 to 0.6>))
+* ((<Changes from 0.4 to 0.5>))
+
+== Zlib
+
+Zlib is the module which provides the other features in zlib C
+library. See zlib.h for detail of each module function.
+
+=== Module Functions:
+
+--- Zlib.zlib_version
+
+ Returns the string which represents the version of zlib
+ library.
+
+--- Zlib.adler32([string[, adler]])
+
+ Calculates Alder-32 checksum for ((|string|)),
+ and returns updated value of ((|alder|)).
+ If ((|string|)) is omitted, it returns the Adler-32 initial
+ value. If ((|alder|)) is omitted, it assumes that the initial
+ value is given to ((|alder|)).
+
+--- Zlib.crc32([string[, crc]])
+
+ Calculates CRC checksum for ((|string|)), and returns
+ updated value of ((|crc|)). If ((|string|)) is omitted,
+ it returns the CRC initial value. ((|crc|)) is omitted,
+ it assumes that the initial value is given to ((|crc|)).
+
+--- Zlib.crc_table
+
+ Returns the table for calculating CRC checksum as an array.
+
+=== Constants:
+
+--- Zlib::VERSION
+
+ The Ruby/zlib version string.
+
+--- Zlib::ZLIB_VERSION
+
+ The string which represents the version of zlib.h.
+
+--- Zlib::BINARY
+--- Zlib::ASCII
+--- Zlib::UNKNOWN
+
+ The integers representing data types which
+ ((<Zlib::ZStream#data_type>)) method returns.
+
+--- Zlib::NO_COMPRESSION
+--- Zlib::BEST_SPEED
+--- Zlib::BEST_COMPRESSION
+--- Zlib::DEFAULT_COMPRESSION
+
+ The integers representing compression levels which are
+ an argument for ((<Zlib::Deflate.new>)),
+ ((<Zlib::Deflate#deflate>)), and so on.
+
+--- Zlib::FILTERED
+--- Zlib::HUFFMAN_ONLY
+--- Zlib::DEFAULT_STRATEGY
+
+ The integers representing compression methods which are
+ an argument for ((<Zlib::Deflate.new>)) and
+ ((<Zlib::Deflate#params>)).
+
+--- Zlib::DEF_MEM_LEVEL
+--- Zlib::MAX_MEM_LEVEL
+
+ The integers representing memory levels which are an
+ argument for ((<Zlib::Deflate.new>)),
+ ((<Zlib::Deflate#params>)), and so on.
+
+--- Zlib::MAX_WBITS
+
+ The default value of ((|windowBits|)) which is an argument for
+ ((<Zlib::Deflate.new>)) and ((<Zlib::Inflate.new>)).
+
+--- Zlib::NO_FLUSH
+--- Zlib::SYNC_FLUSH
+--- Zlib::FULL_FLUSH
+--- Zlib::FINISH
+
+ The integers to control the output of the deflate stream,
+ which are an argument for ((<Zlib::Deflate#deflate>)) and so on.
+
+--- Zlib::OS_CODE
+--- Zlib::OS_MSDOS
+--- Zlib::OS_AMIGA
+--- Zlib::OS_VMS
+--- Zlib::OS_UNIX
+--- Zlib::OS_VMCMS
+--- Zlib::OS_ATARI
+--- Zlib::OS_OS2
+--- Zlib::OS_MACOS
+--- Zlib::OS_ZSYSTEM
+--- Zlib::OS_CPM
+--- Zlib::OS_TOPS20
+--- Zlib::OS_WIN32
+--- Zlib::OS_QDOS
+--- Zlib::OS_RISCOS
+--- Zlib::OS_UNKNOWN
+
+ The return values of ((<Zlib::GzipFile#os_code>)) method.
+
+
+== Zlib::Error
+
+The superclass for all exceptions raised by Ruby/zlib.
+
+The following exceptions are defined as subclasses of Zlib::Error.
+These exceptions are raised when zlib library functions return
+with an error status.
+
+ * Zlib::StreamEnd
+ * Zlib::NeedDict
+ * Zlib::DataError
+ * Zlib::StreamError
+ * Zlib::MemError
+ * Zlib::BufError
+ * Zlib::VersionError
+
+=== SuperClass:
+
+* StandardError
+
+
+== Zlib::ZStream
+
+The abstract class for the stream which handles the compressed
+data. The operations are defined in the subclasses,
+((<Zlib::Deflate>)) for compression, and ((<Zlib::Inflate>))
+for decompression.
+
+An instance of Zlib::ZStream has one stream (struct zstream) and
+two variable-length buffers which associated to the input
+(next_in) of the stream and the output (next_out) of the stream.
+In this document, "input buffer" means the buffer for input, and
+"output buffer" means the buffer for output.
+
+Data inputed into an instance of Zlib::ZStream are temporally
+stored into the end of input buffer, and then data in input buffer
+are processed from the beginning of the buffer until no more
+output from the stream is produced (i.e. until avail_out > 0
+after processing). During processing, output buffer is allocated
+and expanded automatically to hold all output data.
+
+Some particular instance methods consume the data in output buffer
+and return them as a String.
+
+Here is an ascii art for describing above:
+
+ +================ an instance of Zlib::ZStream ================+
+ || ||
+ || +--------+ +-------+ +--------+ ||
+ || +--| output |<---------|zstream|<---------| input |<--+ ||
+ || | | buffer | next_out+-------+next_in | buffer | | ||
+ || | +--------+ +--------+ | ||
+ || | | ||
+ +===|======================================================|===+
+ | |
+ v |
+ "output data" "input data"
+
+If an error is occurred during processing input buffer,
+an exception which is a subclass of ((<Zlib::Error>)) is raised.
+At that time, both input and output buffer keeps their conditions
+at the time when the error is occurred.
+
+=== SuperClass:
+
+* Object
+
+=== Class Methods:
+
+--- Zlib::ZStream.new
+
+ See ((<Zlib::Deflate.new>)) and ((<Zlib::Inflate.new>)).
+
+=== Methods:
+
+--- Zlib::ZStream#avail_in
+
+ Returns bytes of data in input buffer.
+ Normally, returns 0.
+
+--- Zlib::ZStream#avail_out
+
+ Returns bytes of free spaces in output buffer.
+ Because the free spaces are allocated automatically,
+ this method returns 0 normally.
+
+--- Zlib::ZStream#avail_out = size
+
+ Allocates free spaces of ((|size|)) bytes in output buffer.
+ If there are more than ((|size|)) bytes spaces in the buffer,
+ the buffer is truncated.
+ Because the free spaces are allocated automatically,
+ you usually need not to use this method.
+
+--- Zlib::ZStream#flush_next_in
+
+ Flushes input buffer and returns all data in that buffer.
+
+--- Zlib::ZStream#flush_next_out
+
+ Flushes output buffer and returns all data in that buffer.
+
+--- Zlib::ZStream#total_in
+
+ Returns the total bytes of the input data to the stream.
+
+--- Zlib::ZStream#total_out
+
+ Returns the total bytes of the output data from the stream.
+
+--- Zlib::ZStream#data_type
+
+ Guesses the type of the data which have been inputed into
+ the stream. The returned value is either ((<Zlib::BINARY>)),
+ ((<Zlib::ASCII>)), or ((<Zlib::UNKNOWN>)).
+
+--- Zlib::ZStream#adler
+
+ Returns the alder-32 checksum.
+
+--- Zlib::ZStream#reset
+
+ Resets and initializes the stream. All data in both
+ input and output buffer are discarded.
+
+--- Zlib::ZStream#finish
+
+ Finishes the stream and flushes output buffer.
+ See ((<Zlib::Deflate#finish>)) and ((<Zlib::Inflate#finish>))
+ for detail of the behavior.
+
+--- Zlib::ZStream#finished?
+--- Zlib::ZStream#stream_end?
+
+ Returns true if the stream is finished.
+
+--- Zlib::ZStream#close
+--- Zlib::ZStream#end
+
+ Closes the stream. All operations on the closed stream
+ will raise an exception.
+
+--- Zlib::ZStream#closed?
+--- Zlib::ZStream#ended?
+
+ Returns true if the stream closed.
+
+
+== Zlib::Deflate
+
+The class for compressing string data.
+
+=== SuperClass:
+
+* ((<Zlib::ZStream>))
+
+=== Class Methods:
+
+--- Zlib::Deflate.deflate(string[, level])
+
+ Compresses ((|string|)). The avail values of ((|level|)) are
+ ((<Zlib::NO_COMPRESSION>)), ((<Zlib::BEST_SPEED>)),
+ ((<Zlib::BEST_COMPRESSION>)), ((<Zlib::DEFAULT_COMPRESSION>)),
+ and the integer from 0 to 9.
+
+ This method is almost equivalent to the following code:
+
+ def deflate(string, level)
+ z = Zlib::Deflate.new(level)
+ dst = z.deflate(string, Zlib::FINISH)
+ z.close
+ dst
+ end
+
+--- Zlib::Deflate.new([level[, windowBits[, memlevel[, strategy]]]])
+
+ Creates a new deflate stream for compression.
+ See zlib.h for details of each argument.
+ If an argument is nil, the default value of that
+ argument is used.
+
+=== Methods:
+
+--- Zlib::Deflate#clone
+
+ Duplicates the deflate stream.
+
+--- Zlib::Deflate#deflate(string[, flush])
+
+ Inputs ((|string|)) into the deflate stream and returns
+ the output from the stream. Calling this method,
+ both input and output buffer of the stream are flushed.
+ If ((|string|)) is nil, this method finishes the stream,
+ just like ((<Zlib::ZStream#finish>)).
+ The value of ((|flush|)) should be either ((<Zlib::NO_FLUSH>)),
+ ((<Zlib::SYNC_FLUSH>)), ((<Zlib::FULL_FLUSH>)), or
+ ((<Zlib::FINISH>)).
+ See zlib.h for details.
+
+--- Zlib::Deflate#<< string
+
+ Inputs ((|string|)) into the deflate stream just like
+ ((<Zlib::Deflate#deflate>)), but returns Zlib::Deflate object
+ itself. The output from the stream is preserved in output
+ buffer.
+
+--- Zlib::Deflate#flush([flush])
+
+ This method is equivalent to (({deflate('', ((|flush|)))})).
+ If ((|flush|)) is omitted, ((<Zlib::SYNC_FLUSH>)) is used
+ as ((|flush|)). This method is just provided for
+ readability of your Ruby script.
+
+--- Zlib::Deflate#finish
+
+ Finishes the stream. This method is equivalent to
+ (({deflate('', Zlib::FINISH)})).
+
+--- Zlib::Deflate#params(level, strategy)
+
+ Changes the parameters of the deflate stream.
+ See zlib.h for details. The output from the stream
+ by changing the params is preserved in output buffer.
+
+--- Zlib::Deflate#set_dictionary(string)
+
+ Sets the preset dictionary and returns ((|string|)).
+ This method is available just only after
+ ((<Zlib::Deflate.new>)) or ((<Zlib::ZStream#reset>)) method
+ was called. See zlib.h for details.
+
+
+== Zlib::Inflate
+
+The class for decompressing compressed data.
+Unlike ((<Zlib::Deflate>)), an instance of this class is not able
+to duplicate (clone, dup) itself.
+
+=== SuperClass:
+
+* ((<Zlib::ZStream>))
+
+=== Class Methods:
+
+--- Zlib::Inflate.inflate(string)
+
+ Decompresses ((|string|)). Raises a ((<Zlib::NeedDict>))
+ exception if a preset dictionary is needed for decompression.
+
+ This method is almost equivalent to the following code:
+
+ def inflate(string)
+ zstream = Zlib::Inflate.new
+ buf = zstream.inflate(string)
+ zstream.finish
+ zstream.close
+ buf
+ end
+
+--- Zlib::Inflate.new([windowBits])
+
+ Creates a new inflate stream for decompression.
+ See zlib.h for details of the argument.
+ If ((|windowBits|)) is nil, the default value is used.
+
+=== Methods:
+
+--- Zlib::Inflate#inflate(string)
+
+ Inputs ((|string|)) into the inflate stream and returns
+ the output from the stream. Calling this method,
+ both input and output buffer of the stream are flushed.
+ If ((|string|)) is nil, this method finishes the stream,
+ just like ((<Zlib::ZStream#finish>)).
+
+ Raises a ((<Zlib::NeedDict>)) exception if a preset
+ dictionary is needed to decompress. Set the dictionary
+ by ((<Zlib::Inflate#set_dictionary>)) and then call
+ this method again with an empty string.
+
+--- Zlib::Inflate#<< string
+
+ Inputs ((|string|)) into the inflate stream just like
+ ((<Zlib::Inflate#inflate>)), but returns Zlib::Inflate object
+ itself. The output from the stream is preserved in output
+ buffer.
+
+--- Zlib::Inflate#finish
+
+ Finishes the inflate stream and returns the garbage
+ following the compressed data. Raises an exception
+ if the stream is not finished
+ (i.e. ((<Zlib::ZStream#finished?>)) doesn't returns true).
+
+ The inflate stream finishes itself as soon as it meets
+ the end code of the compressed data, you need not to call
+ this method explicitly. However, this method is useful
+ for checking whether the data is correctly ended or not.
+
+--- Zlib::Inflate#set_dictionary(string)
+
+ Sets the preset dictionary and returns ((|string|))
+ This method is available just only after a ((<Zlib::NeedDict>))
+ exception was raised. See zlib.h for details.
+
+--- Zlib::Inflate#sync(string)
+
+ Inputs ((|string|)) into the end of input buffer and
+ skips data until a full flush point can be found.
+ If the point is found in the buffer, this method flushes
+ the buffer and returns false. Otherwise it returns true
+ and the following data of full flush point is preserved
+ in the buffer.
+
+--- Zlib::Inflate#sync_point?
+
+ What is this?
+
+
+== Zlib::GzipFile
+
+The abstract class for handling a gzip formatted compressed file.
+The operations are defined in the subclasses,
+((<Zlib::GzipReader>)) for reading, and ((<Zlib::GzipWriter>))
+for writing.
+
+GzipReader should be used with associating an instance of IO class
+(or an object which has the same methods as IO has).
+
+=== SuperClass:
+
+* Object
+
+=== Class Methods:
+
+--- Zlib::GzipFile.new(args...)
+
+ See ((<Zlib::GzipReader.new>)) and ((<Zlib::GzipWriter.new>)).
+
+--- Zlib::GzipFile.wrap(args...) {|gz| ... }
+
+ See ((<Zlib::GzipReader.wrap>)) and ((<Zlib::GzipWriter.wrap>)).
+
+--- Zlib::GzipFile.open(args...) {|gz| ... }
+
+ See ((<Zlib::GzipReader.open>)) and ((<Zlib::GzipWriter.open>)).
+
+=== Methods:
+
+--- Zlib::GzipFile#closed?
+--- Zlib::GzipFile#to_io
+
+ Same as IO.
+
+--- Zlib::GzipFile#close
+
+ Closes the GzipFile object. This method calls close method
+ of the associated IO object. Returns the associated IO object.
+
+--- Zlib::GzipFile#finish
+
+ Closes the GzipFile object. Unlike ((<Zlib::GzipFile#close>)),
+ this method ((*never*)) calls close method of the associated IO
+ object. Returns the associated IO object.
+
+--- Zlib::GzipFile#crc
+
+ Returns CRC value of the uncompressed data.
+
+--- Zlib::GzipFile#level
+
+ Returns compression level.
+
+--- Zlib::GzipFile#mtime
+
+ Returns last modification time recorded in the gzip
+ file header.
+
+--- Zlib::GzipFile#os_code
+
+ Returns OS code number recorded in the gzip file header.
+
+--- Zlib::GzipFile#orig_name
+
+ Returns original filename recorded in the gzip file header,
+ or nil if original filename is not present.
+
+--- Zlib::GzipFile#comment
+
+ Returns comments recorded in the gzip file header, or
+ nil if the comments is not present.
+
+--- Zlib::GzipFile#sync
+--- Zlib::GzipFile#sync= flag
+
+ Same as IO. If ((|flag|)) is true, the associated IO object
+ must respond to flush method. While `sync' mode is true,
+ the compression ratio decreases sharply.
+
+
+== Zlib::GzipFile::Error
+
+The superclass for all exceptions raised during processing a gzip
+file.
+
+The following exceptions are defined as subclasses of
+Zlib::GzipFile::Error.
+
+: Zlib::GzipFile::NoFooter
+
+ Raised when gzip file footer has not found.
+
+: Zlib::GzipFile::CRCError
+
+ Raised when the CRC checksum recorded in gzip file footer
+ is not equivalent to CRC checksum of the actually
+ uncompressed data.
+
+: Zlib::GzipFile::LengthError
+
+ Raised when the data length recorded in gzip file footer
+ is not equivalent to length of the actually uncompressed data.
+
+=== SuperClass:
+
+* ((<Zlib::Error>))
+
+
+== Zlib::GzipReader
+
+The class for reading a gzipped file. GzipReader should be used
+with associating an instance of IO class (or an object which has
+the same methods as IO has).
+
+ Zlib::GzipReader.open('hoge.gz') {|gz|
+ print gz.read
+ }
+
+ f = File.open('hoge.gz')
+ gz = Zlib::GzipReader.new(f)
+ print gz.read
+ gz.close
+
+=== SuperClass:
+
+* ((<Zlib::GzipFile>))
+
+=== Included Modules:
+
+* Enumerable
+
+=== Class Methods:
+
+--- Zlib::GzipReader.new(io)
+
+ Creates a GzipReader object associated with ((|io|)).
+ The GzipReader object reads gzipped data from ((|io|)),
+ and parses/decompresses them. At least, ((|io|)) must have
+ read method that behaves same as read method in IO class.
+
+ If the gzip file header is incorrect, raises an
+ ((<Zlib::GzipFile::Error>)) exception.
+
+--- Zlib::GzipReader.wrap(io) {|gz| ... }
+
+ Creates a GzipReader object associated with ((|io|)), and
+ executes the block with the newly created GzipReader object,
+ just like File::open. The GzipReader object will be closed
+ automatically after executing the block. If you want to keep
+ the associated IO object opening, you may call
+ ((<Zlib::GzipFile#finish>)) method in the block.
+
+--- Zlib::GzipReader.open(filename)
+--- Zlib::GzipReader.open(filename) {|gz| ... }
+
+ Opens a file specified by ((|filename|)) as a gzipped file,
+ and returns a GzipReader object associated with that file.
+ Further details of this method are same as
+ ((<Zlib::GzipReader.new>)) and ((<ZLib::GzipReader.wrap>)).
+
+=== ¥á¥½¥Ã¥É:
+
+--- Zlib::GzipReader#eof
+--- Zlib::GzipReader#eof?
+
+ Returns true if the object reaches the end of compressed data.
+ Note that eof? does ((*not*)) return true when reaches the
+ end of ((*file*)).
+
+--- Zlib::GzipReader#pos
+--- Zlib::GzipReader#tell
+
+ Returns the total bytes of data decompressed until now.
+ Not that it does ((*not*)) the position of file pointer.
+
+--- Zlib::GzipReader#each([rs])
+--- Zlib::GzipReader#each_line([rs])
+--- Zlib::GzipReader#each_byte([rs])
+--- Zlib::GzipReader#gets([rs])
+--- Zlib::GzipReader#getc
+--- Zlib::GzipReader#lineno
+--- Zlib::GzipReader#lineno=
+--- Zlib::GzipReader#read([length])
+--- Zlib::GzipReader#readchar
+--- Zlib::GzipReader#readline([rs])
+--- Zlib::GzipReader#readlines([rs])
+--- Zlib::GzipReader#ungetc(char)
+
+ Same as IO, but raises ((<Zlib::Error>)) or
+ ((<Zlib::GzipFile::Error>)) exception if an error was found
+ in the gzip file.
+
+ Be careful of the footer of gzip file. A gzip file has
+ the checksum of pre-compressed data in its footer.
+ GzipReader checks all uncompressed data against that checksum
+ at the following cases, and if failed, raises
+ ((<Zlib::GzipFile::NoFooter>)), ((<Zlib::GzipFile::CRCError>)),
+ or ((<Zlib::GzipFile::LengthError>)) exception.
+
+ * When an reading request is received beyond the end of file
+ (the end of compressed data).
+ That is, when ((<Zlib::GzipReader#read>)),
+ ((<Zlib::GzipReader#gets>)), or some other methods for reading
+ returns nil.
+
+ * When ((<Zlib::GzipFile#close>)) method is called after
+ the object reaches the end of file.
+
+ * When ((<Zlib::GzipReader#unused>)) method is called after
+ the object reaches the end of file.
+
+--- Zlib::GzipReader#rewind
+
+ Resets the position of the file pointer to the point
+ created the GzipReader object.
+ The associated IO object need to respond to seek method.
+
+--- Zlib::GzipReader#unused
+
+ Returns the rest of the data which had read for parsing gzip
+ format, or nil if the whole gzip file is not parsed yet.
+
+
+== Zlib::GzipWriter
+
+The class for writing a gzipped file. GzipWriter should be used
+with associate with an instance of IO class (or an object which
+has the same methods as IO has).
+
+ Zlib::GzipWriter.open('hoge.gz') {|gz|
+ gz.write 'jugemu jugemu gokou no surikire...'
+ }
+
+ f = File.open('hoge.gz', 'w')
+ gz = Zlib::GzipWriter.new(f)
+ gz.write 'jugemu jugemu gokou no surikire...'
+ gz.close
+
+NOTE: Due to the limitation in finalizer of Ruby, you must close
+explicitly GzipWriter object by ((<Zlib::GzipWriter#close>)) etc.
+Otherwise, GzipWriter should be not able to write gzip footer and
+generate broken gzip file.
+
+=== SuperClass:
+
+* ((<Zlib::GzipFile>))
+
+=== Class Methods:
+
+--- Zlib::GzipWriter.new(io[, level[, strategy]])
+
+ Creates a GzipWriter object associated with ((|io|)).
+ ((|level|)) and ((|strategy|)) should be same as the
+ arguments of ((<Zlib::Deflate.new>)). The GzipWriter object
+ writes gzipped data to ((|io|)). At least, ((|io|)) must
+ respond to write method that behaves same as write method
+ in IO class.
+
+--- Zlib::GzipWriter.wrap(io[, level[, strategy]]) {|gz| ... }
+
+ Creates a GzipWriter object associated with ((|io|)), and
+ executes the block with the newly created GzipWriter object,
+ just like File::open. The GzipWriter object will be closed
+ automatically after executing the block. If you want to keep
+ the associated IO object opening, you may call
+ ((<Zlib::GzipFile#finish>)) method in the block.
+
+--- Zlib::GzipWriter.open(filename[, level[, strategy]])
+--- Zlib::GzipWriter.open(filename[, level[, strategy]]) {|gz| ... }
+
+ Opens a file specified by ((|filename|)) for writing
+ gzip compressed data, and returns a GzipWriter object
+ associated with that file. Further details of this method
+ are same as ((<Zlib::GzipWriter.new>)) and
+ ((<Zlib::GzipWriter#wrap>)).
+
+
+=== Methods:
+
+--- Zlib::GzipWriter#close
+--- Zlib::GzipWriter#finish
+
+ Closes the GzipFile object. This method calls close method
+ of the associated IO object. Returns the associated IO object.
+ See ((<Zlib::GzipFile#close>)) and ((<Zlib::GzipFile#finish>))
+ for the difference between close and finish.
+
+ ((*NOTE: Due to the limitation in finalizer of Ruby, you must
+ close GzipWriter object explicitly. Otherwise, GzipWriter
+ should be not able to write gzip footer and generate broken
+ gzip file.*))
+
+--- Zlib::GzipWriter#pos
+--- Zlib::GzipWriter#tell
+
+ Returns the total bytes of data compressed until now.
+ Note that it does ((*not*)) the position of file pointer.
+
+--- Zlib::GzipWriter#<< str
+--- Zlib::GzipWriter#putc(ch)
+--- Zlib::GzipWriter#puts(obj...)
+--- Zlib::GzipWriter#print(arg...)
+--- Zlib::GzipWriter#printf(format, arg...)
+--- Zlib::GzipWriter#write(str)
+
+ Same as IO.
+
+--- Zlib::GzipWriter#flush([flush])
+
+ Flushes all the internal buffers of the GzipWriter object.
+ The meaning of ((|flush|)) is same as one of the argument of
+ ((<Zlib::Deflate#deflate>)).
+ ((<Zlib::SYNC_FLUSH>)) is used if ((|flush|)) is omitted.
+ It is no use giving ((|flush|)) ((<Zlib::NO_FLUSH>)).
+
+--- Zlib::GzipWriter#mtime= time
+
+ Sets last modification time to be stored in the gzip file
+ header. ((<Zlib::GzipFile::Error>)) exception will be raised
+ if this method is called after writing method (like
+ ((<Zlib::GzipWriter#write>))) was called.
+
+--- Zlib::GzipWriter#orig_name= filename
+
+ Sets original filename to be stored in the gzip file header.
+ ((<Zlib::GzipFile::Error>)) exception will be raised
+ if this method is called after writing method (like
+ ((<Zlib::GzipWriter#write>))) was called.
+
+--- Zlib::GzipWriter#comment= string
+
+ Sets comments to be stored in the gzip file header.
+ ((<Zlib::GzipFile::Error>)) exception will be raised
+ if this method is called after writing method (like
+ ((<Zlib::GzipWriter#write>))) was called.
+
+
+== Changes from 0.5 to 0.6
+
+* New methods:
+
+ * ((<Zlib::GzipFile.wrap>))
+ * ((<Zlib::GzipFile#finish>))
+
+* New constants:
+
+ * ((<Zlib::ZLIB_VERSION>))
+ * ((<Zlib::OS_VMCMS>))
+ * ((<Zlib::OS_ZSYSTEM>))
+ * ((<Zlib::OS_CPM>))
+ * ((<Zlib::OS_QDOS>))
+ * ((<Zlib::OS_RISCOS>))
+ * ((<Zlib::OS_UNKNOWN>))
+
+* Changed methods:
+
+ * ((<Zlib::GzipFile.new>)) now takes no block. Use
+ ((<Zlib::GzipFile.wrap>)) instead.
+
+ * ((<Zlib::GzipFile#close>)) now takes no argument. Use
+ ((<Zlib::GzipFile#finish>)) instead.
+
+* Renamed methods:
+
+ * Zlib.version is renamed to ((<Zlib.zlib_version>)).
+
+* Changed constants:
+
+ * ((<Zlib::VERSION>)) indicates the version of Ruby/zlib.
+ The zlib.h version is now in ((<Zlib::ZLIB_VERSION>)).
+
+* Backward compatibility:
+
+ * For backward compatibility for 0.5, the obsoleted methods and
+ arguments are still available.
+
+ * Obsoleted classes, methods, and constants for backward
+ compatibility for 0.4 or earlier are removed.
+
+== Changes from 0.4 to 0.5
+
+Almost all the code are rewritten.
+I hope all changes are enumerated below :-)
+
+* The names of almost classes and some methods are changed.
+ All classes and constants are now defined under module
+ ((<Zlib>)). The obsoleted names are also available for backward
+ compatibility.
+
+ * Classes
+
+ * Deflate -> ((<Zlib::Deflate>))
+ * Inflate -> ((<Zlib::Inflate>))
+ * Zlib::Gzip -> ((<Zlib::GzipFile>))
+ * GzipReader -> ((<Zlib::GzipReader>))
+ * GzipWriter -> ((<Zlib::GzipWriter>))
+ * Zlib::Gzip::Error -> ((<Zlib::GzipFile::Error>))
+ * Zlib::GzipReader::NoFooter -> ((<Zlib::GzipFile::NoFooter>))
+ * Zlib::GzipReader::CRCError -> ((<Zlib::GzipFile::CRCError>))
+ * Zlib::GzipReader::LengthError -> ((<Zlib::GzipFile::LengthError>))
+
+ * Constants
+
+ * Zlib::ZStream::BINARY -> ((<Zlib::BINARY>))
+ * Zlib::ZStream::ASCII -> ((<Zlib::ASCII>))
+ * Zlib::ZStream::UNKNOWN -> ((<Zlib::UNKNOWN>))
+ * Zlib::Deflate::NO_COMPRESSION -> ((<Zlib::NO_COMPRESSION>))
+ * Zlib::Deflate::BEST_SPEED -> ((<Zlib::BEST_SPEED>))
+ * Zlib::Deflate::BEST_COMPRESSION -> ((<Zlib::BEST_COMPRESSION>))
+ * Zlib::Deflate::DEFAULT_COMPRESSION -> ((<Zlib::DEFAULT_COMPRESSION>))
+ * Zlib::Deflate::FILTERED -> ((<Zlib::FILTERED>))
+ * Zlib::Deflate::HUFFMAN_ONLY -> ((<Zlib::HUFFMAN_ONLY>))
+ * Zlib::Deflate::DEFAULT_STRATEGY -> ((<Zlib::DEFAULT_STRATEGY>))
+ * Zlib::Deflate::MAX_WBITS -> ((<Zlib::MAX_WBITS>))
+ * Zlib::Deflate::DEF_MEM_LEVEL -> ((<Zlib::DEF_MEM_LEVEL>))
+ * Zlib::Deflate::MAX_MEM_LEVEL -> ((<Zlib::MAX_MEM_LEVEL>))
+ * Zlib::Deflate::NO_FLUSH -> ((<Zlib::NO_FLUSH>))
+ * Zlib::Deflate::SYNC_FLUSH -> ((<Zlib::SYNC_FLUSH>))
+ * Zlib::Deflate::FULL_FLUSH -> ((<Zlib::FULL_FLUSH>))
+ * Zlib::Inflate::MAX_WBITS -> ((<Zlib::MAX_WBITS>))
+ * Zlib::GzipReader::OS_* -> ((<Zlib::OS_*|Zlib::OS_CODE>))
+
+ * Methods
+
+ * Zlib::ZStream#flush_out -> ((<Zlib::ZStream#flush_next_out>))
+
+* Made buffer for input (next_in).
+
+* ((<Zlib::GzipReader#unused>)) returns nil after closing.
+
+* Now you are up to call ((<Zlib::GzipWriter#close>)) explicitly
+to avoid segv in finalizer.
+((<[ruby-dev:11915]|URL:http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/11915>))
+
+* divided initialize from new.
+
+* remove sanity checks for arguments for deflateInit2 and
+ inflateInit2.
+
+* adapted the behavior of ((<Zlib::GzipWriter#puts>)) to Ruby-1.7.
+
+* Made all functions static.
+
+
+=end
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
new file mode 100644
index 0000000000..bf3349a65d
--- /dev/null
+++ b/ext/zlib/extconf.rb
@@ -0,0 +1,66 @@
+#
+# extconf.rb
+#
+# $Id$
+#
+
+require 'mkmf'
+require 'rbconfig'
+
+dir_config 'zlib'
+
+
+if %w'z libz zlib'.find {|z| have_library(z, 'deflateReset')} and
+ have_header('zlib.h') then
+
+ defines = []
+
+ message 'checking for kind of operating system... '
+ os_code = with_config('os-code') ||
+ case RUBY_PLATFORM.split('-',2)[1]
+ when 'amigaos' then
+ os_code = 'AMIGA'
+ when /\Aos2[\-_]emx\z/ then
+ os_code = 'OS2'
+ when 'mswin32', 'mingw32', 'bccwin32' then
+ # NOTE: cygwin should be regarded as Unix.
+ os_code = 'WIN32'
+ else
+ os_code = 'UNIX'
+ end
+ os_code = 'OS_' + os_code.upcase
+
+ OS_NAMES = {
+ 'OS_MSDOS' => 'MS-DOS',
+ 'OS_AMIGA' => 'Amiga',
+ 'OS_VMS' => 'VMS',
+ 'OS_UNIX' => 'Unix',
+ 'OS_ATARI' => 'Atari',
+ 'OS_OS2' => 'OS/2',
+ 'OS_MACOS' => 'MacOS',
+ 'OS_TOPS20' => 'TOPS20',
+ 'OS_WIN32' => 'Win32',
+ 'OS_VMCMS' => 'VM/CMS',
+ 'OS_ZSYSTEM' => 'Z-System',
+ 'OS_CPM' => 'CP/M',
+ 'OS_QDOS' => 'QDOS',
+ 'OS_RISCOS' => 'RISCOS',
+ 'OS_UNKNOWN' => 'Unknown',
+ }
+ unless OS_NAMES.key? os_code then
+ puts "invalid OS_CODE `#{os_code}'"
+ exit
+ end
+ message "#{OS_NAMES[os_code]}\n"
+ defines << "OS_CODE=#{os_code}"
+
+ defines = defines.collect{|d|' -D'+d}.join
+ if $CPPFLAGS then
+ $CPPFLAGS += defines
+ else
+ $CFLAGS += defines
+ end
+
+ create_makefile('zlib')
+
+end
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
new file mode 100644
index 0000000000..6dfb4cb4b6
--- /dev/null
+++ b/ext/zlib/zlib.c
@@ -0,0 +1,3510 @@
+/*
+ * zlib.c - An interface for zlib.
+ *
+ * Copyright (C) UENO Katsuhiro 2000-2003
+ *
+ * $Id$
+ */
+
+#include <ruby.h>
+#include <zlib.h>
+#include <time.h>
+
+#define RUBY_ZLIB_VERSION "0.6.0"
+
+
+#define OBJ_IS_FREED(val) (RBASIC(val)->flags == 0)
+
+#ifndef GZIP_SUPPORT
+#define GZIP_SUPPORT 1
+#endif
+
+/* from zutil.h */
+#ifndef DEF_MEM_LEVEL
+#if MAX_MEM_LEVEL >= 8
+#define DEF_MEM_LEVEL 8
+#else
+#define DEF_MEM_LEVEL MAX_MEM_LEVEL
+#endif
+#endif
+
+
+/*--------- Prototypes --------*/
+
+static NORETURN(void raise_zlib_error _((int, const char *)));
+static VALUE rb_zlib_version _((VALUE));
+static VALUE do_checksum _((int, VALUE*, uLong (*) _((uLong, const Bytef*, uInt))));
+static VALUE rb_zlib_adler32 _((int, VALUE*, VALUE));
+static VALUE rb_zlib_crc32 _((int, VALUE*, VALUE));
+static VALUE rb_zlib_crc_table _((VALUE));
+static voidpf zlib_mem_alloc _((voidpf, uInt, uInt));
+static void zlib_mem_free _((voidpf, voidpf));
+
+struct zstream;
+struct zstream_funcs;
+static void zstream_init _((struct zstream*, const struct zstream_funcs *));
+static void zstream_expand_buffer _((struct zstream*));
+static void zstream_expand_buffer_into _((struct zstream*, int));
+static void zstream_append_buffer _((struct zstream*, const char*, int));
+static VALUE zstream_detach_buffer _((struct zstream*));
+static VALUE zstream_shift_buffer _((struct zstream*, int));
+static void zstream_buffer_ungetc _((struct zstream*, int));
+static void zstream_append_input _((struct zstream*, const char*, unsigned int));
+static void zstream_discard_input _((struct zstream*, unsigned int));
+static void zstream_reset_input _((struct zstream*));
+static void zstream_passthrough_input _((struct zstream*));
+static VALUE zstream_detach_input _((struct zstream*));
+static void zstream_reset _((struct zstream*));
+static void zstream_end _((struct zstream*));
+static void zstream_run _((struct zstream*, Bytef*, uInt, int));
+static VALUE zstream_sync _((struct zstream*, Bytef*, uInt));
+static void zstream_mark _((struct zstream*));
+static void zstream_free _((struct zstream*));
+static VALUE zstream_new _((VALUE, const struct zstream_funcs*));
+static struct zstream *get_zstream _((VALUE));
+
+static VALUE rb_zstream_end _((VALUE));
+static VALUE rb_zstream_reset _((VALUE));
+static VALUE rb_zstream_finish _((VALUE));
+static VALUE rb_zstream_flush_next_in _((VALUE));
+static VALUE rb_zstream_flush_next_out _((VALUE));
+static VALUE rb_zstream_avail_out _((VALUE));
+static VALUE rb_zstream_set_avail_out _((VALUE, VALUE));
+static VALUE rb_zstream_avail_in _((VALUE));
+static VALUE rb_zstream_total_in _((VALUE));
+static VALUE rb_zstream_total_out _((VALUE));
+static VALUE rb_zstream_data_type _((VALUE));
+static VALUE rb_zstream_adler _((VALUE));
+static VALUE rb_zstream_finished_p _((VALUE));
+static VALUE rb_zstream_closed_p _((VALUE));
+
+static VALUE rb_deflate_s_allocate _((VALUE));
+static VALUE rb_deflate_initialize _((int, VALUE*, VALUE));
+static VALUE rb_deflate_clone _((VALUE));
+static VALUE rb_deflate_s_deflate _((int, VALUE*, VALUE));
+static void do_deflate _((struct zstream*, VALUE, int));
+static VALUE rb_deflate_deflate _((int, VALUE*, VALUE));
+static VALUE rb_deflate_addstr _((VALUE, VALUE));
+static VALUE rb_deflate_flush _((int, VALUE*, VALUE));
+static VALUE rb_deflate_params _((VALUE, VALUE, VALUE));
+static VALUE rb_deflate_set_dictionary _((VALUE, VALUE));
+
+static VALUE rb_inflate_s_allocate _((VALUE));
+static VALUE rb_inflate_initialize _((int, VALUE*, VALUE));
+static VALUE rb_inflate_s_inflate _((VALUE, VALUE));
+static void do_inflate _((struct zstream*, VALUE));
+static VALUE rb_inflate_inflate _((VALUE, VALUE));
+static VALUE rb_inflate_addstr _((VALUE, VALUE));
+static VALUE rb_inflate_sync _((VALUE, VALUE));
+static VALUE rb_inflate_sync_point_p _((VALUE));
+static VALUE rb_inflate_set_dictionary _((VALUE, VALUE));
+
+#if GZIP_SUPPORT
+struct gzfile;
+static void gzfile_mark _((struct gzfile*));
+static void gzfile_free _((struct gzfile*));
+static VALUE gzfile_new _((VALUE, const struct zstream_funcs*, void (*) _((struct gzfile*))));
+static void gzfile_reset _((struct gzfile*));
+static void gzfile_close _((struct gzfile*, int));
+static void gzfile_write_raw _((struct gzfile*));
+static VALUE gzfile_read_raw _((struct gzfile*));
+static int gzfile_read_raw_ensure _((struct gzfile*, int));
+static char *gzfile_read_raw_until_zero _((struct gzfile*, long));
+static unsigned int gzfile_get16 _((const unsigned char*));
+static unsigned long gzfile_get32 _((const unsigned char*));
+static void gzfile_set32 _((unsigned long n, unsigned char*));
+static void gzfile_make_header _((struct gzfile*));
+static void gzfile_make_footer _((struct gzfile*));
+static void gzfile_read_header _((struct gzfile*));
+static void gzfile_check_footer _((struct gzfile*));
+static void gzfile_write _((struct gzfile*, Bytef*, uInt));
+static long gzfile_read_more _((struct gzfile*));
+static void gzfile_calc_crc _((struct gzfile*, VALUE));
+static VALUE gzfile_read _((struct gzfile*, int));
+static VALUE gzfile_read_all _((struct gzfile*));
+static void gzfile_ungetc _((struct gzfile*, int));
+static VALUE gzfile_finalize _((VALUE));
+static void gzfile_writer_end _((struct gzfile*));
+static void gzfile_reader_end _((struct gzfile*));
+static void gzfile_reader_rewind _((struct gzfile*));
+static VALUE gzfile_reader_get_unused _((struct gzfile*));
+static struct gzfile *get_gzfile _((VALUE));
+static VALUE gzfile_ensure_close _((VALUE));
+static VALUE rb_gzfile_s_wrap _((int, VALUE*, VALUE));
+static VALUE gzfile_s_open _((int, VALUE*, VALUE, const char*));
+
+static VALUE rb_gzfile_to_io _((VALUE));
+static VALUE rb_gzfile_crc _((VALUE));
+static VALUE rb_gzfile_mtime _((VALUE));
+static VALUE rb_gzfile_level _((VALUE));
+static VALUE rb_gzfile_os_code _((VALUE));
+static VALUE rb_gzfile_orig_name _((VALUE));
+static VALUE rb_gzfile_comment _((VALUE));
+static VALUE rb_gzfile_lineno _((VALUE));
+static VALUE rb_gzfile_set_lineno _((VALUE, VALUE));
+static VALUE rb_gzfile_set_mtime _((VALUE, VALUE));
+static VALUE rb_gzfile_set_orig_name _((VALUE, VALUE));
+static VALUE rb_gzfile_set_comment _((VALUE, VALUE));
+static VALUE rb_gzfile_close _((VALUE));
+static VALUE rb_gzfile_finish _((VALUE));
+static VALUE rb_gzfile_closed_p _((VALUE));
+static VALUE rb_gzfile_eof_p _((VALUE));
+static VALUE rb_gzfile_sync _((VALUE));
+static VALUE rb_gzfile_set_sync _((VALUE, VALUE));
+static VALUE rb_gzfile_total_in _((VALUE));
+static VALUE rb_gzfile_total_out _((VALUE));
+
+static VALUE rb_gzwriter_s_allocate _((VALUE));
+static VALUE rb_gzwriter_s_open _((int, VALUE*, VALUE));
+static VALUE rb_gzwriter_initialize _((int, VALUE*, VALUE));
+static VALUE rb_gzwriter_flush _((int, VALUE*, VALUE));
+static VALUE rb_gzwriter_write _((VALUE, VALUE));
+static VALUE rb_gzwriter_putc _((VALUE, VALUE));
+
+static VALUE rb_gzreader_s_allocate _((VALUE));
+static VALUE rb_gzreader_s_open _((int, VALUE*, VALUE));
+static VALUE rb_gzreader_initialize _((VALUE, VALUE));
+static VALUE rb_gzreader_rewind _((VALUE));
+static VALUE rb_gzreader_unused _((VALUE));
+static VALUE rb_gzreader_read _((int, VALUE*, VALUE));
+static VALUE rb_gzreader_getc _((VALUE));
+static VALUE rb_gzreader_readchar _((VALUE));
+static VALUE rb_gzreader_each_byte _((VALUE));
+static VALUE rb_gzreader_ungetc _((VALUE, VALUE));
+static void gzreader_skip_linebreaks _((struct gzfile*));
+static VALUE gzreader_gets _((int, VALUE*, VALUE));
+static VALUE rb_gzreader_gets _((int, VALUE*, VALUE));
+static VALUE rb_gzreader_readline _((int, VALUE*, VALUE));
+static VALUE rb_gzreader_each _((int, VALUE*, VALUE));
+static VALUE rb_gzreader_readlines _((int, VALUE*, VALUE));
+#endif /* GZIP_SUPPORT */
+
+
+void Init_zlib _((void));
+
+
+
+/*--------- Exceptions --------*/
+
+static VALUE cZError, cStreamEnd, cNeedDict;
+static VALUE cStreamError, cDataError, cMemError, cBufError, cVersionError;
+
+static void
+raise_zlib_error(err, msg)
+ int err;
+ const char *msg;
+{
+ VALUE exc;
+
+ if (!msg) {
+ msg = zError(err);
+ }
+
+ switch(err) {
+ case Z_STREAM_END:
+ exc = rb_exc_new2(cStreamEnd, msg);
+ break;
+ case Z_NEED_DICT:
+ exc = rb_exc_new2(cNeedDict, msg);
+ break;
+ case Z_STREAM_ERROR:
+ exc = rb_exc_new2(cStreamError, msg);
+ break;
+ case Z_DATA_ERROR:
+ exc = rb_exc_new2(cDataError, msg);
+ break;
+ case Z_BUF_ERROR:
+ exc = rb_exc_new2(cBufError, msg);
+ break;
+ case Z_VERSION_ERROR:
+ exc = rb_exc_new2(cVersionError, msg);
+ break;
+ case Z_MEM_ERROR:
+ exc = rb_exc_new2(cMemError, msg);
+ break;
+ case Z_ERRNO:
+ rb_sys_fail(msg);
+ /* no return */
+ default:
+ {
+ char buf[BUFSIZ];
+ snprintf(buf, BUFSIZ, "unknown zlib error %d: %s", err, msg);
+ exc = rb_exc_new2(cZError, buf);
+ }
+ }
+
+ rb_exc_raise(exc);
+}
+
+
+
+/*-------- module Zlib --------*/
+
+/*
+ * Returns the string which represents the version of zlib library.
+ */
+static VALUE
+rb_zlib_version(klass)
+ VALUE klass;
+{
+ VALUE str;
+
+ str = rb_str_new2(zlibVersion());
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+static VALUE
+do_checksum(argc, argv, func)
+ int argc;
+ VALUE *argv;
+ uLong (*func) _((uLong, const Bytef *, uInt));
+{
+ VALUE str, vsum;
+ unsigned long sum;
+
+ rb_scan_args(argc, argv, "02", &str, &vsum);
+
+ if (!NIL_P(vsum)) {
+ sum = NUM2ULONG(vsum);
+ }
+ else if (NIL_P(str)) {
+ sum = 0;
+ }
+ else {
+ sum = func(0, Z_NULL, 0);
+ }
+
+ if (NIL_P(str)) {
+ sum = func(sum, Z_NULL, 0);
+ }
+ else {
+ StringValue(str);
+ sum = func(sum, RSTRING(str)->ptr, RSTRING(str)->len);
+ }
+ return rb_uint2inum(sum);
+}
+
+/*
+ * call-seq: Zlib.adler32(string, adler)
+ *
+ * Calculates Alder-32 checksum for +string+, and returns updated value of
+ * +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
+ * +adler+ is omitted, it assumes that the initial value is given to +adler+.
+ *
+ * FIXME: expression.
+ */
+static VALUE
+rb_zlib_adler32(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ return do_checksum(argc, argv, adler32);
+}
+
+/*
+ * call-seq: Zlib.crc32(string, adler)
+ *
+ * Calculates CRC checksum for +string+, and returns updated value of +crc+. If
+ * +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it
+ * assumes that the initial value is given to +crc+.
+ *
+ * FIXME: expression.
+ */
+static VALUE
+rb_zlib_crc32(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ return do_checksum(argc, argv, crc32);
+}
+
+/*
+ * Returns the table for calculating CRC checksum as an array.
+ */
+static VALUE
+rb_zlib_crc_table(obj)
+ VALUE obj;
+{
+ const unsigned long *crctbl;
+ VALUE dst;
+ int i;
+
+ crctbl = get_crc_table();
+ dst = rb_ary_new2(256);
+
+ for (i = 0; i < 256; i++) {
+ rb_ary_push(dst, rb_uint2inum(crctbl[i]));
+ }
+ return dst;
+}
+
+
+
+/*-------- zstream - internal APIs --------*/
+
+struct zstream {
+ unsigned long flags;
+ VALUE buf;
+ long buf_filled;
+ VALUE input;
+ z_stream stream;
+ const struct zstream_funcs {
+ int (*reset) _((z_streamp));
+ int (*end) _((z_streamp));
+ int (*run) _((z_streamp, int));
+ } *func;
+};
+
+#define ZSTREAM_FLAG_READY 0x1
+#define ZSTREAM_FLAG_IN_STREAM 0x2
+#define ZSTREAM_FLAG_FINISHED 0x4
+#define ZSTREAM_FLAG_FINALIZE 0x8
+#define ZSTREAM_FLAG_CLOSED 0x10
+#define ZSTREAM_FLAG_UNUSED 0x20
+
+#define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
+#define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
+#define ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED)
+#define ZSTREAM_IS_FINALIZE(z) ((z)->flags & ZSTREAM_FLAG_FINALIZE)
+#define ZSTREAM_IS_CLOSED(z) ((z)->flags & ZSTREAM_FLAG_CLOSED)
+
+/* I think that more better value should be found,
+ but I gave up finding it. B) */
+#define ZSTREAM_INITIAL_BUFSIZE 1024
+#define ZSTREAM_AVAIL_OUT_STEP_MAX 16384
+#define ZSTREAM_AVAIL_OUT_STEP_MIN 2048
+
+static const struct zstream_funcs deflate_funcs = {
+ deflateReset, deflateEnd, deflate,
+};
+
+static const struct zstream_funcs inflate_funcs = {
+ inflateReset, inflateEnd, inflate,
+};
+
+
+static voidpf
+zlib_mem_alloc(opaque, items, size)
+ voidpf opaque;
+ uInt items, size;
+{
+ return xmalloc(items * size);
+}
+
+static void
+zlib_mem_free(opaque, address)
+ voidpf opaque, address;
+{
+ free(address);
+}
+
+static void
+zstream_init(z, func)
+ struct zstream *z;
+ const struct zstream_funcs *func;
+{
+ z->flags = 0;
+ z->buf = Qnil;
+ z->buf_filled = 0;
+ z->input = Qnil;
+ z->stream.zalloc = zlib_mem_alloc;
+ z->stream.zfree = zlib_mem_free;
+ z->stream.opaque = Z_NULL;
+ z->stream.msg = Z_NULL;
+ z->stream.next_in = Z_NULL;
+ z->stream.avail_in = 0;
+ z->stream.next_out = Z_NULL;
+ z->stream.avail_out = 0;
+ z->func = func;
+}
+
+#define zstream_init_deflate(z) zstream_init((z), &deflate_funcs)
+#define zstream_init_inflate(z) zstream_init((z), &inflate_funcs)
+
+static void
+zstream_expand_buffer(z)
+ struct zstream *z;
+{
+ long inc;
+
+ if (NIL_P(z->buf)) {
+ /* I uses rb_str_new here not rb_str_buf_new because
+ rb_str_buf_new makes a zero-length string. */
+ z->buf = rb_str_new(0, ZSTREAM_INITIAL_BUFSIZE);
+ z->buf_filled = 0;
+ z->stream.next_out = RSTRING(z->buf)->ptr;
+ z->stream.avail_out = ZSTREAM_INITIAL_BUFSIZE;
+ RBASIC(z->buf)->klass = 0;
+ return;
+ }
+
+ if (RSTRING(z->buf)->len - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
+ /* to keep other threads from freezing */
+ z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+ else {
+ inc = z->buf_filled / 2;
+ if (inc < ZSTREAM_AVAIL_OUT_STEP_MIN) {
+ inc = ZSTREAM_AVAIL_OUT_STEP_MIN;
+ }
+ rb_str_resize(z->buf, z->buf_filled + inc);
+ z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
+ inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
+}
+
+static void
+zstream_expand_buffer_into(z, size)
+ struct zstream *z;
+ int size;
+{
+ if (NIL_P(z->buf)) {
+ /* I uses rb_str_new here not rb_str_buf_new because
+ rb_str_buf_new makes a zero-length string. */
+ z->buf = rb_str_new(0, size);
+ z->buf_filled = 0;
+ z->stream.next_out = RSTRING(z->buf)->ptr;
+ z->stream.avail_out = size;
+ RBASIC(z->buf)->klass = 0;
+ }
+ else if (z->stream.avail_out != size) {
+ rb_str_resize(z->buf, z->buf_filled + size);
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
+ z->stream.avail_out = size;
+ }
+}
+
+static void
+zstream_append_buffer(z, src, len)
+ struct zstream *z;
+ const char *src;
+ int len;
+{
+ if (NIL_P(z->buf)) {
+ z->buf = rb_str_buf_new(len);
+ rb_str_buf_cat(z->buf, src, len);
+ z->buf_filled = len;
+ z->stream.next_out = RSTRING(z->buf)->ptr;
+ z->stream.avail_out = 0;
+ RBASIC(z->buf)->klass = 0;
+ return;
+ }
+
+ if (RSTRING(z->buf)->len < z->buf_filled + len) {
+ rb_str_resize(z->buf, z->buf_filled + len);
+ z->stream.avail_out = 0;
+ }
+ else {
+ if (z->stream.avail_out >= len) {
+ z->stream.avail_out -= len;
+ }
+ else {
+ z->stream.avail_out = 0;
+ }
+ }
+ memcpy(RSTRING(z->buf)->ptr + z->buf_filled, src, len);
+ z->buf_filled += len;
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
+}
+
+#define zstream_append_buffer2(z,v) \
+ zstream_append_buffer((z),RSTRING(v)->ptr,RSTRING(v)->len)
+
+static VALUE
+zstream_detach_buffer(z)
+ struct zstream *z;
+{
+ VALUE dst;
+
+ if (NIL_P(z->buf)) {
+ dst = rb_str_new(0, 0);
+ }
+ else {
+ dst = z->buf;
+ rb_str_resize(dst, z->buf_filled);
+ RBASIC(dst)->klass = rb_cString;
+ }
+
+ z->buf = Qnil;
+ z->buf_filled = 0;
+ z->stream.next_out = 0;
+ z->stream.avail_out = 0;
+ return dst;
+}
+
+static VALUE
+zstream_shift_buffer(z, len)
+ struct zstream *z;
+ int len;
+{
+ VALUE dst;
+
+ if (z->buf_filled <= len) {
+ return zstream_detach_buffer(z);
+ }
+
+ dst = rb_str_substr(z->buf, 0, len);
+ RBASIC(dst)->klass = rb_cString;
+ z->buf_filled -= len;
+ memmove(RSTRING(z->buf)->ptr, RSTRING(z->buf)->ptr + len,
+ z->buf_filled);
+ z->stream.next_out = RSTRING(z->buf)->ptr + z->buf_filled;
+ z->stream.avail_out = RSTRING(z->buf)->len - z->buf_filled;
+ if (z->stream.avail_out > ZSTREAM_AVAIL_OUT_STEP_MAX) {
+ z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+
+ return dst;
+}
+
+static void
+zstream_buffer_ungetc(z, c)
+ struct zstream *z;
+ int c;
+{
+ if (NIL_P(z->buf) || RSTRING(z->buf)->len - z->buf_filled == 0) {
+ zstream_expand_buffer(z);
+ }
+
+ memmove(RSTRING(z->buf)->ptr + 1, RSTRING(z->buf)->ptr, z->buf_filled);
+ RSTRING(z->buf)->ptr[0] = (char)c;
+ z->buf_filled++;
+ if (z->stream.avail_out > 0) {
+ z->stream.next_out++;
+ z->stream.avail_out--;
+ }
+}
+
+static void
+zstream_append_input(z, src, len)
+ struct zstream *z;
+ const char *src;
+ unsigned int len;
+{
+ if (len <= 0) return;
+
+ if (NIL_P(z->input)) {
+ z->input = rb_str_buf_new(len);
+ rb_str_buf_cat(z->input, src, len);
+ RBASIC(z->input)->klass = 0;
+ }
+ else {
+ rb_str_buf_cat(z->input, src, len);
+ }
+}
+
+#define zstream_append_input2(z,v)\
+ zstream_append_input((z), RSTRING(v)->ptr, RSTRING(v)->len)
+
+static void
+zstream_discard_input(z, len)
+ struct zstream *z;
+ unsigned int len;
+{
+ if (NIL_P(z->input) || RSTRING(z->input)->len <= len) {
+ z->input = Qnil;
+ }
+ else {
+ memmove(RSTRING(z->input)->ptr, RSTRING(z->input)->ptr + len,
+ RSTRING(z->input)->len - len);
+ rb_str_resize(z->input, RSTRING(z->input)->len - len);
+ }
+}
+
+static void
+zstream_reset_input(z)
+ struct zstream *z;
+{
+ z->input = Qnil;
+}
+
+static void
+zstream_passthrough_input(z)
+ struct zstream *z;
+{
+ if (!NIL_P(z->input)) {
+ zstream_append_buffer2(z, z->input);
+ z->input = Qnil;
+ }
+}
+
+static VALUE
+zstream_detach_input(z)
+ struct zstream *z;
+{
+ VALUE dst;
+
+ if (NIL_P(z->input)) {
+ dst = rb_str_new(0, 0);
+ }
+ else {
+ dst = z->input;
+ RBASIC(dst)->klass = rb_cString;
+ }
+ z->input = Qnil;
+ return dst;
+}
+
+static void
+zstream_reset(z)
+ struct zstream *z;
+{
+ int err;
+
+ err = z->func->reset(&z->stream);
+ if (err != Z_OK && !ZSTREAM_IS_FINALIZE(z)) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ z->flags = ZSTREAM_FLAG_READY;
+ z->buf = Qnil;
+ z->buf_filled = 0;
+ z->stream.next_out = 0;
+ z->stream.avail_out = 0;
+ zstream_reset_input(z);
+}
+
+static void
+zstream_end(z)
+ struct zstream *z;
+{
+ int err;
+
+ if (!ZSTREAM_IS_READY(z) && !ZSTREAM_IS_FINALIZE(z)) {
+ if (RTEST(ruby_debug)) {
+ rb_warning("attempt to close uninitialized zstream; ignored.");
+ }
+ return;
+ }
+ if (z->flags & ZSTREAM_FLAG_IN_STREAM) {
+ if (RTEST(ruby_debug)) {
+ rb_warning("attempt to close unfinished zstream; reset forced.");
+ }
+ zstream_reset(z);
+ }
+
+ zstream_reset_input(z);
+ err = z->func->end(&z->stream);
+ if (err != Z_OK && !ZSTREAM_IS_FINALIZE(z)) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ z->flags = 0;
+}
+
+static void
+zstream_run(z, src, len, flush)
+ struct zstream *z;
+ Bytef *src;
+ uInt len;
+ int flush;
+{
+ uInt n;
+ int err;
+
+ if (NIL_P(z->input) && len == 0) {
+ z->stream.next_in = "";
+ z->stream.avail_in = 0;
+ }
+ else {
+ zstream_append_input(z, src, len);
+ z->stream.next_in = RSTRING(z->input)->ptr;
+ z->stream.avail_in = RSTRING(z->input)->len;
+ }
+
+ if (z->stream.avail_out == 0) {
+ zstream_expand_buffer(z);
+ }
+
+ for (;;) {
+ n = z->stream.avail_out;
+ err = z->func->run(&z->stream, flush);
+ z->buf_filled += n - z->stream.avail_out;
+ rb_thread_schedule();
+
+ if (err == Z_STREAM_END) {
+ z->flags &= ~ZSTREAM_FLAG_IN_STREAM;
+ z->flags |= ZSTREAM_FLAG_FINISHED;
+ break;
+ }
+ if (err != Z_OK) {
+ if (flush != Z_FINISH && err == Z_BUF_ERROR
+ && z->stream.avail_out > 0) {
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ break;
+ }
+ zstream_reset_input(z);
+ if (z->stream.avail_in > 0) {
+ zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
+ }
+ raise_zlib_error(err, z->stream.msg);
+ }
+ if (z->stream.avail_out > 0) {
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ break;
+ }
+ zstream_expand_buffer(z);
+ }
+
+ zstream_reset_input(z);
+ if (z->stream.avail_in > 0) {
+ zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
+ }
+}
+
+static VALUE
+zstream_sync(z, src, len)
+ struct zstream *z;
+ Bytef *src;
+ uInt len;
+{
+ VALUE rest;
+ int err;
+
+ if (!NIL_P(z->input)) {
+ z->stream.next_in = RSTRING(z->input)->ptr;
+ z->stream.avail_in = RSTRING(z->input)->len;
+ err = inflateSync(&z->stream);
+ if (err == Z_OK) {
+ zstream_discard_input(z,
+ RSTRING(z->input)->len - z->stream.avail_in);
+ zstream_append_input(z, src, len);
+ return Qtrue;
+ }
+ zstream_reset_input(z);
+ if (err != Z_DATA_ERROR) {
+ rest = rb_str_new(z->stream.next_in, z->stream.avail_in);
+ raise_zlib_error(err, z->stream.msg);
+ }
+ }
+
+ if (len <= 0) return Qfalse;
+
+ z->stream.next_in = src;
+ z->stream.avail_in = len;
+ err = inflateSync(&z->stream);
+ if (err == Z_OK) {
+ zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
+ return Qtrue;
+ }
+ if (err != Z_DATA_ERROR) {
+ rest = rb_str_new(z->stream.next_in, z->stream.avail_in);
+ raise_zlib_error(err, z->stream.msg);
+ }
+ return Qfalse;
+}
+
+static void
+zstream_mark(z)
+ struct zstream *z;
+{
+ rb_gc_mark(z->buf);
+ rb_gc_mark(z->input);
+}
+
+static void
+zstream_free(z)
+ struct zstream *z;
+{
+ z->flags |= ZSTREAM_FLAG_FINALIZE;
+ zstream_end(z);
+ free(z);
+}
+
+static VALUE
+zstream_new(klass, funcs)
+ VALUE klass;
+ const struct zstream_funcs *funcs;
+{
+ VALUE obj;
+ struct zstream *z;
+
+ obj = Data_Make_Struct(klass, struct zstream,
+ zstream_mark, zstream_free, z);
+ zstream_init(z, funcs);
+ return obj;
+}
+
+#define zstream_deflate_new(klass) zstream_new((klass), &deflate_funcs)
+#define zstream_inflate_new(klass) zstream_new((klass), &inflate_funcs)
+
+static struct zstream *
+get_zstream(obj)
+ VALUE obj;
+{
+ struct zstream *z;
+
+ Data_Get_Struct(obj, struct zstream, z);
+ if (!ZSTREAM_IS_READY(z)) {
+ rb_raise(cZError, "stream is not ready");
+ }
+ return z;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::ZStream
+ *
+ * Zlib::ZStream is the abstract class for the stream which handles the
+ * compressed data. The operations are defined in the subclasses:
+ * Zlib::Deflate for compression, and Zlib::Inflate for decompression.
+ *
+ * An instance of Zlib::ZStream has one stream (struct zstream in the source)
+ * and two variable-length buffers which associated to the input (next_in) of
+ * the stream and the output (next_out) of the stream. In this document,
+ * "input buffer" means the buffer for input, and "output buffer" means the
+ * buffer for output.
+ *
+ * Data input into an instance of Zlib::ZStream are temporally stored into
+ * the end of input buffer, and then data in input buffer are processed from
+ * the beginning of the buffer until no more output from the stream is
+ * produced (i.e. until avail_out > 0 after processing). During processing,
+ * output buffer is allocated and expanded automatically to hold all output
+ * data.
+ *
+ * Some particular instance methods consume the data in output buffer and
+ * return them as a String.
+ *
+ * Here is an ascii art for describing above:
+ *
+ * +================ an instance of Zlib::ZStream ================+
+ * || ||
+ * || +--------+ +-------+ +--------+ ||
+ * || +--| output |<---------|zstream|<---------| input |<--+ ||
+ * || | | buffer | next_out+-------+next_in | buffer | | ||
+ * || | +--------+ +--------+ | ||
+ * || | | ||
+ * +===|======================================================|===+
+ * | |
+ * v |
+ * "output data" "input data"
+ *
+ * If an error occurs during processing input buffer, an exception which is a
+ * subclass of Zlib::Error is raised. At that time, both input and output
+ * buffer keep their conditions at the time when the error occurs.
+ *
+ * == Method Catalogue
+ *
+ * Many of the methods in this class are fairly low-level and unlikely to be
+ * of interest to users. In fact, users are unlikely to use this class
+ * directly; rather they will be interested in Zlib::Inflate and
+ * Zlib::Deflate.
+ *
+ * The higher level methods are listed below.
+ *
+ * - #total_in
+ * - #total_out
+ * - #data_type
+ * - #adler
+ * - #reset
+ * - #finish
+ * - #finished?
+ * - #close
+ * - #closed?
+ */
+
+/*
+ * Closes the stream. All operations on the closed stream will raise an
+ * exception.
+ */
+static VALUE
+rb_zstream_end(obj)
+ VALUE obj;
+{
+ zstream_end(get_zstream(obj));
+ return Qnil;
+}
+
+/*
+ * Resets and initializes the stream. All data in both input and output buffer
+ * are discarded.
+ */
+static VALUE
+rb_zstream_reset(obj)
+ VALUE obj;
+{
+ zstream_reset(get_zstream(obj));
+ return Qnil;
+}
+
+/*
+ * Finishes the stream and flushes output buffer. See Zlib::Deflate#finish and
+ * Zlib::Inflate#finish for details of this behavior.
+ */
+static VALUE
+rb_zstream_finish(obj)
+ VALUE obj;
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE dst;
+
+ zstream_run(z, "", 0, Z_FINISH);
+ dst = zstream_detach_buffer(z);
+
+ OBJ_INFECT(dst, obj);
+ return dst;
+}
+
+/*
+ * Flushes input buffer and returns all data in that buffer.
+ */
+static VALUE
+rb_zstream_flush_next_in(obj)
+ VALUE obj;
+{
+ struct zstream *z;
+ VALUE dst;
+
+ Data_Get_Struct(obj, struct zstream, z);
+ dst = zstream_detach_input(z);
+ OBJ_INFECT(dst, obj);
+ return dst;
+}
+
+/*
+ * Flushes output buffer and returns all data in that buffer.
+ */
+static VALUE
+rb_zstream_flush_next_out(obj)
+ VALUE obj;
+{
+ struct zstream *z;
+ VALUE dst;
+
+ Data_Get_Struct(obj, struct zstream, z);
+ dst = zstream_detach_buffer(z);
+ OBJ_INFECT(dst, obj);
+ return dst;
+}
+
+/*
+ * Returns number of bytes of free spaces in output buffer. Because the free
+ * space is allocated automatically, this method returns 0 normally.
+ */
+static VALUE
+rb_zstream_avail_out(obj)
+ VALUE obj;
+{
+ struct zstream *z;
+ Data_Get_Struct(obj, struct zstream, z);
+ return rb_uint2inum(z->stream.avail_out);
+}
+
+/*
+ * Allocates +size+ bytes of free space in the output buffer. If there are more
+ * than +size+ bytes already in the buffer, the buffer is truncated. Because
+ * free space is allocated automatically, you usually don't need to use this
+ * method.
+ */
+static VALUE
+rb_zstream_set_avail_out(obj, size)
+ VALUE obj, size;
+{
+ struct zstream *z = get_zstream(obj);
+
+ Check_Type(size, T_FIXNUM);
+ zstream_expand_buffer_into(z, FIX2INT(size));
+ return size;
+}
+
+/*
+ * Returns bytes of data in the input buffer. Normally, returns 0.
+ */
+static VALUE
+rb_zstream_avail_in(obj)
+ VALUE obj;
+{
+ struct zstream *z;
+ Data_Get_Struct(obj, struct zstream, z);
+ return INT2FIX(NIL_P(z->input) ? 0 : (int)(RSTRING(z->input)->len));
+}
+
+/*
+ * Returns the total bytes of the input data to the stream. FIXME
+ */
+static VALUE
+rb_zstream_total_in(obj)
+ VALUE obj;
+{
+ return rb_uint2inum(get_zstream(obj)->stream.total_in);
+}
+
+/*
+ * Returns the total bytes of the output data from the stream. FIXME
+ */
+static VALUE
+rb_zstream_total_out(obj)
+ VALUE obj;
+{
+ return rb_uint2inum(get_zstream(obj)->stream.total_out);
+}
+
+/*
+ * Guesses the type of the data which have been inputed into the stream. The
+ * returned value is either <tt>Zlib::BINARY</tt>, <tt>Zlib::ASCII</tt>, or
+ * <tt>Zlib::UNKNOWN</tt>.
+ */
+static VALUE
+rb_zstream_data_type(obj)
+ VALUE obj;
+{
+ return INT2FIX(get_zstream(obj)->stream.data_type);
+}
+
+/*
+ * Returns the adler-32 checksum.
+ */
+static VALUE
+rb_zstream_adler(obj)
+ VALUE obj;
+{
+ return rb_uint2inum(get_zstream(obj)->stream.adler);
+}
+
+/*
+ * Returns true if the stream is finished.
+ */
+static VALUE
+rb_zstream_finished_p(obj)
+ VALUE obj;
+{
+ return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse;
+}
+
+/*
+ * Returns true if the stream is closed.
+ */
+static VALUE
+rb_zstream_closed_p(obj)
+ VALUE obj;
+{
+ struct zstream *z;
+ Data_Get_Struct(obj, struct zstream, z);
+ return ZSTREAM_IS_READY(z) ? Qfalse : Qtrue;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::Deflate
+ *
+ * Zlib::Deflate is the class for compressing data. See Zlib::Stream for more
+ * information.
+ */
+
+#define FIXNUMARG(val, ifnil) \
+ (NIL_P((val)) ? (ifnil) \
+ : ((void)Check_Type((val), T_FIXNUM), FIX2INT((val))))
+
+#define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
+#define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
+#define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
+#define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
+#define ARG_FLUSH(val) FIXNUMARG((val), Z_NO_FLUSH)
+
+
+static VALUE
+rb_deflate_s_allocate(klass)
+ VALUE klass;
+{
+ return zstream_deflate_new(klass);
+}
+
+/*
+ * call-seq: Zlib::Deflate.new(level=nil, windowBits=nil, memlevel=nil, strategy=nil)
+ *
+ * Creates a new deflate stream for compression. See zlib.h for details of
+ * each argument. If an argument is nil, the default value of that argument is
+ * used.
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_deflate_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct zstream *z;
+ VALUE level, wbits, memlevel, strategy;
+ int err;
+
+ rb_scan_args(argc, argv, "04", &level, &wbits, &memlevel, &strategy);
+ Data_Get_Struct(obj, struct zstream, z);
+
+ err = deflateInit2(&z->stream, ARG_LEVEL(level), Z_DEFLATED,
+ ARG_WBITS(wbits), ARG_MEMLEVEL(memlevel),
+ ARG_STRATEGY(strategy));
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ ZSTREAM_READY(z);
+
+ return obj;
+}
+
+/*
+ * Duplicates the deflate stream.
+ */
+static VALUE
+rb_deflate_clone(obj)
+ VALUE obj;
+{
+ struct zstream *z = get_zstream(obj);
+ struct zstream *z2;
+ VALUE clone;
+ int err;
+
+ clone = zstream_deflate_new(rb_class_of(obj));
+ Data_Get_Struct(clone, struct zstream, z2);
+
+ err = deflateCopy(&z2->stream, &z->stream);
+ if (err != Z_OK) {
+ raise_zlib_error(err, 0);
+ }
+
+ z2->flags = z->flags;
+ CLONESETUP(clone, obj);
+ OBJ_INFECT(clone, obj);
+ return clone;
+}
+
+/*
+ * call-seq: Zlib::Deflate.deflate(string[, level])
+ *
+ * Compresses the given +string+. Valid values of level are
+ * <tt>Zlib::NO_COMPRESSION</tt>, <tt>Zlib::BEST_SPEED</tt>,
+ * <tt>Zlib::BEST_COMPRESSION</tt>, <tt>Zlib::DEFAULT_COMPRESSION</tt>, and an
+ * integer from 0 to 9.
+ *
+ * This method is almost equivalent to the following code:
+ *
+ * def deflate(string, level)
+ * z = Zlib::Deflate.new(level)
+ * dst = z.deflate(string, Zlib::FINISH)
+ * z.close
+ * dst
+ * end
+ *
+ * TODO: what's default value of +level+?
+ *
+ */
+static VALUE
+rb_deflate_s_deflate(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ struct zstream z;
+ VALUE src, level, dst;
+ int err;
+
+ rb_scan_args(argc, argv, "11", &src, &level);
+
+ zstream_init_deflate(&z);
+ err = deflateInit(&z.stream, ARG_LEVEL(level));
+ if (err != Z_OK) {
+ raise_zlib_error(err, z.stream.msg);
+ }
+ ZSTREAM_READY(&z);
+
+ StringValue(src);
+ zstream_run(&z, RSTRING(src)->ptr, RSTRING(src)->len, Z_FINISH);
+ dst = zstream_detach_buffer(&z);
+ zstream_end(&z);
+
+ OBJ_INFECT(dst, src);
+ return dst;
+}
+
+static void
+do_deflate(z, src, flush)
+ struct zstream *z;
+ VALUE src;
+ int flush;
+{
+ if (NIL_P(src)) {
+ zstream_run(z, "", 0, Z_FINISH);
+ return;
+ }
+ StringValue(src);
+ if (flush != Z_NO_FLUSH || RSTRING(src)->len > 0) { /* prevent BUF_ERROR */
+ zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, flush);
+ }
+}
+
+/*
+ * call-seq: deflate(string[, flush])
+ *
+ * Inputs +string+ into the deflate stream and returns the output from the
+ * stream. On calling this method, both the input and the output buffers of
+ * the stream are flushed. If +string+ is nil, this method finishes the
+ * stream, just like Zlib::ZStream#finish.
+ *
+ * The value of +flush+ should be either <tt>Zlib::NO_FLUSH</tt>,
+ * <tt>Zlib::SYNC_FLUSH</tt>, <tt>Zlib::FULL_FLUSH</tt>, or
+ * <tt>Zlib::FINISH</tt>. See zlib.h for details.
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_deflate_deflate(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE src, flush, dst;
+
+ rb_scan_args(argc, argv, "11", &src, &flush);
+ OBJ_INFECT(obj, src);
+ do_deflate(z, src, ARG_FLUSH(flush));
+ dst = zstream_detach_buffer(z);
+
+ OBJ_INFECT(dst, obj);
+ return dst;
+}
+
+/*
+ * call-seq: << string
+ *
+ * Inputs +string+ into the deflate stream just like Zlib::Deflate#deflate, but
+ * returns the Zlib::Deflate object itself. The output from the stream is
+ * preserved in output buffer.
+ */
+static VALUE
+rb_deflate_addstr(obj, src)
+ VALUE obj, src;
+{
+ OBJ_INFECT(obj, src);
+ do_deflate(get_zstream(obj), src, Z_NO_FLUSH);
+ return obj;
+}
+
+/*
+ * call-seq: flush(flush)
+ *
+ * This method is equivalent to <tt>deflate('', flush)</tt>. If flush is omitted,
+ * <tt>Zlib::SYNC_FLUSH</tt> is used as flush. This method is just provided
+ * to improve the readability of your Ruby program.
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_deflate_flush(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE v_flush, dst;
+ int flush;
+
+ rb_scan_args(argc, argv, "01", &v_flush);
+ flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
+ if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
+ zstream_run(z, "", 0, flush);
+ }
+ dst = zstream_detach_buffer(z);
+
+ OBJ_INFECT(dst, obj);
+ return dst;
+}
+
+/*
+ * call-seq: params(level, strategy)
+ *
+ * Changes the parameters of the deflate stream. See zlib.h for details. The
+ * output from the stream by changing the params is preserved in output
+ * buffer.
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_deflate_params(obj, v_level, v_strategy)
+ VALUE obj, v_level, v_strategy;
+{
+ struct zstream *z = get_zstream(obj);
+ int level, strategy;
+ int err;
+
+ level = ARG_LEVEL(v_level);
+ strategy = ARG_STRATEGY(v_strategy);
+
+ err = deflateParams(&z->stream, level, strategy);
+ while (err == Z_BUF_ERROR) {
+ if (RTEST(ruby_debug)) {
+ rb_warning("deflateParams() returned Z_BUF_ERROR");
+ }
+ zstream_expand_buffer(z);
+ err = deflateParams(&z->stream, level, strategy);
+ }
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq: set_dictionary(string)
+ *
+ * Sets the preset dictionary and returns +string+. This method is available
+ * just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called.
+ * See zlib.h for details.
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_deflate_set_dictionary(obj, dic)
+ VALUE obj, dic;
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE src = dic;
+ int err;
+
+ OBJ_INFECT(obj, dic);
+ StringValue(src);
+ err = deflateSetDictionary(&z->stream,
+ RSTRING(src)->ptr, RSTRING(src)->len);
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+
+ return dic;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::Inflate
+ *
+ * Zlib:Inflate is the class for decompressing compressed data. Unlike
+ * Zlib::Deflate, an instance of this class is not able to duplicate (clone,
+ * dup) itself.
+ */
+
+
+
+static VALUE
+rb_inflate_s_allocate(klass)
+ VALUE klass;
+{
+ return zstream_inflate_new(klass);
+}
+
+/*
+ * call-seq: Zlib::Inflate.new(window_bits)
+ *
+ * Creates a new inflate stream for decompression. See zlib.h for details
+ * of the argument. If +window_bits+ is +nil+, the default value is used.
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_inflate_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct zstream *z;
+ VALUE wbits;
+ int err;
+
+ rb_scan_args(argc, argv, "01", &wbits);
+ Data_Get_Struct(obj, struct zstream, z);
+
+ err = inflateInit2(&z->stream, ARG_WBITS(wbits));
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ ZSTREAM_READY(z);
+
+ return obj;
+}
+
+/*
+ * call-seq: Zlib::Inflate.inflate(string)
+ *
+ * Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
+ * dictionary is needed for decompression.
+ *
+ * This method is almost equivalent to the following code:
+ *
+ * def inflate(string)
+ * zstream = Zlib::Inflate.new
+ * buf = zstream.inflate(string)
+ * zstream.finish
+ * zstream.close
+ * buf
+ * end
+ *
+ */
+static VALUE
+rb_inflate_s_inflate(obj, src)
+ VALUE obj, src;
+{
+ struct zstream z;
+ VALUE dst;
+ int err;
+
+ zstream_init_inflate(&z);
+ err = inflateInit(&z.stream);
+ if (err != Z_OK) {
+ raise_zlib_error(err, z.stream.msg);
+ }
+ ZSTREAM_READY(&z);
+
+ StringValue(src);
+ zstream_run(&z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
+ zstream_run(&z, "", 0, Z_FINISH); /* for checking errors */
+ dst = zstream_detach_buffer(&z);
+ zstream_end(&z);
+
+ OBJ_INFECT(dst, src);
+ return dst;
+}
+
+static void
+do_inflate(z, src)
+ struct zstream *z;
+ VALUE src;
+{
+ if (NIL_P(src)) {
+ zstream_run(z, "", 0, Z_FINISH);
+ return;
+ }
+ StringValue(src);
+ if (RSTRING(src)->len > 0) { /* prevent Z_BUF_ERROR */
+ zstream_run(z, RSTRING(src)->ptr, RSTRING(src)->len, Z_SYNC_FLUSH);
+ }
+}
+
+/*
+ * call-seq: inflate(string)
+ *
+ * Inputs +string+ into the inflate stream and returns the output from the
+ * stream. Calling this method, both the input and the output buffer of the
+ * stream are flushed. If string is +nil+, this method finishes the stream,
+ * just like Zlib::ZStream#finish.
+ *
+ * Raises a Zlib::NeedDict exception if a preset dictionary is needed to
+ * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
+ * call this method again with an empty string. (<i>???</i>)
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_inflate_inflate(obj, src)
+ VALUE obj, src;
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE dst;
+
+ OBJ_INFECT(obj, src);
+
+ if (ZSTREAM_IS_FINISHED(z)) {
+ if (NIL_P(src)) {
+ dst = zstream_detach_buffer(z);
+ }
+ else {
+ StringValue(src);
+ zstream_append_buffer2(z, src);
+ dst = rb_str_new(0, 0);
+ }
+ }
+ else {
+ do_inflate(z, src);
+ dst = zstream_detach_buffer(z);
+ if (ZSTREAM_IS_FINISHED(z)) {
+ zstream_passthrough_input(z);
+ }
+ }
+
+ OBJ_INFECT(dst, obj);
+ return dst;
+}
+
+/*
+ * call-seq: << string
+ *
+ * Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but
+ * returns the Zlib::Inflate object itself. The output from the stream is
+ * preserved in output buffer.
+ */
+static VALUE
+rb_inflate_addstr(obj, src)
+ VALUE obj, src;
+{
+ struct zstream *z = get_zstream(obj);
+
+ OBJ_INFECT(obj, src);
+
+ if (ZSTREAM_IS_FINISHED(z)) {
+ if (!NIL_P(src)) {
+ StringValue(src);
+ zstream_append_buffer2(z, src);
+ }
+ }
+ else {
+ do_inflate(z, src);
+ if (ZSTREAM_IS_FINISHED(z)) {
+ zstream_passthrough_input(z);
+ }
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq: sync(string)
+ *
+ * Inputs +string+ into the end of input buffer and skips data until a full
+ * flush point can be found. If the point is found in the buffer, this method
+ * flushes the buffer and returns false. Otherwise it returns +true+ and the
+ * following data of full flush point is preserved in the buffer.
+ */
+static VALUE
+rb_inflate_sync(obj, src)
+ VALUE obj, src;
+{
+ struct zstream *z = get_zstream(obj);
+
+ OBJ_INFECT(obj, src);
+ StringValue(src);
+ return zstream_sync(z, RSTRING(src)->ptr, RSTRING(src)->len);
+}
+
+/*
+ * Quoted verbatim from original documentation:
+ *
+ * What is this?
+ *
+ * <tt>:)</tt>
+ */
+static VALUE
+rb_inflate_sync_point_p(obj)
+ VALUE obj;
+{
+ struct zstream *z = get_zstream(obj);
+ int err;
+
+ err = inflateSyncPoint(&z->stream);
+ if (err == 1) {
+ return Qtrue;
+ }
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ return Qfalse;
+}
+
+/*
+ * Sets the preset dictionary and returns +string+. This method is available just
+ * only after a Zlib::NeedDict exception was raised. See zlib.h for details.
+ *
+ * TODO: document better!
+ */
+static VALUE
+rb_inflate_set_dictionary(obj, dic)
+ VALUE obj, dic;
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE src = dic;
+ int err;
+
+ OBJ_INFECT(obj, dic);
+ StringValue(src);
+ err = inflateSetDictionary(&z->stream,
+ RSTRING(src)->ptr, RSTRING(src)->len);
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+
+ return dic;
+}
+
+
+
+#if GZIP_SUPPORT
+
+/* NOTE: Features for gzip files of Ruby/zlib are written from scratch
+ * and using undocumented feature of zlib, negative wbits.
+ * I don't think gzFile APIs of zlib are good for Ruby.
+ */
+
+/*------- .gz file header --------*/
+
+#define GZ_MAGIC1 0x1f
+#define GZ_MAGIC2 0x8b
+#define GZ_METHOD_DEFLATE 8
+#define GZ_FLAG_MULTIPART 0x2
+#define GZ_FLAG_EXTRA 0x4
+#define GZ_FLAG_ORIG_NAME 0x8
+#define GZ_FLAG_COMMENT 0x10
+#define GZ_FLAG_ENCRYPT 0x20
+#define GZ_FLAG_UNKNOWN_MASK 0xc0
+
+#define GZ_EXTRAFLAG_FAST 0x4
+#define GZ_EXTRAFLAG_SLOW 0x2
+
+/* from zutil.h */
+#define OS_MSDOS 0x00
+#define OS_AMIGA 0x01
+#define OS_VMS 0x02
+#define OS_UNIX 0x03
+#define OS_ATARI 0x05
+#define OS_OS2 0x06
+#define OS_MACOS 0x07
+#define OS_TOPS20 0x0a
+#define OS_WIN32 0x0b
+
+#define OS_VMCMS 0x04
+#define OS_ZSYSTEM 0x08
+#define OS_CPM 0x09
+#define OS_QDOS 0x0c
+#define OS_RISCOS 0x0d
+#define OS_UNKNOWN 0xff
+
+#ifndef OS_CODE
+#define OS_CODE OS_UNIX
+#endif
+
+static ID id_write, id_read, id_flush, id_seek, id_close;
+static VALUE cGzError, cNoFooter, cCRCError, cLengthError;
+
+
+
+/*-------- gzfile internal APIs --------*/
+
+struct gzfile {
+ struct zstream z;
+ VALUE io;
+ int level;
+ time_t mtime; /* for header */
+ int os_code; /* for header */
+ VALUE orig_name; /* for header; must be a String */
+ VALUE comment; /* for header; must be a String */
+ unsigned long crc;
+ int lineno;
+ int ungetc;
+ void (*end)(struct gzfile *);
+};
+
+#define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED
+#define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)
+#define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
+
+#define GZFILE_IS_FINISHED(gz) \
+ (ZSTREAM_IS_FINISHED(&gz->z) && (gz)->z.buf_filled == 0)
+
+#define GZFILE_READ_SIZE 2048
+
+
+static void
+gzfile_mark(gz)
+ struct gzfile *gz;
+{
+ rb_gc_mark(gz->io);
+ rb_gc_mark(gz->orig_name);
+ rb_gc_mark(gz->comment);
+ zstream_mark(&gz->z);
+}
+
+static void
+gzfile_free(gz)
+ struct gzfile *gz;
+{
+ gz->z.flags |= ZSTREAM_FLAG_FINALIZE;
+ if (ZSTREAM_IS_READY(&gz->z)) {
+ gz->end(gz);
+ }
+ free(gz);
+}
+
+static VALUE
+gzfile_new(klass, funcs, endfunc)
+ VALUE klass;
+ const struct zstream_funcs *funcs;
+ void (*endfunc) _((struct gzfile *));
+{
+ VALUE obj;
+ struct gzfile *gz;
+
+ obj = Data_Make_Struct(klass, struct gzfile, gzfile_mark, gzfile_free, gz);
+ zstream_init(&gz->z, funcs);
+ gz->io = Qnil;
+ gz->level = 0;
+ gz->mtime = 0;
+ gz->os_code = OS_CODE;
+ gz->orig_name = Qnil;
+ gz->comment = Qnil;
+ gz->crc = crc32(0, Z_NULL, 0);
+ gz->lineno = 0;
+ gz->ungetc = 0;
+ gz->end = endfunc;
+
+ return obj;
+}
+
+#define gzfile_writer_new(gz) gzfile_new((gz),&deflate_funcs,gzfile_writer_end)
+#define gzfile_reader_new(gz) gzfile_new((gz),&inflate_funcs,gzfile_reader_end)
+
+static void
+gzfile_reset(gz)
+ struct gzfile *gz;
+{
+ zstream_reset(&gz->z);
+ gz->crc = crc32(0, Z_NULL, 0);
+ gz->lineno = 0;
+ gz->ungetc = 0;
+}
+
+static void
+gzfile_close(gz, closeflag)
+ struct gzfile *gz;
+ int closeflag;
+{
+ VALUE io = gz->io;
+
+ gz->end(gz);
+ gz->io = Qnil;
+ gz->orig_name = Qnil;
+ gz->comment = Qnil;
+ if (closeflag && rb_respond_to(io, id_close)) {
+ rb_funcall(io, id_close, 0);
+ }
+}
+
+static void
+gzfile_write_raw(gz)
+ struct gzfile *gz;
+{
+ VALUE str;
+
+ if (gz->z.buf_filled > 0) {
+ str = zstream_detach_buffer(&gz->z);
+ OBJ_TAINT(str); /* for safe */
+ rb_funcall(gz->io, id_write, 1, str);
+ if ((gz->z.flags & GZFILE_FLAG_SYNC)
+ && rb_respond_to(gz->io, id_flush))
+ rb_funcall(gz->io, id_flush, 0);
+ }
+}
+
+static VALUE
+gzfile_read_raw(gz)
+ struct gzfile *gz;
+{
+ VALUE str;
+
+ str = rb_funcall(gz->io, id_read, 1, INT2FIX(GZFILE_READ_SIZE));
+ if (!NIL_P(str)) {
+ Check_Type(str, T_STRING);
+ }
+ return str;
+}
+
+static int
+gzfile_read_raw_ensure(gz, size)
+ struct gzfile *gz;
+ int size;
+{
+ VALUE str;
+
+ while (NIL_P(gz->z.input) || RSTRING(gz->z.input)->len < size) {
+ str = gzfile_read_raw(gz);
+ if (NIL_P(str)) return Qfalse;
+ zstream_append_input2(&gz->z, str);
+ }
+ return Qtrue;
+}
+
+static char *
+gzfile_read_raw_until_zero(gz, offset)
+ struct gzfile *gz;
+ long offset;
+{
+ VALUE str;
+ char *p;
+
+ for (;;) {
+ p = memchr(RSTRING(gz->z.input)->ptr + offset, '\0',
+ RSTRING(gz->z.input)->len - offset);
+ if (p) break;
+ str = gzfile_read_raw(gz);
+ if (NIL_P(str)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ offset = RSTRING(gz->z.input)->len;
+ zstream_append_input2(&gz->z, str);
+ }
+ return p;
+}
+
+static unsigned int
+gzfile_get16(src)
+ const unsigned char *src;
+{
+ unsigned int n;
+ n = *(src++) & 0xff;
+ n |= (*(src++) & 0xff) << 8;
+ return n;
+}
+
+static unsigned long
+gzfile_get32(src)
+ const unsigned char *src;
+{
+ unsigned long n;
+ n = *(src++) & 0xff;
+ n |= (*(src++) & 0xff) << 8;
+ n |= (*(src++) & 0xff) << 16;
+ n |= (*(src++) & 0xffU) << 24;
+ return n;
+}
+
+static void
+gzfile_set32(n, dst)
+ unsigned long n;
+ unsigned char *dst;
+{
+ *(dst++) = n & 0xff;
+ *(dst++) = (n >> 8) & 0xff;
+ *(dst++) = (n >> 16) & 0xff;
+ *dst = (n >> 24) & 0xff;
+}
+
+static void
+gzfile_make_header(gz)
+ struct gzfile *gz;
+{
+ unsigned char buf[10]; /* the size of gzip header */
+ unsigned char flags = 0, extraflags = 0;
+
+ if (!NIL_P(gz->orig_name)) {
+ flags |= GZ_FLAG_ORIG_NAME;
+ }
+ if (!NIL_P(gz->comment)) {
+ flags |= GZ_FLAG_COMMENT;
+ }
+ if (gz->mtime == 0) {
+ gz->mtime = time(0);
+ }
+
+ if (gz->level == Z_BEST_SPEED) {
+ extraflags |= GZ_EXTRAFLAG_FAST;
+ }
+ else if (gz->level == Z_BEST_COMPRESSION) {
+ extraflags |= GZ_EXTRAFLAG_SLOW;
+ }
+
+ buf[0] = GZ_MAGIC1;
+ buf[1] = GZ_MAGIC2;
+ buf[2] = GZ_METHOD_DEFLATE;
+ buf[3] = flags;
+ gzfile_set32(gz->mtime, &buf[4]);
+ buf[8] = extraflags;
+ buf[9] = gz->os_code;
+ zstream_append_buffer(&gz->z, buf, sizeof(buf));
+
+ if (!NIL_P(gz->orig_name)) {
+ zstream_append_buffer2(&gz->z, gz->orig_name);
+ zstream_append_buffer(&gz->z, "\0", 1);
+ }
+ if (!NIL_P(gz->comment)) {
+ zstream_append_buffer2(&gz->z, gz->comment);
+ zstream_append_buffer(&gz->z, "\0", 1);
+ }
+
+ gz->z.flags |= GZFILE_FLAG_HEADER_FINISHED;
+}
+
+static void
+gzfile_make_footer(gz)
+ struct gzfile *gz;
+{
+ unsigned char buf[8]; /* 8 is the size of gzip footer */
+
+ gzfile_set32(gz->crc, buf);
+ gzfile_set32(gz->z.stream.total_in, &buf[4]);
+ zstream_append_buffer(&gz->z, buf, sizeof(buf));
+ gz->z.flags |= GZFILE_FLAG_FOOTER_FINISHED;
+}
+
+static void
+gzfile_read_header(gz)
+ struct gzfile *gz;
+{
+ const unsigned char *head;
+ long len;
+ char flags, *p;
+
+ if (!gzfile_read_raw_ensure(gz, 10)) { /* 10 is the size of gzip header */
+ rb_raise(cGzError, "not in gzip format");
+ }
+
+ head = RSTRING(gz->z.input)->ptr;
+
+ if (head[0] != GZ_MAGIC1 || head[1] != GZ_MAGIC2) {
+ rb_raise(cGzError, "not in gzip format");
+ }
+ if (head[2] != GZ_METHOD_DEFLATE) {
+ rb_raise(cGzError, "unsupported compression method %d", head[2]);
+ }
+
+ flags = head[3];
+ if (flags & GZ_FLAG_MULTIPART) {
+ rb_raise(cGzError, "multi-part gzip file is not supported");
+ }
+ else if (flags & GZ_FLAG_ENCRYPT) {
+ rb_raise(cGzError, "encrypted gzip file is not supported");
+ }
+ else if (flags & GZ_FLAG_UNKNOWN_MASK) {
+ rb_raise(cGzError, "unknown flags 0x%02x", flags);
+ }
+
+ if (head[8] & GZ_EXTRAFLAG_FAST) {
+ gz->level = Z_BEST_SPEED;
+ }
+ else if (head[8] & GZ_EXTRAFLAG_SLOW) {
+ gz->level = Z_BEST_COMPRESSION;
+ }
+ else {
+ gz->level = Z_DEFAULT_COMPRESSION;
+ }
+
+ gz->mtime = gzfile_get32(&head[4]);
+ gz->os_code = head[9];
+ zstream_discard_input(&gz->z, 10);
+
+ if (flags & GZ_FLAG_EXTRA) {
+ if (!gzfile_read_raw_ensure(gz, 2)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ len = gzfile_get16(RSTRING(gz->z.input)->ptr);
+ if (!gzfile_read_raw_ensure(gz, 2 + len)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ zstream_discard_input(&gz->z, 2 + len);
+ }
+ if (flags & GZ_FLAG_ORIG_NAME) {
+ p = gzfile_read_raw_until_zero(gz, 0);
+ len = p - RSTRING(gz->z.input)->ptr;
+ gz->orig_name = rb_str_new(RSTRING(gz->z.input)->ptr, len);
+ OBJ_TAINT(gz->orig_name); /* for safe */
+ zstream_discard_input(&gz->z, len + 1);
+ }
+ if (flags & GZ_FLAG_COMMENT) {
+ p = gzfile_read_raw_until_zero(gz, 0);
+ len = p - RSTRING(gz->z.input)->ptr;
+ gz->comment = rb_str_new(RSTRING(gz->z.input)->ptr, len);
+ OBJ_TAINT(gz->comment); /* for safe */
+ zstream_discard_input(&gz->z, len + 1);
+ }
+
+ if (gz->z.input != Qnil && RSTRING(gz->z.input)->len > 0) {
+ zstream_run(&gz->z, 0, 0, Z_SYNC_FLUSH);
+ }
+}
+
+static void
+gzfile_check_footer(gz)
+ struct gzfile *gz;
+{
+ unsigned long crc, length;
+
+ gz->z.flags |= GZFILE_FLAG_FOOTER_FINISHED;
+
+ if (!gzfile_read_raw_ensure(gz, 8)) { /* 8 is the size of gzip footer */
+ rb_raise(cNoFooter, "footer is not found");
+ }
+
+ crc = gzfile_get32(RSTRING(gz->z.input)->ptr);
+ length = gzfile_get32(RSTRING(gz->z.input)->ptr + 4);
+
+ gz->z.stream.total_in += 8; /* to rewind correctly */
+ zstream_discard_input(&gz->z, 8);
+
+ if (gz->crc != crc) {
+ rb_raise(cCRCError, "invalid compressed data -- crc error");
+ }
+ if (gz->z.stream.total_out != length) {
+ rb_raise(cLengthError, "invalid compressed data -- length error");
+ }
+}
+
+static void
+gzfile_write(gz, str, len)
+ struct gzfile *gz;
+ Bytef *str;
+ uInt len;
+{
+ if (!(gz->z.flags & GZFILE_FLAG_HEADER_FINISHED)) {
+ gzfile_make_header(gz);
+ }
+
+ if (len > 0 || (gz->z.flags & GZFILE_FLAG_SYNC)) {
+ gz->crc = crc32(gz->crc, str, len);
+ zstream_run(&gz->z, str, len, (gz->z.flags & GZFILE_FLAG_SYNC)
+ ? Z_SYNC_FLUSH : Z_NO_FLUSH);
+ }
+ gzfile_write_raw(gz);
+}
+
+static long
+gzfile_read_more(gz)
+ struct gzfile *gz;
+{
+ volatile VALUE str;
+
+ while (!ZSTREAM_IS_FINISHED(&gz->z)) {
+ str = gzfile_read_raw(gz);
+ if (NIL_P(str)) {
+ if (!ZSTREAM_IS_FINISHED(&gz->z)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ break;
+ }
+ if (RSTRING(str)->len > 0) { /* prevent Z_BUF_ERROR */
+ zstream_run(&gz->z, RSTRING(str)->ptr, RSTRING(str)->len,
+ Z_SYNC_FLUSH);
+ }
+ if (gz->z.buf_filled > 0) break;
+ }
+ return gz->z.buf_filled;
+}
+
+static void
+gzfile_calc_crc(gz, str)
+ struct gzfile *gz;
+ VALUE str;
+{
+ if (RSTRING(str)->len <= gz->ungetc) {
+ gz->ungetc -= RSTRING(str)->len;
+ }
+ else {
+ gz->crc = crc32(gz->crc, RSTRING(str)->ptr + gz->ungetc,
+ RSTRING(str)->len - gz->ungetc);
+ gz->ungetc = 0;
+ }
+}
+
+static VALUE
+gzfile_read(gz, len)
+ struct gzfile *gz;
+ int len;
+{
+ VALUE dst;
+
+ if (len < 0)
+ rb_raise(rb_eArgError, "negative length %d given", len);
+ if (len == 0)
+ return rb_str_new(0, 0);
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled < len) {
+ gzfile_read_more(gz);
+ }
+ if (GZFILE_IS_FINISHED(gz)) {
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ return Qnil;
+ }
+
+ dst = zstream_shift_buffer(&gz->z, len);
+ gzfile_calc_crc(gz, dst);
+
+ OBJ_TAINT(dst); /* for safe */
+ return dst;
+}
+
+static VALUE
+gzfile_read_all(gz)
+ struct gzfile *gz;
+{
+ VALUE dst;
+
+ while (!ZSTREAM_IS_FINISHED(&gz->z)) {
+ gzfile_read_more(gz);
+ }
+ if (GZFILE_IS_FINISHED(gz)) {
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ return rb_str_new(0, 0);
+ }
+
+ dst = zstream_detach_buffer(&gz->z);
+ gzfile_calc_crc(gz, dst);
+
+ OBJ_TAINT(dst); /* for safe */
+ return dst;
+}
+
+static void
+gzfile_ungetc(gz, c)
+ struct gzfile *gz;
+ int c;
+{
+ zstream_buffer_ungetc(&gz->z, c);
+ gz->ungetc++;
+}
+
+static VALUE
+gzfile_finalize(obj)
+ VALUE obj;
+{
+ struct gzfile *gz = (struct gzfile *)obj;
+ gzfile_write_raw(gz);
+ return Qnil;
+}
+
+static void
+gzfile_writer_end(gz)
+ struct gzfile *gz;
+{
+ int aborted;
+
+ if (ZSTREAM_IS_CLOSED(&gz->z)) return;
+ gz->z.flags |= ZSTREAM_FLAG_CLOSED;
+
+ if (!(gz->z.flags & GZFILE_FLAG_HEADER_FINISHED)) {
+ gzfile_make_header(gz);
+ }
+
+ zstream_run(&gz->z, "", 0, Z_FINISH);
+ gzfile_make_footer(gz);
+
+ if (ZSTREAM_IS_FINALIZE(&gz->z)) {
+ if (NIL_P(gz->io)) return;
+ rb_warn("Zlib::GzipWriter object must be closed explicitly.");
+ if (!SPECIAL_CONST_P(gz->io) && OBJ_IS_FREED(gz->io)) {
+ aborted = 1;
+ }
+ else {
+ rb_protect(gzfile_finalize, (VALUE)gz, &aborted);
+ }
+ if (aborted) {
+ rb_warn("gzip footer is not written; broken gzip file");
+ }
+ zstream_end(&gz->z);
+ return;
+ }
+ gzfile_write_raw(gz);
+ zstream_end(&gz->z);
+}
+
+static void
+gzfile_reader_end(gz)
+ struct gzfile *gz;
+{
+ if (ZSTREAM_IS_CLOSED(&gz->z)) return;
+ gz->z.flags |= ZSTREAM_FLAG_CLOSED;
+
+ if (GZFILE_IS_FINISHED(gz)
+ && !ZSTREAM_IS_FINALIZE(&gz->z)
+ && !(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+
+ zstream_end(&gz->z);
+}
+
+static void
+gzfile_reader_rewind(gz)
+ struct gzfile *gz;
+{
+ long n;
+
+ n = gz->z.stream.total_in;
+ if (!NIL_P(gz->z.input)) {
+ n += RSTRING(gz->z.input)->len;
+ }
+
+ rb_funcall(gz->io, id_seek, 2, rb_int2inum(-n), INT2FIX(1));
+ gzfile_reset(gz);
+}
+
+static VALUE
+gzfile_reader_get_unused(gz)
+ struct gzfile *gz;
+{
+ VALUE str;
+
+ if (!ZSTREAM_IS_READY(&gz->z)) return Qnil;
+ if (!GZFILE_IS_FINISHED(gz)) return Qnil;
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ if (NIL_P(gz->z.input)) return Qnil;
+
+ str = rb_str_dup(gz->z.input);
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+static struct gzfile *
+get_gzfile(obj)
+ VALUE obj;
+{
+ struct gzfile *gz;
+
+ Data_Get_Struct(obj, struct gzfile, gz);
+ if (!ZSTREAM_IS_READY(&gz->z)) {
+ rb_raise(cGzError, "closed gzip stream");
+ }
+ return gz;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::GzipFile
+ *
+ * Zlib::GzipFile is an abstract class for handling a gzip formatted
+ * compressed file. The operations are defined in the subclasses,
+ * Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
+ *
+ * GzipReader should be used by associating an IO, or IO-like, object.
+ */
+
+
+static VALUE
+gzfile_ensure_close(obj)
+ VALUE obj;
+{
+ struct gzfile *gz;
+
+ Data_Get_Struct(obj, struct gzfile, gz);
+ if (ZSTREAM_IS_READY(&gz->z)) {
+ gzfile_close(gz, 1);
+ }
+ return Qnil;
+}
+
+/*
+ * See Zlib::GzipReader#wrap and Zlib::GzipWriter#wrap.
+ */
+static VALUE
+rb_gzfile_s_wrap(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE obj = rb_class_new_instance(argc, argv, klass);
+
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, gzfile_ensure_close, obj);
+ }
+ else {
+ return obj;
+ }
+}
+
+/*
+ * See Zlib::GzipReader#open and Zlib::GzipWriter#open.
+ */
+static VALUE
+gzfile_s_open(argc, argv, klass, mode)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+ const char *mode;
+{
+ VALUE io, filename;
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
+ }
+ filename = argv[0];
+ SafeStringValue(filename);
+ io = rb_file_open(RSTRING(filename)->ptr, mode);
+
+ argv[0] = io;
+ return rb_gzfile_s_wrap(argc, argv, klass);
+}
+
+/*
+ * Same as IO.
+ */
+static VALUE
+rb_gzfile_to_io(obj)
+ VALUE obj;
+{
+ return get_gzfile(obj)->io;
+}
+
+/*
+ * Returns CRC value of the uncompressed data.
+ */
+static VALUE
+rb_gzfile_crc(obj)
+ VALUE obj;
+{
+ return rb_uint2inum(get_gzfile(obj)->crc);
+}
+
+/*
+ * Returns last modification time recorded in the gzip file header.
+ */
+static VALUE
+rb_gzfile_mtime(obj)
+ VALUE obj;
+{
+ return rb_time_new(get_gzfile(obj)->mtime, (time_t)0);
+}
+
+/*
+ * Returns compression level.
+ */
+static VALUE
+rb_gzfile_level(obj)
+ VALUE obj;
+{
+ return INT2FIX(get_gzfile(obj)->level);
+}
+
+/*
+ * Returns OS code number recorded in the gzip file header.
+ */
+static VALUE
+rb_gzfile_os_code(obj)
+ VALUE obj;
+{
+ return INT2FIX(get_gzfile(obj)->os_code);
+}
+
+/*
+ * Returns original filename recorded in the gzip file header, or +nil+ if
+ * original filename is not present.
+ */
+static VALUE
+rb_gzfile_orig_name(obj)
+ VALUE obj;
+{
+ VALUE str = get_gzfile(obj)->orig_name;
+ if (!NIL_P(str)) {
+ str = rb_str_dup(str);
+ }
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+/*
+ * Returns comments recorded in the gzip file header, or nil if the comments
+ * is not present.
+ */
+static VALUE
+rb_gzfile_comment(obj)
+ VALUE obj;
+{
+ VALUE str = get_gzfile(obj)->comment;
+ if (!NIL_P(str)) {
+ str = rb_str_dup(str);
+ }
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_lineno(obj)
+ VALUE obj;
+{
+ return INT2NUM(get_gzfile(obj)->lineno);
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_set_lineno(obj, lineno)
+ VALUE obj, lineno;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ gz->lineno = NUM2INT(lineno);
+ return lineno;
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_set_mtime(obj, mtime)
+ VALUE obj, mtime;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE val;
+
+ if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) {
+ rb_raise(cGzError, "header is already written");
+ }
+
+ if (FIXNUM_P(time)) {
+ gz->mtime = FIX2INT(mtime);
+ }
+ else {
+ val = rb_Integer(mtime);
+ gz->mtime = FIXNUM_P(val) ? FIX2INT(val) : rb_big2ulong(val);
+ }
+ return mtime;
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_set_orig_name(obj, str)
+ VALUE obj, str;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE s;
+ char *p;
+
+ if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) {
+ rb_raise(cGzError, "header is already written");
+ }
+ s = rb_str_dup(rb_str_to_str(str));
+ p = memchr(RSTRING(s)->ptr, '\0', RSTRING(s)->len);
+ if (p) {
+ rb_str_resize(s, p - RSTRING(s)->ptr);
+ }
+ gz->orig_name = s;
+ return str;
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_set_comment(obj, str)
+ VALUE obj, str;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE s;
+ char *p;
+
+ if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) {
+ rb_raise(cGzError, "header is already written");
+ }
+ s = rb_str_dup(rb_str_to_str(str));
+ p = memchr(RSTRING(s)->ptr, '\0', RSTRING(s)->len);
+ if (p) {
+ rb_str_resize(s, p - RSTRING(s)->ptr);
+ }
+ gz->comment = s;
+ return str;
+}
+
+/*
+ * Closes the GzipFile object. This method calls close method of the
+ * associated IO object. Returns the associated IO object.
+ */
+static VALUE
+rb_gzfile_close(obj)
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE io;
+
+ io = gz->io;
+ gzfile_close(gz, 1);
+ return io;
+}
+
+/*
+ * Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never
+ * calls the close method of the associated IO object. Returns the associated IO
+ * object.
+ */
+static VALUE
+rb_gzfile_finish(obj)
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE io;
+
+ io = gz->io;
+ gzfile_close(gz, 0);
+ return io;
+}
+
+/*
+ * Same as IO.
+ */
+static VALUE
+rb_gzfile_closed_p(obj)
+ VALUE obj;
+{
+ struct gzfile *gz;
+ Data_Get_Struct(obj, struct gzfile, gz);
+ return NIL_P(gz->io) ? Qtrue : Qfalse;
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_eof_p(obj)
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ return GZFILE_IS_FINISHED(gz) ? Qtrue : Qfalse;
+}
+
+/*
+ * Same as IO.
+ */
+static VALUE
+rb_gzfile_sync(obj)
+ VALUE obj;
+{
+ return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq: sync = flag
+ *
+ * Same as IO. If flag is +true+, the associated IO object must respond to the
+ * +flush+ method. While +sync+ mode is +true+, the compression ratio
+ * decreases sharply.
+ */
+static VALUE
+rb_gzfile_set_sync(obj, mode)
+ VALUE obj, mode;
+{
+ struct gzfile *gz = get_gzfile(obj);
+
+ if (RTEST(mode)) {
+ gz->z.flags |= GZFILE_FLAG_SYNC;
+ }
+ else {
+ gz->z.flags &= ~GZFILE_FLAG_SYNC;
+ }
+ return mode;
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_total_in(obj)
+ VALUE obj;
+{
+ return rb_uint2inum(get_gzfile(obj)->z.stream.total_in);
+}
+
+/*
+ * ???
+ */
+static VALUE
+rb_gzfile_total_out(obj)
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ return rb_uint2inum(gz->z.stream.total_out - gz->z.buf_filled);
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::GzipWriter
+ *
+ * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
+ * be used with an instance of IO, or IO-like, object.
+ *
+ * For example:
+ *
+ * Zlib::GzipWriter.open('hoge.gz') do |gz|
+ * gz.write 'jugemu jugemu gokou no surikire...'
+ * end
+ *
+ * File.open('hoge.gz', 'w') do |f|
+ * gz = Zlib::GzipWriter.new(f)
+ * gz.write 'jugemu jugemu gokou no surikire...'
+ * gz.close
+ * end
+ *
+ * # TODO: test these. Are they equivalent? Can GzipWriter.new take a
+ * # block?
+ *
+ * NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
+ * GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
+ * will be not able to write the gzip footer and will generate a broken gzip
+ * file.
+ */
+
+static VALUE
+rb_gzwriter_s_allocate(klass)
+ VALUE klass;
+{
+ return gzfile_writer_new(klass);
+}
+
+/*
+ * call-seq: Zlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
+ *
+ * Opens a file specified by +filename+ for writing gzip compressed data, and
+ * returns a GzipWriter object associated with that file. Further details of
+ * this method are found in Zlib::GzipWriter.new and Zlib::GzipWriter#wrap.
+ */
+static VALUE
+rb_gzwriter_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ return gzfile_s_open(argc, argv, klass, "wb");
+}
+
+/*
+ * call-seq: Zlib::GzipWriter.new(io, level, strategy)
+ *
+ * Creates a GzipWriter object associated with +io+. +level+ and +strategy+
+ * should be the same as the arguments of Zlib::Deflate.new. The GzipWriter
+ * object writes gzipped data to +io+. At least, +io+ must respond to the
+ * +write+ method that behaves same as write method in IO class.
+ */
+static VALUE
+rb_gzwriter_initialize(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct gzfile *gz;
+ VALUE io, level, strategy;
+ int err;
+
+ rb_scan_args(argc, argv, "12", &io, &level, &strategy);
+ Data_Get_Struct(obj, struct gzfile, gz);
+
+ /* this is undocumented feature of zlib */
+ gz->level = ARG_LEVEL(level);
+ err = deflateInit2(&gz->z.stream, gz->level, Z_DEFLATED,
+ -MAX_WBITS, DEF_MEM_LEVEL, ARG_STRATEGY(strategy));
+ if (err != Z_OK) {
+ raise_zlib_error(err, gz->z.stream.msg);
+ }
+ gz->io = io;
+ ZSTREAM_READY(&gz->z);
+
+ return obj;
+}
+
+/*
+ * call-seq: flush(flush=nil)
+ *
+ * Flushes all the internal buffers of the GzipWriter object. The meaning of
+ * +flush+ is same as in Zlib::Deflate#deflate. <tt>Zlib::SYNC_FLUSH</tt> is used if
+ * +flush+ is omitted. It is no use giving flush <tt>Zlib::NO_FLUSH</tt>.
+ */
+static VALUE
+rb_gzwriter_flush(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE v_flush;
+ int flush;
+
+ rb_scan_args(argc, argv, "01", &v_flush);
+
+ flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
+ if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
+ zstream_run(&gz->z, "", 0, flush);
+ }
+
+ gzfile_write_raw(gz);
+ if (rb_respond_to(gz->io, id_flush)) {
+ rb_funcall(gz->io, id_flush, 0);
+ }
+ return obj;
+}
+
+/*
+ * Same as IO.
+ */
+static VALUE
+rb_gzwriter_write(obj, str)
+ VALUE obj, str;
+{
+ struct gzfile *gz = get_gzfile(obj);
+
+ if (TYPE(str) != T_STRING) {
+ str = rb_obj_as_string(str);
+ }
+ gzfile_write(gz, RSTRING(str)->ptr, RSTRING(str)->len);
+ return INT2FIX(RSTRING(str)->len);
+}
+
+/*
+ * Same as IO.
+ */
+static VALUE
+rb_gzwriter_putc(obj, ch)
+ VALUE obj, ch;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ char c = NUM2CHR(ch);
+
+ gzfile_write(gz, &c, 1);
+ return ch;
+}
+
+
+
+/*
+ * Document-method: <<
+ * Same as IO.
+ */
+#define rb_gzwriter_addstr rb_io_addstr
+/*
+ * Document-method: printf
+ * Same as IO.
+ */
+#define rb_gzwriter_printf rb_io_printf
+/*
+ * Document-method: print
+ * Same as IO.
+ */
+#define rb_gzwriter_print rb_io_print
+/*
+ * Document-method: puts
+ * Same as IO.
+ */
+#define rb_gzwriter_puts rb_io_puts
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::GzipReader
+ *
+ * Zlib::GzipReader is the class for reading a gzipped file. GzipReader should
+ * be used an IO, or -IO-lie, object.
+ *
+ * Zlib::GzipReader.open('hoge.gz') {|gz|
+ * print gz.read
+ * }
+ *
+ * File.open('hoge.gz') do |f|
+ * gz = Zlib::GzipReader.new(f)
+ * print gz.read
+ * gz.close
+ * end
+ *
+ * # TODO: test these. Are they equivalent? Can GzipReader.new take a
+ * # block?
+ *
+ * == Method Catalogue
+ *
+ * The following methods in Zlib::GzipReader are just like their counterparts
+ * in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
+ * error was found in the gzip file.
+ * - #each
+ * - #each_line
+ * - #each_byte
+ * - #gets
+ * - #getc
+ * - #lineno
+ * - #lineno=
+ * - #read
+ * - #readchar
+ * - #readline
+ * - #readlines
+ * - #ungetc
+ *
+ * Be careful of the footer of the gzip file. A gzip file has the checksum of
+ * pre-compressed data in its footer. GzipReader checks all uncompressed data
+ * against that checksum at the following cases, and if it fails, raises
+ * <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or
+ * <tt>Zlib::GzipFile::LengthError</tt> exception.
+ *
+ * - When an reading request is received beyond the end of file (the end of
+ * compressed data). That is, when Zlib::GzipReader#read,
+ * Zlib::GzipReader#gets, or some other methods for reading returns nil.
+ * - When Zlib::GzipFile#close method is called after the object reaches the
+ * end of file.
+ * - When Zlib::GzipReader#unused method is called after the object reaches
+ * the end of file.
+ *
+ * The rest of the methods are adequately described in their own
+ * documentation.
+ */
+
+static VALUE
+rb_gzreader_s_allocate(klass)
+ VALUE klass;
+{
+ return gzfile_reader_new(klass);
+}
+
+/*
+ * call-seq: Zlib::GzipReader.open(filename) {|gz| ... }
+ *
+ * Opens a file specified by +filename+ as a gzipped file, and returns a
+ * GzipReader object associated with that file. Further details of this method
+ * are in Zlib::GzipReader.new and ZLib::GzipReader.wrap.
+ */
+static VALUE
+rb_gzreader_s_open(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ return gzfile_s_open(argc, argv, klass, "rb");
+}
+
+/*
+ * call-seq: Zlib::GzipReader.new(io)
+ *
+ * Creates a GzipReader object associated with +io+. The GzipReader object reads
+ * gzipped data from +io+, and parses/decompresses them. At least, +io+ must have
+ * a +read+ method that behaves same as the +read+ method in IO class.
+ *
+ * If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
+ * exception.
+ */
+static VALUE
+rb_gzreader_initialize(obj, io)
+ VALUE obj, io;
+{
+ struct gzfile *gz;
+ int err;
+
+ Data_Get_Struct(obj, struct gzfile, gz);
+
+ /* this is undocumented feature of zlib */
+ err = inflateInit2(&gz->z.stream, -MAX_WBITS);
+ if (err != Z_OK) {
+ raise_zlib_error(err, gz->z.stream.msg);
+ }
+ gz->io = io;
+ ZSTREAM_READY(&gz->z);
+ gzfile_read_header(gz);
+
+ return obj;
+}
+
+/*
+ * Resets the position of the file pointer to the point created the GzipReader
+ * object. The associated IO object needs to respond to the +seek+ method.
+ */
+static VALUE
+rb_gzreader_rewind(obj)
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ gzfile_reader_rewind(gz);
+ return INT2FIX(0);
+}
+
+/*
+ * Returns the rest of the data which had read for parsing gzip format, or
+ * +nil+ if the whole gzip file is not parsed yet.
+ */
+static VALUE
+rb_gzreader_unused(obj)
+ VALUE obj;
+{
+ struct gzfile *gz;
+ Data_Get_Struct(obj, struct gzfile, gz);
+ return gzfile_reader_get_unused(gz);
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_read(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE vlen;
+ int len;
+
+ rb_scan_args(argc, argv, "01", &vlen);
+ if (NIL_P(vlen)) {
+ return gzfile_read_all(gz);
+ }
+
+ len = NUM2INT(vlen);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative length %d given", len);
+ }
+ return gzfile_read(gz, len);
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_getc(obj)
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE dst;
+
+ dst = gzfile_read(gz, 1);
+ if (!NIL_P(dst)) {
+ dst = INT2FIX((unsigned int)(RSTRING(dst)->ptr[0]) & 0xff);
+ }
+ return dst;
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_readchar(obj)
+ VALUE obj;
+{
+ VALUE dst;
+ dst = rb_gzreader_getc(obj);
+ if (NIL_P(dst)) {
+ rb_raise(rb_eEOFError, "End of file reached");
+ }
+ return dst;
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_each_byte(obj)
+ VALUE obj;
+{
+ VALUE c;
+ while (!NIL_P(c = rb_gzreader_getc(obj))) {
+ rb_yield(c);
+ }
+ return Qnil;
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_ungetc(obj, ch)
+ VALUE obj, ch;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ gzfile_ungetc(gz, NUM2CHR(ch));
+ return Qnil;
+}
+
+static void
+gzreader_skip_linebreaks(gz)
+ struct gzfile *gz;
+{
+ VALUE str;
+ char *p;
+ int n;
+
+ while (gz->z.buf_filled == 0) {
+ if (GZFILE_IS_FINISHED(gz)) return;
+ gzfile_read_more(gz);
+ }
+ n = 0;
+ p = RSTRING(gz->z.buf)->ptr;
+
+ while (n++, *(p++) == '\n') {
+ if (n >= gz->z.buf_filled) {
+ str = zstream_detach_buffer(&gz->z);
+ gzfile_calc_crc(gz, str);
+ while (gz->z.buf_filled == 0) {
+ if (GZFILE_IS_FINISHED(gz)) return;
+ gzfile_read_more(gz);
+ }
+ n = 0;
+ p = RSTRING(gz->z.buf)->ptr;
+ }
+ }
+
+ str = zstream_shift_buffer(&gz->z, n - 1);
+ gzfile_calc_crc(gz, str);
+}
+
+static void
+rscheck(rsptr, rslen, rs)
+ char *rsptr;
+ long rslen;
+ VALUE rs;
+{
+ if (RSTRING(rs)->ptr != rsptr && RSTRING(rs)->len != rslen)
+ rb_raise(rb_eRuntimeError, "rs modified");
+}
+
+static VALUE
+gzreader_gets(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct gzfile *gz = get_gzfile(obj);
+ volatile VALUE rs;
+ VALUE dst;
+ char *rsptr, *p, *res;
+ long rslen, n;
+ int rspara;
+
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
+ if (!NIL_P(rs)) {
+ Check_Type(rs, T_STRING);
+ }
+ }
+
+ if (NIL_P(rs)) {
+ dst = gzfile_read_all(gz);
+ if (RSTRING(dst)->len != 0) gz->lineno++;
+ return dst;
+ }
+
+ if (RSTRING(rs)->len == 0) {
+ rsptr = "\n\n";
+ rslen = 2;
+ rspara = 1;
+ } else {
+ rsptr = RSTRING(rs)->ptr;
+ rslen = RSTRING(rs)->len;
+ rspara = 0;
+ }
+
+ if (rspara) {
+ gzreader_skip_linebreaks(gz);
+ }
+
+ while (gz->z.buf_filled < rslen) {
+ if (ZSTREAM_IS_FINISHED(&gz->z)) {
+ if (gz->z.buf_filled > 0) gz->lineno++;
+ return gzfile_read(gz, rslen);
+ }
+ gzfile_read_more(gz);
+ }
+
+ p = RSTRING(gz->z.buf)->ptr;
+ n = rslen;
+ for (;;) {
+ if (n > gz->z.buf_filled) {
+ if (ZSTREAM_IS_FINISHED(&gz->z)) break;
+ gzfile_read_more(gz);
+ p = RSTRING(gz->z.buf)->ptr + n - rslen;
+ }
+ if (!rspara) rscheck(rsptr, rslen, rs);
+ res = memchr(p, rsptr[0], (gz->z.buf_filled - n + 1));
+ if (!res) {
+ n = gz->z.buf_filled + 1;
+ } else {
+ n += (long)(res - p);
+ p = res;
+ if (rslen == 1 || memcmp(p, rsptr, rslen) == 0) break;
+ p++, n++;
+ }
+ }
+
+ gz->lineno++;
+ dst = gzfile_read(gz, n);
+ if (rspara) {
+ gzreader_skip_linebreaks(gz);
+ }
+
+ return dst;
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_gets(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE dst;
+ dst = gzreader_gets(argc, argv, obj);
+ if (!NIL_P(dst)) {
+ rb_lastline_set(dst);
+ }
+ return dst;
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_readline(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE dst;
+ dst = rb_gzreader_gets(argc, argv, obj);
+ if (NIL_P(dst)) {
+ rb_raise(rb_eEOFError, "End of file reached");
+ }
+ return dst;
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_each(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE str;
+ while (!NIL_P(str = gzreader_gets(argc, argv, obj))) {
+ rb_yield(str);
+ }
+ return obj;
+}
+
+/*
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_readlines(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ VALUE str, dst;
+ dst = rb_ary_new();
+ while (!NIL_P(str = gzreader_gets(argc, argv, obj))) {
+ rb_ary_push(dst, str);
+ }
+ return dst;
+}
+
+#endif /* GZIP_SUPPORT */
+
+
+
+/*
+ * The Zlib module contains several classes for compressing and decompressing
+ * streams, and for working with "gzip" files.
+ *
+ * == Classes
+ *
+ * Following are the classes that are most likely to be of interest to the
+ * user:
+ * Zlib::Inflate
+ * Zlib::Deflate
+ * Zlib::GzipReader
+ * Zlib::GzipWriter
+ *
+ * There are two important base classes for the classes above: Zlib::ZStream
+ * and Zlib::GzipFile. Everything else is an error class.
+ *
+ * == Constants
+ *
+ * Here's a list.
+ *
+ * Zlib::VERSION
+ * The Ruby/zlib version string.
+ *
+ * Zlib::ZLIB_VERSION
+ * The string which represents the version of zlib.h.
+ *
+ * Zlib::BINARY
+ * Zlib::ASCII
+ * Zlib::UNKNOWN
+ * The integers representing data types which Zlib::ZStream#data_type
+ * method returns.
+ *
+ * Zlib::NO_COMPRESSION
+ * Zlib::BEST_SPEED
+ * Zlib::BEST_COMPRESSION
+ * Zlib::DEFAULT_COMPRESSION
+ * The integers representing compression levels which are an argument
+ * for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on.
+ *
+ * Zlib::FILTERED
+ * Zlib::HUFFMAN_ONLY
+ * Zlib::DEFAULT_STRATEGY
+ * The integers representing compression methods which are an argument
+ * for Zlib::Deflate.new and Zlib::Deflate#params.
+ *
+ * Zlib::DEF_MEM_LEVEL
+ * Zlib::MAX_MEM_LEVEL
+ * The integers representing memory levels which are an argument for
+ * Zlib::Deflate.new, Zlib::Deflate#params, and so on.
+ *
+ * Zlib::MAX_WBITS
+ * The default value of windowBits which is an argument for
+ * Zlib::Deflate.new and Zlib::Inflate.new.
+ *
+ * Zlib::NO_FLUSH
+ * Zlib::SYNC_FLUSH
+ * Zlib::FULL_FLUSH
+ * Zlib::FINISH
+ * The integers to control the output of the deflate stream, which are
+ * an argument for Zlib::Deflate#deflate and so on.
+ *
+ * Zlib::OS_CODE
+ * Zlib::OS_MSDOS
+ * Zlib::OS_AMIGA
+ * Zlib::OS_VMS
+ * Zlib::OS_UNIX
+ * Zlib::OS_VMCMS
+ * Zlib::OS_ATARI
+ * Zlib::OS_OS2
+ * Zlib::OS_MACOS
+ * Zlib::OS_ZSYSTEM
+ * Zlib::OS_CPM
+ * Zlib::OS_TOPS20
+ * Zlib::OS_WIN32
+ * Zlib::OS_QDOS
+ * Zlib::OS_RISCOS
+ * Zlib::OS_UNKNOWN
+ * The return values of Zlib::GzipFile#os_code method.
+ */
+void Init_zlib()
+{
+ VALUE mZlib, cZStream, cDeflate, cInflate;
+#if GZIP_SUPPORT
+ VALUE cGzipFile, cGzipWriter, cGzipReader;
+#endif
+
+ mZlib = rb_define_module("Zlib");
+
+ cZError = rb_define_class_under(mZlib, "Error", rb_eStandardError);
+ cStreamEnd = rb_define_class_under(mZlib, "StreamEnd", cZError);
+ cNeedDict = rb_define_class_under(mZlib, "NeedDict", cZError);
+ cDataError = rb_define_class_under(mZlib, "DataError", cZError);
+ cStreamError = rb_define_class_under(mZlib, "StreamError", cZError);
+ cMemError = rb_define_class_under(mZlib, "MemError", cZError);
+ cBufError = rb_define_class_under(mZlib, "BufError", cZError);
+ cVersionError = rb_define_class_under(mZlib, "VersionError", cZError);
+
+ rb_define_module_function(mZlib, "zlib_version", rb_zlib_version, 0);
+ rb_define_module_function(mZlib, "adler32", rb_zlib_adler32, -1);
+ rb_define_module_function(mZlib, "crc32", rb_zlib_crc32, -1);
+ rb_define_module_function(mZlib, "crc_table", rb_zlib_crc_table, 0);
+
+ rb_define_const(mZlib, "VERSION", rb_str_new2(RUBY_ZLIB_VERSION));
+ rb_define_const(mZlib, "ZLIB_VERSION", rb_str_new2(ZLIB_VERSION));
+
+ cZStream = rb_define_class_under(mZlib, "ZStream", rb_cObject);
+ rb_undef_alloc_func(cZStream);
+ rb_define_method(cZStream, "avail_out", rb_zstream_avail_out, 0);
+ rb_define_method(cZStream, "avail_out=", rb_zstream_set_avail_out, 1);
+ rb_define_method(cZStream, "avail_in", rb_zstream_avail_in, 0);
+ rb_define_method(cZStream, "total_in", rb_zstream_total_in, 0);
+ rb_define_method(cZStream, "total_out", rb_zstream_total_out, 0);
+ rb_define_method(cZStream, "data_type", rb_zstream_data_type, 0);
+ rb_define_method(cZStream, "adler", rb_zstream_adler, 0);
+ rb_define_method(cZStream, "finished?", rb_zstream_finished_p, 0);
+ rb_define_method(cZStream, "stream_end?", rb_zstream_finished_p, 0);
+ rb_define_method(cZStream, "closed?", rb_zstream_closed_p, 0);
+ rb_define_method(cZStream, "ended?", rb_zstream_closed_p, 0);
+ rb_define_method(cZStream, "close", rb_zstream_end, 0);
+ rb_define_method(cZStream, "end", rb_zstream_end, 0);
+ rb_define_method(cZStream, "reset", rb_zstream_reset, 0);
+ rb_define_method(cZStream, "finish", rb_zstream_finish, 0);
+ rb_define_method(cZStream, "flush_next_in", rb_zstream_flush_next_in, 0);
+ rb_define_method(cZStream, "flush_next_out", rb_zstream_flush_next_out, 0);
+
+ rb_define_const(mZlib, "BINARY", INT2FIX(Z_BINARY));
+ rb_define_const(mZlib, "ASCII", INT2FIX(Z_ASCII));
+ rb_define_const(mZlib, "UNKNOWN", INT2FIX(Z_UNKNOWN));
+
+ cDeflate = rb_define_class_under(mZlib, "Deflate", cZStream);
+ rb_define_singleton_method(cDeflate, "deflate", rb_deflate_s_deflate, -1);
+ rb_define_alloc_func(cDeflate, rb_deflate_s_allocate);
+ rb_define_method(cDeflate, "initialize", rb_deflate_initialize, -1);
+ rb_define_method(cDeflate, "clone", rb_deflate_clone, 0);
+ rb_define_method(cDeflate, "deflate", rb_deflate_deflate, -1);
+ rb_define_method(cDeflate, "<<", rb_deflate_addstr, 1);
+ rb_define_method(cDeflate, "flush", rb_deflate_flush, -1);
+ rb_define_method(cDeflate, "params", rb_deflate_params, 2);
+ rb_define_method(cDeflate, "set_dictionary", rb_deflate_set_dictionary, 1);
+
+ cInflate = rb_define_class_under(mZlib, "Inflate", cZStream);
+ rb_define_singleton_method(cInflate, "inflate", rb_inflate_s_inflate, 1);
+ rb_define_alloc_func(cInflate, rb_inflate_s_allocate);
+ rb_define_method(cInflate, "initialize", rb_inflate_initialize, -1);
+ rb_define_method(cInflate, "inflate", rb_inflate_inflate, 1);
+ rb_define_method(cInflate, "<<", rb_inflate_addstr, 1);
+ rb_define_method(cInflate, "sync", rb_inflate_sync, 1);
+ rb_define_method(cInflate, "sync_point?", rb_inflate_sync_point_p, 0);
+ rb_define_method(cInflate, "set_dictionary", rb_inflate_set_dictionary, 1);
+
+ rb_define_const(mZlib, "NO_COMPRESSION", INT2FIX(Z_NO_COMPRESSION));
+ rb_define_const(mZlib, "BEST_SPEED", INT2FIX(Z_BEST_SPEED));
+ rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(Z_BEST_COMPRESSION));
+ rb_define_const(mZlib, "DEFAULT_COMPRESSION",
+ INT2FIX(Z_DEFAULT_COMPRESSION));
+
+ rb_define_const(mZlib, "FILTERED", INT2FIX(Z_FILTERED));
+ rb_define_const(mZlib, "HUFFMAN_ONLY", INT2FIX(Z_HUFFMAN_ONLY));
+ rb_define_const(mZlib, "DEFAULT_STRATEGY", INT2FIX(Z_DEFAULT_STRATEGY));
+
+ rb_define_const(mZlib, "MAX_WBITS", INT2FIX(MAX_WBITS));
+ rb_define_const(mZlib, "DEF_MEM_LEVEL", INT2FIX(DEF_MEM_LEVEL));
+ rb_define_const(mZlib, "MAX_MEM_LEVEL", INT2FIX(MAX_MEM_LEVEL));
+
+ rb_define_const(mZlib, "NO_FLUSH", INT2FIX(Z_NO_FLUSH));
+ rb_define_const(mZlib, "SYNC_FLUSH", INT2FIX(Z_SYNC_FLUSH));
+ rb_define_const(mZlib, "FULL_FLUSH", INT2FIX(Z_FULL_FLUSH));
+ rb_define_const(mZlib, "FINISH", INT2FIX(Z_FINISH));
+
+#if GZIP_SUPPORT
+ id_write = rb_intern("write");
+ id_read = rb_intern("read");
+ id_flush = rb_intern("flush");
+ id_seek = rb_intern("seek");
+ id_close = rb_intern("close");
+
+ cGzipFile = rb_define_class_under(mZlib, "GzipFile", rb_cObject);
+ cGzError = rb_define_class_under(cGzipFile, "Error", cZError);
+
+ cNoFooter = rb_define_class_under(cGzipFile, "NoFooter", cGzError);
+ cCRCError = rb_define_class_under(cGzipFile, "CRCError", cGzError);
+ cLengthError = rb_define_class_under(cGzipFile,"LengthError",cGzError);
+
+ cGzipWriter = rb_define_class_under(mZlib, "GzipWriter", cGzipFile);
+ cGzipReader = rb_define_class_under(mZlib, "GzipReader", cGzipFile);
+ rb_include_module(cGzipReader, rb_mEnumerable);
+
+ rb_define_singleton_method(cGzipFile, "wrap", rb_gzfile_s_wrap, -1);
+ rb_undef_alloc_func(cGzipFile);
+ rb_define_method(cGzipFile, "to_io", rb_gzfile_to_io, 0);
+ rb_define_method(cGzipFile, "crc", rb_gzfile_crc, 0);
+ rb_define_method(cGzipFile, "mtime", rb_gzfile_mtime, 0);
+ rb_define_method(cGzipFile, "level", rb_gzfile_level, 0);
+ rb_define_method(cGzipFile, "os_code", rb_gzfile_os_code, 0);
+ rb_define_method(cGzipFile, "orig_name", rb_gzfile_orig_name, 0);
+ rb_define_method(cGzipFile, "comment", rb_gzfile_comment, 0);
+ rb_define_method(cGzipReader, "lineno", rb_gzfile_lineno, 0);
+ rb_define_method(cGzipReader, "lineno=", rb_gzfile_set_lineno, 1);
+ rb_define_method(cGzipWriter, "mtime=", rb_gzfile_set_mtime, 1);
+ rb_define_method(cGzipWriter, "orig_name=", rb_gzfile_set_orig_name,1);
+ rb_define_method(cGzipWriter, "comment=", rb_gzfile_set_comment, 1);
+ rb_define_method(cGzipFile, "close", rb_gzfile_close, 0);
+ rb_define_method(cGzipFile, "finish", rb_gzfile_finish, 0);
+ rb_define_method(cGzipFile, "closed?", rb_gzfile_closed_p, 0);
+ rb_define_method(cGzipReader, "eof", rb_gzfile_eof_p, 0);
+ rb_define_method(cGzipReader, "eof?", rb_gzfile_eof_p, 0);
+ rb_define_method(cGzipFile, "sync", rb_gzfile_sync, 0);
+ rb_define_method(cGzipFile, "sync=", rb_gzfile_set_sync, 1);
+ rb_define_method(cGzipReader, "pos", rb_gzfile_total_out, 0);
+ rb_define_method(cGzipWriter, "pos", rb_gzfile_total_in, 0);
+ rb_define_method(cGzipReader, "tell", rb_gzfile_total_out, 0);
+ rb_define_method(cGzipWriter, "tell", rb_gzfile_total_in, 0);
+
+ rb_define_singleton_method(cGzipWriter, "open", rb_gzwriter_s_open,-1);
+ rb_define_alloc_func(cGzipWriter, rb_gzwriter_s_allocate);
+ rb_define_method(cGzipWriter, "initialize", rb_gzwriter_initialize,-1);
+ rb_define_method(cGzipWriter, "flush", rb_gzwriter_flush, -1);
+ rb_define_method(cGzipWriter, "write", rb_gzwriter_write, 1);
+ rb_define_method(cGzipWriter, "putc", rb_gzwriter_putc, 1);
+ rb_define_method(cGzipWriter, "<<", rb_gzwriter_addstr, 1);
+ rb_define_method(cGzipWriter, "printf", rb_gzwriter_printf, -1);
+ rb_define_method(cGzipWriter, "print", rb_gzwriter_print, -1);
+ rb_define_method(cGzipWriter, "puts", rb_gzwriter_puts, -1);
+
+ rb_define_singleton_method(cGzipReader, "open", rb_gzreader_s_open,-1);
+ rb_define_alloc_func(cGzipReader, rb_gzreader_s_allocate);
+ rb_define_method(cGzipReader, "initialize", rb_gzreader_initialize, 1);
+ rb_define_method(cGzipReader, "rewind", rb_gzreader_rewind, 0);
+ rb_define_method(cGzipReader, "unused", rb_gzreader_unused, 0);
+ rb_define_method(cGzipReader, "read", rb_gzreader_read, -1);
+ rb_define_method(cGzipReader, "getc", rb_gzreader_getc, 0);
+ rb_define_method(cGzipReader, "readchar", rb_gzreader_readchar, 0);
+ rb_define_method(cGzipReader, "each_byte", rb_gzreader_each_byte, 0);
+ rb_define_method(cGzipReader, "ungetc", rb_gzreader_ungetc, 1);
+ rb_define_method(cGzipReader, "gets", rb_gzreader_gets, -1);
+ rb_define_method(cGzipReader, "readline", rb_gzreader_readline, -1);
+ rb_define_method(cGzipReader, "each", rb_gzreader_each, -1);
+ rb_define_method(cGzipReader, "each_line", rb_gzreader_each, -1);
+ rb_define_method(cGzipReader, "readlines", rb_gzreader_readlines, -1);
+
+ rb_define_const(mZlib, "OS_CODE", INT2FIX(OS_CODE));
+ rb_define_const(mZlib, "OS_MSDOS", INT2FIX(OS_MSDOS));
+ rb_define_const(mZlib, "OS_AMIGA", INT2FIX(OS_AMIGA));
+ rb_define_const(mZlib, "OS_VMS", INT2FIX(OS_VMS));
+ rb_define_const(mZlib, "OS_UNIX", INT2FIX(OS_UNIX));
+ rb_define_const(mZlib, "OS_ATARI", INT2FIX(OS_ATARI));
+ rb_define_const(mZlib, "OS_OS2", INT2FIX(OS_OS2));
+ rb_define_const(mZlib, "OS_MACOS", INT2FIX(OS_MACOS));
+ rb_define_const(mZlib, "OS_TOPS20", INT2FIX(OS_TOPS20));
+ rb_define_const(mZlib, "OS_WIN32", INT2FIX(OS_WIN32));
+
+ rb_define_const(mZlib, "OS_VMCMS", INT2FIX(OS_VMCMS));
+ rb_define_const(mZlib, "OS_ZSYSTEM", INT2FIX(OS_ZSYSTEM));
+ rb_define_const(mZlib, "OS_CPM", INT2FIX(OS_CPM));
+ rb_define_const(mZlib, "OS_QDOS", INT2FIX(OS_QDOS));
+ rb_define_const(mZlib, "OS_RISCOS", INT2FIX(OS_RISCOS));
+ rb_define_const(mZlib, "OS_UNKNOWN", INT2FIX(OS_UNKNOWN));
+
+#endif /* GZIP_SUPPORT */
+}
+
+/* Document error classes. */
+
+/*
+ * Document-class: Zlib::Error
+ *
+ * The superclass for all exceptions raised by Ruby/zlib.
+ *
+ * The following exceptions are defined as subclasses of Zlib::Error. These
+ * exceptions are raised when zlib library functions return with an error
+ * status.
+ *
+ * - Zlib::StreamEnd
+ * - Zlib::NeedDict
+ * - Zlib::DataError
+ * - Zlib::StreamError
+ * - Zlib::MemError
+ * - Zlib::BufError
+ * - Zlib::VersionError
+ *
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::Error
+ *
+ * Base class of errors that occur when processing GZIP files.
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::NoFooter
+ *
+ * Raised when gzip file footer is not found.
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::CRCError
+ *
+ * Raised when the CRC checksum recorded in gzip file footer is not equivalent
+ * to the CRC checksum of the actual uncompressed data.
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::LengthError
+ *
+ * Raised when the data length recorded in the gzip file footer is not equivalent
+ * to the length of the actual uncompressed data.
+ */
+
+
diff --git a/file.c b/file.c
index af18b88fba..066745ca6a 100644
--- a/file.c
+++ b/file.c
@@ -6,19 +6,20 @@
$Date$
created at: Mon Nov 15 12:24:34 JST 1993
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
-#ifdef NT
+#ifdef _WIN32
#include "missing/file.h"
#endif
#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
+#include "util.h"
#include "dln.h"
#ifdef HAVE_UNISTD_H
@@ -33,26 +34,19 @@ int flock _((int, int));
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
-#else
+#endif
+#ifndef MAXPATHLEN
# define MAXPATHLEN 1024
#endif
#include <time.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#else
-#ifndef NT
-struct timeval {
- long tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
-};
-#endif /* NT */
-#endif
VALUE rb_time_new _((time_t, time_t));
#ifdef HAVE_UTIME_H
#include <utime.h>
+#elif defined HAVE_SYS_UTIME_H
+#include <sys/utime.h>
#endif
#ifdef HAVE_PWD_H
@@ -66,62 +60,75 @@ char *strrchr _((const char*,const char));
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_MKDEV_H
+#include <sys/mkdev.h>
+#endif
+
#ifndef HAVE_LSTAT
-#define lstat rb_sys_stat
+#define lstat(path,st) stat(path,st)
#endif
-
+#if !HAVE_FSEEKO && !defined(fseeko)
+# define fseeko fseek
+#endif
+
VALUE rb_cFile;
VALUE rb_mFileTest;
static VALUE rb_cStat;
-static int
+static long
apply2files(func, vargs, arg)
- int (*func)();
+ void (*func)();
VALUE vargs;
void *arg;
{
- int i;
+ long i;
VALUE path;
struct RArray *args = RARRAY(vargs);
for (i=0; i<args->len; i++) {
- Check_SafeStr(args->ptr[i]);
- }
-
- for (i=0; i<args->len; i++) {
path = args->ptr[i];
- if ((*func)(RSTRING(path)->ptr, arg) < 0)
- rb_sys_fail(RSTRING(path)->ptr);
+ SafeStringValue(path);
+ (*func)(StringValueCStr(path), arg);
}
return args->len;
}
+/*
+ * call-seq:
+ * file.path -> file_ame
+ *
+ * Returns the pathname used to create <i>file</i> as a string. Does
+ * not normalize the name.
+ *
+ * File.new("testfile").path #=> "testfile"
+ * File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
+ *
+ */
+
static VALUE
rb_file_path(obj)
VALUE obj;
{
OpenFile *fptr;
- GetOpenFile(obj, fptr);
+ fptr = RFILE(rb_io_taint_check(obj))->fptr;
+ rb_io_check_initialized(fptr);
if (!fptr->path) return Qnil;
- return rb_str_new2(fptr->path);
+ return rb_tainted_str_new2(fptr->path);
}
-#ifdef NT
-#include "missing/file.h"
-#endif
-
static VALUE
stat_new_0(klass, st)
VALUE klass;
struct stat *st;
{
- struct stat *nst;
- if (!st) rb_bug("stat_new() called with bad value");
+ struct stat *nst = 0;
- nst = ALLOC(struct stat);
- *nst = *st;
+ if (st) {
+ nst = ALLOC(struct stat);
+ *nst = *st;
+ }
return Data_Wrap_Struct(klass, NULL, free, nst);
}
@@ -138,24 +145,50 @@ get_stat(self)
{
struct stat* st;
Data_Get_Struct(self, struct stat, st);
- if (!st) rb_bug("collapsed File::Stat");
+ if (!st) rb_raise(rb_eTypeError, "uninitialized File::Stat");
return st;
}
+/*
+ * call-seq:
+ * stat <=> other_stat => -1, 0, 1
+ *
+ * Compares <code>File::Stat</code> objects by comparing their
+ * respective modification times.
+ *
+ * f1 = File.new("f1", "w")
+ * sleep 1
+ * f2 = File.new("f2", "w")
+ * f1.stat <=> f2.stat #=> -1
+ */
+
static VALUE
rb_stat_cmp(self, other)
VALUE self, other;
{
- time_t t1 = get_stat(self)->st_mtime;
- time_t t2 = get_stat(other)->st_mtime;
- if (t1 == t2)
- return INT2FIX(0);
- else if (t1 < t2)
- return INT2FIX(-1);
- else
- return INT2FIX(1);
+ if (rb_obj_is_kind_of(other, rb_obj_class(self))) {
+ time_t t1 = get_stat(self)->st_mtime;
+ time_t t2 = get_stat(other)->st_mtime;
+ if (t1 == t2)
+ return INT2FIX(0);
+ else if (t1 < t2)
+ return INT2FIX(-1);
+ else
+ return INT2FIX(1);
+ }
+ return Qnil;
}
+/*
+ * call-seq:
+ * stat.dev => fixnum
+ *
+ * Returns an integer representing the device on which <i>stat</i>
+ * resides.
+ *
+ * File.stat("testfile").dev #=> 774
+ */
+
static VALUE
rb_stat_dev(self)
VALUE self;
@@ -163,20 +196,110 @@ rb_stat_dev(self)
return INT2NUM(get_stat(self)->st_dev);
}
+/*
+ * call-seq:
+ * stat.dev_major => fixnum
+ *
+ * Returns the major part of <code>File_Stat#dev</code> or
+ * <code>nil</code>.
+ *
+ * File.stat("/dev/fd1").dev_major #=> 2
+ * File.stat("/dev/tty").dev_major #=> 5
+ */
+
+static VALUE
+rb_stat_dev_major(self)
+ VALUE self;
+{
+#if defined(major)
+ long dev = get_stat(self)->st_dev;
+ return ULONG2NUM(major(dev));
+#else
+ return Qnil;
+#endif
+}
+
+/*
+ * call-seq:
+ * stat.dev_minor => fixnum
+ *
+ * Returns the minor part of <code>File_Stat#dev</code> or
+ * <code>nil</code>.
+ *
+ * File.stat("/dev/fd1").dev_minor #=> 1
+ * File.stat("/dev/tty").dev_minor #=> 0
+ */
+
+static VALUE
+rb_stat_dev_minor(self)
+ VALUE self;
+{
+#if defined(minor)
+ long dev = get_stat(self)->st_dev;
+ return ULONG2NUM(minor(dev));
+#else
+ return Qnil;
+#endif
+}
+
+
+/*
+ * call-seq:
+ * stat.ino => fixnum
+ *
+ * Returns the inode number for <i>stat</i>.
+ *
+ * File.stat("testfile").ino #=> 1083669
+ *
+ */
+
static VALUE
rb_stat_ino(self)
VALUE self;
{
- return UINT2NUM(get_stat(self)->st_ino);
+#ifdef HUGE_ST_INO
+ return ULL2NUM(get_stat(self)->st_ino);
+#else
+ return ULONG2NUM(get_stat(self)->st_ino);
+#endif
}
+/*
+ * call-seq:
+ * stat.mode => fixnum
+ *
+ * Returns an integer representing the permission bits of
+ * <i>stat</i>. The meaning of the bits is platform dependent; on
+ * Unix systems, see <code>stat(2)</code>.
+ *
+ * File.chmod(0644, "testfile") #=> 1
+ * s = File.stat("testfile")
+ * sprintf("%o", s.mode) #=> "100644"
+ */
+
static VALUE
rb_stat_mode(self)
VALUE self;
{
+#ifdef __BORLANDC__
+ return UINT2NUM((unsigned short)(get_stat(self)->st_mode));
+#else
return UINT2NUM(get_stat(self)->st_mode);
+#endif
}
+/*
+ * call-seq:
+ * stat.nlink => fixnum
+ *
+ * Returns the number of hard links to <i>stat</i>.
+ *
+ * File.stat("testfile").nlink #=> 1
+ * File.link("testfile", "testfile.bak") #=> 0
+ * File.stat("testfile").nlink #=> 2
+ *
+ */
+
static VALUE
rb_stat_nlink(self)
VALUE self;
@@ -184,6 +307,17 @@ rb_stat_nlink(self)
return UINT2NUM(get_stat(self)->st_nlink);
}
+
+/*
+ * call-seq:
+ * stat.uid => fixnum
+ *
+ * Returns the numeric user id of the owner of <i>stat</i>.
+ *
+ * File.stat("testfile").uid #=> 501
+ *
+ */
+
static VALUE
rb_stat_uid(self)
VALUE self;
@@ -191,6 +325,16 @@ rb_stat_uid(self)
return UINT2NUM(get_stat(self)->st_uid);
}
+/*
+ * call-seq:
+ * stat.gid => fixnum
+ *
+ * Returns the numeric group id of the owner of <i>stat</i>.
+ *
+ * File.stat("testfile").gid #=> 500
+ *
+ */
+
static VALUE
rb_stat_gid(self)
VALUE self;
@@ -198,46 +342,148 @@ rb_stat_gid(self)
return UINT2NUM(get_stat(self)->st_gid);
}
+
+/*
+ * call-seq:
+ * stat.rdev => fixnum or nil
+ *
+ * Returns an integer representing the device type on which
+ * <i>stat</i> resides. Returns <code>nil</code> if the operating
+ * system doesn't support this feature.
+ *
+ * File.stat("/dev/fd1").rdev #=> 513
+ * File.stat("/dev/tty").rdev #=> 1280
+ */
+
static VALUE
rb_stat_rdev(self)
VALUE self;
{
#ifdef HAVE_ST_RDEV
- return INT2NUM(get_stat(self)->st_rdev);
+ return ULONG2NUM(get_stat(self)->st_rdev);
#else
- return INT2FIX(0);
+ return Qnil;
#endif
}
+/*
+ * call-seq:
+ * stat.rdev_major => fixnum
+ *
+ * Returns the major part of <code>File_Stat#rdev</code> or
+ * <code>nil</code>.
+ *
+ * File.stat("/dev/fd1").rdev_major #=> 2
+ * File.stat("/dev/tty").rdev_major #=> 5
+ */
+
+static VALUE
+rb_stat_rdev_major(self)
+ VALUE self;
+{
+#if defined(HAVE_ST_RDEV) && defined(major)
+ long rdev = get_stat(self)->st_rdev;
+ return ULONG2NUM(major(rdev));
+#else
+ return Qnil;
+#endif
+}
+
+/*
+ * call-seq:
+ * stat.rdev_minor => fixnum
+ *
+ * Returns the minor part of <code>File_Stat#rdev</code> or
+ * <code>nil</code>.
+ *
+ * File.stat("/dev/fd1").rdev_minor #=> 1
+ * File.stat("/dev/tty").rdev_minor #=> 0
+ */
+
+static VALUE
+rb_stat_rdev_minor(self)
+ VALUE self;
+{
+#if defined(HAVE_ST_RDEV) && defined(minor)
+ long rdev = get_stat(self)->st_rdev;
+ return ULONG2NUM(minor(rdev));
+#else
+ return Qnil;
+#endif
+}
+
+/*
+ * call-seq:
+ * stat.size => fixnum
+ *
+ * Returns the size of <i>stat</i> in bytes.
+ *
+ * File.stat("testfile").size #=> 66
+ */
+
static VALUE
rb_stat_size(self)
VALUE self;
{
- return INT2NUM(get_stat(self)->st_size);
+ return OFFT2NUM(get_stat(self)->st_size);
}
+/*
+ * call-seq:
+ * stat.blksize => integer or nil
+ *
+ * Returns the native file system's block size. Will return <code>nil</code>
+ * on platforms that don't support this information.
+ *
+ * File.stat("testfile").blksize #=> 4096
+ *
+ */
+
static VALUE
rb_stat_blksize(self)
VALUE self;
{
#ifdef HAVE_ST_BLKSIZE
- return UINT2NUM(get_stat(self)->st_blksize);
+ return ULONG2NUM(get_stat(self)->st_blksize);
#else
- return INT2FIX(0);
+ return Qnil;
#endif
}
+/*
+ * call-seq:
+ * stat.blocks => integer or nil
+ *
+ * Returns the number of native file system blocks allocated for this
+ * file, or <code>nil</code> if the operating system doesn't
+ * support this feature.
+ *
+ * File.stat("testfile").blocks #=> 2
+ */
+
static VALUE
rb_stat_blocks(self)
VALUE self;
{
#ifdef HAVE_ST_BLOCKS
- return UINT2NUM(get_stat(self)->st_blocks);
+ return ULONG2NUM(get_stat(self)->st_blocks);
#else
- return INT2FIX(0);
+ return Qnil;
#endif
}
+
+/*
+ * call-seq:
+ * stat.atime => time
+ *
+ * Returns the last access time for this file as an object of class
+ * <code>Time</code>.
+ *
+ * File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
+ *
+ */
+
static VALUE
rb_stat_atime(self)
VALUE self;
@@ -245,6 +491,16 @@ rb_stat_atime(self)
return rb_time_new(get_stat(self)->st_atime, 0);
}
+/*
+ * call-seq:
+ * stat.mtime -> aTime
+ *
+ * Returns the modification time of <i>stat</i>.
+ *
+ * File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
+ *
+ */
+
static VALUE
rb_stat_mtime(self)
VALUE self;
@@ -252,6 +508,18 @@ rb_stat_mtime(self)
return rb_time_new(get_stat(self)->st_mtime, 0);
}
+/*
+ * call-seq:
+ * stat.ctime -> aTime
+ *
+ * Returns the change time for <i>stat</i> (that is, the time
+ * directory information about the file was changed, not the file
+ * itself).
+ *
+ * File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
+ *
+ */
+
static VALUE
rb_stat_ctime(self)
VALUE self;
@@ -259,13 +527,27 @@ rb_stat_ctime(self)
return rb_time_new(get_stat(self)->st_ctime, 0);
}
+/*
+ * call-seq:
+ * stat.inspect => string
+ *
+ * Produce a nicely formatted description of <i>stat</i>.
+ *
+ * File.stat("/etc/passwd").inspect
+ * #=> "#<File::Stat dev=0xe000005, ino=1078078, mode=0100644,
+ * nlink=1, uid=0, gid=0, rdev=0x0, size=1374, blksize=4096,
+ * blocks=8, atime=Wed Dec 10 10:16:12 CST 2003,
+ * mtime=Fri Sep 12 15:41:41 CDT 2003,
+ * ctime=Mon Oct 27 11:20:27 CST 2003>"
+ */
+
static VALUE
rb_stat_inspect(self)
VALUE self;
{
VALUE str;
int i;
- struct {
+ static struct {
char *name;
VALUE (*func)();
} member[] = {
@@ -284,23 +566,36 @@ rb_stat_inspect(self)
{"ctime", rb_stat_ctime},
};
- str = rb_str_new2("#<");
- rb_str_cat2(str, rb_class2name(CLASS_OF(self)));
- rb_str_cat2(str, " ");
+ str = rb_str_buf_new2("#<");
+ rb_str_buf_cat2(str, rb_obj_classname(self));
+ rb_str_buf_cat2(str, " ");
for (i = 0; i < sizeof(member)/sizeof(member[0]); i++) {
- VALUE str2;
- char *p;
+ VALUE v;
if (i > 0) {
- rb_str_cat2(str, ", ");
+ rb_str_buf_cat2(str, ", ");
+ }
+ rb_str_buf_cat2(str, member[i].name);
+ rb_str_buf_cat2(str, "=");
+ v = (*member[i].func)(self);
+ if (i == 2) { /* mode */
+ char buf[32];
+
+ sprintf(buf, "0%lo", NUM2ULONG(v));
+ rb_str_buf_cat2(str, buf);
+ }
+ else if (i == 0 || i == 6) { /* dev/rdev */
+ char buf[32];
+
+ sprintf(buf, "0x%lx", NUM2ULONG(v));
+ rb_str_buf_cat2(str, buf);
+ }
+ else {
+ rb_str_append(str, rb_inspect(v));
}
- rb_str_cat2(str, member[i].name);
- rb_str_cat2(str, "=");
- str2 = rb_inspect((*member[i].func)(self));
- rb_str_append(str, str2);
}
- rb_str_cat2(str, ">");
+ rb_str_buf_cat2(str, ">");
OBJ_INFECT(str, self);
return str;
@@ -311,33 +606,59 @@ rb_stat(file, st)
VALUE file;
struct stat *st;
{
- if (TYPE(file) == T_FILE) {
+ VALUE tmp;
+
+ tmp = rb_check_convert_type(file, T_FILE, "IO", "to_io");
+ if (!NIL_P(tmp)) {
OpenFile *fptr;
rb_secure(2);
- GetOpenFile(file, fptr);
+ GetOpenFile(tmp, fptr);
return fstat(fileno(fptr->f), st);
}
- Check_SafeStr(file);
-#if defined DJGPP
- if (RSTRING(file)->len == 0) return -1;
-#endif
- return rb_sys_stat(RSTRING(file)->ptr, st);
+ SafeStringValue(file);
+ return stat(StringValueCStr(file), st);
}
+/*
+ * call-seq:
+ * File.stat(file_name) => stat
+ *
+ * Returns a <code>File::Stat</code> object for the named file (see
+ * <code>File::Stat</code>).
+ *
+ * File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003
+ *
+ */
+
static VALUE
rb_file_s_stat(klass, fname)
VALUE klass, fname;
{
struct stat st;
- Check_SafeStr(fname);
- if (rb_sys_stat(RSTRING(fname)->ptr, &st) == -1) {
- rb_sys_fail(RSTRING(fname)->ptr);
+ SafeStringValue(fname);
+ if (rb_stat(fname, &st) < 0) {
+ rb_sys_fail(StringValueCStr(fname));
}
return stat_new(&st);
}
+/*
+ * call-seq:
+ * ios.stat => stat
+ *
+ * Returns status information for <em>ios</em> as an object of type
+ * <code>File::Stat</code>.
+ *
+ * f = File.new("testfile")
+ * s = f.stat
+ * "%o" % s.mode #=> "100644"
+ * s.blksize #=> 4096
+ * s.atime #=> Wed Apr 09 08:53:54 CDT 2003
+ *
+ */
+
static VALUE
rb_io_stat(obj)
VALUE obj;
@@ -352,6 +673,20 @@ rb_io_stat(obj)
return stat_new(&st);
}
+/*
+ * call-seq:
+ * File.lstat(file_name) => stat
+ *
+ * Same as <code>File::stat</code>, but does not follow the last symbolic
+ * link. Instead, reports on the link itself.
+ *
+ * File.symlink("testfile", "link2test") #=> 0
+ * File.stat("testfile").size #=> 66
+ * File.lstat("link2test").size #=> 8
+ * File.stat("link2test").size #=> 66
+ *
+ */
+
static VALUE
rb_file_s_lstat(klass, fname)
VALUE klass, fname;
@@ -359,8 +694,8 @@ rb_file_s_lstat(klass, fname)
#ifdef HAVE_LSTAT
struct stat st;
- Check_SafeStr(fname);
- if (lstat(RSTRING(fname)->ptr, &st) == -1) {
+ SafeStringValue(fname);
+ if (lstat(StringValueCStr(fname), &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr);
}
return stat_new(&st);
@@ -369,6 +704,21 @@ rb_file_s_lstat(klass, fname)
#endif
}
+
+/*
+ * call-seq:
+ * file.lstat => stat
+ *
+ * Same as <code>IO#stat</code>, but does not follow the last symbolic
+ * link. Instead, reports on the link itself.
+ *
+ * File.symlink("testfile", "link2test") #=> 0
+ * File.stat("testfile").size #=> 66
+ * f = File.new("link2test")
+ * f.lstat.size #=> 8
+ * f.stat.size #=> 66
+ */
+
static VALUE
rb_file_lstat(obj)
VALUE obj;
@@ -393,13 +743,17 @@ static int
group_member(gid)
GETGROUPS_T gid;
{
-#if !defined(NT)
- if (getgid() == gid || getegid() == gid)
+#ifndef _WIN32
+ if (getgid() == gid)
return Qtrue;
# ifdef HAVE_GETGROUPS
# ifndef NGROUPS
+# ifdef NGROUPS_MAX
+# define NGROUPS NGROUPS_MAX
+# else
# define NGROUPS 32
+# endif
# endif
{
GETGROUPS_T gary[NGROUPS];
@@ -424,40 +778,62 @@ eaccess(path, mode)
const char *path;
int mode;
{
-#ifdef S_IXGRP
- struct stat st;
- static int euid = -1;
+#if defined(S_IXGRP) && !defined(_WIN32) && !defined(__CYGWIN__)
+ struct stat st;
+ int euid;
- if (rb_sys_stat(path, &st) < 0) return (-1);
+ if (stat(path, &st) < 0) return -1;
- if (euid == -1)
- euid = geteuid ();
+ euid = geteuid();
- if (euid == 0)
- {
- /* Root can read or write any file. */
- if (mode != X_OK)
- return 0;
+ if (euid == 0) {
+ /* Root can read or write any file. */
+ if (!(mode & X_OK))
+ return 0;
- /* Root can execute any file that has any one of the execute
- bits set. */
- if (st.st_mode & S_IXUGO)
- return 0;
+ /* Root can execute any file that has any one of the execute
+ bits set. */
+ if (st.st_mode & S_IXUGO)
+ return 0;
+
+ return -1;
}
- if (st.st_uid == euid) /* owner */
- mode <<= 6;
- else if (group_member (st.st_gid))
- mode <<= 3;
+ if (st.st_uid == euid) /* owner */
+ mode <<= 6;
+ else if (getegid() == st.st_gid || group_member(st.st_gid))
+ mode <<= 3;
- if (st.st_mode & mode) return 0;
+ if ((st.st_mode & mode) == mode) return 0;
- return -1;
-#else /* !NT */
- return access(path, mode);
+ return -1;
+#else
+ return access(path, mode);
#endif
}
+
+/*
+ * Document-class: FileTest
+ *
+ * <code>FileTest</code> implements file test operations similar to
+ * those used in <code>File::Stat</code>. It exists as a standalone
+ * module, and its methods are also insinuated into the <code>File</code>
+ * class. (Note that this is not done by inclusion: the interpreter cheats).
+ *
+ */
+
+
+/*
+ * call-seq:
+ * File.directory?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a directory,
+ * <code>false</code> otherwise.
+ *
+ * File.directory?(".")
+ */
+
static VALUE
test_d(obj, fname)
VALUE obj, fname;
@@ -473,6 +849,13 @@ test_d(obj, fname)
return Qfalse;
}
+/*
+ * call-seq:
+ * File.pipe?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a pipe.
+ */
+
static VALUE
test_p(obj, fname)
VALUE obj, fname;
@@ -491,6 +874,13 @@ test_p(obj, fname)
return Qfalse;
}
+/*
+ * call-seq:
+ * File.symlink?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a symbolic link.
+ */
+
static VALUE
test_l(obj, fname)
VALUE obj, fname;
@@ -498,6 +888,14 @@ test_l(obj, fname)
#ifndef S_ISLNK
# ifdef _S_ISLNK
# define S_ISLNK(m) _S_ISLNK(m)
+# elif defined __BORLANDC__
+# ifdef _S_IFLNK
+# define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == _S_IFLNK)
+# else
+# ifdef S_IFLNK
+# define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == S_IFLNK)
+# endif
+# endif
# else
# ifdef _S_IFLNK
# define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
@@ -512,14 +910,21 @@ test_l(obj, fname)
#ifdef S_ISLNK
struct stat st;
- Check_SafeStr(fname);
- if (lstat(RSTRING(fname)->ptr, &st) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (lstat(StringValueCStr(fname), &st) < 0) return Qfalse;
if (S_ISLNK(st.st_mode)) return Qtrue;
#endif
return Qfalse;
}
+/*
+ * call-seq:
+ * File.socket?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a socket.
+ */
+
static VALUE
test_S(obj, fname)
VALUE obj, fname;
@@ -527,6 +932,14 @@ test_S(obj, fname)
#ifndef S_ISSOCK
# ifdef _S_ISSOCK
# define S_ISSOCK(m) _S_ISSOCK(m)
+# elif defined __BORLANDC__
+# ifdef _S_IFSOCK
+# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == _S_IFSOCK)
+# else
+# ifdef S_IFSOCK
+# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == S_IFSOCK)
+# endif
+# endif
# else
# ifdef _S_IFSOCK
# define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
@@ -548,6 +961,13 @@ test_S(obj, fname)
return Qfalse;
}
+/*
+ * call-seq:
+ * File.blockdev?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a block device.
+ */
+
static VALUE
test_b(obj, fname)
VALUE obj, fname;
@@ -570,6 +990,12 @@ test_b(obj, fname)
return Qfalse;
}
+/*
+ * call-seq:
+ * File.chardev?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a character device.
+ */
static VALUE
test_c(obj, fname)
VALUE obj, fname;
@@ -586,6 +1012,15 @@ test_c(obj, fname)
return Qfalse;
}
+
+/*
+ * call-seq:
+ * File.exist?(file_name) => true or false
+ * File.exists?(file_name) => true or false (obsolete)
+ *
+ * Return <code>true</code> if the named file exists.
+ */
+
static VALUE
test_e(obj, fname)
VALUE obj, fname;
@@ -596,57 +1031,106 @@ test_e(obj, fname)
return Qtrue;
}
+/*
+ * call-seq:
+ * File.readable?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is readable by the effective
+ * user id of this process.
+ */
+
static VALUE
test_r(obj, fname)
VALUE obj, fname;
{
- Check_SafeStr(fname);
- if (eaccess(RSTRING(fname)->ptr, R_OK) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (eaccess(StringValueCStr(fname), R_OK) < 0) return Qfalse;
return Qtrue;
}
+/*
+ * call-seq:
+ * File.readable_real?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is readable by the real
+ * user id of this process.
+ */
+
static VALUE
test_R(obj, fname)
VALUE obj, fname;
{
- Check_SafeStr(fname);
- if (access(RSTRING(fname)->ptr, R_OK) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (access(StringValueCStr(fname), R_OK) < 0) return Qfalse;
return Qtrue;
}
+
+/*
+ * call-seq:
+ * File.writable?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is writable by the effective
+ * user id of this process.
+ */
+
static VALUE
test_w(obj, fname)
VALUE obj, fname;
{
- Check_SafeStr(fname);
- if (eaccess(RSTRING(fname)->ptr, W_OK) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (eaccess(StringValueCStr(fname), W_OK) < 0) return Qfalse;
return Qtrue;
}
+/*
+ * call-seq:
+ * File.writable_real?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is writable by the real
+ * user id of this process.
+ */
+
static VALUE
test_W(obj, fname)
VALUE obj, fname;
{
- Check_SafeStr(fname);
- if (access(RSTRING(fname)->ptr, W_OK) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (access(StringValueCStr(fname), W_OK) < 0) return Qfalse;
return Qtrue;
}
+/*
+ * call-seq:
+ * File.executable?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is executable by the effective
+ * user id of this process.
+ */
+
static VALUE
test_x(obj, fname)
VALUE obj, fname;
{
- Check_SafeStr(fname);
- if (eaccess(RSTRING(fname)->ptr, X_OK) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (eaccess(StringValueCStr(fname), X_OK) < 0) return Qfalse;
return Qtrue;
}
+/*
+ * call-seq:
+ * File.executable_real?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is executable by the real
+ * user id of this process.
+ */
+
static VALUE
test_X(obj, fname)
VALUE obj, fname;
{
- Check_SafeStr(fname);
- if (access(RSTRING(fname)->ptr, X_OK) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (access(StringValueCStr(fname), X_OK) < 0) return Qfalse;
return Qtrue;
}
@@ -654,6 +1138,14 @@ test_X(obj, fname)
# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
#endif
+/*
+ * call-seq:
+ * File.file?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file exists and is a
+ * regular file.
+ */
+
static VALUE
test_f(obj, fname)
VALUE obj, fname;
@@ -665,6 +1157,14 @@ test_f(obj, fname)
return Qfalse;
}
+/*
+ * call-seq:
+ * File.zero?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file exists and has
+ * a zero size.
+ */
+
static VALUE
test_z(obj, fname)
VALUE obj, fname;
@@ -676,6 +1176,14 @@ test_z(obj, fname)
return Qfalse;
}
+/*
+ * call-seq:
+ * File.file?(file_name) => integer or nil
+ *
+ * Returns <code>nil</code> if <code>file_name</code> doesn't
+ * exist or has zero size, the size of the file otherwise.
+ */
+
static VALUE
test_s(obj, fname)
VALUE obj, fname;
@@ -684,9 +1192,18 @@ test_s(obj, fname)
if (rb_stat(fname, &st) < 0) return Qnil;
if (st.st_size == 0) return Qnil;
- return rb_int2inum(st.st_size);
+ return OFFT2NUM(st.st_size);
}
+/*
+ * call-seq:
+ * File.owned?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file exists and the
+ * effective used id of the calling process is the owner of
+ * the file.
+ */
+
static VALUE
test_owned(obj, fname)
VALUE obj, fname;
@@ -709,11 +1226,20 @@ test_rowned(obj, fname)
return Qfalse;
}
+/*
+ * call-seq:
+ * File.grpowned?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file exists and the
+ * effective group id of the calling process is the owner of
+ * the file. Returns <code>false</code> on Windows.
+ */
+
static VALUE
test_grpowned(obj, fname)
VALUE obj, fname;
{
-#ifndef NT
+#ifndef _WIN32
struct stat st;
if (rb_stat(fname, &st) < 0) return Qfalse;
@@ -724,54 +1250,80 @@ test_grpowned(obj, fname)
#if defined(S_ISUID) || defined(S_ISGID) || defined(S_ISVTX)
static VALUE
-check3rdbyte(file, mode)
- const char *file;
+check3rdbyte(fname, mode)
+ VALUE fname;
int mode;
{
struct stat st;
- if (rb_sys_stat(file, &st) < 0) return Qfalse;
+ SafeStringValue(fname);
+ if (stat(StringValueCStr(fname), &st) < 0) return Qfalse;
if (st.st_mode & mode) return Qtrue;
return Qfalse;
}
#endif
+/*
+ * call-seq:
+ * File.setuid?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a has the setuid bit set.
+ */
+
static VALUE
test_suid(obj, fname)
VALUE obj, fname;
{
#ifdef S_ISUID
- Check_SafeStr(fname);
- return check3rdbyte(RSTRING(fname)->ptr, S_ISUID);
+ return check3rdbyte(fname, S_ISUID);
#else
return Qfalse;
#endif
}
+/*
+ * call-seq:
+ * File.setgid?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a has the setgid bit set.
+ */
+
static VALUE
test_sgid(obj, fname)
VALUE obj, fname;
{
#ifdef S_ISGID
- Check_SafeStr(fname);
- return check3rdbyte(RSTRING(fname)->ptr, S_ISGID);
+ return check3rdbyte(fname, S_ISGID);
#else
return Qfalse;
#endif
}
+/*
+ * call-seq:
+ * File.sticky?(file_name) => true or false
+ *
+ * Returns <code>true</code> if the named file is a has the sticky bit set.
+ */
+
static VALUE
test_sticky(obj, fname)
VALUE obj, fname;
{
#ifdef S_ISVTX
- Check_SafeStr(fname);
- return check3rdbyte(RSTRING(fname)->ptr, S_ISVTX);
+ return check3rdbyte(fname, S_ISVTX);
#else
return Qnil;
#endif
}
+/*
+ * call-seq:
+ * File.size(file_name) => integer
+ *
+ * Returns the size of <code>file_name</code>.
+ */
+
static VALUE
rb_file_s_size(klass, fname)
VALUE klass, fname;
@@ -779,8 +1331,8 @@ rb_file_s_size(klass, fname)
struct stat st;
if (rb_stat(fname, &st) < 0)
- rb_sys_fail(RSTRING(fname)->ptr);
- return rb_int2inum(st.st_size);
+ rb_sys_fail(StringValueCStr(fname));
+ return OFFT2NUM(st.st_size);
}
static VALUE
@@ -791,9 +1343,11 @@ rb_file_ftype(st)
if (S_ISREG(st->st_mode)) {
t = "file";
- } else if (S_ISDIR(st->st_mode)) {
+ }
+ else if (S_ISDIR(st->st_mode)) {
t = "directory";
- } else if (S_ISCHR(st->st_mode)) {
+ }
+ else if (S_ISCHR(st->st_mode)) {
t = "characterSpecial";
}
#ifdef S_ISBLK
@@ -823,20 +1377,45 @@ rb_file_ftype(st)
return rb_str_new2(t);
}
+/*
+ * call-seq:
+ * File.ftype(file_name) => string
+ *
+ * Identifies the type of the named file; the return string is one of
+ * ``<code>file</code>'', ``<code>directory</code>'',
+ * ``<code>characterSpecial</code>'', ``<code>blockSpecial</code>'',
+ * ``<code>fifo</code>'', ``<code>link</code>'',
+ * ``<code>socket</code>'', or ``<code>unknown</code>''.
+ *
+ * File.ftype("testfile") #=> "file"
+ * File.ftype("/dev/tty") #=> "characterSpecial"
+ * File.ftype("/tmp/.X11-unix/X0") #=> "socket"
+ */
+
static VALUE
rb_file_s_ftype(klass, fname)
VALUE klass, fname;
{
struct stat st;
- Check_SafeStr(fname);
- if (lstat(RSTRING(fname)->ptr, &st) == -1) {
+ SafeStringValue(fname);
+ if (lstat(StringValueCStr(fname), &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr);
}
return rb_file_ftype(&st);
}
+/*
+ * call-seq:
+ * File.atime(file_name) => time
+ *
+ * Returns the last access time for the named file as a Time object).
+ *
+ * File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
+ *
+ */
+
static VALUE
rb_file_s_atime(klass, fname)
VALUE klass, fname;
@@ -844,10 +1423,21 @@ rb_file_s_atime(klass, fname)
struct stat st;
if (rb_stat(fname, &st) < 0)
- rb_sys_fail(RSTRING(fname)->ptr);
+ rb_sys_fail(StringValueCStr(fname));
return rb_time_new(st.st_atime, 0);
}
+/*
+ * call-seq:
+ * file.atime => time
+ *
+ * Returns the last access time (a <code>Time</code> object)
+ * for <i>file</i>, or epoch if <i>file</i> has not been accessed.
+ *
+ * File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
+ *
+ */
+
static VALUE
rb_file_atime(obj)
VALUE obj;
@@ -862,6 +1452,16 @@ rb_file_atime(obj)
return rb_time_new(st.st_atime, 0);
}
+/*
+ * call-seq:
+ * File.mtime(file_name) => time
+ *
+ * Returns the modification time for the named file as a Time object.
+ *
+ * File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
+ *
+ */
+
static VALUE
rb_file_s_mtime(klass, fname)
VALUE klass, fname;
@@ -873,6 +1473,16 @@ rb_file_s_mtime(klass, fname)
return rb_time_new(st.st_mtime, 0);
}
+/*
+ * call-seq:
+ * file.mtime -> time
+ *
+ * Returns the modification time for <i>file</i>.
+ *
+ * File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
+ *
+ */
+
static VALUE
rb_file_mtime(obj)
VALUE obj;
@@ -887,6 +1497,18 @@ rb_file_mtime(obj)
return rb_time_new(st.st_mtime, 0);
}
+/*
+ * call-seq:
+ * File.ctime(file_name) => time
+ *
+ * Returns the change time for the named file (the time at which
+ * directory information about the file was changed, not the file
+ * itself).
+ *
+ * File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
+ *
+ */
+
static VALUE
rb_file_s_ctime(klass, fname)
VALUE klass, fname;
@@ -898,6 +1520,17 @@ rb_file_s_ctime(klass, fname)
return rb_time_new(st.st_ctime, 0);
}
+/*
+ * call-seq:
+ * file.ctime -> time
+ *
+ * Returns the change time for <i>file</i> (that is, the time directory
+ * information about the file was changed, not the file itself).
+ *
+ * File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
+ *
+ */
+
static VALUE
rb_file_ctime(obj)
VALUE obj;
@@ -917,10 +1550,23 @@ chmod_internal(path, mode)
const char *path;
int mode;
{
- if (chmod(path, mode) == -1)
+ if (chmod(path, mode) < 0)
rb_sys_fail(path);
}
+/*
+ * call-seq:
+ * File.chmod(mode_int, file_name, ... ) -> integer
+ *
+ * Changes permission bits on the named file(s) to the bit pattern
+ * represented by <i>mode_int</i>. Actual effects are operating system
+ * dependent (see the beginning of this section). On Unix systems, see
+ * <code>chmod(2)</code> for details. Returns the number of files
+ * processed.
+ *
+ * File.chmod(0644, "testfile", "out") #=> 2
+ */
+
static VALUE
rb_file_s_chmod(argc, argv)
int argc;
@@ -928,16 +1574,30 @@ rb_file_s_chmod(argc, argv)
{
VALUE vmode;
VALUE rest;
- int mode, n;
+ int mode;
+ long n;
rb_secure(2);
rb_scan_args(argc, argv, "1*", &vmode, &rest);
mode = NUM2INT(vmode);
- n = apply2files(chmod_internal, rest, mode);
- return INT2FIX(n);
+ n = apply2files(chmod_internal, rest, (void *)(long)mode);
+ return LONG2FIX(n);
}
+/*
+ * call-seq:
+ * file.chmod(mode_int) => 0
+ *
+ * Changes permission bits on <i>file</i> to the bit pattern
+ * represented by <i>mode_int</i>. Actual effects are platform
+ * dependent; on Unix systems, see <code>chmod(2)</code> for details.
+ * Follows symbolic links. Also see <code>File#lchmod</code>.
+ *
+ * f = File.new("out", "w");
+ * f.chmod(0644) #=> 0
+ */
+
static VALUE
rb_file_chmod(obj, vmode)
VALUE obj, vmode;
@@ -961,6 +1621,53 @@ rb_file_chmod(obj, vmode)
return INT2FIX(0);
}
+#if defined(HAVE_LCHMOD)
+static void
+lchmod_internal(path, mode)
+ const char *path;
+ int mode;
+{
+ if (lchmod(path, mode) < 0)
+ rb_sys_fail(path);
+}
+
+/*
+ * call-seq:
+ * File.lchmod(mode_int, file_name, ...) => integer
+ *
+ * Equivalent to <code>File::chmod</code>, but does not follow symbolic
+ * links (so it will change the permissions associated with the link,
+ * not the file referenced by the link). Often not available.
+ *
+ */
+
+static VALUE
+rb_file_s_lchmod(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE vmode;
+ VALUE rest;
+ long mode, n;
+
+ rb_secure(2);
+ rb_scan_args(argc, argv, "1*", &vmode, &rest);
+ mode = NUM2INT(vmode);
+
+ n = apply2files(lchmod_internal, rest, (void *)(long)mode);
+ return LONG2FIX(n);
+}
+#else
+static VALUE
+rb_file_s_lchmod(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ rb_notimplement();
+ return Qnil; /* not reached */
+}
+#endif
+
struct chown_args {
int owner, group;
};
@@ -974,6 +1681,21 @@ chown_internal(path, args)
rb_sys_fail(path);
}
+/*
+ * call-seq:
+ * File.chown(owner_int, group_int, file_name,... ) -> integer
+ *
+ * Changes the owner and group of the named file(s) to the given
+ * numeric owner and group id's. Only a process with superuser
+ * privileges may change the owner of a file. The current owner of a
+ * file may change the file's group to any group to which the owner
+ * belongs. A <code>nil</code> or -1 owner or group id is ignored.
+ * Returns the number of files processed.
+ *
+ * File.chown(nil, 100, "testfile")
+ *
+ */
+
static VALUE
rb_file_s_chown(argc, argv)
int argc;
@@ -981,7 +1703,7 @@ rb_file_s_chown(argc, argv)
{
VALUE o, g, rest;
struct chown_args arg;
- int n;
+ long n;
rb_secure(2);
rb_scan_args(argc, argv, "2*", &o, &g, &rest);
@@ -999,9 +1721,24 @@ rb_file_s_chown(argc, argv)
}
n = apply2files(chown_internal, rest, &arg);
- return INT2FIX(n);
+ return LONG2FIX(n);
}
+/*
+ * call-seq:
+ * file.chown(owner_int, group_int ) => 0
+ *
+ * Changes the owner and group of <i>file</i> to the given numeric
+ * owner and group id's. Only a process with superuser privileges may
+ * change the owner of a file. The current owner of a file may change
+ * the file's group to any group to which the owner belongs. A
+ * <code>nil</code> or -1 owner or group id is ignored. Follows
+ * symbolic links. See also <code>File#lchown</code>.
+ *
+ * File.new("testfile").chown(502, 1000)
+ *
+ */
+
static VALUE
rb_file_chown(obj, owner, group)
VALUE obj, owner, group;
@@ -1010,7 +1747,7 @@ rb_file_chown(obj, owner, group)
rb_secure(2);
GetOpenFile(obj, fptr);
-#if defined(DJGPP) || defined(__CYGWIN32__) || defined(NT) || defined(__EMX__)
+#if defined(DJGPP) || defined(__CYGWIN32__) || defined(_WIN32) || defined(__EMX__)
if (!fptr->path) return Qnil;
if (chown(fptr->path, NUM2INT(owner), NUM2INT(group)) == -1)
rb_sys_fail(fptr->path);
@@ -1022,6 +1759,65 @@ rb_file_chown(obj, owner, group)
return INT2FIX(0);
}
+#if defined(HAVE_LCHOWN) && !defined(__CHECKER__)
+static void
+lchown_internal(path, args)
+ const char *path;
+ struct chown_args *args;
+{
+ if (lchown(path, args->owner, args->group) < 0)
+ rb_sys_fail(path);
+}
+
+
+/*
+ * call-seq:
+ * file.lchown(owner_int, group_int, file_name,..) => integer
+ *
+ * Equivalent to <code>File::chown</code>, but does not follow symbolic
+ * links (so it will change the owner associated with the link, not the
+ * file referenced by the link). Often not available. Returns number
+ * of files in the argument list.
+ *
+ */
+
+static VALUE
+rb_file_s_lchown(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE o, g, rest;
+ struct chown_args arg;
+ long n;
+
+ rb_secure(2);
+ rb_scan_args(argc, argv, "2*", &o, &g, &rest);
+ if (NIL_P(o)) {
+ arg.owner = -1;
+ }
+ else {
+ arg.owner = NUM2INT(o);
+ }
+ if (NIL_P(g)) {
+ arg.group = -1;
+ }
+ else {
+ arg.group = NUM2INT(g);
+ }
+
+ n = apply2files(lchown_internal, rest, &arg);
+ return LONG2FIX(n);
+}
+#else
+static VALUE
+rb_file_s_lchown(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ rb_notimplement();
+}
+#endif
+
struct timeval rb_time_timeval();
#if defined(HAVE_UTIMES) && !defined(__CHECKER__)
@@ -1035,6 +1831,15 @@ utime_internal(path, tvp)
rb_sys_fail(path);
}
+/*
+ * call-seq:
+ * File.utime(atime, mtime, file_name,...) => integer
+ *
+ * Sets the access and modification times of each
+ * named file to the first two arguments. Returns
+ * the number of file names in the argument list.
+ */
+
static VALUE
rb_file_s_utime(argc, argv)
int argc;
@@ -1042,7 +1847,7 @@ rb_file_s_utime(argc, argv)
{
VALUE atime, mtime, rest;
struct timeval tvp[2];
- int n;
+ long n;
rb_scan_args(argc, argv, "2*", &atime, &mtime, &rest);
@@ -1050,27 +1855,16 @@ rb_file_s_utime(argc, argv)
tvp[1] = rb_time_timeval(mtime);
n = apply2files(utime_internal, rest, tvp);
- return INT2FIX(n);
+ return LONG2FIX(n);
}
#else
-#ifndef HAVE_UTIME_H
-# ifdef NT
-# if defined(__BORLANDC__)
-# include <utime.h>
-# else
-# include <sys/utime.h>
-# endif
-# if defined(_MSC_VER) || defined __MINGW32__
-# define utimbuf _utimbuf
-# endif
-# else
+#if !defined HAVE_UTIME_H && !defined HAVE_SYS_UTIME_H
struct utimbuf {
long actime;
long modtime;
};
-# endif
#endif
static void
@@ -1088,7 +1882,7 @@ rb_file_s_utime(argc, argv)
VALUE *argv;
{
VALUE atime, mtime, rest;
- int n;
+ long n;
struct timeval tv;
struct utimbuf utbuf;
@@ -1100,33 +1894,73 @@ rb_file_s_utime(argc, argv)
utbuf.modtime = tv.tv_sec;
n = apply2files(utime_internal, rest, &utbuf);
- return INT2FIX(n);
+ return LONG2FIX(n);
}
#endif
+NORETURN(static void sys_fail2 _((VALUE,VALUE)));
+static void
+sys_fail2(s1, s2)
+ VALUE s1, s2;
+{
+ char *buf;
+ int len;
+
+ len = RSTRING(s1)->len + RSTRING(s2)->len + 5;
+ buf = ALLOCA_N(char, len);
+ snprintf(buf, len, "%s or %s", RSTRING(s1)->ptr, RSTRING(s2)->ptr);
+ rb_sys_fail(buf);
+}
+
+/*
+ * call-seq:
+ * File.link(old_name, new_name) => 0
+ *
+ * Creates a new name for an existing file using a hard link. Will not
+ * overwrite <i>new_name</i> if it already exists (raising a subclass
+ * of <code>SystemCallError</code>). Not available on all platforms.
+ *
+ * File.link("testfile", ".testfile") #=> 0
+ * IO.readlines(".testfile")[0] #=> "This is line one\n"
+ */
+
static VALUE
rb_file_s_link(klass, from, to)
VALUE klass, from, to;
{
- Check_SafeStr(from);
- Check_SafeStr(to);
+ SafeStringValue(from);
+ SafeStringValue(to);
- if (link(RSTRING(from)->ptr, RSTRING(to)->ptr) < 0)
- rb_sys_fail(RSTRING(from)->ptr);
+ if (link(StringValueCStr(from), StringValueCStr(to)) < 0) {
+ sys_fail2(from, to);
+ }
return INT2FIX(0);
}
+/*
+ * call-seq:
+ * File.symlink(old_name, new_name) => 0
+ *
+ * Creates a symbolic link called <i>new_name</i> for the existing file
+ * <i>old_name</i>. Raises a <code>NotImplemented</code> exception on
+ * platforms that do not support symbolic links.
+ *
+ * File.symlink("testfile", "link2test") #=> 0
+ *
+ */
+
static VALUE
rb_file_s_symlink(klass, from, to)
VALUE klass, from, to;
{
#ifdef HAVE_SYMLINK
- Check_SafeStr(from);
- Check_SafeStr(to);
+ SafeStringValue(from);
+ SafeStringValue(to);
- if (symlink(RSTRING(from)->ptr, RSTRING(to)->ptr) < 0)
- rb_sys_fail(RSTRING(from)->ptr);
+ if (symlink(StringValueCStr(from), StringValueCStr(to)) < 0) {
+ sys_fail2(from, to);
+ }
return INT2FIX(0);
#else
rb_notimplement();
@@ -1134,20 +1968,41 @@ rb_file_s_symlink(klass, from, to)
#endif
}
+/*
+ * call-seq:
+ * File.readlink(link_name) -> file_name
+ *
+ * Returns the name of the file referenced by the given link.
+ * Not available on all platforms.
+ *
+ * File.symlink("testfile", "link2test") #=> 0
+ * File.readlink("link2test") #=> "testfile"
+ */
+
static VALUE
rb_file_s_readlink(klass, path)
VALUE klass, path;
{
#ifdef HAVE_READLINK
- char buf[MAXPATHLEN];
- int cc;
-
- Check_SafeStr(path);
-
- if ((cc = readlink(RSTRING(path)->ptr, buf, MAXPATHLEN)) < 0)
+ char *buf;
+ int size = 100;
+ int rv;
+ VALUE v;
+
+ SafeStringValue(path);
+ buf = xmalloc(size);
+ while ((rv = readlink(StringValueCStr(path), buf, size)) == size) {
+ size *= 2;
+ buf = xrealloc(buf, size);
+ }
+ if (rv < 0) {
+ free(buf);
rb_sys_fail(RSTRING(path)->ptr);
+ }
+ v = rb_tainted_str_new(buf, rv);
+ free(buf);
- return rb_tainted_str_new(buf, cc);
+ return v;
#else
rb_notimplement();
return Qnil; /* not reached */
@@ -1162,34 +2017,84 @@ unlink_internal(path)
rb_sys_fail(path);
}
+/*
+ * call-seq:
+ * File.delete(file_name, ...) => integer
+ * File.unlink(file_name, ...) => integer
+ *
+ * Deletes the named files, returning the number of names
+ * passed as arguments. Raises an exception on any error.
+ * See also <code>Dir::rmdir</code>.
+ */
+
static VALUE
rb_file_s_unlink(klass, args)
VALUE klass, args;
{
- int n;
+ long n;
+ rb_secure(2);
n = apply2files(unlink_internal, args, 0);
- return INT2FIX(n);
+ return LONG2FIX(n);
}
+/*
+ * call-seq:
+ * File.rename(old_name, new_name) => 0
+ *
+ * Renames the given file to the new name. Raises a
+ * <code>SystemCallError</code> if the file cannot be renamed.
+ *
+ * File.rename("afile", "afile.bak") #=> 0
+ */
+
static VALUE
rb_file_s_rename(klass, from, to)
VALUE klass, from, to;
{
- Check_SafeStr(from);
- Check_SafeStr(to);
+ const char *src, *dst;
+ SafeStringValue(from);
+ SafeStringValue(to);
- if (rename(RSTRING(from)->ptr, RSTRING(to)->ptr) < 0) {
+ src = StringValueCStr(from);
+ dst = StringValueCStr(to);
+ if (rename(src, dst) < 0) {
#if defined __CYGWIN__
extern unsigned long __attribute__((stdcall)) GetLastError();
errno = GetLastError(); /* This is a Cygwin bug */
+#elif defined DOSISH && !defined _WIN32
+ if (errno == EEXIST
+#if defined (__EMX__)
+ || errno == EACCES
+#endif
+ ) {
+ if (chmod(dst, 0666) == 0 &&
+ unlink(dst) == 0 &&
+ rename(src, dst) == 0)
+ return INT2FIX(0);
+ }
#endif
- rb_sys_fail(RSTRING(from)->ptr);
+ sys_fail2(from, to);
}
return INT2FIX(0);
}
+/*
+ * call-seq:
+ * File.umask() => integer
+ * File.umask(integer) => integer
+ *
+ * Returns the current umask value for this process. If the optional
+ * argument is given, set the umask to that value and return the
+ * previous value. Umask values are <em>subtracted</em> from the
+ * default permissions, so a umask of <code>0222</code> would make a
+ * file read-only for everyone.
+ *
+ * File.umask(0006) #=> 18
+ * File.umask #=> 6
+ */
+
static VALUE
rb_file_s_umask(argc, argv)
int argc;
@@ -1206,32 +2111,188 @@ rb_file_s_umask(argc, argv)
omask = umask(NUM2INT(argv[0]));
}
else {
- rb_raise(rb_eArgError, "wrong # of argument");
+ rb_raise(rb_eArgError, "wrong number of arguments");
}
return INT2FIX(omask);
}
#if defined DOSISH
+#define DOSISH_UNC
#define isdirsep(x) ((x) == '/' || (x) == '\\')
#else
#define isdirsep(x) ((x) == '/')
#endif
+#ifndef CharNext /* defined as CharNext[AW] on Windows. */
+# if defined(DJGPP)
+# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
+# else
+# define CharNext(p) ((p) + 1)
+# endif
+#endif
-VALUE
-rb_file_s_expand_path(argc, argv)
- int argc;
- VALUE *argv;
+#ifdef __CYGWIN__
+#undef DOSISH
+#define DOSISH_UNC
+#define DOSISH_DRIVE_LETTER
+#endif
+
+#ifdef DOSISH_DRIVE_LETTER
+static inline int
+has_drive_letter(buf)
+ const char *buf;
{
- VALUE fname, dname;
- char *s, *p;
- char buf[MAXPATHLEN+2];
- int tainted;
+ if (ISALPHA(buf[0]) && buf[1] == ':') {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
- rb_scan_args(argc, argv, "11", &fname, &dname);
+static char*
+getcwdofdrv(drv)
+ int drv;
+{
+ char drive[4];
+ char *drvcwd, *oldcwd;
+
+ drive[0] = drv;
+ drive[1] = ':';
+ drive[2] = '\0';
+
+ /* the only way that I know to get the current directory
+ of a particular drive is to change chdir() to that drive,
+ so save the old cwd before chdir()
+ */
+ oldcwd = my_getcwd();
+ if (chdir(drive) == 0) {
+ drvcwd = my_getcwd();
+ chdir(oldcwd);
+ free(oldcwd);
+ }
+ else {
+ /* perhaps the drive is not exist. we return only drive letter */
+ drvcwd = strdup(drive);
+ }
+ return drvcwd;
+}
+#endif
+static inline char *
+skiproot(path)
+ const char *path;
+{
+#ifdef DOSISH_DRIVE_LETTER
+ if (has_drive_letter(path)) path += 2;
+#endif
+ while (isdirsep(*path)) path++;
+ return (char *)path;
+}
+
+#define nextdirsep rb_path_next
+char *
+rb_path_next(s)
+ const char *s;
+{
+ while (*s && !isdirsep(*s)) {
+ s = CharNext(s);
+ }
+ return (char *)s;
+}
+
+#define skipprefix rb_path_skip_prefix
+char *
+rb_path_skip_prefix(path)
+ const char *path;
+{
+#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
+#ifdef DOSISH_UNC
+ if (isdirsep(path[0]) && isdirsep(path[1])) {
+ if (*(path = nextdirsep(path + 2)))
+ path = nextdirsep(path + 1);
+ return (char *)path;
+ }
+#endif
+#ifdef DOSISH_DRIVE_LETTER
+ if (has_drive_letter(path))
+ return (char *)(path + 2);
+#endif
+#endif
+ return (char *)path;
+}
+
+#define strrdirsep rb_path_last_separator
+char *
+rb_path_last_separator(path)
+ const char *path;
+{
+ char *last = NULL;
+ while (*path) {
+ if (isdirsep(*path)) {
+ const char *tmp = path++;
+ while (isdirsep(*path)) path++;
+ if (!*path) break;
+ last = (char *)tmp;
+ }
+ else {
+ path = CharNext(path);
+ }
+ }
+ return last;
+}
+
+#define chompdirsep rb_path_end
+char *
+rb_path_end(path)
+ const char *path;
+{
+ while (*path) {
+ if (isdirsep(*path)) {
+ const char *last = path++;
+ while (isdirsep(*path)) path++;
+ if (!*path) return (char *)last;
+ }
+ else {
+ path = CharNext(path);
+ }
+ }
+ return (char *)path;
+}
+
+#define BUFCHECK(cond) do {\
+ long bdiff = p - buf;\
+ while (cond) {\
+ buflen *= 2;\
+ }\
+ rb_str_resize(result, buflen);\
+ buf = RSTRING(result)->ptr;\
+ p = buf + bdiff;\
+ pend = buf + buflen;\
+} while (0)
+
+#define BUFINIT() (\
+ p = buf = RSTRING(result)->ptr,\
+ buflen = RSTRING(result)->len,\
+ pend = p + buflen)
+
+#if !defined(TOLOWER)
+#define TOLOWER(c) (ISUPPER(c) ? tolower(c) : (c))
+#endif
+
+static int is_absolute_path _((const char*));
+
+static VALUE
+file_expand_path(fname, dname, result)
+ VALUE fname, dname, result;
+{
+ char *s, *buf, *b, *p, *pend, *root;
+ long buflen, dirlen;
+ int tainted;
+
+ s = StringValuePtr(fname);
+ BUFINIT();
tainted = OBJ_TAINTED(fname);
- s = STR2CSTR(fname);
- p = buf;
+
if (s[0] == '~') {
if (isdirsep(s[1]) || s[1] == '\0') {
char *dir = getenv("HOME");
@@ -1239,8 +2300,18 @@ rb_file_s_expand_path(argc, argv)
if (!dir) {
rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `%s'", s);
}
+ dirlen = strlen(dir);
+ BUFCHECK(dirlen > buflen);
strcpy(buf, dir);
- p = &buf[strlen(buf)];
+#if defined DOSISH || defined __CYGWIN__
+ for (p = buf; *p; p = CharNext(p)) {
+ if (*p == '\\') {
+ *p = '/';
+ }
+ }
+#else
+ p = buf + strlen(dir);
+#endif
s++;
tainted = 1;
}
@@ -1249,9 +2320,10 @@ rb_file_s_expand_path(argc, argv)
struct passwd *pwPtr;
s++;
#endif
- while (*s && !isdirsep(*s)) {
- *p++ = *s++;
- }
+ s = nextdirsep(b = s);
+ BUFCHECK(bdiff + (s-b) >= buflen);
+ memcpy(p, b, s-b);
+ p += s-b;
*p = '\0';
#ifdef HAVE_PWD_H
pwPtr = getpwnam(buf);
@@ -1259,91 +2331,193 @@ rb_file_s_expand_path(argc, argv)
endpwent();
rb_raise(rb_eArgError, "user %s doesn't exist", buf);
}
+ dirlen = strlen(pwPtr->pw_dir);
+ BUFCHECK(dirlen > buflen);
strcpy(buf, pwPtr->pw_dir);
- p = &buf[strlen(buf)];
+ p = buf + strlen(pwPtr->pw_dir);
endpwent();
#endif
}
}
-#if defined DOSISH
+#ifdef DOSISH_DRIVE_LETTER
/* skip drive letter */
- else if (ISALPHA(s[0]) && s[1] == ':' && isdirsep(s[2])) {
- while (*s && !isdirsep(*s)) {
- *p++ = *s++;
+ else if (has_drive_letter(s)) {
+ if (isdirsep(s[2])) {
+ /* specified drive letter, and full path */
+ /* skip drive letter */
+ BUFCHECK(bdiff + 2 >= buflen);
+ memcpy(p, s, 2);
+ p += 2;
+ s += 2;
+ }
+ else {
+ /* specified drive, but not full path */
+ int same = 0;
+ if (!NIL_P(dname)) {
+ file_expand_path(dname, Qnil, result);
+ BUFINIT();
+ if (has_drive_letter(p) && TOLOWER(p[0]) == TOLOWER(s[0])) {
+ /* ok, same drive */
+ same = 1;
+ }
+ }
+ if (!same) {
+ char *dir = getcwdofdrv(*s);
+
+ tainted = 1;
+ dirlen = strlen(dir);
+ BUFCHECK(dirlen > buflen);
+ strcpy(buf, dir);
+ free(dir);
+ }
+ p = chompdirsep(skiproot(buf));
+ s += 2;
}
}
#endif
- else if (!isdirsep(*s)) {
+ else if (!is_absolute_path(s)) {
if (!NIL_P(dname)) {
- dname = rb_file_s_expand_path(1, &dname);
- if (OBJ_TAINTED(dname)) tainted = 1;
- strcpy(buf, RSTRING(dname)->ptr);
+ file_expand_path(dname, Qnil, result);
+ BUFINIT();
}
else {
+ char *dir = my_getcwd();
+
tainted = 1;
-#ifdef HAVE_GETCWD
- getcwd(buf, MAXPATHLEN);
-#else
- getwd(buf);
-#endif
+ dirlen = strlen(dir);
+ BUFCHECK(dirlen > buflen);
+ strcpy(buf, dir);
+ free(dir);
+ }
+#if defined DOSISH || defined __CYGWIN__
+ if (isdirsep(*s)) {
+ /* specified full path, but not drive letter nor UNC */
+ /* we need to get the drive letter or UNC share name */
+ p = skipprefix(buf);
}
- p = &buf[strlen(buf)];
- while (p > buf && *(p - 1) == '/') p--;
+ else
+#endif
+ p = chompdirsep(skiproot(buf));
}
else {
- while (*s && isdirsep(*s)) {
- *p++ = '/';
- s++;
- }
- if (p > buf && *s) p--;
+ b = s;
+ do s++; while (isdirsep(*s));
+ p = buf + (s - b);
+ BUFCHECK(bdiff >= buflen);
+ memset(buf, '/', p - buf);
}
- *p = '/';
+ if (p > buf && p[-1] == '/')
+ --p;
+ else
+ *p = '/';
- for ( ; *s; s++) {
+ p[1] = 0;
+ root = skipprefix(buf);
+
+ b = s;
+ while (*s) {
switch (*s) {
case '.':
- if (*(s+1)) {
- switch (*++s) {
+ if (b == s++) { /* beginning of path element */
+ switch (*s) {
+ case '\0':
+ b = s;
+ break;
case '.':
- if (*(s+1) == '\0' || isdirsep(*(s+1))) {
+ if (*(s+1) == '\0' || isdirsep(*(s+1))) {
/* We must go back to the parent */
- if (isdirsep(*p) && p > buf) p--;
- while (p > buf && !isdirsep(*p)) p--;
- }
- else {
- *++p = '.';
- do *++p = '.'; while (*++s == '.');
- --s;
+ *p = '\0';
+ if (!(b = strrdirsep(root))) {
+ *p = '/';
+ }
+ else {
+ p = b;
+ }
+ b = ++s;
}
break;
case '/':
-#if defined DOSISH
+#if defined DOSISH || defined __CYGWIN__
case '\\':
#endif
- if (!isdirsep(*p)) *++p = '/';
+ b = ++s;
break;
default:
- *++p = '.'; *++p = *s; break;
+ /* ordinary path element, beginning don't move */
+ break;
}
}
break;
case '/':
-#if defined DOSISH
+#if defined DOSISH || defined __CYGWIN__
case '\\':
#endif
- if (!isdirsep(*p)) *++p = '/'; break;
+ if (s > b) {
+ long rootdiff = root - buf;
+ BUFCHECK(bdiff + (s-b+1) >= buflen);
+ root = buf + rootdiff;
+ memcpy(++p, b, s-b);
+ p += s-b;
+ *p = '/';
+ }
+ b = ++s;
+ break;
default:
- *++p = *s;
+ s = CharNext(s);
+ break;
}
}
-
- /* Place a \0 at end. If path ends with a "/", delete it */
- if (p == buf || !isdirsep(*p)) p++;
+
+ if (s > b) {
+ BUFCHECK(bdiff + (s-b) >= buflen);
+ memcpy(++p, b, s-b);
+ p += s-b;
+ }
+ if (p == skiproot(buf) - 1) p++;
+
+ if (tainted) OBJ_TAINT(result);
+ RSTRING(result)->len = p - buf;
*p = '\0';
+ return result;
+}
+
+VALUE
+rb_file_expand_path(fname, dname)
+ VALUE fname, dname;
+{
+ return file_expand_path(fname, dname, rb_str_new(0, MAXPATHLEN + 2));
+}
+
+/*
+ * call-seq:
+ * File.expand_path(file_name [, dir_string] ) -> abs_file_name
+ *
+ * Converts a pathname to an absolute pathname. Relative paths are
+ * referenced from the current working directory of the process unless
+ * <i>dir_string</i> is given, in which case it will be used as the
+ * starting point. The given pathname may start with a
+ * ``<code>~</code>'', which expands to the process owner's home
+ * directory (the environment variable <code>HOME</code> must be set
+ * correctly). ``<code>~</code><i>user</i>'' expands to the named
+ * user's home directory.
+ *
+ * File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
+ * File.expand_path("../../bin", "/tmp/x") #=> "/bin"
+ */
+
+VALUE
+rb_file_s_expand_path(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE fname, dname;
+
+ if (argc == 1) {
+ return rb_file_expand_path(argv[0], Qnil);
+ }
+ rb_scan_args(argc, argv, "11", &fname, &dname);
- fname = rb_str_new2(buf);
- if (tainted) OBJ_TAINT(fname);
- return fname;
+ return rb_file_expand_path(fname, dname);
}
static int
@@ -1352,9 +2526,9 @@ rmext(p, e)
{
int l1, l2;
- l1 = strlen(p);
if (!e) return 0;
+ l1 = chompdirsep(p) - p;
l2 = strlen(e);
if (l2 == 2 && e[1] == '*') {
e = strrchr(p, *e);
@@ -1363,104 +2537,294 @@ rmext(p, e)
}
if (l1 < l2) return l1;
- if (strcmp(p+l1-l2, e) == 0) {
+ if (strncmp(p+l1-l2, e, l2) == 0) {
return l1-l2;
}
return 0;
}
+/*
+ * call-seq:
+ * File.basename(file_name [, suffix] ) -> base_name
+ *
+ * Returns the last component of the filename given in <i>file_name</i>,
+ * which must be formed using forward slashes (``<code>/</code>'')
+ * regardless of the separator used on the local file system. If
+ * <i>suffix</i> is given and present at the end of <i>file_name</i>,
+ * it is removed.
+ *
+ * File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
+ * File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
+ */
+
static VALUE
rb_file_s_basename(argc, argv)
int argc;
VALUE *argv;
{
VALUE fname, fext, basename;
- char *name, *p, *ext;
+ char *name, *p;
int f;
if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
- ext = STR2CSTR(fext);
+ StringValue(fext);
}
- name = STR2CSTR(fname);
- p = strrchr(name, '/');
- if (!p) {
- if (NIL_P(fext) || !(f = rmext(name, ext)))
- return fname;
- basename = rb_str_new(name, f);
+ StringValue(fname);
+ if (RSTRING(fname)->len == 0 || !*(name = RSTRING(fname)->ptr))
+ return fname;
+ if (!*(name = skiproot(name))) {
+ p = name - 1;
+ f = 1;
+#ifdef DOSISH_DRIVE_LETTER
+ if (*p == ':') {
+ p++;
+ f = 0;
+ }
+#endif
}
- else {
- p++; /* skip last `/' */
- if (NIL_P(fext) || !(f = rmext(p, ext))) {
- basename = rb_str_new2(p);
+ else if (!(p = strrdirsep(name))) {
+ if (NIL_P(fext) || !(f = rmext(name, StringValueCStr(fext)))) {
+ f = chompdirsep(name) - name;
+ if (f == RSTRING(fname)->len) return fname;
}
- else {
- basename = rb_str_new(p, f);
+ p = name;
+ }
+ else {
+ while (isdirsep(*p)) p++; /* skip last / */
+ if (NIL_P(fext) || !(f = rmext(p, StringValueCStr(fext)))) {
+ f = chompdirsep(p) - p;
}
}
+ basename = rb_str_new(p, f);
OBJ_INFECT(basename, fname);
return basename;
}
+/*
+ * call-seq:
+ * File.dirname(file_name ) -> dir_name
+ *
+ * Returns all components of the filename given in <i>file_name</i>
+ * except the last one. The filename must be formed using forward
+ * slashes (``<code>/</code>'') regardless of the separator used on the
+ * local file system.
+ *
+ * File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work"
+ */
+
static VALUE
rb_file_s_dirname(klass, fname)
VALUE klass, fname;
{
- char *name, *p;
+ char *name, *root, *p;
VALUE dirname;
- name = STR2CSTR(fname);
- p = strrchr(name, '/');
+ name = StringValueCStr(fname);
+ root = skiproot(name);
+#ifdef DOSISH_UNC
+ if (root > name + 2 && isdirsep(*name))
+ name = root - 2;
+#else
+ if (root > name + 1)
+ name = root - 1;
+#endif
+ p = strrdirsep(root);
if (!p) {
- return rb_str_new2(".");
+ p = root;
}
if (p == name)
- p++;
+ return rb_str_new2(".");
dirname = rb_str_new(name, p - name);
- if (OBJ_TAINTED(fname)) OBJ_TAINT(dirname);
+#ifdef DOSISH_DRIVE_LETTER
+ if (root == name + 2 && name[1] == ':')
+ rb_str_cat(dirname, ".", 1);
+#endif
+ OBJ_INFECT(dirname, fname);
return dirname;
}
+/*
+ * call-seq:
+ * File.extname(path) -> string
+ *
+ * Returns the extension (the portion of file name in <i>path</i>
+ * after the period).
+ *
+ * File.extname("test.rb") #=> ".rb"
+ * File.extname("a/b/d/test.rb") #=> ".rb"
+ * File.extname("test") #=> ""
+ * File.extname(".profile") #=> ""
+ *
+ */
+
+static VALUE
+rb_file_s_extname(klass, fname)
+ VALUE klass, fname;
+{
+ char *name, *p, *e;
+ VALUE extname;
+
+ name = StringValueCStr(fname);
+ p = strrdirsep(name); /* get the last path component */
+ if (!p)
+ p = name;
+ else
+ p++;
+
+ e = strrchr(p, '.'); /* get the last dot of the last component */
+ if (!e || e == p) /* no dot, or the only dot is first? */
+ return rb_str_new2("");
+ extname = rb_str_new(e, chompdirsep(e) - e); /* keep the dot, too! */
+ OBJ_INFECT(extname, fname);
+ return extname;
+}
+
+/*
+ * call-seq:
+ * File.split(file_name) => array
+ *
+ * Splits the given string into a directory and a file component and
+ * returns them in a two-element array. See also
+ * <code>File::dirname</code> and <code>File::basename</code>.
+ *
+ * File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
+ */
+
static VALUE
rb_file_s_split(klass, path)
VALUE klass, path;
{
+ StringValue(path); /* get rid of converting twice */
return rb_assoc_new(rb_file_s_dirname(Qnil, path), rb_file_s_basename(1,&path));
}
static VALUE separator;
+static VALUE rb_file_join _((VALUE ary, VALUE sep));
+
+static VALUE
+file_inspect_join(ary, arg)
+ VALUE ary;
+ VALUE *arg;
+{
+ return rb_file_join(arg[0], arg[1]);
+}
+
+static VALUE
+rb_file_join(ary, sep)
+ VALUE ary, sep;
+{
+ long len, i;
+ int taint = 0;
+ VALUE result, tmp;
+ char *name;
+
+ if (RARRAY(ary)->len == 0) return rb_str_new(0, 0);
+ if (OBJ_TAINTED(ary)) taint = 1;
+ if (OBJ_TAINTED(sep)) taint = 1;
+
+ len = 1;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ if (TYPE(RARRAY(ary)->ptr[i]) == T_STRING) {
+ len += RSTRING(RARRAY(ary)->ptr[i])->len;
+ }
+ else {
+ len += 10;
+ }
+ }
+ if (!NIL_P(sep) && TYPE(sep) == T_STRING) {
+ len += RSTRING(sep)->len * RARRAY(ary)->len - 1;
+ }
+ result = rb_str_buf_new(len);
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ tmp = RARRAY(ary)->ptr[i];
+ switch (TYPE(tmp)) {
+ case T_STRING:
+ break;
+ case T_ARRAY:
+ if (rb_inspecting_p(tmp)) {
+ tmp = rb_str_new2("[...]");
+ }
+ else {
+ VALUE args[2];
+
+ args[0] = tmp;
+ args[1] = sep;
+ tmp = rb_protect_inspect(file_inspect_join, ary, (VALUE)args);
+ }
+ break;
+ default:
+ tmp = rb_obj_as_string(tmp);
+ }
+ name = StringValueCStr(result);
+ if (i > 0 && !NIL_P(sep) && !*chompdirsep(name))
+ rb_str_buf_append(result, sep);
+ rb_str_buf_append(result, tmp);
+ if (OBJ_TAINTED(tmp)) taint = 1;
+ }
+
+ if (taint) OBJ_TAINT(result);
+ return result;
+}
+
+/*
+ * call-seq:
+ * File.join(string, ...) -> path
+ *
+ * Returns a new string formed by joining the strings using
+ * <code>File::SEPARATOR</code>.
+ *
+ * File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
+ *
+ */
+
static VALUE
rb_file_s_join(klass, args)
VALUE klass, args;
{
- return rb_ary_join(args, separator);
+ return rb_file_join(args, separator);
}
+/*
+ * call-seq:
+ * File.truncate(file_name, integer) => 0
+ *
+ * Truncates the file <i>file_name</i> to be at most <i>integer</i>
+ * bytes long. Not available on all platforms.
+ *
+ * f = File.new("out", "w")
+ * f.write("1234567890") #=> 10
+ * f.close #=> nil
+ * File.truncate("out", 5) #=> 0
+ * File.size("out") #=> 5
+ *
+ */
+
static VALUE
rb_file_s_truncate(klass, path, len)
VALUE klass, path, len;
{
rb_secure(2);
- Check_SafeStr(path);
+ SafeStringValue(path);
#ifdef HAVE_TRUNCATE
- if (truncate(RSTRING(path)->ptr, NUM2INT(len)) < 0)
+ if (truncate(StringValueCStr(path), NUM2OFFT(len)) < 0)
rb_sys_fail(RSTRING(path)->ptr);
#else
# ifdef HAVE_CHSIZE
{
int tmpfd;
-# if defined(NT)
- if ((tmpfd = open(RSTRING(path)->ptr, O_RDWR)) < 0) {
+# ifdef _WIN32
+ if ((tmpfd = open(StringValueCStr(path), O_RDWR)) < 0) {
rb_sys_fail(RSTRING(path)->ptr);
}
# else
- if ((tmpfd = open(RSTRING(path)->ptr, 0)) < 0) {
+ if ((tmpfd = open(StringValueCStr(path), 0)) < 0) {
rb_sys_fail(RSTRING(path)->ptr);
}
# endif
- if (chsize(tmpfd, NUM2INT(len)) < 0) {
+ if (chsize(tmpfd, NUM2OFFT(len)) < 0) {
close(tmpfd);
rb_sys_fail(RSTRING(path)->ptr);
}
@@ -1473,23 +2837,41 @@ rb_file_s_truncate(klass, path, len)
return INT2FIX(0);
}
+/*
+ * call-seq:
+ * file.truncate(integer) => 0
+ *
+ * Truncates <i>file</i> to at most <i>integer</i> bytes. The file
+ * must be opened for writing. Not available on all platforms.
+ *
+ * f = File.new("out", "w")
+ * f.syswrite("1234567890") #=> 10
+ * f.truncate(5) #=> 0
+ * f.close() #=> nil
+ * File.size("out") #=> 5
+ */
+
static VALUE
rb_file_truncate(obj, len)
VALUE obj, len;
{
OpenFile *fptr;
+ FILE *f;
rb_secure(2);
GetOpenFile(obj, fptr);
if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing");
}
+ f = GetWriteFile(fptr);
+ fflush(f);
+ fseeko(f, (off_t)0, SEEK_CUR);
#ifdef HAVE_TRUNCATE
- if (ftruncate(fileno(fptr->f), NUM2INT(len)) < 0)
+ if (ftruncate(fileno(f), NUM2OFFT(len)) < 0)
rb_sys_fail(fptr->path);
#else
# ifdef HAVE_CHSIZE
- if (chsize(fileno(fptr->f), NUM2INT(len)) < 0)
+ if (chsize(fileno(f), NUM2OFFT(len)) < 0)
rb_sys_fail(fptr->path);
# else
rb_notimplement();
@@ -1511,7 +2893,7 @@ rb_file_truncate(obj, len)
# define LOCK_UN 8
# endif
-#if defined(EWOULDBLOCK) && 0
+#if 0
static int
rb_thread_flock(fd, op, fptr)
int fd, op;
@@ -1540,6 +2922,35 @@ rb_thread_flock(fd, op, fptr)
#define flock(fd, op) rb_thread_flock(fd, op, fptr)
#endif
+/*
+ * call-seq:
+ * file.flock (locking_constant ) => 0 or false
+ *
+ * Locks or unlocks a file according to <i>locking_constant</i> (a
+ * logical <em>or</em> of the values in the table below).
+ * Returns <code>false</code> if <code>File::LOCK_NB</code> is
+ * specified and the operation would otherwise have blocked. Not
+ * available on all platforms.
+ *
+ * Locking constants (in class File):
+ *
+ * LOCK_EX | Exclusive lock. Only one process may hold an
+ * | exclusive lock for a given file at a time.
+ * ----------+------------------------------------------------
+ * LOCK_NB | Don't block when locking. May be combined
+ * | with other lock options using logical or.
+ * ----------+------------------------------------------------
+ * LOCK_SH | Shared lock. Multiple processes may each hold a
+ * | shared lock for a given file at the same time.
+ * ----------+------------------------------------------------
+ * LOCK_UN | Unlock.
+ *
+ * Example:
+ *
+ * File.new("testfile").flock(File::LOCK_UN) #=> 0
+ *
+ */
+
static VALUE
rb_file_flock(obj, operation)
VALUE obj;
@@ -1547,7 +2958,6 @@ rb_file_flock(obj, operation)
{
#ifndef __CHECKER__
OpenFile *fptr;
- int ret;
rb_secure(2);
GetOpenFile(obj, fptr);
@@ -1555,10 +2965,8 @@ rb_file_flock(obj, operation)
if (fptr->mode & FMODE_WRITABLE) {
fflush(GetWriteFile(fptr));
}
- TRAP_BEG;
- ret = flock(fileno(fptr->f), NUM2INT(operation));
- TRAP_END;
- if (ret < 0) {
+ retry:
+ if (flock(fileno(fptr->f), NUM2INT(operation)) < 0) {
switch (errno) {
case EAGAIN:
case EACCES:
@@ -1566,6 +2974,11 @@ rb_file_flock(obj, operation)
case EWOULDBLOCK:
#endif
return Qfalse;
+ case EINTR:
+#if defined(ERESTART)
+ case ERESTART:
+#endif
+ goto retry;
}
rb_sys_fail(fptr->path);
}
@@ -1582,23 +2995,80 @@ test_check(n, argc, argv)
int i;
n+=1;
- if (n != argc) rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, n);
+ if (n != argc) rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, n);
for (i=1; i<n; i++) {
switch (TYPE(argv[i])) {
case T_STRING:
- Check_SafeStr(argv[i]);
+ default:
+ SafeStringValue(argv[i]);
break;
case T_FILE:
break;
- default:
- Check_Type(argv[i], T_STRING);
- break;
}
}
}
#define CHECK(n) test_check((n), argc, argv)
+/*
+ * call-seq:
+ * test(int_cmd, file1 [, file2] ) => obj
+ *
+ * Uses the integer <i>aCmd</i> to perform various tests on
+ * <i>file1</i> (first table below) or on <i>file1</i> and
+ * <i>file2</i> (second table).
+ *
+ * File tests on a single file:
+ *
+ * Test Returns Meaning
+ * ?A | Time | Last access time for file1
+ * ?b | boolean | True if file1 is a block device
+ * ?c | boolean | True if file1 is a character device
+ * ?C | Time | Last change time for file1
+ * ?d | boolean | True if file1 exists and is a directory
+ * ?e | boolean | True if file1 exists
+ * ?f | boolean | True if file1 exists and is a regular file
+ * ?g | boolean | True if files has the \CF{setgid} bit
+ * | | set (false under NT)
+ * ?G | boolean | True if file1 exists and has a group
+ * | | ownership equal to the caller's group
+ * ?k | boolean | True if file1 exists and has the sticky bit set
+ * ?l | boolean | True if files exists and is a symbolic link
+ * ?M | Time | Last modification time for file1
+ * ?o | boolean | True if files exists and is owned by
+ * | | the caller's effective uid
+ * ?O | boolean | True if file1 exists and is owned by
+ * | | the caller's real uid
+ * ?p | boolean | True if file1 exists and is a fifo
+ * ?r | boolean | True if file1 is readable by the effective
+ * | | uid/gid of the caller
+ * ?R | boolean | True if file is readable by the real
+ * | | uid/gid of the caller
+ * ?s | int/nil | If files has nonzero size, return the size,
+ * | | otherwise return nil
+ * ?S | boolean | True if file1 exists and is a socket
+ * ?u | boolean | True if file1 has the setuid bit set
+ * ?w | boolean | True if file1 exists and is writable by
+ * | | the effective uid/gid
+ * ?W | boolean | True if file1 exists and is writable by
+ * | | the real uid/gid
+ * ?x | boolean | True if file1 exists and is executable by
+ * | | the effective uid/gid
+ * ?X | boolean | True if file1 exists and is executable by
+ * | | the real uid/gid
+ * ?z | boolean | True if file1 exists and has a zero length
+ *
+ * Tests that take two files:
+ *
+ * ?- | boolean | True if file1 is a hard link to file2
+ * ?= | boolean | True if the modification times of file1
+ * | | and file2 are equal
+ * ?< | boolean | True if the modification time of file1
+ * | | is prior to that of file2
+ * ?> | boolean | True if the modification time of file1
+ * | | is after that of file2
+ */
+
static VALUE
rb_f_test(argc, argv)
int argc;
@@ -1606,7 +3076,7 @@ rb_f_test(argc, argv)
{
int cmd;
- if (argc == 0) rb_raise(rb_eArgError, "wrong # of arguments");
+ if (argc == 0) rb_raise(rb_eArgError, "wrong number of arguments");
#if 0 /* 1.7 behavior? */
if (argc == 1) {
return RTEST(argv[0]) ? Qtrue : Qfalse;
@@ -1716,15 +3186,15 @@ rb_f_test(argc, argv)
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
return Qtrue;
return Qfalse;
-
+
case '=':
if (st1.st_mtime == st2.st_mtime) return Qtrue;
return Qfalse;
-
+
case '>':
if (st1.st_mtime > st2.st_mtime) return Qtrue;
return Qfalse;
-
+
case '<':
if (st1.st_mtime < st2.st_mtime) return Qtrue;
return Qfalse;
@@ -1735,30 +3205,100 @@ rb_f_test(argc, argv)
return Qnil; /* not reached */
}
+
+
+/*
+ * Document-class: File::Stat
+ *
+ * Objects of class <code>File::Stat</code> encapsulate common status
+ * information for <code>File</code> objects. The information is
+ * recorded at the moment the <code>File::Stat</code> object is
+ * created; changes made to the file after that point will not be
+ * reflected. <code>File::Stat</code> objects are returned by
+ * <code>IO#stat</code>, <code>File::stat</code>,
+ * <code>File#lstat</code>, and <code>File::lstat</code>. Many of these
+ * methods return platform-specific values, and not all values are
+ * meaningful on all systems. See also <code>Kernel#test</code>.
+ */
+
+static VALUE rb_stat_s_alloc _((VALUE));
static VALUE
-rb_stat_s_new(klass, fname)
- VALUE klass, fname;
+rb_stat_s_alloc(klass)
+ VALUE klass;
{
- VALUE s;
- struct stat st;
+ return stat_new_0(klass, 0);
+}
+
+/*
+ * call-seq:
+ *
+ * File::Stat.new(file_name) => stat
+ *
+ * Create a File::Stat object for the given file name (raising an
+ * exception if the file doesn't exist).
+ */
+
+static VALUE
+rb_stat_init(obj, fname)
+ VALUE obj, fname;
+{
+ struct stat st, *nst;
+
+ SafeStringValue(fname);
- Check_SafeStr(fname);
- if (rb_sys_stat(RSTRING(fname)->ptr, &st) == -1) {
+ if (stat(StringValueCStr(fname), &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr);
}
- s = stat_new_0(klass, &st);
- rb_obj_call_init(s, 1, &fname);
- return s;
+ if (DATA_PTR(obj)) {
+ free(DATA_PTR(obj));
+ DATA_PTR(obj) = NULL;
+ }
+ nst = ALLOC(struct stat);
+ *nst = st;
+ DATA_PTR(obj) = nst;
+
+ return Qnil;
}
static VALUE
-rb_stat_init(klass, fname)
- VALUE klass, fname;
+rb_stat_init_copy(copy, orig)
+ VALUE copy, orig;
{
- /* do nothing */
- return Qnil;
+ struct stat *nst;
+
+ if (copy == orig) return orig;
+ rb_check_frozen(copy);
+ /* need better argument type check */
+ if (!rb_obj_is_instance_of(orig, rb_obj_class(copy))) {
+ rb_raise(rb_eTypeError, "wrong argument class");
+ }
+ if (DATA_PTR(copy)) {
+ free(DATA_PTR(copy));
+ DATA_PTR(copy) = 0;
+ }
+ if (DATA_PTR(orig)) {
+ nst = ALLOC(struct stat);
+ *nst = *(struct stat*)DATA_PTR(orig);
+ DATA_PTR(copy) = nst;
+ }
+
+ return copy;
}
+/*
+ * call-seq:
+ * stat.ftype => string
+ *
+ * Identifies the type of <i>stat</i>. The return string is one of:
+ * ``<code>file</code>'', ``<code>directory</code>'',
+ * ``<code>characterSpecial</code>'', ``<code>blockSpecial</code>'',
+ * ``<code>fifo</code>'', ``<code>link</code>'',
+ * ``<code>socket</code>'', or ``<code>unknown</code>''.
+ *
+ * File.stat("/dev/tty").ftype #=> "characterSpecial"
+ *
+ */
+
static VALUE
rb_stat_ftype(obj)
VALUE obj;
@@ -1766,6 +3306,17 @@ rb_stat_ftype(obj)
return rb_file_ftype(get_stat(obj));
}
+/*
+ * call-seq:
+ * stat.directory? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is a directory,
+ * <code>false</code> otherwise.
+ *
+ * File.stat("testfile").directory? #=> false
+ * File.stat(".").directory? #=> true
+ */
+
static VALUE
rb_stat_d(obj)
VALUE obj;
@@ -1774,6 +3325,14 @@ rb_stat_d(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.pipe? => true or false
+ *
+ * Returns <code>true</code> if the operating system supports pipes and
+ * <i>stat</i> is a pipe; <code>false</code> otherwise.
+ */
+
static VALUE
rb_stat_p(obj)
VALUE obj;
@@ -1785,6 +3344,23 @@ rb_stat_p(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.symlink? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is a symbolic link,
+ * <code>false</code> if it isn't or if the operating system doesn't
+ * support this feature. As <code>File::stat</code> automatically
+ * follows symbolic links, <code>symlink?</code> will always be
+ * <code>false</code> for an object returned by
+ * <code>File::stat</code>.
+ *
+ * File.symlink("testfile", "alink") #=> 0
+ * File.stat("alink").symlink? #=> false
+ * File.lstat("alink").symlink? #=> true
+ *
+ */
+
static VALUE
rb_stat_l(obj)
VALUE obj;
@@ -1795,6 +3371,18 @@ rb_stat_l(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.socket? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is a socket,
+ * <code>false</code> if it isn't or if the operating system doesn't
+ * support this feature.
+ *
+ * File.stat("testfile").socket? #=> false
+ *
+ */
+
static VALUE
rb_stat_S(obj)
VALUE obj;
@@ -1806,6 +3394,19 @@ rb_stat_S(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.blockdev? => true or false
+ *
+ * Returns <code>true</code> if the file is a block device,
+ * <code>false</code> if it isn't or if the operating system doesn't
+ * support this feature.
+ *
+ * File.stat("testfile").blockdev? #=> false
+ * File.stat("/dev/hda1").blockdev? #=> true
+ *
+ */
+
static VALUE
rb_stat_b(obj)
VALUE obj;
@@ -1817,6 +3418,18 @@ rb_stat_b(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.chardev? => true or false
+ *
+ * Returns <code>true</code> if the file is a character device,
+ * <code>false</code> if it isn't or if the operating system doesn't
+ * support this feature.
+ *
+ * File.stat("/dev/tty").chardev? #=> true
+ *
+ */
+
static VALUE
rb_stat_c(obj)
VALUE obj;
@@ -1826,6 +3439,18 @@ rb_stat_c(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.owned? => true or false
+ *
+ * Returns <code>true</code> if the effective user id of the process is
+ * the same as the owner of <i>stat</i>.
+ *
+ * File.stat("testfile").owned? #=> true
+ * File.stat("/etc/passwd").owned? #=> false
+ *
+ */
+
static VALUE
rb_stat_owned(obj)
VALUE obj;
@@ -1842,16 +3467,39 @@ rb_stat_rowned(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.grpowned? => true or false
+ *
+ * Returns true if the effective group id of the process is the same as
+ * the group id of <i>stat</i>. On Windows NT, returns <code>false</code>.
+ *
+ * File.stat("testfile").grpowned? #=> true
+ * File.stat("/etc/passwd").grpowned? #=> false
+ *
+ */
+
static VALUE
rb_stat_grpowned(obj)
VALUE obj;
{
-#ifndef NT
+#ifndef _WIN32
if (get_stat(obj)->st_gid == getegid()) return Qtrue;
#endif
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.readable? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is readable by the
+ * effective user id of this process.
+ *
+ * File.stat("testfile").readable? #=> true
+ *
+ */
+
static VALUE
rb_stat_r(obj)
VALUE obj;
@@ -1872,6 +3520,19 @@ rb_stat_r(obj)
return Qtrue;
}
+
+
+/*
+ * call-seq:
+ * stat.readable_real? -> true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is readable by the real
+ * user id of this process.
+ *
+ * File.stat("testfile").readable_real? #=> true
+ *
+ */
+
static VALUE
rb_stat_R(obj)
VALUE obj;
@@ -1892,6 +3553,17 @@ rb_stat_R(obj)
return Qtrue;
}
+/*
+ * call-seq:
+ * stat.writable? -> true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is writable by the
+ * effective user id of this process.
+ *
+ * File.stat("testfile").writable? #=> true
+ *
+ */
+
static VALUE
rb_stat_w(obj)
VALUE obj;
@@ -1912,6 +3584,17 @@ rb_stat_w(obj)
return Qtrue;
}
+/*
+ * call-seq:
+ * stat.writable_real? -> true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is writable by the real
+ * user id of this process.
+ *
+ * File.stat("testfile").writable_real? #=> true
+ *
+ */
+
static VALUE
rb_stat_W(obj)
VALUE obj;
@@ -1932,6 +3615,19 @@ rb_stat_W(obj)
return Qtrue;
}
+/*
+ * call-seq:
+ * stat.executable? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is executable or if the
+ * operating system doesn't distinguish executable files from
+ * nonexecutable files. The tests are made using the effective owner of
+ * the process.
+ *
+ * File.stat("testfile").executable? #=> false
+ *
+ */
+
static VALUE
rb_stat_x(obj)
VALUE obj;
@@ -1952,6 +3648,15 @@ rb_stat_x(obj)
return Qtrue;
}
+/*
+ * call-seq:
+ * stat.executable_real? => true or false
+ *
+ * Same as <code>executable?</code>, but tests using the real owner of
+ * the process.
+ */
+
+
static VALUE
rb_stat_X(obj)
VALUE obj;
@@ -1972,6 +3677,17 @@ rb_stat_X(obj)
return Qtrue;
}
+/*
+ * call-seq:
+ * stat.file? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is a regular file (not
+ * a device file, pipe, socket, etc.).
+ *
+ * File.stat("testfile").file? #=> true
+ *
+ */
+
static VALUE
rb_stat_f(obj)
VALUE obj;
@@ -1980,6 +3696,17 @@ rb_stat_f(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.zero? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> is a zero-length file;
+ * <code>false</code> otherwise.
+ *
+ * File.stat("testfile").zero? #=> false
+ *
+ */
+
static VALUE
rb_stat_z(obj)
VALUE obj;
@@ -1988,16 +3715,38 @@ rb_stat_z(obj)
return Qfalse;
}
+
+/*
+ * call-seq:
+ * state.size => integer
+ *
+ * Returns the size of <i>stat</i> in bytes.
+ *
+ * File.stat("testfile").size #=> 66
+ *
+ */
+
static VALUE
rb_stat_s(obj)
VALUE obj;
{
- int size = get_stat(obj)->st_size;
+ off_t size = get_stat(obj)->st_size;
if (size == 0) return Qnil;
- return INT2FIX(size);
+ return OFFT2NUM(size);
}
+/*
+ * call-seq:
+ * stat.setuid? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> has the set-user-id
+ * permission bit set, <code>false</code> if it doesn't or if the
+ * operating system doesn't support this feature.
+ *
+ * File.stat("/bin/su").setuid? #=> true
+ */
+
static VALUE
rb_stat_suid(obj)
VALUE obj;
@@ -2008,6 +3757,18 @@ rb_stat_suid(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.setgid? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> has the set-group-id
+ * permission bit set, <code>false</code> if it doesn't or if the
+ * operating system doesn't support this feature.
+ *
+ * File.stat("/usr/sbin/lpc").setgid? #=> true
+ *
+ */
+
static VALUE
rb_stat_sgid(obj)
VALUE obj;
@@ -2018,6 +3779,18 @@ rb_stat_sgid(obj)
return Qfalse;
}
+/*
+ * call-seq:
+ * stat.sticky? => true or false
+ *
+ * Returns <code>true</code> if <i>stat</i> has its sticky bit set,
+ * <code>false</code> if it doesn't or if the operating system doesn't
+ * support this feature.
+ *
+ * File.stat("testfile").sticky? #=> false
+ *
+ */
+
static VALUE
rb_stat_sticky(obj)
VALUE obj;
@@ -2042,74 +3815,85 @@ static int
is_absolute_path(path)
const char *path;
{
+#ifdef DOSISH_DRIVE_LETTER
+ if (has_drive_letter(path) && isdirsep(path[2])) return 1;
+#endif
+#ifdef DOSISH_UNC
+ if (isdirsep(path[0]) && isdirsep(path[1])) return 1;
+#endif
+#ifndef DOSISH
if (path[0] == '/') return 1;
-# if defined DOSISH
- if (path[0] == '\\') return 1;
- if (strlen(path) > 2 && path[1] == ':') return 1;
-# endif
+#endif
return 0;
}
+#ifndef DOSISH
static int
path_check_1(path)
- char *path;
+ VALUE path;
{
struct stat st;
- char *p = 0;
- char *s;
+ char *p0 = StringValueCStr(path);
+ char *p = 0, *s;
- if (!is_absolute_path(path)) {
- char buf[MAXPATHLEN+1];
+ if (!is_absolute_path(p0)) {
+ char *buf = my_getcwd();
+ VALUE newpath;
-#ifdef HAVE_GETCWD
- if (getcwd(buf, MAXPATHLEN) == 0) return 0;
-#else
- if (getwd(buf) == 0) return 0;
-#endif
- strncat(buf, "/", MAXPATHLEN);
- strncat(buf, path, MAXPATHLEN);
- buf[MAXPATHLEN] = '\0';
- return path_check_1(buf);
+ newpath = rb_str_new2(buf);
+ free(buf);
+
+ rb_str_cat2(newpath, "/");
+ rb_str_cat2(newpath, p0);
+ return path_check_1(newpath);
}
for (;;) {
- if (stat(path, &st) == 0 && (st.st_mode & 002)) {
- if (p) *p = '/';
+#ifndef S_IWOTH
+# define S_IWOTH 002
+#endif
+ if (stat(p0, &st) == 0 && S_ISDIR(st.st_mode) && (st.st_mode & S_IWOTH)
+#ifdef S_ISVTX
+ && !(st.st_mode & S_ISVTX)
+#endif
+ ) {
+ rb_warn("Insecure world writable dir %s, mode 0%o", p0, st.st_mode);
+ if (p) *p = '/';
return 0;
}
- s = strrchr(path, '/');
+ s = strrdirsep(p0);
if (p) *p = '/';
- if (!s || s == path) return 1;
+ if (!s || s == p0) return 1;
p = s;
*p = '\0';
}
}
+#endif
int
rb_path_check(path)
char *path;
{
- char *p, *pend;
+#ifndef DOSISH
+ char *p0, *p, *pend;
const char sep = PATH_SEP_CHAR;
if (!path) return 1;
- p = path;
- pend = strchr(path, sep);
-
+ pend = path + strlen(path);
+ p0 = path;
+ p = strchr(path, sep);
+ if (!p) p = pend;
+
for (;;) {
- int safe;
-
- if (pend) *pend = '\0';
- safe = path_check_1(p);
- if (!safe) {
- if (pend) *pend = sep;
- return 0;
- }
- if (!pend) break;
- *pend = sep;
- p = pend + 1;
- pend = strchr(p, sep);
+ if (!path_check_1(rb_str_new(p0, p - p0))) {
+ return 0; /* not safe */
+ }
+ p0 = p + 1;
+ if (p0 > pend) break;
+ p = strchr(p0, sep);
+ if (!p) p = pend;
}
+#endif
return 1;
}
@@ -2123,76 +3907,152 @@ is_macos_native_path(path)
}
#endif
-char*
-rb_find_file(file)
+static int
+file_load_ok(file)
char *file;
{
- extern VALUE rb_load_path;
- volatile VALUE vpath;
+ FILE *f;
+
+ if (!file) return 0;
+ f = fopen(file, "r");
+ if (f == NULL) return 0;
+ fclose(f);
+ return 1;
+}
+
+extern VALUE rb_load_path;
+
+int
+rb_find_file_ext(filep, ext)
+ VALUE *filep;
+ const char * const *ext;
+{
+ char *path, *found;
+ char *f = RSTRING(*filep)->ptr;
VALUE fname;
- char *path;
- struct stat st;
+ long i, j;
-#if defined(__MACOS__) || defined(riscos)
- if (is_macos_native_path(file)) {
- FILE *f;
+ if (f[0] == '~') {
+ fname = rb_file_expand_path(*filep, Qnil);
+ if (rb_safe_level() >= 2 && OBJ_TAINTED(fname)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
+ }
+ OBJ_FREEZE(fname);
+ f = StringValueCStr(fname);
+ *filep = fname;
+ }
- if (safe_level >= 2 && !rb_path_check(file)) {
- rb_raise(rb_eSecurityError, "loading from unsafe file %s", file);
+ if (is_absolute_path(f)) {
+ for (i=0; ext[i]; i++) {
+ fname = rb_str_dup(*filep);
+ rb_str_cat2(fname, ext[i]);
+ OBJ_FREEZE(fname);
+ if (file_load_ok(StringValueCStr(fname))) {
+ *filep = fname;
+ return i+1;
+ }
}
- f= fopen(file, "r");
- if (f == NULL) return 0;
- fclose(f);
- return file;
+ return 0;
}
-#endif
- if (is_absolute_path(file)) {
- FILE *f;
+ if (!rb_load_path) return 0;
+
+ Check_Type(rb_load_path, T_ARRAY);
+ for (i=0;i<RARRAY(rb_load_path)->len;i++) {
+ VALUE str = RARRAY(rb_load_path)->ptr[i];
+
+ SafeStringValue(str);
+ if (RSTRING(str)->len == 0) continue;
+ path = RSTRING(str)->ptr;
+ for (j=0; ext[j]; j++) {
+ fname = rb_str_dup(*filep);
+ rb_str_cat2(fname, ext[j]);
+ OBJ_FREEZE(fname);
+ found = dln_find_file(StringValueCStr(fname), path);
+ if (found && file_load_ok(found)) {
+ *filep = fname;
+ return j+1;
+ }
+ }
+ }
+ return 0;
+}
+
+VALUE
+rb_find_file(path)
+ VALUE path;
+{
+ VALUE tmp;
+ char *f = StringValueCStr(path);
+ char *lpath;
+
+ if (f[0] == '~') {
+ path = rb_file_expand_path(path, Qnil);
+ if (rb_safe_level() >= 1 && OBJ_TAINTED(path)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe path %s", f);
+ }
+ OBJ_FREEZE(path);
+ f = StringValueCStr(path);
+ }
- if (rb_safe_level() >= 2 && !rb_path_check(file)) {
- rb_raise(rb_eSecurityError, "loading from unsafe file %s", file);
+#if defined(__MACOS__) || defined(riscos)
+ if (is_macos_native_path(f)) {
+ if (rb_safe_level() >= 1 && !rb_path_check(f)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
- f = fopen(file, "r");
- if (f == NULL) return 0;
- fclose(f);
- return file;
+ if (file_load_ok(f)) return path;
}
+#endif
- if (file[0] == '~') {
- fname = rb_str_new2(file);
- fname = rb_file_s_expand_path(1, &fname);
- if (rb_safe_level() >= 2 && OBJ_TAINTED(fname)) {
- rb_raise(rb_eSecurityError, "loading from unsafe file %s", file);
+ if (is_absolute_path(f)) {
+ if (rb_safe_level() >= 1 && !rb_path_check(f)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
- file = STR2CSTR(fname);
+ if (file_load_ok(f)) return path;
+ }
+
+ if (rb_safe_level() >= 4) {
+ rb_raise(rb_eSecurityError, "loading from non-absolute path %s", f);
}
if (rb_load_path) {
- int i;
+ long i;
Check_Type(rb_load_path, T_ARRAY);
- vpath = rb_ary_new();
+ tmp = rb_ary_new();
for (i=0;i<RARRAY(rb_load_path)->len;i++) {
VALUE str = RARRAY(rb_load_path)->ptr[i];
- Check_SafeStr(str);
+ SafeStringValue(str);
if (RSTRING(str)->len > 0) {
- rb_ary_push(vpath, str);
+ rb_ary_push(tmp, str);
}
}
- vpath = rb_ary_join(vpath, rb_str_new2(PATH_SEP));
- path = STR2CSTR(vpath);
- if (rb_safe_level() >= 2 && !rb_path_check(path)) {
- rb_raise(rb_eSecurityError, "loading from unsafe path %s", path);
+ tmp = rb_ary_join(tmp, rb_str_new2(PATH_SEP));
+ if (RSTRING(tmp)->len == 0) {
+ lpath = 0;
+ }
+ else {
+ lpath = RSTRING(tmp)->ptr;
+ if (rb_safe_level() >= 1 && !rb_path_check(lpath)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe path %s", lpath);
+ }
}
}
else {
- path = 0;
+ lpath = 0;
}
- path = dln_find_file(file, path);
- if (path && stat(path, &st) == 0) {
- return path;
+ if (!lpath) {
+ return 0; /* no path, no load */
+ }
+ f = dln_find_file(f, lpath);
+ if (rb_safe_level() >= 1 && !rb_path_check(f)) {
+ rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
+ }
+ if (file_load_ok(f)) {
+ tmp = rb_str_new2(f);
+ OBJ_FREEZE(tmp);
+ return tmp;
}
return 0;
}
@@ -2207,6 +4067,39 @@ define_filetest_function(name, func, argc)
rb_define_singleton_method(rb_cFile, name, func, argc);
}
+
+/*
+ * A <code>File</code> is an abstraction of any file object accessible
+ * by the program and is closely associated with class <code>IO</code>
+ * <code>File</code> includes the methods of module
+ * <code>FileTest</code> as class methods, allowing you to write (for
+ * example) <code>File.exist?("foo")</code>.
+ *
+ * In the description of File methods,
+ * <em>permission bits</em> are a platform-specific
+ * set of bits that indicate permissions of a file. On Unix-based
+ * systems, permissions are viewed as a set of three octets, for the
+ * owner, the group, and the rest of the world. For each of these
+ * entities, permissions may be set to read, write, or execute the
+ * file:
+ *
+ * The permission bits <code>0644</code> (in octal) would thus be
+ * interpreted as read/write for owner, and read-only for group and
+ * other. Higher-order bits may also be used to indicate the type of
+ * file (plain, directory, pipe, socket, and so on) and various other
+ * special features. If the permissions are for a directory, the
+ * meaning of the execute bit changes; when set the directory can be
+ * searched.
+ *
+ * On non-Posix operating systems, there may be only the ability to
+ * make a file read-only or read-write. In this case, the remaining
+ * permission bits will be synthesized to resemble typical values. For
+ * instance, on Windows NT the default permission bits are
+ * <code>0644</code>, which means read/write for owner, read-only for
+ * all others. The only change that can be made is to make the file
+ * read-only, which is reported as <code>0444</code>.
+ */
+
void
Init_File()
{
@@ -2251,6 +4144,8 @@ Init_File()
rb_define_singleton_method(rb_cFile, "utime", rb_file_s_utime, -1);
rb_define_singleton_method(rb_cFile, "chmod", rb_file_s_chmod, -1);
rb_define_singleton_method(rb_cFile, "chown", rb_file_s_chown, -1);
+ rb_define_singleton_method(rb_cFile, "lchmod", rb_file_s_lchmod, -1);
+ rb_define_singleton_method(rb_cFile, "lchown", rb_file_s_lchown, -1);
rb_define_singleton_method(rb_cFile, "link", rb_file_s_link, 2);
rb_define_singleton_method(rb_cFile, "symlink", rb_file_s_symlink, 2);
@@ -2264,19 +4159,20 @@ Init_File()
rb_define_singleton_method(rb_cFile, "expand_path", rb_file_s_expand_path, -1);
rb_define_singleton_method(rb_cFile, "basename", rb_file_s_basename, -1);
rb_define_singleton_method(rb_cFile, "dirname", rb_file_s_dirname, 1);
+ rb_define_singleton_method(rb_cFile, "extname", rb_file_s_extname, 1);
- separator = rb_str_new2("/");
+ separator = rb_obj_freeze(rb_str_new2("/"));
rb_define_const(rb_cFile, "Separator", separator);
rb_define_const(rb_cFile, "SEPARATOR", separator);
rb_define_singleton_method(rb_cFile, "split", rb_file_s_split, 1);
rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2);
-#if defined DOSISH && !defined __CYGWIN__
- rb_define_const(rb_cFile, "ALT_SEPARATOR", rb_str_new2("\\"));
+#ifdef DOSISH
+ rb_define_const(rb_cFile, "ALT_SEPARATOR", rb_obj_freeze(rb_str_new2("\\")));
#else
rb_define_const(rb_cFile, "ALT_SEPARATOR", Qnil);
#endif
- rb_define_const(rb_cFile, "PATH_SEPARATOR", rb_str_new2(PATH_SEP));
+ rb_define_const(rb_cFile, "PATH_SEPARATOR", rb_obj_freeze(rb_str_new2(PATH_SEP)));
rb_define_method(rb_cIO, "stat", rb_io_stat, 0); /* this is IO's method */
rb_define_method(rb_cFile, "lstat", rb_file_lstat, 0);
@@ -2292,31 +4188,35 @@ Init_File()
rb_define_method(rb_cFile, "flock", rb_file_flock, 1);
rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
- rb_include_module(rb_cFile, rb_mFConst);
+ rb_include_module(rb_cIO, rb_mFConst);
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);
-
rb_define_global_function("test", rb_f_test, -1);
rb_cStat = rb_define_class_under(rb_cFile, "Stat", rb_cObject);
- rb_define_singleton_method(rb_cStat, "new", rb_stat_s_new, 1);
+ rb_define_alloc_func(rb_cStat, rb_stat_s_alloc);
rb_define_method(rb_cStat, "initialize", rb_stat_init, 1);
+ rb_define_method(rb_cStat, "initialize_copy", rb_stat_init_copy, 1);
rb_include_module(rb_cStat, rb_mComparable);
rb_define_method(rb_cStat, "<=>", rb_stat_cmp, 1);
rb_define_method(rb_cStat, "dev", rb_stat_dev, 0);
+ rb_define_method(rb_cStat, "dev_major", rb_stat_dev_major, 0);
+ rb_define_method(rb_cStat, "dev_minor", rb_stat_dev_minor, 0);
rb_define_method(rb_cStat, "ino", rb_stat_ino, 0);
rb_define_method(rb_cStat, "mode", rb_stat_mode, 0);
rb_define_method(rb_cStat, "nlink", rb_stat_nlink, 0);
rb_define_method(rb_cStat, "uid", rb_stat_uid, 0);
rb_define_method(rb_cStat, "gid", rb_stat_gid, 0);
rb_define_method(rb_cStat, "rdev", rb_stat_rdev, 0);
+ rb_define_method(rb_cStat, "rdev_major", rb_stat_rdev_major, 0);
+ rb_define_method(rb_cStat, "rdev_minor", rb_stat_rdev_minor, 0);
rb_define_method(rb_cStat, "size", rb_stat_size, 0);
rb_define_method(rb_cStat, "blksize", rb_stat_blksize, 0);
rb_define_method(rb_cStat, "blocks", rb_stat_blocks, 0);
diff --git a/gc.c b/gc.c
index a0e4ce6404..b00c170927 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-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -20,15 +20,39 @@
#include "re.h"
#include <stdio.h>
#include <setjmp.h>
+#include <sys/types.h>
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#ifdef __ia64__
+#include <ucontext.h>
+#if defined(__FreeBSD__)
+/*
+ * FreeBSD/ia64 currently does not have a way for a process to get the
+ * base address for the RSE backing store, so hardcode it.
+ */
+#define __libc_ia64_register_backing_store_base (4ULL<<61)
+#else
+#pragma weak __libc_ia64_register_backing_store_base
+extern unsigned long __libc_ia64_register_backing_store_base;
+#endif
+#endif
+
+#if defined _WIN32 || defined __CYGWIN__
+#include <windows.h>
+#endif
void re_free_registers _((struct re_registers*));
void rb_io_fptr_finalize _((struct OpenFile*));
-#ifndef setjmp
-#ifdef HAVE__SETJMP
+#if !defined(setjmp) && defined(HAVE__SETJMP)
#define setjmp(env) _setjmp(env)
-#define longjmp(env,val) _longjmp(env,val)
-#endif
#endif
/* Make alloca work the best possible way. */
@@ -39,19 +63,19 @@ void rb_io_fptr_finalize _((struct OpenFile*));
# endif
# endif /* atarist */
#else
-# if defined(HAVE_ALLOCA_H)
+# ifdef HAVE_ALLOCA_H
# include <alloca.h>
-# elif !defined(alloca)
-void *alloca();
-# endif
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+void *alloca ();
+# endif
+# endif /* AIX */
+# endif /* HAVE_ALLOCA_H */
#endif /* __GNUC__ */
-#ifdef _AIX
-#pragma alloca
-#endif
-
-static void run_final();
-
#ifndef GC_MALLOC_LIMIT
#if defined(MSDOS) || defined(__human68k__)
#define GC_MALLOC_LIMIT 200000
@@ -60,23 +84,23 @@ static void run_final();
#endif
#endif
-static unsigned long malloc_memories = 0;
+static unsigned long malloc_increase = 0;
+static unsigned long malloc_limit = GC_MALLOC_LIMIT;
+static void run_final();
+static VALUE nomem_error;
+static void garbage_collect();
-static void
-mem_error(mesg)
- char *mesg;
+void
+rb_memerror()
{
static int recurse = 0;
- if (rb_safe_level() >= 4) {
- rb_raise(rb_eNoMemError, mesg);
- }
- if (recurse == 0) {
- recurse++;
- rb_fatal(mesg);
+ if (recurse > 0 && rb_safe_level() < 4) {
+ fprintf(stderr, "[FATAL] failed to allocate memory\n");
+ exit(1);
}
- fprintf(stderr, "[FATAL] failed to allocate memory\n");
- exit(1);
+ recurse++;
+ rb_exc_raise(nomem_error);
}
void *
@@ -89,20 +113,17 @@ ruby_xmalloc(size)
rb_raise(rb_eNoMemError, "negative allocation size (or too big)");
}
if (size == 0) size = 1;
- malloc_memories += size;
+ malloc_increase += size;
- if (malloc_memories > GC_MALLOC_LIMIT) {
- rb_gc();
+ if (malloc_increase > malloc_limit) {
+ garbage_collect();
}
RUBY_CRITICAL(mem = malloc(size));
if (!mem) {
- rb_gc();
+ garbage_collect();
RUBY_CRITICAL(mem = malloc(size));
if (!mem) {
- if (size >= 10 * 1024 * 1024) {
- rb_raise(rb_eNoMemError, "tried to allocate too big memory");
- }
- mem_error("failed to allocate memory");
+ rb_memerror();
}
}
@@ -133,16 +154,14 @@ ruby_xrealloc(ptr, size)
}
if (!ptr) return xmalloc(size);
if (size == 0) size = 1;
- malloc_memories += size;
+ malloc_increase += size;
RUBY_CRITICAL(mem = realloc(ptr, size));
if (!mem) {
- rb_gc();
+ garbage_collect();
RUBY_CRITICAL(mem = realloc(ptr, size));
- if (!mem)
- if (size >= 50 * 1024 * 1024) {
- rb_raise(rb_eNoMemError, "tried to re-allocate too big memory");
- }
- mem_error("failed to allocate memory(realloc)");
+ if (!mem) {
+ rb_memerror();
+ }
}
return mem;
@@ -162,8 +181,22 @@ static int during_gc;
static int need_call_final = 0;
static st_table *finalizer_table = 0;
-static VALUE
-gc_enable()
+
+/*
+ * call-seq:
+ * GC.enable => true or false
+ *
+ * Enables garbage collection, returning <code>true</code> if garbage
+ * collection was previously disabled.
+ *
+ * GC.disable #=> false
+ * GC.enable #=> true
+ * GC.enable #=> false
+ *
+ */
+
+VALUE
+rb_gc_enable()
{
int old = dont_gc;
@@ -171,8 +204,20 @@ gc_enable()
return old;
}
-static VALUE
-gc_disable()
+/*
+ * call-seq:
+ * GC.disable => true or false
+ *
+ * Disables garbage collection, returning <code>true</code> if garbage
+ * collection was already disabled.
+ *
+ * GC.disable #=> false
+ * GC.disable #=> true
+ *
+ */
+
+VALUE
+rb_gc_disable()
{
int old = dont_gc;
@@ -185,7 +230,7 @@ VALUE rb_mGC;
static struct gc_list {
VALUE *varptr;
struct gc_list *next;
-} *Global_List = 0;
+} *global_List = 0;
void
rb_gc_register_address(addr)
@@ -194,19 +239,19 @@ rb_gc_register_address(addr)
struct gc_list *tmp;
tmp = ALLOC(struct gc_list);
- tmp->next = Global_List;
+ tmp->next = global_List;
tmp->varptr = addr;
- Global_List = tmp;
+ global_List = tmp;
}
void
rb_gc_unregister_address(addr)
VALUE *addr;
{
- struct gc_list *tmp = Global_List;
+ struct gc_list *tmp = global_List;
if (tmp->varptr == addr) {
- Global_List = tmp->next;
+ global_List = tmp->next;
RUBY_CRITICAL(free(tmp));
return;
}
@@ -222,6 +267,8 @@ rb_gc_unregister_address(addr)
}
}
+#undef GC_DEBUG
+
void
rb_global_variable(var)
VALUE *var;
@@ -232,7 +279,7 @@ rb_global_variable(var)
typedef struct RVALUE {
union {
struct {
- unsigned long flag; /* always 0 for freed obj */
+ unsigned long flags; /* always 0 for freed obj */
struct RVALUE *next;
} free;
struct RBasic basic;
@@ -252,17 +299,26 @@ typedef struct RVALUE {
struct RVarmap varmap;
struct SCOPE scope;
} as;
+#ifdef GC_DEBUG
+ char *file;
+ int line;
+#endif
} RVALUE;
static RVALUE *freelist = 0;
static RVALUE *deferred_final_list = 0;
#define HEAPS_INCREMENT 10
-static RVALUE **heaps;
+static struct heaps_slot {
+ RVALUE *slot;
+ int limit;
+} *heaps;
static int heaps_length = 0;
static int heaps_used = 0;
-#define HEAP_SLOTS 10000
+#define HEAP_MIN_SLOTS 10000
+static int heap_slots = HEAP_MIN_SLOTS;
+
#define FREE_MIN 4096
static RVALUE *himem, *lomem;
@@ -274,21 +330,42 @@ add_heap()
if (heaps_used == heaps_length) {
/* Realloc heaps */
+ struct heaps_slot *p;
+ int length;
+
heaps_length += HEAPS_INCREMENT;
- RUBY_CRITICAL(heaps = (heaps_used>0)?
- (RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE*)):
- (RVALUE**)malloc(heaps_length*sizeof(RVALUE*)));
- if (heaps == 0) mem_error("heaps: can't alloc memory");
+ length = heaps_length*sizeof(struct heaps_slot);
+ RUBY_CRITICAL(
+ if (heaps_used > 0) {
+ p = (struct heaps_slot *)realloc(heaps, length);
+ if (p) heaps = p;
+ }
+ else {
+ p = heaps = (struct heaps_slot *)malloc(length);
+ });
+ if (p == 0) rb_memerror();
}
- RUBY_CRITICAL(p = heaps[heaps_used++] = (RVALUE*)malloc(sizeof(RVALUE)*HEAP_SLOTS));
- if (p == 0) mem_error("add_heap: can't alloc memory");
- pend = p + HEAP_SLOTS;
+ for (;;) {
+ RUBY_CRITICAL(p = heaps[heaps_used].slot = (RVALUE*)malloc(sizeof(RVALUE)*heap_slots));
+ heaps[heaps_used].limit = heap_slots;
+ if (p == 0) {
+ if (heap_slots == HEAP_MIN_SLOTS) {
+ rb_memerror();
+ }
+ heap_slots = HEAP_MIN_SLOTS;
+ continue;
+ }
+ break;
+ }
+ pend = p + heap_slots;
if (lomem == 0 || lomem > p) lomem = p;
if (himem < pend) himem = pend;
+ heaps_used++;
+ heap_slots *= 1.8;
while (p < pend) {
- p->as.free.flag = 0;
+ p->as.free.flags = 0;
p->as.free.next = freelist;
freelist = p;
p++;
@@ -301,11 +378,15 @@ rb_newobj()
{
VALUE obj;
- if (!freelist) rb_gc();
+ if (!freelist) garbage_collect();
obj = (VALUE)freelist;
freelist = freelist->as.free.next;
MEMZERO((void*)obj, RVALUE, 1);
+#ifdef GC_DEBUG
+ RANY(obj)->file = ruby_sourcefile;
+ RANY(obj)->line = ruby_sourceline;
+#endif
return obj;
}
@@ -317,6 +398,7 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
RUBY_DATA_FUNC dfree;
{
NEWOBJ(data, struct RData);
+ Check_Type(klass, T_CLASS);
OBJSETUP(data, klass, T_DATA);
data->data = datap;
data->dfree = dfree;
@@ -328,6 +410,182 @@ rb_data_object_alloc(klass, datap, dmark, dfree)
extern st_table *rb_class_tbl;
VALUE *rb_gc_stack_start = 0;
+#ifdef DJGPP
+/* set stack size (http://www.delorie.com/djgpp/v2faq/faq15_9.html) */
+unsigned int _stklen = 0x180000; /* 1.5 kB */
+#endif
+
+#if defined(DJGPP) || defined(_WIN32_WCE)
+static unsigned int STACK_LEVEL_MAX = 65535;
+#elif defined(__human68k__)
+unsigned int _stacksize = 262144;
+# define STACK_LEVEL_MAX (_stacksize - 4096)
+# undef HAVE_GETRLIMIT
+#elif defined(HAVE_GETRLIMIT)
+static unsigned int STACK_LEVEL_MAX = 655300;
+#else
+# define STACK_LEVEL_MAX 655300
+#endif
+
+#ifdef C_ALLOCA
+# define SET_STACK_END VALUE stack_end; alloca(0);
+# define STACK_END (&stack_end)
+#else
+# if defined(__GNUC__) && defined(USE_BUILTIN_FRAME_ADDRESS) && !defined(__ia64__)
+# define SET_STACK_END VALUE *stack_end = __builtin_frame_address(0)
+# else
+# define SET_STACK_END VALUE *stack_end = alloca(1)
+# endif
+# define STACK_END (stack_end)
+#endif
+#if defined(sparc) || defined(__sparc__)
+# define STACK_LENGTH (rb_gc_stack_start - STACK_END + 0x80)
+#elif STACK_GROW_DIRECTION < 0
+# define STACK_LENGTH (rb_gc_stack_start - STACK_END)
+#elif STACK_GROW_DIRECTION > 0
+# define STACK_LENGTH (STACK_END - rb_gc_stack_start + 1)
+#else
+# define STACK_LENGTH ((STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END\
+ : STACK_END - rb_gc_stack_start + 1)
+#endif
+#if STACK_GROW_DIRECTION > 0
+# define STACK_UPPER(x, a, b) a
+#elif STACK_GROW_DIRECTION < 0
+# define STACK_UPPER(x, a, b) b
+#else
+static int grow_direction;
+static int
+stack_grow_direction(addr)
+ VALUE *addr;
+{
+ SET_STACK_END;
+
+ if (STACK_END > addr) return grow_direction = 1;
+ return grow_direction = -1;
+}
+# define stack_growup_p(x) ((grow_direction ? grow_direction : stack_grow_direction(x)) > 0)
+# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
+#endif
+
+#define GC_WATER_MARK 512
+
+#define CHECK_STACK(ret) do {\
+ SET_STACK_END;\
+ (ret) = (STACK_LENGTH > STACK_LEVEL_MAX + GC_WATER_MARK);\
+} while (0)
+
+int
+ruby_stack_length(p)
+ VALUE **p;
+{
+ SET_STACK_END;
+ if (p) *p = STACK_UPPER(STACK_END, rb_gc_stack_start, STACK_END);
+ return STACK_LENGTH;
+}
+
+int
+ruby_stack_check()
+{
+ int ret;
+
+ CHECK_STACK(ret);
+ return ret;
+}
+
+#define MARK_STACK_MAX 1024
+static VALUE mark_stack[MARK_STACK_MAX];
+static VALUE *mark_stack_ptr;
+static int mark_stack_overflow;
+
+static void
+init_mark_stack()
+{
+ mark_stack_overflow = 0;
+ mark_stack_ptr = mark_stack;
+}
+
+#define MARK_STACK_EMPTY (mark_stack_ptr == mark_stack)
+
+static st_table *source_filenames;
+
+char *
+rb_source_filename(f)
+ const char *f;
+{
+ char *name;
+
+ if (!st_lookup(source_filenames, (st_data_t)f, (st_data_t *)&name)) {
+ long len = strlen(f) + 1;
+ char *ptr = name = ALLOC_N(char, len + 1);
+ *ptr++ = 0;
+ MEMCPY(ptr, f, char, len);
+ st_add_direct(source_filenames, (st_data_t)ptr, (st_data_t)name);
+ return ptr;
+ }
+ return name + 1;
+}
+
+static void
+mark_source_filename(f)
+ char *f;
+{
+ if (f) {
+ f[-1] = 1;
+ }
+}
+
+static int
+sweep_source_filename(key, value)
+ char *key, *value;
+{
+ if (*value) {
+ *value = 0;
+ return ST_CONTINUE;
+ }
+ else {
+ free(value);
+ return ST_DELETE;
+ }
+}
+
+static void gc_mark _((VALUE ptr, int lev));
+static void gc_mark_children _((VALUE ptr, int lev));
+
+static void
+gc_mark_all()
+{
+ RVALUE *p, *pend;
+ int i;
+
+ init_mark_stack();
+ for (i = 0; i < heaps_used; i++) {
+ p = heaps[i].slot; pend = p + heaps[i].limit;
+ while (p < pend) {
+ if ((p->as.basic.flags & FL_MARK) &&
+ (p->as.basic.flags != FL_MARK)) {
+ gc_mark_children((VALUE)p, 0);
+ }
+ p++;
+ }
+ }
+}
+
+static void
+gc_mark_rest()
+{
+ VALUE tmp_arry[MARK_STACK_MAX];
+ VALUE *p;
+
+ p = (mark_stack_ptr - mark_stack) + tmp_arry;
+ MEMCPY(tmp_arry, mark_stack, VALUE, MARK_STACK_MAX);
+
+ init_mark_stack();
+ while(p != tmp_arry){
+ p--;
+ gc_mark_children(*p, 0);
+ }
+}
+
static inline int
is_pointer_to_heap(ptr)
void *ptr;
@@ -340,9 +598,9 @@ is_pointer_to_heap(ptr)
/* check if p looks like a pointer */
for (i=0; i < heaps_used; i++) {
- heap_org = heaps[i];
- if (heap_org <= p && p < heap_org + HEAP_SLOTS
- && ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0)
+ heap_org = heaps[i].slot;
+ if (heap_org <= p && p < heap_org + heaps[i].limit &&
+ ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0)
return Qtrue;
}
return Qfalse;
@@ -354,8 +612,8 @@ mark_locations_array(x, n)
register long n;
{
while (n--) {
- if (is_pointer_to_heap(*x)) {
- rb_gc_mark(*x);
+ if (is_pointer_to_heap((void *)*x)) {
+ gc_mark(*x, 0);
}
x++;
}
@@ -365,77 +623,130 @@ void
rb_gc_mark_locations(start, end)
VALUE *start, *end;
{
- VALUE *tmp;
long n;
- if (start > end) {
- tmp = start;
- start = end;
- end = tmp;
- }
- n = end - start + 1;
+ n = end - start;
mark_locations_array(start,n);
}
static int
-mark_entry(key, value)
+mark_entry(key, value, lev)
ID key;
VALUE value;
+ int lev;
{
- rb_gc_mark(value);
+ gc_mark(value, lev);
return ST_CONTINUE;
}
void
-rb_mark_tbl(tbl)
+mark_tbl(tbl, lev)
st_table *tbl;
+ int lev;
{
if (!tbl) return;
- st_foreach(tbl, mark_entry, 0);
+ st_foreach(tbl, mark_entry, lev);
+}
+
+void
+rb_mark_tbl(tbl)
+ st_table *tbl;
+{
+ mark_tbl(tbl, 0);
}
static int
-mark_hashentry(key, value)
+mark_keyvalue(key, value, lev)
VALUE key;
VALUE value;
+ int lev;
{
- rb_gc_mark(key);
- rb_gc_mark(value);
+ gc_mark(key, lev);
+ gc_mark(value, lev);
return ST_CONTINUE;
}
void
-rb_mark_hash(tbl)
+mark_hash(tbl, lev)
st_table *tbl;
+ int lev;
{
if (!tbl) return;
- st_foreach(tbl, mark_hashentry, 0);
+ st_foreach(tbl, mark_keyvalue, lev);
+}
+
+void
+rb_mark_hash(tbl)
+ st_table *tbl;
+{
+ mark_hash(tbl, 0);
}
void
rb_gc_mark_maybe(obj)
- void *obj;
+ VALUE obj;
{
- if (is_pointer_to_heap(obj)) {
- rb_gc_mark(obj);
+ if (is_pointer_to_heap((void *)obj)) {
+ gc_mark(obj, 0);
}
}
+#define GC_LEVEL_MAX 250
+
+void
+gc_mark(ptr, lev)
+ VALUE ptr;
+ int lev;
+{
+ register RVALUE *obj;
+
+ obj = RANY(ptr);
+ if (rb_special_const_p(ptr)) return; /* special const not 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;
+
+ if (lev > GC_LEVEL_MAX || (lev == 0 && ruby_stack_check())) {
+ if (!mark_stack_overflow) {
+ if (mark_stack_ptr - mark_stack < MARK_STACK_MAX) {
+ *mark_stack_ptr = ptr;
+ mark_stack_ptr++;
+ }
+ else {
+ mark_stack_overflow = 1;
+ }
+ }
+ return;
+ }
+ gc_mark_children(ptr, lev+1);
+}
+
void
rb_gc_mark(ptr)
- void *ptr;
+ VALUE ptr;
+{
+ gc_mark(ptr, 0);
+}
+
+static void
+gc_mark_children(ptr, lev)
+ VALUE ptr;
+ int lev;
{
register RVALUE *obj = RANY(ptr);
- Top:
- 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 */
+ goto marking; /* skip */
+ again:
+ obj = RANY(ptr);
+ if (rb_special_const_p(ptr)) return; /* special const not 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;
+ marking:
if (FL_TEST(obj, FL_EXIVAR)) {
- rb_mark_generic_ivar((VALUE)obj);
+ rb_mark_generic_ivar(ptr);
}
switch (obj->as.basic.flags & T_MASK) {
@@ -445,6 +756,7 @@ rb_gc_mark(ptr)
break;
case T_NODE:
+ mark_source_filename(obj->as.node.nd_file);
switch (nd_type(obj)) {
case NODE_IF: /* 1,2,3 */
case NODE_FOR:
@@ -454,13 +766,13 @@ rb_gc_mark(ptr)
case NODE_MASGN:
case NODE_RESCUE:
case NODE_RESBODY:
- rb_gc_mark(obj->as.node.u2.node);
+ case NODE_CLASS:
+ gc_mark((VALUE)obj->as.node.u2.node, lev);
/* fall through */
case NODE_BLOCK: /* 1,3 */
case NODE_ARRAY:
case NODE_DSTR:
case NODE_DXSTR:
- case NODE_EVSTR:
case NODE_DREGX:
case NODE_DREGX_ONCE:
case NODE_FBODY:
@@ -468,14 +780,14 @@ rb_gc_mark(ptr)
case NODE_CALL:
case NODE_DEFS:
case NODE_OP_ASGN1:
- rb_gc_mark(obj->as.node.u1.node);
+ gc_mark((VALUE)obj->as.node.u1.node, lev);
/* fall through */
case NODE_SUPER: /* 3 */
case NODE_FCALL:
case NODE_DEFN:
case NODE_NEWLINE:
- obj = RANY(obj->as.node.u3.node);
- goto Top;
+ ptr = (VALUE)obj->as.node.u3.node;
+ goto again;
case NODE_WHILE: /* 1,2 */
case NODE_UNTIL:
@@ -491,7 +803,8 @@ rb_gc_mark(ptr)
case NODE_MATCH3:
case NODE_OP_ASGN_OR:
case NODE_OP_ASGN_AND:
- rb_gc_mark(obj->as.node.u1.node);
+ case NODE_MODULE:
+ gc_mark((VALUE)obj->as.node.u1.node, lev);
/* fall through */
case NODE_METHOD: /* 2 */
case NODE_NOT:
@@ -500,14 +813,13 @@ rb_gc_mark(ptr)
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_IASGN:
- case NODE_CDECL:
case NODE_CVDECL:
case NODE_CVASGN:
- case NODE_MODULE:
case NODE_COLON3:
case NODE_OPT_N:
- obj = RANY(obj->as.node.u2.node);
- goto Top;
+ case NODE_EVSTR:
+ ptr = (VALUE)obj->as.node.u2.node;
+ goto again;
case NODE_HASH: /* 1 */
case NODE_LIT:
@@ -516,18 +828,23 @@ rb_gc_mark(ptr)
case NODE_DEFINED:
case NODE_MATCH:
case NODE_RETURN:
+ case NODE_BREAK:
+ case NODE_NEXT:
case NODE_YIELD:
case NODE_COLON2:
case NODE_ARGS:
- obj = RANY(obj->as.node.u1.node);
- goto Top;
+ case NODE_SPLAT:
+ case NODE_TO_ARY:
+ case NODE_SVALUE:
+ ptr = (VALUE)obj->as.node.u1.node;
+ goto again;
case NODE_SCOPE: /* 2,3 */
- case NODE_CLASS:
case NODE_BLOCK_PASS:
- rb_gc_mark(obj->as.node.u3.node);
- obj = RANY(obj->as.node.u2.node);
- goto Top;
+ case NODE_CDECL:
+ gc_mark((VALUE)obj->as.node.u3.node, lev);
+ ptr = (VALUE)obj->as.node.u2.node;
+ goto again;
case NODE_ZARRAY: /* - */
case NODE_ZSUPER:
@@ -538,13 +855,10 @@ rb_gc_mark(ptr)
case NODE_DVAR:
case NODE_IVAR:
case NODE_CVAR:
- case NODE_CVAR2:
case NODE_NTH_REF:
case NODE_BACK_REF:
case NODE_ALIAS:
case NODE_VALIAS:
- case NODE_BREAK:
- case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
case NODE_UNDEF:
@@ -560,54 +874,59 @@ rb_gc_mark(ptr)
case NODE_ALLOCA:
mark_locations_array((VALUE*)obj->as.node.u1.value,
obj->as.node.u3.cnt);
- obj = RANY(obj->as.node.u2.node);
- goto Top;
+ ptr = (VALUE)obj->as.node.u2.node;
+ goto again;
#endif
- default:
+ default: /* unlisted NODE */
if (is_pointer_to_heap(obj->as.node.u1.node)) {
- rb_gc_mark(obj->as.node.u1.node);
+ gc_mark((VALUE)obj->as.node.u1.node, lev);
}
if (is_pointer_to_heap(obj->as.node.u2.node)) {
- rb_gc_mark(obj->as.node.u2.node);
+ gc_mark((VALUE)obj->as.node.u2.node, lev);
}
if (is_pointer_to_heap(obj->as.node.u3.node)) {
- obj = RANY(obj->as.node.u3.node);
- goto Top;
+ gc_mark((VALUE)obj->as.node.u3.node, lev);
}
}
return; /* no need to mark class. */
}
- rb_gc_mark(obj->as.basic.klass);
+ gc_mark(obj->as.basic.klass, lev);
switch (obj->as.basic.flags & T_MASK) {
case T_ICLASS:
case T_CLASS:
case T_MODULE:
- rb_gc_mark(obj->as.klass.super);
- rb_mark_tbl(obj->as.klass.m_tbl);
- rb_mark_tbl(obj->as.klass.iv_tbl);
- break;
+ mark_tbl(obj->as.klass.m_tbl, lev);
+ mark_tbl(obj->as.klass.iv_tbl, lev);
+ ptr = obj->as.klass.super;
+ goto again;
case T_ARRAY:
- {
- int i, len = obj->as.array.len;
+ if (FL_TEST(obj, ELTS_SHARED)) {
+ ptr = obj->as.array.aux.shared;
+ goto again;
+ }
+ else {
+ long i, len = obj->as.array.len;
VALUE *ptr = obj->as.array.ptr;
- for (i=0; i < len; i++)
- rb_gc_mark(*ptr++);
+ for (i=0; i < len; i++) {
+ gc_mark(*ptr++, lev);
+ }
}
break;
case T_HASH:
- rb_mark_hash(obj->as.hash.tbl);
- rb_gc_mark(obj->as.hash.ifnone);
- break;
+ mark_hash(obj->as.hash.tbl, lev);
+ ptr = obj->as.hash.ifnone;
+ goto again;
case T_STRING:
- if (obj->as.string.orig) {
- obj = RANY(obj->as.string.orig);
- goto Top;
+#define STR_ASSOC FL_USER3 /* copied from string.c */
+ if (FL_TEST(obj, ELTS_SHARED|STR_ASSOC)) {
+ ptr = obj->as.string.aux.shared;
+ goto again;
}
break;
@@ -616,7 +935,7 @@ rb_gc_mark(ptr)
break;
case T_OBJECT:
- rb_mark_tbl(obj->as.object.iv_tbl);
+ mark_tbl(obj->as.object.iv_tbl, lev);
break;
case T_FILE:
@@ -628,86 +947,127 @@ rb_gc_mark(ptr)
case T_MATCH:
if (obj->as.match.str) {
- obj = RANY(obj->as.match.str);
- goto Top;
+ ptr = obj->as.match.str;
+ goto again;
}
break;
case T_VARMAP:
- rb_gc_mark(obj->as.varmap.val);
- obj = RANY(obj->as.varmap.next);
- goto Top;
- break;
+ gc_mark(obj->as.varmap.val, lev);
+ ptr = (VALUE)obj->as.varmap.next;
+ goto again;
case T_SCOPE:
- if (obj->as.scope.local_vars && (obj->as.scope.flag & SCOPE_MALLOC)) {
+ if (obj->as.scope.local_vars && (obj->as.scope.flags & SCOPE_MALLOC)) {
int n = obj->as.scope.local_tbl[0]+1;
VALUE *vars = &obj->as.scope.local_vars[-1];
while (n--) {
- rb_gc_mark(*vars);
- vars++;
+ gc_mark(*vars++, lev);
}
}
break;
case T_STRUCT:
{
- int i, len = obj->as.rstruct.len;
+ long len = obj->as.rstruct.len;
VALUE *ptr = obj->as.rstruct.ptr;
- for (i=0; i < len; i++)
- rb_gc_mark(*ptr++);
+ while (len--) {
+ gc_mark(*ptr++, lev);
+ }
}
break;
default:
- rb_bug("rb_gc_mark(): unknown data type 0x%x(0x%x) %s",
+ rb_bug("rb_gc_mark(): unknown data type 0x%lx(0x%lx) %s",
obj->as.basic.flags & T_MASK, obj,
- is_pointer_to_heap(obj)?"corrupted object":"non object");
+ is_pointer_to_heap(obj) ? "corrupted object" : "non object");
}
}
static void obj_free _((VALUE));
static void
+finalize_list(p)
+ RVALUE *p;
+{
+ while (p) {
+ RVALUE *tmp = p->as.free.next;
+ run_final((VALUE)p);
+ if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
+ p->as.free.flags = 0;
+ p->as.free.next = freelist;
+ freelist = p;
+ }
+ p = tmp;
+ }
+}
+
+static void
+free_unused_heaps()
+{
+ int i, j;
+
+ for (i = j = 1; j < heaps_used; i++) {
+ if (heaps[i].limit == 0) {
+ free(heaps[i].slot);
+ heaps_used--;
+ }
+ else {
+ if (i != j) {
+ heaps[j] = heaps[i];
+ }
+ j++;
+ }
+ }
+}
+
+static void
gc_sweep()
{
RVALUE *p, *pend, *final_list;
int freed = 0;
- int i, used = heaps_used;
+ int i;
+ unsigned long live = 0;
- if (ruby_in_compile) {
- /* should not reclaim nodes during compilation */
- for (i = 0; i < used; i++) {
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ if (ruby_in_compile && ruby_parser_stack_on_heap()) {
+ /* should not reclaim nodes during compilation
+ if yacc's semantic stack is not allocated on machine stack */
+ for (i = 0; i < heaps_used; i++) {
+ p = heaps[i].slot; pend = p + heaps[i].limit;
while (p < pend) {
if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE)
- rb_gc_mark(p);
+ gc_mark((VALUE)p, 0);
p++;
}
}
}
+ mark_source_filename(ruby_sourcefile);
+ st_foreach(source_filenames, sweep_source_filename, 0);
+
freelist = 0;
final_list = deferred_final_list;
deferred_final_list = 0;
- for (i = 0; i < used; i++) {
+ for (i = 0; i < heaps_used; i++) {
int n = 0;
+ RVALUE *free = freelist;
+ RVALUE *final = final_list;
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i].slot; pend = p + heaps[i].limit;
while (p < pend) {
if (!(p->as.basic.flags & FL_MARK)) {
if (p->as.basic.flags) {
obj_free((VALUE)p);
}
if (need_call_final && FL_TEST(p, FL_FINALIZE)) {
- p->as.free.flag = FL_MARK; /* remain marked */
+ p->as.free.flags = FL_MARK; /* remain marked */
p->as.free.next = final_list;
final_list = p;
}
else {
- p->as.free.flag = 0;
+ p->as.free.flags = 0;
p->as.free.next = freelist;
freelist = p;
}
@@ -719,11 +1079,28 @@ gc_sweep()
}
else {
RBASIC(p)->flags &= ~FL_MARK;
+ live++;
}
p++;
}
- freed += n;
+ if (n == heaps[i].limit && freed > FREE_MIN) {
+ RVALUE *pp;
+
+ heaps[i].limit = 0;
+ for (pp = final_list; pp != final; pp = pp->as.free.next) {
+ p->as.free.flags |= FL_SINGLETON; /* freeing page mark */
+ }
+ freelist = free; /* cancel this page from freelist */
+ }
+ else {
+ freed += n;
+ }
}
+ if (malloc_increase > malloc_limit) {
+ malloc_limit += (malloc_increase - malloc_limit) * (double)live / (live + freed);
+ if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT;
+ }
+ malloc_increase = 0;
if (freed < FREE_MIN) {
add_heap();
}
@@ -731,28 +1108,17 @@ gc_sweep()
/* clear finalization list */
if (final_list) {
- RVALUE *tmp;
-
- if (rb_prohibit_interrupt || ruby_in_compile) {
- deferred_final_list = final_list;
- return;
- }
-
- for (p = final_list; p; p = tmp) {
- tmp = p->as.free.next;
- run_final((VALUE)p);
- p->as.free.flag = 0;
- p->as.free.next = freelist;
- freelist = p;
- }
+ deferred_final_list = final_list;
+ return;
}
+ free_unused_heaps();
}
void
rb_gc_force_recycle(p)
VALUE p;
{
- RANY(p)->as.free.flag = 0;
+ RANY(p)->as.free.flags = 0;
RANY(p)->as.free.next = freelist;
freelist = RANY(p);
}
@@ -782,20 +1148,19 @@ obj_free(obj)
break;
case T_MODULE:
case T_CLASS:
- rb_clear_cache();
+ rb_clear_cache_by_class((VALUE)obj);
st_free_table(RANY(obj)->as.klass.m_tbl);
if (RANY(obj)->as.object.iv_tbl) {
st_free_table(RANY(obj)->as.object.iv_tbl);
}
break;
case T_STRING:
-#define STR_NO_ORIG FL_USER2 /* copied from string.c */
- if (!RANY(obj)->as.string.orig || FL_TEST(obj, STR_NO_ORIG)) {
+ if (RANY(obj)->as.string.ptr && !FL_TEST(obj, ELTS_SHARED)) {
RUBY_CRITICAL(free(RANY(obj)->as.string.ptr));
}
break;
case T_ARRAY:
- if (RANY(obj)->as.array.ptr) {
+ if (RANY(obj)->as.array.ptr && !FL_TEST(obj, ELTS_SHARED)) {
RUBY_CRITICAL(free(RANY(obj)->as.array.ptr));
}
break;
@@ -857,7 +1222,7 @@ obj_free(obj)
break;
#ifdef C_ALLOCA
case NODE_ALLOCA:
- RUBY_CRITICAL(free(RANY(obj)->as.node.u1.value));
+ RUBY_CRITICAL(free(RANY(obj)->as.node.u1.node));
break;
#endif
}
@@ -865,11 +1230,11 @@ obj_free(obj)
case T_SCOPE:
if (RANY(obj)->as.scope.local_vars &&
- RANY(obj)->as.scope.flag != SCOPE_ALLOCA) {
+ RANY(obj)->as.scope.flags != SCOPE_ALLOCA) {
VALUE *vars = RANY(obj)->as.scope.local_vars-1;
if (vars[0] == 0)
RUBY_CRITICAL(free(RANY(obj)->as.scope.local_tbl));
- if (RANY(obj)->as.scope.flag&SCOPE_MALLOC)
+ if (RANY(obj)->as.scope.flags & SCOPE_MALLOC)
RUBY_CRITICAL(free(vars));
}
break;
@@ -881,7 +1246,7 @@ obj_free(obj)
break;
default:
- rb_bug("gc_sweep(): unknown data type %d",
+ rb_bug("gc_sweep(): unknown data type 0x%lx(%ld)", obj,
RANY(obj)->as.basic.flags & T_MASK);
}
}
@@ -891,18 +1256,18 @@ rb_gc_mark_frame(frame)
struct FRAME *frame;
{
mark_locations_array(frame->argv, frame->argc);
- rb_gc_mark(frame->cbase);
+ gc_mark((VALUE)frame->node, 0);
}
#ifdef __GNUC__
#if defined(__human68k__) || defined(DJGPP)
#if defined(__human68k__)
typedef unsigned long rb_jmp_buf[8];
-__asm__ (".even
-_rb_setjmp:
- move.l 4(sp),a0
- movem.l d3-d7/a3-a5,(a0)
- moveq.l #0,d0
+__asm__ (".even\n\
+_rb_setjmp:\n\
+ move.l 4(sp),a0\n\
+ movem.l d3-d7/a3-a5,(a0)\n\
+ moveq.l #0,d0\n\
rts");
#ifdef setjmp
#undef setjmp
@@ -910,19 +1275,19 @@ _rb_setjmp:
#else
#if defined(DJGPP)
typedef unsigned long rb_jmp_buf[6];
-__asm__ (".align 4
-_rb_setjmp:
- pushl %ebp
- movl %esp,%ebp
- movl 8(%ebp),%ebp
- movl %eax,(%ebp)
- movl %ebx,4(%ebp)
- movl %ecx,8(%ebp)
- movl %edx,12(%ebp)
- movl %esi,16(%ebp)
- movl %edi,20(%ebp)
- popl %ebp
- xorl %eax,%eax
+__asm__ (".align 4\n\
+_rb_setjmp:\n\
+ pushl %ebp\n\
+ movl %esp,%ebp\n\
+ movl 8(%ebp),%ebp\n\
+ movl %eax,(%ebp)\n\
+ movl %ebx,4(%ebp)\n\
+ movl %ecx,8(%ebp)\n\
+ movl %edx,12(%ebp)\n\
+ movl %esi,16(%ebp)\n\
+ movl %edi,20(%ebp)\n\
+ popl %ebp\n\
+ xorl %eax,%eax\n\
ret");
#endif
#endif
@@ -932,38 +1297,30 @@ int rb_setjmp (rb_jmp_buf);
#endif /* __human68k__ or DJGPP */
#endif /* __GNUC__ */
-void
-rb_gc()
+static void
+garbage_collect()
{
struct gc_list *list;
struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug?? */
jmp_buf save_regs_gc_mark;
-#ifdef C_ALLOCA
- VALUE stack_end;
- alloca(0);
-# define STACK_END (&stack_end)
-#else
-# if defined(__GNUC__) && defined(__i386__)
- VALUE *stack_end = __builtin_frame_address(0);
-# else
- VALUE *stack_end = alloca(1);
-# endif
-# define STACK_END (stack_end)
-#endif
+ SET_STACK_END;
+#ifdef HAVE_NATIVETHREAD
+ if (!is_ruby_native_thread()) {
+ rb_bug("cross-thread violation on rb_gc()");
+ }
+#endif
if (dont_gc || during_gc) {
- if (!freelist || malloc_memories > GC_MALLOC_LIMIT) {
- malloc_memories = 0;
+ if (!freelist) {
add_heap();
}
return;
}
-
- malloc_memories = 0;
-
if (during_gc) return;
during_gc++;
+ init_mark_stack();
+
/* mark frame stack */
for (frame = ruby_frame; frame; frame = frame->prev) {
rb_gc_mark_frame(frame);
@@ -975,27 +1332,53 @@ rb_gc()
}
}
}
- rb_gc_mark(ruby_class);
- rb_gc_mark(ruby_scope);
- rb_gc_mark(ruby_dyna_vars);
+ gc_mark((VALUE)ruby_scope, 0);
+ gc_mark((VALUE)ruby_dyna_vars, 0);
if (finalizer_table) {
- rb_mark_tbl(finalizer_table);
+ mark_tbl(finalizer_table, 0);
}
FLUSH_REGISTER_WINDOWS;
- /* This assumes that all registers are saved into the jmp_buf */
+ /* This assumes that all registers are saved into the jmp_buf (and stack) */
setjmp(save_regs_gc_mark);
mark_locations_array((VALUE*)save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE *));
- rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END);
-#if defined(__human68k__)
- rb_gc_mark_locations((VALUE*)((char*)rb_gc_stack_start + 2),
- (VALUE*)((char*)STACK_END + 2));
+#if STACK_GROW_DIRECTION < 0
+ rb_gc_mark_locations((VALUE*)STACK_END, rb_gc_stack_start);
+#elif STACK_GROW_DIRECTION > 0
+ rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END + 1);
+#else
+ if ((VALUE*)STACK_END < rb_gc_stack_start)
+ rb_gc_mark_locations((VALUE*)STACK_END, rb_gc_stack_start);
+ else
+ rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END + 1);
+#endif
+#ifdef __ia64__
+ /* mark backing store (flushed register window on the stack) */
+ /* the basic idea from guile GC code */
+ {
+ ucontext_t ctx;
+ VALUE *top, *bot;
+ getcontext(&ctx);
+ mark_locations_array((VALUE*)&ctx.uc_mcontext,
+ ((size_t)(sizeof(VALUE)-1 + sizeof ctx.uc_mcontext)/sizeof(VALUE)));
+ bot = (VALUE*)__libc_ia64_register_backing_store_base;
+#if defined(__FreeBSD__)
+ top = (VALUE*)ctx.uc_mcontext.mc_special.bspstore;
+#else
+ top = (VALUE*)ctx.uc_mcontext.sc_ar_bsp;
+#endif
+ rb_gc_mark_locations(bot, top);
+ }
+#endif
+#if defined(__human68k__) || defined(__mc68000__)
+ rb_gc_mark_locations((VALUE*)((char*)STACK_END + 2),
+ (VALUE*)((char*)rb_gc_stack_start + 2));
#endif
rb_gc_mark_threads();
/* mark protected global variables */
- for (list = Global_List; list; list = list->next) {
- rb_gc_mark(*list->varptr);
+ for (list = global_List; list; list = list->next) {
+ rb_gc_mark_maybe(*list->varptr);
}
rb_mark_end_proc();
rb_gc_mark_global_tbl();
@@ -1006,33 +1389,133 @@ rb_gc()
/* mark generic instance variables for special constants */
rb_mark_generic_ivar_tbl();
+ rb_gc_mark_parser();
+
+ /* gc_mark objects whose marking are not completed*/
+ while (!MARK_STACK_EMPTY){
+ if (mark_stack_overflow){
+ gc_mark_all();
+ }
+ else {
+ gc_mark_rest();
+ }
+ }
gc_sweep();
}
-static VALUE
-gc_start()
+void
+rb_gc()
+{
+ garbage_collect();
+ rb_gc_finalize_deferred();
+}
+
+/*
+ * call-seq:
+ * GC.start => nil
+ * gc.garbage_collect => nil
+ * ObjectSpace.garbage_collect => nil
+ *
+ * Initiates garbage collection, unless manually disabled.
+ *
+ */
+
+VALUE
+rb_gc_start()
{
rb_gc();
return Qnil;
}
void
+ruby_set_stack_size(size)
+ size_t size;
+{
+#ifndef STACK_LEVEL_MAX
+ STACK_LEVEL_MAX = size / sizeof(VALUE);
+#endif
+}
+
+void
Init_stack(addr)
VALUE *addr;
{
-#if defined(__human68k__)
- extern void *_SEND;
- rb_gc_stack_start = _SEND;
-#elif defined(__GNUC__) && defined(__i386__)
- rb_gc_stack_start = __builtin_frame_address(2);
+#if defined(_WIN32) || defined(__CYGWIN__)
+ MEMORY_BASIC_INFORMATION m;
+ memset(&m, 0, sizeof(m));
+ VirtualQuery(&m, &m, sizeof(m));
+ rb_gc_stack_start =
+ STACK_UPPER((VALUE *)&m, (VALUE *)m.BaseAddress,
+ (VALUE *)((char *)m.BaseAddress + m.RegionSize) - 1);
+#elif defined(STACK_END_ADDRESS)
+ extern void *STACK_END_ADDRESS;
+ rb_gc_stack_start = STACK_END_ADDRESS;
#else
- VALUE start;
-
- if (!addr) addr = &start;
+ if (!addr) addr = (VALUE *)&addr;
+ STACK_UPPER(&addr, addr, ++addr);
+ if (rb_gc_stack_start) {
+ if (STACK_UPPER(&addr,
+ rb_gc_stack_start > addr,
+ rb_gc_stack_start < addr))
+ rb_gc_stack_start = addr;
+ return;
+ }
rb_gc_stack_start = addr;
#endif
+#ifdef HAVE_GETRLIMIT
+ {
+ struct rlimit rlim;
+
+ if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
+ unsigned int space = rlim.rlim_cur/5;
+
+ if (space > 1024*1024) space = 1024*1024;
+ STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
+ }
+ }
+#if defined(__ia64__) && (!defined(__GNUC__) || __GNUC__ < 2 || defined(__OPTIMIZE__))
+ /* ruby crashes on IA64 if compiled with optimizer on */
+ /* when if STACK_LEVEL_MAX is greater than this magic number */
+ /* I know this is a kludge. I suspect optimizer bug */
+#define IA64_MAGIC_STACK_LIMIT 49152
+ if (STACK_LEVEL_MAX > IA64_MAGIC_STACK_LIMIT)
+ STACK_LEVEL_MAX = IA64_MAGIC_STACK_LIMIT;
+#endif
+#endif
}
+
+/*
+ * Document-class: ObjectSpace
+ *
+ * The <code>ObjectSpace</code> module contains a number of routines
+ * that interact with the garbage collection facility and allow you to
+ * traverse all living objects with an iterator.
+ *
+ * <code>ObjectSpace</code> also provides support for object
+ * finalizers, procs that will be called when a specific object is
+ * about to be destroyed by garbage collection.
+ *
+ * include ObjectSpace
+ *
+ *
+ * a = "A"
+ * b = "B"
+ * c = "C"
+ *
+ *
+ * define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" })
+ * define_finalizer(a, proc {|id| puts "Finalizer two on #{id}" })
+ * define_finalizer(b, proc {|id| puts "Finalizer three on #{id}" })
+ *
+ * <em>produces:</em>
+ *
+ * Finalizer three on 537763470
+ * Finalizer one on 537763480
+ * Finalizer two on 537763480
+ *
+ */
+
void
Init_heap()
{
@@ -1051,7 +1534,7 @@ os_live_obj()
for (i = 0; i < heaps_used; i++) {
RVALUE *p, *pend;
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i].slot; pend = p + heaps[i].limit;
for (;p < pend; p++) {
if (p->as.basic.flags) {
switch (TYPE(p)) {
@@ -1084,7 +1567,7 @@ os_obj_of(of)
for (i = 0; i < heaps_used; i++) {
RVALUE *p, *pend;
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i].slot; pend = p + heaps[i].limit;
for (;p < pend; p++) {
if (p->as.basic.flags) {
switch (TYPE(p)) {
@@ -1109,6 +1592,39 @@ os_obj_of(of)
return INT2FIX(n);
}
+/*
+ * call-seq:
+ * ObjectSpace.each_object([module]) {|obj| ... } => fixnum
+ *
+ * Calls the block once for each living, nonimmediate object in this
+ * Ruby process. If <i>module</i> is specified, calls the block
+ * for only those classes or modules that match (or are a subclass of)
+ * <i>module</i>. Returns the number of objects found. Immediate
+ * objects (<code>Fixnum</code>s, <code>Symbol</code>s
+ * <code>true</code>, <code>false</code>, and <code>nil</code>) are
+ * never returned. In the example below, <code>each_object</code>
+ * returns both the numbers we defined and several constants defined in
+ * the <code>Math</code> module.
+ *
+ * a = 102.7
+ * b = 95 # Won't be returned
+ * c = 12345678987654321
+ * count = ObjectSpace.each_object(Numeric) {|x| p x }
+ * puts "Total count: #{count}"
+ *
+ * <em>produces:</em>
+ *
+ * 12345678987654321
+ * 102.7
+ * 2.71828182845905
+ * 3.14159265358979
+ * 2.22044604925031e-16
+ * 1.7976931348623157e+308
+ * 2.2250738585072e-308
+ * Total count: 7
+ *
+ */
+
static VALUE
os_each_obj(argc, argv)
int argc;
@@ -1116,6 +1632,7 @@ os_each_obj(argc, argv)
{
VALUE of;
+ rb_secure(4);
if (rb_scan_args(argc, argv, "01", &of) == 0) {
return os_live_obj();
}
@@ -1126,93 +1643,137 @@ os_each_obj(argc, argv)
static VALUE finalizers;
+/* deprecated
+ */
+
static VALUE
-add_final(os, proc)
- VALUE os, proc;
+add_final(os, block)
+ VALUE os, block;
{
rb_warn("ObjectSpace::add_finalizer is deprecated; use define_finalizer");
- if (!rb_obj_is_kind_of(proc, rb_cProc)) {
- rb_raise(rb_eArgError, "wrong type argument %s (Proc required)",
- rb_class2name(CLASS_OF(proc)));
+ if (!rb_respond_to(block, rb_intern("call"))) {
+ rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
+ rb_obj_classname(block));
}
- rb_ary_push(finalizers, proc);
- return proc;
+ rb_ary_push(finalizers, block);
+ return block;
}
+/*
+ * deprecated
+ */
static VALUE
-rm_final(os, proc)
- VALUE os, proc;
+rm_final(os, block)
+ VALUE os, block;
{
rb_warn("ObjectSpace::remove_finalizer is deprecated; use undefine_finalizer");
- rb_ary_delete(finalizers, proc);
- return proc;
+ rb_ary_delete(finalizers, block);
+ return block;
}
+/*
+ * deprecated
+ */
static VALUE
finals()
{
- rb_warn("ObjectSpace::finals is deprecated");
+ rb_warn("ObjectSpace::finalizers is deprecated");
return finalizers;
}
+/*
+ * deprecated
+ */
+
static VALUE
call_final(os, obj)
VALUE os, obj;
{
- rb_warn("ObjectSpace::call_final is deprecated; use define_finalizer");
+ rb_warn("ObjectSpace::call_finalizer is deprecated; use define_finalizer");
need_call_final = 1;
FL_SET(obj, FL_FINALIZE);
return obj;
}
+/*
+ * call-seq:
+ * ObjectSpace.undefine_finalizer(obj)
+ *
+ * Removes all finalizers for <i>obj</i>.
+ *
+ */
+
static VALUE
undefine_final(os, obj)
VALUE os, obj;
{
- VALUE table;
-
if (finalizer_table) {
- st_delete(finalizer_table, &obj, 0);
+ st_delete(finalizer_table, (st_data_t*)&obj, 0);
}
return obj;
}
+/*
+ * call-seq:
+ * ObjectSpace.define_finalizer(obj, aProc=proc())
+ *
+ * Adds <i>aProc</i> as a finalizer, to be called when <i>obj</i>
+ * is about to be destroyed.
+ *
+ */
+
static VALUE
define_final(argc, argv, os)
int argc;
VALUE *argv;
VALUE os;
{
- VALUE obj, proc, table;
+ VALUE obj, block, table;
- rb_scan_args(argc, argv, "11", &obj, &proc);
+ rb_scan_args(argc, argv, "11", &obj, &block);
if (argc == 1) {
- proc = rb_f_lambda();
+ block = rb_block_proc();
}
- else if (!rb_obj_is_kind_of(proc, rb_cProc)) {
- rb_raise(rb_eArgError, "wrong type argument %s (Proc required)",
- rb_class2name(CLASS_OF(proc)));
+ else if (!rb_respond_to(block, rb_intern("call"))) {
+ rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
+ rb_obj_classname(block));
}
need_call_final = 1;
FL_SET(obj, FL_FINALIZE);
+ block = rb_ary_new3(2, INT2FIX(ruby_safe_level), block);
+
if (!finalizer_table) {
finalizer_table = st_init_numtable();
}
if (st_lookup(finalizer_table, obj, &table)) {
- rb_ary_push(table, proc);
+ rb_ary_push(table, block);
}
else {
- st_add_direct(finalizer_table, obj, rb_ary_new3(1, proc));
+ st_add_direct(finalizer_table, obj, rb_ary_new3(1, block));
}
- return proc;
+ return block;
+}
+
+void
+rb_gc_copy_finalizer(dest, obj)
+ VALUE dest, obj;
+{
+ VALUE table;
+
+ if (!finalizer_table) return;
+ if (!FL_TEST(obj, FL_FINALIZE)) return;
+ if (st_lookup(finalizer_table, obj, &table)) {
+ st_insert(finalizer_table, dest, table);
+ }
+ RBASIC(dest)->flags |= FL_FINALIZE;
}
static VALUE
run_single_final(args)
VALUE *args;
{
- rb_eval_cmd(args[0], args[1]);
+ rb_eval_cmd(args[0], args[1], (int)args[2]);
return Qnil;
}
@@ -1220,20 +1781,38 @@ static void
run_final(obj)
VALUE obj;
{
- int i, status;
- VALUE args[2], table;
+ long i;
+ int status, critical_save = rb_thread_critical;
+ VALUE args[3], table;
+ rb_thread_critical = Qtrue;
args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */
+ args[2] = (VALUE)ruby_safe_level;
for (i=0; i<RARRAY(finalizers)->len; i++) {
args[0] = RARRAY(finalizers)->ptr[i];
- rb_protect(run_single_final, (VALUE)args, &status);
+ rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
}
- if (finalizer_table && st_delete(finalizer_table, &obj, &table)) {
+ if (finalizer_table && st_delete(finalizer_table, (st_data_t*)&obj, &table)) {
for (i=0; i<RARRAY(table)->len; i++) {
- args[0] = RARRAY(table)->ptr[i];
- rb_protect(run_single_final, (VALUE)args, &status);
+ VALUE final = RARRAY(table)->ptr[i];
+ args[0] = RARRAY(final)->ptr[1];
+ args[2] = FIX2INT(RARRAY(final)->ptr[0]);
+ rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
}
}
+ rb_thread_critical = critical_save;
+}
+
+void
+rb_gc_finalize_deferred()
+{
+ RVALUE *p = deferred_final_list;
+
+ deferred_final_list = 0;
+ if (p) {
+ finalize_list(p);
+ free_unused_heaps();
+ }
}
void
@@ -1244,16 +1823,9 @@ rb_gc_call_finalizer_at_exit()
/* run finalizers */
if (need_call_final) {
- if (deferred_final_list) {
- p = deferred_final_list;
- while (p) {
- RVALUE *tmp = p;
- p = p->as.free.next;
- run_final((VALUE)tmp);
- }
- }
+ finalize_list(deferred_final_list);
for (i = 0; i < heaps_used; i++) {
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i].slot; pend = p + heaps[i].limit;
while (p < pend) {
if (FL_TEST(p, FL_FINALIZE)) {
FL_UNSET(p, FL_FINALIZE);
@@ -1264,17 +1836,22 @@ rb_gc_call_finalizer_at_exit()
}
}
}
- /* run data object's finaliers */
+ /* run data object's finalizers */
for (i = 0; i < heaps_used; i++) {
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i].slot; pend = p + heaps[i].limit;
while (p < pend) {
if (BUILTIN_TYPE(p) == T_DATA &&
DATA_PTR(p) && RANY(p)->as.data.dfree) {
- p->as.free.flag = 0;
- (*RANY(p)->as.data.dfree)(DATA_PTR(p));
+ p->as.free.flags = 0;
+ if ((long)RANY(p)->as.data.dfree == -1) {
+ RUBY_CRITICAL(free(DATA_PTR(p)));
+ }
+ else if (RANY(p)->as.data.dfree) {
+ (*RANY(p)->as.data.dfree)(DATA_PTR(p));
+ }
}
else if (BUILTIN_TYPE(p) == T_FILE) {
- p->as.free.flag = 0;
+ p->as.free.flags = 0;
rb_io_fptr_finalize(RANY(p)->as.file.fptr);
}
p++;
@@ -1282,6 +1859,19 @@ rb_gc_call_finalizer_at_exit()
}
}
+/*
+ * call-seq:
+ * ObjectSpace._id2ref(object_id) -> an_object
+ *
+ * Converts an object id to a reference to the object. May not be
+ * called on an object id passed as a parameter to a finalizer.
+ *
+ * s = "I am a string" #=> "I am a string"
+ * r = ObjectSpace._id2ref(s.object_id) #=> "I am a string"
+ * r == s #=> true
+ *
+ */
+
static VALUE
id2ref(obj, id)
VALUE obj, id;
@@ -1289,7 +1879,7 @@ id2ref(obj, id)
unsigned long ptr, p0;
rb_secure(4);
- p0 = ptr = NUM2UINT(id);
+ p0 = ptr = NUM2ULONG(id);
if (ptr == Qtrue) return Qtrue;
if (ptr == Qfalse) return Qfalse;
if (ptr == Qnil) return Qnil;
@@ -1299,29 +1889,35 @@ id2ref(obj, id)
}
ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
- if (!is_pointer_to_heap(ptr)) {
- rb_raise(rb_eRangeError, "0x%x is not id value", p0);
+ if (!is_pointer_to_heap((void *)ptr)|| BUILTIN_TYPE(ptr) >= T_BLKTAG) {
+ rb_raise(rb_eRangeError, "0x%lx is not id value", p0);
}
- if (BUILTIN_TYPE(ptr) == 0) {
- rb_raise(rb_eRangeError, "0x%x is recycled object", p0);
+ if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) {
+ rb_raise(rb_eRangeError, "0x%lx is recycled object", p0);
}
return (VALUE)ptr;
}
+/*
+ * The <code>GC</code> module provides an interface to Ruby's mark and
+ * sweep garbage collection mechanism. Some of the underlying methods
+ * are also available via the <code>ObjectSpace</code> module.
+ */
+
void
Init_GC()
{
VALUE rb_mObSpace;
rb_mGC = rb_define_module("GC");
- rb_define_singleton_method(rb_mGC, "start", gc_start, 0);
- rb_define_singleton_method(rb_mGC, "enable", gc_enable, 0);
- rb_define_singleton_method(rb_mGC, "disable", gc_disable, 0);
- rb_define_method(rb_mGC, "garbage_collect", gc_start, 0);
+ rb_define_singleton_method(rb_mGC, "start", rb_gc_start, 0);
+ rb_define_singleton_method(rb_mGC, "enable", rb_gc_enable, 0);
+ rb_define_singleton_method(rb_mGC, "disable", rb_gc_disable, 0);
+ rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);
rb_mObSpace = rb_define_module("ObjectSpace");
rb_define_module_function(rb_mObSpace, "each_object", os_each_obj, -1);
- rb_define_module_function(rb_mObSpace, "garbage_collect", gc_start, 0);
+ rb_define_module_function(rb_mObSpace, "garbage_collect", rb_gc_start, 0);
rb_define_module_function(rb_mObSpace, "add_finalizer", add_final, 1);
rb_define_module_function(rb_mObSpace, "remove_finalizer", rm_final, 1);
rb_define_module_function(rb_mObSpace, "finalizers", finals, 0);
@@ -1336,4 +1932,9 @@ Init_GC()
rb_global_variable(&finalizers);
rb_gc_unregister_address(&rb_mObSpace);
finalizers = rb_ary_new();
+
+ source_filenames = st_init_strtable();
+
+ nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory");
+ rb_global_variable(&nomem_error);
}
diff --git a/hash.c b/hash.c
index eb6e73908c..fbf8d5d20d 100644
--- a/hash.c
+++ b/hash.c
@@ -6,7 +6,7 @@
$Date$
created at: Mon Nov 22 18:51:18 JST 1993
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -17,12 +17,18 @@
#include "util.h"
#include "rubysig.h"
+#ifdef __APPLE__
+#include <crt_externs.h>
+#endif
+
#define HASH_DELETED FL_USER1
+#define HASH_PROC_DEFAULT FL_USER2
static void
rb_hash_modify(hash)
VALUE hash;
{
+ if (!RHASH(hash)->tbl) rb_raise(rb_eTypeError, "uninitialized Hash");
if (OBJ_FROZEN(hash)) rb_error_frozen("hash");
if (!OBJ_TAINTED(hash) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify hash");
@@ -38,14 +44,7 @@ rb_hash_freeze(hash)
VALUE rb_cHash;
static VALUE envtbl;
-static ID hash;
-
-VALUE
-rb_hash(obj)
- VALUE obj;
-{
- return rb_funcall(obj, hash, 0);
-}
+static ID id_hash, id_call, id_default;
static VALUE
eql(args)
@@ -59,6 +58,8 @@ rb_any_cmp(a, b)
VALUE a, b;
{
VALUE args[2];
+
+ if (a == b) return 0;
if (FIXNUM_P(a) && FIXNUM_P(b)) {
return a != b;
}
@@ -66,6 +67,7 @@ rb_any_cmp(a, b)
TYPE(b) == T_STRING && RBASIC(b)->klass == rb_cString) {
return rb_str_cmp(a, b);
}
+ if (a == Qundef || b == Qundef) return -1;
if (SYMBOL_P(a) && SYMBOL_P(b)) {
return a != b;
}
@@ -75,6 +77,13 @@ rb_any_cmp(a, b)
return !rb_with_disable_interrupt(eql, (VALUE)args);
}
+VALUE
+rb_hash(obj)
+ VALUE obj;
+{
+ return rb_funcall(obj, id_hash, 0);
+}
+
static int
rb_any_hash(a)
VALUE a;
@@ -92,12 +101,10 @@ rb_any_hash(a)
break;
default:
- DEFER_INTS;
- hval = rb_funcall(a, hash, 0);
+ hval = rb_funcall(a, id_hash, 0);
if (!FIXNUM_P(hval)) {
- hval = rb_funcall(hval, '%', 1, INT2FIX(65439));
+ hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
}
- ENABLE_INTS;
return (int)FIX2LONG(hval);
}
}
@@ -107,39 +114,82 @@ static struct st_hash_type objhash = {
rb_any_hash,
};
-struct rb_hash_foreach_arg {
- VALUE hash;
- enum st_retval (*func)();
- char *arg;
+struct foreach_safe_arg {
+ st_table *tbl;
+ int (*func)();
+ st_data_t arg;
};
static int
-rb_hash_foreach_iter(key, value, arg)
- VALUE key, value;
- struct rb_hash_foreach_arg *arg;
+foreach_safe_i(key, value, arg, err)
+ st_data_t key, value;
+ struct foreach_safe_arg *arg;
{
int status;
- st_table *tbl = RHASH(arg->hash)->tbl;
- struct st_table_entry **bins = tbl->bins;
+ if (err) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
+ }
if (key == Qundef) 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");
+ status = (*arg->func)(key, value, arg->arg, err);
+ if (status == ST_CONTINUE) {
+ return ST_CHECK;
}
return status;
}
-static VALUE
-rb_hash_foreach_call(arg)
- struct rb_hash_foreach_arg *arg;
+void
+st_foreach_safe(table, func, a)
+ st_table *table;
+ int (*func)();
+ st_data_t a;
{
- st_foreach(RHASH(arg->hash)->tbl, rb_hash_foreach_iter, arg);
- return Qnil;
+ struct foreach_safe_arg arg;
+
+ arg.tbl = table;
+ arg.func = func;
+ arg.arg = a;
+ st_foreach(table, foreach_safe_i, (st_data_t)&arg);
+}
+
+struct hash_foreach_arg {
+ VALUE hash;
+ int (*func)();
+ VALUE arg;
+};
+
+static int
+hash_foreach_iter(key, value, arg, err)
+ VALUE key, value;
+ struct hash_foreach_arg *arg;
+ int err;
+{
+ int status;
+ st_table *tbl;
+
+ if (err) {
+ rb_raise(rb_eRuntimeError, "hash modified during iteration");
+ }
+ tbl = RHASH(arg->hash)->tbl;
+ if (key == Qundef) return ST_CONTINUE;
+ status = (*arg->func)(key, value, arg->arg);
+ if (RHASH(arg->hash)->tbl != tbl) {
+ rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
+ }
+ switch (status) {
+ case ST_DELETE:
+ st_delete_safe(tbl, (st_data_t*)&key, 0, Qundef);
+ FL_SET(arg->hash, HASH_DELETED);
+ case ST_CONTINUE:
+ break;
+ case ST_STOP:
+ return ST_STOP;
+ }
+ return ST_CHECK;
}
static VALUE
-rb_hash_foreach_ensure(hash)
+hash_foreach_ensure(hash)
VALUE hash;
{
RHASH(hash)->iter_lev--;
@@ -153,23 +203,32 @@ rb_hash_foreach_ensure(hash)
return 0;
}
-static int
+static VALUE
+hash_foreach_call(arg)
+ struct hash_foreach_arg *arg;
+{
+ st_foreach(RHASH(arg->hash)->tbl, hash_foreach_iter, (st_data_t)arg);
+ return Qnil;
+}
+
+void
rb_hash_foreach(hash, func, farg)
VALUE hash;
- enum st_retval (*func)();
- char *farg;
+ int (*func)();
+ VALUE farg;
{
- struct rb_hash_foreach_arg arg;
+ struct hash_foreach_arg arg;
RHASH(hash)->iter_lev++;
arg.hash = hash;
arg.func = func;
arg.arg = farg;
- return rb_ensure(rb_hash_foreach_call, (VALUE)&arg, rb_hash_foreach_ensure, hash);
+ rb_ensure(hash_foreach_call, (VALUE)&arg, hash_foreach_ensure, hash);
}
+static VALUE hash_alloc _((VALUE));
static VALUE
-rb_hash_new2(klass)
+hash_alloc(klass)
VALUE klass;
{
NEWOBJ(hash, struct RHash);
@@ -184,20 +243,43 @@ rb_hash_new2(klass)
VALUE
rb_hash_new()
{
- return rb_hash_new2(rb_cHash);
-}
-
-static VALUE
-rb_hash_s_new(argc, argv, klass)
- int argc;
- VALUE *argv;
- VALUE klass;
-{
- VALUE hash = rb_hash_new2(klass);
-
- rb_obj_call_init(hash, argc, argv);
- return hash;
-}
+ return hash_alloc(rb_cHash);
+}
+
+/*
+ * call-seq:
+ * Hash.new => hash
+ * Hash.new(obj) => aHash
+ * Hash.new {|hash, key| block } => aHash
+ *
+ * Returns a new, empty hash. If this hash is subsequently accessed by
+ * a key that doesn't correspond to a hash entry, the value returned
+ * depends on the style of <code>new</code> used to create the hash. In
+ * the first form, the access returns <code>nil</code>. If
+ * <i>obj</i> is specified, this single object will be used for
+ * all <em>default values</em>. If a block is specified, it will be
+ * called with the hash object and the key, and should return the
+ * default value. It is the block's responsibility to store the value
+ * in the hash if required.
+ *
+ * h = Hash.new("Go Fish")
+ * h["a"] = 100
+ * h["b"] = 200
+ * h["a"] #=> 100
+ * h["c"] #=> "Go Fish"
+ * # The following alters the single default object
+ * h["c"].upcase! #=> "GO FISH"
+ * h["d"] #=> "GO FISH"
+ * h.keys #=> ["a", "b"]
+ *
+ * # While this creates a new default object each time
+ * h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
+ * h["c"] #=> "Go Fish: c"
+ * h["c"].upcase! #=> "GO FISH: C"
+ * h["d"] #=> "Go Fish: d"
+ * h.keys #=> ["c", "d"]
+ *
+ */
static VALUE
rb_hash_initialize(argc, argv, hash)
@@ -207,13 +289,35 @@ rb_hash_initialize(argc, argv, hash)
{
VALUE ifnone;
- rb_scan_args(argc, argv, "01", &ifnone);
rb_hash_modify(hash);
- RHASH(hash)->ifnone = ifnone;
+ if (rb_block_given_p()) {
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments");
+ }
+ RHASH(hash)->ifnone = rb_block_proc();
+ FL_SET(hash, HASH_PROC_DEFAULT);
+ }
+ else {
+ rb_scan_args(argc, argv, "01", &ifnone);
+ RHASH(hash)->ifnone = ifnone;
+ }
return hash;
}
+/*
+ * call-seq:
+ * Hash[ [key =>|, value]* ] => hash
+ *
+ * Creates a new hash populated with the given objects. Equivalent to
+ * the literal <code>{ <i>key</i>, <i>value</i>, ... }</code>. Keys and
+ * values occur in pairs, so there must be an even number of arguments.
+ *
+ * Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200}
+ * Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200}
+ * { "a" => 100, "b" => 200 } #=> {"a"=>100, "b"=>200}
+ */
+
static VALUE
rb_hash_s_create(argc, argv, klass)
int argc;
@@ -224,41 +328,27 @@ rb_hash_s_create(argc, argv, klass)
int i;
if (argc == 1 && TYPE(argv[0]) == T_HASH) {
- NEWOBJ(hash, struct RHash);
- OBJSETUP(hash, klass, T_HASH);
+ hash = hash_alloc(klass);
- hash->ifnone = Qnil;
- hash->tbl = st_copy(RHASH(argv[0])->tbl);
+ RHASH(hash)->ifnone = Qnil;
+ RHASH(hash)->tbl = st_copy(RHASH(argv[0])->tbl);
- return (VALUE)hash;
+ return hash;
}
if (argc % 2 != 0) {
- rb_raise(rb_eArgError, "odd number args for Hash");
+ rb_raise(rb_eArgError, "odd number of arguments for Hash");
}
- hash = rb_hash_new2(klass);
+ hash = hash_alloc(klass);
for (i=0; i<argc; i+=2) {
- st_insert(RHASH(hash)->tbl, argv[i], argv[i+1]);
+ rb_hash_aset(hash, argv[i], argv[i + 1]);
}
return hash;
}
static VALUE
-rb_hash_clone(hash)
- VALUE hash;
-{
- NEWOBJ(clone, struct RHash);
- CLONESETUP(clone, hash);
-
- clone->ifnone = RHASH(hash)->ifnone;
- clone->tbl = (st_table*)st_copy(RHASH(hash)->tbl);
-
- return (VALUE)clone;
-}
-
-static VALUE
to_hash(hash)
VALUE hash;
{
@@ -274,20 +364,55 @@ rb_hash_rehash_i(key, value, tbl)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.rehash -> hsh
+ *
+ * Rebuilds the hash based on the current hash values for each key. If
+ * values of key objects have changed since they were inserted, this
+ * method will reindex <i>hsh</i>. If <code>Hash#rehash</code> is
+ * called while an iterator is traversing the hash, an
+ * <code>IndexError</code> will be raised in the iterator.
+ *
+ * a = [ "a", "b" ]
+ * c = [ "c", "d" ]
+ * h = { a => 100, c => 300 }
+ * h[a] #=> 100
+ * a[0] = "z"
+ * h[a] #=> nil
+ * h.rehash #=> {["z", "b"]=>100, ["c", "d"]=>300}
+ * h[a] #=> 100
+ */
+
static VALUE
rb_hash_rehash(hash)
VALUE hash;
{
st_table *tbl;
+ rb_hash_modify(hash);
tbl = st_init_table_with_size(&objhash, RHASH(hash)->tbl->num_entries);
- st_foreach(RHASH(hash)->tbl, rb_hash_rehash_i, tbl);
+ rb_hash_foreach(hash, rb_hash_rehash_i, (st_data_t)tbl);
st_free_table(RHASH(hash)->tbl);
RHASH(hash)->tbl = tbl;
return hash;
}
+/*
+ * call-seq:
+ * hsh[key] => value
+ *
+ * Element Reference---Retrieves the <i>value</i> object corresponding
+ * to the <i>key</i> object. If not found, returns the a default value (see
+ * <code>Hash::new</code> for details).
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h["a"] #=> 100
+ * h["c"] #=> nil
+ *
+ */
+
VALUE
rb_hash_aref(hash, key)
VALUE hash, key;
@@ -295,11 +420,40 @@ rb_hash_aref(hash, key)
VALUE val;
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
- return RHASH(hash)->ifnone;
+ return rb_funcall(hash, id_default, 1, key);
}
return val;
}
+/*
+ * call-seq:
+ * hsh.fetch(key [, default] ) => obj
+ * hsh.fetch(key) {| key | block } => obj
+ *
+ * Returns a value from the hash for the given key. If the key can't be
+ * found, there are several options: With no other arguments, it will
+ * raise an <code>IndexError</code> exception; if <i>default</i> is
+ * given, then that will be returned; if the optional code block is
+ * specified, then that will be run and its result returned.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.fetch("a") #=> 100
+ * h.fetch("z", "go fish") #=> "go fish"
+ * h.fetch("z") { |el| "go fish, #{el}"} #=> "go fish, z"
+ *
+ * The following example shows that an exception is raised if the key
+ * is not found and a default value is not supplied.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.fetch("z")
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:2:in `fetch': key not found (IndexError)
+ * from prog.rb:2
+ *
+ */
+
static VALUE
rb_hash_fetch(argc, argv, hash)
int argc;
@@ -308,16 +462,16 @@ rb_hash_fetch(argc, argv, hash)
{
VALUE key, if_none;
VALUE val;
+ long block_given;
rb_scan_args(argc, argv, "11", &key, &if_none);
+ block_given = rb_block_given_p();
+ if (block_given && argc == 2) {
+ rb_warn("block supersedes default value argument");
+ }
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
- if (rb_block_given_p()) {
- if (argc > 1) {
- rb_raise(rb_eArgError, "wrong # of arguments", argc);
- }
- return rb_yield(key);
- }
+ if (block_given) return rb_yield(key);
if (argc == 1) {
rb_raise(rb_eIndexError, "key not found");
}
@@ -326,20 +480,95 @@ rb_hash_fetch(argc, argv, hash)
return val;
}
+/*
+ * call-seq:
+ * hsh.default(key=nil) => obj
+ *
+ * Returns the default value, the value that would be returned by
+ * <i>hsh</i>[<i>key</i>] if <i>key</i> did not exist in <i>hsh</i>.
+ * See also <code>Hash::new</code> and <code>Hash#default=</code>.
+ *
+ * h = Hash.new #=> {}
+ * h.default #=> nil
+ * h.default(2) #=> nil
+ *
+ * h = Hash.new("cat") #=> {}
+ * h.default #=> "cat"
+ * h.default(2) #=> "cat"
+ *
+ * h = Hash.new {|h,k| h[k] = k.to_i*10} #=> {}
+ * h.default #=> 0
+ * h.default(2) #=> 20
+ */
+
static VALUE
-rb_hash_default(hash)
+rb_hash_default(argc, argv, hash)
+ int argc;
+ VALUE *argv;
VALUE hash;
{
+ VALUE key;
+
+ rb_scan_args(argc, argv, "01", &key);
+ if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
+ return rb_funcall(RHASH(hash)->ifnone, id_call, 2, hash, key);
+ }
return RHASH(hash)->ifnone;
}
+/*
+ * call-seq:
+ * hsh.default = obj => hsh
+ *
+ * Sets the default value, the value returned for a key that does not
+ * exist in the hash. It is not possible to set the a default to a
+ * <code>Proc</code> that will be executed on each key lookup.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.default = "Go fish"
+ * h["a"] #=> 100
+ * h["z"] #=> "Go fish"
+ * # This doesn't do what you might hope...
+ * h.default = proc do |hash, key|
+ * hash[key] = key + key
+ * end
+ * h[2] #=> #<Proc:0x401b3948@-:6>
+ * h["cat"] #=> #<Proc:0x401b3948@-:6>
+ */
+
static VALUE
rb_hash_set_default(hash, ifnone)
VALUE hash, ifnone;
{
rb_hash_modify(hash);
RHASH(hash)->ifnone = ifnone;
- return hash;
+ FL_UNSET(hash, HASH_PROC_DEFAULT);
+ return ifnone;
+}
+
+/*
+ * call-seq:
+ * hsh.default_proc -> anObject
+ *
+ * If <code>Hash::new</code> was invoked with a block, return that
+ * block, otherwise return <code>nil</code>.
+ *
+ * h = Hash.new {|h,k| h[k] = k*k } #=> {}
+ * p = h.default_proc #=> #<Proc:0x401b3d08@-:1>
+ * a = [] #=> []
+ * p.call(a, 2)
+ * a #=> [nil, nil, 4]
+ */
+
+
+static VALUE
+rb_hash_default_proc(hash)
+ VALUE hash;
+{
+ if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
+ return RHASH(hash)->ifnone;
+ }
+ return Qnil;
}
static int
@@ -354,6 +583,18 @@ index_i(key, value, args)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.index(value) => key
+ *
+ * Returns the key for a given value. If not found, returns <code>nil</code>.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.index(200) #=> "b"
+ * h.index(999) #=> nil
+ *
+ */
+
static VALUE
rb_hash_index(hash, value)
VALUE hash, value;
@@ -361,13 +602,22 @@ rb_hash_index(hash, value)
VALUE args[2];
args[0] = value;
- args[1] = RHASH(hash)->ifnone;
+ args[1] = Qnil;
- st_foreach(RHASH(hash)->tbl, index_i, args);
+ rb_hash_foreach(hash, index_i, (st_data_t)args);
return args[1];
}
+/*
+ * call-seq:
+ * hsh.indexes(key, ...) => array
+ * hsh.indices(key, ...) => array
+ *
+ * Deprecated in favor of <code>Hash#select</code>.
+ *
+ */
+
static VALUE
rb_hash_indexes(argc, argv, hash)
int argc;
@@ -377,15 +627,35 @@ rb_hash_indexes(argc, argv, hash)
VALUE indexes;
int i;
+ rb_warn("Hash#%s is deprecated; use Hash#values_at",
+ rb_id2name(rb_frame_last_func()));
indexes = rb_ary_new2(argc);
for (i=0; i<argc; i++) {
RARRAY(indexes)->ptr[i] = rb_hash_aref(hash, argv[i]);
+ RARRAY(indexes)->len++;
}
- RARRAY(indexes)->len = i;
return indexes;
}
-static VALUE
+/*
+ * call-seq:
+ * hsh.delete(key) => value
+ * hsh.delete(key) {| key | block } => value
+ *
+ * Deletes and returns a key-value pair from <i>hsh</i> whose key is
+ * equal to <i>key</i>. If the key is not found, returns the
+ * <em>default value</em>. If the optional code block is given and the
+ * key is not found, pass in the key and return the result of
+ * <i>block</i>.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.delete("a") #=> 100
+ * h.delete("z") #=> nil
+ * h.delete("z") { |el| "#{el} not found" } #=> "z not found"
+ *
+ */
+
+VALUE
rb_hash_delete(hash, key)
VALUE hash, key;
{
@@ -393,17 +663,17 @@ rb_hash_delete(hash, key)
rb_hash_modify(hash);
if (RHASH(hash)->iter_lev > 0) {
- if (st_delete_safe(RHASH(hash)->tbl, &key, &val, Qundef)) {
+ if (st_delete_safe(RHASH(hash)->tbl, (st_data_t*)&key, &val, Qundef)) {
FL_SET(hash, HASH_DELETED);
return val;
}
}
- else if (st_delete(RHASH(hash)->tbl, &key, &val))
+ else if (st_delete(RHASH(hash)->tbl, (st_data_t*)&key, &val))
return val;
if (rb_block_given_p()) {
return rb_yield(key);
}
- return RHASH(hash)->ifnone;
+ return Qnil;
}
struct shift_var {
@@ -425,6 +695,19 @@ shift_i(key, value, var)
return ST_DELETE;
}
+/*
+ * call-seq:
+ * hsh.shift -> anArray or obj
+ *
+ * Removes a key-value pair from <i>hsh</i> and returns it as the
+ * two-item array <code>[</code> <i>key, value</i> <code>]</code>, or
+ * the hash's default value if the hash is empty.
+ *
+ * h = { 1 => "a", 2 => "b", 3 => "c" }
+ * h.shift #=> [1, "a"]
+ * h #=> {2=>"b", 3=>"c"}
+ */
+
static VALUE
rb_hash_shift(hash)
VALUE hash;
@@ -433,31 +716,59 @@ rb_hash_shift(hash)
rb_hash_modify(hash);
var.stop = 0;
- st_foreach(RHASH(hash)->tbl, shift_i, &var);
+ rb_hash_foreach(hash, shift_i, (st_data_t)&var);
- if (var.stop == 0) return RHASH(hash)->ifnone;
- return rb_assoc_new(var.key, var.val);
+ if (var.stop) {
+ return rb_assoc_new(var.key, var.val);
+ }
+ else if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
+ return rb_funcall(RHASH(hash)->ifnone, id_call, 2, hash, Qnil);
+ }
+ else {
+ return RHASH(hash)->ifnone;
+ }
}
static int
-delete_if_i(key, value)
- VALUE key, value;
+delete_if_i(key, value, hash)
+ VALUE key, value, hash;
{
if (key == Qundef) return ST_CONTINUE;
- if (RTEST(rb_yield(rb_assoc_new(key, value))))
- return ST_DELETE;
+ if (RTEST(rb_yield_values(2, key, value))) {
+ rb_hash_delete(hash, key);
+ }
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.delete_if {| key, value | block } -> hsh
+ *
+ * Deletes every key-value pair from <i>hsh</i> for which <i>block</i>
+ * evaluates to <code>true</code>.
+ *
+ * h = { "a" => 100, "b" => 200, "c" => 300 }
+ * h.delete_if {|key, value| key >= "b" } #=> {"a"=>100}
+ *
+ */
+
VALUE
rb_hash_delete_if(hash)
VALUE hash;
{
rb_hash_modify(hash);
- rb_hash_foreach(hash, delete_if_i, 0);
+ rb_hash_foreach(hash, delete_if_i, hash);
return hash;
}
+/*
+ * call-seq:
+ * hsh.reject! {| key, value | block } -> hsh or nil
+ *
+ * Equivalent to <code>Hash#delete_if</code>, but returns
+ * <code>nil</code> if no changes were made.
+ */
+
VALUE
rb_hash_reject_bang(hash)
VALUE hash;
@@ -468,6 +779,16 @@ rb_hash_reject_bang(hash)
return hash;
}
+/*
+ * call-seq:
+ * hsh.reject {| key, value | block } -> a_hash
+ *
+ * Same as <code>Hash#delete_if</code>, but works on (and returns) a
+ * copy of the <i>hsh</i>. Equivalent to
+ * <code><i>hsh</i>.dup.delete_if</code>.
+ *
+ */
+
static VALUE
rb_hash_reject(hash)
VALUE hash;
@@ -476,22 +797,120 @@ rb_hash_reject(hash)
}
static int
+select_i(key, value, result)
+ VALUE key, value, result;
+{
+ if (key == Qundef) return ST_CONTINUE;
+ if (RTEST(rb_yield_values(2, key, value)))
+ rb_ary_push(result, rb_assoc_new(key, value));
+ return ST_CONTINUE;
+}
+
+/*
+ * call-seq:
+ * hsh.values_at(key, ...) => array
+ *
+ * Return an array containing the values associated with the given keys.
+ * Also see <code>Hash.select</code>.
+ *
+ * h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
+ * h.values_at("cow", "cat") #=> ["bovine", "feline"]
+*/
+
+VALUE
+rb_hash_values_at(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
+{
+ VALUE result = rb_ary_new();
+ long i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(result, rb_hash_aref(hash, argv[i]));
+ }
+ return result;
+}
+
+/*
+ * call-seq:
+ * hsh.select {|key, value| block} => array
+ *
+ * Returns a new array consisting of <code>[key,value]</code>
+ * pairs for which the block returns true.
+ * Also see <code>Hash.values_at</code>.
+ *
+ * h = { "a" => 100, "b" => 200, "c" => 300 }
+ * h.select {|k,v| k > "a"} #=> [["b", 200], ["c", 300]]
+ * h.select {|k,v| v < 200} #=> [["a", 100]]
+ */
+
+VALUE
+rb_hash_select(argc, argv, hash)
+ int argc;
+ VALUE *argv;
+ VALUE hash;
+{
+ VALUE result;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ result = rb_ary_new();
+ rb_hash_foreach(hash, select_i, result);
+ return result;
+}
+
+static int
clear_i(key, value, dummy)
VALUE key, value, dummy;
{
return ST_DELETE;
}
+/*
+ * call-seq:
+ * hsh.clear -> hsh
+ *
+ * Removes all key-value pairs from <i>hsh</i>.
+ *
+ * h = { "a" => 100, "b" => 200 } #=> {"a"=>100, "b"=>200}
+ * h.clear #=> {}
+ *
+ */
+
static VALUE
rb_hash_clear(hash)
VALUE hash;
{
+ void *tmp;
+
rb_hash_modify(hash);
- st_foreach(RHASH(hash)->tbl, clear_i, 0);
+ if (RHASH(hash)->tbl->num_entries > 0) {
+ rb_hash_foreach(hash, clear_i, 0);
+ }
return hash;
}
+/*
+ * call-seq:
+ * hsh[key] = value => value
+ * hsh.store(key, value) => value
+ *
+ * Element Assignment---Associates the value given by
+ * <i>value</i> with the key given by <i>key</i>.
+ * <i>key</i> should not have its value changed while it is in
+ * use as a key (a <code>String</code> passed as a key will be
+ * duplicated and frozen).
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h["a"] = 9
+ * h["c"] = 4
+ * h #=> {"a"=>9, "b"=>200, "c"=>4}
+ *
+ */
+
VALUE
rb_hash_aset(hash, key, val)
VALUE hash, key, val;
@@ -510,21 +929,57 @@ static int
replace_i(key, val, hash)
VALUE key, val, hash;
{
- rb_hash_aset(hash, key, val);
+ if (key != Qundef) {
+ rb_hash_aset(hash, key, val);
+ }
+
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.replace(other_hash) -> hsh
+ *
+ * Replaces the contents of <i>hsh</i> with the contents of
+ * <i>other_hash</i>.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400}
+ *
+ */
+
static VALUE
rb_hash_replace(hash, hash2)
VALUE hash, hash2;
{
hash2 = to_hash(hash2);
+ if (hash == hash2) return hash;
rb_hash_clear(hash);
- st_foreach(RHASH(hash2)->tbl, replace_i, hash);
+ rb_hash_foreach(hash2, replace_i, hash);
+ RHASH(hash)->ifnone = RHASH(hash2)->ifnone;
+ if (FL_TEST(hash2, HASH_PROC_DEFAULT)) {
+ FL_SET(hash, HASH_PROC_DEFAULT);
+ }
+ else {
+ FL_UNSET(hash, HASH_PROC_DEFAULT);
+ }
return hash;
}
+/*
+ * call-seq:
+ * hsh.length => fixnum
+ * hsh.size => fixnum
+ *
+ * Returns the number of key-value pairs in the hash.
+ *
+ * h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
+ * h.length #=> 4
+ * h.delete("a") #=> 200
+ * h.length #=> 3
+ */
+
static VALUE
rb_hash_size(hash)
VALUE hash;
@@ -532,6 +987,17 @@ rb_hash_size(hash)
return INT2FIX(RHASH(hash)->tbl->num_entries);
}
+
+/*
+ * call-seq:
+ * hsh.empty? => true or false
+ *
+ * Returns <code>true</code> if <i>hsh</i> contains no key-value pairs.
+ *
+ * {}.empty? #=> true
+ *
+ */
+
static VALUE
rb_hash_empty_p(hash)
VALUE hash;
@@ -550,6 +1016,22 @@ each_value_i(key, value)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.each_value {| value | block } -> hsh
+ *
+ * Calls <i>block</i> once for each key in <i>hsh</i>, passing the
+ * value as a parameter.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.each_value {|value| puts value }
+ *
+ * <em>produces:</em>
+ *
+ * 100
+ * 200
+ */
+
static VALUE
rb_hash_each_value(hash)
VALUE hash;
@@ -567,6 +1049,21 @@ each_key_i(key, value)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.each_key {| key | block } -> hsh
+ *
+ * Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
+ * as a parameter.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.each_key {|key| puts key }
+ *
+ * <em>produces:</em>
+ *
+ * a
+ * b
+ */
static VALUE
rb_hash_each_key(hash)
VALUE hash;
@@ -580,10 +1077,27 @@ each_pair_i(key, value)
VALUE key, value;
{
if (key == Qundef) return ST_CONTINUE;
- rb_yield(rb_assoc_new(key, value));
+ rb_yield_values(2, key, value);
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.each_pair {| key_value_array | block } -> hsh
+ *
+ * Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
+ * and value as parameters.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.each_pair {|key, value| puts "#{key} is #{value}" }
+ *
+ * <em>produces:</em>
+ *
+ * a is 100
+ * b is 200
+ *
+ */
+
static VALUE
rb_hash_each_pair(hash)
VALUE hash;
@@ -593,6 +1107,43 @@ rb_hash_each_pair(hash)
}
static int
+each_i(key, value)
+ VALUE key, value;
+{
+ if (key == Qundef) return ST_CONTINUE;
+ rb_yield(rb_assoc_new(key, value));
+ return ST_CONTINUE;
+}
+
+/*
+ * call-seq:
+ * hsh.each {| key, value | block } -> hsh
+ *
+ * Calls <i>block</i> once for each key in <i>hsh</i>, passing the key
+ * and value to the block as a two-element array. Because of the assignment
+ * semantics of block parameters, these elements will be split out if the
+ * block has two formal parameters. Also see <code>Hash.each_pair</code>, which
+ * will be marginally more efficient for blocks with two parameters.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.each {|key, value| puts "#{key} is #{value}" }
+ *
+ * <em>produces:</em>
+ *
+ * a is 100
+ * b is 200
+ *
+ */
+
+static VALUE
+rb_hash_each(hash)
+ VALUE hash;
+{
+ rb_hash_foreach(hash, each_i, 0);
+ return hash;
+}
+
+static int
to_a_i(key, value, ary)
VALUE key, value, ary;
{
@@ -601,6 +1152,17 @@ to_a_i(key, value, ary)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.to_a -> array
+ *
+ * Converts <i>hsh</i> to a nested array of <code>[</code> <i>key,
+ * value</i> <code>]</code> arrays.
+ *
+ * h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
+ * h.to_a #=> [["a", 100], ["c", 300], ["d", 400]]
+ */
+
static VALUE
rb_hash_to_a(hash)
VALUE hash;
@@ -608,12 +1170,27 @@ rb_hash_to_a(hash)
VALUE ary;
ary = rb_ary_new();
- st_foreach(RHASH(hash)->tbl, to_a_i, ary);
+ rb_hash_foreach(hash, to_a_i, ary);
if (OBJ_TAINTED(hash)) OBJ_TAINT(ary);
return ary;
}
+/*
+ * call-seq:
+ * hsh.sort => array
+ * hsh.sort {| a, b | block } => array
+ *
+ * Converts <i>hsh</i> to a nested array of <code>[</code> <i>key,
+ * value</i> <code>]</code> arrays and sorts it, using
+ * <code>Array#sort</code>.
+ *
+ * h = { "a" => 20, "b" => 30, "c" => 10 }
+ * h.sort #=> [["a", 20], ["b", 30], ["c", 10]]
+ * h.sort {|a,b| a[1]<=>b[1]} #=> [["c", 10], ["a", 20], ["b", 30]]
+ *
+ */
+
static VALUE
rb_hash_sort(hash)
VALUE hash;
@@ -634,11 +1211,11 @@ inspect_i(key, value, str)
rb_str_cat2(str, ", ");
}
str2 = rb_inspect(key);
- rb_str_append(str, str2);
+ rb_str_buf_append(str, str2);
OBJ_INFECT(str, str2);
- rb_str_cat2(str, "=>");
+ rb_str_buf_cat2(str, "=>");
str2 = rb_inspect(value);
- rb_str_append(str, str2);
+ rb_str_buf_append(str, str2);
OBJ_INFECT(str, str2);
return ST_CONTINUE;
@@ -650,19 +1227,27 @@ inspect_hash(hash)
{
VALUE str;
- str = rb_str_new2("{");
- st_foreach(RHASH(hash)->tbl, inspect_i, str);
- rb_str_cat2(str, "}");
-
+ str = rb_str_buf_new2("{");
+ rb_hash_foreach(hash, inspect_i, str);
+ rb_str_buf_cat2(str, "}");
OBJ_INFECT(str, hash);
+
return str;
}
+/*
+ * call-seq:
+ * hsh.inspect => string
+ *
+ * Return the contents of this hash as a string.
+ */
+
static VALUE
rb_hash_inspect(hash)
VALUE hash;
{
- if (RHASH(hash)->tbl->num_entries == 0) return rb_str_new2("{}");
+ if (RHASH(hash)->tbl == 0 || RHASH(hash)->tbl->num_entries == 0)
+ return rb_str_new2("{}");
if (rb_inspecting_p(hash)) return rb_str_new2("{...}");
return rb_protect_inspect(inspect_hash, hash, 0);
}
@@ -674,6 +1259,19 @@ to_s_hash(hash)
return rb_ary_to_s(rb_hash_to_a(hash));
}
+/*
+ * call-seq:
+ * hsh.to_s => string
+ *
+ * Converts <i>hsh</i> to a string by converting the hash to an array
+ * of <code>[</code> <i>key, value</i> <code>]</code> pairs and then
+ * converting that array to a string using <code>Array#join</code> with
+ * the default separator.
+ *
+ * h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
+ * h.to_s #=> "a100c300d400"
+ */
+
static VALUE
rb_hash_to_s(hash)
VALUE hash;
@@ -682,6 +1280,13 @@ rb_hash_to_s(hash)
return rb_protect_inspect(to_s_hash, hash, 0);
}
+/*
+ * call-seq:
+ * hsh.to_hash => hsh
+ *
+ * Returns <i>self</i>.
+ */
+
static VALUE
rb_hash_to_hash(hash)
VALUE hash;
@@ -698,6 +1303,18 @@ keys_i(key, value, ary)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.keys => array
+ *
+ * Returns a new array populated with the keys from this hash. See also
+ * <code>Hash#values</code>.
+ *
+ * h = { "a" => 100, "b" => 200, "c" => 300, "d" => 400 }
+ * h.keys #=> ["a", "b", "c", "d"]
+ *
+ */
+
static VALUE
rb_hash_keys(hash)
VALUE hash;
@@ -705,7 +1322,7 @@ rb_hash_keys(hash)
VALUE ary;
ary = rb_ary_new();
- st_foreach(RHASH(hash)->tbl, keys_i, ary);
+ rb_hash_foreach(hash, keys_i, ary);
return ary;
}
@@ -719,6 +1336,18 @@ values_i(key, value, ary)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.values => array
+ *
+ * Returns a new array populated with the values from <i>hsh</i>. See
+ * also <code>Hash#keys</code>.
+ *
+ * h = { "a" => 100, "b" => 200, "c" => 300 }
+ * h.values #=> [100, 200, 300]
+ *
+ */
+
static VALUE
rb_hash_values(hash)
VALUE hash;
@@ -726,11 +1355,26 @@ rb_hash_values(hash)
VALUE ary;
ary = rb_ary_new();
- st_foreach(RHASH(hash)->tbl, values_i, ary);
+ rb_hash_foreach(hash, values_i, ary);
return ary;
}
+/*
+ * call-seq:
+ * hsh.has_key?(key) => true or false
+ * hsh.include?(key) => true or false
+ * hsh.key?(key) => true or false
+ * hsh.member?(key) => true or false
+ *
+ * Returns <code>true</code> if the given key is present in <i>hsh</i>.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.has_key?("a") #=> true
+ * h.has_key?("z") #=> false
+ *
+ */
+
static VALUE
rb_hash_has_key(hash, key)
VALUE hash;
@@ -754,6 +1398,19 @@ rb_hash_search_value(key, value, data)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.has_value?(value) => true or false
+ * hsh.value?(value) => true or false
+ *
+ * Returns <code>true</code> if the given value is present for some key
+ * in <i>hsh</i>.
+ *
+ * h = { "a" => 100, "b" => 200 }
+ * h.has_value?(100) #=> true
+ * h.has_value?(999) #=> false
+ */
+
static VALUE
rb_hash_has_value(hash, val)
VALUE hash;
@@ -763,7 +1420,7 @@ rb_hash_has_value(hash, val)
data[0] = Qfalse;
data[1] = val;
- st_foreach(RHASH(hash)->tbl, rb_hash_search_value, data);
+ rb_hash_foreach(hash, rb_hash_search_value, (st_data_t)data);
return data[0];
}
@@ -792,22 +1449,76 @@ equal_i(key, val1, data)
}
static VALUE
-rb_hash_equal(hash1, hash2)
+hash_equal(hash1, hash2, eql)
VALUE hash1, hash2;
+ int eql; /* compare default value if true */
{
struct equal_data data;
- if (TYPE(hash2) != T_HASH) return Qfalse;
+ if (hash1 == hash2) return Qtrue;
+ if (TYPE(hash2) != T_HASH) {
+ if (!rb_respond_to(hash2, rb_intern("to_hash"))) {
+ return Qfalse;
+ }
+ return rb_equal(hash2, hash1);
+ }
if (RHASH(hash1)->tbl->num_entries != RHASH(hash2)->tbl->num_entries)
return Qfalse;
+ if (eql) {
+ if (!(rb_equal(RHASH(hash1)->ifnone, RHASH(hash2)->ifnone) &&
+ FL_TEST(hash1, HASH_PROC_DEFAULT) == FL_TEST(hash2, HASH_PROC_DEFAULT)))
+ return Qfalse;
+ }
data.tbl = RHASH(hash2)->tbl;
data.result = Qtrue;
- st_foreach(RHASH(hash1)->tbl, equal_i, &data);
+ rb_hash_foreach(hash1, equal_i, (st_data_t)&data);
return data.result;
}
+/*
+ * call-seq:
+ * hsh == other_hash => true or false
+ *
+ * Equality---Two hashes are equal if they each contain the same number
+ * of keys and if each key-value pair is equal to (according to
+ * <code>Object#==</code>) the corresponding elements in the other
+ * hash.
+ *
+ * h1 = { "a" => 1, "c" => 2 }
+ * h2 = { 7 => 35, "c" => 2, "a" => 1 }
+ * h3 = { "a" => 1, "c" => 2, 7 => 35 }
+ * h4 = { "a" => 1, "d" => 2, "f" => 35 }
+ * h1 == h2 #=> false
+ * h2 == h3 #=> true
+ * h3 == h4 #=> false
+ *
+ */
+
+static VALUE
+rb_hash_equal(hash1, hash2)
+ VALUE hash1, hash2;
+{
+ return hash_equal(hash1, hash2, Qfalse);
+}
+
+/*
+ * call-seq:
+ * hsh.eql?(other_hash) => true or false
+ *
+ * Returns true if two hashes are equal, i.e they have same key-value set,
+ * and same default values.
+ *
+ */
+
+static VALUE
+rb_hash_eql(hash1, hash2)
+ VALUE hash1, hash2;
+{
+ return hash_equal(hash1, hash2, Qtrue);
+}
+
static int
rb_hash_invert_i(key, value, hash)
VALUE key, value;
@@ -818,13 +1529,25 @@ rb_hash_invert_i(key, value, hash)
return ST_CONTINUE;
}
+/*
+ * call-seq:
+ * hsh.invert -> aHash
+ *
+ * Returns a new hash created by using <i>hsh</i>'s values as keys, and
+ * the keys as values.
+ *
+ * h = { "n" => 100, "m" => 100, "y" => 300, "d" => 200, "a" => 0 }
+ * h.invert #=> {0=>"a", 100=>"n", 200=>"d", 300=>"y"}
+ *
+ */
+
static VALUE
rb_hash_invert(hash)
VALUE hash;
{
VALUE h = rb_hash_new();
- st_foreach(RHASH(hash)->tbl, rb_hash_invert_i, h);
+ rb_hash_foreach(hash, rb_hash_invert_i, h);
return h;
}
@@ -838,40 +1561,130 @@ rb_hash_update_i(key, value, hash)
return ST_CONTINUE;
}
+static int
+rb_hash_update_block_i(key, value, hash)
+ VALUE key, value;
+ VALUE hash;
+{
+ if (key == Qundef) return ST_CONTINUE;
+ if (rb_hash_has_key(hash, key)) {
+ value = rb_yield_values(3, key, rb_hash_aref(hash, key), value);
+ }
+ rb_hash_aset(hash, key, value);
+ return ST_CONTINUE;
+}
+
+/*
+ * call-seq:
+ * hsh.merge!(other_hash) => hsh
+ * hsh.update(other_hash) => hsh
+ *
+ * Adds the contents of <i>other_hash</i> to <i>hsh</i>, overwriting
+ * entries with duplicate keys with those from <i>other_hash</i>.
+ *
+ * h1 = { "a" => 100, "b" => 200 }
+ * h2 = { "b" => 254, "c" => 300 }
+ * h1.merge!(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
+ */
+
static VALUE
rb_hash_update(hash1, hash2)
VALUE hash1, hash2;
{
hash2 = to_hash(hash2);
- st_foreach(RHASH(hash2)->tbl, rb_hash_update_i, hash1);
+ if (rb_block_given_p()) {
+ rb_hash_foreach(hash2, rb_hash_update_block_i, hash1);
+ }
+ else {
+ rb_hash_foreach(hash2, rb_hash_update_i, hash1);
+ }
return hash1;
}
+/*
+ * call-seq:
+ * hsh.merge(other_hash) -> a_hash
+ *
+ * Returns a new hash containing the contents of <i>other_hash</i> and
+ * the contents of <i>hsh</i>, overwriting entries in <i>hsh</i> with
+ * duplicate keys with those from <i>other_hash</i>.
+ *
+ * h1 = { "a" => 100, "b" => 200 }
+ * h2 = { "b" => 254, "c" => 300 }
+ * h1.merge(h2) #=> {"a"=>100, "b"=>254, "c"=>300}
+ * h1 #=> {"a"=>100, "b"=>200}
+ *
+ */
+
+static VALUE
+rb_hash_merge(hash1, hash2)
+ VALUE hash1, hash2;
+{
+ return rb_hash_update(rb_obj_dup(hash1), hash2);
+}
+
static int path_tainted = -1;
-#ifndef NT
+static char **origenviron;
+#ifdef _WIN32
+#define GET_ENVIRON(e) (e = rb_w32_get_environ())
+#define FREE_ENVIRON(e) rb_w32_free_environ(e)
+static char **my_environ;
+#undef environ
+#define environ my_environ
+#elif defined(__APPLE__)
+#undef environ
+#define environ (*_NSGetEnviron())
+#define GET_ENVIRON(e) (e)
+#define FREE_ENVIRON(e)
+#else
extern char **environ;
+#define GET_ENVIRON(e) (e)
+#define FREE_ENVIRON(e)
#endif
-static char **origenviron;
+
+static VALUE
+env_str_new(ptr, len)
+ const char *ptr;
+ long len;
+{
+ VALUE str = rb_tainted_str_new(ptr, len);
+
+ rb_obj_freeze(str);
+ return str;
+}
+
+static VALUE
+env_str_new2(ptr)
+ const char *ptr;
+{
+ if (!ptr) return Qnil;
+ return env_str_new(ptr, strlen(ptr));
+}
static VALUE
env_delete(obj, name)
VALUE obj, name;
{
- int len;
char *nam, *val;
rb_secure(4);
- nam = rb_str2cstr(name, &len);
- if (strlen(nam) != len) {
+ SafeStringValue(name);
+ nam = RSTRING(name)->ptr;
+ if (strlen(nam) != RSTRING(name)->len) {
rb_raise(rb_eArgError, "bad environment variable name");
}
val = getenv(nam);
if (val) {
- VALUE value = rb_tainted_str_new2(val);
+ VALUE value = env_str_new2(val);
ruby_setenv(nam, 0);
- if (strcmp(nam, "PATH") == 0 && !OBJ_TAINTED(name)) {
+#ifdef ENV_IGNORECASE
+ if (strcasecmp(nam, PATH_ENV) == 0)
+#else
+ if (strcmp(nam, PATH_ENV) == 0)
+#endif
+ {
path_tainted = 0;
}
return value;
@@ -883,8 +1696,10 @@ static VALUE
env_delete_m(obj, name)
VALUE obj, name;
{
- VALUE val = env_delete(obj, name);
- if (rb_block_given_p()) rb_yield(name);
+ VALUE val;
+
+ val = env_delete(obj, name);
+ if (NIL_P(val) && rb_block_given_p()) rb_yield(name);
return val;
}
@@ -893,17 +1708,26 @@ rb_f_getenv(obj, name)
VALUE obj, name;
{
char *nam, *env;
- int len;
- nam = rb_str2cstr(name, &len);
- if (strlen(nam) != len) {
+ StringValue(name);
+ nam = RSTRING(name)->ptr;
+ if (strlen(nam) != RSTRING(name)->len) {
rb_raise(rb_eArgError, "bad environment variable name");
}
env = getenv(nam);
if (env) {
- if (strcmp(nam, "PATH") == 0 && !rb_env_path_tainted())
- return rb_str_new2(env);
- return rb_tainted_str_new2(env);
+#ifdef ENV_IGNORECASE
+ if (strcasecmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
+#else
+ if (strcmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
+#endif
+ {
+ VALUE str = rb_str_new2(env);
+
+ rb_obj_freeze(str);
+ return str;
+ }
+ return env_str_new2(env);
}
return Qnil;
}
@@ -914,30 +1738,34 @@ env_fetch(argc, argv)
VALUE *argv;
{
VALUE key, if_none;
+ long block_given;
char *nam, *env;
- int len;
rb_scan_args(argc, argv, "11", &key, &if_none);
- nam = rb_str2cstr(key, &len);
- if (strlen(nam) != len) {
+ block_given = rb_block_given_p();
+ if (block_given && argc == 2) {
+ rb_warn("block supersedes default value argument");
+ }
+ StringValue(key);
+ nam = RSTRING(key)->ptr;
+ if (strlen(nam) != RSTRING(key)->len) {
rb_raise(rb_eArgError, "bad environment variable name");
}
env = getenv(nam);
if (!env) {
- if (rb_block_given_p()) {
- if (argc > 1) {
- rb_raise(rb_eArgError, "wrong # of arguments", argc);
- }
- return rb_yield(key);
- }
+ if (block_given) return rb_yield(key);
if (argc == 1) {
rb_raise(rb_eIndexError, "key not found");
}
return if_none;
}
- if (strcmp(nam, "PATH") == 0 && !rb_env_path_tainted())
+#ifdef ENV_IGNORECASE
+ if (strcasecmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
+#else
+ if (strcmp(nam, PATH_ENV) == 0 && !rb_env_path_tainted())
+#endif
return rb_str_new2(env);
- return rb_tainted_str_new2(env);
+ return env_str_new2(env);
}
static void
@@ -951,27 +1779,30 @@ int
rb_env_path_tainted()
{
if (path_tainted < 0) {
- path_tainted_p(getenv("PATH"));
+ path_tainted_p(getenv(PATH_ENV));
}
return path_tainted;
}
static int
envix(nam)
-char *nam;
+ const char *nam;
{
register int i, len = strlen(nam);
+ char **env;
- for (i = 0; environ[i]; i++) {
+ env = GET_ENVIRON(environ);
+ for (i = 0; env[i]; i++) {
if (
-#ifdef WIN32
- strnicmp(environ[i],nam,len) == 0
+#ifdef ENV_IGNORECASE
+ strncasecmp(env[i],nam,len) == 0
#else
- memcmp(environ[i],nam,len) == 0
+ memcmp(env[i],nam,len) == 0
#endif
- && environ[i][len] == '=')
+ && env[i][len] == '=')
break; /* memcmp must come first to avoid */
} /* potential SEGV's */
+ FREE_ENVIRON(environ);
return i;
}
@@ -980,45 +1811,7 @@ ruby_setenv(name, value)
const char *name;
const char *value;
{
-#if defined(WIN32) && !defined(__CYGWIN32__)
-#ifdef USE_WIN32_RTL_ENV
- register char *envstr;
- STRLEN namlen = strlen(name);
- STRLEN vallen;
- char *oldstr = environ[envix(name)];
-
- /* putenv() has totally broken semantics in both the Borland
- * and Microsoft CRTLs. They either store the passed pointer in
- * the environment without making a copy, or make a copy and don't
- * free it. And on top of that, they dont free() old entries that
- * are being replaced/deleted. This means the caller must
- * free any old entries somehow, or we end up with a memory
- * leak every time setenv() is called. One might think
- * one could directly manipulate environ[], like the UNIX code
- * above, but direct changes to environ are not allowed when
- * calling putenv(), since the RTLs maintain an internal
- * *copy* of environ[]. Bad, bad, *bad* stink.
- * GSAR 97-06-07
- */
-
- if (!value) {
- if (!oldstr)
- return;
- value = "";
- vallen = 0;
- }
- else
- vallen = strlen(val);
- envstr = ALLOC_N(char, namelen + vallen + 3);
- sprintf(envstr,"%s=%s",name,value);
- putenv(envstr);
- if (oldstr) free(oldstr);
-#ifdef _MSC_VER
- free(envstr); /* MSVCRT leaks without this */
-#endif
-
-#else /* !USE_WIN32_RTL_ENV */
-
+#if defined(_WIN32)
/* The sane way to deal with the environment.
* Has these advantages over putenv() & co.:
* * enables us to store a truly empty value in the
@@ -1032,10 +1825,11 @@ ruby_setenv(name, value)
* not see changes made by extensions that call the Win32
* functions directly, either.
* GSAR 97-06-07
+ *
+ * REMARK: USE_WIN32_RTL_ENV is already obsoleted since we don't use
+ * RTL's environ global variable directly yet.
*/
SetEnvironmentVariable(name,value);
-#endif
-
#elif defined __CYGWIN__
#undef setenv
#undef unsetenv
@@ -1060,8 +1854,12 @@ ruby_setenv(name, value)
environ = tmpenv; /* tell exec where it is now */
}
if (!value) {
- if (environ[i] != origenviron[i])
- free(environ[i]);
+ if (environ != origenviron) {
+ char **envp = origenviron;
+ while (*envp && *envp != environ[i]) envp++;
+ if (!*envp)
+ free(environ[i]);
+ }
while (environ[i]) {
environ[i] = environ[i+1];
i++;
@@ -1100,11 +1898,10 @@ ruby_unsetenv(name)
}
static VALUE
-rb_f_setenv(obj, nm, val)
+env_aset(obj, nm, val)
VALUE obj, nm, val;
{
char *name, *value;
- int nlen, vlen;
if (rb_safe_level() >= 4) {
rb_raise(rb_eSecurityError, "cannot change environment variable");
@@ -1115,25 +1912,31 @@ rb_f_setenv(obj, nm, val)
return Qnil;
}
- name = rb_str2cstr(nm, &nlen);
- value = rb_str2cstr(val, &vlen);
- if (strlen(name) != nlen)
+ StringValue(nm);
+ StringValue(val);
+ name = RSTRING(nm)->ptr;
+ value = RSTRING(val)->ptr;
+ if (strlen(name) != RSTRING(nm)->len)
rb_raise(rb_eArgError, "bad environment variable name");
- if (strlen(value) != vlen)
+ if (strlen(value) != RSTRING(val)->len)
rb_raise(rb_eArgError, "bad environment variable value");
ruby_setenv(name, value);
- if (strcmp(name, "PATH") == 0) {
+#ifdef ENV_IGNORECASE
+ if (strcasecmp(name, PATH_ENV) == 0) {
+#else
+ if (strcmp(name, PATH_ENV) == 0) {
+#endif
if (OBJ_TAINTED(val)) {
/* already tainted, no check */
path_tainted = 1;
- return Qtrue;
+ return val;
}
else {
path_tainted_p(value);
}
}
- return Qtrue;
+ return val;
}
static VALUE
@@ -1142,32 +1945,29 @@ env_keys()
char **env;
VALUE ary = rb_ary_new();
- env = environ;
+ env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_ary_push(ary, rb_tainted_str_new(*env, s-*env));
+ rb_ary_push(ary, env_str_new(*env, s-*env));
}
env++;
}
+ FREE_ENVIRON(environ);
return ary;
}
static VALUE
-env_each_key(hash)
- VALUE hash;
+env_each_key(ehash)
+ VALUE ehash;
{
- char **env;
+ VALUE keys = env_keys();
+ long i;
- env = environ;
- while (*env) {
- char *s = strchr(*env, '=');
- if (s) {
- rb_yield(rb_tainted_str_new(*env, s-*env));
- }
- env++;
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ rb_yield(RARRAY(keys)->ptr[i]);
}
- return Qnil;
+ return ehash;
}
static VALUE
@@ -1176,73 +1976,95 @@ env_values()
char **env;
VALUE ary = rb_ary_new();
- env = environ;
+ env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_ary_push(ary, rb_tainted_str_new2(s+1));
+ rb_ary_push(ary, env_str_new2(s+1));
}
env++;
}
+ FREE_ENVIRON(environ);
return ary;
}
static VALUE
-env_each_value(hash)
- VALUE hash;
+env_each_value(ehash)
+ VALUE ehash;
{
- char **env;
+ VALUE values = env_values();
+ long i;
- env = environ;
- while (*env) {
- char *s = strchr(*env, '=');
- if (s) {
- rb_yield(rb_tainted_str_new2(s+1));
- }
- env++;
+ for (i=0; i<RARRAY(values)->len; i++) {
+ rb_yield(RARRAY(values)->ptr[i]);
}
- return Qnil;
+ return ehash;
}
static VALUE
-env_each(hash)
- VALUE hash;
+env_each_i(ehash, values)
+ VALUE ehash;
+ int values;
{
char **env;
+ VALUE ary = rb_ary_new();
+ long i;
- env = environ;
+ env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_yield(rb_assoc_new(rb_tainted_str_new(*env, s-*env),
- rb_tainted_str_new2(s+1)));
+ rb_ary_push(ary, env_str_new(*env, s-*env));
+ rb_ary_push(ary, env_str_new2(s+1));
}
env++;
}
- return Qnil;
+ FREE_ENVIRON(environ);
+
+ for (i=0; i<RARRAY(ary)->len; i+=2) {
+ if (values) {
+ rb_yield_values(2, RARRAY(ary)->ptr[i], RARRAY(ary)->ptr[i+1]);
+ }
+ else {
+ rb_yield(rb_assoc_new(RARRAY(ary)->ptr[i], RARRAY(ary)->ptr[i+1]));
+ }
+ }
+ return ehash;
+}
+
+static VALUE
+env_each(ehash)
+ VALUE ehash;
+{
+ return env_each_i(ehash, Qfalse);
+}
+
+static VALUE
+env_each_pair(ehash)
+ VALUE ehash;
+{
+ return env_each_i(ehash, Qtrue);
}
static VALUE
env_reject_bang()
{
volatile VALUE keys;
- VALUE *ptr;
- int len, del = 0;
+ long i;
+ int del = 0;
rb_secure(4);
keys = env_keys();
- ptr = RARRAY(keys)->ptr;
- len = RARRAY(keys)->len;
- while (len--) {
- VALUE val = rb_f_getenv(Qnil, *ptr);
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
if (!NIL_P(val)) {
- if (RTEST(rb_yield(rb_assoc_new(*ptr, val)))) {
- env_delete(Qnil, *ptr);
+ if (RTEST(rb_yield_values(2, RARRAY(keys)->ptr[i], val))) {
+ FL_UNSET(RARRAY(keys)->ptr[i], FL_TAINT);
+ env_delete(Qnil, RARRAY(keys)->ptr[i]);
del++;
}
}
- ptr++;
}
if (del == 0) return Qnil;
return envtbl;
@@ -1256,6 +2078,67 @@ env_delete_if()
}
static VALUE
+env_values_at(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE result = rb_ary_new();
+ long i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(result, rb_f_getenv(Qnil, argv[i]));
+ }
+ return result;
+}
+
+static VALUE
+env_select(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE result;
+ char **env;
+
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ result = rb_ary_new();
+ env = GET_ENVIRON(environ);
+ while (*env) {
+ char *s = strchr(*env, '=');
+ if (s) {
+ VALUE k = env_str_new(*env, s-*env);
+ VALUE v = env_str_new2(s+1);
+ if (RTEST(rb_yield_values(2, k, v))) {
+ rb_ary_push(result, rb_assoc_new(k, v));
+ }
+ }
+ env++;
+ }
+ FREE_ENVIRON(environ);
+
+ return result;
+}
+
+static VALUE
+env_clear()
+{
+ volatile VALUE keys;
+ long i;
+
+ rb_secure(4);
+ keys = env_keys();
+
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
+ if (!NIL_P(val)) {
+ env_delete(Qnil, RARRAY(keys)->ptr[i]);
+ }
+ }
+ return envtbl;
+}
+
+static VALUE
env_to_s()
{
return rb_str_new2("ENV");
@@ -1265,26 +2148,27 @@ static VALUE
env_inspect()
{
char **env;
- VALUE str = rb_str_new2("{");
+ VALUE str = rb_str_buf_new2("{");
VALUE i;
- env = environ;
+ env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (env != environ) {
- rb_str_cat2(str, ", ");
+ rb_str_buf_cat2(str, ", ");
}
if (s) {
- rb_str_cat2(str, "\"");
- rb_str_cat(str, *env, s-*env);
- rb_str_cat2(str, "\"=>");
+ rb_str_buf_cat2(str, "\"");
+ rb_str_buf_cat(str, *env, s-*env);
+ rb_str_buf_cat2(str, "\"=>");
i = rb_inspect(rb_str_new2(s+1));
- rb_str_append(str, i);
+ rb_str_buf_append(str, i);
}
env++;
}
- rb_str_cat2(str, "}");
+ FREE_ENVIRON(environ);
+ rb_str_buf_cat2(str, "}");
OBJ_TAINT(str);
return str;
@@ -1296,15 +2180,16 @@ env_to_a()
char **env;
VALUE ary = rb_ary_new();
- env = environ;
+ env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_ary_push(ary, rb_assoc_new(rb_tainted_str_new(*env, s-*env),
- rb_tainted_str_new2(s+1)));
+ rb_ary_push(ary, rb_assoc_new(env_str_new(*env, s-*env),
+ env_str_new2(s+1)));
}
env++;
}
+ FREE_ENVIRON(environ);
return ary;
}
@@ -1318,16 +2203,26 @@ static VALUE
env_size()
{
int i;
+ char **env;
- for(i=0; environ[i]; i++)
+ env = GET_ENVIRON(environ);
+ for(i=0; env[i]; i++)
;
+ FREE_ENVIRON(environ);
return INT2FIX(i);
}
static VALUE
env_empty_p()
{
- if (environ[0] == 0) return Qtrue;
+ char **env;
+
+ env = GET_ENVIRON(environ);
+ if (env[0] == 0) {
+ FREE_ENVIRON(environ);
+ return Qtrue;
+ }
+ FREE_ENVIRON(environ);
return Qfalse;
}
@@ -1335,8 +2230,12 @@ static VALUE
env_has_key(env, key)
VALUE env, key;
{
- if (TYPE(key) != T_STRING) return Qfalse;
- if (getenv(STR2CSTR(key))) return Qtrue;
+ char *s;
+
+ s = StringValuePtr(key);
+ if (strlen(s) != RSTRING(key)->len)
+ rb_raise(rb_eArgError, "bad environment variable name");
+ if (getenv(s)) return Qtrue;
return Qfalse;
}
@@ -1347,15 +2246,19 @@ env_has_value(dmy, value)
char **env;
if (TYPE(value) != T_STRING) return Qfalse;
- env = environ;
+ env = GET_ENVIRON(environ);
while (*env) {
- char *s = strchr(*env, '=')+1;
- if (s) {
- if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0)
+ char *s = strchr(*env, '=');
+ if (s++) {
+ long len = strlen(s);
+ if (RSTRING(value)->len == len && strncmp(s, RSTRING(value)->ptr, len) == 0) {
+ FREE_ENVIRON(environ);
return Qtrue;
+ }
}
env++;
}
+ FREE_ENVIRON(environ);
return Qfalse;
}
@@ -1364,18 +2267,23 @@ env_index(dmy, value)
VALUE dmy, value;
{
char **env;
+ VALUE str;
- if (TYPE(value) != T_STRING) return Qnil;
- env = environ;
+ StringValue(value);
+ env = GET_ENVIRON(environ);
while (*env) {
- char *s = strchr(*env, '=')+1;
- if (s) {
- if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) {
- return rb_tainted_str_new(*env, s-*env-1);
+ char *s = strchr(*env, '=');
+ if (s++) {
+ long len = strlen(s);
+ if (RSTRING(value)->len == len && strncmp(s, RSTRING(value)->ptr, len) == 0) {
+ str = env_str_new(*env, s-*env-1);
+ FREE_ENVIRON(environ);
+ return str;
}
}
env++;
}
+ FREE_ENVIRON(environ);
return Qnil;
}
@@ -1387,16 +2295,15 @@ env_indexes(argc, argv)
int i;
VALUE indexes = rb_ary_new2(argc);
+ rb_warn("ENV.%s is deprecated; use ENV.values_at",
+ rb_id2name(rb_frame_last_func()));
for (i=0;i<argc;i++) {
- char *v = 0;
- if (TYPE(argv[i]) == T_STRING) {
- v = getenv(RSTRING(argv[i])->ptr);
- }
- if (v) {
- RARRAY(indexes)->ptr[i] = rb_tainted_str_new2(v);
+ VALUE tmp = rb_check_string_type(argv[i]);
+ if (NIL_P(tmp)) {
+ RARRAY(indexes)->ptr[i] = Qnil;
}
else {
- RARRAY(indexes)->ptr[i] = Qnil;
+ RARRAY(indexes)->ptr[i] = env_str_new2(getenv(RSTRING(tmp)->ptr));
}
RARRAY(indexes)->len = i+1;
}
@@ -1410,15 +2317,16 @@ env_to_hash()
char **env;
VALUE hash = rb_hash_new();
- env = environ;
+ env = GET_ENVIRON(environ);
while (*env) {
char *s = strchr(*env, '=');
if (s) {
- rb_hash_aset(hash, rb_tainted_str_new(*env, s-*env),
- rb_tainted_str_new2(s+1));
+ rb_hash_aset(hash, env_str_new(*env, s-*env),
+ env_str_new2(s+1));
}
env++;
}
+ FREE_ENVIRON(environ);
return hash;
}
@@ -1428,20 +2336,112 @@ env_reject()
return rb_hash_delete_if(env_to_hash());
}
+static VALUE
+env_shift()
+{
+ char **env;
+
+ env = GET_ENVIRON(environ);
+ if (*env) {
+ char *s = strchr(*env, '=');
+ if (s) {
+ VALUE key = env_str_new(*env, s-*env);
+ VALUE val = env_str_new2(getenv(RSTRING(key)->ptr));
+ env_delete(Qnil, key);
+ return rb_assoc_new(key, val);
+ }
+ }
+ FREE_ENVIRON(environ);
+ return Qnil;
+}
+
+static VALUE
+env_invert()
+{
+ return rb_hash_invert(env_to_hash());
+}
+
+static int
+env_replace_i(key, val, keys)
+ VALUE key, val, keys;
+{
+ if (key != Qundef) {
+ env_aset(Qnil, key, val);
+ if (rb_ary_includes(keys, key)) {
+ rb_ary_delete(keys, key);
+ }
+ }
+ return ST_CONTINUE;
+}
+
+static VALUE
+env_replace(env, hash)
+ VALUE env, hash;
+{
+ volatile VALUE keys = env_keys();
+ long i;
+
+ if (env == hash) return env;
+ hash = to_hash(hash);
+ rb_hash_foreach(hash, env_replace_i, keys);
+
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ env_delete(env, RARRAY(keys)->ptr[i]);
+ }
+ return env;
+}
+
+static int
+env_update_i(key, val)
+ VALUE key, val;
+{
+ if (key != Qundef) {
+ if (rb_block_given_p()) {
+ val = rb_yield_values(3, key, rb_f_getenv(Qnil, key), val);
+ }
+ env_aset(Qnil, key, val);
+ }
+ return ST_CONTINUE;
+}
+
+static VALUE
+env_update(env, hash)
+ VALUE env, hash;
+{
+ if (env == hash) return env;
+ hash = to_hash(hash);
+ rb_hash_foreach(hash, env_update_i, 0);
+ return env;
+}
+
+/*
+ * A <code>Hash</code> is a collection of key-value pairs. It is
+ * similar to an <code>Array</code>, except that indexing is done via
+ * arbitrary keys of any object type, not an integer index. The order
+ * in which you traverse a hash by either key or value may seem
+ * arbitrary, and will generally not be in the insertion order.
+ *
+ * Hashes have a <em>default value</em> that is returned when accessing
+ * keys that do not exist in the hash. By default, that value is
+ * <code>nil</code>.
+ *
+ */
+
void
Init_Hash()
{
- hash = rb_intern("hash");
+ id_hash = rb_intern("hash");
+ id_call = rb_intern("call");
+ id_default = rb_intern("default");
rb_cHash = rb_define_class("Hash", rb_cObject);
rb_include_module(rb_cHash, rb_mEnumerable);
- rb_define_singleton_method(rb_cHash, "new", rb_hash_s_new, -1);
+ rb_define_alloc_func(rb_cHash, hash_alloc);
rb_define_singleton_method(rb_cHash, "[]", rb_hash_s_create, -1);
rb_define_method(rb_cHash,"initialize", rb_hash_initialize, -1);
-
- rb_define_method(rb_cHash,"clone", rb_hash_clone, 0);
+ rb_define_method(rb_cHash,"initialize_copy", rb_hash_replace, 1);
rb_define_method(rb_cHash,"rehash", rb_hash_rehash, 0);
rb_define_method(rb_cHash,"to_hash", rb_hash_to_hash, 0);
@@ -1450,12 +2450,14 @@ Init_Hash()
rb_define_method(rb_cHash,"inspect", rb_hash_inspect, 0);
rb_define_method(rb_cHash,"==", rb_hash_equal, 1);
+ rb_define_method(rb_cHash,"eql?", rb_hash_eql, 1);
rb_define_method(rb_cHash,"[]", rb_hash_aref, 1);
rb_define_method(rb_cHash,"fetch", rb_hash_fetch, -1);
rb_define_method(rb_cHash,"[]=", rb_hash_aset, 2);
rb_define_method(rb_cHash,"store", rb_hash_aset, 2);
- rb_define_method(rb_cHash,"default", rb_hash_default, 0);
+ rb_define_method(rb_cHash,"default", rb_hash_default, -1);
rb_define_method(rb_cHash,"default=", rb_hash_set_default, 1);
+ rb_define_method(rb_cHash,"default_proc", rb_hash_default_proc, 0);
rb_define_method(rb_cHash,"index", rb_hash_index, 1);
rb_define_method(rb_cHash,"indexes", rb_hash_indexes, -1);
rb_define_method(rb_cHash,"indices", rb_hash_indexes, -1);
@@ -1463,7 +2465,7 @@ Init_Hash()
rb_define_method(rb_cHash,"length", rb_hash_size, 0);
rb_define_method(rb_cHash,"empty?", rb_hash_empty_p, 0);
- rb_define_method(rb_cHash,"each", rb_hash_each_pair, 0);
+ rb_define_method(rb_cHash,"each", rb_hash_each, 0);
rb_define_method(rb_cHash,"each_value", rb_hash_each_value, 0);
rb_define_method(rb_cHash,"each_key", rb_hash_each_key, 0);
rb_define_method(rb_cHash,"each_pair", rb_hash_each_pair, 0);
@@ -1471,16 +2473,20 @@ Init_Hash()
rb_define_method(rb_cHash,"keys", rb_hash_keys, 0);
rb_define_method(rb_cHash,"values", rb_hash_values, 0);
+ rb_define_method(rb_cHash,"values_at", rb_hash_values_at, -1);
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,"select", rb_hash_select, -1);
rb_define_method(rb_cHash,"reject", rb_hash_reject, 0);
rb_define_method(rb_cHash,"reject!", rb_hash_reject_bang, 0);
rb_define_method(rb_cHash,"clear", rb_hash_clear, 0);
rb_define_method(rb_cHash,"invert", rb_hash_invert, 0);
rb_define_method(rb_cHash,"update", rb_hash_update, 1);
rb_define_method(rb_cHash,"replace", rb_hash_replace, 1);
+ rb_define_method(rb_cHash,"merge!", rb_hash_update, 1);
+ rb_define_method(rb_cHash,"merge", rb_hash_merge, 1);
rb_define_method(rb_cHash,"include?", rb_hash_has_key, 1);
rb_define_method(rb_cHash,"member?", rb_hash_has_key, 1);
@@ -1496,20 +2502,26 @@ Init_Hash()
rb_define_singleton_method(envtbl,"[]", rb_f_getenv, 1);
rb_define_singleton_method(envtbl,"fetch", env_fetch, -1);
- rb_define_singleton_method(envtbl,"[]=", rb_f_setenv, 2);
- rb_define_singleton_method(envtbl,"store", rb_f_setenv, 2);
+ rb_define_singleton_method(envtbl,"[]=", env_aset, 2);
+ rb_define_singleton_method(envtbl,"store", env_aset, 2);
rb_define_singleton_method(envtbl,"each", env_each, 0);
- rb_define_singleton_method(envtbl,"each_pair", env_each, 0);
+ rb_define_singleton_method(envtbl,"each_pair", env_each_pair, 0);
rb_define_singleton_method(envtbl,"each_key", env_each_key, 0);
rb_define_singleton_method(envtbl,"each_value", env_each_value, 0);
rb_define_singleton_method(envtbl,"delete", env_delete_m, 1);
rb_define_singleton_method(envtbl,"delete_if", env_delete_if, 0);
+ rb_define_singleton_method(envtbl,"clear", env_clear, 0);
rb_define_singleton_method(envtbl,"reject", env_reject, 0);
rb_define_singleton_method(envtbl,"reject!", env_reject_bang, 0);
- rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
+ rb_define_singleton_method(envtbl,"select", env_select, -1);
+ rb_define_singleton_method(envtbl,"shift", env_shift, 0);
+ rb_define_singleton_method(envtbl,"invert", env_invert, 0);
+ rb_define_singleton_method(envtbl,"replace", env_replace, 1);
+ rb_define_singleton_method(envtbl,"update", env_update, 1);
rb_define_singleton_method(envtbl,"inspect", env_inspect, 0);
rb_define_singleton_method(envtbl,"rehash", env_none, 0);
rb_define_singleton_method(envtbl,"to_a", env_to_a, 0);
+ rb_define_singleton_method(envtbl,"to_s", env_to_s, 0);
rb_define_singleton_method(envtbl,"index", env_index, 1);
rb_define_singleton_method(envtbl,"indexes", env_indexes, -1);
rb_define_singleton_method(envtbl,"indices", env_indexes, -1);
@@ -1518,6 +2530,7 @@ Init_Hash()
rb_define_singleton_method(envtbl,"empty?", env_empty_p, 0);
rb_define_singleton_method(envtbl,"keys", env_keys, 0);
rb_define_singleton_method(envtbl,"values", env_values, 0);
+ rb_define_singleton_method(envtbl,"values_at", env_values_at, -1);
rb_define_singleton_method(envtbl,"include?", env_has_key, 1);
rb_define_singleton_method(envtbl,"member?", env_has_key, 1);
rb_define_singleton_method(envtbl,"has_key?", env_has_key, 1);
diff --git a/inits.c b/inits.c
index 7f0074e6ae..052573a443 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-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
**********************************************************************/
@@ -14,10 +14,12 @@
void Init_Array _((void));
void Init_Bignum _((void));
+void Init_Binding _((void));
void Init_Comparable _((void));
void Init_Dir _((void));
void Init_Enumerable _((void));
void Init_Exception _((void));
+void Init_syserr _((void));
void Init_eval _((void));
void Init_load _((void));
void Init_Proc _((void));
@@ -59,6 +61,7 @@ rb_call_inits()
Init_Thread();
Init_Numeric();
Init_Bignum();
+ Init_syserr();
Init_Array();
Init_Hash();
Init_Struct();
@@ -73,6 +76,7 @@ rb_call_inits()
Init_process();
Init_load();
Init_Proc();
+ Init_Binding();
Init_Math();
Init_GC();
Init_marshal();
diff --git a/instruby.rb b/instruby.rb
index 265b854eb4..a9d66c7670 100644
--- a/instruby.rb
+++ b/instruby.rb
@@ -3,100 +3,213 @@
load "./rbconfig.rb"
include Config
+$:.unshift File.join(CONFIG["srcdir"], "lib")
+require 'fileutils'
+require 'shellwords'
+require 'getopts'
+require 'tempfile'
+
File.umask(0)
-destdir = ARGV[0] || ''
-$:.unshift CONFIG["srcdir"]+"/lib"
-require "ftools"
-require "find"
+def parse_args()
+ getopts('n', 'dest-dir:',
+ 'make:', 'make-flags:', 'mflags:',
+ 'mantype:doc')
-exeext = CONFIG["EXEEXT"]
-if ENV["prefix"]
- prefix = ENV["prefix"]
-else
- prefix = CONFIG["prefix"]
-end
+ $dryrun = $OPT['n']
+ $destdir = $OPT['dest-dir'] || ''
+ $make = $OPT['make'] || $make || 'make'
+ $mantype = $OPT['mantype']
+ mflags = ($OPT['make-flags'] || '').strip
+ mflags = ($OPT['mflags'] || '').strip if mflags.empty?
-ruby_install_name = CONFIG["ruby_install_name"]
-version = "/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
-arch = "/"+CONFIG["arch"]
-
-bindir = destdir+CONFIG["bindir"]
-libdir = destdir+CONFIG["libdir"]
-rubylibdir = destdir+CONFIG["prefix"]+"/lib/ruby"+version
-archlibdir = rubylibdir+arch
-sitelibdir = destdir+CONFIG["sitedir"]+version
-sitearchlibdir = sitelibdir+arch
-mandir = destdir+CONFIG["mandir"] + "/man1"
-wdir = Dir.getwd
-
-File.makedirs bindir, true
-File.install ruby_install_name+exeext,
- "#{bindir}/#{ruby_install_name}#{exeext}", 0755, true
-rubyw = ruby_install_name.sub(/ruby/, '\&w')+exeext
-if File.exist? rubyw
- File.install rubyw, "#{bindir}/#{rubyw}", 0755, true
+ $mflags = Shellwords.shellwords(mflags)
+ if arg = $mflags.first
+ arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
+ end
+
+ $make, *rest = Shellwords.shellwords($make)
+ $mflags.unshift(*rest) unless rest.empty?
+
+ def $mflags.set?(flag)
+ grep(/\A-(?!-).*#{'%c' % flag}/i) { return true }
+ false
+ end
+
+ if $mflags.set?(?n)
+ $dryrun = true
+ else
+ $mflags << '-n' if $dryrun
+ end
+
+ $mflags << "DESTDIR=#{$destdir}"
+
+ $continue = $mflags.set?(?k)
end
-for dll in Dir['*.dll']
- File.install dll, "#{bindir}/#{dll}", 0755, true
+
+parse_args()
+
+include FileUtils::Verbose
+include FileUtils::NoWrite if $dryrun
+@fileutils_output = STDOUT
+@fileutils_label = ''
+
+def install(src, dest, options = {})
+ options[:preserve] = true
+ super
end
-File.makedirs libdir, true
-if CONFIG["LIBRUBY"] != CONFIG["LIBRUBY_A"]
- for lib in [CONFIG["LIBRUBY"]]
- if File.exist? lib
- File.install lib, libdir, 0555, true
+
+$made_dirs = {}
+def makedirs(dirs)
+ dirs = fu_list(dirs)
+ dirs.reject! do |dir|
+ $made_dirs.fetch(dir) do
+ $made_dirs[dir] = true
+ File.directory?(dir)
end
end
+ super(dirs, :mode => 0755, :verbose => true) unless dirs.empty?
end
-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
+
+def with_destdir(dir)
+ return dir if $destdir.empty?
+ dir = dir.sub(/\A\w:/, '') if File::PATH_SEPARATOR == ';'
+ $destdir + dir
end
-Dir.chdir wdir
-File.makedirs rubylibdir, true
-File.makedirs archlibdir, true
-File.makedirs sitelibdir, true
-File.makedirs sitearchlibdir, true
-
-if RUBY_PLATFORM =~ /-aix/
- File.install "ruby.imp", archlibdir, 0644, true
+
+exeext = CONFIG["EXEEXT"]
+
+ruby_install_name = CONFIG["ruby_install_name"]
+rubyw_install_name = CONFIG["rubyw_install_name"]
+
+version = CONFIG["ruby_version"]
+bindir = with_destdir(CONFIG["bindir"])
+libdir = with_destdir(CONFIG["libdir"])
+rubylibdir = with_destdir(CONFIG["rubylibdir"])
+archlibdir = with_destdir(CONFIG["archdir"])
+sitelibdir = with_destdir(CONFIG["sitelibdir"])
+sitearchlibdir = with_destdir(CONFIG["sitearchdir"])
+mandir = with_destdir(File.join(CONFIG["mandir"], "man"))
+configure_args = Shellwords.shellwords(CONFIG["configure_args"])
+enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
+dll = CONFIG["LIBRUBY_SO"]
+lib = CONFIG["LIBRUBY"]
+arc = CONFIG["LIBRUBY_A"]
+
+makedirs [bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir]
+
+ruby_bin = File.join(bindir, ruby_install_name)
+
+install ruby_install_name+exeext, ruby_bin+exeext, :mode => 0755
+if rubyw_install_name and !rubyw_install_name.empty?
+ install rubyw_install_name+exeext, bindir, :mode => 0755
+end
+install dll, bindir, :mode => 0755 if enable_shared and dll != lib
+install lib, libdir, :mode => 0755 unless lib == arc
+install arc, libdir, :mode => 0644
+install "config.h", archlibdir, :mode => 0644
+install "rbconfig.rb", archlibdir, :mode => 0644
+if CONFIG["ARCHFILE"]
+ for file in CONFIG["ARCHFILE"].split
+ install file, archlibdir, :mode => 0644
+ end
end
-Dir.chdir "ext"
-if defined? CROSS_COMPILING
- system "#{CONFIG['MINIRUBY']} extmk.rb install #{destdir}"
-else
- system "../miniruby#{exeext} extmk.rb install #{destdir}"
+if dll == lib and dll != arc
+ for link in CONFIG["LIBRUBY_ALIASES"].split
+ ln_sf(dll, File.join(libdir, link))
+ end
end
+
Dir.chdir CONFIG["srcdir"]
-File.install "sample/irb.rb", "#{bindir}/irb", 0755, true
+ruby_shebang = File.join(CONFIG["bindir"], ruby_install_name)
+if File::ALT_SEPARATOR
+ ruby_bin_dosish = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
+end
+for src in Dir["bin/*"]
+ next unless File.file?(src)
+ next if /\/[.#]|(\.(old|bak|orig|rej|diff|patch|core)|~|\/core)$/i =~ src
+
+ name = ruby_install_name.sub(/ruby/, File.basename(src))
+ dest = File.join(bindir, name)
-Find.find("lib") do |f|
- next unless /\.rb$/ =~ f
- dir = rubylibdir+"/"+File.dirname(f[4..-1])
- File.makedirs dir, true unless File.directory? dir
- File.install f, dir, 0644, true
+ install src, dest, :mode => 0755
+
+ next if $dryrun
+
+ shebang = ''
+ body = ''
+ open(dest, "r+") { |f|
+ shebang = f.gets
+ body = f.read
+
+ if shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang}
+ f.rewind
+ f.print shebang, body
+ f.truncate(f.pos)
+ end
+ }
+
+ if ruby_bin_dosish
+ batfile = File.join(CONFIG["bindir"], name + ".bat")
+ open(with_destdir(batfile), "w") { |b|
+ b.print <<EOH, shebang, body, <<EOF
+@echo off
+if not "%~d0" == "~d0" goto WinNT
+#{ruby_bin_dosish} -x "#{batfile}" %1 %2 %3 %4 %5 %6 %7 %8 %9
+goto endofruby
+:WinNT
+"%~dp0#{ruby_install_name}" -x "%~f0" %*
+goto endofruby
+EOH
+__END__
+:endofruby
+EOF
+ }
+ end
+end
+
+for f in Dir["lib/**/*{.rb,help-message}"]
+ dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
+ makedirs dir
+ install f, dir, :mode => 0644
end
for f in Dir["*.h"]
- File.install f, archlibdir, 0644, true
+ install f, archlibdir, :mode => 0644
+end
+
+if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/
+ makedirs File.join(archlibdir, "win32")
+ install "win32/win32.h", File.join(archlibdir, "win32"), :mode => 0644
end
-if RUBY_PLATFORM =~ /mswin32|mingw/
- File.makedirs archlibdir + "/win32", true
- File.install "win32/win32.h", archlibdir + "/win32", 0644, true
+
+for mdoc in Dir["*.[1-9]"]
+ next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'}
+
+ section = mdoc[-1,1]
+
+ destdir = mandir + section
+ destfile = File.join(destdir, mdoc.sub(/ruby/, ruby_install_name))
+
+ makedirs destdir
+
+ if $mantype == "doc"
+ install mdoc, destfile, :mode => 0644
+ else
+ require 'mdoc2man.rb'
+
+ w = Tempfile.open(mdoc)
+
+ open(mdoc) { |r|
+ Mdoc2Man.mdoc2man(r, w)
+ }
+
+ w.close
+
+ install w.path, destfile, :mode => 0644
+ end
end
-File.install wdir+'/'+CONFIG['LIBRUBY_A'], archlibdir, 0644, true
-File.makedirs mandir, true
-File.install "ruby.1", mandir+"/"+ruby_install_name+".1", 0644, true
-Dir.chdir wdir
-File.install "config.h", archlibdir, 0644, true
-File.install "rbconfig.rb", archlibdir, 0644, true
# vi:set sw=2:
diff --git a/intern.h b/intern.h
index 147fb605df..f97afade46 100644
--- a/intern.h
+++ b/intern.h
@@ -6,7 +6,7 @@
$Date$
created at: Thu Jun 10 14:22:17 JST 1993
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
@@ -17,16 +17,21 @@
* the kernel.
*/
+#define ID_ALLOCATOR 1
+
/* array.c */
void rb_mem_clear _((register VALUE*, register long));
VALUE rb_assoc_new _((VALUE, VALUE));
+VALUE rb_check_array_type _((VALUE));
VALUE rb_ary_new _((void));
VALUE rb_ary_new2 _((long));
VALUE rb_ary_new3 __((long,...));
-VALUE rb_ary_new4 _((long, VALUE *));
+VALUE rb_ary_new4 _((long, const VALUE *));
VALUE rb_ary_freeze _((VALUE));
VALUE rb_ary_aref _((int, VALUE*, VALUE));
void rb_ary_store _((VALUE, long, VALUE));
+VALUE rb_ary_dup _((VALUE));
+VALUE rb_ary_to_ary _((VALUE));
VALUE rb_ary_to_s _((VALUE));
VALUE rb_ary_push _((VALUE, VALUE));
VALUE rb_ary_pop _((VALUE));
@@ -47,8 +52,11 @@ VALUE rb_ary_concat _((VALUE, VALUE));
VALUE rb_ary_assoc _((VALUE, VALUE));
VALUE rb_ary_rassoc _((VALUE, VALUE));
VALUE rb_ary_includes _((VALUE, VALUE));
-VALUE rb_protect_inspect _((VALUE(*)(),VALUE,VALUE));
+VALUE rb_ary_cmp _((VALUE, VALUE));
+VALUE rb_protect_inspect _((VALUE(*)(ANYARGS),VALUE,VALUE));
VALUE rb_inspecting_p _((VALUE));
+VALUE rb_check_array_value _((VALUE));
+VALUE rb_values_at _((VALUE, long, int, VALUE*, VALUE(*) _((VALUE,long))));
/* bignum.c */
VALUE rb_big_clone _((VALUE));
void rb_big_2comp _((VALUE));
@@ -57,6 +65,8 @@ VALUE rb_uint2big _((unsigned long));
VALUE rb_int2big _((long));
VALUE rb_uint2inum _((unsigned long));
VALUE rb_int2inum _((long));
+VALUE rb_cstr_to_inum _((const char*, int, int));
+VALUE rb_str_to_inum _((VALUE, int, int));
VALUE rb_cstr2inum _((const char*, int));
VALUE rb_str2inum _((VALUE, int));
VALUE rb_big2str _((VALUE, int));
@@ -64,6 +74,14 @@ long rb_big2long _((VALUE));
#define rb_big2int(x) rb_big2long(x)
unsigned long rb_big2ulong _((VALUE));
#define rb_big2uint(x) rb_big2ulong(x)
+#if HAVE_LONG_LONG
+VALUE rb_ll2inum _((LONG_LONG));
+VALUE rb_ull2inum _((unsigned LONG_LONG));
+LONG_LONG rb_big2ll _((VALUE));
+unsigned LONG_LONG rb_big2ull _((VALUE));
+#endif /* HAVE_LONG_LONG */
+void rb_quad_pack _((char*,VALUE));
+VALUE rb_quad_unpack _((const char*,int));
VALUE rb_dbl2big _((double));
double rb_big2dbl _((VALUE));
VALUE rb_big_plus _((VALUE, VALUE));
@@ -75,50 +93,67 @@ VALUE rb_big_and _((VALUE, VALUE));
VALUE rb_big_or _((VALUE, VALUE));
VALUE rb_big_xor _((VALUE, VALUE));
VALUE rb_big_lshift _((VALUE, VALUE));
-VALUE rb_big_rand _((VALUE, double));
+VALUE rb_big_rand _((VALUE, double*));
/* class.c */
+VALUE rb_class_boot _((VALUE));
VALUE rb_class_new _((VALUE));
-VALUE rb_mod_clone _((VALUE));
-VALUE rb_mod_dup _((VALUE));
-VALUE rb_singleton_class_new _((VALUE));
+VALUE rb_mod_init_copy _((VALUE, VALUE));
+VALUE rb_class_init_copy _((VALUE, VALUE));
VALUE rb_singleton_class_clone _((VALUE));
void rb_singleton_class_attached _((VALUE,VALUE));
+VALUE rb_make_metaclass _((VALUE, VALUE));
+void rb_check_inheritable _((VALUE));
+VALUE rb_class_inherited _((VALUE, VALUE));
VALUE rb_define_class_id _((ID, VALUE));
VALUE rb_module_new _((void));
VALUE rb_define_module_id _((ID));
VALUE rb_mod_included_modules _((VALUE));
+VALUE rb_mod_include_p _((VALUE, VALUE));
VALUE rb_mod_ancestors _((VALUE));
VALUE rb_class_instance_methods _((int, VALUE*, VALUE));
+VALUE rb_class_public_instance_methods _((int, VALUE*, VALUE));
VALUE rb_class_protected_instance_methods _((int, VALUE*, VALUE));
VALUE rb_class_private_instance_methods _((int, VALUE*, VALUE));
-VALUE rb_obj_singleton_methods _((VALUE));
-void rb_define_method_id _((VALUE, ID, VALUE (*)(), int));
+VALUE rb_obj_singleton_methods _((int, VALUE*, VALUE));
+void rb_define_method_id _((VALUE, ID, VALUE (*)(ANYARGS), int));
void rb_frozen_class_p _((VALUE));
void rb_undef _((VALUE, ID));
-void rb_define_protected_method _((VALUE, const char*, VALUE (*)(), int));
-void rb_define_private_method _((VALUE, const char*, VALUE (*)(), int));
-void rb_define_singleton_method _((VALUE,const char*,VALUE(*)(),int));
-void rb_define_private_method _((VALUE,const char*,VALUE(*)(),int));
+void rb_define_protected_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
+void rb_define_private_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
+void rb_define_singleton_method _((VALUE, const char*, VALUE(*)(ANYARGS), int));
VALUE rb_singleton_class _((VALUE));
+/* compar.c */
+int rb_cmpint _((VALUE, VALUE, VALUE));
+NORETURN(void rb_cmperr _((VALUE, VALUE)));
/* enum.c */
-VALUE rb_enum_length _((VALUE));
/* error.c */
-EXTERN int ruby_nerrs;
+RUBY_EXTERN int ruby_nerrs;
VALUE rb_exc_new _((VALUE, const char*, long));
VALUE rb_exc_new2 _((VALUE, const char*));
VALUE rb_exc_new3 _((VALUE, VALUE));
-void rb_loaderror __((const char*, ...)) NORETURN;
+NORETURN(void rb_loaderror __((const char*, ...)));
+NORETURN(void rb_name_error __((ID, const char*, ...)));
+NORETURN(void rb_invalid_str _((const char*, const char*)));
void rb_compile_error __((const char*, ...));
void rb_compile_error_append __((const char*, ...));
-void rb_load_fail _((char*)) NORETURN;
-void rb_error_frozen _((char*)) NORETURN;
+NORETURN(void rb_load_fail _((const char*)));
+NORETURN(void rb_error_frozen _((const char*)));
+void rb_check_frozen _((VALUE));
/* eval.c */
-void rb_exc_raise _((VALUE)) NORETURN;
-void rb_exc_fatal _((VALUE)) NORETURN;
+RUBY_EXTERN struct RNode *ruby_current_node;
+void ruby_set_current_source _((void));
+NORETURN(void rb_exc_raise _((VALUE)));
+NORETURN(void rb_exc_fatal _((VALUE)));
+VALUE rb_f_exit _((int,VALUE*));
+VALUE rb_f_abort _((int,VALUE*));
void rb_remove_method _((VALUE, const char*));
-void rb_disable_super _((VALUE, const char*));
-void rb_enable_super _((VALUE, const char*));
+#define rb_disable_super(klass, name) ((void)0)
+#define rb_enable_super(klass, name) ((void)0)
+#define HAVE_RB_DEFINE_ALLOC_FUNC 1
+void rb_define_alloc_func _((VALUE, VALUE (*)(VALUE)));
+void rb_undef_alloc_func _((VALUE));
void rb_clear_cache _((void));
+void rb_clear_cache_by_class _((VALUE));
void rb_alias _((VALUE, ID, ID));
void rb_attr _((VALUE,ID,int,int,int));
int rb_method_boundp _((VALUE, ID, int));
@@ -127,28 +162,35 @@ VALUE rb_dvar_curr _((ID));
VALUE rb_dvar_ref _((ID));
void rb_dvar_asgn _((ID, VALUE));
void rb_dvar_push _((ID, VALUE));
-VALUE rb_eval_cmd _((VALUE, VALUE));
+VALUE *rb_svar _((int));
+VALUE rb_eval_cmd _((VALUE, VALUE, int));
int rb_respond_to _((VALUE, ID));
void rb_interrupt _((void));
VALUE rb_apply _((VALUE, ID, VALUE));
void rb_backtrace _((void));
ID rb_frame_last_func _((void));
VALUE rb_obj_instance_eval _((int, VALUE*, VALUE));
+VALUE rb_mod_module_eval _((int, VALUE*, VALUE));
void rb_load _((VALUE, int));
void rb_load_protect _((VALUE, int, int*));
-void rb_jump_tag _((int)) NORETURN;
+NORETURN(void rb_jump_tag _((int)));
int rb_provided _((const char*));
void rb_provide _((const char*));
VALUE rb_f_require _((VALUE, VALUE));
+VALUE rb_require_safe _((VALUE, int));
void rb_obj_call_init _((VALUE, int, VALUE*));
VALUE rb_class_new_instance _((int, VALUE*, VALUE));
+VALUE rb_block_proc _((void));
VALUE rb_f_lambda _((void));
-VALUE rb_protect _((VALUE (*)(), VALUE, int*));
-void rb_set_end_proc _((void (*)(), VALUE));
+VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
+VALUE rb_protect _((VALUE (*)(VALUE), VALUE, int*));
+void rb_set_end_proc _((void (*)(VALUE), VALUE));
void rb_mark_end_proc _((void));
void rb_exec_end_proc _((void));
void ruby_finalize _((void));
-void ruby_stop _((int));
+NORETURN(void ruby_stop _((int)));
+int ruby_cleanup _((int));
+int ruby_exec _((void));
void rb_gc_mark_threads _((void));
void rb_thread_start_timer _((void));
void rb_thread_stop_timer _((void));
@@ -163,13 +205,13 @@ void rb_thread_sleep_forever _((void));
VALUE rb_thread_stop _((void));
VALUE rb_thread_wakeup _((VALUE));
VALUE rb_thread_run _((VALUE));
-VALUE rb_thread_create _((VALUE (*)(), void*));
-int rb_thread_scope_shared_p _((void));
+VALUE rb_thread_kill _((VALUE));
+VALUE rb_thread_create _((VALUE (*)(ANYARGS), void*));
void rb_thread_interrupt _((void));
-void rb_thread_trap_eval _((VALUE, int));
+void rb_thread_trap_eval _((VALUE, int, int));
void rb_thread_signal_raise _((char*));
-int rb_thread_select();
-void rb_thread_wait_for();
+int rb_thread_select _((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+void rb_thread_wait_for _((struct timeval));
VALUE rb_thread_current _((void));
VALUE rb_thread_main _((void));
VALUE rb_thread_local_aref _((VALUE, ID));
@@ -179,31 +221,49 @@ void rb_thread_atfork _((void));
int eaccess _((const char*, int));
VALUE rb_file_s_expand_path _((int, VALUE *));
void rb_file_const _((const char*, VALUE));
-char *rb_find_file _((char*));
+int rb_find_file_ext _((VALUE*, const char* const*));
+VALUE rb_find_file _((VALUE));
+char *rb_path_next _((const char *));
+char *rb_path_skip_prefix _((const char *));
+char *rb_path_last_separator _((const char *));
+char *rb_path_end _((const char *));
/* gc.c */
+NORETURN(void rb_memerror __((void)));
+int ruby_stack_check _((void));
+int ruby_stack_length _((VALUE**));
+char *rb_source_filename _((const char*));
void rb_gc_mark_locations _((VALUE*, VALUE*));
void rb_mark_tbl _((struct st_table*));
void rb_mark_hash _((struct st_table*));
-void rb_gc_mark_maybe();
-void rb_gc_mark();
+void rb_gc_mark_maybe _((VALUE));
+void rb_gc_mark _((VALUE));
void rb_gc_force_recycle _((VALUE));
void rb_gc _((void));
+void rb_gc_copy_finalizer _((VALUE,VALUE));
+void rb_gc_finalize_deferred _((void));
void rb_gc_call_finalizer_at_exit _((void));
+VALUE rb_gc_enable _((void));
+VALUE rb_gc_disable _((void));
+VALUE rb_gc_start _((void));
/* hash.c */
+void st_foreach _((struct st_table *, int (*)(), unsigned long));
+void rb_hash_foreach _((VALUE, int (*)(), VALUE));
VALUE rb_hash _((VALUE));
VALUE rb_hash_new _((void));
VALUE rb_hash_freeze _((VALUE));
VALUE rb_hash_aref _((VALUE, VALUE));
VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
VALUE rb_hash_delete_if _((VALUE));
-int rb_path_check _((char *));
+VALUE rb_hash_delete _((VALUE,VALUE));
+int rb_path_check _((char*));
int rb_env_path_tainted _((void));
/* io.c */
-EXTERN VALUE rb_fs;
-EXTERN VALUE rb_output_fs;
-EXTERN VALUE rb_rs;
-EXTERN VALUE rb_default_rs;
-EXTERN VALUE rb_output_rs;
+#define rb_defout rb_stdout
+RUBY_EXTERN VALUE rb_fs;
+RUBY_EXTERN VALUE rb_output_fs;
+RUBY_EXTERN VALUE rb_rs;
+RUBY_EXTERN VALUE rb_default_rs;
+RUBY_EXTERN VALUE rb_output_rs;
VALUE rb_io_write _((VALUE, VALUE));
VALUE rb_io_gets _((VALUE));
VALUE rb_io_getc _((VALUE));
@@ -211,15 +271,26 @@ VALUE rb_io_ungetc _((VALUE, VALUE));
VALUE rb_io_close _((VALUE));
VALUE rb_io_eof _((VALUE));
VALUE rb_io_binmode _((VALUE));
+VALUE rb_io_addstr _((VALUE, VALUE));
+VALUE rb_io_printf _((int, VALUE*, VALUE));
+VALUE rb_io_print _((int, VALUE*, VALUE));
+VALUE rb_io_puts _((int, VALUE*, VALUE));
VALUE rb_file_open _((const char*, const char*));
VALUE rb_gets _((void));
+void rb_write_error _((const char*));
+void rb_write_error2 _((const char*, long));
+/* marshal.c */
+VALUE rb_marshal_dump _((VALUE, VALUE));
+VALUE rb_marshal_load _((VALUE));
/* numeric.c */
void rb_num_zerodiv _((void));
VALUE rb_num_coerce_bin _((VALUE, VALUE));
+VALUE rb_num_coerce_cmp _((VALUE, VALUE));
+VALUE rb_num_coerce_relop _((VALUE, VALUE));
VALUE rb_float_new _((double));
VALUE rb_num2fix _((VALUE));
VALUE rb_fix2str _((VALUE, int));
-VALUE rb_fix_upto _((VALUE, VALUE));
+VALUE rb_dbl_cmp _((double, double));
/* object.c */
int rb_eql _((VALUE, VALUE));
VALUE rb_any_to_s _((VALUE));
@@ -229,46 +300,58 @@ VALUE rb_obj_is_kind_of _((VALUE, VALUE));
VALUE rb_obj_alloc _((VALUE));
VALUE rb_obj_clone _((VALUE));
VALUE rb_obj_dup _((VALUE));
+VALUE rb_obj_init_copy _((VALUE,VALUE));
VALUE rb_obj_taint _((VALUE));
VALUE rb_obj_tainted _((VALUE));
VALUE rb_obj_untaint _((VALUE));
VALUE rb_obj_freeze _((VALUE));
VALUE rb_obj_id _((VALUE));
+VALUE rb_obj_class _((VALUE));
+VALUE rb_class_real _((VALUE));
+VALUE rb_class_inherited_p _((VALUE, VALUE));
VALUE rb_convert_type _((VALUE,int,const char*,const char*));
+VALUE rb_check_convert_type _((VALUE,int,const char*,const char*));
VALUE rb_to_int _((VALUE));
VALUE rb_Integer _((VALUE));
VALUE rb_Float _((VALUE));
VALUE rb_String _((VALUE));
VALUE rb_Array _((VALUE));
+double rb_cstr_to_dbl _((const char*, int));
+double rb_str_to_dbl _((VALUE, int));
/* parse.y */
-EXTERN int ruby_sourceline;
-EXTERN char *ruby_sourcefile;
-#define yyparse rb_yyparse
-#define yylex rb_yylex
-#define yyerror rb_yyerror
-#define yylval rb_yylval
-#define yychar rb_yychar
-#define yydebug rb_yydebug
-int yyparse _((void));
+RUBY_EXTERN int ruby_sourceline;
+RUBY_EXTERN char *ruby_sourcefile;
+int ruby_yyparse _((void));
ID rb_id_attrset _((ID));
void rb_parser_append_print _((void));
void rb_parser_while_loop _((int, int));
+int ruby_parser_stack_on_heap _((void));
+void rb_gc_mark_parser _((void));
int rb_is_const_id _((ID));
int rb_is_instance_id _((ID));
int rb_is_class_id _((ID));
+int rb_is_local_id _((ID));
+int rb_is_junk_id _((ID));
VALUE rb_backref_get _((void));
void rb_backref_set _((VALUE));
VALUE rb_lastline_get _((void));
void rb_lastline_set _((VALUE));
+VALUE rb_sym_all_symbols _((void));
/* process.c */
int rb_proc_exec _((const char*));
+VALUE rb_f_exec _((int,VALUE*));
+int rb_waitpid _((int,int*,int));
void rb_syswait _((int));
+VALUE rb_proc_times _((VALUE));
+VALUE rb_detach_process _((int));
/* range.c */
VALUE rb_range_new _((VALUE, VALUE, int));
VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
VALUE rb_length_by_each _((VALUE));
/* re.c */
int rb_memcmp _((char*,char*,long));
+int rb_memcicmp _((char*,char*,long));
+long rb_memsearch _((char*,long,char*,long));
VALUE rb_reg_nth_defined _((int, VALUE));
VALUE rb_reg_nth_match _((int, VALUE));
VALUE rb_reg_last_match _((VALUE));
@@ -282,10 +365,10 @@ int rb_reg_options _((VALUE));
void rb_set_kcode _((const char*));
const char* rb_get_kcode _((void));
/* ruby.c */
-EXTERN VALUE rb_argv;
-EXTERN VALUE rb_argv0;
-void rb_load_file _((char*));
-void ruby_script _((char*));
+RUBY_EXTERN VALUE rb_argv;
+RUBY_EXTERN VALUE rb_argv0;
+void rb_load_file _((const char*));
+void ruby_script _((const char*));
void ruby_prog_init _((void));
void ruby_set_argv _((int, char**));
void ruby_process_options _((int, char**));
@@ -297,10 +380,11 @@ VALUE rb_f_kill _((int, VALUE*));
void rb_gc_mark_trap_list _((void));
#ifdef POSIX_SIGNAL
#define posix_signal ruby_posix_signal
-void posix_signal _((int, void (*)()));
+void posix_signal _((int, RETSIGTYPE (*)(int)));
#endif
void rb_trap_exit _((void));
void rb_trap_exec _((void));
+const char *ruby_signal_name _((int));
/* sprintf.c */
VALUE rb_f_sprintf _((int, VALUE*));
/* string.c */
@@ -308,11 +392,20 @@ VALUE rb_str_new _((const char*, long));
VALUE rb_str_new2 _((const char*));
VALUE rb_str_new3 _((VALUE));
VALUE rb_str_new4 _((VALUE));
+VALUE rb_str_new5 _((VALUE, const char*, long));
VALUE rb_tainted_str_new _((const char*, long));
VALUE rb_tainted_str_new2 _((const char*));
+VALUE rb_str_buf_new _((long));
+VALUE rb_str_buf_new2 _((const char*));
+VALUE rb_str_buf_append _((VALUE, VALUE));
+VALUE rb_str_buf_cat _((VALUE, const char*, long));
+VALUE rb_str_buf_cat2 _((VALUE, const char*));
VALUE rb_obj_as_string _((VALUE));
-VALUE rb_str_to_str _((VALUE));
+VALUE rb_check_string_type _((VALUE));
VALUE rb_str_dup _((VALUE));
+VALUE rb_str_locktmp _((VALUE));
+VALUE rb_str_unlocktmp _((VALUE));
+VALUE rb_str_dup_frozen _((VALUE));
VALUE rb_str_plus _((VALUE, VALUE));
VALUE rb_str_times _((VALUE, VALUE));
VALUE rb_str_substr _((VALUE, long, long));
@@ -326,10 +419,14 @@ VALUE rb_str_concat _((VALUE, VALUE));
int rb_str_hash _((VALUE));
int rb_str_cmp _((VALUE, VALUE));
VALUE rb_str_upto _((VALUE, VALUE, int));
+void rb_str_update _((VALUE, long, long, VALUE));
VALUE rb_str_inspect _((VALUE));
+VALUE rb_str_dump _((VALUE));
VALUE rb_str_split _((VALUE, const char*));
void rb_str_associate _((VALUE, VALUE));
+VALUE rb_str_associated _((VALUE));
void rb_str_setter _((VALUE, ID, VALUE*));
+VALUE rb_str_intern _((VALUE));
/* struct.c */
VALUE rb_struct_new __((VALUE, ...));
VALUE rb_struct_define __((const char*, ...));
@@ -337,49 +434,60 @@ 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));
+VALUE rb_struct_iv_get _((VALUE, char*));
+VALUE rb_struct_s_members _((VALUE));
+VALUE rb_struct_members _((VALUE));
/* time.c */
-VALUE rb_time_new();
+VALUE rb_time_new _((time_t, time_t));
/* variable.c */
VALUE rb_mod_name _((VALUE));
VALUE rb_class_path _((VALUE));
void rb_set_class_path _((VALUE, VALUE, const char*));
VALUE rb_path2class _((const char*));
void rb_name_class _((VALUE, ID));
-void rb_autoload _((const char*, const char*));
-VALUE rb_f_autoload _((VALUE, VALUE, VALUE));
+VALUE rb_class_name _((VALUE));
+void rb_autoload _((VALUE, ID, const char*));
+void rb_autoload_load _((VALUE, ID));
+VALUE rb_autoload_p _((VALUE, ID));
void rb_gc_mark_global_tbl _((void));
VALUE rb_f_trace_var _((int, VALUE*));
VALUE rb_f_untrace_var _((int, VALUE*));
VALUE rb_f_global_variables _((void));
void rb_alias_variable _((ID, ID));
struct st_table* rb_generic_ivar_table _((VALUE));
-void rb_clone_generic_ivar _((VALUE,VALUE));
+void rb_copy_generic_ivar _((VALUE,VALUE));
void rb_mark_generic_ivar _((VALUE));
void rb_mark_generic_ivar_tbl _((void));
void rb_free_generic_ivar _((VALUE));
VALUE rb_ivar_get _((VALUE, ID));
VALUE rb_ivar_set _((VALUE, ID, VALUE));
VALUE rb_ivar_defined _((VALUE, ID));
+VALUE rb_iv_set _((VALUE, const char*, VALUE));
+VALUE rb_iv_get _((VALUE, const char*));
+VALUE rb_attr_get _((VALUE, ID));
VALUE rb_obj_instance_variables _((VALUE));
VALUE rb_obj_remove_instance_variable _((VALUE, VALUE));
-VALUE rb_mod_const_at _((VALUE, VALUE));
+void *rb_mod_const_at _((VALUE, void*));
+void *rb_mod_const_of _((VALUE, void*));
+VALUE rb_const_list _((void*));
VALUE rb_mod_constants _((VALUE));
-VALUE rb_mod_const_of _((VALUE, VALUE));
VALUE rb_mod_remove_const _((VALUE, VALUE));
-int rb_const_defined_at _((VALUE, ID));
-int rb_autoload_defined _((ID));
int rb_const_defined _((VALUE, ID));
+int rb_const_defined_at _((VALUE, ID));
+int rb_const_defined_from _((VALUE, ID));
VALUE rb_const_get _((VALUE, ID));
VALUE rb_const_get_at _((VALUE, ID));
+VALUE rb_const_get_from _((VALUE, ID));
void rb_const_set _((VALUE, ID, VALUE));
-void rb_const_assign _((VALUE, ID, VALUE));
VALUE rb_mod_constants _((VALUE));
-void rb_autoload_load _((ID));
-void rb_cvar_declare _((VALUE, ID, VALUE));
+VALUE rb_mod_const_missing _((VALUE,VALUE));
VALUE rb_cvar_defined _((VALUE, ID));
-void rb_cvar_set _((VALUE, ID, VALUE));
+#define RB_CVAR_SET_4ARGS 1
+void rb_cvar_set _((VALUE, ID, VALUE, int));
VALUE rb_cvar_get _((VALUE, ID));
-VALUE rb_cvar_singleton _((VALUE));
+void rb_cv_set _((VALUE, const char*, VALUE));
+VALUE rb_cv_get _((VALUE, const char*));
+void rb_define_class_variable _((VALUE, const char*, VALUE));
VALUE rb_mod_class_variables _((VALUE));
VALUE rb_mod_remove_cvar _((VALUE, VALUE));
/* version.c */
diff --git a/io.c b/io.c
index 79118b073a..195392e565 100644
--- a/io.c
+++ b/io.c
@@ -6,12 +6,17 @@
$Date$
created at: Fri Oct 15 18:08:59 JST 1993
- Copyright (C) 1993-2000 Yukihiro Matsumoto
+ Copyright (C) 1993-2003 Yukihiro Matsumoto
Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
Copyright (C) 2000 Information-technology Promotion Agency, Japan
**********************************************************************/
+#if defined(__VMS)
+#define _XOPEN_SOURCE
+#define _POSIX_C_SOURCE 2
+#endif
+
#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
@@ -19,48 +24,50 @@
#include <ctype.h>
#include <errno.h>
-#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(NT) || defined(__human68k__) || defined(__EMX__) || defined(__BEOS__)
+#if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__) || defined(__BEOS__)
# define NO_SAFE_RENAME
#endif
-#if defined(MSDOS) || defined(__CYGWIN__) || defined(NT)
+#if defined(MSDOS) || defined(__CYGWIN__) || defined(_WIN32)
# define NO_LONG_FNAME
#endif
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(sun)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(sun) || defined(_nec_ews)
# define USE_SETVBUF
#endif
+#ifdef __QNXNTO__
+#include "unix.h"
+#endif
+
#include <sys/types.h>
-#if !defined(DJGPP) && !defined(NT) && !defined(__human68k__)
+#if !defined(DJGPP) && !defined(_WIN32) && !defined(__human68k__)
#include <sys/ioctl.h>
#endif
-#if defined(HAVE_FCNTL_H) || defined(NT)
+#if defined(HAVE_FCNTL_H) || defined(_WIN32)
#include <fcntl.h>
#elif defined(HAVE_SYS_FCNTL_H)
#include <sys/fcntl.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#else
-#ifndef NT
-struct timeval {
- long tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
-};
+#if !HAVE_OFF_T && !defined(off_t)
+# define off_t long
#endif
+#if !HAVE_FSEEKO && !defined(fseeko)
+# define fseeko fseek
#endif
-#ifdef HAVE_VFORK_H
-#include <vfork.h>
+#if !HAVE_FTELLO && !defined(ftello)
+# define ftello ftell
#endif
#include <sys/stat.h>
-/* EMX has sys/parm.h, but.. */
-#if defined(HAVE_SYS_PARAM_H) && !defined(__EMX__)
+/* EMX has sys/param.h, but.. */
+#if defined(HAVE_SYS_PARAM_H) && !(defined(__EMX__) || defined(__HIUX_MPP__))
# include <sys/param.h>
-#else
+#endif
+
+#if !defined NOFILE
# define NOFILE 64
#endif
@@ -79,12 +86,17 @@ extern void Init_File _((void));
#include "util.h"
+#if SIZEOF_OFF_T > SIZEOF_LONG && !defined(HAVE_LONG_LONG)
+# error off_t is bigger than long, but you have no long long...
+#endif
+
VALUE rb_cIO;
VALUE rb_eEOFError;
VALUE rb_eIOError;
-VALUE rb_stdin, rb_stdout, rb_stderr, rb_defout;
-static VALUE orig_stdin, orig_stdout, orig_stderr;
+VALUE rb_stdin, rb_stdout, rb_stderr;
+VALUE rb_deferr; /* rescue VIM plugin */
+static VALUE orig_stdout, orig_stderr;
VALUE rb_output_fs;
VALUE rb_rs;
@@ -93,7 +105,7 @@ VALUE rb_default_rs;
static VALUE argf;
-static ID id_write;
+static ID id_write, id_read, id_getc;
extern char *ruby_inplace_mode;
@@ -101,23 +113,50 @@ struct timeval rb_time_interval _((VALUE));
static VALUE filename, current_file;
static int gets_lineno;
-static int init_p = 0, next_p = 0, first_p = 1;
-static VALUE lineno;
+static int init_p = 0, next_p = 0;
+static VALUE lineno = INT2FIX(0);
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
# ifdef _IO_fpos_t
# define READ_DATA_PENDING(fp) ((fp)->_IO_read_ptr != (fp)->_IO_read_end)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->_IO_read_end - (fp)->_IO_read_ptr)
+# define READ_DATA_PENDING_PTR(fp) ((fp)->_IO_read_ptr)
# else
# define READ_DATA_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->_egptr - (fp)->_gptr)
+# define READ_DATA_PENDING_PTR(fp) ((fp)->_gptr)
# endif
#elif defined(FILE_COUNT)
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_COUNT)
+#elif defined(FILE_READEND)
+# define READ_DATA_PENDING(fp) ((fp)->FILE_READPTR < (fp)->FILE_READEND)
+# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_READEND - (fp)->FILE_READPTR)
#elif defined(__BEOS__)
# define READ_DATA_PENDING(fp) (fp->_state._eof == 0)
+#elif defined(__VMS)
+# define READ_DATA_PENDING_COUNT(fp) ((unsigned int)(*(fp))->_cnt)
+# define READ_DATA_PENDING(fp) (((unsigned int)(*(fp))->_cnt) > 0)
+# define READ_DATA_BUFFERED(fp) 0
#else
/* requires systems own version of the ReadDataPending() */
extern int ReadDataPending();
-# define READ_DATA_PENDING(fp) ReadDataPending(fp)
+# define READ_DATA_PENDING(fp) (!feof(fp))
+# define READ_DATA_BUFFERED(fp) 0
+#endif
+#ifndef READ_DATA_BUFFERED
+# define READ_DATA_BUFFERED(fp) READ_DATA_PENDING(fp)
+#endif
+
+#ifndef READ_DATA_PENDING_PTR
+# ifdef FILE_READPTR
+# define READ_DATA_PENDING_PTR(fp) ((char *)(fp)->FILE_READPTR)
+# endif
+#endif
+
+#if defined __DJGPP__
+# undef READ_DATA_PENDING_COUNT
+# undef READ_DATA_PENDING_PTR
#endif
#define READ_CHECK(fp) do {\
@@ -139,37 +178,87 @@ rb_io_taint_check(io)
{
if (!OBJ_TAINTED(io) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
+ rb_check_frozen(io);
return io;
}
void
-rb_io_check_closed(fptr)
+rb_io_check_initialized(fptr)
OpenFile *fptr;
{
if (!fptr) {
rb_raise(rb_eIOError, "uninitialized stream");
}
+}
+
+void
+rb_io_check_closed(fptr)
+ OpenFile *fptr;
+{
+ rb_io_check_initialized(fptr);
if (!fptr->f && !fptr->f2) {
rb_raise(rb_eIOError, "closed stream");
}
}
+static void io_fflush _((FILE *, OpenFile *));
+
+static OpenFile *
+flush_before_seek(fptr)
+ OpenFile *fptr;
+{
+ if (fptr->mode & FMODE_WBUF) {
+ io_fflush(GetWriteFile(fptr), fptr);
+ }
+ return fptr;
+}
+
+#define io_seek(fptr, ofs, whence) fseeko(flush_before_seek(fptr)->f, ofs, whence)
+#define io_tell(fptr) ftello(flush_before_seek(fptr)->f)
+
+#ifndef SEEK_CUR
+# define SEEK_SET 0
+# define SEEK_CUR 1
+# define SEEK_END 2
+#endif
+
+#define FMODE_SYNCWRITE (FMODE_SYNC|FMODE_WRITABLE)
+
void
rb_io_check_readable(fptr)
OpenFile *fptr;
{
+ rb_io_check_closed(fptr);
if (!(fptr->mode & FMODE_READABLE)) {
rb_raise(rb_eIOError, "not opened for reading");
}
+#if NEED_IO_SEEK_BETWEEN_RW
+ if (((fptr->mode & FMODE_WBUF) ||
+ (fptr->mode & (FMODE_SYNCWRITE|FMODE_RBUF)) == FMODE_SYNCWRITE) &&
+ !feof(fptr->f) &&
+ !fptr->f2) {
+ io_seek(fptr, 0, SEEK_CUR);
+ }
+#endif
+ fptr->mode |= FMODE_RBUF;
}
void
rb_io_check_writable(fptr)
OpenFile *fptr;
{
+ rb_io_check_closed(fptr);
if (!(fptr->mode & FMODE_WRITABLE)) {
rb_raise(rb_eIOError, "not opened for writing");
}
+#if NEED_IO_SEEK_BETWEEN_RW
+ if ((fptr->mode & FMODE_RBUF) && !feof(fptr->f) && !fptr->f2) {
+ io_seek(fptr, 0, SEEK_CUR);
+ }
+#endif
+ if (!fptr->f2) {
+ fptr->mode &= ~FMODE_RBUF;
+ }
}
int
@@ -189,7 +278,7 @@ rb_read_check(fp)
}
static int
-rb_dup(orig)
+ruby_dup(orig)
int orig;
{
int fd;
@@ -207,65 +296,184 @@ rb_dup(orig)
return fd;
}
+static VALUE io_alloc _((VALUE));
+static VALUE
+io_alloc(klass)
+ VALUE klass;
+{
+ NEWOBJ(io, struct RFile);
+ OBJSETUP(io, klass, T_FILE);
+
+ io->fptr = 0;
+
+ return (VALUE)io;
+}
+
static void
-io_fflush(f, path)
+io_fflush(f, fptr)
FILE *f;
- const char *path;
+ OpenFile *fptr;
{
int n;
- rb_thread_fd_writable(fileno(f));
- TRAP_BEG;
- n = fflush(f);
- TRAP_END;
- if (n == EOF) rb_sys_fail(path);
+ if (!rb_thread_fd_writable(fileno(f))) {
+ rb_io_check_closed(fptr);
+ }
+ for (;;) {
+ n = fflush(f);
+ if (n != EOF) break;
+ if (!rb_io_wait_writable(fileno(f)))
+ rb_sys_fail(fptr->path);
+ }
+ fptr->mode &= ~FMODE_WBUF;
+}
+
+int
+rb_io_wait_readable(f)
+ int f;
+{
+ fd_set rfds;
+
+ switch (errno) {
+ case EINTR:
+#if defined(ERESTART)
+ case ERESTART:
+#endif
+ rb_thread_wait_fd(f);
+ return Qtrue;
+
+ case EAGAIN:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ FD_ZERO(&rfds);
+ FD_SET(f, &rfds);
+ rb_thread_select(f + 1, &rfds, NULL, NULL, NULL);
+ return Qtrue;
+
+ default:
+ return Qfalse;
+ }
+}
+
+int
+rb_io_wait_writable(f)
+ int f;
+{
+ fd_set wfds;
+
+ switch (errno) {
+ case EINTR:
+#if defined(ERESTART)
+ case ERESTART:
+#endif
+ rb_thread_fd_writable(f);
+ return Qtrue;
+
+ case EAGAIN:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ FD_ZERO(&wfds);
+ FD_SET(f, &wfds);
+ rb_thread_select(f + 1, NULL, &wfds, NULL, NULL);
+ return Qtrue;
+
+ default:
+ return Qfalse;
+ }
}
/* writing functions */
+long
+rb_io_fwrite(ptr, len, f)
+ const char *ptr;
+ long len;
+ FILE *f;
+{
+ long n, r;
+
+ if ((n = len) <= 0) return n;
+#if defined(__human68k__) || defined(__vms)
+ do {
+ if (fputc(*ptr++, f) == EOF) {
+ if (ferror(f)) return -1L;
+ break;
+ }
+ } while (--n > 0);
+#else
+ while (errno = 0, ptr += (r = fwrite(ptr, 1, n, f)), (n -= r) > 0) {
+ if (ferror(f)
+#if defined __BORLANDC__
+ || errno
+#endif
+ ) {
+#ifdef __hpux
+ if (!errno) errno = EAGAIN;
+#endif
+ if (rb_io_wait_writable(fileno(f))) {
+ clearerr(f);
+ continue;
+ }
+ return -1L;
+ }
+ }
+#endif
+ return len - n;
+}
+
+/*
+ * call-seq:
+ * ios.write(string) => integer
+ *
+ * Writes the given string to <em>ios</em>. The stream must be opened
+ * for writing. If the argument is not a string, it will be converted
+ * to a string using <code>to_s</code>. Returns the number of bytes
+ * written.
+ *
+ * count = $stdout.write( "This is a test\n" )
+ * puts "That was #{count} bytes of data"
+ *
+ * <em>produces:</em>
+ *
+ * This is a test
+ * That was 15 bytes of data
+ */
+
static VALUE
io_write(io, str)
VALUE io, str;
{
OpenFile *fptr;
FILE *f;
- int n;
+ long n;
rb_secure(4);
if (TYPE(str) != T_STRING)
str = rb_obj_as_string(str);
- if (RSTRING(str)->len == 0) return INT2FIX(0);
if (TYPE(io) != T_FILE) {
/* port is not IO, call write method for it. */
return rb_funcall(io, id_write, 1, str);
}
+ if (RSTRING(str)->len == 0) return INT2FIX(0);
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
-#ifdef __human68k__
- {
- register char *ptr = RSTRING(str)->ptr;
- n = (int)RSTRING(str)->len;
- while (--n >= 0)
- if (fputc(*ptr++, f) == EOF)
- rb_sys_fail(fptr->path);
- n = ptr - RSTRING(str)->ptr;
- }
- if (ferror(f))
- rb_sys_fail(fptr->path);
-#else
- n = fwrite(RSTRING(str)->ptr, 1, RSTRING(str)->len, f);
- if (ferror(f)) {
- rb_sys_fail(fptr->path);
- }
-#endif
+ rb_str_locktmp(str);
+ n = rb_io_fwrite(RSTRING(str)->ptr, RSTRING(str)->len, f);
+ rb_str_unlocktmp(str);
+ if (n == -1L) rb_sys_fail(fptr->path);
if (fptr->mode & FMODE_SYNC) {
- io_fflush(f, fptr->path);
+ io_fflush(f, fptr);
+ }
+ else {
+ fptr->mode |= FMODE_WBUF;
}
- return INT2FIX(n);
+ return LONG2FIX(n);
}
VALUE
@@ -275,7 +483,22 @@ rb_io_write(io, str)
return rb_funcall(io, id_write, 1, str);
}
-static VALUE
+/*
+ * call-seq:
+ * ios << obj => ios
+ *
+ * String Output---Writes <i>obj</i> to <em>ios</em>.
+ * <i>obj</i> will be converted to a string using
+ * <code>to_s</code>.
+ *
+ * $stdout << "Hello " << "world!\n"
+ *
+ * <em>produces:</em>
+ *
+ * Hello world!
+ */
+
+VALUE
rb_io_addstr(io, str)
VALUE io, str;
{
@@ -283,6 +506,22 @@ rb_io_addstr(io, str)
return io;
}
+/*
+ * call-seq:
+ * ios.flush => ios
+ *
+ * Flushes any buffered data within <em>ios</em> to the underlying
+ * operating system (note that this is Ruby internal buffering only;
+ * the OS may buffer the data as well).
+ *
+ * $stdout.print "no newline"
+ * $stdout.flush
+ *
+ * <em>produces:</em>
+ *
+ * no newline
+ */
+
static VALUE
rb_io_flush(io)
VALUE io;
@@ -293,78 +532,139 @@ rb_io_flush(io)
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
-
- io_fflush(f, fptr->path);
+
+ io_fflush(f, fptr);
return io;
}
+/*
+ * call-seq:
+ * ios.pos => integer
+ * ios.tell => integer
+ *
+ * Returns the current offset (in bytes) of <em>ios</em>.
+ *
+ * f = File.new("testfile")
+ * f.pos #=> 0
+ * f.gets #=> "This is line one\n"
+ * f.pos #=> 17
+ */
+
static VALUE
rb_io_tell(io)
VALUE io;
{
OpenFile *fptr;
- long pos;
+ off_t pos;
GetOpenFile(io, fptr);
- pos = ftell(fptr->f);
- if (ferror(fptr->f)) rb_sys_fail(fptr->path);
+ pos = io_tell(fptr);
+ if (pos < 0) rb_sys_fail(fptr->path);
+ return OFFT2NUM(pos);
+}
- return rb_int2inum(pos);
+static VALUE
+rb_io_seek(io, offset, whence)
+ VALUE io, offset;
+ int whence;
+{
+ OpenFile *fptr;
+ off_t pos;
+
+ GetOpenFile(io, fptr);
+ pos = io_seek(fptr, NUM2OFFT(offset), whence);
+ if (pos < 0) rb_sys_fail(fptr->path);
+ clearerr(fptr->f);
+
+ return INT2FIX(0);
}
-#ifndef SEEK_CUR
-# define SEEK_SET 0
-# define SEEK_CUR 1
-# define SEEK_END 2
-#endif
+/*
+ * call-seq:
+ * ios.seek(amount, whence=SEEK_SET) -> 0
+ *
+ * Seeks to a given offset <i>anInteger</i> in the stream according to
+ * the value of <i>whence</i>:
+ *
+ * IO::SEEK_CUR | Seeks to _amount_ plus current position
+ * --------------+----------------------------------------------------
+ * IO::SEEK_END | Seeks to _amount_ plus end of stream (you probably
+ * | want a negative value for _amount_)
+ * --------------+----------------------------------------------------
+ * IO::SEEK_SET | Seeks to the absolute location given by _amount_
+ *
+ * Example:
+ *
+ * f = File.new("testfile")
+ * f.seek(-13, IO::SEEK_END) #=> 0
+ * f.readline #=> "And so on...\n"
+ */
static VALUE
-rb_io_seek(argc, argv, io)
+rb_io_seek_m(argc, argv, io)
int argc;
VALUE *argv;
VALUE io;
{
VALUE offset, ptrname;
- int whence;
- OpenFile *fptr;
- long pos;
+ int whence = SEEK_SET;
- rb_scan_args(argc, argv, "11", &offset, &ptrname);
- if (argc == 1) whence = SEEK_SET;
- else whence = NUM2INT(ptrname);
-
- GetOpenFile(io, fptr);
- pos = fseek(fptr->f, NUM2INT(offset), whence);
- if (pos != 0) rb_sys_fail(fptr->path);
- clearerr(fptr->f);
+ if (rb_scan_args(argc, argv, "11", &offset, &ptrname) == 2) {
+ whence = NUM2INT(ptrname);
+ }
- return INT2FIX(0);
+ return rb_io_seek(io, offset, whence);
}
+/*
+ * call-seq:
+ * ios.pos = integer => 0
+ *
+ * Seeks to the given position (in bytes) in <em>ios</em>.
+ *
+ * f = File.new("testfile")
+ * f.pos = 17
+ * f.gets #=> "This is line two\n"
+ */
+
static VALUE
rb_io_set_pos(io, offset)
VALUE io, offset;
{
OpenFile *fptr;
- long pos;
+ off_t pos;
GetOpenFile(io, fptr);
- pos = fseek(fptr->f, NUM2INT(offset), SEEK_SET);
+ pos = io_seek(fptr, NUM2OFFT(offset), SEEK_SET);
if (pos != 0) rb_sys_fail(fptr->path);
clearerr(fptr->f);
- return INT2NUM(pos);
+ return OFFT2NUM(pos);
}
+/*
+ * call-seq:
+ * ios.rewind => 0
+ *
+ * Positions <em>ios</em> to the beginning of input, resetting
+ * <code>lineno</code> to zero.
+ *
+ * f = File.new("testfile")
+ * f.readline #=> "This is line one\n"
+ * f.rewind #=> 0
+ * f.lineno #=> 0
+ * f.readline #=> "This is line one\n"
+ */
+
static VALUE
rb_io_rewind(io)
- VALUE io;
+ VALUE io;
{
OpenFile *fptr;
GetOpenFile(io, fptr);
- if (fseek(fptr->f, 0L, 0) != 0) rb_sys_fail(fptr->path);
+ if (io_seek(fptr, 0L, 0) != 0) rb_sys_fail(fptr->path);
clearerr(fptr->f);
if (io == current_file) {
gets_lineno -= fptr->lineno;
@@ -374,6 +674,19 @@ rb_io_rewind(io)
return INT2FIX(0);
}
+/*
+ * call-seq:
+ * ios.eof => true or false
+ * ios.eof? => true or false
+ *
+ * Returns true if <em>ios</em> is at end of file. The stream must be
+ * opened for reading or an <code>IOError</code> will be raised.
+ *
+ * f = File.new("testfile")
+ * dummy = f.readlines
+ * f.eof #=> true
+ */
+
VALUE
rb_io_eof(io)
VALUE io;
@@ -395,9 +708,23 @@ rb_io_eof(io)
ungetc(ch, fptr->f);
return Qfalse;
}
+ clearerr(fptr->f);
return Qtrue;
}
+/*
+ * call-seq:
+ * ios.sync => true or false
+ *
+ * Returns the current ``sync mode'' of <em>ios</em>. When sync mode is
+ * true, all output is immediately flushed to the underlying operating
+ * system and is not buffered by Ruby internally. See also
+ * <code>IO#fsync</code>.
+ *
+ * f = File.new("testfile")
+ * f.sync #=> false
+ */
+
static VALUE
rb_io_sync(io)
VALUE io;
@@ -408,6 +735,21 @@ rb_io_sync(io)
return (fptr->mode & FMODE_SYNC) ? Qtrue : Qfalse;
}
+/*
+ * call-seq:
+ * ios.sync = boolean => boolean
+ *
+ * Sets the ``sync mode'' to <code>true</code> or <code>false</code>.
+ * When sync mode is true, all output is immediately flushed to the
+ * underlying operating system and is not buffered internally. Returns
+ * the new state. See also <code>IO#fsync</code>.
+ *
+ * f = File.new("testfile")
+ * f.sync = true
+ *
+ * <em>(produces no output)</em>
+ */
+
static VALUE
rb_io_set_sync(io, mode)
VALUE io, mode;
@@ -424,6 +766,51 @@ rb_io_set_sync(io, mode)
return mode;
}
+/*
+ * call-seq:
+ * ios.fsync => 0 or nil
+ *
+ * Immediately writes all buffered data in <em>ios</em> to disk.
+ * Returns <code>nil</code> if the underlying operating system does not
+ * support <em>fsync(2)</em>. Note that <code>fsync</code> differs from
+ * using <code>IO#sync=</code>. The latter ensures that data is flushed
+ * from Ruby's buffers, but doesn't not guarantee that the underlying
+ * operating system actually writes it to disk.
+ */
+
+static VALUE
+rb_io_fsync(io)
+ VALUE io;
+{
+#ifdef HAVE_FSYNC
+ OpenFile *fptr;
+ FILE *f;
+
+ GetOpenFile(io, fptr);
+ f = GetWriteFile(fptr);
+
+ io_fflush(f, fptr);
+ if (fsync(fileno(f)) < 0)
+ rb_sys_fail(fptr->path);
+ return INT2FIX(0);
+#else
+ rb_notimplement();
+ return Qnil; /* not reached */
+#endif
+}
+
+/*
+ * call-seq:
+ * ios.fileno => fixnum
+ * ios.to_i => fixnum
+ *
+ * Returns an integer representing the numeric file descriptor for
+ * <em>ios</em>.
+ *
+ * $stdin.fileno #=> 0
+ * $stdout.fileno #=> 1
+ */
+
static VALUE
rb_io_fileno(io)
VALUE io;
@@ -436,6 +823,26 @@ rb_io_fileno(io)
return INT2FIX(fd);
}
+/*
+ * call-seq:
+ * ios.pid => fixnum
+ *
+ * Returns the process ID of a child process associated with
+ * <em>ios</em>. This will be set by <code>IO::popen</code>.
+ *
+ * pipe = IO.popen("-")
+ * if pipe
+ * $stderr.puts "In parent, child pid is #{pipe.pid}"
+ * else
+ * $stderr.puts "In child, pid is #{$$}"
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * In child, pid is 26209
+ * In parent, child pid is 26209
+ */
+
static VALUE
rb_io_pid(io)
VALUE io;
@@ -448,6 +855,41 @@ rb_io_pid(io)
return INT2FIX(fptr->pid);
}
+/*
+ * call-seq:
+ * ios.inspect => string
+ *
+ * Return a string describing this IO object.
+ */
+
+static VALUE
+rb_io_inspect(obj)
+ VALUE obj;
+{
+ OpenFile *fptr;
+ char *buf, *cname, *st = "";
+ long len;
+
+ fptr = RFILE(rb_io_taint_check(obj))->fptr;
+ if (!fptr || !fptr->path) return rb_any_to_s(obj);
+ cname = rb_obj_classname(obj);
+ len = strlen(cname) + strlen(fptr->path) + 5;
+ if (!(fptr->f || fptr->f2)) {
+ st = " (closed)";
+ len += 9;
+ }
+ buf = ALLOCA_N(char, len);
+ sprintf(buf, "#<%s:%s%s>", cname, fptr->path, st);
+ return rb_str_new2(buf);
+}
+
+/*
+ * call-seq:
+ * ios.to_io -> ios
+ *
+ * Returns <em>ios</em>.
+ */
+
static VALUE
rb_io_to_io(io)
VALUE io;
@@ -456,9 +898,8 @@ rb_io_to_io(io)
}
/* reading functions */
-
-static long
-io_fread(ptr, len, f)
+long
+rb_io_fread(ptr, len, f)
char *ptr;
long len;
FILE *f;
@@ -466,25 +907,60 @@ io_fread(ptr, len, f)
long n = len;
int c;
- while (n--) {
+ while (n > 0) {
+#ifdef READ_DATA_PENDING_COUNT
+ long i = READ_DATA_PENDING_COUNT(f);
+ if (i <= 0) {
+ rb_thread_wait_fd(fileno(f));
+ i = READ_DATA_PENDING_COUNT(f);
+ }
+ if (i > 0) {
+ if (i > n) i = n;
+ TRAP_BEG;
+ c = fread(ptr, 1, i, f);
+ TRAP_END;
+ if (c < 0) goto eof;
+ ptr += c;
+ n -= c;
+ if (c < i) goto eof;
+ continue;
+ }
+#else
if (!READ_DATA_PENDING(f)) {
rb_thread_wait_fd(fileno(f));
}
+#endif
TRAP_BEG;
c = getc(f);
TRAP_END;
if (c == EOF) {
+ eof:
if (ferror(f)) {
- if (errno == EINTR) continue;
- rb_sys_fail(0);
+ switch (errno) {
+ case EINTR:
+#if defined(ERESTART)
+ case ERESTART:
+#endif
+ clearerr(f);
+ continue;
+ case EAGAIN:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ if (len > n) {
+ clearerr(f);
+ }
+ rb_thread_wait_fd(fileno(f));
+ }
+ if (len == n) return 0;
}
*ptr = '\0';
break;
}
*ptr++ = c;
+ n--;
}
-
- return len - n - 1;
+ return len - n;
}
#ifndef S_ISREG
@@ -493,44 +969,59 @@ io_fread(ptr, len, f)
#define SMALLBUF 100
-static VALUE
-read_all(port)
- VALUE port;
-{
+static long
+remain_size(fptr)
OpenFile *fptr;
- VALUE str = Qnil;
+{
struct stat st;
- long siz = BUFSIZ;
- long bytes = 0;
- int n;
+ off_t siz = BUFSIZ;
+ off_t pos;
- GetOpenFile(port, fptr);
- rb_io_check_readable(fptr);
-
- if (feof(fptr->f)) return Qnil;
+ if (feof(fptr->f)) return 0;
if (fstat(fileno(fptr->f), &st) == 0 && S_ISREG(st.st_mode)
#ifdef __BEOS__
&& (st.st_dev > 3)
#endif
)
{
- if (st.st_size == 0) {
- getc(fptr->f); /* force EOF */
- return rb_str_new(0, 0);
- }
- else {
- long pos = ftell(fptr->f);
- if (st.st_size > pos && pos >= 0) {
- siz = st.st_size - pos + 1;
+ pos = io_tell(fptr);
+ if (st.st_size >= pos && pos >= 0) {
+ siz = st.st_size - pos + 1;
+ if (siz > LONG_MAX) {
+ rb_raise(rb_eIOError, "file too big for single read");
}
}
}
- str = rb_tainted_str_new(0, siz);
- READ_CHECK(fptr->f);
+ return (long)siz;
+}
+
+static VALUE
+read_all(fptr, siz, str)
+ OpenFile *fptr;
+ long siz;
+ VALUE str;
+{
+ long bytes = 0;
+ long n;
+
+ if (siz == 0) siz = BUFSIZ;
+ if (NIL_P(str)) {
+ str = rb_tainted_str_new(0, siz);
+ }
+ else {
+ StringValue(str);
+ rb_str_resize(str, siz);
+ }
for (;;) {
- n = io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f);
+ rb_str_locktmp(str);
+ READ_CHECK(fptr->f);
+ n = rb_io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr->f);
+ rb_str_unlocktmp(str);
if (n == 0 && bytes == 0) {
- if (feof(fptr->f)) return Qnil;
+ rb_str_resize(str,0);
+ if (!fptr->f) break;
+ if (feof(fptr->f)) break;
+ if (!ferror(fptr->f)) break;
rb_sys_fail(fptr->path);
}
bytes += n;
@@ -538,12 +1029,25 @@ read_all(port)
siz += BUFSIZ;
rb_str_resize(str, siz);
}
- if (bytes == 0) return rb_str_new(0,0);
if (bytes != siz) rb_str_resize(str, bytes);
return str;
}
+/*
+ * call-seq:
+ * ios.read([integer [, buffer]]) => string, buffer, or nil
+ *
+ * Reads at most <i>integer</i> bytes from the I/O stream, or to the
+ * end of file if <i>integer</i> is omitted or is <code>nil</code>.
+ * If the optional <i>buffer</i> argument is present, it must reference
+ * a String, which will receive the data. Returns <code>nil</code>
+ * if called at end of file.
+ *
+ * f = File.new("testfile")
+ * f.read(16) #=> "This is line one"
+ */
+
static VALUE
io_read(argc, argv, io)
int argc;
@@ -551,30 +1055,42 @@ io_read(argc, argv, io)
VALUE io;
{
OpenFile *fptr;
- int n, len;
+ long n, len;
VALUE length, str;
- rb_scan_args(argc, argv, "01", &length);
+ rb_scan_args(argc, argv, "02", &length, &str);
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
if (NIL_P(length)) {
- return read_all(io);
+ return read_all(fptr, remain_size(fptr), str);
}
- len = NUM2INT(length);
+ len = NUM2LONG(length);
if (len < 0) {
- rb_raise(rb_eArgError, "negative length %d given", len);
+ rb_raise(rb_eArgError, "negative length %ld given", len);
}
- GetOpenFile(io, fptr);
- rb_io_check_readable(fptr);
if (feof(fptr->f)) return Qnil;
- str = rb_str_new(0, len);
+ if (NIL_P(str)) {
+ str = rb_str_new(0, len);
+ }
+ else {
+ StringValue(str);
+ rb_str_modify(str);
+ rb_str_resize(str,len);
+ }
if (len == 0) return str;
+ rb_str_locktmp(str);
READ_CHECK(fptr->f);
- n = io_fread(RSTRING(str)->ptr, len, fptr->f);
+ n = rb_io_fread(RSTRING(str)->ptr, len, fptr->f);
+ rb_str_unlocktmp(str);
if (n == 0) {
+ rb_str_resize(str,0);
+ if (!fptr->f) return Qnil;
if (feof(fptr->f)) return Qnil;
- rb_sys_fail(fptr->path);
+ if (len > 0) rb_sys_fail(fptr->path);
}
RSTRING(str)->len = n;
RSTRING(str)->ptr[n] = '\0';
@@ -583,139 +1099,157 @@ io_read(argc, argv, io)
return str;
}
-static VALUE
-rb_io_gets_internal(argc, argv, io)
- int argc;
- VALUE *argv;
- VALUE io;
-{
+static int
+appendline(fptr, delim, strp)
OpenFile *fptr;
- FILE *f;
- VALUE str = Qnil;
- int c, newline;
- char *rsptr;
- int rslen, rspara = 0;
- VALUE rs;
-
- if (argc == 0) {
- rs = rb_rs;
- }
- else {
- rb_scan_args(argc, argv, "1", &rs);
- if (!NIL_P(rs)) Check_Type(rs, T_STRING);
- }
+ int delim;
+ VALUE *strp;
+{
+ FILE *f = fptr->f;
+ VALUE str = *strp;
+ int c = EOF;
+#ifndef READ_DATA_PENDING_PTR
+ char buf[8192];
+ char *bp = buf, *bpe = buf + sizeof buf - 3;
+ int update = Qfalse;
+#endif
- if (NIL_P(rs)) {
- rsptr = 0;
- rslen = 0;
- }
- else if (rs == rb_default_rs) {
- return rb_io_gets(io);
- }
- else {
- rslen = RSTRING(rs)->len;
- if (rslen == 0) {
- rsptr = "\n\n";
- rslen = 2;
- rspara = 1;
+ do {
+#ifdef READ_DATA_PENDING_PTR
+ long pending = READ_DATA_PENDING_COUNT(f);
+ if (pending > 0) {
+ const char *p = READ_DATA_PENDING_PTR(f);
+ const char *e = memchr(p, delim, pending);
+ long last = 0, len = (c != EOF);
+ if (e) pending = e - p + 1;
+ len += pending;
+ if (!NIL_P(str)) {
+ last = RSTRING(str)->len;
+ rb_str_resize(str, last + len);
+ }
+ else {
+ *strp = str = rb_str_buf_new(len);
+ RSTRING(str)->len = len;
+ RSTRING(str)->ptr[len] = '\0';
+ }
+ if (c != EOF) {
+ RSTRING(str)->ptr[last++] = c;
+ }
+ fread(RSTRING(str)->ptr + last, 1, pending, f); /* must not fail */
+ if (e) return delim;
}
- else if (rslen == 1 && RSTRING(rs)->ptr[0] == '\n') {
- return rb_io_gets(io);
+ else if (c != EOF) {
+ if (!NIL_P(str)) {
+ char ch = c;
+ rb_str_buf_cat(str, &ch, 1);
+ }
+ else {
+ *strp = str = rb_str_buf_new(1);
+ RSTRING(str)->ptr[RSTRING(str)->len++] = c;
+ }
}
- else {
- rsptr = RSTRING(rs)->ptr;
+ rb_thread_wait_fd(fileno(f));
+ rb_io_check_closed(fptr);
+#else
+ READ_CHECK(f);
+#endif
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
+ if (c == EOF) {
+ if (ferror(f)) {
+ clearerr(f);
+ if (!rb_io_wait_readable(fileno(f)))
+ rb_sys_fail(fptr->path);
+ continue;
+ }
+#ifdef READ_DATA_PENDING_PTR
+ return c;
+#endif
}
- }
-
- GetOpenFile(io, fptr);
- rb_io_check_readable(fptr);
- f = fptr->f;
-
- if (rspara) {
- do {
- READ_CHECK(f);
- TRAP_BEG;
- c = getc(f);
- TRAP_END;
- if (c != '\n') {
- ungetc(c,f);
- break;
+#ifndef READ_DATA_PENDING_PTR
+ if (c == EOF || (*bp++ = c) == delim || bp == bpe) {
+ int cnt = bp - buf;
+
+ if (cnt > 0) {
+ if (!NIL_P(str))
+ rb_str_cat(str, buf, cnt);
+ else
+ *strp = str = rb_str_new(buf, cnt);
}
- } while (c != EOF);
- }
+ if (c == EOF) {
+ if (update)
+ return (int)RSTRING(str)->ptr[RSTRING(str)->len-1];
+ return c;
+ }
+ bp = buf;
+ }
+ update = Qtrue;
+#endif
+ } while (c != delim);
- newline = rslen ? rsptr[rslen - 1] : 0777;
+#ifdef READ_DATA_PENDING_PTR
{
- char buf[8192];
- char *bp, *bpe = buf + sizeof buf - 3;
- int cnt;
- int append = 0;
-
- again:
- bp = buf;
-
- if (rslen) {
- for (;;) {
- READ_CHECK(f);
- TRAP_BEG;
- c = getc(f);
- TRAP_END;
- if (c == EOF) {
- if (ferror(f)) {
- if (errno == EINTR) continue;
- rb_sys_fail(fptr->path);
- }
- break;
- }
- if ((*bp++ = c) == newline) break;
- if (bp == bpe) break;
- }
- cnt = bp - buf;
+ char ch = c;
+ if (!NIL_P(str)) {
+ rb_str_cat(str, &ch, 1);
}
else {
- READ_CHECK(f);
- cnt = io_fread(buf, sizeof(buf), f);
- if (cnt == 0) {
- if (ferror(f)) rb_sys_fail(fptr->path);
- c = EOF;
- }
- else {
- c = 0;
- }
+ *strp = str = rb_str_new(&ch, 1);
}
+ }
+#endif
- if (c == EOF && !append && cnt == 0) {
- str = Qnil;
- goto return_gets;
- }
+ return c;
+}
- if (append)
- rb_str_cat(str, buf, cnt);
- else
- str = rb_str_new(buf, cnt);
+static inline int
+swallow(fptr, term)
+ OpenFile *fptr;
+ int term;
+{
+ FILE *f = fptr->f;
+ int c;
- if (c != EOF &&
- (!rslen ||
- RSTRING(str)->len < rslen ||
- memcmp(RSTRING(str)->ptr+RSTRING(str)->len-rslen,rsptr,rslen))) {
- append = 1;
- goto again;
+ do {
+#ifdef READ_DATA_PENDING_PTR
+ long cnt;
+ while ((cnt = READ_DATA_PENDING_COUNT(f)) > 0) {
+ char buf[1024];
+ const char *p = READ_DATA_PENDING_PTR(f);
+ int i;
+ if (cnt > sizeof buf) cnt = sizeof buf;
+ if (*p != term) return Qtrue;
+ i = cnt;
+ while (--i && *++p == term);
+ if (!fread(buf, 1, cnt - i, f)) /* must not fail */
+ rb_sys_fail(fptr->path);
}
- }
-
- return_gets:
- if (rspara) {
- while (c != EOF) {
- READ_CHECK(f);
- TRAP_BEG;
- c = getc(f);
- TRAP_END;
- if (c != '\n') {
- ungetc(c, f);
- break;
- }
+ rb_thread_wait_fd(fileno(f));
+ rb_io_check_closed(fptr);
+#else
+ READ_CHECK(f);
+#endif
+ TRAP_BEG;
+ c = getc(f);
+ TRAP_END;
+ if (c != term) {
+ ungetc(c, f);
+ return Qtrue;
}
- }
+ } while (c != EOF);
+ return Qfalse;
+}
+
+static VALUE
+rb_io_getline_fast(fptr, delim)
+ OpenFile *fptr;
+ unsigned char delim;
+{
+ VALUE str = Qnil;
+ int c;
+
+ while ((c = appendline(fptr, delim, &str)) != EOF && c != delim);
if (!NIL_P(str)) {
fptr->lineno++;
@@ -726,58 +1260,66 @@ rb_io_gets_internal(argc, argv, io)
return str;
}
-VALUE
-rb_io_gets(io)
- VALUE io;
+static int
+rscheck(rsptr, rslen, rs)
+ char *rsptr;
+ long rslen;
+ VALUE rs;
{
+ if (RSTRING(rs)->ptr != rsptr && RSTRING(rs)->len != rslen)
+ rb_raise(rb_eRuntimeError, "rs modified");
+ return 1;
+}
+
+static VALUE
+rb_io_getline(rs, fptr)
+ VALUE rs;
OpenFile *fptr;
- FILE *f;
+{
VALUE str = Qnil;
- int c;
- char buf[8192];
- char *bp, *bpe = buf + sizeof buf - 3;
- int cnt;
- int append = 0;
- GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- f = fptr->f;
-
- again:
- bp = buf;
- for (;;) {
- READ_CHECK(f);
- TRAP_BEG;
- c = getc(f);
- TRAP_END;
- if (c == EOF) {
- if (ferror(f)) {
- if (errno == EINTR) continue;
- rb_sys_fail(fptr->path);
- }
- break;
- }
- if ((*bp++ = c) == '\n') break;
- if (bp == bpe) break;
+ if (NIL_P(rs)) {
+ str = read_all(fptr, 0, Qnil);
+ if (RSTRING(str)->len == 0) return Qnil;
}
- cnt = bp - buf;
-
- if (c == EOF && !append && cnt == 0) {
- str = Qnil;
- goto return_gets;
+ else if (rs == rb_default_rs) {
+ return rb_io_getline_fast(fptr, '\n');
}
+ else {
+ int c, newline;
+ char *rsptr;
+ long rslen;
+ int rspara = 0;
- if (append)
- rb_str_cat(str, buf, cnt);
- else
- str = rb_str_new(buf, cnt);
+ StringValue(rs);
+ rslen = RSTRING(rs)->len;
+ if (rslen == 0) {
+ rsptr = "\n\n";
+ rslen = 2;
+ rspara = 1;
+ swallow(fptr, '\n');
+ }
+ else if (rslen == 1) {
+ return rb_io_getline_fast(fptr, (unsigned char)RSTRING(rs)->ptr[0]);
+ }
+ else {
+ rsptr = RSTRING(rs)->ptr;
+ }
+ newline = rsptr[rslen - 1];
+
+ while ((c = appendline(fptr, newline, &str)) != EOF &&
+ (c != newline || RSTRING(str)->len < rslen ||
+ (rspara || rscheck(rsptr,rslen,rs), 0) ||
+ memcmp(RSTRING(str)->ptr+RSTRING(str)->len-rslen,rsptr,rslen)));
- if (c != EOF && RSTRING(str)->ptr[RSTRING(str)->len-1] != '\n') {
- append = 1;
- goto again;
+ if (rspara) {
+ if (c != EOF) {
+ swallow(fptr, '\n');
+ }
+ }
}
- return_gets:
if (!NIL_P(str)) {
fptr->lineno++;
lineno = INT2FIX(fptr->lineno);
@@ -787,20 +1329,75 @@ rb_io_gets(io)
return str;
}
+VALUE
+rb_io_gets(io)
+ VALUE io;
+{
+ OpenFile *fptr;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ return rb_io_getline_fast(fptr, '\n');
+}
+
+/*
+ * call-seq:
+ * ios.gets(sep_string=$/) => string or nil
+ *
+ * Reads the next ``line'' from the I/O stream; lines are separated by
+ * <i>sep_string</i>. A separator of <code>nil</code> reads the entire
+ * contents, and a zero-length separator reads the input a paragraph at
+ * a time (two successive newlines in the input separate paragraphs).
+ * The stream must be opened for reading or an <code>IOError</code>
+ * will be raised. The line read in will be returned and also assigned
+ * to <code>$_</code>. Returns <code>nil</code> if called at end of
+ * file.
+ *
+ * File.new("testfile").gets #=> "This is line one\n"
+ * $_ #=> "This is line one\n"
+ */
+
static VALUE
rb_io_gets_m(argc, argv, io)
int argc;
VALUE *argv;
VALUE io;
{
- VALUE str = rb_io_gets_internal(argc, argv, io);
+ VALUE rs, str;
+ OpenFile *fptr;
- if (!NIL_P(str)) {
- rb_lastline_set(str);
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
}
+ GetOpenFile(io, fptr);
+ str = rb_io_getline(rs, fptr);
+ rb_lastline_set(str);
+
return str;
}
+/*
+ * call-seq:
+ * ios.lineno => integer
+ *
+ * Returns the current line number in <em>ios</em>. The stream must be
+ * opened for reading. <code>lineno</code> counts the number of times
+ * <code>gets</code> is called, rather than the number of newlines
+ * encountered. The two values will differ if <code>gets</code> is
+ * called with a separator other than newline. See also the
+ * <code>$.</code> variable.
+ *
+ * f = File.new("testfile")
+ * f.lineno #=> 0
+ * f.gets #=> "This is line one\n"
+ * f.lineno #=> 1
+ * f.gets #=> "This is line two\n"
+ * f.lineno #=> 2
+ */
+
static VALUE
rb_io_lineno(io)
VALUE io;
@@ -812,6 +1409,23 @@ rb_io_lineno(io)
return INT2NUM(fptr->lineno);
}
+/*
+ * call-seq:
+ * ios.lineno = integer => integer
+ *
+ * Manually sets the current line number to the given value.
+ * <code>$.</code> is updated only on the next read.
+ *
+ * f = File.new("testfile")
+ * f.gets #=> "This is line one\n"
+ * $. #=> 1
+ * f.lineno = 1000
+ * f.lineno #=> 1000
+ * $. # lineno of last read #=> 1
+ * f.gets #=> "This is line two\n"
+ * $. # lineno of last read #=> 1001
+ */
+
static VALUE
rb_io_set_lineno(io, lineno)
VALUE io, lineno;
@@ -849,6 +1463,14 @@ argf_lineno()
return lineno;
}
+/*
+ * call-seq:
+ * ios.readline(sep_string=$/) => string
+ *
+ * Reads a line as with <code>IO#gets</code>, but raises an
+ * <code>EOFError</code> on end of file.
+ */
+
static VALUE
rb_io_readline(argc, argv, io)
int argc;
@@ -863,6 +1485,21 @@ rb_io_readline(argc, argv, io)
return line;
}
+/*
+ * call-seq:
+ * ios.readlines(sep_string=$/) => array
+ *
+ * Reads all of the lines in <em>ios</em>, and returns them in
+ * <i>anArray</i>. Lines are separated by the optional
+ * <i>sep_string</i>. If <i>set_string</i> is <code>nil</code>, the
+ * rest of the stream is returned as a single record.
+ * The stream must be opened for reading or an
+ * <code>IOError</code> will be raised.
+ *
+ * f = File.new("testfile")
+ * f.readlines[0] #=> "This is line one\n"
+ */
+
static VALUE
rb_io_readlines(argc, argv, io)
int argc;
@@ -870,14 +1507,43 @@ rb_io_readlines(argc, argv, io)
VALUE io;
{
VALUE line, ary;
+ VALUE rs;
+ OpenFile *fptr;
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
+ }
+ GetOpenFile(io, fptr);
ary = rb_ary_new();
- while (!NIL_P(line = rb_io_gets_internal(argc, argv, io))) {
+ while (!NIL_P(line = rb_io_getline(rs, fptr))) {
rb_ary_push(ary, line);
}
return ary;
}
+/*
+ * call-seq:
+ * ios.each(sep_string=$/) {|line| block } => ios
+ * ios.each_line(sep_string=$/) {|line| block } => ios
+ *
+ * Executes the block for every line in <em>ios</em>, where lines are
+ * separated by <i>sep_string</i>. <em>ios</em> must be opened for
+ * reading or an <code>IOError</code> will be raised.
+ *
+ * f = File.new("testfile")
+ * f.each {|line| puts "#{f.lineno}: #{line}" }
+ *
+ * <em>produces:</em>
+ *
+ * 1: This is line one
+ * 2: This is line two
+ * 3: This is line three
+ * 4: And so on...
+ */
+
static VALUE
rb_io_each_line(argc, argv, io)
int argc;
@@ -885,13 +1551,36 @@ rb_io_each_line(argc, argv, io)
VALUE io;
{
VALUE str;
+ OpenFile *fptr;
+ VALUE rs;
- while (!NIL_P(str = rb_io_gets_internal(argc, argv, io))) {
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
+ }
+ GetOpenFile(io, fptr);
+ while (!NIL_P(str = rb_io_getline(rs, fptr))) {
rb_yield(str);
}
return io;
}
+/*
+ * call-seq:
+ * ios.each_byte {|byte| block } => nil
+ *
+ * Calls the given block once for each byte (0..255) in <em>ios</em>,
+ * passing the byte as an argument. The stream must be opened for
+ * reading or an <code>IOError</code> will be raised.
+ *
+ * f = File.new("testfile")
+ * checksum = 0
+ * f.each_byte {|x| checksum ^= x } #=> #<File:testfile>
+ * checksum #=> 12
+ */
+
static VALUE
rb_io_each_byte(io)
VALUE io;
@@ -901,27 +1590,41 @@ rb_io_each_byte(io)
int c;
GetOpenFile(io, fptr);
- rb_io_check_readable(fptr);
- f = fptr->f;
for (;;) {
+ rb_io_check_readable(fptr);
+ f = fptr->f;
READ_CHECK(f);
TRAP_BEG;
c = getc(f);
TRAP_END;
if (c == EOF) {
if (ferror(f)) {
- if (errno == EINTR) continue;
- rb_sys_fail(fptr->path);
+ clearerr(f);
+ if (!rb_io_wait_readable(fileno(f)))
+ rb_sys_fail(fptr->path);
+ continue;
}
break;
}
rb_yield(INT2FIX(c & 0xff));
}
if (ferror(f)) rb_sys_fail(fptr->path);
- return Qnil;
+ return io;
}
+/*
+ * call-seq:
+ * ios.getc => fixnum or nil
+ *
+ * Gets the next 8-bit byte (0..255) from <em>ios</em>. Returns
+ * <code>nil</code> if called at end of file.
+ *
+ * f = File.new("testfile")
+ * f.getc #=> 84
+ * f.getc #=> 104
+ */
+
VALUE
rb_io_getc(io)
VALUE io;
@@ -942,8 +1645,10 @@ rb_io_getc(io)
if (c == EOF) {
if (ferror(f)) {
- if (errno == EINTR) goto retry;
- rb_sys_fail(fptr->path);
+ clearerr(f);
+ if (!rb_io_wait_readable(fileno(f)))
+ rb_sys_fail(fptr->path);
+ goto retry;
}
return Qnil;
}
@@ -966,6 +1671,14 @@ rb_getc(f)
return c;
}
+/*
+ * call-seq:
+ * ios.readchar => fixnum
+ *
+ * Reads a character as with <code>IO#getc</code>, but raises an
+ * <code>EOFError</code> on end of file.
+ */
+
static VALUE
rb_io_readchar(io)
VALUE io;
@@ -978,6 +1691,22 @@ rb_io_readchar(io)
return c;
}
+/*
+ * call-seq:
+ * ios.ungetc(integer) => nil
+ *
+ * Pushes back one character (passed as a parameter) onto <em>ios</em>,
+ * such that a subsequent buffered read will return it. Only one character
+ * may be pushed back before a subsequent read operation (that is,
+ * you will be able to read only the last of several characters that have been pushed
+ * back). Has no effect with unbuffered reads (such as <code>IO#sysread</code>).
+ *
+ * f = File.new("testfile") #=> #<File:testfile>
+ * c = f.getc #=> 84
+ * f.ungetc(c) #=> nil
+ * f.getc #=> 84
+ */
+
VALUE
rb_io_ungetc(io, c)
VALUE io, c;
@@ -986,13 +1715,28 @@ rb_io_ungetc(io, c)
int cc = NUM2INT(c);
GetOpenFile(io, fptr);
+ if (!(fptr->mode & FMODE_RBUF))
+ rb_raise(rb_eIOError, "unread stream");
rb_io_check_readable(fptr);
- if (ungetc(cc, fptr->f) == EOF)
- rb_sys_fail(fptr->path);
+ if (ungetc(cc, fptr->f) == EOF && cc != EOF) {
+ rb_raise(rb_eIOError, "ungetc failed");
+ }
return Qnil;
}
+/*
+ * call-seq:
+ * ios.isatty => true or false
+ * ios.tty? => true or false
+ *
+ * Returns <code>true</code> if <em>ios</em> is associated with a
+ * terminal device (tty), <code>false</code> otherwise.
+ *
+ * File.new("testfile").isatty #=> false
+ * File.new("/dev/tty").isatty #=> true
+ */
+
static VALUE
rb_io_isatty(io)
VALUE io;
@@ -1006,32 +1750,52 @@ rb_io_isatty(io)
}
static void
-fptr_finalize(fptr)
+fptr_finalize(fptr, noraise)
OpenFile *fptr;
+ int noraise;
{
+ int n1 = 0, n2 = 0, f1, f2 = -1;
+
+ if (fptr->f2) {
+ f2 = fileno(fptr->f2);
+ while (n2 = 0, fclose(fptr->f2) < 0) {
+ n2 = errno;
+ if (!rb_io_wait_writable(f2)) {
+ break;
+ }
+ if (!fptr->f2) break;
+ }
+ fptr->f2 = 0;
+ }
if (fptr->f) {
- fclose(fptr->f);
+ f1 = fileno(fptr->f);
+ while (n1 = 0, fclose(fptr->f) < 0) {
+ n1 = errno;
+ if (f2 != -1 || !(fptr->mode & FMODE_WBUF)) break;
+ if (!rb_io_wait_writable(f1)) break;
+ if (!fptr->f) break;
+ }
+ fptr->f = 0;
+ if (n1 == EBADF && f1 == f2) {
+ n1 = 0;
+ }
}
- if (fptr->f2) {
- fclose(fptr->f2);
+ if (!noraise && (n1 || n2)) {
+ errno = (n1 ? n1 : n2);
+ rb_sys_fail(fptr->path);
}
}
static void
-rb_io_fptr_cleanup(fptr)
+rb_io_fptr_cleanup(fptr, noraise)
OpenFile *fptr;
+ int noraise;
{
if (fptr->finalize) {
- (*fptr->finalize)(fptr);
+ (*fptr->finalize)(fptr, noraise);
}
else {
- fptr_finalize(fptr);
- }
- fptr->f = fptr->f2 = 0;
-
- if (fptr->path) {
- free(fptr->path);
- fptr->path = 0;
+ fptr_finalize(fptr, noraise);
}
}
@@ -1040,24 +1804,13 @@ rb_io_fptr_finalize(fptr)
OpenFile *fptr;
{
if (!fptr) return;
+ if (fptr->path) {
+ free(fptr->path);
+ }
if (!fptr->f && !fptr->f2) return;
if (fileno(fptr->f) < 3) return;
- rb_io_fptr_cleanup(fptr);
-}
-
-static void
-rb_io_fptr_close(fptr)
- OpenFile *fptr;
-{
- int fd;
-
- if (!fptr) return;
- if (!fptr->f && !fptr->f2) return;
-
- fd = fileno(fptr->f);
- rb_io_fptr_cleanup(fptr);
- rb_thread_fd_close(fd);
+ rb_io_fptr_cleanup(fptr, Qtrue);
}
VALUE
@@ -1065,9 +1818,23 @@ rb_io_close(io)
VALUE io;
{
OpenFile *fptr;
+ int fd, fd2;
fptr = RFILE(io)->fptr;
- rb_io_fptr_close(fptr);
+ if (!fptr) return Qnil;
+ if (fptr->f2) {
+ fd2 = fileno(fptr->f2);
+ }
+ else {
+ if (!fptr->f) return Qnil;
+ fd2 = -1;
+ }
+
+ fd = fileno(fptr->f);
+ rb_io_fptr_cleanup(fptr, Qfalse);
+ rb_thread_fd_close(fd);
+ if (fd2 >= 0) rb_thread_fd_close(fd2);
+
if (fptr->pid) {
rb_syswait(fptr->pid);
fptr->pid = 0;
@@ -1076,6 +1843,17 @@ rb_io_close(io)
return Qnil;
}
+/*
+ * call-seq:
+ * ios.close => nil
+ *
+ * Closes <em>ios</em> and flushes any pending writes to the operating
+ * system. The stream is unavailable for any further data operations;
+ * an <code>IOError</code> is raised if such an attempt is made. I/O
+ * streams are automatically closed when they are claimed by the
+ * garbage collector.
+ */
+
static VALUE
rb_io_close_m(io)
VALUE io;
@@ -1083,21 +1861,66 @@ rb_io_close_m(io)
if (rb_safe_level() >= 4 && !OBJ_TAINTED(io)) {
rb_raise(rb_eSecurityError, "Insecure: can't close");
}
+ rb_io_check_closed(RFILE(io)->fptr);
rb_io_close(io);
return Qnil;
}
static VALUE
+io_close(io)
+ VALUE io;
+{
+ return rb_funcall(io, rb_intern("close"), 0, 0);
+}
+
+/*
+ * call-seq:
+ * ios.closed? => true or false
+ *
+ * Returns <code>true</code> if <em>ios</em> is completely closed (for
+ * duplex streams, both reader and writer), <code>false</code>
+ * otherwise.
+ *
+ * f = File.new("testfile")
+ * f.close #=> nil
+ * f.closed? #=> true
+ * f = IO.popen("/bin/sh","r+")
+ * f.close_write #=> nil
+ * f.closed? #=> false
+ * f.close_read #=> nil
+ * f.closed? #=> true
+ */
+
+static VALUE
rb_io_closed(io)
VALUE io;
{
OpenFile *fptr;
fptr = RFILE(io)->fptr;
+ rb_io_check_initialized(fptr);
return (fptr->f || fptr->f2)?Qfalse:Qtrue;
}
-VALUE
+/*
+ * call-seq:
+ * ios.close_read => nil
+ *
+ * Closes the read end of a duplex I/O stream (i.e., one that contains
+ * both a read and a write stream, such as a pipe). Will raise an
+ * <code>IOError</code> if the stream is not duplexed.
+ *
+ * f = IO.popen("/bin/sh","r+")
+ * f.close_read
+ * f.readlines
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:3:in `readlines': not opened for reading (IOError)
+ * from prog.rb:3
+ */
+
+static VALUE
rb_io_close_read(io)
VALUE io;
{
@@ -1123,6 +1946,25 @@ rb_io_close_read(io)
return Qnil;
}
+/*
+ * call-seq:
+ * ios.close_write => nil
+ *
+ * Closes the write end of a duplex I/O stream (i.e., one that contains
+ * both a read and a write stream, such as a pipe). Will raise an
+ * <code>IOError</code> if the stream is not duplexed.
+ *
+ * f = IO.popen("/bin/sh","r+")
+ * f.close_write
+ * f.print "nowhere"
+ *
+ * <em>produces:</em>
+ *
+ * prog.rb:3:in `write': not opened for writing (IOError)
+ * from prog.rb:3:in `print'
+ * from prog.rb:3
+ */
+
static VALUE
rb_io_close_write(io)
VALUE io;
@@ -1148,13 +1990,68 @@ rb_io_close_write(io)
return Qnil;
}
+/*
+ * call-seq:
+ * ios.sysseek(offset, whence=SEEK_SET) => integer
+ *
+ * Seeks to a given <i>offset</i> in the stream according to the value
+ * of <i>whence</i> (see <code>IO#seek</code> for values of
+ * <i>whence</i>). Returns the new offset into the file.
+ *
+ * f = File.new("testfile")
+ * f.sysseek(-13, IO::SEEK_END) #=> 53
+ * f.sysread(10) #=> "And so on."
+ */
+
+static VALUE
+rb_io_sysseek(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
+{
+ VALUE offset, ptrname;
+ int whence = SEEK_SET;
+ OpenFile *fptr;
+ off_t pos;
+
+ if (rb_scan_args(argc, argv, "11", &offset, &ptrname) == 2) {
+ whence = NUM2INT(ptrname);
+ }
+
+ GetOpenFile(io, fptr);
+ if ((fptr->mode & FMODE_READABLE) && READ_DATA_BUFFERED(fptr->f)) {
+ rb_raise(rb_eIOError, "sysseek for buffered IO");
+ }
+ if ((fptr->mode & FMODE_WRITABLE) && (fptr->mode & FMODE_WBUF)) {
+ rb_warn("sysseek for buffered IO");
+ }
+ pos = lseek(fileno(fptr->f), NUM2OFFT(offset), whence);
+ if (pos == -1) rb_sys_fail(fptr->path);
+ clearerr(fptr->f);
+
+ return OFFT2NUM(pos);
+}
+
+/*
+ * call-seq:
+ * ios.syswrite(string ) => integer
+ *
+ * Writes the given string to <em>ios</em> using a low-level write.
+ * Returns the number of bytes written. Do not mix with other methods
+ * that write to <em>ios</em> or you may get unpredictable results.
+ * Raises <code>SystemCallError</code> on error.
+ *
+ * f = File.new("out", "w")
+ * f.syswrite("ABCDEF") #=> 6
+ */
+
static VALUE
rb_io_syswrite(io, str)
VALUE io, str;
{
OpenFile *fptr;
FILE *f;
- int n;
+ long n;
rb_secure(4);
if (TYPE(str) != T_STRING)
@@ -1164,6 +2061,9 @@ rb_io_syswrite(io, str)
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
+ if (fptr->mode & FMODE_WBUF) {
+ rb_warn("syswrite for buffered IO");
+ }
if (!rb_thread_fd_writable(fileno(f))) {
rb_io_check_closed(fptr);
}
@@ -1171,33 +2071,63 @@ rb_io_syswrite(io, str)
if (n == -1) rb_sys_fail(fptr->path);
- return INT2FIX(n);
+ return LONG2FIX(n);
}
+/*
+ * call-seq:
+ * ios.sysread(integer ) => string
+ *
+ * Reads <i>integer</i> bytes from <em>ios</em> using a low-level
+ * read and returns them as a string. Do not mix with other methods
+ * that read from <em>ios</em> or you may get unpredictable results.
+ * Raises <code>SystemCallError</code> on error and
+ * <code>EOFError</code> at end of file.
+ *
+ * f = File.new("testfile")
+ * f.sysread(16) #=> "This is line one"
+ */
+
static VALUE
-rb_io_sysread(io, len)
- VALUE io, len;
+rb_io_sysread(argc, argv, io)
+ int argc;
+ VALUE *argv;
+ VALUE io;
{
+ VALUE len, str;
OpenFile *fptr;
- int n, ilen;
- VALUE str;
+ long n, ilen;
- ilen = NUM2INT(len);
+ rb_scan_args(argc, argv, "11", &len, &str);
+ ilen = NUM2LONG(len);
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
- if (READ_DATA_PENDING(fptr->f)) {
+ if (READ_DATA_BUFFERED(fptr->f)) {
rb_raise(rb_eIOError, "sysread for buffered IO");
}
- str = rb_str_new(0, ilen);
+ if (NIL_P(str)) {
+ str = rb_str_new(0, ilen);
+ }
+ else {
+ StringValue(str);
+ rb_str_modify(str);
+ rb_str_resize(str, ilen);
+ }
+ if (ilen == 0) return str;
+ n = fileno(fptr->f);
rb_thread_wait_fd(fileno(fptr->f));
TRAP_BEG;
n = read(fileno(fptr->f), RSTRING(str)->ptr, RSTRING(str)->len);
TRAP_END;
- if (n == -1) rb_sys_fail(fptr->path);
+ if (n == -1) {
+ rb_str_resize(str, 0);
+ rb_sys_fail(fptr->path);
+ }
if (n == 0 && ilen > 0) {
+ rb_str_resize(str, 0);
rb_eof_error();
}
@@ -1208,11 +2138,20 @@ rb_io_sysread(io, len)
return str;
}
+/*
+ * call-seq:
+ * ios.binmode => ios
+ *
+ * Puts <em>ios</em> into binary mode. This is useful only in
+ * MS-DOS/Windows environments. Once a stream is in binary mode, it
+ * cannot be reset to nonbinary mode.
+ */
+
VALUE
rb_io_binmode(io)
VALUE io;
{
-#if defined(NT) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__EMX__)
+#if defined(_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__EMX__)
OpenFile *fptr;
GetOpenFile(io, fptr);
@@ -1233,59 +2172,98 @@ rb_io_binmode(io)
return io;
}
+char*
+rb_io_flags_mode(flags)
+ int flags;
+{
+#ifdef O_BINARY
+# define MODE_BINMODE(a,b) ((flags & FMODE_BINMODE) ? (b) : (a))
+#else
+# define MODE_BINMODE(a,b) (a)
+#endif
+ if (flags & FMODE_APPEND) {
+ if ((flags & FMODE_READWRITE) == FMODE_READWRITE) {
+ return MODE_BINMODE("a+", "ab+");
+ }
+ return MODE_BINMODE("a", "ab");
+ }
+ switch (flags & FMODE_READWRITE) {
+ case FMODE_READABLE:
+ return MODE_BINMODE("r", "rb");
+ case FMODE_WRITABLE:
+ return MODE_BINMODE("w", "wb");
+ case FMODE_READWRITE:
+ if (flags & FMODE_CREATE) {
+ return MODE_BINMODE("w+", "wb+");
+ }
+ return MODE_BINMODE("r+", "rb+");
+ }
+ rb_raise(rb_eArgError, "illegal access mode %o", flags);
+ return NULL; /* not reached */
+}
+
int
rb_io_mode_flags(mode)
const char *mode;
{
int flags = 0;
+ const char *m = mode;
- switch (mode[0]) {
+ switch (*m++) {
case 'r':
flags |= FMODE_READABLE;
break;
case 'w':
- flags |= FMODE_WRITABLE;
+ flags |= FMODE_WRITABLE | FMODE_CREATE;
break;
case 'a':
- flags |= FMODE_WRITABLE;
+ flags |= FMODE_WRITABLE | FMODE_APPEND | FMODE_CREATE;
break;
default:
error:
rb_raise(rb_eArgError, "illegal access mode %s", mode);
}
- if (mode[1] == 'b') {
- flags |= FMODE_BINMODE;
- mode++;
- }
-
- if (mode[1] == '+') {
- flags |= FMODE_READWRITE;
- if (mode[2] != 0) goto error;
+ while (*m) {
+ switch (*m++) {
+ case 'b':
+ flags |= FMODE_BINMODE;
+ break;
+ case '+':
+ flags |= FMODE_READWRITE;
+ break;
+ default:
+ goto error;
+ }
}
- else if (mode[1] != 0) goto error;
return flags;
}
static int
-rb_io_mode_flags2(mode)
+rb_io_modenum_flags(mode)
int mode;
{
- int flags;
+ int flags = 0;
switch (mode & (O_RDONLY|O_WRONLY|O_RDWR)) {
- case O_RDONLY:
+ case O_RDONLY:
flags = FMODE_READABLE;
break;
case O_WRONLY:
flags = FMODE_WRITABLE;
break;
case O_RDWR:
- flags = FMODE_WRITABLE|FMODE_READABLE;
+ flags = FMODE_READWRITE;
break;
}
+ if (mode & O_APPEND) {
+ flags |= FMODE_APPEND;
+ }
+ if (mode & O_CREAT) {
+ flags |= FMODE_CREATE;
+ }
#ifdef O_BINARY
if (mode & O_BINARY) {
flags |= FMODE_BINMODE;
@@ -1295,52 +2273,88 @@ rb_io_mode_flags2(mode)
return flags;
}
-static char*
-rb_io_flags_mode(flags)
- int flags;
+static int
+rb_io_mode_modenum(mode)
+ const char *mode;
{
- static char mode[4];
- char *p = mode;
+ int flags = 0;
+ const char *m = mode;
- switch (flags & (O_RDONLY|O_WRONLY|O_RDWR)) {
- case O_RDONLY:
- *p++ = 'r';
+ switch (*m++) {
+ case 'r':
+ flags |= O_RDONLY;
break;
- case O_WRONLY:
- *p++ = 'w';
+ case 'w':
+ flags |= O_WRONLY | O_CREAT | O_TRUNC;
break;
- case O_RDWR:
- *p++ = 'w';
- *p++ = '+';
+ case 'a':
+ flags |= O_WRONLY | O_CREAT | O_APPEND;
break;
+ default:
+ error:
+ rb_raise(rb_eArgError, "illegal access mode %s", mode);
}
- *p++ = '\0';
+
+ while (*m) {
+ switch (*m++) {
+ case 'b':
#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';
- }
+ flags |= O_BINARY;
+#endif
+ break;
+ case '+':
+ flags |= O_RDWR;
+ break;
+ default:
+ goto error;
+ }
}
+
+ return flags;
+}
+
+#define MODENUM_MAX 4
+
+static char*
+rb_io_modenum_mode(flags)
+ int flags;
+{
+#ifdef O_BINARY
+# define MODE_BINARY(a,b) ((flags & O_BINARY) ? (b) : (a))
+#else
+# define MODE_BINARY(a,b) (a)
#endif
- return mode;
+ if (flags & O_APPEND) {
+ if ((flags & O_RDWR) == O_RDWR) {
+ return MODE_BINARY("a+", "ab+");
+ }
+ return MODE_BINARY("a", "ab");
+ }
+ switch (flags & (O_RDONLY|O_WRONLY|O_RDWR)) {
+ case O_RDONLY:
+ return MODE_BINARY("r", "rb");
+ case O_WRONLY:
+ return MODE_BINARY("w", "wb");
+ case O_RDWR:
+ return MODE_BINARY("r+", "rb+");
+ }
+ rb_raise(rb_eArgError, "illegal access modenum %o", flags);
+ return NULL; /* not reached */
}
static int
-rb_sysopen(fname, flag, mode)
+rb_sysopen(fname, flags, mode)
char *fname;
- int flag;
+ int flags;
unsigned int mode;
{
int fd;
- fd = open(fname, flag, mode);
+ fd = open(fname, flags, mode);
if (fd < 0) {
if (errno == EMFILE || errno == ENFILE) {
rb_gc();
- fd = open(fname, flag, mode);
+ fd = open(fname, flags, mode);
}
if (fd < 0) {
rb_sys_fail(fname);
@@ -1368,7 +2382,7 @@ rb_fopen(fname, mode)
}
#ifdef USE_SETVBUF
if (setvbuf(file, NULL, _IOFBF, 0) != 0)
- rb_warn("setvbuf() can't be honered for %s", fname);
+ rb_warn("setvbuf() can't be honoured for %s", fname);
#endif
#ifdef __human68k__
fmode(file, _IOTEXT);
@@ -1383,21 +2397,37 @@ rb_fdopen(fd, mode)
{
FILE *file;
+#if defined(sun)
+ errno = 0;
+#endif
file = fdopen(fd, mode);
if (!file) {
+#if defined(sun)
+ if (errno == 0 || errno == EMFILE || errno == ENFILE) {
+#else
if (errno == EMFILE || errno == ENFILE) {
+#endif
rb_gc();
+#if defined(sun)
+ errno = 0;
+#endif
file = fdopen(fd, mode);
}
if (!file) {
+#ifdef _WIN32
+ if (errno == 0) errno = EINVAL;
+#endif
+#if defined(sun)
+ if (errno == 0) errno = EMFILE;
+#endif
rb_sys_fail(0);
}
}
+
#ifdef USE_SETVBUF
if (setvbuf(file, NULL, _IOFBF, 0) != 0)
- rb_warn("setvbuf() can't be honered (fd=%d)", fd);
+ rb_warn("setvbuf() can't be honoured (fd=%d)", fd);
#endif
-
return file;
}
@@ -1411,8 +2441,8 @@ rb_file_open_internal(io, fname, mode)
MakeOpenFile(io, fptr);
fptr->mode = rb_io_mode_flags(mode);
- fptr->f = rb_fopen(fname, mode);
fptr->path = strdup(fname);
+ fptr->f = rb_fopen(fptr->path, rb_io_flags_mode(fptr->mode));
return io;
}
@@ -1421,9 +2451,7 @@ VALUE
rb_file_open(fname, mode)
const char *fname, *mode;
{
- NEWOBJ(io, struct RFile);
- OBJSETUP(io, rb_cFile, T_FILE);
- return rb_file_open_internal((VALUE)io, fname, mode);
+ return rb_file_open_internal(io_alloc(rb_cFile), fname, mode);
}
static VALUE
@@ -1438,11 +2466,11 @@ rb_file_sysopen_internal(io, fname, flags, mode)
MakeOpenFile(io, fptr);
- fd = rb_sysopen(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);
+ m = rb_io_modenum_mode(flags);
+ fptr->mode = rb_io_modenum_flags(flags);
+ fd = rb_sysopen(fptr->path, flags, mode);
+ fptr->f = rb_fdopen(fd, m);
return io;
}
@@ -1452,12 +2480,10 @@ rb_file_sysopen(fname, flags, mode)
const char *fname;
int flags, mode;
{
- NEWOBJ(io, struct RFile);
- OBJSETUP(io, rb_cFile, T_FILE);
- return rb_file_sysopen_internal((VALUE)io, fname, flags, mode);
+ return rb_file_sysopen_internal(io_alloc(rb_cFile), fname, flags, mode);
}
-#if defined (NT) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__)
+#if defined (_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__) || defined(__VMS)
static struct pipe_list {
OpenFile *fptr;
struct pipe_list *next;
@@ -1499,7 +2525,6 @@ pipe_del_fptr(fptr)
}
}
-#if defined (NT) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__)
static void
pipe_atexit _((void))
{
@@ -1512,13 +2537,15 @@ pipe_atexit _((void))
list = tmp;
}
}
-#endif
+
+static void pipe_finalize _((OpenFile *fptr,int));
static void
-pipe_finalize(fptr)
+pipe_finalize(fptr, noraise)
OpenFile *fptr;
+ int noraise;
{
-#if !defined (__CYGWIN__)
+#if !defined (__CYGWIN__) && !defined(_WIN32)
extern VALUE rb_last_status;
int status;
if (fptr->f) {
@@ -1533,7 +2560,7 @@ pipe_finalize(fptr)
#endif
rb_last_status = INT2FIX(status);
#else
- fptr_finalize(fptr);
+ fptr_finalize(fptr, noraise);
#endif
pipe_del_fptr(fptr);
}
@@ -1553,20 +2580,26 @@ rb_io_unbuffered(fptr)
rb_io_synchronized(fptr);
}
+static VALUE pipe_open(VALUE pstr, char *pname, char *mode);
+
static VALUE
-pipe_open(pname, mode)
+pipe_open(pstr, pname, mode)
+ VALUE pstr;
char *pname, *mode;
{
int modef = rb_io_mode_flags(mode);
OpenFile *fptr;
-#if defined(NT) || defined(DJGPP) || defined(__human68k__)
- FILE *f = popen(pname, mode);
+#if defined(DJGPP) || defined(__human68k__) || defined(__VMS)
+ FILE *f;
+ if (!pname) pname = StringValuePtr(pstr);
+ f = popen(pname, mode);
+
if (!f) rb_sys_fail(pname);
else {
- NEWOBJ(port, struct RFile);
- OBJSETUP(port, rb_cIO, T_FILE);
+ VALUE port = io_alloc(rb_cIO);
+
MakeOpenFile(port, fptr);
fptr->finalize = pipe_finalize;
fptr->mode = modef;
@@ -1581,9 +2614,46 @@ pipe_open(pname, mode)
return (VALUE)port;
}
#else
+#ifdef _WIN32
+ int pid;
+ FILE *fpr, *fpw;
+
+ if (!pname) pname = StringValuePtr(pstr);
+
+retry:
+ pid = pipe_exec(pname, rb_io_mode_modenum(mode), &fpr, &fpw);
+ if (pid == -1) { /* exec failed */
+ if (errno == EAGAIN) {
+ rb_thread_sleep(1);
+ goto retry;
+ }
+ rb_sys_fail(pname);
+ }
+ else {
+ VALUE port = io_alloc(rb_cIO);
+
+ MakeOpenFile(port, fptr);
+ fptr->mode = modef;
+ fptr->mode |= FMODE_SYNC;
+ fptr->pid = pid;
+
+ if (modef & FMODE_READABLE) {
+ fptr->f = fpr;
+ }
+ if (modef & FMODE_WRITABLE) {
+ if (fptr->f) fptr->f2 = fpw;
+ else fptr->f = fpw;
+ }
+ fptr->finalize = pipe_finalize;
+ pipe_add_fptr(fptr);
+ return (VALUE)port;
+ }
+#else
int pid, pr[2], pw[2];
volatile int doexec;
+ if (!pname) pname = StringValuePtr(pstr);
+
if (((modef & FMODE_READABLE) && pipe(pr) == -1) ||
((modef & FMODE_WRITABLE) && pipe(pw) == -1))
rb_sys_fail(pname);
@@ -1596,7 +2666,7 @@ pipe_open(pname, mode)
}
retry:
- switch (pid = (doexec?vfork():fork())) {
+ switch ((pid = fork())) {
case 0: /* child */
if (modef & FMODE_READABLE) {
close(pr[0]);
@@ -1639,8 +2709,8 @@ pipe_open(pname, mode)
default: /* parent */
if (pid < 0) rb_sys_fail(pname);
else {
- NEWOBJ(port, struct RFile);
- OBJSETUP(port, rb_cIO, T_FILE);
+ VALUE port = io_alloc(rb_cIO);
+
MakeOpenFile(port, fptr);
fptr->mode = modef;
fptr->mode |= FMODE_SYNC;
@@ -1661,15 +2731,56 @@ pipe_open(pname, mode)
fptr->finalize = pipe_finalize;
pipe_add_fptr(fptr);
#endif
- return (VALUE)port;
+ return port;
}
}
#endif
+#endif
}
+/*
+ * call-seq:
+ * IO.popen(cmd_string, mode="r" ) => io
+ * IO.popen(cmd_string, mode="r" ) {|io| block } => obj
+ *
+ * Runs the specified command string as a subprocess; the subprocess's
+ * standard input and output will be connected to the returned
+ * <code>IO</code> object. If <i>cmd_string</i> starts with a
+ * ``<code>-</code>'', then a new instance of Ruby is started as the
+ * subprocess. The default mode for the new file object is ``r'', but
+ * <i>mode</i> may be set to any of the modes listed in the description
+ * for class IO.
+ *
+ * If a block is given, Ruby will run the command as a child connected
+ * to Ruby with a pipe. Ruby's end of the pipe will be passed as a
+ * parameter to the block. In this case <code>IO::popen</code> returns
+ * the value of the block.
+ *
+ * If a block is given with a <i>cmd_string</i> of ``<code>-</code>'',
+ * the block will be run in two separate processes: once in the parent,
+ * and once in a child. The parent process will be passed the pipe
+ * object as a parameter to the block, the child version of the block
+ * will be passed <code>nil</code>, and the child's standard in and
+ * standard out will be connected to the parent through the pipe. Not
+ * available on all platforms.
+ *
+ * f = IO.popen("uname")
+ * p f.readlines
+ * puts "Parent is #{Process.pid}"
+ * IO.popen ("date") { |f| puts f.gets }
+ * IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f is #{f}"}
+ *
+ * <em>produces:</em>
+ *
+ * ["Linux\n"]
+ * Parent is 26166
+ * Wed Apr 9 08:53:52 CDT 2003
+ * 26169 is here, f is
+ * 26166 is here, f is #<IO:0x401b3d44>
+ */
+
static VALUE
-rb_io_popen(str, argc, argv, klass)
- char *str;
+rb_io_s_popen(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
@@ -1680,11 +2791,14 @@ rb_io_popen(str, argc, argv, klass)
if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) {
mode = "r";
}
+ else if (FIXNUM_P(pmode)) {
+ mode = rb_io_modenum_mode(FIX2INT(pmode));
+ }
else {
- mode = STR2CSTR(pmode);
+ mode = rb_io_flags_mode(rb_io_mode_flags(StringValuePtr(pmode)));
}
- Check_SafeStr(pname);
- port = pipe_open(str, mode);
+ SafeStringValue(pname);
+ port = pipe_open(pname, 0, mode);
if (NIL_P(port)) {
/* child */
if (rb_block_given_p()) {
@@ -1697,72 +2811,207 @@ rb_io_popen(str, argc, argv, klass)
}
RBASIC(port)->klass = klass;
if (rb_block_given_p()) {
- return rb_ensure(rb_yield, port, rb_io_close, port);
+ return rb_ensure(rb_yield, port, io_close, port);
}
return port;
}
static VALUE
-rb_io_s_popen(argc, argv, klass)
+rb_open_file(argc, argv, io)
int argc;
VALUE *argv;
- VALUE klass;
+ VALUE io;
{
- char *str = 0;
+ VALUE fname, vmode, perm;
+ char *mode;
+ int flags, fmode;
- if (argc >= 1) {
- str = STR2CSTR(argv[0]);
+ rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
+ SafeStringValue(fname);
+
+ if (FIXNUM_P(vmode) || !NIL_P(perm)) {
+ if (FIXNUM_P(vmode)) {
+ flags = FIX2INT(vmode);
+ }
+ else {
+ SafeStringValue(vmode);
+ flags = rb_io_mode_modenum(RSTRING(vmode)->ptr);
+ }
+ fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
+
+ rb_file_sysopen_internal(io, RSTRING(fname)->ptr, flags, fmode);
+ }
+ else {
+ mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
+ rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
}
- return rb_io_popen(str, argc, argv, klass);
+ return io;
}
+/*
+ * call-seq:
+ * IO.open(fd, mode_string="r" ) => io
+ * IO.open(fd, mode_string="r" ) {|io| block } => obj
+ *
+ * With no associated block, <code>open</code> is a synonym for
+ * <code>IO::new</code>. If the optional code block is given, it will
+ * be passed <i>io</i> as an argument, and the IO object will
+ * automatically be closed when the block terminates. In this instance,
+ * <code>IO::open</code> returns the value of the block.
+ *
+ */
+
static VALUE
-rb_file_s_open(argc, argv, klass)
+rb_io_s_open(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
- VALUE fname, vmode, file, perm;
- char *path, *mode;
-
- NEWOBJ(io, struct RFile);
- OBJSETUP(io, klass, T_FILE);
- rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
- Check_SafeStr(fname);
- path = RSTRING(fname)->ptr;
-
- RFILE(io)->fptr = 0;
- if (FIXNUM_P(vmode)) {
- int flags = NUM2INT(vmode);
- int fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
-
- file = rb_file_sysopen_internal((VALUE)io, path, flags, fmode);
- }
- else {
- mode = NIL_P(vmode) ? "r" : STR2CSTR(vmode);
- file = rb_file_open_internal((VALUE)io, RSTRING(fname)->ptr, mode);
- }
+ VALUE io = rb_class_new_instance(argc, argv, klass);
if (rb_block_given_p()) {
- return rb_ensure(rb_yield, file, rb_io_close, file);
+ return rb_ensure(rb_yield, io, io_close, io);
}
- return file;
+ return io;
}
+/*
+ * call-seq:
+ * IO.sysopen(path, [mode, [perm]]) => fixnum
+ *
+ * Opens the given path, returning the underlying file descriptor as a
+ * <code>Fixnum</code>.
+ *
+ * IO.sysopen("testfile") #=> 3
+ *
+ */
+
+static VALUE
+rb_io_s_sysopen(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE fname, vmode, perm;
+ int flags, fmode, fd;
+ char *path;
+
+ rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
+ SafeStringValue(fname);
+
+ if (NIL_P(vmode)) flags = O_RDONLY;
+ else if (FIXNUM_P(vmode)) flags = FIX2INT(vmode);
+ else {
+ SafeStringValue(vmode);
+ flags = rb_io_mode_modenum(RSTRING(vmode)->ptr);
+ }
+ if (NIL_P(perm)) fmode = 0666;
+ else fmode = NUM2INT(perm);
+
+ path = ALLOCA_N(char, strlen(RSTRING(fname)->ptr)+1);
+ strcpy(path, RSTRING(fname)->ptr);
+ fd = rb_sysopen(path, flags, fmode);
+ return INT2NUM(fd);
+}
+
+/*
+ * call-seq:
+ * open(path [, mode [, perm]] ) => io or nil
+ * open(path [, mode [. perm]] ) {|io| block } => nil
+ *
+ * Creates an <code>IO</code> object connected to the given stream,
+ * file, or subprocess.
+ *
+ * If <i>path</i> does not start with a pipe character
+ * (``<code>|</code>''), treat it as the name of a file to open using
+ * the specified mode (defaulting to ``<code>r</code>''). (See the table
+ * of valid modes on page 331.) If a file is being created, its initial
+ * permissions may be set using the integer third parameter.
+ *
+ * If a block is specified, it will be invoked with the
+ * <code>File</code> object as a parameter, and the file will be
+ * automatically closed when the block terminates. The call always
+ * returns <code>nil</code> in this case.
+ *
+ * If <i>path</i> starts with a pipe character, a subprocess is
+ * created, connected to the caller by a pair of pipes. The returned
+ * <code>IO</code> object may be used to write to the standard input
+ * and read from the standard output of this subprocess. If the command
+ * following the ``<code>|</code>'' is a single minus sign, Ruby forks,
+ * and this subprocess is connected to the parent. In the subprocess,
+ * the <code>open</code> call returns <code>nil</code>. If the command
+ * is not ``<code>-</code>'', the subprocess runs the command. If a
+ * block is associated with an <code>open("|-")</code> call, that block
+ * will be run twice---once in the parent and once in the child. The
+ * block parameter will be an <code>IO</code> object in the parent and
+ * <code>nil</code> in the child. The parent's <code>IO</code> object
+ * will be connected to the child's <code>$stdin</code> and
+ * <code>$stdout</code>. The subprocess will be terminated at the end
+ * of the block.
+ *
+ * open("testfile") do |f|
+ * print f.gets
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * This is line one
+ *
+ * Open a subprocess and read its output:
+ *
+ * cmd = open("|date")
+ * print cmd.gets
+ * cmd.close
+ *
+ * <em>produces:</em>
+ *
+ * Wed Apr 9 08:56:31 CDT 2003
+ *
+ * Open a subprocess running the same Ruby program:
+ *
+ * f = open("|-", "w+")
+ * if f == nil
+ * puts "in Child"
+ * exit
+ * else
+ * puts "Got: #{f.gets}"
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * Got: in Child
+ *
+ * Open a subprocess using a block to receive the I/O object:
+ *
+ * open("|-") do |f|
+ * if f == nil
+ * puts "in Child"
+ * else
+ * puts "Got: #{f.gets}"
+ * end
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * Got: in Child
+ */
+
static VALUE
rb_f_open(argc, argv)
int argc;
VALUE *argv;
{
if (argc >= 1) {
- char *str = STR2CSTR(argv[0]);
+ char *str = StringValuePtr(argv[0]);
if (str[0] == '|') {
- return rb_io_popen(str+1, argc, argv, rb_cIO);
+ VALUE tmp = rb_str_new(str+1, RSTRING(argv[0])->len-1);
+ OBJ_INFECT(tmp, argv[0]);
+ argv[0] = tmp;
+ return rb_io_s_popen(argc, argv, rb_cIO);
}
}
- return rb_file_s_open(argc, argv, rb_cFile);
+ return rb_io_s_open(argc, argv, rb_cFile);
}
static VALUE
@@ -1770,7 +3019,7 @@ rb_io_open(fname, mode)
char *fname, *mode;
{
if (fname[0] == '|') {
- return pipe_open(fname+1, mode);
+ return pipe_open(0, fname+1, mode);
}
else {
return rb_file_open(fname, mode);
@@ -1784,6 +3033,13 @@ rb_io_get_io(io)
return rb_convert_type(io, T_FILE, "IO", "to_io");
}
+static VALUE
+rb_io_check_io(io)
+ VALUE io;
+{
+ return rb_check_convert_type(io, T_FILE, "IO", "to_io");
+}
+
static char*
rb_io_mode_string(fptr)
OpenFile *fptr;
@@ -1805,8 +3061,8 @@ io_reopen(io, nfile)
{
OpenFile *fptr, *orig;
char *mode;
- int fd;
- long pos;
+ int fd, fd2;
+ off_t pos = 0;
nfile = rb_io_get_io(nfile);
if (rb_safe_level() >= 4 && (!OBJ_TAINTED(io) || !OBJ_TAINTED(nfile))) {
@@ -1817,15 +3073,17 @@ io_reopen(io, nfile)
if (fptr == orig) return io;
if (orig->mode & FMODE_READABLE) {
- pos = ftell(orig->f);
+ pos = io_tell(orig);
}
if (orig->f2) {
- io_fflush(orig->f2, orig->path);
+ io_fflush(orig->f2, orig);
}
else if (orig->mode & FMODE_WRITABLE) {
- io_fflush(orig->f, orig->path);
+ io_fflush(orig->f, orig);
+ }
+ if (fptr->mode & FMODE_WRITABLE) {
+ io_fflush(GetWriteFile(fptr), fptr);
}
- rb_thread_fd_close(fileno(fptr->f));
/* copy OpenFile structure */
fptr->mode = orig->mode;
@@ -1838,34 +3096,41 @@ io_reopen(io, nfile)
mode = rb_io_mode_string(fptr);
fd = fileno(fptr->f);
- if (fd < 3) {
- clearerr(fptr->f);
- /* need to keep stdio objects */
- if (dup2(fileno(orig->f), fd) < 0)
- rb_sys_fail(orig->path);
- }
- else {
- fclose(fptr->f);
- if (dup2(fileno(orig->f), fd) < 0)
- rb_sys_fail(orig->path);
- fptr->f = rb_fdopen(fd, mode);
- }
- if ((orig->mode & FMODE_READABLE) && pos >= 0) {
- fseek(fptr->f, pos, SEEK_SET);
- fseek(orig->f, pos, SEEK_SET);
+ fd2 = fileno(orig->f);
+ if (fd != fd2) {
+ if (fptr->f == stdin || fptr->f == stdout || fptr->f == stderr) {
+ clearerr(fptr->f);
+ /* need to keep stdio objects */
+ if (dup2(fd2, fd) < 0)
+ rb_sys_fail(orig->path);
+ }
+ else {
+ fclose(fptr->f);
+ if (dup2(fd2, fd) < 0)
+ rb_sys_fail(orig->path);
+ fptr->f = rb_fdopen(fd, mode);
+ }
+ rb_thread_fd_close(fd);
+ if ((orig->mode & FMODE_READABLE) && pos >= 0) {
+ io_seek(fptr, pos, SEEK_SET);
+ io_seek(orig, pos, SEEK_SET);
+ }
}
- if (fptr->f2) {
+ if (fptr->f2 && fd != fileno(fptr->f2)) {
fd = fileno(fptr->f2);
- fclose(fptr->f2);
- if (orig->f2) {
- if (dup2(fileno(orig->f2), fd) < 0)
+ if (!orig->f2) {
+ fclose(fptr->f2);
+ rb_thread_fd_close(fd);
+ fptr->f2 = 0;
+ }
+ else if (fd != (fd2 = fileno(orig->f2))) {
+ fclose(fptr->f2);
+ rb_thread_fd_close(fd);
+ if (dup2(fd2, fd) < 0)
rb_sys_fail(orig->path);
fptr->f2 = rb_fdopen(fd, "w");
}
- else {
- fptr->f2 = 0;
- }
}
if (fptr->mode & FMODE_BINMODE) {
@@ -1876,6 +3141,22 @@ io_reopen(io, nfile)
return io;
}
+/*
+ * call-seq:
+ * ios.reopen(other_IO) => ios
+ * ios.reopen(path, mode_str) => ios
+ *
+ * Reassociates <em>ios</em> with the I/O stream given in
+ * <i>other_IO</i> or to a new stream opened on <i>path</i>. This may
+ * dynamically change the actual class of this stream.
+ *
+ * f1 = File.new("testfile")
+ * f2 = File.new("testfile")
+ * f2.readlines[0] #=> "This is line one\n"
+ * f2.reopen(f1) #=> #<File:testfile>
+ * f2.readlines[0] #=> "This is line one\n"
+ */
+
static VALUE
rb_io_reopen(argc, argv, file)
int argc;
@@ -1888,34 +3169,37 @@ rb_io_reopen(argc, argv, file)
rb_secure(4);
if (rb_scan_args(argc, argv, "11", &fname, &nmode) == 1) {
- if (TYPE(fname) != T_STRING) { /* fname must be IO */
- return io_reopen(file, fname);
+ VALUE tmp = rb_io_check_io(fname);
+ if (!NIL_P(tmp)) {
+ return io_reopen(file, tmp);
}
}
- Check_SafeStr(fname);
- if (!NIL_P(nmode)) {
- mode = STR2CSTR(nmode);
+ SafeStringValue(fname);
+ rb_io_taint_check(file);
+ fptr = RFILE(file)->fptr;
+ if (!fptr) {
+ fptr = RFILE(file)->fptr = ALLOC(OpenFile);
+ MEMZERO(fptr, OpenFile, 1);
}
- else {
- mode = "r";
+
+ if (!NIL_P(nmode)) {
+ fptr->mode = rb_io_mode_flags(StringValuePtr(nmode));
}
- GetOpenFile(file, fptr);
if (fptr->path) {
free(fptr->path);
fptr->path = 0;
}
fptr->path = strdup(RSTRING(fname)->ptr);
- fptr->mode = rb_io_mode_flags(mode);
+ mode = rb_io_flags_mode(fptr->mode);
if (!fptr->f) {
- fptr->f = rb_fopen(RSTRING(fname)->ptr, mode);
+ fptr->f = rb_fopen(fptr->path, mode);
if (fptr->f2) {
fclose(fptr->f2);
fptr->f2 = 0;
}
-
return file;
}
@@ -1924,7 +3208,7 @@ rb_io_reopen(argc, argv, file)
}
#ifdef USE_SETVBUF
if (setvbuf(fptr->f, NULL, _IOFBF, 0) != 0)
- rb_warn("setvbuf() can't be honered for %s", RSTRING(fname)->ptr);
+ rb_warn("setvbuf() can't be honoured for %s", RSTRING(fname)->ptr);
#endif
if (fptr->f2) {
@@ -1937,25 +3221,27 @@ rb_io_reopen(argc, argv, file)
}
static VALUE
-rb_io_clone(io)
- VALUE io;
+rb_io_init_copy(dest, io)
+ VALUE dest, io;
{
- VALUE klass;
OpenFile *fptr, *orig;
int fd;
char *mode;
- NEWOBJ(clone, struct RFile);
- CLONESETUP(clone, io);
-
+ io = rb_io_get_io(io);
+ if (dest == io) return dest;
GetOpenFile(io, orig);
- MakeOpenFile(clone, fptr);
+ MakeOpenFile(dest, fptr);
if (orig->f2) {
- io_fflush(orig->f2, orig->path);
+ io_fflush(orig->f2, orig);
+ fseeko(orig->f, 0L, SEEK_CUR);
}
else if (orig->mode & FMODE_WRITABLE) {
- io_fflush(orig->f, orig->path);
+ io_fflush(orig->f, orig);
+ }
+ else {
+ fseeko(orig->f, 0L, SEEK_CUR);
}
/* copy OpenFile structure */
@@ -1976,20 +3262,33 @@ rb_io_clone(io)
else mode = "r+";
break;
}
- fd = rb_dup(fileno(orig->f));
+ fd = ruby_dup(fileno(orig->f));
fptr->f = rb_fdopen(fd, mode);
- if (fptr->f2) {
- fd = rb_dup(fileno(orig->f2));
- fptr->f = rb_fdopen(fd, "w");
+ fseeko(fptr->f, ftello(orig->f), SEEK_SET);
+ if (orig->f2) {
+ if (fileno(orig->f) != fileno(orig->f2)) {
+ fd = ruby_dup(fileno(orig->f2));
+ }
+ fptr->f2 = rb_fdopen(fd, "w");
+ fseeko(fptr->f2, ftello(orig->f2), SEEK_SET);
}
if (fptr->mode & FMODE_BINMODE) {
- rb_io_binmode((VALUE)clone);
+ rb_io_binmode(dest);
}
- return (VALUE)clone;
+ return dest;
}
-static VALUE
+/*
+ * call-seq:
+ * ios.printf(format_string [, obj, ...] ) => nil
+ *
+ * Formats and writes to <em>ios</em>, converting parameters under
+ * control of the format string. See <code>Kernel#sprintf</code>
+ * for details.
+ */
+
+VALUE
rb_io_printf(argc, argv, out)
int argc;
VALUE argv[];
@@ -1999,6 +3298,17 @@ rb_io_printf(argc, argv, out)
return Qnil;
}
+/*
+ * call-seq:
+ * printf(io, string [, obj ... ] ) => nil
+ * printf(string [, obj ... ] ) => nil
+ *
+ * Equivalent to:
+ * io.write(sprintf(string, obj, ...)
+ * or
+ * $stdout.write(sprintf(string, obj, ...)
+ */
+
static VALUE
rb_f_printf(argc, argv)
int argc;
@@ -2008,7 +3318,7 @@ rb_f_printf(argc, argv)
if (argc == 0) return Qnil;
if (TYPE(argv[0]) == T_STRING) {
- out = rb_defout;
+ out = rb_stdout;
}
else {
out = argv[0];
@@ -2020,7 +3330,27 @@ rb_f_printf(argc, argv)
return Qnil;
}
-static VALUE
+/*
+ * call-seq:
+ * ios.print() => nil
+ * ios.print(obj, ...) => nil
+ *
+ * Writes the given object(s) to <em>ios</em>. The stream must be
+ * opened for writing. If the output record separator (<code>$\</code>)
+ * is not <code>nil</code>, it will be appended to the output. If no
+ * arguments are given, prints <code>$_</code>. Objects that aren't
+ * strings will be converted by calling their <code>to_s</code> method.
+ * With no argument, prints the contents of the variable <code>$_</code>.
+ * Returns <code>nil</code>.
+ *
+ * $stdout.print("This is ", 100, " percent.\n")
+ *
+ * <em>produces:</em>
+ *
+ * This is 100 percent.
+ */
+
+VALUE
rb_io_print(argc, argv, out)
int argc;
VALUE *argv;
@@ -2055,52 +3385,86 @@ rb_io_print(argc, argv, out)
return Qnil;
}
+/*
+ * call-seq:
+ * print(obj, ...) => nil
+ *
+ * Prints each object in turn to <code>$stdout</code>. If the output
+ * field separator (<code>$,</code>) is not +nil+, its
+ * contents will appear between each field. If the output record
+ * separator (<code>$\</code>) is not +nil+, it will be
+ * appended to the output. If no arguments are given, prints
+ * <code>$_</code>. Objects that aren't strings will be converted by
+ * calling their <code>to_s</code> method.
+ *
+ * print "cat", [1,2,3], 99, "\n"
+ * $, = ", "
+ * $\ = "\n"
+ * print "cat", [1,2,3], 99
+ *
+ * <em>produces:</em>
+ *
+ * cat12399
+ * cat, 1, 2, 3, 99
+ */
+
static VALUE
rb_f_print(argc, argv)
int argc;
VALUE *argv;
{
- rb_io_print(argc, argv, rb_defout);
+ rb_io_print(argc, argv, rb_stdout);
return Qnil;
}
+/*
+ * call-seq:
+ * ios.putc(obj) => obj
+ *
+ * If <i>obj</i> is <code>Numeric</code>, write the character whose
+ * code is <i>obj</i>, otherwise write the first character of the
+ * string representation of <i>obj</i> to <em>ios</em>.
+ *
+ * $stdout.putc "A"
+ * $stdout.putc 65
+ *
+ * <em>produces:</em>
+ *
+ * AA
+ */
+
static VALUE
rb_io_putc(io, ch)
VALUE io, ch;
{
- OpenFile *fptr;
- FILE *f;
- int c = NUM2CHR(ch);
-
- rb_secure(4);
- GetOpenFile(io, fptr);
- rb_io_check_writable(fptr);
- f = GetWriteFile(fptr);
-
- if (fputc(c, f) == EOF)
- rb_sys_fail(fptr->path);
- if (fptr->mode & FMODE_SYNC) {
- io_fflush(f, fptr->path);
- }
+ char c = NUM2CHR(ch);
+ rb_io_write(io, rb_str_new(&c, 1));
return ch;
}
+/*
+ * call-seq:
+ * putc(int) => int
+ *
+ * Equivalent to:
+ *
+ * $stdout.putc(int)
+ */
+
static VALUE
rb_f_putc(recv, ch)
VALUE recv, ch;
{
- return rb_io_putc(rb_defout, ch);
+ return rb_io_putc(rb_stdout, ch);
}
-static VALUE rb_io_puts _((int, VALUE*, VALUE));
-
static VALUE
io_puts_ary(ary, out)
VALUE ary, out;
{
VALUE tmp;
- int i;
+ long i;
for (i=0; i<RARRAY(ary)->len; i++) {
tmp = RARRAY(ary)->ptr[i];
@@ -2112,7 +3476,27 @@ io_puts_ary(ary, out)
return Qnil;
}
-static VALUE
+/*
+ * call-seq:
+ * ios.puts(obj, ...) => nil
+ *
+ * Writes the given objects to <em>ios</em> as with
+ * <code>IO#print</code>. Writes a record separator (typically a
+ * newline) after any that do not already end with a newline sequence.
+ * If called with an array argument, writes each element on a new line.
+ * If called without arguments, outputs a single record separator.
+ *
+ * $stdout.puts("this", "is", "a", "test")
+ *
+ * <em>produces:</em>
+ *
+ * this
+ * is
+ * a
+ * test
+ */
+
+VALUE
rb_io_puts(argc, argv, out)
int argc;
VALUE *argv;
@@ -2127,20 +3511,20 @@ rb_io_puts(argc, argv, out)
return Qnil;
}
for (i=0; i<argc; i++) {
- switch (TYPE(argv[i])) {
- case T_NIL:
+ if (NIL_P(argv[i])) {
line = rb_str_new2("nil");
- break;
- case T_ARRAY:
- rb_protect_inspect(io_puts_ary, argv[i], out);
- continue;
- default:
- line = argv[i];
- break;
}
- line = rb_obj_as_string(line);
+ else {
+ line = rb_check_array_type(argv[i]);
+ if (!NIL_P(line)) {
+ rb_protect_inspect(io_puts_ary, line, out);
+ continue;
+ }
+ line = rb_obj_as_string(argv[i]);
+ }
rb_io_write(out, line);
- if (RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') {
+ if (RSTRING(line)->len == 0 ||
+ RSTRING(line)->ptr[RSTRING(line)->len-1] != '\n') {
rb_io_write(out, rb_default_rs);
}
}
@@ -2148,12 +3532,21 @@ rb_io_puts(argc, argv, out)
return Qnil;
}
+/*
+ * call-seq:
+ * puts(obj, ...) => nil
+ *
+ * Equivalent to
+ *
+ * $stdout.puts(obj, ...)
+ */
+
static VALUE
rb_f_puts(argc, argv)
int argc;
VALUE *argv;
{
- rb_io_puts(argc, argv, rb_defout);
+ rb_io_puts(argc, argv, rb_stdout);
return Qnil;
}
@@ -2161,9 +3554,27 @@ void
rb_p(obj) /* for debug print within C code */
VALUE obj;
{
- rb_io_write(rb_defout, rb_obj_as_string(rb_inspect(obj)));
- rb_io_write(rb_defout, rb_default_rs);
-}
+ rb_io_write(rb_stdout, rb_obj_as_string(rb_inspect(obj)));
+ rb_io_write(rb_stdout, rb_default_rs);
+}
+
+/*
+ * call-seq:
+ * p(obj, ...) => nil
+ *
+ * For each object, directly writes
+ * _obj_.+inspect+ followed by the current output
+ * record separator to the program's standard output. +p+
+ * bypasses the Ruby I/O libraries.
+ *
+ * S = Struct.new(:name, :state)
+ * s = S['dave', 'TX']
+ * p s
+ *
+ * <em>produces:</em>
+ *
+ * #<S name="dave", state="TX">
+ */
static VALUE
rb_f_p(argc, argv)
@@ -2175,12 +3586,35 @@ rb_f_p(argc, argv)
for (i=0; i<argc; i++) {
rb_p(argv[i]);
}
- if (TYPE(rb_defout) == T_FILE) {
- rb_io_flush(rb_defout);
+ if (TYPE(rb_stdout) == T_FILE) {
+ rb_io_flush(rb_stdout);
}
return Qnil;
}
+/*
+ * call-seq:
+ * obj.display(port=$>) => nil
+ *
+ * Prints <i>obj</i> on the given port (default <code>$></code>).
+ * Equivalent to:
+ *
+ * def display(port=$>)
+ * port.write self
+ * end
+ *
+ * For example:
+ *
+ * 1.display
+ * "cat".display
+ * [ 4, 5, 6 ].display
+ * puts
+ *
+ * <em>produces:</em>
+ *
+ * 1cat456
+ */
+
static VALUE
rb_obj_display(argc, argv, self)
int argc;
@@ -2190,7 +3624,7 @@ rb_obj_display(argc, argv, self)
VALUE out;
if (rb_scan_args(argc, argv, "01", &out) == 0) {
- out = rb_defout;
+ out = rb_stdout;
}
rb_io_write(out, self);
@@ -2198,89 +3632,62 @@ rb_obj_display(argc, argv, self)
return Qnil;
}
-static void
-rb_io_defset(val, id)
- VALUE val;
- ID id;
+void
+rb_write_error2(mesg, len)
+ const char *mesg;
+ long len;
{
- if (!rb_respond_to(val, id_write)) {
- rb_raise(rb_eTypeError, "$> must have write method, %s given",
- rb_class2name(CLASS_OF(val)));
- }
- rb_defout = val;
+ rb_io_write(rb_stderr, rb_str_new(mesg, len));
+}
+
+void
+rb_write_error(mesg)
+ const char *mesg;
+{
+ rb_write_error2(mesg, strlen(mesg));
}
static void
-set_stdin(val, id, var)
+must_respond_to(mid, val, id)
+ ID mid;
VALUE val;
ID id;
- VALUE *var;
{
- OpenFile *fptr;
-
- if (val == *var) return;
- if (TYPE(val) != T_FILE) {
- *var = val;
- return;
+ if (!rb_respond_to(val, mid)) {
+ rb_raise(rb_eTypeError, "%s must have %s method, %s given",
+ rb_id2name(id), rb_id2name(mid),
+ rb_obj_classname(val));
}
- if (TYPE(*var) != T_FILE) {
- *var = orig_stdin;
- }
-
- GetOpenFile(val, fptr);
- rb_io_check_readable(fptr);
- dup2(fileno(fptr->f), 0);
-
- *var = val;
}
static void
-set_outfile(val, var, orig, stdf)
+stdout_setter(val, id, variable)
VALUE val;
- VALUE *var;
- VALUE orig;
- FILE *stdf;
+ ID id;
+ VALUE *variable;
{
- OpenFile *fptr;
- FILE *f;
-
- if (val == *var) return;
-
- if (TYPE(*var) == T_FILE) {
- rb_io_flush(*var);
- }
- if (TYPE(val) != T_FILE) {
- *var = val;
- return;
- }
- if (TYPE(*var) != T_FILE) {
- *var = orig;
- }
-
- GetOpenFile(val, fptr);
- rb_io_check_writable(fptr);
- f = GetWriteFile(fptr);
- dup2(fileno(f), fileno(stdf));
-
- *var = val;
+ must_respond_to(id_write, val, id);
+ *variable = val;
}
static void
-set_stdout(val, id, var)
+defout_setter(val, id, variable)
VALUE val;
ID id;
- VALUE *var;
+ VALUE *variable;
{
- set_outfile(val, var, orig_stdout, stdout);
+ stdout_setter(val, id, variable);
+ rb_warn("$defout is obsolete; use $stdout instead");
}
static void
-set_stderr(val, id, var)
+deferr_setter(val, id, variable)
VALUE val;
ID id;
- VALUE *var;
+ VALUE *variable;
{
- set_outfile(val, var, orig_stderr, stderr);
+ stdout_setter(val, id, variable);
+ rb_warn("$deferr is obsolete; use $stderr instead");
}
static VALUE
@@ -2290,14 +3697,19 @@ prep_stdio(f, mode, klass)
VALUE klass;
{
OpenFile *fp;
- NEWOBJ(io, struct RFile);
- OBJSETUP(io, klass, T_FILE);
+ VALUE io = io_alloc(klass);
MakeOpenFile(io, fp);
+#ifdef __CYGWIN__
+ if (!isatty(fileno(f))) {
+ mode |= O_BINARY;
+ setmode(fileno(f), O_BINARY);
+ }
+#endif
fp->f = f;
fp->mode = mode;
- return (VALUE)io;
+ return io;
}
static void
@@ -2312,20 +3724,23 @@ prep_path(io, path)
fptr->path = strdup(path);
}
-static VALUE
-rb_io_s_new(argc, argv, klass)
- int argc;
- VALUE *argv;
- VALUE klass;
-{
- NEWOBJ(io, struct RFile);
- OBJSETUP(io, klass, T_FILE);
-
- io->fptr = 0;
- rb_obj_call_init((VALUE)io, argc, argv);
-
- return (VALUE)io;
-}
+/*
+ * call-seq:
+ * IO.new(fd, mode) => io
+ *
+ * Returns a new <code>IO</code> object (a stream) for the given
+ * integer file descriptor and mode string. See also
+ * <code>IO#fileno</code> and <code>IO::for_fd</code>.
+ *
+ * a = IO.new(2,"w") # '2' is standard error
+ * $stderr.puts "Hello"
+ * a.puts "World"
+ *
+ * <em>produces:</em>
+ *
+ * Hello
+ * World
+ */
static VALUE
rb_io_initialize(argc, argv, io)
@@ -2335,62 +3750,130 @@ rb_io_initialize(argc, argv, io)
{
VALUE fnum, mode;
OpenFile *fp;
- char *m = "r";
+ int fd, flags;
- if (RFILE(io)->fptr) {
- rb_io_close_m(io);
- free(RFILE(io)->fptr);
- RFILE(io)->fptr = 0;
+ rb_secure(4);
+ rb_scan_args(argc, argv, "11", &fnum, &mode);
+ fd = NUM2INT(fnum);
+ if (argc == 2) {
+ if (FIXNUM_P(mode)) {
+ flags = FIX2LONG(mode);
+ }
+ else {
+ SafeStringValue(mode);
+ flags = rb_io_mode_modenum(RSTRING(mode)->ptr);
+ }
}
- if (rb_scan_args(argc, argv, "11", &fnum, &mode) == 2) {
- Check_SafeStr(mode);
- m = RSTRING(mode)->ptr;
+ else {
+#if defined(HAVE_FCNTL) && defined(F_GETFL)
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1) rb_sys_fail(0);
+#else
+ flags = O_RDONLY;
+#endif
}
MakeOpenFile(io, fp);
- fp->f = rb_fdopen(NUM2INT(fnum), m);
- fp->mode = rb_io_mode_flags(m);
+ fp->mode = rb_io_modenum_flags(flags);
+ fp->f = rb_fdopen(fd, rb_io_modenum_mode(flags));
return io;
}
+/*
+ * call-seq:
+ * File.new(filename, mode="r") => file
+ * File.new(filename [, mode [, perm]]) => file
+ *
+
+ * Opens the file named by _filename_ according to
+ * _mode_ (default is ``r'') and returns a new
+ * <code>File</code> object. See the description of class +IO+ for
+ * a description of _mode_. The file mode may optionally be
+ * specified as a +Fixnum+ by _or_-ing together the
+ * flags (O_RDONLY etc, again described under +IO+). Optional
+ * permission bits may be given in _perm_. These mode and permission
+ * bits are platform dependent; on Unix systems, see
+ * <code>open(2)</code> for details.
+ *
+ * f = File.new("testfile", "r")
+ * f = File.new("newfile", "w+")
+ * f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
+ */
+
static VALUE
rb_file_initialize(argc, argv, io)
int argc;
VALUE *argv;
VALUE io;
{
- 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 (RFILE(io)->fptr) {
rb_io_close_m(io);
free(RFILE(io)->fptr);
RFILE(io)->fptr = 0;
}
- if (FIXNUM_P(vmode)) {
- int flags = NUM2INT(vmode);
- int fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
+ if (0 < argc && argc < 3) {
+ VALUE fd = rb_check_convert_type(argv[0], T_FIXNUM, "Fixnum", "to_int");
- file = rb_file_sysopen_internal(io, path, flags, fmode);
- }
- else {
- if (NIL_P(vmode)) {
- mode = "r";
- }
- else {
- mode = STR2CSTR(vmode);
+ if (!NIL_P(fd)) {
+ argv[0] = fd;
+ return rb_io_initialize(argc, argv, io);
}
- file = rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
}
+ rb_open_file(argc, argv, io);
+
+ return io;
+}
+
+/*
+ * call-seq:
+ * IO.new(fd, mode_string) => io
+ *
+ * Returns a new <code>IO</code> object (a stream) for the given
+ * integer file descriptor and mode string. See also
+ * <code>IO#fileno</code> and <code>IO::for_fd</code>.
+ *
+ * a = IO.new(2,"w") # '2' is standard error
+ * $stderr.puts "Hello"
+ * a.puts "World"
+ *
+ * <em>produces:</em>
+ *
+ * Hello
+ * World
+ */
+
+static VALUE
+rb_io_s_new(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
if (rb_block_given_p()) {
- rb_warn("File::new() does not take block; use File::open() instead");
+ char *cname = rb_class2name(klass);
+
+ rb_warn("%s::new() does not take block; use %s::open() instead",
+ cname, cname);
}
+ return rb_class_new_instance(argc, argv, klass);
+}
- return file;
+/*
+ * call-seq:
+ * IO.for_fd(fd, mode) => io
+ *
+ * Synonym for <code>IO::new</code>.
+ *
+ */
+
+static VALUE
+rb_io_s_for_fd(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE io = rb_obj_alloc(klass);
+ rb_io_initialize(argc, argv, io);
+ return io;
}
static int binmode = 0;
@@ -2402,17 +3885,20 @@ argf_forward()
ruby_frame->argc, ruby_frame->argv);
}
-static VALUE
-argf_binmode()
+#define ARGF_FORWARD() do { if (TYPE(current_file) != T_FILE) return argf_forward(); } while (0)
+#define NEXT_ARGF_FORWARD() do {\
+ if (!next_argv()) return Qnil;\
+ ARGF_FORWARD();\
+} while (0)
+
+static void
+argf_close(file)
+ VALUE file;
{
- if (TYPE(current_file) != T_FILE) {
- argf_forward();
- }
- else {
- rb_io_binmode(current_file);
- }
- binmode = 1;
- return argf;
+ if (TYPE(file) == T_FILE)
+ rb_io_close(file);
+ else
+ rb_funcall3(file, rb_intern("close"), 0, 0);
}
static int
@@ -2420,6 +3906,14 @@ next_argv()
{
extern VALUE rb_argv;
char *fn;
+ OpenFile *fptr;
+ int stdout_binmode = 0;
+
+ if (TYPE(rb_stdout) == T_FILE) {
+ GetOpenFile(rb_stdout, fptr);
+ if (fptr->mode & FMODE_BINMODE)
+ stdout_binmode = 1;
+ }
if (init_p == 0) {
if (RARRAY(rb_argv)->len > 0) {
@@ -2427,25 +3921,22 @@ next_argv()
}
else {
next_p = -1;
- current_file = rb_stdin;
- filename = rb_str_new2("-");
}
init_p = 1;
- first_p = 0;
gets_lineno = 0;
}
- retry:
if (next_p == 1) {
next_p = 0;
+ retry:
if (RARRAY(rb_argv)->len > 0) {
filename = rb_ary_shift(rb_argv);
- fn = STR2CSTR(filename);
+ fn = StringValuePtr(filename);
if (strlen(fn) == 1 && fn[0] == '-') {
current_file = rb_stdin;
if (ruby_inplace_mode) {
- rb_warn("Can't do inplace edit for stdio");
- rb_defout = rb_stdout;
+ rb_warn("Can't do inplace edit for stdio; skipping");
+ goto retry;
}
}
else {
@@ -2456,8 +3947,8 @@ next_argv()
VALUE str;
FILE *fw;
- if (TYPE(rb_defout) == T_FILE && rb_defout != rb_stdout) {
- rb_io_close(rb_defout);
+ if (TYPE(rb_stdout) == T_FILE && rb_stdout != orig_stdout) {
+ rb_io_close(rb_stdout);
}
fstat(fileno(fr), &st);
if (*ruby_inplace_mode) {
@@ -2505,8 +3996,9 @@ next_argv()
fchown(fileno(fw), st.st_uid, st.st_gid);
}
#endif
- rb_defout = prep_stdio(fw, FMODE_WRITABLE, rb_cFile);
- prep_path(rb_defout, fn);
+ rb_stdout = prep_stdio(fw, FMODE_WRITABLE, rb_cFile);
+ prep_path(rb_stdout, fn);
+ if (stdout_binmode) rb_io_binmode(rb_stdout);
}
current_file = prep_stdio(fr, FMODE_READABLE, rb_cFile);
prep_path(current_file, fn);
@@ -2514,25 +4006,23 @@ next_argv()
if (binmode) rb_io_binmode(current_file);
}
else {
- init_p = 0;
+ next_p = 1;
return Qfalse;
}
}
+ else if (next_p == -1) {
+ current_file = rb_stdin;
+ filename = rb_str_new2("-");
+ if (ruby_inplace_mode) {
+ rb_warn("Can't do inplace edit for stdio");
+ rb_stdout = orig_stdout;
+ }
+ }
return Qtrue;
}
-static void
-any_close(file)
- VALUE file;
-{
- if (TYPE(file) == T_FILE)
- rb_io_close(file);
- else
- rb_funcall3(file, rb_intern("close"), 0, 0);
-}
-
static VALUE
-rb_f_gets_internal(argc, argv)
+argf_getline(argc, argv)
int argc;
VALUE *argv;
{
@@ -2540,33 +4030,77 @@ rb_f_gets_internal(argc, argv)
retry:
if (!next_argv()) return Qnil;
- if (TYPE(current_file) != T_FILE) {
- line = rb_funcall3(current_file, rb_intern("gets"), argc, argv);
- }
- else if (argc == 0 && rb_rs == rb_default_rs) {
+ if (argc == 0 && rb_rs == rb_default_rs) {
line = rb_io_gets(current_file);
}
else {
- line = rb_io_gets_internal(argc, argv, current_file);
+ VALUE rs;
+ OpenFile *fptr;
+
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ rb_scan_args(argc, argv, "1", &rs);
+ }
+ GetOpenFile(current_file, fptr);
+ line = rb_io_getline(rs, fptr);
}
if (NIL_P(line) && next_p != -1) {
- any_close(current_file);
+ argf_close(current_file);
next_p = 1;
goto retry;
}
- gets_lineno++;
- lineno = INT2FIX(gets_lineno);
-
+ if (!NIL_P(line)) {
+ gets_lineno++;
+ lineno = INT2FIX(gets_lineno);
+ }
return line;
}
+/*
+ * call-seq:
+ * gets(separator=$/) => string or nil
+ *
+ * Returns (and assigns to <code>$_</code>) the next line from the list
+ * of files in +ARGV+ (or <code>$*</code>), or from standard
+ * input if no files are present on the command line. Returns
+ * +nil+ at end of file. The optional argument specifies the
+ * record separator. The separator is included with the contents of
+ * each record. A separator of +nil+ reads the entire
+ * contents, and a zero-length separator reads the input one paragraph
+ * at a time, where paragraphs are divided by two consecutive newlines.
+ * If multiple filenames are present in +ARGV+,
+ * +gets(nil)+ will read the contents one file at a time.
+ *
+ * ARGV << "testfile"
+ * print while gets
+ *
+ * <em>produces:</em>
+ *
+ * This is line one
+ * This is line two
+ * This is line three
+ * And so on...
+ *
+ * The style of programming using <code>$_</code> as an implicit
+ * parameter is gradually losing favor in the Ruby community.
+ */
+
static VALUE
rb_f_gets(argc, argv)
int argc;
VALUE *argv;
{
- VALUE line = rb_f_gets_internal(argc, argv);
+ VALUE line;
+ if (!next_argv()) return Qnil;
+ if (TYPE(current_file) != T_FILE) {
+ line = rb_funcall3(current_file, rb_intern("gets"), argc, argv);
+ }
+ else {
+ line = argf_getline(argc, argv);
+ }
rb_lastline_set(line);
return line;
}
@@ -2584,7 +4118,7 @@ rb_gets()
if (!next_argv()) return Qnil;
line = rb_io_gets(current_file);
if (NIL_P(line) && next_p != -1) {
- any_close(current_file);
+ argf_close(current_file);
next_p = 1;
goto retry;
}
@@ -2597,13 +4131,24 @@ rb_gets()
return line;
}
+/*
+ * call-seq:
+ * readline(separator=$/ => string
+ *
+ * Equivalent to <code>Kernel::gets</code>, except
+ * +readline+ raises +EOFError+ at end of file.
+ */
+
static VALUE
rb_f_readline(argc, argv)
int argc;
VALUE *argv;
{
- VALUE line = rb_f_gets(argc, argv);
+ VALUE line;
+ if (!next_argv()) rb_eof_error();
+ ARGF_FORWARD();
+ line = rb_f_gets(argc, argv);
if (NIL_P(line)) {
rb_eof_error();
}
@@ -2611,13 +4156,28 @@ rb_f_readline(argc, argv)
return line;
}
+/*
+ * obsolete
+ */
+
static VALUE
rb_f_getc()
{
rb_warn("getc is obsolete; use STDIN.getc instead");
+ if (TYPE(rb_stdin) != T_FILE) {
+ return rb_funcall3(rb_stdin, rb_intern("getc"), 0, 0);
+ }
return rb_io_getc(rb_stdin);
}
+/*
+ * call-seq:
+ * readlines(separator=$/) => array
+ *
+ * Returns an array containing the lines returned by calling
+ * <code>Kernel.gets(<i>aString</i>)</code> until the end of file.
+ */
+
static VALUE
rb_f_readlines(argc, argv)
int argc;
@@ -2625,28 +4185,44 @@ rb_f_readlines(argc, argv)
{
VALUE line, ary;
+ NEXT_ARGF_FORWARD();
ary = rb_ary_new();
- while (!NIL_P(line = rb_f_gets_internal(argc, argv))) {
+ while (!NIL_P(line = argf_getline(argc, argv))) {
rb_ary_push(ary, line);
}
return ary;
}
+/*
+ * call-seq:
+ * `cmd` => string
+ *
+ * Returns the standard output of running _cmd_ in a subshell.
+ * The built-in syntax <code>%x{...}</code> uses
+ * this method. Sets <code>$?</code> to the process status.
+ *
+ * `date` #=> "Wed Apr 9 08:56:30 CDT 2003\n"
+ * `ls testdir`.split[1] #=> "main.rb"
+ * `echo oops && exit 99` #=> "oops\n"
+ * $?.exitstatus #=> 99
+ */
+
static VALUE
rb_f_backquote(obj, str)
VALUE obj, str;
{
VALUE port, result;
+ OpenFile *fptr;
- Check_SafeStr(str);
- port = pipe_open(RSTRING(str)->ptr, "r");
+ SafeStringValue(str);
+ port = pipe_open(str, 0, "r");
if (NIL_P(port)) return rb_str_new(0,0);
- result = read_all(port);
+ GetOpenFile(port, fptr);
+ result = read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);
- if (NIL_P(result)) return rb_str_new(0,0);
return result;
}
@@ -2654,6 +4230,16 @@ rb_f_backquote(obj, str)
#include <sys/select.h>
#endif
+/*
+ * call-seq:
+ * IO.select(read_array
+ * [, write_array
+ * [, error_array
+ * [, timeout]]] ) => array or nil
+ *
+ * See <code>Kernel#select</code>.
+ */
+
static VALUE
rb_f_select(argc, argv, obj)
int argc;
@@ -2665,7 +4251,8 @@ rb_f_select(argc, argv, obj)
fd_set *rp, *wp, *ep;
struct timeval *tp, timerec;
OpenFile *fptr;
- int i, max = 0, n;
+ long i;
+ int max = 0, n;
int interrupt_flag = 0;
int pending = 0;
@@ -2792,7 +4379,7 @@ rb_f_select(argc, argv, obj)
#if !defined(MSDOS) && !defined(__human68k__)
static int
-io_cntl(fd,cmd,narg,io_p)
+io_cntl(fd, cmd, narg, io_p)
int fd, cmd, io_p;
long narg;
{
@@ -2826,7 +4413,7 @@ rb_io_ctl(io, req, arg, io_p)
#if !defined(MSDOS) && !defined(__human68k__)
int cmd = NUM2ULONG(req);
OpenFile *fptr;
- int len = 0;
+ long len = 0;
long narg = 0;
int retval;
@@ -2837,34 +4424,40 @@ rb_io_ctl(io, req, arg, io_p)
narg = 0;
}
else if (FIXNUM_P(arg)) {
- narg = FIX2INT(arg);
+ narg = FIX2LONG(arg);
}
else if (arg == Qtrue) {
narg = 1;
}
else {
- Check_Type(arg, T_STRING);
+ VALUE tmp = rb_check_string_type(arg);
+ if (NIL_P(tmp)) {
+ narg = NUM2LONG(arg);
+ }
+ else {
+ arg = tmp;
#ifdef IOCPARM_MASK
#ifndef IOCPARM_LEN
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
#endif
#endif
#ifdef IOCPARM_LEN
- len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
+ len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */
#else
- len = 256; /* otherwise guess at what's safe */
+ len = 256; /* otherwise guess at what's safe */
#endif
- rb_str_modify(arg);
+ rb_str_modify(arg);
- if (len <= RSTRING(arg)->len) {
- len = RSTRING(arg)->len;
- }
- if (RSTRING(arg)->len < len) {
- rb_str_resize(arg, len+1);
+ if (len <= RSTRING(arg)->len) {
+ len = RSTRING(arg)->len;
+ }
+ if (RSTRING(arg)->len < len) {
+ rb_str_resize(arg, len+1);
+ }
+ RSTRING(arg)->ptr[len] = 17; /* a little sanity check here */
+ narg = (long)RSTRING(arg)->ptr;
}
- RSTRING(arg)->ptr[len] = 17; /* a little sanity check here */
- narg = (long)RSTRING(arg)->ptr;
}
retval = io_cntl(fileno(fptr->f), cmd, narg, io_p);
if (retval < 0) rb_sys_fail(fptr->path);
@@ -2872,7 +4465,8 @@ rb_io_ctl(io, req, arg, io_p)
rb_raise(rb_eArgError, "return value overflowed string");
}
- if (fptr->f2) { /* call on f2 too; ignore result */
+ if (fptr->f2 && fileno(fptr->f) != fileno(fptr->f2)) {
+ /* call on f2 too; ignore result */
io_cntl(fileno(fptr->f2), cmd, narg, io_p);
}
@@ -2883,6 +4477,18 @@ rb_io_ctl(io, req, arg, io_p)
#endif
}
+/*
+ * call-seq:
+ * ios.ioctl(integer_cmd, arg) => integer
+ *
+ * Provides a mechanism for issuing low-level commands to control or
+ * query I/O devices. Arguments and results are platform dependent. If
+ * <i>arg</i> is a number, its value is passed directly. If it is a
+ * string, it is interpreted as a binary sequence of bytes. On Unix
+ * platforms, see <code>ioctl(2)</code> for details. Not implemented on
+ * all platforms.
+ */
+
static VALUE
rb_io_ioctl(argc, argv, io)
int argc;
@@ -2895,6 +4501,19 @@ rb_io_ioctl(argc, argv, io)
return rb_io_ctl(io, req, arg, 1);
}
+/*
+ * call-seq:
+ * ios.fcntl(integer_cmd, arg) => integer
+ *
+ * Provides a mechanism for issuing low-level commands to control or
+ * query file-oriented I/O streams. Arguments and results are platform
+ * dependent. If <i>arg</i> is a number, its value is passed
+ * directly. If it is a string, it is interpreted as a binary sequence
+ * of bytes (<code>Array#pack</code> might be a useful way to build this
+ * string). On Unix platforms, see <code>fcntl(2)</code> for details.
+ * Not implemented on all platforms.
+ */
+
static VALUE
rb_io_fcntl(argc, argv, io)
int argc;
@@ -2912,6 +4531,25 @@ rb_io_fcntl(argc, argv, io)
#endif
}
+/*
+ * call-seq:
+ * syscall(fixnum [, args...]) => integer
+ *
+ * Calls the operating system function identified by _fixnum_,
+ * passing in the arguments, which must be either +String+
+ * objects, or +Integer+ objects that ultimately fit within
+ * a native +long+. Up to nine parameters may be passed (14
+ * on the Atari-ST). The function identified by _fixnum_ is system
+ * dependent. On some Unix systems, the numbers may be obtained from a
+ * header file called <code>syscall.h</code>.
+ *
+ * syscall 4, 1, "hello\n", 6 # '4' is write(2) on our box
+ *
+ * <em>produces:</em>
+ *
+ * hello
+ */
+
static VALUE
rb_f_syscall(argc, argv)
int argc;
@@ -2935,16 +4573,19 @@ rb_f_syscall(argc, argv)
rb_secure(2);
if (argc == 0)
rb_raise(rb_eArgError, "too few arguments for syscall");
- arg[0] = NUM2INT(argv[0]); argv++;
+ arg[0] = NUM2LONG(argv[0]); argv++;
while (items--) {
- if (FIXNUM_P(*argv)) {
- arg[i] = (unsigned long)NUM2INT(*argv); argv++;
+ VALUE v = rb_check_string_type(*argv);
+
+ if (!NIL_P(v)) {
+ StringValue(v);
+ rb_str_modify(v);
+ arg[i] = (unsigned long)RSTRING(v)->ptr;
}
else {
- Check_Type(*argv, T_STRING);
- rb_str_modify(*argv);
- arg[i] = (unsigned long)RSTRING(*argv)->ptr; argv++;
+ arg[i] = (unsigned long)NUM2LONG(*argv);
}
+ argv++;
i++;
}
TRAP_BEG;
@@ -3010,22 +4651,83 @@ rb_f_syscall(argc, argv)
#endif
}
+static VALUE io_new_instance _((VALUE));
static VALUE
-rb_io_s_pipe()
+io_new_instance(args)
+ VALUE args;
+{
+ return rb_class_new_instance(2, (VALUE*)args+1, *(VALUE*)args);
+}
+
+/*
+ * call-seq:
+ * IO.pipe -> array
+ *
+ * Creates a pair of pipe endpoints (connected to each other) and
+ * returns them as a two-element array of <code>IO</code> objects:
+ * <code>[</code> <i>read_file</i>, <i>write_file</i> <code>]</code>. Not
+ * available on all platforms.
+ *
+ * In the example below, the two processes close the ends of the pipe
+ * that they are not using. This is not just a cosmetic nicety. The
+ * read end of a pipe will not generate an end of file condition if
+ * there are any writers with the pipe still open. In the case of the
+ * parent process, the <code>rd.read</code> will never return if it
+ * does not first issue a <code>wr.close</code>.
+ *
+ * rd, wr = IO.pipe
+ *
+ * if fork
+ * wr.close
+ * puts "Parent got: <#{rd.read}>"
+ * rd.close
+ * Process.wait
+ * else
+ * rd.close
+ * puts "Sending message to parent"
+ * wr.write "Hi Dad"
+ * wr.close
+ * end
+ *
+ * <em>produces:</em>
+ *
+ * Sending message to parent
+ * Parent got: <Hi Dad>
+ */
+
+static VALUE
+rb_io_s_pipe(klass)
+ VALUE klass;
{
#ifndef __human68k__
- int pipes[2];
- VALUE r, w, ary;
+ int pipes[2], state;
+ VALUE r, w, args[3];
-#ifdef NT
+#ifdef _WIN32
if (_pipe(pipes, 1024, O_BINARY) == -1)
#else
if (pipe(pipes) == -1)
#endif
rb_sys_fail(0);
- r = prep_stdio(rb_fdopen(pipes[0], "r"), FMODE_READABLE, rb_cIO);
- w = prep_stdio(rb_fdopen(pipes[1], "w"), FMODE_WRITABLE|FMODE_SYNC, rb_cIO);
+ args[0] = klass;
+ args[1] = INT2NUM(pipes[0]);
+ args[2] = INT2FIX(O_RDONLY);
+ r = rb_protect(io_new_instance, (VALUE)args, &state);
+ if (state) {
+ close(pipes[0]);
+ close(pipes[1]);
+ rb_jump_tag(state);
+ }
+ args[1] = INT2NUM(pipes[1]);
+ args[2] = INT2FIX(O_WRONLY);
+ w = rb_protect(io_new_instance, (VALUE)args, &state);
+ if (state) {
+ close(pipes[1]);
+ if (!NIL_P(r)) rb_io_close(r);
+ rb_jump_tag(state);
+ }
+ rb_io_synchronized(RFILE(w)->fptr);
return rb_assoc_new(r, w);
#else
@@ -3038,22 +4740,83 @@ struct foreach_arg {
int argc;
VALUE sep;
VALUE io;
+ OpenFile *fptr;
};
static VALUE
-rb_io_foreach_line(arg)
+io_s_foreach(arg)
struct foreach_arg *arg;
{
VALUE str;
- while (!NIL_P(str = rb_io_gets_internal(arg->argc, &arg->sep, arg->io))) {
+ while (!NIL_P(str = rb_io_getline(arg->sep, arg->fptr))) {
rb_yield(str);
}
return Qnil;
}
+/*
+ * call-seq:
+ * IO.foreach(name, sep_string=$/) {|line| block } => nil
+ *
+ * Executes the block for every line in the named I/O port, where lines
+ * are separated by <em>sep_string</em>.
+ *
+ * IO.foreach("testfile") {|x| print "GOT ", x }
+ *
+ * <em>produces:</em>
+ *
+ * GOT This is line one
+ * GOT This is line two
+ * GOT This is line three
+ * GOT And so on...
+ */
+
static VALUE
-rb_io_s_foreach(argc, argv, io)
+rb_io_s_foreach(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ VALUE fname, io;
+ OpenFile *fptr;
+ struct foreach_arg arg;
+
+ rb_scan_args(argc, argv, "11", &fname, &arg.sep);
+ SafeStringValue(fname);
+
+ if (argc == 1) {
+ arg.sep = rb_default_rs;
+ }
+ io = rb_io_open(RSTRING(fname)->ptr, "r");
+ if (NIL_P(io)) return Qnil;
+ GetOpenFile(io, fptr);
+ arg.fptr = fptr;
+
+ return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, io);
+}
+
+static VALUE
+io_s_readlines(arg)
+ struct foreach_arg *arg;
+{
+ return rb_io_readlines(arg->argc, &arg->sep, arg->io);
+}
+
+/*
+ * call-seq:
+ * IO.readlines(name, sep_string=$/) => array
+ *
+ * Reads the entire file specified by <i>name</i> as individual
+ * lines, and returns those lines in an array. Lines are separated by
+ * <i>sep_string</i>.
+ *
+ * a = IO.readlines("testfile")
+ * a[0] #=> "This is line one\n"
+ *
+ */
+
+static VALUE
+rb_io_s_readlines(argc, argv, io)
int argc;
VALUE *argv;
VALUE io;
@@ -3062,44 +4825,53 @@ rb_io_s_foreach(argc, argv, io)
struct foreach_arg arg;
rb_scan_args(argc, argv, "11", &fname, &arg.sep);
- Check_SafeStr(fname);
+ SafeStringValue(fname);
arg.argc = argc - 1;
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
- return rb_ensure(rb_io_foreach_line, (VALUE)&arg, rb_io_close, arg.io);
+ return rb_ensure(io_s_readlines, (VALUE)&arg, rb_io_close, arg.io);
}
static VALUE
-rb_io_readline_line(arg)
+io_s_read(arg)
struct foreach_arg *arg;
{
- VALUE line, ary;
-
- ary = rb_ary_new();
- while (!NIL_P(line = rb_io_gets_internal(arg->argc, &arg->sep, arg->io))) {
- rb_ary_push(ary, line);
- }
-
- return ary;
+ return io_read(arg->argc, &arg->sep, arg->io);
}
+/*
+ * call-seq:
+ * IO.read(rane, [length [, offset]] ) => string
+ *
+ * Opens the file, optionally seeks to the given offset, then returns
+ * <i>length</i> bytes (defaulting to the rest of the file).
+ * <code>read</code> ensures the file is closed before returning.
+ *
+ * IO.read("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
+ * IO.read("testfile", 20) #=> "This is line one\nThi"
+ * IO.read("testfile", 20, 10) #=> "ne one\nThis is line "
+ */
+
static VALUE
-rb_io_s_readlines(argc, argv, io)
+rb_io_s_read(argc, argv, io)
int argc;
VALUE *argv;
VALUE io;
{
- VALUE fname;
+ VALUE fname, offset;
struct foreach_arg arg;
- rb_scan_args(argc, argv, "11", &fname, &arg.sep);
- Check_SafeStr(fname);
+ rb_scan_args(argc, argv, "12", &fname, &arg.sep, &offset);
+ SafeStringValue(fname);
- arg.argc = argc - 1;
+ arg.argc = argc ? 1 : 0;
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
- return rb_ensure(rb_io_readline_line, (VALUE)&arg, rb_io_close, arg.io);
+ if (!NIL_P(offset)) {
+ rb_io_seek(arg.io, offset, SEEK_SET);
+ }
+ return rb_ensure(io_s_read, (VALUE)&arg, rb_io_close, arg.io);
}
static VALUE
@@ -3108,26 +4880,21 @@ argf_tell()
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to tell");
}
-
- if (TYPE(current_file) != T_FILE) {
- return argf_forward();
- }
+ ARGF_FORWARD();
return rb_io_tell(current_file);
}
static VALUE
-argf_seek(argc, argv)
+argf_seek_m(argc, argv, self)
int argc;
VALUE *argv;
+ VALUE self;
{
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to seek");
}
-
- if (TYPE(current_file) != T_FILE) {
- return argf_forward();
- }
- return rb_io_seek(argc, argv, current_file);
+ ARGF_FORWARD();
+ return rb_io_seek_m(argc, argv, current_file);
}
static VALUE
@@ -3135,12 +4902,9 @@ argf_set_pos(self, offset)
VALUE self, offset;
{
if (!next_argv()) {
- rb_raise(rb_eArgError, "no stream to pos");
- }
-
- if (TYPE(current_file) != T_FILE) {
- return argf_forward();
+ rb_raise(rb_eArgError, "no stream to set position");
}
+ ARGF_FORWARD();
return rb_io_set_pos(current_file, offset);
}
@@ -3150,9 +4914,7 @@ argf_rewind()
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to rewind");
}
- if (TYPE(current_file) != T_FILE) {
- return argf_forward();
- }
+ ARGF_FORWARD();
return rb_io_rewind(current_file);
}
@@ -3162,55 +4924,75 @@ argf_fileno()
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream");
}
- if (TYPE(current_file) != T_FILE) {
- return argf_forward();
- }
+ ARGF_FORWARD();
return rb_io_fileno(current_file);
}
static VALUE
argf_to_io()
{
+ next_argv();
+ ARGF_FORWARD();
return current_file;
}
static VALUE
+argf_eof()
+{
+ if (current_file) {
+ if (init_p == 0) return Qtrue;
+ ARGF_FORWARD();
+ if (rb_io_eof(current_file)) {
+ return Qtrue;
+ }
+ }
+ return Qfalse;
+}
+
+static VALUE
argf_read(argc, argv)
int argc;
VALUE *argv;
{
- VALUE tmp, str;
- int len;
+ VALUE tmp, str, length;
+ long len = 0;
- if (argc == 1) len = NUM2INT(argv[0]);
- str = Qnil;
+ rb_scan_args(argc, argv, "02", &length, &str);
+ if (!NIL_P(length)) {
+ len = NUM2LONG(argv[0]);
+ }
+ if (!NIL_P(str)) {
+ StringValue(str);
+ rb_str_resize(str,0);
+ argv[1] = Qnil;
+ }
retry:
- if (!next_argv()) return str;
+ if (!next_argv()) {
+ return str;
+ }
if (TYPE(current_file) != T_FILE) {
tmp = argf_forward();
- STR2CSTR(tmp);
}
else {
tmp = io_read(argc, argv, current_file);
}
- if (NIL_P(tmp) && next_p != -1) {
- any_close(current_file);
- next_p = 1;
- goto retry;
- }
- if (NIL_P(tmp) || RSTRING(tmp)->len == 0) return str;
- else if (NIL_P(str)) str = tmp;
- else rb_str_append(str, tmp);
- if (argc == 0) {
- goto retry;
+ if (NIL_P(str)) str = tmp;
+ else if (!NIL_P(tmp)) rb_str_append(str, tmp);
+ if (NIL_P(tmp) || NIL_P(length)) {
+ if (next_p != -1) {
+ argf_close(current_file);
+ next_p = 1;
+ goto retry;
+ }
}
- if (RSTRING(tmp)->len < len) {
- len -= RSTRING(tmp)->len;
- argv[0] = INT2FIX(len);
- goto retry;
+ else if (argc >= 1) {
+ if (RSTRING(str)->len < len) {
+ len -= RSTRING(str)->len;
+ argv[0] = INT2NUM(len);
+ goto retry;
+ }
}
-
return str;
}
@@ -3228,7 +5010,7 @@ argf_getc()
byte = rb_io_getc(current_file);
}
if (NIL_P(byte) && next_p != -1) {
- any_close(current_file);
+ argf_close(current_file);
next_p = 1;
goto retry;
}
@@ -3239,8 +5021,10 @@ argf_getc()
static VALUE
argf_readchar()
{
- VALUE c = argf_getc();
+ VALUE c;
+ NEXT_ARGF_FORWARD();
+ c = argf_getc();
if (NIL_P(c)) {
rb_eof_error();
}
@@ -3248,32 +5032,21 @@ argf_readchar()
}
static VALUE
-argf_eof()
-{
- int first = first_p;
-
- if (!next_argv()) return Qtrue;
- if (!first && next_p == -1) {
- return Qtrue;
- }
- if (TYPE(current_file) != T_FILE) {
- return argf_forward();
- }
- if (rb_io_eof(current_file)) {
- next_p = 1;
- return Qtrue;
- }
- return Qfalse;
-}
-
-static VALUE
argf_each_line(argc, argv)
int argc;
VALUE *argv;
{
VALUE str;
- while (RTEST(str = rb_f_gets_internal(argc, argv))) {
+ if (!next_argv()) return Qnil;
+ if (TYPE(current_file) != T_FILE) {
+ for (;;) {
+ if (!next_argv()) return argf;
+ rb_iterate(rb_each, current_file, rb_yield, 0);
+ next_p = 1;
+ }
+ }
+ while (!NIL_P(str = argf_getline(argc, argv))) {
rb_yield(str);
}
return argf;
@@ -3287,35 +5060,48 @@ argf_each_byte()
while (!NIL_P(byte = argf_getc())) {
rb_yield(byte);
}
- return Qnil;
+ return argf;
}
static VALUE
argf_filename()
{
+ next_argv();
return filename;
}
static VALUE
argf_file()
{
+ next_argv();
return current_file;
}
static VALUE
+argf_binmode()
+{
+ binmode = 1;
+ next_argv();
+ ARGF_FORWARD();
+ rb_io_binmode(current_file);
+ return argf;
+}
+
+static VALUE
argf_skip()
{
if (next_p != -1) {
- any_close(current_file);
+ argf_close(current_file);
next_p = 1;
}
return argf;
}
static VALUE
-argf_close()
+argf_close_m()
{
- any_close(current_file);
+ next_argv();
+ argf_close(current_file);
if (next_p != -1) {
next_p = 1;
}
@@ -3326,13 +5112,18 @@ argf_close()
static VALUE
argf_closed()
{
- if (TYPE(current_file) != T_FILE) {
- return argf_forward();
- }
+ next_argv();
+ ARGF_FORWARD();
return rb_io_closed(current_file);
}
static VALUE
+argf_to_s()
+{
+ return rb_str_new2("ARGF");
+}
+
+static VALUE
opt_i_get()
{
if (!ruby_inplace_mode) return Qnil;
@@ -3343,21 +5134,115 @@ static void
opt_i_set(val)
VALUE val;
{
- if (ruby_inplace_mode) free(ruby_inplace_mode);
if (!RTEST(val)) {
+ if (ruby_inplace_mode) free(ruby_inplace_mode);
ruby_inplace_mode = 0;
return;
}
- ruby_inplace_mode = strdup(STR2CSTR(val));
-}
+ StringValue(val);
+ if (ruby_inplace_mode) free(ruby_inplace_mode);
+ ruby_inplace_mode = 0;
+ ruby_inplace_mode = strdup(RSTRING(val)->ptr);
+}
+
+/*
+ * Class <code>IO</code> is the basis for all input and output in Ruby.
+ * An I/O stream may be <em>duplexed</em> (that is, bidirectional), and
+ * so may use more than one native operating system stream.
+ *
+ * Many of the examples in this section use class <code>File</code>,
+ * the only standard subclass of <code>IO</code>. The two classes are
+ * closely associated.
+ *
+ * As used in this section, <em>portname</em> may take any of the
+ * following forms.
+ *
+ * * A plain string represents a filename suitable for the underlying
+ * operating system.
+ *
+ * * A string starting with ``<code>|</code>'' indicates a subprocess.
+ * The remainder of the string following the ``<code>|</code>'' is
+ * invoked as a process with appropriate input/output channels
+ * connected to it.
+ *
+ * * A string equal to ``<code>|-</code>'' will create another Ruby
+ * instance as a subprocess.
+ *
+ * Ruby will convert pathnames between different operating system
+ * conventions if possible. For instance, on a Windows system the
+ * filename ``<code>/gumby/ruby/test.rb</code>'' will be opened as
+ * ``<code>\gumby\ruby\test.rb</code>''. When specifying a
+ * Windows-style filename in a Ruby string, remember to escape the
+ * backslashes:
+ *
+ * "c:\\gumby\\ruby\\test.rb"
+ *
+ * Our examples here will use the Unix-style forward slashes;
+ * <code>File::SEPARATOR</code> can be used to get the
+ * platform-specific separator character.
+ *
+ * I/O ports may be opened in any one of several different modes, which
+ * are shown in this section as <em>mode</em>. The mode may
+ * either be a Fixnum or a String. If numeric, it should be
+ * one of the operating system specific constants (O_RDONLY,
+ * O_WRONLY, O_RDWR, O_APPEND and so on). See man open(2) for
+ * more information.
+ *
+ * If the mode is given as a String, it must be one of the
+ * values listed in the following table.
+ *
+ * Mode | Meaning
+ * -----+--------------------------------------------------------
+ * "r" | Read-only, starts at beginning of file (default mode).
+ * -----+--------------------------------------------------------
+ * "r+" | Read-write, starts at beginning of file.
+ * -----+--------------------------------------------------------
+ * "w" | Write-only, truncates existing file
+ * | to zero length or creates a new file for writing.
+ * -----+--------------------------------------------------------
+ * "w+" | Read-write, truncates existing file to zero length
+ * | or creates a new file for reading and writing.
+ * -----+--------------------------------------------------------
+ * "a" | Write-only, starts at end of file if file exists,
+ * | otherwise creates a new file for writing.
+ * -----+--------------------------------------------------------
+ * "a+" | Read-write, starts at end of file if file exists,
+ * | otherwise creates a new file for reading and
+ * | writing.
+ * -----+--------------------------------------------------------
+ * "b" | (DOS/Windows only) Binary file mode (may appear with
+ * | any of the key letters listed above).
+ *
+ *
+ * The global constant ARGF (also accessible as $<) provides an
+ * IO-like stream which allows access to all files mentioned on the
+ * command line (or STDIN if no files are mentioned). ARGF provides
+ * the methods <code>#path</code> and <code>#filename</code> to access
+ * the name of the file currently being read.
+ */
void
Init_IO()
{
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+ static struct __cygwin_perfile pf[] =
+ {
+ {"", O_RDONLY | O_BINARY},
+ {"", O_WRONLY | O_BINARY},
+ {"", O_RDWR | O_BINARY},
+ {"", O_APPEND | O_BINARY},
+ {NULL, 0}
+ };
+ cygwin_internal(CW_PERFILE, pf);
+#endif
+
rb_eIOError = rb_define_class("IOError", rb_eStandardError);
rb_eEOFError = rb_define_class("EOFError", rb_eIOError);
id_write = rb_intern("write");
+ id_read = rb_intern("read");
+ id_getc = rb_intern("getc");
rb_define_global_function("syscall", rb_f_syscall, -1);
@@ -3381,18 +5266,25 @@ Init_IO()
rb_cIO = rb_define_class("IO", rb_cObject);
rb_include_module(rb_cIO, rb_mEnumerable);
+ rb_define_alloc_func(rb_cIO, io_alloc);
rb_define_singleton_method(rb_cIO, "new", rb_io_s_new, -1);
- rb_define_method(rb_cIO, "initialize", rb_io_initialize, -1);
+ rb_define_singleton_method(rb_cIO, "open", rb_io_s_open, -1);
+ rb_define_singleton_method(rb_cIO, "sysopen", rb_io_s_sysopen, -1);
+ rb_define_singleton_method(rb_cIO, "for_fd", rb_io_s_for_fd, -1);
rb_define_singleton_method(rb_cIO, "popen", rb_io_s_popen, -1);
rb_define_singleton_method(rb_cIO, "foreach", rb_io_s_foreach, -1);
rb_define_singleton_method(rb_cIO, "readlines", rb_io_s_readlines, -1);
+ rb_define_singleton_method(rb_cIO, "read", rb_io_s_read, -1);
rb_define_singleton_method(rb_cIO, "select", rb_f_select, -1);
rb_define_singleton_method(rb_cIO, "pipe", rb_io_s_pipe, 0);
+ rb_define_method(rb_cIO, "initialize", rb_io_initialize, -1);
+
rb_output_fs = Qnil;
rb_define_hooked_variable("$,", &rb_output_fs, 0, rb_str_setter);
- rb_rs = rb_default_rs = rb_str_new2("\n"); rb_output_rs = Qnil;
+ rb_rs = rb_default_rs = rb_str_new2("\n");
+ rb_output_rs = Qnil;
rb_global_variable(&rb_default_rs);
OBJ_FREEZE(rb_default_rs); /* avoid modifying RS_default */
rb_define_hooked_variable("$/", &rb_rs, 0, rb_str_setter);
@@ -3402,7 +5294,7 @@ Init_IO()
rb_define_hooked_variable("$.", &lineno, 0, lineno_setter);
rb_define_virtual_variable("$_", rb_lastline_get, rb_lastline_set);
- rb_define_method(rb_cIO, "clone", rb_io_clone, 0);
+ rb_define_method(rb_cIO, "initialize_copy", rb_io_init_copy, 1);
rb_define_method(rb_cIO, "reopen", rb_io_reopen, -1);
rb_define_method(rb_cIO, "print", rb_io_print, -1);
@@ -3415,12 +5307,13 @@ Init_IO()
rb_define_method(rb_cIO, "each_byte", rb_io_each_byte, 0);
rb_define_method(rb_cIO, "syswrite", rb_io_syswrite, 1);
- rb_define_method(rb_cIO, "sysread", rb_io_sysread, 1);
+ rb_define_method(rb_cIO, "sysread", rb_io_sysread, -1);
rb_define_method(rb_cIO, "fileno", rb_io_fileno, 0);
rb_define_alias(rb_cIO, "to_i", "fileno");
rb_define_method(rb_cIO, "to_io", rb_io_to_io, 0);
+ rb_define_method(rb_cIO, "fsync", rb_io_fsync, 0);
rb_define_method(rb_cIO, "sync", rb_io_sync, 0);
rb_define_method(rb_cIO, "sync=", rb_io_set_sync, 1);
@@ -3439,7 +5332,7 @@ Init_IO()
rb_define_method(rb_cIO, "<<", rb_io_addstr, 1);
rb_define_method(rb_cIO, "flush", rb_io_flush, 0);
rb_define_method(rb_cIO, "tell", rb_io_tell, 0);
- rb_define_method(rb_cIO, "seek", rb_io_seek, -1);
+ rb_define_method(rb_cIO, "seek", rb_io_seek_m, -1);
rb_define_const(rb_cIO, "SEEK_SET", INT2FIX(SEEK_SET));
rb_define_const(rb_cIO, "SEEK_CUR", INT2FIX(SEEK_CUR));
rb_define_const(rb_cIO, "SEEK_END", INT2FIX(SEEK_END));
@@ -3457,21 +5350,28 @@ Init_IO()
rb_define_method(rb_cIO, "isatty", rb_io_isatty, 0);
rb_define_method(rb_cIO, "tty?", rb_io_isatty, 0);
rb_define_method(rb_cIO, "binmode", rb_io_binmode, 0);
+ rb_define_method(rb_cIO, "sysseek", rb_io_sysseek, -1);
rb_define_method(rb_cIO, "ioctl", rb_io_ioctl, -1);
rb_define_method(rb_cIO, "fcntl", rb_io_fcntl, -1);
rb_define_method(rb_cIO, "pid", rb_io_pid, 0);
-
- rb_stdin = orig_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
- rb_define_hooked_variable("$stdin", &rb_stdin, 0, set_stdin);
- rb_stdout = orig_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO);
- rb_define_hooked_variable("$stdout", &rb_stdout, 0, set_stdout);
- rb_stderr = orig_stderr = prep_stdio(stderr, FMODE_WRITABLE, rb_cIO);
- rb_define_hooked_variable("$stderr", &rb_stderr, 0, set_stderr);
- rb_defout = rb_stdout;
- rb_define_hooked_variable("$>", &rb_defout, 0, rb_io_defset);
- rb_define_hooked_variable("$defout", &rb_defout, 0, rb_io_defset);
-
+ rb_define_method(rb_cIO, "inspect", rb_io_inspect, 0);
+
+ rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
+ rb_define_variable("$stdin", &rb_stdin);
+ rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, rb_cIO);
+ rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);
+ rb_stderr = prep_stdio(stderr, FMODE_WRITABLE, rb_cIO);
+ rb_define_hooked_variable("$stderr", &rb_stderr, 0, stdout_setter);
+ rb_define_hooked_variable("$>", &rb_stdout, 0, stdout_setter);
+ orig_stdout = rb_stdout;
+ rb_deferr = orig_stderr = rb_stderr;
+
+ /* variables to be removed in 1.8.1 */
+ rb_define_hooked_variable("$defout", &rb_stdout, 0, defout_setter);
+ rb_define_hooked_variable("$deferr", &rb_stderr, 0, deferr_setter);
+
+ /* constants to hold original stdin/stdout/stderr */
rb_define_global_const("STDIN", rb_stdin);
rb_define_global_const("STDOUT", rb_stdout);
rb_define_global_const("STDERR", rb_stderr);
@@ -3482,6 +5382,8 @@ Init_IO()
rb_define_readonly_variable("$<", &argf);
rb_define_global_const("ARGF", argf);
+ rb_define_singleton_method(argf, "to_s", argf_to_s, 0);
+
rb_define_singleton_method(argf, "fileno", argf_fileno, 0);
rb_define_singleton_method(argf, "to_i", argf_fileno, 0);
rb_define_singleton_method(argf, "to_io", argf_to_io, 0);
@@ -3497,7 +5399,7 @@ Init_IO()
rb_define_singleton_method(argf, "getc", argf_getc, 0);
rb_define_singleton_method(argf, "readchar", argf_readchar, 0);
rb_define_singleton_method(argf, "tell", argf_tell, 0);
- rb_define_singleton_method(argf, "seek", argf_seek, -1);
+ rb_define_singleton_method(argf, "seek", argf_seek_m, -1);
rb_define_singleton_method(argf, "rewind", argf_rewind, 0);
rb_define_singleton_method(argf, "pos", argf_tell, 0);
rb_define_singleton_method(argf, "pos=", argf_set_pos, 1);
@@ -3505,30 +5407,28 @@ Init_IO()
rb_define_singleton_method(argf, "eof?", argf_eof, 0);
rb_define_singleton_method(argf, "binmode", argf_binmode, 0);
- rb_define_singleton_method(argf, "to_s", argf_filename, 0);
rb_define_singleton_method(argf, "filename", argf_filename, 0);
+ rb_define_singleton_method(argf, "path", argf_filename, 0);
rb_define_singleton_method(argf, "file", argf_file, 0);
rb_define_singleton_method(argf, "skip", argf_skip, 0);
- rb_define_singleton_method(argf, "close", argf_close, 0);
+ rb_define_singleton_method(argf, "close", argf_close_m, 0);
rb_define_singleton_method(argf, "closed?", argf_closed, 0);
rb_define_singleton_method(argf, "lineno", argf_lineno, 0);
rb_define_singleton_method(argf, "lineno=", argf_set_lineno, 1);
- current_file = rb_stdin;
rb_global_variable(&current_file);
filename = rb_str_new2("-");
rb_define_readonly_variable("$FILENAME", &filename);
rb_define_virtual_variable("$-i", opt_i_get, opt_i_set);
-#if defined (NT) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__)
+#if defined (_WIN32) || defined(DJGPP) || defined(__CYGWIN__) || defined(__human68k__)
atexit(pipe_atexit);
#endif
Init_File();
- rb_define_singleton_method(rb_cFile, "open", rb_file_s_open, -1);
rb_define_method(rb_cFile, "initialize", rb_file_initialize, -1);
rb_file_const("RDONLY", INT2FIX(O_RDONLY));
diff --git a/keywords b/keywords
index eafc5ed8ab..04be992857 100644
--- a/keywords
+++ b/keywords
@@ -1,42 +1,42 @@
struct kwtable {char *name; int id[2]; enum lex_state state;};
%%
-__LINE__, k__LINE__, k__LINE__, EXPR_END
-__FILE__, k__FILE__, k__FILE__, EXPR_END
-BEGIN, klBEGIN, klBEGIN, EXPR_END
-END, klEND, klEND, EXPR_END
-alias, kALIAS, kALIAS, EXPR_FNAME
-and, kAND, kAND, EXPR_BEG
-begin, kBEGIN, kBEGIN, EXPR_BEG
-break, kBREAK, kBREAK, EXPR_END
-case, kCASE, kCASE, EXPR_BEG
-class, kCLASS, kCLASS, EXPR_CLASS
-def, kDEF, kDEF, EXPR_FNAME
-defined?, kDEFINED, kDEFINED, EXPR_ARG
-do, kDO, kDO, EXPR_BEG
-else, kELSE, kELSE, EXPR_BEG
-elsif, kELSIF, kELSIF, EXPR_BEG
-end, kEND, kEND, EXPR_END
-ensure, kENSURE, kENSURE, EXPR_BEG
-false, kFALSE, kFALSE, EXPR_END
-for, kFOR, kFOR, EXPR_BEG
-if, kIF, kIF_MOD, EXPR_BEG
-in, kIN, kIN, EXPR_BEG
-module, kMODULE, kMODULE, EXPR_BEG
-next, kNEXT, kNEXT, EXPR_END
-nil, kNIL, kNIL, EXPR_END
-not, kNOT, kNOT, EXPR_BEG
-or, kOR, kOR, EXPR_BEG
-redo, kREDO, kREDO, EXPR_END
-rescue, kRESCUE, kRESCUE_MOD, EXPR_END
-retry, kRETRY, kRETRY, EXPR_END
-return, kRETURN, kRETURN, EXPR_MID
-self, kSELF, kSELF, EXPR_END
-super, kSUPER, kSUPER, EXPR_ARG
-then, kTHEN, kTHEN, EXPR_BEG
-true, kTRUE, kTRUE, EXPR_END
-undef, kUNDEF, kUNDEF, EXPR_FNAME
-unless, kUNLESS, kUNLESS_MOD, EXPR_BEG
-until, kUNTIL, kUNTIL_MOD, EXPR_BEG
-when, kWHEN, kWHEN, EXPR_BEG
-while, kWHILE, kWHILE_MOD, EXPR_BEG
-yield, kYIELD, kYIELD, EXPR_ARG
+__LINE__, {k__LINE__, k__LINE__}, EXPR_END
+__FILE__, {k__FILE__, k__FILE__}, EXPR_END
+BEGIN, {klBEGIN, klBEGIN}, EXPR_END
+END, {klEND, klEND}, EXPR_END
+alias, {kALIAS, kALIAS}, EXPR_FNAME
+and, {kAND, kAND}, EXPR_BEG
+begin, {kBEGIN, kBEGIN}, EXPR_BEG
+break, {kBREAK, kBREAK}, EXPR_MID
+case, {kCASE, kCASE}, EXPR_BEG
+class, {kCLASS, kCLASS}, EXPR_CLASS
+def, {kDEF, kDEF}, EXPR_FNAME
+defined?, {kDEFINED, kDEFINED}, EXPR_ARG
+do, {kDO, kDO}, EXPR_BEG
+else, {kELSE, kELSE}, EXPR_BEG
+elsif, {kELSIF, kELSIF}, EXPR_BEG
+end, {kEND, kEND}, EXPR_END
+ensure, {kENSURE, kENSURE}, EXPR_BEG
+false, {kFALSE, kFALSE}, EXPR_END
+for, {kFOR, kFOR}, EXPR_BEG
+if, {kIF, kIF_MOD}, EXPR_BEG
+in, {kIN, kIN}, EXPR_BEG
+module, {kMODULE, kMODULE}, EXPR_BEG
+next, {kNEXT, kNEXT}, EXPR_MID
+nil, {kNIL, kNIL}, EXPR_END
+not, {kNOT, kNOT}, EXPR_BEG
+or, {kOR, kOR}, EXPR_BEG
+redo, {kREDO, kREDO}, EXPR_END
+rescue, {kRESCUE, kRESCUE_MOD}, EXPR_MID
+retry, {kRETRY, kRETRY}, EXPR_END
+return, {kRETURN, kRETURN}, EXPR_MID
+self, {kSELF, kSELF}, EXPR_END
+super, {kSUPER, kSUPER}, EXPR_ARG
+then, {kTHEN, kTHEN}, EXPR_BEG
+true, {kTRUE, kTRUE}, EXPR_END
+undef, {kUNDEF, kUNDEF}, EXPR_FNAME
+unless, {kUNLESS, kUNLESS_MOD}, EXPR_BEG
+until, {kUNTIL, kUNTIL_MOD}, EXPR_BEG
+when, {kWHEN, kWHEN}, EXPR_BEG
+while, {kWHILE, kWHILE_MOD}, EXPR_BEG
+yield, {kYIELD, kYIELD}, EXPR_ARG
diff --git a/lex.c b/lex.c
index 0784c245bb..79d9448dae 100644
--- a/lex.c
+++ b/lex.c
@@ -1,5 +1,5 @@
-/* C code produced by gperf version 2.7.1 (19981006 egcs) */
-/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ ./keywords */
+/* C code produced by gperf version 2.7.2 */
+/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' ./keywords */
struct kwtable {char *name; int id[2]; enum lex_state state;};
#define TOTAL_KEYWORDS 40
@@ -11,6 +11,10 @@ struct kwtable {char *name; int id[2]; enum lex_state state;};
#ifdef __GNUC__
__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
#endif
static unsigned int
hash (str, len)
@@ -72,48 +76,48 @@ rb_reserved_word (str, len)
static struct kwtable wordlist[] =
{
{""}, {""}, {""}, {""}, {""}, {""},
- {"end", kEND, kEND, EXPR_END},
- {"else", kELSE, kELSE, EXPR_BEG},
- {"case", kCASE, kCASE, EXPR_BEG},
- {"ensure", kENSURE, kENSURE, EXPR_BEG},
- {"module", kMODULE, kMODULE, EXPR_BEG},
- {"elsif", kELSIF, kELSIF, EXPR_BEG},
- {"def", kDEF, kDEF, EXPR_FNAME},
- {"rescue", kRESCUE, kRESCUE_MOD, EXPR_END},
- {"not", kNOT, kNOT, EXPR_BEG},
- {"then", kTHEN, kTHEN, EXPR_BEG},
- {"yield", kYIELD, kYIELD, EXPR_ARG},
- {"for", kFOR, kFOR, EXPR_BEG},
- {"self", kSELF, kSELF, EXPR_END},
- {"false", kFALSE, kFALSE, EXPR_END},
- {"retry", kRETRY, kRETRY, EXPR_END},
- {"return", kRETURN, kRETURN, EXPR_MID},
- {"true", kTRUE, kTRUE, EXPR_END},
- {"if", kIF, kIF_MOD, EXPR_BEG},
- {"defined?", kDEFINED, kDEFINED, EXPR_ARG},
- {"super", kSUPER, kSUPER, EXPR_ARG},
- {"undef", kUNDEF, kUNDEF, EXPR_FNAME},
- {"break", kBREAK, kBREAK, EXPR_END},
- {"in", kIN, kIN, EXPR_BEG},
- {"do", kDO, kDO, EXPR_BEG},
- {"nil", kNIL, kNIL, EXPR_END},
- {"until", kUNTIL, kUNTIL_MOD, EXPR_BEG},
- {"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG},
- {"or", kOR, kOR, EXPR_BEG},
- {"next", kNEXT, kNEXT, EXPR_END},
- {"when", kWHEN, kWHEN, EXPR_BEG},
- {"redo", kREDO, kREDO, EXPR_END},
- {"and", kAND, kAND, EXPR_BEG},
- {"begin", kBEGIN, kBEGIN, EXPR_BEG},
- {"__LINE__", k__LINE__, k__LINE__, EXPR_END},
- {"class", kCLASS, kCLASS, EXPR_CLASS},
- {"__FILE__", k__FILE__, k__FILE__, EXPR_END},
- {"END", klEND, klEND, EXPR_END},
- {"BEGIN", klBEGIN, klBEGIN, EXPR_END},
- {"while", kWHILE, kWHILE_MOD, EXPR_BEG},
+ {"end", {kEND, kEND}, EXPR_END},
+ {"else", {kELSE, kELSE}, EXPR_BEG},
+ {"case", {kCASE, kCASE}, EXPR_BEG},
+ {"ensure", {kENSURE, kENSURE}, EXPR_BEG},
+ {"module", {kMODULE, kMODULE}, EXPR_BEG},
+ {"elsif", {kELSIF, kELSIF}, EXPR_BEG},
+ {"def", {kDEF, kDEF}, EXPR_FNAME},
+ {"rescue", {kRESCUE, kRESCUE_MOD}, EXPR_MID},
+ {"not", {kNOT, kNOT}, EXPR_BEG},
+ {"then", {kTHEN, kTHEN}, EXPR_BEG},
+ {"yield", {kYIELD, kYIELD}, EXPR_ARG},
+ {"for", {kFOR, kFOR}, EXPR_BEG},
+ {"self", {kSELF, kSELF}, EXPR_END},
+ {"false", {kFALSE, kFALSE}, EXPR_END},
+ {"retry", {kRETRY, kRETRY}, EXPR_END},
+ {"return", {kRETURN, kRETURN}, EXPR_MID},
+ {"true", {kTRUE, kTRUE}, EXPR_END},
+ {"if", {kIF, kIF_MOD}, EXPR_BEG},
+ {"defined?", {kDEFINED, kDEFINED}, EXPR_ARG},
+ {"super", {kSUPER, kSUPER}, EXPR_ARG},
+ {"undef", {kUNDEF, kUNDEF}, EXPR_FNAME},
+ {"break", {kBREAK, kBREAK}, EXPR_MID},
+ {"in", {kIN, kIN}, EXPR_BEG},
+ {"do", {kDO, kDO}, EXPR_BEG},
+ {"nil", {kNIL, kNIL}, EXPR_END},
+ {"until", {kUNTIL, kUNTIL_MOD}, EXPR_BEG},
+ {"unless", {kUNLESS, kUNLESS_MOD}, EXPR_BEG},
+ {"or", {kOR, kOR}, EXPR_BEG},
+ {"next", {kNEXT, kNEXT}, EXPR_MID},
+ {"when", {kWHEN, kWHEN}, EXPR_BEG},
+ {"redo", {kREDO, kREDO}, EXPR_END},
+ {"and", {kAND, kAND}, EXPR_BEG},
+ {"begin", {kBEGIN, kBEGIN}, EXPR_BEG},
+ {"__LINE__", {k__LINE__, k__LINE__}, EXPR_END},
+ {"class", {kCLASS, kCLASS}, EXPR_CLASS},
+ {"__FILE__", {k__FILE__, k__FILE__}, EXPR_END},
+ {"END", {klEND, klEND}, EXPR_END},
+ {"BEGIN", {klBEGIN, klBEGIN}, EXPR_END},
+ {"while", {kWHILE, kWHILE_MOD}, EXPR_BEG},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
- {"alias", kALIAS, kALIAS, EXPR_FNAME}
+ {"alias", {kALIAS, kALIAS}, EXPR_FNAME}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/lib/.document b/lib/.document
new file mode 100644
index 0000000000..e93b0e63e2
--- /dev/null
+++ b/lib/.document
@@ -0,0 +1,33 @@
+# We only run RDoc on the top-level files in here: we skip
+# all the helper stuff in sub-directories
+
+# Eventually, we hope to see...
+# *.rb
+
+# But for now
+
+abbrev.rb
+base64.rb
+benchmark.rb
+cgi.rb
+cgi
+complex.rb
+date.rb
+English.rb
+fileutils.rb
+find.rb
+generator.rb
+logger.rb
+matrix.rb
+observer.rb
+optionparser.rb
+pathname.rb
+set.rb
+shellwords.rb
+singleton.rb
+tempfile.rb
+test/unit.rb
+thread.rb
+thwait.rb
+time.rb
+yaml.rb
diff --git a/lib/English.rb b/lib/English.rb
index c7e13bebe6..1a0e11de74 100644
--- a/lib/English.rb
+++ b/lib/English.rb
@@ -1,28 +1,155 @@
+# Include the English library file in a Ruby script, and you can
+# reference the global variables such as \VAR{\$\_} using less
+# cryptic names, listed in the following table.% \vref{tab:english}.
+#
+# Without 'English':
+#
+# $\ = ' -- '
+# "waterbuffalo" =~ /buff/
+# print $", $', $$, "\n"
+#
+# With English:
+#
+# require "English"
+#
+# $OUTPUT_FIELD_SEPARATOR = ' -- '
+# "waterbuffalo" =~ /buff/
+# print $LOADED_FEATURES, $POSTMATCH, $PID, "\n"
+
+# The exception object passed to +raise+.
alias $ERROR_INFO $!
+
+# The stack backtrace generated by the last
+# exception. <tt>See Kernel.caller</tt> for details. Thread local.
alias $ERROR_POSITION $@
-alias $LOADED_FEATURES $"
+
+# The default separator pattern used by <tt>String.split</tt>. May be
+# set from the command line using the <tt>-F</tt> flag.
alias $FS $;
+
+# The default separator pattern used by <tt>String.split</tt>. May be
+# set from the command line using the <tt>-F</tt> flag.
alias $FIELD_SEPARATOR $;
+
+# The separator string output between the parameters to methods such
+# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+,
+# which adds no text.
alias $OFS $,
+
+# The separator string output between the parameters to methods such
+# as <tt>Kernel.print</tt> and <tt>Array.join</tt>. Defaults to +nil+,
+# which adds no text.
alias $OUTPUT_FIELD_SEPARATOR $,
+
+# The input record separator (newline by default). This is the value
+# that routines such as <tt>Kernel.gets</tt> use to determine record
+# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $RS $/
+
+# The input record separator (newline by default). This is the value
+# that routines such as <tt>Kernel.gets</tt> use to determine record
+# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $INPUT_RECORD_SEPARATOR $/
+
+# The string appended to the output of every call to methods such as
+# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is
+# +nil+.
alias $ORS $\
-alias $OUPUT_RECORD_SEPARATOR $\
+
+# The string appended to the output of every call to methods such as
+# <tt>Kernel.print</tt> and <tt>IO.write</tt>. The default value is
+# +nil+.
+alias $OUTPUT_RECORD_SEPARATOR $\
+
+# The number of the last line read from the current input file.
alias $INPUT_LINE_NUMBER $.
+
+# The number of the last line read from the current input file.
alias $NR $.
+
+# The last line read by <tt>Kernel.gets</tt> or
+# <tt>Kernel.readline</tt>. Many string-related functions in the
+# +Kernel+ module operate on <tt>$_</tt> by default. The variable is
+# local to the current scope. Thread local.
alias $LAST_READ_LINE $_
+
+# The destination of output for <tt>Kernel.print</tt>
+# and <tt>Kernel.printf</tt>. The default value is
+# <tt>$stdout</tt>.
alias $DEFAULT_OUTPUT $>
+
+# An object that provides access to the concatenation
+# of the contents of all the files
+# given as command-line arguments, or <tt>$stdin</tt>
+# (in the case where there are no
+# arguments). <tt>$<</tt> supports methods similar to a
+# +File+ object:
+# +inmode+, +close+,
+# <tt>closed?</tt>, +each+,
+# <tt>each_byte</tt>, <tt>each_line</tt>,
+# +eof+, <tt>eof?</tt>, +file+,
+# +filename+, +fileno+,
+# +getc+, +gets+, +lineno+,
+# <tt>lineno=</tt>, +path+,
+# +pos+, <tt>pos=</tt>,
+# +read+, +readchar+,
+# +readline+, +readlines+,
+# +rewind+, +seek+, +skip+,
+# +tell+, <tt>to_a</tt>, <tt>to_i</tt>,
+# <tt>to_io</tt>, <tt>to_s</tt>, along with the
+# methods in +Enumerable+. The method +file+
+# returns a +File+ object for the file currently
+# being read. This may change as <tt>$<</tt> reads
+# through the files on the command line. Read only.
alias $DEFAULT_INPUT $<
+
+# The process number of the program being executed. Read only.
alias $PID $$
+
+# The process number of the program being executed. Read only.
alias $PROCESS_ID $$
+
+# The exit status of the last child process to terminate. Read
+# only. Thread local.
alias $CHILD_STATUS $?
+
+# A +MatchData+ object that encapsulates the results of a successful
+# pattern match. The variables <tt>$&</tt>, <tt>$`</tt>, <tt>$'</tt>,
+# and <tt>$1</tt> to <tt>$9</tt> are all derived from
+# <tt>$~</tt>. Assigning to <tt>$~</tt> changes the values of these
+# derived variables. This variable is local to the current
+# scope. Thread local.
alias $LAST_MATCH_INFO $~
+
+# If set to any value apart from +nil+ or +false+, all pattern matches
+# will be case insensitive, string comparisons will ignore case, and
+# string hash values will be case insensitive. Deprecated
alias $IGNORECASE $=
-alias $PROGRAM_NAME $0
+
+# An array of strings containing the command-line
+# options from the invocation of the program. Options
+# used by the Ruby interpreter will have been
+# removed. Read only. Also known simply as +ARGV+.
alias $ARGV $*
+
+# The string matched by the last successful pattern
+# match. This variable is local to the current
+# scope. Read only. Thread local.
alias $MATCH $&
+
+# The string preceding the match in the last
+# successful pattern match. This variable is local to
+# the current scope. Read only. Thread local.
alias $PREMATCH $`
+
+# The string following the match in the last
+# successful pattern match. This variable is local to
+# the current scope. Read only. Thread local.
alias $POSTMATCH $'
+
+# The contents of the highest-numbered group matched in the last
+# successful pattern match. Thus, in <tt>"cat" =~ /(c|a)(t|z)/</tt>,
+# <tt>$+</tt> will be set to "t". This variable is local to the
+# current scope. Read only. Thread local.
alias $LAST_PAREN_MATCH $+
diff --git a/lib/README b/lib/README
index de6a43af09..19d6309166 100644
--- a/lib/README
+++ b/lib/README
@@ -1,48 +1,96 @@
-English.rb access global variables by english names
-Env.rb access environment variables as globals
+English.rb lets Perl'ish global variables have English names
+Env.rb loads importenv.rb
README this file
-base64.rb encode/decode base64 (obsolete)
-cgi-lib.rb decode CGI data
+base64.rb encodes/decodes base64 (obsolete)
+benchmark.rb a benchmark utility
+cgi-lib.rb simple CGI support library (old style)
+cgi.rb CGI support library
+cgi/session.rb CGI session class
complex.rb complex number suppor
+csv.rb CSV parser/generator
date.rb date object
-date2.rb date object (compatible)
+date/format.rb date parsing and formatting
+date2.rb date object (obsolete; use date)
debug.rb ruby debugger
-delegate.rb delegate messages to other object
+delegate.rb delegates messages to other object
+drb.rb distributed Ruby
e2mmap.rb exception utilities
+erb.rb tiny eRuby library
eregex.rb extended regular expression (just a proof of concept)
-final.rb add finalizer to the object (simple)
-finalize.rb add finalizer to the object
-find.rb traverse directory tree
+fileutils.rb file utilities
+finalize.rb adds finalizer to the object
+find.rb traverses directory tree
+forwardable.rb explicit delegation library
ftools.rb file tools
-ftplib.rb ftp access library
getoptlong.rb GNU getoptlong compatible
-getopts.rb parse command line options
-importenv.rb access environment variables as globals
-jcode.rb japanese text handling (replace String methods)
-mailread.rb read mail headers
+getopts.rb parses command line options (use getoptlong)
+gserver.rb general TCP server
+importenv.rb imports environment variables as global variables
+ipaddr.rb defines the IPAddr class
+irb.rb interactive ruby
+jcode.rb Japanese text handling (replace String methods)
+logger.rb simple logging utility
+mailread.rb reads mail headers
mathn.rb extended math operation
matrix.rb matrix calculation library
mkmf.rb Makefile maker
monitor.rb exclusive region monitor for thread
mutex_m.rb mutex mixin
+net/ftp.rb ftp access
+net/http.rb HTTP access
+net/imap.rb IMAP4 access
+net/pop.rb POP3 access
+net/protocol.rb abstract class for net library (DO NOT USE)
+net/smtp.rb SMTP access
+net/telnet.rb telnet library
observer.rb observer desing pattern library (provides Observable)
-open3.rb open subprocess connection stdin/stdout/stderr
+open-uri.rb easy-to-use network interface using URI and Net
+open3.rb opens subprocess connection stdin/stdout/stderr
+optparse.rb command line option analysis
ostruct.rb python style object
parsearg.rb argument parser using getopts
-parsedate.rb parse date string
-ping.rb check whether host is up, using TCP echo.
-profile.rb ruby profiler
+parsedate.rb parses date string
+pathname.rb Object-Oriented Pathname Class
+ping.rb checks whether host is up, using TCP echo.
+pp.rb pretty print objects
+prettyprint.rb pretty printing algorithm
+profile.rb runs ruby profiler
+profiler.rb ruby profiler module
pstore.rb persistent object strage using marshal
+racc/parser.rb racc (Ruby yACC) runtime
rational.rb rational number support
+rdoc source-code documentation tool
readbytes.rb define IO#readbytes
-shell.rb shell like operation under Ruby (imcomplete)
+resolv-replace.rb replace Socket DNS by resolve.rb
+resolv.rb DNS resolver in Ruby
+rexml an XML parser for Ruby, in Ruby
+rubyunit.rb original Ruby Unit testing framework
+scanf.rb scanf for Ruby
+set.rb defines the Set class
+shell.rb runs commands and does pipeline operations like shell
shellwords.rb split into words like shell
singleton.rb singleton design pattern library
+soap SOAP 1.1 implementation
sync.rb 2 phase lock
-telnet.rb telnet library
-tempfile.rb temporary file that automatically removed
+tempfile.rb temporary file with automatic removal
+test/unit Ruby Unit Testing Framework
thread.rb thread support
thwait.rb thread syncronization class
-timeout.rb provids timeout
+time.rb RFC2822, RFC2616, ISO8601 style time formatting/parsing
+timeout.rb provides timeout
+tmpdir.rb retrieve temporary directory path
tracer.rb execution tracer
+tsort.rb topological sorting
+un.rb Utilities to replace common UNIX commands in Makefiles etc
+uri.rb URI support
+uri/ftp.rb ftp scheme support
+uri/http.rb http scheme support
+uri/https.rb https scheme support
+uri/ldap.rb ldap scheme support
+uri/mailto.rb mailto scheme support
weakref.rb weak reference class
+webrick.rb WEB server toolkit
+wsdl WSDL 1.1 implementation
+xmlrpc XML-RPC implementation
+xsd XML Schema Datatypes implementation
+yaml.rb YAML implementation
diff --git a/lib/abbrev.rb b/lib/abbrev.rb
new file mode 100644
index 0000000000..6530679681
--- /dev/null
+++ b/lib/abbrev.rb
@@ -0,0 +1,103 @@
+#!/usr/bin/env ruby
+=begin
+#
+# Copyright (c) 2001,2003 Akinori MUSHA <knu@iDaemons.org>
+#
+# All rights reserved. You can redistribute and/or modify it under
+# the same terms as Ruby.
+#
+# $Idaemons: /home/cvs/rb/abbrev.rb,v 1.2 2001/05/30 09:37:45 knu Exp $
+# $RoughId: abbrev.rb,v 1.4 2003/10/14 19:45:42 knu Exp $
+# $Id$
+=end
+
+# Calculate the set of unique abbreviations for a given set of strings.
+#
+# require 'abbrev'
+# require 'pp'
+#
+# pp Abbrev::abbrev(['ruby', 'rules']).sort
+#
+# <i>Generates:</i>
+#
+# [["rub", "ruby"],
+# ["ruby", "ruby"],
+# ["rul", "rules"],
+# ["rule", "rules"],
+# ["rules", "rules"]]
+#
+# Also adds an +abbrev+ method to class +Array+.
+
+module Abbrev
+
+ # Given a set of strings, calculate the set of unambiguous
+ # abbreviations for those strings, and return a hash where the keys
+ # are all the possible abbreviations and the values are the full
+ # strings. Thus, given input of "car" and "cone", the keys pointing
+ # to "car" would be "ca" and "car", while those pointing to "cone"
+ # would be "co", "con", and "cone".
+ #
+ # The optional +pattern+ parameter is a pattern or a string. Only
+ # those input strings matching the pattern, or begging the string,
+ # are considered for inclusion in the output hash
+
+ def abbrev(words, pattern = nil)
+ table = {}
+ seen = Hash.new(0)
+
+ if pattern.is_a?(String)
+ pattern = /^#{Regexp.quote(pattern)}/ # regard as a prefix
+ end
+
+ words.each do |word|
+ next if (abbrev = word).empty?
+ while (len = abbrev.rindex(/[\w\W]\z/)) > 0
+ abbrev = word[0,len]
+
+ next if pattern && pattern !~ abbrev
+
+ case seen[abbrev] += 1
+ when 1
+ table[abbrev] = word
+ when 2
+ table.delete(abbrev)
+ else
+ break
+ end
+ end
+ end
+
+ words.each do |word|
+ next if pattern && pattern !~ word
+
+ table[word] = word
+ end
+
+ table
+ end
+
+ module_function :abbrev
+end
+
+class Array
+ # Calculates the set of unambiguous abbreviations for the strings in
+ # +self+. If passed a pattern or a string, only the strings matching
+ # the pattern or starting with the string are considered.
+ #
+ # %w{ car cone }.abbrev #=> { "ca" => "car", "car" => "car",
+ # "co" => "cone", "con" => cone",
+ # "cone" => "cone" }
+ def abbrev(pattern = nil)
+ Abbrev::abbrev(self, pattern)
+ end
+end
+
+if $0 == __FILE__
+ while line = gets
+ hash = line.split.abbrev
+
+ hash.sort.each do |k, v|
+ puts "#{k} => #{v}"
+ end
+ end
+end
diff --git a/lib/base64.rb b/lib/base64.rb
index d7461d82e7..410d76ffcd 100644
--- a/lib/base64.rb
+++ b/lib/base64.rb
@@ -1,29 +1,133 @@
+#
+# = base64.rb: methods for base64-encoding and -decoding stings
+#
+# Author:: Yukihiro Matsumoto
+# Documentation:: Dave Thomas and Gavin Sinclair
+#
+# Until Ruby 1.8.1, these methods were defined at the top-level. Now
+# they are in the Base64 module but included in the top-level, where
+# their usage is deprecated.
+#
+# See Base64 for documentation.
+#
+
require "kconv"
-def decode64(str)
- str.unpack("m")[0]
-end
-def decode_b(str)
- str.gsub!(/=\?ISO-2022-JP\?B\?([!->@-~]+)\?=/i) {
- decode64($1)
- }
- str = Kconv::toeuc(str)
- str.gsub!(/=\?SHIFT_JIS\?B\?([!->@-~]+)\?=/i) {
- decode64($1)
- }
- str = Kconv::toeuc(str)
- str.gsub!(/\n/, ' ')
- str.gsub!(/\0/, '')
- str
-end
+# The Base64 module provides for the encoding (#encode64) and decoding
+# (#decode64) of binary data using a Base64 representation.
+#
+# The following particular features are also provided:
+# - encode into lines of a given length (#b64encode)
+# - decode the special format specified in RFC2047 for the
+# representation of email headers (decode_b)
+#
+# == Example
+#
+# A simple encoding and decoding.
+#
+# require "base64"
+#
+# enc = Base64.encode64('Send reinforcements')
+# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
+# plain = Base64.decode64(enc)
+# # -> "Send reinforcements"
+#
+# The purpose of using base64 to encode data is that it translates any
+# binary data into purely printable characters. It is specified in
+# RFC 2045 (http://www.faqs.org/rfcs/rfc2045.html).
-def encode64(bin)
- [bin].pack("m")
-end
+module Base64
+ module_function
+
+ # Returns the Base64-decoded version of +str+.
+ #
+ # require 'base64'
+ # str = 'VGhpcyBpcyBsaW5lIG9uZQpUaGlzIG' +
+ # 'lzIGxpbmUgdHdvClRoaXMgaXMgbGlu' +
+ # 'ZSB0aHJlZQpBbmQgc28gb24uLi4K'
+ # puts Base64.decode64(str)
+ #
+ # <i>Generates:</i>
+ #
+ # This is line one
+ # This is line two
+ # This is line three
+ # And so on...
+
+ def decode64(str)
+ str.unpack("m")[0]
+ end
+
+
+ # Decodes text formatted using a subset of RFC2047 (the one used for
+ # mime-encoding mail headers).
+ #
+ # Only supports an encoding type of 'b' (base 64), and only supports
+ # the character sets ISO-2022-JP and SHIFT_JIS (so the only two
+ # encoded word sequences recognized are <tt>=?ISO-2022-JP?B?...=</tt> and
+ # <tt>=?SHIFT_JIS?B?...=</tt>). Recognition of these sequences is case
+ # insensitive.
+
+ def decode_b(str)
+ str.gsub!(/=\?ISO-2022-JP\?B\?([!->@-~]+)\?=/i) {
+ decode64($1)
+ }
+ str = Kconv::toeuc(str)
+ str.gsub!(/=\?SHIFT_JIS\?B\?([!->@-~]+)\?=/i) {
+ decode64($1)
+ }
+ str = Kconv::toeuc(str)
+ str.gsub!(/\n/, ' ')
+ str.gsub!(/\0/, '')
+ str
+ end
+
+ # Returns the Base64-encoded version of +str+.
+ #
+ # require 'base64'
+ # Base64.b64encode("Now is the time for all good coders\nto learn Ruby")
+ #
+ # <i>Generates:</i>
+ #
+ # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
+ # UnVieQ==
+
+ def encode64(bin)
+ [bin].pack("m")
+ end
+
+ # _Prints_ the Base64 encoded version of +bin+ (a +String+) in lines of
+ # +len+ (default 60) characters.
+ #
+ # require 'base64'
+ # data = "Now is the time for all good coders\nto learn Ruby"
+ # puts Base64.b64encode(data)
+ #
+ # <i>Generates:</i>
+ #
+ # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
+ # UnVieQ==
-def b64encode(bin, len = 60)
- encode64(bin).scan(/.{1,#{len}}/o) do
- print $&, "\n"
+ def b64encode(bin, len = 60)
+ encode64(bin).scan(/.{1,#{len}}/o) do
+ print $&, "\n"
+ end
+ end
+
+
+ module Deprecated # :nodoc:
+ include Base64
+
+ for m in Base64.private_instance_methods(false)
+ module_eval %{
+ def #{m}(*args)
+ warn("\#{caller(1)[0]}: #{m} is deprecated; use Base64.#{m} instead")
+ super
+ end
+ }
+ end
end
-end
+end
+
+include Base64::Deprecated
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
new file mode 100644
index 0000000000..36e593518f
--- /dev/null
+++ b/lib/benchmark.rb
@@ -0,0 +1,569 @@
+=begin
+#
+# benchmark.rb - a performance benchmarking library
+#
+# $Id$
+#
+# Created by Gotoken (gotoken@notwork.org).
+#
+# Documentation by Gotoken (original RD), Lyle Johnson (RDoc conversion), and
+# Gavin Sinclair (editing).
+#
+=end
+
+# == Overview
+#
+# The Benchmark module provides methods for benchmarking Ruby code, giving
+# detailed reports on the time taken for each task.
+#
+
+# The Benchmark module provides methods to measure and report the time
+# used to execute Ruby code.
+#
+# * Measure the time to construct the string given by the expression
+# <tt>"a"*1_000_000</tt>:
+#
+# require 'benchmark'
+#
+# puts Benchmark.measure { "a"*1_000_000 }
+#
+# On my machine (FreeBSD 3.2 on P5, 100MHz) this generates:
+#
+# 1.166667 0.050000 1.216667 ( 0.571355)
+#
+# This report shows the user CPU time, system CPU time, the sum of
+# the user and system CPU times, and the elapsed real time. The unit
+# of time is seconds.
+#
+# * Do some experiments sequentially using the #bm method:
+#
+# require 'benchmark'
+#
+# n = 50000
+# Benchmark.bm do |x|
+# x.report { for i in 1..n; a = "1"; end }
+# x.report { n.times do ; a = "1"; end }
+# x.report { 1.upto(n) do ; a = "1"; end }
+# end
+#
+# The result:
+#
+# user system total real
+# 1.033333 0.016667 1.016667 ( 0.492106)
+# 1.483333 0.000000 1.483333 ( 0.694605)
+# 1.516667 0.000000 1.516667 ( 0.711077)
+#
+# * Continuing the previous example, put a label in each report:
+#
+# require 'benchmark'
+#
+# n = 50000
+# Benchmark.bm(7) do |x|
+# x.report("for:") { for i in 1..n; a = "1"; end }
+# x.report("times:") { n.times do ; a = "1"; end }
+# x.report("upto:") { 1.upto(n) do ; a = "1"; end }
+# end
+#
+# The result:
+#
+# user system total real
+# for: 1.050000 0.000000 1.050000 ( 0.503462)
+# times: 1.533333 0.016667 1.550000 ( 0.735473)
+# upto: 1.500000 0.016667 1.516667 ( 0.711239)
+#
+#
+# * The times for some benchmarks depend on the order in which items
+# are run. These differences are due to the cost of memory
+# allocation and garbage collection. To avoid these discrepancies,
+# the #bmbm method is provided. For example, to compare ways to
+# sort an array of floats:
+#
+# require 'benchmark'
+#
+# array = (1..1000000).map { rand }
+#
+# Benchmark.bmbm do |x|
+# x.report("sort!") { array.dup.sort! }
+# x.report("sort") { array.dup.sort }
+# end
+#
+# The result:
+#
+# Rehearsal -----------------------------------------
+# sort! 11.928000 0.010000 11.938000 ( 12.756000)
+# sort 13.048000 0.020000 13.068000 ( 13.857000)
+# ------------------------------- total: 25.006000sec
+#
+# user system total real
+# sort! 12.959000 0.010000 12.969000 ( 13.793000)
+# sort 12.007000 0.000000 12.007000 ( 12.791000)
+#
+#
+# * Report statistics of sequential experiments with unique labels,
+# using the #benchmark method:
+#
+# require 'benchmark'
+#
+# n = 50000
+# Benchmark.benchmark(" "*7 + CAPTION, 7, FMTSTR, ">total:", ">avg:") do |x|
+# tf = x.report("for:") { for i in 1..n; a = "1"; end }
+# tt = x.report("times:") { n.times do ; a = "1"; end }
+# tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
+# [tf+tt+tu, (tf+tt+tu)/3]
+# end
+#
+# The result:
+#
+# user system total real
+# for: 1.016667 0.016667 1.033333 ( 0.485749)
+# times: 1.450000 0.016667 1.466667 ( 0.681367)
+# upto: 1.533333 0.000000 1.533333 ( 0.722166)
+# >total: 4.000000 0.033333 4.033333 ( 1.889282)
+# >avg: 1.333333 0.011111 1.344444 ( 0.629761)
+
+module Benchmark
+
+ BENCHMARK_VERSION = "2002-04-25" #:nodoc"
+
+ def Benchmark::times() # :nodoc:
+ Process::times()
+ end
+
+
+ # Invokes the block with a <tt>Benchmark::Report</tt> object, which
+ # may be used to collect and report on the results of individual
+ # benchmark tests. Reserves <i>label_width</i> leading spaces for
+ # labels on each line. Prints _caption_ at the top of the
+ # report, and uses _fmt_ to format each line.
+ # If the block returns an array of
+ # <tt>Benchmark::Tms</tt> objects, these will be used to format
+ # additional lines of output. If _label_ parameters are
+ # given, these are used to label these extra lines.
+ #
+ # _Note_: Other methods provide a simpler interface to this one, and are
+ # suitable for nearly all benchmarking requirements. See the examples in
+ # Benchmark, and the #bm and #bmbm methods.
+ #
+ # Example:
+ #
+ # require 'benchmark'
+ # include Benchmark # we need the CAPTION and FMTSTR constants
+ #
+ # n = 50000
+ # Benchmark.benchmark(" "*7 + CAPTION, 7, FMTSTR, ">total:", ">avg:") do |x|
+ # tf = x.report("for:") { for i in 1..n; a = "1"; end }
+ # tt = x.report("times:") { n.times do ; a = "1"; end }
+ # tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
+ # [tf+tt+tu, (tf+tt+tu)/3]
+ # end
+ #
+ # <i>Generates:</i>
+ #
+ # user system total real
+ # for: 1.016667 0.016667 1.033333 ( 0.485749)
+ # times: 1.450000 0.016667 1.466667 ( 0.681367)
+ # upto: 1.533333 0.000000 1.533333 ( 0.722166)
+ # >total: 4.000000 0.033333 4.033333 ( 1.889282)
+ # >avg: 1.333333 0.011111 1.344444 ( 0.629761)
+ #
+
+ def benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) # :yield: report
+ sync = STDOUT.sync
+ STDOUT.sync = true
+ label_width ||= 0
+ fmtstr ||= FMTSTR
+ raise ArgumentError, "no block" unless iterator?
+ print caption
+ results = yield(Report.new(label_width, fmtstr))
+ Array === results and results.grep(Tms).each {|t|
+ print((labels.shift || t.label || "").ljust(label_width),
+ t.format(fmtstr))
+ }
+ STDOUT.sync = sync
+ end
+
+
+ # A simple interface to the #benchmark method, #bm is generates sequential reports
+ # with labels. The parameters have the same meaning as for #benchmark.
+ #
+ # require 'benchmark'
+ #
+ # n = 50000
+ # Benchmark.bm(7) do |x|
+ # x.report("for:") { for i in 1..n; a = "1"; end }
+ # x.report("times:") { n.times do ; a = "1"; end }
+ # x.report("upto:") { 1.upto(n) do ; a = "1"; end }
+ # end
+ #
+ # <i>Generates:</i>
+ #
+ # user system total real
+ # for: 1.050000 0.000000 1.050000 ( 0.503462)
+ # times: 1.533333 0.016667 1.550000 ( 0.735473)
+ # upto: 1.500000 0.016667 1.516667 ( 0.711239)
+ #
+
+ def bm(label_width = 0, *labels, &blk) # :yield: report
+ benchmark(" "*label_width + CAPTION, label_width, FMTSTR, *labels, &blk)
+ end
+
+
+ # Sometimes benchmark results are skewed because code executed
+ # earlier encounters different garbage collection overheads than
+ # that run later. #bmbm attempts to minimize this effect by running
+ # the tests twice, the first time as a rehearsal in order to get the
+ # runtime environment stable, the second time for
+ # real. <tt>GC.start</tt> is executed before the start of each of
+ # the real timings; the cost of this is not included in the
+ # timings. In reality, though, there's only so much that #bmbm can
+ # do, and the results are not guaranteed to be isolated from garbage
+ # collection and other effects.
+ #
+ # Because #bmbm takes two passes through the tests, it can
+ # calculate the required label width.
+ #
+ # require 'benchmark'
+ #
+ # array = (1..1000000).map { rand }
+ #
+ # Benchmark.bmbm do |x|
+ # x.report("sort!") { array.dup.sort! }
+ # x.report("sort") { array.dup.sort }
+ # end
+ #
+ # <i>Generates:</i>
+ #
+ # Rehearsal -----------------------------------------
+ # sort! 11.928000 0.010000 11.938000 ( 12.756000)
+ # sort 13.048000 0.020000 13.068000 ( 13.857000)
+ # ------------------------------- total: 25.006000sec
+ #
+ # user system total real
+ # sort! 12.959000 0.010000 12.969000 ( 13.793000)
+ # sort 12.007000 0.000000 12.007000 ( 12.791000)
+ #
+ # #bmbm yields a Benchmark::Job object and returns an array of
+ # Benchmark::Tms objects.
+ #
+ def bmbm(width = 0, &blk) # :yield: job
+ job = Job.new(width)
+ yield(job)
+ width = job.width
+ sync = STDOUT.sync
+ STDOUT.sync = true
+
+ # rehearsal
+ print "Rehearsal "
+ puts '-'*(width+CAPTION.length - "Rehearsal ".length)
+ list = []
+ job.list.each{|label,item|
+ print(label.ljust(width))
+ res = Benchmark::measure(&item)
+ print res.format()
+ list.push res
+ }
+ sum = Tms.new; list.each{|i| sum += i}
+ ets = sum.format("total: %tsec")
+ printf("%s %s\n\n",
+ "-"*(width+CAPTION.length-ets.length-1), ets)
+
+ # take
+ print ' '*width, CAPTION
+ list = []
+ ary = []
+ job.list.each{|label,item|
+ GC::start
+ print label.ljust(width)
+ res = Benchmark::measure(&item)
+ print res.format()
+ ary.push res
+ list.push [label, res]
+ }
+
+ STDOUT.sync = sync
+ ary
+ end
+
+ #
+ # Returns the time used to execute the given block as a
+ # Benchmark::Tms object.
+ #
+ def measure(label = "") # :yield:
+ t0, r0 = Benchmark.times, Time.now
+ yield
+ t1, r1 = Benchmark.times, Time.now
+ Benchmark::Tms.new(t1.utime - t0.utime,
+ t1.stime - t0.stime,
+ t1.cutime - t0.cutime,
+ t1.cstime - t0.cstime,
+ r1.to_f - r0.to_f,
+ label)
+ end
+
+ #
+ # Returns the elapsed real time used to execute the given block.
+ #
+ def realtime(&blk) # :yield:
+ Benchmark::measure(&blk).real
+ end
+
+
+
+ #
+ # A Job is a sequence of labelled blocks to be processed by the
+ # Benchmark.bmbm method. It is of little direct interest to the user.
+ #
+ class Job # :nodoc:
+ #
+ # Returns an initialized Job instance.
+ # Usually, one doesn't call this method directly, as new
+ # Job objects are created by the #bmbm method.
+ # _width_ is a initial value for the label offset used in formatting;
+ # the #bmbm method passes its _width_ argument to this constructor.
+ #
+ def initialize(width)
+ @width = width
+ @list = []
+ end
+
+ #
+ # Registers the given label and block pair in the job list.
+ #
+ def item(label = "", &blk) # :yield:
+ raise ArgmentError, "no block" unless block_given?
+ label.concat ' '
+ w = label.length
+ @width = w if @width < w
+ @list.push [label, blk]
+ self
+ end
+
+ alias report item
+
+ # An array of 2-element arrays, consisting of label and block pairs.
+ attr_reader :list
+
+ # Length of the widest label in the #list, plus one.
+ attr_reader :width
+ end
+
+ module_function :benchmark, :measure, :realtime, :bm, :bmbm
+
+
+
+ #
+ # This class is used by the Benchmark.benchmark and Benchmark.bm methods.
+ # It is of little direct interest to the user.
+ #
+ class Report # :nodoc:
+ #
+ # Returns an initialized Report instance.
+ # Usually, one doesn't call this method directly, as new
+ # Report objects are created by the #benchmark and #bm methods.
+ # _width_ and _fmtstr_ are the label offset and
+ # format string used by Tms#format.
+ #
+ def initialize(width = 0, fmtstr = nil)
+ @width, @fmtstr = width, fmtstr
+ end
+
+ #
+ # Prints the _label_ and measured time for the block,
+ # formatted by _fmt_. See Tms#format for the
+ # formatting rules.
+ #
+ def item(label = "", *fmt, &blk) # :yield:
+ print label.ljust(@width)
+ res = Benchmark::measure(&blk)
+ print res.format(@fmtstr, *fmt)
+ res
+ end
+
+ alias report item
+ end
+
+
+
+ #
+ # A data object, representing the times associated with a benchmark
+ # measurement.
+ #
+ class Tms
+ CAPTION = " user system total real\n"
+ FMTSTR = "%10.6u %10.6y %10.6t %10.6r\n"
+
+ # User CPU time
+ attr_reader :utime
+
+ # System CPU time
+ attr_reader :stime
+
+ # User CPU time of children
+ attr_reader :cutime
+
+ # System CPU time of children
+ attr_reader :cstime
+
+ # Elapsed real time
+ attr_reader :real
+
+ # Total time, that is _utime_ + _stime_ + _cutime_ + _cstime_
+ attr_reader :total
+
+ # Label
+ attr_reader :label
+
+ #
+ # Returns an initialized Tms object which has
+ # _u_ as the user CPU time, _s_ as the system CPU time,
+ # _cu_ as the children's user CPU time, _cs_ as the children's
+ # system CPU time, _real_ as the elapsed real time and _l_
+ # as the label.
+ #
+ def initialize(u = 0.0, s = 0.0, cu = 0.0, cs = 0.0, real = 0.0, l = nil)
+ @utime, @stime, @cutime, @cstime, @real, @label = u, s, cu, cs, real, l
+ @total = @utime + @stime + @cutime + @cstime
+ end
+
+ #
+ # Returns a new Tms object whose times are the sum of the times for this
+ # Tms object, plus the time required to execute the code block (_blk_).
+ #
+ def add(&blk) # :yield:
+ self + Benchmark::measure(&blk)
+ end
+
+ #
+ # An in-place version of #add.
+ #
+ def add!
+ t = Benchmark::measure(&blk)
+ @utime = utime + t.utime
+ @stime = stime + t.stime
+ @cutime = cutime + t.cutime
+ @cstime = cstime + t.cstime
+ @real = real + t.real
+ self
+ end
+
+ #
+ # Returns a new Tms object obtained by memberwise summation
+ # of the individual times for this Tms object with those of the other
+ # Tms object.
+ # This method and #/() are useful for taking statistics.
+ #
+ def +(other); memberwise(:+, other) end
+
+ #
+ # Returns a new Tms object obtained by memberwise subtraction
+ # of the individual times for the other Tms object from those of this
+ # Tms object.
+ #
+ def -(other); memberwise(:-, other) end
+
+ #
+ # Returns a new Tms object obtained by memberwise multiplication
+ # of the individual times for this Tms object by _x_.
+ #
+ def *(x); memberwise(:*, x) end
+
+ #
+ # Returns a new Tms object obtained by memberwise division
+ # of the individual times for this Tms object by _x_.
+ # This method and #+() are useful for taking statistics.
+ #
+ def /(x); memberwise(:/, x) end
+
+ #
+ # Returns the contents of this Tms object as
+ # a formatted string, according to a format string
+ # like that passed to Kernel.format. In addition, #format
+ # accepts the following extensions:
+ #
+ # <tt>%u</tt>:: Replaced by the user CPU time, as reported by Tms#utime.
+ # <tt>%y</tt>:: Replaced by the system CPU time, as reported by #stime (Mnemonic: y of "s*y*stem")
+ # <tt>%U</tt>:: Replaced by the children's user CPU time, as reported by Tms#cutime
+ # <tt>%Y</tt>:: Replaced by the children's system CPU time, as reported by Tms#cstime
+ # <tt>%t</tt>:: Replaced by the total CPU time, as reported by Tms#total
+ # <tt>%r</tt>:: Replaced by the elapsed real time, as reported by Tms#real
+ # <tt>%n</tt>:: Replaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame")
+ #
+ # If _fmtstr_ is not given, FMTSTR is used as default value, detailing the
+ # user, system and real elapsed time.
+ #
+ def format(arg0 = nil, *args)
+ fmtstr = (arg0 || FMTSTR).dup
+ fmtstr.gsub!(/(%[-+\.\d]*)n/){"#{$1}s" % label}
+ fmtstr.gsub!(/(%[-+\.\d]*)u/){"#{$1}f" % utime}
+ fmtstr.gsub!(/(%[-+\.\d]*)y/){"#{$1}f" % stime}
+ fmtstr.gsub!(/(%[-+\.\d]*)U/){"#{$1}f" % cutime}
+ fmtstr.gsub!(/(%[-+\.\d]*)Y/){"#{$1}f" % cstime}
+ fmtstr.gsub!(/(%[-+\.\d]*)t/){"#{$1}f" % total}
+ fmtstr.gsub!(/(%[-+\.\d]*)r/){"(#{$1}f)" % real}
+ arg0 ? Kernel::format(fmtstr, *args) : fmtstr
+ end
+
+ #
+ # Same as #format.
+ #
+ def to_s
+ format
+ end
+
+ #
+ # Returns a new 6-element array, consisting of the
+ # label, user CPU time, system CPU time, children's
+ # user CPU time, children's system CPU time and elapsed
+ # real time.
+ #
+ def to_a
+ [@label, @utime, @stime, @cutime, @cstime, @real]
+ end
+
+ protected
+ def memberwise(op, x)
+ case x
+ when Benchmark::Tms
+ Benchmark::Tms.new(utime.__send__(op, x.utime),
+ stime.__send__(op, x.stime),
+ cutime.__send__(op, x.cutime),
+ cstime.__send__(op, x.cstime),
+ real.__send__(op, x.real)
+ )
+ else
+ Benchmark::Tms.new(utime.__send__(op, x),
+ stime.__send__(op, x),
+ cutime.__send__(op, x),
+ cstime.__send__(op, x),
+ real.__send__(op, x)
+ )
+ end
+ end
+ end
+
+ # The default caption string (heading above the output times).
+ CAPTION = Benchmark::Tms::CAPTION
+
+ # The default format string used to display times. See also Benchmark::Tms#format.
+ FMTSTR = Benchmark::Tms::FMTSTR
+end
+
+if __FILE__ == $0
+ include Benchmark
+
+ n = ARGV[0].to_i.nonzero? || 50000
+ puts %Q([#{n} times iterations of `a = "1"'])
+ benchmark(" " + CAPTION, 7, FMTSTR) do |x|
+ x.report("for:") {for i in 1..n; a = "1"; end} # Benchmark::measure
+ x.report("times:") {n.times do ; a = "1"; end}
+ x.report("upto:") {1.upto(n) do ; a = "1"; end}
+ end
+
+ benchmark do
+ [
+ measure{for i in 1..n; a = "1"; end}, # Benchmark::measure
+ measure{n.times do ; a = "1"; end},
+ measure{1.upto(n) do ; a = "1"; end}
+ ]
+ end
+end
diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb
index ffe3fcf367..bc780ffc4e 100644
--- a/lib/cgi-lib.rb
+++ b/lib/cgi-lib.rb
@@ -181,7 +181,7 @@ class CGI < SimpleDelegator
super(@inputs)
if ENV.has_key?('HTTP_COOKIE') or ENV.has_key?('COOKIE')
- (ENV['HTTP_COOKIE'] or ENV['COOKIE']).split("; ").each do |x|
+ (ENV['HTTP_COOKIE'] or ENV['COOKIE']).split(/; /).each do |x|
key, val = x.split(/=/,2)
key = CGI::unescape(key)
val = val.split(/&/).collect{|x|CGI::unescape(x)}.join("\0")
@@ -216,10 +216,10 @@ class CGI < SimpleDelegator
# make HTTP header string
def CGI::header(*options)
- if ENV['MOD_RUBY']
+ if defined?(MOD_RUBY)
options.each{|option|
option.sub(/(.*?): (.*)/){
- Apache::request[$1] = $2
+ Apache::request.headers_out[$1] = $2
}
}
Apache::request.send_http_header
diff --git a/lib/cgi.rb b/lib/cgi.rb
index fcf8c006e5..0fd0bc7cd4 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -1,199 +1,297 @@
-=begin
-
-== NAME
-
-cgi.rb - cgi support library
-
-Version 2.1.4
-
-Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
-
-Copyright (C) 2000 Information-technology Promotion Agency, Japan
-
-Wakou Aoyama <wakou@fsinet.or.jp>
-
-
-
-== EXAMPLE
-
-=== GET FORM VALUES
-
- require "cgi"
- cgi = CGI.new
- values = cgi['field_name'] # <== array of 'field_name'
- # if not 'field_name' included, then return [].
- fields = cgi.keys # <== array of field names
-
- # returns true if form has 'field_name'
- cgi.has_key?('field_name')
- cgi.has_key?('field_name')
- cgi.include?('field_name')
-
-
-=== GET FORM VALUES AS HASH
-
- require "cgi"
- cgi = CGI.new
- params = cgi.params
-
-cgi.params is a hash.
-
- cgi.params['new_field_name'] = ["value"] # add new param
- cgi.params['field_name'] = ["new_value"] # change value
- cgi.params.delete('field_name') # delete param
- cgi.params.clear # delete all params
-
-
-=== SAVE FORM VALUES TO FILE
-
- require "pstore"
- db = PStore.new("query.db")
- db.transaction do
- db["params"] = cgi.params
- end
-
-
-=== RESTORE FORM VALUES FROM FILE
-
- require "pstore"
- db = PStore.new("query.db")
- db.transaction do
- cgi.params = db["params"]
- end
-
-
-=== GET MULTIPART FORM VALUES
-
- require "cgi"
- cgi = CGI.new
- values = cgi['field_name'] # <== array of 'field_name'
- values[0].read # <== body of values[0]
- values[0].local_path # <== path to local file of values[0]
- values[0].original_filename # <== original filename of values[0]
- values[0].content_type # <== content_type of values[0]
-
-and values[0] has Tempfile class methods.
-(Tempfile class object has File class methods)
-
-
-=== GET COOKIE VALUES
-
- require "cgi"
- cgi = CGI.new
- values = cgi.cookies['name'] # <== array of 'name'
- # if not 'name' included, then return [].
- names = cgi.cookies.keys # <== array of cookie names
-
-and cgi.cookies is a hash.
-
-
-=== GET COOKIE OBJECTS
-
- require "cgi"
- cgi = CGI.new
- for name, cookie in cgi.cookies
- cookie.expires = Time.now + 30
- end
- cgi.out("cookie" => cgi.cookies){"string"}
-
- cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
-
- require "cgi"
- cgi = CGI.new
- cgi.cookies['name'].expires = Time.now + 30
- cgi.out("cookie" => cgi.cookies['name']){"string"}
-
-and see MAKE COOKIE OBJECT.
-
-
-=== GET ENVIRONMENT VALUE
-
- require "cgi"
- cgi = CGI.new
- value = cgi.auth_type
- # ENV["AUTH_TYPE"]
-
-see http://www.w3.org/CGI/
-
-AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE GATEWAY_INTERFACE PATH_INFO
-PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_IDENT
-REMOTE_USER REQUEST_METHOD SCRIPT_NAME SERVER_NAME SERVER_PORT
-SERVER_PROTOCOL SERVER_SOFTWARE
-
-content_length and server_port return Integer. and the others return String.
-
-and HTTP_COOKIE, HTTP_COOKIE2
-
- value = cgi.raw_cookie
- # ENV["HTTP_COOKIE"]
- value = cgi.raw_cookie2
- # ENV["HTTP_COOKIE2"]
-
-and other HTTP_*
-
- value = cgi.accept
- # ENV["HTTP_ACCEPT"]
- value = cgi.accept_charset
- # ENV["HTTP_ACCEPT_CHARSET"]
-
-HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE
-HTTP_CACHE_CONTROL HTTP_FROM HTTP_HOST HTTP_NEGOTIATE HTTP_PRAGMA
-HTTP_REFERER HTTP_USER_AGENT
-
-
-=== PRINT HTTP HEADER AND HTML STRING TO $DEFAULT_OUTPUT ($>)
-
- require "cgi"
- cgi = CGI.new("html3") # add HTML generation methods
- cgi.out() do
- cgi.html() do
- cgi.head{ cgi.title{"TITLE"} } +
- cgi.body() do
- cgi.form() do
- cgi.textarea("get_text") +
- cgi.br +
- cgi.submit
- end +
- cgi.pre() do
- CGI::escapeHTML(
- "params: " + cgi.params.inspect + "\n" +
- "cookies: " + cgi.cookies.inspect + "\n" +
- ENV.collect() do |key, value|
- key + " --> " + value + "\n"
- end.join("")
- )
- end
- end
- end
- end
-
- # add HTML generation methods
- CGI.new("html3") # html3.2
- CGI.new("html4") # html4.0 (Strict)
- CGI.new("html4Tr") # html4.0 Transitional
- CGI.new("html4Fr") # html4.0 Frameset
-
-
-=end
-
-raise "Please, use ruby1.5.4 or later." if RUBY_VERSION < "1.5.4"
+#
+# cgi.rb - cgi support library
+#
+# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+#
+# Copyright (C) 2000 Information-technology Promotion Agency, Japan
+#
+# Author: Wakou Aoyama <wakou@ruby-lang.org>
+#
+# Documentation: Wakou Aoyama (RDoc'd and embellished by William Webber)
+#
+# == Overview
+#
+# The Common Gateway Interface (CGI) is a simple protocol
+# for passing an HTTP request from a web server to a
+# standalone program, and returning the output to the web
+# browser. Basically, a CGI program is called with the
+# parameters of the request passed in either in the
+# environment (GET) or via $stdin (POST), and everything
+# it prints to $stdout is returned to the client.
+#
+# This file holds the +CGI+ class. This class provides
+# functionality for retrieving HTTP request parameters,
+# managing cookies, and generating HTML output. See the
+# class documentation for more details and examples of use.
+#
+# The file cgi/session.rb provides session management
+# functionality; see that file for more details.
+#
+# See http://www.w3.org/CGI/ for more information on the CGI
+# protocol.
+
+raise "Please, use ruby 1.5.4 or later." if RUBY_VERSION < "1.5.4"
require 'English'
+# CGI class. See documentation for the file cgi.rb for an overview
+# of the CGI protocol.
+#
+# == Introduction
+#
+# CGI is a large class, providing several categories of methods, many of which
+# are mixed in from other modules. Some of the documentation is in this class,
+# some in the modules CGI::QueryExtension and CGI::HtmlExtension. See
+# CGI::Cookie for specific information on handling cookies, and cgi/session.rb
+# (CGI::Session) for information on sessions.
+#
+# For queries, CGI provides methods to get at environmental variables,
+# parameters, cookies, and multipart request data. For responses, CGI provides
+# methods for writing output and generating HTML.
+#
+# Read on for more details. Examples are provided at the bottom.
+#
+# == Queries
+#
+# The CGI class dynamically mixes in parameter and cookie-parsing
+# functionality, environmental variable access, and support for
+# parsing multipart requests (including uploaded files) from the
+# CGI::QueryExtension module.
+#
+# === Environmental Variables
+#
+# The standard CGI environmental variables are available as read-only
+# attributes of a CGI object. The following is a list of these variables:
+#
+#
+# AUTH_TYPE HTTP_HOST REMOTE_IDENT
+# CONTENT_LENGTH HTTP_NEGOTIATE REMOTE_USER
+# CONTENT_TYPE HTTP_PRAGMA REQUEST_METHOD
+# GATEWAY_INTERFACE HTTP_REFERER SCRIPT_NAME
+# HTTP_ACCEPT HTTP_USER_AGENT SERVER_NAME
+# HTTP_ACCEPT_CHARSET PATH_INFO SERVER_PORT
+# HTTP_ACCEPT_ENCODING PATH_TRANSLATED SERVER_PROTOCOL
+# HTTP_ACCEPT_LANGUAGE QUERY_STRING SERVER_SOFTWARE
+# HTTP_CACHE_CONTROL REMOTE_ADDR
+# HTTP_FROM REMOTE_HOST
+#
+#
+# For each of these variables, there is a corresponding attribute with the
+# same name, except all lower case and without a preceding HTTP_.
+# +content_length+ and +server_port+ are integers; the rest are strings.
+#
+# === Parameters
+#
+# The method #params() returns a hash of all parameters in the request as
+# name/value-list pairs, where the value-list is an Array of one or more
+# values. The CGI object itself also behaves as a hash of parameter names
+# to values, but only returns a single value (as a String) for each
+# parameter name.
+#
+# For instance, suppose the request contains the parameter
+# "favourite_colours" with the multiple values "blue" and "green". The
+# following behaviour would occur:
+#
+# cgi.params["favourite_colours"] # => ["blue", "green"]
+# cgi["favourite_colours"] # => "blue"
+#
+# If a parameter does not exist, the former method will return an empty
+# array, the latter an empty string. The simplest way to test for existence
+# of a parameter is by the #has_key? method.
+#
+# === Cookies
+#
+# HTTP Cookies are automatically parsed from the request. They are available
+# from the #cookies() accessor, which returns a hash from cookie name to
+# CGI::Cookie object.
+#
+# === Multipart requests
+#
+# If a request's method is POST and its content type is multipart/form-data,
+# then it may contain uploaded files. These are stored by the QueryExtension
+# module in the parameters of the request. The parameter name is the name
+# attribute of the file input field, as usual. However, the value is not
+# a string, but an IO object, either an IOString for small files, or a
+# Tempfile for larger ones. This object also has the additional singleton
+# methods:
+#
+# #local_path():: the path of the uploaded file on the local filesystem
+# #original_filename():: the name of the file on the client computer
+# #content_type():: the content type of the file
+#
+# == Responses
+#
+# The CGI class provides methods for sending header and content output to
+# the HTTP client, and mixes in methods for programmatic HTML generation
+# from CGI::HtmlExtension and CGI::TagMaker modules. The precise version of HTML
+# to use for HTML generation is specified at object creation time.
+#
+# === Writing output
+#
+# The simplest way to send output to the HTTP client is using the #out() method.
+# This takes the HTTP headers as a hash parameter, and the body content
+# via a block. The headers can be generated as a string using the #header()
+# method. The output stream can be written directly to using the #print()
+# method.
+#
+# === Generating HTML
+#
+# Each HTML element has a corresponding method for generating that
+# element as a String. The name of this method is the same as that
+# of the element, all lowercase. The attributes of the element are
+# passed in as a hash, and the body as a no-argument block that evaluates
+# to a String. The HTML generation module knows which elements are
+# always empty, and silently drops any passed-in body. It also knows
+# which elements require matching closing tags and which don't. However,
+# it does not know what attributes are legal for which elements.
+#
+# There are also some additional HTML generation methods mixed in from
+# the CGI::HtmlExtension module. These include individual methods for the
+# different types of form inputs, and methods for elements that commonly
+# take particular attributes where the attributes can be directly specified
+# as arguments, rather than via a hash.
+#
+# == Examples of use
+#
+# === Get form values
+#
+# require "cgi"
+# cgi = CGI.new
+# value = cgi['field_name'] # <== value string for 'field_name'
+# # if not 'field_name' included, then return "".
+# fields = cgi.keys # <== array of field names
+#
+# # returns true if form has 'field_name'
+# cgi.has_key?('field_name')
+# cgi.has_key?('field_name')
+# cgi.include?('field_name')
+#
+# CAUTION! cgi['field_name'] returned an Array with the old
+# cgi.rb(included in ruby 1.6)
+#
+# === Get form values as hash
+#
+# require "cgi"
+# cgi = CGI.new
+# params = cgi.params
+#
+# cgi.params is a hash.
+#
+# cgi.params['new_field_name'] = ["value"] # add new param
+# cgi.params['field_name'] = ["new_value"] # change value
+# cgi.params.delete('field_name') # delete param
+# cgi.params.clear # delete all params
+#
+#
+# === Save form values to file
+#
+# require "pstore"
+# db = PStore.new("query.db")
+# db.transaction do
+# db["params"] = cgi.params
+# end
+#
+#
+# === Restore form values from file
+#
+# require "pstore"
+# db = PStore.new("query.db")
+# db.transaction do
+# cgi.params = db["params"]
+# end
+#
+#
+# === Get multipart form values
+#
+# require "cgi"
+# cgi = CGI.new
+# value = cgi['field_name'] # <== value string for 'field_name'
+# value.read # <== body of value
+# value.local_path # <== path to local file of value
+# value.original_filename # <== original filename of value
+# value.content_type # <== content_type of value
+#
+# and value has StringIO or Tempfile class methods.
+#
+# === Get cookie values
+#
+# require "cgi"
+# cgi = CGI.new
+# values = cgi.cookies['name'] # <== array of 'name'
+# # if not 'name' included, then return [].
+# names = cgi.cookies.keys # <== array of cookie names
+#
+# and cgi.cookies is a hash.
+#
+# === Get cookie objects
+#
+# require "cgi"
+# cgi = CGI.new
+# for name, cookie in cgi.cookies
+# cookie.expires = Time.now + 30
+# end
+# cgi.out("cookie" => cgi.cookies) {"string"}
+#
+# cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
+#
+# require "cgi"
+# cgi = CGI.new
+# cgi.cookies['name'].expires = Time.now + 30
+# cgi.out("cookie" => cgi.cookies['name']) {"string"}
+#
+# === Print http header and html string to $DEFAULT_OUTPUT ($>)
+#
+# require "cgi"
+# cgi = CGI.new("html3") # add HTML generation methods
+# cgi.out() do
+# cgi.html() do
+# cgi.head{ cgi.title{"TITLE"} } +
+# cgi.body() do
+# cgi.form() do
+# cgi.textarea("get_text") +
+# cgi.br +
+# cgi.submit
+# end +
+# cgi.pre() do
+# CGI::escapeHTML(
+# "params: " + cgi.params.inspect + "\n" +
+# "cookies: " + cgi.cookies.inspect + "\n" +
+# ENV.collect() do |key, value|
+# key + " --> " + value + "\n"
+# end.join("")
+# )
+# end
+# end
+# end
+# end
+#
+# # add HTML generation methods
+# CGI.new("html3") # html3.2
+# CGI.new("html4") # html4.01 (Strict)
+# CGI.new("html4Tr") # html4.01 Transitional
+# CGI.new("html4Fr") # html4.01 Frameset
+#
class CGI
+ # :stopdoc:
+
+ # String for carriage return
CR = "\015"
+
+ # String for linefeed
LF = "\012"
+
+ # Standard internet newline sequence
EOL = CR + LF
- VERSION = '2.1.3'
- RELEASE_DATE = '2001-03-18'
- VERSION_CODE = 214
- RELEASE_CODE = 20010318
- REVISION = '$Id$'
- NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM)
+ REVISION = '$Id$' #:nodoc:
+
+ NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM)
+
+ # Path separators in different environments.
PATH_SEPARATOR = {'UNIX'=>'/', 'WINDOWS'=>'\\', 'MACINTOSH'=>':'}
+ # HTTP status codes.
HTTP_STATUS = {
"OK" => "200 OK",
"PARTIAL_CONTENT" => "206 Partial Content",
@@ -215,10 +313,15 @@ class CGI
"VARIANT_ALSO_VARIES" => "506 Variant Also Negotiates"
}
+ # Abbreviated day-of-week names specified by RFC 822
RFC822_DAYS = %w[ Sun Mon Tue Wed Thu Fri Sat ]
+
+ # Abbreviated month names specified by RFC 822
RFC822_MONTHS = %w[ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ]
- def env_table
+ # :startdoc:
+
+ def env_table
ENV
end
@@ -232,14 +335,9 @@ class CGI
private :env_table, :stdinput, :stdoutput
-=begin
-== METHODS
-=end
-
-=begin
-=== ESCAPE URL ENCODE
- url_encoded_string = CGI::escape("string")
-=end
+ # URL-encode a string.
+ # url_encoded_string = CGI::escape("'Stop!' said Fred")
+ # # => "%27Stop%21%27+said+Fred"
def CGI::escape(string)
string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
'%' + $1.unpack('H2' * $1.size).join('%').upcase
@@ -247,10 +345,9 @@ class CGI
end
-=begin
-=== UNESCAPE URL ENCODED
- string = CGI::unescape("url encoded string")
-=end
+ # URL-decode a string.
+ # string = CGI::unescape("%27Stop%21%27+said+Fred")
+ # # => "'Stop!' said Fred"
def CGI::unescape(string)
string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do
[$1.delete('%')].pack('H*')
@@ -258,19 +355,17 @@ class CGI
end
-=begin
-=== ESCAPE HTML &\"<>
- CGI::escapeHTML("string")
-=end
+ # Escape special characters in HTML, namely &\"<>
+ # CGI::escapeHTML('Usage: foo "bar" <baz>')
+ # # => "Usage: foo &quot;bar&quot; &lt;baz&gt;"
def CGI::escapeHTML(string)
string.gsub(/&/n, '&amp;').gsub(/\"/n, '&quot;').gsub(/>/n, '&gt;').gsub(/</n, '&lt;')
end
-=begin
-=== UNESCAPE HTML
- CGI::unescapeHTML("HTML escaped string")
-=end
+ # Unescape a string that has been HTML-escaped
+ # CGI::unescapeHTML("Usage: foo &quot;bar&quot; &lt;baz&gt;")
+ # # => "Usage: foo \"bar\" <baz>"
def CGI::unescapeHTML(string)
string.gsub(/&(.*?);/n) do
match = $1.dup
@@ -306,14 +401,19 @@ class CGI
end
-=begin
-=== ESCAPE ELEMENT
- print CGI::escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
- # "<BR>&lt;A HREF="url"&gt;&lt;/A&gt"
-
- print CGI::escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
- # "<BR>&lt;A HREF="url"&gt;&lt;/A&gt"
-=end
+ # Escape only the tags of certain HTML elements in +string+.
+ #
+ # Takes an element or elements or array of elements. Each element
+ # is specified by the name of the element, without angle brackets.
+ # This matches both the start and the end tag of that element.
+ # The attribute list of the open tag will also be escaped (for
+ # instance, the double-quotes surrounding attribute values).
+ #
+ # print CGI::escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
+ #
+ # print CGI::escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
+ # # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
def CGI::escapeElement(string, *elements)
elements = elements[0] if elements[0].kind_of?(Array)
unless elements.empty?
@@ -326,16 +426,15 @@ class CGI
end
-=begin
-=== UNESCAPE ELEMENT
- print CGI::unescapeElement(
- CGI::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
- # "&lt;BR&gt;<A HREF="url"></A>"
-
- print CGI::unescapeElement(
- CGI::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
- # "&lt;BR&gt;<A HREF="url"></A>"
-=end
+ # Undo escaping such as that done by CGI::escapeElement()
+ #
+ # print CGI::unescapeElement(
+ # CGI::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
+ # # "&lt;BR&gt;<A HREF="url"></A>"
+ #
+ # print CGI::unescapeElement(
+ # CGI::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
+ # # "&lt;BR&gt;<A HREF="url"></A>"
def CGI::unescapeElement(string, *elements)
elements = elements[0] if elements[0].kind_of?(Array)
unless elements.empty?
@@ -348,11 +447,10 @@ class CGI
end
-=begin
-=== MAKE RFC1123 DATE STRING
- CGI::rfc1123_date(Time.now)
- # Sat, 01 Jan 2000 00:00:00 GMT
-=end
+ # Format a +Time+ object as a String using the format specified by RFC 1123.
+ #
+ # CGI::rfc1123_date(Time.now)
+ # # Sat, 01 Jan 2000 00:00:00 GMT
def CGI::rfc1123_date(time)
t = time.clone.gmtime
return format("%s, %.2d %s %.4d %.2d:%.2d:%.2d GMT",
@@ -361,58 +459,92 @@ class CGI
end
-=begin
-=== MAKE HTTP HEADER STRING
- header
- # Content-Type: text/html
-
- header("text/plain")
- # Content-Type: text/plain
-
- header({"nph" => true,
- "status" => "OK", # == "200 OK"
- # "status" => "200 GOOD",
- "server" => ENV['SERVER_SOFTWARE'],
- "connection" => "close",
- "type" => "text/html",
- "charset" => "iso-2022-jp",
- # Content-Type: text/html; charset=iso-2022-jp
- "language" => "ja",
- "expires" => Time.now + 30,
- "cookie" => [cookie1, cookie2],
- "my_header1" => "my_value"
- "my_header2" => "my_value"})
-
-header will not convert charset.
-
-status:
-
- "OK" --> "200 OK"
- "PARTIAL_CONTENT" --> "206 Partial Content"
- "MULTIPLE_CHOICES" --> "300 Multiple Choices"
- "MOVED" --> "301 Moved Permanently"
- "REDIRECT" --> "302 Found"
- "NOT_MODIFIED" --> "304 Not Modified"
- "BAD_REQUEST" --> "400 Bad Request"
- "AUTH_REQUIRED" --> "401 Authorization Required"
- "FORBIDDEN" --> "403 Forbidden"
- "NOT_FOUND" --> "404 Not Found"
- "METHOD_NOT_ALLOWED" --> "405 Method Not Allowed"
- "NOT_ACCEPTABLE" --> "406 Not Acceptable"
- "LENGTH_REQUIRED" --> "411 Length Required"
- "PRECONDITION_FAILED" --> "412 Rrecondition Failed"
- "SERVER_ERROR" --> "500 Internal Server Error"
- "NOT_IMPLEMENTED" --> "501 Method Not Implemented"
- "BAD_GATEWAY" --> "502 Bad Gateway"
- "VARIANT_ALSO_VARIES" --> "506 Variant Also Negotiates"
-
-=end
+ # Create an HTTP header block as a string.
+ #
+ # Includes the empty line that ends the header block.
+ #
+ # +options+ can be a string specifying the Content-Type (defaults
+ # to text/html), or a hash of header key/value pairs. The following
+ # header keys are recognized:
+ #
+ # type:: the Content-Type header. Defaults to "text/html"
+ # charset:: the charset of the body, appended to the Content-Type header.
+ # nph:: a boolean value. If true, prepend protocol string and status code, and
+ # date; and sets default values for "server" and "connection" if not
+ # explicitly set.
+ # status:: the HTTP status code, returned as the Status header. See the
+ # list of available status codes below.
+ # server:: the server software, returned as the Server header.
+ # connection:: the connection type, returned as the Connection header (for
+ # instance, "close".
+ # length:: the length of the content that will be sent, returned as the
+ # Content-Length header.
+ # language:: the language of the content, returned as the Content-Language
+ # header.
+ # expires:: the time on which the current content expires, as a +Time+
+ # object, returned as the Expires header.
+ # cookie:: a cookie or cookies, returned as one or more Set-Cookie headers.
+ # The value can be the literal string of the cookie; a CGI::Cookie
+ # object; an Array of literal cookie strings or Cookie objects; or a
+ # hash all of whose values are literal cookie strings or Cookie objects.
+ # These cookies are in addition to the cookies held in the
+ # @output_cookies field.
+ #
+ # Other header lines can also be set; they are appended as key: value.
+ #
+ # header
+ # # Content-Type: text/html
+ #
+ # header("text/plain")
+ # # Content-Type: text/plain
+ #
+ # header("nph" => true,
+ # "status" => "OK", # == "200 OK"
+ # # "status" => "200 GOOD",
+ # "server" => ENV['SERVER_SOFTWARE'],
+ # "connection" => "close",
+ # "type" => "text/html",
+ # "charset" => "iso-2022-jp",
+ # # Content-Type: text/html; charset=iso-2022-jp
+ # "length" => 103,
+ # "language" => "ja",
+ # "expires" => Time.now + 30,
+ # "cookie" => [cookie1, cookie2],
+ # "my_header1" => "my_value"
+ # "my_header2" => "my_value")
+ #
+ # The status codes are:
+ #
+ # "OK" --> "200 OK"
+ # "PARTIAL_CONTENT" --> "206 Partial Content"
+ # "MULTIPLE_CHOICES" --> "300 Multiple Choices"
+ # "MOVED" --> "301 Moved Permanently"
+ # "REDIRECT" --> "302 Found"
+ # "NOT_MODIFIED" --> "304 Not Modified"
+ # "BAD_REQUEST" --> "400 Bad Request"
+ # "AUTH_REQUIRED" --> "401 Authorization Required"
+ # "FORBIDDEN" --> "403 Forbidden"
+ # "NOT_FOUND" --> "404 Not Found"
+ # "METHOD_NOT_ALLOWED" --> "405 Method Not Allowed"
+ # "NOT_ACCEPTABLE" --> "406 Not Acceptable"
+ # "LENGTH_REQUIRED" --> "411 Length Required"
+ # "PRECONDITION_FAILED" --> "412 Precondition Failed"
+ # "SERVER_ERROR" --> "500 Internal Server Error"
+ # "NOT_IMPLEMENTED" --> "501 Method Not Implemented"
+ # "BAD_GATEWAY" --> "502 Bad Gateway"
+ # "VARIANT_ALSO_VARIES" --> "506 Variant Also Negotiates"
+ #
+ # This method does not perform charset conversion.
+ #
def header(options = "text/html")
buf = ""
- if options.kind_of?(String)
+ case options
+ when String
options = { "type" => options }
+ when Hash
+ options = options.dup
end
unless options.has_key?("type")
@@ -420,21 +552,15 @@ status:
end
if options.has_key?("charset")
- options["type"].concat( "; charset=" )
- options["type"].concat( options.delete("charset") )
+ options["type"] += "; charset=" + options.delete("charset")
end
options.delete("nph") if defined?(MOD_RUBY)
if options.delete("nph") or /IIS/n.match(env_table['SERVER_SOFTWARE'])
- buf.concat( (env_table["SERVER_PROTOCOL"] or "HTTP/1.0") + " " )
- buf.concat( (HTTP_STATUS[options["status"]] or
- options["status"] or
- "200 OK"
- ) + EOL
- )
- buf.concat(
- "Date: " + CGI::rfc1123_date(Time.now) + EOL
- )
+ buf += (env_table["SERVER_PROTOCOL"] or "HTTP/1.0") + " " +
+ (HTTP_STATUS[options["status"]] or options["status"] or "200 OK") +
+ EOL +
+ "Date: " + CGI::rfc1123_date(Time.now) + EOL
unless options.has_key?("server")
options["server"] = (env_table['SERVER_SOFTWARE'] or "")
@@ -448,70 +574,76 @@ status:
end
if options.has_key?("status")
- status = (HTTP_STATUS[options["status"]] or options["status"])
- buf.concat("Status: " + status + EOL)
+ buf += "Status: " +
+ (HTTP_STATUS[options["status"]] or options["status"]) + EOL
options.delete("status")
end
if options.has_key?("server")
- buf.concat("Server: " + options.delete("server") + EOL)
+ buf += "Server: " + options.delete("server") + EOL
end
if options.has_key?("connection")
- buf.concat("Connection: " + options.delete("connection") + EOL)
+ buf += "Connection: " + options.delete("connection") + EOL
end
- buf.concat("Content-Type: " + options.delete("type") + EOL)
+ buf += "Content-Type: " + options.delete("type") + EOL
if options.has_key?("length")
- buf.concat("Content-Length: " + options.delete("length").to_s + EOL)
+ buf += "Content-Length: " + options.delete("length").to_s + EOL
end
if options.has_key?("language")
- buf.concat("Content-Language: " + options.delete("language") + EOL)
+ buf += "Content-Language: " + options.delete("language") + EOL
end
if options.has_key?("expires")
- buf.concat("Expires: " + CGI::rfc1123_date( options.delete("expires") ) + EOL)
+ buf += "Expires: " + CGI::rfc1123_date( options.delete("expires") ) + EOL
end
if options.has_key?("cookie")
if options["cookie"].kind_of?(String) or
options["cookie"].kind_of?(Cookie)
- buf.concat("Set-Cookie: " + options.delete("cookie").to_s + EOL)
+ buf += "Set-Cookie: " + options.delete("cookie").to_s + EOL
elsif options["cookie"].kind_of?(Array)
options.delete("cookie").each{|cookie|
- buf.concat("Set-Cookie: " + cookie.to_s + EOL)
+ buf += "Set-Cookie: " + cookie.to_s + EOL
}
elsif options["cookie"].kind_of?(Hash)
options.delete("cookie").each_value{|cookie|
- buf.concat("Set-Cookie: " + cookie.to_s + EOL)
+ buf += "Set-Cookie: " + cookie.to_s + EOL
}
end
end
if @output_cookies
for cookie in @output_cookies
- buf.concat("Set-Cookie: " + cookie.to_s + EOL)
+ buf += "Set-Cookie: " + cookie.to_s + EOL
end
end
options.each{|key, value|
- buf.concat(key + ": " + value + EOL)
+ buf += key + ": " + value.to_s + EOL
}
if defined?(MOD_RUBY)
table = Apache::request.headers_out
buf.scan(/([^:]+): (.+)#{EOL}/n){ |name, value|
- $stderr.printf("name:%s value:%s\n", name, value) if $DEBUG
+ warn sprintf("name:%s value:%s\n", name, value) if $DEBUG
case name
when 'Set-Cookie'
- table.add($1, $2)
+ table.add(name, value)
when /^status$/ni
Apache::request.status_line = value
+ Apache::request.status = value.to_i
when /^content-type$/ni
Apache::request.content_type = value
when /^content-encoding$/ni
Apache::request.content_encoding = value
+ when /^location$/ni
+ if Apache::request.status == 200
+ Apache::request.status = 302
+ end
+ Apache::request.headers_out[name] = value
else
Apache::request.headers_out[name] = value
end
@@ -525,41 +657,49 @@ status:
end # header()
-=begin
-=== PRINT HTTP HEADER AND STRING TO $DEFAULT_OUTPUT ($>)
- cgi = CGI.new
- cgi.out{ "string" }
- # Content-Type: text/html
- # Content-Length: 6
- #
- # string
-
- cgi.out("text/plain"){ "string" }
- # Content-Type: text/plain
- # Content-Length: 6
- #
- # string
-
- cgi.out({"nph" => true,
- "status" => "OK", # == "200 OK"
- "server" => ENV['SERVER_SOFTWARE'],
- "connection" => "close",
- "type" => "text/html",
- "charset" => "iso-2022-jp",
- # Content-Type: text/html; charset=iso-2022-jp
- "language" => "ja",
- "expires" => Time.now + (3600 * 24 * 30),
- "cookie" => [cookie1, cookie2],
- "my_header1" => "my_value",
- "my_header2" => "my_value"}){ "string" }
-
-if "HEAD" == REQUEST_METHOD then output only HTTP header.
-
-if charset is "iso-2022-jp" or "euc-jp" or "shift_jis" then
-convert string charset, and set language to "ja".
-
-=end
- def out(options = "text/html")
+ # Print an HTTP header and body to $DEFAULT_OUTPUT ($>)
+ #
+ # The header is provided by +options+, as for #header().
+ # The body of the document is that returned by the passed-
+ # in block. This block takes no arguments. It is required.
+ #
+ # cgi = CGI.new
+ # cgi.out{ "string" }
+ # # Content-Type: text/html
+ # # Content-Length: 6
+ # #
+ # # string
+ #
+ # cgi.out("text/plain") { "string" }
+ # # Content-Type: text/plain
+ # # Content-Length: 6
+ # #
+ # # string
+ #
+ # cgi.out("nph" => true,
+ # "status" => "OK", # == "200 OK"
+ # "server" => ENV['SERVER_SOFTWARE'],
+ # "connection" => "close",
+ # "type" => "text/html",
+ # "charset" => "iso-2022-jp",
+ # # Content-Type: text/html; charset=iso-2022-jp
+ # "language" => "ja",
+ # "expires" => Time.now + (3600 * 24 * 30),
+ # "cookie" => [cookie1, cookie2],
+ # "my_header1" => "my_value",
+ # "my_header2" => "my_value") { "string" }
+ #
+ # Content-Length is automatically calculated from the size of
+ # the String returned by the content block.
+ #
+ # If ENV['REQUEST_METHOD'] == "HEAD", then only the header
+ # is outputted (the content block is still required, but it
+ # is ignored).
+ #
+ # If the charset is "iso-2022-jp" or "euc-jp" or "shift_jis" then
+ # the content is converted to this charset, and the language is set
+ # to "ja".
+ def out(options = "text/html") # :yield:
options = { "type" => options } if options.kind_of?(String)
content = yield
@@ -587,47 +727,69 @@ convert string charset, and set language to "ja".
end
-=begin
-=== PRINT
- cgi = CGI.new
- cgi.print # default: cgi.print == $DEFAULT_OUTPUT.print
-=end
+ # Print an argument or list of arguments to the default output stream
+ #
+ # cgi = CGI.new
+ # cgi.print # default: cgi.print == $DEFAULT_OUTPUT.print
def print(*options)
stdoutput.print(*options)
end
-
-=begin
-=== MAKE COOKIE OBJECT
- cookie1 = CGI::Cookie::new("name", "value1", "value2", ...)
- cookie1 = CGI::Cookie::new({"name" => "name", "value" => "value"})
- cookie1 = CGI::Cookie::new({'name' => 'name',
- 'value' => ['value1', 'value2', ...],
- 'path' => 'path', # optional
- 'domain' => 'domain', # optional
- 'expires' => Time.now, # optional
- 'secure' => true # optional
- })
-
- cgi.out({"cookie" => [cookie1, cookie2]}){ "string" }
-
- name = cookie1.name
- values = cookie1.value
- path = cookie1.path
- domain = cookie1.domain
- expires = cookie1.expires
- secure = cookie1.secure
-
- cookie1.name = 'name'
- cookie1.value = ['value1', 'value2', ...]
- cookie1.path = 'path'
- cookie1.domain = 'domain'
- cookie1.expires = Time.now + 30
- cookie1.secure = true
-=end
require "delegate"
+
+ # Class representing an HTTP cookie.
+ #
+ # In addition to its specific fields and methods, a Cookie instance
+ # is a delegator to the array of its values.
+ #
+ # See RFC 2965.
+ #
+ # == Examples of use
+ # cookie1 = CGI::Cookie::new("name", "value1", "value2", ...)
+ # cookie1 = CGI::Cookie::new("name" => "name", "value" => "value")
+ # cookie1 = CGI::Cookie::new('name' => 'name',
+ # 'value' => ['value1', 'value2', ...],
+ # 'path' => 'path', # optional
+ # 'domain' => 'domain', # optional
+ # 'expires' => Time.now, # optional
+ # 'secure' => true # optional
+ # )
+ #
+ # cgi.out("cookie" => [cookie1, cookie2]) { "string" }
+ #
+ # name = cookie1.name
+ # values = cookie1.value
+ # path = cookie1.path
+ # domain = cookie1.domain
+ # expires = cookie1.expires
+ # secure = cookie1.secure
+ #
+ # cookie1.name = 'name'
+ # cookie1.value = ['value1', 'value2', ...]
+ # cookie1.path = 'path'
+ # cookie1.domain = 'domain'
+ # cookie1.expires = Time.now + 30
+ # cookie1.secure = true
class Cookie < SimpleDelegator
+ # Create a new CGI::Cookie object.
+ #
+ # The contents of the cookie can be specified as a +name+ and one
+ # or more +value+ arguments. Alternatively, the contents can
+ # be specified as a single hash argument. The possible keywords of
+ # this hash are as follows:
+ #
+ # name:: the name of the cookie. Required.
+ # value:: the cookie's value or list of values.
+ # path:: the path for which this cookie applies. Defaults to the
+ # base directory of the CGI script.
+ # domain:: the domain for which this cookie applies.
+ # expires:: the time at which this cookie expires, as a +Time+ object.
+ # secure:: whether this cookie is a secure cookie or not (default to
+ # false). Secure cookies are only transmitted to HTTPS
+ # servers.
+ #
+ # These keywords correspond to attributes of the cookie object.
def initialize(name = "", *value)
options = if name.kind_of?(String)
{ "name" => name, "value" => value }
@@ -643,13 +805,9 @@ convert string charset, and set language to "ja".
# simple support for IE
if options["path"]
@path = options["path"]
- elsif ENV["REQUEST_URI"]
- @path = ENV["REQUEST_URI"].sub(/\?.*/n,'')
- if ENV["PATH_INFO"]
- @path = @path[0...@path.rindex(ENV["PATH_INFO"])]
- end
else
- @path = (ENV["SCRIPT_NAME"] or "")
+ %r|^(.*/)|.match(ENV["SCRIPT_NAME"])
+ @path = ($1 or "")
end
@domain = options["domain"]
@expires = options["expires"]
@@ -660,35 +818,40 @@ convert string charset, and set language to "ja".
attr_accessor("name", "value", "path", "domain", "expires")
attr_reader("secure")
+
+ # Set whether the Cookie is a secure cookie or not.
+ #
+ # +val+ must be a boolean.
def secure=(val)
@secure = val if val == true or val == false
@secure
end
+ # Convert the Cookie to its string representation.
def to_s
buf = ""
- buf.concat(@name + '=')
+ buf += @name + '='
if @value.kind_of?(String)
- buf.concat CGI::escape(@value)
+ buf += CGI::escape(@value)
else
- buf.concat(@value.collect{|v| CGI::escape(v) }.join("&"))
+ buf += @value.collect{|v| CGI::escape(v) }.join("&")
end
if @domain
- buf.concat('; domain=' + @domain)
+ buf += '; domain=' + @domain
end
if @path
- buf.concat('; path=' + @path)
+ buf += '; path=' + @path
end
if @expires
- buf.concat('; expires=' + CGI::rfc1123_date(@expires))
+ buf += '; expires=' + CGI::rfc1123_date(@expires)
end
if @secure == true
- buf.concat('; secure')
+ buf += '; secure'
end
buf
@@ -697,23 +860,23 @@ convert string charset, and set language to "ja".
end # class Cookie
-=begin
-=== PARSE RAW COOKIE STRING
- cookies = CGI::Cookie::parse("raw_cookie_string")
- # { "name1" => cookie1, "name2" => cookie2, ... }
-=end
+ # Parse a raw cookie string into a hash of cookie-name=>Cookie
+ # pairs.
+ #
+ # cookies = CGI::Cookie::parse("raw_cookie_string")
+ # # { "name1" => cookie1, "name2" => cookie2, ... }
+ #
def Cookie::parse(raw_cookie)
cookies = Hash.new([])
return cookies unless raw_cookie
- raw_cookie.split('; ').each do |pairs|
+ raw_cookie.split(/; /).each do |pairs|
name, values = pairs.split('=',2)
+ next unless name and values
name = CGI::unescape(name)
values ||= ""
values = values.split('&').collect{|v| CGI::unescape(v) }
- if cookies.has_key?(name)
- cookies[name].value.push(*values)
- else
+ unless cookies.has_key?(name)
cookies[name] = Cookie::new({ "name" => name, "value" => values })
end
end
@@ -721,15 +884,14 @@ convert string charset, and set language to "ja".
cookies
end
-
-=begin
-=== PARSE QUERY STRING
- params = CGI::parse("query_string")
- # {"name1" => ["value1", "value2", ...],
- # "name2" => ["value1", "value2", ...], ... }
-=end
+ # Parse an HTTP query string into a hash of key=>value pairs.
+ #
+ # params = CGI::parse("query_string")
+ # # {"name1" => ["value1", "value2", ...],
+ # # "name2" => ["value1", "value2", ...], ... }
+ #
def CGI::parse(query)
- params = Hash.new([])
+ params = Hash.new([].freeze)
query.split(/[&;]/n).each do |pairs|
key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
@@ -743,51 +905,64 @@ convert string charset, and set language to "ja".
params
end
-
+ # Mixin module. It provides the follow functionality groups:
+ #
+ # 1. Access to CGI environment variables as methods. See
+ # documentation to the CGI class for a list of these variables.
+ #
+ # 2. Access to cookies, including the cookies attribute.
+ #
+ # 3. Access to parameters, including the params attribute, and overloading
+ # [] to perform parameter value lookup by key.
+ #
+ # 4. The initialize_query method, for initialising the above
+ # mechanisms, handling multipart forms, and allowing the
+ # class to be used in "offline" mode.
+ #
module QueryExtension
- for env in %w[ CONTENT_LENGTH SERVER_PORT ]
- eval( <<-END )
- def #{env.sub(/^HTTP_/n, '').downcase}
- env_table["#{env}"] && Integer(env_table["#{env}"])
- end
- END
+ %w[ CONTENT_LENGTH SERVER_PORT ].each do |env|
+ define_method(env.sub(/^HTTP_/n, '').downcase) do
+ (val = env_table[env]) && Integer(val)
+ end
end
- for env in %w[ AUTH_TYPE CONTENT_TYPE GATEWAY_INTERFACE PATH_INFO
+ %w[ AUTH_TYPE CONTENT_TYPE GATEWAY_INTERFACE PATH_INFO
PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST
REMOTE_IDENT REMOTE_USER REQUEST_METHOD SCRIPT_NAME
SERVER_NAME SERVER_PROTOCOL SERVER_SOFTWARE
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM HTTP_HOST
- HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ]
- eval( <<-END )
- def #{env.sub(/^HTTP_/n, '').downcase}
- env_table["#{env}"]
- end
- END
+ HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ].each do |env|
+ define_method(env.sub(/^HTTP_/n, '').downcase) do
+ env_table[env]
+ end
end
+ # Get the raw cookies as a string.
def raw_cookie
env_table["HTTP_COOKIE"]
end
+ # Get the raw RFC2965 cookies as a string.
def raw_cookie2
env_table["HTTP_COOKIE2"]
end
+ # Get the cookies as a hash of cookie-name=>Cookie pairs.
attr_accessor("cookies")
+
+ # Get the parameters as a hash of name=>values pairs, where
+ # values is an Array.
attr("params")
+
+ # Set all the parameters.
def params=(hash)
@params.clear
@params.update(hash)
end
- def param(name)
- @params[name].join("\0")
- end
-
def read_multipart(boundary, content_length)
params = Hash.new([])
boundary = "--" + boundary
@@ -795,20 +970,31 @@ convert string charset, and set language to "ja".
bufsize = 10 * 1024
# start multipart/form-data
- stdinput.binmode
+ stdinput.binmode if defined? stdinput.binmode
boundary_size = boundary.size + EOL.size
content_length -= boundary_size
status = stdinput.read(boundary_size)
if nil == status
raise EOFError, "no content body"
+ elsif boundary + EOL != status
+ raise EOFError, "bad content body"
end
- require "tempfile"
-
- until -1 == content_length
+ loop do
head = nil
- body = Tempfile.new("CGI")
- body.binmode
+ if 10240 < content_length
+ require "tempfile"
+ body = Tempfile.new("CGI")
+ else
+ begin
+ require "stringio"
+ body = StringIO.new
+ rescue LoadError
+ require "tempfile"
+ body = Tempfile.new("CGI")
+ end
+ end
+ body.binmode if defined? body.binmode
until head and /#{boundary}(?:#{EOL}|--)/n.match(buf)
@@ -826,16 +1012,18 @@ convert string charset, and set language to "ja".
end
c = if bufsize < content_length
- stdinput.read(bufsize) or ''
+ stdinput.read(bufsize)
else
- stdinput.read(content_length) or ''
+ stdinput.read(content_length)
end
- buf.concat c
+ if c.nil?
+ raise EOFError, "bad content body"
+ end
+ buf.concat(c)
content_length -= c.size
-
end
- buf = buf.sub(/\A((?:.|\n)*?)(?:#{EOL})?#{boundary}(#{EOL}|--)/n) do
+ buf = buf.sub(/\A((?:.|\n)*?)(?:[\r\n]{1,2})?#{boundary}([\r\n]{1,2}|--)/n) do
body.print $1
if "--" == $2
content_length = -1
@@ -845,34 +1033,22 @@ convert string charset, and set language to "ja".
body.rewind
- eval <<-END
- def body.local_path
- #{body.path.dump}
- end
- END
-
/Content-Disposition:.* filename="?([^\";]*)"?/ni.match(head)
- eval <<-END
- def body.original_filename
- #{
- filename = ($1 or "").dup
- if /Mac/ni.match(env_table['HTTP_USER_AGENT']) and
- /Mozilla/ni.match(env_table['HTTP_USER_AGENT']) and
- (not /MSIE/ni.match(env_table['HTTP_USER_AGENT']))
- CGI::unescape(filename)
- else
- filename
- end.dump.untaint
- }.taint
- end
- END
-
+ filename = ($1 or "")
+ if /Mac/ni.match(env_table['HTTP_USER_AGENT']) and
+ /Mozilla/ni.match(env_table['HTTP_USER_AGENT']) and
+ (not /MSIE/ni.match(env_table['HTTP_USER_AGENT']))
+ filename = CGI::unescape(filename)
+ end
+
/Content-Type: (.*)/ni.match(head)
- eval <<-END
- def body.content_type
- #{($1 or "").dump.untaint}.taint
- end
- END
+ content_type = ($1 or "")
+
+ (class << body; self; end).class_eval do
+ alias local_path path
+ define_method(:original_filename) {filename.dup.taint}
+ define_method(:content_type) {content_type.dup.taint}
+ end
/Content-Disposition:.* name="?([^\";]*)"?/ni.match(head)
name = $1.dup
@@ -882,7 +1058,8 @@ convert string charset, and set language to "ja".
else
params[name] = [body]
end
-
+ break if buf.size == 0
+ break if content_length === -1
end
params
@@ -914,12 +1091,18 @@ convert string charset, and set language to "ja".
end
private :read_from_cmdline
+ # Initialize the data from the query.
+ #
+ # Handles multipart forms (in particular, forms that involve file uploads).
+ # Reads query parameters in the @params field, and cookies into @cookies.
def initialize_query()
if ("POST" == env_table['REQUEST_METHOD']) and
%r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n.match(env_table['CONTENT_TYPE'])
boundary = $1.dup
+ @multipart = true
@params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
else
+ @multipart = false
@params = CGI::parse(
case env_table['REQUEST_METHOD']
when "GET", "HEAD"
@@ -929,7 +1112,7 @@ convert string charset, and set language to "ja".
env_table['QUERY_STRING'] or ""
end
when "POST"
- stdinput.binmode
+ stdinput.binmode if defined? stdinput.binmode
stdinput.read(Integer(env_table['CONTENT_LENGTH'])) or ''
else
read_from_cmdline
@@ -938,18 +1121,65 @@ convert string charset, and set language to "ja".
end
@cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] or env_table['COOKIE']))
-
end
private :initialize_query
- def [](*args)
- @params[*args]
+ def multipart?
+ @multipart
+ end
+
+ module Value # :nodoc:
+ def set_params(params)
+ @params = params
+ end
+ def [](idx, *args)
+ if args.size == 0
+ warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
+ @params[idx]
+ else
+ super[idx,*args]
+ end
+ end
+ def first
+ warn "#{caller(1)[0]}:CAUTION! cgi['key'] == cgi.params['key'][0]; if want Array, use cgi.params['key']"
+ self
+ end
+ alias last first
+ def to_a
+ @params || [self]
+ end
+ alias to_ary to_a # to be rhs of multiple assignment
+ end
+
+ # Get the value for the parameter with a given key.
+ #
+ # If the parameter has multiple values, only the first will be
+ # retrieved; use #params() to get the array of values.
+ def [](key)
+ params = @params[key]
+ value = params[0]
+ if @multipart
+ if value
+ return value
+ elsif defined? StringIO
+ StringIO.new("")
+ else
+ Tempfile.new("CGI")
+ end
+ else
+ str = if value then value.dup else "" end
+ str.extend(Value)
+ str.set_params(params)
+ str
+ end
end
+ # Return all parameter keys as an array.
def keys(*args)
@params.keys(*args)
end
+ # Returns true if a given parameter key exists in the query.
def has_key?(*args)
@params.has_key?(*args)
end
@@ -959,20 +1189,23 @@ convert string charset, and set language to "ja".
end # QueryExtension
-=begin
-=== HTML PRETTY FORMAT
- print CGI::pretty("<HTML><BODY></BODY></HTML>")
- # <HTML>
- # <BODY>
- # </BODY>
- # </HTML>
-
- print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t")
- # <HTML>
- # <BODY>
- # </BODY>
- # </HTML>
-=end
+ # Prettify (indent) an HTML string.
+ #
+ # +string+ is the HTML string to indent. +shift+ is the indentation
+ # unit to use; it defaults to two spaces.
+ #
+ # print CGI::pretty("<HTML><BODY></BODY></HTML>")
+ # # <HTML>
+ # # <BODY>
+ # # </BODY>
+ # # </HTML>
+ #
+ # print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t")
+ # # <HTML>
+ # # <BODY>
+ # # </BODY>
+ # # </HTML>
+ #
def CGI::pretty(string, shift = " ")
lines = string.gsub(/(?!\A)<(?:.|\n)*?>/n, "\n\\0").gsub(/<(?:.|\n)*?>(?!\n)/n, "\\0\n")
end_pos = 0
@@ -985,51 +1218,32 @@ convert string charset, and set language to "ja".
end
-=begin
-== HTML ELEMENTS
-
- cgi = CGI.new("html3") # add HTML generation methods
- cgi.element
- cgi.element{ "string" }
- cgi.element({ "ATTRIBUTE1" => "value1", "ATTRIBUTE2" => "value2" })
- cgi.element({ "ATTRIBUTE1" => "value1", "ATTRIBUTE2" => "value2" }){ "string" }
-
- # add HTML generation methods
- CGI.new("html3") # html3.2
- CGI.new("html4") # html4.0 (Strict)
- CGI.new("html4Tr") # html4.0 Transitional
- CGI.new("html4Fr") # html4.0 Frameset
+ # Base module for HTML-generation mixins.
+ #
+ # Provides methods for code generation for tags following
+ # the various DTD element types.
+ module TagMaker # :nodoc:
-=end
-
-
- module TagMaker
-
- # - -
+ # Generate code for an element with required start and end tags.
+ #
+ # - -
def nn_element_def(element)
- <<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
- "<element.upcase" + attributes.collect{|name, value|
- next unless value
- " " + CGI::escapeHTML(name) +
- if true == value
- ""
- else
- '="' + CGI::escapeHTML(value) + '"'
- end
- }.to_s + ">" +
+ nOE_element_def(element, <<-END)
if block_given?
yield.to_s
else
""
end +
- "</element.upcase>"
+ "</#{element.upcase}>"
END
end
- # - O EMPTY
- def nOE_element_def(element)
- <<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
- "<element.upcase" + attributes.collect{|name, value|
+ # Generate code for an empty element.
+ #
+ # - O EMPTY
+ def nOE_element_def(element, append = nil)
+ s = <<-END
+ "<#{element.upcase}" + attributes.collect{|name, value|
next unless value
" " + CGI::escapeHTML(name) +
if true == value
@@ -1039,22 +1253,18 @@ convert string charset, and set language to "ja".
end
}.to_s + ">"
END
+ s.sub!(/\Z/, " +") << append if append
+ s
end
- # O O or - O
+ # Generate code for an element for which the end (and possibly the
+ # start) tag is optional.
+ #
+ # O O or - O
def nO_element_def(element)
- <<-END.gsub(/element\.downcase/n, element.downcase).gsub(/element\.upcase/n, element.upcase)
- "<element.upcase" + attributes.collect{|name, value|
- next unless value
- " " + CGI::escapeHTML(name) +
- if true == value
- ""
- else
- '="' + CGI::escapeHTML(value) + '"'
- end
- }.to_s + ">" +
+ nOE_element_def(element, <<-END)
if block_given?
- yield.to_s + "</element.upcase>"
+ yield.to_s + "</#{element.upcase}>"
else
""
end
@@ -1064,15 +1274,37 @@ convert string charset, and set language to "ja".
end # TagMaker
+ #
+ # Mixin module providing HTML generation methods.
+ #
+ # For example,
+ # cgi.a("http://www.example.com") { "Example" }
+ # # => "<A HREF=\"http://www.example.com\">Example</A>"
+ #
+ # Modules Http3, Http4, etc., contain more basic HTML-generation methods
+ # (:title, :center, etc.).
+ #
+ # See class CGI for a detailed example.
+ #
module HtmlExtension
-=begin
-=== A ELEMENT
- a("url")
- # = a({ "HREF" => "url" })
-=end
- def a(href = "")
+ # Generate an Anchor element as a string.
+ #
+ # +href+ can either be a string, giving the URL
+ # for the HREF attribute, or it can be a hash of
+ # the element's attributes.
+ #
+ # The body of the element is the string returned by the no-argument
+ # block passed in.
+ #
+ # a("http://www.example.com") { "Example" }
+ # # => "<A HREF=\"http://www.example.com\">Example</A>"
+ #
+ # a("HREF" => "http://www.example.com", "TARGET" => "_top") { "Example" }
+ # # => "<A HREF=\"http://www.example.com\" TARGET=\"_top\">Example</A>"
+ #
+ def a(href = "") # :yield:
attributes = if href.kind_of?(String)
{ "HREF" => href }
else
@@ -1085,13 +1317,16 @@ convert string charset, and set language to "ja".
end
end
-
-=begin
-=== BASE ELEMENT
- base("url")
- # = base({ "HREF" => "url" })
-=end
- def base(href = "")
+ # Generate a Document Base URI element as a String.
+ #
+ # +href+ can either by a string, giving the base URL for the HREF
+ # attribute, or it can be a has of the element's attributes.
+ #
+ # The passed-in no-argument block is ignored.
+ #
+ # base("http://www.example.com/cgi")
+ # # => "<BASE HREF=\"http://www.example.com/cgi\">"
+ def base(href = "") # :yield:
attributes = if href.kind_of?(String)
{ "HREF" => href }
else
@@ -1104,13 +1339,17 @@ convert string charset, and set language to "ja".
end
end
-
-=begin
-=== BLOCKQUOTE ELEMENT
- blockquote("url"){ "string" }
- # = blockquote({ "CITE" => "url" }){ "string" }
-=end
- def blockquote(cite = nil)
+ # Generate a BlockQuote element as a string.
+ #
+ # +cite+ can either be a string, give the URI for the source of
+ # the quoted text, or a hash, giving all attributes of the element,
+ # or it can be omitted, in which case the element has no attributes.
+ #
+ # The body is provided by the passed-in no-argument block
+ #
+ # blockquote("http://www.example.com/quotes/foo.html") { "Foo!" }
+ # #=> "<BLOCKQUOTE CITE=\"http://www.example.com/quotes/foo.html\">Foo!</BLOCKQUOTE>
+ def blockquote(cite = nil) # :yield:
attributes = if cite.kind_of?(String)
{ "CITE" => cite }
else
@@ -1124,12 +1363,17 @@ convert string charset, and set language to "ja".
end
-=begin
-=== CAPTION ELEMENT
- caption("align"){ "string" }
- # = caption({ "ALIGN" => "align" }){ "string" }
-=end
- def caption(align = nil)
+ # Generate a Table Caption element as a string.
+ #
+ # +align+ can be a string, giving the alignment of the caption
+ # (one of top, bottom, left, or right). It can be a hash of
+ # all the attributes of the element. Or it can be omitted.
+ #
+ # The body of the element is provided by the passed-in no-argument block.
+ #
+ # caption("left") { "Capital Cities" }
+ # # => <CAPTION ALIGN=\"left\">Capital Cities</CAPTION>
+ def caption(align = nil) # :yield:
attributes = if align.kind_of?(String)
{ "ALIGN" => align }
else
@@ -1143,17 +1387,22 @@ convert string charset, and set language to "ja".
end
-=begin
-=== CHECKBOX
- checkbox("name")
- # = checkbox({ "NAME" => "name" })
-
- checkbox("name", "value")
- # = checkbox({ "NAME" => "name", "VALUE" => "value" })
-
- checkbox("name", "value", true)
- # = checkbox({ "NAME" => "name", "VALUE" => "value", "CHECKED" => true })
-=end
+ # Generate a Checkbox Input element as a string.
+ #
+ # The attributes of the element can be specified as three arguments,
+ # +name+, +value+, and +checked+. +checked+ is a boolean value;
+ # if true, the CHECKED attribute will be included in the element.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # checkbox("name")
+ # # = checkbox("NAME" => "name")
+ #
+ # checkbox("name", "value")
+ # # = checkbox("NAME" => "name", "VALUE" => "value")
+ #
+ # checkbox("name", "value", true)
+ # # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true)
def checkbox(name = "", value = nil, checked = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "checkbox", "NAME" => name,
@@ -1165,33 +1414,49 @@ convert string charset, and set language to "ja".
input(attributes)
end
-
-=begin
-=== CHECKBOX_GROUP
- checkbox_group("name", "foo", "bar", "baz")
- # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
- # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar
- # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
-
- checkbox_group("name", ["foo"], ["bar", true], "baz")
- # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
- # <INPUT TYPE="checkbox" SELECTED NAME="name" VALUE="bar">bar
- # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
-
- checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
- # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo
- # <INPUT TYPE="checkbox" SELECTED NAME="name" VALUE="2">Bar
- # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz
-
- checkbox_group({ "NAME" => "name",
- "VALUES" => ["foo", "bar", "baz"] })
-
- checkbox_group({ "NAME" => "name",
- "VALUES" => [["foo"], ["bar", true], "baz"] })
-
- checkbox_group({ "NAME" => "name",
- "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
-=end
+ # Generate a sequence of checkbox elements, as a String.
+ #
+ # The checkboxes will all have the same +name+ attribute.
+ # Each checkbox is followed by a label.
+ # There will be one checkbox for each value. Each value
+ # can be specified as a String, which will be used both
+ # as the value of the VALUE attribute and as the label
+ # for that checkbox. A single-element array has the
+ # same effect.
+ #
+ # Each value can also be specified as a three-element array.
+ # The first element is the VALUE attribute; the second is the
+ # label; and the third is a boolean specifying whether this
+ # checkbox is CHECKED.
+ #
+ # Each value can also be specified as a two-element
+ # array, by omitting either the value element (defaults
+ # to the same as the label), or the boolean checked element
+ # (defaults to false).
+ #
+ # checkbox_group("name", "foo", "bar", "baz")
+ # # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
+ # # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar
+ # # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
+ #
+ # checkbox_group("name", ["foo"], ["bar", true], "baz")
+ # # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
+ # # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="bar">bar
+ # # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
+ #
+ # checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
+ # # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo
+ # # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="2">Bar
+ # # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz
+ #
+ # checkbox_group("NAME" => "name",
+ # "VALUES" => ["foo", "bar", "baz"])
+ #
+ # checkbox_group("NAME" => "name",
+ # "VALUES" => [["foo"], ["bar", true], "baz"])
+ #
+ # checkbox_group("NAME" => "name",
+ # "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
def checkbox_group(name = "", *values)
if name.kind_of?(Hash)
values = name["VALUES"]
@@ -1213,20 +1478,27 @@ convert string charset, and set language to "ja".
end
-=begin
-=== FILE_FIELD
- file_field("name")
- # <INPUT TYPE="file" NAME="name" SIZE="20">
-
- file_field("name", 40)
- # <INPUT TYPE="file" NAME="name" SIZE="40">
-
- file_field("name", 40, 100)
- # <INPUT TYPE="file" NAME="name" SIZE="40", MAXLENGTH="100">
-
- file_field({ "NAME" => "name", "SIZE" => 40 })
- # <INPUT TYPE="file" NAME="name" SIZE="40">
-=end
+ # Generate an File Upload Input element as a string.
+ #
+ # The attributes of the element can be specified as three arguments,
+ # +name+, +size+, and +maxlength+. +maxlength+ is the maximum length
+ # of the file's _name_, not of the file's _contents_.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # See #multipart_form() for forms that include file uploads.
+ #
+ # file_field("name")
+ # # <INPUT TYPE="file" NAME="name" SIZE="20">
+ #
+ # file_field("name", 40)
+ # # <INPUT TYPE="file" NAME="name" SIZE="40">
+ #
+ # file_field("name", 40, 100)
+ # # <INPUT TYPE="file" NAME="name" SIZE="40" MAXLENGTH="100">
+ #
+ # file_field("NAME" => "name", "SIZE" => 40)
+ # # <INPUT TYPE="file" NAME="name" SIZE="40">
def file_field(name = "", size = 20, maxlength = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "file", "NAME" => name,
@@ -1240,23 +1512,28 @@ convert string charset, and set language to "ja".
end
-=begin
-=== FORM ELEMENT
- form{ "string" }
- # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
-
- form("get"){ "string" }
- # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
-
- form("get", "url"){ "string" }
- # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
-
- form({"METHOD" => "post", "ENCTYPE" => "enctype"}){ "string" }
- # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
-
-The hash keys are case sensitive. Ask the samples.
-=end
- def form(method = "post", action = nil, enctype = "application/x-www-form-urlencoded")
+ # Generate a Form element as a string.
+ #
+ # +method+ should be either "get" or "post", and defaults to the latter.
+ # +action+ defaults to the current CGI script name. +enctype+
+ # defaults to "application/x-www-form-urlencoded".
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # See also #multipart_form() for forms that include file uploads.
+ #
+ # form{ "string" }
+ # # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
+ #
+ # form("get") { "string" }
+ # # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
+ #
+ # form("get", "url") { "string" }
+ # # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
+ #
+ # form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" }
+ # # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
+ def form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded")
attributes = if method.kind_of?(String)
{ "METHOD" => method, "ACTION" => action,
"ENCTYPE" => enctype }
@@ -1275,25 +1552,28 @@ The hash keys are case sensitive. Ask the samples.
body = ""
end
if @output_hidden
- hidden = @output_hidden.collect{|k,v|
- "<INPUT TYPE=HIDDEN NAME=\"#{k}\" VALUE=\"#{v}\">"
+ body += @output_hidden.collect{|k,v|
+ "<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">"
}.to_s
- body.concat hidden
end
super(attributes){body}
end
-=begin
-=== HIDDEN FIELD
- hidden("name")
- # <INPUT TYPE="hidden" NAME="name">
-
- hidden("name", "value")
- # <INPUT TYPE="hidden" NAME="name" VALUE="value">
-
- hidden({ "NAME" => "name", "VALUE" => "reset", "ID" => "foo" })
- # <INPUT TYPE="hidden" NAME="name" VALUE="value" ID="foo">
-=end
+ # Generate a Hidden Input element as a string.
+ #
+ # The attributes of the element can be specified as two arguments,
+ # +name+ and +value+.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # hidden("name")
+ # # <INPUT TYPE="hidden" NAME="name">
+ #
+ # hidden("name", "value")
+ # # <INPUT TYPE="hidden" NAME="name" VALUE="value">
+ #
+ # hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo")
+ # # <INPUT TYPE="hidden" NAME="name" VALUE="value" ID="foo">
def hidden(name = "", value = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "hidden", "NAME" => name, "VALUE" => value }
@@ -1304,43 +1584,49 @@ The hash keys are case sensitive. Ask the samples.
input(attributes)
end
-
-=begin
-=== HTML ELEMENT
-
- html{ "string" }
- # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>string</HTML>
-
- html({ "LANG" => "ja" }){ "string" }
- # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML LANG="ja">string</HTML>
-
- html({ "DOCTYPE" => false }){ "string" }
- # <HTML>string</HTML>
-
- html({ "DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">' }){ "string" }
- # <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>string</HTML>
-
- html({ "PRETTY" => " " }){ "<BODY></BODY>" }
- # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
- # <HTML>
- # <BODY>
- # </BODY>
- # </HTML>
-
- html({ "PRETTY" => "\t" }){ "<BODY></BODY>" }
- # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
- # <HTML>
- # <BODY>
- # </BODY>
- # </HTML>
-
- html("PRETTY"){ "<BODY></BODY>" }
- # = html({ "PRETTY" => " " }){ "<BODY></BODY>" }
-
- html(if $VERBOSE then "PRETTY" end){ "HTML string" }
-
-=end
- def html(attributes = {})
+ # Generate a top-level HTML element as a string.
+ #
+ # The attributes of the element are specified as a hash. The
+ # pseudo-attribute "PRETTY" can be used to specify that the generated
+ # HTML string should be indented. "PRETTY" can also be specified as
+ # a string as the sole argument to this method. The pseudo-attribute
+ # "DOCTYPE", if given, is used as the leading DOCTYPE SGML tag; it
+ # should include the entire text of this tag, including angle brackets.
+ #
+ # The body of the html element is supplied as a block.
+ #
+ # html{ "string" }
+ # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>string</HTML>
+ #
+ # html("LANG" => "ja") { "string" }
+ # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML LANG="ja">string</HTML>
+ #
+ # html("DOCTYPE" => false) { "string" }
+ # # <HTML>string</HTML>
+ #
+ # html("DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">') { "string" }
+ # # <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>string</HTML>
+ #
+ # html("PRETTY" => " ") { "<BODY></BODY>" }
+ # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+ # # <HTML>
+ # # <BODY>
+ # # </BODY>
+ # # </HTML>
+ #
+ # html("PRETTY" => "\t") { "<BODY></BODY>" }
+ # # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+ # # <HTML>
+ # # <BODY>
+ # # </BODY>
+ # # </HTML>
+ #
+ # html("PRETTY") { "<BODY></BODY>" }
+ # # = html("PRETTY" => " ") { "<BODY></BODY>" }
+ #
+ # html(if $VERBOSE then "PRETTY" end) { "HTML string" }
+ #
+ def html(attributes = {}) # :yield:
if nil == attributes
attributes = {}
elsif "PRETTY" == attributes
@@ -1352,18 +1638,18 @@ The hash keys are case sensitive. Ask the samples.
if attributes.has_key?("DOCTYPE")
if attributes["DOCTYPE"]
- buf.concat( attributes.delete("DOCTYPE") )
+ buf += attributes.delete("DOCTYPE")
else
attributes.delete("DOCTYPE")
end
else
- buf.concat( doctype )
+ buf += doctype
end
if block_given?
- buf.concat( super(attributes){ yield } )
+ buf += super(attributes){ yield }
else
- buf.concat( super(attributes) )
+ buf += super(attributes)
end
if pretty
@@ -1374,18 +1660,21 @@ The hash keys are case sensitive. Ask the samples.
end
-
-=begin
-=== IMAGE_BUTTON
- image_button("url")
- # <INPUT TYPE="image" SRC="url">
-
- image_button("url", "name", "string")
- # <INPUT TYPE="image" SRC="url" NAME="name", ALT="string">
-
- image_button({ "SRC" => "url", "ATL" => "strng" })
- # <INPUT TYPE="image" SRC="url" ALT="string">
-=end
+ # Generate an Image Button Input element as a string.
+ #
+ # +src+ is the URL of the image to use for the button. +name+
+ # is the input name. +alt+ is the alternative text for the image.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # image_button("url")
+ # # <INPUT TYPE="image" SRC="url">
+ #
+ # image_button("url", "name", "string")
+ # # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string">
+ #
+ # image_button("SRC" => "url", "ATL" => "strng")
+ # # <INPUT TYPE="image" SRC="url" ALT="string">
def image_button(src = "", name = nil, alt = nil)
attributes = if src.kind_of?(String)
{ "TYPE" => "image", "SRC" => src, "NAME" => name,
@@ -1399,14 +1688,19 @@ The hash keys are case sensitive. Ask the samples.
end
-=begin
-=== IMG ELEMENT
- img("src", "alt", 100, 50)
- # <IMG SRC="src" ALT="alt" WIDTH="100", HEIGHT="50">
-
- img({ "SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50 })
- # <IMG SRC="src" ALT="alt" WIDTH="100", HEIGHT="50">
-=end
+ # Generate an Image element as a string.
+ #
+ # +src+ is the URL of the image. +alt+ is the alternative text for
+ # the image. +width+ is the width of the image, and +height+ is
+ # its height.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # img("src", "alt", 100, 50)
+ # # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
+ #
+ # img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50)
+ # # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
def img(src = "", alt = "", width = nil, height = nil)
attributes = if src.kind_of?(String)
{ "SRC" => src, "ALT" => alt }
@@ -1419,14 +1713,20 @@ The hash keys are case sensitive. Ask the samples.
end
-=begin
-=== MULTIPART FORM
- multipart_form{ "string" }
- # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM>
-
- multipart_form("url"){ "string" }
- # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
-=end
+ # Generate a Form element with multipart encoding as a String.
+ #
+ # Multipart encoding is used for forms that include file uploads.
+ #
+ # +action+ is the action to perform. +enctype+ is the encoding
+ # type, which defaults to "multipart/form-data".
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # multipart_form{ "string" }
+ # # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM>
+ #
+ # multipart_form("url") { "string" }
+ # # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
def multipart_form(action = nil, enctype = "multipart/form-data")
attributes = if action == nil
{ "METHOD" => "post", "ENCTYPE" => enctype }
@@ -1450,20 +1750,25 @@ The hash keys are case sensitive. Ask the samples.
end
-=begin
-=== PASSWORD_FIELD
- password_field("name")
- # <INPUT TYPE="password" NAME="name" SIZE="40">
-
- password_field("name", "value")
- # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="40">
-
- password_field("password", "value", 80, 200)
- # <INPUT TYPE="password" NAME="name" VALUE="value", SIZE="80", MAXLENGTH="200">
-
- password_field({ "NAME" => "name", "VALUE" => "value" })
- # <INPUT TYPE="password" NAME="name" VALUE="value">
-=end
+ # Generate a Password Input element as a string.
+ #
+ # +name+ is the name of the input field. +value+ is its default
+ # value. +size+ is the size of the input field display. +maxlength+
+ # is the maximum length of the inputted password.
+ #
+ # Alternatively, attributes can be specified as a hash.
+ #
+ # password_field("name")
+ # # <INPUT TYPE="password" NAME="name" SIZE="40">
+ #
+ # password_field("name", "value")
+ # # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="40">
+ #
+ # password_field("password", "value", 80, 200)
+ # # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
+ #
+ # password_field("NAME" => "name", "VALUE" => "value")
+ # # <INPUT TYPE="password" NAME="name" VALUE="value">
def password_field(name = "", value = nil, size = 40, maxlength = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "password", "NAME" => name,
@@ -1476,38 +1781,49 @@ The hash keys are case sensitive. Ask the samples.
input(attributes)
end
-
-=begin
-=== POPUP_MENU
- popup_menu("name", "foo", "bar", "baz")
- # <SELECT NAME="name">
- # <OPTION VALUE="foo">foo</OPTION>
- # <OPTION VALUE="bar">bar</OPTION>
- # <OPTION VALUE="baz">baz</OPTION>
- # </SELECT>
-
- popup_menu("name", ["foo"], ["bar", true], "baz")
- # <SELECT NAME="name">
- # <OPTION VALUE="foo">foo</OPTION>
- # <OPTION VALUE="bar" SELECTED>bar</OPTION>
- # <OPTION VALUE="baz">baz</OPTION>
- # </SELECT>
-
- popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
- # <SELECT NAME="name">
- # <OPTION VALUE="1">Foo</OPTION>
- # <OPTION SELECTED VALUE="2">Bar</OPTION>
- # <OPTION VALUE="Baz">Baz</OPTION>
- # </SELECT>
-
- popup_menu({"NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
- "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
- # <SELECT NAME="name" MULTIPLE SIZE="2">
- # <OPTION VALUE="1">Foo</OPTION>
- # <OPTION SELECTED VALUE="2">Bar</OPTION>
- # <OPTION VALUE="Baz">Baz</OPTION>
- # </SELECT>
-=end
+ # Generate a Select element as a string.
+ #
+ # +name+ is the name of the element. The +values+ are the options that
+ # can be selected from the Select menu. Each value can be a String or
+ # a one, two, or three-element Array. If a String or a one-element
+ # Array, this is both the value of that option and the text displayed for
+ # it. If a three-element Array, the elements are the option value, displayed
+ # text, and a boolean value specifying whether this option starts as selected.
+ # The two-element version omits either the option value (defaults to the same
+ # as the display text) or the boolean selected specifier (defaults to false).
+ #
+ # The attributes and options can also be specified as a hash. In this
+ # case, options are specified as an array of values as described above,
+ # with the hash key of "VALUES".
+ #
+ # popup_menu("name", "foo", "bar", "baz")
+ # # <SELECT NAME="name">
+ # # <OPTION VALUE="foo">foo</OPTION>
+ # # <OPTION VALUE="bar">bar</OPTION>
+ # # <OPTION VALUE="baz">baz</OPTION>
+ # # </SELECT>
+ #
+ # popup_menu("name", ["foo"], ["bar", true], "baz")
+ # # <SELECT NAME="name">
+ # # <OPTION VALUE="foo">foo</OPTION>
+ # # <OPTION VALUE="bar" SELECTED>bar</OPTION>
+ # # <OPTION VALUE="baz">baz</OPTION>
+ # # </SELECT>
+ #
+ # popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
+ # # <SELECT NAME="name">
+ # # <OPTION VALUE="1">Foo</OPTION>
+ # # <OPTION SELECTED VALUE="2">Bar</OPTION>
+ # # <OPTION VALUE="Baz">Baz</OPTION>
+ # # </SELECT>
+ #
+ # popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
+ # "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
+ # # <SELECT NAME="name" MULTIPLE SIZE="2">
+ # # <OPTION VALUE="1">Foo</OPTION>
+ # # <OPTION SELECTED VALUE="2">Bar</OPTION>
+ # # <OPTION VALUE="Baz">Baz</OPTION>
+ # # </SELECT>
def popup_menu(name = "", *values)
if name.kind_of?(Hash)
@@ -1541,18 +1857,22 @@ The hash keys are case sensitive. Ask the samples.
end
-
-=begin
-=== RADIO_BUTTON
- radio_button("name", "value")
- # <INPUT TYPE="radio" NAME="name", VALUE="value">
-
- radio_button("name", "value", true)
- # <INPUT TYPE="radio" NAME="name", VALUE="value", CHECKED>
-
- radio_button({ "NAME" => "name", "VALUE" => "value", "ID" => "foo" })
- # <INPUT TYPE="radio" NAME="name" VALUE="value" ID="foo">
-=end
+ # Generates a radio-button Input element.
+ #
+ # +name+ is the name of the input field. +value+ is the value of
+ # the field if checked. +checked+ specifies whether the field
+ # starts off checked.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # radio_button("name", "value")
+ # # <INPUT TYPE="radio" NAME="name" VALUE="value">
+ #
+ # radio_button("name", "value", true)
+ # # <INPUT TYPE="radio" NAME="name" VALUE="value" CHECKED>
+ #
+ # radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo")
+ # # <INPUT TYPE="radio" NAME="name" VALUE="value" ID="foo">
def radio_button(name = "", value = nil, checked = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "radio", "NAME" => name,
@@ -1564,33 +1884,34 @@ The hash keys are case sensitive. Ask the samples.
input(attributes)
end
-
-=begin
-=== RADIO_GROUP
- radio_group("name", "foo", "bar", "baz")
- # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
- # <INPUT TYPE="radio" NAME="name" VALUE="bar">bar
- # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
-
- radio_group("name", ["foo"], ["bar", true], "baz")
- # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
- # <INPUT TYPE="radio" SELECTED NAME="name" VALUE="bar">bar
- # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
-
- radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
- # <INPUT TYPE="radio" NAME="name" VALUE="1">Foo
- # <INPUT TYPE="radio" SELECTED NAME="name" VALUE="2">Bar
- # <INPUT TYPE="radio" NAME="name" VALUE="Baz">Baz
-
- radio_group({ "NAME" => "name",
- "VALUES" => ["foo", "bar", "baz"] })
-
- radio_group({ "NAME" => "name",
- "VALUES" => [["foo"], ["bar", true], "baz"] })
-
- radio_group({ "NAME" => "name",
- "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
-=end
+ # Generate a sequence of radio button Input elements, as a String.
+ #
+ # This works the same as #checkbox_group(). However, it is not valid
+ # to have more than one radiobutton in a group checked.
+ #
+ # radio_group("name", "foo", "bar", "baz")
+ # # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
+ # # <INPUT TYPE="radio" NAME="name" VALUE="bar">bar
+ # # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
+ #
+ # radio_group("name", ["foo"], ["bar", true], "baz")
+ # # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
+ # # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="bar">bar
+ # # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
+ #
+ # radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
+ # # <INPUT TYPE="radio" NAME="name" VALUE="1">Foo
+ # # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="2">Bar
+ # # <INPUT TYPE="radio" NAME="name" VALUE="Baz">Baz
+ #
+ # radio_group("NAME" => "name",
+ # "VALUES" => ["foo", "bar", "baz"])
+ #
+ # radio_group("NAME" => "name",
+ # "VALUES" => [["foo"], ["bar", true], "baz"])
+ #
+ # radio_group("NAME" => "name",
+ # "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
def radio_group(name = "", *values)
if name.kind_of?(Hash)
values = name["VALUES"]
@@ -1611,18 +1932,21 @@ The hash keys are case sensitive. Ask the samples.
}.to_s
end
-
-=begin
-=== RESET BUTTON
- reset
- # <INPUT TYPE="reset">
-
- reset("reset")
- # <INPUT TYPE="reset" VALUE="reset">
-
- reset({ "VALUE" => "reset", "ID" => "foo" })
- # <INPUT TYPE="reset" VALUE="reset" ID="foo">
-=end
+ # Generate a reset button Input element, as a String.
+ #
+ # This resets the values on a form to their initial values. +value+
+ # is the text displayed on the button. +name+ is the name of this button.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # reset
+ # # <INPUT TYPE="reset">
+ #
+ # reset("reset")
+ # # <INPUT TYPE="reset" VALUE="reset">
+ #
+ # reset("VALUE" => "reset", "ID" => "foo")
+ # # <INPUT TYPE="reset" VALUE="reset" ID="foo">
def reset(value = nil, name = nil)
attributes = if (not value) or value.kind_of?(String)
{ "TYPE" => "reset", "VALUE" => value, "NAME" => name }
@@ -1633,34 +1957,26 @@ The hash keys are case sensitive. Ask the samples.
input(attributes)
end
-
-=begin
-=== SCROLLING_LIST
- scrolling_list({"NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
- "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"] })
- # <SELECT NAME="name" MULTIPLE SIZE="2">
- # <OPTION VALUE="1">Foo</OPTION>
- # <OPTION SELECTED VALUE="2">Bar</OPTION>
- # <OPTION VALUE="Baz">Baz</OPTION>
- # </SELECT>
-=end
alias scrolling_list popup_menu
-
-=begin
-=== SUBMIT BUTTON
- submit
- # <INPUT TYPE="submit">
-
- submit("ok")
- # <INPUT TYPE="submit" VALUE="ok">
-
- submit("ok", "button1")
- # <INPUT TYPE="submit" VALUE="ok" NAME="button1">
-
- submit({ "VALUE" => "ok", "NAME" => "button1", "ID" => "foo" })
- # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
-=end
+ # Generate a submit button Input element, as a String.
+ #
+ # +value+ is the text to display on the button. +name+ is the name
+ # of the input.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # submit
+ # # <INPUT TYPE="submit">
+ #
+ # submit("ok")
+ # # <INPUT TYPE="submit" VALUE="ok">
+ #
+ # submit("ok", "button1")
+ # # <INPUT TYPE="submit" VALUE="ok" NAME="button1">
+ #
+ # submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo")
+ # # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
def submit(value = nil, name = nil)
attributes = if (not value) or value.kind_of?(String)
{ "TYPE" => "submit", "VALUE" => value, "NAME" => name }
@@ -1671,24 +1987,28 @@ The hash keys are case sensitive. Ask the samples.
input(attributes)
end
-
-=begin
-=== TEXT_FIELD
- text_field("name")
- # <INPUT TYPE="text" NAME="name" SIZE="40">
-
- text_field("name", "value")
- # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="40">
-
- text_field("name", "value", 80)
- # <INPUT TYPE="text" NAME="name" VALUE="value", SIZE="80">
-
- text_field("name", "value", 80, 200)
- # <INPUT TYPE="text" NAME="name" VALUE="value", SIZE="80", MAXLENGTH="200">
-
- text_field({ "NAME" => "name", "VALUE" => "value" })
- # <INPUT TYPE="text" NAME="name" VALUE="value">
-=end
+ # Generate a text field Input element, as a String.
+ #
+ # +name+ is the name of the input field. +value+ is its initial
+ # value. +size+ is the size of the input area. +maxlength+
+ # is the maximum length of input accepted.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # text_field("name")
+ # # <INPUT TYPE="text" NAME="name" SIZE="40">
+ #
+ # text_field("name", "value")
+ # # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="40">
+ #
+ # text_field("name", "value", 80)
+ # # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80">
+ #
+ # text_field("name", "value", 80, 200)
+ # # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
+ #
+ # text_field("NAME" => "name", "VALUE" => "value")
+ # # <INPUT TYPE="text" NAME="name" VALUE="value">
def text_field(name = "", value = nil, size = 40, maxlength = nil)
attributes = if name.kind_of?(String)
{ "TYPE" => "text", "NAME" => name, "VALUE" => value,
@@ -1701,16 +2021,21 @@ The hash keys are case sensitive. Ask the samples.
input(attributes)
end
-
-=begin
-=== TEXTAREA ELEMENT
- textarea("name")
- # = textarea({ "NAME" => "name", "COLS" => 70, "ROWS" => 10 })
-
- textarea("name", 40, 5)
- # = textarea({ "NAME" => "name", "COLS" => 40, "ROWS" => 5 })
-=end
- def textarea(name = "", cols = 70, rows = 10)
+ # Generate a TextArea element, as a String.
+ #
+ # +name+ is the name of the textarea. +cols+ is the number of
+ # columns and +rows+ is the number of rows in the display.
+ #
+ # Alternatively, the attributes can be specified as a hash.
+ #
+ # The body is provided by the passed-in no-argument block
+ #
+ # textarea("name")
+ # # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10)
+ #
+ # textarea("name", 40, 5)
+ # # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5)
+ def textarea(name = "", cols = 70, rows = 10) # :yield:
attributes = if name.kind_of?(String)
{ "NAME" => name, "COLS" => cols.to_s,
"ROWS" => rows.to_s }
@@ -1727,12 +2052,15 @@ The hash keys are case sensitive. Ask the samples.
end # HtmlExtension
- module Html3
+ # Mixin module for HTML version 3 generation methods.
+ module Html3 # :nodoc:
+ # The DOCTYPE declaration for this version of HTML
def doctype
%|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">|
end
+ # Initialise the HTML generation methods for this version.
def element_init
extend TagMaker
methods = ""
@@ -1742,7 +2070,7 @@ The hash keys are case sensitive. Ask the samples.
APPLET PRE XMP LISTING DL OL UL DIR MENU SELECT table TITLE
STYLE SCRIPT H1 H2 H3 H4 H5 H6 TEXTAREA FORM BLOCKQUOTE
CAPTION ]
- methods.concat( <<-BEGIN + nn_element_def(element) + <<-END )
+ methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1752,7 +2080,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY
for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
ISINDEX META ]
- methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END )
+ methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1762,7 +2090,7 @@ The hash keys are case sensitive. Ask the samples.
# O O or - O
for element in %w[ HTML HEAD BODY P PLAINTEXT DT DD LI OPTION tr
th td ]
- methods.concat( <<-BEGIN + nO_element_def(element) + <<-END )
+ methods += <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1774,12 +2102,15 @@ The hash keys are case sensitive. Ask the samples.
end # Html3
- module Html4
+ # Mixin module for HTML version 4 generation methods.
+ module Html4 # :nodoc:
+ # The DOCTYPE declaration for this version of HTML
def doctype
%|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">|
end
+ # Initialise the HTML generation methods for this version.
def element_init
extend TagMaker
methods = ""
@@ -1789,7 +2120,7 @@ The hash keys are case sensitive. Ask the samples.
H1 H2 H3 H4 H5 H6 PRE Q INS DEL DL OL UL LABEL SELECT OPTGROUP
FIELDSET LEGEND BUTTON TABLE TITLE STYLE SCRIPT NOSCRIPT
TEXTAREA FORM A BLOCKQUOTE CAPTION ]
- methods.concat( <<-BEGIN + nn_element_def(element) + <<-END )
+ methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1798,7 +2129,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY
for element in %w[ IMG BASE BR AREA LINK PARAM HR INPUT COL META ]
- methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END )
+ methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1808,7 +2139,7 @@ The hash keys are case sensitive. Ask the samples.
# O O or - O
for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
COLGROUP TR TH TD HEAD]
- methods.concat( <<-BEGIN + nO_element_def(element) + <<-END )
+ methods += <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1820,12 +2151,15 @@ The hash keys are case sensitive. Ask the samples.
end # Html4
- module Html4Tr
+ # Mixin module for HTML version 4 transitional generation methods.
+ module Html4Tr # :nodoc:
+ # The DOCTYPE declaration for this version of HTML
def doctype
%|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">|
end
+ # Initialise the HTML generation methods for this version.
def element_init
extend TagMaker
methods = ""
@@ -1836,7 +2170,7 @@ The hash keys are case sensitive. Ask the samples.
INS DEL DL OL UL DIR MENU LABEL SELECT OPTGROUP FIELDSET
LEGEND BUTTON TABLE IFRAME NOFRAMES TITLE STYLE SCRIPT
NOSCRIPT TEXTAREA FORM A BLOCKQUOTE CAPTION ]
- methods.concat( <<-BEGIN + nn_element_def(element) + <<-END )
+ methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1846,7 +2180,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY
for element in %w[ IMG BASE BASEFONT BR AREA LINK PARAM HR INPUT
COL ISINDEX META ]
- methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END )
+ methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1856,7 +2190,7 @@ The hash keys are case sensitive. Ask the samples.
# O O or - O
for element in %w[ HTML BODY P DT DD LI OPTION THEAD TFOOT TBODY
COLGROUP TR TH TD HEAD ]
- methods.concat( <<-BEGIN + nO_element_def(element) + <<-END )
+ methods += <<-BEGIN + nO_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1868,20 +2202,20 @@ The hash keys are case sensitive. Ask the samples.
end # Html4Tr
- module Html4Fr
+ # Mixin module for generating HTML version 4 with framesets.
+ module Html4Fr # :nodoc:
+ # The DOCTYPE declaration for this version of HTML
def doctype
%|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">|
end
+ # Initialise the HTML generation methods for this version.
def element_init
- extend TagMaker
- extend Html4Tr
- element_init()
methods = ""
# - -
for element in %w[ FRAMESET ]
- methods.concat( <<-BEGIN + nn_element_def(element) + <<-END )
+ methods += <<-BEGIN + nn_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1890,7 +2224,7 @@ The hash keys are case sensitive. Ask the samples.
# - O EMPTY
for element in %w[ FRAME ]
- methods.concat( <<-BEGIN + nOE_element_def(element) + <<-END )
+ methods += <<-BEGIN + nOE_element_def(element) + <<-END
def #{element.downcase}(attributes = {})
BEGIN
end
@@ -1902,15 +2236,37 @@ The hash keys are case sensitive. Ask the samples.
end # Html4Fr
+ # Creates a new CGI instance.
+ #
+ # +type+ specifies which version of HTML to load the HTML generation
+ # methods for. The following versions of HTML are supported:
+ #
+ # html3:: HTML 3.x
+ # html4:: HTML 4.0
+ # html4Tr:: HTML 4.0 Transitional
+ # html4Fr:: HTML 4.0 with Framesets
+ #
+ # If not specified, no HTML generation methods will be loaded.
+ #
+ # If the CGI object is not created in a standard CGI call environment
+ # (that is, it can't locate REQUEST_METHOD in its environment), then
+ # it will run in "offline" mode. In this mode, it reads its parameters
+ # from the command line or (failing that) from standard input. Otherwise,
+ # cookies and other parameters are parsed automatically from the standard
+ # CGI locations, which varies according to the REQUEST_METHOD.
def initialize(type = "query")
+ if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE")
+ Apache.request.setup_cgi_env
+ end
+
extend QueryExtension
+ @multipart = false
if defined?(CGI_PARAMS)
- @params = CGI_PARAMS.nil? ? nil : CGI_PARAMS.dup
- @cookies = CGI_COOKIES.nil? ? nil : CGI_COOKIES.dup
+ warn "do not use CGI_PARAMS and CGI_COOKIES"
+ @params = CGI_PARAMS.dup
+ @cookies = CGI_COOKIES.dup
else
initialize_query() # set @params, @cookies
- eval "CGI_PARAMS = @params.nil? ? nil : @params.dup"
- eval "CGI_COOKIES = @cookies.nil? ? nil : @cookies.dup"
end
@output_cookies = nil
@output_hidden = nil
@@ -1929,31 +2285,12 @@ The hash keys are case sensitive. Ask the samples.
element_init()
extend HtmlExtension
when "html4Fr"
+ extend Html4Tr
+ element_init()
extend Html4Fr
element_init()
extend HtmlExtension
end
-
end
- if defined?(MOD_RUBY) and (RUBY_VERSION < "1.4.3")
- raise "Please, use ruby1.4.3 or later."
- else
- at_exit() do
- if defined?(CGI_PARAMS)
- remove_const(:CGI_PARAMS)
- remove_const(:CGI_COOKIES)
- end
- end
- end
-end
-
-
-=begin
-
-== HISTORY
-
-delete. see cvs log.
-
-
-=end
+end # class CGI
diff --git a/lib/cgi/.document b/lib/cgi/.document
new file mode 100644
index 0000000000..107f2f317c
--- /dev/null
+++ b/lib/cgi/.document
@@ -0,0 +1,2 @@
+session.rb
+
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 1120fb50f0..9a49fdedc9 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -1,41 +1,256 @@
+#
+# cgi/session.rb - session support for cgi scripts
+#
# Copyright (C) 2001 Yukihiro "Matz" Matsumoto
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright (C) 2000 Information-technology Promotion Agency, Japan
+#
+# Author: Yukihiro "Matz" Matsumoto
+#
+# Documentation: William Webber (william@williamwebber.com)
+#
+# == Overview
+#
+# This file provides the +CGI::Session+ class, which provides session
+# support for CGI scripts. A session is a sequence of HTTP requests
+# and responses linked together and associated with a single client.
+# Information associated with the session is stored
+# on the server between requests. A session id is passed between client
+# and server with every request and response, transparently
+# to the user. This adds state information to the otherwise stateless
+# HTTP request/response protocol.
+#
+# See the documentation to the +CGI::Session+ class for more details
+# and examples of usage. See cgi.rb for the +CGI+ class itself.
require 'cgi'
-require 'final'
+require 'tmpdir'
class CGI
+
+ # Class representing an HTTP session. See documentation for the file
+ # cgi/session.rb for an introduction to HTTP sessions.
+ #
+ # == Lifecycle
+ #
+ # A CGI::Session instance is created from a CGI object. By default,
+ # this CGI::Session instance will start a new session if none currently
+ # exists, or continue the current session for this client if one does
+ # exist. The +new_session+ option can be used to either always or
+ # never create a new session. See #new() for more details.
+ #
+ # #delete() deletes a session from session storage. It
+ # does not however remove the session id from the client. If the client
+ # makes another request with the same id, the effect will be to start
+ # a new session with the old session's id.
+ #
+ # == Setting and retrieving session data.
+ #
+ # The Session class associates data with a session as key-value pairs.
+ # This data can be set and retrieved by indexing the Session instance
+ # using '[]', much the same as hashes (although other hash methods
+ # are not supported).
+ #
+ # When session processing has been completed for a request, the
+ # session should be closed using the close() method. This will
+ # store the session's state to persistent storage. If you want
+ # to store the session's state to persistent storage without
+ # finishing session processing for this request, call the update()
+ # method.
+ #
+ # == Storing session state
+ #
+ # The caller can specify what form of storage to use for the session's
+ # data with the +database_manager+ option to CGI::Session::new. The
+ # following storage classes are provided as part of the standard library:
+ #
+ # CGI::Session::FileStore:: stores data as plain text in a flat file. Only
+ # works with String data. This is the default
+ # storage type.
+ # CGI::Session::MemoryStore:: stores data in an in-memory hash. The data
+ # only persists for as long as the current ruby
+ # interpreter instance does.
+ # CGI::Session::PStore:: stores data in Marshalled format. Provided by
+ # cgi/session/pstore.rb. Supports data of any type,
+ # and provides file-locking and transaction support.
+ #
+ # Custom storage types can also be created by defining a class with
+ # the following methods:
+ #
+ # new(session, options)
+ # restore # returns hash of session data.
+ # update
+ # close
+ # delete
+ #
+ # Changing storage type mid-session does not work. Note in particular
+ # that by default the FileStore and PStore session data files have the
+ # same name. If your application switches from one to the other without
+ # making sure that filenames will be different
+ # and clients still have old sessions lying around in cookies, then
+ # things will break nastily!
+ #
+ # == Maintaining the session id.
+ #
+ # Most session state is maintained on the server. However, a session
+ # id must be passed backwards and forwards between client and server
+ # to maintain a reference to this session state.
+ #
+ # The simplest way to do this is via cookies. The CGI::Session class
+ # provides transparent support for session id communication via cookies
+ # if the client has cookies enabled.
+ #
+ # If the client has cookies disabled, the session id must be included
+ # as a parameter of all requests sent by the client to the server. The
+ # CGI::Session class in conjunction with the CGI class will transparently
+ # add the session id as a hidden input field to all forms generated
+ # using the CGI#form() HTML generation method. No built-in support is
+ # provided for other mechanisms, such as URL re-writing. The caller is
+ # responsible for extracting the session id from the session_id
+ # attribute and manually encoding it in URLs and adding it as a hidden
+ # input to HTML forms created by other mechanisms. Also, session expiry
+ # is not automatically handled.
+ #
+ # == Examples of use
+ #
+ # === Setting the user's name
+ #
+ # require 'cgi'
+ # require 'cgi/session'
+ # require 'cgi/session/pstore' # provides CGI::Session::PStore
+ #
+ # cgi = CGI.new("html4")
+ #
+ # session = CGI::Session.new(cgi,
+ # 'database_manager' => CGI::Session::PStore, # use PStore
+ # 'session_key' => '_rb_sess_id', # custom session key
+ # 'session_expires' => Time.now + 30 * 60, # 30 minute timeout
+ # 'prefix' => 'pstore_sid_') # PStore option
+ # if cgi.has_key?('user_name') and cgi['user_name'] != ''
+ # # coerce to String: cgi[] returns the
+ # # string-like CGI::QueryExtension::Value
+ # session['user_name'] = cgi['user_name'].to_s
+ # elsif !session['user_name']
+ # session['user_name'] = "guest"
+ # end
+ # session.close
+ #
+ # === Creating a new session safely
+ #
+ # require 'cgi'
+ # require 'cgi/session'
+ #
+ # cgi = CGI.new("html4")
+ #
+ # # We make sure to delete an old session if one exists,
+ # # not just to free resources, but to prevent the session
+ # # from being maliciously hijacked later on.
+ # begin
+ # session = CGI::Session.new(cgi, 'new_session' => false)
+ # session.delete
+ # rescue ArgumentError # if no old session
+ # end
+ # session = CGI::Session.new(cgi, 'new_session' => true)
+ # session.close
+ #
class Session
+ # The id of this session.
attr_reader :session_id
- def Session::callback(dbman)
+ def Session::callback(dbman) #:nodoc:
lambda{
- dbman.close
+ dbman[0].close unless dbman.empty?
}
end
+ # Create a new session id.
+ #
+ # The session id is an MD5 hash based upon the time,
+ # a random number, and a constant string. This routine
+ # is used internally for automatically generated
+ # session ids.
def Session::create_new_id
- require 'md5'
- md5 = MD5::new
- md5.update(String(Time::now))
+ require 'digest/md5'
+ md5 = Digest::MD5::new
+ now = Time::now
+ md5.update(now.to_s)
+ md5.update(String(now.usec))
md5.update(String(rand(0)))
md5.update(String($$))
md5.update('foobar')
md5.hexdigest[0,16]
end
+ # Create a new CGI::Session object for +request+.
+ #
+ # +request+ is an instance of the +CGI+ class (see cgi.rb).
+ # +option+ is a hash of options for initialising this
+ # CGI::Session instance. The following options are
+ # recognised:
+ #
+ # session_key:: the parameter name used for the session id.
+ # Defaults to '_session_id'.
+ # session_id:: the session id to use. If not provided, then
+ # it is retrieved from the +session_key+ parameter
+ # of the request, or automatically generated for
+ # a new session.
+ # new_session:: if true, force creation of a new session. If not set,
+ # a new session is only created if none currently
+ # exists. If false, a new session is never created,
+ # and if none currently exists and the +session_id+
+ # option is not set, an ArgumentError is raised.
+ # database_manager:: the name of the class providing storage facilities
+ # for session state persistence. Built-in support
+ # is provided for +FileStore+ (the default),
+ # +MemoryStore+, and +PStore+ (from
+ # cgi/session/pstore.rb). See the documentation for
+ # these classes for more details.
+ #
+ # The following options are also recognised, but only apply if the
+ # session id is stored in a cookie.
+ #
+ # session_expires:: the time the current session expires, as a
+ # +Time+ object. If not set, the session will terminate
+ # when the user's browser is closed.
+ # session_domain:: the hostname domain for which this session is valid.
+ # If not set, defaults to the hostname of the server.
+ # session_secure:: if +true+, this session will only work over HTTPS.
+ # session_path:: the path for which this session applies. Defaults
+ # to the directory of the CGI script.
+ #
+ # +option+ is also passed on to the session storage class initialiser; see
+ # the documentation for each session storage class for the options
+ # they support.
+ #
+ # The retrieved or created session is automatically added to +request+
+ # as a cookie, and also to its +output_hidden+ table, which is used
+ # to add hidden input elements to forms.
+ #
+ # *WARNING* the +output_hidden+
+ # fields are surrounded by a <fieldset> tag in HTML 4 generation, which
+ # is _not_ invisible on many browsers; you may wish to disable the
+ # use of fieldsets with code similar to the following
+ # (see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/37805)
+ #
+ # cgi = CGI.new("html4")
+ # class << cgi
+ # undef_method :fieldset
+ # end
+ #
def initialize(request, option={})
session_key = option['session_key'] || '_session_id'
- id, = option['session_id']
+ id = option['session_id']
unless id
if option['new_session']
id = Session::create_new_id
end
end
unless id
- id, = request[session_key]
+ if request.key?(session_key)
+ id = request[session_key]
+ id = id.read if id.respond_to?(:read)
+ end
unless id
id, = request.cookies[session_key]
end
@@ -54,6 +269,9 @@ class CGI
@output_cookies = [
Cookie::new("name" => session_key,
"value" => id,
+ "expires" => option['session_expires'],
+ "domain" => option['session_domain'],
+ "secure" => option['session_secure'],
"path" => if option['session_path'] then
option['session_path']
elsif ENV["SCRIPT_NAME"] then
@@ -63,9 +281,11 @@ class CGI
end)
]
end
- ObjectSpace::define_finalizer(self, Session::callback(@dbman))
+ @dbprot = [@dbman]
+ ObjectSpace::define_finalizer(self, Session::callback(@dbprot))
end
+ # Retrieve the session data for key +key+.
def [](key)
unless @data
@data = @dbman.restore
@@ -73,6 +293,7 @@ class CGI
@data[key]
end
+ # Set the session date for key +key+.
def []=(key, val)
unless @write_lock
@write_lock = true
@@ -80,94 +301,161 @@ class CGI
unless @data
@data = @dbman.restore
end
- @data[key] = String(val)
+ @data[key] = val
end
- def update
+ # Store session data on the server. For some session storage types,
+ # this is a no-op.
+ def update
@dbman.update
end
+ # Store session data on the server and close the session storage.
+ # For some session storage types, this is a no-op.
def close
@dbman.close
+ @dbprot.clear
end
+ # Delete the session from storage. Also closes the storage.
+ #
+ # Note that the session's data is _not_ automatically deleted
+ # upon the session expiring.
def delete
@dbman.delete
+ @dbprot.clear
end
+ # File-based session storage class.
+ #
+ # Implements session storage as a flat file of 'key=value' values.
+ # This storage type only works directly with String values; the
+ # user is responsible for converting other types to Strings when
+ # storing and from Strings when retrieving.
class FileStore
+ # Create a new FileStore instance.
+ #
+ # This constructor is used internally by CGI::Session. The
+ # user does not generally need to call it directly.
+ #
+ # +session+ is the session for which this instance is being
+ # created. The session id must only contain alphanumeric
+ # characters; automatically generated session ids observe
+ # this requirement.
+ #
+ # +option+ is a hash of options for the initialiser. The
+ # following options are recognised:
+ #
+ # tmpdir:: the directory to use for storing the FileStore
+ # file. Defaults to Dir::tmpdir (generally "/tmp"
+ # on Unix systems).
+ # prefix:: the prefix to add to the session id when generating
+ # the filename for this session's FileStore file.
+ # Defaults to the empty string.
+ #
+ # This session's FileStore file will be created if it does
+ # not exist, or opened if it does.
def initialize(session, option={})
- dir = option['tmpdir'] || ENV['TMP'] || '/tmp'
+ dir = option['tmpdir'] || Dir::tmpdir
prefix = option['prefix'] || ''
- path = dir+"/"+prefix+session.session_id
- path.untaint
- unless File::exist? path
+ id = session.session_id
+ require 'digest/md5'
+ md5 = Digest::MD5.hexdigest(id)[0,16]
+ @path = dir+"/"+prefix+md5
+ unless File::exist? @path
@hash = {}
end
- begin
- @f = open(path, "r+")
- rescue Errno::ENOENT
- @f = open(path, "w+")
- end
end
+ # Restore session state from the session's FileStore file.
+ #
+ # Returns the session state as a hash.
def restore
unless @hash
@hash = {}
- @f.flock File::LOCK_EX
- @f.rewind
- for line in @f
- line.chomp!
- k, v = line.split('=',2)
- @hash[CGI::unescape(k)] = CGI::unescape(v)
- end
+ begin
+ f = File.open(@path, 'r')
+ f.flock File::LOCK_SH
+ for line in f
+ line.chomp!
+ k, v = line.split('=',2)
+ @hash[CGI::unescape(k)] = CGI::unescape(v)
+ end
+ ensure
+ f.close unless f.nil?
+ end
end
@hash
end
+ # Save session state to the session's FileStore file.
def update
- @f.rewind
- for k,v in @hash
- @f.printf "%s=%s\n", CGI::escape(k), CGI::escape(v)
- end
- @f.truncate @f.tell
+ return unless @hash
+ begin
+ f = File.open(@path, File::CREAT|File::TRUNC|File::RDWR, 0600)
+ f.flock File::LOCK_EX
+ for k,v in @hash
+ f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(v))
+ end
+ ensure
+ f.close unless f.nil?
+ end
end
+ # Update and close the session's FileStore file.
def close
- return if @f.closed?
update
- @f.close
end
+ # Close and delete the session's FileStore file.
def delete
- path = @f.path
- @f.close
- File::unlink path
+ File::unlink @path
+ rescue Errno::ENOENT
end
end
+ # In-memory session storage class.
+ #
+ # Implements session storage as a global in-memory hash. Session
+ # data will only persist for as long as the ruby interpreter
+ # instance does.
class MemoryStore
- GLOBAL_HASH_TABLE = {}
+ GLOBAL_HASH_TABLE = {} #:nodoc:
- def initialize(session, option={})
+ # Create a new MemoryStore instance.
+ #
+ # +session+ is the session this instance is associated with.
+ # +option+ is a list of initialisation options. None are
+ # currently recognised.
+ def initialize(session, option=nil)
@session_id = session.session_id
- GLOBAL_HASH_TABLE[@session_id] = {}
+ GLOBAL_HASH_TABLE[@session_id] ||= {}
end
+ # Restore session state.
+ #
+ # Returns session data as a hash.
def restore
GLOBAL_HASH_TABLE[@session_id]
end
+ # Update session state.
+ #
+ # A no-op.
def update
# don't need to update; hash is shared
end
+ # Close session storage.
+ #
+ # A no-op.
def close
# don't need to close
end
+ # Delete the session state.
def delete
- GLOBAL_HASH_TABLE[@session_id] = nil
+ GLOBAL_HASH_TABLE.delete(@session_id)
end
end
end
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
new file mode 100644
index 0000000000..10f3e8f75f
--- /dev/null
+++ b/lib/cgi/session/pstore.rb
@@ -0,0 +1,117 @@
+#
+# cgi/session/pstore.rb - persistent storage of marshalled session data
+#
+# Documentation: William Webber (william@williamwebber.com)
+#
+# == Overview
+#
+# This file provides the CGI::Session::PStore class, which builds
+# persistent of session data on top of the pstore library. See
+# cgi/session.rb for more details on session storage managers.
+
+require 'cgi/session'
+require 'pstore'
+
+class CGI
+ class Session
+ def []=(key, val)
+ unless @write_lock
+ @write_lock = true
+ end
+ unless @data
+ @data = @dbman.restore
+ end
+ #@data[key] = String(val)
+ @data[key] = val
+ end
+
+ # PStore-based session storage class.
+ #
+ # This builds upon the top-level PStore class provided by the
+ # library file pstore.rb. Session data is marshalled and stored
+ # in a file. File locking and transaction services are provided.
+ class PStore
+ # Create a new CGI::Session::PStore instance
+ #
+ # This constructor is used internally by CGI::Session. The
+ # user does not generally need to call it directly.
+ #
+ # +session+ is the session for which this instance is being
+ # created. The session id must only contain alphanumeric
+ # characters; automatically generated session ids observe
+ # this requirement.
+ #
+ # +option+ is a hash of options for the initialiser. The
+ # following options are recognised:
+ #
+ # tmpdir:: the directory to use for storing the PStore
+ # file. Defaults to Dir::tmpdir (generally "/tmp"
+ # on Unix systems).
+ # prefix:: the prefix to add to the session id when generating
+ # the filename for this session's PStore file.
+ # Defaults to the empty string.
+ #
+ # This session's PStore file will be created if it does
+ # not exist, or opened if it does.
+ def initialize session, option={}
+ dir = option['tmpdir'] || Dir::tmpdir
+ prefix = option['prefix'] || ''
+ id = session.session_id
+ require 'digest/md5'
+ md5 = Digest::MD5.hexdigest(id)[0,16]
+ path = dir+"/"+prefix+md5
+ path.untaint
+ unless File::exist? path
+ @hash = {}
+ end
+ @p = ::PStore.new(path)
+ @p.transaction do |p|
+ File.chmod(0600, p.path)
+ end
+ end
+
+ # Restore session state from the session's PStore file.
+ #
+ # Returns the session state as a hash.
+ def restore
+ unless @hash
+ @p.transaction do
+ @hash = @p['hash'] || {}
+ end
+ end
+ @hash
+ end
+
+ # Save session state to the session's PStore file.
+ def update
+ @p.transaction do
+ @p['hash'] = @hash
+ end
+ end
+
+ # Update and close the session's PStore file.
+ def close
+ update
+ end
+
+ # Close and delete the session's PStore file.
+ def delete
+ path = @p.path
+ File::unlink path
+ end
+
+ end
+ end
+end
+
+if $0 == __FILE__
+ # :enddoc:
+ STDIN.reopen("/dev/null")
+ cgi = CGI.new
+ session = CGI::Session.new(cgi, 'database_manager' => CGI::Session::PStore)
+ session['key'] = {'k' => 'v'}
+ puts session['key'].class
+ fail unless Hash === session['key']
+ puts session['key'].inspect
+ fail unless session['key'].inspect == '{"k"=>"v"}'
+end
diff --git a/lib/complex.rb b/lib/complex.rb
index cb0a3dc564..9300f391e8 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -5,85 +5,136 @@
# $Date: 1998/07/08 10:05:28 $
# by Keiju ISHITSUKA(SHL Japan Inc.)
#
-# --
-# Usage:
-# class Complex < Numeric
+# ----
#
-# Complex(x, y) --> x + yi
-# y.im --> 0 + yi
+# complex.rb implements the Complex class for complex numbers. Additionally,
+# some methods in other Numeric classes are redefined or added to allow greater
+# interoperability with Complex numbers.
#
-# Complex::polar
+# Complex numbers can be created in the following manner:
+# - <tt>Complex(a, b)</tt>
+# - <tt>Complex.polar(radius, theta)</tt>
+#
+# Additionally, note the following:
+# - <tt>Complex::I</tt> (the mathematical constant <i>i</i>)
+# - <tt>Numeric#im</tt> (e.g. <tt>5.im -> 0+5i</tt>)
#
-# Complex::+
-# Complex::-
-# Complex::*
-# Complex::/
-# Complex::**
-# Complex::%
-# Complex::divmod -- obsolete
-# Complex::abs
-# Complex::abs2
-# Complex::arg
-# Complex::polar
-# Complex::conjugate
-# Complex::<=>
-# Complex::==
-# Complex::to_i
-# Complex::to_f
-# Complex::to_r
-# Complex::to_s
+# The following +Math+ module methods are redefined to handle Complex arguments.
+# They will work as normal with non-Complex arguments.
+# sqrt exp cos sin tan log log10
+# cosh sinh tanh acos asin atan atan2 acosh asinh atanh
#
-# Complex::I
+
+
#
-# Numeric::im
+# Numeric is a built-in class on which Fixnum, Bignum, etc., are based. Here
+# some methods are added so that all number types can be treated to some extent
+# as Complex numbers.
#
-# Math.sqrt
-# Math.exp
-# Math.cos
-# Math.sin
-# Math.tan
-# Math.log
-# Math.log10
-# Math.atan2
+class Numeric
+ #
+ # Returns a Complex number <tt>(0,<i>self</i>)</tt>.
+ #
+ def im
+ Complex(0, self)
+ end
+
+ #
+ # The real part of a complex number, i.e. <i>self</i>.
+ #
+ def real
+ self
+ end
+
+ #
+ # The imaginary part of a complex number, i.e. 0.
+ #
+ def image
+ 0
+ end
+ alias imag image
+
+ #
+ # See Complex#arg.
+ #
+ def arg
+ if self >= 0
+ return 0
+ else
+ return Math::PI
+ end
+ end
+ alias angle arg
+
+ #
+ # See Complex#polar.
+ #
+ def polar
+ return abs, arg
+ end
+
+ #
+ # See Complex#conjugate (short answer: returns <i>self</i>).
+ #
+ def conjugate
+ self
+ end
+ alias conj conjugate
+end
+
+
#
+# Creates a Complex number. +a+ and +b+ should be Numeric. The result will be
+# <tt>a+bi</tt>.
#
-
def Complex(a, b = 0)
- if a.kind_of?(Complex) and b == 0
- a
- elsif b.kind_of?(Complex)
- if a.kind_of?(Complex)
- Complex(a.real-b.image, a.image + b.real)
- else
- Complex(a-b.image, b.real)
- end
- elsif b == 0 and defined? Complex::Unify
+ if b == 0 and (a.kind_of?(Complex) or defined? Complex::Unify)
a
else
- Complex.new(a, b)
+ Complex.new( a.real-b.imag, a.imag+b.real )
end
end
+#
+# The complex number class. See complex.rb for an overview.
+#
class Complex < Numeric
@RCS_ID='-$Id: complex.rb,v 1.3 1998/07/08 10:05:28 keiju Exp keiju $-'
-
- def Complex.generic?(other)
+
+ undef step
+
+ def Complex.generic?(other) # :nodoc:
other.kind_of?(Integer) or
other.kind_of?(Float) or
(defined?(Rational) and other.kind_of?(Rational))
end
+ #
+ # Creates a +Complex+ number in terms of +r+ (radius) and +theta+ (angle).
+ #
def Complex.polar(r, theta)
Complex(r*Math.cos(theta), r*Math.sin(theta))
end
-
- def initialize(a, b = 0)
- raise "non numeric 1st arg `#{a.inspect}'" if !a.kind_of? Numeric
- raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric
+
+ #
+ # Creates a +Complex+ number <tt>a</tt>+<tt>b</tt><i>i</i>.
+ #
+ def Complex.new!(a, b=0)
+ new(a,b)
+ end
+
+ def initialize(a, b)
+ raise TypeError, "non numeric 1st arg `#{a.inspect}'" if !a.kind_of? Numeric
+ raise TypeError, "`#{a.inspect}' for 1st arg" if a.kind_of? Complex
+ raise TypeError, "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of? Numeric
+ raise TypeError, "`#{b.inspect}' for 2nd arg" if b.kind_of? Complex
@real = a
@image = b
end
-
+
+ #
+ # Addition with real or complex number.
+ #
def + (other)
if other.kind_of?(Complex)
re = @real + other.real
@@ -97,6 +148,9 @@ class Complex < Numeric
end
end
+ #
+ # Subtraction with real or complex number.
+ #
def - (other)
if other.kind_of?(Complex)
re = @real - other.real
@@ -110,6 +164,9 @@ class Complex < Numeric
end
end
+ #
+ # Multiplication with real or complex number.
+ #
def * (other)
if other.kind_of?(Complex)
re = @real*other.real - @image*other.image
@@ -123,6 +180,9 @@ class Complex < Numeric
end
end
+ #
+ # Division by real or complex number.
+ #
def / (other)
if other.kind_of?(Complex)
self*other.conjugate/other.abs2
@@ -134,6 +194,9 @@ class Complex < Numeric
end
end
+ #
+ # Raise this complex number to the given (real or complex) power.
+ #
def ** (other)
if other == 0
return Complex(1)
@@ -169,13 +232,16 @@ class Complex < Numeric
end
elsif Complex.generic?(other)
r, theta = polar
- Complex.polar(r.power!(other), theta * other)
+ Complex.polar(r**other, theta*other)
else
x, y = other.coerce(self)
- x/y
+ x**y
end
end
+ #
+ # Remainder after division by a real or complex number.
+ #
def % (other)
if other.kind_of?(Complex)
Complex(@real % other.real, @image % other.image)
@@ -187,6 +253,7 @@ class Complex < Numeric
end
end
+#--
# def divmod(other)
# if other.kind_of?(Complex)
# rdiv, rmod = @real.divmod(other.real)
@@ -199,72 +266,96 @@ class Complex < Numeric
# x.divmod(y)
# end
# end
+#++
+ #
+ # Absolute value (aka modulus): distance from the zero point on the complex
+ # plane.
+ #
def abs
- Math.sqrt!((@real*@real + @image*@image).to_f)
+ Math.hypot(@real, @image)
end
+ #
+ # Square of the absolute value.
+ #
def abs2
@real*@real + @image*@image
end
+ #
+ # Argument (angle from (1,0) on the complex plane).
+ #
def arg
- Math.atan2(@image.to_f, @real.to_f)
+ Math.atan2!(@image, @real)
end
+ alias angle arg
+ #
+ # Returns the absolute value _and_ the argument.
+ #
def polar
return abs, arg
end
+ #
+ # Complex conjugate (<tt>z + z.conjugate = 2 * z.real</tt>).
+ #
def conjugate
Complex(@real, -@image)
end
+ alias conj conjugate
+ #
+ # Compares the absolute values of the two numbers.
+ #
def <=> (other)
self.abs <=> other.abs
end
+ #
+ # Test for numerical equality (<tt>a == a + 0<i>i</i></tt>).
+ #
def == (other)
if other.kind_of?(Complex)
@real == other.real and @image == other.image
elsif Complex.generic?(other)
@real == other and @image == 0
else
- x , y = other.coerce(self)
- x == y
+ other == self
end
end
+ #
+ # Attempts to coerce +other+ to a Complex number.
+ #
def coerce(other)
if Complex.generic?(other)
- return Complex.new(other), self
+ return Complex.new!(other), self
else
super
end
end
- def to_i
- Complex(@real.to_i, @image.to_i)
- end
-
- def to_f
- Complex(@real.to_f, @image.to_f)
- end
-
- def to_r
- Complex(@real.to_r, @image.to_r)
- end
-
+ #
+ # FIXME
+ #
def denominator
@real.denominator.lcm(@image.denominator)
end
+ #
+ # FIXME
+ #
def numerator
cd = denominator
Complex(@real.numerator*(cd/@real.denominator),
@image.numerator*(cd/@image.denominator))
end
+ #
+ # Standard string representation of the complex number.
+ #
def to_s
if @real != 0
if defined?(Rational) and @image.kind_of?(Rational) and @image.denominator != 1
@@ -289,94 +380,58 @@ class Complex < Numeric
end
end
+ #
+ # Returns a hash code for the complex number.
+ #
def hash
- @real ^ @image
+ @real.hash ^ @image.hash
end
+ #
+ # Returns "<tt>Complex(<i>real</i>, <i>image</i>)</tt>".
+ #
def inspect
sprintf("Complex(%s, %s)", @real.inspect, @image.inspect)
end
+ #
+ # +I+ is the imaginary number. It exists at point (0,1) on the complex plane.
+ #
I = Complex(0,1)
+ # The real part of a complex number.
attr :real
+
+ # The imaginary part of a complex number.
attr :image
+ alias imag image
end
-class Numeric
- def im
- Complex(0, self)
- end
-
- def real
- self
- end
-
- def image
- 0
- end
-
- def arg
- if self >= 0
- return 0
- else
- return Math.atan2(1,1)*4
- end
- end
-
- def polar
- return abs, arg
- end
-
- def conjugate
- self
- end
-end
-class Fixnum
- if not defined? Rational
- alias power! **
- end
-
- def ** (other)
- if self < 0
- Complex.new(self) ** other
- else
- if defined? Rational
- if other >= 0
- self.power!(other)
- else
- Rational.new!(self,1)**other
- end
- else
- self.power!(other)
- end
- end
- end
-end
-class Bignum
- if not defined? Rational
- alias power! **
- end
-end
-
-class Float
- alias power! **
-end
module Math
alias sqrt! sqrt
alias exp! exp
+ alias log! log
+ alias log10! log10
alias cos! cos
alias sin! sin
alias tan! tan
- alias log! log
- alias log10! log10
+ alias cosh! cosh
+ alias sinh! sinh
+ alias tanh! tanh
+ alias acos! acos
+ alias asin! asin
+ alias atan! atan
alias atan2! atan2
-
+ alias acosh! acosh
+ alias asinh! asinh
+ alias atanh! atanh
+
+ # Redefined to handle a Complex argument.
def sqrt(z)
if Complex.generic?(z)
if z >= 0
@@ -385,10 +440,17 @@ module Math
Complex(0,sqrt!(-z))
end
else
- z**Rational(1,2)
+ if z.image < 0
+ sqrt(z.conjugate).conjugate
+ else
+ r = z.abs
+ x = z.real
+ Complex( sqrt!((r+x)/2), sqrt!((r-x)/2) )
+ end
end
end
+ # Redefined to handle a Complex argument.
def exp(z)
if Complex.generic?(z)
exp!(z)
@@ -397,14 +459,7 @@ module Math
end
end
- def cosh!(x)
- (exp!(x) + exp!(-x))/2.0
- end
-
- def sinh!(x)
- (exp!(x) - exp!(-x))/2.0
- end
-
+ # Redefined to handle a Complex argument.
def cos(z)
if Complex.generic?(z)
cos!(z)
@@ -414,6 +469,7 @@ module Math
end
end
+ # Redefined to handle a Complex argument.
def sin(z)
if Complex.generic?(z)
sin!(z)
@@ -423,6 +479,7 @@ module Math
end
end
+ # Redefined to handle a Complex argument.
def tan(z)
if Complex.generic?(z)
tan!(z)
@@ -430,7 +487,32 @@ module Math
sin(z)/cos(z)
end
end
+
+ def sinh(z)
+ if Complex.generic?(z)
+ sinh!(z)
+ else
+ Complex( sinh!(z.real)*cos!(z.image), cosh!(z.real)*sin!(z.image) )
+ end
+ end
+
+ def cosh(z)
+ if Complex.generic?(z)
+ cosh!(z)
+ else
+ Complex( cosh!(z.real)*cos!(z.image), sinh!(z.real)*sin!(z.image) )
+ end
+ end
+
+ def tanh(z)
+ if Complex.generic?(z)
+ tanh!(z)
+ else
+ sinh(z)/cosh(z)
+ end
+ end
+ # Redefined to handle a Complex argument.
def log(z)
if Complex.generic?(z) and z >= 0
log!(z)
@@ -440,6 +522,7 @@ module Math
end
end
+ # Redefined to handle a Complex argument.
def log10(z)
if Complex.generic?(z)
log10!(z)
@@ -447,56 +530,102 @@ module Math
log(z)/log!(10)
end
end
-
- def atan2(x, y)
- if Complex.generic?(x) and Complex.generic?(y)
- atan2!(x, y)
+
+ def acos(z)
+ if Complex.generic?(z) and z >= -1 and z <= 1
+ acos!(z)
else
- fail "Not yet implemented."
+ -1.0.im * log( z + 1.0.im * sqrt(1.0-z*z) )
end
end
-
- def atanh!(x)
- log((1.0 + x.to_f) / ( 1.0 - x.to_f)) / 2.0
+
+ def asin(z)
+ if Complex.generic?(z) and z >= -1 and z <= 1
+ asin!(z)
+ else
+ -1.0.im * log( 1.0.im * z + sqrt(1.0-z*z) )
+ end
end
-
+
def atan(z)
if Complex.generic?(z)
- atan2!(z, 1)
- elsif z.image == 0
- atan2(z.real,1)
+ atan!(z)
else
- a = z.real
- b = z.image
-
- c = (a*a + b*b - 1.0)
- d = (a*a + b*b + 1.0)
-
- Complex(atan2!((c + sqrt(c*c + 4.0*a*a)), 2.0*a),
- atanh!((-d + sqrt(d*d - 4.0*b*b))/(2.0*b)))
+ 1.0.im * log( (1.0.im+z) / (1.0.im-z) ) / 2.0
end
end
-
- module_function :sqrt
+
+ def atan2(y,x)
+ if Complex.generic?(y) and Complex.generic?(x)
+ atan2!(y,x)
+ else
+ -1.0.im * log( (x+1.0.im*y) / sqrt(x*x+y*y) )
+ end
+ end
+
+ def acosh(z)
+ if Complex.generic?(z) and z >= 1
+ acosh!(z)
+ else
+ log( z + sqrt(z*z-1.0) )
+ end
+ end
+
+ def asinh(z)
+ if Complex.generic?(z)
+ asinh!(z)
+ else
+ log( z + sqrt(1.0+z*z) )
+ end
+ end
+
+ def atanh(z)
+ if Complex.generic?(z) and z >= -1 and z <= 1
+ atanh!(z)
+ else
+ log( (1.0+z) / (1.0-z) ) / 2.0
+ end
+ end
+
module_function :sqrt!
+ module_function :sqrt
module_function :exp!
module_function :exp
+ module_function :log!
+ module_function :log
+ module_function :log10!
+ module_function :log10
module_function :cosh!
+ module_function :cosh
module_function :cos!
module_function :cos
module_function :sinh!
+ module_function :sinh
module_function :sin!
module_function :sin
module_function :tan!
module_function :tan
- module_function :log!
- module_function :log
- module_function :log10!
- module_function :log
+ module_function :tanh!
+ module_function :tanh
+ module_function :acos!
+ module_function :acos
+ module_function :asin!
+ module_function :asin
+ module_function :atan!
+ module_function :atan
module_function :atan2!
module_function :atan2
-# module_function :atan!
- module_function :atan
+ module_function :acosh!
+ module_function :acosh
+ module_function :asinh!
+ module_function :asinh
module_function :atanh!
+ module_function :atanh
end
+
+# Documentation comments:
+# - source: original (researched from pickaxe)
+# - a couple of fixme's
+# - RDoc output for Bignum etc. is a bit short, with nothing but an
+# (undocumented) alias. No big deal.
diff --git a/lib/csv.rb b/lib/csv.rb
new file mode 100644
index 0000000000..f6c12fa285
--- /dev/null
+++ b/lib/csv.rb
@@ -0,0 +1,992 @@
+# CSV -- module for generating/parsing CSV data.
+# Copyright (C) 2000-2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
+
+# $Id$
+
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
+
+
+class CSV
+ class IllegalFormatError < RuntimeError; end
+
+ # deprecated
+ class Cell < String
+ def initialize(data = "", is_null = false)
+ super(is_null ? "" : data)
+ end
+
+ def data
+ to_s
+ end
+ end
+
+ # deprecated
+ class Row < Array
+ end
+
+ # Open a CSV formatted file for reading or writing.
+ #
+ # For reading.
+ #
+ # EXAMPLE 1
+ # CSV.open('csvfile.csv', 'r') do |row|
+ # p row
+ # end
+ #
+ # EXAMPLE 2
+ # reader = CSV.open('csvfile.csv', 'r')
+ # row1 = reader.shift
+ # row2 = reader.shift
+ # if row2.empty?
+ # p 'row2 not find.'
+ # end
+ # reader.close
+ #
+ # ARGS
+ # filename: filename to parse.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # reader instance. To get parse result, see CSV::Reader#each.
+ #
+ #
+ # For writing.
+ #
+ # EXAMPLE 1
+ # CSV.open('csvfile.csv', 'w') do |writer|
+ # writer << ['r1c1', 'r1c2']
+ # writer << ['r2c1', 'r2c2']
+ # writer << [nil, nil]
+ # end
+ #
+ # EXAMPLE 2
+ # writer = CSV.open('csvfile.csv', 'w')
+ # writer << ['r1c1', 'r1c2'] << ['r2c1', 'r2c2'] << [nil, nil]
+ # writer.close
+ #
+ # ARGS
+ # filename: filename to generate.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # writer instance. See CSV::Writer#<< and CSV::Writer#add_row to know how
+ # to generate CSV string.
+ #
+ def CSV.open(path, mode, fs = nil, rs = nil, &block)
+ if mode == 'r' or mode == 'rb'
+ open_reader(path, mode, fs, rs, &block)
+ elsif mode == 'w' or mode == 'wb'
+ open_writer(path, mode, fs, rs, &block)
+ else
+ raise ArgumentError.new("'mode' must be 'r', 'rb', 'w', or 'wb'")
+ end
+ end
+
+ def CSV.foreach(path, rs = nil, &block)
+ open_reader(path, 'r', ',', rs, &block)
+ end
+
+ def CSV.read(path, length = nil, offset = nil)
+ CSV.parse(IO.read(path, length, offset))
+ end
+
+ def CSV.readlines(path, rs = nil)
+ reader = open_reader(path, 'r', ',', rs)
+ begin
+ reader.collect { |row| row }
+ ensure
+ reader.close
+ end
+ end
+
+ def CSV.generate(path, fs = nil, rs = nil, &block)
+ open_writer(path, 'w', fs, rs, &block)
+ end
+
+ # Parse lines from given string or stream. Return rows as an Array of Arrays.
+ def CSV.parse(str_or_readable, fs = nil, rs = nil, &block)
+ if File.exist?(str_or_readable)
+ STDERR.puts("CSV.parse(filename) is deprecated." +
+ " Use CSV.open(filename, 'r') instead.")
+ return open_reader(str_or_readable, 'r', fs, rs, &block)
+ end
+ if block
+ CSV::Reader.parse(str_or_readable, fs, rs) do |row|
+ yield(row)
+ end
+ nil
+ else
+ CSV::Reader.create(str_or_readable, fs, rs).collect { |row| row }
+ end
+ end
+
+ # Parse a line from given string. Bear in mind it parses ONE LINE. Rest of
+ # the string is ignored for example "a,b\r\nc,d" => ['a', 'b'] and the
+ # second line 'c,d' is ignored.
+ #
+ # If you don't know whether a target string to parse is exactly 1 line or
+ # not, use CSV.parse_row instead of this method.
+ def CSV.parse_line(src, fs = nil, rs = nil)
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
+ end
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
+ end
+ idx = 0
+ res_type = :DT_COLSEP
+ row = []
+ begin
+ while res_type == :DT_COLSEP
+ res_type, idx, cell = parse_body(src, idx, fs, rs)
+ row << cell
+ end
+ rescue IllegalFormatError
+ return []
+ end
+ row
+ end
+
+ # Create a line from cells. each cell is stringified by to_s.
+ def CSV.generate_line(row, fs = nil, rs = nil)
+ if row.size == 0
+ return ''
+ end
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
+ end
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
+ end
+ res_type = :DT_COLSEP
+ result_str = ''
+ idx = 0
+ while true
+ generate_body(row[idx], result_str, fs, rs)
+ idx += 1
+ if (idx == row.size)
+ break
+ end
+ generate_separator(:DT_COLSEP, result_str, fs, rs)
+ end
+ result_str
+ end
+
+ # Parse a line from string. Consider using CSV.parse_line instead.
+ # To parse lines in CSV string, see EXAMPLE below.
+ #
+ # EXAMPLE
+ # src = "a,b\r\nc,d\r\ne,f"
+ # idx = 0
+ # begin
+ # parsed = []
+ # parsed_cells, idx = CSV.parse_row(src, idx, parsed)
+ # puts "Parsed #{ parsed_cells } cells."
+ # p parsed
+ # end while parsed_cells > 0
+ #
+ # ARGS
+ # src: a CSV data to be parsed. Must respond '[](idx)'.
+ # src[](idx) must return a char. (Not a string such as 'a', but 97).
+ # src[](idx_out_of_bounds) must return nil. A String satisfies this
+ # requirement.
+ # idx: index of parsing location of 'src'. 0 origin.
+ # out_dev: buffer for parsed cells. Must respond '<<(aString)'.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # parsed_cells: num of parsed cells.
+ # idx: index of next parsing location of 'src'.
+ #
+ def CSV.parse_row(src, idx, out_dev, fs = nil, rs = nil)
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
+ end
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
+ end
+ idx_backup = idx
+ parsed_cells = 0
+ res_type = :DT_COLSEP
+ begin
+ while res_type != :DT_ROWSEP
+ res_type, idx, cell = parse_body(src, idx, fs, rs)
+ if res_type == :DT_EOS
+ if idx == idx_backup #((parsed_cells == 0) and cell.nil?)
+ return 0, 0
+ end
+ res_type = :DT_ROWSEP
+ end
+ parsed_cells += 1
+ out_dev << cell
+ end
+ rescue IllegalFormatError
+ return 0, 0
+ end
+ return parsed_cells, idx
+ end
+
+ # Convert a line from cells data to string. Consider using CSV.generate_line
+ # instead. To generate multi-row CSV string, see EXAMPLE below.
+ #
+ # EXAMPLE
+ # row1 = ['a', 'b']
+ # row2 = ['c', 'd']
+ # row3 = ['e', 'f']
+ # src = [row1, row2, row3]
+ # buf = ''
+ # src.each do |row|
+ # parsed_cells = CSV.generate_row(row, 2, buf)
+ # puts "Created #{ parsed_cells } cells."
+ # end
+ # p buf
+ #
+ # ARGS
+ # src: an Array of String to be converted to CSV string. Must respond to
+ # 'size' and '[](idx)'. src[idx] must return String.
+ # cells: num of cells in a line.
+ # out_dev: buffer for generated CSV string. Must respond to '<<(string)'.
+ # col_sep: Column separator. ?, by default. If you want to separate
+ # fields with semicolon, give ?; here.
+ # row_sep: Row separator. nil by default. nil means "\r\n or \n". If you
+ # want to separate records with \r, give ?\r here.
+ #
+ # RETURNS
+ # parsed_cells: num of converted cells.
+ #
+ def CSV.generate_row(src, cells, out_dev, fs = nil, rs = nil)
+ fs ||= ','
+ if fs.is_a?(Fixnum)
+ fs = fs.chr
+ end
+ if !rs.nil? and rs.is_a?(Fixnum)
+ rs = rs.chr
+ end
+ src_size = src.size
+ if (src_size == 0)
+ if cells == 0
+ generate_separator(:DT_ROWSEP, out_dev, fs, rs)
+ end
+ return 0
+ end
+ res_type = :DT_COLSEP
+ parsed_cells = 0
+ generate_body(src[parsed_cells], out_dev, fs, rs)
+ parsed_cells += 1
+ while ((parsed_cells < cells) and (parsed_cells != src_size))
+ generate_separator(:DT_COLSEP, out_dev, fs, rs)
+ generate_body(src[parsed_cells], out_dev, fs, rs)
+ parsed_cells += 1
+ end
+ if (parsed_cells == cells)
+ generate_separator(:DT_ROWSEP, out_dev, fs, rs)
+ else
+ generate_separator(:DT_COLSEP, out_dev, fs, rs)
+ end
+ parsed_cells
+ end
+
+ # Private class methods.
+ class << self
+ private
+
+ def open_reader(path, mode, fs, rs, &block)
+ file = File.open(path, mode)
+ if block
+ begin
+ CSV::Reader.parse(file, fs, rs) do |row|
+ yield(row)
+ end
+ ensure
+ file.close
+ end
+ nil
+ else
+ reader = CSV::Reader.create(file, fs, rs)
+ reader.close_on_terminate
+ reader
+ end
+ end
+
+ def open_writer(path, mode, fs, rs, &block)
+ file = File.open(path, mode)
+ if block
+ begin
+ CSV::Writer.generate(file, fs, rs) do |writer|
+ yield(writer)
+ end
+ ensure
+ file.close
+ end
+ nil
+ else
+ writer = CSV::Writer.create(file, fs, rs)
+ writer.close_on_terminate
+ writer
+ end
+ end
+
+ def parse_body(src, idx, fs, rs)
+ fs_str = fs
+ fs_size = fs_str.size
+ rs_str = rs || "\n"
+ rs_size = rs_str.size
+ fs_idx = rs_idx = 0
+ cell = Cell.new
+ state = :ST_START
+ quoted = cr = false
+ c = nil
+ last_idx = idx
+ while c = src[idx]
+ unless quoted
+ fschar = (c == fs_str[fs_idx])
+ rschar = (c == rs_str[rs_idx])
+ # simple 1 char backtrack
+ if !fschar and c == fs_str[0]
+ fs_idx = 0
+ fschar = true
+ if state == :ST_START
+ state = :ST_DATA
+ elsif state == :ST_QUOTE
+ raise IllegalFormatError
+ end
+ end
+ if !rschar and c == rs_str[0]
+ rs_idx = 0
+ rschar = true
+ if state == :ST_START
+ state = :ST_DATA
+ elsif state == :ST_QUOTE
+ raise IllegalFormatError
+ end
+ end
+ end
+ if c == ?"
+ fs_idx = rs_idx = 0
+ if cr
+ raise IllegalFormatError
+ end
+ cell << src[last_idx, (idx - last_idx)]
+ last_idx = idx
+ if state == :ST_DATA
+ if quoted
+ last_idx += 1
+ quoted = false
+ state = :ST_QUOTE
+ else
+ raise IllegalFormatError
+ end
+ elsif state == :ST_QUOTE
+ cell << c.chr
+ last_idx += 1
+ quoted = true
+ state = :ST_DATA
+ else # :ST_START
+ quoted = true
+ last_idx += 1
+ state = :ST_DATA
+ end
+ elsif fschar or rschar
+ if fschar
+ fs_idx += 1
+ end
+ if rschar
+ rs_idx += 1
+ end
+ sep = nil
+ if fs_idx == fs_size
+ if state == :ST_START and rs_idx > 0 and fs_idx < rs_idx
+ state = :ST_DATA
+ end
+ cell << src[last_idx, (idx - last_idx - (fs_size - 1))]
+ last_idx = idx
+ fs_idx = rs_idx = 0
+ if cr
+ raise IllegalFormatError
+ end
+ sep = :DT_COLSEP
+ elsif rs_idx == rs_size
+ if state == :ST_START and fs_idx > 0 and rs_idx < fs_idx
+ state = :ST_DATA
+ end
+ if !(rs.nil? and cr)
+ cell << src[last_idx, (idx - last_idx - (rs_size - 1))]
+ last_idx = idx
+ end
+ fs_idx = rs_idx = 0
+ sep = :DT_ROWSEP
+ end
+ if sep
+ if state == :ST_DATA
+ return sep, idx + 1, cell;
+ elsif state == :ST_QUOTE
+ return sep, idx + 1, cell;
+ else # :ST_START
+ return sep, idx + 1, nil
+ end
+ end
+ elsif rs.nil? and c == ?\r
+ # special \r treatment for backward compatibility
+ fs_idx = rs_idx = 0
+ if cr
+ raise IllegalFormatError
+ end
+ cell << src[last_idx, (idx - last_idx)]
+ last_idx = idx
+ if quoted
+ state = :ST_DATA
+ else
+ cr = true
+ end
+ else
+ fs_idx = rs_idx = 0
+ if state == :ST_DATA or state == :ST_START
+ if cr
+ raise IllegalFormatError
+ end
+ state = :ST_DATA
+ else # :ST_QUOTE
+ raise IllegalFormatError
+ end
+ end
+ idx += 1
+ end
+ if state == :ST_START
+ if fs_idx > 0 or rs_idx > 0
+ state = :ST_DATA
+ else
+ return :DT_EOS, idx, nil
+ end
+ elsif quoted
+ raise IllegalFormatError
+ elsif cr
+ raise IllegalFormatError
+ end
+ cell << src[last_idx, (idx - last_idx)]
+ last_idx = idx
+ return :DT_EOS, idx, cell
+ end
+
+ def generate_body(cell, out_dev, fs, rs)
+ if cell.nil?
+ # empty
+ else
+ cell = cell.to_s
+ row_data = cell.dup
+ if (row_data.gsub!('"', '""') or
+ row_data.index(fs) or
+ (rs and row_data.index(rs)) or
+ (/[\r\n]/ =~ row_data) or
+ (cell.empty?))
+ out_dev << '"' << row_data << '"'
+ else
+ out_dev << row_data
+ end
+ end
+ end
+
+ def generate_separator(type, out_dev, fs, rs)
+ case type
+ when :DT_COLSEP
+ out_dev << fs
+ when :DT_ROWSEP
+ out_dev << (rs || "\n")
+ end
+ end
+ end
+
+
+ # CSV formatted string/stream reader.
+ #
+ # EXAMPLE
+ # read CSV lines untill the first column is 'stop'.
+ #
+ # CSV::Reader.parse(File.open('bigdata', 'rb')) do |row|
+ # p row
+ # break if !row[0].is_null && row[0].data == 'stop'
+ # end
+ #
+ class Reader
+ include Enumerable
+
+ # Parse CSV data and get lines. Given block is called for each parsed row.
+ # Block value is always nil. Rows are not cached for performance reason.
+ def Reader.parse(str_or_readable, fs = ',', rs = nil, &block)
+ reader = Reader.create(str_or_readable, fs, rs)
+ if block
+ reader.each do |row|
+ yield(row)
+ end
+ reader.close
+ nil
+ else
+ reader
+ end
+ end
+
+ # Returns reader instance.
+ def Reader.create(str_or_readable, fs = ',', rs = nil)
+ case str_or_readable
+ when IO
+ IOReader.new(str_or_readable, fs, rs)
+ when String
+ StringReader.new(str_or_readable, fs, rs)
+ else
+ IOReader.new(str_or_readable, fs, rs)
+ end
+ end
+
+ def each
+ while true
+ row = []
+ parsed_cells = get_row(row)
+ if parsed_cells == 0
+ break
+ end
+ yield(row)
+ end
+ nil
+ end
+
+ def shift
+ row = []
+ parsed_cells = get_row(row)
+ row
+ end
+
+ def close
+ terminate
+ end
+
+ private
+
+ def initialize(dev)
+ raise RuntimeError.new('Do not instanciate this class directly.')
+ end
+
+ def get_row(row)
+ raise NotImplementedError.new('Method get_row must be defined in a derived class.')
+ end
+
+ def terminate
+ # Define if needed.
+ end
+ end
+
+
+ class StringReader < Reader
+ def initialize(string, fs = ',', rs = nil)
+ @fs = fs
+ @rs = rs
+ @dev = string
+ @idx = 0
+ if @dev[0, 3] == "\xef\xbb\xbf"
+ @idx += 3
+ end
+ end
+
+ private
+
+ def get_row(row)
+ parsed_cells, next_idx = CSV.parse_row(@dev, @idx, row, @fs, @rs)
+ if parsed_cells == 0 and next_idx == 0 and @idx != @dev.size
+ raise IllegalFormatError.new
+ end
+ @idx = next_idx
+ parsed_cells
+ end
+ end
+
+
+ class IOReader < Reader
+ def initialize(io, fs = ',', rs = nil)
+ @io = io
+ @fs = fs
+ @rs = rs
+ @dev = CSV::IOBuf.new(@io)
+ @idx = 0
+ if @dev[0] == 0xef and @dev[1] == 0xbb and @dev[2] == 0xbf
+ @idx += 3
+ end
+ @close_on_terminate = false
+ end
+
+ # Tell this reader to close the IO when terminated (Triggered by invoking
+ # CSV::IOReader#close).
+ def close_on_terminate
+ @close_on_terminate = true
+ end
+
+ private
+
+ def get_row(row)
+ parsed_cells, next_idx = CSV.parse_row(@dev, @idx, row, @fs, @rs)
+ if parsed_cells == 0 and next_idx == 0 and !@dev.is_eos?
+ raise IllegalFormatError.new
+ end
+ dropped = @dev.drop(next_idx)
+ @idx = next_idx - dropped
+ parsed_cells
+ end
+
+ def terminate
+ if @close_on_terminate
+ @io.close
+ end
+
+ if @dev
+ @dev.close
+ end
+ end
+ end
+
+
+ # CSV formatted string/stream writer.
+ #
+ # EXAMPLE
+ # Write rows to 'csvout' file.
+ #
+ # outfile = File.open('csvout', 'wb')
+ # CSV::Writer.generate(outfile) do |csv|
+ # csv << ['c1', nil, '', '"', "\r\n", 'c2']
+ # ...
+ # end
+ #
+ # outfile.close
+ #
+ class Writer
+ # Given block is called with the writer instance. str_or_writable must
+ # handle '<<(string)'.
+ def Writer.generate(str_or_writable, fs = ',', rs = nil, &block)
+ writer = Writer.create(str_or_writable, fs, rs)
+ if block
+ yield(writer)
+ writer.close
+ nil
+ else
+ writer
+ end
+ end
+
+ # str_or_writable must handle '<<(string)'.
+ def Writer.create(str_or_writable, fs = ',', rs = nil)
+ BasicWriter.new(str_or_writable, fs, rs)
+ end
+
+ # dump CSV stream to the device. argument must be an Array of String.
+ def <<(row)
+ CSV.generate_row(row, row.size, @dev, @fs, @rs)
+ self
+ end
+ alias add_row <<
+
+ def close
+ terminate
+ end
+
+ private
+
+ def initialize(dev)
+ raise RuntimeError.new('Do not instanciate this class directly.')
+ end
+
+ def terminate
+ # Define if needed.
+ end
+ end
+
+
+ class BasicWriter < Writer
+ def initialize(str_or_writable, fs = ',', rs = nil)
+ @fs = fs
+ @rs = rs
+ @dev = str_or_writable
+ @close_on_terminate = false
+ end
+
+ # Tell this writer to close the IO when terminated (Triggered by invoking
+ # CSV::BasicWriter#close).
+ def close_on_terminate
+ @close_on_terminate = true
+ end
+
+ private
+
+ def terminate
+ if @close_on_terminate
+ @dev.close
+ end
+ end
+ end
+
+private
+
+ # Buffered stream.
+ #
+ # EXAMPLE 1 -- an IO.
+ # class MyBuf < StreamBuf
+ # # Do initialize myself before a super class. Super class might call my
+ # # method 'read'. (Could be awful for C++ user. :-)
+ # def initialize(s)
+ # @s = s
+ # super()
+ # end
+ #
+ # # define my own 'read' method.
+ # # CAUTION: Returning nil means EnfOfStream.
+ # def read(size)
+ # @s.read(size)
+ # end
+ #
+ # # release buffers. in Ruby which has GC, you do not have to call this...
+ # def terminate
+ # @s = nil
+ # super()
+ # end
+ # end
+ #
+ # buf = MyBuf.new(STDIN)
+ # my_str = ''
+ # p buf[0, 0] # => '' (null string)
+ # p buf[0] # => 97 (char code of 'a')
+ # p buf[0, 1] # => 'a'
+ # my_str = buf[0, 5]
+ # p my_str # => 'abcde' (5 chars)
+ # p buf[0, 6] # => "abcde\n" (6 chars)
+ # p buf[0, 7] # => "abcde\n" (6 chars)
+ # p buf.drop(3) # => 3 (dropped chars)
+ # p buf.get(0, 2) # => 'de' (2 chars)
+ # p buf.is_eos? # => false (is not EOS here)
+ # p buf.drop(5) # => 3 (dropped chars)
+ # p buf.is_eos? # => true (is EOS here)
+ # p buf[0] # => nil (is EOS here)
+ #
+ # EXAMPLE 2 -- String.
+ # This is a conceptual example. No pros with this.
+ #
+ # class StrBuf < StreamBuf
+ # def initialize(s)
+ # @str = s
+ # @idx = 0
+ # super()
+ # end
+ #
+ # def read(size)
+ # str = @str[@idx, size]
+ # @idx += str.size
+ # str
+ # end
+ # end
+ #
+ class StreamBuf
+ # get a char or a partial string from the stream.
+ # idx: index of a string to specify a start point of a string to get.
+ # unlike String instance, idx < 0 returns nil.
+ # n: size of a string to get.
+ # returns char at idx if n == nil.
+ # returns a partial string, from idx to (idx + n) if n != nil. at EOF,
+ # the string size could not equal to arg n.
+ def [](idx, n = nil)
+ if idx < 0
+ return nil
+ end
+ if (idx_is_eos?(idx))
+ if n and (@offset + idx == buf_size(@cur_buf))
+ # Like a String, 'abc'[4, 1] returns nil and
+ # 'abc'[3, 1] returns '' not nil.
+ return ''
+ else
+ return nil
+ end
+ end
+ my_buf = @cur_buf
+ my_offset = @offset
+ next_idx = idx
+ while (my_offset + next_idx >= buf_size(my_buf))
+ if (my_buf == @buf_tail_idx)
+ unless add_buf
+ break
+ end
+ end
+ next_idx = my_offset + next_idx - buf_size(my_buf)
+ my_buf += 1
+ my_offset = 0
+ end
+ loc = my_offset + next_idx
+ if !n
+ return @buf_list[my_buf][loc] # Fixnum of char code.
+ elsif (loc + n - 1 < buf_size(my_buf))
+ return @buf_list[my_buf][loc, n] # String.
+ else # should do loop insted of (tail) recursive call...
+ res = @buf_list[my_buf][loc, BufSize]
+ size_added = buf_size(my_buf) - loc
+ if size_added > 0
+ idx += size_added
+ n -= size_added
+ ret = self[idx, n]
+ if ret
+ res << ret
+ end
+ end
+ return res
+ end
+ end
+ alias get []
+
+ # drop a string from the stream.
+ # returns dropped size. at EOF, dropped size might not equals to arg n.
+ # Once you drop the head of the stream, access to the dropped part via []
+ # or get returns nil.
+ def drop(n)
+ if is_eos?
+ return 0
+ end
+ size_dropped = 0
+ while (n > 0)
+ if !@is_eos or (@cur_buf != @buf_tail_idx)
+ if (@offset + n < buf_size(@cur_buf))
+ size_dropped += n
+ @offset += n
+ n = 0
+ else
+ size = buf_size(@cur_buf) - @offset
+ size_dropped += size
+ n -= size
+ @offset = 0
+ unless rel_buf
+ unless add_buf
+ break
+ end
+ @cur_buf = @buf_tail_idx
+ end
+ end
+ end
+ end
+ size_dropped
+ end
+
+ def is_eos?
+ return idx_is_eos?(0)
+ end
+
+ # WARN: Do not instantiate this class directly. Define your own class
+ # which derives this class and define 'read' instance method.
+ def initialize
+ @buf_list = []
+ @cur_buf = @buf_tail_idx = -1
+ @offset = 0
+ @is_eos = false
+ add_buf
+ @cur_buf = @buf_tail_idx
+ end
+
+ protected
+
+ def terminate
+ while (rel_buf); end
+ end
+
+ # protected method 'read' must be defined in derived classes.
+ # CAUTION: Returning a string which size is not equal to 'size' means
+ # EnfOfStream. When it is not at EOS, you must block the callee, try to
+ # read and return the sized string.
+ def read(size) # raise EOFError
+ raise NotImplementedError.new('Method read must be defined in a derived class.')
+ end
+
+ private
+
+ def buf_size(idx)
+ @buf_list[idx].size
+ end
+
+ def add_buf
+ if @is_eos
+ return false
+ end
+ begin
+ str_read = read(BufSize)
+ rescue EOFError
+ str_read = nil
+ rescue
+ terminate
+ raise
+ end
+ if str_read.nil?
+ @is_eos = true
+ @buf_list.push('')
+ @buf_tail_idx += 1
+ false
+ else
+ @buf_list.push(str_read)
+ @buf_tail_idx += 1
+ true
+ end
+ end
+
+ def rel_buf
+ if (@cur_buf < 0)
+ return false
+ end
+ @buf_list[@cur_buf] = nil
+ if (@cur_buf == @buf_tail_idx)
+ @cur_buf = -1
+ return false
+ else
+ @cur_buf += 1
+ return true
+ end
+ end
+
+ def idx_is_eos?(idx)
+ (@is_eos and ((@cur_buf < 0) or (@cur_buf == @buf_tail_idx)))
+ end
+
+ BufSize = 1024 * 8
+ end
+
+ # Buffered IO.
+ #
+ # EXAMPLE
+ # # File 'bigdata' could be a giga-byte size one!
+ # buf = CSV::IOBuf.new(File.open('bigdata', 'rb'))
+ # CSV::Reader.new(buf).each do |row|
+ # p row
+ # break if row[0].data == 'admin'
+ # end
+ #
+ class IOBuf < StreamBuf
+ def initialize(s)
+ @s = s
+ super()
+ end
+
+ def close
+ terminate
+ end
+
+ private
+
+ def read(size)
+ @s.read(size)
+ end
+
+ def terminate
+ super()
+ end
+ end
+end
diff --git a/lib/date.rb b/lib/date.rb
index 3422121298..79a2df1135 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1,208 +1,723 @@
-# date2.rb: Written by Tadayoshi Funaba 1998-2001
-# $Id: date2.rb,v 1.23 2001-01-18 12:09:47+09 tadf Exp $
-
+#
+# date.rb - date and time library
+#
+# Author: Tadayoshi Funaba 1998-2004
+#
+# Documentation: William Webber <william@williamwebber.com>
+#
+#--
+# $Id: date.rb,v 2.12 2004-03-20 08:05:13+09 tadf Exp $
+#++
+#
+# == Overview
+#
+# This file provides two classes for working with
+# dates and times.
+#
+# The first class, Date, represents dates.
+# It works with years, months, weeks, and days.
+# See the Date class documentation for more details.
+#
+# The second, DateTime, extends Date to include hours,
+# minutes, seconds, and fractions of a second. It
+# provides basic support for time zones. See the
+# DateTime class documentation for more details.
+#
+# === Ways of calculating the date.
+#
+# In common usage, the date is reckoned in years since or
+# before the Common Era (CE/BCE, also known as AD/BC), then
+# as a month and day-of-the-month within the current year.
+# This is known as the *Civil* *Date*, and abbreviated
+# as +civil+ in the Date class.
+#
+# Instead of year, month-of-the-year, and day-of-the-month,
+# the date can also be reckoned in terms of year and
+# day-of-the-year. This is known as the *Ordinal* *Date*,
+# and is abbreviated as +ordinal+ in the Date class. (Note
+# that referring to this as the Julian date is incorrect.)
+#
+# The date can also be reckoned in terms of year, week-of-the-year,
+# and day-of-the-week. This is known as the *Commercial*
+# *Date*, and is abbreviated as +commercial+ in the
+# Date class. The commercial week runs Monday (day-of-the-week
+# 1) to Sunday (day-of-the-week 7), in contrast to the civil
+# week which runs Sunday (day-of-the-week 0) to Saturday
+# (day-of-the-week 6). The first week of the commercial year
+# starts on the Monday on or before January 1, and the commercial
+# year itself starts on this Monday, not January 1.
+#
+# For scientific purposes, it is convenient to refer to a date
+# simply as a day count, counting from an arbitrary initial
+# day. The date first chosen for this was January 1, 4713 BCE.
+# A count of days from this date is the *Julian* *Day* *Number*
+# or *Julian* *Date*, which is abbreviated as +jd+ in the
+# Date class. This is in local time, and counts from midnight
+# on the initial day. The stricter usage is in UTC, and counts
+# from midday on the initial day. This is referred to in the
+# Date class as the *Astronomical* *Julian* *Day* *Number*, and
+# abbreviated as +ajd+. In the Date class, the Astronomical
+# Julian Day Number includes fractional days.
+#
+# Another absolute day count is the *Modified* *Julian* *Day*
+# *Number*, which takes November 17, 1858 as its initial day.
+# This is abbreviated as +mjd+ in the Date class. There
+# is also an *Astronomical* *Modified* *Julian* *Day* *Number*,
+# which is in UTC and includes fractional days. This is
+# abbreviated as +amjd+ in the Date class. Like the Modified
+# Julian Day Number (and unlike the Astronomical Julian
+# Day Number), it counts from midnight.
+#
+# Alternative calendars such as the Chinese Lunar Calendar,
+# the Islamic Calendar, or the French Revolutionary Calendar
+# are not supported by the Date class; nor are calendars that
+# are based on an Era different from the Common Era, such as
+# the Japanese Imperial Calendar or the Republic of China
+# Calendar.
+#
+# === Calendar Reform
+#
+# The standard civil year is 365 days long. However, the
+# solar year is fractionally longer than this. To account
+# for this, a *leap* *year* is occasionally inserted. This
+# is a year with 366 days, the extra day falling on February 29.
+# In the early days of the civil calendar, every fourth
+# year without exception was a leap year. This way of
+# reckoning leap years is the *Julian* *Calendar*.
+#
+# However, the solar year is marginally shorter than 365 1/4
+# days, and so the *Julian* *Calendar* gradually ran slow
+# over the centuries. To correct this, every 100th year
+# (but not every 400th year) was excluded as a leap year.
+# This way of reckoning leap years, which we use today, is
+# the *Gregorian* *Calendar*.
+#
+# The Gregorian Calendar was introduced at different times
+# in different regions. The day on which it was introduced
+# for a particular region is the *Day* *of* *Calendar*
+# *Reform* for that region. This is abbreviated as +sg+
+# (for Start of Gregorian calendar) in the Date class.
+#
+# Two such days are of particular
+# significance. The first is October 15, 1582, which was
+# the Day of Calendar Reform for Italy and most Catholic
+# countries. The second is September 14, 1752, which was
+# the Day of Calendar Reform for England and its colonies
+# (including what is now the United States). These two
+# dates are available as the constants Date::ITALY and
+# Date::ENGLAND, respectively. (By comparison, Germany and
+# Holland, less Catholic than Italy but less stubborn than
+# England, changed over in 1698; Sweden in 1753; Russia not
+# till 1918, after the Revolution; and Greece in 1923. Many
+# Orthodox churches still use the Julian Calendar. A complete
+# list of Days of Calendar Reform can be found at
+# http://www.polysyllabic.com/GregConv.html.)
+#
+# Switching from the Julian to the Gregorian calendar
+# involved skipping a number of days to make up for the
+# accumulated lag, and the later the switch was (or is)
+# done, the more days need to be skipped. So in 1582 in Italy,
+# 4th October was followed by 15th October, skipping 10 days; in 1752
+# in England, 2nd September was followed by 14th September, skipping
+# 11 days; and if I decided to switch from Julian to Gregorian
+# Calendar this midnight, I would go from 27th July 2003 (Julian)
+# today to 10th August 2003 (Gregorian) tomorrow, skipping
+# 13 days. The Date class is aware of this gap, and a supposed
+# date that would fall in the middle of it is regarded as invalid.
+#
+# The Day of Calendar Reform is relevant to all date representations
+# involving years. It is not relevant to the Julian Day Numbers,
+# except for converting between them and year-based representations.
+#
+# In the Date and DateTime classes, the Day of Calendar Reform or
+# +sg+ can be specified a number of ways. First, it can be as
+# the Julian Day Number of the Day of Calendar Reform. Second,
+# it can be using the constants Date::ITALY or Date::ENGLAND; these
+# are in fact the Julian Day Numbers of the Day of Calendar Reform
+# of the respective regions. Third, it can be as the constant
+# Date::JULIAN, which means to always use the Julian Calendar.
+# Finally, it can be as the constant Date::GREGORIAN, which means
+# to always use the Gregorian Calendar.
+#
+# Note: in the Julian Calendar, New Years Day was March 25. The
+# Date class does not follow this convention.
+#
+# === Time Zones
+#
+# DateTime objects support a simple representation
+# of time zones. Time zones are represented as an offset
+# from UTC, as a fraction of a day. This offset is the
+# how much local time is later (or earlier) than UTC.
+# UTC offset 0 is centred on England (also known as GMT).
+# As you travel east, the offset increases until you
+# reach the dateline in the middle of the Pacific Ocean;
+# as you travel west, the offset decreases. This offset
+# is abbreviated as +of+ in the Date class.
+#
+# This simple representation of time zones does not take
+# into account the common practice of Daylight Savings
+# Time or Summer Time.
+#
+# Most DateTime methods return the date and the
+# time in local time. The two exceptions are
+# #ajd() and #amjd(), which return the date and time
+# in UTC time, including fractional days.
+#
+# The Date class does not support time zone offsets, in that
+# there is no way to create a Date object with a time zone.
+# However, methods of the Date class when used by a
+# DateTime instance will use the time zone offset of this
+# instance.
+#
+# == Examples of use
+#
+# === Print out the date of every Sunday between two dates.
+#
+# def print_sundays(d1, d2)
+# d1 +=1 while (d1.wday != 0)
+# d1.step(d2, 7) do |date|
+# puts "#{Date::MONTHNAMES[date.mon]} #{date.day}"
+# end
+# end
+#
+# print_sundays(Date::civil(2003, 4, 8), Date::civil(2003, 5, 23))
+#
+# === Calculate how many seconds to go till midnight on New Year's Day.
+#
+# def secs_to_new_year(now = DateTime::now())
+# new_year = DateTime.new(now.year + 1, 1, 1)
+# dif = new_year - now
+# hours, mins, secs, ignore_fractions = Date::day_fraction_to_time(dif)
+# return hours * 60 * 60 + mins * 60 + secs
+# end
+#
+# puts secs_to_new_year()
+
+require 'rational'
+require 'date/format'
+
+# Class representing a date.
+#
+# See the documentation to the file date.rb for an overview.
+#
+# Internally, the date is represented as an Astronomical
+# Julian Day Number, +ajd+. The Day of Calendar Reform, +sg+, is
+# also stored, for conversions to other date formats. (There
+# is also an +of+ field for a time zone offset, but this
+# is only for the use of the DateTime subclass.)
+#
+# A new Date object is created using one of the object creation
+# class methods named after the corresponding date format, and the
+# arguments appropriate to that date format; for instance,
+# Date::civil() (aliased to Date::new()) with year, month,
+# and day-of-month, or Date::ordinal() with year and day-of-year.
+# All of these object creation class methods also take the
+# Day of Calendar Reform as an optional argument.
+#
+# Date objects are immutable once created.
+#
+# Once a Date has been created, date values
+# can be retrieved for the different date formats supported
+# using instance methods. For instance, #mon() gives the
+# Civil month, #cwday() gives the Commercial day of the week,
+# and #yday() gives the Ordinal day of the year. Date values
+# can be retrieved in any format, regardless of what format
+# was used to create the Date instance.
+#
+# The Date class includes the Comparable module, allowing
+# date objects to be compared and sorted, ranges of dates
+# to be created, and so forth.
class Date
include Comparable
- IDENT = 2
-
+ # Full month names, in English. Months count from 1 to 12; a
+ # month's numerical representation indexed into this array
+ # gives the name of that month (hence the first element is nil).
MONTHNAMES = [nil] + %w(January February March April May June July
August September October November December)
+ # Full names of days of the week, in English. Days of the week
+ # count from 0 to 6 (except in the commercial week); a day's numerical
+ # representation indexed into this array gives the name of that day.
DAYNAMES = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
- ITALY = 2299161 # 1582-10-15
- ENGLAND = 2361222 # 1752-09-14
- JULIAN = false
- GREGORIAN = true
+ # Abbreviated month names, in English.
+ ABBR_MONTHNAMES = [nil] + %w(Jan Feb Mar Apr May Jun
+ Jul Aug Sep Oct Nov Dec)
- class << self
+ # Abbreviated day names, in English.
+ ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
- def os? (jd, sg)
- case sg
- when Numeric; jd < sg
- else; not sg
- end
- end
+ # The Julian Day Number of the Day of Calendar Reform for Italy
+ # and the Catholic countries.
+ ITALY = 2299161 # 1582-10-15
- def ns? (jd, sg) not os?(jd, sg) end
+ # The Julian Day Number of the Day of Calendar Reform for England
+ # and her Colonies.
+ ENGLAND = 2361222 # 1752-09-14
- def civil_to_jd(y, m, d, sg=GREGORIAN)
- if m <= 2
- y -= 1
- m += 12
- end
- a = (y / 100.0).floor
- b = 2 - a + (a / 4.0).floor
- jd = (365.25 * (y + 4716)).floor +
- (30.6001 * (m + 1)).floor +
- d + b - 1524
- if os?(jd, sg)
- jd -= b
- end
- jd
- end
+ # A constant used to indicate that a Date should always use the
+ # Julian calendar.
+ JULIAN = false
- def jd_to_civil(jd, sg=GREGORIAN)
- if os?(jd, sg)
- a = jd
- else
- x = ((jd - 1867216.25) / 36524.25).floor
- a = jd + 1 + x - (x / 4.0).floor
- end
- b = a + 1524
- c = ((b - 122.1) / 365.25).floor
- d = (365.25 * c).floor
- e = ((b - d) / 30.6001).floor
- dom = b - d - (30.6001 * e).floor
- if e <= 13
- m = e - 1
- y = c - 4716
- else
- m = e - 13
- y = c - 4715
- end
- return y, m, dom
- end
+ # A constant used to indicate that a Date should always use the
+ # Gregorian calendar.
+ GREGORIAN = true
- def ordinal_to_jd(y, d, sg=GREGORIAN)
- civil_to_jd(y, 1, d, sg)
+ # Does a given Julian Day Number fall inside the old-style (Julian)
+ # calendar?
+ #
+ # +jd+ is the Julian Day Number in question. +sg+ may be Date::GREGORIAN,
+ # in which case the answer is false; it may be Date::JULIAN, in which case
+ # the answer is true; or it may a number representing the Day of
+ # Calendar Reform. Date::ENGLAND and Date::ITALY are two possible such
+ # days.
+ def self.os? (jd, sg)
+ case sg
+ when Numeric; jd < sg
+ else; not sg
end
+ end
- def jd_to_ordinal(jd, sg=GREGORIAN)
- y = jd_to_civil(jd, sg)[0]
- doy = jd - civil_to_jd(y - 1, 12, 31, ns?(jd, sg))
- return y, doy
+ # Does a given Julian Day Number fall inside the new-style (Gregorian)
+ # calendar?
+ #
+ # The reverse of self.os? See the documentation for that method for
+ # more details.
+ def self.ns? (jd, sg) not os?(jd, sg) end
+
+ # Convert a Civil Date to a Julian Day Number.
+ # +y+, +m+, and +d+ are the year, month, and day of the
+ # month. +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Julian Day Number.
+ def self.civil_to_jd(y, m, d, sg=GREGORIAN)
+ if m <= 2
+ y -= 1
+ m += 12
end
-
- def jd_to_commercial(jd, sg=GREGORIAN)
- ns = ns?(jd, sg)
- a = jd_to_civil(jd - 3, ns)[0]
- y = if jd >= commercial_to_jd(a + 1, 1, 1, ns) then a + 1 else a end
- w = 1 + (jd - commercial_to_jd(y, 1, 1, ns)) / 7
- d = (jd + 1) % 7
- if d.zero? then d = 7 end
- return y, w, d
+ a = (y / 100.0).floor
+ b = 2 - a + (a / 4.0).floor
+ jd = (365.25 * (y + 4716)).floor +
+ (30.6001 * (m + 1)).floor +
+ d + b - 1524
+ if os?(jd, sg)
+ jd -= b
end
+ jd
+ end
- def commercial_to_jd(y, w, d, ns=GREGORIAN)
- jd = civil_to_jd(y, 1, 4, ns)
- (jd - (((jd - 1) + 1) % 7)) +
- 7 * (w - 1) +
- (d - 1)
+ # Convert a Julian Day Number to a Civil Date. +jd+ is
+ # the Julian Day Number. +sg+ specifies the Day of
+ # Calendar Reform.
+ #
+ # Returns the corresponding [year, month, day_of_month]
+ # as a three-element array.
+ def self.jd_to_civil(jd, sg=GREGORIAN)
+ if os?(jd, sg)
+ a = jd
+ else
+ x = ((jd - 1867216.25) / 36524.25).floor
+ a = jd + 1 + x - (x / 4.0).floor
end
-
- def clfloor(x, y=1)
- q, r = x.divmod(y)
- q = q.to_i
- return q, r
+ b = a + 1524
+ c = ((b - 122.1) / 365.25).floor
+ d = (365.25 * c).floor
+ e = ((b - d) / 30.6001).floor
+ dom = b - d - (30.6001 * e).floor
+ if e <= 13
+ m = e - 1
+ y = c - 4716
+ else
+ m = e - 13
+ y = c - 4715
end
+ return y, m, dom
+ end
- def rjd_to_jd(rjd) clfloor(rjd + 0.5) end
- def jd_to_rjd(jd, fr) jd + fr - 0.5 end
+ # Convert an Ordinal Date to a Julian Day Number.
+ #
+ # +y+ and +d+ are the year and day-of-year to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Julian Day Number.
+ def self.ordinal_to_jd(y, d, sg=GREGORIAN)
+ civil_to_jd(y, 1, d, sg)
+ end
- def mjd_to_jd(mjd) mjd + 2400000.5 end
- def jd_to_mjd(jd) jd - 2400000.5 end
- def tjd_to_jd(tjd) tjd + 2440000.5 end
- def jd_to_tjd(jd) jd - 2440000.5 end
- def tjd2_to_jd(cycle, tjd) tjd_to_jd(cycle * 10000 + tjd) end
- def jd_to_tjd2(jd) clfloor(jd_to_tjd(jd), 10000) end
- def ld_to_jd(ld) ld + 2299160 end
- def jd_to_ld(jd) jd - 2299160 end
+ # Convert a Julian Day Number to an Ordinal Date.
+ #
+ # +jd+ is the Julian Day Number to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Ordinal Date as
+ # [year, day_of_year]
+ def self.jd_to_ordinal(jd, sg=GREGORIAN)
+ y = jd_to_civil(jd, sg)[0]
+ doy = jd - civil_to_jd(y - 1, 12, 31, ns?(jd, sg))
+ return y, doy
+ end
- def jd_to_wday(jd) (jd + 1) % 7 end
+ # Convert a Julian Day Number to a Commercial Date
+ #
+ # +jd+ is the Julian Day Number to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # Returns the corresponding Commercial Date as
+ # [commercial_year, week_of_year, day_of_week]
+ def self.jd_to_commercial(jd, sg=GREGORIAN)
+ ns = ns?(jd, sg)
+ a = jd_to_civil(jd - 3, ns)[0]
+ y = if jd >= commercial_to_jd(a + 1, 1, 1, ns) then a + 1 else a end
+ w = 1 + (jd - commercial_to_jd(y, 1, 1, ns)) / 7
+ d = (jd + 1) % 7
+ if d.zero? then d = 7 end
+ return y, w, d
+ end
- def julian_leap? (y) y % 4 == 0 end
- def gregorian_leap? (y) y % 4 == 0 and y % 100 != 0 or y % 400 == 0 end
+ # Convert a Commercial Date to a Julian Day Number.
+ #
+ # +y+, +w+, and +d+ are the (commercial) year, week of the year,
+ # and day of the week of the Commercial Date to convert.
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.commercial_to_jd(y, w, d, ns=GREGORIAN)
+ jd = civil_to_jd(y, 1, 4, ns)
+ (jd - (((jd - 1) + 1) % 7)) +
+ 7 * (w - 1) +
+ (d - 1)
+ end
- alias_method :leap?, :gregorian_leap?
+ %w(self.clfloor clfloor).each do |name|
+ module_eval <<-"end;"
+ def #{name}(x, y=1)
+ q, r = x.divmod(y)
+ q = q.to_i
+ return q, r
+ end
+ end;
+ end
- alias_method :new0, :new
+ private_class_method :clfloor
+ private :clfloor
+
+
+ # Convert an Astronomical Julian Day Number to a (civil) Julian
+ # Day Number.
+ #
+ # +ajd+ is the Astronomical Julian Day Number to convert.
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ #
+ # Returns the (civil) Julian Day Number as [day_number,
+ # fraction] where +fraction+ is always 1/2.
+ def self.ajd_to_jd(ajd, of=0) clfloor(ajd + of + 1.to_r/2) end
+
+ # Convert a (civil) Julian Day Number to an Astronomical Julian
+ # Day Number.
+ #
+ # +jd+ is the Julian Day Number to convert, and +fr+ is a
+ # fractional day.
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ #
+ # Returns the Astronomical Julian Day Number as a single
+ # numeric value.
+ def self.jd_to_ajd(jd, fr, of=0) jd + fr - of - 1.to_r/2 end
+
+ # Convert a fractional day +fr+ to [hours, minutes, seconds,
+ # fraction_of_a_second]
+ def self.day_fraction_to_time(fr)
+ h, fr = clfloor(fr, 1.to_r/24)
+ min, fr = clfloor(fr, 1.to_r/1440)
+ s, fr = clfloor(fr, 1.to_r/86400)
+ return h, min, s, fr
+ end
- def new1(jd=0, sg=ITALY) new0(jd, sg) end
+ # Convert an +h+ hour, +min+ minutes, +s+ seconds period
+ # to a fractional day.
+ def self.time_to_day_fraction(h, min, s)
+ h.to_r/24 + min.to_r/1440 + s.to_r/86400
+ end
- def exist3? (y, m, d, sg=ITALY)
- if m < 0
- m += 13
- end
- if d < 0
- ny, nm = clfloor(y * 12 + m, 12)
- nm, = clfloor(nm + 1, 1)
- jd = civil_to_jd(ny, nm, d + 1, sg)
- ns = ns?(jd, sg)
- return unless [y, m] == jd_to_civil(jd, sg)[0..1]
- return unless [ny, nm, 1] == jd_to_civil(jd - d, ns)
- else
- jd = civil_to_jd(y, m, d, sg)
- return unless [y, m, d] == jd_to_civil(jd, sg)
- end
- jd
- end
+ # Convert an Astronomical Modified Julian Day Number to an
+ # Astronomical Julian Day Number.
+ def self.amjd_to_ajd(amjd) amjd + 4800001.to_r/2 end
+
+ # Convert an Astronomical Julian Day Number to an
+ # Astronomical Modified Julian Day Number.
+ def self.ajd_to_amjd(ajd) ajd - 4800001.to_r/2 end
+
+ # Convert a Modified Julian Day Number to a Julian
+ # Day Number.
+ def self.mjd_to_jd(mjd) mjd + 2400001 end
+
+ # Convert a Julian Day Number to a Modified Julian Day
+ # Number.
+ def self.jd_to_mjd(jd) jd - 2400001 end
+
+ # Convert a count of the number of days since the adoption
+ # of the Gregorian Calendar (in Italy) to a Julian Day Number.
+ def self.ld_to_jd(ld) ld + 2299160 end
+
+ # Convert a Julian Day Number to the number of days since
+ # the adoption of the Gregorian Calendar (in Italy).
+ def self.jd_to_ld(jd) jd - 2299160 end
+
+ # Convert a Julian Day Number to the day of the week.
+ #
+ # Sunday is day-of-week 0; Saturday is day-of-week 6.
+ def self.jd_to_wday(jd) (jd + 1) % 7 end
+
+ # Is a year a leap year in the Julian calendar?
+ #
+ # All years divisible by 4 are leap years in the Julian calendar.
+ def self.julian_leap? (y) y % 4 == 0 end
+
+ # Is a year a leap year in the Gregorian calendar?
+ #
+ # All years divisible by 4 are leap years in the Gregorian calendar,
+ # except for years divisible by 100 and not by 400.
+ def self.gregorian_leap? (y) y % 4 == 0 and y % 100 != 0 or y % 400 == 0 end
+
+ class << self; alias_method :leap?, :gregorian_leap? end
+ class << self; alias_method :new0, :new end
+
+ # Is +jd+ a valid Julian Day Number?
+ #
+ # If it is, returns it. In fact, any value is treated as a valid
+ # Julian Day Number.
+ def self.valid_jd? (jd, sg=ITALY) jd end
+
+ # Create a new Date object from a Julian Day Number.
+ #
+ # +jd+ is the Julian Day Number; if not specified, it defaults to
+ # 0.
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.jd(jd=0, sg=ITALY)
+ jd = valid_jd?(jd, sg)
+ new0(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
- alias_method :exist?, :exist3?
+ # Do the year +y+ and day-of-year +d+ make a valid Ordinal Date?
+ # Returns the corresponding Julian Day Number if they do, or
+ # nil if they don't.
+ #
+ # +d+ can be a negative number, in which case it counts backwards
+ # from the end of the year (-1 being the last day of the year).
+ # No year wraparound is performed, however, so valid values of
+ # +d+ are -365 .. -1, 1 .. 365 on a non-leap-year,
+ # -366 .. -1, 1 .. 366 on a leap year.
+ # A date falling in the period skipped in the Day of Calendar Reform
+ # adjustment is not valid.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.valid_ordinal? (y, d, sg=ITALY)
+ if d < 0
+ ny, = clfloor(y + 1, 1)
+ jd = ordinal_to_jd(ny, d + 1, sg)
+ ns = ns?(jd, sg)
+ return unless [y] == jd_to_ordinal(jd, sg)[0..0]
+ return unless [ny, 1] == jd_to_ordinal(jd - d, ns)
+ else
+ jd = ordinal_to_jd(y, d, sg)
+ return unless [y, d] == jd_to_ordinal(jd, sg)
+ end
+ jd
+ end
- def new3(y=-4712, m=1, d=1, sg=ITALY)
- unless jd = exist3?(y, m, d, sg)
- raise ArgumentError, 'invalid date'
- end
- new0(jd, sg)
+ # Create a new Date object from an Ordinal Date, specified
+ # by year +y+ and day-of-year +d+. +d+ can be negative,
+ # in which it counts backwards from the end of the year.
+ # No year wraparound is performed, however. An invalid
+ # value for +d+ results in an ArgumentError being raised.
+ #
+ # +y+ defaults to -4712, and +d+ to 1; this is Julian Day
+ # Number day 0.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.ordinal(y=-4712, d=1, sg=ITALY)
+ unless jd = valid_ordinal?(y, d, sg)
+ raise ArgumentError, 'invalid date'
end
+ new0(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
- alias_method :new, :new3
-
- def exist2? (y, d, sg=ITALY)
- if d < 0
- ny, = clfloor(y + 1, 1)
- jd = ordinal_to_jd(ny, d + 1, sg)
- ns = ns?(jd, sg)
- return unless [y] == jd_to_ordinal(jd, sg)[0..0]
- return unless [ny, 1] == jd_to_ordinal(jd - d, ns)
- else
- jd = ordinal_to_jd(y, d, sg)
- return unless [y, d] == jd_to_ordinal(jd, sg)
- end
- jd
+ # Do year +y+, month +m+, and day-of-month +d+ make a
+ # valid Civil Date? Returns the corresponding Julian
+ # Day Number if they do, nil if they don't.
+ #
+ # +m+ and +d+ can be negative, in which case they count
+ # backwards from the end of the year and the end of the
+ # month respectively. No wraparound is performed, however,
+ # and invalid values cause an ArgumentError to be raised.
+ # A date falling in the period skipped in the Day of Calendar
+ # Reform adjustment is not valid.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.valid_civil? (y, m, d, sg=ITALY)
+ if m < 0
+ m += 13
+ end
+ if d < 0
+ ny, nm = clfloor(y * 12 + m, 12)
+ nm, = clfloor(nm + 1, 1)
+ jd = civil_to_jd(ny, nm, d + 1, sg)
+ ns = ns?(jd, sg)
+ return unless [y, m] == jd_to_civil(jd, sg)[0..1]
+ return unless [ny, nm, 1] == jd_to_civil(jd - d, ns)
+ else
+ jd = civil_to_jd(y, m, d, sg)
+ return unless [y, m, d] == jd_to_civil(jd, sg)
end
+ jd
+ end
- def new2(y=-4712, d=1, sg=ITALY)
- unless jd = exist2?(y, d, sg)
- raise ArgumentError, 'invalid date'
- end
- new0(jd, sg)
+ class << self; alias_method :valid_date?, :valid_civil? end
+
+ # Create a new Date object for the Civil Date specified by
+ # year +y+, month +m+, and day-of-month +d+.
+ #
+ # +m+ and +d+ can be negative, in which case they count
+ # backwards from the end of the year and the end of the
+ # month respectively. No wraparound is performed, however,
+ # and invalid values cause an ArgumentError to be raised.
+ # can be negative
+ #
+ # +y+ defaults to -4712, +m+ to 1, and +d+ to 1; this is
+ # Julian Day Number day 0.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.civil(y=-4712, m=1, d=1, sg=ITALY)
+ unless jd = valid_civil?(y, m, d, sg)
+ raise ArgumentError, 'invalid date'
end
+ new0(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
- def existw? (y, w, d, sg=ITALY)
- if d < 0
- d += 8
- end
- if w < 0
- w = jd_to_commercial(commercial_to_jd(y + 1, 1, 1) + w * 7)[1]
- end
- jd = commercial_to_jd(y, w, d)
- return unless ns?(jd, sg)
- return unless [y, w, d] == jd_to_commercial(jd)
- jd
+ class << self; alias_method :new, :civil end
+
+ # Do year +y+, week-of-year +w+, and day-of-week +d+ make a
+ # valid Commercial Date? Returns the corresponding Julian
+ # Day Number if they do, nil if they don't.
+ #
+ # Monday is day-of-week 1; Sunday is day-of-week 7.
+ #
+ # +w+ and +d+ can be negative, in which case they count
+ # backwards from the end of the year and the end of the
+ # week respectively. No wraparound is performed, however,
+ # and invalid values cause an ArgumentError to be raised.
+ # A date falling in the period skipped in the Day of Calendar
+ # Reform adjustment is not valid.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.valid_commercial? (y, w, d, sg=ITALY)
+ if d < 0
+ d += 8
end
+ if w < 0
+ w = jd_to_commercial(commercial_to_jd(y + 1, 1, 1) + w * 7)[1]
+ end
+ jd = commercial_to_jd(y, w, d)
+ return unless ns?(jd, sg)
+ return unless [y, w, d] == jd_to_commercial(jd)
+ jd
+ end
- def neww(y=1582, w=41, d=5, sg=ITALY)
- unless jd = existw?(y, w, d, sg)
- raise ArgumentError, 'invalid date'
- end
- new0(jd, sg)
+ # Create a new Date object for the Commercial Date specified by
+ # year +y+, week-of-year +w+, and day-of-week +d+.
+ #
+ # Monday is day-of-week 1; Sunday is day-of-week 7.
+ #
+ # +w+ and +d+ can be negative, in which case they count
+ # backwards from the end of the year and the end of the
+ # week respectively. No wraparound is performed, however,
+ # and invalid values cause an ArgumentError to be raised.
+ #
+ # +y+ defaults to 1582, +w+ to 41, and +d+ to 5, the Day of
+ # Calendar Reform for Italy and the Catholic countries.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.commercial(y=1582, w=41, d=5, sg=ITALY)
+ unless jd = valid_commercial?(y, w, d, sg)
+ raise ArgumentError, 'invalid date'
end
+ new0(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
- def today(sg=ITALY)
- new0(civil_to_jd(*(Time.now.to_a[3..5].reverse << sg)), sg)
+ def self.new_with_hash(elem, sg)
+ elem ||= {}
+ y, m, d = elem.values_at(:year, :mon, :mday)
+ if [y, m, d].include? nil
+ raise ArgumentError, 'invalid date'
+ else
+ civil(y, m, d, sg)
end
+ end
+
+ private_class_method :new_with_hash
+
+ # Create a new Date object by parsing from a String
+ # according to a specified format.
+ #
+ # +str+ is a String holding a date representation.
+ # +fmt+ is the format that the date is in. See
+ # date/format.rb for details on supported formats.
+ #
+ # The default +str+ is '-4712-01-01', and the default
+ # +fmt+ is '%F', which means Year-Month-Day_of_Month.
+ # This gives Julian Day Number day 0.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # An ArgumentError will be raised if +str+ cannot be
+ # parsed.
+ def self.strptime(str='-4712-01-01', fmt='%F', sg=ITALY)
+ elem = _strptime(str, fmt)
+ new_with_hash(elem, sg)
+ end
+
+ # Create a new Date object by parsing from a String,
+ # without specifying the format.
+ #
+ # +str+ is a String holding a date representation.
+ # +comp+ specifies whether to interpret 2-digit years
+ # as 19XX (>= 69) or 20XX (< 69); the default is not to.
+ # The method will attempt to parse a date from the String
+ # using various heuristics; see #_parse in date/format.rb
+ # for more details. If parsing fails, an ArgumentError
+ # will be raised.
+ #
+ # The default +str+ is '-4712-01-01'; this is Julian
+ # Day Number day 0.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.parse(str='-4712-01-01', comp=false, sg=ITALY)
+ elem = _parse(str, comp)
+ new_with_hash(elem, sg)
+ end
+
+ # Create a new Date object representing today.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.today(sg=ITALY)
+ jd = civil_to_jd(*(Time.now.to_a[3..5].reverse << sg))
+ new0(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
+
+ class << self
- def once(*ids)
+ def once(*ids) # :nodoc:
for id in ids
- module_eval <<-"end;"
- alias_method :__#{id.to_i}__, :#{id.id2name}
+ module_eval <<-"end;", __FILE__, __LINE__
+ alias_method :__#{id.to_i}__, :#{id.to_s}
private :__#{id.to_i}__
- def #{id.id2name}(*args, &block)
- (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]
+ def #{id.to_s}(*args, &block)
+ if defined? @__#{id.to_i}__
+ @__#{id.to_i}__
+ elsif ! self.frozen?
+ @__#{id.to_i}__ ||= __#{id.to_i}__(*args, &block)
+ else
+ __#{id.to_i}__(*args, &block)
+ end
end
end;
end
@@ -212,111 +727,258 @@ class Date
end
- def initialize(rjd=0, sg=ITALY) @rjd, @sg = rjd, sg end
+ # *NOTE* this is the documentation for the method new0(). If
+ # you are reading this as the documentation for new(), that is
+ # because rdoc doesn't fully support the aliasing of the
+ # initialize() method.
+ # new() is in
+ # fact an alias for #civil(): read the documentation for that
+ # method instead.
+ #
+ # Create a new Date object.
+ #
+ # +ajd+ is the Astronomical Julian Day Number.
+ # +of+ is the offset from UTC as a fraction of a day.
+ # Both default to 0.
+ #
+ # +sg+ specifies the Day of Calendar Reform to use for this
+ # Date object.
+ #
+ # Using one of the factory methods such as Date::civil is
+ # generally easier and safer.
+ def initialize(ajd=0, of=0, sg=ITALY) @ajd, @of, @sg = ajd, of, sg end
- def rjd() @rjd end
- def rmjd() type.jd_to_mjd(@rjd) end
- def rtjd() type.jd_to_tjd(@rjd) end
- def rtjd2() type.jd_to_tjd2(@rjd) end
+ # Get the date as an Astronomical Julian Day Number.
+ def ajd() @ajd end
- once :rmjd, :rtjd, :rtjd2
+ # Get the date as an Astronomical Modified Julian Day Number.
+ def amjd() self.class.ajd_to_amjd(@ajd) end
- def jd() type.rjd_to_jd(@rjd)[0] end
- def fr1() type.rjd_to_jd(@rjd)[1] end
- def mjd() type.jd_to_mjd(jd) end
- def tjd() type.jd_to_tjd(jd) end
- def tjd2() type.jd_to_tjd2(jd) end
- def ld() type.jd_to_ld(jd) end
+ once :amjd
- once :jd, :fr1, :mjd, :tjd, :tjd2, :ld
+ # Get the date as a Julian Day Number.
+ def jd() self.class.ajd_to_jd(@ajd, @of)[0] end
- def civil() type.jd_to_civil(jd, @sg) end
- def ordinal() type.jd_to_ordinal(jd, @sg) end
- def commercial() type.jd_to_commercial(jd, @sg) end
+ # Get any fractional day part of the date.
+ def day_fraction() self.class.ajd_to_jd(@ajd, @of)[1] end
+
+ # Get the date as a Modified Julian Day Number.
+ def mjd() self.class.jd_to_mjd(jd) end
+
+ # Get the date as the number of days since the Day of Calendar
+ # Reform (in Italy and the Catholic countries).
+ def ld() self.class.jd_to_ld(jd) end
+
+ once :jd, :day_fraction, :mjd, :ld
+
+ # Get the date as a Civil Date, [year, month, day_of_month]
+ def civil() self.class.jd_to_civil(jd, @sg) end
+
+ # Get the date as an Ordinal Date, [year, day_of_year]
+ def ordinal() self.class.jd_to_ordinal(jd, @sg) end
+
+ # Get the date as a Commercial Date, [year, week_of_year, day_of_week]
+ def commercial() self.class.jd_to_commercial(jd, @sg) end
once :civil, :ordinal, :commercial
private :civil, :ordinal, :commercial
+ # Get the year of this date.
def year() civil[0] end
+
+ # Get the day-of-the-year of this date.
+ #
+ # January 1 is day-of-the-year 1
def yday() ordinal[1] end
- def mon() civil[1] end
- alias_method :month, :mon
+ # Get the month of this date.
+ #
+ # January is month 1.
+ def mon() civil[1] end
+ # Get the day-of-the-month of this date.
def mday() civil[2] end
+ alias_method :month, :mon
alias_method :day, :mday
+ # Get the time of this date as [hours, minutes, seconds,
+ # fraction_of_a_second]
+ def time() self.class.day_fraction_to_time(day_fraction) end
+
+ once :time
+ private :time
+
+ # Get the hour of this date.
+ def hour() time[0] end
+
+ # Get the minute of this date.
+ def min() time[1] end
+
+ # Get the second of this date.
+ def sec() time[2] end
+
+ # Get the fraction-of-a-second of this date.
+ def sec_fraction() time[3] end
+
+ private :hour, :min, :sec, :sec_fraction
+
+ def zone() strftime('%Z') end
+
+ private :zone
+
+ # Get the commercial year of this date. See *Commercial* *Date*
+ # in the introduction for how this differs from the normal year.
def cwyear() commercial[0] end
+
+ # Get the commercial week of the year of this date.
def cweek() commercial[1] end
+
+ # Get the commercial day of the week of this date. Monday is
+ # commercial day-of-week 1; Sunday is commercial day-of-week 7.
def cwday() commercial[2] end
- def wday() type.jd_to_wday(jd) end
+ # Get the week day of this date. Sunday is day-of-week 0;
+ # Saturday is day-of-week 6.
+ def wday() self.class.jd_to_wday(jd) end
once :wday
- def os? () type.os?(jd, @sg) end
- def ns? () type.ns?(jd, @sg) end
+ # Is the current date old-style (Julian Calendar)?
+ def os? () self.class.os?(jd, @sg) end
+
+ # Is the current date new-style (Gregorian Calendar)?
+ def ns? () self.class.ns?(jd, @sg) end
once :os?, :ns?
+ # Is this a leap year?
def leap?
- type.jd_to_civil(type.civil_to_jd(year, 3, 1, ns?) - 1,
+ self.class.jd_to_civil(self.class.civil_to_jd(year, 3, 1, ns?) - 1,
ns?)[-1] == 29
end
once :leap?
- def sg() @sg end
- def newsg(sg=type::ITALY) type.new0(@rjd, sg) end
+ # When is the Day of Calendar Reform for this Date object?
+ def start() @sg end
+
+ # Create a copy of this Date object using a new Day of Calendar Reform.
+ def new_start(sg=self.class::ITALY) self.class.new0(@ajd, @of, sg) end
+
+ # Create a copy of this Date object that uses the Italian/Catholic
+ # Day of Calendar Reform.
+ def italy() new_start(self.class::ITALY) end
+
+ # Create a copy of this Date object that uses the English/Colonial
+ # Day of Calendar Reform.
+ def england() new_start(self.class::ENGLAND) end
+
+ # Create a copy of this Date object that always uses the Julian
+ # Calendar.
+ def julian() new_start(self.class::JULIAN) end
- def italy() newsg(type::ITALY) end
- def england() newsg(type::ENGLAND) end
- def julian() newsg(type::JULIAN) end
- def gregorian() newsg(type::GREGORIAN) end
+ # Create a copy of this Date object that always uses the Gregorian
+ # Calendar.
+ def gregorian() new_start(self.class::GREGORIAN) end
+ def offset() @of end
+ def new_offset(of=0) self.class.new0(@ajd, of, @sg) end
+
+ private :offset, :new_offset
+
+ # Return a new Date object that is +n+ days later than the
+ # current one.
+ #
+ # +n+ may be a negative value, in which case the new Date
+ # is earlier than the current one; however, #-() might be
+ # more intuitive.
+ #
+ # If +n+ is not a Numeric, a TypeError will be thrown. In
+ # particular, two Dates cannot be added to each other.
def + (n)
case n
- when Numeric; return type.new0(@rjd + n, @sg)
+ when Numeric; return self.class.new0(@ajd + n, @of, @sg)
end
raise TypeError, 'expected numeric'
end
+ # If +x+ is a Numeric value, create a new Date object that is
+ # +x+ days earlier than the current one.
+ #
+ # If +x+ is a Date, return the number of days between the
+ # two dates; or, more precisely, how many days later the current
+ # date is than +x+.
+ #
+ # If +x+ is neither Numeric nor a Date, a TypeError is raised.
def - (x)
case x
- when Numeric; return type.new0(@rjd - x, @sg)
- when Date; return @rjd - x.rjd
+ when Numeric; return self.class.new0(@ajd - x, @of, @sg)
+ when Date; return @ajd - x.ajd
end
raise TypeError, 'expected numeric or date'
end
+ # Compare this date with another date.
+ #
+ # +other+ can also be a Numeric value, in which case it is
+ # interpreted as an Astronomical Julian Day Number.
+ #
+ # Comparison is by Astronomical Julian Day Number, including
+ # fractional days. This means that both the time and the
+ # timezone offset are taken into account when comparing
+ # two DateTime instances. When comparing a DateTime instance
+ # with a Date instance, the time of the latter will be
+ # considered as falling on midnight UTC.
def <=> (other)
case other
- when Numeric; return @rjd <=> other
- when Date; return @rjd <=> other.rjd
+ when Numeric; return @ajd <=> other
+ when Date; return @ajd <=> other.ajd
end
- raise TypeError, 'expected numeric or date'
+ nil
end
+ # The relationship operator for Date.
+ #
+ # Compares dates by Julian Day Number. When comparing
+ # two DateTime instances, or a DateTime with a Date,
+ # the instances will be regarded as equivalent if they
+ # fall on the same date in local time.
def === (other)
case other
when Numeric; return jd == other
when Date; return jd == other.jd
end
- raise TypeError, 'expected numeric or date'
+ false
end
+ # Return a new Date object that is +n+ months later than
+ # the current one.
+ #
+ # If the day-of-the-month of the current Date is greater
+ # than the last day of the target month, the day-of-the-month
+ # of the returned Date will be the last day of the target month.
def >> (n)
- y, m = type.clfloor(year * 12 + (mon - 1) + n, 12)
- m, = type.clfloor(m + 1, 1)
+ y, m = clfloor(year * 12 + (mon - 1) + n, 12)
+ m, = clfloor(m + 1, 1)
d = mday
- d -= 1 until jd2 = type.exist3?(y, m, d, ns?)
+ d -= 1 until jd2 = self.class.valid_civil?(y, m, d, ns?)
self + (jd2 - jd)
end
+ # Return a new Date object that is +n+ months earlier than
+ # the current one.
+ #
+ # If the day-of-the-month of the current Date is greater
+ # than the last day of the target month, the day-of-the-month
+ # of the returned Date will be the last day of the target month.
def << (n) self >> -n end
- def step(limit, step)
+ # Step the current date forward +step+ days at a
+ # time (or backward, if +step+ is negative) until
+ # we reach +limit+ (inclusive), yielding the resultant
+ # date at each step.
+ def step(limit, step) # :yield: date
da = self
op = [:-,:<=,:>=][step<=>0]
while da.__send__(op, limit)
@@ -326,20 +988,341 @@ class Date
self
end
- def upto(max, &block) step(max, +1, &block) end
- def downto(min, &block) step(min, -1, &block) end
+ # Step forward one day at a time until we reach +max+
+ # (inclusive), yielding each date as we go.
+ def upto(max, &block) # :yield: date
+ step(max, +1, &block)
+ end
+ # Step backward one day at a time until we reach +min+
+ # (inclusive), yielding each date as we go.
+ def downto(min, &block) # :yield: date
+ step(min, -1, &block)
+ end
+
+ # Return a new Date one day after this one.
def succ() self + 1 end
alias_method :next, :succ
+ # Is this Date equal to +other+?
+ #
+ # +other+ must both be a Date object, and represent the same date.
def eql? (other) Date === other and self == other end
- def hash() type.clfloor(@rjd)[0] end
- def inspect() format('#<%s: %s,%s>', type, @rjd, @sg) end
- def to_s() format('%.4d-%02d-%02d', year, mon, mday) end
+ # Calculate a hash value for this date.
+ def hash() @ajd.hash end
+
+ # Return internal object state as a programmer-readable string.
+ def inspect() format('#<%s: %s,%s,%s>', self.class, @ajd, @of, @sg) end
+
+ # Return the date as a human-readable string.
+ #
+ # The format used is YYYY-MM-DD.
+ def to_s() strftime end
+
+ # Dump to Marshal format.
+ def _dump(limit) Marshal.dump([@ajd, @of, @sg], -1) end
+
+# def self._load(str) new0(*Marshal.load(str)) end
+
+ # Load from Marshall format.
+ def self._load(str)
+ a = Marshal.load(str)
+ if a.size == 2
+ ajd, sg = a
+ of = 0
+ ajd -= 1.to_r/2
+ else
+ ajd, of, sg = a
+ end
+ new0(ajd, of, sg)
+ end
+
+end
+
+# Class representing a date and time.
+#
+# See the documentation to the file date.rb for an overview.
+#
+# DateTime objects are immutable once created.
+#
+# == Other methods.
+#
+# The following methods are defined in Date, but declared private
+# there. They are made public in DateTime. They are documented
+# here.
+#
+# === hour()
+#
+# Get the hour-of-the-day of the time. This is given
+# using the 24-hour clock, counting from midnight. The first
+# hour after midnight is hour 0; the last hour of the day is
+# hour 23.
+#
+# === min()
+#
+# Get the minute-of-the-hour of the time.
+#
+# === sec()
+#
+# Get the second-of-the-minute of the time.
+#
+# === sec_fraction()
+#
+# Get the fraction of a second of the time. This is returned as
+# a +Rational+.
+#
+# === zone()
+#
+# Get the time zone as a String. This is representation of the
+# time offset such as "+1000", not the true time-zone name.
+#
+# === offset()
+#
+# Get the time zone offset as a fraction of a day. This is returned
+# as a +Rational+.
+#
+# === new_offset(of=0)
+#
+# Create a new DateTime object, identical to the current one, except
+# with a new time zone offset of +of+. +of+ is the new offset from
+# UTC as a fraction of a day.
+#
+class DateTime < Date
+
+ # Do hour +h+, minute +min+, and second +s+ constitute a valid time?
+ #
+ # If they do, returns their value as a fraction of a day. If not,
+ # returns nil.
+ #
+ # The 24-hour clock is used. Negative values of +h+, +min+, and
+ # +sec+ are treating as counting backwards from the end of the
+ # next larger unit (e.g. a +min+ of -2 is treated as 58). No
+ # wraparound is performed.
+ def self.valid_time? (h, min, s)
+ h += 24 if h < 0
+ min += 60 if min < 0
+ s += 60 if s < 0
+ return unless (0..24) === h and
+ (0..59) === min and
+ (0..59) === s
+ time_to_day_fraction(h, min, s)
+ end
+
+ # Create a new DateTime object corresponding to the specified
+ # Julian Day Number +jd+ and hour +h+, minute +min+, second +s+.
+ #
+ # The 24-hour clock is used. Negative values of +h+, +min+, and
+ # +sec+ are treating as counting backwards from the end of the
+ # next larger unit (e.g. a +min+ of -2 is treated as 58). No
+ # wraparound is performed. If an invalid time portion is specified,
+ # an ArgumentError is raised.
+ #
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # All day/time values default to 0.
+ def self.jd(jd=0, h=0, min=0, s=0, of=0, sg=ITALY)
+ unless (jd = valid_jd?(jd, sg)) and
+ (fr = valid_time?(h, min, s))
+ raise ArgumentError, 'invalid date'
+ end
+ new0(jd_to_ajd(jd, fr, of), of, sg)
+ end
+
+ # Create a new DateTime object corresponding to the specified
+ # Ordinal Date and hour +h+, minute +min+, second +s+.
+ #
+ # The 24-hour clock is used. Negative values of +h+, +min+, and
+ # +sec+ are treating as counting backwards from the end of the
+ # next larger unit (e.g. a +min+ of -2 is treated as 58). No
+ # wraparound is performed. If an invalid time portion is specified,
+ # an ArgumentError is raised.
+ #
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # +y+ defaults to -4712, and +d+ to 1; this is Julian Day Number
+ # day 0. The time values default to 0.
+ def self.ordinal(y=-4712, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
+ unless (jd = valid_ordinal?(y, d, sg)) and
+ (fr = valid_time?(h, min, s))
+ raise ArgumentError, 'invalid date'
+ end
+ new0(jd_to_ajd(jd, fr, of), of, sg)
+ end
+
+ # Create a new DateTime object corresponding to the specified
+ # Civil Date and hour +h+, minute +min+, second +s+.
+ #
+ # The 24-hour clock is used. Negative values of +h+, +min+, and
+ # +sec+ are treating as counting backwards from the end of the
+ # next larger unit (e.g. a +min+ of -2 is treated as 58). No
+ # wraparound is performed. If an invalid time portion is specified,
+ # an ArgumentError is raised.
+ #
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # +y+ defaults to -4712, +m+ to 1, and +d+ to 1; this is Julian Day
+ # Number day 0. The time values default to 0.
+ def self.civil(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
+ unless (jd = valid_civil?(y, m, d, sg)) and
+ (fr = valid_time?(h, min, s))
+ raise ArgumentError, 'invalid date'
+ end
+ new0(jd_to_ajd(jd, fr, of), of, sg)
+ end
+
+ class << self; alias_method :new, :civil end
+
+ # Create a new DateTime object corresponding to the specified
+ # Commercial Date and hour +h+, minute +min+, second +s+.
+ #
+ # The 24-hour clock is used. Negative values of +h+, +min+, and
+ # +sec+ are treating as counting backwards from the end of the
+ # next larger unit (e.g. a +min+ of -2 is treated as 58). No
+ # wraparound is performed. If an invalid time portion is specified,
+ # an ArgumentError is raised.
+ #
+ # +of+ is the offset from UTC as a fraction of a day (defaults to 0).
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # +y+ defaults to 1582, +w+ to 41, and +d+ to 5; this is the Day of
+ # Calendar Reform for Italy and the Catholic countries.
+ # The time values default to 0.
+ def self.commercial(y=1582, w=41, d=5, h=0, min=0, s=0, of=0, sg=ITALY)
+ unless (jd = valid_commercial?(y, w, d, sg)) and
+ (fr = valid_time?(h, min, s))
+ raise ArgumentError, 'invalid date'
+ end
+ new0(jd_to_ajd(jd, fr, of), of, sg)
+ end
+
+ def self.new_with_hash(elem, sg)
+ elem ||= {}
+ y, m, d, h, min, s, fr, of =
+ elem.values_at(:year, :mon, :mday,
+ :hour, :min, :sec, :sec_fraction, :offset)
+ h ||= 0
+ min ||= 0
+ s ||= 0
+ fr ||= 0
+ of ||= 0
+ if [y, m, d].include? nil
+ raise ArgumentError, 'invalid date'
+ else
+ civil(y, m, d, h, min, s, of.to_r/86400, sg) + (fr/86400)
+ end
+ end
+
+ private_class_method :new_with_hash
+
+ # Create a new DateTime object by parsing from a String
+ # according to a specified format.
+ #
+ # +str+ is a String holding a date-time representation.
+ # +fmt+ is the format that the date-time is in. See
+ # date/format.rb for details on supported formats.
+ #
+ # The default +str+ is '-4712-01-01T00:00:00Z', and the default
+ # +fmt+ is '%FT%T%Z'. This gives midnight on Julian Day Number day 0.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ #
+ # An ArgumentError will be raised if +str+ cannot be
+ # parsed.
+ def self.strptime(str='-4712-01-01T00:00:00Z', fmt='%FT%T%Z', sg=ITALY)
+ elem = _strptime(str, fmt)
+ new_with_hash(elem, sg)
+ end
+
+ # Create a new DateTime object by parsing from a String,
+ # without specifying the format.
+ #
+ # +str+ is a String holding a date-time representation.
+ # +comp+ specifies whether to interpret 2-digit years
+ # as 19XX (>= 69) or 20XX (< 69); the default is not to.
+ # The method will attempt to parse a date-time from the String
+ # using various heuristics; see #_parse in date/format.rb
+ # for more details. If parsing fails, an ArgumentError
+ # will be raised.
+ #
+ # The default +str+ is '-4712-01-01T00:00:00Z'; this is Julian
+ # Day Number day 0.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.parse(str='-4712-01-01T00:00:00Z', comp=false, sg=ITALY)
+ elem = _parse(str, comp)
+ new_with_hash(elem, sg)
+ end
+
+ class << self; undef_method :today end
+
+ # Create a new DateTime object representing the current time.
+ #
+ # +sg+ specifies the Day of Calendar Reform.
+ def self.now(sg=ITALY)
+ i = Time.now
+ a = i.to_a[0..5].reverse
+ jd = civil_to_jd(*(a[0,3] << sg))
+ fr = time_to_day_fraction(*(a[3,3])) + i.usec.to_r/86400000000
+ of = i.utc_offset.to_r/86400
+ new0(jd_to_ajd(jd, fr, of), of, sg)
+ end
+
+ public :hour, :min, :sec, :sec_fraction, :zone, :offset, :new_offset
+
+end
+
+class Date
+
+ [ %w(exist1? valid_jd?),
+ %w(exist2? valid_ordinal?),
+ %w(exist3? valid_date?),
+ %w(exist? valid_date?),
+ %w(existw? valid_commercial?),
+ %w(new1 jd),
+ %w(new2 ordinal),
+ %w(new3 new),
+ %w(neww commercial)
+ ].each do |old, new|
+ module_eval <<-"end;"
+ def self.#{old}(*args, &block)
+ if $VERBOSE
+ warn("\#{caller.shift.sub(/:in .*/, '')}: " \
+ "warning: \#{self}::#{old} is deprecated; " \
+ "use \#{self}::#{new}")
+ end
+ #{new}(*args, &block)
+ end
+ end;
+ end
+
+ [ %w(sg start),
+ %w(newsg new_start),
+ %w(of offset),
+ %w(newof new_offset)
+ ].each do |old, new|
+ module_eval <<-"end;"
+ def #{old}(*args, &block)
+ if $VERBOSE
+ warn("\#{caller.shift.sub(/:in .*/, '')}: " \
+ "warning: \#{self.class}\##{old} is deprecated; " \
+ "use \#{self.class}\##{new}")
+ end
+ #{new}(*args, &block)
+ end
+ end;
+ end
+
+ private :of, :newof
+
+end
+
+class DateTime < Date
- def _dump(limit) Marshal.dump([@rjd, @sg], -1) end
- def self._load(str) new0(*Marshal.load(str)) end
+ public :of, :newof
end
diff --git a/lib/date/format.rb b/lib/date/format.rb
new file mode 100644
index 0000000000..e8e54e7894
--- /dev/null
+++ b/lib/date/format.rb
@@ -0,0 +1,563 @@
+# format.rb: Written by Tadayoshi Funaba 1999-2004
+# $Id: format.rb,v 2.13 2004-03-20 08:05:13+09 tadf Exp $
+
+require 'rational'
+
+class Date
+
+ MONTHS = {
+ 'january' => 1, 'february' => 2, 'march' => 3, 'april' => 4,
+ 'may' => 5, 'june' => 6, 'july' => 7, 'august' => 8,
+ 'september'=> 9, 'october' =>10, 'november' =>11, 'december' =>12
+ }
+
+ DAYS = {
+ 'sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday'=> 3,
+ 'thursday' => 4, 'friday' => 5, 'saturday' => 6
+ }
+
+ ABBR_MONTHS = {
+ 'jan' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4,
+ 'may' => 5, 'jun' => 6, 'jul' => 7, 'aug' => 8,
+ 'sep' => 9, 'oct' =>10, 'nov' =>11, 'dec' =>12
+ }
+
+ ABBR_DAYS = {
+ 'sun' => 0, 'mon' => 1, 'tue' => 2, 'wed' => 3,
+ 'thu' => 4, 'fri' => 5, 'sat' => 6
+ }
+
+ ZONES = {
+ 'ut' => 0*3600, 'gmt' => 0*3600, 'est' => -5*3600, 'edt' => -4*3600,
+ 'cst' => -6*3600, 'cdt' => -5*3600, 'mst' => -7*3600, 'mdt' => -6*3600,
+ 'pst' => -8*3600, 'pdt' => -7*3600,
+ 'a' => 1*3600, 'b' => 2*3600, 'c' => 3*3600, 'd' => 4*3600,
+ 'e' => 5*3600, 'f' => 6*3600, 'g' => 7*3600, 'h' => 8*3600,
+ 'i' => 9*3600, 'k' => 10*3600, 'l' => 11*3600, 'm' => 12*3600,
+ 'n' => -1*3600, 'o' => -2*3600, 'p' => -3*3600, 'q' => -4*3600,
+ 'r' => -5*3600, 's' => -6*3600, 't' => -7*3600, 'u' => -8*3600,
+ 'v' => -9*3600, 'w' =>-10*3600, 'x' =>-11*3600, 'y' =>-12*3600,
+ 'z' => 0*3600,
+ 'utc' => 0*3600, 'wet' => 0*3600, 'bst' => 1*3600, 'wat' => -1*3600,
+ 'at' => -2*3600, 'ast' => -4*3600, 'adt' => -3*3600, 'yst' => -9*3600,
+ 'ydt' => -8*3600, 'hst' =>-10*3600, 'hdt' => -9*3600, 'cat' =>-10*3600,
+ 'ahst'=>-10*3600, 'nt' =>-11*3600, 'idlw'=>-12*3600, 'cet' => 1*3600,
+ 'met' => 1*3600, 'mewt'=> 1*3600, 'mest'=> 2*3600, 'mesz'=> 2*3600,
+ 'swt' => 1*3600, 'sst' => 2*3600, 'fwt' => 1*3600, 'fst' => 2*3600,
+ 'eet' => 2*3600, 'bt' => 3*3600, 'zp4' => 4*3600, 'zp5' => 5*3600,
+ 'zp6' => 6*3600, 'wast'=> 7*3600, 'wadt'=> 8*3600, 'cct' => 8*3600,
+ 'jst' => 9*3600, 'east'=> 10*3600, 'eadt'=> 11*3600, 'gst' => 10*3600,
+ 'nzt' => 12*3600, 'nzst'=> 12*3600, 'nzdt'=> 13*3600, 'idle'=> 12*3600
+ }
+
+ def self.__strptime(str, fmt, elem)
+ fmt.scan(/%[EO]?.|./o) do |c|
+ cc = c.sub(/\A%[EO]?(.)\Z/o, '%\\1')
+ case cc
+ when /\A\s/o
+ str.sub!(/\A[\s\v]+/o, '')
+ when '%A', '%a'
+ return unless str.sub!(/\A([a-z]+)\b/io, '')
+ val = DAYS[$1.downcase] || ABBR_DAYS[$1.downcase]
+ return unless val
+ elem[:wday] = val
+ when '%B', '%b', '%h'
+ return unless str.sub!(/\A([a-z]+)\b/io, '')
+ val = MONTHS[$1.downcase] || ABBR_MONTHS[$1.downcase]
+ return unless val
+ elem[:mon] = val
+ when '%C'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ elem[:cent] = val
+ when '%c'
+ return unless __strptime(str, '%a %b %e %H:%M:%S %Y', elem)
+ when '%D'
+ return unless __strptime(str, '%m/%d/%y', elem)
+ when '%d', '%e'
+ return unless str.sub!(/\A ?(\d+)/o, '')
+ val = $1.to_i
+ return unless (1..31) === val
+ elem[:mday] = val
+ when '%F'
+ return unless __strptime(str, '%Y-%m-%d', elem)
+ when '%G'
+ return unless str.sub!(/\A([-+]?\d+)/o, '')
+ val = $1.to_i
+ elem[:cwyear] = val
+ when '%g'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (0..99) === val
+ elem[:cwyear] = val
+ elem[:cent] ||= if val >= 69 then 19 else 20 end
+ when '%H', '%k'
+ return unless str.sub!(/\A ?(\d+)/o, '')
+ val = $1.to_i
+ return unless (0..24) === val
+ elem[:hour] = val
+ when '%I', '%l'
+ return unless str.sub!(/\A ?(\d+)/o, '')
+ val = $1.to_i
+ return unless (1..12) === val
+ elem[:hour] = val
+ when '%j'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (1..366) === val
+ elem[:yday] = val
+ when '%M'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (0..59) === val
+ elem[:min] = val
+ when '%m'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (1..12) === val
+ elem[:mon] = val
+ when '%n'
+ return unless __strptime(str, ' ', elem)
+ when '%p', '%P'
+ return unless str.sub!(/\A([ap])(?:m\b|\.m\.)/io, '')
+ elem[:merid] = if $1.downcase == 'a' then 0 else 12 end
+ when '%R'
+ return unless __strptime(str, '%H:%M', elem)
+ when '%r'
+ return unless __strptime(str, '%I:%M:%S %p', elem)
+ when '%S'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (0..60) === val
+ elem[:sec] = val
+ when '%s'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ elem[:seconds] = val
+ when '%T'
+ return unless __strptime(str, '%H:%M:%S', elem)
+ when '%t'
+ return unless __strptime(str, ' ', elem)
+ when '%U', '%W'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (0..53) === val
+ elem[if c == '%U' then :wnum0 else :wnum1 end] = val
+ when '%u'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (1..7) === val
+ elem[:cwday] = val
+ when '%V'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (1..53) === val
+ elem[:cweek] = val
+ when '%v'
+ return unless __strptime(str, '%e-%b-%Y', elem)
+ when '%w'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (0..6) === val
+ elem[:wday] = val
+ when '%X'
+ return unless __strptime(str, '%H:%M:%S', elem)
+ when '%x'
+ return unless __strptime(str, '%m/%d/%y', elem)
+ when '%Y'
+ return unless str.sub!(/\A([-+]?\d+)/o, '')
+ val = $1.to_i
+ elem[:year] = val
+ when '%y'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ return unless (0..99) === val
+ elem[:year] = val
+ elem[:cent] ||= if val >= 69 then 19 else 20 end
+ when '%Z', '%z'
+ return unless str.sub!(/\A([-+:a-z0-9]+(?:\s+dst\b)?)/io, '')
+ val = $1
+ elem[:zone] = val
+ offset = zone_to_diff(val)
+ elem[:offset] = offset
+ when '%%'
+ return unless str.sub!(/\A%/o, '')
+ when '%+'
+ return unless __strptime(str, '%a %b %e %H:%M:%S %Z %Y', elem)
+=begin
+ when '%.'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i.to_r / (10**$1.size)
+ elem[:sec_fraction] = val
+=end
+ when '%1'
+ return unless str.sub!(/\A(\d+)/o, '')
+ val = $1.to_i
+ elem[:jd] = val
+ when '%2'
+ return unless __strptime(str, '%Y-%j', elem)
+ when '%3'
+ return unless __strptime(str, '%F', elem)
+ else
+ return unless str.sub!(Regexp.new('\\A' + Regexp.quote(c)), '')
+ end
+ end
+
+ if cent = elem.delete(:cent)
+ if elem[:cwyear]
+ elem[:cwyear] += cent * 100
+ end
+ if elem[:year]
+ elem[:year] += cent * 100
+ end
+ end
+
+ if merid = elem.delete(:merid)
+ if elem[:hour]
+ elem[:hour] %= 12
+ elem[:hour] += merid
+ end
+ end
+
+ str
+ end
+
+ private_class_method :__strptime
+
+ def self._strptime(str, fmt='%F')
+ elem = {}
+ elem if __strptime(str.dup, fmt, elem)
+ end
+
+ PARSE_MONTHPAT = ABBR_MONTHS.keys.join('|')
+ PARSE_DAYPAT = ABBR_DAYS. keys.join('|')
+
+ def self._parse(str, comp=false)
+ str = str.dup
+
+ str.gsub!(/[^-+,.\/:0-9a-z]+/ino, ' ')
+
+ # day
+ if str.sub!(/(#{PARSE_DAYPAT})\S*/ino, ' ')
+ wday = ABBR_DAYS[$1.downcase]
+ end
+
+ # time
+ if str.sub!(
+ /(\d+):(\d+)
+ (?:
+ :(\d+)(?:[,.](\d*))?
+ )?
+ (?:
+ \s*
+ ([ap])(?:m\b|\.m\.)
+ )?
+ (?:
+ \s*
+ (
+ [a-z]+(?:\s+dst)?\b
+ |
+ [-+]\d+(?::?\d+)
+ )
+ )?
+ /inox,
+ ' ')
+ hour = $1.to_i
+ min = $2.to_i
+ sec = $3.to_i if $3
+ if $4
+ sec_fraction = $4.to_i.to_r / (10**$4.size)
+ end
+
+ if $5
+ hour %= 12
+ if $5.downcase == 'p'
+ hour += 12
+ end
+ end
+
+ zone = $6
+ end
+
+ # eu
+ if str.sub!(
+ /(\d+)\S*
+ \s+
+ (#{PARSE_MONTHPAT})\S*
+ (?:
+ \s+
+ (-?\d+)
+ )?
+ /inox,
+ ' ')
+ mday = $1.to_i
+ mon = ABBR_MONTHS[$2.downcase]
+
+ if $3
+ year = $3.to_i
+ if $3.size > 2
+ comp = false
+ end
+ end
+
+ # us
+ elsif str.sub!(
+ /(#{PARSE_MONTHPAT})\S*
+ \s+
+ (\d+)\S*
+ (?:
+ \s+
+ (-?\d+)
+ )?
+ /inox,
+ ' ')
+ mon = ABBR_MONTHS[$1.downcase]
+ mday = $2.to_i
+
+ if $3
+ year = $3.to_i
+ if $3.size > 2
+ comp = false
+ end
+ end
+
+ # iso
+ elsif str.sub!(/([-+]?\d+)-(\d+)-(-?\d+)/no, ' ')
+ year = $1.to_i
+ mon = $2.to_i
+ mday = $3.to_i
+
+ if $1.size > 2
+ comp = false
+ elsif $3.size > 2
+ comp = false
+ mday, mon, year = year, mon, mday
+ end
+
+ # jis
+ elsif str.sub!(/([MTSH])(\d+)\.(\d+)\.(\d+)/ino, ' ')
+ e = { 'm'=>1867,
+ 't'=>1911,
+ 's'=>1925,
+ 'h'=>1988
+ }[$1.downcase]
+ year = $2.to_i + e
+ mon = $3.to_i
+ mday = $4.to_i
+
+ # vms
+ elsif str.sub!(/(-?\d+)-(#{PARSE_MONTHPAT})[^-]*-(-?\d+)/ino, ' ')
+ mday = $1.to_i
+ mon = ABBR_MONTHS[$2.downcase]
+ year = $3.to_i
+
+ if $1.size > 2
+ comp = false
+ year, mon, mday = mday, mon, year
+ elsif $3.size > 2
+ comp = false
+ end
+
+ # sla
+ elsif str.sub!(%r|(-?\d+)/(\d+)(?:/(-?\d+))?|no, ' ')
+ mon = $1.to_i
+ mday = $2.to_i
+
+ if $3
+ year = $3.to_i
+ if $3.size > 2
+ comp = false
+ end
+ end
+
+ if $3 && $1.size > 2
+ comp = false
+ year, mon, mday = mon, mday, year
+ end
+
+ # ddd
+ elsif str.sub!(
+ /([-+]?)(\d{4,14})
+ (?:
+ \s*
+ T?
+ \s*
+ (\d{2,6})(?:[,.](\d*))?
+ )?
+ (?:
+ \s*
+ (
+ Z
+ |
+ [-+]\d{2,4}
+ )
+ \b
+ )?
+ /inox,
+ ' ')
+ case $2.size
+ when 4
+ mon = $2[ 0, 2].to_i
+ mday = $2[ 2, 2].to_i
+ when 6
+ year = ($1 + $2[ 0, 2]).to_i
+ mon = $2[ 2, 2].to_i
+ mday = $2[ 4, 2].to_i
+ when 8, 10, 12, 14
+ year = ($1 + $2[ 0, 4]).to_i
+ mon = $2[ 4, 2].to_i
+ mday = $2[ 6, 2].to_i
+ hour = $2[ 8, 2].to_i if $2.size >= 10
+ min = $2[10, 2].to_i if $2.size >= 12
+ sec = $2[12, 2].to_i if $2.size >= 14
+ comp = false
+ end
+ if $3
+ case $3.size
+ when 2, 4, 6
+ hour = $3[ 0, 2].to_i
+ min = $3[ 2, 2].to_i if $3.size >= 4
+ sec = $3[ 4, 2].to_i if $3.size >= 6
+ end
+ end
+ if $4
+ sec_fraction = $4.to_i.to_r / (10**$4.size)
+ end
+ zone = $5
+ end
+
+ if str.sub!(/\b(bc\b|bce\b|b\.c\.|b\.c\.e\.)/ino, ' ')
+ if year
+ year = -year + 1
+ end
+ end
+
+ if comp and year
+ if year >= 0 and year <= 99
+ if year >= 69
+ year += 1900
+ else
+ year += 2000
+ end
+ end
+ end
+
+ elem = {}
+ elem[:year] = year if year
+ elem[:mon] = mon if mon
+ elem[:mday] = mday if mday
+ elem[:hour] = hour if hour
+ elem[:min] = min if min
+ elem[:sec] = sec if sec
+ elem[:sec_fraction] = sec_fraction if sec_fraction
+ elem[:zone] = zone if zone
+ offset = zone_to_diff(zone) if zone
+ elem[:offset] = offset if offset
+ elem[:wday] = wday if wday
+ elem
+ end
+
+ def self.zone_to_diff(str)
+ abb, dst = str.downcase.split(/\s+/o, 2)
+ if ZONES.include?(abb)
+ offset = ZONES[abb]
+ offset += 3600 if dst
+ elsif /\A([-+])(\d{2}):?(\d{2})?\Z/no =~ str
+ offset = $2.to_i * 3600 + $3.to_i * 60
+ offset *= -1 if $1 == '-'
+ end
+ offset
+ end
+
+ def strftime(fmt='%F')
+ o = ''
+ fmt.scan(/%[EO]?.|./o) do |c|
+ cc = c.sub(/^%[EO]?(.)$/o, '%\\1')
+ case cc
+ when '%A'; o << DAYNAMES[wday]
+ when '%a'; o << ABBR_DAYNAMES[wday]
+ when '%B'; o << MONTHNAMES[mon]
+ when '%b'; o << ABBR_MONTHNAMES[mon]
+ when '%C'; o << '%02d' % (year / 100.0).floor # P2,ID
+ when '%c'; o << strftime('%a %b %e %H:%M:%S %Y')
+ when '%D'; o << strftime('%m/%d/%y') # P2,ID
+ when '%d'; o << '%02d' % mday
+ when '%e'; o << '%2d' % mday
+ when '%F'; o << strftime('%Y-%m-%d') # ID
+ when '%G'; o << '%.4d' % cwyear # ID
+ when '%g'; o << '%02d' % (cwyear % 100) # ID
+ when '%H'; o << '%02d' % hour
+ when '%h'; o << strftime('%b') # P2,ID
+ when '%I'; o << '%02d' % ((hour % 12).nonzero? or 12)
+ when '%j'; o << '%03d' % yday
+ when '%k'; o << '%2d' % hour # AR,TZ,GL
+ when '%l'; o << '%2d' % ((hour % 12).nonzero? or 12) # AR,TZ,GL
+ when '%M'; o << '%02d' % min
+ when '%m'; o << '%02d' % mon
+ when '%n'; o << "\n" # P2,ID
+ when '%P'; o << if hour < 12 then 'am' else 'pm' end # GL
+ when '%p'; o << if hour < 12 then 'AM' else 'PM' end
+ when '%R'; o << strftime('%H:%M') # ID
+ when '%r'; o << strftime('%I:%M:%S %p') # P2,ID
+ when '%S'; o << '%02d' % sec
+ when '%s' # TZ,GL
+ d = ajd - self.class.jd_to_ajd(self.class.civil_to_jd(1970,1,1), 0)
+ s = (d * 86400).to_i
+ o << '%d' % s
+ when '%T'; o << strftime('%H:%M:%S') # P2,ID
+ when '%t'; o << "\t" # P2,ID
+ when '%U', '%W'
+ a = self.class.civil_to_jd(year, 1, 1, ns?) + 6
+ k = if c == '%U' then 0 else 1 end
+ w = (jd - (a - ((a - k) + 1) % 7) + 7) / 7
+ o << '%02d' % w
+ when '%u'; o << '%d' % cwday # P2,ID
+ when '%V'; o << '%02d' % cweek # P2,ID
+ when '%v'; o << strftime('%e-%b-%Y') # AR,TZ
+ when '%w'; o << '%d' % wday
+ when '%X'; o << strftime('%H:%M:%S')
+ when '%x'; o << strftime('%m/%d/%y')
+ when '%Y'; o << '%.4d' % year
+ when '%y'; o << '%02d' % (year % 100)
+ when '%Z'; o << (if offset.zero? then 'Z' else strftime('%z') end)
+ when '%z' # ID
+ o << if offset < 0 then '-' else '+' end
+ of = offset.abs
+ hh, fr = of.divmod(1.to_r/24)
+ mm = fr / (1.to_r/1440)
+ o << '%02d' % hh
+ o << '%02d' % mm
+ when '%%'; o << '%'
+ when '%+'; o << strftime('%a %b %e %H:%M:%S %Z %Y') # TZ
+=begin
+ when '%.'
+ o << '%06d' % (sec_fraction / (1.to_r/86400/(10**6)))
+=end
+ when '%1'; o << '%d' % jd
+ when '%2'; o << strftime('%Y-%j')
+ when '%3'; o << strftime('%Y-%m-%d')
+ else; o << c
+ end
+ end
+ o
+ end
+
+# alias_method :format, :strftime
+
+ def asctime() strftime('%c') end
+
+ alias_method :ctime, :asctime
+
+end
+
+class DateTime < Date
+
+ def self._strptime(str, fmt='%FT%T%Z')
+ super(str, fmt)
+ end
+
+ def strftime(fmt='%FT%T%Z')
+ super(fmt)
+ end
+
+end
diff --git a/lib/debug.rb b/lib/debug.rb
index 220b68d2c9..1b12188a76 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -1,5 +1,6 @@
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
# Copyright (C) 2000 Information-technology Promotion Agency, Japan
+# Copyright (C) 2000-2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
if $SAFE > 0
STDERR.print "-r debug.rb is not available in safe mode\n"
@@ -7,6 +8,7 @@ if $SAFE > 0
end
require 'tracer'
+require 'pp'
class Tracer
def Tracer.trace_func(*vars)
@@ -17,203 +19,219 @@ end
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
class DEBUGGER__
- class Mutex
- def initialize
- @locker = nil
- @waiting = []
- @locked = false;
- end
+class Mutex
+ def initialize
+ @locker = nil
+ @waiting = []
+ @locked = false;
+ end
- def locked?
- @locked
- end
+ def locked?
+ @locked
+ end
- def lock
- return if @locker == Thread.current
- while (Thread.critical = true; @locked)
- @waiting.push Thread.current
- Thread.stop
- end
- @locked = true
- @locker = Thread.current
- Thread.critical = false
- self
- end
+ def lock
+ return if Thread.critical
+ return if @locker == Thread.current
+ while (Thread.critical = true; @locked)
+ @waiting.push Thread.current
+ Thread.stop
+ end
+ @locked = true
+ @locker = Thread.current
+ Thread.critical = false
+ self
+ end
- def unlock
- return unless @locked
- unless @locker == Thread.current
- raise RuntimeError, "unlocked by other"
- end
- Thread.critical = true
- t = @waiting.shift
- @locked = false
- @locker = nil
- Thread.critical = false
- t.run if t
- self
- end
+ def unlock
+ return if Thread.critical
+ return unless @locked
+ unless @locker == Thread.current
+ raise RuntimeError, "unlocked by other"
+ end
+ Thread.critical = true
+ t = @waiting.shift
+ @locked = false
+ @locker = nil
+ Thread.critical = false
+ t.run if t
+ self
+ end
+end
+MUTEX = Mutex.new
+
+class Context
+ DEBUG_LAST_CMD = []
+
+ begin
+ require 'readline'
+ def readline(prompt, hist)
+ Readline::readline(prompt, hist)
+ end
+ rescue LoadError
+ def readline(prompt, hist)
+ STDOUT.print prompt
+ STDOUT.flush
+ line = STDIN.gets
+ exit unless line
+ line.chomp!
+ line
+ end
+ USE_READLINE = false
end
- MUTEX = Mutex.new
- class Context
- DEBUG_LAST_CMD = []
+ def initialize
+ if Thread.current == Thread.main
+ @stop_next = 1
+ else
+ @stop_next = 0
+ end
+ @last_file = nil
+ @file = nil
+ @line = nil
+ @no_step = nil
+ @frames = []
+ @finish_pos = 0
+ @trace = false
+ @catch = "StandardError"
+ @suspend_next = false
+ end
- begin
- require 'readline'
- def readline(prompt, hist)
- Readline::readline(prompt, hist)
- end
- rescue LoadError
- def readline(prompt, hist)
- STDOUT.print prompt
- STDOUT.flush
- line = STDIN.gets
- exit unless line
- line.chomp!
- line
- end
- USE_READLINE = false
- end
+ def stop_next(n=1)
+ @stop_next = n
+ end
- def initialize
- if Thread.current == Thread.main
- @stop_next = 1
- else
- @stop_next = 0
- end
- @last_file = nil
- @last = [nil, nil]
- @file = nil
- @line = nil
- @no_step = nil
- @frames = []
- @finish_pos = 0
- @trace = false
- @catch = "StandardError"
- @suspend_next = false
- end
+ def set_suspend
+ @suspend_next = true
+ end
- def stop_next(n=1)
- @stop_next = n
- end
+ def clear_suspend
+ @suspend_next = false
+ end
- def set_suspend
- @suspend_next = true
- end
+ def suspend_all
+ DEBUGGER__.suspend
+ end
- def clear_suspend
+ def resume_all
+ DEBUGGER__.resume
+ end
+
+ def check_suspend
+ return if Thread.critical
+ while (Thread.critical = true; @suspend_next)
+ DEBUGGER__.waiting.push Thread.current
@suspend_next = false
+ Thread.stop
end
+ Thread.critical = false
+ end
- def suspend_all
- DEBUGGER__.suspend
- end
+ def trace?
+ @trace
+ end
- def resume_all
- DEBUGGER__.resume
- end
+ def set_trace(arg)
+ @trace = arg
+ end
- def check_suspend
- while (Thread.critical = true; @suspend_next)
- DEBUGGER__.waiting.push Thread.current
- @suspend_next = false
- Thread.stop
- end
- Thread.critical = false
- end
+ def stdout
+ DEBUGGER__.stdout
+ end
- def trace?
- @trace
- end
+ def break_points
+ DEBUGGER__.break_points
+ end
- def set_trace(arg)
- @trace = arg
- end
+ def display
+ DEBUGGER__.display
+ end
- def stdout
- DEBUGGER__.stdout
- end
+ def context(th)
+ DEBUGGER__.context(th)
+ end
- def break_points
- DEBUGGER__.break_points
- end
+ def set_trace_all(arg)
+ DEBUGGER__.set_trace(arg)
+ end
- def display
- DEBUGGER__.display
- end
+ def set_last_thread(th)
+ DEBUGGER__.set_last_thread(th)
+ end
- def context(th)
- DEBUGGER__.context(th)
+ def debug_eval(str, binding)
+ begin
+ val = eval(str, binding)
+ rescue StandardError, ScriptError => e
+ at = eval("caller(1)", binding)
+ stdout.printf "%s:%s\n", at.shift, e.to_s.sub(/\(eval\):1:(in `.*?':)?/, '')
+ for i in at
+ stdout.printf "\tfrom %s\n", i
+ end
+ throw :debug_error
end
+ end
- def set_trace_all(arg)
- DEBUGGER__.set_trace(arg)
+ def debug_silent_eval(str, binding)
+ begin
+ eval(str, binding)
+ rescue StandardError, ScriptError
+ nil
end
+ end
- def set_last_thread(th)
- DEBUGGER__.set_last_thread(th)
+ def var_list(ary, binding)
+ ary.sort!
+ for v in ary
+ stdout.printf " %s => %s\n", v, eval(v, binding).inspect
end
+ end
- def debug_eval(str, binding)
- begin
- val = eval(str, binding)
- val
- rescue StandardError, ScriptError
- at = eval("caller(0)", binding)
- stdout.printf "%s:%s\n", at.shift, $!.to_s.sub(/\(eval\):1:(in `.*?':)?/, '') #`
- for i in at
- stdout.printf "\tfrom %s\n", i
- end
- throw :debug_error
- end
- end
+ def debug_variable_info(input, binding)
+ case input
+ when /^\s*g(?:lobal)?\s*$/
+ var_list(global_variables, binding)
- def debug_silent_eval(str, binding)
- begin
- val = eval(str, binding)
- val
- rescue StandardError, ScriptError
- nil
- end
- end
+ when /^\s*l(?:ocal)?\s*$/
+ var_list(eval("local_variables", binding), binding)
- def var_list(ary, binding)
- ary.sort!
- for v in ary
- stdout.printf " %s => %s\n", v, eval(v, binding).inspect
+ when /^\s*i(?:nstance)?\s+/
+ obj = debug_eval($', binding)
+ var_list(obj.instance_variables, obj.instance_eval{binding()})
+
+ when /^\s*c(?:onst(?:ant)?)?\s+/
+ obj = debug_eval($', binding)
+ unless obj.kind_of? Module
+ stdout.print "Should be Class/Module: ", $', "\n"
+ else
+ var_list(obj.constants, obj.module_eval{binding()})
end
end
+ end
- def debug_variable_info(input, binding)
- case input
- when /^\s*g(?:lobal)?$/
- var_list(global_variables, binding)
-
- when /^\s*l(?:ocal)?$/
- var_list(eval("local_variables", binding), binding)
-
- when /^\s*i(?:nstance)?\s+/
- obj = debug_eval($', binding)
- var_list(obj.instance_variables, binding)
+ def debug_method_info(input, binding)
+ case input
+ when /^i(:?nstance)?\s+/
+ obj = debug_eval($', binding)
- when /^\s*c(?:onst(?:ant)?)?\s+/
- obj = debug_eval($', binding)
- unless obj.kind_of? Module
- stdout.print "Should be Class/Module: ", $', "\n"
- else
- var_list(obj.constants, obj.module_eval{binding()})
+ len = 0
+ for v in obj.methods.sort
+ len += v.size + 1
+ if len > 70
+ len = v.size + 1
+ stdout.print "\n"
end
+ stdout.print v, " "
end
- end
-
- def debug_method_info(input, binding)
- case input
- when /^i(:?nstance)?\s+/
- obj = debug_eval($', binding)
+ stdout.print "\n"
+ else
+ obj = debug_eval(input, binding)
+ unless obj.kind_of? Module
+ stdout.print "Should be Class/Module: ", input, "\n"
+ else
len = 0
- for v in obj.methods.sort
+ for v in obj.instance_methods(false).sort
len += v.size + 1
if len > 70
len = v.size + 1
@@ -222,320 +240,315 @@ class DEBUGGER__
stdout.print v, " "
end
stdout.print "\n"
-
- else
- obj = debug_eval(input, binding)
- unless obj.kind_of? Module
- stdout.print "Should be Class/Module: ", input, "\n"
- else
- len = 0
- for v in obj.instance_methods.sort
- len += v.size + 1
- if len > 70
- len = v.size + 1
- stdout.print "\n"
- end
- stdout.print v, " "
- end
- stdout.print "\n"
- end
end
end
+ end
- def thnum
+ def thnum
+ num = DEBUGGER__.instance_eval{@thread_list[Thread.current]}
+ unless num
+ DEBUGGER__.make_thread_list
num = DEBUGGER__.instance_eval{@thread_list[Thread.current]}
- unless num
- DEBUGGER__.make_thread_list
- num = DEBUGGER__.instance_eval{@thread_list[Thread.current]}
- end
- num
- end
-
- def debug_command(file, line, id, binding)
- MUTEX.lock
- set_last_thread(Thread.current)
- frame_pos = 0
- binding_file = file
- binding_line = line
- previous_line = nil
- if (ENV['EMACS'] == 't')
- stdout.printf "\032\032%s:%d:\n", binding_file, binding_line
- else
- stdout.printf "%s:%d:%s", binding_file, binding_line,
- line_at(binding_file, binding_line)
- end
- @frames[0] = [binding, file, line, id]
- display_expressions(binding)
- prompt = true
- while prompt and input = readline("(rdb:%d) "%thnum(), true)
- catch(:debug_error) do
- if input == ""
- input = DEBUG_LAST_CMD[0]
- stdout.print input, "\n"
+ end
+ num
+ end
+
+ def debug_command(file, line, id, binding)
+ MUTEX.lock
+ set_last_thread(Thread.current)
+ frame_pos = 0
+ binding_file = file
+ binding_line = line
+ previous_line = nil
+ if ENV['EMACS']
+ stdout.printf "\032\032%s:%d:\n", binding_file, binding_line
+ else
+ stdout.printf "%s:%d:%s", binding_file, binding_line,
+ line_at(binding_file, binding_line)
+ end
+ @frames[0] = [binding, file, line, id]
+ display_expressions(binding)
+ prompt = true
+ while prompt and input = readline("(rdb:%d) "%thnum(), true)
+ catch(:debug_error) do
+ if input == ""
+ next unless DEBUG_LAST_CMD[0]
+ input = DEBUG_LAST_CMD[0]
+ stdout.print input, "\n"
+ else
+ DEBUG_LAST_CMD[0] = input
+ end
+
+ case input
+ when /^\s*tr(?:ace)?(?:\s+(on|off))?(?:\s+(all))?$/
+ if defined?( $2 )
+ if $1 == 'on'
+ set_trace_all true
+ else
+ set_trace_all false
+ end
+ elsif defined?( $1 )
+ if $1 == 'on'
+ set_trace true
+ else
+ set_trace false
+ end
+ end
+ if trace?
+ stdout.print "Trace on.\n"
+ else
+ stdout.print "Trace off.\n"
+ end
+
+ when /^\s*b(?:reak)?\s+(?:(.+):)?([^.:]+)$/
+ pos = $2
+ if $1
+ klass = debug_silent_eval($1, binding)
+ file = $1
+ end
+ if pos =~ /^\d+$/
+ pname = pos
+ pos = pos.to_i
else
- DEBUG_LAST_CMD[0] = input
+ pname = pos = pos.intern.id2name
end
-
- case input
- when /^\s*tr(?:ace)?(?:\s+(on|off))?(?:\s+(all))?$/
- if defined?( $2 )
- if $1 == 'on'
- set_trace_all true
- else
- set_trace_all false
- end
- elsif defined?( $1 )
- if $1 == 'on'
- set_trace true
- else
- set_trace false
+ break_points.push [true, 0, klass || file, pos]
+ stdout.printf "Set breakpoint %d at %s:%s\n", break_points.size, klass || file, pname
+
+ when /^\s*b(?:reak)?\s+(.+)[#.]([^.:]+)$/
+ pos = $2.intern.id2name
+ klass = debug_eval($1, binding)
+ break_points.push [true, 0, klass, pos]
+ stdout.printf "Set breakpoint %d at %s.%s\n", break_points.size, klass, pos
+
+ when /^\s*wat(?:ch)?\s+(.+)$/
+ exp = $1
+ break_points.push [true, 1, exp]
+ stdout.printf "Set watchpoint %d\n", break_points.size, exp
+
+ when /^\s*b(?:reak)?$/
+ if break_points.find{|b| b[1] == 0}
+ n = 1
+ stdout.print "Breakpoints:\n"
+ for b in break_points
+ if b[0] and b[1] == 0
+ stdout.printf " %d %s:%s\n", n, b[2], b[3]
end
+ n += 1
end
- if trace?
- stdout.print "Trace on.\n"
- else
- stdout.print "Trace off.\n"
- end
-
- when /^\s*b(?:reak)?\s+((?:.*?+:)?.+)$/
- pos = $1
- if pos.index(":")
- file, pos = pos.split(":")
- end
- file = File.basename(file)
- if pos =~ /^\d+$/
- pname = pos
- pos = pos.to_i
- else
- pname = pos = pos.intern.id2name
- end
- break_points.push [true, 0, file, pos]
- stdout.printf "Set breakpoint %d at %s:%s\n", break_points.size, file, pname
-
- when /^\s*wat(?:ch)?\s+(.+)$/
- exp = $1
- break_points.push [true, 1, exp]
- stdout.printf "Set watchpoint %d\n", break_points.size, exp
-
- when /^\s*b(?:reak)?$/
- if break_points.find{|b| b[1] == 0}
- n = 1
- stdout.print "Breakpoints:\n"
- for b in break_points
- if b[0] and b[1] == 0
- stdout.printf " %d %s:%s\n", n, b[2], b[3]
- end
- n += 1
+ end
+ if break_points.find{|b| b[1] == 1}
+ n = 1
+ stdout.print "\n"
+ stdout.print "Watchpoints:\n"
+ for b in break_points
+ if b[0] and b[1] == 1
+ stdout.printf " %d %s\n", n, b[2]
end
+ n += 1
end
- if break_points.find{|b| b[1] == 1}
- n = 1
- stdout.print "\n"
- stdout.print "Watchpoints:\n"
+ end
+ if break_points.size == 0
+ stdout.print "No breakpoints\n"
+ else
+ stdout.print "\n"
+ end
+
+ when /^\s*del(?:ete)?(?:\s+(\d+))?$/
+ pos = $1
+ unless pos
+ input = readline("Clear all breakpoints? (y/n) ", false)
+ if input == "y"
for b in break_points
- if b[0] and b[1] == 1
- stdout.printf " %d %s\n", n, b[2]
- end
- n += 1
+ b[0] = false
end
end
- if break_points.size == 0
- stdout.print "No breakpoints\n"
+ else
+ pos = pos.to_i
+ if break_points[pos-1]
+ break_points[pos-1][0] = false
else
- stdout.print "\n"
+ stdout.printf "Breakpoint %d is not defined\n", pos
end
+ end
- when /^\s*del(?:ete)?(?:\s+(\d+))?$/
- pos = $1
- unless pos
- input = readline("Clear all breakpoints? (y/n) ", false)
- if input == "y"
- for b in break_points
- b[0] = false
- end
- end
- else
- pos = pos.to_i
- if break_points[pos-1]
- break_points[pos-1][0] = false
- else
- stdout.printf "Breakpoint %d is not defined\n", pos
- end
- end
+ when /^\s*disp(?:lay)?\s+(.+)$/
+ exp = $1
+ display.push [true, exp]
+ stdout.printf "%d: ", display.size
+ display_expression(exp, binding)
- when /^\s*disp(?:lay)?\s+(.+)$/
- exp = $1
- display.push [true, exp]
- stdout.printf "%d: ", display.size
- display_expression(exp, binding)
-
- when /^\s*disp(?:lay)?$/
- display_expressions(binding)
-
- when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
- pos = $1
- unless pos
- input = readline("Clear all expressions? (y/n) ", false)
- if input == "y"
- for d in display
- d[0] = false
- end
+ when /^\s*disp(?:lay)?$/
+ display_expressions(binding)
+
+ when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
+ pos = $1
+ unless pos
+ input = readline("Clear all expressions? (y/n) ", false)
+ if input == "y"
+ for d in display
+ d[0] = false
end
+ end
+ else
+ pos = pos.to_i
+ if display[pos-1]
+ display[pos-1][0] = false
else
- pos = pos.to_i
- if display[pos-1]
- display[pos-1][0] = false
- else
- stdout.printf "Display expression %d is not defined\n", pos
- end
+ stdout.printf "Display expression %d is not defined\n", pos
end
+ end
- when /^\s*c(?:ont)?$/
- prompt = false
+ when /^\s*c(?:ont)?$/
+ prompt = false
- when /^\s*s(?:tep)?(?:\s+(\d+))?$/
- if $1
- lev = $1.to_i
- else
- lev = 1
- end
- @stop_next = lev
- prompt = false
+ when /^\s*s(?:tep)?(?:\s+(\d+))?$/
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ @stop_next = lev
+ prompt = false
- when /^\s*n(?:ext)?(?:\s+(\d+))?$/
- if $1
- lev = $1.to_i
+ when /^\s*n(?:ext)?(?:\s+(\d+))?$/
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ @stop_next = lev
+ @no_step = @frames.size - frame_pos
+ prompt = false
+
+ when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
+ display_frames(frame_pos)
+
+ when /^\s*l(?:ist)?(?:\s+(.+))?$/
+ if not $1
+ b = previous_line ? previous_line + 10 : binding_line - 5
+ e = b + 9
+ elsif $1 == '-'
+ b = previous_line ? previous_line - 10 : binding_line - 5
+ e = b + 9
+ else
+ b, e = $1.split(/[-,]/)
+ if e
+ b = b.to_i
+ e = e.to_i
else
- lev = 1
+ b = b.to_i - 5
+ e = b + 9
end
- @stop_next = lev
- @no_step = @frames.size - frame_pos
- prompt = false
+ end
+ previous_line = b
+ display_list(b, e, binding_file, binding_line)
- when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
- display_frames(frame_pos)
+ when /^\s*up(?:\s+(\d+))?$/
+ previous_line = nil
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ frame_pos += lev
+ if frame_pos >= @frames.size
+ frame_pos = @frames.size - 1
+ stdout.print "At toplevel\n"
+ end
+ binding, binding_file, binding_line = @frames[frame_pos]
+ stdout.print format_frame(frame_pos)
- when /^\s*l(?:ist)?(?:\s+(.+))?$/
- if not $1
- b = previous_line ? previous_line + 10 : binding_line - 5
- e = b + 9
- elsif $1 == '-'
- b = previous_line ? previous_line - 10 : binding_line - 5
- e = b + 9
- else
- b, e = $1.split(/[-,]/)
- if e
- b = b.to_i
- e = e.to_i
- else
- b = b.to_i - 5
- e = b + 9
- end
- end
- previous_line = b
- display_list(b, e, binding_file, binding_line)
+ when /^\s*down(?:\s+(\d+))?$/
+ previous_line = nil
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ frame_pos -= lev
+ if frame_pos < 0
+ frame_pos = 0
+ stdout.print "At stack bottom\n"
+ end
+ binding, binding_file, binding_line = @frames[frame_pos]
+ stdout.print format_frame(frame_pos)
- when /^\s*up(?:\s+(\d+))?$/
- previous_line = nil
- if $1
- lev = $1.to_i
- else
- lev = 1
- end
- frame_pos += lev
- if frame_pos >= @frames.size
- frame_pos = @frames.size - 1
- stdout.print "At toplevel\n"
- end
- binding, binding_file, binding_line = @frames[frame_pos]
- stdout.printf "#%d %s:%s\n", frame_pos, binding_file, binding_line
+ when /^\s*fin(?:ish)?$/
+ if frame_pos == @frames.size
+ stdout.print "\"finish\" not meaningful in the outermost frame.\n"
+ else
+ @finish_pos = @frames.size - frame_pos
+ frame_pos = 0
+ prompt = false
+ end
- when /^\s*down(?:\s+(\d+))?$/
- previous_line = nil
- if $1
- lev = $1.to_i
+ when /^\s*cat(?:ch)?(?:\s+(.+))?$/
+ if $1
+ excn = $1
+ if excn == 'off'
+ @catch = nil
+ stdout.print "Clear catchpoint.\n"
else
- lev = 1
+ @catch = excn
+ stdout.printf "Set catchpoint %s.\n", @catch
end
- frame_pos -= lev
- if frame_pos < 0
- frame_pos = 0
- stdout.print "At stack bottom\n"
- end
- binding, binding_file, binding_line = @frames[frame_pos]
- stdout.printf "#%d %s:%s\n", frame_pos, binding_file, binding_line
-
- when /^\s*fin(?:ish)?$/
- if frame_pos == @frames.size
- stdout.print "\"finish\" not meaningful in the outermost frame.\n"
+ else
+ if @catch
+ stdout.printf "Catchpoint %s.\n", @catch
else
- @finish_pos = @frames.size - frame_pos
- frame_pos = 0
- prompt = false
+ stdout.print "No catchpoint.\n"
end
+ end
- when /^\s*cat(?:ch)?(?:\s+(.+))?$/
- if $1
- excn = $1
- if excn == 'off'
- @catch = nil
- stdout.print "Clear catchpoint.\n"
- else
- @catch = excn
- stdout.printf "Set catchpoint %s.\n", @catch
- end
- else
- if @catch
- stdout.printf "Catchpoint %s.\n", @catch
- else
- stdout.print "No catchpoint.\n"
- end
- end
+ when /^\s*q(?:uit)?$/
+ input = readline("Really quit? (y/n) ", false)
+ if input == "y"
+ exit! # exit -> exit!: No graceful way to stop threads...
+ end
- when /^\s*q(?:uit)?$/
- input = readline("Really quit? (y/n) ", false)
- if input == "y"
- exit! # exit -> exit!: No graceful way to stop threads...
- end
+ when /^\s*v(?:ar)?\s+/
+ debug_variable_info($', binding)
- when /^\s*v(?:ar)?\s+/
- debug_variable_info($', binding)
+ when /^\s*m(?:ethod)?\s+/
+ debug_method_info($', binding)
- when /^\s*m(?:ethod)?\s+/
- debug_method_info($', binding)
+ when /^\s*th(?:read)?\s+/
+ if DEBUGGER__.debug_thread_info($', binding) == :cont
+ prompt = false
+ end
- when /^\s*th(?:read)?\s+/
- if DEBUGGER__.debug_thread_info($', binding) == :cont
- prompt = false
- end
+ when /^\s*pp\s+/
+ PP.pp(debug_eval($', binding), stdout)
- when /^\s*p\s+/
- stdout.printf "%s\n", debug_eval($', binding).inspect
+ when /^\s*p\s+/
+ stdout.printf "%s\n", debug_eval($', binding).inspect
- when /^\s*h(?:elp)?$/
- debug_print_help()
+ when /^\s*h(?:elp)?$/
+ debug_print_help()
- else
- v = debug_eval(input, binding)
- stdout.printf "%s\n", v.inspect unless (v == nil)
- end
+ else
+ v = debug_eval(input, binding)
+ stdout.printf "%s\n", v.inspect
end
end
- MUTEX.unlock
- resume_all
end
+ MUTEX.unlock
+ resume_all
+ end
- def debug_print_help
- stdout.print <<EOHELP
+ def debug_print_help
+ stdout.print <<EOHELP
Debugger help v.-0.002b
Commands
- b[reak] [file|method:]<line|method>
+ b[reak] [file|class:]<line|method>
+ b[reak] [class.]<line|method>
set breakpoint to some position
wat[ch] <expression> set watchpoint to some expression
cat[ch] <an Exception> set catchpoint to an exception
b[reak] list breakpoints
cat[ch] show catchpoint
- del[ele][ nnn] delete some or all breakpoints
+ del[ete][ nnn] delete some or all breakpoints
disp[lay] <expression> add expression into display expression list
undisp[lay][ nnn] delete one particular or all display expressions
c[ont] run until program ends or hit breakpoint
@@ -566,360 +579,363 @@ Commands
h[elp] print this help
<everything else> evaluate
EOHELP
- end
-
- def display_expressions(binding)
- n = 1
- for d in display
- if d[0]
- stdout.printf "%d: ", n
- display_expression(d[1], binding)
- end
- n += 1
+ end
+
+ def display_expressions(binding)
+ n = 1
+ for d in display
+ if d[0]
+ stdout.printf "%d: ", n
+ display_expression(d[1], binding)
end
+ n += 1
end
+ end
- def display_expression(exp, binding)
- stdout.printf "%s = %s\n", exp, debug_silent_eval(exp, binding).to_s
- end
+ def display_expression(exp, binding)
+ stdout.printf "%s = %s\n", exp, debug_silent_eval(exp, binding).to_s
+ end
- def frame_set_pos(file, line)
- if @frames[0]
- @frames[0][1] = file
- @frames[0][2] = line
- end
+ def frame_set_pos(file, line)
+ if @frames[0]
+ @frames[0][1] = file
+ @frames[0][2] = line
end
+ end
- def display_frames(pos)
- pos += 1
- n = 0
- at = @frames
- for bind, file, line, id in at
- n += 1
- break unless bind
- if pos == n
- stdout.printf "--> #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
- else
- stdout.printf " #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
- end
+ def display_frames(pos)
+ 0.upto(@frames.size - 1) do |n|
+ if n == pos
+ stdout.print "--> "
+ else
+ stdout.print " "
end
+ stdout.print format_frame(n)
end
+ end
- def display_list(b, e, file, line)
- stdout.printf "[%d, %d] in %s\n", b, e, file
- if lines = SCRIPT_LINES__[file] and lines != true
- n = 0
- b.upto(e) do |n|
- if n > 0 && lines[n-1]
- if n == line
- stdout.printf "=> %d %s\n", n, lines[n-1].chomp
- else
- stdout.printf " %d %s\n", n, lines[n-1].chomp
- end
+ def format_frame(pos)
+ bind, file, line, id = @frames[pos]
+ sprintf "#%d %s:%s%s\n", pos + 1, file, line,
+ (id ? ":in `#{id.id2name}'" : "")
+ end
+
+ def display_list(b, e, file, line)
+ stdout.printf "[%d, %d] in %s\n", b, e, file
+ if lines = SCRIPT_LINES__[file] and lines != true
+ n = 0
+ b.upto(e) do |n|
+ if n > 0 && lines[n-1]
+ if n == line
+ stdout.printf "=> %d %s\n", n, lines[n-1].chomp
+ else
+ stdout.printf " %d %s\n", n, lines[n-1].chomp
end
end
- else
- stdout.printf "No sourcefile available for %s\n", file
end
+ else
+ stdout.printf "No sourcefile available for %s\n", file
end
+ end
- def line_at(file, line)
- lines = SCRIPT_LINES__[file]
- if lines
- return "\n" if lines == true
- line = lines[line-1]
- return "\n" unless line
- return line
- end
- return "\n"
+ def line_at(file, line)
+ lines = SCRIPT_LINES__[file]
+ if lines
+ return "\n" if lines == true
+ line = lines[line-1]
+ return "\n" unless line
+ return line
end
+ return "\n"
+ end
- def debug_funcname(id)
- if id.nil?
- "toplevel"
- else
- id.id2name
- end
+ def debug_funcname(id)
+ if id.nil?
+ "toplevel"
+ else
+ id.id2name
end
+ end
- def check_break_points(file, pos, binding, id)
- return false if break_points.empty?
- file = File.basename(file)
- n = 1
- for b in break_points
- if b[0]
- if b[1] == 0 and b[2] == file and b[3] == pos
+ def check_break_points(file, klass, pos, binding, id)
+ return false if break_points.empty?
+ n = 1
+ for b in break_points
+ if b[0] # valid
+ if b[1] == 0 # breakpoint
+ if (b[2] == file and b[3] == pos) or
+ (klass and b[2] == klass and b[3] == pos)
stdout.printf "Breakpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
return true
- elsif b[1] == 1
- if debug_silent_eval(b[2], binding)
- stdout.printf "Watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
- return true
- end
+ end
+ elsif b[1] == 1 # watchpoint
+ if debug_silent_eval(b[2], binding)
+ stdout.printf "Watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
+ return true
end
end
- n += 1
end
- return false
+ n += 1
end
+ return false
+ end
- def excn_handle(file, line, id, binding)
- stdout.printf "%s:%d: `%s' (%s)\n", file, line, $!, $!.type
- if $!.type <= SystemExit
- set_trace_func nil
- exit
- end
+ def excn_handle(file, line, id, binding)
+ if $!.class <= SystemExit
+ set_trace_func nil
+ exit
+ end
- if @catch and ($!.type.ancestors.find { |e| e.to_s == @catch })
- fs = @frames.size
- tb = caller(0)[-fs..-1]
- if tb
- for i in tb
- stdout.printf "\tfrom %s\n", i
- end
+ if @catch and ($!.class.ancestors.find { |e| e.to_s == @catch })
+ stdout.printf "%s:%d: `%s' (%s)\n", file, line, $!, $!.class
+ fs = @frames.size
+ tb = caller(0)[-fs..-1]
+ if tb
+ for i in tb
+ stdout.printf "\tfrom %s\n", i
end
- suspend_all
- debug_command(file, line, id, binding)
end
+ suspend_all
+ debug_command(file, line, id, binding)
end
+ end
- def trace_func(event, file, line, id, binding, klass)
- Tracer.trace_func(event, file, line, id, binding, klass) if trace?
- context(Thread.current).check_suspend
- @file = file
- @line = line
- case event
- when 'line'
- frame_set_pos(file, line)
- if !@no_step or @frames.size == @no_step
- @stop_next -= 1
- elsif @frames.size < @no_step
- @stop_next = 0 # break here before leaving...
- else
- # nothing to do. skipped.
- end
- if @stop_next == 0 or check_break_points(file, line, binding, id)
- if [file, line] == @last
- @stop_next = 1
- else
- @no_step = nil
- suspend_all
- debug_command(file, line, id, binding)
- @last = [file, line]
- end
- end
+ def trace_func(event, file, line, id, binding, klass)
+ Tracer.trace_func(event, file, line, id, binding, klass) if trace?
+ context(Thread.current).check_suspend
+ @file = file
+ @line = line
+ case event
+ when 'line'
+ frame_set_pos(file, line)
+ if !@no_step or @frames.size == @no_step
+ @stop_next -= 1
+ @stop_next = -1 if @stop_next < 0
+ elsif @frames.size < @no_step
+ @stop_next = 0 # break here before leaving...
+ else
+ # nothing to do. skipped.
+ end
+ if @stop_next == 0 or check_break_points(file, nil, line, binding, id)
+ @no_step = nil
+ suspend_all
+ debug_command(file, line, id, binding)
+ end
- when 'call'
- @frames.unshift [binding, file, line, id]
- if check_break_points(file, id.id2name, binding, id) or
- check_break_points(klass.to_s, id.id2name, binding, id)
- suspend_all
- debug_command(file, line, id, binding)
- end
+ when 'call'
+ @frames.unshift [binding, file, line, id]
+ if check_break_points(file, klass, id.id2name, binding, id)
+ suspend_all
+ debug_command(file, line, id, binding)
+ end
- when 'c-call'
- frame_set_pos(file, line)
+ when 'c-call'
+ frame_set_pos(file, line)
- when 'class'
- @frames.unshift [binding, file, line, id]
+ when 'class'
+ @frames.unshift [binding, file, line, id]
- when 'return', 'end'
- if @frames.size == @finish_pos
- @stop_next = 1
- @finish_pos = 0
- end
- @frames.shift
+ when 'return', 'end'
+ if @frames.size == @finish_pos
+ @stop_next = 1
+ @finish_pos = 0
+ end
+ @frames.shift
- when 'end'
- @frames.shift
+ when 'end'
+ @frames.shift
- when 'raise'
- excn_handle(file, line, id, binding)
+ when 'raise'
+ excn_handle(file, line, id, binding)
- end
- @last_file = file
end
+ @last_file = file
end
+end
- trap("INT") { DEBUGGER__.interrupt }
- @last_thread = Thread::main
- @max_thread = 1
- @thread_list = {Thread::main => 1}
- @break_points = []
- @display = []
- @waiting = []
- @stdout = STDOUT
+trap("INT") { DEBUGGER__.interrupt }
+@last_thread = Thread::main
+@max_thread = 1
+@thread_list = {Thread::main => 1}
+@break_points = []
+@display = []
+@waiting = []
+@stdout = STDOUT
+
+class << DEBUGGER__
+ def stdout
+ @stdout
+ end
- class <<DEBUGGER__
- def stdout
- @stdout
- end
+ def stdout=(s)
+ @stdout = s
+ end
- def stdout=(s)
- @stdout = s
- end
+ def display
+ @display
+ end
- def display
- @display
- end
+ def break_points
+ @break_points
+ end
- def break_points
- @break_points
- end
+ def waiting
+ @waiting
+ end
- def waiting
- @waiting
+ def set_trace( arg )
+ saved_crit = Thread.critical
+ Thread.critical = true
+ make_thread_list
+ for th, in @thread_list
+ context(th).set_trace arg
end
+ Thread.critical = saved_crit
+ arg
+ end
- def set_trace( arg )
- Thread.critical = true
- make_thread_list
- for th in @thread_list
- context(th[0]).set_trace arg
- end
- Thread.critical = false
- end
+ def set_last_thread(th)
+ @last_thread = th
+ end
- def set_last_thread(th)
- @last_thread = th
- end
+ def suspend
+ saved_crit = Thread.critical
+ Thread.critical = true
+ make_thread_list
+ for th, in @thread_list
+ next if th == Thread.current
+ context(th).set_suspend
+ end
+ Thread.critical = saved_crit
+ # Schedule other threads to suspend as soon as possible.
+ Thread.pass unless Thread.critical
+ end
- def suspend
- Thread.critical = true
- make_thread_list
- for th in @thread_list
- next if th[0] == Thread.current
- context(th[0]).set_suspend
- end
- Thread.critical = false
- # Schedule other threads to suspend as soon as possible.
- Thread.pass
- end
+ def resume
+ saved_crit = Thread.critical
+ Thread.critical = true
+ make_thread_list
+ for th, in @thread_list
+ next if th == Thread.current
+ context(th).clear_suspend
+ end
+ waiting.each do |th|
+ th.run
+ end
+ waiting.clear
+ Thread.critical = saved_crit
+ # Schedule other threads to restart as soon as possible.
+ Thread.pass
+ end
- def resume
- Thread.critical = true
- make_thread_list
- for th in @thread_list
- next if th[0] == Thread.current
- context(th[0]).clear_suspend
- end
- waiting.each do |th|
- th.run
- end
- waiting.clear
- Thread.critical = false
- # Schedule other threads to restart as soon as possible.
- Thread.pass
+ def context(thread=Thread.current)
+ c = thread[:__debugger_data__]
+ unless c
+ thread[:__debugger_data__] = c = Context.new
end
+ c
+ end
- def context(thread=Thread.current)
- c = thread[:__debugger_data__]
- unless c
- thread[:__debugger_data__] = c = Context.new
- end
- c
- end
+ def interrupt
+ context(@last_thread).stop_next
+ end
- def interrupt
- context(@last_thread).stop_next
+ def get_thread(num)
+ th = @thread_list.index(num)
+ unless th
+ @stdout.print "No thread ##{num}\n"
+ throw :debug_error
end
+ th
+ end
- def get_thread(num)
- th = @thread_list.index(num)
- unless th
- @stdout.print "No thread ##{num}\n"
- throw :debug_error
- end
- th
+ def thread_list(num)
+ th = get_thread(num)
+ if th == Thread.current
+ @stdout.print "+"
+ else
+ @stdout.print " "
end
-
- def thread_list(num)
- th = get_thread(num)
- if th == Thread.current
- @stdout.print "+"
- else
- @stdout.print " "
- end
- @stdout.printf "%d ", num
- @stdout.print th.inspect, "\t"
- file = context(th).instance_eval{@file}
- if file
- @stdout.print file,":",context(th).instance_eval{@line}
- end
- @stdout.print "\n"
+ @stdout.printf "%d ", num
+ @stdout.print th.inspect, "\t"
+ file = context(th).instance_eval{@file}
+ if file
+ @stdout.print file,":",context(th).instance_eval{@line}
end
+ @stdout.print "\n"
+ end
- def thread_list_all
- for th in @thread_list.values.sort
- thread_list(th)
- end
+ def thread_list_all
+ for th in @thread_list.values.sort
+ thread_list(th)
end
+ end
- def make_thread_list
- hash = {}
- for th in Thread::list
- if @thread_list.key? th
- hash[th] = @thread_list[th]
- else
- @max_thread += 1
- hash[th] = @max_thread
- end
+ def make_thread_list
+ hash = {}
+ for th in Thread::list
+ if @thread_list.key? th
+ hash[th] = @thread_list[th]
+ else
+ @max_thread += 1
+ hash[th] = @max_thread
end
- @thread_list = hash
end
+ @thread_list = hash
+ end
- def debug_thread_info(input, binding)
- case input
- when /^l(?:ist)?/
- make_thread_list
- thread_list_all
+ def debug_thread_info(input, binding)
+ case input
+ when /^l(?:ist)?/
+ make_thread_list
+ thread_list_all
- when /^c(?:ur(?:rent)?)?$/
- make_thread_list
- thread_list(@thread_list[Thread.current])
+ when /^c(?:ur(?:rent)?)?$/
+ make_thread_list
+ thread_list(@thread_list[Thread.current])
- when /^(?:sw(?:itch)?\s+)?(\d+)/
- make_thread_list
- th = get_thread($1.to_i)
- if th == Thread.current
- @stdout.print "It's the current thread.\n"
- else
- thread_list(@thread_list[th])
- context(th).stop_next
- th.run
- return :cont
- end
+ when /^(?:sw(?:itch)?\s+)?(\d+)/
+ make_thread_list
+ th = get_thread($1.to_i)
+ if th == Thread.current
+ @stdout.print "It's the current thread.\n"
+ else
+ thread_list(@thread_list[th])
+ context(th).stop_next
+ th.run
+ return :cont
+ end
- when /^stop\s+(\d+)/
- make_thread_list
- th = get_thread($1.to_i)
- if th == Thread.current
- @stdout.print "It's the current thread.\n"
- elsif th.stop?
- @stdout.print "Already stopped.\n"
- else
- thread_list(@thread_list[th])
- context(th).suspend
- end
+ when /^stop\s+(\d+)/
+ make_thread_list
+ th = get_thread($1.to_i)
+ if th == Thread.current
+ @stdout.print "It's the current thread.\n"
+ elsif th.stop?
+ @stdout.print "Already stopped.\n"
+ else
+ thread_list(@thread_list[th])
+ context(th).suspend
+ end
- when /^resume\s+(\d+)/
- make_thread_list
- th = get_thread($1.to_i)
- if th == Thread.current
- @stdout.print "It's the current thread.\n"
- elsif !th.stop?
- @stdout.print "Already running."
- else
- thread_list(@thread_list[th])
- th.run
- end
+ when /^resume\s+(\d+)/
+ make_thread_list
+ th = get_thread($1.to_i)
+ if th == Thread.current
+ @stdout.print "It's the current thread.\n"
+ elsif !th.stop?
+ @stdout.print "Already running."
+ else
+ thread_list(@thread_list[th])
+ th.run
end
end
end
+end
- stdout.printf "Debug.rb\n"
- stdout.printf "Emacs support available.\n\n"
- set_trace_func proc { |event, file, line, id, binding, klass, *rest|
- DEBUGGER__.context.trace_func event, file, line, id, binding, klass
- }
+stdout.printf "Debug.rb\n"
+stdout.printf "Emacs support available.\n\n"
+set_trace_func proc { |event, file, line, id, binding, klass, *rest|
+ DEBUGGER__.context.trace_func event, file, line, id, binding, klass
+}
end
diff --git a/lib/delegate.rb b/lib/delegate.rb
index a72ea943ba..20e6b53c2e 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -19,49 +19,70 @@
class Delegator
def initialize(obj)
- preserved = ::Kernel.instance_methods
+ preserved = ::Kernel.public_instance_methods(false)
preserved -= ["to_s","to_a","inspect","==","=~","==="]
- for t in self.type.ancestors
- preserved |= t.instance_methods
- preserved |= t.private_instance_methods
- preserved |= t.protected_instance_methods
+ for t in self.class.ancestors
+ preserved |= t.public_instance_methods(false)
+ preserved |= t.private_instance_methods(false)
+ preserved |= t.protected_instance_methods(false)
break if t == Delegator
end
+ preserved << "singleton_method_added"
for method in obj.methods
next if preserved.include? method
- eval <<-EOS
- def self.#{method}(*args, &block)
- begin
- __getobj__.__send__(:#{method}, *args, &block)
- rescue Exception
- $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #`
- $@.delete_if{|s| /^\\(eval\\):/ =~ s}
- raise
+ begin
+ eval <<-EOS
+ def self.#{method}(*args, &block)
+ begin
+ __getobj__.__send__(:#{method}, *args, &block)
+ rescue Exception
+ $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #`
+ $@.delete_if{|s| /^\\(eval\\):/ =~ s}
+ Kernel::raise
+ end
end
- end
- EOS
+ EOS
+ rescue SyntaxError
+ raise NameError, "invalid identifier %s" % method, caller(4)
+ end
end
end
+ alias initialize_methods initialize
def __getobj__
- raise NotImplementError, "need to define `__getobj__'"
+ raise NotImplementedError, "need to define `__getobj__'"
end
+ def marshal_dump
+ __getobj__
+ end
+ def marshal_load(obj)
+ initialize_methods(obj)
+ end
end
class SimpleDelegator<Delegator
def initialize(obj)
super
- @obj = obj
+ @_sd_obj = obj
end
def __getobj__
- @obj
+ @_sd_obj
end
def __setobj__(obj)
- @obj = obj
+ @_sd_obj = obj
+ end
+
+ def clone(obj)
+ super
+ __setobj__(obj.__getobj__.clone)
+ end
+ def dup(obj)
+ super
+ __setobj__(obj.__getobj__.dup)
end
end
@@ -72,28 +93,52 @@ SimpleDelegater = SimpleDelegator
#
def DelegateClass(superclass)
klass = Class.new
- methods = superclass.instance_methods
- methods -= ::Kernel.instance_methods
+ methods = superclass.public_instance_methods(true)
+ methods -= ::Kernel.public_instance_methods(false)
methods |= ["to_s","to_a","inspect","==","=~","==="]
- klass.module_eval <<-EOS
- def initialize(obj)
- @obj = obj
- end
- EOS
+ klass.module_eval {
+ def initialize(obj)
+ @_dc_obj = obj
+ end
+ def method_missing(m, *args)
+ unless @_dc_obj.respond_to?(m)
+ super(m, *args)
+ end
+ @_dc_obj.__send__(m, *args)
+ end
+ def __getobj__
+ @_dc_obj
+ end
+ def __setobj__(obj)
+ @_dc_obj = obj
+ end
+ def clone(obj)
+ super
+ __setobj__(obj.__getobj__.clone)
+ end
+ def dup(obj)
+ super
+ __setobj__(obj.__getobj__.dup)
+ end
+ }
for method in methods
- klass.module_eval <<-EOS
- def #{method}(*args, &block)
+ begin
+ klass.module_eval <<-EOS
+ def #{method}(*args, &block)
begin
- @obj.__send__(:#{method}, *args, &block)
+ @_dc_obj.__send__(:#{method}, *args, &block)
rescue
$@[0,2] = nil
raise
end
end
- EOS
- end
- return klass;
+ EOS
+ rescue SyntaxError
+ raise NameError, "invalid identifier %s" % method, caller(3)
+ end
end
+ return klass
+end
if __FILE__ == $0
class ExtArray<DelegateClass(Array)
@@ -103,7 +148,7 @@ if __FILE__ == $0
end
ary = ExtArray.new
- p ary.type
+ p ary.class
ary.push 25
p ary
diff --git a/lib/drb.rb b/lib/drb.rb
new file mode 100644
index 0000000000..93cc811e14
--- /dev/null
+++ b/lib/drb.rb
@@ -0,0 +1,2 @@
+require 'drb/drb'
+
diff --git a/lib/drb/acl.rb b/lib/drb/acl.rb
new file mode 100644
index 0000000000..aa86dbe70f
--- /dev/null
+++ b/lib/drb/acl.rb
@@ -0,0 +1,144 @@
+# acl-2.0 - simple Access Control List
+#
+# Copyright (c) 2000,2002,2003 Masatoshi SEKI
+#
+# acl.rb is copyrighted free software by Masatoshi SEKI.
+# You can redistribute it and/or modify it under the same terms as Ruby.
+
+require 'ipaddr'
+
+class ACL
+ VERSION=["2.0.0"]
+ class ACLEntry
+ def initialize(str)
+ if str == '*' or str == 'all'
+ @pat = [:all]
+ else
+ begin
+ @pat = [:ip, IPAddr.new(str)]
+ rescue ArgumentError
+ @pat = [:name, dot_pat(str)]
+ end
+ end
+ end
+
+ private
+ def dot_pat_str(str)
+ list = str.split('.').collect { |s|
+ (s == '*') ? '.+' : s
+ }
+ list.join("\\.")
+ end
+
+ private
+ def dot_pat(str)
+ exp = "^" + dot_pat_str(str) + "$"
+ Regexp.new(exp)
+ end
+
+ public
+ def match(addr)
+ case @pat[0]
+ when :all
+ true
+ when :ip
+ begin
+ ipaddr = IPAddr.new(addr[3])
+ ipaddr = ipaddr.ipv4_mapped if @pat[1].ipv6? && ipaddr.ipv4?
+ rescue ArgumentError
+ return false
+ end
+ (@pat[1].include?(ipaddr)) ? true : false
+ when :name
+ (@pat[1] =~ addr[2]) ? true : false
+ else
+ false
+ end
+ end
+ end
+
+ class ACLList
+ def initialize
+ @list = []
+ end
+
+ public
+ def match(addr)
+ @list.each do |e|
+ return true if e.match(addr)
+ end
+ false
+ end
+
+ public
+ def add(str)
+ @list.push(ACLEntry.new(str))
+ end
+ end
+
+ DENY_ALLOW = 0
+ ALLOW_DENY = 1
+
+ def initialize(list=nil, order = DENY_ALLOW)
+ @order = order
+ @deny = ACLList.new
+ @allow = ACLList.new
+ install_list(list) if list
+ end
+
+ public
+ def allow_socket?(soc)
+ allow_addr?(soc.peeraddr)
+ end
+
+ public
+ def allow_addr?(addr)
+ case @order
+ when DENY_ALLOW
+ return true if @allow.match(addr)
+ return false if @deny.match(addr)
+ return true
+ when ALLOW_DENY
+ return false if @deny.match(addr)
+ return true if @allow.match(addr)
+ return false
+ else
+ false
+ end
+ end
+
+ public
+ def install_list(list)
+ i = 0
+ while i < list.size
+ permission, domain = list.slice(i,2)
+ case permission.downcase
+ when 'allow'
+ @allow.add(domain)
+ when 'deny'
+ @deny.add(domain)
+ else
+ raise "Invalid ACL entry #{list.to_s}"
+ end
+ i += 2
+ end
+ end
+end
+
+if __FILE__ == $0
+ # example
+ list = %w(deny all
+ allow 192.168.1.1
+ allow ::ffff:192.168.1.2
+ allow 192.168.1.3
+ )
+
+ addr = ["AF_INET", 10, "lc630", "192.168.1.3"]
+
+ acl = ACL.new
+ p acl.allow_addr?(addr)
+
+ acl = ACL.new(list, ACL::DENY_ALLOW)
+ p acl.allow_addr?(addr)
+end
+
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
new file mode 100644
index 0000000000..c90259f87e
--- /dev/null
+++ b/lib/drb/drb.rb
@@ -0,0 +1,1622 @@
+#
+# = drb/drb.rb
+#
+# Distributed Ruby: _dRuby_ version 2.0.4
+#
+# Copyright (c) 1999-2003 Masatoshi SEKI. You can redistribute it and/or
+# modify it under the same terms as Ruby.
+#
+# Author:: Masatoshi SEKI
+#
+# Documentation:: William Webber (william@williamwebber.com)
+#
+# == Overview
+#
+# dRuby is a distributed object system for Ruby. It allows an object in one
+# Ruby process to invoke methods on an object in another Ruby process on the
+# same or a different machine.
+#
+# The Ruby standard library contains the core classes of the dRuby package.
+# However, the full package also includes access control lists and the
+# Rinda tuple-space distributed task management system, as well as a
+# large number of samples. The full dRuby package can be downloaded from
+# the dRuby home page (see *References*).
+#
+# For an introduction and examples of usage see the documentation to the
+# DRb module.
+#
+# == References
+#
+# [http://www2a.biglobe.ne.jp/~seki/ruby/druby.html]
+# The dRuby home page, in Japanese. Contains the full dRuby package
+# and links to other Japanese-language sources.
+#
+# [http://www2a.biglobe.ne.jp/~seki/ruby/druby.en.html]
+# The English version of the dRuby home page.
+#
+# [http://www.chadfowler.com/ruby/drb.html]
+# A quick tutorial introduction to using dRuby by Chad Fowler.
+#
+# [http://www.linux-mag.com/2002-09/ruby_05.html]
+# A tutorial introduction to dRuby in Linux Magazine by Dave Thomas.
+# Includes a discussion of Rinda.
+#
+# [http://www.eng.cse.dmu.ac.uk/~hgs/ruby/dRuby/]
+# Links to English-language Ruby material collected by Hugh Sasse.
+#
+# [http://www.rubycentral.com/book/ospace.html]
+# The chapter from *Programming* *Ruby* by Dave Thomas and Andy Hunt
+# which discusses dRuby.
+#
+# [http://www.clio.ne.jp/home/web-i31s/Flotuard/Ruby/PRC2K_seki/dRuby.en.html]
+# Translation of presentation on Ruby by Masatoshi Seki.
+
+require 'socket'
+require 'thread'
+require 'fcntl'
+require 'drb/eq'
+
+#
+# == Overview
+#
+# dRuby is a distributed object system for Ruby. It is written in
+# pure Ruby and uses its own protocol. No add-in services are needed
+# beyond those provided by the Ruby runtime, such as TCP sockets. It
+# does not rely on or interoperate with other distributed object
+# systems such as CORBA, RMI, or .NET.
+#
+# dRuby allows methods to be called in one Ruby process upon a Ruby
+# object located in another Ruby process, even on another machine.
+# References to objects can be passed between processes. Method
+# arguments and return values are dumped and loaded in marshalled
+# format. All of this is done transparently to both the caller of the
+# remote method and the object that it is called upon.
+#
+# An object in a remote process is locally represented by a
+# DRb::DRbObject instance. This acts as a sort of proxy for the
+# remote object. Methods called upon this DRbObject instance are
+# forwarded to its remote object. This is arranged dynamically at run
+# time. There are no statically declared interfaces for remote
+# objects, such as CORBA's IDL.
+#
+# dRuby calls made into a process are handled by a DRb::DRbServer
+# instance within that process. This reconstitutes the method call,
+# invokes it upon the specified local object, and returns the value to
+# the remote caller. Any object can receive calls over dRuby. There
+# is no need to implement a special interface, or mixin special
+# functionality. Nor, in the general case, does an object need to
+# explicitly register itself with a DRbServer in order to receive
+# dRuby calls.
+#
+# One process wishing to make dRuby calls upon another process must
+# somehow obtain an initial reference to an object in the remote
+# process by some means other than as the return value of a remote
+# method call, as there is initially no remote object reference it can
+# invoke a method upon. This is done by attaching to the server by
+# URI. Each DRbServer binds itself to a URI such as
+# 'druby://example.com:8787'. A DRbServer can have an object attached
+# to it that acts as the server's *front* *object*. A DRbObject can
+# be explicitly created from the server's URI. This DRbObject's
+# remote object will be the server's front object. This front object
+# can then return references to other Ruby objects in the DRbServer's
+# process.
+#
+# Method calls made over dRuby behave largely the same as normal Ruby
+# method calls made within a process. Method calls with blocks are
+# supported, as are raising exceptions. In addition to a method's
+# standard errors, a dRuby call may also raise one of the
+# dRuby-specific errors, all of which are subclasses of DRb::DRbError.
+#
+# Any type of object can be passed as an argument to a dRuby call or
+# returned as its return value. By default, such objects are dumped
+# or marshalled at the local end, then loaded or unmarshalled at the
+# remote end. The remote end therefore receives a copy of the local
+# object, not a distributed reference to it; methods invoked upon this
+# copy are executed entirely in the remote process, not passed on to
+# the local original. This has semantics similar to pass-by-value.
+#
+# However, if an object cannot be marshalled, a dRuby reference to it
+# is passed or returned instead. This will turn up at the remote end
+# as a DRbObject instance. All methods invoked upon this remote proxy
+# are forwarded to the local object, as described in the discussion of
+# DRbObjects. This has semantics similar to the normal Ruby
+# pass-by-reference.
+#
+# The easiest way to signal that we want an otherwise marshallable
+# object to be passed or returned as a DRbObject reference, rather
+# than marshalled and sent as a copy, is to include the
+# DRb::DRbUndumped mixin module.
+#
+# dRuby supports calling remote methods with blocks. As blocks (or
+# rather the Proc objects that represent them) are not marshallable,
+# the block executes in the local, not the remote, context. Each
+# value yielded to the block is passed from the remote object to the
+# local block, then the value returned by each block invocation is
+# passed back to the remote execution context to be collected, before
+# the collected values are finally returned to the local context as
+# the return value of the method invocation.
+#
+# == Examples of usage
+#
+# For more dRuby samples, see the +samples+ directory in the full
+# dRuby distribution.
+#
+# === dRuby in client/server mode
+#
+# This illustrates setting up a simple client-server drb
+# system. Run the server and client code in different terminals,
+# starting the server code first.
+#
+# ==== Server code
+#
+# require 'drb/drb'
+#
+# # The URI for the server to connect to
+# URI="druby://localhost:8787"
+#
+# class TimeServer
+#
+# def get_current_time
+# return Time.now
+# end
+#
+# end
+#
+# # The object that handles requests on the server
+# FRONT_OBJECT=TimeServer.new
+#
+# $SAFE = 1 # disable eval() and friends
+#
+# DRb.start_service(URI, FRONT_OBJECT)
+# # Wait for the drb server thread to finish before exiting.
+# DRb.thread.join
+#
+# ==== Client code
+#
+# require 'drb/drb'
+#
+# # The URI to connect to
+# SERVER_URI="druby://localhost:8787"
+#
+# # Start a local DRbServer to handle callbacks.
+# #
+# # Not necessary for this small example, but will be required
+# # as soon as we pass a non-marshallable object as an argument
+# # to a dRuby call.
+# DRb.start_service
+#
+# timeserver = DRbObject.new_with_uri(SERVER_URI)
+# puts timeserver.get_current_time
+#
+# === Remote objects under dRuby
+#
+# This example illustrates returning a reference to an object
+# from a dRuby call. The Logger instances live in the server
+# process. References to them are returned to the client process,
+# where methods can be invoked upon them. These methods are
+# executed in the server process.
+#
+# ==== Server code
+#
+# require 'drb/drb'
+#
+# URI="druby://localhost:8787"
+#
+# class Logger
+#
+# # Make dRuby send Logger instances as dRuby references,
+# # not copies.
+# include DRb::DRbUndumped
+#
+# def initialize(n, fname)
+# @name = n
+# @filename = fname
+# end
+#
+# def log(message)
+# File.open(@filename, "a") do |f|
+# f.puts("#{Time.now}: #{@name}: #{message}")
+# end
+# end
+#
+# end
+#
+# # We have a central object for creating and retrieving loggers.
+# # This retains a local reference to all loggers created. This
+# # is so an existing logger can be looked up by name, but also
+# # to prevent loggers from being garbage collected. A dRuby
+# # reference to an object is not sufficient to prevent it being
+# # garbage collected!
+# class LoggerFactory
+#
+# def initialize(bdir)
+# @basedir = bdir
+# @loggers = {}
+# end
+#
+# def get_logger(name)
+# if !@loggers.has_key? name
+# # make the filename safe, then declare it to be so
+# fname = name.gsub(/[.\/]/, "_").untaint
+# @loggers[name] = Logger.new(name, @basedir + "/" + fname)
+# end
+# return @loggers[name]
+# end
+#
+# end
+#
+# FRONT_OBJECT=LoggerFactory.new("/tmp/dlog")
+#
+# $SAFE = 1 # disable eval() and friends
+#
+# DRb.start_service(URI, FRONT_OBJECT)
+# DRb.thread.join
+#
+# ==== Client code
+#
+# require 'drb/drb'
+#
+# SERVER_URI="druby://localhost:8787"
+#
+# DRb.start_service
+#
+# log_service=DRbObject.new_with_uri(SERVER_URI)
+#
+# ["loga", "logb", "logc"].each do |logname|
+#
+# logger=log_service.get_logger(logname)
+#
+# logger.log("Hello, world!")
+# logger.log("Goodbye, world!")
+# logger.log("=== EOT ===")
+#
+# end
+#
+# == Security
+#
+# As with all network services, security needs to be considered when
+# using dRuby. By allowing external access to a Ruby object, you are
+# not only allowing outside clients to call the methods you have
+# defined for that object, but by default to execute arbitrary Ruby
+# code on your server. Consider the following:
+#
+# # !!! UNSAFE CODE !!!
+# ro = DRbObject::new_with_uri("druby://your.server.com:8989")
+# class << ro
+# undef :instance_eval # force call to be passed to remote object
+# end
+# ro.instance_eval("`rm -rf *`")
+#
+# The dangers posed by instance_eval and friends are such that a
+# DRbServer should generally be run with $SAFE set to at least
+# level 1. This will disable eval() and related calls on strings
+# passed across the wire. The sample usage code given above follows
+# this practice.
+#
+# A DRbServer can be configured with an access control list to
+# selectively allow or deny access from specified IP addresses. The
+# main druby distribution provides the ACL class for this purpose. In
+# general, this mechanism should only be used alongside, rather than
+# as a replacement for, a good firewall.
+#
+# == dRuby internals
+#
+# dRuby is implemented using three main components: a remote method
+# call marshaller/unmarshaller; a transport protocol; and an
+# ID-to-object mapper. The latter two can be directly, and the first
+# indirectly, replaced, in order to provide different behaviour and
+# capabilities.
+#
+# Marshalling and unmarshalling of remote method calls is performed by
+# a DRb::DRbMessage instance. This uses the Marshal module to dump
+# the method call before sending it over the transport layer, then
+# reconstitute it at the other end. There is normally no need to
+# replace this component, and no direct way is provided to do so.
+# However, it is possible to implement an alternative marshalling
+# scheme as part of an implementation of the transport layer.
+#
+# The transport layer is responsible for opening client and server
+# network connections and forwarding dRuby request across them.
+# Normally, it uses DRb::DRbMessage internally to manage marshalling
+# and unmarshalling. The transport layer is managed by
+# DRb::DRbProtocol. Multiple protocols can be installed in
+# DRbProtocol at the one time; selection between them is determined by
+# the scheme of a dRuby URI. The default transport protocol is
+# selected by the scheme 'druby:', and implemented by
+# DRb::DRbTCPSocket. This uses plain TCP/IP sockets for
+# communication. An alternative protocol, using UNIX domain sockets,
+# is implemented by DRb::DRbUNIXSocket in the file drb/unix.rb, and
+# selected by the scheme 'drbunix:'. A sample implementation over
+# HTTP can be found in the samples accompanying the main dRuby
+# distribution.
+#
+# The ID-to-object mapping component maps dRuby object ids to the
+# objects they refer to, and vice versa. The implementation to use
+# can be specified as part of a DRb::DRbServer's configuration. The
+# default implementation is provided by DRb::DRbIdConv. It uses an
+# object's ObjectSpace id as its dRuby id. This means that the dRuby
+# reference to that object only remains meaningful for the lifetime of
+# the object's process and the lifetime of the object within that
+# process. A modified implementation is provided by DRb::TimerIdConv
+# in the file drb/timeridconv.rb. This implementation retains a local
+# reference to all objects exported over dRuby for a configurable
+# period of time (defaulting to ten minutes), to prevent them being
+# garbage-collected within this time. Another sample implementation
+# is provided in sample/name.rb in the main dRuby distribution. This
+# allows objects to specify their own id or "name". A dRuby reference
+# can be made persistent across processes by having each process
+# register an object using the same dRuby name.
+#
+module DRb
+
+ # Superclass of all errors raised in the DRb module.
+ class DRbError < RuntimeError; end
+
+ # Error raised when an error occurs on the underlying communication
+ # protocol.
+ class DRbConnError < DRbError; end
+
+ # Class responsible for converting between an object and its id.
+ #
+ # This, the default implementation, uses an object's local ObjectSpace
+ # __id__ as its id. This means that an object's identification over
+ # drb remains valid only while that object instance remains alive
+ # within the server runtime.
+ #
+ # For alternative mechanisms, see DRb::TimerIdConv in rdb/timeridconv.rb
+ # and DRbNameIdConv in sample/name.rb in the full drb distribution.
+ class DRbIdConv
+
+ # Convert an object reference id to an object.
+ #
+ # This implementation looks up the reference id in the local object
+ # space and returns the object it refers to.
+ def to_obj(ref)
+ ObjectSpace._id2ref(ref)
+ end
+
+ # Convert an object into a reference id.
+ #
+ # This implementation returns the object's __id__ in the local
+ # object space.
+ def to_id(obj)
+ obj.nil? ? nil : obj.__id__
+ end
+ end
+
+ # Mixin module making an object undumpable or unmarshallable.
+ #
+ # If an object which includes this module is returned by method
+ # called over drb, then the object remains in the server space
+ # and a reference to the object is returned, rather than the
+ # object being marshalled and moved into the client space.
+ module DRbUndumped
+ def _dump(dummy) # :nodoc:
+ raise TypeError, 'can\'t dump'
+ end
+ end
+
+ # Error raised by the DRb module when an attempt is made to refer to
+ # the context's current drb server but the context does not have one.
+ # See #current_server.
+ class DRbServerNotFound < DRbError; end
+
+ # Error raised by the DRbProtocol module when it cannot find any
+ # protocol implementation support the scheme specified in a URI.
+ class DRbBadURI < DRbError; end
+
+ # Error raised by a dRuby protocol when it doesn't support the
+ # scheme specified in a URI. See DRb::DRbProtocol.
+ class DRbBadScheme < DRbError; end
+
+ # An exception wrapping a DRb::DRbUnknown object
+ class DRbUnknownError < DRbError
+
+ # Create a new DRbUnknownError for the DRb::DRbUnknown object +unknown+
+ def initialize(unknown)
+ @unknown = unknown
+ super(unknown.name)
+ end
+
+ # Get the wrapped DRb::DRbUnknown object.
+ attr_reader :unknown
+
+ def self._load(s) # :nodoc:
+ Marshal::load(s)
+ end
+
+ def _dump(lv) # :nodoc:
+ Marshal::dump(@unknown)
+ end
+ end
+
+ # Class wrapping a marshalled object whose type is unknown locally.
+ #
+ # If an object is returned by a method invoked over drb, but the
+ # class of the object is unknown in the client namespace, or
+ # the object is a constant unknown in the client namespace, then
+ # the still-marshalled object is returned wrapped in a DRbUnknown instance.
+ #
+ # If this object is passed as an argument to a method invoked over
+ # drb, then the wrapped object is passed instead.
+ #
+ # The class or constant name of the object can be read from the
+ # +name+ attribute. The marshalled object is held in the +buf+
+ # attribute.
+ class DRbUnknown
+
+ # Create a new DRbUnknown object.
+ #
+ # +buf+ is a string containing a marshalled object that could not
+ # be unmarshalled. +err+ is the error message that was raised
+ # when the unmarshalling failed. It is used to determine the
+ # name of the unmarshalled object.
+ def initialize(err, buf)
+ case err
+ when /uninitialized constant (\S+)/
+ @name = $1
+ when /undefined class\/module (\S+)/
+ @name = $1
+ else
+ @name = nil
+ end
+ @buf = buf
+ end
+
+ # The name of the unknown thing.
+ #
+ # Class name for unknown objects; variable name for unknown
+ # constants.
+ attr_reader :name
+
+ # Buffer contained the marshalled, unknown object.
+ attr_reader :buf
+
+ def self._load(s) # :nodoc:
+ begin
+ Marshal::load(s)
+ rescue NameError, ArgumentError
+ DRbUnknown.new($!, s)
+ end
+ end
+
+ def _dump(lv) # :nodoc:
+ @buf
+ end
+
+ # Attempt to load the wrapped marshalled object again.
+ #
+ # If the class of the object is now known locally, the object
+ # will be unmarshalled and returned. Otherwise, a new
+ # but identical DRbUnknown object will be returned.
+ def reload
+ self.class._load(@buf)
+ end
+
+ # Create a DRbUnknownError exception containing this object.
+ def exception
+ DRbUnknownError.new(self)
+ end
+ end
+
+ class DRbArray
+ def initialize(ary)
+ @ary = ary.collect { |obj|
+ if obj.kind_of? DRbUndumped
+ DRbObject.new(obj)
+ else
+ begin
+ Marshal.dump(obj)
+ obj
+ rescue
+ DRbObject.new(obj)
+ end
+ end
+ }
+ end
+
+ def self._load(s)
+ Marshal::load(s)
+ end
+
+ def _dump(lv)
+ Marshal.dump(@ary)
+ end
+ end
+
+ # Handler for sending and receiving drb messages.
+ #
+ # This takes care of the low-level marshalling and unmarshalling
+ # of drb requests and responses sent over the wire between server
+ # and client. This relieves the implementor of a new drb
+ # protocol layer with having to deal with these details.
+ #
+ # The user does not have to directly deal with this object in
+ # normal use.
+ class DRbMessage
+ def initialize(config) # :nodoc:
+ @load_limit = config[:load_limit]
+ @argc_limit = config[:argc_limit]
+ end
+
+ def dump(obj) # :nodoc:
+ obj = DRbObject.new(obj) if obj.kind_of? DRbUndumped
+ begin
+ str = Marshal::dump(obj)
+ rescue
+ str = Marshal::dump(DRbObject.new(obj))
+ end
+ [str.size].pack('N') + str
+ end
+
+ def load(soc) # :nodoc:
+ begin
+ sz = soc.read(4) # sizeof (N)
+ rescue
+ raise(DRbConnError, $!.message, $!.backtrace)
+ end
+ raise(DRbConnError, 'connection closed') if sz.nil?
+ raise(DRbConnError, 'premature header') if sz.size < 4
+ sz = sz.unpack('N')[0]
+ raise(DRbConnError, "too large packet #{sz}") if @load_limit < sz
+ begin
+ str = soc.read(sz)
+ rescue
+ raise(DRbConnError, $!.message, $!.backtrace)
+ end
+ raise(DRbConnError, 'connection closed') if sz.nil?
+ raise(DRbConnError, 'premature marshal format(can\'t read)') if str.size < sz
+ begin
+ Marshal::load(str)
+ rescue NameError, ArgumentError
+ DRbUnknown.new($!, str)
+ end
+ end
+
+ def send_request(stream, ref, msg_id, arg, b) # :nodoc:
+ ary = []
+ ary.push(dump(ref.__drbref))
+ ary.push(dump(msg_id.id2name))
+ ary.push(dump(arg.length))
+ arg.each do |e|
+ ary.push(dump(e))
+ end
+ ary.push(dump(b))
+ stream.write(ary.join(''))
+ rescue
+ raise(DRbConnError, $!.message, $!.backtrace)
+ end
+
+ def recv_request(stream) # :nodoc:
+ ref = load(stream)
+ ro = DRb.to_obj(ref)
+ msg = load(stream)
+ argc = load(stream)
+ raise ArgumentError, 'too many arguments' if @argc_limit < argc
+ argv = Array.new(argc, nil)
+ argc.times do |n|
+ argv[n] = load(stream)
+ end
+ block = load(stream)
+ return ro, msg, argv, block
+ end
+
+ def send_reply(stream, succ, result) # :nodoc:
+ stream.write(dump(succ) + dump(result))
+ rescue
+ raise(DRbConnError, $!.message, $!.backtrace)
+ end
+
+ def recv_reply(stream) # :nodoc:
+ succ = load(stream)
+ result = load(stream)
+ [succ, result]
+ end
+ end
+
+ # Module managing the underlying network protocol(s) used by drb.
+ #
+ # By default, drb uses the DRbTCPSocket protocol. Other protocols
+ # can be defined. A protocol must define the following class methods:
+ #
+ # [open(uri, config)] Open a client connection to the server at +uri+,
+ # using configuration +config+. Return a protocol
+ # instance for this connection.
+ # [open_server(uri, config)] Open a server listening at +uri+,
+ # using configuration +config+. Return a
+ # protocol instance for this listener.
+ # [uri_option(uri, config)] Take a URI, possibly containing an option
+ # component (e.g. a trailing '?param=val'),
+ # and return a [uri, option] tuple.
+ #
+ # All of these methods should raise a DRbBadScheme error if the URI
+ # does not identify the protocol they support (e.g. "druby:" for
+ # the standard Ruby protocol). This is how the DRbProtocol module,
+ # given a URI, determines which protocol implementation serves that
+ # protocol.
+ #
+ # The protocol instance returned by #open_server must have the
+ # following methods:
+ #
+ # [accept] Accept a new connection to the server. Returns a protocol
+ # instance capable of communicating with the client.
+ # [close] Close the server connection.
+ # [uri] Get the URI for this server.
+ #
+ # The protocol instance returned by #open must have the following methods:
+ #
+ # [send_request (ref, msg_id, arg, b)]
+ # Send a request to +ref+ with the given message id and arguments.
+ # This is most easily implemented by calling DRbMessage.send_request,
+ # providing a stream that sits on top of the current protocol.
+ # [recv_reply]
+ # Receive a reply from the server and return it as a [success-boolean,
+ # reply-value] pair. This is most easily implemented by calling
+ # DRb.recv_reply, providing a stream that sits on top of the
+ # current protocol.
+ # [alive?]
+ # Is this connection still alive?
+ # [close]
+ # Close this connection.
+ #
+ # The protocol instance returned by #open_server().accept() must have
+ # the following methods:
+ #
+ # [recv_request]
+ # Receive a request from the client and return a [object, message,
+ # args, block] tuple. This is most easily implemented by calling
+ # DRbMessage.recv_request, providing a stream that sits on top of
+ # the current protocol.
+ # [send_reply(succ, result)]
+ # Send a reply to the client. This is most easily implemented
+ # by calling DRbMessage.send_reply, providing a stream that sits
+ # on top of the current protocol.
+ # [close]
+ # Close this connection.
+ #
+ # A new protocol is registered with the DRbProtocol module using
+ # the add_protocol method.
+ #
+ # For examples of other protocols, see DRbUNIXSocket in drb/unix.rb,
+ # and HTTP0 in sample/http0.rb and sample/http0serv.rb in the full
+ # drb distribution.
+ module DRbProtocol
+
+ # Add a new protocol to the DRbProtocol module.
+ def add_protocol(prot)
+ @protocol.push(prot)
+ end
+ module_function :add_protocol
+
+ # Open a client connection to +uri+ with the configuration +config+.
+ #
+ # The DRbProtocol module asks each registered protocol in turn to
+ # try to open the URI. Each protocol signals that it does not handle that
+ # URI by raising a DRbBadScheme error. If no protocol recognises the
+ # URI, then a DRbBadURI error is raised. If a protocol accepts the
+ # URI, but an error occurs in opening it, a DRbConnError is raised.
+ def open(uri, config, first=true)
+ @protocol.each do |prot|
+ begin
+ return prot.open(uri, config)
+ rescue DRbBadScheme
+ rescue DRbConnError
+ raise($!)
+ rescue
+ raise(DRbConnError, "#{uri} - #{$!.inspect}")
+ end
+ end
+ if first && (config[:auto_load] != false)
+ auto_load(uri, config)
+ return open(uri, config, false)
+ end
+ raise DRbBadURI, 'can\'t parse uri:' + uri
+ end
+ module_function :open
+
+ # Open a server listening for connections at +uri+ with
+ # configuration +config+.
+ #
+ # The DRbProtocol module asks each registered protocol in turn to
+ # try to open a server at the URI. Each protocol signals that it does
+ # not handle that URI by raising a DRbBadScheme error. If no protocol
+ # recognises the URI, then a DRbBadURI error is raised. If a protocol
+ # accepts the URI, but an error occurs in opening it, the underlying
+ # error is passed on to the caller.
+ def open_server(uri, config, first=true)
+ @protocol.each do |prot|
+ begin
+ return prot.open_server(uri, config)
+ rescue DRbBadScheme
+ end
+ end
+ if first && (config[:auto_load] != false)
+ auto_load(uri, config)
+ return open_server(uri, config, false)
+ end
+ raise DRbBadURI, 'can\'t parse uri:' + uri
+ end
+ module_function :open_server
+
+ # Parse +uri+ into a [uri, option] pair.
+ #
+ # The DRbProtocol module asks each registered protocol in turn to
+ # try to parse the URI. Each protocol signals that it does not handle that
+ # URI by raising a DRbBadScheme error. If no protocol recognises the
+ # URI, then a DRbBadURI error is raised.
+ def uri_option(uri, config, first=true)
+ @protocol.each do |prot|
+ begin
+ uri, opt = prot.uri_option(uri, config)
+ # opt = nil if opt == ''
+ return uri, opt
+ rescue DRbBadScheme
+ end
+ end
+ if first && (config[:auto_load] != false)
+ auto_load(uri, config)
+ return uri_option(uri, config, false)
+ end
+ raise DRbBadURI, 'can\'t parse uri:' + uri
+ end
+ module_function :uri_option
+
+ def auto_load(uri, config) # :nodoc:
+ if uri =~ /^drb([a-z0-9]+):/
+ require("drb/#{$1}") rescue nil
+ end
+ end
+ module_function :auto_load
+ end
+
+ # The default drb protocol.
+ #
+ # Communicates over a TCP socket.
+ class DRbTCPSocket
+ private
+ def self.parse_uri(uri)
+ if uri =~ /^druby:\/\/(.*?):(\d+)(\?(.*))?$/
+ host = $1
+ port = $2.to_i
+ option = $4
+ [host, port, option]
+ else
+ raise(DRbBadScheme, uri) unless uri =~ /^druby:/
+ raise(DRbBadURI, 'can\'t parse uri:' + uri)
+ end
+ end
+
+ public
+
+ # Open a client connection to +uri+ using configuration +config+.
+ def self.open(uri, config)
+ host, port, option = parse_uri(uri)
+ host.untaint
+ port.untaint
+ soc = TCPSocket.open(host, port)
+ self.new(uri, soc, config)
+ end
+
+ # Open a server listening for connections at +uri+ using
+ # configuration +config+.
+ def self.open_server(uri, config)
+ uri = 'druby://:0' unless uri
+ host, port, opt = parse_uri(uri)
+ if host.size == 0
+ soc = TCPServer.open(port)
+ host = Socket.gethostname
+ else
+ soc = TCPServer.open(host, port)
+ end
+ port = soc.addr[1] if port == 0
+ uri = "druby://#{host}:#{port}"
+ self.new(uri, soc, config)
+ end
+
+ # Parse +uri+ into a [uri, option] pair.
+ def self.uri_option(uri, config)
+ host, port, option = parse_uri(uri)
+ return "druby://#{host}:#{port}", option
+ end
+
+ # Create a new DRbTCPSocket instance.
+ #
+ # +uri+ is the URI we are connected to.
+ # +soc+ is the tcp socket we are bound to. +config+ is our
+ # configuration.
+ def initialize(uri, soc, config={})
+ @uri = uri
+ @socket = soc
+ @config = config
+ @acl = config[:tcp_acl]
+ @msg = DRbMessage.new(config)
+ set_sockopt(@socket)
+ end
+
+ # Get the URI that we are connected to.
+ attr_reader :uri
+
+ # Get the address of our TCP peer (the other end of the socket
+ # we are bound to.
+ def peeraddr
+ @socket.peeraddr
+ end
+
+ # Get the socket.
+ def stream; @socket; end
+
+ # On the client side, send a request to the server.
+ def send_request(ref, msg_id, arg, b)
+ @msg.send_request(stream, ref, msg_id, arg, b)
+ end
+
+ # On the server side, receive a request from the client.
+ def recv_request
+ @msg.recv_request(stream)
+ end
+
+ # On the server side, send a reply to the client.
+ def send_reply(succ, result)
+ @msg.send_reply(stream, succ, result)
+ end
+
+ # On the client side, receive a reply from the server.
+ def recv_reply
+ @msg.recv_reply(stream)
+ end
+
+ public
+
+ # Close the connection.
+ #
+ # If this is an instance returned by #open_server, then this stops
+ # listening for new connections altogether. If this is an instance
+ # returned by #open or by #accept, then it closes this particular
+ # client-server session.
+ def close
+ if @socket
+ @socket.close
+ @socket = nil
+ end
+ end
+
+ # On the server side, for an instance returned by #open_server,
+ # accept a client connection and return a new instance to handle
+ # the server's side of this client-server session.
+ def accept
+ while true
+ s = @socket.accept
+ break if (@acl ? @acl.allow_socket?(s) : true)
+ s.close
+ end
+ self.class.new(nil, s, @config)
+ end
+
+ # Check to see if this connection is alive.
+ def alive?
+ return false unless @socket
+ if IO.select([@socket], nil, nil, 0)
+ close
+ return false
+ end
+ true
+ end
+
+ def set_sockopt(soc) # :nodoc:
+ soc.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
+ soc.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
+ end
+ end
+
+ module DRbProtocol
+ @protocol = [DRbTCPSocket] # default
+ end
+
+ class DRbURIOption # :nodoc: I don't understand the purpose of this class...
+ def initialize(option)
+ @option = option.to_s
+ end
+ attr :option
+ def to_s; @option; end
+
+ def ==(other)
+ return false unless DRbURIOption === other
+ @option == other.option
+ end
+
+ def hash
+ @option.hash
+ end
+
+ alias eql? ==
+ end
+
+ # Object wrapping a reference to a remote drb object.
+ #
+ # Method calls on this object are relayed to the remote
+ # object that this object is a stub for.
+ class DRbObject
+
+ # Unmarshall a marshalled DRbObject.
+ #
+ # If the referenced object is located within the local server, then
+ # the object itself is returned. Otherwise, a new DRbObject is
+ # created to act as a stub for the remote referenced object.
+ def self._load(s)
+ uri, ref = Marshal.load(s)
+ if DRb.here?(uri)
+ return DRb.to_obj(ref)
+ end
+
+ it = self.new(nil)
+ it.reinit(uri, ref)
+ it
+ end
+
+ # Create a new DRbObject from a URI alone.
+ def self.new_with_uri(uri)
+ self.new(nil, uri)
+ end
+
+ # Marshall this object.
+ #
+ # The URI and ref of the object are marshalled.
+ def _dump(lv)
+ Marshal.dump([@uri, @ref])
+ end
+
+ # Create a new remote object stub.
+ #
+ # +obj+ is the (local) object we want to create a stub for. Normally
+ # this is +nil+. +uri+ is the URI of the remote object that this
+ # will be a stub for.
+ def initialize(obj, uri=nil)
+ @uri = nil
+ @ref = nil
+ if obj.nil?
+ return if uri.nil?
+ @uri, option = DRbProtocol.uri_option(uri, DRb.config)
+ @ref = DRbURIOption.new(option) unless option.nil?
+ else
+ @uri = uri ? uri : (DRb.uri rescue nil)
+ @ref = obj ? DRb.to_id(obj) : nil
+ end
+ end
+
+ # Reinitialise this object with the given +uri+ and +ref+
+ def reinit(uri, ref)
+ @uri = uri
+ @ref = ref
+ end
+
+ # Get the URI of the remote object.
+ def __drburi
+ @uri
+ end
+
+ # Get the reference of the object, if local.
+ def __drbref
+ @ref
+ end
+
+ undef :to_s
+ undef :to_a if respond_to?(:to_a)
+ undef :respond_to?
+
+ # Routes method calls to the referenced object.
+ def method_missing(msg_id, *a, &b)
+ if DRb.here?(@uri)
+ obj = DRb.to_obj(@ref)
+ DRb.current_server.check_insecure_method(obj, msg_id)
+ return obj.__send__(msg_id, *a, &b)
+ end
+
+ succ, result = DRbConn.open(@uri) do |conn|
+ conn.send_message(self, msg_id, a, b)
+ end
+ return result if succ
+ unless DRbUnknown === result
+ prefix = "(#{@uri}) "
+ bt = []
+ result.backtrace.each do |x|
+ break if /`__send__'$/ =~ x
+ if /^\(druby:\/\// =~ x
+ bt.push(x)
+ else
+ bt.push(prefix + x)
+ end
+ end
+ raise result, result.message, bt + caller
+ else
+ raise result
+ end
+ end
+
+ def pretty_print(q) # :nodoc:
+ q.pp_object(self)
+ end
+
+ def pretty_print_cycle(q) # :nodoc:
+ q.object_address_group(self) {
+ q.breakable
+ q.text '...'
+ }
+ end
+ end
+
+ # Class handling the connection between a DRbObject and the
+ # server the real object lives on.
+ #
+ # This class maintains a pool of connections, to reduce the
+ # overhead of starting and closing down connections for each
+ # method call.
+ #
+ # This class is used internally by DRbObject. The user does
+ # not normally need to deal with it directly.
+ class DRbConn
+ POOL_SIZE = 16 # :nodoc:
+ @mutex = Mutex.new
+ @pool = []
+
+ def self.open(remote_uri) # :nodoc:
+ begin
+ conn = nil
+
+ @mutex.synchronize do
+ #FIXME
+ new_pool = []
+ @pool.each do |c|
+ if conn.nil? and c.uri == remote_uri
+ conn = c if c.alive?
+ else
+ new_pool.push c
+ end
+ end
+ @pool = new_pool
+ end
+
+ conn = self.new(remote_uri) unless conn
+ succ, result = yield(conn)
+ return succ, result
+
+ ensure
+ if conn
+ if succ
+ @mutex.synchronize do
+ @pool.unshift(conn)
+ @pool.pop.close while @pool.size > POOL_SIZE
+ end
+ else
+ conn.close
+ end
+ end
+ end
+ end
+
+ def initialize(remote_uri) # :nodoc:
+ @uri = remote_uri
+ @protocol = DRbProtocol.open(remote_uri, DRb.config)
+ end
+ attr_reader :uri # :nodoc:
+
+ def send_message(ref, msg_id, arg, block) # :nodoc:
+ @protocol.send_request(ref, msg_id, arg, block)
+ @protocol.recv_reply
+ end
+
+ def close # :nodoc:
+ @protocol.close
+ @protocol = nil
+ end
+
+ def alive? # :nodoc:
+ @protocol.alive?
+ end
+ end
+
+ # Class representing a drb server instance.
+ #
+ # A DRbServer must be running in the local process before any incoming
+ # dRuby calls can be accepted, or any local objects can be passed as
+ # dRuby references to remote processes, even if those local objects are
+ # never actually called remotely. You do not need to start a DRbServer
+ # in the local process if you are only making outgoing dRuby calls
+ # passing marshalled parameters.
+ #
+ # Unless multiple servers are being used, the local DRbServer is normally
+ # started by calling DRb.start_service.
+ class DRbServer
+ @@acl = nil
+ @@idconv = DRbIdConv.new
+ @@secondary_server = nil
+ @@argc_limit = 256
+ @@load_limit = 256 * 102400
+ @@verbose = false
+
+ # Set the default value for the :argc_limit option.
+ #
+ # See #new(). The initial default value is 256.
+ def self.default_argc_limit(argc)
+ @@argc_limit = argc
+ end
+
+ # Set the default value for the :load_limit option.
+ #
+ # See #new(). The initial default value is 25 MB.
+ def self.default_load_limit(sz)
+ @@load_limit = sz
+ end
+
+ # Set the default value for the :acl option.
+ #
+ # See #new(). The initial default value is nil.
+ def self.default_acl(acl)
+ @@acl = acl
+ end
+
+ # Set the default value for the :id_conv option.
+ #
+ # See #new(). The initial default value is a DRbIdConv instance.
+ def self.default_id_conv(idconv)
+ @@idconv = idconv
+ end
+
+ # Set the default value of the :verbose option.
+ #
+ # See #new(). The initial default value is false.
+ def self.verbose=(on)
+ @@verbose = on
+ end
+
+ # Get the default value of the :verbose option.
+ def self.verbose
+ @@verbose
+ end
+
+ def self.make_config(hash={}) # :nodoc:
+ default_config = {
+ :idconv => @@idconv,
+ :verbose => @@verbose,
+ :tcp_acl => @@acl,
+ :load_limit => @@load_limit,
+ :argc_limit => @@argc_limit
+ }
+ default_config.update(hash)
+ end
+
+ # Create a new DRbServer instance.
+ #
+ # +uri+ is the URI to bind to. This is normally of the form
+ # 'druby://<hostname>:<port>' where <hostname> is a hostname of
+ # the local machine. If nil, then the system's default hostname
+ # will be bound to, on a port selected by the system; these value
+ # can be retrieved from the +uri+ attribute. 'druby:' specifies
+ # the default dRuby transport protocol: another protocol, such
+ # as 'drbunix:', can be specified instead.
+ #
+ # +front+ is the front object for the server, that is, the object
+ # to which remote method calls on the server will be passed. If
+ # nil, then the server will not accept remote method calls.
+ #
+ # If +config_or_acl+ is a hash, it is the configuration to
+ # use for this server. The following options are recognised:
+ #
+ # :idconv :: an id-to-object conversion object. This defaults
+ # to an instance of the class DRb::DRbIdConv.
+ # :verbose :: if true, all unsuccessful remote calls on objects
+ # in the server will be logged to $stdout. false
+ # by default.
+ # :tcp_acl :: the access control list for this server. See
+ # the ACL class from the main dRuby distribution.
+ # :load_limit :: the maximum message size in bytes accepted by
+ # the server. Defaults to 25 MB (26214400).
+ # :argc_limit :: the maximum number of arguments to a remote
+ # method accepted by the server. Defaults to
+ # 256.
+ #
+ # The default values of these options can be modified on
+ # a class-wide basis by the class methods #default_argc_limit,
+ # #default_load_limit, #default_acl, #default_id_conv,
+ # and #verbose=
+ #
+ # If +config_or_acl+ is not a hash, but is not nil, it is
+ # assumed to be the access control list for this server.
+ # See the :tcp_acl option for more details.
+ #
+ # If no other server is currently set as the primary server,
+ # this will become the primary server.
+ #
+ # The server will immediately start running in its own thread.
+ def initialize(uri=nil, front=nil, config_or_acl=nil)
+ if Hash === config_or_acl
+ config = config_or_acl.dup
+ else
+ acl = config_or_acl || @@acl
+ config = {
+ :tcp_acl => acl
+ }
+ end
+
+ @config = self.class.make_config(config)
+
+ @protocol = DRbProtocol.open_server(uri, @config)
+ @uri = @protocol.uri
+
+ @front = front
+ @idconv = @config[:idconv]
+
+ @grp = ThreadGroup.new
+ @thread = run
+
+ Thread.exclusive do
+ DRb.primary_server = self unless DRb.primary_server
+ end
+ end
+
+ # The URI of this DRbServer.
+ attr_reader :uri
+
+ # The main thread of this DRbServer.
+ #
+ # This is the thread that listens for and accepts connections
+ # from clients, not that handles each client's request-response
+ # session.
+ attr_reader :thread
+
+ # The front object of the DRbServer.
+ #
+ # This object receives remote method calls made on the server's
+ # URI alone, with an object id.
+ attr_reader :front
+
+ # The configuration of this DRbServer
+ attr_reader :config
+
+ # Set whether to operate in verbose mode.
+ #
+ # In verbose mode, failed calls are logged to stdout.
+ def verbose=(v); @config[:verbose]=v; end
+
+ # Get whether the server is in verbose mode.
+ #
+ # In verbose mode, failed calls are logged to stdout.
+ def verbose; @config[:verbose]; end
+
+ # Is this server alive?
+ def alive?
+ @thread.alive?
+ end
+
+ # Stop this server.
+ def stop_service
+ @thread.kill
+ end
+
+ # Convert a dRuby reference to the local object it refers to.
+ def to_obj(ref)
+ return front if ref.nil?
+ return front[ref.to_s] if DRbURIOption === ref
+ @idconv.to_obj(ref)
+ end
+
+ # Convert a local object to a dRuby reference.
+ def to_id(obj)
+ return nil if obj.__id__ == front.__id__
+ @idconv.to_id(obj)
+ end
+
+ private
+ def kill_sub_thread
+ Thread.new do
+ grp = ThreadGroup.new
+ grp.add(Thread.current)
+ list = @grp.list
+ while list.size > 0
+ list.each do |th|
+ th.kill if th.alive?
+ end
+ list = @grp.list
+ end
+ end
+ end
+
+ def run
+ Thread.start do
+ begin
+ while true
+ main_loop
+ end
+ ensure
+ @protocol.close if @protocol
+ kill_sub_thread
+ end
+ end
+ end
+
+ # List of insecure methods.
+ #
+ # These methods are not callable via dRuby.
+ INSECURE_METHOD = [
+ :__send__
+ ]
+
+ # Has a method been included in the list of insecure methods?
+ def insecure_method?(msg_id)
+ INSECURE_METHOD.include?(msg_id)
+ end
+
+ # Coerce an object to a string, providing our own representation if
+ # to_s is not defined for the object.
+ def any_to_s(obj)
+ obj.to_s rescue sprintf("#<%s:0x%lx>", obj.class, obj.__id__)
+ end
+
+ # Check that a method is callable via dRuby.
+ #
+ # +obj+ is the object we want to invoke the method on. +msg_id+ is the
+ # method name, as a Symbol.
+ #
+ # If the method is an insecure method (see #insecure_method?) a
+ # SecurityError is thrown. If the method is private or undefined,
+ # a NameError is thrown.
+ def check_insecure_method(obj, msg_id)
+ return true if Proc === obj && msg_id == :__drb_yield
+ raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
+ raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
+ unless obj.respond_to?(msg_id)
+ desc = any_to_s(obj)
+ if desc.nil? || desc[0] == '#'
+ desc << ":#{obj.class}"
+ end
+
+ if obj.private_methods.include?(msg_id.to_s)
+ raise NameError, "private method `#{msg_id}' called for #{desc}"
+ else
+ raise NameError, "undefined method `#{msg_id}' called for #{desc}"
+ end
+ end
+ true
+ end
+ public :check_insecure_method
+
+ class InvokeMethod # :nodoc:
+ def initialize(drb_server, client)
+ @drb_server = drb_server
+ @client = client
+ end
+
+ def perform
+ @result = nil
+ @succ = false
+ setup_message
+ if @block
+ @result = perform_with_block
+ else
+ @result = perform_without_block
+ end
+ @succ = true
+ if @msg_id == :to_ary && @result.class == Array
+ @result = DRbArray.new(@result)
+ end
+ return @succ, @result
+ rescue StandardError, ScriptError, Interrupt
+ @result = $!
+ return @succ, @result
+ end
+
+ private
+ def init_with_client
+ obj, msg, argv, block = @client.recv_request
+ @obj = obj
+ @msg_id = msg.intern
+ @argv = argv
+ @block = block
+ end
+
+ def check_insecure_method
+ @drb_server.check_insecure_method(@obj, @msg_id)
+ end
+
+ def setup_message
+ init_with_client
+ check_insecure_method
+ end
+
+ def perform_without_block
+ if Proc === @obj && @msg_id == :__drb_yield
+ if @argv.size == 1
+ ary = @argv
+ else
+ ary = [@argv]
+ end
+ ary.collect(&@obj)[0]
+ else
+ @obj.__send__(@msg_id, *@argv)
+ end
+ end
+
+ end
+
+ if RUBY_VERSION >= '1.8'
+ require 'drb/invokemethod'
+ class InvokeMethod
+ include InvokeMethod18Mixin
+ end
+ else
+ require 'drb/invokemethod16'
+ class InvokeMethod
+ include InvokeMethod16Mixin
+ end
+ end
+
+ # The main loop performed by a DRbServer's internal thread.
+ #
+ # Accepts a connection from a client, and starts up its own
+ # thread to handle it. This thread loops, receiving requests
+ # from the client, invoking them on a local object, and
+ # returning responses, until the client closes the connection
+ # or a local method call fails.
+ def main_loop
+ Thread.start(@protocol.accept) do |client|
+ @grp.add Thread.current
+ Thread.current['DRb'] = { 'client' => client ,
+ 'server' => self }
+ loop do
+ begin
+ succ = false
+ invoke_method = InvokeMethod.new(self, client)
+ succ, result = invoke_method.perform
+ if !succ && verbose
+ p result
+ result.backtrace.each do |x|
+ puts x
+ end
+ end
+ client.send_reply(succ, result) rescue nil
+ ensure
+ unless succ
+ client.close
+ break
+ end
+ end
+ end
+ end
+ end
+ end
+
+ @primary_server = nil
+
+ # Start a dRuby server locally.
+ #
+ # The new dRuby server will become the primary server, even
+ # if another server is currently the primary server.
+ #
+ # +uri+ is the URI for the server to bind to. If nil,
+ # the server will bind to random port on the default local host
+ # name and use the default dRuby protocol.
+ #
+ # +front+ is the server's front object. This may be nil.
+ #
+ # +config+ is the configuration for the new server. This may
+ # be nil.
+ #
+ # See DRbServer::new.
+ def start_service(uri=nil, front=nil, config=nil)
+ @primary_server = DRbServer.new(uri, front, config)
+ end
+ module_function :start_service
+
+ # The primary local dRuby server.
+ #
+ # This is the server created by the #start_service call.
+ attr_accessor :primary_server
+ module_function :primary_server=, :primary_server
+
+ # Get the 'current' server.
+ #
+ # In the context of execution taking place within the main
+ # thread of a dRuby server (typically, as a result of a remote
+ # call on the server or one of its objects), the current
+ # server is that server. Otherwise, the current server is
+ # the primary server.
+ #
+ # If the above rule fails to find a server, a DRbServerNotFound
+ # error is raised.
+ def current_server
+ drb = Thread.current['DRb']
+ server = (drb && drb['server']) ? drb['server'] : @primary_server
+ raise DRbServerNotFound unless server
+ return server
+ end
+ module_function :current_server
+
+ # Stop the local dRuby server.
+ #
+ # This operates on the primary server. If there is no primary
+ # server currently running, it is a noop.
+ def stop_service
+ @primary_server.stop_service if @primary_server
+ @primary_server = nil
+ end
+ module_function :stop_service
+
+ # Get the URI defining the local dRuby space.
+ #
+ # This is the URI of the current server. See #current_server.
+ def uri
+ current_server.uri
+ end
+ module_function :uri
+
+ # Is +uri+ the URI for the current local server?
+ def here?(uri)
+ (current_server.uri rescue nil) == uri
+ end
+ module_function :here?
+
+ # Get the configuration of the current server.
+ #
+ # If there is no current server, this returns the default configuration.
+ # See #current_server and DRbServer::make_config.
+ def config
+ current_server.config
+ rescue
+ DRbServer.make_config
+ end
+ module_function :config
+
+ # Get the front object of the current server.
+ #
+ # This raises a DRbServerNotFound error if there is no current server.
+ # See #current_server.
+ def front
+ current_server.front
+ end
+ module_function :front
+
+ # Convert a reference into an object using the current server.
+ #
+ # This raises a DRbServerNotFound error if there is no current server.
+ # See #current_server.
+ def to_obj(ref)
+ current_server.to_obj(ref)
+ end
+
+ # Get a reference id for an object using the current server.
+ #
+ # This raises a DRbServerNotFound error if there is no current server.
+ # See #current_server.
+ def to_id(obj)
+ current_server.to_id(obj)
+ end
+ module_function :to_id
+ module_function :to_obj
+
+ # Get the thread of the primary server.
+ #
+ # This returns nil if there is no primary server. See #primary_server.
+ def thread
+ @primary_server ? @primary_server.thread : nil
+ end
+ module_function :thread
+
+ # Set the default id conv object.
+ #
+ # See DRbServer#default_id_conv.
+ def install_id_conv(idconv)
+ DRbServer.default_id_conv(idconv)
+ end
+ module_function :install_id_conv
+
+ # Set the default acl.
+ #
+ # See DRb::DRbServer.default_acl.
+ def install_acl(acl)
+ DRbServer.default_acl(acl)
+ end
+ module_function :install_acl
+end
+
+DRbObject = DRb::DRbObject
+DRbUndumped = DRb::DRbUndumped
+DRbIdConv = DRb::DRbIdConv
diff --git a/lib/drb/eq.rb b/lib/drb/eq.rb
new file mode 100644
index 0000000000..e24512d6a7
--- /dev/null
+++ b/lib/drb/eq.rb
@@ -0,0 +1,16 @@
+require 'drb/drb'
+
+module DRb
+ class DRbObject
+ def ==(other)
+ return false unless DRbObject === other
+ (@ref == other.__drbref) && (@uri == other.__drburi)
+ end
+
+ def hash
+ [@uri, @ref].hash
+ end
+
+ alias eql? ==
+ end
+end
diff --git a/lib/drb/extserv.rb b/lib/drb/extserv.rb
new file mode 100644
index 0000000000..4ed2913051
--- /dev/null
+++ b/lib/drb/extserv.rb
@@ -0,0 +1,67 @@
+=begin
+ external service
+ Copyright (c) 2000,2002 Masatoshi SEKI
+=end
+
+require 'drb/drb'
+
+module DRb
+ class ExtServ
+ include DRbUndumped
+
+ def initialize(there, name, server=nil)
+ @server = server || DRb::primary_server
+ @name = name
+ ro = DRbObject.new(nil, there)
+ @invoker = ro.regist(name, DRbObject.new(self, @server.uri))
+ end
+ attr_reader :server
+
+ def front
+ DRbObject.new(nil, @server.uri)
+ end
+
+ def stop_service
+ @invoker.unregist(@name)
+ server = @server
+ @server = nil
+ Thread.new do
+ sleep 1
+ server.stop_service
+ end
+ true
+ end
+
+ def alive?
+ @server ? @server.alive? : false
+ end
+ end
+end
+
+if __FILE__ == $0
+ class Foo
+ include DRbUndumped
+
+ def initialize(str)
+ @str = str
+ end
+
+ def hello(it)
+ "#{it}: #{self}"
+ end
+
+ def to_s
+ @str
+ end
+ end
+
+ cmd = ARGV.shift
+ case cmd
+ when 'itest1', 'itest2'
+ front = Foo.new(cmd)
+ manager = DRb::DRbServer.new(nil, front)
+ es = DRb::ExtServ.new(ARGV.shift, ARGV.shift, manager)
+ es.server.thread.join
+ end
+end
+
diff --git a/lib/drb/extservm.rb b/lib/drb/extservm.rb
new file mode 100644
index 0000000000..50009dbae2
--- /dev/null
+++ b/lib/drb/extservm.rb
@@ -0,0 +1,94 @@
+=begin
+ external service manager
+ Copyright (c) 2000 Masatoshi SEKI
+=end
+
+require 'drb/drb'
+require 'thread'
+
+module DRb
+ class ExtServManager
+ include DRbUndumped
+
+ @@command = {}
+
+ def self.command
+ @@command
+ end
+
+ def self.command=(cmd)
+ @@command = cmd
+ end
+
+ def initialize
+ @servers = {}
+ @waiting = []
+ @queue = Queue.new
+ @thread = invoke_thread
+ end
+ attr_reader :server
+
+ def service(name)
+ while true
+ server = nil
+ Thread.exclusive do
+ server = @servers[name] if @servers[name]
+ end
+ return server if server && server.alive?
+ invoke_service(name)
+ end
+ end
+
+ def regist(name, ro)
+ ary = nil
+ Thread.exclusive do
+ @servers[name] = ro
+ ary = @waiting
+ @waiting = []
+ end
+ ary.each do |th|
+ begin
+ th.run
+ rescue ThreadError
+ end
+ end
+ self
+ end
+
+ def unregist(name)
+ Thread.exclusive do
+ @servers.delete(name)
+ end
+ end
+
+ private
+ def invoke_thread
+ Thread.new do
+ while true
+ name = @queue.pop
+ invoke_service_command(name, @@command[name])
+ end
+ end
+ end
+
+ def invoke_service(name)
+ Thread.critical = true
+ @waiting.push Thread.current
+ @queue.push name
+ Thread.stop
+ end
+
+ def invoke_service_command(name, command)
+ raise "invalid command. name: #{name}" unless command
+ Thread.exclusive do
+ return if @servers.include?(name)
+ @servers[name] = false
+ end
+ if RUBY_PLATFORM =~ /mswin32/
+ system("cmd /c start /b #{command} #{DRb.uri} #{name}")
+ else
+ system("#{command} #{DRb.uri} #{name} &")
+ end
+ end
+ end
+end
diff --git a/lib/drb/gw.rb b/lib/drb/gw.rb
new file mode 100644
index 0000000000..012a2b0a11
--- /dev/null
+++ b/lib/drb/gw.rb
@@ -0,0 +1,60 @@
+require 'drb/drb'
+require 'monitor'
+
+module DRb
+ class GWIdConv < DRbIdConv
+ def to_obj(ref)
+ if Array === ref && ref[0] == :DRbObject
+ it = DRbObject.new(nil)
+ it.reinit(ref[1], ref[2])
+ return it
+ end
+ super(ref)
+ end
+ end
+
+ class GW
+ include MonitorMixin
+ def initialize
+ super()
+ @hash = {}
+ end
+
+ def [](key)
+ synchronize do
+ @hash[key]
+ end
+ end
+
+ def []=(key, v)
+ synchronize do
+ @hash[key] = v
+ end
+ end
+ end
+
+ class DRbObject
+ def self._load(s)
+ uri, ref = Marshal.load(s)
+ if DRb.uri == uri
+ return ref ? DRb.to_obj(ref) : DRb.front
+ end
+
+ it = self.new(nil)
+ it.reinit(DRb.uri, [:DRbObject, uri, ref])
+ it
+ end
+
+ def _dump(lv)
+ if DRb.uri == @uri
+ if Array === @ref && @ref[0] == :DRbObject
+ Marshal.dump([@ref[1], @ref[2]])
+ else
+ Marshal.dump([@uri, @ref]) # ??
+ end
+ else
+ Marshal.dump([DRb.uri, [:DRbObject, @uri, @ref]])
+ end
+ end
+ end
+end
diff --git a/lib/drb/invokemethod.rb b/lib/drb/invokemethod.rb
new file mode 100644
index 0000000000..412b2ab9b5
--- /dev/null
+++ b/lib/drb/invokemethod.rb
@@ -0,0 +1,36 @@
+# for ruby-1.8.0
+
+module DRb
+ class DRbServer
+ module InvokeMethod18Mixin
+ def block_yield(x)
+ if x.size == 1 && x[0].class == Array
+ x[0] = DRbArray.new(x[0])
+ end
+ block_value = @block.call(*x)
+ end
+
+ def perform_with_block
+ @obj.__send__(@msg_id, *@argv) do |*x|
+ jump_error = nil
+ begin
+ block_value = block_yield(x)
+ rescue LocalJumpError
+ jump_error = $!
+ end
+ if jump_error
+ case jump_error.reason
+ when :retry
+ retry
+ when :break
+ break(jump_error.exit_value)
+ else
+ raise jump_error
+ end
+ end
+ block_value
+ end
+ end
+ end
+ end
+end
diff --git a/lib/drb/observer.rb b/lib/drb/observer.rb
new file mode 100644
index 0000000000..e7f1668c52
--- /dev/null
+++ b/lib/drb/observer.rb
@@ -0,0 +1,22 @@
+require 'observer'
+
+module DRb
+ module DRbObservable
+ include Observable
+
+ def notify_observers(*arg)
+ if defined? @observer_state and @observer_state
+ if defined? @observer_peers
+ for i in @observer_peers.dup
+ begin
+ i.update(*arg)
+ rescue
+ delete_observer(i)
+ end
+ end
+ end
+ @observer_state = false
+ end
+ end
+ end
+end
diff --git a/lib/drb/ssl.rb b/lib/drb/ssl.rb
new file mode 100644
index 0000000000..1a454a59cc
--- /dev/null
+++ b/lib/drb/ssl.rb
@@ -0,0 +1,185 @@
+require 'socket'
+require 'openssl'
+require 'drb/drb'
+require 'singleton'
+
+module DRb
+
+ class DRbSSLSocket < DRbTCPSocket
+
+ class SSLConfig
+
+ DEFAULT = {
+ :SSLCertificate => nil,
+ :SSLPrivateKey => nil,
+ :SSLClientCA => nil,
+ :SSLCACertificatePath => nil,
+ :SSLCACertificateFile => nil,
+ :SSLVerifyMode => ::OpenSSL::SSL::VERIFY_NONE,
+ :SSLVerifyDepth => nil,
+ :SSLVerifyCallback => nil, # custom verification
+ :SSLCertificateStore => nil,
+ # Must specify if you use auto generated certificate.
+ :SSLCertName => nil, # e.g. [["CN","fqdn.example.com"]]
+ :SSLCertComment => "Generated by Ruby/OpenSSL"
+ }
+
+ def initialize(config)
+ @config = config
+ @cert = config[:SSLCertificate]
+ @pkey = config[:SSLPrivateKey]
+ @ssl_ctx = nil
+ end
+
+ def [](key);
+ @config[key] || DEFAULT[key]
+ end
+
+ def connect(tcp)
+ ssl = ::OpenSSL::SSL::SSLSocket.new(tcp, @ssl_ctx)
+ ssl.sync = true
+ ssl.connect
+ ssl
+ end
+
+ def accept(tcp)
+ ssl = OpenSSL::SSL::SSLSocket.new(tcp, @ssl_ctx)
+ ssl.sync = true
+ ssl.accept
+ ssl
+ end
+
+ def setup_certificate
+ if @cert && @pkey
+ return
+ end
+
+ rsa = OpenSSL::PKey::RSA.new(512){|p, n|
+ next unless self[:verbose]
+ case p
+ when 0; $stderr.putc "." # BN_generate_prime
+ when 1; $stderr.putc "+" # BN_generate_prime
+ when 2; $stderr.putc "*" # searching good prime,
+ # n = #of try,
+ # but also data from BN_generate_prime
+ when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
+ # but also data from BN_generate_prime
+ else; $stderr.putc "*" # BN_generate_prime
+ end
+ }
+
+ cert = OpenSSL::X509::Certificate.new
+ cert.version = 3
+ cert.serial = 0
+ name = OpenSSL::X509::Name.new(self[:SSLCertName])
+ cert.subject = name
+ cert.issuer = name
+ cert.not_before = Time.now
+ cert.not_after = Time.now + (365*24*60*60)
+ cert.public_key = rsa.public_key
+
+ ef = OpenSSL::X509::ExtensionFactory.new(nil,cert)
+ cert.extensions = [
+ ef.create_extension("basicConstraints","CA:FALSE"),
+ ef.create_extension("subjectKeyIdentifier", "hash") ]
+ ef.issuer_certificate = cert
+ cert.add_extension(ef.create_extension("authorityKeyIdentifier",
+ "keyid:always,issuer:always"))
+ if comment = self[:SSLCertComment]
+ cert.add_extension(ef.create_extension("nsComment", comment))
+ end
+ cert.sign(rsa, OpenSSL::Digest::SHA1.new)
+
+ @cert = cert
+ @pkey = rsa
+ end
+
+ def setup_ssl_context
+ ctx = ::OpenSSL::SSL::SSLContext.new
+ ctx.cert = @cert
+ ctx.key = @pkey
+ ctx.client_ca = self[:SSLClientCA]
+ ctx.ca_path = self[:SSLCACertificatePath]
+ ctx.ca_file = self[:SSLCACertificateFile]
+ ctx.verify_mode = self[:SSLVerifyMode]
+ ctx.verify_depth = self[:SSLVerifyDepth]
+ ctx.verify_callback = self[:SSLVerifyCallback]
+ ctx.cert_store = self[:SSLCertificateStore]
+ @ssl_ctx = ctx
+ end
+ end
+
+ def self.parse_uri(uri)
+ if uri =~ /^drbssl:\/\/(.*?):(\d+)(\?(.*))?$/
+ host = $1
+ port = $2.to_i
+ option = $4
+ [host, port, option]
+ else
+ raise(DRbBadScheme, uri) unless uri =~ /^drbssl:/
+ raise(DRbBadURI, 'can\'t parse uri:' + uri)
+ end
+ end
+
+ def self.open(uri, config)
+ host, port, option = parse_uri(uri)
+ host.untaint
+ port.untaint
+ soc = TCPSocket.open(host, port)
+ ssl_conf = SSLConfig::new(config)
+ ssl_conf.setup_ssl_context
+ ssl = ssl_conf.connect(soc)
+ self.new(uri, ssl, ssl_conf, true)
+ end
+
+ def self.open_server(uri, config)
+ uri = 'drbssl://:0' unless uri
+ host, port, opt = parse_uri(uri)
+ if host.size == 0
+ soc = TCPServer.open(port)
+ host = Socket.gethostname
+ else
+ soc = TCPServer.open(host, port)
+ end
+ port = soc.addr[1] if port == 0
+ @uri = "drbssl://#{host}:#{port}"
+
+ ssl_conf = SSLConfig.new(config)
+ ssl_conf.setup_certificate
+ ssl_conf.setup_ssl_context
+ self.new(@uri, soc, ssl_conf, false)
+ end
+
+ def self.uri_option(uri, config)
+ host, port, option = parse_uri(uri)
+ return "drbssl://#{host}:#{port}", option
+ end
+
+ def initialize(uri, soc, config, is_established)
+ @ssl = is_established ? soc : nil
+ super(uri, soc.to_io, config)
+ end
+
+ def stream; @ssl; end
+
+ def close
+ if @ssl
+ @ssl.close
+ @ssl = nil
+ end
+ super
+ end
+
+ def accept
+ while true
+ soc = @socket.accept
+ break if (@acl ? @acl.allow_socket?(soc) : true)
+ soc.close
+ end
+ ssl = @config.accept(soc)
+ self.class.new(uri, ssl, @config, true)
+ end
+ end
+
+ DRbProtocol.add_protocol(DRbSSLSocket)
+end
diff --git a/lib/drb/timeridconv.rb b/lib/drb/timeridconv.rb
new file mode 100644
index 0000000000..bb2c48d528
--- /dev/null
+++ b/lib/drb/timeridconv.rb
@@ -0,0 +1,91 @@
+require 'drb/drb'
+require 'monitor'
+
+module DRb
+ class TimerIdConv < DRbIdConv
+ class TimerHolder2
+ include MonitorMixin
+
+ class InvalidIndexError < RuntimeError; end
+
+ def initialize(timeout=600)
+ super()
+ @sentinel = Object.new
+ @gc = {}
+ @curr = {}
+ @renew = {}
+ @timeout = timeout
+ @keeper = keeper
+ end
+
+ def add(obj)
+ synchronize do
+ key = obj.__id__
+ @curr[key] = obj
+ return key
+ end
+ end
+
+ def fetch(key, dv=@sentinel)
+ synchronize do
+ obj = peek(key)
+ if obj == @sentinel
+ return dv unless dv == @sentinel
+ raise InvalidIndexError
+ end
+ @renew[key] = obj # KeepIt
+ return obj
+ end
+ end
+
+ def include?(key)
+ synchronize do
+ obj = peek(key)
+ return false if obj == @sentinel
+ true
+ end
+ end
+
+ def peek(key)
+ synchronize do
+ return @curr.fetch(key, @renew.fetch(key, @gc.fetch(key, @sentinel)))
+ end
+ end
+
+ private
+ def alternate
+ synchronize do
+ @gc = @curr # GCed
+ @curr = @renew
+ @renew = {}
+ end
+ end
+
+ def keeper
+ Thread.new do
+ loop do
+ size = alternate
+ sleep(@timeout)
+ end
+ end
+ end
+ end
+
+ def initialize(timeout=600)
+ @holder = TimerHolder2.new(timeout)
+ end
+
+ def to_obj(ref)
+ return super if ref.nil?
+ @holder.fetch(ref)
+ rescue TimerHolder2::InvalidIndexError
+ raise "invalid reference"
+ end
+
+ def to_id(obj)
+ return @holder.add(obj)
+ end
+ end
+end
+
+# DRb.install_id_conv(TimerIdConv.new)
diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb
new file mode 100644
index 0000000000..cdc771da1f
--- /dev/null
+++ b/lib/drb/unix.rb
@@ -0,0 +1,107 @@
+require 'socket'
+require 'drb/drb'
+require 'tmpdir'
+
+raise(LoadError, "UNIXServer is required") unless defined?(UNIXServer)
+
+module DRb
+
+ class DRbUNIXSocket < DRbTCPSocket
+ def self.parse_uri(uri)
+ if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
+ filename = $1
+ option = $3
+ [filename, option]
+ else
+ raise(DRbBadScheme, uri) unless uri =~ /^drbunix:/
+ raise(DRbBadURI, 'can\'t parse uri:' + uri)
+ end
+ end
+
+ def self.open(uri, config)
+ filename, option = parse_uri(uri)
+ filename.untaint
+ soc = UNIXSocket.open(filename)
+ self.new(uri, soc, config)
+ end
+
+ def self.open_server(uri, config)
+ filename, option = parse_uri(uri)
+ if filename.size == 0
+ soc = temp_server
+ uri = 'drbunix:' + soc.path
+ else
+ soc = UNIXServer.open(filename)
+ end
+ owner = config[:UNIXFileOwner]
+ group = config[:UNIXFileGroup]
+ if owner || group
+ require 'etc'
+ owner = Etc.getpwnam( owner ).uid if owner
+ group = Etc.getgrnam( group ).gid if group
+ File.chown owner, group, filename
+ end
+ mode = config[:UNIXFileMode]
+ File.chmod(mode, filename) if mode
+
+ self.new(uri, soc, config, true)
+ end
+
+ def self.uri_option(uri, config)
+ filename, option = parse_uri(uri)
+ return "drbunix:#{filename}", option
+ end
+
+ def initialize(uri, soc, config={}, server_mode = false)
+ super(uri, soc, config)
+ set_sockopt(@socket)
+ @server_mode = server_mode
+ @acl = nil
+ end
+
+ # import from tempfile.rb
+ Max_try = 10
+ private
+ def self.temp_server
+ tmpdir = Dir::tmpdir
+ n = 0
+ while true
+ begin
+ tmpname = sprintf('%s/druby%d.%d', tmpdir, $$, n)
+ lock = tmpname + '.lock'
+ unless File.exist?(tmpname) or File.exist?(lock)
+ Dir.mkdir(lock)
+ break
+ end
+ rescue
+ raise "cannot generate tempfile `%s'" % tmpname if n >= Max_try
+ #sleep(1)
+ end
+ n += 1
+ end
+ soc = UNIXServer.new(tmpname)
+ Dir.rmdir(lock)
+ soc
+ end
+
+ public
+ def close
+ return unless @socket
+ path = @socket.path
+ @socket.close
+ File.unlink(path) if @server_mode
+ @socket = nil
+ end
+
+ def accept
+ s = @socket.accept
+ self.class.new(nil, s, @config)
+ end
+
+ def set_sockopt(soc)
+ soc.fcntl(Fcntl::F_SETFL, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC
+ end
+ end
+
+ DRbProtocol.add_protocol(DRbUNIXSocket)
+end
diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb
index 2ae934578d..3e2604af5d 100644
--- a/lib/e2mmap.rb
+++ b/lib/e2mmap.rb
@@ -69,12 +69,11 @@ module Exception2MessageMapper
def bind(cl)
self.module_eval %[
def Raise(err = nil, *rest)
- Exception2MessageMapper.Raise(self.type, err, *rest)
+ Exception2MessageMapper.Raise(self.class, err, *rest)
end
alias Fail Raise
- def self.append_features(mod)
- super
+ def self.included(mod)
mod.extend Exception2MessageMapper
end
]
diff --git a/lib/erb.rb b/lib/erb.rb
new file mode 100644
index 0000000000..44529bf325
--- /dev/null
+++ b/lib/erb.rb
@@ -0,0 +1,473 @@
+# Tiny eRuby --- ERB2
+# Copyright (c) 1999-2000,2002,2003 Masatoshi SEKI
+# You can redistribute it and/or modify it under the same terms as Ruby.
+
+class ERB
+ Revision = '$Date$' #'
+
+ def self.version
+ "erb.rb [2.0.4 #{ERB::Revision.split[1]}]"
+ end
+end
+
+# ERB::Compiler
+class ERB
+ class Compiler
+ class PercentLine
+ def initialize(str)
+ @value = str
+ end
+ attr_reader :value
+ alias :to_s :value
+ end
+
+ class Scanner
+ SplitRegexp = /(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>)|(\n)/
+
+ @scanner_map = {}
+ def self.regist_scanner(klass, trim_mode, percent)
+ @scanner_map[[trim_mode, percent]] = klass
+ end
+
+ def self.default_scanner=(klass)
+ @default_scanner = klass
+ end
+
+ def self.make_scanner(src, trim_mode, percent)
+ klass = @scanner_map.fetch([trim_mode, percent], @default_scanner)
+ klass.new(src, trim_mode, percent)
+ end
+
+ def initialize(src, trim_mode, percent)
+ @src = src
+ @stag = nil
+ end
+ attr_accessor :stag
+
+ def scan; end
+ end
+
+ class TrimScanner < Scanner
+ TrimSplitRegexp = /(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>\n)|(%>)|(\n)/
+
+ def initialize(src, trim_mode, percent)
+ super
+ @trim_mode = trim_mode
+ @percent = percent
+ if @trim_mode == '>'
+ @scan_line = self.method(:trim_line1)
+ elsif @trim_mode == '<>'
+ @scan_line = self.method(:trim_line2)
+ elsif @trim_mode == '-'
+ @scan_line = self.method(:explicit_trim_line)
+ else
+ @scan_line = self.method(:scan_line)
+ end
+ end
+ attr_accessor :stag
+
+ def scan(&block)
+ @stag = nil
+ if @percent
+ @src.each do |line|
+ percent_line(line, &block)
+ end
+ else
+ @src.each do |line|
+ @scan_line.call(line, &block)
+ end
+ end
+ nil
+ end
+
+ def percent_line(line, &block)
+ if @stag || line[0] != ?%
+ return @scan_line.call(line, &block)
+ end
+
+ line[0] = ''
+ if line[0] == ?%
+ @scan_line.call(line, &block)
+ else
+ yield(PercentLine.new(line.chomp))
+ end
+ end
+
+ def scan_line(line)
+ line.split(SplitRegexp).each do |token|
+ next if token.empty?
+ yield(token)
+ end
+ end
+
+ def trim_line1(line)
+ line.split(TrimSplitRegexp).each do |token|
+ next if token.empty?
+ if token == "%>\n"
+ yield('%>')
+ yield(:cr)
+ break
+ end
+ yield(token)
+ end
+ end
+
+ def trim_line2(line)
+ head = nil
+ line.split(TrimSplitRegexp).each do |token|
+ next if token.empty?
+ head = token unless head
+ if token == "%>\n"
+ yield('%>')
+ if is_erb_stag?(head)
+ yield(:cr)
+ else
+ yield("\n")
+ end
+ break
+ end
+ yield(token)
+ end
+ end
+
+ ExplicitTrimRegexp = /(^[ \t]*<%-)|(-%>\n?\z)|(<%-)|(-%>)|(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>)|(\n)/
+ def explicit_trim_line(line)
+ line.split(ExplicitTrimRegexp).each do |token|
+ next if token.empty?
+ if @stag.nil? && /[ \t]*<%-/ =~ token
+ yield('<%')
+ elsif @stag && /-%>\n/ =~ token
+ yield('%>')
+ yield(:cr)
+ elsif @stag && token == '-%>'
+ yield('%>')
+ else
+ yield(token)
+ end
+ end
+ end
+
+ ERB_STAG = %w(<%= <%# <%)
+ def is_erb_stag?(s)
+ ERB_STAG.member?(s)
+ end
+ end
+
+ Scanner.default_scanner = TrimScanner
+
+ class SimpleScanner < Scanner
+ def scan
+ @src.each do |line|
+ line.split(SplitRegexp).each do |token|
+ next if token.empty?
+ yield(token)
+ end
+ end
+ end
+ end
+
+ Scanner.regist_scanner(SimpleScanner, nil, false)
+
+ begin
+ require 'strscan'
+ class SimpleScanner2 < Scanner
+ def scan
+ stag_reg = /(.*?)(<%%|<%=|<%#|<%|\n|\z)/
+ etag_reg = /(.*?)(%%>|%>|\n|\z)/
+ scanner = StringScanner.new(@src)
+ while ! scanner.eos?
+ scanner.scan(@stag ? etag_reg : stag_reg)
+ text = scanner[1]
+ elem = scanner[2]
+ yield(text) unless text.empty?
+ yield(elem) unless elem.empty?
+ end
+ end
+ end
+ Scanner.regist_scanner(SimpleScanner2, nil, false)
+
+ class PercentScanner < Scanner
+ def scan
+ new_line = true
+ stag_reg = /(.*?)(<%%|<%=|<%#|<%|\n|\z)/
+ etag_reg = /(.*?)(%%>|%>|\n|\z)/
+ scanner = StringScanner.new(@src)
+ while ! scanner.eos?
+ if new_line && @stag.nil?
+ if scanner.scan(/%%/)
+ yield('%')
+ new_line = false
+ next
+ elsif scanner.scan(/%/)
+ yield(PercentLine.new(scanner.scan(/.*?(\n|\z)/).chomp))
+ next
+ end
+ end
+ scanner.scan(@stag ? etag_reg : stag_reg)
+ text = scanner[1]
+ elem = scanner[2]
+ yield(text) unless text.empty?
+ yield(elem) unless elem.empty?
+ new_line = (elem == "\n")
+ end
+ end
+ end
+ Scanner.regist_scanner(PercentScanner, nil, true)
+
+ class ExplicitScanner < Scanner
+ def scan
+ new_line = true
+ stag_reg = /(.*?)(<%%|<%=|<%#|<%-|<%|\n|\z)/
+ etag_reg = /(.*?)(%%>|-%>|%>|\n|\z)/
+ scanner = StringScanner.new(@src)
+ while ! scanner.eos?
+ if new_line && @stag.nil? && scanner.scan(/[ \t]*<%-/)
+ yield('<%')
+ new_line = false
+ next
+ end
+ scanner.scan(@stag ? etag_reg : stag_reg)
+ text = scanner[1]
+ elem = scanner[2]
+ new_line = (elem == "\n")
+ yield(text) unless text.empty?
+ if elem == '-%>'
+ yield('%>')
+ if scanner.scan(/(\n|\z)/)
+ yield(:cr)
+ new_line = true
+ end
+ elsif elem == '<%-'
+ yield('<%')
+ else
+ yield(elem) unless elem.empty?
+ end
+ end
+ end
+ end
+ Scanner.regist_scanner(ExplicitScanner, '-', false)
+
+ rescue LoadError
+ end
+
+ class Buffer
+ def initialize(compiler)
+ @compiler = compiler
+ @line = []
+ @script = ""
+ @compiler.pre_cmd.each do |x|
+ push(x)
+ end
+ end
+ attr_reader :script
+
+ def push(cmd)
+ @line << cmd
+ end
+
+ def cr
+ @script << (@line.join('; '))
+ @line = []
+ @script << "\n"
+ end
+
+ def close
+ return unless @line
+ @compiler.post_cmd.each do |x|
+ push(x)
+ end
+ @script << (@line.join('; '))
+ @line = nil
+ end
+ end
+
+ def compile(s)
+ out = Buffer.new(self)
+
+ content = ''
+ scanner = make_scanner(s)
+ scanner.scan do |token|
+ if scanner.stag.nil?
+ case token
+ when PercentLine
+ out.push("#{@put_cmd} #{content.dump}") if content.size > 0
+ content = ''
+ out.push(token.to_s)
+ out.cr
+ when :cr
+ out.cr
+ when '<%', '<%=', '<%#'
+ scanner.stag = token
+ out.push("#{@put_cmd} #{content.dump}") if content.size > 0
+ content = ''
+ when "\n"
+ content << "\n"
+ out.push("#{@put_cmd} #{content.dump}")
+ out.cr
+ content = ''
+ when '<%%'
+ content << '<%'
+ else
+ content << token
+ end
+ else
+ case token
+ when '%>'
+ case scanner.stag
+ when '<%'
+ if content[-1] == ?\n
+ content.chop!
+ out.push(content)
+ out.cr
+ else
+ out.push(content)
+ end
+ when '<%='
+ out.push("#{@put_cmd}((#{content}).to_s)")
+ when '<%#'
+ # out.push("# #{content.dump}")
+ end
+ scanner.stag = nil
+ content = ''
+ when '%%>'
+ content << '%>'
+ else
+ content << token
+ end
+ end
+ end
+ out.push("#{@put_cmd} #{content.dump}") if content.size > 0
+ out.close
+ out.script
+ end
+
+ def prepare_trim_mode(mode)
+ case mode
+ when 1
+ return [false, '>']
+ when 2
+ return [false, '<>']
+ when 0
+ return [false, nil]
+ when String
+ perc = mode.include?('%')
+ if mode.include?('-')
+ return [perc, '-']
+ elsif mode.include?('<>')
+ return [perc, '<>']
+ elsif mode.include?('>')
+ return [perc, '>']
+ else
+ [perc, nil]
+ end
+ else
+ return [false, nil]
+ end
+ end
+
+ def make_scanner(src)
+ Scanner.make_scanner(src, @trim_mode, @percent)
+ end
+
+ def initialize(trim_mode)
+ @percent, @trim_mode = prepare_trim_mode(trim_mode)
+ @put_cmd = 'print'
+ @pre_cmd = []
+ @post_cmd = []
+ end
+ attr_reader :percent, :trim_mode
+ attr_accessor :put_cmd, :pre_cmd, :post_cmd
+ end
+end
+
+# ERB
+class ERB
+ def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
+ @safe_level = safe_level
+ compiler = ERB::Compiler.new(trim_mode)
+ set_eoutvar(compiler, eoutvar)
+ @src = compiler.compile(str)
+ @filename = nil
+ end
+ attr_reader :src
+ attr_accessor :filename
+
+ def set_eoutvar(compiler, eoutvar = '_erbout')
+ compiler.put_cmd = "#{eoutvar}.concat"
+
+ cmd = []
+ cmd.push "#{eoutvar} = ''"
+
+ compiler.pre_cmd = cmd
+
+ cmd = []
+ cmd.push(eoutvar)
+
+ compiler.post_cmd = cmd
+ end
+
+ def run(b=TOPLEVEL_BINDING)
+ print self.result(b)
+ end
+
+ def result(b=TOPLEVEL_BINDING)
+ if @safe_level
+ th = Thread.start {
+ $SAFE = @safe_level
+ eval(@src, b, (@filename || '(erb)'), 1)
+ }
+ return th.value
+ else
+ return eval(@src, b, (@filename || '(erb)'), 1)
+ end
+ end
+
+ def def_method(mod, methodname, fname='(ERB)')
+ mod.module_eval("def #{methodname}\n" + self.src + "\nend\n", fname, 0)
+ end
+
+ def def_module(methodname='erb')
+ mod = Module.new
+ def_method(mod, methodname)
+ mod
+ end
+
+ def def_class(superklass=Object, methodname='result')
+ cls = Class.new(superklass)
+ def_method(cls, methodname)
+ cls
+ end
+end
+
+# ERB::Util
+class ERB
+ module Util
+ public
+ def html_escape(s)
+ s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
+ end
+ alias h html_escape
+
+ def url_encode(s)
+ s.to_s.gsub(/[^a-zA-Z0-9_\-.]/n){ sprintf("%%%02X", $&.unpack("C")[0]) }
+ end
+ alias u url_encode
+ end
+end
+
+# ERB::DefMethod
+class ERB
+ module DefMethod
+ public
+ def def_erb_method(methodname, erb)
+ if erb.kind_of? String
+ fname = erb
+ File.open(fname) {|f| erb = ERB.new(f.read) }
+ erb.def_method(self, methodname, fname)
+ else
+ erb.def_method(self, methodname)
+ end
+ end
+ module_function :def_erb_method
+ end
+end
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
new file mode 100644
index 0000000000..d92e4c3c94
--- /dev/null
+++ b/lib/fileutils.rb
@@ -0,0 +1,1007 @@
+#
+# = fileutils.rb
+#
+# Copyright (c) 2000-2004 Minero Aoki <aamine@loveruby.net>
+#
+# This program is free software.
+# You can distribute/modify this program under the same terms of ruby.
+#
+# == module FileUtils
+#
+# Namespace for several file utility methods for copying, moving, removing, etc.
+#
+# === Module Functions
+#
+# cd(dir, options)
+# cd(dir, options) {|dir| .... }
+# pwd()
+# mkdir(dir, options)
+# mkdir_p(dir, options)
+# rmdir(dir, options)
+# ln(old, new, options)
+# ln(list, destdir, options)
+# ln_s(old, new, options)
+# ln_s(list, destdir, options)
+# ln_sf(src, dest, options)
+# cp(src, dest, options)
+# cp(list, dir, options)
+# cp_r(src, dest, options)
+# cp_r(list, dir, options)
+# mv(src, dest, options)
+# mv(list, dir, options)
+# rm(list, options)
+# rm_r(list, options)
+# rm_rf(list, options)
+# install(src, dest, mode = <src's>, options)
+# chmod(mode, list, options)
+# touch(list, options)
+#
+# The <tt>options</tt> parameter is a hash of options, taken from the list
+# <tt>:force</tt>, <tt>:noop</tt>, <tt>:preserve</tt>, and <tt>:verbose</tt>.
+# <tt>:noop</tt> means that no changes are made. The other two are obvious.
+# Each method documents the options that it honours.
+#
+# All methods that have the concept of a "source" file or directory can take
+# either one file or a list of files in that argument. See the method
+# documentation for examples.
+#
+# There are some `low level' methods, which does not accept any option:
+#
+# uptodate?(file, cmp_list)
+# copy_entry(src, dest, preserve = false, dereference = false)
+# copy_file(src, dest, preserve = false, dereference = true)
+# copy_stream(srcstream, deststream)
+# compare_file(path_a, path_b)
+# compare_stream(stream_a, stream_b)
+#
+# == module FileUtils::Verbose
+#
+# This module has all methods of FileUtils module, but it outputs messages
+# before acting. This equates to passing the <tt>:verbose</tt> flag to methods
+# in FileUtils.
+#
+# == module FileUtils::NoWrite
+#
+# This module has all methods of FileUtils module, but never changes
+# files/directories. This equates to passing the <tt>:noop</tt> flag to methods
+# in FileUtils.
+#
+# == module FileUtils::DryRun
+#
+# This module has all methods of FileUtils module, but never changes
+# files/directories. This equates to passing the <tt>:noop</tt> and
+# <tt>:verbose</tt> flags to methods in FileUtils.
+#
+
+
+module FileUtils
+
+ # All methods are module_function.
+
+ #
+ # Options: (none)
+ #
+ # Returns the name of the current directory.
+ #
+ def pwd
+ Dir.pwd
+ end
+
+ alias getwd pwd
+
+ #
+ # Options: noop verbose
+ #
+ # Changes the current directory to the directory +dir+.
+ #
+ # If this method is called with block, resumes to the old
+ # working directory after the block execution finished.
+ #
+ # FileUtils.cd('/', :verbose => true) # chdir and report it
+ #
+ def cd(dir, options = {}, &block) # :yield: dir
+ fu_check_options options, :noop, :verbose
+ fu_output_message "cd #{dir}" if options[:verbose]
+ Dir.chdir(dir, &block) unless options[:noop]
+ fu_output_message 'cd -' if options[:verbose] and block
+ end
+
+ alias chdir cd
+
+
+ #
+ # Options: (none)
+ #
+ # Returns true if +newer+ is newer than all +old_list+.
+ # Non-existent files are older than any file.
+ #
+ # FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
+ # system 'make hello.o'
+ #
+ def uptodate?(new, old_list, options = nil)
+ raise ArgumentError, 'uptodate? does not accept any option' if options
+
+ return false unless File.exist?(new)
+ new_time = File.mtime(new)
+ old_list.each do |old|
+ if File.exist?(old)
+ return false unless new_time > File.mtime(old)
+ end
+ end
+ true
+ end
+
+
+ #
+ # Options: mode noop verbose
+ #
+ # Creates one or more directories.
+ #
+ # FileUtils.mkdir 'test'
+ # FileUtils.mkdir %w( tmp data )
+ # FileUtils.mkdir 'notexist', :noop => true # Does not really create.
+ # FileUtils.mkdir 'tmp', :mode => 0700
+ #
+ def mkdir(list, options = {})
+ fu_check_options options, :mode, :noop, :verbose
+ list = fu_list(list)
+ fu_output_message "mkdir #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ mode = options[:mode] || (0777 & ~File.umask)
+ list.each do |dir|
+ Dir.mkdir dir.sub(%r</\z>, ''), mode
+ end
+ end
+
+ #
+ # Options: mode noop verbose
+ #
+ # Creates a directory and all its parent directories.
+ # For example,
+ #
+ # FileUtils.mkdir_p '/usr/local/lib/ruby'
+ #
+ # causes to make following directories, if it does not exist.
+ # * /usr
+ # * /usr/local
+ # * /usr/local/lib
+ # * /usr/local/lib/ruby
+ #
+ # You can pass several directories at a time in a list.
+ #
+ def mkdir_p(list, options = {})
+ fu_check_options options, :mode, :noop, :verbose
+ list = fu_list(list)
+ fu_output_message "mkdir -p #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
+ return *list if options[:noop]
+
+ mode = options[:mode] || (0777 & ~File.umask)
+ list.map {|path| path.sub(%r</\z>, '') }.each do |path|
+ # optimize for the most common case
+ begin
+ Dir.mkdir path, mode
+ next
+ rescue SystemCallError
+ next if File.directory?(path)
+ end
+
+ stack = []
+ until path == stack.last # dirname("/")=="/", dirname("C:/")=="C:/"
+ stack.push path
+ path = File.dirname(path)
+ end
+ stack.reverse_each do |path|
+ begin
+ Dir.mkdir path, mode
+ rescue SystemCallError => err
+ raise unless File.directory?(path)
+ end
+ end
+ end
+
+ return *list
+ end
+
+ alias mkpath mkdir_p
+ alias makedirs mkdir_p
+
+
+ #
+ # Options: noop, verbose
+ #
+ # Removes one or more directories.
+ #
+ # FileUtils.rmdir 'somedir'
+ # FileUtils.rmdir %w(somedir anydir otherdir)
+ # # Does not really remove directory; outputs message.
+ # FileUtils.rmdir 'somedir', :verbose => true, :noop => true
+ #
+ def rmdir(list, options = {})
+ fu_check_options options, :noop, :verbose
+ list = fu_list(list)
+ fu_output_message "rmdir #{list.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ list.each do |dir|
+ Dir.rmdir dir.sub(%r</\z>, '')
+ end
+ end
+
+
+ #
+ # Options: force noop verbose
+ #
+ # <b><tt>ln( old, new, options = {} )</tt></b>
+ #
+ # Creates a hard link +new+ which points to +old+.
+ # If +new+ already exists and it is a directory, creates a symbolic link +new/old+.
+ # If +new+ already exists and it is not a directory, raises Errno::EEXIST.
+ # But if :force option is set, overwrite +new+.
+ #
+ # FileUtils.ln 'gcc', 'cc', :verbose => true
+ # FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
+ #
+ # <b><tt>ln( list, destdir, options = {} )</tt></b>
+ #
+ # Creates several hard links in a directory, with each one pointing to the
+ # item in +list+. If +destdir+ is not a directory, raises Errno::ENOTDIR.
+ #
+ # include FileUtils
+ # cd '/bin'
+ # ln %w(cp mv mkdir), '/usr/bin' # Now /usr/bin/cp and /bin/cp are linked.
+ #
+ def ln(src, dest, options = {})
+ fu_check_options options, :force, :noop, :verbose
+ fu_output_message "ln#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ fu_each_src_dest0(src, dest) do |s,d|
+ remove_file d, true if options[:force]
+ File.link s, d
+ end
+ end
+
+ alias link ln
+
+ #
+ # Options: force noop verbose
+ #
+ # <b><tt>ln_s( old, new, options = {} )</tt></b>
+ #
+ # Creates a symbolic link +new+ which points to +old+. If +new+ already
+ # exists and it is a directory, creates a symbolic link +new/old+. If +new+
+ # already exists and it is not a directory, raises Errno::EEXIST. But if
+ # :force option is set, overwrite +new+.
+ #
+ # FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
+ # FileUtils.ln_s 'verylongsourcefilename.c', 'c', :force => true
+ #
+ # <b><tt>ln_s( list, destdir, options = {} )</tt></b>
+ #
+ # Creates several symbolic links in a directory, with each one pointing to the
+ # item in +list+. If +destdir+ is not a directory, raises Errno::ENOTDIR.
+ #
+ # If +destdir+ is not a directory, raises Errno::ENOTDIR.
+ #
+ # FileUtils.ln_s Dir.glob('bin/*.rb'), '/home/aamine/bin'
+ #
+ def ln_s(src, dest, options = {})
+ fu_check_options options, :force, :noop, :verbose
+ fu_output_message "ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ fu_each_src_dest0(src, dest) do |s,d|
+ remove_file d, true if options[:force]
+ File.symlink s, d
+ end
+ end
+
+ alias symlink ln_s
+
+ #
+ # Options: noop verbose
+ #
+ # Same as
+ # #ln_s(src, dest, :force)
+ #
+ def ln_sf(src, dest, options = {})
+ fu_check_options options, :noop, :verbose
+ options = options.dup
+ options[:force] = true
+ ln_s src, dest, options
+ end
+
+
+ #
+ # Options: preserve noop verbose
+ #
+ # Copies a file +src+ to +dest+. If +dest+ is a directory, copies
+ # +src+ to +dest/src+.
+ #
+ # If +src+ is a list of files, then +dest+ must be a directory.
+ #
+ # FileUtils.cp 'eval.c', 'eval.c.org'
+ # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
+ # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
+ #
+ def cp(src, dest, options = {})
+ fu_check_options options, :preserve, :noop, :verbose
+ fu_output_message "cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ fu_each_src_dest(src, dest) do |s,d|
+ copy_file s, d, options[:preserve]
+ end
+ end
+
+ alias copy cp
+
+ #
+ # Options: preserve noop verbose
+ #
+ # Copies +src+ to +dest+. If +src+ is a directory, this method copies
+ # all its contents recursively. If +dest+ is a directory, copies
+ # +src+ to +dest/src+.
+ #
+ # +src+ can be a list of files.
+ #
+ # # Installing ruby library "mylib" under the site_ruby
+ # FileUtils.rm_r site_ruby + '/mylib', :force
+ # FileUtils.cp_r 'lib/', site_ruby + '/mylib'
+ #
+ # # Examples of copying several files to target directory.
+ # FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
+ # FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop, :verbose
+ #
+ # # If you want to copy all contents of a directory instead of the
+ # # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
+ # # use following code.
+ # FileUtils.cp_r 'src/.', 'dest' # cp_r('src', 'dest') makes src/dest,
+ # # but this doesn't.
+ #
+ def cp_r(src, dest, options = {})
+ fu_check_options options, :preserve, :noop, :verbose
+ fu_output_message "cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ fu_each_src_dest(src, dest) do |s,d|
+ if File.directory?(s)
+ fu_traverse(s) {|rel, deref, st|
+ ctx = CopyContext_.new(options[:preserve], deref, st)
+ ctx.copy_entry "#{s}/#{rel}", "#{d}/#{rel}"
+ }
+ else
+ copy_file s, d, options[:preserve]
+ end
+ end
+ end
+
+ def fu_traverse(prefix, dereference_root = true) #:nodoc:
+ stack = ['.']
+ deref = dereference_root
+ while rel = stack.pop
+ st = File.lstat("#{prefix}/#{rel}")
+ if st.directory? and (deref or not st.symlink?)
+ stack.concat Dir.entries("#{prefix}/#{rel}")\
+ .reject {|ent| ent == '.' or ent == '..' }\
+ .map {|ent| "#{rel}/#{ent}" }.reverse
+ end
+ yield rel, deref, st
+ deref = false
+ end
+ end
+ private :fu_traverse
+
+ #
+ # Copies a file system entry +src+ to +dest+.
+ # This method preserves file types, c.f. FIFO, device files, directory....
+ #
+ # Both of +src+ and +dest+ must be a path name.
+ # +src+ must exist, +dest+ must not exist.
+ #
+ # If +preserve+ is true, this method preserves owner, group and permissions.
+ # If +dereference+ is true, this method copies a target of symbolic link
+ # instead of a symbolic link itself.
+ #
+ def copy_entry(src, dest, preserve = false, dereference = false)
+ CopyContext_.new(preserve, dereference).copy_entry src, dest
+ end
+
+ #
+ # Copies file contents of +src+ to +dest+.
+ # Both of +src+ and +dest+ must be a path name.
+ #
+ def copy_file(src, dest, preserve = false, dereference = true)
+ CopyContext_.new(preserve, dereference).copy_content src, dest
+ end
+
+ #
+ # Copies stream +src+ to +dest+.
+ # Both of +src+ and +dest+ must be a IO.
+ #
+ def copy_stream(src, dest)
+ fu_copy_stream0 src, dest, fu_stream_blksize(src, dest)
+ end
+
+ def fu_copy_stream0(src, dest, blksize) #:nodoc:
+ begin
+ while true
+ dest.syswrite src.sysread(blksize)
+ end
+ rescue EOFError
+ end
+ end
+ private :fu_copy_stream0
+
+ class CopyContext_
+ include ::FileUtils
+
+ def initialize(preserve = false, dereference = false, stat = nil)
+ @preserve = preserve
+ @dereference = dereference
+ @stat = stat
+ end
+
+ def copy_entry(src, dest)
+ preserve(src, dest) {
+ _copy_entry src, dest
+ }
+ end
+
+ def copy_content(src, dest)
+ preserve(src, dest) {
+ _copy_content src, dest
+ }
+ end
+
+ private
+
+ def _copy_entry(src, dest)
+ st = stat(src)
+ case
+ when st.file?
+ _copy_content src, dest
+ when st.directory?
+ begin
+ Dir.mkdir File.expand_path(dest)
+ rescue => err
+ raise unless File.directory?(dest)
+ end
+ when st.symlink?
+ File.symlink File.readlink(src), dest
+ when st.chardev?
+ raise "cannot handle device file" unless File.respond_to?(:mknod)
+ mknod dest, ?c, 0666, st.rdev
+ when st.blockdev?
+ raise "cannot handle device file" unless File.respond_to?(:mknod)
+ mknod dest, ?b, 0666, st.rdev
+ when st.socket?
+ raise "cannot handle socket" unless File.respond_to?(:mknod)
+ mknod dest, nil, st.mode, 0
+ when st.pipe?
+ raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
+ mkfifo dest, 0666
+ when (st.mode & 0xF000) == (_S_IF_DOOR = 0xD000) # door
+ raise "cannot handle door: #{src}"
+ else
+ raise "unknown file type: #{src}"
+ end
+ end
+
+ def _copy_content(src, dest)
+ st = stat(src)
+ File.open(src, 'rb') {|r|
+ File.open(dest, 'wb', st.mode) {|w|
+ fu_copy_stream0 r, w, (fu_blksize(st) || fu_default_blksize())
+ }
+ }
+ end
+
+ def preserve(src, dest)
+ return yield unless @preserve
+ st = stat(src)
+ yield
+ File.utime st.atime, st.mtime, dest
+ begin
+ chown st.uid, st.gid, dest
+ rescue Errno::EPERM
+ # clear setuid/setgid
+ chmod st.mode & 01777, dest
+ else
+ chmod st.mode, dest
+ end
+ end
+
+ def stat(path)
+ @stat ||= ::File.stat(path)
+ end
+
+ def chmod(mode, path)
+ if @dereference
+ ::File.chmod mode, path
+ else
+ begin
+ ::File.lchmod mode, path
+ rescue NotImplementedError
+ # just ignore this because chmod(symlink) changes attributes of
+ # symlink target, which is not our intent.
+ end
+ end
+ end
+
+ def chown(uid, gid, path)
+ if @dereference
+ ::File.chown uid, gid, path
+ else
+ begin
+ ::File.lchown uid, gid, path
+ rescue NotImplementedError
+ # just ignore this because chown(symlink) changes attributes of
+ # symlink target, which is not our intent.
+ end
+ end
+ end
+ end
+
+ #
+ # Options: force noop verbose
+ #
+ # Moves file(s) +src+ to +dest+. If +file+ and +dest+ exist on the different
+ # disk partition, the file is copied instead.
+ #
+ # FileUtils.mv 'badname.rb', 'goodname.rb'
+ # FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true # no error
+ #
+ # FileUtils.mv %w(junk.txt dust.txt), '/home/aamine/.trash/'
+ # FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
+ #
+ def mv(src, dest, options = {})
+ fu_check_options options, :force, :noop, :verbose
+ fu_output_message "mv#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ fu_each_src_dest(src, dest) do |s,d|
+ if rename_cannot_overwrite_file? and File.file?(d)
+ begin
+ File.unlink d
+ rescue SystemCallError
+ raise unless options[:force]
+ end
+ end
+ begin
+ File.rename s, d
+ rescue SystemCallError
+ begin
+ copy_entry s, d, true
+ File.unlink s
+ rescue SystemCallError
+ raise unless options[:force]
+ end
+ end
+ end
+ end
+
+ alias move mv
+
+ def rename_cannot_overwrite_file? #:nodoc:
+ /djgpp|cygwin|mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM
+ end
+ private :rename_cannot_overwrite_file?
+
+
+ #
+ # Options: force noop verbose
+ #
+ # Remove file(s) specified in +list+. This method cannot remove directories.
+ # All StandardErrors are ignored when the :force option is set.
+ #
+ # FileUtils.rm %w( junk.txt dust.txt )
+ # FileUtils.rm Dir.glob('*.so')
+ # FileUtils.rm 'NotExistFile', :force => true # never raises exception
+ #
+ def rm(list, options = {})
+ fu_check_options options, :force, :noop, :verbose
+ list = fu_list(list)
+ fu_output_message "rm#{options[:force] ? ' -f' : ''} #{list.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ list.each do |fname|
+ remove_file fname, options[:force]
+ end
+ end
+
+ alias remove rm
+
+ #
+ # Options: noop verbose
+ #
+ # Same as
+ # #rm(list, :force)
+ #
+ def rm_f(list, options = {})
+ fu_check_options options, :noop, :verbose
+ options = options.dup
+ options[:force] = true
+ rm list, options
+ end
+
+ alias safe_unlink rm_f
+
+ #
+ # Options: force noop verbose
+ #
+ # remove files +list+[0] +list+[1]... If +list+[n] is a directory,
+ # removes its all contents recursively. This method ignores
+ # StandardError when :force option is set.
+ #
+ # FileUtils.rm_r Dir.glob('/tmp/*')
+ # FileUtils.rm_r '/', :force => true # :-)
+ #
+ def rm_r(list, options = {})
+ fu_check_options options, :force, :noop, :verbose
+ list = fu_list(list)
+ fu_output_message "rm -r#{options[:force] ? 'f' : ''} #{list.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ list.each do |fname|
+ begin
+ st = File.lstat(fname)
+ rescue
+ next if options[:force]
+ raise
+ end
+ if st.symlink? then remove_file fname, options[:force]
+ elsif st.directory? then remove_dir fname, options[:force]
+ else remove_file fname, options[:force]
+ end
+ end
+ end
+
+ #
+ # Options: noop verbose
+ #
+ # Same as
+ # #rm_r(list, :force => true)
+ #
+ def rm_rf(list, options = {})
+ fu_check_options options, :noop, :verbose
+ options = options.dup
+ options[:force] = true
+ rm_r list, options
+ end
+
+ alias rmtree rm_rf
+
+ def remove_file(fname, force = false) #:nodoc:
+ first_time_p = true
+ begin
+ File.unlink fname
+ rescue Errno::ENOENT
+ raise unless force
+ rescue
+ if first_time_p
+ # try once more for Windows
+ first_time_p = false
+ File.chmod 0777, fname
+ retry
+ end
+ raise
+ end
+ end
+
+ def remove_dir(dir, force = false) #:nodoc:
+ Dir.foreach(dir) do |file|
+ next if /\A\.\.?\z/ === file
+ path = "#{dir}/#{file}"
+ if File.symlink?(path)
+ remove_file path, force
+ elsif File.directory?(path)
+ remove_dir path, force
+ else
+ remove_file path, force
+ end
+ end
+ begin
+ Dir.rmdir dir.sub(%r</\z>, '')
+ rescue Errno::ENOENT
+ raise unless force
+ end
+ end
+
+
+ #
+ # Returns true if the contents of a file A and a file B are identical.
+ #
+ # FileUtils.compare_file('somefile', 'somefile') #=> true
+ # FileUtils.compare_file('/bin/cp', '/bin/mv') #=> maybe false
+ #
+ def compare_file(a, b)
+ return false unless File.size(a) == File.size(b)
+ File.open(a, 'rb') {|fa|
+ File.open(b, 'rb') {|fb|
+ return compare_stream(fa, fb)
+ }
+ }
+ end
+
+ alias identical? compare_file
+ alias cmp compare_file
+
+ #
+ # Returns true if the contents of a stream +a+ and +b+ are identical.
+ #
+ def compare_stream(a, b)
+ bsize = fu_stream_blksize(a, b)
+ sa = sb = nil
+ while sa == sb
+ sa = a.read(bsize)
+ sb = b.read(bsize)
+ unless sa and sb
+ if sa.nil? and sb.nil?
+ return true
+ end
+ end
+ end
+ false
+ end
+
+
+ #
+ # Options: mode noop verbose
+ #
+ # If +src+ is not same as +dest+, copies it and changes the permission
+ # mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
+ #
+ # FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
+ # FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
+ #
+ def install(src, dest, options = {})
+ fu_check_options options, :mode, :preserve, :noop, :verbose
+ fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ fu_each_src_dest(src, dest) do |s,d|
+ unless File.exist?(d) and compare_file(s,d)
+ remove_file d, true
+ st = File.stat(s) if options[:preserve]
+ copy_file s, d
+ File.utime st.atime, st.mtime, d if options[:preserve]
+ File.chmod options[:mode], d if options[:mode]
+ end
+ end
+ end
+
+
+ #
+ # Options: noop verbose
+ #
+ # Changes permission bits on the named files (in +list+) to the bit pattern
+ # represented by +mode+.
+ #
+ # FileUtils.chmod 0755, 'somecommand'
+ # FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
+ # FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
+ #
+ def chmod(mode, list, options = {})
+ fu_check_options options, :noop, :verbose
+ list = fu_list(list)
+ fu_output_message sprintf('chmod %o %s', mode, list.join(' ')) if options[:verbose]
+ return if options[:noop]
+ File.chmod mode, *list
+ end
+
+
+ #
+ # Options: noop verbose
+ #
+ # Updates modification time (mtime) and access time (atime) of file(s) in
+ # +list+. Files are created if they don't exist.
+ #
+ # FileUtils.touch 'timestamp'
+ # FileUtils.touch Dir.glob('*.c'); system 'make'
+ #
+ def touch(list, options = {})
+ fu_check_options options, :noop, :verbose
+ list = fu_list(list)
+ fu_output_message "touch #{list.join ' '}" if options[:verbose]
+ return if options[:noop]
+
+ t = Time.now
+ list.each do |fname|
+ begin
+ File.utime(t, t, fname)
+ rescue Errno::ENOENT
+ File.open(fname, 'a') {
+ ;
+ }
+ end
+ end
+ end
+
+ private
+
+ def fu_check_options(options, *optdecl)
+ h = options.dup
+ optdecl.each do |name|
+ h.delete name
+ end
+ raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty?
+ end
+
+ def fu_list(arg)
+ [arg].flatten.map {|path| path.to_str }
+ end
+
+ def fu_each_src_dest(src, dest)
+ fu_each_src_dest0(src, dest) do |s, d|
+ raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
+ yield s, d
+ end
+ end
+
+ def fu_each_src_dest0(src, dest)
+ if src.is_a?(Array)
+ src.each do |s|
+ yield s.to_str, File.join(dest, File.basename(s))
+ end
+ else
+ if File.directory?(dest)
+ yield src.to_str, File.join(dest, File.basename(src))
+ else
+ yield src.to_str, dest.to_str
+ end
+ end
+ end
+
+ def fu_same?(a, b)
+ if have_st_ino?
+ st1 = File.stat(a)
+ st2 = File.stat(b)
+ st1.dev == st2.dev and st1.ino == st2.ino
+ else
+ File.expand_path(a) == File.expand_path(b)
+ end
+ rescue Errno::ENOENT
+ return false
+ end
+
+ def have_st_ino?
+ /mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM
+ end
+
+ def fu_stream_blksize(*streams)
+ streams.each do |s|
+ next unless s.respond_to?(:stat)
+ size = fu_blksize(s.stat)
+ return size if size
+ end
+ fu_default_blksize()
+ end
+
+ def fu_blksize(st)
+ s = st.blksize
+ return nil unless s
+ return nil if s == 0
+ s
+ end
+
+ def fu_default_blksize
+ 1024
+ end
+
+ @fileutils_output = $stderr
+ @fileutils_label = ''
+
+ def fu_output_message(msg)
+ @fileutils_output ||= $stderr
+ @fileutils_label ||= ''
+ @fileutils_output.puts @fileutils_label + msg
+ end
+
+ def fu_update_option(args, new)
+ if args.last.is_a?(Hash)
+ args.last.update new
+ else
+ args.push new
+ end
+ args
+ end
+
+
+ extend self
+
+
+ OPT_TABLE = {
+ 'cd' => %w( noop verbose ),
+ 'chdir' => %w( noop verbose ),
+ 'chmod' => %w( noop verbose ),
+ 'copy' => %w( noop verbose preserve ),
+ 'cp' => %w( noop verbose preserve ),
+ 'cp_r' => %w( noop verbose preserve ),
+ 'install' => %w( noop verbose preserve mode ),
+ 'link' => %w( noop verbose force ),
+ 'ln' => %w( noop verbose force ),
+ 'ln_s' => %w( noop verbose force ),
+ 'ln_sf' => %w( noop verbose ),
+ 'makedirs' => %w( noop verbose ),
+ 'mkdir' => %w( noop verbose mode ),
+ 'mkdir_p' => %w( noop verbose mode ),
+ 'mkpath' => %w( noop verbose ),
+ 'move' => %w( noop verbose force ),
+ 'mv' => %w( noop verbose force ),
+ 'remove' => %w( noop verbose force ),
+ 'rm' => %w( noop verbose force ),
+ 'rm_f' => %w( noop verbose ),
+ 'rm_r' => %w( noop verbose force ),
+ 'rm_rf' => %w( noop verbose ),
+ 'rmtree' => %w( noop verbose ),
+ 'rmdir' => %w( noop verbose ),
+ 'safe_unlink' => %w( noop verbose ),
+ 'symlink' => %w( noop verbose force ),
+ 'touch' => %w( noop verbose )
+ }
+
+
+ #
+ # This module has all methods of FileUtils module, but it outputs messages
+ # before acting. This equates to passing the <tt>:verbose</tt> flag to
+ # methods in FileUtils.
+ #
+ module Verbose
+ include FileUtils
+ @fileutils_output = $stderr
+ @fileutils_label = ''
+ FileUtils::OPT_TABLE.each do |name, opts|
+ next unless opts.include?('verbose')
+ module_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{name}(*args)
+ super(*fu_update_option(args, :verbose => true))
+ end
+ EOS
+ end
+ extend self
+ end
+
+ #
+ # This module has all methods of FileUtils module, but never changes
+ # files/directories. This equates to passing the <tt>:noop</tt> flag
+ # to methods in FileUtils.
+ #
+ module NoWrite
+ include FileUtils
+ @fileutils_output = $stderr
+ @fileutils_label = ''
+ FileUtils::OPT_TABLE.each do |name, opts|
+ next unless opts.include?('noop')
+ module_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{name}(*args)
+ super(*fu_update_option(args, :noop => true))
+ end
+ EOS
+ end
+ extend self
+ end
+
+ #
+ # This module has all methods of FileUtils module, but never changes
+ # files/directories, with printing message before acting.
+ # This equates to passing the <tt>:noop</tt> and <tt>:verbose</tt> flag
+ # to methods in FileUtils.
+ #
+ module DryRun
+ include FileUtils
+ @fileutils_output = $stderr
+ @fileutils_label = ''
+ FileUtils::OPT_TABLE.each do |name, opts|
+ next unless opts.include?('noop')
+ module_eval(<<-EOS, __FILE__, __LINE__ + 1)
+ def #{name}(*args)
+ super(*fu_update_option(args, :noop => true, :verbose => true))
+ end
+ EOS
+ end
+ extend self
+ end
+
+end
diff --git a/lib/final.rb b/lib/final.rb
deleted file mode 100644
index 9d81238823..0000000000
--- a/lib/final.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# $Id$
-# Copyright (C) 1998 Yukihiro Matsumoto. All rights reserved.
-
-# final.rb is integrated into ObjectSpace; no longer needed.
diff --git a/lib/finalize.rb b/lib/finalize.rb
index 598569f52e..ed1ccc830f 100644
--- a/lib/finalize.rb
+++ b/lib/finalize.rb
@@ -43,159 +43,144 @@
module Finalizer
RCS_ID='-$Id: finalize.rb,v 1.4 1998/02/27 05:34:33 keiju Exp keiju $-'
-
- # @dependency: {id => [[dependant, method, *opt], ...], ...}
-
- # add dependency R_method(obj, dependant)
- def add_dependency(obj, dependant, method = :finalize, *opt)
- ObjectSpace.call_finalizer(obj)
- method = method.intern unless method.kind_of?(Integer)
- assoc = [dependant, method].concat(opt)
- if dep = @dependency[obj.id]
- dep.push assoc
- else
- @dependency[obj.id] = [assoc]
+
+ class <<self
+ # @dependency: {id => [[dependant, method, *opt], ...], ...}
+
+ # add dependency R_method(obj, dependant)
+ def add_dependency(obj, dependant, method = :finalize, *opt)
+ ObjectSpace.call_finalizer(obj)
+ method = method.intern unless method.kind_of?(Integer)
+ assoc = [dependant, method].concat(opt)
+ if dep = @dependency[obj.object_id]
+ dep.push assoc
+ else
+ @dependency[obj.object_id] = [assoc]
+ end
end
- end
- alias add add_dependency
-
- # delete dependency R_method(obj, dependant)
- def delete_dependency(id, dependant, method = :finalize)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assoc in @dependency[id]
- assoc.delete_if do
- |d, m, *o|
- d == dependant && m == method
+ alias add add_dependency
+
+ # delete dependency R_method(obj, dependant)
+ def delete_dependency(id, dependant, method = :finalize)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assoc in @dependency[id]
+ assoc.delete_if do
+ |d, m, *o|
+ d == dependant && m == method
+ end
+ @dependency.delete(id) if assoc.empty?
end
- @dependency.delete(id) if assoc.empty?
end
- end
- alias delete delete_dependency
-
- # delete dependency R_*(obj, dependant)
- def delete_all_dependency(id, dependant)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assoc in @dependency[id]
- assoc.delete_if do
- |d, m, *o|
- d == dependant
+ alias delete delete_dependency
+
+ # delete dependency R_*(obj, dependant)
+ def delete_all_dependency(id, dependant)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assoc in @dependency[id]
+ assoc.delete_if do
+ |d, m, *o|
+ d == dependant
+ end
+ @dependency.delete(id) if assoc.empty?
end
- @dependency.delete(id) if assoc.empty?
end
- end
-
- # delete dependency R_method(*, dependant)
- def delete_by_dependant(dependant, method = :finalize)
- method = method.intern unless method.kind_of?(Integer)
- for id in @dependency.keys
- delete(id, dependant, method)
+
+ # delete dependency R_method(*, dependant)
+ def delete_by_dependant(dependant, method = :finalize)
+ method = method.intern unless method.kind_of?(Integer)
+ for id in @dependency.keys
+ delete(id, dependant, method)
+ end
end
- end
-
- # delete dependency R_*(*, dependant)
- def delete_all_by_dependant(dependant)
- for id in @dependency.keys
- delete_all_dependency(id, dependant)
+
+ # delete dependency R_*(*, dependant)
+ def delete_all_by_dependant(dependant)
+ for id in @dependency.keys
+ delete_all_dependency(id, dependant)
+ end
end
- end
-
- # finalize the depandant connected by dependency R_method(obj, dependtant)
- def finalize_dependency(id, dependant, method = :finalize)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assocs in @dependency[id]
- assocs.delete_if do
- |d, m, *o|
- d.send(m, id, *o) if ret = d == dependant && m == method
- ret
+
+ # finalize the depandant connected by dependency R_method(obj, dependtant)
+ def finalize_dependency(id, dependant, method = :finalize)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assocs in @dependency[id]
+ assocs.delete_if do
+ |d, m, *o|
+ d.send(m, id, *o) if ret = d == dependant && m == method
+ ret
+ end
+ @dependency.delete(id) if assoc.empty?
end
- @dependency.delete(id) if assoc.empty?
end
- end
- alias finalize finalize_dependency
-
- # finalize all dependants connected by dependency R_*(obj, dependtant)
- def finalize_all_dependency(id, dependant)
- id = id.id unless id.kind_of?(Integer)
- method = method.intern unless method.kind_of?(Integer)
- for assoc in @dependency[id]
- assoc.delete_if do
- |d, m, *o|
- d.send(m, id, *o) if ret = d == dependant
+ alias finalize finalize_dependency
+
+ # finalize all dependants connected by dependency R_*(obj, dependtant)
+ def finalize_all_dependency(id, dependant)
+ id = id.object_id unless id.kind_of?(Integer)
+ method = method.intern unless method.kind_of?(Integer)
+ for assoc in @dependency[id]
+ assoc.delete_if do
+ |d, m, *o|
+ d.send(m, id, *o) if ret = d == dependant
+ end
+ @dependency.delete(id) if assoc.empty?
end
- @dependency.delete(id) if assoc.empty?
end
- end
-
- # finalize the dependant connected by dependency R_method(*, dependtant)
- def finalize_by_dependant(dependant, method = :finalize)
- method = method.intern unless method.kind_of?(Integer)
- for id in @dependency.keys
- finalize(id, dependant, method)
+
+ # finalize the dependant connected by dependency R_method(*, dependtant)
+ def finalize_by_dependant(dependant, method = :finalize)
+ method = method.intern unless method.kind_of?(Integer)
+ for id in @dependency.keys
+ finalize(id, dependant, method)
+ end
end
- end
-
- # finalize all dependants connected by dependency R_*(*, dependtant)
- def finalize_all_by_dependant(dependant)
- for id in @dependency.keys
- finalize_all_dependency(id, dependant)
+
+ # finalize all dependants connected by dependency R_*(*, dependtant)
+ def finalize_all_by_dependant(dependant)
+ for id in @dependency.keys
+ finalize_all_dependency(id, dependant)
+ end
end
- end
-
- # finalize all dependants registered to the Finalizer.
- def finalize_all
- for id, assocs in @dependency
- for dependant, method, *opt in assocs
- dependant.send(method, id, *opt)
+
+ # finalize all dependants registered to the Finalizer.
+ def finalize_all
+ for id, assocs in @dependency
+ for dependant, method, *opt in assocs
+ dependant.send(method, id, *opt)
+ end
+ assocs.clear
end
- assocs.clear
end
- end
-
- # method to call finalize_* safely.
- def safe
- old_status = Thread.critical
- Thread.critical = true
- ObjectSpace.remove_finalizer(@proc)
- yield
- ObjectSpace.add_finalizer(@proc)
- Thread.critical = old_status
- end
-
- # registering function to ObjectSpace#add_finalizer
- def final_of(id)
- if assocs = @dependency.delete(id)
- for dependant, method, *opt in assocs
- dependant.send(method, id, *opt)
+
+ # method to call finalize_* safely.
+ def safe
+ old_status = Thread.critical
+ Thread.critical = true
+ ObjectSpace.remove_finalizer(@proc)
+ begin
+ yield
+ ensure
+ ObjectSpace.add_finalizer(@proc)
+ Thread.critical = old_status
+ end
+ end
+
+ private
+
+ # registering function to ObjectSpace#add_finalizer
+ def final_of(id)
+ if assocs = @dependency.delete(id)
+ for dependant, method, *opt in assocs
+ dependant.send(method, id, *opt)
+ end
end
end
+
end
-
@dependency = Hash.new
@proc = proc{|id| final_of(id)}
ObjectSpace.add_finalizer(@proc)
-
- module_function :add
- module_function :add_dependency
-
- module_function :delete
- module_function :delete_dependency
- module_function :delete_all_dependency
- module_function :delete_by_dependant
- module_function :delete_all_by_dependant
-
- module_function :finalize
- module_function :finalize_dependency
- module_function :finalize_all_dependency
- module_function :finalize_by_dependant
- module_function :finalize_all_by_dependant
- module_function :finalize_all
-
- module_function :safe
-
- module_function :final_of
- private_class_method :final_of
-
end
diff --git a/lib/find.rb b/lib/find.rb
index b220018b6b..52efde81fd 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -1,18 +1,43 @@
-# Usage:
-# require "find"
#
-# Find.find('/foo','/bar') {|f| ...}
-# or
-# include Find
-# find('/foo','/bar') {|f| ...}
+# find.rb: the Find module for processing all files under a given directory.
#
+#
+# The +Find+ module supports the top-down traversal of a set of file paths.
+#
+# For example, to total the size of all files under your home directory,
+# ignoring anything in a "dot" directory (e.g. $HOME/.ssh):
+#
+# require 'find'
+#
+# total_size = 0
+#
+# Find.find(ENV["HOME"]) do |path|
+# if FileTest.directory?(path)
+# if File.basename(path)[0] == ?.
+# Find.prune # Don't look any further into this directory.
+# else
+# next
+# end
+# else
+# total_size += FileTest.size(path)
+# end
+# end
+#
module Find
- def find(*path)
- path.collect!{|d| d.dup}
- while file = path.shift
+
+ #
+ # Calls the associated block with the name of every file and directory listed
+ # as arguments, then recursively on their subdirectories, and so on.
+ #
+ # See the +Find+ module documentation for an example.
+ #
+ def find(*paths) # :yield: path
+ paths.collect!{|d| d.dup}
+ while file = paths.shift
catch(:prune) do
- yield file
+ next unless File.exist? file
+ yield file.dup.taint
begin
if File.lstat(file).directory? then
d = Dir.open(file)
@@ -26,20 +51,29 @@ module Find
else
f = File.join(file, f)
end
- path.unshift f
+ paths.unshift f.untaint
end
ensure
d.close
end
end
- rescue Errno::ENOENT
+ rescue Errno::ENOENT, Errno::EACCES
end
end
end
end
+ #
+ # Skips the current file or directory, restarting the loop with the next
+ # entry. If the current file is a directory, that directory will not be
+ # recursively entered. Meaningful only within the block associated with
+ # Find::find.
+ #
+ # See the +Find+ module documentation for an example.
+ #
def prune
throw :prune
end
+
module_function :find, :prune
end
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
new file mode 100644
index 0000000000..b845f76ec4
--- /dev/null
+++ b/lib/forwardable.rb
@@ -0,0 +1,94 @@
+#
+# forwardable.rb -
+# $Release Version: 1.1$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+# original definition by delegator.rb
+# --
+# Usage:
+#
+# class Foo
+# extend Forwardable
+#
+# def_delegators("@out", "printf", "print")
+# def_delegators(:@in, :gets)
+# def_delegator(:@contents, :[], "content_at")
+# end
+# f = Foo.new
+# f.printf ...
+# f.gets
+# f.content_at(1)
+#
+# g = Goo.new
+# g.extend SingleForwardable
+# g.def_delegator("@out", :puts)
+# g.puts ...
+#
+#
+
+module Forwardable
+
+ @debug = nil
+ class<<self
+ attr_accessor :debug
+ end
+
+ def def_instance_delegators(accessor, *methods)
+ for method in methods
+ def_instance_delegator(accessor, method)
+ end
+ end
+
+ def def_instance_delegator(accessor, method, ali = method)
+ accessor = accessor.id2name if accessor.kind_of?(Integer)
+ method = method.id2name if method.kind_of?(Integer)
+ ali = ali.id2name if ali.kind_of?(Integer)
+
+ module_eval(<<-EOS, "(__FORWARDABLE__)", 1)
+ def #{ali}(*args, &block)
+ begin
+ #{accessor}.__send__(:#{method}, *args, &block)
+ rescue Exception
+ $@.delete_if{|s| /^\\(__FORWARDABLE__\\):/ =~ s} unless Forwardable::debug
+ Kernel::raise
+ end
+ end
+ EOS
+ end
+
+ alias def_delegators def_instance_delegators
+ alias def_delegator def_instance_delegator
+end
+
+module SingleForwardable
+ def def_singleton_delegators(accessor, *methods)
+ for method in methods
+ def_singleton_delegator(accessor, method)
+ end
+ end
+
+ def def_singleton_delegator(accessor, method, ali = method)
+ accessor = accessor.id2name if accessor.kind_of?(Integer)
+ method = method.id2name if method.kind_of?(Integer)
+ ali = ali.id2name if ali.kind_of?(Integer)
+
+ instance_eval(<<-EOS, "(__FORWARDABLE__)", 1)
+ def #{ali}(*args, &block)
+ begin
+ #{accessor}.__send__(:#{method}, *args,&block)
+ rescue Exception
+ $@.delete_if{|s| /^\\(__FORWARDABLE__\\):/ =~ s} unless Forwardable::debug
+ Kernel::raise
+ end
+ end
+ EOS
+ end
+
+ alias def_delegators def_singleton_delegators
+ alias def_delegator def_singleton_delegator
+end
+
+
+
+
diff --git a/lib/ftools.rb b/lib/ftools.rb
index 369a6177d2..0441020b05 100644
--- a/lib/ftools.rb
+++ b/lib/ftools.rb
@@ -1,46 +1,74 @@
+#
+# = ftools.rb: Extra tools for the File class
+#
+# Author:: WANTANABE, Hirofumi
+# Documentation:: Zachary Landau
+#
+# This library can be distributed under the terms of the Ruby license.
+# You can freely distribute/modify this library.
+#
+# It is included in the Ruby standard library.
+#
+# == Description
+#
+# +ftools+ adds several (class, not instance) methods to the File class, for copying, moving,
+# deleting, installing, and comparing files, as well as creating a directory path. See the
+# File class for details.
+#
+# +fileutils+ contains all or nearly all the same functionality and more, and is a recommended
+# option over +ftools+.
+#
+
+
+#
+# When you
+#
+# require 'ftools'
+#
+# then the File class aquires some utility methods for copying, moving, and deleting files, and
+# more.
+#
+# See the method descriptions below, and consider using +fileutils+ as it is more
+# comprehensive.
+#
+class File
+end
+
class << File
- TOO_BIG = 1024 * 1024 * 2 # 2MB
+ BUFSIZE = 8 * 1024
- def catname from, to
+ #
+ # If +to+ is a valid directory, +from+ will be appended to +to+, adding
+ # and escaping backslashes as necessary. Otherwise, +to+ will be returned.
+ # Useful for appending +from+ to +to+ only if the filename was not specified
+ # in +to+.
+ #
+ def catname(from, to)
if FileTest.directory? to
- to +
- if to =~ /\\/
- if to[-1,1] != '\\' then '\\' end + basename(from)
- else
- if to[-1,1] != '/' then '/' end + basename(from)
- end
+ File.join to.sub(%r([/\\]$), ''), basename(from)
else
to
end
end
-# copy file
-
- def syscopy from, to
+ #
+ # Copies a file +from+ to +to+. If +to+ is a directory, copies +from+
+ # to <tt>to/from</tt>.
+ #
+ def syscopy(from, to)
to = catname(from, to)
- fsize = size(from)
- fsize = 1024 if fsize < 512
- fsize = TOO_BIG if fsize > TOO_BIG
-
fmode = stat(from).mode
tpath = to
+ not_exist = !exist?(tpath)
- from = open(from, "r")
- from.binmode
- to = open(to, "w")
- to.binmode
+ from = open(from, "rb")
+ to = open(to, "wb")
begin
while true
- r = from.sysread(fsize)
- rsize = r.size
- w = 0
- while w < rsize
- t = to.syswrite(r[w, rsize - w])
- w += t
- end
+ to.syswrite from.sysread(BUFSIZE)
end
rescue EOFError
ret = true
@@ -50,24 +78,32 @@ class << File
to.close
from.close
end
- chmod(fmode, tpath)
+ chmod(fmode, tpath) if not_exist
ret
end
- def copy from, to, verbose = false
- $stderr.print from, " -> ", catname(from, to), "\n" if verbose
+ #
+ # Copies a file +from+ to +to+ using #syscopy. If +to+ is a directory,
+ # copies +from+ to <tt>to/from</tt>. If +verbose+ is true, <tt>from -> to</tt>
+ # is printed.
+ #
+ def copy(from, to, verbose = false)
+ $deferr.print from, " -> ", catname(from, to), "\n" if verbose
syscopy from, to
end
alias cp copy
-# move file
-
- def move from, to, verbose = false
+ #
+ # Moves a file +from+ to +to+ using #syscopy. If +to+ is a directory,
+ # copies from +from+ to <tt>to/from</tt>. If +verbose+ is true, <tt>from -> to</tt>
+ # is printed.
+ #
+ def move(from, to, verbose = false)
to = catname(from, to)
- $stderr.print from, " -> ", to, "\n" if verbose
+ $deferr.print from, " -> ", to, "\n" if verbose
- if RUBY_PLATFORM =~ /djgpp|cygwin|mswin32/ and FileTest.file? to
+ if RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ and FileTest.file? to
unlink to
end
fstat = stat(from)
@@ -90,31 +126,28 @@ class << File
alias mv move
-# compare two files
-# true: identical
-# false: not identical
+ #
+ # Returns +true+ iff the contents of files +from+ and +to+ are
+ # identical. If +verbose+ is +true+, <tt>from <=> to</tt> is printed.
+ #
+ def compare(from, to, verbose = false)
+ $deferr.print from, " <=> ", to, "\n" if verbose
- def compare from, to, verbose = false
- $stderr.print from, " <=> ", to, "\n" if verbose
- fsize = size(from)
- fsize = 1024 if fsize < 512
- fsize = TOO_BIG if fsize > TOO_BIG
+ return false if stat(from).size != stat(to).size
- from = open(from, "r")
- from.binmode
- to = open(to, "r")
- to.binmode
+ from = open(from, "rb")
+ to = open(to, "rb")
ret = false
fr = tr = ''
begin
while fr == tr
- fr = from.read(fsize)
+ fr = from.read(BUFSIZE)
if fr
tr = to.read(fr.size)
else
- ret = to.read(fsize)
+ ret = to.read(BUFSIZE)
ret = !ret || ret.length == 0
break
end
@@ -130,32 +163,53 @@ class << File
alias cmp compare
-# unlink files safely
-
+ #
+ # Removes a list of files. Each parameter should be the name of the file to
+ # delete. If the last parameter isn't a String, verbose mode will be enabled.
+ # Returns the number of files deleted.
+ #
def safe_unlink(*files)
verbose = if files[-1].is_a? String then false else files.pop end
begin
- $stderr.print files.join(" "), "\n" if verbose
+ $deferr.print files.join(" "), "\n" if verbose
chmod 0777, *files
unlink(*files)
rescue
-# STDERR.print "warning: Couldn't unlink #{files.join ' '}\n"
+# $deferr.print "warning: Couldn't unlink #{files.join ' '}\n"
end
end
alias rm_f safe_unlink
+ #
+ # Creates a directory and all its parent directories.
+ # For example,
+ #
+ # File.makedirs '/usr/lib/ruby'
+ #
+ # causes the following directories to be made, if they do not exist.
+ # * /usr
+ # * /usr/lib
+ # * /usr/lib/ruby
+ #
+ # You can pass several directories, each as a parameter. If the last
+ # parameter isn't a String, verbose mode will be enabled.
+ #
def makedirs(*dirs)
verbose = if dirs[-1].is_a? String then false else dirs.pop end
# mode = if dirs[-1].is_a? Fixnum then dirs.pop else 0755 end
mode = 0755
for dir in dirs
- next if FileTest.directory? dir
parent = dirname(dir)
+ next if parent == dir or FileTest.directory? dir
makedirs parent unless FileTest.directory? parent
- $stderr.print "mkdir ", dir, "\n" if verbose
+ $deferr.print "mkdir ", dir, "\n" if verbose
if basename(dir) != ""
- Dir.mkdir dir, mode
+ begin
+ Dir.mkdir dir, mode
+ rescue SystemCallError
+ raise unless File.directory? dir
+ end
end
end
end
@@ -165,13 +219,28 @@ class << File
alias o_chmod chmod
vsave, $VERBOSE = $VERBOSE, false
+
+ #
+ # Changes permission bits on +files+ to the bit pattern represented
+ # by +mode+. If the last parameter isn't a String, verbose mode will
+ # be enabled.
+ #
+ # File.chmod 0755, 'somecommand'
+ # File.chmod 0644, 'my.rb', 'your.rb', true
+ #
def chmod(mode, *files)
verbose = if files[-1].is_a? String then false else files.pop end
- $stderr.printf "chmod %04o %s\n", mode, files.join(" ") if verbose
+ $deferr.printf "chmod %04o %s\n", mode, files.join(" ") if verbose
o_chmod mode, *files
end
$VERBOSE = vsave
+ #
+ # If +src+ is not the same as +dest+, copies it and changes the permission
+ # mode to +mode+. If +dest+ is a directory, destination is <tt>dest/src</tt>.
+ # If +mode+ is not set, default is used. If +verbose+ is set to true, the
+ # name of each file copied will be printed.
+ #
def install(from, to, mode = nil, verbose = false)
to = catname(from, to)
unless FileTest.exist? to and cmp from, to
@@ -182,4 +251,5 @@ class << File
end
end
+
# vi:set sw=2:
diff --git a/lib/ftplib.rb b/lib/ftplib.rb
deleted file mode 100644
index 4cb1b752d6..0000000000
--- a/lib/ftplib.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# ftplib.rb
-#
-
-$stderr.puts 'Warning: ftplib.rb is obsolete: use net/ftp'
-
-require 'net/ftp'
-
-FTP = ::Net::FTP
-FTPError = ::Net::FTPError
-FTPReplyError = ::Net::FTPReplyError
-FTPTempError = ::Net::FTPTempError
-FTPPermError = ::Net::FTPPermError
-FTPProtoError = ::Net::FTPProtoError
diff --git a/lib/generator.rb b/lib/generator.rb
new file mode 100644
index 0000000000..a010559b60
--- /dev/null
+++ b/lib/generator.rb
@@ -0,0 +1,380 @@
+#!/usr/bin/env ruby
+#--
+# $Idaemons: /home/cvs/rb/generator.rb,v 1.8 2001/10/03 08:54:32 knu Exp $
+# $RoughId: generator.rb,v 1.10 2003/10/14 19:36:58 knu Exp $
+# $Id$
+#++
+#
+# = generator.rb: convert an internal iterator to an external one
+#
+# Copyright (c) 2001,2003 Akinori MUSHA <knu@iDaemons.org>
+#
+# All rights reserved. You can redistribute and/or modify it under
+# the same terms as Ruby.
+#
+# == Overview
+#
+# This library provides the Generator class, which converts an
+# internal iterator (i.e. an Enumerable object) to an external
+# iterator. In that form, you can roll many iterators independently.
+#
+# The SyncEnumerator class, which is implemented using Generator,
+# makes it easy to roll many Enumerable objects synchronously.
+#
+# See the respective classes for examples of usage.
+
+
+#
+# Generator converts an internal iterator (i.e. an Enumerable object)
+# to an external iterator.
+#
+# Note that it is not very fast since it is implemented using
+# continuations, which are currently slow.
+#
+# == Example
+#
+# require 'generator'
+#
+# # Generator from an Enumerable object
+# g = Generator.new(['A', 'B', 'C', 'Z'])
+#
+# while g.next?
+# puts g.next
+# end
+#
+# # Generator from a block
+# g = Generator.new { |g|
+# for i in 'A'..'C'
+# g.yield i
+# end
+#
+# g.yield 'Z'
+# }
+#
+# # The same result as above
+# while g.next?
+# puts g.next
+# end
+#
+class Generator
+ include Enumerable
+
+ # Creates a new generator either from an Enumerable object or from a
+ # block.
+ #
+ # In the former, block is ignored even if given.
+ #
+ # In the latter, the given block is called with the generator
+ # itself, and expected to call the +yield+ method for each element.
+ def initialize(enum = nil, &block)
+ if enum
+ @block = proc { |g|
+ enum.each { |x| g.yield x }
+ }
+ else
+ @block = block
+ end
+
+ @index = 0
+ @queue = []
+ @cont_next = @cont_yield = @cont_endp = nil
+
+ if @cont_next = callcc { |c| c }
+ @block.call(self)
+
+ @cont_endp.call(nil) if @cont_endp
+ end
+
+ self
+ end
+
+ # Yields an element to the generator.
+ def yield(value)
+ if @cont_yield = callcc { |c| c }
+ @queue << value
+ @cont_next.call(nil)
+ end
+
+ self
+ end
+
+ # Returns true if the generator has reached the end.
+ def end?()
+ if @cont_endp = callcc { |c| c }
+ @cont_yield.nil? && @queue.empty?
+ else
+ @queue.empty?
+ end
+ end
+
+ # Returns true if the generator has not reached the end yet.
+ def next?()
+ !end?
+ end
+
+ # Returns the current index (position) counting from zero.
+ def index()
+ @index
+ end
+
+ # Returns the current index (position) counting from zero.
+ def pos()
+ @index
+ end
+
+ # Returns the element at the current position and moves forward.
+ def next()
+ if end?
+ raise EOFError, "no more elements available"
+ end
+
+ if @cont_next = callcc { |c| c }
+ @cont_yield.call(nil) if @cont_yield
+ end
+
+ @index += 1
+
+ @queue.shift
+ end
+
+ # Returns the element at the current position.
+ def current()
+ if @queue.empty?
+ raise EOFError, "no more elements available"
+ end
+
+ @queue.first
+ end
+
+ # Rewinds the generator.
+ def rewind()
+ initialize(nil, &@block) if @index.nonzero?
+
+ self
+ end
+
+ # Rewinds the generator and enumerates the elements.
+ def each
+ rewind
+
+ until end?
+ yield self.next
+ end
+
+ self
+ end
+end
+
+#
+# SyncEnumerator creates an Enumerable object from multiple Enumerable
+# objects and enumerates them synchronously.
+#
+# == Example
+#
+# require 'generator'
+#
+# s = SyncEnumerator.new([1,2,3], ['a', 'b', 'c'])
+#
+# # Yields [1, 'a'], [2, 'b'], and [3,'c']
+# s.each { |row| puts row.join(', ') }
+#
+class SyncEnumerator
+ include Enumerable
+
+ # Creates a new SyncEnumerator which enumerates rows of given
+ # Enumerable objects.
+ def initialize(*enums)
+ @gens = enums.map { |e| Generator.new(e) }
+ end
+
+ # Returns the number of enumerated Enumerable objects, i.e. the size
+ # of each row.
+ def size
+ @gens.size
+ end
+
+ # Returns the number of enumerated Enumerable objects, i.e. the size
+ # of each row.
+ def length
+ @gens.length
+ end
+
+ # Returns true if the given nth Enumerable object has reached the
+ # end. If no argument is given, returns true if any of the
+ # Enumerable objects has reached the end.
+ def end?(i = nil)
+ if i.nil?
+ @gens.detect { |g| g.end? } ? true : false
+ else
+ @gens[i].end?
+ end
+ end
+
+ # Enumerates rows of the Enumerable objects.
+ def each
+ @gens.each { |g| g.rewind }
+
+ loop do
+ count = 0
+
+ ret = @gens.map { |g|
+ if g.end?
+ count += 1
+ nil
+ else
+ g.next
+ end
+ }
+
+ if count == @gens.size
+ break
+ end
+
+ yield ret
+ end
+
+ self
+ end
+end
+
+if $0 == __FILE__
+ eval DATA.read, nil, $0, __LINE__+4
+end
+
+__END__
+
+require 'test/unit'
+
+class TC_Generator < Test::Unit::TestCase
+ def test_block1
+ g = Generator.new { |g|
+ # no yield's
+ }
+
+ assert_equal(0, g.pos)
+ assert_raises(EOFError) { g.current }
+ end
+
+ def test_block2
+ g = Generator.new { |g|
+ for i in 'A'..'C'
+ g.yield i
+ end
+
+ g.yield 'Z'
+ }
+
+ assert_equal(0, g.pos)
+ assert_equal('A', g.current)
+
+ assert_equal(true, g.next?)
+ assert_equal(0, g.pos)
+ assert_equal('A', g.current)
+ assert_equal(0, g.pos)
+ assert_equal('A', g.next)
+
+ assert_equal(1, g.pos)
+ assert_equal(true, g.next?)
+ assert_equal(1, g.pos)
+ assert_equal('B', g.current)
+ assert_equal(1, g.pos)
+ assert_equal('B', g.next)
+
+ assert_equal(g, g.rewind)
+
+ assert_equal(0, g.pos)
+ assert_equal('A', g.current)
+
+ assert_equal(true, g.next?)
+ assert_equal(0, g.pos)
+ assert_equal('A', g.current)
+ assert_equal(0, g.pos)
+ assert_equal('A', g.next)
+
+ assert_equal(1, g.pos)
+ assert_equal(true, g.next?)
+ assert_equal(1, g.pos)
+ assert_equal('B', g.current)
+ assert_equal(1, g.pos)
+ assert_equal('B', g.next)
+
+ assert_equal(2, g.pos)
+ assert_equal(true, g.next?)
+ assert_equal(2, g.pos)
+ assert_equal('C', g.current)
+ assert_equal(2, g.pos)
+ assert_equal('C', g.next)
+
+ assert_equal(3, g.pos)
+ assert_equal(true, g.next?)
+ assert_equal(3, g.pos)
+ assert_equal('Z', g.current)
+ assert_equal(3, g.pos)
+ assert_equal('Z', g.next)
+
+ assert_equal(4, g.pos)
+ assert_equal(false, g.next?)
+ assert_raises(EOFError) { g.next }
+ end
+
+ def test_each
+ a = [5, 6, 7, 8, 9]
+
+ g = Generator.new(a)
+
+ i = 0
+
+ g.each { |x|
+ assert_equal(a[i], x)
+
+ i += 1
+
+ break if i == 3
+ }
+
+ assert_equal(3, i)
+
+ i = 0
+
+ g.each { |x|
+ assert_equal(a[i], x)
+
+ i += 1
+ }
+
+ assert_equal(5, i)
+ end
+end
+
+class TC_SyncEnumerator < Test::Unit::TestCase
+ def test_each
+ r = ['a'..'f', 1..10, 10..20]
+ ra = r.map { |x| x.to_a }
+
+ a = (0...(ra.map {|x| x.size}.max)).map { |i| ra.map { |x| x[i] } }
+
+ s = SyncEnumerator.new(*r)
+
+ i = 0
+
+ s.each { |x|
+ assert_equal(a[i], x)
+
+ i += 1
+
+ break if i == 3
+ }
+
+ assert_equal(3, i)
+
+ i = 0
+
+ s.each { |x|
+ assert_equal(a[i], x)
+
+ i += 1
+ }
+
+ assert_equal(a.size, i)
+ end
+end
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
index 9826b0d456..1a0d669fa3 100644
--- a/lib/getoptlong.rb
+++ b/lib/getoptlong.rb
@@ -1,15 +1,8 @@
# -*- Ruby -*-
# Copyright (C) 1998, 1999, 2000 Motoyuki Kasahara
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# You may redistribute it and/or modify it under the same license
+# terms as Ruby.
#
#
@@ -40,10 +33,11 @@ class GetoptLong
#
# Error types.
#
- class AmbigousOption < StandardError; end
- class NeedlessArgument < StandardError; end
- class MissingArgument < StandardError; end
- class InvalidOption < StandardError; end
+ class Error < StandardError; end
+ class AmbigousOption < Error; end
+ class NeedlessArgument < Error; end
+ class MissingArgument < Error; end
+ class InvalidOption < Error; end
#
# Initializer.
@@ -60,20 +54,20 @@ class GetoptLong
#
# Hash table of option names.
- # Keyes of the table are option names, and their values are canonical
+ # Keys of the table are option names, and their values are canonical
# names of the options.
#
@canonical_names = Hash.new
#
# Hash table of argument flags.
- # Keyes of the table are option names, and their values are argument
+ # Keys of the table are option names, and their values are argument
# flags of the options.
#
@argument_flags = Hash.new
#
- # Whether error messages are output to stderr.
+ # Whether error messages are output to $deferr.
#
@quiet = FALSE
@@ -93,7 +87,7 @@ class GetoptLong
@error_message = nil
#
- # Rest of catinated short options.
+ # Rest of catenated short options.
#
@rest_singles = ''
@@ -229,7 +223,7 @@ class GetoptLong
alias quiet? quiet
#
- # Termintate option processing.
+ # Terminate option processing.
#
def terminate
return nil if @status == STATUS_TERMINATED
@@ -249,7 +243,7 @@ class GetoptLong
end
#
- # Examine whether option processing is termintated or not.
+ # Examine whether option processing is terminated or not.
#
def terminated?
return @status == STATUS_TERMINATED
@@ -259,7 +253,7 @@ class GetoptLong
# Set an error (protected).
#
def set_error(type, message)
- $stderr.print("#{$0}: #{message}\n") if !@quiet
+ $deferr.print("#{$0}: #{message}\n") if !@quiet
@error = type
@error_message = message
@@ -399,7 +393,7 @@ class GetoptLong
elsif argument =~ /^(-(.))(.*)/
#
# This is a short style option, which start with `-' (not `--').
- # Short options may be catinated (e.g. `-l -g' is equivalent to
+ # Short options may be catenated (e.g. `-l -g' is equivalent to
# `-lg').
#
option_name, ch, @rest_singles = $1, $2, $3
diff --git a/lib/getopts.rb b/lib/getopts.rb
index 490523b878..34fb0d6442 100644
--- a/lib/getopts.rb
+++ b/lib/getopts.rb
@@ -11,117 +11,114 @@
# 2000-03-21
# modified by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
#
+# 2002-03-05
+# rewritten by Akinori MUSHA <knu@ruby-lang.org>
+#
$RCS_ID=%q$Header$
-def getopts( single_opts, *options )
- single_opts_exp = (single_opts && !single_opts.empty?) ?
- /[#{single_opts}]/ : nil
- single_colon_exp = nil
- single_colon = nil
- opt = arg = val = nil
+def getopts(single_options, *options)
boolopts = {}
valopts = {}
- argv = ARGV
- newargv = []
#
- # set default
+ # set defaults
#
- if single_opts then
- single_opts.each_byte do |byte|
- boolopts[ byte.chr ] = false
- end
-end
- unless options.empty? then
- single_colon = ''
+ single_options.scan(/.:?/) do |opt|
+ if opt.size == 1
+ boolopts[opt] = false
+ else
+ valopts[opt[0, 1]] = nil
+ end
+ end if single_options
- options.each do |opt|
- m = /\A([^:]+):(.*)\z/.match( opt )
- if m then
- valopts[ m[1] ] = m[2].empty? ? 0 : m[2]
- else
- boolopts[ opt ] = false
-end
- end
- valopts.each do |opt, dflt|
- if opt.size == 1 then
- single_colon << opt
-end
- end
+ options.each do |arg|
+ opt, val = arg.split(':', 2)
- if single_colon.empty? then
- single_colon = single_colon_exp = nil
- else
- single_colon_exp = /[#{single_colon}]/
+ if val
+ valopts[opt] = val.empty? ? nil : val
+ else
+ boolopts[opt] = false
end
end
-
+
#
# scan
#
c = 0
- arg = argv.shift
- while arg do
- case arg
- when /\A--?\z/ # xinit -- -bpp 24
- newargv.concat argv
- break
+ argv = ARGV
+ while arg = argv.shift
+ case arg
when /\A--(.*)/
- opt = $1
- if valopts.key? opt then # imclean --src +trash
- return nil if argv.empty?
- valopts[ opt ] = argv.shift
- elsif boolopts.key? opt then # ruby --verbose
- boolopts[ opt ] = true
+ if $1.empty? # xinit -- -bpp 24
+ break
+ end
+
+ opt, val = $1.split('=', 2)
+
+ if opt.size == 1
+ argv.unshift arg
+ return nil
+ elsif valopts.key? opt # imclean --src +trash
+ valopts[opt] = val || argv.shift or return nil
+ elsif boolopts.key? opt # ruby --verbose
+ boolopts[opt] = true
else
- return nil
- end
- c += 1
+ argv.unshift arg
+ return nil
+ end
+ c += 1
when /\A-(.+)/
- arg = $1
- 0.upto( arg.size - 1 ) do |idx|
- opt = arg[idx, 1]
- if single_opts and single_opts_exp === opt then
- boolopts[ opt ] = true # ruby -h
- c += 1
-
- elsif single_colon and single_colon_exp === opt then
- val = arg[ (idx+1)..-1 ]
- if val.empty? then # ruby -e 'p $:'
- return nil if argv.empty?
- valopts[ opt ] = argv.shift
- else # cc -ohello ...
- valopts[ opt ] = val
- end
- c += 1
+ opts = $1
- break
- else
- return nil
- end
- end
+ until opts.empty?
+ opt = opts.slice!(0, 1)
- else # ruby test.rb
- newargv.push arg
- end
+ if valopts.key? opt
+ val = opts
- arg = argv.shift
+ if val.empty? # ruby -e 'p $:'
+ valopts[opt] = argv.shift or return nil
+ else # cc -ohello ...
+ valopts[opt] = val
+ end
+
+ c += 1
+ break
+ elsif boolopts.key? opt
+ boolopts[opt] = true # ruby -h
+ c += 1
+ else
+ argv.unshift arg
+ return nil
+ end
+ end
+ else
+ argv.unshift arg
+ break
end
-
+ end
+
#
# set
#
+ $OPT = {}
+
boolopts.each do |opt, val|
- eval "$OPT_#{opt} = val"
- end
+ $OPT[opt] = val
+
+ sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
+ eval "$OPT_#{sopt} = val"
+ end
valopts.each do |opt, val|
- eval "$OPT_#{opt} = #{val == 0 ? 'nil' : 'val'}"
+ $OPT[opt] = val
+
+ sopt = opt.gsub(/[^A-Za-z0-9_]/, '_')
+ eval "$OPT_#{sopt} = val"
end
- argv.replace newargv
c
end
diff --git a/lib/gserver.rb b/lib/gserver.rb
new file mode 100644
index 0000000000..371fceb290
--- /dev/null
+++ b/lib/gserver.rb
@@ -0,0 +1,249 @@
+#
+# Copyright (C) 2001 John W. Small All Rights Reserved
+#
+# Author:: John W. Small
+# Documentation:: Gavin Sinclair
+# Licence:: Freeware.
+#
+# See the class GServer for documentation.
+#
+
+require "socket"
+require "thread"
+
+#
+# +GServer+ implements a generic server, featuring thread pool management, simple logging, and
+# multi-server management. See <tt>xmlrpc/httpserver.rb</tt> in the Ruby standard library for
+# an example of +GServer+ in action.
+#
+# Any kind of application-level server can be implemented using this class. It accepts
+# multiple simultaneous connections from clients, up to an optional maximum number. Several
+# _services_ (i.e. one service per TCP port) can be run simultaneously, and stopped at any time
+# through the class method <tt>GServer.stop(port)</tt>. All the threading issues are handled,
+# saving you the effort. All events are optionally logged, but you can provide your own event
+# handlers if you wish.
+#
+# === Example
+#
+# Using +GServer+ is simple. Below we implement a simple time server, run it, query it, and
+# shut it down. Try this code in +irb+:
+#
+# require 'gserver'
+#
+# #
+# # A server that returns the time in seconds since 1970.
+# #
+# class TimeServer < GServer
+# def initialize(port=10001, *args)
+# super(port, *args)
+# end
+# def serve(io)
+# io.puts(Time.now.to_i)
+# end
+# end
+#
+# # Run the server with logging enabled (it's a separate thread).
+# server = TimeServer.new
+# server.audit = true # Turn logging on.
+# server.start
+#
+# # *** Now point your browser to http://localhost:10001 to see it working ***
+#
+# # See if it's still running.
+# GServer.in_service?(10001) # -> true
+# server.stopped? # -> false
+#
+# # Shut the server down gracefully.
+# server.shutdown
+#
+# # Alternatively, stop it immediately.
+# GServer.stop(10001)
+# # or, of course, "server.stop".
+#
+# All the business of accepting connections and exception handling is taken care of. All we
+# have to do is implement the method that actually serves the client.
+#
+# === Advanced
+#
+# As the example above shows, the way to use +GServer+ is to subclass it to create a specific
+# server, overriding the +serve+ method. You can override other methods as well if you wish,
+# perhaps to collect statistics, or emit more detailed logging.
+#
+# connecting
+# disconnecting
+# starting
+# stopping
+#
+# The above methods are only called if auditing is enabled.
+#
+# You can also override +log+ and +error+ if, for example, you wish to use a more sophisticated
+# logging system.
+#
+class GServer
+
+ DEFAULT_HOST = "127.0.0.1"
+
+ def serve(io)
+ end
+
+ @@services = {} # Hash of opened ports, i.e. services
+ @@servicesMutex = Mutex.new
+
+ def GServer.stop(port, host = DEFAULT_HOST)
+ @@servicesMutex.synchronize {
+ @@services[host][port].stop
+ }
+ end
+
+ def GServer.in_service?(port, host = DEFAULT_HOST)
+ @@services.has_key?(host) and
+ @@services[host].has_key?(port)
+ end
+
+ def stop
+ @connectionsMutex.synchronize {
+ if @tcpServerThread
+ @tcpServerThread.raise "stop"
+ end
+ }
+ end
+
+ def stopped?
+ @tcpServerThread == nil
+ end
+
+ def shutdown
+ @shutdown = true
+ end
+
+ def connections
+ @connections.size
+ end
+
+ def join
+ @tcpServerThread.join if @tcpServerThread
+ end
+
+ attr_reader :port, :host, :maxConnections
+ attr_accessor :stdlog, :audit, :debug
+
+ def connecting(client)
+ addr = client.peeraddr
+ log("#{self.class.to_s} #{@host}:#{@port} client:#{addr[1]} " +
+ "#{addr[2]}<#{addr[3]}> connect")
+ true
+ end
+
+ def disconnecting(clientPort)
+ log("#{self.class.to_s} #{@host}:#{@port} " +
+ "client:#{clientPort} disconnect")
+ end
+
+ protected :connecting, :disconnecting
+
+ def starting()
+ log("#{self.class.to_s} #{@host}:#{@port} start")
+ end
+
+ def stopping()
+ log("#{self.class.to_s} #{@host}:#{@port} stop")
+ end
+
+ protected :starting, :stopping
+
+ def error(detail)
+ log(detail.backtrace.join("\n"))
+ end
+
+ def log(msg)
+ if @stdlog
+ @stdlog.puts("[#{Time.new.ctime}] %s" % msg)
+ @stdlog.flush
+ end
+ end
+
+ protected :error, :log
+
+ def initialize(port, host = DEFAULT_HOST, maxConnections = 4,
+ stdlog = $stderr, audit = false, debug = false)
+ @tcpServerThread = nil
+ @port = port
+ @host = host
+ @maxConnections = maxConnections
+ @connections = []
+ @connectionsMutex = Mutex.new
+ @connectionsCV = ConditionVariable.new
+ @stdlog = stdlog
+ @audit = audit
+ @debug = debug
+ end
+
+ def start(maxConnections = -1)
+ raise "running" if !stopped?
+ @shutdown = false
+ @maxConnections = maxConnections if maxConnections > 0
+ @@servicesMutex.synchronize {
+ if GServer.in_service?(@port,@host)
+ raise "Port already in use: #{host}:#{@port}!"
+ end
+ @tcpServer = TCPServer.new(@host,@port)
+ @port = @tcpServer.addr[1]
+ @@services[@host] = {} unless @@services.has_key?(@host)
+ @@services[@host][@port] = self;
+ }
+ @tcpServerThread = Thread.new {
+ begin
+ starting if @audit
+ while !@shutdown
+ @connectionsMutex.synchronize {
+ while @connections.size >= @maxConnections
+ @connectionsCV.wait(@connectionsMutex)
+ end
+ }
+ client = @tcpServer.accept
+ @connections << Thread.new(client) { |myClient|
+ begin
+ myPort = myClient.peeraddr[1]
+ serve(myClient) if !@audit or connecting(myClient)
+ rescue => detail
+ error(detail) if @debug
+ ensure
+ begin
+ myClient.close
+ rescue
+ end
+ @connectionsMutex.synchronize {
+ @connections.delete(Thread.current)
+ @connectionsCV.signal
+ }
+ disconnecting(myPort) if @audit
+ end
+ }
+ end
+ rescue => detail
+ error(detail) if @debug
+ ensure
+ begin
+ @tcpServer.close
+ rescue
+ end
+ if @shutdown
+ @connectionsMutex.synchronize {
+ while @connections.size > 0
+ @connectionsCV.wait(@connectionsMutex)
+ end
+ }
+ else
+ @connections.each { |c| c.raise "stop" }
+ end
+ @tcpServerThread = nil
+ @@servicesMutex.synchronize {
+ @@services[@host].delete(@port)
+ }
+ stopping if @audit
+ end
+ }
+ self
+ end
+
+end
diff --git a/lib/importenv.rb b/lib/importenv.rb
index 586f37661b..435d6f972a 100644
--- a/lib/importenv.rb
+++ b/lib/importenv.rb
@@ -29,4 +29,3 @@ if __FILE__ == $0
$TERM = "foo"
p ENV["TERM"]
end
-
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
new file mode 100644
index 0000000000..24543ce093
--- /dev/null
+++ b/lib/ipaddr.rb
@@ -0,0 +1,762 @@
+#
+# ipaddr.rb - A class to manipulate an IP address
+#
+# Copyright (c) 2002 Hajimu UMEMOTO <ume@mahoroba.org>.
+# All rights reserved.
+#
+# You can redistribute and/or modify it under the same terms as Ruby.
+#
+# $Id$
+#--
+# TODO:
+# - scope_id support
+#++
+#
+#== Example
+#
+# require 'ipaddr'
+#
+# ipaddr1 = IPAddr.new "3ffe:505:2::1"
+#
+# p ipaddr1 #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
+#
+# p ipaddr1.to_s #=> "3ffe:505:2::1"
+#
+# ipaddr2 = ipaddr1.mask(48) #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000>
+#
+# p ipaddr2.to_s #=> "3ffe:505:2::"
+#
+# ipaddr3 = IPAddr.new "192.168.2.0/24"
+#
+# p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
+
+require 'socket'
+
+unless Socket.const_defined? "AF_INET6"
+ class Socket
+ AF_INET6 = Object.new
+ end
+
+ class << IPSocket
+ def valid_v4?(addr)
+ if /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\Z/ =~ addr
+ return $~.captures.all? {|i| i.to_i < 256}
+ end
+ return false
+ end
+
+ def valid_v6?(addr)
+ # IPv6 (normal)
+ return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*\Z/ =~ addr
+ return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z/ =~ addr
+ return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z/ =~ addr
+ # IPv6 (IPv4 compat)
+ return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:/ =~ addr && valid_v4?($')
+ return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_v4?($')
+ return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_v4?($')
+
+ false
+ end
+
+ def valid?(addr)
+ valid_v4?(addr) || valid_v6?(addr)
+ end
+
+ alias getaddress_orig getaddress
+ def getaddress(s)
+ if valid?(s)
+ s
+ elsif /\A[-A-Za-z\d.]+\Z/ =~ s
+ getaddress_orig(s)
+ else
+ raise ArgumentError, "invalid address"
+ end
+ end
+ end
+end
+
+# IPAddr provides a set of methods to manipulate an IP address. Both
+# IPv4 and IPv6 are supported.
+class IPAddr
+
+ IN4MASK = 0xffffffff
+ IN6MASK = 0xffffffffffffffffffffffffffffffff
+ IN6FORMAT = (["%.4x"] * 8).join(':')
+
+ # Returns the address family of this IP address.
+ attr :family
+
+ # Creates a new ipaddr containing the given network byte ordered
+ # string form of an IP address.
+ def IPAddr::new_ntoh(addr)
+ return IPAddr.new(IPAddr::ntop(addr))
+ end
+
+ # Convert a network byte ordered string form of an IP address into
+ # human readable form.
+ def IPAddr::ntop(addr)
+ case addr.size
+ when 4
+ s = addr.unpack('C4').join('.')
+ when 16
+ s = IN6FORMAT % addr.unpack('n8')
+ else
+ raise ArgumentError, "unsupported address family"
+ end
+ return s
+ end
+
+ # Returns a new ipaddr built by bitwise AND.
+ def &(other)
+ return self.clone.set(@addr & other.to_i)
+ end
+
+ # Returns a new ipaddr built by bitwise OR.
+ def |(other)
+ return self.clone.set(@addr | other.to_i)
+ end
+
+ # Returns a new ipaddr built by bitwise right-shift.
+ def >>(num)
+ return self.clone.set(@addr >> num)
+ end
+
+ # Returns a new ipaddr built by bitwise left shift.
+ def <<(num)
+ return self.clone.set(addr_mask(@addr << num))
+ end
+
+ # Returns a new ipaddr built by bitwise negation.
+ def ~
+ return self.clone.set(addr_mask(~@addr))
+ end
+
+ # Returns true if two ipaddr are equal.
+ def ==(other)
+ if other.kind_of?(IPAddr) && @family != other.family
+ return false
+ end
+ return (@addr == other.to_i)
+ end
+
+ # Returns a new ipaddr built by masking IP address with the given
+ # prefixlen/netmask. (e.g. 8, 64, "255.255.255.0", etc.)
+ def mask(prefixlen)
+ return self.clone.mask!(prefixlen)
+ end
+
+ # Returns true if the given ipaddr is in the range.
+ #
+ # e.g.:
+ # require 'ipaddr'
+ # net1 = IPAddr.new("192.168.2.0/24")
+ # p net1.include?(IPAddr.new("192.168.2.0")) #=> true
+ # p net1.include?(IPAddr.new("192.168.2.255")) #=> true
+ # p net1.include?(IPAddr.new("192.168.3.0")) #=> false
+ def include?(other)
+ if ipv4_mapped?
+ if (@mask_addr >> 32) != 0xffffffffffffffffffffffff
+ return false
+ end
+ mask_addr = (@mask_addr & IN4MASK)
+ addr = (@addr & IN4MASK)
+ family = Socket::AF_INET
+ else
+ mask_addr = @mask_addr
+ addr = @addr
+ family = @family
+ end
+ if other.kind_of?(IPAddr)
+ if other.ipv4_mapped?
+ other_addr = (other.to_i & IN4MASK)
+ other_family = Socket::AF_INET
+ else
+ other_addr = other.to_i
+ other_family = other.family
+ end
+ else # Not IPAddr - assume integer in same family as us
+ other_addr = other.to_i
+ other_family = family
+ end
+
+ if family != other_family
+ return false
+ end
+ return ((addr & mask_addr) == (other_addr & mask_addr))
+ end
+ alias === include?
+
+ # Returns the integer representation of the ipaddr.
+ def to_i
+ return @addr
+ end
+
+ # Returns a string containing the IP address representation.
+ def to_s
+ str = to_string
+ return str if ipv4?
+
+ str.gsub!(/\b0{1,3}([\da-f]+)\b/i, '\1')
+ loop do
+ break if str.sub!(/\A0:0:0:0:0:0:0:0\Z/, '::')
+ break if str.sub!(/\b0:0:0:0:0:0:0\b/, ':')
+ break if str.sub!(/\b0:0:0:0:0:0\b/, ':')
+ break if str.sub!(/\b0:0:0:0:0\b/, ':')
+ break if str.sub!(/\b0:0:0:0\b/, ':')
+ break if str.sub!(/\b0:0:0\b/, ':')
+ break if str.sub!(/\b0:0\b/, ':')
+ break
+ end
+
+ if /\A::(ffff:)?([\da-f]{1,4}):([\da-f]{1,4})\Z/i =~ str
+ str = sprintf('::%s%d.%d.%d.%d', $1, $2.hex / 256, $2.hex % 256, $3.hex / 256, $3.hex % 256)
+ end
+
+ str
+ end
+
+ # Returns a string containing the IP address representation in
+ # canonical form.
+ def to_string
+ return _to_string(@addr)
+ end
+
+ # Returns a network byte ordered string form of the IP address.
+ def hton
+ case @family
+ when Socket::AF_INET
+ return [@addr].pack('N')
+ when Socket::AF_INET6
+ return (0..7).map { |i|
+ (@addr >> (112 - 16 * i)) & 0xffff
+ }.pack('n8')
+ else
+ raise "unsupported address family"
+ end
+ end
+
+ # Returns true if the ipaddr is an IPv4 address.
+ def ipv4?
+ return @family == Socket::AF_INET
+ end
+
+ # Returns true if the ipaddr is an IPv6 address.
+ def ipv6?
+ return @family == Socket::AF_INET6
+ end
+
+ # Returns true if the ipaddr is an IPv4-mapped IPv6 address.
+ def ipv4_mapped?
+ return ipv6? && (@addr >> 32) == 0xffff
+ end
+
+ # Returns true if the ipaddr is an IPv4-compatible IPv6 address.
+ def ipv4_compat?
+ if !ipv6? || (@addr >> 32) != 0
+ return false
+ end
+ a = (@addr & IN4MASK)
+ return a != 0 && a != 1
+ end
+
+ # Returns a new ipaddr built by converting the native IPv4 address
+ # into an IPv4-mapped IPv6 address.
+ def ipv4_mapped
+ if !ipv4?
+ raise ArgumentError, "not an IPv4 address"
+ end
+ return self.clone.set(@addr | 0xffff00000000, Socket::AF_INET6)
+ end
+
+ # Returns a new ipaddr built by converting the native IPv4 address
+ # into an IPv4-compatible IPv6 address.
+ def ipv4_compat
+ if !ipv4?
+ raise ArgumentError, "not an IPv4 address"
+ end
+ return self.clone.set(@addr, Socket::AF_INET6)
+ end
+
+ # Returns a new ipaddr built by converting the IPv6 address into a
+ # native IPv4 address. If the IP address is not an IPv4-mapped or
+ # IPv4-compatible IPv6 address, returns self.
+ def native
+ if !ipv4_mapped? && !ipv4_compat?
+ return self
+ end
+ return self.clone.set(@addr & IN4MASK, Socket::AF_INET)
+ end
+
+ # Returns a string for DNS reverse lookup. It returns a string in
+ # RFC3172 form for an IPv6 address.
+ def reverse
+ case @family
+ when Socket::AF_INET
+ return _reverse + ".in-addr.arpa"
+ when Socket::AF_INET6
+ return ip6_arpa
+ else
+ raise "unsupported address family"
+ end
+ end
+
+ # Returns a string for DNS reverse lookup compatible with RFC3172.
+ def ip6_arpa
+ if !ipv6?
+ raise ArgumentError, "not an IPv6 address"
+ end
+ return _reverse + ".ip6.arpa"
+ end
+
+ # Returns a string for DNS reverse lookup compatible with RFC1886.
+ def ip6_int
+ if !ipv6?
+ raise ArgumentError, "not an IPv6 address"
+ end
+ return _reverse + ".ip6.int"
+ end
+
+ # Returns a string containing a human-readable representation of the
+ # ipaddr. ("#<IPAddr: family:address/mask>")
+ def inspect
+ case @family
+ when Socket::AF_INET
+ af = "IPv4"
+ when Socket::AF_INET6
+ af = "IPv6"
+ else
+ raise "unsupported address family"
+ end
+ return sprintf("#<%s: %s:%s/%s>", self.class.name,
+ af, _to_string(@addr), _to_string(@mask_addr))
+ end
+
+ protected
+
+ def set(addr, *family)
+ case family[0] ? family[0] : @family
+ when Socket::AF_INET
+ if addr < 0 || addr > IN4MASK
+ raise ArgumentError, "invalid address"
+ end
+ when Socket::AF_INET6
+ if addr < 0 || addr > IN6MASK
+ raise ArgumentError, "invalid address"
+ end
+ else
+ raise ArgumentError, "unsupported address family"
+ end
+ @addr = addr
+ if family[0]
+ @family = family[0]
+ end
+ return self
+ end
+
+ def mask!(mask)
+ if mask.kind_of?(String)
+ if mask =~ /^\d+$/
+ prefixlen = mask.to_i
+ else
+ m = IPAddr.new(mask)
+ if m.family != @family
+ raise ArgumentError, "address family is not same"
+ end
+ @mask_addr = m.to_i
+ @addr &= @mask_addr
+ return self
+ end
+ else
+ prefixlen = mask
+ end
+ case @family
+ when Socket::AF_INET
+ if prefixlen < 0 || prefixlen > 32
+ raise ArgumentError, "invalid length"
+ end
+ masklen = 32 - prefixlen
+ @mask_addr = ((IN4MASK >> masklen) << masklen)
+ when Socket::AF_INET6
+ if prefixlen < 0 || prefixlen > 128
+ raise ArgumentError, "invalid length"
+ end
+ masklen = 128 - prefixlen
+ @mask_addr = ((IN6MASK >> masklen) << masklen)
+ else
+ raise "unsupported address family"
+ end
+ @addr = ((@addr >> masklen) << masklen)
+ return self
+ end
+
+ private
+
+ # Creates a new ipaddr containing the given human readable form of
+ # an IP address. It also accepts `address/prefixlen' and
+ # `address/mask'. When prefixlen or mask is specified, it returns a
+ # masked ipaddr. IPv6 address may beenclosed with `[' and `]'.
+ #
+ # Although an address family is determined automatically from a
+ # specified address, you can specify an address family explicitly by
+ # the optional second argument.
+ def initialize(addr = '::', family = Socket::AF_UNSPEC)
+ if !addr.kind_of?(String)
+ if family != Socket::AF_INET6 && family != Socket::AF_INET
+ raise ArgumentError, "unsupported address family"
+ end
+ set(addr, family)
+ @mask_addr = (family == Socket::AF_INET) ? IN4MASK : IN6MASK
+ return
+ end
+ prefix, prefixlen = addr.split('/')
+ if prefix =~ /^\[(.*)\]$/i
+ prefix = $1
+ family = Socket::AF_INET6
+ end
+ # It seems AI_NUMERICHOST doesn't do the job.
+ #Socket.getaddrinfo(left, nil, Socket::AF_INET6, Socket::SOCK_STREAM, nil,
+ # Socket::AI_NUMERICHOST)
+ begin
+ IPSocket.getaddress(prefix) # test if address is vaild
+ rescue
+ raise ArgumentError, "invalid address"
+ end
+ @addr = @family = nil
+ if family == Socket::AF_UNSPEC || family == Socket::AF_INET
+ @addr = in_addr(prefix)
+ if @addr
+ @family = Socket::AF_INET
+ end
+ end
+ if !@addr && (family == Socket::AF_UNSPEC || family == Socket::AF_INET6)
+ @addr = in6_addr(prefix)
+ @family = Socket::AF_INET6
+ end
+ if family != Socket::AF_UNSPEC && @family != family
+ raise ArgumentError, "address family unmatch"
+ end
+ if prefixlen
+ mask!(prefixlen)
+ else
+ @mask_addr = (family == Socket::AF_INET) ? IN4MASK : IN6MASK
+ end
+ end
+
+ def in_addr(addr)
+ if addr =~ /^\d+\.\d+\.\d+\.\d+$/
+ n = 0
+ addr.split('.').each { |i|
+ n <<= 8
+ n += i.to_i
+ }
+ return n
+ end
+ return nil
+ end
+
+ def in6_addr(left)
+ case left
+ when /^::ffff:(\d+\.\d+\.\d+\.\d+)$/i
+ return in_addr($1) + 0xffff00000000
+ when /^::(\d+\.\d+\.\d+\.\d+)$/i
+ return in_addr($1)
+ when /[^0-9a-f:]/i
+ raise ArgumentError, "invalid address"
+ when /^(.*)::(.*)$/
+ left, right = $1, $2
+ else
+ right = ''
+ end
+ l = left.split(':')
+ r = right.split(':')
+ rest = 8 - l.size - r.size
+ if rest < 0
+ return nil
+ end
+ a = [l, Array.new(rest, '0'), r].flatten!
+ n = 0
+ a.each { |i|
+ n <<= 16
+ n += i.hex
+ }
+ return n
+ end
+
+ def addr_mask(addr)
+ case @family
+ when Socket::AF_INET
+ addr &= IN4MASK
+ when Socket::AF_INET6
+ addr &= IN6MASK
+ else
+ raise "unsupported address family"
+ end
+ return addr
+ end
+
+ def _reverse
+ case @family
+ when Socket::AF_INET
+ return (0..3).map { |i|
+ (@addr >> (8 * i)) & 0xff
+ }.join('.')
+ when Socket::AF_INET6
+ return ("%.32x" % @addr).reverse!.gsub!(/.(?!$)/, '\&.')
+ else
+ raise "unsupported address family"
+ end
+ end
+
+ def _to_string(addr)
+ case @family
+ when Socket::AF_INET
+ return (0..3).map { |i|
+ (addr >> (24 - 8 * i)) & 0xff
+ }.join('.')
+ when Socket::AF_INET6
+ return (("%.32x" % addr).gsub!(/.{4}(?!$)/, '\&:'))
+ else
+ raise "unsupported address family"
+ end
+ end
+
+end
+
+if $0 == __FILE__
+ eval DATA.read, nil, $0, __LINE__+4
+end
+
+__END__
+
+require 'test/unit'
+require 'test/unit/ui/console/testrunner'
+
+class TC_IPAddr < Test::Unit::TestCase
+ def test_s_new
+ assert_nothing_raised {
+ IPAddr.new("3FFE:505:ffff::/48")
+ IPAddr.new("0:0:0:1::")
+ IPAddr.new("2001:200:300::/48")
+ }
+
+ a = IPAddr.new
+ assert_equal("::", a.to_s)
+ assert_equal("0000:0000:0000:0000:0000:0000:0000:0000", a.to_string)
+ assert_equal(Socket::AF_INET6, a.family)
+
+ a = IPAddr.new("0123:4567:89ab:cdef:0ABC:DEF0:1234:5678")
+ assert_equal("123:4567:89ab:cdef:abc:def0:1234:5678", a.to_s)
+ assert_equal("0123:4567:89ab:cdef:0abc:def0:1234:5678", a.to_string)
+ assert_equal(Socket::AF_INET6, a.family)
+
+ a = IPAddr.new("3ffe:505:2::/48")
+ assert_equal("3ffe:505:2::", a.to_s)
+ assert_equal("3ffe:0505:0002:0000:0000:0000:0000:0000", a.to_string)
+ assert_equal(Socket::AF_INET6, a.family)
+ assert_equal(false, a.ipv4?)
+ assert_equal(true, a.ipv6?)
+ assert_equal("#<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000>", a.inspect)
+
+ a = IPAddr.new("3ffe:505:2::/ffff:ffff:ffff::")
+ assert_equal("3ffe:505:2::", a.to_s)
+ assert_equal("3ffe:0505:0002:0000:0000:0000:0000:0000", a.to_string)
+ assert_equal(Socket::AF_INET6, a.family)
+
+ a = IPAddr.new("0.0.0.0")
+ assert_equal("0.0.0.0", a.to_s)
+ assert_equal("0.0.0.0", a.to_string)
+ assert_equal(Socket::AF_INET, a.family)
+
+ a = IPAddr.new("192.168.1.2")
+ assert_equal("192.168.1.2", a.to_s)
+ assert_equal("192.168.1.2", a.to_string)
+ assert_equal(Socket::AF_INET, a.family)
+ assert_equal(true, a.ipv4?)
+ assert_equal(false, a.ipv6?)
+
+ a = IPAddr.new("192.168.1.2/24")
+ assert_equal("192.168.1.0", a.to_s)
+ assert_equal("192.168.1.0", a.to_string)
+ assert_equal(Socket::AF_INET, a.family)
+ assert_equal("#<IPAddr: IPv4:192.168.1.0/255.255.255.0>", a.inspect)
+
+ a = IPAddr.new("192.168.1.2/255.255.255.0")
+ assert_equal("192.168.1.0", a.to_s)
+ assert_equal("192.168.1.0", a.to_string)
+ assert_equal(Socket::AF_INET, a.family)
+
+ assert_equal("0:0:0:1::", IPAddr.new("0:0:0:1::").to_s)
+ assert_equal("2001:200:300::", IPAddr.new("2001:200:300::/48").to_s)
+
+ assert_equal("2001:200:300::", IPAddr.new("[2001:200:300::]/48").to_s)
+
+ [
+ ["fe80::1%fxp0"],
+ ["::1/255.255.255.0"],
+ ["::1:192.168.1.2/120"],
+ [IPAddr.new("::1").to_i],
+ ["::ffff:192.168.1.2/120", Socket::AF_INET],
+ ["[192.168.1.2]/120"],
+ ].each { |args|
+ assert_raises(ArgumentError) {
+ IPAddr.new(*args)
+ }
+ }
+ end
+
+ def test_s_new_ntoh
+ addr = ''
+ IPAddr.new("1234:5678:9abc:def0:1234:5678:9abc:def0").hton.each_byte { |c|
+ addr += sprintf("%02x", c)
+ }
+ assert_equal("123456789abcdef0123456789abcdef0", addr)
+ addr = ''
+ IPAddr.new("123.45.67.89").hton.each_byte { |c|
+ addr += sprintf("%02x", c)
+ }
+ assert_equal(sprintf("%02x%02x%02x%02x", 123, 45, 67, 89), addr)
+ a = IPAddr.new("3ffe:505:2::")
+ assert_equal("3ffe:505:2::", IPAddr.new_ntoh(a.hton).to_s)
+ a = IPAddr.new("192.168.2.1")
+ assert_equal("192.168.2.1", IPAddr.new_ntoh(a.hton).to_s)
+ end
+
+ def test_ipv4_compat
+ a = IPAddr.new("::192.168.1.2")
+ assert_equal("::192.168.1.2", a.to_s)
+ assert_equal("0000:0000:0000:0000:0000:0000:c0a8:0102", a.to_string)
+ assert_equal(Socket::AF_INET6, a.family)
+ assert_equal(true, a.ipv4_compat?)
+ b = a.native
+ assert_equal("192.168.1.2", b.to_s)
+ assert_equal(Socket::AF_INET, b.family)
+ assert_equal(false, b.ipv4_compat?)
+
+ a = IPAddr.new("192.168.1.2")
+ b = a.ipv4_compat
+ assert_equal("::192.168.1.2", b.to_s)
+ assert_equal(Socket::AF_INET6, b.family)
+ end
+
+ def test_ipv4_mapped
+ a = IPAddr.new("::ffff:192.168.1.2")
+ assert_equal("::ffff:192.168.1.2", a.to_s)
+ assert_equal("0000:0000:0000:0000:0000:ffff:c0a8:0102", a.to_string)
+ assert_equal(Socket::AF_INET6, a.family)
+ assert_equal(true, a.ipv4_mapped?)
+ b = a.native
+ assert_equal("192.168.1.2", b.to_s)
+ assert_equal(Socket::AF_INET, b.family)
+ assert_equal(false, b.ipv4_mapped?)
+
+ a = IPAddr.new("192.168.1.2")
+ b = a.ipv4_mapped
+ assert_equal("::ffff:192.168.1.2", b.to_s)
+ assert_equal(Socket::AF_INET6, b.family)
+ end
+
+ def test_reverse
+ assert_equal("f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa", IPAddr.new("3ffe:505:2::f").reverse)
+ assert_equal("1.2.168.192.in-addr.arpa", IPAddr.new("192.168.2.1").reverse)
+ end
+
+ def test_ip6_arpa
+ assert_equal("f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa", IPAddr.new("3ffe:505:2::f").ip6_arpa)
+ assert_raises(ArgumentError) {
+ IPAddr.new("192.168.2.1").ip6_arpa
+ }
+ end
+
+ def test_ip6_int
+ assert_equal("f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.int", IPAddr.new("3ffe:505:2::f").ip6_int)
+ assert_raises(ArgumentError) {
+ IPAddr.new("192.168.2.1").ip6_int
+ }
+ end
+
+end
+
+class TC_Operator < Test::Unit::TestCase
+
+ IN6MASK32 = "ffff:ffff::"
+ IN6MASK128 = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
+
+ def setup
+ @in6_addr_any = IPAddr.new()
+ @a = IPAddr.new("3ffe:505:2::/48")
+ @b = IPAddr.new("0:0:0:1::")
+ @c = IPAddr.new(IN6MASK32)
+ end
+ alias set_up setup
+
+ def test_or
+ assert_equal("3ffe:505:2:1::", (@a | @b).to_s)
+ a = @a
+ a |= @b
+ assert_equal("3ffe:505:2:1::", a.to_s)
+ assert_equal("3ffe:505:2::", @a.to_s)
+ assert_equal("3ffe:505:2:1::",
+ (@a | 0x00000000000000010000000000000000).to_s)
+ end
+
+ def test_and
+ assert_equal("3ffe:505::", (@a & @c).to_s)
+ a = @a
+ a &= @c
+ assert_equal("3ffe:505::", a.to_s)
+ assert_equal("3ffe:505:2::", @a.to_s)
+ assert_equal("3ffe:505::", (@a & 0xffffffff000000000000000000000000).to_s)
+ end
+
+ def test_shift_right
+ assert_equal("0:3ffe:505:2::", (@a >> 16).to_s)
+ a = @a
+ a >>= 16
+ assert_equal("0:3ffe:505:2::", a.to_s)
+ assert_equal("3ffe:505:2::", @a.to_s)
+ end
+
+ def test_shift_left
+ assert_equal("505:2::", (@a << 16).to_s)
+ a = @a
+ a <<= 16
+ assert_equal("505:2::", a.to_s)
+ assert_equal("3ffe:505:2::", @a.to_s)
+ end
+
+ def test_carrot
+ a = ~@in6_addr_any
+ assert_equal(IN6MASK128, a.to_s)
+ assert_equal("::", @in6_addr_any.to_s)
+ end
+
+ def test_equal
+ assert_equal(true, @a == IPAddr.new("3ffe:505:2::"))
+ assert_equal(false, @a == IPAddr.new("3ffe:505:3::"))
+ assert_equal(true, @a != IPAddr.new("3ffe:505:3::"))
+ assert_equal(false, @a != IPAddr.new("3ffe:505:2::"))
+ end
+
+ def test_mask
+ a = @a.mask(32)
+ assert_equal("3ffe:505::", a.to_s)
+ assert_equal("3ffe:505:2::", @a.to_s)
+ end
+
+ def test_include?
+ assert_equal(true, @a.include?(IPAddr.new("3ffe:505:2::")))
+ assert_equal(true, @a.include?(IPAddr.new("3ffe:505:2::1")))
+ assert_equal(false, @a.include?(IPAddr.new("3ffe:505:3::")))
+ net1 = IPAddr.new("192.168.2.0/24")
+ assert_equal(true, net1.include?(IPAddr.new("192.168.2.0")))
+ assert_equal(true, net1.include?(IPAddr.new("192.168.2.255")))
+ assert_equal(false, net1.include?(IPAddr.new("192.168.3.0")))
+ # test with integer parameter
+ int = (192 << 24) + (168 << 16) + (2 << 8) + 13
+
+ assert_equal(true, net1.include?(int))
+ assert_equal(false, net1.include?(int+255))
+
+ end
+
+end
diff --git a/lib/irb.rb b/lib/irb.rb
new file mode 100644
index 0000000000..1e59d6f669
--- /dev/null
+++ b/lib/irb.rb
@@ -0,0 +1,340 @@
+#
+# irb.rb - irb main module
+# $Release Version: 0.9 $
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+require "e2mmap"
+
+require "irb/init"
+require "irb/context"
+require "irb/extend-command"
+#require "irb/workspace"
+
+require "irb/ruby-lex"
+require "irb/input-method"
+require "irb/locale"
+
+STDOUT.sync = true
+
+module IRB
+ @RCS_ID='-$Id$-'
+
+ class Abort < Exception;end
+
+ #
+ @CONF = {}
+
+ def IRB.conf
+ @CONF
+ end
+
+ # IRB version method
+ def IRB.version
+ if v = @CONF[:VERSION] then return v end
+
+ require "irb/version"
+ rv = @RELEASE_VERSION.sub(/\.0/, "")
+ @CONF[:VERSION] = format("irb %s(%s)", rv, @LAST_UPDATE_DATE)
+ end
+
+ def IRB.CurrentContext
+ IRB.conf[:MAIN_CONTEXT]
+ end
+
+ # initialize IRB and start TOP_LEVEL irb
+ def IRB.start(ap_path = nil)
+ $0 = File::basename(ap_path, ".rb") if ap_path
+
+ IRB.setup(ap_path)
+
+ if @CONF[:SCRIPT]
+ irb = Irb.new(nil, @CONF[:SCRIPT])
+ else
+ irb = Irb.new
+ end
+
+ @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
+ @CONF[:MAIN_CONTEXT] = irb.context
+
+ trap("SIGINT") do
+ irb.signal_handle
+ end
+
+ catch(:IRB_EXIT) do
+ irb.eval_input
+ end
+# print "\n"
+ end
+
+ def IRB.irb_exit(irb, ret)
+ throw :IRB_EXIT, ret
+ end
+
+ def IRB.irb_abort(irb, exception = Abort)
+ if defined? Thread
+ irb.context.thread.raise exception, "abort then interrupt!!"
+ else
+ raise exception, "abort then interrupt!!"
+ end
+ end
+
+ #
+ # irb interpriter main routine
+ #
+ class Irb
+ def initialize(workspace = nil, input_method = nil)
+ @context = Context.new(self, workspace, input_method)
+ @context.main.extend ExtendCommandBundle
+ @signal_status = :IN_IRB
+
+ @scanner = RubyLex.new
+ @scanner.exception_on_syntax_error = false
+ end
+ attr_reader :context
+ attr_accessor :scanner
+
+ def eval_input
+ @scanner.set_prompt do
+ |ltype, indent, continue, line_no|
+ if ltype
+ f = @context.prompt_s
+ elsif continue
+ f = @context.prompt_c
+ else @context.prompt_i
+ f = @context.prompt_i
+ end
+ f = "" unless f
+ if @context.prompting?
+ @context.io.prompt = p = prompt(f, ltype, indent, line_no)
+ else
+ @context.io.prompt = p = ""
+ end
+ if @context.auto_indent_mode
+ unless ltype
+ ind = prompt(@context.prompt_i, ltype, indent, line_no).size +
+ indent * 2 - p.size
+ ind += 2 if continue
+ @context.io.prompt = p + " " * ind if ind > 0
+ end
+ end
+ end
+
+ @scanner.set_input(@context.io) do
+ signal_status(:IN_INPUT) do
+ if l = @context.io.gets
+ print l if @context.verbose?
+ else
+ if @context.ignore_eof? and @context.io.readable_atfer_eof?
+ l = "\n"
+ if @context.verbose?
+ printf "Use \"exit\" to leave %s\n", @context.ap_name
+ end
+ end
+ end
+ l
+ end
+ end
+
+ @scanner.each_top_level_statement do |line, line_no|
+ signal_status(:IN_EVAL) do
+ begin
+ line.untaint
+ @context.evaluate(line, line_no)
+ output_value if @context.echo?
+ rescue StandardError, ScriptError, Abort
+ $! = RuntimeError.new("unknown exception raised") unless $!
+ print $!.class, ": ", $!, "\n"
+ if $@[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && $!.class.to_s !~ /^IRB/
+ irb_bug = true
+ else
+ irb_bug = false
+ end
+
+ messages = []
+ lasts = []
+ levels = 0
+ for m in $@
+ m = @context.workspace.filter_backtrace(m) unless irb_bug
+ if m
+ if messages.size < @context.back_trace_limit
+ messages.push "\tfrom "+m
+ else
+ lasts.push "\tfrom "+m
+ if lasts.size > @context.back_trace_limit
+ lasts.shift
+ levels += 1
+ end
+ end
+ end
+ end
+ print messages.join("\n"), "\n"
+ unless lasts.empty?
+ printf "... %d levels...\n", levels if levels > 0
+ print lasts.join("\n")
+ end
+ print "Maybe IRB bug!!\n" if irb_bug
+ end
+ if $SAFE > 2
+ warn "Error: irb does not work for $SAFE level higher than 2"
+ exit 1
+ end
+ end
+ end
+ end
+
+ def suspend_name(path = nil, name = nil)
+ @context.irb_path, back_path = path, @context.irb_path if path
+ @context.irb_name, back_name = name, @context.irb_name if name
+ begin
+ yield back_path, back_name
+ ensure
+ @context.irb_path = back_path if path
+ @context.irb_name = back_name if name
+ end
+ end
+
+ def suspend_workspace(workspace)
+ @context.workspace, back_workspace = workspace, @context.workspace
+ begin
+ yield back_workspace
+ ensure
+ @context.workspace = back_workspace
+ end
+ end
+
+ def suspend_input_method(input_method)
+ back_io = @context.io
+ @context.instance_eval{@io = input_method}
+ begin
+ yield back_io
+ ensure
+ @context.instance_eval{@io = back_io}
+ end
+ end
+
+ def suspend_context(context)
+ @context, back_context = context, @context
+ begin
+ yield back_context
+ ensure
+ @context = back_context
+ end
+ end
+
+ def signal_handle
+ unless @context.ignore_sigint?
+ print "\nabort!!\n" if @context.verbose?
+ exit
+ end
+
+ case @signal_status
+ when :IN_INPUT
+ print "^C\n"
+ raise RubyLex::TerminateLineInput
+ when :IN_EVAL
+ IRB.irb_abort(self)
+ when :IN_LOAD
+ IRB.irb_abort(self, LoadAbort)
+ when :IN_IRB
+ # ignore
+ else
+ # ignore other cases as well
+ end
+ end
+
+ def signal_status(status)
+ return yield if @signal_status == :IN_LOAD
+
+ signal_status_back = @signal_status
+ @signal_status = status
+ begin
+ yield
+ ensure
+ @signal_status = signal_status_back
+ end
+ end
+
+ def prompt(prompt, ltype, indent, line_no)
+ p = prompt.dup
+ p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
+ case $2
+ when "N"
+ @context.irb_name
+ when "m"
+ @context.main.to_s
+ when "M"
+ @context.main.inspect
+ when "l"
+ ltype
+ when "i"
+ if $1
+ format("%" + $1 + "d", indent)
+ else
+ indent.to_s
+ end
+ when "n"
+ if $1
+ format("%" + $1 + "d", line_no)
+ else
+ line_no.to_s
+ end
+ when "%"
+ "%"
+ end
+ end
+ p
+ end
+
+ def output_value
+ if @context.inspect?
+ printf @context.return_format, @context.last_value.inspect
+ else
+ printf @context.return_format, @context.last_value
+ end
+ end
+
+ def inspect
+ ary = []
+ for iv in instance_variables
+ case iv
+ when "@signal_status"
+ ary.push format("%s=:%s", iv, @signal_status.id2name)
+ when "@context"
+ ary.push format("%s=%s", iv, eval(iv).__to_s__)
+ else
+ ary.push format("%s=%s", iv, eval(iv))
+ end
+ end
+ format("#<%s: %s>", self.class, ary.join(", "))
+ end
+ end
+
+ # Singleton method
+ def @CONF.inspect
+ IRB.version unless self[:VERSION]
+
+ array = []
+ for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
+ case k
+ when :MAIN_CONTEXT, :__TMP__EHV__
+ array.push format("CONF[:%s]=...myself...", k.id2name)
+ when :PROMPT
+ s = v.collect{
+ |kk, vv|
+ ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
+ format(":%s=>{%s}", kk.id2name, ss.join(", "))
+ }
+ array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
+ else
+ array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
+ end
+ end
+ array.join("\n")
+ end
+end
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/cmd/chws.rb
new file mode 100644
index 0000000000..84f06014ba
--- /dev/null
+++ b/lib/irb/cmd/chws.rb
@@ -0,0 +1,33 @@
+#
+# change-ws.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+require "irb/cmd/nop.rb"
+require "irb/ext/change-ws.rb"
+
+module IRB
+ module ExtendCommand
+
+ class CurrentWorkingWorkspace<Nop
+ def execute(*obj)
+ irb_context.main
+ end
+ end
+
+ class ChangeWorkspace<Nop
+ def execute(*obj)
+ irb_context.change_workspace(*obj)
+ irb_context.main
+ end
+ end
+ end
+end
+
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
new file mode 100644
index 0000000000..30024dc5e0
--- /dev/null
+++ b/lib/irb/cmd/fork.rb
@@ -0,0 +1,25 @@
+
+module IRB
+ module ExtendCommand
+ class Fork<Nop
+ def execute(&block)
+ pid = send(ExtendCommand.irb_original_method_name("fork"))
+ unless pid
+ class<<self
+ alias_method :exit, ExtendCommand.irb_original_method_name('exit')
+ end
+ if iterator?
+ begin
+ yield
+ ensure
+ exit
+ end
+ end
+ end
+ pid
+ end
+ end
+ end
+end
+
+
diff --git a/lib/irb/cmd/load.rb b/lib/irb/cmd/load.rb
new file mode 100644
index 0000000000..99d20f500c
--- /dev/null
+++ b/lib/irb/cmd/load.rb
@@ -0,0 +1,67 @@
+#
+# load.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+require "irb/cmd/nop.rb"
+require "irb/ext/loader"
+
+module IRB
+ module ExtendCommand
+ class Load<Nop
+ include IrbLoader
+
+ def execute(file_name, priv = nil)
+# return ruby_load(file_name) unless IRB.conf[:USE_LOADER]
+ return irb_load(file_name, priv)
+ end
+ end
+
+ class Require<Nop
+ include IrbLoader
+
+ def execute(file_name)
+# return ruby_require(file_name) unless IRB.conf[:USE_LOADER]
+
+ rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
+ return false if $".find{|f| f =~ rex}
+
+ case file_name
+ when /\.rb$/
+ begin
+ if irb_load(file_name)
+ $".push file_name
+ return true
+ end
+ rescue LoadError
+ end
+ when /\.(so|o|sl)$/
+ return ruby_require(file_name)
+ end
+
+ begin
+ irb_load(f = file_name + ".rb")
+ $".push f
+ return true
+ rescue LoadError
+ return ruby_require(file_name)
+ end
+ end
+ end
+
+ class Source<Nop
+ include IrbLoader
+ def execute(file_name)
+ source_file(file_name)
+ end
+ end
+ end
+
+end
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
new file mode 100644
index 0000000000..73c52b1aa3
--- /dev/null
+++ b/lib/irb/cmd/nop.rb
@@ -0,0 +1,39 @@
+#
+# nop.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+module IRB
+ module ExtendCommand
+ class Nop
+
+ @RCS_ID='-$Id$-'
+
+ def self.execute(conf, *opts)
+ command = new(conf)
+ command.execute(*opts)
+ end
+
+ def initialize(conf)
+ @irb_context = conf
+ end
+
+ attr_reader :irb_context
+
+ def irb
+ @irb_context.irb
+ end
+
+ def execute(*opts)
+ #nop
+ end
+ end
+ end
+end
+
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/cmd/pushws.rb
new file mode 100644
index 0000000000..0d8130d5c6
--- /dev/null
+++ b/lib/irb/cmd/pushws.rb
@@ -0,0 +1,39 @@
+#
+# change-ws.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+require "irb/cmd/nop.rb"
+require "irb/ext/workspaces.rb"
+
+module IRB
+ module ExtendCommand
+ class Workspaces<Nop
+ def execute(*obj)
+ irb_context.workspaces.collect{|ws| ws.main}
+ end
+ end
+
+ class PushWorkspace<Workspaces
+ def execute(*obj)
+ irb_context.push_workspace(*obj)
+ super
+ end
+ end
+
+ class PopWorkspace<Workspaces
+ def execute(*obj)
+ irb_context.pop_workspace(*obj)
+ super
+ end
+ end
+ end
+end
+
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/cmd/subirb.rb
new file mode 100644
index 0000000000..7899f1bb43
--- /dev/null
+++ b/lib/irb/cmd/subirb.rb
@@ -0,0 +1,43 @@
+#!/usr/local/bin/ruby
+#
+# multi.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+require "irb/cmd/nop.rb"
+require "irb/ext/multi-irb"
+
+module IRB
+ module ExtendCommand
+ class IrbCommand<Nop
+ def execute(*obj)
+ IRB.irb(nil, *obj)
+ end
+ end
+
+ class Jobs<Nop
+ def execute
+ IRB.JobManager
+ end
+ end
+
+ class Foreground<Nop
+ def execute(key)
+ IRB.JobManager.switch(key)
+ end
+ end
+
+ class Kill<Nop
+ def execute(*keys)
+ IRB.JobManager.kill(*keys)
+ end
+ end
+ end
+end
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index cbd4012773..e51a92adc1 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -1,8 +1,19 @@
+#
+# irb/completor.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+# From Original Idea of shugo@ruby-lang.org
+#
require "readline"
module IRB
- module InputCompletion
+ module InputCompletor
+
+ @RCS_ID='-$Id$-'
+
ReservedWords = [
"BEGIN", "END",
"alias", "and",
@@ -20,28 +31,158 @@ module IRB
"then", "true",
"undef", "unless", "until",
"when", "while",
- "yield"
+ "yield",
]
CompletionProc = proc { |input|
+ bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
+
+# puts "input: #{input}"
+
case input
- when /^([^.]+)\.([^.]*)$/
+ when /^(\/[^\/]*\/)\.([^.]*)$/
+ # Regexp
+ receiver = $1
+ message = Regexp.quote($2)
+
+ candidates = Regexp.instance_methods(true)
+ select_message(receiver, message, candidates)
+
+ when /^([^\]]*\])\.([^.]*)$/
+ # Array
+ receiver = $1
+ message = Regexp.quote($2)
+
+ candidates = Array.instance_methods(true)
+ select_message(receiver, message, candidates)
+
+ when /^([^\}]*\})\.([^.]*)$/
+ # Proc or Hash
receiver = $1
- message = $2
- if eval("(local_variables|#{receiver}.type.constants).include?('#{receiver}')",
- IRB.conf[:MAIN_CONTEXT].bind)
- candidates = eval("#{receiver}.methods", IRB.conf[:MAIN_CONTEXT].bind)
+ message = Regexp.quote($2)
+
+ candidates = Proc.instance_methods(true) | Hash.instance_methods(true)
+ select_message(receiver, message, candidates)
+
+ when /^(:[^:.]*)$/
+ # Symbol
+ if Symbol.respond_to?(:all_symbols)
+ sym = $1
+ candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
+ candidates.grep(/^#{sym}/)
else
+ []
+ end
+
+ when /^::([A-Z][^:\.\(]*)$/
+ # Absolute Constant or class methods
+ receiver = $1
+ candidates = Object.constants
+ candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
+
+ when /^(((::)?[A-Z][^:.\(]*)+)::?([^:.]*)$/
+ # Constant or class methods
+ receiver = $1
+ message = Regexp.quote($4)
+ begin
+ candidates = eval("#{receiver}.constants | #{receiver}.methods", bind)
+ rescue Exception
candidates = []
end
- candidates.grep(/^#{Regexp.quote(message)}/).collect{|e| receiver + "." + e}
+ candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
+
+ when /^(:[^:.]+)\.([^.]*)$/
+ # Symbol
+ receiver = $1
+ message = Regexp.quote($2)
+
+ candidates = Symbol.instance_methods(true)
+ select_message(receiver, message, candidates)
+
+ when /^([0-9_]+(\.[0-9_]+)?(e[0-9]+)?)\.([^.]*)$/
+ # Numeric
+ receiver = $1
+ message = Regexp.quote($4)
+
+ begin
+ candidates = eval(receiver, bind).methods
+ rescue Exception
+ candidates
+ end
+ select_message(receiver, message, candidates)
+
+ when /^(\$[^.]*)$/
+ candidates = global_variables.grep(Regexp.new(Regexp.quote($1)))
+
+# when /^(\$?(\.?[^.]+)+)\.([^.]*)$/
+ when /^((\.?[^.]+)+)\.([^.]*)$/
+ # variable
+ receiver = $1
+ message = Regexp.quote($3)
+
+ gv = eval("global_variables", bind)
+ lv = eval("local_variables", bind)
+ cv = eval("self.class.constants", bind)
+
+ if (gv | lv | cv).include?(receiver)
+ # foo.func and foo is local var.
+ candidates = eval("#{receiver}.methods", bind)
+ elsif /^[A-Z]/ =~ receiver and /\./ !~ receiver
+ # Foo::Bar.func
+ begin
+ candidates = eval("#{receiver}.methods", bind)
+ rescue Exception
+ candidates = []
+ end
+ else
+ # func1.func2
+ candidates = []
+ ObjectSpace.each_object(Module){|m|
+ next if m.name != "IRB::Context" and
+ /^(IRB|SLex|RubyLex|RubyToken)/ =~ m.name
+ candidates.concat m.instance_methods(false)
+ }
+ candidates.sort!
+ candidates.uniq!
+ end
+ select_message(receiver, message, candidates)
+
+ when /^\.([^.]*)$/
+ # unknown(maybe String)
+
+ receiver = ""
+ message = Regexp.quote($1)
+
+ candidates = String.instance_methods(true)
+ select_message(receiver, message, candidates)
+
else
- candidates = eval("methods | private_methods | local_variables | type.constants",
- IRB.conf[:MAIN_CONTEXT].bind)
+ candidates = eval("methods | private_methods | local_variables | self.class.constants", bind)
+
(candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
end
}
+
+ Operators = ["%", "&", "*", "**", "+", "-", "/",
+ "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
+ "[]", "[]=", "^",]
+
+ def self.select_message(receiver, message, candidates)
+ candidates.grep(/^#{message}/).collect do |e|
+ case e
+ when /^[a-zA-Z_]/
+ receiver + "." + e
+ when /^[0-9]/
+ when *Operators
+ #receiver + " " + e
+ end
+ end
+ end
end
end
-Readline.completion_proc = IRB::InputCompletion::CompletionProc
+if Readline.respond_to?("basic_word_break_characters=")
+ Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{("
+end
+Readline.completion_append_character = nil
+Readline.completion_proc = IRB::InputCompletor::CompletionProc
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
new file mode 100644
index 0000000000..9421608f85
--- /dev/null
+++ b/lib/irb/context.rb
@@ -0,0 +1,234 @@
+#
+# irb/context.rb - irb context
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+require "irb/workspace"
+
+module IRB
+ class Context
+ #
+ # Arguments:
+ # input_method: nil -- stdin or readline
+ # String -- File
+ # other -- using this as InputMethod
+ #
+ def initialize(irb, workspace = nil, input_method = nil)
+ @irb = irb
+ if workspace
+ @workspace = workspace
+ else
+ @workspace = WorkSpace.new
+ end
+ @thread = Thread.current if defined? Thread
+# @irb_level = 0
+
+ # copy of default configuration
+ @ap_name = IRB.conf[:AP_NAME]
+ @rc = IRB.conf[:RC]
+ @load_modules = IRB.conf[:LOAD_MODULES]
+
+ @use_readline = IRB.conf[:USE_READLINE]
+ @inspect_mode = IRB.conf[:INSPECT_MODE]
+
+ self.math_mode = IRB.conf[:MATH_MODE] if IRB.conf[:MATH_MODE]
+ self.use_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRASER]
+ self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
+ self.eval_history = IRB.conf[:EVAL_HISTORY] if IRB.conf[:EVAL_HISTORY]
+
+ @ignore_sigint = IRB.conf[:IGNORE_SIGINT]
+ @ignore_eof = IRB.conf[:IGNORE_EOF]
+
+ @back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
+
+ self.prompt_mode = IRB.conf[:PROMPT_MODE]
+
+ if IRB.conf[:SINGLE_IRB] or !defined?(JobManager)
+ @irb_name = IRB.conf[:IRB_NAME]
+ else
+ @irb_name = "irb#"+IRB.JobManager.n_jobs.to_s
+ end
+ @irb_path = "(" + @irb_name + ")"
+
+ case input_method
+ when nil
+ if (defined?(ReadlineInputMethod) &&
+ (use_readline? || IRB.conf[:PROMPT_MODE] != :INF_RUBY && STDIN.tty?))
+ @io = ReadlineInputMethod.new
+ else
+ @io = StdioInputMethod.new
+ end
+ when String
+ @io = FileInputMethod.new(input_method)
+ @irb_name = File.basename(input_method)
+ @irb_path = input_method
+ else
+ @io = input_method
+ end
+
+ @verbose = IRB.conf[:VERBOSE]
+ @echo = IRB.conf[:ECHO]
+ if @echo.nil?
+ @echo = true
+ end
+ @debug_level = IRB.conf[:DEBUG_LEVEL]
+ end
+
+ def main
+ @workspace.main
+ end
+
+ attr_reader :workspace_home
+ attr_accessor :workspace
+ attr_reader :thread
+ attr_accessor :io
+
+ attr_accessor :irb
+ attr_accessor :ap_name
+ attr_accessor :rc
+ attr_accessor :load_modules
+ attr_accessor :irb_name
+ attr_accessor :irb_path
+
+ attr_accessor :use_readline
+ attr_reader :inspect_mode
+
+ attr_reader :prompt_mode
+ attr_accessor :prompt_i
+ attr_accessor :prompt_s
+ attr_accessor :prompt_c
+ attr_accessor :auto_indent_mode
+ attr_accessor :return_format
+
+ attr_accessor :ignore_sigint
+ attr_accessor :ignore_eof
+ attr_accessor :echo
+ attr_accessor :verbose
+ attr_reader :debug_level
+
+ attr_accessor :back_trace_limit
+
+ alias use_readline? use_readline
+ alias rc? rc
+ alias ignore_sigint? ignore_sigint
+ alias ignore_eof? ignore_eof
+ alias echo? echo
+
+ def verbose?
+ if @verbose.nil?
+ if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
+ false
+ elsif !STDIN.tty? or @io.kind_of?(FileInputMethod)
+ true
+ else
+ false
+ end
+ end
+ end
+
+ def prompting?
+ verbose? || (STDIN.tty? && @io.kind_of?(StdioInputMethod) ||
+ (defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)))
+ end
+
+ attr_reader :last_value
+
+ def set_last_value(value)
+ @last_value = value
+ end
+
+ attr_reader :irb_name
+
+ def prompt_mode=(mode)
+ @prompt_mode = mode
+ pconf = IRB.conf[:PROMPT][mode]
+ @prompt_i = pconf[:PROMPT_I]
+ @prompt_s = pconf[:PROMPT_S]
+ @prompt_c = pconf[:PROMPT_C]
+ @return_format = pconf[:RETURN]
+ if ai = pconf.include?(:AUTO_INDENT)
+ @auto_indent_mode = ai
+ else
+ @auto_indent_mode = IRB.conf[:AUTO_INDENT]
+ end
+ end
+
+ def inspect?
+ @inspect_mode.nil? or @inspect_mode
+ end
+
+ def file_input?
+ @io.class == FileInputMethod
+ end
+
+ def inspect_mode=(opt)
+ if opt
+ @inspect_mode = opt
+ else
+ @inspect_mode = !@inspect_mode
+ end
+ print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose?
+ @inspect_mode
+ end
+
+ undef use_readline=
+ def use_readline=(opt)
+ @use_readline = opt
+ print "use readline module\n" if @use_readline
+ end
+
+ def debug_level=(value)
+ @debug_level = value
+ RubyLex.debug_level = value
+ SLex.debug_level = value
+ end
+
+ def debug?
+ @debug_level > 0
+ end
+
+ def evaluate(line, line_no)
+ @line_no = line_no
+ set_last_value(@workspace.evaluate(self, line, irb_path, line_no))
+# @workspace.evaluate("_ = IRB.conf[:MAIN_CONTEXT]._")
+# @_ = @workspace.evaluate(line, irb_path, line_no)
+ end
+
+ alias __exit__ exit
+ def exit(ret = 0)
+ IRB.irb_exit(@irb, ret)
+ end
+
+ NOPRINTING_IVARS = ["@last_value"]
+ NO_INSPECTING_IVARS = ["@irb", "@io"]
+ IDNAME_IVARS = ["@prompt_mode"]
+
+ alias __inspect__ inspect
+ def inspect
+ array = []
+ for ivar in instance_variables.sort{|e1, e2| e1 <=> e2}
+ name = ivar.sub(/^@(.*)$/){$1}
+ val = instance_eval(ivar)
+ case ivar
+ when *NOPRINTING_IVARS
+ array.push format("conf.%s=%s", name, "...")
+ when *NO_INSPECTING_IVARS
+ array.push format("conf.%s=%s", name, val.to_s)
+ when *IDNAME_IVARS
+ array.push format("conf.%s=:%s", name, val.id2name)
+ else
+ array.push format("conf.%s=%s", name, val.inspect)
+ end
+ end
+ array.join("\n")
+ end
+ alias __to_s__ to_s
+ alias to_s inspect
+ end
+end
diff --git a/lib/irb/ext/change-ws.rb b/lib/irb/ext/change-ws.rb
new file mode 100644
index 0000000000..f15391e202
--- /dev/null
+++ b/lib/irb/ext/change-ws.rb
@@ -0,0 +1,62 @@
+#
+# irb/ext/cb.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+module IRB
+ class Context
+
+ def home_workspace
+ if defined? @home_workspace
+ @home_workspace
+ else
+ @home_workspace = @workspace
+ end
+ end
+
+ def change_workspace(*_main)
+ if _main.empty?
+ @workspace = home_workspace
+ return main
+ end
+
+ @workspace = WorkSpace.new(_main[0])
+
+ if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
+ main.extend ExtendCommandBundle
+ end
+ end
+
+# def change_binding(*_main)
+# back = @workspace
+# @workspace = WorkSpace.new(*_main)
+# unless _main.empty?
+# begin
+# main.extend ExtendCommandBundle
+# rescue
+# print "can't change binding to: ", main.inspect, "\n"
+# @workspace = back
+# return nil
+# end
+# end
+# @irb_level += 1
+# begin
+# catch(:SU_EXIT) do
+# @irb.eval_input
+# end
+# ensure
+# @irb_level -= 1
+# @workspace = back
+# end
+# end
+# alias change_workspace change_binding
+ end
+end
+
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
new file mode 100644
index 0000000000..d40a62e959
--- /dev/null
+++ b/lib/irb/ext/history.rb
@@ -0,0 +1,110 @@
+#
+# history.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+module IRB
+
+ class Context
+
+ NOPRINTING_IVARS.push "@eval_history_values"
+
+ alias _set_last_value set_last_value
+
+ def set_last_value(value)
+ _set_last_value(value)
+
+ @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
+ if @eval_history #and !@eval_history_values.equal?(llv)
+ @eval_history_values.push @line_no, @last_value
+ @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
+ end
+
+ @last_value
+ end
+
+ attr_reader :eval_history
+ def eval_history=(no)
+ if no
+ if @eval_history
+ @eval_history_values.size(no)
+ else
+ @eval_history_values = History.new(no)
+ IRB.conf[:__TMP__EHV__] = @eval_history_values
+ @workspace.evaluate(self, "__ = IRB.conf[:__TMP__EHV__]")
+ IRB.conf.delete(:__TMP_EHV__)
+ end
+ else
+ @eval_history_values = nil
+ end
+ @eval_history = no
+ end
+ end
+
+ class History
+ @RCS_ID='-$Id$-'
+
+ def initialize(size = 16)
+ @size = size
+ @contents = []
+ end
+
+ def size(size)
+ if size != 0 && size < @size
+ @contents = @contents[@size - size .. @size]
+ end
+ @size = size
+ end
+
+ def [](idx)
+ begin
+ if idx >= 0
+ @contents.find{|no, val| no == idx}[1]
+ else
+ @contents[idx][1]
+ end
+ rescue NameError
+ nil
+ end
+ end
+
+ def push(no, val)
+ @contents.push [no, val]
+ @contents.shift if @size != 0 && @contents.size > @size
+ end
+
+ alias real_inspect inspect
+
+ def inspect
+ if @contents.empty?
+ return real_inspect
+ end
+
+ unless (last = @contents.pop)[1].equal?(self)
+ @contents.push last
+ last = nil
+ end
+ str = @contents.collect{|no, val|
+ if val.equal?(self)
+ "#{no} ...self-history..."
+ else
+ "#{no} #{val.inspect}"
+ end
+ }.join("\n")
+ if str == ""
+ str = "Empty."
+ end
+ @contents.push last if last
+ str
+ end
+ end
+end
+
+
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
new file mode 100644
index 0000000000..26e36e1209
--- /dev/null
+++ b/lib/irb/ext/loader.rb
@@ -0,0 +1,106 @@
+module IRB
+ class LoadAbort < Exception;end
+
+ module IrbLoader
+ @RCS_ID='-$Id$-'
+ alias ruby_load load
+ alias ruby_require require
+
+ def irb_load(fn, priv = nil)
+ path = search_file_from_ruby_path(fn)
+ raise LoadError, "No such file to load -- #{fn}" unless path
+
+ load_file(path, priv)
+ end
+
+ def search_file_from_ruby_path(fn)
+ if /^#{Regexp.quote(File::Separator)}/ =~ fn
+ return fn if File.exist?(fn)
+ return nil
+ end
+
+ for path in $:
+ if File.exist?(f = File.join(path, fn))
+ return f
+ end
+ end
+ return nil
+ end
+
+ def source_file(path)
+ irb.suspend_name(path, File.basename(path)) do
+ irb.suspend_input_method(FileInputMethod.new(path)) do
+ |back_io|
+ irb.signal_status(:IN_LOAD) do
+ if back_io.kind_of?(FileInputMethod)
+ irb.eval_input
+ else
+ begin
+ irb.eval_input
+ rescue LoadAbort
+ print "load abort!!\n"
+ end
+ end
+ end
+ end
+ end
+ end
+
+ def load_file(path, priv = nil)
+ irb.suspend_name(path, File.basename(path)) do
+
+ if priv
+ ws = WorkSpace.new(Module.new)
+ else
+ ws = WorkSpace.new
+ end
+ irb.suspend_workspace(ws) do
+ irb.suspend_input_method(FileInputMethod.new(path)) do
+ |back_io|
+ irb.signal_status(:IN_LOAD) do
+# p irb.conf
+ if back_io.kind_of?(FileInputMethod)
+ irb.eval_input
+ else
+ begin
+ irb.eval_input
+ rescue LoadAbort
+ print "load abort!!\n"
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ def old
+ back_io = @io
+ back_path = @irb_path
+ back_name = @irb_name
+ back_scanner = @irb.scanner
+ begin
+ @io = FileInputMethod.new(path)
+ @irb_name = File.basename(path)
+ @irb_path = path
+ @irb.signal_status(:IN_LOAD) do
+ if back_io.kind_of?(FileInputMethod)
+ @irb.eval_input
+ else
+ begin
+ @irb.eval_input
+ rescue LoadAbort
+ print "load abort!!\n"
+ end
+ end
+ end
+ ensure
+ @io = back_io
+ @irb_name = back_name
+ @irb_path = back_path
+ @irb.scanner = back_scanner
+ end
+ end
+ end
+end
+
diff --git a/lib/irb/ext/math-mode.rb b/lib/irb/ext/math-mode.rb
new file mode 100644
index 0000000000..5e268bb3e5
--- /dev/null
+++ b/lib/irb/ext/math-mode.rb
@@ -0,0 +1,37 @@
+#
+# math-mode.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+require "mathn"
+
+module IRB
+ class Context
+ attr_reader :math_mode
+ alias math? math_mode
+
+ def math_mode=(opt)
+ if @math_mode == true && opt == false
+ IRB.fail CantReturnToNormalMode
+ return
+ end
+
+ @math_mode = opt
+ if math_mode
+ main.extend Math
+ print "start math mode\n" if verbose?
+ end
+ end
+
+ def inspect?
+ @inspect_mode.nil? && !@math_mode or @inspect_mode
+ end
+ end
+end
+
diff --git a/lib/irb/multi-irb.rb b/lib/irb/ext/multi-irb.rb
index 39dbcbae3c..e815889383 100644
--- a/lib/irb/multi-irb.rb
+++ b/lib/irb/ext/multi-irb.rb
@@ -1,15 +1,15 @@
#
-# multi-irb.rb - multiple irb module
-# $Release Version: 0.6$
+# irb/multi-irb.rb - multiple irb module
+# $Release Version: 0.9$
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
#
#
#
-IRB.fail CanNotGoMultiIrbMode unless defined?(Thread)
+IRB.fail CantShiftToMultiIrbMode unless defined?(Thread)
require "thread"
module IRB
@@ -23,7 +23,7 @@ module IRB
@current_job = nil
end
- attr :current_job, true
+ attr_accessor :current_job
def n_jobs
@jobs.size
@@ -31,7 +31,7 @@ module IRB
def thread(key)
th, irb = search(key)
- irb
+ th
end
def irb(key)
@@ -54,7 +54,7 @@ module IRB
def switch(key)
th, irb = search(key)
IRB.fail IrbAlreadyDead unless th.alive?
- IRB.fail IrbSwitchToCurrentThread if th == Thread.current
+ IRB.fail IrbSwitchedToCurrentThread if th == Thread.current
@current_job = irb
th.run
Thread.stop
@@ -74,7 +74,7 @@ module IRB
when Integer
@jobs[key]
when Irb
- @jobs.find{|k, v| v.equal?(irb)}
+ @jobs.find{|k, v| v.equal?(key)}
when Thread
@jobs.assoc(key)
else
@@ -90,7 +90,7 @@ module IRB
IRB.fail NoSuchJob, key unless @jobs[key]
@jobs[key] = nil
else
- catch (:EXISTS) do
+ catch(:EXISTS) do
@jobs.each_index do
|i|
if @jobs[i] and (@jobs[i][0] == key ||
@@ -140,20 +140,19 @@ module IRB
@JobManager
end
- # invoke multiple irb
+ def IRB.CurrentContext
+ IRB.JobManager.irb(Thread.current).context
+ end
+
+ # invoke multi-irb
def IRB.irb(file = nil, *main)
- workspace = IRB.workspace_binding(*main)
- if main.empty?
- main = eval("self", workspace)
- else
- main = main[0]
- end
+ workspace = WorkSpace.new(*main)
parent_thread = Thread.current
Thread.start do
begin
- irb = Irb.new(main, workspace, file)
+ irb = Irb.new(workspace, file)
rescue
- print "Subirb can't start with context(self): ", main.inspect, "\n"
+ print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
print "return to main irb\n"
Thread.pass
Thread.main.wakeup
@@ -161,6 +160,7 @@ module IRB
end
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
@JobManager.insert(irb)
+ @JobManager.current_job = irb
begin
system_exit = false
catch(:IRB_EXIT) do
@@ -187,26 +187,55 @@ module IRB
@JobManager.current_job = @JobManager.irb(Thread.current)
end
- class Context
- def _=(value)
- @_ = value
- eval "_ = IRB.JobManager.irb(Thread.current).context._", @bind
- end
- end
-
- module ExtendCommand
- def irb_context
- IRB.JobManager.irb(Thread.current).context
- end
- alias conf irb_context
- end
+# class Context
+# def set_last_value(value)
+# @last_value = value
+# @workspace.evaluate "_ = IRB.JobManager.irb(Thread.current).context.last_value"
+# if @eval_history #and !@__.equal?(@last_value)
+# @eval_history_values.push @line_no, @last_value
+# @workspace.evaluate "__ = IRB.JobManager.irb(Thread.current).context.instance_eval{@eval_history_values}"
+# end
+# @last_value
+# end
+# end
+
+# module ExtendCommand
+# def irb_context
+# IRB.JobManager.irb(Thread.current).context
+# end
+# # alias conf irb_context
+# end
@CONF[:SINGLE_IRB_MODE] = false
@JobManager.insert(@CONF[:MAIN_CONTEXT].irb)
@JobManager.current_job = @CONF[:MAIN_CONTEXT].irb
+ class Irb
+ def signal_handle
+ unless @context.ignore_sigint?
+ print "\nabort!!\n" if @context.verbose?
+ exit
+ end
+
+ case @signal_status
+ when :IN_INPUT
+ print "^C\n"
+ IRB.JobManager.thread(self).raise RubyLex::TerminateLineInput
+ when :IN_EVAL
+ IRB.irb_abort(self)
+ when :IN_LOAD
+ IRB.irb_abort(self, LoadAbort)
+ when :IN_IRB
+ # ignore
+ else
+ # ignore other cases as well
+ end
+ end
+ end
+
trap("SIGINT") do
@JobManager.current_job.signal_handle
+ Thread.stop
end
end
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
new file mode 100644
index 0000000000..b2528f74b2
--- /dev/null
+++ b/lib/irb/ext/tracer.rb
@@ -0,0 +1,61 @@
+#
+# irb/lib/tracer.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+require "tracer"
+
+module IRB
+
+ # initialize tracing function
+ def IRB.initialize_tracer
+ Tracer.verbose = false
+ Tracer.add_filter {
+ |event, file, line, id, binding, *rests|
+ /^#{Regexp.quote(@CONF[:IRB_LIB_PATH])}/ !~ file and
+ File::basename(file) != "irb.rb"
+ }
+ end
+
+ class Context
+ attr_reader :use_tracer
+ alias use_tracer? use_tracer
+
+ def use_tracer=(opt)
+ if opt
+ Tracer.set_get_line_procs(@irb_path) {
+ |line_no, *rests|
+ @io.line(line_no)
+ }
+ elsif !opt && @use_tracer
+ Tracer.off
+ end
+ @use_tracer=opt
+ end
+ end
+
+ class WorkSpace
+ alias __evaluate__ evaluate
+ def evaluate(context, statements, file = nil, line = nil)
+ if context.use_tracer? && file != nil && line != nil
+ Tracer.on
+ begin
+ __evaluate__(context, statements, file, line)
+ ensure
+ Tracer.off
+ end
+ else
+ __evaluate__(context, statements, file || __FILE__, line || __LINE__)
+ end
+ end
+ end
+
+ IRB.initialize_tracer
+end
+
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
new file mode 100644
index 0000000000..a81b3aca7b
--- /dev/null
+++ b/lib/irb/ext/use-loader.rb
@@ -0,0 +1,65 @@
+#
+# use-loader.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+require "irb/cmd/load"
+require "irb/ext/loader"
+
+class Object
+ alias __original__load__IRB_use_loader__ load
+ alias __original__require__IRB_use_loader__ require
+end
+
+module IRB
+ module ExtendCommandBundle
+ def irb_load(*opts, &b)
+ ExtendCommand::Load.execute(irb_context, *opts, &b)
+ end
+ def irb_require(*opts, &b)
+ ExtendCommand::Require.execute(irb_context, *opts, &b)
+ end
+ end
+
+ class Context
+
+ IRB.conf[:USE_LOADER] = false
+
+ def use_loader
+ IRB.conf[:USE_LOADER]
+ end
+
+ alias use_loader? use_loader
+
+ def use_loader=(opt)
+
+ if IRB.conf[:USE_LOADER] != opt
+ IRB.conf[:USE_LOADER] = opt
+ if opt
+ if !$".include?("irb/cmd/load")
+ end
+ (class<<@workspace.main;self;end).instance_eval {
+ alias_method :load, :irb_load
+ alias_method :require, :irb_require
+ }
+ else
+ (class<<@workspace.main;self;end).instance_eval {
+ alias_method :load, :__original__load__IRB_use_loader__
+ alias_method :require, :__original__require__IRB_use_loader__
+ }
+ end
+ end
+ print "Switch to load/require#{unless use_loader; ' non';end} trace mode.\n" if verbose?
+ opt
+ end
+ end
+end
+
+
diff --git a/lib/irb/ext/workspaces.rb b/lib/irb/ext/workspaces.rb
new file mode 100644
index 0000000000..2fe8f8a87b
--- /dev/null
+++ b/lib/irb/ext/workspaces.rb
@@ -0,0 +1,56 @@
+#
+# push-ws.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+#
+# --
+#
+#
+#
+
+module IRB
+ class Context
+
+ def irb_level
+ workspace_stack.size
+ end
+
+ def workspaces
+ if defined? @workspaces
+ @workspaces
+ else
+ @workspaces = []
+ end
+ end
+
+ def push_workspace(*_main)
+ if _main.empty?
+ if workspaces.empty?
+ print "No other workspace\n"
+ return nil
+ end
+ ws = workspaces.pop
+ workspaces.push @workspace
+ @workspace = ws
+ return workspaces
+ end
+
+ workspaces.push @workspace
+ @workspace = WorkSpace.new(@workspace.binding, _main[0])
+ if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
+ main.extend ExtendCommandBundle
+ end
+ end
+
+ def pop_workspace
+ if workspaces.empty?
+ print "workspace stack empty\n"
+ return
+ end
+ @workspace = workspaces.pop
+ end
+ end
+end
+
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
new file mode 100644
index 0000000000..cfb2c7c4be
--- /dev/null
+++ b/lib/irb/extend-command.rb
@@ -0,0 +1,215 @@
+#
+# irb/extend-command.rb - irb command extend
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+module IRB
+ #
+ # IRB extended command
+ #
+ module ExtendCommandBundle
+ EXCB = ExtendCommandBundle
+
+ NO_OVERRIDE = 0
+ OVERRIDE_PRIVATE_ONLY = 0x01
+ OVERRIDE_ALL = 0x02
+
+ def irb_exit(ret = 0)
+ irb_context.exit(ret)
+ end
+
+ def irb_context
+ IRB.CurrentContext
+ end
+
+ @ALIASES = [
+ [:context, :irb_context, NO_OVERRIDE],
+ [:conf, :irb_context, NO_OVERRIDE],
+ [:irb_quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
+ [:exit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
+ [:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
+ ]
+
+ @EXTEND_COMMANDS = [
+ [:irb_current_working_workspace, :CurrentWorkingWorkspace, "irb/cmd/chws",
+ [:irb_print_working_workspace, OVERRIDE_ALL],
+ [:irb_cwws, OVERRIDE_ALL],
+ [:irb_pwws, OVERRIDE_ALL],
+# [:irb_cww, OVERRIDE_ALL],
+# [:irb_pww, OVERRIDE_ALL],
+ [:cwws, NO_OVERRIDE],
+ [:pwws, NO_OVERRIDE],
+# [:cww, NO_OVERRIDE],
+# [:pww, NO_OVERRIDE],
+ [:irb_current_working_binding, OVERRIDE_ALL],
+ [:irb_print_working_binding, OVERRIDE_ALL],
+ [:irb_cwb, OVERRIDE_ALL],
+ [:irb_pwb, OVERRIDE_ALL],
+# [:cwb, NO_OVERRIDE],
+# [:pwb, NO_OVERRIDE]
+ ],
+ [:irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
+ [:irb_chws, OVERRIDE_ALL],
+# [:irb_chw, OVERRIDE_ALL],
+ [:irb_cws, OVERRIDE_ALL],
+# [:irb_cw, OVERRIDE_ALL],
+ [:chws, NO_OVERRIDE],
+# [:chw, NO_OVERRIDE],
+ [:cws, NO_OVERRIDE],
+# [:cw, NO_OVERRIDE],
+ [:irb_change_binding, OVERRIDE_ALL],
+ [:irb_cb, OVERRIDE_ALL],
+ [:cb, NO_OVERRIDE]],
+
+ [:irb_workspaces, :Workspaces, "irb/cmd/pushws",
+ [:workspaces, NO_OVERRIDE],
+ [:irb_bindings, OVERRIDE_ALL],
+ [:bindings, NO_OVERRIDE]],
+ [:irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
+ [:irb_pushws, OVERRIDE_ALL],
+# [:irb_pushw, OVERRIDE_ALL],
+ [:pushws, NO_OVERRIDE],
+# [:pushw, NO_OVERRIDE],
+ [:irb_push_binding, OVERRIDE_ALL],
+ [:irb_pushb, OVERRIDE_ALL],
+ [:pushb, NO_OVERRIDE]],
+ [:irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
+ [:irb_popws, OVERRIDE_ALL],
+# [:irb_popw, OVERRIDE_ALL],
+ [:popws, NO_OVERRIDE],
+# [:popw, NO_OVERRIDE],
+ [:irb_pop_binding, OVERRIDE_ALL],
+ [:irb_popb, OVERRIDE_ALL],
+ [:popb, NO_OVERRIDE]],
+
+ [:irb_load, :Load, "irb/cmd/load"],
+ [:irb_require, :Require, "irb/cmd/load"],
+ [:irb_source, :Source, "irb/cmd/load",
+ [:source, NO_OVERRIDE]],
+
+ [:irb, :IrbCommand, "irb/cmd/subirb"],
+ [:irb_jobs, :Jobs, "irb/cmd/subirb",
+ [:jobs, NO_OVERRIDE]],
+ [:irb_fg, :Foreground, "irb/cmd/subirb",
+ [:fg, NO_OVERRIDE]],
+ [:irb_kill, :Kill, "irb/cmd/subirb",
+ [:kill, OVERRIDE_PRIVATE_ONLY]],
+ ]
+
+ def EXCB.install_extend_commands
+ for args in @EXTEND_COMMANDS
+ def_extend_command(*args)
+ end
+ end
+
+ # aliases = [commans_alias, flag], ...
+ def EXCB.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
+ case cmd_class
+ when Symbol
+ cmd_class = cmd_class.id2name
+ when String
+ when Class
+ cmd_class = cmd_class.name
+ end
+
+ if load_file
+ eval %[
+ def #{cmd_name}(*opts, &b)
+ require "#{load_file}"
+ eval %[
+ def #{cmd_name}(*opts, &b)
+ ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
+ end
+ ]
+ send :#{cmd_name}, *opts, &b
+ end
+ ]
+ else
+ eval %[
+ def #{cmd_name}(*opts, &b)
+ ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
+ end
+ ]
+ end
+
+ for ali, flag in aliases
+ @ALIASES.push [ali, cmd_name, flag]
+ end
+ end
+
+ # override = {NO_OVERRIDE, OVERRIDE_PRIVATE_ONLY, OVERRIDE_ALL}
+ def install_alias_method(to, from, override = NO_OVERRIDE)
+ to = to.id2name unless to.kind_of?(String)
+ from = from.id2name unless from.kind_of?(String)
+
+ if override == OVERRIDE_ALL or
+ (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or
+ (override == NO_OVERRIDE) && !respond_to?(to, true)
+ target = self
+ (class<<self;self;end).instance_eval{
+ if target.respond_to?(to, true) &&
+ !target.respond_to?(EXCB.irb_original_method_name(to), true)
+ alias_method(EXCB.irb_original_method_name(to), to)
+ end
+ alias_method to, from
+ }
+ else
+ print "irb: warn: can't alias #{to} from #{from}.\n"
+ end
+ end
+
+ def self.irb_original_method_name(method_name)
+ "irb_" + method_name + "_org"
+ end
+
+ def EXCB.extend_object(obj)
+ unless (class<<obj;ancestors;end).include?(EXCB)
+ super
+ for ali, com, flg in @ALIASES
+ obj.install_alias_method(ali, com, flg)
+ end
+ end
+ end
+
+ install_extend_commands
+ end
+
+ # extension support for Context
+ module ContextExtender
+ CE = ContextExtender
+
+ @EXTEND_COMMANDS = [
+ [:eval_history=, "irb/ext/history.rb"],
+ [:use_tracer=, "irb/ext/tracer.rb"],
+ [:math_mode=, "irb/ext/math-mode.rb"],
+ [:use_loader=, "irb/ext/use-loader.rb"],
+ ]
+
+ def CE.install_extend_commands
+ for args in @EXTEND_COMMANDS
+ def_extend_command(*args)
+ end
+ end
+
+ def CE.def_extend_command(cmd_name, load_file, *aliases)
+ Context.module_eval %[
+ def #{cmd_name}(*opts, &b)
+ require "#{load_file}"
+ send :#{cmd_name}, *opts, &b
+ end
+ for ali in aliases
+ alias_method ali, cmd_name
+ end
+ ]
+ end
+
+ CE.install_extend_commands
+ end
+end
+
diff --git a/lib/irb/frame.rb b/lib/irb/frame.rb
index dcfa5c1d13..f0b0a9abf3 100644
--- a/lib/irb/frame.rb
+++ b/lib/irb/frame.rb
@@ -1,6 +1,6 @@
#
# frame.rb -
-# $Release Version: 0.6$
+# $Release Version: 0.9$
# $Revision$
# $Date$
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
new file mode 100644
index 0000000000..eb876a6dbe
--- /dev/null
+++ b/lib/irb/help.rb
@@ -0,0 +1,33 @@
+#
+# irb/help.rb - print usase module
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+
+module IRB
+ def IRB.print_usage
+ lc = IRB.conf[:LC_MESSAGES]
+ path = lc.find("irb/help-message")
+ space_line = false
+ File.foreach(path) do
+ |l|
+ if /^\s*$/ =~ l
+ lc.puts l unless space_line
+ space_line = true
+ next
+ end
+ space_line = false
+
+ l.sub!(/#.*$/, "")
+ next if /^\s*$/ =~ l
+ lc.puts l
+ end
+ end
+end
+
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
new file mode 100644
index 0000000000..37cdb313e6
--- /dev/null
+++ b/lib/irb/init.rb
@@ -0,0 +1,225 @@
+#
+# irb/init.rb - irb initialize module
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+
+module IRB
+
+ # initialize config
+ def IRB.setup(ap_path)
+ IRB.init_config(ap_path)
+ IRB.init_error
+ IRB.parse_opts
+ IRB.run_config
+ IRB.load_modules
+
+ unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
+ IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE])
+ end
+ end
+
+ # @CONF default setting
+ def IRB.init_config(ap_path)
+ # class instance variables
+ @TRACER_INITIALIZED = false
+
+ # default configurations
+ unless ap_path and @CONF[:AP_NAME]
+ ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
+ end
+ @CONF[:AP_NAME] = File::basename(ap_path, ".rb")
+
+ @CONF[:IRB_NAME] = "irb"
+ @CONF[:IRB_LIB_PATH] = File.dirname(__FILE__)
+
+ @CONF[:RC] = true
+ @CONF[:LOAD_MODULES] = []
+ @CONF[:IRB_RC] = nil
+
+ @CONF[:MATH_MODE] = false
+ @CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod)
+ @CONF[:INSPECT_MODE] = nil
+ @CONF[:USE_TRACER] = false
+ @CONF[:USE_LOADER] = false
+ @CONF[:IGNORE_SIGINT] = true
+ @CONF[:IGNORE_EOF] = false
+ @CONF[:ECHO] = nil
+ @CONF[:VERBOSE] = nil
+
+ @CONF[:EVAL_HISTORY] = nil
+
+ @CONF[:BACK_TRACE_LIMIT] = 16
+
+ @CONF[:PROMPT] = {
+ :NULL => {
+ :PROMPT_I => nil,
+ :PROMPT_S => nil,
+ :PROMPT_C => nil,
+ :RETURN => "%s\n"
+ },
+ :DEFAULT => {
+ :PROMPT_I => "%N(%m):%03n:%i> ",
+ :PROMPT_S => "%N(%m):%03n:%i%l ",
+ :PROMPT_C => "%N(%m):%03n:%i* ",
+ :RETURN => "=> %s\n"
+ },
+ :CLASSIC => {
+ :PROMPT_I => "%N(%m):%03n:%i> ",
+ :PROMPT_S => "%N(%m):%03n:%i%l ",
+ :PROMPT_C => "%N(%m):%03n:%i* ",
+ :RETURN => "%s\n"
+ },
+ :SIMPLE => {
+ :PROMPT_I => ">> ",
+ :PROMPT_S => nil,
+ :PROMPT_C => "?> ",
+ :RETURN => "=> %s\n"
+ },
+ :INF_RUBY => {
+ :PROMPT_I => "%N(%m):%03n:%i> ",
+ :PROMPT_S => nil,
+ :PROMPT_C => nil,
+ :RETURN => "%s\n",
+ :AUTO_INDENT => true
+ },
+ :XMP => {
+ :PROMPT_I => nil,
+ :PROMPT_S => nil,
+ :PROMPT_C => nil,
+ :RETURN => " ==>%s\n"
+ }
+ }
+
+ @CONF[:PROMPT_MODE] = :DEFAULT
+ @CONF[:AUTO_INDENT] = false
+
+ @CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING
+ @CONF[:SINGLE_IRB] = false
+
+# @CONF[:LC_MESSAGES] = "en"
+ @CONF[:LC_MESSAGES] = Locale.new
+
+ @CONF[:DEBUG_LEVEL] = 1
+ end
+
+ def IRB.init_error
+ @CONF[:LC_MESSAGES].load("irb/error.rb")
+ end
+
+ # option analyzing
+ def IRB.parse_opts
+ while opt = ARGV.shift
+ case opt
+ when "-f"
+ @CONF[:RC] = false
+ when "-m"
+ @CONF[:MATH_MODE] = true
+ when "-d"
+ $DEBUG = true
+ when "-r"
+ opt = ARGV.shift
+ @CONF[:LOAD_MODULES].push opt if opt
+ when "-I"
+ opt = ARGV.shift
+ $LOAD_PATH.push opt if opt
+ when /^-K(.)/
+ $KCODE = $1
+ when "--inspect"
+ @CONF[:INSPECT_MODE] = true
+ when "--noinspect"
+ @CONF[:INSPECT_MODE] = false
+ when "--readline"
+ @CONF[:USE_READLINE] = true
+ when "--noreadline"
+ @CONF[:USE_READLINE] = false
+ when "--echo"
+ @CONF[:ECHO] = true
+ when "--noecho"
+ @CONF[:ECHO] = false
+ when "--verbose"
+ @CONF[:VERBOSE] = true
+ when "--noverbose"
+ @CONF[:VERBOSE] = false
+ when "--prompt-mode", "--prompt"
+ prompt_mode = ARGV.shift.upcase.tr("-", "_").intern
+ @CONF[:PROMPT_MODE] = prompt_mode
+ when "--noprompt"
+ @CONF[:PROMPT_MODE] = :NULL
+ when "--inf-ruby-mode"
+ @CONF[:PROMPT_MODE] = :INF_RUBY
+ when "--sample-book-mode", "--simple-prompt"
+ @CONF[:PROMPT_MODE] = :SIMPLE
+ when "--tracer"
+ @CONF[:USE_TRACER] = true
+ when "--back-trace-limit"
+ @CONF[:BACK_TRACE_LIMIT] = ARGV.shift.to_i
+ when "--context-mode"
+ @CONF[:CONTEXT_MODE] = ARGV.shift.to_i
+ when "--single-irb"
+ @CONF[:SINGLE_IRB] = true
+ when "--irb_debug"
+ @CONF[:DEBUG_LEVEL] = ARGV.shift.to_i
+ when "-v", "--version"
+ print IRB.version, "\n"
+ exit 0
+ when "-h", "--help"
+ require "irb/help"
+ IRB.print_usage
+ exit 0
+ when /^-/
+ IRB.fail UnrecognizedSwitch, opt
+ else
+ @CONF[:SCRIPT] = opt
+ $0 = opt
+ break
+ end
+ end
+ end
+
+ # running config
+ def IRB.run_config
+ if @CONF[:RC]
+ rcs = []
+ rcs.push File.expand_path("~/.irbrc") if ENV.key?("HOME")
+ rcs.push ".irbrc"
+ rcs.push "irb.rc"
+ rcs.push "_irbrc"
+ rcs.push "$irbrc"
+ catch(:EXIT) do
+ for rc in rcs
+ begin
+ load rc
+ throw :EXIT
+ rescue LoadError, Errno::ENOENT
+ rescue
+ print "load error: #{rc}\n"
+ print $!.class, ": ", $!, "\n"
+ for err in $@[0, $@.size - 2]
+ print "\t", err, "\n"
+ end
+ throw :EXIT
+ end
+ end
+ end
+ end
+ end
+
+ # loading modules
+ def IRB.load_modules
+ for m in @CONF[:LOAD_MODULES]
+ begin
+ require m
+ rescue
+ print $@[0], ":", $!.class, ": ", $!, "\n"
+ end
+ end
+ end
+
+end
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 19df0eb073..ec834b17bc 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -1,9 +1,9 @@
#
-# input-method.rb - input methods using irb
-# $Release Version: 0.6$
+# irb/input-method.rb - input methods using irb
+# $Release Version: 0.9$
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
#
@@ -23,12 +23,12 @@ module IRB
def initialize(file = STDIN_FILE_NAME)
@file_name = file
end
- attr :file_name
+ attr_reader :file_name
- attr :prompt, true
+ attr_accessor :prompt
def gets
- IRB.fail NotImplementError, "gets"
+ IRB.fail NotImplementedError, "gets"
end
public :gets
@@ -67,15 +67,16 @@ module IRB
super
@io = open(file)
end
- attr :file_name
+ attr_reader :file_name
def eof?
@io.eof?
end
def gets
+ print @prompt
l = @io.gets
- print @prompt, l
+# print @prompt, l
l
end
end
@@ -94,6 +95,7 @@ module IRB
def gets
if l = readline(@prompt, true)
+ HISTORY.pop if l.empty?
@line[@line_no += 1] = l + "\n"
else
@eof = true
diff --git a/lib/irb/lc/error.rb b/lib/irb/lc/error.rb
new file mode 100644
index 0000000000..68a488a48a
--- /dev/null
+++ b/lib/irb/lc/error.rb
@@ -0,0 +1,30 @@
+#
+# irb/lc/error.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+require "e2mmap"
+
+module IRB
+
+ # exceptions
+ extend Exception2MessageMapper
+ def_exception :UnrecognizedSwitch, "Unrecognized switch: %s"
+ def_exception :NotImplementedError, "Need to define `%s'"
+ def_exception :CantReturnToNormalMode, "Can't return to normal mode."
+ def_exception :IllegalParameter, "Illegal parameter(%s)."
+ def_exception :IrbAlreadyDead, "Irb is already dead."
+ def_exception :IrbSwitchedToCurrentThread, "Switched to current thread."
+ def_exception :NoSuchJob, "No such job(%s)."
+ def_exception :CantShiftToMultiIrbMode, "Can't shift to multi irb mode."
+ def_exception :CantChangeBinding, "Can't change binding to (%s)."
+ def_exception :UndefinedPromptMode, "Undefined prompt mode(%s)."
+
+end
+
diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message
new file mode 100644
index 0000000000..efc00bf148
--- /dev/null
+++ b/lib/irb/lc/help-message
@@ -0,0 +1,35 @@
+#
+# irb/lc/help-message.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+Usage: irb.rb [options] [programfile] [arguments]
+ -f Suppress read of ~/.irbrc
+ -m Bc mode (load mathn, fraction or matrix are available)
+ -d Set $DEBUG to true (same as `ruby -d')
+ -r load-module Same as `ruby -r'
+ -I path Specify $LOAD_PATH directory
+ --inspect Use `inspect' for output (default except for bc mode)
+ --noinspect Don't use inspect for output
+ --readline Use Readline extension module
+ --noreadline Don't use Readline extension module
+ --prompt prompt-mode
+ --prompt-mode prompt-mode
+ Switch prompt mode. Pre-defined prompt modes are
+ `default', `simple', `xmp' and `inf-ruby'
+ --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
+ Suppresses --readline.
+ --simple-prompt Simple prompt mode
+ --noprompt No prompt mode
+ --tracer Display trace for each execution of commands.
+ --back-trace-limit n
+ Display backtrace top n and tail n. The default
+ value is 16.
+ --irb_debug n Set internal debug level to n (not for popular use)
+ -v, --version Print the version of irb
diff --git a/lib/irb/lc/ja/error.rb b/lib/irb/lc/ja/error.rb
new file mode 100644
index 0000000000..e1afaf5d71
--- /dev/null
+++ b/lib/irb/lc/ja/error.rb
@@ -0,0 +1,29 @@
+#
+# irb/lc/ja/error.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+require "e2mmap"
+
+module IRB
+ # exceptions
+ extend Exception2MessageMapper
+ def_exception :UnrecognizedSwitch, '$B%9%$%C%A(B(%s)$B$,J,$j$^$;$s(B'
+ def_exception :NotImplementedError, '`%s\'$B$NDj5A$,I,MW$G$9(B'
+ def_exception :CantReturnToNormalMode, 'Normal$B%b!<%I$KLa$l$^$;$s(B.'
+ def_exception :IllegalParameter, '$B%Q%i%a!<%?(B(%s)$B$,4V0c$C$F$$$^$9(B.'
+ def_exception :IrbAlreadyDead, 'Irb$B$O4{$K;`$s$G$$$^$9(B.'
+ def_exception :IrbSwitchedToCurrentThread, '$B%+%l%s%H%9%l%C%I$K@Z$jBX$o$j$^$7$?(B.'
+ def_exception :NoSuchJob, '$B$=$N$h$&$J%8%g%V(B(%s)$B$O$"$j$^$;$s(B.'
+ def_exception :CantShiftToMultiIrbMode, 'multi-irb mode$B$K0\$l$^$;$s(B.'
+ def_exception :CantChangeBinding, '$B%P%$%s%G%#%s%0(B(%s)$B$KJQ99$G$-$^$;$s(B.'
+ def_exception :UndefinedPromptMode, '$B%W%m%s%W%H%b!<%I(B(%s)$B$ODj5A$5$l$F$$$^$;$s(B.'
+end
+
+
diff --git a/lib/irb/lc/ja/help-message b/lib/irb/lc/ja/help-message
new file mode 100644
index 0000000000..4b710c7788
--- /dev/null
+++ b/lib/irb/lc/ja/help-message
@@ -0,0 +1,36 @@
+#
+# irb/lc/ja/help-message.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+Usage: irb.rb [options] [programfile] [arguments]
+ -f ~/.irbrc $B$rFI$_9~$^$J$$(B.
+ -m bc$B%b!<%I(B($BJ,?t(B, $B9TNs$N7W;;$,$G$-$k(B)
+ -d $DEBUG $B$r(Btrue$B$K$9$k(B(ruby -d $B$HF1$8(B)
+ -r load-module ruby -r $B$HF1$8(B.
+ -I path $LOAD_PATH $B$K(B path $B$rDI2C$9$k(B.
+ --inspect $B7k2L=PNO$K(Binspect$B$rMQ$$$k(B(bc$B%b!<%I0J30$O%G%U%)%k%H(B).
+ --noinspect $B7k2L=PNO$K(Binspect$B$rMQ$$$J$$(B.
+ --readline readline$B%i%$%V%i%j$rMxMQ$9$k(B.
+ --noreadline readline$B%i%$%V%i%j$rMxMQ$7$J$$(B.
+ --prompt prompt-mode/--prompt-mode prompt-mode
+ $B%W%m%s%W%H%b!<%I$r@ZBX$($^$9(B. $B8=:_Dj5A$5$l$F$$$k%W(B
+ $B%m%s%W%H%b!<%I$O(B, default, simple, xmp, inf-ruby$B$,(B
+ $BMQ0U$5$l$F$$$^$9(B.
+ --inf-ruby-mode emacs$B$N(Binf-ruby-mode$BMQ$N%W%m%s%W%HI=<($r9T$J$&(B. $BFC(B
+ $B$K;XDj$,$J$$8B$j(B, readline$B%i%$%V%i%j$O;H$o$J$/$J$k(B.
+ --simple-prompt $BHs>o$K%7%s%W%k$J%W%m%s%W%H$rMQ$$$k%b!<%I$G$9(B.
+ --noprompt $B%W%m%s%W%HI=<($r9T$J$o$J$$(B.
+ --tracer $B%3%^%s%I<B9T;~$K%H%l!<%9$r9T$J$&(B.
+ --back-trace-limit n
+ $B%P%C%/%H%l!<%9I=<($r%P%C%/%H%l!<%9$NF,$+$i(B n, $B8e$m(B
+ $B$+$i(Bn$B$@$19T$J$&(B. $B%G%U%)%k%H$O(B16
+ --irb_debug n irb$B$N%G%P%C%0%G%P%C%0%l%Y%k$r(Bn$B$K@_Dj$9$k(B($BMxMQ$7$J(B
+ $B$$J}$,L5Fq$G$7$g$&(B).
+ -v, --version irb$B$N%P!<%8%g%s$rI=<($9$k(B
diff --git a/lib/irb/loader.rb b/lib/irb/loader.rb
deleted file mode 100644
index 83b10a55a0..0000000000
--- a/lib/irb/loader.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-#
-# irb-loader.rb -
-# $Release Version: 0.6$
-# $Revision$
-# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
-#
-# --
-#
-#
-#
-
-module IRB
- class LoadAbort < GlobalExit;end
-
- module Loader
- @RCS_ID='-$Id$-'
-
- alias ruby_load load
- alias ruby_require require
-
- def irb_load(file_name)
- return ruby_load(file_name) unless IRB.conf[:USE_LOADER]
-
- load_sub(file_name)
- return true
- end
-
- def irb_require(file_name)
- return ruby_require(file_name) unless IRB.conf[:USE_LOADER]
-
- rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
- return false if $".find{|f| f =~ rex}
-
- case file_name
- when /\.rb$/
- begin
- load_sub(file_name)
- $".push file_name
- return true
- rescue LoadError
- end
- when /\.(so|o|sl)$/
- return ruby_require(file_name)
- end
-
- begin
- load_sub(f = file_name + ".rb")
- $".push f
- return true
- rescue LoadError
- return ruby_require(file_name)
- end
- end
-
- def load_sub(fn)
- if fn =~ /^#{Regexp.quote(File::Separator)}/
- return false unless File.exist?(fn)
- return irb_context.load_file(fn)
- end
-
- for path in $:
- if File.exist?(f = File.join(path, fn))
- return irb_context.load_file(f)
- end
- end
- raise LoadError, "No such file to load -- #{file_name}"
- end
-
- alias load irb_load
- alias require irb_require
- end
-
-# class Context
-# def load_from(file_name)
-# io = FileInputMethod.new(file_name)
-# @irb.signal_status(:IN_LOAD) do
-# switch_io(io, file_name) do
-# eval_input
-# end
-# end
-# end
-# end
-
- class Context
- def load_file(path)
- back_io = @io
- back_path = @irb_path
- back_name = @irb_name
- back_scanner = @irb.scanner
- begin
- @io = FileInputMethod.new(path)
- @irb_name = File.basename(path)
- @irb_path = path
- @irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- @irb.eval_input
- else
- begin
- @irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- ensure
- @io = back_io
- @irb_name = back_name
- @irb_path = back_path
- @irb.scanner = back_scanner
- end
- end
- end
-
- module ExtendCommand
- include Loader
- end
-end
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
new file mode 100644
index 0000000000..b2c90e38e2
--- /dev/null
+++ b/lib/irb/locale.rb
@@ -0,0 +1,186 @@
+#
+# irb/locale.rb - internationalization module
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+
+autoload :Tempfile, "tempfile"
+autoload :Kconv, "kconv"
+
+module IRB
+ class Locale
+ @RCS_ID='-$Id$-'
+
+ JPDefaultLocale = "ja"
+ LOCALE_DIR = "/lc/"
+
+ def initialize(locale = nil)
+ @lang = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
+ end
+
+ attr_reader :lang
+
+ def lc2kconv(lang)
+ case lang
+ when "ja_JP.ujis", "ja_JP.euc", "ja_JP.eucJP"
+ Kconv::EUC
+ when "ja_JP.sjis", "ja_JP.SJIS"
+ Kconv::SJIS
+ end
+ end
+ private :lc2kconv
+
+ def String(mes)
+ mes = super(mes)
+ case @lang
+ when /^ja/
+ mes = Kconv::kconv(mes, lc2kconv(@lang))
+ else
+ mes
+ end
+ mes
+ end
+
+ def format(*opts)
+ String(super(*opts))
+ end
+
+ def gets(*rs)
+ String(super(*rs))
+ end
+
+ def readline(*rs)
+ String(super(*rs))
+ end
+
+ def print(*opts)
+ ary = opts.collect{|opt| String(opt)}
+ super(*ary)
+ end
+
+ def printf(*opts)
+ s = format(*opts)
+ print s
+ end
+
+ def puts(*opts)
+ ary = opts.collect{|opt| String(opts)}
+ super(*ary)
+ end
+
+ def require(file, priv = nil)
+ rex = Regexp.new("lc/#{Regexp.quote(file)}\.(so|o|sl|rb)?")
+ return false if $".find{|f| f =~ rex}
+
+ case file
+ when /\.rb$/
+ begin
+ load(file, priv)
+ $".push file
+ return true
+ rescue LoadError
+ end
+ when /\.(so|o|sl)$/
+ return super
+ end
+
+ begin
+ load(f = file + ".rb")
+ $".push f #"
+ return true
+ rescue LoadError
+ return ruby_require(file)
+ end
+ end
+
+ alias toplevel_load load
+
+ def load(file, priv=nil)
+ dir = File.dirname(file)
+ dir = "" if dir == "."
+ base = File.basename(file)
+
+ if /^ja(_JP)?$/ =~ @lang
+ back, @lang = @lang, "C"
+ end
+ begin
+ if dir[0] == ?/ #/
+ lc_path = search_file(dir, base)
+ return real_load(lc_path, priv) if lc_path
+ end
+
+ for path in $:
+ lc_path = search_file(path + "/" + dir, base)
+ return real_load(lc_path, priv) if lc_path
+ end
+ ensure
+ @lang = back if back
+ end
+ raise LoadError, "No such file to load -- #{file}"
+ end
+
+ def real_load(path, priv)
+ tmp_base = path.tr("./:", "___")
+ lc_file = Tempfile.new(tmp_base)
+ File.foreach(path) do |line|
+ line = self.String(line)
+ lc_file.print(line)
+ end
+ lc_file.close
+ toplevel_load lc_file.path, priv
+ lc_file.close(true)
+ end
+ private :real_load
+
+ def find(file , paths = $:)
+ dir = File.dirname(file)
+ dir = "" if dir == "."
+ base = File.basename(file)
+ if dir[0] == ?/ #/
+ return lc_path = search_file(dir, base)
+ else
+ for path in $:
+ if lc_path = search_file(path + "/" + dir, base)
+ return lc_path
+ end
+ end
+ end
+ nil
+ end
+
+ def search_file(path, file)
+ if File.exists?(p1 = path + lc_path(file, "C"))
+ if File.exists?(p2 = path + lc_path(file))
+ return p2
+ else
+ end
+ return p1
+ else
+ end
+ nil
+ end
+ private :search_file
+
+ def lc_path(file = "", lc = @lang)
+ case lc
+ when "C"
+ LOCALE_DIR + file
+ when /^ja/
+ LOCALE_DIR + "ja/" + file
+ else
+ LOCALE_DIR + @lang + "/" + file
+ end
+ end
+ private :lc_path
+ end
+end
+
+
+
+
diff --git a/lib/irb/main.rb b/lib/irb/main.rb
deleted file mode 100644
index 4c7dac240b..0000000000
--- a/lib/irb/main.rb
+++ /dev/null
@@ -1,867 +0,0 @@
-#
-# main.rb - irb main module
-# $Release Version: 0.6 $
-# $Revision$
-# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
-#
-# --
-#
-#
-#
-require "e2mmap"
-require "irb/ruby-lex"
-require "irb/input-method"
-require "irb/workspace-binding"
-
-STDOUT.sync = true
-
-module IRB
- @RCS_ID='-$Id$-'
-
- # exceptions
- extend Exception2MessageMapper
- def_exception :UnrecognizedSwitch, "Unrecognized switch: %s"
- def_exception :NotImplementError, "Need to define `%s'"
- def_exception :CantRetuenNormalMode, "Can't return normal mode."
- def_exception :IllegalParameter, "Illegal parameter(%s)."
- def_exception :IrbAlreadyDead, "Irb is already dead."
- def_exception :IrbSwitchToCurrentThread, "Change to current thread."
- def_exception :NoSuchJob, "No such job(%s)."
- def_exception :CanNotGoMultiIrbMode, "Can't go multi irb mode."
- def_exception :CanNotChangeBinding, "Can't change binding to (%s)."
- def_exception :UndefinedPromptMode, "Undefined prompt mode(%s)."
-
- class Abort < Exception;end
-
- # initialize IRB and start TOP_LEVEL irb
- def IRB.start(ap_path = nil)
- $0 = File::basename(ap_path, ".rb") if ap_path
-
- IRB.initialize(ap_path)
- IRB.parse_opts
- IRB.load_modules
-
- bind = workspace_binding
- main = eval("self", bind)
-
- if @CONF[:SCRIPT]
- irb = Irb.new(main, bind, @CONF[:SCRIPT])
- else
- irb = Irb.new(main, bind)
- end
-
- @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
- @CONF[:MAIN_CONTEXT] = irb.context
-
- trap("SIGINT") do
- irb.signal_handle
- end
-
- catch(:IRB_EXIT) do
- irb.eval_input
- end
- print "\n"
- end
-
- # initialize config
- def IRB.initialize(ap_path)
- IRB.init_config(ap_path)
- IRB.run_config
- end
-
- #
- # @CONF functions
- #
- @CONF = {}
- # @CONF default setting
- def IRB.init_config(ap_path)
- # class instance variables
- @TRACER_INITIALIZED = false
- @MATHN_INITIALIZED = false
-
- # default configurations
- unless ap_path and @CONF[:AP_NAME]
- ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
- end
- @CONF[:AP_NAME] = File::basename(ap_path, ".rb")
-
- @CONF[:IRB_NAME] = "irb"
- @CONF[:IRB_LIB_PATH] = File.dirname(__FILE__)
-
- @CONF[:RC] = true
- @CONF[:LOAD_MODULES] = []
- @CONF[:IRB_RC] = nil
-
- @CONF[:MATH_MODE] = false
- @CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod)
- @CONF[:INSPECT_MODE] = nil
- @CONF[:USE_TRACER] = false
- @CONF[:USE_LOADER] = false
- @CONF[:IGNORE_SIGINT] = true
- @CONF[:IGNORE_EOF] = false
-
- @CONF[:BACK_TRACE_LIMIT] = 16
-
- @CONF[:PROMPT] = {
- :NULL => {
- :PROMPT_I => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => "%s\n"
- },
- :DEFAULT => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_S => "%N(%m):%03n:%i%l ",
- :PROMPT_C => "%N(%m):%03n:%i* ",
- :RETURN => "%s\n"
- },
- :SIMPLE => {
- :PROMPT_I => ">> ",
- :PROMPT_S => nil,
- :PROMPT_C => "?> ",
- :RETURN => "=> %s\n"
- },
- :INF_RUBY => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => "%s\n",
- :AUTO_INDENT => true
- },
- :XMP => {
- :PROMPT_I => nil,
- :PROMPT_S => nil,
- :PROMPT_C => nil,
- :RETURN => " ==>%s\n"
- }
- }
-
- @CONF[:PROMPT_MODE] = :DEFAULT
- @CONF[:AUTO_INDENT] = false
-
- @CONF[:CONTEXT_MODE] = 3
- @CONF[:SINGLE_IRB] = false
-
- @CONF[:DEBUG_LEVEL] = 1
- @CONF[:VERBOSE] = true
- end
-
- # IRB version method
- def IRB.version
- if v = @CONF[:VERSION] then return v end
-
- require "irb/version"
- rv = @RELEASE_VERSION.sub(/\.0/, "")
- @CONF[:VERSION] = format("irb %s(%s)", rv, @LAST_UPDATE_DATE)
- end
-
- def IRB.conf
- @CONF
- end
-
- # option analyzing
- def IRB.parse_opts
- while opt = ARGV.shift
- case opt
- when "-f"
- opt = ARGV.shift
- @CONF[:RC] = false
- when "-m"
- @CONF[:MATH_MODE] = true
- when "-d"
- $DEBUG = true
- when "-r"
- opt = ARGV.shift
- @CONF[:LOAD_MODULES].push opt if opt
- when "--inspect"
- @CONF[:INSPECT_MODE] = true
- when "--noinspect"
- @CONF[:INSPECT_MODE] = false
- when "--readline"
- @CONF[:USE_READLINE] = true
- when "--noreadline"
- @CONF[:USE_READLINE] = false
- when "--prompt-mode", "--prompt"
- prompt_mode = ARGV.shift.upcase.tr("-", "_").intern
- IRB.fail(UndefinedPromptMode,
- prompt_mode.id2name) unless @CONF[:PROMPT][prompt_mode]
- @CONF[:PROMPT_MODE] = prompt_mode
- when "--noprompt"
- @CONF[:PROMPT_MODE] = :NULL
- when "--inf-ruby-mode"
- @CONF[:PROMPT_MODE] = :INF_RUBY
- when "--sample-book-mode", "--simple-prompt"
- @CONF[:PROMPT_MODE] = :SIMPLE
- when "--tracer"
- @CONF[:USE_TRACER] = true
- when "--back-trace-limit"
- @CONF[:BACK_TRACE_LIMIT] = ARGV.shift.to_i
- when "--context-mode"
- @CONF[:CONTEXT_MODE] = ARGV.shift.to_i
- when "--single-irb"
- @CONF[:SINGLE_IRB] = true
- when "--irb_debug"
- @CONF[:DEBUG_LEVEL] = ARGV.shift.to_i
- when "-v", "--version"
- print IRB.version, "\n"
- exit(0)
- when /^-/
- IRB.fail UnrecognizedSwitch, opt
- else
- @CONF[:USE_READLINE] = false
- @CONF[:SCRIPT] = opt
- $0 = opt
- break
- end
- end
- end
-
- # running config
- def IRB.run_config
- if @CONF[:RC]
- rcs = []
- rcs.push File.expand_path("~/.irbrc") if ENV.key?("HOME")
- rcs.push ".irbrc"
- rcs.push "irb.rc"
- rcs.push "_irbrc"
- rcs.push "$irbrc"
- catch(:EXIT) do
- for rc in rcs
- begin
- load rc
- throw :EXIT
- rescue LoadError, Errno::ENOENT
- rescue
- print "load error: #{rc}\n"
- print $!.type, ": ", $!, "\n"
- for err in $@[0, $@.size - 2]
- print "\t", err, "\n"
- end
- throw :EXIT
- end
- end
- end
- end
- end
-
- # loading modules
- def IRB.load_modules
- for m in @CONF[:LOAD_MODULES]
- begin
- require m
- rescue
- print $@[0], ":", $!.type, ": ", $!, "\n"
- end
- end
- end
-
- # initialize tracing function
- def IRB.initialize_tracer
- unless @TRACER_INITIALIZED
- require("tracer")
- Tracer.verbose = false
- Tracer.add_filter {
- |event, file, line, id, binding|
- File::dirname(file) != @CONF[:IRB_LIB_PATH]
- }
- @TRACER_INITIALIZED = true
- end
- end
-
- # initialize mathn function
- def IRB.initialize_mathn
- unless @MATHN_INITIALIZED
- require "mathn"
- @MATHN_INITIALIZED = true
- end
- end
-
- # initialize loader function
- def IRB.initialize_loader
- unless @LOADER_INITIALIZED
- require "irb/loader"
- @LOADER_INITIALIZED = true
- end
- end
-
- def IRB.irb_exit(irb, ret)
- throw :IRB_EXIT, ret
- end
-
- def IRB.irb_abort(irb, exception = Abort)
- if defined? Thread
- irb.context.thread.raise exception, "abort then interrupt!!"
- else
- raise exception, "abort then interrupt!!"
- end
- end
-
- #
- # irb interpriter main routine
- #
- class Irb
- def initialize(main, bind, input_method = nil)
- @context = Context.new(self, main, bind, input_method)
- main.extend ExtendCommand
- @signal_status = :IN_IRB
-
- @scanner = RubyLex.new
- @scanner.exception_on_syntax_error = false
- end
- attr :context
- attr :scanner, true
-
- def eval_input
-# @scanner = RubyLex.new
- @scanner.set_input(@context.io) do
- signal_status(:IN_INPUT) do
- unless l = @context.io.gets
- if @context.ignore_eof? and @context.io.readable_atfer_eof?
- l = "\n"
- if @context.verbose?
- printf "Use \"exit\" to leave %s\n", @context.ap_name
- end
- end
- end
- l
- end
- end
-
- @scanner.set_prompt do
- |ltype, indent, continue, line_no|
- if ltype
- f = @context.prompt_s
- elsif continue
- f = @context.prompt_c
- else @context.prompt_i
- f = @context.prompt_i
- end
- f = "" unless f
- @context.io.prompt = p = prompt(f, ltype, indent, line_no)
- if @context.auto_indent_mode
- unless ltype
- ind = prompt(@context.prompt_i, ltype, indent, line_no).size +
- indent * 2 - p.size
- ind += 2 if continue
- @context.io.prompt = p + " " * ind if ind > 0
- end
- end
- end
-
- @scanner.each_top_level_statement do
- |line, line_no|
- signal_status(:IN_EVAL) do
- begin
- trace_in do
- @context._ = eval(line, @context.bind, @context.irb_path, line_no)
-# @context._ = irb_eval(line, @context.bind, @context.irb_path, line_no)
- end
-
- if @context.inspect?
- printf @context.return_format, @context._.inspect
- else
- printf @context.return_format, @context._
- end
- rescue StandardError, ScriptError, Abort
- $! = RuntimeError.new("unknown exception raised") unless $!
- print $!.type, ": ", $!, "\n"
- if $@[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && $!.type.to_s !~ /^IRB/
- irb_bug = true
- else
- irb_bug = false
- end
-
- messages = []
- lasts = []
- levels = 0
- for m in $@
- if m !~ /irb2?(\/.*|-.*|\.rb)?:/ or irb_bug
- if messages.size < @context.back_trace_limit
- messages.push m
- else
- lasts.push m
- if lasts.size > @context.back_trace_limit
- lasts.shift
- levels += 1
- end
- end
- end
- end
- print messages.join("\n"), "\n"
- unless lasts.empty?
- printf "... %d levels...\n", levels if levels > 0
- print lasts.join("\n")
- end
- print "Maybe IRB bug!!\n" if irb_bug
- end
- end
- end
- end
-
-# def irb_eval(line, bind, path, line_no)
-# id, str = catch(:IRB_TOPLEVEL_EVAL){
-# return eval(line, bind, path, line_no)
-# }
-# case id
-# when :EVAL_TOPLEVEL
-# eval(str, bind, "(irb_internal)", 1)
-# when :EVAL_CONTEXT
-# @context.instance_eval(str)
-# else
-# IRB.fail IllegalParameter
-# end
-# end
-
- def signal_handle
- unless @context.ignore_sigint?
- print "\nabort!!\n" if @context.verbose?
- exit
- end
-
- case @signal_status
- when :IN_INPUT
- print "^C\n"
- @scanner.initialize_input
- print @context.io.prompt
- when :IN_EVAL
- IRB.irb_abort(self)
- when :IN_LOAD
- IRB.irb_abort(self, LoadAbort)
- when :IN_IRB
- # ignore
- else
- # ignore
- end
- end
-
- def signal_status(status)
- return yield if @signal_status == :IN_LOAD
-
- signal_status_back = @signal_status
- @signal_status = status
- begin
- yield
- ensure
- @signal_status = signal_status_back
- end
- end
-
- def trace_in
- Tracer.on if @context.use_tracer?
- begin
- yield
- ensure
- Tracer.off if @context.use_tracer?
- end
- end
-
- def prompt(prompt, ltype, indent, line_no)
- p = prompt.dup
- p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
- case $2
- when "N"
- @context.irb_name
- when "m"
- @context.main.to_s
- when "M"
- @context.main.inspect
- when "l"
- ltype
- when "i"
- if $1
- format("%" + $1 + "d", indent)
- else
- indent.to_s
- end
- when "n"
- if $1
- format("%" + $1 + "d", line_no)
- else
- line_no.to_s
- end
- when "%"
- "%"
- end
- end
- p
- end
-
- def inspect
- ary = []
- for iv in instance_variables
- case iv
- when "@signal_status"
- ary.push format("%s=:%s", iv, @signal_status.id2name)
- when "@context"
- ary.push format("%s=%s", iv, eval(iv).__to_s__)
- else
- ary.push format("%s=%s", iv, eval(iv))
- end
- end
- format("#<%s: %s>", type, ary.join(", "))
- end
- end
-
- #
- # irb context
- #
- class Context
- #
- # Arguments:
- # input_method: nil -- stdin or readline
- # String -- File
- # other -- using this as InputMethod
- #
- def initialize(irb, main, bind, input_method = nil)
- @irb = irb
- @main = main
- @bind = bind
- @thread = Thread.current if defined? Thread
- @irb_level = 0
-
- # copy of default configuration
- @ap_name = IRB.conf[:AP_NAME]
- @rc = IRB.conf[:RC]
- @load_modules = IRB.conf[:LOAD_MODULES]
-
- self.math_mode = IRB.conf[:MATH_MODE]
- @use_readline = IRB.conf[:USE_READLINE]
- @inspect_mode = IRB.conf[:INSPECT_MODE]
- @use_tracer = IRB.conf[:USE_TRACER]
-# @use_loader = IRB.conf[:USE_LOADER]
-
- self.prompt_mode = IRB.conf[:PROMPT_MODE]
-
- @ignore_sigint = IRB.conf[:IGNORE_SIGINT]
- @ignore_eof = IRB.conf[:IGNORE_EOF]
-
- @back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
-
- debug_level = IRB.conf[:DEBUG_LEVEL]
- @verbose = IRB.conf[:VERBOSE]
-
- @tracer_initialized = false
-
- if IRB.conf[:SINGLE_IRB] or !defined?(JobManager)
- @irb_name = IRB.conf[:IRB_NAME]
- else
- @irb_name = "irb#"+IRB.JobManager.n_jobs.to_s
- end
- @irb_path = "(" + @irb_name + ")"
-
- case input_method
- when nil
- if (use_readline.nil? && IRB.conf[:PROMPT_MODE] != :INF_RUBY ||
- use_readline?)
- @io = ReadlineInputMethod.new
- else
- @io = StdioInputMethod.new
- end
- when String
- @io = FileInputMethod.new(input_method)
- @irb_name = File.basename(input_method)
- @irb_path = input_method
- else
- @io = input_method
- end
- end
-
- attr :bind, true
- attr :main, true
- attr :thread
- attr :io, true
-
- attr :_
-
- attr :irb
- attr :ap_name
- attr :rc
- attr :load_modules
- attr :irb_name
- attr :irb_path
-
- attr :math_mode, true
- attr :use_readline, true
- attr :inspect_mode
- attr :use_tracer
-# attr :use_loader
-
- attr :debug_level
- attr :verbose, true
-
- attr :prompt_mode
- attr :prompt_i, true
- attr :prompt_s, true
- attr :prompt_c, true
- attr :auto_indent_mode, true
- attr :return_format, true
-
- attr :ignore_sigint, true
- attr :ignore_eof, true
-
- attr :back_trace_limit
-
-# alias use_loader? use_loader
- alias use_tracer? use_tracer
- alias use_readline? use_readline
- alias rc? rc
- alias math? math_mode
- alias verbose? verbose
- alias ignore_sigint? ignore_sigint
- alias ignore_eof? ignore_eof
-
- def _=(value)
- @_ = value
- eval "_ = IRB.conf[:MAIN_CONTEXT]._", @bind
- end
-
- def irb_name
- if @irb_level == 0
- @irb_name
- elsif @irb_name =~ /#[0-9]*$/
- @irb_name + "." + @irb_level.to_s
- else
- @irb_name + "#0." + @irb_level.to_s
- end
- end
-
- def prompt_mode=(mode)
- @prompt_mode = mode
- pconf = IRB.conf[:PROMPT][mode]
- @prompt_i = pconf[:PROMPT_I]
- @prompt_s = pconf[:PROMPT_S]
- @prompt_c = pconf[:PROMPT_C]
- @return_format = pconf[:RETURN]
- if ai = pconf.include?(:AUTO_INDENT)
- @auto_indent_mode = ai
- else
- @auto_indent_mode = IRB.conf[:AUTO_INDENT]
- end
- end
-
- def inspect?
- @inspect_mode.nil? && !@math_mode or @inspect_mode
- end
-
- def file_input?
- @io.type == FileInputMethod
- end
-
- def use_tracer=(opt)
- if opt
- IRB.initialize_tracer
- unless @tracer_initialized
- Tracer.set_get_line_procs(@irb_path) {
- |line_no|
- @io.line(line_no)
- }
- @tracer_initialized = true
- end
- elsif !opt && @use_tracer
- Tracer.off
- end
- @use_tracer=opt
- end
-
- def use_loader
- IRB.conf[:USE_LOADER]
- end
-
- def use_loader=(opt)
- IRB.conf[:USE_LOADER] = opt
- if opt
- IRB.initialize_loader
- end
- print "Switch to load/require#{unless use_loader; ' non';end} trace mode.\n" if verbose?
- opt
- end
-
- def inspect_mode=(opt)
- if opt
- @inspect_mode = opt
- else
- @inspect_mode = !@inspect_mode
- end
- print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose?
- @inspect_mode
- end
-
- def math_mode=(opt)
- if @math_mode == true && opt == false
- IRB.fail CantRetuenNormalMode
- return
- end
-
- @math_mode = opt
- if math_mode
- IRB.initialize_mathn
- @main.instance_eval("include Math")
- print "start math mode\n" if verbose?
- end
- end
-
- def use_readline=(opt)
- @use_readline = opt
- print "use readline module\n" if @use_readline
- end
-
- def debug_level=(value)
- @debug_level = value
- RubyLex.debug_level = value
- SLex.debug_level = value
- end
-
- def debug?
- @debug_level > 0
- end
-
- def change_binding(*main)
- back = [@bind, @main]
- @bind = IRB.workspace_binding(*main)
- unless main.empty?
- @main = eval("self", @bind)
- begin
- @main.extend ExtendCommand
- rescue
- print "can't change binding to: ", @main.inspect, "\n"
- @bind, @main = back
- return nil
- end
- end
- @irb_level += 1
- begin
- catch(:SU_EXIT) do
- @irb.eval_input
- end
- ensure
- @irb_level -= 1
- @bind, @main = back
- end
- end
-
- alias __exit__ exit
- def exit(ret = 0)
- if @irb_level == 0
- IRB.irb_exit(@irb, ret)
- else
- throw :SU_EXIT, ret
- end
- end
-
- NOPRINTING_IVARS = ["@_"]
- NO_INSPECTING_IVARS = ["@irb", "@io"]
- IDNAME_IVARS = ["@prompt_mode"]
-
- alias __inspect__ inspect
- def inspect
- array = []
- for ivar in instance_variables.sort{|e1, e2| e1 <=> e2}
- name = ivar.sub(/^@(.*)$/){$1}
- val = instance_eval(ivar)
- case ivar
- when *NOPRINTING_IVARS
- next
- when *NO_INSPECTING_IVARS
- array.push format("conf.%s=%s", name, val.to_s)
- when *IDNAME_IVARS
- array.push format("conf.%s=:%s", name, val.id2name)
- else
- array.push format("conf.%s=%s", name, val.inspect)
- end
- end
- array.join("\n")
- end
- alias __to_s__ to_s
- alias to_s inspect
-
- end
-
- #
- # IRB extended command
- #
- module Loader; end
- module ExtendCommand
- include Loader
-
- alias irb_exit_org exit
- def irb_exit(ret = 0)
- irb_context.exit(ret)
- end
- alias exit irb_exit
- alias quit irb_exit
-
- alias irb_fork fork
- def fork(&block)
- unless irb_fork
- eval "alias exit irb_exit_org"
- instance_eval "alias exit irb_exit_org"
- if iterator?
- yield
- exit
- end
- end
- end
-
- def irb_change_binding(*main)
- irb_context.change_binding(*main)
- end
- alias cb irb_change_binding
-
- def irb_source(file)
- irb_context.source(file)
- end
- alias source irb_source
-
- def irb(*obj)
- require "irb/multi-irb"
- IRB.irb(nil, *obj)
- end
-
- def irb_context
- IRB.conf[:MAIN_CONTEXT]
- end
- alias conf irb_context
-
- def irb_jobs
- require "irb/multi-irb"
- IRB.JobManager
- end
- alias jobs irb_jobs
-
- def irb_fg(key)
- require "irb/multi-irb"
- IRB.JobManager.switch(key)
- end
- alias fg irb_fg
-
- def irb_kill(*keys)
- require "irb/multi-irb"
- IRB.JobManager.kill(*keys)
- end
- alias kill irb_kill
- end
-
- # Singleton method
- def @CONF.inspect
- IRB.version unless self[:VERSION]
-
- array = []
- for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
- case k
- when :MAIN_CONTEXT
- next
- when :PROMPT
- s = v.collect{
- |kk, vv|
- ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
- format(":%s=>{%s}", kk.id2name, ss.join(", "))
- }
- array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
- else
- array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
- end
- end
- array.join("\n")
- end
-end
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 534870e329..e25af30546 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -1,9 +1,9 @@
#
-# ruby-lex.rb - ruby lexcal analizer
-# $Release Version: 0.6$
+# irb/ruby-lex.rb - ruby lexcal analizer
+# $Release Version: 0.9$
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
#
@@ -24,11 +24,13 @@ class RubyLex
def_exception(:TkReading2TokenDuplicateError,
"key duplicate(token_n='%s', key='%s')")
def_exception(:SyntaxError, "%s")
+
+ def_exception(:TerminateLineInput, "Terminate Line Input")
include RubyToken
class << self
- attr :debug_level, TRUE
+ attr_accessor :debug_level
def debug?
@debug_level > 0
end
@@ -48,30 +50,34 @@ class RubyLex
@here_readed = []
@indent = 0
+ @indent_stack = []
@skip_space = false
@readed_auto_clean_up = false
@exception_on_syntax_error = true
+ @prompt = nil
+ @here_header = nil
+ @lex_state = nil
end
- attr :skip_space, true
- attr :readed_auto_clean_up, true
- attr :exception_on_syntax_error, true
+ attr_accessor :skip_space
+ attr_accessor :readed_auto_clean_up
+ attr_accessor :exception_on_syntax_error
- attr :seek
- attr :char_no
- attr :line_no
- attr :indent
+ attr_reader :seek
+ attr_reader :char_no
+ attr_reader :line_no
+ attr_reader :indent
# io functions
- def set_input(io, p = nil)
+ def set_input(io, p = nil, &block)
@io = io
- if p.kind_of?(Proc)
+ if p.respond_to?(:call)
@input = p
- elsif iterator?
- @input = proc
+ elsif block_given?
+ @input = block
else
- @input = proc{@io.gets}
+ @input = Proc.new{@io.gets}
end
end
@@ -180,11 +186,12 @@ class RubyLex
end
private :buf_input
- def set_prompt(p = proc)
- if p.kind_of?(Proc)
+ def set_prompt(p=nil, &block)
+ p = block if block_given?
+ if p.respond_to?(:call)
@prompt = p
else
- @prompt = proc{print p}
+ @prompt = Proc.new{print p}
end
end
@@ -198,12 +205,13 @@ class RubyLex
@ltype = nil
@quoted = nil
@indent = 0
+ @indent_stack = []
@lex_state = EXPR_BEG
@space_seen = false
@here_header = false
+ @continue = false
prompt
- @continue = FALSE
@line = ""
@exp_line_no = @line_no
@@ -211,27 +219,36 @@ class RubyLex
def each_top_level_statement
initialize_input
- loop do
- @continue = FALSE
- prompt
- unless l = lex
- break if @line == ''
- else
- # p l
- @line.concat l
- if @ltype or @continue or @indent > 0
- next
+ catch(:TERM_INPUT) do
+ loop do
+ begin
+ @continue = false
+ prompt
+ unless l = lex
+ throw :TERM_INPUT if @line == ''
+ else
+ #p l
+ @line.concat l
+ if @ltype or @continue or @indent > 0
+ next
+ end
+ end
+ if @line != "\n"
+ yield @line, @exp_line_no
+ end
+ break unless l
+ @line = ''
+ @exp_line_no = @line_no
+
+ @indent = 0
+ @indent_stack = []
+ prompt
+ rescue TerminateLineInput
+ initialize_input
+ prompt
+ get_readed
end
end
- if @line != "\n"
- yield @line, @exp_line_no
- end
- break unless l
- @line = ''
- @exp_line_no = @line_no
-
- @indent = 0
- prompt
end
end
@@ -239,8 +256,9 @@ class RubyLex
until (((tk = token).kind_of?(TkNL) || tk.kind_of?(TkEND_OF_SCRIPT)) &&
!@continue or
tk.nil?)
- # p tk
- # p self
+ #p tk
+ #p @lex_state
+ #p self
end
line = get_readed
# print self.inspect
@@ -285,7 +303,9 @@ class RubyLex
"Q" => "\"",
"x" => "\`",
"r" => "\/",
- "w" => "]"
+ "w" => "]",
+ "W" => "]",
+ "s" => ":"
}
PERCENT_PAREN = {
@@ -300,7 +320,8 @@ class RubyLex
"\"" => TkSTRING,
"\`" => TkXSTRING,
"\/" => TkREGEXP,
- "]" => TkDSTRING
+ "]" => TkDSTRING,
+ ":" => TkSYMBOL
}
DLtype2Token = {
"\"" => TkDSTRING,
@@ -315,7 +336,7 @@ class RubyLex
end
@OP.def_rules(" ", "\t", "\f", "\r", "\13") do
- @space_seen = TRUE
+ @space_seen = true
while getc =~ /[ \t\f\r\13]/; end
ungetc
Token(TkSPACE)
@@ -333,7 +354,7 @@ class RubyLex
until peek_equal?("=end") && peek(4) =~ /\s/
until getc == "\n"; end
end
- getc; getc; getc; getc
+ gets
@ltype = nil
Token(TkRD_COMMENT)
end
@@ -342,10 +363,15 @@ class RubyLex
print "\\n\n" if RubyLex.debug?
case @lex_state
when EXPR_BEG, EXPR_FNAME, EXPR_DOT
- @continue = TRUE
+ @continue = true
else
- @continue = FALSE
+ @continue = false
@lex_state = EXPR_BEG
+ until (@indent_stack.empty? ||
+ [TkLPAREN, TkLBRACK, TkLBRACE,
+ TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
+ @indent_stack.pop
+ end
end
@here_header = false
@here_readed = []
@@ -353,26 +379,44 @@ class RubyLex
end
@OP.def_rules("*", "**",
- "!", "!=", "!~",
"=", "==", "===",
"=~", "<=>",
"<", "<=",
">", ">=", ">>") do
|op, io|
+ case @lex_state
+ when EXPR_FNAME, EXPR_DOT
+ @lex_state = EXPR_ARG
+ else
+ @lex_state = EXPR_BEG
+ end
+ Token(op)
+ end
+
+ @OP.def_rules("!", "!=", "!~") do
+ |op, io|
@lex_state = EXPR_BEG
Token(op)
end
@OP.def_rules("<<") do
|op, io|
+ tk = nil
if @lex_state != EXPR_END && @lex_state != EXPR_CLASS &&
(@lex_state != EXPR_ARG || @space_seen)
c = peek(0)
if /\S/ =~ c && (/["'`]/ =~ c || /[\w_]/ =~ c || c == "-")
tk = identify_here_document
end
- else
- tk = Token(op)
+ end
+ unless tk
+ tk = Token(op)
+ case @lex_state
+ when EXPR_FNAME, EXPR_DOT
+ @lex_state = EXPR_ARG
+ else
+ @lex_state = EXPR_BEG
+ end
end
tk
end
@@ -398,7 +442,7 @@ class RubyLex
Token(TkQUESTION)
else
ch = getc
- if @lex_state == EXPR_ARG && ch !~ /\s/
+ if @lex_state == EXPR_ARG && ch =~ /\s/
ungetc
@lex_state = EXPR_BEG;
Token(TkQUESTION)
@@ -427,11 +471,13 @@ class RubyLex
end
@OP.def_rule("+@", proc{@lex_state == EXPR_FNAME}) do
- Token(TkUPLUS)
+ |op, io|
+ Token(op)
end
@OP.def_rule("-@", proc{@lex_state == EXPR_FNAME}) do
- Token(TkUMINUS)
+ |op, io|
+ Token(op)
end
@OP.def_rules("+", "-") do
@@ -458,7 +504,7 @@ class RubyLex
ungetc
identify_number
else
- # for obj.if
+ # for "obj.if" etc.
@lex_state = EXPR_DOT
Token(TkDOT)
end
@@ -478,6 +524,7 @@ class RubyLex
|op, io|
@lex_state = EXPR_END
@indent -= 1
+ @indent_stack.pop
Token(op)
end
@@ -509,7 +556,7 @@ class RubyLex
elsif peek(0) == '='
getc
@lex_state = EXPR_BEG
- Token(TkOPASGN, :/) #/)
+ Token(TkOPASGN, "/") #/)
elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
identify_string(op)
else
@@ -528,9 +575,20 @@ class RubyLex
# Token(OP_ASGN, :^)
# end
- @OP.def_rules(",", ";") do
+ @OP.def_rules(",") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op)
+ end
+
+ @OP.def_rules(";") do
|op, io|
@lex_state = EXPR_BEG
+ until (@indent_stack.empty? ||
+ [TkLPAREN, TkLBRACK, TkLBRACE,
+ TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
+ @indent_stack.pop
+ end
Token(op)
end
@@ -539,7 +597,7 @@ class RubyLex
Token("~")
end
- @OP.def_rule("~@", proc{@lex_state = EXPR_FNAME}) do
+ @OP.def_rule("~@", proc{@lex_state == EXPR_FNAME}) do
@lex_state = EXPR_BEG
Token("~")
end
@@ -548,11 +606,13 @@ class RubyLex
@indent += 1
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
@lex_state = EXPR_BEG
- Token(TkfLPAREN)
+ tk_c = TkfLPAREN
else
@lex_state = EXPR_BEG
- Token(TkLPAREN)
+ tk_c = TkLPAREN
end
+ @indent_stack.push tk_c
+ tk = Token(tk_c)
end
@OP.def_rule("[]", proc{@lex_state == EXPR_FNAME}) do
@@ -566,29 +626,31 @@ class RubyLex
@OP.def_rule("[") do
@indent += 1
if @lex_state == EXPR_FNAME
- Token(TkfLBRACK)
+ tk_c = TkfLBRACK
else
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
- t = Token(TkLBRACK)
+ tk_c = TkLBRACK
elsif @lex_state == EXPR_ARG && @space_seen
- t = Token(TkLBRACK)
+ tk_c = TkLBRACK
else
- t = Token(TkfLBRACK)
+ tk_c = TkfLBRACK
end
@lex_state = EXPR_BEG
- t
end
+ @indent_stack.push tk_c
+ Token(tk_c)
end
@OP.def_rule("{") do
@indent += 1
if @lex_state != EXPR_END && @lex_state != EXPR_ARG
- t = Token(TkLBRACE)
+ tk_c = TkLBRACE
else
- t = Token(TkfLBRACE)
+ tk_c = TkfLBRACE
end
@lex_state = EXPR_BEG
- t
+ @indent_stack.push tk_c
+ Token(tk_c)
end
@OP.def_rule('\\') do
@@ -622,7 +684,7 @@ class RubyLex
end
@OP.def_rule('@') do
- if peek(0) =~ /[\w_]/
+ if peek(0) =~ /[\w_@]/
ungetc
identify_identifier
else
@@ -681,21 +743,32 @@ class RubyLex
def identify_identifier
token = ""
- token.concat getc if peek(0) =~ /[$@]/
+ if peek(0) =~ /[$@]/
+ token.concat(c = getc)
+ if c == "@" and peek(0) == "@"
+ token.concat getc
+ end
+ end
+
while (ch = getc) =~ /\w|_/
print ":", ch, ":" if RubyLex.debug?
token.concat ch
end
ungetc
- if ch == "!" or ch == "?"
+ if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
token.concat getc
end
- # fix token
+
+ # almost fix token
case token
when /^\$/
return Token(TkGVAR, token)
+ when /^\@\@/
+ @lex_state = EXPR_END
+ # p Token(TkCVAR, token)
+ return Token(TkCVAR, token)
when /^\@/
@lex_state = EXPR_END
return Token(TkIVAR, token)
@@ -717,9 +790,37 @@ class RubyLex
else
if @lex_state != EXPR_FNAME
if ENINDENT_CLAUSE.include?(token)
- @indent += 1
+ # check for ``class = val''.
+ valid = true
+ case token
+ when "class"
+ valid = false unless peek_match?(/^\s*(<<|\w|::)/)
+ when "def"
+ valid = false if peek_match?(/^\s*(([+-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/)
+# valid = false if peek_match?(/^\s*(([+-\/*&\|^]|<<|>>|\|\||\&\&)?=|\&\&|\|\|)/)
+ when "do"
+ valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&)/)
+ when *ENINDENT_CLAUSE
+ valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&|\|)/)
+ else
+ # no nothing
+ end
+ if valid
+ if token == "do"
+ if ![TkFOR, TkWHILE, TkUNTIL].include?(@indent_stack.last)
+ @indent += 1
+ @indent_stack.push token_c
+ end
+ else
+ @indent += 1
+ @indent_stack.push token_c
+ end
+# p @indent_stack
+ end
+
elsif DEINDENT_CLAUSE.include?(token)
@indent -= 1
+ @indent_stack.pop
end
@lex_state = trans[0]
else
@@ -752,6 +853,7 @@ class RubyLex
def identify_here_document
ch = getc
+# if lt = PERCENT_LTYPE[ch]
if ch == "-"
ch = getc
indent = true
@@ -819,9 +921,12 @@ class RubyLex
@lex_state = EXPR_END
if ch = getc
- if peek(0) == "x"
+ if /[xX]/ =~ peek(0)
+ ch = getc
+ match = /[0-9a-fA-F_]/
+ elsif /[bB]/ =~ peek(0)
ch = getc
- match = /[0-9a-f_]/
+ match = /[01_]/
else
match = /[0-7_]/
end
@@ -835,8 +940,8 @@ class RubyLex
end
type = TkINTEGER
- allow_point = TRUE
- allow_e = TRUE
+ allow_point = true
+ allow_e = true
while ch = getc
case ch
when /[0-9_]/
@@ -867,17 +972,25 @@ class RubyLex
@quoted = quoted
subtype = nil
begin
- while ch = getc
- if @quoted == ch
+ nest = 0
+ while ch = getc
+ if @quoted == ch and nest == 0
break
- elsif @ltype != "'" && @ltype != "]" and ch == "#"
+ elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#"
subtype = true
elsif ch == '\\' #'
read_escape
end
+ if PERCENT_PAREN.values.include?(@quoted)
+ if PERCENT_PAREN[ch] == @quoted
+ nest += 1
+ elsif ch == @quoted
+ nest -= 1
+ end
+ end
end
if @ltype == "/"
- if peek(0) =~ /i|o|n|e|s/
+ if peek(0) =~ /i|m|x|o|e|s|u|n/
getc
end
end
@@ -897,9 +1010,9 @@ class RubyLex
@ltype = "#"
while ch = getc
- if ch == "\\" #"
- read_escape
- end
+# if ch == "\\" #"
+# read_escape
+# end
if ch == "\n"
@ltype = nil
ungetc
@@ -943,7 +1056,7 @@ class RubyLex
ungetc
else
if (ch = getc) == "\\" #"
- read_escape(chrs)
+ read_escape
end
end
@@ -951,10 +1064,10 @@ class RubyLex
if ch == "C" and (ch = getc) != "-"
ungetc
elsif (ch = getc) == "\\" #"
- read_escape(chrs)
+ read_escape
end
else
- # other characters
+ # other characters
end
end
end
diff --git a/lib/irb/ruby-token.rb b/lib/irb/ruby-token.rb
index 1532dc78eb..49b97e9c54 100644
--- a/lib/irb/ruby-token.rb
+++ b/lib/irb/ruby-token.rb
@@ -1,9 +1,9 @@
#
-# ruby-token.rb - ruby tokens
-# $Release Version: 0.6$
+# irb/ruby-token.rb - ruby tokens
+# $Release Version: 0.9$
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
#
@@ -17,6 +17,11 @@ module RubyToken
EXPR_FNAME = :EXPR_FNAME
EXPR_DOT = :EXPR_DOT
EXPR_CLASS = :EXPR_CLASS
+
+ # for ruby 1.4X
+ if !defined?(Symbol)
+ Symbol = Integer
+ end
class Token
def initialize(seek, line_no, char_no)
@@ -150,6 +155,7 @@ module RubyToken
[:TkIDENTIFIER, TkId],
[:TkFID, TkId],
[:TkGVAR, TkId],
+ [:TkCVAR, TkId],
[:TkIVAR, TkId],
[:TkCONSTANT, TkId],
@@ -158,6 +164,7 @@ module RubyToken
[:TkSTRING, TkVal],
[:TkXSTRING, TkVal],
[:TkREGEXP, TkVal],
+ [:TkSYMBOL, TkVal],
[:TkDSTRING, TkNode],
[:TkDXSTRING, TkNode],
@@ -213,7 +220,7 @@ module RubyToken
[:TkBACKQUOTE, TkOp, "`"],
- [:TkASSGIN, Token, "="],
+ [:TkASSIGN, Token, "="],
[:TkDOT, Token, "."],
[:TkLPAREN, Token, "("], #(exp)
[:TkLBRACK, Token, "["], #[arry]
@@ -241,7 +248,7 @@ module RubyToken
TkSymbol2Token = {}
def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
- token_n = token_n.id2name unless token_n.kind_of?(String)
+ token_n = token_n.id2name if token_n.kind_of?(Symbol)
if RubyToken.const_defined?(token_n)
IRB.fail AlreadyDefinedToken, token_n
end
diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb
index 85aa92bd73..c0943f6e33 100644
--- a/lib/irb/slex.rb
+++ b/lib/irb/slex.rb
@@ -1,9 +1,9 @@
#
-# irb-slex.rb - symple lex analizer
-# $Release Version: 0.6$
+# irb/slex.rb - symple lex analizer
+# $Release Version: 0.9$
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nippon Rational Inc.)
+# by Keiju ISHITSUKA(keiju@ishituska.com)
#
# --
#
@@ -20,7 +20,7 @@ class SLex
def_exception :ErrNodeAlreadyExists, "node already exists"
class << self
- attr :debug_level, TRUE
+ attr_accessor :debug_level
def debug?
debug_level > 0
end
@@ -31,22 +31,22 @@ class SLex
@head = Node.new("")
end
- def def_rule(token, preproc = nil, postproc = nil)
+ def def_rule(token, preproc = nil, postproc = nil, &block)
# print node.inspect, "\n" if SLex.debug?
- postproc = proc if iterator?
+ postproc = block if block_given?
node = create(token, preproc, postproc)
end
- def def_rules(*tokens)
- if iterator?
- p = proc
+ def def_rules(*tokens, &block)
+ if block_given?
+ p = block
end
for token in tokens
def_rule(token, nil, p)
end
end
- def preporc(token, proc)
+ def preproc(token, proc)
node = search(token)
node.preproc=proc
end
@@ -68,8 +68,7 @@ class SLex
case token
when Array
when String
- token = token.split(//)
- match(token.split(//))
+ return match(token.split(//))
else
return @head.match_io(token)
end
@@ -88,16 +87,16 @@ class SLex
#
#----------------------------------------------------------------------
class Node
- # if postproc no exist, this node is abstract node.
- # if postproc isn't nil, this node is real node.
+ # if postproc is nil, this node is an abstract node.
+ # if postproc is non-nil, this node is a real node.
def initialize(preproc = nil, postproc = nil)
@Tree = {}
@preproc = preproc
@postproc = postproc
end
- attr :preproc, TRUE
- attr :postproc, TRUE
+ attr_accessor :preproc
+ attr_accessor :postproc
def search(chrs, opt = nil)
return self if chrs.empty?
@@ -120,7 +119,7 @@ class SLex
p node
SLex.fail ErrNodeAlreadyExists
else
- print "Warn: change abstruct node to real node\n" if SLex.debug?
+ print "Warn: change abstract node to real node\n" if SLex.debug?
@preproc = preproc
@postproc = postproc
end
@@ -137,7 +136,7 @@ class SLex
p chrs
SLex.fail ErrNodeAlreadyExists
else
- print "Warn: change abstruct node to real node\n" if SLex.debug?
+ print "Warn: change abstract node to real node\n" if SLex.debug?
node.preproc = preproc
node.postproc = postproc
end
@@ -159,8 +158,8 @@ class SLex
#
# chrs: String
# character array
- # io It must have getc()/ungetc(), and ungetc() can be
- # called any number of times.
+ # io must have getc()/ungetc(); and ungetc() must be
+ # able to be called arbitrary number of times.
#
def match(chrs, op = "")
print "match>: ", chrs, "op:", op, "\n" if SLex.debug?
@@ -265,7 +264,7 @@ if $0 == __FILE__
print "0: ", tr.inspect, "\n"
tr.def_rule("=") {print "=\n"}
print "1: ", tr.inspect, "\n"
- tr.def_rule("==", proc{FALSE}) {print "==\n"}
+ tr.def_rule("==", proc{false}) {print "==\n"}
print "2: ", tr.inspect, "\n"
print "case 1:\n"
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
index 7179d1c163..a9e37f7e7b 100644
--- a/lib/irb/version.rb
+++ b/lib/irb/version.rb
@@ -1,9 +1,9 @@
#
-# version.rb - irb version definition file
-# $Release Version: 0.6.1$
+# irb/version.rb - irb version definition file
+# $Release Version: 0.9$
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
# --
#
@@ -11,6 +11,6 @@
#
module IRB
- @RELEASE_VERSION = "0.6.1"
- @LAST_UPDATE_DATE = "99/09/16"
+ @RELEASE_VERSION = "0.9"
+ @LAST_UPDATE_DATE = "02/07/03"
end
diff --git a/lib/irb/workspace-binding-2.rb b/lib/irb/workspace-binding-2.rb
deleted file mode 100644
index d005296f6e..0000000000
--- a/lib/irb/workspace-binding-2.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# bind.rb -
-# $Release Version: $
-# $Revision$
-# $Date$
-# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
-#
-# --
-#
-#
-#
-
-while true
- IRB::BINDING_QUEUE.push b = binding
-end
diff --git a/lib/irb/workspace-binding.rb b/lib/irb/workspace-binding.rb
deleted file mode 100644
index d58088d9dd..0000000000
--- a/lib/irb/workspace-binding.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# workspace-binding.rb -
-# $Release Version: $
-# $Revision$
-# $Date$
-# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
-#
-# --
-#
-#
-#
-
-
-module IRB
- # create new workspace.
- def IRB.workspace_binding(*main)
- if @CONF[:SINGLE_IRB]
- bind = TOPLEVEL_BINDING
- else
- case @CONF[:CONTEXT_MODE]
- when 0
- bind = eval("proc{binding}.call",
- TOPLEVEL_BINDING,
- "(irb_local_binding)",
- 1)
- when 1
- require "tempfile"
- f = Tempfile.open("irb-binding")
- f.print <<EOF
- $binding = binding
-EOF
- f.close
- load f.path
- bind = $binding
-
- when 2
- unless defined? BINDING_QUEUE
- require "thread"
-
- IRB.const_set("BINDING_QUEUE", SizedQueue.new(1))
- Thread.abort_on_exception = true
- Thread.start do
- eval "require \"irb/workspace-binding-2\"", TOPLEVEL_BINDING, __FILE__, __LINE__
- end
- Thread.pass
-
- end
-
- bind = BINDING_QUEUE.pop
-
- when 3
- bind = eval("def irb_binding; binding; end; irb_binding",
- TOPLEVEL_BINDING,
- __FILE__,
- __LINE__ - 3)
- end
- end
- unless main.empty?
- @CONF[:__MAIN__] = main[0]
- case main[0]
- when Module
- bind = eval("IRB.conf[:__MAIN__].module_eval('binding')", bind)
- else
- begin
- bind = eval("IRB.conf[:__MAIN__].instance_eval('binding')", bind)
- rescue TypeError
- IRB.fail CanNotChangeBinding, main[0].inspect
- end
- end
- end
- eval("_=nil", bind)
- bind
- end
-
- def IRB.delete_caller
- end
-end
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
new file mode 100644
index 0000000000..3b099b1baa
--- /dev/null
+++ b/lib/irb/workspace.rb
@@ -0,0 +1,107 @@
+#
+# irb/workspace-binding.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+module IRB
+ class WorkSpace
+ # create new workspace. set self to main if specified, otherwise
+ # inherit main from TOPLEVEL_BINDING.
+ def initialize(*main)
+ if main[0].kind_of?(Binding)
+ @binding = main.shift
+ elsif IRB.conf[:SINGLE_IRB]
+ @binding = TOPLEVEL_BINDING
+ else
+ case IRB.conf[:CONTEXT_MODE]
+ when 0 # binding in proc on TOPLEVEL_BINDING
+ @binding = eval("proc{binding}.call",
+ TOPLEVEL_BINDING,
+ __FILE__,
+ __LINE__)
+ when 1 # binding in loaded file
+ require "tempfile"
+ f = Tempfile.open("irb-binding")
+ f.print <<EOF
+ $binding = binding
+EOF
+ f.close
+ load f.path
+ @binding = $binding
+
+ when 2 # binding in loaded file(thread use)
+ unless defined? BINDING_QUEUE
+ require "thread"
+
+ IRB.const_set("BINDING_QUEUE", SizedQueue.new(1))
+ Thread.abort_on_exception = true
+ Thread.start do
+ eval "require \"irb/ws-for-case-2\"", TOPLEVEL_BINDING, __FILE__, __LINE__
+ end
+ Thread.pass
+ end
+ @binding = BINDING_QUEUE.pop
+
+ when 3 # binging in function on TOPLEVEL_BINDING(default)
+ @binding = eval("def irb_binding; binding; end; irb_binding",
+ TOPLEVEL_BINDING,
+ __FILE__,
+ __LINE__ - 3)
+ end
+ end
+ if main.empty?
+ @main = eval("self", @binding)
+ else
+ @main = main[0]
+ IRB.conf[:__MAIN__] = @main
+ case @main
+ when Module
+ @binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
+ else
+ begin
+ @binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
+ rescue TypeError
+ IRB.fail CantChangeBinding, @main.inspect
+ end
+ end
+ end
+ eval("_=nil", @binding)
+ end
+
+ attr_reader :binding
+ attr_reader :main
+
+ def evaluate(context, statements, file = __FILE__, line = __LINE__)
+ eval(statements, @binding, file, line)
+ end
+
+ # error message manipulator
+ def filter_backtrace(bt)
+ case IRB.conf[:CONTEXT_MODE]
+ when 0
+ return nil if bt =~ /\(irb_local_binding\)/
+ when 1
+ if(bt =~ %r!/tmp/irb-binding! or
+ bt =~ %r!irb/.*\.rb! or
+ bt =~ /irb\.rb/)
+ return nil
+ end
+ when 2
+ return nil if bt =~ /irb\/.*\.rb/
+ when 3
+ return nil if bt =~ /irb\/.*\.rb/
+ bt.sub!(/:\s*in `irb_binding'/){""}
+ end
+ bt
+ end
+
+ def IRB.delete_caller
+ end
+ end
+end
diff --git a/lib/irb/ws-for-case-2.rb b/lib/irb/ws-for-case-2.rb
new file mode 100644
index 0000000000..1c58fb7dda
--- /dev/null
+++ b/lib/irb/ws-for-case-2.rb
@@ -0,0 +1,15 @@
+#
+# irb/ws-for-case-2.rb -
+# $Release Version: 0.9$
+# $Revision$
+# $Date$
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+#
+# --
+#
+#
+#
+
+while true
+ IRB::BINDING_QUEUE.push b = binding
+end
diff --git a/lib/irb/xmp.rb b/lib/irb/xmp.rb
index fc745a2757..4bcc2ca22f 100644
--- a/lib/irb/xmp.rb
+++ b/lib/irb/xmp.rb
@@ -1,6 +1,6 @@
#
# xmp.rb - irb version of gotoken xmp
-# $Release Version: 0.6$
+# $Release Version: 0.9$
# $Revision$
# $Date$
# by Keiju ISHITSUKA(Nippon Rational Inc.)
@@ -10,21 +10,23 @@
#
#
-require "irb/irb"
+require "irb"
require "irb/frame"
class XMP
@RCS_ID='-$Id$-'
def initialize(bind = nil)
+ IRB.init_config(nil)
#IRB.parse_opts
#IRB.load_modules
+ IRB.conf[:PROMPT_MODE] = :XMP
+
bind = IRB::Frame.top(1) unless bind
- main = eval("self", bind)
+ ws = IRB::WorkSpace.new(bind)
@io = StringInputMethod.new
- @irb = IRB::Irb.new(main, bind, @io)
- @irb.context.prompt_mode = :XMP
+ @irb = IRB::Irb.new(ws, @io)
@irb.context.ignore_sigint = false
# IRB.conf[:IRB_RC].call(@irb.context) if IRB.conf[:IRB_RC]
diff --git a/lib/jcode.rb b/lib/jcode.rb
index 7175c1b4b6..8cd770be26 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -1,17 +1,17 @@
# jcode.rb - ruby code to handle japanese (EUC/SJIS) string
if $VERBOSE && $KCODE == "NONE"
- STDERR.puts "Warning: $KCODE is NONE."
+ warn "Warning: $KCODE is NONE."
end
$vsave, $VERBOSE = $VERBOSE, false
class String
- printf STDERR, "feel free for some warnings:\n" if $VERBOSE
+ warn "feel free for some warnings:\n" if $VERBOSE
def _regex_quote(str)
- str.gsub(/[][.\\|*?+{}()]/){|s|
- if s == "\\" then "\\\\" else "\\\\#{s}" end
- }
+ str.gsub(/(\\[\[\]\-\\])|\\(.)|([\[\]\\])/) do
+ $1 || $2 || '\\' + $3
+ end
end
private :_regex_quote
@@ -19,9 +19,9 @@ class String
PATTERN_EUC = '[\xa1-\xfe][\xa1-\xfe]'
PATTERN_UTF8 = '[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]'
- RE_SJIS = Regexp.new(PATTERN_SJIS, 'n')
- RE_EUC = Regexp.new(PATTERN_EUC, 'n')
- RE_UTF8 = Regexp.new(PATTERN_UTF8, 'n')
+ RE_SJIS = Regexp.new(PATTERN_SJIS, 0, 'n')
+ RE_EUC = Regexp.new(PATTERN_EUC, 0, 'n')
+ RE_UTF8 = Regexp.new(PATTERN_UTF8, 0, 'n')
SUCC = {}
SUCC['s'] = Hash.new(1)
@@ -59,13 +59,13 @@ class String
def end_regexp
case $KCODE[0]
when ?s, ?S
- /#{PATTERN_SJIS}$/o
+ /#{PATTERN_SJIS}$/on
when ?e, ?E
- /#{PATTERN_EUC}$/o
+ /#{PATTERN_EUC}$/on
when ?u, ?U
- /#{PATTERN_UTF8}$/o
+ /#{PATTERN_UTF8}$/on
else
- /.$/o
+ /.$/on
end
end
@@ -97,15 +97,18 @@ class String
def _expand_ch str
a = []
- str.scan(/(.)-(.)|(.)/m) do |r|
- if $3
- a.push $3
- elsif $1.length != $2.length
- next
- elsif $1.length == 1
- $1[0].upto($2[0]) { |c| a.push c.chr }
+ str.scan(/(?:\\(.)|([^\\]))-(?:\\(.)|([^\\]))|(?:\\(.)|(.))/m) do
+ from = $1 || $2
+ to = $3 || $4
+ one = $5 || $6
+ if one
+ a.push one
+ elsif from.length != to.length
+ next
+ elsif from.length == 1
+ from[0].upto(to[0]) { |c| a.push c.chr }
else
- $1.upto($2) { |c| a.push c }
+ from.upto(to) { |c| a.push c }
end
end
a
@@ -127,14 +130,15 @@ class String
public
def tr!(from, to)
- return self.delete!(from) if to.length == 0
+ return nil if from == ""
+ return self.delete!(from) if to == ""
pattern = TrPatternCache[from] ||= /[#{_regex_quote(from)}]/
if from[0] == ?^
last = /.$/.match(to)[0]
self.gsub!(pattern, last)
else
- h = HashCache[from + "::" + to] ||= expand_ch_hash(from, to)
+ h = HashCache[from + "1-0" + to] ||= expand_ch_hash(from, to)
self.gsub!(pattern) do |c| h[c] end
end
end
@@ -144,6 +148,7 @@ class String
end
def delete!(del)
+ return nil if del == ""
self.gsub!(DeletePatternCache[del] ||= /[#{_regex_quote(del)}]+/, '')
end
@@ -152,6 +157,7 @@ class String
end
def squeeze!(del=nil)
+ return nil if del == ""
pattern =
if del
SqueezePatternCache[del] ||= /([#{_regex_quote(del)}])\1+/
@@ -168,12 +174,12 @@ class String
def tr_s!(from, to)
return self.delete!(from) if to.length == 0
- pattern = SqueezePatternCache[from] ||= /([#{_regex_quote(from)}])\1+"/
+ pattern = SqueezePatternCache[from] ||= /([#{_regex_quote(from)}])\1+/
if from[0] == ?^
last = /.$/.match(to)[0]
self.gsub!(pattern, last)
else
- h = HashCache[from + "::" + to] ||= expand_ch_hash(from, to)
+ h = HashCache[from + "1-0" + to] ||= expand_ch_hash(from, to)
self.gsub!(pattern) do h[$1] end
end
end
diff --git a/lib/logger.rb b/lib/logger.rb
new file mode 100644
index 0000000000..363e9774b4
--- /dev/null
+++ b/lib/logger.rb
@@ -0,0 +1,728 @@
+#
+# = logger.rb
+#
+# Simple logging utility.
+#
+# Author:: NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+# Documentation:: NAKAMURA, Hiroshi and Gavin Sinclair
+# License::
+# You can redistribute it and/or modify it under the same terms of Ruby's
+# license; either the dual license version in 2003, or any later version.
+# Revision:: $Id$
+#
+# See Logger for documentation.
+#
+
+
+#
+# == Description
+#
+# The Logger class provides a simple but sophisticated logging utility that
+# anyone can use because it's included in the Ruby 1.8.x standard library.
+# For more advanced logging, see the "Log4r" package on the RAA.
+#
+# The HOWTOs below give a code-based overview of Logger's usage, but the basic
+# concept is as follows. You create a Logger object (output to a file or
+# elsewhere), and use it to log messages. The messages will have varying
+# levels (+info+, +error+, etc), reflecting their varying importance. The
+# levels, and their meanings, are:
+#
+# +FATAL+:: an unhandleable error that results in a program crash
+# +ERROR+:: a handleable error condition
+# +WARN+:: a warning
+# +INFO+:: generic (useful) information about system operation
+# +DEBUG+:: low-level information for developers
+#
+# So each message has a level, and the Logger itself has a level, which acts
+# as a filter, so you can control the amount of information emitted from the
+# logger without having to remove actual messages.
+#
+# For instance, in a production system, you may have your logger(s) set to
+# +INFO+ (or +WARN+ if you don't want the log files growing large with
+# repetitive information). When you are developing it, though, you probably
+# want to know about the program's internal state, and would set them to
+# +DEBUG+.
+#
+# === Example
+#
+# A simple example demonstrates the above explanation:
+#
+# log = Logger.new(STDOUT)
+# log.level = Logger::WARN
+#
+# log.debug("Created logger")
+# log.info("Program started")
+# log.warn("Nothing to do!")
+#
+# begin
+# File.each_line(path) do |line|
+# unless line =~ /^(\w+) = (.*)$/
+# log.error("Line in wrong format: #{line}")
+# end
+# end
+# rescue => err
+# log.fatal("Caught exception; exiting")
+# log.fatal(err)
+# end
+#
+# Because the Logger's level is set to +WARN+, only the warning, error, and
+# fatal messages are recorded. The debug and info messages are silently
+# discarded.
+#
+# === Features
+#
+# There are several interesting features that Logger provides, like
+# auto-rolling of log files, setting the format of log messages, and
+# specifying a program name in conjunction with the message. The next section
+# shows you how to achieve these things.
+#
+# See http://raa.ruby-lang.org/list.rhtml?name=log4r for Log4r, which contains
+# many advanced features like file-based configuration, a wide range of
+# logging targets, simultaneous logging, and hierarchical logging.
+#
+#
+# == HOWTOs
+#
+# === How to create a logger
+#
+# The options below give you various choices, in more or less increasing
+# complexity.
+#
+# 1. Create a logger which logs messages to STDERR/STDOUT.
+#
+# logger = Logger.new(STDERR)
+# logger = Logger.new(STDOUT)
+#
+# 2. Create a logger for the file which has the specified name.
+#
+# logger = Logger.new('logfile.log')
+#
+# 3. Create a logger for the specified file.
+#
+# file = File.open('foo.log', File::WRONLY | File::APPEND)
+# # To create new (and to remove old) logfile, add File::CREAT like;
+# # file = open('foo.log', File::WRONLY | File::APPEND | File::CREAT)
+# logger = Logger.new(file)
+#
+# 4. Create a logger which ages logfile once it reaches a certain size. Leave
+# 10 "old log files" and each file is about 1,024,000 bytes.
+#
+# logger = Logger.new('foo.log', 10, 1024000)
+#
+# 5. Create a logger which ages logfile daily/weekly/monthly.
+#
+# logger = Logger.new('foo.log', 'daily')
+# logger = Logger.new('foo.log', 'weekly')
+# logger = Logger.new('foo.log', 'monthly')
+#
+# === How to log a message
+#
+# Notice the different methods (+fatal+, +error+, +info+) being used to log
+# messages of various levels. Other methods in this family are +warn+ and
+# +debug+. +add+ is used below to log a message of an arbitrary (perhaps
+# dynamic) level.
+#
+# 1. Message in block.
+#
+# logger.fatal { "Argument 'foo' not given." }
+#
+# 2. Message as a string.
+#
+# logger.error "Argument #{ @foo } mismatch."
+#
+# 3. With progname.
+#
+# logger.info('initialize') { "Initializing..." }
+#
+# 4. With severity.
+#
+# logger.add(Logger::FATAL) { 'Fatal error!' }
+#
+# === How to close a logger
+#
+# logger.close
+#
+# === Setting severity threshold
+#
+# 1. Original interface.
+#
+# logger.level = Logger::WARN
+#
+# 2. Log4r (somewhat) compatible interface.
+#
+# logger.level = Logger::INFO
+#
+# DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
+#
+#
+# == Format
+#
+# Log messages are rendered in the output stream in a certain format. The
+# default format and a sample are shown below:
+#
+# Log format:
+# SeverityID, [Date Time mSec #pid] SeverityLabel -- ProgName: message
+#
+# Log sample:
+# I, [Wed Mar 03 02:34:24 JST 1999 895701 #19074] INFO -- Main: info.
+#
+# You may change the date and time format in this manner:
+#
+# logger.datetime_format = "%Y-%m-%d %H:%M:%S"
+# # e.g. "2004-01-03 00:54:26"
+#
+# There is currently no supported way to change the overall format, but you may
+# have some luck hacking the Format constant.
+#
+class Logger
+ /: (\S+),v (\S+)/ =~ %q$Id$
+ ProgName = "#{$1}/#{$2}"
+
+ class Error < RuntimeError; end
+ class ShiftingError < Error; end
+
+ # Logging severity.
+ module Severity
+ DEBUG = 0
+ INFO = 1
+ WARN = 2
+ ERROR = 3
+ FATAL = 4
+ UNKNOWN = 5
+ end
+ include Severity
+
+ # Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
+ attr_accessor :level
+
+ # Logging program name.
+ attr_accessor :progname
+
+ # Logging date-time format (string passed to +strftime+).
+ attr_accessor :datetime_format
+
+ alias sev_threshold level
+ alias sev_threshold= level=
+
+ # Returns +true+ iff the current severity level allows for the printing of
+ # +DEBUG+ messages.
+ def debug?; @level <= DEBUG; end
+
+ # Returns +true+ iff the current severity level allows for the printing of
+ # +INFO+ messages.
+ def info?; @level <= INFO; end
+
+ # Returns +true+ iff the current severity level allows for the printing of
+ # +WARN+ messages.
+ def warn?; @level <= WARN; end
+
+ # Returns +true+ iff the current severity level allows for the printing of
+ # +ERROR+ messages.
+ def error?; @level <= ERROR; end
+
+ # Returns +true+ iff the current severity level allows for the printing of
+ # +FATAL+ messages.
+ def fatal?; @level <= FATAL; end
+
+ #
+ # === Synopsis
+ #
+ # Logger.new(name, shift_age = 7, shift_size = 1048576)
+ # Logger.new(name, shift_age = 'weekly')
+ #
+ # === Args
+ #
+ # +logdev+::
+ # The log device. This is a filename (String) or IO object (typically
+ # +STDOUT+, +STDERR+, or an open file).
+ # +shift_age+::
+ # Number of old log files to keep, *or* frequency of rotation (+daily+,
+ # +weekly+ or +monthly+).
+ # +shift_size+::
+ # Maximum logfile size (only applies when +shift_age+ is a number).
+ #
+ # === Description
+ #
+ # Create an instance. See Logger::LogDevice.new for more information if
+ # required.
+ #
+ def initialize(logdev, shift_age = 0, shift_size = 1048576)
+ @logdev = nil
+ @progname = nil
+ @level = DEBUG
+ @datetime_format = nil
+ @logdev = nil
+ if logdev
+ @logdev = LogDevice.new(logdev, :shift_age => shift_age, :shift_size => shift_size)
+ end
+ end
+
+ #
+ # === Synopsis
+ #
+ # Logger#add(severity, message = nil, progname = nil) { ... }
+ #
+ # === Args
+ #
+ # +severity+::
+ # Severity. Constants are defined in Logger namespace: +DEBUG+, +INFO+,
+ # +WARN+, +ERROR+, +FATAL+, or +UNKNOWN+.
+ # +message+::
+ # The log message. A String or Exception.
+ # +progname+::
+ # Program name string. Can be omitted. Treated as a message if no +message+ and
+ # +block+ are given.
+ # +block+::
+ # Can be omitted. Called to get a message string if +message+ is nil.
+ #
+ # === Return
+ #
+ # +true+ if successful, +false+ otherwise.
+ #
+ # When the given severity is not high enough (for this particular logger), log
+ # no message, and return +true+.
+ #
+ # === Description
+ #
+ # Log a message if the given severity is high enough. This is the generic
+ # logging method. Users will be more inclined to use #debug, #info, #warn,
+ # #error, and #fatal.
+ #
+ # <b>Message format</b>: +message+ can be any object, but it has to be
+ # converted to a String in order to log it. Generally, +inspect+ is used
+ # if the given object is not a String.
+ # A special case is an +Exception+ object, which will be printed in detail,
+ # including message, class, and backtrace. See #msg2str for the
+ # implementation if required.
+ #
+ # === Bugs
+ #
+ # * Logfile is not locked.
+ # * Append open does not need to lock file.
+ # * But on the OS which supports multi I/O, records possibly be mixed.
+ #
+ def add(severity, message = nil, progname = nil, &block)
+ severity ||= UNKNOWN
+ if @logdev.nil? or severity < @level
+ return true
+ end
+ progname ||= @progname
+ if message.nil?
+ if block_given?
+ message = yield
+ else
+ message = progname
+ progname = @progname
+ end
+ end
+ @logdev.write(
+ format_message(
+ format_severity(severity),
+ format_datetime(Time.now),
+ msg2str(message),
+ progname
+ )
+ )
+ true
+ end
+ alias log add
+
+ #
+ # Dump given message to the log device without any formatting. If no log
+ # device exists, return +nil+.
+ #
+ def <<(msg)
+ unless @logdev.nil?
+ @logdev.write(msg)
+ end
+ end
+
+ #
+ # Log a +DEBUG+ message.
+ #
+ # See #info for more information.
+ #
+ def debug(progname = nil, &block)
+ add(DEBUG, nil, progname, &block)
+ end
+
+ #
+ # Log an +INFO+ message.
+ #
+ # The message can come either from the +progname+ argument or the +block+. If
+ # both are provided, then the +block+ is used as the message, and +progname+
+ # is used as the program name.
+ #
+ # === Examples
+ #
+ # logger.info("MainApp") { "Received connection from #{ip}" }
+ # # ...
+ # logger.info "Waiting for input from user"
+ # # ...
+ # logger.info { "User typed #{input}" }
+ #
+ # You'll probably stick to the second form above, unless you want to provide a
+ # program name (which you can do with <tt>Logger#progname=</tt> as well).
+ #
+ # === Return
+ #
+ # See #add.
+ #
+ def info(progname = nil, &block)
+ add(INFO, nil, progname, &block)
+ end
+
+ #
+ # Log a +WARN+ message.
+ #
+ # See #info for more information.
+ #
+ def warn(progname = nil, &block)
+ add(WARN, nil, progname, &block)
+ end
+
+ #
+ # Log an +ERROR+ message.
+ #
+ # See #info for more information.
+ #
+ def error(progname = nil, &block)
+ add(ERROR, nil, progname, &block)
+ end
+
+ #
+ # Log a +FATAL+ message.
+ #
+ # See #info for more information.
+ #
+ def fatal(progname = nil, &block)
+ add(FATAL, nil, progname, &block)
+ end
+
+ #
+ # Log an +UNKNOWN+ message. This will be printed no matter what the logger
+ # level.
+ #
+ # See #info for more information.
+ #
+ def unknown(progname = nil, &block)
+ add(UNKNOWN, nil, progname, &block)
+ end
+
+ #
+ # Close the logging device.
+ #
+ def close
+ @logdev.close if @logdev
+ end
+
+private
+
+ # Severity label for logging. (max 5 char)
+ SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY)
+
+ def format_severity(severity)
+ SEV_LABEL[severity] || 'ANY'
+ end
+
+ def format_datetime(datetime)
+ if @datetime_format.nil?
+ datetime.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % datetime.usec
+ else
+ datetime.strftime(@datetime_format)
+ end
+ end
+
+ Format = "%s, [%s#%d] %5s -- %s: %s\n"
+ def format_message(severity, timestamp, msg, progname)
+ Format % [severity[0..0], timestamp, $$, severity, progname, msg]
+ end
+
+ def msg2str(msg)
+ case msg
+ when ::String
+ msg
+ when ::Exception
+ "#{ msg.message } (#{ msg.class })\n" << (msg.backtrace || []).join("\n")
+ else
+ msg.inspect
+ end
+ end
+
+
+ #
+ # LogDevice -- Logging device.
+ #
+ class LogDevice
+ attr_reader :dev
+ attr_reader :filename
+
+ #
+ # == Synopsis
+ #
+ # Logger::LogDev.new(name, :shift_age => 'daily|weekly|monthly')
+ # Logger::LogDev.new(name, :shift_age => 10, :shift_size => 1024*1024)
+ #
+ # == Args
+ #
+ # +name+::
+ # A String (representing a filename) or an IO object (actually, anything
+ # that responds to +write+ and +close+). If a filename is given, then
+ # that file is opened for writing (and appending if it already exists),
+ # with +sync+ set to +true+.
+ # +opts+::
+ # Contains optional arguments for rolling ("shifting") the log file.
+ # <tt>:shift_age</tt> is either a description (e.g. 'daily'), or an
+ # integer number of log files to keep. <tt>shift_size</tt> is the maximum
+ # size of the log file, and is only significant is a number is given for
+ # <tt>shift_age</tt>.
+ #
+ # These arguments are only relevant if a filename is provided for the
+ # first argument.
+ #
+ # == Description
+ #
+ # Creates a LogDevice object, which is the target for log messages. Rolling
+ # of log files is supported (only if a filename is given; you can't roll an
+ # IO object). The beginning of each file created by this class is tagged
+ # with a header message.
+ #
+ # This class is unlikely to be used directly; it is a backend for Logger.
+ #
+ def initialize(log = nil, opt = {})
+ @dev = @filename = @shift_age = @shift_size = nil
+ if log.respond_to?(:write) and log.respond_to?(:close)
+ @dev = log
+ else
+ @dev = open_logfile(log)
+ @dev.sync = true
+ @filename = log
+ @shift_age = opt[:shift_age] || 7
+ @shift_size = opt[:shift_size] || 1048576
+ end
+ end
+
+ #
+ # Log a message. If needed, the log file is rolled and the new file is
+ # prepared. Log device is not locked. Append open does not need to lock
+ # file but on an OS which supports multi I/O, records could possibly be
+ # mixed.
+ #
+ def write(message)
+ if shift_log?
+ begin
+ shift_log
+ rescue
+ raise Logger::ShiftingError.new("Shifting failed. #{$!}")
+ end
+ end
+
+ @dev.write(message)
+ end
+
+ #
+ # Close the logging device.
+ #
+ def close
+ @dev.close
+ end
+
+ private
+
+ def open_logfile(filename)
+ if (FileTest.exist?(filename))
+ open(filename, (File::WRONLY | File::APPEND))
+ else
+ create_logfile(filename)
+ end
+ end
+
+ def create_logfile(filename)
+ logdev = open(filename, (File::WRONLY | File::APPEND | File::CREAT))
+ logdev.sync = true
+ add_log_header(logdev)
+ logdev
+ end
+
+ def add_log_header(file)
+ file.write(
+ "# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName]
+ )
+ end
+
+ SiD = 24 * 60 * 60
+
+ def shift_log?
+ if !@shift_age or !@dev.respond_to?(:stat)
+ return false
+ end
+ if (@shift_age.is_a?(Integer))
+ # Note: always returns false if '0'.
+ return (@filename && (@shift_age > 0) && (@dev.stat.size > @shift_size))
+ else
+ now = Time.now
+ limit_time = case @shift_age
+ when /^daily$/
+ eod(now - 1 * SiD)
+ when /^weekly$/
+ eod(now - ((now.wday + 1) * SiD))
+ when /^monthly$/
+ eod(now - now.mday * SiD)
+ else
+ now
+ end
+ return (@dev.stat.mtime <= limit_time)
+ end
+ end
+
+ def shift_log
+ # At first, close the device if opened.
+ if @dev
+ @dev.close
+ @dev = nil
+ end
+ if (@shift_age.is_a?(Integer))
+ (@shift_age-3).downto(0) do |i|
+ if (FileTest.exist?("#{@filename}.#{i}"))
+ File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}")
+ end
+ end
+ File.rename("#{@filename}", "#{@filename}.0")
+ else
+ now = Time.now
+ postfix_time = case @shift_age
+ when /^daily$/
+ eod(now - 1 * SiD)
+ when /^weekly$/
+ eod(now - ((now.wday + 1) * SiD))
+ when /^monthly$/
+ eod(now - now.mday * SiD)
+ else
+ now
+ end
+ postfix = postfix_time.strftime("%Y%m%d") # YYYYMMDD
+ age_file = "#{@filename}.#{postfix}"
+ if (FileTest.exist?(age_file))
+ raise RuntimeError.new("'#{ age_file }' already exists.")
+ end
+ File.rename("#{@filename}", age_file)
+ end
+
+ @dev = create_logfile(@filename)
+ return true
+ end
+
+ def eod(t)
+ Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
+ end
+ end
+
+
+ #
+ # == Description
+ #
+ # Application -- Add logging support to your application.
+ #
+ # == Usage
+ #
+ # 1. Define your application class as a sub-class of this class.
+ # 2. Override 'run' method in your class to do many things.
+ # 3. Instantiate it and invoke 'start'.
+ #
+ # == Example
+ #
+ # class FooApp < Application
+ # def initialize(foo_app, application_specific, arguments)
+ # super('FooApp') # Name of the application.
+ # end
+ #
+ # def run
+ # ...
+ # log(WARN, 'warning', 'my_method1')
+ # ...
+ # @log.error('my_method2') { 'Error!' }
+ # ...
+ # end
+ # end
+ #
+ # status = FooApp.new(....).start
+ #
+ class Application
+ include Logger::Severity
+
+ attr_reader :appname
+ attr_reader :logdev
+
+ #
+ # == Synopsis
+ #
+ # Application.new(appname = '')
+ #
+ # == Args
+ #
+ # +appname+:: Name of the application.
+ #
+ # == Description
+ #
+ # Create an instance. Log device is +STDERR+ by default. This can be
+ # changed with #set_log.
+ #
+ def initialize(appname = nil)
+ @appname = appname
+ @log = Logger.new(STDERR)
+ @log.progname = @appname
+ @level = @log.level
+ end
+
+ #
+ # Start the application. Return the status code.
+ #
+ def start
+ status = -1
+ begin
+ log(INFO, "Start of #{ @appname }.")
+ status = run
+ rescue
+ log(FATAL, "Detected an exception. Stopping ... #{$!} (#{$!.class})\n" << $@.join("\n"))
+ ensure
+ log(INFO, "End of #{ @appname }. (status: #{ status.to_s })")
+ end
+ status
+ end
+
+ #
+ # Sets the log device for this application. See the classes Logger and
+ # Logger::LogDevice for an explanation of the arguments.
+ #
+ def set_log(logdev, shift_age = 0, shift_size = 1024000)
+ @log = Logger.new(logdev, shift_age, shift_size)
+ @log.progname = @appname
+ @log.level = @level
+ end
+
+ def log=(logdev)
+ set_log(logdev)
+ end
+
+ #
+ # Set the logging threshold, just like <tt>Logger#level=</tt>.
+ #
+ def level=(level)
+ @level = level
+ @log.level = @level
+ end
+
+ #
+ # See Logger#add. This application's +appname+ is used.
+ #
+ def log(severity, message = nil, &block)
+ @log.add(severity, message, @appname, &block) if @log
+ end
+
+ private
+
+ def run
+ raise RuntimeError.new('Method run must be defined in the derived class.')
+ end
+ end
+end
diff --git a/lib/mailread.rb b/lib/mailread.rb
index ee86d353eb..7573d03ed4 100644
--- a/lib/mailread.rb
+++ b/lib/mailread.rb
@@ -14,7 +14,7 @@ class Mail
next if /^From /=~line # skip From-line
break if /^$/=~line # end of header
- if /^(\S+):\s*(.*)/=~line
+ if /^(\S+?):\s*(.*)/=~line
(attr = $1).capitalize!
@header[attr] = $2
elsif attr
diff --git a/lib/mathn.rb b/lib/mathn.rb
index 8d92272159..2257a4074a 100644
--- a/lib/mathn.rb
+++ b/lib/mathn.rb
@@ -10,8 +10,8 @@
#
#
-require "rational.rb"
require "complex.rb"
+require "rational.rb"
require "matrix.rb"
class Integer
@@ -106,29 +106,26 @@ class Prime
end
class Fixnum
- alias divmod! divmod
- alias / rdiv
- def divmod(other)
- a = self.div(other)
- b = self % other
- return a,b
- end
+ alias / quo
end
class Bignum
- alias divmod! divmod
- alias / rdiv
+ alias / quo
end
class Rational
Unify = true
-
+
+ def inspect
+ format "%s/%s", numerator.inspect, denominator.inspect
+ end
+
alias power! **
def ** (other)
if other.kind_of?(Rational)
if self < 0
- return Complex(self, 0) ** other
+ return Complex.new!(self, 0) ** other
elsif other == 0
return Rational(1,1)
elsif self == 0
@@ -137,8 +134,8 @@ class Rational
return Rational(1,1)
end
- npd = @numerator.prime_division
- dpd = @denominator.prime_division
+ npd = numerator.prime_division
+ dpd = denominator.prime_division
if other < 0
other = -other
npd, dpd = dpd, npd
@@ -167,11 +164,11 @@ class Rational
elsif other.kind_of?(Integer)
if other > 0
- num = @numerator ** other
- den = @denominator ** other
+ num = numerator ** other
+ den = denominator ** other
elsif other < 0
- num = @denominator ** -other
- den = @numerator ** -other
+ num = denominator ** -other
+ den = numerator ** -other
elsif other == 0
num = 1
den = 1
@@ -211,11 +208,11 @@ class Rational
elsif other.kind_of?(Integer)
if other > 0
- num = @numerator ** other
- den = @denominator ** other
+ num = numerator ** other
+ den = denominator ** other
elsif other < 0
- num = @denominator ** -other
- den = @numerator ** -other
+ num = denominator ** -other
+ den = numerator ** -other
elsif other == 0
num = 1
den = 1
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 4821bababf..c62acdf9aa 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -1,179 +1,28 @@
#!/usr/local/bin/ruby
-#
+#--
# matrix.rb -
-# $Release Version: 1.0$
-# $Revision: 1.11 $
-# $Date: 1999/10/06 11:01:53 $
+# $Release Version: 1.0$
+# $Revision: 1.11 $
+# $Date: 1999/10/06 11:01:53 $
# Original Version from Smalltalk-80 version
-# on July 23, 1985 at 8:37:17 am
-# by Keiju ISHITSUKA
-#
-# --
-#
-# Matrix[[1,2,3],
-# :
-# [3,4,5]]
-# Matrix[row0,
-# row1,
-# :
-# rown]
+# on July 23, 1985 at 8:37:17 am
+# by Keiju ISHITSUKA
+#++
#
+# = matrix.rb
#
-# module ExceptionForMatrix::
-# Exceptions:
-# ErrDimensionMismatch
-# number of column/row do not match
-# ErrNotRegular
-# not a regular matrix
-# ErrOperationNotDefined
-# specified operator is not defined (yet)
+# An implementation of Matrix and Vector classes.
#
-# class Matrix
-# include ExceptionForMatrix
+# Author:: Keiju ISHITSUKA
+# Documentation:: Gavin Sinclair (sourced from <i>Ruby in a Nutshell</i> (Matsumoto, O'Reilly))
#
-# Methods:
-# class methods:
-# Matrix.[](*rows)
-# creates a matrix where `rows' indicates rows.
-# `rows' is an array of arrays,
-# e.g, Matrix[[11, 12], [21, 22]]
-# Matrix.rows(rows, copy = true)
-# creates a matrix where `rows' indicates rows.
-# if optional argument `copy' is false, use the array as
-# internal structure of the metrix without copying.
-# Matrix.columns(columns)
-# creates a new matrix using `columns` as set of colums vectors.
-# Matrix.diagonal(*values)
-# creates a matrix where `columns' indicates columns.
-# Matrix.scalar(n, value)
-# creates a diagonal matrix such that the diagal compornents is
-# given by `values'.
-# Matrix.scalar(n, value)
-# creates an n-by-n scalar matrix such that the diagal compornent is
-# given by `value'.
-# Matrix.identity(n)
-# Matrix.unit(n)
-# Matrix.I(n)
-# creates an n-by-n unit matrix.
-# Matrix.zero(n)
-# creates an n-by-n zero matrix.
-# Matrix.row_vector(row)
-# creates a 1-by-n matrix such the row vector is `row'.
-# `row' is specifed as a Vector or an Array.
-# Matrix.column_vector(column)
-# creates a 1-by-n matrix such that column vector is `column'.
-# `column' is specifed as a Vector or an Array.
-# accessing:
-# [](i, j)
-# returns (i,j) compornent
-# row_size
-# returns the number of rows
-# column_size
-# returns the number of columns
-# row(i)
-# returns the i-th row vector.
-# when the block is supplied for the method, the block is iterated
-# over all row vectors.
-# column(j)
-# returns the jth column vector.
-# when the block is supplied for the method, the block is iterated
-# over all column vectors.
-# collect
-# map
-# creates a matrix which is the result of iteration of given
-# block over all compornents.
-# minor(*param)
-# returns sub matrix. parameter is specified as the following:
-# 1. from_row, row_size, from_col, size_col
-# 2. from_row..to_row, from_col..to_col
-# TESTING:
-# regular?
-# Is regular?
-# singular?
-# Is singular? i.e. Is non-regular?
-# square?
-# Is square?
-# ARITHMETIC:
-# *(m)
-# times
-# +(m)
-# plus
-# -(m)
-# minus
-# /(m)
-# self * m.inv
-# inverse
-# inv
-# inverse
-# **
-# power
-# Matrix functions:
-# determinant
-# det
-# returns the determinant
-# rank
-# returns the rank
-# trace
-# tr
-# returns the trace
-# transpose
-# t
-# returns the transposed
-# CONVERTING:
-# coerce(other)
-# row_vectors
-# array of row vectors
-# column_vectors
-# array of column vectors
-# to_a
-# converts each element to Array
-# to_f
-# converts each element to Float
-# to_i
-# converts each element to Integer
-# to_r
-# converts each element to Rational
-# PRINTING:
-# to_s
-# returns string representation
-# inspect
+# See classes Matrix and Vector for documentation.
#
-# class Vector
-# include ExceptionForMatrix
-#
-# INSTANCE CREATION:
-# Vector.[](*array)
-# Vector.elements(array, copy = true)
-# ACCSESSING:
-# [](i)
-# size
-# ENUMRATIONS:
-# each2(v)
-# collect2(v)
-# ARITHMETIC:
-# *(x) "is matrix or number"
-# +(v)
-# -(v)
-# VECTOR FUNCTIONS:
-# inner_product(v)
-# collect
-# map
-# map2(v)
-# r
-# CONVERTING:
-# covector
-# to_a
-# to_f
-# to_i
-# to_r
-# coerce(other)
-# PRINTING:
-# to_s
-# inspect
+
require "e2mmap.rb"
-module ExceptionForMatrix
+module ExceptionForMatrix # :nodoc:
extend Exception2MessageMapper
def_e2message(TypeError, "wrong argument type %s (expected %s)")
def_e2message(ArgumentError, "Wrong # of arguments(%d for %d)")
@@ -183,6 +32,78 @@ module ExceptionForMatrix
def_exception("ErrOperationNotDefined", "This operation(%s) can\\'t defined")
end
+#
+# The +Matrix+ class represents a mathematical matrix, and provides methods for creating
+# special-case matrices (zero, identity, diagonal, singular, vector), operating on them
+# arithmetically and algebraically, and determining their mathematical properties (trace, rank,
+# inverse, determinant).
+#
+# Note that although matrices should theoretically be rectangular, this is not
+# enforced by the class.
+#
+# Also note that the determinant of integer matrices may be incorrectly calculated unless you
+# also <tt>require 'mathn'</tt>. This may be fixed in the future.
+#
+# == Method Catalogue
+#
+# To create a matrix:
+# * <tt> Matrix[*rows] </tt>
+# * <tt> Matrix.[](*rows) </tt>
+# * <tt> Matrix.rows(rows, copy = true) </tt>
+# * <tt> Matrix.columns(columns) </tt>
+# * <tt> Matrix.diagonal(*values) </tt>
+# * <tt> Matrix.scalar(n, value) </tt>
+# * <tt> Matrix.scalar(n, value) </tt>
+# * <tt> Matrix.identity(n) </tt>
+# * <tt> Matrix.unit(n) </tt>
+# * <tt> Matrix.I(n) </tt>
+# * <tt> Matrix.zero(n) </tt>
+# * <tt> Matrix.row_vector(row) </tt>
+# * <tt> Matrix.column_vector(column) </tt>
+#
+# To access Matrix elements/columns/rows/submatrices/properties:
+# * <tt> [](i, j) </tt>
+# * <tt> #row_size </tt>
+# * <tt> #column_size </tt>
+# * <tt> #row(i) </tt>
+# * <tt> #column(j) </tt>
+# * <tt> #collect </tt>
+# * <tt> #map </tt>
+# * <tt> #minor(*param) </tt>
+#
+# Properties of a matrix:
+# * <tt> #regular? </tt>
+# * <tt> #singular? </tt>
+# * <tt> #square? </tt>
+#
+# Matrix arithmetic:
+# * <tt> *(m) </tt>
+# * <tt> +(m) </tt>
+# * <tt> -(m) </tt>
+# * <tt> #/(m) </tt>
+# * <tt> #inverse </tt>
+# * <tt> #inv </tt>
+# * <tt> ** </tt>
+#
+# Matrix functions:
+# * <tt> #determinant </tt>
+# * <tt> #det </tt>
+# * <tt> #rank </tt>
+# * <tt> #trace </tt>
+# * <tt> #tr </tt>
+# * <tt> #transpose </tt>
+# * <tt> #t </tt>
+#
+# Conversion to other data types:
+# * <tt> #coerce(other) </tt>
+# * <tt> #row_vectors </tt>
+# * <tt> #column_vectors </tt>
+# * <tt> #to_a </tt>
+#
+# String representations:
+# * <tt> #to_s </tt>
+# * <tt> #inspect </tt>
+#
class Matrix
@RCS_ID='-$Id: matrix.rb,v 1.11 1999/10/06 11:01:53 keiju Exp keiju $-'
@@ -192,25 +113,52 @@ class Matrix
# instance creations
private_class_method :new
+ #
+ # Creates a matrix where each argument is a row.
+ # Matrix[ [25, 93], [-1, 66] ]
+ # => 25 93
+ # -1 66
+ #
def Matrix.[](*rows)
new(:init_rows, rows, false)
end
+ #
+ # Creates a matrix where +rows+ is an array of arrays, each of which is a row
+ # to the matrix. If the optional argument +copy+ is false, use the given
+ # arrays as the internal structure of the matrix without copying.
+ # Matrix.rows([[25, 93], [-1, 66]])
+ # => 25 93
+ # -1 66
def Matrix.rows(rows, copy = true)
new(:init_rows, rows, copy)
end
+ #
+ # Creates a matrix using +columns+ as an array of column vectors.
+ # Matrix.columns([[25, 93], [-1, 66]])
+ # => 25 -1
+ # 93 66
+ #
+ #
def Matrix.columns(columns)
rows = (0 .. columns[0].size - 1).collect {
|i|
(0 .. columns.size - 1).collect {
- |j|
- columns[j][i]
+ |j|
+ columns[j][i]
}
}
Matrix.rows(rows, false)
end
+ #
+ # Creates a matrix where the diagonal elements are composed of +values+.
+ # Matrix.diagonal(9, 5, -3)
+ # => 9 0 0
+ # 0 5 0
+ # 0 0 -3
+ #
def Matrix.diagonal(*values)
size = values.size
rows = (0 .. size - 1).collect {
@@ -219,14 +167,26 @@ class Matrix
row[j] = values[j]
row
}
- self
rows(rows, false)
end
+ #
+ # Creates an +n+ by +n+ diagonal matrix where each diagonal element is
+ # +value+.
+ # Matrix.scalar(2, 5)
+ # => 5 0
+ # 0 5
+ #
def Matrix.scalar(n, value)
Matrix.diagonal(*Array.new(n).fill(value, 0, n))
end
+ #
+ # Creates an +n+ by +n+ identity matrix.
+ # Matrix.identity(2)
+ # => 1 0
+ # 0 1
+ #
def Matrix.identity(n)
Matrix.scalar(n, 1)
end
@@ -235,10 +195,22 @@ class Matrix
alias I identity
end
+ #
+ # Creates an +n+ by +n+ zero matrix.
+ # Matrix.zero(2)
+ # => 0 0
+ # 0 0
+ #
def Matrix.zero(n)
Matrix.scalar(n, 0)
end
+ #
+ # Creates a single-row matrix where the values of that row are as given in
+ # +row+.
+ # Matrix.row_vector([4,5,6])
+ # => 4 5 6
+ #
def Matrix.row_vector(row)
case row
when Vector
@@ -246,10 +218,18 @@ class Matrix
when Array
Matrix.rows([row.dup], false)
else
- Matrix.row([[row]], false)
+ Matrix.rows([[row]], false)
end
end
+ #
+ # Creates a single-column matrix where the values of that column are as given
+ # in +column+.
+ # Matrix.column_vector([4,5,6])
+ # => 4
+ # 5
+ # 6
+ #
def Matrix.column_vector(column)
case column
when Vector
@@ -261,7 +241,10 @@ class Matrix
end
end
- # initializing
+ #
+ # This method is used by the other methods that create matrices, and is of no
+ # use to general users.
+ #
def initialize(init_method, *argv)
self.send(init_method, *argv)
end
@@ -276,62 +259,95 @@ class Matrix
end
private :init_rows
- #accessing
+ #
+ # Returns element (+i+,+j+) of the matrix. That is: row +i+, column +j+.
+ #
def [](i, j)
@rows[i][j]
end
+ #
+ # Returns the number of rows.
+ #
def row_size
@rows.size
end
+ #
+ # Returns the number of columns. Note that it is possible to construct a
+ # matrix with uneven columns (e.g. Matrix[ [1,2,3], [4,5] ]), but this is
+ # mathematically unsound. This method uses the first row to determine the
+ # result.
+ #
def column_size
@rows[0].size
end
- def row(i)
+ #
+ # Returns row vector number +i+ of the matrix as a Vector (starting at 0 like
+ # an array). When a block is given, the elements of that vector are iterated.
+ #
+ def row(i) # :yield: e
if block_given?
for e in @rows[i]
- yield e
-
+ yield e
end
else
Vector.elements(@rows[i])
end
end
- def column(j)
+ #
+ # Returns column vector number +j+ of the matrix as a Vector (starting at 0
+ # like an array). When a block is given, the elements of that vector are
+ # iterated.
+ #
+ def column(j) # :yield: e
if block_given?
0.upto(row_size - 1) do
- |i|
- yield @rows[i][j]
+ |i|
+ yield @rows[i][j]
end
else
col = (0 .. row_size - 1).collect {
- |i|
- @rows[i][j]
+ |i|
+ @rows[i][j]
}
Vector.elements(col, false)
end
end
- def collect
+ #
+ # Returns a matrix that is the result of iteration of the given block over all
+ # elements of the matrix.
+ # Matrix[ [1,2], [3,4] ].collect { |i| i**2 }
+ # => 1 4
+ # 9 16
+ #
+ def collect # :yield: e
rows = @rows.collect{|row| row.collect{|e| yield e}}
Matrix.rows(rows, false)
end
alias map collect
#
- # param: (from_row, row_size, from_col, size_col)
- # (from_row..to_row, from_col..to_col)
+ # Returns a section of the matrix. The parameters are either:
+ # * start_row, nrows, start_col, ncols; OR
+ # * col_range, row_range
+ #
+ # Matrix.diagonal(9, 5, -3).minor(0..1, 0..2)
+ # => 9 0 0
+ # 0 5 0
#
def minor(*param)
case param.size
when 2
from_row = param[0].first
- size_row = param[0].size
+ size_row = param[0].end - from_row
+ size_row += 1 unless param[0].exclude_end?
from_col = param[1].first
- size_col = param[1].size
+ size_col = param[1].end - from_col
+ size_col += 1 unless param[1].exclude_end?
when 4
from_row = param[0]
size_row = param[1]
@@ -347,21 +363,40 @@ class Matrix
}
Matrix.rows(rows, false)
end
-
- # TESTING
+
+ #--
+ # TESTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+
+ #
+ # Returns +true+ if this is a regular matrix.
+ #
def regular?
square? and rank == column_size
end
+ #
+ # Returns +true+ is this is a singular (i.e. non-regular) matrix.
+ #
def singular?
not regular?
end
+ #
+ # Returns +true+ is this is a square matrix. See note in column_size about this
+ # being unreliable, though.
+ #
def square?
column_size == row_size
end
- # COMPARING
+ #--
+ # OBJECT METHODS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+
+ #
+ # Returns +true+ if and only if the two matrices contain equal elements.
+ #
def ==(other)
return false unless Matrix === other
@@ -369,6 +404,9 @@ class Matrix
end
alias eql? ==
+ #
+ # Not really intended for general consumption.
+ #
def compare_by_row_vectors(rows)
return false unless @rows.size == rows.size
@@ -379,31 +417,46 @@ class Matrix
true
end
+ #
+ # Returns a clone of the matrix, so that the contents of each do not reference
+ # identical objects.
+ #
def clone
Matrix.rows(@rows)
end
+ #
+ # Returns a hash-code for the matrix.
+ #
def hash
value = 0
for row in @rows
for e in row
- value ^= e.hash
+ value ^= e.hash
end
end
return value
end
- # ARITHMETIC
+ #--
+ # ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
- def *(m) #is matrix or vector or number"
+ #
+ # Matrix multiplication.
+ # Matrix[[2,4], [6,8]] * Matrix.identity(2)
+ # => 2 4
+ # 6 8
+ #
+ def *(m) # m is matrix or vector or number
case(m)
when Numeric
rows = @rows.collect {
- |row|
- row.collect {
- |e|
- e * m
- }
+ |row|
+ row.collect {
+ |e|
+ e * m
+ }
}
return Matrix.rows(rows, false)
when Vector
@@ -414,16 +467,16 @@ class Matrix
Matrix.Raise ErrDimensionMismatch if column_size != m.row_size
rows = (0 .. row_size - 1).collect {
- |i|
- (0 .. m.column_size - 1).collect {
- |j|
- vij = 0
- 0.upto(column_size - 1) do
- |k|
- vij += self[i, k] * m[k, j]
- end
- vij
- }
+ |i|
+ (0 .. m.column_size - 1).collect {
+ |j|
+ vij = 0
+ 0.upto(column_size - 1) do
+ |k|
+ vij += self[i, k] * m[k, j]
+ end
+ vij
+ }
}
return Matrix.rows(rows, false)
else
@@ -432,6 +485,12 @@ class Matrix
end
end
+ #
+ # Matrix addition.
+ # Matrix.scalar(2,5) + Matrix[[1,0], [-4,7]]
+ # => 6 0
+ # -4 12
+ #
def +(m)
case m
when Numeric
@@ -449,13 +508,19 @@ class Matrix
rows = (0 .. row_size - 1).collect {
|i|
(0 .. column_size - 1).collect {
- |j|
- self[i, j] + m[i, j]
+ |j|
+ self[i, j] + m[i, j]
}
}
Matrix.rows(rows, false)
end
+ #
+ # Matrix subtraction.
+ # Matrix[[1,5], [4,2]] - Matrix[[9,3], [-4,1]]
+ # => -8 2
+ # 8 1
+ #
def -(m)
case m
when Numeric
@@ -473,22 +538,28 @@ class Matrix
rows = (0 .. row_size - 1).collect {
|i|
(0 .. column_size - 1).collect {
- |j|
- self[i, j] - m[i, j]
+ |j|
+ self[i, j] - m[i, j]
}
}
Matrix.rows(rows, false)
end
+ #
+ # Matrix division (multiplication by the inverse).
+ # Matrix[[7,6], [3,9]] / Matrix[[2,9], [3,1]]
+ # => -7 1
+ # -3 -6
+ #
def /(other)
case other
when Numeric
rows = @rows.collect {
- |row|
- row.collect {
- |e|
- e / other
- }
+ |row|
+ row.collect {
+ |e|
+ e / other
+ }
}
return Matrix.rows(rows, false)
when Matrix
@@ -499,73 +570,89 @@ class Matrix
end
end
+ #
+ # Returns the inverse of the matrix.
+ # Matrix[[1, 2], [2, 1]].inverse
+ # => -1 1
+ # 0 -1
+ #
def inverse
Matrix.Raise ErrDimensionMismatch unless square?
Matrix.I(row_size).inverse_from(self)
end
alias inv inverse
-
+
+ #
+ # Not for public consumption?
+ #
def inverse_from(src)
size = row_size - 1
a = src.to_a
for k in 0..size
if (akk = a[k][k]) == 0
- i = k
- begin
- Matrix.Raise ErrNotRegular if (i += 1) > size
- end while a[i][k] == 0
- a[i], a[k] = a[k], a[i]
- @rows[i], @rows[k] = @rows[k], @rows[i]
- akk = a[k][k]
+ i = k
+ begin
+ Matrix.Raise ErrNotRegular if (i += 1) > size
+ end while a[i][k] == 0
+ a[i], a[k] = a[k], a[i]
+ @rows[i], @rows[k] = @rows[k], @rows[i]
+ akk = a[k][k]
end
for i in 0 .. size
- next if i == k
- q = a[i][k] / akk
- a[i][k] = 0
-
- (k + 1).upto(size) do
- |j|
- a[i][j] -= a[k][j] * q
- end
- 0.upto(size) do
- |j|
- @rows[i][j] -= @rows[k][j] * q
- end
+ next if i == k
+ q = a[i][k] / akk
+ a[i][k] = 0
+
+ (k + 1).upto(size) do
+ |j|
+ a[i][j] -= a[k][j] * q
+ end
+ 0.upto(size) do
+ |j|
+ @rows[i][j] -= @rows[k][j] * q
+ end
end
(k + 1).upto(size) do
- |j|
- a[k][j] /= akk
+ |j|
+ a[k][j] /= akk
end
0.upto(size) do
- |j|
- @rows[k][j] /= akk
+ |j|
+ @rows[k][j] /= akk
end
end
self
end
#alias reciprocal inverse
+ #
+ # Matrix exponentiation. Defined for integer powers only. Equivalent to
+ # multiplying the matrix by itself N times.
+ # Matrix[[7,6], [3,9]] ** 2
+ # => 67 96
+ # 48 99
+ #
def ** (other)
if other.kind_of?(Integer)
x = self
if other <= 0
- x = self.inverse
- return Matrix.identity(self.column_size) if other == 0
- other = -other
+ x = self.inverse
+ return Matrix.identity(self.column_size) if other == 0
+ other = -other
end
z = x
n = other - 1
while n != 0
- while (div, mod = n.divmod(2)
- mod == 0)
- x = x * x
- n = div
- end
- z *= x
- n -= 1
+ while (div, mod = n.divmod(2)
+ mod == 0)
+ x = x * x
+ n = div
+ end
+ z *= x
+ n -= 1
end
z
elsif other.kind_of?(Float) || defined?(Rational) && other.kind_of?(Rational)
@@ -575,8 +662,16 @@ class Matrix
end
end
- # Matrix functions
+ #--
+ # MATRIX FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+ #
+ # Returns the determinant of the matrix. If the matrix is not square, the
+ # result is 0.
+ # Matrix[[7,6], [3,9]].determinant
+ # => 63
+ #
def determinant
return 0 unless square?
@@ -587,28 +682,35 @@ class Matrix
k = 0
begin
if (akk = a[k][k]) == 0
- i = k
- begin
- return 0 if (i += 1) > size
- end while a[i][k] == 0
- a[i], a[k] = a[k], a[i]
- akk = a[k][k]
- det *= -1
+ i = k
+ begin
+ return 0 if (i += 1) > size
+ end while a[i][k] == 0
+ a[i], a[k] = a[k], a[i]
+ akk = a[k][k]
+ det *= -1
end
(k + 1).upto(size) do
- |i|
- q = a[i][k] / akk
- (k + 1).upto(size) do
- |j|
- a[i][j] -= a[k][j] * q
- end
+ |i|
+ q = a[i][k] / akk
+ (k + 1).upto(size) do
+ |j|
+ a[i][j] -= a[k][j] * q
+ end
end
det *= akk
end while (k += 1) <= size
det
end
alias det determinant
-
+
+ #
+ # Returns the rank of the matrix. Beware that using Float values, with their
+ # usual lack of precision, can affect the value returned by this method. Use
+ # Rational values instead if this is important to you.
+ # Matrix[[7,6], [3,9]].rank
+ # => 2
+ #
def rank
if column_size > row_size
a = transpose.to_a
@@ -623,50 +725,55 @@ class Matrix
k = 0
begin
if (akk = a[k][k]) == 0
- i = k
- exists = true
- begin
- if (i += 1) > a_column_size - 1
- exists = false
- break
- end
- end while a[i][k] == 0
- if exists
- a[i], a[k] = a[k], a[i]
- akk = a[k][k]
- else
- i = k
- exists = true
- begin
- if (i += 1) > a_row_size - 1
- exists = false
- break
- end
- end while a[k][i] == 0
- if exists
- k.upto(a_column_size - 1) do
- |j|
- a[j][k], a[j][i] = a[j][i], a[j][k]
- end
- akk = a[k][k]
- else
- next
- end
- end
+ i = k
+ exists = true
+ begin
+ if (i += 1) > a_column_size - 1
+ exists = false
+ break
+ end
+ end while a[i][k] == 0
+ if exists
+ a[i], a[k] = a[k], a[i]
+ akk = a[k][k]
+ else
+ i = k
+ exists = true
+ begin
+ if (i += 1) > a_row_size - 1
+ exists = false
+ break
+ end
+ end while a[k][i] == 0
+ if exists
+ k.upto(a_column_size - 1) do
+ |j|
+ a[j][k], a[j][i] = a[j][i], a[j][k]
+ end
+ akk = a[k][k]
+ else
+ next
+ end
+ end
end
(k + 1).upto(a_row_size - 1) do
- |i|
- q = a[i][k] / akk
- (k + 1).upto(a_column_size - 1) do
- |j|
- a[i][j] -= a[k][j] * q
- end
+ |i|
+ q = a[i][k] / akk
+ (k + 1).upto(a_column_size - 1) do
+ |j|
+ a[i][j] -= a[k][j] * q
+ end
end
rank += 1
end while (k += 1) <= a_column_size - 1
return rank
end
+ #
+ # Returns the trace (sum of diagonal elements) of the matrix.
+ # Matrix[[7,6], [3,9]].trace
+ # => 16
+ #
def trace
tr = 0
0.upto(column_size - 1) do
@@ -677,55 +784,73 @@ class Matrix
end
alias tr trace
+ #
+ # Returns the transpose of the matrix.
+ # Matrix[[1,2], [3,4], [5,6]]
+ # => 1 2
+ # 3 4
+ # 5 6
+ # Matrix[[1,2], [3,4], [5,6]].transpose
+ # => 1 3 5
+ # 2 4 6
+ #
def transpose
Matrix.columns(@rows)
end
alias t transpose
- # CONVERTING
+ #--
+ # CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+ #
+ # FIXME: describe #coerce.
+ #
def coerce(other)
case other
when Numeric
return Scalar.new(other), self
else
- raise TypeError, "#{type} can't be coerced into #{other.type}"
+ raise TypeError, "#{self.class} can't be coerced into #{other.class}"
end
end
+ #
+ # Returns an array of the row vectors of the matrix. See Vector.
+ #
def row_vectors
- rows = (0 .. column_size - 1).collect {
+ rows = (0 .. row_size - 1).collect {
|i|
row(i)
}
rows
end
+ #
+ # Returns an array of the column vectors of the matrix. See Vector.
+ #
def column_vectors
- columns = (0 .. row_size - 1).collect {
+ columns = (0 .. column_size - 1).collect {
|i|
column(i)
}
columns
end
+ #
+ # Returns an array of arrays that describe the rows of the matrix.
+ #
def to_a
@rows.collect{|row| row.collect{|e| e}}
end
- def to_f
- collect{|e| e.to_f}
- end
-
- def to_i
- collect{|e| e.to_i}
- end
+ #--
+ # PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
- def to_r
- collect{|e| e.to_r}
- end
-
- # PRINTING
+ #
+ # Overrides Object#to_s
+ #
def to_s
"Matrix[" + @rows.collect{
|row|
@@ -733,13 +858,16 @@ class Matrix
}.join(", ")+"]"
end
+ #
+ # Overrides Object#inspect
+ #
def inspect
"Matrix"+@rows.inspect
end
# Private CLASS
- class Scalar < Numeric
+ class Scalar < Numeric # :nodoc:
include ExceptionForMatrix
def initialize(value)
@@ -750,96 +878,146 @@ class Matrix
def +(other)
case other
when Numeric
- Scalar.new(@value + other)
+ Scalar.new(@value + other)
when Vector, Matrix
- Scalar.Raise WrongArgType, other.type, "Numeric or Scalar"
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar"
when Scalar
- Scalar.new(@value + other.value)
+ Scalar.new(@value + other.value)
else
- x, y = other.coerce(self)
- x + y
+ x, y = other.coerce(self)
+ x + y
end
end
def -(other)
case other
when Numeric
- Scalar.new(@value - other)
+ Scalar.new(@value - other)
when Vector, Matrix
- Scalar.Raise WrongArgType, other.type, "Numeric or Scalar"
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar"
when Scalar
- Scalar.new(@value - other.value)
+ Scalar.new(@value - other.value)
else
- x, y = other.coerce(self)
- x - y
+ x, y = other.coerce(self)
+ x - y
end
end
def *(other)
case other
when Numeric
- Scalar.new(@value * other)
+ Scalar.new(@value * other)
when Vector, Matrix
- other.collect{|e| @value * e}
+ other.collect{|e| @value * e}
else
- x, y = other.coerce(self)
- x * y
+ x, y = other.coerce(self)
+ x * y
end
end
def / (other)
case other
when Numeric
- Scalar.new(@value / other)
+ Scalar.new(@value / other)
when Vector
- Scalar.Raise WrongArgType, other.type, "Numeric or Scalar or Matrix"
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar or Matrix"
when Matrix
- self * _M.inverse
+ self * _M.inverse
else
- x, y = other.coerce(self)
- x / y
+ x, y = other.coerce(self)
+ x / y
end
end
def ** (other)
case other
when Numeric
- Scalar.new(@value ** other)
+ Scalar.new(@value ** other)
when Vector
- Scalar.Raise WrongArgType, other.type, "Numeric or Scalar or Matrix"
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar or Matrix"
when Matrix
- other.powered_by(self)
+ other.powered_by(self)
else
- x, y = other.coerce(self)
- x ** y
+ x, y = other.coerce(self)
+ x ** y
end
end
end
end
-#----------------------------------------------------------------------
+
+#
+# The +Vector+ class represents a mathematical vector, which is useful in its own right, and
+# also constitutes a row or column of a Matrix.
#
-# -
+# == Method Catalogue
+#
+# To create a Vector:
+# * <tt> Vector.[](*array) </tt>
+# * <tt> Vector.elements(array, copy = true) </tt>
+#
+# To access elements:
+# * <tt> [](i) </tt>
+#
+# To enumerate the elements:
+# * <tt> #each2(v) </tt>
+# * <tt> #collect2(v) </tt>
+#
+# Vector arithmetic:
+# * <tt> *(x) "is matrix or number" </tt>
+# * <tt> +(v) </tt>
+# * <tt> -(v) </tt>
+#
+# Vector functions:
+# * <tt> #inner_product(v) </tt>
+# * <tt> #collect </tt>
+# * <tt> #map </tt>
+# * <tt> #map2(v) </tt>
+# * <tt> #r </tt>
+# * <tt> #size </tt>
+#
+# Conversion to other data types:
+# * <tt> #covector </tt>
+# * <tt> #to_a </tt>
+# * <tt> #coerce(other) </tt>
+#
+# String representations:
+# * <tt> #to_s </tt>
+# * <tt> #inspect </tt>
#
-#----------------------------------------------------------------------
class Vector
include ExceptionForMatrix
#INSTANCE CREATION
private_class_method :new
+
+ #
+ # Creates a Vector from a list of elements.
+ # Vector[7, 4, ...]
+ #
def Vector.[](*array)
new(:init_elements, array, copy = false)
end
+ #
+ # Creates a vector from an Array. The optional second argument specifies
+ # whether the array itself or a copy is used internally.
+ #
def Vector.elements(array, copy = true)
new(:init_elements, array, copy)
end
+ #
+ # For internal use.
+ #
def initialize(method, array, copy)
self.send(method, array, copy)
end
+ #
+ # For internal use.
+ #
def init_elements(array, copy)
if copy
@elements = array.dup
@@ -848,18 +1026,30 @@ class Vector
end
end
- # ACCSESSING
-
+ # ACCESSING
+
+ #
+ # Returns element number +i+ (starting at zero) of the vector.
+ #
def [](i)
@elements[i]
end
+ #
+ # Returns the number of elements in the vector.
+ #
def size
@elements.size
end
- # ENUMRATIONS
- def each2(v)
+ #--
+ # ENUMERATIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+
+ #
+ # Iterate over the elements of this vector and +v+ in conjunction.
+ #
+ def each2(v) # :yield: e1, e2
Vector.Raise ErrDimensionMismatch if size != v.size
0.upto(size - 1) do
|i|
@@ -867,7 +1057,11 @@ class Vector
end
end
- def collect2(v)
+ #
+ # Collects (as in Enumerable#collect) over the elements of this vector and +v+
+ # in conjunction.
+ #
+ def collect2(v) # :yield: e1, e2
Vector.Raise ErrDimensionMismatch if size != v.size
(0 .. size - 1).collect do
|i|
@@ -875,7 +1069,13 @@ class Vector
end
end
- # COMPARING
+ #--
+ # COMPARING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+
+ #
+ # Returns +true+ iff the two vectors have the same elements in the same order.
+ #
def ==(other)
return false unless Vector === other
@@ -883,40 +1083,57 @@ class Vector
end
alias eqn? ==
+ #
+ # For internal use.
+ #
def compare_by(elements)
@elements == elements
end
+ #
+ # Return a copy of the vector.
+ #
def clone
Vector.elements(@elements)
end
+ #
+ # Return a hash-code for the vector.
+ #
def hash
@elements.hash
end
- # ARITHMETIC
+ #--
+ # ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
- def *(x) "is matrix or number"
+ #
+ # Multiplies the vector by +x+, where +x+ is a number or another vector.
+ #
+ def *(x)
case x
when Numeric
els = @elements.collect{|e| e * x}
Vector.elements(els, false)
when Matrix
- self.covector * x
+ Matrix.column_vector(self) * x
else
- s, x = X.coerce(self)
+ s, x = x.coerce(self)
s * x
end
end
+ #
+ # Vector addition.
+ #
def +(v)
case v
when Vector
Vector.Raise ErrDimensionMismatch if size != v.size
els = collect2(v) {
- |v1, v2|
- v1 + v2
+ |v1, v2|
+ v1 + v2
}
Vector.elements(els, false)
when Matrix
@@ -927,13 +1144,16 @@ class Vector
end
end
+ #
+ # Vector subtraction.
+ #
def -(v)
case v
when Vector
Vector.Raise ErrDimensionMismatch if size != v.size
els = collect2(v) {
- |v1, v2|
- v1 - v2
+ |v1, v2|
+ v1 - v2
}
Vector.elements(els, false)
when Matrix
@@ -944,8 +1164,14 @@ class Vector
end
end
- # VECTOR FUNCTIONS
+ #--
+ # VECTOR FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+ #
+ # Returns the inner product of this vector with the other.
+ # Vector[4,7].inner_product Vector[10,1] => 47
+ #
def inner_product(v)
Vector.Raise ErrDimensionMismatch if size != v.size
@@ -957,7 +1183,10 @@ class Vector
p
end
- def collect
+ #
+ # Like Array#collect.
+ #
+ def collect # :yield: e
els = @elements.collect {
|v|
yield v
@@ -966,7 +1195,10 @@ class Vector
end
alias map collect
- def map2(v)
+ #
+ # Like Vector#collect2, but returns a Vector instead of an Array.
+ #
+ def map2(v) # :yield: e1, e2
els = collect2(v) {
|v1, v2|
yield v1, v2
@@ -974,6 +1206,10 @@ class Vector
Vector.elements(els, false)
end
+ #
+ # Returns the modulus (Pythagorean distance) of the vector.
+ # Vector[5,8,2].r => 9.643650761
+ #
def r
v = 0
for e in @elements
@@ -982,43 +1218,55 @@ class Vector
return Math.sqrt(v)
end
+ #--
# CONVERTING
+ #++
+
+ #
+ # Creates a single-row matrix from this vector.
+ #
def covector
Matrix.row_vector(self)
end
+ #
+ # Returns the elements of the vector in an array.
+ #
def to_a
@elements.dup
end
- def to_f
- collect{|e| e.to_f}
- end
-
- def to_i
- collect{|e| e.to_i}
- end
-
- def to_r
- collect{|e| e.to_r}
- end
-
+ #
+ # FIXME: describe Vector#coerce.
+ #
def coerce(other)
case other
when Numeric
return Scalar.new(other), self
else
- raise TypeError, "#{type} can't be coerced into #{other.type}"
+ raise TypeError, "#{self.class} can't be coerced into #{other.class}"
end
end
- # PRINTING
+ #--
+ # PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+ #++
+ #
+ # Overrides Object#to_s
+ #
def to_s
"Vector[" + @elements.join(", ") + "]"
end
+ #
+ # Overrides Object#inspect
+ #
def inspect
str = "Vector"+@elements.inspect
end
end
+
+
+# Documentation comments:
+# - Matrix#coerce and Vector#coerce need to be documented
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index a9ce9b55bb..494838e63b 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -2,405 +2,808 @@
# invoke like: ruby -r mkmf extconf.rb
require 'rbconfig'
-require 'find'
+require 'fileutils'
+require 'shellwords'
CONFIG = Config::MAKEFILE_CONFIG
ORIG_LIBPATH = ENV['LIB']
SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
+$static = $config_h = nil
-$config_cache = CONFIG["compile_dir"]+"/ext/config.cache"
+unless defined? $configure_args
+ $configure_args = {}
+ args = CONFIG["configure_args"]
+ if ENV["CONFIGURE_ARGS"]
+ args << " " << ENV["CONFIGURE_ARGS"]
+ end
+ for arg in Shellwords::shellwords(args)
+ arg, val = arg.split('=', 2)
+ next unless arg
+ arg.tr!('_', '-')
+ if arg.sub!(/^(?!--)/, '--')
+ val or next
+ arg.downcase!
+ end
+ next if /^--(?:top|topsrc|src|cur)dir$/ =~ arg
+ $configure_args[arg] = val || true
+ end
+ for arg in ARGV
+ arg, val = arg.split('=', 2)
+ next unless arg
+ arg.tr!('_', '-')
+ if arg.sub!(/^(?!--)/, '--')
+ val or next
+ arg.downcase!
+ end
+ $configure_args[arg] = val || true
+ end
+end
$srcdir = CONFIG["srcdir"]
-$libdir = CONFIG["libdir"]+"/ruby/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
-$archdir = $libdir+"/"+CONFIG["arch"]
-$sitelibdir = CONFIG["sitedir"]+"/"+CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
-$sitearchdir = $sitelibdir+"/"+CONFIG["arch"]
+$libdir = CONFIG["libdir"]
+$rubylibdir = CONFIG["rubylibdir"]
+$archdir = CONFIG["archdir"]
+$sitedir = CONFIG["sitedir"]
+$sitelibdir = CONFIG["sitelibdir"]
+$sitearchdir = CONFIG["sitearchdir"]
+
+$mswin = /mswin/ =~ RUBY_PLATFORM
+$bccwin = /bccwin/ =~ RUBY_PLATFORM
+$mingw = /mingw/ =~ RUBY_PLATFORM
+$cygwin = /cygwin/ =~ RUBY_PLATFORM
+$human = /human/ =~ RUBY_PLATFORM
+$netbsd = /netbsd/ =~ RUBY_PLATFORM
+$os2 = /os2/ =~ RUBY_PLATFORM
+
+def config_string(key, config = CONFIG)
+ s = config[key] and !s.empty? and block_given? ? yield(s) : s
+end
-if File.exist? $archdir + "/ruby.h"
- $hdrdir = $archdir
-elsif File.exist? $srcdir + "/ruby.h"
- $hdrdir = $srcdir
-else
- STDERR.print "can't find header files for ruby.\n"
- exit 1
+def dir_re(dir)
+ Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$\(target_prefix\)|\{target_prefix\})?')
end
-$topdir = $hdrdir
-# $hdrdir.gsub!('/', '\\') if RUBY_PLATFORM =~ /mswin32/
-CFLAGS = CONFIG["CFLAGS"]
-if RUBY_PLATFORM == "m68k-human"
- CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
-elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody|-darwin/
- CFLAGS.gsub!( /-arch\s\w*/, '' )
+INSTALL_DIRS = [
+ [dir_re('commondir'), "$(RUBYCOMMONDIR)"],
+ [dir_re("sitedir"), "$(RUBYCOMMONDIR)"],
+ [dir_re('rubylibdir'), "$(RUBYLIBDIR)"],
+ [dir_re('archdir'), "$(RUBYARCHDIR)"],
+ [dir_re('sitelibdir'), "$(RUBYLIBDIR)"],
+ [dir_re('sitearchdir'), "$(RUBYARCHDIR)"]
+]
+
+def map_dir(dir, map = nil)
+ map ||= INSTALL_DIRS
+ map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)}
end
-if FileTest.readable? 'nul'
- $null = open('nul', 'w')
-elsif FileTest.readable? '/dev/null'
- $null = open('/dev/null', 'w')
+libdir = File.dirname(__FILE__)
+$extmk = libdir != Config::CONFIG["rubylibdir"]
+if not $extmk and File.exist? Config::CONFIG["archdir"] + "/ruby.h"
+ $hdrdir = $topdir = Config::CONFIG["archdir"]
+elsif File.exist? $srcdir + "/ruby.h"
+ $topdir = Config::CONFIG["compile_dir"]
+ $hdrdir = $srcdir
else
- $null = open('test.log', 'w')
+ abort "can't find header files for ruby."
end
-LINK = "#{CONFIG['CC']} -o conftest -I#{$hdrdir} #{CFLAGS} -I#{CONFIG['includedir']} %s %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}"
-CPP = "#{CONFIG['CPP']} -E %s -I#{$hdrdir} #{CFLAGS} -I#{CONFIG['includedir']} %s %s conftest.c"
+OUTFLAG = CONFIG['OUTFLAG']
+CPPOUTFILE = CONFIG['CPPOUTFILE']
-def rm_f(*files)
- targets = []
- for file in files
- targets.concat Dir[file]
+CONFTEST_C = "conftest.c"
+
+class String
+ def quote
+ /\s/ =~ self ? "\"#{self}\"" : self
end
- if not targets.empty?
- File::chmod 0777, *targets
- File::unlink *targets
+end
+class Array
+ def quote
+ map {|s| s.quote}
end
end
-$orgerr = $stderr.dup
-$orgout = $stdout.dup
-def xsystem command
- if $DEBUG
- print command, "\n"
- return system(command)
- end
- $stderr.reopen($null)
- $stdout.reopen($null)
- r = system(command)
- $stderr.reopen($orgerr)
- $stdout.reopen($orgout)
- return r
-end
-
-def try_link0(src, opt="")
- cfile = open("conftest.c", "w")
- cfile.print src
- cfile.close
- ldflags = $LDFLAGS
- if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty?
- ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';')
- else
- $LDFLAGS = ldflags.dup
- $LIBPATH.each {|d| $LDFLAGS << " -L" + d}
- end
- begin
- xsystem(format(LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
- ensure
- $LDFLAGS = ldflags
- ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM
- end
+def rm_f(*files)
+ FileUtils.rm_f(Dir[files.join("\0")])
end
-def try_link(src, opt="")
- begin
- try_link0(src, opt)
- ensure
- rm_f "conftest*"
- end
+def modified?(target, times)
+ (t = File.mtime(target)) rescue return nil
+ Array === times or times = [times]
+ t if times.all? {|n| n <= t}
end
-def try_cpp(src, opt="")
- cfile = open("conftest.c", "w")
- cfile.print src
- cfile.close
- begin
- xsystem(format(CPP, $CPPFLAGS, $CFLAGS, opt))
- ensure
- rm_f "conftest*"
+def merge_libs(*libs)
+ libs.inject([]) do |x, y|
+ xy = x & y
+ xn = yn = 0
+ y = y.inject([]) {|ary, e| ary.last == e ? ary : ary << e}
+ y.each_with_index do |v, yi|
+ if xy.include?(v)
+ xi = [x.index(v), xn].max()
+ x[xi, 1] = y[yn..yi]
+ xn, yn = xi + (yi - yn + 1), yi + 1
+ end
+ end
+ x.concat(y[yn..-1] || [])
end
end
-def egrep_cpp(pat, src, opt="")
- cfile = open("conftest.c", "w")
- cfile.print src
- cfile.close
- begin
- xsystem(format(CPP+"|egrep #{pat}", $CPPFLAGS, $CFLAGS, opt))
+module Logging
+ @log = nil
+ @logfile = 'mkmf.log'
+ @orgerr = $stderr.dup
+ @orgout = $stdout.dup
+
+ def self::open
+ @log ||= File::open(@logfile, 'w')
+ @log.sync = true
+ $stderr.reopen(@log)
+ $stdout.reopen(@log)
+ yield
ensure
- rm_f "conftest*"
+ $stderr.reopen(@orgerr)
+ $stdout.reopen(@orgout)
end
-end
-def try_run(src, opt="")
- begin
- if try_link0(src, opt)
- if xsystem("./conftest")
- true
- else
- false
+ def self::message(*s)
+ @log ||= File::open(@logfile, 'w')
+ @log.sync = true
+ @log.printf(*s)
+ end
+
+ def self::logfile file
+ @logfile = file
+ if @log and not @log.closed?
+ @log.flush
+ @log.close
+ @log = nil
+ end
+ end
+
+ def self::postpone
+ tmplog = "mkmftmp.log"
+ open do
+ log, *save = @log, @logfile, @orgout, @orgerr
+ @log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
+ begin
+ log.print(open {yield})
+ @log.close
+ File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
+ ensure
+ @log, @logfile, @orgout, @orgerr = log, *save
+ rm_f tmplog
end
- else
- nil
end
- ensure
- rm_f "conftest*"
end
end
-def install_rb(mfile, dest, srcdir = nil)
- libdir = "lib"
- libdir = srcdir + "/" + libdir if srcdir
- path = []
- dir = []
- if File.directory? libdir
- Find.find(libdir) do |f|
- next unless /\.rb$/ =~ f
- f = f[libdir.length+1..-1]
- path.push f
- dir |= [File.dirname(f)]
- end
+def xsystem command
+ Config.expand(command)
+ Logging::open do
+ puts command.quote
+ system(command)
end
- for f in dir
- next if f == "."
- mfile.printf "\t@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' %s/%s\n", dest, f
+end
+
+def xpopen command, *mode, &block
+ Config.expand(command)
+ Logging::open do
+ case mode[0]
+ when nil, /^r/
+ puts "#{command} |"
+ else
+ puts "| #{command}"
+ end
+ IO.popen(command, *mode, &block)
end
- for f in path
- d = '/' + File::dirname(f)
- d = '' if d == '/.'
- mfile.printf "\t@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' %s/%s %s%s\n", libdir, f, dest, d
+end
+
+def log_src(src)
+ Logging::message <<"EOM", src
+checked program was:
+/* begin */
+%s/* end */
+
+EOM
+end
+
+def create_tmpsrc(src)
+ src = yield(src) if block_given?
+ src = src.sub(/[^\n]\z/, "\\&\n")
+ open(CONFTEST_C, "wb") do |cfile|
+ cfile.print src
end
+ src
end
-def append_library(libs, lib)
- if /mswin32/ =~ RUBY_PLATFORM
- lib + ".lib " + libs
+def try_do(src, command, &b)
+ src = create_tmpsrc(src, &b)
+ xsystem(command)
+ensure
+ log_src(src)
+end
+
+def link_command(ldflags, opt="", libpath=$LIBPATH)
+ Config::expand(TRY_LINK.dup,
+ 'hdrdir' => $hdrdir,
+ 'src' => CONFTEST_C,
+ 'INCFLAGS' => $INCFLAGS,
+ 'CPPFLAGS' => $CPPFLAGS,
+ 'CFLAGS' => "#$CFLAGS",
+ 'ARCH_FLAG' => "#$ARCH_FLAG",
+ 'LDFLAGS' => "#$LDFLAGS #{ldflags}",
+ 'LIBPATH' => libpathflag(libpath),
+ 'LOCAL_LIBS' => "#$LOCAL_LIBS #$libs",
+ 'LIBS' => "#$LIBRUBYARG_STATIC #{opt} #$LIBS")
+end
+
+def cc_command(opt="")
+ "$(CC) -c #$INCFLAGS -I#{$hdrdir} " \
+ "#$CPPFLAGS #$CFLAGS #$ARCH_FLAG #{opt} #{CONFTEST_C}"
+end
+
+def cpp_command(outfile, opt="")
+ "$(CPP) #$INCFLAGS -I#{$hdrdir} " \
+ "#$CPPFLAGS #$CFLAGS #{opt} #{CONFTEST_C} #{outfile}"
+end
+
+def libpathflag(libpath=$LIBPATH)
+ libpath.map{|x|
+ (x == "$(topdir)" ? LIBPATHFLAG : LIBPATHFLAG+RPATHFLAG) % x
+ }.join
+end
+
+def try_link0(src, opt="", &b)
+ try_do(src, link_command("", opt), &b)
+end
+
+def try_link(src, opt="", &b)
+ try_link0(src, opt, &b)
+ensure
+ rm_f "conftest*", "c0x32*"
+end
+
+def try_compile(src, opt="", &b)
+ try_do(src, cc_command(opt), &b)
+ensure
+ rm_f "conftest*"
+end
+
+def try_cpp(src, opt="", &b)
+ try_do(src, cpp_command(CPPOUTFILE, opt), &b)
+ensure
+ rm_f "conftest*"
+end
+
+def cpp_include(header)
+ if header
+ header = [header] unless header.kind_of? Array
+ header.map {|h| "#include <#{h}>\n"}.join
else
- "-l" + lib + " " + libs
+ ""
end
end
-def have_library(lib, func="main")
- printf "checking for %s() in -l%s... ", func, lib
- STDOUT.flush
+def try_static_assert(expr, headers = nil, opt = "", &b)
+ headers = cpp_include(headers)
+ try_compile(<<SRC, opt, &b)
+#{COMMON_HEADERS}
+#{headers}
+/*top*/
+int tmp[(#{expr}) ? 1 : -1];
+SRC
+end
- if func && func != ""
- libs = append_library($libs, lib)
- if /mswin32|mingw/ =~ RUBY_PLATFORM
- r = try_link(<<"SRC", libs)
-#include <windows.h>
-#include <winsock.h>
+def try_constant(const, headers = nil, opt = "", &b)
+ headers = cpp_include(headers)
+ if CROSS_COMPILING
+ unless try_compile(<<"SRC", opt, &b)
+#{COMMON_HEADERS}
+#{headers}
+/*top*/
+int tmp = #{const};
+SRC
+ return nil
+ end
+ if try_static_assert("#{const} < 0", headers, opt)
+ neg = true
+ const = "-(#{const})"
+ elsif try_static_assert("#{const} == 0", headers, opt)
+ return 0
+ end
+ upper = 1
+ until try_static_assert("#{const} < #{upper}", headers, opt)
+ lower = upper
+ upper <<= 1
+ end
+ return nil unless lower
+ until try_static_assert("#{const} == #{upper}", headers, opt)
+ if try_static_assert("#{const} > #{(upper+lower)/2}", headers, opt)
+ lower = (upper+lower)/2
+ else
+ upper = (upper+lower)/2
+ end
+ end
+ upper = -upper if neg
+ return upper
+ else
+ src = %{#{COMMON_HEADERS}
+#{headers}
+#include <stdio.h>
+/*top*/
+int main() {printf("%d\\n", (int)(#{const})); return 0;}
+}
+ if try_link0(src, opt, &b)
+ xpopen("./conftest") do |f|
+ return Integer(f.gets)
+ end
+ end
+ end
+ nil
+end
+
+def try_func(func, libs, headers = nil, &b)
+ headers = cpp_include(headers)
+ try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
+#{headers}
+/*top*/
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
- unless r
- r = try_link(<<"SRC", libs)
-#include <windows.h>
-#include <winsock.h>
+#{COMMON_HEADERS}
+#{headers}
+/*top*/
int main() { return 0; }
-int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
+int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
SRC
- end
+end
+
+def egrep_cpp(pat, src, opt = "", &b)
+ src = create_tmpsrc(src, &b)
+ xpopen(cpp_command('', opt)) do |f|
+ if Regexp === pat
+ puts(" ruby -ne 'print if #{pat.inspect}'")
+ f.grep(pat) {|l|
+ puts "#{f.lineno}: #{l}"
+ return true
+ }
+ false
else
- r = try_link(<<"SRC", libs)
-int main() { return 0; }
-int t() { #{func}(); return 0; }
+ puts(" egrep '#{pat}'")
+ begin
+ stdin = $stdin.dup
+ $stdin.reopen(f)
+ system("egrep", pat)
+ ensure
+ $stdin.reopen(stdin)
+ end
+ end
+ end
+ensure
+ rm_f "conftest*"
+ log_src(src)
+end
+
+def macro_defined?(macro, src, opt = "", &b)
+ src = src.sub(/[^\n]\z/, "\\&\n")
+ try_cpp(src + <<"SRC", opt, &b)
+/*top*/
+#ifndef #{macro}
+# error
+#endif
SRC
+end
+
+def try_run(src, opt = "", &b)
+ if try_link0(src, opt, &b)
+ xsystem("./conftest")
+ else
+ nil
+ end
+ensure
+ rm_f "conftest*"
+end
+
+def install_files(mfile, ifiles, map = nil, srcprefix = nil)
+ ifiles or return
+ srcprefix ||= '$(srcdir)'
+ Config::expand(srcdir = srcprefix.dup)
+ dirs = []
+ path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]}
+ ifiles.each do |files, dir, prefix|
+ dir = map_dir(dir, map)
+ prefix = %r|\A#{Regexp.quote(prefix)}/?| if prefix
+ if( files[0,2] == "./" )
+ # install files which are in current working directory.
+ files = files[2..-1]
+ len = nil
+ else
+ # install files which are under the $(srcdir).
+ files = File.join(srcdir, files)
+ len = srcdir.size
end
- unless r
- print "no\n"
- return false
+ f = nil
+ Dir.glob(files) do |f|
+ f[0..len] = "" if len
+ d = File.dirname(f)
+ d.sub!(prefix, "") if prefix
+ d = (d.empty? || d == ".") ? dir : File.join(dir, d)
+ f = File.join(srcprefix, f) if len
+ path[d] << f
+ end
+ unless len or f
+ d = File.dirname(files)
+ d.sub!(prefix, "") if prefix
+ d = (d.empty? || d == ".") ? dir : File.join(dir, d)
+ path[d] << files
end
- else
- libs = append_library($libs, lib)
end
+ dirs
+end
- $libs = libs
- print "yes\n"
- return true
+def install_rb(mfile, dest, srcdir = nil)
+ install_files(mfile, [["lib/**/*.rb", dest, "lib"]], nil, srcdir)
end
-def find_library(lib, func, *paths)
- printf "checking for %s() in -l%s... ", func, lib
- STDOUT.flush
+def append_library(libs, lib)
+ format(LIBARG, lib) + " " + libs
+end
- libpath = $LIBPATH
- libs = append_library($libs, lib)
- until try_link(<<"SRC", libs)
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- if paths.size == 0
- $LIBPATH = libpath
- print "no\n"
- return false
+def message(*s)
+ unless $extmk and not $VERBOSE
+ printf(*s)
+ $stdout.flush
+ end
+end
+
+def checking_for(m)
+ f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
+ m = "checking for #{m}... "
+ message "%s", m
+ a = r = nil
+ Logging::postpone do
+ r = yield
+ a = r ? "yes\n" : "no\n"
+ "#{f}#{m}-------------------- #{a}\n"
+ end
+ message(a)
+ Logging::message "--------------------\n\n"
+ r
+end
+
+def have_library(lib, func = nil, header=nil, &b)
+ func = "main" if !func or func.empty?
+ lib = with_config(lib+'lib', lib)
+ checking_for "#{func}() in #{LIBARG%lib}" do
+ if COMMON_LIBS.include?(lib)
+ true
+ else
+ libs = append_library($libs, lib)
+ if try_func(func, libs, header, &b)
+ $libs = libs
+ true
+ else
+ false
+ end
end
- $LIBPATH = libpath | [paths.shift]
end
- $libs = libs
- print "yes\n"
- return true
end
-def have_func(func, header=nil)
- printf "checking for %s()... ", func
- STDOUT.flush
+def find_library(lib, func, *paths, &b)
+ func = "main" if !func or func.empty?
+ lib = with_config(lib+'lib', lib)
+ checking_for "#{func}() in #{LIBARG%lib}" do
+ libpath = $LIBPATH
+ libs = append_library($libs, lib)
+ begin
+ until r = try_func(func, libs, &b) or paths.empty?
+ $LIBPATH = libpath | [paths.shift]
+ end
+ if r
+ $libs = libs
+ libpath = nil
+ end
+ ensure
+ $LIBPATH = libpath if libpath
+ end
+ r
+ end
+end
- libs = $libs
- src =
- if /mswin32|mingw/ =~ RUBY_PLATFORM
- r = <<"SRC"
-#include <windows.h>
-#include <winsock.h>
-SRC
+def have_func(func, headers = nil, &b)
+ checking_for "#{func}()" do
+ if try_func(func, $libs, headers, &b)
+ $defs.push(format("-DHAVE_%s", func.upcase))
+ true
else
- ""
+ false
+ end
+ end
+end
+
+def have_header(header, &b)
+ checking_for header do
+ if try_cpp(cpp_include(header), &b)
+ $defs.push(format("-DHAVE_%s", header.tr("a-z./\055", "A-Z___")))
+ true
+ else
+ false
end
- unless header.nil?
- src << <<"SRC"
-#include <#{header}>
-SRC
end
- r = try_link(src + <<"SRC", libs)
+end
+
+def have_struct_member(type, member, header = nil, &b)
+ checking_for "#{type}.#{member}" do
+ if try_compile(<<"SRC", &b)
+#{COMMON_HEADERS}
+#{cpp_include(header)}
+/*top*/
int main() { return 0; }
-int t() { #{func}(); return 0; }
+int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
SRC
- unless r
- r = try_link(src + <<"SRC", libs)
-int main() { return 0; }
-int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
+ $defs.push(format("-DHAVE_ST_%s", member.upcase))
+ true
+ else
+ false
+ end
+ end
+end
+
+def have_type(type, header = nil, opt = "", &b)
+ checking_for type do
+ header = cpp_include(header)
+ if try_compile(<<"SRC", opt, &b) or (/\A\w+\z/n =~ type && try_compile(<<"SRC", opt, &b))
+#{COMMON_HEADERS}
+#{header}
+/*top*/
+static #{type} t;
SRC
+#{COMMON_HEADERS}
+#{header}
+/*top*/
+static #{type} *t;
+SRC
+ $defs.push(format("-DHAVE_TYPE_%s", type.strip.upcase.tr_s("^A-Z0-9_", "_")))
+ true
+ else
+ false
+ end
end
- unless r
- print "no\n"
- return false
+end
+
+def check_sizeof(type, header = nil, &b)
+ expr = "sizeof(#{type})"
+ m = "checking size of #{type}... "
+ message "%s", m
+ Logging::message "check_sizeof: %s--------------------\n", m
+ if size = try_constant(expr, header, &b)
+ $defs.push(format("-DSIZEOF_%s=%d", type.upcase.tr_s("^A-Z0-9_", "_"), size))
end
- $defs.push(format("-DHAVE_%s", func.upcase))
- print "yes\n"
- return true
+ message(a = size ? "#{size}\n" : "failed\n")
+ Logging::message "-------------------- %s\n", a
+ size
end
-def have_header(header)
- printf "checking for %s... ", header
- STDOUT.flush
+def find_executable0(bin, path = nil)
+ path = (path || ENV['PATH']).split(File::PATH_SEPARATOR)
+ ext = config_string('EXEEXT')
+ file = nil
+ path.each do |dir|
+ return file if File.executable?(file = File.join(dir, bin))
+ return file if ext and File.executable?(file << ext)
+ end
+ nil
+end
- unless try_cpp(<<"SRC")
-#include <#{header}>
-SRC
- print "no\n"
- return false
+def find_executable(bin, path = nil)
+ checking_for bin do
+ find_executable0(bin, path)
end
- header.tr!("a-z./\055", "A-Z___")
- $defs.push(format("-DHAVE_%s", header))
- print "yes\n"
- return true
end
def arg_config(config, default=nil)
- unless defined? $configure_args
- $configure_args = {}
- for arg in CONFIG["configure_args"].split + ARGV
- next unless /^--/ =~ arg
- if /=/ =~ arg
- $configure_args[$`] = $'
- else
- $configure_args[arg] = true
- end
- end
- end
- $configure_args.fetch(config, default)
+ $configure_args.fetch(config.tr('_', '-'), default)
end
def with_config(config, default=nil)
- unless /^--with-/ =~ config
+ unless /^--with[-_]/ =~ config
config = '--with-' + config
end
arg_config(config, default)
end
def enable_config(config, default=nil)
- if arg_config("--enable-"+config, default)
+ if arg_config("--enable-"+config)
true
- elsif arg_config("--disable-"+config, false)
+ elsif arg_config("--disable-"+config)
false
else
default
end
end
-def create_header()
- print "creating extconf.h\n"
- STDOUT.flush
+def create_header(header = "extconf.h")
+ message "creating %s\n", header
if $defs.length > 0
- hfile = open("extconf.h", "w")
- for line in $defs
- line =~ /^-D(.*)/
- hfile.printf "#define %s 1\n", $1
+ sym = header.tr("a-z./\055", "A-Z___")
+ open(header, "w") do |hfile|
+ hfile.print "#ifndef #{sym}\n#define #{sym}\n"
+ for line in $defs
+ case line
+ when /^-D([^=]+)(?:=(.*))?/
+ hfile.print "#define #$1 #{$2 || 1}\n"
+ when /^-U(.*)/
+ hfile.print "#undef #$1\n"
+ end
+ end
+ hfile.print "#endif\n"
end
- hfile.close
end
end
def dir_config(target, idefault=nil, ldefault=nil)
- if idefault && ldefault == nil
- default = idefault
- idefault = default + "/include"
- ldefault = default + "/lib"
+ if dir = with_config(target + "-dir", (idefault unless ldefault))
+ defaults = dir.split(File::PATH_SEPARATOR)
+ idefault = ldefault = nil
end
- dir = with_config("%s-dir"%target, default)
- if dir
- idir = " -I"+dir+"/include"
- ldir = dir+"/lib"
+
+ idir = with_config(target + "-include", idefault)
+ ldir = with_config(target + "-lib", ldefault)
+
+# idirs = idir ? idir.split(File::PATH_SEPARATOR) : []
+ idirs = idir.split(File::PATH_SEPARATOR) rescue []
+ if defaults
+ idirs.concat(defaults.collect {|dir| dir + "/include"})
+ idir = ([idir] + idirs).compact.join(File::PATH_SEPARATOR)
end
- unless idir
- dir = with_config("%s-include"%target, idefault)
- idir = " -I"+dir if dir
+ unless idirs.empty?
+ idirs.collect! {|dir| "-I" + dir}
+ idirs -= Shellwords.shellwords($CPPFLAGS)
+ unless idirs.empty?
+ $CPPFLAGS = (idirs.quote << $CPPFLAGS).join(" ")
+ end
end
- unless ldir
- ldir = with_config("%s-lib"%target, ldefault)
+
+ ldirs = ldir ? ldir.split(File::PATH_SEPARATOR) : []
+ if defaults
+ ldirs.concat(defaults.collect {|dir| dir + "/lib"})
+ ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR)
end
+ $LIBPATH = ldirs | $LIBPATH
- $CPPFLAGS += idir if idir
- $LIBPATH |= [ldir] if ldir
+ [idir, ldir]
end
-def create_makefile(target, srcdir = File.dirname($0))
- save_libs = $libs.dup
- save_libpath = $LIBPATH.dup
- print "creating Makefile\n"
- rm_f "conftest*"
- STDOUT.flush
- if target.rindex(%r!/!) #/
- target = $'
- target_prefix = "/"+$`
- else
- target_prefix = ""
- end
- if CONFIG["DLEXT"] == $OBJEXT
- libs = $libs.split
- for lib in libs
- lib.sub!(/-l(.*)/, '"lib\1.a"')
+def pkg_config(pkg)
+ unless defined?($PKGCONFIG)
+ if pkgconfig = with_config("pkg-config", !CROSS_COMPILING && "pkg-config")
+ find_executable0(pkgconfig) or pkgconfig = nil
end
- $defs.push(format("-DEXTLIB='%s'", libs.join(",")))
+ $PKGCONFIG = pkgconfig
end
- $DLDFLAGS = CONFIG["DLDFLAGS"]
+ if $PKGCONFIG and system("#{$PKGCONFIG} --exists #{pkg}")
+ cflags = `#{$PKGCONFIG} --cflags #{pkg}`.chomp
+ ldflags = `#{$PKGCONFIG} --libs #{pkg}`.chomp
+ libs = `#{$PKGCONFIG} --libs-only-l #{pkg}`.chomp
+ ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ")
+ $CFLAGS += " " << cflags
+ $LDFLAGS += " " << ldflags
+ $libs += " " << libs
+ Logging::message "package configuration for %s\n", pkg
+ Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n",
+ cflags, ldflags, libs
+ [cflags, ldflags, libs]
+ end
+end
- $libs = CONFIG["LIBRUBYARG"] + " " + $libs
- $configure_args['--enable-shared'] or $LIBPATH |= [$topdir]
- $LIBPATH |= [CONFIG["libdir"]]
+def with_destdir(dir)
+ /^\$[\(\{]/ =~ dir ? dir : "$(DESTDIR)"+dir
+end
+
+def winsep(s)
+ s.tr('/', '\\')
+end
- defflag = ''
- if RUBY_PLATFORM =~ /cygwin|mingw/
- if not File.exist? target + '.def'
- open(target + '.def', 'wb') do |f|
- f.print "EXPORTS\n", "Init_", target, "\n"
+def configuration(srcdir)
+ mk = []
+ mk << %{
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = #{srcdir}
+topdir = #{$topdir}
+hdrdir = #{$extmk ? $hdrdir : '$(topdir)'}
+VPATH = #{$mingw && CONFIG['build_os'] == 'cygwin' ? '$(shell cygpath -u $(srcdir))' : '$(srcdir)'}
+}
+ drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/
+ if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty?
+ mk << "\nDESTDIR = #{destdir}\n"
+ end
+ CONFIG.each do |key, var|
+ next unless /prefix$/ =~ key
+ mk << "#{key} = #{with_destdir(var.sub(drive, ''))}\n"
+ end
+ CONFIG.each do |key, var|
+ next if /^abs_/ =~ key
+ next unless /^(?:src|top|(.*))dir$/ =~ key and $1
+ mk << "#{key} = #{with_destdir(var.sub(drive, ''))}\n"
+ end
+ mk << %{
+CC = #{CONFIG['CC']}
+LIBRUBY = #{CONFIG['LIBRUBY']}
+LIBRUBY_A = #{CONFIG['LIBRUBY_A']}
+LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
+LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC
+
+CFLAGS = #{CONFIG['CCDLFLAGS'] unless $static} #$CFLAGS #$ARCH_FLAG
+CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{$CPPFLAGS}
+CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']}
+DLDFLAGS = #$LDFLAGS #$DLDFLAGS #$ARCH_FLAG
+LDSHARED = #{CONFIG['LDSHARED']}
+AR = #{CONFIG['AR']}
+EXEEXT = #{CONFIG['EXEEXT']}
+
+RUBY_INSTALL_NAME = #{CONFIG['RUBY_INSTALL_NAME']}
+RUBY_SO_NAME = #{CONFIG['RUBY_SO_NAME']}
+arch = #{CONFIG['arch']}
+sitearch = #{CONFIG['sitearch']}
+ruby_version = #{Config::CONFIG['ruby_version']}
+ruby = #{$ruby}
+RUBY = #{($nmake && !$extmk && !$configure_args.has_key?('--ruby')) ? '$(ruby:/=\)' : '$(ruby)'}
+RM = $(RUBY) -run -e rm -- -f
+MAKEDIRS = $(RUBY) -run -e mkdir -- -p
+INSTALL_PROG = $(RUBY) -run -e install -- -vpm 0755
+INSTALL_DATA = $(RUBY) -run -e install -- -vpm 0644
+
+#### End of system configuration section. ####
+
+}
+ if $nmake == ?b
+ mk.each do |x|
+ x.gsub!(/^(MAKEDIRS|INSTALL_(?:PROG|DATA))+\s*=.*\n/) do
+ "!ifndef " + $1 + "\n" +
+ $& +
+ "!endif\n"
end
end
- defflag = "--def=" + target + ".def"
+ end
+ mk
+end
+
+def dummy_makefile(srcdir)
+ configuration(srcdir) << "all install: Makefile\n" << CLEANINGS
+end
+
+def create_makefile(target, srcprefix = nil)
+ $target = target
+ libpath = $LIBPATH
+ message "creating Makefile\n"
+ rm_f "conftest*"
+ if CONFIG["DLEXT"] == $OBJEXT
+ for lib in libs = $libs.split
+ lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
+ end
+ $defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end
- if RUBY_PLATFORM =~ /mswin32/
- libpath = $LIBPATH.join(';')
+ if target.include?('/')
+ target_prefix, target = File.split(target)
+ target_prefix[0,0] = '/'
else
- $LIBPATH.each {|d| $DLDFLAGS << " -L" << d}
+ target_prefix = ""
end
- drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/
+
+ srcprefix ||= '$(srcdir)'
+ Config::expand(srcdir = srcprefix.dup)
unless $objs then
$objs = []
- for f in Dir[File.join(srcdir || ".", "*.{#{SRC_EXT.join(%q{,})}}")]
- f = File.basename(f)
- f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT)
- $objs.push f
+ for f in Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+ $objs.push(File.basename(f, ".*") << "." << $OBJEXT)
end
else
for i in $objs
@@ -409,192 +812,243 @@ def create_makefile(target, srcdir = File.dirname($0))
end
$objs = $objs.join(" ")
- mfile = open("Makefile", "w")
- mfile.binmode if /mingw/ =~ RUBY_PLATFORM
- mfile.print <<EOMF
-SHELL = /bin/sh
-
-#### Start of system configuration section. ####
+ target = nil if $objs == ""
-srcdir = #{srcdir || $srcdir}
-topdir = #{$topdir}
-hdrdir = #{$hdrdir}
-VPATH = $(srcdir)
+ if target and EXPORT_PREFIX
+ if File.exist?(File.join(srcdir, target + '.def'))
+ deffile = "$(srcdir)/$(TARGET).def"
+ unless EXPORT_PREFIX.empty?
+ makedef = %{-pe "sub!(/^(?=\\w)/,'#{EXPORT_PREFIX}') unless 1../^EXPORTS$/i"}
+ end
+ else
+ makedef = %{-e "puts 'EXPORTS', '#{EXPORT_PREFIX}Init_$(TARGET)'"}
+ end
+ if makedef
+ $distcleanfiles << '$(DEFFILE)'
+ origdef = deffile
+ deffile = "$(TARGET)-$(arch).def"
+ end
+ end
-CC = #{CONFIG["CC"]}
+ libpath = libpathflag(libpath)
-CFLAGS = #{CONFIG["CCDLFLAGS"]} #{CFLAGS} #{$CFLAGS}
-CPPFLAGS = -I$(hdrdir) -I#{CONFIG["includedir"]} #{$defs.join(" ")} #{CONFIG["CPPFLAGS"]} #{$CPPFLAGS}
-CXXFLAGS = $(CFLAGS)
-DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS}
-LDSHARED = #{CONFIG["LDSHARED"]} #{defflag}
+ dllib = target ? "$(TARGET).#{CONFIG['DLEXT']}" : ""
+ staticlib = target ? "$(TARGET).#$LIBEXT" : ""
+ mfile = open("Makefile", "wb")
+ mfile.print configuration(srcdir)
+ mfile.print %{
LIBPATH = #{libpath}
+DEFFILE = #{deffile}
-RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]}
-RUBY_SO_NAME = #{CONFIG["RUBY_SO_NAME"]}
-#{
-if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty?
- "\nDESTDIR = " + destdir
-else
- ""
-end
-}
-prefix = $(DESTDIR)#{CONFIG["prefix"].sub(drive, '')}
-exec_prefix = $(DESTDIR)#{CONFIG["exec_prefix"].sub(drive, '')}
-libdir = $(DESTDIR)#{$libdir.sub(drive, '')}#{target_prefix}
-archdir = $(DESTDIR)#{$archdir.sub(drive, '')}#{target_prefix}
-sitelibdir = $(DESTDIR)#{$sitelibdir.sub(drive, '')}#{target_prefix}
-sitearchdir = $(DESTDIR)#{$sitearchdir.sub(drive, '')}#{target_prefix}
-
-#### End of system configuration section. ####
+CLEANFILES = #{$cleanfiles.join(' ')}
+DISTCLEANFILES = #{$distcleanfiles.join(' ')}
-LOCAL_LIBS = #{$LOCAL_LIBS} #{$local_flags}
-LIBS = #{$libs}
+target_prefix = #{target_prefix}
+LOCAL_LIBS = #{$LOCAL_LIBS}
+LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS}
OBJS = #{$objs}
-
TARGET = #{target}
-DLLIB = $(TARGET).#{CONFIG["DLEXT"]}
-
-RUBY = #{CONFIG["ruby_install_name"]}
-RM = $(RUBY) -r ftools -e 'File::rm_f(*Dir[ARGV.join(" ")])'
+DLLIB = #{dllib}
+STATIC_LIB = #{staticlib}
+}
+ if $extmk
+ mfile.print %{
+RUBYCOMMONDIR = $(rubylibdir)
+RUBYLIBDIR = $(rubylibdir)$(target_prefix)
+RUBYARCHDIR = $(archdir)$(target_prefix)
+}
+ else
+ mfile.print %{
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR = $(sitearchdir)$(target_prefix)
+}
+ end
+ mfile.print %{
+CLEANLIBS = "$(TARGET).{lib,exp,il?,tds,map}" $(DLLIB)
+CLEANOBJS = "*.{#{$OBJEXT},#{$LIBEXT},s[ol],pdb,bak}"
-EXEEXT = #{CONFIG["EXEEXT"]}
+all: #{target ? "$(DLLIB)" : "Makefile"}
+static: $(STATIC_LIB)
+}
+ mfile.print CLEANINGS
+ dirs = []
+ if not $static and target
+ dirs << (dir = "$(RUBYARCHDIR)")
+ mfile.print("install: #{dir}\n")
+ f = "$(DLLIB)"
+ dest = "#{dir}/#{f}"
+ mfile.print "install: #{dest}\n"
+ mfile.print "#{dest}: #{f} #{dir}\n\t@$(INSTALL_PROG) #{f} #{dir}\n"
+ end
+ for i in [[["lib/**/*.rb", "$(RUBYLIBDIR)", "lib"]], $INSTALLFILES]
+ files = install_files(mfile, i, nil, srcprefix) or next
+ for dir, *files in files
+ unless dirs.include?(dir)
+ dirs << dir
+ mfile.print("install: #{dir}\n")
+ end
+ files.each do |f|
+ dest = "#{dir}/#{File.basename(f)}"
+ mfile.print("install: #{dest}\n")
+ mfile.print("#{dest}: #{f} #{dir}\n\t@$(INSTALL_DATA) #{f} #{dir}\n")
+ end
+ end
+ end
+ if dirs.empty?
+ mfile.print("install:\n")
+ else
+ dirs.each {|dir| mfile.print "#{dir}:\n\t@$(MAKEDIRS) #{dir}\n"}
+ end
-all: $(DLLIB)
+ mfile.print "\nsite-install: install\n\n"
-clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB)
- @$(RM) $(TARGET).lib $(TARGET).exp $(TARGET).ilk *.pdb
+ return unless target
-distclean: clean
- @$(RM) Makefile extconf.h conftest.*
- @$(RM) core ruby$(EXEEXT) *~
+ mfile.print ".SUFFIXES: .#{SRC_EXT.join(' .')} .#{$OBJEXT}\n"
+ mfile.print "\n"
-realclean: distclean
+ %w[cc cpp cxx C].each do |ext|
+ COMPILE_RULES.each do |rule|
+ mfile.printf(rule, ext, $OBJEXT)
+ mfile.printf("\n\t%s\n\n", COMPILE_CXX)
+ end
+ end
+ %w[c].each do |ext|
+ COMPILE_RULES.each do |rule|
+ mfile.printf(rule, ext, $OBJEXT)
+ mfile.printf("\n\t%s\n\n", COMPILE_C)
+ end
+ end
-install: $(archdir)/$(DLLIB)
-
-site-install: $(sitearchdir)/$(DLLIB)
-
-$(archdir)/$(DLLIB): $(DLLIB)
- @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir) $(archdir)
- @$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(archdir)/$(DLLIB)
-EOMF
- install_rb(mfile, "$(libdir)", srcdir)
- mfile.printf "\n"
-
- mfile.printf <<EOMF
-$(sitearchdir)/$(DLLIB): $(DLLIB)
- @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir) $(sitearchdir)
- @$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(sitearchdir)/$(DLLIB)
-EOMF
- install_rb(mfile, "$(sitelibdir)", srcdir)
- mfile.printf "\n"
-
- if /mswin32/ !~ RUBY_PLATFORM
- mfile.print "
-.c.#{$OBJEXT}:
- $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
-
-.cc.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
-.cpp.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
-.cxx.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
-.C.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
-"
- elsif /nmake/i =~ $make
- mfile.print "
-{$(srcdir)}.c.#{$OBJEXT}:
- $(CC) $(CFLAGS) -I$(<D) $(CPPFLAGS) -c $(<:/=\\)
-.c.#{$OBJEXT}:
- $(CC) $(CFLAGS) -I$(<D) $(CPPFLAGS) -c $(<:/=\\)
-
-{$(srcdir)}.cc{}.#{$OBJEXT}:
- $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-.cc.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-{$(srcdir)}.cpp{}.#{$OBJEXT}:
- $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-.cpp.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-{$(srcdir)}.cxx{}.#{$OBJEXT}:
- $(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-.cxx.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<:/=\\)
-"
+ if makedef
+ mfile.print "$(DLLIB): $(OBJS) $(DEFFILE)\n\t"
else
- mfile.print "
-.SUFFIXES: .#{$OBJEXT}
-
-.c.#{$OBJEXT}:
- $(CC) $(CFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
-
-.cc.#{$OBJEXT} .cpp.#{$OBJEXT} .cxx.#{$OBJEXT} .C.#{$OBJEXT}:
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(subst /,\\\\,$<)
-"
+ mfile.print "$(DLLIB): $(OBJS)\n\t"
+ end
+ mfile.print "@-$(RM) $@\n\t"
+ mfile.print "@-$(RM) $(TARGET).lib\n\t" if $mswin
+ mfile.print LINK_SO, "\n\n"
+ mfile.print "$(STATIC_LIB): $(OBJS)\n\t"
+ mfile.print "$(AR) #{config_string('ARFLAGS') || 'cru '}$@ $(OBJS)"
+ if ranlib = config_string('RANLIB')
+ mfile.print "\n\t@-#{ranlib} $(DLLIB) 2> /dev/null || true"
+ end
+ mfile.print "\n\n"
+ if makedef
+ mfile.print "$(DEFFILE): #{origdef}\n"
+ mfile.print "\t$(RUBY) #{makedef} #{origdef} > $@\n\n"
end
- if CONFIG["DLEXT"] != $OBJEXT
- mfile.print "$(DLLIB): $(OBJS)\n"
- if /mswin32/ =~ RUBY_PLATFORM
- if /nmake/i =~ $make
- mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n"
- else
- mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n"
+ depend = File.join(srcdir, "depend")
+ if File.exist?(depend)
+ open(depend, "r") do |dfile|
+ mfile.printf "###\n"
+ while line = dfile.gets()
+ line.gsub!(/\.o\b/, ".#{$OBJEXT}")
+ line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if $nmake
+ line.gsub!(/\$\(hdrdir\)\/config.h/, $config_h) if $config_h
+ mfile.print line
end
end
- mfile.print "\t$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n"
- elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
- mfile.print "$(DLLIB): $(OBJS)\n"
- case RUBY_PLATFORM
- when "m68k-human"
- mfile.printf "ar cru $(DLLIB) $(OBJS)\n"
- else
- mfile.printf "ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)\n"
- end
end
+ensure
+ mfile.close if mfile
+end
- if File.exist?("depend")
- dfile = open("depend", "r")
- mfile.printf "###\n"
- while line = dfile.gets()
- mfile.printf "%s", line.gsub(/\.o\b/, ".#{$OBJEXT}")
- end
- dfile.close
+def init_mkmf(config = CONFIG)
+ $enable_shared = config['ENABLE_SHARED'] == 'yes'
+ $defs = []
+ $CFLAGS = with_config("cflags", arg_config("CFLAGS", config["CFLAGS"])).dup
+ $ARCH_FLAG = with_config("arch_flag", arg_config("ARCH_FLAG", config["ARCH_FLAG"])).dup
+ $CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", config["CPPFLAGS"])).dup
+ $LDFLAGS = (with_config("ldflags") || "").dup
+ $INCFLAGS = "-I$(topdir)"
+ $DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
+ $LIBEXT = config['LIBEXT'].dup
+ $OBJEXT = config["OBJEXT"].dup
+ $LIBS = "#{config['LIBS']} #{config['DLDLIBS']}"
+ $LIBRUBYARG = ""
+ $LIBRUBYARG_STATIC = config['LIBRUBYARG_STATIC']
+ $LIBRUBYARG_SHARED = config['LIBRUBYARG_SHARED']
+ $LIBPATH = $extmk ? ["$(topdir)"] : CROSS_COMPILING ? [] : ["$(libdir)"]
+ $INSTALLFILES = nil
+
+ $objs = nil
+ $libs = ""
+ if $enable_shared or Config.expand(config["LIBRUBY"].dup) != Config.expand(config["LIBRUBY_A"].dup)
+ $LIBRUBYARG = config['LIBRUBYARG']
end
- mfile.close
- $libs = save_libs
- $LIBPATH = save_libpath
-end
-$OBJEXT = CONFIG["OBJEXT"]
-$objs = nil
-$libs = CONFIG["DLDLIBS"]
-$local_flags = ""
-case RUBY_PLATFORM
-when /mswin32/
- $local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)"
+ $LOCAL_LIBS = ""
+
+ $cleanfiles = []
+ $distcleanfiles = []
+
+ dir_config("opt")
end
-$LOCAL_LIBS = ""
-$defs = []
+
+init_mkmf
$make = with_config("make-prog", ENV["MAKE"] || "make")
-dir = with_config("opt-dir")
-if dir
- idir = "-I"+dir+"/include"
- ldir = dir+"/lib"
+make, = Shellwords.shellwords($make)
+$nmake = nil
+case
+when $mswin
+ $nmake = ?m if /nmake/i =~ make
+when $bccwin
+ $nmake = ?b if /Borland/i =~ `#{make} -h`
end
-unless idir
- dir = with_config("opt-include")
- idir = "-I"+dir if dir
+
+Config::CONFIG["srcdir"] = CONFIG["srcdir"] =
+ $srcdir = arg_config("--srcdir", File.dirname($0))
+$configure_args["--topsrcdir"] ||= $srcdir
+Config::CONFIG["topdir"] = CONFIG["topdir"] =
+ $curdir = arg_config("--curdir", Dir.pwd)
+$configure_args["--topdir"] ||= $curdir
+$ruby = arg_config("--ruby", File.join(Config::CONFIG["bindir"], CONFIG["ruby_install_name"]))
+
+split = Shellwords.method(:shellwords).to_proc
+
+EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip}
+
+hdr = []
+config_string('COMMON_MACROS') do |s|
+ Shellwords.shellwords(s).each do |s|
+ /(.*?)(?:=(.*))/ =~ s
+ hdr << "#define #$1 #$2"
+ end
end
-unless ldir
- ldir = with_config("opt-lib")
+config_string('COMMON_HEADERS') do |s|
+ Shellwords.shellwords(s).each {|s| hdr << "#include <#{s}>"}
end
+COMMON_HEADERS = (hdr.join("\n") unless hdr.empty?)
+COMMON_LIBS = config_string('COMMON_LIBS', &split) || []
+
+COMPILE_RULES = config_string('COMPILE_RULES', &split) || %w[.%s.%s:]
+COMPILE_C = config_string('COMPILE_C') || '$(CC) $(CFLAGS) $(CPPFLAGS) -c $<'
+COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<'
+TRY_LINK = config_string('TRY_LINK') ||
+ "$(CC) #{OUTFLAG}conftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) " \
+ "$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
+LINK_SO = config_string('LINK_SO') ||
+ if CONFIG["DLEXT"] == $OBJEXT
+ "ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)\n"
+ else
+ "$(LDSHARED) $(DLDFLAGS) $(LIBPATH) #{OUTFLAG}$(DLLIB) " \
+ "$(OBJS) $(LOCAL_LIBS) $(LIBS)"
+ end
+LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
+RPATHFLAG = config_string('RPATHFLAG') || ''
+LIBARG = config_string('LIBARG') || '-l%s'
+
+CLEANINGS = "
+clean:
+ @$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
-$CFLAGS = with_config("cflags", "")
-$CPPFLAGS = [with_config("cppflags", ""), idir].compact.join(" ")
-$LDFLAGS = with_config("ldflags", "")
-$LIBPATH = [ldir].compact
+distclean: clean
+ @$(RM) Makefile extconf.h conftest.* mkmf.log
+ @$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+
+realclean: distclean
+"
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 721c51a9f5..a573af2bae 100644
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -42,73 +42,72 @@ empty_cond.signal.
=end
+
+#
+# Adds monitor functionality to an arbitrary object by mixing the module with
+# +include+. For example:
+#
+# require 'monitor.rb'
+#
+# buf = []
+# buf.extend(MonitorMixin)
+# empty_cond = buf.new_cond
+#
+# # consumer
+# Thread.start do
+# loop do
+# buf.synchronize do
+# empty_cond.wait_while { buf.empty? }
+# print buf.shift
+# end
+# end
+# end
+#
+# # producer
+# while line = ARGF.gets
+# buf.synchronize do
+# buf.push(line)
+# empty_cond.signal
+# end
+# end
+#
+# The consumer thread waits for the producer thread to push a line
+# to buf while buf.empty?, and the producer thread (main thread)
+# reads a line from ARGF and push it to buf, then call
+# empty_cond.signal.
+#
module MonitorMixin
- module Accessible
- protected
- attr_accessor :mon_owner, :mon_count
- attr_reader :mon_entering_queue, :mon_waiting_queue
- end
-
- module Initializable
- protected
- def mon_initialize
- @mon_owner = nil
- @mon_count = 0
- @mon_entering_queue = []
- @mon_waiting_queue = []
- end
- end
-
+ #
+ # FIXME: This isn't documented in Nutshell.
+ #
+ # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
+ # above calls while_wait and signal, this class should be documented.
+ #
class ConditionVariable
class Timeout < Exception; end
- include Accessible
-
def wait(timeout = nil)
- if @monitor.mon_owner != Thread.current
- raise ThreadError, "current thread not owner"
- end
+ @monitor.__send__(:mon_check_owner)
+ timer = create_timer(timeout)
- if timeout
- ct = Thread.current
- timeout_thread = Thread.start {
- Thread.pass
- sleep(timeout)
- ct.raise(Timeout.new)
- }
- end
-
Thread.critical = true
- count = @monitor.mon_count
- @monitor.mon_count = 0
- @monitor.mon_owner = nil
- if @monitor.mon_waiting_queue.empty?
- t = @monitor.mon_entering_queue.shift
- else
- t = @monitor.mon_waiting_queue.shift
- end
- t.wakeup if t
+ count = @monitor.__send__(:mon_exit_for_cond)
@waiters.push(Thread.current)
begin
Thread.stop
+ return true
rescue Timeout
+ return false
ensure
Thread.critical = true
- if timeout && timeout_thread.alive?
- Thread.kill(timeout_thread)
+ if timer && timer.alive?
+ Thread.kill(timer)
end
if @waiters.include?(Thread.current) # interrupted?
@waiters.delete(Thread.current)
end
- while @monitor.mon_owner &&
- @monitor.mon_owner != Thread.current
- @monitor.mon_waiting_queue.push(Thread.current)
- Thread.stop
- Thread.critical = true
- end
- @monitor.mon_owner = Thread.current
- @monitor.mon_count = count
+ @monitor.__send__(:mon_enter_for_cond, count)
Thread.critical = false
end
end
@@ -126,9 +125,7 @@ module MonitorMixin
end
def signal
- if @monitor.mon_owner != Thread.current
- raise ThreadError, "current thread not owner"
- end
+ @monitor.__send__(:mon_check_owner)
Thread.critical = true
t = @waiters.shift
t.wakeup if t
@@ -137,9 +134,7 @@ module MonitorMixin
end
def broadcast
- if @monitor.mon_owner != Thread.current
- raise ThreadError, "current thread not owner"
- end
+ @monitor.__send__(:mon_check_owner)
Thread.critical = true
for t in @waiters
t.wakeup
@@ -153,67 +148,81 @@ module MonitorMixin
return @waiters.length
end
- private
+ private
+
def initialize(monitor)
@monitor = monitor
@waiters = []
end
+
+ def create_timer(timeout)
+ if timeout
+ waiter = Thread.current
+ return Thread.start {
+ Thread.pass
+ sleep(timeout)
+ Thread.critical = true
+ waiter.raise(Timeout.new)
+ }
+ else
+ return nil
+ end
+ end
end
- include Accessible
- include Initializable
- extend Initializable
-
def self.extend_object(obj)
super(obj)
- obj.mon_initialize
+ obj.__send__(:mon_initialize)
end
- def try_mon_enter
+ #
+ # Attempts to enter exclusive section. Returns +false+ if lock fails.
+ #
+ def mon_try_enter
result = false
Thread.critical = true
- if mon_owner.nil?
- self.mon_owner = Thread.current
+ if @mon_owner.nil?
+ @mon_owner = Thread.current
end
- if mon_owner == Thread.current
- self.mon_count += 1
+ if @mon_owner == Thread.current
+ @mon_count += 1
result = true
end
Thread.critical = false
return result
end
+ # For backward compatibility
+ alias try_mon_enter mon_try_enter
+ #
+ # Enters exclusive section.
+ #
def mon_enter
Thread.critical = true
- while mon_owner != nil && mon_owner != Thread.current
- mon_entering_queue.push(Thread.current)
- Thread.stop
- Thread.critical = true
- end
- self.mon_owner = Thread.current
- self.mon_count += 1
+ mon_acquire(@mon_entering_queue)
+ @mon_count += 1
Thread.critical = false
end
+ #
+ # Leaves exclusive section.
+ #
def mon_exit
- if mon_owner != Thread.current
- raise ThreadError, "current thread not owner"
- end
+ mon_check_owner
Thread.critical = true
- self.mon_count -= 1
- if mon_count == 0
- self.mon_owner = nil
- if mon_waiting_queue.empty?
- t = mon_entering_queue.shift
- else
- t = mon_waiting_queue.shift
- end
+ @mon_count -= 1
+ if @mon_count == 0
+ mon_release
end
- t.wakeup if t
Thread.critical = false
Thread.pass
end
+ #
+ # Enters exclusive section and executes the block. Leaves the exclusive
+ # section automatically when the block exits. See example under
+ # +MonitorMixin+.
+ #
def mon_synchronize
mon_enter
begin
@@ -224,15 +233,60 @@ module MonitorMixin
end
alias synchronize mon_synchronize
+ #
+ # FIXME: This isn't documented in Nutshell.
+ #
def new_cond
return ConditionVariable.new(self)
end
-
-private
+
+ private
+
def initialize(*args)
super
mon_initialize
end
+
+ def mon_initialize
+ @mon_owner = nil
+ @mon_count = 0
+ @mon_entering_queue = []
+ @mon_waiting_queue = []
+ end
+
+ def mon_check_owner
+ if @mon_owner != Thread.current
+ raise ThreadError, "current thread not owner"
+ end
+ end
+
+ def mon_acquire(queue)
+ while @mon_owner && @mon_owner != Thread.current
+ queue.push(Thread.current)
+ Thread.stop
+ Thread.critical = true
+ end
+ @mon_owner = Thread.current
+ end
+
+ def mon_release
+ @mon_owner = nil
+ t = @mon_waiting_queue.shift
+ t = @mon_entering_queue.shift unless t
+ t.wakeup if t
+ end
+
+ def mon_enter_for_cond(count)
+ mon_acquire(@mon_waiting_queue)
+ @mon_count = count
+ end
+
+ def mon_exit_for_cond
+ count = @mon_count
+ @mon_count = 0
+ mon_release
+ return count
+ end
end
class Monitor
@@ -240,9 +294,27 @@ class Monitor
alias try_enter try_mon_enter
alias enter mon_enter
alias exit mon_exit
- alias owner mon_owner
end
+
+# Documentation comments:
+# - All documentation comes from Nutshell.
+# - MonitorMixin.new_cond appears in the example, but is not documented in
+# Nutshell.
+# - All the internals (internal modules Accessible and Initializable, class
+# ConditionVariable) appear in RDoc. It might be good to hide them, by
+# making them private, or marking them :nodoc:, etc.
+# - The entire example from the RD section at the top is replicated in the RDoc
+# comment for MonitorMixin. Does the RD section need to remain?
+# - RDoc doesn't recognise aliases, so we have mon_synchronize documented, but
+# not synchronize.
+# - mon_owner is in Nutshell, but appears as an accessor in a separate module
+# here, so is hard/impossible to RDoc. Some other useful accessors
+# (mon_count and some queue stuff) are also in this module, and don't appear
+# directly in the RDoc output.
+# - in short, it may be worth changing the code layout in this file to make the
+# documentation easier
+
# Local variables:
# mode: Ruby
# tab-width: 8
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
index e0fcf0f209..0192d83bee 100644
--- a/lib/mutex_m.rb
+++ b/lib/mutex_m.rb
@@ -1,10 +1,12 @@
#
# mutex_m.rb -
-# $Release Version: 2.0$
+# $Release Version: 3.0$
# $Revision: 1.7 $
# $Date: 1998/02/27 04:28:57 $
# Original from mutex.rb
-# by Keiju ISHITSUKA(SHL Japan Inc.)
+# by Keiju ISHITSUKA(keiju@ishitsuka.com)
+# modified by matz
+# patched by akira yamada
#
# --
# Usage:
@@ -13,21 +15,29 @@
# obj.extend Mutex_m
# ...
# extended object can be handled like Mutex
+# or
+# class Foo
+# include Mutex_m
+# ...
+# end
+# obj = Foo.new
+# this obj can be handled like Mutex
#
module Mutex_m
+ def Mutex_m.define_aliases(cl)
+ cl.module_eval %q{
+ alias locked? mu_locked?
+ alias lock mu_lock
+ alias unlock mu_unlock
+ alias try_lock mu_try_lock
+ alias synchronize mu_synchronize
+ }
+ end
+
def Mutex_m.append_features(cl)
super
- unless cl.instance_of?(Module)
- cl.module_eval %q{
- alias locked? mu_locked?
- alias lock mu_lock
- alias unlock mu_unlock
- alias try_lock mu_try_lock
- alias synchronize mu_synchronize
- }
- end
- return self
+ define_aliases(cl) unless cl.instance_of?(Module)
end
def Mutex_m.extend_object(obj)
@@ -41,15 +51,9 @@ module Mutex_m
defined? unlock and
defined? try_lock and
defined? synchronize)
- eval "class << self
- alias locked? mu_locked?
- alias lock mu_lock
- alias unlock mu_unlock
- alias try_lock mu_try_lock
- alias synchronize mu_synchronize
- end"
+ Mutex_m.define_aliases(class<<self;self;end)
end
- initialize
+ mu_initialize
end
# locking
@@ -102,10 +106,13 @@ module Mutex_m
private
- def initialize(*args)
- ret = super
+ def mu_initialize
@mu_waiting = []
@mu_locked = false;
- return ret
+ end
+
+ def initialize(*args)
+ mu_initialize
+ super
end
end
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index 88361b9ddb..dfbcf1499f 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -1,44 +1,135 @@
-=begin
-
-= net/ftp.rb
-
-written by Shugo Maeda <shugo@ruby-lang.org>
-
-This library is distributed under the terms of the Ruby license.
-You can freely distribute/modify this library.
-
-=end
+#
+# = net/ftp.rb - FTP Client Library
+#
+# Written by Shugo Maeda <shugo@ruby-lang.org>.
+#
+# Documentation by Gavin Sinclair, sourced from "Programming Ruby" (Hunt/Thomas)
+# and "Ruby In a Nutshell" (Matsumoto), used with permission.
+#
+# This library is distributed under the terms of the Ruby license.
+# You can freely distribute/modify this library.
+#
+# It is included in the Ruby standard library.
+#
+# See the Net::FTP class for an overview.
+#
require "socket"
require "monitor"
module Net
+ # :stopdoc:
class FTPError < StandardError; end
class FTPReplyError < FTPError; end
- class FTPTempError < FTPError; end
- class FTPPermError < FTPError; end
+ class FTPTempError < FTPError; end
+ class FTPPermError < FTPError; end
class FTPProtoError < FTPError; end
+ # :startdoc:
+ #
+ # This class implements the File Transfer Protocol. If you have used a
+ # command-line FTP program, and are familiar with the commands, you will be
+ # able to use this class easily. Some extra features are included to take
+ # advantage of Ruby's style and strengths.
+ #
+ # == Example
+ #
+ # require 'net/ftp'
+ #
+ # === Example 1
+ #
+ # ftp = Net::FTP.new('ftp.netlab.co.jp')
+ # ftp.login
+ # files = ftp.chdir('pub/lang/ruby/contrib')
+ # files = ftp.list('n*')
+ # ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
+ # ftp.close
+ #
+ # === Example 2
+ #
+ # Net::FTP.open('ftp.netlab.co.jp') do |ftp|
+ # ftp.login
+ # files = ftp.chdir('pub/lang/ruby/contrib')
+ # files = ftp.list('n*')
+ # ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
+ # end
+ #
+ # == Major Methods
+ #
+ # The following are the methods most likely to be useful to users:
+ # - FTP.open
+ # - #getbinaryfile
+ # - #gettextfile
+ # - #putbinaryfile
+ # - #puttextfile
+ # - #chdir
+ # - #nlst
+ # - #size
+ # - #rename
+ # - #delete
+ #
class FTP
include MonitorMixin
+ # :stopdoc:
FTP_PORT = 21
CRLF = "\r\n"
-
DEFAULT_BLOCKSIZE = 4096
+ # :startdoc:
- attr_accessor :passive, :return_code, :debug_mode, :resume
- attr_reader :welcome, :lastresp
-
+ # When +true+, transfers are performed in binary mode. Default: +true+.
+ attr_accessor :binary
+
+ # When +true+, the connection is in passive mode. Default: +false+.
+ attr_accessor :passive
+
+ # When +true+, all traffic to and from the server is written
+ # to +$stdout+. Default: +false+.
+ attr_accessor :debug_mode
+
+ # Sets or retrieves the +resume+ status, which decides whether incomplete
+ # transfers are resumed or restarted. Default: +false+.
+ attr_accessor :resume
+
+ # The server's welcome message.
+ attr_reader :welcome
+
+ # The server's last response code.
+ attr_reader :last_response_code
+ alias lastresp last_response_code
+
+ # The server's last response.
+ attr_reader :last_response
+
+ #
+ # A synonym for <tt>FTP.new</tt>, but with a mandatory host parameter.
+ #
+ # If a block is given, it is passed the +FTP+ object, which will be closed
+ # when the block finishes, or when an exception is raised.
+ #
def FTP.open(host, user = nil, passwd = nil, acct = nil)
- new(host, user, passwd, acct)
+ if block_given?
+ ftp = new(host, user, passwd, acct)
+ begin
+ yield ftp
+ ensure
+ ftp.close
+ end
+ else
+ new(host, user, passwd, acct)
+ end
end
+ #
+ # Creates and returns a new +FTP+ object. If a +host+ is given, a connection
+ # is made. Additionally, if the +user+ is given, the given user name,
+ # password, and (optionally) account are used to log in. See #login.
+ #
def initialize(host = nil, user = nil, passwd = nil, acct = nil)
super()
+ @binary = true
@passive = false
- @return_code = "\n"
@debug_mode = false
@resume = false
if host
@@ -48,17 +139,34 @@ module Net
end
end
end
-
+
+ # Obsolete
+ def return_code
+ $stderr.puts("warning: Net::FTP#return_code is obsolete and do nothing")
+ return "\n"
+ end
+
+ # Obsolete
+ def return_code=(s)
+ $stderr.puts("warning: Net::FTP#return_code= is obsolete and do nothing")
+ end
+
def open_socket(host, port)
if defined? SOCKSsocket and ENV["SOCKS_SERVER"]
@passive = true
return SOCKSsocket.open(host, port)
else
- return TCPsocket.open(host, port)
+ return TCPSocket.open(host, port)
end
end
private :open_socket
+ #
+ # Establishes an FTP connection to host, optionally overriding the default
+ # port. If the environment variable +SOCKS_SERVER+ is set, sets up the
+ # connection through a SOCKS proxy. Raises an exception (typically
+ # <tt>Errno::ECONNREFUSED</tt>) if the connection cannot be established.
+ #
def connect(host, port = FTP_PORT)
if @debug_mode
print "connect: ", host, ", ", port, "\n"
@@ -68,7 +176,19 @@ module Net
voidresp
end
end
-
+
+ #
+ # WRITEME or make private
+ #
+ def set_socket(sock, get_greeting = true)
+ synchronize do
+ @sock = sock
+ if get_greeting
+ voidresp
+ end
+ end
+ end
+
def sanitize(s)
if s =~ /^PASS /i
return s[0, 5] + "*" * (s.length - 5)
@@ -89,12 +209,7 @@ module Net
def getline
line = @sock.readline # if get EOF, raise EOFError
- if line[-2, 2] == CRLF
- line = line[0 .. -3]
- elsif line[-1] == ?\r or
- line[-1] == ?\n
- line = line[0 .. -2]
- end
+ line.sub!(/(\r\n|\n|\r)\z/n, "")
if @debug_mode
print "get: ", sanitize(line), "\n"
end
@@ -117,18 +232,17 @@ module Net
private :getmultiline
def getresp
- resp = getmultiline
- @lastresp = resp[0, 3]
- c = resp[0]
- case c
- when ?1, ?2, ?3
- return resp
- when ?4
- raise FTPTempError, resp
- when ?5
- raise FTPPermError, resp
+ @last_response = getmultiline
+ @last_response_code = @last_response[0, 3]
+ case @last_response_code
+ when /\A[123]/
+ return @last_response
+ when /\A4/
+ raise FTPTempError, @last_response
+ when /\A5/
+ raise FTPPermError, @last_response
else
- raise FTPProtoError, resp
+ raise FTPProtoError, @last_response
end
end
private :getresp
@@ -141,6 +255,9 @@ module Net
end
private :voidresp
+ #
+ # Sends a command and returns the response.
+ #
def sendcmd(cmd)
synchronize do
putline(cmd)
@@ -148,6 +265,9 @@ module Net
end
end
+ #
+ # Sends a command and expect a response beginning with '2'.
+ #
def voidcmd(cmd)
synchronize do
putline(cmd)
@@ -172,7 +292,7 @@ module Net
private :sendport
def makeport
- sock = TCPserver.open(@sock.addr[3], 0)
+ sock = TCPServer.open(@sock.addr[3], 0)
port = sock.addr[1]
host = sock.addr[3]
resp = sendport(host, port)
@@ -240,6 +360,14 @@ module Net
end
private :getaddress
+ #
+ # Logs in to the remote host. The session must have been previously
+ # connected. If +user+ is the string "anonymous" and the +password+ is
+ # +nil+, a password of <tt>user@host</tt> is synthesized. If the +acct+
+ # parameter is not +nil+, an FTP ACCT command is sent following the
+ # successful login. Raises an exception on error (typically
+ # <tt>Net::FTPPermError</tt>).
+ #
def login(user = "anonymous", passwd = nil, acct = nil)
if user == "anonymous" and passwd == nil
passwd = getaddress
@@ -261,26 +389,33 @@ module Net
@welcome = resp
end
- def retrbinary(cmd, blocksize, rest_offset = nil, callback = Proc.new)
+ #
+ # Puts the connection into binary (image) mode, issues the given command,
+ # and fetches the data returned, passing it to the associated block in
+ # chunks of +blocksize+ characters. Note that +cmd+ is a server command
+ # (such as "RETR myfile").
+ #
+ def retrbinary(cmd, blocksize, rest_offset = nil) # :yield: data
synchronize do
voidcmd("TYPE I")
conn = transfercmd(cmd, rest_offset)
loop do
data = conn.read(blocksize)
break if data == nil
- callback.call(data)
+ yield(data)
end
conn.close
voidresp
end
end
- def retrlines(cmd, callback = nil)
- if block_given?
- callback = Proc.new
- elsif not callback.is_a?(Proc)
- callback = Proc.new {|line| print line, "\n"}
- end
+ #
+ # Puts the connection into ASCII (text) mode, issues the given command, and
+ # passes the resulting data, one line at a time, to the associated block. If
+ # no block is given, prints the lines. Note that +cmd+ is a server command
+ # (such as "RETR myfile").
+ #
+ def retrlines(cmd) # :yield: line
synchronize do
voidcmd("TYPE A")
conn = transfercmd(cmd)
@@ -292,18 +427,23 @@ module Net
elsif line[-1] == ?\n
line = line[0 .. -2]
end
- callback.call(line)
+ yield(line)
end
conn.close
voidresp
end
end
- def storbinary(cmd, file, blocksize, rest_offset = nil, callback = nil)
- if block_given?
- callback = Proc.new
+ #
+ # Puts the connection into binary (image) mode, issues the given server-side
+ # command (such as "STOR myfile"), and sends the contents of the file named
+ # +file+ to the server. If the optional block is given, it also passes it
+ # the data, in chunks of +blocksize+ characters.
+ #
+ def storbinary(cmd, file, blocksize, rest_offset = nil, &block) # :yield: data
+ if rest_offset
+ file.seek(rest_offset, IO::SEEK_SET)
end
- use_callback = callback.is_a?(Proc)
synchronize do
voidcmd("TYPE I")
conn = transfercmd(cmd, rest_offset)
@@ -311,18 +451,20 @@ module Net
buf = file.read(blocksize)
break if buf == nil
conn.write(buf)
- callback.call(buf) if use_callback
+ yield(buf) if block
end
conn.close
voidresp
end
end
- def storlines(cmd, file, callback = nil)
- if block_given?
- callback = Proc.new
- end
- use_callback = callback.is_a?(Proc)
+ #
+ # Puts the connection into ASCII (text) mode, issues the given server-side
+ # command (such as "STOR myfile"), and sends the contents of the file
+ # named +file+ to the server, one line at a time. If the optional block is
+ # given, it also passes it the lines.
+ #
+ def storlines(cmd, file, &block) # :yield: line
synchronize do
voidcmd("TYPE A")
conn = transfercmd(cmd)
@@ -333,19 +475,20 @@ module Net
buf = buf.chomp + CRLF
end
conn.write(buf)
- callback.call(buf) if use_callback
+ yield(buf) if block
end
conn.close
voidresp
end
end
-
- def getbinaryfile(remotefile, localfile,
- blocksize = DEFAULT_BLOCKSIZE, callback = nil)
- if block_given?
- callback = Proc.new
- end
- use_callback = callback.is_a?(Proc)
+
+ #
+ # Retrieves +remotefile+ in binary mode, storing the result in +localfile+.
+ # If a block is supplied, it is passed the retrieved data in +blocksize+
+ # chunks.
+ #
+ def getbinaryfile(remotefile, localfile = File.basename(remotefile),
+ blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
if @resume
rest_offset = File.size?(localfile)
f = open(localfile, "a")
@@ -357,72 +500,106 @@ module Net
f.binmode
retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
f.write(data)
- callback.call(data) if use_callback
+ yield(data) if block
end
ensure
f.close
end
end
- def gettextfile(remotefile, localfile, callback = nil)
- if block_given?
- callback = Proc.new
- end
- use_callback = callback.is_a?(Proc)
+ #
+ # Retrieves +remotefile+ in ASCII (text) mode, storing the result in
+ # +localfile+. If a block is supplied, it is passed the retrieved data one
+ # line at a time.
+ #
+ def gettextfile(remotefile, localfile = File.basename(remotefile), &block) # :yield: line
f = open(localfile, "w")
begin
retrlines("RETR " + remotefile) do |line|
- line = line + @return_code
- f.write(line)
- callback.call(line) if use_callback
+ f.puts(line)
+ yield(line) if block
end
ensure
f.close
end
end
-
- def putbinaryfile(localfile, remotefile,
- blocksize = DEFAULT_BLOCKSIZE, callback = nil)
- if block_given?
- callback = Proc.new
+
+ #
+ # Retrieves +remotefile+ in whatever mode the session is set (text or
+ # binary). See #gettextfile and #getbinaryfile.
+ #
+ def get(remotefile, localfile = File.basename(remotefile),
+ blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
+ unless @binary
+ gettextfile(remotefile, localfile, &block)
+ else
+ getbinaryfile(remotefile, localfile, blocksize, &block)
end
- use_callback = callback.is_a?(Proc)
+ end
+
+ #
+ # Transfers +localfile+ to the server in binary mode, storing the result in
+ # +remotefile+. If a block is supplied, calls it, passing in the transmitted
+ # data in +blocksize+ chunks.
+ #
+ def putbinaryfile(localfile, remotefile = File.basename(localfile),
+ blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
if @resume
- rest_offset = size(remotefile)
+ begin
+ rest_offset = size(remotefile)
+ rescue Net::FTPPermError
+ rest_offset = nil
+ end
else
rest_offset = nil
end
f = open(localfile)
begin
f.binmode
- storbinary("STOR " + remotefile, f, blocksize, rest_offset) do |data|
- callback.call(data) if use_callback
- end
+ storbinary("STOR " + remotefile, f, blocksize, rest_offset, &block)
ensure
f.close
end
end
- def puttextfile(localfile, remotefile, callback = nil)
- if block_given?
- callback = Proc.new
- end
- use_callback = callback.is_a?(Proc)
+ #
+ # Transfers +localfile+ to the server in ASCII (text) mode, storing the result
+ # in +remotefile+. If callback or an associated block is supplied, calls it,
+ # passing in the transmitted data one line at a time.
+ #
+ def puttextfile(localfile, remotefile = File.basename(localfile), &block) # :yield: line
f = open(localfile)
begin
- storlines("STOR " + remotefile, f) do |line|
- callback.call(line) if use_callback
- end
+ storlines("STOR " + remotefile, f, &block)
ensure
f.close
end
end
-
+
+ #
+ # Transfers +localfile+ to the server in whatever mode the session is set
+ # (text or binary). See #puttextfile and #putbinaryfile.
+ #
+ def put(localfile, remotefile = File.basename(localfile),
+ blocksize = DEFAULT_BLOCKSIZE, &block)
+ unless @binary
+ puttextfile(localfile, remotefile, &block)
+ else
+ putbinaryfile(localfile, remotefile, blocksize, &block)
+ end
+ end
+
+ #
+ # Sends the ACCT command. TODO: more info.
+ #
def acct(account)
cmd = "ACCT " + account
voidcmd(cmd)
end
+ #
+ # Returns an array of filenames in the remote directory.
+ #
def nlst(dir = nil)
cmd = "NLST"
if dir
@@ -435,7 +612,11 @@ module Net
return files
end
- def list(*args, &block)
+ #
+ # Returns an array of file information in the directory (the output is like
+ # `ls -l`). If a block is given, it iterates through the listing.
+ #
+ def list(*args, &block) # :yield: line
cmd = "LIST"
args.each do |arg|
cmd = cmd + " " + arg
@@ -453,6 +634,9 @@ module Net
alias ls list
alias dir list
+ #
+ # Renames a file on the server.
+ #
def rename(fromname, toname)
resp = sendcmd("RNFR " + fromname)
if resp[0] != ?3
@@ -461,6 +645,9 @@ module Net
voidcmd("RNTO " + toname)
end
+ #
+ # Deletes a file on the server.
+ #
def delete(filename)
resp = sendcmd("DELE " + filename)
if resp[0, 3] == "250"
@@ -472,6 +659,9 @@ module Net
end
end
+ #
+ # Changes the (remote) directory.
+ #
def chdir(dirname)
if dirname == ".."
begin
@@ -487,6 +677,9 @@ module Net
voidcmd(cmd)
end
+ #
+ # Returns the size of the given (remote) filename.
+ #
def size(filename)
voidcmd("TYPE I")
resp = sendcmd("SIZE " + filename)
@@ -496,29 +689,45 @@ module Net
return resp[3..-1].strip.to_i
end
- MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/
+ MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ # :nodoc:
+ #
+ # Returns the last modification time of the (remote) file. If +local+ is
+ # +true+, it is returned as a local time, otherwise it's a UTC time.
+ #
def mtime(filename, local = false)
str = mdtm(filename)
ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i}
return local ? Time.local(*ary) : Time.gm(*ary)
end
+ #
+ # Creates a remote directory.
+ #
def mkdir(dirname)
resp = sendcmd("MKD " + dirname)
return parse257(resp)
end
+ #
+ # Removes a remote directory.
+ #
def rmdir(dirname)
voidcmd("RMD " + dirname)
end
+ #
+ # Returns the current remote directory.
+ #
def pwd
resp = sendcmd("PWD")
return parse257(resp)
end
alias getdir pwd
+ #
+ # Returns system information.
+ #
def system
resp = sendcmd("SYST")
if resp[0, 3] != "215"
@@ -527,6 +736,9 @@ module Net
return resp[4 .. -1]
end
+ #
+ # Aborts the previous command (ABOR command).
+ #
def abort
line = "ABOR" + CRLF
print "put: ABOR\n" if @debug_mode
@@ -538,6 +750,9 @@ module Net
return resp
end
+ #
+ # Returns the status (STAT command).
+ #
def status
line = "STAT" + CRLF
print "put: STAT\n" if @debug_mode
@@ -545,6 +760,9 @@ module Net
return getresp
end
+ #
+ # Issues the MDTM command. TODO: more info.
+ #
def mdtm(filename)
resp = sendcmd("MDTM " + filename)
if resp[0, 3] == "213"
@@ -552,6 +770,9 @@ module Net
end
end
+ #
+ # Issues the HELP command.
+ #
def help(arg = nil)
cmd = "HELP"
if arg
@@ -560,14 +781,39 @@ module Net
sendcmd(cmd)
end
+ #
+ # Exits the FTP session.
+ #
def quit
voidcmd("QUIT")
end
+
+ #
+ # Issues a NOOP command.
+ #
+ def noop
+ voidcmd("NOOP")
+ end
+
+ #
+ # Issues a SITE command.
+ #
+ def site(arg)
+ cmd = "SITE " + arg
+ voidcmd(cmd)
+ end
+ #
+ # Closes the connection. Further operations are impossible until you open
+ # a new connection with #connect.
+ #
def close
@sock.close if @sock and not @sock.closed?
end
+ #
+ # Returns +true+ iff the connection is closed.
+ #
def closed?
@sock == nil or @sock.closed?
end
@@ -669,3 +915,9 @@ module Net
end
end
+
+
+# Documentation comments:
+# - sourced from pickaxe and nutshell, with improvements (hopefully)
+# - three methods should be private (search WRITEME)
+# - two methods need more information (search TODO)
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 26e5285525..39c58dd521 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1,309 +1,457 @@
-=begin
+#
+# = net/http.rb
+#
+# Copyright (c) 1999-2003 Yukihiro Matsumoto
+# Copyright (c) 1999-2003 Minero Aoki
+#
+# Written & maintained by Minero Aoki <aamine@loveruby.net>.
+#
+# This file is derived from "http-access.rb".
+#
+# Documented by Minero Aoki; converted to RDoc by William Webber.
+#
+# This program is free software. You can re-distribute and/or
+# modify this program under the same terms of ruby itself ---
+# Ruby Distribution License or GNU General Public License.
+#
+# See Net::HTTP for an overview and examples.
+#
+# NOTE: You can find Japanese version of this document here:
+# http://www.ruby-lang.org/ja/man/?cmd=view;name=net%2Fhttp.rb
+#
+#--
+# $Id$
+#++
-= net/http.rb version 1.1.34
-
-written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
-This file is derived from "http-access.rb".
-
-This program is free software.
-You can distribute/modify this program under
-the terms of the Ruby Distribute License.
-
-Japanese version of this document is in "net" full package.
-You can get it from RAA
-(Ruby Application Archive: http://www.ruby-lang.org/en/raa.html).
-
-
-== http.rb version 1.2 features
-
-You can use 1.2 features by calling HTTP.version_1_2. And
-calling Net::HTTP.version_1_1 allows to use 1.1 features.
-
- # example
- HTTP.start {|http1| ...(http1 has 1.1 features)... }
-
- HTTP.version_1_2
- HTTP.start {|http2| ...(http2 has 1.2 features)... }
-
- HTTP.version_1_1
- HTTP.start {|http3| ...(http3 has 1.1 features)... }
-
-Changes are:
-
- * HTTP#get, head, post does not raise ProtocolError
- * HTTP#get, head, post returns only one object, a HTTPResponse object
- * HTTPResponseReceiver is joined into HTTPResponse
- * request object: HTTP::Get, Head, Post; and HTTP#request(req)
-
-WARNING: These features are not definite yet.
-They will change without notice!
-
-
-== class HTTP
+require 'net/protocol'
+require 'uri'
-=== Class Methods
-: new( address = 'localhost', port = 80, proxy_addr = nil, proxy_port = nil )
- creates a new Net::HTTP object.
- If proxy_addr is given, this method is equals to
- Net::HTTP::Proxy(proxy_addr,proxy_port).
+module Net # :nodoc:
-: start( address = 'localhost', port = 80, proxy_addr = nil, proxy_port = nil )
-: start( address = 'localhost', port = 80, proxy_addr = nil, proxy_port = nil ) {|http| .... }
- is equals to
- Net::HTTP.new( address, port, proxy_addr, proxy_port ).start(&block)
+ # :stopdoc:
+ class HTTPBadResponse < StandardError; end
+ class HTTPHeaderSyntaxError < StandardError; end
+ # :startdoc:
+
+ # == What Is This Library?
+ #
+ # This library provides your program functions to access WWW
+ # documents via HTTP, Hyper Text Transfer Protocol version 1.1.
+ # For details of HTTP, refer [RFC2616]
+ # (http://www.ietf.org/rfc/rfc2616.txt).
+ #
+ # == Examples
+ #
+ # === Getting Document From WWW Server
+ #
+ # (formal version)
+ #
+ # require 'net/http'
+ # Net::HTTP.start('www.example.com', 80) { |http|
+ # response = http.get('/index.html')
+ # puts response.body
+ # }
+ #
+ # (shorter version)
+ #
+ # require 'net/http'
+ # Net::HTTP.get_print 'www.example.com', '/index.html'
+ #
+ # or
+ #
+ # require 'net/http'
+ # require 'uri'
+ # Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
+ #
+ # === Posting Form Data
+ #
+ # require 'net/http'
+ # Net::HTTP.start('some.www.server', 80) { |http|
+ # response = http.post('/cgi-bin/search.rb', 'query=ruby')
+ # }
+ #
+ # === Accessing via Proxy
+ #
+ # Net::HTTP.Proxy creates http proxy class. It has same
+ # methods of Net::HTTP but its instances always connect to
+ # proxy, instead of given host.
+ #
+ # require 'net/http'
+ #
+ # proxy_addr = 'your.proxy.host'
+ # proxy_port = 8080
+ # :
+ # Net::HTTP::Proxy(proxy_addr, proxy_port).start('www.example.com') {|http|
+ # # always connect to your.proxy.addr:8080
+ # :
+ # }
+ #
+ # Since Net::HTTP.Proxy returns Net::HTTP itself when proxy_addr is nil,
+ # there's no need to change code if there's proxy or not.
+ #
+ # There are two additional parameters in Net::HTTP.Proxy which allow to
+ # specify proxy user name and password:
+ #
+ # Net::HTTP::Proxy(proxy_addr, proxy_port, proxy_user = nil, proxy_pass = nil)
+ #
+ # You may use them to work with authorization-enabled proxies:
+ #
+ # require 'net/http'
+ # require 'uri'
+ #
+ # proxy_host = 'your.proxy.host'
+ # proxy_port = 8080
+ # uri = URI.parse(ENV['http_proxy'])
+ # proxy_user, proxy_pass = uri.userinfo.split(/:/) if uri.userinfo
+ # Net::HTTP::Proxy(proxy_host, proxy_port,
+ # proxy_user, proxy_pass).start('www.example.com') {|http|
+ # # always connect to your.proxy.addr:8080 using specified username and password
+ # :
+ # }
+ #
+ # Note that net/http never rely on HTTP_PROXY environment variable.
+ # If you want to use proxy, set it explicitly.
+ #
+ # === Following Redirection
+ #
+ # require 'net/http'
+ # require 'uri'
+ #
+ # def fetch( uri_str, limit = 10 )
+ # # You should choose better exception.
+ # raise ArgumentError, 'HTTP redirect too deep' if limit == 0
+ #
+ # response = Net::HTTP.get_response(URI.parse(uri_str))
+ # case response
+ # when Net::HTTPSuccess then response
+ # when Net::HTTPRedirection then fetch(response['location'], limit - 1)
+ # else
+ # response.error!
+ # end
+ # end
+ #
+ # print fetch('http://www.ruby-lang.org')
+ #
+ # Net::HTTPSuccess and Net::HTTPRedirection is a HTTPResponse class.
+ # All HTTPResponse objects belong to its own response class which
+ # indicate HTTP result status. For details of response classes,
+ # see section "HTTP Response Classes".
+ #
+ # === Basic Authentication
+ #
+ # require 'net/http'
+ #
+ # Net::HTTP.start('www.example.com') {|http|
+ # req = Net::HTTP::Get.new('/secret-page.html')
+ # req.basic_auth 'account', 'password'
+ # response = http.request(req)
+ # print response.body
+ # }
+ #
+ # === HTTP Response Classes
+ #
+ # TODO: write me.
+ #
+ # == Switching Net::HTTP versions
+ #
+ # You can use net/http.rb 1.1 features (bundled with Ruby 1.6)
+ # by calling HTTP.version_1_1. Calling Net::HTTP.version_1_2
+ # allows you to use 1.2 features again.
+ #
+ # # example
+ # Net::HTTP.start { |http1| ...(http1 has 1.2 features)... }
+ #
+ # Net::HTTP.version_1_1
+ # Net::HTTP.start { |http2| ...(http2 has 1.1 features)... }
+ #
+ # Net::HTTP.version_1_2
+ # Net::HTTP.start { |http3| ...(http3 has 1.2 features)... }
+ #
+ # This function is NOT thread-safe.
+ #
+ class HTTP < Protocol
-: Proxy( address, port )
- creates a HTTP proxy class.
- Arguments are address/port of proxy host.
- You can replace HTTP class by this proxy class.
+ # :stopdoc:
+ Revision = %q$Revision$.split[1]
+ HTTPVersion = '1.1'
+ @@newimpl = true # for backward compatability
+ # :startdoc:
- # example
- proxy_http = HTTP::Proxy( 'proxy.foo.org', 8080 )
- :
- proxy_http.start( 'www.ruby-lang.org' ) do |http|
- # connecting proxy.foo.org:8080
- :
+ # Turns on net/http 1.2 (ruby 1.8) features.
+ # Defaults to ON in ruby 1.8.
+ #
+ # I strongly recommend to call this method always.
+ #
+ # require 'net/http'
+ # Net::HTTP.version_1_2
+ #
+ def HTTP.version_1_2
+ @@newimpl = true
end
-: proxy_class?
- If self is HTTP, false.
- If self is a class which was created by HTTP::Proxy(), true.
-
-: port
- HTTP default port (80).
-
-
-=== Methods
-
-: start
-: start {|http| .... }
- creates a new Net::HTTP object and starts HTTP session.
-
- When this method is called with block, gives a HTTP object to block
- and close HTTP session after returning from the block.
-
-: proxy?
- true if self is a HTTP proxy class
-
-: proxy_address
- address of proxy host. If self is not a proxy, nil.
-
-: proxy_port
- port number of proxy host. If self is not a proxy, nil.
-
-: get( path, header = nil, dest = '' )
-: get( path, header = nil ) {|str| .... }
- get data from "path" on connecting host.
- "header" must be a Hash like { 'Accept' => '*/*', ... }.
- Data is written to "dest" by using "<<" method.
- This method returns HTTPResponse object, and "dest".
-
- # example
- response, body = http.get( '/index.html' )
-
- If called with block, give a part String of entity body.
-
- Note:
- If status is not 2xx(success), ProtocolError exception is
- raised. At that time, you can get HTTPResponse object from
- exception object. (same in head/post)
-
- # example
- begin
- response, body = http.get( '/index.html' )
- rescue Net::ProtoRetriableError => err
- response = err.data
- ...
+ # Turns on net/http 1.1 (ruby 1.6) features.
+ # Defaults to OFF in ruby 1.8.
+ def HTTP.version_1_1
+ @@newimpl = false
end
-: head( path, header = nil )
- gets only header from "path" on connecting host.
- "header" is a Hash like { 'Accept' => '*/*', ... }.
- This method returns a HTTPResponse object.
- You can http header from this object like:
-
- response['content-length'] #-> '2554'
- response['content-type'] #-> 'text/html'
- response['Content-Type'] #-> 'text/html'
- response['CoNtEnT-tYpe'] #-> 'text/html'
-
-: post( path, data, header = nil, dest = '' )
-: post( path, data, header = nil ) {|str| .... }
- posts "data" (must be String now) to "path".
- If the body exists, also gets entity body.
- Data is written to "dest" by using "<<" method.
- "header" must be a Hash like { 'Accept' => '*/*', ... }.
- This method returns HTTPResponse object and "dest".
-
- If called with block, gives a part of entity body string.
-
-: get2( path, header = nil )
-: get2( path, header = nil ) {|recv| .... }
- send GET request for "path".
- "header" must be a Hash like { 'Accept' => '*/*', ... }.
- If this method is called with block, one gives
- a HTTPResponseReceiver object to block.
-
- # example
- http.get2( '/index.html' ) do |recv|
- # "recv" is a HTTPResponseReceiver object
- recv.header
- recv.body
+ # true if net/http is in version 1.2 mode.
+ # Defaults to true.
+ def HTTP.version_1_2?
+ @@newimpl
end
- # another way
- response = http.get2( '/index.html' )
- response['content-type']
- response.body
-
- # this is wrong
- http.get2( '/index.html' ) do |recv|
- print recv.response.body # body is not read yet!!!
+ # true if net/http is in version 1.1 compatible mode.
+ # Defaults to true.
+ def HTTP.version_1_1?
+ not @@newimpl
end
- # but this is ok
- http.get2( '/index.html' ) do |recv|
- recv.body # read body and set recv.response.body
- print recv.response.body # ref
+ class << HTTP
+ alias is_version_1_1? version_1_1? #:nodoc:
+ alias is_version_1_2? version_1_2? #:nodoc:
end
-: head2( path, header = nil )
-: head2( path, header = nil ) {|recv| .... }
- send HEAD request for "path".
- "header" must be a Hash like { 'Accept' => 'text/html', ... }.
- The difference between "head" method is that
- "head2" does not raise exceptions.
-
- If this method is called with block, one gives
- a HTTPResponseReceiver object to block.
-
- # example
- response = http.head2( '/index.html' )
-
- # another way
- http.head2( '/index.html' ) do |recv|
- recv.response
+ def HTTP.setimplversion(obj) #:nodoc:
+ f = @@newimpl
+ obj.instance_eval { @newimpl = f }
end
+ private_class_method :setimplversion
-: post2( path, data, header = nil )
-: post2( path, data, header = nil ) {|recv| .... }
- posts "data" (must be String now) to "path".
- "header" must be a Hash like { 'Accept' => '*/*', ... }.
- If this method is called with block, one gives
- a HTTPResponseReceiver object to block.
+ #
+ # short cut methods
+ #
- # example
- http.post2( '/anycgi.rb', 'data data data...' ) do |recv|
- # "recv" is a HTTPResponseReceiver object
- recv.header
- recv.body
+ #
+ # Get body from target and output it to +$stdout+. The
+ # target can either be specified as (+uri+), or as
+ # (+host+, +path+, +port+ = 80); so:
+ #
+ # Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
+ #
+ # or:
+ #
+ # Net::HTTP.get_print('www.example.com', '/index.html')
+ #
+ def HTTP.get_print(arg1, arg2 = nil, port = nil)
+ if arg2
+ addr, path = arg1, arg2
+ else
+ uri = arg1
+ addr = uri.host
+ path = uri.request_uri
+ port = uri.port
+ end
+ new(addr, port || HTTP.default_port).start {|http|
+ http.get path, nil, $stdout
+ }
+ nil
end
- # another way
- response = http.post2( '/anycgi.rb', 'important data' )
- response['content-type']
- response.body
-
-
-== class HTTPResponse
-
-HTTP response object.
-All "key" is case-insensitive.
-
-=== Methods
+ # Send a GET request to the target and return the response
+ # as a string. The target can either be specified as
+ # (+uri+), or as (+host+, +path+, +port+ = 80); so:
+ #
+ # print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
+ #
+ # or:
+ #
+ # print Net::HTTP.get('www.example.com', '/index.html')
+ #
+ def HTTP.get(arg1, arg2 = nil, arg3 = nil)
+ get_response(arg1,arg2,arg3).body
+ end
-: body
- the entity body (String).
+ # Send a GET request to the target and return the response
+ # as a Net::HTTPResponse object. The target can either be specified as
+ # (+uri+), or as (+host+, +path+, +port+ = 80); so:
+ #
+ # res = Net::HTTP.get_response(URI.parse('http://www.example.com/index.html'))
+ # print res.body
+ #
+ # or:
+ #
+ # res = Net::HTTP.get_response('www.example.com', '/index.html')
+ # print res.body
+ #
+ def HTTP.get_response(arg1, arg2 = nil, arg3 = nil)
+ if arg2
+ get_by_path(arg1, arg2, arg3)
+ else
+ get_by_uri(arg1)
+ end
+ end
-: self[ key ]
- returns header field for "key".
- for HTTP, value is a string like 'text/plain'(for Content-Type),
- '2045'(for Content-Length), 'bytes 0-1023/10024'(for Content-Range).
- If there's some fields which has same name, they are joined with ','.
+ def HTTP.get_by_path(addr, path, port = nil) #:nodoc:
+ new(addr, port || HTTP.default_port).start {|http|
+ return http.request(Get.new(path))
+ }
+ end
+ private_class_method :get_by_path
-: self[ key ] = val
- set field value for "key".
+ def HTTP.get_by_uri(uri) #:nodoc:
+ # Should we allow this?
+ # uri = URI.parse(uri) unless uri.respond_to?(:host)
+ new(uri.host, uri.port).start {|http|
+ return http.request(Get.new(uri.request_uri))
+ }
+ end
+ private_class_method :get_by_uri
-: key?( key )
- true if key exists
+ #
+ # HTTP session management
+ #
-: each {|name,value| .... }
- iterates for each field name and value pair.
+ # The default port to use for HTTP requests; defaults to 80.
+ def HTTP.default_port
+ 80
+ end
-: code
- HTTP result code string. For example, '302'.
+ def HTTP.socket_type #:nodoc: obsolete
+ InternetMessageIO
+ end
-: message
- HTTP result message. For example, 'Not Found'.
+ class << HTTP
+ # creates a new Net::HTTP object and opens its TCP connection and
+ # HTTP session. If the optional block is given, the newly
+ # created Net::HTTP object is passed to it and closed when the
+ # block finishes. In this case, the return value of this method
+ # is the return value of the block. If no block is given, the
+ # return value of this method is the newly created Net::HTTP object
+ # itself, and the caller is responsible for closing it upon completion.
+ def start(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil, &block) # :yield: +http+
+ new(address, port, p_addr, p_port, p_user, p_pass).start(&block)
+ end
+ alias newobj new
-== class HTTPResponseReceiver
+ # Creates a new Net::HTTP object.
+ # If +proxy_addr+ is given, creates an Net::HTTP object with proxy support.
+ # This method does not open the TCP connection.
+ def new(address, port = nil, p_addr = nil, p_port = nil, p_user = nil, p_pass = nil)
+ obj = Proxy(p_addr, p_port, p_user, p_pass).newobj(address, port)
+ setimplversion obj
+ obj
+ end
+ end
-=== Methods
+ # Creates a new Net::HTTP object for the specified +address+.
+ # This method does not open the TCP connection.
+ def initialize(address, port = nil)
+ @address = address
+ @port = (port || HTTP.default_port)
-: header
-: response
- HTTPResponse object
+ @curr_http_version = HTTPVersion
+ @seems_1_0_server = false
+ @close_on_empty_response = false
+ @socket = nil
+ @started = false
-: read_body( dest = '' )
- reads entity body into DEST by calling "<<" method and
- returns DEST.
+ @open_timeout = 30
+ @read_timeout = 60
-: read_body {|string| ... }
- reads entity body little by little and gives it to block
- until entity ends.
+ @debug_output = nil
+ end
-: body
-: entity
- entity body. If #read_body is called already, returns its
- argument DEST. Else returns entity body as String.
+ def inspect
+ "#<#{self.class} #{@address}:#{@port} open=#{started?}>"
+ end
- Calling this method any times causes returning same
- object (does not read entity again).
+ # *WARNING* This method causes serious security hole.
+ # Never use this method in production code.
+ #
+ # Set an output stream for debugging.
+ #
+ # http = Net::HTTP.new
+ # http.set_debug_output $stderr
+ # http.start { .... }
+ #
+ def set_debug_output(output)
+ warn 'Net::HTTP#set_debug_output called after HTTP started' if started?
+ @debug_output = output
+ end
-=end
+ # The host name to connect to.
+ attr_reader :address
-require 'net/protocol'
+ # The port number to connect to.
+ attr_reader :port
+ # Seconds to wait until connection is opened.
+ # If the HTTP object cannot open a connection in this many seconds,
+ # it raises a TimeoutError exception.
+ attr_accessor :open_timeout
-module Net
+ # Seconds to wait until reading one block (by one read(2) call).
+ # If the HTTP object cannot open a connection in this many seconds,
+ # it raises a TimeoutError exception.
+ attr_reader :read_timeout
- class HTTPBadResponse < StandardError; end
- class HTTPHeaderSyntaxError < StandardError; end
+ # Setter for the read_timeout attribute.
+ def read_timeout=(sec)
+ @socket.read_timeout = sec if @socket
+ @read_timeout = sec
+ end
+ # returns true if the HTTP session is started.
+ def started?
+ @started
+ end
- class HTTP < Protocol
+ alias active? started? #:nodoc: obsolete
- HTTPVersion = '1.1'
+ attr_accessor :close_on_empty_response
+ # Opens TCP connection and HTTP session.
+ #
+ # When this method is called with block, gives a HTTP object
+ # to the block and closes the TCP connection / HTTP session
+ # after the block executed.
#
- # connection
+ # When called with a block, returns the return value of the
+ # block; otherwise, returns self.
#
-
- protocol_param :port, '80'
-
-
- def initialize( addr = nil, port = nil )
- super
-
- @proxy_address = nil
- @proxy_port = nil
-
- @curr_http_version = HTTPVersion
- @seems_1_0_server = false
+ def start # :yield: http
+ raise IOError, 'HTTP session already opened' if @started
+ if block_given?
+ begin
+ do_start
+ return yield(self)
+ ensure
+ do_finish
+ end
+ end
+ do_start
+ self
end
+ def do_start
+ @socket = self.class.socket_type.open(conn_address(), conn_port(),
+ @open_timeout, @read_timeout,
+ @debug_output)
+ on_connect
+ @started = true
+ end
+ private :do_start
- private
+ def on_connect
+ end
+ private :on_connect
- def conn_command( sock )
+ # Finishes HTTP session and closes TCP connection.
+ # Raises IOError if not started.
+ def finish
+ raise IOError, 'HTTP session not yet started' unless started?
+ do_finish
end
def do_finish
+ @started = false
+ @socket.close if @socket and not @socket.closed?
+ @socket = nil
end
-
+ private :do_finish
#
# proxy
@@ -311,393 +459,517 @@ module Net
public
+ # no proxy
+ @is_proxy_class = false
+ @proxy_addr = nil
+ @proxy_port = nil
+ @proxy_user = nil
+ @proxy_pass = nil
+
+ # Creates an HTTP proxy class.
+ # Arguments are address/port of proxy host and username/password
+ # if authorization on proxy server is required.
+ # You can replace the HTTP class with created proxy class.
+ #
+ # If ADDRESS is nil, this method returns self (Net::HTTP).
+ #
+ # # Example
+ # proxy_class = Net::HTTP::Proxy('proxy.example.com', 8080)
+ # :
+ # proxy_class.start('www.ruby-lang.org') {|http|
+ # # connecting proxy.foo.org:8080
+ # :
+ # }
+ #
+ def HTTP.Proxy(p_addr, p_port = nil, p_user = nil, p_pass = nil)
+ return self unless p_addr
+ delta = ProxyDelta
+ proxyclass = Class.new(self)
+ proxyclass.module_eval {
+ include delta
+ # with proxy
+ @is_proxy_class = true
+ @proxy_address = p_addr
+ @proxy_port = p_port || default_port()
+ @proxy_user = p_user
+ @proxy_pass = p_pass
+ }
+ proxyclass
+ end
- class << self
-
- def Proxy( p_addr, p_port = nil )
- ProxyMod.create_proxy_class( p_addr, p_port || self.port )
- end
-
- alias orig_new new
-
- def new( address = nil, port = nil, p_addr = nil, p_port = nil )
- c = p_addr ? self::Proxy(p_addr, p_port) : self
- i = c.orig_new( address, port )
- setvar i
- i
- end
-
- def start( address = nil, port = nil, p_addr = nil, p_port = nil, &block )
- new( address, port, p_addr, p_port ).start( &block )
- end
-
+ class << HTTP
+ # returns true if self is a class which was created by HTTP::Proxy.
def proxy_class?
- false
- end
-
- def proxy_address
- nil
- end
-
- def proxy_port
- nil
+ @is_proxy_class
end
+ attr_reader :proxy_address
+ attr_reader :proxy_port
+ attr_reader :proxy_user
+ attr_reader :proxy_pass
end
+ # True if self is a HTTP proxy class
def proxy?
- false
+ self.class.proxy_class?
end
+ # Address of proxy host. If self does not use a proxy, nil.
def proxy_address
- nil
+ self.class.proxy_address
end
+ # Port number of proxy host. If self does not use a proxy, nil.
def proxy_port
- nil
+ self.class.proxy_port
end
- def edit_path( path )
- path
+ # User name for accessing proxy. If self does not use a proxy, nil.
+ def proxy_user
+ self.class.proxy_user
end
+ # User password for accessing proxy. If self does not use a proxy, nil.
+ def proxy_pass
+ self.class.proxy_pass
+ end
- module ProxyMod
+ alias proxyaddr proxy_address #:nodoc: obsolete
+ alias proxyport proxy_port #:nodoc: obsolete
- class << self
+ private
- def create_proxy_class( p_addr, p_port )
- mod = self
- klass = Class.new( HTTP )
- klass.module_eval {
- include mod
- @proxy_address = p_addr
- @proxy_port = p_port
- }
- def klass.proxy_class?
- true
- end
+ # without proxy
- def klass.proxy_address
- @proxy_address
- end
+ def conn_address
+ address
+ end
- def klass.proxy_port
- @proxy_port
- end
+ def conn_port
+ port
+ end
- klass
- end
+ def edit_path(path)
+ path
+ end
- end
+ module ProxyDelta #:nodoc: internal use only
+ private
- def initialize( addr, port )
- super
- @proxy_address = type.proxy_address
- @proxy_port = type.proxy_port
+ def conn_address
+ proxy_address()
end
-
- attr_reader :proxy_address, :proxy_port
-
- alias proxyaddr proxy_address
- alias proxyport proxy_port
- def proxy?
- true
- end
-
- private
-
- def conn_socket( addr, port )
- super @proxy_address, @proxy_port
+ def conn_port
+ proxy_port()
end
- def edit_path( path )
- 'http://' + addr_port + path
+ def edit_path(path)
+ 'http://' + addr_port() + path
end
-
- end # module ProxyMod
-
+ end
#
- # for backward compatibility
+ # HTTP operations
#
- @@newimpl = false
-
- class << self
+ public
- def version_1_2
- @@newimpl = true
+ # Gets data from +path+ on the connected-to host.
+ # +header+ must be a Hash like { 'Accept' => '*/*', ... }.
+ #
+ # In version 1.1 (ruby 1.6), this method returns a pair of objects,
+ # a Net::HTTPResponse object and the entity body string.
+ # In version 1.2 (ruby 1.8), this method returns a Net::HTTPResponse
+ # object.
+ #
+ # If called with a block, yields each fragment of the
+ # entity body in turn as a string as it is read from
+ # the socket. Note that in this case, the returned response
+ # object will *not* contain a (meaningful) body.
+ #
+ # +dest+ argument is obsolete.
+ # It still works but you must not use it.
+ #
+ # In version 1.1, this method might raise an exception for
+ # 3xx (redirect). In this case you can get a HTTPResponse object
+ # by "anException.response".
+ #
+ # In version 1.2, this method never raises exception.
+ #
+ # # version 1.1 (bundled with Ruby 1.6)
+ # response, body = http.get('/index.html')
+ #
+ # # version 1.2 (bundled with Ruby 1.8 or later)
+ # response = http.get('/index.html')
+ #
+ # # using block
+ # File.open('result.txt', 'w') {|f|
+ # http.get('/~foo/') do |str|
+ # f.write str
+ # end
+ # }
+ #
+ def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+
+ res = nil
+ request(Get.new(path, initheader)) {|r|
+ r.read_body dest, &block
+ res = r
+ }
+ unless @newimpl
+ res.value
+ return res, res.body
end
- def version_1_1
- @@newimpl = false
+ res
+ end
+
+ # Gets only the header from +path+ on the connected-to host.
+ # +header+ is a Hash like { 'Accept' => '*/*', ... }.
+ #
+ # This method returns a Net::HTTPResponse object.
+ #
+ # In version 1.1, this method might raise an exception for
+ # 3xx (redirect). On the case you can get a HTTPResponse object
+ # by "anException.response".
+ # In version 1.2, this method never raises an exception.
+ #
+ # response = nil
+ # Net::HTTP.start('some.www.server', 80) {|http|
+ # response = http.head('/index.html')
+ # }
+ # p response['content-type']
+ #
+ def head(path, initheader = nil)
+ res = request(Head.new(path, initheader))
+ res.value unless @newimpl
+ res
+ end
+
+ # Posts +data+ (must be a String) to +path+. +header+ must be a Hash
+ # like { 'Accept' => '*/*', ... }.
+ #
+ # In version 1.1 (ruby 1.6), this method returns a pair of objects, a
+ # Net::HTTPResponse object and an entity body string.
+ # In version 1.2 (ruby 1.8), this method returns a Net::HTTPResponse object.
+ #
+ # If called with a block, yields each fragment of the
+ # entity body in turn as a string as it are read from
+ # the socket. Note that in this case, the returned response
+ # object will *not* contain a (meaningful) body.
+ #
+ # +dest+ is an alternative method of collecting the body. It
+ # must be an object responding to the "<<" operator (such as
+ # a String or an Array). Each fragment of the entity body
+ # will be "<<"-ed in turn onto +dest+ if provided, and it will
+ # also become the body of the returned response object.
+ #
+ # You must *not* provide both +dest+ and a block; doing so
+ # will result in an ArgumentError.
+ #
+ # In version 1.1, this method might raise an exception for
+ # 3xx (redirect). In this case you can get an HTTPResponse object
+ # by "anException.response".
+ # In version 1.2, this method never raises exception.
+ #
+ # # version 1.1
+ # response, body = http.post('/cgi-bin/search.rb', 'query=foo')
+ #
+ # # version 1.2
+ # response = http.post('/cgi-bin/search.rb', 'query=foo')
+ #
+ # # using block
+ # File.open('result.txt', 'w') {|f|
+ # http.post('/cgi-bin/search.rb', 'query=foo') do |str|
+ # f.write str
+ # end
+ # }
+ #
+ def post(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
+ res = nil
+ request(Post.new(path, initheader), data) {|r|
+ r.read_body dest, &block
+ res = r
+ }
+ unless @newimpl
+ res.value
+ return res, res.body
end
- private
+ res
+ end
- def setvar( obj )
- f = @@newimpl
- obj.instance_eval { @newimpl = f }
- end
+ def put(path, data, initheader = nil) #:nodoc:
+ res = request(Put.new(path, initheader), data)
+ res.value unless @newimpl
+ res
+ end
+ # Sends a GET request to the +path+ and gets a response,
+ # as an HTTPResponse object.
+ #
+ # When called with a block, yields an HTTPResponse object.
+ # The body of this response will not have been read yet;
+ # the caller can process it using HTTPResponse#read_body,
+ # if desired.
+ #
+ # Returns the response.
+ #
+ # This method never raises Net::* exceptions.
+ #
+ # response = http.request_get('/index.html')
+ # # The entity body is already read here.
+ # p response['content-type']
+ # puts response.body
+ #
+ # # using block
+ # http.request_get('/index.html') {|response|
+ # p response['content-type']
+ # response.read_body do |str| # read body now
+ # print str
+ # end
+ # }
+ #
+ def request_get(path, initheader = nil, &block) # :yield: +response+
+ request(Get.new(path, initheader), &block)
end
+ # Sends a HEAD request to the +path+ and gets a response,
+ # as an HTTPResponse object.
+ #
+ # Returns the response.
+ #
+ # This method never raises Net::* exceptions.
+ #
+ # response = http.request_head('/index.html')
+ # p response['content-type']
+ #
+ def request_head(path, initheader = nil, &block)
+ request(Head.new(path, initheader), &block)
+ end
+ # Sends a POST request to the +path+ and gets a response,
+ # as an HTTPResponse object.
+ #
+ # When called with a block, yields an HTTPResponse object.
+ # The body of this response will not have been read yet;
+ # the caller can process it using HTTPResponse#read_body,
+ # if desired.
#
- # http operations
+ # Returns the response.
+ #
+ # This method never raises Net::* exceptions.
+ #
+ # # example
+ # response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
+ # p response.status
+ # puts response.body # body is already read
+ #
+ # # using block
+ # http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
+ # p response.status
+ # p response['content-type']
+ # response.read_body do |str| # read body now
+ # print str
+ # end
+ # }
#
+ def request_post(path, data, initheader = nil, &block) # :yield: +response+
+ request Post.new(path, initheader), data, &block
+ end
- public
+ def request_put(path, data, initheader = nil, &block) #:nodoc:
+ request Put.new(path, initheader), data, &block
+ end
- def self.def_http_method( nm, hasdest, hasdata )
- name = nm.id2name.downcase
- cname = nm.id2name
- lineno = __LINE__ + 2
- src = <<" ----"
-
- def #{name}( path, #{hasdata ? 'data,' : ''}
- u_header = nil #{hasdest ? ',dest = nil, &block' : ''} )
- resp = nil
- request(
- #{cname}.new( path, u_header ) #{hasdata ? ',data' : ''}
- ) do |resp|
- resp.read_body( #{hasdest ? 'dest, &block' : ''} )
- end
- if @newimpl then
- resp
- else
- resp.value
- #{hasdest ? 'return resp, resp.body' : 'resp'}
- end
- end
+ alias get2 request_get #:nodoc: obsolete
+ alias head2 request_head #:nodoc: obsolete
+ alias post2 request_post #:nodoc: obsolete
+ alias put2 request_put #:nodoc: obsolete
- def #{name}2( path, #{hasdata ? 'data,' : ''}
- u_header = nil, &block )
- request( #{cname}.new(path, u_header),
- #{hasdata ? 'data,' : ''} &block )
- end
- ----
- module_eval src, __FILE__, lineno
- end
- def_http_method :Get, true, false
- def_http_method :Head, false, false
- def_http_method :Post, true, true
- def_http_method :Put, false, true
+ # Sends an HTTP request to the HTTP server.
+ # This method also sends DATA string if DATA is given.
+ #
+ # Returns a HTTPResponse object.
+ #
+ # This method never raises Net::* exceptions.
+ #
+ # response = http.send_request('GET', '/index.html')
+ # puts response.body
+ #
+ def send_request(name, path, data = nil, header = nil)
+ r = HTTPGenericRequest.new(name,(data ? true : false),true,path,header)
+ request r, data
+ end
+
+ # Sends an HTTPRequest object REQUEST to the HTTP server.
+ # This method also sends DATA string if REQUEST is a post/put request.
+ # Giving DATA for get/head request causes ArgumentError.
+ #
+ # When called with a block, yields an HTTPResponse object.
+ # The body of this response will not have been read yet;
+ # the caller can process it using HTTPResponse#read_body,
+ # if desired.
+ #
+ # Returns a HTTPResponse object.
+ #
+ # This method never raises Net::* exceptions.
+ #
+ def request(req, body = nil, &block) # :yield: +response+
+ unless started?
+ start {
+ req['connection'] ||= 'close'
+ return request(req, body, &block)
+ }
+ end
+ if proxy_user()
+ req.proxy_basic_auth proxy_user(), proxy_pass()
+ end
- def request( req, *args )
- common_oper( req ) {
- req.__send__( :exec,
- @socket, @curr_http_version, edit_path(req.path), *args )
- yield req.response if block_given?
- }
- req.response
- end
+ begin_transport req
+ req.exec @socket, @curr_http_version, edit_path(req.path), body
+ begin
+ res = HTTPResponse.read_new(@socket)
+ end while HTTPContinue === res
+ res.reading_body(@socket, req.response_body_permitted?) {
+ yield res if block_given?
+ }
+ end_transport req, res
+ res
+ end
private
-
- def common_oper( req )
- req['connection'] ||= 'keep-alive'
- if not @socket then
- start
- req['connection'] = 'close'
- elsif @socket.closed? then
- re_connect
+ def begin_transport(req)
+ if @socket.closed?
+ @socket.reopen @open_timeout
+ on_connect
end
- if not req.body_exist? or @seems_1_0_server then
- req['connection'] = 'close'
+ if @seems_1_0_server
+ req['connection'] ||= 'close'
end
- req['host'] = addr_port
-
- yield req
- req.response.__send__ :terminate
- @curr_http_version = req.response.http_version
+ if not req.response_body_permitted? and @close_on_empty_response
+ req['connection'] ||= 'close'
+ end
+ req['host'] ||= addr_port()
+ end
- if not req.response.body then
+ def end_transport(req, res)
+ @curr_http_version = res.http_version
+ if not res.body and @close_on_empty_response
+ D 'Conn close'
@socket.close
- elsif keep_alive? req, req.response then
+ elsif keep_alive?(req, res)
D 'Conn keep-alive'
- if @socket.closed? then # (only) read stream had been closed
+ if @socket.closed?
D 'Conn (but seems 1.0 server)'
@seems_1_0_server = true
- @socket.close
end
else
D 'Conn close'
@socket.close
end
-
- req.response
end
- def keep_alive?( req, res )
- /close/i === req['connection'].to_s and return false
- @seems_1_0_server and return false
-
- /keep-alive/i === res['connection'].to_s and return true
- /close/i === res['connection'].to_s and return false
- /keep-alive/i === res['proxy-connection'].to_s and return true
- /close/i === res['proxy-connection'].to_s and return false
-
- @curr_http_version == '1.1' and return true
- false
+ def keep_alive?(req, res)
+ return false if /close/i =~ req['connection'].to_s
+ return false if @seems_1_0_server
+ return true if /keep-alive/i =~ res['connection'].to_s
+ return false if /close/i =~ res['connection'].to_s
+ return true if /keep-alive/i =~ res['proxy-connection'].to_s
+ return false if /close/i =~ res['proxy-connection'].to_s
+ (@curr_http_version == '1.1')
end
-
#
# utils
#
- public
-
- def self.get( addr, path, port = nil )
- req = Get.new( path )
- resp = nil
- new( addr, port || HTTP.port ).start {|http|
- resp = http.request( req )
- }
- resp.body
- end
-
- def self.get_print( addr, path, port = nil )
- print get( addr, path, port )
- end
-
-
private
def addr_port
- address + (port == HTTP.port ? '' : ":#{port}")
+ address + (port == HTTP.default_port ? '' : ":#{port}")
end
- def D( msg )
- if @dout then
- @dout << msg
- @dout << "\n"
- end
+ def D(msg)
+ return unless @debug_output
+ @debug_output << msg
+ @debug_output << "\n"
end
end
HTTPSession = HTTP
-
-
- class Code
-
- def http_mkchild( bodyexist = nil )
- c = mkchild(nil)
- be = if bodyexist.nil? then @body_exist else bodyexist end
- c.instance_eval { @body_exist = be }
- c
- end
-
- def body_exist?
- @body_exist
- end
-
- end
-
- HTTPInformationCode = InformationCode.http_mkchild( false )
- HTTPSuccessCode = SuccessCode .http_mkchild( true )
- HTTPRedirectionCode = RetriableCode .http_mkchild( true )
- HTTPRetriableCode = HTTPRedirectionCode
- HTTPClientErrorCode = FatalErrorCode .http_mkchild( true )
- HTTPFatalErrorCode = HTTPClientErrorCode
- HTTPServerErrorCode = ServerErrorCode.http_mkchild( true )
-
-
- HTTPSwitchProtocol = HTTPInformationCode.http_mkchild
-
- HTTPOK = HTTPSuccessCode.http_mkchild
- HTTPCreated = HTTPSuccessCode.http_mkchild
- HTTPAccepted = HTTPSuccessCode.http_mkchild
- HTTPNonAuthoritativeInformation = HTTPSuccessCode.http_mkchild
- HTTPNoContent = HTTPSuccessCode.http_mkchild( false )
- HTTPResetContent = HTTPSuccessCode.http_mkchild( false )
- HTTPPartialContent = HTTPSuccessCode.http_mkchild
-
- HTTPMultipleChoice = HTTPRedirectionCode.http_mkchild
- HTTPMovedPermanently = HTTPRedirectionCode.http_mkchild
- HTTPMovedTemporarily = HTTPRedirectionCode.http_mkchild
- HTTPNotModified = HTTPRedirectionCode.http_mkchild( false )
- HTTPUseProxy = HTTPRedirectionCode.http_mkchild( false )
-
- HTTPBadRequest = HTTPClientErrorCode.http_mkchild
- HTTPUnauthorized = HTTPClientErrorCode.http_mkchild
- HTTPPaymentRequired = HTTPClientErrorCode.http_mkchild
- HTTPForbidden = HTTPClientErrorCode.http_mkchild
- HTTPNotFound = HTTPClientErrorCode.http_mkchild
- HTTPMethodNotAllowed = HTTPClientErrorCode.http_mkchild
- HTTPNotAcceptable = HTTPClientErrorCode.http_mkchild
- HTTPProxyAuthenticationRequired = HTTPClientErrorCode.http_mkchild
- HTTPRequestTimeOut = HTTPClientErrorCode.http_mkchild
- HTTPConflict = HTTPClientErrorCode.http_mkchild
- HTTPGone = HTTPClientErrorCode.http_mkchild
- HTTPLengthRequired = HTTPClientErrorCode.http_mkchild
- HTTPPreconditionFailed = HTTPClientErrorCode.http_mkchild
- HTTPRequestEntityTooLarge = HTTPClientErrorCode.http_mkchild
- HTTPRequestURITooLarge = HTTPClientErrorCode.http_mkchild
- HTTPUnsupportedMediaType = HTTPClientErrorCode.http_mkchild
-
- HTTPNotImplemented = HTTPServerErrorCode.http_mkchild
- HTTPBadGateway = HTTPServerErrorCode.http_mkchild
- HTTPServiceUnavailable = HTTPServerErrorCode.http_mkchild
- HTTPGatewayTimeOut = HTTPServerErrorCode.http_mkchild
- HTTPVersionNotSupported = HTTPServerErrorCode.http_mkchild
-
-
-
- ###
- ### header
- ###
-
- net_private {
-
+ #
+ # Header module.
+ #
+ # Provides access to @header in the mixed-into class as a hash-like
+ # object, except with case-insensitive keys. Also provides
+ # methods for accessing commonly-used header values in a more
+ # convenient format.
+ #
module HTTPHeader
- def size
+ def size #:nodoc: obsolete
@header.size
end
- alias length size
+ alias length size #:nodoc: obsolete
- def []( key )
- @header[ key.downcase ]
+ # Returns the header field corresponding to the case-insensitive key.
+ # For example, a key of "Content-Type" might return "text/html"
+ def [](key)
+ @header[key.downcase]
end
- def []=( key, val )
- @header[ key.downcase ] = val
+ # Sets the header field corresponding to the case-insensitive key.
+ def []=(key, val)
+ @header[key.downcase] = val
end
- def each( &block )
- @header.each( &block )
+ # Returns the header field corresponding to the case-insensitive key.
+ # Returns the default value +args+, or the result of the block, or nil,
+ # if there's no header field named key. See Hash#fetch
+ def fetch(key, *args, &block) #:yield: +key+
+ @header.fetch(key.downcase, *args, &block)
end
- def each_key( &block )
- @header.each_key( &block )
+ # Iterates for each header names and values.
+ def each_header(&block) #:yield: +key+, +value+
+ @header.each(&block)
end
- def each_value( &block )
- @header.each_value( &block )
+ alias each each_header
+
+ # Iterates for each header names.
+ def each_key(&block) #:yield: +key+
+ @header.each_key(&block)
+ end
+
+ # Iterates for each header values.
+ def each_value(&block) #:yield: +value+
+ @header.each_value(&block)
end
- def delete( key )
- @header.delete key.downcase
+ # Removes a header field.
+ def delete(key)
+ @header.delete(key.downcase)
end
- def key?( key )
- @header.key? key.downcase
+ # true if +key+ header exists.
+ def key?(key)
+ @header.key?(key.downcase)
end
+ # Returns a Hash consist of header names and values.
def to_hash
@header.dup
end
+ # As for #each_header, except the keys are provided in capitalized form.
def canonical_each
@header.each do |k,v|
yield canonical(k), v
@@ -705,47 +977,43 @@ module Net
end
def canonical( k )
- k.split('-').collect {|i| i.capitalize }.join('-')
+ k.split(/-/).map {|i| i.capitalize }.join('-')
end
+ private :canonical
+ # Returns a Range object which represents Range: header field,
+ # or +nil+ if there is no such header.
def range
- s = @header['range']
- s or return nil
-
- arr = []
- s.split(',').each do |spec|
- m = /bytes\s*=\s*(\d+)?\s*-\s*(\d+)?/i.match( spec )
- m or raise HTTPHeaderSyntaxError, "wrong Range: #{spec}"
-
+ s = @header['range'] or return nil
+ s.split(/,/).map {|spec|
+ m = /bytes\s*=\s*(\d+)?\s*-\s*(\d+)?/i.match(spec) or
+ raise HTTPHeaderSyntaxError, "wrong Range: #{spec}"
d1 = m[1].to_i
d2 = m[2].to_i
- if m[1] and m[2] then arr.push (d1 .. d2)
- elsif m[1] then arr.push (d1 .. -1)
- elsif m[2] then arr.push (-d2 .. -1)
+ if m[1] and m[2] then d1..d2
+ elsif m[1] then d1..-1
+ elsif m[2] then -d2..-1
else
raise HTTPHeaderSyntaxError, 'range is not specified'
end
- end
-
- return *arr
+ }
end
- def range=( r, fin = nil )
- if fin then
- r = r ... r+fin
- end
-
+ # Set Range: header from Range (arg r) or beginning index and
+ # length from it (arg i&len).
+ def range=(r, fin = nil)
+ r = (r ... r + fin) if fin
case r
when Numeric
s = r > 0 ? "0-#{r - 1}" : "-#{-r}"
when Range
first = r.first
last = r.last
- if r.exclude_end? then
+ if r.exclude_end?
last -= 1
end
- if last == -1 then
+ if last == -1
s = first > 0 ? "#{first}-" : "-#{-first}"
else
first >= 0 or raise HTTPHeaderSyntaxError, 'range.first is negative'
@@ -763,266 +1031,461 @@ module Net
alias set_range range=
+ # Returns an Integer object which represents the Content-Length: header field
+ # or +nil+ if that field is not provided.
def content_length
- s = @header['content-length']
- s or return nil
-
- m = /\d+/.match(s)
- m or raise HTTPHeaderSyntaxError, 'wrong Content-Length format'
+ s = @header['content-length'] or return nil
+ m = /\d+/.match(s) or
+ raise HTTPHeaderSyntaxError, 'wrong Content-Length format'
m[0].to_i
end
+ # Returns "true" if the "transfer-encoding" header is present and
+ # set to "chunked". This is an HTTP/1.1 feature, allowing the
+ # the content to be sent in "chunks" without at the outset
+ # stating the entire content length.
def chunked?
s = @header['transfer-encoding']
(s and /(?:\A|[^\-\w])chunked(?:[^\-\w]|\z)/i === s) ? true : false
end
+ # Returns a Range object which represents Content-Range: header field.
+ # This indicates, for a partial entity body, where this fragment
+ # fits inside the full entity body, as range of byte offsets.
def content_range
- s = @header['content-range']
- s or return nil
-
- m = %r<bytes\s+(\d+)-(\d+)/(?:\d+|\*)>i.match( s )
- m or raise HTTPHeaderSyntaxError, 'wrong Content-Range format'
-
+ s = @header['content-range'] or return nil
+ m = %r<bytes\s+(\d+)-(\d+)/(?:\d+|\*)>i.match(s) or
+ raise HTTPHeaderSyntaxError, 'wrong Content-Range format'
m[1].to_i .. m[2].to_i + 1
end
+ # The length of the range represented in Range: header.
def range_length
- r = content_range
- r and r.length
+ r = self.content_range
+ r and (r.end - r.begin)
end
- def basic_auth( acc, pass )
- @header['authorization'] =
- 'Basic ' + ["#{acc}:#{pass}"].pack('m').gsub(/\s+/, '')
+ # Set the Authorization: header for "Basic" authorization.
+ def basic_auth(account, password)
+ @header['authorization'] = basic_encode(account, password)
end
- end
-
- }
-
+ # Set Proxy-Authorization: header for "Basic" authorization.
+ def proxy_basic_auth(account, password)
+ @header['proxy-authorization'] = basic_encode(account, password)
+ end
- ###
- ### request
- ###
+ def basic_encode(account, password)
+ 'Basic ' + ["#{account}:#{password}"].pack('m').strip
+ end
+ private :basic_encode
- net_private {
+ end
- class HTTPRequest
+ #
+ # Parent of HTTPRequest class. Do not use this directly; use
+ # a subclass of HTTPRequest.
+ #
+ # Mixes in the HTTPHeader module.
+ #
+ class HTTPGenericRequest
- include ::Net::NetPrivate::HTTPHeader
+ include HTTPHeader
- def initialize( path, uhead = nil )
+ def initialize(m, reqbody, resbody, path, initheader = nil)
+ @method = m
+ @request_has_body = reqbody
+ @response_has_body = resbody
@path = path
- @header = tmp = {}
- return unless uhead
- uhead.each do |k,v|
+
+ @header = {}
+ return unless initheader
+ initheader.each do |k,v|
key = k.downcase
- if tmp.key? key then
- $stderr.puts "WARNING: duplicated HTTP header: #{k}" if $VERBOSE
- end
- tmp[ key ] = v.strip
+ $stderr.puts "net/http: warning: duplicated HTTP header: #{k}" if @header.key?(key) and $VERBOSE
+ @header[key] = v.strip
end
- tmp['accept'] ||= '*/*'
-
- @socket = nil
- @response = nil
+ @header['accept'] ||= '*/*'
end
+ attr_reader :method
attr_reader :path
- attr_reader :response
def inspect
- "\#<#{type}>"
+ "\#<#{self.class} #{@method}>"
end
- def body_exist?
- type::HAS_BODY
+ def request_body_permitted?
+ @request_has_body
end
+ def response_body_permitted?
+ @response_has_body
+ end
- private
+ alias body_exist? response_body_permitted?
#
# write
#
- def exec( sock, ver, path )
- ready( sock ) {
- request ver, path
- }
- @response
- end
-
- def ready( sock )
- @response = nil
- @socket = sock
- yield
- @response = get_response
- @socket = nil
- end
-
- def request( ver, path )
- @socket.writeline sprintf('%s %s HTTP/%s', type::METHOD, path, ver)
- canonical_each do |k,v|
- @socket.writeline k + ': ' + v
+ def exec(sock, ver, path, body) #:nodoc: internal use only
+ if body
+ check_body_permitted
+ send_request_with_body sock, ver, path, body
+ else
+ request sock, ver, path
end
- @socket.writeline ''
- end
-
- #
- # read
- #
-
- def get_response
- begin
- resp = read_response
- end while ContinueCode === resp
- resp
end
- def read_response
- resp = get_resline
-
- while true do
- line = @socket.readuntil( "\n", true ) # ignore EOF
- line.sub!( /\s+\z/, '' ) # don't use chop!
- break if line.empty?
-
- m = /\A([^:]+):\s*/.match( line )
- m or raise HTTPBadResponse, 'wrong header line format'
- nm = m[1]
- line = m.post_match
- if resp.key? nm then
- resp[nm] << ', ' << line
- else
- resp[nm] = line
- end
- end
+ private
- resp
+ def check_body_permitted
+ request_body_permitted? or
+ raise ArgumentError, 'HTTP request body is not permitted'
end
- def get_resline
- str = @socket.readline
- m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/i.match( str )
- m or raise HTTPBadResponse, "wrong status line: #{str}"
- httpver = m[1]
- status = m[2]
- discrip = m[3]
-
- ::Net::NetPrivate::HTTPResponse.new(
- status, discrip, @socket, type::HAS_BODY, httpver )
- end
-
- end
-
-
- class HTTPRequestWithBody < HTTPRequest
-
- private
-
- def exec( sock, ver, path, str = nil )
- check_arg str, block_given?
+ def send_request_with_body( sock, ver, path, body )
+ @header['content-length'] = body.length.to_s
+ @header.delete 'transfer-encoding'
- if block_given? then
- ac = Accumulator.new
- yield ac # must be yield, DO NOT USE block.call
- data = ac.terminate
- else
- data = str
+ unless @header['content-type']
+ $stderr.puts 'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded' if $VERBOSE
+ @header['content-type'] = 'application/x-www-form-urlencoded'
end
- @header['content-length'] = data.size.to_s
- @header.delete 'transfer-encoding'
- ready( sock ) {
- request ver, path
- @socket.write data
- }
- @response
+ request sock, ver, path
+ sock.write body
end
- def check_arg( data, blkp )
- if data and blkp then
- raise ArgumentError, 'both of data and block given'
- end
- unless data or blkp then
- raise ArgumentError, 'str or block required'
+ def request(sock, ver, path)
+ buf = "#{@method} #{path} HTTP/#{ver}\r\n"
+ canonical_each do |k,v|
+ buf << k + ': ' + v + "\r\n"
end
+ buf << "\r\n"
+ sock.write buf
end
end
- class Accumulator
-
- def initialize
- @buf = ''
- end
+ #
+ # HTTP request class. This class wraps request header and entity path.
+ # You *must* use its subclass, Net::HTTP::Get, Post, Head.
+ #
+ class HTTPRequest < HTTPGenericRequest
- def write( s )
- @buf.concat s
+ # Creates HTTP request object.
+ def initialize(path, initheader = nil)
+ super self.class::METHOD,
+ self.class::REQUEST_HAS_BODY,
+ self.class::RESPONSE_HAS_BODY,
+ path, initheader
end
-
- alias << write
-
- def terminate
- ret = @buf
- @buf = nil
- ret
- end
-
end
- }
-
class HTTP
- class Get < ::Net::NetPrivate::HTTPRequest
- HAS_BODY = true
+ class Get < HTTPRequest
METHOD = 'GET'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = true
end
- class Head < ::Net::NetPrivate::HTTPRequest
- HAS_BODY = false
+ class Head < HTTPRequest
METHOD = 'HEAD'
+ REQUEST_HAS_BODY = false
+ RESPONSE_HAS_BODY = false
end
- class Post < ::Net::NetPrivate::HTTPRequestWithBody
- HAS_BODY = true
+ class Post < HTTPRequest
METHOD = 'POST'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
end
- class Put < ::Net::NetPrivate::HTTPRequestWithBody
- HAS_BODY = true
+ class Put < HTTPRequest
METHOD = 'PUT'
+ REQUEST_HAS_BODY = true
+ RESPONSE_HAS_BODY = true
end
end
-
###
- ### response
+ ### Response
###
- net_private {
+ # HTTP exception class.
+ # You must use its subclasses.
+ module HTTPExceptions
+ def initialize(msg, res) #:nodoc:
+ super msg
+ @response = res
+ end
+ attr_reader :response
+ alias data response #:nodoc: obsolete
+ end
+ class HTTPError < ProtocolError
+ include HTTPExceptions
+ end
+ class HTTPRetriableError < ProtoRetriableError
+ include HTTPExceptions
+ end
+ class HTTPServerException < ProtoServerError
+ # We cannot use the name "HTTPServerError", it is the name of the response.
+ include HTTPExceptions
+ end
+ class HTTPFatalError < ProtoFatalError
+ include HTTPExceptions
+ end
+
+
+ # HTTP response class. This class wraps response header and entity.
+ # Mixes in the HTTPHeader module, which provides access to response
+ # header values both via hash-like methods and individual readers.
+ # Note that each possible HTTP response code defines its own
+ # HTTPResponse subclass. These are listed below.
+ # All classes are
+ # defined under the Net module. Indentation indicates inheritance.
+ #
+ # xxx HTTPResponse
+ #
+ # 1xx HTTPInformation
+ # 100 HTTPContinue
+ # 101 HTTPSwitchProtocol
+ #
+ # 2xx HTTPSuccess
+ # 200 HTTPOK
+ # 201 HTTPCreated
+ # 202 HTTPAccepted
+ # 203 HTTPNonAuthoritativeInformation
+ # 204 HTTPNoContent
+ # 205 HTTPResetContent
+ # 206 HTTPPartialContent
+ #
+ # 3xx HTTPRedirection
+ # 300 HTTPMultipleChoice
+ # 301 HTTPMovedPermanently
+ # 302 HTTPFound
+ # 303 HTTPSeeOther
+ # 304 HTTPNotModified
+ # 305 HTTPUseProxy
+ # 307 HTTPTemporaryRedirect
+ #
+ # 4xx HTTPClientError
+ # 400 HTTPBadRequest
+ # 401 HTTPUnauthorized
+ # 402 HTTPPaymentRequired
+ # 403 HTTPForbidden
+ # 404 HTTPNotFound
+ # 405 HTTPMethodNotAllowed
+ # 406 HTTPNotAcceptable
+ # 407 HTTPProxyAuthenticationRequired
+ # 408 HTTPRequestTimeOut
+ # 409 HTTPConflict
+ # 410 HTTPGone
+ # 411 HTTPLengthRequired
+ # 412 HTTPPreconditionFailed
+ # 413 HTTPRequestEntityTooLarge
+ # 414 HTTPRequestURITooLong
+ # 415 HTTPUnsupportedMediaType
+ # 416 HTTPRequestedRangeNotSatisfiable
+ # 417 HTTPExpectationFailed
+ #
+ # 5xx HTTPServerError
+ # 500 HTTPInternalServerError
+ # 501 HTTPNotImplemented
+ # 502 HTTPBadGateway
+ # 503 HTTPServiceUnavailable
+ # 504 HTTPGatewayTimeOut
+ # 505 HTTPVersionNotSupported
+ #
+ # xxx HTTPUnknownResponse
+ #
+ class HTTPResponse
+ # true if the response has body.
+ def HTTPResponse.body_permitted?
+ self::HAS_BODY
+ end
+
+ def HTTPResponse.exception_type # :nodoc: internal use only
+ self::EXCEPTION_TYPE
+ end
+ end # redefined after
+
+ # :stopdoc:
+
+ class HTTPUnknownResponse < HTTPResponse
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPError
+ end
+ class HTTPInformation < HTTPResponse # 1xx
+ HAS_BODY = false
+ EXCEPTION_TYPE = HTTPError
+ end
+ class HTTPSuccess < HTTPResponse # 2xx
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPError
+ end
+ class HTTPRedirection < HTTPResponse # 3xx
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPRetriableError
+ end
+ class HTTPClientError < HTTPResponse # 4xx
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPServerException # for backward compatibility
+ end
+ class HTTPServerError < HTTPResponse # 5xx
+ HAS_BODY = true
+ EXCEPTION_TYPE = HTTPFatalError # for backward compatibility
+ end
+
+ class HTTPContinue < HTTPInformation # 100
+ HAS_BODY = false
+ end
+ class HTTPSwitchProtocol < HTTPInformation # 101
+ HAS_BODY = false
+ end
+
+ class HTTPOK < HTTPSuccess # 200
+ HAS_BODY = true
+ end
+ class HTTPCreated < HTTPSuccess # 201
+ HAS_BODY = true
+ end
+ class HTTPAccepted < HTTPSuccess # 202
+ HAS_BODY = true
+ end
+ class HTTPNonAuthoritativeInformation < HTTPSuccess # 203
+ HAS_BODY = true
+ end
+ class HTTPNoContent < HTTPSuccess # 204
+ HAS_BODY = false
+ end
+ class HTTPResetContent < HTTPSuccess # 205
+ HAS_BODY = false
+ end
+ class HTTPPartialContent < HTTPSuccess # 206
+ HAS_BODY = true
+ end
+
+ class HTTPMultipleChoice < HTTPRedirection # 300
+ HAS_BODY = true
+ end
+ class HTTPMovedPermanently < HTTPRedirection # 301
+ HAS_BODY = true
+ end
+ class HTTPFound < HTTPRedirection # 302
+ HAS_BODY = true
+ end
+ HTTPMovedTemporarily = HTTPFound
+ class HTTPSeeOther < HTTPRedirection # 303
+ HAS_BODY = true
+ end
+ class HTTPNotModified < HTTPRedirection # 304
+ HAS_BODY = false
+ end
+ class HTTPUseProxy < HTTPRedirection # 305
+ HAS_BODY = false
+ end
+ # 306 unused
+ class HTTPTemporaryRedirect < HTTPRedirection # 307
+ HAS_BODY = true
+ end
- class HTTPResponse < Response
+ class HTTPBadRequest < HTTPClientError # 400
+ HAS_BODY = true
+ end
+ class HTTPUnauthorized < HTTPClientError # 401
+ HAS_BODY = true
+ end
+ class HTTPPaymentRequired < HTTPClientError # 402
+ HAS_BODY = true
+ end
+ class HTTPForbidden < HTTPClientError # 403
+ HAS_BODY = true
+ end
+ class HTTPNotFound < HTTPClientError # 404
+ HAS_BODY = true
+ end
+ class HTTPMethodNotAllowed < HTTPClientError # 405
+ HAS_BODY = true
+ end
+ class HTTPNotAcceptable < HTTPClientError # 406
+ HAS_BODY = true
+ end
+ class HTTPProxyAuthenticationRequired < HTTPClientError # 407
+ HAS_BODY = true
+ end
+ class HTTPRequestTimeOut < HTTPClientError # 408
+ HAS_BODY = true
+ end
+ class HTTPConflict < HTTPClientError # 409
+ HAS_BODY = true
+ end
+ class HTTPGone < HTTPClientError # 410
+ HAS_BODY = true
+ end
+ class HTTPLengthRequired < HTTPClientError # 411
+ HAS_BODY = true
+ end
+ class HTTPPreconditionFailed < HTTPClientError # 412
+ HAS_BODY = true
+ end
+ class HTTPRequestEntityTooLarge < HTTPClientError # 413
+ HAS_BODY = true
+ end
+ class HTTPRequestURITooLong < HTTPClientError # 414
+ HAS_BODY = true
+ end
+ HTTPRequestURITooLarge = HTTPRequestURITooLong
+ class HTTPUnsupportedMediaType < HTTPClientError # 415
+ HAS_BODY = true
+ end
+ class HTTPRequestedRangeNotSatisfiable < HTTPClientError # 416
+ HAS_BODY = true
+ end
+ class HTTPExpectationFailed < HTTPClientError # 417
+ HAS_BODY = true
+ end
+
+ class HTTPInternalServerError < HTTPServerError # 500
+ HAS_BODY = true
+ end
+ class HTTPNotImplemented < HTTPServerError # 501
+ HAS_BODY = true
+ end
+ class HTTPBadGateway < HTTPServerError # 502
+ HAS_BODY = true
+ end
+ class HTTPServiceUnavailable < HTTPServerError # 503
+ HAS_BODY = true
+ end
+ class HTTPGatewayTimeOut < HTTPServerError # 504
+ HAS_BODY = true
+ end
+ class HTTPVersionNotSupported < HTTPServerError # 505
+ HAS_BODY = true
+ end
+
+ # :startdoc:
- include ::Net::NetPrivate::HTTPHeader
+
+ class HTTPResponse # redefine
CODE_CLASS_TO_OBJ = {
- '1' => HTTPInformationCode,
- '2' => HTTPSuccessCode,
- '3' => HTTPRedirectionCode,
- '4' => HTTPClientErrorCode,
- '5' => HTTPServerErrorCode
+ '1' => HTTPInformation,
+ '2' => HTTPSuccess,
+ '3' => HTTPRedirection,
+ '4' => HTTPClientError,
+ '5' => HTTPServerError
}
-
CODE_TO_OBJ = {
- '100' => ContinueCode,
+ '100' => HTTPContinue,
'101' => HTTPSwitchProtocol,
'200' => HTTPOK,
@@ -1035,10 +1498,11 @@ module Net
'300' => HTTPMultipleChoice,
'301' => HTTPMovedPermanently,
- '302' => HTTPMovedTemporarily,
- '303' => HTTPMovedPermanently,
+ '302' => HTTPFound,
+ '303' => HTTPSeeOther,
'304' => HTTPNotModified,
'305' => HTTPUseProxy,
+ '307' => HTTPTemporaryRedirect,
'400' => HTTPBadRequest,
'401' => HTTPUnauthorized,
@@ -1051,13 +1515,15 @@ module Net
'408' => HTTPRequestTimeOut,
'409' => HTTPConflict,
'410' => HTTPGone,
- '411' => HTTPFatalErrorCode,
+ '411' => HTTPLengthRequired,
'412' => HTTPPreconditionFailed,
'413' => HTTPRequestEntityTooLarge,
- '414' => HTTPRequestURITooLarge,
+ '414' => HTTPRequestURITooLong,
'415' => HTTPUnsupportedMediaType,
+ '416' => HTTPRequestedRangeNotSatisfiable,
+ '417' => HTTPExpectationFailed,
- '500' => HTTPFatalErrorCode,
+ '501' => HTTPInternalServerError,
'501' => HTTPNotImplemented,
'502' => HTTPBadGateway,
'503' => HTTPServiceUnavailable,
@@ -1065,88 +1531,211 @@ module Net
'505' => HTTPVersionNotSupported
}
- def initialize( stat, msg, sock, be, hv )
- code = CODE_TO_OBJ[stat] ||
- CODE_CLASS_TO_OBJ[stat[0,1]] ||
- UnknownCode
- super code, stat, msg
- @socket = sock
- @body_exist = be
- @http_version = hv
+
+ class << self
+
+ def read_new(sock) #:nodoc: internal use only
+ httpv, code, msg = read_status_line(sock)
+ res = response_class(code).new(httpv, code, msg)
+ each_response_header(sock) do |k,v|
+ if res.key?(k)
+ res[k] << ', ' << v
+ else
+ res[k] = v
+ end
+ end
+
+ res
+ end
+
+ private
+
+ def read_status_line(sock)
+ str = sock.readline
+ m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in.match(str) or
+ raise HTTPBadResponse, "wrong status line: #{str.dump}"
+ m.to_a[1,3]
+ end
+
+ def response_class(code)
+ CODE_TO_OBJ[code] or
+ CODE_CLASS_TO_OBJ[code[0,1]] or
+ HTTPUnknownResponse
+ end
+
+ def each_response_header(sock)
+ while true
+ line = sock.readuntil("\n", true).sub(/\s+\z/, '')
+ break if line.empty?
+ m = /\A([^:]+):\s*/.match(line) or
+ raise HTTPBadResponse, 'wrong header line format'
+ yield m[1], m.post_match
+ end
+ end
+
+ end
+
+ # next is to fix bug in RDoc, where the private inside class << self
+ # spills out.
+ public
+
+ include HTTPHeader
+
+ def initialize(httpv, code, msg) #:nodoc: internal use only
+ @http_version = httpv
+ @code = code
+ @message = msg
@header = {}
@body = nil
@read = false
end
+ # The HTTP version supported by the server.
attr_reader :http_version
+ # HTTP result code string. For example, '302'. You can also
+ # determine the response type by which response subclass the
+ # response object is an instance of.
+ attr_reader :code
+
+ # HTTP result message. For example, 'Not Found'.
+ attr_reader :message
+ alias msg message # :nodoc: obsolete
+
def inspect
- "#<#{type} #{code}>"
+ "#<#{self.class} #{@code} readbody=#{@read}>"
end
- def value
- SuccessCode === self or error! self
+ # For backward compatibility.
+ # To allow Net::HTTP 1.1 style assignment
+ # e.g.
+ # response, body = Net::HTTP.get(....)
+ #
+ def to_ary
+ warn "net/http.rb: warning: Net::HTTP v1.1 style assignment found at #{caller(1)[0]}; use `response = http.get(...)' instead." if $VERBOSE
+ [self, body()]
end
+ #
+ # response <-> exception relationship
+ #
+
+ def code_type #:nodoc:
+ self.class
+ end
+
+ def error! #:nodoc:
+ raise error_type().new(@code + ' ' + @message.dump, self)
+ end
+
+ def error_type #:nodoc:
+ self.class::EXCEPTION_TYPE
+ end
+
+ # Raises HTTP error if the response is not 2xx.
+ def value
+ error! unless HTTPSuccess === self
+ end
#
- # header (for backward compatibility)
+ # header (for backward compatibility only; DO NOT USE)
#
- def read_header
+ def response #:nodoc:
self
end
- alias header read_header
- alias response read_header
+ alias header response #:nodoc:
+ alias read_header response #:nodoc:
#
# body
#
- def read_body( dest = nil, &block )
- if @read and (dest or block) then
- raise IOError, "#{type}\#read_body called twice with argument"
+ def reading_body(sock, reqmethodallowbody) #:nodoc: internal use only
+ @socket = sock
+ @body_exist = reqmethodallowbody && self.class.body_permitted?
+ begin
+ yield
+ self.body # ensure to read body
+ ensure
+ @socket = nil
end
+ end
- unless @read then
- to = procdest( dest, block )
- stream_check
-
- if @body_exist and code_type.body_exist? then
- read_body_0 to
- @body = to
- else
- @body = nil
- end
- @read = true
+ # Gets entity body. If the block given, yields it to +block+.
+ # The body is provided in fragments, as it is read in from the socket.
+ #
+ # Calling this method a second or subsequent time will return the
+ # already read string.
+ #
+ # http.request_get('/index.html') {|res|
+ # puts res.read_body
+ # }
+ #
+ # http.request_get('/index.html') {|res|
+ # p res.read_body.object_id # 538149362
+ # p res.read_body.object_id # 538149362
+ # }
+ #
+ # # using iterator
+ # http.request_get('/index.html') {|res|
+ # res.read_body do |segment|
+ # print segment
+ # end
+ # }
+ #
+ def read_body(dest = nil, &block)
+ if @read
+ raise IOError, "#{self.class}\#read_body called twice" if dest or block
+ return @body
end
+ to = procdest(dest, block)
+ stream_check
+ if @body_exist
+ read_body_0 to
+ @body = to
+ else
+ @body = nil
+ end
+ @read = true
@body
end
- alias body read_body
- alias entity read_body
+ # Returns the entity body.
+ #
+ # Calling this method a second or subsequent time will return the
+ # already read string.
+ #
+ # http.request_get('/index.html') {|res|
+ # puts res.body
+ # }
+ #
+ # http.request_get('/index.html') {|res|
+ # p res.body.object_id # 538149362
+ # p res.body.object_id # 538149362
+ # }
+ #
+ def body
+ read_body()
+ end
+ alias entity body #:nodoc: obsolete
private
-
- def terminate
- read_body
- end
-
- def read_body_0( dest )
- if chunked? then
+ def read_body_0(dest)
+ if chunked?
read_chunked dest
else
- clen = content_length
- if clen then
+ clen = content_length()
+ if clen
@socket.read clen, dest, true # ignore EOF
else
- clen = range_length
- if clen then
+ clen = range_length()
+ if clen
@socket.read clen, dest
else
@socket.read_all dest
@@ -1155,34 +1744,32 @@ module Net
end
end
- def read_chunked( dest )
+ def read_chunked(dest)
len = nil
total = 0
-
- while true do
+ while true
line = @socket.readline
- m = /[0-9a-fA-F]+/.match( line )
- m or raise HTTPBadResponse, "wrong chunk size line: #{line}"
- len = m[0].hex
+ hexlen = line.slice(/[0-9a-fA-F]+/) or
+ raise HTTPBadResponse, "wrong chunk size line: #{line}"
+ len = hexlen.hex
break if len == 0
- @socket.read( len, dest ); total += len
+ @socket.read len, dest; total += len
@socket.read 2 # \r\n
end
- until @socket.readline.empty? do
- ;
+ until @socket.readline.empty?
+ # none
end
end
def stream_check
- @socket.closed? and raise IOError, 'try to read body out of block'
+ raise IOError, 'attempt to read body out of block' if @socket.closed?
end
- def procdest( dest, block )
- if dest and block then
- raise ArgumentError, 'both of arg and block are given for HTTP method'
- end
- if block then
- ::Net::NetPrivate::ReadAdapter.new block
+ def procdest(dest, block)
+ raise ArgumentError, 'both arg and block given for HTTP method' \
+ if dest and block
+ if block
+ ReadAdapter.new(block)
else
dest || ''
end
@@ -1190,10 +1777,25 @@ module Net
end
- }
+ # :enddoc:
+
+ # for backward compatibility
+
+ class HTTP
+ ProxyMod = ProxyDelta
+ end
+ module NetPrivate
+ HTTPRequest = ::Net::HTTPRequest
+ end
- HTTPResponse = NetPrivate::HTTPResponse
- HTTPResponseReceiver = NetPrivate::HTTPResponse
+ HTTPInformationCode = HTTPInformation
+ HTTPSuccessCode = HTTPSuccess
+ HTTPRedirectionCode = HTTPRedirection
+ HTTPRetriableCode = HTTPRedirection
+ HTTPClientErrorCode = HTTPClientError
+ HTTPFatalErrorCode = HTTPClientError
+ HTTPServerErrorCode = HTTPServerError
+ HTTPResponceReceiver = HTTPResponse
end # module Net
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index ea064d2552..7886c66fdd 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -1,917 +1,992 @@
-=begin
+#
+# = net/imap.rb
+#
+# Copyright (C) 2000 Shugo Maeda <shugo@ruby-lang.org>
+#
+# This library is distributed under the terms of the Ruby license.
+# You can freely distribute/modify this library.
+#
+# Documentation: Shugo Maeda, with RDoc conversion and overview by William
+# Webber.
+#
+# See Net::IMAP for documentation.
+#
-= net/imap.rb
-Copyright (C) 2000 Shugo Maeda <shugo@ruby-lang.org>
-
-This library is distributed under the terms of the Ruby license.
-You can freely distribute/modify this library.
-
-== Net::IMAP
-
-Net::IMAP implements Internet Message Access Protocol (IMAP) clients.
-(The protocol is described in ((<[IMAP]>)).)
-
-=== Super Class
-
-Object
-
-=== Class Methods
-
-: new(host, port = 143)
- Creates a new Net::IMAP object and connects it to the specified
- port on the named host.
-
-: debug
- Returns the debug mode.
-
-: debug = val
- Sets the debug mode.
-
-: add_authenticator(auth_type, authenticator)
- Adds an authenticator for Net::IMAP#authenticate.
-
-=== Methods
-
-: greeting
- Returns an initial greeting response from the server.
-
-: responses
- Returns recorded untagged responses.
-
- ex).
- imap.select("inbox")
- p imap.responses["EXISTS"][-1]
- #=> 2
- p imap.responses["UIDVALIDITY"][-1]
- #=> 968263756
-
-: disconnect
- Disconnects from the server.
-
-: capability
- Sends a CAPABILITY command, and returns a listing of
- capabilities that the server supports.
-
-: noop
- Sends a NOOP command to the server. It does nothing.
-
-: logout
- Sends a LOGOUT command to inform the server that the client is
- done with the connection.
-
-: authenticate(auth_type, arg...)
- Sends an AUTEHNTICATE command to authenticate the client.
- The auth_type parameter is a string that represents
- the authentication mechanism to be used. Currently Net::IMAP
- supports "LOGIN" and "CRAM-MD5" for the auth_type.
-
- ex).
- imap.authenticate('LOGIN', user, password)
-
-: login(user, password)
- Sends a LOGIN command to identify the client and carries
- the plaintext password authenticating this user.
-
-: select(mailbox)
- Sends a SELECT command to select a mailbox so that messages
- in the mailbox can be accessed.
-
-: examine(mailbox)
- Sends a EXAMINE command to select a mailbox so that messages
- in the mailbox can be accessed. However, the selected mailbox
- is identified as read-only.
-
-: create(mailbox)
- Sends a CREATE command to create a new mailbox.
-
-: delete(mailbox)
- Sends a DELETE command to remove the mailbox.
-
-: rename(mailbox, newname)
- Sends a RENAME command to change the name of the mailbox to
- the newname.
-
-: subscribe(mailbox)
- Sends a SUBSCRIBE command to add the specified mailbox name to
- the server's set of "active" or "subscribed" mailboxes.
-
-: unsubscribe(mailbox)
- Sends a UNSUBSCRIBE command to remove the specified mailbox name
- from the server's set of "active" or "subscribed" mailboxes.
-
-: list(refname, mailbox)
- Sends a LIST command, and returns a subset of names from
- the complete set of all names available to the client.
- The return value is an array of ((<Net::IMAP::MailboxList>)).
-
- ex).
- imap.create("foo/bar")
- imap.create("foo/baz")
- p imap.list("", "foo/%")
- #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, #<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
-
-: lsub(refname, mailbox)
- Sends a LSUB command, and returns a subset of names from the set
- of names that the user has declared as being "active" or
- "subscribed".
- The return value is an array of ((<Net::IMAP::MailboxList>)).
-
-: status(mailbox, attr)
- Sends a STATUS command, and returns the status of the indicated
- mailbox.
- The return value is a hash of attributes.
-
- ex).
- p imap.status("inbox", ["MESSAGES", "RECENT"])
- #=> {"RECENT"=>0, "MESSAGES"=>44}
-
-: append(mailbox, message, flags = nil, date_time = nil)
- Sends a APPEND command to append the message to the end of
- the mailbox.
-
- ex).
- imap.append("inbox", <<EOF.gsub(/\n/, "\r\n"), [:Seen], Time.now)
- Subject: hello
- From: shugo@ruby-lang.org
- To: shugo@ruby-lang.org
-
- hello world
- EOF
-
-: check
- Sends a CHECK command to request a checkpoint of the currently
- selected mailbox.
-
-: close
- Sends a CLOSE command to close the currently selected mailbox.
- The CLOSE command permanently removes from the mailbox all
- messages that have the \Deleted flag set.
-
-: expunge
- Sends a EXPUNGE command to permanently remove from the currently
- selected mailbox all messages that have the \Deleted flag set.
-
-: search(keys, charset = nil)
-: uid_search(keys, charset = nil)
- Sends a SEARCH command to search the mailbox for messages that
- match the given searching criteria, and returns message sequence
- numbers (search) or unique identifiers (uid_search).
-
- ex).
- p imap.search(["SUBJECT", "hello"])
- #=> [1, 6, 7, 8]
- p imap.search('SUBJECT "hello"')
- #=> [1, 6, 7, 8]
-
-: fetch(set, attr)
-: uid_fetch(set, attr)
- Sends a FETCH command to retrieve data associated with a message
- in the mailbox. the set parameter is a number or an array of
- numbers or a Range object. the number is a message sequence
- number (fetch) or a unique identifier (uid_fetch).
- The return value is an array of ((<Net::IMAP::FetchData>)).
-
- ex).
- p imap.fetch(6..8, "UID")
- #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, #<Net::IMAP::FetchData seqno=7, attr={"UID"=>99}>, #<Net::IMAP::FetchData seqno=8, attr={"UID"=>100}>]
- p imap.fetch(6, "BODY[HEADER.FIELDS (SUBJECT)]")
- #=> [#<Net::IMAP::FetchData seqno=6, attr={"BODY[HEADER.FIELDS (SUBJECT)]"=>"Subject: test\r\n\r\n"}>]
- data = imap.uid_fetch(98, ["RFC822.SIZE", "INTERNALDATE"])[0]
- p data.seqno
- #=> 6
- p data.attr["RFC822.SIZE"]
- #=> 611
- p data.attr["INTERNALDATE"]
- #=> "12-Oct-2000 22:40:59 +0900"
- p data.attr["UID"]
- #=> 98
-
-: store(set, attr, flags)
-: uid_store(set, attr, flags)
- Sends a STORE command to alter data associated with a message
- in the mailbox. the set parameter is a number or an array of
- numbers or a Range object. the number is a message sequence
- number (store) or a unique identifier (uid_store).
- The return value is an array of ((<Net::IMAP::FetchData>)).
-
- ex).
- p imap.store(6..8, "+FLAGS", [:Deleted])
- #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>, #<Net::IMAP::FetchData seqno=8, attr={"FLAGS"=>[:Seen, :Deleted]}>]
-
-: copy(set, mailbox)
-: uid_copy(set, mailbox)
- Sends a COPY command to copy the specified message(s) to the end
- of the specified destination mailbox. the set parameter is
- a number or an array of numbers or a Range object. the number is
- a message sequence number (copy) or a unique identifier (uid_copy).
-
-: sort(sort_keys, search_keys, charset)
-: uid_sort(sort_keys, search_keys, charset)
- Sends a SORT command to sort messages in the mailbox.
-
- ex).
- p imap.sort(["FROM"], ["ALL"], "US-ASCII")
- #=> [1, 2, 3, 5, 6, 7, 8, 4, 9]
- p imap.sort(["DATE"], ["SUBJECT", "hello"], "US-ASCII")
- #=> [6, 7, 8, 1]
-
-== Net::IMAP::ContinuationRequest
-
-Net::IMAP::ContinuationRequest represents command continuation requests.
-
-The command continuation request response is indicated by a "+" token
-instead of a tag. This form of response indicates that the server is
-ready to accept the continuation of a command from the client. The
-remainder of this response is a line of text.
-
- continue_req ::= "+" SPACE (resp_text / base64)
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: data
- Returns the data (Net::IMAP::ResponseText).
-
-: raw_data
- Returns the raw data string.
-
-== Net::IMAP::UntaggedResponse
-
-Net::IMAP::UntaggedResponse represents untagged responses.
-
-Data transmitted by the server to the client and status responses
-that do not indicate command completion are prefixed with the token
-"*", and are called untagged responses.
-
- response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye /
- mailbox_data / message_data / capability_data)
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: name
- Returns the name such as "FLAGS", "LIST", "FETCH"....
-
-: data
- Returns the data such as an array of flag symbols,
- a ((<Net::IMAP::MailboxList>)) object....
-
-: raw_data
- Returns the raw data string.
-
-== Net::IMAP::TaggedResponse
-
-Net::IMAP::TaggedResponse represents tagged responses.
-
-The server completion result response indicates the success or
-failure of the operation. It is tagged with the same tag as the
-client command which began the operation.
-
- response_tagged ::= tag SPACE resp_cond_state CRLF
-
- tag ::= 1*<any ATOM_CHAR except "+">
-
- resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: tag
- Returns the tag.
-
-: name
- Returns the name. the name is one of "OK", "NO", "BAD".
-
-: data
- Returns the data. See ((<Net::IMAP::ResponseText>)).
-
-: raw_data
- Returns the raw data string.
-
-== Net::IMAP::ResponseText
-
-Net::IMAP::ResponseText represents texts of responses.
-The text may be prefixed by the response code.
-
- resp_text ::= ["[" resp_text_code "]" SPACE] (text_mime2 / text)
- ;; text SHOULD NOT begin with "[" or "="
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: code
- Returns the response code. See ((<Net::IMAP::ResponseCode>)).
-
-: text
- Returns the text.
-
-== Net::IMAP::ResponseCode
-
-Net::IMAP::ResponseCode represents response codes.
-
- resp_text_code ::= "ALERT" / "PARSE" /
- "PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" /
- "READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
- "UIDVALIDITY" SPACE nz_number /
- "UNSEEN" SPACE nz_number /
- atom [SPACE 1*<any TEXT_CHAR except "]">]
-
-=== SuperClass
-
-Struct
-
-=== Methods
-
-: name
- Returns the name such as "ALERT", "PERMANENTFLAGS", "UIDVALIDITY"....
-
-: data
- Returns the data if it exists.
-
-== Net::IMAP::MailboxList
-
-Net::IMAP::MailboxList represents contents of the LIST response.
-
- mailbox_list ::= "(" #("\Marked" / "\Noinferiors" /
- "\Noselect" / "\Unmarked" / flag_extension) ")"
- SPACE (<"> QUOTED_CHAR <"> / nil) SPACE mailbox
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: attr
- Returns the name attributes. Each name attribute is a symbol
- capitalized by String#capitalize, such as :Noselect (not :NoSelect).
-
-: delim
- Returns the hierarchy delimiter
-
-: name
- Returns the mailbox name.
-
-== Net::IMAP::StatusData
-
-Net::IMAP::StatusData represents contents of the STATUS response.
-
-=== Super Class
-
-Object
-
-=== Methods
-
-: mailbox
- Returns the mailbox name.
-
-: attr
- Returns a hash. Each key is one of "MESSAGES", "RECENT", "UIDNEXT",
- "UIDVALIDITY", "UNSEEN". Each value is a number.
-
-== Net::IMAP::FetchData
-
-Net::IMAP::FetchData represents contents of the FETCH response.
-
-=== Super Class
-
-Object
-
-=== Methods
-
-: seqno
- Returns the message sequence number.
- (Note: not the unique identifier, even for the UID command response.)
-
-: attr
- Returns a hash. Each key is a data item name, and each value is
- its value.
-
- The current data items are:
-
- : BODY
- A form of BODYSTRUCTURE without extension data.
- : BODY[<section>]<<origin_octet>>
- A string expressing the body contents of the specified section.
- : BODYSTRUCTURE
- An object that describes the ((<[MIME-IMB]>)) body structure of a message.
- See ((<Net::IMAP::BodyTypeBasic>)), ((<Net::IMAP::BodyTypeText>)),
- ((<Net::IMAP::BodyTypeMessage>)), ((<Net::IMAP::BodyTypeMultipart>)).
- : ENVELOPE
- A ((<Net::IMAP::Envelope>)) object that describes the envelope
- structure of a message.
- : FLAGS
- A array of flag symbols that are set for this message. flag symbols
- are capitalized by String#capitalize.
- : INTERNALDATE
- A string representing the internal date of the message.
- : RFC822
- Equivalent to BODY[].
- : RFC822.HEADER
- Equivalent to BODY.PEEK[HEADER].
- : RFC822.SIZE
- A number expressing the ((<[RFC-822]>)) size of the message.
- : RFC822.TEXT
- Equivalent to BODY[TEXT].
- : UID
- A number expressing the unique identifier of the message.
-
-== Net::IMAP::Envelope
-
-Net::IMAP::Envelope represents envelope structures of messages.
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: date
- Retunns a string that represents the date.
-
-: subject
- Retunns a string that represents the subject.
-
-: from
- Retunns an array of ((<Net::IMAP::Address>)) that represents the from.
-
-: sender
- Retunns an array of ((<Net::IMAP::Address>)) that represents the sender.
-
-: reply_to
- Retunns an array of ((<Net::IMAP::Address>)) that represents the reply-to.
-
-: to
- Retunns an array of ((<Net::IMAP::Address>)) that represents the to.
-
-: cc
- Retunns an array of ((<Net::IMAP::Address>)) that represents the cc.
-
-: bcc
- Retunns an array of ((<Net::IMAP::Address>)) that represents the bcc.
-
-: in_reply_to
- Retunns a string that represents the in-reply-to.
-
-: message_id
- Retunns a string that represents the message-id.
-
-== Net::IMAP::Address
-
-((<Net::IMAP::Address>)) represents electronic mail addresses.
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: name
- Returns the phrase from ((<[RFC-822]>)) mailbox.
-
-: route
- Returns the route from ((<[RFC-822]>)) route-addr.
-
-: mailbox
- nil indicates end of ((<[RFC-822]>)) group.
- If non-nil and host is nil, returns ((<[RFC-822]>)) group name.
- Otherwise, returns ((<[RFC-822]>)) local-part
-
-: host
- nil indicates ((<[RFC-822]>)) group syntax.
- Otherwise, returns ((<[RFC-822]>)) domain name.
-
-== Net::IMAP::ContentDisposition
-
-Net::IMAP::ContentDisposition represents Content-Disposition fields.
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: dsp_type
- Returns the disposition type.
-
-: param
- Returns a hash that represents parameters of the Content-Disposition
- field.
-
-== Net::IMAP::BodyTypeBasic
-
-Net::IMAP::BodyTypeBasic represents basic body structures of messages.
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: media_type
- Returns the content media type name as defined in ((<[MIME-IMB]>)).
-
-: subtype
- Returns the content subtype name as defined in ((<[MIME-IMB]>)).
-
-: param
- Returns a hash that represents parameters as defined in
- ((<[MIME-IMB]>)).
-
-: content_id
- Returns a string giving the content id as defined in ((<[MIME-IMB]>)).
-
-: description
- Returns a string giving the content description as defined in
- ((<[MIME-IMB]>)).
-
-: encoding
- Returns a string giving the content transfer encoding as defined in
- ((<[MIME-IMB]>)).
-
-: size
- Returns a number giving the size of the body in octets.
-
-: md5
- Returns a string giving the body MD5 value as defined in ((<[MD5]>)).
-
-: disposition
- Returns a ((<Net::IMAP::ContentDisposition>)) object giving
- the content disposition.
-
-: language
- Returns a string or an array of strings giving the body
- language value as defined in [LANGUAGE-TAGS].
-
-: extension
- Returns extension data.
-
-: multipart?
- Returns false.
-
-== Net::IMAP::BodyTypeText
-
-Net::IMAP::BodyTypeText represents TEXT body structures of messages.
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: lines
- Returns the size of the body in text lines.
-
-And Net::IMAP::BodyTypeText has all methods of ((<Net::IMAP::BodyTypeBasic>)).
-
-== Net::IMAP::BodyTypeMessage
-
-Net::IMAP::BodyTypeMessage represents MESSAGE/RFC822 body structures of messages.
-
-=== Super Class
-
-Struct
-
-=== Methods
-
-: envelope
- Returns a ((<Net::IMAP::Envelope>)) giving the envelope structure.
-
-: body
- Returns an object giving the body structure.
-
-And Net::IMAP::BodyTypeMessage has all methods of ((<Net::IMAP::BodyTypeText>)).
-
-== Net::IMAP::BodyTypeText
-
-=== Super Class
-
-Struct
-
-=== Methods
+require "socket"
+require "monitor"
+require "digest/md5"
+begin
+ require "openssl"
+rescue LoadError
+end
-: media_type
- Returns the content media type name as defined in ((<[MIME-IMB]>)).
+module Net
-: subtype
- Returns the content subtype name as defined in ((<[MIME-IMB]>)).
+ #
+ # Net::IMAP implements Internet Message Access Protocol (IMAP) client
+ # functionality. The protocol is described in [IMAP].
+ #
+ # == IMAP Overview
+ #
+ # An IMAP client connects to a server, and then authenticates
+ # itself using either #authenticate() or #login(). Having
+ # authenticated itself, there is a range of commands
+ # available to it. Most work with mailboxes, which may be
+ # arranged in an hierarchical namespace, and each of which
+ # contains zero or more messages. How this is implemented on
+ # the server is implementation-dependent; on a UNIX server, it
+ # will frequently be implemented as a files in mailbox format
+ # within a hierarchy of directories.
+ #
+ # To work on the messages within a mailbox, the client must
+ # first select that mailbox, using either #select() or (for
+ # read-only access) #examine(). Once the client has successfully
+ # selected a mailbox, they enter _selected_ state, and that
+ # mailbox becomes the _current_ mailbox, on which mail-item
+ # related commands implicitly operate.
+ #
+ # Messages have two sorts of identifiers: message sequence
+ # numbers, and UIDs.
+ #
+ # Message sequence numbers number messages within a mail box
+ # from 1 up to the number of items in the mail box. If new
+ # message arrives during a session, it receives a sequence
+ # number equal to the new size of the mail box. If messages
+ # are expunged from the mailbox, remaining messages have their
+ # sequence numbers "shuffled down" to fill the gaps.
+ #
+ # UIDs, on the other hand, are permanently guaranteed not to
+ # identify another message within the same mailbox, even if
+ # the existing message is deleted. UIDs are required to
+ # be assigned in ascending (but not necessarily sequential)
+ # order within a mailbox; this means that if a non-IMAP client
+ # rearranges the order of mailitems within a mailbox, the
+ # UIDs have to be reassigned. An IMAP client cannot thus
+ # rearrange message orders.
+ #
+ # == Examples of Usage
+ #
+ # === List sender and subject of all recent messages in the default mailbox
+ #
+ # imap = Net::IMAP.new('mail.example.com')
+ # imap.authenticate('LOGIN', 'joe_user', 'joes_password')
+ # imap.examine('INBOX')
+ # imap.search(["RECENT"]).each do |message_id|
+ # envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
+ # puts "#{envelope.from[0].name}: \t#{envelope.subject}"
+ # end
+ #
+ # === Move all messages from April 2003 from "Mail/sent-mail" to "Mail/sent-apr03"
+ #
+ # imap = Net::IMAP.new('mail.example.com')
+ # imap.authenticate('LOGIN', 'joe_user', 'joes_password')
+ # imap.select('Mail/sent-mail')
+ # if not imap.list('Mail/', 'sent-apr03')
+ # imap.create('Mail/sent-apr03')
+ # end
+ # imap.search(["BEFORE", "30-Apr-2003", "SINCE", "1-Apr-2003"]).each do |message_id|
+ # imap.copy(message_id, "Mail/sent-apr03")
+ # imap.store(message_id, "+FLAGS", [:Deleted])
+ # end
+ # imap.expunge
+ #
+ # == Thread Safety
+ #
+ # Net::IMAP supports concurrent threads. For example,
+ #
+ # imap = Net::IMAP.new("imap.foo.net", "imap2")
+ # imap.authenticate("cram-md5", "bar", "password")
+ # imap.select("inbox")
+ # fetch_thread = Thread.start { imap.fetch(1..-1, "UID") }
+ # search_result = imap.search(["BODY", "hello"])
+ # fetch_result = fetch_thread.value
+ # imap.disconnect
+ #
+ # This script invokes the FETCH command and the SEARCH command concurrently.
+ #
+ # == Errors
+ #
+ # An IMAP server can send three different types of responses to indicate
+ # failure:
+ #
+ # NO:: the attempted command could not be successfully completed. For
+ # instance, the username/password used for logging in are incorrect;
+ # the selected mailbox does not exists; etc.
+ #
+ # BAD:: the request from the client does not follow the server's
+ # understanding of the IMAP protocol. This includes attempting
+ # commands from the wrong client state; for instance, attempting
+ # to perform a SEARCH command without having SELECTed a current
+ # mailbox. It can also signal an internal server
+ # failure (such as a disk crash) has occurred.
+ #
+ # BYE:: the server is saying goodbye. This can be part of a normal
+ # logout sequence, and can be used as part of a login sequence
+ # to indicate that the server is (for some reason) unwilling
+ # to accept our connection. As a response to any other command,
+ # it indicates either that the server is shutting down, or that
+ # the server is timing out the client connection due to inactivity.
+ #
+ # These three error response are represented by the errors
+ # Net::IMAP::NoResponseError, Net::IMAP::BadResponseError, and
+ # Net::IMAP::ByeResponseError, all of which are subclasses of
+ # Net::IMAP::ResponseError. Essentially, all methods that involve
+ # sending a request to the server can generate one of these errors.
+ # Only the most pertinent instances have been documented below.
+ #
+ # Because the IMAP class uses Sockets for communication, its methods
+ # are also susceptible to the various errors that can occur when
+ # working with sockets. These are generally represented as
+ # Errno errors. For instance, any method that involves sending a
+ # request to the server and/or receiving a response from it could
+ # raise an Errno::EPIPE error if the network connection unexpectedly
+ # goes down. See the socket(7), ip(7), tcp(7), socket(2), connect(2),
+ # and associated man pages.
+ #
+ # Finally, a Net::IMAP::DataFormatError is thrown if low-level data
+ # is found to be in an incorrect format (for instance, when converting
+ # between UTF-8 and UTF-16), and Net::IMAP::ResponseParseError is
+ # thrown if a server response is non-parseable.
+ #
+ #
+ # == References
+ #
+ # [[IMAP]]
+ # M. Crispin, "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1",
+ # RFC 2060, December 1996. (Note: since obsoleted by RFC 3501)
+ #
+ # [[LANGUAGE-TAGS]]
+ # Alvestrand, H., "Tags for the Identification of
+ # Languages", RFC 1766, March 1995.
+ #
+ # [[MD5]]
+ # Myers, J., and M. Rose, "The Content-MD5 Header Field", RFC
+ # 1864, October 1995.
+ #
+ # [[MIME-IMB]]
+ # Freed, N., and N. Borenstein, "MIME (Multipurpose Internet
+ # Mail Extensions) Part One: Format of Internet Message Bodies", RFC
+ # 2045, November 1996.
+ #
+ # [[RFC-822]]
+ # Crocker, D., "Standard for the Format of ARPA Internet Text
+ # Messages", STD 11, RFC 822, University of Delaware, August 1982.
+ #
+ # [[RFC-2087]]
+ # Myers, J., "IMAP4 QUOTA extension", RFC 2087, January 1997.
+ #
+ # [[RFC-2086]]
+ # Myers, J., "IMAP4 ACL extension", RFC 2086, January 1997.
+ #
+ # [[RFC-2195]]
+ # Klensin, J., Catoe, R., and Krumviede, P., "IMAP/POP AUTHorize Extension
+ # for Simple Challenge/Response", RFC 2195, September 1997.
+ #
+ # [[SORT-THREAD-EXT]]
+ # Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - SORT and THREAD
+ # Extensions", draft-ietf-imapext-sort, May 2003.
+ #
+ # [[OSSL]]
+ # http://www.openssl.org
+ #
+ # [[RSSL]]
+ # http://savannah.gnu.org/projects/rubypki
+ #
+ # [[UTF7]]
+ # Goldsmith, D. and Davis, M., "UTF-7: A Mail-Safe Transformation Format of
+ # Unicode", RFC 2152, May 1997.
+ #
+ class IMAP
+ include MonitorMixin
+ if defined?(OpenSSL)
+ include OpenSSL
+ include SSL
+ end
-: parts
- Returns multiple parts.
+ # Returns an initial greeting response from the server.
+ attr_reader :greeting
-: param
- Returns a hash that represents parameters as defined in
- ((<[MIME-IMB]>)).
+ # Returns recorded untagged responses. For example:
+ #
+ # imap.select("inbox")
+ # p imap.responses["EXISTS"][-1]
+ # #=> 2
+ # p imap.responses["UIDVALIDITY"][-1]
+ # #=> 968263756
+ attr_reader :responses
-: disposition
- Returns a ((<Net::IMAP::ContentDisposition>)) object giving
- the content disposition.
+ # Returns all response handlers.
+ attr_reader :response_handlers
-: language
- Returns a string or an array of strings giving the body
- language value as defined in [LANGUAGE-TAGS].
+ # The thread to receive exceptions.
+ attr_accessor :client_thread
-: extension
- Returns extension data.
+ # Flag indicating a message has been seen
+ SEEN = :Seen
-: multipart?
- Returns true.
+ # Flag indicating a message has been answered
+ ANSWERED = :Answered
-== References
+ # Flag indicating a message has been flagged for special or urgent
+ # attention
+ FLAGGED = :Flagged
-: [IMAP]
- M. Crispin, "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1",
- RFC 2060, December 1996.
+ # Flag indicating a message has been marked for deletion. This
+ # will occur when the mailbox is closed or expunged.
+ DELETED = :Deleted
-: [LANGUAGE-TAGS]
- Alvestrand, H., "Tags for the Identification of
- Languages", RFC 1766, March 1995.
+ # Flag indicating a message is only a draft or work-in-progress version.
+ DRAFT = :Draft
-: [MD5]
- Myers, J., and M. Rose, "The Content-MD5 Header Field", RFC
- 1864, October 1995.
+ # Flag indicating that the message is "recent", meaning that this
+ # session is the first session in which the client has been notified
+ # of this message.
+ RECENT = :Recent
-: [MIME-IMB]
- Freed, N., and N. Borenstein, "MIME (Multipurpose Internet
- Mail Extensions) Part One: Format of Internet Message Bodies", RFC
- 2045, November 1996.
+ # Flag indicating that a mailbox context name cannot contain
+ # children.
+ NOINFERIORS = :Noinferiors
-: [RFC-822]
- Crocker, D., "Standard for the Format of ARPA Internet Text
- Messages", STD 11, RFC 822, University of Delaware, August 1982.
+ # Flag indicating that a mailbox is not selected.
+ NOSELECT = :Noselect
-=end
+ # Flag indicating that a mailbox has been marked "interesting" by
+ # the server; this commonly indicates that the mailbox contains
+ # new messages.
+ MARKED = :Marked
-require "socket"
-require "md5"
-
-module Net
- class IMAP
- attr_reader :greeting, :responses
+ # Flag indicating that the mailbox does not contains new messages.
+ UNMARKED = :Unmarked
+ # Returns the debug mode.
def self.debug
return @@debug
end
+ # Sets the debug mode.
def self.debug=(val)
return @@debug = val
end
+ # Adds an authenticator for Net::IMAP#authenticate. +auth_type+
+ # is the type of authentication this authenticator supports
+ # (for instance, "LOGIN"). The +authenticator+ is an object
+ # which defines a process() method to handle authentication with
+ # the server. See Net::IMAP::LoginAuthenticator and
+ # Net::IMAP::CramMD5Authenticator for examples.
+ #
+ # If +auth_type+ refers to an existing authenticator, it will be
+ # replaced by the new one.
def self.add_authenticator(auth_type, authenticator)
@@authenticators[auth_type] = authenticator
end
+ # Disconnects from the server.
def disconnect
+ @sock.shutdown unless @usessl
+ @receiver_thread.join
@sock.close
end
+ # Returns true if disconnected from the server.
+ def disconnected?
+ return @sock.closed?
+ end
+
+ # Sends a CAPABILITY command, and returns an array of
+ # capabilities that the server supports. Each capability
+ # is a string. See [IMAP] for a list of possible
+ # capabilities.
+ #
+ # Note that the Net::IMAP class does not modify its
+ # behaviour according to the capabilities of the server;
+ # it is up to the user of the class to ensure that
+ # a certain capability is supported by a server before
+ # using it.
def capability
- send_command("CAPABILITY")
- return @responses.delete("CAPABILITY")[-1]
+ synchronize do
+ send_command("CAPABILITY")
+ return @responses.delete("CAPABILITY")[-1]
+ end
end
+ # Sends a NOOP command to the server. It does nothing.
def noop
send_command("NOOP")
end
+ # Sends a LOGOUT command to inform the server that the client is
+ # done with the connection.
def logout
send_command("LOGOUT")
end
+ # Sends an AUTHENTICATE command to authenticate the client.
+ # The +auth_type+ parameter is a string that represents
+ # the authentication mechanism to be used. Currently Net::IMAP
+ # supports authentication mechanisms:
+ #
+ # LOGIN:: login using cleartext user and password.
+ # CRAM-MD5:: login with cleartext user and encrypted password
+ # (see [RFC-2195] for a full description). This
+ # mechanism requires that the server have the user's
+ # password stored in clear-text password.
+ #
+ # For both these mechanisms, there should be two +args+: username
+ # and (cleartext) password. A server may not support one or other
+ # of these mechanisms; check #capability() for a capability of
+ # the form "AUTH=LOGIN" or "AUTH=CRAM-MD5".
+ #
+ # Authentication is done using the appropriate authenticator object:
+ # see @@authenticators for more information on plugging in your own
+ # authenticator.
+ #
+ # For example:
+ #
+ # imap.authenticate('LOGIN', user, password)
+ #
+ # A Net::IMAP::NoResponseError is raised if authentication fails.
def authenticate(auth_type, *args)
auth_type = auth_type.upcase
unless @@authenticators.has_key?(auth_type)
- raise ArgumentError,
- format('unknown auth type - "%s"', auth_type)
+ raise ArgumentError,
+ format('unknown auth type - "%s"', auth_type)
end
authenticator = @@authenticators[auth_type].new(*args)
send_command("AUTHENTICATE", auth_type) do |resp|
- if resp.instance_of?(ContinueRequest)
- data = authenticator.process(resp.data.text.unpack("m")[0])
- send_data([data].pack("m").chomp)
- end
+ if resp.instance_of?(ContinuationRequest)
+ data = authenticator.process(resp.data.text.unpack("m")[0])
+ s = [data].pack("m").gsub(/\n/, "")
+ send_string_data(s)
+ put_string(CRLF)
+ end
end
end
+ # Sends a LOGIN command to identify the client and carries
+ # the plaintext +password+ authenticating this +user+. Note
+ # that, unlike calling #authenticate() with an +auth_type+
+ # of "LOGIN", #login() does *not* use the login authenticator.
+ #
+ # A Net::IMAP::NoResponseError is raised if authentication fails.
def login(user, password)
send_command("LOGIN", user, password)
end
+ # Sends a SELECT command to select a +mailbox+ so that messages
+ # in the +mailbox+ can be accessed.
+ #
+ # After you have selected a mailbox, you may retrieve the
+ # number of items in that mailbox from @responses["EXISTS"][-1],
+ # and the number of recent messages from @responses["RECENT"][-1].
+ # Note that these values can change if new messages arrive
+ # during a session; see #add_response_handler() for a way of
+ # detecting this event.
+ #
+ # A Net::IMAP::NoResponseError is raised if the mailbox does not
+ # exist or is for some reason non-selectable.
def select(mailbox)
- @responses.clear
- send_command("SELECT", mailbox)
+ synchronize do
+ @responses.clear
+ send_command("SELECT", mailbox)
+ end
end
+ # Sends a EXAMINE command to select a +mailbox+ so that messages
+ # in the +mailbox+ can be accessed. Behaves the same as #select(),
+ # except that the selected +mailbox+ is identified as read-only.
+ #
+ # A Net::IMAP::NoResponseError is raised if the mailbox does not
+ # exist or is for some reason non-examinable.
def examine(mailbox)
- @responses.clear
- send_command("EXAMINE", mailbox)
+ synchronize do
+ @responses.clear
+ send_command("EXAMINE", mailbox)
+ end
end
+ # Sends a CREATE command to create a new +mailbox+.
+ #
+ # A Net::IMAP::NoResponseError is raised if a mailbox with that name
+ # cannot be created.
def create(mailbox)
send_command("CREATE", mailbox)
end
+ # Sends a DELETE command to remove the +mailbox+.
+ #
+ # A Net::IMAP::NoResponseError is raised if a mailbox with that name
+ # cannot be deleted, either because it does not exist or because the
+ # client does not have permission to delete it.
def delete(mailbox)
send_command("DELETE", mailbox)
end
+ # Sends a RENAME command to change the name of the +mailbox+ to
+ # +newname+.
+ #
+ # A Net::IMAP::NoResponseError is raised if a mailbox with the
+ # name +mailbox+ cannot be renamed to +newname+ for whatever
+ # reason; for instance, because +mailbox+ does not exist, or
+ # because there is already a mailbox with the name +newname+.
def rename(mailbox, newname)
send_command("RENAME", mailbox, newname)
end
+ # Sends a SUBSCRIBE command to add the specified +mailbox+ name to
+ # the server's set of "active" or "subscribed" mailboxes as returned
+ # by #lsub().
+ #
+ # A Net::IMAP::NoResponseError is raised if +mailbox+ cannot be
+ # subscribed to, for instance because it does not exist.
def subscribe(mailbox)
send_command("SUBSCRIBE", mailbox)
end
+ # Sends a UNSUBSCRIBE command to remove the specified +mailbox+ name
+ # from the server's set of "active" or "subscribed" mailboxes.
+ #
+ # A Net::IMAP::NoResponseError is raised if +mailbox+ cannot be
+ # unsubscribed from, for instance because the client is not currently
+ # subscribed to it.
def unsubscribe(mailbox)
send_command("UNSUBSCRIBE", mailbox)
end
+ # Sends a LIST command, and returns a subset of names from
+ # the complete set of all names available to the client.
+ # +refname+ provides a context (for instance, a base directory
+ # in a directory-based mailbox hierarchy). +mailbox+ specifies
+ # a mailbox or (via wildcards) mailboxes under that context.
+ # Two wildcards may be used in +mailbox+: '*', which matches
+ # all characters *including* the hierarchy delimiter (for instance,
+ # '/' on a UNIX-hosted directory-based mailbox hierarchy); and '%',
+ # which matches all characters *except* the hierarchy delimiter.
+ #
+ # If +refname+ is empty, +mailbox+ is used directly to determine
+ # which mailboxes to match. If +mailbox+ is empty, the root
+ # name of +refname+ and the hierarchy delimiter are returned.
+ #
+ # The return value is an array of +Net::IMAP::MailboxList+. For example:
+ #
+ # imap.create("foo/bar")
+ # imap.create("foo/baz")
+ # p imap.list("", "foo/%")
+ # #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
+ # #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
+ # #<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
def list(refname, mailbox)
- send_command("LIST", refname, mailbox)
- return @responses.delete("LIST")
+ synchronize do
+ send_command("LIST", refname, mailbox)
+ return @responses.delete("LIST")
+ end
end
- def lsub(refname, mailbox)
- send_command("LSUB", refname, mailbox)
- return @responses.delete("LSUB")
+ # Sends the GETQUOTAROOT command along with specified +mailbox+.
+ # This command is generally available to both admin and user.
+ # If mailbox exists, returns an array containing objects of
+ # Net::IMAP::MailboxQuotaRoot and Net::IMAP::MailboxQuota.
+ def getquotaroot(mailbox)
+ synchronize do
+ send_command("GETQUOTAROOT", mailbox)
+ result = []
+ result.concat(@responses.delete("QUOTAROOT"))
+ result.concat(@responses.delete("QUOTA"))
+ return result
+ end
end
- def status(mailbox, attr)
- send_command("STATUS", mailbox, attr)
- return @responses.delete("STATUS")[-1][1]
+ # Sends the GETQUOTA command along with specified +mailbox+.
+ # If this mailbox exists, then an array containing a
+ # Net::IMAP::MailboxQuota object is returned. This
+ # command generally is only available to server admin.
+ def getquota(mailbox)
+ synchronize do
+ send_command("GETQUOTA", mailbox)
+ return @responses.delete("QUOTA")
+ end
+ end
+
+ # Sends a SETQUOTA command along with the specified +mailbox+ and
+ # +quota+. If +quota+ is nil, then quota will be unset for that
+ # mailbox. Typically one needs to be logged in as server admin
+ # for this to work. The IMAP quota commands are described in
+ # [RFC-2087].
+ def setquota(mailbox, quota)
+ if quota.nil?
+ data = '()'
+ else
+ data = '(STORAGE ' + quota.to_s + ')'
+ end
+ send_command("SETQUOTA", mailbox, RawData.new(data))
+ end
+
+ # Sends the SETACL command along with +mailbox+, +user+ and the
+ # +rights+ that user is to have on that mailbox. If +rights+ is nil,
+ # then that user will be stripped of any rights to that mailbox.
+ # The IMAP ACL commands are described in [RFC-2086].
+ def setacl(mailbox, user, rights)
+ if rights.nil?
+ send_command("SETACL", mailbox, user, "")
+ else
+ send_command("SETACL", mailbox, user, rights)
+ end
end
+ # Send the GETACL command along with specified +mailbox+.
+ # If this mailbox exists, an array containing objects of
+ # Net::IMAP::MailboxACLItem will be returned.
+ def getacl(mailbox)
+ synchronize do
+ send_command("GETACL", mailbox)
+ return @responses.delete("ACL")[-1]
+ end
+ end
+
+ # Sends a LSUB command, and returns a subset of names from the set
+ # of names that the user has declared as being "active" or
+ # "subscribed". +refname+ and +mailbox+ are interpreted as
+ # for #list().
+ # The return value is an array of +Net::IMAP::MailboxList+.
+ def lsub(refname, mailbox)
+ synchronize do
+ send_command("LSUB", refname, mailbox)
+ return @responses.delete("LSUB")
+ end
+ end
+
+ # Sends a STATUS command, and returns the status of the indicated
+ # +mailbox+. +attr+ is a list of one or more attributes that
+ # we are request the status of. Supported attributes include:
+ #
+ # MESSAGES:: the number of messages in the mailbox.
+ # RECENT:: the number of recent messages in the mailbox.
+ # UNSEEN:: the number of unseen messages in the mailbox.
+ #
+ # The return value is a hash of attributes. For example:
+ #
+ # p imap.status("inbox", ["MESSAGES", "RECENT"])
+ # #=> {"RECENT"=>0, "MESSAGES"=>44}
+ #
+ # A Net::IMAP::NoResponseError is raised if status values
+ # for +mailbox+ cannot be returned, for instance because it
+ # does not exist.
+ def status(mailbox, attr)
+ synchronize do
+ send_command("STATUS", mailbox, attr)
+ return @responses.delete("STATUS")[-1].attr
+ end
+ end
+
+ # Sends a APPEND command to append the +message+ to the end of
+ # the +mailbox+. The optional +flags+ argument is an array of
+ # flags to initially passing to the new message. The optional
+ # +date_time+ argument specifies the creation time to assign to the
+ # new message; it defaults to the current time.
+ # For example:
+ #
+ # imap.append("inbox", <<EOF.gsub(/\n/, "\r\n"), [:Seen], Time.now)
+ # Subject: hello
+ # From: shugo@ruby-lang.org
+ # To: shugo@ruby-lang.org
+ #
+ # hello world
+ # EOF
+ #
+ # A Net::IMAP::NoResponseError is raised if the mailbox does
+ # not exist (it is not created automatically), or if the flags,
+ # date_time, or message arguments contain errors.
def append(mailbox, message, flags = nil, date_time = nil)
args = []
if flags
- args.push(flags)
+ args.push(flags)
end
args.push(date_time) if date_time
args.push(Literal.new(message))
send_command("APPEND", mailbox, *args)
end
+ # Sends a CHECK command to request a checkpoint of the currently
+ # selected mailbox. This performs implementation-specific
+ # housekeeping, for instance, reconciling the mailbox's
+ # in-memory and on-disk state.
def check
send_command("CHECK")
end
+ # Sends a CLOSE command to close the currently selected mailbox.
+ # The CLOSE command permanently removes from the mailbox all
+ # messages that have the \Deleted flag set.
def close
send_command("CLOSE")
end
+ # Sends a EXPUNGE command to permanently remove from the currently
+ # selected mailbox all messages that have the \Deleted flag set.
def expunge
- send_command("EXPUNGE")
- return @responses.delete("EXPUNGE")
- end
-
+ synchronize do
+ send_command("EXPUNGE")
+ return @responses.delete("EXPUNGE")
+ end
+ end
+
+ # Sends a SEARCH command to search the mailbox for messages that
+ # match the given searching criteria, and returns message sequence
+ # numbers. +keys+ can either be a string holding the entire
+ # search string, or a single-dimension array of search keywords and
+ # arguments. The following are some common search criteria;
+ # see [IMAP] section 6.4.4 for a full list.
+ #
+ # <message set>:: a set of message sequence numbers. ',' indicates
+ # an interval, ':' indicates a range. For instance,
+ # '2,10:12,15' means "2,10,11,12,15".
+ #
+ # BEFORE <date>:: messages with an internal date strictly before
+ # <date>. The date argument has a format similar
+ # to 8-Aug-2002.
+ #
+ # BODY <string>:: messages that contain <string> within their body.
+ #
+ # CC <string>:: messages containing <string> in their CC field.
+ #
+ # FROM <string>:: messages that contain <string> in their FROM field.
+ #
+ # NEW:: messages with the \Recent, but not the \Seen, flag set.
+ #
+ # NOT <search-key>:: negate the following search key.
+ #
+ # OR <search-key> <search-key>:: "or" two search keys together.
+ #
+ # ON <date>:: messages with an internal date exactly equal to <date>,
+ # which has a format similar to 8-Aug-2002.
+ #
+ # SINCE <date>:: messages with an internal date on or after <date>.
+ #
+ # SUBJECT <string>:: messages with <string> in their subject.
+ #
+ # TO <string>:: messages with <string> in their TO field.
+ #
+ # For example:
+ #
+ # p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
+ # #=> [1, 6, 7, 8]
def search(keys, charset = nil)
return search_internal("SEARCH", keys, charset)
end
+ # As for #search(), but returns unique identifiers.
def uid_search(keys, charset = nil)
return search_internal("UID SEARCH", keys, charset)
end
+ # Sends a FETCH command to retrieve data associated with a message
+ # in the mailbox. The +set+ parameter is a number or an array of
+ # numbers or a Range object. The number is a message sequence
+ # number. +attr+ is a list of attributes to fetch; see the
+ # documentation for Net::IMAP::FetchData for a list of valid
+ # attributes.
+ # The return value is an array of Net::IMAP::FetchData. For example:
+ #
+ # p imap.fetch(6..8, "UID")
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, \\
+ # #<Net::IMAP::FetchData seqno=7, attr={"UID"=>99}>, \\
+ # #<Net::IMAP::FetchData seqno=8, attr={"UID"=>100}>]
+ # p imap.fetch(6, "BODY[HEADER.FIELDS (SUBJECT)]")
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"BODY[HEADER.FIELDS (SUBJECT)]"=>"Subject: test\r\n\r\n"}>]
+ # data = imap.uid_fetch(98, ["RFC822.SIZE", "INTERNALDATE"])[0]
+ # p data.seqno
+ # #=> 6
+ # p data.attr["RFC822.SIZE"]
+ # #=> 611
+ # p data.attr["INTERNALDATE"]
+ # #=> "12-Oct-2000 22:40:59 +0900"
+ # p data.attr["UID"]
+ # #=> 98
def fetch(set, attr)
return fetch_internal("FETCH", set, attr)
end
+ # As for #fetch(), but +set+ contains unique identifiers.
def uid_fetch(set, attr)
return fetch_internal("UID FETCH", set, attr)
end
+ # Sends a STORE command to alter data associated with messages
+ # in the mailbox, in particular their flags. The +set+ parameter
+ # is a number or an array of numbers or a Range object. Each number
+ # is a message sequence number. +attr+ is the name of a data item
+ # to store: 'FLAGS' means to replace the message's flag list
+ # with the provided one; '+FLAGS' means to add the provided flags;
+ # and '-FLAGS' means to remove them. +flags+ is a list of flags.
+ #
+ # The return value is an array of Net::IMAP::FetchData. For example:
+ #
+ # p imap.store(6..8, "+FLAGS", [:Deleted])
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
+ # #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
+ # #<Net::IMAP::FetchData seqno=8, attr={"FLAGS"=>[:Seen, :Deleted]}>]
def store(set, attr, flags)
return store_internal("STORE", set, attr, flags)
end
+ # As for #store(), but +set+ contains unique identifiers.
def uid_store(set, attr, flags)
return store_internal("UID STORE", set, attr, flags)
end
+ # Sends a COPY command to copy the specified message(s) to the end
+ # of the specified destination +mailbox+. The +set+ parameter is
+ # a number or an array of numbers or a Range object. The number is
+ # a message sequence number.
def copy(set, mailbox)
copy_internal("COPY", set, mailbox)
end
+ # As for #copy(), but +set+ contains unique identifiers.
def uid_copy(set, mailbox)
copy_internal("UID COPY", set, mailbox)
end
+ # Sends a SORT command to sort messages in the mailbox.
+ # Returns an array of message sequence numbers. For example:
+ #
+ # p imap.sort(["FROM"], ["ALL"], "US-ASCII")
+ # #=> [1, 2, 3, 5, 6, 7, 8, 4, 9]
+ # p imap.sort(["DATE"], ["SUBJECT", "hello"], "US-ASCII")
+ # #=> [6, 7, 8, 1]
+ #
+ # See [SORT-THREAD-EXT] for more details.
def sort(sort_keys, search_keys, charset)
return sort_internal("SORT", sort_keys, search_keys, charset)
end
+ # As for #sort(), but returns an array of unique identifiers.
def uid_sort(sort_keys, search_keys, charset)
return sort_internal("UID SORT", sort_keys, search_keys, charset)
end
+ # Adds a response handler. For example, to detect when
+ # the server sends us a new EXISTS response (which normally
+ # indicates new messages being added to the mail box),
+ # you could add the following handler after selecting the
+ # mailbox.
+ #
+ # imap.add_response_handler { |resp|
+ # if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS"
+ # puts "Mailbox now has #{resp.data} messages"
+ # end
+ # }
+ #
+ def add_response_handler(handler = Proc.new)
+ @response_handlers.push(handler)
+ end
+
+ # Removes the response handler.
+ def remove_response_handler(handler)
+ @response_handlers.delete(handler)
+ end
+
+ # As for #search(), but returns message sequence numbers in threaded
+ # format, as a Net::IMAP::ThreadMember tree. The supported algorithms
+ # are:
+ #
+ # ORDEREDSUBJECT:: split into single-level threads according to subject,
+ # ordered by date.
+ # REFERENCES:: split into threads by parent/child relationships determined
+ # by which message is a reply to which.
+ #
+ # Unlike #search(), +charset+ is a required argument. US-ASCII
+ # and UTF-8 are sample values.
+ #
+ # See [SORT-THREAD-EXT] for more details.
+ def thread(algorithm, search_keys, charset)
+ return thread_internal("THREAD", algorithm, search_keys, charset)
+ end
+
+ # As for #thread(), but returns unique identifiers instead of
+ # message sequence numbers.
+ def uid_thread(algorithm, search_keys, charset)
+ return thread_internal("UID THREAD", algorithm, search_keys, charset)
+ end
+
+ # Decode a string from modified UTF-7 format to UTF-8.
+ #
+ # UTF-7 is a 7-bit encoding of Unicode [UTF7]. IMAP uses a
+ # slightly modified version of this to encode mailbox names
+ # containing non-ASCII characters; see [IMAP] section 5.1.3.
+ #
+ # Net::IMAP does _not_ automatically encode and decode
+ # mailbox names to and from utf7.
+ def self.decode_utf7(s)
+ return s.gsub(/&(.*?)-/n) {
+ if $1.empty?
+ "&"
+ else
+ base64 = $1.tr(",", "/")
+ x = base64.length % 4
+ if x > 0
+ base64.concat("=" * (4 - x))
+ end
+ u16tou8(base64.unpack("m")[0])
+ end
+ }
+ end
+
+ # Encode a string from UTF-8 format to modified UTF-7.
+ def self.encode_utf7(s)
+ return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/n) { |x|
+ if $1
+ "&-"
+ else
+ base64 = [u8tou16(x)].pack("m")
+ "&" + base64.delete("=\n").tr("/", ",") + "-"
+ end
+ }
+ end
+
private
- CRLF = "\r\n"
- PORT = 143
+ CRLF = "\r\n" # :nodoc:
+ PORT = 143 # :nodoc:
@@debug = false
@@authenticators = {}
- def initialize(host, port = PORT)
+ # Creates a new Net::IMAP object and connects it to the specified
+ # +port+ (143 by default) on the named +host+. If +usessl+ is true,
+ # then an attempt will
+ # be made to use SSL (now TLS) to connect to the server. For this
+ # to work OpenSSL [OSSL] and the Ruby OpenSSL [RSSL]
+ # extensions need to be installed. The +certs+ parameter indicates
+ # the path or file containing the CA cert of the server, and the
+ # +verify+ parameter is for the OpenSSL verification callback.
+ #
+ # The most common errors are:
+ #
+ # Errno::ECONNREFUSED:: connection refused by +host+ or an intervening
+ # firewall.
+ # Errno::ETIMEDOUT:: connection timed out (possibly due to packets
+ # being dropped by an intervening firewall).
+ # Errno::ENETUNREACH:: there is no route to that network.
+ # SocketError:: hostname not known or other socket error.
+ # Net::IMAP::ByeResponseError:: we connected to the host, but they
+ # immediately said goodbye to us.
+ def initialize(host, port = PORT, usessl = false, certs = nil, verify = false)
+ super()
@host = host
@port = port
@tag_prefix = "RUBY"
@tagno = 0
@parser = ResponseParser.new
@sock = TCPSocket.open(host, port)
- @responses = Hash.new([].freeze)
- @greeting = get_response
- if /\ABYE\z/ni =~ @greeting.name
- @sock.close
- raise ByeResponseError, resp[0]
- end
- end
-
- def send_command(cmd, *args, &block)
- tag = generate_tag
- data = args.collect {|i| format_data(i)}.join(" ")
- if data.length > 0
- put_line(tag + " " + cmd + " " + data)
+ if usessl
+ unless defined?(OpenSSL)
+ raise "SSL extension not installed"
+ end
+ @usessl = true
+ @sock = SSLSocket.new(@sock)
+
+ # verify the server.
+ @sock.ca_file = certs if certs && FileTest::file?(certs)
+ @sock.ca_path = certs if certs && FileTest::directory?(certs)
+ @sock.verify_mode = VERIFY_PEER if verify
+ if defined?(VerifyCallbackProc)
+ @sock.verify_callback = VerifyCallbackProc
+ end
+ @sock.connect # start ssl session.
else
- put_line(tag + " " + cmd)
+ @usessl = false
end
- return get_all_responses(tag, cmd, &block)
- end
+ @responses = Hash.new([].freeze)
+ @tagged_responses = {}
+ @response_handlers = []
+ @tagged_response_arrival = new_cond
+ @continuation_request_arrival = new_cond
+ @logout_command_tag = nil
+ @debug_output_bol = true
- def generate_tag
- @tagno += 1
- return format("%s%04d", @tag_prefix, @tagno)
- end
+ @greeting = get_response
+ if @greeting.name == "BYE"
+ @sock.close
+ raise ByeResponseError, @greeting.raw_data
+ end
- def send_data(*args)
- data = args.collect {|i| format_data(i)}.join(" ")
- put_line(data)
+ @client_thread = Thread.current
+ @receiver_thread = Thread.start {
+ receive_responses
+ }
end
- def put_line(line)
- line = line + CRLF
- @sock.print(line)
- if @@debug
- $stderr.print(line.gsub(/^/n, "C: "))
- end
- end
-
- def get_all_responses(tag, cmd, &block)
- while resp = get_response
- if @@debug
- $stderr.printf("R: %s\n", resp.inspect)
- end
- case resp
- when TaggedResponse
- case resp.name
- when /\A(?:NO)\z/ni
- raise NoResponseError, resp.data.text
- when /\A(?:BAD)\z/ni
- raise BadResponseError, resp.data.text
- else
- return resp
- end
- when UntaggedResponse
- if /\ABYE\z/ni =~ resp.name &&
- cmd != "LOGOUT"
- raise ByeResponseError, resp.data.text
- end
- record_response(resp.name, resp.data)
- if resp.data.instance_of?(ResponseText) &&
- (code = resp.data.code)
- record_response(code.name, code.data)
- end
- end
- block.call(resp) if block
+ def receive_responses
+ while true
+ begin
+ resp = get_response
+ rescue Exception
+ @sock.close
+ @client_thread.raise($!)
+ break
+ end
+ break unless resp
+ begin
+ synchronize do
+ case resp
+ when TaggedResponse
+ @tagged_responses[resp.tag] = resp
+ @tagged_response_arrival.broadcast
+ if resp.tag == @logout_command_tag
+ return
+ end
+ when UntaggedResponse
+ record_response(resp.name, resp.data)
+ if resp.data.instance_of?(ResponseText) &&
+ (code = resp.data.code)
+ record_response(code.name, code.data)
+ end
+ if resp.name == "BYE" && @logout_command_tag.nil?
+ @sock.close
+ raise ByeResponseError, resp.raw_data
+ end
+ when ContinuationRequest
+ @continuation_request_arrival.signal
+ end
+ @response_handlers.each do |handler|
+ handler.call(resp)
+ end
+ end
+ rescue Exception
+ @client_thread.raise($!)
+ end
+ end
+ end
+
+ def get_tagged_response(tag, cmd)
+ until @tagged_responses.key?(tag)
+ @tagged_response_arrival.wait
+ end
+ resp = @tagged_responses.delete(tag)
+ case resp.name
+ when /\A(?:NO)\z/ni
+ raise NoResponseError, resp.data.text
+ when /\A(?:BAD)\z/ni
+ raise BadResponseError, resp.data.text
+ else
+ return resp
end
end
def get_response
buff = ""
while true
- s = @sock.gets(CRLF)
- break unless s
- buff.concat(s)
- if /\{(\d+)\}\r\n/n =~ s
- s = @sock.read($1.to_i)
- buff.concat(s)
- else
- break
- end
+ s = @sock.gets(CRLF)
+ break unless s
+ buff.concat(s)
+ if /\{(\d+)\}\r\n/n =~ s
+ s = @sock.read($1.to_i)
+ buff.concat(s)
+ else
+ break
+ end
end
return nil if buff.length == 0
if @@debug
@@ -922,101 +997,171 @@ module Net
def record_response(name, data)
unless @responses.has_key?(name)
- @responses[name] = []
+ @responses[name] = []
end
@responses[name].push(data)
end
- def format_data(data)
+ def send_command(cmd, *args, &block)
+ synchronize do
+ tag = generate_tag
+ put_string(tag + " " + cmd)
+ args.each do |i|
+ put_string(" ")
+ send_data(i)
+ end
+ put_string(CRLF)
+ if cmd == "LOGOUT"
+ @logout_command_tag = tag
+ end
+ if block
+ add_response_handler(block)
+ end
+ begin
+ return get_tagged_response(tag, cmd)
+ ensure
+ if block
+ remove_response_handler(block)
+ end
+ end
+ end
+ end
+
+ def generate_tag
+ @tagno += 1
+ return format("%s%04d", @tag_prefix, @tagno)
+ end
+
+ def put_string(str)
+ @sock.print(str)
+ if @@debug
+ if @debug_output_bol
+ $stderr.print("C: ")
+ end
+ $stderr.print(str.gsub(/\n(?!\z)/n, "\nC: "))
+ if /\r\n\z/n.match(str)
+ @debug_output_bol = true
+ else
+ @debug_output_bol = false
+ end
+ end
+ end
+
+ def send_data(data)
case data
when nil
- return "NIL"
+ put_string("NIL")
when String
- return format_string(data)
+ send_string_data(data)
when Integer
- return format_number(data)
+ send_number_data(data)
when Array
- return format_list(data)
+ send_list_data(data)
when Time
- return format_time(data)
+ send_time_data(data)
when Symbol
- return format_symbol(data)
+ send_symbol_data(data)
else
- return data.format_data
+ data.send_data(self)
end
end
- def format_string(str)
+ def send_string_data(str)
case str
when ""
- return '""'
+ put_string('""')
when /[\x80-\xff\r\n]/n
- # literal
- return "{" + str.length.to_s + "}" + CRLF + str
+ # literal
+ send_literal(str)
when /[(){ \x00-\x1f\x7f%*"\\]/n
- # quoted string
- return '"' + str.gsub(/["\\]/n, "\\\\\\&") + '"'
+ # quoted string
+ send_quoted_string(str)
else
- # atom
- return str
+ put_string(str)
end
end
+
+ def send_quoted_string(str)
+ put_string('"' + str.gsub(/["\\]/n, "\\\\\\&") + '"')
+ end
+
+ def send_literal(str)
+ put_string("{" + str.length.to_s + "}" + CRLF)
+ @continuation_request_arrival.wait
+ put_string(str)
+ end
- def format_number(num)
+ def send_number_data(num)
if num < 0 || num >= 4294967296
- raise DataFormatError, num.to_s
+ raise DataFormatError, num.to_s
end
- return num.to_s
+ put_string(num.to_s)
end
- def format_list(list)
- contents = list.collect {|i| format_data(i)}.join(" ")
- return "(" + contents + ")"
+ def send_list_data(list)
+ put_string("(")
+ first = true
+ list.each do |i|
+ if first
+ first = false
+ else
+ put_string(" ")
+ end
+ send_data(i)
+ end
+ put_string(")")
end
DATE_MONTH = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
- def format_time(time)
+ def send_time_data(time)
t = time.dup.gmtime
- return format('"%2d-%3s-%4d %02d:%02d:%02d +0000"',
- t.day, DATE_MONTH[t.month - 1], t.year,
- t.hour, t.min, t.sec)
+ s = format('"%2d-%3s-%4d %02d:%02d:%02d +0000"',
+ t.day, DATE_MONTH[t.month - 1], t.year,
+ t.hour, t.min, t.sec)
+ put_string(s)
end
- def format_symbol(symbol)
- return "\\" + symbol.to_s
+ def send_symbol_data(symbol)
+ put_string("\\" + symbol.to_s)
end
def search_internal(cmd, keys, charset)
if keys.instance_of?(String)
- keys = [RawData.new(keys)]
+ keys = [RawData.new(keys)]
else
- normalize_searching_criteria(keys)
+ normalize_searching_criteria(keys)
end
- if charset
- send_command(cmd, "CHARSET", charset, *keys)
- else
- send_command(cmd, *keys)
+ synchronize do
+ if charset
+ send_command(cmd, "CHARSET", charset, *keys)
+ else
+ send_command(cmd, *keys)
+ end
+ return @responses.delete("SEARCH")[-1]
end
- return @responses.delete("SEARCH")[-1]
end
def fetch_internal(cmd, set, attr)
if attr.instance_of?(String)
- attr = RawData.new(attr)
+ attr = RawData.new(attr)
+ end
+ synchronize do
+ @responses.delete("FETCH")
+ send_command(cmd, MessageSet.new(set), attr)
+ return @responses.delete("FETCH")
end
- @responses.delete("FETCH")
- send_command(cmd, MessageSet.new(set), attr)
- return @responses.delete("FETCH")
end
def store_internal(cmd, set, attr, flags)
if attr.instance_of?(String)
- attr = RawData.new(attr)
+ attr = RawData.new(attr)
+ end
+ synchronize do
+ @responses.delete("FETCH")
+ send_command(cmd, MessageSet.new(set), attr, flags)
+ return @responses.delete("FETCH")
end
- @responses.delete("FETCH")
- send_command(cmd, MessageSet.new(set), attr, flags)
- return @responses.delete("FETCH")
end
def copy_internal(cmd, set, mailbox)
@@ -1025,1274 +1170,1951 @@ module Net
def sort_internal(cmd, sort_keys, search_keys, charset)
if search_keys.instance_of?(String)
- search_keys = [RawData.new(search_keys)]
+ search_keys = [RawData.new(search_keys)]
else
- normalize_searching_criteria(search_keys)
+ normalize_searching_criteria(search_keys)
end
normalize_searching_criteria(search_keys)
- send_command(cmd, sort_keys, charset, *search_keys)
- return @responses.delete("SORT")[-1]
+ synchronize do
+ send_command(cmd, sort_keys, charset, *search_keys)
+ return @responses.delete("SORT")[-1]
+ end
end
- def normalize_searching_criteria(keys)
- keys.collect! do |i|
- case i
- when -1, Range, Array
- MessageSet.new(i)
- else
- i
- end
+ def thread_internal(cmd, algorithm, search_keys, charset)
+ if search_keys.instance_of?(String)
+ search_keys = [RawData.new(search_keys)]
+ else
+ normalize_searching_criteria(search_keys)
end
+ normalize_searching_criteria(search_keys)
+ send_command(cmd, algorithm, charset, *search_keys)
+ return @responses.delete("THREAD")[-1]
end
- class RawData
- def format_data
- return @data
+ def normalize_searching_criteria(keys)
+ keys.collect! do |i|
+ case i
+ when -1, Range, Array
+ MessageSet.new(i)
+ else
+ i
+ end
+ end
+ end
+
+ def self.u16tou8(s)
+ len = s.length
+ if len < 2
+ return ""
+ end
+ buf = ""
+ i = 0
+ while i < len
+ c = s[i] << 8 | s[i + 1]
+ i += 2
+ if c == 0xfeff
+ next
+ elsif c < 0x0080
+ buf.concat(c)
+ elsif c < 0x0800
+ b2 = c & 0x003f
+ b1 = c >> 6
+ buf.concat(b1 | 0xc0)
+ buf.concat(b2 | 0x80)
+ elsif c >= 0xdc00 && c < 0xe000
+ raise DataFormatError, "invalid surrogate detected"
+ elsif c >= 0xd800 && c < 0xdc00
+ if i + 2 > len
+ raise DataFormatError, "invalid surrogate detected"
+ end
+ low = s[i] << 8 | s[i + 1]
+ i += 2
+ if low < 0xdc00 || low > 0xdfff
+ raise DataFormatError, "invalid surrogate detected"
+ end
+ c = (((c & 0x03ff)) << 10 | (low & 0x03ff)) + 0x10000
+ b4 = c & 0x003f
+ b3 = (c >> 6) & 0x003f
+ b2 = (c >> 12) & 0x003f
+ b1 = c >> 18;
+ buf.concat(b1 | 0xf0)
+ buf.concat(b2 | 0x80)
+ buf.concat(b3 | 0x80)
+ buf.concat(b4 | 0x80)
+ else # 0x0800-0xffff
+ b3 = c & 0x003f
+ b2 = (c >> 6) & 0x003f
+ b1 = c >> 12
+ buf.concat(b1 | 0xe0)
+ buf.concat(b2 | 0x80)
+ buf.concat(b3 | 0x80)
+ end
+ end
+ return buf
+ end
+ private_class_method :u16tou8
+
+ def self.u8tou16(s)
+ len = s.length
+ buf = ""
+ i = 0
+ while i < len
+ c = s[i]
+ if (c & 0x80) == 0
+ buf.concat(0x00)
+ buf.concat(c)
+ i += 1
+ elsif (c & 0xe0) == 0xc0 &&
+ inlen >= 2 &&
+ (s[i + 1] & 0xc0) == 0x80
+ if c == 0xc0 || c == 0xc1
+ raise DataFormatError, format("non-shortest UTF-8 sequence (%02x)", c)
+ end
+ u = ((c & 0x1f) << 6) | (s[i + 1] & 0x3f)
+ buf.concat(u >> 8)
+ buf.concat(u & 0x00ff)
+ i += 2
+ elsif (c & 0xf0) == 0xe0 &&
+ i + 2 < len &&
+ (s[i + 1] & 0xc0) == 0x80 &&
+ (s[i + 2] & 0xc0) == 0x80
+ if c == 0xe0 && s[i + 1] < 0xa0
+ raise DataFormatError, format("non-shortest UTF-8 sequence (%02x)", c)
+ end
+ u = ((c & 0x0f) << 12) | ((s[i + 1] & 0x3f) << 6) | (s[i + 2] & 0x3f)
+ # surrogate chars
+ if u >= 0xd800 && u <= 0xdfff
+ raise DataFormatError, format("none-UTF-16 char detected (%04x)", u)
+ end
+ buf.concat(u >> 8)
+ buf.concat(u & 0x00ff)
+ i += 3
+ elsif (c & 0xf8) == 0xf0 &&
+ i + 3 < len &&
+ (s[i + 1] & 0xc0) == 0x80 &&
+ (s[i + 2] & 0xc0) == 0x80 &&
+ (s[i + 3] & 0xc0) == 0x80
+ if c == 0xf0 && s[i + 1] < 0x90
+ raise DataFormatError, format("non-shortest UTF-8 sequence (%02x)", c)
+ end
+ u = ((c & 0x07) << 18) | ((s[i + 1] & 0x3f) << 12) |
+ ((s[i + 2] & 0x3f) << 6) | (s[i + 3] & 0x3f)
+ if u < 0x10000
+ buf.concat(u >> 8)
+ buf.concat(u & 0x00ff)
+ elsif u < 0x110000
+ high = ((u - 0x10000) >> 10) | 0xd800
+ low = (u & 0x03ff) | 0xdc00
+ buf.concat(high >> 8)
+ buf.concat(high & 0x00ff)
+ buf.concat(low >> 8)
+ buf.concat(low & 0x00ff)
+ else
+ raise DataFormatError, format("none-UTF-16 char detected (%04x)", u)
+ end
+ i += 4
+ else
+ raise DataFormatError, format("illegal UTF-8 sequence (%02x)", c)
+ end
+ end
+ return buf
+ end
+ private_class_method :u8tou16
+
+ class RawData # :nodoc:
+ def send_data(imap)
+ imap.send(:put_string, @data)
end
private
def initialize(data)
- @data = data
+ @data = data
end
end
- class Atom
- def format_data
- return @data
+ class Atom # :nodoc:
+ def send_data(imap)
+ imap.send(:put_string, @data)
end
private
def initialize(data)
- @data = data
+ @data = data
end
end
- class QuotedString
- def format_data
- return '"' + @data.gsub(/["\\]/n, "\\\\\\&") + '"'
+ class QuotedString # :nodoc:
+ def send_data(imap)
+ imap.send(:send_quoted_string, @data)
end
private
def initialize(data)
- @data = data
+ @data = data
end
end
- class Literal
- def format_data
- return "{" + @data.length.to_s + "}" + CRLF + @data
+ class Literal # :nodoc:
+ def send_data(imap)
+ imap.send(:send_literal, @data)
end
private
def initialize(data)
- @data = data
+ @data = data
end
end
- class MessageSet
- def format_data
- return format_internal(@data)
+ class MessageSet # :nodoc:
+ def send_data(imap)
+ imap.send(:put_string, format_internal(@data))
end
private
def initialize(data)
- @data = data
+ @data = data
end
def format_internal(data)
- case data
- when "*"
- return data
- when Integer
- ensure_nz_number(data)
- if data == -1
- return "*"
- else
- return data.to_s
- end
- when Range
- return format_internal(data.first) +
- ":" + format_internal(data.last)
- when Array
- return data.collect {|i| format_internal(i)}.join(",")
- else
- raise DataFormatError, data.inspect
- end
+ case data
+ when "*"
+ return data
+ when Integer
+ ensure_nz_number(data)
+ if data == -1
+ return "*"
+ else
+ return data.to_s
+ end
+ when Range
+ return format_internal(data.first) +
+ ":" + format_internal(data.last)
+ when Array
+ return data.collect {|i| format_internal(i)}.join(",")
+ when ThreadMember
+ return data.seqno.to_s +
+ ":" + data.children.collect {|i| format_internal(i).join(",")}
+ else
+ raise DataFormatError, data.inspect
+ end
end
def ensure_nz_number(num)
- if num < -1 || num == 0 || num >= 4294967296
- raise DataFormatError, num.inspect
- end
- end
- end
-
- ContinueRequest = Struct.new(:data, :raw_data)
+ if num < -1 || num == 0 || num >= 4294967296
+ msg = "nz_number must be non-zero unsigned 32-bit integer: " +
+ num.inspect
+ raise DataFormatError, msg
+ end
+ end
+ end
+
+ # Net::IMAP::ContinuationRequest represents command continuation requests.
+ #
+ # The command continuation request response is indicated by a "+" token
+ # instead of a tag. This form of response indicates that the server is
+ # ready to accept the continuation of a command from the client. The
+ # remainder of this response is a line of text.
+ #
+ # continue_req ::= "+" SPACE (resp_text / base64)
+ #
+ # ==== Fields:
+ #
+ # data:: Returns the data (Net::IMAP::ResponseText).
+ #
+ # raw_data:: Returns the raw data string.
+ ContinuationRequest = Struct.new(:data, :raw_data)
+
+ # Net::IMAP::UntaggedResponse represents untagged responses.
+ #
+ # Data transmitted by the server to the client and status responses
+ # that do not indicate command completion are prefixed with the token
+ # "*", and are called untagged responses.
+ #
+ # response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye /
+ # mailbox_data / message_data / capability_data)
+ #
+ # ==== Fields:
+ #
+ # name:: Returns the name such as "FLAGS", "LIST", "FETCH"....
+ #
+ # data:: Returns the data such as an array of flag symbols,
+ # a ((<Net::IMAP::MailboxList>)) object....
+ #
+ # raw_data:: Returns the raw data string.
UntaggedResponse = Struct.new(:name, :data, :raw_data)
+
+ # Net::IMAP::TaggedResponse represents tagged responses.
+ #
+ # The server completion result response indicates the success or
+ # failure of the operation. It is tagged with the same tag as the
+ # client command which began the operation.
+ #
+ # response_tagged ::= tag SPACE resp_cond_state CRLF
+ #
+ # tag ::= 1*<any ATOM_CHAR except "+">
+ #
+ # resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text
+ #
+ # ==== Fields:
+ #
+ # tag:: Returns the tag.
+ #
+ # name:: Returns the name. the name is one of "OK", "NO", "BAD".
+ #
+ # data:: Returns the data. See ((<Net::IMAP::ResponseText>)).
+ #
+ # raw_data:: Returns the raw data string.
+ #
TaggedResponse = Struct.new(:tag, :name, :data, :raw_data)
+
+ # Net::IMAP::ResponseText represents texts of responses.
+ # The text may be prefixed by the response code.
+ #
+ # resp_text ::= ["[" resp_text_code "]" SPACE] (text_mime2 / text)
+ # ;; text SHOULD NOT begin with "[" or "="
+ #
+ # ==== Fields:
+ #
+ # code:: Returns the response code. See ((<Net::IMAP::ResponseCode>)).
+ #
+ # text:: Returns the text.
+ #
ResponseText = Struct.new(:code, :text)
+
+ #
+ # Net::IMAP::ResponseCode represents response codes.
+ #
+ # resp_text_code ::= "ALERT" / "PARSE" /
+ # "PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" /
+ # "READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
+ # "UIDVALIDITY" SPACE nz_number /
+ # "UNSEEN" SPACE nz_number /
+ # atom [SPACE 1*<any TEXT_CHAR except "]">]
+ #
+ # ==== Fields:
+ #
+ # name:: Returns the name such as "ALERT", "PERMANENTFLAGS", "UIDVALIDITY"....
+ #
+ # data:: Returns the data if it exists.
+ #
ResponseCode = Struct.new(:name, :data)
+
+ # Net::IMAP::MailboxList represents contents of the LIST response.
+ #
+ # mailbox_list ::= "(" #("\Marked" / "\Noinferiors" /
+ # "\Noselect" / "\Unmarked" / flag_extension) ")"
+ # SPACE (<"> QUOTED_CHAR <"> / nil) SPACE mailbox
+ #
+ # ==== Fields:
+ #
+ # attr:: Returns the name attributes. Each name attribute is a symbol
+ # capitalized by String#capitalize, such as :Noselect (not :NoSelect).
+ #
+ # delim:: Returns the hierarchy delimiter
+ #
+ # name:: Returns the mailbox name.
+ #
MailboxList = Struct.new(:attr, :delim, :name)
+
+ # Net::IMAP::MailboxQuota represents contents of GETQUOTA response.
+ # This object can also be a response to GETQUOTAROOT. In the syntax
+ # specification below, the delimiter used with the "#" construct is a
+ # single space (SPACE).
+ #
+ # quota_list ::= "(" #quota_resource ")"
+ #
+ # quota_resource ::= atom SPACE number SPACE number
+ #
+ # quota_response ::= "QUOTA" SPACE astring SPACE quota_list
+ #
+ # ==== Fields:
+ #
+ # mailbox:: The mailbox with the associated quota.
+ #
+ # usage:: Current storage usage of mailbox.
+ #
+ # quota:: Quota limit imposed on mailbox.
+ #
+ MailboxQuota = Struct.new(:mailbox, :usage, :quota)
+
+ # Net::IMAP::MailboxQuotaRoot represents part of the GETQUOTAROOT
+ # response. (GETQUOTAROOT can also return Net::IMAP::MailboxQuota.)
+ #
+ # quotaroot_response ::= "QUOTAROOT" SPACE astring *(SPACE astring)
+ #
+ # ==== Fields:
+ #
+ # mailbox:: The mailbox with the associated quota.
+ #
+ # quotaroots:: Zero or more quotaroots that effect the quota on the
+ # specified mailbox.
+ #
+ MailboxQuotaRoot = Struct.new(:mailbox, :quotaroots)
+
+ # Net::IMAP::MailboxACLItem represents response from GETACL.
+ #
+ # acl_data ::= "ACL" SPACE mailbox *(SPACE identifier SPACE rights)
+ #
+ # identifier ::= astring
+ #
+ # rights ::= astring
+ #
+ # ==== Fields:
+ #
+ # user:: Login name that has certain rights to the mailbox
+ # that was specified with the getacl command.
+ #
+ # rights:: The access rights the indicated user has to the
+ # mailbox.
+ #
+ MailboxACLItem = Struct.new(:user, :rights)
+
+ # Net::IMAP::StatusData represents contents of the STATUS response.
+ #
+ # ==== Fields:
+ #
+ # mailbox:: Returns the mailbox name.
+ #
+ # attr:: Returns a hash. Each key is one of "MESSAGES", "RECENT", "UIDNEXT",
+ # "UIDVALIDITY", "UNSEEN". Each value is a number.
+ #
StatusData = Struct.new(:mailbox, :attr)
+
+ # Net::IMAP::FetchData represents contents of the FETCH response.
+ #
+ # ==== Fields:
+ #
+ # seqno:: Returns the message sequence number.
+ # (Note: not the unique identifier, even for the UID command response.)
+ #
+ # attr:: Returns a hash. Each key is a data item name, and each value is
+ # its value.
+ #
+ # The current data items are:
+ #
+ # [BODY]
+ # A form of BODYSTRUCTURE without extension data.
+ # [BODY[<section>]<<origin_octet>>]
+ # A string expressing the body contents of the specified section.
+ # [BODYSTRUCTURE]
+ # An object that describes the [MIME-IMB] body structure of a message.
+ # See Net::IMAP::BodyTypeBasic, Net::IMAP::BodyTypeText,
+ # Net::IMAP::BodyTypeMessage, Net::IMAP::BodyTypeMultipart.
+ # [ENVELOPE]
+ # A Net::IMAP::Envelope object that describes the envelope
+ # structure of a message.
+ # [FLAGS]
+ # A array of flag symbols that are set for this message. flag symbols
+ # are capitalized by String#capitalize.
+ # [INTERNALDATE]
+ # A string representing the internal date of the message.
+ # [RFC822]
+ # Equivalent to BODY[].
+ # [RFC822.HEADER]
+ # Equivalent to BODY.PEEK[HEADER].
+ # [RFC822.SIZE]
+ # A number expressing the [RFC-822] size of the message.
+ # [RFC822.TEXT]
+ # Equivalent to BODY[TEXT].
+ # [UID]
+ # A number expressing the unique identifier of the message.
+ #
FetchData = Struct.new(:seqno, :attr)
+
+ # Net::IMAP::Envelope represents envelope structures of messages.
+ #
+ # ==== Fields:
+ #
+ # date:: Returns a string that represents the date.
+ #
+ # subject:: Returns a string that represents the subject.
+ #
+ # from:: Returns an array of Net::IMAP::Address that represents the from.
+ #
+ # sender:: Returns an array of Net::IMAP::Address that represents the sender.
+ #
+ # reply_to:: Returns an array of Net::IMAP::Address that represents the reply-to.
+ #
+ # to:: Returns an array of Net::IMAP::Address that represents the to.
+ #
+ # cc:: Returns an array of Net::IMAP::Address that represents the cc.
+ #
+ # bcc:: Returns an array of Net::IMAP::Address that represents the bcc.
+ #
+ # in_reply_to:: Returns a string that represents the in-reply-to.
+ #
+ # message_id:: Returns a string that represents the message-id.
+ #
Envelope = Struct.new(:date, :subject, :from, :sender, :reply_to,
- :to, :cc, :bcc, :in_reply_to, :message_id)
+ :to, :cc, :bcc, :in_reply_to, :message_id)
+
+ #
+ # Net::IMAP::Address represents electronic mail addresses.
+ #
+ # ==== Fields:
+ #
+ # name:: Returns the phrase from [RFC-822] mailbox.
+ #
+ # route:: Returns the route from [RFC-822] route-addr.
+ #
+ # mailbox:: nil indicates end of [RFC-822] group.
+ # If non-nil and host is nil, returns [RFC-822] group name.
+ # Otherwise, returns [RFC-822] local-part
+ #
+ # host:: nil indicates [RFC-822] group syntax.
+ # Otherwise, returns [RFC-822] domain name.
+ #
Address = Struct.new(:name, :route, :mailbox, :host)
+
+ #
+ # Net::IMAP::ContentDisposition represents Content-Disposition fields.
+ #
+ # ==== Fields:
+ #
+ # dsp_type:: Returns the disposition type.
+ #
+ # param:: Returns a hash that represents parameters of the Content-Disposition
+ # field.
+ #
ContentDisposition = Struct.new(:dsp_type, :param)
+ # Net::IMAP::ThreadMember represents a thread-node returned
+ # by Net::IMAP#thread
+ #
+ # ==== Fields:
+ #
+ # seqno:: The sequence number of this message.
+ #
+ # children:: an array of Net::IMAP::ThreadMember objects for mail
+ # items that are children of this in the thread.
+ #
+ ThreadMember = Struct.new(:seqno, :children)
+
+ # Net::IMAP::BodyTypeBasic represents basic body structures of messages.
+ #
+ # ==== Fields:
+ #
+ # media_type:: Returns the content media type name as defined in [MIME-IMB].
+ #
+ # subtype:: Returns the content subtype name as defined in [MIME-IMB].
+ #
+ # param:: Returns a hash that represents parameters as defined in [MIME-IMB].
+ #
+ # content_id:: Returns a string giving the content id as defined in [MIME-IMB].
+ #
+ # description:: Returns a string giving the content description as defined in
+ # [MIME-IMB].
+ #
+ # encoding:: Returns a string giving the content transfer encoding as defined in
+ # [MIME-IMB].
+ #
+ # size:: Returns a number giving the size of the body in octets.
+ #
+ # md5:: Returns a string giving the body MD5 value as defined in [MD5].
+ #
+ # disposition:: Returns a Net::IMAP::ContentDisposition object giving
+ # the content disposition.
+ #
+ # language:: Returns a string or an array of strings giving the body
+ # language value as defined in [LANGUAGE-TAGS].
+ #
+ # extension:: Returns extension data.
+ #
+ # multipart?:: Returns false.
+ #
class BodyTypeBasic < Struct.new(:media_type, :subtype,
- :param, :content_id,
- :description, :encoding, :size,
- :md5, :disposition, :language,
- :extension)
+ :param, :content_id,
+ :description, :encoding, :size,
+ :md5, :disposition, :language,
+ :extension)
def multipart?
- return false
+ return false
end
+ # Obsolete: use +subtype+ instead. Calling this will
+ # generate a warning message to +stderr+, then return
+ # the value of +subtype+.
def media_subtype
- $stderr.printf("warning: media_subtype is obsolete.\n")
- $stderr.printf(" use subtype instead.\n")
- return subtype
+ $stderr.printf("warning: media_subtype is obsolete.\n")
+ $stderr.printf(" use subtype instead.\n")
+ return subtype
end
end
+ # Net::IMAP::BodyTypeText represents TEXT body structures of messages.
+ #
+ # ==== Fields:
+ #
+ # lines:: Returns the size of the body in text lines.
+ #
+ # And Net::IMAP::BodyTypeText has all fields of Net::IMAP::BodyTypeBasic.
+ #
class BodyTypeText < Struct.new(:media_type, :subtype,
- :param, :content_id,
- :description, :encoding, :size,
- :lines,
- :md5, :disposition, :language,
- :extension)
+ :param, :content_id,
+ :description, :encoding, :size,
+ :lines,
+ :md5, :disposition, :language,
+ :extension)
def multipart?
- return false
+ return false
end
+ # Obsolete: use +subtype+ instead. Calling this will
+ # generate a warning message to +stderr+, then return
+ # the value of +subtype+.
def media_subtype
- $stderr.printf("warning: media_subtype is obsolete.\n")
- $stderr.printf(" use subtype instead.\n")
- return subtype
- end
- end
-
+ $stderr.printf("warning: media_subtype is obsolete.\n")
+ $stderr.printf(" use subtype instead.\n")
+ return subtype
+ end
+ end
+
+ # Net::IMAP::BodyTypeMessage represents MESSAGE/RFC822 body structures of messages.
+ #
+ # ==== Fields:
+ #
+ # envelope:: Returns a Net::IMAP::Envelope giving the envelope structure.
+ #
+ # body:: Returns an object giving the body structure.
+ #
+ # And Net::IMAP::BodyTypeMessage has all methods of Net::IMAP::BodyTypeText.
+ #
class BodyTypeMessage < Struct.new(:media_type, :subtype,
- :param, :content_id,
- :description, :encoding, :size,
- :envelope, :body, :lines,
- :md5, :disposition, :language,
- :extension)
+ :param, :content_id,
+ :description, :encoding, :size,
+ :envelope, :body, :lines,
+ :md5, :disposition, :language,
+ :extension)
def multipart?
- return false
+ return false
end
+ # Obsolete: use +subtype+ instead. Calling this will
+ # generate a warning message to +stderr+, then return
+ # the value of +subtype+.
def media_subtype
- $stderr.printf("warning: media_subtype is obsolete.\n")
- $stderr.printf(" use subtype instead.\n")
- return subtype
- end
- end
-
+ $stderr.printf("warning: media_subtype is obsolete.\n")
+ $stderr.printf(" use subtype instead.\n")
+ return subtype
+ end
+ end
+
+ # Net::IMAP::BodyTypeMultipart represents multipart body structures
+ # of messages.
+ #
+ # ==== Fields:
+ #
+ # media_type:: Returns the content media type name as defined in [MIME-IMB].
+ #
+ # subtype:: Returns the content subtype name as defined in [MIME-IMB].
+ #
+ # parts:: Returns multiple parts.
+ #
+ # param:: Returns a hash that represents parameters as defined in [MIME-IMB].
+ #
+ # disposition:: Returns a Net::IMAP::ContentDisposition object giving
+ # the content disposition.
+ #
+ # language:: Returns a string or an array of strings giving the body
+ # language value as defined in [LANGUAGE-TAGS].
+ #
+ # extension:: Returns extension data.
+ #
+ # multipart?:: Returns true.
+ #
class BodyTypeMultipart < Struct.new(:media_type, :subtype,
- :parts,
- :param, :disposition, :language,
- :extension)
+ :parts,
+ :param, :disposition, :language,
+ :extension)
def multipart?
- return true
+ return true
end
+ # Obsolete: use +subtype+ instead. Calling this will
+ # generate a warning message to +stderr+, then return
+ # the value of +subtype+.
def media_subtype
- $stderr.printf("warning: media_subtype is obsolete.\n")
- $stderr.printf(" use subtype instead.\n")
- return subtype
+ $stderr.printf("warning: media_subtype is obsolete.\n")
+ $stderr.printf(" use subtype instead.\n")
+ return subtype
end
end
- class ResponseParser
+ class ResponseParser # :nodoc:
def parse(str)
- @str = str
- @pos = 0
- @lex_state = EXPR_BEG
- @token = nil
- return response
+ @str = str
+ @pos = 0
+ @lex_state = EXPR_BEG
+ @token = nil
+ return response
end
private
- EXPR_BEG = :EXPR_BEG
- EXPR_DATA = :EXPR_DATA
- EXPR_TEXT = :EXPR_TEXT
- EXPR_RTEXT = :EXPR_RTEXT
- EXPR_CTEXT = :EXPR_CTEXT
-
- T_SPACE = :SPACE
- T_NIL = :NIL
- T_NUMBER = :NUMBER
- T_ATOM = :ATOM
- T_QUOTED = :QUOTED
- T_LPAR = :LPAR
- T_RPAR = :RPAR
- T_BSLASH = :BSLASH
- T_STAR = :STAR
- T_LBRA = :LBRA
- T_RBRA = :RBRA
- T_LITERAL = :LITERAL
- T_PLUS = :PLUS
- T_PERCENT = :PERCENT
- T_CRLF = :CRLF
- T_EOF = :EOF
- T_TEXT = :TEXT
+ EXPR_BEG = :EXPR_BEG
+ EXPR_DATA = :EXPR_DATA
+ EXPR_TEXT = :EXPR_TEXT
+ EXPR_RTEXT = :EXPR_RTEXT
+ EXPR_CTEXT = :EXPR_CTEXT
+
+ T_SPACE = :SPACE
+ T_NIL = :NIL
+ T_NUMBER = :NUMBER
+ T_ATOM = :ATOM
+ T_QUOTED = :QUOTED
+ T_LPAR = :LPAR
+ T_RPAR = :RPAR
+ T_BSLASH = :BSLASH
+ T_STAR = :STAR
+ T_LBRA = :LBRA
+ T_RBRA = :RBRA
+ T_LITERAL = :LITERAL
+ T_PLUS = :PLUS
+ T_PERCENT = :PERCENT
+ T_CRLF = :CRLF
+ T_EOF = :EOF
+ T_TEXT = :TEXT
BEG_REGEXP = /\G(?:\
-(?# 1: SPACE )( )|\
-(?# 2: NIL )(NIL)(?=[\x80-\xff(){ \x00-\x1f\x7f%*"\\\[\]+])|\
-(?# 3: NUMBER )(\d+)(?=[\x80-\xff(){ \x00-\x1f\x7f%*"\\\[\]+])|\
-(?# 4: ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*"\\\[\]+]+)|\
-(?# 5: QUOTED )"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)"|\
-(?# 6: LPAR )(\()|\
-(?# 7: RPAR )(\))|\
-(?# 8: BSLASH )(\\)|\
-(?# 9: STAR )(\*)|\
-(?# 10: LBRA )(\[)|\
-(?# 11: RBRA )(\])|\
-(?# 12: LITERAL )\{(\d+)\}\r\n|\
-(?# 13: PLUS )(\+)|\
-(?# 14: PERCENT )(%)|\
-(?# 15: CRLF )(\r\n)|\
-(?# 16: EOF )(\z))/ni
+(?# 1: SPACE )( )|\
+(?# 2: NIL )(NIL)(?=[\x80-\xff(){ \x00-\x1f\x7f%*"\\\[\]+])|\
+(?# 3: NUMBER )(\d+)(?=[\x80-\xff(){ \x00-\x1f\x7f%*"\\\[\]+])|\
+(?# 4: ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*"\\\[\]+]+)|\
+(?# 5: QUOTED )"((?:[^\x00\r\n"\\]|\\["\\])*)"|\
+(?# 6: LPAR )(\()|\
+(?# 7: RPAR )(\))|\
+(?# 8: BSLASH )(\\)|\
+(?# 9: STAR )(\*)|\
+(?# 10: LBRA )(\[)|\
+(?# 11: RBRA )(\])|\
+(?# 12: LITERAL )\{(\d+)\}\r\n|\
+(?# 13: PLUS )(\+)|\
+(?# 14: PERCENT )(%)|\
+(?# 15: CRLF )(\r\n)|\
+(?# 16: EOF )(\z))/ni
DATA_REGEXP = /\G(?:\
-(?# 1: SPACE )( )|\
-(?# 2: NIL )(NIL)|\
-(?# 3: NUMBER )(\d+)|\
-(?# 4: QUOTED )"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)"|\
-(?# 5: LITERAL )\{(\d+)\}\r\n|\
-(?# 6: LPAR )(\()|\
-(?# 7: RPAR )(\)))/ni
+(?# 1: SPACE )( )|\
+(?# 2: NIL )(NIL)|\
+(?# 3: NUMBER )(\d+)|\
+(?# 4: QUOTED )"((?:[^\x00\r\n"\\]|\\["\\])*)"|\
+(?# 5: LITERAL )\{(\d+)\}\r\n|\
+(?# 6: LPAR )(\()|\
+(?# 7: RPAR )(\)))/ni
TEXT_REGEXP = /\G(?:\
-(?# 1: TEXT )([^\x00\x80-\xff\r\n]*))/ni
+(?# 1: TEXT )([^\x00\r\n]*))/ni
RTEXT_REGEXP = /\G(?:\
-(?# 1: LBRA )(\[)|\
-(?# 2: TEXT )([^\x00\x80-\xff\r\n]*))/ni
+(?# 1: LBRA )(\[)|\
+(?# 2: TEXT )([^\x00\r\n]*))/ni
CTEXT_REGEXP = /\G(?:\
-(?# 1: TEXT )([^\x00\x80-\xff\r\n\]]*))/ni
+(?# 1: TEXT )([^\x00\r\n\]]*))/ni
Token = Struct.new(:symbol, :value)
def response
- token = lookahead
- case token.symbol
- when T_PLUS
- result = continue_req
- when T_STAR
- result = response_untagged
- else
- result = response_tagged
- end
- match(T_CRLF)
- match(T_EOF)
- return result
+ token = lookahead
+ case token.symbol
+ when T_PLUS
+ result = continue_req
+ when T_STAR
+ result = response_untagged
+ else
+ result = response_tagged
+ end
+ match(T_CRLF)
+ match(T_EOF)
+ return result
end
def continue_req
- match(T_PLUS)
- match(T_SPACE)
- return ContinueRequest.new(resp_text, @str)
+ match(T_PLUS)
+ match(T_SPACE)
+ return ContinuationRequest.new(resp_text, @str)
end
def response_untagged
- match(T_STAR)
- match(T_SPACE)
- token = lookahead
- if token.symbol == T_NUMBER
- return numeric_response
- elsif token.symbol == T_ATOM
- case token.value
- when /\A(?:OK|NO|BAD|BYE|PREAUTH)\z/ni
- return response_cond
- when /\A(?:FLAGS)\z/ni
- return flags_response
- when /\A(?:LIST|LSUB)\z/ni
- return list_response
- when /\A(?:SEARCH|SORT)\z/ni
- return search_response
- when /\A(?:STATUS)\z/ni
- return status_response
- when /\A(?:CAPABILITY)\z/ni
- return capability_response
- else
- return text_response
- end
- else
- parse_error("unexpected token %s", token.symbol)
- end
+ match(T_STAR)
+ match(T_SPACE)
+ token = lookahead
+ if token.symbol == T_NUMBER
+ return numeric_response
+ elsif token.symbol == T_ATOM
+ case token.value
+ when /\A(?:OK|NO|BAD|BYE|PREAUTH)\z/ni
+ return response_cond
+ when /\A(?:FLAGS)\z/ni
+ return flags_response
+ when /\A(?:LIST|LSUB)\z/ni
+ return list_response
+ when /\A(?:QUOTA)\z/ni
+ return getquota_response
+ when /\A(?:QUOTAROOT)\z/ni
+ return getquotaroot_response
+ when /\A(?:ACL)\z/ni
+ return getacl_response
+ when /\A(?:SEARCH|SORT)\z/ni
+ return search_response
+ when /\A(?:THREAD)\z/ni
+ return thread_response
+ when /\A(?:STATUS)\z/ni
+ return status_response
+ when /\A(?:CAPABILITY)\z/ni
+ return capability_response
+ else
+ return text_response
+ end
+ else
+ parse_error("unexpected token %s", token.symbol)
+ end
end
def response_tagged
- tag = atom
- match(T_SPACE)
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return TaggedResponse.new(tag, name, resp_text, @str)
+ tag = atom
+ match(T_SPACE)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return TaggedResponse.new(tag, name, resp_text, @str)
end
def response_cond
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return UntaggedResponse.new(name, resp_text, @str)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return UntaggedResponse.new(name, resp_text, @str)
end
def numeric_response
- n = number
- match(T_SPACE)
- token = match(T_ATOM)
- name = token.value.upcase
- case name
- when "EXISTS", "RECENT", "EXPUNGE"
- return UntaggedResponse.new(name, n, @str)
- when "FETCH"
- shift_token
- match(T_SPACE)
- data = FetchData.new(n, msg_att)
- return UntaggedResponse.new(name, data, @str)
- end
+ n = number
+ match(T_SPACE)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ case name
+ when "EXISTS", "RECENT", "EXPUNGE"
+ return UntaggedResponse.new(name, n, @str)
+ when "FETCH"
+ shift_token
+ match(T_SPACE)
+ data = FetchData.new(n, msg_att)
+ return UntaggedResponse.new(name, data, @str)
+ end
end
def msg_att
- match(T_LPAR)
- attr = {}
- while true
- token = lookahead
- case token.symbol
- when T_RPAR
- shift_token
- break
- when T_SPACE
- shift_token
- token = lookahead
- end
- case token.value
- when /\A(?:ENVELOPE)\z/ni
- name, val = envelope_data
- when /\A(?:FLAGS)\z/ni
- name, val = flags_data
- when /\A(?:INTERNALDATE)\z/ni
- name, val = internaldate_data
- when /\A(?:RFC822(?:\.HEADER|\.TEXT)?)\z/ni
- name, val = rfc822_text
- when /\A(?:RFC822\.SIZE)\z/ni
- name, val = rfc822_size
- when /\A(?:BODY(?:STRUCTURE)?)\z/ni
- name, val = body_data
- when /\A(?:UID)\z/ni
- name, val = uid_data
- else
- parse_error("unknown attribute `%s'", token.value)
- end
- attr[name] = val
- end
- return attr
+ match(T_LPAR)
+ attr = {}
+ while true
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ shift_token
+ break
+ when T_SPACE
+ shift_token
+ token = lookahead
+ end
+ case token.value
+ when /\A(?:ENVELOPE)\z/ni
+ name, val = envelope_data
+ when /\A(?:FLAGS)\z/ni
+ name, val = flags_data
+ when /\A(?:INTERNALDATE)\z/ni
+ name, val = internaldate_data
+ when /\A(?:RFC822(?:\.HEADER|\.TEXT)?)\z/ni
+ name, val = rfc822_text
+ when /\A(?:RFC822\.SIZE)\z/ni
+ name, val = rfc822_size
+ when /\A(?:BODY(?:STRUCTURE)?)\z/ni
+ name, val = body_data
+ when /\A(?:UID)\z/ni
+ name, val = uid_data
+ else
+ parse_error("unknown attribute `%s'", token.value)
+ end
+ attr[name] = val
+ end
+ return attr
end
def envelope_data
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return name, envelope
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return name, envelope
end
def envelope
- @lex_state = EXPR_DATA
- match(T_LPAR)
- date = nstring
- match(T_SPACE)
- subject = nstring
- match(T_SPACE)
- from = address_list
- match(T_SPACE)
- sender = address_list
- match(T_SPACE)
- reply_to = address_list
- match(T_SPACE)
- to = address_list
- match(T_SPACE)
- cc = address_list
- match(T_SPACE)
- bcc = address_list
- match(T_SPACE)
- in_reply_to = nstring
- match(T_SPACE)
- message_id = nstring
- match(T_RPAR)
- @lex_state = EXPR_BEG
- return Envelope.new(date, subject, from, sender, reply_to,
- to, cc, bcc, in_reply_to, message_id)
+ @lex_state = EXPR_DATA
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ result = nil
+ else
+ match(T_LPAR)
+ date = nstring
+ match(T_SPACE)
+ subject = nstring
+ match(T_SPACE)
+ from = address_list
+ match(T_SPACE)
+ sender = address_list
+ match(T_SPACE)
+ reply_to = address_list
+ match(T_SPACE)
+ to = address_list
+ match(T_SPACE)
+ cc = address_list
+ match(T_SPACE)
+ bcc = address_list
+ match(T_SPACE)
+ in_reply_to = nstring
+ match(T_SPACE)
+ message_id = nstring
+ match(T_RPAR)
+ result = Envelope.new(date, subject, from, sender, reply_to,
+ to, cc, bcc, in_reply_to, message_id)
+ end
+ @lex_state = EXPR_BEG
+ return result
end
def flags_data
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return name, flag_list
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return name, flag_list
end
def internaldate_data
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- token = match(T_QUOTED)
- return name, token.value
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ token = match(T_QUOTED)
+ return name, token.value
end
def rfc822_text
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return name, nstring
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return name, nstring
end
def rfc822_size
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return name, number
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return name, number
end
def body_data
- token = match(T_ATOM)
- name = token.value.upcase
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- return name, body
- end
- name.concat(section)
- token = lookahead
- if token.symbol == T_ATOM
- name.concat(token.value)
- shift_token
- end
- match(T_SPACE)
- data = nstring
- return name, data
+ token = match(T_ATOM)
+ name = token.value.upcase
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ return name, body
+ end
+ name.concat(section)
+ token = lookahead
+ if token.symbol == T_ATOM
+ name.concat(token.value)
+ shift_token
+ end
+ match(T_SPACE)
+ data = nstring
+ return name, data
end
def body
- @lex_state = EXPR_DATA
- match(T_LPAR)
- token = lookahead
- if token.symbol == T_LPAR
- result = body_type_mpart
- else
- result = body_type_1part
- end
- match(T_RPAR)
- @lex_state = EXPR_BEG
- return result
+ @lex_state = EXPR_DATA
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ result = nil
+ else
+ match(T_LPAR)
+ token = lookahead
+ if token.symbol == T_LPAR
+ result = body_type_mpart
+ else
+ result = body_type_1part
+ end
+ match(T_RPAR)
+ end
+ @lex_state = EXPR_BEG
+ return result
end
def body_type_1part
- token = lookahead
- case token.value
- when /\A(?:TEXT)\z/ni
- return body_type_text
- when /\A(?:MESSAGE)\z/ni
- return body_type_msg
- else
- return body_type_basic
- end
+ token = lookahead
+ case token.value
+ when /\A(?:TEXT)\z/ni
+ return body_type_text
+ when /\A(?:MESSAGE)\z/ni
+ return body_type_msg
+ else
+ return body_type_basic
+ end
end
def body_type_basic
- mtype, msubtype = media_type
- match(T_SPACE)
- param, content_id, desc, enc, size = body_fields
- md5, disposition, language, extension = body_ext_1part
- return BodyTypeBasic.new(mtype, msubtype,
- param, content_id,
- desc, enc, size,
- md5, disposition, language, extension)
+ mtype, msubtype = media_type
+ token = lookahead
+ if token.symbol == T_RPAR
+ return BodyTypeBasic.new(mtype, msubtype)
+ end
+ match(T_SPACE)
+ param, content_id, desc, enc, size = body_fields
+ md5, disposition, language, extension = body_ext_1part
+ return BodyTypeBasic.new(mtype, msubtype,
+ param, content_id,
+ desc, enc, size,
+ md5, disposition, language, extension)
end
def body_type_text
- mtype, msubtype = media_type
- match(T_SPACE)
- param, content_id, desc, enc, size = body_fields
- match(T_SPACE)
- lines = number
- md5, disposition, language, extension = body_ext_1part
- return BodyTypeText.new(mtype, msubtype,
- param, content_id,
- desc, enc, size,
- lines,
- md5, disposition, language, extension)
+ mtype, msubtype = media_type
+ match(T_SPACE)
+ param, content_id, desc, enc, size = body_fields
+ match(T_SPACE)
+ lines = number
+ md5, disposition, language, extension = body_ext_1part
+ return BodyTypeText.new(mtype, msubtype,
+ param, content_id,
+ desc, enc, size,
+ lines,
+ md5, disposition, language, extension)
end
def body_type_msg
- mtype, msubtype = media_type
- match(T_SPACE)
- param, content_id, desc, enc, size = body_fields
- match(T_SPACE)
- env = envelope
- match(T_SPACE)
- b = body
- match(T_SPACE)
- lines = number
- md5, disposition, language, extension = body_ext_1part
- return BodyTypeMessage.new(mtype, msubtype,
- param, content_id,
- desc, enc, size,
- env, b, lines,
- md5, disposition, language, extension)
+ mtype, msubtype = media_type
+ match(T_SPACE)
+ param, content_id, desc, enc, size = body_fields
+ match(T_SPACE)
+ env = envelope
+ match(T_SPACE)
+ b = body
+ match(T_SPACE)
+ lines = number
+ md5, disposition, language, extension = body_ext_1part
+ return BodyTypeMessage.new(mtype, msubtype,
+ param, content_id,
+ desc, enc, size,
+ env, b, lines,
+ md5, disposition, language, extension)
end
def body_type_mpart
- parts = []
- while true
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- break
- end
- parts.push(body)
- end
- mtype = "MULTIPART"
- msubtype = string.upcase
- param, disposition, language, extension = body_ext_mpart
- return BodyTypeMultipart.new(mtype, msubtype, parts,
- param, disposition, language,
- extension)
+ parts = []
+ while true
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ break
+ end
+ parts.push(body)
+ end
+ mtype = "MULTIPART"
+ msubtype = case_insensitive_string
+ param, disposition, language, extension = body_ext_mpart
+ return BodyTypeMultipart.new(mtype, msubtype, parts,
+ param, disposition, language,
+ extension)
end
def media_type
- mtype = string.upcase
- match(T_SPACE)
- msubtype = string.upcase
- return mtype, msubtype
+ mtype = case_insensitive_string
+ match(T_SPACE)
+ msubtype = case_insensitive_string
+ return mtype, msubtype
end
def body_fields
- param = body_fld_param
- match(T_SPACE)
- content_id = nstring
- match(T_SPACE)
- desc = nstring
- match(T_SPACE)
- enc = string.upcase
- match(T_SPACE)
- size = number
- return param, content_id, desc, enc, size
+ param = body_fld_param
+ match(T_SPACE)
+ content_id = nstring
+ match(T_SPACE)
+ desc = nstring
+ match(T_SPACE)
+ enc = case_insensitive_string
+ match(T_SPACE)
+ size = number
+ return param, content_id, desc, enc, size
end
def body_fld_param
- token = lookahead
- if token.symbol == T_NIL
- shift_token
- return nil
- end
- match(T_LPAR)
- param = {}
- while true
- token = lookahead
- case token.symbol
- when T_RPAR
- shift_token
- break
- when T_SPACE
- shift_token
- end
- name = string.upcase
- match(T_SPACE)
- val = string
- param[name] = val
- end
- return param
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ end
+ match(T_LPAR)
+ param = {}
+ while true
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ shift_token
+ break
+ when T_SPACE
+ shift_token
+ end
+ name = case_insensitive_string
+ match(T_SPACE)
+ val = string
+ param[name] = val
+ end
+ return param
end
def body_ext_1part
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- else
- return nil
- end
- md5 = nstring
-
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- else
- return md5
- end
- disposition = body_fld_dsp
-
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- else
- return md5, disposition
- end
- language = body_fld_lang
-
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- else
- return md5, disposition, language
- end
-
- extension = body_extensions
- return md5, disposition, language, extension
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ else
+ return nil
+ end
+ md5 = nstring
+
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ else
+ return md5
+ end
+ disposition = body_fld_dsp
+
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ else
+ return md5, disposition
+ end
+ language = body_fld_lang
+
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ else
+ return md5, disposition, language
+ end
+
+ extension = body_extensions
+ return md5, disposition, language, extension
end
def body_ext_mpart
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- else
- return nil
- end
- param = body_fld_param
-
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- else
- return param
- end
- disposition = body_fld_dsp
- match(T_SPACE)
- language = body_fld_lang
-
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- else
- return param, disposition, language
- end
-
- extension = body_extensions
- return param, disposition, language, extension
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ else
+ return nil
+ end
+ param = body_fld_param
+
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ else
+ return param
+ end
+ disposition = body_fld_dsp
+ match(T_SPACE)
+ language = body_fld_lang
+
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ else
+ return param, disposition, language
+ end
+
+ extension = body_extensions
+ return param, disposition, language, extension
end
def body_fld_dsp
- token = lookahead
- if token.symbol == T_NIL
- shift_token
- return nil
- end
- match(T_LPAR)
- dsp_type = string.upcase
- match(T_SPACE)
- param = body_fld_param
- match(T_RPAR)
- return ContentDisposition.new(dsp_type, param)
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ end
+ match(T_LPAR)
+ dsp_type = case_insensitive_string
+ match(T_SPACE)
+ param = body_fld_param
+ match(T_RPAR)
+ return ContentDisposition.new(dsp_type, param)
end
def body_fld_lang
- token = lookahead
- if token.symbol == T_LPAR
- shift_token
- result = []
- while true
- token = lookahead
- case token.symbol
- when T_RPAR
- shift_token
- return result
- when T_SPACE
- shift_token
- end
- result.push(string.upcase)
- end
- else
- lang = nstring
- if lang
- return lang.upcase
- else
- return lang
- end
- end
+ token = lookahead
+ if token.symbol == T_LPAR
+ shift_token
+ result = []
+ while true
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ shift_token
+ return result
+ when T_SPACE
+ shift_token
+ end
+ result.push(case_insensitive_string)
+ end
+ else
+ lang = nstring
+ if lang
+ return lang.upcase
+ else
+ return lang
+ end
+ end
end
def body_extensions
- result = []
- while true
- token = lookahead
- case token.symbol
- when T_RPAR
- return result
- when T_SPACE
- shift_token
- end
- result.push(body_extension)
- end
+ result = []
+ while true
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ return result
+ when T_SPACE
+ shift_token
+ end
+ result.push(body_extension)
+ end
end
def body_extension
- token = lookahead
- case token.symbol
- when T_LPAR
- shift_token
- result = body_extensions
- match(T_RPAR)
- return result
- when T_NUMBER
- return number
- else
- return nstring
- end
+ token = lookahead
+ case token.symbol
+ when T_LPAR
+ shift_token
+ result = body_extensions
+ match(T_RPAR)
+ return result
+ when T_NUMBER
+ return number
+ else
+ return nstring
+ end
end
def section
- str = ""
- token = match(T_LBRA)
- str.concat(token.value)
- token = match(T_ATOM, T_NUMBER, T_RBRA)
- if token.symbol == T_RBRA
- str.concat(token.value)
- return str
- end
- str.concat(token.value)
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- str.concat(token.value)
- token = match(T_LPAR)
- str.concat(token.value)
- while true
- token = lookahead
- case token.symbol
- when T_RPAR
- str.concat(token.value)
- shift_token
- break
- when T_SPACE
- shift_token
- str.concat(token.value)
- end
- str.concat(format_string(astring))
- end
- end
- token = match(T_RBRA)
- str.concat(token.value)
- return str
+ str = ""
+ token = match(T_LBRA)
+ str.concat(token.value)
+ token = match(T_ATOM, T_NUMBER, T_RBRA)
+ if token.symbol == T_RBRA
+ str.concat(token.value)
+ return str
+ end
+ str.concat(token.value)
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ str.concat(token.value)
+ token = match(T_LPAR)
+ str.concat(token.value)
+ while true
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ str.concat(token.value)
+ shift_token
+ break
+ when T_SPACE
+ shift_token
+ str.concat(token.value)
+ end
+ str.concat(format_string(astring))
+ end
+ end
+ token = match(T_RBRA)
+ str.concat(token.value)
+ return str
end
def format_string(str)
- case str
- when ""
- return '""'
- when /[\x80-\xff\r\n]/n
- # literal
- return "{" + str.length.to_s + "}" + CRLF + str
- when /[(){ \x00-\x1f\x7f%*"\\]/n
- # quoted string
- return '"' + str.gsub(/["\\]/n, "\\\\\\&") + '"'
- else
- # atom
- return str
- end
+ case str
+ when ""
+ return '""'
+ when /[\x80-\xff\r\n]/n
+ # literal
+ return "{" + str.length.to_s + "}" + CRLF + str
+ when /[(){ \x00-\x1f\x7f%*"\\]/n
+ # quoted string
+ return '"' + str.gsub(/["\\]/n, "\\\\\\&") + '"'
+ else
+ # atom
+ return str
+ end
end
def uid_data
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return name, number
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return name, number
end
def text_response
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- @lex_state = EXPR_TEXT
- token = match(T_TEXT)
- @lex_state = EXPR_BEG
- return UntaggedResponse.new(name, token.value)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ @lex_state = EXPR_TEXT
+ token = match(T_TEXT)
+ @lex_state = EXPR_BEG
+ return UntaggedResponse.new(name, token.value)
end
def flags_response
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return UntaggedResponse.new(name, flag_list, @str)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return UntaggedResponse.new(name, flag_list, @str)
end
def list_response
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- return UntaggedResponse.new(name, mailbox_list, @str)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ return UntaggedResponse.new(name, mailbox_list, @str)
end
def mailbox_list
- attr = flag_list
- match(T_SPACE)
- token = match(T_QUOTED, T_NIL)
- if token.symbol == T_NIL
- delim = nil
- else
- delim = token.value
- end
- match(T_SPACE)
- name = astring
- return MailboxList.new(attr, delim, name)
+ attr = flag_list
+ match(T_SPACE)
+ token = match(T_QUOTED, T_NIL)
+ if token.symbol == T_NIL
+ delim = nil
+ else
+ delim = token.value
+ end
+ match(T_SPACE)
+ name = astring
+ return MailboxList.new(attr, delim, name)
+ end
+
+ def getquota_response
+ # If quota never established, get back
+ # `NO Quota root does not exist'.
+ # If quota removed, get `()' after the
+ # folder spec with no mention of `STORAGE'.
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ mailbox = astring
+ match(T_SPACE)
+ match(T_LPAR)
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ shift_token
+ data = MailboxQuota.new(mailbox, nil, nil)
+ return UntaggedResponse.new(name, data, @str)
+ when T_ATOM
+ shift_token
+ match(T_SPACE)
+ token = match(T_NUMBER)
+ usage = token.value
+ match(T_SPACE)
+ token = match(T_NUMBER)
+ quota = token.value
+ match(T_RPAR)
+ data = MailboxQuota.new(mailbox, usage, quota)
+ return UntaggedResponse.new(name, data, @str)
+ else
+ parse_error("unexpected token %s", token.symbol)
+ end
+ end
+
+ def getquotaroot_response
+ # Similar to getquota, but only admin can use getquota.
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ mailbox = astring
+ quotaroots = []
+ while true
+ token = lookahead
+ break unless token.symbol == T_SPACE
+ shift_token
+ quotaroots.push(astring)
+ end
+ data = MailboxQuotaRoot.new(mailbox, quotaroots)
+ return UntaggedResponse.new(name, data, @str)
+ end
+
+ def getacl_response
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ mailbox = astring
+ data = []
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ while true
+ token = lookahead
+ case token.symbol
+ when T_CRLF
+ break
+ when T_SPACE
+ shift_token
+ end
+ user = astring
+ match(T_SPACE)
+ rights = astring
+ ##XXX data.push([user, rights])
+ data.push(MailboxACLItem.new(user, rights))
+ end
+ end
+ return UntaggedResponse.new(name, data, @str)
end
def search_response
- token = match(T_ATOM)
- name = token.value.upcase
- token = lookahead
- if token.symbol == T_SPACE
- shift_token
- data = []
- while true
- token = lookahead
- case token.symbol
- when T_CRLF
- break
- when T_SPACE
- shift_token
- end
- data.push(number)
- end
- else
- data = []
- end
- return UntaggedResponse.new(name, data, @str)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ token = lookahead
+ if token.symbol == T_SPACE
+ shift_token
+ data = []
+ while true
+ token = lookahead
+ case token.symbol
+ when T_CRLF
+ break
+ when T_SPACE
+ shift_token
+ end
+ data.push(number)
+ end
+ else
+ data = []
+ end
+ return UntaggedResponse.new(name, data, @str)
+ end
+
+ def thread_response
+ token = match(T_ATOM)
+ name = token.value.upcase
+ token = lookahead
+
+ if token.symbol == T_SPACE
+ threads = []
+
+ while true
+ shift_token
+ token = lookahead
+
+ case token.symbol
+ when T_LPAR
+ threads << thread_branch(token)
+ when T_CRLF
+ break
+ end
+ end
+ else
+ # no member
+ threads = []
+ end
+
+ return UntaggedResponse.new(name, threads, @str)
+ end
+
+ def thread_branch(token)
+ rootmember = nil
+ lastmember = nil
+
+ while true
+ shift_token # ignore first T_LPAR
+ token = lookahead
+
+ case token.symbol
+ when T_NUMBER
+ # new member
+ newmember = ThreadMember.new(number, [])
+ if rootmember.nil?
+ rootmember = newmember
+ else
+ lastmember.children << newmember
+ end
+ lastmember = newmember
+ when T_SPACE
+ # do nothing
+ when T_LPAR
+ if rootmember.nil?
+ # dummy member
+ lastmember = rootmember = ThreadMember.new(nil, [])
+ end
+
+ lastmember.children << thread_branch(token)
+ when T_RPAR
+ break
+ end
+ end
+
+ return rootmember
end
def status_response
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- mailbox = astring
- match(T_SPACE)
- match(T_LPAR)
- attr = {}
- while true
- token = lookahead
- case token.symbol
- when T_RPAR
- shift_token
- break
- when T_SPACE
- shift_token
- end
- token = match(T_ATOM)
- key = token.value.upcase
- match(T_SPACE)
- val = number
- attr[key] = val
- end
- data = StatusData.new(mailbox, attr)
- return UntaggedResponse.new(name, data, @str)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ mailbox = astring
+ match(T_SPACE)
+ match(T_LPAR)
+ attr = {}
+ while true
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ shift_token
+ break
+ when T_SPACE
+ shift_token
+ end
+ token = match(T_ATOM)
+ key = token.value.upcase
+ match(T_SPACE)
+ val = number
+ attr[key] = val
+ end
+ data = StatusData.new(mailbox, attr)
+ return UntaggedResponse.new(name, data, @str)
end
def capability_response
- token = match(T_ATOM)
- name = token.value.upcase
- match(T_SPACE)
- data = []
- while true
- token = lookahead
- case token.symbol
- when T_CRLF
- break
- when T_SPACE
- shift_token
- end
- data.push(atom.upcase)
- end
- return UntaggedResponse.new(name, data, @str)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ match(T_SPACE)
+ data = []
+ while true
+ token = lookahead
+ case token.symbol
+ when T_CRLF
+ break
+ when T_SPACE
+ shift_token
+ end
+ data.push(atom.upcase)
+ end
+ return UntaggedResponse.new(name, data, @str)
end
def resp_text
- @lex_state = EXPR_RTEXT
- token = lookahead
- if token.symbol == T_LBRA
- code = resp_text_code
- else
- code = nil
- end
- token = match(T_TEXT)
- @lex_state = EXPR_BEG
- return ResponseText.new(code, token.value)
+ @lex_state = EXPR_RTEXT
+ token = lookahead
+ if token.symbol == T_LBRA
+ code = resp_text_code
+ else
+ code = nil
+ end
+ token = match(T_TEXT)
+ @lex_state = EXPR_BEG
+ return ResponseText.new(code, token.value)
end
def resp_text_code
- @lex_state = EXPR_BEG
- match(T_LBRA)
- token = match(T_ATOM)
- name = token.value.upcase
- case name
- when /\A(?:ALERT|PARSE|READ-ONLY|READ-WRITE|TRYCREATE)\z/n
- result = ResponseCode.new(name, nil)
- when /\A(?:PERMANENTFLAGS)\z/n
- match(T_SPACE)
- result = ResponseCode.new(name, flag_list)
- when /\A(?:UIDVALIDITY|UIDNEXT|UNSEEN)\z/n
- match(T_SPACE)
- result = ResponseCode.new(name, number)
- else
- match(T_SPACE)
- @lex_state = EXPR_CTEXT
- token = match(T_TEXT)
- @lex_state = EXPR_BEG
- result = ResponseCode.new(name, token.value)
- end
- match(T_RBRA)
- @lex_state = EXPR_RTEXT
- return result
+ @lex_state = EXPR_BEG
+ match(T_LBRA)
+ token = match(T_ATOM)
+ name = token.value.upcase
+ case name
+ when /\A(?:ALERT|PARSE|READ-ONLY|READ-WRITE|TRYCREATE)\z/n
+ result = ResponseCode.new(name, nil)
+ when /\A(?:PERMANENTFLAGS)\z/n
+ match(T_SPACE)
+ result = ResponseCode.new(name, flag_list)
+ when /\A(?:UIDVALIDITY|UIDNEXT|UNSEEN)\z/n
+ match(T_SPACE)
+ result = ResponseCode.new(name, number)
+ else
+ match(T_SPACE)
+ @lex_state = EXPR_CTEXT
+ token = match(T_TEXT)
+ @lex_state = EXPR_BEG
+ result = ResponseCode.new(name, token.value)
+ end
+ match(T_RBRA)
+ @lex_state = EXPR_RTEXT
+ return result
end
def address_list
- token = lookahead
- if token.symbol == T_NIL
- shift_token
- return nil
- else
- result = []
- match(T_LPAR)
- while true
- token = lookahead
- case token.symbol
- when T_RPAR
- shift_token
- break
- when T_SPACE
- shift_token
- end
- result.push(address)
- end
- return result
- end
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ else
+ result = []
+ match(T_LPAR)
+ while true
+ token = lookahead
+ case token.symbol
+ when T_RPAR
+ shift_token
+ break
+ when T_SPACE
+ shift_token
+ end
+ result.push(address)
+ end
+ return result
+ end
end
ADDRESS_REGEXP = /\G\
-(?# 1: NAME )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
-(?# 2: ROUTE )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
-(?# 3: MAILBOX )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
-(?# 4: HOST )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)")\
+(?# 1: NAME )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
+(?# 2: ROUTE )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
+(?# 3: MAILBOX )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)") \
+(?# 4: HOST )(?:NIL|"((?:[^\x80-\xff\x00\r\n"\\]|\\["\\])*)")\
\)/ni
def address
- match(T_LPAR)
- if @str.index(ADDRESS_REGEXP, @pos)
- # address does not include literal.
- @pos = $~.end(0)
- name = $1
- route = $2
- mailbox = $3
- host = $4
- for s in [name, route, mailbox, host]
- if s
- s.gsub!(/\\(["\\])/n, "\\1")
- end
- end
- else
- name = nstring
- match(T_SPACE)
- route = nstring
- match(T_SPACE)
- mailbox = nstring
- match(T_SPACE)
- host = nstring
- match(T_RPAR)
- end
- return Address.new(name, route, mailbox, host)
+ match(T_LPAR)
+ if @str.index(ADDRESS_REGEXP, @pos)
+ # address does not include literal.
+ @pos = $~.end(0)
+ name = $1
+ route = $2
+ mailbox = $3
+ host = $4
+ for s in [name, route, mailbox, host]
+ if s
+ s.gsub!(/\\(["\\])/n, "\\1")
+ end
+ end
+ else
+ name = nstring
+ match(T_SPACE)
+ route = nstring
+ match(T_SPACE)
+ mailbox = nstring
+ match(T_SPACE)
+ host = nstring
+ match(T_RPAR)
+ end
+ return Address.new(name, route, mailbox, host)
end
# def flag_list
-# result = []
-# match(T_LPAR)
-# while true
-# token = lookahead
-# case token.symbol
-# when T_RPAR
-# shift_token
-# break
-# when T_SPACE
-# shift_token
-# end
-# result.push(flag)
-# end
-# return result
+# result = []
+# match(T_LPAR)
+# while true
+# token = lookahead
+# case token.symbol
+# when T_RPAR
+# shift_token
+# break
+# when T_SPACE
+# shift_token
+# end
+# result.push(flag)
+# end
+# return result
# end
# def flag
-# token = lookahead
-# if token.symbol == T_BSLASH
-# shift_token
-# token = lookahead
-# if token.symbol == T_STAR
-# shift_token
-# return token.value.intern
-# else
-# return atom.intern
-# end
-# else
-# return atom
-# end
+# token = lookahead
+# if token.symbol == T_BSLASH
+# shift_token
+# token = lookahead
+# if token.symbol == T_STAR
+# shift_token
+# return token.value.intern
+# else
+# return atom.intern
+# end
+# else
+# return atom
+# end
# end
FLAG_REGEXP = /\
-(?# FLAG )\\([^\x80-\xff(){ \x00-\x1f\x7f%"\\]+)|\
-(?# ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*"\\]+)/n
+(?# FLAG )\\([^\x80-\xff(){ \x00-\x1f\x7f%"\\]+)|\
+(?# ATOM )([^\x80-\xff(){ \x00-\x1f\x7f%*"\\]+)/n
def flag_list
- if @str.index(/\(([^)]*)\)/ni, @pos)
- @pos = $~.end(0)
- return $1.scan(FLAG_REGEXP).collect { |flag, atom|
- atom || flag.capitalize.intern
- }
- else
- parse_error("invalid flag list")
- end
+ if @str.index(/\(([^)]*)\)/ni, @pos)
+ @pos = $~.end(0)
+ return $1.scan(FLAG_REGEXP).collect { |flag, atom|
+ atom || flag.capitalize.intern
+ }
+ else
+ parse_error("invalid flag list")
+ end
end
def nstring
- token = lookahead
- if token.symbol == T_NIL
- shift_token
- return nil
- else
- return string
- end
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ else
+ return string
+ end
end
def astring
- token = lookahead
- if string_token?(token)
- return string
- else
- return atom
- end
+ token = lookahead
+ if string_token?(token)
+ return string
+ else
+ return atom
+ end
end
def string
- token = match(T_QUOTED, T_LITERAL)
- return token.value
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ end
+ token = match(T_QUOTED, T_LITERAL)
+ return token.value
end
- STRING_TOKENS = [T_QUOTED, T_LITERAL]
+ STRING_TOKENS = [T_QUOTED, T_LITERAL, T_NIL]
def string_token?(token)
- return STRING_TOKENS.include?(token.symbol)
+ return STRING_TOKENS.include?(token.symbol)
+ end
+
+ def case_insensitive_string
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ end
+ token = match(T_QUOTED, T_LITERAL)
+ return token.value.upcase
end
def atom
- result = ""
- while true
- token = lookahead
- if atom_token?(token)
- result.concat(token.value)
- shift_token
- else
- if result.empty?
- parse_error("unexpected token %s", token.symbol)
- else
- return result
- end
- end
- end
+ result = ""
+ while true
+ token = lookahead
+ if atom_token?(token)
+ result.concat(token.value)
+ shift_token
+ else
+ if result.empty?
+ parse_error("unexpected token %s", token.symbol)
+ else
+ return result
+ end
+ end
+ end
end
ATOM_TOKENS = [
- T_ATOM,
- T_NUMBER,
- T_NIL,
- T_LBRA,
- T_RBRA,
- T_PLUS
+ T_ATOM,
+ T_NUMBER,
+ T_NIL,
+ T_LBRA,
+ T_RBRA,
+ T_PLUS
]
def atom_token?(token)
- return ATOM_TOKENS.include?(token.symbol)
+ return ATOM_TOKENS.include?(token.symbol)
end
def number
- token = match(T_NUMBER)
- return token.value.to_i
+ token = lookahead
+ if token.symbol == T_NIL
+ shift_token
+ return nil
+ end
+ token = match(T_NUMBER)
+ return token.value.to_i
end
def nil_atom
- match(T_NIL)
- return nil
+ match(T_NIL)
+ return nil
end
def match(*args)
- token = lookahead
- unless args.include?(token.symbol)
- parse_error('unexpected token %s (expected %s)',
- token.symbol.id2name,
- args.collect {|i| i.id2name}.join(" or "))
- end
- shift_token
- return token
+ token = lookahead
+ unless args.include?(token.symbol)
+ parse_error('unexpected token %s (expected %s)',
+ token.symbol.id2name,
+ args.collect {|i| i.id2name}.join(" or "))
+ end
+ shift_token
+ return token
end
def lookahead
- unless @token
- @token = next_token
- end
- return @token
+ unless @token
+ @token = next_token
+ end
+ return @token
end
def shift_token
- @token = nil
+ @token = nil
end
def next_token
- case @lex_state
- when EXPR_BEG
- if @str.index(BEG_REGEXP, @pos)
- @pos = $~.end(0)
- if $1
- return Token.new(T_SPACE, $+)
- elsif $2
- return Token.new(T_NIL, $+)
- elsif $3
- return Token.new(T_NUMBER, $+)
- elsif $4
- return Token.new(T_ATOM, $+)
- elsif $5
- return Token.new(T_QUOTED,
- $+.gsub(/\\(["\\])/n, "\\1"))
- elsif $6
- return Token.new(T_LPAR, $+)
- elsif $7
- return Token.new(T_RPAR, $+)
- elsif $8
- return Token.new(T_BSLASH, $+)
- elsif $9
- return Token.new(T_STAR, $+)
- elsif $10
- return Token.new(T_LBRA, $+)
- elsif $11
- return Token.new(T_RBRA, $+)
- elsif $12
- len = $+.to_i
- val = @str[@pos, len]
- @pos += len
- return Token.new(T_LITERAL, val)
- elsif $13
- return Token.new(T_PLUS, $+)
- elsif $14
- return Token.new(T_PERCENT, $+)
- elsif $15
- return Token.new(T_CRLF, $+)
- elsif $16
- return Token.new(T_EOF, $+)
- else
- parse_error("[Net::IMAP BUG] BEG_REGEXP is invalid")
- end
- else
- @str.index(/\S*/n, @pos)
- parse_error("unknown token - %s", $&.dump)
- end
- when EXPR_DATA
- if @str.index(DATA_REGEXP, @pos)
- @pos = $~.end(0)
- if $1
- return Token.new(T_SPACE, $+)
- elsif $2
- return Token.new(T_NIL, $+)
- elsif $3
- return Token.new(T_NUMBER, $+)
- elsif $4
- return Token.new(T_QUOTED,
- $+.gsub(/\\(["\\])/n, "\\1"))
- elsif $5
- len = $+.to_i
- val = @str[@pos, len]
- @pos += len
- return Token.new(T_LITERAL, val)
- elsif $6
- return Token.new(T_LPAR, $+)
- elsif $7
- return Token.new(T_RPAR, $+)
- else
- parse_error("[Net::IMAP BUG] BEG_REGEXP is invalid")
- end
- else
- @str.index(/\S*/n, @pos)
- parse_error("unknown token - %s", $&.dump)
- end
- when EXPR_TEXT
- if @str.index(TEXT_REGEXP, @pos)
- @pos = $~.end(0)
- if $1
- return Token.new(T_TEXT, $+)
- else
- parse_error("[Net::IMAP BUG] TEXT_REGEXP is invalid")
- end
- else
- @str.index(/\S*/n, @pos)
- parse_error("unknown token - %s", $&.dump)
- end
- when EXPR_RTEXT
- if @str.index(RTEXT_REGEXP, @pos)
- @pos = $~.end(0)
- if $1
- return Token.new(T_LBRA, $+)
- elsif $2
- return Token.new(T_TEXT, $+)
- else
- parse_error("[Net::IMAP BUG] RTEXT_REGEXP is invalid")
- end
- else
- @str.index(/\S*/n, @pos)
- parse_error("unknown token - %s", $&.dump)
- end
- when EXPR_CTEXT
- if @str.index(CTEXT_REGEXP, @pos)
- @pos = $~.end(0)
- if $1
- return Token.new(T_TEXT, $+)
- else
- parse_error("[Net::IMAP BUG] CTEXT_REGEXP is invalid")
- end
- else
- @str.index(/\S*/n, @pos) #/
- parse_error("unknown token - %s", $&.dump)
- end
- else
- parse_error("illegal @lex_state - %s", @lex_state.inspect)
- end
+ case @lex_state
+ when EXPR_BEG
+ if @str.index(BEG_REGEXP, @pos)
+ @pos = $~.end(0)
+ if $1
+ return Token.new(T_SPACE, $+)
+ elsif $2
+ return Token.new(T_NIL, $+)
+ elsif $3
+ return Token.new(T_NUMBER, $+)
+ elsif $4
+ return Token.new(T_ATOM, $+)
+ elsif $5
+ return Token.new(T_QUOTED,
+ $+.gsub(/\\(["\\])/n, "\\1"))
+ elsif $6
+ return Token.new(T_LPAR, $+)
+ elsif $7
+ return Token.new(T_RPAR, $+)
+ elsif $8
+ return Token.new(T_BSLASH, $+)
+ elsif $9
+ return Token.new(T_STAR, $+)
+ elsif $10
+ return Token.new(T_LBRA, $+)
+ elsif $11
+ return Token.new(T_RBRA, $+)
+ elsif $12
+ len = $+.to_i
+ val = @str[@pos, len]
+ @pos += len
+ return Token.new(T_LITERAL, val)
+ elsif $13
+ return Token.new(T_PLUS, $+)
+ elsif $14
+ return Token.new(T_PERCENT, $+)
+ elsif $15
+ return Token.new(T_CRLF, $+)
+ elsif $16
+ return Token.new(T_EOF, $+)
+ else
+ parse_error("[Net::IMAP BUG] BEG_REGEXP is invalid")
+ end
+ else
+ @str.index(/\S*/n, @pos)
+ parse_error("unknown token - %s", $&.dump)
+ end
+ when EXPR_DATA
+ if @str.index(DATA_REGEXP, @pos)
+ @pos = $~.end(0)
+ if $1
+ return Token.new(T_SPACE, $+)
+ elsif $2
+ return Token.new(T_NIL, $+)
+ elsif $3
+ return Token.new(T_NUMBER, $+)
+ elsif $4
+ return Token.new(T_QUOTED,
+ $+.gsub(/\\(["\\])/n, "\\1"))
+ elsif $5
+ len = $+.to_i
+ val = @str[@pos, len]
+ @pos += len
+ return Token.new(T_LITERAL, val)
+ elsif $6
+ return Token.new(T_LPAR, $+)
+ elsif $7
+ return Token.new(T_RPAR, $+)
+ else
+ parse_error("[Net::IMAP BUG] BEG_REGEXP is invalid")
+ end
+ else
+ @str.index(/\S*/n, @pos)
+ parse_error("unknown token - %s", $&.dump)
+ end
+ when EXPR_TEXT
+ if @str.index(TEXT_REGEXP, @pos)
+ @pos = $~.end(0)
+ if $1
+ return Token.new(T_TEXT, $+)
+ else
+ parse_error("[Net::IMAP BUG] TEXT_REGEXP is invalid")
+ end
+ else
+ @str.index(/\S*/n, @pos)
+ parse_error("unknown token - %s", $&.dump)
+ end
+ when EXPR_RTEXT
+ if @str.index(RTEXT_REGEXP, @pos)
+ @pos = $~.end(0)
+ if $1
+ return Token.new(T_LBRA, $+)
+ elsif $2
+ return Token.new(T_TEXT, $+)
+ else
+ parse_error("[Net::IMAP BUG] RTEXT_REGEXP is invalid")
+ end
+ else
+ @str.index(/\S*/n, @pos)
+ parse_error("unknown token - %s", $&.dump)
+ end
+ when EXPR_CTEXT
+ if @str.index(CTEXT_REGEXP, @pos)
+ @pos = $~.end(0)
+ if $1
+ return Token.new(T_TEXT, $+)
+ else
+ parse_error("[Net::IMAP BUG] CTEXT_REGEXP is invalid")
+ end
+ else
+ @str.index(/\S*/n, @pos) #/
+ parse_error("unknown token - %s", $&.dump)
+ end
+ else
+ parse_error("illegal @lex_state - %s", @lex_state.inspect)
+ end
end
def parse_error(fmt, *args)
- if IMAP.debug
- $stderr.printf("@str: %s\n", @str.dump)
- $stderr.printf("@pos: %d\n", @pos)
- $stderr.printf("@lex_state: %s\n", @lex_state)
- if @token.symbol
- $stderr.printf("@token.symbol: %s\n", @token.symbol)
- $stderr.printf("@token.value: %s\n", @token.value.inspect)
- end
- end
- raise ResponseParseError, format(fmt, *args)
+ if IMAP.debug
+ $stderr.printf("@str: %s\n", @str.dump)
+ $stderr.printf("@pos: %d\n", @pos)
+ $stderr.printf("@lex_state: %s\n", @lex_state)
+ if @token.symbol
+ $stderr.printf("@token.symbol: %s\n", @token.symbol)
+ $stderr.printf("@token.value: %s\n", @token.value.inspect)
+ end
+ end
+ raise ResponseParseError, format(fmt, *args)
end
end
+ # Authenticator for the "LOGIN" authentication type. See
+ # #authenticate().
class LoginAuthenticator
def process(data)
- case @state
- when STATE_USER
- @state = STATE_PASSWORD
- return @user
- when STATE_PASSWORD
- return @password
- end
+ case @state
+ when STATE_USER
+ @state = STATE_PASSWORD
+ return @user
+ when STATE_PASSWORD
+ return @password
+ end
end
private
@@ -2301,71 +3123,230 @@ module Net
STATE_PASSWORD = :PASSWORD
def initialize(user, password)
- @user = user
- @password = password
- @state = STATE_USER
+ @user = user
+ @password = password
+ @state = STATE_USER
end
end
add_authenticator "LOGIN", LoginAuthenticator
+ # Authenticator for the "CRAM-MD5" authentication type. See
+ # #authenticate().
class CramMD5Authenticator
def process(challenge)
- digest = hmac_md5(challenge, @password)
- return @user + " " + digest
+ digest = hmac_md5(challenge, @password)
+ return @user + " " + digest
end
private
def initialize(user, password)
- @user = user
- @password = password
+ @user = user
+ @password = password
end
def hmac_md5(text, key)
- if key.length > 64
- md5 = MD5.new(key)
- key = md5.digest
- end
+ if key.length > 64
+ key = Digest::MD5.digest(key)
+ end
- k_ipad = key + "\0" * (64 - key.length)
- k_opad = key + "\0" * (64 - key.length)
- for i in 0..63
- k_ipad[i] ^= 0x36
- k_opad[i] ^= 0x5c
- end
+ k_ipad = key + "\0" * (64 - key.length)
+ k_opad = key + "\0" * (64 - key.length)
+ for i in 0..63
+ k_ipad[i] ^= 0x36
+ k_opad[i] ^= 0x5c
+ end
- md5 = MD5.new
- md5.update(k_ipad)
- md5.update(text)
- digest = md5.digest
+ digest = Digest::MD5.digest(k_ipad + text)
- md5 = MD5.new
- md5.update(k_opad)
- md5.update(digest)
- return md5.hexdigest
+ return Digest::MD5.hexdigest(k_opad + digest)
end
end
add_authenticator "CRAM-MD5", CramMD5Authenticator
+ # Superclass of IMAP errors.
class Error < StandardError
end
+ # Error raised when data is in the incorrect format.
class DataFormatError < Error
end
+ # Error raised when a response from the server is non-parseable.
class ResponseParseError < Error
end
+ # Superclass of all errors used to encapsulate "fail" responses
+ # from the server.
class ResponseError < Error
end
+ # Error raised upon a "NO" response from the server, indicating
+ # that the client command could not be completed successfully.
class NoResponseError < ResponseError
end
+ # Error raised upon a "BAD" response from the server, indicating
+ # that the client command violated the IMAP protocol, or an internal
+ # server failure has occurred.
class BadResponseError < ResponseError
end
+ # Error raised upon a "BYE" response from the server, indicating
+ # that the client is not being allowed to login, or has been timed
+ # out due to inactivity.
class ByeResponseError < ResponseError
end
end
end
+
+if __FILE__ == $0
+ # :enddoc:
+ require "getoptlong"
+
+ $stdout.sync = true
+ $port = nil
+ $user = ENV["USER"] || ENV["LOGNAME"]
+ $auth = "login"
+ $ssl = false
+
+ def usage
+ $stderr.print <<EOF
+usage: #{$0} [options] <host>
+
+ --help print this message
+ --port=PORT specifies port
+ --user=USER specifies user
+ --auth=AUTH specifies auth type
+ --ssl use ssl
+EOF
+ end
+
+ def get_password
+ print "password: "
+ system("stty", "-echo")
+ begin
+ return gets.chop
+ ensure
+ system("stty", "echo")
+ print "\n"
+ end
+ end
+
+ def get_command
+ printf("%s@%s> ", $user, $host)
+ if line = gets
+ return line.strip.split(/\s+/)
+ else
+ return nil
+ end
+ end
+
+ parser = GetoptLong.new
+ parser.set_options(['--debug', GetoptLong::NO_ARGUMENT],
+ ['--help', GetoptLong::NO_ARGUMENT],
+ ['--port', GetoptLong::REQUIRED_ARGUMENT],
+ ['--user', GetoptLong::REQUIRED_ARGUMENT],
+ ['--auth', GetoptLong::REQUIRED_ARGUMENT],
+ ['--ssl', GetoptLong::NO_ARGUMENT])
+ begin
+ parser.each_option do |name, arg|
+ case name
+ when "--port"
+ $port = arg
+ when "--user"
+ $user = arg
+ when "--auth"
+ $auth = arg
+ when "--ssl"
+ $ssl = true
+ when "--debug"
+ Net::IMAP.debug = true
+ when "--help"
+ usage
+ exit(1)
+ end
+ end
+ rescue
+ usage
+ exit(1)
+ end
+
+ $host = ARGV.shift
+ unless $host
+ usage
+ exit(1)
+ end
+ $port ||= $ssl ? 993 : 143
+
+ imap = Net::IMAP.new($host, $port, $ssl)
+ begin
+ password = get_password
+ imap.authenticate($auth, $user, password)
+ while true
+ cmd, *args = get_command
+ break unless cmd
+ begin
+ case cmd
+ when "list"
+ for mbox in imap.list("", args[0] || "*")
+ if mbox.attr.include?(Net::IMAP::NOSELECT)
+ prefix = "!"
+ elsif mbox.attr.include?(Net::IMAP::MARKED)
+ prefix = "*"
+ else
+ prefix = " "
+ end
+ print prefix, mbox.name, "\n"
+ end
+ when "select"
+ imap.select(args[0] || "inbox")
+ print "ok\n"
+ when "close"
+ imap.close
+ print "ok\n"
+ when "summary"
+ unless messages = imap.responses["EXISTS"][-1]
+ puts "not selected"
+ next
+ end
+ if messages > 0
+ for data in imap.fetch(1..-1, ["ENVELOPE"])
+ print data.seqno, ": ", data.attr["ENVELOPE"].subject, "\n"
+ end
+ else
+ puts "no message"
+ end
+ when "fetch"
+ if args[0]
+ data = imap.fetch(args[0].to_i, ["RFC822.HEADER", "RFC822.TEXT"])[0]
+ puts data.attr["RFC822.HEADER"]
+ puts data.attr["RFC822.TEXT"]
+ else
+ puts "missing argument"
+ end
+ when "logout", "exit", "quit"
+ break
+ when "help", "?"
+ print <<EOF
+list [pattern] list mailboxes
+select [mailbox] select mailbox
+close close mailbox
+summary display summary
+fetch [msgno] display message
+logout logout
+help, ? display help message
+EOF
+ else
+ print "unknown command: ", cmd, "\n"
+ end
+ rescue Net::IMAP::Error
+ puts $!
+ end
+ end
+ ensure
+ imap.logout
+ imap.disconnect
+ end
+end
+
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 8f3f978e8c..a4f50b002c 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -1,457 +1,879 @@
-=begin
+# = net/pop.rb
+#
+# Copyright (c) 1999-2003 Yukihiro Matsumoto.
+#
+# Copyright (c) 1999-2003 Minero Aoki.
+#
+# Written & maintained by Minero Aoki <aamine@loveruby.net>.
+#
+# Documented by William Webber and Minero Aoki.
+#
+# This program is free software. You can re-distribute and/or
+# modify this program under the same terms as Ruby itself,
+# Ruby Distribute License or GNU General Public License.
+#
+# NOTE: You can find Japanese version of this document in
+# the doc/net directory of the standard ruby interpreter package.
+#
+# $Id$
+#
+# See Net::POP3 for documentation.
+#
-= net/pop.rb version 1.1.34
-
-written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
-This program is free software.
-You can distribute/modify this program under
-the terms of the Ruby Distribute License.
-
-Japanese version of this document is in "net" full package.
-You can get it from RAA
-(Ruby Application Archive: http://www.ruby-lang.org/en/raa.html).
-
-
-== Net::POP3
-
-=== Super Class
-
-Net::Protocol
-
-=== Class Methods
-
-: new( address = 'localhost', port = 110 )
- creates a new Net::POP3 object.
- This method does not open TCP connection yet.
-
-: start( address = 'localhost', port = 110, account, password )
-: start( address = 'localhost', port = 110, account, password ) {|pop| .... }
- equals to Net::POP3.new( address, port ).start( account, password )
+require 'net/protocol'
+require 'digest/md5'
- # typical usage
- Net::POP3.start( addr, port, acnt, pass ) do |pop|
- pop.each_mail do |m|
- any_file.write m.pop
- m.delete
- end
- end
+module Net
-: foreach( address = 'localhost', port = 110, account, password ) {|mail| .... }
- starts protocol and iterate for each POPMail object.
- This method equals to
+ # Non-authentication POP3 protocol error
+ # (reply code "-ERR", except authentication).
+ class POPError < ProtocolError; end
+
+ # POP3 authentication error.
+ class POPAuthenticationError < ProtoAuthError; end
+
+ # Unexpected response from the server.
+ class POPBadResponse < POPError; end
+
+ #
+ # = Net::POP3
+ #
+ # == What is This Library?
+ #
+ # This library provides functionality for retrieving
+ # email via POP3, the Post Office Protocol version 3. For details
+ # of POP3, see [RFC1939] (http://www.ietf.org/rfc/rfc1939.txt).
+ #
+ # == Examples
+ #
+ # === Retrieving Messages
+ #
+ # This example retrieves messages from the server and deletes them
+ # on the server.
+ #
+ # Messages are written to files named 'inbox/1', 'inbox/2', ....
+ # Replace 'pop.example.com' with your POP3 server address, and
+ # 'YourAccount' and 'YourPassword' with the appropriate account
+ # details.
+ #
+ # require 'net/pop'
+ #
+ # pop = Net::POP3.new('pop.example.com')
+ # pop.start('YourAccount', 'YourPassword') # (1)
+ # if pop.mails.empty?
+ # puts 'No mail.'
+ # else
+ # i = 0
+ # pop.each_mail do |m| # or "pop.mails.each ..." # (2)
+ # File.open("inbox/#{i}", 'w') do |f|
+ # f.write m.pop
+ # end
+ # m.delete
+ # i += 1
+ # end
+ # puts "#{pop.mails.size} mails popped."
+ # end
+ # pop.finish # (3)
+ #
+ # 1. Call Net::POP3#start and start POP session.
+ # 2. Access messages by using POP3#each_mail and/or POP3#mails.
+ # 3. Close POP session by calling POP3#finish or use the block form of #start.
+ #
+ # === Shortened Code
+ #
+ # The example above is very verbose. You can shorten the code by using
+ # some utility methods. First, the block form of Net::POP3.start can
+ # be used instead of POP3.new, POP3#start and POP3#finish.
+ #
+ # require 'net/pop'
+ #
+ # Net::POP3.start('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword') do |pop|
+ # if pop.mails.empty?
+ # puts 'No mail.'
+ # else
+ # i = 0
+ # pop.each_mail do |m| # or "pop.mails.each ..."
+ # File.open("inbox/#{i}", 'w') do |f|
+ # f.write m.pop
+ # end
+ # m.delete
+ # i += 1
+ # end
+ # puts "#{pop.mails.size} mails popped."
+ # end
+ # end
+ #
+ # POP3#delete_all is an alternative for #each_mail and #delete.
+ #
+ # require 'net/pop'
+ #
+ # Net::POP3.start('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword') do |pop|
+ # if pop.mails.empty?
+ # puts 'No mail.'
+ # else
+ # i = 1
+ # pop.delete_all do |m|
+ # File.open("inbox/#{i}", 'w') do |f|
+ # f.write m.pop
+ # end
+ # i += 1
+ # end
+ # end
+ # end
+ #
+ # And here is an even shorter example.
+ #
+ # require 'net/pop'
+ #
+ # i = 0
+ # Net::POP3.delete_all('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword') do |m|
+ # File.open("inbox/#{i}", 'w') do |f|
+ # f.write m.pop
+ # end
+ # i += 1
+ # end
+ #
+ # === Memory Space Issues
+ #
+ # All the examples above get each message as one big string.
+ # This example avoids this.
+ #
+ # require 'net/pop'
+ #
+ # i = 1
+ # Net::POP3.delete_all('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword') do |m|
+ # File.open("inbox/#{i}", 'w') do |f|
+ # m.pop do |chunk| # get a message little by little.
+ # f.write chunk
+ # end
+ # i += 1
+ # end
+ # end
+ #
+ # === Using APOP
+ #
+ # The net/pop library supports APOP authentication.
+ # To use APOP, use the Net::APOP class instead of the Net::POP3 class.
+ # You can use the utility method, Net::POP3.APOP(). For example:
+ #
+ # require 'net/pop'
+ #
+ # # Use APOP authentication if $isapop == true
+ # pop = Net::POP3.APOP($is_apop).new('apop.example.com', 110)
+ # pop.start(YourAccount', 'YourPassword') do |pop|
+ # # Rest of the code is the same.
+ # end
+ #
+ # === Fetch Only Selected Mail Using 'UIDL' POP Command
+ #
+ # If your POP server provides UIDL functionality,
+ # you can grab only selected mails from the POP server.
+ # e.g.
+ #
+ # def need_pop?( id )
+ # # determine if we need pop this mail...
+ # end
+ #
+ # Net::POP3.start('pop.example.com', 110,
+ # 'Your account', 'Your password') do |pop|
+ # pop.mails.select { |m| need_pop?(m.unique_id) }.each do |m|
+ # do_something(m.pop)
+ # end
+ # end
+ #
+ # The POPMail#unique_id() method returns the unique-id of the message as a
+ # String. Normally the unique-id is a hash of the message.
+ #
+ class POP3 < Protocol
- Net::POP3.start( address, port, account, password ) do |pop|
- pop.each do |m|
- yield m
- end
+ Revision = %q$Revision$.split[1]
+
+ #
+ # Class Parameters
+ #
+
+ # The default port for POP3 connections, port 110
+ def POP3.default_port
+ 110
+ end
+
+ def POP3.socket_type #:nodoc: obsolete
+ Net::InternetMessageIO
+ end
+
+ #
+ # Utilities
+ #
+
+ # Returns the APOP class if +isapop+ is true; otherwise, returns
+ # the POP class. For example:
+ #
+ # # Example 1
+ # pop = Net::POP3::APOP($is_apop).new(addr, port)
+ #
+ # # Example 2
+ # Net::POP3::APOP($is_apop).start(addr, port) do |pop|
+ # ....
+ # end
+ #
+ def POP3.APOP( isapop )
+ isapop ? APOP : POP3
+ end
+
+ # Starts a POP3 session and iterates over each POPMail object,
+ # yielding it to the +block+.
+ # This method is equivalent to:
+ #
+ # Net::POP3.start(address, port, account, password) do |pop|
+ # pop.each_mail do |m|
+ # yield m
+ # end
+ # end
+ #
+ # This method raises a POPAuthenticationError if authentication fails.
+ #
+ # === Example
+ #
+ # Net::POP3.foreach('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword') do |m|
+ # file.write m.pop
+ # m.delete if $DELETE
+ # end
+ #
+ def POP3.foreach( address, port = nil,
+ account = nil, password = nil,
+ isapop = false, &block ) # :yields: message
+ start(address, port, account, password, isapop) {|pop|
+ pop.each_mail(&block)
+ }
end
- .
-
- # typical usage
- Net::POP3.foreach( addr, nil, acnt, pass ) do |m|
- m.pop file
- m.delete
+ # Starts a POP3 session and deletes all messages on the server.
+ # If a block is given, each POPMail object is yielded to it before
+ # being deleted.
+ #
+ # This method raises a POPAuthenticationError if authentication fails.
+ #
+ # === Example
+ #
+ # Net::POP3.delete_all('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword') do |m|
+ # file.write m.pop
+ # end
+ #
+ def POP3.delete_all( address, port = nil,
+ account = nil, password = nil,
+ isapop = false, &block )
+ start(address, port, account, password, isapop) {|pop|
+ pop.delete_all(&block)
+ }
end
-: delete_all( address = 'localhost', port = 110, account, password )
-: delete_all( address = 'localhost', port = 110, account, password ) {|mail| .... }
- starts POP3 session and delete all mails.
- If block is given, iterates for each POPMail object before delete.
-
- # typical usage
- Net::POP3.delete_all( addr, nil, acnt, pass ) do |m|
- m.pop file
+ # Opens a POP3 session, attempts authentication, and quits.
+ #
+ # This method raises POPAuthenticationError if authentication fails.
+ #
+ # === Example: normal POP3
+ #
+ # Net::POP3.auth_only('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword')
+ #
+ # === Example: APOP
+ #
+ # Net::POP3.auth_only('pop.example.com', 110,
+ # 'YourAccount', 'YourPassword', true)
+ #
+ def POP3.auth_only( address, port = nil,
+ account = nil, password = nil,
+ isapop = false )
+ new(address, port, isapop).auth_only account, password
+ end
+
+ # Starts a pop3 session, attempts authentication, and quits.
+ # This method must not be called while POP3 session is opened.
+ # This method raises POPAuthenticationError if authentication fails.
+ def auth_only( account, password )
+ raise IOError, 'opening previously opened POP session' if started?
+ start(account, password) {
+ ;
+ }
end
-
-=== Methods
-
-: start( account, password )
-: start( account, password ) {|pop| .... }
- starts POP3 session.
-
- When called with block, gives a POP3 object to block and
- closes the session after block call finish.
-
-: mails
- an array of ((URL:#POPMail)).
- This array is renewed when session started.
-: each_mail {|popmail| .... }
-: each {|popmail| .... }
- is equals to "pop3.mails.each"
+ #
+ # Session management
+ #
+
+ # Creates a new POP3 object and open the connection. Equivalent to
+ #
+ # Net::POP3.new(address, port, isapop).start(account, password)
+ #
+ # If +block+ is provided, yields the newly-opened POP3 object to it,
+ # and automatically closes it at the end of the session.
+ #
+ # === Example
+ #
+ # Net::POP3.start(addr, port, account, password) do |pop|
+ # pop.each_mail do |m|
+ # file.write m.pop
+ # m.delete
+ # end
+ # end
+ #
+ def POP3.start( address, port = nil,
+ account = nil, password = nil,
+ isapop = false, &block ) # :yield: pop
+ new(address, port, isapop).start(account, password, &block)
+ end
+
+ # Creates a new POP3 object.
+ #
+ # +address+ is the hostname or ip address of your POP3 server.
+ #
+ # The optional +port+ is the port to connect to; it defaults to 110.
+ #
+ # The optional +isapop+ specifies whether this connection is going
+ # to use APOP authentication; it defaults to +false+.
+ #
+ # This method does *not* open the TCP connection.
+ def initialize( addr, port = nil, isapop = false )
+ @address = addr
+ @port = port || self.class.default_port
+ @apop = isapop
+
+ @command = nil
+ @socket = nil
+ @started = false
+ @open_timeout = 30
+ @read_timeout = 60
+ @debug_output = nil
-: delete_all
-: delete_all {|popmail| .... }
- deletes all mails.
- If called with block, gives mails to the block before deleting.
-
- # example 1
- # pop and delete all mails
- n = 1
- pop.delete_all do |m|
- File.open("inbox/#{n}") {|f| f.write m.pop }
- n += 1
+ @mails = nil
+ @n_mails = nil
+ @n_bytes = nil
end
- # example 2
- # clear all mails on server
- Net::POP3.start( addr, port, acc, pass ) do |pop|
- pop.delete_all
+ # Does this instance use APOP authentication?
+ def apop?
+ @apop
end
-: reset
- reset the session. All "deleted mark" are removed.
-
-
-== Net::APOP
-
-This class defines no new methods.
-Only difference from POP3 is using APOP authentification.
-
-=== Super Class
-
-Net::POP3
-
-
-== Net::POPMail
-
-A class of mail which exists on POP server.
-
-=== Super Class
-
-Object
-
-
-=== Methods
-
-: pop( dest = '' )
- This method fetches a mail and write to 'dest' using '<<' method.
-
- # usage example
-
- mailarr = []
- POP3.start( 'localhost', 110 ) do |pop|
- pop.each_mail do |popm|
- mailarr.push popm.pop # all() returns 'dest' (this time, string)
- # or, you can also
- # popm.pop( $stdout ) # write mail to stdout
-
- # maybe you also want to delete mail after popping
- popm.delete
- end
- end
-
-: pop {|str| .... }
- If pop() is called with block, it gives the block part strings of a mail.
-
- # usage example
-
- POP3.start( 'localhost', 110 ) do |pop3|
- pop3.each_mail do |m|
- m.pop do |str|
- # do anything
+ # Provide human-readable stringification of class state.
+ def inspect
+ "#<#{self.class} #{@address}:#{@port} open=#{@started}>"
+ end
+
+ # *WARNING*: This method causes a serious security hole.
+ # Use this method only for debugging.
+ #
+ # Set an output stream for debugging.
+ #
+ # === Example
+ #
+ # pop = Net::POP.new(addr, port)
+ # pop.set_debug_output $stderr
+ # pop.start(account, passwd) do |pop|
+ # ....
+ # end
+ #
+ def set_debug_output( arg )
+ @debug_output = arg
+ end
+
+ # The address to connect to.
+ attr_reader :address
+
+ # The port number to connect to.
+ attr_reader :port
+
+ # Seconds to wait until a connection is opened.
+ # If the POP3 object cannot open a connection within this time,
+ # it raises a TimeoutError exception.
+ attr_accessor :open_timeout
+
+ # Seconds to wait until reading one block (by one read(1) call).
+ # If the POP3 object cannot complete a read() within this time,
+ # it raises a TimeoutError exception.
+ attr_reader :read_timeout
+
+ # Set the read timeout.
+ def read_timeout=( sec )
+ @command.socket.read_timeout = sec if @command
+ @read_timeout = sec
+ end
+
+ # +true+ if the POP3 session has started.
+ def started?
+ @started
+ end
+
+ alias active? started? #:nodoc: obsolete
+
+ # Starts a POP3 session.
+ #
+ # When called with block, gives a POP3 object to the block and
+ # closes the session after block call finishes.
+ #
+ # This method raises a POPAuthenticationError if authentication fails.
+ def start( account, password ) # :yield: pop
+ raise IOError, 'POP session already started' if @started
+
+ if block_given?
+ begin
+ do_start account, password
+ return yield(self)
+ ensure
+ do_finish
end
+ else
+ do_start account, password
+ return self
end
end
-: header
- This method fetches only mail header.
-
-: top( lines )
- This method fetches mail header and 'lines' lines body.
-
-: delete
-: delete!
- This method deletes mail.
-
-: size
- size of mail(bytes)
-
-: deleted?
- true if mail was deleted
-
-=end
-
-require 'net/protocol'
-require 'md5'
-
-
-module Net
-
- class POP3 < Protocol
-
- protocol_param :port, '110'
- protocol_param :command_type, '::Net::NetPrivate::POP3Command'
- protocol_param :apop_command_type, '::Net::NetPrivate::APOPCommand'
-
- protocol_param :mail_type, '::Net::POPMail'
-
- class << self
-
- def foreach( address = nil, port = nil,
- account = nil, password = nil, &block )
- start( address, port, account, password ) do |pop|
- pop.each_mail( &block )
- end
+ def do_start( account, password )
+ @socket = self.class.socket_type.open(@address, @port,
+ @open_timeout, @read_timeout, @debug_output)
+ on_connect
+ @command = POP3Command.new(@socket)
+ if apop?
+ @command.apop account, password
+ else
+ @command.auth account, password
end
+ @started = true
+ ensure
+ do_finish if not @started
+ end
+ private :do_start
- def delete_all( address = nil, port = nil,
- account = nil, password = nil, &block )
- start( address, port, account, password ) do |pop|
- pop.delete_all( &block )
- end
- end
-
+ def on_connect
end
+ private :on_connect
+ # Finishes a POP3 session and closes TCP connection.
+ def finish
+ raise IOError, 'POP session not yet started' unless started?
+ do_finish
+ end
- def initialize( addr = nil, port = nil, apop = false )
- super addr, port
+ def do_finish
@mails = nil
- @apop = false
- end
+ @command.quit if @command
+ ensure
+ @started = false
+ @command = nil
+ @socket.close if @socket and not @socket.closed?
+ @socket = nil
+ end
+ private :do_finish
+
+ def command
+ raise IOError, 'POP session not opened yet' \
+ if not @socket or @socket.closed?
+ @command
+ end
+ private :command
+
+ #
+ # POP protocol wrapper
+ #
+
+ # Returns the number of messages on the POP server.
+ def n_mails
+ return @n_mails if @n_mails
+ @n_mails, @n_bytes = command().stat
+ @n_mails
+ end
+
+ # Returns the total size in bytes of all the messages on the POP server.
+ def n_bytes
+ return @n_bytes if @n_bytes
+ @n_mails, @n_bytes = command().stat
+ @n_bytes
+ end
+
+ # Returns an array of Net::POPMail objects, representing all the
+ # messages on the server. This array is renewed when the session
+ # restarts; otherwise, it is fetched from the server the first time
+ # this method is called (directly or indirectly) and cached.
+ #
+ # This method raises a POPError if an error occurs.
+ def mails
+ return @mails.dup if @mails
+ if n_mails() == 0
+ # some popd raises error for LIST on the empty mailbox.
+ @mails = []
+ return []
+ end
- attr :mails
+ @mails = command().list.map {|num, size|
+ POPMail.new(num, size, self, command())
+ }
+ @mails.dup
+ end
- def each_mail( &block )
- io_check
- @mails.each( &block )
+ # Yields each message to the passed-in block in turn.
+ # Equivalent to:
+ #
+ # pop3.mails.each do |popmail|
+ # ....
+ # end
+ #
+ # This method raises a POPError if an error occurs.
+ def each_mail( &block ) # :yield: message
+ mails().each(&block)
end
alias each each_mail
- def delete_all
- @mails.each do |m|
+ # Deletes all messages on the server.
+ #
+ # If called with a block, yields each message in turn before deleting it.
+ #
+ # === Example
+ #
+ # n = 1
+ # pop.delete_all do |m|
+ # File.open("inbox/#{n}") do |f|
+ # f.write m.pop
+ # end
+ # n += 1
+ # end
+ #
+ # This method raises a POPError if an error occurs.
+ #
+ def delete_all # :yield: message
+ mails().each do |m|
yield m if block_given?
m.delete unless m.deleted?
end
end
+ # Resets the session. This clears all "deleted" marks from messages.
+ #
+ # This method raises a POPError if an error occurs.
def reset
- io_check
- @command.rset
- @mails.each do |m|
- m.instance_eval { @deleted = false }
+ command().rset
+ mails().each do |m|
+ m.instance_eval {
+ @deleted = false
+ }
end
end
-
- private
-
- def conn_command( sock )
- @command =
- (@apop ? type.apop_command_type : type.command_type).new(sock)
- end
-
- def do_start( acnt, pwd )
- @command.auth( acnt, pwd )
-
- @mails = []
- mtype = type.mail_type
- @command.list.each_with_index do |size,idx|
- if size then
- @mails.push mtype.new( idx, size, @command )
- end
+ def set_all_uids #:nodoc: internal use only (called from POPMail#uidl)
+ command().uidl.each do |num, uid|
+ @mails.find {|m| m.number == num }.uid = uid
end
- @mails.freeze
end
- def io_check
- if not @socket or @socket.closed? then
- raise IOError, 'pop session is not opened yet'
- end
- end
+ end # class POP3
- end
-
- POP = POP3
+ # class aliases
+ POP = POP3
POPSession = POP3
POP3Session = POP3
-
+ #
+ # This class is equivalent to POP3, except that it uses APOP authentication.
+ #
class APOP < POP3
- protocol_param :command_type, 'Net::NetPrivate::APOPCommand'
+ # Always returns true.
+ def apop?
+ true
+ end
end
+ # class aliases
APOPSession = APOP
-
+ #
+ # This class represents a message which exists on the POP server.
+ # Instances of this class are created by the POP3 class; they should
+ # not be directly created by the user.
+ #
class POPMail
- def initialize( n, s, cmd )
- @num = n
- @size = s
+ def initialize( num, len, pop, cmd ) #:nodoc:
+ @number = num
+ @length = len
+ @pop = pop
@command = cmd
-
@deleted = false
+ @uid = nil
end
- attr :size
+ # The sequence number of the message on the server.
+ attr_reader :number
- def inspect
- "#<#{type} #{@num}#{@deleted ? ' deleted' : ''}>"
- end
+ # The length of the message in octets.
+ attr_reader :length
+ alias size length
- def all( dest = '' )
- if block_given? then
- dest = NetPrivate::ReadAdapter.new( Proc.new )
+ # Provide human-readable stringification of class state.
+ def inspect
+ "#<#{self.class} #{@number}#{@deleted ? ' deleted' : ''}>"
+ end
+
+ #
+ # This method fetches the message. If called with a block, the
+ # message is yielded to the block one chunk at a time. If called
+ # without a block, the message is returned as a String. The optional
+ # +dest+ argument will be prepended to the returned String; this
+ # argument is essentially obsolete.
+ #
+ # === Example without block
+ #
+ # POP3.start('pop.example.com', 110,
+ # 'YourAccount, 'YourPassword') do |pop|
+ # n = 1
+ # pop.mails.each do |popmail|
+ # File.open("inbox/#{n}", 'w') do |f|
+ # f.write popmail.pop
+ # end
+ # popmail.delete
+ # n += 1
+ # end
+ # end
+ #
+ # === Example with block
+ #
+ # POP3.start('pop.example.com', 110,
+ # 'YourAccount, 'YourPassword') do |pop|
+ # n = 1
+ # pop.mails.each do |popmail|
+ # File.open("inbox/#{n}", 'w') do |f|
+ # popmail.pop do |chunk| ####
+ # f.write chunk
+ # end
+ # end
+ # n += 1
+ # end
+ # end
+ #
+ # This method raises a POPError if an error occurs.
+ #
+ def pop( dest = '', &block ) # :yield: message_chunk
+ if block_given?
+ @command.retr(@number, &block)
+ nil
+ else
+ @command.retr(@number) do |chunk|
+ dest << chunk
+ end
+ dest
end
- @command.retr( @num, dest )
end
- alias pop all
- alias mail all
+ alias all pop #:nodoc: obsolete
+ alias mail pop #:nodoc: obsolete
+
+ # Fetches the message header and +lines+ lines of body.
+ #
+ # The optional +dest+ argument is obsolete.
+ #
+ # This method raises a POPError if an error occurs.
def top( lines, dest = '' )
- @command.top( @num, lines, dest )
+ @command.top(@number, lines) do |chunk|
+ dest << chunk
+ end
+ dest
end
+ # Fetches the message header.
+ #
+ # The optional +dest+ argument is obsolete.
+ #
+ # This method raises a POPError if an error occurs.
def header( dest = '' )
- top 0, dest
- end
-
+ top(0, dest)
+ end
+
+ # Marks a message for deletion on the server. Deletion does not
+ # actually occur until the end of the session; deletion may be
+ # cancelled for _all_ marked messages by calling POP3#reset().
+ #
+ # This method raises a POPError if an error occurs.
+ #
+ # === Example
+ #
+ # POP3.start('pop.example.com', 110,
+ # 'YourAccount, 'YourPassword') do |pop|
+ # n = 1
+ # pop.mails.each do |popmail|
+ # File.open("inbox/#{n}", 'w') do |f|
+ # f.write popmail.pop
+ # end
+ # popmail.delete ####
+ # n += 1
+ # end
+ # end
+ #
def delete
- @command.dele( @num )
+ @command.dele @number
@deleted = true
end
- alias delete! delete
+ alias delete! delete #:nodoc: obsolete
+ # True if the mail has been deleted.
def deleted?
@deleted
end
- def uidl
- @command.uidl @num
+ # Returns the unique-id of the message.
+ # Normally the unique-id is a hash string of the message.
+ #
+ # This method raises a POPError if an error occurs.
+ def unique_id
+ return @uid if @uid
+ @pop.set_all_uids
+ @uid
end
- end
-
+ alias uidl unique_id
+ def uid=( uid ) #:nodoc: internal use only (used from POP3#set_all_uids)
+ @uid = uid
+ end
- module NetPrivate
+ end # class POPMail
- class POP3Command < Command
+ class POP3Command #:nodoc: internal use only
def initialize( sock )
- super
- critical {
- check_reply SuccessCode
- }
+ @socket = sock
+ @error_occured = false
+ res = check_response(critical { recv_response() })
+ @apop_stamp = res.slice(/<.+>/)
end
- def auth( acnt, pass )
- critical {
- @socket.writeline 'USER ' + acnt
- check_reply_auth
+ def inspect
+ "#<#{self.class} socket=#{@socket}>"
+ end
- @socket.writeline 'PASS ' + pass
- check_reply_auth
- }
+ def auth( account, password )
+ check_response_auth(critical {
+ check_response_auth(get_response('USER %s', account))
+ get_response('PASS %s', password)
+ })
+ end
+
+ def apop( account, password )
+ raise POPAuthenticationError, 'not APOP server; cannot login' \
+ unless @apop_stamp
+ check_response_auth(critical {
+ get_response('APOP %s %s',
+ account,
+ Digest::MD5.hexdigest(@apop_stamp + password))
+ })
end
def list
- arr = []
critical {
getok 'LIST'
- @socket.read_pendlist do |line|
- num, siz = line.split( / +/o )
- arr[ num.to_i ] = siz.to_i
+ list = []
+ @socket.each_list_item do |line|
+ m = /\A(\d+)[ \t]+(\d+)/.match(line) or
+ raise POPBadResponse, "bad response: #{line}"
+ list.push [m[1].to_i, m[2].to_i]
end
+ return list
}
- arr
end
- def rset
- critical {
- getok 'RSET'
- }
+ def stat
+ res = check_response(critical { get_response('STAT') })
+ m = /\A\+OK\s+(\d+)\s+(\d+)/.match(res) or
+ raise POPBadResponse, "wrong response format: #{res}"
+ [m[1].to_i, m[2].to_i]
end
+ def rset
+ check_response(critical { get_response 'RSET' })
+ end
- def top( num, lines = 0, dest = '' )
+ def top( num, lines = 0, &block )
critical {
- getok sprintf( 'TOP %d %d', num, lines )
- @socket.read_pendstr( dest )
+ getok('TOP %d %d', num, lines)
+ @socket.each_message_chunk(&block)
}
end
- def retr( num, dest = '', &block )
+ def retr( num, &block )
critical {
- getok sprintf( 'RETR %d', num )
- @socket.read_pendstr( dest, &block )
+ getok('RETR %d', num)
+ @socket.each_message_chunk(&block)
}
end
def dele( num )
- critical {
- getok sprintf( 'DELE %d', num )
- }
+ check_response(critical { get_response('DELE %d', num) })
end
- def uidl( num )
- critical {
- getok( sprintf 'UIDL %d', num ).msg.split(' ')[1]
- }
+ def uidl( num = nil )
+ if num
+ res = check_response(critical { get_response('UIDL %d', num) })
+ return res.split(/ /)[1]
+ else
+ critical {
+ getok('UIDL')
+ table = {}
+ @socket.each_list_item do |line|
+ num, uid = line.split
+ table[num.to_i] = uid
+ end
+ return table
+ }
+ end
end
def quit
- critical {
- getok 'QUIT'
- }
+ check_response(critical { get_response('QUIT') })
end
-
private
- def check_reply_auth
- begin
- cod = check_reply( SuccessCode )
- rescue ProtocolError
- raise ProtoAuthError, 'Fail to POP authentication'
- end
-
- return cod
+ def getok( fmt, *fargs )
+ @socket.writeline sprintf(fmt, *fargs)
+ check_response(recv_response())
end
- def get_reply
- str = @socket.readline
-
- if /\A\+/ === str then
- return Response.new( SuccessCode, str[0,3], str[3, str.size - 3].strip )
- else
- return Response.new( ErrorCode, str[0,4], str[4, str.size - 4].strip )
- end
+ def get_response( fmt, *fargs )
+ @socket.writeline sprintf(fmt, *fargs)
+ recv_response()
end
- end
-
-
- class APOPCommand < POP3Command
-
- def initialize( sock )
- rep = super( sock )
-
- m = /<.+>/.match( rep.msg )
- unless m then
- raise ProtoAuthError, "This is not APOP server: can't login"
- end
- @stamp = m[0]
+ def recv_response
+ @socket.readline
end
- def auth( account, pass )
- critical {
- @socket.writeline sprintf( 'APOP %s %s',
- account, MD5.new(@stamp + pass).hexdigest )
- check_reply_auth
- }
+ def check_response( res )
+ raise POPError, res unless /\A\+OK/i === res
+ res
end
- end
+ def check_response_auth( res )
+ raise POPAuthenticationError, res unless /\A\+OK/i === res
+ res
+ end
+ def critical
+ return '+OK dummy ok response' if @error_occured
+ begin
+ return yield()
+ rescue Exception
+ @error_occured = true
+ raise
+ end
+ end
- end # module Net::NetPrivate
+ end # class POP3Command
end # module Net
+
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 343721add3..ac6bce1058 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -1,279 +1,39 @@
-=begin
-
-= net/protocol.rb version 1.1.34
-
-written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
-This program is free software.
-You can distribute/modify this program under
-the terms of the Ruby Distribute License.
-
-Japanese version of this document is in "net" full package.
-You can get it from RAA
-(Ruby Application Archive: http://www.ruby-lang.org/en/raa.html).
-
-
-== Net::Protocol
-
-the abstract class for Internet protocol
-
-=== Super Class
-
-Object
-
-=== Class Methods
-
-: new( address = 'localhost', port = nil )
- This method Creates a new protocol object.
-
-: start( address = 'localhost', port = nil, *protoargs )
-: start( address = 'localhost', port = nil, *protoargs ) {|proto| .... }
- This method creates a new Protocol object and opens a session.
- equals to Net::Protocol.new( address, port ).start( *protoargs )
-
-=== Methods
-
-: address
- the address of connecting server (FQDN).
-
-: port
- connecting port number
-
-: start( *args )
-: start( *args ) {|proto| .... }
- This method starts protocol. If protocol was already started,
- do nothing and returns false.
-
- '*args' are specified in subclasses.
-
- When is called with block, gives Protocol object to block and
- close session when block finished.
-
-: finish
- This method ends protocol. If you call this method before protocol starts,
- it only return false without doing anything.
-
-: active?
- true if session have been started
-
-=end
+#
+# = net/protocol.rb
+#
+#--
+# Copyright (c) 1999-2004 Yukihiro Matsumoto
+# Copyright (c) 1999-2004 Minero Aoki
+#
+# written and maintained by Minero Aoki <aamine@loveruby.net>
+#
+# This program is free software. You can re-distribute and/or
+# modify this program under the same terms as Ruby itself,
+# Ruby Distribute License or GNU General Public License.
+#
+# $Id$
+#++
+#
+# WARNING: This file is going to remove.
+# Do not rely on the implementation written in this file.
+#
require 'socket'
require 'timeout'
+module Net # :nodoc:
-module Net
-
- module NetPrivate
- end
-
- def self.net_private( &block )
- ::Net::NetPrivate.module_eval( &block )
- end
-
-
- class Protocol
-
- Version = '1.1.34'
-
-
- class << self
-
- def start( address = 'localhost', port = nil, *args )
- instance = new( address, port )
-
- if block_given? then
- instance.start( *args ) { yield instance }
- else
- instance.start( *args )
- instance
- end
- end
-
- private
-
- def protocol_param( name, val )
- module_eval %-
- def self.#{name.id2name}
- #{val}
- end
- -
- end
-
- end
-
-
- #
- # sub-class requirements
- #
- # protocol_param command_type
- # protocol_param port
- #
- # private method do_start (optional)
- # private method do_finish (optional)
- #
-
- protocol_param :port, 'nil'
- protocol_param :command_type, 'nil'
- protocol_param :socket_type, '::Net::NetPrivate::Socket'
-
-
- def initialize( addr = nil, port = nil )
- @address = addr || 'localhost'
- @port = port || type.port
-
- @command = nil
- @socket = nil
-
- @active = false
-
- @open_timeout = nil
- @read_timeout = nil
-
- @dout = nil
- end
-
- attr_reader :address
- attr_reader :port
-
- attr_reader :command
- attr_reader :socket
-
- attr_accessor :open_timeout
- attr_accessor :read_timeout
-
- def active?
- @active
- end
-
- def set_debug_output( arg ) # un-documented
- @dout = arg
- end
-
- alias set_pipe set_debug_output
-
- def inspect
- "#<#{type} #{address}:#{port} open=#{active?}>"
- end
-
- #
- # open session
- #
-
- def start( *args )
- return false if active?
-
- if block_given? then
- begin
- _start args
- yield self
- ensure
- finish
- end
- else
- _start args
- end
- end
-
- private
-
- def _start( args )
- connect
- do_start( *args )
- @active = true
- end
-
- def connect
- conn_socket @address, @port
- conn_command @socket
- on_connect
- end
-
- def re_connect
- @socket.reopen @open_timeout
- on_connect
- end
-
- def conn_socket( addr, port )
- @socket = type.socket_type.open(
- addr, port, @open_timeout, @read_timeout, @dout )
- end
-
- def conn_command( sock )
- @command = type.command_type.new( sock )
- end
-
- def on_connect
- end
-
- def do_start
- end
-
- #
- # close session
- #
-
- public
-
- def finish
- return false unless active?
-
- do_finish if @command and not @command.critical?
- disconnect
- @active = false
- true
- end
-
+ class Protocol #:nodoc: internal use only
private
-
- def do_finish
- @command.quit
- end
-
- def disconnect
- @command = nil
- if @socket and not @socket.closed? then
- @socket.close
- end
- @socket = nil
- on_disconnect
- end
-
- def on_disconnect
- end
-
- end
-
- Session = Protocol
-
-
- net_private {
-
- class Response
-
- def initialize( ctype, cno, msg )
- @code_type = ctype
- @code = cno
- @message = msg
- super()
- end
-
- attr_reader :code_type, :code, :message
- alias msg message
-
- def inspect
- "#<#{type} #{code}>"
- end
-
- def error!( data = nil )
- raise code_type.error_type.new( code + ' ' + Net.quote(msg), data )
+ def Protocol.protocol_param( name, val )
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def #{name}
+ #{val}
+ end
+ End
end
-
end
- }
-
-
class ProtocolError < StandardError; end
class ProtoSyntaxError < ProtocolError; end
class ProtoFatalError < ProtocolError; end
@@ -284,592 +44,405 @@ module Net
class ProtoRetriableError < ProtocolError; end
ProtocRetryError = ProtoRetriableError
- class ProtocolError
-
- def initialize( msg, data = nil )
- super msg
- @data = data
- end
-
- attr :data
-
- def inspect
- "#<#{type}>"
- end
-
- end
-
-
- class Code
-
- def initialize( paren, err )
- @parents = paren
- @err = err
-
- @parents.push self
- end
-
- attr_reader :parents
-
- def inspect
- "#<#{type}>"
- end
-
- def error_type
- @err
- end
-
- def ===( response )
- response.code_type.parents.reverse_each {|i| return true if i == self }
- false
- end
-
- def mkchild( err = nil )
- type.new( @parents + [self], err || @err )
- end
-
- end
-
- ReplyCode = Code.new( [], ProtoUnknownError )
- InformationCode = ReplyCode.mkchild( ProtoUnknownError )
- SuccessCode = ReplyCode.mkchild( ProtoUnknownError )
- ContinueCode = ReplyCode.mkchild( ProtoUnknownError )
- ErrorCode = ReplyCode.mkchild( ProtocolError )
- SyntaxErrorCode = ErrorCode.mkchild( ProtoSyntaxError )
- FatalErrorCode = ErrorCode.mkchild( ProtoFatalError )
- ServerErrorCode = ErrorCode.mkchild( ProtoServerError )
- AuthErrorCode = ErrorCode.mkchild( ProtoAuthError )
- RetriableCode = ReplyCode.mkchild( ProtoRetriableError )
- UnknownCode = ReplyCode.mkchild( ProtoUnknownError )
-
-
-
- net_private {
-
- class WriteAdapter
-
- def initialize( sock, mid )
- @sock = sock
- @mid = mid
- end
-
- def inspect
- "#<#{type}>"
- end
-
- def write( str )
- @sock.__send__ @mid, str
- end
-
- def <<( str )
- @sock.__send__ @mid, str
- self
- end
-
- end
-
- class ReadAdapter
-
- def initialize( block )
- @block = block
- end
-
- def inspect
- "#<#{type}>"
- end
-
- def <<( str )
- callblock( str, &@block ) if @block
- end
-
- private
-
- def callblock( str )
- begin
- user_break = true
- yield str
- user_break = false
- rescue Exception
- user_break = false
- raise
- ensure
- if user_break then
- @block = nil
- return # stop break
- end
- end
- end
-
- end
-
-
-
- class Command
-
- def initialize( sock )
- @socket = sock
- @last_reply = nil
- @critical = false
- end
-
- attr_accessor :socket
- attr_reader :last_reply
-
- def inspect
- "#<#{type}>"
- end
- # abstract quit
-
-
- private
-
- # abstract get_reply()
-
- def check_reply( *oks )
- @last_reply = get_reply
- reply_must( @last_reply, *oks )
- end
+ class InternetMessageIO #:nodoc: internal use only
- def reply_must( rep, *oks )
- oks.each do |i|
- if i === rep then
- return rep
- end
- end
- rep.error!
- end
-
- def getok( line, expect = SuccessCode )
- @socket.writeline line
- check_reply expect
- end
-
-
- #
- # error handle
- #
-
- public
-
- def critical?
- @critical
+ class << self
+ alias open new
end
- def error_ok
- @critical = false
+ def initialize( addr, port,
+ open_timeout = nil, read_timeout = nil,
+ debug_output = nil )
+ @address = addr
+ @port = port
+ @read_timeout = read_timeout
+ @debug_output = debug_output
+ @socket = nil
+ @rbuf = nil # read buffer
+ @wbuf = nil # write buffer
+ connect open_timeout
+ LOG 'opened'
end
+ attr_reader :address
+ attr_reader :port
- private
-
- def critical
- @critical = true
- ret = yield
- @critical = false
- ret
- end
-
- def begin_critical
- ret = @critical
- @critical = true
- not ret
- end
-
- def end_critical
- @critical = false
+ def ip_address
+ return '' unless @socket
+ @socket.addr[3]
end
- end
-
-
- class Socket
-
- def initialize( addr, port, otime = nil, rtime = nil, dout = nil )
- @addr = addr
- @port = port
-
- @read_timeout = rtime
-
- @debugout = dout
-
- @socket = nil
- @sending = ''
- @buffer = ''
+ attr_accessor :read_timeout
- connect otime
- D 'opened'
- end
+ attr_reader :socket
- def connect( otime )
- D "opening connection to #{@addr}..."
- timeout( otime ) {
- @socket = TCPsocket.new( @addr, @port )
+ def connect( open_timeout )
+ LOG "opening connection to #{@address}..."
+ timeout(open_timeout) {
+ @socket = TCPsocket.new(@address, @port)
}
+ @rbuf = ''
end
private :connect
- attr :pipe, true
-
- class << self
- alias open new
- end
-
- def inspect
- "#<#{type} #{closed? ? 'closed' : 'opened'}>"
- end
-
- def reopen( otime = nil )
- D 'reopening...'
- close
- connect otime
- D 'reopened'
- end
-
- attr :socket, true
-
def close
- if @socket then
+ if @socket
@socket.close
- D 'closed'
+ LOG 'closed'
else
- D 'close call for already closed socket'
+ LOG 'close call for already closed socket'
end
@socket = nil
- @buffer = ''
+ @rbuf = ''
end
- def closed?
- not @socket
+ def reopen( open_timeout = nil )
+ LOG 'reopening...'
+ close
+ connect open_timeout
+ LOG 'reopened'
end
- def address
- @addr.dup
+ def closed?
+ not @socket
end
- alias addr address
-
- attr_reader :port
-
- def ip_address
- @socket or return ''
- @socket.addr[3]
+ def inspect
+ "#<#{self.class} #{closed?() ? 'closed' : 'opened'}>"
end
- alias ipaddr ip_address
-
- attr_reader :sending
-
-
- #
- # read
- #
+ ###
+ ### READ
+ ###
public
- CRLF = "\r\n"
-
- def read( len, dest = '', ignerr = false )
- D_off "reading #{len} bytes..."
-
- rsize = 0
+ def read( len, dest = '', ignore_eof = false )
+ LOG "reading #{len} bytes..."
+ # LOG_off() # experimental: [ruby-list:38800]
+ read_bytes = 0
begin
- while rsize + @buffer.size < len do
- rsize += rbuf_moveto( dest, @buffer.size )
+ while read_bytes + @rbuf.size < len
+ read_bytes += rbuf_moveto(dest, @rbuf.size)
rbuf_fill
end
- rbuf_moveto dest, len - rsize
+ rbuf_moveto dest, len - read_bytes
rescue EOFError
- raise unless igneof
+ raise unless ignore_eof
end
-
- D_on "read #{len} bytes"
+ # LOG_on()
+ LOG "read #{read_bytes} bytes"
dest
end
def read_all( dest = '' )
- D_off 'reading all...'
-
- rsize = 0
+ LOG 'reading all...'
+ # LOG_off() # experimental: [ruby-list:38800]
+ read_bytes = 0
begin
- while true do
- rsize += rbuf_moveto( dest, @buffer.size )
+ while true
+ read_bytes += rbuf_moveto(dest, @rbuf.size)
rbuf_fill
end
rescue EOFError
;
end
-
- D_on "read #{rsize} bytes"
+ # LOG_on()
+ LOG "read #{read_bytes} bytes"
dest
end
- def readuntil( target, igneof = false )
+ def readuntil( terminator, ignore_eof = false )
dest = ''
begin
- while true do
- idx = @buffer.index( target )
- break if idx
+ until idx = @rbuf.index(terminator)
rbuf_fill
end
- rbuf_moveto dest, idx + target.size
+ rbuf_moveto dest, idx + terminator.size
rescue EOFError
- raise unless igneof
- rbuf_moveto dest, @buffer.size
+ raise unless ignore_eof
+ rbuf_moveto dest, @rbuf.size
end
dest
end
def readline
- ret = readuntil( "\n" )
- ret.chop!
- ret
+ readuntil("\n").chop
end
- def read_pendstr( dest )
- D_off 'reading text...'
-
- rsize = 0
- while (str = readuntil("\r\n")) != ".\r\n" do
- rsize += str.size
- str.gsub!( /\A\./, '' )
- dest << str
+ def each_message_chunk
+ LOG 'reading message...'
+ LOG_off()
+ read_bytes = 0
+ while (line = readuntil("\r\n")) != ".\r\n"
+ read_bytes += line.size
+ yield line.sub(/\A\./, '')
end
-
- D_on "read #{rsize} bytes"
- dest
+ LOG_on()
+ LOG "read message (#{read_bytes} bytes)"
end
-
- # private use only (can not handle 'break')
- def read_pendlist
- D_off 'reading list...'
-
- str = nil
- i = 0
- while (str = readuntil("\r\n")) != ".\r\n" do
- i += 1
- str.chop!
- yield str
+
+ # *library private* (cannot handle 'break')
+ def each_list_item
+ while (str = readuntil("\r\n")) != ".\r\n"
+ yield str.chop
end
-
- D_on "read #{i} items"
end
-
private
-
- READ_SIZE = 1024 * 4
-
def rbuf_fill
- unless IO.select [@socket], nil, nil, @read_timeout then
- on_read_timeout
- end
- @buffer << @socket.sysread( READ_SIZE )
- end
-
- def on_read_timeout
- raise TimeoutError, "socket read timeout (#{@read_timeout} sec)"
+ timeout(@read_timeout) {
+ @rbuf << @socket.sysread(1024)
+ }
end
def rbuf_moveto( dest, len )
- bsi = @buffer.size
- s = @buffer[ 0, len ]
- dest << s
- @buffer = @buffer[ len, bsi - len ]
-
- @debugout << %<read "#{Net.quote s}"\n> if @debugout
+ dest << (s = @rbuf.slice!(0, len))
+ @debug_output << %Q[-> #{s.dump}\n] if @debug_output
len
end
-
- #
- # write interfece
- #
+ ###
+ ### WRITE
+ ###
public
def write( str )
writing {
- do_write str
+ write0 str
}
end
def writeline( str )
writing {
- do_write str + "\r\n"
+ write0 str + "\r\n"
}
end
- def write_bin( src, block )
- writing {
- if block then
- block.call ::Net::NetPrivate::WriteAdapter.new( self, :do_write )
- else
- src.each do |bin|
- do_write bin
- end
- end
+ def write_message( src )
+ LOG "writing message from #{src.class}"
+ LOG_off()
+ len = using_each_crlf_line {
+ write_message_0 src
}
+ LOG_on()
+ LOG "wrote #{len} bytes"
+ len
end
- def write_pendstr( src, block )
- D_off "writing text from #{src.type}"
-
- wsize = use_each_crlf_line {
- if block then
- block.call ::Net::NetPrivate::WriteAdapter.new( self, :wpend_in )
- else
- wpend_in src
+ def write_message_by_block( &block )
+ LOG 'writing message from block'
+ LOG_off()
+ len = using_each_crlf_line {
+ begin
+ block.call(WriteAdapter.new(self, :write_message_0))
+ rescue LocalJumpError
+ # allow `break' from writer block
end
}
-
- D_on "wrote #{wsize} bytes text"
- wsize
+ LOG_on()
+ LOG "wrote #{len} bytes"
+ len
end
-
private
+ def writing
+ @written_bytes = 0
+ @debug_output << '<- ' if @debug_output
+ yield
+ @socket.flush
+ @debug_output << "\n" if @debug_output
+ bytes = @written_bytes
+ @written_bytes = nil
+ bytes
+ end
- def wpend_in( src )
- line = nil
- pre = @writtensize
- each_crlf_line( src ) do |line|
- do_write '.' if line[0] == ?.
- do_write line
- end
+ def write0( str )
+ @debug_output << str.dump if @debug_output
+ len = @socket.write(str)
+ @written_bytes += len
+ len
+ end
- @writtensize - pre
+ #
+ # Reads string from src calling :each, and write to @socket.
+ # Escapes '.' on the each line head.
+ #
+ def write_message_0( src )
+ prev = @written_bytes
+ each_crlf_line(src) do |line|
+ if line[0] == ?.
+ then write0 '.' + line
+ else write0 line
+ end
+ end
+ @written_bytes - prev
end
- def use_each_crlf_line
+ #
+ # setup @wbuf for each_crlf_line.
+ #
+ def using_each_crlf_line
writing {
- @wbuf = ''
-
- yield
-
- if not @wbuf.empty? then # un-terminated last line
- if @wbuf[-1] == ?\r then
- @wbuf.chop!
+ @wbuf = ''
+ yield
+ if not @wbuf.empty? # unterminated last line
+ if @wbuf[-1] == ?\r
+ @wbuf.chop!
+ end
+ @wbuf.concat "\r\n"
+ write0 @wbuf
+ elsif @written_bytes == 0 # empty src
+ write0 "\r\n"
end
- @wbuf.concat "\r\n"
- do_write @wbuf
- elsif @writtensize == 0 then # empty src
- do_write "\r\n"
- end
- do_write ".\r\n"
-
- @wbuf = nil
+ write0 ".\r\n"
+ @wbuf = nil
}
end
+ #
+ # extract a CR-LF-terminating-line from @wbuf and yield it.
+ #
def each_crlf_line( src )
- str = m = beg = nil
-
- adding( src ) do
+ adding(src) do
beg = 0
buf = @wbuf
- while buf.index( /\n|\r\n|\r/, beg ) do
+ while buf.index(/\n|\r\n|\r/, beg)
m = Regexp.last_match
- if m.begin(0) == buf.size - 1 and buf[-1] == ?\r then
+ if (m.begin(0) == buf.length - 1) and buf[-1] == ?\r
# "...\r" : can follow "\n..."
break
end
- str = buf[ beg ... m.begin(0) ]
+ str = buf[beg ... m.begin(0)]
str.concat "\r\n"
yield str
beg = m.end(0)
end
- @wbuf = buf[ beg ... buf.size ]
+ @wbuf = buf[beg ... buf.length]
end
end
+ #
+ # Reads strings from SRC and add to @wbuf, then yield.
+ #
def adding( src )
- i = nil
-
case src
- when String
- 0.step( src.size - 1, 2048 ) do |i|
+ when String # for speeding up.
+ 0.step(src.size - 1, 2048) do |i|
@wbuf << src[i,2048]
yield
end
- when File
- while true do
- i = src.read( 2048 )
- break unless i
- i[0,0] = @wbuf
- @wbuf = i
+ when File # for speeding up.
+ while s = src.read(2048)
+ s[0,0] = @wbuf
+ @wbuf = s
yield
end
- else
- src.each do |i|
- @wbuf << i
- if @wbuf.size > 2048 then
- yield
- end
+ else # generic reader
+ src.each do |s|
+ @wbuf << s
+ yield if @wbuf.size > 2048
end
yield unless @wbuf.empty?
end
end
+ ###
+ ### DEBUG
+ ###
- def writing
- @writtensize = 0
- @sending = ''
+ private
- yield
+ def LOG_off
+ @save_debug_out = @debug_output
+ @debug_output = nil
+ end
- if @debugout then
- @debugout << 'write "'
- @debugout << @sending
- @debugout << "\"\n"
- end
- @socket.flush
- @writtensize
+ def LOG_on
+ @debug_output = @save_debug_out
end
- def do_write( arg )
- if @debugout or @sending.size < 128 then
- @sending << Net.quote( arg )
- else
- @sending << '...' unless @sending[-1] == ?.
- end
+ def LOG( msg )
+ return unless @debug_output
+ @debug_output << msg
+ @debug_output << "\n"
+ end
+
+ end
+
+
+ #
+ # The writer adapter class
+ #
+ class WriteAdapter
- s = @socket.write( arg )
- @writtensize += s
- s
+ def initialize( sock, mid )
+ @socket = sock
+ @method_id = mid
end
+ def inspect
+ "#<#{self.class} socket=#{@socket.inspect}>"
+ end
- def D_off( msg )
- D msg
- @savedo, @debugout = @debugout, nil
+ def write( str )
+ @socket.__send__(@method_id, str)
end
- def D_on( msg )
- @debugout = @savedo
- D msg
+ alias print write
+
+ def <<( str )
+ write str
+ self
end
- def D( msg )
- @debugout or return
- @debugout << msg
- @debugout << "\n"
+ def puts( str = '' )
+ write str.sub(/\n?/, "\n")
end
+ def printf( *args )
+ write sprintf(*args)
+ end
+
end
- }
+
+ class ReadAdapter #:nodoc: internal use only
+
+ def initialize( block )
+ @block = block
+ end
+
+ def inspect
+ "#<#{self.class}>"
+ end
+
+ def <<( str )
+ call_block(str, &@block) if @block
+ end
+
+ private
+
+ #
+ # This method is needed because @block must be called by yield,
+ # not Proc#call. You can see difference when using `break' in
+ # the block.
+ #
+ def call_block( str )
+ yield str
+ end
+
+ end
- def Net.quote( str )
- str = str.gsub( "\n", '\\n' )
- str.gsub!( "\r", '\\r' )
- str.gsub!( "\t", '\\t' )
- str
+ module NetPrivate #:nodoc: obsolete
+ Socket = ::Net::InternetMessageIO
end
end # module Net
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index befc1adf03..db54b998c9 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -1,304 +1,697 @@
-=begin
+# = net/smtp.rb
+#
+# Copyright (c) 1999-2003 Yukihiro Matsumoto.
+#
+# Copyright (c) 1999-2003 Minero Aoki.
+#
+# Written & maintained by Minero Aoki <aamine@loveruby.net>.
+#
+# Documented by William Webber and Minero Aoki.
+#
+# This program is free software. You can re-distribute and/or
+# modify this program under the same terms as Ruby itself,
+# Ruby Distribute License or GNU General Public License.
+#
+# NOTE: You can find Japanese version of this document in
+# the doc/net directory of the standard ruby interpreter package.
+#
+# $Id$
+#
+# See Net::SMTP for documentation.
+#
-= net/smtp.rb version 1.1.34
-
-written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
-
-This program is free software.
-You can distribute/modify this program under
-the terms of the Ruby Distribute License.
-
-Japanese version of this document is in "net" full package.
-You can get it from RAA
-(Ruby Application Archive: http://www.ruby-lang.org/en/raa.html).
-
-
-== Net::SMTP
-
-=== Super Class
-
-Net::Protocol
-
-=== Class Methods
-
-: new( address = 'localhost', port = 25 )
- creates a new Net::SMTP object.
-
-: start( address = 'localhost', port = 25, *protoargs )
-: start( address = 'localhost', port = 25, *protoargs ) {|smtp| .... }
- is equal to Net::SMTP.new( address, port ).start( *protoargs )
-
-=== Methods
+require 'net/protocol'
+require 'digest/md5'
-: start( helo_domain = Socket.gethostname, account = nil, password = nil, authtype = nil )
-: start( helo_domain = Socket.gethostname, account = nil, password = nil, authtype = nil ) {|smtp| .... }
- opens TCP connection and starts SMTP session.
- If protocol had been started, do nothing and return false.
+module Net
- When this methods is called with block, give a SMTP object to block and
- close session after block call finished.
+ # Module mixed in to all SMTP error classes
+ module SMTPError
+ # This *class* is module for some reason.
+ # In ruby 1.9.x, this module becomes a class.
+ end
- If account and password are given, is trying to get authentication
- by using AUTH command. "authtype" is :plain (symbol) or :cram_md5.
+ # Represents an SMTP authentication error.
+ class SMTPAuthenticationError < ProtoAuthError
+ include SMTPError
+ end
-: send_mail( mailsrc, from_addr, *to_addrs )
-: sendmail( mailsrc, from_addr, *to_addrs )
- This method sends 'mailsrc' as mail. SMTP read strings
- from 'mailsrc' by calling 'each' iterator, and convert them
- into "\r\n" terminated string when write.
+ # Represents SMTP error code 420 or 450, a temporary error.
+ class SMTPServerBusy < ProtoServerError
+ include SMTPError
+ end
- from_addr must be String.
- to_addrs must be a String(s) or an Array of String.
+ # Represents an SMTP command syntax error (error code 500)
+ class SMTPSyntaxError < ProtoSyntaxError
+ include SMTPError
+ end
- Exceptions which SMTP raises are:
- * Net::ProtoSyntaxError: syntax error (errno.500)
- * Net::ProtoFatalError: fatal error (errno.550)
- * Net::ProtoUnknownError: unknown error
- * Net::ProtoServerBusy: temporary error (errno.420/450)
+ # Represents a fatal SMTP error (error code 5xx, except for 500)
+ class SMTPFatalError < ProtoFatalError
+ include SMTPError
+ end
- # usage example
+ # Unexpected reply code returned from server.
+ class SMTPUnknownError < ProtoUnknownError
+ include SMTPError
+ end
- Net::SMTP.start( 'localhost', 25 ) do |smtp|
- smtp.send_mail mail_string, 'from-addr@foo.or.jp', 'to-addr@bar.or.jp'
+ #
+ # = Net::SMTP
+ #
+ # == What is This Library?
+ #
+ # This library provides functionality to send internet
+ # mail via SMTP, the Simple Mail Transfer Protocol. For details of
+ # SMTP itself, see [RFC2821] (http://www.ietf.org/rfc/rfc2821.txt).
+ #
+ # == What is This Library NOT?
+ #
+ # This library does NOT provide functions to compose internet mails.
+ # You must create them by yourself. If you want better mail support,
+ # try RubyMail or TMail. You can get both libraries from RAA.
+ # (http://www.ruby-lang.org/en/raa.html)
+ #
+ # FYI: the official documentation on internet mail is: [RFC2822] (http://www.ietf.org/rfc/rfc2822.txt).
+ #
+ # == Examples
+ #
+ # === Sending Messages
+ #
+ # You must open a connection to an SMTP server before sending messages.
+ # The first argument is the address of your SMTP server, and the second
+ # argument is the port number. Using SMTP.start with a block is the simplest
+ # way to do this. This way, the SMTP connection is closed automatically
+ # after the block is executed.
+ #
+ # require 'net/smtp'
+ # Net::SMTP.start('your.smtp.server', 25) do |smtp|
+ # # Use the SMTP object smtp only in this block.
+ # end
+ #
+ # Replace 'your.smtp.server' with your SMTP server. Normally
+ # your system manager or internet provider supplies a server
+ # for you.
+ #
+ # Then you can send messages.
+ #
+ # msgstr = <<END_OF_MESSAGE
+ # From: Your Name <your@mail.address>
+ # To: Destination Address <someone@example.com>
+ # Subject: test message
+ # Date: Sat, 23 Jun 2001 16:26:43 +0900
+ # Message-Id: <unique.message.id.string@example.com>
+ #
+ # This is a test message.
+ # END_OF_MESSAGE
+ #
+ # require 'net/smtp'
+ # Net::SMTP.start('your.smtp.server', 25) do |smtp|
+ # smtp.send_message msgstr,
+ # 'your@mail.address',
+ # 'his_addess@example.com'
+ # end
+ #
+ # === Closing the Session
+ #
+ # You MUST close the SMTP session after sending messages, by calling
+ # the #finish method:
+ #
+ # # using SMTP#finish
+ # smtp = Net::SMTP.start('your.smtp.server', 25)
+ # smtp.send_message msgstr, 'from@address', 'to@address'
+ # smtp.finish
+ #
+ # You can also use the block form of SMTP.start/SMTP#start. This closes
+ # the SMTP session automatically:
+ #
+ # # using block form of SMTP.start
+ # Net::SMTP.start('your.smtp.server', 25) do |smtp|
+ # smtp.send_message msgstr, 'from@address', 'to@address'
+ # end
+ #
+ # I strongly recommend this scheme. This form is simpler and more robust.
+ #
+ # === HELO domain
+ #
+ # In almost all situations, you must provide a third argument
+ # to SMTP.start/SMTP#start. This is the domain name which you are on
+ # (the host to send mail from). It is called the "HELO domain".
+ # The SMTP server will judge whether it should send or reject
+ # the SMTP session by inspecting the HELO domain.
+ #
+ # Net::SMTP.start('your.smtp.server', 25,
+ # 'mail.from.domain') { |smtp| ... }
+ #
+ # === SMTP Authentication
+ #
+ # The Net::SMTP class supports three authentication schemes;
+ # PLAIN, LOGIN and CRAM MD5. (SMTP Authentication: [RFC2554])
+ # To use SMTP authentication, pass extra arguments to
+ # SMTP.start/SMTP#start.
+ #
+ # # PLAIN
+ # Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
+ # 'Your Account', 'Your Password', :plain)
+ # # LOGIN
+ # Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
+ # 'Your Account', 'Your Password', :login)
+ #
+ # # CRAM MD5
+ # Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
+ # 'Your Account', 'Your Password', :cram_md5)
+ #
+ class SMTP
+
+ Revision = %q$Revision$.split[1]
+
+ # The default SMTP port, port 25.
+ def SMTP.default_port
+ 25
end
-: ready( from_addr, to_addrs ) {|adapter| .... }
- This method stands by the SMTP object for sending mail.
- "adapter" object accepts only "write" method.
-
- # usage example
-
- Net::SMTP.start( 'localhost', 25 ) do |smtp|
- smtp.ready( from, to ) do |adapter|
- adapter.write str1
- adapter.write str2
- adapter.write str3
- end
+ #
+ # Creates a new Net::SMTP object.
+ #
+ # +address+ is the hostname or ip address of your SMTP
+ # server. +port+ is the port to connect to; it defaults to
+ # port 25.
+ #
+ # This method does not open the TCP connection. You can use
+ # SMTP.start instead of SMTP.new if you want to do everything
+ # at once. Otherwise, follow SMTP.new with SMTP#start.
+ #
+ def initialize( address, port = nil )
+ @address = address
+ @port = (port || SMTP.default_port)
+ @esmtp = true
+ @socket = nil
+ @started = false
+ @open_timeout = 30
+ @read_timeout = 60
+ @error_occured = false
+ @debug_output = nil
end
-: finish
- finishes SMTP session.
- If SMTP session had not started, do nothing and return false.
-
-=end
+ # Provide human-readable stringification of class state.
+ def inspect
+ "#<#{self.class} #{@address}:#{@port} started=#{@started}>"
+ end
-require 'net/protocol'
-require 'md5'
+ # +true+ if the SMTP object uses ESMTP (which it does by default).
+ def esmtp?
+ @esmtp
+ end
+ #
+ # Set whether to use ESMTP or not. This should be done before
+ # calling #start. Note that if #start is called in ESMTP mode,
+ # and the connection fails due to a ProtocolError, the SMTP
+ # object will automatically switch to plain SMTP mode and
+ # retry (but not vice versa).
+ #
+ def esmtp=( bool )
+ @esmtp = bool
+ end
-module Net
+ alias esmtp esmtp?
+ # The address of the SMTP server to connect to.
+ attr_reader :address
- class SMTP < Protocol
+ # The port number of the SMTP server to connect to.
+ attr_reader :port
- protocol_param :port, '25'
- protocol_param :command_type, '::Net::NetPrivate::SMTPCommand'
+ # Seconds to wait while attempting to open a connection.
+ # If the connection cannot be opened within this time, a
+ # TimeoutError is raised.
+ attr_accessor :open_timeout
+ # Seconds to wait while reading one block (by one read(2) call).
+ # If the read(2) call does not complete within this time, a
+ # TimeoutError is raised.
+ attr_reader :read_timeout
- def initialize( addr = nil, port = nil )
- super
- @esmtp = true
+ # Set the number of seconds to wait until timing-out a read(2)
+ # call.
+ def read_timeout=( sec )
+ @socket.read_timeout = sec if @socket
+ @read_timeout = sec
end
- attr :esmtp
-
- def send_mail( mailsrc, from_addr, *to_addrs )
- do_ready from_addr, to_addrs.flatten
- @command.write_mail mailsrc, nil
+ #
+ # WARNING: This method causes serious security holes.
+ # Use this method for only debugging.
+ #
+ # Set an output stream for debug logging.
+ # You must call this before #start.
+ #
+ # # example
+ # smtp = Net::SMTP.new(addr, port)
+ # smtp.set_debug_output $stderr
+ # smtp.start do |smtp|
+ # ....
+ # end
+ #
+ def set_debug_output( arg )
+ @debug_output = arg
end
- alias sendmail send_mail
-
- def ready( from_addr, *to_addrs, &block )
- do_ready from_addr, to_addrs.flatten
- @command.write_mail nil, block
+ #
+ # SMTP session control
+ #
+
+ #
+ # Creates a new Net::SMTP object and connects to the server.
+ #
+ # This method is equivalent to:
+ #
+ # Net::SMTP.new(address, port).start(helo_domain, account, password, authtype)
+ #
+ # === Example
+ #
+ # Net::SMTP.start('your.smtp.server') do |smtp|
+ # smtp.send_message msgstr, 'from@example.com', ['dest@example.com']
+ # end
+ #
+ # === Block Usage
+ #
+ # If called with a block, the newly-opened Net::SMTP object is yielded
+ # to the block, and automatically closed when the block finishes. If called
+ # without a block, the newly-opened Net::SMTP object is returned to
+ # the caller, and it is the caller's responsibility to close it when
+ # finished.
+ #
+ # === Parameters
+ #
+ # +address+ is the hostname or ip address of your smtp server.
+ #
+ # +port+ is the port to connect to; it defaults to port 25.
+ #
+ # +helo+ is the _HELO_ _domain_ provided by the client to the
+ # server (see overview comments); it defaults to 'localhost.localdomain'.
+ #
+ # The remaining arguments are used for SMTP authentication, if required
+ # or desired. +user+ is the account name; +secret+ is your password
+ # or other authentication token; and +authtype+ is the authentication
+ # type, one of :plain, :login, or :cram_md5. See the discussion of
+ # SMTP Authentication in the overview notes.
+ #
+ # === Errors
+ #
+ # This method may raise:
+ #
+ # * Net::SMTPAuthenticationError
+ # * Net::SMTPServerBusy
+ # * Net::SMTPSyntaxError
+ # * Net::SMTPFatalError
+ # * Net::SMTPUnknownError
+ # * IOError
+ # * TimeoutError
+ #
+ def SMTP.start( address, port = nil,
+ helo = 'localhost.localdomain',
+ user = nil, secret = nil, authtype = nil,
+ &block) # :yield: smtp
+ new(address, port).start(helo, user, secret, authtype, &block)
end
+ # +true+ if the SMTP session has been started.
+ def started?
+ @started
+ end
- private
-
-
- def do_ready( from_addr, to_addrs )
- if to_addrs.empty? then
- raise ArgumentError, 'mail destination does not given'
+ #
+ # Opens a TCP connection and starts the SMTP session.
+ #
+ # === Parameters
+ #
+ # +helo+ is the _HELO_ _domain_ that you'll dispatch mails from; see
+ # the discussion in the overview notes.
+ #
+ # If both of +user+ and +secret+ are given, SMTP authentication
+ # will be attempted using the AUTH command. +authtype+ specifies
+ # the type of authentication to attempt; it must be one of
+ # :login, :plain, and :cram_md5. See the notes on SMTP Authentication
+ # in the overview.
+ #
+ # === Block Usage
+ #
+ # When this methods is called with a block, the newly-started SMTP
+ # object is yielded to the block, and automatically closed after
+ # the block call finishes. Otherwise, it is the caller's
+ # responsibility to close the session when finished.
+ #
+ # === Example
+ #
+ # This is very similar to the class method SMTP.start.
+ #
+ # require 'net/smtp'
+ # smtp = Net::SMTP.new('smtp.mail.server', 25)
+ # smtp.start(helo_domain, account, password, authtype) do |smtp|
+ # smtp.send_message msgstr, 'from@example.com', ['dest@example.com']
+ # end
+ #
+ # The primary use of this method (as opposed to SMTP.start)
+ # is probably to set debugging (#set_debug_output) or ESMTP
+ # (#esmtp=), which must be done before the session is
+ # started.
+ #
+ # === Errors
+ #
+ # If session has already been started, an IOError will be raised.
+ #
+ # This method may raise:
+ #
+ # * Net::SMTPAuthenticationError
+ # * Net::SMTPServerBusy
+ # * Net::SMTPSyntaxError
+ # * Net::SMTPFatalError
+ # * Net::SMTPUnknownError
+ # * IOError
+ # * TimeoutError
+ #
+ def start( helo = 'localhost.localdomain',
+ user = nil, secret = nil, authtype = nil ) # :yield: smtp
+ if block_given?
+ begin
+ do_start(helo, user, secret, authtype)
+ return yield(self)
+ ensure
+ do_finish
+ end
+ else
+ do_start(helo, user, secret, authtype)
+ return self
end
- @command.mailfrom from_addr
- @command.rcpt to_addrs
- @command.data
end
- def do_start( helodom = nil,
- user = nil, secret = nil, authtype = nil )
- helodom ||= ::Socket.gethostname
- unless helodom then
- raise ArgumentError,
- "cannot get localhost name; try 'smtp.start(local_host_name)'"
- end
+ def do_start( helodomain, user, secret, authtype )
+ raise IOError, 'SMTP session already started' if @started
+ check_auth_args user, secret, authtype if user or secret
+ @socket = InternetMessageIO.open(@address, @port,
+ @open_timeout, @read_timeout,
+ @debug_output)
+ check_response(critical { recv_response() })
begin
- if @esmtp then
- @command.ehlo helodom
+ if @esmtp
+ ehlo helodomain
else
- @command.helo helodom
+ helo helodomain
end
rescue ProtocolError
- if @esmtp then
+ if @esmtp
@esmtp = false
- @command.error_ok
+ @error_occured = false
retry
- else
- raise
end
+ raise
end
-
- if user or secret then
- (user and secret) or
- raise ArgumentError, 'both of account and password are required'
-
- mid = 'auth_' + (authtype || 'cram_md5').to_s
- @command.respond_to? mid or
- raise ArgumentError, "wrong auth type #{authtype.to_s}"
-
- @command.__send__ mid, user, secret
- end
+ authenticate user, secret, authtype if user
+ @started = true
+ ensure
+ @socket.close if not @started and @socket and not @socket.closed?
end
+ private :do_start
- end
-
- SMTPSession = SMTP
+ # Finishes the SMTP session and closes TCP connection.
+ # Raises IOError if not started.
+ def finish
+ raise IOError, 'not yet started' unless started?
+ do_finish
+ end
+ def do_finish
+ quit if @socket and not @socket.closed? and not @error_occured
+ ensure
+ @started = false
+ @error_occured = false
+ @socket.close if @socket and not @socket.closed?
+ @socket = nil
+ end
+ private :do_finish
+
+ #
+ # message send
+ #
+
+ public
+
+ #
+ # Sends +msgstr+ as a message. Single CR ("\r") and LF ("\n") found
+ # in the +msgstr+, are converted into the CR LF pair. You cannot send a
+ # binary message with this method. +msgstr+ should include both
+ # the message headers and body.
+ #
+ # +from_addr+ is a String representing the source mail address.
+ #
+ # +to_addr+ is a String or Strings or Array of Strings, representing
+ # the destination mail address or addresses.
+ #
+ # === Example
+ #
+ # Net::SMTP.start('smtp.example.com') do |smtp|
+ # smtp.send_message msgstr,
+ # 'from@example.com',
+ # ['dest@example.com', 'dest2@example.com']
+ # end
+ #
+ # === Errors
+ #
+ # This method may raise:
+ #
+ # * Net::SMTPServerBusy
+ # * Net::SMTPSyntaxError
+ # * Net::SMTPFatalError
+ # * Net::SMTPUnknownError
+ # * IOError
+ # * TimeoutError
+ #
+ def send_message( msgstr, from_addr, *to_addrs )
+ send0(from_addr, to_addrs.flatten) {
+ @socket.write_message msgstr
+ }
+ end
+ alias send_mail send_message
+ alias sendmail send_message # obsolete
+
+ #
+ # Opens a message writer stream and gives it to the block.
+ # The stream is valid only in the block, and has these methods:
+ #
+ # puts(str = ''):: outputs STR and CR LF.
+ # print(str):: outputs STR.
+ # printf(fmt, *args):: outputs sprintf(fmt,*args).
+ # write(str):: outputs STR and returns the length of written bytes.
+ # <<(str):: outputs STR and returns self.
+ #
+ # If a single CR ("\r") or LF ("\n") is found in the message,
+ # it is converted to the CR LF pair. You cannot send a binary
+ # message with this method.
+ #
+ # === Parameters
+ #
+ # +from_addr+ is a String representing the source mail address.
+ #
+ # +to_addr+ is a String or Strings or Array of Strings, representing
+ # the destination mail address or addresses.
+ #
+ # === Example
+ #
+ # Net::SMTP.start('smtp.example.com', 25) do |smtp|
+ # smtp.open_message_stream('from@example.com', ['dest@example.com']) do |f|
+ # f.puts 'From: from@example.com'
+ # f.puts 'To: dest@example.com'
+ # f.puts 'Subject: test message'
+ # f.puts
+ # f.puts 'This is a test message.'
+ # end
+ # end
+ #
+ # === Errors
+ #
+ # This method may raise:
+ #
+ # * Net::SMTPServerBusy
+ # * Net::SMTPSyntaxError
+ # * Net::SMTPFatalError
+ # * Net::SMTPUnknownError
+ # * IOError
+ # * TimeoutError
+ #
+ def open_message_stream( from_addr, *to_addrs, &block ) # :yield: stream
+ send0(from_addr, to_addrs.flatten) {
+ @socket.write_message_by_block(&block)
+ }
+ end
- module NetPrivate
+ alias ready open_message_stream # obsolete
+ private
- class SMTPCommand < Command
+ def send0( from_addr, to_addrs )
+ raise IOError, 'closed session' unless @socket
+ raise ArgumentError, 'mail destination not given' if to_addrs.empty?
+ if $SAFE > 0
+ raise SecurityError, 'tainted from_addr' if from_addr.tainted?
+ to_addrs.each do |to|
+ raise SecurityError, 'tainted to_addr' if to.tainted?
+ end
+ end
- def initialize( sock )
- super
- critical {
- check_reply SuccessCode
+ mailfrom from_addr
+ to_addrs.each do |to|
+ rcptto to
+ end
+ res = critical {
+ check_response(get_response('DATA'), true)
+ yield
+ recv_response()
}
+ check_response(res)
end
+ #
+ # auth
+ #
- def helo( fromdom )
- critical {
- getok sprintf( 'HELO %s', fromdom )
- }
- end
-
+ private
- def ehlo( fromdom )
- critical {
- getok sprintf( 'EHLO %s', fromdom )
- }
+ def check_auth_args( user, secret, authtype )
+ raise ArgumentError, 'both user and secret are required'\
+ unless user and secret
+ auth_method = "auth_#{authtype || 'cram_md5'}"
+ raise ArgumentError, "wrong auth type #{authtype}"\
+ unless respond_to?(auth_method, true)
end
+ def authenticate( user, secret, authtype )
+ __send__("auth_#{authtype || 'cram_md5'}", user, secret)
+ end
- # "PLAIN" authentication [RFC2554]
def auth_plain( user, secret )
- critical {
- getok sprintf( 'AUTH PLAIN %s',
- ["\0#{user}\0#{secret}"].pack('m').chomp )
+ res = critical { get_response('AUTH PLAIN %s',
+ base64_encode("\0#{user}\0#{secret}")) }
+ raise SMTPAuthenticationError, res unless /\A2../ === res
+ end
+
+ def auth_login( user, secret )
+ res = critical {
+ check_response(get_response('AUTH LOGIN'), true)
+ check_response(get_response(base64_encode(user)), true)
+ get_response(base64_encode(secret))
}
+ raise SMTPAuthenticationError, res unless /\A2../ === res
end
- # "CRAM-MD5" authentication [RFC2195]
def auth_cram_md5( user, secret )
+ # CRAM-MD5: [RFC2195]
+ res = nil
critical {
- rep = getok( 'AUTH CRAM-MD5', ContinueCode )
- challenge = rep.msg.split(' ')[1].unpack('m')[0]
- secret = MD5.new( secret ).digest if secret.size > 64
+ res = check_response(get_response('AUTH CRAM-MD5'), true)
+ challenge = res.split(/ /)[1].unpack('m')[0]
+ secret = Digest::MD5.digest(secret) if secret.size > 64
isecret = secret + "\0" * (64 - secret.size)
osecret = isecret.dup
- 0.upto( 63 ) do |i|
+ 0.upto(63) do |i|
isecret[i] ^= 0x36
osecret[i] ^= 0x5c
end
- tmp = MD5.new( isecret + challenge ).digest
- tmp = MD5.new( osecret + tmp ).hexdigest
+ tmp = Digest::MD5.digest(isecret + challenge)
+ tmp = Digest::MD5.hexdigest(osecret + tmp)
- getok [user + ' ' + tmp].pack('m').chomp
+ res = get_response(base64_encode(user + ' ' + tmp))
}
+ raise SMTPAuthenticationError, res unless /\A2../ === res
end
-
- def mailfrom( fromaddr )
- critical {
- getok sprintf( 'MAIL FROM:<%s>', fromaddr )
- }
+ def base64_encode( str )
+ # expects "str" may not become too long
+ [str].pack('m').gsub(/\s+/, '')
end
+ #
+ # SMTP command dispatcher
+ #
- def rcpt( toaddrs )
- toaddrs.each do |i|
- critical {
- getok sprintf( 'RCPT TO:<%s>', i )
- }
- end
- end
+ private
+ def helo( domain )
+ getok('HELO %s', domain)
+ end
- def data
- return unless begin_critical
- getok 'DATA', ContinueCode
+ def ehlo( domain )
+ getok('EHLO %s', domain)
end
- def write_mail( mailsrc, block )
- @socket.write_pendstr mailsrc, block
- check_reply SuccessCode
- end_critical
+ def mailfrom( fromaddr )
+ getok('MAIL FROM:<%s>', fromaddr)
end
+ def rcptto( to )
+ getok('RCPT TO:<%s>', to)
+ end
def quit
- critical {
- getok 'QUIT'
- }
+ getok('QUIT')
end
+ #
+ # row level library
+ #
private
-
- def get_reply
- arr = read_reply
- stat = arr[0][0,3]
-
- klass = case stat[0]
- when ?2 then SuccessCode
- when ?3 then ContinueCode
- when ?4 then ServerErrorCode
- when ?5 then
- case stat[1]
- when ?0 then SyntaxErrorCode
- when ?3 then AuthErrorCode
- when ?5 then FatalErrorCode
- end
- end
- klass ||= UnknownCode
-
- Response.new( klass, stat, arr.join('') )
+ def getok( fmt, *args )
+ res = critical {
+ @socket.writeline sprintf(fmt, *args)
+ recv_response()
+ }
+ return check_response(res)
end
+ def get_response( fmt, *args )
+ @socket.writeline sprintf(fmt, *args)
+ recv_response()
+ end
- def read_reply
- arr = []
- while true do
- str = @socket.readline
- break unless str[3] == ?- # ex: "210-..."
- arr.push str
+ def recv_response
+ res = ''
+ while true
+ line = @socket.readline
+ res << line << "\n"
+ break unless line[3] == ?- # "210-PIPELINING"
end
- arr.push str
+ res
+ end
- arr
+ def check_response( res, allow_continue = false )
+ return res if /\A2/ === res
+ return res if allow_continue and /\A3/ === res
+ err = case res
+ when /\A4/ then SMTPServerBusy
+ when /\A50/ then SMTPSyntaxError
+ when /\A55/ then SMTPFatalError
+ else SMTPUnknownError
+ end
+ raise err, res
end
- end
+ def critical( &block )
+ return '200 dummy reply code' if @error_occured
+ begin
+ return yield()
+ rescue Exception
+ @error_occured = true
+ raise
+ end
+ end
+ end # class SMTP
- end # module Net::NetPrivate
+ SMTPSession = SMTP
end # module Net
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index 380e834bea..05691de0f7 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -1,251 +1,278 @@
-=begin
-
-== NAME
-
-net/telnet.rb - simple telnet client library
-
-Version 1.6.3
-
-Wakou Aoyama <wakou@fsinet.or.jp>
-
-
-=== MAKE NEW TELNET OBJECT
-
- host = Net::Telnet::new({
- "Binmode" => false, # default: false
- "Host" => "localhost", # default: "localhost"
- "Output_log" => "output_log", # default: nil (no output)
- "Dump_log" => "dump_log", # default: nil (no output)
- "Port" => 23, # default: 23
- "Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
- "Telnetmode" => true, # default: true
- "Timeout" => 10, # default: 10
- # if ignore timeout then set "Timeout" to false.
- "Waittime" => 0, # default: 0
- "Proxy" => proxy # default: nil
- # proxy is Net::Telnet or IO object
- })
-
-Telnet object has socket class methods.
-
-if set "Telnetmode" option to false. not telnet command interpretation.
-"Waittime" is time to confirm "Prompt". There is a possibility that
-the same character as "Prompt" is included in the data, and, when
-the network or the host is very heavy, the value is enlarged.
-
-
-=== STATUS OUTPUT
-
- host = Net::Telnet::new({"Host" => "localhost"}){|c| print c }
-
-connection status output.
-
-example:
-
- Trying localhost...
- Connected to localhost.
-
-
-=== WAIT FOR MATCH
-
- line = host.waitfor(/match/)
- line = host.waitfor({"Match" => /match/,
- "String" => "string",
- "Timeout" => secs})
- # if ignore timeout then set "Timeout" to false.
-
-if set "String" option, then Match == Regexp.new(quote("string"))
-
-
-==== REALTIME OUTPUT
-
- host.waitfor(/match/){|c| print c }
- host.waitfor({"Match" => /match/,
- "String" => "string",
- "Timeout" => secs}){|c| print c}
-
-of cource, set sync=true or flush is necessary.
-
-
-=== SEND STRING AND WAIT PROMPT
-
- line = host.cmd("string")
- line = host.cmd({"String" => "string",
- "Match" => /[$%#>] \z/n,
- "Timeout" => 10})
-
-
-==== REALTIME OUTPUT
-
- host.cmd("string"){|c| print c }
- host.cmd({"String" => "string",
- "Match" => /[$%#>] \z/n,
- "Timeout" => 10}){|c| print c }
-
-of cource, set sync=true or flush is necessary.
-
-
-=== SEND STRING
-
- host.print("string")
- host.puts("string")
-
-Telnet#puts() adds "\n" to the last of "string".
-
-WARNING: Telnet#print() NOT adds "\n" to the last of "string", in the future.
-
-If "Telnetmode" option is true, then escape IAC code ("\xFF"). If
-"Binmode" option is false, then convert "\n" to EOL(end of line) code.
-
-If "WILL SGA" and "DO BIN", then EOL is CR. If "WILL SGA", then EOL is
-CR + NULL. If the other cases, EOL is CR + LF.
-
-
-=== TOGGLE TELNET COMMAND INTERPRETATION
-
- host.telnetmode # return the current status (true or false)
- host.telnetmode = true # do telnet command interpretation (default)
- host.telnetmode = false # don't telnet command interpretation
-
-
-=== TOGGLE NEWLINE TRANSLATION
-
- host.binmode # return the current status (true or false)
- host.binmode = true # no translate newline
- host.binmode = false # translate newline (default)
-
-
-=== LOGIN
-
- host.login("username", "password")
- host.login({"Name" => "username",
- "Password" => "password"})
-
-if no password prompt:
-
- host.login("username")
- host.login({"Name" => "username"})
-
-
-==== REALTIME OUTPUT
-
- host.login("username", "password"){|c| print c }
- host.login({"Name" => "username",
- "Password" => "password"}){|c| print c }
-
-of cource, set sync=true or flush is necessary.
-
-
-
-== EXAMPLE
-
-=== LOGIN AND SEND COMMAND
-
- localhost = Net::Telnet::new({"Host" => "localhost",
- "Timeout" => 10,
- "Prompt" => /[$%#>] \z/n})
- localhost.login("username", "password"){|c| print c }
- localhost.cmd("command"){|c| print c }
- localhost.close
-
-
-=== CHECKS A POP SERVER TO SEE IF YOU HAVE MAIL
-
- pop = Net::Telnet::new({"Host" => "your_destination_host_here",
- "Port" => 110,
- "Telnetmode" => false,
- "Prompt" => /^\+OK/n})
- pop.cmd("user " + "your_username_here"){|c| print c}
- pop.cmd("pass " + "your_password_here"){|c| print c}
- pop.cmd("list"){|c| print c}
-
-
-=end
-
+# = net/telnet.rb - Simple Telnet Client Library
+#
+# Author:: Wakou Aoyama <wakou@ruby-lang.org>
+# Documentation:: William Webber and Wakou Aoyama
+#
+# This file holds the class Net::Telnet, which provides client-side
+# telnet functionality.
+#
+# For documentation, see Net::Telnet.
+#
require "socket"
require "delegate"
require "timeout"
require "English"
-
+
module Net
+
+ #
+ # == Net::Telnet
+ #
+ # Provides telnet client functionality.
+ #
+ # This class also has, through delegation, all the methods of a
+ # socket object (by default, a +TCPSocket+, but can be set by the
+ # +Proxy+ option to <tt>new()</tt>). This provides methods such as
+ # <tt>close()</tt> to end the session and <tt>sysread()</tt> to read
+ # data directly from the host, instead of via the <tt>waitfor()</tt>
+ # mechanism. Note that if you do use <tt>sysread()</tt> directly
+ # when in telnet mode, you should probably pass the output through
+ # <tt>preprocess()</tt> to extract telnet command sequences.
+ #
+ # == Overview
+ #
+ # The telnet protocol allows a client to login remotely to a user
+ # account on a server and execute commands via a shell. The equivalent
+ # is done by creating a Net::Telnet class with the +Host+ option
+ # set to your host, calling #login() with your user and password,
+ # issuing one or more #cmd() calls, and then calling #close()
+ # to end the session. The #waitfor(), #print(), #puts(), and
+ # #write() methods, which #cmd() is implemented on top of, are
+ # only needed if you are doing something more complicated.
+ #
+ # A Net::Telnet object can also be used to connect to non-telnet
+ # services, such as SMTP or HTTP. In this case, you normally
+ # want to provide the +Port+ option to specify the port to
+ # connect to, and set the +Telnetmode+ option to false to prevent
+ # the client from attempting to interpret telnet command sequences.
+ # Generally, #login() will not work with other protocols, and you
+ # have to handle authentication yourself.
+ #
+ # For some protocols, it will be possible to specify the +Prompt+
+ # option once when you create the Telnet object and use #cmd() calls;
+ # for others, you will have to specify the response sequence to
+ # look for as the Match option to every #cmd() call, or call
+ # #puts() and #waitfor() directly; for yet others, you will have
+ # to use #sysread() instead of #waitfor() and parse server
+ # responses yourself.
+ #
+ # It is worth noting that when you create a new Net::Telnet object,
+ # you can supply a proxy IO channel via the Proxy option. This
+ # can be used to attach the Telnet object to other Telnet objects,
+ # to already open sockets, or to any read-write IO object. This
+ # can be useful, for instance, for setting up a test fixture for
+ # unit testing.
+ #
+ # == Examples
+ #
+ # === Log in and send a command, echoing all output to stdout
+ #
+ # localhost = Net::Telnet::new("Host" => "localhost",
+ # "Timeout" => 10,
+ # "Prompt" => /[$%#>] \z/n)
+ # localhost.login("username", "password") { |c| print c }
+ # localhost.cmd("command") { |c| print c }
+ # localhost.close
+ #
+ #
+ # === Check a POP server to see if you have mail
+ #
+ # pop = Net::Telnet::new("Host" => "your_destination_host_here",
+ # "Port" => 110,
+ # "Telnetmode" => false,
+ # "Prompt" => /^\+OK/n)
+ # pop.cmd("user " + "your_username_here") { |c| print c }
+ # pop.cmd("pass " + "your_password_here") { |c| print c }
+ # pop.cmd("list") { |c| print c }
+ #
+ # == References
+ #
+ # There are a large number of RFCs relevant to the Telnet protocol.
+ # RFCs 854-861 define the base protocol. For a complete listing
+ # of relevant RFCs, see
+ # http://www.omnifarious.org/~hopper/technical/telnet-rfc.html
+ #
class Telnet < SimpleDelegator
- IAC = 255.chr # "\377" # "\xff" # interpret as command:
- DONT = 254.chr # "\376" # "\xfe" # you are not to use option
- DO = 253.chr # "\375" # "\xfd" # please, you use option
- WONT = 252.chr # "\374" # "\xfc" # I won't use option
- WILL = 251.chr # "\373" # "\xfb" # I will use option
- SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
- GA = 249.chr # "\371" # "\xf9" # you may reverse the line
- EL = 248.chr # "\370" # "\xf8" # erase the current line
- EC = 247.chr # "\367" # "\xf7" # erase the current character
- AYT = 246.chr # "\366" # "\xf6" # are you there
- AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
- IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
- BREAK = 243.chr # "\363" # "\xf3" # break
- DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
- NOP = 241.chr # "\361" # "\xf1" # nop
- SE = 240.chr # "\360" # "\xf0" # end sub negotiation
- EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
- ABORT = 238.chr # "\356" # "\xee" # Abort process
- SUSP = 237.chr # "\355" # "\xed" # Suspend process
- EOF = 236.chr # "\354" # "\xec" # End of file
- SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
-
- OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
- OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
- OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
- OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
- OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
- OPT_STATUS = 5.chr # "\005" # "\x05" # Status
- OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
- OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
- OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
- OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
- OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
- OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
- OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
- OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
- OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
- OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
- OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
- OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
- OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
- OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
- OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
- OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
- OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
- OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
- OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
- OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
- OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
- OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
- OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
- OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
- OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
- OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
- OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
- OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
- OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
- OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
- OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
- OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
- OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
- OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
- OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
-
- NULL = "\000"
- CR = "\015"
- LF = "\012"
- EOL = CR + LF
- VERSION = '1.6.3'
- RELEASE_DATE = '2001-02-26'
- VERSION_CODE = 163
- RELEASE_CODE = 20010226
+ # :stopdoc:
+ IAC = 255.chr # "\377" # "\xff" # interpret as command
+ DONT = 254.chr # "\376" # "\xfe" # you are not to use option
+ DO = 253.chr # "\375" # "\xfd" # please, you use option
+ WONT = 252.chr # "\374" # "\xfc" # I won't use option
+ WILL = 251.chr # "\373" # "\xfb" # I will use option
+ SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
+ GA = 249.chr # "\371" # "\xf9" # you may reverse the line
+ EL = 248.chr # "\370" # "\xf8" # erase the current line
+ EC = 247.chr # "\367" # "\xf7" # erase the current character
+ AYT = 246.chr # "\366" # "\xf6" # are you there
+ AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
+ IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
+ BREAK = 243.chr # "\363" # "\xf3" # break
+ DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
+ NOP = 241.chr # "\361" # "\xf1" # nop
+ SE = 240.chr # "\360" # "\xf0" # end sub negotiation
+ EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
+ ABORT = 238.chr # "\356" # "\xee" # Abort process
+ SUSP = 237.chr # "\355" # "\xed" # Suspend process
+ EOF = 236.chr # "\354" # "\xec" # End of file
+ SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
+
+ OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
+ OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
+ OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
+ OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
+ OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
+ OPT_STATUS = 5.chr # "\005" # "\x05" # Status
+ OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
+ OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
+ OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
+ OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
+ OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
+ OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
+ OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
+ OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
+ OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
+ OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
+ OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
+ OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
+ OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
+ OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
+ OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
+ OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
+ OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
+ OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
+ OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
+ OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
+ OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
+ OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
+ OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
+ OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
+ OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
+ OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
+ OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
+ OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
+ OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
+ OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
+ OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
+ OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
+ OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
+ OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
+ OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
+
+ NULL = "\000"
+ CR = "\015"
+ LF = "\012"
+ EOL = CR + LF
REVISION = '$Id$'
-
- def initialize(options)
+ # :startdoc:
+
+ #
+ # Creates a new Net::Telnet object.
+ #
+ # Attempts to connect to the host (unless the Proxy option is
+ # provided: see below). If a block is provided, it is yielded
+ # status messages on the attempt to connect to the server, of
+ # the form:
+ #
+ # Trying localhost...
+ # Connected to localhost.
+ #
+ # +options+ is a hash of options. The following example lists
+ # all options and their default values.
+ #
+ # host = Net::Telnet::new(
+ # "Host" => "localhost", # default: "localhost"
+ # "Port" => 23, # default: 23
+ # "Binmode" => false, # default: false
+ # "Output_log" => "output_log", # default: nil (no output)
+ # "Dump_log" => "dump_log", # default: nil (no output)
+ # "Prompt" => /[$%#>] \z/n, # default: /[$%#>] \z/n
+ # "Telnetmode" => true, # default: true
+ # "Timeout" => 10, # default: 10
+ # # if ignore timeout then set "Timeout" to false.
+ # "Waittime" => 0, # default: 0
+ # "Proxy" => proxy # default: nil
+ # # proxy is Net::Telnet or IO object
+ # )
+ #
+ # The options have the following meanings:
+ #
+ # Host:: the hostname or IP address of the host to connect to, as a String.
+ # Defaults to "localhost".
+ #
+ # Port:: the port to connect to. Defaults to 23.
+ #
+ # Binmode:: if false (the default), newline substitution is performed.
+ # Outgoing LF is
+ # converted to CRLF, and incoming CRLF is converted to LF. If
+ # true, this substitution is not performed. This value can
+ # also be set with the #binmode() method. The
+ # outgoing conversion only applies to the #puts() and #print()
+ # methods, not the #write() method. The precise nature of
+ # the newline conversion is also affected by the telnet options
+ # SGA and BIN.
+ #
+ # Output_log:: the name of the file to write connection status messages
+ # and all received traffic to. In the case of a proper
+ # Telnet session, this will include the client input as
+ # echoed by the host; otherwise, it only includes server
+ # responses. Output is appended verbatim to this file.
+ # By default, no output log is kept.
+ #
+ # Dump_log:: as for Output_log, except that output is written in hexdump
+ # format (16 bytes per line as hex pairs, followed by their
+ # printable equivalent), with connection status messages
+ # preceded by '#', sent traffic preceded by '>', and
+ # received traffic preceded by '<'. By default, not dump log
+ # is kept.
+ #
+ # Prompt:: a regular expression matching the host's command-line prompt
+ # sequence. This is needed by the Telnet class to determine
+ # when the output from a command has finished and the host is
+ # ready to receive a new command. By default, this regular
+ # expression is /[$%#>] \z/n.
+ #
+ # Telnetmode:: a boolean value, true by default. In telnet mode,
+ # traffic received from the host is parsed for special
+ # command sequences, and these sequences are escaped
+ # in outgoing traffic sent using #puts() or #print()
+ # (but not #write()). If you are using the Net::Telnet
+ # object to connect to a non-telnet service (such as
+ # SMTP or POP), this should be set to "false" to prevent
+ # undesired data corruption. This value can also be set
+ # by the #telnetmode() method.
+ #
+ # Timeout:: the number of seconds to wait before timing out both the
+ # initial attempt to connect to host (in this constructor),
+ # and all attempts to read data from the host (in #waitfor(),
+ # #cmd(), and #login()). Exceeding this timeout causes a
+ # TimeoutError to be raised. The default value is 10 seconds.
+ # You can disable the timeout by setting this value to false.
+ # In this case, the connect attempt will eventually timeout
+ # on the underlying connect(2) socket call with an
+ # Errno::ETIMEDOUT error (but generally only after a few
+ # minutes), but other attempts to read data from the host
+ # will hand indefinitely if no data is forthcoming.
+ #
+ # Waittime:: the amount of time to wait after seeing what looks like a
+ # prompt (that is, received data that matches the Prompt
+ # option regular expression) to see if more data arrives.
+ # If more data does arrive in this time, Net::Telnet assumes
+ # that what it saw was not really a prompt. This is to try to
+ # avoid false matches, but it can also lead to missing real
+ # prompts (if, for instance, a background process writes to
+ # the terminal soon after the prompt is displayed). By
+ # default, set to 0, meaning not to wait for more data.
+ #
+ # Proxy:: a proxy object to used instead of opening a direct connection
+ # to the host. Must be either another Net::Telnet object or
+ # an IO object. If it is another Net::Telnet object, this
+ # instance will use that one's socket for communication. If an
+ # IO object, it is used directly for communication. Any other
+ # kind of object will cause an error to be raised.
+ #
+ def initialize(options) # :yield: mesg
@options = options
@options["Host"] = "localhost" unless @options.has_key?("Host")
@options["Port"] = 23 unless @options.has_key?("Port")
@@ -256,7 +283,7 @@ module Net
@options["Binmode"] = false
else
unless (true == @options["Binmode"] or false == @options["Binmode"])
- raise ArgumentError, "Binmode option required true or false"
+ raise ArgumentError, "Binmode option must be true or false"
end
end
@@ -264,7 +291,7 @@ module Net
@options["Telnetmode"] = true
else
unless (true == @options["Telnetmode"] or false == @options["Telnetmode"])
- raise ArgumentError, "Telnetmode option required true or false"
+ raise ArgumentError, "Telnetmode option must be true or false"
end
end
@@ -280,7 +307,7 @@ module Net
@dumplog = File.open(@options["Dump_log"], 'a+')
@dumplog.sync = true
@dumplog.binmode
- def @dumplog.log_dump(dir, x)
+ def @dumplog.log_dump(dir, x) # :nodoc:
len = x.length
addr = 0
offset = 0
@@ -291,8 +318,8 @@ module Net
line = x[offset, 16]
end
hexvals = line.unpack('H*')[0]
- hexvals.concat ' ' * (32 - hexvals.length)
- hexvals = format "%s %s %s %s " * 4, *hexvals.unpack('a2' * 16)
+ hexvals += ' ' * (32 - hexvals.length)
+ hexvals = format("%s %s %s %s " * 4, *hexvals.unpack('a2' * 16))
line = line.gsub(/[\000-\037\177-\377]/n, '.')
printf "%s 0x%5.5x: %s%s\n", dir, addr, hexvals, line
addr += 16
@@ -309,7 +336,7 @@ module Net
elsif @options["Proxy"].kind_of?(IO)
@sock = @options["Proxy"]
else
- raise "Error; Proxy is Net::Telnet or IO object."
+ raise "Error: Proxy must be an instance of Net::Telnet or IO."
end
else
message = "Trying " + @options["Host"] + "...\n"
@@ -319,14 +346,14 @@ module Net
begin
if @options["Timeout"] == false
- @sock = TCPsocket.open(@options["Host"], @options["Port"])
+ @sock = TCPSocket.open(@options["Host"], @options["Port"])
else
timeout(@options["Timeout"]) do
- @sock = TCPsocket.open(@options["Host"], @options["Port"])
+ @sock = TCPSocket.open(@options["Host"], @options["Port"])
end
end
rescue TimeoutError
- raise TimeoutError, "timed-out; opening of the host"
+ raise TimeoutError, "timed out while opening a connection to the host"
rescue
@log.write($ERROR_INFO.to_s + "\n") if @options.has_key?("Output_log")
@dumplog.log_dump('#', $ERROR_INFO.to_s + "\n") if @options.has_key?("Dump_log")
@@ -344,8 +371,16 @@ module Net
super(@sock)
end # initialize
- attr :sock
+ # The socket the Telnet object is using. Note that this object becomes
+ # a delegate of the Telnet object, so normally you invoke its methods
+ # directly on the Telnet object.
+ attr :sock
+ # Set telnet command interpretation on (+mode+ == true) or off
+ # (+mode+ == false), or return the current value (+mode+ not
+ # provided). It should be on for true telnet sessions, off if
+ # using Net::Telnet to connect to a non-telnet service such
+ # as SMTP.
def telnetmode(mode = nil)
case mode
when nil
@@ -353,18 +388,23 @@ module Net
when true, false
@options["Telnetmode"] = mode
else
- raise ArgumentError, "required true or false"
+ raise ArgumentError, "argument must be true or false, or missing"
end
end
+ # Turn telnet command interpretation on (true) or off (false). It
+ # should be on for true telnet sessions, off if using Net::Telnet
+ # to connect to a non-telnet service such as SMTP.
def telnetmode=(mode)
if (true == mode or false == mode)
@options["Telnetmode"] = mode
else
- raise ArgumentError, "required true or false"
+ raise ArgumentError, "argument must be true or false"
end
end
+ # Turn newline conversion on (+mode+ == false) or off (+mode+ == true),
+ # or return the current value (+mode+ is not specified).
def binmode(mode = nil)
case mode
when nil
@@ -372,18 +412,25 @@ module Net
when true, false
@options["Binmode"] = mode
else
- raise ArgumentError, "required true or false"
+ raise ArgumentError, "argument must be true or false"
end
end
+ # Turn newline conversion on (false) or off (true).
def binmode=(mode)
if (true == mode or false == mode)
@options["Binmode"] = mode
else
- raise ArgumentError, "required true or false"
+ raise ArgumentError, "argument must be true or false"
end
end
+ # Preprocess received data from the host.
+ #
+ # Performs newline conversion and detects telnet command sequences.
+ # Called automatically by #waitfor(). You should only use this
+ # method yourself if you have read input directly using sysread()
+ # or similar, and even then only if in telnet mode.
def preprocess(string)
# combine CR+NULL into CR
string = string.gsub(/#{CR}#{NULL}/no, CR) if @options["Telnetmode"]
@@ -441,7 +488,40 @@ module Net
end
end # preprocess
- def waitfor(options)
+ # Read data from the host until a certain sequence is matched.
+ #
+ # If a block is given, the received data will be yielded as it
+ # is read in (not necessarily all in one go), or nil if EOF
+ # occurs before any data is received. Whether a block is given
+ # or not, all data read will be returned in a single string, or again
+ # nil if EOF occurs before any data is received. Note that
+ # received data includes the matched sequence we were looking for.
+ #
+ # +options+ can be either a regular expression or a hash of options.
+ # If a regular expression, this specifies the data to wait for.
+ # If a hash, this can specify the following options:
+ #
+ # Match:: a regular expression, specifying the data to wait for.
+ # Prompt:: as for Match; used only if Match is not specified.
+ # String:: as for Match, except a string that will be converted
+ # into a regular expression. Used only if Match and
+ # Prompt are not specified.
+ # Timeout:: the number of seconds to wait for data from the host
+ # before raising a TimeoutError. If set to false,
+ # no timeout will occur. If not specified, the
+ # Timeout option value specified when this instance
+ # was created will be used, or, failing that, the
+ # default value of 10 seconds.
+ # Waittime:: the number of seconds to wait after matching against
+ # the input data to see if more data arrives. If more
+ # data arrives within this time, we will judge ourselves
+ # not to have matched successfully, and will continue
+ # trying to match. If not specified, the Waittime option
+ # value specified when this instance was created will be
+ # used, or, failing that, the default value of 0 seconds,
+ # which means not to wait for more input.
+ #
+ def waitfor(options) # :yield: recvdata
time_out = @options["Timeout"]
waittime = @options["Waittime"]
@@ -468,26 +548,35 @@ module Net
rest = ''
until(prompt === line and not IO::select([@sock], nil, nil, waittime))
unless IO::select([@sock], nil, nil, time_out)
- raise TimeoutError, "timed-out; wait for the next data"
+ raise TimeoutError, "timed out while waiting for more data"
end
begin
c = @sock.sysread(1024 * 1024)
@dumplog.log_dump('<', c) if @options.has_key?("Dump_log")
if @options["Telnetmode"]
+ c = rest + c
if Integer(c.rindex(/#{IAC}#{SE}/no)) <
Integer(c.rindex(/#{IAC}#{SB}/no))
- buf = preprocess(rest + c[0 ... c.rindex(/#{IAC}#{SB}/no)])
+ buf = preprocess(c[0 ... c.rindex(/#{IAC}#{SB}/no)])
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1]
elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no)
- buf = preprocess(rest + c[0 ... pt])
+ buf = preprocess(c[0 ... pt])
rest = c[pt .. -1]
else
buf = preprocess(c)
rest = ''
end
+ else
+ # Not Telnetmode.
+ #
+ # We cannot use preprocess() on this data, because that
+ # method makes some Telnetmode-specific assumptions.
+ buf = c
+ buf.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
+ rest = ''
end
@log.print(buf) if @options.has_key?("Output_log")
- line.concat(buf)
+ line += buf
yield buf if block_given?
rescue EOFError # End of file reached
if line == ''
@@ -500,6 +589,10 @@ module Net
line
end
+ # Write +string+ to the host.
+ #
+ # Does not perform any conversions on +string+. Will log +string+ to the
+ # dumplog, if the Dump_log option is set.
def write(string)
length = string.length
while 0 < length
@@ -509,7 +602,13 @@ module Net
end
end
- def _print(string)
+ # Sends a string to the host.
+ #
+ # This does _not_ automatically append a newline to the string. Embedded
+ # newlines may be converted and telnet command sequences escaped
+ # depending upon the values of telnetmode, binmode, and telnet options
+ # set by the host.
+ def print(string)
string = string.gsub(/#{IAC}/no, IAC + IAC) if @options["Telnetmode"]
if @options["Binmode"]
@@ -528,19 +627,41 @@ module Net
end
end
+ # Sends a string to the host.
+ #
+ # Same as #print(), but appends a newline to the string.
def puts(string)
- self._print(string + "\n")
+ self.print(string + "\n")
end
- def print(string)
- if $VERBOSE
- $stderr.puts 'WARNING: Telnet#print("string") NOT adds "\n" to the last of "string", in the future.'
- $stderr.puts ' cf. Telnet#puts().'
- end
- self.puts(string)
- end
-
- def cmd(options)
+ # Send a command to the host.
+ #
+ # More exactly, sends a string to the host, and reads in all received
+ # data until is sees the prompt or other matched sequence.
+ #
+ # If a block is given, the received data will be yielded to it as
+ # it is read in. Whether a block is given or not, the received data
+ # will be return as a string. Note that the received data includes
+ # the prompt and in most cases the host's echo of our command.
+ #
+ # +options+ is either a String, specified the string or command to
+ # send to the host; or it is a hash of options. If a hash, the
+ # following options can be specified:
+ #
+ # String:: the command or other string to send to the host.
+ # Match:: a regular expression, the sequence to look for in
+ # the received data before returning. If not specified,
+ # the Prompt option value specified when this instance
+ # was created will be used, or, failing that, the default
+ # prompt of /[$%#>] \z/n.
+ # Timeout:: the seconds to wait for data from the host before raising
+ # a Timeout error. If not specified, the Timeout option
+ # value specified when this instance was created will be
+ # used, or, failing that, the default value of 10 seconds.
+ #
+ # The command or other string will have the newline sequence appended
+ # to it.
+ def cmd(options) # :yield: recvdata
match = @options["Prompt"]
time_out = @options["Timeout"]
@@ -560,45 +681,62 @@ module Net
end
end
- def login(options, password = nil)
+ # Login to the host with a given username and password.
+ #
+ # The username and password can either be provided as two string
+ # arguments in that order, or as a hash with keys "Name" and
+ # "Password".
+ #
+ # This method looks for the strings "login" and "Password" from the
+ # host to determine when to send the username and password. If the
+ # login sequence does not follow this pattern (for instance, you
+ # are connecting to a service other than telnet), you will need
+ # to handle login yourself.
+ #
+ # The password can be omitted, either by only
+ # provided one String argument, which will be used as the username,
+ # or by providing a has that has no "Password" key. In this case,
+ # the method will not look for the "Password:" prompt; if it is
+ # sent, it will have to be dealt with by later calls.
+ #
+ # The method returns all data received during the login process from
+ # the host, including the echoed username but not the password (which
+ # the host should not echo). If a block is passed in, this received
+ # data is also yielded to the block as it is received.
+ def login(options, password = nil) # :yield: recvdata
+ login_prompt = /[Ll]ogin[: ]*\z/n
+ password_prompt = /Password[: ]*\z/n
if options.kind_of?(Hash)
username = options["Name"]
password = options["Password"]
+ login_prompt = options["LoginPrompt"] if options["LoginPrompt"]
+ password_prompt = options["PasswordPrompt"] if options["PasswordPrompt"]
else
username = options
end
if block_given?
- line = waitfor(/login[: ]*\z/n){|c| yield c }
+ line = waitfor(login_prompt){|c| yield c }
if password
- line.concat( cmd({"String" => username,
- "Match" => /Password[: ]*\z/n}){|c| yield c } )
- line.concat( cmd(password){|c| yield c } )
+ line += cmd({"String" => username,
+ "Match" => password_prompt}){|c| yield c }
+ line += cmd(password){|c| yield c }
else
- line.concat( cmd(username){|c| yield c } )
+ line += cmd(username){|c| yield c }
end
else
- line = waitfor(/login[: ]*\z/n)
+ line = waitfor(login_prompt)
if password
- line.concat( cmd({"String" => username,
- "Match" => /Password[: ]*\z/n}) )
- line.concat( cmd(password) )
+ line += cmd({"String" => username,
+ "Match" => password_prompt})
+ line += cmd(password)
else
- line.concat( cmd(username) )
+ line += cmd(username)
end
end
line
end
- end
-end
-
-
-=begin
-
-== HISTORY
-
-delete. see cvs log.
-
+ end # class Telnet
+end # module Net
-=end
diff --git a/lib/observer.rb b/lib/observer.rb
index e1b249e885..64c7d81351 100644
--- a/lib/observer.rb
+++ b/lib/observer.rb
@@ -1,21 +1,151 @@
-# Observable Mixin
-#
-# Observers must respond to update
+#
+# observer.rb implements the _Observer_ object-oriented design pattern. The
+# following documentation is copied, with modifications, from "Programming
+# Ruby", by Hunt and Thomas; http://www.rubycentral.com/book/lib_patterns.html.
+#
+# == About
+#
+# The Observer pattern, also known as Publish/Subscribe, provides a simple
+# mechanism for one object to inform a set of interested third-party objects
+# when its state changes.
+#
+# == Mechanism
+#
+# In the Ruby implementation, the notifying class mixes in the +Observable+
+# module, which provides the methods for managing the associated observer
+# objects.
+#
+# The observers must implement the +update+ method to receive notifications.
+#
+# The observable object must:
+# * assert that it has +changed+
+# * call +notify_observers+
+#
+# == Example
+#
+# The following example demonstrates this nicely. A +Ticker+, when run,
+# continually receives the stock +Price+ for its +@symbol+. A +Warner+ is a
+# general observer of the price, and two warners are demonstrated, a +WarnLow+
+# and a +WarnHigh+, which print a warning if the price is below or above their
+# set limits, respectively.
+#
+# The +update+ callback allows the warners to run without being explicitly
+# called. The system is set up with the +Ticker+ and several observers, and the
+# observers do their duty without the top-level code having to interfere.
+#
+# Note that the contract between publisher and subscriber (observable and
+# observer) is not declared or enforced. The +Ticker+ publishes a time and a
+# price, and the warners receive that. But if you don't ensure that your
+# contracts are correct, nothing else can warn you.
+#
+# require "observer"
+#
+# class Ticker ### Periodically fetch a stock price.
+# include Observable
+#
+# def initialize(symbol)
+# @symbol = symbol
+# end
+#
+# def run
+# lastPrice = nil
+# loop do
+# price = Price.fetch(@symbol)
+# print "Current price: #{price}\n"
+# if price != lastPrice
+# changed # notify observers
+# lastPrice = price
+# notify_observers(Time.now, price)
+# end
+# sleep 1
+# end
+# end
+# end
+#
+# class Price ### A mock class to fetch a stock price (60 - 140).
+# def Price.fetch(symbol)
+# 60 + rand(80)
+# end
+# end
+#
+# class Warner ### An abstract observer of Ticker objects.
+# def initialize(ticker, limit)
+# @limit = limit
+# ticker.add_observer(self)
+# end
+# end
+#
+# class WarnLow < Warner
+# def update(time, price) # callback for observer
+# if price < @limit
+# print "--- #{time.to_s}: Price below #@limit: #{price}\n"
+# end
+# end
+# end
+#
+# class WarnHigh < Warner
+# def update(time, price) # callback for observer
+# if price > @limit
+# print "+++ #{time.to_s}: Price above #@limit: #{price}\n"
+# end
+# end
+# end
+#
+# ticker = Ticker.new("MSFT")
+# WarnLow.new(ticker, 80)
+# WarnHigh.new(ticker, 120)
+# ticker.run
+#
+# Produces:
+#
+# Current price: 83
+# Current price: 75
+# --- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 75
+# Current price: 90
+# Current price: 134
+# +++ Sun Jun 09 00:10:25 CDT 2002: Price above 120: 134
+# Current price: 134
+# Current price: 112
+# Current price: 79
+# --- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 79
+
+#
+# Implements the Observable design pattern as a mixin so that other objects can
+# be notified of changes in state. See observer.rb for details and an example.
+#
module Observable
+
+ #
+ # Add +observer+ as an observer on this object. +observer+ will now receive
+ # notifications.
+ #
def add_observer(observer)
@observer_peers = [] unless defined? @observer_peers
unless observer.respond_to? :update
- raise NameError, "observer needs to respond to `update'"
+ raise NoMethodError, "observer needs to respond to `update'"
end
@observer_peers.push observer
end
+
+ #
+ # Delete +observer+ as an observer on this object. It will no longer receive
+ # notifications.
+ #
def delete_observer(observer)
@observer_peers.delete observer if defined? @observer_peers
end
+
+ #
+ # Delete all observers associated with this object.
+ #
def delete_observers
@observer_peers.clear if defined? @observer_peers
end
+
+ #
+ # Return the number of observers associated with this object.
+ #
def count_observers
if defined? @observer_peers
@observer_peers.size
@@ -23,9 +153,18 @@ module Observable
0
end
end
+
+ #
+ # Set the changed state of this object. Notifications will be sent only if
+ # the changed +state+ is +true+.
+ #
def changed(state=true)
@observer_state = state
end
+
+ #
+ # Query the changed state of this object.
+ #
def changed?
if defined? @observer_state and @observer_state
true
@@ -33,6 +172,12 @@ module Observable
false
end
end
+
+ #
+ # If this object's changed state is +true+, invoke the update method in each
+ # currently associated observer in turn, passing it the given arguments. The
+ # changed state is then set to +false+.
+ #
def notify_observers(*arg)
if defined? @observer_state and @observer_state
if defined? @observer_peers
@@ -43,4 +188,5 @@ module Observable
@observer_state = false
end
end
+
end
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
new file mode 100644
index 0000000000..8d0353bbc9
--- /dev/null
+++ b/lib/open-uri.rb
@@ -0,0 +1,610 @@
+#= open-uri.rb
+#
+#open-uri.rb is easy-to-use wrapper for net/http and net/ftp.
+#
+#== Example
+#
+#It is possible to open http/ftp URL as usual a file:
+#
+# open("http://www.ruby-lang.org/") {|f|
+# f.each_line {|line| p line}
+# }
+#
+#The opened file has several methods for meta information as follows since
+#it is extended by OpenURI::Meta.
+#
+# open("http://www.ruby-lang.org/en") {|f|
+# f.each_line {|line| p line}
+# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
+# p f.content_type # "text/html"
+# p f.charset # "iso-8859-1"
+# p f.content_encoding # []
+# p f.last_modified # Thu Dec 05 02:45:02 UTC 2002
+# }
+#
+#Additional header fields can be specified by an optional hash argument.
+#
+# open("http://www.ruby-lang.org/en/",
+# "User-Agent" => "Ruby/#{RUBY_VERSION}",
+# "From" => "foo@bar.invalid",
+# "Referer" => "http://www.ruby-lang.org/") {|f|
+# ...
+# }
+#
+#The environment variables such as http_proxy and ftp_proxy are in effect by
+#default. :proxy => nil disables proxy.
+#
+# open("http://www.ruby-lang.org/en/raa.html",
+# :proxy => nil) {|f|
+# ...
+# }
+#
+#URI objects can be opened in similar way.
+#
+# uri = URI.parse("http://www.ruby-lang.org/en/")
+# uri.open {|f|
+# ...
+# }
+#
+#URI objects can be read directly.
+#The returned string is also extended by OpenURI::Meta.
+#
+# str = uri.read
+# p str.base_uri
+#
+#Author:: Tanaka Akira <akr@m17n.org>
+
+require 'uri'
+require 'stringio'
+require 'time'
+
+module Kernel
+ private
+ alias open_uri_original_open open # :nodoc:
+
+ # makes possible to open various resources including URIs.
+ # If the first argument respond to `open' method,
+ # the method is called with the rest arguments.
+ #
+ # If the first argument is a string which begins with xxx://,
+ # it is parsed by URI.parse. If the parsed object respond to `open' method,
+ # the method is called with the rest arguments.
+ #
+ # Otherwise original open is called.
+ #
+ # Since open-uri.rb provides URI::HTTP#open and URI::FTP#open,
+ # Kernel[#.]open can accepts such URIs and strings which begins with
+ # http:// and ftp://. In this http and ftp case, the opened file object
+ # is extended by OpenURI::Meta.
+ def open(name, *rest, &block) # :doc:
+ if name.respond_to?(:open)
+ name.open(*rest, &block)
+ elsif name.respond_to?(:to_str) &&
+ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name &&
+ (uri = URI.parse(name)).respond_to?(:open)
+ uri.open(*rest, &block)
+ else
+ open_uri_original_open(name, *rest, &block)
+ end
+ end
+ module_function :open
+end
+
+module OpenURI
+ Options = {
+ :proxy => true,
+ :progress_proc => true,
+ :content_length_proc => true,
+ }
+
+
+ def OpenURI.check_options(options) # :nodoc:
+ options.each {|k, v|
+ next unless Symbol === k
+ unless Options.include? k
+ raise ArgumentError, "unrecognized option: #{k}"
+ end
+ }
+ end
+
+ def OpenURI.scan_open_optional_arguments(*rest) # :nodoc:
+ if !rest.empty? && (String === rest.first || Integer === rest.first)
+ mode = rest.shift
+ if !rest.empty? && Integer === rest.first
+ perm = rest.shift
+ end
+ end
+ return mode, perm, rest
+ end
+
+ def OpenURI.open_uri(name, *rest) # :nodoc:
+ uri = URI::Generic === name ? name : URI.parse(name)
+ mode, perm, rest = OpenURI.scan_open_optional_arguments(*rest)
+ options = rest.shift if !rest.empty? && Hash === rest.first
+ raise ArgumentError.new("extra arguments") if !rest.empty?
+ options ||= {}
+ OpenURI.check_options(options)
+
+ unless mode == nil ||
+ mode == 'r' || mode == 'rb' ||
+ mode == File::RDONLY
+ raise ArgumentError.new("invalid access mode #{mode} (#{uri.class} resource is read only.)")
+ end
+
+ io = open_loop(uri, options)
+ if block_given?
+ begin
+ yield io
+ ensure
+ io.close
+ end
+ else
+ io
+ end
+ end
+
+ def OpenURI.open_loop(uri, options) # :nodoc:
+ case opt_proxy = options.fetch(:proxy, true)
+ when true
+ find_proxy = lambda {|u| u.find_proxy}
+ when nil, false
+ find_proxy = lambda {|u| nil}
+ when String
+ opt_proxy = URI.parse(opt_proxy)
+ find_proxy = lambda {|u| opt_proxy}
+ when URI::Generic
+ find_proxy = lambda {|u| opt_proxy}
+ else
+ raise ArgumentError.new("Invalid proxy option: #{opt_proxy}")
+ end
+
+ uri_set = {}
+ buf = nil
+ while true
+ redirect = catch(:open_uri_redirect) {
+ buf = Buffer.new
+ if proxy_uri = find_proxy.call(uri)
+ proxy_uri.proxy_open(buf, uri, options)
+ else
+ uri.direct_open(buf, options)
+ end
+ nil
+ }
+ if redirect
+ if redirect.relative?
+ # Although it violates RFC2616, Location: field may have relative
+ # URI. It is converted to absolute URI using uri as a base URI.
+ redirect = uri + redirect
+ end
+ unless OpenURI.redirectable?(uri, redirect)
+ raise "redirection forbidden: #{uri} -> #{redirect}"
+ end
+ uri = redirect
+ raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s
+ uri_set[uri.to_s] = true
+ else
+ break
+ end
+ end
+ io = buf.io
+ io.base_uri = uri
+ io
+ end
+
+ def OpenURI.redirectable?(uri1, uri2) # :nodoc:
+ # This test is intended to forbid a redirection from http://... to
+ # file:///etc/passwd.
+ # However this is ad hoc. It should be extensible/configurable.
+ uri1.scheme.downcase == uri2.scheme.downcase ||
+ (/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:http|ftp)\z/i =~ uri2.scheme)
+ end
+
+ class HTTPError < StandardError
+ def initialize(message, io)
+ super(message)
+ @io = io
+ end
+ attr_reader :io
+ end
+
+ class Buffer # :nodoc:
+ def initialize
+ @io = StringIO.new
+ @size = 0
+ end
+ attr_reader :size
+
+ StringMax = 10240
+ def <<(str)
+ @io << str
+ @size += str.length
+ if StringIO === @io && StringMax < @size
+ require 'tempfile'
+ io = Tempfile.new('open-uri')
+ io.binmode
+ Meta.init io, @io if Meta === @io
+ io << @io.string
+ @io = io
+ end
+ end
+
+ def io
+ Meta.init @io unless Meta === @io
+ @io
+ end
+ end
+
+ # Mixin for holding meta-information.
+ module Meta
+ def Meta.init(obj, src=nil) # :nodoc:
+ obj.extend Meta
+ obj.instance_eval {
+ @base_uri = nil
+ @meta = {}
+ }
+ if src
+ obj.status = src.status
+ obj.base_uri = src.base_uri
+ src.meta.each {|name, value|
+ obj.meta_add_field(name, value)
+ }
+ end
+ end
+
+ # returns an Array which consists status code and message.
+ attr_accessor :status
+
+ # returns a URI which is base of relative URIs in the data.
+ # It may differ from the URI supplied by a user because redirection.
+ attr_accessor :base_uri
+
+ # returns a Hash which represents header fields.
+ # The Hash keys are downcased for canonicalization.
+ attr_reader :meta
+
+ def meta_add_field(name, value) # :nodoc:
+ @meta[name.downcase] = value
+ end
+
+ # returns a Time which represents Last-Modified field.
+ def last_modified
+ if v = @meta['last-modified']
+ Time.httpdate(v)
+ else
+ nil
+ end
+ end
+
+ RE_LWS = /[\r\n\t ]+/n
+ RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n
+ RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])"}n
+ RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n
+
+ def content_type_parse # :nodoc:
+ v = @meta['content-type']
+ # The last (?:;#{RE_LWS}?)? matches extra ";" which violates RFC2045.
+ if v && %r{\A#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?/(#{RE_TOKEN})#{RE_LWS}?(#{RE_PARAMETERS})(?:;#{RE_LWS}?)?\z}no =~ v
+ type = $1.downcase
+ subtype = $2.downcase
+ parameters = []
+ $3.scan(/;#{RE_LWS}?(#{RE_TOKEN})#{RE_LWS}?=#{RE_LWS}?(?:(#{RE_TOKEN})|(#{RE_QUOTED_STRING}))/no) {|att, val, qval|
+ val = qval.gsub(/[\r\n\t !#-\[\]-~\x80-\xff]+|(\\[\x00-\x7f])/) { $1 ? $1[1,1] : $& } if qval
+ parameters << [att.downcase, val]
+ }
+ ["#{type}/#{subtype}", *parameters]
+ else
+ nil
+ end
+ end
+
+ # returns "type/subtype" which is MIME Content-Type.
+ # It is downcased for canonicalization.
+ # Content-Type parameters are stripped.
+ def content_type
+ type, *parameters = content_type_parse
+ type || 'application/octet-stream'
+ end
+
+ # returns a charset parameter in Content-Type field.
+ # It is downcased for canonicalization.
+ #
+ # If charset parameter is not given but a block is given,
+ # the block is called and its result is returned.
+ # It can be used to guess charset.
+ #
+ # If charset parameter and block is not given,
+ # nil is returned except text type in HTTP.
+ # In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1.
+ def charset
+ type, *parameters = content_type_parse
+ if pair = parameters.assoc('charset')
+ pair.last.downcase
+ elsif block_given?
+ yield
+ elsif type && %r{\Atext/} =~ type &&
+ @base_uri && /\Ahttp\z/i =~ @base_uri.scheme
+ "iso-8859-1" # RFC2616 3.7.1
+ else
+ nil
+ end
+ end
+
+ # returns a list of encodings in Content-Encoding field
+ # as an Array of String.
+ # The encodings are downcased for canonicalization.
+ def content_encoding
+ v = @meta['content-encoding']
+ if v && %r{\A#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?(?:,#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?)*}o =~ v
+ v.scan(RE_TOKEN).map {|content_coding| content_coding.downcase}
+ else
+ []
+ end
+ end
+ end
+
+ # Mixin for HTTP and FTP URIs.
+ module OpenRead
+ # OpenURI::OpenRead#open provides `open' for URI::HTTP and URI::FTP.
+ #
+ # OpenURI::OpenRead#open takes optional 3 arguments as:
+ # OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }]
+ #
+ # `mode', `perm' is same as Kernel#open.
+ #
+ # However, `mode' must be read mode because OpenURI::OpenRead#open doesn't
+ # support write mode (yet).
+ # Also `perm' is just ignored because it is meaningful only for file
+ # creation.
+ #
+ # `options' must be a hash.
+ #
+ # Each pairs which key is a string in the hash specify a extra header
+ # field for HTTP.
+ # I.e. it is ignored for FTP without HTTP proxy.
+ #
+ # The hash may include other option which key is a symbol:
+ #
+ # :proxy => "http://proxy.foo.com:8000/"
+ # :proxy => URI.parse("http://proxy.foo.com:8000/")
+ # :proxy => true
+ # :proxy => false
+ # :proxy => nil
+ #
+ # If :proxy option is specified, the value should be String, URI,
+ # boolean or nil.
+ # When String or URI is given, it is treated as proxy URI.
+ # When true is given or the option itself is not specified,
+ # environment variable `scheme_proxy'(or `SCHEME_PROXY') is examined.
+ # `scheme' is replaced by `http' or `ftp'.
+ # When false or nil is given, the environment variables are ignored and
+ # connection will be made to a server directly.
+ #
+ # :content_length_proc => lambda {|content_length| ... }
+ #
+ # If :content_length_proc option is specified, the option value procedure
+ # is called before actual transfer is started.
+ # It takes one argument which is expected content length in bytes.
+ #
+ # If two or more transfer is done by HTTP redirection, the procedure
+ # is called only one for a last transfer.
+ #
+ # When expected content length is unknown, the procedure is called with
+ # nil.
+ # It is happen when HTTP response has no Content-Length header.
+ #
+ # :progress_proc => lambda {|size| ...}
+ #
+ # If :progress_proc option is specified, the proc is called with one
+ # argument each time when `open' gets content fragment from network.
+ # The argument `size' `size' is a accumulated transfered size in bytes.
+ #
+ # If two or more transfer is done by HTTP redirection, the procedure
+ # is called only one for a last transfer.
+ #
+ # :progress_proc and :content_length_proc are intended to be used for
+ # progress bar.
+ # For example, it can be implemented as follows using Ruby/ProgressBar.
+ #
+ # pbar = nil
+ # open("http://...",
+ # :content_length_proc => lambda {|t|
+ # if t && 0 < t
+ # pbar = ProgressBar.new("...", t)
+ # pbar.file_transfer_mode
+ # end
+ # },
+ # :progress_proc => lambda {|s|
+ # pbar.set s if pbar
+ # }) {|f| ... }
+ #
+ # OpenURI::OpenRead#open returns an IO like object if block is not given.
+ # Otherwise it yields the IO object and return the value of the block.
+ # The IO object is extended with OpenURI::Meta.
+ def open(*rest, &block)
+ OpenURI.open_uri(self, *rest, &block)
+ end
+
+ # OpenURI::OpenRead#read([options]) reads a content referenced by self and
+ # returns the content as string.
+ # The string is extended with OpenURI::Meta.
+ # The argument `options' is same as OpenURI::OpenRead#open.
+ def read(options={})
+ self.open(options) {|f|
+ str = f.read
+ Meta.init str, f
+ str
+ }
+ end
+ end
+end
+
+module URI
+ class Generic
+ # returns a proxy URI.
+ # The proxy URI is obtained from environment variables such as http_proxy,
+ # ftp_proxy, no_proxy, etc.
+ # If there is no proper proxy, nil is returned.
+ #
+ # Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.)
+ # are examined too.
+ #
+ # But http_proxy and HTTP_PROXY is treated specially under CGI environment.
+ # It's because HTTP_PROXY may be set by Proxy: header.
+ # So HTTP_PROXY is not used.
+ # http_proxy is not used too if the variable is case insensitive.
+ # CGI_HTTP_PROXY can be used instead.
+ def find_proxy
+ name = self.scheme.downcase + '_proxy'
+ proxy_uri = nil
+ if name == 'http_proxy' && ENV.include?('REQUEST_METHOD') # CGI?
+ # HTTP_PROXY conflicts with *_proxy for proxy settings and
+ # HTTP_* for header information in CGI.
+ # So it should be careful to use it.
+ pairs = ENV.reject {|k, v| /\Ahttp_proxy\z/i !~ k }
+ case pairs.length
+ when 0 # no proxy setting anyway.
+ proxy_uri = nil
+ when 1
+ k, v = pairs.shift
+ if k == 'http_proxy' && ENV[k.upcase] == nil
+ # http_proxy is safe to use because ENV is case sensitive.
+ proxy_uri = ENV[name]
+ else
+ proxy_uri = nil
+ end
+ else # http_proxy is safe to use because ENV is case sensitive.
+ proxy_uri = ENV[name]
+ end
+ if !proxy_uri
+ # Use CGI_HTTP_PROXY. cf. libwww-perl.
+ proxy_uri = ENV["CGI_#{name.upcase}"]
+ end
+ elsif name == 'http_proxy'
+ unless proxy_uri = ENV[name]
+ if proxy_uri = ENV[name.upcase]
+ warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.'
+ end
+ end
+ else
+ proxy_uri = ENV[name] || ENV[name.upcase]
+ end
+
+ if proxy_uri && self.host
+ require 'socket'
+ begin
+ addr = IPSocket.getaddress(self.host)
+ proxy_uri = nil if /\A127\.|\A::1\z/ =~ addr
+ rescue SocketError
+ end
+ end
+
+ if proxy_uri
+ proxy_uri = URI.parse(proxy_uri)
+ unless URI::HTTP === proxy_uri
+ raise "Non-HTTP proxy URI: #{proxy_uri}"
+ end
+ name = 'no_proxy'
+ if no_proxy = ENV[name] || ENV[name.upcase]
+ no_proxy.scan(/([^:,]*)(?::(\d+))?/) {|host, port|
+ if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host &&
+ (!port || self.port == port.to_i)
+ proxy_uri = nil
+ break
+ end
+ }
+ end
+ proxy_uri
+ else
+ nil
+ end
+ end
+ end
+
+ class HTTP
+ def direct_open(buf, options) # :nodoc:
+ proxy_open(buf, request_uri, options)
+ end
+
+ def proxy_open(buf, uri, options) # :nodoc:
+ header = {}
+ options.each {|k, v| header[k] = v if String === k }
+
+ if uri.respond_to? :host
+ # According to RFC2616 14.23, Host: request-header field should be set
+ # an origin server.
+ # But net/http wrongly set a proxy server if an absolute URI is
+ # specified as a request URI.
+ # So open-uri override it here explicitly.
+ header['host'] = uri.host
+ header['host'] += ":#{uri.port}" if uri.port
+ end
+
+ require 'net/http'
+ resp = nil
+ Net::HTTP.start(self.host, self.port) {|http|
+ http.request_get(uri.to_s, header) {|response|
+ resp = response
+ if options[:content_length_proc] && Net::HTTPSuccess === resp
+ if resp.key?('Content-Length')
+ options[:content_length_proc].call(resp['Content-Length'].to_i)
+ else
+ options[:content_length_proc].call(nil)
+ end
+ end
+ resp.read_body {|str|
+ buf << str
+ if options[:progress_proc] && Net::HTTPSuccess === resp
+ options[:progress_proc].call(buf.size)
+ end
+ }
+ }
+ }
+ io = buf.io
+ io.rewind
+ io.status = [resp.code, resp.message]
+ resp.each {|name,value| buf.io.meta_add_field name, value }
+ case resp
+ when Net::HTTPSuccess
+ when Net::HTTPMovedPermanently, # 301
+ Net::HTTPFound, # 302
+ Net::HTTPSeeOther, # 303
+ Net::HTTPTemporaryRedirect # 307
+ throw :open_uri_redirect, URI.parse(resp['location'])
+ else
+ raise OpenURI::HTTPError.new(io.status.join(' '), io)
+ end
+ end
+
+ include OpenURI::OpenRead
+ end
+
+ class HTTPS
+ def proxy_open(buf, uri, options) # :nodoc:
+ raise ArgumentError, "open-uri doesn't support https."
+ end
+ end
+
+ class FTP
+ def direct_open(buf, options) # :nodoc:
+ require 'net/ftp'
+ # todo: extract user/passwd from .netrc.
+ user = 'anonymous'
+ passwd = nil
+ user, passwd = self.userinfo.split(/:/) if self.userinfo
+
+ ftp = Net::FTP.open(self.host)
+ ftp.login(user, passwd)
+ if options[:content_length_proc]
+ options[:content_length_proc].call(ftp.size(self.path))
+ end
+ ftp.getbinaryfile(self.path, '/dev/null', Net::FTP::DEFAULT_BLOCKSIZE) {|str|
+ buf << str
+ options[:progress_proc].call(buf.size) if options[:progress_proc]
+ }
+ ftp.close
+ buf.io.rewind
+ end
+
+ include OpenURI::OpenRead
+ end
+end
diff --git a/lib/open3.rb b/lib/open3.rb
index 58de740393..407cd7662c 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -1,11 +1,14 @@
+# open3.rb: Spawn a program like popen, but with stderr, too. You might also
+# want to use this if you want to bypass the shell. (By passing multiple args,
+# which IO#popen does not allow)
+#
# Usage:
# require "open3"
#
-# in, out, err = Open3.popen3('nroff -man')
+# stdin, stdout, stderr = Open3.popen3('nroff -man')
# or
# include Open3
-# in, out, err = popen3('nroff -man')
-#
+# stdin, stdout, stderr = popen3('nroff -man')
module Open3
#[stdin, stdout, stderr] = popen3(command);
@@ -32,6 +35,7 @@ module Open3
exec(*cmd)
}
+ exit!
}
pw[0].close
@@ -39,6 +43,7 @@ module Open3
pe[1].close
Process.waitpid(pid)
pi = [pw[1], pr[0], pe[0]]
+ pw[1].sync = true
if defined? yield
begin
return yield(*pi)
diff --git a/lib/optparse.rb b/lib/optparse.rb
new file mode 100644
index 0000000000..63cf1d79f0
--- /dev/null
+++ b/lib/optparse.rb
@@ -0,0 +1,1796 @@
+#
+# optparse.rb - command-line option analysis with the OptionParser class.
+#
+# Author:: Nobu Nakada
+# Documentation:: Nobu Nakada and Gavin Sinclair.
+#
+# See OptionParser for documentation.
+#
+
+
+# == Developer Documentation (not for RDoc output)
+#
+# === Class tree
+#
+# - OptionParser:: front end
+# - OptionParser::Switch:: each switches
+# - OptionParser::List:: options list
+# - OptionParser::ParseError:: errors on parsing
+# - OptionParser::AmbiguousOption
+# - OptionParser::NeedlessArgument
+# - OptionParser::MissingArgument
+# - OptionParser::InvalidOption
+# - OptionParser::InvalidArgument
+# - OptionParser::AmbiguousArgument
+#
+# === Object relationship diagram
+#
+# +--------------+
+# | OptionParser |<>-----+
+# +--------------+ | +--------+
+# | ,-| Switch |
+# on_head -------->+---------------+ / +--------+
+# accept/reject -->| List |<|>-
+# | |<|>- +----------+
+# on ------------->+---------------+ `-| argument |
+# : : | class |
+# +---------------+ |==========|
+# on_tail -------->| | |pattern |
+# +---------------+ |----------|
+# OptionParser.accept ->| DefaultList | |converter |
+# reject |(shared between| +----------+
+# | all instances)|
+# +---------------+
+
+
+#
+# == OptionParser
+#
+# === Introduction
+#
+# OptionParser is a class for command-line option analysis. It is much more
+# advanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented
+# solution.
+#
+# === Features
+#
+# 1. The argument specification and the code to handle it are written in the same
+# place.
+# 2. It can output an option summary; you don't need to maintain this string
+# separately.
+# 3. Optional and mandatory arguments are specified very gracefully.
+# 4. Arguments can be automatically converted to a specified class.
+# 5. Arguments can be restricted to a certain set.
+#
+# All of these features are demonstrated in the example below.
+#
+# === Example
+#
+# The following example is a complete Ruby program. You can run it and see the
+# effect of specifying various options. This is probably the best way to learn
+# the features of +optparse+.
+#
+# require 'optparse'
+# require 'optparse/time'
+# require 'ostruct'
+# require 'pp'
+#
+# class OptparseExample
+#
+# CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
+# CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
+#
+# #
+# # Return a structure describing the options.
+# #
+# def self.parse(args)
+# # The options specified on the command line will be collected in *options*.
+# # We set default values here.
+# options = OpenStruct.new
+# options.library = []
+# options.inplace = false
+# options.encoding = "utf8"
+# options.transfer_type = :auto
+# options.verbose = false
+#
+# opts = OptionParser.new do |opts|
+# opts.banner = "Usage: example.rb [options]"
+#
+# opts.separator ""
+# opts.separator "Specific options:"
+#
+# # Mandatory argument.
+# opts.on("-r", "--require LIBRARY",
+# "Require the LIBRARY before executing your script") do |lib|
+# options.library << lib
+# end
+#
+# # Optional argument; multi-line description.
+# opts.on("-i", "--inplace [EXTENSION]",
+# "Edit ARGV files in place",
+# " (make backup if EXTENSION supplied)") do |ext|
+# options.inplace = true
+# options.extension = ext || ''
+# options.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
+# end
+#
+# # Cast 'delay' argument to a Float.
+# opts.on("--delay N", Float, "Delay N seconds before executing") do |n|
+# options.delay = n
+# end
+#
+# # Cast 'time' argument to a Time object.
+# opts.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
+# options.time = time
+# end
+#
+# # Cast to octal integer.
+# opts.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
+# "Specify record separator (default \\0)") do |rs|
+# options.record_separator = rs
+# end
+#
+# # List of arguments.
+# opts.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
+# options.list = list
+# end
+#
+# # Keyword completion. We are specifying a specific set of arguments (CODES
+# # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
+# # the shortest unambiguous text.
+# code_list = (CODE_ALIASES.keys + CODES).join(',')
+# opts.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
+# " (#{code_list})") do |encoding|
+# options.encoding = encoding
+# end
+#
+# # Optional argument with keyword completion.
+# opts.on("--type [TYPE]", [:text, :binary, :auto],
+# "Select transfer type (text, binary, auto)") do |t|
+# options.transfer_type = t
+# end
+#
+# # Boolean switch.
+# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
+# options.verbose = v
+# end
+#
+# opts.separator ""
+# opts.separator "Common options:"
+#
+# # No argument, shows at tail. This will print an options summary.
+# # Try it and see!
+# opts.on_tail("-h", "--help", "Show this message") do
+# puts opts
+# exit
+# end
+#
+# # Another typical switch to print the version.
+# opts.on_tail("--version", "Show version") do
+# puts OptionParser::Version.join('.')
+# exit
+# end
+# end
+#
+# opts.parse!(args)
+# options
+# end # parse()
+#
+# end # class OptparseExample
+#
+# options = OptparseExample.parse(ARGV)
+# pp options
+#
+# Note: some bugs were fixed between 1.8.0 and 1.8.1. If you experience trouble
+# with the above code, keep this in mind.
+#
+# === Further documentation
+#
+# The methods are not individually documented at this stage. The above example
+# should be enough to learn how to use this class. If you have any questions,
+# email me (gsinclair@soyabean.com.au) and I will update this document.
+#
+class OptionParser
+ # :stopdoc:
+ RCSID = %w$Id$[1..-1].each {|s| s.freeze}.freeze
+ Version = (RCSID[1].split('.').collect {|s| s.to_i}.extend(Comparable).freeze if RCSID[1])
+ LastModified = (Time.gm(*RCSID[2, 2].join('-').scan(/\d+/).collect {|s| s.to_i}) if RCSID[2])
+ Release = RCSID[2]
+
+ NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
+ RequiredArgument = [REQUIRED_ARGUMENT = :REQUIRED, true].freeze
+ OptionalArgument = [OPTIONAL_ARGUMENT = :OPTIONAL, false].freeze
+ # :startdoc:
+
+ #
+ # Keyword completion module. This allows partial arguments to be specified
+ # and resolved against a list of acceptable values.
+ #
+ module Completion
+ def complete(key, pat = nil)
+ pat ||= Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'),
+ ignore_case?)
+ canon, sw, k, v, cn = nil
+ candidates = []
+ each do |k, *v|
+ (if Regexp === k
+ kn = nil
+ k === key
+ else
+ kn = defined?(k.id2name) ? k.id2name : k
+ pat === kn
+ end) or next
+ v << k if v.empty?
+ candidates << [k, v, kn]
+ end
+ candidates = candidates.sort_by {|k, v, kn| kn.size}
+ if candidates.size == 1
+ canon, sw, * = candidates[0]
+ elsif candidates.size > 1
+ canon, sw, cn = candidates.shift
+ candidates.each do |k, v, kn|
+ next if sw == v
+ if String === cn and String === kn
+ if cn.rindex(kn, 0)
+ canon, sw, cn = k, v, kn
+ next
+ elsif kn.rindex(cn, 0)
+ next
+ end
+ end
+ throw :ambiguous, key
+ end
+ end
+ if canon
+ block_given? or return key, *sw
+ yield(key, *sw)
+ end
+ end
+
+ def convert(opt = nil, val = nil, *)
+ val
+ end
+
+ def ignore_case?
+ false
+ end
+ end
+
+
+ #
+ # Map from option/keyword string to object with completion.
+ #
+ class OptionMap < Hash
+ include Completion
+ end
+ class OptionCaseMap < OptionMap
+ def ignore_case?
+ true
+ end
+ end
+
+
+ #
+ # Individual switch class. Not important to the user.
+ #
+ # Defined within Switch are several Switch-derived classes: NoArgument,
+ # RequiredArgument, etc.
+ #
+ class Switch
+ attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block
+
+ #
+ # Guesses argument style from +arg+. Returns corresponding
+ # OptionParser::Switch class (OptionalArgument, etc.).
+ #
+ def self.guess(arg)
+ case arg
+ when ""
+ t = self
+ when /\A=?\[/
+ t = Switch::OptionalArgument
+ when /\A\s+\[/
+ t = Switch::PlacedArgument
+ else
+ t = Switch::RequiredArgument
+ end
+ self >= t or incompatible_argument_styles(arg, t)
+ t
+ end
+
+ def self.incompatible_argument_styles(arg, t)
+ raise ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}"
+ end
+
+ def self.pattern
+ NilClass
+ end
+
+ def initialize(pattern = nil, conv = nil,
+ short = nil, long = nil, arg = nil,
+ desc = ([] if short or long), block = Proc.new)
+ raise if Array === pattern
+ @pattern, @conv, @short, @long, @arg, @desc, @block =
+ pattern, conv, short, long, arg, desc, block
+ end
+
+ #
+ # OptionParser::Switch#parse_arg(arg) {non-serious error handler}
+ #
+ # Parses argument and returns rest of ((|arg|)), and matched portion
+ # to the argument pattern.
+ # :Parameters:
+ # : ((|arg|))
+ # option argument to be parsed.
+ # : (({block}))
+ # yields when the pattern doesn't match sub-string.
+ #
+ def parse_arg(arg)
+ pattern or return nil, arg
+ unless m = pattern.match(arg)
+ yield(InvalidArgument, arg)
+ return arg, nil
+ end
+ if String === m
+ m = [s = m]
+ else
+ m = m.to_a
+ s = m[0]
+ return nil, m unless String === s
+ end
+ raise InvalidArgument, arg unless arg.rindex(s, 0)
+ return nil, m if s.length == arg.length
+ yield(InvalidArgument, arg) # didn't match whole arg
+ return arg[s.length..-1], m
+ end
+ private :parse_arg
+
+ #
+ # OptionParser::Switch#conv_arg(arg, val) {semi-error handler}
+ #
+ # Parses argument, convert and returns ((|arg|)), ((|block|)) and
+ # result of conversion.
+ # : Arguments to ((|@conv|))
+ # substrings matched to ((|@pattern|)), ((|$&|)), ((|$1|)),
+ # ((|$2|)) and so on.
+ # :Parameters:
+ # : ((|arg|))
+ # argument string follows the switch.
+ # : ((|val|))
+ # following argument.
+ # : (({block}))
+ # (({yields})) at semi-error condition, instead of raises exception.
+ #
+ def conv_arg(arg, val = nil)
+ if block
+ if conv
+ val = conv.call(*val)
+ else
+ val = *val
+ end
+ return arg, block, val
+ else
+ return arg, nil
+ end
+ end
+ private :conv_arg
+
+ #
+ # OptionParser::Switch#summarize(sdone, ldone, width, max, indent)
+ #
+ # Makes summary strings.
+ # :Parameters:
+ # : ((|sdone|))
+ # already summarized short style options keyed hash.
+ # : ((|ldone|))
+ # already summarized long style options keyed hash.
+ # : ((|width|))
+ # width of left side, option part. in other word, right side,
+ # description part strings start at ((|width|)) column.
+ # : ((|max|))
+ # maximum width of left side, options are filled within ((|max|)) columns.
+ # : ((|indent|))
+ # prefix string indents each summarized lines.
+ # : (({block}))
+ # to be passed each lines(without newline).
+ #
+ def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "")
+ sopts, lopts, s = [], [], nil
+ @short.each {|s| sdone.fetch(s) {sopts << s}; sdone[s] = true} if @short
+ @long.each {|s| ldone.fetch(s) {lopts << s}; ldone[s] = true} if @long
+ return if sopts.empty? and lopts.empty? # completely hidden
+
+ left = [sopts.join(', ')]
+ right = desc.dup
+
+ while s = lopts.shift
+ l = left[-1].length + s.length
+ l += arg.length if left.size == 1 && arg
+ l < max or left << ''
+ left[-1] << if left[-1].empty? then ' ' * 4 else ', ' end << s
+ end
+
+ left[0] << arg if arg
+ mlen = left.collect {|s| s.length}.max.to_i
+ while mlen > width and l = left.shift
+ mlen = left.collect {|s| s.length}.max.to_i if l.length == mlen
+ yield(indent + l)
+ end
+
+ while (l = left.shift; r = right.shift; l or r)
+ l = l.to_s.ljust(width) + ' ' + r if r and !r.empty?
+ yield(indent + l)
+ end
+
+ self
+ end
+
+ #
+ # Switch that takes no arguments.
+ #
+ class NoArgument < self
+ #
+ # Raises an exception if any arguments given.
+ #
+ def parse(arg, argv, &error)
+ yield(NeedlessArgument, arg) if arg
+ conv_arg(arg)
+ end
+ def self.incompatible_argument_styles(*)
+ end
+ def self.pattern
+ Object
+ end
+ end
+
+ #
+ # Switch that takes an argument.
+ #
+ class RequiredArgument < self
+ #
+ # Raises an exception if argument is not present.
+ #
+ def parse(arg, argv, &error)
+ unless arg
+ raise MissingArgument if argv.empty?
+ arg = argv.shift
+ end
+ conv_arg(*parse_arg(arg, &error))
+ end
+ end
+
+ #
+ # Switch that can omit argument.
+ #
+ class OptionalArgument < self
+ #
+ # Parses argument if given, or uses default value.
+ #
+ def parse(arg, argv, &error)
+ if arg
+ conv_arg(*parse_arg(arg, &error))
+ else
+ conv_arg(arg)
+ end
+ end
+ end
+
+ #
+ # ?
+ #
+ class PlacedArgument < self
+ #
+ # ?
+ #
+ def parse(arg, argv, &error)
+ if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
+ return nil, block, nil
+ end
+ opt = (val = parse_arg(val, &error))[1]
+ val = conv_arg(*val)
+ if opt and !arg
+ argv.shift
+ else
+ val[0] = nil
+ end
+ val
+ end
+ end
+ end
+
+ #
+ # Simple option list providing mapping from short and/or long option
+ # string to ((<OptionParser::Switch>)), and mapping from acceptable
+ # argument to matching pattern and converter pair. Also provides
+ # summary feature.
+ #
+ class List
+ # Map from acceptable argument types to pattern and converter pairs.
+ attr_reader :atype
+
+ # Map from short style option switches to actual switch objects.
+ attr_reader :short
+
+ # Map from long style option switches to actual switch objects.
+ attr_reader :long
+
+ # List of all switches and summary string.
+ attr_reader :list
+
+ #
+ # Just initializes all instance variables.
+ #
+ def initialize
+ @atype = {}
+ @short = OptionMap.new
+ @long = OptionCaseMap.new
+ @list = []
+ end
+
+ #
+ # See OptionParser.accept.
+ #
+ def accept(t, pat = /.*/, &block)
+ if pat
+ pat.respond_to?(:match) or raise TypeError, "has no `match'"
+ else
+ pat = t if t.respond_to?(:match)
+ end
+ unless block
+ block = pat.method(:convert).to_proc if pat.respond_to?(:convert)
+ end
+ @atype[t] = [pat, block]
+ end
+
+ #
+ # See OptionParser.reject.
+ #
+ def reject(t)
+ @atype.delete(t)
+ end
+
+ #
+ # OptionParser::List#update(sw, sopts, lopts, nlopts = nil)
+ #
+ # Adds ((|sw|)) according to ((|sopts|)), ((|lopts|)) and
+ # ((|nlopts|)).
+ # :Parameters:
+ # : ((|sw|))
+ # ((<OptionParser::Switch>)) instance to be added.
+ # : ((|sopts|))
+ # short style options list.
+ # : ((|lopts|))
+ # long style options list.
+ # : ((|nlopts|))
+ # negated long style options list.
+ #
+ def update(sw, sopts, lopts, nsw = nil, nlopts = nil)
+ o = nil
+ sopts.each {|o| @short[o] = sw} if sopts
+ lopts.each {|o| @long[o] = sw} if lopts
+ nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
+ used = @short.invert.update(@long.invert)
+ @list.delete_if {|o| Switch === o and !used[o]}
+ end
+ private :update
+
+ #
+ # OptionParser::List#prepend(switch, short_opts, long_opts, nolong_opts)
+ #
+ # Inserts ((|switch|)) at head of the list, and associates short,
+ # long and negated long options.
+ def prepend(*args)
+ update(*args)
+ @list.unshift(args[0])
+ end
+
+ #
+ # OptionParser::List#append(switch, short_opts, long_opts, nolong_opts)
+ #
+ # Appends ((|switch|)) at tail of the list, and associates short,
+ # long and negated long options.
+ # :Parameters:
+ # : ((|switch|))
+ # ((<OptionParser::Switch>)) instance to be inserted.
+ # : ((|short_opts|))
+ # list of short style options.
+ # : ((|long_opts|))
+ # list of long style options.
+ # : ((|nolong_opts|))
+ # list of long style options with (({"no-"})) prefix.
+ def append(*args)
+ update(*args)
+ @list.push(args[0])
+ end
+
+ #
+ # OptionParser::List#search(id, key) [{block}]
+ #
+ # Searches ((|key|)) in ((|id|)) list.
+ # :Parameters:
+ # : ((|id|))
+ # searching list.
+ # : ((|k|))
+ # searching key.
+ # : (({block}))
+ # yielded with the found value when succeeded.
+ #
+ def search(id, key)
+ if list = __send__(id)
+ val = list.fetch(key) {return nil}
+ return val unless block_given?
+ yield(val)
+ end
+ end
+
+ #
+ # OptionParser::List#complete(id, opt, *pat, &block)
+ #
+ # Searches list ((|id|)) for ((|opt|)) and ((|*pat|)).
+ # :Parameters:
+ # : ((|id|))
+ # searching list.
+ # : ((|opt|))
+ # searching key.
+ # : ((|*pat|))
+ # optional pattern for completion.
+ # : (({block}))
+ # yielded with the found value when succeeded.
+ #
+ def complete(id, opt, *pat, &block)
+ __send__(id).complete(opt, *pat, &block)
+ end
+
+ #
+ # OptionParser::List#summarize(*args) {...}
+ #
+ # Making summary table, yields the (({block})) with each lines.
+ # Each elements of (({@list})) should be able to (({summarize})).
+ # :Parameters:
+ # : ((|args|))
+ # passed to elements#summarize through.
+ # : (({block}))
+ # to be passed each lines(without newline).
+ #
+ def summarize(*args, &block)
+ list.each do |opt|
+ if opt.respond_to?(:summarize) # perhaps OptionParser::Switch
+ opt.summarize(*args, &block)
+ elsif opt.empty?
+ yield("")
+ else
+ opt.each(&block)
+ end
+ end
+ end
+ end
+
+ #
+ # Hash with completion search feature. See Completion module.
+ #
+ class CompletingHash < Hash
+ include Completion
+
+ #
+ # OptionParser::CompletingHash#match(key)
+ #
+ # Completion for hash key.
+ #
+ def match(key)
+ return key, *fetch(key) {
+ raise AmbiguousArgument, catch(:ambiguous) {return complete(key)}
+ }
+ end
+ end
+
+ #
+ # OptionParser::ArgumentStyle
+ # Enumeration of acceptable argument styles; possible values are:
+ # : OptionParser::NO_ARGUMENT
+ # the switch takes no arguments. ((({:NONE})))
+ # : OptionParser::REQUIRED_ARGUMENT
+ # the switch requires an argument. ((({:REQUIRED})))
+ # : OptionParser::OPTIONAL_ARGUMENT
+ # the switch requires an optional argument, that is, may take or
+ # not. ((({:OPTIONAL})))
+ #
+ # Use like (({--switch=argument}))(long style) or
+ # (({-Xargument}))(short style). For short style, only portion
+ # matched to ((<argument pattern>)) is dealed as argument.
+ #
+
+ # :stopdoc:
+ ArgumentStyle = {}
+ NoArgument.each {|el| ArgumentStyle[el] = Switch::NoArgument}
+ RequiredArgument.each {|el| ArgumentStyle[el] = Switch::RequiredArgument}
+ OptionalArgument.each {|el| ArgumentStyle[el] = Switch::OptionalArgument}
+ ArgumentStyle.freeze
+
+ #
+ # OptionParser::DefaultList
+ #
+ # Switches common used such as '--', and also provides default
+ # argument classes
+ #
+
+ DefaultList = List.new
+ DefaultList.short['-'] = Switch::NoArgument.new {}
+ DefaultList.long[''] = Switch::NoArgument.new {throw :terminate}
+
+ #
+ # Default options, which never appear in option summary.
+ # --help
+ # Shows option summary.
+ # --version
+ # Shows version string if (({::Version})) is defined.
+ #
+ DefaultList.long['help'] = Switch::NoArgument.new do
+ puts ARGV.options
+ exit
+ end
+ DefaultList.long['version'] = Switch::OptionalArgument.new do |pkg|
+ if pkg
+ begin
+ require 'optparse/version'
+ rescue LoadError
+ pkg = nil
+ else
+ show_version(*pkg.split(/,/))
+ end
+ end
+ unless pkg
+ v = ARGV.options.ver and puts v
+ end
+ exit
+ end
+
+ # :startdoc:
+
+ #
+ # Class methods
+ #
+
+=begin
+--- OptionParser.with([banner[, width[, indent]]]) [{...}]
+ Initializes new instance, and evaluates the block in context of
+ the instance if called as iterator. This behavior is equivalent
+ to older (({new})). This is ((*deprecated*)) method.
+
+ cf. ((<OptionParser.new>))
+ :Parameters:
+ : ((|banner|))
+ banner message.
+ : ((|width|))
+ summary width.
+ : ((|indent|))
+ summary indent.
+ : (({block}))
+ to be evaluated in the new instance context.
+=end #'#"#`#
+ def self.with(*args, &block)
+ opts = new(*args)
+ opts.instance_eval(&block)
+ opts
+ end
+
+=begin
+--- OptionParser.inc(arg[, default])
+--- OptionParser#inc(arg[, default])
+ Returns incremented value of ((|default|)) according to ((|arg|)).
+=end
+ def self.inc(arg, default = nil)
+ case arg
+ when Integer
+ arg.nonzero?
+ when nil
+ default.to_i + 1
+ end
+ end
+ def inc(*args)
+ self.class.inc(*args)
+ end
+
+=begin
+--- OptionParser.new([banner[, width[, indent]]]) [{...}]
+ Initializes the instance, and yields itself if called as iterator.
+ :Parameters:
+ : ((|banner|))
+ banner message.
+ : ((|width|))
+ summary width.
+ : ((|indent|))
+ summary indent.
+ : (({block}))
+ to be evaluated in the new instance context.
+=end #'#"#`#
+ def initialize(banner = nil, width = 32, indent = ' ' * 4)
+ @stack = [DefaultList, List.new, List.new]
+ @program_name = nil
+ @banner = banner
+ @summary_width = width
+ @summary_indent = indent
+ yield self if block_given?
+ end
+
+=begin
+--- OptionParser.terminate([arg])
+ Terminates option parsing. Optional parameter ((|arg|)) would be
+ pushed back if given.
+ :Parameters:
+ : ((|arg|))
+ string pushed back to be first non-option argument
+=end #'#"#`#
+ def terminate(arg = nil)
+ self.class.terminate(arg)
+ end
+ def self.terminate(arg = nil)
+ throw :terminate, arg
+ end
+
+ @stack = [DefaultList]
+ def self.top() DefaultList end
+
+=begin
+--- OptionParser.accept(t, [pat]) {...}
+--- OptionParser#accept(t, [pat]) {...}
+ Directs to accept specified class argument.
+ :Parameters:
+ : ((|t|))
+ argument class specifier, any object including Class.
+ : ((|pat|))
+ pattern for argument, defaulted to ((|t|)) if it respond to (({match})).
+ : (({block}))
+ receives argument string and should be convert to desired class.
+=end #'#"#`#
+ def accept(*args, &blk) top.accept(*args, &blk) end
+ def self.accept(*args, &blk) top.accept(*args, &blk) end
+
+=begin
+--- OptionParser.reject(t)
+--- OptionParser#reject(t)
+ Directs to reject specified class argument.
+ :Parameters:
+ : ((|t|))
+ argument class specifier, any object including Class.
+=end #'#"#`#
+ def reject(*args, &blk) top.reject(*args, &blk) end
+ def self.reject(*args, &blk) top.reject(*args, &blk) end
+
+
+=begin
+=== Instance methods
+=end #'#"#`#
+
+=begin
+--- OptionParser#banner
+--- OptionParser#banner=(heading)
+ Heading banner preceding summary.
+--- OptionParser#summary_width
+--- OptionParser#summary_width=(width)
+ Width for option list portion of summary. Must be (({Numeric})).
+--- OptionParser#summary_indent
+--- OptionParser#summary_indent=(indent)
+ Indentation for summary. Must be (({String})) (or have (({+ String}))).
+--- OptionParser#program_name
+--- OptionParser#program_name=(name)
+ Program name to be emitted in error message and default banner,
+ defaulted to (({$0})).
+=end #'#"#`#
+ attr_writer :banner, :program_name
+ attr_accessor :summary_width, :summary_indent
+
+ def banner
+ @banner ||= "Usage: #{program_name} [options]"
+ end
+
+ def program_name
+ @program_name || File.basename($0, '.*')
+ end
+
+# for experimental cascading :-)
+ alias set_banner banner=
+ alias set_program_name program_name=
+ alias set_summary_width summary_width=
+ alias set_summary_indent summary_indent=
+
+=begin
+--- OptionParser#version
+--- OptionParser#version=(ver)
+ Version.
+--- OptionParser#release
+--- OptionParser#release=(rel)
+ Release code.
+--- OptionParser#ver
+ Returns version string from ((<program_name>)), (({version})) and
+ (({release})).
+=end #'#"#`#
+ attr_writer :version, :release
+
+ def version
+ @version || (defined?(::Version) && ::Version) || (defined?(::VERSION) && ::VERSION)
+ end
+
+ def release
+ @release || (defined?(::Release) && ::Release) || (defined?(::RELEASE) && ::RELEASE)
+ end
+
+ def ver
+ if v = version
+ str = "#{program_name} #{[v].join('.')}"
+ str << " (#{v})" if v = release
+ str
+ end
+ end
+
+ def warn(mesg = $!)
+ super("#{program_name}: #{mesg}")
+ end
+
+ def abort(mesg = $!)
+ super("#{program_name}: #{mesg}")
+ end
+
+=begin
+--- OptionParser#top
+ Subject of ((<on>))/((<on_head>)), ((<accept>))/((<reject>)).
+=end #'#"#`#
+ def top
+ @stack[-1]
+ end
+
+=begin
+--- OptionParser#base
+ Subject of ((<on_tail>)).
+=end #'#"#`#
+ def base
+ @stack[1]
+ end
+
+=begin
+--- OptionParser#new
+ Pushes a new (({List})).
+=end #'#"#`#
+ def new
+ @stack.push(List.new)
+ if block_given?
+ yield self
+ else
+ self
+ end
+ end
+
+=begin
+--- OptionParser#remove
+ Removes the last (({List})).
+=end #'#"#`#
+ def remove
+ @stack.pop
+ end
+
+
+=begin
+--- OptionParser#summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent)
+ Puts option summary into ((|to|)), and returns ((|to|)).
+ :Parameters:
+ : ((|to|))
+ output destination, which must have method ((|<<|)). Defaulted to (({[]})).
+ : ((|width|))
+ width of left side. Defaulted to ((|@summary_width|))
+ : ((|max|))
+ maximum length allowed for left side. Defaulted to (({((|width|)) - 1}))
+ : ((|indent|))
+ indentation. Defaulted to ((|@summary_indent|))
+ : (({block}))
+ yields with each line if called as iterator.
+=end #'#"#`#
+ def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
+ visit(:summarize, {}, {}, width, max, indent, &(blk || proc {|l| to << l + $/}))
+ to
+ end
+
+=begin
+--- OptionParser#help
+--- OptionParser#to_s
+ Returns option summary string.
+=end #'#"#`#
+ def help; summarize(banner.to_s.sub(/\n?\z/, "\n")) end
+ alias to_s help
+
+=begin
+--- OptionParser#to_a
+ Returns option summary list.
+=end #'#"#`#
+ def to_a; summarize(banner.to_a.dup) end
+
+
+=begin
+--- OptionParser#switch
+ Creates ((<OptionParser::Switch>)).
+ :Parameters:
+ : ((|*opts|))
+ option definition:
+ : argument style
+ see ((<OptionParser::ArgumentStyle>))
+ : argument pattern
+ acceptable option argument format, must pre-defined with
+ ((<OptionParser.accept>)) or ((<OptionParser#accept>)), or
+ (({Regexp})). This can appear once or assigned as (({String}))
+ if not present, otherwise causes exception (({ArgumentError})).
+
+ cf. ((<Acceptable argument classes>)).
+ : Hash
+ : Array
+ possible argument values.
+ : Proc
+ : Method
+ alternative way to give the ((*handler*)).
+ : "--switch=MANDATORY", "--switch[=OPTIONAL]", "--switch"
+ specifies long style switch that takes ((*mandatory*)),
+ ((*optional*)) and ((*no*)) argument, respectively.
+ : "-xMANDATORY", "-x[OPTIONAL]", "-x"
+ specifies short style switch that takes ((*mandatory*)),
+ ((*optional*)) and ((*no*)) argument, respectively.
+ : "-[a-z]MANDATORY", "-[a-z][OPTIONAL]", "-[a-z]"
+ special form short style switch that matches character
+ range(not fullset of regular expression).
+ : "=MANDATORY", "=[OPTIONAL]"
+ argument style and description.
+ : "description", ...
+ ((*description*)) for this option.
+ : (({block}))
+ ((*handler*)) to convert option argument to arbitrary (({Class})).
+=end #'#"#`#
+=begin private
+--- OptionParser#notwice(obj, prv, msg)
+ Checks never given twice an argument.
+ ((*Called from OptionParser#switch only*))
+ :Parameters:
+ : ((|obj|))
+ new argument.
+ : ((|prv|))
+ previously specified argument.
+ : ((|msg|))
+ exception message
+=end #'#"#`#
+ def notwice(obj, prv, msg)
+ unless !prv or prv == obj
+ begin
+ raise ArgumentError, "argument #{msg} given twice: #{obj}"
+ rescue
+ $@[0, 2] = nil
+ raise
+ end
+ end
+ obj
+ end
+ private :notwice
+
+ def make_switch(*opts, &block)
+ short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
+ ldesc, sdesc, desc, arg = [], [], []
+ default_style = Switch::NoArgument
+ default_pattern = nil
+ klass = nil
+ o = nil
+ n, q, a = nil
+
+ opts.each do |o|
+ # argument class
+ next if search(:atype, o) do |pat, c|
+ klass = notwice(o, klass, 'type')
+ if not_style and not_style != Switch::NoArgument
+ not_pattern, not_conv = pat, c
+ else
+ default_pattern, conv = pat, c
+ end
+ end
+
+ # directly specified pattern(any object possible to match)
+ if !(String === o) and o.respond_to?(:match)
+ pattern = notwice(o, pattern, 'pattern')
+ conv = (pattern.method(:convert).to_proc if pattern.respond_to?(:convert))
+ next
+ end
+
+ # anything others
+ case o
+ when Proc, Method
+ block = notwice(o, block, 'block')
+ when Array, Hash
+ case pattern
+ when CompletingHash
+ when nil
+ pattern = CompletingHash.new
+ conv = (pattern.method(:convert).to_proc if pattern.respond_to?(:convert))
+ else
+ raise ArgumentError, "argument pattern given twice"
+ end
+ o.each {|(o, *v)| pattern[o] = v.fetch(0) {o}}
+ when Module
+ raise ArgumentError, "unsupported argument type: #{o}"
+ when *ArgumentStyle.keys
+ style = notwice(ArgumentStyle[o], style, 'style')
+ when /^--no-([^\[\]=\s]*)(.+)?/
+ q, a = $1, $2
+ o = notwice(a ? Object : TrueClass, klass, 'type')
+ not_pattern, not_conv = search(:atype, o) unless not_style
+ not_style = (not_style || default_style).guess(arg = a) if a
+ default_style = Switch::NoArgument
+ default_pattern, conv = search(:atype, FalseClass) unless default_pattern
+ ldesc << "--no-#{q}"
+ long << 'no-' + (q = q.downcase)
+ nolong << q
+ when /^--\[no-\]([^\[\]=\s]*)(.+)?/
+ q, a = $1, $2
+ o = notwice(a ? Object : TrueClass, klass, 'type')
+ if a
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ end
+ ldesc << "--[no-]#{q}"
+ long << (o = q.downcase)
+ not_pattern, not_conv = search(:atype, FalseClass) unless not_style
+ not_style = Switch::NoArgument
+ nolong << 'no-' + o
+ when /^--([^\[\]=\s]*)(.+)?/
+ q, a = $1, $2
+ if a
+ o = notwice(NilClass, klass, 'type')
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ end
+ ldesc << "--#{q}"
+ long << (o = q.downcase)
+ when /^-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
+ q, a = $1, $2
+ o = notwice(Object, klass, 'type')
+ if a
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ end
+ sdesc << "-#{q}"
+ short << Regexp.new(q)
+ when /^-(.)(.+)?/
+ q, a = $1, $2
+ if a
+ o = notwice(NilClass, klass, 'type')
+ default_style = default_style.guess(arg = a)
+ default_pattern, conv = search(:atype, o) unless default_pattern
+ end
+ sdesc << "-#{q}"
+ short << q
+ when /^=/
+ style = notwice(default_style.guess(arg = o), style, 'style')
+ default_pattern, conv = search(:atype, Object) unless default_pattern
+ else
+ desc.push(o)
+ end
+ end
+
+ default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern
+ s = if short.empty? and long.empty?
+ raise ArgumentError, "no switch given" if style or pattern or block
+ desc
+ else
+ (style || default_style).new(pattern || default_pattern,
+ conv, sdesc, ldesc, arg, desc, block)
+ end
+ return s, short, long,
+ (not_style.new(not_pattern, not_conv, sdesc, ldesc, nil, desc, block) if not_style),
+ nolong
+ end
+
+=begin
+--- OptionParser#on(*opts) [{...}]
+--- OptionParser#def_option(*opts) [{...}]
+--- OptionParser#on_head(*opts) [{...}]
+--- OptionParser#def_head_option(*opts) [{...}]
+--- OptionParser#on_tail(*opts) [{...}]
+--- OptionParser#def_tail_option(*opts) [{...}]
+ Defines option switch and handler. (({on_head})), (({def_head_option}))
+ and (({on_tail})), (({def_tail_option})) put the switch at head
+ and tail of summary, respectively.
+
+ cf. ((<OptionParser#switch>)).
+=end #'#"#`#
+ def define(*opts, &block)
+ top.append(*(sw = make_switch(*opts, &block)))
+ sw[0]
+ end
+ def on(*opts, &block)
+ define(*opts, &block)
+ self
+ end
+ alias def_option define
+
+ def define_head(*opts, &block)
+ top.prepend(*(sw = make_switch(*opts, &block)))
+ sw[0]
+ end
+ def on_head(*opts, &block)
+ define_head(*opts, &block)
+ self
+ end
+ alias def_head_option define_head
+
+ def define_tail(*opts, &block)
+ base.append(*(sw = make_switch(*opts, &block)))
+ sw[0]
+ end
+ def on_tail(*opts, &block)
+ define_tail(*opts, &block)
+ self
+ end
+ alias def_tail_option define_tail
+
+ def separator(string)
+ top.append(string, nil, nil)
+ end
+
+
+=begin
+--- OptionParser#order(*argv) [{...}]
+--- OptionParser#order!([argv = ARGV]) [{...}]
+ Parses ((|argv|)) in order. When non-option argument encountered,
+ yields it if called as iterator, otherwise terminates the parse
+ process.
+ Returns rest of ((|argv|)) left unparsed.
+
+ (({order!})) takes argument array itself, and removes switches
+ destructively.
+ Defaults to parse ((|ARGV|)).
+ :Parameters:
+ : ((|argv|))
+ command line arguments to be parsed.
+ : (({block}))
+ called with each non-option argument.
+=end #'#"#`#
+ def order(*argv, &block)
+ argv = argv[0].dup if argv.size == 1 and Array === argv[0]
+ order!(argv, &block)
+ end
+
+ def order!(argv = ARGV, &nonopt)
+ opt, arg, sw, val, rest = nil
+ nonopt ||= proc {|arg| throw :terminate, arg}
+ argv.unshift(arg) if arg = catch(:terminate) {
+ while arg = argv.shift
+ case arg
+ # long option
+ when /\A--([^=]*)(?:=(.*))?/
+ opt, rest = $1, $2
+ begin
+ sw, = complete(:long, opt)
+ rescue ParseError
+ raise $!.set_option(arg, true)
+ end
+ begin
+ opt, sw, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
+ sw.call(val) if sw
+ rescue ParseError
+ raise $!.set_option(arg, rest)
+ end
+
+ # short option
+ when /\A-(.)((=).*|.+)?/
+ opt, has_arg, eq, val, rest = $1, $3, $3, $2, $2
+ begin
+ unless sw = search(:short, opt)
+ begin
+ sw, = complete(:short, opt)
+ # short option matched.
+ val = arg.sub(/\A-/, '')
+ has_arg = true
+ rescue InvalidOption
+ # if no short options match, try completion with long
+ # options.
+ sw, = complete(:long, opt)
+ eq ||= !rest
+ end
+ end
+ rescue ParseError
+ raise $!.set_option(arg, true)
+ end
+ begin
+ opt, sw, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
+ raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}"
+ argv.unshift(opt) if opt and (opt = opt.sub(/\A-*/, '-')) != '-'
+ sw.call(val) if sw
+ rescue ParseError
+ raise $!.set_option(arg, arg.length > 2)
+ end
+
+ # non-option argument
+ else
+ nonopt.call(arg)
+ end
+ end
+
+ nil
+ }
+
+ argv
+ end
+
+=begin
+--- OptionParser#permute(*argv)
+--- OptionParser#permute!([argv = ARGV])
+ Parses ((|argv|)) in permutation mode, and returns list of
+ non-option arguments.
+
+ (({permute!})) takes argument array itself, and removes switches
+ destructively.
+ Defaults to parse ((|ARGV|)).
+ :Parameters:
+ : ((|argv|))
+ command line arguments to be parsed.
+=end #'#"#`#
+ def permute(*argv)
+ argv = argv[0].dup if argv.size == 1 and Array === argv[0]
+ permute!(argv)
+ end
+
+ def permute!(argv = ARGV)
+ nonopts = []
+ arg = nil
+ order!(argv) {|arg| nonopts << arg}
+ argv[0, 0] = nonopts
+ argv
+ end
+
+=begin
+--- OptionParser#parse(*argv)
+--- OptionParser#parse!([argv = ARGV])
+ Parses ((|argv|)) in order when environment variable (({POSIXLY_CORRECT}))
+ is set, otherwise permutation mode
+
+ (({parse!})) takes argument array itself, and removes switches
+ destructively.
+ Defaults to parse ((|ARGV|)).
+ :Parameters:
+ : ((|argv|))
+ command line arguments to be parsed.
+=end #'#"#`#
+ def parse(*argv)
+ argv = argv[0].dup if argv.size == 1 and Array === argv[0]
+ parse!(argv)
+ end
+
+ def parse!(argv = ARGV)
+ if ENV.include?('POSIXLY_CORRECT')
+ order!(argv)
+ else
+ permute!(argv)
+ end
+ end
+
+
+=begin private
+--- OptionParser#visit(id, *args) {block}
+ Traverses (({stack}))s calling method ((|id|)) with ((|*args|)).
+ :Parameters:
+ : ((|id|))
+ called method in each elements of (({stack}))s.
+ : ((|*args|))
+ passed to ((|id|)).
+ : (({block}))
+ passed to ((|id|)).
+=end #'#"#`#
+ def visit(id, *args, &block)
+ el = nil
+ @stack.reverse_each do |el|
+ el.send(id, *args, &block)
+ end
+ nil
+ end
+ private :visit
+
+=begin private
+--- OptionParser#search(id, k)
+ Searches ((|k|)) in stack for ((|id|)) hash, and returns it or yielded
+ value if called as iterator.
+ :Parameters:
+ : ((|id|))
+ searching table.
+ : ((|k|))
+ searching key.
+ : (({block}))
+ yielded with the found value when succeeded.
+=end #'#"#`#
+ def search(id, k)
+ visit(:search, id, k) do |k|
+ return k unless block_given?
+ return yield(k)
+ end
+ end
+ private :search
+
+=begin private
+--- OptionParser#complete(typ, opt, *etc)
+ Completes shortened long style option switch, and returns pair of
+ canonical switch and switch descriptor((<OptionParser::Switch>)).
+ :Parameters:
+ : ((|id|))
+ searching table.
+ : ((|opt|))
+ searching key.
+ : ((|*pat|))
+ optional pattern for completion.
+ : (({block}))
+ yielded with the found value when succeeded.
+=end #'#"#`#
+ def complete(typ, opt, *pat)
+ if pat.empty?
+ search(typ, opt) {|sw| return [sw, opt]} # exact match or...
+ end
+ raise AmbiguousOption, catch(:ambiguous) {
+ visit(:complete, typ, opt, *pat) {|opt, *sw| return sw}
+ raise InvalidOption, opt
+ }
+ end
+ private :complete
+
+=begin undocumented
+--- OptionParser#load([filename])
+ Loads options from file named as ((|filename|)). Does nothing when
+ the file is not present. Returns whether successfuly loaded.
+ :Parameters:
+ : ((|filename|))
+ option file name. defaulted to basename of the program without
+ suffix in a directory ((%~/.options%)).
+=end #'#"#`#
+ def load(filename = nil)
+ begin
+ filename ||= File.expand_path(File.basename($0, '.*'), '~/.options')
+ rescue
+ return false
+ end
+ begin
+ parse(*IO.readlines(filename).each {|s| s.chomp!})
+ true
+ rescue Errno::ENOENT, Errno::ENOTDIR
+ false
+ end
+ end
+
+=begin undocumented
+--- OptionParser#environment([env])
+ Parses environment variable ((|env|)) or its uppercase with spliting
+ like as shell.
+ :Parameters:
+ : ((|env|))
+ defaulted to basename of the program.
+=end #'#"#`#
+ def environment(env = File.basename($0, '.*'))
+ env = ENV[env] || ENV[env.upcase] or return
+ parse(*Shellwords.shellwords(env))
+ end
+
+
+=begin
+= Acceptable argument classes
+=end #'#"#`#
+
+=begin
+: Object
+ any string, and no conversion. this is fall-back.
+=end #'#"#`#
+ accept(Object) {|s,|s or s.nil?}
+
+ accept(NilClass) {|s,|s}
+
+=begin
+: String
+ any none-empty string, and no conversion.
+=end #'#"#`#
+ accept(String, /.+/) {|s,*|s}
+
+=begin
+: Integer
+ Ruby/C-like integer, octal for (({0-7})) sequence, binary for
+ (({0b})), hexadecimal for (({0x})), and decimal for others; with
+ optional sign prefix. Converts to (({Integer})).
+=end #'#"#`#
+ decimal = '\d+(?:_\d+)*'
+ binary = 'b[01]+(?:_[01]+)*'
+ hex = 'x[\da-f]+(?:_[\da-f]+)*'
+ octal = "0(?:[0-7]*(?:_[0-7]+)*|#{binary}|#{hex})"
+ integer = "#{octal}|#{decimal}"
+ accept(Integer, %r"\A[-+]?(?:#{integer})"io) {|s,| Integer(s) if s}
+
+=begin
+: Float
+ Float number format, and converts to (({Float})).
+=end #'#"#`#
+ float = "(?:#{decimal}(?:\\.(?:#{decimal})?)?|\\.#{decimal})(?:E[-+]?#{decimal})?"
+ floatpat = %r"\A[-+]?#{float}"io
+ accept(Float, floatpat) {|s,| s.to_f if s}
+
+=begin
+: Numeric
+ Generic numeric format, and converts to (({Integer})) for integer
+ format, (({Float})) for float format.
+=end #'#"#`#
+ accept(Numeric, %r"\A[-+]?(?:#{octal}|#{float})"io) {|s,| eval(s) if s}
+
+=begin
+: OptionParser::DecimalInteger
+ Decimal integer format, to be converted to (({Integer})).
+=end #'#"#`#
+ DecimalInteger = /\A[-+]?#{decimal}/io
+ accept(DecimalInteger) {|s,| s.to_i if s}
+
+=begin
+: OptionParser::OctalInteger
+ Ruby/C like octal/hexadecimal/binary integer format, to be converted
+ to (({Integer})).
+=end #'#"#`#
+ OctalInteger = /\A[-+]?(?:[0-7]+(?:_[0-7]+)*|0(?:#{binary}|#{hex}))/io
+ accept(OctalInteger) {|s,| s.oct if s}
+
+=begin
+: OptionParser::DecimalNumeric
+ Decimal integer/float number format, to be converted to
+ (({Integer})) for integer format, (({Float})) for float format.
+=end #'#"#`#
+ DecimalNumeric = floatpat # decimal integer is allowed as float also.
+ accept(DecimalNumeric) {|s,| eval(s) if s}
+
+=begin
+: TrueClass
+ Boolean switch, which means whether it is present or not, whether it
+ is absent or not with prefix (({no-})), or it takes an argument
+ (({yes/no/true/false/+/-})).
+: FalseClass
+ Similar to ((<TrueClass>)), but defaulted to (({false})).
+=end #'#"#`#
+ yesno = CompletingHash.new
+ %w[- no false].each {|el| yesno[el] = false}
+ %w[+ yes true].each {|el| yesno[el] = true}
+ yesno['nil'] = false # shoud be nil?
+ accept(TrueClass, yesno) {|arg, val| val == nil or val}
+ accept(FalseClass, yesno) {|arg, val| val != nil and val}
+
+=begin
+: Array
+ List of strings separated by ","
+=end #'#"#`#
+ accept(Array) do |s,|
+ if s
+ s = s.split(',').collect {|s| s unless s.empty?}
+ end
+ s
+ end
+
+
+=begin
+= Exceptions
+=end #'#"#`#
+
+=begin
+== ((:OptionParser::ParseError:))
+Base class of exceptions from ((<OptionParser>))
+=== Superclass
+(({RuntimeError}))
+=== Constants
+: OptionParser::ParseError::Reason
+ Reason caused error.
+=== Instance methods
+--- OptionParser::ParseError#recover(argv)
+ Push backs erred argument(s) to ((|argv|)).
+--- OptionParser::ParseError#reason
+ Returns error reason. Override this to I18N.
+--- OptionParser::ParseError#inspect
+ Returns inspection string.
+--- OptionParser::ParseError#message
+--- OptionParser::ParseError#to_s
+--- OptionParser::ParseError#to_str
+ Default stringizing method to emit standard error message.
+=end #'#"#`#
+ class ParseError < RuntimeError
+ Reason = 'parse error'.freeze
+
+ def initialize(*args)
+ @args = args
+ @reason = nil
+ end
+
+ attr_reader :args
+ attr_writer :reason
+
+ def recover(argv)
+ argv[0, 0] = @args
+ argv
+ end
+
+ def set_option(opt, eq)
+ if eq
+ @args[0] = opt
+ else
+ @args.unshift(opt)
+ end
+ self
+ end
+
+ def reason
+ @reason || self.class::Reason
+ end
+
+ def inspect
+ "#<#{self.class.to_s}: #{args.join(' ')}>"
+ end
+
+ def message
+ reason + ': ' + args.join(' ')
+ end
+
+ alias to_s message
+ alias to_str message
+ end
+
+=begin
+== ((:OptionParser::AmbiguousOption:))
+Raises when encountered ambiguously completable string.
+=== Superclass
+((<OptionParser::ParseError>))
+=end #'#"#`#
+ class AmbiguousOption < ParseError
+ const_set(:Reason, 'ambiguous option'.freeze)
+ end
+
+=begin
+== ((:OptionParser::NeedlessArgument:))
+Raises when encountered argument for switch defined as which takes no
+argument.
+=== Superclass
+((<OptionParser::ParseError>))
+=end #'#"#`#
+ class NeedlessArgument < ParseError
+ const_set(:Reason, 'needles argument'.freeze)
+ end
+
+=begin
+== ((:OptionParser::MissingArgument:))
+Raises when no argument found for switch defined as which needs
+argument.
+=== Superclass
+((<OptionParser::ParseError>))
+=end #'#"#`#
+ class MissingArgument < ParseError
+ const_set(:Reason, 'missing argument'.freeze)
+ end
+
+=begin
+== ((:OptionParser::InvalidOption:))
+Raises when undefined switch.
+=== Superclass
+((<OptionParser::ParseError>))
+=end #'#"#`#
+ class InvalidOption < ParseError
+ const_set(:Reason, 'invalid option'.freeze)
+ end
+
+=begin
+== ((:OptionParser::InvalidArgument:))
+Raises when the given argument does not match required format.
+=== Superclass
+((<OptionParser::ParseError>))
+=end #'#"#`#
+ class InvalidArgument < ParseError
+ const_set(:Reason, 'invalid argument'.freeze)
+ end
+
+=begin
+== ((:OptionParser::AmbiguousArgument:))
+Raises when the given argument word can't completed uniquely.
+=== Superclass
+((<OptionParser::InvalidArgument>))
+=end #'#"#`#
+ class AmbiguousArgument < InvalidArgument
+ const_set(:Reason, 'ambiguous argument'.freeze)
+ end
+
+
+=begin
+= Miscellaneous
+=end #'#"#`#
+=begin
+== ((:OptionParser::Arguable:))
+Extends command line arguments array to parse itself.
+=end #'#"#`#
+ module Arguable
+=begin
+--- OptionParser::Arguable#options=(opt)
+ Sets ((<OptionParser>)) object, when ((|opt|)) is (({false})) or
+ (({nil})), methods ((<OptionParser::Arguable#options>)) and
+ ((<OptionParser::Arguable#options=>)) are undefined. Thus, there
+ is no ways to access the ((<OptionParser>)) object via the
+ receiver object.
+=end #'#"#`#
+ def options=(opt)
+ unless @optparse = opt
+ class << self
+ undef_method(:options)
+ undef_method(:options=)
+ end
+ end
+ end
+
+=begin
+--- OptionParser::Arguable#options
+ Actual ((<OptionParser>)) object, automatically created if not
+ yet.
+
+ If called as iterator, yields with the ((<OptionParser>)) object
+ and returns the result of the block. In this case, rescues any
+ ((<OptionParser::ParseError>)) exceptions in the block, just emits
+ error message to ((<STDERR>)) and returns (({nil})).
+
+ :Parameters:
+ : (({block}))
+ Yielded with the ((<OptionParser>)) instance.
+
+=end #'#"#`#
+ def options
+ @optparse ||= OptionParser.new
+ block_given? or return @optparse
+ begin
+ yield @optparse
+ rescue ParseError
+ @optparse.warn $!
+ nil
+ end
+ end
+
+=begin
+--- OptionParser::Arguable#order!
+--- OptionParser::Arguable#permute!
+--- OptionParser::Arguable#parse!
+ Parses ((|self|)) destructively, and returns ((|self|)) just contains
+ rest arguments left without parsed.
+=end #'#"#`#
+ def order!(&blk) options.order!(self, &blk) end
+ def permute!() options.permute!(self) end
+ def parse!() options.parse!(self) end
+
+=begin private
+Initializes instance variable.
+=end #'#"#`#
+ def self.extend_object(obj)
+ super
+ obj.instance_eval {@optparse = nil}
+ end
+ def initialize(*args)
+ super
+ @optparse = nil
+ end
+ end
+
+=begin
+== OptionParser::Acceptables
+Acceptable argument classes. Now contains (({DecimalInteger})),
+(({OctalInteger})) and (({DecimalNumeric})).
+see ((<Acceptable argument classes>)).
+=end #'#"#`#
+ module Acceptables
+ const_set(:DecimalInteger, OptionParser::DecimalInteger)
+ const_set(:OctalInteger, OptionParser::OctalInteger)
+ const_set(:DecimalNumeric, OptionParser::DecimalNumeric)
+ end
+end
+
+# ARGV is arguable by OptionParser
+ARGV.extend(OptionParser::Arguable)
+
+
+if $0 == __FILE__
+ Version = OptionParser::Version
+ ARGV.options {|q|
+ q.parse!.empty? or puts "what's #{ARGV.join(' ')}?"
+ } or exit 1
+end
+__END__
+=begin example
+= Example
+<<< opttest.rb
+=end #'#"#`#
diff --git a/lib/optparse/date.rb b/lib/optparse/date.rb
new file mode 100644
index 0000000000..d680559f37
--- /dev/null
+++ b/lib/optparse/date.rb
@@ -0,0 +1,17 @@
+require 'optparse'
+require 'date'
+
+OptionParser.accept(DateTime) do |s,|
+ begin
+ DateTime.parse(s) if s
+ rescue ArgumentError
+ raise OptionParser::InvalidArgument, s
+ end
+end
+OptionParser.accept(Date) do |s,|
+ begin
+ Date.parse(s) if s
+ rescue ArgumentError
+ raise OptionParser::InvalidArgument, s
+ end
+end
diff --git a/lib/optparse/shellwords.rb b/lib/optparse/shellwords.rb
new file mode 100644
index 0000000000..0422d7c887
--- /dev/null
+++ b/lib/optparse/shellwords.rb
@@ -0,0 +1,6 @@
+# -*- ruby -*-
+
+require 'shellwords'
+require 'optparse'
+
+OptionParser.accept(Shellwords) {|s,| Shellwords.shellwords(s)}
diff --git a/lib/optparse/time.rb b/lib/optparse/time.rb
new file mode 100644
index 0000000000..402cadcf16
--- /dev/null
+++ b/lib/optparse/time.rb
@@ -0,0 +1,10 @@
+require 'optparse'
+require 'time'
+
+OptionParser.accept(Time) do |s,|
+ begin
+ (Time.httpdate(s) rescue Time.parse(s)) if s
+ rescue
+ raise OptionParser::InvalidArgument, s
+ end
+end
diff --git a/lib/optparse/uri.rb b/lib/optparse/uri.rb
new file mode 100644
index 0000000000..024dc69eac
--- /dev/null
+++ b/lib/optparse/uri.rb
@@ -0,0 +1,6 @@
+# -*- ruby -*-
+
+require 'optparse'
+require 'uri'
+
+OptionParser.accept(URI) {|s,| URI.parse(s) if s}
diff --git a/lib/optparse/version.rb b/lib/optparse/version.rb
new file mode 100644
index 0000000000..8e99836878
--- /dev/null
+++ b/lib/optparse/version.rb
@@ -0,0 +1,68 @@
+# OptionParser internal utility
+
+class << OptionParser
+ def show_version(*pkg)
+ progname = ARGV.options.program_name
+ show = proc do |klass, version|
+ version = version.join(".") if Array === version
+ str = "#{progname}"
+ str << ": #{klass}" unless klass == Object
+ str << " version #{version}"
+ case
+ when klass.const_defined?(:Release)
+ str << " (#{klass.const_get(:Release)})"
+ when klass.const_defined?(:RELEASE)
+ str << " (#{klass.const_get(:Release)})"
+ end
+ puts str
+ end
+ if pkg.size == 1 and pkg[0] == "all"
+ self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
+ unless cname[1] == ?e and klass.const_defined?(:Version)
+ show.call(klass, version)
+ end
+ end
+ else
+ pkg.each do |pkg|
+ /\A[A-Z]\w*((::|\/)[A-Z]\w*)*\z/ni =~ pkg or next
+ begin
+ pkg = eval(pkg)
+ v = case
+ when pkg.const_defined?(:Version)
+ pkg.const_get(:Version)
+ when pkg.const_defined?(:VERSION)
+ pkg.const_get(:VERSION)
+ else
+ "unknown"
+ end
+ show.call(pkg, v)
+ rescue NameError
+ puts "#{progname}: #$!"
+ end
+ end
+ end
+ exit
+ end
+
+ def each_const(path, klass = ::Object)
+ path.split(/::|\//).inject(klass) do |klass, name|
+ raise NameError, path unless Module === klass
+ klass.constants.grep(/#{name}/i) do |c|
+ klass.const_defined?(c) or next
+ c = klass.const_get(c)
+ end
+ end
+ end
+
+ def search_const(klass, name)
+ klasses = [klass]
+ while klass = klasses.shift
+ klass.constants.each do |cname|
+ klass.const_defined?(cname) or next
+ const = klass.const_get(cname)
+ yield klass, cname, const if name === cname
+ klasses << const if Module === const and const != ::Object
+ end
+ end
+ end
+end
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index f083677d8e..d92ee503ad 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -1,55 +1,110 @@
-# ostruct.rb - Python Style Object
-# just assign to create field
-#
-# s = OpenStruct.new
-# s.foo = 25
-# p s.foo
-# s.bar = 2
-# p s.bar
-# p s
+#
+# = ostruct.rb: OpenStruct implementation
+#
+# Author:: Yukihiro Matsumoto
+# Documentation:: Gavin Sinclair
+#
+# OpenStruct allows the creation of data objects with arbitrary attributes.
+# See OpenStruct for an example.
+#
+#
+# OpenStruct allows you to create data objects and set arbitrary attributes.
+# For example:
+#
+# require 'ostruct'
+#
+# record = OpenStruct.new
+# record.name = "John Smith"
+# record.age = 70
+# record.pension = 300
+#
+# puts record.name # -> "John Smith"
+# puts record.address # -> nil
+#
+# It is like a hash with a different way to access the data. In fact, it is
+# implemented with a hash, and you can initialize it with one.
+#
+# hash = { "country" => "Australia", :population => 20_000_000 }
+# data = OpenStruct.new(hash)
+#
+# p data # -> <OpenStruct country="Australia" population=20000000>
+#
class OpenStruct
+ #
+ # Create a new OpenStruct object. The optional +hash+, if given, will
+ # generate attributes and values. For example.
+ #
+ # require 'ostruct'
+ # hash = { "country" => "Australia", :population => 20_000_000 }
+ # data = OpenStruct.new(hash)
+ #
+ # p data # -> <OpenStruct country="Australia" population=20000000>
+ #
+ # By default, the resulting OpenStruct object will have no attributes.
+ #
def initialize(hash=nil)
@table = {}
if hash
for k,v in hash
- @table[k] = v
+ @table[k.to_sym] = v
end
end
end
- def method_missing(mid, *args)
+ def new_ostruct_member(name)
+ self.instance_eval %{
+ def #{name}; @table[:#{name}]; end
+ def #{name}=(x); @table[:#{name}] = x; end
+ }
+ end
+
+ def method_missing(mid, *args) # :nodoc:
mname = mid.id2name
len = args.length
if mname =~ /=$/
if len != 1
- raise ArgumentError, "wrong # of arguments (#{len} for 1)", caller(1)
+ raise ArgumentError, "wrong number of arguments (#{len} for 1)", caller(1)
+ end
+ if self.frozen?
+ raise TypeError, "can't modify frozen #{self.class}", caller(1)
end
mname.chop!
- @table[mname] = args[0]
- elsif args.length == 0
- @table[mname]
+ @table[mname.intern] = args[0]
+ self.new_ostruct_member(mname)
+ elsif len == 0
+ @table[mid]
else
- raise NameError, "undefined method `#{mname}'", caller(1)
+ raise NoMethodError, "undefined method `#{mname}' for #{self}", caller(1)
end
end
-
+
+ #
+ # Remove the named field from the object.
+ #
def delete_field(name)
- if name.type == Fixnum
- name = name.id2name
- end
- @table.delete name
+ @table.delete name.to_sym
end
+ #
+ # Returns a string containing a detailed summary of the keys and values.
+ #
def inspect
- str = "<#{self.type}"
+ str = "<#{self.class}"
for k,v in @table
- str += " "
- str += k
- str += "="
- str += v.inspect
+ str << " #{k}=#{v.inspect}"
end
- str += ">"
- str
+ str << ">"
+ end
+
+ attr_reader :table # :nodoc:
+ protected :table
+
+ #
+ # Compare this object and +other+ for equality.
+ #
+ def ==(other)
+ return false unless(other.kind_of?(OpenStruct))
+ return @table == other.table
end
end
diff --git a/lib/parsearg.rb b/lib/parsearg.rb
index b9f41d5e5f..d5f3c9638d 100644
--- a/lib/parsearg.rb
+++ b/lib/parsearg.rb
@@ -73,7 +73,7 @@ def parseArgs(argc, nopt, single_opts, *opts)
end
rescue
print "Format Error!! : \"" + nopt + "\"\t[parseArgs]\n"
- exit! -1
+ exit!(-1)
end
end
if ARGV.length < argc
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index 7fc75cf0c2..405ab46907 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -1,179 +1,13 @@
-# parsedate3.rb: Written by Tadayoshi Funaba 2000, 2001
-# $Id: parsedate3.rb,v 1.3 2001-01-18 12:09:47+09 tadf Exp $
+# parsedate.rb: Written by Tadayoshi Funaba 2001, 2002
+# $Id: parsedate.rb,v 2.6 2002-05-14 07:43:18+09 tadf Exp $
-module ParseDate
-
- MONTHS = {
- 'jan' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4,
- 'may' => 5, 'jun' => 6, 'jul' => 7, 'aug' => 8,
- 'sep' => 9, 'oct' =>10, 'nov' =>11, 'dec' =>12
- }
- MONTHPAT = MONTHS.keys.join('|')
-
- DAYS = {
- 'sun' => 0, 'mon' => 1, 'tue' => 2, 'wed' => 3,
- 'thu' => 4, 'fri' => 5, 'sat' => 6
- }
- DAYPAT = DAYS.keys.join('|')
-
- def parsedate(date, cyear=false)
- date = date.dup
-
- # day
- if date.sub!(/(#{DAYPAT})\S*/ino, ' ')
- wday = DAYS[$1.downcase]
- end
-
- # time
- if date.sub!(
- /(\d+):(\d+)(?::(\d+))?
- (?:
- \s*
- ([ap])\.?m\.?
- \b
- )?
- (?:
- \s*
- (
- [a-z]+(?:\s+dst)?
- |
- [-+]\d+(?::?\d+)
- )
- \b
- )?
- /inox,
- ' ')
- hour = $1.to_i
- min = $2.to_i
- sec = $3.to_i if $3
- if $4
- hour %= 12
- if $4.downcase == 'p'
- hour += 12
- end
- end
- zone = $5
- end
-
- # eu
- if date.sub!(
- /(\d+)\S*
- \s+
- (#{MONTHPAT})\S*
- (?:
- \s+
- (\d+)
- )?
- /inox,
- ' ')
- mday = $1.to_i
- mon = MONTHS[$2.downcase]
- year = $3.to_i if $3
-
- # us
- elsif date.sub!(
- /(#{MONTHPAT})\S*
- \s+
- (\d+)\S*
- (?:
- \s+
- (\d+)
- )?
- /inox,
- ' ')
- mon = MONTHS[$1.downcase]
- mday = $2.to_i
- year = $3.to_i if $3
+require 'date/format'
- # iso
- elsif date.sub!(/(\d+)-(\d+)-(\d+)/no, ' ')
- year = $1.to_i
- mon = $2.to_i
- mday = $3.to_i
- mday, mon, year = year, mon, mday if $3.size >= 4
-
- # jis
- elsif date.sub!(/([MTSH])(\d+)\.(\d+)\.(\d+)/no, ' ')
- e = { 'M'=>1867,
- 'T'=>1911,
- 'S'=>1925,
- 'H'=>1988
- }[$1]
- year, mon, mday = $2.to_i + e, $3.to_i, $4.to_i
-
- # vms
- elsif date.sub!(/(\d+)-(#{MONTHPAT})\S*-(\d+)/ino, ' ')
- mday = $1.to_i
- mon = MONTHS[$2.downcase]
- year = $3.to_i
- year, mon, mday = mday, mon, year if $1.size >= 4
-
- # sla
- elsif date.sub!(%r|(\d+)/(\d+)(?:/(\d+))?|no, ' ')
- mon = $1.to_i
- mday = $2.to_i
- year = $3.to_i if $3
- year, mon, mday = mon, mday, year if $1.size >= 4
-
- # ddd
- elsif date.sub!(
- /(\d{4,14})
- (?:
- \s*
- T?
- \s*
- (\d{2,6})
- )?
- (?:
- \s*
- (
- Z
- |
- [-+]\d{2,4}
- )
- \b
- )?
- /nox,
- ' ')
- case $1.size
- when 4
- mon = $1[ 0, 2].to_i
- mday = $1[ 2, 2].to_i
- when 6
- year = $1[ 0, 2].to_i
- mon = $1[ 2, 2].to_i
- mday = $1[ 4, 2].to_i
- when 8, 10, 12, 14
- year = $1[ 0, 4].to_i
- mon = $1[ 4, 2].to_i
- mday = $1[ 6, 2].to_i
- hour = $1[ 8, 2].to_i if $1.size >= 10
- min = $1[10, 2].to_i if $1.size >= 12
- sec = $1[12, 2].to_i if $1.size >= 14
- end
- if $2
- case $2.size
- when 2, 4, 6
- hour = $2[ 0, 2].to_i
- min = $2[ 2, 2].to_i if $2.size >= 4
- sec = $2[ 4, 2].to_i if $2.size >= 6
- end
- end
- zone = $3
- end
-
- if cyear and year
- if year < 100
- if year >= 69
- year += 1900
- else
- year += 2000
- end
- end
- end
-
- return year, mon, mday, hour, min, sec, zone, wday
+module ParseDate
+ def parsedate(str, comp=false)
+ Date._parse(str, comp).
+ values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
end
module_function :parsedate
diff --git a/lib/pathname.rb b/lib/pathname.rb
new file mode 100644
index 0000000000..663afcf5ed
--- /dev/null
+++ b/lib/pathname.rb
@@ -0,0 +1,1197 @@
+#
+# = pathname.rb
+#
+# Object-Oriented Pathname Class
+#
+# Author:: Tanaka Akira <akr@m17n.org>
+# Documentation:: Author and Gavin Sinclair
+#
+# For documentation, see class Pathname.
+#
+# <tt>pathname.rb</tt> is distributed with Ruby since 1.8.0.
+#
+
+#
+# == Pathname
+#
+# Pathname represents a pathname which locates a file in a filesystem.
+# It supports only Unix style pathnames. It does not represent the file
+# itself. A Pathname can be relative or absolute. It's not until you try to
+# reference the file that it even matters whether the file exists or not.
+#
+# Pathname is immutable. It has no method for destructive update.
+#
+# The value of this class is to manipulate file path information in a neater
+# way than standard Ruby provides. The examples below demonstrate the
+# difference. *All* functionality from File, FileTest, and some from Dir and
+# FileUtils is included, in an unsurprising way. It is essentially a facade for
+# all of these, and more.
+#
+# == Examples
+#
+# === Example 1: Using Pathname
+#
+# require 'pathname'
+# p = Pathname.new("/usr/bin/ruby")
+# size = p.size # 27662
+# isdir = p.directory? # false
+# dir = p.dirname # Pathname:/usr/bin
+# base = p.basename # Pathname:ruby
+# dir, base = p.split # [Pathname:/usr/bin, Pathname:ruby]
+# data = p.read
+# p.open { |f| _ }
+# p.each_line { |line| _ }
+#
+# === Example 2: Using standard Ruby
+#
+# p = "/usr/bin/ruby"
+# size = File.size(p) # 27662
+# isdir = File.directory?(p) # false
+# dir = File.dirname(p) # "/usr/bin"
+# base = File.basename(p) # "ruby"
+# dir, base = File.split(p) # ["/usr/bin", "ruby"]
+# data = File.read(p)
+# File.open(p) { |f| _ }
+# File.foreach(p) { |line| _ }
+#
+# === Example 3: Special features
+#
+# p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
+# p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
+# p3 = p1.parent # Pathname:/usr
+# p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
+# pwd = Pathname.pwd # Pathname:/home/gavin
+# pwd.absolute? # true
+# p5 = Pathname.new "." # Pathname:.
+# p5 = p5 + "music/../articles" # Pathname:music/../articles
+# p5.cleanpath # Pathname:articles
+# p5.realpath # Pathname:/home/gavin/articles
+# p5.children # [Pathname:/home/gavin/articles/linux, ...]
+#
+# == Breakdown of functionality
+#
+# === Core methods
+#
+# These methods are effectively manipulating a String, because that's all a path
+# is. Except for #mountpoint?, #children, and #realpath, they don't access the
+# filesystem.
+#
+# - +
+# - #join
+# - #parent
+# - #root?
+# - #absolute?
+# - #relative?
+# - #relative_path_from
+# - #each_filename
+# - #cleanpath
+# - #realpath
+# - #children
+# - #mountpoint?
+#
+# === File status predicate methods
+#
+# These methods are a facade for FileTest:
+# - #blockdev?
+# - #chardev?
+# - #directory?
+# - #executable?
+# - #executable_real?
+# - #exist?
+# - #file?
+# - #grpowned?
+# - #owned?
+# - #pipe?
+# - #readable?
+# - #readable_real?
+# - #setgid?
+# - #setuid?
+# - #size
+# - #size?
+# - #socket?
+# - #sticky?
+# - #symlink?
+# - #writable?
+# - #writable_real?
+# - #zero?
+#
+# === File property and manipulation methods
+#
+# These methods are a facade for File:
+# - #atime
+# - #ctime
+# - #mtime
+# - #chmod(mode)
+# - #lchmod(mode)
+# - #chown(owner, group)
+# - #lchown(owner, group)
+# - #fnmatch(pattern, *args)
+# - #fnmatch?(pattern, *args)
+# - #ftype
+# - #make_link(old)
+# - #open(*args, &block)
+# - #readlink
+# - #rename(to)
+# - #stat
+# - #lstat
+# - #make_symlink(old)
+# - #truncate(length)
+# - #utime(atime, mtime)
+# - #basename(*args)
+# - #dirname
+# - #extname
+# - #expand_path(*args)
+# - #split
+#
+# === Directory methods
+#
+# These methods are a facade for Dir:
+# - Pathname.glob(*args)
+# - Pathname.getwd / Pathname.pwd
+# - #rmdir
+# - #entries
+# - #each_entry(&block)
+# - #mkdir(*args)
+# - #opendir(*args)
+#
+# === IO
+#
+# These methods are a facade for IO:
+# - #each_line(*args, &block)
+# - #read(*args)
+# - #readlines(*args)
+# - #sysopen(*args)
+#
+# === Utilities
+#
+# These methods are a mixture of Find, FileUtils, and others:
+# - #find(&block)
+# - #mkpath
+# - #rmtree
+# - #unlink / #delete
+#
+#
+# == Method documentation
+#
+# As the above section shows, most of the methods in Pathname are facades. The
+# documentation for these methods generally just says, for instance, "See
+# FileTest.writable?", as you should be familiar with the original method
+# anyway, and its documentation (e.g. through +ri+) will contain more
+# information. In some cases, a brief description will follow.
+#
+class Pathname
+ #
+ # Create a Pathname object from the given String (or String-like object).
+ # If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
+ #
+ def initialize(path)
+ path = path.to_str if path.respond_to? :to_str
+ @path = path.dup
+
+ if /\0/ =~ @path
+ raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
+ end
+
+ self.taint if @path.tainted?
+ end
+
+ def freeze() super; @path.freeze; self end
+ def taint() super; @path.taint; self end
+ def untaint() super; @path.untaint; self end
+
+ #
+ # Compare this pathname with +other+. The comparison is string-based.
+ # Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>)
+ # can refer to the same file.
+ #
+ def ==(other)
+ return false unless Pathname === other
+ other.to_s == @path
+ end
+ alias === ==
+ alias eql? ==
+
+ # Provides for comparing pathnames, case-sensitively.
+ def <=>(other)
+ return nil unless Pathname === other
+ @path.tr('/', "\0") <=> other.to_s.tr('/', "\0")
+ end
+
+ def hash # :nodoc:
+ @path.hash
+ end
+
+ # Return the path as a String.
+ def to_s
+ @path.dup
+ end
+
+ # to_str is implemented so Pathname objects are usable with File.open, etc.
+ alias to_str to_s
+
+ def inspect # :nodoc:
+ "#<#{self.class}:#{@path}>"
+ end
+
+ #
+ # Returns clean pathname of +self+ with consecutive slashes and useless dots
+ # removed. The filesystem is not accessed.
+ #
+ # If +consider_symlink+ is +true+, then a more conservative algorithm is used
+ # to avoid breaking symbolic linkages. This may retain more <tt>..</tt>
+ # entries than absolutely necessary, but without accessing the filesystem,
+ # this can't be avoided. See #realpath.
+ #
+ def cleanpath(consider_symlink=false)
+ if consider_symlink
+ cleanpath_conservative
+ else
+ cleanpath_aggressive
+ end
+ end
+
+ #
+ # Clean the path simply by resolving and removing excess "." and ".." entries.
+ # Nothing more, nothing less.
+ #
+ def cleanpath_aggressive # :nodoc:
+ # cleanpath_aggressive assumes:
+ # * no symlink
+ # * all pathname prefix contained in the pathname is existing directory
+ return Pathname.new('') if @path == ''
+ absolute = absolute?
+ names = []
+ @path.scan(%r{[^/]+}) {|name|
+ next if name == '.'
+ if name == '..'
+ if names.empty?
+ next if absolute
+ else
+ if names.last != '..'
+ names.pop
+ next
+ end
+ end
+ end
+ names << name
+ }
+ return Pathname.new(absolute ? '/' : '.') if names.empty?
+ path = absolute ? '/' : ''
+ path << names.join('/')
+ Pathname.new(path)
+ end
+
+ def cleanpath_conservative # :nodoc:
+ return Pathname.new('') if @path == ''
+ names = @path.scan(%r{[^/]+})
+ last_dot = names.last == '.'
+ names.delete('.')
+ names.shift while names.first == '..' if absolute?
+ return Pathname.new(absolute? ? '/' : '.') if names.empty?
+ path = absolute? ? '/' : ''
+ path << names.join('/')
+ if names.last != '..'
+ if last_dot
+ path << '/.'
+ elsif %r{/\z} =~ @path
+ path << '/'
+ end
+ end
+ Pathname.new(path)
+ end
+
+ #
+ # Returns a real (absolute) pathname of +self+ in the actual filesystem.
+ # The real pathname doesn't contain symlinks or useless dots.
+ #
+ # No arguments should be given; the old behaviour is *obsoleted*.
+ #
+ def realpath(*args)
+ unless args.empty?
+ warn "The argument for Pathname#realpath is obsoleted."
+ end
+ force_absolute = args.fetch(0, true)
+
+ if %r{\A/} =~ @path
+ top = '/'
+ unresolved = @path.scan(%r{[^/]+})
+ elsif force_absolute
+ # Although POSIX getcwd returns a pathname which contains no symlink,
+ # 4.4BSD-Lite2 derived getcwd may return the environment variable $PWD
+ # which may contain a symlink.
+ # So the return value of Dir.pwd should be examined.
+ top = '/'
+ unresolved = Dir.pwd.scan(%r{[^/]+}) + @path.scan(%r{[^/]+})
+ else
+ top = ''
+ unresolved = @path.scan(%r{[^/]+})
+ end
+ resolved = []
+
+ until unresolved.empty?
+ case unresolved.last
+ when '.'
+ unresolved.pop
+ when '..'
+ resolved.unshift unresolved.pop
+ else
+ loop_check = {}
+ while (stat = File.lstat(path = top + unresolved.join('/'))).symlink?
+ symlink_id = "#{stat.dev}:#{stat.ino}"
+ raise Errno::ELOOP.new(path) if loop_check[symlink_id]
+ loop_check[symlink_id] = true
+ if %r{\A/} =~ (link = File.readlink(path))
+ top = '/'
+ unresolved = link.scan(%r{[^/]+})
+ else
+ unresolved[-1,1] = link.scan(%r{[^/]+})
+ end
+ end
+ next if (filename = unresolved.pop) == '.'
+ if filename != '..' && resolved.first == '..'
+ resolved.shift
+ else
+ resolved.unshift filename
+ end
+ end
+ end
+
+ if top == '/'
+ resolved.shift while resolved[0] == '..'
+ end
+
+ if resolved.empty?
+ Pathname.new(top.empty? ? '.' : '/')
+ else
+ Pathname.new(top + resolved.join('/'))
+ end
+ end
+
+ # #parent returns the parent directory.
+ #
+ # This is same as <tt>self + '..'</tt>.
+ def parent
+ self + '..'
+ end
+
+ # #mountpoint? returns +true+ if <tt>self</tt> points to a mountpoint.
+ def mountpoint?
+ begin
+ stat1 = self.lstat
+ stat2 = self.parent.lstat
+ stat1.dev == stat2.dev && stat1.ino == stat2.ino ||
+ stat1.dev != stat2.dev
+ rescue Errno::ENOENT
+ false
+ end
+ end
+
+ #
+ # #root? is a predicate for root directories. I.e. it returns +true+ if the
+ # pathname consists of consecutive slashes.
+ #
+ # It doesn't access actual filesystem. So it may return +false+ for some
+ # pathnames which points to roots such as <tt>/usr/..</tt>.
+ #
+ def root?
+ %r{\A/+\z} =~ @path ? true : false
+ end
+
+ # Predicate method for testing whether a path is absolute.
+ # It returns +true+ if the pathname begins with a slash.
+ def absolute?
+ %r{\A/} =~ @path ? true : false
+ end
+
+ # The opposite of #absolute?
+ def relative?
+ !absolute?
+ end
+
+ #
+ # Iterates over each component of the path.
+ #
+ # Pathname.new("/usr/bin/ruby").each_filename
+ # # yields "usr", "bin", and "ruby".
+ #
+ def each_filename # :yield: s
+ @path.scan(%r{[^/]+}) { yield $& }
+ end
+
+ #
+ # Pathname#+ appends a pathname fragment to this one to produce a new Pathname
+ # object.
+ #
+ # p1 = Pathname.new("/usr") # Pathname:/usr
+ # p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
+ # p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
+ #
+ # This method doesn't access the file system; it is pure string manipulation.
+ #
+ def +(other)
+ other = Pathname.new(other) unless Pathname === other
+
+ return other if other.absolute?
+
+ path1 = @path
+ path2 = other.to_s
+ while m2 = %r{\A\.\.(?:/+|\z)}.match(path2) and
+ m1 = %r{(\A|/+)([^/]+)\z}.match(path1) and
+ %r{\A(?:\.|\.\.)\z} !~ m1[2]
+ path1 = m1[1].empty? ? '.' : '/' if (path1 = m1.pre_match).empty?
+ path2 = '.' if (path2 = m2.post_match).empty?
+ end
+ if %r{\A/+\z} =~ path1
+ while m2 = %r{\A\.\.(?:/+|\z)}.match(path2)
+ path2 = '.' if (path2 = m2.post_match).empty?
+ end
+ end
+
+ return Pathname.new(path2) if path1 == '.'
+ return Pathname.new(path1) if path2 == '.'
+
+ if %r{/\z} =~ path1
+ Pathname.new(path1 + path2)
+ else
+ Pathname.new(path1 + '/' + path2)
+ end
+ end
+
+ #
+ # Pathname#join joins pathnames.
+ #
+ # <tt>path0.join(path1, ..., pathN)</tt> is the same as
+ # <tt>path0 + path1 + ... + pathN</tt>.
+ #
+ def join(*args)
+ args.unshift self
+ result = args.pop
+ result = Pathname.new(result) unless Pathname === result
+ return result if result.absolute?
+ args.reverse_each {|arg|
+ arg = Pathname.new(arg) unless Pathname === arg
+ result = arg + result
+ return result if result.absolute?
+ }
+ result
+ end
+
+ #
+ # Returns the children of the directory (files and subdirectories, not
+ # recursive) as an array of Pathname objects. By default, the returned
+ # pathnames will have enough information to access the files. If you set
+ # +with_directory+ to +false+, then the returned pathnames will contain the
+ # filename only.
+ #
+ # For example:
+ # p = Pathname("/usr/lib/ruby/1.8")
+ # p.children
+ # # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
+ # Pathname:/usr/lib/ruby/1.8/Env.rb,
+ # Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
+ # p.children(false)
+ # # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
+ #
+ # Note that the result never contain the entries <tt>.</tt> and <tt>..</tt> in
+ # the directory because they are not children.
+ #
+ # This method has existed since 1.8.1.
+ #
+ def children(with_directory=true)
+ with_directory = false if @path == '.'
+ result = []
+ Dir.foreach(@path) {|e|
+ next if e == '.' || e == '..'
+ if with_directory
+ result << Pathname.new(File.join(@path, e))
+ else
+ result << Pathname.new(e)
+ end
+ }
+ result
+ end
+
+ #
+ # #relative_path_from returns a relative path from the argument to the
+ # receiver. If +self+ is absolute, the argument must be absolute too. If
+ # +self+ is relative, the argument must be relative too.
+ #
+ # #relative_path_from doesn't access the filesystem. It assumes no symlinks.
+ #
+ # ArgumentError is raised when it cannot find a relative path.
+ #
+ # This method has existed since 1.8.1.
+ #
+ def relative_path_from(base_directory)
+ if self.absolute? != base_directory.absolute?
+ raise ArgumentError,
+ "relative path between absolute and relative path: #{self.inspect}, #{base_directory.inspect}"
+ end
+
+ dest = []
+ self.cleanpath.each_filename {|f|
+ next if f == '.'
+ dest << f
+ }
+
+ base = []
+ base_directory.cleanpath.each_filename {|f|
+ next if f == '.'
+ base << f
+ }
+
+ while !base.empty? && !dest.empty? && base[0] == dest[0]
+ base.shift
+ dest.shift
+ end
+
+ if base.include? '..'
+ raise ArgumentError, "base_directory has ..: #{base_directory.inspect}"
+ end
+
+ base.fill '..'
+ relpath = base + dest
+ if relpath.empty?
+ Pathname.new(".")
+ else
+ Pathname.new(relpath.join('/'))
+ end
+ end
+
+end
+
+
+class Pathname # * IO *
+ #
+ # #each_line iterates over the line in the file. It yields a String object
+ # for each line.
+ #
+ # This method has existed since 1.8.1.
+ #
+ def each_line(*args, &block) # :yield: line
+ IO.foreach(@path, *args, &block)
+ end
+
+ # Pathname#foreachline is *obsoleted* at 1.8.1. Use #each_line.
+ def foreachline(*args, &block)
+ warn "Pathname#foreachline is obsoleted. Use Pathname#each_line."
+ each_line(*args, &block)
+ end
+
+ # See <tt>IO.read</tt>. Returns all the bytes from the file, or the first +N+
+ # if specified.
+ def read(*args) IO.read(@path, *args) end
+
+ # See <tt>IO.readlines</tt>. Returns all the lines from the file.
+ def readlines(*args) IO.readlines(@path, *args) end
+
+ # See <tt>IO.sysopen</tt>.
+ def sysopen(*args) IO.sysopen(@path, *args) end
+end
+
+
+class Pathname # * File *
+
+ # See <tt>File.atime</tt>. Returns last access time.
+ def atime() File.atime(@path) end
+
+ # See <tt>File.ctime</tt>. Returns last (directory entry, not file) change time.
+ def ctime() File.ctime(@path) end
+
+ # See <tt>File.mtime</tt>. Returns last modification time.
+ def mtime() File.mtime(@path) end
+
+ # See <tt>File.chmod</tt>. Changes permissions.
+ def chmod(mode) File.chmod(mode, @path) end
+
+ # See <tt>File.lchmod</tt>.
+ def lchmod(mode) File.lchmod(mode, @path) end
+
+ # See <tt>File.chown</tt>. Change owner and group of file.
+ def chown(owner, group) File.chown(owner, group, @path) end
+
+ # See <tt>File.lchown</tt>.
+ def lchown(owner, group) File.lchown(owner, group, @path) end
+
+ # See <tt>File.fnmatch</tt>. Return +true+ if the receiver matches the given
+ # pattern.
+ def fnmatch(pattern, *args) File.fnmatch(pattern, @path, *args) end
+
+ # See <tt>File.fnmatch?</tt> (same as #fnmatch).
+ def fnmatch?(pattern, *args) File.fnmatch?(pattern, @path, *args) end
+
+ # See <tt>File.ftype</tt>. Returns "type" of file ("file", "directory",
+ # etc).
+ def ftype() File.ftype(@path) end
+
+ # See <tt>File.link</tt>. Creates a hard link.
+ def make_link(old) File.link(old, @path) end
+
+ # See <tt>File.open</tt>. Opens the file for reading or writing.
+ def open(*args, &block) # :yield: file
+ File.open(@path, *args, &block)
+ end
+
+ # See <tt>File.readlink</tt>. Read symbolic link.
+ def readlink() Pathname.new(File.readlink(@path)) end
+
+ # See <tt>File.rename</tt>. Rename the file.
+ def rename(to) File.rename(@path, to) end
+
+ # See <tt>File.stat</tt>. Returns a <tt>File::Stat</tt> object.
+ def stat() File.stat(@path) end
+
+ # See <tt>File.lstat</tt>.
+ def lstat() File.lstat(@path) end
+
+ # See <tt>File.symlink</tt>. Creates a symbolic link.
+ def make_symlink(old) File.symlink(old, @path) end
+
+ # See <tt>File.truncate</tt>. Truncate the file to +length+ bytes.
+ def truncate(length) File.truncate(@path, length) end
+
+ # See <tt>File.utime</tt>. Update the access and modification times.
+ def utime(atime, mtime) File.utime(atime, mtime, @path) end
+
+ # See <tt>File.basename</tt>. Returns the last component of the path.
+ def basename(*args) Pathname.new(File.basename(@path, *args)) end
+
+ # See <tt>File.dirname</tt>. Returns all but the last component of the path.
+ def dirname() Pathname.new(File.dirname(@path)) end
+
+ # See <tt>File.extname</tt>. Returns the file's extension.
+ def extname() File.extname(@path) end
+
+ # See <tt>File.expand_path</tt>.
+ def expand_path(*args) Pathname.new(File.expand_path(@path, *args)) end
+
+ # See <tt>File.split</tt>. Returns the #dirname and the #basename in an
+ # Array.
+ def split() File.split(@path).map {|f| Pathname.new(f) } end
+
+ # Pathname#link is confusing and *obsoleted* because the receiver/argument
+ # order is inverted to corresponding system call.
+ def link(old)
+ warn 'Pathname#link is obsoleted. Use Pathname#make_link.'
+ File.link(old, @path)
+ end
+
+ # Pathname#symlink is confusing and *obsoleted* because the receiver/argument
+ # order is inverted to corresponding system call.
+ def symlink(old)
+ warn 'Pathname#symlink is obsoleted. Use Pathname#make_symlink.'
+ File.symlink(old, @path)
+ end
+end
+
+
+class Pathname # * FileTest *
+
+ # See <tt>FileTest.blockdev?</tt>.
+ def blockdev?() FileTest.blockdev?(@path) end
+
+ # See <tt>FileTest.chardev?</tt>.
+ def chardev?() FileTest.chardev?(@path) end
+
+ # See <tt>FileTest.executable?</tt>.
+ def executable?() FileTest.executable?(@path) end
+
+ # See <tt>FileTest.executable_real?</tt>.
+ def executable_real?() FileTest.executable_real?(@path) end
+
+ # See <tt>FileTest.exist?</tt>.
+ def exist?() FileTest.exist?(@path) end
+
+ # See <tt>FileTest.grpowned?</tt>.
+ def grpowned?() FileTest.grpowned?(@path) end
+
+ # See <tt>FileTest.directory?</tt>.
+ def directory?() FileTest.directory?(@path) end
+
+ # See <tt>FileTest.file?</tt>.
+ def file?() FileTest.file?(@path) end
+
+ # See <tt>FileTest.pipe?</tt>.
+ def pipe?() FileTest.pipe?(@path) end
+
+ # See <tt>FileTest.socket?</tt>.
+ def socket?() FileTest.socket?(@path) end
+
+ # See <tt>FileTest.owned?</tt>.
+ def owned?() FileTest.owned?(@path) end
+
+ # See <tt>FileTest.readable?</tt>.
+ def readable?() FileTest.readable?(@path) end
+
+ # See <tt>FileTest.readable_real?</tt>.
+ def readable_real?() FileTest.readable_real?(@path) end
+
+ # See <tt>FileTest.setuid?</tt>.
+ def setuid?() FileTest.setuid?(@path) end
+
+ # See <tt>FileTest.setgid?</tt>.
+ def setgid?() FileTest.setgid?(@path) end
+
+ # See <tt>FileTest.size</tt>.
+ def size() FileTest.size(@path) end
+
+ # See <tt>FileTest.size?</tt>.
+ def size?() FileTest.size?(@path) end
+
+ # See <tt>FileTest.sticky?</tt>.
+ def sticky?() FileTest.sticky?(@path) end
+
+ # See <tt>FileTest.symlink?</tt>.
+ def symlink?() FileTest.symlink?(@path) end
+
+ # See <tt>FileTest.writable?</tt>.
+ def writable?() FileTest.writable?(@path) end
+
+ # See <tt>FileTest.writable_real?</tt>.
+ def writable_real?() FileTest.writable_real?(@path) end
+
+ # See <tt>FileTest.zero?</tt>.
+ def zero?() FileTest.zero?(@path) end
+end
+
+
+class Pathname # * Dir *
+ # See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
+ def Pathname.glob(*args) # :yield: p
+ if block_given?
+ Dir.glob(*args) {|f| yield Pathname.new(f) }
+ else
+ Dir.glob(*args).map {|f| Pathname.new(f) }
+ end
+ end
+
+ # See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname.
+ def Pathname.getwd() Pathname.new(Dir.getwd) end
+ class << self; alias pwd getwd end
+
+ # Pathname#chdir is *obsoleted* at 1.8.1.
+ def chdir(&block)
+ warn "Pathname#chdir is obsoleted. Use Dir.chdir."
+ Dir.chdir(@path, &block)
+ end
+
+ # Pathname#chroot is *obsoleted* at 1.8.1.
+ def chroot
+ warn "Pathname#chroot is obsoleted. Use Dir.chroot."
+ Dir.chroot(@path)
+ end
+
+ # Return the entries (files and subdirectories) in the directory, each as a
+ # Pathname object.
+ def entries() Dir.entries(@path).map {|f| Pathname.new(f) } end
+
+ # Iterates over the entries (files and subdirectories) in the directory. It
+ # yields a Pathname object for each entry.
+ #
+ # This method has existed since 1.8.1.
+ def each_entry(&block) # :yield: p
+ Dir.foreach(@path) {|f| yield Pathname.new(f) }
+ end
+
+ # Pathname#dir_foreach is *obsoleted* at 1.8.1.
+ def dir_foreach(*args, &block)
+ warn "Pathname#dir_foreach is obsoleted. Use Pathname#each_entry."
+ each_entry(*args, &block)
+ end
+
+ # See <tt>Dir.mkdir</tt>. Create the referenced directory.
+ def mkdir(*args) Dir.mkdir(@path, *args) end
+
+ # See <tt>Dir.rmdir</tt>. Remove the referenced directory.
+ def rmdir() Dir.rmdir(@path) end
+
+ # See <tt>Dir.open</tt>.
+ def opendir(&block) # :yield: dir
+ Dir.open(@path, &block)
+ end
+end
+
+
+class Pathname # * Find *
+ #
+ # Pathname#find is an iterator to traverse a directory tree in a depth first
+ # manner. It yields a Pathname for each file under "this" directory.
+ #
+ # Since it is implemented by <tt>find.rb</tt>, <tt>Find.prune</tt> can be used
+ # to control the traverse.
+ #
+ # If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
+ # current directory, not <tt>./</tt>.
+ #
+ def find(&block) # :yield: p
+ require 'find'
+ if @path == '.'
+ Find.find(@path) {|f| yield Pathname.new(f.sub(%r{\A\./}, '')) }
+ else
+ Find.find(@path) {|f| yield Pathname.new(f) }
+ end
+ end
+end
+
+
+class Pathname # * FileUtils *
+ # See <tt>FileUtils.mkpath</tt>. Creates a full path, including any
+ # intermediate directories that don't yet exist.
+ def mkpath
+ require 'fileutils'
+ FileUtils.mkpath(@path)
+ nil
+ end
+
+ # See <tt>FileUtils.rm_r</tt>. Deletes a directory and all beneath it.
+ def rmtree
+ # The name "rmtree" is borrowed from File::Path of Perl.
+ # File::Path provides "mkpath" and "rmtree".
+ require 'fileutils'
+ FileUtils.rm_r(@path)
+ nil
+ end
+end
+
+
+class Pathname # * mixed *
+ # Removes a file or directory, using <tt>File.unlink</tt> or
+ # <tt>Dir.unlink</tt> as necessary.
+ def unlink()
+ if FileTest.directory? @path
+ Dir.unlink @path
+ else
+ File.unlink @path
+ end
+ end
+ alias delete unlink
+
+ # This method is *obsoleted* at 1.8.1. Use #each_line or #each_entry.
+ def foreach(*args, &block)
+ warn "Pathname#foreach is obsoleted. Use each_line or each_entry."
+ if FileTest.directory? @path
+ # For polymorphism between Dir.foreach and IO.foreach,
+ # Pathname#foreach doesn't yield Pathname object.
+ Dir.foreach(@path, *args, &block)
+ else
+ IO.foreach(@path, *args, &block)
+ end
+ end
+end
+
+if $0 == __FILE__
+ require 'test/unit'
+
+ class PathnameTest < Test::Unit::TestCase # :nodoc:
+ def test_initialize
+ p1 = Pathname.new('a')
+ assert_equal('a', p1.to_s)
+ p2 = Pathname.new(p1)
+ assert_equal(p1, p2)
+ end
+
+ class AnotherStringLike # :nodoc:
+ def initialize(s) @s = s end
+ def to_str() @s end
+ def ==(other) @s == other end
+ end
+
+ def test_equality
+ obj = Pathname.new("a")
+ str = "a"
+ sym = :a
+ ano = AnotherStringLike.new("a")
+ assert_equal(false, obj == str)
+ assert_equal(false, str == obj)
+ assert_equal(false, obj == ano)
+ assert_equal(false, ano == obj)
+ assert_equal(false, obj == sym)
+ assert_equal(false, sym == obj)
+
+ obj2 = Pathname.new("a")
+ assert_equal(true, obj == obj2)
+ assert_equal(true, obj === obj2)
+ assert_equal(true, obj.eql?(obj2))
+ end
+
+ def test_hashkey
+ h = {}
+ h[Pathname.new("a")] = 1
+ h[Pathname.new("a")] = 2
+ assert_equal(1, h.size)
+ end
+
+ def assert_pathname_cmp(e, s1, s2)
+ p1 = Pathname.new(s1)
+ p2 = Pathname.new(s2)
+ r = p1 <=> p2
+ assert(e == r,
+ "#{p1.inspect} <=> #{p2.inspect}: <#{e}> expected but was <#{r}>")
+ end
+ def test_comparison
+ assert_pathname_cmp( 0, "a", "a")
+ assert_pathname_cmp( 1, "b", "a")
+ assert_pathname_cmp(-1, "a", "b")
+ ss = %w(
+ a
+ a/
+ a/b
+ a.
+ a0
+ )
+ s1 = ss.shift
+ ss.each {|s2|
+ assert_pathname_cmp(-1, s1, s2)
+ s1 = s2
+ }
+ end
+
+ def test_comparison_string
+ assert_equal(nil, Pathname.new("a") <=> "a")
+ assert_equal(nil, "a" <=> Pathname.new("a"))
+ end
+
+ def test_syntactical
+ assert_equal(true, Pathname.new("/").root?)
+ assert_equal(true, Pathname.new("//").root?)
+ assert_equal(true, Pathname.new("///").root?)
+ assert_equal(false, Pathname.new("").root?)
+ assert_equal(false, Pathname.new("a").root?)
+ end
+
+ def test_cleanpath
+ assert_equal('/', Pathname.new('/').cleanpath(true).to_s)
+ assert_equal('/', Pathname.new('//').cleanpath(true).to_s)
+ assert_equal('', Pathname.new('').cleanpath(true).to_s)
+
+ assert_equal('.', Pathname.new('.').cleanpath(true).to_s)
+ assert_equal('..', Pathname.new('..').cleanpath(true).to_s)
+ assert_equal('a', Pathname.new('a').cleanpath(true).to_s)
+ assert_equal('/', Pathname.new('/.').cleanpath(true).to_s)
+ assert_equal('/', Pathname.new('/..').cleanpath(true).to_s)
+ assert_equal('/a', Pathname.new('/a').cleanpath(true).to_s)
+ assert_equal('.', Pathname.new('./').cleanpath(true).to_s)
+ assert_equal('..', Pathname.new('../').cleanpath(true).to_s)
+ assert_equal('a/', Pathname.new('a/').cleanpath(true).to_s)
+
+ assert_equal('a/b', Pathname.new('a//b').cleanpath(true).to_s)
+ assert_equal('a/.', Pathname.new('a/.').cleanpath(true).to_s)
+ assert_equal('a/.', Pathname.new('a/./').cleanpath(true).to_s)
+ assert_equal('a/..', Pathname.new('a/../').cleanpath(true).to_s)
+ assert_equal('/a/.', Pathname.new('/a/.').cleanpath(true).to_s)
+ assert_equal('..', Pathname.new('./..').cleanpath(true).to_s)
+ assert_equal('..', Pathname.new('../.').cleanpath(true).to_s)
+ assert_equal('..', Pathname.new('./../').cleanpath(true).to_s)
+ assert_equal('..', Pathname.new('.././').cleanpath(true).to_s)
+ assert_equal('/', Pathname.new('/./..').cleanpath(true).to_s)
+ assert_equal('/', Pathname.new('/../.').cleanpath(true).to_s)
+ assert_equal('/', Pathname.new('/./../').cleanpath(true).to_s)
+ assert_equal('/', Pathname.new('/.././').cleanpath(true).to_s)
+
+ assert_equal('a/b/c', Pathname.new('a/b/c').cleanpath(true).to_s)
+ assert_equal('b/c', Pathname.new('./b/c').cleanpath(true).to_s)
+ assert_equal('a/c', Pathname.new('a/./c').cleanpath(true).to_s)
+ assert_equal('a/b/.', Pathname.new('a/b/.').cleanpath(true).to_s)
+ assert_equal('a/..', Pathname.new('a/../.').cleanpath(true).to_s)
+
+ assert_equal('/a', Pathname.new('/../.././../a').cleanpath(true).to_s)
+ assert_equal('a/b/../../../../c/../d',
+ Pathname.new('a/b/../../../../c/../d').cleanpath(true).to_s)
+ end
+
+ def test_cleanpath_no_symlink
+ assert_equal('/', Pathname.new('/').cleanpath.to_s)
+ assert_equal('/', Pathname.new('//').cleanpath.to_s)
+ assert_equal('', Pathname.new('').cleanpath.to_s)
+
+ assert_equal('.', Pathname.new('.').cleanpath.to_s)
+ assert_equal('..', Pathname.new('..').cleanpath.to_s)
+ assert_equal('a', Pathname.new('a').cleanpath.to_s)
+ assert_equal('/', Pathname.new('/.').cleanpath.to_s)
+ assert_equal('/', Pathname.new('/..').cleanpath.to_s)
+ assert_equal('/a', Pathname.new('/a').cleanpath.to_s)
+ assert_equal('.', Pathname.new('./').cleanpath.to_s)
+ assert_equal('..', Pathname.new('../').cleanpath.to_s)
+ assert_equal('a', Pathname.new('a/').cleanpath.to_s)
+
+ assert_equal('a/b', Pathname.new('a//b').cleanpath.to_s)
+ assert_equal('a', Pathname.new('a/.').cleanpath.to_s)
+ assert_equal('a', Pathname.new('a/./').cleanpath.to_s)
+ assert_equal('.', Pathname.new('a/../').cleanpath.to_s)
+ assert_equal('/a', Pathname.new('/a/.').cleanpath.to_s)
+ assert_equal('..', Pathname.new('./..').cleanpath.to_s)
+ assert_equal('..', Pathname.new('../.').cleanpath.to_s)
+ assert_equal('..', Pathname.new('./../').cleanpath.to_s)
+ assert_equal('..', Pathname.new('.././').cleanpath.to_s)
+ assert_equal('/', Pathname.new('/./..').cleanpath.to_s)
+ assert_equal('/', Pathname.new('/../.').cleanpath.to_s)
+ assert_equal('/', Pathname.new('/./../').cleanpath.to_s)
+ assert_equal('/', Pathname.new('/.././').cleanpath.to_s)
+
+ assert_equal('a/b/c', Pathname.new('a/b/c').cleanpath.to_s)
+ assert_equal('b/c', Pathname.new('./b/c').cleanpath.to_s)
+ assert_equal('a/c', Pathname.new('a/./c').cleanpath.to_s)
+ assert_equal('a/b', Pathname.new('a/b/.').cleanpath.to_s)
+ assert_equal('.', Pathname.new('a/../.').cleanpath.to_s)
+
+ assert_equal('/a', Pathname.new('/../.././../a').cleanpath.to_s)
+ assert_equal('../../d', Pathname.new('a/b/../../../../c/../d').cleanpath.to_s)
+ end
+
+ def test_destructive_update
+ path = Pathname.new("a")
+ path.to_s.replace "b"
+ assert_equal(Pathname.new("a"), path)
+ end
+
+ def test_null_character
+ assert_raise(ArgumentError) { Pathname.new("\0") }
+ end
+
+ def assert_relpath(result, dest, base)
+ assert_equal(Pathname.new(result),
+ Pathname.new(dest).relative_path_from(Pathname.new(base)))
+ end
+
+ def assert_relpath_err(dest, base)
+ assert_raise(ArgumentError) {
+ Pathname.new(dest).relative_path_from(Pathname.new(base))
+ }
+ end
+
+ def test_relative_path_from
+ assert_relpath("../a", "a", "b")
+ assert_relpath("../a", "a", "b/")
+ assert_relpath("../a", "a/", "b")
+ assert_relpath("../a", "a/", "b/")
+ assert_relpath("../a", "/a", "/b")
+ assert_relpath("../a", "/a", "/b/")
+ assert_relpath("../a", "/a/", "/b")
+ assert_relpath("../a", "/a/", "/b/")
+
+ assert_relpath("../b", "a/b", "a/c")
+ assert_relpath("../a", "../a", "../b")
+
+ assert_relpath("a", "a", ".")
+ assert_relpath("..", ".", "a")
+
+ assert_relpath(".", ".", ".")
+ assert_relpath(".", "..", "..")
+ assert_relpath("..", "..", ".")
+
+ assert_relpath("c/d", "/a/b/c/d", "/a/b")
+ assert_relpath("../..", "/a/b", "/a/b/c/d")
+ assert_relpath("../../../../e", "/e", "/a/b/c/d")
+ assert_relpath("../b/c", "a/b/c", "a/d")
+
+ assert_relpath("../a", "/../a", "/b")
+ assert_relpath("../../a", "../a", "b")
+ assert_relpath(".", "/a/../../b", "/b")
+ assert_relpath("..", "a/..", "a")
+ assert_relpath(".", "a/../b", "b")
+
+ assert_relpath("a", "a", "b/..")
+ assert_relpath("b/c", "b/c", "b/..")
+
+ assert_relpath_err("/", ".")
+ assert_relpath_err(".", "/")
+ assert_relpath_err("a", "..")
+ assert_relpath_err(".", "..")
+ end
+
+ def assert_pathname_plus(a, b, c)
+ a = Pathname.new(a)
+ b = Pathname.new(b)
+ c = Pathname.new(c)
+ d = b + c
+ assert(a == d,
+ "#{b.inspect} + #{c.inspect}: #{a.inspect} expected but was #{d.inspect}")
+ end
+
+ def test_plus
+ assert_pathname_plus('a/b', 'a', 'b')
+ assert_pathname_plus('a', 'a', '.')
+ assert_pathname_plus('b', '.', 'b')
+ assert_pathname_plus('.', '.', '.')
+ assert_pathname_plus('/b', 'a', '/b')
+
+ assert_pathname_plus('/', '/', '..')
+ assert_pathname_plus('.', 'a', '..')
+ assert_pathname_plus('a', 'a/b', '..')
+ assert_pathname_plus('../..', '..', '..')
+ assert_pathname_plus('/c', '/', '../c')
+ assert_pathname_plus('c', 'a', '../c')
+ assert_pathname_plus('a/c', 'a/b', '../c')
+ assert_pathname_plus('../../c', '..', '../c')
+ end
+
+ def test_taint
+ obj = Pathname.new("a"); assert_same(obj, obj.taint)
+ obj = Pathname.new("a"); assert_same(obj, obj.untaint)
+
+ assert_equal(false, Pathname.new("a" ) .tainted?)
+ assert_equal(false, Pathname.new("a" ) .to_s.tainted?)
+ assert_equal(true, Pathname.new("a" ).taint .tainted?)
+ assert_equal(true, Pathname.new("a" ).taint.to_s.tainted?)
+ assert_equal(true, Pathname.new("a".taint) .tainted?)
+ assert_equal(true, Pathname.new("a".taint) .to_s.tainted?)
+ assert_equal(true, Pathname.new("a".taint).taint .tainted?)
+ assert_equal(true, Pathname.new("a".taint).taint.to_s.tainted?)
+
+ str = "a"
+ path = Pathname.new(str)
+ str.taint
+ assert_equal(false, path .tainted?)
+ assert_equal(false, path.to_s.tainted?)
+ end
+
+ def test_untaint
+ obj = Pathname.new("a"); assert_same(obj, obj.untaint)
+
+ assert_equal(false, Pathname.new("a").taint.untaint .tainted?)
+ assert_equal(false, Pathname.new("a").taint.untaint.to_s.tainted?)
+
+ str = "a".taint
+ path = Pathname.new(str)
+ str.untaint
+ assert_equal(true, path .tainted?)
+ assert_equal(true, path.to_s.tainted?)
+ end
+
+ def test_freeze
+ obj = Pathname.new("a"); assert_same(obj, obj.freeze)
+
+ assert_equal(false, Pathname.new("a" ) .frozen?)
+ assert_equal(false, Pathname.new("a".freeze) .frozen?)
+ assert_equal(true, Pathname.new("a" ).freeze .frozen?)
+ assert_equal(true, Pathname.new("a".freeze).freeze .frozen?)
+ assert_equal(false, Pathname.new("a" ) .to_s.frozen?)
+ assert_equal(false, Pathname.new("a".freeze) .to_s.frozen?)
+ assert_equal(false, Pathname.new("a" ).freeze.to_s.frozen?)
+ assert_equal(false, Pathname.new("a".freeze).freeze.to_s.frozen?)
+ end
+
+ def test_to_s
+ str = "a"
+ obj = Pathname.new(str)
+ assert_equal(str, obj.to_s)
+ assert_not_same(str, obj.to_s)
+ assert_not_same(obj.to_s, obj.to_s)
+ end
+
+ def test_kernel_open
+ count = 0
+ stat1 = File.stat(__FILE__)
+ result = Kernel.open(Pathname.new(__FILE__)) {|f|
+ stat2 = f.stat
+ assert_equal(stat1.dev, stat2.dev)
+ assert_equal(stat1.ino, stat2.ino)
+ assert_equal(stat1.size, stat2.size)
+ count += 1
+ 2
+ }
+ assert_equal(1, count)
+ assert_equal(2, result)
+ end
+ end
+end
diff --git a/lib/ping.rb b/lib/ping.rb
index d698dd0c52..7f970f96de 100644
--- a/lib/ping.rb
+++ b/lib/ping.rb
@@ -44,12 +44,12 @@ module Ping
def pingecho(host, timeout=5, service="echo")
begin
timeout(timeout) do
- s = TCPsocket.new(host, service)
+ s = TCPSocket.new(host, service)
s.close
end
rescue Errno::ECONNREFUSED
return true
- rescue
+ rescue Timeout::Error
return false
end
return true
diff --git a/lib/pp.rb b/lib/pp.rb
new file mode 100644
index 0000000000..6ddd4dd2eb
--- /dev/null
+++ b/lib/pp.rb
@@ -0,0 +1,652 @@
+# $Id$
+
+=begin
+= Pretty-printer for Ruby objects.
+
+== Which seems better?
+
+non-pretty-printed output by (({p})) is:
+ #<PP:0x81fedf0 @genspace=#<Proc:0x81feda0>, @group_queue=#<PrettyPrint::GroupQueue:0x81fed3c @queue=[[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], []]>, @buffer=[], @newline="\n", @group_stack=[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#<IO:0x8114ee4>>
+
+pretty-printed output by (({pp})) is:
+ #<PP:0x81fedf0
+ @buffer=[],
+ @buffer_width=0,
+ @genspace=#<Proc:0x81feda0>,
+ @group_queue=
+ #<PrettyPrint::GroupQueue:0x81fed3c
+ @queue=
+ [[#<PrettyPrint::Group:0x81fed78 @break=false, @breakables=[], @depth=0>],
+ []]>,
+ @group_stack=
+ [#<PrettyPrint::Group:0x81fed78 @break=false, @breakables=[], @depth=0>],
+ @indent=0,
+ @maxwidth=79,
+ @newline="\n",
+ @output=#<IO:0x8114ee4>,
+ @output_width=2>
+
+I like the latter. If you do too, this library is for you.
+
+== Usage
+
+: pp(obj)
+ output ((|obj|)) to (({$>})) in pretty printed format.
+
+ It returns (({nil})).
+
+== Output Customization
+To define your customized pretty printing function for your classes,
+redefine a method (({pretty_print(((|pp|)))})) in the class.
+It takes an argument ((|pp|)) which is an instance of the class ((<PP>)).
+The method should use PP#text, PP#breakable, PP#nest, PP#group and
+PP#pp to print the object.
+
+= PP
+== super class
+((<PrettyPrint>))
+
+== class methods
+--- PP.pp(obj[, out[, width]])
+ outputs ((|obj|)) to ((|out|)) in pretty printed format of
+ ((|width|)) columns in width.
+
+ If ((|out|)) is omitted, (({$>})) is assumed.
+ If ((|width|)) is omitted, 79 is assumed.
+
+ PP.pp returns ((|out|)).
+
+--- PP.singleline_pp(obj[, out])
+ outputs ((|obj|)) to ((|out|)) like (({PP.pp})) but with no indent and
+ newline.
+
+ PP.singleline_pp returns ((|out|)).
+
+--- PP.sharing_detection
+ returns the sharing detection flag as a boolean value.
+ It is false by default.
+
+--- PP.sharing_detection = boolean_value
+ sets the sharing detection flag.
+
+== methods
+--- pp(obj)
+ adds ((|obj|)) to the pretty printing buffer
+ using Object#pretty_print or Object#pretty_print_cycle.
+
+ Object#pretty_print_cycle is used when ((|obj|)) is already
+ printed, a.k.a the object reference chain has a cycle.
+
+--- object_group(obj) { ... }
+ is a convenience method which is same as follows:
+
+ group(1, '#<' + obj.class.name, '>') { ... }
+
+--- comma_breakable
+ is a convenience method which is same as follows:
+
+ text ','
+ breakable
+
+--- seplist(list[, separator_proc[, iter_method]]) {|elt| ... }
+ adds a separated list.
+ The list is separated by comma with breakable space, by default.
+
+ seplist iterates the ((|list|)) using ((|iter_method|)).
+ It yields each object to the block given for seplist.
+ The procedure ((|separator_proc|)) is called between each yields.
+
+ If the iteration is zero times, ((|separator_proc|)) is not called at all.
+
+ If ((|separator_proc|)) is nil or not given,
+ (({lambda { comma_breakable }})) is used.
+ If ((|iter_method|)) is not given, (({:each})) is used.
+
+ For example, following 3 code fragments has similar effect.
+
+ q.seplist([1,2,3]) {|v| xxx v }
+
+ q.seplist([1,2,3], lambda { comma_breakable }, :each) {|v| xxx v }
+
+ xxx 1
+ q.comma_breakable
+ xxx 2
+ q.comma_breakable
+ xxx 3
+
+= Object
+--- pretty_print(pp)
+ is a default pretty printing method for general objects.
+ It calls (({pretty_print_instance_variables})) to list instance variables.
+
+ If (({self})) has a customized (redefined) (({inspect})) method,
+ the result of (({self.inspect})) is used but it obviously has no
+ line break hints.
+
+ This module provides predefined pretty_print() methods for some of
+ the most commonly used built-in classes for convenience.
+
+--- pretty_print_cycle(pp)
+ is a default pretty printing method for general objects that are
+ detected as part of a cycle.
+
+--- pretty_print_instance_variables
+ returns a sorted array of instance variable names.
+
+ This method should return an array of names of instance variables as symbols or strings as:
+ (({[:@a, :@b]})).
+
+--- pretty_print_inspect
+ is (({inspect})) implementation using (({pretty_print})).
+ If you implement (({pretty_print})), it can be used as follows.
+
+ alias inspect pretty_print_inspect
+
+== AUTHOR
+Tanaka Akira <akr@m17n.org>
+=end
+
+require 'prettyprint'
+
+module Kernel
+ private
+ def pp(*objs)
+ objs.each {|obj|
+ PP.pp(obj)
+ }
+ nil
+ end
+ module_function :pp
+end
+
+class PP < PrettyPrint
+ def PP.pp(obj, out=$>, width=79)
+ q = PP.new(out, width)
+ q.guard_inspect_key {q.pp obj}
+ q.flush
+ #$pp = q
+ out << "\n"
+ end
+
+ def PP.singleline_pp(obj, out=$>)
+ q = SingleLine.new(out)
+ q.guard_inspect_key {q.pp obj}
+ q.flush
+ out
+ end
+
+ @sharing_detection = false
+ class << self
+ attr_accessor :sharing_detection
+ end
+
+ module PPMethods
+ InspectKey = :__inspect_key__
+
+ def guard_inspect_key
+ if Thread.current[InspectKey] == nil
+ Thread.current[InspectKey] = []
+ end
+
+ save = Thread.current[InspectKey]
+
+ begin
+ Thread.current[InspectKey] = []
+ yield
+ ensure
+ Thread.current[InspectKey] = save
+ end
+ end
+
+ def pp(obj)
+ id = obj.__id__
+
+ if Thread.current[InspectKey].include? id
+ group {obj.pretty_print_cycle self}
+ return
+ end
+
+ begin
+ Thread.current[InspectKey] << id
+ group {obj.pretty_print self}
+ ensure
+ Thread.current[InspectKey].pop unless PP.sharing_detection
+ end
+ end
+
+ def object_group(obj, &block)
+ group(1, '#<' + obj.class.name, '>', &block)
+ end
+
+ def object_address_group(obj, &block)
+ group(1, "\#<#{obj.class}:#{("0x%x" % (obj.__id__ * 2)).sub(/\.\.f/, '')}", '>', &block)
+ end
+
+ def comma_breakable
+ text ','
+ breakable
+ end
+
+ def seplist(list, sep=nil, iter_method=:each)
+ sep ||= lambda { comma_breakable }
+ first = true
+ list.__send__(iter_method) {|*v|
+ if first
+ first = false
+ else
+ sep.call
+ end
+ yield(*v)
+ }
+ end
+
+ def pp_object(obj)
+ object_address_group(obj) {
+ seplist(obj.pretty_print_instance_variables, lambda { text ',' }) {|v|
+ breakable
+ v = v.to_s if Symbol === v
+ text v
+ text '='
+ group(1) {
+ breakable ''
+ pp(obj.instance_eval(v))
+ }
+ }
+ }
+ end
+
+ def pp_hash(obj)
+ group(1, '{', '}') {
+ seplist(obj, nil, :each_pair) {|k, v|
+ group {
+ pp k
+ text '=>'
+ group(1) {
+ breakable ''
+ pp v
+ }
+ }
+ }
+ }
+ end
+ end
+
+ include PPMethods
+
+ class SingleLine < PrettyPrint::SingleLine
+ include PPMethods
+ end
+
+ module ObjectMixin
+ # 1. specific pretty_print
+ # 2. specific inspect
+ # 3. specific to_s if instance variable is empty
+ # 4. generic pretty_print
+
+ def pretty_print(q)
+ if /\(Kernel\)#/ !~ method(:inspect).inspect
+ q.text self.inspect
+ elsif /\(Kernel\)#/ !~ method(:to_s).inspect && instance_variables.empty?
+ q.text self.to_s
+ else
+ q.pp_object(self)
+ end
+ end
+
+ def pretty_print_cycle(q)
+ q.object_address_group(self) {
+ q.breakable
+ q.text '...'
+ }
+ end
+
+ def pretty_print_instance_variables
+ instance_variables.sort
+ end
+
+ def pretty_print_inspect
+ if /\(PP::ObjectMixin\)#/ =~ method(:pretty_print).inspect
+ raise "pretty_print is not overridden."
+ end
+ PP.singleline_pp(self, '')
+ end
+ end
+end
+
+class Array
+ def pretty_print(q)
+ q.group(1, '[', ']') {
+ q.seplist(self) {|v|
+ q.pp v
+ }
+ }
+ end
+
+ def pretty_print_cycle(q)
+ q.text(empty? ? '[]' : '[...]')
+ end
+end
+
+class Hash
+ def pretty_print(q)
+ q.pp_hash self
+ end
+
+ def pretty_print_cycle(q)
+ q.text(empty? ? '{}' : '{...}')
+ end
+end
+
+class << ENV
+ def pretty_print(q)
+ q.pp_hash self
+ end
+end
+
+class Struct
+ def pretty_print(q)
+ q.group(1, '#<struct ' + self.class.name, '>') {
+ q.seplist(self.members, lambda { q.text "," }) {|member|
+ q.breakable
+ q.text member.to_s
+ q.text '='
+ q.group(1) {
+ q.breakable ''
+ q.pp self[member]
+ }
+ }
+ }
+ end
+
+ def pretty_print_cycle(q)
+ q.text sprintf("#<struct %s:...>", self.class.name)
+ end
+end
+
+class Range
+ def pretty_print(q)
+ q.pp self.begin
+ q.breakable ''
+ q.text(self.exclude_end? ? '...' : '..')
+ q.breakable ''
+ q.pp self.end
+ end
+end
+
+class File
+ class Stat
+ def pretty_print(q)
+ require 'etc.so'
+ q.object_group(self) {
+ q.breakable
+ q.text sprintf("dev=0x%x", self.dev); q.comma_breakable
+ q.text "ino="; q.pp self.ino; q.comma_breakable
+ q.group {
+ m = self.mode
+ q.text sprintf("mode=0%o", m)
+ q.breakable
+ q.text sprintf("(%s %c%c%c%c%c%c%c%c%c)",
+ self.ftype,
+ (m & 0400 == 0 ? ?- : ?r),
+ (m & 0200 == 0 ? ?- : ?w),
+ (m & 0100 == 0 ? (m & 04000 == 0 ? ?- : ?S) :
+ (m & 04000 == 0 ? ?x : ?s)),
+ (m & 0040 == 0 ? ?- : ?r),
+ (m & 0020 == 0 ? ?- : ?w),
+ (m & 0010 == 0 ? (m & 02000 == 0 ? ?- : ?S) :
+ (m & 02000 == 0 ? ?x : ?s)),
+ (m & 0004 == 0 ? ?- : ?r),
+ (m & 0002 == 0 ? ?- : ?w),
+ (m & 0001 == 0 ? (m & 01000 == 0 ? ?- : ?T) :
+ (m & 01000 == 0 ? ?x : ?t)))
+ }
+ q.comma_breakable
+ q.text "nlink="; q.pp self.nlink; q.comma_breakable
+ q.group {
+ q.text "uid="; q.pp self.uid
+ begin
+ name = Etc.getpwuid(self.uid).name
+ q.breakable; q.text "(#{name})"
+ rescue ArgumentError
+ end
+ }
+ q.comma_breakable
+ q.group {
+ q.text "gid="; q.pp self.gid
+ begin
+ name = Etc.getgrgid(self.gid).name
+ q.breakable; q.text "(#{name})"
+ rescue ArgumentError
+ end
+ }
+ q.comma_breakable
+ q.group {
+ q.text sprintf("rdev=0x%x", self.rdev)
+ q.breakable
+ q.text sprintf('(%d, %d)', self.rdev_major, self.rdev_minor)
+ }
+ q.comma_breakable
+ q.text "size="; q.pp self.size; q.comma_breakable
+ q.text "blksize="; q.pp self.blksize; q.comma_breakable
+ q.text "blocks="; q.pp self.blocks; q.comma_breakable
+ q.group {
+ t = self.atime
+ q.text "atime="; q.pp t
+ q.breakable; q.text "(#{t.tv_sec})"
+ }
+ q.comma_breakable
+ q.group {
+ t = self.mtime
+ q.text "mtime="; q.pp t
+ q.breakable; q.text "(#{t.tv_sec})"
+ }
+ q.comma_breakable
+ q.group {
+ t = self.ctime
+ q.text "ctime="; q.pp t
+ q.breakable; q.text "(#{t.tv_sec})"
+ }
+ }
+ end
+ end
+end
+
+class MatchData
+ def pretty_print(q)
+ q.object_group(self) {
+ q.breakable
+ q.seplist(1..self.size, lambda { q.breakable }) {|i|
+ q.pp self[i-1]
+ }
+ }
+ end
+end
+
+class Object
+ include PP::ObjectMixin
+end
+
+[Numeric, Symbol, FalseClass, TrueClass, NilClass, Module].each {|c|
+ c.class_eval {
+ def pretty_print_cycle(q)
+ q.text inspect
+ end
+ }
+}
+
+[Numeric, FalseClass, TrueClass, Module].each {|c|
+ c.class_eval {
+ def pretty_print(q)
+ q.text inspect
+ end
+ }
+}
+
+if __FILE__ == $0
+ require 'test/unit'
+
+ class PPTest < Test::Unit::TestCase
+ def test_list0123_12
+ assert_equal("[0, 1, 2, 3]\n", PP.pp([0,1,2,3], '', 12))
+ end
+
+ def test_list0123_11
+ assert_equal("[0,\n 1,\n 2,\n 3]\n", PP.pp([0,1,2,3], '', 11))
+ end
+ end
+
+ class HasInspect
+ def initialize(a)
+ @a = a
+ end
+
+ def inspect
+ return "<inspect:#{@a.inspect}>"
+ end
+ end
+
+ class HasPrettyPrint
+ def initialize(a)
+ @a = a
+ end
+
+ def pretty_print(q)
+ q.text "<pretty_print:"
+ q.pp @a
+ q.text ">"
+ end
+ end
+
+ class HasBoth
+ def initialize(a)
+ @a = a
+ end
+
+ def inspect
+ return "<inspect:#{@a.inspect}>"
+ end
+
+ def pretty_print(q)
+ q.text "<pretty_print:"
+ q.pp @a
+ q.text ">"
+ end
+ end
+
+ class PrettyPrintInspect < HasPrettyPrint
+ alias inspect pretty_print_inspect
+ end
+
+ class PrettyPrintInspectWithoutPrettyPrint
+ alias inspect pretty_print_inspect
+ end
+
+ class PPInspectTest < Test::Unit::TestCase
+ def test_hasinspect
+ a = HasInspect.new(1)
+ assert_equal("<inspect:1>\n", PP.pp(a, ''))
+ end
+
+ def test_hasprettyprint
+ a = HasPrettyPrint.new(1)
+ assert_equal("<pretty_print:1>\n", PP.pp(a, ''))
+ end
+
+ def test_hasboth
+ a = HasBoth.new(1)
+ assert_equal("<pretty_print:1>\n", PP.pp(a, ''))
+ end
+
+ def test_pretty_print_inspect
+ a = PrettyPrintInspect.new(1)
+ assert_equal("<pretty_print:1>", a.inspect)
+ a = PrettyPrintInspectWithoutPrettyPrint.new
+ assert_raise(RuntimeError) { a.inspect }
+ end
+
+ def test_proc
+ a = proc {1}
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ end
+
+ def test_to_s_with_iv
+ a = Object.new
+ def a.to_s() "aaa" end
+ a.instance_eval { @a = nil }
+ result = PP.pp(a, '')
+ assert_equal("#{a.inspect}\n", result)
+ assert_match(/\A#<Object.*>\n\z/m, result)
+ a = 1.0
+ a.instance_eval { @a = nil }
+ result = PP.pp(a, '')
+ assert_equal("#{a.inspect}\n", result)
+ end
+
+ def test_to_s_without_iv
+ a = Object.new
+ def a.to_s() "aaa" end
+ result = PP.pp(a, '')
+ assert_equal("#{a.inspect}\n", result)
+ assert_equal("aaa\n", result)
+ end
+ end
+
+ class PPCycleTest < Test::Unit::TestCase
+ def test_array
+ a = []
+ a << a
+ assert_equal("[[...]]\n", PP.pp(a, ''))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ end
+
+ def test_hash
+ a = {}
+ a[0] = a
+ assert_equal("{0=>{...}}\n", PP.pp(a, ''))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ end
+
+ S = Struct.new("S", :a, :b)
+ def test_struct
+ a = S.new(1,2)
+ a.b = a
+ assert_equal("#<struct Struct::S a=1, b=#<struct Struct::S:...>>\n", PP.pp(a, ''))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ end
+
+ def test_object
+ a = Object.new
+ a.instance_eval {@a = a}
+ assert_equal(a.inspect + "\n", PP.pp(a, ''))
+ end
+
+ def test_anonymous
+ a = Class.new.new
+ assert_equal(a.inspect + "\n", PP.pp(a, ''))
+ end
+
+ def test_withinspect
+ a = []
+ a << HasInspect.new(a)
+ assert_equal("[<inspect:[...]>]\n", PP.pp(a, ''))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ end
+
+ def test_share_nil
+ begin
+ PP.sharing_detection = true
+ a = [nil, nil]
+ assert_equal("[nil, nil]\n", PP.pp(a, ''))
+ ensure
+ PP.sharing_detection = false
+ end
+ end
+ end
+
+ class PPSingleLineTest < Test::Unit::TestCase
+ def test_hash
+ assert_equal("{1=>1}", PP.singleline_pp({ 1 => 1}, '')) # [ruby-core:02699]
+ assert_equal("[1#{', 1'*99}]", PP.singleline_pp([1]*100, ''))
+ end
+ end
+end
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
new file mode 100644
index 0000000000..7b38cc0112
--- /dev/null
+++ b/lib/prettyprint.rb
@@ -0,0 +1,914 @@
+# $Id$
+
+=begin
+= PrettyPrint
+The class implements pretty printing algorithm.
+It finds line breaks and nice indentations for grouped structure.
+
+By default, the class assumes that primitive elements are strings and
+each byte in the strings have single column in width.
+But it can be used for other situations
+by giving suitable arguments for some methods:
+newline object and space generation block for (({PrettyPrint.new})),
+optional width argument for (({PrettyPrint#text})),
+(({PrettyPrint#breakable})), etc.
+There are several candidates to use them:
+text formatting using proportional fonts,
+multibyte characters which has columns different to number of bytes,
+non-string formatting, etc.
+
+== class methods
+--- PrettyPrint.new([output[, maxwidth[, newline]]]) [{|width| ...}]
+ creates a buffer for pretty printing.
+
+ ((|output|)) is an output target.
+ If it is not specified, (({''})) is assumed.
+ It should have a (({<<})) method which accepts
+ the first argument ((|obj|)) of (({PrettyPrint#text})),
+ the first argument ((|sep|)) of (({PrettyPrint#breakable})),
+ the first argument ((|newline|)) of (({PrettyPrint.new})),
+ and
+ the result of a given block for (({PrettyPrint.new})).
+
+ ((|maxwidth|)) specifies maximum line length.
+ If it is not specified, 79 is assumed.
+ However actual outputs may overflow ((|maxwidth|)) if
+ long non-breakable texts are provided.
+
+ ((|newline|)) is used for line breaks.
+ (({"\n"})) is used if it is not specified.
+
+ The block is used to generate spaces.
+ (({{|width| ' ' * width}})) is used if it is not given.
+
+--- PrettyPrint.format([output[, maxwidth[, newline[, genspace]]]]) {|q| ...}
+ is a convenience method which is same as follows:
+
+ begin
+ q = PrettyPrint.new(output, maxwidth, newline, &genspace)
+ ...
+ q.flush
+ output
+ end
+
+--- PrettyPrint.singleline_format([output[, maxwidth[, newline[, genspace]]]]) {|q| ...}
+ is similar to (({PrettyPrint.format})) but the result has no breaks.
+
+ ((|maxwidth|)), ((|newline|)) and ((|genspace|)) are ignored.
+ The invocation of (({breakable})) in the block doesn't break a line and
+ treated as just an invocation of (({text})).
+
+== methods
+--- text(obj[, width])
+ adds ((|obj|)) as a text of ((|width|)) columns in width.
+
+ If ((|width|)) is not specified, (({((|obj|)).length})) is used.
+
+--- breakable([sep[, width]])
+ tells "you can break a line here if necessary", and a
+ ((|width|))-column text ((|sep|)) is inserted if a line is not
+ broken at the point.
+
+ If ((|sep|)) is not specified, (({" "})) is used.
+
+ If ((|width|)) is not specified, (({((|sep|)).length})) is used.
+ You will have to specify this when ((|sep|)) is a multibyte
+ character, for example.
+
+--- nest(indent) {...}
+ increases left margin after newline with ((|indent|)) for line breaks added
+ in the block.
+
+--- group([indent[, open_obj[, close_obj[, open_width[, close_width]]]]]) {...}
+ groups line break hints added in the block.
+ The line break hints are all to be breaked or not.
+
+ If ((|indent|)) is specified, the method call is regarded as nested by
+ (({nest(((|indent|))) { ... }})).
+
+ If ((|open_obj|)) is specified, (({text open_obj, open_width})) is called
+ at first.
+ If ((|close_obj|)) is specified, (({text close_obj, close_width})) is
+ called at last.
+
+--- flush
+ outputs buffered data.
+
+--- first?
+ first? is obsoleted at 1.8.2.
+
+ first? is a predicate to test the call is a first call to (({first?})) with
+ current group.
+ It is useful to format comma separated values as:
+
+ q.group(1, '[', ']') {
+ xxx.each {|yyy|
+ unless q.first?
+ q.text ','
+ q.breakable
+ end
+ ... pretty printing yyy ...
+ }
+ }
+
+== Bugs
+* Box based formatting? Other (better) model/algorithm?
+
+== References
+Christian Lindig, Strictly Pretty, March 2000,
+((<URL:http://www.st.cs.uni-sb.de/~lindig/papers/#pretty>))
+
+Philip Wadler, A prettier printer, March 1998,
+((<URL:http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier>))
+
+== AUTHOR
+Tanaka Akira <akr@m17n.org>
+=end
+
+class PrettyPrint
+ def PrettyPrint.format(output='', maxwidth=79, newline="\n", genspace=lambda {|n| ' ' * n})
+ q = PrettyPrint.new(output, maxwidth, newline, &genspace)
+ yield q
+ q.flush
+ output
+ end
+
+ def PrettyPrint.singleline_format(output='', maxwidth=nil, newline=nil, genspace=nil)
+ q = SingleLine.new(output)
+ yield q
+ output
+ end
+
+ def initialize(output='', maxwidth=79, newline="\n", &genspace)
+ @output = output
+ @maxwidth = maxwidth
+ @newline = newline
+ @genspace = genspace || lambda {|n| ' ' * n}
+
+ @output_width = 0
+ @buffer_width = 0
+ @buffer = []
+
+ root_group = Group.new(0)
+ @group_stack = [root_group]
+ @group_queue = GroupQueue.new(root_group)
+ @indent = 0
+ end
+ attr_reader :output, :maxwidth, :newline, :genspace
+ attr_reader :indent, :group_queue
+
+ def current_group
+ @group_stack.last
+ end
+
+ def first?
+ warn "PrettyPrint#first? is obsoleted at 1.8.2."
+ current_group.first?
+ end
+
+ def break_outmost_groups
+ while @maxwidth < @output_width + @buffer_width
+ return unless group = @group_queue.deq
+ until group.breakables.empty?
+ data = @buffer.shift
+ @output_width = data.output(@output, @output_width)
+ @buffer_width -= data.width
+ end
+ while !@buffer.empty? && Text === @buffer.first
+ text = @buffer.shift
+ @output_width = text.output(@output, @output_width)
+ @buffer_width -= text.width
+ end
+ end
+ end
+
+ def text(obj, width=obj.length)
+ if @buffer.empty?
+ @output << obj
+ @output_width += width
+ else
+ text = @buffer.last
+ unless Text === text
+ text = Text.new
+ @buffer << text
+ end
+ text.add(obj, width)
+ @buffer_width += width
+ break_outmost_groups
+ end
+ end
+
+ def fill_breakable(sep=' ', width=sep.length)
+ group { breakable sep, width }
+ end
+
+ def breakable(sep=' ', width=sep.length)
+ group = @group_stack.last
+ if group.break?
+ flush
+ @output << @newline
+ @output << @genspace.call(@indent)
+ @output_width = @indent
+ @buffer_width = 0
+ else
+ @buffer << Breakable.new(sep, width, self)
+ @buffer_width += width
+ break_outmost_groups
+ end
+ end
+
+ def group(indent=0, open_obj='', close_obj='', open_width=open_obj.length, close_width=close_obj.length)
+ text open_obj, open_width
+ group_sub {
+ nest(indent) {
+ yield
+ }
+ }
+ text close_obj, close_width
+ end
+
+ def group_sub
+ group = Group.new(@group_stack.last.depth + 1)
+ @group_stack.push group
+ @group_queue.enq group
+ begin
+ yield
+ ensure
+ @group_stack.pop
+ if group.breakables.empty?
+ @group_queue.delete group
+ end
+ end
+ end
+
+ def nest(indent)
+ @indent += indent
+ begin
+ yield
+ ensure
+ @indent -= indent
+ end
+ end
+
+ def flush
+ @buffer.each {|data|
+ @output_width = data.output(@output, @output_width)
+ }
+ @buffer.clear
+ @buffer_width = 0
+ end
+
+ class Text
+ def initialize
+ @objs = []
+ @width = 0
+ end
+ attr_reader :width
+
+ def output(out, output_width)
+ @objs.each {|obj| out << obj}
+ output_width + @width
+ end
+
+ def add(obj, width)
+ @objs << obj
+ @width += width
+ end
+ end
+
+ class Breakable
+ def initialize(sep, width, q)
+ @obj = sep
+ @width = width
+ @pp = q
+ @indent = q.indent
+ @group = q.current_group
+ @group.breakables.push self
+ end
+ attr_reader :obj, :width, :indent
+
+ def output(out, output_width)
+ @group.breakables.shift
+ if @group.break?
+ out << @pp.newline
+ out << @pp.genspace.call(@indent)
+ @indent
+ else
+ @pp.group_queue.delete @group if @group.breakables.empty?
+ out << @obj
+ output_width + @width
+ end
+ end
+ end
+
+ class Group
+ def initialize(depth)
+ @depth = depth
+ @breakables = []
+ @break = false
+ end
+ attr_reader :depth, :breakables
+
+ def break
+ @break = true
+ end
+
+ def break?
+ @break
+ end
+
+ def first?
+ if defined? @first
+ false
+ else
+ @first = false
+ true
+ end
+ end
+ end
+
+ class GroupQueue
+ def initialize(*groups)
+ @queue = []
+ groups.each {|g| enq g}
+ end
+
+ def enq(group)
+ depth = group.depth
+ @queue << [] until depth < @queue.length
+ @queue[depth] << group
+ end
+
+ def deq
+ @queue.each {|gs|
+ (gs.length-1).downto(0) {|i|
+ unless gs[i].breakables.empty?
+ group = gs.slice!(i, 1).first
+ group.break
+ return group
+ end
+ }
+ gs.each {|group| group.break}
+ gs.clear
+ }
+ return nil
+ end
+
+ def delete(group)
+ @queue[group.depth].delete(group)
+ end
+ end
+
+ class SingleLine
+ def initialize(output, maxwidth=nil, newline=nil)
+ @output = output
+ @first = [true]
+ end
+
+ def text(obj, width=nil)
+ @output << obj
+ end
+
+ def breakable(sep=' ', width=nil)
+ @output << sep
+ end
+
+ def nest(indent)
+ yield
+ end
+
+ def group(indent=nil, open_obj='', close_obj='', open_width=nil, close_width=nil)
+ @first.push true
+ @output << open_obj
+ yield
+ @output << close_obj
+ @first.pop
+ end
+
+ def flush
+ end
+
+ def first?
+ result = @first[-1]
+ @first[-1] = false
+ result
+ end
+ end
+end
+
+if __FILE__ == $0
+ require 'test/unit'
+
+ class WadlerExample < Test::Unit::TestCase
+ def setup
+ @tree = Tree.new("aaaa", Tree.new("bbbbb", Tree.new("ccc"),
+ Tree.new("dd")),
+ Tree.new("eee"),
+ Tree.new("ffff", Tree.new("gg"),
+ Tree.new("hhh"),
+ Tree.new("ii")))
+ end
+
+ def hello(width)
+ PrettyPrint.format('', width) {|hello|
+ hello.group {
+ hello.group {
+ hello.group {
+ hello.group {
+ hello.text 'hello'
+ hello.breakable; hello.text 'a'
+ }
+ hello.breakable; hello.text 'b'
+ }
+ hello.breakable; hello.text 'c'
+ }
+ hello.breakable; hello.text 'd'
+ }
+ }
+ end
+
+ def test_hello_00_06
+ expected = <<'End'.chomp
+hello
+a
+b
+c
+d
+End
+ assert_equal(expected, hello(0))
+ assert_equal(expected, hello(6))
+ end
+
+ def test_hello_07_08
+ expected = <<'End'.chomp
+hello a
+b
+c
+d
+End
+ assert_equal(expected, hello(7))
+ assert_equal(expected, hello(8))
+ end
+
+ def test_hello_09_10
+ expected = <<'End'.chomp
+hello a b
+c
+d
+End
+ out = hello(9); assert_equal(expected, out)
+ out = hello(10); assert_equal(expected, out)
+ end
+
+ def test_hello_11_12
+ expected = <<'End'.chomp
+hello a b c
+d
+End
+ assert_equal(expected, hello(11))
+ assert_equal(expected, hello(12))
+ end
+
+ def test_hello_13
+ expected = <<'End'.chomp
+hello a b c d
+End
+ assert_equal(expected, hello(13))
+ end
+
+ def tree(width)
+ PrettyPrint.format('', width) {|q| @tree.show(q)}
+ end
+
+ def test_tree_00_19
+ expected = <<'End'.chomp
+aaaa[bbbbb[ccc,
+ dd],
+ eee,
+ ffff[gg,
+ hhh,
+ ii]]
+End
+ assert_equal(expected, tree(0))
+ assert_equal(expected, tree(19))
+ end
+
+ def test_tree_20_22
+ expected = <<'End'.chomp
+aaaa[bbbbb[ccc, dd],
+ eee,
+ ffff[gg,
+ hhh,
+ ii]]
+End
+ assert_equal(expected, tree(20))
+ assert_equal(expected, tree(22))
+ end
+
+ def test_tree_23_43
+ expected = <<'End'.chomp
+aaaa[bbbbb[ccc, dd],
+ eee,
+ ffff[gg, hhh, ii]]
+End
+ assert_equal(expected, tree(23))
+ assert_equal(expected, tree(43))
+ end
+
+ def test_tree_44
+ assert_equal(<<'End'.chomp, tree(44))
+aaaa[bbbbb[ccc, dd], eee, ffff[gg, hhh, ii]]
+End
+ end
+
+ def tree_alt(width)
+ PrettyPrint.format('', width) {|q| @tree.altshow(q)}
+ end
+
+ def test_tree_alt_00_18
+ expected = <<'End'.chomp
+aaaa[
+ bbbbb[
+ ccc,
+ dd
+ ],
+ eee,
+ ffff[
+ gg,
+ hhh,
+ ii
+ ]
+]
+End
+ assert_equal(expected, tree_alt(0))
+ assert_equal(expected, tree_alt(18))
+ end
+
+ def test_tree_alt_19_20
+ expected = <<'End'.chomp
+aaaa[
+ bbbbb[ ccc, dd ],
+ eee,
+ ffff[
+ gg,
+ hhh,
+ ii
+ ]
+]
+End
+ assert_equal(expected, tree_alt(19))
+ assert_equal(expected, tree_alt(20))
+ end
+
+ def test_tree_alt_20_49
+ expected = <<'End'.chomp
+aaaa[
+ bbbbb[ ccc, dd ],
+ eee,
+ ffff[ gg, hhh, ii ]
+]
+End
+ assert_equal(expected, tree_alt(21))
+ assert_equal(expected, tree_alt(49))
+ end
+
+ def test_tree_alt_50
+ expected = <<'End'.chomp
+aaaa[ bbbbb[ ccc, dd ], eee, ffff[ gg, hhh, ii ] ]
+End
+ assert_equal(expected, tree_alt(50))
+ end
+
+ class Tree
+ def initialize(string, *children)
+ @string = string
+ @children = children
+ end
+
+ def show(q)
+ q.group {
+ q.text @string
+ q.nest(@string.length) {
+ unless @children.empty?
+ q.text '['
+ q.nest(1) {
+ first = true
+ @children.each {|t|
+ if first
+ first = false
+ else
+ q.text ','
+ q.breakable
+ end
+ t.show(q)
+ }
+ }
+ q.text ']'
+ end
+ }
+ }
+ end
+
+ def altshow(q)
+ q.group {
+ q.text @string
+ unless @children.empty?
+ q.text '['
+ q.nest(2) {
+ q.breakable
+ first = true
+ @children.each {|t|
+ if first
+ first = false
+ else
+ q.text ','
+ q.breakable
+ end
+ t.altshow(q)
+ }
+ }
+ q.breakable
+ q.text ']'
+ end
+ }
+ end
+
+ end
+ end
+
+ class StrictPrettyExample < Test::Unit::TestCase
+ def prog(width)
+ PrettyPrint.format('', width) {|q|
+ q.group {
+ q.group {q.nest(2) {
+ q.text "if"; q.breakable;
+ q.group {
+ q.nest(2) {
+ q.group {q.text "a"; q.breakable; q.text "=="}
+ q.breakable; q.text "b"}}}}
+ q.breakable
+ q.group {q.nest(2) {
+ q.text "then"; q.breakable;
+ q.group {
+ q.nest(2) {
+ q.group {q.text "a"; q.breakable; q.text "<<"}
+ q.breakable; q.text "2"}}}}
+ q.breakable
+ q.group {q.nest(2) {
+ q.text "else"; q.breakable;
+ q.group {
+ q.nest(2) {
+ q.group {q.text "a"; q.breakable; q.text "+"}
+ q.breakable; q.text "b"}}}}}
+ }
+ end
+
+ def test_00_04
+ expected = <<'End'.chomp
+if
+ a
+ ==
+ b
+then
+ a
+ <<
+ 2
+else
+ a
+ +
+ b
+End
+ assert_equal(expected, prog(0))
+ assert_equal(expected, prog(4))
+ end
+
+ def test_05
+ expected = <<'End'.chomp
+if
+ a
+ ==
+ b
+then
+ a
+ <<
+ 2
+else
+ a +
+ b
+End
+ assert_equal(expected, prog(5))
+ end
+
+ def test_06
+ expected = <<'End'.chomp
+if
+ a ==
+ b
+then
+ a <<
+ 2
+else
+ a +
+ b
+End
+ assert_equal(expected, prog(6))
+ end
+
+ def test_07
+ expected = <<'End'.chomp
+if
+ a ==
+ b
+then
+ a <<
+ 2
+else
+ a + b
+End
+ assert_equal(expected, prog(7))
+ end
+
+ def test_08
+ expected = <<'End'.chomp
+if
+ a == b
+then
+ a << 2
+else
+ a + b
+End
+ assert_equal(expected, prog(8))
+ end
+
+ def test_09
+ expected = <<'End'.chomp
+if a == b
+then
+ a << 2
+else
+ a + b
+End
+ assert_equal(expected, prog(9))
+ end
+
+ def test_10
+ expected = <<'End'.chomp
+if a == b
+then
+ a << 2
+else a + b
+End
+ assert_equal(expected, prog(10))
+ end
+
+ def test_11_31
+ expected = <<'End'.chomp
+if a == b
+then a << 2
+else a + b
+End
+ assert_equal(expected, prog(11))
+ assert_equal(expected, prog(15))
+ assert_equal(expected, prog(31))
+ end
+
+ def test_32
+ expected = <<'End'.chomp
+if a == b then a << 2 else a + b
+End
+ assert_equal(expected, prog(32))
+ end
+
+ end
+
+ class TailGroup < Test::Unit::TestCase
+ def test_1
+ out = PrettyPrint.format('', 10) {|q|
+ q.group {
+ q.group {
+ q.text "abc"
+ q.breakable
+ q.text "def"
+ }
+ q.group {
+ q.text "ghi"
+ q.breakable
+ q.text "jkl"
+ }
+ }
+ }
+ assert_equal("abc defghi\njkl", out)
+ end
+ end
+
+ class NonString < Test::Unit::TestCase
+ def format(width)
+ PrettyPrint.format([], width, 'newline', lambda {|n| "#{n} spaces"}) {|q|
+ q.text(3, 3)
+ q.breakable(1, 1)
+ q.text(3, 3)
+ }
+ end
+
+ def test_6
+ assert_equal([3, "newline", "0 spaces", 3], format(6))
+ end
+
+ def test_7
+ assert_equal([3, 1, 3], format(7))
+ end
+
+ end
+
+ class Fill < Test::Unit::TestCase
+ def format(width)
+ PrettyPrint.format('', width) {|q|
+ q.group {
+ q.text 'abc'
+ q.fill_breakable
+ q.text 'def'
+ q.fill_breakable
+ q.text 'ghi'
+ q.fill_breakable
+ q.text 'jkl'
+ q.fill_breakable
+ q.text 'mno'
+ q.fill_breakable
+ q.text 'pqr'
+ q.fill_breakable
+ q.text 'stu'
+ }
+ }
+ end
+
+ def test_00_06
+ expected = <<'End'.chomp
+abc
+def
+ghi
+jkl
+mno
+pqr
+stu
+End
+ assert_equal(expected, format(0))
+ assert_equal(expected, format(6))
+ end
+
+ def test_07_10
+ expected = <<'End'.chomp
+abc def
+ghi jkl
+mno pqr
+stu
+End
+ assert_equal(expected, format(7))
+ assert_equal(expected, format(10))
+ end
+
+ def test_11_14
+ expected = <<'End'.chomp
+abc def ghi
+jkl mno pqr
+stu
+End
+ assert_equal(expected, format(11))
+ assert_equal(expected, format(14))
+ end
+
+ def test_15_18
+ expected = <<'End'.chomp
+abc def ghi jkl
+mno pqr stu
+End
+ assert_equal(expected, format(15))
+ assert_equal(expected, format(18))
+ end
+
+ def test_19_22
+ expected = <<'End'.chomp
+abc def ghi jkl mno
+pqr stu
+End
+ assert_equal(expected, format(19))
+ assert_equal(expected, format(22))
+ end
+
+ def test_23_26
+ expected = <<'End'.chomp
+abc def ghi jkl mno pqr
+stu
+End
+ assert_equal(expected, format(23))
+ assert_equal(expected, format(26))
+ end
+
+ def test_27
+ expected = <<'End'.chomp
+abc def ghi jkl mno pqr stu
+End
+ assert_equal(expected, format(27))
+ end
+
+ end
+end
diff --git a/lib/profile.rb b/lib/profile.rb
index b00caac42e..104cb205b9 100644
--- a/lib/profile.rb
+++ b/lib/profile.rb
@@ -1,55 +1,6 @@
+require 'profiler'
-module Profiler__
- Start = Float(Time.times[0])
- top = "toplevel".intern
- Stack = [[0, 0, top]]
- MAP = {"#toplevel" => [1, 0, 0, "#toplevel"]}
-
- p = proc{|event, file, line, id, binding, klass|
- case event
- when "call", "c-call"
- now = Float(Time.times[0])
- Stack.push [now, 0.0, id]
- when "return", "c-return"
- now = Float(Time.times[0])
- tick = Stack.pop
- name = klass.to_s
- if name.nil? then name = '' end
- if klass.kind_of? Class
- name += "#"
- else
- name += "."
- end
- name += id.id2name
- data = MAP[name]
- unless data
- data = [0.0, 0.0, 0.0, name]
- MAP[name] = data
- end
- data[0] += 1
- cost = now - tick[0]
- data[1] += cost
- data[2] += cost - tick[1]
- Stack[-1][1] += cost
- end
- }
- END {
- set_trace_func nil
- total = Float(Time.times[0]) - Start
- if total == 0 then total = 0.01 end
- MAP["#toplevel"][1] = total
-# f = open("./rmon.out", "w")
- f = STDERR
- data = MAP.values.sort!{|a,b| b[2] <=> a[2]}
- sum = 0
- f.printf " %% cumulative self self total\n"
- f.printf " time seconds seconds calls ms/call ms/call name\n"
- for d in data
- sum += d[2]
- f.printf "%6.2f %8.2f %8.2f %8d ", d[2]/total*100, sum, d[2], d[0]
- f.printf "%8.2f %8.2f %s\n", d[2]*1000/d[0], d[1]*1000/d[0], d[3]
- end
- f.close
- }
- set_trace_func p
-end
+END {
+ Profiler__::print_profile(STDERR)
+}
+Profiler__::start_profile
diff --git a/lib/profiler.rb b/lib/profiler.rb
new file mode 100644
index 0000000000..74e9b96295
--- /dev/null
+++ b/lib/profiler.rb
@@ -0,0 +1,59 @@
+module Profiler__
+ Times = if defined? Process.times then Process else Time end
+ # internal values
+ @@start = @@stack = @@map = nil
+ PROFILE_PROC = proc{|event, file, line, id, binding, klass|
+ case event
+ when "call", "c-call"
+ now = Float(Times::times[0])
+ @@stack.push [now, 0.0, id]
+ when "return", "c-return"
+ now = Float(Times::times[0])
+ tick = @@stack.pop
+ name = klass.to_s
+ if name.nil? then name = '' end
+ if klass.kind_of? Class
+ name += "#"
+ else
+ name += "."
+ end
+ name += id.id2name
+ data = @@map[name]
+ unless data
+ data = [0.0, 0.0, 0.0, name]
+ @@map[name] = data
+ end
+ data[0] += 1
+ cost = now - tick[0]
+ data[1] += cost
+ data[2] += cost - tick[1]
+ @@stack[-1][1] += cost
+ end
+ }
+module_function
+ def start_profile
+ @@start = Float(Times::times[0])
+ @@stack = [[0, 0, :toplevel], [0, 0, :dummy]]
+ @@map = {"#toplevel" => [1, 0, 0, "#toplevel"]}
+ set_trace_func PROFILE_PROC
+ end
+ def stop_profile
+ set_trace_func nil
+ end
+ def print_profile(f)
+ stop_profile
+ total = Float(Times::times[0]) - @@start
+ if total == 0 then total = 0.01 end
+ @@map["#toplevel"][1] = total
+ data = @@map.values
+ data.sort!{|a,b| b[2] <=> a[2]}
+ sum = 0
+ f.printf " %% cumulative self self total\n"
+ f.printf " time seconds seconds calls ms/call ms/call name\n"
+ for d in data
+ sum += d[2]
+ f.printf "%6.2f %8.2f %8.2f %8d ", d[2]/total*100, sum, d[2], d[0]
+ f.printf "%8.2f %8.2f %s\n", d[2]*1000/d[0], d[1]*1000/d[0], d[3]
+ end
+ end
+end
diff --git a/lib/pstore.rb b/lib/pstore.rb
index b3e1df8284..51cef6e134 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -12,7 +12,8 @@
# p db["root"]
# end
-require "ftools"
+require "fileutils"
+require "digest/md5"
class PStore
class Error < StandardError
@@ -23,9 +24,6 @@ class PStore
unless File::directory? dir
raise PStore::Error, format("directory %s does not exist", dir)
end
- unless File::writable? dir
- raise PStore::Error, format("directory %s not writable", dir)
- end
if File::exist? file and not File::readable? file
raise PStore::Error, format("file %s not readable", file)
end
@@ -37,22 +35,32 @@ class PStore
def in_transaction
raise PStore::Error, "not in transaction" unless @transaction
end
- private :in_transaction
+ def in_transaction_wr()
+ in_transaction()
+ raise PStore::Error, "in read-only transaction" if @rdonly
+ end
+ private :in_transaction, :in_transaction_wr
def [](name)
in_transaction
- value = @table[name]
- if value == nil
- raise PStore::Error, format("undefined root name `%s'", name)
+ @table[name]
+ end
+ def fetch(name, default=PStore::Error)
+ unless @table.key? name
+ if default==PStore::Error
+ raise PStore::Error, format("undefined root name `%s'", name)
+ else
+ default
+ end
end
- value
+ self[name]
end
def []=(name, value)
- in_transaction
+ in_transaction_wr()
@table[name] = value
end
def delete(name)
- in_transaction
+ in_transaction_wr()
@table.delete name
end
@@ -69,33 +77,54 @@ class PStore
end
def commit
+ in_transaction
@abort = false
throw :pstore_abort_transaction
end
def abort
+ in_transaction
@abort = true
throw :pstore_abort_transaction
end
- def transaction
+ def transaction(read_only=false)
raise PStore::Error, "nested transaction" if @transaction
begin
+ @rdonly = read_only
+ @abort = false
@transaction = true
value = nil
- backup = @filename+"~"
- if File::exist?(@filename)
- file = File::open(@filename, "r+")
- orig = true
+ new_file = @filename + ".new"
+
+ content = nil
+ unless read_only
+ file = File.open(@filename, File::RDWR | File::CREAT)
+ file.binmode
+ file.flock(File::LOCK_EX)
+ commit_new(file) if FileTest.exist?(new_file)
+ content = file.read()
else
- @table = {}
- file = File::open(@filename, "w+")
- Marshal::dump(@table, file)
+ begin
+ file = File.open(@filename, File::RDONLY)
+ file.binmode
+ file.flock(File::LOCK_SH)
+ content = (File.read(new_file) rescue file.read())
+ rescue Errno::ENOENT
+ content = ""
+ end
end
- file.flock(File::LOCK_EX)
- if orig
- File::copy @filename, backup
- @table = Marshal::load(file)
+
+ if content != ""
+ @table = load(content)
+ if !read_only
+ size = content.size
+ md5 = Digest::MD5.digest(content)
+ end
+ else
+ @table = {}
end
+ content = nil # unreference huge data
+
begin
catch(:pstore_abort_transaction) do
value = yield(self)
@@ -104,25 +133,51 @@ class PStore
@abort = true
raise
ensure
- unless @abort
- begin
- file.rewind
- Marshal::dump(@table, file)
- file.truncate(file.pos)
- rescue
- File::rename backup, @filename if File::exist?(backup)
- raise
- end
+ if !read_only and !@abort
+ tmp_file = @filename + ".tmp"
+ content = dump(@table)
+ if !md5 || size != content.size || md5 != Digest::MD5.digest(content)
+ File.open(tmp_file, "w") {|t|
+ t.binmode
+ t.write(content)
+ }
+ File.rename(tmp_file, new_file)
+ commit_new(file)
+ end
+ content = nil # unreference huge data
end
- @abort = false
end
ensure
@table = nil
@transaction = false
- file.close
+ file.close if file
end
value
end
+
+ def dump(table)
+ Marshal::dump(table)
+ end
+
+ def load(content)
+ Marshal::load(content)
+ end
+
+ def load_file(file)
+ Marshal::load(file)
+ end
+
+ private
+ def commit_new(f)
+ f.truncate(0)
+ f.rewind
+ new_file = @filename + ".new"
+ File.open(new_file) do |nf|
+ nf.binmode
+ FileUtils.copy_stream(nf, f)
+ end
+ File.unlink(new_file)
+ end
end
if __FILE__ == $0
@@ -139,4 +194,8 @@ if __FILE__ == $0
p db["root"][0]
end
end
+
+ db.transaction(true) do
+ p db["root"]
+ end
end
diff --git a/lib/racc/parser.rb b/lib/racc/parser.rb
new file mode 100644
index 0000000000..7d160f6c44
--- /dev/null
+++ b/lib/racc/parser.rb
@@ -0,0 +1,456 @@
+#
+# parser.rb
+#
+# Copyright (c) 1999-2003 Minero Aoki <aamine@loveruby.net>
+#
+# This program is free software.
+# You can distribute/modify this program under the same terms of ruby.
+#
+# As a special exception, when this code is copied by Racc
+# into a Racc output file, you may use that output file
+# without restriction.
+#
+# $raccId: parser.rb,v 1.4 2003/11/03 13:41:47 aamine Exp $
+#
+
+unless defined?(NotImplementedError)
+ NotImplementedError = NotImplementError
+end
+
+module Racc
+ class ParseError < StandardError; end
+end
+unless defined?(::ParseError)
+ ParseError = Racc::ParseError
+end
+
+
+module Racc
+
+ unless defined?(Racc_No_Extentions)
+ Racc_No_Extentions = false
+ end
+
+ class Parser
+
+ Racc_Runtime_Version = '1.4.4'
+ Racc_Runtime_Revision = '$raccRevision: 1.4 $'.split[1]
+
+ Racc_Runtime_Core_Version_R = '1.4.4'
+ Racc_Runtime_Core_Revision_R = '$raccRevision: 1.4 $'.split[1]
+ begin
+ require 'racc/cparse'
+ # Racc_Runtime_Core_Version_C = (defined in extension)
+ Racc_Runtime_Core_Revision_C = Racc_Runtime_Core_Id_C.split[2]
+ unless new.respond_to?(:_racc_do_parse_c, true)
+ raise LoadError, 'old cparse.so'
+ end
+ if Racc_No_Extentions
+ raise LoadError, 'selecting ruby version of racc runtime core'
+ end
+
+ Racc_Main_Parsing_Routine = :_racc_do_parse_c
+ Racc_YY_Parse_Method = :_racc_yyparse_c
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_C
+ Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_C
+ Racc_Runtime_Type = 'c'
+ rescue LoadError
+ Racc_Main_Parsing_Routine = :_racc_do_parse_rb
+ Racc_YY_Parse_Method = :_racc_yyparse_rb
+ Racc_Runtime_Core_Version = Racc_Runtime_Core_Version_R
+ Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
+ Racc_Runtime_Type = 'ruby'
+ end
+
+ def Parser.racc_runtime_type
+ Racc_Runtime_Type
+ end
+
+ private
+
+ def _racc_setup
+ @yydebug = false unless self.class::Racc_debug_parser
+ @yydebug = false unless defined?(@yydebug)
+ if @yydebug
+ @racc_debug_out = $stderr unless defined?(@racc_debug_out)
+ @racc_debug_out ||= $stderr
+ end
+ arg = self.class::Racc_arg
+ arg[13] = true if arg.size < 14
+ arg
+ end
+
+ def _racc_init_sysvars
+ @racc_state = [0]
+ @racc_tstack = []
+ @racc_vstack = []
+
+ @racc_t = nil
+ @racc_val = nil
+
+ @racc_read_next = true
+
+ @racc_user_yyerror = false
+ @racc_error_status = 0
+ end
+
+ ###
+ ### do_parse
+ ###
+
+ def do_parse
+ __send__(Racc_Main_Parsing_Routine, _racc_setup(), false)
+ end
+
+ def next_token
+ raise NotImplementedError, "#{self.class}\#next_token is not defined"
+ end
+
+ def _racc_do_parse_rb( arg, in_debug )
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+
+ _racc_init_sysvars
+ tok = act = i = nil
+ nerr = 0
+
+ catch(:racc_end_parse) {
+ while true
+ if i = action_pointer[@racc_state[-1]]
+ if @racc_read_next
+ if @racc_t != 0 # not EOF
+ tok, @racc_val = next_token()
+ unless tok # EOF
+ @racc_t = 0
+ else
+ @racc_t = (token_table[tok] or 1) # error token
+ end
+ racc_read_token(@racc_t, tok, @racc_val) if @yydebug
+ @racc_read_next = false
+ end
+ end
+ i += @racc_t
+ unless i >= 0 and
+ act = action_table[i] and
+ action_check[i] == @racc_state[-1]
+ act = action_default[@racc_state[-1]]
+ end
+ else
+ act = action_default[@racc_state[-1]]
+ end
+ while act = _racc_evalact(act, arg)
+ ;
+ end
+ end
+ }
+ end
+
+ ###
+ ### yyparse
+ ###
+
+ def yyparse( recv, mid )
+ __send__(Racc_YY_Parse_Method, recv, mid, _racc_setup(), true)
+ end
+
+ def _racc_yyparse_rb( recv, mid, arg, c_debug )
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+
+ _racc_init_sysvars
+ tok = nil
+ act = nil
+ i = nil
+ nerr = 0
+
+ catch(:racc_end_parse) {
+ until i = action_pointer[@racc_state[-1]]
+ while act = _racc_evalact(action_default[@racc_state[-1]], arg)
+ ;
+ end
+ end
+ recv.__send__(mid) do |tok, val|
+# $stderr.puts "rd: tok=#{tok}, val=#{val}"
+ unless tok
+ @racc_t = 0
+ else
+ @racc_t = (token_table[tok] or 1) # error token
+ end
+ @racc_val = val
+ @racc_read_next = false
+
+ i += @racc_t
+ unless i >= 0 and
+ act = action_table[i] and
+ action_check[i] == @racc_state[-1]
+ act = action_default[@racc_state[-1]]
+# $stderr.puts "02: act=#{act}"
+# $stderr.puts "curstate=#{@racc_state[-1]}"
+ else
+# $stderr.puts "01: act=#{act}"
+ end
+
+ while act = _racc_evalact(act, arg)
+ ;
+ end
+
+ while not (i = action_pointer[@racc_state[-1]]) or
+ not @racc_read_next or
+ @racc_t == 0 # $
+ unless i and i += @racc_t and
+ i >= 0 and
+ act = action_table[i] and
+ action_check[i] == @racc_state[-1]
+ act = action_default[@racc_state[-1]]
+# $stderr.puts "04: act=#{act}"
+ else
+# $stderr.puts "03: act=#{act}"
+ end
+ while act = _racc_evalact(act, arg)
+ ;
+ end
+ end
+ end
+ }
+ end
+
+ ###
+ ### common
+ ###
+
+ def _racc_evalact( act, arg )
+# $stderr.puts "ea: act=#{act}"
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+nerr = 0 # tmp
+
+ if act > 0 and act < shift_n
+ #
+ # shift
+ #
+ if @racc_error_status > 0
+ @racc_error_status -= 1 unless @racc_t == 1 # error token
+ end
+ @racc_vstack.push @racc_val
+ @racc_state.push act
+ @racc_read_next = true
+ if @yydebug
+ @racc_tstack.push @racc_t
+ racc_shift @racc_t, @racc_tstack, @racc_vstack
+ end
+
+ elsif act < 0 and act > -reduce_n
+ #
+ # reduce
+ #
+ code = catch(:racc_jump) {
+ @racc_state.push _racc_do_reduce(arg, act)
+ false
+ }
+ if code
+ case code
+ when 1 # yyerror
+ @racc_user_yyerror = true # user_yyerror
+ return -reduce_n
+ when 2 # yyaccept
+ return shift_n
+ else
+ raise RuntimeError, '[Racc Bug] unknown jump code'
+ end
+ end
+
+ elsif act == shift_n
+ #
+ # accept
+ #
+ racc_accept if @yydebug
+ throw :racc_end_parse, @racc_vstack[0]
+
+ elsif act == -reduce_n
+ #
+ # error
+ #
+ case @racc_error_status
+ when 0
+ unless arg[21] # user_yyerror
+ nerr += 1
+ on_error @racc_t, @racc_val, @racc_vstack
+ end
+ when 3
+ if @racc_t == 0 # is $
+ throw :racc_end_parse, nil
+ end
+ @racc_read_next = true
+ end
+ @racc_user_yyerror = false
+ @racc_error_status = 3
+ while true
+ if i = action_pointer[@racc_state[-1]]
+ i += 1 # error token
+ if i >= 0 and
+ (act = action_table[i]) and
+ action_check[i] == @racc_state[-1]
+ break
+ end
+ end
+
+ throw :racc_end_parse, nil if @racc_state.size <= 1
+ @racc_state.pop
+ @racc_vstack.pop
+ if @yydebug
+ @racc_tstack.pop
+ racc_e_pop @racc_state, @racc_tstack, @racc_vstack
+ end
+ end
+ return act
+
+ else
+ raise RuntimeError, "[Racc Bug] unknown action #{act.inspect}"
+ end
+
+ racc_next_state(@racc_state[-1], @racc_state) if @yydebug
+
+ nil
+ end
+
+ def _racc_do_reduce( arg, act )
+ action_table, action_check, action_default, action_pointer,
+ goto_table, goto_check, goto_default, goto_pointer,
+ nt_base, reduce_table, token_table, shift_n,
+ reduce_n, use_result, * = arg
+ state = @racc_state
+ vstack = @racc_vstack
+ tstack = @racc_tstack
+
+ i = act * -3
+ len = reduce_table[i]
+ reduce_to = reduce_table[i+1]
+ method_id = reduce_table[i+2]
+ void_array = []
+
+ tmp_t = tstack[-len, len] if @yydebug
+ tmp_v = vstack[-len, len]
+ tstack[-len, len] = void_array if @yydebug
+ vstack[-len, len] = void_array
+ state[-len, len] = void_array
+
+ # tstack must be updated AFTER method call
+ if use_result
+ vstack.push __send__(method_id, tmp_v, vstack, tmp_v[0])
+ else
+ vstack.push __send__(method_id, tmp_v, vstack)
+ end
+ tstack.push reduce_to
+
+ racc_reduce(tmp_t, reduce_to, tstack, vstack) if @yydebug
+
+ k1 = reduce_to - nt_base
+ if i = goto_pointer[k1]
+ i += state[-1]
+ if i >= 0 and (curstate = goto_table[i]) and goto_check[i] == k1
+ return curstate
+ end
+ end
+ goto_default[k1]
+ end
+
+ def on_error( t, val, vstack )
+ raise ParseError, sprintf("\nparse error on value %s (%s)",
+ val.inspect, token_to_str(t) || '?')
+ end
+
+ def yyerror
+ throw :racc_jump, 1
+ end
+
+ def yyaccept
+ throw :racc_jump, 2
+ end
+
+ def yyerrok
+ @racc_error_status = 0
+ end
+
+ #
+ # for debugging output
+ #
+
+ def racc_read_token( t, tok, val )
+ @racc_debug_out.print 'read '
+ @racc_debug_out.print tok.inspect, '(', racc_token2str(t), ') '
+ @racc_debug_out.puts val.inspect
+ @racc_debug_out.puts
+ end
+
+ def racc_shift( tok, tstack, vstack )
+ @racc_debug_out.puts "shift #{racc_token2str tok}"
+ racc_print_stacks tstack, vstack
+ @racc_debug_out.puts
+ end
+
+ def racc_reduce( toks, sim, tstack, vstack )
+ out = @racc_debug_out
+ out.print 'reduce '
+ if toks.empty?
+ out.print ' <none>'
+ else
+ toks.each {|t| out.print ' ', racc_token2str(t) }
+ end
+ out.puts " --> #{racc_token2str(sim)}"
+
+ racc_print_stacks tstack, vstack
+ @racc_debug_out.puts
+ end
+
+ def racc_accept
+ @racc_debug_out.puts 'accept'
+ @racc_debug_out.puts
+ end
+
+ def racc_e_pop( state, tstack, vstack )
+ @racc_debug_out.puts 'error recovering mode: pop token'
+ racc_print_states state
+ racc_print_stacks tstack, vstack
+ @racc_debug_out.puts
+ end
+
+ def racc_next_state( curstate, state )
+ @racc_debug_out.puts "goto #{curstate}"
+ racc_print_states state
+ @racc_debug_out.puts
+ end
+
+ def racc_print_stacks( t, v )
+ out = @racc_debug_out
+ out.print ' ['
+ t.each_index do |i|
+ out.print ' (', racc_token2str(t[i]), ' ', v[i].inspect, ')'
+ end
+ out.puts ' ]'
+ end
+
+ def racc_print_states( s )
+ out = @racc_debug_out
+ out.print ' ['
+ s.each {|st| out.print ' ', st }
+ out.puts ' ]'
+ end
+
+ def racc_token2str( tok )
+ self.class::Racc_token_to_s_table[tok] or
+ raise RuntimeError, "[Racc Bug] can't convert token #{tok} to string"
+ end
+
+ def token_to_str( t )
+ self.class::Racc_token_to_s_table[t]
+ end
+
+ end
+
+end
diff --git a/lib/rational.rb b/lib/rational.rb
index decf26b1ba..2019363ac6 100644
--- a/lib/rational.rb
+++ b/lib/rational.rb
@@ -8,7 +8,7 @@
# --
# Usage:
# class Rational < Numeric
-# (include Compareable)
+# (include Comparable)
#
# Rational(a, b) --> a/b
#
@@ -31,8 +31,9 @@
# Integer::to_r
#
# Fixnum::**
+# Fixnum::quo
# Bignum::**
-#
+# Bignum::quo
#
def Rational(a, b = 1)
@@ -47,7 +48,7 @@ class Rational < Numeric
@RCS_ID='-$Id: rational.rb,v 1.7 1999/08/24 12:49:28 keiju Exp keiju $-'
def Rational.reduce(num, den = 1)
- raise ZeroDivisionError, "denometor is 0" if den == 0
+ raise ZeroDivisionError, "denominator is zero" if den == 0
if den < 0
num = -num
@@ -66,7 +67,9 @@ class Rational < Numeric
def Rational.new!(num, den = 1)
new(num, den)
end
-
+
+ private_class_method :new
+
def initialize(num, den)
if den < 0
num = -num
@@ -91,7 +94,7 @@ class Rational < Numeric
elsif a.kind_of?(Float)
Float(self) + a
else
- x , y = a.coerce(self)
+ x, y = a.coerce(self)
x + y
end
end
@@ -106,7 +109,7 @@ class Rational < Numeric
elsif a.kind_of?(Float)
Float(self) - a
else
- x , y = a.coerce(self)
+ x, y = a.coerce(self)
x - y
end
end
@@ -121,7 +124,7 @@ class Rational < Numeric
elsif a.kind_of?(Float)
Float(self) * a
else
- x , y = a.coerce(self)
+ x, y = a.coerce(self)
x * y
end
end
@@ -132,12 +135,12 @@ class Rational < Numeric
den = @denominator * a.numerator
Rational(num, den)
elsif a.kind_of?(Integer)
- raise ZeroDivisionError, "devided by 0" if a == 0
+ raise ZeroDivisionError, "division by zero" if a == 0
self / Rational.new!(a, 1)
elsif a.kind_of?(Float)
Float(self) / a
else
- x , y = a.coerce(self)
+ x, y = a.coerce(self)
x / y
end
end
@@ -160,7 +163,7 @@ class Rational < Numeric
elsif other.kind_of?(Float)
Float(self) ** other
else
- x , y = other.coerce(self)
+ x, y = other.coerce(self)
x ** y
end
end
@@ -183,6 +186,18 @@ class Rational < Numeric
end
end
+ def == (other)
+ if other.kind_of?(Rational)
+ @numerator == other.numerator and @denominator == other.denominator
+ elsif other.kind_of?(Integer)
+ self == Rational.new!(other, 1)
+ elsif other.kind_of?(Float)
+ Float(self) == other
+ else
+ other == self
+ end
+ end
+
def <=> (other)
if other.kind_of?(Rational)
num = @numerator * other.denominator
@@ -199,9 +214,11 @@ class Rational < Numeric
return self <=> Rational.new!(other, 1)
elsif other.kind_of?(Float)
return Float(self) <=> other
- else
- x , y = other.coerce(self)
+ elsif defined? other.coerce
+ x, y = other.coerce(self)
return x <=> y
+ else
+ return nil
end
end
@@ -240,7 +257,7 @@ class Rational < Numeric
end
def hash
- @numerator ^ @denominator
+ @numerator.hash ^ @denominator.hash
end
attr :numerator
@@ -254,7 +271,7 @@ class Integer
self
end
- def denomerator
+ def denominator
1
end
@@ -312,41 +329,11 @@ class Integer
end
class Fixnum
- alias div! /;
- def div(other)
- if other.kind_of?(Fixnum)
- self.div!(other)
- elsif other.kind_of?(Bignum)
- x, y = other.coerce(self)
- x.div!(y)
- else
- x, y = other.coerce(self)
- x / y
- end
- end
-
-# alias divmod! divmod
-
- if not defined? Complex
- alias power! **;
- end
-
-# def rdiv(other)
-# if other.kind_of?(Fixnum)
-# Rational(self, other)
-# elsif
-# x, y = other.coerce(self)
-# if defined?(x.div())
-# x.div(y)
-# else
-# x / y
-# end
-# end
- # end
-
- def rdiv(other)
+ undef quo
+ def quo(other)
Rational.new!(self,1) / other
end
+ alias rdiv quo
def rpower (other)
if other >= 0
@@ -355,24 +342,23 @@ class Fixnum
Rational.new!(self,1)**other
end
end
-
- if not defined? Complex
+
+ unless defined? 1.power!
+ alias power! **
alias ** rpower
end
end
class Bignum
- alias div! /;
- alias div /;
- alias divmod! divmod
-
- if not defined? power!
+ unless defined? Complex
alias power! **
end
-
- def rdiv(other)
+
+ undef quo
+ def quo(other)
Rational.new!(self,1) / other
end
+ alias rdiv quo
def rpower (other)
if other >= 0
@@ -382,9 +368,7 @@ class Bignum
end
end
- if not defined? Complex
+ unless defined? Complex
alias ** rpower
end
-
end
-
diff --git a/lib/rdoc/README b/lib/rdoc/README
new file mode 100644
index 0000000000..5e90d792a2
--- /dev/null
+++ b/lib/rdoc/README
@@ -0,0 +1,475 @@
+= RDOC - Ruby Documentation System
+
+This package contains Rdoc and SimpleMarkup. Rdoc is an application
+that produces documentation for one or more Ruby source files. We work
+similarly to JavaDoc, parsing the source, and extracting the
+definition for classes, modules, and methods (along with includes and
+requires). We associate with these optional documentation contained
+in the immediately preceding comment block, and then render the result
+using a pluggable output formatter. (Currently, HTML is the only
+supported format. Markup is a library that converts plain text into
+various output formats. The Markup library is used to interpret the
+comment blocks that Rdoc uses to document methods, classes, and so on.
+
+This library contains two packages, rdoc itself and a text markup
+library, 'markup'.
+
+== Roadmap
+
+* If you want to use Rdoc to create documentation for your Ruby source
+ files, read on.
+* If you want to include extensions written in C, see rdoc/parsers/parse_c.rb.
+* For information on the various markups available in comment
+ blocks, see markup/simple_markup.rb.
+* If you want to drive Rdoc programatically, see RDoc::RDoc.
+* If you want to use the library to format text blocks into HTML,
+ have a look at SM::SimpleMarkup.
+* If you want to try writing your own HTML output template, see
+ RDoc::Page.
+
+== Summary
+
+Once installed, you can create documentation using the 'rdoc' command
+(the command is 'rdoc.bat' under Windows)
+
+ % rdoc [options] [names...]
+
+Type "rdoc --help" for an up-to-date option summary.
+
+A typical use might be to generate documentation for a package of Ruby
+source (such as rdoc itself).
+
+ % rdoc
+
+This command generates documentation for all the Ruby and C source
+files in and below the current directory. These will be stored in a
+documentation tree starting in the subdirectory 'doc'.
+
+You can make this slightly more useful for your readers by having the
+index page contain the documentation for the primary file. In our
+case, we could type
+
+ % rdoc --main rdoc/rdoc.rb
+
+You'll find information on the various formatting tricks you can use
+in comment blocks in the documentation this generates.
+
+RDoc uses file extensions to determine how to process each file. File
+names ending <tt>.rb</tt> and <tt>.rbw</tt> are assumed to be Ruby
+source. Files ending <tt>.c</tt> are parsed as C files. All other
+files are assumed to contain just SimpleMarkup-style markup (with or
+without leading '#' comment markers). If directory names are passed to
+RDoc, they are scanned recursively for C and Ruby source files only.
+
+== Credits
+
+* The Ruby parser in rdoc/parse.rb is based heavily on the outstanding
+ work of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby
+ parser for irb and the rtags package.
+
+* Code to diagram classes and modules was written by Sergey A Yanovitsky
+ (Jah) of Enticla.
+
+* Charset patch from MoonWolf.
+
+* Rich Kilmer wrote the kilmer.rb output template.
+
+* Dan Brickley led the design of the RDF format.
+
+== License
+
+RDoc is Copyright (c) 2001-2003 Dave Thomas, The Pragmatic Programmers. It
+is free software, and may be redistributed under the terms specified
+in the README file of the Ruby distribution.
+
+
+----
+
+= Usage
+
+RDoc is invoked from the command line using:
+
+ % rdoc <options> [name...]
+
+Files are parsed, and the information they contain collected, before
+any output is produced. This allows cross references between all files
+to be resolved. If a name is a directory, it is traversed. If no
+names are specified, all Ruby files in the current directory (and
+subdirectories) are processed.
+
+Options are:
+
+[<tt>--accessor</tt> <i>name[,name...]</i>]
+ specifies the name(s) of additional methods that should be treated
+ as if they were <tt>attr_</tt><i>xxx</i> methods. Specifying
+ "--accessor db_opt" means lines such as
+
+ db_opt :name, :age
+
+ will get parsed and displayed in the documentation. Each name may have an
+ optional "=flagtext" appended, in which case the given flagtext will appear
+ where (for example) the 'rw' appears for attr_accessor.
+
+[<tt>--all</tt>]
+ include protected and private methods in the output (by default
+ only public methods are included)
+
+[<tt>--charset</tt> _charset_]
+ Set the character set for the generated HTML.
+
+[<tt>--diagram</tt>]
+ include diagrams showing modules and classes. This is currently
+ an experimental feature, and may not be supported by all output
+ templates. You need dot V1.8.6 or later to use the --diagram
+ option correctly (http://www.research.att.com/sw/tools/graphviz/).
+
+[<tt>--exclude</tt> <i>pattern</i>]
+ exclude files and directories matching this pattern from processing
+
+[<tt>--extension</tt> <i>new=old</i>]
+ treat files ending <i>.new</i> as if they ended
+ <i>.old</i>. Saying '--extension cgi=rb' causes RDoc to treat .cgi
+ files as Ruby source.
+
+[<tt>fileboxes</tt>]
+ Classes are put in boxes which represents files, where these
+ classes reside. Classes shared between more than one file are
+ shown with list of files that sharing them. Silently discarded if
+ --diagram is not given Experimental.
+
+[<tt>--fmt</tt> _fmt_]
+ generate output in a particular format.
+
+[<tt>--help</tt>]
+ generate a usage summary.
+
+[<tt>--help-output</tt>]
+ explain the various output options.
+
+[<tt>--image-format</tt> <i>gif/png/jpg/jpeg</i>]
+ sets output image format for diagrams. Can be png, gif, jpeg,
+ jpg. If this option is omitted, png is used. Requires --diagram.
+
+[<tt>--include</tt> <i>dir,...</i>]
+ specify one or more directories to be searched when satisfying
+ :+include+: directives. Multiple <tt>--include</tt> options may be
+ given. The directory containing the file currently being processed
+ is always searched.
+
+[<tt>--inline-source</tt>]
+ By default, the source code of methods is shown in a popup. With
+ this option, it's displayed inline.
+
+[<tt>line-numbers</tt>]
+ include line numbers in the source code
+
+[<tt>--main</tt> _name_]
+ the class of module _name_ will appear on the index page. If you
+ want to set a particular file as a main page (a README, for
+ example) simply specifiy its name as the first on the command
+ line.
+
+[<tt>--merge</tt>]
+ when generating _ri_ output, if classes being processed already
+ exist in the destination directory, merge in the current details
+ rather than overwrite them.
+
+[<tt>--one-file</tt>]
+ place all the output into a single file
+
+[<tt>--op</tt> _dir_]
+ set the output directory to _dir_ (the default is the directory
+ "doc")
+
+[<tt>--op-name</tt> _name_]
+ set the name of the output. Has no effect for HTML.
+ "doc")
+
+[<tt>--opname</tt> _name_]
+ set the output name (has no effect for HTML).
+
+[<tt>--promiscuous</tt>]
+ If a module or class is defined in more than one source file, and
+ you click on a particular file's name in the top navigation pane,
+ RDoc will normally only show you the inner classes and modules of
+ that class that are defined in the particular file. Using this
+ option makes it show all classes and modules defined in the class,
+ regardless of the file they were defined in.
+
+[<tt>--quiet</tt>]
+ do not display progress messages
+
+[<tt>--ri</tt>, <tt>--ri-site</tt>, _and_ <tt>--ri-system</tt>]
+ generate output than can be read by the _ri_ command-line tool.
+ By default --ri places its output in ~/.rdoc, --ri-site in
+ $datadir/ri/<ver>/site, and --ri-system in
+ $datadir/ri/<ver>/system. All can be overridden with a subsequent
+ --op option. All default directories are in ri's default search
+ path.
+
+[<tt>--show-hash</tt>]
+ A name of the form #name in a comment is a possible hyperlink to
+ an instance method name. When displayed, the '#' is removed unless
+ this option is specified
+
+[<tt>--style</tt> <i>stylesheet url</i>]
+ specifies the URL of an external stylesheet to use (rather than
+ generating one of our own)
+
+[<tt>tab-width</tt> _n_]
+ set the width of tab characters (default 8)
+
+[<tt>--template</tt> <i>name</i>]
+ specify an alternate template to use when generating output (the
+ default is 'standard'). This template should be in a directory
+ accessible via $: as rdoc/generators/xxxx_template, where 'xxxx'
+ depends on the output formatter.
+
+[<tt>--version</tt>]
+ display RDoc's version
+
+[<tt>--webcvs</tt> _url_]
+ Specify a URL for linking to a web frontend to CVS. If the URL
+ contains a '\%s', the name of the current file will be
+ substituted; if the URL doesn't contain a '\%s', the filename will
+ be appended to it.
+
+= Example
+
+A typical small Ruby program commented using RDoc might be as follows. You
+can see the formatted result in EXAMPLE.rb and Anagram.
+
+ :include: EXAMPLE.rb
+
+= Markup
+
+Comment blocks can be written fairly naturally, either using '#' on
+successive lines of the comment, or by including the comment in
+an =begin/=end block. If you use the latter form, the =begin line
+must be flagged with an RDoc tag:
+
+ =begin rdoc
+ Documentation to
+ be processed by RDoc.
+ =end
+
+Paragraphs are lines that share the left margin. Text indented past
+this margin are formatted verbatim.
+
+1. Lists are typed as indented paragraphs with:
+ * a '*' or '-' (for bullet lists)
+ * a digit followed by a period for
+ numbered lists
+ * an upper or lower case letter followed
+ by a period for alpha lists.
+
+ For example, the input that produced the above paragraph looked like
+ 1. Lists are typed as indented
+ paragraphs with:
+ * a '*' or '-' (for bullet lists)
+ * a digit followed by a period for
+ numbered lists
+ * an upper or lower case letter followed
+ by a period for alpha lists.
+
+2. Labeled lists (sometimes called description
+ lists) are typed using square brackets for the label.
+ [cat] small domestic animal
+ [+cat+] command to copy standard input
+
+3. Labeled lists may also be produced by putting a double colon
+ after the label. This sets the result in tabular form, so the
+ descriptions all line up. This was used to create the 'author'
+ block at the bottom of this description.
+ cat:: small domestic animal
+ +cat+:: command to copy standard input
+
+ For both kinds of labeled lists, if the body text starts on the same
+ line as the label, then the start of that text determines the block
+ indent for the rest of the body. The text may also start on the line
+ following the label, indented from the start of the label. This is
+ often preferable if the label is long. Both the following are
+ valid labeled list entries:
+
+ <tt>--output</tt> <i>name [, name]</i>::
+ specify the name of one or more output files. If multiple
+ files are present, the first is used as the index.
+
+ <tt>--quiet:</tt>:: do not output the names, sizes, byte counts,
+ index areas, or bit ratios of units as
+ they are processed.
+
+4. Headings are entered using equals signs
+
+ = Level One Heading
+ == Level Two Heading
+ and so on
+
+5. Rules (horizontal lines) are entered using three or
+ more hyphens.
+
+6. Non-verbatim text can be marked up:
+
+ _italic_:: \_word_ or \<em>text</em>
+ *bold*:: \*word* or \<b>text</b>
+ +typewriter+:: \+word+ or \<tt>text</tt>
+
+ The first form only works around 'words', where a word is a
+ sequence of upper and lower case letters and underscores. Putting a
+ backslash before inline markup stops it being interpreted, which is
+ how I created the table above:
+
+ _italic_:: \_word_ or \<em>text</em>
+ *bold*:: \*word* or \<b>text</b>
+ +typewriter+:: \+word+ or \<tt>text</tt>
+
+7. Names of classes, source files, and any method names
+ containing an underscore or preceded by a hash
+ character are automatically hyperlinked from
+ comment text to their description.
+
+8. Hyperlinks to the web starting http:, mailto:, ftp:, or www. are
+ recognized. An HTTP url that references an external image file is
+ converted into an inline <IMG..>. Hyperlinks starting 'link:' are
+ assumed to refer to local files whose path is relative to the --op
+ directory.
+
+ Hyperlinks can also be of the form <tt>label</tt>[url], in which
+ case the label is used in the displayed text, and <tt>url</tt> is
+ used as the target. If <tt>label</tt> contains multiple words,
+ put it in braces: <em>{multi word label}[</em>url<em>]</em>.
+
+9. Method parameter lists are extracted and displayed with
+ the method description. If a method calls +yield+, then
+ the parameters passed to yield will also be displayed:
+
+ def fred
+ ...
+ yield line, address
+
+ This will get documented as
+
+ fred() { |line, address| ... }
+
+ You can override this using a comment containing
+ ':yields: ...' immediately after the method definition
+
+ def fred # :yields: index, position
+ ...
+ yield line, address
+
+ which will get documented as
+
+ fred() { |index, position| ... }
+
+
+10. ':yields:' is an example of a documentation modifier. These appear
+ immediately after the start of the document element they are modifying.
+ Other modifiers include
+
+ [<tt>:nodoc:</tt><i>[all]</i>]
+ don't include this element in the documentation. For classes
+ and modules, the methods, aliases, constants, and attributes
+ directly within the affected class or module will also be
+ omitted. By default, though, modules and classes within that
+ class of module _will_ be documented. This is turned off by
+ adding the +all+ modifier.
+
+ module SM #:nodoc:
+ class Input
+ end
+ end
+ module Markup #:nodoc: all
+ class Output
+ end
+ end
+
+ In the above code, only class <tt>SM::Input</tt> will be
+ documented.
+
+ [<tt>:doc:</tt>]
+ force a method or attribute to be documented even if it
+ wouldn't otherwise be. Useful if, for example, you want to
+ include documentation of a particular private method.
+
+ [<tt>:notnew:</tt>]
+ only applicable to the +initialize+ instance method. Normally
+ RDoc assumes that the documentation and parameters for
+ #initialize are actually for the ::new method, and so fakes
+ out a ::new for the class. THe :notnew: modifier stops
+ this. Remember that #initialize is protected, so you won't
+ see the documentation unless you use the -a command line
+ option.
+
+
+11. RDoc stops processing comments if it finds a comment
+ line containing '<tt>#--</tt>'. This can be used to
+ separate external from internal comments, or
+ to stop a comment being associated with a method,
+ class, or module. Commenting can be turned back on with
+ a line that starts '<tt>#++</tt>'.
+
+ # Extract the age and calculate the
+ # date-of-birth.
+ #--
+ # FIXME: fails if the birthday falls on
+ # February 29th
+ #++
+ # The DOB is returned as a Time object.
+
+ def get_dob(person)
+ ...
+
+12. Comment blocks can contain other directives:
+
+ [<tt>call-seq:</tt>]
+ lines up to the next blank line in the comment are treated as
+ the method's calling sequence, overriding the
+ default parsing of method parameters and yield arguments.
+
+ [<tt>:include:</tt><i>filename</i>]
+ include the contents of the named file at this point. The
+ file will be searched for in the directories listed by
+ the <tt>--include</tt> option, or in the current
+ directory by default. The contents of the file will be
+ shifted to have the same indentation as the ':' at the
+ start of the :include: directive.
+
+ [<tt>:title:</tt><i>text</i>]
+ Sets the title for the document. Equivalent to the --title command
+ line parameter. (The command line parameter overrides any :title:
+ directive in the source).
+
+ [<tt>:enddoc:</tt>]
+ Document nothing further at the current level.
+
+ [<tt>:main:</tt><i>name</i>]
+ Equivalent to the --main command line parameter.
+
+ [<tt>:stopdoc: / :startdoc:</tt>]
+ Stop and start adding new documentation elements to the
+ current container. For example, if a class has a number of
+ constants that you don't want to document, put a
+ <tt>:stopdoc:</tt> before the first, and a
+ <tt>:startdoc:</tt> after the last. If you don't specifiy a
+ <tt>:startdoc:</tt> by the end of the container, disables
+ documentation for the entire class or module.
+
+
+---
+
+See also markup/simple_markup.rb.
+
+= Other stuff
+
+Author:: Dave Thomas <dave@pragmaticprogrammer.com>
+Requires:: Ruby 1.8.1 or later
+License:: Copyright (c) 2001-2003 Dave Thomas.
+ Released under the same license as Ruby.
+
+== Warranty
+
+This software is provided "as is" and without any express or
+implied warranties, including, without limitation, the implied
+warranties of merchantibility and fitness for a particular
+purpose.
diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb
new file mode 100644
index 0000000000..bd713ab92b
--- /dev/null
+++ b/lib/rdoc/code_objects.rb
@@ -0,0 +1,706 @@
+# We represent the various high-level code constructs that appear
+# in Ruby programs: classes, modules, methods, and so on.
+
+require 'rdoc/tokenstream'
+
+module RDoc
+
+
+ # We contain the common stuff for contexts (which are containers)
+ # and other elements (methods, attributes and so on)
+ #
+ class CodeObject
+
+ attr_accessor :parent
+
+ # We are the model of the code, but we know that at some point
+ # we will be worked on by viewers. By implementing the Viewable
+ # protocol, viewers can associated themselves with these objects.
+
+ attr_accessor :viewer
+
+ # are we done documenting (ie, did we come across a :enddoc:)?
+
+ attr_accessor :done_documenting
+
+
+ # do we document ourselves?
+
+ attr_reader :document_self
+
+ def document_self=(val)
+ @document_self = val
+ if !val
+ remove_methods_etc
+ end
+ end
+
+ # set and cleared by :startdoc: and :enddoc:, this is used to toggle
+ # the capturing of documentation
+ def start_doc
+ @document_self = true
+ @document_children = true
+ end
+
+ def stop_doc
+ @document_self = false
+ @document_children = false
+ end
+
+ # do we document ourselves and our children
+
+ attr_reader :document_children
+
+ def document_children=(val)
+ @document_children = val
+ if !val
+ remove_classes_and_modules
+ end
+ end
+
+ # Do we _force_ documentation, even is we wouldn't normally show the entity
+ attr_accessor :force_documentation
+
+ # Default callbacks to nothing, but this is overridden for classes
+ # and modules
+ def remove_classes_and_modules
+ end
+
+ def remove_methods_etc
+ end
+
+ def initialize
+ @document_self = true
+ @document_children = true
+ @force_documentation = false
+ @done_documenting = false
+ end
+
+ # Access the code object's comment
+ attr_reader :comment
+
+ # Update the comment, but don't overwrite a real comment
+ # with an empty one
+ def comment=(comment)
+ @comment = comment unless comment.empty?
+ end
+
+ # There's a wee trick we pull. Comment blocks can have directives that
+ # override the stuff we extract during the parse. So, we have a special
+ # class method, attr_overridable, that lets code objects list
+ # those directives. Wehn a comment is assigned, we then extract
+ # out any matching directives and update our object
+
+ def CodeObject.attr_overridable(name, *aliases)
+ @overridables ||= {}
+
+ attr_accessor name
+
+ aliases.unshift name
+ aliases.each do |directive_name|
+ @overridables[directive_name.to_s] = name
+ end
+ end
+
+ end
+
+ # A Context is something that can hold modules, classes, methods,
+ # attributes, aliases, requires, and includes. Classes, modules, and
+ # files are all Contexts.
+
+ class Context < CodeObject
+ attr_reader :name, :method_list, :attributes, :aliases, :constants
+ attr_reader :requires, :includes, :in_files, :visibility
+
+
+ def initialize
+ super()
+
+ @in_files = []
+
+ @name ||= "unknown"
+ @comment ||= ""
+ @parent = nil
+ @visibility = :public
+
+ initialize_methods_etc
+ initialize_classes_and_modules
+ end
+
+ # map the class hash to an array externally
+ def classes
+ @classes.values
+ end
+
+ # map the module hash to an array externally
+ def modules
+ @modules.values
+ end
+
+ # Change the default visibility for new methods
+ def ongoing_visibility=(vis)
+ @visibility = vis
+ end
+
+ # Given an array +methods+ of method names, set the
+ # visibility of the corresponding AnyMethod object
+
+ def set_visibility_for(methods, vis, singleton=false)
+ count = 0
+ @method_list.each do |m|
+ if methods.include?(m.name) && m.singleton == singleton
+ m.visibility = vis
+ count += 1
+ end
+ end
+
+ return if count == methods.size || singleton
+
+ # perhaps we need to look at attributes
+
+ @attributes.each do |a|
+ if methods.include?(a.name)
+ a.visibility = vis
+ count += 1
+ end
+ end
+ end
+
+ # Record the file that we happen to find it in
+ def record_location(toplevel)
+ @in_files << toplevel unless @in_files.include?(toplevel)
+ end
+
+ # Return true if at least part of this thing was defined in +file+
+ def defined_in?(file)
+ @in_files.include?(file)
+ end
+
+ def add_class(class_type, name, superclass)
+ add_class_or_module(@classes, class_type, name, superclass)
+ end
+
+ def add_module(class_type, name)
+ add_class_or_module(@modules, class_type, name, nil)
+ end
+
+ def add_method(a_method)
+ puts "Adding #@visibility method #{a_method.name} to #@name" if $DEBUG
+ a_method.visibility = @visibility
+ add_to(@method_list, a_method)
+ end
+
+ def add_attribute(an_attribute)
+ add_to(@attributes, an_attribute)
+ end
+
+ def add_alias(an_alias)
+ meth = find_instance_method_named(an_alias.old_name)
+ if meth
+ new_meth = AnyMethod.new(an_alias.text, an_alias.new_name)
+ new_meth.is_alias_for = meth
+ new_meth.singleton = meth.singleton
+ new_meth.params = meth.params
+ new_meth.comment = "Alias for \##{meth.name}"
+ meth.add_alias(new_meth)
+ add_method(new_meth)
+ else
+ add_to(@aliases, an_alias)
+ end
+ end
+
+ def add_include(an_include)
+ add_to(@includes, an_include)
+ end
+
+ def add_constant(const)
+ add_to(@constants, const)
+ end
+
+ # Requires always get added to the top-level (file) context
+ def add_require(a_require)
+ if self.kind_of? TopLevel
+ add_to(@requires, a_require)
+ else
+ parent.add_require(a_require)
+ end
+ end
+
+ def add_class_or_module(collection, class_type, name, superclass=nil)
+ cls = collection[name]
+ if cls
+ puts "Reusing class/module #{name}" if $DEBUG
+ else
+ cls = class_type.new(name, superclass)
+ puts "Adding class/module #{name} to #@name" if $DEBUG
+# collection[name] = cls if @document_self && !@done_documenting
+ collection[name] = cls if !@done_documenting
+ cls.parent = self
+ end
+ cls
+ end
+
+ def add_to(array, thing)
+ array << thing if @document_self && !@done_documenting
+ thing.parent = self
+ end
+
+ # If a class's documentation is turned off after we've started
+ # collecting methods etc., we need to remove the ones
+ # we have
+
+ def remove_methods_etc
+ initialize_methods_etc
+ end
+
+ def initialize_methods_etc
+ @method_list = []
+ @attributes = []
+ @aliases = []
+ @requires = []
+ @includes = []
+ @constants = []
+ end
+
+ # and remove classes and modules when we see a :nodoc: all
+ def remove_classes_and_modules
+ initialize_classes_and_modules
+ end
+
+ def initialize_classes_and_modules
+ @classes = {}
+ @modules = {}
+ end
+
+ # Find a named module
+ def find_module_named(name)
+ return self if self.name == name
+ res = @modules[name] || @classes[name]
+ return res if res
+ find_enclosing_module_named(name)
+ end
+
+ # find a module at a higher scope
+ def find_enclosing_module_named(name)
+ parent && parent.find_module_named(name)
+ end
+
+ # Iterate over all the classes and modules in
+ # this object
+
+ def each_classmodule
+ @modules.each_value {|m| yield m}
+ @classes.each_value {|c| yield c}
+ end
+
+ def each_method
+ @method_list.each {|m| yield m}
+ end
+
+ def each_attribute
+ @attributes.each {|a| yield a}
+ end
+
+ def each_constant
+ @constants.each {|c| yield c}
+ end
+
+ # Return the toplevel that owns us
+
+ def toplevel
+ return @toplevel if defined? @toplevel
+ @toplevel = self
+ @toplevel = @toplevel.parent until TopLevel === @toplevel
+ @toplevel
+ end
+
+ # allow us to sort modules by name
+ def <=>(other)
+ name <=> other.name
+ end
+
+ # Look up the given symbol. If method is non-nil, then
+ # we assume the symbol references a module that
+ # contains that method
+ def find_symbol(symbol, method=nil)
+ result = nil
+ case symbol
+ when /^::(.*)/
+ result = toplevel.find_symbol($1)
+ when /::/
+ modules = symbol.split(/::/)
+ unless modules.empty?
+ module_name = modules.shift
+ result = find_module_named(module_name)
+ if result
+ modules.each do |module_name|
+ result = result.find_module_named(module_name)
+ break unless result
+ end
+ end
+ end
+ else
+ # if a method is specified, then we're definitely looking for
+ # a module, otherwise it could be any symbol
+ if method
+ result = find_module_named(symbol)
+ else
+ result = find_local_symbol(symbol)
+ if result.nil?
+ if symbol =~ /^[A-Z]/
+ result = parent
+ while result && result.name != symbol
+ result = result.parent
+ end
+ end
+ end
+ end
+ end
+ if result && method
+ if !result.respond_to?(:find_local_symbol)
+ p result.name
+ p method
+ fail
+ end
+ result = result.find_local_symbol(method)
+ end
+ result
+ end
+
+ def find_local_symbol(symbol)
+ res = find_method_named(symbol) ||
+ find_constant_named(symbol) ||
+ find_attribute_named(symbol) ||
+ find_module_named(symbol)
+ end
+
+ private
+
+ # Find a named method, or return nil
+ def find_method_named(name)
+ @method_list.find {|meth| meth.name == name}
+ end
+
+ # Find a named instance method, or return nil
+ def find_instance_method_named(name)
+ @method_list.find {|meth| meth.name == name && !meth.singleton}
+ end
+
+ # Find a named constant, or return nil
+ def find_constant_named(name)
+ @constants.find {|m| m.name == name}
+ end
+
+ # Find a named attribute, or return nil
+ def find_attribute_named(name)
+ @attributes.find {|m| m.name == name}
+ end
+
+ end
+
+
+ # A TopLevel context is a source file
+
+ class TopLevel < Context
+ attr_accessor :file_stat
+ attr_accessor :file_relative_name
+ attr_accessor :file_absolute_name
+ attr_accessor :diagram
+
+ @@all_classes = {}
+ @@all_modules = {}
+
+ def TopLevel::reset
+ @@all_classes = {}
+ @@all_modules = {}
+ end
+
+ def initialize(file_name)
+ super()
+ @name = "TopLevel"
+ @file_relative_name = file_name
+ @file_absolute_name = file_name
+ @file_stat = File.stat(file_name)
+ @diagram = nil
+ end
+
+ def full_name
+ nil
+ end
+
+ # Adding a class or module to a TopLevel is special, as we only
+ # want one copy of a particular top-level class. For example,
+ # if both file A and file B implement class C, we only want one
+ # ClassModule object for C. This code arranges to share
+ # classes and modules between files.
+
+ def add_class_or_module(collection, class_type, name, superclass)
+ cls = collection[name]
+ if cls
+ puts "Reusing class/module #{name}" if $DEBUG
+ else
+ if class_type == NormalModule
+ all = @@all_modules
+ else
+ all = @@all_classes
+ end
+ cls = all[name]
+ if !cls
+ cls = class_type.new(name, superclass)
+ all[name] = cls unless @done_documenting
+ end
+ puts "Adding class/module #{name} to #@name" if $DEBUG
+ collection[name] = cls unless @done_documenting
+ cls.parent = self
+ end
+ cls
+ end
+
+ def TopLevel.all_classes_and_modules
+ @@all_classes.values + @@all_modules.values
+ end
+
+ def TopLevel.find_class_named(name)
+ @@all_classes.each_value do |c|
+ res = c.find_class_named(name)
+ return res if res
+ end
+ nil
+ end
+
+ def find_local_symbol(symbol)
+ find_class_or_module_named(symbol) || super
+ end
+
+ def find_class_or_module_named(symbol)
+ @@all_classes.each_value {|c| return c if c.name == symbol}
+ @@all_modules.each_value {|m| return m if m.name == symbol}
+ nil
+ end
+
+ # Find a named module
+ def find_module_named(name)
+ find_class_or_module_named(name) || find_enclosing_module_named(name)
+ end
+
+
+ end
+
+ # ClassModule is the base class for objects representing either a
+ # class or a module.
+
+ class ClassModule < Context
+
+ attr_reader :superclass
+ attr_accessor :diagram
+
+ def initialize(name, superclass = nil)
+ @name = name
+ @diagram = nil
+ @superclass = superclass
+ @comment = ""
+ super()
+ end
+
+ # Return the fully qualified name of this class or module
+ def full_name
+ if @parent && @parent.full_name
+ @parent.full_name + "::" + @name
+ else
+ @name
+ end
+ end
+
+ def http_url(prefix)
+ path = full_name.split("::")
+ File.join(prefix, *path) + ".html"
+ end
+
+ # Return +true+ if this object represents a module
+ def is_module?
+ false
+ end
+
+ # to_s is simply for debugging
+ def to_s
+ res = self.class.name + ": " + @name
+ res << @comment.to_s
+ res << super
+ res
+ end
+
+ def find_class_named(name)
+ return self if full_name == name
+ @classes.each_value {|c| return c if c.find_class_named(name) }
+ nil
+ end
+ end
+
+ # Anonymous classes
+ class AnonClass < ClassModule
+ end
+
+ # Normal classes
+ class NormalClass < ClassModule
+ end
+
+ # Singleton classes
+ class SingleClass < ClassModule
+ end
+
+ # Module
+ class NormalModule < ClassModule
+ def is_module?
+ true
+ end
+ end
+
+
+ # AnyMethod is the base class for objects representing methods
+
+ class AnyMethod < CodeObject
+ attr_accessor :name
+ attr_accessor :visibility
+ attr_accessor :block_params
+ attr_accessor :dont_rename_initialize
+ attr_accessor :singleton
+ attr_reader :aliases # list of other names for this method
+ attr_accessor :is_alias_for # or a method we're aliasing
+
+ attr_overridable :params, :param, :parameters, :parameter
+
+ attr_accessor :call_seq
+
+
+ include TokenStream
+
+ def initialize(text, name)
+ super()
+ @text = text
+ @name = name
+ @token_stream = nil
+ @visibility = :public
+ @dont_rename_initialize = false
+ @block_params = nil
+ @aliases = []
+ @is_alias_for = nil
+ @comment = ""
+ @call_seq = nil
+ end
+
+ def <=>(other)
+ @name <=> other.name
+ end
+
+ def to_s
+ res = self.class.name + ": " + @name + " (" + @text + ")\n"
+ res << @comment.to_s
+ res
+ end
+
+ def param_seq
+ p = params.gsub(/\s*\#.*/, '')
+ p = p.tr("\n", " ").squeeze(" ")
+ p = "(" + p + ")" unless p[0] == ?(
+
+ if (block = block_params)
+ # If this method has explicit block parameters, remove any
+ # explicit &block
+$stderr.puts p
+ p.sub!(/,?\s*&\w+/)
+$stderr.puts p
+
+ block.gsub!(/\s*\#.*/, '')
+ block = block.tr("\n", " ").squeeze(" ")
+ if block[0] == ?(
+ block.sub!(/^\(/, '').sub!(/\)/, '')
+ end
+ p << " {|#{block}| ...}"
+ end
+ p
+ end
+
+ def add_alias(method)
+ @aliases << method
+ end
+ end
+
+
+ # Represent an alias, which is an old_name/ new_name pair associated
+ # with a particular context
+ class Alias < CodeObject
+ attr_accessor :text, :old_name, :new_name, :comment
+
+ def initialize(text, old_name, new_name, comment)
+ super()
+ @text = text
+ @old_name = old_name
+ @new_name = new_name
+ self.comment = comment
+ end
+
+ def to_s
+ "alias: #{self.old_name} -> #{self.new_name}\n#{self.comment}"
+ end
+ end
+
+ # Represent a constant
+ class Constant < CodeObject
+ attr_accessor :name, :value
+
+ def initialize(name, value, comment)
+ super()
+ @name = name
+ @value = value
+ self.comment = comment
+ end
+ end
+
+ # Represent attributes
+ class Attr < CodeObject
+ attr_accessor :text, :name, :rw, :visibility
+
+ def initialize(text, name, rw, comment)
+ super()
+ @text = text
+ @name = name
+ @rw = rw
+ @visibility = :public
+ self.comment = comment
+ end
+
+ def to_s
+ "attr: #{self.name} #{self.rw}\n#{self.comment}"
+ end
+
+ def <=>(other)
+ self.name <=> other.name
+ end
+ end
+
+ # a required file
+
+ class Require < CodeObject
+ attr_accessor :name
+
+ def initialize(name, comment)
+ super()
+ @name = name.gsub(/'|"/, "") #'
+ self.comment = comment
+ end
+
+ end
+
+ # an included module
+ class Include < CodeObject
+ attr_accessor :name
+
+ def initialize(name, comment)
+ super()
+ @name = name
+ self.comment = comment
+ end
+
+ end
+
+end
diff --git a/lib/rdoc/diagram.rb b/lib/rdoc/diagram.rb
new file mode 100644
index 0000000000..62e2f2e164
--- /dev/null
+++ b/lib/rdoc/diagram.rb
@@ -0,0 +1,333 @@
+# A wonderful hack by to draw package diagrams using the dot package.
+# Originally written by Jah, team Enticla.
+#
+# You must have the V1.7 or later in your path
+# http://www.research.att.com/sw/tools/graphviz/
+
+require "rdoc/dot/dot"
+require 'rdoc/options'
+
+module RDoc
+
+ # Draw a set of diagrams representing the modules and classes in the
+ # system. We draw one diagram for each file, and one for each toplevel
+ # class or module. This means there will be overlap. However, it also
+ # means that you'll get better context for objects.
+ #
+ # To use, simply
+ #
+ # d = Diagram.new(info) # pass in collection of top level infos
+ # d.draw
+ #
+ # The results will be written to the +dot+ subdirectory. The process
+ # also sets the +diagram+ attribute in each object it graphs to
+ # the name of the file containing the image. This can be used
+ # by output generators to insert images.
+
+ class Diagram
+
+ FONT = "Arial"
+
+ DOT_PATH = "dot"
+
+ # Pass in the set of top level objects. The method also creates
+ # the subdirectory to hold the images
+
+ def initialize(info, options)
+ @info = info
+ @options = options
+ @counter = 0
+ File.makedirs(DOT_PATH)
+ end
+
+ # Draw the diagrams. We traverse the files, drawing a diagram for
+ # each. We also traverse each top-level class and module in that
+ # file drawing a diagram for these too.
+
+ def draw
+ unless @options.quiet
+ $stderr.print "Diagrams: "
+ $stderr.flush
+ end
+
+ @info.each_with_index do |i, file_count|
+ @done_modules = {}
+ @local_names = find_names(i)
+ @global_names = []
+ @global_graph = graph = DOT::DOTDigraph.new('name' => 'TopLevel',
+ 'label' => i.file_absolute_name,
+ 'fontname' => FONT,
+ 'fontsize' => '8',
+ 'bgcolor' => 'lightcyan1',
+ 'compound' => 'true')
+
+ # it's a little hack %) i'm too lazy to create a separate class
+ # for default node
+ graph << DOT::DOTNode.new('name' => 'node',
+ 'fontname' => FONT,
+ 'color' => 'black',
+ 'fontsize' => 8)
+
+ i.modules.each do |mod|
+ draw_module(mod, graph, true, i.file_relative_name)
+ end
+ add_classes(i, graph, i.file_relative_name)
+
+ i.diagram = convert_to_png("f_#{file_count}", graph, i.name)
+
+ # now go through and document each top level class and
+ # module independently
+ i.modules.each_with_index do |mod, count|
+ @done_modules = {}
+ @local_names = find_names(mod)
+ @global_names = []
+
+ @global_graph = graph = DOT::DOTDigraph.new('name' => 'TopLevel',
+ 'label' => i.full_name,
+ 'fontname' => FONT,
+ 'fontsize' => '8',
+ 'bgcolor' => 'lightcyan1',
+ 'compound' => 'true')
+
+ graph << DOT::DOTNode.new('name' => 'node',
+ 'fontname' => FONT,
+ 'color' => 'black',
+ 'fontsize' => 8)
+ draw_module(mod, graph, true)
+ mod.diagram = convert_to_png("m_#{file_count}_#{count}",
+ graph,
+ "Module: #{mod.name}")
+ end
+ end
+ $stderr.puts unless @options.quiet
+ end
+
+ #######
+ private
+ #######
+
+ def find_names(mod)
+ return [mod.full_name] + mod.classes.collect{|cl| cl.full_name} +
+ mod.modules.collect{|m| find_names(m)}.flatten
+ end
+
+ def find_full_name(name, mod)
+ full_name = name.dup
+ return full_name if @local_names.include?(full_name)
+ mod_path = mod.full_name.split('::')[0..-2]
+ unless mod_path.nil?
+ until mod_path.empty?
+ full_name = mod_path.pop + '::' + full_name
+ return full_name if @local_names.include?(full_name)
+ end
+ end
+ return name
+ end
+
+ def draw_module(mod, graph, toplevel = false, file = nil)
+ return if @done_modules[mod.full_name] and not toplevel
+
+ @counter += 1
+ url = mod.http_url("classes")
+ m = DOT::DOTSubgraph.new('name' => "cluster_#{mod.full_name.gsub( /:/,'_' )}",
+ 'label' => mod.name,
+ 'fontname' => FONT,
+ 'color' => 'blue',
+ 'style' => 'filled',
+ 'URL' => %{"#{url}"},
+ 'fillcolor' => toplevel ? 'palegreen1' : 'palegreen3')
+
+ @done_modules[mod.full_name] = m
+ add_classes(mod, m, file)
+ graph << m
+
+ unless mod.includes.empty?
+ mod.includes.each do |m|
+ m_full_name = find_full_name(m.name, mod)
+ if @local_names.include?(m_full_name)
+ @global_graph << DOT::DOTEdge.new('from' => "#{m_full_name.gsub( /:/,'_' )}",
+ 'to' => "#{mod.full_name.gsub( /:/,'_' )}",
+ 'ltail' => "cluster_#{m_full_name.gsub( /:/,'_' )}",
+ 'lhead' => "cluster_#{mod.full_name.gsub( /:/,'_' )}")
+ else
+ unless @global_names.include?(m_full_name)
+ path = m_full_name.split("::")
+ url = File.join('classes', *path) + ".html"
+ @global_graph << DOT::DOTNode.new('name' => "#{m_full_name.gsub( /:/,'_' )}",
+ 'shape' => 'box',
+ 'label' => "#{m_full_name}",
+ 'URL' => %{"#{url}"})
+ @global_names << m_full_name
+ end
+ @global_graph << DOT::DOTEdge.new('from' => "#{m_full_name.gsub( /:/,'_' )}",
+ 'to' => "#{mod.full_name.gsub( /:/,'_' )}",
+ 'lhead' => "cluster_#{mod.full_name.gsub( /:/,'_' )}")
+ end
+ end
+ end
+ end
+
+ def add_classes(container, graph, file = nil )
+
+ use_fileboxes = Options.instance.fileboxes
+
+ files = {}
+
+ # create dummy node (needed if empty and for module includes)
+ if container.full_name
+ graph << DOT::DOTNode.new('name' => "#{container.full_name.gsub( /:/,'_' )}",
+ 'label' => "",
+ 'width' => (container.classes.empty? and
+ container.modules.empty?) ?
+ '0.75' : '0.01',
+ 'height' => '0.01',
+ 'shape' => 'plaintext')
+ end
+ container.classes.each_with_index do |cl, cl_index|
+ last_file = cl.in_files[-1].file_relative_name
+
+ if use_fileboxes && !files.include?(last_file)
+ @counter += 1
+ files[last_file] =
+ DOT::DOTSubgraph.new('name' => "cluster_#{@counter}",
+ 'label' => "#{last_file}",
+ 'fontname' => FONT,
+ 'color'=>
+ last_file == file ? 'red' : 'black')
+ end
+
+ next if cl.name == 'Object' || cl.name[0,2] == "<<"
+
+ url = cl.http_url("classes")
+
+ label = cl.name.dup
+ if use_fileboxes && cl.in_files.length > 1
+ label << '\n[' +
+ cl.in_files.collect {|i|
+ i.file_relative_name
+ }.sort.join( '\n' ) +
+ ']'
+ end
+
+ attrs = {
+ 'name' => "#{cl.full_name.gsub( /:/, '_' )}",
+ 'fontcolor' => 'black',
+ 'style'=>'filled',
+ 'color'=>'palegoldenrod',
+ 'label' => label,
+ 'shape' => 'ellipse',
+ 'URL' => %{"#{url}"}
+ }
+
+ c = DOT::DOTNode.new(attrs)
+
+ if use_fileboxes
+ files[last_file].push c
+ else
+ graph << c
+ end
+ end
+
+ if use_fileboxes
+ files.each_value do |val|
+ graph << val
+ end
+ end
+
+ unless container.classes.empty?
+ container.classes.each_with_index do |cl, cl_index|
+ cl.includes.each do |m|
+ m_full_name = find_full_name(m.name, cl)
+ if @local_names.include?(m_full_name)
+ @global_graph << DOT::DOTEdge.new('from' => "#{m_full_name.gsub( /:/,'_' )}",
+ 'to' => "#{cl.full_name.gsub( /:/,'_' )}",
+ 'ltail' => "cluster_#{m_full_name.gsub( /:/,'_' )}")
+ else
+ unless @global_names.include?(m_full_name)
+ path = m_full_name.split("::")
+ url = File.join('classes', *path) + ".html"
+ @global_graph << DOT::DOTNode.new('name' => "#{m_full_name.gsub( /:/,'_' )}",
+ 'shape' => 'box',
+ 'label' => "#{m_full_name}",
+ 'URL' => %{"#{url}"})
+ @global_names << m_full_name
+ end
+ @global_graph << DOT::DOTEdge.new('from' => "#{m_full_name.gsub( /:/,'_' )}",
+ 'to' => "#{cl.full_name.gsub( /:/, '_')}")
+ end
+ end
+
+ sclass = cl.superclass
+ next if sclass.nil? || sclass == 'Object'
+ sclass_full_name = find_full_name(sclass,cl)
+ unless @local_names.include?(sclass_full_name) or @global_names.include?(sclass_full_name)
+ path = sclass_full_name.split("::")
+ url = File.join('classes', *path) + ".html"
+ @global_graph << DOT::DOTNode.new(
+ 'name' => "#{sclass_full_name.gsub( /:/, '_' )}",
+ 'label' => sclass_full_name,
+ 'URL' => %{"#{url}"})
+ @global_names << sclass_full_name
+ end
+ @global_graph << DOT::DOTEdge.new('from' => "#{sclass_full_name.gsub( /:/,'_' )}",
+ 'to' => "#{cl.full_name.gsub( /:/, '_')}")
+ end
+ end
+
+ container.modules.each do |submod|
+ draw_module(submod, graph)
+ end
+
+ end
+
+ def convert_to_png(file_base, graph, name)
+ op_type = Options.instance.image_format
+ dotfile = File.join(DOT_PATH, file_base)
+ src = dotfile + ".dot"
+ dot = dotfile + "." + op_type
+
+ unless @options.quiet
+ $stderr.print "."
+ $stderr.flush
+ end
+
+ File.open(src, 'w+' ) do |f|
+ f << graph.to_s << "\n"
+ end
+
+ system "dot -T#{op_type} #{src} -o #{dot}"
+
+ # Now construct the imagemap wrapper around
+ # that png
+
+ return wrap_in_image_map(src, dot, name)
+ end
+
+ # Extract the client-side image map from dot, and use it
+ # to generate the imagemap proper. Return the whole
+ # <map>..<img> combination, suitable for inclusion on
+ # the page
+
+ def wrap_in_image_map(src, dot, name)
+ res = %{<map id="map" name="map">\n}
+ dot_map = `dot -Tismap #{src}`
+ dot_map.each do |area|
+ unless area =~ /^rectangle \((\d+),(\d+)\) \((\d+),(\d+)\) ([\/\w.]+)\s*(.*)/
+ $stderr.puts "Unexpected output from dot:\n#{area}"
+ return nil
+ end
+
+ xs, ys = [$1.to_i, $3.to_i], [$2.to_i, $4.to_i]
+ url, area_name = $5, $6
+
+ res << %{ <area shape="RECT" coords="#{xs.min},#{ys.min},#{xs.max},#{ys.max}" }
+ res << %{ href="#{url}" alt="#{area_name}">\n}
+ end
+ res << "</map>\n"
+# map_file = src.sub(/.dot/, '.map')
+# system("dot -Timap #{src} -o #{map_file}")
+ res << %{<img src="#{dot}" usemap="#map" border=0 alt="#{name}">}
+ return res
+ end
+ end
+end
diff --git a/lib/rdoc/dot/dot.rb b/lib/rdoc/dot/dot.rb
new file mode 100644
index 0000000000..6dbb7cb237
--- /dev/null
+++ b/lib/rdoc/dot/dot.rb
@@ -0,0 +1,255 @@
+module DOT
+
+ # these glogal vars are used to make nice graph source
+ $tab = ' '
+ $tab2 = $tab * 2
+
+ # if we don't like 4 spaces, we can change it any time
+ def change_tab( t )
+ $tab = t
+ $tab2 = t * 2
+ end
+
+ # options for node declaration
+ NODE_OPTS = [
+ 'bgcolor',
+ 'color',
+ 'fontcolor',
+ 'fontname',
+ 'fontsize',
+ 'height',
+ 'width',
+ 'label',
+ 'layer',
+ 'rank',
+ 'shape',
+ 'shapefile',
+ 'style',
+ 'URL',
+ ]
+
+ # options for edge declaration
+ EDGE_OPTS = [
+ 'color',
+ 'decorate',
+ 'dir',
+ 'fontcolor',
+ 'fontname',
+ 'fontsize',
+ 'id',
+ 'label',
+ 'layer',
+ 'lhead',
+ 'ltail',
+ 'minlen',
+ 'style',
+ 'weight'
+ ]
+
+ # options for graph declaration
+ GRAPH_OPTS = [
+ 'bgcolor',
+ 'center',
+ 'clusterrank',
+ 'color',
+ 'compound',
+ 'concentrate',
+ 'fillcolor',
+ 'fontcolor',
+ 'fontname',
+ 'fontsize',
+ 'label',
+ 'layerseq',
+ 'margin',
+ 'mclimit',
+ 'nodesep',
+ 'nslimit',
+ 'ordering',
+ 'orientation',
+ 'page',
+ 'rank',
+ 'rankdir',
+ 'ranksep',
+ 'ratio',
+ 'size',
+ 'style',
+ 'URL'
+ ]
+
+ # a root class for any element in dot notation
+ class DOTSimpleElement
+ attr_accessor :name
+
+ def initialize( params = {} )
+ @label = params['name'] ? params['name'] : ''
+ end
+
+ def to_s
+ @name
+ end
+ end
+
+ # an element that has options ( node, edge or graph )
+ class DOTElement < DOTSimpleElement
+ #attr_reader :parent
+ attr_accessor :name, :options
+
+ def initialize( params = {}, option_list = [] )
+ super( params )
+ @name = params['name'] ? params['name'] : nil
+ @parent = params['parent'] ? params['parent'] : nil
+ @options = {}
+ option_list.each{ |i|
+ @options[i] = params[i] if params[i]
+ }
+ @options['label'] ||= @name if @name != 'node'
+ end
+
+ def each_option
+ @options.each{ |i| yield i }
+ end
+
+ def each_option_pair
+ @options.each_pair{ |key, val| yield key, val }
+ end
+
+ #def parent=( thing )
+ # @parent.delete( self ) if defined?( @parent ) and @parent
+ # @parent = thing
+ #end
+ end
+
+
+ # this is used when we build nodes that have shape=record
+ # ports don't have options :)
+ class DOTPort < DOTSimpleElement
+ attr_accessor :label
+
+ def initialize( params = {} )
+ super( params )
+ @name = params['label'] ? params['label'] : ''
+ end
+ def to_s
+ ( @name && @name != "" ? "<#{@name}>" : "" ) + "#{@label}"
+ end
+ end
+
+ # node element
+ class DOTNode < DOTElement
+
+ def initialize( params = {}, option_list = NODE_OPTS )
+ super( params, option_list )
+ @ports = params['ports'] ? params['ports'] : []
+ end
+
+ def each_port
+ @ports.each{ |i| yield i }
+ end
+
+ def << ( thing )
+ @ports << thing
+ end
+
+ def push ( thing )
+ @ports.push( thing )
+ end
+
+ def pop
+ @ports.pop
+ end
+
+ def to_s( t = '' )
+
+ label = @options['shape'] != 'record' && @ports.length == 0 ?
+ @options['label'] ?
+ t + $tab + "label = \"#{@options['label']}\"\n" :
+ '' :
+ t + $tab + 'label = "' + " \\\n" +
+ t + $tab2 + "#{@options['label']}| \\\n" +
+ @ports.collect{ |i|
+ t + $tab2 + i.to_s
+ }.join( "| \\\n" ) + " \\\n" +
+ t + $tab + '"' + "\n"
+
+ t + "#{@name} [\n" +
+ @options.to_a.collect{ |i|
+ i[1] && i[0] != 'label' ?
+ t + $tab + "#{i[0]} = #{i[1]}" : nil
+ }.compact.join( ",\n" ) + ( label != '' ? ",\n" : "\n" ) +
+ label +
+ t + "]\n"
+ end
+ end
+
+ # subgraph element is the same to graph, but has another header in dot
+ # notation
+ class DOTSubgraph < DOTElement
+
+ def initialize( params = {}, option_list = GRAPH_OPTS )
+ super( params, option_list )
+ @nodes = params['nodes'] ? params['nodes'] : []
+ @dot_string = 'subgraph'
+ end
+
+ def each_node
+ @nodes.each{ |i| yield i }
+ end
+
+ def << ( thing )
+ @nodes << thing
+ end
+
+ def push( thing )
+ @nodes.push( thing )
+ end
+
+ def pop
+ @nodes.pop
+ end
+
+ def to_s( t = '' )
+ hdr = t + "#{@dot_string} #{@name} {\n"
+
+ options = @options.to_a.collect{ |name, val|
+ val && name != 'label' ?
+ t + $tab + "#{name} = #{val}" :
+ name ? t + $tab + "#{name} = \"#{val}\"" : nil
+ }.compact.join( "\n" ) + "\n"
+
+ nodes = @nodes.collect{ |i|
+ i.to_s( t + $tab )
+ }.join( "\n" ) + "\n"
+ hdr + options + nodes + t + "}\n"
+ end
+ end
+
+ # this is graph
+ class DOTDigraph < DOTSubgraph
+ def initialize( params = {}, option_list = GRAPH_OPTS )
+ super( params, option_list )
+ @dot_string = 'digraph'
+ end
+ end
+
+ # this is edge
+ class DOTEdge < DOTElement
+ attr_accessor :from, :to
+ def initialize( params = {}, option_list = EDGE_OPTS )
+ super( params, option_list )
+ @from = params['from'] ? params['from'] : nil
+ @to = params['to'] ? params['to'] : nil
+ end
+
+ def to_s( t = '' )
+ t + "#{@from} -> #{to} [\n" +
+ @options.to_a.collect{ |i|
+ i[1] && i[0] != 'label' ?
+ t + $tab + "#{i[0]} = #{i[1]}" :
+ i[1] ? t + $tab + "#{i[0]} = \"#{i[1]}\"" : nil
+ }.compact.join( "\n" ) + "\n" + t + "]\n"
+ end
+ end
+end
+
+
+
diff --git a/lib/rdoc/generators/chm_generator.rb b/lib/rdoc/generators/chm_generator.rb
new file mode 100644
index 0000000000..1c46769cc2
--- /dev/null
+++ b/lib/rdoc/generators/chm_generator.rb
@@ -0,0 +1,112 @@
+require 'rdoc/generators/html_generator'
+
+module Generators
+
+ class CHMGenerator < HTMLGenerator
+
+ HHC_PATH = "c:\\Program Files\\HTML Help Workshop\\hhc.exe"
+
+ # Standard generator factory
+ def CHMGenerator.for(options)
+ CHMGenerator.new(options)
+ end
+
+
+ def initialize(*args)
+ super
+ @op_name = @options.op_name || "rdoc"
+ check_for_html_help_workshop
+ end
+
+ def check_for_html_help_workshop
+ stat = File.stat(HHC_PATH)
+ rescue
+ $stderr <<
+ "\n.chm output generation requires that Microsoft's Html Help\n" <<
+ "Workshop is installed. RDoc looks for it in:\n\n " <<
+ HHC_PATH <<
+ "\n\nYou can download a copy for free from:\n\n" <<
+ " http://msdn.microsoft.com/library/default.asp?" <<
+ "url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp\n\n"
+
+ exit 99
+ end
+
+ # Generate the html as normal, then wrap it
+ # in a help project
+ def generate(info)
+ super
+ @project_name = @op_name + ".hhp"
+ create_help_project
+ end
+
+ # The project contains the project file, a table of contents
+ # and an index
+ def create_help_project
+ create_project_file
+ create_contents_and_index
+ compile_project
+ end
+
+ # The project file links together all the various
+ # files that go to make up the help.
+
+ def create_project_file
+ template = TemplatePage.new(RDoc::Page::HPP_FILE)
+ values = { "title" => @options.title, "opname" => @op_name }
+ files = []
+ @files.each do |f|
+ files << { "html_file_name" => f.path }
+ end
+
+ values['all_html_files'] = files
+
+ File.open(@project_name, "w") do |f|
+ template.write_html_on(f, values)
+ end
+ end
+
+ # The contents is a list of all files and modules.
+ # For each we include as sub-entries the list
+ # of methods they contain. As we build the contents
+ # we also build an index file
+
+ def create_contents_and_index
+ contents = []
+ index = []
+
+ (@files+@classes).sort.each do |entry|
+ content_entry = { "c_name" => entry.name, "ref" => entry.path }
+ index << { "name" => entry.name, "aref" => entry.path }
+
+ internals = []
+
+ methods = entry.build_method_summary_list(entry.path)
+
+ content_entry["methods"] = methods unless methods.empty?
+ contents << content_entry
+ index.concat methods
+ end
+
+ values = { "contents" => contents }
+ template = TemplatePage.new(RDoc::Page::CONTENTS)
+ File.open("contents.hhc", "w") do |f|
+ template.write_html_on(f, values)
+ end
+
+ values = { "index" => index }
+ template = TemplatePage.new(RDoc::Page::CHM_INDEX)
+ File.open("index.hhk", "w") do |f|
+ template.write_html_on(f, values)
+ end
+ end
+
+ # Invoke the windows help compiler to compiler the project
+ def compile_project
+ system("\"#{HHC_PATH}\" #@project_name")
+ end
+
+ end
+
+
+end
diff --git a/lib/rdoc/generators/html_generator.rb b/lib/rdoc/generators/html_generator.rb
new file mode 100644
index 0000000000..fbfc596cc3
--- /dev/null
+++ b/lib/rdoc/generators/html_generator.rb
@@ -0,0 +1,1442 @@
+# We're responsible for generating all the HTML files
+# from the object tree defined in code_objects.rb. We
+# generate:
+#
+# [files] an html file for each input file given. These
+# input files appear as objects of class
+# TopLevel
+#
+# [classes] an html file for each class or module encountered.
+# These classes are not grouped by file: if a file
+# contains four classes, we'll generate an html
+# file for the file itself, and four html files
+# for the individual classes.
+#
+# [indices] we generate three indices for files, classes,
+# and methods. These are displayed in a browser
+# like window with three index panes across the
+# top and the selected description below
+#
+# Method descriptions appear in whatever entity (file, class,
+# or module) that contains them.
+#
+# We generate files in a structure below a specified subdirectory,
+# normally +doc+.
+#
+# opdir
+# |
+# |___ files
+# | |__ per file summaries
+# |
+# |___ classes
+# |__ per class/module descriptions
+#
+# HTML is generated using the Template class.
+#
+
+require 'ftools'
+
+require 'rdoc/options'
+require 'rdoc/template'
+require 'rdoc/markup/simple_markup'
+require 'rdoc/markup/simple_markup/to_html'
+require 'cgi'
+
+module Generators
+
+ # Name of sub-direcories that hold file and class/module descriptions
+
+ FILE_DIR = "files"
+ CLASS_DIR = "classes"
+ CSS_NAME = "rdoc-style.css"
+
+
+ ##
+ # Build a hash of all items that can be cross-referenced.
+ # This is used when we output required and included names:
+ # if the names appear in this hash, we can generate
+ # an html cross reference to the appropriate description.
+ # We also use this when parsing comment blocks: any decorated
+ # words matching an entry in this list are hyperlinked.
+
+ class AllReferences
+ @@refs = {}
+
+ def AllReferences::reset
+ @@refs = {}
+ end
+
+ def AllReferences.add(name, html_class)
+ @@refs[name] = html_class
+ end
+
+ def AllReferences.[](name)
+ @@refs[name]
+ end
+
+ def AllReferences.keys
+ @@refs.keys
+ end
+ end
+
+
+ ##
+ # Subclass of the SM::ToHtml class that supports looking
+ # up words in the AllReferences list. Those that are
+ # found (like AllReferences in this comment) will
+ # be hyperlinked
+
+ class HyperlinkHtml < SM::ToHtml
+ # We need to record the html path of our caller so we can generate
+ # correct relative paths for any hyperlinks that we find
+ def initialize(from_path, context)
+ super()
+ @from_path = from_path
+
+ @parent_name = context.parent_name
+ @parent_name += "::" if @parent_name
+ @context = context
+ end
+
+ # We're invoked when any text matches the CROSSREF pattern
+ # (defined in MarkUp). If we fine the corresponding reference,
+ # generate a hyperlink. If the name we're looking for contains
+ # no punctuation, we look for it up the module/class chain. For
+ # example, HyperlinkHtml is found, even without the Generators::
+ # prefix, because we look for it in module Generators first.
+
+ def handle_special_CROSSREF(special)
+ name = special.text
+ if name[0,1] == '#'
+ lookup = name[1..-1]
+ name = lookup unless Options.instance.show_hash
+ else
+ lookup = name
+ end
+
+ if /([A-Z].*)[.\#](.*)/ =~ lookup
+ container = $1
+ method = $2
+ ref = @context.find_symbol(container, method)
+ else
+ ref = @context.find_symbol(lookup)
+ end
+
+ if ref and ref.document_self
+ "<a href=\"#{ref.as_href(@from_path)}\">#{name}</a>"
+ else
+ name
+ end
+ end
+
+
+ # Generate a hyperlink for url, labeled with text. Handle the
+ # special cases for img: and link: described under handle_special_HYPEDLINK
+ def gen_url(url, text)
+ if url =~ /([A-Za-z]+):(.*)/
+ type = $1
+ path = $2
+ else
+ type = "http"
+ path = url
+ url = "http://#{url}"
+ end
+
+ if type == "link"
+ if path[0,1] == '#' # is this meaningful?
+ url = path
+ else
+ url = HTMLGenerator.gen_url(@from_path, path)
+ end
+ end
+
+ if (type == "http" || type == "link") &&
+ url =~ /\.(gif|png|jpg|jpeg|bmp)$/
+
+ "<img src=\"#{url}\">"
+ else
+ "<a href=\"#{url}\">#{text.sub(%r{^#{type}:/*}, '')}</a>"
+ end
+ end
+
+ # And we're invoked with a potential external hyperlink mailto:
+ # just gets inserted. http: links are checked to see if they
+ # reference an image. If so, that image gets inserted using an
+ # <img> tag. Otherwise a conventional <a href> is used. We also
+ # support a special type of hyperlink, link:, which is a reference
+ # to a local file whose path is relative to the --op directory.
+
+ def handle_special_HYPERLINK(special)
+ url = special.text
+ gen_url(url, url)
+ end
+
+ # HEre's a hypedlink where the label is different to the URL
+ # <label>[url]
+ #
+
+ def handle_special_TIDYLINK(special)
+ text = special.text
+# unless text =~ /(\S+)\[(.*?)\]/
+ unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
+ return text
+ end
+ label = $1
+ url = $2
+ gen_url(url, label)
+ end
+
+ end
+
+
+
+ #####################################################################
+ #
+ # Handle common markup tasks for the various Html classes
+ #
+
+ module MarkUp
+
+ # Convert a string in markup format into HTML. We keep a cached
+ # SimpleMarkup object lying around after the first time we're
+ # called per object.
+
+ def markup(str, remove_para=false)
+ return '' unless str
+ unless defined? @markup
+ @markup = SM::SimpleMarkup.new
+
+ # class names, variable names, file names, or instance variables
+ @markup.add_special(/(
+ \b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth
+ | \b([A-Z]\w+(::\w+)*) # A::B..
+ | \#\w+[!?=]? # #meth_name
+ | \b\w+([_\/\.]+\w+)+[!?=]? # meth_name
+ )/x,
+ :CROSSREF)
+
+ # external hyperlinks
+ @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
+
+ # and links of the form <text>[<url>]
+ @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
+# @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)
+
+ end
+ unless defined? @html_formatter
+ @html_formatter = HyperlinkHtml.new(self.path, self)
+ end
+
+ # Convert leading comment markers to spaces, but only
+ # if all non-blank lines have them
+
+ if str =~ /^(?>\s*)[^\#]/
+ content = str
+ else
+ content = str.gsub(/^\s*(#+)/) { $1.tr('#',' ') }
+ end
+
+ res = @markup.convert(content, @html_formatter)
+ if remove_para
+ res.sub!(/^<p>/, '')
+ res.sub!(/<\/p>$/, '')
+ end
+ res
+ end
+
+ # Qualify a stylesheet URL; if if +css_name+ does not begin with '/' or
+ # 'http[s]://', prepend a prefix relative to +path+. Otherwise, return it
+ # unmodified.
+
+ def style_url(path, css_name=nil)
+# $stderr.puts "style_url( #{path.inspect}, #{css_name.inspect} )"
+ css_name ||= CSS_NAME
+ if %r{^(https?:/)?/} =~ css_name
+ return css_name
+ else
+ return HTMLGenerator.gen_url(path, css_name)
+ end
+ end
+
+ # Build a webcvs URL with the given 'url' argument. URLs with a '%s' in them
+ # get the file's path sprintfed into them; otherwise they're just catenated
+ # together.
+
+ def cvs_url(url, full_path)
+ if /%s/ =~ url
+ return sprintf( url, full_path )
+ else
+ return url + full_path
+ end
+ end
+ end
+
+
+ #####################################################################
+ #
+ # A Context is built by the parser to represent a container: contexts
+ # hold classes, modules, methods, require lists and include lists.
+ # ClassModule and TopLevel are the context objects we process here
+ #
+ class ContextUser
+
+ include MarkUp
+
+ attr_reader :context
+
+ def initialize(context, options)
+ @context = context
+ @options = options
+ end
+
+ # convenience method to build a hyperlink
+ def href(link, cls, name)
+ %{<a href="#{link}" class="#{cls}">#{name}</a>} #"
+ end
+
+ # return a reference to outselves to be used as an href=
+ # the form depends on whether we're all in one file
+ # or in multiple files
+
+ def as_href(from_path)
+ if @options.all_one_file
+ "#" + path
+ else
+ HTMLGenerator.gen_url(from_path, path)
+ end
+ end
+
+ # Create a list of HtmlMethod objects for each method
+ # in the corresponding context object. If the @options.show_all
+ # variable is set (corresponding to the <tt>--all</tt> option,
+ # we include all methods, otherwise just the public ones.
+
+ def collect_methods
+ list = @context.method_list
+ unless @options.show_all
+ list = list.find_all {|m| m.visibility == :public || m.force_documentation }
+ end
+ @methods = list.collect {|m| HtmlMethod.new(m, self, @options) }
+ end
+
+ # Build a summary list of all the methods in this context
+ def build_method_summary_list(path_prefix="")
+ collect_methods unless @methods
+ meths = @methods.sort
+ res = []
+ meths.each do |meth|
+ res << {
+ "name" => CGI.escapeHTML(meth.name),
+ "aref" => "#{path_prefix}\##{meth.aref}"
+ }
+ end
+ res
+ end
+
+
+ # Build a list of aliases for which we couldn't find a
+ # corresponding method
+ def build_alias_summary_list
+ @context.aliases.map do |al|
+ res = {
+ 'old_name' => al.old_name,
+ 'new_name' => al.new_name,
+ }
+ if al.comment && !al.comment.empty?
+ res['desc'] = markup(al.comment, true)
+ end
+ res
+ end
+ end
+
+ # Build a list of constants
+ def build_constants_summary_list
+ @context.constants.map do |co|
+ res = {
+ 'name' => co.name,
+ 'value' => CGI.escapeHTML(co.value)
+ }
+ res['desc'] = markup(co.comment, true) if co.comment && !co.comment.empty?
+ res
+ end
+ end
+
+ def build_requires_list(context)
+ potentially_referenced_list(context.requires) {|fn| [fn + ".rb"] }
+ end
+
+ def build_include_list(context)
+ potentially_referenced_list(context.includes)
+ end
+
+ # Build a list from an array of <i>Htmlxxx</i> items. Look up each
+ # in the AllReferences hash: if we find a corresponding entry,
+ # we generate a hyperlink to it, otherwise just output the name.
+ # However, some names potentially need massaging. For example,
+ # you may require a Ruby file without the .rb extension,
+ # but the file names we know about may have it. To deal with
+ # this, we pass in a block which performs the massaging,
+ # returning an array of alternative names to match
+
+ def potentially_referenced_list(array)
+ res = []
+ array.each do |i|
+ ref = AllReferences[i.name]
+# if !ref
+# container = @context.parent
+# while !ref && container
+# name = container.name + "::" + i.name
+# ref = AllReferences[name]
+# container = container.parent
+# end
+# end
+
+ ref = @context.find_symbol(i.name)
+ ref = ref.viewer if ref
+
+ if !ref && block_given?
+ possibles = yield(i.name)
+ while !ref and !possibles.empty?
+ ref = AllReferences[possibles.shift]
+ end
+ end
+ h_name = CGI.escapeHTML(i.name)
+ if ref and ref.document_self
+ path = url(ref.path)
+ res << { "name" => h_name, "aref" => path }
+ else
+ res << { "name" => h_name }
+ end
+ end
+ res
+ end
+
+ # Build an array of arrays of method details. The outer array has up
+ # to six entries, public, private, and protected for both class
+ # methods, the other for instance methods. The inner arrays contain
+ # a hash for each method
+
+ def build_method_detail_list
+ outer = []
+
+ methods = @methods.sort
+ for singleton in [true, false]
+ for vis in [ :public, :protected, :private ]
+ res = []
+ methods.each do |m|
+ if m.document_self and m.visibility == vis and m.singleton == singleton
+ row = {}
+ if m.call_seq
+ row["callseq"] = m.call_seq.gsub(/->/, '&rarr;')
+ else
+ row["name"] = CGI.escapeHTML(m.name)
+ row["params"] = m.params
+ end
+ desc = m.description.strip
+ row["m_desc"] = desc unless desc.empty?
+ row["aref"] = m.aref
+ row["visibility"] = m.visibility.to_s
+
+ alias_names = []
+ m.aliases.each do |other|
+ if other.viewer # won't be if the alias is private
+ alias_names << {
+ 'name' => other.name,
+ 'aref' => other.viewer.as_href(path)
+ }
+ end
+ end
+ unless alias_names.empty?
+ row["aka"] = alias_names
+ end
+
+ if @options.inline_source
+ code = m.source_code
+ row["sourcecode"] = code if code
+ else
+ code = m.src_url
+ if code
+ row["codeurl"] = code
+ row["imgurl"] = m.img_url
+ end
+ end
+ res << row
+ end
+ end
+ if res.size > 0
+ outer << {
+ "type" => vis.to_s.capitalize,
+ "category" => singleton ? "Class" : "Instance",
+ "methods" => res
+ }
+ end
+ end
+ end
+ outer
+ end
+
+ # Build the structured list of classes and modules contained
+ # in this context.
+
+ def build_class_list(level, from, infile=nil)
+ res = ""
+ prefix = "&nbsp;&nbsp;::" * level;
+
+ from.modules.sort.each do |mod|
+ next if infile && !mod.defined_in?(infile)
+ if mod.document_self
+ res <<
+ prefix <<
+ "Module " <<
+ href(url(mod.viewer.path), "link", mod.full_name) <<
+ "<br />\n" <<
+ build_class_list(level + 1, mod, infile)
+ end
+ end
+
+ from.classes.sort.each do |cls|
+ next if infile && !cls.defined_in?(infile)
+ if cls.document_self
+ res <<
+ prefix <<
+ "Class " <<
+ href(url(cls.viewer.path), "link", cls.full_name) <<
+ "<br />\n" <<
+ build_class_list(level + 1, cls, infile)
+ end
+ end
+
+ res
+ end
+
+ def url(target)
+ HTMLGenerator.gen_url(path, target)
+ end
+
+ def aref_to(target)
+ if @options.all_one_file
+ "#" + target
+ else
+ url(target)
+ end
+ end
+
+ def document_self
+ @context.document_self
+ end
+
+ def diagram_reference(diagram)
+ res = diagram.gsub(/((?:src|href)=")(.*?)"/) {
+ $1 + url($2) + '"'
+ }
+ res
+ end
+
+
+ # Find a symbol in ourselves or our parent
+ def find_symbol(symbol, method=nil)
+ res = @context.find_symbol(symbol, method)
+ if res
+ res = res.viewer
+ end
+ res
+ end
+ end
+
+ #####################################################################
+ #
+ # Wrap a ClassModule context
+
+ class HtmlClass < ContextUser
+
+ attr_reader :path
+
+ def initialize(context, html_file, prefix, options)
+ super(context, options)
+
+ @html_file = html_file
+ @is_module = context.is_module?
+ @values = {}
+
+ context.viewer = self
+
+ if options.all_one_file
+ @path = context.full_name
+ else
+ @path = http_url(context.full_name, prefix)
+ end
+
+ collect_methods
+
+ AllReferences.add(name, self)
+ end
+
+ # return the relative file name to store this class in,
+ # which is also its url
+ def http_url(full_name, prefix)
+ path = full_name.dup
+ if path['<<']
+ path.gsub!(/<<\s*(\w*)/) { "from-#$1" }
+ end
+ File.join(prefix, path.split("::")) + ".html"
+ end
+
+
+ def name
+ @context.full_name
+ end
+
+ def parent_name
+ @context.parent.full_name
+ end
+
+ def index_name
+ name
+ end
+
+ def write_on(f)
+ value_hash
+ template = TemplatePage.new(RDoc::Page::BODY,
+ RDoc::Page::CLASS_PAGE,
+ RDoc::Page::METHOD_LIST)
+ template.write_html_on(f, @values)
+ end
+
+ def value_hash
+ class_attribute_values
+
+ @values["charset"] = @options.charset
+ @values["style_url"] = style_url(path, @options.css)
+
+ d = markup(@context.comment)
+ @values["description"] = d unless d.empty?
+
+ ml = build_method_summary_list
+ @values["methods"] = ml unless ml.empty?
+
+ al = build_alias_summary_list
+ @values["aliases"] = al unless al.empty?
+
+ co = build_constants_summary_list
+ @values["constants"] = co unless co.empty?
+
+ il = build_include_list(@context)
+ @values["includes"] = il unless il.empty?
+
+ al = build_attribute_list
+ @values["attributes"] = al unless al.empty?
+
+ cl = build_class_list(0, @context)
+ @values["classlist"] = cl unless cl.empty?
+
+ mdl = build_method_detail_list
+ @values["method_list"] = mdl unless mdl.empty?
+ @values
+ end
+
+ def build_attribute_list
+ atts = @context.attributes.sort
+ res = []
+ atts.each do |att|
+ if att.visibility == :public || @options.show_all
+ entry = {
+ "name" => CGI.escapeHTML(att.name),
+ "rw" => att.rw,
+ "a_desc" => markup(att.comment, true)
+ }
+ unless att.visibility == :public
+ entry["rw"] << "-"
+ end
+ res << entry
+ end
+ end
+ res
+ end
+
+ def class_attribute_values
+ h_name = CGI.escapeHTML(name)
+
+ @values["classmod"] = @is_module ? "Module" : "Class"
+ @values["title"] = "#{@values['classmod']}: #{h_name}"
+
+ c = @context
+ c = c.parent while c and !c.diagram
+ if c && c.diagram
+ @values["diagram"] = diagram_reference(c.diagram)
+ end
+
+ @values["full_name"] = h_name
+
+ parent_class = @context.superclass
+
+ if parent_class
+ @values["parent"] = CGI.escapeHTML(parent_class)
+
+ if parent_name
+ lookup = parent_name + "::" + parent_class
+ else
+ lookup = parent_class
+ end
+
+ parent_url = AllReferences[lookup] || AllReferences[parent_class]
+
+ if parent_url and parent_url.document_self
+ @values["par_url"] = aref_to(parent_url.path)
+ end
+ end
+
+ files = []
+ @context.in_files.each do |f|
+ res = {}
+ full_path = CGI.escapeHTML(f.file_absolute_name)
+
+ res["full_path"] = full_path
+ res["full_path_url"] = aref_to(f.viewer.path) if f.document_self
+
+ if @options.webcvs
+ res["cvsurl"] = cvs_url( @options.webcvs, full_path )
+ end
+
+ files << res
+ end
+
+ @values['infiles'] = files
+
+ end
+
+ def <=>(other)
+ self.name <=> other.name
+ end
+
+ end
+
+ #####################################################################
+ #
+ # Handles the mapping of a file's information to HTML. In reality,
+ # a file corresponds to a +TopLevel+ object, containing modules,
+ # classes, and top-level methods. In theory it _could_ contain
+ # attributes and aliases, but we ignore these for now.
+
+ class HtmlFile < ContextUser
+
+ attr_reader :path
+ attr_reader :name
+
+ def initialize(context, options, file_dir)
+ super(context, options)
+
+ @values = {}
+
+ if options.all_one_file
+ @path = filename_to_label
+ else
+ @path = http_url(file_dir)
+ end
+
+ @name = @context.file_relative_name
+
+ collect_methods
+ AllReferences.add(name, self)
+ context.viewer = self
+ end
+
+ def http_url(file_dir)
+ File.join(file_dir, @context.file_relative_name.tr('.', '_')) +
+ ".html"
+ end
+
+ def filename_to_label
+ @context.file_relative_name.gsub(/%|\/|\?|\#/) {|s| '%' + ("%x" % s[0]) }
+ end
+
+ def index_name
+ name
+ end
+
+ def parent_name
+ nil
+ end
+
+ def value_hash
+ file_attribute_values
+
+ @values["charset"] = @options.charset
+ @values["href"] = path
+ @values["style_url"] = style_url(path, @options.css)
+
+ if @context.comment
+ d = markup(@context.comment)
+ @values["description"] = d if d.size > 0
+ end
+
+ ml = build_method_summary_list
+ @values["methods"] = ml unless ml.empty?
+
+ il = build_include_list(@context)
+ @values["includes"] = il unless il.empty?
+
+ rl = build_requires_list(@context)
+ @values["requires"] = rl unless rl.empty?
+
+ co = build_constants_summary_list
+ @values["constants"] = co unless co.empty?
+
+ al = build_alias_summary_list
+ @values["aliases"] = al unless al.empty?
+
+ if @options.promiscuous
+ file_context = nil
+ else
+ file_context = @context
+ end
+
+ cl = build_class_list(0, @context, file_context)
+ @values["classlist"] = cl unless cl.empty?
+
+ mdl = build_method_detail_list
+ @values["method_list"] = mdl unless mdl.empty?
+ @values
+ end
+
+ def write_on(f)
+ value_hash
+ template = TemplatePage.new(RDoc::Page::BODY,
+ RDoc::Page::FILE_PAGE,
+ RDoc::Page::METHOD_LIST)
+ template.write_html_on(f, @values)
+ end
+
+ def file_attribute_values
+ full_path = @context.file_absolute_name
+ short_name = File.basename(full_path)
+
+ @values["title"] = CGI.escapeHTML("File: #{short_name}")
+
+ if @context.diagram
+ @values["diagram"] = diagram_reference(@context.diagram)
+ end
+
+ @values["short_name"] = CGI.escapeHTML(short_name)
+ @values["full_path"] = CGI.escapeHTML(full_path)
+ @values["dtm_modified"] = @context.file_stat.mtime.to_s
+
+ if @options.webcvs
+ @values["cvsurl"] = cvs_url( @options.webcvs, @values["full_path"] )
+ end
+ end
+
+ def <=>(other)
+ self.name <=> other.name
+ end
+ end
+
+ #####################################################################
+
+ class HtmlMethod
+ include MarkUp
+
+ attr_reader :context
+ attr_reader :src_url
+ attr_reader :img_url
+ attr_reader :source_code
+
+ @@seq = "M000000"
+
+ @@all_methods = []
+
+ def HtmlMethod::reset
+ @@all_methods = []
+ end
+
+ def initialize(context, html_class, options)
+ @context = context
+ @html_class = html_class
+ @options = options
+ @@seq = @@seq.succ
+ @seq = @@seq
+ @@all_methods << self
+
+ context.viewer = self
+
+ if (ts = @context.token_stream)
+ @source_code = markup_code(ts)
+ unless @options.inline_source
+ @src_url = create_source_code_file(@source_code)
+ @img_url = HTMLGenerator.gen_url(path, 'source.png')
+ end
+ end
+
+ AllReferences.add(name, self)
+ end
+
+ # return a reference to outselves to be used as an href=
+ # the form depends on whether we're all in one file
+ # or in multiple files
+
+ def as_href(from_path)
+ if @options.all_one_file
+ "#" + path
+ else
+ HTMLGenerator.gen_url(from_path, path)
+ end
+ end
+
+ def name
+ @context.name
+ end
+
+ def index_name
+ "#{@context.name} (#{@html_class.name})"
+ end
+
+ def parent_name
+ if @context.parent.parent
+ @context.parent.parent.full_name
+ else
+ nil
+ end
+ end
+
+ def aref
+ @seq
+ end
+
+ def path
+ if @options.all_one_file
+ aref
+ else
+ @html_class.path + "#" + aref
+ end
+ end
+
+ def description
+ markup(@context.comment)
+ end
+
+ def visibility
+ @context.visibility
+ end
+
+ def singleton
+ @context.singleton
+ end
+
+ def call_seq
+ cs = @context.call_seq
+ if cs
+ cs.gsub(/\n/, "<br />\n")
+ else
+ nil
+ end
+ end
+
+ def params
+ # params coming from a call-seq in 'C' will start with the
+ # method name
+ p = @context.params
+ if p !~ /^\w/
+ p = @context.params.gsub(/\s*\#.*/, '')
+ p = p.tr("\n", " ").squeeze(" ")
+ p = "(" + p + ")" unless p[0] == ?(
+
+ if (block = @context.block_params)
+ # If this method has explicit block parameters, remove any
+ # explicit &block
+
+ p.sub!(/,?\s*&\w+/, '')
+
+ block.gsub!(/\s*\#.*/, '')
+ block = block.tr("\n", " ").squeeze(" ")
+ if block[0] == ?(
+ block.sub!(/^\(/, '').sub!(/\)/, '')
+ end
+ p << " {|#{block.strip}| ...}"
+ end
+ end
+ CGI.escapeHTML(p)
+ end
+
+ def create_source_code_file(code_body)
+ meth_path = @html_class.path.sub(/\.html$/, '.src')
+ File.makedirs(meth_path)
+ file_path = File.join(meth_path, @seq) + ".html"
+
+ template = TemplatePage.new(RDoc::Page::SRC_PAGE)
+ File.open(file_path, "w") do |f|
+ values = {
+ 'title' => CGI.escapeHTML(index_name),
+ 'code' => code_body,
+ 'style_url' => style_url(file_path, @options.css),
+ 'charset' => @options.charset
+ }
+ template.write_html_on(f, values)
+ end
+ HTMLGenerator.gen_url(path, file_path)
+ end
+
+ def HtmlMethod.all_methods
+ @@all_methods
+ end
+
+ def <=>(other)
+ @context <=> other.context
+ end
+
+ ##
+ # Given a sequence of source tokens, mark up the source code
+ # to make it look purty.
+
+
+ def markup_code(tokens)
+ src = ""
+ tokens.each do |t|
+ next unless t
+ # p t.class
+# style = STYLE_MAP[t.class]
+ style = case t
+ when RubyToken::TkCONSTANT then "ruby-constant"
+ when RubyToken::TkKW then "ruby-keyword kw"
+ when RubyToken::TkIVAR then "ruby-ivar"
+ when RubyToken::TkOp then "ruby-operator"
+ when RubyToken::TkId then "ruby-identifier"
+ when RubyToken::TkNode then "ruby-node"
+ when RubyToken::TkCOMMENT then "ruby-comment cmt"
+ when RubyToken::TkREGEXP then "ruby-regexp re"
+ when RubyToken::TkSTRING then "ruby-value str"
+ when RubyToken::TkVal then "ruby-value"
+ else
+ nil
+ end
+
+ text = CGI.escapeHTML(t.text)
+
+ if style
+ src << "<span class=\"#{style}\">#{text}</span>"
+ else
+ src << text
+ end
+ end
+
+ add_line_numbers(src) if Options.instance.include_line_numbers
+ src
+ end
+
+ # we rely on the fact that the first line of a source code
+ # listing has
+ # # File xxxxx, line dddd
+
+ def add_line_numbers(src)
+ if src =~ /\A.*, line (\d+)/
+ first = $1.to_i - 1
+ last = first + src.count("\n")
+ size = last.to_s.length
+ real_fmt = "%#{size}d: "
+ fmt = " " * (size+2)
+ src.gsub!(/^/) do
+ res = sprintf(fmt, first)
+ first += 1
+ fmt = real_fmt
+ res
+ end
+ end
+ end
+
+ def document_self
+ @context.document_self
+ end
+
+ def aliases
+ @context.aliases
+ end
+
+ def find_symbol(symbol, method=nil)
+ res = @context.parent.find_symbol(symbol, method)
+ if res
+ res = res.viewer
+ end
+ res
+ end
+ end
+
+ #####################################################################
+
+ class HTMLGenerator
+
+ include MarkUp
+
+ ##
+ # convert a target url to one that is relative to a given
+ # path
+
+ def HTMLGenerator.gen_url(path, target)
+ from = File.dirname(path)
+ to, to_file = File.split(target)
+
+ from = from.split("/")
+ to = to.split("/")
+
+ while from.size > 0 and to.size > 0 and from[0] == to[0]
+ from.shift
+ to.shift
+ end
+
+ from.fill("..")
+ from.concat(to)
+ from << to_file
+ File.join(*from)
+ end
+
+ # Generators may need to return specific subclasses depending
+ # on the options they are passed. Because of this
+ # we create them using a factory
+
+ def HTMLGenerator.for(options)
+ AllReferences::reset
+ HtmlMethod::reset
+
+ if options.all_one_file
+ HTMLGeneratorInOne.new(options)
+ else
+ HTMLGenerator.new(options)
+ end
+ end
+
+ class <<self
+ protected :new
+ end
+
+ # Set up a new HTML generator. Basically all we do here is load
+ # up the correct output temlate
+
+ def initialize(options) #:not-new:
+ @options = options
+ load_html_template
+ end
+
+
+ ##
+ # Build the initial indices and output objects
+ # based on an array of TopLevel objects containing
+ # the extracted information.
+
+ def generate(toplevels)
+ @toplevels = toplevels
+ @files = []
+ @classes = []
+
+ write_style_sheet
+ gen_sub_directories()
+ build_indices
+ generate_html
+ end
+
+ private
+
+ ##
+ # Load up the HTML template specified in the options.
+ # If the template name contains a slash, use it literally
+ #
+ def load_html_template
+ template = @options.template
+ unless template =~ %r{/|\\}
+ template = File.join("rdoc/generators/template",
+ @options.generator.key, template)
+ end
+ require template
+ extend RDoc::Page
+ rescue LoadError
+ $stderr.puts "Could not find HTML template '#{template}'"
+ exit 99
+ end
+
+ ##
+ # Write out the style sheet used by the main frames
+ #
+
+ def write_style_sheet
+ template = TemplatePage.new(RDoc::Page::STYLE)
+ unless @options.css
+ File.open(CSS_NAME, "w") do |f|
+ values = { "fonts" => RDoc::Page::FONTS }
+ template.write_html_on(f, values)
+ end
+ end
+ end
+
+ ##
+ # See the comments at the top for a description of the
+ # directory structure
+
+ def gen_sub_directories
+ File.makedirs(FILE_DIR, CLASS_DIR)
+ rescue
+ $stderr.puts $!.message
+ exit 1
+ end
+
+ ##
+ # Generate:
+ #
+ # * a list of HtmlFile objects for each TopLevel object.
+ # * a list of HtmlClass objects for each first level
+ # class or module in the TopLevel objects
+ # * a complete list of all hyperlinkable terms (file,
+ # class, module, and method names)
+
+ def build_indices
+
+ @toplevels.each do |toplevel|
+ @files << HtmlFile.new(toplevel, @options, FILE_DIR)
+ end
+
+ RDoc::TopLevel.all_classes_and_modules.each do |cls|
+ build_class_list(cls, @files[0], CLASS_DIR)
+ end
+ end
+
+ def build_class_list(from, html_file, class_dir)
+ @classes << HtmlClass.new(from, html_file, class_dir, @options)
+ from.each_classmodule do |mod|
+ build_class_list(mod, html_file, class_dir)
+ end
+ end
+
+ ##
+ # Generate all the HTML
+ #
+ def generate_html
+ # the individual descriptions for files and classes
+ gen_into(@files)
+ gen_into(@classes)
+ # and the index files
+ gen_file_index
+ gen_class_index
+ gen_method_index
+ gen_main_index
+
+ # this method is defined in the template file
+ write_extra_pages if defined? write_extra_pages
+ end
+
+ def gen_into(list)
+ list.each do |item|
+ if item.document_self
+ op_file = item.path
+ File.makedirs(File.dirname(op_file))
+ File.open(op_file, "w") { |file| item.write_on(file) }
+ end
+ end
+
+ end
+
+ def gen_file_index
+ gen_an_index(@files, 'Files',
+ RDoc::Page::FILE_INDEX,
+ "fr_file_index.html")
+ end
+
+ def gen_class_index
+ gen_an_index(@classes, 'Classes',
+ RDoc::Page::CLASS_INDEX,
+ "fr_class_index.html")
+ end
+
+ def gen_method_index
+ gen_an_index(HtmlMethod.all_methods, 'Methods',
+ RDoc::Page::METHOD_INDEX,
+ "fr_method_index.html")
+ end
+
+
+ def gen_an_index(collection, title, template, filename)
+ template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
+ res = []
+ collection.sort.each do |f|
+ if f.document_self
+ res << { "href" => f.path, "name" => f.index_name }
+ end
+ end
+
+ values = {
+ "entries" => res,
+ 'list_title' => CGI.escapeHTML(title),
+ 'index_url' => main_url,
+ 'charset' => @options.charset,
+ 'style_url' => style_url('', @options.css),
+ }
+
+ File.open(filename, "w") do |f|
+ template.write_html_on(f, values)
+ end
+ end
+
+ # The main index page is mostly a template frameset, but includes
+ # the initial page. If the <tt>--main</tt> option was given,
+ # we use this as our main page, otherwise we use the
+ # first file specified on the command line.
+
+ def gen_main_index
+ template = TemplatePage.new(RDoc::Page::INDEX)
+ File.open("index.html", "w") do |f|
+ values = {
+ "initial_page" => main_url,
+ 'title' => CGI.escapeHTML(@options.title),
+ 'charset' => @options.charset
+ }
+ if @options.inline_source
+ values['inline_source'] = true
+ end
+ template.write_html_on(f, values)
+ end
+ end
+
+ # return the url of the main page
+ def main_url
+ main_page = @options.main_page
+ ref = nil
+ if main_page
+ ref = AllReferences[main_page]
+ if ref
+ ref = ref.path
+ else
+ $stderr.puts "Could not find main page #{main_page}"
+ end
+ end
+
+ unless ref
+ for file in @files
+ if file.document_self
+ ref = file.path
+ break
+ end
+ end
+ end
+
+ unless ref
+ $stderr.puts "Couldn't find anything to document"
+ $stderr.puts "Perhaps you've used :stopdoc: in all classes"
+ exit(1)
+ end
+
+ ref
+ end
+
+
+ end
+
+
+ ######################################################################
+
+
+ class HTMLGeneratorInOne < HTMLGenerator
+
+ def initialize(*args)
+ super
+ end
+
+ ##
+ # Build the initial indices and output objects
+ # based on an array of TopLevel objects containing
+ # the extracted information.
+
+ def generate(info)
+ @toplevels = info
+ @files = []
+ @classes = []
+ @hyperlinks = {}
+
+ build_indices
+ generate_xml
+ end
+
+
+ ##
+ # Generate:
+ #
+ # * a list of HtmlFile objects for each TopLevel object.
+ # * a list of HtmlClass objects for each first level
+ # class or module in the TopLevel objects
+ # * a complete list of all hyperlinkable terms (file,
+ # class, module, and method names)
+
+ def build_indices
+
+ @toplevels.each do |toplevel|
+ @files << HtmlFile.new(toplevel, @options, FILE_DIR)
+ end
+
+ RDoc::TopLevel.all_classes_and_modules.each do |cls|
+ build_class_list(cls, @files[0], CLASS_DIR)
+ end
+ end
+
+ def build_class_list(from, html_file, class_dir)
+ @classes << HtmlClass.new(from, html_file, class_dir, @options)
+ from.each_classmodule do |mod|
+ build_class_list(mod, html_file, class_dir)
+ end
+ end
+
+ ##
+ # Generate all the HTML. For the one-file case, we generate
+ # all the information in to one big hash
+ #
+ def generate_xml
+ values = {
+ 'charset' => @options.charset,
+ 'files' => gen_into(@files),
+ 'classes' => gen_into(@classes),
+ 'title' => CGI.escapeHTML(@options.title),
+ }
+
+ # this method is defined in the template file
+ write_extra_pages if defined? write_extra_pages
+
+ template = TemplatePage.new(RDoc::Page::ONE_PAGE)
+
+ if @options.op_name
+ opfile = File.open(@options.op_name, "w")
+ else
+ opfile = $stdout
+ end
+ template.write_html_on(opfile, values)
+ end
+
+ def gen_into(list)
+ res = []
+ list.each do |item|
+ res << item.value_hash
+ end
+ res
+ end
+
+ def gen_file_index
+ gen_an_index(@files, 'Files')
+ end
+
+ def gen_class_index
+ gen_an_index(@classes, 'Classes')
+ end
+
+ def gen_method_index
+ gen_an_index(HtmlMethod.all_methods, 'Methods')
+ end
+
+
+ def gen_an_index(collection, title)
+ res = []
+ collection.sort.each do |f|
+ if f.document_self
+ res << { "href" => f.path, "name" => f.index_name }
+ end
+ end
+
+ return {
+ "entries" => res,
+ 'list_title' => title,
+ 'index_url' => main_url,
+ }
+ end
+
+ end
+end
diff --git a/lib/rdoc/generators/ri_generator.rb b/lib/rdoc/generators/ri_generator.rb
new file mode 100644
index 0000000000..8d94579347
--- /dev/null
+++ b/lib/rdoc/generators/ri_generator.rb
@@ -0,0 +1,268 @@
+# We're responsible for generating all the HTML files
+# from the object tree defined in code_objects.rb. We
+# generate:
+#
+# [files] an html file for each input file given. These
+# input files appear as objects of class
+# TopLevel
+#
+# [classes] an html file for each class or module encountered.
+# These classes are not grouped by file: if a file
+# contains four classes, we'll generate an html
+# file for the file itself, and four html files
+# for the individual classes.
+#
+# [indices] we generate three indices for files, classes,
+# and methods. These are displayed in a browser
+# like window with three index panes across the
+# top and the selected description below
+#
+# Method descriptions appear in whatever entity (file, class,
+# or module) that contains them.
+#
+# We generate files in a structure below a specified subdirectory,
+# normally +doc+.
+#
+# opdir
+# |
+# |___ files
+# | |__ per file summaries
+# |
+# |___ classes
+# |__ per class/module descriptions
+#
+# HTML is generated using the Template class.
+#
+
+require 'ftools'
+
+require 'rdoc/options'
+require 'rdoc/template'
+require 'rdoc/markup/simple_markup'
+require 'rdoc/markup/simple_markup/to_flow'
+require 'cgi'
+
+require 'rdoc/ri/ri_cache'
+require 'rdoc/ri/ri_reader'
+require 'rdoc/ri/ri_writer'
+require 'rdoc/ri/ri_descriptions'
+
+module Generators
+
+
+ class RIGenerator
+
+ # Generators may need to return specific subclasses depending
+ # on the options they are passed. Because of this
+ # we create them using a factory
+
+ def RIGenerator.for(options)
+ new(options)
+ end
+
+ class <<self
+ protected :new
+ end
+
+ # Set up a new HTML generator. Basically all we do here is load
+ # up the correct output temlate
+
+ def initialize(options) #:not-new:
+ @options = options
+ @ri_writer = RI::RiWriter.new(options.op_dir)
+ @markup = SM::SimpleMarkup.new
+ @to_flow = SM::ToFlow.new
+ end
+
+
+ ##
+ # Build the initial indices and output objects
+ # based on an array of TopLevel objects containing
+ # the extracted information.
+
+ def generate(toplevels)
+ RDoc::TopLevel.all_classes_and_modules.each do |cls|
+ process_class(cls)
+ end
+ end
+
+ def process_class(from_class)
+ generate_class_info(from_class)
+
+ # now recure into this classes constituent classess
+ from_class.each_classmodule do |mod|
+ process_class(mod)
+ end
+ end
+
+ def generate_class_info(cls)
+ if cls === RDoc::NormalModule
+ cls_desc = RI::ModuleDescription.new
+ else
+ cls_desc = RI::ClassDescription.new
+ cls_desc.superclass = cls.superclass
+ end
+ cls_desc.name = cls.name
+ cls_desc.full_name = cls.full_name
+ cls_desc.comment = markup(cls.comment)
+
+ cls_desc.attributes =cls.attributes.sort.map do |a|
+ RI::Attribute.new(a.name, a.rw, markup(a.comment))
+ end
+
+ cls_desc.constants = cls.constants.map do |c|
+ RI::Constant.new(c.name, c.value, markup(c.comment))
+ end
+
+ cls_desc.includes = cls.includes.map do |i|
+ RI::IncludedModule.new(i.name)
+ end
+
+ class_methods, instance_methods = method_list(cls)
+
+ cls_desc.class_methods = class_methods.map do |m|
+ RI::MethodSummary.new(m.name)
+ end
+ cls_desc.instance_methods = instance_methods.map do |m|
+ RI::MethodSummary.new(m.name)
+ end
+
+ update_or_replace(cls_desc)
+
+ class_methods.each do |m|
+ generate_method_info(cls_desc, m)
+ end
+
+ instance_methods.each do |m|
+ generate_method_info(cls_desc, m)
+ end
+ end
+
+
+ def generate_method_info(cls_desc, method)
+ meth_desc = RI::MethodDescription.new
+ meth_desc.name = method.name
+ meth_desc.full_name = cls_desc.full_name
+ if method.singleton
+ meth_desc.full_name += "::"
+ else
+ meth_desc.full_name += "#"
+ end
+ meth_desc.full_name << method.name
+
+ meth_desc.comment = markup(method.comment)
+ meth_desc.params = params_of(method)
+ meth_desc.visibility = method.visibility.to_s
+ meth_desc.is_singleton = method.singleton
+ meth_desc.block_params = method.block_params
+
+ meth_desc.aliases = method.aliases.map do |a|
+ RI::AliasName.new(a.name)
+ end
+
+ @ri_writer.add_method(cls_desc, meth_desc)
+ end
+
+ private
+
+ # return a list of class and instance methods that we'll be
+ # documenting
+
+ def method_list(cls)
+ list = cls.method_list
+ unless @options.show_all
+ list = list.find_all do |m|
+ m.visibility == :public || m.force_documentation
+ end
+ end
+
+ c = []
+ i = []
+ list.sort.each do |m|
+ if m.singleton
+ c << m
+ else
+ i << m
+ end
+ end
+ return c,i
+ end
+
+ def params_of(method)
+ if method.call_seq
+ method.call_seq
+ else
+ params = method.params || ""
+
+ p = params.gsub(/\s*\#.*/, '')
+ p = p.tr("\n", " ").squeeze(" ")
+ p = "(" + p + ")" unless p[0] == ?(
+
+ if (block = method.block_params)
+ block.gsub!(/\s*\#.*/, '')
+ block = block.tr("\n", " ").squeeze(" ")
+ if block[0] == ?(
+ block.sub!(/^\(/, '').sub!(/\)/, '')
+ end
+ p << " {|#{block.strip}| ...}"
+ end
+ p
+ end
+ end
+
+ def markup(comment)
+ return nil if !comment || comment.empty?
+
+ # Convert leading comment markers to spaces, but only
+ # if all non-blank lines have them
+
+ if comment =~ /^(?>\s*)[^\#]/
+ content = comment
+ else
+ content = comment.gsub(/^\s*(#+)/) { $1.tr('#',' ') }
+ end
+ @markup.convert(content, @to_flow)
+ end
+
+
+ # By default we replace existing classes with the
+ # same name. If the --merge option was given, we instead
+ # merge this definition into an existing class. We add
+ # our methods, aliases, etc to that class, but do not
+ # change the class's description.
+
+ def update_or_replace(cls_desc)
+ old_cls = nil
+
+ if @options.merge
+ rdr = RI::RiReader.new(RI::RiCache.new(@options.op_dir))
+
+ namespace = rdr.top_level_namespace
+ namespace = rdr.lookup_namespace_in(cls_desc.name, namespace)
+ if namespace.empty?
+ $stderr.puts "You asked me to merge this source into existing "
+ $stderr.puts "documentation. This file references a class or "
+ $stderr.puts "module called #{cls_desc.name} which I don't"
+ $stderr.puts "have existing documentation for."
+ $stderr.puts
+ $stderr.puts "Perhaps you need to generate its documentation first"
+ exit 1
+ else
+ old_cls = namespace[0]
+ end
+ end
+
+ if old_cls.nil?
+ # no merge: simply overwrite
+ @ri_writer.remove_class(cls_desc)
+ @ri_writer.add_class(cls_desc)
+ else
+ # existing class: merge in
+ old_desc = rdr.get_class(old_cls)
+
+ old_desc.merge_in(cls_desc)
+ @ri_writer.add_class(old_desc)
+ end
+ end
+ end
+end
diff --git a/lib/rdoc/generators/template/chm/chm.rb b/lib/rdoc/generators/template/chm/chm.rb
new file mode 100644
index 0000000000..4a89c26520
--- /dev/null
+++ b/lib/rdoc/generators/template/chm/chm.rb
@@ -0,0 +1,87 @@
+module RDoc
+module Page
+
+require "rdoc/generators/template/html/html"
+
+# This is a nasty little hack, but hhc doesn't support the <?xml
+# tag, so...
+
+BODY.sub!(/<\?xml.*\?>/, '')
+SRC_PAGE.sub!(/<\?xml.*\?>/, '')
+
+HPP_FILE = %{
+[OPTIONS]
+Auto Index = Yes
+Compatibility=1.1 or later
+Compiled file=%opname%.chm
+Contents file=contents.hhc
+Full-text search=Yes
+Index file=index.hhk
+Language=0x409 English(United States)
+Title=%title%
+
+[FILES]
+START:all_html_files
+%html_file_name%
+END:all_html_files
+}
+
+CONTENTS = %{
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<HTML>
+<HEAD>
+<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
+<!-- Sitemap 1.0 -->
+</HEAD><BODY>
+<OBJECT type="text/site properties">
+ <param name="Foreground" value="0x80">
+ <param name="Window Styles" value="0x800025">
+ <param name="ImageType" value="Folder">
+</OBJECT>
+<UL>
+START:contents
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="%c_name%">
+ <param name="Local" value="%ref%">
+ </OBJECT>
+IF:methods
+<ul>
+START:methods
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="%name%">
+ <param name="Local" value="%aref%">
+ </OBJECT>
+END:methods
+</ul>
+ENDIF:methods
+ </LI>
+END:contents
+</UL>
+</BODY></HTML>
+}
+
+
+CHM_INDEX = %{
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<HTML>
+<HEAD>
+<meta name="GENERATOR" content="Microsoft&reg; HTML Help Workshop 4.1">
+<!-- Sitemap 1.0 -->
+</HEAD><BODY>
+<OBJECT type="text/site properties">
+ <param name="Foreground" value="0x80">
+ <param name="Window Styles" value="0x800025">
+ <param name="ImageType" value="Folder">
+</OBJECT>
+<UL>
+START:index
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="%name%">
+ <param name="Local" value="%aref%">
+ </OBJECT>
+END:index
+</UL>
+</BODY></HTML>
+}
+end
+end
diff --git a/lib/rdoc/generators/template/html/hefss.rb b/lib/rdoc/generators/template/html/hefss.rb
new file mode 100644
index 0000000000..ff4f557b71
--- /dev/null
+++ b/lib/rdoc/generators/template/html/hefss.rb
@@ -0,0 +1,418 @@
+module RDoc
+module Page
+
+
+FONTS = "Verdana, Arial, Helvetica, sans-serif"
+
+STYLE = %{
+body,p { font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #000040; background: #BBBBBB;
+}
+
+td { font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #000040;
+}
+
+.attr-rw { font-size: small; color: #444488 }
+
+.title-row {color: #eeeeff;
+ background: #BBBBDD;
+}
+
+.big-title-font { color: white;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: large;
+ height: 50px}
+
+.small-title-font { color: purple;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: small; }
+
+.aqua { color: purple }
+
+.method-name, attr-name {
+ font-family: monospace; font-weight: bold;
+}
+
+.tablesubtitle {
+ width: 100%;
+ margin-top: 1ex;
+ margin-bottom: .5ex;
+ padding: 5px 0px 5px 20px;
+ font-size: large;
+ color: purple;
+ background: #BBBBCC;
+}
+
+.tablesubsubtitle {
+ width: 100%;
+ margin-top: 1ex;
+ margin-bottom: .5ex;
+ padding: 5px 0px 5px 20px;
+ font-size: medium;
+ color: white;
+ background: #BBBBCC;
+}
+
+.name-list {
+ font-family: monospace;
+ margin-left: 40px;
+ margin-bottom: 2ex;
+ line-height: 140%;
+}
+
+.description {
+ margin-left: 40px;
+ margin-bottom: 2ex;
+ line-height: 140%;
+}
+
+.methodtitle {
+ font-size: medium;
+ text_decoration: none;
+ padding: 3px 3px 3px 20px;
+ color: #0000AA;
+}
+
+.column-title {
+ font-size: medium;
+ font-weight: bold;
+ text_decoration: none;
+ padding: 3px 3px 3px 20px;
+ color: #3333CC;
+ }
+
+.variable-name {
+ font-family: monospace;
+ font-size: medium;
+ text_decoration: none;
+ padding: 3px 3px 3px 20px;
+ color: #0000AA;
+}
+
+.row-name {
+ font-size: medium;
+ font-weight: medium;
+ font-family: monospace;
+ text_decoration: none;
+ padding: 3px 3px 3px 20px;
+}
+
+.paramsig {
+ font-size: small;
+}
+
+.srcbut { float: right }
+
+}
+
+
+############################################################################
+
+
+BODY = %{
+<html><head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+ <link rel=StyleSheet href="%style_url%" type="text/css" media=screen>
+ <script type="text/javascript" language="JavaScript">
+ <!--
+ function popCode(url) {
+ parent.frames.source.location = url
+ }
+ //-->
+ </script>
+</head>
+<body bgcolor="#BBBBBB">
+
+!INCLUDE! <!-- banner header -->
+
+IF:diagram
+<table width="100%"><tr><td align="center">
+%diagram%
+</td></tr></table>
+ENDIF:diagram
+
+IF:description
+<div class="description">%description%</div>
+ENDIF:description
+
+IF:requires
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Required files</td></tr>
+</table><br>
+<div class="name-list">
+START:requires
+HREF:aref:name:
+END:requires
+ENDIF:requires
+</div>
+
+IF:methods
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Subroutines and Functions</td></tr>
+</table><br>
+<div class="name-list">
+START:methods
+HREF:aref:name:,
+END:methods
+</div>
+ENDIF:methods
+
+IF:attributes
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Arguments</td></tr>
+</table><br>
+<table cellspacing=5>
+START:attributes
+ <tr valign="top">
+IF:rw
+ <td align="center" class="attr-rw">&nbsp;[%rw%]&nbsp;</td>
+ENDIF:rw
+IFNOT:rw
+ <td></td>
+ENDIF:rw
+ <td class="attr-name">%name%</td>
+ <td>%a_desc%</td>
+ </tr>
+END:attributes
+</table>
+ENDIF:attributes
+
+IF:classlist
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Modules</td></tr>
+</table><br>
+%classlist%<br>
+ENDIF:classlist
+
+ !INCLUDE! <!-- method descriptions -->
+
+</body>
+</html>
+}
+
+###############################################################################
+
+FILE_PAGE = <<_FILE_PAGE_
+<table width="100%">
+ <tr class="title-row">
+ <td><table width="100%"><tr>
+ <td class="big-title-font" colspan=2><font size=-3><B>File</B><BR></font>%short_name%</td>
+ <td align="right"><table cellspacing=0 cellpadding=2>
+ <tr>
+ <td class="small-title-font">Path:</td>
+ <td class="small-title-font">%full_path%
+IF:cvsurl
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+ </td>
+ </tr>
+ <tr>
+ <td class="small-title-font">Modified:</td>
+ <td class="small-title-font">%dtm_modified%</td>
+ </tr>
+ </table>
+ </td></tr></table></td>
+ </tr>
+</table><br>
+_FILE_PAGE_
+
+###################################################################
+
+CLASS_PAGE = %{
+<table width="100%" border=0 cellspacing=0>
+ <tr class="title-row">
+ <td class="big-title-font">
+ <font size=-3><B>%classmod%</B><BR></font>%full_name%
+ </td>
+ <td align="right">
+ <table cellspacing=0 cellpadding=2>
+ <tr valign="top">
+ <td class="small-title-font">In:</td>
+ <td class="small-title-font">
+START:infiles
+HREF:full_path_url:full_path:
+IF:cvsurl
+&nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+END:infiles
+ </td>
+ </tr>
+IF:parent
+ <tr>
+ <td class="small-title-font">Parent:</td>
+ <td class="small-title-font">
+IF:par_url
+ <a href="%par_url%" class="cyan">
+ENDIF:par_url
+%parent%
+IF:par_url
+ </a>
+ENDIF:par_url
+ </td>
+ </tr>
+ENDIF:parent
+ </table>
+ </td>
+ </tr>
+</table><br>
+}
+
+###################################################################
+
+METHOD_LIST = %{
+IF:includes
+<div class="tablesubsubtitle">Uses</div><br>
+<div class="name-list">
+START:includes
+ <span class="method-name">HREF:aref:name:</span>
+END:includes
+</div>
+ENDIF:includes
+
+IF:method_list
+START:method_list
+IF:methods
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">%type% %category% methods</td></tr>
+</table>
+START:methods
+<table width="100%" cellspacing = 0 cellpadding=5 border=0>
+<tr><td class="methodtitle">
+<a name="%aref%">
+<b>%name%</b>%params%
+IF:codeurl
+<a href="%codeurl%" target="source" class="srclink">src</a>
+ENDIF:codeurl
+</a></td></tr>
+</table>
+IF:m_desc
+<div class="description">
+%m_desc%
+</div>
+ENDIF:m_desc
+END:methods
+ENDIF:methods
+END:method_list
+ENDIF:method_list
+}
+
+=begin
+=end
+
+########################## Source code ##########################
+
+SRC_PAGE = %{
+<html>
+<head><title>%title%</title>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<style>
+ .kw { color: #3333FF; font-weight: bold }
+ .cmt { color: green; font-style: italic }
+ .str { color: #662222; font-style: italic }
+ .re { color: #662222; }
+.ruby-comment { color: green; font-style: italic }
+.ruby-constant { color: #4433aa; font-weight: bold; }
+.ruby-identifier { color: #222222; }
+.ruby-ivar { color: #2233dd; }
+.ruby-keyword { color: #3333FF; font-weight: bold }
+.ruby-node { color: #777777; }
+.ruby-operator { color: #111111; }
+.ruby-regexp { color: #662222; }
+.ruby-value { color: #662222; font-style: italic }
+</style>
+</head>
+<body bgcolor="#BBBBBB">
+<pre>%code%</pre>
+</body>
+</html>
+}
+
+########################## Index ################################
+
+FR_INDEX_BODY = %{
+!INCLUDE!
+}
+
+FILE_INDEX = %{
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<style>
+<!--
+ body {
+background-color: #bbbbbb;
+ font-family: #{FONTS};
+ font-size: 11px;
+ font-style: normal;
+ line-height: 14px;
+ color: #000040;
+ }
+div.banner {
+ background: #bbbbcc;
+ color: white;
+ padding: 1;
+ margin: 0;
+ font-size: 90%;
+ font-weight: bold;
+ line-height: 1.1;
+ text-align: center;
+ width: 100%;
+}
+
+-->
+</style>
+<base target="docwin">
+</head>
+<body>
+<div class="banner">%list_title%</div>
+START:entries
+<a href="%href%">%name%</a><br>
+END:entries
+</body></html>
+}
+
+CLASS_INDEX = FILE_INDEX
+METHOD_INDEX = FILE_INDEX
+
+INDEX = %{
+<html>
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+</head>
+
+<frameset cols="20%,*">
+ <frameset rows="15%,35%,50%">
+ <frame src="fr_file_index.html" title="Files" name="Files">
+ <frame src="fr_class_index.html" name="Modules">
+ <frame src="fr_method_index.html" name="Subroutines and Functions">
+ </frameset>
+ <frameset rows="80%,20%">
+ <frame src="%initial_page%" name="docwin">
+ <frame src="blank.html" name="source">
+ </frameset>
+ <noframes>
+ <body bgcolor="#BBBBBB">
+ Click <a href="html/index.html">here</a> for a non-frames
+ version of this page.
+ </body>
+ </noframes>
+</frameset>
+
+</html>
+}
+
+# and a blank page to use as a target
+BLANK = %{
+<html><body bgcolor="#BBBBBB"></body></html>
+}
+
+def write_extra_pages
+ template = TemplatePage.new(BLANK)
+ File.open("blank.html", "w") { |f| template.write_html_on(f, {}) }
+end
+
+end
+end
diff --git a/lib/rdoc/generators/template/html/html.rb b/lib/rdoc/generators/template/html/html.rb
new file mode 100644
index 0000000000..e0a8880004
--- /dev/null
+++ b/lib/rdoc/generators/template/html/html.rb
@@ -0,0 +1,647 @@
+#
+# = CSS2 RDoc HTML template
+#
+# This is a template for RDoc that uses XHTML 1.0 Transitional and dictates a
+# bit more of the appearance of the output to cascading stylesheets than the
+# default. It was designed for clean inline code display, and uses DHTMl to
+# toggle the visbility of each method's source with each click on the '[source]'
+# link.
+#
+# == Authors
+#
+# * Michael Granger <ged@FaerieMUD.org>
+#
+# Copyright (c) 2002, 2003 The FaerieMUD Consortium. Some rights reserved.
+#
+# This work is licensed under the Creative Commons Attribution License. To view
+# a copy of this license, visit http://creativecommons.org/licenses/by/1.0/ or
+# send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
+# 94305, USA.
+#
+
+module RDoc
+ module Page
+
+ FONTS = "Verdana,Arial,Helvetica,sans-serif"
+
+STYLE = %{
+body {
+ margin: 0;
+ padding: 0;
+ background: white;
+}
+
+h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
+h1 { font-size: 120%; }
+h2,h3,h4 { margin-top: 1em; }
+
+a { background: #eef; color: #039; text-decoration: none; }
+a:hover { background: #039; color: #eef; }
+
+/* Override the base stylesheet's Anchor inside a table cell */
+td > a {
+ background: transparent;
+ color: #039;
+ text-decoration: none;
+}
+
+/* === Structural elements =================================== */
+
+div#index {
+ margin: 0;
+ padding: 0;
+ font-size: 0.9em;
+}
+
+div#index a {
+ margin-left: 0.7em;
+}
+
+div#classHeader {
+ width: auto;
+ background: #039;
+ color: white;
+ padding: 0.5em 1.5em 0.5em 1.5em;
+ margin: 0;
+ border-bottom: 3px solid #006;
+}
+
+div#classHeader a {
+ background: inherit;
+ color: white;
+}
+
+div#classHeader td {
+ background: inherit;
+ color: white;
+}
+
+div#fileHeader {
+ width: auto;
+ background: #039;
+ color: white;
+ padding: 0.5em 1.5em 0.5em 1.5em;
+ margin: 0;
+ border-bottom: 3px solid #006;
+}
+
+div#fileHeader a {
+ background: inherit;
+ color: white;
+}
+
+div#fileHeader td {
+ background: inherit;
+ color: white;
+}
+
+div#bodyContent {
+ padding: 0 1.5em 0 1.5em;
+}
+
+div#description {
+ padding: 0.5em 1.5em;
+ background: #efefef;
+ border: 1px dotted #999;
+}
+
+div#description h1,h2,h3,h4,h5,h6 {
+ color: black;
+ background: transparent;
+}
+
+div#validator-badges {
+ text-align: center;
+}
+div#validator-badges img { border: 0; }
+
+div#copyright {
+ color: #333;
+ background: #efefef;
+ font: 0.75em sans-serif;
+ margin-top: 5em;
+ margin-bottom: 0;
+ padding: 0.5em 2em;
+}
+
+
+/* === Classes =================================== */
+
+table.header-table {
+ color: white;
+ font-size: small;
+}
+
+.type-note {
+ font-size: small;
+ color: #DEDEDE;
+}
+
+.section-bar {
+ background: #eee;
+ color: #333;
+ padding: 3px;
+ border: 1px solid #999;
+}
+
+.top-aligned-row { vertical-align: vertical-align: top }
+
+/* --- Context section classes ----------------------- */
+
+.context-row { }
+.context-item-name { font-family: monospace; font-weight: bold; color: black; }
+.context-item-value { font-size: x-small; color: #448; }
+.context-item-desc { background: #efefef; }
+
+/* --- Method classes -------------------------- */
+.method-detail {
+ background: #EFEFEF;
+ padding: 0;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ border: 1px dotted #DDD;
+}
+.method-heading {
+ color: black;
+ background: #AAA;
+ border-bottom: 1px solid #666;
+ padding: 0.2em 0.5em 0 0.5em;
+}
+.method-signature { color: black; background: inherit; }
+.method-name { font-weight: bold; }
+.method-args { font-style: italic; }
+.method-description { padding: 0 0.5em 0 0.5em; }
+
+/* --- Source code sections -------------------- */
+
+a.source-toggle { font-size: 90%; }
+div.method-source-code {
+ background: #262626;
+ color: #ffdead;
+ margin: 1em;
+ padding: 0.5em;
+ border: 1px dashed #999;
+ overflow: hidden;
+}
+
+div.method-source-code pre { color: #ffdead; overflow: hidden; }
+
+/* --- Ruby keyword styles --------------------- */
+
+.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
+
+.ruby-constant { color: #7fffd4; background: transparent; }
+.ruby-keyword { color: #00ffff; background: transparent; }
+.ruby-ivar { color: #eedd82; background: transparent; }
+.ruby-operator { color: #00ffee; background: transparent; }
+.ruby-identifier { color: #ffdead; background: transparent; }
+.ruby-node { color: #ffa07a; background: transparent; }
+.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
+.ruby-regexp { color: #ffa07a; background: transparent; }
+.ruby-value { color: #7fffd4; background: transparent; }
+}
+
+
+#####################################################################
+### H E A D E R T E M P L A T E
+#####################################################################
+
+XHTML_PREAMBLE = %{<?xml version="1.0" encoding="%charset%"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+}
+
+HEADER = XHTML_PREAMBLE + %{
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\\"text/css\\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+}
+
+
+#####################################################################
+### C O N T E X T C O N T E N T T E M P L A T E
+#####################################################################
+
+CONTEXT_CONTENT = %{
+ <div id="contextContent">
+IF:diagram
+ <div id="diagram">
+ %diagram%
+ </div>
+ENDIF:diagram
+
+IF:description
+ <div id="description">
+ %description%
+ </div>
+ENDIF:description
+
+IF:requires
+ <div id="requires-list">
+ <h2 class="section-bar">Required files</h2>
+
+ <div class="name-list">
+START:requires
+ HREF:aref:name:&nbsp;&nbsp;
+END:requires
+ </div>
+ </div>
+ENDIF:requires
+
+IF:methods
+ <div id="method-list">
+ <h2 class="section-bar">Methods</h2>
+
+ <div class="name-list">
+START:methods
+ HREF:aref:name:&nbsp;&nbsp;
+END:methods
+ </div>
+ </div>
+ENDIF:methods
+
+IF:constants
+ <div id="constants-list">
+ <h2 class="section-bar">Constants</h2>
+
+ <div class="name-list">
+ <table summary="Constants">
+START:constants
+ <tr class="top-aligned-row context-row">
+ <td class="context-item-name">%name%</td>
+ <td>=</td>
+ <td class="context-item-value">%value%</td>
+ </tr>
+IF:desc
+ <tr class="top-aligned-row context-row">
+ <td>&nbsp;</td>
+ <td colspan="2" class="context-item-desc">%desc%</td>
+ </tr>
+ENDIF:desc
+END:constants
+ </table>
+ </div>
+ </div>
+ENDIF:constants
+
+IF:aliases
+ <div id="aliases-list">
+ <h2 class="section-bar">External Aliases</h2>
+
+ <div class="name-list">
+ <table summary="aliases">
+START:aliases
+ <tr class="top-aligned-row context-row">
+ <td class="context-item-name">%old_name%</td>
+ <td>-></td>
+ <td class="context-item-value">%new_name%</td>
+ </tr>
+IF:desc
+ <tr class="top-aligned-row context-row">
+ <td>&nbsp;</td>
+ <td colspan="2" class="context-item-desc">%desc%</td>
+ </tr>
+ENDIF:desc
+END:aliases
+ </table>
+ </div>
+ </div>
+ENDIF:aliases
+
+
+IF:attributes
+ <div id="attribute-list">
+ <h2 class="section-bar">Attributes</h2>
+
+ <div class="name-list">
+ <table>
+START:attributes
+ <tr class="top-aligned-row context-row">
+ <td class="context-item-name">%name%</td>
+ <td class="context-item-value">&nbsp;[%rw%]&nbsp;</td>
+ <td class="context-item-desc">%a_desc%</td>
+ </tr>
+END:attributes
+ </table>
+ </div>
+ </div>
+ENDIF:attributes
+
+IF:classlist
+ <div id="class-list">
+ <h2 class="section-bar">Classes and Modules</h2>
+
+ %classlist%
+ </div>
+ENDIF:classlist
+
+ </div>
+
+}
+
+
+#####################################################################
+### F O O T E R T E M P L A T E
+#####################################################################
+FOOTER = %{
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
+}
+
+
+#####################################################################
+### F I L E P A G E H E A D E R T E M P L A T E
+#####################################################################
+
+FILE_PAGE = %{
+ <div id="fileHeader">
+ <h1>%short_name%</h1>
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Path:</strong></td>
+ <td>%full_path%
+IF:cvsurl
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+ </td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>Last Update:</strong></td>
+ <td>%dtm_modified%</td>
+ </tr>
+ </table>
+ </div>
+}
+
+
+#####################################################################
+### C L A S S P A G E H E A D E R T E M P L A T E
+#####################################################################
+
+CLASS_PAGE = %{
+ <div id="classHeader">
+ <h1>%full_name% <sup class="type-note">(%classmod%)</sup></h1>
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>In:</strong></td>
+ <td>
+START:infiles
+IF:full_path_url
+ <a href="%full_path_url%">
+ENDIF:full_path_url
+ %full_path%
+IF:full_path_url
+ </a>
+ENDIF:full_path_url
+IF:cvsurl
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+ <br />
+END:infiles
+ </td>
+ </tr>
+
+IF:parent
+ <tr class="top-aligned-row">
+ <td><strong>Parent:</strong></td>
+ <td>
+IF:par_url
+ <a href="%par_url%">
+ENDIF:par_url
+ %parent%
+IF:par_url
+ </a>
+ENDIF:par_url
+ </td>
+ </tr>
+ENDIF:parent
+ </table>
+ </div>
+}
+
+
+#####################################################################
+### M E T H O D L I S T T E M P L A T E
+#####################################################################
+
+METHOD_LIST = %{
+
+ <!-- if includes -->
+IF:includes
+ <div id="includes">
+ <h2 class="section-bar">Included Modules</h2>
+
+ <div id="includes-list">
+START:includes
+ <span class="include-name">HREF:aref:name:</span>
+END:includes
+ </div>
+ </div>
+ENDIF:includes
+
+
+ <!-- if method_list -->
+IF:method_list
+ <div id="methods">
+START:method_list
+IF:methods
+ <h2 class="section-bar">%type% %category% methods</h2>
+
+START:methods
+ <div id="method-%aref%" class="method-detail">
+ <a name="%aref%"></a>
+
+ <div class="method-heading">
+IF:codeurl
+ <a href="%codeurl%" target="Code" class="method-signature"
+ onclick="popupCode('%codeurl%');return false;">
+ENDIF:codeurl
+IF:sourcecode
+ <a href="#%aref%" class="method-signature">
+ENDIF:sourcecode
+IF:callseq
+ <span class="method-name">%callseq%</span>
+ENDIF:callseq
+IFNOT:callseq
+ <span class="method-name">%name%</span><span class="method-args">%params%</span>
+ENDIF:callseq
+IF:codeurl
+ </a>
+ENDIF:codeurl
+IF:sourcecode
+ </a>
+ENDIF:sourcecode
+ </div>
+
+ <div class="method-description">
+IF:m_desc
+ %m_desc%
+ENDIF:m_desc
+IF:sourcecode
+ <p><a class="source-toggle" href="#"
+ onclick="toggleCode('%aref%-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="%aref%-source">
+<pre>
+%sourcecode%
+</pre>
+ </div>
+ENDIF:sourcecode
+ </div>
+ </div>
+
+END:methods
+ENDIF:methods
+END:method_list
+
+ </div>
+ENDIF:method_list
+}
+
+
+#####################################################################
+### B O D Y T E M P L A T E
+#####################################################################
+
+BODY = HEADER + %{
+
+!INCLUDE! <!-- banner header -->
+
+ <div id="bodyContent">
+
+} + CONTEXT_CONTENT + METHOD_LIST + %{
+
+ </div>
+
+} + FOOTER
+
+
+
+#####################################################################
+### S O U R C E C O D E T E M P L A T E
+#####################################################################
+
+SRC_PAGE = XHTML_PREAMBLE + %{
+<html>
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
+ <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" />
+</head>
+<body class="standalone-code">
+ <pre>%code%</pre>
+</body>
+</html>
+}
+
+
+#####################################################################
+### I N D E X F I L E T E M P L A T E S
+#####################################################################
+
+FR_INDEX_BODY = %{
+!INCLUDE!
+}
+
+FILE_INDEX = XHTML_PREAMBLE + %{
+<!--
+
+ %list_title%
+
+ -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>%list_title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
+ <link rel="stylesheet" href="%style_url%" type="text/css" />
+ <base target="docwin" />
+</head>
+<body>
+<div id="index">
+ <h1 class="section-bar">%list_title%</h1>
+ <div id="index-entries">
+START:entries
+ <a href="%href%">%name%</a><br />
+END:entries
+ </div>
+</div>
+</body>
+</html>
+}
+
+CLASS_INDEX = FILE_INDEX
+METHOD_INDEX = FILE_INDEX
+
+INDEX = %{<?xml version="1.0" encoding="%charset%"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
+
+<!--
+
+ %title%
+
+ -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
+</head>
+<frameset rows="20%, 80%">
+ <frameset cols="25%,35%,45%">
+ <frame src="fr_file_index.html" title="Files" name="Files" />
+ <frame src="fr_class_index.html" name="Classes" />
+ <frame src="fr_method_index.html" name="Methods" />
+ </frameset>
+ <frame src="%initial_page%" name="docwin" />
+</frameset>
+</html>
+}
+
+
+
+ end # module Page
+end # class RDoc
+
+require 'rdoc/generators/template/html/one_page_html'
diff --git a/lib/rdoc/generators/template/html/kilmer.rb b/lib/rdoc/generators/template/html/kilmer.rb
new file mode 100644
index 0000000000..0d47587f67
--- /dev/null
+++ b/lib/rdoc/generators/template/html/kilmer.rb
@@ -0,0 +1,421 @@
+module RDoc
+module Page
+
+
+FONTS = "Verdana, Arial, Helvetica, sans-serif"
+
+STYLE = %{
+body,td,p { font-family: %fonts%;
+ color: #000040;
+}
+
+.attr-rw { font-size: xx-small; color: #444488 }
+
+.title-row { background-color: #CCCCFF;
+ color: #000010;
+}
+
+.big-title-font {
+ color: black;
+ font-weight: bold;
+ font-family: %fonts%;
+ font-size: large;
+ height: 60px;
+ padding: 10px 3px 10px 3px;
+}
+
+.small-title-font { color: black;
+ font-family: %fonts%;
+ font-size:10; }
+
+.aqua { color: black }
+
+.method-name, .attr-name {
+ font-family: font-family: %fonts%;
+ font-weight: bold;
+ font-size: small;
+ margin-left: 20px;
+ color: #000033;
+}
+
+.tablesubtitle, .tablesubsubtitle {
+ width: 100%;
+ margin-top: 1ex;
+ margin-bottom: .5ex;
+ padding: 5px 0px 5px 3px;
+ font-size: large;
+ color: black;
+ background-color: #CCCCFF;
+ border: thin;
+}
+
+.name-list {
+ margin-left: 5px;
+ margin-bottom: 2ex;
+ line-height: 105%;
+}
+
+.description {
+ margin-left: 5px;
+ margin-bottom: 2ex;
+ line-height: 105%;
+ font-size: small;
+}
+
+.methodtitle {
+ font-size: small;
+ font-weight: bold;
+ text-decoration: none;
+ color: #000033;
+ background-color: white;
+}
+
+.srclink {
+ font-size: small;
+ font-weight: bold;
+ text-decoration: none;
+ color: #0000DD;
+ background-color: white;
+}
+
+.paramsig {
+ font-size: small;
+}
+
+.srcbut { float: right }
+
+}
+
+
+############################################################################
+
+
+BODY = %{
+<html><head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+ <link rel=StyleSheet href="%style_url%" type="text/css" media=screen>
+ <script type="text/javascript" language="JavaScript">
+ <!--
+ function popCode(url) {
+ parent.frames.source.location = url
+ }
+ //-->
+ </script>
+</head>
+<body bgcolor="white">
+
+!INCLUDE! <!-- banner header -->
+
+IF:diagram
+<table width="100%"><tr><td align="center">
+%diagram%
+</td></tr></table>
+ENDIF:diagram
+
+IF:description
+<div class="description">%description%</div>
+ENDIF:description
+
+IF:requires
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Required files</td></tr>
+</table><br>
+<div class="name-list">
+START:requires
+HREF:aref:name:
+END:requires
+ENDIF:requires
+</div>
+
+IF:methods
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Methods</td></tr>
+</table><br>
+<div class="name-list">
+START:methods
+HREF:aref:name:,
+END:methods
+</div>
+ENDIF:methods
+
+IF:attributes
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Attributes</td></tr>
+</table><br>
+<table cellspacing=5>
+START:attributes
+ <tr valign="top">
+IF:rw
+ <td align="center" class="attr-rw">&nbsp;[%rw%]&nbsp;</td>
+ENDIF:rw
+IFNOT:rw
+ <td></td>
+ENDIF:rw
+ <td class="attr-name">%name%</td>
+ <td>%a_desc%</td>
+ </tr>
+END:attributes
+</table>
+ENDIF:attributes
+
+IF:classlist
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">Classes and Modules</td></tr>
+</table><br>
+%classlist%<br>
+ENDIF:classlist
+
+ !INCLUDE! <!-- method descriptions -->
+
+</body>
+</html>
+}
+
+###############################################################################
+
+FILE_PAGE = <<_FILE_PAGE_
+<table width="100%">
+ <tr class="title-row">
+ <td><table width="100%"><tr>
+ <td class="big-title-font" colspan=2><font size=-3><B>File</B><BR></font>%short_name%</td>
+ <td align="right"><table cellspacing=0 cellpadding=2>
+ <tr>
+ <td class="small-title-font">Path:</td>
+ <td class="small-title-font">%full_path%
+IF:cvsurl
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+ </td>
+ </tr>
+ <tr>
+ <td class="small-title-font">Modified:</td>
+ <td class="small-title-font">%dtm_modified%</td>
+ </tr>
+ </table>
+ </td></tr></table></td>
+ </tr>
+</table><br>
+_FILE_PAGE_
+
+###################################################################
+
+CLASS_PAGE = %{
+<table width="100%" border=0 cellspacing=0>
+ <tr class="title-row">
+ <td class="big-title-font">
+ <font size=-3><B>%classmod%</B><BR></font>%full_name%
+ </td>
+ <td align="right">
+ <table cellspacing=0 cellpadding=2>
+ <tr valign="top">
+ <td class="small-title-font">In:</td>
+ <td class="small-title-font">
+START:infiles
+HREF:full_path_url:full_path:
+IF:cvsurl
+&nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+END:infiles
+ </td>
+ </tr>
+IF:parent
+ <tr>
+ <td class="small-title-font">Parent:</td>
+ <td class="small-title-font">
+IF:par_url
+ <a href="%par_url%" class="cyan">
+ENDIF:par_url
+%parent%
+IF:par_url
+ </a>
+ENDIF:par_url
+ </td>
+ </tr>
+ENDIF:parent
+ </table>
+ </td>
+ </tr>
+</table><br>
+}
+
+###################################################################
+
+METHOD_LIST = %{
+IF:includes
+<div class="tablesubsubtitle">Included modules</div><br>
+<div class="name-list">
+START:includes
+ <span class="method-name">HREF:aref:name:</span>
+END:includes
+</div>
+ENDIF:includes
+
+IF:method_list
+START:method_list
+IF:methods
+<table cellpadding=5 width="100%">
+<tr><td class="tablesubtitle">%type% %category% methods</td></tr>
+</table>
+START:methods
+<table width="100%" cellspacing = 0 cellpadding=5 border=0>
+<tr><td class="methodtitle">
+<a name="%aref%">
+IF:callseq
+<b>%callseq%</b>
+ENDIF:callseq
+IFNOT:callseq
+ <b>%name%</b>%params%
+ENDIF:callseq
+IF:codeurl
+<a href="%codeurl%" target="source" class="srclink">src</a>
+ENDIF:codeurl
+</a></td></tr>
+</table>
+IF:m_desc
+<div class="description">
+%m_desc%
+</div>
+ENDIF:m_desc
+IF:aka
+<div class="aka">
+This method is also aliased as
+START:aka
+<a href="%aref%">%name%</a>
+END:aka
+</div>
+ENDIF:aka
+IF:sourcecode
+<pre class="source">
+%sourcecode%
+</pre>
+ENDIF:sourcecode
+END:methods
+ENDIF:methods
+END:method_list
+ENDIF:method_list
+}
+
+=begin
+=end
+
+########################## Source code ##########################
+
+SRC_PAGE = %{
+<html>
+<head><title>%title%</title>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<style>
+.ruby-comment { color: green; font-style: italic }
+.ruby-constant { color: #4433aa; font-weight: bold; }
+.ruby-identifier { color: #222222; }
+.ruby-ivar { color: #2233dd; }
+.ruby-keyword { color: #3333FF; font-weight: bold }
+.ruby-node { color: #777777; }
+.ruby-operator { color: #111111; }
+.ruby-regexp { color: #662222; }
+.ruby-value { color: #662222; font-style: italic }
+ .kw { color: #3333FF; font-weight: bold }
+ .cmt { color: green; font-style: italic }
+ .str { color: #662222; font-style: italic }
+ .re { color: #662222; }
+</style>
+</head>
+<body bgcolor="white">
+<pre>%code%</pre>
+</body>
+</html>
+}
+
+########################## Index ################################
+
+FR_INDEX_BODY = %{
+!INCLUDE!
+}
+
+FILE_INDEX = %{
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<style>
+<!--
+ body {
+background-color: #ddddff;
+ font-family: #{FONTS};
+ font-size: 11px;
+ font-style: normal;
+ line-height: 14px;
+ color: #000040;
+ }
+div.banner {
+ background: #0000aa;
+ color: white;
+ padding: 1;
+ margin: 0;
+ font-size: 90%;
+ font-weight: bold;
+ line-height: 1.1;
+ text-align: center;
+ width: 100%;
+}
+
+-->
+</style>
+<base target="docwin">
+</head>
+<body>
+<div class="banner">%list_title%</div>
+START:entries
+<a href="%href%">%name%</a><br>
+END:entries
+</body></html>
+}
+
+CLASS_INDEX = FILE_INDEX
+METHOD_INDEX = FILE_INDEX
+
+INDEX = %{
+<html>
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+</head>
+
+<frameset cols="20%,*">
+ <frameset rows="15%,35%,50%">
+ <frame src="fr_file_index.html" title="Files" name="Files">
+ <frame src="fr_class_index.html" name="Classes">
+ <frame src="fr_method_index.html" name="Methods">
+ </frameset>
+IF:inline_source
+ <frame src="%initial_page%" name="docwin">
+ENDIF:inline_source
+IFNOT:inline_source
+ <frameset rows="80%,20%">
+ <frame src="%initial_page%" name="docwin">
+ <frame src="blank.html" name="source">
+ </frameset>
+ENDIF:inline_source
+ <noframes>
+ <body bgcolor="white">
+ Click <a href="html/index.html">here</a> for a non-frames
+ version of this page.
+ </body>
+ </noframes>
+</frameset>
+
+</html>
+}
+
+# and a blank page to use as a target
+BLANK = %{
+<html><body bgcolor="white"></body></html>
+}
+
+def write_extra_pages
+ template = TemplatePage.new(BLANK)
+ File.open("blank.html", "w") { |f| template.write_html_on(f, {}) }
+end
+
+end
+end
diff --git a/lib/rdoc/generators/template/html/old_html.rb b/lib/rdoc/generators/template/html/old_html.rb
new file mode 100644
index 0000000000..9e0073c37e
--- /dev/null
+++ b/lib/rdoc/generators/template/html/old_html.rb
@@ -0,0 +1,728 @@
+module RDoc
+
+# This is how you define the HTML that RDoc generates. Simply create
+# a file in rdoc/generators/html_templates that creates the
+# module RDoc::Page and populate it as described below. Then invoke
+# rdoc using the --template <name of your file> option, and
+# your template will be used.
+#
+# The constants defining pages use a simple templating system:
+#
+# * The templating system is passed a hash. Keys in the hash correspond
+# to tags on this page. The tag %abc% is looked up in the hash,
+# and is replaced by the corresponding hash value.
+#
+# * Some tags are optional. You can detect this using IF/ENDIF
+#
+# IF: title
+# The value of title is %title%
+# ENDIF: title
+#
+# * Some entries in the hash have values that are arrays, where each
+# entry in the array is itself a hash. These are used to generate
+# lists using the START: construct. For example, given a hash
+# containing
+#
+# { 'people' => [ { 'name' => 'Fred', 'age' => '12' },
+# { 'name' => 'Mary', 'age' => '21' } ]
+#
+# You could generate a simple table using
+#
+# <table>
+# START:people
+# <tr><td>%name%<td>%age%</tr>
+# END:people
+# </table>
+#
+# These lists can be nested to an arbitrary depth
+#
+# * the construct HREF:url:name: generates <a href="%url%">%name%</a>
+# if +url+ is defined in the hash, or %name% otherwise.
+#
+#
+# Your file must contain the following constants
+#
+# [*FONTS*] a list of fonts to be used
+# [*STYLE*] a CSS section (without the <style> or comments). This is
+# used to generate a style.css file
+#
+# [*BODY*]
+# The main body of all non-index RDoc pages. BODY will contain
+# two !INCLUDE!s. The first is used to include a document-type
+# specific header (FILE_PAGE or CLASS_PAGE). The second include
+# is for the method list (METHOD_LIST). THe body is passed:
+#
+# %title%::
+# the page's title
+#
+# %style_url%::
+# the url of a style sheet for this page
+#
+# %diagram%::
+# the optional URL of a diagram for this page
+#
+# %description%::
+# a (potentially multi-paragraph) string containing the
+# description for th file/class/module.
+#
+# %requires%::
+# an optional list of %aref%/%name% pairs, one for each module
+# required by this file.
+#
+# %methods%::
+# an optional list of %aref%/%name%, one for each method
+# documented on this page. This is intended to be an index.
+#
+# %attributes%::
+# An optional list. For each attribute it contains:
+# %name%:: the attribute name
+# %rw%:: r/o, w/o, or r/w
+# %a_desc%:: description of the attribute
+#
+# %classlist%::
+# An optional string containing an already-formatted list of
+# classes and modules documented in this file
+#
+# For FILE_PAGE entries, the body will be passed
+#
+# %short_name%::
+# The name of the file
+#
+# %full_path%::
+# The full path to the file
+#
+# %dtm_modified%::
+# The date/time the file was last changed
+#
+# For class and module pages, the body will be passed
+#
+# %classmod%::
+# The name of the class or module
+#
+# %files%::
+# A list. For each file this class is defined in, it contains:
+# %full_path_url%:: an (optional) URL of the RDoc page
+# for this file
+# %full_path%:: the name of the file
+#
+# %par_url%::
+# The (optional) URL of the RDoc page documenting this class's
+# parent class
+#
+# %parent%::
+# The name of this class's parent.
+#
+# For both files and classes, the body is passed the following information
+# on includes and methods:
+#
+# %includes%::
+# Optional list of included modules. For each, it receives
+# %aref%:: optional URL to RDoc page for the module
+# %name%:: the name of the module
+#
+# %method_list%::
+# Optional list of methods of a particular class and category.
+#
+# Each method list entry contains:
+#
+# %type%:: public/private/protected
+# %category%:: instance/class
+# %methods%:: a list of method descriptions
+#
+# Each method description contains:
+#
+# %aref%:: a target aref, used when referencing this method
+# description. You should code this as <a name="%aref%">
+# %codeurl%:: the optional URL to the page containing this method's
+# source code.
+# %name%:: the method's name
+# %params%:: the method's parameters
+# %callseq%:: a full calling sequence
+# %m_desc%:: the (potentially multi-paragraph) description of
+# this method.
+#
+# [*CLASS_PAGE*]
+# Header for pages documenting classes and modules. See
+# BODY above for the available parameters.
+#
+# [*FILE_PAGE*]
+# Header for pages documenting files. See
+# BODY above for the available parameters.
+#
+# [*METHOD_LIST*]
+# Controls the display of the listing of methods. See BODY for
+# parameters.
+#
+# [*INDEX*]
+# The top-level index page. For a browser-like environment
+# define a frame set that includes the file, class, and
+# method indices. Passed
+# %title%:: title of page
+# %initial_page% :: url of initial page to display
+#
+# [*CLASS_INDEX*]
+# Individual files for the three indexes. Passed:
+# %index_url%:: URL of main index page
+# %entries%:: List of
+# %name%:: name of an index entry
+# %href%:: url of corresponding page
+# [*METHOD_INDEX*]
+# Same as CLASS_INDEX for methods
+#
+# [*FILE_INDEX*]
+# Same as CLASS_INDEX for methods
+#
+# [*FR_INDEX_BODY*]
+# A wrapper around CLASS_INDEX, METHOD_INDEX, and FILE_INDEX.
+# If those index strings contain the complete HTML for the
+# output, then FR_INDEX_BODY can simply be !INCLUDE!
+#
+# [*SRC_PAGE*]
+# Page used to display source code. Passed %title% and %code%,
+# the latter being a multi-line string of code.
+
+module Page
+
+FONTS = "Verdana, Arial, Helvetica, sans-serif"
+
+STYLE = %{
+body,td,p { font-family: %fonts%;
+ color: #000040;
+}
+
+.attr-rw { font-size: x-small; color: #444488 }
+
+.title-row { background: #0000aa;
+ color: #eeeeff;
+}
+
+.big-title-font { color: white;
+ font-family: %fonts%;
+ font-size: large;
+ height: 50px}
+
+.small-title-font { color: aqua;
+ font-family: %fonts%;
+ font-size: xx-small; }
+
+.aqua { color: aqua }
+
+.method-name, attr-name {
+ font-family: monospace; font-weight: bold;
+}
+
+.tablesubtitle, .tablesubsubtitle {
+ width: 100%;
+ margin-top: 1ex;
+ margin-bottom: .5ex;
+ padding: 5px 0px 5px 20px;
+ font-size: large;
+ color: aqua;
+ background: #3333cc;
+}
+
+.name-list {
+ font-family: monospace;
+ margin-left: 40px;
+ margin-bottom: 2ex;
+ line-height: 140%;
+}
+
+.description {
+ margin-left: 40px;
+ margin-top: -2ex;
+ margin-bottom: 2ex;
+}
+
+.description p {
+ line-height: 140%;
+}
+
+.aka {
+ margin-left: 40px;
+ margin-bottom: 2ex;
+ line-height: 100%;
+ font-size: small;
+ color: #808080;
+}
+
+.methodtitle {
+ font-size: medium;
+ text-decoration: none;
+ color: #0000AA;
+ background: white;
+}
+
+.paramsig {
+ font-size: small;
+}
+
+.srcbut { float: right }
+
+pre { font-size: 1.2em; }
+tt { font-size: 1.2em; }
+
+pre.source {
+ border-style: groove;
+ background-color: #ddddff;
+ margin-left: 40px;
+ padding: 1em 0em 1em 2em;
+}
+
+.classlist {
+ margin-left: 40px;
+ margin-bottom: 2ex;
+ line-height: 140%;
+}
+
+li {
+ display: list-item;
+ margin-top: .6em;
+}
+
+.ruby-comment { color: green; font-style: italic }
+.ruby-constant { color: #4433aa; font-weight: bold; }
+.ruby-identifier { color: #222222; }
+.ruby-ivar { color: #2233dd; }
+.ruby-keyword { color: #3333FF; font-weight: bold }
+.ruby-node { color: #777777; }
+.ruby-operator { color: #111111; }
+.ruby-regexp { color: #662222; }
+.ruby-value { color: #662222; font-style: italic }
+
+}
+
+
+############################################################################
+
+
+HEADER = %{
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
+ <link rel=StyleSheet href="%style_url%" type="text/css" media="screen" />
+ <script type="text/javascript" language="JavaScript">
+ <!--
+ function popCode(url) {
+ window.open(url, "Code",
+ "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+ //-->
+ </script>
+</head>
+}
+
+
+###################################################################
+
+METHOD_LIST = %{
+IF:includes
+<table summary="Included modules" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">Included modules</td></tr>
+</table>
+<div class="name-list">
+START:includes
+ <span class="method-name">HREF:aref:name:</span>
+END:includes
+</div>
+ENDIF:includes
+
+IF:method_list
+START:method_list
+IF:methods
+<table summary="Method list" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">%type% %category% methods</td></tr>
+</table>
+START:methods
+<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0">
+<tr><td class="methodtitle">
+<a name="%aref%"></a>
+IF:codeurl
+<a href="%codeurl%" target="Code" class="methodtitle"
+ onClick="popCode('%codeurl%');return false;">
+ENDIF:codeurl
+IF:callseq
+<b>%callseq%</b>
+ENDIF:callseq
+IFNOT:callseq
+<b>%name%</b>%params%
+ENDIF:callseq
+IF:codeurl
+</a>
+ENDIF:codeurl
+</td></tr>
+</table>
+IF:m_desc
+<div class="description">
+%m_desc%
+</div>
+ENDIF:m_desc
+IF:aka
+<div class="aka">
+This method is also aliased as
+START:aka
+<a href="%aref%">%name%</a>
+END:aka
+</div>
+ENDIF:aka
+IF:sourcecode
+<pre class="source">
+%sourcecode%
+</pre>
+ENDIF:sourcecode
+END:methods
+ENDIF:methods
+END:method_list
+ENDIF:method_list
+}
+
+###################################################################
+
+CONTEXT_CONTENT = %{
+IF:diagram
+<table summary="Diagram of classes and modules" width="100%">
+<tr><td align="center">
+%diagram%
+</td></tr></table>
+ENDIF:diagram
+
+
+IF:description
+<div class="description">%description%</div>
+ENDIF:description
+
+IF:requires
+<table summary="Requires" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">Required files</td></tr>
+</table>
+<div class="name-list">
+START:requires
+HREF:aref:name:&nbsp; &nbsp;
+END:requires
+</div>
+ENDIF:requires
+
+IF:methods
+<table summary="Methods" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">Methods</td></tr>
+</table>
+<div class="name-list">
+START:methods
+HREF:aref:name:&nbsp; &nbsp;
+END:methods
+</div>
+ENDIF:methods
+
+IF:constants
+<table summary="Constants" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">Constants</td></tr>
+</table>
+<table cellpadding="5">
+START:constants
+<tr valign="top"><td>%name%</td><td>=</td><td>%value%</td></tr>
+IF:desc
+<tr><td></td><td></td><td>%desc%</td></tr>
+ENDIF:desc
+END:constants
+</table>
+ENDIF:constants
+
+IF:aliases
+<table summary="Aliases" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">External Aliases</td></tr>
+</table>
+<div class="name-list">
+START:aliases
+%old_name% -> %new_name%<br />
+END:aliases
+</div>
+ENDIF:aliases
+
+IF:attributes
+<table summary="Attributes" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">Attributes</td></tr>
+</table>
+<table summary="Attribute details" cellspacing="5">
+START:attributes
+ <tr valign="top">
+ <td class="attr-name">%name%</td>
+IF:rw
+ <td align="center" class="attr-rw">&nbsp;[%rw%]&nbsp;</td>
+ENDIF:rw
+IFNOT:rw
+ <td></td>
+ENDIF:rw
+ <td>%a_desc%</td>
+ </tr>
+END:attributes
+</table>
+ENDIF:attributes
+
+IF:classlist
+<table summary="List of classes" cellpadding="5" width="100%">
+<tr><td class="tablesubtitle">Classes and Modules</td></tr>
+</table>
+<div class="classlist">
+%classlist%
+</div>
+ENDIF:classlist
+}
+
+###############################################################################
+
+BODY = HEADER + %{
+<body bgcolor="white">
+!INCLUDE! <!-- banner header -->
+} +
+CONTEXT_CONTENT + METHOD_LIST +
+%{
+</body>
+</html>
+}
+
+
+###############################################################################
+
+FILE_PAGE = <<_FILE_PAGE_
+<table summary="Information on file" width="100%">
+ <tr class="title-row">
+ <td><table summary="layout" width="100%"><tr>
+ <td class="big-title-font" colspan="2">%short_name%</td>
+ <td align="right"><table summary="layout" cellspacing="0" cellpadding="2">
+ <tr>
+ <td class="small-title-font">Path:</td>
+ <td class="small-title-font">%full_path%
+IF:cvsurl
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+ </td>
+ </tr>
+ <tr>
+ <td class="small-title-font">Modified:</td>
+ <td class="small-title-font">%dtm_modified%</td>
+ </tr>
+ </table>
+ </td></tr></table></td>
+ </tr>
+</table>
+_FILE_PAGE_
+
+###################################################################
+
+CLASS_PAGE = %{
+<table summary="Information on class" width="100%" border="0" cellspacing="0">
+ <tr class="title-row">
+ <td class="big-title-font">
+ <sup><font color="aqua">%classmod%</font></sup> %full_name%
+ </td>
+ <td align="right">
+ <table summary="layout" cellspacing="0" cellpadding="2">
+ <tr valign="top">
+ <td class="small-title-font">In:</td>
+ <td class="small-title-font">
+START:infiles
+IF:full_path_url
+ <a href="%full_path_url%" class="aqua">
+ENDIF:full_path_url
+%full_path%
+IF:full_path_url
+ </a>
+ENDIF:full_path_url
+IF:cvsurl
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
+ENDIF:cvsurl
+<br />
+END:infiles
+ </td>
+ </tr>
+IF:parent
+ <tr>
+ <td class="small-title-font">Parent:</td>
+ <td class="small-title-font">
+IF:par_url
+ <a href="%par_url%" class="aqua">
+ENDIF:par_url
+%parent%
+IF:par_url
+ </a>
+ENDIF:par_url
+ </td>
+ </tr>
+ENDIF:parent
+ </table>
+ </td>
+ </tr>
+</table>
+}
+
+=begin
+=end
+
+########################## Source code ##########################
+
+SRC_PAGE = %{
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<title>%title%</title>
+<link rel=StyleSheet href="%style_url%" type="text/css" media="screen" />
+</head>
+<body bgcolor="white">
+<pre>%code%</pre>
+</body>
+</html>
+}
+
+########################## Index ################################
+
+FR_INDEX_BODY = %{
+!INCLUDE!
+}
+
+FILE_INDEX = %{
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<title>%list_title%</title>
+<style type="text/css">
+<!--
+ body {
+background-color: #ddddff;
+ font-family: #{FONTS};
+ font-size: 11px;
+ font-style: normal;
+ line-height: 14px;
+ color: #000040;
+ }
+div.banner {
+ background: #0000aa;
+ color: white;
+ padding: 1;
+ margin: 0;
+ font-size: 90%;
+ font-weight: bold;
+ line-height: 1.1;
+ text-align: center;
+ width: 100%;
+}
+
+A.xx { color: white; font-weight: bold; }
+-->
+</style>
+<base target="docwin">
+</head>
+<body>
+<div class="banner"><a href="%index_url%" class="xx">%list_title%</a></div>
+START:entries
+<a href="%href%">%name%</a><br />
+END:entries
+</body></html>
+}
+
+CLASS_INDEX = FILE_INDEX
+METHOD_INDEX = FILE_INDEX
+
+INDEX = %{
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=%charset%">
+<title>%title%</title></head>
+
+<frameset rows="20%, 80%">
+ <frameset cols="25%,35%,45%">
+ <frame src="fr_file_index.html" title="Files" name="Files">
+ <frame src="fr_class_index.html" name="Classes">
+ <frame src="fr_method_index.html" name="Methods">
+ </frameset>
+ <frame src="%initial_page%" name="docwin">
+ <noframes>
+ <body bgcolor="white">
+ Sorry, RDoc currently only generates HTML using frames.
+ </body>
+ </noframes>
+</frameset>
+
+</html>
+}
+
+######################################################################
+#
+# The following is used for the -1 option
+#
+
+CONTENTS_XML = %{
+IF:description
+%description%
+ENDIF:description
+
+IF:requires
+<h4>Requires:</h4>
+<ul>
+START:requires
+IF:aref
+<li><a href="%aref%">%name%</a></li>
+ENDIF:aref
+IFNOT:aref
+<li>%name%</li>
+ENDIF:aref
+END:requires
+</ul>
+ENDIF:requires
+
+IF:attributes
+<h4>Attributes</h4>
+<table>
+START:attributes
+<tr><td>%name%</td><td>%rw%</td><td>%a_desc%</td></tr>
+END:attributes
+</table>
+ENDIF:attributes
+
+IF:includes
+<h4>Includes</h4>
+<ul>
+START:includes
+IF:aref
+<li><a href="%aref%">%name%</a></li>
+ENDIF:aref
+IFNOT:aref
+<li>%name%</li>
+ENDIF:aref
+END:includes
+</ul>
+ENDIF:includes
+
+IF:method_list
+<h3>Methods</h3>
+START:method_list
+IF:methods
+START:methods
+<h4>%type% %category% method: <a name="%aref%">%name%%params%</a></h4>
+
+IF:m_desc
+%m_desc%
+ENDIF:m_desc
+
+IF:sourcecode
+<blockquote><pre>
+%sourcecode%
+</pre></blockquote>
+ENDIF:sourcecode
+END:methods
+ENDIF:methods
+END:method_list
+ENDIF:method_list
+}
+
+
+end
+end
+
+require 'rdoc/generators/template/html/one_page_html'
diff --git a/lib/rdoc/generators/template/html/one_page_html.rb b/lib/rdoc/generators/template/html/one_page_html.rb
new file mode 100644
index 0000000000..19441f4725
--- /dev/null
+++ b/lib/rdoc/generators/template/html/one_page_html.rb
@@ -0,0 +1,122 @@
+module RDoc
+module Page
+######################################################################
+#
+# The following is used for the -1 option
+#
+
+CONTENTS_XML = %{
+IF:description
+%description%
+ENDIF:description
+
+IF:requires
+<h4>Requires:</h4>
+<ul>
+START:requires
+IF:aref
+<li><a href="%aref%">%name%</a></li>
+ENDIF:aref
+IFNOT:aref
+<li>%name%</li>
+ENDIF:aref
+END:requires
+</ul>
+ENDIF:requires
+
+IF:attributes
+<h4>Attributes</h4>
+<table>
+START:attributes
+<tr><td>%name%</td><td>%rw%</td><td>%a_desc%</td></tr>
+END:attributes
+</table>
+ENDIF:attributes
+
+IF:includes
+<h4>Includes</h4>
+<ul>
+START:includes
+IF:aref
+<li><a href="%aref%">%name%</a></li>
+ENDIF:aref
+IFNOT:aref
+<li>%name%</li>
+ENDIF:aref
+END:includes
+</ul>
+ENDIF:includes
+
+IF:method_list
+<h3>Methods</h3>
+START:method_list
+IF:methods
+START:methods
+<h4>%type% %category% method:
+IF:callseq
+<a name="%aref%">%callseq%</a>
+ENDIF:callseq
+IFNOT:callseq
+<a name="%aref%">%name%%params%</a></h4>
+ENDIF:callseq
+
+IF:m_desc
+%m_desc%
+ENDIF:m_desc
+
+IF:sourcecode
+<blockquote><pre>
+%sourcecode%
+</pre></blockquote>
+ENDIF:sourcecode
+END:methods
+ENDIF:methods
+END:method_list
+ENDIF:method_list
+}
+
+########################################################################
+
+ONE_PAGE = %{
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>%title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
+</head>
+<body>
+START:files
+<h2>File: %short_name%</h2>
+<table>
+ <tr><td>Path:</td><td>%full_path%</td></tr>
+ <tr><td>Modified:</td><td>%dtm_modified%</td></tr>
+</table>
+} + CONTENTS_XML + %{
+END:files
+
+IF:classes
+<h2>Classes</h2>
+START:classes
+IF:parent
+<h3>%classmod% %full_name% &lt; HREF:par_url:parent:</h3>
+ENDIF:parent
+IFNOT:parent
+<h3>%classmod% %full_name%</h3>
+ENDIF:parent
+
+IF:infiles
+(in files
+START:infiles
+HREF:full_path_url:full_path:
+END:infiles
+)
+ENDIF:infiles
+} + CONTENTS_XML + %{
+END:classes
+ENDIF:classes
+</body>
+</html>
+}
+
+end
+end
diff --git a/lib/rdoc/generators/template/xml/rdf.rb b/lib/rdoc/generators/template/xml/rdf.rb
new file mode 100644
index 0000000000..1545d81a2f
--- /dev/null
+++ b/lib/rdoc/generators/template/xml/rdf.rb
@@ -0,0 +1,112 @@
+module RDoc
+module Page
+
+
+
+CONTENTS_RDF = %{
+IF:description
+ <description rd:parseType="Literal">
+%description%
+ </description>
+ENDIF:description
+
+IF:requires
+START:requires
+ <rd:required-file rd:name="%name%" />
+END:requires
+ENDIF:requires
+
+IF:attributes
+START:attributes
+ <contents>
+ <Attribute rd:name="%name%">
+IF:rw
+ <attribute-rw>%rw%</attribute-rw>
+ENDIF:rw
+ <description rdf:parseType="Literal">%a_desc%</description>
+ </Attribute>
+ </contents>
+END:attributes
+ENDIF:attributes
+
+IF:includes
+ <IncludedModuleList>
+START:includes
+ <included-module rd:name="%name%" />
+END:includes
+ </IncludedModuleList>
+ENDIF:includes
+
+IF:method_list
+START:method_list
+IF:methods
+START:methods
+ <contents>
+ <Method rd:name="%name%" rd:visibility="%type%"
+ rd:category="%category%" rd:id="%aref%">
+ <parameters>%params%</parameters>
+IF:m_desc
+ <description rdf:parseType="Literal">
+%m_desc%
+ </description>
+ENDIF:m_desc
+IF:sourcecode
+ <source-code-listing rdf:parseType="Literal">
+%sourcecode%
+ </source-code-listing>
+ENDIF:sourcecode
+ </Method>
+ </contents>
+END:methods
+ENDIF:methods
+END:method_list
+ENDIF:method_list
+ <!-- end method list -->
+}
+
+########################################################################
+
+ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns="http://pragprog.com/rdoc/rdoc.rdf#"
+ xmlns:rd="http://pragprog.com/rdoc/rdoc.rdf#">
+
+<!-- RDoc -->
+START:files
+ <rd:File rd:name="%short_name%" rd:id="%href%">
+ <path>%full_path%</path>
+ <dtm-modified>%dtm_modified%</dtm-modified>
+} + CONTENTS_RDF + %{
+ </rd:File>
+END:files
+START:classes
+ <%classmod% rd:name="%full_name%" rd:id="%full_name%">
+ <classmod-info>
+IF:infiles
+ <InFiles>
+START:infiles
+ <infile>
+ <File rd:name="%full_path%"
+IF:full_path_url
+ rdf:about="%full_path_url%"
+ENDIF:full_path_url
+ />
+ </infile>
+END:infiles
+ </InFiles>
+ENDIF:infiles
+IF:parent
+ <superclass>HREF:par_url:parent:</superclass>
+ENDIF:parent
+ </classmod-info>
+} + CONTENTS_RDF + %{
+ </%classmod%>
+END:classes
+<!-- /RDoc -->
+</rdf:RDF>
+}
+
+
+end
+end
+
diff --git a/lib/rdoc/generators/template/xml/xml.rb b/lib/rdoc/generators/template/xml/xml.rb
new file mode 100644
index 0000000000..4a0c8c9ac4
--- /dev/null
+++ b/lib/rdoc/generators/template/xml/xml.rb
@@ -0,0 +1,112 @@
+module RDoc
+module Page
+
+
+
+CONTENTS_XML = %{
+IF:description
+ <description>
+%description%
+ </description>
+ENDIF:description
+ <contents>
+IF:requires
+ <required-file-list>
+START:requires
+ <required-file name="%name%"
+IF:aref
+ href="%aref%"
+ENDIF:aref
+ />
+END:requires
+ </required-file-list>
+ENDIF:requires
+IF:attributes
+ <attribute-list>
+START:attributes
+ <attribute name="%name%">
+IF:rw
+ <attribute-rw>%rw%</attribute-rw>
+ENDIF:rw
+ <description>%a_desc%</description>
+ </attribute>
+END:attributes
+ </attribute-list>
+ENDIF:attributes
+IF:includes
+ <included-module-list>
+START:includes
+ <included-module name="%name%"
+IF:aref
+ href="%aref%"
+ENDIF:aref
+ />
+END:includes
+ </included-module-list>
+ENDIF:includes
+IF:method_list
+ <method-list>
+START:method_list
+IF:methods
+START:methods
+ <method name="%name%" type="%type%" category="%category%" id="%aref%">
+ <parameters>%params%</parameters>
+IF:m_desc
+ <description>
+%m_desc%
+ </description>
+ENDIF:m_desc
+IF:sourcecode
+ <source-code-listing>
+%sourcecode%
+ </source-code-listing>
+ENDIF:sourcecode
+ </method>
+END:methods
+ENDIF:methods
+END:method_list
+ </method-list>
+ENDIF:method_list
+ </contents>
+}
+
+########################################################################
+
+ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?>
+<rdoc>
+<file-list>
+START:files
+ <file name="%short_name%" id="%href%">
+ <file-info>
+ <path>%full_path%</path>
+ <dtm-modified>%dtm_modified%</dtm-modified>
+ </file-info>
+} + CONTENTS_XML + %{
+ </file>
+END:files
+</file-list>
+<class-module-list>
+START:classes
+ <%classmod% name="%full_name%" id="%full_name%">
+ <classmod-info>
+IF:infiles
+ <infiles>
+START:infiles
+ <infile>HREF:full_path_url:full_path:</infile>
+END:infiles
+ </infiles>
+ENDIF:infiles
+IF:parent
+ <superclass>HREF:par_url:parent:</superclass>
+ENDIF:parent
+ </classmod-info>
+} + CONTENTS_XML + %{
+ </%classmod%>
+END:classes
+</class-module-list>
+</rdoc>
+}
+
+
+end
+end
diff --git a/lib/rdoc/generators/xml_generator.rb b/lib/rdoc/generators/xml_generator.rb
new file mode 100644
index 0000000000..8c1a76d62b
--- /dev/null
+++ b/lib/rdoc/generators/xml_generator.rb
@@ -0,0 +1,130 @@
+
+require 'ftools'
+
+require 'rdoc/options'
+require 'rdoc/markup/simple_markup'
+require 'rdoc/markup/simple_markup/to_html'
+require 'rdoc/generators/html_generator'
+
+module Generators
+
+ # Generate XML output as one big file
+
+ class XMLGenerator < HTMLGenerator
+
+ # Standard generator factory
+ def XMLGenerator.for(options)
+ XMLGenerator.new(options)
+ end
+
+
+ def initialize(*args)
+ super
+ end
+
+ ##
+ # Build the initial indices and output objects
+ # based on an array of TopLevel objects containing
+ # the extracted information.
+
+ def generate(info)
+ @info = info
+ @files = []
+ @classes = []
+ @hyperlinks = {}
+
+ build_indices
+ generate_xml
+ end
+
+
+ ##
+ # Generate:
+ #
+ # * a list of HtmlFile objects for each TopLevel object.
+ # * a list of HtmlClass objects for each first level
+ # class or module in the TopLevel objects
+ # * a complete list of all hyperlinkable terms (file,
+ # class, module, and method names)
+
+ def build_indices
+
+ @info.each do |toplevel|
+ @files << HtmlFile.new(toplevel, @options, FILE_DIR)
+ end
+
+ RDoc::TopLevel.all_classes_and_modules.each do |cls|
+ build_class_list(cls, @files[0], CLASS_DIR)
+ end
+ end
+
+ def build_class_list(from, html_file, class_dir)
+ @classes << HtmlClass.new(from, html_file, class_dir, @options)
+ from.each_classmodule do |mod|
+ build_class_list(mod, html_file, class_dir)
+ end
+ end
+
+ ##
+ # Generate all the HTML. For the one-file case, we generate
+ # all the information in to one big hash
+ #
+ def generate_xml
+ values = {
+ 'charset' => @options.charset,
+ 'files' => gen_into(@files),
+ 'classes' => gen_into(@classes)
+ }
+
+ # this method is defined in the template file
+ write_extra_pages if defined? write_extra_pages
+
+ template = TemplatePage.new(RDoc::Page::ONE_PAGE)
+
+ if @options.op_name
+ opfile = File.open(@options.op_name, "w")
+ else
+ opfile = $stdout
+ end
+ template.write_html_on(opfile, values)
+ end
+
+ def gen_into(list)
+ res = []
+ list.each do |item|
+ res << item.value_hash
+ end
+ res
+ end
+
+ def gen_file_index
+ gen_an_index(@files, 'Files')
+ end
+
+ def gen_class_index
+ gen_an_index(@classes, 'Classes')
+ end
+
+ def gen_method_index
+ gen_an_index(HtmlMethod.all_methods, 'Methods')
+ end
+
+
+ def gen_an_index(collection, title)
+ res = []
+ collection.sort.each do |f|
+ if f.document_self
+ res << { "href" => f.path, "name" => f.index_name }
+ end
+ end
+
+ return {
+ "entries" => res,
+ 'list_title' => title,
+ 'index_url' => main_url,
+ }
+ end
+
+ end
+
+end
diff --git a/lib/rdoc/markup/sample/rdoc2latex.rb b/lib/rdoc/markup/sample/rdoc2latex.rb
new file mode 100644
index 0000000000..26563b75da
--- /dev/null
+++ b/lib/rdoc/markup/sample/rdoc2latex.rb
@@ -0,0 +1,16 @@
+#!/usr/local/bin/ruby
+# Illustration of a script to convert an RDoc-style file to a LaTeX
+# document
+
+require 'rdoc/markup/simple_markup'
+require 'rdoc/markup/simple_markup/to_latex'
+
+p = SM::SimpleMarkup.new
+h = SM::ToLaTeX.new
+
+#puts "\\documentclass{report}"
+#puts "\\usepackage{tabularx}"
+#puts "\\usepackage{parskip}"
+#puts "\\begin{document}"
+puts p.convert(ARGF.read, h)
+#puts "\\end{document}"
diff --git a/lib/rdoc/markup/sample/sample.rb b/lib/rdoc/markup/sample/sample.rb
new file mode 100644
index 0000000000..a375b54564
--- /dev/null
+++ b/lib/rdoc/markup/sample/sample.rb
@@ -0,0 +1,42 @@
+# This program illustrates the basic use of the SimpleMarkup
+# class. It extracts the first comment block from the
+# simple_markup.rb file and converts it into HTML on
+# standard output. Run it using
+#
+# % ruby sample.rb
+#
+# You should be in the sample/ directory when you do this,
+# as it hardwires the path to the files it needs to require.
+# This isn't necessary in the code you write once you've
+# installed the package.
+#
+# For a better way of formatting code comment blocks (and more)
+# see the rdoc package.
+#
+
+$:.unshift "../../.."
+
+require 'rdoc/markup/simple_markup'
+require 'rdoc/markup/simple_markup/to_html'
+
+# Extract the comment block from the source file
+
+input_string = ""
+
+File.foreach("../simple_markup.rb") do |line|
+ break unless line.gsub!(/^\# ?/, '')
+ input_string << line
+end
+
+# Create a markup object
+markup = SM::SimpleMarkup.new
+
+# Attach it to an HTML formatter
+h = SM::ToHtml.new
+
+# And convert out comment block to html. Wrap it a body
+# tag pair to let browsers view it
+
+puts "<html><body>"
+puts markup.convert(input_string, h)
+puts "</body></html>"
diff --git a/lib/rdoc/markup/simple_markup.rb b/lib/rdoc/markup/simple_markup.rb
new file mode 100644
index 0000000000..21064cb009
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup.rb
@@ -0,0 +1,477 @@
+# = Introduction
+#
+# SimpleMarkup parses plain text documents and attempts to decompose
+# them into their constituent parts. Some of these parts are high-level:
+# paragraphs, chunks of verbatim text, list entries and the like. Other
+# parts happen at the character level: a piece of bold text, a word in
+# code font. This markup is similar in spirit to that used on WikiWiki
+# webs, where folks create web pages using a simple set of formatting
+# rules.
+#
+# SimpleMarkup itself does no output formatting: this is left to a
+# different set of classes.
+#
+# SimpleMarkup is extendable at runtime: you can add new markup
+# elements to be recognised in the documents that SimpleMarkup parses.
+#
+# SimpleMarkup is intended to be the basis for a family of tools which
+# share the common requirement that simple, plain-text should be
+# rendered in a variety of different output formats and media. It is
+# envisaged that SimpleMarkup could be the basis for formating RDoc
+# style comment blocks, Wiki entries, and online FAQs.
+#
+# = Basic Formatting
+#
+# * SimpleMarkup looks for a document's natural left margin. This is
+# used as the initial margin for the document.
+#
+# * Consecutive lines starting at this margin are considered to be a
+# paragraph.
+#
+# * If a paragraph starts with a "*", "-", or with "<digit>.", then it is
+# taken to be the start of a list. The margin in increased to be the
+# first non-space following the list start flag. Subsequent lines
+# should be indented to this new margin until the list ends. For
+# example:
+#
+# * this is a list with three paragraphs in
+# the first item. This is the first paragraph.
+#
+# And this is the second paragraph.
+#
+# 1. This is an indented, numbered list.
+# 2. This is the second item in that list
+#
+# This is the third conventional paragraph in the
+# first list item.
+#
+# * This is the second item in the original list
+#
+# * You can also construct labeled lists, sometimes called description
+# or definition lists. Do this by putting the label in square brackets
+# and indenting the list body:
+#
+# [cat] a small furry mammal
+# that seems to sleep a lot
+#
+# [ant] a little insect that is known
+# to enjoy picnics
+#
+# A minor variation on labeled lists uses two colons to separate the
+# label from the list body:
+#
+# cat:: a small furry mammal
+# that seems to sleep a lot
+#
+# ant:: a little insect that is known
+# to enjoy picnics
+#
+# This latter style guarantees that the list bodies' left margins are
+# aligned: think of them as a two column table.
+#
+# * Any line that starts to the right of the current margin is treated
+# as verbatim text. This is useful for code listings. The example of a
+# list above is also verbatim text.
+#
+# * A line starting with an equals sign (=) is treated as a
+# heading. Level one headings have one equals sign, level two headings
+# have two,and so on.
+#
+# * A line starting with three or more hyphens (at the current indent)
+# generates a horizontal rule. THe more hyphens, the thicker the rule
+# (within reason, and if supported by the output device)
+#
+# * You can use markup within text (except verbatim) to change the
+# appearance of parts of that text. Out of the box, SimpleMarkup
+# supports word-based and general markup.
+#
+# Word-based markup uses flag characters around individual words:
+#
+# [\*word*] displays word in a *bold* font
+# [\_word_] displays word in an _emphasized_ font
+# [\+word+] displays word in a +code+ font
+#
+# General markup affects text between a start delimiter and and end
+# delimiter. Not surprisingly, these delimiters look like HTML markup.
+#
+# [\<b>text...</b>] displays word in a *bold* font
+# [\<em>text...</em>] displays word in an _emphasized_ font
+# [\<i>text...</i>] displays word in an _emphasized_ font
+# [\<tt>text...</tt>] displays word in a +code+ font
+#
+# Unlike conventional Wiki markup, general markup can cross line
+# boundaries. You can turn off the interpretation of markup by
+# preceding the first character with a backslash, so \\\<b>bold
+# text</b> and \\\*bold* produce \<b>bold text</b> and \*bold
+# respectively.
+#
+# = Using SimpleMarkup
+#
+# For information on using SimpleMarkup programatically,
+# see SM::SimpleMarkup.
+#
+# Author:: Dave Thomas, dave@pragmaticprogrammer.com
+# Version:: 0.0
+# License:: Ruby license
+
+
+
+require 'rdoc/markup/simple_markup/fragments'
+require 'rdoc/markup/simple_markup/lines.rb'
+
+module SM #:nodoc:
+
+ # == Synopsis
+ #
+ # This code converts <tt>input_string</tt>, which is in the format
+ # described in markup/simple_markup.rb, to HTML. The conversion
+ # takes place in the +convert+ method, so you can use the same
+ # SimpleMarkup object to convert multiple input strings.
+ #
+ # require 'rdoc/markup/simple_markup'
+ # require 'rdoc/markup/simple_markup/to_html'
+ #
+ # p = SM::SimpleMarkup.new
+ # h = SM::ToHtml.new
+ #
+ # puts p.convert(input_string, h)
+ #
+ # You can extend the SimpleMarkup parser to recognise new markup
+ # sequences, and to add special processing for text that matches a
+ # regular epxression. Here we make WikiWords significant to the parser,
+ # and also make the sequences {word} and \<no>text...</no> signify
+ # strike-through text. When then subclass the HTML output class to deal
+ # with these:
+ #
+ # require 'rdoc/markup/simple_markup'
+ # require 'rdoc/markup/simple_markup/to_html'
+ #
+ # class WikiHtml < SM::ToHtml
+ # def handle_special_WIKIWORD(special)
+ # "<font color=red>" + special.text + "</font>"
+ # end
+ # end
+ #
+ # p = SM::SimpleMarkup.new
+ # p.add_word_pair("{", "}", :STRIKE)
+ # p.add_html("no", :STRIKE)
+ #
+ # p.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
+ #
+ # h = WikiHtml.new
+ # h.add_tag(:STRIKE, "<strike>", "</strike>")
+ #
+ # puts "<body>" + p.convert(ARGF.read, h) + "</body>"
+ #
+ # == Output Formatters
+ #
+ # _missing_
+ #
+ #
+
+ class SimpleMarkup
+
+ SPACE = ?\s
+
+ # List entries look like:
+ # * text
+ # 1. text
+ # [label] text
+ # label:: text
+ #
+ # Flag it as a list entry, and
+ # work out the indent for subsequent lines
+
+ SIMPLE_LIST_RE = /^(
+ ( \* (?# bullet)
+ |- (?# bullet)
+ |\d+\. (?# numbered )
+ |[A-Za-z]\. (?# alphabetically numbered )
+ )
+ \s+
+ )\S/x
+
+ LABEL_LIST_RE = /^(
+ ( \[.*?\] (?# labeled )
+ |\S.*:: (?# note )
+ )(?=\s|$)
+ \s*
+ )/x
+
+
+ ##
+ # take a block of text and use various heuristics to determine
+ # it's structure (paragraphs, lists, and so on). Invoke an
+ # event handler as we identify significant chunks.
+ #
+
+ def initialize
+ @am = AttributeManager.new
+ @output = nil
+ end
+
+ ##
+ # Add to the sequences used to add formatting to an individual word
+ # (such as *bold*). Matching entries will generate attibutes
+ # that the output formatters can recognize by their +name+
+
+ def add_word_pair(start, stop, name)
+ @am.add_word_pair(start, stop, name)
+ end
+
+ ##
+ # Add to the sequences recognized as general markup
+ #
+
+ def add_html(tag, name)
+ @am.add_html(tag, name)
+ end
+
+ ##
+ # Add to other inline sequences. For example, we could add
+ # WikiWords using something like:
+ #
+ # parser.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
+ #
+ # Each wiki word will be presented to the output formatter
+ # via the accept_special method
+ #
+
+ def add_special(pattern, name)
+ @am.add_special(pattern, name)
+ end
+
+
+ # We take a string, split it into lines, work out the type of
+ # each line, and from there deduce groups of lines (for example
+ # all lines in a paragraph). We then invoke the output formatter
+ # using a Visitor to display the result
+
+ def convert(str, op)
+ @lines = Lines.new(str.split(/\r?\n/).collect { |aLine|
+ Line.new(aLine) })
+ return "" if @lines.empty?
+ @lines.normalize
+ assign_types_to_lines
+ group = group_lines
+ # call the output formatter to handle the result
+ # group.to_a.each {|i| p i}
+ group.accept(@am, op)
+ end
+
+
+ #######
+ private
+ #######
+
+
+ ##
+ # Look through the text at line indentation. We flag each line as being
+ # Blank, a paragraph, a list element, or verbatim text
+ #
+
+ def assign_types_to_lines(margin = 0, level = 0)
+
+ while line = @lines.next
+ if line.isBlank?
+ line.stamp(Line::BLANK, level)
+ next
+ end
+
+ # if a line contains non-blanks before the margin, then it must belong
+ # to an outer level
+
+ text = line.text
+
+ for i in 0...margin
+ if text[i] != SPACE
+ @lines.unget
+ return
+ end
+ end
+
+ active_line = text[margin..-1]
+
+ # Rules (horizontal lines) look like
+ #
+ # --- (three or more hyphens)
+ #
+ # The more hyphens, the thicker the rule
+ #
+
+ if /^(---+)\s*$/ =~ active_line
+ line.stamp(Line::RULE, level, $1.length-2)
+ next
+ end
+
+ # Then look for list entries. First the ones that have to have
+ # text following them (* xxx, - xxx, and dd. xxx)
+
+ if SIMPLE_LIST_RE =~ active_line
+
+ offset = margin + $1.length
+ prefix = $2
+ prefix_length = prefix.length
+
+ flag = case prefix
+ when "*","-" then ListBase::BULLET
+ when /^\d/ then ListBase::NUMBER
+ when /^[A-Z]/ then ListBase::UPPERALPHA
+ when /^[a-z]/ then ListBase::LOWERALPHA
+ else raise "Invalid List Type: #{self.inspect}"
+ end
+
+ line.stamp(Line::LIST, level+1, prefix, flag)
+ text[margin, prefix_length] = " " * prefix_length
+ assign_types_to_lines(offset, level + 1)
+ next
+ end
+
+
+ if LABEL_LIST_RE =~ active_line
+ offset = margin + $1.length
+ prefix = $2
+ prefix_length = prefix.length
+
+ next if handled_labeled_list(line, level, margin, offset, prefix)
+ end
+
+ # Headings look like
+ # = Main heading
+ # == Second level
+ # === Third
+ #
+ # Headings reset the level to 0
+
+ if active_line[0] == ?= and active_line =~ /^(=+)\s*(.*)/
+ prefix_length = $1.length
+ prefix_length = 6 if prefix_length > 6
+ line.stamp(Line::HEADING, 0, prefix_length)
+ line.strip_leading(margin + prefix_length)
+ next
+ end
+
+ # If the character's a space, then we have verbatim text,
+ # otherwise
+
+ if active_line[0] == SPACE
+ line.strip_leading(margin) if margin > 0
+ line.stamp(Line::VERBATIM, level)
+ else
+ line.stamp(Line::PARAGRAPH, level)
+ end
+ end
+ end
+
+ # Handle labeled list entries, We have a special case
+ # to deal with. Because the labels can be long, they force
+ # the remaining block of text over the to right:
+ #
+ # this is a long label that I wrote:: and here is the
+ # block of text with
+ # a silly margin
+ #
+ # So we allow the special case. If the label is followed
+ # by nothing, and if the following line is indented, then
+ # we take the indent of that line as the new margin
+ #
+ # this is a long label that I wrote::
+ # here is a more reasonably indented block which
+ # will ab attached to the label.
+ #
+
+ def handled_labeled_list(line, level, margin, offset, prefix)
+ prefix_length = prefix.length
+ text = line.text
+ flag = nil
+ case prefix
+ when /^\[/
+ flag = ListBase::LABELED
+ prefix = prefix[1, prefix.length-2]
+ when /:$/
+ flag = ListBase::NOTE
+ prefix.chop!
+ else raise "Invalid List Type: #{self.inspect}"
+ end
+
+ # body is on the next line
+
+ if text.length <= offset
+ original_line = line
+ line = @lines.next
+ return(false) unless line
+ text = line.text
+
+ for i in 0..margin
+ if text[i] != SPACE
+ @lines.unget
+ return false
+ end
+ end
+ i = margin
+ i += 1 while text[i] == SPACE
+ if i >= text.length
+ @lines.unget
+ return false
+ else
+ offset = i
+ prefix_length = 0
+ @lines.delete(original_line)
+ end
+ end
+
+ line.stamp(Line::LIST, level+1, prefix, flag)
+ text[margin, prefix_length] = " " * prefix_length
+ assign_types_to_lines(offset, level + 1)
+ return true
+ end
+
+ # Return a block consisting of fragments which are
+ # paragraphs, list entries or verbatim text. We merge consecutive
+ # lines of the same type and level together. We are also slightly
+ # tricky with lists: the lines following a list introduction
+ # look like paragraph lines at the next level, and we remap them
+ # into list entries instead
+
+ def group_lines
+ @lines.rewind
+
+ inList = false
+ wantedType = wantedLevel = nil
+
+ block = LineCollection.new
+ group = nil
+
+ while line = @lines.next
+ if line.level == wantedLevel and line.type == wantedType
+ group.add_text(line.text)
+ else
+ group = block.fragment_for(line)
+ block.add(group)
+ if line.type == Line::LIST
+ wantedType = Line::PARAGRAPH
+ else
+ wantedType = line.type
+ end
+ wantedLevel = line.type == Line::HEADING ? line.param : line.level
+ end
+ end
+
+ block.normalize
+ block
+ end
+
+ ## for debugging, we allow access to our line contents as text
+ def content
+ @lines.as_text
+ end
+ public :content
+
+ ## for debugging, return the list of line types
+ def get_line_types
+ @lines.line_types
+ end
+ public :get_line_types
+ end
+
+end
diff --git a/lib/rdoc/markup/simple_markup/fragments.rb b/lib/rdoc/markup/simple_markup/fragments.rb
new file mode 100644
index 0000000000..6ca06382ab
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup/fragments.rb
@@ -0,0 +1,328 @@
+require 'rdoc/markup/simple_markup/lines.rb'
+#require 'rdoc/markup/simple_markup/to_flow.rb'
+
+module SM
+
+ ##
+ # A Fragment is a chunk of text, subclassed as a paragraph, a list
+ # entry, or verbatim text
+
+ class Fragment
+ attr_reader :level, :param, :txt
+ attr_accessor :type
+
+ def initialize(level, param, type, txt)
+ @level = level
+ @param = param
+ @type = type
+ @txt = ""
+ add_text(txt) if txt
+ end
+
+ def add_text(txt)
+ @txt << " " if @txt.length > 0
+ @txt << txt.tr_s("\n ", " ").strip
+ end
+
+ def to_s
+ "L#@level: #{self.class.name.split('::')[-1]}\n#@txt"
+ end
+
+ ######
+ # This is a simple factory system that lets us associate fragement
+ # types (a string) with a subclass of fragment
+
+ TYPE_MAP = {}
+
+ def Fragment.type_name(name)
+ TYPE_MAP[name] = self
+ end
+
+ def Fragment.for(line)
+ klass = TYPE_MAP[line.type] ||
+ raise("Unknown line type: '#{line.type.inspect}:' '#{line.text}'")
+ return klass.new(line.level, line.param, line.flag, line.text)
+ end
+ end
+
+ ##
+ # A paragraph is a fragment which gets wrapped to fit. We remove all
+ # newlines when we're created, and have them put back on output
+
+ class Paragraph < Fragment
+ type_name Line::PARAGRAPH
+ end
+
+ class BlankLine < Paragraph
+ type_name Line::BLANK
+ end
+
+ class Heading < Paragraph
+ type_name Line::HEADING
+
+ def head_level
+ @param.to_i
+ end
+ end
+
+ ##
+ # A List is a fragment with some kind of label
+ #
+
+ class ListBase < Paragraph
+ # List types
+ BULLET = :BULLET
+ NUMBER = :NUMBER
+ UPPERALPHA = :UPPERALPHA
+ LOWERALPHA = :LOWERALPHA
+ LABELED = :LABELED
+ NOTE = :NOTE
+ end
+
+ class ListItem < ListBase
+ type_name Line::LIST
+
+ # def label
+ # am = AttributeManager.new(@param)
+ # am.flow
+ # end
+ end
+
+ class ListStart < ListBase
+ def initialize(level, param, type)
+ super(level, param, type, nil)
+ end
+ end
+
+ class ListEnd < ListBase
+ def initialize(level, type)
+ super(level, "", type, nil)
+ end
+ end
+
+ ##
+ # Verbatim code contains lines that don't get wrapped.
+
+ class Verbatim < Fragment
+ type_name Line::VERBATIM
+
+ def add_text(txt)
+ @txt << txt.chomp << "\n"
+ end
+
+ end
+
+ ##
+ # A horizontal rule
+ class Rule < Fragment
+ type_name Line::RULE
+ end
+
+
+ # Collect groups of lines together. Each group
+ # will end up containing a flow of text
+
+ class LineCollection
+
+ def initialize
+ @fragments = []
+ end
+
+ def add(fragment)
+ @fragments << fragment
+ end
+
+ def each(&b)
+ @fragments.each(&b)
+ end
+
+ # For testing
+ def to_a
+ @fragments.map {|fragment| fragment.to_s}
+ end
+
+ # Factory for different fragment types
+ def fragment_for(*args)
+ Fragment.for(*args)
+ end
+
+ # tidy up at the end
+ def normalize
+ change_verbatim_blank_lines
+ add_list_start_and_ends
+ add_list_breaks
+ tidy_blank_lines
+ end
+
+ def to_s
+ @fragments.join("\n----\n")
+ end
+
+ def accept(am, visitor)
+
+ visitor.start_accepting
+
+ @fragments.each do |fragment|
+ case fragment
+ when Verbatim
+ visitor.accept_verbatim(am, fragment)
+ when Rule
+ visitor.accept_rule(am, fragment)
+ when ListStart
+ visitor.accept_list_start(am, fragment)
+ when ListEnd
+ visitor.accept_list_end(am, fragment)
+ when ListItem
+ visitor.accept_list_item(am, fragment)
+ when BlankLine
+ visitor.accept_blank_line(am, fragment)
+ when Heading
+ visitor.accept_heading(am, fragment)
+ when Paragraph
+ visitor.accept_paragraph(am, fragment)
+ end
+ end
+
+ visitor.end_accepting
+ end
+ #######
+ private
+ #######
+
+ # If you have:
+ #
+ # normal paragraph text.
+ #
+ # this is code
+ #
+ # and more code
+ #
+ # You'll end up with the fragments Paragraph, BlankLine,
+ # Verbatim, BlankLine, Verbatim, BlankLine, etc
+ #
+ # The BlankLine in the middle of the verbatim chunk needs to
+ # be changed to a real verbatim newline, and the two
+ # verbatim blocks merged
+ #
+ #
+ def change_verbatim_blank_lines
+ frag_block = nil
+ blank_count = 0
+ @fragments.each_with_index do |frag, i|
+ if frag_block.nil?
+ frag_block = frag if Verbatim === frag
+ else
+ case frag
+ when Verbatim
+ blank_count.times { frag_block.add_text("\n") }
+ blank_count = 0
+ frag_block.add_text(frag.txt)
+ @fragments[i] = nil # remove out current fragment
+ when BlankLine
+ if frag_block
+ blank_count += 1
+ @fragments[i] = nil
+ end
+ else
+ frag_block = nil
+ blank_count = 0
+ end
+ end
+ end
+ @fragments.compact!
+ end
+
+ # List nesting is implicit given the level of
+ # Make it explicit, just to make life a tad
+ # easier for the output processors
+
+ def add_list_start_and_ends
+ level = 0
+ res = []
+ type_stack = []
+
+ @fragments.each do |fragment|
+ # $stderr.puts "#{level} : #{fragment.class.name} : #{fragment.level}"
+ new_level = fragment.level
+ while (level < new_level)
+ level += 1
+ type = fragment.type
+ res << ListStart.new(level, fragment.param, type) if type
+ type_stack.push type
+ # $stderr.puts "Start: #{level}"
+ end
+
+ while level > new_level
+ type = type_stack.pop
+ res << ListEnd.new(level, type) if type
+ level -= 1
+ # $stderr.puts "End: #{level}, #{type}"
+ end
+
+ res << fragment
+ level = fragment.level
+ end
+ level.downto(1) do |i|
+ type = type_stack.pop
+ res << ListEnd.new(i, type) if type
+ end
+
+ @fragments = res
+ end
+
+ # now insert start/ends between list entries at the
+ # same level that have different element types
+
+ def add_list_breaks
+ res = @fragments
+
+ @fragments = []
+ list_stack = []
+
+ res.each do |fragment|
+ case fragment
+ when ListStart
+ list_stack.push fragment
+ when ListEnd
+ start = list_stack.pop
+ fragment.type = start.type
+ when ListItem
+ l = list_stack.last
+ if fragment.type != l.type
+ @fragments << ListEnd.new(l.level, l.type)
+ start = ListStart.new(l.level, fragment.param, fragment.type)
+ @fragments << start
+ list_stack.pop
+ list_stack.push start
+ end
+ else
+ ;
+ end
+ @fragments << fragment
+ end
+ end
+
+ # Finally tidy up the blank lines:
+ # * change Blank/ListEnd into ListEnd/Blank
+ # * remove blank lines at the front
+
+ def tidy_blank_lines
+ (@fragments.size - 1).times do |i|
+ if @fragments[i].kind_of?(BlankLine) and
+ @fragments[i+1].kind_of?(ListEnd)
+ @fragments[i], @fragments[i+1] = @fragments[i+1], @fragments[i]
+ end
+ end
+
+ # remove leading blanks
+ @fragments.each_with_index do |f, i|
+ break unless f.kind_of? BlankLine
+ @fragments[i] = nil
+ end
+
+ @fragments.compact!
+ end
+
+ end
+
+end
diff --git a/lib/rdoc/markup/simple_markup/inline.rb b/lib/rdoc/markup/simple_markup/inline.rb
new file mode 100644
index 0000000000..1e76c201c9
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup/inline.rb
@@ -0,0 +1,338 @@
+module SM
+
+ # We manage a set of attributes. Each attribute has a symbol name
+ # and a bit value
+
+ class Attribute
+ SPECIAL = 1
+
+ @@name_to_bitmap = { :_SPECIAL_ => SPECIAL }
+ @@next_bitmap = 2
+
+ def Attribute.bitmap_for(name)
+ bitmap = @@name_to_bitmap[name]
+ if !bitmap
+ bitmap = @@next_bitmap
+ @@next_bitmap <<= 1
+ @@name_to_bitmap[name] = bitmap
+ end
+ bitmap
+ end
+
+ def Attribute.as_string(bitmap)
+ return "none" if bitmap.zero?
+ res = []
+ @@name_to_bitmap.each do |name, bit|
+ res << name if (bitmap & bit) != 0
+ end
+ res.join(",")
+ end
+
+ def Attribute.each_name_of(bitmap)
+ @@name_to_bitmap.each do |name, bit|
+ next if bit == SPECIAL
+ yield name.to_s if (bitmap & bit) != 0
+ end
+ end
+ end
+
+
+ # An AttrChanger records a change in attributes. It contains
+ # a bitmap of the attributes to turn on, and a bitmap of those to
+ # turn off
+
+ AttrChanger = Struct.new(:turn_on, :turn_off)
+ class AttrChanger
+ def to_s
+ "Attr: +#{Attribute.as_string(@turn_on)}/-#{Attribute.as_string(@turn_on)}"
+ end
+ end
+
+ # An array of attributes which parallels the characters in a string
+ class AttrSpan
+ def initialize(length)
+ @attrs = Array.new(length, 0)
+ end
+
+ def set_attrs(start, length, bits)
+ for i in start ... (start+length)
+ @attrs[i] |= bits
+ end
+ end
+
+ def [](n)
+ @attrs[n]
+ end
+ end
+
+ ##
+ # Hold details of a special sequence
+
+ class Special
+ attr_reader :type
+ attr_accessor :text
+
+ def initialize(type, text)
+ @type, @text = type, text
+ end
+
+ def ==(o)
+ self.text == o.text && self.type == o.type
+ end
+
+ def to_s
+ "Special: type=#{type}, text=#{text.dump}"
+ end
+ end
+
+ class AttributeManager
+
+ NULL = "\000".freeze
+
+ ##
+ # We work by substituting non-printing characters in to the
+ # text. For now I'm assuming that I can substitute
+ # a character in the range 0..8 for a 7 bit character
+ # without damaging the encoded string, but this might
+ # be optimistic
+ #
+
+ A_PROTECT = 004
+ PROTECT_ATTR = A_PROTECT.chr
+
+ # This maps delimiters that occur around words (such as
+ # *bold* or +tt+) where the start and end delimiters
+ # and the same. This lets us optimize the regexp
+ MATCHING_WORD_PAIRS = {}
+
+ # And this is used when the delimiters aren't the same. In this
+ # case the hash maps a pattern to the attribute character
+ WORD_PAIR_MAP = {}
+
+ # This maps HTML tags to the corresponding attribute char
+ HTML_TAGS = {}
+
+ # And this maps _special_ sequences to a name. A special sequence
+ # is something like a WikiWord
+ SPECIAL = {}
+
+ # Return an attribute object with the given turn_on
+ # and turn_off bits set
+
+ def attribute(turn_on, turn_off)
+ AttrChanger.new(turn_on, turn_off)
+ end
+
+
+ def change_attribute(current, new)
+ diff = current ^ new
+ attribute(new & diff, current & diff)
+ end
+
+ def changed_attribute_by_name(current_set, new_set)
+ current = new = 0
+ current_set.each {|name| current |= Attribute.bitmap_for(name) }
+ new_set.each {|name| new |= Attribute.bitmap_for(name) }
+ change_attribute(current, new)
+ end
+
+ def copy_string(start_pos, end_pos)
+ res = @str[start_pos...end_pos]
+ res.gsub!(/\000/, '')
+ res
+ end
+
+ # Map attributes like <b>text</b>to the sequence \001\002<char>\001\003<char>,
+ # where <char> is a per-attribute specific character
+
+ def convert_attrs(str, attrs)
+ # first do matching ones
+ tags = MATCHING_WORD_PAIRS.keys.join("")
+ re = "(^|\\W)([#{tags}])([A-Za-z_]+?)\\2(\\W|\$)"
+# re = "(^|\\W)([#{tags}])(\\S+?)\\2(\\W|\$)"
+ 1 while str.gsub!(Regexp.new(re)) {
+ attr = MATCHING_WORD_PAIRS[$2];
+ attrs.set_attrs($`.length + $1.length + $2.length, $3.length, attr)
+ $1 + NULL*$2.length + $3 + NULL*$2.length + $4
+ }
+
+ # then non-matching
+ unless WORD_PAIR_MAP.empty?
+ WORD_PAIR_MAP.each do |regexp, attr|
+ str.gsub!(regexp) {
+ attrs.set_attrs($`.length + $1.length, $2.length, attr)
+ NULL*$1.length + $2 + NULL*$3.length
+ }
+ end
+ end
+ end
+
+ def convert_html(str, attrs)
+ tags = HTML_TAGS.keys.join("|")
+ re = "<(#{tags})>(.*?)</\\1>"
+ 1 while str.gsub!(Regexp.new(re, Regexp::IGNORECASE)) {
+ attr = HTML_TAGS[$1.downcase]
+ html_length = $1.length + 2
+ seq = NULL * html_length
+ attrs.set_attrs($`.length + html_length, $2.length, attr)
+ seq + $2 + seq + NULL
+ }
+ end
+
+ def convert_specials(str, attrs)
+ unless SPECIAL.empty?
+ SPECIAL.each do |regexp, attr|
+ str.scan(regexp) do
+ attrs.set_attrs($`.length, $1.length, attr | Attribute::SPECIAL)
+ end
+ end
+ end
+ end
+
+ # A \ in front of a character that would normally be
+ # processed turns off processing. We do this by turning
+ # \< into <#{PROTECT}
+
+ PROTECTABLE = [ "<" << "\\" ] #"
+
+
+ def mask_protected_sequences
+ protect_pattern = Regexp.new("\\\\([#{Regexp.escape(PROTECTABLE.join(''))}])")
+ @str.gsub!(protect_pattern, "\\1#{PROTECT_ATTR}")
+ end
+
+ def unmask_protected_sequences
+ @str.gsub!(/(.)#{PROTECT_ATTR}/, "\\1\000")
+ end
+
+ def initialize
+ add_word_pair("*", "*", :BOLD)
+ add_word_pair("_", "_", :EM)
+ add_word_pair("+", "+", :TT)
+
+ add_html("em", :EM)
+ add_html("i", :EM)
+ add_html("b", :BOLD)
+ add_html("tt", :TT)
+ add_html("code", :TT)
+ end
+
+ def add_word_pair(start, stop, name)
+ raise "Word flags may not start '<'" if start[0] == ?<
+ bitmap = Attribute.bitmap_for(name)
+ if start == stop
+ MATCHING_WORD_PAIRS[start] = bitmap
+ else
+ pattern = Regexp.new("(" + Regexp.escape(start) + ")" +
+# "([A-Za-z]+)" +
+ "(\\S+)" +
+ "(" + Regexp.escape(stop) +")")
+ WORD_PAIR_MAP[pattern] = bitmap
+ end
+ PROTECTABLE << start[0,1]
+ PROTECTABLE.uniq!
+ end
+
+ def add_html(tag, name)
+ HTML_TAGS[tag.downcase] = Attribute.bitmap_for(name)
+ end
+
+ def add_special(pattern, name)
+ SPECIAL[pattern] = Attribute.bitmap_for(name)
+ end
+
+ def flow(str)
+ @str = str
+
+ puts("Before flow, str='#{@str.dump}'") if $DEBUG
+ mask_protected_sequences
+
+ @attrs = AttrSpan.new(@str.length)
+
+ puts("After protecting, str='#{@str.dump}'") if $DEBUG
+ convert_attrs(@str, @attrs)
+ convert_html(@str, @attrs)
+ convert_specials(str, @attrs)
+ unmask_protected_sequences
+ puts("After flow, str='#{@str.dump}'") if $DEBUG
+ return split_into_flow
+ end
+
+ def display_attributes
+ puts
+ puts @str.tr(NULL, "!")
+ bit = 1
+ 16.times do |bno|
+ line = ""
+ @str.length.times do |i|
+ if (@attrs[i] & bit) == 0
+ line << " "
+ else
+ if bno.zero?
+ line << "S"
+ else
+ line << ("%d" % (bno+1))
+ end
+ end
+ end
+ puts(line) unless line =~ /^ *$/
+ bit <<= 1
+ end
+ end
+
+ def split_into_flow
+
+ display_attributes if $DEBUG
+
+ res = []
+ current_attr = 0
+ str = ""
+
+
+ str_len = @str.length
+
+ # skip leading invisible text
+ i = 0
+ i += 1 while i < str_len and @str[i].zero?
+ start_pos = i
+
+ # then scan the string, chunking it on attribute changes
+ while i < str_len
+ new_attr = @attrs[i]
+ if new_attr != current_attr
+ if i > start_pos
+ res << copy_string(start_pos, i)
+ start_pos = i
+ end
+
+ res << change_attribute(current_attr, new_attr)
+ current_attr = new_attr
+
+ if (current_attr & Attribute::SPECIAL) != 0
+ i += 1 while i < str_len and (@attrs[i] & Attribute::SPECIAL) != 0
+ res << Special.new(current_attr, copy_string(start_pos, i))
+ start_pos = i
+ next
+ end
+ end
+
+ # move on, skipping any invisible characters
+ begin
+ i += 1
+ end while i < str_len and @str[i].zero?
+ end
+
+ # tidy up trailing text
+ if start_pos < str_len
+ res << copy_string(start_pos, str_len)
+ end
+
+ # and reset to all attributes off
+ res << change_attribute(current_attr, 0) if current_attr != 0
+
+ return res
+ end
+
+ end
+
+end
diff --git a/lib/rdoc/markup/simple_markup/lines.rb b/lib/rdoc/markup/simple_markup/lines.rb
new file mode 100644
index 0000000000..4e294f27dc
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup/lines.rb
@@ -0,0 +1,151 @@
+##########################################################################
+#
+# We store the lines we're working on as objects of class Line.
+# These contain the text of the line, along with a flag indicating the
+# line type, and an indentation level
+
+module SM
+
+ class Line
+ INFINITY = 9999
+
+ BLANK = :BLANK
+ HEADING = :HEADING
+ LIST = :LIST
+ RULE = :RULE
+ PARAGRAPH = :PARAGRAPH
+ VERBATIM = :VERBATIM
+
+ # line type
+ attr_accessor :type
+
+ # The indentation nesting level
+ attr_accessor :level
+
+ # The contents
+ attr_accessor :text
+
+ # A prefix or parameter. For LIST lines, this is
+ # the text that introduced the list item (the label)
+ attr_accessor :param
+
+ # A flag. For list lines, this is the type of the list
+ attr_accessor :flag
+
+ # the number of leading spaces
+ attr_accessor :leading_spaces
+
+ # true if this line has been deleted from the list of lines
+ attr_accessor :deleted
+
+
+ def initialize(text)
+ @text = text.dup
+ @deleted = false
+
+ # expand tabs
+ 1 while @text.gsub!(/\t+/) { ' ' * (8*$&.length - $`.length % 8)} && $~ #`
+
+ # Strip trailing whitespace
+ @text.sub!(/\s+$/, '')
+
+ # and look for leading whitespace
+ if @text.length > 0
+ @text =~ /^(\s*)/
+ @leading_spaces = $1.length
+ else
+ @leading_spaces = INFINITY
+ end
+ end
+
+ # Return true if this line is blank
+ def isBlank?
+ @text.length.zero?
+ end
+
+ # stamp a line with a type, a level, a prefix, and a flag
+ def stamp(type, level, param="", flag=nil)
+ @type, @level, @param, @flag = type, level, param, flag
+ end
+
+ ##
+ # Strip off the leading margin
+ #
+
+ def strip_leading(size)
+ if @text.size > size
+ @text[0,size] = ""
+ else
+ @text = ""
+ end
+ end
+
+ def to_s
+ "#@type#@level: #@text"
+ end
+ end
+
+ ###############################################################################
+ #
+ # A container for all the lines
+ #
+
+ class Lines
+ include Enumerable
+
+ attr_reader :lines # for debugging
+
+ def initialize(lines)
+ @lines = lines
+ rewind
+ end
+
+ def empty?
+ @lines.size.zero?
+ end
+
+ def each
+ @lines.each do |line|
+ yield line unless line.deleted
+ end
+ end
+
+# def [](index)
+# @lines[index]
+# end
+
+ def rewind
+ @nextline = 0
+ end
+
+ def next
+ begin
+ res = @lines[@nextline]
+ @nextline += 1 if @nextline < @lines.size
+ end while res and res.deleted and @nextline < @lines.size
+ res
+ end
+
+ def unget
+ @nextline -= 1
+ end
+
+ def delete(a_line)
+ a_line.deleted = true
+ end
+
+ def normalize
+ margin = @lines.collect{|l| l.leading_spaces}.min
+ margin = 0 if margin == Line::INFINITY
+ @lines.each {|line| line.strip_leading(margin) } if margin > 0
+ end
+
+ def as_text
+ @lines.map {|l| l.text}.join("\n")
+ end
+
+ def line_types
+ @lines.map {|l| l.type }
+ end
+ end
+end
diff --git a/lib/rdoc/markup/simple_markup/preprocess.rb b/lib/rdoc/markup/simple_markup/preprocess.rb
new file mode 100644
index 0000000000..dbf4b216ca
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup/preprocess.rb
@@ -0,0 +1,70 @@
+module SM
+
+ ##
+ # Handle common directives that can occur in a block of text:
+ #
+ # : include : filename
+ #
+
+ class PreProcess
+
+ def initialize(input_file_name, include_path)
+ @input_file_name = input_file_name
+ @include_path = include_path
+ end
+
+ # Look for common options in a chunk of text. Options that
+ # we don't handle are passed back to our caller
+ # as |directive, param|
+
+ def handle(text)
+ text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do
+
+ prefix = $1
+ directive = $2.downcase
+ param = $3
+
+ case directive
+
+ when "include"
+ filename = param.split[0]
+ include_file(filename, prefix)
+
+ else
+ yield(directive, param)
+ end
+ end
+ end
+
+ #######
+ private
+ #######
+
+ # Include a file, indenting it correctly
+
+ def include_file(name, indent)
+ if (full_name = find_include_file(name))
+ content = File.open(full_name) {|f| f.read}
+ res = content.gsub(/^#?/, indent)
+ else
+ $stderr.puts "Couldn't find file to include: '#{name}'"
+ ''
+ end
+ end
+
+ # Look for the given file in the directory containing the current
+ # file, and then in each of the directories specified in the
+ # RDOC_INCLUDE path
+
+ def find_include_file(name)
+ to_search = [ File.dirname(@input_file_name) ].concat @include_path
+ to_search.each do |dir|
+ full_name = File.join(dir, name)
+ stat = File.stat(full_name) rescue next
+ return full_name if stat.readable?
+ end
+ nil
+ end
+
+ end
+end
diff --git a/lib/rdoc/markup/simple_markup/to_flow.rb b/lib/rdoc/markup/simple_markup/to_flow.rb
new file mode 100644
index 0000000000..401703a72a
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup/to_flow.rb
@@ -0,0 +1,188 @@
+require 'rdoc/markup/simple_markup/fragments'
+require 'rdoc/markup/simple_markup/inline'
+require 'cgi'
+
+module SM
+
+ module Flow
+ P = Struct.new(:body)
+ VERB = Struct.new(:body)
+ RULE = Struct.new(:width)
+ class LIST
+ attr_reader :type, :contents
+ def initialize(type)
+ @type = type
+ @contents = []
+ end
+ def <<(stuff)
+ @contents << stuff
+ end
+ end
+ LI = Struct.new(:label, :body)
+ H = Struct.new(:level, :text)
+ end
+
+ class ToFlow
+ LIST_TYPE_TO_HTML = {
+ SM::ListBase::BULLET => [ "<ul>", "</ul>" ],
+ SM::ListBase::NUMBER => [ "<ol>", "</ol>" ],
+ SM::ListBase::UPPERALPHA => [ "<ol>", "</ol>" ],
+ SM::ListBase::LOWERALPHA => [ "<ol>", "</ol>" ],
+ SM::ListBase::LABELED => [ "<dl>", "</dl>" ],
+ SM::ListBase::NOTE => [ "<table>", "</table>" ],
+ }
+
+ InlineTag = Struct.new(:bit, :on, :off)
+
+ def initialize
+ init_tags
+ end
+
+ ##
+ # Set up the standard mapping of attributes to HTML tags
+ #
+ def init_tags
+ @attr_tags = [
+ InlineTag.new(SM::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
+ InlineTag.new(SM::Attribute.bitmap_for(:TT), "<tt>", "</tt>"),
+ InlineTag.new(SM::Attribute.bitmap_for(:EM), "<em>", "</em>"),
+ ]
+ end
+
+ ##
+ # Add a new set of HTML tags for an attribute. We allow
+ # separate start and end tags for flexibility
+ #
+ def add_tag(name, start, stop)
+ @attr_tags << InlineTag.new(SM::Attribute.bitmap_for(name), start, stop)
+ end
+
+ ##
+ # Given an HTML tag, decorate it with class information
+ # and the like if required. This is a no-op in the base
+ # class, but is overridden in HTML output classes that
+ # implement style sheets
+
+ def annotate(tag)
+ tag
+ end
+
+ ##
+ # Here's the client side of the visitor pattern
+
+ def start_accepting
+ @res = []
+ @list_stack = []
+ end
+
+ def end_accepting
+ @res
+ end
+
+ def accept_paragraph(am, fragment)
+ @res << Flow::P.new((convert_flow(am.flow(fragment.txt))))
+ end
+
+ def accept_verbatim(am, fragment)
+ @res << Flow::VERB.new((convert_flow(am.flow(fragment.txt))))
+ end
+
+ def accept_rule(am, fragment)
+ size = fragment.param
+ size = 10 if size > 10
+ @res << Flow::RULE.new(size)
+ end
+
+ def accept_list_start(am, fragment)
+ @list_stack.push(@res)
+ list = Flow::LIST.new(fragment.type)
+ @res << list
+ @res = list
+ end
+
+ def accept_list_end(am, fragment)
+ @res = @list_stack.pop
+ end
+
+ def accept_list_item(am, fragment)
+ @res << Flow::LI.new(fragment.param, convert_flow(am.flow(fragment.txt)))
+ end
+
+ def accept_blank_line(am, fragment)
+ # @res << annotate("<p />") << "\n"
+ end
+
+ def accept_heading(am, fragment)
+ @res << Flow::H.new(fragment.head_level, am.flow(fragment.txt))
+ end
+
+
+ #######################################################################
+
+ private
+
+ #######################################################################
+
+ def on_tags(res, item)
+ attr_mask = item.turn_on
+ return if attr_mask.zero?
+
+ @attr_tags.each do |tag|
+ if attr_mask & tag.bit != 0
+ res << annotate(tag.on)
+ end
+ end
+ end
+
+ def off_tags(res, item)
+ attr_mask = item.turn_off
+ return if attr_mask.zero?
+
+ @attr_tags.reverse_each do |tag|
+ if attr_mask & tag.bit != 0
+ res << annotate(tag.off)
+ end
+ end
+ end
+
+ def convert_flow(flow)
+ res = ""
+ flow.each do |item|
+ case item
+ when String
+ res << convert_string(item)
+ when AttrChanger
+ off_tags(res, item)
+ on_tags(res, item)
+ when Special
+ res << convert_special(item)
+ else
+ raise "Unknown flow element: #{item.inspect}"
+ end
+ end
+ res
+ end
+
+ # some of these patterns are taken from SmartyPants...
+
+ def convert_string(item)
+ CGI.escapeHTML(item)
+ end
+
+ def convert_special(special)
+ handled = false
+ Attribute.each_name_of(special.type) do |name|
+ method_name = "handle_special_#{name}"
+ if self.respond_to? method_name
+ special.text = send(method_name, special)
+ handled = true
+ end
+ end
+ raise "Unhandled special: #{special}" unless handled
+ special.text
+ end
+
+
+ end
+
+end
diff --git a/lib/rdoc/markup/simple_markup/to_html.rb b/lib/rdoc/markup/simple_markup/to_html.rb
new file mode 100644
index 0000000000..26b5f4ce70
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup/to_html.rb
@@ -0,0 +1,289 @@
+require 'rdoc/markup/simple_markup/fragments'
+require 'rdoc/markup/simple_markup/inline'
+
+require 'cgi'
+
+module SM
+
+ class ToHtml
+
+ LIST_TYPE_TO_HTML = {
+ ListBase::BULLET => [ "<ul>", "</ul>" ],
+ ListBase::NUMBER => [ "<ol>", "</ol>" ],
+ ListBase::UPPERALPHA => [ "<ol>", "</ol>" ],
+ ListBase::LOWERALPHA => [ "<ol>", "</ol>" ],
+ ListBase::LABELED => [ "<dl>", "</dl>" ],
+ ListBase::NOTE => [ "<table>", "</table>" ],
+ }
+
+ InlineTag = Struct.new(:bit, :on, :off)
+
+ def initialize
+ init_tags
+ end
+
+ ##
+ # Set up the standard mapping of attributes to HTML tags
+ #
+ def init_tags
+ @attr_tags = [
+ InlineTag.new(SM::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
+ InlineTag.new(SM::Attribute.bitmap_for(:TT), "<tt>", "</tt>"),
+ InlineTag.new(SM::Attribute.bitmap_for(:EM), "<em>", "</em>"),
+ ]
+ end
+
+ ##
+ # Add a new set of HTML tags for an attribute. We allow
+ # separate start and end tags for flexibility
+ #
+ def add_tag(name, start, stop)
+ @attr_tags << InlineTag.new(SM::Attribute.bitmap_for(name), start, stop)
+ end
+
+ ##
+ # Given an HTML tag, decorate it with class information
+ # and the like if required. This is a no-op in the base
+ # class, but is overridden in HTML output classes that
+ # implement style sheets
+
+ def annotate(tag)
+ tag
+ end
+
+ ##
+ # Here's the client side of the visitor pattern
+
+ def start_accepting
+ @res = ""
+ @in_list_entry = []
+ end
+
+ def end_accepting
+ @res
+ end
+
+ def accept_paragraph(am, fragment)
+ @res << annotate("<p>") + "\n"
+ @res << wrap(convert_flow(am.flow(fragment.txt)))
+ @res << annotate("</p>") + "\n"
+ end
+
+ def accept_verbatim(am, fragment)
+ @res << annotate("<pre>") + "\n"
+ @res << CGI.escapeHTML(fragment.txt)
+ @res << annotate("</pre>") << "\n"
+ end
+
+ def accept_rule(am, fragment)
+ size = fragment.param
+ size = 10 if size > 10
+ @res << "<hr size=\"#{size}\"></hr>"
+ end
+
+ def accept_list_start(am, fragment)
+ @res << html_list_name(fragment.type, true) <<"\n"
+ @in_list_entry.push false
+ end
+
+ def accept_list_end(am, fragment)
+ if tag = @in_list_entry.pop
+ @res << annotate(tag) << "\n"
+ end
+ @res << html_list_name(fragment.type, false) <<"\n"
+ end
+
+ def accept_list_item(am, fragment)
+ if tag = @in_list_entry.last
+ @res << annotate(tag) << "\n"
+ end
+ @res << list_item_start(am, fragment)
+ @res << wrap(convert_flow(am.flow(fragment.txt))) << "\n"
+ @in_list_entry[-1] = list_end_for(fragment.type)
+ end
+
+ def accept_blank_line(am, fragment)
+ # @res << annotate("<p />") << "\n"
+ end
+
+ def accept_heading(am, fragment)
+ @res << convert_heading(fragment.head_level, am.flow(fragment.txt))
+ end
+
+ # This is a higher speed (if messier) version of wrap
+
+ def wrap(txt, line_len = 76)
+ res = ""
+ sp = 0
+ ep = txt.length
+ while sp < ep
+ # scan back for a space
+ p = sp + line_len - 1
+ if p >= ep
+ p = ep
+ else
+ while p > sp and txt[p] != ?\s
+ p -= 1
+ end
+ if p <= sp
+ p = sp + line_len
+ while p < ep and txt[p] != ?\s
+ p += 1
+ end
+ end
+ end
+ res << txt[sp...p] << "\n"
+ sp = p
+ sp += 1 while sp < ep and txt[sp] == ?\s
+ end
+ res
+ end
+
+ #######################################################################
+
+ private
+
+ #######################################################################
+
+ def on_tags(res, item)
+ attr_mask = item.turn_on
+ return if attr_mask.zero?
+
+ @attr_tags.each do |tag|
+ if attr_mask & tag.bit != 0
+ res << annotate(tag.on)
+ end
+ end
+ end
+
+ def off_tags(res, item)
+ attr_mask = item.turn_off
+ return if attr_mask.zero?
+
+ @attr_tags.reverse_each do |tag|
+ if attr_mask & tag.bit != 0
+ res << annotate(tag.off)
+ end
+ end
+ end
+
+ def convert_flow(flow)
+ res = ""
+ flow.each do |item|
+ case item
+ when String
+ res << convert_string(item)
+ when AttrChanger
+ off_tags(res, item)
+ on_tags(res, item)
+ when Special
+ res << convert_special(item)
+ else
+ raise "Unknown flow element: #{item.inspect}"
+ end
+ end
+ res
+ end
+
+ # some of these patterns are taken from SmartyPants...
+
+ def convert_string(item)
+ CGI.escapeHTML(item).
+
+
+ # convert -- to em-dash, (-- to en-dash)
+ gsub(/---?/, '&#8212;'). #gsub(/--/, '&#8211;').
+
+ # convert ... to elipsis (and make sure .... becomes .<elipsis>)
+ gsub(/\.\.\.\./, '.&#8230;').gsub(/\.\.\./, '&#8230;').
+
+ # convert single closing quote
+ gsub(%r{([^ \t\r\n\[\{\(])\'}) { "#$1&#8217;" }.
+ gsub(%r{\'(?=\W|s\b)}) { "&#8217;" }.
+
+ # convert single opening quote
+ gsub(/'/, '&#8216;').
+
+ # convert double closing quote
+ gsub(%r{([^ \t\r\n\[\{\(])\'(?=\W)}) { "#$1&#8221;" }.
+
+ # convert double opening quote
+ gsub(/'/, '&#8220;').
+
+ # convert copyright
+ gsub(/\(c\)/, '&#169;').
+
+ # convert and registered trademark
+ gsub(/\(r\)/, '&#174;')
+
+ end
+
+ def convert_special(special)
+ handled = false
+ Attribute.each_name_of(special.type) do |name|
+ method_name = "handle_special_#{name}"
+ if self.respond_to? method_name
+ special.text = send(method_name, special)
+ handled = true
+ end
+ end
+ raise "Unhandled special: #{special}" unless handled
+ special.text
+ end
+
+ def convert_heading(level, flow)
+ res =
+ annotate("<h#{level}>") +
+ convert_flow(flow) +
+ annotate("</h#{level}>\n")
+ end
+
+ def html_list_name(list_type, is_open_tag)
+ tags = LIST_TYPE_TO_HTML[list_type] || raise("Invalid list type: #{list_type.inspect}")
+ annotate(tags[ is_open_tag ? 0 : 1])
+ end
+
+ def list_item_start(am, fragment)
+ case fragment.type
+ when ListBase::BULLET, ListBase::NUMBER
+ annotate("<li>")
+
+ when ListBase::UPPERALPHA
+ annotate("<li type=\"A\">")
+
+ when ListBase::LOWERALPHA
+ annotate("<li type=\"a\">")
+
+ when ListBase::LABELED
+ annotate("<dt>") +
+ convert_flow(am.flow(fragment.param)) +
+ annotate("</dt>") +
+ annotate("<dd>")
+
+ when ListBase::NOTE
+ annotate("<tr>") +
+ annotate("<td valign=\"top\">") +
+ convert_flow(am.flow(fragment.param)) +
+ annotate("</td>") +
+ annotate("<td>")
+ else
+ raise "Invalid list type"
+ end
+ end
+
+ def list_end_for(fragment_type)
+ case fragment_type
+ when ListBase::BULLET, ListBase::NUMBER, ListBase::UPPERALPHA, ListBase::LOWERALPHA
+ "</li>"
+ when ListBase::LABELED
+ "</dd>"
+ when ListBase::NOTE
+ "</td></tr>"
+ else
+ raise "Invalid list type"
+ end
+ end
+
+ end
+
+end
diff --git a/lib/rdoc/markup/simple_markup/to_latex.rb b/lib/rdoc/markup/simple_markup/to_latex.rb
new file mode 100644
index 0000000000..6c16278652
--- /dev/null
+++ b/lib/rdoc/markup/simple_markup/to_latex.rb
@@ -0,0 +1,333 @@
+require 'rdoc/markup/simple_markup/fragments'
+require 'rdoc/markup/simple_markup/inline'
+
+require 'cgi'
+
+module SM
+
+ # Convert SimpleMarkup to basic LaTeX report format
+
+ class ToLaTeX
+
+ BS = "\020" # \
+ OB = "\021" # {
+ CB = "\022" # }
+ DL = "\023" # Dollar
+
+ BACKSLASH = "#{BS}symbol#{OB}92#{CB}"
+ HAT = "#{BS}symbol#{OB}94#{CB}"
+ BACKQUOTE = "#{BS}symbol#{OB}0#{CB}"
+ TILDE = "#{DL}#{BS}sim#{DL}"
+ LESSTHAN = "#{DL}<#{DL}"
+ GREATERTHAN = "#{DL}>#{DL}"
+
+ def self.l(str)
+ str.tr('\\', BS).tr('{', OB).tr('}', CB).tr('$', DL)
+ end
+
+ def l(arg)
+ SM::ToLaTeX.l(arg)
+ end
+
+ LIST_TYPE_TO_LATEX = {
+ ListBase::BULLET => [ l("\\begin{itemize}"), l("\\end{itemize}") ],
+ ListBase::NUMBER => [ l("\\begin{enumerate}"), l("\\end{enumerate}"), "\\arabic" ],
+ ListBase::UPPERALPHA => [ l("\\begin{enumerate}"), l("\\end{enumerate}"), "\\Alph" ],
+ ListBase::LOWERALPHA => [ l("\\begin{enumerate}"), l("\\end{enumerate}"), "\\alph" ],
+ ListBase::LABELED => [ l("\\begin{description}"), l("\\end{description}") ],
+ ListBase::NOTE => [
+ l("\\begin{tabularx}{\\linewidth}{@{} l X @{}}"),
+ l("\\end{tabularx}") ],
+ }
+
+ InlineTag = Struct.new(:bit, :on, :off)
+
+ def initialize
+ init_tags
+ @list_depth = 0
+ @prev_list_types = []
+ end
+
+ ##
+ # Set up the standard mapping of attributes to LaTeX
+ #
+ def init_tags
+ @attr_tags = [
+ InlineTag.new(SM::Attribute.bitmap_for(:BOLD), l("\\textbf{"), l("}")),
+ InlineTag.new(SM::Attribute.bitmap_for(:TT), l("\\texttt{"), l("}")),
+ InlineTag.new(SM::Attribute.bitmap_for(:EM), l("\\emph{"), l("}")),
+ ]
+ end
+
+ ##
+ # Escape a LaTeX string
+ def escape(str)
+# $stderr.print "FE: ", str
+ s = str.
+# sub(/\s+$/, '').
+ gsub(/([_\${}&%#])/, "#{BS}\\1").
+ gsub(/\\/, BACKSLASH).
+ gsub(/\^/, HAT).
+ gsub(/~/, TILDE).
+ gsub(/</, LESSTHAN).
+ gsub(/>/, GREATERTHAN).
+ gsub(/,,/, ",{},").
+ gsub(/\`/, BACKQUOTE)
+# $stderr.print "-> ", s, "\n"
+ s
+ end
+
+ ##
+ # Add a new set of LaTeX tags for an attribute. We allow
+ # separate start and end tags for flexibility
+ #
+ def add_tag(name, start, stop)
+ @attr_tags << InlineTag.new(SM::Attribute.bitmap_for(name), start, stop)
+ end
+
+
+ ##
+ # Here's the client side of the visitor pattern
+
+ def start_accepting
+ @res = ""
+ @in_list_entry = []
+ end
+
+ def end_accepting
+ @res.tr(BS, '\\').tr(OB, '{').tr(CB, '}').tr(DL, '$')
+ end
+
+ def accept_paragraph(am, fragment)
+ @res << wrap(convert_flow(am.flow(fragment.txt)))
+ @res << "\n"
+ end
+
+ def accept_verbatim(am, fragment)
+ @res << "\n\\begin{code}\n"
+ @res << fragment.txt.sub(/[\n\s]+\Z/, '')
+ @res << "\n\\end{code}\n\n"
+ end
+
+ def accept_rule(am, fragment)
+ size = fragment.param
+ size = 10 if size > 10
+ @res << "\n\n\\rule{\\linewidth}{#{size}pt}\n\n"
+ end
+
+ def accept_list_start(am, fragment)
+ @res << list_name(fragment.type, true) <<"\n"
+ @in_list_entry.push false
+ end
+
+ def accept_list_end(am, fragment)
+ if tag = @in_list_entry.pop
+ @res << tag << "\n"
+ end
+ @res << list_name(fragment.type, false) <<"\n"
+ end
+
+ def accept_list_item(am, fragment)
+ if tag = @in_list_entry.last
+ @res << tag << "\n"
+ end
+ @res << list_item_start(am, fragment)
+ @res << wrap(convert_flow(am.flow(fragment.txt))) << "\n"
+ @in_list_entry[-1] = list_end_for(fragment.type)
+ end
+
+ def accept_blank_line(am, fragment)
+ # @res << "\n"
+ end
+
+ def accept_heading(am, fragment)
+ @res << convert_heading(fragment.head_level, am.flow(fragment.txt))
+ end
+
+ # This is a higher speed (if messier) version of wrap
+
+ def wrap(txt, line_len = 76)
+ res = ""
+ sp = 0
+ ep = txt.length
+ while sp < ep
+ # scan back for a space
+ p = sp + line_len - 1
+ if p >= ep
+ p = ep
+ else
+ while p > sp and txt[p] != ?\s
+ p -= 1
+ end
+ if p <= sp
+ p = sp + line_len
+ while p < ep and txt[p] != ?\s
+ p += 1
+ end
+ end
+ end
+ res << txt[sp...p] << "\n"
+ sp = p
+ sp += 1 while sp < ep and txt[sp] == ?\s
+ end
+ res
+ end
+
+ #######################################################################
+
+ private
+
+ #######################################################################
+
+ def on_tags(res, item)
+ attr_mask = item.turn_on
+ return if attr_mask.zero?
+
+ @attr_tags.each do |tag|
+ if attr_mask & tag.bit != 0
+ res << tag.on
+ end
+ end
+ end
+
+ def off_tags(res, item)
+ attr_mask = item.turn_off
+ return if attr_mask.zero?
+
+ @attr_tags.reverse_each do |tag|
+ if attr_mask & tag.bit != 0
+ res << tag.off
+ end
+ end
+ end
+
+ def convert_flow(flow)
+ res = ""
+ flow.each do |item|
+ case item
+ when String
+# $stderr.puts "Converting '#{item}'"
+ res << convert_string(item)
+ when AttrChanger
+ off_tags(res, item)
+ on_tags(res, item)
+ when Special
+ res << convert_special(item)
+ else
+ raise "Unknown flow element: #{item.inspect}"
+ end
+ end
+ res
+ end
+
+ # some of these patterns are taken from SmartyPants...
+
+ def convert_string(item)
+
+ escape(item).
+
+
+ # convert ... to elipsis (and make sure .... becomes .<elipsis>)
+ gsub(/\.\.\.\./, '.\ldots{}').gsub(/\.\.\./, '\ldots{}').
+
+ # convert single closing quote
+ gsub(%r{([^ \t\r\n\[\{\(])\'}) { "#$1'" }.
+ gsub(%r{\'(?=\W|s\b)}) { "'" }.
+
+ # convert single opening quote
+ gsub(/'/, '`').
+
+ # convert double closing quote
+ gsub(%r{([^ \t\r\n\[\{\(])\"(?=\W)}) { "#$1''" }.
+
+ # convert double opening quote
+ gsub(/"/, "``").
+
+ # convert copyright
+ gsub(/\(c\)/, '\copyright{}')
+
+ end
+
+ def convert_special(special)
+ handled = false
+ Attribute.each_name_of(special.type) do |name|
+ method_name = "handle_special_#{name}"
+ if self.respond_to? method_name
+ special.text = send(method_name, special)
+ handled = true
+ end
+ end
+ raise "Unhandled special: #{special}" unless handled
+ special.text
+ end
+
+ def convert_heading(level, flow)
+ res =
+ case level
+ when 1 then "\\chapter{"
+ when 2 then "\\section{"
+ when 3 then "\\subsection{"
+ when 4 then "\\subsubsection{"
+ else "\\paragraph{"
+ end +
+ convert_flow(flow) +
+ "}\n"
+ end
+
+ def list_name(list_type, is_open_tag)
+ tags = LIST_TYPE_TO_LATEX[list_type] || raise("Invalid list type: #{list_type.inspect}")
+ if tags[2] # enumerate
+ if is_open_tag
+ @list_depth += 1
+ if @prev_list_types[@list_depth] != tags[2]
+ case @list_depth
+ when 1
+ roman = "i"
+ when 2
+ roman = "ii"
+ when 3
+ roman = "iii"
+ when 4
+ roman = "iv"
+ else
+ raise("Too deep list: level #{@list_depth}")
+ end
+ @prev_list_types[@list_depth] = tags[2]
+ return l("\\renewcommand{\\labelenum#{roman}}{#{tags[2]}{enum#{roman}}}") + "\n" + tags[0]
+ end
+ else
+ @list_depth -= 1
+ end
+ end
+ tags[ is_open_tag ? 0 : 1]
+ end
+
+ def list_item_start(am, fragment)
+ case fragment.type
+ when ListBase::BULLET, ListBase::NUMBER, ListBase::UPPERALPHA, ListBase::LOWERALPHA
+ "\\item "
+
+ when ListBase::LABELED
+ "\\item[" + convert_flow(am.flow(fragment.param)) + "] "
+
+ when ListBase::NOTE
+ convert_flow(am.flow(fragment.param)) + " & "
+ else
+ raise "Invalid list type"
+ end
+ end
+
+ def list_end_for(fragment_type)
+ case fragment_type
+ when ListBase::BULLET, ListBase::NUMBER, ListBase::UPPERALPHA, ListBase::LOWERALPHA, ListBase::LABELED
+ ""
+ when ListBase::NOTE
+ "\\\\\n"
+ else
+ raise "Invalid list type"
+ end
+ end
+
+ end
+
+end
diff --git a/lib/rdoc/markup/test/AllTests.rb b/lib/rdoc/markup/test/AllTests.rb
new file mode 100644
index 0000000000..b9c8c9dfcc
--- /dev/null
+++ b/lib/rdoc/markup/test/AllTests.rb
@@ -0,0 +1,2 @@
+require 'TestParse.rb'
+require 'TestInline.rb'
diff --git a/lib/rdoc/markup/test/TestInline.rb b/lib/rdoc/markup/test/TestInline.rb
new file mode 100644
index 0000000000..a067d4c24c
--- /dev/null
+++ b/lib/rdoc/markup/test/TestInline.rb
@@ -0,0 +1,154 @@
+require "test/unit"
+
+$:.unshift "../../.."
+
+require "rdoc/markup/simple_markup/inline"
+
+class TestInline < Test::Unit::TestCase
+
+
+ def setup
+ @am = SM::AttributeManager.new
+
+ @bold_on = @am.changed_attribute_by_name([], [:BOLD])
+ @bold_off = @am.changed_attribute_by_name([:BOLD], [])
+
+ @tt_on = @am.changed_attribute_by_name([], [:TT])
+ @tt_off = @am.changed_attribute_by_name([:TT], [])
+
+ @em_on = @am.changed_attribute_by_name([], [:EM])
+ @em_off = @am.changed_attribute_by_name([:EM], [])
+
+ @bold_em_on = @am.changed_attribute_by_name([], [:BOLD] | [:EM])
+ @bold_em_off = @am.changed_attribute_by_name([:BOLD] | [:EM], [])
+
+ @em_then_bold = @am.changed_attribute_by_name([:EM], [:EM] | [:BOLD])
+
+ @em_to_bold = @am.changed_attribute_by_name([:EM], [:BOLD])
+
+ @am.add_word_pair("{", "}", :WOMBAT)
+ @wombat_on = @am.changed_attribute_by_name([], [:WOMBAT])
+ @wombat_off = @am.changed_attribute_by_name([:WOMBAT], [])
+ end
+
+ def crossref(text)
+ [ @am.changed_attribute_by_name([], [:CROSSREF] | [:_SPECIAL_]),
+ SM::Special.new(33, text),
+ @am.changed_attribute_by_name([:CROSSREF] | [:_SPECIAL_], [])
+ ]
+ end
+
+ def test_special
+ # class names, variable names, file names, or instance variables
+ @am.add_special(/(
+ \b([A-Z]\w+(::\w+)*)
+ | \#\w+[!?=]?
+ | \b\w+([_\/\.]+\w+)+[!?=]?
+ )/x,
+ :CROSSREF)
+
+ assert_equal(["cat"], @am.flow("cat"))
+
+ assert_equal(["cat ", crossref("#fred"), " dog"].flatten,
+ @am.flow("cat #fred dog"))
+
+ assert_equal([crossref("#fred"), " dog"].flatten,
+ @am.flow("#fred dog"))
+
+ assert_equal(["cat ", crossref("#fred")].flatten, @am.flow("cat #fred"))
+ end
+
+ def test_basic
+ assert_equal(["cat"], @am.flow("cat"))
+
+ assert_equal(["cat ", @bold_on, "and", @bold_off, " dog"],
+ @am.flow("cat *and* dog"))
+
+ assert_equal(["cat ", @bold_on, "AND", @bold_off, " dog"],
+ @am.flow("cat *AND* dog"))
+
+ assert_equal(["cat ", @em_on, "And", @em_off, " dog"],
+ @am.flow("cat _And_ dog"))
+
+ assert_equal(["cat *and dog*"], @am.flow("cat *and dog*"))
+
+ assert_equal(["*cat and* dog"], @am.flow("*cat and* dog"))
+
+ assert_equal(["cat *and ", @bold_on, "dog", @bold_off],
+ @am.flow("cat *and *dog*"))
+
+ assert_equal(["cat ", @em_on, "and", @em_off, " dog"],
+ @am.flow("cat _and_ dog"))
+
+ assert_equal(["cat_and_dog"],
+ @am.flow("cat_and_dog"))
+
+ assert_equal(["cat ", @tt_on, "and", @tt_off, " dog"],
+ @am.flow("cat +and+ dog"))
+
+ assert_equal(["cat ", @bold_on, "a_b_c", @bold_off, " dog"],
+ @am.flow("cat *a_b_c* dog"))
+
+ assert_equal(["cat __ dog"],
+ @am.flow("cat __ dog"))
+
+ assert_equal(["cat ", @em_on, "_", @em_off, " dog"],
+ @am.flow("cat ___ dog"))
+
+ end
+
+ def test_combined
+ assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
+ @am.flow("cat _and_ *dog*"))
+
+ assert_equal(["cat ", @em_on, "a__nd", @em_off, " ", @bold_on, "dog", @bold_off],
+ @am.flow("cat _a__nd_ *dog*"))
+ end
+
+ def test_html_like
+ assert_equal(["cat ", @tt_on, "dog", @tt_off], @am.flow("cat <tt>dog</Tt>"))
+
+ assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
+ @am.flow("cat <i>and</i> <B>dog</b>"))
+
+ assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
+ @am.flow("cat <i>and <B>dog</B></I>"))
+
+ assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+ @am.flow("cat <i>and </i><b>dog</b>"))
+
+ assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+ @am.flow("cat <i>and <b></i>dog</b>"))
+
+ assert_equal([@tt_on, "cat", @tt_off, " ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+ @am.flow("<tt>cat</tt> <i>and <b></i>dog</b>"))
+
+ assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
+ @am.flow("cat <i>and <b>dog</b></i>"))
+
+ assert_equal(["cat ", @bold_em_on, "and", @bold_em_off, " dog"],
+ @am.flow("cat <i><b>and</b></i> dog"))
+
+
+ end
+
+ def test_protect
+ assert_equal(['cat \\ dog'], @am.flow('cat \\ dog'))
+
+ assert_equal(["cat <tt>dog</Tt>"], @am.flow("cat \\<tt>dog</Tt>"))
+
+ assert_equal(["cat ", @em_on, "and", @em_off, " <B>dog</b>"],
+ @am.flow("cat <i>and</i> \\<B>dog</b>"))
+
+ assert_equal(["*word* or <b>text</b>"], @am.flow("\\*word* or \\<b>text</b>"))
+
+ assert_equal(["_cat_", @em_on, "dog", @em_off],
+ @am.flow("\\_cat_<i>dog</i>"))
+ end
+
+ def test_adding
+ assert_equal(["cat ", @wombat_on, "and", @wombat_off, " dog" ],
+ @am.flow("cat {and} dog"))
+# assert_equal(["cat {and} dog" ], @am.flow("cat \\{and} dog"))
+ end
+end
diff --git a/lib/rdoc/markup/test/TestParse.rb b/lib/rdoc/markup/test/TestParse.rb
new file mode 100644
index 0000000000..3ec541ce7a
--- /dev/null
+++ b/lib/rdoc/markup/test/TestParse.rb
@@ -0,0 +1,503 @@
+require 'test/unit'
+
+$:.unshift "../../.."
+
+require 'rdoc/markup/simple_markup'
+
+include SM
+
+class TestParse < Test::Unit::TestCase
+
+ class MockOutput
+ def start_accepting
+ @res = []
+ end
+
+ def end_accepting
+ @res
+ end
+
+ def accept_paragraph(am, fragment)
+ @res << fragment.to_s
+ end
+
+ def accept_verbatim(am, fragment)
+ @res << fragment.to_s
+ end
+
+ def accept_list_start(am, fragment)
+ @res << fragment.to_s
+ end
+
+ def accept_list_end(am, fragment)
+ @res << fragment.to_s
+ end
+
+ def accept_list_item(am, fragment)
+ @res << fragment.to_s
+ end
+
+ def accept_blank_line(am, fragment)
+ @res << fragment.to_s
+ end
+
+ def accept_heading(am, fragment)
+ @res << fragment.to_s
+ end
+
+ def accept_rule(am, fragment)
+ @res << fragment.to_s
+ end
+
+ end
+
+ def basic_conv(str)
+ sm = SimpleMarkup.new
+ mock = MockOutput.new
+ sm.convert(str, mock)
+ sm.content
+ end
+
+ def line_types(str, expected)
+ p = SimpleMarkup.new
+ mock = MockOutput.new
+ p.convert(str, mock)
+ assert_equal(expected, p.get_line_types.map{|type| type.to_s[0,1]}.join(''))
+ end
+
+ def line_groups(str, expected)
+ p = SimpleMarkup.new
+ mock = MockOutput.new
+
+ block = p.convert(str, mock)
+
+ if block != expected
+ rows = (0...([expected.size, block.size].max)).collect{|i|
+ [expected[i]||"nil", block[i]||"nil"]
+ }
+ printf "\n\n%35s %35s\n", "Expected", "Got"
+ rows.each {|e,g| printf "%35s %35s\n", e.dump, g.dump }
+ end
+
+ assert_equal(expected, block)
+ end
+
+ def test_tabs
+ str = "hello\n dave"
+ assert_equal(str, basic_conv(str))
+ str = "hello\n\tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = "hello\n \tdave"
+ assert_equal("hello\n dave", basic_conv(str))
+ str = ".\t\t."
+ assert_equal(". .", basic_conv(str))
+ end
+
+ def test_whitespace
+ assert_equal("hello", basic_conv("hello"))
+ assert_equal("hello", basic_conv(" hello "))
+ assert_equal("hello", basic_conv(" \t \t hello\t\t"))
+
+ assert_equal("1\n 2\n 3", basic_conv("1\n 2\n 3"))
+ assert_equal("1\n 2\n 3", basic_conv(" 1\n 2\n 3"))
+
+ assert_equal("1\n 2\n 3\n1\n 2", basic_conv("1\n 2\n 3\n1\n 2"))
+ assert_equal("1\n 2\n 3\n1\n 2", basic_conv(" 1\n 2\n 3\n 1\n 2"))
+
+ assert_equal("1\n 2\n\n 3", basic_conv(" 1\n 2\n\n 3"))
+ end
+
+ def test_types
+ str = "now is the time"
+ line_types(str, 'P')
+
+ str = "now is the time\nfor all good men"
+ line_types(str, 'PP')
+
+ str = "now is the time\n code\nfor all good men"
+ line_types(str, 'PVP')
+
+ str = "now is the time\n code\n more code\nfor all good men"
+ line_types(str, 'PVVP')
+
+ str = "now is\n---\nthe time"
+ line_types(str, 'PRP')
+
+ str = %{\
+ now is
+ * l1
+ * l2
+ the time}
+ line_types(str, 'PLLP')
+
+ str = %{\
+ now is
+ * l1
+ l1+
+ * l2
+ the time}
+ line_types(str, 'PLPLP')
+
+ str = %{\
+ now is
+ * l1
+ * l1.1
+ * l2
+ the time}
+ line_types(str, 'PLLLP')
+
+ str = %{\
+ now is
+ * l1
+ * l1.1
+ text
+ code
+ code
+
+ text
+ * l2
+ the time}
+ line_types(str, 'PLLPVVBPLP')
+
+ str = %{\
+ now is
+ 1. l1
+ * l1.1
+ 2. l2
+ the time}
+ line_types(str, 'PLLLP')
+
+ str = %{\
+ now is
+ [cat] l1
+ * l1.1
+ [dog] l2
+ the time}
+ line_types(str, 'PLLLP')
+
+ str = %{\
+ now is
+ [cat] l1
+ continuation
+ [dog] l2
+ the time}
+ line_types(str, 'PLPLP')
+ end
+
+ def test_groups
+ str = "now is the time"
+ line_groups(str, ["L0: Paragraph\nnow is the time"] )
+
+ str = "now is the time\nfor all good men"
+ line_groups(str, ["L0: Paragraph\nnow is the time for all good men"] )
+
+ str = %{\
+ now is the time
+ code _line_ here
+ for all good men}
+
+ line_groups(str,
+ [ "L0: Paragraph\nnow is the time",
+ "L0: Verbatim\n code _line_ here\n",
+ "L0: Paragraph\nfor all good men"
+ ] )
+
+ str = "now is the time\n code\n more code\nfor all good men"
+ line_groups(str,
+ [ "L0: Paragraph\nnow is the time",
+ "L0: Verbatim\n code\n more code\n",
+ "L0: Paragraph\nfor all good men"
+ ] )
+
+ str = %{\
+ now is
+ * l1
+ * l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+ str = %{\
+ now is
+ * l1
+ l1+
+ * l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1 l1+",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+ str = %{\
+ now is
+ * l1
+ * l1.1
+ * l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1",
+ "L2: ListStart\n",
+ "L2: ListItem\nl1.1",
+ "L2: ListEnd\n",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ str = %{\
+ now is
+ * l1
+ * l1.1
+ text
+ code
+ code
+
+ text
+ * l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1",
+ "L2: ListStart\n",
+ "L2: ListItem\nl1.1 text",
+ "L2: Verbatim\n code\n code\n",
+ "L2: Paragraph\ntext",
+ "L2: ListEnd\n",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ str = %{\
+ now is
+ 1. l1
+ * l1.1
+ 2. l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1",
+ "L2: ListStart\n",
+ "L2: ListItem\nl1.1",
+ "L2: ListEnd\n",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+ str = %{\
+ now is
+ [cat] l1
+ * l1.1
+ [dog] l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1",
+ "L2: ListStart\n",
+ "L2: ListItem\nl1.1",
+ "L2: ListEnd\n",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+ str = %{\
+ now is
+ [cat] l1
+ continuation
+ [dog] l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1 continuation",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ end
+
+ def test_verbatim_merge
+ str = %{\
+ now is
+ code
+ the time}
+
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L0: Verbatim\n code\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ str = %{\
+ now is
+ code
+ code1
+ the time}
+
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L0: Verbatim\n code\n code1\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ str = %{\
+ now is
+ code
+
+ code1
+ the time}
+
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L0: Verbatim\n code\n\n code1\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ str = %{\
+ now is
+ code
+
+ code1
+
+ the time}
+
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L0: Verbatim\n code\n\n code1\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ str = %{\
+ now is
+ code
+
+ code1
+
+ code2
+ the time}
+
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L0: Verbatim\n code\n\n code1\n\n code2\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ # Folds multiple blank lines
+ str = %{\
+ now is
+ code
+
+
+ code1
+
+ the time}
+
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L0: Verbatim\n code\n\n code1\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+
+ end
+
+ def test_list_split
+ str = %{\
+ now is
+ * l1
+ 1. n1
+ 2. n2
+ * l2
+ the time}
+ line_groups(str,
+ [ "L0: Paragraph\nnow is",
+ "L1: ListStart\n",
+ "L1: ListItem\nl1",
+ "L1: ListEnd\n",
+ "L1: ListStart\n",
+ "L1: ListItem\nn1",
+ "L1: ListItem\nn2",
+ "L1: ListEnd\n",
+ "L1: ListStart\n",
+ "L1: ListItem\nl2",
+ "L1: ListEnd\n",
+ "L0: Paragraph\nthe time"
+ ])
+
+ end
+
+
+ def test_headings
+ str = "= heading one"
+ line_groups(str,
+ [ "L0: Heading\nheading one"
+ ])
+
+ str = "=== heading three"
+ line_groups(str,
+ [ "L0: Heading\nheading three"
+ ])
+
+ str = "text\n === heading three"
+ line_groups(str,
+ [ "L0: Paragraph\ntext",
+ "L0: Verbatim\n === heading three\n"
+ ])
+
+ str = "text\n code\n === heading three"
+ line_groups(str,
+ [ "L0: Paragraph\ntext",
+ "L0: Verbatim\n code\n === heading three\n"
+ ])
+
+ str = "text\n code\n=== heading three"
+ line_groups(str,
+ [ "L0: Paragraph\ntext",
+ "L0: Verbatim\n code\n",
+ "L0: Heading\nheading three"
+ ])
+
+ end
+
+
+end
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
new file mode 100644
index 0000000000..62c6dabff0
--- /dev/null
+++ b/lib/rdoc/options.rb
@@ -0,0 +1,575 @@
+# We handle the parsing of options, and subsequently as a singleton
+# object to be queried for option values
+
+require "rdoc/ri/ri_paths"
+
+class Options
+
+ require 'singleton'
+ require 'getoptlong'
+
+ include Singleton
+
+ # files matching this pattern will be excluded
+ attr_accessor :exclude
+
+ # the name of the output directory
+ attr_accessor :op_dir
+
+ # the name to use for the output
+ attr_reader :op_name
+
+ # include private and protected methods in the
+ # output
+ attr_accessor :show_all
+
+ # name of the file, class or module to display in
+ # the initial index page (if not specified
+ # the first file we encounter is used)
+ attr_accessor :main_page
+
+ # merge into classes of the name name when generating ri
+ attr_reader :merge
+
+ # Don't display progress as we process the files
+ attr_reader :quiet
+
+ # description of the output generator (set with the <tt>-fmt</tt>
+ # option
+ attr_accessor :generator
+
+ # and the list of files to be processed
+ attr_reader :files
+
+ # array of directories to search for files to satisfy an :include:
+ attr_reader :rdoc_include
+
+ # title to be used out the output
+ #attr_writer :title
+
+ # template to be used when generating output
+ attr_reader :template
+
+ # should diagrams be drawn
+ attr_reader :diagram
+
+ # should we draw fileboxes in diagrams
+ attr_reader :fileboxes
+
+ # include the '#' at the front of hyperlinked instance method names
+ attr_reader :show_hash
+
+ # image format for diagrams
+ attr_reader :image_format
+
+ # character-set
+ attr_reader :charset
+
+ # should source code be included inline, or displayed in a popup
+ attr_reader :inline_source
+
+ # should the output be placed into a single file
+ attr_reader :all_one_file
+
+ # the number of columns in a tab
+ attr_reader :tab_width
+
+ # include line numbers in the source listings
+ attr_reader :include_line_numbers
+
+ # pattern for additional attr_... style methods
+ attr_reader :extra_accessors
+ attr_reader :extra_accessor_flags
+
+ # URL of stylesheet
+ attr_reader :css
+
+ # URL of web cvs frontend
+ attr_reader :webcvs
+
+ # Are we promiscuous about showing module contents across
+ # multiple files
+ attr_reader :promiscuous
+
+ module OptionList
+
+ OPTION_LIST = [
+ [ "--accessor", "-A", "accessorname[,..]",
+ "comma separated list of additional class methods\n" +
+ "that should be treated like 'attr_reader' and\n" +
+ "friends. Option may be repeated. Each accessorname\n" +
+ "may have '=text' appended, in which case that text\n" +
+ "appears where the r/w/rw appears for normal accessors."],
+
+ [ "--all", "-a", nil,
+ "include all methods (not just public)\nin the output" ],
+
+ [ "--charset", "-c", "charset",
+ "specifies HTML character-set" ],
+
+ [ "--debug", "-D", nil,
+ "displays lots on internal stuff" ],
+
+ [ "--diagram", "-d", nil,
+ "Generate diagrams showing modules and classes.\n" +
+ "You need dot V1.8.6 or later to use the --diagram\n" +
+ "option correctly. Dot is available from\n"+
+ "http://www.research.att.com/sw/tools/graphviz/" ],
+
+ [ "--exclude", "-x", "pattern",
+ "do not process files or directories matching\n" +
+ "pattern. Files given explicitly on the command\n" +
+ "line will never be excluded." ],
+
+ [ "--extension", "-E", "new=old",
+ "Treat files ending with .new as if they ended with\n" +
+ ".old. Using '-E cgi=rb' will cause xxx.cgi to be\n" +
+ "parsed as a Ruby file"],
+
+ [ "--fileboxes", "-F", nil,
+ "classes are put in boxes which represents\n" +
+ "files, where these classes reside. Classes\n" +
+ "shared between more than one file are\n" +
+ "shown with list of files that sharing them.\n" +
+ "Silently discarded if --diagram is not given\n" +
+ "Experimental." ],
+
+ [ "--fmt", "-f", "format name",
+ "set the output formatter (see below)" ],
+
+ [ "--help", "-h", nil,
+ "you're looking at it" ],
+
+ [ "--help-output", "-O", nil,
+ "explain the various output options" ],
+
+ [ "--image-format", "-I", "gif/png/jpg/jpeg",
+ "Sets output image format for diagrams. Can\n" +
+ "be png, gif, jpeg, jpg. If this option is\n" +
+ "omitted, png is used. Requires --diagram." ],
+
+ [ "--include", "-i", "dir[,dir...]",
+ "set (or add to) the list of directories\n" +
+ "to be searched when satisfying :include:\n" +
+ "requests. Can be used more than once." ],
+
+ [ "--inline-source", "-S", nil,
+ "Show method source code inline, rather\n" +
+ "than via a popup link" ],
+
+ [ "--line-numbers", "-N", nil,
+ "Include line numbers in the source code" ],
+
+ [ "--main", "-m", "name",
+ "'name' will be the initial page displayed" ],
+
+ [ "--merge", "-M", nil,
+ "when creating ri output, merge processed classes\n" +
+ "into previously documented classes of the name name"],
+
+ [ "--one-file", "-1", nil,
+ "put all the output into a single file" ],
+
+ [ "--op", "-o", "dir",
+ "set the output directory" ],
+
+ [ "--opname", "-n", "name",
+ "Set the 'name' of the output. Has no\n" +
+ "effect for HTML." ],
+
+ [ "--promiscuous", "-p", nil,
+ "When documenting a file that contains a module\n" +
+ "or class also defined in other files, show\n" +
+ "all stuff for that module/class in each files\n" +
+ "page. By default, only show stuff defined in\n" +
+ "that particular file." ],
+
+ [ "--quiet", "-q", nil,
+ "don't show progress as we parse" ],
+
+ [ "--ri", "-r", nil,
+ "generate output for use by 'ri.' The files are\n" +
+ "stored in the '.rdoc' directory under your home\n"+
+ "directory unless overridden by a subsequent\n" +
+ "--op parameter, so no special privileges are needed." ],
+
+ [ "--ri-site", "-R", nil,
+ "generate output for use by 'ri.' The files are\n" +
+ "stored in a site-wide directory, making them accessible\n"+
+ "to others, so special privileges are needed." ],
+
+ [ "--ri-system", "-Y", nil,
+ "generate output for use by 'ri.' The files are\n" +
+ "stored in a system-level directory, making them accessible\n"+
+ "to others, so special privileges are needed. This option\n"+
+ "is intended to be used during Ruby installations" ],
+
+ [ "--show-hash", "-H", nil,
+ "A name of the form #name in a comment\n" +
+ "is a possible hyperlink to an instance\n" +
+ "method name. When displayed, the '#' is\n" +
+ "removed unless this option is specified" ],
+
+ [ "--style", "-s", "stylesheet url",
+ "specifies the URL of a separate stylesheet." ],
+
+ [ "--tab-width", "-w", "n",
+ "Set the width of tab characters (default 8)"],
+
+ [ "--template", "-T", "template name",
+ "Set the template used when generating output" ],
+
+ [ "--title", "-t", "text",
+ "Set 'txt' as the title for the output" ],
+
+ [ "--version", "-v", nil,
+ "display RDoc's version" ],
+
+ [ "--webcvs", "-W", "url",
+ "Specify a URL for linking to a web frontend\n" +
+ "to CVS. If the URL contains a '\%s', the\n" +
+ "name of the current file will be substituted;\n" +
+ "if the URL doesn't contain a '\%s', the\n" +
+ "filename will be appended to it." ],
+ ]
+
+ def OptionList.options
+ OPTION_LIST.map do |long, short, arg,|
+ [ long,
+ short,
+ arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT
+ ]
+ end
+ end
+
+
+ def OptionList.strip_output(text)
+ text =~ /^\s+/
+ leading_spaces = $&
+ text.gsub!(/^#{leading_spaces}/, '')
+ $stdout.puts text
+ end
+
+
+ # Show an error and exit
+
+ def OptionList.error(msg)
+ $stderr.puts
+ $stderr.puts msg
+ $stderr.puts "\nFor help on options, try 'rdoc --help'\n\n"
+ exit 1
+ end
+
+ # Show usage and exit
+
+ def OptionList.usage(generator_names)
+
+ puts
+ puts(VERSION_STRING)
+ puts
+
+ name = File.basename($0)
+ OptionList.strip_output(<<-EOT)
+ Usage:
+
+ #{name} [options] [names...]
+
+ Files are parsed, and the information they contain
+ collected, before any output is produced. This allows cross
+ references between all files to be resolved. If a name is a
+ directory, it is traversed. If no names are specified, all
+ Ruby files in the current directory (and subdirectories) are
+ processed.
+
+ Options:
+
+ EOT
+
+ OPTION_LIST.each do |long, short, arg, desc|
+ opt = sprintf("%20s", "#{long}, #{short}")
+ oparg = sprintf("%-7s", arg)
+ print "#{opt} #{oparg}"
+ desc = desc.split("\n")
+ if arg.nil? || arg.length < 7
+ puts desc.shift
+ else
+ puts
+ end
+ desc.each do |line|
+ puts(" "*28 + line)
+ end
+ puts
+ end
+
+ puts "\nAvailable output formatters: " +
+ generator_names.sort.join(', ') + "\n\n"
+
+ puts "For information on where the output goes, use\n\n"
+ puts " rdoc --help-output\n\n"
+
+ exit 0
+ end
+
+ def OptionList.help_output
+ OptionList.strip_output(<<-EOT)
+ How RDoc generates output depends on the output formatter being
+ used, and on the options you give.
+
+ - HTML output is normally produced into a number of separate files
+ (one per class, module, and file, along with various indices).
+ These files will appear in the directory given by the --op
+ option (doc/ by default).
+
+ - XML output by default is written to standard output. If a
+ --opname option is given, the output will instead be written
+ to a file with that name in the output directory.
+
+ - .chm files (Windows help files) are written in the --op directory.
+ If an --opname parameter is present, that name is used, otherwise
+ the file will be called rdoc.chm.
+
+ For information on other RDoc options, use "rdoc --help".
+ EOT
+ exit 0
+ end
+ end
+
+ # Parse command line options. We're passed a hash containing
+ # output generators, keyed by the generator name
+
+ def parse(argv, generators)
+ old_argv = ARGV.dup
+ begin
+ ARGV.replace(argv)
+ @op_dir = "doc"
+ @op_name = nil
+ @show_all = false
+ @main_page = nil
+ @marge = false
+ @exclude = []
+ @quiet = false
+ @generator_name = 'html'
+ @generator = generators[@generator_name]
+ @rdoc_include = []
+ @title = nil
+ @template = nil
+ @diagram = false
+ @fileboxes = false
+ @show_hash = false
+ @image_format = 'png'
+ @inline_source = false
+ @all_one_file = false
+ @tab_width = 8
+ @include_line_numbers = false
+ @extra_accessor_flags = {}
+ @promiscuous = false
+
+ @css = nil
+ @webcvs = nil
+
+ @charset = case $KCODE
+ when /^S/i
+ 'Shift_JIS'
+ when /^E/i
+ 'EUC-JP'
+ else
+ 'iso-8859-1'
+ end
+
+ accessors = []
+
+ go = GetoptLong.new(*OptionList.options)
+ go.quiet = true
+
+ go.each do |opt, arg|
+ case opt
+ when "--all" then @show_all = true
+ when "--charset" then @charset = arg
+ when "--debug" then $DEBUG = true
+ when "--exclude" then @exclude << Regexp.new(arg)
+ when "--inline-source" then @inline_source = true
+ when "--line-numbers" then @include_line_numbers = true
+ when "--main" then @main_page = arg
+ when "--merge" then @merge = true
+ when "--one-file" then @all_one_file = true
+ when "--op" then @op_dir = arg
+ when "--opname" then @op_name = arg
+ when "--promiscuous" then @promiscuous = true
+ when "--quiet" then @quiet = true
+ when "--show-hash" then @show_hash = true
+ when "--style" then @css = arg
+ when "--template" then @template = arg
+ when "--title" then @title = arg
+ when "--webcvs" then @webcvs = arg
+
+ when "--accessor"
+ arg.split(/,/).each do |accessor|
+ if accessor =~ /^(\w+)(=(.*))?$/
+ accessors << $1
+ @extra_accessor_flags[$1] = $3
+ end
+ end
+
+ when "--diagram"
+ check_diagram
+ @diagram = true
+
+ when "--fileboxes"
+ @fileboxes = true if @diagram
+
+ when "--fmt"
+ @generator_name = arg.downcase
+ setup_generator(generators)
+
+ when "--help"
+ OptionList.usage(generators.keys)
+
+ when "--help-output"
+ OptionList.help_output
+
+ when "--image-format"
+ if ['gif', 'png', 'jpeg', 'jpg'].include?(arg)
+ @image_format = arg
+ else
+ raise GetoptLong::InvalidOption.new("unknown image format: #{arg}")
+ end
+
+ when "--include"
+ @rdoc_include.concat arg.split(/\s*,\s*/)
+
+ when "--ri", "--ri-site", "--ri-system"
+ @generator_name = "ri"
+ @op_dir = case opt
+ when "--ri" then RI::Paths::HOMEDIR
+ when "--ri-site" then RI::Paths::SITEDIR
+ when "--ri-system" then RI::Paths::SYSDIR
+ else fail opt
+ end
+ setup_generator(generators)
+
+ when "--tab-width"
+ begin
+ @tab_width = Integer(arg)
+ rescue
+ $stderr.puts "Invalid tab width: '#{arg}'"
+ exit 1
+ end
+
+ when "--extension"
+ new, old = arg.split(/=/, 2)
+ OptionList.error("Invalid parameter to '-E'") unless new && old
+ unless RDoc::ParserFactory.alias_extension(old, new)
+ OptionList.error("Unknown extension .#{old} to -E")
+ end
+
+ when "--version"
+ puts VERSION_STRING
+ exit
+ end
+
+ end
+
+ @files = ARGV.dup
+
+ @rdoc_include << "." if @rdoc_include.empty?
+
+ if @exclude.empty?
+ @exclude = nil
+ else
+ @exclude = Regexp.new(@exclude.join("|"))
+ end
+
+ check_files
+
+ # If no template was specified, use the default
+ # template for the output formatter
+
+ @template ||= @generator_name
+
+ # Generate a regexp from the accessors
+ unless accessors.empty?
+ re = '^(' + accessors.map{|a| Regexp.quote(a)}.join('|') + ')$'
+ @extra_accessors = Regexp.new(re)
+ end
+
+ rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
+ OptionList.error(error.message)
+
+ ensure
+ ARGV.replace(old_argv)
+ end
+ end
+
+
+ def title
+ @title ||= "RDoc Documentation"
+ end
+
+ # Set the title, but only if not already set. This means that a title set from
+ # the command line trumps one set in a source file
+
+ def title=(string)
+ @title ||= string
+ end
+
+
+ private
+
+ # Set up an output generator for the format in @generator_name
+ def setup_generator(generators)
+ @generator = generators[@generator_name]
+ if !@generator
+ OptionList.error("Invalid output formatter")
+ end
+
+ if @generator_name == "xml"
+ @all_one_file = true
+ @inline_source = true
+ end
+ end
+
+ # Check that the right version of 'dot' is available.
+ # Unfortuately this doesn't work correctly under Windows NT,
+ # so we'll bypass the test under Windows
+
+ def check_diagram
+ return if RUBY_PLATFORM =~ /win/
+
+ ok = false
+ ver = nil
+ IO.popen("dot -V 2>&1") do |io|
+ ver = io.read
+ if ver =~ /dot\s+version(?:\s+gviz)?\s+(\d+)\.(\d+)/
+ ok = ($1.to_i > 1) || ($1.to_i == 1 && $2.to_i >= 8)
+ end
+ end
+ unless ok
+ if ver =~ /^dot version/
+ $stderr.puts "Warning: You may need dot V1.8.6 or later to use\n",
+ "the --diagram option correctly. You have:\n\n ",
+ ver,
+ "\nDiagrams might have strange background colors.\n\n"
+ else
+ $stderr.puts "You need the 'dot' program to produce diagrams.",
+ "(see http://www.research.att.com/sw/tools/graphviz/)\n\n"
+ exit
+ end
+# exit
+ end
+ end
+
+ # Check that the files on the command line exist
+
+ def check_files
+ @files.each do |f|
+ stat = File.stat f rescue error("File not found: #{f}")
+ error("File '#{f}' not readable") unless stat.readable?
+ end
+ end
+
+ def error(str)
+ $stderr.puts str
+ exit(1)
+ end
+
+end
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb
new file mode 100644
index 0000000000..6c9134fc62
--- /dev/null
+++ b/lib/rdoc/parsers/parse_c.rb
@@ -0,0 +1,523 @@
+ # We attempt to parse C extension files. Basically we look for
+ # the standard patterns that you find in extensions: <tt>rb_define_class,
+ # rb_define_method</tt> and so on. We also try to find the corresponding
+ # C source for the methods and extract comments, but if we fail
+ # we don't worry too much.
+ #
+ # The comments associated with a Ruby method are extracted from the C
+ # comment block associated with the routine that _implements_ that
+ # method, that is to say the method whose name is given in the
+ # <tt>rb_define_method</tt> call. For example, you might write:
+ #
+ # /*
+ # * Returns a new array that is a one-dimensional flattening of this
+ # * array (recursively). That is, for every element that is an array,
+ # * extract its elements into the new array.
+ # *
+ # * s = [ 1, 2, 3 ] #=> [1, 2, 3]
+ # * t = [ 4, 5, 6, [7, 8] ] #=> [4, 5, 6, [7, 8]]
+ # * a = [ s, t, 9, 10 ] #=> [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10]
+ # * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+ # */
+ # static VALUE
+ # rb_ary_flatten(ary)
+ # VALUE ary;
+ # {
+ # ary = rb_obj_dup(ary);
+ # rb_ary_flatten_bang(ary);
+ # return ary;
+ # }
+ #
+ # ...
+ #
+ # void
+ # Init_Array()
+ # {
+ # ...
+ # rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
+ #
+ # Here RDoc will determine from the rb_define_method line that there's a
+ # method called "flatten" in class Array, and will look for the implementation
+ # in the method rb_ary_flatten. It will then use the comment from that
+ # method in the HTML output. This method must be in the same source file
+ # as the rb_define_method.
+ #
+ # C classes can be diagramed (see /tc/dl/ruby/ruby/error.c), and RDoc
+ # integrates C and Ruby source into one tree
+ #
+ # The comment blocks may include special direcives:
+ #
+ # [Document-class: <i>name</i>]
+ # This comment block is documentation for the given class. Use this
+ # when the <tt>Init_xxx</tt> method is not named after the class.
+ #
+ # [Document-method: <i>name</i>]
+ # This comment documents the named method. Use when RDoc cannot outomatically
+ # find the method from it's declaration
+ #
+ # [call-seq: <i>text up to an empty line</i>]
+ # Because C source doesn't give descripive names to Ruby-level parameters,
+ # you need to document the calling sequence explicitly
+ #
+ # In additon, RDoc assumes by default that the C method implementing a
+ # Ruby function is in the same source file as the rb_define_method call.
+ # If this isn't the case, add the comment
+ #
+ # rb_define_method(....); // in: filename
+ #
+ # As an example, we might have an extension that defines multiple classes
+ # in its Init_xxx method. We could document them using
+ #
+ #
+ # /*
+ # * Document-class: MyClass
+ # *
+ # * Encapsulate the writing and reading of the configuration
+ # * file. ...
+ # */
+ #
+ # /*
+ # * Document-method: read_value
+ # *
+ # * call-seq:
+ # * cfg.read_value(key) -> value
+ # * cfg.read_value(key} { |key| } -> value
+ # *
+ # * Return the value corresponding to +key+ from the configuration.
+ # * In the second form, if the key isn't found, invoke the
+ # * block and return its value.
+ # */
+ #
+
+
+ # Classes and modules built in to the interpreter. We need
+ # these to define superclasses of user objects
+
+require "rdoc/code_objects"
+require "rdoc/parsers/parserfactory"
+
+
+module RDoc
+
+ KNOWN_CLASSES = {
+ "rb_cObject" => "Object",
+ "rb_cArray" => "Array",
+ "rb_cBignum" => "Bignum",
+ "rb_cClass" => "Class",
+ "rb_cDir" => "Dir",
+ "rb_cData" => "Data",
+ "rb_cFalseClass" => "FalseClass",
+ "rb_cFile" => "File",
+ "rb_cFixnum" => "Fixnum",
+ "rb_cFloat" => "Float",
+ "rb_cHash" => "Hash",
+ "rb_cInteger" => "Integer",
+ "rb_cIO" => "IO",
+ "rb_cModule" => "Module",
+ "rb_cNilClass" => "NilClass",
+ "rb_cNumeric" => "Numeric",
+ "rb_cProc" => "Proc",
+ "rb_cRange" => "Range",
+ "rb_cRegexp" => "Regexp",
+ "rb_cString" => "String",
+ "rb_cSymbol" => "Symbol",
+ "rb_cThread" => "Thread",
+ "rb_cTime" => "Time",
+ "rb_cTrueClass" => "TrueClass",
+ "rb_cStruct" => "Struct",
+ "rb_eException" => "Exception",
+ "rb_eStandardError" => "StandardError",
+ "rb_eSystemExit" => "SystemExit",
+ "rb_eInterrupt" => "Interrupt",
+ "rb_eSignal" => "Signal",
+ "rb_eFatal" => "Fatal",
+ "rb_eArgError" => "ArgError",
+ "rb_eEOFError" => "EOFError",
+ "rb_eIndexError" => "IndexError",
+ "rb_eRangeError" => "RangeError",
+ "rb_eIOError" => "IOError",
+ "rb_eRuntimeError" => "RuntimeError",
+ "rb_eSecurityError" => "SecurityError",
+ "rb_eSystemCallError" => "SystemCallError",
+ "rb_eTypeError" => "TypeError",
+ "rb_eZeroDivError" => "ZeroDivError",
+ "rb_eNotImpError" => "NotImpError",
+ "rb_eNoMemError" => "NoMemError",
+ "rb_eFloatDomainError" => "FloatDomainError",
+ "rb_eScriptError" => "ScriptError",
+ "rb_eNameError" => "NameError",
+ "rb_eSyntaxError" => "SyntaxError",
+ "rb_eLoadError" => "LoadError",
+
+ "rb_mKernel" => "Kernel",
+ "rb_mComparable" => "Comparable",
+ "rb_mEnumerable" => "Enumerable",
+ "rb_mPrecision" => "Precision",
+ "rb_mErrno" => "Errno",
+ "rb_mFileTest" => "FileTest",
+ "rb_mGC" => "GC",
+ "rb_mMath" => "Math",
+ "rb_mProcess" => "Process"
+
+ }
+
+ # See rdoc/c_parse.rb
+
+ class C_Parser
+
+
+ extend ParserFactory
+ parse_files_matching(/\.(c|cc|cpp|CC)$/)
+
+ @@known_bodies = {}
+
+ # prepare to parse a C file
+ def initialize(top_level, file_name, body, options, stats)
+ @known_classes = KNOWN_CLASSES.dup
+ @body = handle_ifdefs_in(body)
+ @options = options
+ @stats = stats
+ @top_level = top_level
+ @classes = Hash.new
+ @file_dir = File.dirname(file_name)
+ end
+
+ # Extract the classes/modules and methods from a C file
+ # and return the corresponding top-level object
+ def scan
+ remove_commented_out_lines
+ do_classes
+ do_methods
+ do_includes
+ do_aliases
+ @top_level
+ end
+
+ #######
+ private
+ #######
+
+ # remove lines that are commented out that might otherwise get
+ # picked up when scanning for classes and methods
+
+ def remove_commented_out_lines
+ @body.gsub!(%r{//.*rb_define_}, '//')
+ end
+
+ def handle_class_module(var_name, class_mod, class_name, parent, in_module)
+ parent_name = @known_classes[parent] || parent
+
+ if in_module
+ enclosure = @classes[in_module]
+ unless enclosure
+ $stderr.puts("Enclosing class/module '#{in_module}' for " +
+ "#{class_mod} #{class_name} not known")
+ return
+ end
+ else
+ enclosure = @top_level
+ end
+
+ if class_mod == "class"
+ cm = enclosure.add_class(NormalClass, class_name, parent_name)
+ @stats.num_classes += 1
+ else
+ cm = enclosure.add_module(NormalModule, class_name)
+ @stats.num_modules += 1
+ end
+ cm.record_location(enclosure.toplevel)
+
+ find_class_comment(cm.full_name, cm)
+ @classes[var_name] = cm
+ @known_classes[var_name] = cm.full_name
+ end
+
+
+ ############################################################
+
+ def find_class_comment(class_name, class_meth)
+ comment = nil
+ if @body =~ %r{((?>/\*.*?\*/\s+))
+ (static\s+)?void\s+Init_#{class_name}\s*\(\)}xmi
+ comment = $1
+ elsif @body =~ %r{Document-(class|module):\s#{class_name}.*?\n((?>.*?\*/))}m
+ comment = $2
+ end
+ class_meth.comment = mangle_comment(comment) if comment
+ end
+
+ ############################################################
+
+ def do_classes
+ @body.scan(/(\w+)\s* = \s*rb_define_module\(\s*"(\w+)"\s*\)/mx) do
+ |var_name, class_name|
+ handle_class_module(var_name, "module", class_name, nil, nil)
+ end
+
+ # The '.' lets us handle SWIG-generated files
+ @body.scan(/([\w\.]+)\s* = \s*rb_define_class
+ \(
+ \s*"(\w+)",
+ \s*(\w+)\s*
+ \)/mx) do
+
+ |var_name, class_name, parent|
+ handle_class_module(var_name, "class", class_name, parent, nil)
+ end
+
+ @body.scan(/(\w+)\s*=\s*boot_defclass\(\s*"(\w+?)",\s*(\w+?)\)/) do
+ |var_name, class_name, parent|
+ parent = nil if parent == "0"
+ handle_class_module(var_name, "class", class_name, parent, nil)
+ end
+
+ @body.scan(/(\w+)\s* = \s*rb_define_module_under\s*
+ \(
+ \s*(\w+),
+ \s*"(\w+)"
+ \s*\)/mx) do
+
+ |var_name, in_module, class_name|
+ handle_class_module(var_name, "module", class_name, nil, in_module)
+ end
+
+ @body.scan(/([\w\.]+)\s* = \s*rb_define_class_under
+ \(
+ \s*(\w+),
+ \s*"(\w+)",
+ \s*(\w+)\s*
+ \)/mx) do
+
+ |var_name, in_module, class_name, parent|
+ handle_class_module(var_name, "class", class_name, parent, in_module)
+ end
+
+ end
+
+ ############################################################
+
+ def do_methods
+
+ @body.scan(%r{rb_define_
+ (
+ singleton_method |
+ method |
+ module_function |
+ private_method
+ )
+ \(\s*([\w\.]+),
+ \s*"([^"]+)",
+ \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
+ \s*(-?\w+)\s*\)
+ (?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))?
+ }xm) do
+ |type, var_name, meth_name, meth_body, param_count, source_file|
+ #"
+
+ # Ignore top-object and weird struct.c dynamic stuff
+ next if var_name == "ruby_top_self"
+ next if var_name == "nstr"
+ next if var_name == "envtbl"
+ next if var_name == "argf" # it'd be nice to handle this one
+
+ var_name = "rb_cObject" if var_name == "rb_mKernel"
+ handle_method(type, var_name, meth_name,
+ meth_body, param_count, source_file)
+ end
+
+ @body.scan(%r{rb_define_global_function\(
+ \s*"([^"]+)",
+ \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
+ \s*(-?\w+)\s*\)
+ (?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))?
+ }xm) do #"
+ |meth_name, meth_body, param_count, source_file|
+ handle_method("method", "rb_mKernel", meth_name,
+ meth_body, param_count, source_file)
+ end
+
+ @body.scan(/define_filetest_function\(
+ \s*"([^"]+)",
+ \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
+ \s*(-?\w+)\s*\)/xm) do #"
+ |meth_name, meth_body, param_count|
+
+ handle_method("method", "rb_mFileTest", meth_name, meth_body, param_count)
+ handle_method("singleton_method", "rb_cFile", meth_name, meth_body, param_count)
+ end
+ end
+
+ ############################################################
+
+ def do_aliases
+ @body.scan(%r{rb_define_alias\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
+ |var_name, new_name, old_name|
+ @stats.num_methods += 1
+ class_name = @known_classes[var_name] || var_name
+ class_obj = find_class(var_name, class_name)
+
+ class_obj.add_alias(Alias.new("", old_name, new_name, ""))
+ end
+ end
+
+ ############################################################
+
+ def handle_method(type, var_name, meth_name,
+ meth_body, param_count, source_file = nil)
+ @stats.num_methods += 1
+ class_name = @known_classes[var_name]
+
+ return unless class_name
+
+ class_obj = find_class(var_name, class_name)
+
+ if class_obj
+ if meth_name == "initialize"
+ meth_name = "new"
+ type = "singleton_method"
+ end
+ meth_obj = AnyMethod.new("", meth_name)
+ meth_obj.singleton = type == "singleton_method"
+
+ p_count = (Integer(param_count) rescue -1)
+
+ if p_count < 0
+ meth_obj.params = "(...)"
+ elsif p_count == 0
+ meth_obj.params = "()"
+ else
+ meth_obj.params = "(" +
+ (1..p_count).map{|i| "p#{i}"}.join(", ") +
+ ")"
+ end
+
+ if source_file
+ file_name = File.join(@file_dir, source_file)
+ body = (@@known_bodies[source_file] ||= File.read(file_name))
+ else
+ body = @body
+ end
+ find_body(meth_body, meth_obj, body)
+ class_obj.add_method(meth_obj)
+ end
+ end
+
+ ############################################################
+
+ # Find the C code corresponding to a Ruby method
+ def find_body(meth_name, meth_obj, body)
+ if body =~ %r{((?>/\*.*?\*/\s*))(static\s+)?VALUE\s+#{meth_name}
+ \s*(\(.*?\)).*?^}xm
+
+ comment, params = $1, $3
+ body_text = $&
+
+ # see if we can find the whole body
+
+ re = Regexp.escape(body_text) + '[^(]*^\{.*?^\}'
+ if Regexp.new(re, Regexp::MULTILINE).match(body)
+ body_text = $&
+ end
+
+ # The comment block may have been overridden with a
+ # 'Document-method' block. This happens in the interpreter
+ # when multiple methods are vectored through to the same
+ # C method but those methods are logically distinct (for
+ # example Kernel.hash and Kernel.object_id share the same
+ # implementation
+
+ override_comment = find_override_comment(meth_obj.name)
+ comment = override_comment if override_comment
+
+ find_call_seq(comment, meth_obj) if comment
+
+# meth_obj.params = params
+ meth_obj.start_collecting_tokens
+ meth_obj.add_token(RubyToken::Token.new(1,1).set_text(body_text))
+ meth_obj.comment = mangle_comment(comment)
+
+ else
+
+ # No body, but might still have an override comment
+ comment = find_override_comment(meth_obj.name)
+
+ if comment
+ find_call_seq(comment, meth_obj)
+ meth_obj.comment = mangle_comment(comment)
+ else
+ $stderr.puts "No definition for #{meth_name}"
+ end
+ end
+ end
+
+
+ ##################################################
+ #
+ # If the comment block contains a section that looks like
+ # call-seq:
+ # Array.new
+ # Array.new(10)
+ # use it for the parameters
+ def find_call_seq(comment, meth_obj)
+ if comment.sub!(/call-seq:(.*?)^\s*\*?\s*$/m, '')
+ seq = $1
+ seq.gsub!(/^\s*\*\s*/, '')
+ meth_obj.call_seq = seq
+ end
+ end
+
+ ############################################################
+
+ def find_override_comment(meth_name)
+ comment = nil
+ name = Regexp.escape(meth_name)
+ if @body =~ %r{Document-method:\s#{name}.*?\n((?>.*?\*/))}m
+ comment = $1
+ end
+ comment
+ end
+
+ ############################################################
+
+ # Look for includes of the form
+ # rb_include_module(rb_cArray, rb_mEnumerable);
+ def do_includes
+ @body.scan(/rb_include_module\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
+ if cls = @classes[c]
+ m = KNOWN_CLASSES[m] || m
+ cls.add_include(Include.new(m, ""))
+ end
+ end
+ end
+
+ ############################################################
+
+ # Remove the /*'s and leading asterisks from C comments
+
+ def mangle_comment(comment)
+ comment.sub!(%r{/\*+}) { " " * $&.length }
+ comment.sub!(%r{\*+/}) { " " * $&.length }
+ comment.gsub!(/^[ \t]*\*/m) { " " * $&.length }
+ comment
+ end
+
+ def find_class(raw_name, name)
+ unless @classes[raw_name]
+ if raw_name =~ /^rb_m/
+ @classes[raw_name] = @top_level.add_module(NormalModule, name)
+ else
+ @classes[raw_name] = @top_level.add_class(NormalClass, name, nil)
+ end
+ end
+ @classes[raw_name]
+ end
+
+ # Remove #ifdefs that would otherwise confuse us
+
+ def handle_ifdefs_in(body)
+ body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\n(.*?)#endif.*?\n/m) { $1 }
+ end
+
+ end
+
+end
diff --git a/lib/rdoc/parsers/parse_f95.rb b/lib/rdoc/parsers/parse_f95.rb
new file mode 100644
index 0000000000..518e421c60
--- /dev/null
+++ b/lib/rdoc/parsers/parse_f95.rb
@@ -0,0 +1,119 @@
+# Parse a Fortran 95 file.
+
+require "rdoc/code_objects"
+
+module RDoc
+
+ # See rdoc/parsers/parse_f95.rb
+
+ class Token
+
+ NO_TEXT = "??".freeze
+
+ def initialize(line_no, char_no)
+ @line_no = line_no
+ @char_no = char_no
+ @text = NO_TEXT
+ end
+ # Because we're used in contexts that expect to return a token,
+ # we set the text string and then return ourselves
+ def set_text(text)
+ @text = text
+ self
+ end
+
+ attr_reader :line_no, :char_no, :text
+
+ end
+
+ class Fortran95parser
+
+ extend ParserFactory
+ parse_files_matching(/\.(f9(0|5)|F)$/)
+
+ # prepare to parse a Fortran 95 file
+ def initialize(top_level, file_name, body, options, stats)
+ @body = body
+ @stats = stats
+ @options = options
+ @top_level = top_level
+ @progress = $stderr unless options.quiet
+ end
+
+ # devine code constructs
+ def scan
+
+ # modules and programs
+ if @body =~ /^(module|program)\s+(\w+)/i
+ progress "m"
+ f9x_module = @top_level.add_module NormalClass, $2
+ f9x_module.record_location @top_level
+ first_comment, second_comment = $`.gsub(/^!\s?/,"").split "\n\s*\n"
+ if second_comment
+ @top_level.comment = first_comment if first_comment
+ f9x_module.comment = second_comment
+ else
+ f9x_module.comment = first_comment if first_comment
+ end
+ end
+
+ # use modules
+ remaining_code = @body
+ while remaining_code =~ /^\s*use\s+(\w+)/i
+ remaining_code = $~.post_match
+ progress "."
+ f9x_module.add_include Include.new($1, "") if f9x_module
+ end
+
+ # subroutines
+ remaining_code = @body
+ while remaining_code =~ /^\s*subroutine\s+(\w+)\s*\((.*?)\)/im
+ remaining_code = $~.post_match
+ subroutine = AnyMethod.new("Text", $1)
+ subroutine.singleton = false
+
+ prematchText = $~.pre_match
+ params = $2
+ params.gsub!(/&/,'')
+ subroutine.params = params
+ comment = find_comments prematchText
+ subroutine.comment = comment if comment
+
+ subroutine.start_collecting_tokens
+ remaining_code =~ /^\s*end\s+subroutine/i
+ code = "subroutine #{subroutine.name} (#{subroutine.params})\n"
+ code += $~.pre_match
+ code += "\nend subroutine\n"
+ subroutine.add_token Token.new(1,1).set_text(code)
+
+ progress "s"
+ f9x_module.add_method subroutine if f9x_module
+ end
+
+ @top_level
+
+ end
+
+ def find_comments text
+ lines = text.split("\n").reverse
+ comment_block = Array.new
+ lines.each do |line|
+ break if line =~ /^\s*\w/
+ comment_block.unshift line.sub(/^!\s?/,"")
+ end
+ nice_lines = comment_block.join("\n").split "\n\s*\n"
+ nice_lines.shift
+ nice_lines.shift
+ nice_lines.shift
+ end
+
+ def progress(char)
+ unless @options.quiet
+ @progress.print(char)
+ @progress.flush
+ end
+ end
+
+ end # class Fortran95parser
+
+end # module RDoc
diff --git a/lib/rdoc/parsers/parse_rb.rb b/lib/rdoc/parsers/parse_rb.rb
new file mode 100644
index 0000000000..5a98258f7e
--- /dev/null
+++ b/lib/rdoc/parsers/parse_rb.rb
@@ -0,0 +1,2594 @@
+#!/usr/local/bin/ruby
+
+# Parse a Ruby source file, building a set of objects
+# representing the modules, classes, methods,
+# requires, and includes we find (these classes
+# are defined in code_objects.rb).
+
+# This file contains stuff stolen outright from:
+#
+# rtags.rb -
+# ruby-lex.rb - ruby lexcal analizer
+# ruby-token.rb - ruby tokens
+# by Keiju ISHITSUKA (Nippon Rational Inc.)
+#
+
+require "tracer"
+require "e2mmap"
+require "irb/slex"
+
+require "rdoc/code_objects"
+require "rdoc/tokenstream"
+
+require "rdoc/markup/simple_markup/preprocess"
+
+require "rdoc/parsers/parserfactory"
+
+$TOKEN_DEBUG = $DEBUG
+
+# Definitions of all tokens involved in the lexical analysis
+
+module RubyToken
+ EXPR_BEG = :EXPR_BEG
+ EXPR_MID = :EXPR_MID
+ EXPR_END = :EXPR_END
+ EXPR_ARG = :EXPR_ARG
+ EXPR_FNAME = :EXPR_FNAME
+ EXPR_DOT = :EXPR_DOT
+ EXPR_CLASS = :EXPR_CLASS
+
+ class Token
+ NO_TEXT = "??".freeze
+ attr :text
+
+ def initialize(line_no, char_no)
+ @line_no = line_no
+ @char_no = char_no
+ @text = NO_TEXT
+ end
+
+ # Because we're used in contexts that expect to return a token,
+ # we set the text string and then return ourselves
+ def set_text(text)
+ @text = text
+ self
+ end
+
+ attr_reader :line_no, :char_no, :text
+ end
+
+ class TkNode < Token
+ attr :node
+ end
+
+ class TkId < Token
+ def initialize(line_no, char_no, name)
+ super(line_no, char_no)
+ @name = name
+ end
+ attr :name
+ end
+
+ class TkKW < TkId
+ end
+
+ class TkVal < Token
+ def initialize(line_no, char_no, value = nil)
+ super(line_no, char_no)
+ set_text(value)
+ end
+ end
+
+ class TkOp < Token
+ def name
+ self.class.op_name
+ end
+ end
+
+ class TkOPASGN < TkOp
+ def initialize(line_no, char_no, op)
+ super(line_no, char_no)
+ op = TkReading2Token[op] unless op.kind_of?(Symbol)
+ @op = op
+ end
+ attr :op
+ end
+
+ class TkUnknownChar < Token
+ def initialize(line_no, char_no, id)
+ super(line_no, char_no)
+ @name = char_no.chr
+ end
+ attr :name
+ end
+
+ class TkError < Token
+ end
+
+ def set_token_position(line, char)
+ @prev_line_no = line
+ @prev_char_no = char
+ end
+
+ def Token(token, value = nil)
+ tk = nil
+ case token
+ when String, Symbol
+ source = token.kind_of?(String) ? TkReading2Token : TkSymbol2Token
+ if (tk = source[token]).nil?
+ IRB.fail TkReading2TokenNoKey, token
+ end
+ tk = Token(tk[0], value)
+ else
+ tk = if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
+ token.new(@prev_line_no, @prev_char_no)
+ else
+ token.new(@prev_line_no, @prev_char_no, value)
+ end
+ end
+ tk
+ end
+
+ TokenDefinitions = [
+ [:TkCLASS, TkKW, "class", EXPR_CLASS],
+ [:TkMODULE, TkKW, "module", EXPR_BEG],
+ [:TkDEF, TkKW, "def", EXPR_FNAME],
+ [:TkUNDEF, TkKW, "undef", EXPR_FNAME],
+ [:TkBEGIN, TkKW, "begin", EXPR_BEG],
+ [:TkRESCUE, TkKW, "rescue", EXPR_MID],
+ [:TkENSURE, TkKW, "ensure", EXPR_BEG],
+ [:TkEND, TkKW, "end", EXPR_END],
+ [:TkIF, TkKW, "if", EXPR_BEG, :TkIF_MOD],
+ [:TkUNLESS, TkKW, "unless", EXPR_BEG, :TkUNLESS_MOD],
+ [:TkTHEN, TkKW, "then", EXPR_BEG],
+ [:TkELSIF, TkKW, "elsif", EXPR_BEG],
+ [:TkELSE, TkKW, "else", EXPR_BEG],
+ [:TkCASE, TkKW, "case", EXPR_BEG],
+ [:TkWHEN, TkKW, "when", EXPR_BEG],
+ [:TkWHILE, TkKW, "while", EXPR_BEG, :TkWHILE_MOD],
+ [:TkUNTIL, TkKW, "until", EXPR_BEG, :TkUNTIL_MOD],
+ [:TkFOR, TkKW, "for", EXPR_BEG],
+ [:TkBREAK, TkKW, "break", EXPR_END],
+ [:TkNEXT, TkKW, "next", EXPR_END],
+ [:TkREDO, TkKW, "redo", EXPR_END],
+ [:TkRETRY, TkKW, "retry", EXPR_END],
+ [:TkIN, TkKW, "in", EXPR_BEG],
+ [:TkDO, TkKW, "do", EXPR_BEG],
+ [:TkRETURN, TkKW, "return", EXPR_MID],
+ [:TkYIELD, TkKW, "yield", EXPR_END],
+ [:TkSUPER, TkKW, "super", EXPR_END],
+ [:TkSELF, TkKW, "self", EXPR_END],
+ [:TkNIL, TkKW, "nil", EXPR_END],
+ [:TkTRUE, TkKW, "true", EXPR_END],
+ [:TkFALSE, TkKW, "false", EXPR_END],
+ [:TkAND, TkKW, "and", EXPR_BEG],
+ [:TkOR, TkKW, "or", EXPR_BEG],
+ [:TkNOT, TkKW, "not", EXPR_BEG],
+ [:TkIF_MOD, TkKW],
+ [:TkUNLESS_MOD, TkKW],
+ [:TkWHILE_MOD, TkKW],
+ [:TkUNTIL_MOD, TkKW],
+ [:TkALIAS, TkKW, "alias", EXPR_FNAME],
+ [:TkDEFINED, TkKW, "defined?", EXPR_END],
+ [:TklBEGIN, TkKW, "BEGIN", EXPR_END],
+ [:TklEND, TkKW, "END", EXPR_END],
+ [:Tk__LINE__, TkKW, "__LINE__", EXPR_END],
+ [:Tk__FILE__, TkKW, "__FILE__", EXPR_END],
+
+ [:TkIDENTIFIER, TkId],
+ [:TkFID, TkId],
+ [:TkGVAR, TkId],
+ [:TkIVAR, TkId],
+ [:TkCONSTANT, TkId],
+
+ [:TkINTEGER, TkVal],
+ [:TkFLOAT, TkVal],
+ [:TkSTRING, TkVal],
+ [:TkXSTRING, TkVal],
+ [:TkREGEXP, TkVal],
+ [:TkCOMMENT, TkVal],
+
+ [:TkDSTRING, TkNode],
+ [:TkDXSTRING, TkNode],
+ [:TkDREGEXP, TkNode],
+ [:TkNTH_REF, TkId],
+ [:TkBACK_REF, TkId],
+
+ [:TkUPLUS, TkOp, "+@"],
+ [:TkUMINUS, TkOp, "-@"],
+ [:TkPOW, TkOp, "**"],
+ [:TkCMP, TkOp, "<=>"],
+ [:TkEQ, TkOp, "=="],
+ [:TkEQQ, TkOp, "==="],
+ [:TkNEQ, TkOp, "!="],
+ [:TkGEQ, TkOp, ">="],
+ [:TkLEQ, TkOp, "<="],
+ [:TkANDOP, TkOp, "&&"],
+ [:TkOROP, TkOp, "||"],
+ [:TkMATCH, TkOp, "=~"],
+ [:TkNMATCH, TkOp, "!~"],
+ [:TkDOT2, TkOp, ".."],
+ [:TkDOT3, TkOp, "..."],
+ [:TkAREF, TkOp, "[]"],
+ [:TkASET, TkOp, "[]="],
+ [:TkLSHFT, TkOp, "<<"],
+ [:TkRSHFT, TkOp, ">>"],
+ [:TkCOLON2, TkOp],
+ [:TkCOLON3, TkOp],
+# [:OPASGN, TkOp], # +=, -= etc. #
+ [:TkASSOC, TkOp, "=>"],
+ [:TkQUESTION, TkOp, "?"], #?
+ [:TkCOLON, TkOp, ":"], #:
+
+ [:TkfLPAREN], # func( #
+ [:TkfLBRACK], # func[ #
+ [:TkfLBRACE], # func{ #
+ [:TkSTAR], # *arg
+ [:TkAMPER], # &arg #
+ [:TkSYMBOL, TkId], # :SYMBOL
+ [:TkSYMBEG, TkId],
+ [:TkGT, TkOp, ">"],
+ [:TkLT, TkOp, "<"],
+ [:TkPLUS, TkOp, "+"],
+ [:TkMINUS, TkOp, "-"],
+ [:TkMULT, TkOp, "*"],
+ [:TkDIV, TkOp, "/"],
+ [:TkMOD, TkOp, "%"],
+ [:TkBITOR, TkOp, "|"],
+ [:TkBITXOR, TkOp, "^"],
+ [:TkBITAND, TkOp, "&"],
+ [:TkBITNOT, TkOp, "~"],
+ [:TkNOTOP, TkOp, "!"],
+
+ [:TkBACKQUOTE, TkOp, "`"],
+
+ [:TkASSIGN, Token, "="],
+ [:TkDOT, Token, "."],
+ [:TkLPAREN, Token, "("], #(exp)
+ [:TkLBRACK, Token, "["], #[arry]
+ [:TkLBRACE, Token, "{"], #{hash}
+ [:TkRPAREN, Token, ")"],
+ [:TkRBRACK, Token, "]"],
+ [:TkRBRACE, Token, "}"],
+ [:TkCOMMA, Token, ","],
+ [:TkSEMICOLON, Token, ";"],
+
+ [:TkRD_COMMENT],
+ [:TkSPACE],
+ [:TkNL],
+ [:TkEND_OF_SCRIPT],
+
+ [:TkBACKSLASH, TkUnknownChar, "\\"],
+ [:TkAT, TkUnknownChar, "@"],
+ [:TkDOLLAR, TkUnknownChar, "\$"], #"
+ ]
+
+ # {reading => token_class}
+ # {reading => [token_class, *opt]}
+ TkReading2Token = {}
+ TkSymbol2Token = {}
+
+ def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
+ token_n = token_n.id2name unless token_n.kind_of?(String)
+ if RubyToken.const_defined?(token_n)
+ IRB.fail AlreadyDefinedToken, token_n
+ end
+
+ token_c = Class.new super_token
+ RubyToken.const_set token_n, token_c
+# token_c.inspect
+
+ if reading
+ if TkReading2Token[reading]
+ IRB.fail TkReading2TokenDuplicateError, token_n, reading
+ end
+ if opts.empty?
+ TkReading2Token[reading] = [token_c]
+ else
+ TkReading2Token[reading] = [token_c].concat(opts)
+ end
+ end
+ TkSymbol2Token[token_n.intern] = token_c
+
+ if token_c <= TkOp
+ token_c.class_eval %{
+ def self.op_name; "#{reading}"; end
+ }
+ end
+ end
+
+ for defs in TokenDefinitions
+ def_token(*defs)
+ end
+
+ NEWLINE_TOKEN = TkNL.new(0,0)
+ NEWLINE_TOKEN.set_text("\n")
+
+end
+
+
+
+# Lexical analyzer for Ruby source
+
+class RubyLex
+
+ ######################################################################
+ #
+ # Read an input stream character by character. We allow for unlimited
+ # ungetting of characters just read.
+ #
+ # We simplify the implementation greatly by reading the entire input
+ # into a buffer initially, and then simply traversing it using
+ # pointers.
+ #
+ # We also have to allow for the <i>here document diversion</i>. This
+ # little gem comes about when the lexer encounters a here
+ # document. At this point we effectively need to split the input
+ # stream into two parts: one to read the body of the here document,
+ # the other to read the rest of the input line where the here
+ # document was initially encountered. For example, we might have
+ #
+ # do_something(<<-A, <<-B)
+ # stuff
+ # for
+ # A
+ # stuff
+ # for
+ # B
+ #
+ # When the lexer encounters the <<A, it reads until the end of the
+ # line, and keeps it around for later. It then reads the body of the
+ # here document. Once complete, it needs to read the rest of the
+ # original line, but then skip the here document body.
+ #
+
+ class BufferedReader
+
+ attr_reader :line_num
+
+ def initialize(content)
+ if /\t/ =~ content
+ tab_width = Options.instance.tab_width
+ content = content.split(/\n/).map do |line|
+ 1 while line.gsub!(/\t+/) { ' ' * (tab_width*$&.length - $`.length % tab_width)} && $~ #`
+ line
+ end .join("\n")
+ end
+ @content = content
+ @content << "\n" unless @content[-1,1] == "\n"
+ @size = @content.size
+ @offset = 0
+ @hwm = 0
+ @line_num = 1
+ @read_back_offset = 0
+ @last_newline = 0
+ @newline_pending = false
+ end
+
+ def column
+ @offset - @last_newline
+ end
+
+ def getc
+ return nil if @offset >= @size
+ ch = @content[@offset, 1]
+
+ @offset += 1
+ @hwm = @offset if @hwm < @offset
+
+ if @newline_pending
+ @line_num += 1
+ @last_newline = @offset - 1
+ @newline_pending = false
+ end
+
+ if ch == "\n"
+ @newline_pending = true
+ end
+ ch
+ end
+
+ def getc_already_read
+ getc
+ end
+
+ def ungetc(ch)
+ raise "unget past beginning of file" if @offset <= 0
+ @offset -= 1
+ if @content[@offset] == ?\n
+ @newline_pending = false
+ end
+ end
+
+ def get_read
+ res = @content[@read_back_offset...@offset]
+ @read_back_offset = @offset
+ res
+ end
+
+ def peek(at)
+ pos = @offset + at
+ if pos >= @size
+ nil
+ else
+ @content[pos, 1]
+ end
+ end
+
+ def peek_equal(str)
+ @content[@offset, str.length] == str
+ end
+
+ def divert_read_from(reserve)
+ @content[@offset, 0] = reserve
+ @size = @content.size
+ end
+ end
+
+ # end of nested class BufferedReader
+
+ extend Exception2MessageMapper
+ def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
+ def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
+ def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
+ def_exception(:TkReading2TokenDuplicateError,
+ "key duplicate(token_n='%s', key='%s')")
+ def_exception(:SyntaxError, "%s")
+
+ include RubyToken
+
+ attr_reader :continue
+ attr_reader :lex_state
+
+ def RubyLex.debug?
+ false
+ end
+
+ def initialize(content)
+ lex_init
+
+ @reader = BufferedReader.new(content)
+
+ @exp_line_no = @line_no = 1
+ @base_char_no = 0
+ @indent = 0
+
+ @ltype = nil
+ @quoted = nil
+ @lex_state = EXPR_BEG
+ @space_seen = false
+
+ @continue = false
+ @line = ""
+
+ @skip_space = false
+ @read_auto_clean_up = false
+ @exception_on_syntax_error = true
+ end
+
+ attr :skip_space, true
+ attr :read_auto_clean_up, true
+ attr :exception_on_syntax_error, true
+
+ attr :indent
+
+ # io functions
+ def line_no
+ @reader.line_num
+ end
+
+ def char_no
+ @reader.column
+ end
+
+ def get_read
+ @reader.get_read
+ end
+
+ def getc
+ @reader.getc
+ end
+
+ def getc_of_rests
+ @reader.getc_already_read
+ end
+
+ def gets
+ c = getc or return
+ l = ""
+ begin
+ l.concat c unless c == "\r"
+ break if c == "\n"
+ end while c = getc
+ l
+ end
+
+
+ def ungetc(c = nil)
+ @reader.ungetc(c)
+ end
+
+ def peek_equal?(str)
+ @reader.peek_equal(str)
+ end
+
+ def peek(i = 0)
+ @reader.peek(i)
+ end
+
+ def lex
+ until (((tk = token).kind_of?(TkNL) || tk.kind_of?(TkEND_OF_SCRIPT)) &&
+ !@continue or
+ tk.nil?)
+ end
+ line = get_read
+
+ if line == "" and tk.kind_of?(TkEND_OF_SCRIPT) || tk.nil?
+ nil
+ else
+ line
+ end
+ end
+
+ def token
+ set_token_position(line_no, char_no)
+ begin
+ begin
+ tk = @OP.match(self)
+ @space_seen = tk.kind_of?(TkSPACE)
+ rescue SyntaxError
+ abort if @exception_on_syntax_error
+ tk = TkError.new(line_no, char_no)
+ end
+ end while @skip_space and tk.kind_of?(TkSPACE)
+ if @read_auto_clean_up
+ get_read
+ end
+# throw :eof unless tk
+ p tk if $DEBUG
+ tk
+ end
+
+ ENINDENT_CLAUSE = [
+ "case", "class", "def", "do", "for", "if",
+ "module", "unless", "until", "while", "begin" #, "when"
+ ]
+ DEINDENT_CLAUSE = ["end" #, "when"
+ ]
+
+ PERCENT_LTYPE = {
+ "q" => "\'",
+ "Q" => "\"",
+ "x" => "\`",
+ "r" => "\/",
+ "w" => "]"
+ }
+
+ PERCENT_PAREN = {
+ "{" => "}",
+ "[" => "]",
+ "<" => ">",
+ "(" => ")"
+ }
+
+ Ltype2Token = {
+ "\'" => TkSTRING,
+ "\"" => TkSTRING,
+ "\`" => TkXSTRING,
+ "\/" => TkREGEXP,
+ "]" => TkDSTRING
+ }
+ Ltype2Token.default = TkSTRING
+
+ DLtype2Token = {
+ "\"" => TkDSTRING,
+ "\`" => TkDXSTRING,
+ "\/" => TkDREGEXP,
+ }
+
+ def lex_init()
+ @OP = SLex.new
+ @OP.def_rules("\0", "\004", "\032") do |chars, io|
+ Token(TkEND_OF_SCRIPT).set_text(chars)
+ end
+
+ @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |chars, io|
+ @space_seen = TRUE
+ while (ch = getc) =~ /[ \t\f\r\13]/
+ chars << ch
+ end
+ ungetc
+ Token(TkSPACE).set_text(chars)
+ end
+
+ @OP.def_rule("#") do
+ |op, io|
+ identify_comment
+ end
+
+ @OP.def_rule("=begin", proc{@prev_char_no == 0 && peek(0) =~ /\s/}) do
+ |op, io|
+ str = op
+ @ltype = "="
+
+
+ begin
+ line = ""
+ begin
+ ch = getc
+ line << ch
+ end until ch == "\n"
+ str << line
+ end until line =~ /^=end/
+
+ ungetc
+
+ @ltype = nil
+
+ if str =~ /\A=begin\s+rdoc/i
+ str.sub!(/\A=begin.*\n/, '')
+ str.sub!(/^=end.*/m, '')
+ Token(TkCOMMENT).set_text(str)
+ else
+ Token(TkRD_COMMENT)#.set_text(str)
+ end
+ end
+
+ @OP.def_rule("\n") do
+ print "\\n\n" if RubyLex.debug?
+ case @lex_state
+ when EXPR_BEG, EXPR_FNAME, EXPR_DOT
+ @continue = TRUE
+ else
+ @continue = FALSE
+ @lex_state = EXPR_BEG
+ end
+ Token(TkNL).set_text("\n")
+ end
+
+ @OP.def_rules("*", "**",
+ "!", "!=", "!~",
+ "=", "==", "===",
+ "=~", "<=>",
+ "<", "<=",
+ ">", ">=", ">>") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op).set_text(op)
+ end
+
+ @OP.def_rules("<<") do
+ |op, io|
+ tk = nil
+ if @lex_state != EXPR_END && @lex_state != EXPR_CLASS &&
+ (@lex_state != EXPR_ARG || @space_seen)
+ c = peek(0)
+ if /[-\w_\"\'\`]/ =~ c
+ tk = identify_here_document
+ end
+ end
+ if !tk
+ @lex_state = EXPR_BEG
+ tk = Token(op).set_text(op)
+ end
+ tk
+ end
+
+ @OP.def_rules("'", '"') do
+ |op, io|
+ identify_string(op)
+ end
+
+ @OP.def_rules("`") do
+ |op, io|
+ if @lex_state == EXPR_FNAME
+ Token(op).set_text(op)
+ else
+ identify_string(op)
+ end
+ end
+
+ @OP.def_rules('?') do
+ |op, io|
+ if @lex_state == EXPR_END
+ @lex_state = EXPR_BEG
+ Token(TkQUESTION).set_text(op)
+ else
+ ch = getc
+ if @lex_state == EXPR_ARG && ch !~ /\s/
+ ungetc
+ @lex_state = EXPR_BEG;
+ Token(TkQUESTION).set_text(op)
+ else
+ str = op
+ str << ch
+ if (ch == '\\') #'
+ str << read_escape
+ end
+ @lex_state = EXPR_END
+ Token(TkINTEGER).set_text(str)
+ end
+ end
+ end
+
+ @OP.def_rules("&", "&&", "|", "||") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op).set_text(op)
+ end
+
+ @OP.def_rules("+=", "-=", "*=", "**=",
+ "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ op =~ /^(.*)=$/
+ Token(TkOPASGN, $1).set_text(op)
+ end
+
+ @OP.def_rule("+@", proc{@lex_state == EXPR_FNAME}) do |op, io|
+ Token(TkUPLUS).set_text(op)
+ end
+
+ @OP.def_rule("-@", proc{@lex_state == EXPR_FNAME}) do |op, io|
+ Token(TkUMINUS).set_text(op)
+ end
+
+ @OP.def_rules("+", "-") do
+ |op, io|
+ catch(:RET) do
+ if @lex_state == EXPR_ARG
+ if @space_seen and peek(0) =~ /[0-9]/
+ throw :RET, identify_number(op)
+ else
+ @lex_state = EXPR_BEG
+ end
+ elsif @lex_state != EXPR_END and peek(0) =~ /[0-9]/
+ throw :RET, identify_number(op)
+ else
+ @lex_state = EXPR_BEG
+ end
+ Token(op).set_text(op)
+ end
+ end
+
+ @OP.def_rule(".") do
+ @lex_state = EXPR_BEG
+ if peek(0) =~ /[0-9]/
+ ungetc
+ identify_number("")
+ else
+ # for obj.if
+ @lex_state = EXPR_DOT
+ Token(TkDOT).set_text(".")
+ end
+ end
+
+ @OP.def_rules("..", "...") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op).set_text(op)
+ end
+
+ lex_int2
+ end
+
+ def lex_int2
+ @OP.def_rules("]", "}", ")") do
+ |op, io|
+ @lex_state = EXPR_END
+ @indent -= 1
+ Token(op).set_text(op)
+ end
+
+ @OP.def_rule(":") do
+ if @lex_state == EXPR_END || peek(0) =~ /\s/
+ @lex_state = EXPR_BEG
+ tk = Token(TkCOLON)
+ else
+ @lex_state = EXPR_FNAME;
+ tk = Token(TkSYMBEG)
+ end
+ tk.set_text(":")
+ end
+
+ @OP.def_rule("::") do
+# p @lex_state.id2name, @space_seen
+ if @lex_state == EXPR_BEG or @lex_state == EXPR_ARG && @space_seen
+ @lex_state = EXPR_BEG
+ tk = Token(TkCOLON3)
+ else
+ @lex_state = EXPR_DOT
+ tk = Token(TkCOLON2)
+ end
+ tk.set_text("::")
+ end
+
+ @OP.def_rule("/") do
+ |op, io|
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ identify_string(op)
+ elsif peek(0) == '='
+ getc
+ @lex_state = EXPR_BEG
+ Token(TkOPASGN, :/).set_text("/=") #")
+ elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
+ identify_string(op)
+ else
+ @lex_state = EXPR_BEG
+ Token("/").set_text(op)
+ end
+ end
+
+ @OP.def_rules("^") do
+ @lex_state = EXPR_BEG
+ Token("^").set_text("^")
+ end
+
+ # @OP.def_rules("^=") do
+ # @lex_state = EXPR_BEG
+ # Token(TkOPASGN, :^)
+ # end
+
+ @OP.def_rules(",", ";") do
+ |op, io|
+ @lex_state = EXPR_BEG
+ Token(op).set_text(op)
+ end
+
+ @OP.def_rule("~") do
+ @lex_state = EXPR_BEG
+ Token("~").set_text("~")
+ end
+
+ @OP.def_rule("~@", proc{@lex_state = EXPR_FNAME}) do
+ @lex_state = EXPR_BEG
+ Token("~").set_text("~@")
+ end
+
+ @OP.def_rule("(") do
+ @indent += 1
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ @lex_state = EXPR_BEG
+ tk = Token(TkfLPAREN)
+ else
+ @lex_state = EXPR_BEG
+ tk = Token(TkLPAREN)
+ end
+ tk.set_text("(")
+ end
+
+ @OP.def_rule("[]", proc{@lex_state == EXPR_FNAME}) do
+ Token("[]").set_text("[]")
+ end
+
+ @OP.def_rule("[]=", proc{@lex_state == EXPR_FNAME}) do
+ Token("[]=").set_text("[]=")
+ end
+
+ @OP.def_rule("[") do
+ @indent += 1
+ if @lex_state == EXPR_FNAME
+ t = Token(TkfLBRACK)
+ else
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ t = Token(TkLBRACK)
+ elsif @lex_state == EXPR_ARG && @space_seen
+ t = Token(TkLBRACK)
+ else
+ t = Token(TkfLBRACK)
+ end
+ @lex_state = EXPR_BEG
+ end
+ t.set_text("[")
+ end
+
+ @OP.def_rule("{") do
+ @indent += 1
+ if @lex_state != EXPR_END && @lex_state != EXPR_ARG
+ t = Token(TkLBRACE)
+ else
+ t = Token(TkfLBRACE)
+ end
+ @lex_state = EXPR_BEG
+ t.set_text("{")
+ end
+
+ @OP.def_rule('\\') do #'
+ if getc == "\n"
+ @space_seen = true
+ @continue = true
+ Token(TkSPACE).set_text("\\\n")
+ else
+ ungetc
+ Token("\\").set_text("\\") #"
+ end
+ end
+
+ @OP.def_rule('%') do
+ |op, io|
+ if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
+ identify_quotation('%')
+ elsif peek(0) == '='
+ getc
+ Token(TkOPASGN, "%").set_text("%=")
+ elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
+ identify_quotation('%')
+ else
+ @lex_state = EXPR_BEG
+ Token("%").set_text("%")
+ end
+ end
+
+ @OP.def_rule('$') do #'
+ identify_gvar
+ end
+
+ @OP.def_rule('@') do
+ if peek(0) =~ /[@\w_]/
+ ungetc
+ identify_identifier
+ else
+ Token("@").set_text("@")
+ end
+ end
+
+ # @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
+ # |op, io|
+ # @indent += 1
+ # @lex_state = EXPR_FNAME
+ # # @lex_state = EXPR_END
+ # # until @rests[0] == "\n" or @rests[0] == ";"
+ # # rests.shift
+ # # end
+ # end
+
+ @OP.def_rule("__END__", proc{@prev_char_no == 0 && peek(0) =~ /[\r\n]/}) do
+ throw :eof
+ end
+
+ @OP.def_rule("") do
+ |op, io|
+ printf "MATCH: start %s: %s\n", op, io.inspect if RubyLex.debug?
+ if peek(0) =~ /[0-9]/
+ t = identify_number("")
+ elsif peek(0) =~ /[\w_]/
+ t = identify_identifier
+ end
+ printf "MATCH: end %s: %s\n", op, io.inspect if RubyLex.debug?
+ t
+ end
+
+ p @OP if RubyLex.debug?
+ end
+
+ def identify_gvar
+ @lex_state = EXPR_END
+ str = "$"
+
+ tk = case ch = getc
+ when /[~_*$?!@\/\\;,=:<>".]/ #"
+ str << ch
+ Token(TkGVAR, str)
+
+ when "-"
+ str << "-" << getc
+ Token(TkGVAR, str)
+
+ when "&", "`", "'", "+"
+ str << ch
+ Token(TkBACK_REF, str)
+
+ when /[1-9]/
+ str << ch
+ while (ch = getc) =~ /[0-9]/
+ str << ch
+ end
+ ungetc
+ Token(TkNTH_REF)
+ when /\w/
+ ungetc
+ ungetc
+ return identify_identifier
+ else
+ ungetc
+ Token("$")
+ end
+ tk.set_text(str)
+ end
+
+ def identify_identifier
+ token = ""
+ token.concat getc if peek(0) =~ /[$@]/
+ token.concat getc if peek(0) == "@"
+
+ while (ch = getc) =~ /\w|_/
+ print ":", ch, ":" if RubyLex.debug?
+ token.concat ch
+ end
+ ungetc
+
+ if ch == "!" or ch == "?"
+ token.concat getc
+ end
+ # fix token
+
+ # $stderr.puts "identifier - #{token}, state = #@lex_state"
+
+ case token
+ when /^\$/
+ return Token(TkGVAR, token).set_text(token)
+ when /^\@/
+ @lex_state = EXPR_END
+ return Token(TkIVAR, token).set_text(token)
+ end
+
+ if @lex_state != EXPR_DOT
+ print token, "\n" if RubyLex.debug?
+
+ token_c, *trans = TkReading2Token[token]
+ if token_c
+ # reserved word?
+
+ if (@lex_state != EXPR_BEG &&
+ @lex_state != EXPR_FNAME &&
+ trans[1])
+ # modifiers
+ token_c = TkSymbol2Token[trans[1]]
+ @lex_state = trans[0]
+ else
+ if @lex_state != EXPR_FNAME
+ if ENINDENT_CLAUSE.include?(token)
+ @indent += 1
+ elsif DEINDENT_CLAUSE.include?(token)
+ @indent -= 1
+ end
+ @lex_state = trans[0]
+ else
+ @lex_state = EXPR_END
+ end
+ end
+ return Token(token_c, token).set_text(token)
+ end
+ end
+
+ if @lex_state == EXPR_FNAME
+ @lex_state = EXPR_END
+ if peek(0) == '='
+ token.concat getc
+ end
+ elsif @lex_state == EXPR_BEG || @lex_state == EXPR_DOT
+ @lex_state = EXPR_ARG
+ else
+ @lex_state = EXPR_END
+ end
+
+ if token[0, 1] =~ /[A-Z]/
+ return Token(TkCONSTANT, token).set_text(token)
+ elsif token[token.size - 1, 1] =~ /[!?]/
+ return Token(TkFID, token).set_text(token)
+ else
+ return Token(TkIDENTIFIER, token).set_text(token)
+ end
+ end
+
+ def identify_here_document
+ ch = getc
+ if ch == "-"
+ ch = getc
+ indent = true
+ end
+ if /['"`]/ =~ ch # '
+ lt = ch
+ quoted = ""
+ while (c = getc) && c != lt
+ quoted.concat c
+ end
+ else
+ lt = '"'
+ quoted = ch.dup
+ while (c = getc) && c =~ /\w/
+ quoted.concat c
+ end
+ ungetc
+ end
+
+ ltback, @ltype = @ltype, lt
+ reserve = ""
+
+ while ch = getc
+ reserve << ch
+ if ch == "\\" #"
+ ch = getc
+ reserve << ch
+ elsif ch == "\n"
+ break
+ end
+ end
+
+ str = ""
+ while (l = gets)
+ l.chomp!
+ l.strip! if indent
+ break if l == quoted
+ str << l.chomp << "\n"
+ end
+
+ @reader.divert_read_from(reserve)
+
+ @ltype = ltback
+ @lex_state = EXPR_END
+ Token(Ltype2Token[lt], str).set_text(str.dump)
+ end
+
+ def identify_quotation(initial_char)
+ ch = getc
+ if lt = PERCENT_LTYPE[ch]
+ initial_char += ch
+ ch = getc
+ elsif ch =~ /\W/
+ lt = "\""
+ else
+ RubyLex.fail SyntaxError, "unknown type of %string ('#{ch}')"
+ end
+# if ch !~ /\W/
+# ungetc
+# next
+# end
+ #@ltype = lt
+ @quoted = ch unless @quoted = PERCENT_PAREN[ch]
+ identify_string(lt, @quoted, ch, initial_char)
+ end
+
+ def identify_number(start)
+ str = start.dup
+
+ if start == "+" or start == "-" or start == ""
+ start = getc
+ str << start
+ end
+
+ @lex_state = EXPR_END
+
+ if start == "0"
+ if peek(0) == "x"
+ ch = getc
+ str << ch
+ match = /[0-9a-f_]/
+ else
+ match = /[0-7_]/
+ end
+ while ch = getc
+ if ch !~ match
+ ungetc
+ break
+ else
+ str << ch
+ end
+ end
+ return Token(TkINTEGER).set_text(str)
+ end
+
+ type = TkINTEGER
+ allow_point = TRUE
+ allow_e = TRUE
+ while ch = getc
+ case ch
+ when /[0-9_]/
+ str << ch
+
+ when allow_point && "."
+ type = TkFLOAT
+ if peek(0) !~ /[0-9]/
+ ungetc
+ break
+ end
+ str << ch
+ allow_point = false
+
+ when allow_e && "e", allow_e && "E"
+ str << ch
+ type = TkFLOAT
+ if peek(0) =~ /[+-]/
+ str << getc
+ end
+ allow_e = false
+ allow_point = false
+ else
+ ungetc
+ break
+ end
+ end
+ Token(type).set_text(str)
+ end
+
+ def identify_string(ltype, quoted = ltype, opener=nil, initial_char = nil)
+ @ltype = ltype
+ @quoted = quoted
+ subtype = nil
+
+ str = ""
+ str << initial_char if initial_char
+ str << (opener||quoted)
+
+ nest = 0
+ begin
+ while ch = getc
+ str << ch
+ if @quoted == ch
+ if nest == 0
+ break
+ else
+ nest -= 1
+ end
+ elsif opener == ch
+ nest += 1
+ elsif @ltype != "'" && @ltype != "]" and ch == "#"
+ ch = getc
+ if ch == "{"
+ subtype = true
+ str << ch << skip_inner_expression
+ else
+ ungetc(ch)
+ end
+ elsif ch == '\\' #'
+ str << read_escape
+ end
+ end
+ if @ltype == "/"
+ if peek(0) =~ /i|o|n|e|s/
+ str << getc
+ end
+ end
+ if subtype
+ Token(DLtype2Token[ltype], str)
+ else
+ Token(Ltype2Token[ltype], str)
+ end.set_text(str)
+ ensure
+ @ltype = nil
+ @quoted = nil
+ @lex_state = EXPR_END
+ end
+ end
+
+ def skip_inner_expression
+ res = ""
+ nest = 0
+ while (ch = getc)
+ res << ch
+ if ch == '}'
+ break if nest.zero?
+ nest -= 1
+ elsif ch == '{'
+ nest += 1
+ end
+ end
+ res
+ end
+
+ def identify_comment
+ @ltype = "#"
+ comment = "#"
+ while ch = getc
+ if ch == "\\"
+ ch = getc
+ if ch == "\n"
+ ch = " "
+ else
+ comment << "\\"
+ end
+ else
+ if ch == "\n"
+ @ltype = nil
+ ungetc
+ break
+ end
+ end
+ comment << ch
+ end
+ return Token(TkCOMMENT).set_text(comment)
+ end
+
+ def read_escape
+ res = ""
+ case ch = getc
+ when /[0-7]/
+ ungetc ch
+ 3.times do
+ case ch = getc
+ when /[0-7]/
+ when nil
+ break
+ else
+ ungetc
+ break
+ end
+ res << ch
+ end
+
+ when "x"
+ res << ch
+ 2.times do
+ case ch = getc
+ when /[0-9a-fA-F]/
+ when nil
+ break
+ else
+ ungetc
+ break
+ end
+ res << ch
+ end
+
+ when "M"
+ res << ch
+ if (ch = getc) != '-'
+ ungetc
+ else
+ res << ch
+ if (ch = getc) == "\\" #"
+ res << ch
+ res << read_escape
+ else
+ res << ch
+ end
+ end
+
+ when "C", "c", "^"
+ res << ch
+ if ch == "C" and (ch = getc) != "-"
+ ungetc
+ else
+ res << ch
+ if (ch = getc) == "\\" #"
+ res << ch
+ res << read_escape
+ else
+ res << ch
+ end
+ end
+ else
+ res << ch
+ end
+ res
+ end
+end
+
+
+
+# Extract code elements from a source file, returning a TopLevel
+# object containing the constituent file elements.
+#
+# This file is based on rtags
+
+module RDoc
+
+ GENERAL_MODIFIERS = [ 'nodoc' ].freeze
+
+ CLASS_MODIFIERS = GENERAL_MODIFIERS
+
+ ATTR_MODIFIERS = GENERAL_MODIFIERS
+
+ CONSTANT_MODIFIERS = GENERAL_MODIFIERS
+
+ METHOD_MODIFIERS = GENERAL_MODIFIERS +
+ [ 'arg', 'args', 'yield', 'yields', 'notnew', 'not-new', 'not_new', 'doc' ]
+
+
+ class RubyParser
+ include RubyToken
+ include TokenStream
+
+ extend ParserFactory
+
+ parse_files_matching(/\.rbw?$/)
+
+
+ def initialize(top_level, file_name, content, options, stats)
+ @options = options
+ @stats = stats
+ @size = 0
+ @token_listeners = nil
+ @input_file_name = file_name
+ @scanner = RubyLex.new(content)
+ @scanner.exception_on_syntax_error = false
+ @top_level = top_level
+ @progress = $stderr unless options.quiet
+ end
+
+ def scan
+ @tokens = []
+ @unget_read = []
+ @read = []
+ catch(:eof) do
+ catch(:enddoc) do
+ begin
+ parse_toplevel_statements(@top_level)
+ rescue Exception => e
+ $stderr.puts "\n\n"
+ $stderr.puts "RDoc failure in #@input_file_name at or around " +
+ "line #{@scanner.line_no} column #{@scanner.char_no}"
+ $stderr.puts
+ $stderr.puts "Before reporting this, could you check that the file"
+ $stderr.puts "you're documenting compiles cleanly--RDoc is not a"
+ $stderr.puts "full Ruby parser, and gets confused easily if fed"
+ $stderr.puts "invalid programs."
+ $stderr.puts
+ $stderr.puts "The internal error was:\n\n"
+
+ e.set_backtrace(e.backtrace[0,4])
+ raise
+ end
+ end
+ end
+ @top_level
+ end
+
+ private
+
+ def warn(msg)
+ prefix = "\n" + @input_file_name + ":"
+ if @scanner
+ prefix << "#{@scanner.line_no}:#{@scanner.char_no}: "
+ end
+ $stderr.puts prefix + msg
+ end
+
+ def error(msg)
+ warn msg
+ exit(1)
+ end
+
+ def progress(char)
+ unless @options.quiet
+ @progress.print(char)
+ @progress.flush
+ end
+ end
+
+ def add_token_listener(obj)
+ @token_listeners ||= []
+ @token_listeners << obj
+ end
+
+ def remove_token_listener(obj)
+ @token_listeners.delete(obj)
+ end
+
+ def get_tk
+ tk = nil
+ if @tokens.empty?
+ tk = @scanner.token
+ @read.push @scanner.get_read
+ puts "get_tk1 => #{tk.inspect}" if $TOKEN_DEBUG
+ else
+ @read.push @unget_read.shift
+ tk = @tokens.shift
+ puts "get_tk2 => #{tk.inspect}" if $TOKEN_DEBUG
+ end
+
+ if tk.kind_of?(TkSYMBEG)
+ set_token_position(tk.line_no, tk.char_no)
+ tk1 = get_tk
+ if tk1.kind_of?(TkId) || tk1.kind_of?(TkOp)
+ tk = Token(TkSYMBOL).set_text(":" + tk1.name)
+ # remove the identifier we just read (we're about to
+ # replace it with a symbol)
+ @token_listeners.each do |obj|
+ obj.pop_token
+ end if @token_listeners
+ else
+ warn("':' not followed by identified or operator")
+ tk = tk1
+ end
+ end
+
+ # inform any listeners of our shiny new token
+ @token_listeners.each do |obj|
+ obj.add_token(tk)
+ end if @token_listeners
+
+ tk
+ end
+
+ def peek_tk
+ unget_tk(tk = get_tk)
+ tk
+ end
+
+ def unget_tk(tk)
+ @tokens.unshift tk
+ @unget_read.unshift @read.pop
+
+ # Remove this token from any listeners
+ @token_listeners.each do |obj|
+ obj.pop_token
+ end if @token_listeners
+ end
+
+ def skip_tkspace(skip_nl = true)
+ tokens = []
+ while ((tk = get_tk).kind_of?(TkSPACE) ||
+ (skip_nl && tk.kind_of?(TkNL)))
+ tokens.push tk
+ end
+ unget_tk(tk)
+ tokens
+ end
+
+ def get_tkread
+ read = @read.join("")
+ @read = []
+ read
+ end
+
+ def peek_read
+ @read.join('')
+ end
+
+ NORMAL = "::"
+ SINGLE = "<<"
+
+ # Look for the first comment in a file that isn't
+ # a shebang line.
+
+ def collect_first_comment
+ skip_tkspace
+ res = ''
+ first_line = true
+
+ tk = get_tk
+ while tk.kind_of?(TkCOMMENT)
+ if first_line && tk.text[0,2] == "#!"
+ skip_tkspace
+ tk = get_tk
+ else
+ res << tk.text << "\n"
+ tk = get_tk
+ if tk.kind_of? TkNL
+ skip_tkspace(false)
+ tk = get_tk
+ end
+ end
+ first_line = false
+ end
+ unget_tk(tk)
+ res
+ end
+
+ def parse_toplevel_statements(container)
+ comment = collect_first_comment
+ look_for_directives_in(container, comment)
+ container.comment = comment unless comment.empty?
+ parse_statements(container, NORMAL, nil, comment)
+ end
+
+ def parse_statements(container, single=NORMAL, current_method=nil, comment='')
+ nest = 1
+ save_visibility = container.visibility
+
+# if container.kind_of?(TopLevel)
+# else
+# comment = ''
+# end
+
+ non_comment_seen = true
+
+ while tk = get_tk
+
+ keep_comment = false
+
+ non_comment_seen = true unless tk.kind_of?(TkCOMMENT)
+
+# $stderr.puts "===== #{tk.inspect}"
+# blank_line_seen = true
+# while tk.kind_of?(TkNL)
+# skip_tkspace(false)
+# if peek_tk.kind_of?(TkCOMMENT)
+# if blank_line_seen
+# comment = ''
+# blank_line_seen = false
+# end
+# tk = get_tk
+# comment << tk.text << "\n"
+# else
+# blank_line_seen = true
+# end
+# tk = get_tk
+# end
+
+ case tk
+
+ when TkNL
+ skip_tkspace(true) # Skip blanks and newlines
+ tk = get_tk
+ if tk.kind_of?(TkCOMMENT)
+ if non_comment_seen
+ comment = ''
+ non_comment_seen = false
+ end
+ while tk.kind_of?(TkCOMMENT)
+ comment << tk.text << "\n"
+ tk = get_tk # this is the newline
+ skip_tkspace(false) # leading spaces
+ tk = get_tk
+ end
+ unless comment.empty?
+ look_for_directives_in(container, comment)
+ if container.done_documenting
+ container.ongoing_visibility = save_visibility
+# return
+ end
+ end
+ keep_comment = true
+ else
+ non_comment_seen = true
+ end
+ unget_tk(tk)
+ keep_comment = true
+
+
+ when TkCLASS
+ if container.document_children
+ parse_class(container, single, tk, comment)
+ else
+ nest += 1
+ end
+
+ when TkMODULE
+ if container.document_children
+ parse_module(container, single, tk, comment)
+ else
+ nest += 1
+ end
+
+ when TkDEF
+ if container.document_self
+ parse_method(container, single, tk, comment)
+ else
+ nest += 1
+ end
+
+ when TkCONSTANT
+ if container.document_self
+ parse_constant(container, single, tk, comment)
+ end
+
+ when TkALIAS
+ if container.document_self
+ parse_alias(container, single, tk, comment)
+ end
+
+ when TkYIELD
+ if current_method.nil?
+ warn("Warning: yield outside of method") if container.document_self
+ else
+ parse_yield(container, single, tk, current_method)
+ end
+
+ # Until and While can have a 'do', which shouldn't increas
+ # the nesting. We can't solve the general case, but we can
+ # handle most occurrences by ignoring a do at the end of a line
+
+ when TkUNTIL, TkWHILE
+ nest += 1
+ puts "FOUND #{tk.class} in #{container.name}, nest = #{nest}, " +
+ "line #{tk.line_no}" if $DEBUG
+ skip_optional_do_after_expression
+
+ # 'for' is trickier
+ when TkFOR
+ nest += 1
+ puts "FOUND #{tk.class} in #{container.name}, nest = #{nest}, " +
+ "line #{tk.line_no}" if $DEBUG
+ skip_for_variable
+ skip_optional_do_after_expression
+
+ when TkCASE, TkDO, TkIF, TkUNLESS, TkBEGIN
+ nest += 1
+ puts "Found #{tk.class} in #{container.name}, nest = #{nest}, " +
+ "line #{tk.line_no}" if $DEBUG
+
+ when TkIDENTIFIER
+ if nest == 1 and current_method.nil?
+ case tk.name
+ when "private", "protected", "public",
+ "private_class_method", "public_class_method"
+ parse_visibility(container, single, tk)
+ keep_comment = true
+ when "attr"
+ parse_attr(container, single, tk, comment)
+ when /^attr_(reader|writer|accessor)$/, @options.extra_accessors
+ parse_attr_accessor(container, single, tk, comment)
+ when "alias_method"
+ if container.document_self
+ parse_alias(container, single, tk, comment)
+ end
+ end
+ end
+
+ case tk.name
+ when "require"
+ parse_require(container, comment)
+ when "include"
+ parse_include(container, comment)
+ end
+
+
+ when TkEND
+ nest -= 1
+ puts "Found 'end' in #{container.name}, nest = #{nest}, line #{tk.line_no}" if $DEBUG
+ puts "Method = #{current_method.name}" if $DEBUG and current_method
+ if nest == 0
+ read_documentation_modifiers(container, CLASS_MODIFIERS)
+ container.ongoing_visibility = save_visibility
+ return
+ end
+
+ end
+
+ comment = '' unless keep_comment
+ begin
+ get_tkread
+ skip_tkspace(false)
+ end while peek_tk == TkNL
+
+ end
+ end
+
+ def parse_class(container, single, tk, comment, &block)
+ progress("c")
+
+ @stats.num_classes += 1
+
+ container, name_t = get_class_or_module(container)
+
+ case name_t
+ when TkCONSTANT
+ name = name_t.name
+ superclass = "Object"
+
+ if peek_tk.kind_of?(TkLT)
+ get_tk
+ skip_tkspace(true)
+ superclass = get_class_specification
+ superclass = "<unknown>" if superclass.empty?
+ end
+
+ if single == SINGLE
+ cls_type = SingleClass
+ else
+ cls_type = NormalClass
+ end
+
+ cls = container.add_class(cls_type, name, superclass)
+ read_documentation_modifiers(cls, CLASS_MODIFIERS)
+ cls.record_location(@top_level)
+ parse_statements(cls)
+ cls.comment = comment
+
+ when TkLSHFT
+ case name = get_class_specification
+ when "self", container.name
+ parse_statements(container, SINGLE, &block)
+ else
+ other = TopLevel.find_class_named(name)
+ unless other
+# other = @top_level.add_class(NormalClass, name, nil)
+# other.record_location(@top_level)
+# other.comment = comment
+ other = NormalClass.new("Dummy", nil)
+ end
+ read_documentation_modifiers(other, CLASS_MODIFIERS)
+ parse_statements(other, SINGLE, &block)
+ end
+
+ else
+ warn("Expected class name or '<<'. Got #{name_t.class}: #{name_t.text.inspect}")
+ end
+ end
+
+ def parse_module(container, single, tk, comment)
+ progress("m")
+ @stats.num_modules += 1
+ container, name_t = get_class_or_module(container)
+# skip_tkspace
+ name = name_t.name
+ mod = container.add_module(NormalModule, name)
+ mod.record_location(@top_level)
+ read_documentation_modifiers(mod, CLASS_MODIFIERS)
+ parse_statements(mod)
+ mod.comment = comment
+ end
+
+ # Look for the name of a class of module (optionally with a leading :: or
+ # with :: separated named) and return the ultimate name and container
+
+ def get_class_or_module(container)
+ skip_tkspace
+ name_t = get_tk
+
+ # class ::A -> A is in the top level
+ if name_t.kind_of?(TkCOLON2)
+ name_t = get_tk
+ container = @top_level
+ end
+
+ skip_tkspace(false)
+
+ while peek_tk.kind_of?(TkCOLON2)
+ prev_container = container
+ container = container.find_module_named(name_t.name)
+ if !container
+# warn("Couldn't find module #{name_t.name}")
+ container = prev_container.add_module(NormalModule, name_t.name)
+ end
+ get_tk
+ name_t = get_tk
+ end
+ return [container, name_t]
+ end
+
+ def parse_constant(container, single, tk, comment)
+ name = tk.name
+ skip_tkspace(false)
+ eq_tk = get_tk
+
+ unless eq_tk.kind_of?(TkASSIGN)
+ unget_tk(eq_tk)
+ return
+ end
+
+
+ nest = 0
+ get_tkread
+
+ tk = get_tk
+ if tk.kind_of? TkGT
+ unget_tk(tk)
+ unget_tk(eq_tk)
+ return
+ end
+
+ loop do
+ puts("Param: #{tk}, #{@scanner.continue} " +
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
+
+ case tk
+ when TkSEMICOLON
+ break
+ when TkLPAREN, TkfLPAREN
+ nest += 1
+ when TkRPAREN
+ nest -= 1
+ when TkCOMMENT
+ if nest <= 0 && @scanner.lex_state == EXPR_END
+ unget_tk(tk)
+ break
+ end
+ when TkNL
+ if (@scanner.lex_state == EXPR_END and nest <= 0) || !@scanner.continue
+ unget_tk(tk)
+ break
+ end
+ end
+ tk = get_tk
+ end
+
+ res = get_tkread.tr("\n", " ").strip
+ res = "" if res == ";"
+ con = Constant.new(name, res, comment)
+ read_documentation_modifiers(con, CONSTANT_MODIFIERS)
+ if con.document_self
+ container.add_constant(con)
+ end
+ end
+
+ def parse_method(container, single, tk, comment)
+ progress(".")
+ @stats.num_methods += 1
+ line_no = tk.line_no
+ column = tk.char_no
+
+ start_collecting_tokens
+ add_token(tk)
+ add_token_listener(self)
+
+ @scanner.instance_eval{@lex_state = EXPR_FNAME}
+ skip_tkspace(false)
+ name_t = get_tk
+ back_tk = skip_tkspace
+ meth = nil
+
+ dot = get_tk
+ if dot.kind_of?(TkDOT) or dot.kind_of?(TkCOLON2)
+ @scanner.instance_eval{@lex_state = EXPR_FNAME}
+ skip_tkspace
+ name_t2 = get_tk
+ case name_t
+ when TkSELF
+ name = name_t2.name
+ when TkCONSTANT
+ name = name_t2.name
+ prev_container = container
+ container = container.find_module_named(name_t.name)
+ if !container
+ warn("Couldn't find #{name_t.name}. Assuming it's a module")
+ container = prev_container.add_module(NormalModule, name_t.name)
+ end
+ else
+ # warn("Unexpected token '#{name_t2.inspect}'")
+ # break
+ skip_method(container)
+ return
+ end
+ meth = AnyMethod.new(get_tkread, name)
+ meth.singleton = true
+ else
+ unget_tk dot
+ back_tk.reverse_each do
+ |tk|
+ unget_tk tk
+ end
+ name = name_t.name
+
+ meth = AnyMethod.new(get_tkread, name)
+ meth.singleton = (single == SINGLE)
+ end
+
+ remove_token_listener(self)
+
+ meth.start_collecting_tokens
+ indent = TkSPACE.new(1,1)
+ indent.set_text(" " * column)
+
+ meth.add_tokens([TkCOMMENT.new(line_no,
+ 1,
+ "# File #{@top_level.file_absolute_name}, line #{line_no}"),
+ NEWLINE_TOKEN,
+ indent])
+
+ meth.add_tokens(@token_stream)
+
+ add_token_listener(meth)
+
+ @scanner.instance_eval{@continue = false}
+ parse_method_parameters(meth)
+
+ if meth.document_self
+ container.add_method(meth)
+ end
+
+ # Having now read the method parameters and documentation modifiers, we
+ # now know whether we have to rename #initialize to ::new
+
+ if name == "initialize" && !meth.singleton
+ if meth.dont_rename_initialize
+ meth.visibility = :protected
+ else
+ meth.singleton = true
+ meth.name = "new"
+ meth.visibility = :public
+ end
+ end
+
+ parse_statements(container, single, meth)
+
+ remove_token_listener(meth)
+
+ # Look for a 'call-seq' in the comment, and override the
+ # normal parameter stuff
+
+ if comment.sub!(/:?call-seq:(.*?)^\s*\#?\s*$/m, '')
+ seq = $1
+ seq.gsub!(/^\s*\#\s*/, '')
+ meth.call_seq = seq
+ end
+
+ meth.comment = comment
+
+ end
+
+ def skip_method(container)
+ meth = AnyMethod.new("", "anon")
+ parse_method_parameters(meth)
+ parse_statements(container, false, meth)
+ end
+
+ # Capture the method's parameters. Along the way,
+ # look for a comment containing
+ #
+ # # yields: ....
+ #
+ # and add this as the block_params for the method
+
+ def parse_method_parameters(method)
+ res = parse_method_or_yield_parameters(method)
+ res = "(" + res + ")" unless res[0] == ?(
+ method.params = res unless method.params
+ if method.block_params.nil?
+ skip_tkspace(false)
+ read_documentation_modifiers(method, METHOD_MODIFIERS)
+ end
+ end
+
+ def parse_method_or_yield_parameters(method=nil, modifiers=METHOD_MODIFIERS)
+ skip_tkspace(false)
+ tk = get_tk
+
+ # Little hack going on here. In the statement
+ # f = 2*(1+yield)
+ # We see the RPAREN as the next token, so we need
+ # to exit early. This still won't catch all cases
+ # (such as "a = yield + 1"
+ end_token = case tk
+ when TkLPAREN, TkfLPAREN
+ TkRPAREN
+ when TkRPAREN
+ return ""
+ else
+ TkNL
+ end
+ nest = 0
+
+ loop do
+ puts("Param: #{tk.inspect}, #{@scanner.continue} " +
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
+ case tk
+ when TkSEMICOLON
+ break
+ when TkLBRACE
+ nest += 1
+ when TkRBRACE
+ # we might have a.each {|i| yield i }
+ unget_tk(tk) if nest.zero?
+ nest -= 1
+ break if nest <= 0
+ when TkLPAREN, TkfLPAREN
+ nest += 1
+ when end_token
+ if end_token == TkRPAREN
+ nest -= 1
+ break if @scanner.lex_state == EXPR_END and nest <= 0
+ else
+ break unless @scanner.continue
+ end
+ when method && method.block_params.nil? && TkCOMMENT
+ unget_tk(tk)
+ read_documentation_modifiers(method, modifiers)
+ end
+ tk = get_tk
+ end
+ res = get_tkread.tr("\n", " ").strip
+ res = "" if res == ";"
+ res
+ end
+
+ # skip the var [in] part of a 'for' statement
+ def skip_for_variable
+ skip_tkspace(false)
+ tk = get_tk
+ skip_tkspace(false)
+ tk = get_tk
+ unget_tk(tk) unless tk.kind_of?(TkIN)
+ end
+
+ # while, until, and for have an optional
+ def skip_optional_do_after_expression
+ skip_tkspace(false)
+ tk = get_tk
+ case tk
+ when TkLPAREN, TkfLPAREN
+ end_token = TkRPAREN
+ else
+ end_token = TkNL
+ end
+
+ nest = 0
+ @scanner.instance_eval{@continue = false}
+
+ loop do
+ puts("\nWhile: #{tk}, #{@scanner.continue} " +
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
+ case tk
+ when TkSEMICOLON
+ break
+ when TkLPAREN, TkfLPAREN
+ nest += 1
+ when TkDO
+ break if nest.zero?
+ when end_token
+ if end_token == TkRPAREN
+ nest -= 1
+ break if @scanner.lex_state == EXPR_END and nest.zero?
+ else
+ break unless @scanner.continue
+ end
+ end
+ tk = get_tk
+ end
+ skip_tkspace(false)
+ if peek_tk.kind_of? TkDO
+ get_tk
+ end
+ end
+
+ # Return a superclass, which can be either a constant
+ # of an expression
+
+ def get_class_specification
+ tk = get_tk
+ return "self" if tk.kind_of?(TkSELF)
+
+ res = ""
+ while tk.kind_of?(TkCOLON2) ||
+ tk.kind_of?(TkCOLON3) ||
+ tk.kind_of?(TkCONSTANT)
+
+ res += tk.text
+ tk = get_tk
+ end
+
+ unget_tk(tk)
+ skip_tkspace(false)
+
+ get_tkread # empty out read buffer
+
+ tk = get_tk
+
+ case tk
+ when TkNL, TkCOMMENT, TkSEMICOLON
+ unget_tk(tk)
+ return res
+ end
+
+ res += parse_call_parameters(tk)
+ res
+ end
+
+ def parse_call_parameters(tk)
+
+ end_token = case tk
+ when TkLPAREN, TkfLPAREN
+ TkRPAREN
+ when TkRPAREN
+ return ""
+ else
+ TkNL
+ end
+ nest = 0
+
+ loop do
+ puts("Call param: #{tk}, #{@scanner.continue} " +
+ "#{@scanner.lex_state} #{nest}") if $DEBUG
+ case tk
+ when TkSEMICOLON
+ break
+ when TkLPAREN, TkfLPAREN
+ nest += 1
+ when end_token
+ if end_token == TkRPAREN
+ nest -= 1
+ break if @scanner.lex_state == EXPR_END and nest <= 0
+ else
+ break unless @scanner.continue
+ end
+ when TkCOMMENT
+ unget_tk(tk)
+ break
+ end
+ tk = get_tk
+ end
+ res = get_tkread.tr("\n", " ").strip
+ res = "" if res == ";"
+ res
+ end
+
+
+ # Parse a constant, which might be qualified by
+ # one or more class or module names
+
+ def get_constant
+ res = ""
+ skip_tkspace(false)
+ tk = get_tk
+
+ while tk.kind_of?(TkCOLON2) ||
+ tk.kind_of?(TkCOLON3) ||
+ tk.kind_of?(TkCONSTANT)
+
+ res += tk.text
+ tk = get_tk
+ end
+
+# if res.empty?
+# warn("Unexpected token #{tk} in constant")
+# end
+ unget_tk(tk)
+ res
+ end
+
+ # Get a constant that may be surrounded by parens
+
+ def get_constant_with_optional_parens
+ skip_tkspace(false)
+ nest = 0
+ while (tk = peek_tk).kind_of?(TkLPAREN) || tk.kind_of?(TkfLPAREN)
+ get_tk
+ skip_tkspace(true)
+ nest += 1
+ end
+
+ name = get_constant
+
+ while nest > 0
+ skip_tkspace(true)
+ tk = get_tk
+ nest -= 1 if tk.kind_of?(TkRPAREN)
+ end
+ name
+ end
+
+ # Directives are modifier comments that can appear after class, module,
+ # or method names. For example
+ #
+ # def fred # :yields: a, b
+ #
+ # or
+ #
+ # class SM # :nodoc:
+ #
+ # we return the directive name and any parameters as a two element array
+
+ def read_directive(allowed)
+ tk = get_tk
+ puts "directive: #{tk.inspect}" if $DEBUG
+ result = nil
+ if tk.kind_of?(TkCOMMENT)
+ if tk.text =~ /\s*:?(\w+):\s*(.*)/
+ directive = $1.downcase
+ if allowed.include?(directive)
+ result = [directive, $2]
+ end
+ end
+ else
+ unget_tk(tk)
+ end
+ result
+ end
+
+
+ def read_documentation_modifiers(context, allow)
+ dir = read_directive(allow)
+
+ case dir[0]
+
+ when "notnew", "not_new", "not-new"
+ context.dont_rename_initialize = true
+
+ when "nodoc"
+ context.document_self = false
+ if dir[1].downcase == "all"
+ context.document_children = false
+ end
+
+ when "doc"
+ context.document_self = true
+ context.force_documentation = true
+
+ when "yield", "yields"
+ unless context.params.nil?
+ context.params.sub!(/(,|)\s*&\w+/,'') # remove parameter &proc
+ end
+ context.block_params = dir[1]
+
+ when "arg", "args"
+ context.params = dir[1]
+ end if dir
+ end
+
+
+ # Look for directives in a normal comment block:
+ #
+ # #-- - don't display comment from this point forward
+ #
+ #
+ # This routine modifies it's parameter
+
+ def look_for_directives_in(context, comment)
+
+ preprocess = SM::PreProcess.new(@input_file_name,
+ @options.rdoc_include)
+
+ preprocess.handle(comment) do |directive, param|
+ case directive
+ when "stopdoc"
+ context.stop_doc
+ ""
+ when "startdoc"
+ context.start_doc
+ context.force_documentation = true
+ ""
+
+ when "enddoc"
+ #context.done_documenting = true
+ #""
+ throw :enddoc
+
+ when "main"
+ options = Options.instance
+ options.main_page = param
+ ""
+
+ when "title"
+ options = Options.instance
+ options.title = param
+ ""
+
+ else
+ warn "Unrecognized directive '#{directive}'"
+ break
+ end
+ end
+
+ remove_private_comments(comment)
+ end
+
+ def remove_private_comments(comment)
+ comment.gsub!(/^#--.*?^#\+\+/m, '')
+ comment.sub!(/^#--.*/m, '')
+ end
+
+
+
+ def get_symbol_or_name
+ tk = get_tk
+ case tk
+ when TkSYMBOL
+ tk.text.sub(/^:/, '')
+ when TkId, TkOp
+ tk.name
+ when TkSTRING
+ tk.text
+ else
+ raise "Name or symbol expected (got #{tk})"
+ end
+ end
+
+ def parse_alias(context, single, tk, comment)
+ skip_tkspace
+ if (peek_tk.kind_of? TkLPAREN)
+ get_tk
+ skip_tkspace
+ end
+ new_name = get_symbol_or_name
+ @scanner.instance_eval{@lex_state = EXPR_FNAME}
+ skip_tkspace
+ if (peek_tk.kind_of? TkCOMMA)
+ get_tk
+ skip_tkspace
+ end
+ old_name = get_symbol_or_name
+
+ al = Alias.new(get_tkread, old_name, new_name, comment)
+ read_documentation_modifiers(al, ATTR_MODIFIERS)
+ if al.document_self
+ context.add_alias(al)
+ end
+ end
+
+ def parse_yield_parameters
+ parse_method_or_yield_parameters
+ end
+
+ def parse_yield(context, single, tk, method)
+ if method.block_params.nil?
+ get_tkread
+ @scanner.instance_eval{@continue = false}
+ method.block_params = parse_yield_parameters
+ end
+ end
+
+ def parse_require(context, comment)
+ skip_tkspace_comment
+ tk = get_tk
+ if tk.kind_of? TkLPAREN
+ skip_tkspace_comment
+ tk = get_tk
+ end
+
+ name = nil
+ case tk
+ when TkSTRING
+ name = tk.text
+ when TkCONSTANT, TkIDENTIFIER, TkIVAR, TkGVAR
+ name = tk.name
+ when TkDSTRING
+ warn "Skipping require of dynamic string: #{tk.text}"
+ else
+ warn "'require' used as variable"
+ end
+ if name
+ context.add_require(Require.new(name, comment))
+ else
+ unget_tk(tk)
+ end
+ end
+
+ def parse_include(context, comment)
+ loop do
+ skip_tkspace_comment
+ name = get_constant_with_optional_parens
+ unless name.empty?
+ context.add_include(Include.new(name, comment))
+ end
+ return unless peek_tk.kind_of?(TkCOMMA)
+ get_tk
+ end
+ end
+
+ def get_bool
+ skip_tkspace
+ tk = get_tk
+ case tk
+ when TkTRUE
+ true
+ when TkFALSE, TkNIL
+ false
+ else
+ unget_tk tk
+ true
+ end
+ end
+
+ def parse_attr(context, single, tk, comment)
+ args = parse_symbol_arg(1)
+ if args.size > 0
+ name = args[0]
+ rw = "R"
+ skip_tkspace(false)
+ tk = get_tk
+ if tk.kind_of? TkCOMMA
+ rw = "RW" if get_bool
+ else
+ unget_tk tk
+ end
+ att = Attr.new(get_tkread, name, rw, comment)
+ read_documentation_modifiers(att, ATTR_MODIFIERS)
+ if att.document_self
+ context.add_attribute(att)
+ end
+ else
+ warn("'attr' ignored - looks like a variable")
+ end
+
+ end
+
+ def parse_visibility(container, single, tk)
+ singleton = (single == SINGLE)
+ vis = case tk.name
+ when "private" then :private
+ when "protected" then :protected
+ when "public" then :public
+ when "private_class_method"
+ singleton = true
+ :private
+ when "public_class_method"
+ singleton = true
+ :public
+ else raise "Invalid visibility: #{tk.name}"
+ end
+
+ skip_tkspace_comment(false)
+ case peek_tk
+ # Ryan Davis suggested the extension to ignore modifiers, because he
+ # often writes
+ #
+ # protected unless $TESTING
+ #
+ when TkNL, TkUNLESS_MOD, TkIF_MOD
+# error("Missing argument") if singleton
+ container.ongoing_visibility = vis
+ else
+ args = parse_symbol_arg
+ container.set_visibility_for(args, vis, singleton)
+ end
+ end
+
+ def parse_attr_accessor(context, single, tk, comment)
+ args = parse_symbol_arg
+ read = get_tkread
+ rw = "?"
+
+ # If nodoc is given, don't document any of them
+
+ tmp = CodeObject.new
+ read_documentation_modifiers(tmp, ATTR_MODIFIERS)
+ return unless tmp.document_self
+
+ case tk.name
+ when "attr_reader" then rw = "R"
+ when "attr_writer" then rw = "W"
+ when "attr_accessor" then rw = "RW"
+ else
+ rw = @options.extra_accessor_flags[tk.name]
+ end
+
+ for name in args
+ att = Attr.new(get_tkread, name, rw, comment)
+ context.add_attribute(att)
+ end
+ end
+
+ def skip_tkspace_comment(skip_nl = true)
+ loop do
+ skip_tkspace(skip_nl)
+ return unless peek_tk.kind_of? TkCOMMENT
+ get_tk
+ end
+ end
+
+ def parse_symbol_arg(no = nil)
+
+ args = []
+ skip_tkspace_comment
+ case tk = get_tk
+ when TkLPAREN
+ loop do
+ skip_tkspace_comment
+ if tk1 = parse_symbol_in_arg
+ args.push tk1
+ break if no and args.size >= no
+ end
+
+ skip_tkspace_comment
+ case tk2 = get_tk
+ when TkRPAREN
+ break
+ when TkCOMMA
+ else
+ warn("unexpected token: '#{tk.inspect}'")
+ break
+ end
+ end
+ else
+ unget_tk tk
+ if tk = parse_symbol_in_arg
+ args.push tk
+ return args if no and args.size >= no
+ end
+
+ loop do
+# skip_tkspace_comment(false)
+ skip_tkspace(false)
+
+ tk1 = get_tk
+ unless tk1.kind_of?(TkCOMMA)
+ unget_tk tk1
+ break
+ end
+
+ skip_tkspace_comment
+ if tk = parse_symbol_in_arg
+ args.push tk
+ break if no and args.size >= no
+ end
+ end
+ end
+ args
+ end
+
+ def parse_symbol_in_arg
+ case tk = get_tk
+ when TkSYMBOL
+ tk.text.sub(/^:/, '')
+ when TkSTRING
+ eval @read[-1]
+ else
+ warn("Expected symbol or string, got #{tk.inspect}") if $DEBUG
+ nil
+ end
+ end
+ end
+
+end
diff --git a/lib/rdoc/parsers/parse_simple.rb b/lib/rdoc/parsers/parse_simple.rb
new file mode 100644
index 0000000000..b01104574e
--- /dev/null
+++ b/lib/rdoc/parsers/parse_simple.rb
@@ -0,0 +1,37 @@
+# Parse a non-source file. We basically take the whole thing
+# as one big comment. If the first character in the file
+# is '#', we strip leading pound signs.
+
+
+require "rdoc/code_objects"
+require "rdoc/markup/simple_markup/preprocess"
+
+module RDoc
+ # See rdoc/parsers/parse_c.rb
+
+ class SimpleParser
+
+ # prepare to parse a plain file
+ def initialize(top_level, file_name, body, options, stats)
+
+ preprocess = SM::PreProcess.new(file_name, options.rdoc_include)
+
+ preprocess.handle(body) do |directive, param|
+ $stderr.puts "Unrecognized directive '#{directive}' in #{file_name}"
+ end
+
+ @body = body
+ @options = options
+ @top_level = top_level
+ end
+
+ # Extract the file contents and attach them to the toplevel as a
+ # comment
+
+ def scan
+ # @body.gsub(/^(\s\n)+/, '')
+ @top_level.comment = @body
+ @top_level
+ end
+ end
+end
diff --git a/lib/rdoc/parsers/parserfactory.rb b/lib/rdoc/parsers/parserfactory.rb
new file mode 100644
index 0000000000..00a82cf4b1
--- /dev/null
+++ b/lib/rdoc/parsers/parserfactory.rb
@@ -0,0 +1,99 @@
+require "rdoc/parsers/parse_simple"
+
+module RDoc
+
+ # A parser is simple a class that implements
+ #
+ # #initialize(file_name, body, options)
+ #
+ # and
+ #
+ # #scan
+ #
+ # The initialize method takes a file name to be used, the body of the
+ # file, and an RDoc::Options object. The scan method is then called
+ # to return an appropriately parsed TopLevel code object.
+ #
+ # The ParseFactory is used to redirect to the correct parser given a filename
+ # extension. This magic works because individual parsers have to register
+ # themselves with us as they are loaded in. The do this using the following
+ # incantation
+ #
+ #
+ # require "rdoc/parsers/parsefactory"
+ #
+ # module RDoc
+ #
+ # class XyzParser
+ # extend ParseFactory <<<<
+ # parse_files_matching /\.xyz$/ <<<<
+ #
+ # def initialize(file_name, body, options)
+ # ...
+ # end
+ #
+ # def scan
+ # ...
+ # end
+ # end
+ # end
+ #
+ # Just to make life interesting, if we suspect a plain text file, we
+ # also look for a shebang line just in case it's a potential
+ # shell script
+
+
+
+ module ParserFactory
+
+ @@parsers = []
+
+ Parsers = Struct.new(:regexp, :parser)
+
+ # Record the fact that a particular class parses files that
+ # match a given extension
+
+ def parse_files_matching(regexp)
+ @@parsers.unshift Parsers.new(regexp, self)
+ end
+
+ # Return a parser that can handle a particular extension
+
+ def ParserFactory.can_parse(file_name)
+ @@parsers.find {|p| p.regexp.match(file_name) }
+ end
+
+ # Alias an extension to another extension. After this call,
+ # files ending "new_ext" will be parsed using the same parser
+ # as "old_ext"
+
+ def ParserFactory.alias_extension(old_ext, new_ext)
+ parser = ParserFactory.can_parse("xxx.#{old_ext}")
+ return false unless parser
+ @@parsers.unshift Parsers.new(Regexp.new("\\.#{new_ext}$"), parser.parser)
+ true
+ end
+
+ # Find the correct parser for a particular file name. Return a
+ # SimpleParser for ones that we don't know
+
+ def ParserFactory.parser_for(top_level, file_name, body, options, stats)
+ # If no extension, look for shebang
+ if file_name !~ /\.\w+$/ && body =~ %r{\A#!(.+)}
+ shebang = $1
+ case shebang
+ when %r{env\s+ruby}, %r{/ruby}
+ file_name = "dummy.rb"
+ end
+ end
+ parser_description = can_parse(file_name)
+ if parser_description
+ parser = parser_description.parser
+ else
+ parser = SimpleParser
+ end
+
+ parser.new(top_level, file_name, body, options, stats)
+ end
+ end
+end
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
new file mode 100644
index 0000000000..060e9ba826
--- /dev/null
+++ b/lib/rdoc/rdoc.rb
@@ -0,0 +1,282 @@
+# See README.
+#
+
+
+RDOC_VERSION = "1.0pr1"
+
+rcs = '$Date$ $Revision$'.
+ gsub(/\$/, '').
+ sub(/Date: /, ': ').
+ sub(/ Revision: (\S+)/) { "(#$1)" }
+
+VERSION_STRING = %{RDoc V} + RDOC_VERSION + rcs
+
+
+require 'rdoc/parsers/parse_rb.rb'
+require 'rdoc/parsers/parse_c.rb'
+require 'rdoc/parsers/parse_f95.rb'
+
+require 'rdoc/parsers/parse_simple.rb'
+require 'rdoc/options'
+
+require 'rdoc/diagram'
+
+require 'find'
+require 'ftools'
+
+# We put rdoc stuff in the RDoc module to avoid namespace
+# clutter.
+#
+# ToDo: This isn't universally true.
+
+module RDoc
+
+ # Name of the dotfile that contains the description of files to be
+ # processed in the current directory
+ DOT_DOC_FILENAME = ".document"
+
+ # Simple stats collector
+ class Stats
+ attr_accessor :num_files, :num_classes, :num_modules, :num_methods
+ def initialize
+ @num_files = @num_classes = @num_modules = @num_methods = 0
+ @start = Time.now
+ end
+ def print
+ puts "Files: #@num_files"
+ puts "Classes: #@num_classes"
+ puts "Modules: #@num_modules"
+ puts "Methods: #@num_methods"
+ puts "Elapsed: " + sprintf("%0.3fs", Time.now - @start)
+ end
+ end
+
+
+ # Exception thrown by any rdoc error. Only the #message part is
+ # of use externally.
+
+ class RDocError < Exception
+ end
+
+ # Encapsulate the production of rdoc documentation. Basically
+ # you can use this as you would invoke rdoc from the command
+ # line:
+ #
+ # rdoc = RDoc::RDoc.new
+ # rdoc.document(args)
+ #
+ # where _args_ is an array of strings, each corresponding to
+ # an argument you'd give rdoc on the command line. See rdoc/rdoc.rb
+ # for details.
+
+ class RDoc
+
+ ##
+ # This is the list of output generators that we
+ # support
+
+ Generator = Struct.new(:file_name, :class_name, :key)
+
+ GENERATORS = {}
+ $:.collect {|d|
+ File::expand_path(d)
+ }.find_all {|d|
+ File::directory?("#{d}/rdoc/generators")
+ }.each {|dir|
+ Dir::entries("#{dir}/rdoc/generators").each {|gen|
+ next unless /(\w+)_generator.rb$/ =~ gen
+ type = $1
+ unless GENERATORS.has_key? type
+ GENERATORS[type] = Generator.new("rdoc/generators/#{gen}",
+ "#{type.upcase}Generator".intern,
+ type)
+ end
+ }
+ }
+
+ #######
+ private
+ #######
+
+ ##
+ # Report an error message and exit
+
+ def error(msg)
+ raise RDocError.new(msg)
+ end
+
+ ##
+ # Create an output dir if it doesn't exist. If it does
+ # exist, but doesn't contain the flag file <tt>created.rid</tt>
+ # then we refuse to use it, as we may clobber some
+ # manually generated documentation
+
+ def setup_output_dir(op_dir)
+ flag_file = File.join(op_dir, "created.rid")
+ if File.exist?(op_dir)
+ unless File.directory?(op_dir)
+ error "'#{op_dir}' exists, and is not a directory"
+ end
+ unless File.file?(flag_file)
+ error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
+ "isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
+ "destroying any of your existing files, you'll need to\n" +
+ "specify a different output directory name (using the\n" +
+ "--op <dir> option).\n\n"
+ end
+ else
+ File.makedirs(op_dir)
+ end
+ File.open(flag_file, "w") {|f| f.puts Time.now }
+ end
+
+
+ # The .document file contains a list of file and directory name
+ # patterns, representing candidates for documentation. It may
+ # also contain comments (starting with '#')
+ def parse_dot_doc_file(in_dir, filename, options)
+ # read and strip comments
+ patterns = File.read(filename).gsub(/#.*/, '')
+
+ result = []
+
+ patterns.split.each do |patt|
+ candidates = Dir.glob(File.join(in_dir, patt))
+ result.concat(normalized_file_list(options, candidates))
+ end
+ result
+ end
+
+
+ # Given a list of files and directories, create a list
+ # of all the Ruby files they contain.
+ #
+ # If +force_dic+ is true, we always add the given files.
+ # If false, only add files that we guarantee we can parse
+ # It is true when looking at files given on the command line,
+ # false when recursing through subdirectories.
+ #
+ # The effect of this is that if you want a file with a non-
+ # standard extension parsed, you must name it explicity.
+
+ def normalized_file_list(options, relative_files, force_doc = false)
+ file_list = []
+
+ relative_files.each do |rel_file_name|
+ next if options.exclude && options.exclude =~ rel_file_name
+ case type = File.stat(rel_file_name).ftype
+ when "file"
+ file_list << rel_file_name.sub(/^\.\//, '') if force_doc || ParserFactory.can_parse(rel_file_name)
+ when "directory"
+ next if rel_file_name == "CVS" || rel_file_name == ".svn"
+ dot_doc = File.join(rel_file_name, DOT_DOC_FILENAME)
+ if File.file?(dot_doc)
+ file_list.concat(parse_dot_doc_file(rel_file_name, dot_doc, options))
+ else
+ file_list.concat(list_files_in_directory(rel_file_name, options))
+ end
+ else
+ raise RDocError.new("I can't deal with a #{type} #{rel_file_name}")
+ end
+ end
+ file_list
+ end
+
+ # Return a list of the files to be processed in
+ # a directory. We know that this directory doesn't have
+ # a .document file, so we're looking for real files. However
+ # we may well contain subdirectories which must
+ # be tested for .document files
+ def list_files_in_directory(dir, options)
+ normalized_file_list(options, Dir.glob(File.join(dir, "*")))
+ end
+
+
+ # Parse each file on the command line, recursively entering
+ # directories
+
+ def parse_files(options)
+
+ file_info = []
+
+ files = options.files
+ files = ["."] if files.empty?
+
+ file_list = normalized_file_list(options, files, true)
+
+ file_list.each do |fn|
+ $stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
+
+ content = File.open(fn, "r") {|f| f.read}
+
+ top_level = TopLevel.new(fn)
+ parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
+ file_info << parser.scan
+ @stats.num_files += 1
+ end
+
+ file_info
+ end
+
+
+ public
+
+ ###################################################################
+ #
+ # Format up one or more files according to the given arguments.
+ # For simplicity, _argv_ is an array of strings, equivalent to the
+ # strings that would be passed on the command line. (This isn't a
+ # coincidence, as we _do_ pass in ARGV when running
+ # interactively). For a list of options, see rdoc/rdoc.rb. By
+ # default, output will be stored in a directory called +doc+ below
+ # the current directory, so make sure you're somewhere writable
+ # before invoking.
+ #
+ # Throws: RDocError on error
+
+ def document(argv)
+
+ TopLevel::reset
+
+ @stats = Stats.new
+
+ options = Options.instance
+ options.parse(argv, GENERATORS)
+
+ unless options.all_one_file
+ setup_output_dir(options.op_dir)
+ end
+
+ file_info = parse_files(options)
+
+ gen = options.generator
+
+ $stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
+
+ require gen.file_name
+
+ gen_class = Generators.const_get(gen.class_name)
+
+ unless file_info.empty?
+ gen = gen_class.for(options)
+
+ pwd = Dir.pwd
+
+ Dir.chdir(options.op_dir) unless options.all_one_file
+
+ begin
+ Diagram.new(file_info, options).draw if options.diagram
+ gen.generate(file_info)
+ ensure
+ Dir.chdir(pwd)
+ end
+ end
+
+ unless options.quiet
+ puts
+ @stats.print
+ end
+ end
+ end
+end
+
diff --git a/lib/rdoc/ri/ri_cache.rb b/lib/rdoc/ri/ri_cache.rb
new file mode 100644
index 0000000000..1844ac969e
--- /dev/null
+++ b/lib/rdoc/ri/ri_cache.rb
@@ -0,0 +1,187 @@
+module RI
+
+ class ClassEntry
+
+ attr_reader :name
+ attr_reader :path_names
+
+ def initialize(path_name, name, in_class)
+ @path_names = [ path_name ]
+ @name = name
+ @in_class = in_class
+ @class_methods = []
+ @instance_methods = []
+ @inferior_classes = []
+ end
+
+ # We found this class in more tha one place, so add
+ # in the name from there.
+ def add_path(path)
+ @path_names << path
+ end
+
+ # read in our methods and any classes
+ # and modules in our namespace. Methods are
+ # stored in files called name-c|i.yaml,
+ # where the 'name' portion is the external
+ # form of the method name and the c|i is a class|instance
+ # flag
+
+ def load_from(dir)
+ Dir.foreach(dir) do |name|
+ next if name =~ /^\./
+
+ # convert from external to internal form, and
+ # extract the instance/class flag
+
+ if name =~ /^(.*?)-(c|i).yaml$/
+ external_name = $1
+ is_class_method = $2 == "c"
+ internal_name = RiWriter.external_to_internal(external_name)
+ list = is_class_method ? @class_methods : @instance_methods
+ path = File.join(dir, name)
+ list << MethodEntry.new(path, internal_name, is_class_method, self)
+ else
+ full_name = File.join(dir, name)
+ if File.directory?(full_name)
+ inf_class = @inferior_classes.find {|c| c.name == name }
+ if inf_class
+ inf_class.add_path(full_name)
+ else
+ inf_class = ClassEntry.new(full_name, name, self)
+ @inferior_classes << inf_class
+ end
+ inf_class.load_from(full_name)
+ end
+ end
+ end
+ end
+
+ # Return a list of any classes or modules that we contain
+ # that match a given string
+
+ def contained_modules_matching(name)
+ @inferior_classes.find_all {|c| c.name[name]}
+ end
+
+ def classes_and_modules
+ @inferior_classes
+ end
+
+ # Return an exact match to a particular name
+ def contained_class_named(name)
+ @inferior_classes.find {|c| c.name == name}
+ end
+
+ # return the list of local methods matching name
+ # We're split into two because we need distinct behavior
+ # when called from the _toplevel_
+ def methods_matching(name, is_class_method)
+ local_methods_matching(name, is_class_method)
+ end
+
+ # Find methods matching 'name' in ourselves and in
+ # any classes we contain
+ def recursively_find_methods_matching(name, is_class_method)
+ res = local_methods_matching(name, is_class_method)
+ @inferior_classes.each do |c|
+ res.concat(c.recursively_find_methods_matching(name, is_class_method))
+ end
+ res
+ end
+
+
+ # Return our full name
+ def full_name
+ res = @in_class.full_name
+ res << "::" unless res.empty?
+ res << @name
+ end
+
+ # Return a list of all out method names
+ def all_method_names
+ res = @class_methods.map {|m| m.full_name }
+ @instance_methods.each {|m| res << m.full_name}
+ res
+ end
+
+ private
+
+ # Return a list of all our methods matching a given string.
+ # Is +is_class_methods+ if 'nil', we don't care if the method
+ # is a class method or not, otherwise we only return
+ # those methods that match
+ def local_methods_matching(name, is_class_method)
+
+ list = case is_class_method
+ when nil then @class_methods + @instance_methods
+ when true then @class_methods
+ when false then @instance_methods
+ else fail "Unknown is_class_method: #{is_class_method.inspect}"
+ end
+
+ list.find_all {|m| m.name; m.name[name]}
+ end
+ end
+
+ # A TopLevelEntry is like a class entry, but when asked to search
+ # for methods searches all classes, not just itself
+
+ class TopLevelEntry < ClassEntry
+ def methods_matching(name, is_class_method)
+ res = recursively_find_methods_matching(name, is_class_method)
+ end
+
+ def full_name
+ ""
+ end
+
+ def module_named(name)
+
+ end
+
+ end
+
+ class MethodEntry
+ attr_reader :name
+ attr_reader :path_name
+
+ def initialize(path_name, name, is_class_method, in_class)
+ @path_name = path_name
+ @name = name
+ @is_class_method = is_class_method
+ @in_class = in_class
+ end
+
+ def full_name
+ res = @in_class.full_name
+ unless res.empty?
+ if @is_class_method
+ res << "::"
+ else
+ res << "#"
+ end
+ end
+ res << @name
+ end
+ end
+
+ # We represent everything know about all 'ri' files
+ # accessible to this program
+
+ class RiCache
+
+ attr_reader :toplevel
+
+ def initialize(dirs)
+ # At the top level we have a dummy module holding the
+ # overall namespace
+ @toplevel = TopLevelEntry.new('', '::', nil)
+
+ dirs.each do |dir|
+ @toplevel.load_from(dir)
+ end
+ end
+
+ end
+end
diff --git a/lib/rdoc/ri/ri_descriptions.rb b/lib/rdoc/ri/ri_descriptions.rb
new file mode 100644
index 0000000000..316fc91903
--- /dev/null
+++ b/lib/rdoc/ri/ri_descriptions.rb
@@ -0,0 +1,152 @@
+require 'yaml'
+require 'rdoc/markup/simple_markup/fragments'
+
+# Descriptions are created by RDoc (in ri_generator) and
+# written out in serialized form into the documentation
+# tree. ri then reads these to generate the documentation
+
+module RI
+ class NamedThing
+ attr_reader :name
+ def initialize(name)
+ @name = name
+ end
+ def <=>(other)
+ @name <=> other.name
+ end
+
+ def hash
+ @name.hash
+ end
+
+ def eql?(other)
+ @name.eql?(other)
+ end
+ end
+
+# Alias = Struct.new(:old_name, :new_name)
+
+ class AliasName < NamedThing
+ end
+
+ class Attribute < NamedThing
+ attr_reader :rw, :comment
+ def initialize(name, rw, comment)
+ super(name)
+ @rw = rw
+ @comment = comment
+ end
+ end
+
+ class Constant < NamedThing
+ attr_reader :value, :comment
+ def initialize(name, value, comment)
+ super(name)
+ @value = value
+ @comment = comment
+ end
+ end
+
+ class IncludedModule < NamedThing
+ end
+
+
+ class MethodSummary < NamedThing
+ def initialize(name="")
+ super
+ end
+ end
+
+
+
+ class Description
+ attr_accessor :name
+ attr_accessor :full_name
+ attr_accessor :comment
+
+ def serialize
+ self.to_yaml
+ end
+
+ def Description.deserialize(from)
+ YAML.load(from)
+ end
+
+ def <=>(other)
+ @name <=> other.name
+ end
+ end
+
+ class ModuleDescription < Description
+
+ attr_accessor :class_methods
+ attr_accessor :instance_methods
+ attr_accessor :attributes
+ attr_accessor :constants
+ attr_accessor :includes
+
+ # merge in another class desscription into this one
+ def merge_in(old)
+ merge(@class_methods, old.class_methods)
+ merge(@instance_methods, old.instance_methods)
+ merge(@attributes, old.attributes)
+ merge(@constants, old.constants)
+ merge(@includes, old.includes)
+ if @comment.nil? || @comment.empty?
+ @comment = old.comment
+ else
+ @comment << SM::Flow::RULE.new
+ @comment.concat old.comment
+ end
+ end
+
+ def display_name
+ "Module"
+ end
+
+ # the 'ClassDescription' subclass overrides this
+ # to format up the name of a parent
+ def superclass_string
+ nil
+ end
+
+ private
+
+ def merge(into, from)
+ names = {}
+ into.each {|i| names[i.name] = i }
+ from.each {|i| names[i.name] = i }
+ into.replace(names.keys.sort.map {|n| names[n]})
+ end
+ end
+
+ class ClassDescription < ModuleDescription
+ attr_accessor :superclass
+
+ def display_name
+ "Class"
+ end
+
+ def superclass_string
+ if @superclass && @superclass != "Object"
+ @superclass
+ else
+ nil
+ end
+ end
+ end
+
+
+ class MethodDescription < Description
+
+ attr_accessor :is_class_method
+ attr_accessor :visibility
+ attr_accessor :block_params
+ attr_accessor :is_singleton
+ attr_accessor :aliases
+ attr_accessor :is_alias_for
+ attr_accessor :params
+
+ end
+
+end
diff --git a/lib/rdoc/ri/ri_display.rb b/lib/rdoc/ri/ri_display.rb
new file mode 100644
index 0000000000..076df46b17
--- /dev/null
+++ b/lib/rdoc/ri/ri_display.rb
@@ -0,0 +1,273 @@
+require 'rdoc/ri/ri_util'
+require 'rdoc/ri/ri_formatter'
+require 'rdoc/ri/ri_options'
+
+
+# This is a kind of 'flag' module. If you want to write your
+# own 'ri' display module (perhaps because you'r writing
+# an IDE or somesuch beast), you simply write a class
+# which implements the various 'display' methods in 'DefaultDisplay',
+# and include the 'RiDisplay' module in that class.
+#
+# To access your class from the command line, you can do
+#
+# ruby -r <your source file> ../ri ....
+#
+# If folks _really_ want to do this from the command line,
+# I'll build an option in
+
+module RiDisplay
+ @@display_class = nil
+
+ def RiDisplay.append_features(display_class)
+ @@display_class = display_class
+ end
+
+ def RiDisplay.new(*args)
+ @@display_class.new(*args)
+ end
+end
+
+######################################################################
+#
+# A paging display module. Uses the ri_formatter class to do the
+# actual presentation
+#
+
+class DefaultDisplay
+
+ include RiDisplay
+
+ def initialize(options)
+ @options = options
+ @formatter = @options.formatter.new(@options, " ")
+ end
+
+
+ ######################################################################
+
+ def display_usage
+ page do
+ RI::Options::OptionList.usage(short_form=true)
+ end
+ end
+
+
+ ######################################################################
+
+ def display_method_info(method)
+ page do
+ @formatter.draw_line(method.full_name)
+ display_params(method)
+ @formatter.draw_line
+ display_flow(method.comment)
+ if method.aliases && !method.aliases.empty?
+ @formatter.blankline
+ aka = "(also known as "
+ aka << method.aliases.map {|a| a.name }.join(", ")
+ aka << ")"
+ @formatter.wrap(aka)
+ end
+ end
+ end
+
+ ######################################################################
+
+ def display_class_info(klass, ri_reader)
+ page do
+ superclass = klass.superclass_string
+
+ if superclass
+ superclass = " < " + superclass
+ else
+ superclass = ""
+ end
+
+ @formatter.draw_line(klass.display_name + ": " +
+ klass.full_name + superclass)
+
+ display_flow(klass.comment)
+ @formatter.draw_line
+
+ unless klass.includes.empty?
+ @formatter.blankline
+ @formatter.display_heading("Includes:", 2, "")
+ incs = []
+ klass.includes.each do |inc|
+ inc_desc = ri_reader.find_class_by_name(inc.name)
+ if inc_desc
+ str = inc.name + "("
+ str << inc_desc.instance_methods.map{|m| m.name}.join(", ")
+ str << ")"
+ incs << str
+ else
+ incs << inc.name
+ end
+ end
+ @formatter.wrap(incs.sort.join(', '))
+ end
+
+ unless klass.constants.empty?
+ @formatter.blankline
+ @formatter.display_heading("Constants:", 2, "")
+ len = 0
+ klass.constants.each { |c| len = c.name.length if c.name.length > len }
+ len += 2
+ klass.constants.each do |c|
+ @formatter.wrap(c.value,
+ @formatter.indent+((c.name+":").ljust(len)))
+ end
+ end
+
+ unless klass.class_methods.empty?
+ @formatter.blankline
+ @formatter.display_heading("Class methods:", 2, "")
+ @formatter.wrap(klass.class_methods.map{|m| m.name}.sort.join(', '))
+ end
+
+ unless klass.instance_methods.empty?
+ @formatter.blankline
+ @formatter.display_heading("Instance methods:", 2, "")
+ @formatter.wrap(klass.instance_methods.map{|m| m.name}.sort.join(', '))
+ end
+
+ unless klass.attributes.empty?
+ @formatter.blankline
+ @formatter.wrap("Attributes:", "")
+ @formatter.wrap(klass.attributes.map{|a| a.name}.sort.join(', '))
+ end
+ end
+ end
+
+ ######################################################################
+
+ # Display a list of method names
+
+ def display_method_list(methods)
+ page do
+ puts "More than one method matched your request. You can refine"
+ puts "your search by asking for information on one of:\n\n"
+ @formatter.wrap(methods.map {|m| m.full_name} .join(", "))
+ end
+ end
+
+ ######################################################################
+
+ def display_class_list(namespaces)
+ page do
+ puts "More than one class or module matched your request. You can refine"
+ puts "your search by asking for information on one of:\n\n"
+ @formatter.wrap(namespaces.map {|m| m.full_name}.join(", "))
+ end
+ end
+
+ ######################################################################
+
+ def list_known_classes(classes)
+ if classes.empty?
+ warn_no_database
+ else
+ page do
+ @formatter.draw_line("Known classes and modules")
+ @formatter.blankline
+ @formatter.wrap(classes.sort.join(", "))
+ end
+ end
+ end
+
+ ######################################################################
+
+ def list_known_names(names)
+ if names.empty?
+ warn_no_database
+ else
+ page do
+ names.each {|n| @formatter.raw_print_line(n)}
+ end
+ end
+ end
+
+ ######################################################################
+
+ private
+
+ ######################################################################
+
+ def page
+ setup_pager
+ begin
+ yield
+ page_output
+ ensure
+ STDOUT.reopen(@save_stdout) if @save_stdout
+ end
+ end
+
+ ######################################################################
+
+ def setup_pager
+ unless @options.use_stdout
+ require 'tempfile'
+
+ @save_stdout = STDOUT.clone
+ STDOUT.reopen(Tempfile.new("ri_"))
+ end
+ end
+
+ ######################################################################
+
+ def page_output
+ unless @options.use_stdout
+ path = STDOUT.path
+ STDOUT.reopen(@save_stdout)
+ @save_stdout = nil
+ paged = false
+ for pager in [ ENV['PAGER'], "less", "more <", 'pager' ].compact.uniq
+ if system("#{pager} #{path}")
+ paged = true
+ break
+ end
+ end
+ if !paged
+ @options.use_stdout = true
+ puts File.read(path)
+ end
+ end
+ end
+
+ ######################################################################
+
+ def display_params(method)
+
+ params = method.params
+
+ if params[0,1] == "("
+ if method.is_singleton
+ params = method.full_name + params
+ else
+ params = method.name + params
+ end
+ end
+ params.split(/\n/).each do |p|
+ @formatter.wrap(p)
+ @formatter.break_to_newline
+ end
+ end
+ ######################################################################
+
+ def warn_no_database
+ puts "Before using ri, you need to generate documentation"
+ puts "using 'rdoc' with the --ri option"
+ end
+ ######################################################################
+
+ def display_flow(flow)
+ if !flow || flow.empty?
+ @formatter.wrap("(no description...)")
+ else
+ @formatter.display_flow(flow)
+ end
+ end
+
+
+end # class RiDisplay
diff --git a/lib/rdoc/ri/ri_driver.rb b/lib/rdoc/ri/ri_driver.rb
new file mode 100644
index 0000000000..d2545bb1da
--- /dev/null
+++ b/lib/rdoc/ri/ri_driver.rb
@@ -0,0 +1,145 @@
+require 'rdoc/usage'
+require 'rdoc/ri/ri_paths'
+require 'rdoc/ri/ri_cache'
+require 'rdoc/ri/ri_util'
+require 'rdoc/ri/ri_reader'
+require 'rdoc/ri/ri_formatter'
+require 'rdoc/ri/ri_options'
+
+
+######################################################################
+
+class RiDriver
+
+ def initialize
+ @options = RI::Options.instance
+
+ args = ARGV
+ if ENV["RI"]
+ args = ENV["RI"].split.concat(ARGV)
+ end
+
+ @options.parse(args)
+
+ paths = @options.paths || RI::Paths::PATH
+ if paths.empty?
+ report_missing_documentation(paths)
+ end
+ @ri_reader = RI::RiReader.new(RI::RiCache.new(paths))
+ @display = @options.displayer
+ end
+
+ # Couldn't find documentation in paths, so tell the user
+ # what to do
+
+ def report_missing_documentation(paths)
+ STDERR.puts "No ri documentation found in:"
+ paths.each do |d|
+ STDERR.puts " #{d}"
+ end
+ STDERR.puts "\nWas rdoc run to create documentation?\n\n"
+ RDoc::usage("Installing Documentation")
+ end
+
+ ######################################################################
+
+ # If the list of matching methods contains exactly one entry, or
+ # if it contains an entry that exactly matches the requested method,
+ # then display that entry, otherwise display the list of
+ # matching method names
+
+ def report_method_stuff(requested_method_name, methods)
+ if methods.size == 1
+ method = @ri_reader.get_method(methods[0])
+ @display.display_method_info(method)
+ else
+ entries = methods.find_all {|m| m.name == requested_method_name}
+ if entries.size == 1
+ method = @ri_reader.get_method(entries[0])
+ @display.display_method_info(method)
+ else
+ @display.display_method_list(methods)
+ end
+ end
+ end
+
+ ######################################################################
+
+ def report_class_stuff(namespaces)
+ if namespaces.size == 1
+ klass = @ri_reader.get_class(namespaces[0])
+ @display.display_class_info(klass, @ri_reader)
+ else
+# entries = namespaces.find_all {|m| m.full_name == requested_class_name}
+# if entries.size == 1
+# klass = @ri_reader.get_class(entries[0])
+# @display.display_class_info(klass, @ri_reader)
+# else
+ @display.display_class_list(namespaces)
+# end
+ end
+ end
+
+ ######################################################################
+
+
+ def get_info_for(arg)
+ desc = NameDescriptor.new(arg)
+
+ namespaces = @ri_reader.top_level_namespace
+
+ for class_name in desc.class_names
+ namespaces = @ri_reader.lookup_namespace_in(class_name, namespaces)
+ if namespaces.empty?
+ raise RiError.new("Nothing known about #{arg}")
+ end
+ end
+
+ # at this point, if we have multiple possible namespaces, but one
+ # is an exact match for our requested class, prune down to just it
+
+ full_class_name = desc.full_class_name
+ entries = namespaces.find_all {|m| m.full_name == full_class_name}
+ namespaces = entries if entries.size == 1
+
+ if desc.method_name.nil?
+ report_class_stuff(namespaces)
+ else
+ methods = @ri_reader.find_methods(desc.method_name,
+ desc.is_class_method,
+ namespaces)
+
+ if methods.empty?
+ raise RiError.new("Nothing known about #{arg}")
+ else
+ report_method_stuff(desc.method_name, methods)
+ end
+ end
+ end
+
+ ######################################################################
+
+ def process_args
+ if @options.list_classes
+ classes = @ri_reader.full_class_names
+ @display.list_known_classes(classes)
+ elsif @options.list_names
+ names = @ri_reader.all_names
+ @display.list_known_names(names)
+ else
+ if ARGV.size.zero?
+ @display.display_usage
+ else
+ begin
+ ARGV.each do |arg|
+ get_info_for(arg)
+ end
+ rescue RiError => e
+ STDERR.puts(e.message)
+ exit(1)
+ end
+ end
+ end
+ end
+
+end # class RiDriver
diff --git a/lib/rdoc/ri/ri_formatter.rb b/lib/rdoc/ri/ri_formatter.rb
new file mode 100644
index 0000000000..15c964618c
--- /dev/null
+++ b/lib/rdoc/ri/ri_formatter.rb
@@ -0,0 +1,651 @@
+module RI
+ class TextFormatter
+
+ attr_reader :indent
+
+ def initialize(options, indent)
+ @options = options
+ @width = options.width
+ @indent = indent
+ end
+
+
+ ######################################################################
+
+ def draw_line(label=nil)
+ len = @width
+ len -= (label.size+1) if label
+ print "-"*len
+ if label
+ print(" ")
+ bold_print(label)
+ end
+ puts
+ end
+
+ ######################################################################
+
+ def wrap(txt, prefix=@indent, linelen=@width)
+ return unless txt && !txt.empty?
+ work = conv_markup(txt)
+ textLen = linelen - prefix.length
+ patt = Regexp.new("^(.{0,#{textLen}})[ \n]")
+ next_prefix = prefix.tr("^ ", " ")
+
+ res = []
+
+ while work.length > textLen
+ if work =~ patt
+ res << $1
+ work.slice!(0, $&.length)
+ else
+ res << work.slice!(0, textLen)
+ end
+ end
+ res << work if work.length.nonzero?
+ puts (prefix + res.join("\n" + next_prefix))
+ end
+
+ ######################################################################
+
+ def blankline
+ puts
+ end
+
+ ######################################################################
+
+ # called when we want to ensure a nbew 'wrap' starts on a newline
+ # Only needed for HtmlFormatter, because the rest do their
+ # own line breaking
+
+ def break_to_newline
+ end
+
+ ######################################################################
+
+ def bold_print(txt)
+ print txt
+ end
+
+ ######################################################################
+
+ def raw_print_line(txt)
+ puts txt
+ end
+
+ ######################################################################
+
+ # convert HTML entities back to ASCII
+ def conv_html(txt)
+ txt.
+ gsub(/&gt;/, '>').
+ gsub(/&lt;/, '<').
+ gsub(/&quot;/, '"').
+ gsub(/&amp;/, '&')
+
+ end
+
+ # convert markup into display form
+ def conv_markup(txt)
+ txt.
+ gsub(%r{<tt>(.*?)</tt>}) { "+#$1+" } .
+ gsub(%r{<code>(.*?)</code>}) { "+#$1+" } .
+ gsub(%r{<b>(.*?)</b>}) { "*#$1*" } .
+ gsub(%r{<em>(.*?)</em>}) { "_#$1_" }
+ end
+
+ ######################################################################
+
+ def display_list(list)
+ case list.type
+
+ when SM::ListBase::BULLET
+ prefixer = proc { |ignored| @indent + "* " }
+
+ when SM::ListBase::NUMBER,
+ SM::ListBase::UPPERALPHA,
+ SM::ListBase::LOWERALPHA
+
+ start = case list.type
+ when SM::ListBase::NUMBER then 1
+ when SM::ListBase::UPPERALPHA then 'A'
+ when SM::ListBase::LOWERALPHA then 'a'
+ end
+ prefixer = proc do |ignored|
+ res = @indent + "#{start}.".ljust(4)
+ start = start.succ
+ res
+ end
+
+ when SM::ListBase::LABELED
+ prefixer = proc do |li|
+ li.label
+ end
+
+ when SM::ListBase::NOTE
+ longest = 0
+ list.contents.each do |item|
+ if item.kind_of?(SM::Flow::LI) && item.label.length > longest
+ longest = item.label.length
+ end
+ end
+
+ prefixer = proc do |li|
+ @indent + li.label.ljust(longest+1)
+ end
+
+ else
+ fail "unknown list type"
+
+ end
+
+ list.contents.each do |item|
+ if item.kind_of? SM::Flow::LI
+ prefix = prefixer.call(item)
+ display_flow_item(item, prefix)
+ else
+ display_flow_item(item)
+ end
+ end
+ end
+
+ ######################################################################
+
+ def display_flow_item(item, prefix=@indent)
+ case item
+ when SM::Flow::P, SM::Flow::LI
+ wrap(conv_html(item.body), prefix)
+ blankline
+
+ when SM::Flow::LIST
+ display_list(item)
+
+ when SM::Flow::VERB
+ display_verbatim_flow_item(item, @indent)
+
+ when SM::Flow::H
+ display_heading(conv_html(item.text.join), item.level, @indent)
+
+ when SM::Flow::RULE
+ draw_line
+
+ else
+ fail "Unknown flow element: #{item.class}"
+ end
+ end
+
+ ######################################################################
+
+ def display_verbatim_flow_item(item, prefix=@indent)
+ item.body.split(/\n/).each do |line|
+ print @indent, conv_html(line), "\n"
+ end
+ blankline
+ end
+
+ ######################################################################
+
+ def display_heading(text, level, indent)
+ case level
+ when 1
+ ul = "=" * text.length
+ puts
+ puts text.upcase
+ puts ul
+# puts
+
+ when 2
+ ul = "-" * text.length
+ puts
+ puts text
+ puts ul
+# puts
+ else
+ print indent, text, "\n"
+ end
+ end
+
+
+ def display_flow(flow)
+ flow.each do |f|
+ display_flow_item(f)
+ end
+ end
+ end
+
+
+ ######################################################################
+ # Handle text with attributes. We're a base class: there are
+ # different presentation classes (one, for example, uses overstrikes
+ # to handle bold and underlinig, while another using ANSI escape
+ # sequences
+
+ class AttributeFormatter < TextFormatter
+
+ BOLD = 1
+ ITALIC = 2
+ CODE = 4
+
+ ATTR_MAP = {
+ "b" => BOLD,
+ "code" => CODE,
+ "em" => ITALIC,
+ "i" => ITALIC,
+ "tt" => CODE
+ }
+
+ # TODO: struct?
+ class AttrChar
+ attr_reader :char
+ attr_reader :attr
+
+ def initialize(char, attr)
+ @char = char
+ @attr = attr
+ end
+ end
+
+
+ class AttributeString
+ def initialize
+ @txt = []
+ @optr = 0
+ end
+
+ def <<(char)
+ @txt << char
+ end
+
+ def empty?
+ @optr >= @txt.length
+ end
+
+ # accept non space, then all following spaces
+ def next_word
+ start = @optr
+ len = @txt.length
+
+ while @optr < len && @txt[@optr].char != " "
+ @optr += 1
+ end
+
+ while @optr < len && @txt[@optr].char == " "
+ @optr += 1
+ end
+
+ @txt[start...@optr]
+ end
+ end
+
+ ######################################################################
+ # overrides base class. Looks for <tt>...</tt> etc sequences
+ # and generates an array of AttrChars. This array is then used
+ # as the basis for the split
+
+ def wrap(txt, prefix=@indent, linelen=@width)
+ return unless txt && !txt.empty?
+
+ txt = add_attributes_to(txt)
+ next_prefix = prefix.tr("^ ", " ")
+ linelen -= prefix.size
+
+ line = []
+
+ until txt.empty?
+ word = txt.next_word
+ if word.size + line.size > linelen
+ write_attribute_text(prefix, line)
+ prefix = next_prefix
+ line = []
+ end
+ line.concat(word)
+ end
+
+ write_attribute_text(prefix, line) if line.length > 0
+ end
+
+ protected
+
+ # overridden in specific formatters
+
+ def write_attribute_text(prefix, line)
+ print prefix
+ line.each do |achar|
+ print achar.char
+ end
+ puts
+ end
+
+ # again, overridden
+
+ def bold_print(txt)
+ print txt
+ end
+
+ private
+
+ def add_attributes_to(txt)
+ tokens = txt.split(%r{(</?(?:b|code|em|i|tt)>)})
+ text = AttributeString.new
+ attributes = 0
+ tokens.each do |tok|
+ case tok
+ when %r{^</(\w+)>$} then attributes &= ~(ATTR_MAP[$1]||0)
+ when %r{^<(\w+)>$} then attributes |= (ATTR_MAP[$1]||0)
+ else
+ tok.split(//).each {|ch| text << AttrChar.new(ch, attributes)}
+ end
+ end
+ text
+ end
+
+ end
+
+
+ ##################################################
+
+ # This formatter generates overstrike-style formatting, which
+ # works with pages such as man and less.
+
+ class OverstrikeFormatter < AttributeFormatter
+
+ BS = "\C-h"
+
+ def write_attribute_text(prefix, line)
+ print prefix
+ line.each do |achar|
+ attr = achar.attr
+ if (attr & (ITALIC+CODE)) != 0
+ print "_", BS
+ end
+ if (attr & BOLD) != 0
+ print achar.char, BS
+ end
+ print achar.char
+ end
+ puts
+ end
+
+ # draw a string in bold
+ def bold_print(text)
+ text.split(//).each do |ch|
+ print ch, BS, ch
+ end
+ end
+ end
+
+ ##################################################
+
+ # This formatter uses ANSI escape sequences
+ # to colorize stuff
+ # works with pages such as man and less.
+
+ class AnsiFormatter < AttributeFormatter
+
+ def initialize(*args)
+ print "\033[0m"
+ super
+ end
+
+ def write_attribute_text(prefix, line)
+ print prefix
+ curr_attr = 0
+ line.each do |achar|
+ attr = achar.attr
+ if achar.attr != curr_attr
+ update_attributes(achar.attr)
+ curr_attr = achar.attr
+ end
+ print achar.char
+ end
+ update_attributes(0) unless curr_attr.zero?
+ puts
+ end
+
+
+ def bold_print(txt)
+ print "\033[1m#{txt}\033[m"
+ end
+
+ HEADINGS = {
+ 1 => "\033[1;32m%s\033[m",
+ 2 => "\033[4;32m%s\033[m",
+ 3 => "\033[32m%s\033[m"
+ }
+
+ def display_heading(text, level, indent)
+ level = 3 if level > 3
+ print indent
+ printf(HEADINGS[level], text)
+ puts
+ end
+
+ private
+
+ ATTR_MAP = {
+ BOLD => "1",
+ ITALIC => "33",
+ CODE => "36"
+ }
+
+ def update_attributes(attr)
+ str = "\033["
+ for quality in [ BOLD, ITALIC, CODE]
+ unless (attr & quality).zero?
+ str << ATTR_MAP[quality]
+ end
+ end
+ print str, "m"
+ end
+ end
+
+ ##################################################
+
+ # This formatter uses HTML.
+
+ class HtmlFormatter < AttributeFormatter
+
+ def initialize(*args)
+ super
+ end
+
+ def write_attribute_text(prefix, line)
+ curr_attr = 0
+ line.each do |achar|
+ attr = achar.attr
+ if achar.attr != curr_attr
+ update_attributes(curr_attr, achar.attr)
+ curr_attr = achar.attr
+ end
+ print(escape(achar.char))
+ end
+ update_attributes(curr_attr, 0) unless curr_attr.zero?
+ end
+
+ def draw_line(label=nil)
+ if label != nil
+ bold_print(label)
+ end
+ puts("<hr>")
+ end
+
+ def bold_print(txt)
+ tag("b") { txt }
+ end
+
+ def blankline()
+ puts("<p>")
+ end
+
+ def break_to_newline
+ puts("<br>")
+ end
+
+ def display_heading(text, level, indent)
+ level = 4 if level > 4
+ tag("h#{level}") { text }
+ puts
+ end
+
+ ######################################################################
+
+ def display_list(list)
+
+ case list.type
+ when SM::ListBase::BULLET
+ list_type = "ul"
+ prefixer = proc { |ignored| "<li>" }
+
+ when SM::ListBase::NUMBER,
+ SM::ListBase::UPPERALPHA,
+ SM::ListBase::LOWERALPHA
+ list_type = "ol"
+ prefixer = proc { |ignored| "<li>" }
+
+ when SM::ListBase::LABELED
+ list_type = "dl"
+ prefixer = proc do |li|
+ "<dt><b>" + escape(li.label) + "</b><dd>"
+ end
+
+ when SM::ListBase::NOTE
+ list_type = "table"
+ prefixer = proc do |li|
+ %{<tr valign="top"><td>#{li.label.gsub(/ /, '&nbsp;')}</td><td>}
+ end
+ else
+ fail "unknown list type"
+ end
+
+ print "<#{list_type}>"
+ list.contents.each do |item|
+ if item.kind_of? SM::Flow::LI
+ prefix = prefixer.call(item)
+ print prefix
+ display_flow_item(item, prefix)
+ else
+ display_flow_item(item)
+ end
+ end
+ print "</#{list_type}>"
+ end
+
+ def display_verbatim_flow_item(item, prefix=@indent)
+ print("<pre>")
+ item.body.split(/\n/).each do |line|
+ puts conv_html(line)
+ end
+ puts("</pre>")
+ end
+
+ private
+
+ ATTR_MAP = {
+ BOLD => "b>",
+ ITALIC => "i>",
+ CODE => "tt>"
+ }
+
+ def update_attributes(current, wanted)
+ str = ""
+ # first turn off unwanted ones
+ off = current & ~wanted
+ for quality in [ BOLD, ITALIC, CODE]
+ if (off & quality) > 0
+ str << "</" + ATTR_MAP[quality]
+ end
+ end
+
+ # now turn on wanted
+ for quality in [ BOLD, ITALIC, CODE]
+ unless (wanted & quality).zero?
+ str << "<" << ATTR_MAP[quality]
+ end
+ end
+ print str
+ end
+
+ def tag(code)
+ print("<#{code}>")
+ print(yield)
+ print("</#{code}>")
+ end
+
+ def escape(str)
+ str.
+ gsub(/&/n, '&amp;').
+ gsub(/\"/n, '&quot;').
+ gsub(/>/n, '&gt;').
+ gsub(/</n, '&lt;')
+ end
+
+ end
+
+ ##################################################
+
+ # This formatter reduces extra lines for a simpler output.
+ # It improves way output looks for tools like IRC bots.
+
+ class SimpleFormatter < TextFormatter
+
+ ######################################################################
+
+ # No extra blank lines
+
+ def blankline
+ end
+
+ ######################################################################
+
+ # Display labels only, no lines
+
+ def draw_line(label=nil)
+ unless label.nil? then
+ bold_print(label)
+ puts
+ end
+ end
+
+ ######################################################################
+
+ # Place heading level indicators inline with heading.
+
+ def display_heading(text, level, indent)
+ case level
+ when 1
+ puts "= " + text.upcase
+ when 2
+ puts "-- " + text
+ else
+ print indent, text, "\n"
+ end
+ end
+
+ end
+
+
+ # Finally, fill in the list of known formatters
+
+ class TextFormatter
+
+ FORMATTERS = {
+ "ansi" => AnsiFormatter,
+ "bs" => OverstrikeFormatter,
+ "html" => HtmlFormatter,
+ "plain" => TextFormatter,
+ "simple" => SimpleFormatter,
+ }
+
+ def TextFormatter.list
+ FORMATTERS.keys.sort.join(", ")
+ end
+
+ def TextFormatter.for(name)
+ FORMATTERS[name.downcase]
+ end
+
+ end
+
+end
+
+
diff --git a/lib/rdoc/ri/ri_options.rb b/lib/rdoc/ri/ri_options.rb
new file mode 100644
index 0000000000..f59cdeda1c
--- /dev/null
+++ b/lib/rdoc/ri/ri_options.rb
@@ -0,0 +1,257 @@
+# We handle the parsing of options, and subsequently as a singleton
+# object to be queried for option values
+
+module RI
+
+ require 'rdoc/ri/ri_display'
+
+ VERSION_STRING = "ri: beta1"
+ CVS_ID = "$Id$";
+
+ class Options
+
+ require 'singleton'
+ require 'getoptlong'
+
+ include Singleton
+
+ # No not use a pager. Writable, because ri sets it if it
+ # can't find a pager
+ attr_accessor :use_stdout
+
+ # should we just display a class list and exit
+ attr_reader :list_classes
+
+ # should we display a list of all names
+ attr_reader :list_names
+
+ # The width of the output line
+ attr_reader :width
+
+ # the formatting we apply to the output
+ attr_reader :formatter
+
+ # the directory we search for original documentation
+ attr_reader :doc_dir
+
+ module OptionList
+
+ OPTION_LIST = [
+ [ "--help", "-h", nil,
+ "you're looking at it" ],
+
+ [ "--classes", "-c", nil,
+ "Display the names of classes and modules we\n" +
+ "know about"],
+
+ [ "--doc-dir", "-d", "<dirname>",
+ "A directory to search for documentation. If not\n"+
+ "specified, we search the standard rdoc/ri directories."],
+
+ [ "--format", "-f", "<name>",
+ "Format to use when displaying output:\n" +
+ " " + RI::TextFormatter.list + "\n" +
+ "Use 'bs' (backspace) with most pager programs.\n" +
+ "To use ANSI, either also use the -T option, or\n" +
+ "tell your pager to allow control characters\n" +
+ "(for example using the -R option to less)"],
+
+ [ "--list-names", "-l", nil,
+ "List all the names known to RDoc, one per line"
+ ],
+
+ [ "--no-pager", "-T", nil,
+ "Send output directly to stdout."
+ ],
+
+ [ "--width", "-w", "output width",
+ "Set the width of the output" ],
+
+ [ "--version", "-v", nil,
+ "Display the version of ri"
+ ],
+
+ ]
+
+ def OptionList.options
+ OPTION_LIST.map do |long, short, arg,|
+ [ long,
+ short,
+ arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT
+ ]
+ end
+ end
+
+
+ def OptionList.strip_output(text)
+ text =~ /^\s+/
+ leading_spaces = $&
+ text.gsub!(/^#{leading_spaces}/, '')
+ $stdout.puts text
+ end
+
+
+ # Show an error and exit
+
+ def OptionList.error(msg)
+ $stderr.puts
+ $stderr.puts msg
+ $stderr.puts "\nFor help on options, try 'ri --help'\n\n"
+ exit 1
+ end
+
+ # Show usage and exit
+
+ def OptionList.usage(short_form=false)
+
+ puts
+ puts(RI::VERSION_STRING)
+ puts
+
+ name = File.basename($0)
+ OptionList.strip_output(<<-EOT)
+ Usage:
+
+ #{name} [options] [names...]
+
+ Display information on Ruby classes, modules, and methods.
+ Give the names of classes or methods to see their documentation.
+ Partial names may be given: if the names match more than
+ one entity, a list will be shown, otherwise details on
+ that entity will be displayed.
+
+ Nested classes and modules can be specified using the normal
+ Name::Name notation, and instance methods can be distinguished
+ from class methods using "." (or "#") instead of "::".
+
+ For example:
+
+ ri File
+ ri File.new
+ ri F.n
+ ri zip
+
+ Note that shell quoting may be required for method names
+ containing punctuation:
+
+ ri 'Array.[]'
+ ri compact\\!
+
+ EOT
+
+ if short_form
+ puts "For help on options, type 'ri -h'"
+ puts "For a list of classes I know about, type 'ri -c'"
+ else
+ puts "Options:\n\n"
+ OPTION_LIST.each do|long, short, arg, desc|
+ opt = sprintf("%15s", "#{long}, #{short}")
+ if arg
+ opt << " " << arg
+ end
+ print opt
+ desc = desc.split("\n")
+ if opt.size < 17
+ print " "*(18-opt.size)
+ puts desc.shift
+ else
+ puts
+ end
+ desc.each do |line|
+ puts(" "*18 + line)
+ end
+ puts
+ end
+ puts "Options may also be passed in the 'RI' environment variable"
+ exit 0
+ end
+ end
+ end
+
+ # Show the version and exit
+ def show_version
+ cvs_info = CVS_ID.split
+ puts "#{VERSION_STRING} (#{cvs_info[2]} #{cvs_info[3]})"
+ exit(0)
+ end
+
+
+ def initialize
+ @use_stdout = !STDOUT.tty?
+ @width = 72
+ @formatter = RI::TextFormatter.for("plain")
+ @list_classes = false
+ @list_names = false
+ end
+
+
+ # Parse command line options.
+
+ def parse(args)
+
+ old_argv = ARGV.dup
+# if ENV["RI"]
+# ARGV.replace(ENV["RI"].split.concat(ARGV))
+# end
+
+ ARGV.replace(args)
+
+ begin
+
+ go = GetoptLong.new(*OptionList.options)
+ go.quiet = true
+
+ go.each do |opt, arg|
+ case opt
+ when "--help" then OptionList.usage
+ when "--version" then show_version
+ when "--list-names" then @list_names = true
+ when "--no-pager" then @use_stdout = true
+ when "--classes" then @list_classes = true
+ when "--doc-dir"
+ if File.directory?(arg)
+ @doc_dir = arg
+ else
+ $stderr.puts "Invalid directory: #{arg}"
+ exit 1
+ end
+
+ when "--format"
+ @formatter = RI::TextFormatter.for(arg)
+ unless @formatter
+ $stderr.print "Invalid formatter (should be one of "
+ $stderr.puts RI::TextFormatter.list + ")"
+ exit 1
+ end
+ when "--width"
+ begin
+ @width = Integer(arg)
+ rescue
+ $stderr.puts "Invalid width: '#{arg}'"
+ exit 1
+ end
+ end
+ end
+
+ rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => error
+ OptionList.error(error.message)
+
+ end
+ end
+
+ # Return the doc_dir as an array, or nil if no overriding doc dir was given
+ def paths
+ defined?(@doc_dir) ? [ @doc_dir ] : nil
+ end
+
+ # Return an instance of the displayer (the thing that actually writes
+ # the information). This allows us to load in new displayer classes
+ # at runtime (for example to help with IDE integration)
+
+ def displayer
+ ::RiDisplay.new(self)
+ end
+ end
+
+end
+
diff --git a/lib/rdoc/ri/ri_paths.rb b/lib/rdoc/ri/ri_paths.rb
new file mode 100644
index 0000000000..32c2542c04
--- /dev/null
+++ b/lib/rdoc/ri/ri_paths.rb
@@ -0,0 +1,51 @@
+module RI
+
+ # Encapsulate all the strangeness to do with finding out
+ # where to find RDoc files
+ #
+ # We basically deal with three directories:
+ #
+ # 1. The 'system' documentation directory, which holds
+ # the documentation distributed with Ruby, and which
+ # is managed by the Ruby install process
+ # 2. The 'site' directory, which contains site-wide
+ # documentation added locally.
+ # 3. The 'user' documentation directory, stored under the
+ # user's own home directory.
+ #
+ # There's contention about all this, but for now:
+ #
+ # system:: $datadir/ri/<ver>/system/...
+ # site:: $datadir/ri/<ver>/site/...
+ # user:: ~/.rdoc
+
+ module Paths
+
+ #:stopdoc:
+ require 'rbconfig'
+
+ DOC_DIR = "doc/rdoc"
+
+ version = Config::CONFIG['ruby_version']
+
+ base = File.join(Config::CONFIG['datadir'], "ri", version)
+
+ if ENV["DESTDIR"]
+ SYSDIR = File.join(ENV["DESTDIR"], base, "system")
+ else
+ SYSDIR = File.join(base, "system")
+ end
+
+ SITEDIR = File.join(base, "site")
+ homedir = ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH']
+
+ if homedir
+ HOMEDIR = File.join(homedir, ".rdoc")
+ else
+ HOMEDIR = nil
+ end
+
+ # This is the search path for 'ri'
+ PATH = [ SYSDIR, SITEDIR, HOMEDIR ].find_all {|p| p && File.directory?(p)}
+ end
+end
diff --git a/lib/rdoc/ri/ri_reader.rb b/lib/rdoc/ri/ri_reader.rb
new file mode 100644
index 0000000000..fb2c373e38
--- /dev/null
+++ b/lib/rdoc/ri/ri_reader.rb
@@ -0,0 +1,100 @@
+require 'rdoc/ri/ri_descriptions'
+require 'rdoc/ri/ri_writer'
+require 'rdoc/markup/simple_markup/to_flow'
+
+module RI
+ class RiReader
+
+ def initialize(ri_cache)
+ @cache = ri_cache
+ end
+
+ def top_level_namespace
+ [ @cache.toplevel ]
+ end
+
+ def lookup_namespace_in(target, namespaces)
+ result = []
+ for n in namespaces
+ result.concat(n.contained_modules_matching(target))
+ end
+ result
+ end
+
+ def find_class_by_name(full_name)
+ names = full_name.split(/::/)
+ ns = @cache.toplevel
+ for name in names
+ ns = ns.contained_class_named(name)
+ return nil if ns.nil?
+ end
+ get_class(ns)
+ end
+
+ def find_methods(name, is_class_method, namespaces)
+ result = []
+ namespaces.each do |ns|
+ result.concat ns.methods_matching(name, is_class_method)
+ end
+ result
+ end
+
+ # return the MethodDescription for a given MethodEntry
+ # by deserializing the YAML
+ def get_method(method_entry)
+ path = method_entry.path_name
+ File.open(path) { |f| RI::Description.deserialize(f) }
+ end
+
+ # Return a class description
+ def get_class(class_entry)
+ result = nil
+ for path in class_entry.path_names
+ path = RiWriter.class_desc_path(path, class_entry)
+ desc = File.open(path) {|f| RI::Description.deserialize(f) }
+ if result
+ result.merge_in(desc)
+ else
+ result = desc
+ end
+ end
+ result
+ end
+
+ # return the names of all classes and modules
+ def full_class_names
+ res = []
+ find_classes_in(res, @cache.toplevel)
+ end
+
+ # return a list of all classes, modules, and methods
+ def all_names
+ res = []
+ find_names_in(res, @cache.toplevel)
+ end
+
+ # ----
+ private
+ # ----
+
+ def find_classes_in(res, klass)
+ classes = klass.classes_and_modules
+ for c in classes
+ res << c.full_name
+ find_classes_in(res, c)
+ end
+ res
+ end
+
+ def find_names_in(res, klass)
+ classes = klass.classes_and_modules
+ for c in classes
+ res << c.full_name
+ res.concat c.all_method_names
+ find_names_in(res, c)
+ end
+ res
+ end
+
+ end
+end
diff --git a/lib/rdoc/ri/ri_util.rb b/lib/rdoc/ri/ri_util.rb
new file mode 100644
index 0000000000..8a01255897
--- /dev/null
+++ b/lib/rdoc/ri/ri_util.rb
@@ -0,0 +1,75 @@
+######################################################################
+
+class RiError < Exception; end
+#
+# Break argument into its constituent class or module names, an
+# optional method type, and a method name
+
+class NameDescriptor
+
+ attr_reader :class_names
+ attr_reader :method_name
+
+ # true and false have the obvious meaning. nil means we don't care
+ attr_reader :is_class_method
+
+ # arg may be
+ # 1. a class or module name (optionally qualified with other class
+ # or module names (Kernel, File::Stat etc)
+ # 2. a method name
+ # 3. a method name qualified by a optionally fully qualified class
+ # or module name
+ #
+ # We're fairly casual about delimiters: folks can say Kernel::puts,
+ # Kernel.puts, or Kernel\#puts for example. There's one exception:
+ # if you say IO::read, we look for a class method, but if you
+ # say IO.read, we look for an instance method
+
+ def initialize(arg)
+ @class_names = []
+ separator = nil
+
+ tokens = arg.split(/(\.|::|#)/)
+
+ # Skip leading '::', '#' or '.', but remember it might
+ # be a method name qualifier
+ separator = tokens.shift if tokens[0] =~ /^(\.|::|#)/
+
+ # Skip leading '::', but remember we potentially have an inst
+
+ # leading stuff must be class names
+
+ while tokens[0] =~ /^[A-Z]/
+ @class_names << tokens.shift
+ unless tokens.empty?
+ separator = tokens.shift
+ break unless separator == "::"
+ end
+ end
+
+ # Now must have a single token, the method name, or an empty
+ # array
+ unless tokens.empty?
+ @method_name = tokens.shift
+ # We may now have a trailing !, ?, or = to roll into
+ # the method name
+ if !tokens.empty? && tokens[0] =~ /^[!?=]$/
+ @method_name << tokens.shift
+ end
+
+ if @method_name =~ /::|\.|#/ or !tokens.empty?
+ raise RiError.new("Bad argument: #{arg}")
+ end
+ if separator && separator != '.'
+ @is_class_method = separator == "::"
+ end
+ end
+ end
+
+ # Return the full class name (with '::' between the components)
+ # or "" if there's no class name
+
+ def full_class_name
+ @class_names.join("::")
+ end
+end
diff --git a/lib/rdoc/ri/ri_writer.rb b/lib/rdoc/ri/ri_writer.rb
new file mode 100644
index 0000000000..78c68e8409
--- /dev/null
+++ b/lib/rdoc/ri/ri_writer.rb
@@ -0,0 +1,62 @@
+require 'fileutils'
+
+module RI
+ class RiWriter
+
+ def RiWriter.class_desc_path(dir, class_desc)
+ File.join(dir, "cdesc-" + class_desc.name + ".yaml")
+ end
+
+
+ # Convert a name from internal form (containing punctuation)
+ # to an external form (where punctuation is replaced
+ # by %xx)
+
+ def RiWriter.internal_to_external(name)
+ name.gsub(/\W/) { sprintf("%%%02x", $&[0]) }
+ end
+
+ # And the reverse operation
+ def RiWriter.external_to_internal(name)
+ name.gsub(/%([0-9a-f]{2,2})/) { $1.to_i(16).chr }
+ end
+
+ def initialize(base_dir)
+ @base_dir = base_dir
+ end
+
+ def remove_class(class_desc)
+ FileUtils.rm_rf(path_to_dir(class_desc.full_name))
+ end
+
+ def add_class(class_desc)
+ dir = path_to_dir(class_desc.full_name)
+ FileUtils.mkdir_p(dir)
+ class_file_name = RiWriter.class_desc_path(dir, class_desc)
+ File.open(class_file_name, "w") do |f|
+ f.write(class_desc.serialize)
+ end
+ end
+
+ def add_method(class_desc, method_desc)
+ dir = path_to_dir(class_desc.full_name)
+ file_name = RiWriter.internal_to_external(method_desc.name)
+ meth_file_name = File.join(dir, file_name)
+ if method_desc.is_singleton
+ meth_file_name += "-c.yaml"
+ else
+ meth_file_name += "-i.yaml"
+ end
+
+ File.open(meth_file_name, "w") do |f|
+ f.write(method_desc.serialize)
+ end
+ end
+
+ private
+
+ def path_to_dir(class_name)
+ File.join(@base_dir, *class_name.split('::'))
+ end
+ end
+end
diff --git a/lib/rdoc/template.rb b/lib/rdoc/template.rb
new file mode 100644
index 0000000000..469e10fb4b
--- /dev/null
+++ b/lib/rdoc/template.rb
@@ -0,0 +1,234 @@
+# Cheap-n-cheerful HTML page template system. You create a
+# template containing:
+#
+# * variable names between percent signs (<tt>%fred%</tt>)
+# * blocks of repeating stuff:
+#
+# START:key
+# ... stuff
+# END:key
+#
+# You feed the code a hash. For simple variables, the values
+# are resolved directly from the hash. For blocks, the hash entry
+# corresponding to +key+ will be an array of hashes. The block will
+# be generated once for each entry. Blocks can be nested arbitrarily
+# deeply.
+#
+# The template may also contain
+#
+# IF:key
+# ... stuff
+# ENDIF:key
+#
+# _stuff_ will only be included in the output if the corresponding
+# key is set in the value hash.
+#
+# Usage: Given a set of templates <tt>T1, T2,</tt> etc
+#
+# values = { "name" => "Dave", state => "TX" }
+#
+# t = TemplatePage.new(T1, T2, T3)
+# File.open(name, "w") {|f| t.write_html_on(f, values)}
+# or
+# res = ''
+# t.write_html_on(res, values)
+#
+#
+
+class TemplatePage
+
+ ##########
+ # A context holds a stack of key/value pairs (like a symbol
+ # table). When asked to resolve a key, it first searches the top of
+ # the stack, then the next level, and so on until it finds a match
+ # (or runs out of entries)
+
+ class Context
+ def initialize
+ @stack = []
+ end
+
+ def push(hash)
+ @stack.push(hash)
+ end
+
+ def pop
+ @stack.pop
+ end
+
+ # Find a scalar value, throwing an exception if not found. This
+ # method is used when substituting the %xxx% constructs
+
+ def find_scalar(key)
+ @stack.reverse_each do |level|
+ if val = level[key]
+ return val unless val.kind_of? Array
+ end
+ end
+ raise "Template error: can't find variable '#{key}'"
+ end
+
+ # Lookup any key in the stack of hashes
+
+ def lookup(key)
+ @stack.reverse_each do |level|
+ val = level[key]
+ return val if val
+ end
+ nil
+ end
+ end
+
+ #########
+ # Simple class to read lines out of a string
+
+ class LineReader
+ # we're initialized with an array of lines
+ def initialize(lines)
+ @lines = lines
+ end
+
+ # read the next line
+ def read
+ @lines.shift
+ end
+
+ # Return a list of lines up to the line that matches
+ # a pattern. That last line is discarded.
+ def read_up_to(pattern)
+ res = []
+ while line = read
+ if pattern.match(line)
+ return LineReader.new(res)
+ else
+ res << line
+ end
+ end
+ raise "Missing end tag in template: #{pattern.source}"
+ end
+
+ # Return a copy of ourselves that can be modified without
+ # affecting us
+ def dup
+ LineReader.new(@lines.dup)
+ end
+ end
+
+
+
+ # +templates+ is an array of strings containing the templates.
+ # We start at the first, and substitute in subsequent ones
+ # where the string <tt>!INCLUDE!</tt> occurs. For example,
+ # we could have the overall page template containing
+ #
+ # <html><body>
+ # <h1>Master</h1>
+ # !INCLUDE!
+ # </bost></html>
+ #
+ # and substitute subpages in to it by passing [master, sub_page].
+ # This gives us a cheap way of framing pages
+
+ def initialize(*templates)
+ result = "!INCLUDE!"
+ templates.each do |content|
+ result.sub!(/!INCLUDE!/, content)
+ end
+ @lines = LineReader.new(result.split($/))
+ end
+
+ # Render the templates into HTML, storing the result on +op+
+ # using the method <tt><<</tt>. The <tt>value_hash</tt> contains
+ # key/value pairs used to drive the substitution (as described above)
+
+ def write_html_on(op, value_hash)
+ @context = Context.new
+ op << substitute_into(@lines, value_hash).tr("\000", '\\')
+ end
+
+
+ # Substitute a set of key/value pairs into the given template.
+ # Keys with scalar values have them substituted directly into
+ # the page. Those with array values invoke <tt>substitute_array</tt>
+ # (below), which examples a block of the template once for each
+ # row in the array.
+ #
+ # This routine also copes with the <tt>IF:</tt>_key_ directive,
+ # removing chunks of the template if the corresponding key
+ # does not appear in the hash, and the START: directive, which
+ # loops its contents for each value in an array
+
+ def substitute_into(lines, values)
+ @context.push(values)
+ skip_to = nil
+ result = []
+
+ while line = lines.read
+
+ case line
+
+ when /^IF:(\w+)/
+ lines.read_up_to(/^ENDIF:#$1/) unless @context.lookup($1)
+
+ when /^IFNOT:(\w+)/
+ lines.read_up_to(/^ENDIF:#$1/) if @context.lookup($1)
+
+ when /^ENDIF:/
+ ;
+
+ when /^START:(\w+)/
+ tag = $1
+ body = lines.read_up_to(/^END:#{tag}/)
+ inner_values = @context.lookup(tag)
+ raise "unknown tag: #{tag}" unless inner_values
+ raise "not array: #{tag}" unless inner_values.kind_of?(Array)
+ inner_values.each do |vals|
+ result << substitute_into(body.dup, vals)
+ end
+ else
+ result << expand_line(line.dup)
+ end
+ end
+
+ @context.pop
+
+ result.join("\n")
+ end
+
+ # Given an individual line, we look for %xxx% constructs and
+ # HREF:ref:name: constructs, substituting for each.
+
+ def expand_line(line)
+ # Generate a cross reference if a reference is given,
+ # otherwise just fill in the name part
+
+ line.gsub!(/HREF:(\w+?):(\w+?):/) {
+ ref = @context.lookup($1)
+ name = @context.find_scalar($2)
+
+ if ref and !ref.kind_of?(Array)
+ "<a href=\"#{ref}\">#{name}</a>"
+ else
+ name
+ end
+ }
+
+ # Substitute in values for %xxx% constructs. This is made complex
+ # because the replacement string may contain characters that are
+ # meaningful to the regexp (like \1)
+
+ line = line.gsub(/%([a-zA-Z]\w*)%/) {
+ val = @context.find_scalar($1)
+ val.tr('\\', "\000")
+ }
+
+
+ line
+ rescue Exception => e
+ $stderr.puts "Error in template: #{e}"
+ $stderr.puts "Original line: #{line}"
+ exit
+ end
+
+end
+
diff --git a/lib/rdoc/tokenstream.rb b/lib/rdoc/tokenstream.rb
new file mode 100644
index 0000000000..0a0720d8a9
--- /dev/null
+++ b/lib/rdoc/tokenstream.rb
@@ -0,0 +1,25 @@
+# A TokenStream is a list of tokens, gathered during the parse
+# of some entity (say a method). Entities populate these streams
+# by being registered with the lexer. Any class can collect tokens
+# by including TokenStream. From the outside, you use such an object
+# by calling the start_collecting_tokens method, followed by calls
+# to add_token and pop_token
+
+module TokenStream
+ def token_stream
+ @token_stream
+ end
+
+ def start_collecting_tokens
+ @token_stream = []
+ end
+ def add_token(tk)
+ @token_stream << tk
+ end
+ def add_tokens(tks)
+ tks.each {|tk| add_token(tk)}
+ end
+ def pop_token
+ @token_stream.pop
+ end
+end
diff --git a/lib/rdoc/usage.rb b/lib/rdoc/usage.rb
new file mode 100644
index 0000000000..da6593d89e
--- /dev/null
+++ b/lib/rdoc/usage.rb
@@ -0,0 +1,203 @@
+# = Synopsis
+#
+# This library allows command-line tools to encapsulate their usage
+# as a comment at the top of the main file. Calling <tt>RDoc::usage</tt>
+# then displays some or all of that comment, and optionally exits
+# the program with an exit status. We always look for the comment
+# in the main program file, so it is safe to call this method
+# from anywhere in the executing program.
+#
+# = Usage
+#
+# RDoc::usage( [ exit_status ], [ section, ...])
+# RDoc::usage_no_exit( [ section, ...])
+#
+# where:
+#
+# exit_status::
+# the integer exit code (default zero). RDoc::usage will exit
+# the calling program with this status.
+#
+# section::
+# an optional list of section names. If specified, only the
+# sections with the given names as headings will be output.
+# For example, this section is named 'Usage', and the next
+# section is named 'Examples'. The section names are case
+# insensitive.
+#
+# = Examples
+#
+# # Comment block describing usage
+# # with (optional) section headings
+# # . . .
+#
+# require 'rdoc/usage'
+#
+# # Display all usage and exit with a status of 0
+#
+# RDoc::usage
+#
+# # Display all usage and exit with a status of 99
+#
+# RDoc::usage(99)
+#
+# # Display usage in the 'Summary' section only, then
+# # exit with a status of 99
+#
+# RDoc::usage(99, 'Summary')
+#
+# # Display information in the Author and Copyright
+# # sections, then exit 0.
+#
+# RDoc::usage('Author', 'Copyright')
+#
+# # Display information in the Author and Copyright
+# # sections, but don't exit
+#
+# RDoc::usage_no_exit('Author', 'Copyright')
+#
+# = Author
+#
+# Dave Thomas, The Pragmatic Programmers, LLC
+#
+# = Copyright
+#
+# Copyright (c) 2004 Dave Thomas.
+# Licensed under the same terms as Ruby
+#
+
+require 'rdoc/markup/simple_markup'
+require 'rdoc/markup/simple_markup/to_flow'
+require 'rdoc/ri/ri_formatter'
+require 'rdoc/ri/ri_options'
+
+module RDoc
+
+ # Display usage information from the comment at the top of
+ # the file. String arguments identify specific sections of the
+ # comment to display. An optional integer first argument
+ # specifies the exit status (defaults to 0)
+
+ def RDoc.usage(*args)
+ exit_code = 0
+
+ if args.size > 0
+ status = args[0]
+ if status.respond_to?(:to_int)
+ exit_code = status.to_int
+ args.shift
+ end
+ end
+
+ # display the usage and exit with the given code
+ usage_no_exit(*args)
+ exit(exit_code)
+ end
+
+ # Display usage
+ def RDoc.usage_no_exit(*args)
+ main_program_file, = caller[-1].split(/:/, 2)
+ comment = File.open(main_program_file) do |file|
+ find_comment(file)
+ end
+
+ comment = comment.gsub(/^\s*#/, '')
+
+ markup = SM::SimpleMarkup.new
+ flow_convertor = SM::ToFlow.new
+
+ flow = markup.convert(comment, flow_convertor)
+
+ format = "plain"
+
+ unless args.empty?
+ flow = extract_sections(flow, args)
+ end
+
+ options = RI::Options.instance
+ if args = ENV["RI"]
+ options.parse(args.split)
+ end
+ formatter = options.formatter.new(options, "")
+ formatter.display_flow(flow)
+ end
+
+ ######################################################################
+
+ private
+
+ # Find the first comment in the file (that isn't a shebang line)
+ # If the file doesn't start with a comment, report the fact
+ # and return nil
+
+ def RDoc.find_comment(file)
+ # skip leading blank lines and shebangs
+ while line = file.gets
+ break unless line =~ /^(#!|\s*$)/
+ end
+
+ comment = []
+
+ while line && line =~ /^\s*#/
+ comment << line
+ line = file.gets
+ end
+
+ return no_comment if comment.empty?
+
+ comment.join
+ end
+
+
+ #####
+ # Given an array of flow items and an array of section names, extract those
+ # sections from the flow which have headings corresponding to
+ # a section name in the list. Return them in the order
+ # of names in the +sections+ array.
+
+ def RDoc.extract_sections(flow, sections)
+ result = []
+ sections.each do |name|
+ name = name.downcase
+ copy_upto_level = nil
+
+ flow.each do |item|
+ case item
+ when SM::Flow::H
+ if copy_upto_level && item.level >= copy_upto_level
+ copy_upto_level = nil
+ else
+ if item.text[0].downcase == name
+ result << item
+ copy_upto_level = item.level
+ end
+ end
+ else
+ if copy_upto_level
+ result << item
+ end
+ end
+ end
+ end
+ if result.empty?
+ puts "Note to developer: requested section(s) [#{sections.join(', ')}] " +
+ "not found"
+ result = flow
+ end
+ result
+ end
+
+ #####
+ # Report the fact that no doc comment count be found
+ def RDoc.no_comment
+ $stderr.puts "No usage information available for this program"
+ nil
+ end
+end
+
+
+if $0 == __FILE__
+
+ RDoc::usage(*ARGV)
+
+end
diff --git a/lib/resolv-replace.rb b/lib/resolv-replace.rb
new file mode 100644
index 0000000000..5d15b4577c
--- /dev/null
+++ b/lib/resolv-replace.rb
@@ -0,0 +1,62 @@
+require 'socket'
+require 'resolv'
+
+class << IPSocket
+ alias original_resolv_getaddress getaddress
+ def getaddress(host)
+ begin
+ return Resolv.getaddress(host).to_s
+ rescue Resolv::ResolvError
+ raise SocketError, "Hostname not known: #{host}"
+ end
+ end
+end
+
+class TCPSocket
+ alias original_resolv_initialize initialize
+ def initialize(host, serv, *rest)
+ rest[0] = IPSocket.getaddress(rest[0]) unless rest.empty?
+ original_resolv_initialize(IPSocket.getaddress(host), serv, *rest)
+ end
+end
+
+class UDPSocket
+ alias original_resolv_bind bind
+ def bind(host, port)
+ original_resolv_bind(IPSocket.getaddress(host), port)
+ end
+
+ alias original_resolv_connect connect
+ def connect(host, port)
+ original_resolv_connect(IPSocket.getaddress(host), port)
+ end
+
+ alias original_resolv_send send
+ def send(mesg, flags, *rest)
+ if rest.length == 2
+ host, port = rest
+ begin
+ addrs = Resolv.getaddresses(host)
+ rescue Resolv::ResolvError
+ raise SocketError, "Hostname not known: #{host}"
+ end
+ err = nil
+ addrs[0...-1].each {|addr|
+ begin
+ return original_resolv_send(mesg, flags, addr, port)
+ rescue SystemCallError
+ end
+ }
+ original_resolv_send(mesg, flags, addrs[-1], port)
+ else
+ original_resolv_send(mesg, flags, *rest)
+ end
+ end
+end
+
+class SOCKSSocket
+ alias original_resolv_initialize initialize
+ def initialize(host, serv)
+ original_resolv_initialize(IPSocket.getaddress(host), port)
+ end
+end if defined? SOCKSSocket
diff --git a/lib/resolv.rb b/lib/resolv.rb
new file mode 100644
index 0000000000..069cf5c8f1
--- /dev/null
+++ b/lib/resolv.rb
@@ -0,0 +1,1767 @@
+=begin
+= resolv library
+resolv.rb is a resolver library written in Ruby.
+Since it is written in Ruby, it is thread-aware.
+I.e. it can resolv many hostnames concurrently.
+
+It is possible to lookup various resources of DNS using DNS module directly.
+
+== example
+ Resolv.getaddress("www.ruby-lang.org")
+ Resolv.getname("210.251.121.214")
+
+ Resolv::DNS.open {|dns|
+ dns.getresources("www.ruby-lang.org", Resolv::DNS::Resource::IN::A).collect {|r| r.address}
+ dns.getresources("ruby-lang.org", Resolv::DNS::Resource::IN::MX).collect {|r| [r.exchange.to_s, r.preference]}
+ }
+
+== Resolv class
+
+=== class methods
+--- Resolv.getaddress(name)
+--- Resolv.getaddresses(name)
+--- Resolv.each_address(name) {|address| ...}
+ They lookups IP addresses of ((|name|)) which represents a hostname
+ as a string by default resolver.
+
+ getaddress returns first entry of lookupped addresses.
+ getaddresses returns lookupped addresses as an array.
+ each_address iterates over lookupped addresses.
+
+--- Resolv.getname(address)
+--- Resolv.getnames(address)
+--- Resolv.each_name(address) {|name| ...}
+ lookups hostnames of ((|address|)) which represents IP address as a string.
+
+ getname returns first entry of lookupped names.
+ getnames returns lookupped names as an array.
+ each_names iterates over lookupped names.
+
+== Resolv::Hosts class
+hostname resolver using /etc/hosts format.
+
+=== class methods
+--- Resolv::Hosts.new(hosts='/etc/hosts')
+
+=== methods
+--- Resolv::Hosts#getaddress(name)
+--- Resolv::Hosts#getaddresses(name)
+--- Resolv::Hosts#each_address(name) {|address| ...}
+ address lookup methods.
+
+--- Resolv::Hosts#getname(address)
+--- Resolv::Hosts#getnames(address)
+--- Resolv::Hosts#each_name(address) {|name| ...}
+ hostnames lookup methods.
+
+== Resolv::DNS class
+DNS stub resolver.
+
+=== class methods
+--- Resolv::DNS.new(config_info=nil)
+
+ ((|config_info|)) should be nil, a string or a hash.
+ If nil is given, /etc/resolv.conf and platform specific information is used.
+ If a string is given, it should be a filename which format is same as /etc/resolv.conf.
+ If a hash is given, it may contains information for nameserver, search and ndots as follows.
+
+ Resolv::DNS.new({:nameserver=>["210.251.121.21"], :search=>["ruby-lang.org"], :ndots=>1})
+
+--- Resolv::DNS.open(config_info=nil)
+--- Resolv::DNS.open(config_info=nil) {|dns| ...}
+
+=== methods
+--- Resolv::DNS#close
+
+--- Resolv::DNS#getaddress(name)
+--- Resolv::DNS#getaddresses(name)
+--- Resolv::DNS#each_address(name) {|address| ...}
+ address lookup methods.
+
+ ((|name|)) must be a instance of Resolv::DNS::Name or String. Lookupped
+ address is represented as an instance of Resolv::IPv4 or Resolv::IPv6.
+
+--- Resolv::DNS#getname(address)
+--- Resolv::DNS#getnames(address)
+--- Resolv::DNS#each_name(address) {|name| ...}
+ hostnames lookup methods.
+
+ ((|address|)) must be a instance of Resolv::IPv4, Resolv::IPv6 or String.
+ Lookupped name is represented as an instance of Resolv::DNS::Name.
+
+--- Resolv::DNS#getresource(name, typeclass)
+--- Resolv::DNS#getresources(name, typeclass)
+--- Resolv::DNS#each_resource(name, typeclass) {|resource| ...}
+ They lookup DNS resources of ((|name|)).
+ ((|name|)) must be a instance of Resolv::Name or String.
+
+ ((|typeclass|)) should be one of follows:
+ * Resolv::DNS::Resource::IN::ANY
+ * Resolv::DNS::Resource::IN::NS
+ * Resolv::DNS::Resource::IN::CNAME
+ * Resolv::DNS::Resource::IN::SOA
+ * Resolv::DNS::Resource::IN::HINFO
+ * Resolv::DNS::Resource::IN::MINFO
+ * Resolv::DNS::Resource::IN::MX
+ * Resolv::DNS::Resource::IN::TXT
+ * Resolv::DNS::Resource::IN::ANY
+ * Resolv::DNS::Resource::IN::A
+ * Resolv::DNS::Resource::IN::WKS
+ * Resolv::DNS::Resource::IN::PTR
+ * Resolv::DNS::Resource::IN::AAAA
+
+ Lookupped resource is represented as an instance of (a subclass of)
+ Resolv::DNS::Resource.
+ (Resolv::DNS::Resource::IN::A, etc.)
+
+== Resolv::DNS::Resource::IN::NS class
+--- name
+== Resolv::DNS::Resource::IN::CNAME class
+--- name
+== Resolv::DNS::Resource::IN::SOA class
+--- mname
+--- rname
+--- serial
+--- refresh
+--- retry
+--- expire
+--- minimum
+== Resolv::DNS::Resource::IN::HINFO class
+--- cpu
+--- os
+== Resolv::DNS::Resource::IN::MINFO class
+--- rmailbx
+--- emailbx
+== Resolv::DNS::Resource::IN::MX class
+--- preference
+--- exchange
+== Resolv::DNS::Resource::IN::TXT class
+--- data
+== Resolv::DNS::Resource::IN::A class
+--- address
+== Resolv::DNS::Resource::IN::WKS class
+--- address
+--- protocol
+--- bitmap
+== Resolv::DNS::Resource::IN::PTR class
+--- name
+== Resolv::DNS::Resource::IN::AAAA class
+--- address
+
+== Resolv::DNS::Name class
+
+=== class methods
+--- Resolv::DNS::Name.create(name)
+
+=== methods
+--- Resolv::DNS::Name#to_s
+
+== Resolv::DNS::Resource class
+
+== Resolv::IPv4 class
+=== class methods
+--- Resolv::IPv4.create(address)
+
+=== methods
+--- Resolv::IPv4#to_s
+--- Resolv::IPv4#to_name
+
+=== constants
+--- Resolv::IPv4::Regex
+ regular expression for IPv4 address.
+
+== Resolv::IPv6 class
+=== class methods
+--- Resolv::IPv6.create(address)
+
+=== methods
+--- Resolv::IPv6#to_s
+--- Resolv::IPv6#to_name
+
+=== constants
+--- Resolv::IPv6::Regex
+ regular expression for IPv6 address.
+
+== Bugs
+* NIS is not supported.
+* /etc/nsswitch.conf is not supported.
+* IPv6 is not supported.
+
+=end
+
+require 'socket'
+require 'fcntl'
+require 'timeout'
+require 'thread'
+
+class Resolv
+ def self.getaddress(name)
+ DefaultResolver.getaddress(name)
+ end
+
+ def self.getaddresses(name)
+ DefaultResolver.getaddresses(name)
+ end
+
+ def self.each_address(name, &block)
+ DefaultResolver.each_address(name, &block)
+ end
+
+ def self.getname(address)
+ DefaultResolver.getname(address)
+ end
+
+ def self.getnames(address)
+ DefaultResolver.getnames(address)
+ end
+
+ def self.each_name(address, &proc)
+ DefaultResolver.each_name(address, &proc)
+ end
+
+ def initialize(resolvers=[Hosts.new, DNS.new])
+ @resolvers = resolvers
+ end
+
+ def getaddress(name)
+ each_address(name) {|address| return address}
+ raise ResolvError.new("no address for #{name}")
+ end
+
+ def getaddresses(name)
+ ret = []
+ each_address(name) {|address| ret << address}
+ return ret
+ end
+
+ def each_address(name)
+ if AddressRegex =~ name
+ yield name
+ return
+ end
+ yielded = false
+ @resolvers.each {|r|
+ r.each_address(name) {|address|
+ yield address.to_s
+ yielded = true
+ }
+ return if yielded
+ }
+ end
+
+ def getname(address)
+ each_name(address) {|name| return name}
+ raise ResolvError.new("no name for #{address}")
+ end
+
+ def getnames(address)
+ ret = []
+ each_name(address) {|name| ret << name}
+ return ret
+ end
+
+ def each_name(address)
+ yielded = false
+ @resolvers.each {|r|
+ r.each_name(address) {|name|
+ yield name.to_s
+ yielded = true
+ }
+ return if yielded
+ }
+ end
+
+ class ResolvError < StandardError
+ end
+
+ class ResolvTimeout < TimeoutError
+ end
+
+ class Hosts
+ if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
+ require 'win32/resolv'
+ DefaultFileName = Win32::Resolv.get_hosts_path
+ else
+ DefaultFileName = '/etc/hosts'
+ end
+
+ def initialize(filename = DefaultFileName)
+ @filename = filename
+ @mutex = Mutex.new
+ @initialized = nil
+ end
+
+ def lazy_initialize
+ @mutex.synchronize {
+ unless @initialized
+ @name2addr = {}
+ @addr2name = {}
+ open(@filename) {|f|
+ f.each {|line|
+ line.sub!(/#.*/, '')
+ addr, hostname, *aliases = line.split(/\s+/)
+ next unless addr
+ addr.untaint
+ hostname.untaint
+ @addr2name[addr] = [] unless @addr2name.include? addr
+ @addr2name[addr] << hostname
+ @addr2name[addr] += aliases
+ @name2addr[hostname] = [] unless @name2addr.include? hostname
+ @name2addr[hostname] << addr
+ aliases.each {|n|
+ n.untaint
+ @name2addr[n] = [] unless @name2addr.include? n
+ @name2addr[n] << addr
+ }
+ }
+ }
+ @name2addr.each {|name, arr| arr.reverse!}
+ @initialized = true
+ end
+ }
+ end
+
+ def getaddress(name)
+ each_address(name) {|address| return address}
+ raise ResolvError.new("#{@filename} has no name: #{name}")
+ end
+
+ def getaddresses(name)
+ ret = []
+ each_address(name) {|address| ret << address}
+ return ret
+ end
+
+ def each_address(name, &proc)
+ lazy_initialize
+ if @name2addr.include?(name)
+ @name2addr[name].each(&proc)
+ end
+ end
+
+ def getname(address)
+ each_name(address) {|name| return name}
+ raise ResolvError.new("#{@filename} has no address: #{address}")
+ end
+
+ def getnames(address)
+ ret = []
+ each_name(address) {|name| ret << name}
+ return ret
+ end
+
+ def each_name(address, &proc)
+ lazy_initialize
+ if @addr2name.include?(address)
+ @addr2name[address].each(&proc)
+ end
+ end
+ end
+
+ class DNS
+ # STD0013 (RFC 1035, etc.)
+ # ftp://ftp.isi.edu/in-notes/iana/assignments/dns-parameters
+
+ Port = 53
+ UDPSize = 512
+
+ DNSThreadGroup = ThreadGroup.new
+
+ def self.open(*args)
+ dns = new(*args)
+ return dns unless block_given?
+ begin
+ yield dns
+ ensure
+ dns.close
+ end
+ end
+
+ def initialize(config_info=nil)
+ @mutex = Mutex.new
+ @config = Config.new(config_info)
+ @initialized = nil
+ end
+
+ def lazy_initialize
+ @mutex.synchronize {
+ unless @initialized
+ @config.lazy_initialize
+
+ if nameserver = @config.single?
+ @requester = Requester::ConnectedUDP.new(nameserver)
+ else
+ @requester = Requester::UnconnectedUDP.new
+ end
+
+ @initialized = true
+ end
+ }
+ end
+
+ def close
+ @mutex.synchronize {
+ if @initialized
+ @requester.close if @requester
+ @requester = nil
+ @initialized = false
+ end
+ }
+ end
+
+ def getaddress(name)
+ each_address(name) {|address| return address}
+ raise ResolvError.new("DNS result has no information for #{name}")
+ end
+
+ def getaddresses(name)
+ ret = []
+ each_address(name) {|address| ret << address}
+ return ret
+ end
+
+ def each_address(name)
+ each_resource(name, Resource::IN::A) {|resource| yield resource.address}
+ end
+
+ def getname(address)
+ each_name(address) {|name| return name}
+ raise ResolvError.new("DNS result has no information for #{address}")
+ end
+
+ def getnames(address)
+ ret = []
+ each_name(address) {|name| ret << name}
+ return ret
+ end
+
+ def each_name(address)
+ case address
+ when Name
+ ptr = address
+ when IPv4::Regex
+ ptr = IPv4.create(address).to_name
+ when IPv6::Regex
+ ptr = IPv6.create(address).to_name
+ else
+ raise ResolvError.new("cannot interpret as address: #{address}")
+ end
+ each_resource(ptr, Resource::IN::PTR) {|resource| yield resource.name}
+ end
+
+ def getresource(name, typeclass)
+ each_resource(name, typeclass) {|resource| return resource}
+ raise ResolvError.new("DNS result has no information for #{name}")
+ end
+
+ def getresources(name, typeclass)
+ ret = []
+ each_resource(name, typeclass) {|resource| ret << resource}
+ return ret
+ end
+
+ def each_resource(name, typeclass, &proc)
+ lazy_initialize
+ q = Queue.new
+ senders = {}
+ begin
+ @config.resolv(name) {|candidate, tout, nameserver|
+ msg = Message.new
+ msg.rd = 1
+ msg.add_question(candidate, typeclass)
+ unless sender = senders[[candidate, nameserver]]
+ sender = senders[[candidate, nameserver]] =
+ @requester.sender(msg, candidate, q, nameserver)
+ end
+ sender.send
+ reply = reply_name = nil
+ timeout(tout, ResolvTimeout) { reply, reply_name = q.pop }
+ case reply.rcode
+ when RCode::NoError
+ extract_resources(reply, reply_name, typeclass, &proc)
+ return
+ when RCode::NXDomain
+ raise Config::NXDomain.new(reply_name.to_s)
+ else
+ raise Config::OtherResolvError.new(reply_name.to_s)
+ end
+ }
+ ensure
+ @requester.delete(q)
+ end
+ end
+
+ def extract_resources(msg, name, typeclass)
+ if typeclass < Resource::ANY
+ n0 = Name.create(name)
+ msg.each_answer {|n, ttl, data|
+ yield data if n0 == n
+ }
+ end
+ yielded = false
+ n0 = Name.create(name)
+ msg.each_answer {|n, ttl, data|
+ if n0 == n
+ case data
+ when typeclass
+ yield data
+ yielded = true
+ when Resource::CNAME
+ n0 = data.name
+ end
+ end
+ }
+ return if yielded
+ msg.each_answer {|n, ttl, data|
+ if n0 == n
+ case data
+ when typeclass
+ yield data
+ end
+ end
+ }
+ end
+
+ class Requester
+ def initialize
+ @senders = {}
+ end
+
+ def close
+ thread, sock, @thread, @sock = @thread, @sock
+ begin
+ if thread
+ thread.kill
+ thread.join
+ end
+ ensure
+ sock.close if sock
+ end
+ end
+
+ def delete(arg)
+ case arg
+ when Sender
+ @senders.delete_if {|k, s| s == arg }
+ when Queue
+ @senders.delete_if {|k, s| s.queue == arg }
+ else
+ raise ArgumentError.new("neither Sender or Queue: #{arg}")
+ end
+ end
+
+ class Sender
+ def initialize(msg, data, sock, queue)
+ @msg = msg
+ @data = data
+ @sock = sock
+ @queue = queue
+ end
+ attr_reader :queue
+
+ def recv(msg)
+ @queue.push([msg, @data])
+ end
+ end
+
+ class UnconnectedUDP < Requester
+ def initialize
+ super()
+ @sock = UDPSocket.new
+ @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
+ @id = {}
+ @id.default = -1
+ @thread = Thread.new {
+ DNSThreadGroup.add Thread.current
+ loop {
+ reply, from = @sock.recvfrom(UDPSize)
+ msg = begin
+ Message.decode(reply)
+ rescue DecodeError
+ STDERR.print("DNS message decoding error: #{reply.inspect}\n")
+ next
+ end
+ if s = @senders[[[from[3],from[1]],msg.id]]
+ s.recv msg
+ else
+ #STDERR.print("non-handled DNS message: #{msg.inspect} from #{from.inspect}\n")
+ end
+ }
+ }
+ end
+
+ def sender(msg, data, queue, host, port=Port)
+ service = [host, port]
+ id = Thread.exclusive {
+ @id[service] = (@id[service] + 1) & 0xffff
+ }
+ request = msg.encode
+ request[0,2] = [id].pack('n')
+ return @senders[[service, id]] =
+ Sender.new(request, data, @sock, host, port, queue)
+ end
+
+ class Sender < Requester::Sender
+ def initialize(msg, data, sock, host, port, queue)
+ super(msg, data, sock, queue)
+ @host = host
+ @port = port
+ end
+
+ def send
+ @sock.send(@msg, 0, @host, @port)
+ end
+ end
+ end
+
+ class ConnectedUDP < Requester
+ def initialize(host, port=Port)
+ super()
+ @host = host
+ @port = port
+ @sock = UDPSocket.new
+ @sock.connect(host, port)
+ @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
+ @id = -1
+ @thread = Thread.new {
+ DNSThreadGroup.add Thread.current
+ loop {
+ reply = @sock.recv(UDPSize)
+ msg = begin
+ Message.decode(reply)
+ rescue DecodeError
+ STDERR.print("DNS message decoding error: #{reply.inspect}")
+ next
+ end
+ if s = @senders[msg.id]
+ s.recv msg
+ else
+ #STDERR.print("non-handled DNS message: #{msg.inspect}")
+ end
+ }
+ }
+ end
+
+ def sender(msg, data, queue, host=@host, port=@port)
+ unless host == @host && port == @port
+ raise RequestError.new("host/port don't match: #{host}:#{port}")
+ end
+ id = Thread.exclusive { @id = (@id + 1) & 0xffff }
+ request = msg.encode
+ request[0,2] = [id].pack('n')
+ return @senders[id] = Sender.new(request, data, @sock, queue)
+ end
+
+ class Sender < Requester::Sender
+ def send
+ @sock.send(@msg, 0)
+ end
+ end
+ end
+
+ class TCP < Requester
+ def initialize(host, port=Port)
+ super()
+ @host = host
+ @port = port
+ @sock = TCPSocket.new
+ @sock.connect(host, port)
+ @sock.fcntl(Fcntl::F_SETFD, 1) if defined? Fcntl::F_SETFD
+ @id = -1
+ @senders = {}
+ @thread = Thread.new {
+ DNSThreadGroup.add Thread.current
+ loop {
+ len = @sock.read(2).unpack('n')
+ reply = @sock.read(len)
+ msg = begin
+ Message.decode(reply)
+ rescue DecodeError
+ STDERR.print("DNS message decoding error: #{reply.inspect}")
+ next
+ end
+ if s = @senders[msg.id]
+ s.push msg
+ else
+ #STDERR.print("non-handled DNS message: #{msg.inspect}")
+ end
+ }
+ }
+ end
+
+ def sender(msg, data, queue, host=@host, port=@port)
+ unless host == @host && port == @port
+ raise RequestError.new("host/port don't match: #{host}:#{port}")
+ end
+ id = Thread.exclusive { @id = (@id + 1) & 0xffff }
+ request = msg.encode
+ request[0,2] = [request.length, id].pack('nn')
+ return @senders[id] = Sender.new(request, data, @sock, queue)
+ end
+
+ class Sender < Requester::Sender
+ def send
+ @sock.print(@msg)
+ @sock.flush
+ end
+ end
+ end
+
+ class RequestError < StandardError
+ end
+ end
+
+ class Config
+ def initialize(config_info=nil)
+ @mutex = Mutex.new
+ @config_info = config_info
+ @initialized = nil
+ end
+
+ def Config.parse_resolv_conf(filename)
+ nameserver = []
+ search = nil
+ ndots = 1
+ open(filename) {|f|
+ f.each {|line|
+ line.sub!(/[#;].*/, '')
+ keyword, *args = line.split(/\s+/)
+ args.each { |arg|
+ arg.untaint
+ }
+ next unless keyword
+ case keyword
+ when 'nameserver'
+ nameserver += args
+ when 'domain'
+ search = [args[0]]
+ when 'search'
+ search = args
+ end
+ }
+ }
+ return { :nameserver => nameserver, :search => search, :ndots => ndots }
+ end
+
+ def Config.default_config_hash(filename="/etc/resolv.conf")
+ if File.exist? filename
+ config_hash = Config.parse_resolv_conf(filename)
+ else
+ if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
+ search, nameserver = Win32::Resolv.get_resolv_info
+ config_hash = {}
+ config_hash[:nameserver] = nameserver if nameserver
+ config_hash[:search] = [search].flatten if search
+ end
+ end
+ config_hash
+ end
+
+ def lazy_initialize
+ @mutex.synchronize {
+ unless @initialized
+ @nameserver = []
+ @search = nil
+ @ndots = 1
+ case @config_info
+ when nil
+ config_hash = Config.default_config_hash
+ when String
+ config_hash = Config.parse_resolv_conf(@config_info)
+ when Hash
+ config_hash = @config_info.dup
+ if String === config_hash[:nameserver]
+ config_hash[:nameserver] = [config_hash[:nameserver]]
+ end
+ if String === config_hash[:search]
+ config_hash[:search] = [config_hash[:search]]
+ end
+ else
+ raise ArgumentError.new("invalid resolv configuration: #{@config_info.inspect}")
+ end
+ @nameserver = config_hash[:nameserver] if config_hash.include? :nameserver
+ @search = config_hash[:search] if config_hash.include? :search
+ @ndots = config_hash[:ndots] if config_hash.include? :ndots
+
+ @nameserver = ['0.0.0.0'] if @nameserver.empty?
+ if @search
+ @search = @search.map {|arg| Label.split(arg) }
+ else
+ hostname = Socket.gethostname
+ if /\./ =~ hostname
+ @search = [Label.split($')]
+ else
+ @search = [[]]
+ end
+ end
+
+ if !@nameserver.kind_of?(Array) ||
+ !@nameserver.all? {|ns| String === ns }
+ raise ArgumentError.new("invalid nameserver config: #{@nameserver.inspect}")
+ end
+
+ if !@search.kind_of?(Array) ||
+ !@search.all? {|ls| ls.all? {|l| Label::Str === l } }
+ raise ArgumentError.new("invalid search config: #{@search.inspect}")
+ end
+
+ if !@ndots.kind_of?(Integer)
+ raise ArgumentError.new("invalid ndots config: #{@ndots.inspect}")
+ end
+
+ @initialized = true
+ end
+ }
+ end
+
+ def single?
+ lazy_initialize
+ if @nameserver.length == 1
+ return @nameserver[0]
+ else
+ return nil
+ end
+ end
+
+ def generate_candidates(name)
+ candidates = nil
+ name = Name.create(name)
+ if name.absolute?
+ candidates = [name]
+ else
+ if @ndots <= name.length - 1
+ candidates = [Name.new(name.to_a)]
+ else
+ candidates = []
+ end
+ candidates.concat(@search.map {|domain| Name.new(name.to_a + domain)})
+ end
+ return candidates
+ end
+
+ InitialTimeout = 5
+
+ def generate_timeouts
+ ts = [InitialTimeout]
+ ts << ts[-1] * 2 / @nameserver.length
+ ts << ts[-1] * 2
+ ts << ts[-1] * 2
+ return ts
+ end
+
+ def resolv(name)
+ candidates = generate_candidates(name)
+ timeouts = generate_timeouts
+ begin
+ candidates.each {|candidate|
+ begin
+ timeouts.each {|tout|
+ @nameserver.each {|nameserver|
+ begin
+ yield candidate, tout, nameserver
+ rescue ResolvTimeout
+ end
+ }
+ }
+ raise ResolvError.new("DNS resolv timeout: #{name}")
+ rescue NXDomain
+ end
+ }
+ rescue OtherResolvError
+ raise ResolvError.new("DNS error: #{$!.message}")
+ end
+ raise ResolvError.new("DNS resolv error: #{name}")
+ end
+
+ class NXDomain < ResolvError
+ end
+
+ class OtherResolvError < ResolvError
+ end
+ end
+
+ module OpCode
+ Query = 0
+ IQuery = 1
+ Status = 2
+ Notify = 4
+ Update = 5
+ end
+
+ module RCode
+ NoError = 0
+ FormErr = 1
+ ServFail = 2
+ NXDomain = 3
+ NotImp = 4
+ Refused = 5
+ YXDomain = 6
+ YXRRSet = 7
+ NXRRSet = 8
+ NotAuth = 9
+ NotZone = 10
+ BADVERS = 16
+ BADSIG = 16
+ BADKEY = 17
+ BADTIME = 18
+ BADMODE = 19
+ BADNAME = 20
+ BADALG = 21
+ end
+
+ class DecodeError < StandardError
+ end
+
+ class EncodeError < StandardError
+ end
+
+ module Label
+ def self.split(arg)
+ labels = []
+ arg.scan(/[^\.]+/) {labels << Str.new($&)}
+ return labels
+ end
+
+ class Str
+ def initialize(string)
+ @string = string
+ @downcase = string.downcase
+ end
+ attr_reader :string, :downcase
+
+ def to_s
+ return @string
+ end
+
+ def inspect
+ return "#<#{self.class} #{self.to_s}>"
+ end
+
+ def ==(other)
+ return @downcase == other.downcase
+ end
+
+ def eql?(other)
+ return self == other
+ end
+
+ def hash
+ return @downcase.hash
+ end
+ end
+ end
+
+ class Name
+ def self.create(arg)
+ case arg
+ when Name
+ return arg
+ when String
+ return Name.new(Label.split(arg), /\.\z/ =~ arg ? true : false)
+ else
+ raise ArgumentError.new("cannot interpret as DNS name: #{arg.inspect}")
+ end
+ end
+
+ def initialize(labels, absolute=true)
+ @labels = labels
+ @absolute = absolute
+ end
+
+ def absolute?
+ return @absolute
+ end
+
+ def ==(other)
+ return @labels == other.to_a && @absolute == other.absolute?
+ end
+ alias eql? ==
+
+ def hash
+ return @labels.hash ^ @absolute.hash
+ end
+
+ def to_a
+ return @labels
+ end
+
+ def length
+ return @labels.length
+ end
+
+ def [](i)
+ return @labels[i]
+ end
+
+ def to_s
+ return @labels.join('.')
+ end
+ end
+
+ class Message
+ @@identifier = -1
+
+ def initialize(id = (@@identifier += 1) & 0xffff)
+ @id = id
+ @qr = 0
+ @opcode = 0
+ @aa = 0
+ @tc = 0
+ @rd = 0 # recursion desired
+ @ra = 0 # recursion available
+ @rcode = 0
+ @question = []
+ @answer = []
+ @authority = []
+ @additional = []
+ end
+
+ attr_accessor :id, :qr, :opcode, :aa, :tc, :rd, :ra, :rcode
+ attr_reader :question, :answer, :authority, :additional
+
+ def ==(other)
+ return @id == other.id &&
+ @qr == other.qr &&
+ @opcode == other.opcode &&
+ @aa == other.aa &&
+ @tc == other.tc &&
+ @rd == other.rd &&
+ @ra == other.ra &&
+ @rcode == other.rcode &&
+ @question == other.question &&
+ @answer == other.answer &&
+ @authority == other.authority &&
+ @additional == other.additional
+ end
+
+ def add_question(name, typeclass)
+ @question << [Name.create(name), typeclass]
+ end
+
+ def each_question
+ @question.each {|name, typeclass|
+ yield name, typeclass
+ }
+ end
+
+ def add_answer(name, ttl, data)
+ @answer << [Name.create(name), ttl, data]
+ end
+
+ def each_answer
+ @answer.each {|name, ttl, data|
+ yield name, ttl, data
+ }
+ end
+
+ def add_authority(name, ttl, data)
+ @authority << [Name.create(name), ttl, data]
+ end
+
+ def each_authority
+ @authority.each {|name, ttl, data|
+ yield name, ttl, data
+ }
+ end
+
+ def add_additional(name, ttl, data)
+ @additional << [Name.create(name), ttl, data]
+ end
+
+ def each_additional
+ @additional.each {|name, ttl, data|
+ yield name, ttl, data
+ }
+ end
+
+ def each_resource
+ each_answer {|name, ttl, data| yield name, ttl, data}
+ each_authority {|name, ttl, data| yield name, ttl, data}
+ each_additional {|name, ttl, data| yield name, ttl, data}
+ end
+
+ def encode
+ return MessageEncoder.new {|msg|
+ msg.put_pack('nnnnnn',
+ @id,
+ (@qr & 1) << 15 |
+ (@opcode & 15) << 11 |
+ (@aa & 1) << 10 |
+ (@tc & 1) << 9 |
+ (@rd & 1) << 8 |
+ (@ra & 1) << 7 |
+ (@rcode & 15),
+ @question.length,
+ @answer.length,
+ @authority.length,
+ @additional.length)
+ @question.each {|q|
+ name, typeclass = q
+ msg.put_name(name)
+ msg.put_pack('nn', typeclass::TypeValue, typeclass::ClassValue)
+ }
+ [@answer, @authority, @additional].each {|rr|
+ rr.each {|r|
+ name, ttl, data = r
+ msg.put_name(name)
+ msg.put_pack('nnN', data.class::TypeValue, data.class::ClassValue, ttl)
+ msg.put_length16 {data.encode_rdata(msg)}
+ }
+ }
+ }.to_s
+ end
+
+ class MessageEncoder
+ def initialize
+ @data = ''
+ @names = {}
+ yield self
+ end
+
+ def to_s
+ return @data
+ end
+
+ def put_bytes(d)
+ @data << d
+ end
+
+ def put_pack(template, *d)
+ @data << d.pack(template)
+ end
+
+ def put_length16
+ length_index = @data.length
+ @data << "\0\0"
+ data_start = @data.length
+ yield
+ data_end = @data.length
+ @data[length_index, 2] = [data_end - data_start].pack("n")
+ end
+
+ def put_string(d)
+ self.put_pack("C", d.length)
+ @data << d
+ end
+
+ def put_name(d)
+ put_labels(d.to_a)
+ end
+
+ def put_labels(d)
+ d.each_index {|i|
+ domain = d[i..-1]
+ if idx = @names[domain]
+ self.put_pack("n", 0xc000 | idx)
+ return
+ else
+ @names[domain] = @data.length
+ self.put_label(d[i])
+ end
+ }
+ @data << "\0"
+ end
+
+ def put_label(d)
+ self.put_string(d.string)
+ end
+ end
+
+ def Message.decode(m)
+ o = Message.new(0)
+ MessageDecoder.new(m) {|msg|
+ id, flag, qdcount, ancount, nscount, arcount =
+ msg.get_unpack('nnnnnn')
+ o.id = id
+ o.qr = (flag >> 15) & 1
+ o.opcode = (flag >> 11) & 15
+ o.aa = (flag >> 10) & 1
+ o.tc = (flag >> 9) & 1
+ o.rd = (flag >> 8) & 1
+ o.ra = (flag >> 7) & 1
+ o.rcode = flag & 15
+ (1..qdcount).each {
+ name, typeclass = msg.get_question
+ o.add_question(name, typeclass)
+ }
+ (1..ancount).each {
+ name, ttl, data = msg.get_rr
+ o.add_answer(name, ttl, data)
+ }
+ (1..nscount).each {
+ name, ttl, data = msg.get_rr
+ o.add_authority(name, ttl, data)
+ }
+ (1..arcount).each {
+ name, ttl, data = msg.get_rr
+ o.add_additional(name, ttl, data)
+ }
+ }
+ return o
+ end
+
+ class MessageDecoder
+ def initialize(data)
+ @data = data
+ @index = 0
+ @limit = data.length
+ yield self
+ end
+
+ def get_length16
+ len, = self.get_unpack('n')
+ save_limit = @limit
+ @limit = @index + len
+ d = yield(len)
+ if @index < @limit
+ raise DecodeError.new("junk exists")
+ elsif @limit < @index
+ raise DecodeError.new("limit exceeded")
+ end
+ @limit = save_limit
+ return d
+ end
+
+ def get_bytes(len = @limit - @index)
+ d = @data[@index, len]
+ @index += len
+ return d
+ end
+
+ def get_unpack(template)
+ len = 0
+ template.each_byte {|byte|
+ case byte
+ when ?c, ?C
+ len += 1
+ when ?n
+ len += 2
+ when ?N
+ len += 4
+ else
+ raise StandardError.new("unsupported template: '#{byte.chr}' in '#{template}'")
+ end
+ }
+ raise DecodeError.new("limit exceeded") if @limit < @index + len
+ arr = @data.unpack("@#{@index}#{template}")
+ @index += len
+ return arr
+ end
+
+ def get_string
+ len = @data[@index]
+ raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len
+ d = @data[@index + 1, len]
+ @index += 1 + len
+ return d
+ end
+
+ def get_name
+ return Name.new(self.get_labels)
+ end
+
+ def get_labels(limit=nil)
+ limit = @index if !limit || @index < limit
+ d = []
+ while true
+ case @data[@index]
+ when 0
+ @index += 1
+ return d
+ when 192..255
+ idx = self.get_unpack('n')[0] & 0x3fff
+ if limit <= idx
+ raise DecodeError.new("non-backward name pointer")
+ end
+ save_index = @index
+ @index = idx
+ d += self.get_labels(limit)
+ @index = save_index
+ return d
+ else
+ d << self.get_label
+ end
+ end
+ return d
+ end
+
+ def get_label
+ return Label::Str.new(self.get_string)
+ end
+
+ def get_question
+ name = self.get_name
+ type, klass = self.get_unpack("nn")
+ return name, Resource.get_class(type, klass)
+ end
+
+ def get_rr
+ name = self.get_name
+ type, klass, ttl = self.get_unpack('nnN')
+ typeclass = Resource.get_class(type, klass)
+ return name, ttl, self.get_length16 {typeclass.decode_rdata(self)}
+ end
+ end
+ end
+
+ class Query
+ def encode_rdata(msg)
+ raise EncodeError.new("#{self.class} is query.")
+ end
+
+ def self.decode_rdata(msg)
+ raise DecodeError.new("#{self.class} is query.")
+ end
+ end
+
+ class Resource < Query
+ ClassHash = {}
+
+ def encode_rdata(msg)
+ raise NotImplementedError.new
+ end
+
+ def self.decode_rdata(msg)
+ raise NotImplementedError.new
+ end
+
+ def ==(other)
+ return self.class == other.class &&
+ self.instance_variables == other.instance_variables &&
+ self.instance_variables.collect {|name| self.instance_eval name} ==
+ other.instance_variables.collect {|name| other.instance_eval name}
+ end
+
+ def eql?(other)
+ return self == other
+ end
+
+ def hash
+ h = 0
+ self.instance_variables.each {|name|
+ h ^= self.instance_eval("#{name}.hash")
+ }
+ return h
+ end
+
+ def self.get_class(type_value, class_value)
+ return ClassHash[[type_value, class_value]] ||
+ Generic.create(type_value, class_value)
+ end
+
+ class Generic < Resource
+ def initialize(data)
+ @data = data
+ end
+ attr_reader :data
+
+ def encode_rdata(msg)
+ msg.put_bytes(data)
+ end
+
+ def self.decode_rdata(msg)
+ return self.new(msg.get_bytes)
+ end
+
+ def self.create(type_value, class_value)
+ c = Class.new(Generic)
+ c.const_set(:TypeValue, type_value)
+ c.const_set(:ClassValue, class_value)
+ Generic.const_set("Type#{type_value}_Class#{class_value}", c)
+ ClassHash[[type_value, class_value]] = c
+ return c
+ end
+ end
+
+ class DomainName < Resource
+ def initialize(name)
+ @name = name
+ end
+ attr_reader :name
+
+ def encode_rdata(msg)
+ msg.put_name(@name)
+ end
+
+ def self.decode_rdata(msg)
+ return self.new(msg.get_name)
+ end
+ end
+
+ # Standard (class generic) RRs
+ ClassValue = nil
+
+ class NS < DomainName
+ TypeValue = 2
+ end
+
+ class CNAME < DomainName
+ TypeValue = 5
+ end
+
+ class SOA < Resource
+ TypeValue = 6
+
+ def initialize(mname, rname, serial, refresh, retry_, expire, minimum)
+ @mname = mname
+ @rname = rname
+ @serial = serial
+ @refresh = refresh
+ @retry = retry_
+ @expire = expire
+ @minimum = minimum
+ end
+ attr_reader :mname, :rname, :serial, :refresh, :retry, :expire, :minimum
+
+ def encode_rdata(msg)
+ msg.put_name(@mname)
+ msg.put_name(@rname)
+ msg.put_pack('NNNNN', @serial, @refresh, @retry, @expire, @minimum)
+ end
+
+ def self.decode_rdata(msg)
+ mname = msg.get_name
+ rname = msg.get_name
+ serial, refresh, retry_, expire, minimum = msg.get_unpack('NNNNN')
+ return self.new(
+ mname, rname, serial, refresh, retry_, expire, minimum)
+ end
+ end
+
+ class PTR < DomainName
+ TypeValue = 12
+ end
+
+ class HINFO < Resource
+ TypeValue = 13
+
+ def initialize(cpu, os)
+ @cpu = cpu
+ @os = os
+ end
+ attr_reader :cpu, :os
+
+ def encode_rdata(msg)
+ msg.put_string(@cpu)
+ msg.put_string(@os)
+ end
+
+ def self.decode_rdata(msg)
+ cpu = msg.get_string
+ os = msg.get_string
+ return self.new(cpu, os)
+ end
+ end
+
+ class MINFO < Resource
+ TypeValue = 14
+
+ def initialize(rmailbx, emailbx)
+ @rmailbx = rmailbx
+ @emailbx = emailbx
+ end
+ attr_reader :rmailbx, :emailbx
+
+ def encode_rdata(msg)
+ msg.put_name(@rmailbx)
+ msg.put_name(@emailbx)
+ end
+
+ def self.decode_rdata(msg)
+ rmailbx = msg.get_string
+ emailbx = msg.get_string
+ return self.new(rmailbx, emailbx)
+ end
+ end
+
+ class MX < Resource
+ TypeValue= 15
+
+ def initialize(preference, exchange)
+ @preference = preference
+ @exchange = exchange
+ end
+ attr_reader :preference, :exchange
+
+ def encode_rdata(msg)
+ msg.put_pack('n', @preference)
+ msg.put_name(@exchange)
+ end
+
+ def self.decode_rdata(msg)
+ preference, = msg.get_unpack('n')
+ exchange = msg.get_name
+ return self.new(preference, exchange)
+ end
+ end
+
+ class TXT < Resource
+ TypeValue = 16
+
+ def initialize(data)
+ @data = data
+ end
+ attr_reader :data
+
+ def encode_rdata(msg)
+ msg.put_string(@data)
+ end
+
+ def self.decode_rdata(msg)
+ data = msg.get_string
+ return self.new(data)
+ end
+ end
+
+ class ANY < Query
+ TypeValue = 255
+ end
+
+ ClassInsensitiveTypes = [
+ NS, CNAME, SOA, PTR, HINFO, MINFO, MX, TXT, ANY
+ ]
+
+ # ARPA Internet specific RRs
+ module IN
+ ClassValue = 1
+
+ ClassInsensitiveTypes.each {|s|
+ c = Class.new(s)
+ c.const_set(:TypeValue, s::TypeValue)
+ c.const_set(:ClassValue, ClassValue)
+ ClassHash[[s::TypeValue, ClassValue]] = c
+ self.const_set(s.name.sub(/.*::/, ''), c)
+ }
+
+ class A < Resource
+ ClassHash[[TypeValue = 1, ClassValue = ClassValue]] = self
+
+ def initialize(address)
+ @address = IPv4.create(address)
+ end
+ attr_reader :address
+
+ def encode_rdata(msg)
+ msg.put_bytes(@address.address)
+ end
+
+ def self.decode_rdata(msg)
+ return self.new(IPv4.new(msg.get_bytes(4)))
+ end
+ end
+
+ class WKS < Resource
+ ClassHash[[TypeValue = 11, ClassValue = ClassValue]] = self
+
+ def initialize(address, protocol, bitmap)
+ @address = IPv4.create(address)
+ @protocol = protocol
+ @bitmap = bitmap
+ end
+ attr_reader :address, :protocol, :bitmap
+
+ def encode_rdata(msg)
+ msg.put_bytes(@address.address)
+ msg.put_pack("n", @protocol)
+ msg.put_bytes(@bitmap)
+ end
+
+ def self.decode_rdata(msg)
+ address = IPv4.new(msg.get_bytes(4))
+ protocol, = msg.get_unpack("n")
+ bitmap = msg.get_bytes
+ return self.new(address, protocol, bitmap)
+ end
+ end
+
+ class AAAA < Resource
+ ClassHash[[TypeValue = 28, ClassValue = ClassValue]] = self
+
+ def initialize(address)
+ @address = IPv6.create(address)
+ end
+ attr_reader :address
+
+ def encode_rdata(msg)
+ msg.put_bytes(@address.address)
+ end
+
+ def self.decode_rdata(msg)
+ return self.new(IPv6.new(msg.get_bytes(16)))
+ end
+ end
+ end
+ end
+ end
+
+ class IPv4
+ Regex = /\A(\d+)\.(\d+)\.(\d+)\.(\d+)\z/
+
+ def self.create(arg)
+ case arg
+ when IPv4
+ return arg
+ when Regex
+ if (0..255) === (a = $1.to_i) &&
+ (0..255) === (b = $2.to_i) &&
+ (0..255) === (c = $3.to_i) &&
+ (0..255) === (d = $4.to_i)
+ return self.new([a, b, c, d].pack("CCCC"))
+ else
+ raise ArgumentError.new("IPv4 address with invalid value: " + arg)
+ end
+ else
+ raise ArgumentError.new("cannot interpret as IPv4 address: #{arg.inspect}")
+ end
+ end
+
+ def initialize(address)
+ unless address.kind_of?(String) && address.length == 4
+ raise ArgumentError.new('IPv4 address must be 4 bytes')
+ end
+ @address = address
+ end
+ attr_reader :address
+
+ def to_s
+ return sprintf("%d.%d.%d.%d", *@address.unpack("CCCC"))
+ end
+
+ def inspect
+ return "#<#{self.class} #{self.to_s}>"
+ end
+
+ def to_name
+ return DNS::Name.create(
+ '%d.%d.%d.%d.in-addr.arpa.' % @address.unpack('CCCC').reverse)
+ end
+
+ def ==(other)
+ return @address == other.address
+ end
+
+ def eql?(other)
+ return self == other
+ end
+
+ def hash
+ return @address.hash
+ end
+ end
+
+ class IPv6
+ Regex_8Hex = /\A
+ (?:[0-9A-Fa-f]{1,4}:){7}
+ [0-9A-Fa-f]{1,4}
+ \z/x
+
+ Regex_CompressedHex = /\A
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?) ::
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)
+ \z/x
+
+ Regex_6Hex4Dec = /\A
+ ((?:[0-9A-Fa-f]{1,4}:){6,6})
+ (\d+)\.(\d+)\.(\d+)\.(\d+)
+ \z/x
+
+ Regex_CompressedHex4Dec = /\A
+ ((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?) ::
+ ((?:[0-9A-Fa-f]{1,4}:)*)
+ (\d+)\.(\d+)\.(\d+)\.(\d+)
+ \z/x
+
+ Regex = /
+ (?:#{Regex_8Hex}) |
+ (?:#{Regex_CompressedHex}) |
+ (?:#{Regex_6Hex4Dec}) |
+ (?:#{Regex_CompressedHex4Dec})/x
+
+ def self.create(arg)
+ case arg
+ when IPv6
+ return arg
+ when String
+ address = ''
+ if Regex_8Hex =~ arg
+ arg.scan(/[0-9A-Fa-f]+/) {|hex| address << [hex.hex].pack('n')}
+ elsif Regex_CompressedHex =~ arg
+ prefix = $1
+ suffix = $2
+ a1 = ''
+ a2 = ''
+ prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
+ suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
+ omitlen = 16 - a1.length - a2.length
+ address << a1 << "\0" * omitlen << a2
+ elsif Regex_6Hex4Dec =~ arg
+ prefix, a, b, c, d = $1, $2.to_i, $3.to_i, $4.to_i, $5.to_i
+ if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
+ prefix.scan(/[0-9A-Fa-f]+/) {|hex| address << [hex.hex].pack('n')}
+ address << [a, b, c, d].pack('CCCC')
+ else
+ raise ArgumentError.new("not numeric IPv6 address: " + arg)
+ end
+ elsif Regex_CompressedHex4Dec =~ arg
+ prefix, suffix, a, b, c, d = $1, $2, $3.to_i, $4.to_i, $5.to_i, $6.to_i
+ if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
+ a1 = ''
+ a2 = ''
+ prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
+ suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
+ omitlen = 12 - a1.length - a2.length
+ address << a1 << "\0" * omitlen << a2 << [a, b, c, d].pack('CCCC')
+ else
+ raise ArgumentError.new("not numeric IPv6 address: " + arg)
+ end
+ else
+ raise ArgumentError.new("not numeric IPv6 address: " + arg)
+ end
+ return IPv6.new(address)
+ else
+ raise ArgumentError.new("cannot interpret as IPv6 address: #{arg.inspect}")
+ end
+ end
+
+ def initialize(address)
+ unless address.kind_of?(String) && address.length == 16
+ raise ArgumentError.new('IPv6 address must be 16 bytes')
+ end
+ @address = address
+ end
+ attr_reader :address
+
+ def to_s
+ address = sprintf("%X:%X:%X:%X:%X:%X:%X:%X", *@address.unpack("nnnnnnnn"))
+ unless address.sub!(/(^|:)0(:0)+(:|$)/, '::')
+ address.sub!(/(^|:)0(:|$)/, '::')
+ end
+ return address
+ end
+
+ def inspect
+ return "#<#{self.class} #{self.to_s}>"
+ end
+
+ def to_name
+ # ip6.arpa should be searched too. [RFC3152]
+ return DNS::Name.new(
+ @address.unpack("H32")[0].split(//).reverse + ['ip6', 'int'])
+ end
+
+ def ==(other)
+ return @address == other.address
+ end
+
+ def eql?(other)
+ return self == other
+ end
+
+ def hash
+ return @address.hash
+ end
+ end
+
+ DefaultResolver = self.new
+ AddressRegex = /(?:#{IPv4::Regex})|(?:#{IPv6::Regex})/
+end
diff --git a/lib/rexml/attlistdecl.rb b/lib/rexml/attlistdecl.rb
new file mode 100644
index 0000000000..d4b5c38af6
--- /dev/null
+++ b/lib/rexml/attlistdecl.rb
@@ -0,0 +1,62 @@
+#vim:ts=2 sw=2 noexpandtab:
+require 'rexml/child'
+require 'rexml/source'
+
+module REXML
+ # This class needs:
+ # * Documentation
+ # * Work! Not all types of attlists are intelligently parsed, so we just
+ # spew back out what we get in. This works, but it would be better if
+ # we formatted the output ourselves.
+ #
+ # AttlistDecls provide *just* enough support to allow namespace
+ # declarations. If you need some sort of generalized support, or have an
+ # interesting idea about how to map the hideous, terrible design of DTD
+ # AttlistDecls onto an intuitive Ruby interface, let me know. I'm desperate
+ # for anything to make DTDs more palateable.
+ class AttlistDecl < Child
+ include Enumerable
+
+ # What is this? Got me.
+ attr_reader :element_name
+
+ # Create an AttlistDecl, pulling the information from a Source. Notice
+ # that this isn't very convenient; to create an AttlistDecl, you basically
+ # have to format it yourself, and then have the initializer parse it.
+ # Sorry, but for the forseeable future, DTD support in REXML is pretty
+ # weak on convenience. Have I mentioned how much I hate DTDs?
+ def initialize(source)
+ super()
+ if (source.kind_of? Array)
+ @element_name, @pairs, @contents = *source
+ end
+ end
+
+ # Access the attlist attribute/value pairs.
+ # value = attlist_decl[ attribute_name ]
+ def [](key)
+ @pairs[key]
+ end
+
+ # Whether an attlist declaration includes the given attribute definition
+ # if attlist_decl.include? "xmlns:foobar"
+ def include?(key)
+ @pairs.keys.include? key
+ end
+
+ # Itterate over the key/value pairs:
+ # attlist_decl.each { |attribute_name, attribute_value| ... }
+ def each(&block)
+ @pairs.each(&block)
+ end
+
+ # Write out exactly what we got in.
+ def write out, indent=-1
+ out << @contents
+ end
+
+ def node_type
+ :attlistdecl
+ end
+ end
+end
diff --git a/lib/rexml/attribute.rb b/lib/rexml/attribute.rb
new file mode 100644
index 0000000000..a5a58055b8
--- /dev/null
+++ b/lib/rexml/attribute.rb
@@ -0,0 +1,163 @@
+require "rexml/namespace"
+require 'rexml/text'
+
+module REXML
+ # Defines an Element Attribute; IE, a attribute=value pair, as in:
+ # <element attribute="value"/>. Attributes can be in their own
+ # namespaces. General users of REXML will not interact with the
+ # Attribute class much.
+ class Attribute
+ include Node
+ include Namespace
+
+ # The element to which this attribute belongs
+ attr_reader :element
+ # The normalized value of this attribute. That is, the attribute with
+ # entities intact.
+ attr_writer :normalized
+ PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\2/um
+
+ # Constructor.
+ #
+ # Attribute.new( attribute_to_clone )
+ # Attribute.new( source )
+ # Attribute.new( "attr", "attr_value" )
+ # Attribute.new( "attr", "attr_value", parent_element )
+ def initialize( first, second=nil, parent=nil )
+ @normalized = @unnormalized = @element = nil
+ if first.kind_of? Attribute
+ self.name = first.expanded_name
+ @value = first.value
+ if second.kind_of? Element
+ @element = second
+ else
+ @element = first.element
+ end
+ elsif first.kind_of? String
+ @element = parent if parent.kind_of? Element
+ self.name = first
+ @value = second.to_s
+ else
+ raise "illegal argument #{first.class.name} to Attribute constructor"
+ end
+ end
+
+ # Returns the namespace of the attribute.
+ #
+ # e = Element.new( "elns:myelement" )
+ # e.add_attribute( "nsa:a", "aval" )
+ # e.add_attribute( "b", "bval" )
+ # e.attributes.get_attribute( "a" ).prefix # -> "nsa"
+ # e.attributes.get_attribute( "b" ).prefix # -> "elns"
+ # a = Attribute.new( "x", "y" )
+ # a.prefix # -> ""
+ def prefix
+ pf = super
+ if pf == ""
+ pf = @element.prefix if @element
+ end
+ pf
+ end
+
+ # Returns the namespace URL, if defined, or nil otherwise
+ #
+ # e = Element.new("el")
+ # e.add_attributes({"xmlns:ns", "http://url"})
+ # e.namespace( "ns" ) # -> "http://url"
+ def namespace arg=nil
+ arg = prefix if arg.nil?
+ @element.namespace arg
+ end
+
+ # Returns true if other is an Attribute and has the same name and value,
+ # false otherwise.
+ def ==( other )
+ other.kind_of?(Attribute) and other.name==name and other.value==@value
+ end
+
+ # Creates (and returns) a hash from both the name and value
+ def hash
+ name.hash + value.hash
+ end
+
+ # Returns this attribute out as XML source, expanding the name
+ #
+ # a = Attribute.new( "x", "y" )
+ # a.to_string # -> "x='y'"
+ # b = Attribute.new( "ns:x", "y" )
+ # b.to_string # -> "ns:x='y'"
+ def to_string
+ "#@expanded_name='#{to_s().gsub(/'/, '&apos;')}'"
+ end
+
+ # Returns the attribute value, with entities replaced
+ def to_s
+ return @normalized if @normalized
+
+ doctype = nil
+ if @element
+ doc = @element.document
+ doctype = doc.doctype if doc
+ end
+
+ @unnormalized = nil
+ @value = @normalized = Text::normalize( @value, doctype )
+ end
+
+ # Returns the UNNORMALIZED value of this attribute. That is, entities
+ # have been expanded to their values
+ def value
+ @unnormalized if @unnormalized
+ doctype = nil
+ if @element
+ doc = @element.document
+ doctype = doc.doctype if doc
+ end
+ @normalized = nil
+ @value = @unnormalized = Text::unnormalize( @value, doctype )
+ end
+
+ # Returns a copy of this attribute
+ def clone
+ Attribute.new self
+ end
+
+ # Sets the element of which this object is an attribute. Normally, this
+ # is not directly called.
+ #
+ # Returns this attribute
+ def element=( element )
+ @element = element
+ self
+ end
+
+ # Removes this Attribute from the tree, and returns true if successfull
+ #
+ # This method is usually not called directly.
+ def remove
+ @element.attributes.delete self.name unless @element.nil?
+ end
+
+ # Writes this attribute (EG, puts 'key="value"' to the output)
+ def write( output, indent=-1 )
+ output << to_string
+ end
+
+ def node_type
+ :attribute
+ end
+
+ def inspect
+ rv = ""
+ write( rv )
+ rv
+ end
+
+ def xpath
+ path = @element.xpath
+ path += "/@#{self.expanded_name}"
+ return path
+ end
+ end
+end
+#vim:ts=2 sw=2 noexpandtab:
diff --git a/lib/rexml/cdata.rb b/lib/rexml/cdata.rb
new file mode 100644
index 0000000000..ffedac1b53
--- /dev/null
+++ b/lib/rexml/cdata.rb
@@ -0,0 +1,68 @@
+require "rexml/text"
+
+module REXML
+ class CData < Text
+ START = '<![CDATA['
+ STOP = ']]>'
+ ILLEGAL = /(\]\]>)/
+
+ # Constructor. CData is data between <![CDATA[ ... ]]>
+ #
+ # _Examples_
+ # CData.new( source )
+ # CData.new( "Here is some CDATA" )
+ # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )
+ def initialize( first, whitespace=true, parent=nil )
+ super( first, whitespace, parent, true, true, ILLEGAL )
+ end
+
+ # Make a copy of this object
+ #
+ # _Examples_
+ # c = CData.new( "Some text" )
+ # d = c.clone
+ # d.to_s # -> "Some text"
+ def clone
+ CData.new self
+ end
+
+ # Returns the content of this CData object
+ #
+ # _Examples_
+ # c = CData.new( "Some text" )
+ # c.to_s # -> "Some text"
+ def to_s
+ @string
+ end
+
+ # Generates XML output of this object
+ #
+ # output::
+ # Where to write the string. Defaults to $stdout
+ # indent::
+ # An integer. If -1, no indenting will be used; otherwise, the
+ # indentation will be this number of spaces, and children will be
+ # indented an additional amount. Defaults to -1.
+ # transitive::
+ # If transitive is true and indent is >= 0, then the output will be
+ # pretty-printed in such a way that the added whitespace does not affect
+ # the absolute *value* of the document -- that is, it leaves the value
+ # and number of Text nodes in the document unchanged.
+ # ie_hack::
+ # Internet Explorer is the worst piece of crap to have ever been
+ # written, with the possible exception of Windows itself. Since IE is
+ # unable to parse proper XML, we have to provide a hack to generate XML
+ # that IE's limited abilities can handle. This hack inserts a space
+ # before the /> on empty tags.
+ #
+ # _Examples_
+ # c = CData.new( " Some text " )
+ # c.write( $stdout ) #-> <![CDATA[ Some text ]]>
+ def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
+ #indent( output, indent ) unless transitive
+ output << START
+ output << @string
+ output << STOP
+ end
+ end
+end
diff --git a/lib/rexml/child.rb b/lib/rexml/child.rb
new file mode 100644
index 0000000000..6d3c9df5e6
--- /dev/null
+++ b/lib/rexml/child.rb
@@ -0,0 +1,96 @@
+require "rexml/node"
+
+module REXML
+ ##
+ # A Child object is something contained by a parent, and this class
+ # contains methods to support that. Most user code will not use this
+ # class directly.
+ class Child
+ include Node
+ attr_reader :parent # The Parent of this object
+
+ # Constructor. Any inheritors of this class should call super to make
+ # sure this method is called.
+ # parent::
+ # if supplied, the parent of this child will be set to the
+ # supplied value, and self will be added to the parent
+ def initialize( parent = nil )
+ @parent = nil
+ # Declare @parent, but don't define it. The next line sets the
+ # parent.
+ parent.add( self ) if parent
+ end
+
+ # Replaces this object with another object. Basically, calls
+ # Parent.replace_child
+ #
+ # Returns:: self
+ def replace_with( child )
+ @parent.replace_child( self, child )
+ self
+ end
+
+ # Removes this child from the parent.
+ #
+ # Returns:: self
+ def remove
+ unless @parent.nil?
+ @parent.delete self
+ end
+ self
+ end
+
+ # Sets the parent of this child to the supplied argument.
+ #
+ # other::
+ # Must be a Parent object. If this object is the same object as the
+ # existing parent of this child, no action is taken. Otherwise, this
+ # child is removed from the current parent (if one exists), and is added
+ # to the new parent.
+ # Returns:: The parent added
+ def parent=( other )
+ return @parent if @parent == other
+ @parent.delete self if defined? @parent and @parent
+ @parent = other
+ end
+
+ alias :next_sibling :next_sibling_node
+ alias :previous_sibling :previous_sibling_node
+
+ # Sets the next sibling of this child. This can be used to insert a child
+ # after some other child.
+ # a = Element.new("a")
+ # b = a.add_element("b")
+ # c = Element.new("c")
+ # b.next_sibling = c
+ # # => <a><b/><c/></a>
+ def next_sibling=( other )
+ parent.insert_after self, other
+ end
+
+ # Sets the previous sibling of this child. This can be used to insert a
+ # child before some other child.
+ # a = Element.new("a")
+ # b = a.add_element("b")
+ # c = Element.new("c")
+ # b.previous_sibling = c
+ # # => <a><b/><c/></a>
+ def previous_sibling=(other)
+ parent.insert_before self, other
+ end
+
+ # Returns:: the document this child belongs to, or nil if this child
+ # belongs to no document
+ def document
+ return parent.document unless parent.nil?
+ nil
+ end
+
+ # This doesn't yet handle encodings
+ def bytes
+ encoding = document.encoding
+
+ to_s
+ end
+ end
+end
diff --git a/lib/rexml/comment.rb b/lib/rexml/comment.rb
new file mode 100644
index 0000000000..334017cbfc
--- /dev/null
+++ b/lib/rexml/comment.rb
@@ -0,0 +1,86 @@
+require "rexml/child"
+
+module REXML
+ ##
+ # Represents an XML comment; that is, text between <!-- ... -->
+ class Comment < Child
+ include Comparable
+ START = "<!--"
+ STOP = "-->"
+
+ attr_accessor :string # The content text
+
+ ##
+ # Constructor. The first argument can be one of three types:
+ # @param first If String, the contents of this comment are set to the
+ # argument. If Comment, the argument is duplicated. If
+ # Source, the argument is scanned for a comment.
+ # @param second If the first argument is a Source, this argument
+ # should be nil, not supplied, or a Parent to be set as the parent
+ # of this object
+ def initialize( first, second = nil )
+ #puts "IN COMMENT CONSTRUCTOR; SECOND IS #{second.type}"
+ super(second)
+ if first.kind_of? String
+ @string = first
+ elsif first.kind_of? Comment
+ @string = first.string
+ end
+ end
+
+ def clone
+ Comment.new self
+ end
+
+ # output::
+ # Where to write the string
+ # indent::
+ # An integer. If -1, no indenting will be used; otherwise, the
+ # indentation will be this number of spaces, and children will be
+ # indented an additional amount.
+ # transitive::
+ # If transitive is true and indent is >= 0, then the output will be
+ # pretty-printed in such a way that the added whitespace does not affect
+ # the absolute *value* of the document -- that is, it leaves the value
+ # and number of Text nodes in the document unchanged.
+ # ie_hack::
+ # Internet Explorer is the worst piece of crap to have ever been
+ # written, with the possible exception of Windows itself. Since IE is
+ # unable to parse proper XML, we have to provide a hack to generate XML
+ # that IE's limited abilities can handle. This hack inserts a space
+ # before the /> on empty tags.
+ #
+ def write( output, indent=-1, transitive=false, ie_hack=false )
+ indent( output, indent )
+ output << START
+ output << @string
+ if indent>-1
+ output << "\n"
+ indent( output, indent )
+ end
+ output << STOP
+ end
+
+ alias :to_s :string
+
+ ##
+ # Compares this Comment to another; the contents of the comment are used
+ # in the comparison.
+ def <=>(other)
+ other.to_s <=> @string
+ end
+
+ ##
+ # Compares this Comment to another; the contents of the comment are used
+ # in the comparison.
+ def ==( other )
+ other.kind_of? Comment and
+ (other <=> self) == 0
+ end
+
+ def node_type
+ :comment
+ end
+ end
+end
+#vim:ts=2 sw=2 noexpandtab:
diff --git a/lib/rexml/doctype.rb b/lib/rexml/doctype.rb
new file mode 100644
index 0000000000..652a04fce2
--- /dev/null
+++ b/lib/rexml/doctype.rb
@@ -0,0 +1,213 @@
+require "rexml/parent"
+require "rexml/parseexception"
+require "rexml/namespace"
+require 'rexml/entity'
+require 'rexml/attlistdecl'
+require 'rexml/xmltokens'
+
+module REXML
+ # Represents an XML DOCTYPE declaration; that is, the contents of <!DOCTYPE
+ # ... >. DOCTYPES can be used to declare the DTD of a document, as well as
+ # being used to declare entities used in the document.
+ class DocType < Parent
+ include XMLTokens
+ START = "<!DOCTYPE"
+ STOP = ">"
+ SYSTEM = "SYSTEM"
+ PUBLIC = "PUBLIC"
+ DEFAULT_ENTITIES = {
+ 'gt'=>EntityConst::GT,
+ 'lt'=>EntityConst::LT,
+ 'quot'=>EntityConst::QUOT,
+ "apos"=>EntityConst::APOS
+ }
+
+ # name is the name of the doctype
+ # external_id is the referenced DTD, if given
+ attr_reader :name, :external_id, :entities, :namespaces
+
+ # Constructor
+ #
+ # dt = DocType.new( 'foo', '-//I/Hate/External/IDs' )
+ # # <!DOCTYPE foo '-//I/Hate/External/IDs'>
+ # dt = DocType.new( doctype_to_clone )
+ # # Incomplete. Shallow clone of doctype
+ #
+ # +Note+ that the constructor:
+ #
+ # Doctype.new( Source.new( "<!DOCTYPE foo 'bar'>" ) )
+ #
+ # is _deprecated_. Do not use it. It will probably disappear.
+ def initialize( first, parent=nil )
+ @entities = DEFAULT_ENTITIES
+ @long_name = @uri = nil
+ if first.kind_of? String
+ super()
+ @name = first
+ @external_id = parent
+ elsif first.kind_of? DocType
+ super( parent )
+ @name = first.name
+ @external_id = first.external_id
+ elsif first.kind_of? Array
+ super( parent )
+ @name = first[0]
+ @external_id = first[1]
+ @long_name = first[2]
+ @uri = first[3]
+ elsif first.kind_of? Source
+ super( parent )
+ parser = Parsers::BaseParser.new( first )
+ event = parser.pull
+ if event[0] == :start_doctype
+ @name, @external_id, @long_name, @uri, = event[1..-1]
+ end
+ else
+ super()
+ end
+ end
+
+ def node_type
+ :doctype
+ end
+
+ def attributes_of element
+ rv = []
+ each do |child|
+ child.each do |key,val|
+ rv << Attribute.new(key,val)
+ end if child.kind_of? AttlistDecl and child.element_name == element
+ end
+ rv
+ end
+
+ def attribute_of element, attribute
+ att_decl = find do |child|
+ child.kind_of? AttlistDecl and
+ child.element_name == element and
+ child.include? attribute
+ end
+ return nil unless att_decl
+ att_decl[attribute]
+ end
+
+ def clone
+ DocType.new self
+ end
+
+ # output::
+ # Where to write the string
+ # indent::
+ # An integer. If -1, no indenting will be used; otherwise, the
+ # indentation will be this number of spaces, and children will be
+ # indented an additional amount.
+ # transitive::
+ # If transitive is true and indent is >= 0, then the output will be
+ # pretty-printed in such a way that the added whitespace does not affect
+ # the absolute *value* of the document -- that is, it leaves the value
+ # and number of Text nodes in the document unchanged.
+ # ie_hack::
+ # Internet Explorer is the worst piece of crap to have ever been
+ # written, with the possible exception of Windows itself. Since IE is
+ # unable to parse proper XML, we have to provide a hack to generate XML
+ # that IE's limited abilities can handle. This hack inserts a space
+ # before the /> on empty tags.
+ #
+ def write( output, indent=0, transitive=false, ie_hack=false )
+ indent( output, indent )
+ output << START
+ output << ' '
+ output << @name
+ output << " #@external_id" if @external_id
+ output << " #@long_name" if @long_name
+ output << " #@uri" if @uri
+ unless @children.empty?
+ next_indent = indent + 1
+ output << ' ['
+ child = nil # speed
+ @children.each { |child|
+ output << "\n"
+ child.write( output, next_indent )
+ }
+ output << "\n"
+ #output << ' '*next_indent
+ output << "]"
+ end
+ output << STOP
+ end
+
+ def context
+ @parent.context
+ end
+
+ def entity( name )
+ @entities[name].unnormalized if @entities[name]
+ end
+
+ def add child
+ super(child)
+ @entities = DEFAULT_ENTITIES.clone if @entities == DEFAULT_ENTITIES
+ @entities[ child.name ] = child if child.kind_of? Entity
+ end
+ end
+
+ # We don't really handle any of these since we're not a validating
+ # parser, so we can be pretty dumb about them. All we need to be able
+ # to do is spew them back out on a write()
+
+ # This is an abstract class. You never use this directly; it serves as a
+ # parent class for the specific declarations.
+ class Declaration < Child
+ def initialize src
+ super()
+ @string = src
+ end
+
+ def to_s
+ @string+'>'
+ end
+
+ def write( output, indent )
+ output << (' '*indent) if indent > 0
+ output << to_s
+ end
+ end
+
+ public
+ class ElementDecl < Declaration
+ def initialize( src )
+ super
+ end
+ end
+
+ class ExternalEntity < Child
+ def initialize( src )
+ super()
+ @entity = src
+ end
+ def to_s
+ @entity
+ end
+ def write( output, indent )
+ output << @entity
+ output << "\n"
+ end
+ end
+
+ class NotationDecl < Child
+ def initialize name, middle, rest
+ @name = name
+ @middle = middle
+ @rest = rest
+ end
+
+ def to_s
+ "<!NOTATION #@name '#@middle #@rest'>"
+ end
+
+ def write( output, indent=-1 )
+ output << (' '*indent) if indent > 0
+ output << to_s
+ end
+ end
+end
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
new file mode 100644
index 0000000000..a7f056ad3f
--- /dev/null
+++ b/lib/rexml/document.rb
@@ -0,0 +1,179 @@
+require "rexml/element"
+require "rexml/xmldecl"
+require "rexml/source"
+require "rexml/comment"
+require "rexml/doctype"
+require "rexml/instruction"
+require "rexml/rexml"
+require "rexml/parseexception"
+require "rexml/output"
+require "rexml/parsers/baseparser"
+require "rexml/parsers/streamparser"
+require "rexml/parsers/treeparser"
+
+module REXML
+ # Represents a full XML document, including PIs, a doctype, etc. A
+ # Document has a single child that can be accessed by root().
+ # Note that if you want to have an XML declaration written for a document
+ # you create, you must add one; REXML documents do not write a default
+ # declaration for you. See |DECLARATION| and |write|.
+ class Document < Element
+ # A convenient default XML declaration. If you want an XML declaration,
+ # the easiest way to add one is mydoc << Document::DECLARATION
+ # +DEPRECATED+
+ # Use: mydoc << XMLDecl.default
+ DECLARATION = XMLDecl.default
+
+ # Constructor
+ # @param source if supplied, must be a Document, String, or IO.
+ # Documents have their context and Element attributes cloned.
+ # Strings are expected to be valid XML documents. IOs are expected
+ # to be sources of valid XML documents.
+ # @param context if supplied, contains the context of the document;
+ # this should be a Hash.
+ # NOTE that I'm not sure what the context is for; I cloned it out of
+ # the Electric XML API (in which it also seems to do nothing), and it
+ # is now legacy. It may do something, someday... it may disappear.
+ def initialize( source = nil, context = {} )
+ super()
+ @context = context
+ return if source.nil?
+ if source.kind_of? Document
+ @context = source.context
+ super source
+ else
+ build( source )
+ end
+ end
+
+ def node_type
+ :document
+ end
+
+ # Should be obvious
+ def clone
+ Document.new self
+ end
+
+ # According to the XML spec, a root node has no expanded name
+ def expanded_name
+ ''
+ #d = doc_type
+ #d ? d.name : "UNDEFINED"
+ end
+
+ alias :name :expanded_name
+
+ # We override this, because XMLDecls and DocTypes must go at the start
+ # of the document
+ def add( child )
+ if child.kind_of? XMLDecl
+ @children.unshift child
+ elsif child.kind_of? DocType
+ if @children[0].kind_of? XMLDecl
+ @children[1,0] = child
+ else
+ @children.unshift child
+ end
+ child.parent = self
+ else
+ rv = super
+ raise "attempted adding second root element to document" if @elements.size > 1
+ rv
+ end
+ end
+ alias :<< :add
+
+ def add_element(arg=nil, arg2=nil)
+ rv = super
+ raise "attempted adding second root element to document" if @elements.size > 1
+ rv
+ end
+
+ # @return the root Element of the document, or nil if this document
+ # has no children.
+ def root
+ @children.find { |item| item.kind_of? Element }
+ end
+
+ # @return the DocType child of the document, if one exists,
+ # and nil otherwise.
+ def doctype
+ @children.find { |item| item.kind_of? DocType }
+ end
+
+ # @return the XMLDecl of this document; if no XMLDecl has been
+ # set, the default declaration is returned.
+ def xml_decl
+ rv = @children[0]
+ return rv if rv.kind_of? XMLDecl
+ rv = @children.unshift(XMLDecl.default)[0]
+ end
+
+ # @return the XMLDecl version of this document as a String.
+ # If no XMLDecl has been set, returns the default version.
+ def version
+ xml_decl().version
+ end
+
+ # @return the XMLDecl encoding of this document as a String.
+ # If no XMLDecl has been set, returns the default encoding.
+ def encoding
+ xml_decl().encoding
+ end
+
+ # @return the XMLDecl standalone value of this document as a String.
+ # If no XMLDecl has been set, returns the default setting.
+ def stand_alone?
+ xml_decl().stand_alone?
+ end
+
+ # Write the XML tree out, optionally with indent. This writes out the
+ # entire XML document, including XML declarations, doctype declarations,
+ # and processing instructions (if any are given).
+ # A controversial point is whether Document should always write the XML
+ # declaration (<?xml version='1.0'?>) whether or not one is given by the
+ # user (or source document). REXML does not write one if one was not
+ # specified, because it adds unneccessary bandwidth to applications such
+ # as XML-RPC.
+ #
+ #
+ # output::
+ # output an object which supports '<< string'; this is where the
+ # document will be written.
+ # indent::
+ # An integer. If -1, no indenting will be used; otherwise, the
+ # indentation will be this number of spaces, and children will be
+ # indented an additional amount. Defaults to -1
+ # transitive::
+ # If transitive is true and indent is >= 0, then the output will be
+ # pretty-printed in such a way that the added whitespace does not affect
+ # the absolute *value* of the document -- that is, it leaves the value
+ # and number of Text nodes in the document unchanged.
+ # ie_hack::
+ # Internet Explorer is the worst piece of crap to have ever been
+ # written, with the possible exception of Windows itself. Since IE is
+ # unable to parse proper XML, we have to provide a hack to generate XML
+ # that IE's limited abilities can handle. This hack inserts a space
+ # before the /> on empty tags. Defaults to false
+ def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
+ output = Output.new( output, xml_decl.encoding ) if xml_decl.encoding != "UTF-8" && !output.kind_of?(Output)
+ @children.each { |node|
+ indent( output, indent ) if node.node_type == :element
+ if node.write( output, indent, transitive, ie_hack )
+ output << "\n" unless indent<0 or node == @children[-1]
+ end
+ }
+ end
+
+
+ def Document::parse_stream( source, listener )
+ Parsers::StreamParser.new( source, listener ).parse
+ end
+
+ private
+ def build( source )
+ Parsers::TreeParser.new( source, self ).parse
+ end
+ end
+end
diff --git a/lib/rexml/dtd/attlistdecl.rb b/lib/rexml/dtd/attlistdecl.rb
new file mode 100644
index 0000000000..e176bb0749
--- /dev/null
+++ b/lib/rexml/dtd/attlistdecl.rb
@@ -0,0 +1,10 @@
+require "rexml/child"
+module REXML
+ module DTD
+ class AttlistDecl < Child
+ START = "<!ATTLIST"
+ START_RE = /^\s*#{START}/um
+ PATTERN_RE = /\s*(#{START}.*?>)/um
+ end
+ end
+end
diff --git a/lib/rexml/dtd/dtd.rb b/lib/rexml/dtd/dtd.rb
new file mode 100644
index 0000000000..81119cfa9b
--- /dev/null
+++ b/lib/rexml/dtd/dtd.rb
@@ -0,0 +1,51 @@
+require "rexml/dtd/elementdecl"
+require "rexml/dtd/entitydecl"
+require "rexml/comment"
+require "rexml/dtd/notationdecl"
+require "rexml/dtd/attlistdecl"
+require "rexml/parent"
+
+module REXML
+ module DTD
+ class Parser
+ def Parser.parse( input )
+ case input
+ when String
+ parse_helper input
+ when File
+ parse_helper input.read
+ end
+ end
+
+ # Takes a String and parses it out
+ def Parser.parse_helper( input )
+ contents = Parent.new
+ while input.size > 0
+ case input
+ when ElementDecl.PATTERN_RE
+ match = $&
+ source = $'
+ contents << EleemntDecl.new( match )
+ when AttlistDecl.PATTERN_RE
+ matchdata = $~
+ source = $'
+ contents << AttlistDecl.new( matchdata )
+ when EntityDecl.PATTERN_RE
+ matchdata = $~
+ source = $'
+ contents << EntityDecl.new( matchdata )
+ when Comment.PATTERN_RE
+ matchdata = $~
+ source = $'
+ contents << Comment.new( matchdata )
+ when NotationDecl.PATTERN_RE
+ matchdata = $~
+ source = $'
+ contents << NotationDecl.new( matchdata )
+ end
+ end
+ contents
+ end
+ end
+ end
+end
diff --git a/lib/rexml/dtd/elementdecl.rb b/lib/rexml/dtd/elementdecl.rb
new file mode 100644
index 0000000000..c4e620f389
--- /dev/null
+++ b/lib/rexml/dtd/elementdecl.rb
@@ -0,0 +1,17 @@
+require "rexml/child"
+module REXML
+ module DTD
+ class ElementDecl < Child
+ START = "<!ELEMENT"
+ START_RE = /^\s*#{START}/um
+ PATTERN_RE = /^\s*(#{START}.*?)>/um
+ PATTERN_RE = /^\s*#{START}\s+((?:[:\w_][-\.\w_]*:)?[-!\*\.\w_]*)(.*?)>/
+ #\s*((((["']).*?\5)|[^\/'">]*)*?)(\/)?>/um, true)
+
+ def initialize match
+ @name = match[1]
+ @rest = match[2]
+ end
+ end
+ end
+end
diff --git a/lib/rexml/dtd/entitydecl.rb b/lib/rexml/dtd/entitydecl.rb
new file mode 100644
index 0000000000..a5f1520f2b
--- /dev/null
+++ b/lib/rexml/dtd/entitydecl.rb
@@ -0,0 +1,56 @@
+require "rexml/child"
+module REXML
+ module DTD
+ class EntityDecl < Child
+ START = "<!ENTITY"
+ START_RE = /^\s*#{START}/um
+ PUBLIC = /^\s*#{START}\s+(?:%\s+)?(\w+)\s+PUBLIC\s+((["']).*?\3)\s+((["']).*?\5)\s*>/um
+ SYSTEM = /^\s*#{START}\s+(?:%\s+)?(\w+)\s+SYSTEM\s+((["']).*?\3)(?:\s+NDATA\s+\w+)?\s*>/um
+ PLAIN = /^\s*#{START}\s+(\w+)\s+((["']).*?\3)\s*>/um
+ PERCENT = /^\s*#{START}\s+%\s+(\w+)\s+((["']).*?\3)\s*>/um
+ # <!ENTITY name SYSTEM "...">
+ # <!ENTITY name "...">
+ def initialize src
+ super()
+ md = nil
+ if src.match( PUBLIC )
+ md = src.match( PUBLIC, true )
+ @middle = "PUBLIC"
+ @content = "#{md[2]} #{md[4]}"
+ elsif src.match( SYSTEM )
+ md = src.match( SYSTEM, true )
+ @middle = "SYSTEM"
+ @content = md[2]
+ elsif src.match( PLAIN )
+ md = src.match( PLAIN, true )
+ @middle = ""
+ @content = md[2]
+ elsif src.match( PERCENT )
+ md = src.match( PERCENT, true )
+ @middle = ""
+ @content = md[2]
+ end
+ raise ParseException.new("failed Entity match", src) if md.nil?
+ @name = md[1]
+ end
+
+ def to_s
+ rv = "<!ENTITY #@name "
+ rv << "#@middle " if @middle.size > 0
+ rv << @content
+ rv
+ end
+
+ def write( output, indent )
+ indent( output, indent )
+ output << to_s
+ end
+
+ def EntityDecl.parse_source source, listener
+ md = source.match( PATTERN_RE, true )
+ thing = md[0].squeeze(" \t\n\r")
+ listener.send inspect.downcase, thing
+ end
+ end
+ end
+end
diff --git a/lib/rexml/dtd/notationdecl.rb b/lib/rexml/dtd/notationdecl.rb
new file mode 100644
index 0000000000..a47ff8f24b
--- /dev/null
+++ b/lib/rexml/dtd/notationdecl.rb
@@ -0,0 +1,39 @@
+require "rexml/child"
+module REXML
+ module DTD
+ class NotationDecl < Child
+ START = "<!NOTATION"
+ START_RE = /^\s*#{START}/um
+ PUBLIC = /^\s*#{START}\s+(\w[\w-]*)\s+(PUBLIC)\s+((["']).*?\4)\s*>/um
+ SYSTEM = /^\s*#{START}\s+(\w[\w-]*)\s+(SYSTEM)\s+((["']).*?\4)\s*>/um
+ def initialize src
+ super()
+ if src.match( PUBLIC )
+ md = src.match( PUBLIC, true )
+ elsif src.match( SYSTEM )
+ md = src.match( SYSTEM, true )
+ else
+ raise ParseException.new( "error parsing notation: no matching pattern", src )
+ end
+ @name = md[1]
+ @middle = md[2]
+ @rest = md[3]
+ end
+
+ def to_s
+ "<!NOTATION #@name #@middle #@rest>"
+ end
+
+ def write( output, indent )
+ indent( output, indent )
+ output << to_s
+ end
+
+ def NotationDecl.parse_source source, listener
+ md = source.match( PATTERN_RE, true )
+ thing = md[0].squeeze(" \t\n\r")
+ listener.send inspect.downcase, thing
+ end
+ end
+ end
+end
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
new file mode 100644
index 0000000000..b76c0179c7
--- /dev/null
+++ b/lib/rexml/element.rb
@@ -0,0 +1,1205 @@
+require "rexml/parent"
+require "rexml/namespace"
+require "rexml/attribute"
+require "rexml/cdata"
+require "rexml/xpath"
+require "rexml/parseexception"
+
+module REXML
+ # Represents a tagged XML element. Elements are characterized by
+ # having children, attributes, and names, and can themselves be
+ # children.
+ class Element < Parent
+ include Namespace
+
+ UNDEFINED = "UNDEFINED"; # The default name
+
+ # Mechanisms for accessing attributes and child elements of this
+ # element.
+ attr_reader :attributes, :elements
+ # The context holds information about the processing environment, such as
+ # whitespace handling.
+ attr_accessor :context
+
+ # Constructor
+ # arg::
+ # if not supplied, will be set to the default value.
+ # If a String, the name of this object will be set to the argument.
+ # If an Element, the object will be shallowly cloned; name,
+ # attributes, and namespaces will be copied. Children will +not+ be
+ # copied.
+ # If a Source, the source will be scanned and parsed for an Element,
+ # and all child elements will be recursively parsed as well.
+ # parent::
+ # if supplied, must be a Parent, and will be used as
+ # the parent of this object.
+ # context::
+ # If supplied, must be a hash containing context items. Context items
+ # include:
+ # * <tt>:respect_whitespace</tt> the value of this is :+all+ or an array of
+ # strings being the names of the elements to respect
+ # whitespace for. Defaults to :+all+.
+ # * <tt>:compress_whitespace</tt> the value can be :+all+ or an array of
+ # strings being the names of the elements to ignore whitespace on.
+ # Overrides :+respect_whitespace+.
+ # * <tt>:ignore_whitespace_nodes</tt> the value can be :+all+ or an array
+ # of strings being the names of the elements in which to ignore
+ # whitespace-only nodes. If this is set, Text nodes which contain only
+ # whitespace will not be added to the document tree.
+ # * <tt>:raw</tt> can be :+all+, or an array of strings being the names of
+ # the elements to process in raw mode. In raw mode, special
+ # characters in text is not converted to or from entities.
+ def initialize( arg = UNDEFINED, parent=nil, context=nil )
+ super(parent)
+
+ @elements = Elements.new(self)
+ @attributes = Attributes.new(self)
+ @context = context
+
+ if arg.kind_of? String
+ self.name = arg
+ elsif arg.kind_of? Element
+ self.name = arg.expanded_name
+ arg.attributes.each_attribute{ |attribute|
+ @attributes << Attribute.new( attribute )
+ }
+ @context = arg.context
+ end
+ end
+
+ def inspect
+ rv = "<#@expanded_name"
+
+ @attributes.each_attribute do |attr|
+ rv << " "
+ attr.write( rv, 0 )
+ end
+
+ if children.size > 0
+ rv << "> ... </>"
+ else
+ rv << "/>"
+ end
+ end
+
+
+ # Creates a shallow copy of self.
+ # d = Document.new "<a><b/><b/><c><d/></c></a>"
+ # new_a = d.root.clone
+ # puts new_a # => "<a/>"
+ def clone
+ Element.new self
+ end
+
+ # Evaluates to the root element of the document that this element
+ # belongs to. If this element doesn't belong to a document, but does
+ # belong to another Element, the parent's root will be returned, until the
+ # earliest ancestor is found.
+ # d = Document.new '<a><b><c/></b></a>'
+ # a = d[1] ; c = a[1][1]
+ # d.root # These all evaluate to the same Element,
+ # a.root # namely, <a>
+ # c.root #
+ def root
+ parent.nil? ? self : parent.root
+ end
+
+ # Evaluates to the document to which this element belongs, or nil if this
+ # element doesn't belong to a document.
+ def document
+ rt = root
+ rt.parent if rt
+ end
+
+ # Evaluates to +true+ if whitespace is respected for this element. This
+ # is the case if:
+ # 1. Neither :+respect_whitespace+ nor :+compress_whitespace+ has any value
+ # 2. The context has :+respect_whitespace+ set to :+all+ or
+ # an array containing the name of this element, and
+ # :+compress_whitespace+ isn't set to :+all+ or an array containing the
+ # name of this element.
+ # The evaluation is tested against +expanded_name+, and so is namespace
+ # sensitive.
+ def whitespace
+ @whitespace = nil
+ if @context
+ if @context[:respect_whitespace]
+ @whitespace = (@context[:respect_whitespace] == :all or
+ @context[:respect_whitespace].include? expanded_name)
+ end
+ @whitespace = false if (@context[:compress_whitespace] and
+ (@context[:compress_whitespace] == :all or
+ @context[:compress_whitespace].include? expanded_name)
+ )
+ end
+ @whitespace = true unless @whitespace == false
+ @whitespace
+ end
+
+ def ignore_whitespace_nodes
+ @ignore_whitespace_nodes = false
+ if @context
+ if @context[:ignore_whitespace_nodes]
+ @ignore_whitespace_nodes =
+ (@context[:ignore_whitespace_nodes] == :all or
+ @context[:ignore_whitespace_nodes].include? expanded_name)
+ end
+ end
+ end
+
+ # Evaluates to +true+ if raw mode is set for this element. This
+ # is the case if the context has :+raw+ set to :+all+ or
+ # an array containing the name of this element.
+ #
+ # The evaluation is tested against +expanded_name+, and so is namespace
+ # sensitive.
+ def raw
+ @raw = (@context and @context[:raw] and
+ (@context[:raw] == :all or
+ @context[:raw].include? expanded_name))
+ @raw
+ end
+
+ #once :whitespace, :raw, :ignore_whitespace_nodes
+
+ #################################################
+ # Namespaces #
+ #################################################
+
+ # Evaluates to an +Array+ containing the prefixes (names) of all defined
+ # namespaces at this context node.
+ # doc = Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
+ # doc.elements['//b'].prefixes # -> ['x', 'y']
+ def prefixes
+ prefixes = []
+ prefixes = parent.prefixes if parent
+ prefixes |= attributes.prefixes
+ return prefixes
+ end
+
+ def namespaces
+ namespaces = []
+ namespaces = parent.namespaces if parent
+ namespaces |= attributes.namespaces
+ return namespaces
+ end
+
+ # Evalutas to the URI for a prefix, or the empty string if no such
+ # namespace is declared for this element. Evaluates recursively for
+ # ancestors. Returns the default namespace, if there is one.
+ # prefix::
+ # the prefix to search for. If not supplied, returns the default
+ # namespace if one exists
+ # Returns::
+ # the namespace URI as a String, or nil if no such namespace
+ # exists. If the namespace is undefined, returns an empty string
+ # doc = Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
+ # b = doc.elements['//b']
+ # b.namespace # -> '1'
+ # b.namespace("y") # -> '2'
+ def namespace(prefix=nil)
+ if prefix.nil?
+ prefix = prefix()
+ end
+ if prefix == ''
+ prefix = "xmlns"
+ else
+ prefix = "xmlns:#{prefix}" unless prefix[0,5] == 'xmlns'
+ end
+ ns = attributes[ prefix ]
+ ns = parent.namespace(prefix) if ns.nil? and parent
+ ns = '' if ns.nil? and prefix == 'xmlns'
+ return ns
+ end
+
+ # Adds a namespace to this element.
+ # prefix::
+ # the prefix string, or the namespace URI if +uri+ is not
+ # supplied
+ # uri::
+ # the namespace URI. May be nil, in which +prefix+ is used as
+ # the URI
+ # Evaluates to: this Element
+ # a = Element.new("a")
+ # a.add_namespace("xmlns:foo", "bar" )
+ # a.add_namespace("foo", "bar") # shorthand for previous line
+ # a.add_namespace("twiddle")
+ # puts a #-> <a xmlns:foo='bar' xmlns='twiddle'/>
+ def add_namespace( prefix, uri=nil )
+ unless uri
+ @attributes["xmlns"] = prefix
+ else
+ prefix = "xmlns:#{prefix}" unless prefix =~ /^xmlns:/
+ @attributes[ prefix ] = uri
+ end
+ self
+ end
+
+ # Removes a namespace from this node. This only works if the namespace is
+ # actually declared in this node. If no argument is passed, deletes the
+ # default namespace.
+ #
+ # Evaluates to: this element
+ # doc = Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
+ # doc.root.delete_namespace
+ # puts doc # -> <a xmlns:foo='bar'/>
+ # doc.root.delete_namespace 'foo'
+ # puts doc # -> <a/>
+ def delete_namespace namespace="xmlns"
+ namespace = "xmlns:#{namespace}" unless namespace == 'xmlns'
+ attribute = attributes.get_attribute(namespace)
+ attribute.remove unless attribute.nil?
+ self
+ end
+
+ #################################################
+ # Elements #
+ #################################################
+
+ # Adds a child to this element, optionally setting attributes in
+ # the element.
+ # element::
+ # optional. If Element, the element is added.
+ # Otherwise, a new Element is constructed with the argument (see
+ # Element.initialize).
+ # attrs::
+ # If supplied, must be a Hash containing String name,value
+ # pairs, which will be used to set the attributes of the new Element.
+ # Returns:: the Element that was added
+ # el = doc.add_element 'my-tag'
+ # el = doc.add_element 'my-tag', {'attr1'=>'val1', 'attr2'=>'val2'}
+ # el = Element.new 'my-tag'
+ # doc.add_element el
+ def add_element element=nil, attrs=nil
+ el = @elements.add(element)
+ if attrs.kind_of? Hash
+ attrs.each do |key, value|
+ el.attributes[key]=value if key =~ /^xmlns:/
+ end
+ attrs.each do |key, value|
+ el.attributes[key]=value if key !~ /^xmlns:/
+ end
+ end
+ el
+ end
+
+ # Deletes a child element.
+ # element::
+ # Must be an +Element+, +String+, or +Integer+. If Element,
+ # the element is removed. If String, the element is found (via XPath)
+ # and removed. <em>This means that any parent can remove any
+ # descendant.<em> If Integer, the Element indexed by that number will be
+ # removed.
+ # Returns:: the element that was removed.
+ # doc.delete_element "/a/b/c[@id='4']"
+ # doc.delete_element doc.elements["//k"]
+ # doc.delete_element 1
+ def delete_element element
+ @elements.delete element
+ end
+
+ # Evaluates to +true+ if this element has at least one child Element
+ # doc = Document.new "<a><b/><c>Text</c></a>"
+ # doc.root.has_elements # -> true
+ # doc.elements["/a/b"].has_elements # -> false
+ # doc.elements["/a/c"].has_elements # -> false
+ def has_elements?
+ !@elements.empty?
+ end
+
+ # Iterates through the child elements, yielding for each Element that
+ # has a particular attribute set.
+ # key::
+ # the name of the attribute to search for
+ # value::
+ # the value of the attribute
+ # max::
+ # (optional) causes this method to return after yielding
+ # for this number of matching children
+ # name::
+ # (optional) if supplied, this is an XPath that filters
+ # the children to check.
+ #
+ # doc = Document.new "<a><b @id='1'/><c @id='2'/><d @id='1'/><e/></a>"
+ # # Yields b, c, d
+ # doc.root.each_element_with_attribute( 'id' ) {|e| p e}
+ # # Yields b, d
+ # doc.root.each_element_with_attribute( 'id', '1' ) {|e| p e}
+ # # Yields b
+ # doc.root.each_element_with_attribute( 'id', '1', 1 ) {|e| p e}
+ # # Yields d
+ # doc.root.each_element_with_attribute( 'id', '1', 0, 'd' ) {|e| p e}
+ def each_element_with_attribute( key, value=nil, max=0, name=nil, &block ) # :yields: Element
+ each_with_something( proc {|child|
+ if value.nil?
+ child.attributes[key] != nil
+ else
+ child.attributes[key]==value
+ end
+ }, max, name, &block )
+ end
+
+ # Iterates through the children, yielding for each Element that
+ # has a particular text set.
+ # text::
+ # the text to search for. If nil, or not supplied, will itterate
+ # over all +Element+ children that contain at least one +Text+ node.
+ # max::
+ # (optional) causes this method to return after yielding
+ # for this number of matching children
+ # name::
+ # (optional) if supplied, this is an XPath that filters
+ # the children to check.
+ #
+ # doc = Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
+ # # Yields b, c, d
+ # doc.each_element_with_text {|e|p e}
+ # # Yields b, c
+ # doc.each_element_with_text('b'){|e|p e}
+ # # Yields b
+ # doc.each_element_with_text('b', 1){|e|p e}
+ # # Yields d
+ # doc.each_element_with_text(nil, 0, 'd'){|e|p e}
+ def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element
+ each_with_something( proc {|child|
+ if text.nil?
+ child.has_text?
+ else
+ child.text == text
+ end
+ }, max, name, &block )
+ end
+
+ # Synonym for Element.elements.each
+ def each_element( xpath=nil, &block ) # :yields: Element
+ @elements.each( xpath, &block )
+ end
+
+ # Synonym for Element.to_a
+ # This is a little slower than calling elements.each directly.
+ # xpath:: any XPath by which to search for elements in the tree
+ # Returns:: an array of Elements that match the supplied path
+ def get_elements( xpath )
+ @elements.to_a( xpath )
+ end
+
+ # Returns the next sibling that is an element, or nil if there is
+ # no Element sibling after this one
+ # doc = Document.new '<a><b/>text<c/></a>'
+ # doc.root.elements['b'].next_element #-> <c/>
+ # doc.root.elements['c'].next_element #-> nil
+ def next_element
+ element = next_sibling
+ element = element.next_sibling until element.nil? or element.kind_of? Element
+ return element
+ end
+
+ # Returns the previous sibling that is an element, or nil if there is
+ # no Element sibling prior to this one
+ # doc = Document.new '<a><b/>text<c/></a>'
+ # doc.root.elements['c'].previous_element #-> <b/>
+ # doc.root.elements['b'].previous_element #-> nil
+ def previous_element
+ element = previous_sibling
+ element = element.previous_sibling until element.nil? or element.kind_of? Element
+ return element
+ end
+
+
+ #################################################
+ # Text #
+ #################################################
+
+ # Evaluates to +true+ if this element has at least one Text child
+ def has_text?
+ not text().nil?
+ end
+
+ # A convenience method which returns the String value of the _first_
+ # child text element, if one exists, and +nil+ otherwise.
+ #
+ # <em>Note that an element may have multiple Text elements, perhaps
+ # separated by other children</em>. Be aware that this method only returns
+ # the first Text node.
+ #
+ # This method returns the +value+ of the first text child node, which
+ # ignores the +raw+ setting, so always returns normalized text. See
+ # the Text::value documentation.
+ #
+ # doc = Document.new "<p>some text <b>this is bold!</b> more text</p>"
+ # # The element 'p' has two text elements, "some text " and " more text".
+ # doc.root.text #-> "some text "
+ def text( path = nil )
+ rv = get_text(path)
+ return rv.value unless rv.nil?
+ nil
+ end
+
+ # Returns the first child Text node, if any, or +nil+ otherwise.
+ # This method returns the actual +Text+ node, rather than the String content.
+ # doc = Document.new "<p>some text <b>this is bold!</b> more text</p>"
+ # # The element 'p' has two text elements, "some text " and " more text".
+ # doc.root.get_text.value #-> "some text "
+ def get_text path = nil
+ rv = nil
+ if path
+ element = @elements[ path ]
+ rv = element.get_text unless element.nil?
+ else
+ rv = @children.find { |node| node.kind_of? Text }
+ end
+ return rv
+ end
+
+ # Sets the first Text child of this object. See text() for a
+ # discussion about Text children.
+ #
+ # If a Text child already exists, the child is replaced by this
+ # content. This means that Text content can be deleted by calling
+ # this method with a nil argument. In this case, the next Text
+ # child becomes the first Text child. In no case is the order of
+ # any siblings disturbed.
+ # text::
+ # If a String, a new Text child is created and added to
+ # this Element as the first Text child. If Text, the text is set
+ # as the first Child element. If nil, then any existing first Text
+ # child is removed.
+ # Returns:: this Element.
+ # doc = Document.new '<a><b/></a>'
+ # doc.root.text = 'Sean' #-> '<a><b/>Sean</a>'
+ # doc.root.text = 'Elliott' #-> '<a><b/>Elliott</a>'
+ # doc.root.add_element 'c' #-> '<a><b/>Elliott<c/></a>'
+ # doc.root.text = 'Russell' #-> '<a><b/>Russell<c/></a>'
+ # doc.root.text = nil #-> '<a><b/><c/></a>'
+ def text=( text )
+ if text.kind_of? String
+ text = Text.new( text, whitespace(), nil, raw() )
+ elsif text and !text.kind_of? Text
+ text = Text.new( text.to_s, whitespace(), nil, raw() )
+ end
+
+ old_text = get_text
+ if text.nil?
+ old_text.remove unless old_text.nil?
+ else
+ if old_text.nil?
+ self << text
+ else
+ old_text.replace_with( text )
+ end
+ end
+ return self
+ end
+
+ # A helper method to add a Text child. Actual Text instances can
+ # be added with regular Parent methods, such as add() and <<()
+ # text::
+ # if a String, a new Text instance is created and added
+ # to the parent. If Text, the object is added directly.
+ # Returns:: this Element
+ # e = Element.new('a') #-> <e/>
+ # e.add_text 'foo' #-> <e>foo</e>
+ # e.add_text Text.new(' bar') #-> <e>foo bar</e>
+ # Note that at the end of this example, the branch has <b>3</b> nodes; the 'e'
+ # element and <b>2</b> Text node children.
+ def add_text( text )
+ if text.kind_of? String
+ if @children[-1].kind_of? Text
+ @children[-1] << text
+ return
+ end
+ text = Text.new( text, whitespace(), nil, raw() )
+ end
+ self << text unless text.nil?
+ return self
+ end
+
+ def node_type
+ :element
+ end
+
+ def xpath
+ path_elements = []
+ cur = self
+ path_elements << __to_xpath_helper( self )
+ while cur.parent
+ cur = cur.parent
+ path_elements << __to_xpath_helper( cur )
+ end
+ return path_elements.reverse.join( "/" )
+ end
+
+ #################################################
+ # Attributes #
+ #################################################
+
+ def attribute( name, namespace=nil )
+ prefix = ''
+ if namespace
+ prefix = attributes.prefixes.each { |prefix|
+ return "#{prefix}:" if namespace( prefix ) == namespace
+ } || ''
+ end
+ attributes.get_attribute( "#{prefix}#{name}" )
+ end
+
+ # Evaluates to +true+ if this element has any attributes set, false
+ # otherwise.
+ def has_attributes?
+ return !@attributes.empty?
+ end
+
+ # Adds an attribute to this element, overwriting any existing attribute
+ # by the same name.
+ # key::
+ # can be either an Attribute or a String. If an Attribute,
+ # the attribute is added to the list of Element attributes. If String,
+ # the argument is used as the name of the new attribute, and the value
+ # parameter must be supplied.
+ # value::
+ # Required if +key+ is a String, and ignored if the first argument is
+ # an Attribute. This is a String, and is used as the value
+ # of the new Attribute.
+ # Returns:: the Attribute added
+ # e = Element.new 'e'
+ # e.add_attribute( 'a', 'b' ) #-> <e a='b'/>
+ # e.add_attribute( 'x:a', 'c' ) #-> <e a='b' x:a='c'/>
+ # e.add_attribute Attribute.new('b', 'd') #-> <e a='b' x:a='c' b='d'/>
+ def add_attribute( key, value=nil )
+ if key.kind_of? Attribute
+ @attributes << key
+ else
+ @attributes[key] = value
+ end
+ end
+
+ # Add multiple attributes to this element.
+ # hash:: is either a hash, or array of arrays
+ # el.add_attributes( {"name1"=>"value1", "name2"=>"value2"} )
+ # el.add_attributes( [ ["name1","value1"], ["name2"=>"value2"] ] )
+ def add_attributes hash
+ if hash.kind_of? Hash
+ hash.each_pair {|key, value| @attributes[key] = value }
+ elsif hash.kind_of? Array
+ hash.each { |value| @attributes[ value[0] ] = value[1] }
+ end
+ end
+
+ # Removes an attribute
+ # key::
+ # either an Attribute or a String. In either case, the
+ # attribute is found by matching the attribute name to the argument,
+ # and then removed. If no attribute is found, no action is taken.
+ # Returns::
+ # the attribute removed, or nil if this Element did not contain
+ # a matching attribute
+ # e = Element.new('E')
+ # e.add_attribute( 'name', 'Sean' ) #-> <E name='Sean'/>
+ # r = e.add_attribute( 'sur:name', 'Russell' ) #-> <E name='Sean' sur:name='Russell'/>
+ # e.delete_attribute( 'name' ) #-> <E sur:name='Russell'/>
+ # e.delete_attribute( r ) #-> <E/>
+ def delete_attribute(key)
+ attr = @attributes.get_attribute(key)
+ attr.remove unless attr.nil?
+ end
+
+ #################################################
+ # Other Utilities #
+ #################################################
+
+ # Get an array of all CData children.
+ # IMMUTABLE
+ def cdatas
+ find_all { |child| child.kind_of? CData }.freeze
+ end
+
+ # Get an array of all Comment children.
+ # IMMUTABLE
+ def comments
+ find_all { |child| child.kind_of? Comment }.freeze
+ end
+
+ # Get an array of all Instruction children.
+ # IMMUTABLE
+ def instructions
+ find_all { |child| child.kind_of? Instruction }.freeze
+ end
+
+ # Get an array of all Text children.
+ # IMMUTABLE
+ def texts
+ find_all { |child| child.kind_of? Text }.freeze
+ end
+
+ # Writes out this element, and recursively, all children.
+ # output::
+ # output an object which supports '<< string'; this is where the
+ # document will be written.
+ # indent::
+ # An integer. If -1, no indenting will be used; otherwise, the
+ # indentation will be this number of spaces, and children will be
+ # indented an additional amount. Defaults to -1
+ # transitive::
+ # If transitive is true and indent is >= 0, then the output will be
+ # pretty-printed in such a way that the added whitespace does not affect
+ # the parse tree of the document
+ # ie_hack::
+ # Internet Explorer is the worst piece of crap to have ever been
+ # written, with the possible exception of Windows itself. Since IE is
+ # unable to parse proper XML, we have to provide a hack to generate XML
+ # that IE's limited abilities can handle. This hack inserts a space
+ # before the /> on empty tags. Defaults to false
+ #
+ # out = ''
+ # doc.write( out ) #-> doc is written to the string 'out'
+ # doc.write( $stdout ) #-> doc written to the console
+ def write(writer=$stdout, indent=-1, transitive=false, ie_hack=false)
+ #print "ID:#{indent}"
+ writer << "<#@expanded_name"
+
+ @attributes.each_attribute do |attr|
+ writer << " "
+ attr.write( writer, indent )
+ end unless @attributes.empty?
+
+ if @children.empty?
+ if transitive and indent>-1
+ writer << "\n"
+ indent( writer, indent )
+ elsif ie_hack
+ writer << " "
+ end
+ writer << "/"
+ else
+ if transitive and indent>-1 and !@children[0].kind_of? Text
+ writer << "\n"
+ indent writer, indent+1
+ end
+ writer << ">"
+ write_children( writer, indent, transitive, ie_hack )
+ writer << "</#{expanded_name}"
+ end
+ if transitive and indent>-1 and !@children.empty?
+ writer << "\n"
+ indent -= 1 if next_sibling.nil?
+ indent(writer, indent)
+ end
+ writer << ">"
+ end
+
+
+ private
+ def __to_xpath_helper node
+ rv = node.expanded_name
+ if node.parent
+ results = node.parent.find_all {|n|
+ n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
+ }
+ if results.length > 1
+ idx = results.index( node )
+ rv << "[#{idx+1}]"
+ end
+ end
+ rv
+ end
+
+ # A private helper method
+ def each_with_something( test, max=0, name=nil )
+ num = 0
+ child=nil
+ @elements.each( name ){ |child|
+ yield child if test.call(child) and num += 1
+ return if max>0 and num == max
+ }
+ end
+
+ # A private helper method
+ def write_children( writer, indent, transitive, ie_hack )
+ cr = (indent < 0) ? '' : "\n"
+ if indent == -1
+ each { |child| child.write( writer, indent, transitive, ie_hack ) }
+ else
+ next_indent = indent+1
+ last_child=nil
+ each { |child|
+ unless child.kind_of? Text or last_child.kind_of? Text or transitive
+ writer << cr
+ indent(writer, next_indent)
+ end
+ child.write( writer, next_indent, transitive, ie_hack )
+ last_child = child
+ }
+ unless last_child.kind_of? Text or transitive
+ writer << cr
+ indent( writer, indent )
+ end
+ end
+ end
+ end
+
+ ########################################################################
+ # ELEMENTS #
+ ########################################################################
+
+ # A class which provides filtering of children for Elements, and
+ # XPath search support. You are expected to only encounter this class as
+ # the <tt>element.elements</tt> object. Therefore, you are
+ # _not_ expected to instantiate this yourself.
+ class Elements
+ include Enumerable
+ # Constructor
+ # parent:: the parent Element
+ def initialize parent
+ @element = parent
+ end
+
+ # Fetches a child element. Filters only Element children, regardless of
+ # the XPath match.
+ # index::
+ # the search parameter. This is either an Integer, which
+ # will be used to find the index'th child Element, or an XPath,
+ # which will be used to search for the Element. <em>Because
+ # of the nature of XPath searches, any element in the connected XML
+ # document can be fetched through any other element.</em> <b>The
+ # Integer index is 1-based, not 0-based.</b> This means that the first
+ # child element is at index 1, not 0, and the +n+th element is at index
+ # +n+, not <tt>n-1</tt>. This is because XPath indexes element children
+ # starting from 1, not 0, and the indexes should be the same.
+ # name::
+ # optional, and only used in the first argument is an
+ # Integer. In that case, the index'th child Element that has the
+ # supplied name will be returned. Note again that the indexes start at 1.
+ # Returns:: the first matching Element, or nil if no child matched
+ # doc = Document.new '<a><b/><c id="1"/><c id="2"/><d/></a>'
+ # doc.root.elements[1] #-> <b/>
+ # doc.root.elements['c'] #-> <c id="1"/>
+ # doc.root.elements[2,'c'] #-> <c id="2"/>
+ def []( index, name=nil)
+ if index.kind_of? Integer
+ raise "index (#{index}) must be >= 1" if index < 1
+ name = literalize(name) if name
+ num = 0
+ child = nil
+ @element.find { |child|
+ child.kind_of? Element and
+ (name.nil? ? true : child.has_name?( name )) and
+ (num += 1) == index
+ }
+ else
+ return XPath::first( @element, index )
+ #{ |element|
+ # return element if element.kind_of? Element
+ #}
+ #return nil
+ end
+ end
+
+ # Sets an element, replacing any previous matching element. If no
+ # existing element is found ,the element is added.
+ # index:: Used to find a matching element to replace. See []().
+ # element::
+ # The element to replace the existing element with
+ # the previous element
+ # Returns:: nil if no previous element was found.
+ #
+ # doc = Document.new '<a/>'
+ # doc.root.elements[10] = Element.new('b') #-> <a><b/></a>
+ # doc.root.elements[1] #-> <b/>
+ # doc.root.elements[1] = Element.new('c') #-> <a><c/></a>
+ # doc.root.elements['c'] = Element.new('d') #-> <a><d/></a>
+ def []=( index, element )
+ previous = self[index]
+ if previous.nil?
+ @element.add element
+ else
+ previous.replace_with element
+ end
+ return previous
+ end
+
+ # Returns +true+ if there are no +Element+ children, +false+ otherwise
+ def empty?
+ @element.find{ |child| child.kind_of? Element}.nil?
+ end
+
+ # Returns the index of the supplied child (starting at 1), or -1 if
+ # the element is not a child
+ # element:: an +Element+ child
+ def index element
+ rv = 0
+ found = @element.find do |child|
+ child.kind_of? Element and
+ (rv += 1) and
+ child == element
+ end
+ return rv if found == element
+ return -1
+ end
+
+ # Deletes a child Element
+ # element::
+ # Either an Element, which is removed directly; an
+ # xpath, where the first matching child is removed; or an Integer,
+ # where the n'th Element is removed.
+ # Returns:: the removed child
+ # doc = Document.new '<a><b/><c/><c id="1"/></a>'
+ # b = doc.root.elements[1]
+ # doc.root.elements.delete b #-> <a><c/><c id="1"/></a>
+ # doc.elements.delete("a/c[@id='1']") #-> <a><c/></a>
+ # doc.root.elements.delete 1 #-> <a/>
+ def delete element
+ if element.kind_of? Element
+ @element.delete element
+ else
+ el = self[element]
+ el.remove if el
+ end
+ end
+
+ # Removes multiple elements. Filters for Element children, regardless of
+ # XPath matching.
+ # xpath:: all elements matching this String path are removed.
+ # Returns:: an Array of Elements that have been removed
+ # doc = Document.new '<a><c/><c/><c/><c/></a>'
+ # deleted = doc.elements.delete_all 'a/c' #-> [<c/>, <c/>, <c/>, <c/>]
+ def delete_all( xpath )
+ rv = []
+ XPath::each( @element, xpath) {|element|
+ rv << element if element.kind_of? Element
+ }
+ rv.each do |element|
+ @element.delete element
+ element.remove
+ end
+ return rv
+ end
+
+ # Adds an element
+ # element::
+ # if supplied, is either an Element, String, or
+ # Source (see Element.initialize). If not supplied or nil, a
+ # new, default Element will be constructed
+ # Returns:: the added Element
+ # a = Element.new 'a'
+ # a.elements.add Element.new 'b' #-> <a><b/></a>
+ # a.elements.add 'c' #-> <a><b/><c/></a>
+ def add element=nil
+ rv = nil
+ if element.nil?
+ Element.new "", self, @element.context
+ elsif not element.kind_of?(Element)
+ Element.new element, self, @element.context
+ else
+ @element << element
+ element.context = @element.context
+ element
+ end
+ end
+
+ alias :<< :add
+
+ # Iterates through all of the child Elements, optionally filtering
+ # them by a given XPath
+ # xpath::
+ # optional. If supplied, this is a String XPath, and is used to
+ # filter the children, so that only matching children are yielded. Note
+ # that XPaths are automatically filtered for Elements, so that
+ # non-Element children will not be yielded
+ # doc = Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
+ # doc.root.each {|e|p e} #-> Yields b, c, d, b, c, d elements
+ # doc.root.each('b') {|e|p e} #-> Yields b, b elements
+ # doc.root.each('child::node()') {|e|p e}
+ # #-> Yields <b/>, <c/>, <d/>, <b/>, <c/>, <d/>
+ # XPath.each(doc.root, 'child::node()', &block)
+ # #-> Yields <b/>, <c/>, <d/>, sean, <b/>, <c/>, <d/>
+ def each( xpath=nil, &block)
+ XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element }
+ end
+
+ # Returns the number of +Element+ children of the parent object.
+ # doc = Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
+ # doc.root.size #-> 6, 3 element and 3 text nodes
+ # doc.root.elements.size #-> 3
+ def size
+ count = 0
+ @element.each {|child| count+=1 if child.kind_of? Element }
+ count
+ end
+
+ # Returns an Array of Element children. An XPath may be supplied to
+ # filter the children. Only Element children are returned, even if the
+ # supplied XPath matches non-Element children.
+ # doc = Document.new '<a>sean<b/>elliott<c/></a>'
+ # doc.root.elements.to_a #-> [ <b/>, <c/> ]
+ # doc.root.elements.to_a("child::node()") #-> [ <b/>, <c/> ]
+ # XPath.match(doc.root, "child::node()") #-> [ sean, <b/>, elliott, <c/> ]
+ def to_a( xpath=nil )
+ rv = XPath.match( @element, xpath )
+ return rv.find_all{|e| e.kind_of? Element} if xpath
+ rv
+ end
+
+ private
+ # Private helper class. Removes quotes from quoted strings
+ def literalize name
+ name = name[1..-2] if name[0] == ?' or name[0] == ?" #'
+ name
+ end
+ end
+
+ ########################################################################
+ # ATTRIBUTES #
+ ########################################################################
+
+ # A class that defines the set of Attributes of an Element and provides
+ # operations for accessing elements in that set.
+ class Attributes < Hash
+ # Constructor
+ # element:: the Element of which this is an Attribute
+ def initialize element
+ @element = element
+ end
+
+ # Fetches an attribute value. If you want to get the Attribute itself,
+ # use get_attribute()
+ # name:: an XPath attribute name. Namespaces are relevant here.
+ # Returns::
+ # the String value of the matching attribute, or +nil+ if no
+ # matching attribute was found.
+ #
+ # doc = Document.new "<a foo:att='1' bar:att='2' att='3'/>"
+ # doc.root.attributes['att'] #-> '3'
+ # doc.root.attributes['bar:att'] #-> '2'
+ def [](name)
+ attr = get_attribute(name)
+ return attr.value unless attr.nil?
+ return nil
+ end
+
+ def to_a
+ values.flatten
+ end
+
+ # Returns the number of attributes the owning Element contains.
+ # doc = Document "<a x='1' y='2' foo:x='3'/>"
+ # doc.root.attributes.length #-> 3
+ def length
+ c = 0
+ each_attribute { c+=1 }
+ c
+ end
+ alias :size :length
+
+ # Itterates over the attributes of an Element. Yields actual Attribute
+ # nodes, not String values.
+ #
+ # doc = Document.new '<a x="1" y="2"/>'
+ # doc.root.attributes.each_attribute {|attr|
+ # p attr.expanded_name+" => "+attr.value
+ # }
+ def each_attribute # :yields: attribute
+ each_value do |val|
+ if val.kind_of? Attribute
+ yield val
+ else
+ val.each_value { |atr| yield atr }
+ end
+ end
+ end
+
+ # Itterates over each attribute of an Element, yielding the expanded name
+ # and value as a pair of Strings.
+ #
+ # doc = Document.new '<a x="1" y="2"/>'
+ # doc.root.attributes.each {|name, value| p name+" => "+value }
+ def each
+ each_attribute do |attr|
+ yield attr.expanded_name, attr.value
+ end
+ end
+
+ # Fetches an attribute
+ # name::
+ # the name by which to search for the attribute. Can be a
+ # <tt>prefix:name</tt> namespace name.
+ # Returns:: The first matching attribute, or nil if there was none. This
+ # value is an Attribute node, not the String value of the attribute.
+ # doc = Document.new '<a x:foo="1" foo="2" bar="3"/>'
+ # doc.root.attributes.get_attribute("foo").value #-> "2"
+ # doc.root.attributes.get_attribute("x:foo").value #-> "1"
+ def get_attribute( name )
+ attr = fetch( name, nil )
+ if attr.nil?
+ return nil if name.nil?
+ # Look for prefix
+ name =~ Namespace::NAMESPLIT
+ prefix, n = $1, $2
+ if prefix
+ attr = fetch( n, nil )
+ # check prefix
+ if attr == nil
+ elsif attr.kind_of? Attribute
+ return attr if prefix == attr.prefix
+ else
+ attr = attr[ prefix ]
+ return attr
+ end
+ end
+ element_document = @element.document
+ if element_document and element_document.doctype
+ expn = @element.expanded_name
+ expn = element_document.doctype.name if expn.size == 0
+ attr_val = element_document.doctype.attribute_of(expn, name)
+ return Attribute.new( name, attr_val ) if attr_val
+ end
+ return nil
+ end
+ if attr.kind_of? Hash
+ attr = attr[ @element.prefix ]
+ end
+ return attr
+ end
+
+ # Sets an attribute, overwriting any existing attribute value by the
+ # same name. Namespace is significant.
+ # name:: the name of the attribute
+ # value::
+ # (optional) If supplied, the value of the attribute. If
+ # nil, any existing matching attribute is deleted.
+ # Returns::
+ # Owning element
+ # doc = Document.new "<a x:foo='1' foo='3'/>"
+ # doc.root.attributes['y:foo'] = '2'
+ # doc.root.attributes['foo'] = '4'
+ # doc.root.attributes['x:foo'] = nil
+ def []=( name, value )
+ if value.nil? # Delete the named attribute
+ attr = get_attribute(name)
+ delete attr
+ return
+ end
+ value = Attribute.new(name, value) unless value.kind_of? Attribute
+ value.element = @element
+ old_attr = fetch(value.name, nil)
+ if old_attr.nil?
+ store(value.name, value)
+ elsif old_attr.kind_of? Hash
+ old_attr[value.prefix] = value
+ elsif old_attr.prefix != value.prefix
+ # Check for conflicting namespaces
+ raise ParseException.new(
+ "Namespace conflict in adding attribute \"#{value.name}\": "+
+ "Prefix \"#{old_attr.prefix}\" = "+
+ "\"#{@element.namespace(old_attr.prefix)}\" and prefix "+
+ "\"#{value.prefix}\" = \"#{@element.namespace(value.prefix)}\"") if
+ value.prefix != "xmlns" and old_attr.prefix != "xmlns" and
+ @element.namespace( old_attr.prefix ) ==
+ @element.namespace( value.prefix )
+ store value.name, { old_attr.prefix => old_attr,
+ value.prefix => value }
+ else
+ store value.name, value
+ end
+ return @element
+ end
+
+ # Returns an array of Strings containing all of the prefixes declared
+ # by this set of # attributes. The array does not include the default
+ # namespace declaration, if one exists.
+ # doc = Document.new("<a xmlns='foo' xmlns:x='bar' xmlns:y='twee' "+
+ # "z='glorp' p:k='gru'/>")
+ # prefixes = doc.root.attributes.prefixes #-> ['x', 'y']
+ def prefixes
+ ns = []
+ each_attribute do |attribute|
+ ns << attribute.name if attribute.prefix == 'xmlns'
+ end
+ if @element.document and @element.document.doctype
+ expn = @element.expanded_name
+ expn = @element.document.doctype.name if expn.size == 0
+ @element.document.doctype.attributes_of(expn).each {
+ |attribute|
+ ns << attribute.name if attribute.prefix == 'xmlns'
+ }
+ end
+ ns
+ end
+
+ def namespaces
+ namespaces = []
+ each_attribute do |attribute|
+ namespaces << attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
+ end
+ if @element.document and @element.document.doctype
+ expn = @element.expanded_name
+ expn = @element.document.doctype.name if expn.size == 0
+ @element.document.doctype.attributes_of(expn).each {
+ |attribute|
+ namespaces << attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
+ }
+ end
+ namespaces
+ end
+
+ # Removes an attribute
+ # attribute::
+ # either a String, which is the name of the attribute to remove --
+ # namespaces are significant here -- or the attribute to remove.
+ # Returns:: the owning element
+ # doc = Document.new "<a y:foo='0' x:foo='1' foo='3' z:foo='4'/>"
+ # doc.root.attributes.delete 'foo' #-> <a y:foo='0' x:foo='1' z:foo='4'/>"
+ # doc.root.attributes.delete 'x:foo' #-> <a y:foo='0' z:foo='4'/>"
+ # attr = doc.root.attributes.get_attribute('y:foo')
+ # doc.root.attributes.delete attr #-> <a z:foo='4'/>"
+ def delete( attribute )
+ name = nil
+ prefix = nil
+ if attribute.kind_of? Attribute
+ name = attribute.name
+ prefix = attribute.prefix
+ else
+ attribute =~ Namespace::NAMESPLIT
+ prefix, name = $1, $2
+ prefix = '' unless prefix
+ end
+ old = fetch(name, nil)
+ attr = nil
+ if old.kind_of? Hash # the supplied attribute is one of many
+ attr = old.delete(prefix)
+ if old.size == 1
+ repl = nil
+ old.each_value{|v| repl = v}
+ store name, repl
+ end
+ elsif old.nil?
+ return @element
+ else # the supplied attribute is a top-level one
+ attr = old
+ res = super(name)
+ end
+ @element
+ end
+
+ # Adds an attribute, overriding any existing attribute by the
+ # same name. Namespaces are significant.
+ # attribute:: An Attribute
+ def add( attribute )
+ self[attribute.name] = attribute
+ end
+
+ alias :<< :add
+
+ # Deletes all attributes matching a name. Namespaces are significant.
+ # name::
+ # A String; all attributes that match this path will be removed
+ # Returns:: an Array of the Attributes that were removed
+ def delete_all( name )
+ rv = []
+ each_attribute { |attribute|
+ rv << attribute if attribute.expanded_name == name
+ }
+ rv.each{ |attr| attr.remove }
+ return rv
+ end
+ end
+end
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb
new file mode 100644
index 0000000000..92ae1e8c21
--- /dev/null
+++ b/lib/rexml/encoding.rb
@@ -0,0 +1,56 @@
+module REXML
+ module Encoding
+ @@uconv_available = false
+
+ # Native, default format is UTF-8, so it is declared here rather than in
+ # an encodings/ definition.
+ UTF_8 = 'UTF-8'
+ UTF_16 = 'UTF-16'
+ UNILE = 'UNILE'
+
+ # ID ---> Encoding name
+ attr_reader :encoding
+ def encoding=( enc )
+ old_verbosity = $VERBOSE
+ begin
+ $VERBOSE = false
+ return if defined? @encoding and enc == @encoding
+ if enc and enc != UTF_8
+ @encoding = enc.upcase
+ begin
+ load 'rexml/encodings/ICONV.rb'
+ instance_eval @@__REXML_encoding_methods
+ Iconv::iconv( UTF_8, @encoding, "" )
+ rescue LoadError, Exception => err
+ raise "Bad encoding name #@encoding" unless @encoding =~ /^[\w-]+$/
+ @encoding.untaint
+ enc_file = File.join( "rexml", "encodings", "#@encoding.rb" )
+ begin
+ load enc_file
+ instance_eval @@__REXML_encoding_methods
+ rescue LoadError
+ puts $!.message
+ raise Exception.new( "No decoder found for encoding #@encoding. Please install iconv." )
+ end
+ end
+ else
+ enc = UTF_8
+ @encoding = enc.upcase
+ load 'rexml/encodings/UTF-8.rb'
+ instance_eval @@__REXML_encoding_methods
+ end
+ ensure
+ $VERBOSE = old_verbosity
+ end
+ end
+
+ def check_encoding str
+ # We have to recognize UTF-16, LSB UTF-16, and UTF-8
+ return UTF_16 if str[0] == 254 && str[1] == 255
+ return UNILE if str[0] == 255 && str[1] == 254
+ str =~ /^\s*<?xml\s*version=(['"]).*?\2\s*encoding=(["'])(.*?)\2/um
+ return $1.upcase if $1
+ return UTF_8
+ end
+ end
+end
diff --git a/lib/rexml/encodings/CP-1252.rb b/lib/rexml/encodings/CP-1252.rb
new file mode 100644
index 0000000000..51179f119f
--- /dev/null
+++ b/lib/rexml/encodings/CP-1252.rb
@@ -0,0 +1,98 @@
+#
+# This class was contributed by Mikko Tiihonen mikko DOT tiihonen AT hut DOT fi
+#
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods = %q~
+ # Convert from UTF-8
+ def encode content
+ array_utf8 = content.unpack('U*')
+ array_enc = []
+ array_utf8.each do |num|
+ case num
+ # shortcut first bunch basic characters
+ when 0..0xFF: array_enc << num
+ # characters added compared to iso-8859-1
+ when 0x20AC: array_enc << 0x80 # 0xe2 0x82 0xac
+ when 0x201A: array_enc << 0x82 # 0xe2 0x82 0x9a
+ when 0x0192: array_enc << 0x83 # 0xc6 0x92
+ when 0x201E: array_enc << 0x84 # 0xe2 0x82 0x9e
+ when 0x2026: array_enc << 0x85 # 0xe2 0x80 0xa6
+ when 0x2020: array_enc << 0x86 # 0xe2 0x80 0xa0
+ when 0x2021: array_enc << 0x87 # 0xe2 0x80 0xa1
+ when 0x02C6: array_enc << 0x88 # 0xcb 0x86
+ when 0x2030: array_enc << 0x89 # 0xe2 0x80 0xb0
+ when 0x0160: array_enc << 0x8A # 0xc5 0xa0
+ when 0x2039: array_enc << 0x8B # 0xe2 0x80 0xb9
+ when 0x0152: array_enc << 0x8C # 0xc5 0x92
+ when 0x017D: array_enc << 0x8E # 0xc5 0xbd
+ when 0x2018: array_enc << 0x91 # 0xe2 0x80 0x98
+ when 0x2019: array_enc << 0x92 # 0xe2 0x80 0x99
+ when 0x201C: array_enc << 0x93 # 0xe2 0x80 0x9c
+ when 0x201D: array_enc << 0x94 # 0xe2 0x80 0x9d
+ when 0x2022: array_enc << 0x95 # 0xe2 0x80 0xa2
+ when 0x2013: array_enc << 0x96 # 0xe2 0x80 0x93
+ when 0x2014: array_enc << 0x97 # 0xe2 0x80 0x94
+ when 0x02DC: array_enc << 0x98 # 0xcb 0x9c
+ when 0x2122: array_enc << 0x99 # 0xe2 0x84 0xa2
+ when 0x0161: array_enc << 0x9A # 0xc5 0xa1
+ when 0x203A: array_enc << 0x9B # 0xe2 0x80 0xba
+ when 0x0152: array_enc << 0x9C # 0xc5 0x93
+ when 0x017E: array_enc << 0x9E # 0xc5 0xbe
+ when 0x0178: array_enc << 0x9F # 0xc5 0xb8
+ else
+ # all remaining basic characters can be used directly
+ if num <= 0xFF
+ array_enc << num
+ else
+ # Numeric entity (&#nnnn;); shard by Stefan Scholl
+ array_enc.concat "&\##{num};".unpack('C*')
+ end
+ end
+ end
+ array_enc.pack('C*')
+ end
+
+ # Convert to UTF-8
+ def decode(str)
+ array_latin9 = str.unpack('C*')
+ array_enc = []
+ array_latin9.each do |num|
+ case num
+ # characters that added compared to iso-8859-1
+ when 0x80: array_enc << 0x20AC # 0xe2 0x82 0xac
+ when 0x82: array_enc << 0x201A # 0xe2 0x82 0x9a
+ when 0x83: array_enc << 0x0192 # 0xc6 0x92
+ when 0x84: array_enc << 0x201E # 0xe2 0x82 0x9e
+ when 0x85: array_enc << 0x2026 # 0xe2 0x80 0xa6
+ when 0x86: array_enc << 0x2020 # 0xe2 0x80 0xa0
+ when 0x87: array_enc << 0x2021 # 0xe2 0x80 0xa1
+ when 0x88: array_enc << 0x02C6 # 0xcb 0x86
+ when 0x89: array_enc << 0x2030 # 0xe2 0x80 0xb0
+ when 0x8A: array_enc << 0x0160 # 0xc5 0xa0
+ when 0x8B: array_enc << 0x2039 # 0xe2 0x80 0xb9
+ when 0x8C: array_enc << 0x0152 # 0xc5 0x92
+ when 0x8E: array_enc << 0x017D # 0xc5 0xbd
+ when 0x91: array_enc << 0x2018 # 0xe2 0x80 0x98
+ when 0x92: array_enc << 0x2019 # 0xe2 0x80 0x99
+ when 0x93: array_enc << 0x201C # 0xe2 0x80 0x9c
+ when 0x94: array_enc << 0x201D # 0xe2 0x80 0x9d
+ when 0x95: array_enc << 0x2022 # 0xe2 0x80 0xa2
+ when 0x96: array_enc << 0x2013 # 0xe2 0x80 0x93
+ when 0x97: array_enc << 0x2014 # 0xe2 0x80 0x94
+ when 0x98: array_enc << 0x02DC # 0xcb 0x9c
+ when 0x99: array_enc << 0x2122 # 0xe2 0x84 0xa2
+ when 0x9A: array_enc << 0x0161 # 0xc5 0xa1
+ when 0x9B: array_enc << 0x203A # 0xe2 0x80 0xba
+ when 0x9C: array_enc << 0x0152 # 0xc5 0x93
+ when 0x9E: array_enc << 0x017E # 0xc5 0xbe
+ when 0x9F: array_enc << 0x0178 # 0xc5 0xb8
+ else
+ array_enc << num
+ end
+ end
+ array_enc.pack('U*')
+ end
+ ~
+ end
+end
diff --git a/lib/rexml/encodings/EUC-JP.rb b/lib/rexml/encodings/EUC-JP.rb
new file mode 100644
index 0000000000..a1314d0856
--- /dev/null
+++ b/lib/rexml/encodings/EUC-JP.rb
@@ -0,0 +1,37 @@
+begin
+ require 'iconv'
+
+ module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def decode(str)
+ return Iconv::iconv("utf-8", "euc-jp", str)[0]
+ end
+
+ def encode content
+ return Iconv::iconv("euc-jp", "utf-8", content)[0]
+ end
+ EOL
+ end
+ end
+rescue LoadError
+ begin
+ require 'uconv'
+
+ module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def decode(str)
+ return Uconv::euctou8(str)
+ end
+
+ def encode content
+ return Uconv::u8toeuc(content)
+ end
+ EOL
+ end
+ end
+ rescue LoadError
+ raise "uconv or iconv is required for Japanese encoding support."
+ end
+end
diff --git a/lib/rexml/encodings/ICONV.rb b/lib/rexml/encodings/ICONV.rb
new file mode 100644
index 0000000000..384758d7b2
--- /dev/null
+++ b/lib/rexml/encodings/ICONV.rb
@@ -0,0 +1,16 @@
+require "iconv"
+raise LoadError unless defined? Iconv
+
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def decode( str )
+ return Iconv::iconv("utf-8", @encoding, str)[0]
+ end
+
+ def encode( content )
+ return Iconv::iconv(@encoding, "utf-8", content)[0]
+ end
+ EOL
+ end
+end
diff --git a/lib/rexml/encodings/ISO-8859-1.rb b/lib/rexml/encodings/ISO-8859-1.rb
new file mode 100644
index 0000000000..f4e4527c2d
--- /dev/null
+++ b/lib/rexml/encodings/ISO-8859-1.rb
@@ -0,0 +1,25 @@
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods = %q~
+ # Convert from UTF-8
+ def encode content
+ array_utf8 = content.unpack('U*')
+ array_enc = []
+ array_utf8.each do |num|
+ if num <= 0xFF
+ array_enc << num
+ else
+ # Numeric entity (&#nnnn;); shard by Stefan Scholl
+ array_enc.concat "&\##{num};".unpack('C*')
+ end
+ end
+ array_enc.pack('C*')
+ end
+
+ # Convert to UTF-8
+ def decode(str)
+ str.unpack('C*').pack('U*')
+ end
+ ~
+ end
+end
diff --git a/lib/rexml/encodings/ISO-8859-15.rb b/lib/rexml/encodings/ISO-8859-15.rb
new file mode 100644
index 0000000000..ce565e7dd5
--- /dev/null
+++ b/lib/rexml/encodings/ISO-8859-15.rb
@@ -0,0 +1,69 @@
+#
+# This class was contributed by Mikko Tiihonen mikko DOT tiihonen AT hut DOT fi
+#
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods = %q~
+ # Convert from UTF-8
+ def to_iso_8859_15 content
+ array_utf8 = content.unpack('U*')
+ array_enc = []
+ array_utf8.each do |num|
+ case num
+ # shortcut first bunch basic characters
+ when 0..0xA3: array_enc << num
+ # characters removed compared to iso-8859-1
+ when 0xA4: array_enc << '&#164;'
+ when 0xA6: array_enc << '&#166;'
+ when 0xA8: array_enc << '&#168;'
+ when 0xB4: array_enc << '&#180;'
+ when 0xB8: array_enc << '&#184;'
+ when 0xBC: array_enc << '&#188;'
+ when 0xBD: array_enc << '&#189;'
+ when 0xBE: array_enc << '&#190;'
+ # characters added compared to iso-8859-1
+ when 0x20AC: array_enc << 0xA4 # 0xe2 0x82 0xac
+ when 0x0160: array_enc << 0xA6 # 0xc5 0xa0
+ when 0x0161: array_enc << 0xA8 # 0xc5 0xa1
+ when 0x017D: array_enc << 0xB4 # 0xc5 0xbd
+ when 0x017E: array_enc << 0xB8 # 0xc5 0xbe
+ when 0x0152: array_enc << 0xBC # 0xc5 0x92
+ when 0x0153: array_enc << 0xBD # 0xc5 0x93
+ when 0x0178: array_enc << 0xBE # 0xc5 0xb8
+ else
+ # all remaining basic characters can be used directly
+ if num <= 0xFF
+ array_enc << num
+ else
+ # Numeric entity (&#nnnn;); shard by Stefan Scholl
+ array_enc.concat "&\##{num};".unpack('C*')
+ end
+ end
+ end
+ array_enc.pack('C*')
+ end
+
+ # Convert to UTF-8
+ def from_iso_8859_15(str)
+ array_latin9 = str.unpack('C*')
+ array_enc = []
+ array_latin9.each do |num|
+ case num
+ # characters that differ compared to iso-8859-1
+ when 0xA4: array_enc << 0x20AC
+ when 0xA6: array_enc << 0x0160
+ when 0xA8: array_enc << 0x0161
+ when 0xB4: array_enc << 0x017D
+ when 0xB8: array_enc << 0x017E
+ when 0xBC: array_enc << 0x0152
+ when 0xBD: array_enc << 0x0153
+ when 0xBE: array_enc << 0x0178
+ else
+ array_enc << num
+ end
+ end
+ array_enc.pack('U*')
+ end
+ ~
+ end
+end
diff --git a/lib/rexml/encodings/SHIFT-JIS.rb b/lib/rexml/encodings/SHIFT-JIS.rb
new file mode 100644
index 0000000000..e7dc6339ae
--- /dev/null
+++ b/lib/rexml/encodings/SHIFT-JIS.rb
@@ -0,0 +1,37 @@
+begin
+ require 'iconv'
+
+ module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def decode(str)
+ return Iconv::iconv("utf-8", "shift-jis", str)[0]
+ end
+
+ def encode content
+ return Iconv::iconv("shift-jis", "utf-8", content)[0]
+ end
+ EOL
+ end
+ end
+rescue LoadError
+ begin
+ require 'uconv'
+
+ module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def to_shift_jis content
+ Uconv::u8tosjis(content)
+ end
+
+ def from_shift_jis(str)
+ Uconv::sjistou8(str)
+ end
+ EOL
+ end
+ end
+ rescue LoadError
+ raise "uconv or iconv is required for Japanese encoding support."
+ end
+end
diff --git a/lib/rexml/encodings/SHIFT_JIS.rb b/lib/rexml/encodings/SHIFT_JIS.rb
new file mode 100644
index 0000000000..6e8f759373
--- /dev/null
+++ b/lib/rexml/encodings/SHIFT_JIS.rb
@@ -0,0 +1 @@
+require 'rexml/encodings/Shift-JIS'
diff --git a/lib/rexml/encodings/UNILE.rb b/lib/rexml/encodings/UNILE.rb
new file mode 100644
index 0000000000..95141093b5
--- /dev/null
+++ b/lib/rexml/encodings/UNILE.rb
@@ -0,0 +1,29 @@
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def encode content
+ array_utf8 = content.unpack("U*")
+ array_enc = []
+ array_utf8.each do |num|
+ if ((num>>16) > 0)
+ array_enc << ??
+ array_enc << 0
+ else
+ array_enc << (num & 0xFF)
+ array_enc << (num >> 8)
+ end
+ end
+ array_enc.pack('C*')
+ end
+
+ def decode(str)
+ array_enc=str.unpack('C*')
+ array_utf8 = []
+ 2.step(array_enc.size-1, 2){|i|
+ array_utf8 << (array_enc.at(i) + array_enc.at(i+1)*0x100)
+ }
+ array_utf8.pack('U*')
+ end
+ EOL
+ end
+end
diff --git a/lib/rexml/encodings/US-ASCII.rb b/lib/rexml/encodings/US-ASCII.rb
new file mode 100644
index 0000000000..fe8f6df303
--- /dev/null
+++ b/lib/rexml/encodings/US-ASCII.rb
@@ -0,0 +1,25 @@
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods = %q~
+ # Convert from UTF-8
+ def encode content
+ array_utf8 = content.unpack('U*')
+ array_enc = []
+ array_utf8.each do |num|
+ if num <= 0x7F
+ array_enc << num
+ else
+ # Numeric entity (&#nnnn;); shard by Stefan Scholl
+ array_enc.concat "&\##{num};".unpack('C*')
+ end
+ end
+ array_enc.pack('C*')
+ end
+
+ # Convert to UTF-8
+ def decode(str)
+ str.unpack('C*').pack('U*')
+ end
+ ~
+ end
+end
diff --git a/lib/rexml/encodings/UTF-16.rb b/lib/rexml/encodings/UTF-16.rb
new file mode 100644
index 0000000000..bd92fce18d
--- /dev/null
+++ b/lib/rexml/encodings/UTF-16.rb
@@ -0,0 +1,29 @@
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def encode content
+ array_utf8 = content.unpack("U*")
+ array_enc = []
+ array_utf8.each do |num|
+ if ((num>>16) > 0)
+ array_enc << 0
+ array_enc << ??
+ else
+ array_enc << (num >> 8)
+ array_enc << (num & 0xFF)
+ end
+ end
+ array_enc.pack('C*')
+ end
+
+ def decode(str)
+ array_enc=str.unpack('C*')
+ array_utf8 = []
+ 2.step(array_enc.size-1, 2){|i|
+ array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
+ }
+ array_utf8.pack('U*')
+ end
+ EOL
+ end
+end
diff --git a/lib/rexml/encodings/UTF-8.rb b/lib/rexml/encodings/UTF-8.rb
new file mode 100644
index 0000000000..33a7e490c4
--- /dev/null
+++ b/lib/rexml/encodings/UTF-8.rb
@@ -0,0 +1,13 @@
+module REXML
+ module Encoding
+ @@__REXML_encoding_methods =<<-EOL
+ def encode content
+ content
+ end
+
+ def decode(str)
+ str
+ end
+ EOL
+ end
+end
diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb
new file mode 100644
index 0000000000..4b88a3c553
--- /dev/null
+++ b/lib/rexml/entity.rb
@@ -0,0 +1,159 @@
+require 'rexml/child'
+require 'rexml/source'
+require 'rexml/xmltokens'
+
+module REXML
+ # God, I hate DTDs. I really do. Why this idiot standard still
+ # plagues us is beyond me.
+ class Entity < Child
+ include XMLTokens
+ PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#"
+ SYSTEMLITERAL = %Q{((?:"[^"]*")|(?:'[^']*'))}
+ PUBIDLITERAL = %Q{("[#{PUBIDCHAR}']*"|'[#{PUBIDCHAR}]*')}
+ EXTERNALID = "(?:(?:(SYSTEM)\\s+#{SYSTEMLITERAL})|(?:(PUBLIC)\\s+#{PUBIDLITERAL}\\s+#{SYSTEMLITERAL}))"
+ NDATADECL = "\\s+NDATA\\s+#{NAME}"
+ PEREFERENCE = "%#{NAME};"
+ ENTITYVALUE = %Q{((?:"(?:[^%&"]|#{PEREFERENCE}|#{REFERENCE})*")|(?:'([^%&']|#{PEREFERENCE}|#{REFERENCE})*'))}
+ PEDEF = "(?:#{ENTITYVALUE}|#{EXTERNALID})"
+ ENTITYDEF = "(?:#{ENTITYVALUE}|(?:#{EXTERNALID}(#{NDATADECL})?))"
+ PEDECL = "<!ENTITY\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>"
+ GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>"
+ ENTITYDECL = /\s*(?:#{GEDECL})|(?:#{PEDECL})/um
+
+ attr_reader :name, :external, :ref, :ndata, :pubid
+
+ # Create a new entity. Simple entities can be constructed by passing a
+ # name, value to the constructor; this creates a generic, plain entity
+ # reference. For anything more complicated, you have to pass a Source to
+ # the constructor with the entity definiton, or use the accessor methods.
+ # +WARNING+: There is no validation of entity state except when the entity
+ # is read from a stream. If you start poking around with the accessors,
+ # you can easily create a non-conformant Entity. The best thing to do is
+ # dump the stupid DTDs and use XMLSchema instead.
+ #
+ # e = Entity.new( 'amp', '&' )
+ def initialize stream, value=nil, parent=nil, reference=false
+ super(parent)
+ @ndata = @pubid = @value = @external = nil
+ if stream.kind_of? Array
+ @name = stream[1]
+ if stream[-1] == '%'
+ @reference = true
+ stream.pop
+ else
+ @reference = false
+ end
+ if stream[2] =~ /SYSTEM|PUBLIC/
+ @external = stream[2]
+ if @external == 'SYSTEM'
+ @ref = stream[3]
+ @ndata = stream[4] if stream.size == 5
+ else
+ @pubid = stream[3]
+ @ref = stream[4]
+ end
+ else
+ @value = stream[2]
+ end
+ else
+ @reference = reference
+ @external = nil
+ @name = stream
+ @value = value
+ end
+ end
+
+ # Evaluates whether the given string matchs an entity definition,
+ # returning true if so, and false otherwise.
+ def Entity::matches? string
+ (ENTITYDECL =~ string) == 0
+ end
+
+ # Evaluates to the unnormalized value of this entity; that is, replacing
+ # all entities -- both %ent; and &ent; entities. This differs from
+ # +value()+ in that +value+ only replaces %ent; entities.
+ def unnormalized
+ v = value()
+ return nil if v.nil?
+ @unnormalized = Text::unnormalize(v, parent)
+ @unnormalized
+ end
+
+ #once :unnormalized
+
+ # Returns the value of this entity unprocessed -- raw. This is the
+ # normalized value; that is, with all %ent; and &ent; entities intact
+ def normalized
+ @value
+ end
+
+ # Write out a fully formed, correct entity definition (assuming the Entity
+ # object itself is valid.)
+ def write out, indent=-1
+ out << '<!ENTITY '
+ out << '% ' if @reference
+ out << @name
+ out << ' '
+ if @external
+ out << @external << ' '
+ if @pubid
+ q = @pubid.include?('"')?"'":'"'
+ out << q << @pubid << q << ' '
+ end
+ q = @ref.include?('"')?"'":'"'
+ out << q << @ref << q
+ out << ' NDATA ' << @ndata if @ndata
+ else
+ q = @value.include?('"')?"'":'"'
+ out << q << @value << q
+ end
+ out << '>'
+ end
+
+ # Returns this entity as a string. See write().
+ def to_s
+ rv = ''
+ write rv
+ rv
+ end
+
+ PEREFERENCE_RE = /#{PEREFERENCE}/um
+ # Returns the value of this entity. At the moment, only internal entities
+ # are processed. If the value contains internal references (IE,
+ # %blah;), those are replaced with their values. IE, if the doctype
+ # contains:
+ # <!ENTITY % foo "bar">
+ # <!ENTITY yada "nanoo %foo; nanoo>
+ # then:
+ # doctype.entity('yada').value #-> "nanoo bar nanoo"
+ def value
+ if @value
+ matches = @value.scan(PEREFERENCE_RE)
+ rv = @value.clone
+ if @parent
+ matches.each do |entity_reference|
+ entity_value = @parent.entity( entity_reference[0] )
+ rv.gsub!( /%#{entity_reference};/um, entity_value )
+ end
+ end
+ return rv
+ end
+ nil
+ end
+ end
+
+ # This is a set of entity constants -- the ones defined in the XML
+ # specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+.
+ module EntityConst
+ # +>+
+ GT = Entity.new( 'gt', '>' )
+ # +<+
+ LT = Entity.new( 'lt', '<' )
+ # +&+
+ AMP = Entity.new( 'amp', '&' )
+ # +"+
+ QUOT = Entity.new( 'quot', '"' )
+ # +'+
+ APOS = Entity.new( 'apos', "'" )
+ end
+end
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
new file mode 100644
index 0000000000..9cbff99537
--- /dev/null
+++ b/lib/rexml/functions.rb
@@ -0,0 +1,372 @@
+module REXML
+ # If you add a method, keep in mind two things:
+ # (1) the first argument will always be a list of nodes from which to
+ # filter. In the case of context methods (such as position), the function
+ # should return an array with a value for each child in the array.
+ # (2) all method calls from XML will have "-" replaced with "_".
+ # Therefore, in XML, "local-name()" is identical (and actually becomes)
+ # "local_name()"
+ module Functions
+ @@node = nil
+ @@index = nil
+ @@size = nil
+ @@variables = {}
+ @@namespace_context = {}
+
+ def Functions::node=(value); @@node = value; end
+ def Functions::index=(value); @@index = value; end
+ def Functions::size=(value); @@size = value; end
+ def Functions::variables=(value); @@variables = value; end
+ def Functions::namespace_context=(value)
+ @@namespace_context = value
+ end
+ def Functions::node; @@node; end
+ def Functions::index; @@index; end
+ def Functions::size; @@size; end
+ def Functions::variables; @@variables; end
+ def Functions::namespace_context; @@namespace_context; end
+
+ def Functions::text( )
+ if @@node.node_type == :element
+ return @@node.text
+ elsif @@node.node_type == :text
+ return @@node.value
+ else
+ return false
+ end
+ end
+
+ def Functions::last( )
+ @@size
+ end
+
+ def Functions::position( )
+ @@index
+ end
+
+ def Functions::count( node_set )
+ node_set.size
+ end
+
+ # Since REXML is non-validating, this method is not implemented as it
+ # requires a DTD
+ def Functions::id( object )
+ end
+
+ # UNTESTED
+ def Functions::local_name( node_set=nil )
+ get_namespace( node_set ) do |node|
+ return node.local_name
+ end
+ end
+
+ def Functions::namespace_uri( node_set=nil )
+ get_namespace( node_set ) {|node| node.namespace}
+ end
+
+ def Functions::name( node_set=nil )
+ get_namespace( node_set ) do |node|
+ node.expanded_name
+ end
+ end
+
+ # Helper method.
+ def Functions::get_namespace( node_set = nil )
+ if node_set == nil
+ yield @@node if defined? @@node.namespace
+ else
+ if node_set.namespace
+ yield node_set
+ else
+ return unless node_set.kind_of? Enumerable
+ node_set.each { |node| yield node if defined? node.namespace }
+ end
+ end
+ end
+
+ # A node-set is converted to a string by returning the string-value of the
+ # node in the node-set that is first in document order. If the node-set is
+ # empty, an empty string is returned.
+ #
+ # A number is converted to a string as follows
+ #
+ # NaN is converted to the string NaN
+ #
+ # positive zero is converted to the string 0
+ #
+ # negative zero is converted to the string 0
+ #
+ # positive infinity is converted to the string Infinity
+ #
+ # negative infinity is converted to the string -Infinity
+ #
+ # if the number is an integer, the number is represented in decimal form
+ # as a Number with no decimal point and no leading zeros, preceded by a
+ # minus sign (-) if the number is negative
+ #
+ # otherwise, the number is represented in decimal form as a Number
+ # including a decimal point with at least one digit before the decimal
+ # point and at least one digit after the decimal point, preceded by a
+ # minus sign (-) if the number is negative; there must be no leading zeros
+ # before the decimal point apart possibly from the one required digit
+ # immediately before the decimal point; beyond the one required digit
+ # after the decimal point there must be as many, but only as many, more
+ # digits as are needed to uniquely distinguish the number from all other
+ # IEEE 754 numeric values.
+ #
+ # The boolean false value is converted to the string false. The boolean
+ # true value is converted to the string true.
+ #
+ # An object of a type other than the four basic types is converted to a
+ # string in a way that is dependent on that type.
+ def Functions::string( object=nil )
+ #object = @context unless object
+ if object.instance_of? Array
+ string( object[0] )
+ elsif defined? object.node_type
+ if object.node_type == :attribute
+ object.value
+ elsif object.node_type == :element
+ object.text
+ else
+ object.to_s
+ end
+ else
+ object.to_s
+ end
+ end
+
+ # UNTESTED
+ def Functions::concat( *objects )
+ objects.join
+ end
+
+ # Fixed by Mike Stok
+ def Functions::starts_with( string, test )
+ string(string).index(string(test)) == 0
+ end
+
+ # Fixed by Mike Stok
+ def Functions::contains( string, test )
+ string(string).include? string(test)
+ end
+
+ # Kouhei fixed this
+ def Functions::substring_before( string, test )
+ ruby_string = string(string)
+ ruby_index = ruby_string.index(string(test))
+ if ruby_index.nil?
+ ""
+ else
+ ruby_string[ 0...ruby_index ]
+ end
+ end
+
+ # Kouhei fixed this too
+ def Functions::substring_after( string, test )
+ ruby_string = string(string)
+ ruby_index = ruby_string.index(string(test))
+ if ruby_index.nil?
+ ""
+ else
+ ruby_string[ ruby_index+1..-1 ]
+ end
+ end
+
+ # Take equal portions of Mike Stok and Sean Russell; mix
+ # vigorously, and pour into a tall, chilled glass. Serves 10,000.
+ def Functions::substring( string, start, length=nil )
+ ruby_string = string(string)
+ ruby_length = if length.nil?
+ ruby_string.length.to_f
+ else
+ number(length)
+ end
+ ruby_start = number(start)
+
+ # Handle the special cases
+ return '' if (
+ ruby_length.nan? or
+ ruby_start.nan? or
+ ruby_start.infinite?
+ )
+
+ infinite_length = ruby_length.infinite? == 1
+ ruby_length = ruby_string.length if infinite_length
+
+ # Now, get the bounds. The XPath bounds are 1..length; the ruby bounds
+ # are 0..length. Therefore, we have to offset the bounds by one.
+ ruby_start = ruby_start.round - 1
+ ruby_length = ruby_length.round
+
+ if ruby_start < 0
+ ruby_length += ruby_start unless infinite_length
+ ruby_start = 0
+ end
+ return '' if ruby_length <= 0
+ ruby_string[ruby_start,ruby_length]
+ end
+
+ # UNTESTED
+ def Functions::string_length( string )
+ string(string).length
+ end
+
+ # UNTESTED
+ def Functions::normalize_space( string=nil )
+ string = string(@@node) if string.nil?
+ if string.kind_of? Array
+ string.collect{|x| string.to_s.strip.gsub(/\s+/um, ' ') if string}
+ else
+ string.to_s.strip.gsub(/\s+/um, ' ')
+ end
+ end
+
+ # This is entirely Mike Stok's beast
+ def Functions::translate( string, tr1, tr2 )
+ from = string(tr1)
+ to = string(tr2)
+
+ # the map is our translation table.
+ #
+ # if a character occurs more than once in the
+ # from string then we ignore the second &
+ # subsequent mappings
+ #
+ # if a charactcer maps to nil then we delete it
+ # in the output. This happens if the from
+ # string is longer than the to string
+ #
+ # there's nothing about - or ^ being special in
+ # http://www.w3.org/TR/xpath#function-translate
+ # so we don't build ranges or negated classes
+
+ map = Hash.new
+ 0.upto(from.length - 1) { |pos|
+ from_char = from[pos]
+ unless map.has_key? from_char
+ map[from_char] =
+ if pos < to.length
+ to[pos]
+ else
+ nil
+ end
+ end
+ }
+
+ string(string).unpack('U*').collect { |c|
+ if map.has_key? c then map[c] else c end
+ }.compact.pack('U*')
+ end
+
+ # UNTESTED
+ def Functions::boolean( object=nil )
+ if object.kind_of? String
+ if object =~ /\d+/u
+ return object.to_f != 0
+ else
+ return object.size > 0
+ end
+ elsif object.kind_of? Array
+ object = object.find{|x| x and true}
+ end
+ return object ? true : false
+ end
+
+ # UNTESTED
+ def Functions::not( object )
+ not boolean( object )
+ end
+
+ # UNTESTED
+ def Functions::true( )
+ true
+ end
+
+ # UNTESTED
+ def Functions::false( )
+ false
+ end
+
+ # UNTESTED
+ def Functions::lang( language )
+ lang = false
+ node = @@node
+ attr = nil
+ until node.nil?
+ if node.node_type == :element
+ attr = node.attributes["xml:lang"]
+ unless attr.nil?
+ lang = compare_language(string(language), attr)
+ break
+ else
+ end
+ end
+ node = node.parent
+ end
+ lang
+ end
+
+ def Functions::compare_language lang1, lang2
+ lang2.downcase.index(lang1.downcase) == 0
+ end
+
+ # a string that consists of optional whitespace followed by an optional
+ # minus sign followed by a Number followed by whitespace is converted to
+ # the IEEE 754 number that is nearest (according to the IEEE 754
+ # round-to-nearest rule) to the mathematical value represented by the
+ # string; any other string is converted to NaN
+ #
+ # boolean true is converted to 1; boolean false is converted to 0
+ #
+ # a node-set is first converted to a string as if by a call to the string
+ # function and then converted in the same way as a string argument
+ #
+ # an object of a type other than the four basic types is converted to a
+ # number in a way that is dependent on that type
+ def Functions::number( object=nil )
+ object = @@node unless object
+ if object == true
+ Float(1)
+ elsif object == false
+ Float(0)
+ elsif object.kind_of? Array
+ number(string( object ))
+ elsif object.kind_of? Float
+ object
+ else
+ str = string( object )
+ #puts "STRING OF #{object.inspect} = #{str}"
+ if str =~ /^\d+/
+ object.to_s.to_f
+ else
+ (0.0 / 0.0)
+ end
+ end
+ end
+
+ def Functions::sum( nodes )
+ end
+
+ def Functions::floor( number )
+ number(number).floor
+ end
+
+ def Functions::ceiling( number )
+ number(number).ceil
+ end
+
+ def Functions::round( number )
+ begin
+ number(number).round
+ rescue FloatDomainError
+ number(number)
+ end
+ end
+
+ def Functions::method_missing( id )
+ puts "METHOD MISSING #{id.id2name}"
+ XPath.match( @@node, id.id2name )
+ end
+ end
+end
diff --git a/lib/rexml/instruction.rb b/lib/rexml/instruction.rb
new file mode 100644
index 0000000000..0b770d4b3d
--- /dev/null
+++ b/lib/rexml/instruction.rb
@@ -0,0 +1,62 @@
+require "rexml/child"
+require "rexml/source"
+
+module REXML
+ # Represents an XML Instruction; IE, <? ... ?>
+ # TODO: Add parent arg (3rd arg) to constructor
+ class Instruction < Child
+ START = '<\?'
+ STOP = '\?>'
+
+ # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
+ # content is everything else.
+ attr_accessor :target, :content
+
+ # Constructs a new Instruction
+ # @param target can be one of a number of things. If String, then
+ # the target of this instruction is set to this. If an Instruction,
+ # then the Instruction is shallowly cloned (target and content are
+ # copied). If a Source, then the source is scanned and parsed for
+ # an Instruction declaration.
+ # @param content Must be either a String, or a Parent. Can only
+ # be a Parent if the target argument is a Source. Otherwise, this
+ # String is set as the content of this instruction.
+ def initialize(target, content=nil)
+ if target.kind_of? String
+ super()
+ @target = target
+ @content = content
+ elsif target.kind_of? Instruction
+ super(content)
+ @target = target.target
+ @content = target.content
+ end
+ @content.strip! if @content
+ end
+
+ def clone
+ Instruction.new self
+ end
+
+ def write writer, indent=-1, transitive=false, ie_hack=false
+ indent(writer, indent)
+ writer << START.sub(/\\/u, '')
+ writer << @target
+ writer << ' '
+ writer << @content
+ writer << STOP.sub(/\\/u, '')
+ end
+
+ # @return true if other is an Instruction, and the content and target
+ # of the other matches the target and content of this object.
+ def ==( other )
+ other.kind_of? Instruction and
+ other.target == @target and
+ other.content == @content
+ end
+
+ def node_type
+ :processing_instruction
+ end
+ end
+end
diff --git a/lib/rexml/light/node.rb b/lib/rexml/light/node.rb
new file mode 100644
index 0000000000..943ec5f1a0
--- /dev/null
+++ b/lib/rexml/light/node.rb
@@ -0,0 +1,196 @@
+require 'rexml/xmltokens'
+require 'rexml/light/node'
+
+# [ :element, parent, name, attributes, children* ]
+ # a = Node.new
+ # a << "B" # => <a>B</a>
+ # a.b # => <a>B<b/></a>
+ # a.b[1] # => <a>B<b/><b/><a>
+ # a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a>
+ # a.b[0].c # => <a>B<b><c/></b><b x="y"/></a>
+ # a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a>
+module REXML
+ module Light
+ # Represents a tagged XML element. Elements are characterized by
+ # having children, attributes, and names, and can themselves be
+ # children.
+ class Node
+ NAMESPLIT = /^(?:(#{XMLTokens::NCNAME_STR}):)?(#{XMLTokens::NCNAME_STR})/u
+ PARENTS = [ :element, :document, :doctype ]
+ # Create a new element.
+ def initialize node=nil
+ @node = node
+ if node.kind_of? String
+ node = [ :text, node ]
+ elsif node.nil?
+ node = [ :document, nil, nil ]
+ elsif node[0] == :start_element
+ node[0] = :element
+ elsif node[0] == :start_doctype
+ node[0] = :doctype
+ elsif node[0] == :start_document
+ node[0] = :document
+ end
+ end
+
+ def size
+ if PARENTS.include? @node[0]
+ @node[-1].size
+ else
+ 0
+ end
+ end
+
+ def each( &block )
+ size.times { |x| yield( at(x+4) ) }
+ end
+
+ def name
+ at(2)
+ end
+
+ def name=( name_str, ns=nil )
+ pfx = ''
+ pfx = "#{prefix(ns)}:" if ns
+ _old_put(2, "#{pfx}#{name_str}")
+ end
+
+ def parent=( node )
+ _old_put(1,node)
+ end
+
+ def local_name
+ namesplit
+ @name
+ end
+
+ def local_name=( name_str )
+ _old_put( 1, "#@prefix:#{name_str}" )
+ end
+
+ def prefix( namespace=nil )
+ prefix_of( self, namespace )
+ end
+
+ def namespace( prefix=prefix() )
+ namespace_of( self, prefix )
+ end
+
+ def namespace=( namespace )
+ @prefix = prefix( namespace )
+ pfx = ''
+ pfx = "#@prefix:" if @prefix.size > 0
+ _old_put(1, "#{pfx}#@name")
+ end
+
+ def []( reference, ns=nil )
+ if reference.kind_of? String
+ pfx = ''
+ pfx = "#{prefix(ns)}:" if ns
+ at(3)["#{pfx}#{reference}"]
+ elsif reference.kind_of? Range
+ _old_get( Range.new(4+reference.begin, reference.end, reference.exclude_end?) )
+ else
+ _old_get( 4+reference )
+ end
+ end
+
+ def =~( path )
+ XPath.match( self, path )
+ end
+
+ # Doesn't handle namespaces yet
+ def []=( reference, ns, value=nil )
+ if reference.kind_of? String
+ value = ns unless value
+ at( 3 )[reference] = value
+ elsif reference.kind_of? Range
+ _old_put( Range.new(3+reference.begin, reference.end, reference.exclude_end?), ns )
+ else
+ if value
+ _old_put( 4+reference, ns, value )
+ else
+ _old_put( 4+reference, ns )
+ end
+ end
+ end
+
+ # Append a child to this element, optionally under a provided namespace.
+ # The namespace argument is ignored if the element argument is an Element
+ # object. Otherwise, the element argument is a string, the namespace (if
+ # provided) is the namespace the element is created in.
+ def << element
+ if node_type() == :text
+ at(-1) << element
+ else
+ newnode = Node.new( element )
+ newnode.parent = self
+ self.push( newnode )
+ end
+ at(-1)
+ end
+
+ def node_type
+ _old_get(0)
+ end
+
+ def text=( foo )
+ replace = at(4).kind_of?(String)? 1 : 0
+ self._old_put(4,replace, normalizefoo)
+ end
+
+ def root
+ context = self
+ context = context.at(1) while context.at(1)
+ end
+
+ def has_name?( name, namespace = '' )
+ at(3) == name and namespace() == namespace
+ end
+
+ def children
+ self
+ end
+
+ def parent
+ at(1)
+ end
+
+ def to_s
+
+ end
+
+ private
+
+ def namesplit
+ return if @name.defined?
+ at(2) =~ NAMESPLIT
+ @prefix = '' || $1
+ @name = $2
+ end
+
+ def namespace_of( node, prefix=nil )
+ if not prefix
+ name = at(2)
+ name =~ NAMESPLIT
+ prefix = $1
+ end
+ to_find = 'xmlns'
+ to_find = "xmlns:#{prefix}" if not prefix.nil?
+ ns = at(3)[ to_find ]
+ ns ? ns : namespace_of( @node[0], prefix )
+ end
+
+ def prefix_of( node, namespace=nil )
+ if not namespace
+ name = node.name
+ name =~ NAMESPLIT
+ $1
+ else
+ ns = at(3).find { |k,v| v == namespace }
+ ns ? ns : prefix_of( node.parent, namespace )
+ end
+ end
+ end
+ end
+end
diff --git a/lib/rexml/namespace.rb b/lib/rexml/namespace.rb
new file mode 100644
index 0000000000..3e8790580b
--- /dev/null
+++ b/lib/rexml/namespace.rb
@@ -0,0 +1,47 @@
+require 'rexml/xmltokens'
+
+module REXML
+ # Adds named attributes to an object.
+ module Namespace
+ # The name of the object, valid if set
+ attr_reader :name, :expanded_name
+ # The expanded name of the object, valid if name is set
+ attr_accessor :prefix
+ include XMLTokens
+ NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u
+
+ # Sets the name and the expanded name
+ def name=( name )
+ @expanded_name = name
+ name =~ NAMESPLIT
+ if $1
+ @prefix = $1
+ else
+ @prefix = ""
+ @namespace = ""
+ end
+ @name = $2
+ end
+
+ # Compares names optionally WITH namespaces
+ def has_name?( other, ns=nil )
+ if ns
+ return (namespace() == ns and name() == other)
+ elsif other.include? ":"
+ return fully_expanded_name == other
+ else
+ return name == other
+ end
+ end
+
+ alias :local_name :name
+
+ # Fully expand the name, even if the prefix wasn't specified in the
+ # source file.
+ def fully_expanded_name
+ ns = prefix
+ return "#{ns}:#@name" if ns.size > 0
+ return @name
+ end
+ end
+end
diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb
new file mode 100644
index 0000000000..5f414c03ef
--- /dev/null
+++ b/lib/rexml/node.rb
@@ -0,0 +1,40 @@
+require "rexml/parseexception"
+
+module REXML
+ # Represents a node in the tree. Nodes are never encountered except as
+ # superclasses of other objects. Nodes have siblings.
+ module Node
+ # @return the next sibling (nil if unset)
+ def next_sibling_node
+ return nil if @parent.nil?
+ @parent[ @parent.index(self) + 1 ]
+ end
+
+ # @return the previous sibling (nil if unset)
+ def previous_sibling_node
+ return nil if @parent.nil?
+ ind = @parent.index(self)
+ return nil if ind == 0
+ @parent[ ind - 1 ]
+ end
+
+ def to_s indent=-1
+ rv = ""
+ write rv,indent
+ rv
+ end
+
+ def indent to, ind
+ if @parent and @parent.context and not @parent.context[:indentstyle].nil? then
+ indentstyle = @parent.context[:indentstyle]
+ else
+ indentstyle = ' '
+ end
+ to << indentstyle*ind unless ind<1
+ end
+
+ def parent?
+ false;
+ end
+ end
+end
diff --git a/lib/rexml/output.rb b/lib/rexml/output.rb
new file mode 100644
index 0000000000..be4d23d42d
--- /dev/null
+++ b/lib/rexml/output.rb
@@ -0,0 +1,24 @@
+require 'rexml/encoding'
+
+module REXML
+ class Output
+ include Encoding
+
+ attr_reader :encoding
+
+ def initialize real_IO, encd="iso-8859-1"
+ @output = real_IO
+ self.encoding = encd
+
+ @to_utf = encd == UTF_8 ? false : true
+ end
+
+ def <<( content )
+ @output << (@to_utf ? self.encode(content) : content)
+ end
+
+ def to_s
+ "Output[#{encoding}]"
+ end
+ end
+end
diff --git a/lib/rexml/parent.rb b/lib/rexml/parent.rb
new file mode 100644
index 0000000000..5c1ed97324
--- /dev/null
+++ b/lib/rexml/parent.rb
@@ -0,0 +1,165 @@
+require "rexml/child"
+
+module REXML
+ # A parent has children, and has methods for accessing them. The Parent
+ # class is never encountered except as the superclass for some other
+ # object.
+ class Parent < Child
+ include Enumerable
+
+ # Constructor
+ # @param parent if supplied, will be set as the parent of this object
+ def initialize parent=nil
+ super(parent)
+ @children = []
+ end
+
+ def add( object )
+ #puts "PARENT GOTS #{size} CHILDREN"
+ object.parent = self
+ @children << object
+ #puts "PARENT NOW GOTS #{size} CHILDREN"
+ object
+ end
+
+ alias :push :add
+ alias :<< :push
+
+ def unshift( object )
+ object.parent = self
+ @children.unshift object
+ end
+
+ def delete( object )
+ return unless @children.include? object
+ @children.delete object
+ object.parent = nil
+ end
+
+ def each(&block)
+ @children.each(&block)
+ end
+
+ def delete_if( &block )
+ @children.delete_if(&block)
+ end
+
+ def delete_at( index )
+ @children.delete_at index
+ end
+
+ def each_index( &block )
+ @children.each_index(&block)
+ end
+
+ # Fetches a child at a given index
+ # @param index the Integer index of the child to fetch
+ def []( index )
+ @children[index]
+ end
+
+ alias :each_child :each
+
+
+
+ # Set an index entry. See Array.[]=
+ # @param index the index of the element to set
+ # @param opt either the object to set, or an Integer length
+ # @param child if opt is an Integer, this is the child to set
+ # @return the parent (self)
+ def []=( *args )
+ args[-1].parent = self
+ @children[*args[0..-2]] = args[-1]
+ end
+
+ # Inserts an child before another child
+ # @param child1 this is either an xpath or an Element. If an Element,
+ # child2 will be inserted before child1 in the child list of the parent.
+ # If an xpath, child2 will be inserted before the first child to match
+ # the xpath.
+ # @param child2 the child to insert
+ # @return the parent (self)
+ def insert_before( child1, child2 )
+ if child1.kind_of? String
+ child1 = XPath.first( self, child1 )
+ child1.parent.insert_before child1, child2
+ else
+ ind = index(child1)
+ child2.parent.delete(child2) if child2.parent
+ @children[ind,0] = child2
+ child2.parent = self
+ end
+ self
+ end
+
+ # Inserts an child after another child
+ # @param child1 this is either an xpath or an Element. If an Element,
+ # child2 will be inserted after child1 in the child list of the parent.
+ # If an xpath, child2 will be inserted after the first child to match
+ # the xpath.
+ # @param child2 the child to insert
+ # @return the parent (self)
+ def insert_after( child1, child2 )
+ if child1.kind_of? String
+ child1 = XPath.first( self, child1 )
+ child1.parent.insert_after child1, child2
+ else
+ ind = index(child1)+1
+ child2.parent.delete(child2) if child2.parent
+ @children[ind,0] = child2
+ child2.parent = self
+ end
+ self
+ end
+
+ def to_a
+ @children.dup
+ end
+
+ # Fetches the index of a given child
+ # @param child the child to get the index of
+ # @return the index of the child, or nil if the object is not a child
+ # of this parent.
+ def index( child )
+ count = -1
+ @children.find { |i| count += 1 ; i.hash == child.hash }
+ count
+ end
+
+ # @return the number of children of this parent
+ def size
+ @children.size
+ end
+
+ # Replaces one child with another, making sure the nodelist is correct
+ # @param to_replace the child to replace (must be a Child)
+ # @param replacement the child to insert into the nodelist (must be a
+ # Child)
+ def replace_child( to_replace, replacement )
+ ind = @children.index( to_replace )
+ to_replace.parent = nil
+ @children[ind,0] = replacement
+ replacement.parent = self
+ end
+
+ # Deeply clones this object. This creates a complete duplicate of this
+ # Parent, including all descendants.
+ def deep_clone
+ cl = clone()
+ each do |child|
+ if child.kind_of? Parent
+ cl << child.deep_clone
+ else
+ cl << child.clone
+ end
+ end
+ cl
+ end
+
+ alias :children :to_a
+
+ def parent?
+ true
+ end
+ end
+end
diff --git a/lib/rexml/parseexception.rb b/lib/rexml/parseexception.rb
new file mode 100644
index 0000000000..feb7a7e638
--- /dev/null
+++ b/lib/rexml/parseexception.rb
@@ -0,0 +1,51 @@
+module REXML
+ class ParseException < RuntimeError
+ attr_accessor :source, :parser, :continued_exception
+
+ def initialize( message, source=nil, parser=nil, exception=nil )
+ super(message)
+ @source = source
+ @parser = parser
+ @continued_exception = exception
+ end
+
+ def to_s
+ # Quote the original exception, if there was one
+ if @continued_exception
+ err = @continued_exception.inspect
+ err << "\n"
+ err << @continued_exception.backtrace.join("\n")
+ err << "\n...\n"
+ else
+ err = ""
+ end
+
+ # Get the stack trace and error message
+ err << super
+
+ # Add contextual information
+ if @source
+ err << "\nLine: #{line}\n"
+ err << "Position: #{position}\n"
+ err << "Last 80 unconsumed characters:\n"
+ err << @source.buffer[0..80].gsub(/\n/, ' ')
+ end
+
+ err
+ end
+
+ def position
+ @source.current_line[0] if @source and defined? @source.current_line and
+ @source.current_line
+ end
+
+ def line
+ @source.current_line[2] if @source and defined? @source.current_line and
+ @source.current_line
+ end
+
+ def context
+ @source.current_line
+ end
+ end
+end
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
new file mode 100644
index 0000000000..e95cba8904
--- /dev/null
+++ b/lib/rexml/parsers/baseparser.rb
@@ -0,0 +1,451 @@
+require 'rexml/parseexception'
+require 'rexml/source'
+
+module REXML
+ module Parsers
+ # = Using the Pull Parser
+ # <em>This API is experimental, and subject to change.</em>
+ # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
+ # while parser.has_next?
+ # res = parser.next
+ # puts res[1]['att'] if res.start_tag? and res[0] == 'b'
+ # end
+ # See the PullEvent class for information on the content of the results.
+ # The data is identical to the arguments passed for the various events to
+ # the StreamListener API.
+ #
+ # Notice that:
+ # parser = PullParser.new( "<a>BAD DOCUMENT" )
+ # while parser.has_next?
+ # res = parser.next
+ # raise res[1] if res.error?
+ # end
+ #
+ # Nat Price gave me some good ideas for the API.
+ class BaseParser
+ NCNAME_STR= '[\w:][\-\w\d.]*'
+ NAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}"
+
+ NAMECHAR = '[\-\w\d\.:]'
+ NAME = "([\\w:]#{NAMECHAR}*)"
+ NMTOKEN = "(?:#{NAMECHAR})+"
+ NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*"
+ REFERENCE = "(?:&#{NAME};|&#\\d+;|&#x[0-9a-fA-F]+;)"
+ REFERENCE_RE = /#{REFERENCE}/
+
+ DOCTYPE_START = /\A\s*<!DOCTYPE\s/um
+ DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/um
+ ATTRIBUTE_PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\2/um
+ COMMENT_START = /\A<!--/u
+ COMMENT_PATTERN = /<!--(.*?)-->/um
+ CDATA_START = /\A<!\[CDATA\[/u
+ CDATA_END = /^\s*\]\s*>/um
+ CDATA_PATTERN = /<!\[CDATA\[(.*?)\]\]>/um
+ XMLDECL_START = /\A<\?xml\s/u;
+ XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/um
+ INSTRUCTION_START = /\A<\?/u
+ INSTRUCTION_PATTERN = /<\?(.*?)(\s+.*?)?\?>/um
+ TAG_MATCH = /^<((?>#{NAME_STR}))\s*((?>\s+#{NAME_STR}\s*=\s*(["']).*?\3)*)\s*(\/)?>/um
+ CLOSE_MATCH = /^\s*<\/(#{NAME_STR})\s*>/um
+
+ VERSION = /\bversion\s*=\s*["'](.*?)['"]/um
+ ENCODING = /\bencoding=["'](.*?)['"]/um
+ STANDALONE = /\bstandalone=["'](.*?)['"]/um
+
+ ENTITY_START = /^\s*<!ENTITY/
+ IDENTITY = /^([!\*\w\-]+)(\s+#{NCNAME_STR})?(\s+["'].*?['"])?(\s+['"].*?["'])?/u
+ ELEMENTDECL_START = /^\s*<!ELEMENT/um
+ ELEMENTDECL_PATTERN = /^\s*(<!ELEMENT.*?)>/um
+ SYSTEMENTITY = /^\s*(%.*?;)\s*$/um
+ ENUMERATION = "\\(\\s*#{NMTOKEN}(?:\\s*\\|\\s*#{NMTOKEN})*\\s*\\)"
+ NOTATIONTYPE = "NOTATION\\s+\\(\\s*#{NAME}(?:\\s*\\|\\s*#{NAME})*\\s*\\)"
+ ENUMERATEDTYPE = "(?:(?:#{NOTATIONTYPE})|(?:#{ENUMERATION}))"
+ ATTTYPE = "(CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS|#{ENUMERATEDTYPE})"
+ ATTVALUE = "(?:\"((?:[^<&\"]|#{REFERENCE})*)\")|(?:'((?:[^<&']|#{REFERENCE})*)')"
+ DEFAULTDECL = "(#REQUIRED|#IMPLIED|(?:(#FIXED\\s+)?#{ATTVALUE}))"
+ ATTDEF = "\\s+#{NAME}\\s+#{ATTTYPE}\\s+#{DEFAULTDECL}"
+ ATTDEF_RE = /#{ATTDEF}/
+ ATTLISTDECL_START = /^\s*<!ATTLIST/um
+ ATTLISTDECL_PATTERN = /^\s*<!ATTLIST\s+#{NAME}(?:#{ATTDEF})*\s*>/um
+ NOTATIONDECL_START = /^\s*<!NOTATION/um
+ PUBLIC = /^\s*<!NOTATION\s+(\w[\-\w]*)\s+(PUBLIC)\s+((["']).*?\4)\s*>/um
+ SYSTEM = /^\s*<!NOTATION\s+(\w[\-\w]*)\s+(SYSTEM)\s+((["']).*?\4)\s*>/um
+
+ TEXT_PATTERN = /\A([^<]*)/um
+
+ # Entity constants
+ PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#"
+ SYSTEMLITERAL = %Q{((?:"[^"]*")|(?:'[^']*'))}
+ PUBIDLITERAL = %Q{("[#{PUBIDCHAR}']*"|'[#{PUBIDCHAR}]*')}
+ EXTERNALID = "(?:(?:(SYSTEM)\\s+#{SYSTEMLITERAL})|(?:(PUBLIC)\\s+#{PUBIDLITERAL}\\s+#{SYSTEMLITERAL}))"
+ NDATADECL = "\\s+NDATA\\s+#{NAME}"
+ PEREFERENCE = "%#{NAME};"
+ ENTITYVALUE = %Q{((?:"(?:[^%&"]|#{PEREFERENCE}|#{REFERENCE})*")|(?:'([^%&']|#{PEREFERENCE}|#{REFERENCE})*'))}
+ PEDEF = "(?:#{ENTITYVALUE}|#{EXTERNALID})"
+ ENTITYDEF = "(?:#{ENTITYVALUE}|(?:#{EXTERNALID}(#{NDATADECL})?))"
+ PEDECL = "<!ENTITY\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>"
+ GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>"
+ ENTITYDECL = /\s*(?:#{GEDECL})|(?:#{PEDECL})/um
+
+ EREFERENCE = /&(?!#{NAME};)/
+
+ DEFAULT_ENTITIES = {
+ 'gt' => [/&gt;/, '&gt;', '>', />/],
+ 'lt' => [/&lt;/, '&lt;', '<', /</],
+ 'quot' => [/&quot;/, '&quot;', '"', /"/],
+ "apos" => [/&apos;/, "&apos;", "'", /'/]
+ }
+
+ def initialize( source )
+ self.stream = source
+ end
+
+ def add_listener( listener )
+ if !defined?(@listeners) or !@listeners
+ @listeners = []
+ instance_eval <<-EOL
+ alias :_old_pull :pull
+ def pull
+ event = _old_pull
+ @listeners.each do |listener|
+ listener.receive event
+ end
+ event
+ end
+ EOL
+ end
+ @listeners << listener
+ end
+
+ attr_reader :source
+
+ def stream=( source )
+ if source.kind_of? String
+ @source = Source.new(source)
+ elsif source.kind_of? IO
+ @source = IOSource.new(source)
+ elsif source.kind_of? Source
+ @source = source
+ elsif defined? StringIO and source.kind_of? StringIO
+ @source = IOSource.new(source)
+ else
+ raise "#{source.class} is not a valid input stream. It must be \n"+
+ "either a String, IO, StringIO or Source."
+ end
+ @closed = nil
+ @document_status = nil
+ @tags = []
+ @stack = []
+ @entities = []
+ end
+
+ # Returns true if there are no more events
+ def empty?
+ #puts "@source.empty? = #{@source.empty?}"
+ #puts "@stack.empty? = #{@stack.empty?}"
+ return (@source.empty? and @stack.empty?)
+ end
+
+ # Returns true if there are more events. Synonymous with !empty?
+ def has_next?
+ return !(@source.empty? and @stack.empty?)
+ end
+
+ # Push an event back on the head of the stream. This method
+ # has (theoretically) infinite depth.
+ def unshift token
+ @stack.unshift(token)
+ end
+
+ # Peek at the +depth+ event in the stack. The first element on the stack
+ # is at depth 0. If +depth+ is -1, will parse to the end of the input
+ # stream and return the last event, which is always :end_document.
+ # Be aware that this causes the stream to be parsed up to the +depth+
+ # event, so you can effectively pre-parse the entire document (pull the
+ # entire thing into memory) using this method.
+ def peek depth=0
+ raise %Q[Illegal argument "#{depth}"] if depth < -1
+ temp = []
+ if depth == -1
+ temp.push(pull()) until empty?
+ else
+ while @stack.size+temp.size < depth+1
+ temp.push(pull())
+ end
+ end
+ @stack += temp if temp.size > 0
+ @stack[depth]
+ end
+
+ # Returns the next event. This is a +PullEvent+ object.
+ def pull
+ if @closed
+ x, @closed = @closed, nil
+ return [ :end_element, x ]
+ end
+ return [ :end_document ] if empty?
+ return @stack.shift if @stack.size > 0
+ @source.read if @source.buffer.size<2
+ if @document_status == nil
+ @source.consume( /^\s*/um )
+ word = @source.match( /(<[^>]*)>/um )
+ word = word[1] unless word.nil?
+ case word
+ when COMMENT_START
+ return [ :comment, @source.match( COMMENT_PATTERN, true )[1] ]
+ when XMLDECL_START
+ results = @source.match( XMLDECL_PATTERN, true )[1]
+ version = VERSION.match( results )
+ version = version[1] unless version.nil?
+ encoding = ENCODING.match(results)
+ encoding = encoding[1] unless encoding.nil?
+ @source.encoding = encoding
+ standalone = STANDALONE.match(results)
+ standalone = standalone[1] unless standalone.nil?
+ return [ :xmldecl, version, encoding, standalone]
+ when INSTRUCTION_START
+ return [ :processing_instruction, *@source.match(INSTRUCTION_PATTERN, true)[1,2] ]
+ when DOCTYPE_START
+ md = @source.match( DOCTYPE_PATTERN, true )
+ identity = md[1]
+ close = md[2]
+ identity =~ IDENTITY
+ name = $1
+ raise REXML::ParseException("DOCTYPE is missing a name") if name.nil?
+ pub_sys = $2.nil? ? nil : $2.strip
+ long_name = $3.nil? ? nil : $3.strip
+ uri = $4.nil? ? nil : $4.strip
+ args = [ :start_doctype, name, pub_sys, long_name, uri ]
+ if close == ">"
+ @document_status = :after_doctype
+ @source.read if @source.buffer.size<2
+ md = @source.match(/^\s*/um, true)
+ @stack << [ :end_doctype ]
+ else
+ @document_status = :in_doctype
+ end
+ return args
+ else
+ @document_status = :after_doctype
+ @source.read if @source.buffer.size<2
+ md = @source.match(/\s*/um, true)
+ end
+ end
+ if @document_status == :in_doctype
+ md = @source.match(/\s*(.*?>)/um)
+ case md[1]
+ when SYSTEMENTITY
+ match = @source.match( SYSTEMENTITY, true )[1]
+ return [ :externalentity, match ]
+
+ when ELEMENTDECL_START
+ return [ :elementdecl, @source.match( ELEMENTDECL_PATTERN, true )[1] ]
+
+ when ENTITY_START
+ match = @source.match( ENTITYDECL, true ).to_a.compact
+ match[0] = :entitydecl
+ ref = false
+ if match[1] == '%'
+ ref = true
+ match.delete_at 1
+ end
+ # Now we have to sort out what kind of entity reference this is
+ if match[2] == 'SYSTEM'
+ # External reference
+ match[3] = match[3][1..-2] # PUBID
+ match.delete_at(4) if match.size > 4 # Chop out NDATA decl
+ # match is [ :entity, name, SYSTEM, pubid(, ndata)? ]
+ elsif match[2] == 'PUBLIC'
+ # External reference
+ match[3] = match[3][1..-2] # PUBID
+ match[4] = match[4][1..-2] # HREF
+ # match is [ :entity, name, PUBLIC, pubid, href ]
+ else
+ match[2] = match[2][1..-2]
+ match.pop if match.size == 4
+ # match is [ :entity, name, value ]
+ end
+ match << '%' if ref
+ return match
+ when ATTLISTDECL_START
+ md = @source.match( ATTLISTDECL_PATTERN, true )
+ raise REXML::ParseException.new( "Bad ATTLIST declaration!", @source ) if md.nil?
+ element = md[1]
+ contents = md[0]
+
+ pairs = {}
+ values = md[0].scan( ATTDEF_RE )
+ values.each do |attdef|
+ unless attdef[3] == "#IMPLIED"
+ attdef.compact!
+ val = attdef[3]
+ val = attdef[4] if val == "#FIXED "
+ pairs[attdef[0]] = val
+ end
+ end
+ return [ :attlistdecl, element, pairs, contents ]
+ when NOTATIONDECL_START
+ md = nil
+ if @source.match( PUBLIC )
+ md = @source.match( PUBLIC, true )
+ elsif @source.match( SYSTEM )
+ md = @source.match( SYSTEM, true )
+ else
+ raise REXML::ParseException.new( "error parsing notation: no matching pattern", @source )
+ end
+ return [ :notationdecl, md[1], md[2], md[3] ]
+ when CDATA_END
+ @document_status = :after_doctype
+ @source.match( CDATA_END, true )
+ return [ :end_doctype ]
+ end
+ end
+ begin
+ if @source.buffer[0] == ?<
+ if @source.buffer[1] == ?/
+ last_tag = @tags.pop
+ #md = @source.match_to_consume( '>', CLOSE_MATCH)
+ md = @source.match( CLOSE_MATCH, true )
+ raise REXML::ParseException.new( "Missing end tag for "+
+ "'#{last_tag}' (got \"#{md[1]}\")",
+ @source) unless last_tag == md[1]
+ return [ :end_element, last_tag ]
+ elsif @source.buffer[1] == ?!
+ md = @source.match(/\A(\s*[^>]*>)/um)
+ #puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}"
+ raise REXML::ParseException.new("Malformed node", @source) unless md
+ if md[0][2] == ?-
+ md = @source.match( COMMENT_PATTERN, true )
+ return [ :comment, md[1] ] if md
+ else
+ md = @source.match( CDATA_PATTERN, true )
+ return [ :cdata, md[1] ] if md
+ end
+ raise REXML::ParseException.new( "Declarations can only occur "+
+ "in the doctype declaration.", @source)
+ elsif @source.buffer[1] == ??
+ md = @source.match( INSTRUCTION_PATTERN, true )
+ return [ :processing_instruction, md[1], md[2] ] if md
+ raise REXML::ParseException.new( "Bad instruction declaration",
+ @source)
+ else
+ # Get the next tag
+ md = @source.match(TAG_MATCH, true)
+ raise REXML::ParseException.new("malformed XML: missing tag start", @source) unless md
+ attrs = []
+ if md[2].size > 0
+ attrs = md[2].scan( ATTRIBUTE_PATTERN )
+ raise REXML::ParseException.new( "error parsing attributes: [#{attrs.join ', '}], excess = \"#$'\"", @source) if $' and $'.strip.size > 0
+ end
+
+ if md[4]
+ @closed = md[1]
+ else
+ @tags.push( md[1] )
+ end
+ attributes = {}
+ attrs.each { |a,b,c| attributes[a] = c }
+ return [ :start_element, md[1], attributes ]
+ end
+ else
+ md = @source.match( TEXT_PATTERN, true )
+ if md[0].length == 0
+ #puts "EMPTY = #{empty?}"
+ #puts "BUFFER = \"#{@source.buffer}\""
+ @source.match( /(\s+)/, true )
+ end
+ #return [ :text, "" ] if md[0].length == 0
+ # unnormalized = Text::unnormalize( md[1], self )
+ # return PullEvent.new( :text, md[1], unnormalized )
+ return [ :text, md[1] ]
+ end
+ rescue REXML::ParseException
+ raise
+ rescue Exception, NameError => error
+ raise REXML::ParseException.new( "Exception parsing",
+ @source, self, (error ? error : $!) )
+ end
+ return [ :dummy ]
+ end
+
+ def entity( reference, entities )
+ value = nil
+ value = entities[ reference ] if entities
+ if not value
+ value = DEFAULT_ENTITIES[ reference ]
+ value = value[2] if value
+ end
+ unnormalize( value, entities ) if value
+ end
+
+ # Escapes all possible entities
+ def normalize( input, entities=nil, entity_filter=nil )
+ copy = input.clone
+ # Doing it like this rather than in a loop improves the speed
+ copy.gsub!( EREFERENCE, '&amp;' )
+ entities.each do |key, value|
+ copy.gsub!( value, "&#{key};" ) unless entity_filter and
+ entity_filter.include?(entity)
+ end if entities
+ copy.gsub!( EREFERENCE, '&amp;' )
+ DEFAULT_ENTITIES.each do |key, value|
+ copy.gsub!( value[3], value[1] )
+ end
+ copy
+ end
+
+ # Unescapes all possible entities
+ def unnormalize( string, entities=nil, filter=nil )
+ rv = string.clone
+ rv.gsub!( /\r\n?/, "\n" )
+ matches = rv.scan( REFERENCE_RE )
+ return rv if matches.size == 0
+ rv.gsub!( /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {|m|
+ m=$1
+ m = "0#{m}" if m[0] == ?x
+ [Integer(m)].pack('U*')
+ }
+ matches.collect!{|x|x[0]}.compact!
+ if matches.size > 0
+ matches.each do |entity_reference|
+ unless filter and filter.include?(entity_reference)
+ entity_value = entity( entity_reference, entities )
+ if entity_value
+ re = /&#{entity_reference};/
+ rv.gsub!( re, entity_value )
+ end
+ end
+ end
+ matches.each do |entity_reference|
+ unless filter and filter.include?(entity_reference)
+ er = DEFAULT_ENTITIES[entity_reference]
+ rv.gsub!( er[0], er[2] ) if er
+ end
+ end
+ rv.gsub!( /&amp;/, '&' )
+ end
+ rv
+ end
+ end
+ end
+end
+
+=begin
+ case event[0]
+ when :start_element
+ when :text
+ when :end_element
+ when :processing_instruction
+ when :cdata
+ when :comment
+ when :xmldecl
+ when :start_doctype
+ when :end_doctype
+ when :externalentity
+ when :elementdecl
+ when :entity
+ when :attlistdecl
+ when :notationdecl
+ when :end_doctype
+ end
+=end
diff --git a/lib/rexml/parsers/lightparser.rb b/lib/rexml/parsers/lightparser.rb
new file mode 100644
index 0000000000..0f35034993
--- /dev/null
+++ b/lib/rexml/parsers/lightparser.rb
@@ -0,0 +1,60 @@
+require 'rexml/parsers/streamparser'
+require 'rexml/parsers/baseparser'
+require 'rexml/light/node'
+
+module REXML
+ module Parsers
+ class LightParser
+ def initialize stream
+ @stream = stream
+ @parser = REXML::Parsers::BaseParser.new( stream )
+ end
+
+ def add_listener( listener )
+ @parser.add_listener( listener )
+ end
+
+ def rewind
+ @stream.rewind
+ @parser.stream = @stream
+ end
+
+ def parse
+ root = context = [ :document ]
+ while true
+ event = @parser.pull
+ case event[0]
+ when :end_document
+ break
+ when :end_doctype
+ context = context[1]
+ when :start_element, :start_doctype
+ new_node = event
+ context << new_node
+ new_node[1,0] = [context]
+ context = new_node
+ when :end_element, :end_doctype
+ context = context[1]
+ else
+ new_node = event
+ context << new_node
+ new_node[1,0] = [context]
+ end
+ end
+ root
+ end
+ end
+
+ # An element is an array. The array contains:
+ # 0 The parent element
+ # 1 The tag name
+ # 2 A hash of attributes
+ # 3..-1 The child elements
+ # An element is an array of size > 3
+ # Text is a String
+ # PIs are [ :processing_instruction, target, data ]
+ # Comments are [ :comment, data ]
+ # DocTypes are DocType structs
+ # The root is an array with XMLDecls, Text, DocType, Array, Text
+ end
+end
diff --git a/lib/rexml/parsers/pullparser.rb b/lib/rexml/parsers/pullparser.rb
new file mode 100644
index 0000000000..fe4d41c959
--- /dev/null
+++ b/lib/rexml/parsers/pullparser.rb
@@ -0,0 +1,149 @@
+require 'rexml/parseexception'
+require 'rexml/parsers/baseparser'
+require 'rexml/xmltokens'
+
+module REXML
+ module Parsers
+ # = Using the Pull Parser
+ # <em>This API is experimental, and subject to change.</em>
+ # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
+ # while parser.has_next?
+ # res = parser.next
+ # puts res[1]['att'] if res.start_tag? and res[0] == 'b'
+ # end
+ # See the PullEvent class for information on the content of the results.
+ # The data is identical to the arguments passed for the various events to
+ # the StreamListener API.
+ #
+ # Notice that:
+ # parser = PullParser.new( "<a>BAD DOCUMENT" )
+ # while parser.has_next?
+ # res = parser.next
+ # raise res[1] if res.error?
+ # end
+ #
+ # Nat Price gave me some good ideas for the API.
+ class PullParser < BaseParser
+ include XMLTokens
+
+ def initialize stream
+ super
+ @entities = {}
+ @listeners = nil
+ end
+
+ def add_listener( listener )
+ @listeners = [] unless @listeners
+ @listeners << listener
+ end
+
+ def each
+ while has_next?
+ yield self.pull
+ end
+ end
+
+ def peek depth=0
+ PullEvent.new(super)
+ end
+
+ def pull
+ event = super
+ case event[0]
+ when :entitydecl
+ @entities[ event[1] ] =
+ event[2] unless event[2] =~ /PUBLIC|SYSTEM/
+ when :text
+ unnormalized = unnormalize( event[1], @entities )
+ event << unnormalized
+ end
+ PullEvent.new( event )
+ end
+ end
+
+ # A parsing event. The contents of the event are accessed as an +Array?,
+ # and the type is given either by the ...? methods, or by accessing the
+ # +type+ accessor. The contents of this object vary from event to event,
+ # but are identical to the arguments passed to +StreamListener+s for each
+ # event.
+ class PullEvent
+ # The type of this event. Will be one of :tag_start, :tag_end, :text,
+ # :processing_instruction, :comment, :doctype, :attlistdecl, :entitydecl,
+ # :notationdecl, :entity, :cdata, :xmldecl, or :error.
+ def initialize(arg)
+ @contents = arg
+ end
+ def []( index )
+ @contents[index+1]
+ end
+ def event_type
+ @contents[0]
+ end
+ # Content: [ String tag_name, Hash attributes ]
+ def start_element?
+ @contents[0] == :start_element
+ end
+ # Content: [ String tag_name ]
+ def end_element?
+ @contents[0] == :end_element
+ end
+ # Content: [ String raw_text, String unnormalized_text ]
+ def text?
+ @contents[0] == :text
+ end
+ # Content: [ String text ]
+ def instruction?
+ @contents[0] == :processing_instruction
+ end
+ # Content: [ String text ]
+ def comment?
+ @contents[0] == :comment
+ end
+ # Content: [ String name, String pub_sys, String long_name, String uri ]
+ def doctype?
+ @contents[0] == :start_doctype
+ end
+ # Content: [ String text ]
+ def attlistdecl?
+ @contents[0] == :attlistdecl
+ end
+ # Content: [ String text ]
+ def elementdecl?
+ @contents[0] == :elementdecl
+ end
+ # Due to the wonders of DTDs, an entity declaration can be just about
+ # anything. There's no way to normalize it; you'll have to interpret the
+ # content yourself. However, the following is true:
+ #
+ # * If the entity declaration is an internal entity:
+ # [ String name, String value ]
+ # Content: [ String text ]
+ def entitydecl?
+ @contents[0] == :entitydecl
+ end
+ # Content: [ String text ]
+ def notationdecl?
+ @contents[0] == :notationdecl
+ end
+ # Content: [ String text ]
+ def entity?
+ @contents[0] == :entity
+ end
+ # Content: [ String text ]
+ def cdata?
+ @contents[0] == :cdata
+ end
+ # Content: [ String version, String encoding, String standalone ]
+ def xmldecl?
+ @contents[0] == :xmldecl
+ end
+ def error?
+ @contents[0] == :error
+ end
+
+ def inspect
+ @contents[0].to_s + ": " + @contents[1..-1].inspect
+ end
+ end
+ end
+end
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
new file mode 100644
index 0000000000..96440d17bf
--- /dev/null
+++ b/lib/rexml/parsers/sax2parser.rb
@@ -0,0 +1,213 @@
+require 'rexml/parsers/baseparser'
+require 'rexml/parseexception'
+require 'rexml/namespace'
+
+module REXML
+ module Parsers
+ class SAX2Parser
+ def initialize source
+ @parser = BaseParser.new(source)
+ @listeners = []
+ @procs = []
+ @namespace_stack = []
+ @has_listeners = false
+ @tag_stack = []
+ end
+
+ def add_listener( listener )
+ @parser.add_listener( listener )
+ end
+
+ # Listen arguments:
+ #
+ # Symbol, Array, Block
+ # Listen to Symbol events on Array elements
+ # Symbol, Block
+ # Listen to Symbol events
+ # Array, Listener
+ # Listen to all events on Array elements
+ # Array, Block
+ # Listen to :start_element events on Array elements
+ # Listener
+ # Listen to All events
+ #
+ # Symbol can be one of: :start_element, :end_element,
+ # :start_prefix_mapping, :end_prefix_mapping, :characters,
+ # :processing_instruction, :doctype, :attlistdecl, :elementdecl,
+ # :entitydecl, :notationdecl, :cdata, :xmldecl, :comment
+ #
+ # Array contains regular expressions or strings which will be matched
+ # against fully qualified element names.
+ #
+ # Listener must implement the methods in SAX2Listener
+ #
+ # Block will be passed the same arguments as a SAX2Listener method would
+ # be, where the method name is the same as the matched Symbol.
+ # See the SAX2Listener for more information.
+ def listen( *args, &blok )
+ if args[0].kind_of? Symbol
+ if args.size == 2
+ args[1].each { |match| @procs << [args[0], match, blok] }
+ else
+ add( [args[0], nil, blok] )
+ end
+ elsif args[0].kind_of? Array
+ if args.size == 2
+ args[0].each { |match| add( [nil, match, args[1]] ) }
+ else
+ args[0].each { |match| add( [ :start_element, match, blok ] ) }
+ end
+ else
+ add([nil, nil, args[0]])
+ end
+ end
+
+ def deafen( listener=nil, &blok )
+ if listener
+ @listeners.delete_if {|item| item[-1] == listener }
+ @has_listeners = false if @listeners.size == 0
+ else
+ @procs.delete_if {|item| item[-1] == blok }
+ end
+ end
+
+ def parse
+ @procs.each { |sym,match,block| block.call if sym == :start_document }
+ @listeners.each { |sym,match,block|
+ block.start_document if sym == :start_document or sym.nil?
+ }
+ root = context = []
+ while true
+ event = @parser.pull
+ case event[0]
+ when :end_document
+ handle( :end_document )
+ break
+ when :end_doctype
+ context = context[1]
+ when :start_element
+ @tag_stack.push(event[1])
+ # find the observers for namespaces
+ procs = get_procs( :start_prefix_mapping, event[1] )
+ listeners = get_listeners( :start_prefix_mapping, event[1] )
+ if procs or listeners
+ # break out the namespace declarations
+ # The attributes live in event[2]
+ event[2].each {|n, v| event[2][n] = @parser.normalize(v)}
+ nsdecl = event[2].find_all { |n, value| n =~ /^xmlns(:|$)/ }
+ nsdecl.collect! { |n, value| [ n[6..-1], value ] }
+ @namespace_stack.push({})
+ nsdecl.each do |n,v|
+ @namespace_stack[-1][n] = v
+ # notify observers of namespaces
+ procs.each { |ob| ob.call( n, v ) } if procs
+ listeners.each { |ob| ob.start_prefix_mapping(n, v) } if listeners
+ end
+ end
+ event[1] =~ Namespace::NAMESPLIT
+ prefix = $1
+ local = $2
+ uri = get_namespace(prefix)
+ # find the observers for start_element
+ procs = get_procs( :start_element, event[1] )
+ listeners = get_listeners( :start_element, event[1] )
+ # notify observers
+ procs.each { |ob| ob.call( uri, local, event[1], event[2] ) } if procs
+ listeners.each { |ob|
+ ob.start_element( uri, local, event[1], event[2] )
+ } if listeners
+ when :end_element
+ @tag_stack.pop
+ event[1] =~ Namespace::NAMESPLIT
+ prefix = $1
+ local = $2
+ uri = get_namespace(prefix)
+ # find the observers for start_element
+ procs = get_procs( :end_element, event[1] )
+ listeners = get_listeners( :end_element, event[1] )
+ # notify observers
+ procs.each { |ob| ob.call( uri, local, event[1] ) } if procs
+ listeners.each { |ob|
+ ob.end_element( uri, local, event[1] )
+ } if listeners
+
+ namespace_mapping = @namespace_stack.pop
+ # find the observers for namespaces
+ procs = get_procs( :end_prefix_mapping, event[1] )
+ listeners = get_listeners( :end_prefix_mapping, event[1] )
+ if procs or listeners
+ namespace_mapping.each do |prefix, uri|
+ # notify observers of namespaces
+ procs.each { |ob| ob.call( prefix ) } if procs
+ listeners.each { |ob| ob.end_prefix_mapping(prefix) } if listeners
+ end
+ end
+ when :text
+ normalized = @parser.normalize( event[1] )
+ handle( :characters, normalized )
+ when :processing_instruction, :comment, :doctype, :attlistdecl,
+ :elementdecl, :entitydecl, :cdata, :notationdecl, :xmldecl
+ handle( *event )
+ end
+ end
+ end
+
+ private
+ def handle( symbol, *arguments )
+ tag = @tag_stack[-1]
+ procs = get_procs( symbol, tag )
+ listeners = get_listeners( symbol, tag )
+ # notify observers
+ procs.each { |ob| ob.call( *arguments ) } if procs
+ listeners.each { |l|
+ l.send( symbol.to_s, *arguments )
+ } if listeners
+ end
+
+ # The following methods are duplicates, but it is faster than using
+ # a helper
+ def get_procs( symbol, name )
+ return nil if @procs.size == 0
+ @procs.find_all do |sym, match, block|
+ #puts sym.inspect+"=="+symbol.inspect+ "\t"+match.inspect+"=="+name.inspect+ "\t"+( (sym.nil? or symbol == sym) and ((name.nil? and match.nil?) or match.nil? or ( (name == match) or (match.kind_of? Regexp and name =~ match)))).to_s
+ (
+ (sym.nil? or symbol == sym) and
+ ((name.nil? and match.nil?) or match.nil? or (
+ (name == match) or
+ (match.kind_of? Regexp and name =~ match)
+ )
+ )
+ )
+ end.collect{|x| x[-1]}
+ end
+ def get_listeners( symbol, name )
+ return nil if @listeners.size == 0
+ @listeners.find_all do |sym, match, block|
+ (
+ (sym.nil? or symbol == sym) and
+ ((name.nil? and match.nil?) or match.nil? or (
+ (name == match) or
+ (match.kind_of? Regexp and name =~ match)
+ )
+ )
+ )
+ end.collect{|x| x[-1]}
+ end
+
+ def add( pair )
+ if pair[-1].respond_to? :call
+ @procs << pair unless @procs.include? pair
+ else
+ @listeners << pair unless @listeners.include? pair
+ @has_listeners = true
+ end
+ end
+
+ def get_namespace( prefix )
+ uris = (@namespace_stack.find_all { |ns| not ns[prefix].nil? }) ||
+ (@namespace_stack.find { |ns| not ns[nil].nil? })
+ uris[-1][prefix] unless uris.nil? or 0 == uris.size
+ end
+ end
+ end
+end
diff --git a/lib/rexml/parsers/streamparser.rb b/lib/rexml/parsers/streamparser.rb
new file mode 100644
index 0000000000..357cc186e6
--- /dev/null
+++ b/lib/rexml/parsers/streamparser.rb
@@ -0,0 +1,43 @@
+module REXML
+ module Parsers
+ class StreamParser
+ def initialize source, listener
+ @listener = listener
+ @parser = BaseParser.new( source )
+ end
+
+ def add_listener( listener )
+ @parser.add_listener( listener )
+ end
+
+ def parse
+ # entity string
+ while true
+ event = @parser.pull
+ case event[0]
+ when :end_document
+ return
+ when :start_element
+ attrs = event[2].each do |n, v|
+ event[2][n] = @parser.unnormalize( v )
+ end
+ @listener.tag_start( event[1], attrs )
+ when :end_element
+ @listener.tag_end( event[1] )
+ when :text
+ normalized = @parser.unnormalize( event[1] )
+ @listener.text( normalized )
+ when :processing_instruction
+ @listener.instruction( *event[1,2] )
+ when :start_doctype
+ @listener.doctype( *event[1..-1] )
+ when :notationdecl, :entitydecl, :elementdecl
+ @listener.notationdecl( event[1..-1] )
+ when :comment, :attlistdecl, :elementdecl, :cdata, :xmldecl
+ @listener.send( event[0].to_s, *event[1..-1] )
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/rexml/parsers/treeparser.rb b/lib/rexml/parsers/treeparser.rb
new file mode 100644
index 0000000000..57d11f7e23
--- /dev/null
+++ b/lib/rexml/parsers/treeparser.rb
@@ -0,0 +1,90 @@
+require 'rexml/validation/validationexception'
+
+module REXML
+ module Parsers
+ class TreeParser
+ def initialize( source, build_context = Document.new )
+ @build_context = build_context
+ @parser = Parsers::BaseParser.new( source )
+ end
+
+ def add_listener( listener )
+ @parser.add_listener( listener )
+ end
+
+ def parse
+ tag_stack = []
+ in_doctype = false
+ entities = nil
+ begin
+ while true
+ event = @parser.pull
+ case event[0]
+ when :end_document
+ return
+ when :start_element
+ tag_stack.push(event[1])
+ # find the observers for namespaces
+ @build_context = @build_context.add_element( event[1], event[2] )
+ when :end_element
+ tag_stack.pop
+ @build_context = @build_context.parent
+ when :text
+ if not in_doctype
+ if @build_context[-1].instance_of? Text
+ @build_context[-1] << event[1]
+ else
+ @build_context.add(
+ Text.new( event[1], @build_context.whitespace, nil, true )
+ ) unless (
+ event[1].strip.size==0 and
+ @build_context.ignore_whitespace_nodes
+ )
+ end
+ end
+ when :comment
+ c = Comment.new( event[1] )
+ @build_context.add( c )
+ when :cdata
+ c = CData.new( event[1] )
+ @build_context.add( c )
+ when :processing_instruction
+ @build_context.add( Instruction.new( event[1], event[2] ) )
+ when :end_doctype
+ in_doctype = false
+ entities.each { |k,v| entities[k] = @build_context.entities[k].value }
+ @build_context = @build_context.parent
+ when :start_doctype
+ doctype = DocType.new( event[1..-1], @build_context )
+ @build_context = doctype
+ entities = {}
+ in_doctype = true
+ when :attlistdecl
+ n = AttlistDecl.new( event[1..-1] )
+ @build_context.add( n )
+ when :externalentity
+ n = ExternalEntity.new( event[1] )
+ @build_context.add( n )
+ when :elementdecl
+ n = ElementDecl.new( event[1] )
+ @build_context.add(n)
+ when :entitydecl
+ entities[ event[1] ] = event[2] unless event[2] =~ /PUBLIC|SYSTEM/
+ @build_context.add(Entity.new(event))
+ when :notationdecl
+ n = NotationDecl.new( *event[1..-1] )
+ @build_context.add( n )
+ when :xmldecl
+ x = XMLDecl.new( event[1], event[2], event[3] )
+ @build_context.add( x )
+ end
+ end
+ rescue REXML::Validation::ValidationException
+ raise
+ rescue
+ raise ParseException.new( $!.message, @parser.source, @parser, $! )
+ end
+ end
+ end
+ end
+end
diff --git a/lib/rexml/parsers/ultralightparser.rb b/lib/rexml/parsers/ultralightparser.rb
new file mode 100644
index 0000000000..adc4af18e2
--- /dev/null
+++ b/lib/rexml/parsers/ultralightparser.rb
@@ -0,0 +1,56 @@
+require 'rexml/parsers/streamparser'
+require 'rexml/parsers/baseparser'
+
+module REXML
+ module Parsers
+ class UltraLightParser
+ def initialize stream
+ @stream = stream
+ @parser = REXML::Parsers::BaseParser.new( stream )
+ end
+
+ def add_listener( listener )
+ @parser.add_listener( listener )
+ end
+
+ def rewind
+ @stream.rewind
+ @parser.stream = @stream
+ end
+
+ def parse
+ root = context = []
+ while true
+ event = @parser.pull
+ case event[0]
+ when :end_document
+ break
+ when :end_doctype
+ context = context[1]
+ when :start_element, :doctype
+ context << event
+ event[1,0] = [context]
+ context = event
+ when :end_element
+ context = context[1]
+ else
+ context << event
+ end
+ end
+ root
+ end
+ end
+
+ # An element is an array. The array contains:
+ # 0 The parent element
+ # 1 The tag name
+ # 2 A hash of attributes
+ # 3..-1 The child elements
+ # An element is an array of size > 3
+ # Text is a String
+ # PIs are [ :processing_instruction, target, data ]
+ # Comments are [ :comment, data ]
+ # DocTypes are DocType structs
+ # The root is an array with XMLDecls, Text, DocType, Array, Text
+ end
+end
diff --git a/lib/rexml/parsers/xpathparser.rb b/lib/rexml/parsers/xpathparser.rb
new file mode 100644
index 0000000000..41b2b8a5c1
--- /dev/null
+++ b/lib/rexml/parsers/xpathparser.rb
@@ -0,0 +1,691 @@
+require 'rexml/namespace'
+require 'rexml/xmltokens'
+
+module REXML
+ module Parsers
+ # You don't want to use this class. Really. Use XPath, which is a wrapper
+ # for this class. Believe me. You don't want to poke around in here.
+ # There is strange, dark magic at work in this code. Beware. Go back! Go
+ # back while you still can!
+ class XPathParser
+ include XMLTokens
+ LITERAL = /^'([^']*)'|^"([^"]*)"/u
+
+ def namespaces=( namespaces )
+ Functions::namespace_context = namespaces
+ @namespaces = namespaces
+ end
+
+ def parse path
+ path.gsub!(/([\(\[])\s+/, '\1') # Strip ignorable spaces
+ path.gsub!( /\s+([\]\)])/, '\1' )
+ parsed = []
+ path = LocationPath(path, parsed)
+ parsed
+ end
+
+ def predicate path
+ parsed = []
+ Predicate( "[#{path}]", parsed )
+ parsed
+ end
+
+ def abbreviate( path )
+ path = path.kind_of?(String) ? parse( path ) : path
+ string = ""
+ document = false
+ while path.size > 0
+ op = path.shift
+ case op
+ when :node
+ when :attribute
+ string << "/" if string.size > 0
+ string << "@"
+ when :child
+ string << "/" if string.size > 0
+ when :descendant_or_self
+ string << "/"
+ when :self
+ string << "."
+ when :parent
+ string << ".."
+ when :any
+ string << "*"
+ when :text
+ string << "text()"
+ when :following, :following_sibling,
+ :ancestor, :ancestor_or_self, :descendant,
+ :namespace, :preceding, :preceding_sibling
+ string << "/" unless string.size == 0
+ string << op.to_s.tr("_", "-")
+ string << "::"
+ when :qname
+ prefix = path.shift
+ name = path.shift
+ string << prefix+":" if prefix.size > 0
+ string << name
+ when :predicate
+ string << '['
+ string << predicate_to_string( path.shift ) {|x| abbreviate( x ) }
+ string << ']'
+ when :document
+ document = true
+ when :function
+ string << path.shift
+ string << "( "
+ string << predicate_to_string( path.shift[0] ) {|x| abbreviate( x )}
+ string << " )"
+ when :literal
+ string << %Q{ "#{path.shift}" }
+ else
+ string << "/" unless string.size == 0
+ string << "UNKNOWN("
+ string << op.inspect
+ string << ")"
+ end
+ end
+ string = "/"+string if document
+ return string
+ end
+
+ def expand( path )
+ path = path.kind_of?(String) ? parse( path ) : path
+ string = ""
+ document = false
+ while path.size > 0
+ op = path.shift
+ case op
+ when :node
+ string << "node()"
+ when :attribute, :child, :following, :following_sibling,
+ :ancestor, :ancestor_or_self, :descendant, :descendant_or_self,
+ :namespace, :preceding, :preceding_sibling, :self, :parent
+ string << "/" unless string.size == 0
+ string << op.to_s.tr("_", "-")
+ string << "::"
+ when :any
+ string << "*"
+ when :qname
+ prefix = path.shift
+ name = path.shift
+ string << prefix+":" if prefix.size > 0
+ string << name
+ when :predicate
+ string << '['
+ string << predicate_to_string( path.shift ) { |x| expand(x) }
+ string << ']'
+ when :document
+ document = true
+ else
+ string << "/" unless string.size == 0
+ string << "UNKNOWN("
+ string << op.inspect
+ string << ")"
+ end
+ end
+ string = "/"+string if document
+ return string
+ end
+
+ def predicate_to_string( path, &block )
+ string = ""
+ case path[0]
+ when :and, :or, :mult, :plus, :minus, :neq, :eq, :lt, :gt, :lteq, :gteq, :div, :mod, :union
+ op = path.shift
+ case op
+ when :eq
+ op = "="
+ when :lt
+ op = "<"
+ when :gt
+ op = ">"
+ when :lteq
+ op = "<="
+ when :gteq
+ op = ">="
+ when :neq
+ op = "!="
+ when :union
+ op = "|"
+ end
+ left = predicate_to_string( path.shift, &block )
+ right = predicate_to_string( path.shift, &block )
+ string << " "
+ string << left
+ string << " "
+ string << op.to_s
+ string << " "
+ string << right
+ string << " "
+ when :function
+ path.shift
+ name = path.shift
+ string << name
+ string << "( "
+ string << predicate_to_string( path.shift, &block )
+ string << " )"
+ when :literal
+ path.shift
+ string << " "
+ string << path.shift.inspect
+ string << " "
+ else
+ string << " "
+ string << yield( path )
+ string << " "
+ end
+ return string.squeeze(" ")
+ end
+
+ private
+ #LocationPath
+ # | RelativeLocationPath
+ # | '/' RelativeLocationPath?
+ # | '//' RelativeLocationPath
+ def LocationPath path, parsed
+ #puts "LocationPath '#{path}'"
+ path = path.strip
+ if path[0] == ?/
+ parsed << :document
+ if path[1] == ?/
+ parsed << :descendant_or_self
+ parsed << :node
+ path = path[2..-1]
+ else
+ path = path[1..-1]
+ end
+ end
+ #puts parsed.inspect
+ return RelativeLocationPath( path, parsed ) if path.size > 0
+ end
+
+ #RelativeLocationPath
+ # | Step
+ # | (AXIS_NAME '::' | '@' | '') AxisSpecifier
+ # NodeTest
+ # Predicate
+ # | '.' | '..' AbbreviatedStep
+ # | RelativeLocationPath '/' Step
+ # | RelativeLocationPath '//' Step
+ AXIS = /^(ancestor|ancestor-or-self|attribute|child|descendant|descendant-or-self|following|following-sibling|namespace|parent|preceding|preceding-sibling|self)::/
+ def RelativeLocationPath path, parsed
+ #puts "RelativeLocationPath #{path}"
+ while path.size > 0
+ # (axis or @ or <child::>) nodetest predicate >
+ # OR > / Step
+ # (. or ..) >
+ if path[0] == ?.
+ if path[1] == ?.
+ parsed << :parent
+ parsed << :node
+ path = path[2..-1]
+ else
+ parsed << :self
+ parsed << :node
+ path = path[1..-1]
+ end
+ else
+ if path[0] == ?@
+ #puts "ATTRIBUTE"
+ parsed << :attribute
+ path = path[1..-1]
+ # Goto Nodetest
+ elsif path =~ AXIS
+ parsed << $1.tr('-','_').intern
+ path = $'
+ # Goto Nodetest
+ else
+ parsed << :child
+ end
+
+ #puts "NODETESTING '#{path}'"
+ n = []
+ path = NodeTest( path, n)
+ #puts "NODETEST RETURNED '#{path}'"
+
+ if path[0] == ?[
+ path = Predicate( path, n )
+ end
+
+ parsed.concat(n)
+ end
+
+ if path.size > 0
+ if path[0] == ?/
+ if path[1] == ?/
+ parsed << :descendant_or_self
+ parsed << :node
+ path = path[2..-1]
+ else
+ path = path[1..-1]
+ end
+ else
+ return path
+ end
+ end
+ end
+ return path
+ end
+
+ # Returns a 1-1 map of the nodeset
+ # The contents of the resulting array are either:
+ # true/false, if a positive match
+ # String, if a name match
+ #NodeTest
+ # | ('*' | NCNAME ':' '*' | QNAME) NameTest
+ # | NODE_TYPE '(' ')' NodeType
+ # | PI '(' LITERAL ')' PI
+ # | '[' expr ']' Predicate
+ NCNAMETEST= /^(#{NCNAME_STR}):\*/u
+ QNAME = Namespace::NAMESPLIT
+ NODE_TYPE = /^(comment|text|node)\(\s*\)/m
+ PI = /^processing-instruction\(/
+ def NodeTest path, parsed
+ #puts "NodeTest with #{path}"
+ res = nil
+ case path
+ when /^\*/
+ path = $'
+ parsed << :any
+ when NODE_TYPE
+ type = $1
+ path = $'
+ parsed << type.tr('-', '_').intern
+ when PI
+ path = $'
+ literal = nil
+ if path !~ /^\s*\)/
+ path =~ LITERAL
+ literal = $1
+ path = $'
+ raise ParseException.new("Missing ')' after processing instruction") if path[0] != ?)
+ path = path[1..-1]
+ end
+ parsed << :processing_instruction
+ parsed << literal
+ when NCNAMETEST
+ #puts "NCNAMETEST"
+ prefix = $1
+ path = $'
+ parsed << :namespace
+ parsed << prefix
+ when QNAME
+ #puts "QNAME"
+ prefix = $1
+ name = $2
+ path = $'
+ prefix = "" unless prefix
+ parsed << :qname
+ parsed << prefix
+ parsed << name
+ end
+ return path
+ end
+
+ # Filters the supplied nodeset on the predicate(s)
+ def Predicate path, parsed
+ #puts "PREDICATE with #{path}"
+ return nil unless path[0] == ?[
+ predicates = []
+ while path[0] == ?[
+ path, expr = get_group(path)
+ predicates << expr[1..-2] if expr
+ end
+ #puts "PREDICATES = #{predicates.inspect}"
+ predicates.each{ |expr|
+ #puts "ORING #{expr}"
+ preds = []
+ parsed << :predicate
+ parsed << preds
+ OrExpr(expr, preds)
+ }
+ #puts "PREDICATES = #{predicates.inspect}"
+ path
+ end
+
+ # The following return arrays of true/false, a 1-1 mapping of the
+ # supplied nodeset, except for axe(), which returns a filtered
+ # nodeset
+
+ #| OrExpr S 'or' S AndExpr
+ #| AndExpr
+ def OrExpr path, parsed
+ #puts "OR >>> #{path}"
+ n = []
+ rest = AndExpr( path, n )
+ #puts "OR <<< #{rest}"
+ if rest != path
+ while rest =~ /^\s*( or )/
+ n = [ :or, n, [] ]
+ rest = AndExpr( $', n[-1] )
+ end
+ end
+ if parsed.size == 0 and n.size != 0
+ parsed.replace(n)
+ elsif n.size > 0
+ parsed << n
+ end
+ rest
+ end
+
+ #| AndExpr S 'and' S EqualityExpr
+ #| EqualityExpr
+ def AndExpr path, parsed
+ #puts "AND >>> #{path}"
+ n = []
+ rest = EqualityExpr( path, n )
+ #puts "AND <<< #{rest}"
+ if rest != path
+ while rest =~ /^\s*( and )/
+ n = [ :and, n, [] ]
+ #puts "AND >>> #{rest}"
+ rest = EqualityExpr( $', n[-1] )
+ #puts "AND <<< #{rest}"
+ end
+ end
+ if parsed.size == 0 and n.size != 0
+ parsed.replace(n)
+ elsif n.size > 0
+ parsed << n
+ end
+ rest
+ end
+
+ #| EqualityExpr ('=' | '!=') RelationalExpr
+ #| RelationalExpr
+ def EqualityExpr path, parsed
+ #puts "EQUALITY >>> #{path}"
+ n = []
+ rest = RelationalExpr( path, n )
+ #puts "EQUALITY <<< #{rest}"
+ if rest != path
+ while rest =~ /^\s*(!?=)\s*/
+ if $1[0] == ?!
+ n = [ :neq, n, [] ]
+ else
+ n = [ :eq, n, [] ]
+ end
+ rest = RelationalExpr( $', n[-1] )
+ end
+ end
+ if parsed.size == 0 and n.size != 0
+ parsed.replace(n)
+ elsif n.size > 0
+ parsed << n
+ end
+ rest
+ end
+
+ #| RelationalExpr ('<' | '>' | '<=' | '>=') AdditiveExpr
+ #| AdditiveExpr
+ def RelationalExpr path, parsed
+ #puts "RELATION >>> #{path}"
+ n = []
+ rest = AdditiveExpr( path, n )
+ #puts "RELATION <<< #{rest}"
+ if rest != path
+ while rest =~ /^\s*([<>]=?)\s*/
+ if $1[0] == ?<
+ sym = "lt"
+ else
+ sym = "gt"
+ end
+ sym << "eq" if $1[-1] == ?=
+ n = [ sym.intern, n, [] ]
+ rest = AdditiveExpr( $', n[-1] )
+ end
+ end
+ if parsed.size == 0 and n.size != 0
+ parsed.replace(n)
+ elsif n.size > 0
+ parsed << n
+ end
+ rest
+ end
+
+ #| AdditiveExpr ('+' | S '-') MultiplicativeExpr
+ #| MultiplicativeExpr
+ def AdditiveExpr path, parsed
+ #puts "ADDITIVE >>> #{path}"
+ n = []
+ rest = MultiplicativeExpr( path, n )
+ #puts "ADDITIVE <<< #{rest}"
+ if rest != path
+ while rest =~ /^\s*(\+| -)\s*/
+ if $1[0] == ?+
+ n = [ :plus, n, [] ]
+ else
+ n = [ :minus, n, [] ]
+ end
+ rest = MultiplicativeExpr( $', n[-1] )
+ end
+ end
+ if parsed.size == 0 and n.size != 0
+ parsed.replace(n)
+ elsif n.size > 0
+ parsed << n
+ end
+ rest
+ end
+
+ #| MultiplicativeExpr ('*' | S ('div' | 'mod') S) UnaryExpr
+ #| UnaryExpr
+ def MultiplicativeExpr path, parsed
+ #puts "MULT >>> #{path}"
+ n = []
+ rest = UnaryExpr( path, n )
+ #puts "MULT <<< #{rest}"
+ if rest != path
+ while rest =~ /^\s*(\*| div | mod )\s*/
+ if $1[0] == ?*
+ n = [ :mult, n, [] ]
+ elsif $1.include?( "div" )
+ n = [ :div, n, [] ]
+ else
+ n = [ :mod, n, [] ]
+ end
+ rest = UnaryExpr( $', n[-1] )
+ end
+ end
+ if parsed.size == 0 and n.size != 0
+ parsed.replace(n)
+ elsif n.size > 0
+ parsed << n
+ end
+ rest
+ end
+
+ #| '-' UnaryExpr
+ #| UnionExpr
+ def UnaryExpr path, parsed
+ path =~ /^(\-*)/
+ path = $'
+ if $1 and (($1.size % 2) != 0)
+ mult = -1
+ else
+ mult = 1
+ end
+ parsed << :neg if mult < 0
+
+ #puts "UNARY >>> #{path}"
+ n = []
+ path = UnionExpr( path, n )
+ #puts "UNARY <<< #{path}"
+ parsed.concat( n )
+ path
+ end
+
+ #| UnionExpr '|' PathExpr
+ #| PathExpr
+ def UnionExpr path, parsed
+ #puts "UNION >>> #{path}"
+ n = []
+ rest = PathExpr( path, n )
+ #puts "UNION <<< #{rest}"
+ if rest != path
+ while rest =~ /^\s*(\|)\s*/
+ n = [ :union, n, [] ]
+ rest = PathExpr( $', n[-1] )
+ end
+ end
+ if parsed.size == 0 and n.size != 0
+ parsed.replace( n )
+ elsif n.size > 0
+ parsed << n
+ end
+ rest
+ end
+
+ #| LocationPath
+ #| FilterExpr ('/' | '//') RelativeLocationPath
+ def PathExpr path, parsed
+ path =~ /^\s*/
+ path = $'
+ #puts "PATH >>> #{path}"
+ n = []
+ rest = FilterExpr( path, n )
+ #puts "PATH <<< '#{rest}'"
+ if rest != path
+ if rest and rest[0] == ?/
+ return RelativeLocationPath(rest, n)
+ end
+ end
+ #puts "BEFORE WITH '#{rest}'"
+ rest = LocationPath(rest, n) if rest =~ /^[\/\.\@\[\w_*]/
+ parsed.concat(n)
+ return rest
+ end
+
+ #| FilterExpr Predicate
+ #| PrimaryExpr
+ def FilterExpr path, parsed
+ #puts "FILTER >>> #{path}"
+ n = []
+ path = PrimaryExpr( path, n )
+ #puts "FILTER <<< #{path}"
+ path = Predicate(path, n) if path and path[0] == ?[
+ #puts "FILTER <<< #{path}"
+ parsed.concat(n)
+ path
+ end
+
+ #| VARIABLE_REFERENCE
+ #| '(' expr ')'
+ #| LITERAL
+ #| NUMBER
+ #| FunctionCall
+ VARIABLE_REFERENCE = /^\$(#{NAME_STR})/u
+ NUMBER = /^(\d*\.?\d+)/
+ NT = /^comment|text|processing-instruction|node$/
+ def PrimaryExpr path, parsed
+ arry = []
+ case path
+ when VARIABLE_REFERENCE
+ varname = $1
+ path = $'
+ parsed << :variable
+ parsed << varname
+ #arry << @variables[ varname ]
+ when /^(\w[-\w]*)(?:\()/
+ #puts "PrimaryExpr :: Function >>> #$1 -- '#$''"
+ fname = $1
+ path = $'
+ #puts "#{fname} =~ #{NT.inspect}"
+ #return nil if fname =~ NT
+ parsed << :function
+ parsed << fname
+ path = FunctionCall(path, parsed)
+ when LITERAL, NUMBER
+ #puts "LITERAL or NUMBER: #$1"
+ varname = $1.nil? ? $2 : $1
+ path = $'
+ parsed << :literal
+ parsed << varname
+ when /^\(/ #/
+ path, contents = get_group(path)
+ contents = contents[1..-2]
+ n = []
+ OrExpr( contents, n )
+ parsed.concat(n)
+ end
+ path
+ end
+
+ #| FUNCTION_NAME '(' ( expr ( ',' expr )* )? ')'
+ def FunctionCall rest, parsed
+ path, arguments = parse_args(rest)
+ argset = []
+ for argument in arguments
+ args = []
+ OrExpr( argument, args )
+ argset << args
+ end
+ parsed << argset
+ path
+ end
+
+ # get_group( '[foo]bar' ) -> ['bar', '[foo]']
+ def get_group string
+ ind = 0
+ depth = 0
+ st = string[0,1]
+ en = (st == "(" ? ")" : "]")
+ begin
+ case string[ind,1]
+ when st
+ depth += 1
+ when en
+ depth -= 1
+ end
+ ind += 1
+ end while depth > 0 and ind < string.length
+ return nil unless depth==0
+ [string[ind..-1], string[0..ind-1]]
+ end
+
+ def parse_args( string )
+ arguments = []
+ ind = 0
+ inquot = false
+ inapos = false
+ depth = 1
+ begin
+ case string[ind]
+ when ?"
+ inquot = !inquot unless inapos
+ when ?'
+ inapos = !inapos unless inquot
+ else
+ unless inquot or inapos
+ case string[ind]
+ when ?(
+ depth += 1
+ if depth == 1
+ string = string[1..-1]
+ ind -= 1
+ end
+ when ?)
+ depth -= 1
+ if depth == 0
+ s = string[0,ind].strip
+ arguments << s unless s == ""
+ string = string[ind+1..-1]
+ end
+ when ?,
+ if depth == 1
+ s = string[0,ind].strip
+ arguments << s unless s == ""
+ string = string[ind+1..-1]
+ ind = -1
+ end
+ end
+ end
+ end
+ ind += 1
+ end while depth > 0 and ind < string.length
+ return nil unless depth==0
+ [string,arguments]
+ end
+ end
+ end
+end
diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb
new file mode 100644
index 0000000000..c099db8579
--- /dev/null
+++ b/lib/rexml/quickpath.rb
@@ -0,0 +1,266 @@
+require 'rexml/functions'
+require 'rexml/xmltokens'
+
+module REXML
+ class QuickPath
+ include Functions
+ include XMLTokens
+
+ EMPTY_HASH = {}
+
+ def QuickPath::first element, path, namespaces=EMPTY_HASH
+ match(element, path, namespaces)[0]
+ end
+
+ def QuickPath::each element, path, namespaces=EMPTY_HASH, &block
+ path = "*" unless path
+ match(element, path, namespaces).each( &block )
+ end
+
+ def QuickPath::match element, path, namespaces=EMPTY_HASH
+ raise "nil is not a valid xpath" unless path
+ results = nil
+ Functions::namespace_context = namespaces
+ case path
+ when /^\/([^\/]|$)/u
+ # match on root
+ path = path[1..-1]
+ return [element.root.parent] if path == ''
+ results = filter([element.root], path)
+ when /^[-\w]*::/u
+ results = filter([element], path)
+ when /^\*/u
+ results = filter(element.to_a, path)
+ when /^[\[!\w:]/u
+ # match on child
+ matches = []
+ children = element.to_a
+ results = filter(children, path)
+ else
+ results = filter([element], path)
+ end
+ return results
+ end
+
+ # Given an array of nodes it filters the array based on the path. The
+ # result is that when this method returns, the array will contain elements
+ # which match the path
+ def QuickPath::filter elements, path
+ return elements if path.nil? or path == '' or elements.size == 0
+ case path
+ when /^\/\//u # Descendant
+ return axe( elements, "descendant-or-self", $' )
+ when /^\/?\b(\w[-\w]*)\b::/u # Axe
+ axe_name = $1
+ rest = $'
+ return axe( elements, $1, $' )
+ when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child
+ rest = $'
+ results = []
+ elements.each do |element|
+ results |= filter( element.to_a, rest )
+ end
+ return results
+ when /^\/?(\w[-\w]*)\(/u # / Function
+ return function( elements, $1, $' )
+ when Namespace::NAMESPLIT # Element name
+ name = $2
+ ns = $1
+ rest = $'
+ elements.delete_if do |element|
+ !(element.kind_of? Element and
+ (element.expanded_name == name or
+ (element.name == name and
+ element.namespace == Functions.namespace_context[ns])))
+ end
+ return filter( elements, rest )
+ when /^\/\[/u
+ matches = []
+ elements.each do |element|
+ matches |= predicate( element.to_a, path[1..-1] ) if element.kind_of? Element
+ end
+ return matches
+ when /^\[/u # Predicate
+ return predicate( elements, path )
+ when /^\/?\.\.\./u # Ancestor
+ return axe( elements, "ancestor", $' )
+ when /^\/?\.\./u # Parent
+ return filter( elements.collect{|e|e.parent}, $' )
+ when /^\/?\./u # Self
+ return filter( elements, $' )
+ when /^\*/u # Any
+ results = []
+ elements.each do |element|
+ results |= filter( [element], $' ) if element.kind_of? Element
+ #if element.kind_of? Element
+ # children = element.to_a
+ # children.delete_if { |child| !child.kind_of?(Element) }
+ # results |= filter( children, $' )
+ #end
+ end
+ return results
+ end
+ return []
+ end
+
+ def QuickPath::axe( elements, axe_name, rest )
+ matches = []
+ matches = filter( elements.dup, rest ) if axe_name =~ /-or-self$/u
+ case axe_name
+ when /^descendant/u
+ elements.each do |element|
+ matches |= filter( element.to_a, "descendant-or-self::#{rest}" ) if element.kind_of? Element
+ end
+ when /^ancestor/u
+ elements.each do |element|
+ while element.parent
+ matches << element.parent
+ element = element.parent
+ end
+ end
+ matches = filter( matches, rest )
+ when "self"
+ matches = filter( elements, rest )
+ when "child"
+ elements.each do |element|
+ matches |= filter( element.to_a, rest ) if element.kind_of? Element
+ end
+ when "attribute"
+ elements.each do |element|
+ matches << element.attributes[ rest ] if element.kind_of? Element
+ end
+ when "parent"
+ matches = filter(elements.collect{|element| element.parent}.uniq, rest)
+ when "following-sibling"
+ matches = filter(elements.collect{|element| element.next_sibling}.uniq,
+ rest)
+ when "previous-sibling"
+ matches = filter(elements.collect{|element|
+ element.previous_sibling}.uniq, rest )
+ end
+ return matches.uniq
+ end
+
+ # A predicate filters a node-set with respect to an axis to produce a
+ # new node-set. For each node in the node-set to be filtered, the
+ # PredicateExpr is evaluated with that node as the context node, with
+ # the number of nodes in the node-set as the context size, and with the
+ # proximity position of the node in the node-set with respect to the
+ # axis as the context position; if PredicateExpr evaluates to true for
+ # that node, the node is included in the new node-set; otherwise, it is
+ # not included.
+ #
+ # A PredicateExpr is evaluated by evaluating the Expr and converting
+ # the result to a boolean. If the result is a number, the result will
+ # be converted to true if the number is equal to the context position
+ # and will be converted to false otherwise; if the result is not a
+ # number, then the result will be converted as if by a call to the
+ # boolean function. Thus a location path para[3] is equivalent to
+ # para[position()=3].
+ def QuickPath::predicate( elements, path )
+ ind = 1
+ bcount = 1
+ while bcount > 0
+ bcount += 1 if path[ind] == ?[
+ bcount -= 1 if path[ind] == ?]
+ ind += 1
+ end
+ ind -= 1
+ predicate = path[1..ind-1]
+ rest = path[ind+1..-1]
+
+ # have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c'
+ predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u ) {
+ "#$1 #$2 #$3 and #$3 #$4 #$5"
+ }
+ # Let's do some Ruby trickery to avoid some work:
+ predicate.gsub!( /&/u, "&&" )
+ predicate.gsub!( /=/u, "==" )
+ predicate.gsub!( /@(\w[-\w.]*)/u ) {
+ "attribute(\"#$1\")"
+ }
+ predicate.gsub!( /\bmod\b/u, "%" )
+ predicate.gsub!( /\b(\w[-\w.]*\()/u ) {
+ fname = $1
+ fname.gsub( /-/u, "_" )
+ }
+
+ Functions.pair = [ 0, elements.size ]
+ results = []
+ elements.each do |element|
+ Functions.pair[0] += 1
+ Functions.node = element
+ res = eval( predicate )
+ case res
+ when true
+ results << element
+ when Fixnum
+ results << element if Functions.pair[0] == res
+ when String
+ results << element
+ end
+ end
+ return filter( results, rest )
+ end
+
+ def QuickPath::attribute( name )
+ return Functions.node.attributes[name] if Functions.node.kind_of? Element
+ end
+
+ def QuickPath::name()
+ return Functions.node.name if Functions.node.kind_of? Element
+ end
+
+ def QuickPath::method_missing( id, *args )
+ begin
+ Functions.send( id.id2name, *args )
+ rescue Exception
+ raise "METHOD: #{id.id2name}(#{args.join ', '})\n#{$!.message}"
+ end
+ end
+
+ def QuickPath::function( elements, fname, rest )
+ args = parse_args( elements, rest )
+ Functions.pair = [0, elements.size]
+ results = []
+ elements.each do |element|
+ Functions.pair[0] += 1
+ Functions.node = element
+ res = Functions.send( fname, *args )
+ case res
+ when true
+ results << element
+ when Fixnum
+ results << element if Functions.pair[0] == res
+ end
+ end
+ return results
+ end
+
+ def QuickPath::parse_args( element, string )
+ # /.*?(?:\)|,)/
+ arguments = []
+ buffer = ""
+ while string and string != ""
+ c = string[0]
+ string.sub!(/^./u, "")
+ case c
+ when ?,
+ # if depth = 1, then we start a new argument
+ arguments << evaluate( buffer )
+ #arguments << evaluate( string[0..count] )
+ when ?(
+ # start a new method call
+ function( element, buffer, string )
+ buffer = ""
+ when ?)
+ # close the method call and return arguments
+ return arguments
+ else
+ buffer << c
+ end
+ end
+ ""
+ end
+ end
+end
diff --git a/lib/rexml/rexml.rb b/lib/rexml/rexml.rb
new file mode 100644
index 0000000000..991650e95f
--- /dev/null
+++ b/lib/rexml/rexml.rb
@@ -0,0 +1,26 @@
+# REXML is an XML toolkit for Ruby[http://www.ruby-lang.org], in Ruby.
+#
+# REXML is a _pure_ Ruby, XML 1.0 conforming,
+# non-validating[http://www.w3.org/TR/2004/REC-xml-20040204/#sec-conformance]
+# toolkit with an intuitive API. REXML passes 100% of the non-validating Oasis
+# tests[http://www.oasis-open.org/committees/xml-conformance/xml-test-suite.shtml],
+# and provides tree, stream, SAX2, pull, and lightweight APIs. REXML also
+# includes a full XPath[http://www.w3c.org/tr/xpath] 1.0 implementation. Since
+# Ruby 1.8, REXML is included in the standard Ruby distribution.
+#
+# Main page:: http://www.germane-software.com/software/rexml
+# Author:: Sean Russell <serATgermaneHYPHENsoftwareDOTcom>
+# Date:: +2004/200
+# Version:: 3.1.2.1
+#
+# This API documentation can be downloaded from the REXML home page, or can
+# be accessed online[http://www.germane-software.com/software/rexml_doc]
+#
+# A tutorial is available in the REXML distribution in docs/tutorial.html,
+# or can be accessed
+# online[http://www.germane-software.com/software/rexml/docs/tutorial.html]
+module REXML
+ Copyright = "Copyright © 2001, 2002, 2003, 2004 Sean Russell <ser@germane-software.com>"
+ Date = "+2004/200"
+ Version = "3.1.2.1"
+end
diff --git a/lib/rexml/sax2listener.rb b/lib/rexml/sax2listener.rb
new file mode 100644
index 0000000000..40a77ed464
--- /dev/null
+++ b/lib/rexml/sax2listener.rb
@@ -0,0 +1,94 @@
+module REXML
+ # A template for stream parser listeners.
+ # Note that the declarations (attlistdecl, elementdecl, etc) are trivially
+ # processed; REXML doesn't yet handle doctype entity declarations, so you
+ # have to parse them out yourself.
+ # === Missing methods from SAX2
+ # ignorable_whitespace
+ # === Methods extending SAX2
+ # +WARNING+
+ # These methods are certainly going to change, until DTDs are fully
+ # supported. Be aware of this.
+ # start_document
+ # end_document
+ # doctype
+ # elementdecl
+ # attlistdecl
+ # entitydecl
+ # notationdecl
+ # cdata
+ # xmldecl
+ # comment
+ module SAX2Listener
+ def start_document
+ end
+ def end_document
+ end
+ def start_prefix_mapping prefix, uri
+ end
+ def end_prefix_mapping prefix
+ end
+ def start_element uri, localname, qname, attributes
+ end
+ def end_element uri, localname, qname
+ end
+ def characters text
+ end
+ def processing_instruction target, data
+ end
+ # Handles a doctype declaration. Any attributes of the doctype which are
+ # not supplied will be nil. # EG, <!DOCTYPE me PUBLIC "foo" "bar">
+ # @p name the name of the doctype; EG, "me"
+ # @p pub_sys "PUBLIC", "SYSTEM", or nil. EG, "PUBLIC"
+ # @p long_name the supplied long name, or nil. EG, "foo"
+ # @p uri the uri of the doctype, or nil. EG, "bar"
+ def doctype name, pub_sys, long_name, uri
+ end
+ # If a doctype includes an ATTLIST declaration, it will cause this
+ # method to be called. The content is the declaration itself, unparsed.
+ # EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el
+ # attr CDATA #REQUIRED". This is the same for all of the .*decl
+ # methods.
+ def attlistdecl(element, pairs, contents)
+ end
+ # <!ELEMENT ...>
+ def elementdecl content
+ end
+ # <!ENTITY ...>
+ # The argument passed to this method is an array of the entity
+ # declaration. It can be in a number of formats, but in general it
+ # returns (example, result):
+ # <!ENTITY % YN '"Yes"'>
+ # ["%", "YN", "'\"Yes\"'", "\""]
+ # <!ENTITY % YN 'Yes'>
+ # ["%", "YN", "'Yes'", "s"]
+ # <!ENTITY WhatHeSaid "He said %YN;">
+ # ["WhatHeSaid", "\"He said %YN;\"", "YN"]
+ # <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
+ # ["open-hatch", "SYSTEM", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
+ # <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
+ # ["open-hatch", "PUBLIC", "\"-//Textuality//TEXT Standard open-hatch boilerplate//EN\"", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
+ # <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
+ # ["hatch-pic", "SYSTEM", "\"../grafix/OpenHatch.gif\"", "\n\t\t\t\t\t\t\tNDATA gif", "gif"]
+ def entitydecl content
+ end
+ # <!NOTATION ...>
+ def notationdecl content
+ end
+ # Called when <![CDATA[ ... ]]> is encountered in a document.
+ # @p content "..."
+ def cdata content
+ end
+ # Called when an XML PI is encountered in the document.
+ # EG: <?xml version="1.0" encoding="utf"?>
+ # @p version the version attribute value. EG, "1.0"
+ # @p encoding the encoding attribute value, or nil. EG, "utf"
+ # @p standalone the standalone attribute value, or nil. EG, nil
+ def xmldecl version, encoding, standalone
+ end
+ # Called when a comment is encountered.
+ # @p comment The content of the comment
+ def comment comment
+ end
+ end
+end
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
new file mode 100644
index 0000000000..7251666160
--- /dev/null
+++ b/lib/rexml/source.rb
@@ -0,0 +1,218 @@
+require 'rexml/encoding'
+
+module REXML
+ # Generates Source-s. USE THIS CLASS.
+ class SourceFactory
+ # Generates a Source object
+ # @param arg Either a String, or an IO
+ # @return a Source, or nil if a bad argument was given
+ def SourceFactory::create_from arg#, slurp=true
+ if arg.kind_of? String
+ source = Source.new(arg)
+ elsif arg.kind_of? IO
+ source = IOSource.new(arg)
+ end
+ source
+ end
+ end
+
+ # A Source can be searched for patterns, and wraps buffers and other
+ # objects and provides consumption of text
+ class Source
+ include Encoding
+ # The current buffer (what we're going to read next)
+ attr_reader :buffer
+ # The line number of the last consumed text
+ attr_reader :line
+ attr_reader :encoding
+
+ # Constructor
+ # @param arg must be a String, and should be a valid XML document
+ def initialize(arg)
+ @orig = @buffer = arg
+ self.encoding = check_encoding( @buffer )
+ @line = 0
+ end
+
+ # Inherited from Encoding
+ # Overridden to support optimized en/decoding
+ def encoding=(enc)
+ super
+ @line_break = encode( '>' )
+ if enc != UTF_8
+ @buffer = decode(@buffer)
+ @to_utf = true
+ else
+ @to_utf = false
+ end
+ end
+
+ # Scans the source for a given pattern. Note, that this is not your
+ # usual scan() method. For one thing, the pattern argument has some
+ # requirements; for another, the source can be consumed. You can easily
+ # confuse this method. Originally, the patterns were easier
+ # to construct and this method more robust, because this method
+ # generated search regexes on the fly; however, this was
+ # computationally expensive and slowed down the entire REXML package
+ # considerably, since this is by far the most commonly called method.
+ # @param pattern must be a Regexp, and must be in the form of
+ # /^\s*(#{your pattern, with no groups})(.*)/. The first group
+ # will be returned; the second group is used if the consume flag is
+ # set.
+ # @param consume if true, the pattern returned will be consumed, leaving
+ # everything after it in the Source.
+ # @return the pattern, if found, or nil if the Source is empty or the
+ # pattern is not found.
+ def scan(pattern, cons=false)
+ return nil if @buffer.nil?
+ rv = @buffer.scan(pattern)
+ @buffer = $' if cons and rv.size>0
+ rv
+ end
+
+ def read
+ end
+
+ def consume( pattern )
+ @buffer = $' if pattern.match( @buffer )
+ end
+
+ def match_to( char, pattern )
+ return pattern.match(@buffer)
+ end
+
+ def match_to_consume( char, pattern )
+ md = pattern.match(@buffer)
+ @buffer = $'
+ return md
+ end
+
+ def match(pattern, cons=false)
+ md = pattern.match(@buffer)
+ @buffer = $' if cons and md
+ return md
+ end
+
+ # @return true if the Source is exhausted
+ def empty?
+ @buffer == ""
+ end
+
+ # @return the current line in the source
+ def current_line
+ lines = @orig.split
+ res = lines.grep @buffer[0..30]
+ res = res[-1] if res.kind_of? Array
+ lines.index( res ) if res
+ end
+ end
+
+ # A Source that wraps an IO. See the Source class for method
+ # documentation
+ class IOSource < Source
+ #attr_reader :block_size
+
+ # block_size has been deprecated
+ def initialize(arg, block_size=500)
+ @er_source = @source = arg
+ @to_utf = false
+ # Determining the encoding is a deceptively difficult issue to resolve.
+ # First, we check the first two bytes for UTF-16. Then we
+ # assume that the encoding is at least ASCII enough for the '>', and
+ # we read until we get one of those. This gives us the XML declaration,
+ # if there is one. If there isn't one, the file MUST be UTF-8, as per
+ # the XML spec. If there is one, we can determine the encoding from
+ # it.
+ str = @source.read( 2 )
+ if (str[0] == 254 && str[1] == 255) || (str[0] == 255 && str[1] == 254)
+ @encoding = check_encoding( str )
+ @line_break = encode( '>' )
+ else
+ @line_break = '>'
+ end
+ super str+@source.readline( @line_break )
+ end
+
+ def scan(pattern, cons=false)
+ rv = super
+ # You'll notice that this next section is very similar to the same
+ # section in match(), but just a liiittle different. This is
+ # because it is a touch faster to do it this way with scan()
+ # than the way match() does it; enough faster to warrent duplicating
+ # some code
+ if rv.size == 0
+ until @buffer =~ pattern or @source.nil?
+ begin
+ # READLINE OPT
+ #str = @source.read(@block_size)
+ str = @source.readline(@line_break)
+ str = decode(str) if @to_utf and str
+ @buffer << str
+ rescue
+ @source = nil
+ end
+ end
+ rv = super
+ end
+ rv.taint
+ rv
+ end
+
+ def read
+ begin
+ str = @source.readline(@line_break)
+ str = decode(str) if @to_utf and str
+ @buffer << str
+ rescue Exception, NameError
+ @source = nil
+ end
+ end
+
+ def consume( pattern )
+ match( pattern, true )
+ end
+
+ def match( pattern, cons=false )
+ rv = pattern.match(@buffer)
+ @buffer = $' if cons and rv
+ while !rv and @source
+ begin
+ str = @source.readline(@line_break)
+ str = decode(str) if @to_utf and str
+ @buffer << str
+ rv = pattern.match(@buffer)
+ @buffer = $' if cons and rv
+ rescue
+ @source = nil
+ end
+ end
+ rv.taint
+ rv
+ end
+
+ def empty?
+ super and ( @source.nil? || @source.eof? )
+ end
+
+ # @return the current line in the source
+ def current_line
+ begin
+ pos = @er_source.pos # The byte position in the source
+ lineno = @er_source.lineno # The XML < position in the source
+ @er_source.rewind
+ line = 0 # The \r\n position in the source
+ begin
+ while @er_source.pos < pos
+ @er_source.readline
+ line += 1
+ end
+ rescue
+ end
+ rescue IOError
+ pos = -1
+ line = -1
+ end
+ [pos, lineno, line]
+ end
+ end
+end
diff --git a/lib/rexml/streamlistener.rb b/lib/rexml/streamlistener.rb
new file mode 100644
index 0000000000..3c3c5e3684
--- /dev/null
+++ b/lib/rexml/streamlistener.rb
@@ -0,0 +1,89 @@
+module REXML
+ # A template for stream parser listeners.
+ # Note that the declarations (attlistdecl, elementdecl, etc) are trivially
+ # processed; REXML doesn't yet handle doctype entity declarations, so you
+ # have to parse them out yourself.
+ module StreamListener
+ # Called when a tag is encountered.
+ # @p name the tag name
+ # @p attrs an array of arrays of attribute/value pairs, suitable for
+ # use with assoc or rassoc. IE, <tag attr1="value1" attr2="value2">
+ # will result in
+ # tag_start( "tag", # [["attr1","value1"],["attr2","value2"]])
+ def tag_start name, attrs
+ end
+ # Called when the end tag is reached. In the case of <tag/>, tag_end
+ # will be called immidiately after tag_start
+ # @p the name of the tag
+ def tag_end name
+ end
+ # Called when text is encountered in the document
+ # @p text the text content.
+ def text text
+ end
+ # Called when an instruction is encountered. EG: <?xsl sheet='foo'?>
+ # @p name the instruction name; in the example, "xsl"
+ # @p instruction the rest of the instruction. In the example,
+ # "sheet='foo'"
+ def instruction name, instruction
+ end
+ # Called when a comment is encountered.
+ # @p comment The content of the comment
+ def comment comment
+ end
+ # Handles a doctype declaration. Any attributes of the doctype which are
+ # not supplied will be nil. # EG, <!DOCTYPE me PUBLIC "foo" "bar">
+ # @p name the name of the doctype; EG, "me"
+ # @p pub_sys "PUBLIC", "SYSTEM", or nil. EG, "PUBLIC"
+ # @p long_name the supplied long name, or nil. EG, "foo"
+ # @p uri the uri of the doctype, or nil. EG, "bar"
+ def doctype name, pub_sys, long_name, uri
+ end
+ # If a doctype includes an ATTLIST declaration, it will cause this
+ # method to be called. The content is the declaration itself, unparsed.
+ # EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el
+ # attr CDATA #REQUIRED". This is the same for all of the .*decl
+ # methods.
+ def attlistdecl element_name, attributes, raw_content
+ end
+ # <!ELEMENT ...>
+ def elementdecl content
+ end
+ # <!ENTITY ...>
+ # The argument passed to this method is an array of the entity
+ # declaration. It can be in a number of formats, but in general it
+ # returns (example, result):
+ # <!ENTITY % YN '"Yes"'>
+ # ["%", "YN", "'\"Yes\"'", "\""]
+ # <!ENTITY % YN 'Yes'>
+ # ["%", "YN", "'Yes'", "s"]
+ # <!ENTITY WhatHeSaid "He said %YN;">
+ # ["WhatHeSaid", "\"He said %YN;\"", "YN"]
+ # <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
+ # ["open-hatch", "SYSTEM", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
+ # <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
+ # ["open-hatch", "PUBLIC", "\"-//Textuality//TEXT Standard open-hatch boilerplate//EN\"", "\"http://www.textuality.com/boilerplate/OpenHatch.xml\""]
+ # <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
+ # ["hatch-pic", "SYSTEM", "\"../grafix/OpenHatch.gif\"", "\n\t\t\t\t\t\t\tNDATA gif", "gif"]
+ def entitydecl content
+ end
+ # <!NOTATION ...>
+ def notationdecl content
+ end
+ # Called when %foo; is encountered in a doctype declaration.
+ # @p content "foo"
+ def entity content
+ end
+ # Called when <![CDATA[ ... ]]> is encountered in a document.
+ # @p content "..."
+ def cdata content
+ end
+ # Called when an XML PI is encountered in the document.
+ # EG: <?xml version="1.0" encoding="utf"?>
+ # @p version the version attribute value. EG, "1.0"
+ # @p encoding the encoding attribute value, or nil. EG, "utf"
+ # @p standalone the standalone attribute value, or nil. EG, nil
+ def xmldecl version, encoding, standalone
+ end
+ end
+end
diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb
new file mode 100644
index 0000000000..3e5fcc23b6
--- /dev/null
+++ b/lib/rexml/text.rb
@@ -0,0 +1,336 @@
+require 'rexml/entity'
+require 'rexml/doctype'
+require 'rexml/child'
+require 'rexml/doctype'
+require 'rexml/parseexception'
+
+module REXML
+ # Represents text nodes in an XML document
+ class Text < Child
+ include Comparable
+ # The order in which the substitutions occur
+ SPECIALS = [ /&(?!#?[\w-]+;)/u, /</u, />/u, /"/u, /'/u, /\r/u ]
+ SUBSTITUTES = ['&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#13;']
+ # Characters which are substituted in written strings
+ SLAICEPS = [ '<', '>', '"', "'", '&' ]
+ SETUTITSBUS = [ /&lt;/u, /&gt;/u, /&quot;/u, /&apos;/u, /&amp;/u ]
+
+ # If +raw+ is true, then REXML leaves the value alone
+ attr_accessor :raw
+
+ ILLEGAL = /(<|&(?!(#{Entity::NAME})|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));))/um
+ NUMERICENTITY = /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/
+
+ # Constructor
+ # +arg+ if a String, the content is set to the String. If a Text,
+ # the object is shallowly cloned.
+ #
+ # +respect_whitespace+ (boolean, false) if true, whitespace is
+ # respected
+ #
+ # +parent+ (nil) if this is a Parent object, the parent
+ # will be set to this.
+ #
+ # +raw+ (nil) This argument can be given three values.
+ # If true, then the value of used to construct this object is expected to
+ # contain no unescaped XML markup, and REXML will not change the text. If
+ # this value is false, the string may contain any characters, and REXML will
+ # escape any and all defined entities whose values are contained in the
+ # text. If this value is nil (the default), then the raw value of the
+ # parent will be used as the raw value for this node. If there is no raw
+ # value for the parent, and no value is supplied, the default is false.
+ # Text.new( "<&", false, nil, false ) #-> "&lt;&amp;"
+ # Text.new( "<&", false, nil, true ) #-> IllegalArgumentException
+ # Text.new( "&lt;&amp;", false, nil, true ) #-> "&lt;&amp;"
+ # # Assume that the entity "s" is defined to be "sean"
+ # # and that the entity "r" is defined to be "russell"
+ # Text.new( "sean russell" ) #-> "&s; &r;"
+ # Text.new( "sean russell", false, nil, true ) #-> "sean russell"
+ #
+ # +entity_filter+ (nil) This can be an array of entities to match in the
+ # supplied text. This argument is only useful if +raw+ is set to false.
+ # Text.new( "sean russell", false, nil, false, ["s"] ) #-> "&s; russell"
+ # Text.new( "sean russell", false, nil, true, ["s"] ) #-> "sean russell"
+ # In the last example, the +entity_filter+ argument is ignored.
+ #
+ # +pattern+ INTERNAL USE ONLY
+ def initialize(arg, respect_whitespace=false, parent=nil, raw=nil,
+ entity_filter=nil, illegal=ILLEGAL )
+
+ @raw = false
+
+ if parent
+ super( parent )
+ @raw = parent.raw
+ else
+ @parent = nil
+ end
+
+ @raw = raw unless raw.nil?
+ @entity_filter = entity_filter
+ @normalized = @unnormalized = nil
+
+ if arg.kind_of? String
+ @string = arg.clone
+ @string.squeeze!(" \n\t") unless respect_whitespace
+ elsif arg.kind_of? Text
+ @string = arg.to_s
+ @raw = arg.raw
+ elsif
+ raise Exception.new( "Illegal argument of type #{arg.type} for Text constructor (#{arg})" )
+ end
+
+ @string.gsub!( /\r\n?/, "\n" )
+
+ # check for illegal characters
+ if @raw
+ if @string =~ illegal
+ raise Exception.new(
+ "Illegal character '#{$1}' in raw string \"#{@string}\""
+ )
+ end
+ end
+ end
+
+ def node_type
+ :text
+ end
+
+ def empty?
+ @string.size==0
+ end
+
+
+ def clone
+ return Text.new(self)
+ end
+
+
+ # Appends text to this text node. The text is appended in the +raw+ mode
+ # of this text node.
+ def <<( to_append )
+ @string << to_append.gsub( /\r\n?/, "\n" )
+ end
+
+
+ # +other+ a String or a Text
+ # +returns+ the result of (to_s <=> arg.to_s)
+ def <=>( other )
+ to_s() <=> other.to_s
+ end
+
+ REFERENCE = /#{Entity::REFERENCE}/
+ # Returns the string value of this text node. This string is always
+ # escaped, meaning that it is a valid XML text node string, and all
+ # entities that can be escaped, have been inserted. This method respects
+ # the entity filter set in the constructor.
+ #
+ # # Assume that the entity "s" is defined to be "sean", and that the
+ # # entity "r" is defined to be "russell"
+ # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
+ # t.to_s #-> "&lt; &amp; &s; russell"
+ # t = Text.new( "< & &s; russell", false, nil, false )
+ # t.to_s #-> "&lt; &amp; &s; russell"
+ # u = Text.new( "sean russell", false, nil, true )
+ # u.to_s #-> "sean russell"
+ def to_s
+ return @string if @raw
+ return @normalized if @normalized
+
+ doctype = nil
+ if @parent
+ doc = @parent.document
+ doctype = doc.doctype if doc
+ end
+
+ @normalized = Text::normalize( @string, doctype, @entity_filter )
+ end
+
+ # Returns the string value of this text. This is the text without
+ # entities, as it might be used programmatically, or printed to the
+ # console. This ignores the 'raw' attribute setting, and any
+ # entity_filter.
+ #
+ # # Assume that the entity "s" is defined to be "sean", and that the
+ # # entity "r" is defined to be "russell"
+ # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
+ # t.string #-> "< & sean russell"
+ # t = Text.new( "< & &s; russell", false, nil, false )
+ # t.string #-> "< & sean russell"
+ # u = Text.new( "sean russell", false, nil, true )
+ # u.string #-> "sean russell"
+ def value
+ @unnormalized if @unnormalized
+ doctype = nil
+ if @parent
+ doc = @parent.document
+ doctype = doc.doctype if doc
+ end
+ @unnormalized = Text::unnormalize( @string, doctype )
+ end
+
+ def wrap(string, width, addnewline=false)
+ # Recursivly wrap string at width.
+ return string if string.length <= width
+ place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
+ if addnewline then
+ return "\n" + string[0,place] + "\n" + wrap(string[place+1..-1], width)
+ else
+ return string[0,place] + "\n" + wrap(string[place+1..-1], width)
+ end
+ end
+
+ # Sets the contents of this text node. This expects the text to be
+ # unnormalized. It returns self.
+ #
+ # e = Element.new( "a" )
+ # e.add_text( "foo" ) # <a>foo</a>
+ # e[0].value = "bar" # <a>bar</a>
+ # e[0].value = "<a>" # <a>&lt;a&gt;</a>
+ def value=( val )
+ @string = val.gsub( /\r\n?/, "\n" )
+ @unnormalized = nil
+ @normalized = nil
+ @raw = false
+ end
+
+ def indent_text(string, level=1, style="\t", indentfirstline=true)
+ return string if level < 0
+ new_string = ''
+ string.each { |line|
+ indent_string = style * level
+ new_line = (indent_string + line).sub(/[\s]+$/,'')
+ new_string << new_line
+ }
+ new_string.strip! unless indentfirstline
+ return new_string
+ end
+
+ def write( writer, indent=-1, transitive=false, ie_hack=false )
+ s = to_s()
+ if not (@parent and @parent.whitespace) then
+ s = wrap(s, 60, false) if @parent and @parent.context[:wordwrap] == :all
+ if @parent and not @parent.context[:indentstyle].nil? and indent > 0 and s.count("\n") > 0
+ s = indent_text(s, indent, @parent.context[:indentstyle], false)
+ end
+ s.squeeze!(" \n\t") if @parent and !@parent.whitespace
+ end
+ writer << s
+ end
+
+ # FIXME
+ # This probably won't work properly
+ def xpath
+ path = @parent.xpath
+ path += "/text()"
+ return path
+ end
+
+ # Writes out text, substituting special characters beforehand.
+ # +out+ A String, IO, or any other object supporting <<( String )
+ # +input+ the text to substitute and the write out
+ #
+ # z=utf8.unpack("U*")
+ # ascOut=""
+ # z.each{|r|
+ # if r < 0x100
+ # ascOut.concat(r.chr)
+ # else
+ # ascOut.concat(sprintf("&#x%x;", r))
+ # end
+ # }
+ # puts ascOut
+ def write_with_substitution out, input
+ copy = input.clone
+ # Doing it like this rather than in a loop improves the speed
+ copy.gsub!( SPECIALS[0], SUBSTITUTES[0] )
+ copy.gsub!( SPECIALS[1], SUBSTITUTES[1] )
+ copy.gsub!( SPECIALS[2], SUBSTITUTES[2] )
+ copy.gsub!( SPECIALS[3], SUBSTITUTES[3] )
+ copy.gsub!( SPECIALS[4], SUBSTITUTES[4] )
+ copy.gsub!( SPECIALS[5], SUBSTITUTES[5] )
+ out << copy
+ end
+
+ # Reads text, substituting entities
+ def Text::read_with_substitution( input, illegal=nil )
+ copy = input.clone
+
+ if copy =~ illegal
+ raise ParseException.new( "malformed text: Illegal character #$& in \"#{copy}\"" )
+ end if illegal
+
+ copy.gsub!( /\r\n?/, "\n" )
+ if copy.include? ?&
+ copy.gsub!( SETUTITSBUS[0], SLAICEPS[0] )
+ copy.gsub!( SETUTITSBUS[1], SLAICEPS[1] )
+ copy.gsub!( SETUTITSBUS[2], SLAICEPS[2] )
+ copy.gsub!( SETUTITSBUS[3], SLAICEPS[3] )
+ copy.gsub!( SETUTITSBUS[4], SLAICEPS[4] )
+ copy.gsub!( /&#0*((?:\d+)|(?:x[a-f0-9]+));/ ) {|m|
+ m=$1
+ #m='0' if m==''
+ m = "0#{m}" if m[0] == ?x
+ [Integer(m)].pack('U*')
+ }
+ end
+ copy
+ end
+
+ EREFERENCE = /&(?!#{Entity::NAME};)/
+ # Escapes all possible entities
+ def Text::normalize( input, doctype=nil, entity_filter=nil )
+ copy = input.clone
+ # Doing it like this rather than in a loop improves the speed
+ if doctype
+ copy = copy.gsub( EREFERENCE, '&amp;' )
+ doctype.entities.each_value do |entity|
+ copy = copy.gsub( entity.value,
+ "&#{entity.name};" ) if entity.value and
+ not( entity_filter and entity_filter.include?(entity) )
+ end
+ else
+ copy = copy.gsub( EREFERENCE, '&amp;' )
+ DocType::DEFAULT_ENTITIES.each_value do |entity|
+ copy = copy.gsub(entity.value, "&#{entity.name};" )
+ end
+ end
+ copy
+ end
+
+ # Unescapes all possible entities
+ def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil )
+ rv = string.clone
+ rv.gsub!( /\r\n?/, "\n" )
+ matches = rv.scan( REFERENCE )
+ return rv if matches.size == 0
+ rv.gsub!( NUMERICENTITY ) {|m|
+ m=$1
+ m = "0#{m}" if m[0] == ?x
+ [Integer(m)].pack('U*')
+ }
+ matches.collect!{|x|x[0]}.compact!
+ if matches.size > 0
+ if doctype
+ matches.each do |entity_reference|
+ unless filter and filter.include?(entity_reference)
+ entity_value = doctype.entity( entity_reference )
+ re = /&#{entity_reference};/
+ rv.gsub!( re, entity_value ) if entity_value
+ end
+ end
+ else
+ matches.each do |entity_reference|
+ unless filter and filter.include?(entity_reference)
+ entity_value = DocType::DEFAULT_ENTITIES[ entity_reference ]
+ re = /&#{entity_reference};/
+ rv.gsub!( re, entity_value.value ) if entity_value
+ end
+ end
+ end
+ rv.gsub!( /&amp;/, '&' )
+ end
+ rv
+ end
+ end
+end
diff --git a/lib/rexml/validation/relaxng.rb b/lib/rexml/validation/relaxng.rb
new file mode 100644
index 0000000000..969f51bc95
--- /dev/null
+++ b/lib/rexml/validation/relaxng.rb
@@ -0,0 +1,559 @@
+require "rexml/validation/validation"
+require "rexml/parsers/baseparser"
+
+module REXML
+ module Validation
+ # Implemented:
+ # * empty
+ # * element
+ # * attribute
+ # * text
+ # * optional
+ # * choice
+ # * oneOrMore
+ # * zeroOrMore
+ # * group
+ # * value
+ # * interleave
+ # * mixed
+ # * ref
+ # * grammar
+ # * start
+ # * define
+ #
+ # Not implemented:
+ # * data
+ # * param
+ # * include
+ # * externalRef
+ # * notAllowed
+ # * anyName
+ # * nsName
+ # * except
+ # * name
+ class RelaxNG
+ include Validator
+
+ INFINITY = 1.0 / 0.0
+ EMPTY = Event.new( nil )
+ TEXT = [:start_element, "text"]
+ attr_accessor :current
+ attr_accessor :count
+ attr_reader :references
+
+ # FIXME: Namespaces
+ def initialize source
+ parser = REXML::Parsers::BaseParser.new( source )
+
+ @count = 0
+ @references = {}
+ @root = @current = Sequence.new(self)
+ @root.previous = true
+ states = [ @current ]
+ begin
+ event = parser.pull
+ case event[0]
+ when :start_element
+ case event[1]
+ when "empty"
+ when "element", "attribute", "text", "value"
+ states[-1] << event
+ when "optional"
+ states << Optional.new( self )
+ states[-2] << states[-1]
+ when "choice"
+ states << Choice.new( self )
+ states[-2] << states[-1]
+ when "oneOrMore"
+ states << OneOrMore.new( self )
+ states[-2] << states[-1]
+ when "zeroOrMore"
+ states << ZeroOrMore.new( self )
+ states[-2] << states[-1]
+ when "group"
+ states << Sequence.new( self )
+ states[-2] << states[-1]
+ when "interleave"
+ states << Interleave.new( self )
+ states[-2] << states[-1]
+ when "mixed"
+ states << Interleave.new( self )
+ states[-2] << states[-1]
+ states[-1] << TEXT
+ when "define"
+ states << [ event[2]["name"] ]
+ when "ref"
+ states[-1] << Ref.new( event[2]["name"] )
+ when "anyName"
+ states << AnyName.new( self )
+ states[-2] << states[-1]
+ when "nsName"
+ when "except"
+ when "name"
+ when "data"
+ when "param"
+ when "include"
+ when "grammar"
+ when "start"
+ when "externalRef"
+ when "notAllowed"
+ end
+ when :end_element
+ case event[1]
+ when "element", "attribute"
+ states[-1] << event
+ when "zeroOrMore", "oneOrMore", "choice", "optional",
+ "interleave", "group", "mixed"
+ states.pop
+ when "define"
+ ref = states.pop
+ @references[ ref.shift ] = ref
+ #when "empty"
+ end
+ when :end_document
+ states[-1] << event
+ when :text
+ states[-1] << event
+ end
+ end while event[0] != :end_document
+ end
+
+ def receive event
+ validate( event )
+ end
+ end
+
+ class State
+ def initialize( context )
+ @previous = []
+ @events = []
+ @current = 0
+ @count = context.count += 1
+ @references = context.references
+ @value = false
+ end
+
+ def reset
+ return if @current == 0
+ @current = 0
+ @events.each {|s| s.reset if s.kind_of? State }
+ end
+
+ def previous=( previous )
+ @previous << previous
+ end
+
+ def next( event )
+ #print "In next with #{event.inspect}. "
+ #puts "Next (#@current) is #{@events[@current]}"
+ #p @previous
+ return @previous.pop.next( event ) if @events[@current].nil?
+ expand_ref_in( @events, @current ) if @events[@current].class == Ref
+ if ( @events[@current].kind_of? State )
+ @current += 1
+ @events[@current-1].previous = self
+ return @events[@current-1].next( event )
+ end
+ #puts "Current isn't a state"
+ if ( @events[@current].matches?(event) )
+ @current += 1
+ if @events[@current].nil?
+ #puts "#{inspect[0,5]} 1RETURNING #{@previous.inspect[0,5]}"
+ return @previous.pop
+ elsif @events[@current].kind_of? State
+ @current += 1
+ #puts "#{inspect[0,5]} 2RETURNING (#{@current-1}) #{@events[@current-1].inspect[0,5]}; on return, next is #{@events[@current]}"
+ @events[@current-1].previous = self
+ return @events[@current-1]
+ else
+ #puts "#{inspect[0,5]} RETURNING self w/ next(#@current) = #{@events[@current]}"
+ return self
+ end
+ else
+ return nil
+ end
+ end
+
+ def to_s
+ # Abbreviated:
+ self.class.name =~ /(?:::)(\w)\w+$/
+ # Full:
+ #self.class.name =~ /(?:::)(\w+)$/
+ "#$1.#@count"
+ end
+
+ def inspect
+ "< #{to_s} #{@events.collect{|e|
+ pre = e == @events[@current] ? '#' : ''
+ pre + e.inspect unless self == e
+ }.join(', ')} >"
+ end
+
+ def expected
+ return [@events[@current]]
+ end
+
+ def <<( event )
+ add_event_to_arry( @events, event )
+ end
+
+
+ protected
+ def expand_ref_in( arry, ind )
+ new_events = []
+ @references[ arry[ind].to_s ].each{ |evt|
+ add_event_to_arry(new_events,evt)
+ }
+ arry[ind,1] = new_events
+ end
+
+ def add_event_to_arry( arry, evt )
+ evt = generate_event( evt )
+ if evt.kind_of? String
+ arry[-1].event_arg = evt if arry[-1].kind_of? Event and @value
+ @value = false
+ else
+ arry << evt
+ end
+ end
+
+ def generate_event( event )
+ return event if event.kind_of? State or event.class == Ref
+ evt = nil
+ arg = nil
+ case event[0]
+ when :start_element
+ case event[1]
+ when "element"
+ evt = :start_element
+ arg = event[2]["name"]
+ when "attribute"
+ evt = :start_attribute
+ arg = event[2]["name"]
+ when "text"
+ evt = :text
+ when "value"
+ evt = :text
+ @value = true
+ end
+ when :text
+ return event[1]
+ when :end_document
+ return Event.new( event[0] )
+ else # then :end_element
+ case event[1]
+ when "element"
+ evt = :end_element
+ when "attribute"
+ evt = :end_attribute
+ end
+ end
+ return Event.new( evt, arg )
+ end
+ end
+
+
+ class Sequence < State
+ def matches?(event)
+ @events[@current].matches?( event )
+ end
+ end
+
+
+ class Optional < State
+ def next( event )
+ if @current == 0
+ rv = super
+ return rv if rv
+ @prior = @previous.pop
+ return @prior.next( event )
+ end
+ super
+ end
+
+ def matches?(event)
+ @events[@current].matches?(event) ||
+ (@current == 0 and @previous[-1].matches?(event))
+ end
+
+ def expected
+ return [ @prior.expected, @events[0] ].flatten if @current == 0
+ return [@events[@current]]
+ end
+ end
+
+
+ class ZeroOrMore < Optional
+ def next( event )
+ expand_ref_in( @events, @current ) if @events[@current].class == Ref
+ if ( @events[@current].matches?(event) )
+ @current += 1
+ if @events[@current].nil?
+ @current = 0
+ return self
+ elsif @events[@current].kind_of? State
+ @current += 1
+ @events[@current-1].previous = self
+ return @events[@current-1]
+ else
+ return self
+ end
+ else
+ @prior = @previous.pop
+ return @prior.next( event ) if @current == 0
+ return nil
+ end
+ end
+
+ def expected
+ return [ @prior.expected, @events[0] ].flatten if @current == 0
+ return [@events[@current]]
+ end
+ end
+
+
+ class OneOrMore < State
+ def initialize context
+ super
+ @ord = 0
+ end
+
+ def reset
+ super
+ @ord = 0
+ end
+
+ def next( event )
+ expand_ref_in( @events, @current ) if @events[@current].class == Ref
+ if ( @events[@current].matches?(event) )
+ @current += 1
+ @ord += 1
+ if @events[@current].nil?
+ @current = 0
+ return self
+ elsif @events[@current].kind_of? State
+ @current += 1
+ @events[@current-1].previous = self
+ return @events[@current-1]
+ else
+ return self
+ end
+ else
+ return @previous.pop.next( event ) if @current == 0 and @ord > 0
+ return nil
+ end
+ end
+
+ def matches?( event )
+ @events[@current].matches?(event) ||
+ (@current == 0 and @ord > 0 and @previous[-1].matches?(event))
+ end
+
+ def expected
+ if @current == 0 and @ord > 0
+ return [@previous[-1].expected, @events[0]].flatten
+ else
+ return [@events[@current]]
+ end
+ end
+ end
+
+
+ class Choice < State
+ def initialize context
+ super
+ @choices = []
+ end
+
+ def reset
+ super
+ @events = []
+ @choices.each { |c| c.each { |s| s.reset if s.kind_of? State } }
+ end
+
+ def <<( event )
+ add_event_to_arry( @choices, event )
+ end
+
+ def next( event )
+ # Make the choice if we haven't
+ if @events.size == 0
+ c = 0 ; max = @choices.size
+ while c < max
+ if @choices[c][0].class == Ref
+ expand_ref_in( @choices[c], 0 )
+ @choices += @choices[c]
+ @choices.delete( @choices[c] )
+ max -= 1
+ else
+ c += 1
+ end
+ end
+ @events = @choices.find { |evt| evt[0].matches? event }
+ # Remove the references
+ # Find the events
+ end
+ #puts "In next with #{event.inspect}."
+ #puts "events is #{@events.inspect}"
+ unless @events
+ @events = []
+ return nil
+ end
+ #puts "current = #@current"
+ super
+ end
+
+ def matches?( event )
+ return @events[@current].matches?( event ) if @events.size > 0
+ !@choices.find{|evt| evt[0].matches?(event)}.nil?
+ end
+
+ def expected
+ #puts "IN CHOICE EXPECTED"
+ #puts "EVENTS = #{@events.inspect}"
+ return [@events[@current]] if @events.size > 0
+ return @choices.collect do |x|
+ if x[0].kind_of? State
+ x[0].expected
+ else
+ x[0]
+ end
+ end.flatten
+ end
+
+ def inspect
+ "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' or ')} >"
+ end
+
+ protected
+ def add_event_to_arry( arry, evt )
+ if evt.kind_of? State or evt.class == Ref
+ arry << [evt]
+ elsif evt[0] == :text
+ if arry[-1] and
+ arry[-1][-1].kind_of?( Event ) and
+ arry[-1][-1].event_type == :text and @value
+
+ arry[-1][-1].event_arg = evt[1]
+ @value = false
+ end
+ else
+ arry << [] if evt[0] == :start_element
+ arry[-1] << generate_event( evt )
+ end
+ end
+ end
+
+
+ class Interleave < Choice
+ def initialize context
+ super
+ @choice = 0
+ end
+
+ def reset
+ @choice = 0
+ end
+
+ def next_current( event )
+ # Expand references
+ c = 0 ; max = @choices.size
+ while c < max
+ if @choices[c][0].class == Ref
+ expand_ref_in( @choices[c], 0 )
+ @choices += @choices[c]
+ @choices.delete( @choices[c] )
+ max -= 1
+ else
+ c += 1
+ end
+ end
+ @events = @choices[@choice..-1].find { |evt| evt[0].matches? event }
+ @current = 0
+ if @events
+ # reorder the choices
+ old = @choices[@choice]
+ idx = @choices.index( @events )
+ @choices[@choice] = @events
+ @choices[idx] = old
+ @choice += 1
+ end
+
+ #puts "In next with #{event.inspect}."
+ #puts "events is #{@events.inspect}"
+ @events = [] unless @events
+ end
+
+
+ def next( event )
+ # Find the next series
+ next_current(event) unless @events[@current]
+ return nil unless @events[@current]
+
+ expand_ref_in( @events, @current ) if @events[@current].class == Ref
+ #puts "In next with #{event.inspect}."
+ #puts "Next (#@current) is #{@events[@current]}"
+ if ( @events[@current].kind_of? State )
+ @current += 1
+ @events[@current-1].previous = self
+ return @events[@current-1].next( event )
+ end
+ #puts "Current isn't a state"
+ return @previous.pop.next( event ) if @events[@current].nil?
+ if ( @events[@current].matches?(event) )
+ @current += 1
+ if @events[@current].nil?
+ #puts "#{inspect[0,5]} 1RETURNING self" unless @choices[@choice].nil?
+ return self unless @choices[@choice].nil?
+ #puts "#{inspect[0,5]} 1RETURNING #{@previous[-1].inspect[0,5]}"
+ return @previous.pop
+ elsif @events[@current].kind_of? State
+ @current += 1
+ #puts "#{inspect[0,5]} 2RETURNING (#{@current-1}) #{@events[@current-1].inspect[0,5]}; on return, next is #{@events[@current]}"
+ @events[@current-1].previous = self
+ return @events[@current-1]
+ else
+ #puts "#{inspect[0,5]} RETURNING self w/ next(#@current) = #{@events[@current]}"
+ return self
+ end
+ else
+ return nil
+ end
+ end
+
+ def matches?( event )
+ return @events[@current].matches?( event ) if @events[@current]
+ !@choices[@choice..-1].find{|evt| evt[0].matches?(event)}.nil?
+ end
+
+ def expected
+ #puts "IN CHOICE EXPECTED"
+ #puts "EVENTS = #{@events.inspect}"
+ return [@events[@current]] if @events[@current]
+ return @choices[@choice..-1].collect do |x|
+ if x[0].kind_of? State
+ x[0].expected
+ else
+ x[0]
+ end
+ end.flatten
+ end
+
+ def inspect
+ "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' and ')} >"
+ end
+ end
+
+ class Ref
+ def initialize value
+ @value = value
+ end
+ def to_s
+ @value
+ end
+ def inspect
+ "{#{to_s}}"
+ end
+ end
+ end
+end
diff --git a/lib/rexml/validation/validation.rb b/lib/rexml/validation/validation.rb
new file mode 100644
index 0000000000..fbee315f0b
--- /dev/null
+++ b/lib/rexml/validation/validation.rb
@@ -0,0 +1,152 @@
+require 'rexml/validation/validationexception'
+
+module REXML
+ module Validation
+ module Validator
+ NILEVENT = [ nil ]
+ def reset
+ @current = @root
+ @root.reset
+ @root.previous = true
+ @attr_stack = []
+ self
+ end
+ def dump
+ puts @root.inspect
+ end
+ def validate( event )
+ #puts "Current: #@current"
+ #puts "Event: #{event.inspect}"
+ @attr_stack = [] unless defined? @attr_stack
+ match = @current.next(event)
+ raise ValidationException.new( "Validation error. Expected: "+
+ @current.expected.join( " or " )+" from #{@current.inspect} "+
+ " but got #{Event.new( event[0], event[1] ).inspect}" ) unless match
+ @current = match
+
+ # Check for attributes
+ case event[0]
+ when :start_element
+ #puts "Checking attributes"
+ @attr_stack << event[2]
+ begin
+ sattr = [:start_attribute, nil]
+ eattr = [:end_attribute]
+ text = [:text, nil]
+ k,v = event[2].find { |k,v|
+ sattr[1] = k
+ #puts "Looking for #{sattr.inspect}"
+ m = @current.next( sattr )
+ #puts "Got #{m.inspect}"
+ if m
+ # If the state has text children...
+ #puts "Looking for #{eattr.inspect}"
+ #puts "Expect #{m.expected}"
+ if m.matches?( eattr )
+ #puts "Got end"
+ @current = m
+ else
+ #puts "Didn't get end"
+ text[1] = v
+ #puts "Looking for #{text.inspect}"
+ m = m.next( text )
+ #puts "Got #{m.inspect}"
+ text[1] = nil
+ return false unless m
+ @current = m if m
+ end
+ m = @current.next( eattr )
+ if m
+ @current = m
+ true
+ else
+ false
+ end
+ else
+ false
+ end
+ }
+ event[2].delete(k) if k
+ end while k
+ when :end_element
+ attrs = @attr_stack.pop
+ raise ValidationException.new( "Validation error. Illegal "+
+ " attributes: #{attrs.inspect}") if attrs.length > 0
+ end
+ end
+ end
+
+ class Event
+ def initialize(event_type, event_arg=nil )
+ @event_type = event_type
+ @event_arg = event_arg
+ end
+
+ attr_reader :done?
+ attr_reader :event_type
+ attr_accessor :event_arg
+
+ def single?
+ return (@event_type != :start_element and @event_type != :start_attribute)
+ end
+
+ def matches?( event )
+ #puts "#@event_type =? #{event[0]} && #@event_arg =? #{event[1]} "
+ return false unless event[0] == @event_type
+ case event[0]
+ when nil
+ return true
+ when :start_element
+ return true if event[1] == @event_arg
+ when :end_element
+ return true
+ when :start_attribute
+ return true if event[1] == @event_arg
+ when :end_attribute
+ return true
+ when :end_document
+ return true
+ when :text
+ return (@event_arg.nil? or @event_arg == event[1])
+=begin
+ when :processing_instruction
+ false
+ when :xmldecl
+ false
+ when :start_doctype
+ false
+ when :end_doctype
+ false
+ when :externalentity
+ false
+ when :elementdecl
+ false
+ when :entity
+ false
+ when :attlistdecl
+ false
+ when :notationdecl
+ false
+ when :end_doctype
+ false
+=end
+ else
+ false
+ end
+ end
+
+ def ==( other )
+ return false unless other.kind_of? Event
+ @event_type == other.event_type and @event_arg == other.event_arg
+ end
+
+ def to_s
+ inspect
+ end
+
+ def inspect
+ "#{@event_type.inspect}( #@event_arg )"
+ end
+ end
+ end
+end
diff --git a/lib/rexml/validation/validationexception.rb b/lib/rexml/validation/validationexception.rb
new file mode 100644